Merge from gnus--rel--5.10
[bpt/emacs.git] / 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, 2006 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-mode))
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 'gmm-utils)
42 (require 'mm-decode)
43 (require 'nnoo)
44
45 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
46 (autoload 'gnus-cache-write-active "gnus-cache")
47 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
48 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
49 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
50 (autoload 'mm-uu-dissect "mm-uu")
51 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
52 "Deuglify broken Outlook (Express) articles and redisplay."
53 t)
54 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
55 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
56 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
57
58 (defcustom gnus-kill-summary-on-exit t
59 "*If non-nil, kill the summary buffer when you exit from it.
60 If nil, the summary will become a \"*Dead Summary*\" buffer, and
61 it will be killed sometime later."
62 :group 'gnus-summary-exit
63 :type 'boolean)
64
65 (defcustom gnus-fetch-old-headers nil
66 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
67 If an unread article in the group refers to an older, already read (or
68 just marked as read) article, the old article will not normally be
69 displayed in the Summary buffer. If this variable is t, Gnus
70 will attempt to grab the headers to the old articles, and thereby
71 build complete threads. If it has the value `some', only enough
72 headers to connect otherwise loose threads will be displayed. This
73 variable can also be a number. In that case, no more than that number
74 of old headers will be fetched. If it has the value `invisible', all
75 old headers will be fetched, but none will be displayed.
76
77 The server has to support NOV for any of this to work."
78 :group 'gnus-thread
79 :type '(choice (const :tag "off" nil)
80 (const :tag "on" t)
81 (const some)
82 (const invisible)
83 number
84 (sexp :menu-tag "other" t)))
85
86 (defcustom gnus-refer-thread-limit 200
87 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
88 If t, fetch all the available old headers."
89 :group 'gnus-thread
90 :type '(choice number
91 (sexp :menu-tag "other" t)))
92
93 (defcustom gnus-summary-make-false-root 'adopt
94 "*nil means that Gnus won't gather loose threads.
95 If the root of a thread has expired or been read in a previous
96 session, the information necessary to build a complete thread has been
97 lost. Instead of having many small sub-threads from this original thread
98 scattered all over the summary buffer, Gnus can gather them.
99
100 If non-nil, Gnus will try to gather all loose sub-threads from an
101 original thread into one large thread.
102
103 If this variable is non-nil, it should be one of `none', `adopt',
104 `dummy' or `empty'.
105
106 If this variable is `none', Gnus will not make a false root, but just
107 present the sub-threads after another.
108 If this variable is `dummy', Gnus will create a dummy root that will
109 have all the sub-threads as children.
110 If this variable is `adopt', Gnus will make one of the \"children\"
111 the parent and mark all the step-children as such.
112 If this variable is `empty', the \"children\" are printed with empty
113 subject fields. (Or rather, they will be printed with a string
114 given by the `gnus-summary-same-subject' variable.)"
115 :group 'gnus-thread
116 :type '(choice (const :tag "off" nil)
117 (const none)
118 (const dummy)
119 (const adopt)
120 (const empty)))
121
122 (defcustom gnus-summary-make-false-root-always nil
123 "Always make a false dummy root."
124 :version "22.1"
125 :group 'gnus-thread
126 :type 'boolean)
127
128 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
129 "*A regexp to match subjects to be excluded from loose thread gathering.
130 As loose thread gathering is done on subjects only, that means that
131 there can be many false gatherings performed. By rooting out certain
132 common subjects, gathering might become saner."
133 :group 'gnus-thread
134 :type 'regexp)
135
136 (defcustom gnus-summary-gather-subject-limit nil
137 "*Maximum length of subject comparisons when gathering loose threads.
138 Use nil to compare full subjects. Setting this variable to a low
139 number will help gather threads that have been corrupted by
140 newsreaders chopping off subject lines, but it might also mean that
141 unrelated articles that have subject that happen to begin with the
142 same few characters will be incorrectly gathered.
143
144 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
145 comparing subjects."
146 :group 'gnus-thread
147 :type '(choice (const :tag "off" nil)
148 (const fuzzy)
149 (sexp :menu-tag "on" t)))
150
151 (defcustom gnus-simplify-subject-functions nil
152 "List of functions taking a string argument that simplify subjects.
153 The functions are applied recursively.
154
155 Useful functions to put in this list include:
156 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
157 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
158 :group 'gnus-thread
159 :type '(repeat function))
160
161 (defcustom gnus-simplify-ignored-prefixes nil
162 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
163 :group 'gnus-thread
164 :type '(choice (const :tag "off" nil)
165 regexp))
166
167 (defcustom gnus-build-sparse-threads nil
168 "*If non-nil, fill in the gaps in threads.
169 If `some', only fill in the gaps that are needed to tie loose threads
170 together. If `more', fill in all leaf nodes that Gnus can find. If
171 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
172 :group 'gnus-thread
173 :type '(choice (const :tag "off" nil)
174 (const some)
175 (const more)
176 (sexp :menu-tag "all" t)))
177
178 (defcustom gnus-summary-thread-gathering-function
179 'gnus-gather-threads-by-subject
180 "*Function used for gathering loose threads.
181 There are two pre-defined functions: `gnus-gather-threads-by-subject',
182 which only takes Subjects into consideration; and
183 `gnus-gather-threads-by-references', which compared the References
184 headers of the articles to find matches."
185 :group 'gnus-thread
186 :type '(radio (function-item gnus-gather-threads-by-subject)
187 (function-item gnus-gather-threads-by-references)
188 (function :tag "other")))
189
190 (defcustom gnus-summary-same-subject ""
191 "*String indicating that the current article has the same subject as the previous.
192 This variable will only be used if the value of
193 `gnus-summary-make-false-root' is `empty'."
194 :group 'gnus-summary-format
195 :type 'string)
196
197 (defcustom gnus-summary-goto-unread t
198 "*If t, many commands will go to the next unread article.
199 This applies to marking commands as well as other commands that
200 \"naturally\" select the next article, like, for instance, `SPC' at
201 the end of an article.
202
203 If nil, the marking commands do NOT go to the next unread article
204 \(they go to the next article instead). If `never', commands that
205 usually go to the next unread article, will go to the next article,
206 whether it is read or not."
207 :group 'gnus-summary-marks
208 :link '(custom-manual "(gnus)Setting Marks")
209 :type '(choice (const :tag "off" nil)
210 (const never)
211 (sexp :menu-tag "on" t)))
212
213 (defcustom gnus-summary-default-score 0
214 "*Default article score level.
215 All scores generated by the score files will be added to this score.
216 If this variable is nil, scoring will be disabled."
217 :group 'gnus-score-default
218 :type '(choice (const :tag "disable")
219 integer))
220
221 (defcustom gnus-summary-default-high-score 0
222 "*Default threshold for a high scored article.
223 An article will be highlighted as high scored if its score is greater
224 than this score."
225 :version "22.1"
226 :group 'gnus-score-default
227 :type 'integer)
228
229 (defcustom gnus-summary-default-low-score 0
230 "*Default threshold for a low scored article.
231 An article will be highlighted as low scored if its score is smaller
232 than this score."
233 :version "22.1"
234 :group 'gnus-score-default
235 :type 'integer)
236
237 (defcustom gnus-summary-zcore-fuzz 0
238 "*Fuzziness factor for the zcore in the summary buffer.
239 Articles with scores closer than this to `gnus-summary-default-score'
240 will not be marked."
241 :group 'gnus-summary-format
242 :type 'integer)
243
244 (defcustom gnus-simplify-subject-fuzzy-regexp nil
245 "*Strings to be removed when doing fuzzy matches.
246 This can either be a regular expression or list of regular expressions
247 that will be removed from subject strings if fuzzy subject
248 simplification is selected."
249 :group 'gnus-thread
250 :type '(repeat regexp))
251
252 (defcustom gnus-show-threads t
253 "*If non-nil, display threads in summary mode."
254 :group 'gnus-thread
255 :type 'boolean)
256
257 (defcustom gnus-thread-hide-subtree nil
258 "*If non-nil, hide all threads initially.
259 This can be a predicate specifier which says which threads to hide.
260 If threads are hidden, you have to run the command
261 `gnus-summary-show-thread' by hand or select an article."
262 :group 'gnus-thread
263 :type '(radio (sexp :format "Non-nil\n"
264 :match (lambda (widget value)
265 (not (or (consp value) (functionp value))))
266 :value t)
267 (const nil)
268 (sexp :tag "Predicate specifier")))
269
270 (defcustom gnus-thread-hide-killed t
271 "*If non-nil, hide killed threads automatically."
272 :group 'gnus-thread
273 :type 'boolean)
274
275 (defcustom gnus-thread-ignore-subject t
276 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
277 If nil, articles that have different subjects from their parents will
278 start separate threads."
279 :group 'gnus-thread
280 :type 'boolean)
281
282 (defcustom gnus-thread-operation-ignore-subject t
283 "*If non-nil, subjects will be ignored when doing thread commands.
284 This affects commands like `gnus-summary-kill-thread' and
285 `gnus-summary-lower-thread'.
286
287 If this variable is nil, articles in the same thread with different
288 subjects will not be included in the operation in question. If this
289 variable is `fuzzy', only articles that have subjects that are fuzzily
290 equal will be included."
291 :group 'gnus-thread
292 :type '(choice (const :tag "off" nil)
293 (const fuzzy)
294 (sexp :tag "on" t)))
295
296 (defcustom gnus-thread-indent-level 4
297 "*Number that says how much each sub-thread should be indented."
298 :group 'gnus-thread
299 :type 'integer)
300
301 (defcustom gnus-auto-extend-newsgroup t
302 "*If non-nil, extend newsgroup forward and backward when requested."
303 :group 'gnus-summary-choose
304 :type 'boolean)
305
306 (defcustom gnus-auto-select-first t
307 "*If non-nil, select the article under point.
308 Which article this is is controlled by the `gnus-auto-select-subject'
309 variable.
310
311 If you want to prevent automatic selection of articles in some
312 newsgroups, set the variable to nil in `gnus-select-group-hook'."
313 :group 'gnus-group-select
314 :type '(choice (const :tag "none" nil)
315 (sexp :menu-tag "first" t)))
316
317 (defcustom gnus-auto-select-subject 'unread
318 "*Says what subject to place under point when entering a group.
319
320 This variable can either be the symbols `first' (place point on the
321 first subject), `unread' (place point on the subject line of the first
322 unread article), `best' (place point on the subject line of the
323 higest-scored article), `unseen' (place point on the subject line of
324 the first unseen article), `unseen-or-unread' (place point on the subject
325 line of the first unseen article or, if all article have been seen, on the
326 subject line of the first unread article), or a function to be called to
327 place point on some subject line."
328 :version "22.1"
329 :group 'gnus-group-select
330 :type '(choice (const best)
331 (const unread)
332 (const first)
333 (const unseen)
334 (const unseen-or-unread)))
335
336 (defcustom gnus-auto-select-next t
337 "*If non-nil, offer to go to the next group from the end of the previous.
338 If the value is t and the next newsgroup is empty, Gnus will exit
339 summary mode and go back to group mode. If the value is neither nil
340 nor t, Gnus will select the following unread newsgroup. In
341 particular, if the value is the symbol `quietly', the next unread
342 newsgroup will be selected without any confirmation, and if it is
343 `almost-quietly', the next group will be selected without any
344 confirmation if you are located on the last article in the group.
345 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
346 will go to the next group without confirmation."
347 :group 'gnus-summary-maneuvering
348 :type '(choice (const :tag "off" nil)
349 (const quietly)
350 (const almost-quietly)
351 (const slightly-quietly)
352 (sexp :menu-tag "on" t)))
353
354 (defcustom gnus-auto-select-same nil
355 "*If non-nil, select the next article with the same subject.
356 If there are no more articles with the same subject, go to
357 the first unread article."
358 :group 'gnus-summary-maneuvering
359 :type 'boolean)
360
361 (defcustom gnus-auto-goto-ignores 'unfetched
362 "*Says how to handle unfetched articles when maneuvering.
363
364 This variable can either be the symbols nil (maneuver to any
365 article), `undownloaded' (maneuvering while unplugged ignores articles
366 that have not been fetched), `always-undownloaded' (maneuvering always
367 ignores articles that have not been fetched), `unfetched' (maneuvering
368 ignores articles whose headers have not been fetched).
369
370 NOTE: The list of unfetched articles will always be nil when plugged
371 and, when unplugged, a subset of the undownloaded article list."
372 :version "22.1"
373 :group 'gnus-summary-maneuvering
374 :type '(choice (const :tag "None" nil)
375 (const :tag "Undownloaded when unplugged" undownloaded)
376 (const :tag "Undownloaded" always-undownloaded)
377 (const :tag "Unfetched" unfetched)))
378
379 (defcustom gnus-summary-check-current nil
380 "*If non-nil, consider the current article when moving.
381 The \"unread\" movement commands will stay on the same line if the
382 current article is unread."
383 :group 'gnus-summary-maneuvering
384 :type 'boolean)
385
386 (defcustom gnus-auto-center-summary t
387 "*If non-nil, always center the current summary buffer.
388 In particular, if `vertical' do only vertical recentering. If non-nil
389 and non-`vertical', do both horizontal and vertical recentering."
390 :group 'gnus-summary-maneuvering
391 :type '(choice (const :tag "none" nil)
392 (const vertical)
393 (integer :tag "height")
394 (sexp :menu-tag "both" t)))
395
396 (defvar gnus-auto-center-group t
397 "*If non-nil, always center the group buffer.")
398
399 (defcustom gnus-show-all-headers nil
400 "*If non-nil, don't hide any headers."
401 :group 'gnus-article-hiding
402 :group 'gnus-article-headers
403 :type 'boolean)
404
405 (defcustom gnus-summary-ignore-duplicates nil
406 "*If non-nil, ignore articles with identical Message-ID headers."
407 :group 'gnus-summary
408 :type 'boolean)
409
410 (defcustom gnus-single-article-buffer t
411 "*If non-nil, display all articles in the same buffer.
412 If nil, each group will get its own article buffer."
413 :group 'gnus-article-various
414 :type 'boolean)
415
416 (defcustom gnus-break-pages t
417 "*If non-nil, do page breaking on articles.
418 The page delimiter is specified by the `gnus-page-delimiter'
419 variable."
420 :group 'gnus-article-various
421 :type 'boolean)
422
423 (defcustom gnus-move-split-methods nil
424 "*Variable used to suggest where articles are to be moved to.
425 It uses the same syntax as the `gnus-split-methods' variable.
426 However, whereas `gnus-split-methods' specifies file names as targets,
427 this variable specifies group names."
428 :group 'gnus-summary-mail
429 :type '(repeat (choice (list :value (fun) function)
430 (cons :value ("" "") regexp (repeat string))
431 (sexp :value nil))))
432
433 ;; FIXME: Although the custom type is `character' for the following variables,
434 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
435
436 (defcustom gnus-unread-mark ? ;Whitespace
437 "*Mark used for unread articles."
438 :group 'gnus-summary-marks
439 :type 'character)
440
441 (defcustom gnus-ticked-mark ?!
442 "*Mark used for ticked articles."
443 :group 'gnus-summary-marks
444 :type 'character)
445
446 (defcustom gnus-dormant-mark ??
447 "*Mark used for dormant articles."
448 :group 'gnus-summary-marks
449 :type 'character)
450
451 (defcustom gnus-del-mark ?r
452 "*Mark used for del'd articles."
453 :group 'gnus-summary-marks
454 :type 'character)
455
456 (defcustom gnus-read-mark ?R
457 "*Mark used for read articles."
458 :group 'gnus-summary-marks
459 :type 'character)
460
461 (defcustom gnus-expirable-mark ?E
462 "*Mark used for expirable articles."
463 :group 'gnus-summary-marks
464 :type 'character)
465
466 (defcustom gnus-killed-mark ?K
467 "*Mark used for killed articles."
468 :group 'gnus-summary-marks
469 :type 'character)
470
471 (defcustom gnus-spam-mark ?$
472 "*Mark used for spam articles."
473 :version "22.1"
474 :group 'gnus-summary-marks
475 :type 'character)
476
477 (defcustom gnus-souped-mark ?F
478 "*Mark used for souped articles."
479 :group 'gnus-summary-marks
480 :type 'character)
481
482 (defcustom gnus-kill-file-mark ?X
483 "*Mark used for articles killed by kill files."
484 :group 'gnus-summary-marks
485 :type 'character)
486
487 (defcustom gnus-low-score-mark ?Y
488 "*Mark used for articles with a low score."
489 :group 'gnus-summary-marks
490 :type 'character)
491
492 (defcustom gnus-catchup-mark ?C
493 "*Mark used for articles that are caught up."
494 :group 'gnus-summary-marks
495 :type 'character)
496
497 (defcustom gnus-replied-mark ?A
498 "*Mark used for articles that have been replied to."
499 :group 'gnus-summary-marks
500 :type 'character)
501
502 (defcustom gnus-forwarded-mark ?F
503 "*Mark used for articles that have been forwarded."
504 :version "22.1"
505 :group 'gnus-summary-marks
506 :type 'character)
507
508 (defcustom gnus-recent-mark ?N
509 "*Mark used for articles that are recent."
510 :version "22.1"
511 :group 'gnus-summary-marks
512 :type 'character)
513
514 (defcustom gnus-cached-mark ?*
515 "*Mark used for articles that are in the cache."
516 :group 'gnus-summary-marks
517 :type 'character)
518
519 (defcustom gnus-saved-mark ?S
520 "*Mark used for articles that have been saved."
521 :group 'gnus-summary-marks
522 :type 'character)
523
524 (defcustom gnus-unseen-mark ?.
525 "*Mark used for articles that haven't been seen."
526 :version "22.1"
527 :group 'gnus-summary-marks
528 :type 'character)
529
530 (defcustom gnus-no-mark ? ;Whitespace
531 "*Mark used for articles that have no other secondary mark."
532 :version "22.1"
533 :group 'gnus-summary-marks
534 :type 'character)
535
536 (defcustom gnus-ancient-mark ?O
537 "*Mark used for ancient articles."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541 (defcustom gnus-sparse-mark ?Q
542 "*Mark used for sparsely reffed articles."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546 (defcustom gnus-canceled-mark ?G
547 "*Mark used for canceled articles."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551 (defcustom gnus-duplicate-mark ?M
552 "*Mark used for duplicate articles."
553 :group 'gnus-summary-marks
554 :type 'character)
555
556 (defcustom gnus-undownloaded-mark ?-
557 "*Mark used for articles that weren't downloaded."
558 :version "22.1"
559 :group 'gnus-summary-marks
560 :type 'character)
561
562 (defcustom gnus-downloaded-mark ?+
563 "*Mark used for articles that were downloaded."
564 :group 'gnus-summary-marks
565 :type 'character)
566
567 (defcustom gnus-downloadable-mark ?%
568 "*Mark used for articles that are to be downloaded."
569 :group 'gnus-summary-marks
570 :type 'character)
571
572 (defcustom gnus-unsendable-mark ?=
573 "*Mark used for articles that won't be sent."
574 :group 'gnus-summary-marks
575 :type 'character)
576
577 (defcustom gnus-score-over-mark ?+
578 "*Score mark used for articles with high scores."
579 :group 'gnus-summary-marks
580 :type 'character)
581
582 (defcustom gnus-score-below-mark ?-
583 "*Score mark used for articles with low scores."
584 :group 'gnus-summary-marks
585 :type 'character)
586
587 (defcustom gnus-empty-thread-mark ? ;Whitespace
588 "*There is no thread under the article."
589 :group 'gnus-summary-marks
590 :type 'character)
591
592 (defcustom gnus-not-empty-thread-mark ?=
593 "*There is a thread under the article."
594 :group 'gnus-summary-marks
595 :type 'character)
596
597 (defcustom gnus-view-pseudo-asynchronously nil
598 "*If non-nil, Gnus will view pseudo-articles asynchronously."
599 :group 'gnus-extract-view
600 :type 'boolean)
601
602 (defcustom gnus-auto-expirable-marks
603 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
604 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
605 gnus-souped-mark gnus-duplicate-mark)
606 "*The list of marks converted into expiration if a group is auto-expirable."
607 :version "21.1"
608 :group 'gnus-summary
609 :type '(repeat character))
610
611 (defcustom gnus-inhibit-user-auto-expire t
612 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
613 :version "21.1"
614 :group 'gnus-summary
615 :type 'boolean)
616
617 (defcustom gnus-view-pseudos nil
618 "*If `automatic', pseudo-articles will be viewed automatically.
619 If `not-confirm', pseudos will be viewed automatically, and the user
620 will not be asked to confirm the command."
621 :group 'gnus-extract-view
622 :type '(choice (const :tag "off" nil)
623 (const automatic)
624 (const not-confirm)))
625
626 (defcustom gnus-view-pseudos-separately t
627 "*If non-nil, one pseudo-article will be created for each file to be viewed.
628 If nil, all files that use the same viewing command will be given as a
629 list of parameters to that command."
630 :group 'gnus-extract-view
631 :type 'boolean)
632
633 (defcustom gnus-insert-pseudo-articles t
634 "*If non-nil, insert pseudo-articles when decoding articles."
635 :group 'gnus-extract-view
636 :type 'boolean)
637
638 (defcustom gnus-summary-dummy-line-format
639 " %(: :%) %S\n"
640 "*The format specification for the dummy roots in the summary buffer.
641 It works along the same lines as a normal formatting string,
642 with some simple extensions.
643
644 %S The subject
645
646 General format specifiers can also be used.
647 See `(gnus)Formatting Variables'."
648 :link '(custom-manual "(gnus)Formatting Variables")
649 :group 'gnus-threading
650 :type 'string)
651
652 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
653 "*The format specification for the summary mode line.
654 It works along the same lines as a normal formatting string,
655 with some simple extensions:
656
657 %G Group name
658 %p Unprefixed group name
659 %A Current article number
660 %z Current article score
661 %V Gnus version
662 %U Number of unread articles in the group
663 %e Number of unselected articles in the group
664 %Z A string with unread/unselected article counts
665 %g Shortish group name
666 %S Subject of the current article
667 %u User-defined spec
668 %s Current score file name
669 %d Number of dormant articles
670 %r Number of articles that have been marked as read in this session
671 %E Number of articles expunged by the score files"
672 :group 'gnus-summary-format
673 :type 'string)
674
675 (defcustom gnus-list-identifiers nil
676 "Regexp that matches list identifiers to be removed from subject.
677 This can also be a list of regexps."
678 :version "21.1"
679 :group 'gnus-summary-format
680 :group 'gnus-article-hiding
681 :type '(choice (const :tag "none" nil)
682 (regexp :value ".*")
683 (repeat :value (".*") regexp)))
684
685 (defcustom gnus-summary-mark-below 0
686 "*Mark all articles with a score below this variable as read.
687 This variable is local to each summary buffer and usually set by the
688 score file."
689 :group 'gnus-score-default
690 :type 'integer)
691
692 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
693 "*List of functions used for sorting articles in the summary buffer.
694
695 Each function takes two articles and returns non-nil if the first
696 article should be sorted before the other. If you use more than one
697 function, the primary sort function should be the last. You should
698 probably always include `gnus-article-sort-by-number' in the list of
699 sorting functions -- preferably first. Also note that sorting by date
700 is often much slower than sorting by number, and the sorting order is
701 very similar. (Sorting by date means sorting by the time the message
702 was sent, sorting by number means sorting by arrival time.)
703
704 Ready-made functions include `gnus-article-sort-by-number',
705 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
706 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
707 and `gnus-article-sort-by-score'.
708
709 When threading is turned on, the variable `gnus-thread-sort-functions'
710 controls how articles are sorted."
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-article-sort-by-number)
713 (function-item gnus-article-sort-by-author)
714 (function-item gnus-article-sort-by-subject)
715 (function-item gnus-article-sort-by-date)
716 (function-item gnus-article-sort-by-score)
717 (function-item gnus-article-sort-by-random)
718 (function :tag "other"))))
719
720 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
721 "*List of functions used for sorting threads in the summary buffer.
722 By default, threads are sorted by article number.
723
724 Each function takes two threads and returns non-nil if the first
725 thread should be sorted before the other. If you use more than one
726 function, the primary sort function should be the last. You should
727 probably always include `gnus-thread-sort-by-number' in the list of
728 sorting functions -- preferably first. Also note that sorting by date
729 is often much slower than sorting by number, and the sorting order is
730 very similar. (Sorting by date means sorting by the time the message
731 was sent, sorting by number means sorting by arrival time.)
732
733 Ready-made functions include `gnus-thread-sort-by-number',
734 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
735 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
736 `gnus-thread-sort-by-most-recent-number',
737 `gnus-thread-sort-by-most-recent-date',
738 `gnus-thread-sort-by-random', and
739 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
740
741 When threading is turned off, the variable
742 `gnus-article-sort-functions' controls how articles are sorted."
743 :group 'gnus-summary-sort
744 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
745 (function-item gnus-thread-sort-by-author)
746 (function-item gnus-thread-sort-by-subject)
747 (function-item gnus-thread-sort-by-date)
748 (function-item gnus-thread-sort-by-score)
749 (function-item gnus-thread-sort-by-total-score)
750 (function-item gnus-thread-sort-by-random)
751 (function :tag "other"))))
752
753 (defcustom gnus-thread-score-function '+
754 "*Function used for calculating the total score of a thread.
755
756 The function is called with the scores of the article and each
757 subthread and should then return the score of the thread.
758
759 Some functions you can use are `+', `max', or `min'."
760 :group 'gnus-summary-sort
761 :type 'function)
762
763 (defcustom gnus-summary-expunge-below nil
764 "All articles that have a score less than this variable will be expunged.
765 This variable is local to the summary buffers."
766 :group 'gnus-score-default
767 :type '(choice (const :tag "off" nil)
768 integer))
769
770 (defcustom gnus-thread-expunge-below nil
771 "All threads that have a total score less than this variable will be expunged.
772 See `gnus-thread-score-function' for en explanation of what a
773 \"thread score\" is.
774
775 This variable is local to the summary buffers."
776 :group 'gnus-threading
777 :group 'gnus-score-default
778 :type '(choice (const :tag "off" nil)
779 integer))
780
781 (defcustom gnus-summary-mode-hook nil
782 "*A hook for Gnus summary mode.
783 This hook is run before any variables are set in the summary buffer."
784 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
785 :group 'gnus-summary-various
786 :type 'hook)
787
788 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
789 (when (featurep 'xemacs)
790 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
791 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
792 (add-hook 'gnus-summary-mode-hook
793 'gnus-xmas-switch-horizontal-scrollbar-off))
794
795 (defcustom gnus-summary-menu-hook nil
796 "*Hook run after the creation of the summary mode menu."
797 :group 'gnus-summary-visual
798 :type 'hook)
799
800 (defcustom gnus-summary-exit-hook nil
801 "*A hook called on exit from the summary buffer.
802 It will be called with point in the group buffer."
803 :group 'gnus-summary-exit
804 :type 'hook)
805
806 (defcustom gnus-summary-prepare-hook nil
807 "*A hook called after the summary buffer has been generated.
808 If you want to modify the summary buffer, you can use this hook."
809 :group 'gnus-summary-various
810 :type 'hook)
811
812 (defcustom gnus-summary-prepared-hook nil
813 "*A hook called as the last thing after the summary buffer has been generated."
814 :group 'gnus-summary-various
815 :type 'hook)
816
817 (defcustom gnus-summary-generate-hook nil
818 "*A hook run just before generating the summary buffer.
819 This hook is commonly used to customize threading variables and the
820 like."
821 :group 'gnus-summary-various
822 :type 'hook)
823
824 (defcustom gnus-select-group-hook nil
825 "*A hook called when a newsgroup is selected.
826
827 If you'd like to simplify subjects like the
828 `gnus-summary-next-same-subject' command does, you can use the
829 following hook:
830
831 (add-hook gnus-select-group-hook
832 (lambda ()
833 (mapcar (lambda (header)
834 (mail-header-set-subject
835 header
836 (gnus-simplify-subject
837 (mail-header-subject header) 're-only)))
838 gnus-newsgroup-headers)))"
839 :group 'gnus-group-select
840 :type 'hook)
841
842 (defcustom gnus-select-article-hook nil
843 "*A hook called when an article is selected."
844 :group 'gnus-summary-choose
845 :options '(gnus-agent-fetch-selected-article)
846 :type 'hook)
847
848 (defcustom gnus-visual-mark-article-hook
849 (list 'gnus-highlight-selected-summary)
850 "*Hook run after selecting an article in the summary buffer.
851 It is meant to be used for highlighting the article in some way. It
852 is not run if `gnus-visual' is nil."
853 :group 'gnus-summary-visual
854 :type 'hook)
855
856 (defcustom gnus-parse-headers-hook nil
857 "*A hook called before parsing the headers."
858 :group 'gnus-various
859 :type 'hook)
860
861 (defcustom gnus-exit-group-hook nil
862 "*A hook called when exiting summary mode.
863 This hook is not called from the non-updating exit commands like `Q'."
864 :group 'gnus-various
865 :type 'hook)
866
867 (defcustom gnus-summary-update-hook
868 (list 'gnus-summary-highlight-line)
869 "*A hook called when a summary line is changed.
870 The hook will not be called if `gnus-visual' is nil.
871
872 The default function `gnus-summary-highlight-line' will
873 highlight the line according to the `gnus-summary-highlight'
874 variable."
875 :group 'gnus-summary-visual
876 :type 'hook)
877
878 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
879 "*A hook called when an article is selected for the first time.
880 The hook is intended to mark an article as read (or unread)
881 automatically when it is selected."
882 :group 'gnus-summary-choose
883 :type 'hook)
884
885 (defcustom gnus-group-no-more-groups-hook nil
886 "*A hook run when returning to group mode having no more (unread) groups."
887 :group 'gnus-group-select
888 :type 'hook)
889
890 (defcustom gnus-ps-print-hook nil
891 "*A hook run before ps-printing something from Gnus."
892 :group 'gnus-summary
893 :type 'hook)
894
895 (defcustom gnus-summary-article-move-hook nil
896 "*A hook called after an article is moved, copied, respooled, or crossposted."
897 :version "22.1"
898 :group 'gnus-summary
899 :type 'hook)
900
901 (defcustom gnus-summary-article-delete-hook nil
902 "*A hook called after an article is deleted."
903 :version "22.1"
904 :group 'gnus-summary
905 :type 'hook)
906
907 (defcustom gnus-summary-article-expire-hook nil
908 "*A hook called after an article is expired."
909 :version "22.1"
910 :group 'gnus-summary
911 :type 'hook)
912
913 (defcustom gnus-summary-display-arrow
914 (and (fboundp 'display-graphic-p)
915 (display-graphic-p))
916 "*If non-nil, display an arrow highlighting the current article."
917 :version "22.1"
918 :group 'gnus-summary
919 :type 'boolean)
920
921 (defcustom gnus-summary-selected-face 'gnus-summary-selected
922 "Face used for highlighting the current article in the summary buffer."
923 :group 'gnus-summary-visual
924 :type 'face)
925
926 (defvar gnus-tmp-downloaded nil)
927
928 (defcustom gnus-summary-highlight
929 '(((eq mark gnus-canceled-mark)
930 . gnus-summary-cancelled)
931 ((and uncached (> score default-high))
932 . gnus-summary-high-undownloaded)
933 ((and uncached (< score default-low))
934 . gnus-summary-low-undownloaded)
935 (uncached
936 . gnus-summary-normal-undownloaded)
937 ((and (> score default-high)
938 (or (eq mark gnus-dormant-mark)
939 (eq mark gnus-ticked-mark)))
940 . gnus-summary-high-ticked)
941 ((and (< score default-low)
942 (or (eq mark gnus-dormant-mark)
943 (eq mark gnus-ticked-mark)))
944 . gnus-summary-low-ticked)
945 ((or (eq mark gnus-dormant-mark)
946 (eq mark gnus-ticked-mark))
947 . gnus-summary-normal-ticked)
948 ((and (> score default-high) (eq mark gnus-ancient-mark))
949 . gnus-summary-high-ancient)
950 ((and (< score default-low) (eq mark gnus-ancient-mark))
951 . gnus-summary-low-ancient)
952 ((eq mark gnus-ancient-mark)
953 . gnus-summary-normal-ancient)
954 ((and (> score default-high) (eq mark gnus-unread-mark))
955 . gnus-summary-high-unread)
956 ((and (< score default-low) (eq mark gnus-unread-mark))
957 . gnus-summary-low-unread)
958 ((eq mark gnus-unread-mark)
959 . gnus-summary-normal-unread)
960 ((> score default-high)
961 . gnus-summary-high-read)
962 ((< score default-low)
963 . gnus-summary-low-read)
964 (t
965 . gnus-summary-normal-read))
966 "*Controls the highlighting of summary buffer lines.
967
968 A list of (FORM . FACE) pairs. When deciding how a a particular
969 summary line should be displayed, each form is evaluated. The content
970 of the face field after the first true form is used. You can change
971 how those summary lines are displayed, by editing the face field.
972
973 You can use the following variables in the FORM field.
974
975 score: The article's score
976 default: The default article score.
977 default-high: The default score for high scored articles.
978 default-low: The default score for low scored articles.
979 below: The score below which articles are automatically marked as read.
980 mark: The article's mark.
981 uncached: Non-nil if the article is uncached."
982 :group 'gnus-summary-visual
983 :type '(repeat (cons (sexp :tag "Form" nil)
984 face)))
985
986 (defcustom gnus-alter-header-function nil
987 "Function called to allow alteration of article header structures.
988 The function is called with one parameter, the article header vector,
989 which it may alter in any way."
990 :type '(choice (const :tag "None" nil)
991 function)
992 :group 'gnus-summary)
993
994 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
995 "Variable that says which function should be used to decode a string with encoded words.")
996
997 (defcustom gnus-extra-headers '(To Newsgroups)
998 "*Extra headers to parse."
999 :version "21.1"
1000 :group 'gnus-summary
1001 :type '(repeat symbol))
1002
1003 (defcustom gnus-ignored-from-addresses
1004 (and user-mail-address
1005 (not (string= user-mail-address ""))
1006 (regexp-quote user-mail-address))
1007 "*Regexp of From headers that may be suppressed in favor of To headers."
1008 :version "21.1"
1009 :group 'gnus-summary
1010 :type 'regexp)
1011
1012 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1013 "List of charsets that should be ignored.
1014 When these charsets are used in the \"charset\" parameter, the
1015 default charset will be used instead."
1016 :version "21.1"
1017 :type '(repeat symbol)
1018 :group 'gnus-charset)
1019
1020 (gnus-define-group-parameter
1021 ignored-charsets
1022 :type list
1023 :function-document
1024 "Return the ignored charsets of GROUP."
1025 :variable gnus-group-ignored-charsets-alist
1026 :variable-default
1027 '(("alt\\.chinese\\.text" iso-8859-1))
1028 :variable-document
1029 "Alist of regexps (to match group names) and charsets that should be ignored.
1030 When these charsets are used in the \"charset\" parameter, the
1031 default charset will be used instead."
1032 :variable-group gnus-charset
1033 :variable-type '(repeat (cons (regexp :tag "Group")
1034 (repeat symbol)))
1035 :parameter-type '(choice :tag "Ignored charsets"
1036 :value nil
1037 (repeat (symbol)))
1038 :parameter-document "\
1039 List of charsets that should be ignored.
1040
1041 When these charsets are used in the \"charset\" parameter, the
1042 default charset will be used instead.")
1043
1044 (defcustom gnus-group-highlight-words-alist nil
1045 "Alist of group regexps and highlight regexps.
1046 This variable uses the same syntax as `gnus-emphasis-alist'."
1047 :version "21.1"
1048 :type '(repeat (cons (regexp :tag "Group")
1049 (repeat (list (regexp :tag "Highlight regexp")
1050 (number :tag "Group for entire word" 0)
1051 (number :tag "Group for displayed part" 0)
1052 (symbol :tag "Face"
1053 gnus-emphasis-highlight-words)))))
1054 :group 'gnus-summary-visual)
1055
1056 (defcustom gnus-summary-show-article-charset-alist
1057 nil
1058 "Alist of number and charset.
1059 The article will be shown with the charset corresponding to the
1060 numbered argument.
1061 For example: ((1 . cn-gb-2312) (2 . big5))."
1062 :version "21.1"
1063 :type '(repeat (cons (number :tag "Argument" 1)
1064 (symbol :tag "Charset")))
1065 :group 'gnus-charset)
1066
1067 (defcustom gnus-preserve-marks t
1068 "Whether marks are preserved when moving, copying and respooling messages."
1069 :version "21.1"
1070 :type 'boolean
1071 :group 'gnus-summary-marks)
1072
1073 (defcustom gnus-alter-articles-to-read-function nil
1074 "Function to be called to alter the list of articles to be selected."
1075 :type '(choice (const nil) function)
1076 :group 'gnus-summary)
1077
1078 (defcustom gnus-orphan-score nil
1079 "*All orphans get this score added. Set in the score file."
1080 :group 'gnus-score-default
1081 :type '(choice (const nil)
1082 integer))
1083
1084 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1085 "*A regexp to match MIME parts when saving multiple parts of a
1086 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1087 This regexp will be used by default when prompting the user for which
1088 type of files to save."
1089 :group 'gnus-summary
1090 :type 'regexp)
1091
1092 (defcustom gnus-read-all-available-headers nil
1093 "Whether Gnus should parse all headers made available to it.
1094 This is mostly relevant for slow back ends where the user may
1095 wish to widen the summary buffer to include all headers
1096 that were fetched. Say, for nnultimate groups."
1097 :version "22.1"
1098 :group 'gnus-summary
1099 :type '(choice boolean regexp))
1100
1101 (defcustom gnus-summary-muttprint-program "muttprint"
1102 "Command (and optional arguments) used to run Muttprint."
1103 :version "22.1"
1104 :group 'gnus-summary
1105 :type 'string)
1106
1107 (defcustom gnus-article-loose-mime nil
1108 "If non-nil, don't require MIME-Version header.
1109 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1110 supply the MIME-Version header or deliberately strip it from the mail.
1111 Set it to non-nil, Gnus will treat some articles as MIME even if
1112 the MIME-Version header is missed."
1113 :version "22.1"
1114 :type 'boolean
1115 :group 'gnus-article-mime)
1116
1117 (defcustom gnus-article-emulate-mime t
1118 "If non-nil, use MIME emulation for uuencode and the like.
1119 This means that Gnus will search message bodies for text that look
1120 like uuencoded bits, yEncoded bits, and so on, and present that using
1121 the normal Gnus MIME machinery."
1122 :version "22.1"
1123 :type 'boolean
1124 :group 'gnus-article-mime)
1125
1126 ;;; Internal variables
1127
1128 (defvar gnus-summary-display-cache nil)
1129 (defvar gnus-article-mime-handles nil)
1130 (defvar gnus-article-decoded-p nil)
1131 (defvar gnus-article-charset nil)
1132 (defvar gnus-article-ignored-charsets nil)
1133 (defvar gnus-scores-exclude-files nil)
1134 (defvar gnus-page-broken nil)
1135
1136 (defvar gnus-original-article nil)
1137 (defvar gnus-article-internal-prepare-hook nil)
1138 (defvar gnus-newsgroup-process-stack nil)
1139
1140 (defvar gnus-thread-indent-array nil)
1141 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1142 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1143 "Function called to sort the articles within a thread after it has been gathered together.")
1144
1145 (defvar gnus-summary-save-parts-type-history nil)
1146 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1147
1148 ;; Avoid highlighting in kill files.
1149 (defvar gnus-summary-inhibit-highlight nil)
1150 (defvar gnus-newsgroup-selected-overlay nil)
1151 (defvar gnus-inhibit-limiting nil)
1152 (defvar gnus-newsgroup-adaptive-score-file nil)
1153 (defvar gnus-current-score-file nil)
1154 (defvar gnus-current-move-group nil)
1155 (defvar gnus-current-copy-group nil)
1156 (defvar gnus-current-crosspost-group nil)
1157 (defvar gnus-newsgroup-display nil)
1158
1159 (defvar gnus-newsgroup-dependencies nil)
1160 (defvar gnus-newsgroup-adaptive nil)
1161 (defvar gnus-summary-display-article-function nil)
1162 (defvar gnus-summary-highlight-line-function nil
1163 "Function called after highlighting a summary line.")
1164
1165 (defvar gnus-summary-line-format-alist
1166 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1167 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1168 (?s gnus-tmp-subject-or-nil ?s)
1169 (?n gnus-tmp-name ?s)
1170 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1171 ?s)
1172 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1173 gnus-tmp-from) ?s)
1174 (?F gnus-tmp-from ?s)
1175 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1176 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1177 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1178 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1179 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1180 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1181 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1182 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1183 (?L gnus-tmp-lines ?s)
1184 (?O gnus-tmp-downloaded ?c)
1185 (?I gnus-tmp-indentation ?s)
1186 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1187 (?R gnus-tmp-replied ?c)
1188 (?\[ gnus-tmp-opening-bracket ?c)
1189 (?\] gnus-tmp-closing-bracket ?c)
1190 (?\> (make-string gnus-tmp-level ? ) ?s)
1191 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1192 (?i gnus-tmp-score ?d)
1193 (?z gnus-tmp-score-char ?c)
1194 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1195 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1196 (?U gnus-tmp-unread ?c)
1197 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1198 ?s)
1199 (?t (gnus-summary-number-of-articles-in-thread
1200 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1201 ?d)
1202 (?e (gnus-summary-number-of-articles-in-thread
1203 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1204 ?c)
1205 (?u gnus-tmp-user-defined ?s)
1206 (?P (gnus-pick-line-number) ?d)
1207 (?B gnus-tmp-thread-tree-header-string ?s)
1208 (user-date (gnus-user-date
1209 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1210 "An alist of format specifications that can appear in summary lines.
1211 These are paired with what variables they correspond with, along with
1212 the type of the variable (string, integer, character, etc).")
1213
1214 (defvar gnus-summary-dummy-line-format-alist
1215 `((?S gnus-tmp-subject ?s)
1216 (?N gnus-tmp-number ?d)
1217 (?u gnus-tmp-user-defined ?s)))
1218
1219 (defvar gnus-summary-mode-line-format-alist
1220 `((?G gnus-tmp-group-name ?s)
1221 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1222 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1223 (?A gnus-tmp-article-number ?d)
1224 (?Z gnus-tmp-unread-and-unselected ?s)
1225 (?V gnus-version ?s)
1226 (?U gnus-tmp-unread-and-unticked ?d)
1227 (?S gnus-tmp-subject ?s)
1228 (?e gnus-tmp-unselected ?d)
1229 (?u gnus-tmp-user-defined ?s)
1230 (?d (length gnus-newsgroup-dormant) ?d)
1231 (?t (length gnus-newsgroup-marked) ?d)
1232 (?h (length gnus-newsgroup-spam-marked) ?d)
1233 (?r (length gnus-newsgroup-reads) ?d)
1234 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1235 (?E gnus-newsgroup-expunged-tally ?d)
1236 (?s (gnus-current-score-file-nondirectory) ?s)))
1237
1238 (defvar gnus-last-search-regexp nil
1239 "Default regexp for article search command.")
1240
1241 (defvar gnus-last-shell-command nil
1242 "Default shell command on article.")
1243
1244 (defvar gnus-newsgroup-agentized nil
1245 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1246 (defvar gnus-newsgroup-begin nil)
1247 (defvar gnus-newsgroup-end nil)
1248 (defvar gnus-newsgroup-last-rmail nil)
1249 (defvar gnus-newsgroup-last-mail nil)
1250 (defvar gnus-newsgroup-last-folder nil)
1251 (defvar gnus-newsgroup-last-file nil)
1252 (defvar gnus-newsgroup-last-directory nil)
1253 (defvar gnus-newsgroup-auto-expire nil)
1254 (defvar gnus-newsgroup-active nil)
1255
1256 (defvar gnus-newsgroup-data nil)
1257 (defvar gnus-newsgroup-data-reverse nil)
1258 (defvar gnus-newsgroup-limit nil)
1259 (defvar gnus-newsgroup-limits nil)
1260 (defvar gnus-summary-use-undownloaded-faces nil)
1261
1262 (defvar gnus-newsgroup-unreads nil
1263 "Sorted list of unread articles in the current newsgroup.")
1264
1265 (defvar gnus-newsgroup-unselected nil
1266 "Sorted list of unselected unread articles in the current newsgroup.")
1267
1268 (defvar gnus-newsgroup-reads nil
1269 "Alist of read articles and article marks in the current newsgroup.")
1270
1271 (defvar gnus-newsgroup-expunged-tally nil)
1272
1273 (defvar gnus-newsgroup-marked nil
1274 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1275
1276 (defvar gnus-newsgroup-spam-marked nil
1277 "List of ranges of articles that have been marked as spam.")
1278
1279 (defvar gnus-newsgroup-killed nil
1280 "List of ranges of articles that have been through the scoring process.")
1281
1282 (defvar gnus-newsgroup-cached nil
1283 "Sorted list of articles that come from the article cache.")
1284
1285 (defvar gnus-newsgroup-saved nil
1286 "List of articles that have been saved.")
1287
1288 (defvar gnus-newsgroup-kill-headers nil)
1289
1290 (defvar gnus-newsgroup-replied nil
1291 "List of articles that have been replied to in the current newsgroup.")
1292
1293 (defvar gnus-newsgroup-forwarded nil
1294 "List of articles that have been forwarded in the current newsgroup.")
1295
1296 (defvar gnus-newsgroup-recent nil
1297 "List of articles that have are recent in the current newsgroup.")
1298
1299 (defvar gnus-newsgroup-expirable nil
1300 "Sorted list of articles in the current newsgroup that can be expired.")
1301
1302 (defvar gnus-newsgroup-processable nil
1303 "List of articles in the current newsgroup that can be processed.")
1304
1305 (defvar gnus-newsgroup-downloadable nil
1306 "Sorted list of articles in the current newsgroup that can be processed.")
1307
1308 (defvar gnus-newsgroup-unfetched nil
1309 "Sorted list of articles in the current newsgroup whose headers have
1310 not been fetched into the agent.
1311
1312 This list will always be a subset of gnus-newsgroup-undownloaded.")
1313
1314 (defvar gnus-newsgroup-undownloaded nil
1315 "List of articles in the current newsgroup that haven't been downloaded.")
1316
1317 (defvar gnus-newsgroup-unsendable nil
1318 "List of articles in the current newsgroup that won't be sent.")
1319
1320 (defvar gnus-newsgroup-bookmarks nil
1321 "List of articles in the current newsgroup that have bookmarks.")
1322
1323 (defvar gnus-newsgroup-dormant nil
1324 "Sorted list of dormant articles in the current newsgroup.")
1325
1326 (defvar gnus-newsgroup-unseen nil
1327 "List of unseen articles in the current newsgroup.")
1328
1329 (defvar gnus-newsgroup-seen nil
1330 "Range of seen articles in the current newsgroup.")
1331
1332 (defvar gnus-newsgroup-articles nil
1333 "List of articles in the current newsgroup.")
1334
1335 (defvar gnus-newsgroup-scored nil
1336 "List of scored articles in the current newsgroup.")
1337
1338 (defvar gnus-newsgroup-headers nil
1339 "List of article headers in the current newsgroup.")
1340
1341 (defvar gnus-newsgroup-threads nil)
1342
1343 (defvar gnus-newsgroup-prepared nil
1344 "Whether the current group has been prepared properly.")
1345
1346 (defvar gnus-newsgroup-ancient nil
1347 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1348
1349 (defvar gnus-newsgroup-sparse nil)
1350
1351 (defvar gnus-current-article nil)
1352 (defvar gnus-article-current nil)
1353 (defvar gnus-current-headers nil)
1354 (defvar gnus-have-all-headers nil)
1355 (defvar gnus-last-article nil)
1356 (defvar gnus-newsgroup-history nil)
1357 (defvar gnus-newsgroup-charset nil)
1358 (defvar gnus-newsgroup-ephemeral-charset nil)
1359 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1360
1361 (defvar gnus-article-before-search nil)
1362
1363 (defvar gnus-summary-local-variables
1364 '(gnus-newsgroup-name
1365 gnus-newsgroup-begin gnus-newsgroup-end
1366 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1367 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1368 gnus-newsgroup-last-directory
1369 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1370 gnus-newsgroup-unselected gnus-newsgroup-marked
1371 gnus-newsgroup-spam-marked
1372 gnus-newsgroup-reads gnus-newsgroup-saved
1373 gnus-newsgroup-replied gnus-newsgroup-forwarded
1374 gnus-newsgroup-recent
1375 gnus-newsgroup-expirable
1376 gnus-newsgroup-processable gnus-newsgroup-killed
1377 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1378 gnus-newsgroup-unfetched
1379 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1380 gnus-newsgroup-seen gnus-newsgroup-articles
1381 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1382 gnus-newsgroup-headers gnus-newsgroup-threads
1383 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1384 gnus-current-article gnus-current-headers gnus-have-all-headers
1385 gnus-last-article gnus-article-internal-prepare-hook
1386 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1387 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1388 gnus-thread-expunge-below
1389 gnus-score-alist gnus-current-score-file
1390 (gnus-summary-expunge-below . global)
1391 (gnus-summary-mark-below . global)
1392 (gnus-orphan-score . global)
1393 gnus-newsgroup-active gnus-scores-exclude-files
1394 gnus-newsgroup-history gnus-newsgroup-ancient
1395 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1396 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1397 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1398 (gnus-newsgroup-expunged-tally . 0)
1399 gnus-cache-removable-articles gnus-newsgroup-cached
1400 gnus-newsgroup-data gnus-newsgroup-data-reverse
1401 gnus-newsgroup-limit gnus-newsgroup-limits
1402 gnus-newsgroup-charset gnus-newsgroup-display
1403 gnus-summary-use-undownloaded-faces)
1404 "Variables that are buffer-local to the summary buffers.")
1405
1406 (defvar gnus-newsgroup-variables nil
1407 "A list of variables that have separate values in different newsgroups.
1408 A list of newsgroup (summary buffer) local variables, or cons of
1409 variables and their default expressions to be evalled (when the default
1410 values are not nil), that should be made global while the summary buffer
1411 is active.
1412
1413 Note: The default expressions will be evaluated (using function `eval')
1414 before assignment to the local variable rather than just assigned to it.
1415 If the default expression is the symbol `global', that symbol will not
1416 be evaluated but the global value of the local variable will be used
1417 instead.
1418
1419 These variables can be used to set variables in the group parameters
1420 while still allowing them to affect operations done in other buffers.
1421 For example:
1422
1423 \(setq gnus-newsgroup-variables
1424 '(message-use-followup-to
1425 (gnus-visible-headers .
1426 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1427 ")
1428
1429 ;; Byte-compiler warning.
1430 (eval-when-compile
1431 ;; Bind features so that require will believe that gnus-sum has
1432 ;; already been loaded (avoids infinite recursion)
1433 (let ((features (cons 'gnus-sum features)))
1434 ;; Several of the declarations in gnus-sum are needed to load the
1435 ;; following files. Right now, these definitions have been
1436 ;; compiled but not defined (evaluated). We could either do a
1437 ;; eval-and-compile about all of the declarations or evaluate the
1438 ;; source file.
1439 (if (boundp 'gnus-newsgroup-variables)
1440 nil
1441 (load "gnus-sum.el" t t t))
1442 (require 'gnus)
1443 (require 'gnus-agent)
1444 (require 'gnus-art)))
1445
1446 ;; MIME stuff.
1447
1448 (defvar gnus-decode-encoded-word-methods
1449 '(mail-decode-encoded-word-string)
1450 "List of methods used to decode encoded words.
1451
1452 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1453 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1454 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1455 whose names match REGEXP.
1456
1457 For example:
1458 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1459 mail-decode-encoded-word-string
1460 (\"chinese\" . rfc1843-decode-string))")
1461
1462 (defvar gnus-decode-encoded-word-methods-cache nil)
1463
1464 (defun gnus-multi-decode-encoded-word-string (string)
1465 "Apply the functions from `gnus-encoded-word-methods' that match."
1466 (unless (and gnus-decode-encoded-word-methods-cache
1467 (eq gnus-newsgroup-name
1468 (car gnus-decode-encoded-word-methods-cache)))
1469 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1470 (mapcar (lambda (x)
1471 (if (symbolp x)
1472 (nconc gnus-decode-encoded-word-methods-cache (list x))
1473 (if (and gnus-newsgroup-name
1474 (string-match (car x) gnus-newsgroup-name))
1475 (nconc gnus-decode-encoded-word-methods-cache
1476 (list (cdr x))))))
1477 gnus-decode-encoded-word-methods))
1478 (let ((xlist gnus-decode-encoded-word-methods-cache))
1479 (pop xlist)
1480 (while xlist
1481 (setq string (funcall (pop xlist) string))))
1482 string)
1483
1484 ;; Subject simplification.
1485
1486 (defun gnus-simplify-whitespace (str)
1487 "Remove excessive whitespace from STR."
1488 ;; Multiple spaces.
1489 (while (string-match "[ \t][ \t]+" str)
1490 (setq str (concat (substring str 0 (match-beginning 0))
1491 " "
1492 (substring str (match-end 0)))))
1493 ;; Leading spaces.
1494 (when (string-match "^[ \t]+" str)
1495 (setq str (substring str (match-end 0))))
1496 ;; Trailing spaces.
1497 (when (string-match "[ \t]+$" str)
1498 (setq str (substring str 0 (match-beginning 0))))
1499 str)
1500
1501 (defun gnus-simplify-all-whitespace (str)
1502 "Remove all whitespace from STR."
1503 (while (string-match "[ \t\n]+" str)
1504 (setq str (replace-match "" nil nil str)))
1505 str)
1506
1507 (defsubst gnus-simplify-subject-re (subject)
1508 "Remove \"Re:\" from subject lines."
1509 (if (string-match message-subject-re-regexp subject)
1510 (substring subject (match-end 0))
1511 subject))
1512
1513 (defun gnus-simplify-subject (subject &optional re-only)
1514 "Remove `Re:' and words in parentheses.
1515 If RE-ONLY is non-nil, strip leading `Re:'s only."
1516 (let ((case-fold-search t)) ;Ignore case.
1517 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1518 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1519 (setq subject (substring subject (match-end 0))))
1520 ;; Remove uninteresting prefixes.
1521 (when (and (not re-only)
1522 gnus-simplify-ignored-prefixes
1523 (string-match gnus-simplify-ignored-prefixes subject))
1524 (setq subject (substring subject (match-end 0))))
1525 ;; Remove words in parentheses from end.
1526 (unless re-only
1527 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1528 (setq subject (substring subject 0 (match-beginning 0)))))
1529 ;; Return subject string.
1530 subject))
1531
1532 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1533 ;; all whitespace.
1534 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1535 (goto-char (point-min))
1536 (while (re-search-forward regexp nil t)
1537 (replace-match (or newtext ""))))
1538
1539 (defun gnus-simplify-buffer-fuzzy ()
1540 "Simplify string in the buffer fuzzily.
1541 The string in the accessible portion of the current buffer is simplified.
1542 It is assumed to be a single-line subject.
1543 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1544 matter is removed. Additional things can be deleted by setting
1545 `gnus-simplify-subject-fuzzy-regexp'."
1546 (let ((case-fold-search t)
1547 (modified-tick))
1548 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1549
1550 (while (not (eq modified-tick (buffer-modified-tick)))
1551 (setq modified-tick (buffer-modified-tick))
1552 (cond
1553 ((listp gnus-simplify-subject-fuzzy-regexp)
1554 (mapcar 'gnus-simplify-buffer-fuzzy-step
1555 gnus-simplify-subject-fuzzy-regexp))
1556 (gnus-simplify-subject-fuzzy-regexp
1557 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1558 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1559 (gnus-simplify-buffer-fuzzy-step
1560 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1561 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1562
1563 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1564 (gnus-simplify-buffer-fuzzy-step " +" " ")
1565 (gnus-simplify-buffer-fuzzy-step " $")
1566 (gnus-simplify-buffer-fuzzy-step "^ +")))
1567
1568 (defun gnus-simplify-subject-fuzzy (subject)
1569 "Simplify a subject string fuzzily.
1570 See `gnus-simplify-buffer-fuzzy' for details."
1571 (save-excursion
1572 (gnus-set-work-buffer)
1573 (let ((case-fold-search t))
1574 ;; Remove uninteresting prefixes.
1575 (when (and gnus-simplify-ignored-prefixes
1576 (string-match gnus-simplify-ignored-prefixes subject))
1577 (setq subject (substring subject (match-end 0))))
1578 (insert subject)
1579 (inline (gnus-simplify-buffer-fuzzy))
1580 (buffer-string))))
1581
1582 (defsubst gnus-simplify-subject-fully (subject)
1583 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1584 (cond
1585 (gnus-simplify-subject-functions
1586 (gnus-map-function gnus-simplify-subject-functions subject))
1587 ((null gnus-summary-gather-subject-limit)
1588 (gnus-simplify-subject-re subject))
1589 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1590 (gnus-simplify-subject-fuzzy subject))
1591 ((numberp gnus-summary-gather-subject-limit)
1592 (gnus-limit-string (gnus-simplify-subject-re subject)
1593 gnus-summary-gather-subject-limit))
1594 (t
1595 subject)))
1596
1597 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1598 "Check whether two subjects are equal.
1599 If optional argument SIMPLE-FIRST is t, first argument is already
1600 simplified."
1601 (cond
1602 ((null simple-first)
1603 (equal (gnus-simplify-subject-fully s1)
1604 (gnus-simplify-subject-fully s2)))
1605 (t
1606 (equal s1
1607 (gnus-simplify-subject-fully s2)))))
1608
1609 (defun gnus-summary-bubble-group ()
1610 "Increase the score of the current group.
1611 This is a handy function to add to `gnus-summary-exit-hook' to
1612 increase the score of each group you read."
1613 (gnus-group-add-score gnus-newsgroup-name))
1614
1615 \f
1616 ;;;
1617 ;;; Gnus summary mode
1618 ;;;
1619
1620 (put 'gnus-summary-mode 'mode-class 'special)
1621
1622 (defvar gnus-article-commands-menu)
1623
1624 ;; Non-orthogonal keys
1625
1626 (gnus-define-keys gnus-summary-mode-map
1627 " " gnus-summary-next-page
1628 "\177" gnus-summary-prev-page
1629 [delete] gnus-summary-prev-page
1630 [backspace] gnus-summary-prev-page
1631 "\r" gnus-summary-scroll-up
1632 "\M-\r" gnus-summary-scroll-down
1633 "n" gnus-summary-next-unread-article
1634 "p" gnus-summary-prev-unread-article
1635 "N" gnus-summary-next-article
1636 "P" gnus-summary-prev-article
1637 "\M-\C-n" gnus-summary-next-same-subject
1638 "\M-\C-p" gnus-summary-prev-same-subject
1639 "\M-n" gnus-summary-next-unread-subject
1640 "\M-p" gnus-summary-prev-unread-subject
1641 "." gnus-summary-first-unread-article
1642 "," gnus-summary-best-unread-article
1643 "\M-s" gnus-summary-search-article-forward
1644 "\M-r" gnus-summary-search-article-backward
1645 "<" gnus-summary-beginning-of-article
1646 ">" gnus-summary-end-of-article
1647 "j" gnus-summary-goto-article
1648 "^" gnus-summary-refer-parent-article
1649 "\M-^" gnus-summary-refer-article
1650 "u" gnus-summary-tick-article-forward
1651 "!" gnus-summary-tick-article-forward
1652 "U" gnus-summary-tick-article-backward
1653 "d" gnus-summary-mark-as-read-forward
1654 "D" gnus-summary-mark-as-read-backward
1655 "E" gnus-summary-mark-as-expirable
1656 "\M-u" gnus-summary-clear-mark-forward
1657 "\M-U" gnus-summary-clear-mark-backward
1658 "k" gnus-summary-kill-same-subject-and-select
1659 "\C-k" gnus-summary-kill-same-subject
1660 "\M-\C-k" gnus-summary-kill-thread
1661 "\M-\C-l" gnus-summary-lower-thread
1662 "e" gnus-summary-edit-article
1663 "#" gnus-summary-mark-as-processable
1664 "\M-#" gnus-summary-unmark-as-processable
1665 "\M-\C-t" gnus-summary-toggle-threads
1666 "\M-\C-s" gnus-summary-show-thread
1667 "\M-\C-h" gnus-summary-hide-thread
1668 "\M-\C-f" gnus-summary-next-thread
1669 "\M-\C-b" gnus-summary-prev-thread
1670 [(meta down)] gnus-summary-next-thread
1671 [(meta up)] gnus-summary-prev-thread
1672 "\M-\C-u" gnus-summary-up-thread
1673 "\M-\C-d" gnus-summary-down-thread
1674 "&" gnus-summary-execute-command
1675 "c" gnus-summary-catchup-and-exit
1676 "\C-w" gnus-summary-mark-region-as-read
1677 "\C-t" gnus-summary-toggle-truncation
1678 "?" gnus-summary-mark-as-dormant
1679 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1680 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1681 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1682 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1683 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1684 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1685 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1686 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1687 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1688 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1689 "=" gnus-summary-expand-window
1690 "\C-x\C-s" gnus-summary-reselect-current-group
1691 "\M-g" gnus-summary-rescan-group
1692 "w" gnus-summary-stop-page-breaking
1693 "\C-c\C-r" gnus-summary-caesar-message
1694 "f" gnus-summary-followup
1695 "F" gnus-summary-followup-with-original
1696 "C" gnus-summary-cancel-article
1697 "r" gnus-summary-reply
1698 "R" gnus-summary-reply-with-original
1699 "\C-c\C-f" gnus-summary-mail-forward
1700 "o" gnus-summary-save-article
1701 "\C-o" gnus-summary-save-article-mail
1702 "|" gnus-summary-pipe-output
1703 "\M-k" gnus-summary-edit-local-kill
1704 "\M-K" gnus-summary-edit-global-kill
1705 ;; "V" gnus-version
1706 "\C-c\C-d" gnus-summary-describe-group
1707 "q" gnus-summary-exit
1708 "Q" gnus-summary-exit-no-update
1709 "\C-c\C-i" gnus-info-find-node
1710 gnus-mouse-2 gnus-mouse-pick-article
1711 [follow-link] mouse-face
1712 "m" gnus-summary-mail-other-window
1713 "a" gnus-summary-post-news
1714 "i" gnus-summary-news-other-window
1715 "x" gnus-summary-limit-to-unread
1716 "s" gnus-summary-isearch-article
1717 "t" gnus-summary-toggle-header
1718 "g" gnus-summary-show-article
1719 "l" gnus-summary-goto-last-article
1720 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1721 "\C-d" gnus-summary-enter-digest-group
1722 "\M-\C-d" gnus-summary-read-document
1723 "\M-\C-e" gnus-summary-edit-parameters
1724 "\M-\C-a" gnus-summary-customize-parameters
1725 "\C-c\C-b" gnus-bug
1726 "*" gnus-cache-enter-article
1727 "\M-*" gnus-cache-remove-article
1728 "\M-&" gnus-summary-universal-argument
1729 "\C-l" gnus-recenter
1730 "I" gnus-summary-increase-score
1731 "L" gnus-summary-lower-score
1732 "\M-i" gnus-symbolic-argument
1733 "h" gnus-summary-select-article-buffer
1734
1735 "b" gnus-article-view-part
1736 "\M-t" gnus-summary-toggle-display-buttonized
1737
1738 "V" gnus-summary-score-map
1739 "X" gnus-uu-extract-map
1740 "S" gnus-summary-send-map)
1741
1742 ;; Sort of orthogonal keymap
1743 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1744 "t" gnus-summary-tick-article-forward
1745 "!" gnus-summary-tick-article-forward
1746 "d" gnus-summary-mark-as-read-forward
1747 "r" gnus-summary-mark-as-read-forward
1748 "c" gnus-summary-clear-mark-forward
1749 " " gnus-summary-clear-mark-forward
1750 "e" gnus-summary-mark-as-expirable
1751 "x" gnus-summary-mark-as-expirable
1752 "?" gnus-summary-mark-as-dormant
1753 "b" gnus-summary-set-bookmark
1754 "B" gnus-summary-remove-bookmark
1755 "#" gnus-summary-mark-as-processable
1756 "\M-#" gnus-summary-unmark-as-processable
1757 "S" gnus-summary-limit-include-expunged
1758 "C" gnus-summary-catchup
1759 "H" gnus-summary-catchup-to-here
1760 "h" gnus-summary-catchup-from-here
1761 "\C-c" gnus-summary-catchup-all
1762 "k" gnus-summary-kill-same-subject-and-select
1763 "K" gnus-summary-kill-same-subject
1764 "P" gnus-uu-mark-map)
1765
1766 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1767 "c" gnus-summary-clear-above
1768 "u" gnus-summary-tick-above
1769 "m" gnus-summary-mark-above
1770 "k" gnus-summary-kill-below)
1771
1772 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1773 "/" gnus-summary-limit-to-subject
1774 "n" gnus-summary-limit-to-articles
1775 "w" gnus-summary-pop-limit
1776 "s" gnus-summary-limit-to-subject
1777 "a" gnus-summary-limit-to-author
1778 "u" gnus-summary-limit-to-unread
1779 "m" gnus-summary-limit-to-marks
1780 "M" gnus-summary-limit-exclude-marks
1781 "v" gnus-summary-limit-to-score
1782 "*" gnus-summary-limit-include-cached
1783 "D" gnus-summary-limit-include-dormant
1784 "T" gnus-summary-limit-include-thread
1785 "d" gnus-summary-limit-exclude-dormant
1786 "t" gnus-summary-limit-to-age
1787 "." gnus-summary-limit-to-unseen
1788 "x" gnus-summary-limit-to-extra
1789 "p" gnus-summary-limit-to-display-predicate
1790 "E" gnus-summary-limit-include-expunged
1791 "c" gnus-summary-limit-exclude-childless-dormant
1792 "C" gnus-summary-limit-mark-excluded-as-read
1793 "o" gnus-summary-insert-old-articles
1794 "N" gnus-summary-insert-new-articles)
1795
1796 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1797 "n" gnus-summary-next-unread-article
1798 "p" gnus-summary-prev-unread-article
1799 "N" gnus-summary-next-article
1800 "P" gnus-summary-prev-article
1801 "\C-n" gnus-summary-next-same-subject
1802 "\C-p" gnus-summary-prev-same-subject
1803 "\M-n" gnus-summary-next-unread-subject
1804 "\M-p" gnus-summary-prev-unread-subject
1805 "f" gnus-summary-first-unread-article
1806 "b" gnus-summary-best-unread-article
1807 "j" gnus-summary-goto-article
1808 "g" gnus-summary-goto-subject
1809 "l" gnus-summary-goto-last-article
1810 "o" gnus-summary-pop-article)
1811
1812 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1813 "k" gnus-summary-kill-thread
1814 "l" gnus-summary-lower-thread
1815 "i" gnus-summary-raise-thread
1816 "T" gnus-summary-toggle-threads
1817 "t" gnus-summary-rethread-current
1818 "^" gnus-summary-reparent-thread
1819 "s" gnus-summary-show-thread
1820 "S" gnus-summary-show-all-threads
1821 "h" gnus-summary-hide-thread
1822 "H" gnus-summary-hide-all-threads
1823 "n" gnus-summary-next-thread
1824 "p" gnus-summary-prev-thread
1825 "u" gnus-summary-up-thread
1826 "o" gnus-summary-top-thread
1827 "d" gnus-summary-down-thread
1828 "#" gnus-uu-mark-thread
1829 "\M-#" gnus-uu-unmark-thread)
1830
1831 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1832 "g" gnus-summary-prepare
1833 "c" gnus-summary-insert-cached-articles
1834 "d" gnus-summary-insert-dormant-articles)
1835
1836 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1837 "c" gnus-summary-catchup-and-exit
1838 "C" gnus-summary-catchup-all-and-exit
1839 "E" gnus-summary-exit-no-update
1840 "Q" gnus-summary-exit
1841 "Z" gnus-summary-exit
1842 "n" gnus-summary-catchup-and-goto-next-group
1843 "R" gnus-summary-reselect-current-group
1844 "G" gnus-summary-rescan-group
1845 "N" gnus-summary-next-group
1846 "s" gnus-summary-save-newsrc
1847 "P" gnus-summary-prev-group)
1848
1849 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1850 " " gnus-summary-next-page
1851 "n" gnus-summary-next-page
1852 "\177" gnus-summary-prev-page
1853 [delete] gnus-summary-prev-page
1854 "p" gnus-summary-prev-page
1855 "\r" gnus-summary-scroll-up
1856 "\M-\r" gnus-summary-scroll-down
1857 "<" gnus-summary-beginning-of-article
1858 ">" gnus-summary-end-of-article
1859 "b" gnus-summary-beginning-of-article
1860 "e" gnus-summary-end-of-article
1861 "^" gnus-summary-refer-parent-article
1862 "r" gnus-summary-refer-parent-article
1863 "D" gnus-summary-enter-digest-group
1864 "R" gnus-summary-refer-references
1865 "T" gnus-summary-refer-thread
1866 "g" gnus-summary-show-article
1867 "s" gnus-summary-isearch-article
1868 "P" gnus-summary-print-article
1869 "M" gnus-mailing-list-insinuate
1870 "t" gnus-article-babel)
1871
1872 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1873 "b" gnus-article-add-buttons
1874 "B" gnus-article-add-buttons-to-head
1875 "o" gnus-article-treat-overstrike
1876 "e" gnus-article-emphasize
1877 "w" gnus-article-fill-cited-article
1878 "Q" gnus-article-fill-long-lines
1879 "C" gnus-article-capitalize-sentences
1880 "c" gnus-article-remove-cr
1881 "q" gnus-article-de-quoted-unreadable
1882 "6" gnus-article-de-base64-unreadable
1883 "Z" gnus-article-decode-HZ
1884 "h" gnus-article-wash-html
1885 "u" gnus-article-unsplit-urls
1886 "s" gnus-summary-force-verify-and-decrypt
1887 "f" gnus-article-display-x-face
1888 "l" gnus-summary-stop-page-breaking
1889 "r" gnus-summary-caesar-message
1890 "m" gnus-summary-morse-message
1891 "t" gnus-summary-toggle-header
1892 "g" gnus-treat-smiley
1893 "v" gnus-summary-verbose-headers
1894 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1895 "p" gnus-article-verify-x-pgp-sig
1896 "d" gnus-article-treat-dumbquotes)
1897
1898 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1899 ;; mnemonic: deuglif*Y*
1900 "u" gnus-article-outlook-unwrap-lines
1901 "a" gnus-article-outlook-repair-attribution
1902 "c" gnus-article-outlook-rearrange-citation
1903 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1904
1905 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1906 "a" gnus-article-hide
1907 "h" gnus-article-hide-headers
1908 "b" gnus-article-hide-boring-headers
1909 "s" gnus-article-hide-signature
1910 "c" gnus-article-hide-citation
1911 "C" gnus-article-hide-citation-in-followups
1912 "l" gnus-article-hide-list-identifiers
1913 "B" gnus-article-strip-banner
1914 "P" gnus-article-hide-pem
1915 "\C-c" gnus-article-hide-citation-maybe)
1916
1917 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1918 "a" gnus-article-highlight
1919 "h" gnus-article-highlight-headers
1920 "c" gnus-article-highlight-citation
1921 "s" gnus-article-highlight-signature)
1922
1923 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1924 "f" gnus-article-treat-fold-headers
1925 "u" gnus-article-treat-unfold-headers
1926 "n" gnus-article-treat-fold-newsgroups)
1927
1928 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1929 "x" gnus-article-display-x-face
1930 "d" gnus-article-display-face
1931 "s" gnus-treat-smiley
1932 "D" gnus-article-remove-images
1933 "f" gnus-treat-from-picon
1934 "m" gnus-treat-mail-picon
1935 "n" gnus-treat-newsgroups-picon)
1936
1937 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1938 "w" gnus-article-decode-mime-words
1939 "c" gnus-article-decode-charset
1940 "v" gnus-mime-view-all-parts
1941 "b" gnus-article-view-part)
1942
1943 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1944 "z" gnus-article-date-ut
1945 "u" gnus-article-date-ut
1946 "l" gnus-article-date-local
1947 "p" gnus-article-date-english
1948 "e" gnus-article-date-lapsed
1949 "o" gnus-article-date-original
1950 "i" gnus-article-date-iso8601
1951 "s" gnus-article-date-user)
1952
1953 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1954 "t" gnus-article-remove-trailing-blank-lines
1955 "l" gnus-article-strip-leading-blank-lines
1956 "m" gnus-article-strip-multiple-blank-lines
1957 "a" gnus-article-strip-blank-lines
1958 "A" gnus-article-strip-all-blank-lines
1959 "s" gnus-article-strip-leading-space
1960 "e" gnus-article-strip-trailing-space
1961 "w" gnus-article-remove-leading-whitespace)
1962
1963 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1964 "v" gnus-version
1965 "f" gnus-summary-fetch-faq
1966 "d" gnus-summary-describe-group
1967 "h" gnus-summary-describe-briefly
1968 "i" gnus-info-find-node
1969 "c" gnus-group-fetch-charter
1970 "C" gnus-group-fetch-control)
1971
1972 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1973 "e" gnus-summary-expire-articles
1974 "\M-\C-e" gnus-summary-expire-articles-now
1975 "\177" gnus-summary-delete-article
1976 [delete] gnus-summary-delete-article
1977 [backspace] gnus-summary-delete-article
1978 "m" gnus-summary-move-article
1979 "r" gnus-summary-respool-article
1980 "w" gnus-summary-edit-article
1981 "c" gnus-summary-copy-article
1982 "B" gnus-summary-crosspost-article
1983 "q" gnus-summary-respool-query
1984 "t" gnus-summary-respool-trace
1985 "i" gnus-summary-import-article
1986 "I" gnus-summary-create-article
1987 "p" gnus-summary-article-posted-p)
1988
1989 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1990 "o" gnus-summary-save-article
1991 "m" gnus-summary-save-article-mail
1992 "F" gnus-summary-write-article-file
1993 "r" gnus-summary-save-article-rmail
1994 "f" gnus-summary-save-article-file
1995 "b" gnus-summary-save-article-body-file
1996 "B" gnus-summary-write-article-body-file
1997 "h" gnus-summary-save-article-folder
1998 "v" gnus-summary-save-article-vm
1999 "p" gnus-summary-pipe-output
2000 "P" gnus-summary-muttprint
2001 "s" gnus-soup-add-article)
2002
2003 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2004 "b" gnus-summary-display-buttonized
2005 "m" gnus-summary-repair-multipart
2006 "v" gnus-article-view-part
2007 "o" gnus-article-save-part
2008 "c" gnus-article-copy-part
2009 "C" gnus-article-view-part-as-charset
2010 "e" gnus-article-view-part-externally
2011 "E" gnus-article-encrypt-body
2012 "i" gnus-article-inline-part
2013 "|" gnus-article-pipe-part)
2014
2015 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2016 "p" gnus-summary-mark-as-processable
2017 "u" gnus-summary-unmark-as-processable
2018 "U" gnus-summary-unmark-all-processable
2019 "v" gnus-uu-mark-over
2020 "s" gnus-uu-mark-series
2021 "r" gnus-uu-mark-region
2022 "g" gnus-uu-unmark-region
2023 "R" gnus-uu-mark-by-regexp
2024 "G" gnus-uu-unmark-by-regexp
2025 "t" gnus-uu-mark-thread
2026 "T" gnus-uu-unmark-thread
2027 "a" gnus-uu-mark-all
2028 "b" gnus-uu-mark-buffer
2029 "S" gnus-uu-mark-sparse
2030 "k" gnus-summary-kill-process-mark
2031 "y" gnus-summary-yank-process-mark
2032 "w" gnus-summary-save-process-mark
2033 "i" gnus-uu-invert-processable)
2034
2035 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2036 ;;"x" gnus-uu-extract-any
2037 "m" gnus-summary-save-parts
2038 "u" gnus-uu-decode-uu
2039 "U" gnus-uu-decode-uu-and-save
2040 "s" gnus-uu-decode-unshar
2041 "S" gnus-uu-decode-unshar-and-save
2042 "o" gnus-uu-decode-save
2043 "O" gnus-uu-decode-save
2044 "b" gnus-uu-decode-binhex
2045 "B" gnus-uu-decode-binhex
2046 "p" gnus-uu-decode-postscript
2047 "P" gnus-uu-decode-postscript-and-save)
2048
2049 (gnus-define-keys
2050 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2051 "u" gnus-uu-decode-uu-view
2052 "U" gnus-uu-decode-uu-and-save-view
2053 "s" gnus-uu-decode-unshar-view
2054 "S" gnus-uu-decode-unshar-and-save-view
2055 "o" gnus-uu-decode-save-view
2056 "O" gnus-uu-decode-save-view
2057 "b" gnus-uu-decode-binhex-view
2058 "B" gnus-uu-decode-binhex-view
2059 "p" gnus-uu-decode-postscript-view
2060 "P" gnus-uu-decode-postscript-and-save-view)
2061
2062 (defvar gnus-article-post-menu nil)
2063
2064 (defconst gnus-summary-menu-maxlen 20)
2065
2066 (defun gnus-summary-menu-split (menu)
2067 ;; If we have lots of elements, divide them into groups of 20
2068 ;; and make a pane (or submenu) for each one.
2069 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2070 (let ((menu menu) sublists next
2071 (i 1))
2072 (while menu
2073 ;; Pull off the next gnus-summary-menu-maxlen elements
2074 ;; and make them the next element of sublist.
2075 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2076 (if next
2077 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2078 nil))
2079 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2080 (aref (car (last menu)) 0)) menu)
2081 sublists))
2082 (setq i (1+ i))
2083 (setq menu next))
2084 (nreverse sublists))
2085 ;; Few elements--put them all in one pane.
2086 menu))
2087
2088 (defun gnus-summary-make-menu-bar ()
2089 (gnus-turn-off-edit-menu 'summary)
2090
2091 (unless (boundp 'gnus-summary-misc-menu)
2092
2093 (easy-menu-define
2094 gnus-summary-kill-menu gnus-summary-mode-map ""
2095 (cons
2096 "Score"
2097 (nconc
2098 (list
2099 ["Customize" gnus-score-customize t])
2100 (gnus-make-score-map 'increase)
2101 (gnus-make-score-map 'lower)
2102 '(("Mark"
2103 ["Kill below" gnus-summary-kill-below t]
2104 ["Mark above" gnus-summary-mark-above t]
2105 ["Tick above" gnus-summary-tick-above t]
2106 ["Clear above" gnus-summary-clear-above t])
2107 ["Current score" gnus-summary-current-score t]
2108 ["Set score" gnus-summary-set-score t]
2109 ["Switch current score file..." gnus-score-change-score-file t]
2110 ["Set mark below..." gnus-score-set-mark-below t]
2111 ["Set expunge below..." gnus-score-set-expunge-below t]
2112 ["Edit current score file" gnus-score-edit-current-scores t]
2113 ["Edit score file" gnus-score-edit-file t]
2114 ["Trace score" gnus-score-find-trace t]
2115 ["Find words" gnus-score-find-favourite-words t]
2116 ["Rescore buffer" gnus-summary-rescore t]
2117 ["Increase score..." gnus-summary-increase-score t]
2118 ["Lower score..." gnus-summary-lower-score t]))))
2119
2120 ;; Define both the Article menu in the summary buffer and the
2121 ;; equivalent Commands menu in the article buffer here for
2122 ;; consistency.
2123 (let ((innards
2124 `(("Hide"
2125 ["All" gnus-article-hide t]
2126 ["Headers" gnus-article-hide-headers t]
2127 ["Signature" gnus-article-hide-signature t]
2128 ["Citation" gnus-article-hide-citation t]
2129 ["List identifiers" gnus-article-hide-list-identifiers t]
2130 ["Banner" gnus-article-strip-banner t]
2131 ["Boring headers" gnus-article-hide-boring-headers t])
2132 ("Highlight"
2133 ["All" gnus-article-highlight t]
2134 ["Headers" gnus-article-highlight-headers t]
2135 ["Signature" gnus-article-highlight-signature t]
2136 ["Citation" gnus-article-highlight-citation t])
2137 ("MIME"
2138 ["Words" gnus-article-decode-mime-words t]
2139 ["Charset" gnus-article-decode-charset t]
2140 ["QP" gnus-article-de-quoted-unreadable t]
2141 ["Base64" gnus-article-de-base64-unreadable t]
2142 ["View MIME buttons" gnus-summary-display-buttonized t]
2143 ["View all" gnus-mime-view-all-parts t]
2144 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2145 ["Encrypt body" gnus-article-encrypt-body
2146 :active (not (gnus-group-read-only-p))
2147 ,@(if (featurep 'xemacs) nil
2148 '(:help "Encrypt the message body on disk"))]
2149 ["Extract all parts..." gnus-summary-save-parts t]
2150 ("Multipart"
2151 ["Repair multipart" gnus-summary-repair-multipart t]
2152 ["Pipe part..." gnus-article-pipe-part t]
2153 ["Inline part" gnus-article-inline-part t]
2154 ["Encrypt body" gnus-article-encrypt-body
2155 :active (not (gnus-group-read-only-p))
2156 ,@(if (featurep 'xemacs) nil
2157 '(:help "Encrypt the message body on disk"))]
2158 ["View part externally" gnus-article-view-part-externally t]
2159 ["View part with charset..." gnus-article-view-part-as-charset t]
2160 ["Copy part" gnus-article-copy-part t]
2161 ["Save part..." gnus-article-save-part t]
2162 ["View part" gnus-article-view-part t]))
2163 ("Date"
2164 ["Local" gnus-article-date-local t]
2165 ["ISO8601" gnus-article-date-iso8601 t]
2166 ["UT" gnus-article-date-ut t]
2167 ["Original" gnus-article-date-original t]
2168 ["Lapsed" gnus-article-date-lapsed t]
2169 ["User-defined" gnus-article-date-user t])
2170 ("Display"
2171 ["Remove images" gnus-article-remove-images t]
2172 ["Toggle smiley" gnus-treat-smiley t]
2173 ["Show X-Face" gnus-article-display-x-face t]
2174 ["Show picons in From" gnus-treat-from-picon t]
2175 ["Show picons in mail headers" gnus-treat-mail-picon t]
2176 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2177 ("View as different encoding"
2178 ,@(gnus-summary-menu-split
2179 (mapcar
2180 (lambda (cs)
2181 ;; Since easymenu under Emacs doesn't allow
2182 ;; lambda forms for menu commands, we should
2183 ;; provide intern'ed function symbols.
2184 (let ((command (intern (format "\
2185 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2186 (fset command
2187 `(lambda ()
2188 (interactive)
2189 (let ((gnus-summary-show-article-charset-alist
2190 '((1 . ,cs))))
2191 (gnus-summary-show-article 1))))
2192 `[,(symbol-name cs) ,command t]))
2193 (sort (if (fboundp 'coding-system-list)
2194 (coding-system-list)
2195 (mapcar 'car mm-mime-mule-charset-alist))
2196 'string<)))))
2197 ("Washing"
2198 ("Remove Blanks"
2199 ["Leading" gnus-article-strip-leading-blank-lines t]
2200 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2201 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2202 ["All of the above" gnus-article-strip-blank-lines t]
2203 ["All" gnus-article-strip-all-blank-lines t]
2204 ["Leading space" gnus-article-strip-leading-space t]
2205 ["Trailing space" gnus-article-strip-trailing-space t]
2206 ["Leading space in headers"
2207 gnus-article-remove-leading-whitespace t])
2208 ["Overstrike" gnus-article-treat-overstrike t]
2209 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2210 ["Emphasis" gnus-article-emphasize t]
2211 ["Word wrap" gnus-article-fill-cited-article t]
2212 ["Fill long lines" gnus-article-fill-long-lines t]
2213 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2214 ["Remove CR" gnus-article-remove-cr t]
2215 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2216 ["Base64" gnus-article-de-base64-unreadable t]
2217 ["Rot 13" gnus-summary-caesar-message
2218 ,@(if (featurep 'xemacs) '(t)
2219 '(:help "\"Caesar rotate\" article by 13"))]
2220 ["Morse decode" gnus-summary-morse-message t]
2221 ["Unix pipe..." gnus-summary-pipe-message t]
2222 ["Add buttons" gnus-article-add-buttons t]
2223 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2224 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2225 ["Verbose header" gnus-summary-verbose-headers t]
2226 ["Toggle header" gnus-summary-toggle-header t]
2227 ["Unfold headers" gnus-article-treat-unfold-headers t]
2228 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2229 ["Html" gnus-article-wash-html t]
2230 ["Unsplit URLs" gnus-article-unsplit-urls t]
2231 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2232 ["Decode HZ" gnus-article-decode-HZ t]
2233 ("(Outlook) Deuglify"
2234 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2235 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2236 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2237 ["Full (Outlook) deuglify"
2238 gnus-article-outlook-deuglify-article t])
2239 )
2240 ("Output"
2241 ["Save in default format..." gnus-summary-save-article
2242 ,@(if (featurep 'xemacs) '(t)
2243 '(:help "Save article using default method"))]
2244 ["Save in file..." gnus-summary-save-article-file
2245 ,@(if (featurep 'xemacs) '(t)
2246 '(:help "Save article in file"))]
2247 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2248 ["Save in MH folder..." gnus-summary-save-article-folder t]
2249 ["Save in VM folder..." gnus-summary-save-article-vm t]
2250 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2251 ["Save body in file..." gnus-summary-save-article-body-file t]
2252 ["Pipe through a filter..." gnus-summary-pipe-output t]
2253 ["Add to SOUP packet" gnus-soup-add-article t]
2254 ["Print with Muttprint..." gnus-summary-muttprint t]
2255 ["Print" gnus-summary-print-article
2256 ,@(if (featurep 'xemacs) '(t)
2257 '(:help "Generate and print a PostScript image"))])
2258 ("Copy, move,... (Backend)"
2259 ,@(if (featurep 'xemacs) nil
2260 '(:help "Copying, moving, expiring articles..."))
2261 ["Respool article..." gnus-summary-respool-article t]
2262 ["Move article..." gnus-summary-move-article
2263 (gnus-check-backend-function
2264 'request-move-article gnus-newsgroup-name)]
2265 ["Copy article..." gnus-summary-copy-article t]
2266 ["Crosspost article..." gnus-summary-crosspost-article
2267 (gnus-check-backend-function
2268 'request-replace-article gnus-newsgroup-name)]
2269 ["Import file..." gnus-summary-import-article
2270 (gnus-check-backend-function
2271 'request-accept-article gnus-newsgroup-name)]
2272 ["Create article..." gnus-summary-create-article
2273 (gnus-check-backend-function
2274 'request-accept-article gnus-newsgroup-name)]
2275 ["Check if posted" gnus-summary-article-posted-p t]
2276 ["Edit article" gnus-summary-edit-article
2277 (not (gnus-group-read-only-p))]
2278 ["Delete article" gnus-summary-delete-article
2279 (gnus-check-backend-function
2280 'request-expire-articles gnus-newsgroup-name)]
2281 ["Query respool" gnus-summary-respool-query t]
2282 ["Trace respool" gnus-summary-respool-trace t]
2283 ["Delete expirable articles" gnus-summary-expire-articles-now
2284 (gnus-check-backend-function
2285 'request-expire-articles gnus-newsgroup-name)])
2286 ("Extract"
2287 ["Uudecode" gnus-uu-decode-uu
2288 ,@(if (featurep 'xemacs) '(t)
2289 '(:help "Decode uuencoded article(s)"))]
2290 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2291 ["Unshar" gnus-uu-decode-unshar t]
2292 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2293 ["Save" gnus-uu-decode-save t]
2294 ["Binhex" gnus-uu-decode-binhex t]
2295 ["Postscript" gnus-uu-decode-postscript t]
2296 ["All MIME parts" gnus-summary-save-parts t])
2297 ("Cache"
2298 ["Enter article" gnus-cache-enter-article t]
2299 ["Remove article" gnus-cache-remove-article t])
2300 ["Translate" gnus-article-babel t]
2301 ["Select article buffer" gnus-summary-select-article-buffer t]
2302 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2303 ["Isearch article..." gnus-summary-isearch-article t]
2304 ["Beginning of the article" gnus-summary-beginning-of-article t]
2305 ["End of the article" gnus-summary-end-of-article t]
2306 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2307 ["Fetch referenced articles" gnus-summary-refer-references t]
2308 ["Fetch current thread" gnus-summary-refer-thread t]
2309 ["Fetch article with id..." gnus-summary-refer-article t]
2310 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2311 ["Redisplay" gnus-summary-show-article t]
2312 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2313 (easy-menu-define
2314 gnus-summary-article-menu gnus-summary-mode-map ""
2315 (cons "Article" innards))
2316
2317 (if (not (keymapp gnus-summary-article-menu))
2318 (easy-menu-define
2319 gnus-article-commands-menu gnus-article-mode-map ""
2320 (cons "Commands" innards))
2321 ;; in Emacs, don't share menu.
2322 (setq gnus-article-commands-menu
2323 (copy-keymap gnus-summary-article-menu))
2324 (define-key gnus-article-mode-map [menu-bar commands]
2325 (cons "Commands" gnus-article-commands-menu))))
2326
2327 (easy-menu-define
2328 gnus-summary-thread-menu gnus-summary-mode-map ""
2329 '("Threads"
2330 ["Find all messages in thread" gnus-summary-refer-thread t]
2331 ["Toggle threading" gnus-summary-toggle-threads t]
2332 ["Hide threads" gnus-summary-hide-all-threads t]
2333 ["Show threads" gnus-summary-show-all-threads t]
2334 ["Hide thread" gnus-summary-hide-thread t]
2335 ["Show thread" gnus-summary-show-thread t]
2336 ["Go to next thread" gnus-summary-next-thread t]
2337 ["Go to previous thread" gnus-summary-prev-thread t]
2338 ["Go down thread" gnus-summary-down-thread t]
2339 ["Go up thread" gnus-summary-up-thread t]
2340 ["Top of thread" gnus-summary-top-thread t]
2341 ["Mark thread as read" gnus-summary-kill-thread t]
2342 ["Lower thread score" gnus-summary-lower-thread t]
2343 ["Raise thread score" gnus-summary-raise-thread t]
2344 ["Rethread current" gnus-summary-rethread-current t]))
2345
2346 (easy-menu-define
2347 gnus-summary-post-menu gnus-summary-mode-map ""
2348 `("Post"
2349 ["Send a message (mail or news)" gnus-summary-post-news
2350 ,@(if (featurep 'xemacs) '(t)
2351 '(:help "Compose a new message (mail or news)"))]
2352 ["Followup" gnus-summary-followup
2353 ,@(if (featurep 'xemacs) '(t)
2354 '(:help "Post followup to this article"))]
2355 ["Followup and yank" gnus-summary-followup-with-original
2356 ,@(if (featurep 'xemacs) '(t)
2357 '(:help "Post followup to this article, quoting its contents"))]
2358 ["Supersede article" gnus-summary-supersede-article t]
2359 ["Cancel article" gnus-summary-cancel-article
2360 ,@(if (featurep 'xemacs) '(t)
2361 '(:help "Cancel an article you posted"))]
2362 ["Reply" gnus-summary-reply t]
2363 ["Reply and yank" gnus-summary-reply-with-original t]
2364 ["Wide reply" gnus-summary-wide-reply t]
2365 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2366 ,@(if (featurep 'xemacs) '(t)
2367 '(:help "Mail a reply, quoting this article"))]
2368 ["Very wide reply" gnus-summary-very-wide-reply t]
2369 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2370 ,@(if (featurep 'xemacs) '(t)
2371 '(:help "Mail a very wide reply, quoting this article"))]
2372 ["Mail forward" gnus-summary-mail-forward t]
2373 ["Post forward" gnus-summary-post-forward t]
2374 ["Digest and mail" gnus-uu-digest-mail-forward t]
2375 ["Digest and post" gnus-uu-digest-post-forward t]
2376 ["Resend message" gnus-summary-resend-message t]
2377 ["Resend message edit" gnus-summary-resend-message-edit t]
2378 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2379 ["Send a mail" gnus-summary-mail-other-window t]
2380 ["Create a local message" gnus-summary-news-other-window t]
2381 ["Uuencode and post" gnus-uu-post-news
2382 ,@(if (featurep 'xemacs) '(t)
2383 '(:help "Post a uuencoded article"))]
2384 ["Followup via news" gnus-summary-followup-to-mail t]
2385 ["Followup via news and yank"
2386 gnus-summary-followup-to-mail-with-original t]
2387 ;;("Draft"
2388 ;;["Send" gnus-summary-send-draft t]
2389 ;;["Send bounced" gnus-resend-bounced-mail t])
2390 ))
2391
2392 (cond
2393 ((not (keymapp gnus-summary-post-menu))
2394 (setq gnus-article-post-menu gnus-summary-post-menu))
2395 ((not gnus-article-post-menu)
2396 ;; Don't share post menu.
2397 (setq gnus-article-post-menu
2398 (copy-keymap gnus-summary-post-menu))))
2399 (define-key gnus-article-mode-map [menu-bar post]
2400 (cons "Post" gnus-article-post-menu))
2401
2402 (easy-menu-define
2403 gnus-summary-misc-menu gnus-summary-mode-map ""
2404 `("Gnus"
2405 ("Mark Read"
2406 ["Mark as read" gnus-summary-mark-as-read-forward t]
2407 ["Mark same subject and select"
2408 gnus-summary-kill-same-subject-and-select t]
2409 ["Mark same subject" gnus-summary-kill-same-subject t]
2410 ["Catchup" gnus-summary-catchup
2411 ,@(if (featurep 'xemacs) '(t)
2412 '(:help "Mark unread articles in this group as read"))]
2413 ["Catchup all" gnus-summary-catchup-all t]
2414 ["Catchup to here" gnus-summary-catchup-to-here t]
2415 ["Catchup from here" gnus-summary-catchup-from-here t]
2416 ["Catchup region" gnus-summary-mark-region-as-read
2417 (gnus-mark-active-p)]
2418 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2419 ("Mark Various"
2420 ["Tick" gnus-summary-tick-article-forward t]
2421 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2422 ["Remove marks" gnus-summary-clear-mark-forward t]
2423 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2424 ["Set bookmark" gnus-summary-set-bookmark t]
2425 ["Remove bookmark" gnus-summary-remove-bookmark t])
2426 ("Limit to"
2427 ["Marks..." gnus-summary-limit-to-marks t]
2428 ["Subject..." gnus-summary-limit-to-subject t]
2429 ["Author..." gnus-summary-limit-to-author t]
2430 ["Age..." gnus-summary-limit-to-age t]
2431 ["Extra..." gnus-summary-limit-to-extra t]
2432 ["Score..." gnus-summary-limit-to-score t]
2433 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2434 ["Unread" gnus-summary-limit-to-unread t]
2435 ["Unseen" gnus-summary-limit-to-unseen t]
2436 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2437 ["Next articles" gnus-summary-limit-to-articles t]
2438 ["Pop limit" gnus-summary-pop-limit t]
2439 ["Show dormant" gnus-summary-limit-include-dormant t]
2440 ["Hide childless dormant"
2441 gnus-summary-limit-exclude-childless-dormant t]
2442 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2443 ["Hide marked" gnus-summary-limit-exclude-marks t]
2444 ["Show expunged" gnus-summary-limit-include-expunged t])
2445 ("Process Mark"
2446 ["Set mark" gnus-summary-mark-as-processable t]
2447 ["Remove mark" gnus-summary-unmark-as-processable t]
2448 ["Remove all marks" gnus-summary-unmark-all-processable t]
2449 ["Mark above" gnus-uu-mark-over t]
2450 ["Mark series" gnus-uu-mark-series t]
2451 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2452 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2453 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2454 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2455 ["Mark all" gnus-uu-mark-all t]
2456 ["Mark buffer" gnus-uu-mark-buffer t]
2457 ["Mark sparse" gnus-uu-mark-sparse t]
2458 ["Mark thread" gnus-uu-mark-thread t]
2459 ["Unmark thread" gnus-uu-unmark-thread t]
2460 ("Process Mark Sets"
2461 ["Kill" gnus-summary-kill-process-mark t]
2462 ["Yank" gnus-summary-yank-process-mark
2463 gnus-newsgroup-process-stack]
2464 ["Save" gnus-summary-save-process-mark t]
2465 ["Run command on marked..." gnus-summary-universal-argument t]))
2466 ("Scroll article"
2467 ["Page forward" gnus-summary-next-page
2468 ,@(if (featurep 'xemacs) '(t)
2469 '(:help "Show next page of article"))]
2470 ["Page backward" gnus-summary-prev-page
2471 ,@(if (featurep 'xemacs) '(t)
2472 '(:help "Show previous page of article"))]
2473 ["Line forward" gnus-summary-scroll-up t])
2474 ("Move"
2475 ["Next unread article" gnus-summary-next-unread-article t]
2476 ["Previous unread article" gnus-summary-prev-unread-article t]
2477 ["Next article" gnus-summary-next-article t]
2478 ["Previous article" gnus-summary-prev-article t]
2479 ["Next unread subject" gnus-summary-next-unread-subject t]
2480 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2481 ["Next article same subject" gnus-summary-next-same-subject t]
2482 ["Previous article same subject" gnus-summary-prev-same-subject t]
2483 ["First unread article" gnus-summary-first-unread-article t]
2484 ["Best unread article" gnus-summary-best-unread-article t]
2485 ["Go to subject number..." gnus-summary-goto-subject t]
2486 ["Go to article number..." gnus-summary-goto-article t]
2487 ["Go to the last article" gnus-summary-goto-last-article t]
2488 ["Pop article off history" gnus-summary-pop-article t])
2489 ("Sort"
2490 ["Sort by number" gnus-summary-sort-by-number t]
2491 ["Sort by author" gnus-summary-sort-by-author t]
2492 ["Sort by subject" gnus-summary-sort-by-subject t]
2493 ["Sort by date" gnus-summary-sort-by-date t]
2494 ["Sort by score" gnus-summary-sort-by-score t]
2495 ["Sort by lines" gnus-summary-sort-by-lines t]
2496 ["Sort by characters" gnus-summary-sort-by-chars t]
2497 ["Randomize" gnus-summary-sort-by-random t]
2498 ["Original sort" gnus-summary-sort-by-original t])
2499 ("Help"
2500 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2501 ["Describe group" gnus-summary-describe-group t]
2502 ["Fetch charter" gnus-group-fetch-charter
2503 ,@(if (featurep 'xemacs) nil
2504 '(:help "Display the charter of the current group"))]
2505 ["Fetch control message" gnus-group-fetch-control
2506 ,@(if (featurep 'xemacs) nil
2507 '(:help "Display the archived control message for the current group"))]
2508 ["Read manual" gnus-info-find-node t])
2509 ("Modes"
2510 ["Pick and read" gnus-pick-mode t]
2511 ["Binary" gnus-binary-mode t])
2512 ("Regeneration"
2513 ["Regenerate" gnus-summary-prepare t]
2514 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2515 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2516 ["Toggle threading" gnus-summary-toggle-threads t])
2517 ["See old articles" gnus-summary-insert-old-articles t]
2518 ["See new articles" gnus-summary-insert-new-articles t]
2519 ["Filter articles..." gnus-summary-execute-command t]
2520 ["Run command on articles..." gnus-summary-universal-argument t]
2521 ["Search articles forward..." gnus-summary-search-article-forward t]
2522 ["Search articles backward..." gnus-summary-search-article-backward t]
2523 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2524 ["Expand window" gnus-summary-expand-window t]
2525 ["Expire expirable articles" gnus-summary-expire-articles
2526 (gnus-check-backend-function
2527 'request-expire-articles gnus-newsgroup-name)]
2528 ["Edit local kill file" gnus-summary-edit-local-kill t]
2529 ["Edit main kill file" gnus-summary-edit-global-kill t]
2530 ["Edit group parameters" gnus-summary-edit-parameters t]
2531 ["Customize group parameters" gnus-summary-customize-parameters t]
2532 ["Send a bug report" gnus-bug t]
2533 ("Exit"
2534 ["Catchup and exit" gnus-summary-catchup-and-exit
2535 ,@(if (featurep 'xemacs) '(t)
2536 '(:help "Mark unread articles in this group as read, then exit"))]
2537 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2538 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2539 ["Exit group" gnus-summary-exit
2540 ,@(if (featurep 'xemacs) '(t)
2541 '(:help "Exit current group, return to group selection mode"))]
2542 ["Exit group without updating" gnus-summary-exit-no-update t]
2543 ["Exit and goto next group" gnus-summary-next-group t]
2544 ["Exit and goto prev group" gnus-summary-prev-group t]
2545 ["Reselect group" gnus-summary-reselect-current-group t]
2546 ["Rescan group" gnus-summary-rescan-group t]
2547 ["Update dribble" gnus-summary-save-newsrc t])))
2548
2549 (gnus-run-hooks 'gnus-summary-menu-hook)))
2550
2551 (defvar gnus-summary-tool-bar-map nil)
2552
2553 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2554 ;; affect _new_ message buffers. We might add a function that walks thru all
2555 ;; summary-mode buffers and force the update.
2556 (defun gnus-summary-tool-bar-update (&optional symbol value)
2557 "Update summary mode toolbar.
2558 Setter function for custom variables."
2559 (setq-default gnus-summary-tool-bar-map nil)
2560 (when symbol
2561 ;; When used as ":set" function:
2562 (set-default symbol value))
2563 (when (gnus-buffer-live-p gnus-summary-buffer)
2564 (with-current-buffer gnus-summary-buffer
2565 (gnus-summary-make-tool-bar))))
2566
2567 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2568 'gnus-summary-tool-bar-gnome
2569 'gnus-summary-tool-bar-retro)
2570 "Specifies the Gnus summary tool bar.
2571
2572 It can be either a list or a symbol refering to a list. See
2573 `gmm-tool-bar-from-list' for the format of the list. The
2574 default key map is `gnus-summary-mode-map'.
2575
2576 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2577 `gnus-summary-tool-bar-retro'."
2578 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2579 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2580 (repeat :tag "User defined list" gmm-tool-bar-item)
2581 (symbol))
2582 :version "22.1" ;; Gnus 5.10.9
2583 :initialize 'custom-initialize-default
2584 :set 'gnus-summary-tool-bar-update
2585 :group 'gnus-summary)
2586
2587 (defcustom gnus-summary-tool-bar-gnome
2588 '((gnus-summary-post-news "mail/compose" nil)
2589 (gnus-summary-insert-new-articles "mail/inbox" nil
2590 :visible (or (not gnus-agent)
2591 gnus-plugged))
2592 (gnus-summary-reply-with-original "mail/reply")
2593 (gnus-summary-reply "mail/reply" nil :visible nil)
2594 (gnus-summary-followup-with-original "mail/reply-all")
2595 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2596 (gnus-summary-mail-forward "mail/forward")
2597 (gnus-summary-save-article "mail/save")
2598 (gnus-summary-search-article-forward "search" nil :visible nil)
2599 (gnus-summary-print-article "print")
2600 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2601 ;; Some new commands that may need more suitable icons:
2602 (gnus-summary-save-newsrc "save" nil :visible nil)
2603 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2604 (gnus-summary-prev-article "left-arrow")
2605 (gnus-summary-next-article "right-arrow")
2606 (gnus-summary-next-page "next-page")
2607 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2608 ;;
2609 ;; Maybe some sort-by-... could be added:
2610 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2611 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2612 (gnus-summary-mark-as-expirable
2613 "delete" nil
2614 :visible (gnus-check-backend-function 'request-expire-articles
2615 gnus-newsgroup-name))
2616 (gnus-summary-mark-as-spam
2617 "mail/spam" t
2618 :visible (and (fboundp 'spam-group-ham-contents-p)
2619 (spam-group-ham-contents-p gnus-newsgroup-name))
2620 :help "Mark as spam")
2621 (gnus-summary-mark-as-read-forward
2622 "mail/not-spam" nil
2623 :visible (and (fboundp 'spam-group-spam-contents-p)
2624 (spam-group-spam-contents-p gnus-newsgroup-name)))
2625 ;;
2626 (gnus-summary-exit "exit")
2627 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2628 (gnus-info-find-node "help"))
2629 "List of functions for the summary tool bar (GNOME style).
2630
2631 See `gmm-tool-bar-from-list' for the format of the list."
2632 :type '(repeat gmm-tool-bar-item)
2633 :version "22.1" ;; Gnus 5.10.9
2634 :initialize 'custom-initialize-default
2635 :set 'gnus-summary-tool-bar-update
2636 :group 'gnus-summary)
2637
2638 (defcustom gnus-summary-tool-bar-retro
2639 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2640 (gnus-summary-next-unread-article "gnus/next-ur")
2641 (gnus-summary-post-news "gnus/post")
2642 (gnus-summary-followup-with-original "gnus/fuwo")
2643 (gnus-summary-followup "gnus/followup")
2644 (gnus-summary-reply-with-original "gnus/reply-wo")
2645 (gnus-summary-reply "gnus/reply")
2646 (gnus-summary-caesar-message "gnus/rot13")
2647 (gnus-uu-decode-uu "gnus/uu-decode")
2648 (gnus-summary-save-article-file "gnus/save-aif")
2649 (gnus-summary-save-article "gnus/save-art")
2650 (gnus-uu-post-news "gnus/uu-post")
2651 (gnus-summary-catchup "gnus/catchup")
2652 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2653 (gnus-summary-exit "gnus/exit-summ")
2654 ;; Some new command that may need more suitable icons:
2655 (gnus-summary-print-article "gnus/print" nil :visible nil)
2656 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2657 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2658 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2659 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2660 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2661 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2662 ;;
2663 (gnus-info-find-node "gnus/help" nil :visible nil))
2664 "List of functions for the summary tool bar (retro look).
2665
2666 See `gmm-tool-bar-from-list' for the format of the list."
2667 :type '(repeat gmm-tool-bar-item)
2668 :version "22.1" ;; Gnus 5.10.9
2669 :initialize 'custom-initialize-default
2670 :set 'gnus-summary-tool-bar-update
2671 :group 'gnus-summary)
2672
2673 (defcustom gnus-summary-tool-bar-zap-list t
2674 "List of icon items from the global tool bar.
2675 These items are not displayed in the Gnus summary mode tool bar.
2676
2677 See `gmm-tool-bar-from-list' for the format of the list."
2678 :type 'gmm-tool-bar-zap-list
2679 :version "22.1" ;; Gnus 5.10.9
2680 :initialize 'custom-initialize-default
2681 :set 'gnus-summary-tool-bar-update
2682 :group 'gnus-summary)
2683
2684 (defvar image-load-path)
2685
2686 (defun gnus-summary-make-tool-bar (&optional force)
2687 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2688 When FORCE, rebuild the tool bar."
2689 (when (and (not (featurep 'xemacs))
2690 (boundp 'tool-bar-mode)
2691 tool-bar-mode
2692 (or (not gnus-summary-tool-bar-map) force))
2693 (let* ((load-path
2694 (gmm-image-load-path-for-library "gnus"
2695 "mail/save.xpm"
2696 nil t))
2697 (image-load-path (cons (car load-path)
2698 (when (boundp 'image-load-path)
2699 image-load-path)))
2700 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2701 gnus-summary-tool-bar-zap-list
2702 'gnus-summary-mode-map)))
2703 (when map
2704 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2705 ;; uses it's value.
2706 (setq gnus-summary-tool-bar-map map))))
2707 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2708
2709 (defun gnus-score-set-default (var value)
2710 "A version of set that updates the GNU Emacs menu-bar."
2711 (set var value)
2712 ;; It is the message that forces the active status to be updated.
2713 (message ""))
2714
2715 (defun gnus-make-score-map (type)
2716 "Make a summary score map of type TYPE."
2717 (if t
2718 nil
2719 (let ((headers '(("author" "from" string)
2720 ("subject" "subject" string)
2721 ("article body" "body" string)
2722 ("article head" "head" string)
2723 ("xref" "xref" string)
2724 ("extra header" "extra" string)
2725 ("lines" "lines" number)
2726 ("followups to author" "followup" string)))
2727 (types '((number ("less than" <)
2728 ("greater than" >)
2729 ("equal" =))
2730 (string ("substring" s)
2731 ("exact string" e)
2732 ("fuzzy string" f)
2733 ("regexp" r))))
2734 (perms '(("temporary" (current-time-string))
2735 ("permanent" nil)
2736 ("immediate" now)))
2737 header)
2738 (list
2739 (apply
2740 'nconc
2741 (list
2742 (if (eq type 'lower)
2743 "Lower score"
2744 "Increase score"))
2745 (let (outh)
2746 (while headers
2747 (setq header (car headers))
2748 (setq outh
2749 (cons
2750 (apply
2751 'nconc
2752 (list (car header))
2753 (let ((ts (cdr (assoc (nth 2 header) types)))
2754 outt)
2755 (while ts
2756 (setq outt
2757 (cons
2758 (apply
2759 'nconc
2760 (list (caar ts))
2761 (let ((ps perms)
2762 outp)
2763 (while ps
2764 (setq outp
2765 (cons
2766 (vector
2767 (caar ps)
2768 (list
2769 'gnus-summary-score-entry
2770 (nth 1 header)
2771 (if (or (string= (nth 1 header)
2772 "head")
2773 (string= (nth 1 header)
2774 "body"))
2775 ""
2776 (list 'gnus-summary-header
2777 (nth 1 header)))
2778 (list 'quote (nth 1 (car ts)))
2779 (list 'gnus-score-delta-default
2780 nil)
2781 (nth 1 (car ps))
2782 t)
2783 t)
2784 outp))
2785 (setq ps (cdr ps)))
2786 (list (nreverse outp))))
2787 outt))
2788 (setq ts (cdr ts)))
2789 (list (nreverse outt))))
2790 outh))
2791 (setq headers (cdr headers)))
2792 (list (nreverse outh))))))))
2793
2794 \f
2795
2796 (defun gnus-summary-mode (&optional group)
2797 "Major mode for reading articles.
2798
2799 All normal editing commands are switched off.
2800 \\<gnus-summary-mode-map>
2801 Each line in this buffer represents one article. To read an
2802 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2803 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2804 respectively.
2805
2806 You can also post articles and send mail from this buffer. To
2807 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2808 of an article, type `\\[gnus-summary-reply]'.
2809
2810 There are approx. one gazillion commands you can execute in this
2811 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2812
2813 The following commands are available:
2814
2815 \\{gnus-summary-mode-map}"
2816 (interactive)
2817 (kill-all-local-variables)
2818 (when (gnus-visual-p 'summary-menu 'menu)
2819 (gnus-summary-make-menu-bar)
2820 (gnus-summary-make-tool-bar))
2821 (gnus-summary-make-local-variables)
2822 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2823 (gnus-summary-make-local-variables))
2824 (gnus-make-thread-indent-array)
2825 (gnus-simplify-mode-line)
2826 (setq major-mode 'gnus-summary-mode)
2827 (setq mode-name "Summary")
2828 (make-local-variable 'minor-mode-alist)
2829 (use-local-map gnus-summary-mode-map)
2830 (buffer-disable-undo)
2831 (setq buffer-read-only t) ;Disable modification
2832 (setq truncate-lines t)
2833 (setq selective-display t)
2834 (setq selective-display-ellipses t) ;Display `...'
2835 (gnus-summary-set-display-table)
2836 (gnus-set-default-directory)
2837 (setq gnus-newsgroup-name group)
2838 (make-local-variable 'gnus-summary-line-format)
2839 (make-local-variable 'gnus-summary-line-format-spec)
2840 (make-local-variable 'gnus-summary-dummy-line-format)
2841 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2842 (make-local-variable 'gnus-summary-mark-positions)
2843 (gnus-make-local-hook 'pre-command-hook)
2844 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2845 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2846 (turn-on-gnus-mailing-list-mode)
2847 (mm-enable-multibyte)
2848 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2849 (gnus-update-summary-mark-positions))
2850
2851 (defun gnus-summary-make-local-variables ()
2852 "Make all the local summary buffer variables."
2853 (let (global)
2854 (dolist (local gnus-summary-local-variables)
2855 (if (consp local)
2856 (progn
2857 (if (eq (cdr local) 'global)
2858 ;; Copy the global value of the variable.
2859 (setq global (symbol-value (car local)))
2860 ;; Use the value from the list.
2861 (setq global (eval (cdr local))))
2862 (set (make-local-variable (car local)) global))
2863 ;; Simple nil-valued local variable.
2864 (set (make-local-variable local) nil)))))
2865
2866 (defun gnus-summary-clear-local-variables ()
2867 (let ((locals gnus-summary-local-variables))
2868 (while locals
2869 (if (consp (car locals))
2870 (and (vectorp (caar locals))
2871 (set (caar locals) nil))
2872 (and (vectorp (car locals))
2873 (set (car locals) nil)))
2874 (setq locals (cdr locals)))))
2875
2876 ;; Summary data functions.
2877
2878 (defmacro gnus-data-number (data)
2879 `(car ,data))
2880
2881 (defmacro gnus-data-set-number (data number)
2882 `(setcar ,data ,number))
2883
2884 (defmacro gnus-data-mark (data)
2885 `(nth 1 ,data))
2886
2887 (defmacro gnus-data-set-mark (data mark)
2888 `(setcar (nthcdr 1 ,data) ,mark))
2889
2890 (defmacro gnus-data-pos (data)
2891 `(nth 2 ,data))
2892
2893 (defmacro gnus-data-set-pos (data pos)
2894 `(setcar (nthcdr 2 ,data) ,pos))
2895
2896 (defmacro gnus-data-header (data)
2897 `(nth 3 ,data))
2898
2899 (defmacro gnus-data-set-header (data header)
2900 `(setf (nth 3 ,data) ,header))
2901
2902 (defmacro gnus-data-level (data)
2903 `(nth 4 ,data))
2904
2905 (defmacro gnus-data-unread-p (data)
2906 `(= (nth 1 ,data) gnus-unread-mark))
2907
2908 (defmacro gnus-data-read-p (data)
2909 `(/= (nth 1 ,data) gnus-unread-mark))
2910
2911 (defmacro gnus-data-pseudo-p (data)
2912 `(consp (nth 3 ,data)))
2913
2914 (defmacro gnus-data-find (number)
2915 `(assq ,number gnus-newsgroup-data))
2916
2917 (defmacro gnus-data-find-list (number &optional data)
2918 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2919 (memq (assq ,number bdata)
2920 bdata)))
2921
2922 (defmacro gnus-data-make (number mark pos header level)
2923 `(list ,number ,mark ,pos ,header ,level))
2924
2925 (defun gnus-data-enter (after-article number mark pos header level offset)
2926 (let ((data (gnus-data-find-list after-article)))
2927 (unless data
2928 (error "No such article: %d" after-article))
2929 (setcdr data (cons (gnus-data-make number mark pos header level)
2930 (cdr data)))
2931 (setq gnus-newsgroup-data-reverse nil)
2932 (gnus-data-update-list (cddr data) offset)))
2933
2934 (defun gnus-data-enter-list (after-article list &optional offset)
2935 (when list
2936 (let ((data (and after-article (gnus-data-find-list after-article)))
2937 (ilist list))
2938 (if (not (or data
2939 after-article))
2940 (let ((odata gnus-newsgroup-data))
2941 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2942 (when offset
2943 (gnus-data-update-list odata offset)))
2944 ;; Find the last element in the list to be spliced into the main
2945 ;; list.
2946 (while (cdr list)
2947 (setq list (cdr list)))
2948 (if (not data)
2949 (progn
2950 (setcdr list gnus-newsgroup-data)
2951 (setq gnus-newsgroup-data ilist)
2952 (when offset
2953 (gnus-data-update-list (cdr list) offset)))
2954 (setcdr list (cdr data))
2955 (setcdr data ilist)
2956 (when offset
2957 (gnus-data-update-list (cdr list) offset))))
2958 (setq gnus-newsgroup-data-reverse nil))))
2959
2960 (defun gnus-data-remove (article &optional offset)
2961 (let ((data gnus-newsgroup-data))
2962 (if (= (gnus-data-number (car data)) article)
2963 (progn
2964 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2965 gnus-newsgroup-data-reverse nil)
2966 (when offset
2967 (gnus-data-update-list gnus-newsgroup-data offset)))
2968 (while (cdr data)
2969 (when (= (gnus-data-number (cadr data)) article)
2970 (setcdr data (cddr data))
2971 (when offset
2972 (gnus-data-update-list (cdr data) offset))
2973 (setq data nil
2974 gnus-newsgroup-data-reverse nil))
2975 (setq data (cdr data))))))
2976
2977 (defmacro gnus-data-list (backward)
2978 `(if ,backward
2979 (or gnus-newsgroup-data-reverse
2980 (setq gnus-newsgroup-data-reverse
2981 (reverse gnus-newsgroup-data)))
2982 gnus-newsgroup-data))
2983
2984 (defun gnus-data-update-list (data offset)
2985 "Add OFFSET to the POS of all data entries in DATA."
2986 (setq gnus-newsgroup-data-reverse nil)
2987 (while data
2988 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2989 (setq data (cdr data))))
2990
2991 (defun gnus-summary-article-pseudo-p (article)
2992 "Say whether this article is a pseudo article or not."
2993 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2994
2995 (defmacro gnus-summary-article-sparse-p (article)
2996 "Say whether this article is a sparse article or not."
2997 `(memq ,article gnus-newsgroup-sparse))
2998
2999 (defmacro gnus-summary-article-ancient-p (article)
3000 "Say whether this article is a sparse article or not."
3001 `(memq ,article gnus-newsgroup-ancient))
3002
3003 (defun gnus-article-parent-p (number)
3004 "Say whether this article is a parent or not."
3005 (let ((data (gnus-data-find-list number)))
3006 (and (cdr data) ; There has to be an article after...
3007 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3008 (gnus-data-level (nth 1 data))))))
3009
3010 (defun gnus-article-children (number)
3011 "Return a list of all children to NUMBER."
3012 (let* ((data (gnus-data-find-list number))
3013 (level (gnus-data-level (car data)))
3014 children)
3015 (setq data (cdr data))
3016 (while (and data
3017 (= (gnus-data-level (car data)) (1+ level)))
3018 (push (gnus-data-number (car data)) children)
3019 (setq data (cdr data)))
3020 children))
3021
3022 (defmacro gnus-summary-skip-intangible ()
3023 "If the current article is intangible, then jump to a different article."
3024 '(let ((to (get-text-property (point) 'gnus-intangible)))
3025 (and to (gnus-summary-goto-subject to))))
3026
3027 (defmacro gnus-summary-article-intangible-p ()
3028 "Say whether this article is intangible or not."
3029 '(get-text-property (point) 'gnus-intangible))
3030
3031 (defun gnus-article-read-p (article)
3032 "Say whether ARTICLE is read or not."
3033 (not (or (memq article gnus-newsgroup-marked)
3034 (memq article gnus-newsgroup-spam-marked)
3035 (memq article gnus-newsgroup-unreads)
3036 (memq article gnus-newsgroup-unselected)
3037 (memq article gnus-newsgroup-dormant))))
3038
3039 ;; Some summary mode macros.
3040
3041 (defmacro gnus-summary-article-number ()
3042 "The article number of the article on the current line.
3043 If there isn't an article number here, then we return the current
3044 article number."
3045 '(progn
3046 (gnus-summary-skip-intangible)
3047 (or (get-text-property (point) 'gnus-number)
3048 (gnus-summary-last-subject))))
3049
3050 (defmacro gnus-summary-article-header (&optional number)
3051 "Return the header of article NUMBER."
3052 `(gnus-data-header (gnus-data-find
3053 ,(or number '(gnus-summary-article-number)))))
3054
3055 (defmacro gnus-summary-thread-level (&optional number)
3056 "Return the level of thread that starts with article NUMBER."
3057 `(if (and (eq gnus-summary-make-false-root 'dummy)
3058 (get-text-property (point) 'gnus-intangible))
3059 0
3060 (gnus-data-level (gnus-data-find
3061 ,(or number '(gnus-summary-article-number))))))
3062
3063 (defmacro gnus-summary-article-mark (&optional number)
3064 "Return the mark of article NUMBER."
3065 `(gnus-data-mark (gnus-data-find
3066 ,(or number '(gnus-summary-article-number)))))
3067
3068 (defmacro gnus-summary-article-pos (&optional number)
3069 "Return the position of the line of article NUMBER."
3070 `(gnus-data-pos (gnus-data-find
3071 ,(or number '(gnus-summary-article-number)))))
3072
3073 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3074 (defmacro gnus-summary-article-subject (&optional number)
3075 "Return current subject string or nil if nothing."
3076 `(let ((headers
3077 ,(if number
3078 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3079 '(gnus-data-header (assq (gnus-summary-article-number)
3080 gnus-newsgroup-data)))))
3081 (and headers
3082 (vectorp headers)
3083 (mail-header-subject headers))))
3084
3085 (defmacro gnus-summary-article-score (&optional number)
3086 "Return current article score."
3087 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3088 gnus-newsgroup-scored))
3089 gnus-summary-default-score 0))
3090
3091 (defun gnus-summary-article-children (&optional number)
3092 "Return a list of article numbers that are children of article NUMBER."
3093 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3094 (level (gnus-data-level (car data)))
3095 l children)
3096 (while (and (setq data (cdr data))
3097 (> (setq l (gnus-data-level (car data))) level))
3098 (and (= (1+ level) l)
3099 (push (gnus-data-number (car data))
3100 children)))
3101 (nreverse children)))
3102
3103 (defun gnus-summary-article-parent (&optional number)
3104 "Return the article number of the parent of article NUMBER."
3105 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3106 (gnus-data-list t)))
3107 (level (gnus-data-level (car data))))
3108 (if (zerop level)
3109 () ; This is a root.
3110 ;; We search until we find an article with a level less than
3111 ;; this one. That function has to be the parent.
3112 (while (and (setq data (cdr data))
3113 (not (< (gnus-data-level (car data)) level))))
3114 (and data (gnus-data-number (car data))))))
3115
3116 (defun gnus-unread-mark-p (mark)
3117 "Say whether MARK is the unread mark."
3118 (= mark gnus-unread-mark))
3119
3120 (defun gnus-read-mark-p (mark)
3121 "Say whether MARK is one of the marks that mark as read.
3122 This is all marks except unread, ticked, dormant, and expirable."
3123 (not (or (= mark gnus-unread-mark)
3124 (= mark gnus-ticked-mark)
3125 (= mark gnus-spam-mark)
3126 (= mark gnus-dormant-mark)
3127 (= mark gnus-expirable-mark))))
3128
3129 (defmacro gnus-article-mark (number)
3130 "Return the MARK of article NUMBER.
3131 This macro should only be used when computing the mark the \"first\"
3132 time; i.e., when generating the summary lines. After that,
3133 `gnus-summary-article-mark' should be used to examine the
3134 marks of articles."
3135 `(cond
3136 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3137 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3138 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3139 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3140 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3141 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3142 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3143 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3144 gnus-ancient-mark))))
3145
3146 ;; Saving hidden threads.
3147
3148 (defmacro gnus-save-hidden-threads (&rest forms)
3149 "Save hidden threads, eval FORMS, and restore the hidden threads."
3150 (let ((config (make-symbol "config")))
3151 `(let ((,config (gnus-hidden-threads-configuration)))
3152 (unwind-protect
3153 (save-excursion
3154 ,@forms)
3155 (gnus-restore-hidden-threads-configuration ,config)))))
3156 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3157 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3158
3159 (defun gnus-data-compute-positions ()
3160 "Compute the positions of all articles."
3161 (setq gnus-newsgroup-data-reverse nil)
3162 (let ((data gnus-newsgroup-data))
3163 (save-excursion
3164 (gnus-save-hidden-threads
3165 (gnus-summary-show-all-threads)
3166 (goto-char (point-min))
3167 (while data
3168 (while (get-text-property (point) 'gnus-intangible)
3169 (forward-line 1))
3170 (gnus-data-set-pos (car data) (+ (point) 3))
3171 (setq data (cdr data))
3172 (forward-line 1))))))
3173
3174 (defun gnus-hidden-threads-configuration ()
3175 "Return the current hidden threads configuration."
3176 (save-excursion
3177 (let (config)
3178 (goto-char (point-min))
3179 (while (search-forward "\r" nil t)
3180 (push (1- (point)) config))
3181 config)))
3182
3183 (defun gnus-restore-hidden-threads-configuration (config)
3184 "Restore hidden threads configuration from CONFIG."
3185 (save-excursion
3186 (let (point buffer-read-only)
3187 (while (setq point (pop config))
3188 (when (and (< point (point-max))
3189 (goto-char point)
3190 (eq (char-after) ?\n))
3191 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3192
3193 ;; Various summary mode internalish functions.
3194
3195 (defun gnus-mouse-pick-article (e)
3196 (interactive "e")
3197 (mouse-set-point e)
3198 (gnus-summary-next-page nil t))
3199
3200 (defun gnus-summary-set-display-table ()
3201 "Change the display table.
3202 Odd characters have a tendency to mess
3203 up nicely formatted displays - we make all possible glyphs
3204 display only a single character."
3205
3206 ;; We start from the standard display table, if any.
3207 (let ((table (or (copy-sequence standard-display-table)
3208 (make-display-table)))
3209 (i 32))
3210 ;; Nix out all the control chars...
3211 (while (>= (setq i (1- i)) 0)
3212 (aset table i [??]))
3213 ;; ... but not newline and cr, of course. (cr is necessary for the
3214 ;; selective display).
3215 (aset table ?\n nil)
3216 (aset table ?\r nil)
3217 ;; We keep TAB as well.
3218 (aset table ?\t nil)
3219 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3220 ;; Emacs 23 (unicode), that are not set already.
3221 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3222 160
3223 256)))
3224 (while (>= (setq i (1- i)) 127)
3225 ;; Only modify if the entry is nil.
3226 (unless (aref table i)
3227 (aset table i [??]))))
3228 (setq buffer-display-table table)))
3229
3230 (defun gnus-summary-set-article-display-arrow (pos)
3231 "Update the overlay arrow to point to line at position POS."
3232 (when (and gnus-summary-display-arrow
3233 (boundp 'overlay-arrow-position)
3234 (boundp 'overlay-arrow-string))
3235 (save-excursion
3236 (goto-char pos)
3237 (beginning-of-line)
3238 (unless overlay-arrow-position
3239 (setq overlay-arrow-position (make-marker)))
3240 (setq overlay-arrow-string "=>"
3241 overlay-arrow-position (set-marker overlay-arrow-position
3242 (point)
3243 (current-buffer))))))
3244
3245 (defun gnus-summary-setup-buffer (group)
3246 "Initialize summary buffer."
3247 (let ((buffer (gnus-summary-buffer-name group))
3248 (dead-name (concat "*Dead Summary "
3249 (gnus-group-decoded-name group) "*")))
3250 ;; If a dead summary buffer exists, we kill it.
3251 (when (gnus-buffer-live-p dead-name)
3252 (gnus-kill-buffer dead-name))
3253 (if (get-buffer buffer)
3254 (progn
3255 (set-buffer buffer)
3256 (setq gnus-summary-buffer (current-buffer))
3257 (not gnus-newsgroup-prepared))
3258 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3259 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3260 (gnus-summary-mode group)
3261 (when gnus-carpal
3262 (gnus-carpal-setup-buffer 'summary))
3263 (unless gnus-single-article-buffer
3264 (make-local-variable 'gnus-article-buffer)
3265 (make-local-variable 'gnus-article-current)
3266 (make-local-variable 'gnus-original-article-buffer))
3267 (setq gnus-newsgroup-name group)
3268 ;; Set any local variables in the group parameters.
3269 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3270 t)))
3271
3272 (defun gnus-set-global-variables ()
3273 "Set the global equivalents of the buffer-local variables.
3274 They are set to the latest values they had. These reflect the summary
3275 buffer that was in action when the last article was fetched."
3276 (when (eq major-mode 'gnus-summary-mode)
3277 (setq gnus-summary-buffer (current-buffer))
3278 (let ((name gnus-newsgroup-name)
3279 (marked gnus-newsgroup-marked)
3280 (spam gnus-newsgroup-spam-marked)
3281 (unread gnus-newsgroup-unreads)
3282 (headers gnus-current-headers)
3283 (data gnus-newsgroup-data)
3284 (summary gnus-summary-buffer)
3285 (article-buffer gnus-article-buffer)
3286 (original gnus-original-article-buffer)
3287 (gac gnus-article-current)
3288 (reffed gnus-reffed-article-number)
3289 (score-file gnus-current-score-file)
3290 (default-charset gnus-newsgroup-charset)
3291 vlist)
3292 (let ((locals gnus-newsgroup-variables))
3293 (while locals
3294 (if (consp (car locals))
3295 (push (eval (caar locals)) vlist)
3296 (push (eval (car locals)) vlist))
3297 (setq locals (cdr locals)))
3298 (setq vlist (nreverse vlist)))
3299 (save-excursion
3300 (set-buffer gnus-group-buffer)
3301 (setq gnus-newsgroup-name name
3302 gnus-newsgroup-marked marked
3303 gnus-newsgroup-spam-marked spam
3304 gnus-newsgroup-unreads unread
3305 gnus-current-headers headers
3306 gnus-newsgroup-data data
3307 gnus-article-current gac
3308 gnus-summary-buffer summary
3309 gnus-article-buffer article-buffer
3310 gnus-original-article-buffer original
3311 gnus-reffed-article-number reffed
3312 gnus-current-score-file score-file
3313 gnus-newsgroup-charset default-charset)
3314 (let ((locals gnus-newsgroup-variables))
3315 (while locals
3316 (if (consp (car locals))
3317 (set (caar locals) (pop vlist))
3318 (set (car locals) (pop vlist)))
3319 (setq locals (cdr locals))))
3320 ;; The article buffer also has local variables.
3321 (when (gnus-buffer-live-p gnus-article-buffer)
3322 (set-buffer gnus-article-buffer)
3323 (setq gnus-summary-buffer summary))))))
3324
3325 (defun gnus-summary-article-unread-p (article)
3326 "Say whether ARTICLE is unread or not."
3327 (memq article gnus-newsgroup-unreads))
3328
3329 (defun gnus-summary-first-article-p (&optional article)
3330 "Return whether ARTICLE is the first article in the buffer."
3331 (if (not (setq article (or article (gnus-summary-article-number))))
3332 nil
3333 (eq article (caar gnus-newsgroup-data))))
3334
3335 (defun gnus-summary-last-article-p (&optional article)
3336 "Return whether ARTICLE is the last article in the buffer."
3337 (if (not (setq article (or article (gnus-summary-article-number))))
3338 ;; All non-existent numbers are the last article. :-)
3339 t
3340 (not (cdr (gnus-data-find-list article)))))
3341
3342 (defun gnus-make-thread-indent-array ()
3343 (let ((n 200))
3344 (unless (and gnus-thread-indent-array
3345 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3346 (setq gnus-thread-indent-array (make-vector 201 "")
3347 gnus-thread-indent-array-level gnus-thread-indent-level)
3348 (while (>= n 0)
3349 (aset gnus-thread-indent-array n
3350 (make-string (* n gnus-thread-indent-level) ? ))
3351 (setq n (1- n))))))
3352
3353 (defun gnus-update-summary-mark-positions ()
3354 "Compute where the summary marks are to go."
3355 (save-excursion
3356 (when (gnus-buffer-exists-p gnus-summary-buffer)
3357 (set-buffer gnus-summary-buffer))
3358 (let ((spec gnus-summary-line-format-spec)
3359 pos)
3360 (save-excursion
3361 (gnus-set-work-buffer)
3362 (let ((gnus-tmp-unread ?Z)
3363 (gnus-replied-mark ?Z)
3364 (gnus-score-below-mark ?Z)
3365 (gnus-score-over-mark ?Z)
3366 (gnus-undownloaded-mark ?Z)
3367 (gnus-summary-line-format-spec spec)
3368 (gnus-newsgroup-downloadable '(0))
3369 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3370 case-fold-search ignores)
3371 ;; Here, all marks are bound to Z.
3372 (gnus-summary-insert-line header
3373 0 nil t gnus-tmp-unread t nil "" nil 1)
3374 (goto-char (point-min))
3375 ;; Memorize the positions of the same characters as dummy marks.
3376 (while (re-search-forward "[A-D]" nil t)
3377 (push (point) ignores))
3378 (erase-buffer)
3379 ;; We use A-D as dummy marks in order to know column positions
3380 ;; where marks should be inserted.
3381 (setq gnus-tmp-unread ?A
3382 gnus-replied-mark ?B
3383 gnus-score-below-mark ?C
3384 gnus-score-over-mark ?C
3385 gnus-undownloaded-mark ?D)
3386 (gnus-summary-insert-line header
3387 0 nil t gnus-tmp-unread t nil "" nil 1)
3388 ;; Ignore characters which aren't dummy marks.
3389 (dolist (p ignores)
3390 (delete-region (goto-char (1- p)) p)
3391 (insert ?Z))
3392 (goto-char (point-min))
3393 (setq pos (list (cons 'unread
3394 (and (search-forward "A" nil t)
3395 (- (point) (point-min) 1)))))
3396 (goto-char (point-min))
3397 (push (cons 'replied (and (search-forward "B" nil t)
3398 (- (point) (point-min) 1)))
3399 pos)
3400 (goto-char (point-min))
3401 (push (cons 'score (and (search-forward "C" nil t)
3402 (- (point) (point-min) 1)))
3403 pos)
3404 (goto-char (point-min))
3405 (push (cons 'download (and (search-forward "D" nil t)
3406 (- (point) (point-min) 1)))
3407 pos)))
3408 (setq gnus-summary-mark-positions pos))))
3409
3410 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3411 "Insert a dummy root in the summary buffer."
3412 (beginning-of-line)
3413 (gnus-add-text-properties
3414 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3415 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3416
3417 (defun gnus-summary-extract-address-component (from)
3418 (or (car (funcall gnus-extract-address-components from))
3419 from))
3420
3421 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3422 (let ((mail-parse-charset gnus-newsgroup-charset)
3423 ; Is it really necessary to do this next part for each summary line?
3424 ; Luckily, doesn't seem to slow things down much.
3425 (mail-parse-ignored-charsets
3426 (save-excursion (set-buffer gnus-summary-buffer)
3427 gnus-newsgroup-ignored-charsets)))
3428 (or
3429 (and gnus-ignored-from-addresses
3430 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3431 (let ((extra-headers (mail-header-extra header))
3432 to
3433 newsgroups)
3434 (cond
3435 ((setq to (cdr (assq 'To extra-headers)))
3436 (concat "-> "
3437 (inline
3438 (gnus-summary-extract-address-component
3439 (funcall gnus-decode-encoded-word-function to)))))
3440 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3441 (concat "=> " newsgroups)))))
3442 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3443
3444 (defun gnus-summary-insert-line (gnus-tmp-header
3445 gnus-tmp-level gnus-tmp-current
3446 undownloaded gnus-tmp-unread gnus-tmp-replied
3447 gnus-tmp-expirable gnus-tmp-subject-or-nil
3448 &optional gnus-tmp-dummy gnus-tmp-score
3449 gnus-tmp-process)
3450 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3451 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3452 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3453 (gnus-tmp-score-char
3454 (if (or (null gnus-summary-default-score)
3455 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3456 gnus-summary-zcore-fuzz))
3457 ? ;Whitespace
3458 (if (< gnus-tmp-score gnus-summary-default-score)
3459 gnus-score-below-mark gnus-score-over-mark)))
3460 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3461 (gnus-tmp-replied
3462 (cond (gnus-tmp-process gnus-process-mark)
3463 ((memq gnus-tmp-current gnus-newsgroup-cached)
3464 gnus-cached-mark)
3465 (gnus-tmp-replied gnus-replied-mark)
3466 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3467 gnus-forwarded-mark)
3468 ((memq gnus-tmp-current gnus-newsgroup-saved)
3469 gnus-saved-mark)
3470 ((memq gnus-tmp-number gnus-newsgroup-recent)
3471 gnus-recent-mark)
3472 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3473 gnus-unseen-mark)
3474 (t gnus-no-mark)))
3475 (gnus-tmp-downloaded
3476 (cond (undownloaded
3477 gnus-undownloaded-mark)
3478 (gnus-newsgroup-agentized
3479 gnus-downloaded-mark)
3480 (t
3481 gnus-no-mark)))
3482 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3483 (gnus-tmp-name
3484 (cond
3485 ((string-match "<[^>]+> *$" gnus-tmp-from)
3486 (let ((beg (match-beginning 0)))
3487 (or (and (string-match "^\".+\"" gnus-tmp-from)
3488 (substring gnus-tmp-from 1 (1- (match-end 0))))
3489 (substring gnus-tmp-from 0 beg))))
3490 ((string-match "(.+)" gnus-tmp-from)
3491 (substring gnus-tmp-from
3492 (1+ (match-beginning 0)) (1- (match-end 0))))
3493 (t gnus-tmp-from)))
3494 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3495 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3496 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3497 (buffer-read-only nil))
3498 (when (string= gnus-tmp-name "")
3499 (setq gnus-tmp-name gnus-tmp-from))
3500 (unless (numberp gnus-tmp-lines)
3501 (setq gnus-tmp-lines -1))
3502 (if (= gnus-tmp-lines -1)
3503 (setq gnus-tmp-lines "?")
3504 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3505 (gnus-put-text-property
3506 (point)
3507 (progn (eval gnus-summary-line-format-spec) (point))
3508 'gnus-number gnus-tmp-number)
3509 (when (gnus-visual-p 'summary-highlight 'highlight)
3510 (forward-line -1)
3511 (gnus-run-hooks 'gnus-summary-update-hook)
3512 (forward-line 1))))
3513
3514 (defun gnus-summary-update-line (&optional dont-update)
3515 "Update summary line after change."
3516 (when (and gnus-summary-default-score
3517 (not gnus-summary-inhibit-highlight))
3518 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3519 (article (gnus-summary-article-number))
3520 (score (gnus-summary-article-score article)))
3521 (unless dont-update
3522 (if (and gnus-summary-mark-below
3523 (< (gnus-summary-article-score)
3524 gnus-summary-mark-below))
3525 ;; This article has a low score, so we mark it as read.
3526 (when (memq article gnus-newsgroup-unreads)
3527 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3528 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3529 ;; This article was previously marked as read on account
3530 ;; of a low score, but now it has risen, so we mark it as
3531 ;; unread.
3532 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3533 (gnus-summary-update-mark
3534 (if (or (null gnus-summary-default-score)
3535 (<= (abs (- score gnus-summary-default-score))
3536 gnus-summary-zcore-fuzz))
3537 ? ;Whitespace
3538 (if (< score gnus-summary-default-score)
3539 gnus-score-below-mark gnus-score-over-mark))
3540 'score))
3541 ;; Do visual highlighting.
3542 (when (gnus-visual-p 'summary-highlight 'highlight)
3543 (gnus-run-hooks 'gnus-summary-update-hook)))))
3544
3545 (defvar gnus-tmp-new-adopts nil)
3546
3547 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3548 "Return the number of articles in THREAD.
3549 This may be 0 in some cases -- if none of the articles in
3550 the thread are to be displayed."
3551 (let* ((number
3552 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3553 (cond
3554 ((not (listp thread))
3555 1)
3556 ((and (consp thread) (cdr thread))
3557 (apply
3558 '+ 1 (mapcar
3559 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3560 ((null thread)
3561 1)
3562 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3563 1)
3564 (t 0))))
3565 (when (and level (zerop level) gnus-tmp-new-adopts)
3566 (incf number
3567 (apply '+ (mapcar
3568 'gnus-summary-number-of-articles-in-thread
3569 gnus-tmp-new-adopts))))
3570 (if char
3571 (if (> number 1) gnus-not-empty-thread-mark
3572 gnus-empty-thread-mark)
3573 number)))
3574
3575 (defsubst gnus-summary-line-message-size (head)
3576 "Return pretty-printed version of message size.
3577 This function is intended to be used in
3578 `gnus-summary-line-format-alist'."
3579 (let ((c (or (mail-header-chars head) -1)))
3580 (cond ((< c 0) "n/a") ; chars not available
3581 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3582 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3583 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3584 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3585
3586
3587 (defun gnus-summary-set-local-parameters (group)
3588 "Go through the local params of GROUP and set all variable specs in that list."
3589 (let ((params (gnus-group-find-parameter group))
3590 (vars '(quit-config)) ; Ignore quit-config.
3591 elem)
3592 (while params
3593 (setq elem (car params)
3594 params (cdr params))
3595 (and (consp elem) ; Has to be a cons.
3596 (consp (cdr elem)) ; The cdr has to be a list.
3597 (symbolp (car elem)) ; Has to be a symbol in there.
3598 (not (memq (car elem) vars))
3599 (ignore-errors ; So we set it.
3600 (push (car elem) vars)
3601 (make-local-variable (car elem))
3602 (set (car elem) (eval (nth 1 elem))))))))
3603
3604 (defun gnus-summary-read-group (group &optional show-all no-article
3605 kill-buffer no-display backward
3606 select-articles)
3607 "Start reading news in newsgroup GROUP.
3608 If SHOW-ALL is non-nil, already read articles are also listed.
3609 If NO-ARTICLE is non-nil, no article is selected initially.
3610 If NO-DISPLAY, don't generate a summary buffer."
3611 (let (result)
3612 (while (and group
3613 (null (setq result
3614 (let ((gnus-auto-select-next nil))
3615 (or (gnus-summary-read-group-1
3616 group show-all no-article
3617 kill-buffer no-display
3618 select-articles)
3619 (setq show-all nil
3620 select-articles nil)))))
3621 (eq gnus-auto-select-next 'quietly))
3622 (set-buffer gnus-group-buffer)
3623 ;; The entry function called above goes to the next
3624 ;; group automatically, so we go two groups back
3625 ;; if we are searching for the previous group.
3626 (when backward
3627 (gnus-group-prev-unread-group 2))
3628 (if (not (equal group (gnus-group-group-name)))
3629 (setq group (gnus-group-group-name))
3630 (setq group nil)))
3631 result))
3632
3633 (defun gnus-summary-read-group-1 (group show-all no-article
3634 kill-buffer no-display
3635 &optional select-articles)
3636 ;; Killed foreign groups can't be entered.
3637 ;; (when (and (not (gnus-group-native-p group))
3638 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3639 ;; (error "Dead non-native groups can't be entered"))
3640 (gnus-message 5 "Retrieving newsgroup: %s..."
3641 (gnus-group-decoded-name group))
3642 (let* ((new-group (gnus-summary-setup-buffer group))
3643 (quit-config (gnus-group-quit-config group))
3644 (did-select (and new-group (gnus-select-newsgroup
3645 group show-all select-articles))))
3646 (cond
3647 ;; This summary buffer exists already, so we just select it.
3648 ((not new-group)
3649 (gnus-set-global-variables)
3650 (when kill-buffer
3651 (gnus-kill-or-deaden-summary kill-buffer))
3652 (gnus-configure-windows 'summary 'force)
3653 (gnus-set-mode-line 'summary)
3654 (gnus-summary-position-point)
3655 (message "")
3656 t)
3657 ;; We couldn't select this group.
3658 ((null did-select)
3659 (when (and (eq major-mode 'gnus-summary-mode)
3660 (not (equal (current-buffer) kill-buffer)))
3661 (kill-buffer (current-buffer))
3662 (if (not quit-config)
3663 (progn
3664 ;; Update the info -- marks might need to be removed,
3665 ;; for instance.
3666 (gnus-summary-update-info)
3667 (set-buffer gnus-group-buffer)
3668 (gnus-group-jump-to-group group)
3669 (gnus-group-next-unread-group 1))
3670 (gnus-handle-ephemeral-exit quit-config)))
3671 (let ((grpinfo (gnus-get-info group)))
3672 (if (null (gnus-info-read grpinfo))
3673 (gnus-message 3 "Group %s contains no messages"
3674 (gnus-group-decoded-name group))
3675 (gnus-message 3 "Can't select group")))
3676 nil)
3677 ;; The user did a `C-g' while prompting for number of articles,
3678 ;; so we exit this group.
3679 ((eq did-select 'quit)
3680 (and (eq major-mode 'gnus-summary-mode)
3681 (not (equal (current-buffer) kill-buffer))
3682 (kill-buffer (current-buffer)))
3683 (when kill-buffer
3684 (gnus-kill-or-deaden-summary kill-buffer))
3685 (if (not quit-config)
3686 (progn
3687 (set-buffer gnus-group-buffer)
3688 (gnus-group-jump-to-group group)
3689 (gnus-group-next-unread-group 1)
3690 (gnus-configure-windows 'group 'force))
3691 (gnus-handle-ephemeral-exit quit-config))
3692 ;; Finally signal the quit.
3693 (signal 'quit nil))
3694 ;; The group was successfully selected.
3695 (t
3696 (gnus-set-global-variables)
3697 ;; Save the active value in effect when the group was entered.
3698 (setq gnus-newsgroup-active
3699 (gnus-copy-sequence
3700 (gnus-active gnus-newsgroup-name)))
3701 ;; You can change the summary buffer in some way with this hook.
3702 (gnus-run-hooks 'gnus-select-group-hook)
3703 (when (memq 'summary (gnus-update-format-specifications
3704 nil 'summary 'summary-mode 'summary-dummy))
3705 ;; The format specification for the summary line was updated,
3706 ;; so we need to update the mark positions as well.
3707 (gnus-update-summary-mark-positions))
3708 ;; Do score processing.
3709 (when gnus-use-scoring
3710 (gnus-possibly-score-headers))
3711 ;; Check whether to fill in the gaps in the threads.
3712 (when gnus-build-sparse-threads
3713 (gnus-build-sparse-threads))
3714 ;; Find the initial limit.
3715 (if show-all
3716 (let ((gnus-newsgroup-dormant nil))
3717 (gnus-summary-initial-limit show-all))
3718 (gnus-summary-initial-limit show-all))
3719 ;; Generate the summary buffer.
3720 (unless no-display
3721 (gnus-summary-prepare))
3722 (when gnus-use-trees
3723 (gnus-tree-open group)
3724 (setq gnus-summary-highlight-line-function
3725 'gnus-tree-highlight-article))
3726 ;; If the summary buffer is empty, but there are some low-scored
3727 ;; articles or some excluded dormants, we include these in the
3728 ;; buffer.
3729 (when (and (zerop (buffer-size))
3730 (not no-display))
3731 (cond (gnus-newsgroup-dormant
3732 (gnus-summary-limit-include-dormant))
3733 ((and gnus-newsgroup-scored show-all)
3734 (gnus-summary-limit-include-expunged t))))
3735 ;; Function `gnus-apply-kill-file' must be called in this hook.
3736 (gnus-run-hooks 'gnus-apply-kill-hook)
3737 (if (and (zerop (buffer-size))
3738 (not no-display))
3739 (progn
3740 ;; This newsgroup is empty.
3741 (gnus-summary-catchup-and-exit nil t)
3742 (gnus-message 6 "No unread news")
3743 (when kill-buffer
3744 (gnus-kill-or-deaden-summary kill-buffer))
3745 ;; Return nil from this function.
3746 nil)
3747 ;; Hide conversation thread subtrees. We cannot do this in
3748 ;; gnus-summary-prepare-hook since kill processing may not
3749 ;; work with hidden articles.
3750 (gnus-summary-maybe-hide-threads)
3751 (when kill-buffer
3752 (gnus-kill-or-deaden-summary kill-buffer))
3753 (gnus-summary-auto-select-subject)
3754 ;; Show first unread article if requested.
3755 (if (and (not no-article)
3756 (not no-display)
3757 gnus-newsgroup-unreads
3758 gnus-auto-select-first)
3759 (progn
3760 (gnus-configure-windows 'summary)
3761 (let ((art (gnus-summary-article-number)))
3762 (unless (and (not gnus-plugged)
3763 (or (memq art gnus-newsgroup-undownloaded)
3764 (memq art gnus-newsgroup-downloadable)))
3765 (gnus-summary-goto-article art))))
3766 ;; Don't select any articles.
3767 (gnus-summary-position-point)
3768 (gnus-configure-windows 'summary 'force)
3769 (gnus-set-mode-line 'summary))
3770 (when (and gnus-auto-center-group
3771 (get-buffer-window gnus-group-buffer t))
3772 ;; Gotta use windows, because recenter does weird stuff if
3773 ;; the current buffer ain't the displayed window.
3774 (let ((owin (selected-window)))
3775 (select-window (get-buffer-window gnus-group-buffer t))
3776 (when (gnus-group-goto-group group)
3777 (recenter))
3778 (select-window owin)))
3779 ;; Mark this buffer as "prepared".
3780 (setq gnus-newsgroup-prepared t)
3781 (gnus-run-hooks 'gnus-summary-prepared-hook)
3782 (unless (gnus-ephemeral-group-p group)
3783 (gnus-group-update-group group))
3784 t)))))
3785
3786 (defun gnus-summary-auto-select-subject ()
3787 "Select the subject line on initial group entry."
3788 (goto-char (point-min))
3789 (cond
3790 ((eq gnus-auto-select-subject 'best)
3791 (gnus-summary-best-unread-subject))
3792 ((eq gnus-auto-select-subject 'unread)
3793 (gnus-summary-first-unread-subject))
3794 ((eq gnus-auto-select-subject 'unseen)
3795 (gnus-summary-first-unseen-subject))
3796 ((eq gnus-auto-select-subject 'unseen-or-unread)
3797 (gnus-summary-first-unseen-or-unread-subject))
3798 ((eq gnus-auto-select-subject 'first)
3799 ;; Do nothing.
3800 )
3801 ((functionp gnus-auto-select-subject)
3802 (funcall gnus-auto-select-subject))))
3803
3804 (defun gnus-summary-prepare ()
3805 "Generate the summary buffer."
3806 (interactive)
3807 (let ((buffer-read-only nil))
3808 (erase-buffer)
3809 (setq gnus-newsgroup-data nil
3810 gnus-newsgroup-data-reverse nil)
3811 (gnus-run-hooks 'gnus-summary-generate-hook)
3812 ;; Generate the buffer, either with threads or without.
3813 (when gnus-newsgroup-headers
3814 (gnus-summary-prepare-threads
3815 (if gnus-show-threads
3816 (gnus-sort-gathered-threads
3817 (funcall gnus-summary-thread-gathering-function
3818 (gnus-sort-threads
3819 (gnus-cut-threads (gnus-make-threads)))))
3820 ;; Unthreaded display.
3821 (gnus-sort-articles gnus-newsgroup-headers))))
3822 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3823 ;; Call hooks for modifying summary buffer.
3824 (goto-char (point-min))
3825 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3826
3827 (defsubst gnus-general-simplify-subject (subject)
3828 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3829 (setq subject
3830 (cond
3831 ;; Truncate the subject.
3832 (gnus-simplify-subject-functions
3833 (gnus-map-function gnus-simplify-subject-functions subject))
3834 ((numberp gnus-summary-gather-subject-limit)
3835 (setq subject (gnus-simplify-subject-re subject))
3836 (if (> (length subject) gnus-summary-gather-subject-limit)
3837 (substring subject 0 gnus-summary-gather-subject-limit)
3838 subject))
3839 ;; Fuzzily simplify it.
3840 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3841 (gnus-simplify-subject-fuzzy subject))
3842 ;; Just remove the leading "Re:".
3843 (t
3844 (gnus-simplify-subject-re subject))))
3845
3846 (if (and gnus-summary-gather-exclude-subject
3847 (string-match gnus-summary-gather-exclude-subject subject))
3848 nil ; This article shouldn't be gathered
3849 subject))
3850
3851 (defun gnus-summary-simplify-subject-query ()
3852 "Query where the respool algorithm would put this article."
3853 (interactive)
3854 (gnus-summary-select-article)
3855 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3856
3857 (defun gnus-gather-threads-by-subject (threads)
3858 "Gather threads by looking at Subject headers."
3859 (if (not gnus-summary-make-false-root)
3860 threads
3861 (let ((hashtb (gnus-make-hashtable 1024))
3862 (prev threads)
3863 (result threads)
3864 subject hthread whole-subject)
3865 (while threads
3866 (setq subject (gnus-general-simplify-subject
3867 (setq whole-subject (mail-header-subject
3868 (caar threads)))))
3869 (when subject
3870 (if (setq hthread (gnus-gethash subject hashtb))
3871 (progn
3872 ;; We enter a dummy root into the thread, if we
3873 ;; haven't done that already.
3874 (unless (stringp (caar hthread))
3875 (setcar hthread (list whole-subject (car hthread))))
3876 ;; We add this new gathered thread to this gathered
3877 ;; thread.
3878 (setcdr (car hthread)
3879 (nconc (cdar hthread) (list (car threads))))
3880 ;; Remove it from the list of threads.
3881 (setcdr prev (cdr threads))
3882 (setq threads prev))
3883 ;; Enter this thread into the hash table.
3884 (gnus-sethash subject
3885 (if gnus-summary-make-false-root-always
3886 (progn
3887 ;; If you want a dummy root above all
3888 ;; threads...
3889 (setcar threads (list whole-subject
3890 (car threads)))
3891 threads)
3892 threads)
3893 hashtb)))
3894 (setq prev threads)
3895 (setq threads (cdr threads)))
3896 result)))
3897
3898 (defun gnus-gather-threads-by-references (threads)
3899 "Gather threads by looking at References headers."
3900 (let ((idhashtb (gnus-make-hashtable 1024))
3901 (thhashtb (gnus-make-hashtable 1024))
3902 (prev threads)
3903 (result threads)
3904 ids references id gthread gid entered ref)
3905 (while threads
3906 (when (setq references (mail-header-references (caar threads)))
3907 (setq id (mail-header-id (caar threads))
3908 ids (inline (gnus-split-references references))
3909 entered nil)
3910 (while (setq ref (pop ids))
3911 (setq ids (delete ref ids))
3912 (if (not (setq gid (gnus-gethash ref idhashtb)))
3913 (progn
3914 (gnus-sethash ref id idhashtb)
3915 (gnus-sethash id threads thhashtb))
3916 (setq gthread (gnus-gethash gid thhashtb))
3917 (unless entered
3918 ;; We enter a dummy root into the thread, if we
3919 ;; haven't done that already.
3920 (unless (stringp (caar gthread))
3921 (setcar gthread (list (mail-header-subject (caar gthread))
3922 (car gthread))))
3923 ;; We add this new gathered thread to this gathered
3924 ;; thread.
3925 (setcdr (car gthread)
3926 (nconc (cdar gthread) (list (car threads)))))
3927 ;; Add it into the thread hash table.
3928 (gnus-sethash id gthread thhashtb)
3929 (setq entered t)
3930 ;; Remove it from the list of threads.
3931 (setcdr prev (cdr threads))
3932 (setq threads prev))))
3933 (setq prev threads)
3934 (setq threads (cdr threads)))
3935 result))
3936
3937 (defun gnus-sort-gathered-threads (threads)
3938 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3939 (let ((result threads))
3940 (while threads
3941 (when (stringp (caar threads))
3942 (setcdr (car threads)
3943 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3944 (setq threads (cdr threads)))
3945 result))
3946
3947 (defun gnus-thread-loop-p (root thread)
3948 "Say whether ROOT is in THREAD."
3949 (let ((stack (list thread))
3950 (infloop 0)
3951 th)
3952 (while (setq thread (pop stack))
3953 (setq th (cdr thread))
3954 (while (and th
3955 (not (eq (caar th) root)))
3956 (pop th))
3957 (if th
3958 ;; We have found a loop.
3959 (let (ref-dep)
3960 (setcdr thread (delq (car th) (cdr thread)))
3961 (if (boundp (setq ref-dep (intern "none"
3962 gnus-newsgroup-dependencies)))
3963 (setcdr (symbol-value ref-dep)
3964 (nconc (cdr (symbol-value ref-dep))
3965 (list (car th))))
3966 (set ref-dep (list nil (car th))))
3967 (setq infloop 1
3968 stack nil))
3969 ;; Push all the subthreads onto the stack.
3970 (push (cdr thread) stack)))
3971 infloop))
3972
3973 (defun gnus-make-threads ()
3974 "Go through the dependency hashtb and find the roots. Return all threads."
3975 (let (threads)
3976 (while (catch 'infloop
3977 (mapatoms
3978 (lambda (refs)
3979 ;; Deal with self-referencing References loops.
3980 (when (and (car (symbol-value refs))
3981 (not (zerop
3982 (apply
3983 '+
3984 (mapcar
3985 (lambda (thread)
3986 (gnus-thread-loop-p
3987 (car (symbol-value refs)) thread))
3988 (cdr (symbol-value refs)))))))
3989 (setq threads nil)
3990 (throw 'infloop t))
3991 (unless (car (symbol-value refs))
3992 ;; These threads do not refer back to any other
3993 ;; articles, so they're roots.
3994 (setq threads (append (cdr (symbol-value refs)) threads))))
3995 gnus-newsgroup-dependencies)))
3996 threads))
3997
3998 ;; Build the thread tree.
3999 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4000 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4001
4002 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4003 if it was already present.
4004
4005 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4006 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4007 Message-IDs will be renamed to a unique Message-ID before being
4008 entered.
4009
4010 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4011 (let* ((id (mail-header-id header))
4012 (id-dep (and id (intern id dependencies)))
4013 parent-id ref ref-dep ref-header replaced)
4014 ;; Enter this `header' in the `dependencies' table.
4015 (cond
4016 ((not id-dep)
4017 (setq header nil))
4018 ;; The first two cases do the normal part: enter a new `header'
4019 ;; in the `dependencies' table.
4020 ((not (boundp id-dep))
4021 (set id-dep (list header)))
4022 ((null (car (symbol-value id-dep)))
4023 (setcar (symbol-value id-dep) header))
4024
4025 ;; From here the `header' was already present in the
4026 ;; `dependencies' table.
4027 (force-new
4028 ;; Overrides an existing entry;
4029 ;; just set the header part of the entry.
4030 (setcar (symbol-value id-dep) header)
4031 (setq replaced t))
4032
4033 ;; Renames the existing `header' to a unique Message-ID.
4034 ((not gnus-summary-ignore-duplicates)
4035 ;; An article with this Message-ID has already been seen.
4036 ;; We rename the Message-ID.
4037 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4038 (list header))
4039 (mail-header-set-id header id))
4040
4041 ;; The last case ignores an existing entry, except it adds any
4042 ;; additional Xrefs (in case the two articles came from different
4043 ;; servers.
4044 ;; Also sets `header' to `nil' meaning that the `dependencies'
4045 ;; table was *not* modified.
4046 (t
4047 (mail-header-set-xref
4048 (car (symbol-value id-dep))
4049 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4050 "")
4051 (or (mail-header-xref header) "")))
4052 (setq header nil)))
4053
4054 (when (and header (not replaced))
4055 ;; First check that we are not creating a References loop.
4056 (setq parent-id (gnus-parent-id (mail-header-references header)))
4057 (setq ref parent-id)
4058 (while (and ref
4059 (setq ref-dep (intern-soft ref dependencies))
4060 (boundp ref-dep)
4061 (setq ref-header (car (symbol-value ref-dep))))
4062 (if (string= id ref)
4063 ;; Yuk! This is a reference loop. Make the article be a
4064 ;; root article.
4065 (progn
4066 (mail-header-set-references (car (symbol-value id-dep)) "none")
4067 (setq ref nil)
4068 (setq parent-id nil))
4069 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4070 (setq ref-dep (intern (or parent-id "none") dependencies))
4071 (if (boundp ref-dep)
4072 (setcdr (symbol-value ref-dep)
4073 (nconc (cdr (symbol-value ref-dep))
4074 (list (symbol-value id-dep))))
4075 (set ref-dep (list nil (symbol-value id-dep)))))
4076 header))
4077
4078 (defun gnus-extract-message-id-from-in-reply-to (string)
4079 (if (string-match "<[^>]+>" string)
4080 (substring string (match-beginning 0) (match-end 0))
4081 nil))
4082
4083 (defun gnus-build-sparse-threads ()
4084 (let ((headers gnus-newsgroup-headers)
4085 (mail-parse-charset gnus-newsgroup-charset)
4086 (gnus-summary-ignore-duplicates t)
4087 header references generation relations
4088 subject child end new-child date)
4089 ;; First we create an alist of generations/relations, where
4090 ;; generations is how much we trust the relation, and the relation
4091 ;; is parent/child.
4092 (gnus-message 7 "Making sparse threads...")
4093 (save-excursion
4094 (nnheader-set-temp-buffer " *gnus sparse threads*")
4095 (while (setq header (pop headers))
4096 (when (and (setq references (mail-header-references header))
4097 (not (string= references "")))
4098 (insert references)
4099 (setq child (mail-header-id header)
4100 subject (mail-header-subject header)
4101 date (mail-header-date header)
4102 generation 0)
4103 (while (search-backward ">" nil t)
4104 (setq end (1+ (point)))
4105 (when (search-backward "<" nil t)
4106 (setq new-child (buffer-substring (point) end))
4107 (push (list (incf generation)
4108 child (setq child new-child)
4109 subject date)
4110 relations)))
4111 (when child
4112 (push (list (1+ generation) child nil subject) relations))
4113 (erase-buffer)))
4114 (kill-buffer (current-buffer)))
4115 ;; Sort over trustworthiness.
4116 (mapcar
4117 (lambda (relation)
4118 (when (gnus-dependencies-add-header
4119 (make-full-mail-header
4120 gnus-reffed-article-number
4121 (nth 3 relation) "" (or (nth 4 relation) "")
4122 (nth 1 relation)
4123 (or (nth 2 relation) "") 0 0 "")
4124 gnus-newsgroup-dependencies nil)
4125 (push gnus-reffed-article-number gnus-newsgroup-limit)
4126 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4127 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4128 gnus-newsgroup-reads)
4129 (decf gnus-reffed-article-number)))
4130 (sort relations 'car-less-than-car))
4131 (gnus-message 7 "Making sparse threads...done")))
4132
4133 (defun gnus-build-old-threads ()
4134 ;; Look at all the articles that refer back to old articles, and
4135 ;; fetch the headers for the articles that aren't there. This will
4136 ;; build complete threads - if the roots haven't been expired by the
4137 ;; server, that is.
4138 (let ((mail-parse-charset gnus-newsgroup-charset)
4139 id heads)
4140 (mapatoms
4141 (lambda (refs)
4142 (when (not (car (symbol-value refs)))
4143 (setq heads (cdr (symbol-value refs)))
4144 (while heads
4145 (if (memq (mail-header-number (caar heads))
4146 gnus-newsgroup-dormant)
4147 (setq heads (cdr heads))
4148 (setq id (symbol-name refs))
4149 (while (and (setq id (gnus-build-get-header id))
4150 (not (car (gnus-id-to-thread id)))))
4151 (setq heads nil)))))
4152 gnus-newsgroup-dependencies)))
4153
4154 (defsubst gnus-remove-odd-characters (string)
4155 "Translate STRING into something that doesn't contain weird characters."
4156 (mm-subst-char-in-string
4157 ?\r ?\-
4158 (mm-subst-char-in-string
4159 ?\n ?\- string)))
4160
4161 ;; This function has to be called with point after the article number
4162 ;; on the beginning of the line.
4163 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4164 (let ((eol (gnus-point-at-eol))
4165 (buffer (current-buffer))
4166 header references in-reply-to)
4167
4168 ;; overview: [num subject from date id refs chars lines misc]
4169 (unwind-protect
4170 (let (x)
4171 (narrow-to-region (point) eol)
4172 (unless (eobp)
4173 (forward-char))
4174
4175 (setq header
4176 (make-full-mail-header
4177 number ; number
4178 (condition-case () ; subject
4179 (gnus-remove-odd-characters
4180 (funcall gnus-decode-encoded-word-function
4181 (setq x (nnheader-nov-field))))
4182 (error x))
4183 (condition-case () ; from
4184 (gnus-remove-odd-characters
4185 (funcall gnus-decode-encoded-word-function
4186 (setq x (nnheader-nov-field))))
4187 (error x))
4188 (nnheader-nov-field) ; date
4189 (nnheader-nov-read-message-id) ; id
4190 (setq references (nnheader-nov-field)) ; refs
4191 (nnheader-nov-read-integer) ; chars
4192 (nnheader-nov-read-integer) ; lines
4193 (unless (eobp)
4194 (if (looking-at "Xref: ")
4195 (goto-char (match-end 0)))
4196 (nnheader-nov-field)) ; Xref
4197 (nnheader-nov-parse-extra)))) ; extra
4198
4199 (widen))
4200
4201 (when (and (string= references "")
4202 (setq in-reply-to (mail-header-extra header))
4203 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4204 (mail-header-set-references
4205 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4206
4207 (when gnus-alter-header-function
4208 (funcall gnus-alter-header-function header))
4209 (gnus-dependencies-add-header header dependencies force-new)))
4210
4211 (defun gnus-build-get-header (id)
4212 "Look through the buffer of NOV lines and find the header to ID.
4213 Enter this line into the dependencies hash table, and return
4214 the id of the parent article (if any)."
4215 (let ((deps gnus-newsgroup-dependencies)
4216 found header)
4217 (prog1
4218 (save-excursion
4219 (set-buffer nntp-server-buffer)
4220 (let ((case-fold-search nil))
4221 (goto-char (point-min))
4222 (while (and (not found)
4223 (search-forward id nil t))
4224 (beginning-of-line)
4225 (setq found (looking-at
4226 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4227 (regexp-quote id))))
4228 (or found (beginning-of-line 2)))
4229 (when found
4230 (beginning-of-line)
4231 (and
4232 (setq header (gnus-nov-parse-line
4233 (read (current-buffer)) deps))
4234 (gnus-parent-id (mail-header-references header))))))
4235 (when header
4236 (let ((number (mail-header-number header)))
4237 (push number gnus-newsgroup-limit)
4238 (push header gnus-newsgroup-headers)
4239 (if (memq number gnus-newsgroup-unselected)
4240 (progn
4241 (setq gnus-newsgroup-unreads
4242 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4243 number))
4244 (setq gnus-newsgroup-unselected
4245 (delq number gnus-newsgroup-unselected)))
4246 (push number gnus-newsgroup-ancient)))))))
4247
4248 (defun gnus-build-all-threads ()
4249 "Read all the headers."
4250 (let ((gnus-summary-ignore-duplicates t)
4251 (mail-parse-charset gnus-newsgroup-charset)
4252 (dependencies gnus-newsgroup-dependencies)
4253 header article)
4254 (save-excursion
4255 (set-buffer nntp-server-buffer)
4256 (let ((case-fold-search nil))
4257 (goto-char (point-min))
4258 (while (not (eobp))
4259 (ignore-errors
4260 (setq article (read (current-buffer))
4261 header (gnus-nov-parse-line article dependencies)))
4262 (when header
4263 (save-excursion
4264 (set-buffer gnus-summary-buffer)
4265 (push header gnus-newsgroup-headers)
4266 (if (memq (setq article (mail-header-number header))
4267 gnus-newsgroup-unselected)
4268 (progn
4269 (setq gnus-newsgroup-unreads
4270 (gnus-add-to-sorted-list
4271 gnus-newsgroup-unreads article))
4272 (setq gnus-newsgroup-unselected
4273 (delq article gnus-newsgroup-unselected)))
4274 (push article gnus-newsgroup-ancient)))
4275 (forward-line 1)))))))
4276
4277 (defun gnus-summary-update-article-line (article header)
4278 "Update the line for ARTICLE using HEADER."
4279 (let* ((id (mail-header-id header))
4280 (thread (gnus-id-to-thread id)))
4281 (unless thread
4282 (error "Article in no thread"))
4283 ;; Update the thread.
4284 (setcar thread header)
4285 (gnus-summary-goto-subject article)
4286 (let* ((datal (gnus-data-find-list article))
4287 (data (car datal))
4288 (buffer-read-only nil)
4289 (level (gnus-summary-thread-level)))
4290 (gnus-delete-line)
4291 (let ((inserted (- (point)
4292 (progn
4293 (gnus-summary-insert-line
4294 header level nil
4295 (memq article gnus-newsgroup-undownloaded)
4296 (gnus-article-mark article)
4297 (memq article gnus-newsgroup-replied)
4298 (memq article gnus-newsgroup-expirable)
4299 ;; Only insert the Subject string when it's different
4300 ;; from the previous Subject string.
4301 (if (and
4302 gnus-show-threads
4303 (gnus-subject-equal
4304 (condition-case ()
4305 (mail-header-subject
4306 (gnus-data-header
4307 (cadr
4308 (gnus-data-find-list
4309 article
4310 (gnus-data-list t)))))
4311 ;; Error on the side of excessive subjects.
4312 (error ""))
4313 (mail-header-subject header)))
4314 ""
4315 (mail-header-subject header))
4316 nil (cdr (assq article gnus-newsgroup-scored))
4317 (memq article gnus-newsgroup-processable))
4318 (point)))))
4319 (when (cdr datal)
4320 (gnus-data-update-list
4321 (cdr datal)
4322 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4323
4324 (defun gnus-summary-update-article (article &optional iheader)
4325 "Update ARTICLE in the summary buffer."
4326 (set-buffer gnus-summary-buffer)
4327 (let* ((header (gnus-summary-article-header article))
4328 (id (mail-header-id header))
4329 (data (gnus-data-find article))
4330 (thread (gnus-id-to-thread id))
4331 (references (mail-header-references header))
4332 (parent
4333 (gnus-id-to-thread
4334 (or (gnus-parent-id
4335 (when (and references
4336 (not (equal "" references)))
4337 references))
4338 "none")))
4339 (buffer-read-only nil)
4340 (old (car thread)))
4341 (when thread
4342 (unless iheader
4343 (setcar thread nil)
4344 (when parent
4345 (delq thread parent)))
4346 (if (gnus-summary-insert-subject id header)
4347 ;; Set the (possibly) new article number in the data structure.
4348 (gnus-data-set-number data (gnus-id-to-article id))
4349 (setcar thread old)
4350 nil))))
4351
4352 (defun gnus-rebuild-thread (id &optional line)
4353 "Rebuild the thread containing ID.
4354 If LINE, insert the rebuilt thread starting on line LINE."
4355 (let ((buffer-read-only nil)
4356 old-pos current thread data)
4357 (if (not gnus-show-threads)
4358 (setq thread (list (car (gnus-id-to-thread id))))
4359 ;; Get the thread this article is part of.
4360 (setq thread (gnus-remove-thread id)))
4361 (setq old-pos (gnus-point-at-bol))
4362 (setq current (save-excursion
4363 (and (re-search-backward "[\r\n]" nil t)
4364 (gnus-summary-article-number))))
4365 ;; If this is a gathered thread, we have to go some re-gathering.
4366 (when (stringp (car thread))
4367 (let ((subject (car thread))
4368 roots thr)
4369 (setq thread (cdr thread))
4370 (while thread
4371 (unless (memq (setq thr (gnus-id-to-thread
4372 (gnus-root-id
4373 (mail-header-id (caar thread)))))
4374 roots)
4375 (push thr roots))
4376 (setq thread (cdr thread)))
4377 ;; We now have all (unique) roots.
4378 (if (= (length roots) 1)
4379 ;; All the loose roots are now one solid root.
4380 (setq thread (car roots))
4381 (setq thread (cons subject (gnus-sort-threads roots))))))
4382 (let (threads)
4383 ;; We then insert this thread into the summary buffer.
4384 (when line
4385 (goto-char (point-min))
4386 (forward-line (1- line)))
4387 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4388 (if gnus-show-threads
4389 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4390 (gnus-summary-prepare-unthreaded thread))
4391 (setq data (nreverse gnus-newsgroup-data))
4392 (setq threads gnus-newsgroup-threads))
4393 ;; We splice the new data into the data structure.
4394 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4395 ;;!!! then we want to insert at the beginning of the buffer.
4396 ;;!!! That happens to be true with Gnus now, but that may
4397 ;;!!! change in the future. Perhaps.
4398 (gnus-data-enter-list
4399 (if line nil current) data (- (point) old-pos))
4400 (setq gnus-newsgroup-threads
4401 (nconc threads gnus-newsgroup-threads))
4402 (gnus-data-compute-positions))))
4403
4404 (defun gnus-number-to-header (number)
4405 "Return the header for article NUMBER."
4406 (let ((headers gnus-newsgroup-headers))
4407 (while (and headers
4408 (not (= number (mail-header-number (car headers)))))
4409 (pop headers))
4410 (when headers
4411 (car headers))))
4412
4413 (defun gnus-parent-headers (in-headers &optional generation)
4414 "Return the headers of the GENERATIONeth parent of HEADERS."
4415 (unless generation
4416 (setq generation 1))
4417 (let ((parent t)
4418 (headers in-headers)
4419 references)
4420 (while (and parent
4421 (not (zerop generation))
4422 (setq references (mail-header-references headers)))
4423 (setq headers (if (and references
4424 (setq parent (gnus-parent-id references)))
4425 (car (gnus-id-to-thread parent))
4426 nil))
4427 (decf generation))
4428 (and (not (eq headers in-headers))
4429 headers)))
4430
4431 (defun gnus-id-to-thread (id)
4432 "Return the (sub-)thread where ID appears."
4433 (gnus-gethash id gnus-newsgroup-dependencies))
4434
4435 (defun gnus-id-to-article (id)
4436 "Return the article number of ID."
4437 (let ((thread (gnus-id-to-thread id)))
4438 (when (and thread
4439 (car thread))
4440 (mail-header-number (car thread)))))
4441
4442 (defun gnus-id-to-header (id)
4443 "Return the article headers of ID."
4444 (car (gnus-id-to-thread id)))
4445
4446 (defun gnus-article-displayed-root-p (article)
4447 "Say whether ARTICLE is a root(ish) article."
4448 (let ((level (gnus-summary-thread-level article))
4449 (refs (mail-header-references (gnus-summary-article-header article)))
4450 particle)
4451 (cond
4452 ((null level) nil)
4453 ((zerop level) t)
4454 ((null refs) t)
4455 ((null (gnus-parent-id refs)) t)
4456 ((and (= 1 level)
4457 (null (setq particle (gnus-id-to-article
4458 (gnus-parent-id refs))))
4459 (null (gnus-summary-thread-level particle)))))))
4460
4461 (defun gnus-root-id (id)
4462 "Return the id of the root of the thread where ID appears."
4463 (let (last-id prev)
4464 (while (and id (setq prev (car (gnus-id-to-thread id))))
4465 (setq last-id id
4466 id (gnus-parent-id (mail-header-references prev))))
4467 last-id))
4468
4469 (defun gnus-articles-in-thread (thread)
4470 "Return the list of articles in THREAD."
4471 (cons (mail-header-number (car thread))
4472 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4473
4474 (defun gnus-remove-thread (id &optional dont-remove)
4475 "Remove the thread that has ID in it."
4476 (let (headers thread last-id)
4477 ;; First go up in this thread until we find the root.
4478 (setq last-id (gnus-root-id id)
4479 headers (message-flatten-list (gnus-id-to-thread last-id)))
4480 ;; We have now found the real root of this thread. It might have
4481 ;; been gathered into some loose thread, so we have to search
4482 ;; through the threads to find the thread we wanted.
4483 (let ((threads gnus-newsgroup-threads)
4484 sub)
4485 (while threads
4486 (setq sub (car threads))
4487 (if (stringp (car sub))
4488 ;; This is a gathered thread, so we look at the roots
4489 ;; below it to find whether this article is in this
4490 ;; gathered root.
4491 (progn
4492 (setq sub (cdr sub))
4493 (while sub
4494 (when (member (caar sub) headers)
4495 (setq thread (car threads)
4496 threads nil
4497 sub nil))
4498 (setq sub (cdr sub))))
4499 ;; It's an ordinary thread, so we check it.
4500 (when (eq (car sub) (car headers))
4501 (setq thread sub
4502 threads nil)))
4503 (setq threads (cdr threads)))
4504 ;; If this article is in no thread, then it's a root.
4505 (if thread
4506 (unless dont-remove
4507 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4508 (setq thread (gnus-id-to-thread last-id)))
4509 (when thread
4510 (prog1
4511 thread ; We return this thread.
4512 (unless dont-remove
4513 (if (stringp (car thread))
4514 (progn
4515 ;; If we use dummy roots, then we have to remove the
4516 ;; dummy root as well.
4517 (when (eq gnus-summary-make-false-root 'dummy)
4518 ;; We go to the dummy root by going to
4519 ;; the first sub-"thread", and then one line up.
4520 (gnus-summary-goto-article
4521 (mail-header-number (caadr thread)))
4522 (forward-line -1)
4523 (gnus-delete-line)
4524 (gnus-data-compute-positions))
4525 (setq thread (cdr thread))
4526 (while thread
4527 (gnus-remove-thread-1 (car thread))
4528 (setq thread (cdr thread))))
4529 (gnus-remove-thread-1 thread))))))))
4530
4531 (defun gnus-remove-thread-1 (thread)
4532 "Remove the thread THREAD recursively."
4533 (let ((number (mail-header-number (pop thread)))
4534 d)
4535 (setq thread (reverse thread))
4536 (while thread
4537 (gnus-remove-thread-1 (pop thread)))
4538 (when (setq d (gnus-data-find number))
4539 (goto-char (gnus-data-pos d))
4540 (gnus-summary-show-thread)
4541 (gnus-data-remove
4542 number
4543 (- (gnus-point-at-bol)
4544 (prog1
4545 (1+ (gnus-point-at-eol))
4546 (gnus-delete-line)))))))
4547
4548 (defun gnus-sort-threads-1 (threads func)
4549 (sort (mapcar (lambda (thread)
4550 (cons (car thread)
4551 (and (cdr thread)
4552 (gnus-sort-threads-1 (cdr thread) func))))
4553 threads) func))
4554
4555 (defun gnus-sort-threads (threads)
4556 "Sort THREADS."
4557 (if (not gnus-thread-sort-functions)
4558 threads
4559 (gnus-message 8 "Sorting threads...")
4560 (let ((max-lisp-eval-depth 5000))
4561 (prog1 (gnus-sort-threads-1
4562 threads
4563 (gnus-make-sort-function gnus-thread-sort-functions))
4564 (gnus-message 8 "Sorting threads...done")))))
4565
4566 (defun gnus-sort-articles (articles)
4567 "Sort ARTICLES."
4568 (when gnus-article-sort-functions
4569 (gnus-message 7 "Sorting articles...")
4570 (prog1
4571 (setq gnus-newsgroup-headers
4572 (sort articles (gnus-make-sort-function
4573 gnus-article-sort-functions)))
4574 (gnus-message 7 "Sorting articles...done"))))
4575
4576 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4577 (defmacro gnus-thread-header (thread)
4578 "Return header of first article in THREAD.
4579 Note that THREAD must never, ever be anything else than a variable -
4580 using some other form will lead to serious barfage."
4581 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4582 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4583 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4584 (vector thread) 2))
4585
4586 (defsubst gnus-article-sort-by-number (h1 h2)
4587 "Sort articles by article number."
4588 (< (mail-header-number h1)
4589 (mail-header-number h2)))
4590
4591 (defun gnus-thread-sort-by-number (h1 h2)
4592 "Sort threads by root article number."
4593 (gnus-article-sort-by-number
4594 (gnus-thread-header h1) (gnus-thread-header h2)))
4595
4596 (defsubst gnus-article-sort-by-random (h1 h2)
4597 "Sort articles by article number."
4598 (zerop (random 2)))
4599
4600 (defun gnus-thread-sort-by-random (h1 h2)
4601 "Sort threads by root article number."
4602 (gnus-article-sort-by-random
4603 (gnus-thread-header h1) (gnus-thread-header h2)))
4604
4605 (defsubst gnus-article-sort-by-lines (h1 h2)
4606 "Sort articles by article Lines header."
4607 (< (mail-header-lines h1)
4608 (mail-header-lines h2)))
4609
4610 (defun gnus-thread-sort-by-lines (h1 h2)
4611 "Sort threads by root article Lines header."
4612 (gnus-article-sort-by-lines
4613 (gnus-thread-header h1) (gnus-thread-header h2)))
4614
4615 (defsubst gnus-article-sort-by-chars (h1 h2)
4616 "Sort articles by octet length."
4617 (< (mail-header-chars h1)
4618 (mail-header-chars h2)))
4619
4620 (defun gnus-thread-sort-by-chars (h1 h2)
4621 "Sort threads by root article octet length."
4622 (gnus-article-sort-by-chars
4623 (gnus-thread-header h1) (gnus-thread-header h2)))
4624
4625 (defsubst gnus-article-sort-by-author (h1 h2)
4626 "Sort articles by root author."
4627 (string-lessp
4628 (let ((extract (funcall
4629 gnus-extract-address-components
4630 (mail-header-from h1))))
4631 (or (car extract) (cadr extract) ""))
4632 (let ((extract (funcall
4633 gnus-extract-address-components
4634 (mail-header-from h2))))
4635 (or (car extract) (cadr extract) ""))))
4636
4637 (defun gnus-thread-sort-by-author (h1 h2)
4638 "Sort threads by root author."
4639 (gnus-article-sort-by-author
4640 (gnus-thread-header h1) (gnus-thread-header h2)))
4641
4642 (defsubst gnus-article-sort-by-subject (h1 h2)
4643 "Sort articles by root subject."
4644 (string-lessp
4645 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4646 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4647
4648 (defun gnus-thread-sort-by-subject (h1 h2)
4649 "Sort threads by root subject."
4650 (gnus-article-sort-by-subject
4651 (gnus-thread-header h1) (gnus-thread-header h2)))
4652
4653 (defsubst gnus-article-sort-by-date (h1 h2)
4654 "Sort articles by root article date."
4655 (time-less-p
4656 (gnus-date-get-time (mail-header-date h1))
4657 (gnus-date-get-time (mail-header-date h2))))
4658
4659 (defun gnus-thread-sort-by-date (h1 h2)
4660 "Sort threads by root article date."
4661 (gnus-article-sort-by-date
4662 (gnus-thread-header h1) (gnus-thread-header h2)))
4663
4664 (defsubst gnus-article-sort-by-score (h1 h2)
4665 "Sort articles by root article score.
4666 Unscored articles will be counted as having a score of zero."
4667 (> (or (cdr (assq (mail-header-number h1)
4668 gnus-newsgroup-scored))
4669 gnus-summary-default-score 0)
4670 (or (cdr (assq (mail-header-number h2)
4671 gnus-newsgroup-scored))
4672 gnus-summary-default-score 0)))
4673
4674 (defun gnus-thread-sort-by-score (h1 h2)
4675 "Sort threads by root article score."
4676 (gnus-article-sort-by-score
4677 (gnus-thread-header h1) (gnus-thread-header h2)))
4678
4679 (defun gnus-thread-sort-by-total-score (h1 h2)
4680 "Sort threads by the sum of all scores in the thread.
4681 Unscored articles will be counted as having a score of zero."
4682 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4683
4684 (defun gnus-thread-total-score (thread)
4685 ;; This function find the total score of THREAD.
4686 (cond
4687 ((null thread)
4688 0)
4689 ((consp thread)
4690 (if (stringp (car thread))
4691 (apply gnus-thread-score-function 0
4692 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4693 (gnus-thread-total-score-1 thread)))
4694 (t
4695 (gnus-thread-total-score-1 (list thread)))))
4696
4697 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4698 "Sort threads such that the thread with the most recently arrived article comes first."
4699 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4700
4701 (defun gnus-thread-highest-number (thread)
4702 "Return the highest article number in THREAD."
4703 (apply 'max (mapcar (lambda (header)
4704 (mail-header-number header))
4705 (message-flatten-list thread))))
4706
4707 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4708 "Sort threads such that the thread with the most recently dated article comes first."
4709 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4710
4711 (defun gnus-thread-latest-date (thread)
4712 "Return the highest article date in THREAD."
4713 (let ((previous-time 0))
4714 (apply 'max
4715 (mapcar
4716 (lambda (header)
4717 (setq previous-time
4718 (condition-case ()
4719 (time-to-seconds (mail-header-parse-date
4720 (mail-header-date header)))
4721 (error previous-time))))
4722 (sort
4723 (message-flatten-list thread)
4724 (lambda (h1 h2)
4725 (< (mail-header-number h1)
4726 (mail-header-number h2))))))))
4727
4728 (defun gnus-thread-total-score-1 (root)
4729 ;; This function find the total score of the thread below ROOT.
4730 (setq root (car root))
4731 (apply gnus-thread-score-function
4732 (or (append
4733 (mapcar 'gnus-thread-total-score
4734 (cdr (gnus-id-to-thread (mail-header-id root))))
4735 (when (> (mail-header-number root) 0)
4736 (list (or (cdr (assq (mail-header-number root)
4737 gnus-newsgroup-scored))
4738 gnus-summary-default-score 0))))
4739 (list gnus-summary-default-score)
4740 '(0))))
4741
4742 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4743 (defvar gnus-tmp-prev-subject nil)
4744 (defvar gnus-tmp-false-parent nil)
4745 (defvar gnus-tmp-root-expunged nil)
4746 (defvar gnus-tmp-dummy-line nil)
4747
4748 (eval-when-compile (defvar gnus-tmp-header))
4749 (defun gnus-extra-header (type &optional header)
4750 "Return the extra header of TYPE."
4751 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4752 ""))
4753
4754 (defvar gnus-tmp-thread-tree-header-string "")
4755
4756 (defcustom gnus-sum-thread-tree-root "> "
4757 "With %B spec, used for the root of a thread.
4758 If nil, use subject instead."
4759 :version "22.1"
4760 :type '(radio (const :format "%v " nil) string)
4761 :group 'gnus-thread)
4762 (defcustom gnus-sum-thread-tree-false-root "> "
4763 "With %B spec, used for a false root of a thread.
4764 If nil, use subject instead."
4765 :version "22.1"
4766 :type '(radio (const :format "%v " nil) string)
4767 :group 'gnus-thread)
4768 (defcustom gnus-sum-thread-tree-single-indent ""
4769 "With %B spec, used for a thread with just one message.
4770 If nil, use subject instead."
4771 :version "22.1"
4772 :type '(radio (const :format "%v " nil) string)
4773 :group 'gnus-thread)
4774 (defcustom gnus-sum-thread-tree-vertical "| "
4775 "With %B spec, used for drawing a vertical line."
4776 :version "22.1"
4777 :type 'string
4778 :group 'gnus-thread)
4779 (defcustom gnus-sum-thread-tree-indent " "
4780 "With %B spec, used for indenting."
4781 :version "22.1"
4782 :type 'string
4783 :group 'gnus-thread)
4784 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4785 "With %B spec, used for a leaf with brothers."
4786 :version "22.1"
4787 :type 'string
4788 :group 'gnus-thread)
4789 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4790 "With %B spec, used for a leaf without brothers."
4791 :version "22.1"
4792 :type 'string
4793 :group 'gnus-thread)
4794
4795 (defun gnus-summary-prepare-threads (threads)
4796 "Prepare summary buffer from THREADS and indentation LEVEL.
4797 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4798 or a straight list of headers."
4799 (gnus-message 7 "Generating summary...")
4800
4801 (setq gnus-newsgroup-threads threads)
4802 (beginning-of-line)
4803
4804 (let ((gnus-tmp-level 0)
4805 (default-score (or gnus-summary-default-score 0))
4806 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4807 (building-line-count gnus-summary-display-while-building)
4808 (building-count (integerp gnus-summary-display-while-building))
4809 thread number subject stack state gnus-tmp-gathered beg-match
4810 new-roots gnus-tmp-new-adopts thread-end simp-subject
4811 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4812 gnus-tmp-replied gnus-tmp-subject-or-nil
4813 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4814 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4815 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4816 tree-stack)
4817
4818 (setq gnus-tmp-prev-subject nil
4819 gnus-tmp-thread-tree-header-string "")
4820
4821 (if (vectorp (car threads))
4822 ;; If this is a straight (sic) list of headers, then a
4823 ;; threaded summary display isn't required, so we just create
4824 ;; an unthreaded one.
4825 (gnus-summary-prepare-unthreaded threads)
4826
4827 ;; Do the threaded display.
4828
4829 (if gnus-summary-display-while-building
4830 (switch-to-buffer (buffer-name)))
4831 (while (or threads stack gnus-tmp-new-adopts new-roots)
4832
4833 (if (and (= gnus-tmp-level 0)
4834 (or (not stack)
4835 (= (caar stack) 0))
4836 (not gnus-tmp-false-parent)
4837 (or gnus-tmp-new-adopts new-roots))
4838 (if gnus-tmp-new-adopts
4839 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4840 thread (list (car gnus-tmp-new-adopts))
4841 gnus-tmp-header (caar thread)
4842 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4843 (when new-roots
4844 (setq thread (list (car new-roots))
4845 gnus-tmp-header (caar thread)
4846 new-roots (cdr new-roots))))
4847
4848 (if threads
4849 ;; If there are some threads, we do them before the
4850 ;; threads on the stack.
4851 (setq thread threads
4852 gnus-tmp-header (caar thread))
4853 ;; There were no current threads, so we pop something off
4854 ;; the stack.
4855 (setq state (car stack)
4856 gnus-tmp-level (car state)
4857 tree-stack (cadr state)
4858 thread (caddr state)
4859 stack (cdr stack)
4860 gnus-tmp-header (caar thread))))
4861
4862 (setq gnus-tmp-false-parent nil)
4863 (setq gnus-tmp-root-expunged nil)
4864 (setq thread-end nil)
4865
4866 (if (stringp gnus-tmp-header)
4867 ;; The header is a dummy root.
4868 (cond
4869 ((eq gnus-summary-make-false-root 'adopt)
4870 ;; We let the first article adopt the rest.
4871 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4872 (cddar thread)))
4873 (setq gnus-tmp-gathered
4874 (nconc (mapcar
4875 (lambda (h) (mail-header-number (car h)))
4876 (cddar thread))
4877 gnus-tmp-gathered))
4878 (setq thread (cons (list (caar thread)
4879 (cadar thread))
4880 (cdr thread)))
4881 (setq gnus-tmp-level -1
4882 gnus-tmp-false-parent t))
4883 ((eq gnus-summary-make-false-root 'empty)
4884 ;; We print adopted articles with empty subject fields.
4885 (setq gnus-tmp-gathered
4886 (nconc (mapcar
4887 (lambda (h) (mail-header-number (car h)))
4888 (cddar thread))
4889 gnus-tmp-gathered))
4890 (setq gnus-tmp-level -1))
4891 ((eq gnus-summary-make-false-root 'dummy)
4892 ;; We remember that we probably want to output a dummy
4893 ;; root.
4894 (setq gnus-tmp-dummy-line gnus-tmp-header)
4895 (setq gnus-tmp-prev-subject gnus-tmp-header))
4896 (t
4897 ;; We do not make a root for the gathered
4898 ;; sub-threads at all.
4899 (setq gnus-tmp-level -1)))
4900
4901 (setq number (mail-header-number gnus-tmp-header)
4902 subject (mail-header-subject gnus-tmp-header)
4903 simp-subject (gnus-simplify-subject-fully subject))
4904
4905 (cond
4906 ;; If the thread has changed subject, we might want to make
4907 ;; this subthread into a root.
4908 ((and (null gnus-thread-ignore-subject)
4909 (not (zerop gnus-tmp-level))
4910 gnus-tmp-prev-subject
4911 (not (string= gnus-tmp-prev-subject simp-subject)))
4912 (setq new-roots (nconc new-roots (list (car thread)))
4913 thread-end t
4914 gnus-tmp-header nil))
4915 ;; If the article lies outside the current limit,
4916 ;; then we do not display it.
4917 ((not (memq number gnus-newsgroup-limit))
4918 (setq gnus-tmp-gathered
4919 (nconc (mapcar
4920 (lambda (h) (mail-header-number (car h)))
4921 (cdar thread))
4922 gnus-tmp-gathered))
4923 (setq gnus-tmp-new-adopts (if (cdar thread)
4924 (append gnus-tmp-new-adopts
4925 (cdar thread))
4926 gnus-tmp-new-adopts)
4927 thread-end t
4928 gnus-tmp-header nil)
4929 (when (zerop gnus-tmp-level)
4930 (setq gnus-tmp-root-expunged t)))
4931 ;; Perhaps this article is to be marked as read?
4932 ((and gnus-summary-mark-below
4933 (< (or (cdr (assq number gnus-newsgroup-scored))
4934 default-score)
4935 gnus-summary-mark-below)
4936 ;; Don't touch sparse articles.
4937 (not (gnus-summary-article-sparse-p number))
4938 (not (gnus-summary-article-ancient-p number)))
4939 (setq gnus-newsgroup-unreads
4940 (delq number gnus-newsgroup-unreads))
4941 (if gnus-newsgroup-auto-expire
4942 (setq gnus-newsgroup-expirable
4943 (gnus-add-to-sorted-list
4944 gnus-newsgroup-expirable number))
4945 (push (cons number gnus-low-score-mark)
4946 gnus-newsgroup-reads))))
4947
4948 (when gnus-tmp-header
4949 ;; We may have an old dummy line to output before this
4950 ;; article.
4951 (when (and gnus-tmp-dummy-line
4952 (gnus-subject-equal
4953 gnus-tmp-dummy-line
4954 (mail-header-subject gnus-tmp-header)))
4955 (gnus-summary-insert-dummy-line
4956 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4957 (setq gnus-tmp-dummy-line nil))
4958
4959 ;; Compute the mark.
4960 (setq gnus-tmp-unread (gnus-article-mark number))
4961
4962 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4963 gnus-tmp-header gnus-tmp-level)
4964 gnus-newsgroup-data)
4965
4966 ;; Actually insert the line.
4967 (setq
4968 gnus-tmp-subject-or-nil
4969 (cond
4970 ((and gnus-thread-ignore-subject
4971 gnus-tmp-prev-subject
4972 (not (string= gnus-tmp-prev-subject simp-subject)))
4973 subject)
4974 ((zerop gnus-tmp-level)
4975 (if (and (eq gnus-summary-make-false-root 'empty)
4976 (memq number gnus-tmp-gathered)
4977 gnus-tmp-prev-subject
4978 (string= gnus-tmp-prev-subject simp-subject))
4979 gnus-summary-same-subject
4980 subject))
4981 (t gnus-summary-same-subject)))
4982 (if (and (eq gnus-summary-make-false-root 'adopt)
4983 (= gnus-tmp-level 1)
4984 (memq number gnus-tmp-gathered))
4985 (setq gnus-tmp-opening-bracket ?\<
4986 gnus-tmp-closing-bracket ?\>)
4987 (setq gnus-tmp-opening-bracket ?\[
4988 gnus-tmp-closing-bracket ?\]))
4989 (setq
4990 gnus-tmp-indentation
4991 (aref gnus-thread-indent-array gnus-tmp-level)
4992 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4993 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4994 gnus-summary-default-score 0)
4995 gnus-tmp-score-char
4996 (if (or (null gnus-summary-default-score)
4997 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4998 gnus-summary-zcore-fuzz))
4999 ? ;Whitespace
5000 (if (< gnus-tmp-score gnus-summary-default-score)
5001 gnus-score-below-mark gnus-score-over-mark))
5002 gnus-tmp-replied
5003 (cond ((memq number gnus-newsgroup-processable)
5004 gnus-process-mark)
5005 ((memq number gnus-newsgroup-cached)
5006 gnus-cached-mark)
5007 ((memq number gnus-newsgroup-replied)
5008 gnus-replied-mark)
5009 ((memq number gnus-newsgroup-forwarded)
5010 gnus-forwarded-mark)
5011 ((memq number gnus-newsgroup-saved)
5012 gnus-saved-mark)
5013 ((memq number gnus-newsgroup-recent)
5014 gnus-recent-mark)
5015 ((memq number gnus-newsgroup-unseen)
5016 gnus-unseen-mark)
5017 (t gnus-no-mark))
5018 gnus-tmp-downloaded
5019 (cond ((memq number gnus-newsgroup-undownloaded)
5020 gnus-undownloaded-mark)
5021 (gnus-newsgroup-agentized
5022 gnus-downloaded-mark)
5023 (t
5024 gnus-no-mark))
5025 gnus-tmp-from (mail-header-from gnus-tmp-header)
5026 gnus-tmp-name
5027 (cond
5028 ((string-match "<[^>]+> *$" gnus-tmp-from)
5029 (setq beg-match (match-beginning 0))
5030 (or (and (string-match "^\".+\"" gnus-tmp-from)
5031 (substring gnus-tmp-from 1 (1- (match-end 0))))
5032 (substring gnus-tmp-from 0 beg-match)))
5033 ((string-match "(.+)" gnus-tmp-from)
5034 (substring gnus-tmp-from
5035 (1+ (match-beginning 0)) (1- (match-end 0))))
5036 (t gnus-tmp-from))
5037
5038 ;; Do the %B string
5039 gnus-tmp-thread-tree-header-string
5040 (cond
5041 ((not gnus-show-threads) "")
5042 ((zerop gnus-tmp-level)
5043 (cond ((cdar thread)
5044 (or gnus-sum-thread-tree-root subject))
5045 (gnus-tmp-new-adopts
5046 (or gnus-sum-thread-tree-false-root subject))
5047 (t
5048 (or gnus-sum-thread-tree-single-indent subject))))
5049 (t
5050 (concat (apply 'concat
5051 (mapcar (lambda (item)
5052 (if (= item 1)
5053 gnus-sum-thread-tree-vertical
5054 gnus-sum-thread-tree-indent))
5055 (cdr (reverse tree-stack))))
5056 (if (nth 1 thread)
5057 gnus-sum-thread-tree-leaf-with-other
5058 gnus-sum-thread-tree-single-leaf)))))
5059 (when (string= gnus-tmp-name "")
5060 (setq gnus-tmp-name gnus-tmp-from))
5061 (unless (numberp gnus-tmp-lines)
5062 (setq gnus-tmp-lines -1))
5063 (if (= gnus-tmp-lines -1)
5064 (setq gnus-tmp-lines "?")
5065 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5066 (gnus-put-text-property
5067 (point)
5068 (progn (eval gnus-summary-line-format-spec) (point))
5069 'gnus-number number)
5070 (when gnus-visual-p
5071 (forward-line -1)
5072 (gnus-run-hooks 'gnus-summary-update-hook)
5073 (forward-line 1))
5074
5075 (setq gnus-tmp-prev-subject simp-subject)))
5076
5077 (when (nth 1 thread)
5078 (push (list (max 0 gnus-tmp-level)
5079 (copy-sequence tree-stack)
5080 (nthcdr 1 thread))
5081 stack))
5082 (push (if (nth 1 thread) 1 0) tree-stack)
5083 (incf gnus-tmp-level)
5084 (setq threads (if thread-end nil (cdar thread)))
5085 (if gnus-summary-display-while-building
5086 (if building-count
5087 (progn
5088 ;; use a set frequency
5089 (setq building-line-count (1- building-line-count))
5090 (when (= building-line-count 0)
5091 (sit-for 0)
5092 (setq building-line-count
5093 gnus-summary-display-while-building)))
5094 ;; always
5095 (sit-for 0)))
5096 (unless threads
5097 (setq gnus-tmp-level 0)))))
5098 (gnus-message 7 "Generating summary...done"))
5099
5100 (defun gnus-summary-prepare-unthreaded (headers)
5101 "Generate an unthreaded summary buffer based on HEADERS."
5102 (let (header number mark)
5103
5104 (beginning-of-line)
5105
5106 (while headers
5107 ;; We may have to root out some bad articles...
5108 (when (memq (setq number (mail-header-number
5109 (setq header (pop headers))))
5110 gnus-newsgroup-limit)
5111 ;; Mark article as read when it has a low score.
5112 (when (and gnus-summary-mark-below
5113 (< (or (cdr (assq number gnus-newsgroup-scored))
5114 gnus-summary-default-score 0)
5115 gnus-summary-mark-below)
5116 (not (gnus-summary-article-ancient-p number)))
5117 (setq gnus-newsgroup-unreads
5118 (delq number gnus-newsgroup-unreads))
5119 (if gnus-newsgroup-auto-expire
5120 (push number gnus-newsgroup-expirable)
5121 (push (cons number gnus-low-score-mark)
5122 gnus-newsgroup-reads)))
5123
5124 (setq mark (gnus-article-mark number))
5125 (push (gnus-data-make number mark (1+ (point)) header 0)
5126 gnus-newsgroup-data)
5127 (gnus-summary-insert-line
5128 header 0 number
5129 (memq number gnus-newsgroup-undownloaded)
5130 mark (memq number gnus-newsgroup-replied)
5131 (memq number gnus-newsgroup-expirable)
5132 (mail-header-subject header) nil
5133 (cdr (assq number gnus-newsgroup-scored))
5134 (memq number gnus-newsgroup-processable))))))
5135
5136 (defun gnus-summary-remove-list-identifiers ()
5137 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5138 (let ((regexp (if (consp gnus-list-identifiers)
5139 (mapconcat 'identity gnus-list-identifiers " *\\|")
5140 gnus-list-identifiers))
5141 changed subject)
5142 (when regexp
5143 (dolist (header gnus-newsgroup-headers)
5144 (setq subject (mail-header-subject header)
5145 changed nil)
5146 (while (string-match
5147 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5148 subject)
5149 (setq subject
5150 (concat (substring subject 0 (match-beginning 2))
5151 (substring subject (match-end 0)))
5152 changed t))
5153 (when (and changed
5154 (string-match
5155 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5156 (setq subject
5157 (concat (substring subject 0 (match-beginning 1))
5158 (substring subject (match-end 1)))))
5159 (when changed
5160 (mail-header-set-subject header subject))))))
5161
5162 (defun gnus-fetch-headers (articles)
5163 "Fetch headers of ARTICLES."
5164 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5165 (gnus-message 5 "Fetching headers for %s..." name)
5166 (prog1
5167 (if (eq 'nov
5168 (setq gnus-headers-retrieved-by
5169 (gnus-retrieve-headers
5170 articles gnus-newsgroup-name
5171 ;; We might want to fetch old headers, but
5172 ;; not if there is only 1 article.
5173 (and (or (and
5174 (not (eq gnus-fetch-old-headers 'some))
5175 (not (numberp gnus-fetch-old-headers)))
5176 (> (length articles) 1))
5177 gnus-fetch-old-headers))))
5178 (gnus-get-newsgroup-headers-xover
5179 articles nil nil gnus-newsgroup-name t)
5180 (gnus-get-newsgroup-headers))
5181 (gnus-message 5 "Fetching headers for %s...done" name))))
5182
5183 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5184 "Select newsgroup GROUP.
5185 If READ-ALL is non-nil, all articles in the group are selected.
5186 If SELECT-ARTICLES, only select those articles from GROUP."
5187 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5188 ;;!!! Dirty hack; should be removed.
5189 (gnus-summary-ignore-duplicates
5190 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5191 t
5192 gnus-summary-ignore-duplicates))
5193 (info (nth 2 entry))
5194 articles fetched-articles cached)
5195
5196 (unless (gnus-check-server
5197 (set (make-local-variable 'gnus-current-select-method)
5198 (gnus-find-method-for-group group)))
5199 (error "Couldn't open server"))
5200
5201 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5202 (gnus-activate-group group) ; Or we can activate it...
5203 (progn ; Or we bug out.
5204 (when (equal major-mode 'gnus-summary-mode)
5205 (gnus-kill-buffer (current-buffer)))
5206 (error "Couldn't activate group %s: %s"
5207 group (gnus-status-message group))))
5208
5209 (unless (gnus-request-group group t)
5210 (when (equal major-mode 'gnus-summary-mode)
5211 (gnus-kill-buffer (current-buffer)))
5212 (error "Couldn't request group %s: %s"
5213 group (gnus-status-message group)))
5214
5215 (when gnus-agent
5216 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5217
5218 (setq gnus-summary-use-undownloaded-faces
5219 (gnus-agent-find-parameter
5220 group
5221 'agent-enable-undownloaded-faces)))
5222
5223 (setq gnus-newsgroup-name group
5224 gnus-newsgroup-unselected nil
5225 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5226
5227 (let ((display (gnus-group-find-parameter group 'display)))
5228 (setq gnus-newsgroup-display
5229 (cond
5230 ((not (zerop (or (car-safe read-all) 0)))
5231 ;; The user entered the group with C-u SPC/RET, let's show
5232 ;; all articles.
5233 'gnus-not-ignore)
5234 ((eq display 'all)
5235 'gnus-not-ignore)
5236 ((arrayp display)
5237 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5238 ((numberp display)
5239 ;; The following is probably the "correct" solution, but
5240 ;; it makes Gnus fetch all headers and then limit the
5241 ;; articles (which is slow), so instead we hack the
5242 ;; select-articles parameter instead. -- Simon Josefsson
5243 ;; <jas@kth.se>
5244 ;;
5245 ;; (gnus-byte-compile
5246 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5247 ;; display)))))
5248 (setq select-articles
5249 (gnus-uncompress-range
5250 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5251 (if (> tmp 0)
5252 tmp
5253 1))
5254 (cdr (gnus-active group)))))
5255 nil)
5256 (t
5257 nil))))
5258
5259 (gnus-summary-setup-default-charset)
5260
5261 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5262 (when (gnus-virtual-group-p group)
5263 (setq cached gnus-newsgroup-cached))
5264
5265 (setq gnus-newsgroup-unreads
5266 (gnus-sorted-ndifference
5267 (gnus-sorted-ndifference gnus-newsgroup-unreads
5268 gnus-newsgroup-marked)
5269 gnus-newsgroup-dormant))
5270
5271 (setq gnus-newsgroup-processable nil)
5272
5273 (gnus-update-read-articles group gnus-newsgroup-unreads)
5274
5275 ;; Adjust and set lists of article marks.
5276 (when info
5277 (gnus-adjust-marked-articles info))
5278 (if (setq articles select-articles)
5279 (setq gnus-newsgroup-unselected
5280 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5281 (setq articles (gnus-articles-to-read group read-all)))
5282
5283 (cond
5284 ((null articles)
5285 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5286 'quit)
5287 ((eq articles 0) nil)
5288 (t
5289 ;; Init the dependencies hash table.
5290 (setq gnus-newsgroup-dependencies
5291 (gnus-make-hashtable (length articles)))
5292 (gnus-set-global-variables)
5293 ;; Retrieve the headers and read them in.
5294
5295 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5296
5297 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5298 (when cached
5299 (setq gnus-newsgroup-cached cached))
5300
5301 ;; Suppress duplicates?
5302 (when gnus-suppress-duplicates
5303 (gnus-dup-suppress-articles))
5304
5305 ;; Set the initial limit.
5306 (setq gnus-newsgroup-limit (copy-sequence articles))
5307 ;; Remove canceled articles from the list of unread articles.
5308 (setq fetched-articles
5309 (mapcar (lambda (headers) (mail-header-number headers))
5310 gnus-newsgroup-headers))
5311 (setq gnus-newsgroup-articles fetched-articles)
5312 (setq gnus-newsgroup-unreads
5313 (gnus-sorted-nintersection
5314 gnus-newsgroup-unreads fetched-articles))
5315 (gnus-compute-unseen-list)
5316
5317 ;; Removed marked articles that do not exist.
5318 (gnus-update-missing-marks
5319 (gnus-sorted-difference articles fetched-articles))
5320 ;; We might want to build some more threads first.
5321 (when (and gnus-fetch-old-headers
5322 (eq gnus-headers-retrieved-by 'nov))
5323 (if (eq gnus-fetch-old-headers 'invisible)
5324 (gnus-build-all-threads)
5325 (gnus-build-old-threads)))
5326 ;; Let the Gnus agent mark articles as read.
5327 (when gnus-agent
5328 (gnus-agent-get-undownloaded-list))
5329 ;; Remove list identifiers from subject
5330 (when gnus-list-identifiers
5331 (gnus-summary-remove-list-identifiers))
5332 ;; Check whether auto-expire is to be done in this group.
5333 (setq gnus-newsgroup-auto-expire
5334 (gnus-group-auto-expirable-p group))
5335 ;; Set up the article buffer now, if necessary.
5336 (unless gnus-single-article-buffer
5337 (gnus-article-setup-buffer))
5338 ;; First and last article in this newsgroup.
5339 (when gnus-newsgroup-headers
5340 (setq gnus-newsgroup-begin
5341 (mail-header-number (car gnus-newsgroup-headers))
5342 gnus-newsgroup-end
5343 (mail-header-number
5344 (gnus-last-element gnus-newsgroup-headers))))
5345 ;; GROUP is successfully selected.
5346 (or gnus-newsgroup-headers t)))))
5347
5348 (defun gnus-compute-unseen-list ()
5349 ;; The `seen' marks are treated specially.
5350 (if (not gnus-newsgroup-seen)
5351 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5352 (setq gnus-newsgroup-unseen
5353 (gnus-inverse-list-range-intersection
5354 gnus-newsgroup-articles gnus-newsgroup-seen))))
5355
5356 (defun gnus-summary-display-make-predicate (display)
5357 (require 'gnus-agent)
5358 (when (= (length display) 1)
5359 (setq display (car display)))
5360 (unless gnus-summary-display-cache
5361 (dolist (elem (append '((unread . unread)
5362 (read . read)
5363 (unseen . unseen))
5364 gnus-article-mark-lists))
5365 (push (cons (cdr elem)
5366 (gnus-byte-compile
5367 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5368 gnus-summary-display-cache)))
5369 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5370 (gnus-category-predicate-cache gnus-summary-display-cache))
5371 (gnus-get-predicate display)))
5372
5373 ;; Uses the dynamically bound `number' variable.
5374 (eval-when-compile
5375 (defvar number))
5376 (defun gnus-article-marked-p (type &optional article)
5377 (let ((article (or article number)))
5378 (cond
5379 ((eq type 'tick)
5380 (memq article gnus-newsgroup-marked))
5381 ((eq type 'spam)
5382 (memq article gnus-newsgroup-spam-marked))
5383 ((eq type 'unsend)
5384 (memq article gnus-newsgroup-unsendable))
5385 ((eq type 'undownload)
5386 (memq article gnus-newsgroup-undownloaded))
5387 ((eq type 'download)
5388 (memq article gnus-newsgroup-downloadable))
5389 ((eq type 'unread)
5390 (memq article gnus-newsgroup-unreads))
5391 ((eq type 'read)
5392 (memq article gnus-newsgroup-reads))
5393 ((eq type 'dormant)
5394 (memq article gnus-newsgroup-dormant) )
5395 ((eq type 'expire)
5396 (memq article gnus-newsgroup-expirable))
5397 ((eq type 'reply)
5398 (memq article gnus-newsgroup-replied))
5399 ((eq type 'killed)
5400 (memq article gnus-newsgroup-killed))
5401 ((eq type 'bookmark)
5402 (assq article gnus-newsgroup-bookmarks))
5403 ((eq type 'score)
5404 (assq article gnus-newsgroup-scored))
5405 ((eq type 'save)
5406 (memq article gnus-newsgroup-saved))
5407 ((eq type 'cache)
5408 (memq article gnus-newsgroup-cached))
5409 ((eq type 'forward)
5410 (memq article gnus-newsgroup-forwarded))
5411 ((eq type 'seen)
5412 (not (memq article gnus-newsgroup-unseen)))
5413 ((eq type 'recent)
5414 (memq article gnus-newsgroup-recent))
5415 (t t))))
5416
5417 (defun gnus-articles-to-read (group &optional read-all)
5418 "Find out what articles the user wants to read."
5419 (let* ((articles
5420 ;; Select all articles if `read-all' is non-nil, or if there
5421 ;; are no unread articles.
5422 (if (or read-all
5423 (and (zerop (length gnus-newsgroup-marked))
5424 (zerop (length gnus-newsgroup-unreads)))
5425 ;; Fetch all if the predicate is non-nil.
5426 gnus-newsgroup-display)
5427 ;; We want to select the headers for all the articles in
5428 ;; the group, so we select either all the active
5429 ;; articles in the group, or (if that's nil), the
5430 ;; articles in the cache.
5431 (or
5432 (gnus-uncompress-range (gnus-active group))
5433 (gnus-cache-articles-in-group group))
5434 ;; Select only the "normal" subset of articles.
5435 (gnus-sorted-nunion
5436 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5437 gnus-newsgroup-unreads)))
5438 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5439 (scored (length scored-list))
5440 (number (length articles))
5441 (marked (+ (length gnus-newsgroup-marked)
5442 (length gnus-newsgroup-dormant)))
5443 (select
5444 (cond
5445 ((numberp read-all)
5446 read-all)
5447 ((numberp gnus-newsgroup-display)
5448 gnus-newsgroup-display)
5449 (t
5450 (condition-case ()
5451 (cond
5452 ((and (or (<= scored marked) (= scored number))
5453 (numberp gnus-large-newsgroup)
5454 (> number gnus-large-newsgroup))
5455 (let* ((cursor-in-echo-area nil)
5456 (initial (gnus-parameter-large-newsgroup-initial
5457 gnus-newsgroup-name))
5458 (input
5459 (read-string
5460 (format
5461 "How many articles from %s (%s %d): "
5462 (gnus-limit-string
5463 (gnus-group-decoded-name gnus-newsgroup-name)
5464 35)
5465 (if initial "max" "default")
5466 number)
5467 (if initial
5468 (cons (number-to-string initial)
5469 0)))))
5470 (if (string-match "^[ \t]*$" input) number input)))
5471 ((and (> scored marked) (< scored number)
5472 (> (- scored number) 20))
5473 (let ((input
5474 (read-string
5475 (format "%s %s (%d scored, %d total): "
5476 "How many articles from"
5477 (gnus-group-decoded-name group)
5478 scored number))))
5479 (if (string-match "^[ \t]*$" input)
5480 number input)))
5481 (t number))
5482 (quit
5483 (message "Quit getting the articles to read")
5484 nil))))))
5485 (setq select (if (stringp select) (string-to-number select) select))
5486 (if (or (null select) (zerop select))
5487 select
5488 (if (and (not (zerop scored)) (<= (abs select) scored))
5489 (progn
5490 (setq articles (sort scored-list '<))
5491 (setq number (length articles)))
5492 (setq articles (copy-sequence articles)))
5493
5494 (when (< (abs select) number)
5495 (if (< select 0)
5496 ;; Select the N oldest articles.
5497 (setcdr (nthcdr (1- (abs select)) articles) nil)
5498 ;; Select the N most recent articles.
5499 (setq articles (nthcdr (- number select) articles))))
5500 (setq gnus-newsgroup-unselected
5501 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5502 (when gnus-alter-articles-to-read-function
5503 (setq articles
5504 (sort
5505 (funcall gnus-alter-articles-to-read-function
5506 gnus-newsgroup-name articles)
5507 '<)))
5508 articles)))
5509
5510 (defun gnus-killed-articles (killed articles)
5511 (let (out)
5512 (while articles
5513 (when (inline (gnus-member-of-range (car articles) killed))
5514 (push (car articles) out))
5515 (setq articles (cdr articles)))
5516 out))
5517
5518 (defun gnus-uncompress-marks (marks)
5519 "Uncompress the mark ranges in MARKS."
5520 (let ((uncompressed '(score bookmark))
5521 out)
5522 (while marks
5523 (if (memq (caar marks) uncompressed)
5524 (push (car marks) out)
5525 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5526 (setq marks (cdr marks)))
5527 out))
5528
5529 (defun gnus-article-mark-to-type (mark)
5530 "Return the type of MARK."
5531 (or (cadr (assq mark gnus-article-special-mark-lists))
5532 'list))
5533
5534 (defun gnus-article-unpropagatable-p (mark)
5535 "Return whether MARK should be propagated to back end."
5536 (memq mark gnus-article-unpropagated-mark-lists))
5537
5538 (defun gnus-adjust-marked-articles (info)
5539 "Set all article lists and remove all marks that are no longer valid."
5540 (let* ((marked-lists (gnus-info-marks info))
5541 (active (gnus-active (gnus-info-group info)))
5542 (min (car active))
5543 (max (cdr active))
5544 (types gnus-article-mark-lists)
5545 marks var articles article mark mark-type
5546 bgn end)
5547
5548 (dolist (marks marked-lists)
5549 (setq mark (car marks)
5550 mark-type (gnus-article-mark-to-type mark)
5551 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5552
5553 ;; We set the variable according to the type of the marks list,
5554 ;; and then adjust the marks to a subset of the active articles.
5555 (cond
5556 ;; Adjust "simple" lists - compressed yet unsorted
5557 ((eq mark-type 'list)
5558 ;; Simultaneously uncompress and clip to active range
5559 ;; See gnus-uncompress-range for a description of possible marks
5560 (let (l lh)
5561 (if (not (cadr marks))
5562 (set var nil)
5563 (setq articles (if (numberp (cddr marks))
5564 (list (cdr marks))
5565 (cdr marks))
5566 lh (cons nil nil)
5567 l lh)
5568
5569 (while (setq article (pop articles))
5570 (cond ((consp article)
5571 (setq bgn (max (car article) min)
5572 end (min (cdr article) max))
5573 (while (<= bgn end)
5574 (setq l (setcdr l (cons bgn nil))
5575 bgn (1+ bgn))))
5576 ((and (<= min article)
5577 (>= max article))
5578 (setq l (setcdr l (cons article nil))))))
5579 (set var (cdr lh)))))
5580 ;; Adjust assocs.
5581 ((eq mark-type 'tuple)
5582 (set var (setq articles (cdr marks)))
5583 (when (not (listp (cdr (symbol-value var))))
5584 (set var (list (symbol-value var))))
5585 (when (not (listp (cdr articles)))
5586 (setq articles (list articles)))
5587 (while articles
5588 (when (or (not (consp (setq article (pop articles))))
5589 (< (car article) min)
5590 (> (car article) max))
5591 (set var (delq article (symbol-value var))))))
5592 ;; Adjust ranges (sloppily).
5593 ((eq mark-type 'range)
5594 (cond
5595 ((eq mark 'seen)
5596 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5597 ;; It should be (seen (NUM1 . NUM2)).
5598 (when (numberp (cddr marks))
5599 (setcdr marks (list (cdr marks))))
5600 (setq articles (cdr marks))
5601 (while (and articles
5602 (or (and (consp (car articles))
5603 (> min (cdar articles)))
5604 (and (numberp (car articles))
5605 (> min (car articles)))))
5606 (pop articles))
5607 (set var articles))))))))
5608
5609 (defun gnus-update-missing-marks (missing)
5610 "Go through the list of MISSING articles and remove them from the mark lists."
5611 (when missing
5612 (let (var m)
5613 ;; Go through all types.
5614 (dolist (elem gnus-article-mark-lists)
5615 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5616 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5617 (when (symbol-value var)
5618 ;; This list has articles. So we delete all missing
5619 ;; articles from it.
5620 (setq m missing)
5621 (while m
5622 (set var (delq (pop m) (symbol-value var))))))))))
5623
5624 (defun gnus-update-marks ()
5625 "Enter the various lists of marked articles into the newsgroup info list."
5626 (let ((types gnus-article-mark-lists)
5627 (info (gnus-get-info gnus-newsgroup-name))
5628 type list newmarked symbol delta-marks)
5629 (when info
5630 ;; Add all marks lists to the list of marks lists.
5631 (while (setq type (pop types))
5632 (setq list (symbol-value
5633 (setq symbol
5634 (intern (format "gnus-newsgroup-%s" (car type))))))
5635
5636 (when list
5637 ;; Get rid of the entries of the articles that have the
5638 ;; default score.
5639 (when (and (eq (cdr type) 'score)
5640 gnus-save-score
5641 list)
5642 (let* ((arts list)
5643 (prev (cons nil list))
5644 (all prev))
5645 (while arts
5646 (if (or (not (consp (car arts)))
5647 (= (cdar arts) gnus-summary-default-score))
5648 (setcdr prev (cdr arts))
5649 (setq prev arts))
5650 (setq arts (cdr arts)))
5651 (setq list (cdr all)))))
5652
5653 (when (eq (cdr type) 'seen)
5654 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5655
5656 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5657 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5658
5659 (when (and (gnus-check-backend-function
5660 'request-set-mark gnus-newsgroup-name)
5661 (not (gnus-article-unpropagatable-p (cdr type))))
5662 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5663 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5664 (add (gnus-remove-from-range
5665 (gnus-copy-sequence list) old)))
5666 (when add
5667 (push (list add 'add (list (cdr type))) delta-marks))
5668 (when del
5669 (push (list del 'del (list (cdr type))) delta-marks))))
5670
5671 (when list
5672 (push (cons (cdr type) list) newmarked)))
5673
5674 (when delta-marks
5675 (unless (gnus-check-group gnus-newsgroup-name)
5676 (error "Can't open server for %s" gnus-newsgroup-name))
5677 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5678
5679 ;; Enter these new marks into the info of the group.
5680 (if (nthcdr 3 info)
5681 (setcar (nthcdr 3 info) newmarked)
5682 ;; Add the marks lists to the end of the info.
5683 (when newmarked
5684 (setcdr (nthcdr 2 info) (list newmarked))))
5685
5686 ;; Cut off the end of the info if there's nothing else there.
5687 (let ((i 5))
5688 (while (and (> i 2)
5689 (not (nth i info)))
5690 (when (nthcdr (decf i) info)
5691 (setcdr (nthcdr i info) nil)))))))
5692
5693 (defun gnus-set-mode-line (where)
5694 "Set the mode line of the article or summary buffers.
5695 If WHERE is `summary', the summary mode line format will be used."
5696 ;; Is this mode line one we keep updated?
5697 (when (and (memq where gnus-updated-mode-lines)
5698 (symbol-value
5699 (intern (format "gnus-%s-mode-line-format-spec" where))))
5700 (let (mode-string)
5701 (save-excursion
5702 ;; We evaluate this in the summary buffer since these
5703 ;; variables are buffer-local to that buffer.
5704 (set-buffer gnus-summary-buffer)
5705 ;; We bind all these variables that are used in the `eval' form
5706 ;; below.
5707 (let* ((mformat (symbol-value
5708 (intern
5709 (format "gnus-%s-mode-line-format-spec" where))))
5710 (gnus-tmp-group-name (gnus-group-decoded-name
5711 gnus-newsgroup-name))
5712 (gnus-tmp-article-number (or gnus-current-article 0))
5713 (gnus-tmp-unread gnus-newsgroup-unreads)
5714 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5715 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5716 (gnus-tmp-unread-and-unselected
5717 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5718 (zerop gnus-tmp-unselected))
5719 "")
5720 ((zerop gnus-tmp-unselected)
5721 (format "{%d more}" gnus-tmp-unread-and-unticked))
5722 (t (format "{%d(+%d) more}"
5723 gnus-tmp-unread-and-unticked
5724 gnus-tmp-unselected))))
5725 (gnus-tmp-subject
5726 (if (and gnus-current-headers
5727 (vectorp gnus-current-headers))
5728 (gnus-mode-string-quote
5729 (mail-header-subject gnus-current-headers))
5730 ""))
5731 bufname-length max-len
5732 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5733 (setq mode-string (eval mformat))
5734 (setq bufname-length (if (string-match "%b" mode-string)
5735 (- (length
5736 (buffer-name
5737 (if (eq where 'summary)
5738 nil
5739 (get-buffer gnus-article-buffer))))
5740 2)
5741 0))
5742 (setq max-len (max 4 (if gnus-mode-non-string-length
5743 (- (window-width)
5744 gnus-mode-non-string-length
5745 bufname-length)
5746 (length mode-string))))
5747 ;; We might have to chop a bit of the string off...
5748 (when (> (length mode-string) max-len)
5749 (setq mode-string
5750 (concat (truncate-string-to-width mode-string (- max-len 3))
5751 "...")))
5752 ;; Pad the mode string a bit.
5753 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5754 ;; Update the mode line.
5755 (setq mode-line-buffer-identification
5756 (gnus-mode-line-buffer-identification (list mode-string)))
5757 (set-buffer-modified-p t))))
5758
5759 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5760 "Go through the HEADERS list and add all Xrefs to a hash table.
5761 The resulting hash table is returned, or nil if no Xrefs were found."
5762 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5763 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5764 (xref-hashtb (gnus-make-hashtable))
5765 start group entry number xrefs header)
5766 (while headers
5767 (setq header (pop headers))
5768 (when (and (setq xrefs (mail-header-xref header))
5769 (not (memq (setq number (mail-header-number header))
5770 unreads)))
5771 (setq start 0)
5772 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5773 (setq start (match-end 0))
5774 (setq group (if prefix
5775 (concat prefix (substring xrefs (match-beginning 1)
5776 (match-end 1)))
5777 (substring xrefs (match-beginning 1) (match-end 1))))
5778 (setq number
5779 (string-to-number (substring xrefs (match-beginning 2)
5780 (match-end 2))))
5781 (if (setq entry (gnus-gethash group xref-hashtb))
5782 (setcdr entry (cons number (cdr entry)))
5783 (gnus-sethash group (cons number nil) xref-hashtb)))))
5784 (and start xref-hashtb)))
5785
5786 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5787 "Look through all the headers and mark the Xrefs as read."
5788 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5789 name entry info xref-hashtb idlist method nth4)
5790 (save-excursion
5791 (set-buffer gnus-group-buffer)
5792 (when (setq xref-hashtb
5793 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5794 (mapatoms
5795 (lambda (group)
5796 (unless (string= from-newsgroup (setq name (symbol-name group)))
5797 (setq idlist (symbol-value group))
5798 ;; Dead groups are not updated.
5799 (and (prog1
5800 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5801 info (nth 2 entry))
5802 (when (stringp (setq nth4 (gnus-info-method info)))
5803 (setq nth4 (gnus-server-to-method nth4))))
5804 ;; Only do the xrefs if the group has the same
5805 ;; select method as the group we have just read.
5806 (or (gnus-methods-equal-p
5807 nth4 (gnus-find-method-for-group from-newsgroup))
5808 virtual
5809 (equal nth4 (setq method (gnus-find-method-for-group
5810 from-newsgroup)))
5811 (and (equal (car nth4) (car method))
5812 (equal (nth 1 nth4) (nth 1 method))))
5813 gnus-use-cross-reference
5814 (or (not (eq gnus-use-cross-reference t))
5815 virtual
5816 ;; Only do cross-references on subscribed
5817 ;; groups, if that is what is wanted.
5818 (<= (gnus-info-level info) gnus-level-subscribed))
5819 (gnus-group-make-articles-read name idlist))))
5820 xref-hashtb)))))
5821
5822 (defun gnus-compute-read-articles (group articles)
5823 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5824 (info (nth 2 entry))
5825 (active (gnus-active group))
5826 ninfo)
5827 (when entry
5828 ;; First peel off all invalid article numbers.
5829 (when active
5830 (let ((ids articles)
5831 id first)
5832 (while (setq id (pop ids))
5833 (when (and first (> id (cdr active)))
5834 ;; We'll end up in this situation in one particular
5835 ;; obscure situation. If you re-scan a group and get
5836 ;; a new article that is cross-posted to a different
5837 ;; group that has not been re-scanned, you might get
5838 ;; crossposted article that has a higher number than
5839 ;; Gnus believes possible. So we re-activate this
5840 ;; group as well. This might mean doing the
5841 ;; crossposting thingy will *increase* the number
5842 ;; of articles in some groups. Tsk, tsk.
5843 (setq active (or (gnus-activate-group group) active)))
5844 (when (or (> id (cdr active))
5845 (< id (car active)))
5846 (setq articles (delq id articles))))))
5847 ;; If the read list is nil, we init it.
5848 (if (and active
5849 (null (gnus-info-read info))
5850 (> (car active) 1))
5851 (setq ninfo (cons 1 (1- (car active))))
5852 (setq ninfo (gnus-info-read info)))
5853 ;; Then we add the read articles to the range.
5854 (gnus-add-to-range
5855 ninfo (setq articles (sort articles '<))))))
5856
5857 (defun gnus-group-make-articles-read (group articles)
5858 "Update the info of GROUP to say that ARTICLES are read."
5859 (let* ((num 0)
5860 (entry (gnus-gethash group gnus-newsrc-hashtb))
5861 (info (nth 2 entry))
5862 (active (gnus-active group))
5863 range)
5864 (when entry
5865 (setq range (gnus-compute-read-articles group articles))
5866 (save-excursion
5867 (set-buffer gnus-group-buffer)
5868 (gnus-undo-register
5869 `(progn
5870 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5871 (gnus-info-set-read ',info ',(gnus-info-read info))
5872 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5873 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5874 (gnus-group-update-group ,group t))))
5875 ;; Add the read articles to the range.
5876 (gnus-info-set-read info range)
5877 (gnus-request-set-mark group (list (list range 'add '(read))))
5878 ;; Then we have to re-compute how many unread
5879 ;; articles there are in this group.
5880 (when active
5881 (cond
5882 ((not range)
5883 (setq num (- (1+ (cdr active)) (car active))))
5884 ((not (listp (cdr range)))
5885 (setq num (- (cdr active) (- (1+ (cdr range))
5886 (car range)))))
5887 (t
5888 (while range
5889 (if (numberp (car range))
5890 (setq num (1+ num))
5891 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5892 (setq range (cdr range)))
5893 (setq num (- (cdr active) num))))
5894 ;; Update the number of unread articles.
5895 (setcar entry num)
5896 ;; Update the group buffer.
5897 (unless (gnus-ephemeral-group-p group)
5898 (gnus-group-update-group group t))))))
5899
5900 (defvar gnus-newsgroup-none-id 0)
5901
5902 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5903 (let ((cur nntp-server-buffer)
5904 (dependencies
5905 (or dependencies
5906 (save-excursion (set-buffer gnus-summary-buffer)
5907 gnus-newsgroup-dependencies)))
5908 headers id end ref
5909 (mail-parse-charset gnus-newsgroup-charset)
5910 (mail-parse-ignored-charsets
5911 (save-excursion (condition-case nil
5912 (set-buffer gnus-summary-buffer)
5913 (error))
5914 gnus-newsgroup-ignored-charsets)))
5915 (save-excursion
5916 (set-buffer nntp-server-buffer)
5917 ;; Translate all TAB characters into SPACE characters.
5918 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5919 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5920 (ietf-drums-unfold-fws)
5921 (gnus-run-hooks 'gnus-parse-headers-hook)
5922 (let ((case-fold-search t)
5923 in-reply-to header p lines chars)
5924 (goto-char (point-min))
5925 ;; Search to the beginning of the next header. Error messages
5926 ;; do not begin with 2 or 3.
5927 (while (re-search-forward "^[23][0-9]+ " nil t)
5928 (setq id nil
5929 ref nil)
5930 ;; This implementation of this function, with nine
5931 ;; search-forwards instead of the one re-search-forward and
5932 ;; a case (which basically was the old function) is actually
5933 ;; about twice as fast, even though it looks messier. You
5934 ;; can't have everything, I guess. Speed and elegance
5935 ;; doesn't always go hand in hand.
5936 (setq
5937 header
5938 (vector
5939 ;; Number.
5940 (prog1
5941 (read cur)
5942 (end-of-line)
5943 (setq p (point))
5944 (narrow-to-region (point)
5945 (or (and (search-forward "\n.\n" nil t)
5946 (- (point) 2))
5947 (point))))
5948 ;; Subject.
5949 (progn
5950 (goto-char p)
5951 (if (search-forward "\nsubject:" nil t)
5952 (funcall gnus-decode-encoded-word-function
5953 (nnheader-header-value))
5954 "(none)"))
5955 ;; From.
5956 (progn
5957 (goto-char p)
5958 (if (search-forward "\nfrom:" nil t)
5959 (funcall gnus-decode-encoded-word-function
5960 (nnheader-header-value))
5961 "(nobody)"))
5962 ;; Date.
5963 (progn
5964 (goto-char p)
5965 (if (search-forward "\ndate:" nil t)
5966 (nnheader-header-value) ""))
5967 ;; Message-ID.
5968 (progn
5969 (goto-char p)
5970 (setq id (if (re-search-forward
5971 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5972 ;; We do it this way to make sure the Message-ID
5973 ;; is (somewhat) syntactically valid.
5974 (buffer-substring (match-beginning 1)
5975 (match-end 1))
5976 ;; If there was no message-id, we just fake one
5977 ;; to make subsequent routines simpler.
5978 (nnheader-generate-fake-message-id))))
5979 ;; References.
5980 (progn
5981 (goto-char p)
5982 (if (search-forward "\nreferences:" nil t)
5983 (progn
5984 (setq end (point))
5985 (prog1
5986 (nnheader-header-value)
5987 (setq ref
5988 (buffer-substring
5989 (progn
5990 (end-of-line)
5991 (search-backward ">" end t)
5992 (1+ (point)))
5993 (progn
5994 (search-backward "<" end t)
5995 (point))))))
5996 ;; Get the references from the in-reply-to header if there
5997 ;; were no references and the in-reply-to header looks
5998 ;; promising.
5999 (if (and (search-forward "\nin-reply-to:" nil t)
6000 (setq in-reply-to (nnheader-header-value))
6001 (string-match "<[^>]+>" in-reply-to))
6002 (let (ref2)
6003 (setq ref (substring in-reply-to (match-beginning 0)
6004 (match-end 0)))
6005 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6006 (setq ref2 (substring in-reply-to (match-beginning 0)
6007 (match-end 0)))
6008 (when (> (length ref2) (length ref))
6009 (setq ref ref2)))
6010 ref)
6011 (setq ref nil))))
6012 ;; Chars.
6013 (progn
6014 (goto-char p)
6015 (if (search-forward "\nchars: " nil t)
6016 (if (numberp (setq chars (ignore-errors (read cur))))
6017 chars -1)
6018 -1))
6019 ;; Lines.
6020 (progn
6021 (goto-char p)
6022 (if (search-forward "\nlines: " nil t)
6023 (if (numberp (setq lines (ignore-errors (read cur))))
6024 lines -1)
6025 -1))
6026 ;; Xref.
6027 (progn
6028 (goto-char p)
6029 (and (search-forward "\nxref:" nil t)
6030 (nnheader-header-value)))
6031 ;; Extra.
6032 (when gnus-extra-headers
6033 (let ((extra gnus-extra-headers)
6034 out)
6035 (while extra
6036 (goto-char p)
6037 (when (search-forward
6038 (concat "\n" (symbol-name (car extra)) ":") nil t)
6039 (push (cons (car extra) (nnheader-header-value))
6040 out))
6041 (pop extra))
6042 out))))
6043 (when (equal id ref)
6044 (setq ref nil))
6045
6046 (when gnus-alter-header-function
6047 (funcall gnus-alter-header-function header)
6048 (setq id (mail-header-id header)
6049 ref (gnus-parent-id (mail-header-references header))))
6050
6051 (when (setq header
6052 (gnus-dependencies-add-header
6053 header dependencies force-new))
6054 (push header headers))
6055 (goto-char (point-max))
6056 (widen))
6057 (nreverse headers)))))
6058
6059 ;; Goes through the xover lines and returns a list of vectors
6060 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6061 force-new dependencies
6062 group also-fetch-heads)
6063 "Parse the news overview data in the server buffer.
6064 Return a list of headers that match SEQUENCE (see
6065 `nntp-retrieve-headers')."
6066 ;; Get the Xref when the users reads the articles since most/some
6067 ;; NNTP servers do not include Xrefs when using XOVER.
6068 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6069 (let ((mail-parse-charset gnus-newsgroup-charset)
6070 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6071 (cur nntp-server-buffer)
6072 (dependencies (or dependencies gnus-newsgroup-dependencies))
6073 (allp (cond
6074 ((eq gnus-read-all-available-headers t)
6075 t)
6076 ((and (stringp gnus-read-all-available-headers)
6077 group)
6078 (string-match gnus-read-all-available-headers group))
6079 (t
6080 nil)))
6081 number headers header)
6082 (save-excursion
6083 (set-buffer nntp-server-buffer)
6084 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6085 ;; Allow the user to mangle the headers before parsing them.
6086 (gnus-run-hooks 'gnus-parse-headers-hook)
6087 (goto-char (point-min))
6088 (gnus-parse-without-error
6089 (while (and (or sequence allp)
6090 (not (eobp)))
6091 (setq number (read cur))
6092 (when (not allp)
6093 (while (and sequence
6094 (< (car sequence) number))
6095 (setq sequence (cdr sequence))))
6096 (when (and (or allp
6097 (and sequence
6098 (eq number (car sequence))))
6099 (progn
6100 (setq sequence (cdr sequence))
6101 (setq header (inline
6102 (gnus-nov-parse-line
6103 number dependencies force-new)))))
6104 (push header headers))
6105 (forward-line 1)))
6106 ;; A common bug in inn is that if you have posted an article and
6107 ;; then retrieves the active file, it will answer correctly --
6108 ;; the new article is included. However, a NOV entry for the
6109 ;; article may not have been generated yet, so this may fail.
6110 ;; We work around this problem by retrieving the last few
6111 ;; headers using HEAD.
6112 (if (or (not also-fetch-heads)
6113 (not sequence))
6114 ;; We (probably) got all the headers.
6115 (nreverse headers)
6116 (let ((gnus-nov-is-evil t))
6117 (nconc
6118 (nreverse headers)
6119 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6120 (gnus-get-newsgroup-headers))))))))
6121
6122 (defun gnus-article-get-xrefs ()
6123 "Fill in the Xref value in `gnus-current-headers', if necessary.
6124 This is meant to be called in `gnus-article-internal-prepare-hook'."
6125 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6126 gnus-current-headers)))
6127 (or (not gnus-use-cross-reference)
6128 (not headers)
6129 (and (mail-header-xref headers)
6130 (not (string= (mail-header-xref headers) "")))
6131 (let ((case-fold-search t)
6132 xref)
6133 (save-restriction
6134 (nnheader-narrow-to-headers)
6135 (goto-char (point-min))
6136 (when (or (and (not (eobp))
6137 (eq (downcase (char-after)) ?x)
6138 (looking-at "Xref:"))
6139 (search-forward "\nXref:" nil t))
6140 (goto-char (1+ (match-end 0)))
6141 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6142 (mail-header-set-xref headers xref)))))))
6143
6144 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6145 "Find article ID and insert the summary line for that article.
6146 OLD-HEADER can either be a header or a line number to insert
6147 the subject line on."
6148 (let* ((line (and (numberp old-header) old-header))
6149 (old-header (and (vectorp old-header) old-header))
6150 (header (cond ((and old-header use-old-header)
6151 old-header)
6152 ((and (numberp id)
6153 (gnus-number-to-header id))
6154 (gnus-number-to-header id))
6155 (t
6156 (gnus-read-header id))))
6157 (number (and (numberp id) id))
6158 d)
6159 (when header
6160 ;; Rebuild the thread that this article is part of and go to the
6161 ;; article we have fetched.
6162 (when (and (not gnus-show-threads)
6163 old-header)
6164 (when (and number
6165 (setq d (gnus-data-find (mail-header-number old-header))))
6166 (goto-char (gnus-data-pos d))
6167 (gnus-data-remove
6168 number
6169 (- (gnus-point-at-bol)
6170 (prog1
6171 (1+ (gnus-point-at-eol))
6172 (gnus-delete-line))))))
6173 ;; Remove list identifiers from subject.
6174 (when gnus-list-identifiers
6175 (let ((gnus-newsgroup-headers (list header)))
6176 (gnus-summary-remove-list-identifiers)))
6177 (when old-header
6178 (mail-header-set-number header (mail-header-number old-header)))
6179 (setq gnus-newsgroup-sparse
6180 (delq (setq number (mail-header-number header))
6181 gnus-newsgroup-sparse))
6182 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6183 (push number gnus-newsgroup-limit)
6184 (gnus-rebuild-thread (mail-header-id header) line)
6185 (gnus-summary-goto-subject number nil t))
6186 (when (and (numberp number)
6187 (> number 0))
6188 ;; We have to update the boundaries even if we can't fetch the
6189 ;; article if ID is a number -- so that the next `P' or `N'
6190 ;; command will fetch the previous (or next) article even
6191 ;; if the one we tried to fetch this time has been canceled.
6192 (when (> number gnus-newsgroup-end)
6193 (setq gnus-newsgroup-end number))
6194 (when (< number gnus-newsgroup-begin)
6195 (setq gnus-newsgroup-begin number))
6196 (setq gnus-newsgroup-unselected
6197 (delq number gnus-newsgroup-unselected)))
6198 ;; Report back a success?
6199 (and header (mail-header-number header))))
6200
6201 ;;; Process/prefix in the summary buffer
6202
6203 (defun gnus-summary-work-articles (n)
6204 "Return a list of articles to be worked upon.
6205 The prefix argument, the list of process marked articles, and the
6206 current article will be taken into consideration."
6207 (save-excursion
6208 (set-buffer gnus-summary-buffer)
6209 (cond
6210 (n
6211 ;; A numerical prefix has been given.
6212 (setq n (prefix-numeric-value n))
6213 (let ((backward (< n 0))
6214 (n (abs (prefix-numeric-value n)))
6215 articles article)
6216 (save-excursion
6217 (while
6218 (and (> n 0)
6219 (push (setq article (gnus-summary-article-number))
6220 articles)
6221 (if backward
6222 (gnus-summary-find-prev nil article)
6223 (gnus-summary-find-next nil article)))
6224 (decf n)))
6225 (nreverse articles)))
6226 ((and (gnus-region-active-p) (mark))
6227 (message "region active")
6228 ;; Work on the region between point and mark.
6229 (let ((max (max (point) (mark)))
6230 articles article)
6231 (save-excursion
6232 (goto-char (min (point) (mark)))
6233 (while
6234 (and
6235 (push (setq article (gnus-summary-article-number)) articles)
6236 (gnus-summary-find-next nil article)
6237 (< (point) max)))
6238 (nreverse articles))))
6239 (gnus-newsgroup-processable
6240 ;; There are process-marked articles present.
6241 ;; Save current state.
6242 (gnus-summary-save-process-mark)
6243 ;; Return the list.
6244 (reverse gnus-newsgroup-processable))
6245 (t
6246 ;; Just return the current article.
6247 (list (gnus-summary-article-number))))))
6248
6249 (defmacro gnus-summary-iterate (arg &rest forms)
6250 "Iterate over the process/prefixed articles and do FORMS.
6251 ARG is the interactive prefix given to the command. FORMS will be
6252 executed with point over the summary line of the articles."
6253 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6254 `(let ((,articles (gnus-summary-work-articles ,arg)))
6255 (while ,articles
6256 (gnus-summary-goto-subject (car ,articles))
6257 ,@forms
6258 (pop ,articles)))))
6259
6260 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6261 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6262
6263 (defun gnus-summary-save-process-mark ()
6264 "Push the current set of process marked articles on the stack."
6265 (interactive)
6266 (push (copy-sequence gnus-newsgroup-processable)
6267 gnus-newsgroup-process-stack))
6268
6269 (defun gnus-summary-kill-process-mark ()
6270 "Push the current set of process marked articles on the stack and unmark."
6271 (interactive)
6272 (gnus-summary-save-process-mark)
6273 (gnus-summary-unmark-all-processable))
6274
6275 (defun gnus-summary-yank-process-mark ()
6276 "Pop the last process mark state off the stack and restore it."
6277 (interactive)
6278 (unless gnus-newsgroup-process-stack
6279 (error "Empty mark stack"))
6280 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6281
6282 (defun gnus-summary-process-mark-set (set)
6283 "Make SET into the current process marked articles."
6284 (gnus-summary-unmark-all-processable)
6285 (while set
6286 (gnus-summary-set-process-mark (pop set))))
6287
6288 ;;; Searching and stuff
6289
6290 (defun gnus-summary-search-group (&optional backward use-level)
6291 "Search for next unread newsgroup.
6292 If optional argument BACKWARD is non-nil, search backward instead."
6293 (save-excursion
6294 (set-buffer gnus-group-buffer)
6295 (when (gnus-group-search-forward
6296 backward nil (if use-level (gnus-group-group-level) nil))
6297 (gnus-group-group-name))))
6298
6299 (defun gnus-summary-best-group (&optional exclude-group)
6300 "Find the name of the best unread group.
6301 If EXCLUDE-GROUP, do not go to this group."
6302 (save-excursion
6303 (set-buffer gnus-group-buffer)
6304 (save-excursion
6305 (gnus-group-best-unread-group exclude-group))))
6306
6307 (defun gnus-summary-find-next (&optional unread article backward)
6308 (if backward
6309 (gnus-summary-find-prev unread article)
6310 (let* ((dummy (gnus-summary-article-intangible-p))
6311 (article (or article (gnus-summary-article-number)))
6312 (data (gnus-data-find-list article))
6313 result)
6314 (when (and (not dummy)
6315 (or (not gnus-summary-check-current)
6316 (not unread)
6317 (not (gnus-data-unread-p (car data)))))
6318 (setq data (cdr data)))
6319 (when (setq result
6320 (if unread
6321 (progn
6322 (while data
6323 (unless (memq (gnus-data-number (car data))
6324 (cond
6325 ((eq gnus-auto-goto-ignores
6326 'always-undownloaded)
6327 gnus-newsgroup-undownloaded)
6328 (gnus-plugged
6329 nil)
6330 ((eq gnus-auto-goto-ignores
6331 'unfetched)
6332 gnus-newsgroup-unfetched)
6333 ((eq gnus-auto-goto-ignores
6334 'undownloaded)
6335 gnus-newsgroup-undownloaded)))
6336 (when (gnus-data-unread-p (car data))
6337 (setq result (car data)
6338 data nil)))
6339 (setq data (cdr data)))
6340 result)
6341 (car data)))
6342 (goto-char (gnus-data-pos result))
6343 (gnus-data-number result)))))
6344
6345 (defun gnus-summary-find-prev (&optional unread article)
6346 (let* ((eobp (eobp))
6347 (article (or article (gnus-summary-article-number)))
6348 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6349 result)
6350 (when (and (not eobp)
6351 (or (not gnus-summary-check-current)
6352 (not unread)
6353 (not (gnus-data-unread-p (car data)))))
6354 (setq data (cdr data)))
6355 (when (setq result
6356 (if unread
6357 (progn
6358 (while data
6359 (unless (memq (gnus-data-number (car data))
6360 (cond
6361 ((eq gnus-auto-goto-ignores
6362 'always-undownloaded)
6363 gnus-newsgroup-undownloaded)
6364 (gnus-plugged
6365 nil)
6366 ((eq gnus-auto-goto-ignores
6367 'unfetched)
6368 gnus-newsgroup-unfetched)
6369 ((eq gnus-auto-goto-ignores
6370 'undownloaded)
6371 gnus-newsgroup-undownloaded)))
6372 (when (gnus-data-unread-p (car data))
6373 (setq result (car data)
6374 data nil)))
6375 (setq data (cdr data)))
6376 result)
6377 (car data)))
6378 (goto-char (gnus-data-pos result))
6379 (gnus-data-number result))))
6380
6381 (defun gnus-summary-find-subject (subject &optional unread backward article)
6382 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6383 (article (or article (gnus-summary-article-number)))
6384 (articles (gnus-data-list backward))
6385 (arts (gnus-data-find-list article articles))
6386 result)
6387 (when (or (not gnus-summary-check-current)
6388 (not unread)
6389 (not (gnus-data-unread-p (car arts))))
6390 (setq arts (cdr arts)))
6391 (while arts
6392 (and (or (not unread)
6393 (gnus-data-unread-p (car arts)))
6394 (vectorp (gnus-data-header (car arts)))
6395 (gnus-subject-equal
6396 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6397 (setq result (car arts)
6398 arts nil))
6399 (setq arts (cdr arts)))
6400 (and result
6401 (goto-char (gnus-data-pos result))
6402 (gnus-data-number result))))
6403
6404 (defun gnus-summary-search-forward (&optional unread subject backward)
6405 "Search forward for an article.
6406 If UNREAD, look for unread articles. If SUBJECT, look for
6407 articles with that subject. If BACKWARD, search backward instead."
6408 (cond (subject (gnus-summary-find-subject subject unread backward))
6409 (backward (gnus-summary-find-prev unread))
6410 (t (gnus-summary-find-next unread))))
6411
6412 (defun gnus-recenter (&optional n)
6413 "Center point in window and redisplay frame.
6414 Also do horizontal recentering."
6415 (interactive "P")
6416 (when (and gnus-auto-center-summary
6417 (not (eq gnus-auto-center-summary 'vertical)))
6418 (gnus-horizontal-recenter))
6419 (recenter n))
6420
6421 (defun gnus-summary-recenter ()
6422 "Center point in the summary window.
6423 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6424 displayed, no centering will be performed."
6425 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6426 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6427 (interactive)
6428 ;; The user has to want it.
6429 (when gnus-auto-center-summary
6430 (let* ((top (cond ((< (window-height) 4) 0)
6431 ((< (window-height) 7) 1)
6432 (t (if (numberp gnus-auto-center-summary)
6433 gnus-auto-center-summary
6434 2))))
6435 (height (1- (window-height)))
6436 (bottom (save-excursion (goto-char (point-max))
6437 (forward-line (- height))
6438 (point)))
6439 (window (get-buffer-window (current-buffer))))
6440 (when (get-buffer-window gnus-article-buffer)
6441 ;; Only do recentering when the article buffer is displayed,
6442 ;; Set the window start to either `bottom', which is the biggest
6443 ;; possible valid number, or the second line from the top,
6444 ;; whichever is the least.
6445 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6446 (if (> bottom top-pos)
6447 ;; Keep the second line from the top visible
6448 (set-window-start window top-pos t)
6449 ;; Try to keep the bottom line visible; if it's partially
6450 ;; obscured, either scroll one more line to make it fully
6451 ;; visible, or revert to using TOP-POS.
6452 (save-excursion
6453 (goto-char (point-max))
6454 (forward-line -1)
6455 (let ((last-line-start (point)))
6456 (goto-char bottom)
6457 (set-window-start window (point) t)
6458 (when (not (pos-visible-in-window-p last-line-start window))
6459 (forward-line 1)
6460 (set-window-start window (min (point) top-pos) t)))))))
6461 ;; Do horizontal recentering while we're at it.
6462 (when (and (get-buffer-window (current-buffer) t)
6463 (not (eq gnus-auto-center-summary 'vertical)))
6464 (let ((selected (selected-window)))
6465 (select-window (get-buffer-window (current-buffer) t))
6466 (gnus-summary-position-point)
6467 (gnus-horizontal-recenter)
6468 (select-window selected))))))
6469
6470 (defun gnus-summary-jump-to-group (newsgroup)
6471 "Move point to NEWSGROUP in group mode buffer."
6472 ;; Keep update point of group mode buffer if visible.
6473 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6474 (save-window-excursion
6475 ;; Take care of tree window mode.
6476 (when (get-buffer-window gnus-group-buffer)
6477 (pop-to-buffer gnus-group-buffer))
6478 (gnus-group-jump-to-group newsgroup))
6479 (save-excursion
6480 ;; Take care of tree window mode.
6481 (if (get-buffer-window gnus-group-buffer)
6482 (pop-to-buffer gnus-group-buffer)
6483 (set-buffer gnus-group-buffer))
6484 (gnus-group-jump-to-group newsgroup))))
6485
6486 ;; This function returns a list of article numbers based on the
6487 ;; difference between the ranges of read articles in this group and
6488 ;; the range of active articles.
6489 (defun gnus-list-of-unread-articles (group)
6490 (let* ((read (gnus-info-read (gnus-get-info group)))
6491 (active (or (gnus-active group) (gnus-activate-group group)))
6492 (last (cdr active))
6493 first nlast unread)
6494 ;; If none are read, then all are unread.
6495 (if (not read)
6496 (setq first (car active))
6497 ;; If the range of read articles is a single range, then the
6498 ;; first unread article is the article after the last read
6499 ;; article. Sounds logical, doesn't it?
6500 (if (and (not (listp (cdr read)))
6501 (or (< (car read) (car active))
6502 (progn (setq read (list read))
6503 nil)))
6504 (setq first (max (car active) (1+ (cdr read))))
6505 ;; `read' is a list of ranges.
6506 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6507 (caar read)))
6508 1)
6509 (setq first (car active)))
6510 (while read
6511 (when first
6512 (while (< first nlast)
6513 (setq unread (cons first unread)
6514 first (1+ first))))
6515 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6516 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6517 (setq read (cdr read)))))
6518 ;; And add the last unread articles.
6519 (while (<= first last)
6520 (setq unread (cons first unread)
6521 first (1+ first)))
6522 ;; Return the list of unread articles.
6523 (delq 0 (nreverse unread))))
6524
6525 (defun gnus-list-of-read-articles (group)
6526 "Return a list of unread, unticked and non-dormant articles."
6527 (let* ((info (gnus-get-info group))
6528 (marked (gnus-info-marks info))
6529 (active (gnus-active group)))
6530 (and info active
6531 (gnus-list-range-difference
6532 (gnus-list-range-difference
6533 (gnus-sorted-complement
6534 (gnus-uncompress-range active)
6535 (gnus-list-of-unread-articles group))
6536 (cdr (assq 'dormant marked)))
6537 (cdr (assq 'tick marked))))))
6538
6539 ;; This function returns a sequence of article numbers based on the
6540 ;; difference between the ranges of read articles in this group and
6541 ;; the range of active articles.
6542 (defun gnus-sequence-of-unread-articles (group)
6543 (let* ((read (gnus-info-read (gnus-get-info group)))
6544 (active (or (gnus-active group) (gnus-activate-group group)))
6545 (last (cdr active))
6546 first nlast unread)
6547 ;; If none are read, then all are unread.
6548 (if (not read)
6549 (setq first (car active))
6550 ;; If the range of read articles is a single range, then the
6551 ;; first unread article is the article after the last read
6552 ;; article. Sounds logical, doesn't it?
6553 (if (and (not (listp (cdr read)))
6554 (or (< (car read) (car active))
6555 (progn (setq read (list read))
6556 nil)))
6557 (setq first (max (car active) (1+ (cdr read))))
6558 ;; `read' is a list of ranges.
6559 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6560 (caar read)))
6561 1)
6562 (setq first (car active)))
6563 (while read
6564 (when first
6565 (push (cons first nlast) unread))
6566 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6567 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6568 (setq read (cdr read)))))
6569 ;; And add the last unread articles.
6570 (cond ((not (and first last))
6571 nil)
6572 ((< first last)
6573 (push (cons first last) unread))
6574 ((= first last)
6575 (push first unread)))
6576 ;; Return the sequence of unread articles.
6577 (delq 0 (nreverse unread))))
6578
6579 ;; Various summary commands
6580
6581 (defun gnus-summary-select-article-buffer ()
6582 "Reconfigure windows to show article buffer."
6583 (interactive)
6584 (if (not (gnus-buffer-live-p gnus-article-buffer))
6585 (error "There is no article buffer for this summary buffer")
6586 (gnus-configure-windows 'article)
6587 (select-window (get-buffer-window gnus-article-buffer))))
6588
6589 (defun gnus-summary-universal-argument (arg)
6590 "Perform any operation on all articles that are process/prefixed."
6591 (interactive "P")
6592 (let ((articles (gnus-summary-work-articles arg))
6593 func article)
6594 (if (eq
6595 (setq
6596 func
6597 (key-binding
6598 (read-key-sequence
6599 (substitute-command-keys
6600 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6601 'undefined)
6602 (gnus-error 1 "Undefined key")
6603 (save-excursion
6604 (while articles
6605 (gnus-summary-goto-subject (setq article (pop articles)))
6606 (let (gnus-newsgroup-processable)
6607 (command-execute func))
6608 (gnus-summary-remove-process-mark article)))))
6609 (gnus-summary-position-point))
6610
6611 (defun gnus-summary-toggle-truncation (&optional arg)
6612 "Toggle truncation of summary lines.
6613 With ARG, turn line truncation on if ARG is positive."
6614 (interactive "P")
6615 (setq truncate-lines
6616 (if (null arg) (not truncate-lines)
6617 (> (prefix-numeric-value arg) 0)))
6618 (redraw-display))
6619
6620 (defun gnus-summary-find-for-reselect ()
6621 "Return the number of an article to stay on across a reselect.
6622 The current article is considered, then following articles, then previous
6623 articles. An article is sought which is not cancelled and isn't a temporary
6624 insertion from another group. If there's no such then return a dummy 0."
6625 (let (found)
6626 (dolist (rev '(nil t))
6627 (unless found ; don't demand the reverse list if we don't need it
6628 (let ((data (gnus-data-find-list
6629 (gnus-summary-article-number) (gnus-data-list rev))))
6630 (while (and data (not found))
6631 (if (and (< 0 (gnus-data-number (car data)))
6632 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6633 (setq found (gnus-data-number (car data))))
6634 (setq data (cdr data))))))
6635 (or found 0)))
6636
6637 (defun gnus-summary-reselect-current-group (&optional all rescan)
6638 "Exit and then reselect the current newsgroup.
6639 The prefix argument ALL means to select all articles."
6640 (interactive "P")
6641 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6642 (error "Ephemeral groups can't be reselected"))
6643 (let ((current-subject (gnus-summary-find-for-reselect))
6644 (group gnus-newsgroup-name))
6645 (setq gnus-newsgroup-begin nil)
6646 (gnus-summary-exit nil 'leave-hidden)
6647 ;; We have to adjust the point of group mode buffer because
6648 ;; point was moved to the next unread newsgroup by exiting.
6649 (gnus-summary-jump-to-group group)
6650 (when rescan
6651 (save-excursion
6652 (gnus-group-get-new-news-this-group 1)))
6653 (gnus-group-read-group all t)
6654 (gnus-summary-goto-subject current-subject nil t)))
6655
6656 (defun gnus-summary-rescan-group (&optional all)
6657 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6658 (interactive "P")
6659 (gnus-summary-reselect-current-group all t))
6660
6661 (defun gnus-summary-update-info (&optional non-destructive)
6662 (save-excursion
6663 (let ((group gnus-newsgroup-name))
6664 (when group
6665 (when gnus-newsgroup-kill-headers
6666 (setq gnus-newsgroup-killed
6667 (gnus-compress-sequence
6668 (gnus-sorted-union
6669 (gnus-list-range-intersection
6670 gnus-newsgroup-unselected gnus-newsgroup-killed)
6671 gnus-newsgroup-unreads)
6672 t)))
6673 (unless (listp (cdr gnus-newsgroup-killed))
6674 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6675 (let ((headers gnus-newsgroup-headers))
6676 ;; Set the new ranges of read articles.
6677 (save-excursion
6678 (set-buffer gnus-group-buffer)
6679 (gnus-undo-force-boundary))
6680 (gnus-update-read-articles
6681 group (gnus-sorted-union
6682 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6683 ;; Set the current article marks.
6684 (let ((gnus-newsgroup-scored
6685 (if (and (not gnus-save-score)
6686 (not non-destructive))
6687 nil
6688 gnus-newsgroup-scored)))
6689 (save-excursion
6690 (gnus-update-marks)))
6691 ;; Do the cross-ref thing.
6692 (when gnus-use-cross-reference
6693 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6694 ;; Do not switch windows but change the buffer to work.
6695 (set-buffer gnus-group-buffer)
6696 (unless (gnus-ephemeral-group-p group)
6697 (gnus-group-update-group group)))))))
6698
6699 (defun gnus-summary-save-newsrc (&optional force)
6700 "Save the current number of read/marked articles in the dribble buffer.
6701 The dribble buffer will then be saved.
6702 If FORCE (the prefix), also save the .newsrc file(s)."
6703 (interactive "P")
6704 (gnus-summary-update-info t)
6705 (if force
6706 (gnus-save-newsrc-file)
6707 (gnus-dribble-save)))
6708
6709 (defun gnus-summary-exit (&optional temporary leave-hidden)
6710 "Exit reading current newsgroup, and then return to group selection mode.
6711 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6712 (interactive)
6713 (gnus-set-global-variables)
6714 (when (gnus-buffer-live-p gnus-article-buffer)
6715 (save-excursion
6716 (set-buffer gnus-article-buffer)
6717 (mm-destroy-parts gnus-article-mime-handles)
6718 ;; Set it to nil for safety reason.
6719 (setq gnus-article-mime-handle-alist nil)
6720 (setq gnus-article-mime-handles nil)))
6721 (gnus-kill-save-kill-buffer)
6722 (gnus-async-halt-prefetch)
6723 (let* ((group gnus-newsgroup-name)
6724 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6725 (gnus-group-is-exiting-p t)
6726 (mode major-mode)
6727 (group-point nil)
6728 (buf (current-buffer)))
6729 (unless quit-config
6730 ;; Do adaptive scoring, and possibly save score files.
6731 (when gnus-newsgroup-adaptive
6732 (gnus-score-adaptive))
6733 (when gnus-use-scoring
6734 (gnus-score-save)))
6735 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6736 ;; If we have several article buffers, we kill them at exit.
6737 (unless gnus-single-article-buffer
6738 (gnus-kill-buffer gnus-original-article-buffer)
6739 (setq gnus-article-current nil))
6740 (when gnus-use-cache
6741 (gnus-cache-possibly-remove-articles)
6742 (gnus-cache-save-buffers))
6743 (gnus-async-prefetch-remove-group group)
6744 (when gnus-suppress-duplicates
6745 (gnus-dup-enter-articles))
6746 (when gnus-use-trees
6747 (gnus-tree-close group))
6748 (when gnus-use-cache
6749 (gnus-cache-write-active))
6750 ;; Remove entries for this group.
6751 (nnmail-purge-split-history (gnus-group-real-name group))
6752 ;; Make all changes in this group permanent.
6753 (unless quit-config
6754 (gnus-run-hooks 'gnus-exit-group-hook)
6755 (gnus-summary-update-info))
6756 (gnus-close-group group)
6757 ;; Make sure where we were, and go to next newsgroup.
6758 (set-buffer gnus-group-buffer)
6759 (unless quit-config
6760 (gnus-group-jump-to-group group))
6761 (gnus-run-hooks 'gnus-summary-exit-hook)
6762 (unless (or quit-config
6763 ;; If this group has disappeared from the summary
6764 ;; buffer, don't skip forwards.
6765 (not (string= group (gnus-group-group-name))))
6766 (gnus-group-next-unread-group 1))
6767 (setq group-point (point))
6768 (if temporary
6769 nil ;Nothing to do.
6770 ;; If we have several article buffers, we kill them at exit.
6771 (unless gnus-single-article-buffer
6772 (gnus-kill-buffer gnus-article-buffer)
6773 (gnus-kill-buffer gnus-original-article-buffer)
6774 (setq gnus-article-current nil))
6775 (set-buffer buf)
6776 (if (not gnus-kill-summary-on-exit)
6777 (progn
6778 (gnus-deaden-summary)
6779 (setq mode nil))
6780 ;; We set all buffer-local variables to nil. It is unclear why
6781 ;; this is needed, but if we don't, buffer-local variables are
6782 ;; not garbage-collected, it seems. This would the lead to en
6783 ;; ever-growing Emacs.
6784 (gnus-summary-clear-local-variables)
6785 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6786 (gnus-summary-clear-local-variables))
6787 (when (get-buffer gnus-article-buffer)
6788 (bury-buffer gnus-article-buffer))
6789 ;; We clear the global counterparts of the buffer-local
6790 ;; variables as well, just to be on the safe side.
6791 (set-buffer gnus-group-buffer)
6792 (gnus-summary-clear-local-variables)
6793 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6794 (gnus-summary-clear-local-variables))
6795 ;; Return to group mode buffer.
6796 (when (eq mode 'gnus-summary-mode)
6797 (gnus-kill-buffer buf)))
6798 (setq gnus-current-select-method gnus-select-method)
6799 (set-buffer gnus-group-buffer)
6800 (if quit-config
6801 (gnus-handle-ephemeral-exit quit-config)
6802 (goto-char group-point)
6803 ;; If gnus-group-buffer is already displayed, make sure we also move
6804 ;; the cursor in the window that displays it.
6805 (let ((win (get-buffer-window (current-buffer) 0)))
6806 (if win (set-window-point win (point))))
6807 (unless leave-hidden
6808 (gnus-configure-windows 'group 'force)))
6809 ;; Clear the current group name.
6810 (unless quit-config
6811 (setq gnus-newsgroup-name nil)))))
6812
6813 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6814 (defun gnus-summary-exit-no-update (&optional no-questions)
6815 "Quit reading current newsgroup without updating read article info."
6816 (interactive)
6817 (let* ((group gnus-newsgroup-name)
6818 (gnus-group-is-exiting-p t)
6819 (gnus-group-is-exiting-without-update-p t)
6820 (quit-config (gnus-group-quit-config group)))
6821 (when (or no-questions
6822 gnus-expert-user
6823 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6824 (gnus-async-halt-prefetch)
6825 (run-hooks 'gnus-summary-prepare-exit-hook)
6826 (when (gnus-buffer-live-p gnus-article-buffer)
6827 (save-excursion
6828 (set-buffer gnus-article-buffer)
6829 (mm-destroy-parts gnus-article-mime-handles)
6830 ;; Set it to nil for safety reason.
6831 (setq gnus-article-mime-handle-alist nil)
6832 (setq gnus-article-mime-handles nil)))
6833 ;; If we have several article buffers, we kill them at exit.
6834 (unless gnus-single-article-buffer
6835 (gnus-kill-buffer gnus-article-buffer)
6836 (gnus-kill-buffer gnus-original-article-buffer)
6837 (setq gnus-article-current nil))
6838 (if (not gnus-kill-summary-on-exit)
6839 (gnus-deaden-summary)
6840 (gnus-close-group group)
6841 (gnus-summary-clear-local-variables)
6842 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6843 (gnus-summary-clear-local-variables))
6844 (set-buffer gnus-group-buffer)
6845 (gnus-summary-clear-local-variables)
6846 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6847 (gnus-summary-clear-local-variables))
6848 (gnus-kill-buffer gnus-summary-buffer))
6849 (unless gnus-single-article-buffer
6850 (setq gnus-article-current nil))
6851 (when gnus-use-trees
6852 (gnus-tree-close group))
6853 (gnus-async-prefetch-remove-group group)
6854 (when (get-buffer gnus-article-buffer)
6855 (bury-buffer gnus-article-buffer))
6856 ;; Return to the group buffer.
6857 (gnus-configure-windows 'group 'force)
6858 ;; Clear the current group name.
6859 (setq gnus-newsgroup-name nil)
6860 (unless (gnus-ephemeral-group-p group)
6861 (gnus-group-update-group group))
6862 (when (equal (gnus-group-group-name) group)
6863 (gnus-group-next-unread-group 1))
6864 (when quit-config
6865 (gnus-handle-ephemeral-exit quit-config)))))
6866
6867 (defun gnus-handle-ephemeral-exit (quit-config)
6868 "Handle movement when leaving an ephemeral group.
6869 The state which existed when entering the ephemeral is reset."
6870 (if (not (buffer-name (car quit-config)))
6871 (gnus-configure-windows 'group 'force)
6872 (set-buffer (car quit-config))
6873 (cond ((eq major-mode 'gnus-summary-mode)
6874 (gnus-set-global-variables))
6875 ((eq major-mode 'gnus-article-mode)
6876 (save-excursion
6877 ;; The `gnus-summary-buffer' variable may point
6878 ;; to the old summary buffer when using a single
6879 ;; article buffer.
6880 (unless (gnus-buffer-live-p gnus-summary-buffer)
6881 (set-buffer gnus-group-buffer))
6882 (set-buffer gnus-summary-buffer)
6883 (gnus-set-global-variables))))
6884 (if (or (eq (cdr quit-config) 'article)
6885 (eq (cdr quit-config) 'pick))
6886 (progn
6887 ;; The current article may be from the ephemeral group
6888 ;; thus it is best that we reload this article
6889 ;;
6890 ;; If we're exiting from a large digest, this can be
6891 ;; extremely slow. So, it's better not to reload it. -- jh.
6892 ;;(gnus-summary-show-article)
6893 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6894 (gnus-configure-windows 'pick 'force)
6895 (gnus-configure-windows (cdr quit-config) 'force)))
6896 (gnus-configure-windows (cdr quit-config) 'force))
6897 (when (eq major-mode 'gnus-summary-mode)
6898 (gnus-summary-next-subject 1 nil t)
6899 (gnus-summary-recenter)
6900 (gnus-summary-position-point))))
6901
6902 ;;; Dead summaries.
6903
6904 (defvar gnus-dead-summary-mode-map nil)
6905
6906 (unless gnus-dead-summary-mode-map
6907 (setq gnus-dead-summary-mode-map (make-keymap))
6908 (suppress-keymap gnus-dead-summary-mode-map)
6909 (substitute-key-definition
6910 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6911 (dolist (key '("\C-d" "\r" "\177" [delete]))
6912 (define-key gnus-dead-summary-mode-map
6913 key 'gnus-summary-wake-up-the-dead))
6914 (dolist (key '("q" "Q"))
6915 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6916
6917 (defvar gnus-dead-summary-mode nil
6918 "Minor mode for Gnus summary buffers.")
6919
6920 (defun gnus-dead-summary-mode (&optional arg)
6921 "Minor mode for Gnus summary buffers."
6922 (interactive "P")
6923 (when (eq major-mode 'gnus-summary-mode)
6924 (make-local-variable 'gnus-dead-summary-mode)
6925 (setq gnus-dead-summary-mode
6926 (if (null arg) (not gnus-dead-summary-mode)
6927 (> (prefix-numeric-value arg) 0)))
6928 (when gnus-dead-summary-mode
6929 (gnus-add-minor-mode
6930 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6931
6932 (defun gnus-deaden-summary ()
6933 "Make the current summary buffer into a dead summary buffer."
6934 ;; Kill any previous dead summary buffer.
6935 (when (and gnus-dead-summary
6936 (buffer-name gnus-dead-summary))
6937 (save-excursion
6938 (set-buffer gnus-dead-summary)
6939 (when gnus-dead-summary-mode
6940 (kill-buffer (current-buffer)))))
6941 ;; Make this the current dead summary.
6942 (setq gnus-dead-summary (current-buffer))
6943 (gnus-dead-summary-mode 1)
6944 (let ((name (buffer-name)))
6945 (when (string-match "Summary" name)
6946 (rename-buffer
6947 (concat (substring name 0 (match-beginning 0)) "Dead "
6948 (substring name (match-beginning 0)))
6949 t)
6950 (bury-buffer))))
6951
6952 (defun gnus-kill-or-deaden-summary (buffer)
6953 "Kill or deaden the summary BUFFER."
6954 (save-excursion
6955 (when (and (buffer-name buffer)
6956 (not gnus-single-article-buffer))
6957 (save-excursion
6958 (set-buffer buffer)
6959 (gnus-kill-buffer gnus-article-buffer)
6960 (gnus-kill-buffer gnus-original-article-buffer)))
6961 (cond
6962 ;; Kill the buffer.
6963 (gnus-kill-summary-on-exit
6964 (when (and gnus-use-trees
6965 (gnus-buffer-exists-p buffer))
6966 (save-excursion
6967 (set-buffer buffer)
6968 (gnus-tree-close gnus-newsgroup-name)))
6969 (gnus-kill-buffer buffer))
6970 ;; Deaden the buffer.
6971 ((gnus-buffer-exists-p buffer)
6972 (save-excursion
6973 (set-buffer buffer)
6974 (gnus-deaden-summary))))))
6975
6976 (defun gnus-summary-wake-up-the-dead (&rest args)
6977 "Wake up the dead summary buffer."
6978 (interactive)
6979 (gnus-dead-summary-mode -1)
6980 (let ((name (buffer-name)))
6981 (when (string-match "Dead " name)
6982 (rename-buffer
6983 (concat (substring name 0 (match-beginning 0))
6984 (substring name (match-end 0)))
6985 t)))
6986 (gnus-message 3 "This dead summary is now alive again"))
6987
6988 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6989 (defun gnus-summary-fetch-faq (&optional faq-dir)
6990 "Fetch the FAQ for the current group.
6991 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6992 in."
6993 (interactive
6994 (list
6995 (when current-prefix-arg
6996 (completing-read
6997 "FAQ dir: " (and (listp gnus-group-faq-directory)
6998 (mapcar (lambda (file) (list file))
6999 gnus-group-faq-directory))))))
7000 (let (gnus-faq-buffer)
7001 (when (setq gnus-faq-buffer
7002 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7003 (gnus-configure-windows 'summary-faq))))
7004
7005 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7006 (defun gnus-summary-describe-group (&optional force)
7007 "Describe the current newsgroup."
7008 (interactive "P")
7009 (gnus-group-describe-group force gnus-newsgroup-name))
7010
7011 (defun gnus-summary-describe-briefly ()
7012 "Describe summary mode commands briefly."
7013 (interactive)
7014 (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")))
7015
7016 ;; Walking around group mode buffer from summary mode.
7017
7018 (defun gnus-summary-next-group (&optional no-article target-group backward)
7019 "Exit current newsgroup and then select next unread newsgroup.
7020 If prefix argument NO-ARTICLE is non-nil, no article is selected
7021 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7022 previous group instead."
7023 (interactive "P")
7024 ;; Stop pre-fetching.
7025 (gnus-async-halt-prefetch)
7026 (let ((current-group gnus-newsgroup-name)
7027 (current-buffer (current-buffer))
7028 entered)
7029 ;; First we semi-exit this group to update Xrefs and all variables.
7030 ;; We can't do a real exit, because the window conf must remain
7031 ;; the same in case the user is prompted for info, and we don't
7032 ;; want the window conf to change before that...
7033 (gnus-summary-exit t)
7034 (while (not entered)
7035 ;; Then we find what group we are supposed to enter.
7036 (set-buffer gnus-group-buffer)
7037 (gnus-group-jump-to-group current-group)
7038 (setq target-group
7039 (or target-group
7040 (if (eq gnus-keep-same-level 'best)
7041 (gnus-summary-best-group gnus-newsgroup-name)
7042 (gnus-summary-search-group backward gnus-keep-same-level))))
7043 (if (not target-group)
7044 ;; There are no further groups, so we return to the group
7045 ;; buffer.
7046 (progn
7047 (gnus-message 5 "Returning to the group buffer")
7048 (setq entered t)
7049 (when (gnus-buffer-live-p current-buffer)
7050 (set-buffer current-buffer)
7051 (gnus-summary-exit))
7052 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7053 ;; We try to enter the target group.
7054 (gnus-group-jump-to-group target-group)
7055 (let ((unreads (gnus-group-group-unread)))
7056 (if (and (or (eq t unreads)
7057 (and unreads (not (zerop unreads))))
7058 (gnus-summary-read-group
7059 target-group nil no-article
7060 (and (buffer-name current-buffer) current-buffer)
7061 nil backward))
7062 (setq entered t)
7063 (setq current-group target-group
7064 target-group nil)))))))
7065
7066 (defun gnus-summary-prev-group (&optional no-article)
7067 "Exit current newsgroup and then select previous unread newsgroup.
7068 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7069 (interactive "P")
7070 (gnus-summary-next-group no-article nil t))
7071
7072 ;; Walking around summary lines.
7073
7074 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7075 "Go to the first subject satisfying any non-nil constraint.
7076 If UNREAD is non-nil, the article should be unread.
7077 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7078 If UNSEEN is non-nil, the article should be unseen.
7079 Returns the article selected or nil if there are no matching articles."
7080 (interactive "P")
7081 (cond
7082 ;; Empty summary.
7083 ((null gnus-newsgroup-data)
7084 (gnus-message 3 "No articles in the group")
7085 nil)
7086 ;; Pick the first article.
7087 ((not (or unread undownloaded unseen))
7088 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7089 (gnus-data-number (car gnus-newsgroup-data)))
7090 ;; Find the first unread article.
7091 (t
7092 (let ((data gnus-newsgroup-data))
7093 (while (and data
7094 (let ((num (gnus-data-number (car data))))
7095 (or (memq num gnus-newsgroup-unfetched)
7096 (not (or (and unread
7097 (memq num gnus-newsgroup-unreads))
7098 (and undownloaded
7099 (memq num gnus-newsgroup-undownloaded))
7100 (and unseen
7101 (memq num gnus-newsgroup-unseen)))))))
7102 (setq data (cdr data)))
7103 (prog1
7104 (if data
7105 (progn
7106 (goto-char (gnus-data-pos (car data)))
7107 (gnus-data-number (car data)))
7108 (gnus-message 3 "No more%s articles"
7109 (let* ((r (when unread " unread"))
7110 (d (when undownloaded " undownloaded"))
7111 (s (when unseen " unseen"))
7112 (l (delq nil (list r d s))))
7113 (cond ((= 3 (length l))
7114 (concat r "," d ", or" s))
7115 ((= 2 (length l))
7116 (concat (car l) ", or" (cadr l)))
7117 ((= 1 (length l))
7118 (car l))
7119 (t
7120 ""))))
7121 nil
7122 )
7123 (gnus-summary-position-point))))))
7124
7125 (defun gnus-summary-next-subject (n &optional unread dont-display)
7126 "Go to next N'th summary line.
7127 If N is negative, go to the previous N'th subject line.
7128 If UNREAD is non-nil, only unread articles are selected.
7129 The difference between N and the actual number of steps taken is
7130 returned."
7131 (interactive "p")
7132 (let ((backward (< n 0))
7133 (n (abs n)))
7134 (while (and (> n 0)
7135 (if backward
7136 (gnus-summary-find-prev unread)
7137 (gnus-summary-find-next unread)))
7138 (unless (zerop (setq n (1- n)))
7139 (gnus-summary-show-thread)))
7140 (when (/= 0 n)
7141 (gnus-message 7 "No more%s articles"
7142 (if unread " unread" "")))
7143 (unless dont-display
7144 (gnus-summary-recenter)
7145 (gnus-summary-position-point))
7146 n))
7147
7148 (defun gnus-summary-next-unread-subject (n)
7149 "Go to next N'th unread summary line."
7150 (interactive "p")
7151 (gnus-summary-next-subject n t))
7152
7153 (defun gnus-summary-prev-subject (n &optional unread)
7154 "Go to previous N'th summary line.
7155 If optional argument UNREAD is non-nil, only unread article is selected."
7156 (interactive "p")
7157 (gnus-summary-next-subject (- n) unread))
7158
7159 (defun gnus-summary-prev-unread-subject (n)
7160 "Go to previous N'th unread summary line."
7161 (interactive "p")
7162 (gnus-summary-next-subject (- n) t))
7163
7164 (defun gnus-summary-goto-subjects (articles)
7165 "Insert the subject header for ARTICLES in the current buffer."
7166 (save-excursion
7167 (dolist (article articles)
7168 (gnus-summary-goto-subject article t)))
7169 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7170 (gnus-summary-position-point))
7171
7172 (defun gnus-summary-goto-subject (article &optional force silent)
7173 "Go the subject line of ARTICLE.
7174 If FORCE, also allow jumping to articles not currently shown."
7175 (interactive "nArticle number: ")
7176 (unless (numberp article)
7177 (error "Article %s is not a number" article))
7178 (let ((b (point))
7179 (data (gnus-data-find article)))
7180 ;; We read in the article if we have to.
7181 (and (not data)
7182 force
7183 (gnus-summary-insert-subject
7184 article
7185 (if (or (numberp force) (vectorp force)) force)
7186 t)
7187 (setq data (gnus-data-find article)))
7188 (goto-char b)
7189 (if (not data)
7190 (progn
7191 (unless silent
7192 (gnus-message 3 "Can't find article %d" article))
7193 nil)
7194 (let ((pt (gnus-data-pos data)))
7195 (goto-char pt)
7196 (gnus-summary-set-article-display-arrow pt))
7197 (gnus-summary-position-point)
7198 article)))
7199
7200 ;; Walking around summary lines with displaying articles.
7201
7202 (defun gnus-summary-expand-window (&optional arg)
7203 "Make the summary buffer take up the entire Emacs frame.
7204 Given a prefix, will force an `article' buffer configuration."
7205 (interactive "P")
7206 (if arg
7207 (gnus-configure-windows 'article 'force)
7208 (gnus-configure-windows 'summary 'force)))
7209
7210 (defun gnus-summary-display-article (article &optional all-header)
7211 "Display ARTICLE in article buffer."
7212 (when (gnus-buffer-live-p gnus-article-buffer)
7213 (with-current-buffer gnus-article-buffer
7214 (mm-enable-multibyte)))
7215 (gnus-set-global-variables)
7216 (when (gnus-buffer-live-p gnus-article-buffer)
7217 (with-current-buffer gnus-article-buffer
7218 (setq gnus-article-charset gnus-newsgroup-charset)
7219 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7220 (mm-enable-multibyte)))
7221 (if (null article)
7222 nil
7223 (prog1
7224 (if gnus-summary-display-article-function
7225 (funcall gnus-summary-display-article-function article all-header)
7226 (gnus-article-prepare article all-header))
7227 (gnus-run-hooks 'gnus-select-article-hook)
7228 (when (and gnus-current-article
7229 (not (zerop gnus-current-article)))
7230 (gnus-summary-goto-subject gnus-current-article))
7231 (gnus-summary-recenter)
7232 (when (and gnus-use-trees gnus-show-threads)
7233 (gnus-possibly-generate-tree article)
7234 (gnus-highlight-selected-tree article))
7235 ;; Successfully display article.
7236 (gnus-article-set-window-start
7237 (cdr (assq article gnus-newsgroup-bookmarks))))))
7238
7239 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7240 "Select the current article.
7241 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7242 non-nil, the article will be re-fetched even if it already present in
7243 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7244 be displayed."
7245 ;; Make sure we are in the summary buffer to work around bbdb bug.
7246 (unless (eq major-mode 'gnus-summary-mode)
7247 (set-buffer gnus-summary-buffer))
7248 (let ((article (or article (gnus-summary-article-number)))
7249 (all-headers (not (not all-headers))) ;Must be t or nil.
7250 gnus-summary-display-article-function)
7251 (and (not pseudo)
7252 (gnus-summary-article-pseudo-p article)
7253 (error "This is a pseudo-article"))
7254 (save-excursion
7255 (set-buffer gnus-summary-buffer)
7256 (if (or (and gnus-single-article-buffer
7257 (or (null gnus-current-article)
7258 (null gnus-article-current)
7259 (null (get-buffer gnus-article-buffer))
7260 (not (eq article (cdr gnus-article-current)))
7261 (not (equal (car gnus-article-current)
7262 gnus-newsgroup-name))))
7263 (and (not gnus-single-article-buffer)
7264 (or (null gnus-current-article)
7265 (not (eq gnus-current-article article))))
7266 force)
7267 ;; The requested article is different from the current article.
7268 (progn
7269 (gnus-summary-display-article article all-headers)
7270 (when (gnus-buffer-live-p gnus-article-buffer)
7271 (with-current-buffer gnus-article-buffer
7272 (if (not gnus-article-decoded-p) ;; a local variable
7273 (mm-disable-multibyte))))
7274 (gnus-article-set-window-start
7275 (cdr (assq article gnus-newsgroup-bookmarks)))
7276 article)
7277 'old))))
7278
7279 (defun gnus-summary-force-verify-and-decrypt ()
7280 "Display buttons for signed/encrypted parts and verify/decrypt them."
7281 (interactive)
7282 (let ((mm-verify-option 'known)
7283 (mm-decrypt-option 'known)
7284 (gnus-article-emulate-mime t)
7285 (gnus-buttonized-mime-types (append (list "multipart/signed"
7286 "multipart/encrypted")
7287 gnus-buttonized-mime-types)))
7288 (gnus-summary-select-article nil 'force)))
7289
7290 (defun gnus-summary-set-current-mark (&optional current-mark)
7291 "Obsolete function."
7292 nil)
7293
7294 (defun gnus-summary-next-article (&optional unread subject backward push)
7295 "Select the next article.
7296 If UNREAD, only unread articles are selected.
7297 If SUBJECT, only articles with SUBJECT are selected.
7298 If BACKWARD, the previous article is selected instead of the next."
7299 (interactive "P")
7300 (cond
7301 ;; Is there such an article?
7302 ((and (gnus-summary-search-forward unread subject backward)
7303 (or (gnus-summary-display-article (gnus-summary-article-number))
7304 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7305 (gnus-summary-position-point))
7306 ;; If not, we try the first unread, if that is wanted.
7307 ((and subject
7308 gnus-auto-select-same
7309 (gnus-summary-first-unread-article))
7310 (gnus-summary-position-point)
7311 (gnus-message 6 "Wrapped"))
7312 ;; Try to get next/previous article not displayed in this group.
7313 ((and gnus-auto-extend-newsgroup
7314 (not unread) (not subject))
7315 (gnus-summary-goto-article
7316 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7317 nil (count-lines (point-min) (point))))
7318 ;; Go to next/previous group.
7319 (t
7320 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7321 (gnus-summary-jump-to-group gnus-newsgroup-name))
7322 (let ((cmd last-command-char)
7323 (point
7324 (save-excursion
7325 (set-buffer gnus-group-buffer)
7326 (point)))
7327 (group
7328 (if (eq gnus-keep-same-level 'best)
7329 (gnus-summary-best-group gnus-newsgroup-name)
7330 (gnus-summary-search-group backward gnus-keep-same-level))))
7331 ;; For some reason, the group window gets selected. We change
7332 ;; it back.
7333 (select-window (get-buffer-window (current-buffer)))
7334 ;; Select next unread newsgroup automagically.
7335 (cond
7336 ((or (not gnus-auto-select-next)
7337 (not cmd))
7338 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7339 ((or (eq gnus-auto-select-next 'quietly)
7340 (and (eq gnus-auto-select-next 'slightly-quietly)
7341 push)
7342 (and (eq gnus-auto-select-next 'almost-quietly)
7343 (gnus-summary-last-article-p)))
7344 ;; Select quietly.
7345 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7346 (gnus-summary-exit)
7347 (gnus-message 7 "No more%s articles (%s)..."
7348 (if unread " unread" "")
7349 (if group (concat "selecting " group)
7350 "exiting"))
7351 (gnus-summary-next-group nil group backward)))
7352 (t
7353 (when (gnus-key-press-event-p last-input-event)
7354 (gnus-summary-walk-group-buffer
7355 gnus-newsgroup-name cmd unread backward point))))))))
7356
7357 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7358 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7359 (?\C-p (gnus-group-prev-unread-group 1))))
7360 (cursor-in-echo-area t)
7361 keve key group ended prompt)
7362 (save-excursion
7363 (set-buffer gnus-group-buffer)
7364 (goto-char start)
7365 (setq group
7366 (if (eq gnus-keep-same-level 'best)
7367 (gnus-summary-best-group gnus-newsgroup-name)
7368 (gnus-summary-search-group backward gnus-keep-same-level))))
7369 (while (not ended)
7370 (setq prompt
7371 (format
7372 "No more%s articles%s " (if unread " unread" "")
7373 (if (and group
7374 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7375 (format " (Type %s for %s [%s])"
7376 (single-key-description cmd)
7377 (gnus-group-decoded-name group)
7378 (car (gnus-gethash group gnus-newsrc-hashtb)))
7379 (format " (Type %s to exit %s)"
7380 (single-key-description cmd)
7381 (gnus-group-decoded-name gnus-newsgroup-name)))))
7382 ;; Confirm auto selection.
7383 (setq key (car (setq keve (gnus-read-event-char prompt)))
7384 ended t)
7385 (cond
7386 ((assq key keystrokes)
7387 (let ((obuf (current-buffer)))
7388 (switch-to-buffer gnus-group-buffer)
7389 (when group
7390 (gnus-group-jump-to-group group))
7391 (eval (cadr (assq key keystrokes)))
7392 (setq group (gnus-group-group-name))
7393 (switch-to-buffer obuf))
7394 (setq ended nil))
7395 ((equal key cmd)
7396 (if (or (not group)
7397 (gnus-ephemeral-group-p gnus-newsgroup-name))
7398 (gnus-summary-exit)
7399 (gnus-summary-next-group nil group backward)))
7400 (t
7401 (push (cdr keve) unread-command-events))))))
7402
7403 (defun gnus-summary-next-unread-article ()
7404 "Select unread article after current one."
7405 (interactive)
7406 (gnus-summary-next-article
7407 (or (not (eq gnus-summary-goto-unread 'never))
7408 (gnus-summary-last-article-p (gnus-summary-article-number)))
7409 (and gnus-auto-select-same
7410 (gnus-summary-article-subject))))
7411
7412 (defun gnus-summary-prev-article (&optional unread subject)
7413 "Select the article after the current one.
7414 If UNREAD is non-nil, only unread articles are selected."
7415 (interactive "P")
7416 (gnus-summary-next-article unread subject t))
7417
7418 (defun gnus-summary-prev-unread-article ()
7419 "Select unread article before current one."
7420 (interactive)
7421 (gnus-summary-prev-article
7422 (or (not (eq gnus-summary-goto-unread 'never))
7423 (gnus-summary-first-article-p (gnus-summary-article-number)))
7424 (and gnus-auto-select-same
7425 (gnus-summary-article-subject))))
7426
7427 (defun gnus-summary-next-page (&optional lines circular stop)
7428 "Show next page of the selected article.
7429 If at the end of the current article, select the next article.
7430 LINES says how many lines should be scrolled up.
7431
7432 If CIRCULAR is non-nil, go to the start of the article instead of
7433 selecting the next article when reaching the end of the current
7434 article.
7435
7436 If STOP is non-nil, just stop when reaching the end of the message.
7437
7438 Also see the variable `gnus-article-skip-boring'."
7439 (interactive "P")
7440 (setq gnus-summary-buffer (current-buffer))
7441 (gnus-set-global-variables)
7442 (let ((article (gnus-summary-article-number))
7443 (article-window (get-buffer-window gnus-article-buffer t))
7444 endp)
7445 ;; If the buffer is empty, we have no article.
7446 (unless article
7447 (error "No article to select"))
7448 (gnus-configure-windows 'article)
7449 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7450 (if (and (eq gnus-summary-goto-unread 'never)
7451 (not (gnus-summary-last-article-p article)))
7452 (gnus-summary-next-article)
7453 (gnus-summary-next-unread-article))
7454 (if (or (null gnus-current-article)
7455 (null gnus-article-current)
7456 (/= article (cdr gnus-article-current))
7457 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7458 ;; Selected subject is different from current article's.
7459 (gnus-summary-display-article article)
7460 (when article-window
7461 (gnus-eval-in-buffer-window gnus-article-buffer
7462 (setq endp (or (gnus-article-next-page lines)
7463 (gnus-article-only-boring-p))))
7464 (when endp
7465 (cond (stop
7466 (gnus-message 3 "End of message"))
7467 (circular
7468 (gnus-summary-beginning-of-article))
7469 (lines
7470 (gnus-message 3 "End of message"))
7471 ((null lines)
7472 (if (and (eq gnus-summary-goto-unread 'never)
7473 (not (gnus-summary-last-article-p article)))
7474 (gnus-summary-next-article)
7475 (gnus-summary-next-unread-article))))))))
7476 (gnus-summary-recenter)
7477 (gnus-summary-position-point)))
7478
7479 (defun gnus-summary-prev-page (&optional lines move)
7480 "Show previous page of selected article.
7481 Argument LINES specifies lines to be scrolled down.
7482 If MOVE, move to the previous unread article if point is at
7483 the beginning of the buffer."
7484 (interactive "P")
7485 (let ((article (gnus-summary-article-number))
7486 (article-window (get-buffer-window gnus-article-buffer t))
7487 endp)
7488 (gnus-configure-windows 'article)
7489 (if (or (null gnus-current-article)
7490 (null gnus-article-current)
7491 (/= article (cdr gnus-article-current))
7492 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7493 ;; Selected subject is different from current article's.
7494 (gnus-summary-display-article article)
7495 (gnus-summary-recenter)
7496 (when article-window
7497 (gnus-eval-in-buffer-window gnus-article-buffer
7498 (setq endp (gnus-article-prev-page lines)))
7499 (when (and move endp)
7500 (cond (lines
7501 (gnus-message 3 "Beginning of message"))
7502 ((null lines)
7503 (if (and (eq gnus-summary-goto-unread 'never)
7504 (not (gnus-summary-first-article-p article)))
7505 (gnus-summary-prev-article)
7506 (gnus-summary-prev-unread-article))))))))
7507 (gnus-summary-position-point))
7508
7509 (defun gnus-summary-prev-page-or-article (&optional lines)
7510 "Show previous page of selected article.
7511 Argument LINES specifies lines to be scrolled down.
7512 If at the beginning of the article, go to the next article."
7513 (interactive "P")
7514 (gnus-summary-prev-page lines t))
7515
7516 (defun gnus-summary-scroll-up (lines)
7517 "Scroll up (or down) one line current article.
7518 Argument LINES specifies lines to be scrolled up (or down if negative)."
7519 (interactive "p")
7520 (gnus-configure-windows 'article)
7521 (gnus-summary-show-thread)
7522 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7523 (gnus-eval-in-buffer-window gnus-article-buffer
7524 (cond ((> lines 0)
7525 (when (gnus-article-next-page lines)
7526 (gnus-message 3 "End of message")))
7527 ((< lines 0)
7528 (gnus-article-prev-page (- lines))))))
7529 (gnus-summary-recenter)
7530 (gnus-summary-position-point))
7531
7532 (defun gnus-summary-scroll-down (lines)
7533 "Scroll down (or up) one line current article.
7534 Argument LINES specifies lines to be scrolled down (or up if negative)."
7535 (interactive "p")
7536 (gnus-summary-scroll-up (- lines)))
7537
7538 (defun gnus-summary-next-same-subject ()
7539 "Select next article which has the same subject as current one."
7540 (interactive)
7541 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7542
7543 (defun gnus-summary-prev-same-subject ()
7544 "Select previous article which has the same subject as current one."
7545 (interactive)
7546 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7547
7548 (defun gnus-summary-next-unread-same-subject ()
7549 "Select next unread article which has the same subject as current one."
7550 (interactive)
7551 (gnus-summary-next-article t (gnus-summary-article-subject)))
7552
7553 (defun gnus-summary-prev-unread-same-subject ()
7554 "Select previous unread article which has the same subject as current one."
7555 (interactive)
7556 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7557
7558 (defun gnus-summary-first-unread-article ()
7559 "Select the first unread article.
7560 Return nil if there are no unread articles."
7561 (interactive)
7562 (prog1
7563 (when (gnus-summary-first-subject t)
7564 (gnus-summary-show-thread)
7565 (gnus-summary-first-subject t)
7566 (gnus-summary-display-article (gnus-summary-article-number)))
7567 (gnus-summary-position-point)))
7568
7569 (defun gnus-summary-first-unread-subject ()
7570 "Place the point on the subject line of the first unread article.
7571 Return nil if there are no unread articles."
7572 (interactive)
7573 (prog1
7574 (when (gnus-summary-first-subject t)
7575 (gnus-summary-show-thread)
7576 (gnus-summary-first-subject t))
7577 (gnus-summary-position-point)))
7578
7579 (defun gnus-summary-first-unseen-subject ()
7580 "Place the point on the subject line of the first unseen article.
7581 Return nil if there are no unseen articles."
7582 (interactive)
7583 (prog1
7584 (when (gnus-summary-first-subject nil nil t)
7585 (gnus-summary-show-thread)
7586 (gnus-summary-first-subject nil nil t))
7587 (gnus-summary-position-point)))
7588
7589 (defun gnus-summary-first-unseen-or-unread-subject ()
7590 "Place the point on the subject line of the first unseen article or,
7591 if all article have been seen, on the subject line of the first unread
7592 article."
7593 (interactive)
7594 (prog1
7595 (unless (when (gnus-summary-first-subject nil nil t)
7596 (gnus-summary-show-thread)
7597 (gnus-summary-first-subject nil nil t))
7598 (when (gnus-summary-first-subject t)
7599 (gnus-summary-show-thread)
7600 (gnus-summary-first-subject t)))
7601 (gnus-summary-position-point)))
7602
7603 (defun gnus-summary-first-article ()
7604 "Select the first article.
7605 Return nil if there are no articles."
7606 (interactive)
7607 (prog1
7608 (when (gnus-summary-first-subject)
7609 (gnus-summary-show-thread)
7610 (gnus-summary-first-subject)
7611 (gnus-summary-display-article (gnus-summary-article-number)))
7612 (gnus-summary-position-point)))
7613
7614 (defun gnus-summary-best-unread-article (&optional arg)
7615 "Select the unread article with the highest score.
7616 If given a prefix argument, select the next unread article that has a
7617 score higher than the default score."
7618 (interactive "P")
7619 (let ((article (if arg
7620 (gnus-summary-better-unread-subject)
7621 (gnus-summary-best-unread-subject))))
7622 (if article
7623 (gnus-summary-goto-article article)
7624 (error "No unread articles"))))
7625
7626 (defun gnus-summary-best-unread-subject ()
7627 "Select the unread subject with the highest score."
7628 (interactive)
7629 (let ((best -1000000)
7630 (data gnus-newsgroup-data)
7631 article score)
7632 (while data
7633 (and (gnus-data-unread-p (car data))
7634 (> (setq score
7635 (gnus-summary-article-score (gnus-data-number (car data))))
7636 best)
7637 (setq best score
7638 article (gnus-data-number (car data))))
7639 (setq data (cdr data)))
7640 (when article
7641 (gnus-summary-goto-subject article))
7642 (gnus-summary-position-point)
7643 article))
7644
7645 (defun gnus-summary-better-unread-subject ()
7646 "Select the first unread subject that has a score over the default score."
7647 (interactive)
7648 (let ((data gnus-newsgroup-data)
7649 article score)
7650 (while (and (setq article (gnus-data-number (car data)))
7651 (or (gnus-data-read-p (car data))
7652 (not (> (gnus-summary-article-score article)
7653 gnus-summary-default-score))))
7654 (setq data (cdr data)))
7655 (when article
7656 (gnus-summary-goto-subject article))
7657 (gnus-summary-position-point)
7658 article))
7659
7660 (defun gnus-summary-last-subject ()
7661 "Go to the last displayed subject line in the group."
7662 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7663 (when article
7664 (gnus-summary-goto-subject article))))
7665
7666 (defun gnus-summary-goto-article (article &optional all-headers force)
7667 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7668 If ALL-HEADERS is non-nil, no header lines are hidden.
7669 If FORCE, go to the article even if it isn't displayed. If FORCE
7670 is a number, it is the line the article is to be displayed on."
7671 (interactive
7672 (list
7673 (completing-read
7674 "Article number or Message-ID: "
7675 (mapcar (lambda (number) (list (int-to-string number)))
7676 gnus-newsgroup-limit))
7677 current-prefix-arg
7678 t))
7679 (prog1
7680 (if (and (stringp article)
7681 (string-match "@\\|%40" article))
7682 (gnus-summary-refer-article article)
7683 (when (stringp article)
7684 (setq article (string-to-number article)))
7685 (if (gnus-summary-goto-subject article force)
7686 (gnus-summary-display-article article all-headers)
7687 (gnus-message 4 "Couldn't go to article %s" article) nil))
7688 (gnus-summary-position-point)))
7689
7690 (defun gnus-summary-goto-last-article ()
7691 "Go to the previously read article."
7692 (interactive)
7693 (prog1
7694 (when gnus-last-article
7695 (gnus-summary-goto-article gnus-last-article nil t))
7696 (gnus-summary-position-point)))
7697
7698 (defun gnus-summary-pop-article (number)
7699 "Pop one article off the history and go to the previous.
7700 NUMBER articles will be popped off."
7701 (interactive "p")
7702 (let (to)
7703 (setq gnus-newsgroup-history
7704 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7705 (if to
7706 (gnus-summary-goto-article (car to) nil t)
7707 (error "Article history empty")))
7708 (gnus-summary-position-point))
7709
7710 ;; Summary commands and functions for limiting the summary buffer.
7711
7712 (defun gnus-summary-limit-to-articles (n)
7713 "Limit the summary buffer to the next N articles.
7714 If not given a prefix, use the process marked articles instead."
7715 (interactive "P")
7716 (prog1
7717 (let ((articles (gnus-summary-work-articles n)))
7718 (setq gnus-newsgroup-processable nil)
7719 (gnus-summary-limit articles))
7720 (gnus-summary-position-point)))
7721
7722 (defun gnus-summary-pop-limit (&optional total)
7723 "Restore the previous limit.
7724 If given a prefix, remove all limits."
7725 (interactive "P")
7726 (when total
7727 (setq gnus-newsgroup-limits
7728 (list (mapcar (lambda (h) (mail-header-number h))
7729 gnus-newsgroup-headers))))
7730 (unless gnus-newsgroup-limits
7731 (error "No limit to pop"))
7732 (prog1
7733 (gnus-summary-limit nil 'pop)
7734 (gnus-summary-position-point)))
7735
7736 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7737 "Limit the summary buffer to articles that have subjects that match a regexp.
7738 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7739 (interactive
7740 (list (read-string (if current-prefix-arg
7741 "Exclude subject (regexp): "
7742 "Limit to subject (regexp): "))
7743 nil current-prefix-arg))
7744 (unless header
7745 (setq header "subject"))
7746 (when (not (equal "" subject))
7747 (prog1
7748 (let ((articles (gnus-summary-find-matching
7749 (or header "subject") subject 'all nil nil
7750 not-matching)))
7751 (unless articles
7752 (error "Found no matches for \"%s\"" subject))
7753 (gnus-summary-limit articles))
7754 (gnus-summary-position-point))))
7755
7756 (defun gnus-summary-limit-to-author (from &optional not-matching)
7757 "Limit the summary buffer to articles that have authors that match a regexp.
7758 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7759 (interactive
7760 (list (read-string (if current-prefix-arg
7761 "Exclude author (regexp): "
7762 "Limit to author (regexp): "))
7763 current-prefix-arg))
7764 (gnus-summary-limit-to-subject from "from" not-matching))
7765
7766 (defun gnus-summary-limit-to-age (age &optional younger-p)
7767 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7768 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7769 articles that are younger than AGE days."
7770 (interactive
7771 (let ((younger current-prefix-arg)
7772 (days-got nil)
7773 days)
7774 (while (not days-got)
7775 (setq days (if younger
7776 (read-string "Limit to articles younger than (in days, older when negative): ")
7777 (read-string
7778 "Limit to articles older than (in days, younger when negative): ")))
7779 (when (> (length days) 0)
7780 (setq days (read days)))
7781 (if (numberp days)
7782 (progn
7783 (setq days-got t)
7784 (if (< days 0)
7785 (progn
7786 (setq younger (not younger))
7787 (setq days (* days -1)))))
7788 (message "Please enter a number.")
7789 (sleep-for 1)))
7790 (list days younger)))
7791 (prog1
7792 (let ((data gnus-newsgroup-data)
7793 (cutoff (days-to-time age))
7794 articles d date is-younger)
7795 (while (setq d (pop data))
7796 (when (and (vectorp (gnus-data-header d))
7797 (setq date (mail-header-date (gnus-data-header d))))
7798 (setq is-younger (time-less-p
7799 (time-since (condition-case ()
7800 (date-to-time date)
7801 (error '(0 0))))
7802 cutoff))
7803 (when (if younger-p
7804 is-younger
7805 (not is-younger))
7806 (push (gnus-data-number d) articles))))
7807 (gnus-summary-limit (nreverse articles)))
7808 (gnus-summary-position-point)))
7809
7810 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7811 "Limit the summary buffer to articles that match an 'extra' header."
7812 (interactive
7813 (let ((header
7814 (intern
7815 (gnus-completing-read-with-default
7816 (symbol-name (car gnus-extra-headers))
7817 (if current-prefix-arg
7818 "Exclude extra header"
7819 "Limit extra header")
7820 (mapcar (lambda (x)
7821 (cons (symbol-name x) x))
7822 gnus-extra-headers)
7823 nil
7824 t))))
7825 (list header
7826 (read-string (format "%s header %s (regexp): "
7827 (if current-prefix-arg "Exclude" "Limit to")
7828 header))
7829 current-prefix-arg)))
7830 (when (not (equal "" regexp))
7831 (prog1
7832 (let ((articles (gnus-summary-find-matching
7833 (cons 'extra header) regexp 'all nil nil
7834 not-matching)))
7835 (unless articles
7836 (error "Found no matches for \"%s\"" regexp))
7837 (gnus-summary-limit articles))
7838 (gnus-summary-position-point))))
7839
7840 (defun gnus-summary-limit-to-display-predicate ()
7841 "Limit the summary buffer to the predicated in the `display' group parameter."
7842 (interactive)
7843 (unless gnus-newsgroup-display
7844 (error "There is no `display' group parameter"))
7845 (let (articles)
7846 (dolist (number gnus-newsgroup-articles)
7847 (when (funcall gnus-newsgroup-display)
7848 (push number articles)))
7849 (gnus-summary-limit articles))
7850 (gnus-summary-position-point))
7851
7852 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7853 (make-obsolete
7854 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7855
7856 (defun gnus-summary-limit-to-unread (&optional all)
7857 "Limit the summary buffer to articles that are not marked as read.
7858 If ALL is non-nil, limit strictly to unread articles."
7859 (interactive "P")
7860 (if all
7861 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7862 (gnus-summary-limit-to-marks
7863 ;; Concat all the marks that say that an article is read and have
7864 ;; those removed.
7865 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7866 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7867 gnus-low-score-mark gnus-expirable-mark
7868 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7869 gnus-duplicate-mark gnus-souped-mark)
7870 'reverse)))
7871
7872 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7873 (make-obsolete 'gnus-summary-delete-marked-with
7874 'gnus-summary-limit-exclude-marks)
7875
7876 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7877 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7878 If REVERSE, limit the summary buffer to articles that are marked
7879 with MARKS. MARKS can either be a string of marks or a list of marks.
7880 Returns how many articles were removed."
7881 (interactive "sMarks: ")
7882 (gnus-summary-limit-to-marks marks t))
7883
7884 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7885 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7886 If REVERSE (the prefix), limit the summary buffer to articles that are
7887 not marked with MARKS. MARKS can either be a string of marks or a
7888 list of marks.
7889 Returns how many articles were removed."
7890 (interactive "sMarks: \nP")
7891 (prog1
7892 (let ((data gnus-newsgroup-data)
7893 (marks (if (listp marks) marks
7894 (append marks nil))) ; Transform to list.
7895 articles)
7896 (while data
7897 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7898 (memq (gnus-data-mark (car data)) marks))
7899 (push (gnus-data-number (car data)) articles))
7900 (setq data (cdr data)))
7901 (gnus-summary-limit articles))
7902 (gnus-summary-position-point)))
7903
7904 (defun gnus-summary-limit-to-score (score)
7905 "Limit to articles with score at or above SCORE."
7906 (interactive "NLimit to articles with score of at least: ")
7907 (let ((data gnus-newsgroup-data)
7908 articles)
7909 (while data
7910 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7911 score)
7912 (push (gnus-data-number (car data)) articles))
7913 (setq data (cdr data)))
7914 (prog1
7915 (gnus-summary-limit articles)
7916 (gnus-summary-position-point))))
7917
7918 (defun gnus-summary-limit-to-unseen ()
7919 "Limit to unseen articles."
7920 (interactive)
7921 (prog1
7922 (gnus-summary-limit gnus-newsgroup-unseen)
7923 (gnus-summary-position-point)))
7924
7925 (defun gnus-summary-limit-include-thread (id)
7926 "Display all the hidden articles that is in the thread with ID in it.
7927 When called interactively, ID is the Message-ID of the current
7928 article."
7929 (interactive (list (mail-header-id (gnus-summary-article-header))))
7930 (let ((articles (gnus-articles-in-thread
7931 (gnus-id-to-thread (gnus-root-id id)))))
7932 (prog1
7933 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7934 (gnus-summary-limit-include-matching-articles
7935 "subject"
7936 (regexp-quote (gnus-simplify-subject-re
7937 (mail-header-subject (gnus-id-to-header id)))))
7938 (gnus-summary-position-point))))
7939
7940 (defun gnus-summary-limit-include-matching-articles (header regexp)
7941 "Display all the hidden articles that have HEADERs that match REGEXP."
7942 (interactive (list (read-string "Match on header: ")
7943 (read-string "Regexp: ")))
7944 (let ((articles (gnus-find-matching-articles header regexp)))
7945 (prog1
7946 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7947 (gnus-summary-position-point))))
7948
7949 (defun gnus-summary-insert-dormant-articles ()
7950 "Insert all the dormant articles for this group into the current buffer."
7951 (interactive)
7952 (let ((gnus-verbose (max 6 gnus-verbose)))
7953 (if (not gnus-newsgroup-dormant)
7954 (gnus-message 3 "No cached articles for this group")
7955 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7956
7957 (defun gnus-summary-limit-include-dormant ()
7958 "Display all the hidden articles that are marked as dormant.
7959 Note that this command only works on a subset of the articles currently
7960 fetched for this group."
7961 (interactive)
7962 (unless gnus-newsgroup-dormant
7963 (error "There are no dormant articles in this group"))
7964 (prog1
7965 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7966 (gnus-summary-position-point)))
7967
7968 (defun gnus-summary-limit-exclude-dormant ()
7969 "Hide all dormant articles."
7970 (interactive)
7971 (prog1
7972 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7973 (gnus-summary-position-point)))
7974
7975 (defun gnus-summary-limit-exclude-childless-dormant ()
7976 "Hide all dormant articles that have no children."
7977 (interactive)
7978 (let ((data (gnus-data-list t))
7979 articles d children)
7980 ;; Find all articles that are either not dormant or have
7981 ;; children.
7982 (while (setq d (pop data))
7983 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7984 (and (setq children
7985 (gnus-article-children (gnus-data-number d)))
7986 (let (found)
7987 (while children
7988 (when (memq (car children) articles)
7989 (setq children nil
7990 found t))
7991 (pop children))
7992 found)))
7993 (push (gnus-data-number d) articles)))
7994 ;; Do the limiting.
7995 (prog1
7996 (gnus-summary-limit articles)
7997 (gnus-summary-position-point))))
7998
7999 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8000 "Mark all unread excluded articles as read.
8001 If ALL, mark even excluded ticked and dormants as read."
8002 (interactive "P")
8003 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8004 (let ((articles (gnus-sorted-ndifference
8005 (sort
8006 (mapcar (lambda (h) (mail-header-number h))
8007 gnus-newsgroup-headers)
8008 '<)
8009 gnus-newsgroup-limit))
8010 article)
8011 (setq gnus-newsgroup-unreads
8012 (gnus-sorted-intersection gnus-newsgroup-unreads
8013 gnus-newsgroup-limit))
8014 (if all
8015 (setq gnus-newsgroup-dormant nil
8016 gnus-newsgroup-marked nil
8017 gnus-newsgroup-reads
8018 (nconc
8019 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8020 gnus-newsgroup-reads))
8021 (while (setq article (pop articles))
8022 (unless (or (memq article gnus-newsgroup-dormant)
8023 (memq article gnus-newsgroup-marked))
8024 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8025
8026 (defun gnus-summary-limit (articles &optional pop)
8027 (if pop
8028 ;; We pop the previous limit off the stack and use that.
8029 (setq articles (car gnus-newsgroup-limits)
8030 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8031 ;; We use the new limit, so we push the old limit on the stack.
8032 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8033 ;; Set the limit.
8034 (setq gnus-newsgroup-limit articles)
8035 (let ((total (length gnus-newsgroup-data))
8036 (data (gnus-data-find-list (gnus-summary-article-number)))
8037 (gnus-summary-mark-below nil) ; Inhibit this.
8038 found)
8039 ;; This will do all the work of generating the new summary buffer
8040 ;; according to the new limit.
8041 (gnus-summary-prepare)
8042 ;; Hide any threads, possibly.
8043 (gnus-summary-maybe-hide-threads)
8044 ;; Try to return to the article you were at, or one in the
8045 ;; neighborhood.
8046 (when data
8047 ;; We try to find some article after the current one.
8048 (while data
8049 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8050 (setq data nil
8051 found t))
8052 (setq data (cdr data))))
8053 (unless found
8054 ;; If there is no data, that means that we were after the last
8055 ;; article. The same goes when we can't find any articles
8056 ;; after the current one.
8057 (goto-char (point-max))
8058 (gnus-summary-find-prev))
8059 (gnus-set-mode-line 'summary)
8060 ;; We return how many articles were removed from the summary
8061 ;; buffer as a result of the new limit.
8062 (- total (length gnus-newsgroup-data))))
8063
8064 (defsubst gnus-invisible-cut-children (threads)
8065 (let ((num 0))
8066 (while threads
8067 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8068 (incf num))
8069 (pop threads))
8070 (< num 2)))
8071
8072 (defsubst gnus-cut-thread (thread)
8073 "Go forwards in the thread until we find an article that we want to display."
8074 (when (or (eq gnus-fetch-old-headers 'some)
8075 (eq gnus-fetch-old-headers 'invisible)
8076 (numberp gnus-fetch-old-headers)
8077 (eq gnus-build-sparse-threads 'some)
8078 (eq gnus-build-sparse-threads 'more))
8079 ;; Deal with old-fetched headers and sparse threads.
8080 (while (and
8081 thread
8082 (or
8083 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8084 (gnus-summary-article-ancient-p
8085 (mail-header-number (car thread))))
8086 (if (or (<= (length (cdr thread)) 1)
8087 (eq gnus-fetch-old-headers 'invisible))
8088 (setq gnus-newsgroup-limit
8089 (delq (mail-header-number (car thread))
8090 gnus-newsgroup-limit)
8091 thread (cadr thread))
8092 (when (gnus-invisible-cut-children (cdr thread))
8093 (let ((th (cdr thread)))
8094 (while th
8095 (if (memq (mail-header-number (caar th))
8096 gnus-newsgroup-limit)
8097 (setq thread (car th)
8098 th nil)
8099 (setq th (cdr th))))))))))
8100 thread)
8101
8102 (defun gnus-cut-threads (threads)
8103 "Cut off all uninteresting articles from the beginning of THREADS."
8104 (when (or (eq gnus-fetch-old-headers 'some)
8105 (eq gnus-fetch-old-headers 'invisible)
8106 (numberp gnus-fetch-old-headers)
8107 (eq gnus-build-sparse-threads 'some)
8108 (eq gnus-build-sparse-threads 'more))
8109 (let ((th threads))
8110 (while th
8111 (setcar th (gnus-cut-thread (car th)))
8112 (setq th (cdr th)))))
8113 ;; Remove nixed out threads.
8114 (delq nil threads))
8115
8116 (defun gnus-summary-initial-limit (&optional show-if-empty)
8117 "Figure out what the initial limit is supposed to be on group entry.
8118 This entails weeding out unwanted dormants, low-scored articles,
8119 fetch-old-headers verbiage, and so on."
8120 ;; Most groups have nothing to remove.
8121 (if (or gnus-inhibit-limiting
8122 (and (null gnus-newsgroup-dormant)
8123 (eq gnus-newsgroup-display 'gnus-not-ignore)
8124 (not (eq gnus-fetch-old-headers 'some))
8125 (not (numberp gnus-fetch-old-headers))
8126 (not (eq gnus-fetch-old-headers 'invisible))
8127 (null gnus-summary-expunge-below)
8128 (not (eq gnus-build-sparse-threads 'some))
8129 (not (eq gnus-build-sparse-threads 'more))
8130 (null gnus-thread-expunge-below)
8131 (not gnus-use-nocem)))
8132 () ; Do nothing.
8133 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8134 (setq gnus-newsgroup-limit nil)
8135 (mapatoms
8136 (lambda (node)
8137 (unless (car (symbol-value node))
8138 ;; These threads have no parents -- they are roots.
8139 (let ((nodes (cdr (symbol-value node)))
8140 thread)
8141 (while nodes
8142 (if (and gnus-thread-expunge-below
8143 (< (gnus-thread-total-score (car nodes))
8144 gnus-thread-expunge-below))
8145 (gnus-expunge-thread (pop nodes))
8146 (setq thread (pop nodes))
8147 (gnus-summary-limit-children thread))))))
8148 gnus-newsgroup-dependencies)
8149 ;; If this limitation resulted in an empty group, we might
8150 ;; pop the previous limit and use it instead.
8151 (when (and (not gnus-newsgroup-limit)
8152 show-if-empty)
8153 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8154 gnus-newsgroup-limit))
8155
8156 (defun gnus-summary-limit-children (thread)
8157 "Return 1 if this subthread is visible and 0 if it is not."
8158 ;; First we get the number of visible children to this thread. This
8159 ;; is done by recursing down the thread using this function, so this
8160 ;; will really go down to a leaf article first, before slowly
8161 ;; working its way up towards the root.
8162 (when thread
8163 (let* ((max-lisp-eval-depth 5000)
8164 (children
8165 (if (cdr thread)
8166 (apply '+ (mapcar 'gnus-summary-limit-children
8167 (cdr thread)))
8168 0))
8169 (number (mail-header-number (car thread)))
8170 score)
8171 (if (and
8172 (not (memq number gnus-newsgroup-marked))
8173 (or
8174 ;; If this article is dormant and has absolutely no visible
8175 ;; children, then this article isn't visible.
8176 (and (memq number gnus-newsgroup-dormant)
8177 (zerop children))
8178 ;; If this is "fetch-old-headered" and there is no
8179 ;; visible children, then we don't want this article.
8180 (and (or (eq gnus-fetch-old-headers 'some)
8181 (numberp gnus-fetch-old-headers))
8182 (gnus-summary-article-ancient-p number)
8183 (zerop children))
8184 ;; If this is "fetch-old-headered" and `invisible', then
8185 ;; we don't want this article.
8186 (and (eq gnus-fetch-old-headers 'invisible)
8187 (gnus-summary-article-ancient-p number))
8188 ;; If this is a sparsely inserted article with no children,
8189 ;; we don't want it.
8190 (and (eq gnus-build-sparse-threads 'some)
8191 (gnus-summary-article-sparse-p number)
8192 (zerop children))
8193 ;; If we use expunging, and this article is really
8194 ;; low-scored, then we don't want this article.
8195 (when (and gnus-summary-expunge-below
8196 (< (setq score
8197 (or (cdr (assq number gnus-newsgroup-scored))
8198 gnus-summary-default-score))
8199 gnus-summary-expunge-below))
8200 ;; We increase the expunge-tally here, but that has
8201 ;; nothing to do with the limits, really.
8202 (incf gnus-newsgroup-expunged-tally)
8203 ;; We also mark as read here, if that's wanted.
8204 (when (and gnus-summary-mark-below
8205 (< score gnus-summary-mark-below))
8206 (setq gnus-newsgroup-unreads
8207 (delq number gnus-newsgroup-unreads))
8208 (if gnus-newsgroup-auto-expire
8209 (push number gnus-newsgroup-expirable)
8210 (push (cons number gnus-low-score-mark)
8211 gnus-newsgroup-reads)))
8212 t)
8213 ;; Do the `display' group parameter.
8214 (and gnus-newsgroup-display
8215 (not (funcall gnus-newsgroup-display)))
8216 ;; Check NoCeM things.
8217 (if (and gnus-use-nocem
8218 (gnus-nocem-unwanted-article-p
8219 (mail-header-id (car thread))))
8220 (progn
8221 (setq gnus-newsgroup-unreads
8222 (delq number gnus-newsgroup-unreads))
8223 t))))
8224 ;; Nope, invisible article.
8225 0
8226 ;; Ok, this article is to be visible, so we add it to the limit
8227 ;; and return 1.
8228 (push number gnus-newsgroup-limit)
8229 1))))
8230
8231 (defun gnus-expunge-thread (thread)
8232 "Mark all articles in THREAD as read."
8233 (let* ((number (mail-header-number (car thread))))
8234 (incf gnus-newsgroup-expunged-tally)
8235 ;; We also mark as read here, if that's wanted.
8236 (setq gnus-newsgroup-unreads
8237 (delq number gnus-newsgroup-unreads))
8238 (if gnus-newsgroup-auto-expire
8239 (push number gnus-newsgroup-expirable)
8240 (push (cons number gnus-low-score-mark)
8241 gnus-newsgroup-reads)))
8242 ;; Go recursively through all subthreads.
8243 (mapcar 'gnus-expunge-thread (cdr thread)))
8244
8245 ;; Summary article oriented commands
8246
8247 (defun gnus-summary-refer-parent-article (n)
8248 "Refer parent article N times.
8249 If N is negative, go to ancestor -N instead.
8250 The difference between N and the number of articles fetched is returned."
8251 (interactive "p")
8252 (let ((skip 1)
8253 error header ref)
8254 (when (not (natnump n))
8255 (setq skip (abs n)
8256 n 1))
8257 (while (and (> n 0)
8258 (not error))
8259 (setq header (gnus-summary-article-header))
8260 (if (and (eq (mail-header-number header)
8261 (cdr gnus-article-current))
8262 (equal gnus-newsgroup-name
8263 (car gnus-article-current)))
8264 ;; If we try to find the parent of the currently
8265 ;; displayed article, then we take a look at the actual
8266 ;; References header, since this is slightly more
8267 ;; reliable than the References field we got from the
8268 ;; server.
8269 (save-excursion
8270 (set-buffer gnus-original-article-buffer)
8271 (nnheader-narrow-to-headers)
8272 (unless (setq ref (message-fetch-field "references"))
8273 (when (setq ref (message-fetch-field "in-reply-to"))
8274 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8275 (widen))
8276 (setq ref
8277 ;; It's not the current article, so we take a bet on
8278 ;; the value we got from the server.
8279 (mail-header-references header)))
8280 (if (and ref
8281 (not (equal ref "")))
8282 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8283 (gnus-message 1 "Couldn't find parent"))
8284 (gnus-message 1 "No references in article %d"
8285 (gnus-summary-article-number))
8286 (setq error t))
8287 (decf n))
8288 (gnus-summary-position-point)
8289 n))
8290
8291 (defun gnus-summary-refer-references ()
8292 "Fetch all articles mentioned in the References header.
8293 Return the number of articles fetched."
8294 (interactive)
8295 (let ((ref (mail-header-references (gnus-summary-article-header)))
8296 (current (gnus-summary-article-number))
8297 (n 0))
8298 (if (or (not ref)
8299 (equal ref ""))
8300 (error "No References in the current article")
8301 ;; For each Message-ID in the References header...
8302 (while (string-match "<[^>]*>" ref)
8303 (incf n)
8304 ;; ... fetch that article.
8305 (gnus-summary-refer-article
8306 (prog1 (match-string 0 ref)
8307 (setq ref (substring ref (match-end 0))))))
8308 (gnus-summary-goto-subject current)
8309 (gnus-summary-position-point)
8310 n)))
8311
8312 (defun gnus-summary-refer-thread (&optional limit)
8313 "Fetch all articles in the current thread.
8314 If LIMIT (the numerical prefix), fetch that many old headers instead
8315 of what's specified by the `gnus-refer-thread-limit' variable."
8316 (interactive "P")
8317 (let ((id (mail-header-id (gnus-summary-article-header)))
8318 (limit (if limit (prefix-numeric-value limit)
8319 gnus-refer-thread-limit)))
8320 (unless (eq gnus-fetch-old-headers 'invisible)
8321 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8322 ;; Retrieve the headers and read them in.
8323 (if (eq (if (numberp limit)
8324 (gnus-retrieve-headers
8325 (list (min
8326 (+ (mail-header-number
8327 (gnus-summary-article-header))
8328 limit)
8329 gnus-newsgroup-end))
8330 gnus-newsgroup-name (* limit 2))
8331 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8332 ;; headers.
8333 (gnus-retrieve-headers (list gnus-newsgroup-end)
8334 gnus-newsgroup-name limit))
8335 'nov)
8336 (gnus-build-all-threads)
8337 (error "Can't fetch thread from back ends that don't support NOV"))
8338 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8339 (gnus-summary-limit-include-thread id)))
8340
8341 (defun gnus-summary-refer-article (message-id)
8342 "Fetch an article specified by MESSAGE-ID."
8343 (interactive "sMessage-ID: ")
8344 (when (and (stringp message-id)
8345 (not (zerop (length message-id))))
8346 (setq message-id (gnus-replace-in-string message-id " " ""))
8347 ;; Construct the correct Message-ID if necessary.
8348 ;; Suggested by tale@pawl.rpi.edu.
8349 (unless (string-match "^<" message-id)
8350 (setq message-id (concat "<" message-id)))
8351 (unless (string-match ">$" message-id)
8352 (setq message-id (concat message-id ">")))
8353 ;; People often post MIDs from URLs, so unhex it:
8354 (unless (string-match "@" message-id)
8355 (setq message-id (gnus-url-unhex-string message-id)))
8356 (let* ((header (gnus-id-to-header message-id))
8357 (sparse (and header
8358 (gnus-summary-article-sparse-p
8359 (mail-header-number header))
8360 (memq (mail-header-number header)
8361 gnus-newsgroup-limit)))
8362 number)
8363 (cond
8364 ;; If the article is present in the buffer we just go to it.
8365 ((and header
8366 (or (not (gnus-summary-article-sparse-p
8367 (mail-header-number header)))
8368 sparse))
8369 (prog1
8370 (gnus-summary-goto-article
8371 (mail-header-number header) nil t)
8372 (when sparse
8373 (gnus-summary-update-article (mail-header-number header)))))
8374 (t
8375 ;; We fetch the article.
8376 (catch 'found
8377 (dolist (gnus-override-method (gnus-refer-article-methods))
8378 (when (and (gnus-check-server gnus-override-method)
8379 ;; Fetch the header,
8380 (setq number (gnus-summary-insert-subject message-id)))
8381 ;; and display the article.
8382 (gnus-summary-select-article nil nil nil number)
8383 (throw 'found t)))
8384 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8385
8386 (defun gnus-refer-article-methods ()
8387 "Return a list of referable methods."
8388 (cond
8389 ;; No method, so we default to current and native.
8390 ((null gnus-refer-article-method)
8391 (list gnus-current-select-method gnus-select-method))
8392 ;; Current.
8393 ((eq 'current gnus-refer-article-method)
8394 (list gnus-current-select-method))
8395 ;; List of select methods.
8396 ((not (and (symbolp (car gnus-refer-article-method))
8397 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8398 (let (out)
8399 (dolist (method gnus-refer-article-method)
8400 (push (if (eq 'current method)
8401 gnus-current-select-method
8402 method)
8403 out))
8404 (nreverse out)))
8405 ;; One single select method.
8406 (t
8407 (list gnus-refer-article-method))))
8408
8409 (defun gnus-summary-edit-parameters ()
8410 "Edit the group parameters of the current group."
8411 (interactive)
8412 (gnus-group-edit-group gnus-newsgroup-name 'params))
8413
8414 (defun gnus-summary-customize-parameters ()
8415 "Customize the group parameters of the current group."
8416 (interactive)
8417 (gnus-group-customize gnus-newsgroup-name))
8418
8419 (defun gnus-summary-enter-digest-group (&optional force)
8420 "Enter an nndoc group based on the current article.
8421 If FORCE, force a digest interpretation. If not, try
8422 to guess what the document format is."
8423 (interactive "P")
8424 (let ((conf gnus-current-window-configuration))
8425 (save-window-excursion
8426 (save-excursion
8427 (let (gnus-article-prepare-hook
8428 gnus-display-mime-function
8429 gnus-break-pages)
8430 (gnus-summary-select-article))))
8431 (setq gnus-current-window-configuration conf)
8432 (let* ((name (format "%s-%d"
8433 (gnus-group-prefixed-name
8434 gnus-newsgroup-name (list 'nndoc ""))
8435 (save-excursion
8436 (set-buffer gnus-summary-buffer)
8437 gnus-current-article)))
8438 (ogroup gnus-newsgroup-name)
8439 (params (append (gnus-info-params (gnus-get-info ogroup))
8440 (list (cons 'to-group ogroup))
8441 (list (cons 'parent-group ogroup))
8442 (list (cons 'save-article-group ogroup))))
8443 (case-fold-search t)
8444 (buf (current-buffer))
8445 dig to-address)
8446 (save-excursion
8447 (set-buffer gnus-original-article-buffer)
8448 ;; Have the digest group inherit the main mail address of
8449 ;; the parent article.
8450 (when (setq to-address (or (gnus-fetch-field "reply-to")
8451 (gnus-fetch-field "from")))
8452 (setq params (append
8453 (list (cons 'to-address
8454 (funcall gnus-decode-encoded-word-function
8455 to-address))))))
8456 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8457 (insert-buffer-substring gnus-original-article-buffer)
8458 ;; Remove lines that may lead nndoc to misinterpret the
8459 ;; document type.
8460 (narrow-to-region
8461 (goto-char (point-min))
8462 (or (search-forward "\n\n" nil t) (point)))
8463 (goto-char (point-min))
8464 (delete-matching-lines "^Path:\\|^From ")
8465 (widen))
8466 (unwind-protect
8467 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8468 (gnus-newsgroup-ephemeral-ignored-charsets
8469 gnus-newsgroup-ignored-charsets))
8470 (gnus-group-read-ephemeral-group
8471 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8472 (nndoc-article-type
8473 ,(if force 'mbox 'guess)))
8474 t nil nil nil
8475 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8476 "ADAPT")))))
8477 ;; Make all postings to this group go to the parent group.
8478 (nconc (gnus-info-params (gnus-get-info name))
8479 params)
8480 ;; Couldn't select this doc group.
8481 (switch-to-buffer buf)
8482 (gnus-set-global-variables)
8483 (gnus-configure-windows 'summary)
8484 (gnus-message 3 "Article couldn't be entered?"))
8485 (kill-buffer dig)))))
8486
8487 (defun gnus-summary-read-document (n)
8488 "Open a new group based on the current article(s).
8489 This will allow you to read digests and other similar
8490 documents as newsgroups.
8491 Obeys the standard process/prefix convention."
8492 (interactive "P")
8493 (let* ((articles (gnus-summary-work-articles n))
8494 (ogroup gnus-newsgroup-name)
8495 (params (append (gnus-info-params (gnus-get-info ogroup))
8496 (list (cons 'to-group ogroup))))
8497 article group egroup groups vgroup)
8498 (while (setq article (pop articles))
8499 (setq group (format "%s-%d" gnus-newsgroup-name article))
8500 (gnus-summary-remove-process-mark article)
8501 (when (gnus-summary-display-article article)
8502 (save-excursion
8503 (with-temp-buffer
8504 (insert-buffer-substring gnus-original-article-buffer)
8505 ;; Remove some headers that may lead nndoc to make
8506 ;; the wrong guess.
8507 (message-narrow-to-head)
8508 (goto-char (point-min))
8509 (delete-matching-lines "^\\(Path\\):\\|^From ")
8510 (widen)
8511 (if (setq egroup
8512 (gnus-group-read-ephemeral-group
8513 group `(nndoc ,group (nndoc-address ,(current-buffer))
8514 (nndoc-article-type guess))
8515 t nil t))
8516 (progn
8517 ;; Make all postings to this group go to the parent group.
8518 (nconc (gnus-info-params (gnus-get-info egroup))
8519 params)
8520 (push egroup groups))
8521 ;; Couldn't select this doc group.
8522 (gnus-error 3 "Article couldn't be entered"))))))
8523 ;; Now we have selected all the documents.
8524 (cond
8525 ((not groups)
8526 (error "None of the articles could be interpreted as documents"))
8527 ((gnus-group-read-ephemeral-group
8528 (setq vgroup (format
8529 "nnvirtual:%s-%s" gnus-newsgroup-name
8530 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8531 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8532 t
8533 (cons (current-buffer) 'summary)))
8534 (t
8535 (error "Couldn't select virtual nndoc group")))))
8536
8537 (defun gnus-summary-isearch-article (&optional regexp-p)
8538 "Do incremental search forward on the current article.
8539 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8540 (interactive "P")
8541 (gnus-summary-select-article)
8542 (gnus-configure-windows 'article)
8543 (gnus-eval-in-buffer-window gnus-article-buffer
8544 (save-restriction
8545 (widen)
8546 (isearch-forward regexp-p))))
8547
8548 (defun gnus-summary-search-article-forward (regexp &optional backward)
8549 "Search for an article containing REGEXP forward.
8550 If BACKWARD, search backward instead."
8551 (interactive
8552 (list (read-string
8553 (format "Search article %s (regexp%s): "
8554 (if current-prefix-arg "backward" "forward")
8555 (if gnus-last-search-regexp
8556 (concat ", default " gnus-last-search-regexp)
8557 "")))
8558 current-prefix-arg))
8559 (if (string-equal regexp "")
8560 (setq regexp (or gnus-last-search-regexp ""))
8561 (setq gnus-last-search-regexp regexp)
8562 (setq gnus-article-before-search gnus-current-article))
8563 ;; Intentionally set gnus-last-article.
8564 (setq gnus-last-article gnus-article-before-search)
8565 (let ((gnus-last-article gnus-last-article))
8566 (if (gnus-summary-search-article regexp backward)
8567 (gnus-summary-show-thread)
8568 (signal 'search-failed (list regexp)))))
8569
8570 (defun gnus-summary-search-article-backward (regexp)
8571 "Search for an article containing REGEXP backward."
8572 (interactive
8573 (list (read-string
8574 (format "Search article backward (regexp%s): "
8575 (if gnus-last-search-regexp
8576 (concat ", default " gnus-last-search-regexp)
8577 "")))))
8578 (gnus-summary-search-article-forward regexp 'backward))
8579
8580 (defun gnus-summary-search-article (regexp &optional backward)
8581 "Search for an article containing REGEXP.
8582 Optional argument BACKWARD means do search for backward.
8583 `gnus-select-article-hook' is not called during the search."
8584 ;; We have to require this here to make sure that the following
8585 ;; dynamic binding isn't shadowed by autoloading.
8586 (require 'gnus-async)
8587 (require 'gnus-art)
8588 (let ((gnus-select-article-hook nil) ;Disable hook.
8589 (gnus-article-prepare-hook nil)
8590 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8591 (gnus-use-article-prefetch nil)
8592 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8593 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8594 (gnus-visual nil)
8595 (gnus-keep-backlog nil)
8596 (gnus-break-pages nil)
8597 (gnus-summary-display-arrow nil)
8598 (gnus-updated-mode-lines nil)
8599 (gnus-auto-center-summary nil)
8600 (sum (current-buffer))
8601 (gnus-display-mime-function nil)
8602 (found nil)
8603 point)
8604 (gnus-save-hidden-threads
8605 (gnus-summary-select-article)
8606 (set-buffer gnus-article-buffer)
8607 (goto-char (window-point (get-buffer-window (current-buffer))))
8608 (when backward
8609 (forward-line -1))
8610 (while (not found)
8611 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8612 (if (if backward
8613 (re-search-backward regexp nil t)
8614 (re-search-forward regexp nil t))
8615 ;; We found the regexp.
8616 (progn
8617 (setq found 'found)
8618 (beginning-of-line)
8619 (set-window-start
8620 (get-buffer-window (current-buffer))
8621 (point))
8622 (forward-line 1)
8623 (set-window-point
8624 (get-buffer-window (current-buffer))
8625 (point))
8626 (set-buffer sum)
8627 (setq point (point)))
8628 ;; We didn't find it, so we go to the next article.
8629 (set-buffer sum)
8630 (setq found 'not)
8631 (while (eq found 'not)
8632 (if (not (if backward (gnus-summary-find-prev)
8633 (gnus-summary-find-next)))
8634 ;; No more articles.
8635 (setq found t)
8636 ;; Select the next article and adjust point.
8637 (unless (gnus-summary-article-sparse-p
8638 (gnus-summary-article-number))
8639 (setq found nil)
8640 (gnus-summary-select-article)
8641 (set-buffer gnus-article-buffer)
8642 (widen)
8643 (goto-char (if backward (point-max) (point-min))))))))
8644 (gnus-message 7 ""))
8645 ;; Return whether we found the regexp.
8646 (when (eq found 'found)
8647 (goto-char point)
8648 (gnus-summary-show-thread)
8649 (gnus-summary-goto-subject gnus-current-article)
8650 (gnus-summary-position-point)
8651 t)))
8652
8653 (defun gnus-find-matching-articles (header regexp)
8654 "Return a list of all articles that match REGEXP on HEADER.
8655 This search includes all articles in the current group that Gnus has
8656 fetched headers for, whether they are displayed or not."
8657 (let ((articles nil)
8658 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8659 (case-fold-search t))
8660 (dolist (header gnus-newsgroup-headers)
8661 (when (string-match regexp (funcall func header))
8662 (push (mail-header-number header) articles)))
8663 (nreverse articles)))
8664
8665 (defun gnus-summary-find-matching (header regexp &optional backward unread
8666 not-case-fold not-matching)
8667 "Return a list of all articles that match REGEXP on HEADER.
8668 The search stars on the current article and goes forwards unless
8669 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8670 If UNREAD is non-nil, only unread articles will
8671 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8672 in the comparisons. If NOT-MATCHING, return a list of all articles that
8673 not match REGEXP on HEADER."
8674 (let ((case-fold-search (not not-case-fold))
8675 articles d func)
8676 (if (consp header)
8677 (if (eq (car header) 'extra)
8678 (setq func
8679 `(lambda (h)
8680 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8681 "")))
8682 (error "%s is an invalid header" header))
8683 (unless (fboundp (intern (concat "mail-header-" header)))
8684 (error "%s is not a valid header" header))
8685 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8686 (dolist (d (if (eq backward 'all)
8687 gnus-newsgroup-data
8688 (gnus-data-find-list
8689 (gnus-summary-article-number)
8690 (gnus-data-list backward))))
8691 (when (and (or (not unread) ; We want all articles...
8692 (gnus-data-unread-p d)) ; Or just unreads.
8693 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8694 (if not-matching
8695 (not (string-match
8696 regexp
8697 (funcall func (gnus-data-header d))))
8698 (string-match regexp
8699 (funcall func (gnus-data-header d)))))
8700 (push (gnus-data-number d) articles))) ; Success!
8701 (nreverse articles)))
8702
8703 (defun gnus-summary-execute-command (header regexp command &optional backward)
8704 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8705 If HEADER is an empty string (or nil), the match is done on the entire
8706 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8707 (interactive
8708 (list (let ((completion-ignore-case t))
8709 (completing-read
8710 "Header name: "
8711 (mapcar (lambda (header) (list (format "%s" header)))
8712 (append
8713 '("Number" "Subject" "From" "Lines" "Date"
8714 "Message-ID" "Xref" "References" "Body")
8715 gnus-extra-headers))
8716 nil 'require-match))
8717 (read-string "Regexp: ")
8718 (read-key-sequence "Command: ")
8719 current-prefix-arg))
8720 (when (equal header "Body")
8721 (setq header ""))
8722 ;; Hidden thread subtrees must be searched as well.
8723 (gnus-summary-show-all-threads)
8724 ;; We don't want to change current point nor window configuration.
8725 (save-excursion
8726 (save-window-excursion
8727 (let (gnus-visual
8728 gnus-treat-strip-trailing-blank-lines
8729 gnus-treat-strip-leading-blank-lines
8730 gnus-treat-strip-multiple-blank-lines
8731 gnus-treat-hide-boring-headers
8732 gnus-treat-fold-newsgroups
8733 gnus-article-prepare-hook)
8734 (gnus-message 6 "Executing %s..." (key-description command))
8735 ;; We'd like to execute COMMAND interactively so as to give arguments.
8736 (gnus-execute header regexp
8737 `(call-interactively ',(key-binding command))
8738 backward)
8739 (gnus-message 6 "Executing %s...done" (key-description command))))))
8740
8741 (defun gnus-summary-beginning-of-article ()
8742 "Scroll the article back to the beginning."
8743 (interactive)
8744 (gnus-summary-select-article)
8745 (gnus-configure-windows 'article)
8746 (gnus-eval-in-buffer-window gnus-article-buffer
8747 (widen)
8748 (goto-char (point-min))
8749 (when gnus-break-pages
8750 (gnus-narrow-to-page))))
8751
8752 (defun gnus-summary-end-of-article ()
8753 "Scroll to the end of the article."
8754 (interactive)
8755 (gnus-summary-select-article)
8756 (gnus-configure-windows 'article)
8757 (gnus-eval-in-buffer-window gnus-article-buffer
8758 (widen)
8759 (goto-char (point-max))
8760 (recenter -3)
8761 (when gnus-break-pages
8762 (when (re-search-backward page-delimiter nil t)
8763 (narrow-to-region (match-end 0) (point-max)))
8764 (gnus-narrow-to-page))))
8765
8766 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8767 "Truncate to LEN and quote all \"(\"'s in STRING."
8768 (gnus-replace-in-string (if (and len (> (length string) len))
8769 (substring string 0 len)
8770 string)
8771 "[()]" "\\\\\\&"))
8772
8773 (defun gnus-summary-print-article (&optional filename n)
8774 "Generate and print a PostScript image of the process-marked (mail) articles.
8775
8776 If used interactively, print the current article if none are
8777 process-marked. With prefix arg, prompt the user for the name of the
8778 file to save in.
8779
8780 When used from Lisp, accept two optional args FILENAME and N. N means
8781 to print the next N articles. If N is negative, print the N previous
8782 articles. If N is nil and articles have been marked with the process
8783 mark, print these instead.
8784
8785 If the optional first argument FILENAME is nil, send the image to the
8786 printer. If FILENAME is a string, save the PostScript image in a file with
8787 that name. If FILENAME is a number, prompt the user for the name of the file
8788 to save in."
8789 (interactive (list (ps-print-preprint current-prefix-arg)))
8790 (dolist (article (gnus-summary-work-articles n))
8791 (gnus-summary-select-article nil nil 'pseudo article)
8792 (gnus-eval-in-buffer-window gnus-article-buffer
8793 (gnus-print-buffer))
8794 (gnus-summary-remove-process-mark article))
8795 (ps-despool filename))
8796
8797 (defun gnus-print-buffer ()
8798 (let ((buffer (generate-new-buffer " *print*")))
8799 (unwind-protect
8800 (progn
8801 (copy-to-buffer buffer (point-min) (point-max))
8802 (set-buffer buffer)
8803 (gnus-remove-text-with-property 'gnus-decoration)
8804 (when (gnus-visual-p 'article-highlight 'highlight)
8805 ;; Copy-to-buffer doesn't copy overlay. So redo
8806 ;; highlight.
8807 (let ((gnus-article-buffer buffer))
8808 (gnus-article-highlight-citation t)
8809 (gnus-article-highlight-signature)
8810 (gnus-article-emphasize)
8811 (gnus-article-delete-invisible-text)))
8812 (let ((ps-left-header
8813 (list
8814 (concat "("
8815 (gnus-summary-print-truncate-and-quote
8816 (mail-header-subject gnus-current-headers)
8817 66) ")")
8818 (concat "("
8819 (gnus-summary-print-truncate-and-quote
8820 (mail-header-from gnus-current-headers)
8821 45) ")")))
8822 (ps-right-header
8823 (list
8824 "/pagenumberstring load"
8825 (concat "("
8826 (mail-header-date gnus-current-headers) ")"))))
8827 (gnus-run-hooks 'gnus-ps-print-hook)
8828 (save-excursion
8829 (if window-system
8830 (ps-spool-buffer-with-faces)
8831 (ps-spool-buffer)))))
8832 (kill-buffer buffer))))
8833
8834 (defun gnus-summary-show-article (&optional arg)
8835 "Force redisplaying of the current article.
8836 If ARG (the prefix) is a number, show the article with the charset
8837 defined in `gnus-summary-show-article-charset-alist', or the charset
8838 input.
8839 If ARG (the prefix) is non-nil and not a number, show the raw article
8840 without any article massaging functions being run. Normally, the key
8841 strokes are `C-u g'."
8842 (interactive "P")
8843 (cond
8844 ((numberp arg)
8845 (gnus-summary-show-article t)
8846 (let ((gnus-newsgroup-charset
8847 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8848 (mm-read-coding-system
8849 "View as charset: " ;; actually it is coding system.
8850 (save-excursion
8851 (set-buffer gnus-article-buffer)
8852 (mm-detect-coding-region (point) (point-max))))))
8853 (gnus-newsgroup-ignored-charsets 'gnus-all))
8854 (gnus-summary-select-article nil 'force)
8855 (let ((deps gnus-newsgroup-dependencies)
8856 head header lines)
8857 (save-excursion
8858 (set-buffer gnus-original-article-buffer)
8859 (save-restriction
8860 (message-narrow-to-head)
8861 (setq head (buffer-string))
8862 (goto-char (point-min))
8863 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8864 (goto-char (point-max))
8865 (widen)
8866 (setq lines (1- (count-lines (point) (point-max))))))
8867 (with-temp-buffer
8868 (insert (format "211 %d Article retrieved.\n"
8869 (cdr gnus-article-current)))
8870 (insert head)
8871 (if lines (insert (format "Lines: %d\n" lines)))
8872 (insert ".\n")
8873 (let ((nntp-server-buffer (current-buffer)))
8874 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8875 (gnus-data-set-header
8876 (gnus-data-find (cdr gnus-article-current))
8877 header)
8878 (gnus-summary-update-article-line
8879 (cdr gnus-article-current) header)
8880 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8881 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8882 ((not arg)
8883 ;; Select the article the normal way.
8884 (gnus-summary-select-article nil 'force))
8885 (t
8886 ;; We have to require this here to make sure that the following
8887 ;; dynamic binding isn't shadowed by autoloading.
8888 (require 'gnus-async)
8889 (require 'gnus-art)
8890 ;; Bind the article treatment functions to nil.
8891 (let ((gnus-have-all-headers t)
8892 gnus-article-prepare-hook
8893 gnus-article-decode-hook
8894 gnus-display-mime-function
8895 gnus-break-pages)
8896 ;; Destroy any MIME parts.
8897 (when (gnus-buffer-live-p gnus-article-buffer)
8898 (save-excursion
8899 (set-buffer gnus-article-buffer)
8900 (mm-destroy-parts gnus-article-mime-handles)
8901 ;; Set it to nil for safety reason.
8902 (setq gnus-article-mime-handle-alist nil)
8903 (setq gnus-article-mime-handles nil)))
8904 (gnus-summary-select-article nil 'force))))
8905 (gnus-summary-goto-subject gnus-current-article)
8906 (gnus-summary-position-point))
8907
8908 (defun gnus-summary-show-raw-article ()
8909 "Show the raw article without any article massaging functions being run."
8910 (interactive)
8911 (gnus-summary-show-article t))
8912
8913 (defun gnus-summary-verbose-headers (&optional arg)
8914 "Toggle permanent full header display.
8915 If ARG is a positive number, turn header display on.
8916 If ARG is a negative number, turn header display off."
8917 (interactive "P")
8918 (setq gnus-show-all-headers
8919 (cond ((or (not (numberp arg))
8920 (zerop arg))
8921 (not gnus-show-all-headers))
8922 ((natnump arg)
8923 t)))
8924 (gnus-summary-show-article))
8925
8926 (defun gnus-summary-toggle-header (&optional arg)
8927 "Show the headers if they are hidden, or hide them if they are shown.
8928 If ARG is a positive number, show the entire header.
8929 If ARG is a negative number, hide the unwanted header lines."
8930 (interactive "P")
8931 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8932 (get-buffer-window gnus-article-buffer t))))
8933 (with-current-buffer gnus-article-buffer
8934 (widen)
8935 (article-narrow-to-head)
8936 (let* ((buffer-read-only nil)
8937 (inhibit-point-motion-hooks t)
8938 (hidden (if (numberp arg)
8939 (>= arg 0)
8940 (or (not (looking-at "[^ \t\n]+:"))
8941 (gnus-article-hidden-text-p 'headers))))
8942 s e)
8943 (delete-region (point-min) (point-max))
8944 (with-current-buffer gnus-original-article-buffer
8945 (goto-char (setq s (point-min)))
8946 (setq e (if (search-forward "\n\n" nil t)
8947 (1- (point))
8948 (point-max))))
8949 (insert-buffer-substring gnus-original-article-buffer s e)
8950 (run-hooks 'gnus-article-decode-hook)
8951 (if hidden
8952 (let ((gnus-treat-hide-headers nil)
8953 (gnus-treat-hide-boring-headers nil))
8954 (gnus-delete-wash-type 'headers)
8955 (gnus-treat-article 'head))
8956 (gnus-treat-article 'head))
8957 (widen)
8958 (if window
8959 (set-window-start window (goto-char (point-min))))
8960 (if gnus-break-pages
8961 (gnus-narrow-to-page)
8962 (when (gnus-visual-p 'page-marker)
8963 (let ((buffer-read-only nil))
8964 (gnus-remove-text-with-property 'gnus-prev)
8965 (gnus-remove-text-with-property 'gnus-next))))
8966 (gnus-set-mode-line 'article)))))
8967
8968 (defun gnus-summary-show-all-headers ()
8969 "Make all header lines visible."
8970 (interactive)
8971 (gnus-summary-toggle-header 1))
8972
8973 (defun gnus-summary-caesar-message (&optional arg)
8974 "Caesar rotate the current article by 13.
8975 The numerical prefix specifies how many places to rotate each letter
8976 forward."
8977 (interactive "P")
8978 (gnus-summary-select-article)
8979 (let ((mail-header-separator ""))
8980 (gnus-eval-in-buffer-window gnus-article-buffer
8981 (save-restriction
8982 (widen)
8983 (let ((start (window-start))
8984 buffer-read-only)
8985 (message-caesar-buffer-body arg)
8986 (set-window-start (get-buffer-window (current-buffer)) start)))))
8987 ;; Create buttons and stuff...
8988 (gnus-treat-article nil))
8989
8990 (autoload 'unmorse-region "morse"
8991 "Convert morse coded text in region to ordinary ASCII text."
8992 t)
8993
8994 (defun gnus-summary-morse-message (&optional arg)
8995 "Morse decode the current article."
8996 (interactive "P")
8997 (gnus-summary-select-article)
8998 (let ((mail-header-separator ""))
8999 (gnus-eval-in-buffer-window gnus-article-buffer
9000 (save-excursion
9001 (save-restriction
9002 (widen)
9003 (let ((pos (window-start))
9004 buffer-read-only)
9005 (goto-char (point-min))
9006 (when (message-goto-body)
9007 (gnus-narrow-to-body))
9008 (goto-char (point-min))
9009 (while (re-search-forward "·" (point-max) t)
9010 (replace-match "."))
9011 (unmorse-region (point-min) (point-max))
9012 (widen)
9013 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9014
9015 (defun gnus-summary-stop-page-breaking ()
9016 "Stop page breaking in the current article."
9017 (interactive)
9018 (gnus-summary-select-article)
9019 (gnus-eval-in-buffer-window gnus-article-buffer
9020 (widen)
9021 (when (gnus-visual-p 'page-marker)
9022 (let ((buffer-read-only nil))
9023 (gnus-remove-text-with-property 'gnus-prev)
9024 (gnus-remove-text-with-property 'gnus-next))
9025 (setq gnus-page-broken nil))))
9026
9027 (defun gnus-summary-move-article (&optional n to-newsgroup
9028 select-method action)
9029 "Move the current article to a different newsgroup.
9030 If N is a positive number, move the N next articles.
9031 If N is a negative number, move the N previous articles.
9032 If N is nil and any articles have been marked with the process mark,
9033 move those articles instead.
9034 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9035 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9036 re-spool using this method.
9037
9038 When called interactively with TO-NEWSGROUP being nil, the value of
9039 the variable `gnus-move-split-methods' is used for finding a default
9040 for the target newsgroup.
9041
9042 For this function to work, both the current newsgroup and the
9043 newsgroup that you want to move to have to support the `request-move'
9044 and `request-accept' functions.
9045
9046 ACTION can be either `move' (the default), `crosspost' or `copy'."
9047 (interactive "P")
9048 (unless action
9049 (setq action 'move))
9050 ;; Check whether the source group supports the required functions.
9051 (cond ((and (eq action 'move)
9052 (not (gnus-check-backend-function
9053 'request-move-article gnus-newsgroup-name)))
9054 (error "The current group does not support article moving"))
9055 ((and (eq action 'crosspost)
9056 (not (gnus-check-backend-function
9057 'request-replace-article gnus-newsgroup-name)))
9058 (error "The current group does not support article editing")))
9059 (let ((articles (gnus-summary-work-articles n))
9060 (prefix (if (gnus-check-backend-function
9061 'request-move-article gnus-newsgroup-name)
9062 (gnus-group-real-prefix gnus-newsgroup-name)
9063 ""))
9064 (names '((move "Move" "Moving")
9065 (copy "Copy" "Copying")
9066 (crosspost "Crosspost" "Crossposting")))
9067 (copy-buf (save-excursion
9068 (nnheader-set-temp-buffer " *copy article*")))
9069 art-group to-method new-xref article to-groups)
9070 (unless (assq action names)
9071 (error "Unknown action %s" action))
9072 ;; Read the newsgroup name.
9073 (when (and (not to-newsgroup)
9074 (not select-method))
9075 (if (and gnus-move-split-methods
9076 (not
9077 (and (memq gnus-current-article articles)
9078 (gnus-buffer-live-p gnus-original-article-buffer))))
9079 ;; When `gnus-move-split-methods' is non-nil, we have to
9080 ;; select an article to give `gnus-read-move-group-name' an
9081 ;; opportunity to suggest an appropriate default. However,
9082 ;; we needn't render or mark the article.
9083 (let ((gnus-display-mime-function nil)
9084 (gnus-article-prepare-hook nil)
9085 (gnus-mark-article-hook nil))
9086 (gnus-summary-select-article nil nil nil (car articles))))
9087 (setq to-newsgroup
9088 (gnus-read-move-group-name
9089 (cadr (assq action names))
9090 (symbol-value (intern (format "gnus-current-%s-group" action)))
9091 articles prefix))
9092 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9093 (setq to-method (or select-method
9094 (gnus-server-to-method
9095 (gnus-group-method to-newsgroup))))
9096 ;; Check the method we are to move this article to...
9097 (unless (gnus-check-backend-function
9098 'request-accept-article (car to-method))
9099 (error "%s does not support article copying" (car to-method)))
9100 (unless (gnus-check-server to-method)
9101 (error "Can't open server %s" (car to-method)))
9102 (gnus-message 6 "%s to %s: %s..."
9103 (caddr (assq action names))
9104 (or (car select-method) to-newsgroup) articles)
9105 (while articles
9106 (setq article (pop articles))
9107 (setq
9108 art-group
9109 (cond
9110 ;; Move the article.
9111 ((eq action 'move)
9112 ;; Remove this article from future suppression.
9113 (gnus-dup-unsuppress-article article)
9114 (gnus-request-move-article
9115 article ; Article to move
9116 gnus-newsgroup-name ; From newsgroup
9117 (nth 1 (gnus-find-method-for-group
9118 gnus-newsgroup-name)) ; Server
9119 (list 'gnus-request-accept-article
9120 to-newsgroup (list 'quote select-method)
9121 (not articles) t) ; Accept form
9122 (not articles))) ; Only save nov last time
9123 ;; Copy the article.
9124 ((eq action 'copy)
9125 (save-excursion
9126 (set-buffer copy-buf)
9127 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9128 (gnus-request-accept-article
9129 to-newsgroup select-method (not articles) t))))
9130 ;; Crosspost the article.
9131 ((eq action 'crosspost)
9132 (let ((xref (message-tokenize-header
9133 (mail-header-xref (gnus-summary-article-header article))
9134 " ")))
9135 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9136 ":" (number-to-string article)))
9137 (unless xref
9138 (setq xref (list (system-name))))
9139 (setq new-xref
9140 (concat
9141 (mapconcat 'identity
9142 (delete "Xref:" (delete new-xref xref))
9143 " ")
9144 " " new-xref))
9145 (save-excursion
9146 (set-buffer copy-buf)
9147 ;; First put the article in the destination group.
9148 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9149 (when (consp (setq art-group
9150 (gnus-request-accept-article
9151 to-newsgroup select-method (not articles))))
9152 (setq new-xref (concat new-xref " " (car art-group)
9153 ":"
9154 (number-to-string (cdr art-group))))
9155 ;; Now we have the new Xrefs header, so we insert
9156 ;; it and replace the new article.
9157 (nnheader-replace-header "Xref" new-xref)
9158 (gnus-request-replace-article
9159 (cdr art-group) to-newsgroup (current-buffer))
9160 art-group))))))
9161 (cond
9162 ((not art-group)
9163 (gnus-message 1 "Couldn't %s article %s: %s"
9164 (cadr (assq action names)) article
9165 (nnheader-get-report (car to-method))))
9166 ((eq art-group 'junk)
9167 (when (eq action 'move)
9168 (gnus-summary-mark-article article gnus-canceled-mark)
9169 (gnus-message 4 "Deleted article %s" article)
9170 ;; run the delete hook
9171 (run-hook-with-args 'gnus-summary-article-delete-hook
9172 action
9173 (gnus-data-header
9174 (assoc article (gnus-data-list nil)))
9175 gnus-newsgroup-name nil
9176 select-method)))
9177 (t
9178 (let* ((pto-group (gnus-group-prefixed-name
9179 (car art-group) to-method))
9180 (entry
9181 (gnus-gethash pto-group gnus-newsrc-hashtb))
9182 (info (nth 2 entry))
9183 (to-group (gnus-info-group info))
9184 to-marks)
9185 ;; Update the group that has been moved to.
9186 (when (and info
9187 (memq action '(move copy)))
9188 (unless (member to-group to-groups)
9189 (push to-group to-groups))
9190
9191 (unless (memq article gnus-newsgroup-unreads)
9192 (push 'read to-marks)
9193 (gnus-info-set-read
9194 info (gnus-add-to-range (gnus-info-read info)
9195 (list (cdr art-group)))))
9196
9197 ;; See whether the article is to be put in the cache.
9198 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9199 gnus-article-mark-lists
9200 (delete '(expirable . expire)
9201 (copy-sequence gnus-article-mark-lists))))
9202 (to-article (cdr art-group)))
9203
9204 ;; Enter the article into the cache in the new group,
9205 ;; if that is required.
9206 (when gnus-use-cache
9207 (gnus-cache-possibly-enter-article
9208 to-group to-article
9209 (memq article gnus-newsgroup-marked)
9210 (memq article gnus-newsgroup-dormant)
9211 (memq article gnus-newsgroup-unreads)))
9212
9213 (when gnus-preserve-marks
9214 ;; Copy any marks over to the new group.
9215 (when (and (equal to-group gnus-newsgroup-name)
9216 (not (memq article gnus-newsgroup-unreads)))
9217 ;; Mark this article as read in this group.
9218 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9219 (setcdr (gnus-active to-group) to-article)
9220 (setcdr gnus-newsgroup-active to-article))
9221
9222 (while marks
9223 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9224 (when (memq article (symbol-value
9225 (intern (format "gnus-newsgroup-%s"
9226 (caar marks)))))
9227 (push (cdar marks) to-marks)
9228 ;; If the other group is the same as this group,
9229 ;; then we have to add the mark to the list.
9230 (when (equal to-group gnus-newsgroup-name)
9231 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9232 (cons to-article
9233 (symbol-value
9234 (intern (format "gnus-newsgroup-%s"
9235 (caar marks)))))))
9236 ;; Copy the marks to other group.
9237 (gnus-add-marked-articles
9238 to-group (cdar marks) (list to-article) info)))
9239 (setq marks (cdr marks)))
9240
9241 (gnus-request-set-mark
9242 to-group (list (list (list to-article) 'add to-marks))))
9243
9244 (gnus-dribble-enter
9245 (concat "(gnus-group-set-info '"
9246 (gnus-prin1-to-string (gnus-get-info to-group))
9247 ")"))))
9248
9249 ;; Update the Xref header in this article to point to
9250 ;; the new crossposted article we have just created.
9251 (when (eq action 'crosspost)
9252 (save-excursion
9253 (set-buffer copy-buf)
9254 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9255 (nnheader-replace-header "Xref" new-xref)
9256 (gnus-request-replace-article
9257 article gnus-newsgroup-name (current-buffer))))
9258
9259 ;; run the move/copy/crosspost/respool hook
9260 (run-hook-with-args 'gnus-summary-article-move-hook
9261 action
9262 (gnus-data-header
9263 (assoc article (gnus-data-list nil)))
9264 gnus-newsgroup-name
9265 to-newsgroup
9266 select-method))
9267
9268 ;;;!!!Why is this necessary?
9269 (set-buffer gnus-summary-buffer)
9270
9271 (gnus-summary-goto-subject article)
9272 (when (eq action 'move)
9273 (gnus-summary-mark-article article gnus-canceled-mark))))
9274 (gnus-summary-remove-process-mark article))
9275 ;; Re-activate all groups that have been moved to.
9276 (save-excursion
9277 (set-buffer gnus-group-buffer)
9278 (let ((gnus-group-marked to-groups))
9279 (gnus-group-get-new-news-this-group nil t)))
9280
9281 (gnus-kill-buffer copy-buf)
9282 (gnus-summary-position-point)
9283 (gnus-set-mode-line 'summary)))
9284
9285 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9286 "Copy the current article to some other group.
9287 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9288 When called interactively, if TO-NEWSGROUP is nil, use the value of
9289 the variable `gnus-move-split-methods' for finding a default target
9290 newsgroup.
9291 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9292 re-spool using this method."
9293 (interactive "P")
9294 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9295
9296 (defun gnus-summary-crosspost-article (&optional n)
9297 "Crosspost the current article to some other group."
9298 (interactive "P")
9299 (gnus-summary-move-article n nil nil 'crosspost))
9300
9301 (defcustom gnus-summary-respool-default-method nil
9302 "Default method type for respooling an article.
9303 If nil, use to the current newsgroup method."
9304 :type 'symbol
9305 :group 'gnus-summary-mail)
9306
9307 (defcustom gnus-summary-display-while-building nil
9308 "If non-nil, show and update the summary buffer as it's being built.
9309 If the value is t, update the buffer after every line is inserted. If
9310 the value is an integer (N), update the display every N lines."
9311 :version "22.1"
9312 :group 'gnus-thread
9313 :type '(choice (const :tag "off" nil)
9314 number
9315 (const :tag "frequently" t)))
9316
9317 (defun gnus-summary-respool-article (&optional n method)
9318 "Respool the current article.
9319 The article will be squeezed through the mail spooling process again,
9320 which means that it will be put in some mail newsgroup or other
9321 depending on `nnmail-split-methods'.
9322 If N is a positive number, respool the N next articles.
9323 If N is a negative number, respool the N previous articles.
9324 If N is nil and any articles have been marked with the process mark,
9325 respool those articles instead.
9326
9327 Respooling can be done both from mail groups and \"real\" newsgroups.
9328 In the former case, the articles in question will be moved from the
9329 current group into whatever groups they are destined to. In the
9330 latter case, they will be copied into the relevant groups."
9331 (interactive
9332 (list current-prefix-arg
9333 (let* ((methods (gnus-methods-using 'respool))
9334 (methname
9335 (symbol-name (or gnus-summary-respool-default-method
9336 (car (gnus-find-method-for-group
9337 gnus-newsgroup-name)))))
9338 (method
9339 (gnus-completing-read-with-default
9340 methname "Backend to use when respooling"
9341 methods nil t nil 'gnus-mail-method-history))
9342 ms)
9343 (cond
9344 ((zerop (length (setq ms (gnus-servers-using-backend
9345 (intern method)))))
9346 (list (intern method) ""))
9347 ((= 1 (length ms))
9348 (car ms))
9349 (t
9350 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9351 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9352 ms-alist))))))))
9353 (unless method
9354 (error "No method given for respooling"))
9355 (if (assoc (symbol-name
9356 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9357 (gnus-methods-using 'respool))
9358 (gnus-summary-move-article n nil method)
9359 (gnus-summary-copy-article n nil method)))
9360
9361 (defun gnus-summary-import-article (file &optional edit)
9362 "Import an arbitrary file into a mail newsgroup."
9363 (interactive "fImport file: \nP")
9364 (let ((group gnus-newsgroup-name)
9365 (now (current-time))
9366 atts lines group-art)
9367 (unless (gnus-check-backend-function 'request-accept-article group)
9368 (error "%s does not support article importing" group))
9369 (or (file-readable-p file)
9370 (not (file-regular-p file))
9371 (error "Can't read %s" file))
9372 (save-excursion
9373 (set-buffer (gnus-get-buffer-create " *import file*"))
9374 (erase-buffer)
9375 (nnheader-insert-file-contents file)
9376 (goto-char (point-min))
9377 (if (nnheader-article-p)
9378 (save-restriction
9379 (goto-char (point-min))
9380 (search-forward "\n\n" nil t)
9381 (narrow-to-region (point-min) (1- (point)))
9382 (goto-char (point-min))
9383 (unless (re-search-forward "^date:" nil t)
9384 (goto-char (point-max))
9385 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9386 ;; This doesn't look like an article, so we fudge some headers.
9387 (setq atts (file-attributes file)
9388 lines (count-lines (point-min) (point-max)))
9389 (insert "From: " (read-string "From: ") "\n"
9390 "Subject: " (read-string "Subject: ") "\n"
9391 "Date: " (message-make-date (nth 5 atts)) "\n"
9392 "Message-ID: " (message-make-message-id) "\n"
9393 "Lines: " (int-to-string lines) "\n"
9394 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9395 (setq group-art (gnus-request-accept-article group nil t))
9396 (kill-buffer (current-buffer)))
9397 (setq gnus-newsgroup-active (gnus-activate-group group))
9398 (forward-line 1)
9399 (gnus-summary-goto-article (cdr group-art) nil t)
9400 (when edit
9401 (gnus-summary-edit-article))))
9402
9403 (defun gnus-summary-create-article ()
9404 "Create an article in a mail newsgroup."
9405 (interactive)
9406 (let ((group gnus-newsgroup-name)
9407 (now (current-time))
9408 group-art)
9409 (unless (gnus-check-backend-function 'request-accept-article group)
9410 (error "%s does not support article importing" group))
9411 (save-excursion
9412 (set-buffer (gnus-get-buffer-create " *import file*"))
9413 (erase-buffer)
9414 (goto-char (point-min))
9415 ;; This doesn't look like an article, so we fudge some headers.
9416 (insert "From: " (read-string "From: ") "\n"
9417 "Subject: " (read-string "Subject: ") "\n"
9418 "Date: " (message-make-date now) "\n"
9419 "Message-ID: " (message-make-message-id) "\n")
9420 (setq group-art (gnus-request-accept-article group nil t))
9421 (kill-buffer (current-buffer)))
9422 (setq gnus-newsgroup-active (gnus-activate-group group))
9423 (forward-line 1)
9424 (gnus-summary-goto-article (cdr group-art) nil t)
9425 (gnus-summary-edit-article)))
9426
9427 (defun gnus-summary-article-posted-p ()
9428 "Say whether the current (mail) article is available from news as well.
9429 This will be the case if the article has both been mailed and posted."
9430 (interactive)
9431 (let ((id (mail-header-references (gnus-summary-article-header)))
9432 (gnus-override-method (car (gnus-refer-article-methods))))
9433 (if (gnus-request-head id "")
9434 (gnus-message 2 "The current message was found on %s"
9435 gnus-override-method)
9436 (gnus-message 2 "The current message couldn't be found on %s"
9437 gnus-override-method)
9438 nil)))
9439
9440 (defun gnus-summary-expire-articles (&optional now)
9441 "Expire all articles that are marked as expirable in the current group."
9442 (interactive)
9443 (when (and (not gnus-group-is-exiting-without-update-p)
9444 (gnus-check-backend-function
9445 'request-expire-articles gnus-newsgroup-name))
9446 ;; This backend supports expiry.
9447 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9448 (expirable (if total
9449 (progn
9450 ;; We need to update the info for
9451 ;; this group for `gnus-list-of-read-articles'
9452 ;; to give us the right answer.
9453 (gnus-run-hooks 'gnus-exit-group-hook)
9454 (gnus-summary-update-info)
9455 (gnus-list-of-read-articles gnus-newsgroup-name))
9456 (setq gnus-newsgroup-expirable
9457 (sort gnus-newsgroup-expirable '<))))
9458 (expiry-wait (if now 'immediate
9459 (gnus-group-find-parameter
9460 gnus-newsgroup-name 'expiry-wait)))
9461 (nnmail-expiry-target
9462 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9463 nnmail-expiry-target))
9464 es)
9465 (when expirable
9466 ;; There are expirable articles in this group, so we run them
9467 ;; through the expiry process.
9468 (gnus-message 6 "Expiring articles...")
9469 (unless (gnus-check-group gnus-newsgroup-name)
9470 (error "Can't open server for %s" gnus-newsgroup-name))
9471 ;; The list of articles that weren't expired is returned.
9472 (save-excursion
9473 (if expiry-wait
9474 (let ((nnmail-expiry-wait-function nil)
9475 (nnmail-expiry-wait expiry-wait))
9476 (setq es (gnus-request-expire-articles
9477 expirable gnus-newsgroup-name)))
9478 (setq es (gnus-request-expire-articles
9479 expirable gnus-newsgroup-name)))
9480 (unless total
9481 (setq gnus-newsgroup-expirable es))
9482 ;; We go through the old list of expirable, and mark all
9483 ;; really expired articles as nonexistent.
9484 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9485 (let ((gnus-use-cache nil))
9486 (dolist (article expirable)
9487 (when (and (not (memq article es))
9488 (gnus-data-find article))
9489 (gnus-summary-mark-article article gnus-canceled-mark)
9490 (run-hook-with-args 'gnus-summary-article-expire-hook
9491 'delete
9492 (gnus-data-header
9493 (assoc article (gnus-data-list nil)))
9494 gnus-newsgroup-name
9495 nil
9496 nil))))))
9497 (gnus-message 6 "Expiring articles...done")))))
9498
9499 (defun gnus-summary-expire-articles-now ()
9500 "Expunge all expirable articles in the current group.
9501 This means that *all* articles that are marked as expirable will be
9502 deleted forever, right now."
9503 (interactive)
9504 (or gnus-expert-user
9505 (gnus-yes-or-no-p
9506 "Are you really, really sure you want to delete all expirable messages? ")
9507 (error "Phew!"))
9508 (gnus-summary-expire-articles t))
9509
9510 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9511 (defun gnus-summary-delete-article (&optional n)
9512 "Delete the N next (mail) articles.
9513 This command actually deletes articles. This is not a marking
9514 command. The article will disappear forever from your life, never to
9515 return.
9516
9517 If N is negative, delete backwards.
9518 If N is nil and articles have been marked with the process mark,
9519 delete these instead.
9520
9521 If `gnus-novice-user' is non-nil you will be asked for
9522 confirmation before the articles are deleted."
9523 (interactive "P")
9524 (unless (gnus-check-backend-function 'request-expire-articles
9525 gnus-newsgroup-name)
9526 (error "The current newsgroup does not support article deletion"))
9527 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9528 (error "Couldn't open server"))
9529 ;; Compute the list of articles to delete.
9530 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9531 (nnmail-expiry-target 'delete)
9532 not-deleted)
9533 (if (and gnus-novice-user
9534 (not (gnus-yes-or-no-p
9535 (format "Do you really want to delete %s forever? "
9536 (if (> (length articles) 1)
9537 (format "these %s articles" (length articles))
9538 "this article")))))
9539 ()
9540 ;; Delete the articles.
9541 (setq not-deleted (gnus-request-expire-articles
9542 articles gnus-newsgroup-name 'force))
9543 (while articles
9544 (gnus-summary-remove-process-mark (car articles))
9545 ;; The backend might not have been able to delete the article
9546 ;; after all.
9547 (unless (memq (car articles) not-deleted)
9548 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9549 (let* ((article (car articles))
9550 (id (mail-header-id (gnus-data-header
9551 (assoc article (gnus-data-list nil))))))
9552 (run-hook-with-args 'gnus-summary-article-delete-hook
9553 'delete id gnus-newsgroup-name nil
9554 nil))
9555 (setq articles (cdr articles)))
9556 (when not-deleted
9557 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9558 (gnus-summary-position-point)
9559 (gnus-set-mode-line 'summary)
9560 not-deleted))
9561
9562 (defun gnus-summary-edit-article (&optional arg)
9563 "Edit the current article.
9564 This will have permanent effect only in mail groups.
9565 If ARG is nil, edit the decoded articles.
9566 If ARG is 1, edit the raw articles.
9567 If ARG is 2, edit the raw articles even in read-only groups.
9568 If ARG is 3, edit the articles with the current handles.
9569 Otherwise, allow editing of articles even in read-only
9570 groups."
9571 (interactive "P")
9572 (let (force raw current-handles)
9573 (cond
9574 ((null arg))
9575 ((eq arg 1)
9576 (setq raw t))
9577 ((eq arg 2)
9578 (setq raw t
9579 force t))
9580 ((eq arg 3)
9581 (setq current-handles
9582 (and (gnus-buffer-live-p gnus-article-buffer)
9583 (with-current-buffer gnus-article-buffer
9584 (prog1
9585 gnus-article-mime-handles
9586 (setq gnus-article-mime-handles nil))))))
9587 (t
9588 (setq force t)))
9589 (when (and raw (not force)
9590 (member gnus-newsgroup-name '("nndraft:delayed"
9591 "nndraft:drafts"
9592 "nndraft:queue")))
9593 (error "Can't edit the raw article in group %s"
9594 gnus-newsgroup-name))
9595 (save-excursion
9596 (set-buffer gnus-summary-buffer)
9597 (let ((mail-parse-charset gnus-newsgroup-charset)
9598 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9599 (gnus-set-global-variables)
9600 (when (and (not force)
9601 (gnus-group-read-only-p))
9602 (error "The current newsgroup does not support article editing"))
9603 (gnus-summary-show-article t)
9604 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9605 (with-current-buffer gnus-article-buffer
9606 (mm-enable-multibyte)))
9607 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9608 (setq raw t))
9609 (gnus-article-edit-article
9610 (if raw 'ignore
9611 `(lambda ()
9612 (let ((mbl mml-buffer-list))
9613 (setq mml-buffer-list nil)
9614 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9615 (mime-to-mml ,'current-handles))
9616 (let ((mbl1 mml-buffer-list))
9617 (setq mml-buffer-list mbl)
9618 (set (make-local-variable 'mml-buffer-list) mbl1))
9619 (gnus-make-local-hook 'kill-buffer-hook)
9620 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9621 `(lambda (no-highlight)
9622 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9623 (message-options message-options)
9624 (message-options-set-recipient)
9625 (mail-parse-ignored-charsets
9626 ',gnus-newsgroup-ignored-charsets))
9627 ,(if (not raw) '(progn
9628 (mml-to-mime)
9629 (mml-destroy-buffers)
9630 (remove-hook 'kill-buffer-hook
9631 'mml-destroy-buffers t)
9632 (kill-local-variable 'mml-buffer-list)))
9633 (gnus-summary-edit-article-done
9634 ,(or (mail-header-references gnus-current-headers) "")
9635 ,(gnus-group-read-only-p)
9636 ,gnus-summary-buffer no-highlight))))))))
9637
9638 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9639
9640 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9641 no-highlight)
9642 "Make edits to the current article permanent."
9643 (interactive)
9644 (save-excursion
9645 ;; The buffer restriction contains the entire article if it exists.
9646 (when (article-goto-body)
9647 (let ((lines (count-lines (point) (point-max)))
9648 (length (- (point-max) (point)))
9649 (case-fold-search t)
9650 (body (copy-marker (point))))
9651 (goto-char (point-min))
9652 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9653 (delete-region (match-beginning 1) (match-end 1))
9654 (insert (number-to-string length)))
9655 (goto-char (point-min))
9656 (when (re-search-forward
9657 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9658 (delete-region (match-beginning 1) (match-end 1))
9659 (insert (number-to-string length)))
9660 (goto-char (point-min))
9661 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9662 (delete-region (match-beginning 1) (match-end 1))
9663 (insert (number-to-string lines))))))
9664 ;; Replace the article.
9665 (let ((buf (current-buffer)))
9666 (with-temp-buffer
9667 (insert-buffer-substring buf)
9668
9669 (if (and (not read-only)
9670 (not (gnus-request-replace-article
9671 (cdr gnus-article-current) (car gnus-article-current)
9672 (current-buffer) t)))
9673 (error "Couldn't replace article")
9674 ;; Update the summary buffer.
9675 (if (and references
9676 (equal (message-tokenize-header references " ")
9677 (message-tokenize-header
9678 (or (message-fetch-field "references") "") " ")))
9679 ;; We only have to update this line.
9680 (save-excursion
9681 (save-restriction
9682 (message-narrow-to-head)
9683 (let ((head (buffer-substring-no-properties
9684 (point-min) (point-max)))
9685 header)
9686 (with-temp-buffer
9687 (insert (format "211 %d Article retrieved.\n"
9688 (cdr gnus-article-current)))
9689 (insert head)
9690 (insert ".\n")
9691 (let ((nntp-server-buffer (current-buffer)))
9692 (setq header (car (gnus-get-newsgroup-headers
9693 nil t))))
9694 (save-excursion
9695 (set-buffer gnus-summary-buffer)
9696 (gnus-data-set-header
9697 (gnus-data-find (cdr gnus-article-current))
9698 header)
9699 (gnus-summary-update-article-line
9700 (cdr gnus-article-current) header)
9701 (if (gnus-summary-goto-subject
9702 (cdr gnus-article-current) nil t)
9703 (gnus-summary-update-secondary-mark
9704 (cdr gnus-article-current))))))))
9705 ;; Update threads.
9706 (set-buffer (or buffer gnus-summary-buffer))
9707 (gnus-summary-update-article (cdr gnus-article-current))
9708 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9709 (gnus-summary-update-secondary-mark
9710 (cdr gnus-article-current))))
9711 ;; Prettify the article buffer again.
9712 (unless no-highlight
9713 (save-excursion
9714 (set-buffer gnus-article-buffer)
9715 ;;;!!! Fix this -- article should be rehighlighted.
9716 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9717 (set-buffer gnus-original-article-buffer)
9718 (gnus-request-article
9719 (cdr gnus-article-current)
9720 (car gnus-article-current) (current-buffer))))
9721 ;; Prettify the summary buffer line.
9722 (when (gnus-visual-p 'summary-highlight 'highlight)
9723 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9724
9725 (defun gnus-summary-edit-wash (key)
9726 "Perform editing command KEY in the article buffer."
9727 (interactive
9728 (list
9729 (progn
9730 (message "%s" (concat (this-command-keys) "- "))
9731 (read-char))))
9732 (message "")
9733 (gnus-summary-edit-article)
9734 (execute-kbd-macro (concat (this-command-keys) key))
9735 (gnus-article-edit-done))
9736
9737 ;;; Respooling
9738
9739 (defun gnus-summary-respool-query (&optional silent trace)
9740 "Query where the respool algorithm would put this article."
9741 (interactive)
9742 (let (gnus-mark-article-hook)
9743 (gnus-summary-select-article)
9744 (save-excursion
9745 (set-buffer gnus-original-article-buffer)
9746 (let ((groups (nnmail-article-group 'identity trace)))
9747 (unless silent
9748 (if groups
9749 (message "This message would go to %s"
9750 (mapconcat 'car groups ", "))
9751 (message "This message would go to no groups"))
9752 groups)))))
9753
9754 (defun gnus-summary-respool-trace ()
9755 "Trace where the respool algorithm would put this article.
9756 Display a buffer showing all fancy splitting patterns which matched."
9757 (interactive)
9758 (gnus-summary-respool-query nil t))
9759
9760 ;; Summary marking commands.
9761
9762 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9763 "Mark articles which has the same subject as read, and then select the next.
9764 If UNMARK is positive, remove any kind of mark.
9765 If UNMARK is negative, tick articles."
9766 (interactive "P")
9767 (when unmark
9768 (setq unmark (prefix-numeric-value unmark)))
9769 (let ((count
9770 (gnus-summary-mark-same-subject
9771 (gnus-summary-article-subject) unmark)))
9772 ;; Select next unread article. If auto-select-same mode, should
9773 ;; select the first unread article.
9774 (gnus-summary-next-article t (and gnus-auto-select-same
9775 (gnus-summary-article-subject)))
9776 (gnus-message 7 "%d article%s marked as %s"
9777 count (if (= count 1) " is" "s are")
9778 (if unmark "unread" "read"))))
9779
9780 (defun gnus-summary-kill-same-subject (&optional unmark)
9781 "Mark articles which has the same subject as read.
9782 If UNMARK is positive, remove any kind of mark.
9783 If UNMARK is negative, tick articles."
9784 (interactive "P")
9785 (when unmark
9786 (setq unmark (prefix-numeric-value unmark)))
9787 (let ((count
9788 (gnus-summary-mark-same-subject
9789 (gnus-summary-article-subject) unmark)))
9790 ;; If marked as read, go to next unread subject.
9791 (when (null unmark)
9792 ;; Go to next unread subject.
9793 (gnus-summary-next-subject 1 t))
9794 (gnus-message 7 "%d articles are marked as %s"
9795 count (if unmark "unread" "read"))))
9796
9797 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9798 "Mark articles with same SUBJECT as read, and return marked number.
9799 If optional argument UNMARK is positive, remove any kinds of marks.
9800 If optional argument UNMARK is negative, mark articles as unread instead."
9801 (let ((count 1))
9802 (save-excursion
9803 (cond
9804 ((null unmark) ; Mark as read.
9805 (while (and
9806 (progn
9807 (gnus-summary-mark-article-as-read gnus-killed-mark)
9808 (gnus-summary-show-thread) t)
9809 (gnus-summary-find-subject subject))
9810 (setq count (1+ count))))
9811 ((> unmark 0) ; Tick.
9812 (while (and
9813 (progn
9814 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9815 (gnus-summary-show-thread) t)
9816 (gnus-summary-find-subject subject))
9817 (setq count (1+ count))))
9818 (t ; Mark as unread.
9819 (while (and
9820 (progn
9821 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9822 (gnus-summary-show-thread) t)
9823 (gnus-summary-find-subject subject))
9824 (setq count (1+ count)))))
9825 (gnus-set-mode-line 'summary)
9826 ;; Return the number of marked articles.
9827 count)))
9828
9829 (defun gnus-summary-mark-as-processable (n &optional unmark)
9830 "Set the process mark on the next N articles.
9831 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9832 the process mark instead. The difference between N and the actual
9833 number of articles marked is returned."
9834 (interactive "P")
9835 (if (and (null n) (gnus-region-active-p))
9836 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9837 (setq n (prefix-numeric-value n))
9838 (let ((backward (< n 0))
9839 (n (abs n)))
9840 (while (and
9841 (> n 0)
9842 (if unmark
9843 (gnus-summary-remove-process-mark
9844 (gnus-summary-article-number))
9845 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9846 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9847 (setq n (1- n)))
9848 (when (/= 0 n)
9849 (gnus-message 7 "No more articles"))
9850 (gnus-summary-recenter)
9851 (gnus-summary-position-point)
9852 n)))
9853
9854 (defun gnus-summary-unmark-as-processable (n)
9855 "Remove the process mark from the next N articles.
9856 If N is negative, unmark backward instead. The difference between N and
9857 the actual number of articles unmarked is returned."
9858 (interactive "P")
9859 (gnus-summary-mark-as-processable n t))
9860
9861 (defun gnus-summary-unmark-all-processable ()
9862 "Remove the process mark from all articles."
9863 (interactive)
9864 (save-excursion
9865 (while gnus-newsgroup-processable
9866 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9867 (gnus-summary-position-point))
9868
9869 (defun gnus-summary-add-mark (article type)
9870 "Mark ARTICLE with a mark of TYPE."
9871 (let ((vtype (car (assq type gnus-article-mark-lists)))
9872 var)
9873 (if (not vtype)
9874 (error "No such mark type: %s" type)
9875 (setq var (intern (format "gnus-newsgroup-%s" type)))
9876 (set var (cons article (symbol-value var)))
9877 (if (memq type '(processable cached replied forwarded recent saved))
9878 (gnus-summary-update-secondary-mark article)
9879 ;;; !!! This is bogus. We should find out what primary
9880 ;;; !!! mark we want to set.
9881 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9882
9883 (defun gnus-summary-mark-as-expirable (n)
9884 "Mark N articles forward as expirable.
9885 If N is negative, mark backward instead. The difference between N and
9886 the actual number of articles marked is returned."
9887 (interactive "p")
9888 (gnus-summary-mark-forward n gnus-expirable-mark))
9889
9890 (defun gnus-summary-mark-as-spam (n)
9891 "Mark N articles forward as spam.
9892 If N is negative, mark backward instead. The difference between N and
9893 the actual number of articles marked is returned."
9894 (interactive "p")
9895 (gnus-summary-mark-forward n gnus-spam-mark))
9896
9897 (defun gnus-summary-mark-article-as-replied (article)
9898 "Mark ARTICLE as replied to and update the summary line.
9899 ARTICLE can also be a list of articles."
9900 (interactive (list (gnus-summary-article-number)))
9901 (let ((articles (if (listp article) article (list article))))
9902 (dolist (article articles)
9903 (unless (numberp article)
9904 (error "%s is not a number" article))
9905 (push article gnus-newsgroup-replied)
9906 (let ((buffer-read-only nil))
9907 (when (gnus-summary-goto-subject article nil t)
9908 (gnus-summary-update-secondary-mark article))))))
9909
9910 (defun gnus-summary-mark-article-as-forwarded (article)
9911 "Mark ARTICLE as forwarded and update the summary line.
9912 ARTICLE can also be a list of articles."
9913 (let ((articles (if (listp article) article (list article))))
9914 (dolist (article articles)
9915 (push article gnus-newsgroup-forwarded)
9916 (let ((buffer-read-only nil))
9917 (when (gnus-summary-goto-subject article nil t)
9918 (gnus-summary-update-secondary-mark article))))))
9919
9920 (defun gnus-summary-set-bookmark (article)
9921 "Set a bookmark in current article."
9922 (interactive (list (gnus-summary-article-number)))
9923 (when (or (not (get-buffer gnus-article-buffer))
9924 (not gnus-current-article)
9925 (not gnus-article-current)
9926 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9927 (error "No current article selected"))
9928 ;; Remove old bookmark, if one exists.
9929 (gnus-pull article gnus-newsgroup-bookmarks)
9930 ;; Set the new bookmark, which is on the form
9931 ;; (article-number . line-number-in-body).
9932 (push
9933 (cons article
9934 (save-excursion
9935 (set-buffer gnus-article-buffer)
9936 (count-lines
9937 (min (point)
9938 (save-excursion
9939 (article-goto-body)
9940 (point)))
9941 (point))))
9942 gnus-newsgroup-bookmarks)
9943 (gnus-message 6 "A bookmark has been added to the current article."))
9944
9945 (defun gnus-summary-remove-bookmark (article)
9946 "Remove the bookmark from the current article."
9947 (interactive (list (gnus-summary-article-number)))
9948 ;; Remove old bookmark, if one exists.
9949 (if (not (assq article gnus-newsgroup-bookmarks))
9950 (gnus-message 6 "No bookmark in current article.")
9951 (gnus-pull article gnus-newsgroup-bookmarks)
9952 (gnus-message 6 "Removed bookmark.")))
9953
9954 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9955 (defun gnus-summary-mark-as-dormant (n)
9956 "Mark N articles forward as dormant.
9957 If N is negative, mark backward instead. The difference between N and
9958 the actual number of articles marked is returned."
9959 (interactive "p")
9960 (gnus-summary-mark-forward n gnus-dormant-mark))
9961
9962 (defun gnus-summary-set-process-mark (article)
9963 "Set the process mark on ARTICLE and update the summary line."
9964 (setq gnus-newsgroup-processable
9965 (cons article
9966 (delq article gnus-newsgroup-processable)))
9967 (when (gnus-summary-goto-subject article)
9968 (gnus-summary-show-thread)
9969 (gnus-summary-goto-subject article)
9970 (gnus-summary-update-secondary-mark article)))
9971
9972 (defun gnus-summary-remove-process-mark (article)
9973 "Remove the process mark from ARTICLE and update the summary line."
9974 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9975 (when (gnus-summary-goto-subject article)
9976 (gnus-summary-show-thread)
9977 (gnus-summary-goto-subject article)
9978 (gnus-summary-update-secondary-mark article)))
9979
9980 (defun gnus-summary-set-saved-mark (article)
9981 "Set the process mark on ARTICLE and update the summary line."
9982 (push article gnus-newsgroup-saved)
9983 (when (gnus-summary-goto-subject article)
9984 (gnus-summary-update-secondary-mark article)))
9985
9986 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9987 "Mark N articles as read forwards.
9988 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9989 The difference between N and the actual number of articles marked is
9990 returned.
9991 If NO-EXPIRE, auto-expiry will be inhibited."
9992 (interactive "p")
9993 (gnus-summary-show-thread)
9994 (let ((backward (< n 0))
9995 (gnus-summary-goto-unread
9996 (and gnus-summary-goto-unread
9997 (not (eq gnus-summary-goto-unread 'never))
9998 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9999 gnus-ticked-mark gnus-dormant-mark)))))
10000 (n (abs n))
10001 (mark (or mark gnus-del-mark)))
10002 (while (and (> n 0)
10003 (gnus-summary-mark-article nil mark no-expire)
10004 (zerop (gnus-summary-next-subject
10005 (if backward -1 1)
10006 (and gnus-summary-goto-unread
10007 (not (eq gnus-summary-goto-unread 'never)))
10008 t)))
10009 (setq n (1- n)))
10010 (when (/= 0 n)
10011 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10012 (gnus-summary-recenter)
10013 (gnus-summary-position-point)
10014 (gnus-set-mode-line 'summary)
10015 n))
10016
10017 (defun gnus-summary-mark-article-as-read (mark)
10018 "Mark the current article quickly as read with MARK."
10019 (let ((article (gnus-summary-article-number)))
10020 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10021 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10022 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10023 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10024 (push (cons article mark) gnus-newsgroup-reads)
10025 ;; Possibly remove from cache, if that is used.
10026 (when gnus-use-cache
10027 (gnus-cache-enter-remove-article article))
10028 ;; Allow the backend to change the mark.
10029 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10030 ;; Check for auto-expiry.
10031 (when (and gnus-newsgroup-auto-expire
10032 (memq mark gnus-auto-expirable-marks))
10033 (setq mark gnus-expirable-mark)
10034 ;; Let the backend know about the mark change.
10035 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10036 (push article gnus-newsgroup-expirable))
10037 ;; Set the mark in the buffer.
10038 (gnus-summary-update-mark mark 'unread)
10039 t))
10040
10041 (defun gnus-summary-mark-article-as-unread (mark)
10042 "Mark the current article quickly as unread with MARK."
10043 (let* ((article (gnus-summary-article-number))
10044 (old-mark (gnus-summary-article-mark article)))
10045 ;; Allow the backend to change the mark.
10046 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10047 (if (eq mark old-mark)
10048 t
10049 (if (<= article 0)
10050 (progn
10051 (gnus-error 1 "Can't mark negative article numbers")
10052 nil)
10053 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10054 (setq gnus-newsgroup-spam-marked
10055 (delq article gnus-newsgroup-spam-marked))
10056 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10057 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10058 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10059 (cond ((= mark gnus-ticked-mark)
10060 (setq gnus-newsgroup-marked
10061 (gnus-add-to-sorted-list gnus-newsgroup-marked
10062 article)))
10063 ((= mark gnus-spam-mark)
10064 (setq gnus-newsgroup-spam-marked
10065 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10066 article)))
10067 ((= mark gnus-dormant-mark)
10068 (setq gnus-newsgroup-dormant
10069 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10070 article)))
10071 (t
10072 (setq gnus-newsgroup-unreads
10073 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10074 article))))
10075 (gnus-pull article gnus-newsgroup-reads)
10076
10077 ;; See whether the article is to be put in the cache.
10078 (and gnus-use-cache
10079 (vectorp (gnus-summary-article-header article))
10080 (save-excursion
10081 (gnus-cache-possibly-enter-article
10082 gnus-newsgroup-name article
10083 (= mark gnus-ticked-mark)
10084 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10085
10086 ;; Fix the mark.
10087 (gnus-summary-update-mark mark 'unread)
10088 t))))
10089
10090 (defun gnus-summary-mark-article (&optional article mark no-expire)
10091 "Mark ARTICLE with MARK. MARK can be any character.
10092 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10093 `??' (dormant) and `?E' (expirable).
10094 If MARK is nil, then the default character `?r' is used.
10095 If ARTICLE is nil, then the article on the current line will be
10096 marked.
10097 If NO-EXPIRE, auto-expiry will be inhibited."
10098 ;; The mark might be a string.
10099 (when (stringp mark)
10100 (setq mark (aref mark 0)))
10101 ;; If no mark is given, then we check auto-expiring.
10102 (when (null mark)
10103 (setq mark gnus-del-mark))
10104 (when (and (not no-expire)
10105 gnus-newsgroup-auto-expire
10106 (memq mark gnus-auto-expirable-marks))
10107 (setq mark gnus-expirable-mark))
10108 (let ((article (or article (gnus-summary-article-number)))
10109 (old-mark (gnus-summary-article-mark article)))
10110 ;; Allow the backend to change the mark.
10111 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10112 (if (eq mark old-mark)
10113 t
10114 (unless article
10115 (error "No article on current line"))
10116 (if (not (if (or (= mark gnus-unread-mark)
10117 (= mark gnus-ticked-mark)
10118 (= mark gnus-spam-mark)
10119 (= mark gnus-dormant-mark))
10120 (gnus-mark-article-as-unread article mark)
10121 (gnus-mark-article-as-read article mark)))
10122 t
10123 ;; See whether the article is to be put in the cache.
10124 (and gnus-use-cache
10125 (not (= mark gnus-canceled-mark))
10126 (vectorp (gnus-summary-article-header article))
10127 (save-excursion
10128 (gnus-cache-possibly-enter-article
10129 gnus-newsgroup-name article
10130 (= mark gnus-ticked-mark)
10131 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10132
10133 (when (gnus-summary-goto-subject article nil t)
10134 (let ((buffer-read-only nil))
10135 (gnus-summary-show-thread)
10136 ;; Fix the mark.
10137 (gnus-summary-update-mark mark 'unread)
10138 t))))))
10139
10140 (defun gnus-summary-update-secondary-mark (article)
10141 "Update the secondary (read, process, cache) mark."
10142 (gnus-summary-update-mark
10143 (cond ((memq article gnus-newsgroup-processable)
10144 gnus-process-mark)
10145 ((memq article gnus-newsgroup-cached)
10146 gnus-cached-mark)
10147 ((memq article gnus-newsgroup-replied)
10148 gnus-replied-mark)
10149 ((memq article gnus-newsgroup-forwarded)
10150 gnus-forwarded-mark)
10151 ((memq article gnus-newsgroup-saved)
10152 gnus-saved-mark)
10153 ((memq article gnus-newsgroup-recent)
10154 gnus-recent-mark)
10155 ((memq article gnus-newsgroup-unseen)
10156 gnus-unseen-mark)
10157 (t gnus-no-mark))
10158 'replied)
10159 (when (gnus-visual-p 'summary-highlight 'highlight)
10160 (gnus-run-hooks 'gnus-summary-update-hook))
10161 t)
10162
10163 (defun gnus-summary-update-download-mark (article)
10164 "Update the download mark."
10165 (gnus-summary-update-mark
10166 (cond ((memq article gnus-newsgroup-undownloaded)
10167 gnus-undownloaded-mark)
10168 (gnus-newsgroup-agentized
10169 gnus-downloaded-mark)
10170 (t
10171 gnus-no-mark))
10172 'download)
10173 (gnus-summary-update-line t)
10174 t)
10175
10176 (defun gnus-summary-update-mark (mark type)
10177 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10178 (buffer-read-only nil))
10179 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10180 (when forward
10181 (when (looking-at "\r")
10182 (incf forward))
10183 (when (<= (+ forward (point)) (point-max))
10184 ;; Go to the right position on the line.
10185 (goto-char (+ forward (point)))
10186 ;; Replace the old mark with the new mark.
10187 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10188 ;; Optionally update the marks by some user rule.
10189 (when (eq type 'unread)
10190 (gnus-data-set-mark
10191 (gnus-data-find (gnus-summary-article-number)) mark)
10192 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10193
10194 (defun gnus-mark-article-as-read (article &optional mark)
10195 "Enter ARTICLE in the pertinent lists and remove it from others."
10196 ;; Make the article expirable.
10197 (let ((mark (or mark gnus-del-mark)))
10198 (setq gnus-newsgroup-expirable
10199 (if (= mark gnus-expirable-mark)
10200 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10201 (delq article gnus-newsgroup-expirable)))
10202 ;; Remove from unread and marked lists.
10203 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10204 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10205 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10206 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10207 (push (cons article mark) gnus-newsgroup-reads)
10208 ;; Possibly remove from cache, if that is used.
10209 (when gnus-use-cache
10210 (gnus-cache-enter-remove-article article))
10211 t))
10212
10213 (defun gnus-mark-article-as-unread (article &optional mark)
10214 "Enter ARTICLE in the pertinent lists and remove it from others."
10215 (let ((mark (or mark gnus-ticked-mark)))
10216 (if (<= article 0)
10217 (progn
10218 (gnus-error 1 "Can't mark negative article numbers")
10219 nil)
10220 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10221 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10222 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10223 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10224 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10225
10226 ;; Unsuppress duplicates?
10227 (when gnus-suppress-duplicates
10228 (gnus-dup-unsuppress-article article))
10229
10230 (cond ((= mark gnus-ticked-mark)
10231 (setq gnus-newsgroup-marked
10232 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10233 ((= mark gnus-spam-mark)
10234 (setq gnus-newsgroup-spam-marked
10235 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10236 article)))
10237 ((= mark gnus-dormant-mark)
10238 (setq gnus-newsgroup-dormant
10239 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10240 (t
10241 (setq gnus-newsgroup-unreads
10242 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10243 (gnus-pull article gnus-newsgroup-reads)
10244 t)))
10245
10246 (defalias 'gnus-summary-mark-as-unread-forward
10247 'gnus-summary-tick-article-forward)
10248 (make-obsolete 'gnus-summary-mark-as-unread-forward
10249 'gnus-summary-tick-article-forward)
10250 (defun gnus-summary-tick-article-forward (n)
10251 "Tick N articles forwards.
10252 If N is negative, tick backwards instead.
10253 The difference between N and the number of articles ticked is returned."
10254 (interactive "p")
10255 (gnus-summary-mark-forward n gnus-ticked-mark))
10256
10257 (defalias 'gnus-summary-mark-as-unread-backward
10258 'gnus-summary-tick-article-backward)
10259 (make-obsolete 'gnus-summary-mark-as-unread-backward
10260 'gnus-summary-tick-article-backward)
10261 (defun gnus-summary-tick-article-backward (n)
10262 "Tick N articles backwards.
10263 The difference between N and the number of articles ticked is returned."
10264 (interactive "p")
10265 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10266
10267 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10268 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10269 (defun gnus-summary-tick-article (&optional article clear-mark)
10270 "Mark current article as unread.
10271 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10272 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10273 (interactive)
10274 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10275 gnus-ticked-mark)))
10276
10277 (defun gnus-summary-mark-as-read-forward (n)
10278 "Mark N articles as read forwards.
10279 If N is negative, mark backwards instead.
10280 The difference between N and the actual number of articles marked is
10281 returned."
10282 (interactive "p")
10283 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10284
10285 (defun gnus-summary-mark-as-read-backward (n)
10286 "Mark the N articles as read backwards.
10287 The difference between N and the actual number of articles marked is
10288 returned."
10289 (interactive "p")
10290 (gnus-summary-mark-forward
10291 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10292
10293 (defun gnus-summary-mark-as-read (&optional article mark)
10294 "Mark current article as read.
10295 ARTICLE specifies the article to be marked as read.
10296 MARK specifies a string to be inserted at the beginning of the line."
10297 (gnus-summary-mark-article article mark))
10298
10299 (defun gnus-summary-clear-mark-forward (n)
10300 "Clear marks from N articles forward.
10301 If N is negative, clear backward instead.
10302 The difference between N and the number of marks cleared is returned."
10303 (interactive "p")
10304 (gnus-summary-mark-forward n gnus-unread-mark))
10305
10306 (defun gnus-summary-clear-mark-backward (n)
10307 "Clear marks from N articles backward.
10308 The difference between N and the number of marks cleared is returned."
10309 (interactive "p")
10310 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10311
10312 (defun gnus-summary-mark-unread-as-read ()
10313 "Intended to be used by `gnus-summary-mark-article-hook'."
10314 (when (memq gnus-current-article gnus-newsgroup-unreads)
10315 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10316
10317 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10318 "Intended to be used by `gnus-summary-mark-article-hook'."
10319 (let ((mark (gnus-summary-article-mark)))
10320 (when (or (gnus-unread-mark-p mark)
10321 (gnus-read-mark-p mark))
10322 (gnus-summary-mark-article gnus-current-article
10323 (or new-mark gnus-read-mark)))))
10324
10325 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10326 "Intended to be used by `gnus-summary-mark-article-hook'."
10327 (let ((mark (gnus-summary-article-mark)))
10328 (when (or (gnus-unread-mark-p mark)
10329 (gnus-read-mark-p mark))
10330 (gnus-summary-mark-article (gnus-summary-article-number)
10331 (or new-mark gnus-read-mark)))))
10332
10333 (defun gnus-summary-mark-unread-as-ticked ()
10334 "Intended to be used by `gnus-summary-mark-article-hook'."
10335 (when (memq gnus-current-article gnus-newsgroup-unreads)
10336 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10337
10338 (defun gnus-summary-mark-region-as-read (point mark all)
10339 "Mark all unread articles between point and mark as read.
10340 If given a prefix, mark all articles between point and mark as read,
10341 even ticked and dormant ones."
10342 (interactive "r\nP")
10343 (save-excursion
10344 (let (article)
10345 (goto-char point)
10346 (beginning-of-line)
10347 (while (and
10348 (< (point) mark)
10349 (progn
10350 (when (or all
10351 (memq (setq article (gnus-summary-article-number))
10352 gnus-newsgroup-unreads))
10353 (gnus-summary-mark-article article gnus-del-mark))
10354 t)
10355 (gnus-summary-find-next))))))
10356
10357 (defun gnus-summary-mark-below (score mark)
10358 "Mark articles with score less than SCORE with MARK."
10359 (interactive "P\ncMark: ")
10360 (setq score (if score
10361 (prefix-numeric-value score)
10362 (or gnus-summary-default-score 0)))
10363 (save-excursion
10364 (set-buffer gnus-summary-buffer)
10365 (goto-char (point-min))
10366 (while
10367 (progn
10368 (and (< (gnus-summary-article-score) score)
10369 (gnus-summary-mark-article nil mark))
10370 (gnus-summary-find-next)))))
10371
10372 (defun gnus-summary-kill-below (&optional score)
10373 "Mark articles with score below SCORE as read."
10374 (interactive "P")
10375 (gnus-summary-mark-below score gnus-killed-mark))
10376
10377 (defun gnus-summary-clear-above (&optional score)
10378 "Clear all marks from articles with score above SCORE."
10379 (interactive "P")
10380 (gnus-summary-mark-above score gnus-unread-mark))
10381
10382 (defun gnus-summary-tick-above (&optional score)
10383 "Tick all articles with score above SCORE."
10384 (interactive "P")
10385 (gnus-summary-mark-above score gnus-ticked-mark))
10386
10387 (defun gnus-summary-mark-above (score mark)
10388 "Mark articles with score over SCORE with MARK."
10389 (interactive "P\ncMark: ")
10390 (setq score (if score
10391 (prefix-numeric-value score)
10392 (or gnus-summary-default-score 0)))
10393 (save-excursion
10394 (set-buffer gnus-summary-buffer)
10395 (goto-char (point-min))
10396 (while (and (progn
10397 (when (> (gnus-summary-article-score) score)
10398 (gnus-summary-mark-article nil mark))
10399 t)
10400 (gnus-summary-find-next)))))
10401
10402 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10403 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10404 (defun gnus-summary-limit-include-expunged (&optional no-error)
10405 "Display all the hidden articles that were expunged for low scores."
10406 (interactive)
10407 (let ((buffer-read-only nil))
10408 (let ((scored gnus-newsgroup-scored)
10409 headers h)
10410 (while scored
10411 (unless (gnus-summary-article-header (caar scored))
10412 (and (setq h (gnus-number-to-header (caar scored)))
10413 (< (cdar scored) gnus-summary-expunge-below)
10414 (push h headers)))
10415 (setq scored (cdr scored)))
10416 (if (not headers)
10417 (when (not no-error)
10418 (error "No expunged articles hidden"))
10419 (goto-char (point-min))
10420 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10421 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10422 (mapcar (lambda (x) (push (mail-header-number x)
10423 gnus-newsgroup-limit))
10424 headers)
10425 (gnus-summary-prepare-unthreaded (nreverse headers))
10426 (goto-char (point-min))
10427 (gnus-summary-position-point)
10428 t))))
10429
10430 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10431 "Mark all unread articles in this newsgroup as read.
10432 If prefix argument ALL is non-nil, ticked and dormant articles will
10433 also be marked as read.
10434 If QUIETLY is non-nil, no questions will be asked.
10435
10436 If TO-HERE is non-nil, it should be a point in the buffer. All
10437 articles before (after, if REVERSE is set) this point will be marked
10438 as read.
10439
10440 Note that this function will only catch up the unread article
10441 in the current summary buffer limitation.
10442
10443 The number of articles marked as read is returned."
10444 (interactive "P")
10445 (prog1
10446 (save-excursion
10447 (when (or quietly
10448 (not gnus-interactive-catchup) ;Without confirmation?
10449 gnus-expert-user
10450 (gnus-y-or-n-p
10451 (if all
10452 "Mark absolutely all articles as read? "
10453 "Mark all unread articles as read? ")))
10454 (if (and not-mark
10455 (not gnus-newsgroup-adaptive)
10456 (not gnus-newsgroup-auto-expire)
10457 (not gnus-suppress-duplicates)
10458 (or (not gnus-use-cache)
10459 (eq gnus-use-cache 'passive)))
10460 (progn
10461 (when all
10462 (setq gnus-newsgroup-marked nil
10463 gnus-newsgroup-spam-marked nil
10464 gnus-newsgroup-dormant nil))
10465 (setq gnus-newsgroup-unreads
10466 (gnus-sorted-nunion
10467 (gnus-intersection gnus-newsgroup-unreads
10468 gnus-newsgroup-downloadable)
10469 gnus-newsgroup-unfetched)))
10470 ;; We actually mark all articles as canceled, which we
10471 ;; have to do when using auto-expiry or adaptive scoring.
10472 (gnus-summary-show-all-threads)
10473 (if (and to-here reverse)
10474 (progn
10475 (goto-char to-here)
10476 (gnus-summary-mark-current-read-and-unread-as-read
10477 gnus-catchup-mark)
10478 (while (gnus-summary-find-next (not all))
10479 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10480 (when (gnus-summary-first-subject (not all))
10481 (while (and
10482 (if to-here (< (point) to-here) t)
10483 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10484 (gnus-summary-find-next (not all))))))
10485 (gnus-set-mode-line 'summary))
10486 t))
10487 (gnus-summary-position-point)))
10488
10489 (defun gnus-summary-catchup-to-here (&optional all)
10490 "Mark all unticked articles before the current one as read.
10491 If ALL is non-nil, also mark ticked and dormant articles as read."
10492 (interactive "P")
10493 (save-excursion
10494 (gnus-save-hidden-threads
10495 (let ((beg (point)))
10496 ;; We check that there are unread articles.
10497 (when (or all (gnus-summary-find-prev))
10498 (gnus-summary-catchup all t beg)))))
10499 (gnus-summary-position-point))
10500
10501 (defun gnus-summary-catchup-from-here (&optional all)
10502 "Mark all unticked articles after (and including) the current one as read.
10503 If ALL is non-nil, also mark ticked and dormant articles as read."
10504 (interactive "P")
10505 (save-excursion
10506 (gnus-save-hidden-threads
10507 (let ((beg (point)))
10508 ;; We check that there are unread articles.
10509 (when (or all (gnus-summary-find-next))
10510 (gnus-summary-catchup all t beg nil t)))))
10511 (gnus-summary-position-point))
10512
10513 (defun gnus-summary-catchup-all (&optional quietly)
10514 "Mark all articles in this newsgroup as read.
10515 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10516 instead, which marks only unread articles as read."
10517 (interactive "P")
10518 (gnus-summary-catchup t quietly))
10519
10520 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10521 "Mark all unread articles in this group as read, then exit.
10522 If prefix argument ALL is non-nil, all articles are marked as read.
10523 If QUIETLY is non-nil, no questions will be asked."
10524 (interactive "P")
10525 (when (gnus-summary-catchup all quietly nil 'fast)
10526 ;; Select next newsgroup or exit.
10527 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10528 (eq gnus-auto-select-next 'quietly))
10529 (gnus-summary-next-group nil)
10530 (gnus-summary-exit))))
10531
10532 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10533 "Mark all articles in this newsgroup as read, and then exit.
10534 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10535 instead, which marks only unread articles as read."
10536 (interactive "P")
10537 (gnus-summary-catchup-and-exit t quietly))
10538
10539 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10540 "Mark all articles in this group as read and select the next group.
10541 If given a prefix, mark all articles, unread as well as ticked, as
10542 read."
10543 (interactive "P")
10544 (save-excursion
10545 (gnus-summary-catchup all))
10546 (gnus-summary-next-group))
10547
10548 ;;;
10549 ;;; with article
10550 ;;;
10551
10552 (defmacro gnus-with-article (article &rest forms)
10553 "Select ARTICLE and perform FORMS in the original article buffer.
10554 Then replace the article with the result."
10555 `(progn
10556 ;; We don't want the article to be marked as read.
10557 (let (gnus-mark-article-hook)
10558 (gnus-summary-select-article t t nil ,article))
10559 (set-buffer gnus-original-article-buffer)
10560 ,@forms
10561 (if (not (gnus-check-backend-function
10562 'request-replace-article (car gnus-article-current)))
10563 (gnus-message 5 "Read-only group; not replacing")
10564 (unless (gnus-request-replace-article
10565 ,article (car gnus-article-current)
10566 (current-buffer) t)
10567 (error "Couldn't replace article")))
10568 ;; The cache and backlog have to be flushed somewhat.
10569 (when gnus-keep-backlog
10570 (gnus-backlog-remove-article
10571 (car gnus-article-current) (cdr gnus-article-current)))
10572 (when gnus-use-cache
10573 (gnus-cache-update-article
10574 (car gnus-article-current) (cdr gnus-article-current)))))
10575
10576 (put 'gnus-with-article 'lisp-indent-function 1)
10577 (put 'gnus-with-article 'edebug-form-spec '(form body))
10578
10579 ;; Thread-based commands.
10580
10581 (defun gnus-summary-articles-in-thread (&optional article)
10582 "Return a list of all articles in the current thread.
10583 If ARTICLE is non-nil, return all articles in the thread that starts
10584 with that article."
10585 (let* ((article (or article (gnus-summary-article-number)))
10586 (data (gnus-data-find-list article))
10587 (top-level (gnus-data-level (car data)))
10588 (top-subject
10589 (cond ((null gnus-thread-operation-ignore-subject)
10590 (gnus-simplify-subject-re
10591 (mail-header-subject (gnus-data-header (car data)))))
10592 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10593 (gnus-simplify-subject-fuzzy
10594 (mail-header-subject (gnus-data-header (car data)))))
10595 (t nil)))
10596 (end-point (save-excursion
10597 (if (gnus-summary-go-to-next-thread)
10598 (point) (point-max))))
10599 articles)
10600 (while (and data
10601 (< (gnus-data-pos (car data)) end-point))
10602 (when (or (not top-subject)
10603 (string= top-subject
10604 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10605 (gnus-simplify-subject-fuzzy
10606 (mail-header-subject
10607 (gnus-data-header (car data))))
10608 (gnus-simplify-subject-re
10609 (mail-header-subject
10610 (gnus-data-header (car data)))))))
10611 (push (gnus-data-number (car data)) articles))
10612 (unless (and (setq data (cdr data))
10613 (> (gnus-data-level (car data)) top-level))
10614 (setq data nil)))
10615 ;; Return the list of articles.
10616 (nreverse articles)))
10617
10618 (defun gnus-summary-rethread-current ()
10619 "Rethread the thread the current article is part of."
10620 (interactive)
10621 (let* ((gnus-show-threads t)
10622 (article (gnus-summary-article-number))
10623 (id (mail-header-id (gnus-summary-article-header)))
10624 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10625 (unless id
10626 (error "No article on the current line"))
10627 (gnus-rebuild-thread id)
10628 (gnus-summary-goto-subject article)))
10629
10630 (defun gnus-summary-reparent-thread ()
10631 "Make the current article child of the marked (or previous) article.
10632
10633 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10634 is non-nil or the Subject: of both articles are the same."
10635 (interactive)
10636 (unless (not (gnus-group-read-only-p))
10637 (error "The current newsgroup does not support article editing"))
10638 (unless (<= (length gnus-newsgroup-processable) 1)
10639 (error "No more than one article may be marked"))
10640 (save-window-excursion
10641 (let ((gnus-article-buffer " *reparent*")
10642 (current-article (gnus-summary-article-number))
10643 ;; First grab the marked article, otherwise one line up.
10644 (parent-article (if (not (null gnus-newsgroup-processable))
10645 (car gnus-newsgroup-processable)
10646 (save-excursion
10647 (if (eq (forward-line -1) 0)
10648 (gnus-summary-article-number)
10649 (error "Beginning of summary buffer"))))))
10650 (unless (not (eq current-article parent-article))
10651 (error "An article may not be self-referential"))
10652 (let ((message-id (mail-header-id
10653 (gnus-summary-article-header parent-article))))
10654 (unless (and message-id (not (equal message-id "")))
10655 (error "No message-id in desired parent"))
10656 (gnus-with-article current-article
10657 (save-restriction
10658 (goto-char (point-min))
10659 (message-narrow-to-head)
10660 (if (re-search-forward "^References: " nil t)
10661 (progn
10662 (re-search-forward "^[^ \t]" nil t)
10663 (forward-line -1)
10664 (end-of-line)
10665 (insert " " message-id))
10666 (insert "References: " message-id "\n"))))
10667 (set-buffer gnus-summary-buffer)
10668 (gnus-summary-unmark-all-processable)
10669 (gnus-summary-update-article current-article)
10670 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10671 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10672 (gnus-summary-rethread-current)
10673 (gnus-message 3 "Article %d is now the child of article %d"
10674 current-article parent-article)))))
10675
10676 (defun gnus-summary-toggle-threads (&optional arg)
10677 "Toggle showing conversation threads.
10678 If ARG is positive number, turn showing conversation threads on."
10679 (interactive "P")
10680 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10681 (setq gnus-show-threads
10682 (if (null arg) (not gnus-show-threads)
10683 (> (prefix-numeric-value arg) 0)))
10684 (gnus-summary-prepare)
10685 (gnus-summary-goto-subject current)
10686 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10687 (gnus-summary-position-point)))
10688
10689 (defun gnus-summary-show-all-threads ()
10690 "Show all threads."
10691 (interactive)
10692 (save-excursion
10693 (let ((buffer-read-only nil))
10694 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10695 (gnus-summary-position-point))
10696
10697 (defun gnus-summary-show-thread ()
10698 "Show thread subtrees.
10699 Returns nil if no thread was there to be shown."
10700 (interactive)
10701 (let ((buffer-read-only nil)
10702 (orig (point))
10703 (end (gnus-point-at-eol))
10704 ;; Leave point at bol
10705 (beg (progn (beginning-of-line) (point))))
10706 (prog1
10707 ;; Any hidden lines here?
10708 (search-forward "\r" end t)
10709 (subst-char-in-region beg end ?\^M ?\n t)
10710 (goto-char orig)
10711 (gnus-summary-position-point))))
10712
10713 (defun gnus-summary-maybe-hide-threads ()
10714 "If requested, hide the threads that should be hidden."
10715 (when (and gnus-show-threads
10716 gnus-thread-hide-subtree)
10717 (gnus-summary-hide-all-threads
10718 (if (or (consp gnus-thread-hide-subtree)
10719 (functionp gnus-thread-hide-subtree))
10720 (gnus-make-predicate gnus-thread-hide-subtree)
10721 nil))))
10722
10723 ;;; Hiding predicates.
10724
10725 (defun gnus-article-unread-p (header)
10726 (memq (mail-header-number header) gnus-newsgroup-unreads))
10727
10728 (defun gnus-article-unseen-p (header)
10729 (memq (mail-header-number header) gnus-newsgroup-unseen))
10730
10731 (defun gnus-map-articles (predicate articles)
10732 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10733 (apply 'gnus-or (mapcar predicate
10734 (mapcar (lambda (number)
10735 (gnus-summary-article-header number))
10736 articles))))
10737
10738 (defun gnus-summary-hide-all-threads (&optional predicate)
10739 "Hide all thread subtrees.
10740 If PREDICATE is supplied, threads that satisfy this predicate
10741 will not be hidden."
10742 (interactive)
10743 (save-excursion
10744 (goto-char (point-min))
10745 (let ((end nil))
10746 (while (not end)
10747 (when (or (not predicate)
10748 (gnus-map-articles
10749 predicate (gnus-summary-article-children)))
10750 (gnus-summary-hide-thread))
10751 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10752 (gnus-summary-position-point))
10753
10754 (defun gnus-summary-hide-thread ()
10755 "Hide thread subtrees.
10756 If PREDICATE is supplied, threads that satisfy this predicate
10757 will not be hidden.
10758 Returns nil if no threads were there to be hidden."
10759 (interactive)
10760 (let ((buffer-read-only nil)
10761 (start (point))
10762 (article (gnus-summary-article-number)))
10763 (goto-char start)
10764 ;; Go forward until either the buffer ends or the subthread
10765 ;; ends.
10766 (when (and (not (eobp))
10767 (or (zerop (gnus-summary-next-thread 1 t))
10768 (goto-char (point-max))))
10769 (prog1
10770 (if (and (> (point) start)
10771 (search-backward "\n" start t))
10772 (progn
10773 (subst-char-in-region start (point) ?\n ?\^M)
10774 (gnus-summary-goto-subject article))
10775 (goto-char start)
10776 nil)))))
10777
10778 (defun gnus-summary-go-to-next-thread (&optional previous)
10779 "Go to the same level (or less) next thread.
10780 If PREVIOUS is non-nil, go to previous thread instead.
10781 Return the article number moved to, or nil if moving was impossible."
10782 (let ((level (gnus-summary-thread-level))
10783 (way (if previous -1 1))
10784 (beg (point)))
10785 (forward-line way)
10786 (while (and (not (eobp))
10787 (< level (gnus-summary-thread-level)))
10788 (forward-line way))
10789 (if (eobp)
10790 (progn
10791 (goto-char beg)
10792 nil)
10793 (setq beg (point))
10794 (prog1
10795 (gnus-summary-article-number)
10796 (goto-char beg)))))
10797
10798 (defun gnus-summary-next-thread (n &optional silent)
10799 "Go to the same level next N'th thread.
10800 If N is negative, search backward instead.
10801 Returns the difference between N and the number of skips actually
10802 done.
10803
10804 If SILENT, don't output messages."
10805 (interactive "p")
10806 (let ((backward (< n 0))
10807 (n (abs n)))
10808 (while (and (> n 0)
10809 (gnus-summary-go-to-next-thread backward))
10810 (decf n))
10811 (unless silent
10812 (gnus-summary-position-point))
10813 (when (and (not silent) (/= 0 n))
10814 (gnus-message 7 "No more threads"))
10815 n))
10816
10817 (defun gnus-summary-prev-thread (n)
10818 "Go to the same level previous N'th thread.
10819 Returns the difference between N and the number of skips actually
10820 done."
10821 (interactive "p")
10822 (gnus-summary-next-thread (- n)))
10823
10824 (defun gnus-summary-go-down-thread ()
10825 "Go down one level in the current thread."
10826 (let ((children (gnus-summary-article-children)))
10827 (when children
10828 (gnus-summary-goto-subject (car children)))))
10829
10830 (defun gnus-summary-go-up-thread ()
10831 "Go up one level in the current thread."
10832 (let ((parent (gnus-summary-article-parent)))
10833 (when parent
10834 (gnus-summary-goto-subject parent))))
10835
10836 (defun gnus-summary-down-thread (n)
10837 "Go down thread N steps.
10838 If N is negative, go up instead.
10839 Returns the difference between N and how many steps down that were
10840 taken."
10841 (interactive "p")
10842 (let ((up (< n 0))
10843 (n (abs n)))
10844 (while (and (> n 0)
10845 (if up (gnus-summary-go-up-thread)
10846 (gnus-summary-go-down-thread)))
10847 (setq n (1- n)))
10848 (gnus-summary-position-point)
10849 (when (/= 0 n)
10850 (gnus-message 7 "Can't go further"))
10851 n))
10852
10853 (defun gnus-summary-up-thread (n)
10854 "Go up thread N steps.
10855 If N is negative, go down instead.
10856 Returns the difference between N and how many steps down that were
10857 taken."
10858 (interactive "p")
10859 (gnus-summary-down-thread (- n)))
10860
10861 (defun gnus-summary-top-thread ()
10862 "Go to the top of the thread."
10863 (interactive)
10864 (while (gnus-summary-go-up-thread))
10865 (gnus-summary-article-number))
10866
10867 (defun gnus-summary-kill-thread (&optional unmark)
10868 "Mark articles under current thread as read.
10869 If the prefix argument is positive, remove any kinds of marks.
10870 If the prefix argument is negative, tick articles instead."
10871 (interactive "P")
10872 (when unmark
10873 (setq unmark (prefix-numeric-value unmark)))
10874 (let ((articles (gnus-summary-articles-in-thread)))
10875 (save-excursion
10876 ;; Expand the thread.
10877 (gnus-summary-show-thread)
10878 ;; Mark all the articles.
10879 (while articles
10880 (gnus-summary-goto-subject (car articles))
10881 (cond ((null unmark)
10882 (gnus-summary-mark-article-as-read gnus-killed-mark))
10883 ((> unmark 0)
10884 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10885 (t
10886 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10887 (setq articles (cdr articles))))
10888 ;; Hide killed subtrees.
10889 (and (null unmark)
10890 gnus-thread-hide-killed
10891 (gnus-summary-hide-thread))
10892 ;; If marked as read, go to next unread subject.
10893 (when (null unmark)
10894 ;; Go to next unread subject.
10895 (gnus-summary-next-subject 1 t)))
10896 (gnus-set-mode-line 'summary))
10897
10898 ;; Summary sorting commands
10899
10900 (defun gnus-summary-sort-by-number (&optional reverse)
10901 "Sort the summary buffer by article number.
10902 Argument REVERSE means reverse order."
10903 (interactive "P")
10904 (gnus-summary-sort 'number reverse))
10905
10906 (defun gnus-summary-sort-by-random (&optional reverse)
10907 "Randomize the order in the summary buffer.
10908 Argument REVERSE means to randomize in reverse order."
10909 (interactive "P")
10910 (gnus-summary-sort 'random reverse))
10911
10912 (defun gnus-summary-sort-by-author (&optional reverse)
10913 "Sort the summary buffer by author name alphabetically.
10914 If `case-fold-search' is non-nil, case of letters is ignored.
10915 Argument REVERSE means reverse order."
10916 (interactive "P")
10917 (gnus-summary-sort 'author reverse))
10918
10919 (defun gnus-summary-sort-by-subject (&optional reverse)
10920 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10921 If `case-fold-search' is non-nil, case of letters is ignored.
10922 Argument REVERSE means reverse order."
10923 (interactive "P")
10924 (gnus-summary-sort 'subject reverse))
10925
10926 (defun gnus-summary-sort-by-date (&optional reverse)
10927 "Sort the summary buffer by date.
10928 Argument REVERSE means reverse order."
10929 (interactive "P")
10930 (gnus-summary-sort 'date reverse))
10931
10932 (defun gnus-summary-sort-by-score (&optional reverse)
10933 "Sort the summary buffer by score.
10934 Argument REVERSE means reverse order."
10935 (interactive "P")
10936 (gnus-summary-sort 'score reverse))
10937
10938 (defun gnus-summary-sort-by-lines (&optional reverse)
10939 "Sort the summary buffer by the number of lines.
10940 Argument REVERSE means reverse order."
10941 (interactive "P")
10942 (gnus-summary-sort 'lines reverse))
10943
10944 (defun gnus-summary-sort-by-chars (&optional reverse)
10945 "Sort the summary buffer by article length.
10946 Argument REVERSE means reverse order."
10947 (interactive "P")
10948 (gnus-summary-sort 'chars reverse))
10949
10950 (defun gnus-summary-sort-by-original (&optional reverse)
10951 "Sort the summary buffer using the default sorting method.
10952 Argument REVERSE means reverse order."
10953 (interactive "P")
10954 (let* ((buffer-read-only)
10955 (gnus-summary-prepare-hook nil))
10956 ;; We do the sorting by regenerating the threads.
10957 (gnus-summary-prepare)
10958 ;; Hide subthreads if needed.
10959 (gnus-summary-maybe-hide-threads)))
10960
10961 (defun gnus-summary-sort (predicate reverse)
10962 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10963 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10964 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10965 (gnus-thread-sort-functions
10966 (if (not reverse)
10967 thread
10968 `(lambda (t1 t2)
10969 (,thread t2 t1))))
10970 (gnus-sort-gathered-threads-function
10971 gnus-thread-sort-functions)
10972 (gnus-article-sort-functions
10973 (if (not reverse)
10974 article
10975 `(lambda (t1 t2)
10976 (,article t2 t1))))
10977 (buffer-read-only)
10978 (gnus-summary-prepare-hook nil))
10979 ;; We do the sorting by regenerating the threads.
10980 (gnus-summary-prepare)
10981 ;; Hide subthreads if needed.
10982 (gnus-summary-maybe-hide-threads)))
10983
10984 ;; Summary saving commands.
10985
10986 (defun gnus-summary-save-article (&optional n not-saved)
10987 "Save the current article using the default saver function.
10988 If N is a positive number, save the N next articles.
10989 If N is a negative number, save the N previous articles.
10990 If N is nil and any articles have been marked with the process mark,
10991 save those articles instead.
10992 The variable `gnus-default-article-saver' specifies the saver function.
10993
10994 If the optional second argument NOT-SAVED is non-nil, articles saved
10995 will not be marked as saved."
10996 (interactive "P")
10997 (require 'gnus-art)
10998 (let* ((articles (gnus-summary-work-articles n))
10999 (save-buffer (save-excursion
11000 (nnheader-set-temp-buffer " *Gnus Save*")))
11001 (num (length articles))
11002 ;; Whether to save decoded articles or raw articles.
11003 (decode (when gnus-article-save-coding-system
11004 (get gnus-default-article-saver :decode)))
11005 ;; When saving many articles in a single file, use the other
11006 ;; function to save articles other than the first one.
11007 (saver2 (get gnus-default-article-saver :function))
11008 (gnus-prompt-before-saving (if saver2
11009 t
11010 gnus-prompt-before-saving))
11011 (gnus-default-article-saver gnus-default-article-saver)
11012 header file)
11013 (dolist (article articles)
11014 (setq header (gnus-summary-article-header article))
11015 (if (not (vectorp header))
11016 ;; This is a pseudo-article.
11017 (if (assq 'name header)
11018 (gnus-copy-file (cdr (assq 'name header)))
11019 (gnus-message 1 "Article %d is unsaveable" article))
11020 ;; This is a real article.
11021 (save-window-excursion
11022 (let ((gnus-display-mime-function (when decode
11023 gnus-display-mime-function))
11024 (gnus-article-prepare-hook (when decode
11025 gnus-article-prepare-hook)))
11026 (gnus-summary-select-article t nil nil article)
11027 (gnus-summary-goto-subject article)))
11028 (save-excursion
11029 (set-buffer save-buffer)
11030 (erase-buffer)
11031 (insert-buffer-substring (if decode
11032 gnus-article-buffer
11033 gnus-original-article-buffer)))
11034 (setq file (gnus-article-save save-buffer file num))
11035 (gnus-summary-remove-process-mark article)
11036 (unless not-saved
11037 (gnus-summary-set-saved-mark article)))
11038 (when saver2
11039 (setq gnus-default-article-saver saver2
11040 saver2 nil)))
11041 (gnus-kill-buffer save-buffer)
11042 (gnus-summary-position-point)
11043 (gnus-set-mode-line 'summary)
11044 n))
11045
11046 (defun gnus-summary-pipe-output (&optional arg headers)
11047 "Pipe the current article to a subprocess.
11048 If N is a positive number, pipe the N next articles.
11049 If N is a negative number, pipe the N previous articles.
11050 If N is nil and any articles have been marked with the process mark,
11051 pipe those articles instead.
11052 If HEADERS (the symbolic prefix), include the headers, too."
11053 (interactive (gnus-interactive "P\ny"))
11054 (require 'gnus-art)
11055 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11056 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11057 (gnus-summary-save-article arg t))
11058 (let ((buffer (get-buffer "*Shell Command Output*")))
11059 (when (and buffer
11060 (not (zerop (buffer-size buffer))))
11061 (gnus-configure-windows 'pipe))))
11062
11063 (defun gnus-summary-save-article-mail (&optional arg)
11064 "Append the current article to a Unix mail box file.
11065 If N is a positive number, save the N next articles.
11066 If N is a negative number, save the N previous articles.
11067 If N is nil and any articles have been marked with the process mark,
11068 save those articles instead."
11069 (interactive "P")
11070 (require 'gnus-art)
11071 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11072 (gnus-summary-save-article arg)))
11073
11074 (defun gnus-summary-save-article-rmail (&optional arg)
11075 "Append the current article to an rmail file.
11076 If N is a positive number, save the N next articles.
11077 If N is a negative number, save the N previous articles.
11078 If N is nil and any articles have been marked with the process mark,
11079 save those articles instead."
11080 (interactive "P")
11081 (require 'gnus-art)
11082 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11083 (gnus-summary-save-article arg)))
11084
11085 (defun gnus-summary-save-article-file (&optional arg)
11086 "Append the current article to a file.
11087 If N is a positive number, save the N next articles.
11088 If N is a negative number, save the N previous articles.
11089 If N is nil and any articles have been marked with the process mark,
11090 save those articles instead."
11091 (interactive "P")
11092 (require 'gnus-art)
11093 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11094 (gnus-summary-save-article arg)))
11095
11096 (defun gnus-summary-write-article-file (&optional arg)
11097 "Write the current article to a file, deleting the previous file.
11098 If N is a positive number, save the N next articles.
11099 If N is a negative number, save the N previous articles.
11100 If N is nil and any articles have been marked with the process mark,
11101 save those articles instead."
11102 (interactive "P")
11103 (require 'gnus-art)
11104 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11105 (gnus-summary-save-article arg)))
11106
11107 (defun gnus-summary-save-article-body-file (&optional arg)
11108 "Append the current article body to a file.
11109 If N is a positive number, save the N next articles.
11110 If N is a negative number, save the N previous articles.
11111 If N is nil and any articles have been marked with the process mark,
11112 save those articles instead."
11113 (interactive "P")
11114 (require 'gnus-art)
11115 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11116 (gnus-summary-save-article arg)))
11117
11118 (defun gnus-summary-write-article-body-file (&optional arg)
11119 "Write the current article body to a file, deleting the previous file.
11120 If N is a positive number, save the N next articles.
11121 If N is a negative number, save the N previous articles.
11122 If N is nil and any articles have been marked with the process mark,
11123 save those articles instead."
11124 (interactive "P")
11125 (require 'gnus-art)
11126 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11127 (gnus-summary-save-article arg)))
11128
11129 (defun gnus-summary-muttprint (&optional arg)
11130 "Print the current article using Muttprint.
11131 If N is a positive number, save the N next articles.
11132 If N is a negative number, save the N previous articles.
11133 If N is nil and any articles have been marked with the process mark,
11134 save those articles instead."
11135 (interactive "P")
11136 (require 'gnus-art)
11137 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11138 (gnus-summary-save-article arg t)))
11139
11140 (defun gnus-summary-pipe-message (program)
11141 "Pipe the current article through PROGRAM."
11142 (interactive "sProgram: ")
11143 (gnus-summary-select-article)
11144 (let ((mail-header-separator ""))
11145 (gnus-eval-in-buffer-window gnus-article-buffer
11146 (save-restriction
11147 (widen)
11148 (let ((start (window-start))
11149 buffer-read-only)
11150 (message-pipe-buffer-body program)
11151 (set-window-start (get-buffer-window (current-buffer)) start))))))
11152
11153 (defun gnus-get-split-value (methods)
11154 "Return a value based on the split METHODS."
11155 (let (split-name method result match)
11156 (when methods
11157 (save-excursion
11158 (set-buffer gnus-original-article-buffer)
11159 (save-restriction
11160 (nnheader-narrow-to-headers)
11161 (while (and methods (not split-name))
11162 (goto-char (point-min))
11163 (setq method (pop methods))
11164 (setq match (car method))
11165 (when (cond
11166 ((stringp match)
11167 ;; Regular expression.
11168 (ignore-errors
11169 (re-search-forward match nil t)))
11170 ((functionp match)
11171 ;; Function.
11172 (save-restriction
11173 (widen)
11174 (setq result (funcall match gnus-newsgroup-name))))
11175 ((consp match)
11176 ;; Form.
11177 (save-restriction
11178 (widen)
11179 (setq result (eval match)))))
11180 (setq split-name (cdr method))
11181 (cond ((stringp result)
11182 (push (expand-file-name
11183 result gnus-article-save-directory)
11184 split-name))
11185 ((consp result)
11186 (setq split-name (append result split-name)))))))))
11187 (nreverse split-name)))
11188
11189 (defun gnus-valid-move-group-p (group)
11190 (and (boundp group)
11191 (symbol-name group)
11192 (symbol-value group)
11193 (gnus-get-function (gnus-find-method-for-group
11194 (symbol-name group)) 'request-accept-article t)))
11195
11196 (defun gnus-read-move-group-name (prompt default articles prefix)
11197 "Read a group name."
11198 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11199 (minibuffer-confirm-incomplete nil) ; XEmacs
11200 (prom
11201 (format "%s %s to"
11202 prompt
11203 (if (> (length articles) 1)
11204 (format "these %d articles" (length articles))
11205 "this article")))
11206 (to-newsgroup
11207 (cond
11208 ((null split-name)
11209 (gnus-completing-read-with-default
11210 default prom
11211 gnus-active-hashtb
11212 'gnus-valid-move-group-p
11213 nil prefix
11214 'gnus-group-history))
11215 ((= 1 (length split-name))
11216 (gnus-completing-read-with-default
11217 (car split-name) prom
11218 gnus-active-hashtb
11219 'gnus-valid-move-group-p
11220 nil nil
11221 'gnus-group-history))
11222 (t
11223 (gnus-completing-read-with-default
11224 nil prom
11225 (mapcar (lambda (el) (list el))
11226 (nreverse split-name))
11227 nil nil nil
11228 'gnus-group-history))))
11229 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11230 (when to-newsgroup
11231 (if (or (string= to-newsgroup "")
11232 (string= to-newsgroup prefix))
11233 (setq to-newsgroup default))
11234 (unless to-newsgroup
11235 (error "No group name entered"))
11236 (or (gnus-active to-newsgroup)
11237 (gnus-activate-group to-newsgroup nil nil to-method)
11238 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11239 to-newsgroup))
11240 (or (and (gnus-request-create-group to-newsgroup to-method)
11241 (gnus-activate-group
11242 to-newsgroup nil nil to-method)
11243 (gnus-subscribe-group to-newsgroup))
11244 (error "Couldn't create group %s" to-newsgroup)))
11245 (error "No such group: %s" to-newsgroup)))
11246 to-newsgroup))
11247
11248 (defun gnus-summary-save-parts (type dir n &optional reverse)
11249 "Save parts matching TYPE to DIR.
11250 If REVERSE, save parts that do not match TYPE."
11251 (interactive
11252 (list (read-string "Save parts of type: "
11253 (or (car gnus-summary-save-parts-type-history)
11254 gnus-summary-save-parts-default-mime)
11255 'gnus-summary-save-parts-type-history)
11256 (setq gnus-summary-save-parts-last-directory
11257 (read-file-name "Save to directory: "
11258 gnus-summary-save-parts-last-directory
11259 nil t))
11260 current-prefix-arg))
11261 (gnus-summary-iterate n
11262 (let ((gnus-display-mime-function nil)
11263 (gnus-inhibit-treatment t))
11264 (gnus-summary-select-article))
11265 (save-excursion
11266 (set-buffer gnus-article-buffer)
11267 (let ((handles (or gnus-article-mime-handles
11268 (mm-dissect-buffer nil gnus-article-loose-mime)
11269 (and gnus-article-emulate-mime
11270 (mm-uu-dissect)))))
11271 (when handles
11272 (gnus-summary-save-parts-1 type dir handles reverse)
11273 (unless gnus-article-mime-handles ;; Don't destroy this case.
11274 (mm-destroy-parts handles)))))))
11275
11276 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11277 (if (stringp (car handle))
11278 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11279 (cdr handle))
11280 (when (if reverse
11281 (not (string-match type (mm-handle-media-type handle)))
11282 (string-match type (mm-handle-media-type handle)))
11283 (let ((file (expand-file-name
11284 (gnus-map-function
11285 mm-file-name-rewrite-functions
11286 (file-name-nondirectory
11287 (or
11288 (mail-content-type-get
11289 (mm-handle-disposition handle) 'filename)
11290 (mail-content-type-get
11291 (mm-handle-type handle) 'name)
11292 (concat gnus-newsgroup-name
11293 "." (number-to-string
11294 (cdr gnus-article-current))))))
11295 dir)))
11296 (unless (file-exists-p file)
11297 (mm-save-part-to-file handle file))))))
11298
11299 ;; Summary extract commands
11300
11301 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11302 (let ((buffer-read-only nil)
11303 (article (gnus-summary-article-number))
11304 after-article b e)
11305 (unless (gnus-summary-goto-subject article)
11306 (error "No such article: %d" article))
11307 (gnus-summary-position-point)
11308 ;; If all commands are to be bunched up on one line, we collect
11309 ;; them here.
11310 (unless gnus-view-pseudos-separately
11311 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11312 files action)
11313 (while ps
11314 (setq action (cdr (assq 'action (car ps))))
11315 (setq files (list (cdr (assq 'name (car ps)))))
11316 (while (and ps (cdr ps)
11317 (string= (or action "1")
11318 (or (cdr (assq 'action (cadr ps))) "2")))
11319 (push (cdr (assq 'name (cadr ps))) files)
11320 (setcdr ps (cddr ps)))
11321 (when files
11322 (when (not (string-match "%s" action))
11323 (push " " files))
11324 (push " " files)
11325 (when (assq 'execute (car ps))
11326 (setcdr (assq 'execute (car ps))
11327 (funcall (if (string-match "%s" action)
11328 'format 'concat)
11329 action
11330 (mapconcat
11331 (lambda (f)
11332 (if (equal f " ")
11333 f
11334 (mm-quote-arg f)))
11335 files " ")))))
11336 (setq ps (cdr ps)))))
11337 (if (and gnus-view-pseudos (not not-view))
11338 (while pslist
11339 (when (assq 'execute (car pslist))
11340 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11341 (eq gnus-view-pseudos 'not-confirm)))
11342 (setq pslist (cdr pslist)))
11343 (save-excursion
11344 (while pslist
11345 (setq after-article (or (cdr (assq 'article (car pslist)))
11346 (gnus-summary-article-number)))
11347 (gnus-summary-goto-subject after-article)
11348 (forward-line 1)
11349 (setq b (point))
11350 (insert " " (file-name-nondirectory
11351 (cdr (assq 'name (car pslist))))
11352 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11353 (setq e (point))
11354 (forward-line -1) ; back to `b'
11355 (gnus-add-text-properties
11356 b (1- e) (list 'gnus-number gnus-reffed-article-number
11357 gnus-mouse-face-prop gnus-mouse-face))
11358 (gnus-data-enter
11359 after-article gnus-reffed-article-number
11360 gnus-unread-mark b (car pslist) 0 (- e b))
11361 (setq gnus-newsgroup-unreads
11362 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11363 gnus-reffed-article-number))
11364 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11365 (setq pslist (cdr pslist)))))))
11366
11367 (defun gnus-pseudos< (p1 p2)
11368 (let ((c1 (cdr (assq 'action p1)))
11369 (c2 (cdr (assq 'action p2))))
11370 (and c1 c2 (string< c1 c2))))
11371
11372 (defun gnus-request-pseudo-article (props)
11373 (cond ((assq 'execute props)
11374 (gnus-execute-command (cdr (assq 'execute props)))))
11375 (let ((gnus-current-article (gnus-summary-article-number)))
11376 (gnus-run-hooks 'gnus-mark-article-hook)))
11377
11378 (defun gnus-execute-command (command &optional automatic)
11379 (save-excursion
11380 (gnus-article-setup-buffer)
11381 (set-buffer gnus-article-buffer)
11382 (setq buffer-read-only nil)
11383 (let ((command (if automatic command
11384 (read-string "Command: " (cons command 0)))))
11385 (erase-buffer)
11386 (insert "$ " command "\n\n")
11387 (if gnus-view-pseudo-asynchronously
11388 (start-process "gnus-execute" (current-buffer) shell-file-name
11389 shell-command-switch command)
11390 (call-process shell-file-name nil t nil
11391 shell-command-switch command)))))
11392
11393 ;; Summary kill commands.
11394
11395 (defun gnus-summary-edit-global-kill (article)
11396 "Edit the \"global\" kill file."
11397 (interactive (list (gnus-summary-article-number)))
11398 (gnus-group-edit-global-kill article))
11399
11400 (defun gnus-summary-edit-local-kill ()
11401 "Edit a local kill file applied to the current newsgroup."
11402 (interactive)
11403 (setq gnus-current-headers (gnus-summary-article-header))
11404 (gnus-group-edit-local-kill
11405 (gnus-summary-article-number) gnus-newsgroup-name))
11406
11407 ;;; Header reading.
11408
11409 (defun gnus-read-header (id &optional header)
11410 "Read the headers of article ID and enter them into the Gnus system."
11411 (let ((group gnus-newsgroup-name)
11412 (gnus-override-method
11413 (or
11414 gnus-override-method
11415 (and (gnus-news-group-p gnus-newsgroup-name)
11416 (car (gnus-refer-article-methods)))))
11417 where)
11418 ;; First we check to see whether the header in question is already
11419 ;; fetched.
11420 (if (stringp id)
11421 ;; This is a Message-ID.
11422 (setq header (or header (gnus-id-to-header id)))
11423 ;; This is an article number.
11424 (setq header (or header (gnus-summary-article-header id))))
11425 (if (and header
11426 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11427 ;; We have found the header.
11428 header
11429 ;; We have to really fetch the header to this article.
11430 (save-excursion
11431 (set-buffer nntp-server-buffer)
11432 (when (setq where (gnus-request-head id group))
11433 (nnheader-fold-continuation-lines)
11434 (goto-char (point-max))
11435 (insert ".\n")
11436 (goto-char (point-min))
11437 (insert "211 ")
11438 (princ (cond
11439 ((numberp id) id)
11440 ((cdr where) (cdr where))
11441 (header (mail-header-number header))
11442 (t gnus-reffed-article-number))
11443 (current-buffer))
11444 (insert " Article retrieved.\n"))
11445 (if (or (not where)
11446 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11447 () ; Malformed head.
11448 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11449 (when (and (stringp id)
11450 (not (string= (gnus-group-real-name group)
11451 (car where))))
11452 ;; If we fetched by Message-ID and the article came
11453 ;; from a different group, we fudge some bogus article
11454 ;; numbers for this article.
11455 (mail-header-set-number header gnus-reffed-article-number))
11456 (save-excursion
11457 (set-buffer gnus-summary-buffer)
11458 (decf gnus-reffed-article-number)
11459 (gnus-remove-header (mail-header-number header))
11460 (push header gnus-newsgroup-headers)
11461 (setq gnus-current-headers header)
11462 (push (mail-header-number header) gnus-newsgroup-limit)))
11463 header)))))
11464
11465 (defun gnus-remove-header (number)
11466 "Remove header NUMBER from `gnus-newsgroup-headers'."
11467 (if (and gnus-newsgroup-headers
11468 (= number (mail-header-number (car gnus-newsgroup-headers))))
11469 (pop gnus-newsgroup-headers)
11470 (let ((headers gnus-newsgroup-headers))
11471 (while (and (cdr headers)
11472 (not (= number (mail-header-number (cadr headers)))))
11473 (pop headers))
11474 (when (cdr headers)
11475 (setcdr headers (cddr headers))))))
11476
11477 ;;;
11478 ;;; summary highlights
11479 ;;;
11480
11481 (defun gnus-highlight-selected-summary ()
11482 "Highlight selected article in summary buffer."
11483 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11484 (when gnus-summary-selected-face
11485 (save-excursion
11486 (let* ((beg (gnus-point-at-bol))
11487 (end (gnus-point-at-eol))
11488 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11489 (from (if (get-text-property beg gnus-mouse-face-prop)
11490 beg
11491 (or (next-single-property-change
11492 beg gnus-mouse-face-prop nil end)
11493 beg)))
11494 (to
11495 (if (= from end)
11496 (- from 2)
11497 (or (next-single-property-change
11498 from gnus-mouse-face-prop nil end)
11499 end))))
11500 ;; If no mouse-face prop on line we will have to = from = end,
11501 ;; so we highlight the entire line instead.
11502 (when (= (+ to 2) from)
11503 (setq from beg)
11504 (setq to end))
11505 (if gnus-newsgroup-selected-overlay
11506 ;; Move old overlay.
11507 (gnus-move-overlay
11508 gnus-newsgroup-selected-overlay from to (current-buffer))
11509 ;; Create new overlay.
11510 (gnus-overlay-put
11511 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11512 'face gnus-summary-selected-face))))))
11513
11514 (defvar gnus-summary-highlight-line-cached nil)
11515 (defvar gnus-summary-highlight-line-trigger nil)
11516
11517 (defun gnus-summary-highlight-line-0 ()
11518 (if (and (eq gnus-summary-highlight-line-trigger
11519 gnus-summary-highlight)
11520 gnus-summary-highlight-line-cached)
11521 gnus-summary-highlight-line-cached
11522 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11523 gnus-summary-highlight-line-cached
11524 (let* ((cond (list 'cond))
11525 (c cond)
11526 (list gnus-summary-highlight))
11527 (while list
11528 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11529 nil))
11530 (setq c (cdr c)
11531 list (cdr list)))
11532 (gnus-byte-compile (list 'lambda nil cond))))))
11533
11534 (defun gnus-summary-highlight-line ()
11535 "Highlight current line according to `gnus-summary-highlight'."
11536 (let* ((beg (gnus-point-at-bol))
11537 (article (or (gnus-summary-article-number) gnus-current-article))
11538 (score (or (cdr (assq article
11539 gnus-newsgroup-scored))
11540 gnus-summary-default-score 0))
11541 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11542 (inhibit-read-only t)
11543 (default gnus-summary-default-score)
11544 (default-high gnus-summary-default-high-score)
11545 (default-low gnus-summary-default-low-score)
11546 (uncached (and gnus-summary-use-undownloaded-faces
11547 (memq article gnus-newsgroup-undownloaded)
11548 (not (memq article gnus-newsgroup-cached)))))
11549 (let ((face (funcall (gnus-summary-highlight-line-0))))
11550 (unless (eq face (get-text-property beg 'face))
11551 (gnus-put-text-property-excluding-characters-with-faces
11552 beg (gnus-point-at-eol) 'face
11553 (setq face (if (boundp face) (symbol-value face) face)))
11554 (when gnus-summary-highlight-line-function
11555 (funcall gnus-summary-highlight-line-function article face))))))
11556
11557 (defun gnus-update-read-articles (group unread &optional compute)
11558 "Update the list of read articles in GROUP.
11559 UNREAD is a sorted list."
11560 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11561 (entry (gnus-gethash group gnus-newsrc-hashtb))
11562 (info (nth 2 entry))
11563 (prev 1)
11564 read)
11565 (if (or (not info) (not active))
11566 ;; There is no info on this group if it was, in fact,
11567 ;; killed. Gnus stores no information on killed groups, so
11568 ;; there's nothing to be done.
11569 ;; One could store the information somewhere temporarily,
11570 ;; perhaps... Hmmm...
11571 ()
11572 ;; Remove any negative articles numbers.
11573 (while (and unread (< (car unread) 0))
11574 (setq unread (cdr unread)))
11575 ;; Remove any expired article numbers
11576 (while (and unread (< (car unread) (car active)))
11577 (setq unread (cdr unread)))
11578 ;; Compute the ranges of read articles by looking at the list of
11579 ;; unread articles.
11580 (while unread
11581 (when (/= (car unread) prev)
11582 (push (if (= prev (1- (car unread))) prev
11583 (cons prev (1- (car unread))))
11584 read))
11585 (setq prev (1+ (car unread)))
11586 (setq unread (cdr unread)))
11587 (when (<= prev (cdr active))
11588 (push (cons prev (cdr active)) read))
11589 (setq read (if (> (length read) 1) (nreverse read) read))
11590 (if compute
11591 read
11592 (save-excursion
11593 (let (setmarkundo)
11594 ;; Propagate the read marks to the backend.
11595 (when (gnus-check-backend-function 'request-set-mark group)
11596 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11597 (add (gnus-remove-from-range read (gnus-info-read info))))
11598 (when (or add del)
11599 (unless (gnus-check-group group)
11600 (error "Can't open server for %s" group))
11601 (gnus-request-set-mark
11602 group (delq nil (list (if add (list add 'add '(read)))
11603 (if del (list del 'del '(read))))))
11604 (setq setmarkundo
11605 `(gnus-request-set-mark
11606 ,group
11607 ',(delq nil (list
11608 (if del (list del 'add '(read)))
11609 (if add (list add 'del '(read))))))))))
11610 (set-buffer gnus-group-buffer)
11611 (gnus-undo-register
11612 `(progn
11613 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11614 (gnus-info-set-read ',info ',(gnus-info-read info))
11615 (gnus-get-unread-articles-in-group ',info
11616 (gnus-active ,group))
11617 (gnus-group-update-group ,group t)
11618 ,setmarkundo))))
11619 ;; Enter this list into the group info.
11620 (gnus-info-set-read info read)
11621 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11622 (gnus-get-unread-articles-in-group info (gnus-active group))
11623 t))))
11624
11625 (defun gnus-offer-save-summaries ()
11626 "Offer to save all active summary buffers."
11627 (let (buffers)
11628 ;; Go through all buffers and find all summaries.
11629 (dolist (buffer (buffer-list))
11630 (when (and (setq buffer (buffer-name buffer))
11631 (string-match "Summary" buffer)
11632 (save-excursion
11633 (set-buffer buffer)
11634 ;; We check that this is, indeed, a summary buffer.
11635 (and (eq major-mode 'gnus-summary-mode)
11636 ;; Also make sure this isn't bogus.
11637 gnus-newsgroup-prepared
11638 ;; Also make sure that this isn't a
11639 ;; dead summary buffer.
11640 (not gnus-dead-summary-mode))))
11641 (push buffer buffers)))
11642 ;; Go through all these summary buffers and offer to save them.
11643 (when buffers
11644 (save-excursion
11645 (map-y-or-n-p
11646 "Update summary buffer %s? "
11647 (lambda (buf)
11648 (switch-to-buffer buf)
11649 (gnus-summary-exit))
11650 buffers)))))
11651
11652 (defun gnus-summary-setup-default-charset ()
11653 "Setup newsgroup default charset."
11654 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11655 (setq gnus-newsgroup-charset nil)
11656 (let* ((ignored-charsets
11657 (or gnus-newsgroup-ephemeral-ignored-charsets
11658 (append
11659 (and gnus-newsgroup-name
11660 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11661 gnus-newsgroup-ignored-charsets))))
11662 (setq gnus-newsgroup-charset
11663 (or gnus-newsgroup-ephemeral-charset
11664 (and gnus-newsgroup-name
11665 (gnus-parameter-charset gnus-newsgroup-name))
11666 gnus-default-charset))
11667 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11668 ignored-charsets))))
11669
11670 ;;;
11671 ;;; Mime Commands
11672 ;;;
11673
11674 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11675 "Display the current article buffer fully MIME-buttonized.
11676 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11677 treated as multipart/mixed."
11678 (interactive "P")
11679 (require 'gnus-art)
11680 (let ((gnus-unbuttonized-mime-types nil)
11681 (gnus-mime-display-multipart-as-mixed show-all-parts))
11682 (gnus-summary-show-article)))
11683
11684 (defun gnus-summary-repair-multipart (article)
11685 "Add a Content-Type header to a multipart article without one."
11686 (interactive (list (gnus-summary-article-number)))
11687 (gnus-with-article article
11688 (message-narrow-to-head)
11689 (message-remove-header "Mime-Version")
11690 (goto-char (point-max))
11691 (insert "Mime-Version: 1.0\n")
11692 (widen)
11693 (when (search-forward "\n--" nil t)
11694 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11695 (message-narrow-to-head)
11696 (message-remove-header "Content-Type")
11697 (goto-char (point-max))
11698 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11699 separator))
11700 (widen))))
11701 (let (gnus-mark-article-hook)
11702 (gnus-summary-select-article t t nil article)))
11703
11704 (defun gnus-summary-toggle-display-buttonized ()
11705 "Toggle the buttonizing of the article buffer."
11706 (interactive)
11707 (require 'gnus-art)
11708 (if (setq gnus-inhibit-mime-unbuttonizing
11709 (not gnus-inhibit-mime-unbuttonizing))
11710 (let ((gnus-unbuttonized-mime-types nil))
11711 (gnus-summary-show-article))
11712 (gnus-summary-show-article)))
11713
11714 ;;;
11715 ;;; Generic summary marking commands
11716 ;;;
11717
11718 (defvar gnus-summary-marking-alist
11719 '((read gnus-del-mark "d")
11720 (unread gnus-unread-mark "u")
11721 (ticked gnus-ticked-mark "!")
11722 (dormant gnus-dormant-mark "?")
11723 (expirable gnus-expirable-mark "e"))
11724 "An alist of names/marks/keystrokes.")
11725
11726 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11727 (defvar gnus-summary-mark-map)
11728
11729 (defun gnus-summary-make-all-marking-commands ()
11730 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11731 (dolist (elem gnus-summary-marking-alist)
11732 (apply 'gnus-summary-make-marking-command elem)))
11733
11734 (defun gnus-summary-make-marking-command (name mark keystroke)
11735 (let ((map (make-sparse-keymap)))
11736 (define-key gnus-summary-generic-mark-map keystroke map)
11737 (dolist (lway `((next "next" next nil "n")
11738 (next-unread "next unread" next t "N")
11739 (prev "previous" prev nil "p")
11740 (prev-unread "previous unread" prev t "P")
11741 (nomove "" nil nil ,keystroke)))
11742 (let ((func (gnus-summary-make-marking-command-1
11743 mark (car lway) lway name)))
11744 (setq func (eval func))
11745 (define-key map (nth 4 lway) func)))))
11746
11747 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11748 `(defun ,(intern
11749 (format "gnus-summary-put-mark-as-%s%s"
11750 name (if (eq way 'nomove)
11751 ""
11752 (concat "-" (symbol-name way)))))
11753 (n)
11754 ,(format
11755 "Mark the current article as %s%s.
11756 If N, the prefix, then repeat N times.
11757 If N is negative, move in reverse order.
11758 The difference between N and the actual number of articles marked is
11759 returned."
11760 name (cadr lway))
11761 (interactive "p")
11762 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11763
11764 (defun gnus-summary-generic-mark (n mark move unread)
11765 "Mark N articles with MARK."
11766 (unless (eq major-mode 'gnus-summary-mode)
11767 (error "This command can only be used in the summary buffer"))
11768 (gnus-summary-show-thread)
11769 (let ((nummove
11770 (cond
11771 ((eq move 'next) 1)
11772 ((eq move 'prev) -1)
11773 (t 0))))
11774 (if (zerop nummove)
11775 (setq n 1)
11776 (when (< n 0)
11777 (setq n (abs n)
11778 nummove (* -1 nummove))))
11779 (while (and (> n 0)
11780 (gnus-summary-mark-article nil mark)
11781 (zerop (gnus-summary-next-subject nummove unread t)))
11782 (setq n (1- n)))
11783 (when (/= 0 n)
11784 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11785 (gnus-summary-recenter)
11786 (gnus-summary-position-point)
11787 (gnus-set-mode-line 'summary)
11788 n))
11789
11790 (defun gnus-summary-insert-articles (articles)
11791 (when (setq articles
11792 (gnus-sorted-difference articles
11793 (mapcar (lambda (h)
11794 (mail-header-number h))
11795 gnus-newsgroup-headers)))
11796 (setq gnus-newsgroup-headers
11797 (gnus-merge 'list
11798 gnus-newsgroup-headers
11799 (gnus-fetch-headers articles)
11800 'gnus-article-sort-by-number))
11801 ;; Suppress duplicates?
11802 (when gnus-suppress-duplicates
11803 (gnus-dup-suppress-articles))
11804
11805 ;; We might want to build some more threads first.
11806 (when (and gnus-fetch-old-headers
11807 (eq gnus-headers-retrieved-by 'nov))
11808 (if (eq gnus-fetch-old-headers 'invisible)
11809 (gnus-build-all-threads)
11810 (gnus-build-old-threads)))
11811 ;; Let the Gnus agent mark articles as read.
11812 (when gnus-agent
11813 (gnus-agent-get-undownloaded-list))
11814 ;; Remove list identifiers from subject
11815 (when gnus-list-identifiers
11816 (gnus-summary-remove-list-identifiers))
11817 ;; First and last article in this newsgroup.
11818 (when gnus-newsgroup-headers
11819 (setq gnus-newsgroup-begin
11820 (mail-header-number (car gnus-newsgroup-headers))
11821 gnus-newsgroup-end
11822 (mail-header-number
11823 (gnus-last-element gnus-newsgroup-headers))))
11824 (when gnus-use-scoring
11825 (gnus-possibly-score-headers))))
11826
11827 (defun gnus-summary-insert-old-articles (&optional all)
11828 "Insert all old articles in this group.
11829 If ALL is non-nil, already read articles become readable.
11830 If ALL is a number, fetch this number of articles."
11831 (interactive "P")
11832 (prog1
11833 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11834 older len)
11835 (setq older
11836 ;; Some nntp servers lie about their active range. When
11837 ;; this happens, the active range can be in the millions.
11838 ;; Use a compressed range to avoid creating a huge list.
11839 (gnus-range-difference (list gnus-newsgroup-active) old))
11840 (setq len (gnus-range-length older))
11841 (cond
11842 ((null older) nil)
11843 ((numberp all)
11844 (if (< all len)
11845 (let ((older-range (nreverse older)))
11846 (setq older nil)
11847
11848 (while (> all 0)
11849 (let* ((r (pop older-range))
11850 (min (if (numberp r) r (car r)))
11851 (max (if (numberp r) r (cdr r))))
11852 (while (and (<= min max)
11853 (> all 0))
11854 (push max older)
11855 (setq all (1- all)
11856 max (1- max))))))
11857 (setq older (gnus-uncompress-range older))))
11858 (all
11859 (setq older (gnus-uncompress-range older)))
11860 (t
11861 (when (and (numberp gnus-large-newsgroup)
11862 (> len gnus-large-newsgroup))
11863 (let* ((cursor-in-echo-area nil)
11864 (initial (gnus-parameter-large-newsgroup-initial
11865 gnus-newsgroup-name))
11866 (input
11867 (read-string
11868 (format
11869 "How many articles from %s (%s %d): "
11870 (gnus-limit-string
11871 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11872 (if initial "max" "default")
11873 len)
11874 (if initial
11875 (cons (number-to-string initial)
11876 0)))))
11877 (unless (string-match "^[ \t]*$" input)
11878 (setq all (string-to-number input))
11879 (if (< all len)
11880 (let ((older-range (nreverse older)))
11881 (setq older nil)
11882
11883 (while (> all 0)
11884 (let* ((r (pop older-range))
11885 (min (if (numberp r) r (car r)))
11886 (max (if (numberp r) r (cdr r))))
11887 (while (and (<= min max)
11888 (> all 0))
11889 (push max older)
11890 (setq all (1- all)
11891 max (1- max))))))))))
11892 (setq older (gnus-uncompress-range older))))
11893 (if (not older)
11894 (message "No old news.")
11895 (gnus-summary-insert-articles older)
11896 (gnus-summary-limit (gnus-sorted-nunion old older))))
11897 (gnus-summary-position-point)))
11898
11899 (defun gnus-summary-insert-new-articles ()
11900 "Insert all new articles in this group."
11901 (interactive)
11902 (prog1
11903 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11904 (old-active gnus-newsgroup-active)
11905 (nnmail-fetched-sources (list t))
11906 i new)
11907 (setq gnus-newsgroup-active
11908 (gnus-activate-group gnus-newsgroup-name 'scan))
11909 (setq i (cdr gnus-newsgroup-active))
11910 (while (> i (cdr old-active))
11911 (push i new)
11912 (decf i))
11913 (if (not new)
11914 (message "No gnus is bad news.")
11915 (gnus-summary-insert-articles new)
11916 (setq gnus-newsgroup-unreads
11917 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11918 (gnus-summary-limit (gnus-sorted-nunion old new))))
11919 (gnus-summary-position-point)))
11920
11921 (gnus-summary-make-all-marking-commands)
11922
11923 (gnus-ems-redefine)
11924
11925 (provide 'gnus-sum)
11926
11927 (run-hooks 'gnus-sum-load-hook)
11928
11929 ;; Local Variables:
11930 ;; coding: iso-8859-1
11931 ;; End:
11932
11933 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11934 ;;; gnus-sum.el ends here