]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Merge from emacs--devo--0
[gnu-emacs] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 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 "Function used to decode a string with encoded words.")
996
997 (defvar gnus-decode-encoded-address-function
998 'mail-decode-encoded-address-string
999 "Function used to decode addresses with encoded words.")
1000
1001 (defcustom gnus-extra-headers '(To Newsgroups)
1002 "*Extra headers to parse."
1003 :version "21.1"
1004 :group 'gnus-summary
1005 :type '(repeat symbol))
1006
1007 (defcustom gnus-ignored-from-addresses
1008 (and user-mail-address
1009 (not (string= user-mail-address ""))
1010 (regexp-quote user-mail-address))
1011 "*Regexp of From headers that may be suppressed in favor of To headers."
1012 :version "21.1"
1013 :group 'gnus-summary
1014 :type 'regexp)
1015
1016 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1017 "List of charsets that should be ignored.
1018 When these charsets are used in the \"charset\" parameter, the
1019 default charset will be used instead."
1020 :version "21.1"
1021 :type '(repeat symbol)
1022 :group 'gnus-charset)
1023
1024 (gnus-define-group-parameter
1025 ignored-charsets
1026 :type list
1027 :function-document
1028 "Return the ignored charsets of GROUP."
1029 :variable gnus-group-ignored-charsets-alist
1030 :variable-default
1031 '(("alt\\.chinese\\.text" iso-8859-1))
1032 :variable-document
1033 "Alist of regexps (to match group names) and charsets that should be ignored.
1034 When these charsets are used in the \"charset\" parameter, the
1035 default charset will be used instead."
1036 :variable-group gnus-charset
1037 :variable-type '(repeat (cons (regexp :tag "Group")
1038 (repeat symbol)))
1039 :parameter-type '(choice :tag "Ignored charsets"
1040 :value nil
1041 (repeat (symbol)))
1042 :parameter-document "\
1043 List of charsets that should be ignored.
1044
1045 When these charsets are used in the \"charset\" parameter, the
1046 default charset will be used instead.")
1047
1048 (defcustom gnus-group-highlight-words-alist nil
1049 "Alist of group regexps and highlight regexps.
1050 This variable uses the same syntax as `gnus-emphasis-alist'."
1051 :version "21.1"
1052 :type '(repeat (cons (regexp :tag "Group")
1053 (repeat (list (regexp :tag "Highlight regexp")
1054 (number :tag "Group for entire word" 0)
1055 (number :tag "Group for displayed part" 0)
1056 (symbol :tag "Face"
1057 gnus-emphasis-highlight-words)))))
1058 :group 'gnus-summary-visual)
1059
1060 (defcustom gnus-summary-show-article-charset-alist
1061 nil
1062 "Alist of number and charset.
1063 The article will be shown with the charset corresponding to the
1064 numbered argument.
1065 For example: ((1 . cn-gb-2312) (2 . big5))."
1066 :version "21.1"
1067 :type '(repeat (cons (number :tag "Argument" 1)
1068 (symbol :tag "Charset")))
1069 :group 'gnus-charset)
1070
1071 (defcustom gnus-preserve-marks t
1072 "Whether marks are preserved when moving, copying and respooling messages."
1073 :version "21.1"
1074 :type 'boolean
1075 :group 'gnus-summary-marks)
1076
1077 (defcustom gnus-alter-articles-to-read-function nil
1078 "Function to be called to alter the list of articles to be selected."
1079 :type '(choice (const nil) function)
1080 :group 'gnus-summary)
1081
1082 (defcustom gnus-orphan-score nil
1083 "*All orphans get this score added. Set in the score file."
1084 :group 'gnus-score-default
1085 :type '(choice (const nil)
1086 integer))
1087
1088 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1089 "*A regexp to match MIME parts when saving multiple parts of a
1090 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1091 This regexp will be used by default when prompting the user for which
1092 type of files to save."
1093 :group 'gnus-summary
1094 :type 'regexp)
1095
1096 (defcustom gnus-read-all-available-headers nil
1097 "Whether Gnus should parse all headers made available to it.
1098 This is mostly relevant for slow back ends where the user may
1099 wish to widen the summary buffer to include all headers
1100 that were fetched. Say, for nnultimate groups."
1101 :version "22.1"
1102 :group 'gnus-summary
1103 :type '(choice boolean regexp))
1104
1105 (defcustom gnus-summary-muttprint-program "muttprint"
1106 "Command (and optional arguments) used to run Muttprint."
1107 :version "22.1"
1108 :group 'gnus-summary
1109 :type 'string)
1110
1111 (defcustom gnus-article-loose-mime nil
1112 "If non-nil, don't require MIME-Version header.
1113 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1114 supply the MIME-Version header or deliberately strip it from the mail.
1115 Set it to non-nil, Gnus will treat some articles as MIME even if
1116 the MIME-Version header is missed."
1117 :version "22.1"
1118 :type 'boolean
1119 :group 'gnus-article-mime)
1120
1121 (defcustom gnus-article-emulate-mime t
1122 "If non-nil, use MIME emulation for uuencode and the like.
1123 This means that Gnus will search message bodies for text that look
1124 like uuencoded bits, yEncoded bits, and so on, and present that using
1125 the normal Gnus MIME machinery."
1126 :version "22.1"
1127 :type 'boolean
1128 :group 'gnus-article-mime)
1129
1130 ;;; Internal variables
1131
1132 (defvar gnus-summary-display-cache nil)
1133 (defvar gnus-article-mime-handles nil)
1134 (defvar gnus-article-decoded-p nil)
1135 (defvar gnus-article-charset nil)
1136 (defvar gnus-article-ignored-charsets nil)
1137 (defvar gnus-scores-exclude-files nil)
1138 (defvar gnus-page-broken nil)
1139
1140 (defvar gnus-original-article nil)
1141 (defvar gnus-article-internal-prepare-hook nil)
1142 (defvar gnus-newsgroup-process-stack nil)
1143
1144 (defvar gnus-thread-indent-array nil)
1145 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1146 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1147 "Function called to sort the articles within a thread after it has been gathered together.")
1148
1149 (defvar gnus-summary-save-parts-type-history nil)
1150 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1151
1152 ;; Avoid highlighting in kill files.
1153 (defvar gnus-summary-inhibit-highlight nil)
1154 (defvar gnus-newsgroup-selected-overlay nil)
1155 (defvar gnus-inhibit-limiting nil)
1156 (defvar gnus-newsgroup-adaptive-score-file nil)
1157 (defvar gnus-current-score-file nil)
1158 (defvar gnus-current-move-group nil)
1159 (defvar gnus-current-copy-group nil)
1160 (defvar gnus-current-crosspost-group nil)
1161 (defvar gnus-newsgroup-display nil)
1162
1163 (defvar gnus-newsgroup-dependencies nil)
1164 (defvar gnus-newsgroup-adaptive nil)
1165 (defvar gnus-summary-display-article-function nil)
1166 (defvar gnus-summary-highlight-line-function nil
1167 "Function called after highlighting a summary line.")
1168
1169 (defvar gnus-summary-line-format-alist
1170 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1171 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1172 (?s gnus-tmp-subject-or-nil ?s)
1173 (?n gnus-tmp-name ?s)
1174 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1175 ?s)
1176 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1177 gnus-tmp-from) ?s)
1178 (?F gnus-tmp-from ?s)
1179 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1180 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1181 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1182 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1183 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1184 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1185 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1186 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1187 (?L gnus-tmp-lines ?s)
1188 (?O gnus-tmp-downloaded ?c)
1189 (?I gnus-tmp-indentation ?s)
1190 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1191 (?R gnus-tmp-replied ?c)
1192 (?\[ gnus-tmp-opening-bracket ?c)
1193 (?\] gnus-tmp-closing-bracket ?c)
1194 (?\> (make-string gnus-tmp-level ? ) ?s)
1195 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1196 (?i gnus-tmp-score ?d)
1197 (?z gnus-tmp-score-char ?c)
1198 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1199 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1200 (?U gnus-tmp-unread ?c)
1201 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1202 ?s)
1203 (?t (gnus-summary-number-of-articles-in-thread
1204 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1205 ?d)
1206 (?e (gnus-summary-number-of-articles-in-thread
1207 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1208 ?c)
1209 (?u gnus-tmp-user-defined ?s)
1210 (?P (gnus-pick-line-number) ?d)
1211 (?B gnus-tmp-thread-tree-header-string ?s)
1212 (user-date (gnus-user-date
1213 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1214 "An alist of format specifications that can appear in summary lines.
1215 These are paired with what variables they correspond with, along with
1216 the type of the variable (string, integer, character, etc).")
1217
1218 (defvar gnus-summary-dummy-line-format-alist
1219 `((?S gnus-tmp-subject ?s)
1220 (?N gnus-tmp-number ?d)
1221 (?u gnus-tmp-user-defined ?s)))
1222
1223 (defvar gnus-summary-mode-line-format-alist
1224 `((?G gnus-tmp-group-name ?s)
1225 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1226 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1227 (?A gnus-tmp-article-number ?d)
1228 (?Z gnus-tmp-unread-and-unselected ?s)
1229 (?V gnus-version ?s)
1230 (?U gnus-tmp-unread-and-unticked ?d)
1231 (?S gnus-tmp-subject ?s)
1232 (?e gnus-tmp-unselected ?d)
1233 (?u gnus-tmp-user-defined ?s)
1234 (?d (length gnus-newsgroup-dormant) ?d)
1235 (?t (length gnus-newsgroup-marked) ?d)
1236 (?h (length gnus-newsgroup-spam-marked) ?d)
1237 (?r (length gnus-newsgroup-reads) ?d)
1238 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1239 (?E gnus-newsgroup-expunged-tally ?d)
1240 (?s (gnus-current-score-file-nondirectory) ?s)))
1241
1242 (defvar gnus-last-search-regexp nil
1243 "Default regexp for article search command.")
1244
1245 (defvar gnus-last-shell-command nil
1246 "Default shell command on article.")
1247
1248 (defvar gnus-newsgroup-agentized nil
1249 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1250 (defvar gnus-newsgroup-begin nil)
1251 (defvar gnus-newsgroup-end nil)
1252 (defvar gnus-newsgroup-last-rmail nil)
1253 (defvar gnus-newsgroup-last-mail nil)
1254 (defvar gnus-newsgroup-last-folder nil)
1255 (defvar gnus-newsgroup-last-file nil)
1256 (defvar gnus-newsgroup-last-directory nil)
1257 (defvar gnus-newsgroup-auto-expire nil)
1258 (defvar gnus-newsgroup-active nil)
1259
1260 (defvar gnus-newsgroup-data nil)
1261 (defvar gnus-newsgroup-data-reverse nil)
1262 (defvar gnus-newsgroup-limit nil)
1263 (defvar gnus-newsgroup-limits nil)
1264 (defvar gnus-summary-use-undownloaded-faces nil)
1265
1266 (defvar gnus-newsgroup-unreads nil
1267 "Sorted list of unread articles in the current newsgroup.")
1268
1269 (defvar gnus-newsgroup-unselected nil
1270 "Sorted list of unselected unread articles in the current newsgroup.")
1271
1272 (defvar gnus-newsgroup-reads nil
1273 "Alist of read articles and article marks in the current newsgroup.")
1274
1275 (defvar gnus-newsgroup-expunged-tally nil)
1276
1277 (defvar gnus-newsgroup-marked nil
1278 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1279
1280 (defvar gnus-newsgroup-spam-marked nil
1281 "List of ranges of articles that have been marked as spam.")
1282
1283 (defvar gnus-newsgroup-killed nil
1284 "List of ranges of articles that have been through the scoring process.")
1285
1286 (defvar gnus-newsgroup-cached nil
1287 "Sorted list of articles that come from the article cache.")
1288
1289 (defvar gnus-newsgroup-saved nil
1290 "List of articles that have been saved.")
1291
1292 (defvar gnus-newsgroup-kill-headers nil)
1293
1294 (defvar gnus-newsgroup-replied nil
1295 "List of articles that have been replied to in the current newsgroup.")
1296
1297 (defvar gnus-newsgroup-forwarded nil
1298 "List of articles that have been forwarded in the current newsgroup.")
1299
1300 (defvar gnus-newsgroup-recent nil
1301 "List of articles that have are recent in the current newsgroup.")
1302
1303 (defvar gnus-newsgroup-expirable nil
1304 "Sorted list of articles in the current newsgroup that can be expired.")
1305
1306 (defvar gnus-newsgroup-processable nil
1307 "List of articles in the current newsgroup that can be processed.")
1308
1309 (defvar gnus-newsgroup-downloadable nil
1310 "Sorted list of articles in the current newsgroup that can be processed.")
1311
1312 (defvar gnus-newsgroup-unfetched nil
1313 "Sorted list of articles in the current newsgroup whose headers have
1314 not been fetched into the agent.
1315
1316 This list will always be a subset of gnus-newsgroup-undownloaded.")
1317
1318 (defvar gnus-newsgroup-undownloaded nil
1319 "List of articles in the current newsgroup that haven't been downloaded.")
1320
1321 (defvar gnus-newsgroup-unsendable nil
1322 "List of articles in the current newsgroup that won't be sent.")
1323
1324 (defvar gnus-newsgroup-bookmarks nil
1325 "List of articles in the current newsgroup that have bookmarks.")
1326
1327 (defvar gnus-newsgroup-dormant nil
1328 "Sorted list of dormant articles in the current newsgroup.")
1329
1330 (defvar gnus-newsgroup-unseen nil
1331 "List of unseen articles in the current newsgroup.")
1332
1333 (defvar gnus-newsgroup-seen nil
1334 "Range of seen articles in the current newsgroup.")
1335
1336 (defvar gnus-newsgroup-articles nil
1337 "List of articles in the current newsgroup.")
1338
1339 (defvar gnus-newsgroup-scored nil
1340 "List of scored articles in the current newsgroup.")
1341
1342 (defvar gnus-newsgroup-headers nil
1343 "List of article headers in the current newsgroup.")
1344
1345 (defvar gnus-newsgroup-threads nil)
1346
1347 (defvar gnus-newsgroup-prepared nil
1348 "Whether the current group has been prepared properly.")
1349
1350 (defvar gnus-newsgroup-ancient nil
1351 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1352
1353 (defvar gnus-newsgroup-sparse nil)
1354
1355 (defvar gnus-current-article nil)
1356 (defvar gnus-article-current nil)
1357 (defvar gnus-current-headers nil)
1358 (defvar gnus-have-all-headers nil)
1359 (defvar gnus-last-article nil)
1360 (defvar gnus-newsgroup-history nil)
1361 (defvar gnus-newsgroup-charset nil)
1362 (defvar gnus-newsgroup-ephemeral-charset nil)
1363 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1364
1365 (defvar gnus-article-before-search nil)
1366
1367 (defvar gnus-summary-local-variables
1368 '(gnus-newsgroup-name
1369 gnus-newsgroup-begin gnus-newsgroup-end
1370 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1371 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1372 gnus-newsgroup-last-directory
1373 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1374 gnus-newsgroup-unselected gnus-newsgroup-marked
1375 gnus-newsgroup-spam-marked
1376 gnus-newsgroup-reads gnus-newsgroup-saved
1377 gnus-newsgroup-replied gnus-newsgroup-forwarded
1378 gnus-newsgroup-recent
1379 gnus-newsgroup-expirable
1380 gnus-newsgroup-processable gnus-newsgroup-killed
1381 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1382 gnus-newsgroup-unfetched
1383 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1384 gnus-newsgroup-seen gnus-newsgroup-articles
1385 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1386 gnus-newsgroup-headers gnus-newsgroup-threads
1387 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1388 gnus-current-article gnus-current-headers gnus-have-all-headers
1389 gnus-last-article gnus-article-internal-prepare-hook
1390 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1391 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1392 gnus-thread-expunge-below
1393 gnus-score-alist gnus-current-score-file
1394 (gnus-summary-expunge-below . global)
1395 (gnus-summary-mark-below . global)
1396 (gnus-orphan-score . global)
1397 gnus-newsgroup-active gnus-scores-exclude-files
1398 gnus-newsgroup-history gnus-newsgroup-ancient
1399 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1400 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1401 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1402 (gnus-newsgroup-expunged-tally . 0)
1403 gnus-cache-removable-articles gnus-newsgroup-cached
1404 gnus-newsgroup-data gnus-newsgroup-data-reverse
1405 gnus-newsgroup-limit gnus-newsgroup-limits
1406 gnus-newsgroup-charset gnus-newsgroup-display
1407 gnus-summary-use-undownloaded-faces)
1408 "Variables that are buffer-local to the summary buffers.")
1409
1410 (defvar gnus-newsgroup-variables nil
1411 "A list of variables that have separate values in different newsgroups.
1412 A list of newsgroup (summary buffer) local variables, or cons of
1413 variables and their default expressions to be evalled (when the default
1414 values are not nil), that should be made global while the summary buffer
1415 is active.
1416
1417 Note: The default expressions will be evaluated (using function `eval')
1418 before assignment to the local variable rather than just assigned to it.
1419 If the default expression is the symbol `global', that symbol will not
1420 be evaluated but the global value of the local variable will be used
1421 instead.
1422
1423 These variables can be used to set variables in the group parameters
1424 while still allowing them to affect operations done in other buffers.
1425 For example:
1426
1427 \(setq gnus-newsgroup-variables
1428 '(message-use-followup-to
1429 (gnus-visible-headers .
1430 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1431 ")
1432
1433 ;; Byte-compiler warning.
1434 (eval-when-compile
1435 ;; Bind features so that require will believe that gnus-sum has
1436 ;; already been loaded (avoids infinite recursion)
1437 (let ((features (cons 'gnus-sum features)))
1438 ;; Several of the declarations in gnus-sum are needed to load the
1439 ;; following files. Right now, these definitions have been
1440 ;; compiled but not defined (evaluated). We could either do a
1441 ;; eval-and-compile about all of the declarations or evaluate the
1442 ;; source file.
1443 (if (boundp 'gnus-newsgroup-variables)
1444 nil
1445 (load "gnus-sum.el" t t t))
1446 (require 'gnus)
1447 (require 'gnus-agent)
1448 (require 'gnus-art)))
1449
1450 ;; MIME stuff.
1451
1452 (defvar gnus-decode-encoded-word-methods
1453 '(mail-decode-encoded-word-string)
1454 "List of methods used to decode encoded words.
1455
1456 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1457 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1458 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1459 whose names match REGEXP.
1460
1461 For example:
1462 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1463 mail-decode-encoded-word-string
1464 (\"chinese\" . rfc1843-decode-string))")
1465
1466 (defvar gnus-decode-encoded-word-methods-cache nil)
1467
1468 (defun gnus-multi-decode-encoded-word-string (string)
1469 "Apply the functions from `gnus-encoded-word-methods' that match."
1470 (unless (and gnus-decode-encoded-word-methods-cache
1471 (eq gnus-newsgroup-name
1472 (car gnus-decode-encoded-word-methods-cache)))
1473 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1474 (mapcar (lambda (x)
1475 (if (symbolp x)
1476 (nconc gnus-decode-encoded-word-methods-cache (list x))
1477 (if (and gnus-newsgroup-name
1478 (string-match (car x) gnus-newsgroup-name))
1479 (nconc gnus-decode-encoded-word-methods-cache
1480 (list (cdr x))))))
1481 gnus-decode-encoded-word-methods))
1482 (let ((xlist gnus-decode-encoded-word-methods-cache))
1483 (pop xlist)
1484 (while xlist
1485 (setq string (funcall (pop xlist) string))))
1486 string)
1487
1488 ;; Subject simplification.
1489
1490 (defun gnus-simplify-whitespace (str)
1491 "Remove excessive whitespace from STR."
1492 ;; Multiple spaces.
1493 (while (string-match "[ \t][ \t]+" str)
1494 (setq str (concat (substring str 0 (match-beginning 0))
1495 " "
1496 (substring str (match-end 0)))))
1497 ;; Leading spaces.
1498 (when (string-match "^[ \t]+" str)
1499 (setq str (substring str (match-end 0))))
1500 ;; Trailing spaces.
1501 (when (string-match "[ \t]+$" str)
1502 (setq str (substring str 0 (match-beginning 0))))
1503 str)
1504
1505 (defun gnus-simplify-all-whitespace (str)
1506 "Remove all whitespace from STR."
1507 (while (string-match "[ \t\n]+" str)
1508 (setq str (replace-match "" nil nil str)))
1509 str)
1510
1511 (defsubst gnus-simplify-subject-re (subject)
1512 "Remove \"Re:\" from subject lines."
1513 (if (string-match message-subject-re-regexp subject)
1514 (substring subject (match-end 0))
1515 subject))
1516
1517 (defun gnus-simplify-subject (subject &optional re-only)
1518 "Remove `Re:' and words in parentheses.
1519 If RE-ONLY is non-nil, strip leading `Re:'s only."
1520 (let ((case-fold-search t)) ;Ignore case.
1521 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1522 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1523 (setq subject (substring subject (match-end 0))))
1524 ;; Remove uninteresting prefixes.
1525 (when (and (not re-only)
1526 gnus-simplify-ignored-prefixes
1527 (string-match gnus-simplify-ignored-prefixes subject))
1528 (setq subject (substring subject (match-end 0))))
1529 ;; Remove words in parentheses from end.
1530 (unless re-only
1531 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1532 (setq subject (substring subject 0 (match-beginning 0)))))
1533 ;; Return subject string.
1534 subject))
1535
1536 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1537 ;; all whitespace.
1538 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1539 (goto-char (point-min))
1540 (while (re-search-forward regexp nil t)
1541 (replace-match (or newtext ""))))
1542
1543 (defun gnus-simplify-buffer-fuzzy ()
1544 "Simplify string in the buffer fuzzily.
1545 The string in the accessible portion of the current buffer is simplified.
1546 It is assumed to be a single-line subject.
1547 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1548 matter is removed. Additional things can be deleted by setting
1549 `gnus-simplify-subject-fuzzy-regexp'."
1550 (let ((case-fold-search t)
1551 (modified-tick))
1552 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1553
1554 (while (not (eq modified-tick (buffer-modified-tick)))
1555 (setq modified-tick (buffer-modified-tick))
1556 (cond
1557 ((listp gnus-simplify-subject-fuzzy-regexp)
1558 (mapcar 'gnus-simplify-buffer-fuzzy-step
1559 gnus-simplify-subject-fuzzy-regexp))
1560 (gnus-simplify-subject-fuzzy-regexp
1561 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1562 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1563 (gnus-simplify-buffer-fuzzy-step
1564 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1565 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1566
1567 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1568 (gnus-simplify-buffer-fuzzy-step " +" " ")
1569 (gnus-simplify-buffer-fuzzy-step " $")
1570 (gnus-simplify-buffer-fuzzy-step "^ +")))
1571
1572 (defun gnus-simplify-subject-fuzzy (subject)
1573 "Simplify a subject string fuzzily.
1574 See `gnus-simplify-buffer-fuzzy' for details."
1575 (save-excursion
1576 (gnus-set-work-buffer)
1577 (let ((case-fold-search t))
1578 ;; Remove uninteresting prefixes.
1579 (when (and gnus-simplify-ignored-prefixes
1580 (string-match gnus-simplify-ignored-prefixes subject))
1581 (setq subject (substring subject (match-end 0))))
1582 (insert subject)
1583 (inline (gnus-simplify-buffer-fuzzy))
1584 (buffer-string))))
1585
1586 (defsubst gnus-simplify-subject-fully (subject)
1587 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1588 (cond
1589 (gnus-simplify-subject-functions
1590 (gnus-map-function gnus-simplify-subject-functions subject))
1591 ((null gnus-summary-gather-subject-limit)
1592 (gnus-simplify-subject-re subject))
1593 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1594 (gnus-simplify-subject-fuzzy subject))
1595 ((numberp gnus-summary-gather-subject-limit)
1596 (gnus-limit-string (gnus-simplify-subject-re subject)
1597 gnus-summary-gather-subject-limit))
1598 (t
1599 subject)))
1600
1601 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1602 "Check whether two subjects are equal.
1603 If optional argument SIMPLE-FIRST is t, first argument is already
1604 simplified."
1605 (cond
1606 ((null simple-first)
1607 (equal (gnus-simplify-subject-fully s1)
1608 (gnus-simplify-subject-fully s2)))
1609 (t
1610 (equal s1
1611 (gnus-simplify-subject-fully s2)))))
1612
1613 (defun gnus-summary-bubble-group ()
1614 "Increase the score of the current group.
1615 This is a handy function to add to `gnus-summary-exit-hook' to
1616 increase the score of each group you read."
1617 (gnus-group-add-score gnus-newsgroup-name))
1618
1619 \f
1620 ;;;
1621 ;;; Gnus summary mode
1622 ;;;
1623
1624 (put 'gnus-summary-mode 'mode-class 'special)
1625
1626 (defvar gnus-article-commands-menu)
1627
1628 ;; Non-orthogonal keys
1629
1630 (gnus-define-keys gnus-summary-mode-map
1631 " " gnus-summary-next-page
1632 "\177" gnus-summary-prev-page
1633 [delete] gnus-summary-prev-page
1634 [backspace] gnus-summary-prev-page
1635 "\r" gnus-summary-scroll-up
1636 "\M-\r" gnus-summary-scroll-down
1637 "n" gnus-summary-next-unread-article
1638 "p" gnus-summary-prev-unread-article
1639 "N" gnus-summary-next-article
1640 "P" gnus-summary-prev-article
1641 "\M-\C-n" gnus-summary-next-same-subject
1642 "\M-\C-p" gnus-summary-prev-same-subject
1643 "\M-n" gnus-summary-next-unread-subject
1644 "\M-p" gnus-summary-prev-unread-subject
1645 "." gnus-summary-first-unread-article
1646 "," gnus-summary-best-unread-article
1647 "\M-s" gnus-summary-search-article-forward
1648 "\M-r" gnus-summary-search-article-backward
1649 "<" gnus-summary-beginning-of-article
1650 ">" gnus-summary-end-of-article
1651 "j" gnus-summary-goto-article
1652 "^" gnus-summary-refer-parent-article
1653 "\M-^" gnus-summary-refer-article
1654 "u" gnus-summary-tick-article-forward
1655 "!" gnus-summary-tick-article-forward
1656 "U" gnus-summary-tick-article-backward
1657 "d" gnus-summary-mark-as-read-forward
1658 "D" gnus-summary-mark-as-read-backward
1659 "E" gnus-summary-mark-as-expirable
1660 "\M-u" gnus-summary-clear-mark-forward
1661 "\M-U" gnus-summary-clear-mark-backward
1662 "k" gnus-summary-kill-same-subject-and-select
1663 "\C-k" gnus-summary-kill-same-subject
1664 "\M-\C-k" gnus-summary-kill-thread
1665 "\M-\C-l" gnus-summary-lower-thread
1666 "e" gnus-summary-edit-article
1667 "#" gnus-summary-mark-as-processable
1668 "\M-#" gnus-summary-unmark-as-processable
1669 "\M-\C-t" gnus-summary-toggle-threads
1670 "\M-\C-s" gnus-summary-show-thread
1671 "\M-\C-h" gnus-summary-hide-thread
1672 "\M-\C-f" gnus-summary-next-thread
1673 "\M-\C-b" gnus-summary-prev-thread
1674 [(meta down)] gnus-summary-next-thread
1675 [(meta up)] gnus-summary-prev-thread
1676 "\M-\C-u" gnus-summary-up-thread
1677 "\M-\C-d" gnus-summary-down-thread
1678 "&" gnus-summary-execute-command
1679 "c" gnus-summary-catchup-and-exit
1680 "\C-w" gnus-summary-mark-region-as-read
1681 "\C-t" gnus-summary-toggle-truncation
1682 "?" gnus-summary-mark-as-dormant
1683 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1684 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1685 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1686 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1687 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1688 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1689 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1690 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1691 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1692 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1693 "=" gnus-summary-expand-window
1694 "\C-x\C-s" gnus-summary-reselect-current-group
1695 "\M-g" gnus-summary-rescan-group
1696 "w" gnus-summary-stop-page-breaking
1697 "\C-c\C-r" gnus-summary-caesar-message
1698 "f" gnus-summary-followup
1699 "F" gnus-summary-followup-with-original
1700 "C" gnus-summary-cancel-article
1701 "r" gnus-summary-reply
1702 "R" gnus-summary-reply-with-original
1703 "\C-c\C-f" gnus-summary-mail-forward
1704 "o" gnus-summary-save-article
1705 "\C-o" gnus-summary-save-article-mail
1706 "|" gnus-summary-pipe-output
1707 "\M-k" gnus-summary-edit-local-kill
1708 "\M-K" gnus-summary-edit-global-kill
1709 ;; "V" gnus-version
1710 "\C-c\C-d" gnus-summary-describe-group
1711 "q" gnus-summary-exit
1712 "Q" gnus-summary-exit-no-update
1713 "\C-c\C-i" gnus-info-find-node
1714 gnus-mouse-2 gnus-mouse-pick-article
1715 [follow-link] mouse-face
1716 "m" gnus-summary-mail-other-window
1717 "a" gnus-summary-post-news
1718 "i" gnus-summary-news-other-window
1719 "x" gnus-summary-limit-to-unread
1720 "s" gnus-summary-isearch-article
1721 "t" gnus-summary-toggle-header
1722 "g" gnus-summary-show-article
1723 "l" gnus-summary-goto-last-article
1724 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1725 "\C-d" gnus-summary-enter-digest-group
1726 "\M-\C-d" gnus-summary-read-document
1727 "\M-\C-e" gnus-summary-edit-parameters
1728 "\M-\C-a" gnus-summary-customize-parameters
1729 "\C-c\C-b" gnus-bug
1730 "*" gnus-cache-enter-article
1731 "\M-*" gnus-cache-remove-article
1732 "\M-&" gnus-summary-universal-argument
1733 "\C-l" gnus-recenter
1734 "I" gnus-summary-increase-score
1735 "L" gnus-summary-lower-score
1736 "\M-i" gnus-symbolic-argument
1737 "h" gnus-summary-select-article-buffer
1738
1739 "b" gnus-article-view-part
1740 "\M-t" gnus-summary-toggle-display-buttonized
1741
1742 "V" gnus-summary-score-map
1743 "X" gnus-uu-extract-map
1744 "S" gnus-summary-send-map)
1745
1746 ;; Sort of orthogonal keymap
1747 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1748 "t" gnus-summary-tick-article-forward
1749 "!" gnus-summary-tick-article-forward
1750 "d" gnus-summary-mark-as-read-forward
1751 "r" gnus-summary-mark-as-read-forward
1752 "c" gnus-summary-clear-mark-forward
1753 " " gnus-summary-clear-mark-forward
1754 "e" gnus-summary-mark-as-expirable
1755 "x" gnus-summary-mark-as-expirable
1756 "?" gnus-summary-mark-as-dormant
1757 "b" gnus-summary-set-bookmark
1758 "B" gnus-summary-remove-bookmark
1759 "#" gnus-summary-mark-as-processable
1760 "\M-#" gnus-summary-unmark-as-processable
1761 "S" gnus-summary-limit-include-expunged
1762 "C" gnus-summary-catchup
1763 "H" gnus-summary-catchup-to-here
1764 "h" gnus-summary-catchup-from-here
1765 "\C-c" gnus-summary-catchup-all
1766 "k" gnus-summary-kill-same-subject-and-select
1767 "K" gnus-summary-kill-same-subject
1768 "P" gnus-uu-mark-map)
1769
1770 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1771 "c" gnus-summary-clear-above
1772 "u" gnus-summary-tick-above
1773 "m" gnus-summary-mark-above
1774 "k" gnus-summary-kill-below)
1775
1776 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1777 "/" gnus-summary-limit-to-subject
1778 "n" gnus-summary-limit-to-articles
1779 "w" gnus-summary-pop-limit
1780 "s" gnus-summary-limit-to-subject
1781 "a" gnus-summary-limit-to-author
1782 "u" gnus-summary-limit-to-unread
1783 "m" gnus-summary-limit-to-marks
1784 "M" gnus-summary-limit-exclude-marks
1785 "v" gnus-summary-limit-to-score
1786 "*" gnus-summary-limit-include-cached
1787 "D" gnus-summary-limit-include-dormant
1788 "T" gnus-summary-limit-include-thread
1789 "d" gnus-summary-limit-exclude-dormant
1790 "t" gnus-summary-limit-to-age
1791 "." gnus-summary-limit-to-unseen
1792 "x" gnus-summary-limit-to-extra
1793 "p" gnus-summary-limit-to-display-predicate
1794 "E" gnus-summary-limit-include-expunged
1795 "c" gnus-summary-limit-exclude-childless-dormant
1796 "C" gnus-summary-limit-mark-excluded-as-read
1797 "o" gnus-summary-insert-old-articles
1798 "N" gnus-summary-insert-new-articles)
1799
1800 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1801 "n" gnus-summary-next-unread-article
1802 "p" gnus-summary-prev-unread-article
1803 "N" gnus-summary-next-article
1804 "P" gnus-summary-prev-article
1805 "\C-n" gnus-summary-next-same-subject
1806 "\C-p" gnus-summary-prev-same-subject
1807 "\M-n" gnus-summary-next-unread-subject
1808 "\M-p" gnus-summary-prev-unread-subject
1809 "f" gnus-summary-first-unread-article
1810 "b" gnus-summary-best-unread-article
1811 "j" gnus-summary-goto-article
1812 "g" gnus-summary-goto-subject
1813 "l" gnus-summary-goto-last-article
1814 "o" gnus-summary-pop-article)
1815
1816 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1817 "k" gnus-summary-kill-thread
1818 "l" gnus-summary-lower-thread
1819 "i" gnus-summary-raise-thread
1820 "T" gnus-summary-toggle-threads
1821 "t" gnus-summary-rethread-current
1822 "^" gnus-summary-reparent-thread
1823 "s" gnus-summary-show-thread
1824 "S" gnus-summary-show-all-threads
1825 "h" gnus-summary-hide-thread
1826 "H" gnus-summary-hide-all-threads
1827 "n" gnus-summary-next-thread
1828 "p" gnus-summary-prev-thread
1829 "u" gnus-summary-up-thread
1830 "o" gnus-summary-top-thread
1831 "d" gnus-summary-down-thread
1832 "#" gnus-uu-mark-thread
1833 "\M-#" gnus-uu-unmark-thread)
1834
1835 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1836 "g" gnus-summary-prepare
1837 "c" gnus-summary-insert-cached-articles
1838 "d" gnus-summary-insert-dormant-articles)
1839
1840 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1841 "c" gnus-summary-catchup-and-exit
1842 "C" gnus-summary-catchup-all-and-exit
1843 "E" gnus-summary-exit-no-update
1844 "Q" gnus-summary-exit
1845 "Z" gnus-summary-exit
1846 "n" gnus-summary-catchup-and-goto-next-group
1847 "R" gnus-summary-reselect-current-group
1848 "G" gnus-summary-rescan-group
1849 "N" gnus-summary-next-group
1850 "s" gnus-summary-save-newsrc
1851 "P" gnus-summary-prev-group)
1852
1853 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1854 " " gnus-summary-next-page
1855 "n" gnus-summary-next-page
1856 "\177" gnus-summary-prev-page
1857 [delete] gnus-summary-prev-page
1858 "p" gnus-summary-prev-page
1859 "\r" gnus-summary-scroll-up
1860 "\M-\r" gnus-summary-scroll-down
1861 "<" gnus-summary-beginning-of-article
1862 ">" gnus-summary-end-of-article
1863 "b" gnus-summary-beginning-of-article
1864 "e" gnus-summary-end-of-article
1865 "^" gnus-summary-refer-parent-article
1866 "r" gnus-summary-refer-parent-article
1867 "D" gnus-summary-enter-digest-group
1868 "R" gnus-summary-refer-references
1869 "T" gnus-summary-refer-thread
1870 "g" gnus-summary-show-article
1871 "s" gnus-summary-isearch-article
1872 "P" gnus-summary-print-article
1873 "M" gnus-mailing-list-insinuate
1874 "t" gnus-article-babel)
1875
1876 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1877 "b" gnus-article-add-buttons
1878 "B" gnus-article-add-buttons-to-head
1879 "o" gnus-article-treat-overstrike
1880 "e" gnus-article-emphasize
1881 "w" gnus-article-fill-cited-article
1882 "Q" gnus-article-fill-long-lines
1883 "C" gnus-article-capitalize-sentences
1884 "c" gnus-article-remove-cr
1885 "q" gnus-article-de-quoted-unreadable
1886 "6" gnus-article-de-base64-unreadable
1887 "Z" gnus-article-decode-HZ
1888 "h" gnus-article-wash-html
1889 "u" gnus-article-unsplit-urls
1890 "s" gnus-summary-force-verify-and-decrypt
1891 "f" gnus-article-display-x-face
1892 "l" gnus-summary-stop-page-breaking
1893 "r" gnus-summary-caesar-message
1894 "m" gnus-summary-morse-message
1895 "t" gnus-summary-toggle-header
1896 "g" gnus-treat-smiley
1897 "v" gnus-summary-verbose-headers
1898 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1899 "p" gnus-article-verify-x-pgp-sig
1900 "d" gnus-article-treat-dumbquotes)
1901
1902 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1903 ;; mnemonic: deuglif*Y*
1904 "u" gnus-article-outlook-unwrap-lines
1905 "a" gnus-article-outlook-repair-attribution
1906 "c" gnus-article-outlook-rearrange-citation
1907 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1908
1909 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1910 "a" gnus-article-hide
1911 "h" gnus-article-hide-headers
1912 "b" gnus-article-hide-boring-headers
1913 "s" gnus-article-hide-signature
1914 "c" gnus-article-hide-citation
1915 "C" gnus-article-hide-citation-in-followups
1916 "l" gnus-article-hide-list-identifiers
1917 "B" gnus-article-strip-banner
1918 "P" gnus-article-hide-pem
1919 "\C-c" gnus-article-hide-citation-maybe)
1920
1921 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1922 "a" gnus-article-highlight
1923 "h" gnus-article-highlight-headers
1924 "c" gnus-article-highlight-citation
1925 "s" gnus-article-highlight-signature)
1926
1927 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1928 "f" gnus-article-treat-fold-headers
1929 "u" gnus-article-treat-unfold-headers
1930 "n" gnus-article-treat-fold-newsgroups)
1931
1932 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1933 "x" gnus-article-display-x-face
1934 "d" gnus-article-display-face
1935 "s" gnus-treat-smiley
1936 "D" gnus-article-remove-images
1937 "f" gnus-treat-from-picon
1938 "m" gnus-treat-mail-picon
1939 "n" gnus-treat-newsgroups-picon)
1940
1941 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1942 "w" gnus-article-decode-mime-words
1943 "c" gnus-article-decode-charset
1944 "v" gnus-mime-view-all-parts
1945 "b" gnus-article-view-part)
1946
1947 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1948 "z" gnus-article-date-ut
1949 "u" gnus-article-date-ut
1950 "l" gnus-article-date-local
1951 "p" gnus-article-date-english
1952 "e" gnus-article-date-lapsed
1953 "o" gnus-article-date-original
1954 "i" gnus-article-date-iso8601
1955 "s" gnus-article-date-user)
1956
1957 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1958 "t" gnus-article-remove-trailing-blank-lines
1959 "l" gnus-article-strip-leading-blank-lines
1960 "m" gnus-article-strip-multiple-blank-lines
1961 "a" gnus-article-strip-blank-lines
1962 "A" gnus-article-strip-all-blank-lines
1963 "s" gnus-article-strip-leading-space
1964 "e" gnus-article-strip-trailing-space
1965 "w" gnus-article-remove-leading-whitespace)
1966
1967 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1968 "v" gnus-version
1969 "f" gnus-summary-fetch-faq
1970 "d" gnus-summary-describe-group
1971 "h" gnus-summary-describe-briefly
1972 "i" gnus-info-find-node
1973 "c" gnus-group-fetch-charter
1974 "C" gnus-group-fetch-control)
1975
1976 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1977 "e" gnus-summary-expire-articles
1978 "\M-\C-e" gnus-summary-expire-articles-now
1979 "\177" gnus-summary-delete-article
1980 [delete] gnus-summary-delete-article
1981 [backspace] gnus-summary-delete-article
1982 "m" gnus-summary-move-article
1983 "r" gnus-summary-respool-article
1984 "w" gnus-summary-edit-article
1985 "c" gnus-summary-copy-article
1986 "B" gnus-summary-crosspost-article
1987 "q" gnus-summary-respool-query
1988 "t" gnus-summary-respool-trace
1989 "i" gnus-summary-import-article
1990 "I" gnus-summary-create-article
1991 "p" gnus-summary-article-posted-p)
1992
1993 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1994 "o" gnus-summary-save-article
1995 "m" gnus-summary-save-article-mail
1996 "F" gnus-summary-write-article-file
1997 "r" gnus-summary-save-article-rmail
1998 "f" gnus-summary-save-article-file
1999 "b" gnus-summary-save-article-body-file
2000 "B" gnus-summary-write-article-body-file
2001 "h" gnus-summary-save-article-folder
2002 "v" gnus-summary-save-article-vm
2003 "p" gnus-summary-pipe-output
2004 "P" gnus-summary-muttprint
2005 "s" gnus-soup-add-article)
2006
2007 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2008 "b" gnus-summary-display-buttonized
2009 "m" gnus-summary-repair-multipart
2010 "v" gnus-article-view-part
2011 "o" gnus-article-save-part
2012 "c" gnus-article-copy-part
2013 "C" gnus-article-view-part-as-charset
2014 "e" gnus-article-view-part-externally
2015 "E" gnus-article-encrypt-body
2016 "i" gnus-article-inline-part
2017 "|" gnus-article-pipe-part)
2018
2019 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2020 "p" gnus-summary-mark-as-processable
2021 "u" gnus-summary-unmark-as-processable
2022 "U" gnus-summary-unmark-all-processable
2023 "v" gnus-uu-mark-over
2024 "s" gnus-uu-mark-series
2025 "r" gnus-uu-mark-region
2026 "g" gnus-uu-unmark-region
2027 "R" gnus-uu-mark-by-regexp
2028 "G" gnus-uu-unmark-by-regexp
2029 "t" gnus-uu-mark-thread
2030 "T" gnus-uu-unmark-thread
2031 "a" gnus-uu-mark-all
2032 "b" gnus-uu-mark-buffer
2033 "S" gnus-uu-mark-sparse
2034 "k" gnus-summary-kill-process-mark
2035 "y" gnus-summary-yank-process-mark
2036 "w" gnus-summary-save-process-mark
2037 "i" gnus-uu-invert-processable)
2038
2039 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2040 ;;"x" gnus-uu-extract-any
2041 "m" gnus-summary-save-parts
2042 "u" gnus-uu-decode-uu
2043 "U" gnus-uu-decode-uu-and-save
2044 "s" gnus-uu-decode-unshar
2045 "S" gnus-uu-decode-unshar-and-save
2046 "o" gnus-uu-decode-save
2047 "O" gnus-uu-decode-save
2048 "b" gnus-uu-decode-binhex
2049 "B" gnus-uu-decode-binhex
2050 "p" gnus-uu-decode-postscript
2051 "P" gnus-uu-decode-postscript-and-save)
2052
2053 (gnus-define-keys
2054 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2055 "u" gnus-uu-decode-uu-view
2056 "U" gnus-uu-decode-uu-and-save-view
2057 "s" gnus-uu-decode-unshar-view
2058 "S" gnus-uu-decode-unshar-and-save-view
2059 "o" gnus-uu-decode-save-view
2060 "O" gnus-uu-decode-save-view
2061 "b" gnus-uu-decode-binhex-view
2062 "B" gnus-uu-decode-binhex-view
2063 "p" gnus-uu-decode-postscript-view
2064 "P" gnus-uu-decode-postscript-and-save-view)
2065
2066 (defvar gnus-article-post-menu nil)
2067
2068 (defconst gnus-summary-menu-maxlen 20)
2069
2070 (defun gnus-summary-menu-split (menu)
2071 ;; If we have lots of elements, divide them into groups of 20
2072 ;; and make a pane (or submenu) for each one.
2073 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2074 (let ((menu menu) sublists next
2075 (i 1))
2076 (while menu
2077 ;; Pull off the next gnus-summary-menu-maxlen elements
2078 ;; and make them the next element of sublist.
2079 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2080 (if next
2081 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2082 nil))
2083 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2084 (aref (car (last menu)) 0)) menu)
2085 sublists))
2086 (setq i (1+ i))
2087 (setq menu next))
2088 (nreverse sublists))
2089 ;; Few elements--put them all in one pane.
2090 menu))
2091
2092 (defun gnus-summary-make-menu-bar ()
2093 (gnus-turn-off-edit-menu 'summary)
2094
2095 (unless (boundp 'gnus-summary-misc-menu)
2096
2097 (easy-menu-define
2098 gnus-summary-kill-menu gnus-summary-mode-map ""
2099 (cons
2100 "Score"
2101 (nconc
2102 (list
2103 ["Customize" gnus-score-customize t])
2104 (gnus-make-score-map 'increase)
2105 (gnus-make-score-map 'lower)
2106 '(("Mark"
2107 ["Kill below" gnus-summary-kill-below t]
2108 ["Mark above" gnus-summary-mark-above t]
2109 ["Tick above" gnus-summary-tick-above t]
2110 ["Clear above" gnus-summary-clear-above t])
2111 ["Current score" gnus-summary-current-score t]
2112 ["Set score" gnus-summary-set-score t]
2113 ["Switch current score file..." gnus-score-change-score-file t]
2114 ["Set mark below..." gnus-score-set-mark-below t]
2115 ["Set expunge below..." gnus-score-set-expunge-below t]
2116 ["Edit current score file" gnus-score-edit-current-scores t]
2117 ["Edit score file" gnus-score-edit-file t]
2118 ["Trace score" gnus-score-find-trace t]
2119 ["Find words" gnus-score-find-favourite-words t]
2120 ["Rescore buffer" gnus-summary-rescore t]
2121 ["Increase score..." gnus-summary-increase-score t]
2122 ["Lower score..." gnus-summary-lower-score t]))))
2123
2124 ;; Define both the Article menu in the summary buffer and the
2125 ;; equivalent Commands menu in the article buffer here for
2126 ;; consistency.
2127 (let ((innards
2128 `(("Hide"
2129 ["All" gnus-article-hide t]
2130 ["Headers" gnus-article-hide-headers t]
2131 ["Signature" gnus-article-hide-signature t]
2132 ["Citation" gnus-article-hide-citation t]
2133 ["List identifiers" gnus-article-hide-list-identifiers t]
2134 ["Banner" gnus-article-strip-banner t]
2135 ["Boring headers" gnus-article-hide-boring-headers t])
2136 ("Highlight"
2137 ["All" gnus-article-highlight t]
2138 ["Headers" gnus-article-highlight-headers t]
2139 ["Signature" gnus-article-highlight-signature t]
2140 ["Citation" gnus-article-highlight-citation t])
2141 ("MIME"
2142 ["Words" gnus-article-decode-mime-words t]
2143 ["Charset" gnus-article-decode-charset t]
2144 ["QP" gnus-article-de-quoted-unreadable t]
2145 ["Base64" gnus-article-de-base64-unreadable t]
2146 ["View MIME buttons" gnus-summary-display-buttonized t]
2147 ["View all" gnus-mime-view-all-parts t]
2148 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2149 ["Encrypt body" gnus-article-encrypt-body
2150 :active (not (gnus-group-read-only-p))
2151 ,@(if (featurep 'xemacs) nil
2152 '(:help "Encrypt the message body on disk"))]
2153 ["Extract all parts..." gnus-summary-save-parts t]
2154 ("Multipart"
2155 ["Repair multipart" gnus-summary-repair-multipart t]
2156 ["Pipe part..." gnus-article-pipe-part t]
2157 ["Inline part" gnus-article-inline-part t]
2158 ["Encrypt body" gnus-article-encrypt-body
2159 :active (not (gnus-group-read-only-p))
2160 ,@(if (featurep 'xemacs) nil
2161 '(:help "Encrypt the message body on disk"))]
2162 ["View part externally" gnus-article-view-part-externally t]
2163 ["View part with charset..." gnus-article-view-part-as-charset t]
2164 ["Copy part" gnus-article-copy-part t]
2165 ["Save part..." gnus-article-save-part t]
2166 ["View part" gnus-article-view-part t]))
2167 ("Date"
2168 ["Local" gnus-article-date-local t]
2169 ["ISO8601" gnus-article-date-iso8601 t]
2170 ["UT" gnus-article-date-ut t]
2171 ["Original" gnus-article-date-original t]
2172 ["Lapsed" gnus-article-date-lapsed t]
2173 ["User-defined" gnus-article-date-user t])
2174 ("Display"
2175 ["Remove images" gnus-article-remove-images t]
2176 ["Toggle smiley" gnus-treat-smiley t]
2177 ["Show X-Face" gnus-article-display-x-face t]
2178 ["Show picons in From" gnus-treat-from-picon t]
2179 ["Show picons in mail headers" gnus-treat-mail-picon t]
2180 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2181 ("View as different encoding"
2182 ,@(gnus-summary-menu-split
2183 (mapcar
2184 (lambda (cs)
2185 ;; Since easymenu under Emacs doesn't allow
2186 ;; lambda forms for menu commands, we should
2187 ;; provide intern'ed function symbols.
2188 (let ((command (intern (format "\
2189 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2190 (fset command
2191 `(lambda ()
2192 (interactive)
2193 (let ((gnus-summary-show-article-charset-alist
2194 '((1 . ,cs))))
2195 (gnus-summary-show-article 1))))
2196 `[,(symbol-name cs) ,command t]))
2197 (sort (if (fboundp 'coding-system-list)
2198 (coding-system-list)
2199 (mapcar 'car mm-mime-mule-charset-alist))
2200 'string<)))))
2201 ("Washing"
2202 ("Remove Blanks"
2203 ["Leading" gnus-article-strip-leading-blank-lines t]
2204 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2205 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2206 ["All of the above" gnus-article-strip-blank-lines t]
2207 ["All" gnus-article-strip-all-blank-lines t]
2208 ["Leading space" gnus-article-strip-leading-space t]
2209 ["Trailing space" gnus-article-strip-trailing-space t]
2210 ["Leading space in headers"
2211 gnus-article-remove-leading-whitespace t])
2212 ["Overstrike" gnus-article-treat-overstrike t]
2213 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2214 ["Emphasis" gnus-article-emphasize t]
2215 ["Word wrap" gnus-article-fill-cited-article t]
2216 ["Fill long lines" gnus-article-fill-long-lines t]
2217 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2218 ["Remove CR" gnus-article-remove-cr t]
2219 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2220 ["Base64" gnus-article-de-base64-unreadable t]
2221 ["Rot 13" gnus-summary-caesar-message
2222 ,@(if (featurep 'xemacs) '(t)
2223 '(:help "\"Caesar rotate\" article by 13"))]
2224 ["Morse decode" gnus-summary-morse-message t]
2225 ["Unix pipe..." gnus-summary-pipe-message t]
2226 ["Add buttons" gnus-article-add-buttons t]
2227 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2228 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2229 ["Verbose header" gnus-summary-verbose-headers t]
2230 ["Toggle header" gnus-summary-toggle-header t]
2231 ["Unfold headers" gnus-article-treat-unfold-headers t]
2232 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2233 ["Html" gnus-article-wash-html t]
2234 ["Unsplit URLs" gnus-article-unsplit-urls t]
2235 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2236 ["Decode HZ" gnus-article-decode-HZ t]
2237 ("(Outlook) Deuglify"
2238 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2239 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2240 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2241 ["Full (Outlook) deuglify"
2242 gnus-article-outlook-deuglify-article t])
2243 )
2244 ("Output"
2245 ["Save in default format..." gnus-summary-save-article
2246 ,@(if (featurep 'xemacs) '(t)
2247 '(:help "Save article using default method"))]
2248 ["Save in file..." gnus-summary-save-article-file
2249 ,@(if (featurep 'xemacs) '(t)
2250 '(:help "Save article in file"))]
2251 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2252 ["Save in MH folder..." gnus-summary-save-article-folder t]
2253 ["Save in VM folder..." gnus-summary-save-article-vm t]
2254 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2255 ["Save body in file..." gnus-summary-save-article-body-file t]
2256 ["Pipe through a filter..." gnus-summary-pipe-output t]
2257 ["Add to SOUP packet" gnus-soup-add-article t]
2258 ["Print with Muttprint..." gnus-summary-muttprint t]
2259 ["Print" gnus-summary-print-article
2260 ,@(if (featurep 'xemacs) '(t)
2261 '(:help "Generate and print a PostScript image"))])
2262 ("Copy, move,... (Backend)"
2263 ,@(if (featurep 'xemacs) nil
2264 '(:help "Copying, moving, expiring articles..."))
2265 ["Respool article..." gnus-summary-respool-article t]
2266 ["Move article..." gnus-summary-move-article
2267 (gnus-check-backend-function
2268 'request-move-article gnus-newsgroup-name)]
2269 ["Copy article..." gnus-summary-copy-article t]
2270 ["Crosspost article..." gnus-summary-crosspost-article
2271 (gnus-check-backend-function
2272 'request-replace-article gnus-newsgroup-name)]
2273 ["Import file..." gnus-summary-import-article
2274 (gnus-check-backend-function
2275 'request-accept-article gnus-newsgroup-name)]
2276 ["Create article..." gnus-summary-create-article
2277 (gnus-check-backend-function
2278 'request-accept-article gnus-newsgroup-name)]
2279 ["Check if posted" gnus-summary-article-posted-p t]
2280 ["Edit article" gnus-summary-edit-article
2281 (not (gnus-group-read-only-p))]
2282 ["Delete article" gnus-summary-delete-article
2283 (gnus-check-backend-function
2284 'request-expire-articles gnus-newsgroup-name)]
2285 ["Query respool" gnus-summary-respool-query t]
2286 ["Trace respool" gnus-summary-respool-trace t]
2287 ["Delete expirable articles" gnus-summary-expire-articles-now
2288 (gnus-check-backend-function
2289 'request-expire-articles gnus-newsgroup-name)])
2290 ("Extract"
2291 ["Uudecode" gnus-uu-decode-uu
2292 ,@(if (featurep 'xemacs) '(t)
2293 '(:help "Decode uuencoded article(s)"))]
2294 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2295 ["Unshar" gnus-uu-decode-unshar t]
2296 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2297 ["Save" gnus-uu-decode-save t]
2298 ["Binhex" gnus-uu-decode-binhex t]
2299 ["Postscript" gnus-uu-decode-postscript t]
2300 ["All MIME parts" gnus-summary-save-parts t])
2301 ("Cache"
2302 ["Enter article" gnus-cache-enter-article t]
2303 ["Remove article" gnus-cache-remove-article t])
2304 ["Translate" gnus-article-babel t]
2305 ["Select article buffer" gnus-summary-select-article-buffer t]
2306 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2307 ["Isearch article..." gnus-summary-isearch-article t]
2308 ["Beginning of the article" gnus-summary-beginning-of-article t]
2309 ["End of the article" gnus-summary-end-of-article t]
2310 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2311 ["Fetch referenced articles" gnus-summary-refer-references t]
2312 ["Fetch current thread" gnus-summary-refer-thread t]
2313 ["Fetch article with id..." gnus-summary-refer-article t]
2314 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2315 ["Redisplay" gnus-summary-show-article t]
2316 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2317 (easy-menu-define
2318 gnus-summary-article-menu gnus-summary-mode-map ""
2319 (cons "Article" innards))
2320
2321 (if (not (keymapp gnus-summary-article-menu))
2322 (easy-menu-define
2323 gnus-article-commands-menu gnus-article-mode-map ""
2324 (cons "Commands" innards))
2325 ;; in Emacs, don't share menu.
2326 (setq gnus-article-commands-menu
2327 (copy-keymap gnus-summary-article-menu))
2328 (define-key gnus-article-mode-map [menu-bar commands]
2329 (cons "Commands" gnus-article-commands-menu))))
2330
2331 (easy-menu-define
2332 gnus-summary-thread-menu gnus-summary-mode-map ""
2333 '("Threads"
2334 ["Find all messages in thread" gnus-summary-refer-thread t]
2335 ["Toggle threading" gnus-summary-toggle-threads t]
2336 ["Hide threads" gnus-summary-hide-all-threads t]
2337 ["Show threads" gnus-summary-show-all-threads t]
2338 ["Hide thread" gnus-summary-hide-thread t]
2339 ["Show thread" gnus-summary-show-thread t]
2340 ["Go to next thread" gnus-summary-next-thread t]
2341 ["Go to previous thread" gnus-summary-prev-thread t]
2342 ["Go down thread" gnus-summary-down-thread t]
2343 ["Go up thread" gnus-summary-up-thread t]
2344 ["Top of thread" gnus-summary-top-thread t]
2345 ["Mark thread as read" gnus-summary-kill-thread t]
2346 ["Lower thread score" gnus-summary-lower-thread t]
2347 ["Raise thread score" gnus-summary-raise-thread t]
2348 ["Rethread current" gnus-summary-rethread-current t]))
2349
2350 (easy-menu-define
2351 gnus-summary-post-menu gnus-summary-mode-map ""
2352 `("Post"
2353 ["Send a message (mail or news)" gnus-summary-post-news
2354 ,@(if (featurep 'xemacs) '(t)
2355 '(:help "Compose a new message (mail or news)"))]
2356 ["Followup" gnus-summary-followup
2357 ,@(if (featurep 'xemacs) '(t)
2358 '(:help "Post followup to this article"))]
2359 ["Followup and yank" gnus-summary-followup-with-original
2360 ,@(if (featurep 'xemacs) '(t)
2361 '(:help "Post followup to this article, quoting its contents"))]
2362 ["Supersede article" gnus-summary-supersede-article t]
2363 ["Cancel article" gnus-summary-cancel-article
2364 ,@(if (featurep 'xemacs) '(t)
2365 '(:help "Cancel an article you posted"))]
2366 ["Reply" gnus-summary-reply t]
2367 ["Reply and yank" gnus-summary-reply-with-original t]
2368 ["Wide reply" gnus-summary-wide-reply t]
2369 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2370 ,@(if (featurep 'xemacs) '(t)
2371 '(:help "Mail a reply, quoting this article"))]
2372 ["Very wide reply" gnus-summary-very-wide-reply t]
2373 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2374 ,@(if (featurep 'xemacs) '(t)
2375 '(:help "Mail a very wide reply, quoting this article"))]
2376 ["Mail forward" gnus-summary-mail-forward t]
2377 ["Post forward" gnus-summary-post-forward t]
2378 ["Digest and mail" gnus-uu-digest-mail-forward t]
2379 ["Digest and post" gnus-uu-digest-post-forward t]
2380 ["Resend message" gnus-summary-resend-message t]
2381 ["Resend message edit" gnus-summary-resend-message-edit t]
2382 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2383 ["Send a mail" gnus-summary-mail-other-window t]
2384 ["Create a local message" gnus-summary-news-other-window t]
2385 ["Uuencode and post" gnus-uu-post-news
2386 ,@(if (featurep 'xemacs) '(t)
2387 '(:help "Post a uuencoded article"))]
2388 ["Followup via news" gnus-summary-followup-to-mail t]
2389 ["Followup via news and yank"
2390 gnus-summary-followup-to-mail-with-original t]
2391 ;;("Draft"
2392 ;;["Send" gnus-summary-send-draft t]
2393 ;;["Send bounced" gnus-resend-bounced-mail t])
2394 ))
2395
2396 (cond
2397 ((not (keymapp gnus-summary-post-menu))
2398 (setq gnus-article-post-menu gnus-summary-post-menu))
2399 ((not gnus-article-post-menu)
2400 ;; Don't share post menu.
2401 (setq gnus-article-post-menu
2402 (copy-keymap gnus-summary-post-menu))))
2403 (define-key gnus-article-mode-map [menu-bar post]
2404 (cons "Post" gnus-article-post-menu))
2405
2406 (easy-menu-define
2407 gnus-summary-misc-menu gnus-summary-mode-map ""
2408 `("Gnus"
2409 ("Mark Read"
2410 ["Mark as read" gnus-summary-mark-as-read-forward t]
2411 ["Mark same subject and select"
2412 gnus-summary-kill-same-subject-and-select t]
2413 ["Mark same subject" gnus-summary-kill-same-subject t]
2414 ["Catchup" gnus-summary-catchup
2415 ,@(if (featurep 'xemacs) '(t)
2416 '(:help "Mark unread articles in this group as read"))]
2417 ["Catchup all" gnus-summary-catchup-all t]
2418 ["Catchup to here" gnus-summary-catchup-to-here t]
2419 ["Catchup from here" gnus-summary-catchup-from-here t]
2420 ["Catchup region" gnus-summary-mark-region-as-read
2421 (gnus-mark-active-p)]
2422 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2423 ("Mark Various"
2424 ["Tick" gnus-summary-tick-article-forward t]
2425 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2426 ["Remove marks" gnus-summary-clear-mark-forward t]
2427 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2428 ["Set bookmark" gnus-summary-set-bookmark t]
2429 ["Remove bookmark" gnus-summary-remove-bookmark t])
2430 ("Limit to"
2431 ["Marks..." gnus-summary-limit-to-marks t]
2432 ["Subject..." gnus-summary-limit-to-subject t]
2433 ["Author..." gnus-summary-limit-to-author t]
2434 ["Age..." gnus-summary-limit-to-age t]
2435 ["Extra..." gnus-summary-limit-to-extra t]
2436 ["Score..." gnus-summary-limit-to-score t]
2437 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2438 ["Unread" gnus-summary-limit-to-unread t]
2439 ["Unseen" gnus-summary-limit-to-unseen t]
2440 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2441 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2442 ["Pop limit" gnus-summary-pop-limit t]
2443 ["Show dormant" gnus-summary-limit-include-dormant t]
2444 ["Hide childless dormant"
2445 gnus-summary-limit-exclude-childless-dormant t]
2446 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2447 ["Hide marked" gnus-summary-limit-exclude-marks t]
2448 ["Show expunged" gnus-summary-limit-include-expunged t])
2449 ("Process Mark"
2450 ["Set mark" gnus-summary-mark-as-processable t]
2451 ["Remove mark" gnus-summary-unmark-as-processable t]
2452 ["Remove all marks" gnus-summary-unmark-all-processable t]
2453 ["Mark above" gnus-uu-mark-over t]
2454 ["Mark series" gnus-uu-mark-series t]
2455 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2456 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2457 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2458 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2459 ["Mark all" gnus-uu-mark-all t]
2460 ["Mark buffer" gnus-uu-mark-buffer t]
2461 ["Mark sparse" gnus-uu-mark-sparse t]
2462 ["Mark thread" gnus-uu-mark-thread t]
2463 ["Unmark thread" gnus-uu-unmark-thread t]
2464 ("Process Mark Sets"
2465 ["Kill" gnus-summary-kill-process-mark t]
2466 ["Yank" gnus-summary-yank-process-mark
2467 gnus-newsgroup-process-stack]
2468 ["Save" gnus-summary-save-process-mark t]
2469 ["Run command on marked..." gnus-summary-universal-argument t]))
2470 ("Scroll article"
2471 ["Page forward" gnus-summary-next-page
2472 ,@(if (featurep 'xemacs) '(t)
2473 '(:help "Show next page of article"))]
2474 ["Page backward" gnus-summary-prev-page
2475 ,@(if (featurep 'xemacs) '(t)
2476 '(:help "Show previous page of article"))]
2477 ["Line forward" gnus-summary-scroll-up t])
2478 ("Move"
2479 ["Next unread article" gnus-summary-next-unread-article t]
2480 ["Previous unread article" gnus-summary-prev-unread-article t]
2481 ["Next article" gnus-summary-next-article t]
2482 ["Previous article" gnus-summary-prev-article t]
2483 ["Next unread subject" gnus-summary-next-unread-subject t]
2484 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2485 ["Next article same subject" gnus-summary-next-same-subject t]
2486 ["Previous article same subject" gnus-summary-prev-same-subject t]
2487 ["First unread article" gnus-summary-first-unread-article t]
2488 ["Best unread article" gnus-summary-best-unread-article t]
2489 ["Go to subject number..." gnus-summary-goto-subject t]
2490 ["Go to article number..." gnus-summary-goto-article t]
2491 ["Go to the last article" gnus-summary-goto-last-article t]
2492 ["Pop article off history" gnus-summary-pop-article t])
2493 ("Sort"
2494 ["Sort by number" gnus-summary-sort-by-number t]
2495 ["Sort by author" gnus-summary-sort-by-author t]
2496 ["Sort by subject" gnus-summary-sort-by-subject t]
2497 ["Sort by date" gnus-summary-sort-by-date t]
2498 ["Sort by score" gnus-summary-sort-by-score t]
2499 ["Sort by lines" gnus-summary-sort-by-lines t]
2500 ["Sort by characters" gnus-summary-sort-by-chars t]
2501 ["Randomize" gnus-summary-sort-by-random t]
2502 ["Original sort" gnus-summary-sort-by-original t])
2503 ("Help"
2504 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2505 ["Describe group" gnus-summary-describe-group t]
2506 ["Fetch charter" gnus-group-fetch-charter
2507 ,@(if (featurep 'xemacs) nil
2508 '(:help "Display the charter of the current group"))]
2509 ["Fetch control message" gnus-group-fetch-control
2510 ,@(if (featurep 'xemacs) nil
2511 '(:help "Display the archived control message for the current group"))]
2512 ["Read manual" gnus-info-find-node t])
2513 ("Modes"
2514 ["Pick and read" gnus-pick-mode t]
2515 ["Binary" gnus-binary-mode t])
2516 ("Regeneration"
2517 ["Regenerate" gnus-summary-prepare t]
2518 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2519 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2520 ["Toggle threading" gnus-summary-toggle-threads t])
2521 ["See old articles" gnus-summary-insert-old-articles t]
2522 ["See new articles" gnus-summary-insert-new-articles t]
2523 ["Filter articles..." gnus-summary-execute-command t]
2524 ["Run command on articles..." gnus-summary-universal-argument t]
2525 ["Search articles forward..." gnus-summary-search-article-forward t]
2526 ["Search articles backward..." gnus-summary-search-article-backward t]
2527 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2528 ["Expand window" gnus-summary-expand-window t]
2529 ["Expire expirable articles" gnus-summary-expire-articles
2530 (gnus-check-backend-function
2531 'request-expire-articles gnus-newsgroup-name)]
2532 ["Edit local kill file" gnus-summary-edit-local-kill t]
2533 ["Edit main kill file" gnus-summary-edit-global-kill t]
2534 ["Edit group parameters" gnus-summary-edit-parameters t]
2535 ["Customize group parameters" gnus-summary-customize-parameters t]
2536 ["Send a bug report" gnus-bug t]
2537 ("Exit"
2538 ["Catchup and exit" gnus-summary-catchup-and-exit
2539 ,@(if (featurep 'xemacs) '(t)
2540 '(:help "Mark unread articles in this group as read, then exit"))]
2541 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2542 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2543 ["Exit group" gnus-summary-exit
2544 ,@(if (featurep 'xemacs) '(t)
2545 '(:help "Exit current group, return to group selection mode"))]
2546 ["Exit group without updating" gnus-summary-exit-no-update t]
2547 ["Exit and goto next group" gnus-summary-next-group t]
2548 ["Exit and goto prev group" gnus-summary-prev-group t]
2549 ["Reselect group" gnus-summary-reselect-current-group t]
2550 ["Rescan group" gnus-summary-rescan-group t]
2551 ["Update dribble" gnus-summary-save-newsrc t])))
2552
2553 (gnus-run-hooks 'gnus-summary-menu-hook)))
2554
2555 (defvar gnus-summary-tool-bar-map nil)
2556
2557 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2558 ;; affect _new_ message buffers. We might add a function that walks thru all
2559 ;; summary-mode buffers and force the update.
2560 (defun gnus-summary-tool-bar-update (&optional symbol value)
2561 "Update summary mode toolbar.
2562 Setter function for custom variables."
2563 (setq-default gnus-summary-tool-bar-map nil)
2564 (when symbol
2565 ;; When used as ":set" function:
2566 (set-default symbol value))
2567 (when (gnus-buffer-live-p gnus-summary-buffer)
2568 (with-current-buffer gnus-summary-buffer
2569 (gnus-summary-make-tool-bar))))
2570
2571 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2572 'gnus-summary-tool-bar-gnome
2573 'gnus-summary-tool-bar-retro)
2574 "Specifies the Gnus summary tool bar.
2575
2576 It can be either a list or a symbol refering to a list. See
2577 `gmm-tool-bar-from-list' for the format of the list. The
2578 default key map is `gnus-summary-mode-map'.
2579
2580 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2581 `gnus-summary-tool-bar-retro'."
2582 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2583 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2584 (repeat :tag "User defined list" gmm-tool-bar-item)
2585 (symbol))
2586 :version "22.1" ;; Gnus 5.10.9
2587 :initialize 'custom-initialize-default
2588 :set 'gnus-summary-tool-bar-update
2589 :group 'gnus-summary)
2590
2591 (defcustom gnus-summary-tool-bar-gnome
2592 '((gnus-summary-post-news "mail/compose" nil)
2593 (gnus-summary-insert-new-articles "mail/inbox" nil
2594 :visible (or (not gnus-agent)
2595 gnus-plugged))
2596 (gnus-summary-reply-with-original "mail/reply")
2597 (gnus-summary-reply "mail/reply" nil :visible nil)
2598 (gnus-summary-followup-with-original "mail/reply-all")
2599 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2600 (gnus-summary-mail-forward "mail/forward")
2601 (gnus-summary-save-article "mail/save")
2602 (gnus-summary-search-article-forward "search" nil :visible nil)
2603 (gnus-summary-print-article "print")
2604 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2605 ;; Some new commands that may need more suitable icons:
2606 (gnus-summary-save-newsrc "save" nil :visible nil)
2607 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2608 (gnus-summary-prev-article "left-arrow")
2609 (gnus-summary-next-article "right-arrow")
2610 (gnus-summary-next-page "next-page")
2611 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2612 ;;
2613 ;; Maybe some sort-by-... could be added:
2614 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2615 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2616 (gnus-summary-mark-as-expirable
2617 "delete" nil
2618 :visible (gnus-check-backend-function 'request-expire-articles
2619 gnus-newsgroup-name))
2620 (gnus-summary-mark-as-spam
2621 "mail/spam" t
2622 :visible (and (fboundp 'spam-group-ham-contents-p)
2623 (spam-group-ham-contents-p gnus-newsgroup-name))
2624 :help "Mark as spam")
2625 (gnus-summary-mark-as-read-forward
2626 "mail/not-spam" nil
2627 :visible (and (fboundp 'spam-group-spam-contents-p)
2628 (spam-group-spam-contents-p gnus-newsgroup-name)))
2629 ;;
2630 (gnus-summary-exit "exit")
2631 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2632 (gnus-info-find-node "help"))
2633 "List of functions for the summary tool bar (GNOME style).
2634
2635 See `gmm-tool-bar-from-list' for the format of the list."
2636 :type '(repeat gmm-tool-bar-item)
2637 :version "22.1" ;; Gnus 5.10.9
2638 :initialize 'custom-initialize-default
2639 :set 'gnus-summary-tool-bar-update
2640 :group 'gnus-summary)
2641
2642 (defcustom gnus-summary-tool-bar-retro
2643 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2644 (gnus-summary-next-unread-article "gnus/next-ur")
2645 (gnus-summary-post-news "gnus/post")
2646 (gnus-summary-followup-with-original "gnus/fuwo")
2647 (gnus-summary-followup "gnus/followup")
2648 (gnus-summary-reply-with-original "gnus/reply-wo")
2649 (gnus-summary-reply "gnus/reply")
2650 (gnus-summary-caesar-message "gnus/rot13")
2651 (gnus-uu-decode-uu "gnus/uu-decode")
2652 (gnus-summary-save-article-file "gnus/save-aif")
2653 (gnus-summary-save-article "gnus/save-art")
2654 (gnus-uu-post-news "gnus/uu-post")
2655 (gnus-summary-catchup "gnus/catchup")
2656 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2657 (gnus-summary-exit "gnus/exit-summ")
2658 ;; Some new command that may need more suitable icons:
2659 (gnus-summary-print-article "gnus/print" nil :visible nil)
2660 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2661 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2662 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2663 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2664 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2665 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2666 ;;
2667 (gnus-info-find-node "gnus/help" nil :visible nil))
2668 "List of functions for the summary tool bar (retro look).
2669
2670 See `gmm-tool-bar-from-list' for the format of the list."
2671 :type '(repeat gmm-tool-bar-item)
2672 :version "22.1" ;; Gnus 5.10.9
2673 :initialize 'custom-initialize-default
2674 :set 'gnus-summary-tool-bar-update
2675 :group 'gnus-summary)
2676
2677 (defcustom gnus-summary-tool-bar-zap-list t
2678 "List of icon items from the global tool bar.
2679 These items are not displayed in the Gnus summary mode tool bar.
2680
2681 See `gmm-tool-bar-from-list' for the format of the list."
2682 :type 'gmm-tool-bar-zap-list
2683 :version "22.1" ;; Gnus 5.10.9
2684 :initialize 'custom-initialize-default
2685 :set 'gnus-summary-tool-bar-update
2686 :group 'gnus-summary)
2687
2688 (defvar image-load-path)
2689
2690 (defun gnus-summary-make-tool-bar (&optional force)
2691 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2692 When FORCE, rebuild the tool bar."
2693 (when (and (not (featurep 'xemacs))
2694 (boundp 'tool-bar-mode)
2695 tool-bar-mode
2696 (or (not gnus-summary-tool-bar-map) force))
2697 (let* ((load-path
2698 (gmm-image-load-path-for-library "gnus"
2699 "mail/save.xpm"
2700 nil t))
2701 (image-load-path (cons (car load-path)
2702 (when (boundp 'image-load-path)
2703 image-load-path)))
2704 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2705 gnus-summary-tool-bar-zap-list
2706 'gnus-summary-mode-map)))
2707 (when map
2708 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2709 ;; uses it's value.
2710 (setq gnus-summary-tool-bar-map map))))
2711 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2712
2713 (defun gnus-score-set-default (var value)
2714 "A version of set that updates the GNU Emacs menu-bar."
2715 (set var value)
2716 ;; It is the message that forces the active status to be updated.
2717 (message ""))
2718
2719 (defun gnus-make-score-map (type)
2720 "Make a summary score map of type TYPE."
2721 (if t
2722 nil
2723 (let ((headers '(("author" "from" string)
2724 ("subject" "subject" string)
2725 ("article body" "body" string)
2726 ("article head" "head" string)
2727 ("xref" "xref" string)
2728 ("extra header" "extra" string)
2729 ("lines" "lines" number)
2730 ("followups to author" "followup" string)))
2731 (types '((number ("less than" <)
2732 ("greater than" >)
2733 ("equal" =))
2734 (string ("substring" s)
2735 ("exact string" e)
2736 ("fuzzy string" f)
2737 ("regexp" r))))
2738 (perms '(("temporary" (current-time-string))
2739 ("permanent" nil)
2740 ("immediate" now)))
2741 header)
2742 (list
2743 (apply
2744 'nconc
2745 (list
2746 (if (eq type 'lower)
2747 "Lower score"
2748 "Increase score"))
2749 (let (outh)
2750 (while headers
2751 (setq header (car headers))
2752 (setq outh
2753 (cons
2754 (apply
2755 'nconc
2756 (list (car header))
2757 (let ((ts (cdr (assoc (nth 2 header) types)))
2758 outt)
2759 (while ts
2760 (setq outt
2761 (cons
2762 (apply
2763 'nconc
2764 (list (caar ts))
2765 (let ((ps perms)
2766 outp)
2767 (while ps
2768 (setq outp
2769 (cons
2770 (vector
2771 (caar ps)
2772 (list
2773 'gnus-summary-score-entry
2774 (nth 1 header)
2775 (if (or (string= (nth 1 header)
2776 "head")
2777 (string= (nth 1 header)
2778 "body"))
2779 ""
2780 (list 'gnus-summary-header
2781 (nth 1 header)))
2782 (list 'quote (nth 1 (car ts)))
2783 (list 'gnus-score-delta-default
2784 nil)
2785 (nth 1 (car ps))
2786 t)
2787 t)
2788 outp))
2789 (setq ps (cdr ps)))
2790 (list (nreverse outp))))
2791 outt))
2792 (setq ts (cdr ts)))
2793 (list (nreverse outt))))
2794 outh))
2795 (setq headers (cdr headers)))
2796 (list (nreverse outh))))))))
2797
2798 \f
2799
2800 (defun gnus-summary-mode (&optional group)
2801 "Major mode for reading articles.
2802
2803 All normal editing commands are switched off.
2804 \\<gnus-summary-mode-map>
2805 Each line in this buffer represents one article. To read an
2806 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2807 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2808 respectively.
2809
2810 You can also post articles and send mail from this buffer. To
2811 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2812 of an article, type `\\[gnus-summary-reply]'.
2813
2814 There are approx. one gazillion commands you can execute in this
2815 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2816
2817 The following commands are available:
2818
2819 \\{gnus-summary-mode-map}"
2820 (interactive)
2821 (kill-all-local-variables)
2822 (when (gnus-visual-p 'summary-menu 'menu)
2823 (gnus-summary-make-menu-bar)
2824 (gnus-summary-make-tool-bar))
2825 (gnus-summary-make-local-variables)
2826 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2827 (gnus-summary-make-local-variables))
2828 (gnus-make-thread-indent-array)
2829 (gnus-simplify-mode-line)
2830 (setq major-mode 'gnus-summary-mode)
2831 (setq mode-name "Summary")
2832 (make-local-variable 'minor-mode-alist)
2833 (use-local-map gnus-summary-mode-map)
2834 (buffer-disable-undo)
2835 (setq buffer-read-only t) ;Disable modification
2836 (setq truncate-lines t)
2837 (setq selective-display t)
2838 (setq selective-display-ellipses t) ;Display `...'
2839 (gnus-summary-set-display-table)
2840 (gnus-set-default-directory)
2841 (setq gnus-newsgroup-name group)
2842 (make-local-variable 'gnus-summary-line-format)
2843 (make-local-variable 'gnus-summary-line-format-spec)
2844 (make-local-variable 'gnus-summary-dummy-line-format)
2845 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2846 (make-local-variable 'gnus-summary-mark-positions)
2847 (gnus-make-local-hook 'pre-command-hook)
2848 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2849 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2850 (turn-on-gnus-mailing-list-mode)
2851 (mm-enable-multibyte)
2852 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2853 (gnus-update-summary-mark-positions))
2854
2855 (defun gnus-summary-make-local-variables ()
2856 "Make all the local summary buffer variables."
2857 (let (global)
2858 (dolist (local gnus-summary-local-variables)
2859 (if (consp local)
2860 (progn
2861 (if (eq (cdr local) 'global)
2862 ;; Copy the global value of the variable.
2863 (setq global (symbol-value (car local)))
2864 ;; Use the value from the list.
2865 (setq global (eval (cdr local))))
2866 (set (make-local-variable (car local)) global))
2867 ;; Simple nil-valued local variable.
2868 (set (make-local-variable local) nil)))))
2869
2870 (defun gnus-summary-clear-local-variables ()
2871 (let ((locals gnus-summary-local-variables))
2872 (while locals
2873 (if (consp (car locals))
2874 (and (vectorp (caar locals))
2875 (set (caar locals) nil))
2876 (and (vectorp (car locals))
2877 (set (car locals) nil)))
2878 (setq locals (cdr locals)))))
2879
2880 ;; Summary data functions.
2881
2882 (defmacro gnus-data-number (data)
2883 `(car ,data))
2884
2885 (defmacro gnus-data-set-number (data number)
2886 `(setcar ,data ,number))
2887
2888 (defmacro gnus-data-mark (data)
2889 `(nth 1 ,data))
2890
2891 (defmacro gnus-data-set-mark (data mark)
2892 `(setcar (nthcdr 1 ,data) ,mark))
2893
2894 (defmacro gnus-data-pos (data)
2895 `(nth 2 ,data))
2896
2897 (defmacro gnus-data-set-pos (data pos)
2898 `(setcar (nthcdr 2 ,data) ,pos))
2899
2900 (defmacro gnus-data-header (data)
2901 `(nth 3 ,data))
2902
2903 (defmacro gnus-data-set-header (data header)
2904 `(setf (nth 3 ,data) ,header))
2905
2906 (defmacro gnus-data-level (data)
2907 `(nth 4 ,data))
2908
2909 (defmacro gnus-data-unread-p (data)
2910 `(= (nth 1 ,data) gnus-unread-mark))
2911
2912 (defmacro gnus-data-read-p (data)
2913 `(/= (nth 1 ,data) gnus-unread-mark))
2914
2915 (defmacro gnus-data-pseudo-p (data)
2916 `(consp (nth 3 ,data)))
2917
2918 (defmacro gnus-data-find (number)
2919 `(assq ,number gnus-newsgroup-data))
2920
2921 (defmacro gnus-data-find-list (number &optional data)
2922 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2923 (memq (assq ,number bdata)
2924 bdata)))
2925
2926 (defmacro gnus-data-make (number mark pos header level)
2927 `(list ,number ,mark ,pos ,header ,level))
2928
2929 (defun gnus-data-enter (after-article number mark pos header level offset)
2930 (let ((data (gnus-data-find-list after-article)))
2931 (unless data
2932 (error "No such article: %d" after-article))
2933 (setcdr data (cons (gnus-data-make number mark pos header level)
2934 (cdr data)))
2935 (setq gnus-newsgroup-data-reverse nil)
2936 (gnus-data-update-list (cddr data) offset)))
2937
2938 (defun gnus-data-enter-list (after-article list &optional offset)
2939 (when list
2940 (let ((data (and after-article (gnus-data-find-list after-article)))
2941 (ilist list))
2942 (if (not (or data
2943 after-article))
2944 (let ((odata gnus-newsgroup-data))
2945 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2946 (when offset
2947 (gnus-data-update-list odata offset)))
2948 ;; Find the last element in the list to be spliced into the main
2949 ;; list.
2950 (while (cdr list)
2951 (setq list (cdr list)))
2952 (if (not data)
2953 (progn
2954 (setcdr list gnus-newsgroup-data)
2955 (setq gnus-newsgroup-data ilist)
2956 (when offset
2957 (gnus-data-update-list (cdr list) offset)))
2958 (setcdr list (cdr data))
2959 (setcdr data ilist)
2960 (when offset
2961 (gnus-data-update-list (cdr list) offset))))
2962 (setq gnus-newsgroup-data-reverse nil))))
2963
2964 (defun gnus-data-remove (article &optional offset)
2965 (let ((data gnus-newsgroup-data))
2966 (if (= (gnus-data-number (car data)) article)
2967 (progn
2968 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2969 gnus-newsgroup-data-reverse nil)
2970 (when offset
2971 (gnus-data-update-list gnus-newsgroup-data offset)))
2972 (while (cdr data)
2973 (when (= (gnus-data-number (cadr data)) article)
2974 (setcdr data (cddr data))
2975 (when offset
2976 (gnus-data-update-list (cdr data) offset))
2977 (setq data nil
2978 gnus-newsgroup-data-reverse nil))
2979 (setq data (cdr data))))))
2980
2981 (defmacro gnus-data-list (backward)
2982 `(if ,backward
2983 (or gnus-newsgroup-data-reverse
2984 (setq gnus-newsgroup-data-reverse
2985 (reverse gnus-newsgroup-data)))
2986 gnus-newsgroup-data))
2987
2988 (defun gnus-data-update-list (data offset)
2989 "Add OFFSET to the POS of all data entries in DATA."
2990 (setq gnus-newsgroup-data-reverse nil)
2991 (while data
2992 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2993 (setq data (cdr data))))
2994
2995 (defun gnus-summary-article-pseudo-p (article)
2996 "Say whether this article is a pseudo article or not."
2997 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2998
2999 (defmacro gnus-summary-article-sparse-p (article)
3000 "Say whether this article is a sparse article or not."
3001 `(memq ,article gnus-newsgroup-sparse))
3002
3003 (defmacro gnus-summary-article-ancient-p (article)
3004 "Say whether this article is a sparse article or not."
3005 `(memq ,article gnus-newsgroup-ancient))
3006
3007 (defun gnus-article-parent-p (number)
3008 "Say whether this article is a parent or not."
3009 (let ((data (gnus-data-find-list number)))
3010 (and (cdr data) ; There has to be an article after...
3011 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3012 (gnus-data-level (nth 1 data))))))
3013
3014 (defun gnus-article-children (number)
3015 "Return a list of all children to NUMBER."
3016 (let* ((data (gnus-data-find-list number))
3017 (level (gnus-data-level (car data)))
3018 children)
3019 (setq data (cdr data))
3020 (while (and data
3021 (= (gnus-data-level (car data)) (1+ level)))
3022 (push (gnus-data-number (car data)) children)
3023 (setq data (cdr data)))
3024 children))
3025
3026 (defmacro gnus-summary-skip-intangible ()
3027 "If the current article is intangible, then jump to a different article."
3028 '(let ((to (get-text-property (point) 'gnus-intangible)))
3029 (and to (gnus-summary-goto-subject to))))
3030
3031 (defmacro gnus-summary-article-intangible-p ()
3032 "Say whether this article is intangible or not."
3033 '(get-text-property (point) 'gnus-intangible))
3034
3035 (defun gnus-article-read-p (article)
3036 "Say whether ARTICLE is read or not."
3037 (not (or (memq article gnus-newsgroup-marked)
3038 (memq article gnus-newsgroup-spam-marked)
3039 (memq article gnus-newsgroup-unreads)
3040 (memq article gnus-newsgroup-unselected)
3041 (memq article gnus-newsgroup-dormant))))
3042
3043 ;; Some summary mode macros.
3044
3045 (defmacro gnus-summary-article-number ()
3046 "The article number of the article on the current line.
3047 If there isn't an article number here, then we return the current
3048 article number."
3049 '(progn
3050 (gnus-summary-skip-intangible)
3051 (or (get-text-property (point) 'gnus-number)
3052 (gnus-summary-last-subject))))
3053
3054 (defmacro gnus-summary-article-header (&optional number)
3055 "Return the header of article NUMBER."
3056 `(gnus-data-header (gnus-data-find
3057 ,(or number '(gnus-summary-article-number)))))
3058
3059 (defmacro gnus-summary-thread-level (&optional number)
3060 "Return the level of thread that starts with article NUMBER."
3061 `(if (and (eq gnus-summary-make-false-root 'dummy)
3062 (get-text-property (point) 'gnus-intangible))
3063 0
3064 (gnus-data-level (gnus-data-find
3065 ,(or number '(gnus-summary-article-number))))))
3066
3067 (defmacro gnus-summary-article-mark (&optional number)
3068 "Return the mark of article NUMBER."
3069 `(gnus-data-mark (gnus-data-find
3070 ,(or number '(gnus-summary-article-number)))))
3071
3072 (defmacro gnus-summary-article-pos (&optional number)
3073 "Return the position of the line of article NUMBER."
3074 `(gnus-data-pos (gnus-data-find
3075 ,(or number '(gnus-summary-article-number)))))
3076
3077 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3078 (defmacro gnus-summary-article-subject (&optional number)
3079 "Return current subject string or nil if nothing."
3080 `(let ((headers
3081 ,(if number
3082 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3083 '(gnus-data-header (assq (gnus-summary-article-number)
3084 gnus-newsgroup-data)))))
3085 (and headers
3086 (vectorp headers)
3087 (mail-header-subject headers))))
3088
3089 (defmacro gnus-summary-article-score (&optional number)
3090 "Return current article score."
3091 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3092 gnus-newsgroup-scored))
3093 gnus-summary-default-score 0))
3094
3095 (defun gnus-summary-article-children (&optional number)
3096 "Return a list of article numbers that are children of article NUMBER."
3097 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3098 (level (gnus-data-level (car data)))
3099 l children)
3100 (while (and (setq data (cdr data))
3101 (> (setq l (gnus-data-level (car data))) level))
3102 (and (= (1+ level) l)
3103 (push (gnus-data-number (car data))
3104 children)))
3105 (nreverse children)))
3106
3107 (defun gnus-summary-article-parent (&optional number)
3108 "Return the article number of the parent of article NUMBER."
3109 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3110 (gnus-data-list t)))
3111 (level (gnus-data-level (car data))))
3112 (if (zerop level)
3113 () ; This is a root.
3114 ;; We search until we find an article with a level less than
3115 ;; this one. That function has to be the parent.
3116 (while (and (setq data (cdr data))
3117 (not (< (gnus-data-level (car data)) level))))
3118 (and data (gnus-data-number (car data))))))
3119
3120 (defun gnus-unread-mark-p (mark)
3121 "Say whether MARK is the unread mark."
3122 (= mark gnus-unread-mark))
3123
3124 (defun gnus-read-mark-p (mark)
3125 "Say whether MARK is one of the marks that mark as read.
3126 This is all marks except unread, ticked, dormant, and expirable."
3127 (not (or (= mark gnus-unread-mark)
3128 (= mark gnus-ticked-mark)
3129 (= mark gnus-spam-mark)
3130 (= mark gnus-dormant-mark)
3131 (= mark gnus-expirable-mark))))
3132
3133 (defmacro gnus-article-mark (number)
3134 "Return the MARK of article NUMBER.
3135 This macro should only be used when computing the mark the \"first\"
3136 time; i.e., when generating the summary lines. After that,
3137 `gnus-summary-article-mark' should be used to examine the
3138 marks of articles."
3139 `(cond
3140 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3141 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3142 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3143 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3144 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3145 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3146 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3147 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3148 gnus-ancient-mark))))
3149
3150 ;; Saving hidden threads.
3151
3152 (defmacro gnus-save-hidden-threads (&rest forms)
3153 "Save hidden threads, eval FORMS, and restore the hidden threads."
3154 (let ((config (make-symbol "config")))
3155 `(let ((,config (gnus-hidden-threads-configuration)))
3156 (unwind-protect
3157 (save-excursion
3158 ,@forms)
3159 (gnus-restore-hidden-threads-configuration ,config)))))
3160 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3161 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3162
3163 (defun gnus-data-compute-positions ()
3164 "Compute the positions of all articles."
3165 (setq gnus-newsgroup-data-reverse nil)
3166 (let ((data gnus-newsgroup-data))
3167 (save-excursion
3168 (gnus-save-hidden-threads
3169 (gnus-summary-show-all-threads)
3170 (goto-char (point-min))
3171 (while data
3172 (while (get-text-property (point) 'gnus-intangible)
3173 (forward-line 1))
3174 (gnus-data-set-pos (car data) (+ (point) 3))
3175 (setq data (cdr data))
3176 (forward-line 1))))))
3177
3178 (defun gnus-hidden-threads-configuration ()
3179 "Return the current hidden threads configuration."
3180 (save-excursion
3181 (let (config)
3182 (goto-char (point-min))
3183 (while (search-forward "\r" nil t)
3184 (push (1- (point)) config))
3185 config)))
3186
3187 (defun gnus-restore-hidden-threads-configuration (config)
3188 "Restore hidden threads configuration from CONFIG."
3189 (save-excursion
3190 (let (point buffer-read-only)
3191 (while (setq point (pop config))
3192 (when (and (< point (point-max))
3193 (goto-char point)
3194 (eq (char-after) ?\n))
3195 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3196
3197 ;; Various summary mode internalish functions.
3198
3199 (defun gnus-mouse-pick-article (e)
3200 (interactive "e")
3201 (mouse-set-point e)
3202 (gnus-summary-next-page nil t))
3203
3204 (defun gnus-summary-set-display-table ()
3205 "Change the display table.
3206 Odd characters have a tendency to mess
3207 up nicely formatted displays - we make all possible glyphs
3208 display only a single character."
3209
3210 ;; We start from the standard display table, if any.
3211 (let ((table (or (copy-sequence standard-display-table)
3212 (make-display-table)))
3213 (i 32))
3214 ;; Nix out all the control chars...
3215 (while (>= (setq i (1- i)) 0)
3216 (aset table i [??]))
3217 ;; ... but not newline and cr, of course. (cr is necessary for the
3218 ;; selective display).
3219 (aset table ?\n nil)
3220 (aset table ?\r nil)
3221 ;; We keep TAB as well.
3222 (aset table ?\t nil)
3223 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3224 ;; Emacs 23 (unicode), that are not set already.
3225 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3226 160
3227 256)))
3228 (while (>= (setq i (1- i)) 127)
3229 ;; Only modify if the entry is nil.
3230 (unless (aref table i)
3231 (aset table i [??]))))
3232 (setq buffer-display-table table)))
3233
3234 (defun gnus-summary-set-article-display-arrow (pos)
3235 "Update the overlay arrow to point to line at position POS."
3236 (when (and gnus-summary-display-arrow
3237 (boundp 'overlay-arrow-position)
3238 (boundp 'overlay-arrow-string))
3239 (save-excursion
3240 (goto-char pos)
3241 (beginning-of-line)
3242 (unless overlay-arrow-position
3243 (setq overlay-arrow-position (make-marker)))
3244 (setq overlay-arrow-string "=>"
3245 overlay-arrow-position (set-marker overlay-arrow-position
3246 (point)
3247 (current-buffer))))))
3248
3249 (defun gnus-summary-setup-buffer (group)
3250 "Initialize summary buffer."
3251 (let ((buffer (gnus-summary-buffer-name group))
3252 (dead-name (concat "*Dead Summary "
3253 (gnus-group-decoded-name group) "*")))
3254 ;; If a dead summary buffer exists, we kill it.
3255 (when (gnus-buffer-live-p dead-name)
3256 (gnus-kill-buffer dead-name))
3257 (if (get-buffer buffer)
3258 (progn
3259 (set-buffer buffer)
3260 (setq gnus-summary-buffer (current-buffer))
3261 (not gnus-newsgroup-prepared))
3262 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3263 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3264 (gnus-summary-mode group)
3265 (when gnus-carpal
3266 (gnus-carpal-setup-buffer 'summary))
3267 (unless gnus-single-article-buffer
3268 (make-local-variable 'gnus-article-buffer)
3269 (make-local-variable 'gnus-article-current)
3270 (make-local-variable 'gnus-original-article-buffer))
3271 (setq gnus-newsgroup-name group)
3272 ;; Set any local variables in the group parameters.
3273 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3274 t)))
3275
3276 (defun gnus-set-global-variables ()
3277 "Set the global equivalents of the buffer-local variables.
3278 They are set to the latest values they had. These reflect the summary
3279 buffer that was in action when the last article was fetched."
3280 (when (eq major-mode 'gnus-summary-mode)
3281 (setq gnus-summary-buffer (current-buffer))
3282 (let ((name gnus-newsgroup-name)
3283 (marked gnus-newsgroup-marked)
3284 (spam gnus-newsgroup-spam-marked)
3285 (unread gnus-newsgroup-unreads)
3286 (headers gnus-current-headers)
3287 (data gnus-newsgroup-data)
3288 (summary gnus-summary-buffer)
3289 (article-buffer gnus-article-buffer)
3290 (original gnus-original-article-buffer)
3291 (gac gnus-article-current)
3292 (reffed gnus-reffed-article-number)
3293 (score-file gnus-current-score-file)
3294 (default-charset gnus-newsgroup-charset)
3295 vlist)
3296 (let ((locals gnus-newsgroup-variables))
3297 (while locals
3298 (if (consp (car locals))
3299 (push (eval (caar locals)) vlist)
3300 (push (eval (car locals)) vlist))
3301 (setq locals (cdr locals)))
3302 (setq vlist (nreverse vlist)))
3303 (save-excursion
3304 (set-buffer gnus-group-buffer)
3305 (setq gnus-newsgroup-name name
3306 gnus-newsgroup-marked marked
3307 gnus-newsgroup-spam-marked spam
3308 gnus-newsgroup-unreads unread
3309 gnus-current-headers headers
3310 gnus-newsgroup-data data
3311 gnus-article-current gac
3312 gnus-summary-buffer summary
3313 gnus-article-buffer article-buffer
3314 gnus-original-article-buffer original
3315 gnus-reffed-article-number reffed
3316 gnus-current-score-file score-file
3317 gnus-newsgroup-charset default-charset)
3318 (let ((locals gnus-newsgroup-variables))
3319 (while locals
3320 (if (consp (car locals))
3321 (set (caar locals) (pop vlist))
3322 (set (car locals) (pop vlist)))
3323 (setq locals (cdr locals))))
3324 ;; The article buffer also has local variables.
3325 (when (gnus-buffer-live-p gnus-article-buffer)
3326 (set-buffer gnus-article-buffer)
3327 (setq gnus-summary-buffer summary))))))
3328
3329 (defun gnus-summary-article-unread-p (article)
3330 "Say whether ARTICLE is unread or not."
3331 (memq article gnus-newsgroup-unreads))
3332
3333 (defun gnus-summary-first-article-p (&optional article)
3334 "Return whether ARTICLE is the first article in the buffer."
3335 (if (not (setq article (or article (gnus-summary-article-number))))
3336 nil
3337 (eq article (caar gnus-newsgroup-data))))
3338
3339 (defun gnus-summary-last-article-p (&optional article)
3340 "Return whether ARTICLE is the last article in the buffer."
3341 (if (not (setq article (or article (gnus-summary-article-number))))
3342 ;; All non-existent numbers are the last article. :-)
3343 t
3344 (not (cdr (gnus-data-find-list article)))))
3345
3346 (defun gnus-make-thread-indent-array (&optional n)
3347 (when (or n
3348 (progn (setq n 200) nil)
3349 (null gnus-thread-indent-array)
3350 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3351 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3352 gnus-thread-indent-array-level gnus-thread-indent-level)
3353 (while (>= n 0)
3354 (aset gnus-thread-indent-array n
3355 (make-string (* n gnus-thread-indent-level) ? ))
3356 (setq n (1- n)))))
3357
3358 (defun gnus-update-summary-mark-positions ()
3359 "Compute where the summary marks are to go."
3360 (save-excursion
3361 (when (gnus-buffer-exists-p gnus-summary-buffer)
3362 (set-buffer gnus-summary-buffer))
3363 (let ((spec gnus-summary-line-format-spec)
3364 pos)
3365 (save-excursion
3366 (gnus-set-work-buffer)
3367 (let ((gnus-tmp-unread ?Z)
3368 (gnus-replied-mark ?Z)
3369 (gnus-score-below-mark ?Z)
3370 (gnus-score-over-mark ?Z)
3371 (gnus-undownloaded-mark ?Z)
3372 (gnus-summary-line-format-spec spec)
3373 (gnus-newsgroup-downloadable '(0))
3374 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3375 case-fold-search ignores)
3376 ;; Here, all marks are bound to Z.
3377 (gnus-summary-insert-line header
3378 0 nil t gnus-tmp-unread t nil "" nil 1)
3379 (goto-char (point-min))
3380 ;; Memorize the positions of the same characters as dummy marks.
3381 (while (re-search-forward "[A-D]" nil t)
3382 (push (point) ignores))
3383 (erase-buffer)
3384 ;; We use A-D as dummy marks in order to know column positions
3385 ;; where marks should be inserted.
3386 (setq gnus-tmp-unread ?A
3387 gnus-replied-mark ?B
3388 gnus-score-below-mark ?C
3389 gnus-score-over-mark ?C
3390 gnus-undownloaded-mark ?D)
3391 (gnus-summary-insert-line header
3392 0 nil t gnus-tmp-unread t nil "" nil 1)
3393 ;; Ignore characters which aren't dummy marks.
3394 (dolist (p ignores)
3395 (delete-region (goto-char (1- p)) p)
3396 (insert ?Z))
3397 (goto-char (point-min))
3398 (setq pos (list (cons 'unread
3399 (and (search-forward "A" nil t)
3400 (- (point) (point-min) 1)))))
3401 (goto-char (point-min))
3402 (push (cons 'replied (and (search-forward "B" nil t)
3403 (- (point) (point-min) 1)))
3404 pos)
3405 (goto-char (point-min))
3406 (push (cons 'score (and (search-forward "C" nil t)
3407 (- (point) (point-min) 1)))
3408 pos)
3409 (goto-char (point-min))
3410 (push (cons 'download (and (search-forward "D" nil t)
3411 (- (point) (point-min) 1)))
3412 pos)))
3413 (setq gnus-summary-mark-positions pos))))
3414
3415 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3416 "Insert a dummy root in the summary buffer."
3417 (beginning-of-line)
3418 (gnus-add-text-properties
3419 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3420 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3421
3422 (defun gnus-summary-extract-address-component (from)
3423 (or (car (funcall gnus-extract-address-components from))
3424 from))
3425
3426 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3427 (let ((mail-parse-charset gnus-newsgroup-charset)
3428 ; Is it really necessary to do this next part for each summary line?
3429 ; Luckily, doesn't seem to slow things down much.
3430 (mail-parse-ignored-charsets
3431 (save-excursion (set-buffer gnus-summary-buffer)
3432 gnus-newsgroup-ignored-charsets)))
3433 (or
3434 (and gnus-ignored-from-addresses
3435 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3436 (let ((extra-headers (mail-header-extra header))
3437 to
3438 newsgroups)
3439 (cond
3440 ((setq to (cdr (assq 'To extra-headers)))
3441 (concat "-> "
3442 (inline
3443 (gnus-summary-extract-address-component
3444 (funcall gnus-decode-encoded-address-function to)))))
3445 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3446 (concat "=> " newsgroups)))))
3447 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3448
3449 (defun gnus-summary-insert-line (gnus-tmp-header
3450 gnus-tmp-level gnus-tmp-current
3451 undownloaded gnus-tmp-unread gnus-tmp-replied
3452 gnus-tmp-expirable gnus-tmp-subject-or-nil
3453 &optional gnus-tmp-dummy gnus-tmp-score
3454 gnus-tmp-process)
3455 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3456 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3457 gnus-tmp-level)))
3458 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3459 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3460 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3461 (gnus-tmp-score-char
3462 (if (or (null gnus-summary-default-score)
3463 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3464 gnus-summary-zcore-fuzz))
3465 ? ;Whitespace
3466 (if (< gnus-tmp-score gnus-summary-default-score)
3467 gnus-score-below-mark gnus-score-over-mark)))
3468 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3469 (gnus-tmp-replied
3470 (cond (gnus-tmp-process gnus-process-mark)
3471 ((memq gnus-tmp-current gnus-newsgroup-cached)
3472 gnus-cached-mark)
3473 (gnus-tmp-replied gnus-replied-mark)
3474 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3475 gnus-forwarded-mark)
3476 ((memq gnus-tmp-current gnus-newsgroup-saved)
3477 gnus-saved-mark)
3478 ((memq gnus-tmp-number gnus-newsgroup-recent)
3479 gnus-recent-mark)
3480 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3481 gnus-unseen-mark)
3482 (t gnus-no-mark)))
3483 (gnus-tmp-downloaded
3484 (cond (undownloaded
3485 gnus-undownloaded-mark)
3486 (gnus-newsgroup-agentized
3487 gnus-downloaded-mark)
3488 (t
3489 gnus-no-mark)))
3490 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3491 (gnus-tmp-name
3492 (cond
3493 ((string-match "<[^>]+> *$" gnus-tmp-from)
3494 (let ((beg (match-beginning 0)))
3495 (or (and (string-match "^\".+\"" gnus-tmp-from)
3496 (substring gnus-tmp-from 1 (1- (match-end 0))))
3497 (substring gnus-tmp-from 0 beg))))
3498 ((string-match "(.+)" gnus-tmp-from)
3499 (substring gnus-tmp-from
3500 (1+ (match-beginning 0)) (1- (match-end 0))))
3501 (t gnus-tmp-from)))
3502 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3503 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3504 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3505 (buffer-read-only nil))
3506 (when (string= gnus-tmp-name "")
3507 (setq gnus-tmp-name gnus-tmp-from))
3508 (unless (numberp gnus-tmp-lines)
3509 (setq gnus-tmp-lines -1))
3510 (if (= gnus-tmp-lines -1)
3511 (setq gnus-tmp-lines "?")
3512 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3513 (gnus-put-text-property
3514 (point)
3515 (progn (eval gnus-summary-line-format-spec) (point))
3516 'gnus-number gnus-tmp-number)
3517 (when (gnus-visual-p 'summary-highlight 'highlight)
3518 (forward-line -1)
3519 (gnus-run-hooks 'gnus-summary-update-hook)
3520 (forward-line 1))))
3521
3522 (defun gnus-summary-update-line (&optional dont-update)
3523 "Update summary line after change."
3524 (when (and gnus-summary-default-score
3525 (not gnus-summary-inhibit-highlight))
3526 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3527 (article (gnus-summary-article-number))
3528 (score (gnus-summary-article-score article)))
3529 (unless dont-update
3530 (if (and gnus-summary-mark-below
3531 (< (gnus-summary-article-score)
3532 gnus-summary-mark-below))
3533 ;; This article has a low score, so we mark it as read.
3534 (when (memq article gnus-newsgroup-unreads)
3535 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3536 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3537 ;; This article was previously marked as read on account
3538 ;; of a low score, but now it has risen, so we mark it as
3539 ;; unread.
3540 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3541 (gnus-summary-update-mark
3542 (if (or (null gnus-summary-default-score)
3543 (<= (abs (- score gnus-summary-default-score))
3544 gnus-summary-zcore-fuzz))
3545 ? ;Whitespace
3546 (if (< score gnus-summary-default-score)
3547 gnus-score-below-mark gnus-score-over-mark))
3548 'score))
3549 ;; Do visual highlighting.
3550 (when (gnus-visual-p 'summary-highlight 'highlight)
3551 (gnus-run-hooks 'gnus-summary-update-hook)))))
3552
3553 (defvar gnus-tmp-new-adopts nil)
3554
3555 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3556 "Return the number of articles in THREAD.
3557 This may be 0 in some cases -- if none of the articles in
3558 the thread are to be displayed."
3559 (let* ((number
3560 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3561 (cond
3562 ((not (listp thread))
3563 1)
3564 ((and (consp thread) (cdr thread))
3565 (apply
3566 '+ 1 (mapcar
3567 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3568 ((null thread)
3569 1)
3570 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3571 1)
3572 (t 0))))
3573 (when (and level (zerop level) gnus-tmp-new-adopts)
3574 (incf number
3575 (apply '+ (mapcar
3576 'gnus-summary-number-of-articles-in-thread
3577 gnus-tmp-new-adopts))))
3578 (if char
3579 (if (> number 1) gnus-not-empty-thread-mark
3580 gnus-empty-thread-mark)
3581 number)))
3582
3583 (defsubst gnus-summary-line-message-size (head)
3584 "Return pretty-printed version of message size.
3585 This function is intended to be used in
3586 `gnus-summary-line-format-alist'."
3587 (let ((c (or (mail-header-chars head) -1)))
3588 (cond ((< c 0) "n/a") ; chars not available
3589 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3590 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3591 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3592 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3593
3594
3595 (defun gnus-summary-set-local-parameters (group)
3596 "Go through the local params of GROUP and set all variable specs in that list."
3597 (let ((params (gnus-group-find-parameter group))
3598 (vars '(quit-config)) ; Ignore quit-config.
3599 elem)
3600 (while params
3601 (setq elem (car params)
3602 params (cdr params))
3603 (and (consp elem) ; Has to be a cons.
3604 (consp (cdr elem)) ; The cdr has to be a list.
3605 (symbolp (car elem)) ; Has to be a symbol in there.
3606 (not (memq (car elem) vars))
3607 (ignore-errors ; So we set it.
3608 (push (car elem) vars)
3609 (make-local-variable (car elem))
3610 (set (car elem) (eval (nth 1 elem))))))))
3611
3612 (defun gnus-summary-read-group (group &optional show-all no-article
3613 kill-buffer no-display backward
3614 select-articles)
3615 "Start reading news in newsgroup GROUP.
3616 If SHOW-ALL is non-nil, already read articles are also listed.
3617 If NO-ARTICLE is non-nil, no article is selected initially.
3618 If NO-DISPLAY, don't generate a summary buffer."
3619 (let (result)
3620 (while (and group
3621 (null (setq result
3622 (let ((gnus-auto-select-next nil))
3623 (or (gnus-summary-read-group-1
3624 group show-all no-article
3625 kill-buffer no-display
3626 select-articles)
3627 (setq show-all nil
3628 select-articles nil)))))
3629 (eq gnus-auto-select-next 'quietly))
3630 (set-buffer gnus-group-buffer)
3631 ;; The entry function called above goes to the next
3632 ;; group automatically, so we go two groups back
3633 ;; if we are searching for the previous group.
3634 (when backward
3635 (gnus-group-prev-unread-group 2))
3636 (if (not (equal group (gnus-group-group-name)))
3637 (setq group (gnus-group-group-name))
3638 (setq group nil)))
3639 result))
3640
3641 (defun gnus-summary-read-group-1 (group show-all no-article
3642 kill-buffer no-display
3643 &optional select-articles)
3644 ;; Killed foreign groups can't be entered.
3645 ;; (when (and (not (gnus-group-native-p group))
3646 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3647 ;; (error "Dead non-native groups can't be entered"))
3648 (gnus-message 5 "Retrieving newsgroup: %s..."
3649 (gnus-group-decoded-name group))
3650 (let* ((new-group (gnus-summary-setup-buffer group))
3651 (quit-config (gnus-group-quit-config group))
3652 (did-select (and new-group (gnus-select-newsgroup
3653 group show-all select-articles))))
3654 (cond
3655 ;; This summary buffer exists already, so we just select it.
3656 ((not new-group)
3657 (gnus-set-global-variables)
3658 (when kill-buffer
3659 (gnus-kill-or-deaden-summary kill-buffer))
3660 (gnus-configure-windows 'summary 'force)
3661 (gnus-set-mode-line 'summary)
3662 (gnus-summary-position-point)
3663 (message "")
3664 t)
3665 ;; We couldn't select this group.
3666 ((null did-select)
3667 (when (and (eq major-mode 'gnus-summary-mode)
3668 (not (equal (current-buffer) kill-buffer)))
3669 (kill-buffer (current-buffer))
3670 (if (not quit-config)
3671 (progn
3672 ;; Update the info -- marks might need to be removed,
3673 ;; for instance.
3674 (gnus-summary-update-info)
3675 (set-buffer gnus-group-buffer)
3676 (gnus-group-jump-to-group group)
3677 (gnus-group-next-unread-group 1))
3678 (gnus-handle-ephemeral-exit quit-config)))
3679 (let ((grpinfo (gnus-get-info group)))
3680 (if (null (gnus-info-read grpinfo))
3681 (gnus-message 3 "Group %s contains no messages"
3682 (gnus-group-decoded-name group))
3683 (gnus-message 3 "Can't select group")))
3684 nil)
3685 ;; The user did a `C-g' while prompting for number of articles,
3686 ;; so we exit this group.
3687 ((eq did-select 'quit)
3688 (and (eq major-mode 'gnus-summary-mode)
3689 (not (equal (current-buffer) kill-buffer))
3690 (kill-buffer (current-buffer)))
3691 (when kill-buffer
3692 (gnus-kill-or-deaden-summary kill-buffer))
3693 (if (not quit-config)
3694 (progn
3695 (set-buffer gnus-group-buffer)
3696 (gnus-group-jump-to-group group)
3697 (gnus-group-next-unread-group 1)
3698 (gnus-configure-windows 'group 'force))
3699 (gnus-handle-ephemeral-exit quit-config))
3700 ;; Finally signal the quit.
3701 (signal 'quit nil))
3702 ;; The group was successfully selected.
3703 (t
3704 (gnus-set-global-variables)
3705 ;; Save the active value in effect when the group was entered.
3706 (setq gnus-newsgroup-active
3707 (gnus-copy-sequence
3708 (gnus-active gnus-newsgroup-name)))
3709 ;; You can change the summary buffer in some way with this hook.
3710 (gnus-run-hooks 'gnus-select-group-hook)
3711 (when (memq 'summary (gnus-update-format-specifications
3712 nil 'summary 'summary-mode 'summary-dummy))
3713 ;; The format specification for the summary line was updated,
3714 ;; so we need to update the mark positions as well.
3715 (gnus-update-summary-mark-positions))
3716 ;; Do score processing.
3717 (when gnus-use-scoring
3718 (gnus-possibly-score-headers))
3719 ;; Check whether to fill in the gaps in the threads.
3720 (when gnus-build-sparse-threads
3721 (gnus-build-sparse-threads))
3722 ;; Find the initial limit.
3723 (if show-all
3724 (let ((gnus-newsgroup-dormant nil))
3725 (gnus-summary-initial-limit show-all))
3726 (gnus-summary-initial-limit show-all))
3727 ;; Generate the summary buffer.
3728 (unless no-display
3729 (gnus-summary-prepare))
3730 (when gnus-use-trees
3731 (gnus-tree-open group)
3732 (setq gnus-summary-highlight-line-function
3733 'gnus-tree-highlight-article))
3734 ;; If the summary buffer is empty, but there are some low-scored
3735 ;; articles or some excluded dormants, we include these in the
3736 ;; buffer.
3737 (when (and (zerop (buffer-size))
3738 (not no-display))
3739 (cond (gnus-newsgroup-dormant
3740 (gnus-summary-limit-include-dormant))
3741 ((and gnus-newsgroup-scored show-all)
3742 (gnus-summary-limit-include-expunged t))))
3743 ;; Function `gnus-apply-kill-file' must be called in this hook.
3744 (gnus-run-hooks 'gnus-apply-kill-hook)
3745 (if (and (zerop (buffer-size))
3746 (not no-display))
3747 (progn
3748 ;; This newsgroup is empty.
3749 (gnus-summary-catchup-and-exit nil t)
3750 (gnus-message 6 "No unread news")
3751 (when kill-buffer
3752 (gnus-kill-or-deaden-summary kill-buffer))
3753 ;; Return nil from this function.
3754 nil)
3755 ;; Hide conversation thread subtrees. We cannot do this in
3756 ;; gnus-summary-prepare-hook since kill processing may not
3757 ;; work with hidden articles.
3758 (gnus-summary-maybe-hide-threads)
3759 (when kill-buffer
3760 (gnus-kill-or-deaden-summary kill-buffer))
3761 (gnus-summary-auto-select-subject)
3762 ;; Show first unread article if requested.
3763 (if (and (not no-article)
3764 (not no-display)
3765 gnus-newsgroup-unreads
3766 gnus-auto-select-first)
3767 (progn
3768 (gnus-configure-windows 'summary)
3769 (let ((art (gnus-summary-article-number)))
3770 (unless (and (not gnus-plugged)
3771 (or (memq art gnus-newsgroup-undownloaded)
3772 (memq art gnus-newsgroup-downloadable)))
3773 (gnus-summary-goto-article art))))
3774 ;; Don't select any articles.
3775 (gnus-summary-position-point)
3776 (gnus-configure-windows 'summary 'force)
3777 (gnus-set-mode-line 'summary))
3778 (when (and gnus-auto-center-group
3779 (get-buffer-window gnus-group-buffer t))
3780 ;; Gotta use windows, because recenter does weird stuff if
3781 ;; the current buffer ain't the displayed window.
3782 (let ((owin (selected-window)))
3783 (select-window (get-buffer-window gnus-group-buffer t))
3784 (when (gnus-group-goto-group group)
3785 (recenter))
3786 (select-window owin)))
3787 ;; Mark this buffer as "prepared".
3788 (setq gnus-newsgroup-prepared t)
3789 (gnus-run-hooks 'gnus-summary-prepared-hook)
3790 (unless (gnus-ephemeral-group-p group)
3791 (gnus-group-update-group group))
3792 t)))))
3793
3794 (defun gnus-summary-auto-select-subject ()
3795 "Select the subject line on initial group entry."
3796 (goto-char (point-min))
3797 (cond
3798 ((eq gnus-auto-select-subject 'best)
3799 (gnus-summary-best-unread-subject))
3800 ((eq gnus-auto-select-subject 'unread)
3801 (gnus-summary-first-unread-subject))
3802 ((eq gnus-auto-select-subject 'unseen)
3803 (gnus-summary-first-unseen-subject))
3804 ((eq gnus-auto-select-subject 'unseen-or-unread)
3805 (gnus-summary-first-unseen-or-unread-subject))
3806 ((eq gnus-auto-select-subject 'first)
3807 ;; Do nothing.
3808 )
3809 ((functionp gnus-auto-select-subject)
3810 (funcall gnus-auto-select-subject))))
3811
3812 (defun gnus-summary-prepare ()
3813 "Generate the summary buffer."
3814 (interactive)
3815 (let ((buffer-read-only nil))
3816 (erase-buffer)
3817 (setq gnus-newsgroup-data nil
3818 gnus-newsgroup-data-reverse nil)
3819 (gnus-run-hooks 'gnus-summary-generate-hook)
3820 ;; Generate the buffer, either with threads or without.
3821 (when gnus-newsgroup-headers
3822 (gnus-summary-prepare-threads
3823 (if gnus-show-threads
3824 (gnus-sort-gathered-threads
3825 (funcall gnus-summary-thread-gathering-function
3826 (gnus-sort-threads
3827 (gnus-cut-threads (gnus-make-threads)))))
3828 ;; Unthreaded display.
3829 (gnus-sort-articles gnus-newsgroup-headers))))
3830 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3831 ;; Call hooks for modifying summary buffer.
3832 (goto-char (point-min))
3833 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3834
3835 (defsubst gnus-general-simplify-subject (subject)
3836 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3837 (setq subject
3838 (cond
3839 ;; Truncate the subject.
3840 (gnus-simplify-subject-functions
3841 (gnus-map-function gnus-simplify-subject-functions subject))
3842 ((numberp gnus-summary-gather-subject-limit)
3843 (setq subject (gnus-simplify-subject-re subject))
3844 (if (> (length subject) gnus-summary-gather-subject-limit)
3845 (substring subject 0 gnus-summary-gather-subject-limit)
3846 subject))
3847 ;; Fuzzily simplify it.
3848 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3849 (gnus-simplify-subject-fuzzy subject))
3850 ;; Just remove the leading "Re:".
3851 (t
3852 (gnus-simplify-subject-re subject))))
3853
3854 (if (and gnus-summary-gather-exclude-subject
3855 (string-match gnus-summary-gather-exclude-subject subject))
3856 nil ; This article shouldn't be gathered
3857 subject))
3858
3859 (defun gnus-summary-simplify-subject-query ()
3860 "Query where the respool algorithm would put this article."
3861 (interactive)
3862 (gnus-summary-select-article)
3863 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3864
3865 (defun gnus-gather-threads-by-subject (threads)
3866 "Gather threads by looking at Subject headers."
3867 (if (not gnus-summary-make-false-root)
3868 threads
3869 (let ((hashtb (gnus-make-hashtable 1024))
3870 (prev threads)
3871 (result threads)
3872 subject hthread whole-subject)
3873 (while threads
3874 (setq subject (gnus-general-simplify-subject
3875 (setq whole-subject (mail-header-subject
3876 (caar threads)))))
3877 (when subject
3878 (if (setq hthread (gnus-gethash subject hashtb))
3879 (progn
3880 ;; We enter a dummy root into the thread, if we
3881 ;; haven't done that already.
3882 (unless (stringp (caar hthread))
3883 (setcar hthread (list whole-subject (car hthread))))
3884 ;; We add this new gathered thread to this gathered
3885 ;; thread.
3886 (setcdr (car hthread)
3887 (nconc (cdar hthread) (list (car threads))))
3888 ;; Remove it from the list of threads.
3889 (setcdr prev (cdr threads))
3890 (setq threads prev))
3891 ;; Enter this thread into the hash table.
3892 (gnus-sethash subject
3893 (if gnus-summary-make-false-root-always
3894 (progn
3895 ;; If you want a dummy root above all
3896 ;; threads...
3897 (setcar threads (list whole-subject
3898 (car threads)))
3899 threads)
3900 threads)
3901 hashtb)))
3902 (setq prev threads)
3903 (setq threads (cdr threads)))
3904 result)))
3905
3906 (defun gnus-gather-threads-by-references (threads)
3907 "Gather threads by looking at References headers."
3908 (let ((idhashtb (gnus-make-hashtable 1024))
3909 (thhashtb (gnus-make-hashtable 1024))
3910 (prev threads)
3911 (result threads)
3912 ids references id gthread gid entered ref)
3913 (while threads
3914 (when (setq references (mail-header-references (caar threads)))
3915 (setq id (mail-header-id (caar threads))
3916 ids (inline (gnus-split-references references))
3917 entered nil)
3918 (while (setq ref (pop ids))
3919 (setq ids (delete ref ids))
3920 (if (not (setq gid (gnus-gethash ref idhashtb)))
3921 (progn
3922 (gnus-sethash ref id idhashtb)
3923 (gnus-sethash id threads thhashtb))
3924 (setq gthread (gnus-gethash gid thhashtb))
3925 (unless entered
3926 ;; We enter a dummy root into the thread, if we
3927 ;; haven't done that already.
3928 (unless (stringp (caar gthread))
3929 (setcar gthread (list (mail-header-subject (caar gthread))
3930 (car gthread))))
3931 ;; We add this new gathered thread to this gathered
3932 ;; thread.
3933 (setcdr (car gthread)
3934 (nconc (cdar gthread) (list (car threads)))))
3935 ;; Add it into the thread hash table.
3936 (gnus-sethash id gthread thhashtb)
3937 (setq entered t)
3938 ;; Remove it from the list of threads.
3939 (setcdr prev (cdr threads))
3940 (setq threads prev))))
3941 (setq prev threads)
3942 (setq threads (cdr threads)))
3943 result))
3944
3945 (defun gnus-sort-gathered-threads (threads)
3946 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3947 (let ((result threads))
3948 (while threads
3949 (when (stringp (caar threads))
3950 (setcdr (car threads)
3951 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3952 (setq threads (cdr threads)))
3953 result))
3954
3955 (defun gnus-thread-loop-p (root thread)
3956 "Say whether ROOT is in THREAD."
3957 (let ((stack (list thread))
3958 (infloop 0)
3959 th)
3960 (while (setq thread (pop stack))
3961 (setq th (cdr thread))
3962 (while (and th
3963 (not (eq (caar th) root)))
3964 (pop th))
3965 (if th
3966 ;; We have found a loop.
3967 (let (ref-dep)
3968 (setcdr thread (delq (car th) (cdr thread)))
3969 (if (boundp (setq ref-dep (intern "none"
3970 gnus-newsgroup-dependencies)))
3971 (setcdr (symbol-value ref-dep)
3972 (nconc (cdr (symbol-value ref-dep))
3973 (list (car th))))
3974 (set ref-dep (list nil (car th))))
3975 (setq infloop 1
3976 stack nil))
3977 ;; Push all the subthreads onto the stack.
3978 (push (cdr thread) stack)))
3979 infloop))
3980
3981 (defun gnus-make-threads ()
3982 "Go through the dependency hashtb and find the roots. Return all threads."
3983 (let (threads)
3984 (while (catch 'infloop
3985 (mapatoms
3986 (lambda (refs)
3987 ;; Deal with self-referencing References loops.
3988 (when (and (car (symbol-value refs))
3989 (not (zerop
3990 (apply
3991 '+
3992 (mapcar
3993 (lambda (thread)
3994 (gnus-thread-loop-p
3995 (car (symbol-value refs)) thread))
3996 (cdr (symbol-value refs)))))))
3997 (setq threads nil)
3998 (throw 'infloop t))
3999 (unless (car (symbol-value refs))
4000 ;; These threads do not refer back to any other
4001 ;; articles, so they're roots.
4002 (setq threads (append (cdr (symbol-value refs)) threads))))
4003 gnus-newsgroup-dependencies)))
4004 threads))
4005
4006 ;; Build the thread tree.
4007 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4008 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4009
4010 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4011 if it was already present.
4012
4013 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4014 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4015 Message-IDs will be renamed to a unique Message-ID before being
4016 entered.
4017
4018 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4019 (let* ((id (mail-header-id header))
4020 (id-dep (and id (intern id dependencies)))
4021 parent-id ref ref-dep ref-header replaced)
4022 ;; Enter this `header' in the `dependencies' table.
4023 (cond
4024 ((not id-dep)
4025 (setq header nil))
4026 ;; The first two cases do the normal part: enter a new `header'
4027 ;; in the `dependencies' table.
4028 ((not (boundp id-dep))
4029 (set id-dep (list header)))
4030 ((null (car (symbol-value id-dep)))
4031 (setcar (symbol-value id-dep) header))
4032
4033 ;; From here the `header' was already present in the
4034 ;; `dependencies' table.
4035 (force-new
4036 ;; Overrides an existing entry;
4037 ;; just set the header part of the entry.
4038 (setcar (symbol-value id-dep) header)
4039 (setq replaced t))
4040
4041 ;; Renames the existing `header' to a unique Message-ID.
4042 ((not gnus-summary-ignore-duplicates)
4043 ;; An article with this Message-ID has already been seen.
4044 ;; We rename the Message-ID.
4045 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4046 (list header))
4047 (mail-header-set-id header id))
4048
4049 ;; The last case ignores an existing entry, except it adds any
4050 ;; additional Xrefs (in case the two articles came from different
4051 ;; servers.
4052 ;; Also sets `header' to `nil' meaning that the `dependencies'
4053 ;; table was *not* modified.
4054 (t
4055 (mail-header-set-xref
4056 (car (symbol-value id-dep))
4057 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4058 "")
4059 (or (mail-header-xref header) "")))
4060 (setq header nil)))
4061
4062 (when (and header (not replaced))
4063 ;; First check that we are not creating a References loop.
4064 (setq parent-id (gnus-parent-id (mail-header-references header)))
4065 (setq ref parent-id)
4066 (while (and ref
4067 (setq ref-dep (intern-soft ref dependencies))
4068 (boundp ref-dep)
4069 (setq ref-header (car (symbol-value ref-dep))))
4070 (if (string= id ref)
4071 ;; Yuk! This is a reference loop. Make the article be a
4072 ;; root article.
4073 (progn
4074 (mail-header-set-references (car (symbol-value id-dep)) "none")
4075 (setq ref nil)
4076 (setq parent-id nil))
4077 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4078 (setq ref-dep (intern (or parent-id "none") dependencies))
4079 (if (boundp ref-dep)
4080 (setcdr (symbol-value ref-dep)
4081 (nconc (cdr (symbol-value ref-dep))
4082 (list (symbol-value id-dep))))
4083 (set ref-dep (list nil (symbol-value id-dep)))))
4084 header))
4085
4086 (defun gnus-extract-message-id-from-in-reply-to (string)
4087 (if (string-match "<[^>]+>" string)
4088 (substring string (match-beginning 0) (match-end 0))
4089 nil))
4090
4091 (defun gnus-build-sparse-threads ()
4092 (let ((headers gnus-newsgroup-headers)
4093 (mail-parse-charset gnus-newsgroup-charset)
4094 (gnus-summary-ignore-duplicates t)
4095 header references generation relations
4096 subject child end new-child date)
4097 ;; First we create an alist of generations/relations, where
4098 ;; generations is how much we trust the relation, and the relation
4099 ;; is parent/child.
4100 (gnus-message 7 "Making sparse threads...")
4101 (save-excursion
4102 (nnheader-set-temp-buffer " *gnus sparse threads*")
4103 (while (setq header (pop headers))
4104 (when (and (setq references (mail-header-references header))
4105 (not (string= references "")))
4106 (insert references)
4107 (setq child (mail-header-id header)
4108 subject (mail-header-subject header)
4109 date (mail-header-date header)
4110 generation 0)
4111 (while (search-backward ">" nil t)
4112 (setq end (1+ (point)))
4113 (when (search-backward "<" nil t)
4114 (setq new-child (buffer-substring (point) end))
4115 (push (list (incf generation)
4116 child (setq child new-child)
4117 subject date)
4118 relations)))
4119 (when child
4120 (push (list (1+ generation) child nil subject) relations))
4121 (erase-buffer)))
4122 (kill-buffer (current-buffer)))
4123 ;; Sort over trustworthiness.
4124 (mapcar
4125 (lambda (relation)
4126 (when (gnus-dependencies-add-header
4127 (make-full-mail-header
4128 gnus-reffed-article-number
4129 (nth 3 relation) "" (or (nth 4 relation) "")
4130 (nth 1 relation)
4131 (or (nth 2 relation) "") 0 0 "")
4132 gnus-newsgroup-dependencies nil)
4133 (push gnus-reffed-article-number gnus-newsgroup-limit)
4134 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4135 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4136 gnus-newsgroup-reads)
4137 (decf gnus-reffed-article-number)))
4138 (sort relations 'car-less-than-car))
4139 (gnus-message 7 "Making sparse threads...done")))
4140
4141 (defun gnus-build-old-threads ()
4142 ;; Look at all the articles that refer back to old articles, and
4143 ;; fetch the headers for the articles that aren't there. This will
4144 ;; build complete threads - if the roots haven't been expired by the
4145 ;; server, that is.
4146 (let ((mail-parse-charset gnus-newsgroup-charset)
4147 id heads)
4148 (mapatoms
4149 (lambda (refs)
4150 (when (not (car (symbol-value refs)))
4151 (setq heads (cdr (symbol-value refs)))
4152 (while heads
4153 (if (memq (mail-header-number (caar heads))
4154 gnus-newsgroup-dormant)
4155 (setq heads (cdr heads))
4156 (setq id (symbol-name refs))
4157 (while (and (setq id (gnus-build-get-header id))
4158 (not (car (gnus-id-to-thread id)))))
4159 (setq heads nil)))))
4160 gnus-newsgroup-dependencies)))
4161
4162 (defsubst gnus-remove-odd-characters (string)
4163 "Translate STRING into something that doesn't contain weird characters."
4164 (mm-subst-char-in-string
4165 ?\r ?\-
4166 (mm-subst-char-in-string
4167 ?\n ?\- string)))
4168
4169 ;; This function has to be called with point after the article number
4170 ;; on the beginning of the line.
4171 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4172 (let ((eol (gnus-point-at-eol))
4173 (buffer (current-buffer))
4174 header references in-reply-to)
4175
4176 ;; overview: [num subject from date id refs chars lines misc]
4177 (unwind-protect
4178 (let (x)
4179 (narrow-to-region (point) eol)
4180 (unless (eobp)
4181 (forward-char))
4182
4183 (setq header
4184 (make-full-mail-header
4185 number ; number
4186 (condition-case () ; subject
4187 (gnus-remove-odd-characters
4188 (funcall gnus-decode-encoded-word-function
4189 (setq x (nnheader-nov-field))))
4190 (error x))
4191 (condition-case () ; from
4192 (gnus-remove-odd-characters
4193 (funcall gnus-decode-encoded-address-function
4194 (setq x (nnheader-nov-field))))
4195 (error x))
4196 (nnheader-nov-field) ; date
4197 (nnheader-nov-read-message-id) ; id
4198 (setq references (nnheader-nov-field)) ; refs
4199 (nnheader-nov-read-integer) ; chars
4200 (nnheader-nov-read-integer) ; lines
4201 (unless (eobp)
4202 (if (looking-at "Xref: ")
4203 (goto-char (match-end 0)))
4204 (nnheader-nov-field)) ; Xref
4205 (nnheader-nov-parse-extra)))) ; extra
4206
4207 (widen))
4208
4209 (when (and (string= references "")
4210 (setq in-reply-to (mail-header-extra header))
4211 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4212 (mail-header-set-references
4213 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4214
4215 (when gnus-alter-header-function
4216 (funcall gnus-alter-header-function header))
4217 (gnus-dependencies-add-header header dependencies force-new)))
4218
4219 (defun gnus-build-get-header (id)
4220 "Look through the buffer of NOV lines and find the header to ID.
4221 Enter this line into the dependencies hash table, and return
4222 the id of the parent article (if any)."
4223 (let ((deps gnus-newsgroup-dependencies)
4224 found header)
4225 (prog1
4226 (save-excursion
4227 (set-buffer nntp-server-buffer)
4228 (let ((case-fold-search nil))
4229 (goto-char (point-min))
4230 (while (and (not found)
4231 (search-forward id nil t))
4232 (beginning-of-line)
4233 (setq found (looking-at
4234 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4235 (regexp-quote id))))
4236 (or found (beginning-of-line 2)))
4237 (when found
4238 (beginning-of-line)
4239 (and
4240 (setq header (gnus-nov-parse-line
4241 (read (current-buffer)) deps))
4242 (gnus-parent-id (mail-header-references header))))))
4243 (when header
4244 (let ((number (mail-header-number header)))
4245 (push number gnus-newsgroup-limit)
4246 (push header gnus-newsgroup-headers)
4247 (if (memq number gnus-newsgroup-unselected)
4248 (progn
4249 (setq gnus-newsgroup-unreads
4250 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4251 number))
4252 (setq gnus-newsgroup-unselected
4253 (delq number gnus-newsgroup-unselected)))
4254 (push number gnus-newsgroup-ancient)))))))
4255
4256 (defun gnus-build-all-threads ()
4257 "Read all the headers."
4258 (let ((gnus-summary-ignore-duplicates t)
4259 (mail-parse-charset gnus-newsgroup-charset)
4260 (dependencies gnus-newsgroup-dependencies)
4261 header article)
4262 (save-excursion
4263 (set-buffer nntp-server-buffer)
4264 (let ((case-fold-search nil))
4265 (goto-char (point-min))
4266 (while (not (eobp))
4267 (ignore-errors
4268 (setq article (read (current-buffer))
4269 header (gnus-nov-parse-line article dependencies)))
4270 (when header
4271 (save-excursion
4272 (set-buffer gnus-summary-buffer)
4273 (push header gnus-newsgroup-headers)
4274 (if (memq (setq article (mail-header-number header))
4275 gnus-newsgroup-unselected)
4276 (progn
4277 (setq gnus-newsgroup-unreads
4278 (gnus-add-to-sorted-list
4279 gnus-newsgroup-unreads article))
4280 (setq gnus-newsgroup-unselected
4281 (delq article gnus-newsgroup-unselected)))
4282 (push article gnus-newsgroup-ancient)))
4283 (forward-line 1)))))))
4284
4285 (defun gnus-summary-update-article-line (article header)
4286 "Update the line for ARTICLE using HEADER."
4287 (let* ((id (mail-header-id header))
4288 (thread (gnus-id-to-thread id)))
4289 (unless thread
4290 (error "Article in no thread"))
4291 ;; Update the thread.
4292 (setcar thread header)
4293 (gnus-summary-goto-subject article)
4294 (let* ((datal (gnus-data-find-list article))
4295 (data (car datal))
4296 (buffer-read-only nil)
4297 (level (gnus-summary-thread-level)))
4298 (gnus-delete-line)
4299 (let ((inserted (- (point)
4300 (progn
4301 (gnus-summary-insert-line
4302 header level nil
4303 (memq article gnus-newsgroup-undownloaded)
4304 (gnus-article-mark article)
4305 (memq article gnus-newsgroup-replied)
4306 (memq article gnus-newsgroup-expirable)
4307 ;; Only insert the Subject string when it's different
4308 ;; from the previous Subject string.
4309 (if (and
4310 gnus-show-threads
4311 (gnus-subject-equal
4312 (condition-case ()
4313 (mail-header-subject
4314 (gnus-data-header
4315 (cadr
4316 (gnus-data-find-list
4317 article
4318 (gnus-data-list t)))))
4319 ;; Error on the side of excessive subjects.
4320 (error ""))
4321 (mail-header-subject header)))
4322 ""
4323 (mail-header-subject header))
4324 nil (cdr (assq article gnus-newsgroup-scored))
4325 (memq article gnus-newsgroup-processable))
4326 (point)))))
4327 (when (cdr datal)
4328 (gnus-data-update-list
4329 (cdr datal)
4330 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4331
4332 (defun gnus-summary-update-article (article &optional iheader)
4333 "Update ARTICLE in the summary buffer."
4334 (set-buffer gnus-summary-buffer)
4335 (let* ((header (gnus-summary-article-header article))
4336 (id (mail-header-id header))
4337 (data (gnus-data-find article))
4338 (thread (gnus-id-to-thread id))
4339 (references (mail-header-references header))
4340 (parent
4341 (gnus-id-to-thread
4342 (or (gnus-parent-id
4343 (when (and references
4344 (not (equal "" references)))
4345 references))
4346 "none")))
4347 (buffer-read-only nil)
4348 (old (car thread)))
4349 (when thread
4350 (unless iheader
4351 (setcar thread nil)
4352 (when parent
4353 (delq thread parent)))
4354 (if (gnus-summary-insert-subject id header)
4355 ;; Set the (possibly) new article number in the data structure.
4356 (gnus-data-set-number data (gnus-id-to-article id))
4357 (setcar thread old)
4358 nil))))
4359
4360 (defun gnus-rebuild-thread (id &optional line)
4361 "Rebuild the thread containing ID.
4362 If LINE, insert the rebuilt thread starting on line LINE."
4363 (let ((buffer-read-only nil)
4364 old-pos current thread data)
4365 (if (not gnus-show-threads)
4366 (setq thread (list (car (gnus-id-to-thread id))))
4367 ;; Get the thread this article is part of.
4368 (setq thread (gnus-remove-thread id)))
4369 (setq old-pos (gnus-point-at-bol))
4370 (setq current (save-excursion
4371 (and (re-search-backward "[\r\n]" nil t)
4372 (gnus-summary-article-number))))
4373 ;; If this is a gathered thread, we have to go some re-gathering.
4374 (when (stringp (car thread))
4375 (let ((subject (car thread))
4376 roots thr)
4377 (setq thread (cdr thread))
4378 (while thread
4379 (unless (memq (setq thr (gnus-id-to-thread
4380 (gnus-root-id
4381 (mail-header-id (caar thread)))))
4382 roots)
4383 (push thr roots))
4384 (setq thread (cdr thread)))
4385 ;; We now have all (unique) roots.
4386 (if (= (length roots) 1)
4387 ;; All the loose roots are now one solid root.
4388 (setq thread (car roots))
4389 (setq thread (cons subject (gnus-sort-threads roots))))))
4390 (let (threads)
4391 ;; We then insert this thread into the summary buffer.
4392 (when line
4393 (goto-char (point-min))
4394 (forward-line (1- line)))
4395 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4396 (if gnus-show-threads
4397 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4398 (gnus-summary-prepare-unthreaded thread))
4399 (setq data (nreverse gnus-newsgroup-data))
4400 (setq threads gnus-newsgroup-threads))
4401 ;; We splice the new data into the data structure.
4402 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4403 ;;!!! then we want to insert at the beginning of the buffer.
4404 ;;!!! That happens to be true with Gnus now, but that may
4405 ;;!!! change in the future. Perhaps.
4406 (gnus-data-enter-list
4407 (if line nil current) data (- (point) old-pos))
4408 (setq gnus-newsgroup-threads
4409 (nconc threads gnus-newsgroup-threads))
4410 (gnus-data-compute-positions))))
4411
4412 (defun gnus-number-to-header (number)
4413 "Return the header for article NUMBER."
4414 (let ((headers gnus-newsgroup-headers))
4415 (while (and headers
4416 (not (= number (mail-header-number (car headers)))))
4417 (pop headers))
4418 (when headers
4419 (car headers))))
4420
4421 (defun gnus-parent-headers (in-headers &optional generation)
4422 "Return the headers of the GENERATIONeth parent of HEADERS."
4423 (unless generation
4424 (setq generation 1))
4425 (let ((parent t)
4426 (headers in-headers)
4427 references)
4428 (while (and parent
4429 (not (zerop generation))
4430 (setq references (mail-header-references headers)))
4431 (setq headers (if (and references
4432 (setq parent (gnus-parent-id references)))
4433 (car (gnus-id-to-thread parent))
4434 nil))
4435 (decf generation))
4436 (and (not (eq headers in-headers))
4437 headers)))
4438
4439 (defun gnus-id-to-thread (id)
4440 "Return the (sub-)thread where ID appears."
4441 (gnus-gethash id gnus-newsgroup-dependencies))
4442
4443 (defun gnus-id-to-article (id)
4444 "Return the article number of ID."
4445 (let ((thread (gnus-id-to-thread id)))
4446 (when (and thread
4447 (car thread))
4448 (mail-header-number (car thread)))))
4449
4450 (defun gnus-id-to-header (id)
4451 "Return the article headers of ID."
4452 (car (gnus-id-to-thread id)))
4453
4454 (defun gnus-article-displayed-root-p (article)
4455 "Say whether ARTICLE is a root(ish) article."
4456 (let ((level (gnus-summary-thread-level article))
4457 (refs (mail-header-references (gnus-summary-article-header article)))
4458 particle)
4459 (cond
4460 ((null level) nil)
4461 ((zerop level) t)
4462 ((null refs) t)
4463 ((null (gnus-parent-id refs)) t)
4464 ((and (= 1 level)
4465 (null (setq particle (gnus-id-to-article
4466 (gnus-parent-id refs))))
4467 (null (gnus-summary-thread-level particle)))))))
4468
4469 (defun gnus-root-id (id)
4470 "Return the id of the root of the thread where ID appears."
4471 (let (last-id prev)
4472 (while (and id (setq prev (car (gnus-id-to-thread id))))
4473 (setq last-id id
4474 id (gnus-parent-id (mail-header-references prev))))
4475 last-id))
4476
4477 (defun gnus-articles-in-thread (thread)
4478 "Return the list of articles in THREAD."
4479 (cons (mail-header-number (car thread))
4480 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4481
4482 (defun gnus-remove-thread (id &optional dont-remove)
4483 "Remove the thread that has ID in it."
4484 (let (headers thread last-id)
4485 ;; First go up in this thread until we find the root.
4486 (setq last-id (gnus-root-id id)
4487 headers (message-flatten-list (gnus-id-to-thread last-id)))
4488 ;; We have now found the real root of this thread. It might have
4489 ;; been gathered into some loose thread, so we have to search
4490 ;; through the threads to find the thread we wanted.
4491 (let ((threads gnus-newsgroup-threads)
4492 sub)
4493 (while threads
4494 (setq sub (car threads))
4495 (if (stringp (car sub))
4496 ;; This is a gathered thread, so we look at the roots
4497 ;; below it to find whether this article is in this
4498 ;; gathered root.
4499 (progn
4500 (setq sub (cdr sub))
4501 (while sub
4502 (when (member (caar sub) headers)
4503 (setq thread (car threads)
4504 threads nil
4505 sub nil))
4506 (setq sub (cdr sub))))
4507 ;; It's an ordinary thread, so we check it.
4508 (when (eq (car sub) (car headers))
4509 (setq thread sub
4510 threads nil)))
4511 (setq threads (cdr threads)))
4512 ;; If this article is in no thread, then it's a root.
4513 (if thread
4514 (unless dont-remove
4515 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4516 (setq thread (gnus-id-to-thread last-id)))
4517 (when thread
4518 (prog1
4519 thread ; We return this thread.
4520 (unless dont-remove
4521 (if (stringp (car thread))
4522 (progn
4523 ;; If we use dummy roots, then we have to remove the
4524 ;; dummy root as well.
4525 (when (eq gnus-summary-make-false-root 'dummy)
4526 ;; We go to the dummy root by going to
4527 ;; the first sub-"thread", and then one line up.
4528 (gnus-summary-goto-article
4529 (mail-header-number (caadr thread)))
4530 (forward-line -1)
4531 (gnus-delete-line)
4532 (gnus-data-compute-positions))
4533 (setq thread (cdr thread))
4534 (while thread
4535 (gnus-remove-thread-1 (car thread))
4536 (setq thread (cdr thread))))
4537 (gnus-remove-thread-1 thread))))))))
4538
4539 (defun gnus-remove-thread-1 (thread)
4540 "Remove the thread THREAD recursively."
4541 (let ((number (mail-header-number (pop thread)))
4542 d)
4543 (setq thread (reverse thread))
4544 (while thread
4545 (gnus-remove-thread-1 (pop thread)))
4546 (when (setq d (gnus-data-find number))
4547 (goto-char (gnus-data-pos d))
4548 (gnus-summary-show-thread)
4549 (gnus-data-remove
4550 number
4551 (- (gnus-point-at-bol)
4552 (prog1
4553 (1+ (gnus-point-at-eol))
4554 (gnus-delete-line)))))))
4555
4556 (defun gnus-sort-threads-recursive (threads func)
4557 (sort (mapcar (lambda (thread)
4558 (cons (car thread)
4559 (and (cdr thread)
4560 (gnus-sort-threads-recursive (cdr thread) func))))
4561 threads) func))
4562
4563 (defun gnus-sort-threads-loop (threads func)
4564 (let* ((superthread (cons nil threads))
4565 (stack (list (cons superthread threads)))
4566 remaining-threads thread)
4567 (while stack
4568 (setq remaining-threads (cdr (car stack)))
4569 (if remaining-threads
4570 (progn (setq thread (car remaining-threads))
4571 (setcdr (car stack) (cdr remaining-threads))
4572 (if (cdr thread)
4573 (push (cons thread (cdr thread)) stack)))
4574 (setq thread (caar stack))
4575 (setcdr thread (sort (cdr thread) func))
4576 (pop stack)))
4577 (cdr superthread)))
4578
4579 (defun gnus-sort-threads (threads)
4580 "Sort THREADS."
4581 (if (not gnus-thread-sort-functions)
4582 threads
4583 (gnus-message 8 "Sorting threads...")
4584 (prog1
4585 (condition-case nil
4586 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4587 (gnus-sort-threads-recursive
4588 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4589 ;; Even after binding max-lisp-eval-depth, the recursive
4590 ;; sorter might fail for very long threads. In that case,
4591 ;; try using a (less well-tested) non-recursive sorter.
4592 (error (gnus-sort-threads-loop
4593 threads (gnus-make-sort-function
4594 gnus-thread-sort-functions))))
4595 (gnus-message 8 "Sorting threads...done"))))
4596
4597 (defun gnus-sort-articles (articles)
4598 "Sort ARTICLES."
4599 (when gnus-article-sort-functions
4600 (gnus-message 7 "Sorting articles...")
4601 (prog1
4602 (setq gnus-newsgroup-headers
4603 (sort articles (gnus-make-sort-function
4604 gnus-article-sort-functions)))
4605 (gnus-message 7 "Sorting articles...done"))))
4606
4607 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4608 (defmacro gnus-thread-header (thread)
4609 "Return header of first article in THREAD.
4610 Note that THREAD must never, ever be anything else than a variable -
4611 using some other form will lead to serious barfage."
4612 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4613 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4614 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4615 (vector thread) 2))
4616
4617 (defsubst gnus-article-sort-by-number (h1 h2)
4618 "Sort articles by article number."
4619 (< (mail-header-number h1)
4620 (mail-header-number h2)))
4621
4622 (defun gnus-thread-sort-by-number (h1 h2)
4623 "Sort threads by root article number."
4624 (gnus-article-sort-by-number
4625 (gnus-thread-header h1) (gnus-thread-header h2)))
4626
4627 (defsubst gnus-article-sort-by-random (h1 h2)
4628 "Sort articles by article number."
4629 (zerop (random 2)))
4630
4631 (defun gnus-thread-sort-by-random (h1 h2)
4632 "Sort threads by root article number."
4633 (gnus-article-sort-by-random
4634 (gnus-thread-header h1) (gnus-thread-header h2)))
4635
4636 (defsubst gnus-article-sort-by-lines (h1 h2)
4637 "Sort articles by article Lines header."
4638 (< (mail-header-lines h1)
4639 (mail-header-lines h2)))
4640
4641 (defun gnus-thread-sort-by-lines (h1 h2)
4642 "Sort threads by root article Lines header."
4643 (gnus-article-sort-by-lines
4644 (gnus-thread-header h1) (gnus-thread-header h2)))
4645
4646 (defsubst gnus-article-sort-by-chars (h1 h2)
4647 "Sort articles by octet length."
4648 (< (mail-header-chars h1)
4649 (mail-header-chars h2)))
4650
4651 (defun gnus-thread-sort-by-chars (h1 h2)
4652 "Sort threads by root article octet length."
4653 (gnus-article-sort-by-chars
4654 (gnus-thread-header h1) (gnus-thread-header h2)))
4655
4656 (defsubst gnus-article-sort-by-author (h1 h2)
4657 "Sort articles by root author."
4658 (string-lessp
4659 (let ((extract (funcall
4660 gnus-extract-address-components
4661 (mail-header-from h1))))
4662 (or (car extract) (cadr extract) ""))
4663 (let ((extract (funcall
4664 gnus-extract-address-components
4665 (mail-header-from h2))))
4666 (or (car extract) (cadr extract) ""))))
4667
4668 (defun gnus-thread-sort-by-author (h1 h2)
4669 "Sort threads by root author."
4670 (gnus-article-sort-by-author
4671 (gnus-thread-header h1) (gnus-thread-header h2)))
4672
4673 (defsubst gnus-article-sort-by-subject (h1 h2)
4674 "Sort articles by root subject."
4675 (string-lessp
4676 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4677 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4678
4679 (defun gnus-thread-sort-by-subject (h1 h2)
4680 "Sort threads by root subject."
4681 (gnus-article-sort-by-subject
4682 (gnus-thread-header h1) (gnus-thread-header h2)))
4683
4684 (defsubst gnus-article-sort-by-date (h1 h2)
4685 "Sort articles by root article date."
4686 (time-less-p
4687 (gnus-date-get-time (mail-header-date h1))
4688 (gnus-date-get-time (mail-header-date h2))))
4689
4690 (defun gnus-thread-sort-by-date (h1 h2)
4691 "Sort threads by root article date."
4692 (gnus-article-sort-by-date
4693 (gnus-thread-header h1) (gnus-thread-header h2)))
4694
4695 (defsubst gnus-article-sort-by-score (h1 h2)
4696 "Sort articles by root article score.
4697 Unscored articles will be counted as having a score of zero."
4698 (> (or (cdr (assq (mail-header-number h1)
4699 gnus-newsgroup-scored))
4700 gnus-summary-default-score 0)
4701 (or (cdr (assq (mail-header-number h2)
4702 gnus-newsgroup-scored))
4703 gnus-summary-default-score 0)))
4704
4705 (defun gnus-thread-sort-by-score (h1 h2)
4706 "Sort threads by root article score."
4707 (gnus-article-sort-by-score
4708 (gnus-thread-header h1) (gnus-thread-header h2)))
4709
4710 (defun gnus-thread-sort-by-total-score (h1 h2)
4711 "Sort threads by the sum of all scores in the thread.
4712 Unscored articles will be counted as having a score of zero."
4713 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4714
4715 (defun gnus-thread-total-score (thread)
4716 ;; This function find the total score of THREAD.
4717 (cond
4718 ((null thread)
4719 0)
4720 ((consp thread)
4721 (if (stringp (car thread))
4722 (apply gnus-thread-score-function 0
4723 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4724 (gnus-thread-total-score-1 thread)))
4725 (t
4726 (gnus-thread-total-score-1 (list thread)))))
4727
4728 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4729 "Sort threads such that the thread with the most recently arrived article comes first."
4730 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4731
4732 (defun gnus-thread-highest-number (thread)
4733 "Return the highest article number in THREAD."
4734 (apply 'max (mapcar (lambda (header)
4735 (mail-header-number header))
4736 (message-flatten-list thread))))
4737
4738 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4739 "Sort threads such that the thread with the most recently dated article comes first."
4740 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4741
4742 (defun gnus-thread-latest-date (thread)
4743 "Return the highest article date in THREAD."
4744 (let ((previous-time 0))
4745 (apply 'max
4746 (mapcar
4747 (lambda (header)
4748 (setq previous-time
4749 (condition-case ()
4750 (time-to-seconds (mail-header-parse-date
4751 (mail-header-date header)))
4752 (error previous-time))))
4753 (sort
4754 (message-flatten-list thread)
4755 (lambda (h1 h2)
4756 (< (mail-header-number h1)
4757 (mail-header-number h2))))))))
4758
4759 (defun gnus-thread-total-score-1 (root)
4760 ;; This function find the total score of the thread below ROOT.
4761 (setq root (car root))
4762 (apply gnus-thread-score-function
4763 (or (append
4764 (mapcar 'gnus-thread-total-score
4765 (cdr (gnus-id-to-thread (mail-header-id root))))
4766 (when (> (mail-header-number root) 0)
4767 (list (or (cdr (assq (mail-header-number root)
4768 gnus-newsgroup-scored))
4769 gnus-summary-default-score 0))))
4770 (list gnus-summary-default-score)
4771 '(0))))
4772
4773 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4774 (defvar gnus-tmp-prev-subject nil)
4775 (defvar gnus-tmp-false-parent nil)
4776 (defvar gnus-tmp-root-expunged nil)
4777 (defvar gnus-tmp-dummy-line nil)
4778
4779 (eval-when-compile (defvar gnus-tmp-header))
4780 (defun gnus-extra-header (type &optional header)
4781 "Return the extra header of TYPE."
4782 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4783 ""))
4784
4785 (defvar gnus-tmp-thread-tree-header-string "")
4786
4787 (defcustom gnus-sum-thread-tree-root "> "
4788 "With %B spec, used for the root of a thread.
4789 If nil, use subject instead."
4790 :version "22.1"
4791 :type '(radio (const :format "%v " nil) string)
4792 :group 'gnus-thread)
4793 (defcustom gnus-sum-thread-tree-false-root "> "
4794 "With %B spec, used for a false root of a thread.
4795 If nil, use subject instead."
4796 :version "22.1"
4797 :type '(radio (const :format "%v " nil) string)
4798 :group 'gnus-thread)
4799 (defcustom gnus-sum-thread-tree-single-indent ""
4800 "With %B spec, used for a thread with just one message.
4801 If nil, use subject instead."
4802 :version "22.1"
4803 :type '(radio (const :format "%v " nil) string)
4804 :group 'gnus-thread)
4805 (defcustom gnus-sum-thread-tree-vertical "| "
4806 "With %B spec, used for drawing a vertical line."
4807 :version "22.1"
4808 :type 'string
4809 :group 'gnus-thread)
4810 (defcustom gnus-sum-thread-tree-indent " "
4811 "With %B spec, used for indenting."
4812 :version "22.1"
4813 :type 'string
4814 :group 'gnus-thread)
4815 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4816 "With %B spec, used for a leaf with brothers."
4817 :version "22.1"
4818 :type 'string
4819 :group 'gnus-thread)
4820 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4821 "With %B spec, used for a leaf without brothers."
4822 :version "22.1"
4823 :type 'string
4824 :group 'gnus-thread)
4825
4826 (defun gnus-summary-prepare-threads (threads)
4827 "Prepare summary buffer from THREADS and indentation LEVEL.
4828 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4829 or a straight list of headers."
4830 (gnus-message 7 "Generating summary...")
4831
4832 (setq gnus-newsgroup-threads threads)
4833 (beginning-of-line)
4834
4835 (let ((gnus-tmp-level 0)
4836 (default-score (or gnus-summary-default-score 0))
4837 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4838 (building-line-count gnus-summary-display-while-building)
4839 (building-count (integerp gnus-summary-display-while-building))
4840 thread number subject stack state gnus-tmp-gathered beg-match
4841 new-roots gnus-tmp-new-adopts thread-end simp-subject
4842 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4843 gnus-tmp-replied gnus-tmp-subject-or-nil
4844 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4845 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4846 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4847 tree-stack)
4848
4849 (setq gnus-tmp-prev-subject nil
4850 gnus-tmp-thread-tree-header-string "")
4851
4852 (if (vectorp (car threads))
4853 ;; If this is a straight (sic) list of headers, then a
4854 ;; threaded summary display isn't required, so we just create
4855 ;; an unthreaded one.
4856 (gnus-summary-prepare-unthreaded threads)
4857
4858 ;; Do the threaded display.
4859
4860 (if gnus-summary-display-while-building
4861 (switch-to-buffer (buffer-name)))
4862 (while (or threads stack gnus-tmp-new-adopts new-roots)
4863
4864 (if (and (= gnus-tmp-level 0)
4865 (or (not stack)
4866 (= (caar stack) 0))
4867 (not gnus-tmp-false-parent)
4868 (or gnus-tmp-new-adopts new-roots))
4869 (if gnus-tmp-new-adopts
4870 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4871 thread (list (car gnus-tmp-new-adopts))
4872 gnus-tmp-header (caar thread)
4873 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4874 (when new-roots
4875 (setq thread (list (car new-roots))
4876 gnus-tmp-header (caar thread)
4877 new-roots (cdr new-roots))))
4878
4879 (if threads
4880 ;; If there are some threads, we do them before the
4881 ;; threads on the stack.
4882 (setq thread threads
4883 gnus-tmp-header (caar thread))
4884 ;; There were no current threads, so we pop something off
4885 ;; the stack.
4886 (setq state (car stack)
4887 gnus-tmp-level (car state)
4888 tree-stack (cadr state)
4889 thread (caddr state)
4890 stack (cdr stack)
4891 gnus-tmp-header (caar thread))))
4892
4893 (setq gnus-tmp-false-parent nil)
4894 (setq gnus-tmp-root-expunged nil)
4895 (setq thread-end nil)
4896
4897 (if (stringp gnus-tmp-header)
4898 ;; The header is a dummy root.
4899 (cond
4900 ((eq gnus-summary-make-false-root 'adopt)
4901 ;; We let the first article adopt the rest.
4902 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4903 (cddar thread)))
4904 (setq gnus-tmp-gathered
4905 (nconc (mapcar
4906 (lambda (h) (mail-header-number (car h)))
4907 (cddar thread))
4908 gnus-tmp-gathered))
4909 (setq thread (cons (list (caar thread)
4910 (cadar thread))
4911 (cdr thread)))
4912 (setq gnus-tmp-level -1
4913 gnus-tmp-false-parent t))
4914 ((eq gnus-summary-make-false-root 'empty)
4915 ;; We print adopted articles with empty subject fields.
4916 (setq gnus-tmp-gathered
4917 (nconc (mapcar
4918 (lambda (h) (mail-header-number (car h)))
4919 (cddar thread))
4920 gnus-tmp-gathered))
4921 (setq gnus-tmp-level -1))
4922 ((eq gnus-summary-make-false-root 'dummy)
4923 ;; We remember that we probably want to output a dummy
4924 ;; root.
4925 (setq gnus-tmp-dummy-line gnus-tmp-header)
4926 (setq gnus-tmp-prev-subject gnus-tmp-header))
4927 (t
4928 ;; We do not make a root for the gathered
4929 ;; sub-threads at all.
4930 (setq gnus-tmp-level -1)))
4931
4932 (setq number (mail-header-number gnus-tmp-header)
4933 subject (mail-header-subject gnus-tmp-header)
4934 simp-subject (gnus-simplify-subject-fully subject))
4935
4936 (cond
4937 ;; If the thread has changed subject, we might want to make
4938 ;; this subthread into a root.
4939 ((and (null gnus-thread-ignore-subject)
4940 (not (zerop gnus-tmp-level))
4941 gnus-tmp-prev-subject
4942 (not (string= gnus-tmp-prev-subject simp-subject)))
4943 (setq new-roots (nconc new-roots (list (car thread)))
4944 thread-end t
4945 gnus-tmp-header nil))
4946 ;; If the article lies outside the current limit,
4947 ;; then we do not display it.
4948 ((not (memq number gnus-newsgroup-limit))
4949 (setq gnus-tmp-gathered
4950 (nconc (mapcar
4951 (lambda (h) (mail-header-number (car h)))
4952 (cdar thread))
4953 gnus-tmp-gathered))
4954 (setq gnus-tmp-new-adopts (if (cdar thread)
4955 (append gnus-tmp-new-adopts
4956 (cdar thread))
4957 gnus-tmp-new-adopts)
4958 thread-end t
4959 gnus-tmp-header nil)
4960 (when (zerop gnus-tmp-level)
4961 (setq gnus-tmp-root-expunged t)))
4962 ;; Perhaps this article is to be marked as read?
4963 ((and gnus-summary-mark-below
4964 (< (or (cdr (assq number gnus-newsgroup-scored))
4965 default-score)
4966 gnus-summary-mark-below)
4967 ;; Don't touch sparse articles.
4968 (not (gnus-summary-article-sparse-p number))
4969 (not (gnus-summary-article-ancient-p number)))
4970 (setq gnus-newsgroup-unreads
4971 (delq number gnus-newsgroup-unreads))
4972 (if gnus-newsgroup-auto-expire
4973 (setq gnus-newsgroup-expirable
4974 (gnus-add-to-sorted-list
4975 gnus-newsgroup-expirable number))
4976 (push (cons number gnus-low-score-mark)
4977 gnus-newsgroup-reads))))
4978
4979 (when gnus-tmp-header
4980 ;; We may have an old dummy line to output before this
4981 ;; article.
4982 (when (and gnus-tmp-dummy-line
4983 (gnus-subject-equal
4984 gnus-tmp-dummy-line
4985 (mail-header-subject gnus-tmp-header)))
4986 (gnus-summary-insert-dummy-line
4987 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4988 (setq gnus-tmp-dummy-line nil))
4989
4990 ;; Compute the mark.
4991 (setq gnus-tmp-unread (gnus-article-mark number))
4992
4993 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4994 gnus-tmp-header gnus-tmp-level)
4995 gnus-newsgroup-data)
4996
4997 ;; Actually insert the line.
4998 (setq
4999 gnus-tmp-subject-or-nil
5000 (cond
5001 ((and gnus-thread-ignore-subject
5002 gnus-tmp-prev-subject
5003 (not (string= gnus-tmp-prev-subject simp-subject)))
5004 subject)
5005 ((zerop gnus-tmp-level)
5006 (if (and (eq gnus-summary-make-false-root 'empty)
5007 (memq number gnus-tmp-gathered)
5008 gnus-tmp-prev-subject
5009 (string= gnus-tmp-prev-subject simp-subject))
5010 gnus-summary-same-subject
5011 subject))
5012 (t gnus-summary-same-subject)))
5013 (if (and (eq gnus-summary-make-false-root 'adopt)
5014 (= gnus-tmp-level 1)
5015 (memq number gnus-tmp-gathered))
5016 (setq gnus-tmp-opening-bracket ?\<
5017 gnus-tmp-closing-bracket ?\>)
5018 (setq gnus-tmp-opening-bracket ?\[
5019 gnus-tmp-closing-bracket ?\]))
5020 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5021 (gnus-make-thread-indent-array
5022 (max (* 2 (length gnus-thread-indent-array))
5023 gnus-tmp-level)))
5024 (setq
5025 gnus-tmp-indentation
5026 (aref gnus-thread-indent-array gnus-tmp-level)
5027 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5028 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5029 gnus-summary-default-score 0)
5030 gnus-tmp-score-char
5031 (if (or (null gnus-summary-default-score)
5032 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5033 gnus-summary-zcore-fuzz))
5034 ? ;Whitespace
5035 (if (< gnus-tmp-score gnus-summary-default-score)
5036 gnus-score-below-mark gnus-score-over-mark))
5037 gnus-tmp-replied
5038 (cond ((memq number gnus-newsgroup-processable)
5039 gnus-process-mark)
5040 ((memq number gnus-newsgroup-cached)
5041 gnus-cached-mark)
5042 ((memq number gnus-newsgroup-replied)
5043 gnus-replied-mark)
5044 ((memq number gnus-newsgroup-forwarded)
5045 gnus-forwarded-mark)
5046 ((memq number gnus-newsgroup-saved)
5047 gnus-saved-mark)
5048 ((memq number gnus-newsgroup-recent)
5049 gnus-recent-mark)
5050 ((memq number gnus-newsgroup-unseen)
5051 gnus-unseen-mark)
5052 (t gnus-no-mark))
5053 gnus-tmp-downloaded
5054 (cond ((memq number gnus-newsgroup-undownloaded)
5055 gnus-undownloaded-mark)
5056 (gnus-newsgroup-agentized
5057 gnus-downloaded-mark)
5058 (t
5059 gnus-no-mark))
5060 gnus-tmp-from (mail-header-from gnus-tmp-header)
5061 gnus-tmp-name
5062 (cond
5063 ((string-match "<[^>]+> *$" gnus-tmp-from)
5064 (setq beg-match (match-beginning 0))
5065 (or (and (string-match "^\".+\"" gnus-tmp-from)
5066 (substring gnus-tmp-from 1 (1- (match-end 0))))
5067 (substring gnus-tmp-from 0 beg-match)))
5068 ((string-match "(.+)" gnus-tmp-from)
5069 (substring gnus-tmp-from
5070 (1+ (match-beginning 0)) (1- (match-end 0))))
5071 (t gnus-tmp-from))
5072
5073 ;; Do the %B string
5074 gnus-tmp-thread-tree-header-string
5075 (cond
5076 ((not gnus-show-threads) "")
5077 ((zerop gnus-tmp-level)
5078 (cond ((cdar thread)
5079 (or gnus-sum-thread-tree-root subject))
5080 (gnus-tmp-new-adopts
5081 (or gnus-sum-thread-tree-false-root subject))
5082 (t
5083 (or gnus-sum-thread-tree-single-indent subject))))
5084 (t
5085 (concat (apply 'concat
5086 (mapcar (lambda (item)
5087 (if (= item 1)
5088 gnus-sum-thread-tree-vertical
5089 gnus-sum-thread-tree-indent))
5090 (cdr (reverse tree-stack))))
5091 (if (nth 1 thread)
5092 gnus-sum-thread-tree-leaf-with-other
5093 gnus-sum-thread-tree-single-leaf)))))
5094 (when (string= gnus-tmp-name "")
5095 (setq gnus-tmp-name gnus-tmp-from))
5096 (unless (numberp gnus-tmp-lines)
5097 (setq gnus-tmp-lines -1))
5098 (if (= gnus-tmp-lines -1)
5099 (setq gnus-tmp-lines "?")
5100 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5101 (gnus-put-text-property
5102 (point)
5103 (progn (eval gnus-summary-line-format-spec) (point))
5104 'gnus-number number)
5105 (when gnus-visual-p
5106 (forward-line -1)
5107 (gnus-run-hooks 'gnus-summary-update-hook)
5108 (forward-line 1))
5109
5110 (setq gnus-tmp-prev-subject simp-subject)))
5111
5112 (when (nth 1 thread)
5113 (push (list (max 0 gnus-tmp-level)
5114 (copy-sequence tree-stack)
5115 (nthcdr 1 thread))
5116 stack))
5117 (push (if (nth 1 thread) 1 0) tree-stack)
5118 (incf gnus-tmp-level)
5119 (setq threads (if thread-end nil (cdar thread)))
5120 (if gnus-summary-display-while-building
5121 (if building-count
5122 (progn
5123 ;; use a set frequency
5124 (setq building-line-count (1- building-line-count))
5125 (when (= building-line-count 0)
5126 (sit-for 0)
5127 (setq building-line-count
5128 gnus-summary-display-while-building)))
5129 ;; always
5130 (sit-for 0)))
5131 (unless threads
5132 (setq gnus-tmp-level 0)))))
5133 (gnus-message 7 "Generating summary...done"))
5134
5135 (defun gnus-summary-prepare-unthreaded (headers)
5136 "Generate an unthreaded summary buffer based on HEADERS."
5137 (let (header number mark)
5138
5139 (beginning-of-line)
5140
5141 (while headers
5142 ;; We may have to root out some bad articles...
5143 (when (memq (setq number (mail-header-number
5144 (setq header (pop headers))))
5145 gnus-newsgroup-limit)
5146 ;; Mark article as read when it has a low score.
5147 (when (and gnus-summary-mark-below
5148 (< (or (cdr (assq number gnus-newsgroup-scored))
5149 gnus-summary-default-score 0)
5150 gnus-summary-mark-below)
5151 (not (gnus-summary-article-ancient-p number)))
5152 (setq gnus-newsgroup-unreads
5153 (delq number gnus-newsgroup-unreads))
5154 (if gnus-newsgroup-auto-expire
5155 (push number gnus-newsgroup-expirable)
5156 (push (cons number gnus-low-score-mark)
5157 gnus-newsgroup-reads)))
5158
5159 (setq mark (gnus-article-mark number))
5160 (push (gnus-data-make number mark (1+ (point)) header 0)
5161 gnus-newsgroup-data)
5162 (gnus-summary-insert-line
5163 header 0 number
5164 (memq number gnus-newsgroup-undownloaded)
5165 mark (memq number gnus-newsgroup-replied)
5166 (memq number gnus-newsgroup-expirable)
5167 (mail-header-subject header) nil
5168 (cdr (assq number gnus-newsgroup-scored))
5169 (memq number gnus-newsgroup-processable))))))
5170
5171 (defun gnus-summary-remove-list-identifiers ()
5172 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5173 (let ((regexp (if (consp gnus-list-identifiers)
5174 (mapconcat 'identity gnus-list-identifiers " *\\|")
5175 gnus-list-identifiers))
5176 changed subject)
5177 (when regexp
5178 (dolist (header gnus-newsgroup-headers)
5179 (setq subject (mail-header-subject header)
5180 changed nil)
5181 (while (string-match
5182 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5183 subject)
5184 (setq subject
5185 (concat (substring subject 0 (match-beginning 2))
5186 (substring subject (match-end 0)))
5187 changed t))
5188 (when (and changed
5189 (string-match
5190 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5191 (setq subject
5192 (concat (substring subject 0 (match-beginning 1))
5193 (substring subject (match-end 1)))))
5194 (when changed
5195 (mail-header-set-subject header subject))))))
5196
5197 (defun gnus-fetch-headers (articles)
5198 "Fetch headers of ARTICLES."
5199 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5200 (gnus-message 5 "Fetching headers for %s..." name)
5201 (prog1
5202 (if (eq 'nov
5203 (setq gnus-headers-retrieved-by
5204 (gnus-retrieve-headers
5205 articles gnus-newsgroup-name
5206 ;; We might want to fetch old headers, but
5207 ;; not if there is only 1 article.
5208 (and (or (and
5209 (not (eq gnus-fetch-old-headers 'some))
5210 (not (numberp gnus-fetch-old-headers)))
5211 (> (length articles) 1))
5212 gnus-fetch-old-headers))))
5213 (gnus-get-newsgroup-headers-xover
5214 articles nil nil gnus-newsgroup-name t)
5215 (gnus-get-newsgroup-headers))
5216 (gnus-message 5 "Fetching headers for %s...done" name))))
5217
5218 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5219 "Select newsgroup GROUP.
5220 If READ-ALL is non-nil, all articles in the group are selected.
5221 If SELECT-ARTICLES, only select those articles from GROUP."
5222 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5223 ;;!!! Dirty hack; should be removed.
5224 (gnus-summary-ignore-duplicates
5225 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5226 t
5227 gnus-summary-ignore-duplicates))
5228 (info (nth 2 entry))
5229 articles fetched-articles cached)
5230
5231 (unless (gnus-check-server
5232 (set (make-local-variable 'gnus-current-select-method)
5233 (gnus-find-method-for-group group)))
5234 (error "Couldn't open server"))
5235
5236 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5237 (gnus-activate-group group) ; Or we can activate it...
5238 (progn ; Or we bug out.
5239 (when (equal major-mode 'gnus-summary-mode)
5240 (gnus-kill-buffer (current-buffer)))
5241 (error "Couldn't activate group %s: %s"
5242 (gnus-group-decoded-name group) (gnus-status-message group))))
5243
5244 (unless (gnus-request-group group t)
5245 (when (equal major-mode 'gnus-summary-mode)
5246 (gnus-kill-buffer (current-buffer)))
5247 (error "Couldn't request group %s: %s"
5248 (gnus-group-decoded-name group) (gnus-status-message group)))
5249
5250 (when gnus-agent
5251 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5252
5253 (setq gnus-summary-use-undownloaded-faces
5254 (gnus-agent-find-parameter
5255 group
5256 'agent-enable-undownloaded-faces)))
5257
5258 (setq gnus-newsgroup-name group
5259 gnus-newsgroup-unselected nil
5260 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5261
5262 (let ((display (gnus-group-find-parameter group 'display)))
5263 (setq gnus-newsgroup-display
5264 (cond
5265 ((not (zerop (or (car-safe read-all) 0)))
5266 ;; The user entered the group with C-u SPC/RET, let's show
5267 ;; all articles.
5268 'gnus-not-ignore)
5269 ((eq display 'all)
5270 'gnus-not-ignore)
5271 ((arrayp display)
5272 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5273 ((numberp display)
5274 ;; The following is probably the "correct" solution, but
5275 ;; it makes Gnus fetch all headers and then limit the
5276 ;; articles (which is slow), so instead we hack the
5277 ;; select-articles parameter instead. -- Simon Josefsson
5278 ;; <jas@kth.se>
5279 ;;
5280 ;; (gnus-byte-compile
5281 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5282 ;; display)))))
5283 (setq select-articles
5284 (gnus-uncompress-range
5285 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5286 (if (> tmp 0)
5287 tmp
5288 1))
5289 (cdr (gnus-active group)))))
5290 nil)
5291 (t
5292 nil))))
5293
5294 (gnus-summary-setup-default-charset)
5295
5296 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5297 (when (gnus-virtual-group-p group)
5298 (setq cached gnus-newsgroup-cached))
5299
5300 (setq gnus-newsgroup-unreads
5301 (gnus-sorted-ndifference
5302 (gnus-sorted-ndifference gnus-newsgroup-unreads
5303 gnus-newsgroup-marked)
5304 gnus-newsgroup-dormant))
5305
5306 (setq gnus-newsgroup-processable nil)
5307
5308 (gnus-update-read-articles group gnus-newsgroup-unreads)
5309
5310 ;; Adjust and set lists of article marks.
5311 (when info
5312 (gnus-adjust-marked-articles info))
5313 (if (setq articles select-articles)
5314 (setq gnus-newsgroup-unselected
5315 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5316 (setq articles (gnus-articles-to-read group read-all)))
5317
5318 (cond
5319 ((null articles)
5320 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5321 'quit)
5322 ((eq articles 0) nil)
5323 (t
5324 ;; Init the dependencies hash table.
5325 (setq gnus-newsgroup-dependencies
5326 (gnus-make-hashtable (length articles)))
5327 (gnus-set-global-variables)
5328 ;; Retrieve the headers and read them in.
5329
5330 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5331
5332 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5333 (when cached
5334 (setq gnus-newsgroup-cached cached))
5335
5336 ;; Suppress duplicates?
5337 (when gnus-suppress-duplicates
5338 (gnus-dup-suppress-articles))
5339
5340 ;; Set the initial limit.
5341 (setq gnus-newsgroup-limit (copy-sequence articles))
5342 ;; Remove canceled articles from the list of unread articles.
5343 (setq fetched-articles
5344 (mapcar (lambda (headers) (mail-header-number headers))
5345 gnus-newsgroup-headers))
5346 (setq gnus-newsgroup-articles fetched-articles)
5347 (setq gnus-newsgroup-unreads
5348 (gnus-sorted-nintersection
5349 gnus-newsgroup-unreads fetched-articles))
5350 (gnus-compute-unseen-list)
5351
5352 ;; Removed marked articles that do not exist.
5353 (gnus-update-missing-marks
5354 (gnus-sorted-difference articles fetched-articles))
5355 ;; We might want to build some more threads first.
5356 (when (and gnus-fetch-old-headers
5357 (eq gnus-headers-retrieved-by 'nov))
5358 (if (eq gnus-fetch-old-headers 'invisible)
5359 (gnus-build-all-threads)
5360 (gnus-build-old-threads)))
5361 ;; Let the Gnus agent mark articles as read.
5362 (when gnus-agent
5363 (gnus-agent-get-undownloaded-list))
5364 ;; Remove list identifiers from subject
5365 (when gnus-list-identifiers
5366 (gnus-summary-remove-list-identifiers))
5367 ;; Check whether auto-expire is to be done in this group.
5368 (setq gnus-newsgroup-auto-expire
5369 (gnus-group-auto-expirable-p group))
5370 ;; Set up the article buffer now, if necessary.
5371 (unless gnus-single-article-buffer
5372 (gnus-article-setup-buffer))
5373 ;; First and last article in this newsgroup.
5374 (when gnus-newsgroup-headers
5375 (setq gnus-newsgroup-begin
5376 (mail-header-number (car gnus-newsgroup-headers))
5377 gnus-newsgroup-end
5378 (mail-header-number
5379 (gnus-last-element gnus-newsgroup-headers))))
5380 ;; GROUP is successfully selected.
5381 (or gnus-newsgroup-headers t)))))
5382
5383 (defun gnus-compute-unseen-list ()
5384 ;; The `seen' marks are treated specially.
5385 (if (not gnus-newsgroup-seen)
5386 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5387 (setq gnus-newsgroup-unseen
5388 (gnus-inverse-list-range-intersection
5389 gnus-newsgroup-articles gnus-newsgroup-seen))))
5390
5391 (defun gnus-summary-display-make-predicate (display)
5392 (require 'gnus-agent)
5393 (when (= (length display) 1)
5394 (setq display (car display)))
5395 (unless gnus-summary-display-cache
5396 (dolist (elem (append '((unread . unread)
5397 (read . read)
5398 (unseen . unseen))
5399 gnus-article-mark-lists))
5400 (push (cons (cdr elem)
5401 (gnus-byte-compile
5402 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5403 gnus-summary-display-cache)))
5404 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5405 (gnus-category-predicate-cache gnus-summary-display-cache))
5406 (gnus-get-predicate display)))
5407
5408 ;; Uses the dynamically bound `number' variable.
5409 (eval-when-compile
5410 (defvar number))
5411 (defun gnus-article-marked-p (type &optional article)
5412 (let ((article (or article number)))
5413 (cond
5414 ((eq type 'tick)
5415 (memq article gnus-newsgroup-marked))
5416 ((eq type 'spam)
5417 (memq article gnus-newsgroup-spam-marked))
5418 ((eq type 'unsend)
5419 (memq article gnus-newsgroup-unsendable))
5420 ((eq type 'undownload)
5421 (memq article gnus-newsgroup-undownloaded))
5422 ((eq type 'download)
5423 (memq article gnus-newsgroup-downloadable))
5424 ((eq type 'unread)
5425 (memq article gnus-newsgroup-unreads))
5426 ((eq type 'read)
5427 (memq article gnus-newsgroup-reads))
5428 ((eq type 'dormant)
5429 (memq article gnus-newsgroup-dormant) )
5430 ((eq type 'expire)
5431 (memq article gnus-newsgroup-expirable))
5432 ((eq type 'reply)
5433 (memq article gnus-newsgroup-replied))
5434 ((eq type 'killed)
5435 (memq article gnus-newsgroup-killed))
5436 ((eq type 'bookmark)
5437 (assq article gnus-newsgroup-bookmarks))
5438 ((eq type 'score)
5439 (assq article gnus-newsgroup-scored))
5440 ((eq type 'save)
5441 (memq article gnus-newsgroup-saved))
5442 ((eq type 'cache)
5443 (memq article gnus-newsgroup-cached))
5444 ((eq type 'forward)
5445 (memq article gnus-newsgroup-forwarded))
5446 ((eq type 'seen)
5447 (not (memq article gnus-newsgroup-unseen)))
5448 ((eq type 'recent)
5449 (memq article gnus-newsgroup-recent))
5450 (t t))))
5451
5452 (defun gnus-articles-to-read (group &optional read-all)
5453 "Find out what articles the user wants to read."
5454 (let* ((articles
5455 ;; Select all articles if `read-all' is non-nil, or if there
5456 ;; are no unread articles.
5457 (if (or read-all
5458 (and (zerop (length gnus-newsgroup-marked))
5459 (zerop (length gnus-newsgroup-unreads)))
5460 ;; Fetch all if the predicate is non-nil.
5461 gnus-newsgroup-display)
5462 ;; We want to select the headers for all the articles in
5463 ;; the group, so we select either all the active
5464 ;; articles in the group, or (if that's nil), the
5465 ;; articles in the cache.
5466 (or
5467 (gnus-uncompress-range (gnus-active group))
5468 (gnus-cache-articles-in-group group))
5469 ;; Select only the "normal" subset of articles.
5470 (gnus-sorted-nunion
5471 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5472 gnus-newsgroup-unreads)))
5473 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5474 (scored (length scored-list))
5475 (number (length articles))
5476 (marked (+ (length gnus-newsgroup-marked)
5477 (length gnus-newsgroup-dormant)))
5478 (select
5479 (cond
5480 ((numberp read-all)
5481 read-all)
5482 ((numberp gnus-newsgroup-display)
5483 gnus-newsgroup-display)
5484 (t
5485 (condition-case ()
5486 (cond
5487 ((and (or (<= scored marked) (= scored number))
5488 (numberp gnus-large-newsgroup)
5489 (> number gnus-large-newsgroup))
5490 (let* ((cursor-in-echo-area nil)
5491 (initial (gnus-parameter-large-newsgroup-initial
5492 gnus-newsgroup-name))
5493 (input
5494 (read-string
5495 (format
5496 "How many articles from %s (%s %d): "
5497 (gnus-limit-string
5498 (gnus-group-decoded-name gnus-newsgroup-name)
5499 35)
5500 (if initial "max" "default")
5501 number)
5502 (if initial
5503 (cons (number-to-string initial)
5504 0)))))
5505 (if (string-match "^[ \t]*$" input) number input)))
5506 ((and (> scored marked) (< scored number)
5507 (> (- scored number) 20))
5508 (let ((input
5509 (read-string
5510 (format "%s %s (%d scored, %d total): "
5511 "How many articles from"
5512 (gnus-group-decoded-name group)
5513 scored number))))
5514 (if (string-match "^[ \t]*$" input)
5515 number input)))
5516 (t number))
5517 (quit
5518 (message "Quit getting the articles to read")
5519 nil))))))
5520 (setq select (if (stringp select) (string-to-number select) select))
5521 (if (or (null select) (zerop select))
5522 select
5523 (if (and (not (zerop scored)) (<= (abs select) scored))
5524 (progn
5525 (setq articles (sort scored-list '<))
5526 (setq number (length articles)))
5527 (setq articles (copy-sequence articles)))
5528
5529 (when (< (abs select) number)
5530 (if (< select 0)
5531 ;; Select the N oldest articles.
5532 (setcdr (nthcdr (1- (abs select)) articles) nil)
5533 ;; Select the N most recent articles.
5534 (setq articles (nthcdr (- number select) articles))))
5535 (setq gnus-newsgroup-unselected
5536 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5537 (when gnus-alter-articles-to-read-function
5538 (setq articles
5539 (sort
5540 (funcall gnus-alter-articles-to-read-function
5541 gnus-newsgroup-name articles)
5542 '<)))
5543 articles)))
5544
5545 (defun gnus-killed-articles (killed articles)
5546 (let (out)
5547 (while articles
5548 (when (inline (gnus-member-of-range (car articles) killed))
5549 (push (car articles) out))
5550 (setq articles (cdr articles)))
5551 out))
5552
5553 (defun gnus-uncompress-marks (marks)
5554 "Uncompress the mark ranges in MARKS."
5555 (let ((uncompressed '(score bookmark))
5556 out)
5557 (while marks
5558 (if (memq (caar marks) uncompressed)
5559 (push (car marks) out)
5560 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5561 (setq marks (cdr marks)))
5562 out))
5563
5564 (defun gnus-article-mark-to-type (mark)
5565 "Return the type of MARK."
5566 (or (cadr (assq mark gnus-article-special-mark-lists))
5567 'list))
5568
5569 (defun gnus-article-unpropagatable-p (mark)
5570 "Return whether MARK should be propagated to back end."
5571 (memq mark gnus-article-unpropagated-mark-lists))
5572
5573 (defun gnus-adjust-marked-articles (info)
5574 "Set all article lists and remove all marks that are no longer valid."
5575 (let* ((marked-lists (gnus-info-marks info))
5576 (active (gnus-active (gnus-info-group info)))
5577 (min (car active))
5578 (max (cdr active))
5579 (types gnus-article-mark-lists)
5580 marks var articles article mark mark-type
5581 bgn end)
5582
5583 (dolist (marks marked-lists)
5584 (setq mark (car marks)
5585 mark-type (gnus-article-mark-to-type mark)
5586 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5587
5588 ;; We set the variable according to the type of the marks list,
5589 ;; and then adjust the marks to a subset of the active articles.
5590 (cond
5591 ;; Adjust "simple" lists - compressed yet unsorted
5592 ((eq mark-type 'list)
5593 ;; Simultaneously uncompress and clip to active range
5594 ;; See gnus-uncompress-range for a description of possible marks
5595 (let (l lh)
5596 (if (not (cadr marks))
5597 (set var nil)
5598 (setq articles (if (numberp (cddr marks))
5599 (list (cdr marks))
5600 (cdr marks))
5601 lh (cons nil nil)
5602 l lh)
5603
5604 (while (setq article (pop articles))
5605 (cond ((consp article)
5606 (setq bgn (max (car article) min)
5607 end (min (cdr article) max))
5608 (while (<= bgn end)
5609 (setq l (setcdr l (cons bgn nil))
5610 bgn (1+ bgn))))
5611 ((and (<= min article)
5612 (>= max article))
5613 (setq l (setcdr l (cons article nil))))))
5614 (set var (cdr lh)))))
5615 ;; Adjust assocs.
5616 ((eq mark-type 'tuple)
5617 (set var (setq articles (cdr marks)))
5618 (when (not (listp (cdr (symbol-value var))))
5619 (set var (list (symbol-value var))))
5620 (when (not (listp (cdr articles)))
5621 (setq articles (list articles)))
5622 (while articles
5623 (when (or (not (consp (setq article (pop articles))))
5624 (< (car article) min)
5625 (> (car article) max))
5626 (set var (delq article (symbol-value var))))))
5627 ;; Adjust ranges (sloppily).
5628 ((eq mark-type 'range)
5629 (cond
5630 ((eq mark 'seen)
5631 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5632 ;; It should be (seen (NUM1 . NUM2)).
5633 (when (numberp (cddr marks))
5634 (setcdr marks (list (cdr marks))))
5635 (setq articles (cdr marks))
5636 (while (and articles
5637 (or (and (consp (car articles))
5638 (> min (cdar articles)))
5639 (and (numberp (car articles))
5640 (> min (car articles)))))
5641 (pop articles))
5642 (set var articles))))))))
5643
5644 (defun gnus-update-missing-marks (missing)
5645 "Go through the list of MISSING articles and remove them from the mark lists."
5646 (when missing
5647 (let (var m)
5648 ;; Go through all types.
5649 (dolist (elem gnus-article-mark-lists)
5650 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5651 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5652 (when (symbol-value var)
5653 ;; This list has articles. So we delete all missing
5654 ;; articles from it.
5655 (setq m missing)
5656 (while m
5657 (set var (delq (pop m) (symbol-value var))))))))))
5658
5659 (defun gnus-update-marks ()
5660 "Enter the various lists of marked articles into the newsgroup info list."
5661 (let ((types gnus-article-mark-lists)
5662 (info (gnus-get-info gnus-newsgroup-name))
5663 type list newmarked symbol delta-marks)
5664 (when info
5665 ;; Add all marks lists to the list of marks lists.
5666 (while (setq type (pop types))
5667 (setq list (symbol-value
5668 (setq symbol
5669 (intern (format "gnus-newsgroup-%s" (car type))))))
5670
5671 (when list
5672 ;; Get rid of the entries of the articles that have the
5673 ;; default score.
5674 (when (and (eq (cdr type) 'score)
5675 gnus-save-score
5676 list)
5677 (let* ((arts list)
5678 (prev (cons nil list))
5679 (all prev))
5680 (while arts
5681 (if (or (not (consp (car arts)))
5682 (= (cdar arts) gnus-summary-default-score))
5683 (setcdr prev (cdr arts))
5684 (setq prev arts))
5685 (setq arts (cdr arts)))
5686 (setq list (cdr all)))))
5687
5688 (when (eq (cdr type) 'seen)
5689 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5690
5691 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5692 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5693
5694 (when (and (gnus-check-backend-function
5695 'request-set-mark gnus-newsgroup-name)
5696 (not (gnus-article-unpropagatable-p (cdr type))))
5697 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5698 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5699 (add (gnus-remove-from-range
5700 (gnus-copy-sequence list) old)))
5701 (when add
5702 (push (list add 'add (list (cdr type))) delta-marks))
5703 (when del
5704 (push (list del 'del (list (cdr type))) delta-marks))))
5705
5706 (when list
5707 (push (cons (cdr type) list) newmarked)))
5708
5709 (when delta-marks
5710 (unless (gnus-check-group gnus-newsgroup-name)
5711 (error "Can't open server for %s" gnus-newsgroup-name))
5712 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5713
5714 ;; Enter these new marks into the info of the group.
5715 (if (nthcdr 3 info)
5716 (setcar (nthcdr 3 info) newmarked)
5717 ;; Add the marks lists to the end of the info.
5718 (when newmarked
5719 (setcdr (nthcdr 2 info) (list newmarked))))
5720
5721 ;; Cut off the end of the info if there's nothing else there.
5722 (let ((i 5))
5723 (while (and (> i 2)
5724 (not (nth i info)))
5725 (when (nthcdr (decf i) info)
5726 (setcdr (nthcdr i info) nil)))))))
5727
5728 (defun gnus-set-mode-line (where)
5729 "Set the mode line of the article or summary buffers.
5730 If WHERE is `summary', the summary mode line format will be used."
5731 ;; Is this mode line one we keep updated?
5732 (when (and (memq where gnus-updated-mode-lines)
5733 (symbol-value
5734 (intern (format "gnus-%s-mode-line-format-spec" where))))
5735 (let (mode-string)
5736 (save-excursion
5737 ;; We evaluate this in the summary buffer since these
5738 ;; variables are buffer-local to that buffer.
5739 (set-buffer gnus-summary-buffer)
5740 ;; We bind all these variables that are used in the `eval' form
5741 ;; below.
5742 (let* ((mformat (symbol-value
5743 (intern
5744 (format "gnus-%s-mode-line-format-spec" where))))
5745 (gnus-tmp-group-name (gnus-mode-string-quote
5746 (gnus-group-decoded-name
5747 gnus-newsgroup-name)))
5748 (gnus-tmp-article-number (or gnus-current-article 0))
5749 (gnus-tmp-unread gnus-newsgroup-unreads)
5750 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5751 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5752 (gnus-tmp-unread-and-unselected
5753 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5754 (zerop gnus-tmp-unselected))
5755 "")
5756 ((zerop gnus-tmp-unselected)
5757 (format "{%d more}" gnus-tmp-unread-and-unticked))
5758 (t (format "{%d(+%d) more}"
5759 gnus-tmp-unread-and-unticked
5760 gnus-tmp-unselected))))
5761 (gnus-tmp-subject
5762 (if (and gnus-current-headers
5763 (vectorp gnus-current-headers))
5764 (gnus-mode-string-quote
5765 (mail-header-subject gnus-current-headers))
5766 ""))
5767 bufname-length max-len
5768 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5769 (setq mode-string (eval mformat))
5770 (setq bufname-length (if (string-match "%b" mode-string)
5771 (- (length
5772 (buffer-name
5773 (if (eq where 'summary)
5774 nil
5775 (get-buffer gnus-article-buffer))))
5776 2)
5777 0))
5778 (setq max-len (max 4 (if gnus-mode-non-string-length
5779 (- (window-width)
5780 gnus-mode-non-string-length
5781 bufname-length)
5782 (length mode-string))))
5783 ;; We might have to chop a bit of the string off...
5784 (when (> (length mode-string) max-len)
5785 (setq mode-string
5786 (concat (truncate-string-to-width mode-string (- max-len 3))
5787 "...")))
5788 ;; Pad the mode string a bit.
5789 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5790 ;; Update the mode line.
5791 (setq mode-line-buffer-identification
5792 (gnus-mode-line-buffer-identification (list mode-string)))
5793 (set-buffer-modified-p t))))
5794
5795 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5796 "Go through the HEADERS list and add all Xrefs to a hash table.
5797 The resulting hash table is returned, or nil if no Xrefs were found."
5798 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5799 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5800 (xref-hashtb (gnus-make-hashtable))
5801 start group entry number xrefs header)
5802 (while headers
5803 (setq header (pop headers))
5804 (when (and (setq xrefs (mail-header-xref header))
5805 (not (memq (setq number (mail-header-number header))
5806 unreads)))
5807 (setq start 0)
5808 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5809 (setq start (match-end 0))
5810 (setq group (if prefix
5811 (concat prefix (substring xrefs (match-beginning 1)
5812 (match-end 1)))
5813 (substring xrefs (match-beginning 1) (match-end 1))))
5814 (setq number
5815 (string-to-number (substring xrefs (match-beginning 2)
5816 (match-end 2))))
5817 (if (setq entry (gnus-gethash group xref-hashtb))
5818 (setcdr entry (cons number (cdr entry)))
5819 (gnus-sethash group (cons number nil) xref-hashtb)))))
5820 (and start xref-hashtb)))
5821
5822 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5823 "Look through all the headers and mark the Xrefs as read."
5824 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5825 name entry info xref-hashtb idlist method nth4)
5826 (save-excursion
5827 (set-buffer gnus-group-buffer)
5828 (when (setq xref-hashtb
5829 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5830 (mapatoms
5831 (lambda (group)
5832 (unless (string= from-newsgroup (setq name (symbol-name group)))
5833 (setq idlist (symbol-value group))
5834 ;; Dead groups are not updated.
5835 (and (prog1
5836 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5837 info (nth 2 entry))
5838 (when (stringp (setq nth4 (gnus-info-method info)))
5839 (setq nth4 (gnus-server-to-method nth4))))
5840 ;; Only do the xrefs if the group has the same
5841 ;; select method as the group we have just read.
5842 (or (gnus-methods-equal-p
5843 nth4 (gnus-find-method-for-group from-newsgroup))
5844 virtual
5845 (equal nth4 (setq method (gnus-find-method-for-group
5846 from-newsgroup)))
5847 (and (equal (car nth4) (car method))
5848 (equal (nth 1 nth4) (nth 1 method))))
5849 gnus-use-cross-reference
5850 (or (not (eq gnus-use-cross-reference t))
5851 virtual
5852 ;; Only do cross-references on subscribed
5853 ;; groups, if that is what is wanted.
5854 (<= (gnus-info-level info) gnus-level-subscribed))
5855 (gnus-group-make-articles-read name idlist))))
5856 xref-hashtb)))))
5857
5858 (defun gnus-compute-read-articles (group articles)
5859 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5860 (info (nth 2 entry))
5861 (active (gnus-active group))
5862 ninfo)
5863 (when entry
5864 ;; First peel off all invalid article numbers.
5865 (when active
5866 (let ((ids articles)
5867 id first)
5868 (while (setq id (pop ids))
5869 (when (and first (> id (cdr active)))
5870 ;; We'll end up in this situation in one particular
5871 ;; obscure situation. If you re-scan a group and get
5872 ;; a new article that is cross-posted to a different
5873 ;; group that has not been re-scanned, you might get
5874 ;; crossposted article that has a higher number than
5875 ;; Gnus believes possible. So we re-activate this
5876 ;; group as well. This might mean doing the
5877 ;; crossposting thingy will *increase* the number
5878 ;; of articles in some groups. Tsk, tsk.
5879 (setq active (or (gnus-activate-group group) active)))
5880 (when (or (> id (cdr active))
5881 (< id (car active)))
5882 (setq articles (delq id articles))))))
5883 ;; If the read list is nil, we init it.
5884 (if (and active
5885 (null (gnus-info-read info))
5886 (> (car active) 1))
5887 (setq ninfo (cons 1 (1- (car active))))
5888 (setq ninfo (gnus-info-read info)))
5889 ;; Then we add the read articles to the range.
5890 (gnus-add-to-range
5891 ninfo (setq articles (sort articles '<))))))
5892
5893 (defun gnus-group-make-articles-read (group articles)
5894 "Update the info of GROUP to say that ARTICLES are read."
5895 (let* ((num 0)
5896 (entry (gnus-gethash group gnus-newsrc-hashtb))
5897 (info (nth 2 entry))
5898 (active (gnus-active group))
5899 range)
5900 (when entry
5901 (setq range (gnus-compute-read-articles group articles))
5902 (save-excursion
5903 (set-buffer gnus-group-buffer)
5904 (gnus-undo-register
5905 `(progn
5906 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5907 (gnus-info-set-read ',info ',(gnus-info-read info))
5908 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5909 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5910 (gnus-group-update-group ,group t))))
5911 ;; Add the read articles to the range.
5912 (gnus-info-set-read info range)
5913 (gnus-request-set-mark group (list (list range 'add '(read))))
5914 ;; Then we have to re-compute how many unread
5915 ;; articles there are in this group.
5916 (when active
5917 (cond
5918 ((not range)
5919 (setq num (- (1+ (cdr active)) (car active))))
5920 ((not (listp (cdr range)))
5921 (setq num (- (cdr active) (- (1+ (cdr range))
5922 (car range)))))
5923 (t
5924 (while range
5925 (if (numberp (car range))
5926 (setq num (1+ num))
5927 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5928 (setq range (cdr range)))
5929 (setq num (- (cdr active) num))))
5930 ;; Update the number of unread articles.
5931 (setcar entry num)
5932 ;; Update the group buffer.
5933 (unless (gnus-ephemeral-group-p group)
5934 (gnus-group-update-group group t))))))
5935
5936 (defvar gnus-newsgroup-none-id 0)
5937
5938 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5939 (let ((cur nntp-server-buffer)
5940 (dependencies
5941 (or dependencies
5942 (save-excursion (set-buffer gnus-summary-buffer)
5943 gnus-newsgroup-dependencies)))
5944 headers id end ref
5945 (mail-parse-charset gnus-newsgroup-charset)
5946 (mail-parse-ignored-charsets
5947 (save-excursion (condition-case nil
5948 (set-buffer gnus-summary-buffer)
5949 (error))
5950 gnus-newsgroup-ignored-charsets)))
5951 (save-excursion
5952 (set-buffer nntp-server-buffer)
5953 ;; Translate all TAB characters into SPACE characters.
5954 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5955 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5956 (ietf-drums-unfold-fws)
5957 (gnus-run-hooks 'gnus-parse-headers-hook)
5958 (let ((case-fold-search t)
5959 in-reply-to header p lines chars)
5960 (goto-char (point-min))
5961 ;; Search to the beginning of the next header. Error messages
5962 ;; do not begin with 2 or 3.
5963 (while (re-search-forward "^[23][0-9]+ " nil t)
5964 (setq id nil
5965 ref nil)
5966 ;; This implementation of this function, with nine
5967 ;; search-forwards instead of the one re-search-forward and
5968 ;; a case (which basically was the old function) is actually
5969 ;; about twice as fast, even though it looks messier. You
5970 ;; can't have everything, I guess. Speed and elegance
5971 ;; doesn't always go hand in hand.
5972 (setq
5973 header
5974 (vector
5975 ;; Number.
5976 (prog1
5977 (read cur)
5978 (end-of-line)
5979 (setq p (point))
5980 (narrow-to-region (point)
5981 (or (and (search-forward "\n.\n" nil t)
5982 (- (point) 2))
5983 (point))))
5984 ;; Subject.
5985 (progn
5986 (goto-char p)
5987 (if (search-forward "\nsubject:" nil t)
5988 (funcall gnus-decode-encoded-word-function
5989 (nnheader-header-value))
5990 "(none)"))
5991 ;; From.
5992 (progn
5993 (goto-char p)
5994 (if (search-forward "\nfrom:" nil t)
5995 (funcall gnus-decode-encoded-address-function
5996 (nnheader-header-value))
5997 "(nobody)"))
5998 ;; Date.
5999 (progn
6000 (goto-char p)
6001 (if (search-forward "\ndate:" nil t)
6002 (nnheader-header-value) ""))
6003 ;; Message-ID.
6004 (progn
6005 (goto-char p)
6006 (setq id (if (re-search-forward
6007 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6008 ;; We do it this way to make sure the Message-ID
6009 ;; is (somewhat) syntactically valid.
6010 (buffer-substring (match-beginning 1)
6011 (match-end 1))
6012 ;; If there was no message-id, we just fake one
6013 ;; to make subsequent routines simpler.
6014 (nnheader-generate-fake-message-id))))
6015 ;; References.
6016 (progn
6017 (goto-char p)
6018 (if (search-forward "\nreferences:" nil t)
6019 (progn
6020 (setq end (point))
6021 (prog1
6022 (nnheader-header-value)
6023 (setq ref
6024 (buffer-substring
6025 (progn
6026 (end-of-line)
6027 (search-backward ">" end t)
6028 (1+ (point)))
6029 (progn
6030 (search-backward "<" end t)
6031 (point))))))
6032 ;; Get the references from the in-reply-to header if there
6033 ;; were no references and the in-reply-to header looks
6034 ;; promising.
6035 (if (and (search-forward "\nin-reply-to:" nil t)
6036 (setq in-reply-to (nnheader-header-value))
6037 (string-match "<[^>]+>" in-reply-to))
6038 (let (ref2)
6039 (setq ref (substring in-reply-to (match-beginning 0)
6040 (match-end 0)))
6041 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6042 (setq ref2 (substring in-reply-to (match-beginning 0)
6043 (match-end 0)))
6044 (when (> (length ref2) (length ref))
6045 (setq ref ref2)))
6046 ref)
6047 (setq ref nil))))
6048 ;; Chars.
6049 (progn
6050 (goto-char p)
6051 (if (search-forward "\nchars: " nil t)
6052 (if (numberp (setq chars (ignore-errors (read cur))))
6053 chars -1)
6054 -1))
6055 ;; Lines.
6056 (progn
6057 (goto-char p)
6058 (if (search-forward "\nlines: " nil t)
6059 (if (numberp (setq lines (ignore-errors (read cur))))
6060 lines -1)
6061 -1))
6062 ;; Xref.
6063 (progn
6064 (goto-char p)
6065 (and (search-forward "\nxref:" nil t)
6066 (nnheader-header-value)))
6067 ;; Extra.
6068 (when gnus-extra-headers
6069 (let ((extra gnus-extra-headers)
6070 out)
6071 (while extra
6072 (goto-char p)
6073 (when (search-forward
6074 (concat "\n" (symbol-name (car extra)) ":") nil t)
6075 (push (cons (car extra) (nnheader-header-value))
6076 out))
6077 (pop extra))
6078 out))))
6079 (when (equal id ref)
6080 (setq ref nil))
6081
6082 (when gnus-alter-header-function
6083 (funcall gnus-alter-header-function header)
6084 (setq id (mail-header-id header)
6085 ref (gnus-parent-id (mail-header-references header))))
6086
6087 (when (setq header
6088 (gnus-dependencies-add-header
6089 header dependencies force-new))
6090 (push header headers))
6091 (goto-char (point-max))
6092 (widen))
6093 (nreverse headers)))))
6094
6095 ;; Goes through the xover lines and returns a list of vectors
6096 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6097 force-new dependencies
6098 group also-fetch-heads)
6099 "Parse the news overview data in the server buffer.
6100 Return a list of headers that match SEQUENCE (see
6101 `nntp-retrieve-headers')."
6102 ;; Get the Xref when the users reads the articles since most/some
6103 ;; NNTP servers do not include Xrefs when using XOVER.
6104 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6105 (let ((mail-parse-charset gnus-newsgroup-charset)
6106 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6107 (cur nntp-server-buffer)
6108 (dependencies (or dependencies gnus-newsgroup-dependencies))
6109 (allp (cond
6110 ((eq gnus-read-all-available-headers t)
6111 t)
6112 ((and (stringp gnus-read-all-available-headers)
6113 group)
6114 (string-match gnus-read-all-available-headers group))
6115 (t
6116 nil)))
6117 number headers header)
6118 (save-excursion
6119 (set-buffer nntp-server-buffer)
6120 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6121 ;; Allow the user to mangle the headers before parsing them.
6122 (gnus-run-hooks 'gnus-parse-headers-hook)
6123 (goto-char (point-min))
6124 (gnus-parse-without-error
6125 (while (and (or sequence allp)
6126 (not (eobp)))
6127 (setq number (read cur))
6128 (when (not allp)
6129 (while (and sequence
6130 (< (car sequence) number))
6131 (setq sequence (cdr sequence))))
6132 (when (and (or allp
6133 (and sequence
6134 (eq number (car sequence))))
6135 (progn
6136 (setq sequence (cdr sequence))
6137 (setq header (inline
6138 (gnus-nov-parse-line
6139 number dependencies force-new)))))
6140 (push header headers))
6141 (forward-line 1)))
6142 ;; A common bug in inn is that if you have posted an article and
6143 ;; then retrieves the active file, it will answer correctly --
6144 ;; the new article is included. However, a NOV entry for the
6145 ;; article may not have been generated yet, so this may fail.
6146 ;; We work around this problem by retrieving the last few
6147 ;; headers using HEAD.
6148 (if (or (not also-fetch-heads)
6149 (not sequence))
6150 ;; We (probably) got all the headers.
6151 (nreverse headers)
6152 (let ((gnus-nov-is-evil t))
6153 (nconc
6154 (nreverse headers)
6155 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6156 (gnus-get-newsgroup-headers))))))))
6157
6158 (defun gnus-article-get-xrefs ()
6159 "Fill in the Xref value in `gnus-current-headers', if necessary.
6160 This is meant to be called in `gnus-article-internal-prepare-hook'."
6161 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6162 gnus-current-headers)))
6163 (or (not gnus-use-cross-reference)
6164 (not headers)
6165 (and (mail-header-xref headers)
6166 (not (string= (mail-header-xref headers) "")))
6167 (let ((case-fold-search t)
6168 xref)
6169 (save-restriction
6170 (nnheader-narrow-to-headers)
6171 (goto-char (point-min))
6172 (when (or (and (not (eobp))
6173 (eq (downcase (char-after)) ?x)
6174 (looking-at "Xref:"))
6175 (search-forward "\nXref:" nil t))
6176 (goto-char (1+ (match-end 0)))
6177 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6178 (mail-header-set-xref headers xref)))))))
6179
6180 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6181 "Find article ID and insert the summary line for that article.
6182 OLD-HEADER can either be a header or a line number to insert
6183 the subject line on."
6184 (let* ((line (and (numberp old-header) old-header))
6185 (old-header (and (vectorp old-header) old-header))
6186 (header (cond ((and old-header use-old-header)
6187 old-header)
6188 ((and (numberp id)
6189 (gnus-number-to-header id))
6190 (gnus-number-to-header id))
6191 (t
6192 (gnus-read-header id))))
6193 (number (and (numberp id) id))
6194 d)
6195 (when header
6196 ;; Rebuild the thread that this article is part of and go to the
6197 ;; article we have fetched.
6198 (when (and (not gnus-show-threads)
6199 old-header)
6200 (when (and number
6201 (setq d (gnus-data-find (mail-header-number old-header))))
6202 (goto-char (gnus-data-pos d))
6203 (gnus-data-remove
6204 number
6205 (- (gnus-point-at-bol)
6206 (prog1
6207 (1+ (gnus-point-at-eol))
6208 (gnus-delete-line))))))
6209 ;; Remove list identifiers from subject.
6210 (when gnus-list-identifiers
6211 (let ((gnus-newsgroup-headers (list header)))
6212 (gnus-summary-remove-list-identifiers)))
6213 (when old-header
6214 (mail-header-set-number header (mail-header-number old-header)))
6215 (setq gnus-newsgroup-sparse
6216 (delq (setq number (mail-header-number header))
6217 gnus-newsgroup-sparse))
6218 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6219 (push number gnus-newsgroup-limit)
6220 (gnus-rebuild-thread (mail-header-id header) line)
6221 (gnus-summary-goto-subject number nil t))
6222 (when (and (numberp number)
6223 (> number 0))
6224 ;; We have to update the boundaries even if we can't fetch the
6225 ;; article if ID is a number -- so that the next `P' or `N'
6226 ;; command will fetch the previous (or next) article even
6227 ;; if the one we tried to fetch this time has been canceled.
6228 (when (> number gnus-newsgroup-end)
6229 (setq gnus-newsgroup-end number))
6230 (when (< number gnus-newsgroup-begin)
6231 (setq gnus-newsgroup-begin number))
6232 (setq gnus-newsgroup-unselected
6233 (delq number gnus-newsgroup-unselected)))
6234 ;; Report back a success?
6235 (and header (mail-header-number header))))
6236
6237 ;;; Process/prefix in the summary buffer
6238
6239 (defun gnus-summary-work-articles (n)
6240 "Return a list of articles to be worked upon.
6241 The prefix argument, the list of process marked articles, and the
6242 current article will be taken into consideration."
6243 (save-excursion
6244 (set-buffer gnus-summary-buffer)
6245 (cond
6246 (n
6247 ;; A numerical prefix has been given.
6248 (setq n (prefix-numeric-value n))
6249 (let ((backward (< n 0))
6250 (n (abs (prefix-numeric-value n)))
6251 articles article)
6252 (save-excursion
6253 (while
6254 (and (> n 0)
6255 (push (setq article (gnus-summary-article-number))
6256 articles)
6257 (if backward
6258 (gnus-summary-find-prev nil article)
6259 (gnus-summary-find-next nil article)))
6260 (decf n)))
6261 (nreverse articles)))
6262 ((and (gnus-region-active-p) (mark))
6263 (message "region active")
6264 ;; Work on the region between point and mark.
6265 (let ((max (max (point) (mark)))
6266 articles article)
6267 (save-excursion
6268 (goto-char (min (point) (mark)))
6269 (while
6270 (and
6271 (push (setq article (gnus-summary-article-number)) articles)
6272 (gnus-summary-find-next nil article)
6273 (< (point) max)))
6274 (nreverse articles))))
6275 (gnus-newsgroup-processable
6276 ;; There are process-marked articles present.
6277 ;; Save current state.
6278 (gnus-summary-save-process-mark)
6279 ;; Return the list.
6280 (reverse gnus-newsgroup-processable))
6281 (t
6282 ;; Just return the current article.
6283 (list (gnus-summary-article-number))))))
6284
6285 (defmacro gnus-summary-iterate (arg &rest forms)
6286 "Iterate over the process/prefixed articles and do FORMS.
6287 ARG is the interactive prefix given to the command. FORMS will be
6288 executed with point over the summary line of the articles."
6289 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6290 `(let ((,articles (gnus-summary-work-articles ,arg)))
6291 (while ,articles
6292 (gnus-summary-goto-subject (car ,articles))
6293 ,@forms
6294 (pop ,articles)))))
6295
6296 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6297 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6298
6299 (defun gnus-summary-save-process-mark ()
6300 "Push the current set of process marked articles on the stack."
6301 (interactive)
6302 (push (copy-sequence gnus-newsgroup-processable)
6303 gnus-newsgroup-process-stack))
6304
6305 (defun gnus-summary-kill-process-mark ()
6306 "Push the current set of process marked articles on the stack and unmark."
6307 (interactive)
6308 (gnus-summary-save-process-mark)
6309 (gnus-summary-unmark-all-processable))
6310
6311 (defun gnus-summary-yank-process-mark ()
6312 "Pop the last process mark state off the stack and restore it."
6313 (interactive)
6314 (unless gnus-newsgroup-process-stack
6315 (error "Empty mark stack"))
6316 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6317
6318 (defun gnus-summary-process-mark-set (set)
6319 "Make SET into the current process marked articles."
6320 (gnus-summary-unmark-all-processable)
6321 (while set
6322 (gnus-summary-set-process-mark (pop set))))
6323
6324 ;;; Searching and stuff
6325
6326 (defun gnus-summary-search-group (&optional backward use-level)
6327 "Search for next unread newsgroup.
6328 If optional argument BACKWARD is non-nil, search backward instead."
6329 (save-excursion
6330 (set-buffer gnus-group-buffer)
6331 (when (gnus-group-search-forward
6332 backward nil (if use-level (gnus-group-group-level) nil))
6333 (gnus-group-group-name))))
6334
6335 (defun gnus-summary-best-group (&optional exclude-group)
6336 "Find the name of the best unread group.
6337 If EXCLUDE-GROUP, do not go to this group."
6338 (save-excursion
6339 (set-buffer gnus-group-buffer)
6340 (save-excursion
6341 (gnus-group-best-unread-group exclude-group))))
6342
6343 (defun gnus-summary-find-next (&optional unread article backward)
6344 (if backward
6345 (gnus-summary-find-prev unread article)
6346 (let* ((dummy (gnus-summary-article-intangible-p))
6347 (article (or article (gnus-summary-article-number)))
6348 (data (gnus-data-find-list article))
6349 result)
6350 (when (and (not dummy)
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-prev (&optional unread article)
6382 (let* ((eobp (eobp))
6383 (article (or article (gnus-summary-article-number)))
6384 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6385 result)
6386 (when (and (not eobp)
6387 (or (not gnus-summary-check-current)
6388 (not unread)
6389 (not (gnus-data-unread-p (car data)))))
6390 (setq data (cdr data)))
6391 (when (setq result
6392 (if unread
6393 (progn
6394 (while data
6395 (unless (memq (gnus-data-number (car data))
6396 (cond
6397 ((eq gnus-auto-goto-ignores
6398 'always-undownloaded)
6399 gnus-newsgroup-undownloaded)
6400 (gnus-plugged
6401 nil)
6402 ((eq gnus-auto-goto-ignores
6403 'unfetched)
6404 gnus-newsgroup-unfetched)
6405 ((eq gnus-auto-goto-ignores
6406 'undownloaded)
6407 gnus-newsgroup-undownloaded)))
6408 (when (gnus-data-unread-p (car data))
6409 (setq result (car data)
6410 data nil)))
6411 (setq data (cdr data)))
6412 result)
6413 (car data)))
6414 (goto-char (gnus-data-pos result))
6415 (gnus-data-number result))))
6416
6417 (defun gnus-summary-find-subject (subject &optional unread backward article)
6418 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6419 (article (or article (gnus-summary-article-number)))
6420 (articles (gnus-data-list backward))
6421 (arts (gnus-data-find-list article articles))
6422 result)
6423 (when (or (not gnus-summary-check-current)
6424 (not unread)
6425 (not (gnus-data-unread-p (car arts))))
6426 (setq arts (cdr arts)))
6427 (while arts
6428 (and (or (not unread)
6429 (gnus-data-unread-p (car arts)))
6430 (vectorp (gnus-data-header (car arts)))
6431 (gnus-subject-equal
6432 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6433 (setq result (car arts)
6434 arts nil))
6435 (setq arts (cdr arts)))
6436 (and result
6437 (goto-char (gnus-data-pos result))
6438 (gnus-data-number result))))
6439
6440 (defun gnus-summary-search-forward (&optional unread subject backward)
6441 "Search forward for an article.
6442 If UNREAD, look for unread articles. If SUBJECT, look for
6443 articles with that subject. If BACKWARD, search backward instead."
6444 (cond (subject (gnus-summary-find-subject subject unread backward))
6445 (backward (gnus-summary-find-prev unread))
6446 (t (gnus-summary-find-next unread))))
6447
6448 (defun gnus-recenter (&optional n)
6449 "Center point in window and redisplay frame.
6450 Also do horizontal recentering."
6451 (interactive "P")
6452 (when (and gnus-auto-center-summary
6453 (not (eq gnus-auto-center-summary 'vertical)))
6454 (gnus-horizontal-recenter))
6455 (recenter n))
6456
6457 (defun gnus-summary-recenter ()
6458 "Center point in the summary window.
6459 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6460 displayed, no centering will be performed."
6461 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6462 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6463 (interactive)
6464 ;; The user has to want it.
6465 (when gnus-auto-center-summary
6466 (let* ((top (cond ((< (window-height) 4) 0)
6467 ((< (window-height) 7) 1)
6468 (t (if (numberp gnus-auto-center-summary)
6469 gnus-auto-center-summary
6470 2))))
6471 (height (1- (window-height)))
6472 (bottom (save-excursion (goto-char (point-max))
6473 (forward-line (- height))
6474 (point)))
6475 (window (get-buffer-window (current-buffer))))
6476 (when (get-buffer-window gnus-article-buffer)
6477 ;; Only do recentering when the article buffer is displayed,
6478 ;; Set the window start to either `bottom', which is the biggest
6479 ;; possible valid number, or the second line from the top,
6480 ;; whichever is the least.
6481 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6482 (if (> bottom top-pos)
6483 ;; Keep the second line from the top visible
6484 (set-window-start window top-pos t)
6485 ;; Try to keep the bottom line visible; if it's partially
6486 ;; obscured, either scroll one more line to make it fully
6487 ;; visible, or revert to using TOP-POS.
6488 (save-excursion
6489 (goto-char (point-max))
6490 (forward-line -1)
6491 (let ((last-line-start (point)))
6492 (goto-char bottom)
6493 (set-window-start window (point) t)
6494 (when (not (pos-visible-in-window-p last-line-start window))
6495 (forward-line 1)
6496 (set-window-start window (min (point) top-pos) t)))))))
6497 ;; Do horizontal recentering while we're at it.
6498 (when (and (get-buffer-window (current-buffer) t)
6499 (not (eq gnus-auto-center-summary 'vertical)))
6500 (let ((selected (selected-window)))
6501 (select-window (get-buffer-window (current-buffer) t))
6502 (gnus-summary-position-point)
6503 (gnus-horizontal-recenter)
6504 (select-window selected))))))
6505
6506 (defun gnus-summary-jump-to-group (newsgroup)
6507 "Move point to NEWSGROUP in group mode buffer."
6508 ;; Keep update point of group mode buffer if visible.
6509 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6510 (save-window-excursion
6511 ;; Take care of tree window mode.
6512 (when (get-buffer-window gnus-group-buffer)
6513 (pop-to-buffer gnus-group-buffer))
6514 (gnus-group-jump-to-group newsgroup))
6515 (save-excursion
6516 ;; Take care of tree window mode.
6517 (if (get-buffer-window gnus-group-buffer)
6518 (pop-to-buffer gnus-group-buffer)
6519 (set-buffer gnus-group-buffer))
6520 (gnus-group-jump-to-group newsgroup))))
6521
6522 ;; This function returns a list of article numbers based on the
6523 ;; difference between the ranges of read articles in this group and
6524 ;; the range of active articles.
6525 (defun gnus-list-of-unread-articles (group)
6526 (let* ((read (gnus-info-read (gnus-get-info group)))
6527 (active (or (gnus-active group) (gnus-activate-group group)))
6528 (last (cdr active))
6529 first nlast unread)
6530 ;; If none are read, then all are unread.
6531 (if (not read)
6532 (setq first (car active))
6533 ;; If the range of read articles is a single range, then the
6534 ;; first unread article is the article after the last read
6535 ;; article. Sounds logical, doesn't it?
6536 (if (and (not (listp (cdr read)))
6537 (or (< (car read) (car active))
6538 (progn (setq read (list read))
6539 nil)))
6540 (setq first (max (car active) (1+ (cdr read))))
6541 ;; `read' is a list of ranges.
6542 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6543 (caar read)))
6544 1)
6545 (setq first (car active)))
6546 (while read
6547 (when first
6548 (while (< first nlast)
6549 (setq unread (cons first unread)
6550 first (1+ first))))
6551 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6552 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6553 (setq read (cdr read)))))
6554 ;; And add the last unread articles.
6555 (while (<= first last)
6556 (setq unread (cons first unread)
6557 first (1+ first)))
6558 ;; Return the list of unread articles.
6559 (delq 0 (nreverse unread))))
6560
6561 (defun gnus-list-of-read-articles (group)
6562 "Return a list of unread, unticked and non-dormant articles."
6563 (let* ((info (gnus-get-info group))
6564 (marked (gnus-info-marks info))
6565 (active (gnus-active group)))
6566 (and info active
6567 (gnus-list-range-difference
6568 (gnus-list-range-difference
6569 (gnus-sorted-complement
6570 (gnus-uncompress-range active)
6571 (gnus-list-of-unread-articles group))
6572 (cdr (assq 'dormant marked)))
6573 (cdr (assq 'tick marked))))))
6574
6575 ;; This function returns a sequence of article numbers based on the
6576 ;; difference between the ranges of read articles in this group and
6577 ;; the range of active articles.
6578 (defun gnus-sequence-of-unread-articles (group)
6579 (let* ((read (gnus-info-read (gnus-get-info group)))
6580 (active (or (gnus-active group) (gnus-activate-group group)))
6581 (last (cdr active))
6582 first nlast unread)
6583 ;; If none are read, then all are unread.
6584 (if (not read)
6585 (setq first (car active))
6586 ;; If the range of read articles is a single range, then the
6587 ;; first unread article is the article after the last read
6588 ;; article. Sounds logical, doesn't it?
6589 (if (and (not (listp (cdr read)))
6590 (or (< (car read) (car active))
6591 (progn (setq read (list read))
6592 nil)))
6593 (setq first (max (car active) (1+ (cdr read))))
6594 ;; `read' is a list of ranges.
6595 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6596 (caar read)))
6597 1)
6598 (setq first (car active)))
6599 (while read
6600 (when first
6601 (push (cons first nlast) unread))
6602 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6603 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6604 (setq read (cdr read)))))
6605 ;; And add the last unread articles.
6606 (cond ((not (and first last))
6607 nil)
6608 ((< first last)
6609 (push (cons first last) unread))
6610 ((= first last)
6611 (push first unread)))
6612 ;; Return the sequence of unread articles.
6613 (delq 0 (nreverse unread))))
6614
6615 ;; Various summary commands
6616
6617 (defun gnus-summary-select-article-buffer ()
6618 "Reconfigure windows to show article buffer."
6619 (interactive)
6620 (if (not (gnus-buffer-live-p gnus-article-buffer))
6621 (error "There is no article buffer for this summary buffer")
6622 (gnus-configure-windows 'article)
6623 (select-window (get-buffer-window gnus-article-buffer))))
6624
6625 (defun gnus-summary-universal-argument (arg)
6626 "Perform any operation on all articles that are process/prefixed."
6627 (interactive "P")
6628 (let ((articles (gnus-summary-work-articles arg))
6629 func article)
6630 (if (eq
6631 (setq
6632 func
6633 (key-binding
6634 (read-key-sequence
6635 (substitute-command-keys
6636 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6637 'undefined)
6638 (gnus-error 1 "Undefined key")
6639 (save-excursion
6640 (while articles
6641 (gnus-summary-goto-subject (setq article (pop articles)))
6642 (let (gnus-newsgroup-processable)
6643 (command-execute func))
6644 (gnus-summary-remove-process-mark article)))))
6645 (gnus-summary-position-point))
6646
6647 (defun gnus-summary-toggle-truncation (&optional arg)
6648 "Toggle truncation of summary lines.
6649 With ARG, turn line truncation on if ARG is positive."
6650 (interactive "P")
6651 (setq truncate-lines
6652 (if (null arg) (not truncate-lines)
6653 (> (prefix-numeric-value arg) 0)))
6654 (redraw-display))
6655
6656 (defun gnus-summary-find-for-reselect ()
6657 "Return the number of an article to stay on across a reselect.
6658 The current article is considered, then following articles, then previous
6659 articles. An article is sought which is not cancelled and isn't a temporary
6660 insertion from another group. If there's no such then return a dummy 0."
6661 (let (found)
6662 (dolist (rev '(nil t))
6663 (unless found ; don't demand the reverse list if we don't need it
6664 (let ((data (gnus-data-find-list
6665 (gnus-summary-article-number) (gnus-data-list rev))))
6666 (while (and data (not found))
6667 (if (and (< 0 (gnus-data-number (car data)))
6668 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6669 (setq found (gnus-data-number (car data))))
6670 (setq data (cdr data))))))
6671 (or found 0)))
6672
6673 (defun gnus-summary-reselect-current-group (&optional all rescan)
6674 "Exit and then reselect the current newsgroup.
6675 The prefix argument ALL means to select all articles."
6676 (interactive "P")
6677 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6678 (error "Ephemeral groups can't be reselected"))
6679 (let ((current-subject (gnus-summary-find-for-reselect))
6680 (group gnus-newsgroup-name))
6681 (setq gnus-newsgroup-begin nil)
6682 (gnus-summary-exit nil 'leave-hidden)
6683 ;; We have to adjust the point of group mode buffer because
6684 ;; point was moved to the next unread newsgroup by exiting.
6685 (gnus-summary-jump-to-group group)
6686 (when rescan
6687 (save-excursion
6688 (gnus-group-get-new-news-this-group 1)))
6689 (gnus-group-read-group all t)
6690 (gnus-summary-goto-subject current-subject nil t)))
6691
6692 (defun gnus-summary-rescan-group (&optional all)
6693 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6694 (interactive "P")
6695 (gnus-summary-reselect-current-group all t))
6696
6697 (defun gnus-summary-update-info (&optional non-destructive)
6698 (save-excursion
6699 (let ((group gnus-newsgroup-name))
6700 (when group
6701 (when gnus-newsgroup-kill-headers
6702 (setq gnus-newsgroup-killed
6703 (gnus-compress-sequence
6704 (gnus-sorted-union
6705 (gnus-list-range-intersection
6706 gnus-newsgroup-unselected gnus-newsgroup-killed)
6707 gnus-newsgroup-unreads)
6708 t)))
6709 (unless (listp (cdr gnus-newsgroup-killed))
6710 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6711 (let ((headers gnus-newsgroup-headers))
6712 ;; Set the new ranges of read articles.
6713 (save-excursion
6714 (set-buffer gnus-group-buffer)
6715 (gnus-undo-force-boundary))
6716 (gnus-update-read-articles
6717 group (gnus-sorted-union
6718 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6719 ;; Set the current article marks.
6720 (let ((gnus-newsgroup-scored
6721 (if (and (not gnus-save-score)
6722 (not non-destructive))
6723 nil
6724 gnus-newsgroup-scored)))
6725 (save-excursion
6726 (gnus-update-marks)))
6727 ;; Do the cross-ref thing.
6728 (when gnus-use-cross-reference
6729 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6730 ;; Do not switch windows but change the buffer to work.
6731 (set-buffer gnus-group-buffer)
6732 (unless (gnus-ephemeral-group-p group)
6733 (gnus-group-update-group group)))))))
6734
6735 (defun gnus-summary-save-newsrc (&optional force)
6736 "Save the current number of read/marked articles in the dribble buffer.
6737 The dribble buffer will then be saved.
6738 If FORCE (the prefix), also save the .newsrc file(s)."
6739 (interactive "P")
6740 (gnus-summary-update-info t)
6741 (if force
6742 (gnus-save-newsrc-file)
6743 (gnus-dribble-save)))
6744
6745 (defun gnus-summary-exit (&optional temporary leave-hidden)
6746 "Exit reading current newsgroup, and then return to group selection mode.
6747 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6748 (interactive)
6749 (gnus-set-global-variables)
6750 (when (gnus-buffer-live-p gnus-article-buffer)
6751 (save-excursion
6752 (set-buffer gnus-article-buffer)
6753 (mm-destroy-parts gnus-article-mime-handles)
6754 ;; Set it to nil for safety reason.
6755 (setq gnus-article-mime-handle-alist nil)
6756 (setq gnus-article-mime-handles nil)))
6757 (gnus-kill-save-kill-buffer)
6758 (gnus-async-halt-prefetch)
6759 (let* ((group gnus-newsgroup-name)
6760 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6761 (gnus-group-is-exiting-p t)
6762 (mode major-mode)
6763 (group-point nil)
6764 (buf (current-buffer)))
6765 (unless quit-config
6766 ;; Do adaptive scoring, and possibly save score files.
6767 (when gnus-newsgroup-adaptive
6768 (gnus-score-adaptive))
6769 (when gnus-use-scoring
6770 (gnus-score-save)))
6771 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6772 ;; If we have several article buffers, we kill them at exit.
6773 (unless gnus-single-article-buffer
6774 (gnus-kill-buffer gnus-original-article-buffer)
6775 (setq gnus-article-current nil))
6776 (when gnus-use-cache
6777 (gnus-cache-possibly-remove-articles)
6778 (gnus-cache-save-buffers))
6779 (gnus-async-prefetch-remove-group group)
6780 (when gnus-suppress-duplicates
6781 (gnus-dup-enter-articles))
6782 (when gnus-use-trees
6783 (gnus-tree-close group))
6784 (when gnus-use-cache
6785 (gnus-cache-write-active))
6786 ;; Remove entries for this group.
6787 (nnmail-purge-split-history (gnus-group-real-name group))
6788 ;; Make all changes in this group permanent.
6789 (unless quit-config
6790 (gnus-run-hooks 'gnus-exit-group-hook)
6791 (gnus-summary-update-info))
6792 (gnus-close-group group)
6793 ;; Make sure where we were, and go to next newsgroup.
6794 (set-buffer gnus-group-buffer)
6795 (unless quit-config
6796 (gnus-group-jump-to-group group))
6797 (gnus-run-hooks 'gnus-summary-exit-hook)
6798 (unless (or quit-config
6799 ;; If this group has disappeared from the summary
6800 ;; buffer, don't skip forwards.
6801 (not (string= group (gnus-group-group-name))))
6802 (gnus-group-next-unread-group 1))
6803 (setq group-point (point))
6804 (if temporary
6805 nil ;Nothing to do.
6806 ;; If we have several article buffers, we kill them at exit.
6807 (unless gnus-single-article-buffer
6808 (gnus-kill-buffer gnus-article-buffer)
6809 (gnus-kill-buffer gnus-original-article-buffer)
6810 (setq gnus-article-current nil))
6811 (set-buffer buf)
6812 (if (not gnus-kill-summary-on-exit)
6813 (progn
6814 (gnus-deaden-summary)
6815 (setq mode nil))
6816 ;; We set all buffer-local variables to nil. It is unclear why
6817 ;; this is needed, but if we don't, buffer-local variables are
6818 ;; not garbage-collected, it seems. This would the lead to en
6819 ;; ever-growing Emacs.
6820 (gnus-summary-clear-local-variables)
6821 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6822 (gnus-summary-clear-local-variables))
6823 (when (get-buffer gnus-article-buffer)
6824 (bury-buffer gnus-article-buffer))
6825 ;; We clear the global counterparts of the buffer-local
6826 ;; variables as well, just to be on the safe side.
6827 (set-buffer gnus-group-buffer)
6828 (gnus-summary-clear-local-variables)
6829 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6830 (gnus-summary-clear-local-variables))
6831 ;; Return to group mode buffer.
6832 (when (eq mode 'gnus-summary-mode)
6833 (gnus-kill-buffer buf)))
6834 (setq gnus-current-select-method gnus-select-method)
6835 (set-buffer gnus-group-buffer)
6836 (if quit-config
6837 (gnus-handle-ephemeral-exit quit-config)
6838 (goto-char group-point)
6839 ;; If gnus-group-buffer is already displayed, make sure we also move
6840 ;; the cursor in the window that displays it.
6841 (let ((win (get-buffer-window (current-buffer) 0)))
6842 (if win (set-window-point win (point))))
6843 (unless leave-hidden
6844 (gnus-configure-windows 'group 'force)))
6845 ;; Clear the current group name.
6846 (unless quit-config
6847 (setq gnus-newsgroup-name nil)))))
6848
6849 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6850 (defun gnus-summary-exit-no-update (&optional no-questions)
6851 "Quit reading current newsgroup without updating read article info."
6852 (interactive)
6853 (let* ((group gnus-newsgroup-name)
6854 (gnus-group-is-exiting-p t)
6855 (gnus-group-is-exiting-without-update-p t)
6856 (quit-config (gnus-group-quit-config group)))
6857 (when (or no-questions
6858 gnus-expert-user
6859 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6860 (gnus-async-halt-prefetch)
6861 (run-hooks 'gnus-summary-prepare-exit-hook)
6862 (when (gnus-buffer-live-p gnus-article-buffer)
6863 (save-excursion
6864 (set-buffer gnus-article-buffer)
6865 (mm-destroy-parts gnus-article-mime-handles)
6866 ;; Set it to nil for safety reason.
6867 (setq gnus-article-mime-handle-alist nil)
6868 (setq gnus-article-mime-handles nil)))
6869 ;; If we have several article buffers, we kill them at exit.
6870 (unless gnus-single-article-buffer
6871 (gnus-kill-buffer gnus-article-buffer)
6872 (gnus-kill-buffer gnus-original-article-buffer)
6873 (setq gnus-article-current nil))
6874 (if (not gnus-kill-summary-on-exit)
6875 (gnus-deaden-summary)
6876 (gnus-close-group group)
6877 (gnus-summary-clear-local-variables)
6878 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6879 (gnus-summary-clear-local-variables))
6880 (set-buffer gnus-group-buffer)
6881 (gnus-summary-clear-local-variables)
6882 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6883 (gnus-summary-clear-local-variables))
6884 (gnus-kill-buffer gnus-summary-buffer))
6885 (unless gnus-single-article-buffer
6886 (setq gnus-article-current nil))
6887 (when gnus-use-trees
6888 (gnus-tree-close group))
6889 (gnus-async-prefetch-remove-group group)
6890 (when (get-buffer gnus-article-buffer)
6891 (bury-buffer gnus-article-buffer))
6892 ;; Return to the group buffer.
6893 (gnus-configure-windows 'group 'force)
6894 ;; Clear the current group name.
6895 (setq gnus-newsgroup-name nil)
6896 (unless (gnus-ephemeral-group-p group)
6897 (gnus-group-update-group group))
6898 (when (equal (gnus-group-group-name) group)
6899 (gnus-group-next-unread-group 1))
6900 (when quit-config
6901 (gnus-handle-ephemeral-exit quit-config)))))
6902
6903 (defun gnus-handle-ephemeral-exit (quit-config)
6904 "Handle movement when leaving an ephemeral group.
6905 The state which existed when entering the ephemeral is reset."
6906 (if (not (buffer-name (car quit-config)))
6907 (gnus-configure-windows 'group 'force)
6908 (set-buffer (car quit-config))
6909 (cond ((eq major-mode 'gnus-summary-mode)
6910 (gnus-set-global-variables))
6911 ((eq major-mode 'gnus-article-mode)
6912 (save-excursion
6913 ;; The `gnus-summary-buffer' variable may point
6914 ;; to the old summary buffer when using a single
6915 ;; article buffer.
6916 (unless (gnus-buffer-live-p gnus-summary-buffer)
6917 (set-buffer gnus-group-buffer))
6918 (set-buffer gnus-summary-buffer)
6919 (gnus-set-global-variables))))
6920 (if (or (eq (cdr quit-config) 'article)
6921 (eq (cdr quit-config) 'pick))
6922 (progn
6923 ;; The current article may be from the ephemeral group
6924 ;; thus it is best that we reload this article
6925 ;;
6926 ;; If we're exiting from a large digest, this can be
6927 ;; extremely slow. So, it's better not to reload it. -- jh.
6928 ;;(gnus-summary-show-article)
6929 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6930 (gnus-configure-windows 'pick 'force)
6931 (gnus-configure-windows (cdr quit-config) 'force)))
6932 (gnus-configure-windows (cdr quit-config) 'force))
6933 (when (eq major-mode 'gnus-summary-mode)
6934 (gnus-summary-next-subject 1 nil t)
6935 (gnus-summary-recenter)
6936 (gnus-summary-position-point))))
6937
6938 ;;; Dead summaries.
6939
6940 (defvar gnus-dead-summary-mode-map nil)
6941
6942 (unless gnus-dead-summary-mode-map
6943 (setq gnus-dead-summary-mode-map (make-keymap))
6944 (suppress-keymap gnus-dead-summary-mode-map)
6945 (substitute-key-definition
6946 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6947 (dolist (key '("\C-d" "\r" "\177" [delete]))
6948 (define-key gnus-dead-summary-mode-map
6949 key 'gnus-summary-wake-up-the-dead))
6950 (dolist (key '("q" "Q"))
6951 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6952
6953 (defvar gnus-dead-summary-mode nil
6954 "Minor mode for Gnus summary buffers.")
6955
6956 (defun gnus-dead-summary-mode (&optional arg)
6957 "Minor mode for Gnus summary buffers."
6958 (interactive "P")
6959 (when (eq major-mode 'gnus-summary-mode)
6960 (make-local-variable 'gnus-dead-summary-mode)
6961 (setq gnus-dead-summary-mode
6962 (if (null arg) (not gnus-dead-summary-mode)
6963 (> (prefix-numeric-value arg) 0)))
6964 (when gnus-dead-summary-mode
6965 (gnus-add-minor-mode
6966 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6967
6968 (defun gnus-deaden-summary ()
6969 "Make the current summary buffer into a dead summary buffer."
6970 ;; Kill any previous dead summary buffer.
6971 (when (and gnus-dead-summary
6972 (buffer-name gnus-dead-summary))
6973 (save-excursion
6974 (set-buffer gnus-dead-summary)
6975 (when gnus-dead-summary-mode
6976 (kill-buffer (current-buffer)))))
6977 ;; Make this the current dead summary.
6978 (setq gnus-dead-summary (current-buffer))
6979 (gnus-dead-summary-mode 1)
6980 (let ((name (buffer-name)))
6981 (when (string-match "Summary" name)
6982 (rename-buffer
6983 (concat (substring name 0 (match-beginning 0)) "Dead "
6984 (substring name (match-beginning 0)))
6985 t)
6986 (bury-buffer))))
6987
6988 (defun gnus-kill-or-deaden-summary (buffer)
6989 "Kill or deaden the summary BUFFER."
6990 (save-excursion
6991 (when (and (buffer-name buffer)
6992 (not gnus-single-article-buffer))
6993 (save-excursion
6994 (set-buffer buffer)
6995 (gnus-kill-buffer gnus-article-buffer)
6996 (gnus-kill-buffer gnus-original-article-buffer)))
6997 (cond
6998 ;; Kill the buffer.
6999 (gnus-kill-summary-on-exit
7000 (when (and gnus-use-trees
7001 (gnus-buffer-exists-p buffer))
7002 (save-excursion
7003 (set-buffer buffer)
7004 (gnus-tree-close gnus-newsgroup-name)))
7005 (gnus-kill-buffer buffer))
7006 ;; Deaden the buffer.
7007 ((gnus-buffer-exists-p buffer)
7008 (save-excursion
7009 (set-buffer buffer)
7010 (gnus-deaden-summary))))))
7011
7012 (defun gnus-summary-wake-up-the-dead (&rest args)
7013 "Wake up the dead summary buffer."
7014 (interactive)
7015 (gnus-dead-summary-mode -1)
7016 (let ((name (buffer-name)))
7017 (when (string-match "Dead " name)
7018 (rename-buffer
7019 (concat (substring name 0 (match-beginning 0))
7020 (substring name (match-end 0)))
7021 t)))
7022 (gnus-message 3 "This dead summary is now alive again"))
7023
7024 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7025 (defun gnus-summary-fetch-faq (&optional faq-dir)
7026 "Fetch the FAQ for the current group.
7027 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7028 in."
7029 (interactive
7030 (list
7031 (when current-prefix-arg
7032 (completing-read
7033 "FAQ dir: " (and (listp gnus-group-faq-directory)
7034 (mapcar (lambda (file) (list file))
7035 gnus-group-faq-directory))))))
7036 (let (gnus-faq-buffer)
7037 (when (setq gnus-faq-buffer
7038 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7039 (gnus-configure-windows 'summary-faq))))
7040
7041 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7042 (defun gnus-summary-describe-group (&optional force)
7043 "Describe the current newsgroup."
7044 (interactive "P")
7045 (gnus-group-describe-group force gnus-newsgroup-name))
7046
7047 (defun gnus-summary-describe-briefly ()
7048 "Describe summary mode commands briefly."
7049 (interactive)
7050 (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")))
7051
7052 ;; Walking around group mode buffer from summary mode.
7053
7054 (defun gnus-summary-next-group (&optional no-article target-group backward)
7055 "Exit current newsgroup and then select next unread newsgroup.
7056 If prefix argument NO-ARTICLE is non-nil, no article is selected
7057 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7058 previous group instead."
7059 (interactive "P")
7060 ;; Stop pre-fetching.
7061 (gnus-async-halt-prefetch)
7062 (let ((current-group gnus-newsgroup-name)
7063 (current-buffer (current-buffer))
7064 entered)
7065 ;; First we semi-exit this group to update Xrefs and all variables.
7066 ;; We can't do a real exit, because the window conf must remain
7067 ;; the same in case the user is prompted for info, and we don't
7068 ;; want the window conf to change before that...
7069 (gnus-summary-exit t)
7070 (while (not entered)
7071 ;; Then we find what group we are supposed to enter.
7072 (set-buffer gnus-group-buffer)
7073 (gnus-group-jump-to-group current-group)
7074 (setq target-group
7075 (or target-group
7076 (if (eq gnus-keep-same-level 'best)
7077 (gnus-summary-best-group gnus-newsgroup-name)
7078 (gnus-summary-search-group backward gnus-keep-same-level))))
7079 (if (not target-group)
7080 ;; There are no further groups, so we return to the group
7081 ;; buffer.
7082 (progn
7083 (gnus-message 5 "Returning to the group buffer")
7084 (setq entered t)
7085 (when (gnus-buffer-live-p current-buffer)
7086 (set-buffer current-buffer)
7087 (gnus-summary-exit))
7088 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7089 ;; We try to enter the target group.
7090 (gnus-group-jump-to-group target-group)
7091 (let ((unreads (gnus-group-group-unread)))
7092 (if (and (or (eq t unreads)
7093 (and unreads (not (zerop unreads))))
7094 (gnus-summary-read-group
7095 target-group nil no-article
7096 (and (buffer-name current-buffer) current-buffer)
7097 nil backward))
7098 (setq entered t)
7099 (setq current-group target-group
7100 target-group nil)))))))
7101
7102 (defun gnus-summary-prev-group (&optional no-article)
7103 "Exit current newsgroup and then select previous unread newsgroup.
7104 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7105 (interactive "P")
7106 (gnus-summary-next-group no-article nil t))
7107
7108 ;; Walking around summary lines.
7109
7110 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7111 "Go to the first subject satisfying any non-nil constraint.
7112 If UNREAD is non-nil, the article should be unread.
7113 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7114 If UNSEEN is non-nil, the article should be unseen.
7115 Returns the article selected or nil if there are no matching articles."
7116 (interactive "P")
7117 (cond
7118 ;; Empty summary.
7119 ((null gnus-newsgroup-data)
7120 (gnus-message 3 "No articles in the group")
7121 nil)
7122 ;; Pick the first article.
7123 ((not (or unread undownloaded unseen))
7124 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7125 (gnus-data-number (car gnus-newsgroup-data)))
7126 ;; Find the first unread article.
7127 (t
7128 (let ((data gnus-newsgroup-data))
7129 (while (and data
7130 (let ((num (gnus-data-number (car data))))
7131 (or (memq num gnus-newsgroup-unfetched)
7132 (not (or (and unread
7133 (memq num gnus-newsgroup-unreads))
7134 (and undownloaded
7135 (memq num gnus-newsgroup-undownloaded))
7136 (and unseen
7137 (memq num gnus-newsgroup-unseen)))))))
7138 (setq data (cdr data)))
7139 (prog1
7140 (if data
7141 (progn
7142 (goto-char (gnus-data-pos (car data)))
7143 (gnus-data-number (car data)))
7144 (gnus-message 3 "No more%s articles"
7145 (let* ((r (when unread " unread"))
7146 (d (when undownloaded " undownloaded"))
7147 (s (when unseen " unseen"))
7148 (l (delq nil (list r d s))))
7149 (cond ((= 3 (length l))
7150 (concat r "," d ", or" s))
7151 ((= 2 (length l))
7152 (concat (car l) ", or" (cadr l)))
7153 ((= 1 (length l))
7154 (car l))
7155 (t
7156 ""))))
7157 nil
7158 )
7159 (gnus-summary-position-point))))))
7160
7161 (defun gnus-summary-next-subject (n &optional unread dont-display)
7162 "Go to next N'th summary line.
7163 If N is negative, go to the previous N'th subject line.
7164 If UNREAD is non-nil, only unread articles are selected.
7165 The difference between N and the actual number of steps taken is
7166 returned."
7167 (interactive "p")
7168 (let ((backward (< n 0))
7169 (n (abs n)))
7170 (while (and (> n 0)
7171 (if backward
7172 (gnus-summary-find-prev unread)
7173 (gnus-summary-find-next unread)))
7174 (unless (zerop (setq n (1- n)))
7175 (gnus-summary-show-thread)))
7176 (when (/= 0 n)
7177 (gnus-message 7 "No more%s articles"
7178 (if unread " unread" "")))
7179 (unless dont-display
7180 (gnus-summary-recenter)
7181 (gnus-summary-position-point))
7182 n))
7183
7184 (defun gnus-summary-next-unread-subject (n)
7185 "Go to next N'th unread summary line."
7186 (interactive "p")
7187 (gnus-summary-next-subject n t))
7188
7189 (defun gnus-summary-prev-subject (n &optional unread)
7190 "Go to previous N'th summary line.
7191 If optional argument UNREAD is non-nil, only unread article is selected."
7192 (interactive "p")
7193 (gnus-summary-next-subject (- n) unread))
7194
7195 (defun gnus-summary-prev-unread-subject (n)
7196 "Go to previous N'th unread summary line."
7197 (interactive "p")
7198 (gnus-summary-next-subject (- n) t))
7199
7200 (defun gnus-summary-goto-subjects (articles)
7201 "Insert the subject header for ARTICLES in the current buffer."
7202 (save-excursion
7203 (dolist (article articles)
7204 (gnus-summary-goto-subject article t)))
7205 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7206 (gnus-summary-position-point))
7207
7208 (defun gnus-summary-goto-subject (article &optional force silent)
7209 "Go the subject line of ARTICLE.
7210 If FORCE, also allow jumping to articles not currently shown."
7211 (interactive "nArticle number: ")
7212 (unless (numberp article)
7213 (error "Article %s is not a number" article))
7214 (let ((b (point))
7215 (data (gnus-data-find article)))
7216 ;; We read in the article if we have to.
7217 (and (not data)
7218 force
7219 (gnus-summary-insert-subject
7220 article
7221 (if (or (numberp force) (vectorp force)) force)
7222 t)
7223 (setq data (gnus-data-find article)))
7224 (goto-char b)
7225 (if (not data)
7226 (progn
7227 (unless silent
7228 (gnus-message 3 "Can't find article %d" article))
7229 nil)
7230 (let ((pt (gnus-data-pos data)))
7231 (goto-char pt)
7232 (gnus-summary-set-article-display-arrow pt))
7233 (gnus-summary-position-point)
7234 article)))
7235
7236 ;; Walking around summary lines with displaying articles.
7237
7238 (defun gnus-summary-expand-window (&optional arg)
7239 "Make the summary buffer take up the entire Emacs frame.
7240 Given a prefix, will force an `article' buffer configuration."
7241 (interactive "P")
7242 (if arg
7243 (gnus-configure-windows 'article 'force)
7244 (gnus-configure-windows 'summary 'force)))
7245
7246 (defun gnus-summary-display-article (article &optional all-header)
7247 "Display ARTICLE in article buffer."
7248 (when (gnus-buffer-live-p gnus-article-buffer)
7249 (with-current-buffer gnus-article-buffer
7250 (mm-enable-multibyte)))
7251 (gnus-set-global-variables)
7252 (when (gnus-buffer-live-p gnus-article-buffer)
7253 (with-current-buffer gnus-article-buffer
7254 (setq gnus-article-charset gnus-newsgroup-charset)
7255 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7256 (mm-enable-multibyte)))
7257 (if (null article)
7258 nil
7259 (prog1
7260 (if gnus-summary-display-article-function
7261 (funcall gnus-summary-display-article-function article all-header)
7262 (gnus-article-prepare article all-header))
7263 (gnus-run-hooks 'gnus-select-article-hook)
7264 (when (and gnus-current-article
7265 (not (zerop gnus-current-article)))
7266 (gnus-summary-goto-subject gnus-current-article))
7267 (gnus-summary-recenter)
7268 (when (and gnus-use-trees gnus-show-threads)
7269 (gnus-possibly-generate-tree article)
7270 (gnus-highlight-selected-tree article))
7271 ;; Successfully display article.
7272 (gnus-article-set-window-start
7273 (cdr (assq article gnus-newsgroup-bookmarks))))))
7274
7275 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7276 "Select the current article.
7277 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7278 non-nil, the article will be re-fetched even if it already present in
7279 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7280 be displayed."
7281 ;; Make sure we are in the summary buffer to work around bbdb bug.
7282 (unless (eq major-mode 'gnus-summary-mode)
7283 (set-buffer gnus-summary-buffer))
7284 (let ((article (or article (gnus-summary-article-number)))
7285 (all-headers (not (not all-headers))) ;Must be t or nil.
7286 gnus-summary-display-article-function)
7287 (and (not pseudo)
7288 (gnus-summary-article-pseudo-p article)
7289 (error "This is a pseudo-article"))
7290 (save-excursion
7291 (set-buffer gnus-summary-buffer)
7292 (if (or (and gnus-single-article-buffer
7293 (or (null gnus-current-article)
7294 (null gnus-article-current)
7295 (null (get-buffer gnus-article-buffer))
7296 (not (eq article (cdr gnus-article-current)))
7297 (not (equal (car gnus-article-current)
7298 gnus-newsgroup-name))))
7299 (and (not gnus-single-article-buffer)
7300 (or (null gnus-current-article)
7301 (not (eq gnus-current-article article))))
7302 force)
7303 ;; The requested article is different from the current article.
7304 (progn
7305 (gnus-summary-display-article article all-headers)
7306 (when (gnus-buffer-live-p gnus-article-buffer)
7307 (with-current-buffer gnus-article-buffer
7308 (if (not gnus-article-decoded-p) ;; a local variable
7309 (mm-disable-multibyte))))
7310 (gnus-article-set-window-start
7311 (cdr (assq article gnus-newsgroup-bookmarks)))
7312 article)
7313 'old))))
7314
7315 (defun gnus-summary-force-verify-and-decrypt ()
7316 "Display buttons for signed/encrypted parts and verify/decrypt them."
7317 (interactive)
7318 (let ((mm-verify-option 'known)
7319 (mm-decrypt-option 'known)
7320 (gnus-article-emulate-mime t)
7321 (gnus-buttonized-mime-types (append (list "multipart/signed"
7322 "multipart/encrypted")
7323 gnus-buttonized-mime-types)))
7324 (gnus-summary-select-article nil 'force)))
7325
7326 (defun gnus-summary-set-current-mark (&optional current-mark)
7327 "Obsolete function."
7328 nil)
7329
7330 (defun gnus-summary-next-article (&optional unread subject backward push)
7331 "Select the next article.
7332 If UNREAD, only unread articles are selected.
7333 If SUBJECT, only articles with SUBJECT are selected.
7334 If BACKWARD, the previous article is selected instead of the next."
7335 (interactive "P")
7336 (cond
7337 ;; Is there such an article?
7338 ((and (gnus-summary-search-forward unread subject backward)
7339 (or (gnus-summary-display-article (gnus-summary-article-number))
7340 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7341 (gnus-summary-position-point))
7342 ;; If not, we try the first unread, if that is wanted.
7343 ((and subject
7344 gnus-auto-select-same
7345 (gnus-summary-first-unread-article))
7346 (gnus-summary-position-point)
7347 (gnus-message 6 "Wrapped"))
7348 ;; Try to get next/previous article not displayed in this group.
7349 ((and gnus-auto-extend-newsgroup
7350 (not unread) (not subject))
7351 (gnus-summary-goto-article
7352 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7353 nil (count-lines (point-min) (point))))
7354 ;; Go to next/previous group.
7355 (t
7356 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7357 (gnus-summary-jump-to-group gnus-newsgroup-name))
7358 (let ((cmd last-command-char)
7359 (point
7360 (save-excursion
7361 (set-buffer gnus-group-buffer)
7362 (point)))
7363 (group
7364 (if (eq gnus-keep-same-level 'best)
7365 (gnus-summary-best-group gnus-newsgroup-name)
7366 (gnus-summary-search-group backward gnus-keep-same-level))))
7367 ;; For some reason, the group window gets selected. We change
7368 ;; it back.
7369 (select-window (get-buffer-window (current-buffer)))
7370 ;; Select next unread newsgroup automagically.
7371 (cond
7372 ((or (not gnus-auto-select-next)
7373 (not cmd))
7374 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7375 ((or (eq gnus-auto-select-next 'quietly)
7376 (and (eq gnus-auto-select-next 'slightly-quietly)
7377 push)
7378 (and (eq gnus-auto-select-next 'almost-quietly)
7379 (gnus-summary-last-article-p)))
7380 ;; Select quietly.
7381 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7382 (gnus-summary-exit)
7383 (gnus-message 7 "No more%s articles (%s)..."
7384 (if unread " unread" "")
7385 (if group (concat "selecting " group)
7386 "exiting"))
7387 (gnus-summary-next-group nil group backward)))
7388 (t
7389 (when (gnus-key-press-event-p last-input-event)
7390 (gnus-summary-walk-group-buffer
7391 gnus-newsgroup-name cmd unread backward point))))))))
7392
7393 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7394 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7395 (?\C-p (gnus-group-prev-unread-group 1))))
7396 (cursor-in-echo-area t)
7397 keve key group ended prompt)
7398 (save-excursion
7399 (set-buffer gnus-group-buffer)
7400 (goto-char start)
7401 (setq group
7402 (if (eq gnus-keep-same-level 'best)
7403 (gnus-summary-best-group gnus-newsgroup-name)
7404 (gnus-summary-search-group backward gnus-keep-same-level))))
7405 (while (not ended)
7406 (setq prompt
7407 (format
7408 "No more%s articles%s " (if unread " unread" "")
7409 (if (and group
7410 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7411 (format " (Type %s for %s [%s])"
7412 (single-key-description cmd)
7413 (gnus-group-decoded-name group)
7414 (car (gnus-gethash group gnus-newsrc-hashtb)))
7415 (format " (Type %s to exit %s)"
7416 (single-key-description cmd)
7417 (gnus-group-decoded-name gnus-newsgroup-name)))))
7418 ;; Confirm auto selection.
7419 (setq key (car (setq keve (gnus-read-event-char prompt)))
7420 ended t)
7421 (cond
7422 ((assq key keystrokes)
7423 (let ((obuf (current-buffer)))
7424 (switch-to-buffer gnus-group-buffer)
7425 (when group
7426 (gnus-group-jump-to-group group))
7427 (eval (cadr (assq key keystrokes)))
7428 (setq group (gnus-group-group-name))
7429 (switch-to-buffer obuf))
7430 (setq ended nil))
7431 ((equal key cmd)
7432 (if (or (not group)
7433 (gnus-ephemeral-group-p gnus-newsgroup-name))
7434 (gnus-summary-exit)
7435 (gnus-summary-next-group nil group backward)))
7436 (t
7437 (push (cdr keve) unread-command-events))))))
7438
7439 (defun gnus-summary-next-unread-article ()
7440 "Select unread article after current one."
7441 (interactive)
7442 (gnus-summary-next-article
7443 (or (not (eq gnus-summary-goto-unread 'never))
7444 (gnus-summary-last-article-p (gnus-summary-article-number)))
7445 (and gnus-auto-select-same
7446 (gnus-summary-article-subject))))
7447
7448 (defun gnus-summary-prev-article (&optional unread subject)
7449 "Select the article after the current one.
7450 If UNREAD is non-nil, only unread articles are selected."
7451 (interactive "P")
7452 (gnus-summary-next-article unread subject t))
7453
7454 (defun gnus-summary-prev-unread-article ()
7455 "Select unread article before current one."
7456 (interactive)
7457 (gnus-summary-prev-article
7458 (or (not (eq gnus-summary-goto-unread 'never))
7459 (gnus-summary-first-article-p (gnus-summary-article-number)))
7460 (and gnus-auto-select-same
7461 (gnus-summary-article-subject))))
7462
7463 (defun gnus-summary-next-page (&optional lines circular stop)
7464 "Show next page of the selected article.
7465 If at the end of the current article, select the next article.
7466 LINES says how many lines should be scrolled up.
7467
7468 If CIRCULAR is non-nil, go to the start of the article instead of
7469 selecting the next article when reaching the end of the current
7470 article.
7471
7472 If STOP is non-nil, just stop when reaching the end of the message.
7473
7474 Also see the variable `gnus-article-skip-boring'."
7475 (interactive "P")
7476 (setq gnus-summary-buffer (current-buffer))
7477 (gnus-set-global-variables)
7478 (let ((article (gnus-summary-article-number))
7479 (article-window (get-buffer-window gnus-article-buffer t))
7480 endp)
7481 ;; If the buffer is empty, we have no article.
7482 (unless article
7483 (error "No article to select"))
7484 (gnus-configure-windows 'article)
7485 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7486 (if (and (eq gnus-summary-goto-unread 'never)
7487 (not (gnus-summary-last-article-p article)))
7488 (gnus-summary-next-article)
7489 (gnus-summary-next-unread-article))
7490 (if (or (null gnus-current-article)
7491 (null gnus-article-current)
7492 (/= article (cdr gnus-article-current))
7493 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7494 ;; Selected subject is different from current article's.
7495 (gnus-summary-display-article article)
7496 (when article-window
7497 (gnus-eval-in-buffer-window gnus-article-buffer
7498 (setq endp (or (gnus-article-next-page lines)
7499 (gnus-article-only-boring-p))))
7500 (when endp
7501 (cond (stop
7502 (gnus-message 3 "End of message"))
7503 (circular
7504 (gnus-summary-beginning-of-article))
7505 (lines
7506 (gnus-message 3 "End of message"))
7507 ((null lines)
7508 (if (and (eq gnus-summary-goto-unread 'never)
7509 (not (gnus-summary-last-article-p article)))
7510 (gnus-summary-next-article)
7511 (gnus-summary-next-unread-article))))))))
7512 (gnus-summary-recenter)
7513 (gnus-summary-position-point)))
7514
7515 (defun gnus-summary-prev-page (&optional lines move)
7516 "Show previous page of selected article.
7517 Argument LINES specifies lines to be scrolled down.
7518 If MOVE, move to the previous unread article if point is at
7519 the beginning of the buffer."
7520 (interactive "P")
7521 (let ((article (gnus-summary-article-number))
7522 (article-window (get-buffer-window gnus-article-buffer t))
7523 endp)
7524 (gnus-configure-windows 'article)
7525 (if (or (null gnus-current-article)
7526 (null gnus-article-current)
7527 (/= article (cdr gnus-article-current))
7528 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7529 ;; Selected subject is different from current article's.
7530 (gnus-summary-display-article article)
7531 (gnus-summary-recenter)
7532 (when article-window
7533 (gnus-eval-in-buffer-window gnus-article-buffer
7534 (setq endp (gnus-article-prev-page lines)))
7535 (when (and move endp)
7536 (cond (lines
7537 (gnus-message 3 "Beginning of message"))
7538 ((null lines)
7539 (if (and (eq gnus-summary-goto-unread 'never)
7540 (not (gnus-summary-first-article-p article)))
7541 (gnus-summary-prev-article)
7542 (gnus-summary-prev-unread-article))))))))
7543 (gnus-summary-position-point))
7544
7545 (defun gnus-summary-prev-page-or-article (&optional lines)
7546 "Show previous page of selected article.
7547 Argument LINES specifies lines to be scrolled down.
7548 If at the beginning of the article, go to the next article."
7549 (interactive "P")
7550 (gnus-summary-prev-page lines t))
7551
7552 (defun gnus-summary-scroll-up (lines)
7553 "Scroll up (or down) one line current article.
7554 Argument LINES specifies lines to be scrolled up (or down if negative)."
7555 (interactive "p")
7556 (gnus-configure-windows 'article)
7557 (gnus-summary-show-thread)
7558 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7559 (gnus-eval-in-buffer-window gnus-article-buffer
7560 (cond ((> lines 0)
7561 (when (gnus-article-next-page lines)
7562 (gnus-message 3 "End of message")))
7563 ((< lines 0)
7564 (gnus-article-prev-page (- lines))))))
7565 (gnus-summary-recenter)
7566 (gnus-summary-position-point))
7567
7568 (defun gnus-summary-scroll-down (lines)
7569 "Scroll down (or up) one line current article.
7570 Argument LINES specifies lines to be scrolled down (or up if negative)."
7571 (interactive "p")
7572 (gnus-summary-scroll-up (- lines)))
7573
7574 (defun gnus-summary-next-same-subject ()
7575 "Select next article which has the same subject as current one."
7576 (interactive)
7577 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7578
7579 (defun gnus-summary-prev-same-subject ()
7580 "Select previous article which has the same subject as current one."
7581 (interactive)
7582 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7583
7584 (defun gnus-summary-next-unread-same-subject ()
7585 "Select next unread article which has the same subject as current one."
7586 (interactive)
7587 (gnus-summary-next-article t (gnus-summary-article-subject)))
7588
7589 (defun gnus-summary-prev-unread-same-subject ()
7590 "Select previous unread article which has the same subject as current one."
7591 (interactive)
7592 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7593
7594 (defun gnus-summary-first-unread-article ()
7595 "Select the first unread article.
7596 Return nil if there are no unread articles."
7597 (interactive)
7598 (prog1
7599 (when (gnus-summary-first-subject t)
7600 (gnus-summary-show-thread)
7601 (gnus-summary-first-subject t)
7602 (gnus-summary-display-article (gnus-summary-article-number)))
7603 (gnus-summary-position-point)))
7604
7605 (defun gnus-summary-first-unread-subject ()
7606 "Place the point on the subject line of the first unread article.
7607 Return nil if there are no unread articles."
7608 (interactive)
7609 (prog1
7610 (when (gnus-summary-first-subject t)
7611 (gnus-summary-show-thread)
7612 (gnus-summary-first-subject t))
7613 (gnus-summary-position-point)))
7614
7615 (defun gnus-summary-first-unseen-subject ()
7616 "Place the point on the subject line of the first unseen article.
7617 Return nil if there are no unseen articles."
7618 (interactive)
7619 (prog1
7620 (when (gnus-summary-first-subject nil nil t)
7621 (gnus-summary-show-thread)
7622 (gnus-summary-first-subject nil nil t))
7623 (gnus-summary-position-point)))
7624
7625 (defun gnus-summary-first-unseen-or-unread-subject ()
7626 "Place the point on the subject line of the first unseen article or,
7627 if all article have been seen, on the subject line of the first unread
7628 article."
7629 (interactive)
7630 (prog1
7631 (unless (when (gnus-summary-first-subject nil nil t)
7632 (gnus-summary-show-thread)
7633 (gnus-summary-first-subject nil nil t))
7634 (when (gnus-summary-first-subject t)
7635 (gnus-summary-show-thread)
7636 (gnus-summary-first-subject t)))
7637 (gnus-summary-position-point)))
7638
7639 (defun gnus-summary-first-article ()
7640 "Select the first article.
7641 Return nil if there are no articles."
7642 (interactive)
7643 (prog1
7644 (when (gnus-summary-first-subject)
7645 (gnus-summary-show-thread)
7646 (gnus-summary-first-subject)
7647 (gnus-summary-display-article (gnus-summary-article-number)))
7648 (gnus-summary-position-point)))
7649
7650 (defun gnus-summary-best-unread-article (&optional arg)
7651 "Select the unread article with the highest score.
7652 If given a prefix argument, select the next unread article that has a
7653 score higher than the default score."
7654 (interactive "P")
7655 (let ((article (if arg
7656 (gnus-summary-better-unread-subject)
7657 (gnus-summary-best-unread-subject))))
7658 (if article
7659 (gnus-summary-goto-article article)
7660 (error "No unread articles"))))
7661
7662 (defun gnus-summary-best-unread-subject ()
7663 "Select the unread subject with the highest score."
7664 (interactive)
7665 (let ((best -1000000)
7666 (data gnus-newsgroup-data)
7667 article score)
7668 (while data
7669 (and (gnus-data-unread-p (car data))
7670 (> (setq score
7671 (gnus-summary-article-score (gnus-data-number (car data))))
7672 best)
7673 (setq best score
7674 article (gnus-data-number (car data))))
7675 (setq data (cdr data)))
7676 (when article
7677 (gnus-summary-goto-subject article))
7678 (gnus-summary-position-point)
7679 article))
7680
7681 (defun gnus-summary-better-unread-subject ()
7682 "Select the first unread subject that has a score over the default score."
7683 (interactive)
7684 (let ((data gnus-newsgroup-data)
7685 article score)
7686 (while (and (setq article (gnus-data-number (car data)))
7687 (or (gnus-data-read-p (car data))
7688 (not (> (gnus-summary-article-score article)
7689 gnus-summary-default-score))))
7690 (setq data (cdr data)))
7691 (when article
7692 (gnus-summary-goto-subject article))
7693 (gnus-summary-position-point)
7694 article))
7695
7696 (defun gnus-summary-last-subject ()
7697 "Go to the last displayed subject line in the group."
7698 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7699 (when article
7700 (gnus-summary-goto-subject article))))
7701
7702 (defun gnus-summary-goto-article (article &optional all-headers force)
7703 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7704 If ALL-HEADERS is non-nil, no header lines are hidden.
7705 If FORCE, go to the article even if it isn't displayed. If FORCE
7706 is a number, it is the line the article is to be displayed on."
7707 (interactive
7708 (list
7709 (completing-read
7710 "Article number or Message-ID: "
7711 (mapcar (lambda (number) (list (int-to-string number)))
7712 gnus-newsgroup-limit))
7713 current-prefix-arg
7714 t))
7715 (prog1
7716 (if (and (stringp article)
7717 (string-match "@\\|%40" article))
7718 (gnus-summary-refer-article article)
7719 (when (stringp article)
7720 (setq article (string-to-number article)))
7721 (if (gnus-summary-goto-subject article force)
7722 (gnus-summary-display-article article all-headers)
7723 (gnus-message 4 "Couldn't go to article %s" article) nil))
7724 (gnus-summary-position-point)))
7725
7726 (defun gnus-summary-goto-last-article ()
7727 "Go to the previously read article."
7728 (interactive)
7729 (prog1
7730 (when gnus-last-article
7731 (gnus-summary-goto-article gnus-last-article nil t))
7732 (gnus-summary-position-point)))
7733
7734 (defun gnus-summary-pop-article (number)
7735 "Pop one article off the history and go to the previous.
7736 NUMBER articles will be popped off."
7737 (interactive "p")
7738 (let (to)
7739 (setq gnus-newsgroup-history
7740 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7741 (if to
7742 (gnus-summary-goto-article (car to) nil t)
7743 (error "Article history empty")))
7744 (gnus-summary-position-point))
7745
7746 ;; Summary commands and functions for limiting the summary buffer.
7747
7748 (defun gnus-summary-limit-to-articles (n)
7749 "Limit the summary buffer to the next N articles.
7750 If not given a prefix, use the process marked articles instead."
7751 (interactive "P")
7752 (prog1
7753 (let ((articles (gnus-summary-work-articles n)))
7754 (setq gnus-newsgroup-processable nil)
7755 (gnus-summary-limit articles))
7756 (gnus-summary-position-point)))
7757
7758 (defun gnus-summary-pop-limit (&optional total)
7759 "Restore the previous limit.
7760 If given a prefix, remove all limits."
7761 (interactive "P")
7762 (when total
7763 (setq gnus-newsgroup-limits
7764 (list (mapcar (lambda (h) (mail-header-number h))
7765 gnus-newsgroup-headers))))
7766 (unless gnus-newsgroup-limits
7767 (error "No limit to pop"))
7768 (prog1
7769 (gnus-summary-limit nil 'pop)
7770 (gnus-summary-position-point)))
7771
7772 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7773 "Limit the summary buffer to articles that have subjects that match a regexp.
7774 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7775 (interactive
7776 (list (read-string (if current-prefix-arg
7777 "Exclude subject (regexp): "
7778 "Limit to subject (regexp): "))
7779 nil current-prefix-arg))
7780 (unless header
7781 (setq header "subject"))
7782 (when (not (equal "" subject))
7783 (prog1
7784 (let ((articles (gnus-summary-find-matching
7785 (or header "subject") subject 'all nil nil
7786 not-matching)))
7787 (unless articles
7788 (error "Found no matches for \"%s\"" subject))
7789 (gnus-summary-limit articles))
7790 (gnus-summary-position-point))))
7791
7792 (defun gnus-summary-limit-to-author (from &optional not-matching)
7793 "Limit the summary buffer to articles that have authors that match a regexp.
7794 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7795 (interactive
7796 (list (read-string (if current-prefix-arg
7797 "Exclude author (regexp): "
7798 "Limit to author (regexp): "))
7799 current-prefix-arg))
7800 (gnus-summary-limit-to-subject from "from" not-matching))
7801
7802 (defun gnus-summary-limit-to-age (age &optional younger-p)
7803 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7804 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7805 articles that are younger than AGE days."
7806 (interactive
7807 (let ((younger current-prefix-arg)
7808 (days-got nil)
7809 days)
7810 (while (not days-got)
7811 (setq days (if younger
7812 (read-string "Limit to articles younger than (in days, older when negative): ")
7813 (read-string
7814 "Limit to articles older than (in days, younger when negative): ")))
7815 (when (> (length days) 0)
7816 (setq days (read days)))
7817 (if (numberp days)
7818 (progn
7819 (setq days-got t)
7820 (if (< days 0)
7821 (progn
7822 (setq younger (not younger))
7823 (setq days (* days -1)))))
7824 (message "Please enter a number.")
7825 (sleep-for 1)))
7826 (list days younger)))
7827 (prog1
7828 (let ((data gnus-newsgroup-data)
7829 (cutoff (days-to-time age))
7830 articles d date is-younger)
7831 (while (setq d (pop data))
7832 (when (and (vectorp (gnus-data-header d))
7833 (setq date (mail-header-date (gnus-data-header d))))
7834 (setq is-younger (time-less-p
7835 (time-since (condition-case ()
7836 (date-to-time date)
7837 (error '(0 0))))
7838 cutoff))
7839 (when (if younger-p
7840 is-younger
7841 (not is-younger))
7842 (push (gnus-data-number d) articles))))
7843 (gnus-summary-limit (nreverse articles)))
7844 (gnus-summary-position-point)))
7845
7846 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7847 "Limit the summary buffer to articles that match an 'extra' header."
7848 (interactive
7849 (let ((header
7850 (intern
7851 (gnus-completing-read-with-default
7852 (symbol-name (car gnus-extra-headers))
7853 (if current-prefix-arg
7854 "Exclude extra header"
7855 "Limit extra header")
7856 (mapcar (lambda (x)
7857 (cons (symbol-name x) x))
7858 gnus-extra-headers)
7859 nil
7860 t))))
7861 (list header
7862 (read-string (format "%s header %s (regexp): "
7863 (if current-prefix-arg "Exclude" "Limit to")
7864 header))
7865 current-prefix-arg)))
7866 (when (not (equal "" regexp))
7867 (prog1
7868 (let ((articles (gnus-summary-find-matching
7869 (cons 'extra header) regexp 'all nil nil
7870 not-matching)))
7871 (unless articles
7872 (error "Found no matches for \"%s\"" regexp))
7873 (gnus-summary-limit articles))
7874 (gnus-summary-position-point))))
7875
7876 (defun gnus-summary-limit-to-display-predicate ()
7877 "Limit the summary buffer to the predicated in the `display' group parameter."
7878 (interactive)
7879 (unless gnus-newsgroup-display
7880 (error "There is no `display' group parameter"))
7881 (let (articles)
7882 (dolist (number gnus-newsgroup-articles)
7883 (when (funcall gnus-newsgroup-display)
7884 (push number articles)))
7885 (gnus-summary-limit articles))
7886 (gnus-summary-position-point))
7887
7888 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7889 (make-obsolete
7890 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7891
7892 (defun gnus-summary-limit-to-unread (&optional all)
7893 "Limit the summary buffer to articles that are not marked as read.
7894 If ALL is non-nil, limit strictly to unread articles."
7895 (interactive "P")
7896 (if all
7897 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7898 (gnus-summary-limit-to-marks
7899 ;; Concat all the marks that say that an article is read and have
7900 ;; those removed.
7901 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7902 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7903 gnus-low-score-mark gnus-expirable-mark
7904 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7905 gnus-duplicate-mark gnus-souped-mark)
7906 'reverse)))
7907
7908 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7909 (make-obsolete 'gnus-summary-delete-marked-with
7910 'gnus-summary-limit-exclude-marks)
7911
7912 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7913 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7914 If REVERSE, limit the summary buffer to articles that are marked
7915 with MARKS. MARKS can either be a string of marks or a list of marks.
7916 Returns how many articles were removed."
7917 (interactive "sMarks: ")
7918 (gnus-summary-limit-to-marks marks t))
7919
7920 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7921 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7922 If REVERSE (the prefix), limit the summary buffer to articles that are
7923 not marked with MARKS. MARKS can either be a string of marks or a
7924 list of marks.
7925 Returns how many articles were removed."
7926 (interactive "sMarks: \nP")
7927 (prog1
7928 (let ((data gnus-newsgroup-data)
7929 (marks (if (listp marks) marks
7930 (append marks nil))) ; Transform to list.
7931 articles)
7932 (while data
7933 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7934 (memq (gnus-data-mark (car data)) marks))
7935 (push (gnus-data-number (car data)) articles))
7936 (setq data (cdr data)))
7937 (gnus-summary-limit articles))
7938 (gnus-summary-position-point)))
7939
7940 (defun gnus-summary-limit-to-score (score)
7941 "Limit to articles with score at or above SCORE."
7942 (interactive "NLimit to articles with score of at least: ")
7943 (let ((data gnus-newsgroup-data)
7944 articles)
7945 (while data
7946 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7947 score)
7948 (push (gnus-data-number (car data)) articles))
7949 (setq data (cdr data)))
7950 (prog1
7951 (gnus-summary-limit articles)
7952 (gnus-summary-position-point))))
7953
7954 (defun gnus-summary-limit-to-unseen ()
7955 "Limit to unseen articles."
7956 (interactive)
7957 (prog1
7958 (gnus-summary-limit gnus-newsgroup-unseen)
7959 (gnus-summary-position-point)))
7960
7961 (defun gnus-summary-limit-include-thread (id)
7962 "Display all the hidden articles that is in the thread with ID in it.
7963 When called interactively, ID is the Message-ID of the current
7964 article."
7965 (interactive (list (mail-header-id (gnus-summary-article-header))))
7966 (let ((articles (gnus-articles-in-thread
7967 (gnus-id-to-thread (gnus-root-id id)))))
7968 (prog1
7969 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7970 (gnus-summary-limit-include-matching-articles
7971 "subject"
7972 (regexp-quote (gnus-simplify-subject-re
7973 (mail-header-subject (gnus-id-to-header id)))))
7974 (gnus-summary-position-point))))
7975
7976 (defun gnus-summary-limit-include-matching-articles (header regexp)
7977 "Display all the hidden articles that have HEADERs that match REGEXP."
7978 (interactive (list (read-string "Match on header: ")
7979 (read-string "Regexp: ")))
7980 (let ((articles (gnus-find-matching-articles header regexp)))
7981 (prog1
7982 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7983 (gnus-summary-position-point))))
7984
7985 (defun gnus-summary-insert-dormant-articles ()
7986 "Insert all the dormant articles for this group into the current buffer."
7987 (interactive)
7988 (let ((gnus-verbose (max 6 gnus-verbose)))
7989 (if (not gnus-newsgroup-dormant)
7990 (gnus-message 3 "No cached articles for this group")
7991 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7992
7993 (defun gnus-summary-limit-include-dormant ()
7994 "Display all the hidden articles that are marked as dormant.
7995 Note that this command only works on a subset of the articles currently
7996 fetched for this group."
7997 (interactive)
7998 (unless gnus-newsgroup-dormant
7999 (error "There are no dormant articles in this group"))
8000 (prog1
8001 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8002 (gnus-summary-position-point)))
8003
8004 (defun gnus-summary-limit-exclude-dormant ()
8005 "Hide all dormant articles."
8006 (interactive)
8007 (prog1
8008 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8009 (gnus-summary-position-point)))
8010
8011 (defun gnus-summary-limit-exclude-childless-dormant ()
8012 "Hide all dormant articles that have no children."
8013 (interactive)
8014 (let ((data (gnus-data-list t))
8015 articles d children)
8016 ;; Find all articles that are either not dormant or have
8017 ;; children.
8018 (while (setq d (pop data))
8019 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8020 (and (setq children
8021 (gnus-article-children (gnus-data-number d)))
8022 (let (found)
8023 (while children
8024 (when (memq (car children) articles)
8025 (setq children nil
8026 found t))
8027 (pop children))
8028 found)))
8029 (push (gnus-data-number d) articles)))
8030 ;; Do the limiting.
8031 (prog1
8032 (gnus-summary-limit articles)
8033 (gnus-summary-position-point))))
8034
8035 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8036 "Mark all unread excluded articles as read.
8037 If ALL, mark even excluded ticked and dormants as read."
8038 (interactive "P")
8039 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8040 (let ((articles (gnus-sorted-ndifference
8041 (sort
8042 (mapcar (lambda (h) (mail-header-number h))
8043 gnus-newsgroup-headers)
8044 '<)
8045 gnus-newsgroup-limit))
8046 article)
8047 (setq gnus-newsgroup-unreads
8048 (gnus-sorted-intersection gnus-newsgroup-unreads
8049 gnus-newsgroup-limit))
8050 (if all
8051 (setq gnus-newsgroup-dormant nil
8052 gnus-newsgroup-marked nil
8053 gnus-newsgroup-reads
8054 (nconc
8055 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8056 gnus-newsgroup-reads))
8057 (while (setq article (pop articles))
8058 (unless (or (memq article gnus-newsgroup-dormant)
8059 (memq article gnus-newsgroup-marked))
8060 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8061
8062 (defun gnus-summary-limit (articles &optional pop)
8063 (if pop
8064 ;; We pop the previous limit off the stack and use that.
8065 (setq articles (car gnus-newsgroup-limits)
8066 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8067 ;; We use the new limit, so we push the old limit on the stack.
8068 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8069 ;; Set the limit.
8070 (setq gnus-newsgroup-limit articles)
8071 (let ((total (length gnus-newsgroup-data))
8072 (data (gnus-data-find-list (gnus-summary-article-number)))
8073 (gnus-summary-mark-below nil) ; Inhibit this.
8074 found)
8075 ;; This will do all the work of generating the new summary buffer
8076 ;; according to the new limit.
8077 (gnus-summary-prepare)
8078 ;; Hide any threads, possibly.
8079 (gnus-summary-maybe-hide-threads)
8080 ;; Try to return to the article you were at, or one in the
8081 ;; neighborhood.
8082 (when data
8083 ;; We try to find some article after the current one.
8084 (while data
8085 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8086 (setq data nil
8087 found t))
8088 (setq data (cdr data))))
8089 (unless found
8090 ;; If there is no data, that means that we were after the last
8091 ;; article. The same goes when we can't find any articles
8092 ;; after the current one.
8093 (goto-char (point-max))
8094 (gnus-summary-find-prev))
8095 (gnus-set-mode-line 'summary)
8096 ;; We return how many articles were removed from the summary
8097 ;; buffer as a result of the new limit.
8098 (- total (length gnus-newsgroup-data))))
8099
8100 (defsubst gnus-invisible-cut-children (threads)
8101 (let ((num 0))
8102 (while threads
8103 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8104 (incf num))
8105 (pop threads))
8106 (< num 2)))
8107
8108 (defsubst gnus-cut-thread (thread)
8109 "Go forwards in the thread until we find an article that we want to display."
8110 (when (or (eq gnus-fetch-old-headers 'some)
8111 (eq gnus-fetch-old-headers 'invisible)
8112 (numberp gnus-fetch-old-headers)
8113 (eq gnus-build-sparse-threads 'some)
8114 (eq gnus-build-sparse-threads 'more))
8115 ;; Deal with old-fetched headers and sparse threads.
8116 (while (and
8117 thread
8118 (or
8119 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8120 (gnus-summary-article-ancient-p
8121 (mail-header-number (car thread))))
8122 (if (or (<= (length (cdr thread)) 1)
8123 (eq gnus-fetch-old-headers 'invisible))
8124 (setq gnus-newsgroup-limit
8125 (delq (mail-header-number (car thread))
8126 gnus-newsgroup-limit)
8127 thread (cadr thread))
8128 (when (gnus-invisible-cut-children (cdr thread))
8129 (let ((th (cdr thread)))
8130 (while th
8131 (if (memq (mail-header-number (caar th))
8132 gnus-newsgroup-limit)
8133 (setq thread (car th)
8134 th nil)
8135 (setq th (cdr th))))))))))
8136 thread)
8137
8138 (defun gnus-cut-threads (threads)
8139 "Cut off all uninteresting articles from the beginning of THREADS."
8140 (when (or (eq gnus-fetch-old-headers 'some)
8141 (eq gnus-fetch-old-headers 'invisible)
8142 (numberp gnus-fetch-old-headers)
8143 (eq gnus-build-sparse-threads 'some)
8144 (eq gnus-build-sparse-threads 'more))
8145 (let ((th threads))
8146 (while th
8147 (setcar th (gnus-cut-thread (car th)))
8148 (setq th (cdr th)))))
8149 ;; Remove nixed out threads.
8150 (delq nil threads))
8151
8152 (defun gnus-summary-initial-limit (&optional show-if-empty)
8153 "Figure out what the initial limit is supposed to be on group entry.
8154 This entails weeding out unwanted dormants, low-scored articles,
8155 fetch-old-headers verbiage, and so on."
8156 ;; Most groups have nothing to remove.
8157 (if (or gnus-inhibit-limiting
8158 (and (null gnus-newsgroup-dormant)
8159 (eq gnus-newsgroup-display 'gnus-not-ignore)
8160 (not (eq gnus-fetch-old-headers 'some))
8161 (not (numberp gnus-fetch-old-headers))
8162 (not (eq gnus-fetch-old-headers 'invisible))
8163 (null gnus-summary-expunge-below)
8164 (not (eq gnus-build-sparse-threads 'some))
8165 (not (eq gnus-build-sparse-threads 'more))
8166 (null gnus-thread-expunge-below)
8167 (not gnus-use-nocem)))
8168 () ; Do nothing.
8169 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8170 (setq gnus-newsgroup-limit nil)
8171 (mapatoms
8172 (lambda (node)
8173 (unless (car (symbol-value node))
8174 ;; These threads have no parents -- they are roots.
8175 (let ((nodes (cdr (symbol-value node)))
8176 thread)
8177 (while nodes
8178 (if (and gnus-thread-expunge-below
8179 (< (gnus-thread-total-score (car nodes))
8180 gnus-thread-expunge-below))
8181 (gnus-expunge-thread (pop nodes))
8182 (setq thread (pop nodes))
8183 (gnus-summary-limit-children thread))))))
8184 gnus-newsgroup-dependencies)
8185 ;; If this limitation resulted in an empty group, we might
8186 ;; pop the previous limit and use it instead.
8187 (when (and (not gnus-newsgroup-limit)
8188 show-if-empty)
8189 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8190 gnus-newsgroup-limit))
8191
8192 (defun gnus-summary-limit-children (thread)
8193 "Return 1 if this subthread is visible and 0 if it is not."
8194 ;; First we get the number of visible children to this thread. This
8195 ;; is done by recursing down the thread using this function, so this
8196 ;; will really go down to a leaf article first, before slowly
8197 ;; working its way up towards the root.
8198 (when thread
8199 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8200 (children
8201 (if (cdr thread)
8202 (apply '+ (mapcar 'gnus-summary-limit-children
8203 (cdr thread)))
8204 0))
8205 (number (mail-header-number (car thread)))
8206 score)
8207 (if (and
8208 (not (memq number gnus-newsgroup-marked))
8209 (or
8210 ;; If this article is dormant and has absolutely no visible
8211 ;; children, then this article isn't visible.
8212 (and (memq number gnus-newsgroup-dormant)
8213 (zerop children))
8214 ;; If this is "fetch-old-headered" and there is no
8215 ;; visible children, then we don't want this article.
8216 (and (or (eq gnus-fetch-old-headers 'some)
8217 (numberp gnus-fetch-old-headers))
8218 (gnus-summary-article-ancient-p number)
8219 (zerop children))
8220 ;; If this is "fetch-old-headered" and `invisible', then
8221 ;; we don't want this article.
8222 (and (eq gnus-fetch-old-headers 'invisible)
8223 (gnus-summary-article-ancient-p number))
8224 ;; If this is a sparsely inserted article with no children,
8225 ;; we don't want it.
8226 (and (eq gnus-build-sparse-threads 'some)
8227 (gnus-summary-article-sparse-p number)
8228 (zerop children))
8229 ;; If we use expunging, and this article is really
8230 ;; low-scored, then we don't want this article.
8231 (when (and gnus-summary-expunge-below
8232 (< (setq score
8233 (or (cdr (assq number gnus-newsgroup-scored))
8234 gnus-summary-default-score))
8235 gnus-summary-expunge-below))
8236 ;; We increase the expunge-tally here, but that has
8237 ;; nothing to do with the limits, really.
8238 (incf gnus-newsgroup-expunged-tally)
8239 ;; We also mark as read here, if that's wanted.
8240 (when (and gnus-summary-mark-below
8241 (< score gnus-summary-mark-below))
8242 (setq gnus-newsgroup-unreads
8243 (delq number gnus-newsgroup-unreads))
8244 (if gnus-newsgroup-auto-expire
8245 (push number gnus-newsgroup-expirable)
8246 (push (cons number gnus-low-score-mark)
8247 gnus-newsgroup-reads)))
8248 t)
8249 ;; Do the `display' group parameter.
8250 (and gnus-newsgroup-display
8251 (not (funcall gnus-newsgroup-display)))
8252 ;; Check NoCeM things.
8253 (if (and gnus-use-nocem
8254 (gnus-nocem-unwanted-article-p
8255 (mail-header-id (car thread))))
8256 (progn
8257 (setq gnus-newsgroup-unreads
8258 (delq number gnus-newsgroup-unreads))
8259 t))))
8260 ;; Nope, invisible article.
8261 0
8262 ;; Ok, this article is to be visible, so we add it to the limit
8263 ;; and return 1.
8264 (push number gnus-newsgroup-limit)
8265 1))))
8266
8267 (defun gnus-expunge-thread (thread)
8268 "Mark all articles in THREAD as read."
8269 (let* ((number (mail-header-number (car thread))))
8270 (incf gnus-newsgroup-expunged-tally)
8271 ;; We also mark as read here, if that's wanted.
8272 (setq gnus-newsgroup-unreads
8273 (delq number gnus-newsgroup-unreads))
8274 (if gnus-newsgroup-auto-expire
8275 (push number gnus-newsgroup-expirable)
8276 (push (cons number gnus-low-score-mark)
8277 gnus-newsgroup-reads)))
8278 ;; Go recursively through all subthreads.
8279 (mapcar 'gnus-expunge-thread (cdr thread)))
8280
8281 ;; Summary article oriented commands
8282
8283 (defun gnus-summary-refer-parent-article (n)
8284 "Refer parent article N times.
8285 If N is negative, go to ancestor -N instead.
8286 The difference between N and the number of articles fetched is returned."
8287 (interactive "p")
8288 (let ((skip 1)
8289 error header ref)
8290 (when (not (natnump n))
8291 (setq skip (abs n)
8292 n 1))
8293 (while (and (> n 0)
8294 (not error))
8295 (setq header (gnus-summary-article-header))
8296 (if (and (eq (mail-header-number header)
8297 (cdr gnus-article-current))
8298 (equal gnus-newsgroup-name
8299 (car gnus-article-current)))
8300 ;; If we try to find the parent of the currently
8301 ;; displayed article, then we take a look at the actual
8302 ;; References header, since this is slightly more
8303 ;; reliable than the References field we got from the
8304 ;; server.
8305 (save-excursion
8306 (set-buffer gnus-original-article-buffer)
8307 (nnheader-narrow-to-headers)
8308 (unless (setq ref (message-fetch-field "references"))
8309 (when (setq ref (message-fetch-field "in-reply-to"))
8310 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8311 (widen))
8312 (setq ref
8313 ;; It's not the current article, so we take a bet on
8314 ;; the value we got from the server.
8315 (mail-header-references header)))
8316 (if (and ref
8317 (not (equal ref "")))
8318 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8319 (gnus-message 1 "Couldn't find parent"))
8320 (gnus-message 1 "No references in article %d"
8321 (gnus-summary-article-number))
8322 (setq error t))
8323 (decf n))
8324 (gnus-summary-position-point)
8325 n))
8326
8327 (defun gnus-summary-refer-references ()
8328 "Fetch all articles mentioned in the References header.
8329 Return the number of articles fetched."
8330 (interactive)
8331 (let ((ref (mail-header-references (gnus-summary-article-header)))
8332 (current (gnus-summary-article-number))
8333 (n 0))
8334 (if (or (not ref)
8335 (equal ref ""))
8336 (error "No References in the current article")
8337 ;; For each Message-ID in the References header...
8338 (while (string-match "<[^>]*>" ref)
8339 (incf n)
8340 ;; ... fetch that article.
8341 (gnus-summary-refer-article
8342 (prog1 (match-string 0 ref)
8343 (setq ref (substring ref (match-end 0))))))
8344 (gnus-summary-goto-subject current)
8345 (gnus-summary-position-point)
8346 n)))
8347
8348 (defun gnus-summary-refer-thread (&optional limit)
8349 "Fetch all articles in the current thread.
8350 If LIMIT (the numerical prefix), fetch that many old headers instead
8351 of what's specified by the `gnus-refer-thread-limit' variable."
8352 (interactive "P")
8353 (let ((id (mail-header-id (gnus-summary-article-header)))
8354 (limit (if limit (prefix-numeric-value limit)
8355 gnus-refer-thread-limit)))
8356 (unless (eq gnus-fetch-old-headers 'invisible)
8357 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8358 ;; Retrieve the headers and read them in.
8359 (if (eq (if (numberp limit)
8360 (gnus-retrieve-headers
8361 (list (min
8362 (+ (mail-header-number
8363 (gnus-summary-article-header))
8364 limit)
8365 gnus-newsgroup-end))
8366 gnus-newsgroup-name (* limit 2))
8367 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8368 ;; headers.
8369 (gnus-retrieve-headers (list gnus-newsgroup-end)
8370 gnus-newsgroup-name limit))
8371 'nov)
8372 (gnus-build-all-threads)
8373 (error "Can't fetch thread from back ends that don't support NOV"))
8374 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8375 (gnus-summary-limit-include-thread id)))
8376
8377 (defun gnus-summary-refer-article (message-id)
8378 "Fetch an article specified by MESSAGE-ID."
8379 (interactive "sMessage-ID: ")
8380 (when (and (stringp message-id)
8381 (not (zerop (length message-id))))
8382 (setq message-id (gnus-replace-in-string message-id " " ""))
8383 ;; Construct the correct Message-ID if necessary.
8384 ;; Suggested by tale@pawl.rpi.edu.
8385 (unless (string-match "^<" message-id)
8386 (setq message-id (concat "<" message-id)))
8387 (unless (string-match ">$" message-id)
8388 (setq message-id (concat message-id ">")))
8389 ;; People often post MIDs from URLs, so unhex it:
8390 (unless (string-match "@" message-id)
8391 (setq message-id (gnus-url-unhex-string message-id)))
8392 (let* ((header (gnus-id-to-header message-id))
8393 (sparse (and header
8394 (gnus-summary-article-sparse-p
8395 (mail-header-number header))
8396 (memq (mail-header-number header)
8397 gnus-newsgroup-limit)))
8398 number)
8399 (cond
8400 ;; If the article is present in the buffer we just go to it.
8401 ((and header
8402 (or (not (gnus-summary-article-sparse-p
8403 (mail-header-number header)))
8404 sparse))
8405 (prog1
8406 (gnus-summary-goto-article
8407 (mail-header-number header) nil t)
8408 (when sparse
8409 (gnus-summary-update-article (mail-header-number header)))))
8410 (t
8411 ;; We fetch the article.
8412 (catch 'found
8413 (dolist (gnus-override-method (gnus-refer-article-methods))
8414 (when (and (gnus-check-server gnus-override-method)
8415 ;; Fetch the header,
8416 (setq number (gnus-summary-insert-subject message-id)))
8417 ;; and display the article.
8418 (gnus-summary-select-article nil nil nil number)
8419 (throw 'found t)))
8420 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8421
8422 (defun gnus-refer-article-methods ()
8423 "Return a list of referable methods."
8424 (cond
8425 ;; No method, so we default to current and native.
8426 ((null gnus-refer-article-method)
8427 (list gnus-current-select-method gnus-select-method))
8428 ;; Current.
8429 ((eq 'current gnus-refer-article-method)
8430 (list gnus-current-select-method))
8431 ;; List of select methods.
8432 ((not (and (symbolp (car gnus-refer-article-method))
8433 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8434 (let (out)
8435 (dolist (method gnus-refer-article-method)
8436 (push (if (eq 'current method)
8437 gnus-current-select-method
8438 method)
8439 out))
8440 (nreverse out)))
8441 ;; One single select method.
8442 (t
8443 (list gnus-refer-article-method))))
8444
8445 (defun gnus-summary-edit-parameters ()
8446 "Edit the group parameters of the current group."
8447 (interactive)
8448 (gnus-group-edit-group gnus-newsgroup-name 'params))
8449
8450 (defun gnus-summary-customize-parameters ()
8451 "Customize the group parameters of the current group."
8452 (interactive)
8453 (gnus-group-customize gnus-newsgroup-name))
8454
8455 (defun gnus-summary-enter-digest-group (&optional force)
8456 "Enter an nndoc group based on the current article.
8457 If FORCE, force a digest interpretation. If not, try
8458 to guess what the document format is."
8459 (interactive "P")
8460 (let ((conf gnus-current-window-configuration))
8461 (save-window-excursion
8462 (save-excursion
8463 (let (gnus-article-prepare-hook
8464 gnus-display-mime-function
8465 gnus-break-pages)
8466 (gnus-summary-select-article))))
8467 (setq gnus-current-window-configuration conf)
8468 (let* ((name (format "%s-%d"
8469 (gnus-group-prefixed-name
8470 gnus-newsgroup-name (list 'nndoc ""))
8471 (save-excursion
8472 (set-buffer gnus-summary-buffer)
8473 gnus-current-article)))
8474 (ogroup gnus-newsgroup-name)
8475 (params (append (gnus-info-params (gnus-get-info ogroup))
8476 (list (cons 'to-group ogroup))
8477 (list (cons 'parent-group ogroup))
8478 (list (cons 'save-article-group ogroup))))
8479 (case-fold-search t)
8480 (buf (current-buffer))
8481 dig to-address)
8482 (save-excursion
8483 (set-buffer gnus-original-article-buffer)
8484 ;; Have the digest group inherit the main mail address of
8485 ;; the parent article.
8486 (when (setq to-address (or (gnus-fetch-field "reply-to")
8487 (gnus-fetch-field "from")))
8488 (setq params
8489 (append
8490 (list (cons 'to-address
8491 (funcall gnus-decode-encoded-address-function
8492 to-address))))))
8493 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8494 (insert-buffer-substring gnus-original-article-buffer)
8495 ;; Remove lines that may lead nndoc to misinterpret the
8496 ;; document type.
8497 (narrow-to-region
8498 (goto-char (point-min))
8499 (or (search-forward "\n\n" nil t) (point)))
8500 (goto-char (point-min))
8501 (delete-matching-lines "^Path:\\|^From ")
8502 (widen))
8503 (unwind-protect
8504 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8505 (gnus-newsgroup-ephemeral-ignored-charsets
8506 gnus-newsgroup-ignored-charsets))
8507 (gnus-group-read-ephemeral-group
8508 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8509 (nndoc-article-type
8510 ,(if force 'mbox 'guess)))
8511 t nil nil nil
8512 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8513 "ADAPT")))))
8514 ;; Make all postings to this group go to the parent group.
8515 (nconc (gnus-info-params (gnus-get-info name))
8516 params)
8517 ;; Couldn't select this doc group.
8518 (switch-to-buffer buf)
8519 (gnus-set-global-variables)
8520 (gnus-configure-windows 'summary)
8521 (gnus-message 3 "Article couldn't be entered?"))
8522 (kill-buffer dig)))))
8523
8524 (defun gnus-summary-read-document (n)
8525 "Open a new group based on the current article(s).
8526 This will allow you to read digests and other similar
8527 documents as newsgroups.
8528 Obeys the standard process/prefix convention."
8529 (interactive "P")
8530 (let* ((articles (gnus-summary-work-articles n))
8531 (ogroup gnus-newsgroup-name)
8532 (params (append (gnus-info-params (gnus-get-info ogroup))
8533 (list (cons 'to-group ogroup))))
8534 article group egroup groups vgroup)
8535 (while (setq article (pop articles))
8536 (setq group (format "%s-%d" gnus-newsgroup-name article))
8537 (gnus-summary-remove-process-mark article)
8538 (when (gnus-summary-display-article article)
8539 (save-excursion
8540 (with-temp-buffer
8541 (insert-buffer-substring gnus-original-article-buffer)
8542 ;; Remove some headers that may lead nndoc to make
8543 ;; the wrong guess.
8544 (message-narrow-to-head)
8545 (goto-char (point-min))
8546 (delete-matching-lines "^\\(Path\\):\\|^From ")
8547 (widen)
8548 (if (setq egroup
8549 (gnus-group-read-ephemeral-group
8550 group `(nndoc ,group (nndoc-address ,(current-buffer))
8551 (nndoc-article-type guess))
8552 t nil t))
8553 (progn
8554 ;; Make all postings to this group go to the parent group.
8555 (nconc (gnus-info-params (gnus-get-info egroup))
8556 params)
8557 (push egroup groups))
8558 ;; Couldn't select this doc group.
8559 (gnus-error 3 "Article couldn't be entered"))))))
8560 ;; Now we have selected all the documents.
8561 (cond
8562 ((not groups)
8563 (error "None of the articles could be interpreted as documents"))
8564 ((gnus-group-read-ephemeral-group
8565 (setq vgroup (format
8566 "nnvirtual:%s-%s" gnus-newsgroup-name
8567 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8568 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8569 t
8570 (cons (current-buffer) 'summary)))
8571 (t
8572 (error "Couldn't select virtual nndoc group")))))
8573
8574 (defun gnus-summary-isearch-article (&optional regexp-p)
8575 "Do incremental search forward on the current article.
8576 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8577 (interactive "P")
8578 (gnus-summary-select-article)
8579 (gnus-configure-windows 'article)
8580 (gnus-eval-in-buffer-window gnus-article-buffer
8581 (save-restriction
8582 (widen)
8583 (isearch-forward regexp-p))))
8584
8585 (defun gnus-summary-search-article-forward (regexp &optional backward)
8586 "Search for an article containing REGEXP forward.
8587 If BACKWARD, search backward instead."
8588 (interactive
8589 (list (read-string
8590 (format "Search article %s (regexp%s): "
8591 (if current-prefix-arg "backward" "forward")
8592 (if gnus-last-search-regexp
8593 (concat ", default " gnus-last-search-regexp)
8594 "")))
8595 current-prefix-arg))
8596 (if (string-equal regexp "")
8597 (setq regexp (or gnus-last-search-regexp ""))
8598 (setq gnus-last-search-regexp regexp)
8599 (setq gnus-article-before-search gnus-current-article))
8600 ;; Intentionally set gnus-last-article.
8601 (setq gnus-last-article gnus-article-before-search)
8602 (let ((gnus-last-article gnus-last-article))
8603 (if (gnus-summary-search-article regexp backward)
8604 (gnus-summary-show-thread)
8605 (signal 'search-failed (list regexp)))))
8606
8607 (defun gnus-summary-search-article-backward (regexp)
8608 "Search for an article containing REGEXP backward."
8609 (interactive
8610 (list (read-string
8611 (format "Search article backward (regexp%s): "
8612 (if gnus-last-search-regexp
8613 (concat ", default " gnus-last-search-regexp)
8614 "")))))
8615 (gnus-summary-search-article-forward regexp 'backward))
8616
8617 (defun gnus-summary-search-article (regexp &optional backward)
8618 "Search for an article containing REGEXP.
8619 Optional argument BACKWARD means do search for backward.
8620 `gnus-select-article-hook' is not called during the search."
8621 ;; We have to require this here to make sure that the following
8622 ;; dynamic binding isn't shadowed by autoloading.
8623 (require 'gnus-async)
8624 (require 'gnus-art)
8625 (let ((gnus-select-article-hook nil) ;Disable hook.
8626 (gnus-article-prepare-hook nil)
8627 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8628 (gnus-use-article-prefetch nil)
8629 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8630 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8631 (gnus-visual nil)
8632 (gnus-keep-backlog nil)
8633 (gnus-break-pages nil)
8634 (gnus-summary-display-arrow nil)
8635 (gnus-updated-mode-lines nil)
8636 (gnus-auto-center-summary nil)
8637 (sum (current-buffer))
8638 (gnus-display-mime-function nil)
8639 (found nil)
8640 point)
8641 (gnus-save-hidden-threads
8642 (gnus-summary-select-article)
8643 (set-buffer gnus-article-buffer)
8644 (goto-char (window-point (get-buffer-window (current-buffer))))
8645 (when backward
8646 (forward-line -1))
8647 (while (not found)
8648 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8649 (if (if backward
8650 (re-search-backward regexp nil t)
8651 (re-search-forward regexp nil t))
8652 ;; We found the regexp.
8653 (progn
8654 (setq found 'found)
8655 (beginning-of-line)
8656 (set-window-start
8657 (get-buffer-window (current-buffer))
8658 (point))
8659 (forward-line 1)
8660 (set-window-point
8661 (get-buffer-window (current-buffer))
8662 (point))
8663 (set-buffer sum)
8664 (setq point (point)))
8665 ;; We didn't find it, so we go to the next article.
8666 (set-buffer sum)
8667 (setq found 'not)
8668 (while (eq found 'not)
8669 (if (not (if backward (gnus-summary-find-prev)
8670 (gnus-summary-find-next)))
8671 ;; No more articles.
8672 (setq found t)
8673 ;; Select the next article and adjust point.
8674 (unless (gnus-summary-article-sparse-p
8675 (gnus-summary-article-number))
8676 (setq found nil)
8677 (gnus-summary-select-article)
8678 (set-buffer gnus-article-buffer)
8679 (widen)
8680 (goto-char (if backward (point-max) (point-min))))))))
8681 (gnus-message 7 ""))
8682 ;; Return whether we found the regexp.
8683 (when (eq found 'found)
8684 (goto-char point)
8685 (gnus-summary-show-thread)
8686 (gnus-summary-goto-subject gnus-current-article)
8687 (gnus-summary-position-point)
8688 t)))
8689
8690 (defun gnus-find-matching-articles (header regexp)
8691 "Return a list of all articles that match REGEXP on HEADER.
8692 This search includes all articles in the current group that Gnus has
8693 fetched headers for, whether they are displayed or not."
8694 (let ((articles nil)
8695 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8696 (case-fold-search t))
8697 (dolist (header gnus-newsgroup-headers)
8698 (when (string-match regexp (funcall func header))
8699 (push (mail-header-number header) articles)))
8700 (nreverse articles)))
8701
8702 (defun gnus-summary-find-matching (header regexp &optional backward unread
8703 not-case-fold not-matching)
8704 "Return a list of all articles that match REGEXP on HEADER.
8705 The search stars on the current article and goes forwards unless
8706 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8707 If UNREAD is non-nil, only unread articles will
8708 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8709 in the comparisons. If NOT-MATCHING, return a list of all articles that
8710 not match REGEXP on HEADER."
8711 (let ((case-fold-search (not not-case-fold))
8712 articles d func)
8713 (if (consp header)
8714 (if (eq (car header) 'extra)
8715 (setq func
8716 `(lambda (h)
8717 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8718 "")))
8719 (error "%s is an invalid header" header))
8720 (unless (fboundp (intern (concat "mail-header-" header)))
8721 (error "%s is not a valid header" header))
8722 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8723 (dolist (d (if (eq backward 'all)
8724 gnus-newsgroup-data
8725 (gnus-data-find-list
8726 (gnus-summary-article-number)
8727 (gnus-data-list backward))))
8728 (when (and (or (not unread) ; We want all articles...
8729 (gnus-data-unread-p d)) ; Or just unreads.
8730 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8731 (if not-matching
8732 (not (string-match
8733 regexp
8734 (funcall func (gnus-data-header d))))
8735 (string-match regexp
8736 (funcall func (gnus-data-header d)))))
8737 (push (gnus-data-number d) articles))) ; Success!
8738 (nreverse articles)))
8739
8740 (defun gnus-summary-execute-command (header regexp command &optional backward)
8741 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8742 If HEADER is an empty string (or nil), the match is done on the entire
8743 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8744 (interactive
8745 (list (let ((completion-ignore-case t))
8746 (completing-read
8747 "Header name: "
8748 (mapcar (lambda (header) (list (format "%s" header)))
8749 (append
8750 '("Number" "Subject" "From" "Lines" "Date"
8751 "Message-ID" "Xref" "References" "Body")
8752 gnus-extra-headers))
8753 nil 'require-match))
8754 (read-string "Regexp: ")
8755 (read-key-sequence "Command: ")
8756 current-prefix-arg))
8757 (when (equal header "Body")
8758 (setq header ""))
8759 ;; Hidden thread subtrees must be searched as well.
8760 (gnus-summary-show-all-threads)
8761 ;; We don't want to change current point nor window configuration.
8762 (save-excursion
8763 (save-window-excursion
8764 (let (gnus-visual
8765 gnus-treat-strip-trailing-blank-lines
8766 gnus-treat-strip-leading-blank-lines
8767 gnus-treat-strip-multiple-blank-lines
8768 gnus-treat-hide-boring-headers
8769 gnus-treat-fold-newsgroups
8770 gnus-article-prepare-hook)
8771 (gnus-message 6 "Executing %s..." (key-description command))
8772 ;; We'd like to execute COMMAND interactively so as to give arguments.
8773 (gnus-execute header regexp
8774 `(call-interactively ',(key-binding command))
8775 backward)
8776 (gnus-message 6 "Executing %s...done" (key-description command))))))
8777
8778 (defun gnus-summary-beginning-of-article ()
8779 "Scroll the article back to the beginning."
8780 (interactive)
8781 (gnus-summary-select-article)
8782 (gnus-configure-windows 'article)
8783 (gnus-eval-in-buffer-window gnus-article-buffer
8784 (widen)
8785 (goto-char (point-min))
8786 (when gnus-break-pages
8787 (gnus-narrow-to-page))))
8788
8789 (defun gnus-summary-end-of-article ()
8790 "Scroll to the end of the article."
8791 (interactive)
8792 (gnus-summary-select-article)
8793 (gnus-configure-windows 'article)
8794 (gnus-eval-in-buffer-window gnus-article-buffer
8795 (widen)
8796 (goto-char (point-max))
8797 (recenter -3)
8798 (when gnus-break-pages
8799 (when (re-search-backward page-delimiter nil t)
8800 (narrow-to-region (match-end 0) (point-max)))
8801 (gnus-narrow-to-page))))
8802
8803 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8804 "Truncate to LEN and quote all \"(\"'s in STRING."
8805 (gnus-replace-in-string (if (and len (> (length string) len))
8806 (substring string 0 len)
8807 string)
8808 "[()]" "\\\\\\&"))
8809
8810 (defun gnus-summary-print-article (&optional filename n)
8811 "Generate and print a PostScript image of the process-marked (mail) articles.
8812
8813 If used interactively, print the current article if none are
8814 process-marked. With prefix arg, prompt the user for the name of the
8815 file to save in.
8816
8817 When used from Lisp, accept two optional args FILENAME and N. N means
8818 to print the next N articles. If N is negative, print the N previous
8819 articles. If N is nil and articles have been marked with the process
8820 mark, print these instead.
8821
8822 If the optional first argument FILENAME is nil, send the image to the
8823 printer. If FILENAME is a string, save the PostScript image in a file with
8824 that name. If FILENAME is a number, prompt the user for the name of the file
8825 to save in."
8826 (interactive (list (ps-print-preprint current-prefix-arg)))
8827 (dolist (article (gnus-summary-work-articles n))
8828 (gnus-summary-select-article nil nil 'pseudo article)
8829 (gnus-eval-in-buffer-window gnus-article-buffer
8830 (gnus-print-buffer))
8831 (gnus-summary-remove-process-mark article))
8832 (ps-despool filename))
8833
8834 (defun gnus-print-buffer ()
8835 (let ((buffer (generate-new-buffer " *print*")))
8836 (unwind-protect
8837 (progn
8838 (copy-to-buffer buffer (point-min) (point-max))
8839 (set-buffer buffer)
8840 (gnus-remove-text-with-property 'gnus-decoration)
8841 (when (gnus-visual-p 'article-highlight 'highlight)
8842 ;; Copy-to-buffer doesn't copy overlay. So redo
8843 ;; highlight.
8844 (let ((gnus-article-buffer buffer))
8845 (gnus-article-highlight-citation t)
8846 (gnus-article-highlight-signature)
8847 (gnus-article-emphasize)
8848 (gnus-article-delete-invisible-text)))
8849 (let ((ps-left-header
8850 (list
8851 (concat "("
8852 (gnus-summary-print-truncate-and-quote
8853 (mail-header-subject gnus-current-headers)
8854 66) ")")
8855 (concat "("
8856 (gnus-summary-print-truncate-and-quote
8857 (mail-header-from gnus-current-headers)
8858 45) ")")))
8859 (ps-right-header
8860 (list
8861 "/pagenumberstring load"
8862 (concat "("
8863 (mail-header-date gnus-current-headers) ")"))))
8864 (gnus-run-hooks 'gnus-ps-print-hook)
8865 (save-excursion
8866 (if window-system
8867 (ps-spool-buffer-with-faces)
8868 (ps-spool-buffer)))))
8869 (kill-buffer buffer))))
8870
8871 (defun gnus-summary-show-article (&optional arg)
8872 "Force redisplaying of the current article.
8873 If ARG (the prefix) is a number, show the article with the charset
8874 defined in `gnus-summary-show-article-charset-alist', or the charset
8875 input.
8876 If ARG (the prefix) is non-nil and not a number, show the raw article
8877 without any article massaging functions being run. Normally, the key
8878 strokes are `C-u g'."
8879 (interactive "P")
8880 (cond
8881 ((numberp arg)
8882 (gnus-summary-show-article t)
8883 (let ((gnus-newsgroup-charset
8884 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8885 (mm-read-coding-system
8886 "View as charset: " ;; actually it is coding system.
8887 (save-excursion
8888 (set-buffer gnus-article-buffer)
8889 (mm-detect-coding-region (point) (point-max))))))
8890 (gnus-newsgroup-ignored-charsets 'gnus-all))
8891 (gnus-summary-select-article nil 'force)
8892 (let ((deps gnus-newsgroup-dependencies)
8893 head header lines)
8894 (save-excursion
8895 (set-buffer gnus-original-article-buffer)
8896 (save-restriction
8897 (message-narrow-to-head)
8898 (setq head (buffer-string))
8899 (goto-char (point-min))
8900 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8901 (goto-char (point-max))
8902 (widen)
8903 (setq lines (1- (count-lines (point) (point-max))))))
8904 (with-temp-buffer
8905 (insert (format "211 %d Article retrieved.\n"
8906 (cdr gnus-article-current)))
8907 (insert head)
8908 (if lines (insert (format "Lines: %d\n" lines)))
8909 (insert ".\n")
8910 (let ((nntp-server-buffer (current-buffer)))
8911 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8912 (gnus-data-set-header
8913 (gnus-data-find (cdr gnus-article-current))
8914 header)
8915 (gnus-summary-update-article-line
8916 (cdr gnus-article-current) header)
8917 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8918 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8919 ((not arg)
8920 ;; Select the article the normal way.
8921 (gnus-summary-select-article nil 'force))
8922 (t
8923 ;; We have to require this here to make sure that the following
8924 ;; dynamic binding isn't shadowed by autoloading.
8925 (require 'gnus-async)
8926 (require 'gnus-art)
8927 ;; Bind the article treatment functions to nil.
8928 (let ((gnus-have-all-headers t)
8929 gnus-article-prepare-hook
8930 gnus-article-decode-hook
8931 gnus-display-mime-function
8932 gnus-break-pages)
8933 ;; Destroy any MIME parts.
8934 (when (gnus-buffer-live-p gnus-article-buffer)
8935 (save-excursion
8936 (set-buffer gnus-article-buffer)
8937 (mm-destroy-parts gnus-article-mime-handles)
8938 ;; Set it to nil for safety reason.
8939 (setq gnus-article-mime-handle-alist nil)
8940 (setq gnus-article-mime-handles nil)))
8941 (gnus-summary-select-article nil 'force))))
8942 (gnus-summary-goto-subject gnus-current-article)
8943 (gnus-summary-position-point))
8944
8945 (defun gnus-summary-show-raw-article ()
8946 "Show the raw article without any article massaging functions being run."
8947 (interactive)
8948 (gnus-summary-show-article t))
8949
8950 (defun gnus-summary-verbose-headers (&optional arg)
8951 "Toggle permanent full header display.
8952 If ARG is a positive number, turn header display on.
8953 If ARG is a negative number, turn header display off."
8954 (interactive "P")
8955 (setq gnus-show-all-headers
8956 (cond ((or (not (numberp arg))
8957 (zerop arg))
8958 (not gnus-show-all-headers))
8959 ((natnump arg)
8960 t)))
8961 (gnus-summary-show-article))
8962
8963 (defun gnus-summary-toggle-header (&optional arg)
8964 "Show the headers if they are hidden, or hide them if they are shown.
8965 If ARG is a positive number, show the entire header.
8966 If ARG is a negative number, hide the unwanted header lines."
8967 (interactive "P")
8968 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8969 (get-buffer-window gnus-article-buffer t))))
8970 (with-current-buffer gnus-article-buffer
8971 (widen)
8972 (article-narrow-to-head)
8973 (let* ((buffer-read-only nil)
8974 (inhibit-point-motion-hooks t)
8975 (hidden (if (numberp arg)
8976 (>= arg 0)
8977 (or (not (looking-at "[^ \t\n]+:"))
8978 (gnus-article-hidden-text-p 'headers))))
8979 s e)
8980 (delete-region (point-min) (point-max))
8981 (with-current-buffer gnus-original-article-buffer
8982 (goto-char (setq s (point-min)))
8983 (setq e (if (search-forward "\n\n" nil t)
8984 (1- (point))
8985 (point-max))))
8986 (insert-buffer-substring gnus-original-article-buffer s e)
8987 (run-hooks 'gnus-article-decode-hook)
8988 (if hidden
8989 (let ((gnus-treat-hide-headers nil)
8990 (gnus-treat-hide-boring-headers nil))
8991 (gnus-delete-wash-type 'headers)
8992 (gnus-treat-article 'head))
8993 (gnus-treat-article 'head))
8994 (widen)
8995 (if window
8996 (set-window-start window (goto-char (point-min))))
8997 (if gnus-break-pages
8998 (gnus-narrow-to-page)
8999 (when (gnus-visual-p 'page-marker)
9000 (let ((buffer-read-only nil))
9001 (gnus-remove-text-with-property 'gnus-prev)
9002 (gnus-remove-text-with-property 'gnus-next))))
9003 (gnus-set-mode-line 'article)))))
9004
9005 (defun gnus-summary-show-all-headers ()
9006 "Make all header lines visible."
9007 (interactive)
9008 (gnus-summary-toggle-header 1))
9009
9010 (defun gnus-summary-caesar-message (&optional arg)
9011 "Caesar rotate the current article by 13.
9012 The numerical prefix specifies how many places to rotate each letter
9013 forward."
9014 (interactive "P")
9015 (gnus-summary-select-article)
9016 (let ((mail-header-separator ""))
9017 (gnus-eval-in-buffer-window gnus-article-buffer
9018 (save-restriction
9019 (widen)
9020 (let ((start (window-start))
9021 buffer-read-only)
9022 (message-caesar-buffer-body arg)
9023 (set-window-start (get-buffer-window (current-buffer)) start)))))
9024 ;; Create buttons and stuff...
9025 (gnus-treat-article nil))
9026
9027 (autoload 'unmorse-region "morse"
9028 "Convert morse coded text in region to ordinary ASCII text."
9029 t)
9030
9031 (defun gnus-summary-morse-message (&optional arg)
9032 "Morse decode the current article."
9033 (interactive "P")
9034 (gnus-summary-select-article)
9035 (let ((mail-header-separator ""))
9036 (gnus-eval-in-buffer-window gnus-article-buffer
9037 (save-excursion
9038 (save-restriction
9039 (widen)
9040 (let ((pos (window-start))
9041 buffer-read-only)
9042 (goto-char (point-min))
9043 (when (message-goto-body)
9044 (gnus-narrow-to-body))
9045 (goto-char (point-min))
9046 (while (re-search-forward "·" (point-max) t)
9047 (replace-match "."))
9048 (unmorse-region (point-min) (point-max))
9049 (widen)
9050 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9051
9052 (defun gnus-summary-stop-page-breaking ()
9053 "Stop page breaking in the current article."
9054 (interactive)
9055 (gnus-summary-select-article)
9056 (gnus-eval-in-buffer-window gnus-article-buffer
9057 (widen)
9058 (when (gnus-visual-p 'page-marker)
9059 (let ((buffer-read-only nil))
9060 (gnus-remove-text-with-property 'gnus-prev)
9061 (gnus-remove-text-with-property 'gnus-next))
9062 (setq gnus-page-broken nil))))
9063
9064 (defun gnus-summary-move-article (&optional n to-newsgroup
9065 select-method action)
9066 "Move the current article to a different newsgroup.
9067 If N is a positive number, move the N next articles.
9068 If N is a negative number, move the N previous articles.
9069 If N is nil and any articles have been marked with the process mark,
9070 move those articles instead.
9071 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9072 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9073 re-spool using this method.
9074
9075 When called interactively with TO-NEWSGROUP being nil, the value of
9076 the variable `gnus-move-split-methods' is used for finding a default
9077 for the target newsgroup.
9078
9079 For this function to work, both the current newsgroup and the
9080 newsgroup that you want to move to have to support the `request-move'
9081 and `request-accept' functions.
9082
9083 ACTION can be either `move' (the default), `crosspost' or `copy'."
9084 (interactive "P")
9085 (unless action
9086 (setq action 'move))
9087 ;; Check whether the source group supports the required functions.
9088 (cond ((and (eq action 'move)
9089 (not (gnus-check-backend-function
9090 'request-move-article gnus-newsgroup-name)))
9091 (error "The current group does not support article moving"))
9092 ((and (eq action 'crosspost)
9093 (not (gnus-check-backend-function
9094 'request-replace-article gnus-newsgroup-name)))
9095 (error "The current group does not support article editing")))
9096 (let ((articles (gnus-summary-work-articles n))
9097 (prefix (if (gnus-check-backend-function
9098 'request-move-article gnus-newsgroup-name)
9099 (gnus-group-real-prefix gnus-newsgroup-name)
9100 ""))
9101 (names '((move "Move" "Moving")
9102 (copy "Copy" "Copying")
9103 (crosspost "Crosspost" "Crossposting")))
9104 (copy-buf (save-excursion
9105 (nnheader-set-temp-buffer " *copy article*")))
9106 art-group to-method new-xref article to-groups)
9107 (unless (assq action names)
9108 (error "Unknown action %s" action))
9109 ;; Read the newsgroup name.
9110 (when (and (not to-newsgroup)
9111 (not select-method))
9112 (if (and gnus-move-split-methods
9113 (not
9114 (and (memq gnus-current-article articles)
9115 (gnus-buffer-live-p gnus-original-article-buffer))))
9116 ;; When `gnus-move-split-methods' is non-nil, we have to
9117 ;; select an article to give `gnus-read-move-group-name' an
9118 ;; opportunity to suggest an appropriate default. However,
9119 ;; we needn't render or mark the article.
9120 (let ((gnus-display-mime-function nil)
9121 (gnus-article-prepare-hook nil)
9122 (gnus-mark-article-hook nil))
9123 (gnus-summary-select-article nil nil nil (car articles))))
9124 (setq to-newsgroup
9125 (gnus-read-move-group-name
9126 (cadr (assq action names))
9127 (symbol-value (intern (format "gnus-current-%s-group" action)))
9128 articles prefix))
9129 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9130 (setq to-method (or select-method
9131 (gnus-server-to-method
9132 (gnus-group-method to-newsgroup))))
9133 ;; Check the method we are to move this article to...
9134 (unless (gnus-check-backend-function
9135 'request-accept-article (car to-method))
9136 (error "%s does not support article copying" (car to-method)))
9137 (unless (gnus-check-server to-method)
9138 (error "Can't open server %s" (car to-method)))
9139 (gnus-message 6 "%s to %s: %s..."
9140 (caddr (assq action names))
9141 (or (car select-method) to-newsgroup) articles)
9142 (while articles
9143 (setq article (pop articles))
9144 (setq
9145 art-group
9146 (cond
9147 ;; Move the article.
9148 ((eq action 'move)
9149 ;; Remove this article from future suppression.
9150 (gnus-dup-unsuppress-article article)
9151 (gnus-request-move-article
9152 article ; Article to move
9153 gnus-newsgroup-name ; From newsgroup
9154 (nth 1 (gnus-find-method-for-group
9155 gnus-newsgroup-name)) ; Server
9156 (list 'gnus-request-accept-article
9157 to-newsgroup (list 'quote select-method)
9158 (not articles) t) ; Accept form
9159 (not articles))) ; Only save nov last time
9160 ;; Copy the article.
9161 ((eq action 'copy)
9162 (save-excursion
9163 (set-buffer copy-buf)
9164 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9165 (gnus-request-accept-article
9166 to-newsgroup select-method (not articles) t))))
9167 ;; Crosspost the article.
9168 ((eq action 'crosspost)
9169 (let ((xref (message-tokenize-header
9170 (mail-header-xref (gnus-summary-article-header article))
9171 " ")))
9172 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9173 ":" (number-to-string article)))
9174 (unless xref
9175 (setq xref (list (system-name))))
9176 (setq new-xref
9177 (concat
9178 (mapconcat 'identity
9179 (delete "Xref:" (delete new-xref xref))
9180 " ")
9181 " " new-xref))
9182 (save-excursion
9183 (set-buffer copy-buf)
9184 ;; First put the article in the destination group.
9185 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9186 (when (consp (setq art-group
9187 (gnus-request-accept-article
9188 to-newsgroup select-method (not articles) t)))
9189 (setq new-xref (concat new-xref " " (car art-group)
9190 ":"
9191 (number-to-string (cdr art-group))))
9192 ;; Now we have the new Xrefs header, so we insert
9193 ;; it and replace the new article.
9194 (nnheader-replace-header "Xref" new-xref)
9195 (gnus-request-replace-article
9196 (cdr art-group) to-newsgroup (current-buffer) t)
9197 art-group))))))
9198 (cond
9199 ((not art-group)
9200 (gnus-message 1 "Couldn't %s article %s: %s"
9201 (cadr (assq action names)) article
9202 (nnheader-get-report (car to-method))))
9203 ((eq art-group 'junk)
9204 (when (eq action 'move)
9205 (gnus-summary-mark-article article gnus-canceled-mark)
9206 (gnus-message 4 "Deleted article %s" article)
9207 ;; run the delete hook
9208 (run-hook-with-args 'gnus-summary-article-delete-hook
9209 action
9210 (gnus-data-header
9211 (assoc article (gnus-data-list nil)))
9212 gnus-newsgroup-name nil
9213 select-method)))
9214 (t
9215 (let* ((pto-group (gnus-group-prefixed-name
9216 (car art-group) to-method))
9217 (entry
9218 (gnus-gethash pto-group gnus-newsrc-hashtb))
9219 (info (nth 2 entry))
9220 (to-group (gnus-info-group info))
9221 to-marks)
9222 ;; Update the group that has been moved to.
9223 (when (and info
9224 (memq action '(move copy)))
9225 (unless (member to-group to-groups)
9226 (push to-group to-groups))
9227
9228 (unless (memq article gnus-newsgroup-unreads)
9229 (push 'read to-marks)
9230 (gnus-info-set-read
9231 info (gnus-add-to-range (gnus-info-read info)
9232 (list (cdr art-group)))))
9233
9234 ;; See whether the article is to be put in the cache.
9235 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9236 gnus-article-mark-lists
9237 (delete '(expirable . expire)
9238 (copy-sequence gnus-article-mark-lists))))
9239 (to-article (cdr art-group)))
9240
9241 ;; Enter the article into the cache in the new group,
9242 ;; if that is required.
9243 (when gnus-use-cache
9244 (gnus-cache-possibly-enter-article
9245 to-group to-article
9246 (memq article gnus-newsgroup-marked)
9247 (memq article gnus-newsgroup-dormant)
9248 (memq article gnus-newsgroup-unreads)))
9249
9250 (when gnus-preserve-marks
9251 ;; Copy any marks over to the new group.
9252 (when (and (equal to-group gnus-newsgroup-name)
9253 (not (memq article gnus-newsgroup-unreads)))
9254 ;; Mark this article as read in this group.
9255 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9256 (setcdr (gnus-active to-group) to-article)
9257 (setcdr gnus-newsgroup-active to-article))
9258
9259 (while marks
9260 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9261 (when (memq article (symbol-value
9262 (intern (format "gnus-newsgroup-%s"
9263 (caar marks)))))
9264 (push (cdar marks) to-marks)
9265 ;; If the other group is the same as this group,
9266 ;; then we have to add the mark to the list.
9267 (when (equal to-group gnus-newsgroup-name)
9268 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9269 (cons to-article
9270 (symbol-value
9271 (intern (format "gnus-newsgroup-%s"
9272 (caar marks)))))))
9273 ;; Copy the marks to other group.
9274 (gnus-add-marked-articles
9275 to-group (cdar marks) (list to-article) info)))
9276 (setq marks (cdr marks)))
9277
9278 (gnus-request-set-mark
9279 to-group (list (list (list to-article) 'add to-marks))))
9280
9281 (gnus-dribble-enter
9282 (concat "(gnus-group-set-info '"
9283 (gnus-prin1-to-string (gnus-get-info to-group))
9284 ")"))))
9285
9286 ;; Update the Xref header in this article to point to
9287 ;; the new crossposted article we have just created.
9288 (when (eq action 'crosspost)
9289 (save-excursion
9290 (set-buffer copy-buf)
9291 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9292 (nnheader-replace-header "Xref" new-xref)
9293 (gnus-request-replace-article
9294 article gnus-newsgroup-name (current-buffer) t)))
9295
9296 ;; run the move/copy/crosspost/respool hook
9297 (run-hook-with-args 'gnus-summary-article-move-hook
9298 action
9299 (gnus-data-header
9300 (assoc article (gnus-data-list nil)))
9301 gnus-newsgroup-name
9302 to-newsgroup
9303 select-method))
9304
9305 ;;;!!!Why is this necessary?
9306 (set-buffer gnus-summary-buffer)
9307
9308 (gnus-summary-goto-subject article)
9309 (when (eq action 'move)
9310 (gnus-summary-mark-article article gnus-canceled-mark))))
9311 (gnus-summary-remove-process-mark article))
9312 ;; Re-activate all groups that have been moved to.
9313 (save-excursion
9314 (set-buffer gnus-group-buffer)
9315 (let ((gnus-group-marked to-groups))
9316 (gnus-group-get-new-news-this-group nil t)))
9317
9318 (gnus-kill-buffer copy-buf)
9319 (gnus-summary-position-point)
9320 (gnus-set-mode-line 'summary)))
9321
9322 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9323 "Copy the current article to some other group.
9324 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9325 When called interactively, if TO-NEWSGROUP is nil, use the value of
9326 the variable `gnus-move-split-methods' for finding a default target
9327 newsgroup.
9328 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9329 re-spool using this method."
9330 (interactive "P")
9331 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9332
9333 (defun gnus-summary-crosspost-article (&optional n)
9334 "Crosspost the current article to some other group."
9335 (interactive "P")
9336 (gnus-summary-move-article n nil nil 'crosspost))
9337
9338 (defcustom gnus-summary-respool-default-method nil
9339 "Default method type for respooling an article.
9340 If nil, use to the current newsgroup method."
9341 :type 'symbol
9342 :group 'gnus-summary-mail)
9343
9344 (defcustom gnus-summary-display-while-building nil
9345 "If non-nil, show and update the summary buffer as it's being built.
9346 If the value is t, update the buffer after every line is inserted. If
9347 the value is an integer (N), update the display every N lines."
9348 :version "22.1"
9349 :group 'gnus-thread
9350 :type '(choice (const :tag "off" nil)
9351 number
9352 (const :tag "frequently" t)))
9353
9354 (defun gnus-summary-respool-article (&optional n method)
9355 "Respool the current article.
9356 The article will be squeezed through the mail spooling process again,
9357 which means that it will be put in some mail newsgroup or other
9358 depending on `nnmail-split-methods'.
9359 If N is a positive number, respool the N next articles.
9360 If N is a negative number, respool the N previous articles.
9361 If N is nil and any articles have been marked with the process mark,
9362 respool those articles instead.
9363
9364 Respooling can be done both from mail groups and \"real\" newsgroups.
9365 In the former case, the articles in question will be moved from the
9366 current group into whatever groups they are destined to. In the
9367 latter case, they will be copied into the relevant groups."
9368 (interactive
9369 (list current-prefix-arg
9370 (let* ((methods (gnus-methods-using 'respool))
9371 (methname
9372 (symbol-name (or gnus-summary-respool-default-method
9373 (car (gnus-find-method-for-group
9374 gnus-newsgroup-name)))))
9375 (method
9376 (gnus-completing-read-with-default
9377 methname "Backend to use when respooling"
9378 methods nil t nil 'gnus-mail-method-history))
9379 ms)
9380 (cond
9381 ((zerop (length (setq ms (gnus-servers-using-backend
9382 (intern method)))))
9383 (list (intern method) ""))
9384 ((= 1 (length ms))
9385 (car ms))
9386 (t
9387 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9388 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9389 ms-alist))))))))
9390 (unless method
9391 (error "No method given for respooling"))
9392 (if (assoc (symbol-name
9393 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9394 (gnus-methods-using 'respool))
9395 (gnus-summary-move-article n nil method)
9396 (gnus-summary-copy-article n nil method)))
9397
9398 (defun gnus-summary-import-article (file &optional edit)
9399 "Import an arbitrary file into a mail newsgroup."
9400 (interactive "fImport file: \nP")
9401 (let ((group gnus-newsgroup-name)
9402 (now (current-time))
9403 atts lines group-art)
9404 (unless (gnus-check-backend-function 'request-accept-article group)
9405 (error "%s does not support article importing" group))
9406 (or (file-readable-p file)
9407 (not (file-regular-p file))
9408 (error "Can't read %s" file))
9409 (save-excursion
9410 (set-buffer (gnus-get-buffer-create " *import file*"))
9411 (erase-buffer)
9412 (nnheader-insert-file-contents file)
9413 (goto-char (point-min))
9414 (if (nnheader-article-p)
9415 (save-restriction
9416 (goto-char (point-min))
9417 (search-forward "\n\n" nil t)
9418 (narrow-to-region (point-min) (1- (point)))
9419 (goto-char (point-min))
9420 (unless (re-search-forward "^date:" nil t)
9421 (goto-char (point-max))
9422 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9423 ;; This doesn't look like an article, so we fudge some headers.
9424 (setq atts (file-attributes file)
9425 lines (count-lines (point-min) (point-max)))
9426 (insert "From: " (read-string "From: ") "\n"
9427 "Subject: " (read-string "Subject: ") "\n"
9428 "Date: " (message-make-date (nth 5 atts)) "\n"
9429 "Message-ID: " (message-make-message-id) "\n"
9430 "Lines: " (int-to-string lines) "\n"
9431 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9432 (setq group-art (gnus-request-accept-article group nil t))
9433 (kill-buffer (current-buffer)))
9434 (setq gnus-newsgroup-active (gnus-activate-group group))
9435 (forward-line 1)
9436 (gnus-summary-goto-article (cdr group-art) nil t)
9437 (when edit
9438 (gnus-summary-edit-article))))
9439
9440 (defun gnus-summary-create-article ()
9441 "Create an article in a mail newsgroup."
9442 (interactive)
9443 (let ((group gnus-newsgroup-name)
9444 (now (current-time))
9445 group-art)
9446 (unless (gnus-check-backend-function 'request-accept-article group)
9447 (error "%s does not support article importing" group))
9448 (save-excursion
9449 (set-buffer (gnus-get-buffer-create " *import file*"))
9450 (erase-buffer)
9451 (goto-char (point-min))
9452 ;; This doesn't look like an article, so we fudge some headers.
9453 (insert "From: " (read-string "From: ") "\n"
9454 "Subject: " (read-string "Subject: ") "\n"
9455 "Date: " (message-make-date now) "\n"
9456 "Message-ID: " (message-make-message-id) "\n")
9457 (setq group-art (gnus-request-accept-article group nil t))
9458 (kill-buffer (current-buffer)))
9459 (setq gnus-newsgroup-active (gnus-activate-group group))
9460 (forward-line 1)
9461 (gnus-summary-goto-article (cdr group-art) nil t)
9462 (gnus-summary-edit-article)))
9463
9464 (defun gnus-summary-article-posted-p ()
9465 "Say whether the current (mail) article is available from news as well.
9466 This will be the case if the article has both been mailed and posted."
9467 (interactive)
9468 (let ((id (mail-header-references (gnus-summary-article-header)))
9469 (gnus-override-method (car (gnus-refer-article-methods))))
9470 (if (gnus-request-head id "")
9471 (gnus-message 2 "The current message was found on %s"
9472 gnus-override-method)
9473 (gnus-message 2 "The current message couldn't be found on %s"
9474 gnus-override-method)
9475 nil)))
9476
9477 (defun gnus-summary-expire-articles (&optional now)
9478 "Expire all articles that are marked as expirable in the current group."
9479 (interactive)
9480 (when (and (not gnus-group-is-exiting-without-update-p)
9481 (gnus-check-backend-function
9482 'request-expire-articles gnus-newsgroup-name))
9483 ;; This backend supports expiry.
9484 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9485 (expirable (if total
9486 (progn
9487 ;; We need to update the info for
9488 ;; this group for `gnus-list-of-read-articles'
9489 ;; to give us the right answer.
9490 (gnus-run-hooks 'gnus-exit-group-hook)
9491 (gnus-summary-update-info)
9492 (gnus-list-of-read-articles gnus-newsgroup-name))
9493 (setq gnus-newsgroup-expirable
9494 (sort gnus-newsgroup-expirable '<))))
9495 (expiry-wait (if now 'immediate
9496 (gnus-group-find-parameter
9497 gnus-newsgroup-name 'expiry-wait)))
9498 (nnmail-expiry-target
9499 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9500 nnmail-expiry-target))
9501 es)
9502 (when expirable
9503 ;; There are expirable articles in this group, so we run them
9504 ;; through the expiry process.
9505 (gnus-message 6 "Expiring articles...")
9506 (unless (gnus-check-group gnus-newsgroup-name)
9507 (error "Can't open server for %s" gnus-newsgroup-name))
9508 ;; The list of articles that weren't expired is returned.
9509 (save-excursion
9510 (if expiry-wait
9511 (let ((nnmail-expiry-wait-function nil)
9512 (nnmail-expiry-wait expiry-wait))
9513 (setq es (gnus-request-expire-articles
9514 expirable gnus-newsgroup-name)))
9515 (setq es (gnus-request-expire-articles
9516 expirable gnus-newsgroup-name)))
9517 (unless total
9518 (setq gnus-newsgroup-expirable es))
9519 ;; We go through the old list of expirable, and mark all
9520 ;; really expired articles as nonexistent.
9521 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9522 (let ((gnus-use-cache nil))
9523 (dolist (article expirable)
9524 (when (and (not (memq article es))
9525 (gnus-data-find article))
9526 (gnus-summary-mark-article article gnus-canceled-mark)
9527 (run-hook-with-args 'gnus-summary-article-expire-hook
9528 'delete
9529 (gnus-data-header
9530 (assoc article (gnus-data-list nil)))
9531 gnus-newsgroup-name
9532 nil
9533 nil))))))
9534 (gnus-message 6 "Expiring articles...done")))))
9535
9536 (defun gnus-summary-expire-articles-now ()
9537 "Expunge all expirable articles in the current group.
9538 This means that *all* articles that are marked as expirable will be
9539 deleted forever, right now."
9540 (interactive)
9541 (or gnus-expert-user
9542 (gnus-yes-or-no-p
9543 "Are you really, really sure you want to delete all expirable messages? ")
9544 (error "Phew!"))
9545 (gnus-summary-expire-articles t))
9546
9547 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9548 (defun gnus-summary-delete-article (&optional n)
9549 "Delete the N next (mail) articles.
9550 This command actually deletes articles. This is not a marking
9551 command. The article will disappear forever from your life, never to
9552 return.
9553
9554 If N is negative, delete backwards.
9555 If N is nil and articles have been marked with the process mark,
9556 delete these instead.
9557
9558 If `gnus-novice-user' is non-nil you will be asked for
9559 confirmation before the articles are deleted."
9560 (interactive "P")
9561 (unless (gnus-check-backend-function 'request-expire-articles
9562 gnus-newsgroup-name)
9563 (error "The current newsgroup does not support article deletion"))
9564 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9565 (error "Couldn't open server"))
9566 ;; Compute the list of articles to delete.
9567 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9568 (nnmail-expiry-target 'delete)
9569 not-deleted)
9570 (if (and gnus-novice-user
9571 (not (gnus-yes-or-no-p
9572 (format "Do you really want to delete %s forever? "
9573 (if (> (length articles) 1)
9574 (format "these %s articles" (length articles))
9575 "this article")))))
9576 ()
9577 ;; Delete the articles.
9578 (setq not-deleted (gnus-request-expire-articles
9579 articles gnus-newsgroup-name 'force))
9580 (while articles
9581 (gnus-summary-remove-process-mark (car articles))
9582 ;; The backend might not have been able to delete the article
9583 ;; after all.
9584 (unless (memq (car articles) not-deleted)
9585 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9586 (let* ((article (car articles))
9587 (id (mail-header-id (gnus-data-header
9588 (assoc article (gnus-data-list nil))))))
9589 (run-hook-with-args 'gnus-summary-article-delete-hook
9590 'delete id gnus-newsgroup-name nil
9591 nil))
9592 (setq articles (cdr articles)))
9593 (when not-deleted
9594 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9595 (gnus-summary-position-point)
9596 (gnus-set-mode-line 'summary)
9597 not-deleted))
9598
9599 (defun gnus-summary-edit-article (&optional arg)
9600 "Edit the current article.
9601 This will have permanent effect only in mail groups.
9602 If ARG is nil, edit the decoded articles.
9603 If ARG is 1, edit the raw articles.
9604 If ARG is 2, edit the raw articles even in read-only groups.
9605 If ARG is 3, edit the articles with the current handles.
9606 Otherwise, allow editing of articles even in read-only
9607 groups."
9608 (interactive "P")
9609 (let (force raw current-handles)
9610 (cond
9611 ((null arg))
9612 ((eq arg 1)
9613 (setq raw t))
9614 ((eq arg 2)
9615 (setq raw t
9616 force t))
9617 ((eq arg 3)
9618 (setq current-handles
9619 (and (gnus-buffer-live-p gnus-article-buffer)
9620 (with-current-buffer gnus-article-buffer
9621 (prog1
9622 gnus-article-mime-handles
9623 (setq gnus-article-mime-handles nil))))))
9624 (t
9625 (setq force t)))
9626 (when (and raw (not force)
9627 (member gnus-newsgroup-name '("nndraft:delayed"
9628 "nndraft:drafts"
9629 "nndraft:queue")))
9630 (error "Can't edit the raw article in group %s"
9631 gnus-newsgroup-name))
9632 (save-excursion
9633 (set-buffer gnus-summary-buffer)
9634 (let ((mail-parse-charset gnus-newsgroup-charset)
9635 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9636 (gnus-set-global-variables)
9637 (when (and (not force)
9638 (gnus-group-read-only-p))
9639 (error "The current newsgroup does not support article editing"))
9640 (gnus-summary-show-article t)
9641 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9642 (with-current-buffer gnus-article-buffer
9643 (mm-enable-multibyte)))
9644 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9645 (setq raw t))
9646 (gnus-article-edit-article
9647 (if raw 'ignore
9648 `(lambda ()
9649 (let ((mbl mml-buffer-list))
9650 (setq mml-buffer-list nil)
9651 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9652 (mime-to-mml ,'current-handles))
9653 (let ((mbl1 mml-buffer-list))
9654 (setq mml-buffer-list mbl)
9655 (set (make-local-variable 'mml-buffer-list) mbl1))
9656 (gnus-make-local-hook 'kill-buffer-hook)
9657 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9658 `(lambda (no-highlight)
9659 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9660 (message-options message-options)
9661 (message-options-set-recipient)
9662 (mail-parse-ignored-charsets
9663 ',gnus-newsgroup-ignored-charsets))
9664 ,(if (not raw) '(progn
9665 (mml-to-mime)
9666 (mml-destroy-buffers)
9667 (remove-hook 'kill-buffer-hook
9668 'mml-destroy-buffers t)
9669 (kill-local-variable 'mml-buffer-list)))
9670 (gnus-summary-edit-article-done
9671 ,(or (mail-header-references gnus-current-headers) "")
9672 ,(gnus-group-read-only-p)
9673 ,gnus-summary-buffer no-highlight))))))))
9674
9675 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9676
9677 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9678 no-highlight)
9679 "Make edits to the current article permanent."
9680 (interactive)
9681 (save-excursion
9682 ;; The buffer restriction contains the entire article if it exists.
9683 (when (article-goto-body)
9684 (let ((lines (count-lines (point) (point-max)))
9685 (length (- (point-max) (point)))
9686 (case-fold-search t)
9687 (body (copy-marker (point))))
9688 (goto-char (point-min))
9689 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9690 (delete-region (match-beginning 1) (match-end 1))
9691 (insert (number-to-string length)))
9692 (goto-char (point-min))
9693 (when (re-search-forward
9694 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9695 (delete-region (match-beginning 1) (match-end 1))
9696 (insert (number-to-string length)))
9697 (goto-char (point-min))
9698 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9699 (delete-region (match-beginning 1) (match-end 1))
9700 (insert (number-to-string lines))))))
9701 ;; Replace the article.
9702 (let ((buf (current-buffer)))
9703 (with-temp-buffer
9704 (insert-buffer-substring buf)
9705
9706 (if (and (not read-only)
9707 (not (gnus-request-replace-article
9708 (cdr gnus-article-current) (car gnus-article-current)
9709 (current-buffer) t)))
9710 (error "Couldn't replace article")
9711 ;; Update the summary buffer.
9712 (if (and references
9713 (equal (message-tokenize-header references " ")
9714 (message-tokenize-header
9715 (or (message-fetch-field "references") "") " ")))
9716 ;; We only have to update this line.
9717 (save-excursion
9718 (save-restriction
9719 (message-narrow-to-head)
9720 (let ((head (buffer-substring-no-properties
9721 (point-min) (point-max)))
9722 header)
9723 (with-temp-buffer
9724 (insert (format "211 %d Article retrieved.\n"
9725 (cdr gnus-article-current)))
9726 (insert head)
9727 (insert ".\n")
9728 (let ((nntp-server-buffer (current-buffer)))
9729 (setq header (car (gnus-get-newsgroup-headers
9730 nil t))))
9731 (save-excursion
9732 (set-buffer gnus-summary-buffer)
9733 (gnus-data-set-header
9734 (gnus-data-find (cdr gnus-article-current))
9735 header)
9736 (gnus-summary-update-article-line
9737 (cdr gnus-article-current) header)
9738 (if (gnus-summary-goto-subject
9739 (cdr gnus-article-current) nil t)
9740 (gnus-summary-update-secondary-mark
9741 (cdr gnus-article-current))))))))
9742 ;; Update threads.
9743 (set-buffer (or buffer gnus-summary-buffer))
9744 (gnus-summary-update-article (cdr gnus-article-current))
9745 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9746 (gnus-summary-update-secondary-mark
9747 (cdr gnus-article-current))))
9748 ;; Prettify the article buffer again.
9749 (unless no-highlight
9750 (save-excursion
9751 (set-buffer gnus-article-buffer)
9752 ;;;!!! Fix this -- article should be rehighlighted.
9753 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9754 (set-buffer gnus-original-article-buffer)
9755 (gnus-request-article
9756 (cdr gnus-article-current)
9757 (car gnus-article-current) (current-buffer))))
9758 ;; Prettify the summary buffer line.
9759 (when (gnus-visual-p 'summary-highlight 'highlight)
9760 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9761
9762 (defun gnus-summary-edit-wash (key)
9763 "Perform editing command KEY in the article buffer."
9764 (interactive
9765 (list
9766 (progn
9767 (message "%s" (concat (this-command-keys) "- "))
9768 (read-char))))
9769 (message "")
9770 (gnus-summary-edit-article)
9771 (execute-kbd-macro (concat (this-command-keys) key))
9772 (gnus-article-edit-done))
9773
9774 ;;; Respooling
9775
9776 (defun gnus-summary-respool-query (&optional silent trace)
9777 "Query where the respool algorithm would put this article."
9778 (interactive)
9779 (let (gnus-mark-article-hook)
9780 (gnus-summary-select-article)
9781 (save-excursion
9782 (set-buffer gnus-original-article-buffer)
9783 (let ((groups (nnmail-article-group 'identity trace)))
9784 (unless silent
9785 (if groups
9786 (message "This message would go to %s"
9787 (mapconcat 'car groups ", "))
9788 (message "This message would go to no groups"))
9789 groups)))))
9790
9791 (defun gnus-summary-respool-trace ()
9792 "Trace where the respool algorithm would put this article.
9793 Display a buffer showing all fancy splitting patterns which matched."
9794 (interactive)
9795 (gnus-summary-respool-query nil t))
9796
9797 ;; Summary marking commands.
9798
9799 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9800 "Mark articles which has the same subject as read, and then select the next.
9801 If UNMARK is positive, remove any kind of mark.
9802 If UNMARK is negative, tick articles."
9803 (interactive "P")
9804 (when unmark
9805 (setq unmark (prefix-numeric-value unmark)))
9806 (let ((count
9807 (gnus-summary-mark-same-subject
9808 (gnus-summary-article-subject) unmark)))
9809 ;; Select next unread article. If auto-select-same mode, should
9810 ;; select the first unread article.
9811 (gnus-summary-next-article t (and gnus-auto-select-same
9812 (gnus-summary-article-subject)))
9813 (gnus-message 7 "%d article%s marked as %s"
9814 count (if (= count 1) " is" "s are")
9815 (if unmark "unread" "read"))))
9816
9817 (defun gnus-summary-kill-same-subject (&optional unmark)
9818 "Mark articles which has the same subject as read.
9819 If UNMARK is positive, remove any kind of mark.
9820 If UNMARK is negative, tick articles."
9821 (interactive "P")
9822 (when unmark
9823 (setq unmark (prefix-numeric-value unmark)))
9824 (let ((count
9825 (gnus-summary-mark-same-subject
9826 (gnus-summary-article-subject) unmark)))
9827 ;; If marked as read, go to next unread subject.
9828 (when (null unmark)
9829 ;; Go to next unread subject.
9830 (gnus-summary-next-subject 1 t))
9831 (gnus-message 7 "%d articles are marked as %s"
9832 count (if unmark "unread" "read"))))
9833
9834 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9835 "Mark articles with same SUBJECT as read, and return marked number.
9836 If optional argument UNMARK is positive, remove any kinds of marks.
9837 If optional argument UNMARK is negative, mark articles as unread instead."
9838 (let ((count 1))
9839 (save-excursion
9840 (cond
9841 ((null unmark) ; Mark as read.
9842 (while (and
9843 (progn
9844 (gnus-summary-mark-article-as-read gnus-killed-mark)
9845 (gnus-summary-show-thread) t)
9846 (gnus-summary-find-subject subject))
9847 (setq count (1+ count))))
9848 ((> unmark 0) ; Tick.
9849 (while (and
9850 (progn
9851 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9852 (gnus-summary-show-thread) t)
9853 (gnus-summary-find-subject subject))
9854 (setq count (1+ count))))
9855 (t ; Mark as unread.
9856 (while (and
9857 (progn
9858 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9859 (gnus-summary-show-thread) t)
9860 (gnus-summary-find-subject subject))
9861 (setq count (1+ count)))))
9862 (gnus-set-mode-line 'summary)
9863 ;; Return the number of marked articles.
9864 count)))
9865
9866 (defun gnus-summary-mark-as-processable (n &optional unmark)
9867 "Set the process mark on the next N articles.
9868 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9869 the process mark instead. The difference between N and the actual
9870 number of articles marked is returned."
9871 (interactive "P")
9872 (if (and (null n) (gnus-region-active-p))
9873 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9874 (setq n (prefix-numeric-value n))
9875 (let ((backward (< n 0))
9876 (n (abs n)))
9877 (while (and
9878 (> n 0)
9879 (if unmark
9880 (gnus-summary-remove-process-mark
9881 (gnus-summary-article-number))
9882 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9883 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9884 (setq n (1- n)))
9885 (when (/= 0 n)
9886 (gnus-message 7 "No more articles"))
9887 (gnus-summary-recenter)
9888 (gnus-summary-position-point)
9889 n)))
9890
9891 (defun gnus-summary-unmark-as-processable (n)
9892 "Remove the process mark from the next N articles.
9893 If N is negative, unmark backward instead. The difference between N and
9894 the actual number of articles unmarked is returned."
9895 (interactive "P")
9896 (gnus-summary-mark-as-processable n t))
9897
9898 (defun gnus-summary-unmark-all-processable ()
9899 "Remove the process mark from all articles."
9900 (interactive)
9901 (save-excursion
9902 (while gnus-newsgroup-processable
9903 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9904 (gnus-summary-position-point))
9905
9906 (defun gnus-summary-add-mark (article type)
9907 "Mark ARTICLE with a mark of TYPE."
9908 (let ((vtype (car (assq type gnus-article-mark-lists)))
9909 var)
9910 (if (not vtype)
9911 (error "No such mark type: %s" type)
9912 (setq var (intern (format "gnus-newsgroup-%s" type)))
9913 (set var (cons article (symbol-value var)))
9914 (if (memq type '(processable cached replied forwarded recent saved))
9915 (gnus-summary-update-secondary-mark article)
9916 ;;; !!! This is bogus. We should find out what primary
9917 ;;; !!! mark we want to set.
9918 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9919
9920 (defun gnus-summary-mark-as-expirable (n)
9921 "Mark N articles forward as expirable.
9922 If N is negative, mark backward instead. The difference between N and
9923 the actual number of articles marked is returned."
9924 (interactive "p")
9925 (gnus-summary-mark-forward n gnus-expirable-mark))
9926
9927 (defun gnus-summary-mark-as-spam (n)
9928 "Mark N articles forward as spam.
9929 If N is negative, mark backward instead. The difference between N and
9930 the actual number of articles marked is returned."
9931 (interactive "p")
9932 (gnus-summary-mark-forward n gnus-spam-mark))
9933
9934 (defun gnus-summary-mark-article-as-replied (article)
9935 "Mark ARTICLE as replied to and update the summary line.
9936 ARTICLE can also be a list of articles."
9937 (interactive (list (gnus-summary-article-number)))
9938 (let ((articles (if (listp article) article (list article))))
9939 (dolist (article articles)
9940 (unless (numberp article)
9941 (error "%s is not a number" article))
9942 (push article gnus-newsgroup-replied)
9943 (let ((buffer-read-only nil))
9944 (when (gnus-summary-goto-subject article nil t)
9945 (gnus-summary-update-secondary-mark article))))))
9946
9947 (defun gnus-summary-mark-article-as-forwarded (article)
9948 "Mark ARTICLE as forwarded and update the summary line.
9949 ARTICLE can also be a list of articles."
9950 (let ((articles (if (listp article) article (list article))))
9951 (dolist (article articles)
9952 (push article gnus-newsgroup-forwarded)
9953 (let ((buffer-read-only nil))
9954 (when (gnus-summary-goto-subject article nil t)
9955 (gnus-summary-update-secondary-mark article))))))
9956
9957 (defun gnus-summary-set-bookmark (article)
9958 "Set a bookmark in current article."
9959 (interactive (list (gnus-summary-article-number)))
9960 (when (or (not (get-buffer gnus-article-buffer))
9961 (not gnus-current-article)
9962 (not gnus-article-current)
9963 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9964 (error "No current article selected"))
9965 ;; Remove old bookmark, if one exists.
9966 (gnus-pull article gnus-newsgroup-bookmarks)
9967 ;; Set the new bookmark, which is on the form
9968 ;; (article-number . line-number-in-body).
9969 (push
9970 (cons article
9971 (save-excursion
9972 (set-buffer gnus-article-buffer)
9973 (count-lines
9974 (min (point)
9975 (save-excursion
9976 (article-goto-body)
9977 (point)))
9978 (point))))
9979 gnus-newsgroup-bookmarks)
9980 (gnus-message 6 "A bookmark has been added to the current article."))
9981
9982 (defun gnus-summary-remove-bookmark (article)
9983 "Remove the bookmark from the current article."
9984 (interactive (list (gnus-summary-article-number)))
9985 ;; Remove old bookmark, if one exists.
9986 (if (not (assq article gnus-newsgroup-bookmarks))
9987 (gnus-message 6 "No bookmark in current article.")
9988 (gnus-pull article gnus-newsgroup-bookmarks)
9989 (gnus-message 6 "Removed bookmark.")))
9990
9991 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9992 (defun gnus-summary-mark-as-dormant (n)
9993 "Mark N articles forward as dormant.
9994 If N is negative, mark backward instead. The difference between N and
9995 the actual number of articles marked is returned."
9996 (interactive "p")
9997 (gnus-summary-mark-forward n gnus-dormant-mark))
9998
9999 (defun gnus-summary-set-process-mark (article)
10000 "Set the process mark on ARTICLE and update the summary line."
10001 (setq gnus-newsgroup-processable
10002 (cons article
10003 (delq article gnus-newsgroup-processable)))
10004 (when (gnus-summary-goto-subject article)
10005 (gnus-summary-show-thread)
10006 (gnus-summary-goto-subject article)
10007 (gnus-summary-update-secondary-mark article)))
10008
10009 (defun gnus-summary-remove-process-mark (article)
10010 "Remove the process mark from ARTICLE and update the summary line."
10011 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10012 (when (gnus-summary-goto-subject article)
10013 (gnus-summary-show-thread)
10014 (gnus-summary-goto-subject article)
10015 (gnus-summary-update-secondary-mark article)))
10016
10017 (defun gnus-summary-set-saved-mark (article)
10018 "Set the process mark on ARTICLE and update the summary line."
10019 (push article gnus-newsgroup-saved)
10020 (when (gnus-summary-goto-subject article)
10021 (gnus-summary-update-secondary-mark article)))
10022
10023 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10024 "Mark N articles as read forwards.
10025 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10026 The difference between N and the actual number of articles marked is
10027 returned.
10028 If NO-EXPIRE, auto-expiry will be inhibited."
10029 (interactive "p")
10030 (gnus-summary-show-thread)
10031 (let ((backward (< n 0))
10032 (gnus-summary-goto-unread
10033 (and gnus-summary-goto-unread
10034 (not (eq gnus-summary-goto-unread 'never))
10035 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10036 gnus-ticked-mark gnus-dormant-mark)))))
10037 (n (abs n))
10038 (mark (or mark gnus-del-mark)))
10039 (while (and (> n 0)
10040 (gnus-summary-mark-article nil mark no-expire)
10041 (zerop (gnus-summary-next-subject
10042 (if backward -1 1)
10043 (and gnus-summary-goto-unread
10044 (not (eq gnus-summary-goto-unread 'never)))
10045 t)))
10046 (setq n (1- n)))
10047 (when (/= 0 n)
10048 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10049 (gnus-summary-recenter)
10050 (gnus-summary-position-point)
10051 (gnus-set-mode-line 'summary)
10052 n))
10053
10054 (defun gnus-summary-mark-article-as-read (mark)
10055 "Mark the current article quickly as read with MARK."
10056 (let ((article (gnus-summary-article-number)))
10057 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10058 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10059 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10060 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10061 (push (cons article mark) gnus-newsgroup-reads)
10062 ;; Possibly remove from cache, if that is used.
10063 (when gnus-use-cache
10064 (gnus-cache-enter-remove-article article))
10065 ;; Allow the backend to change the mark.
10066 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10067 ;; Check for auto-expiry.
10068 (when (and gnus-newsgroup-auto-expire
10069 (memq mark gnus-auto-expirable-marks))
10070 (setq mark gnus-expirable-mark)
10071 ;; Let the backend know about the mark change.
10072 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10073 (push article gnus-newsgroup-expirable))
10074 ;; Set the mark in the buffer.
10075 (gnus-summary-update-mark mark 'unread)
10076 t))
10077
10078 (defun gnus-summary-mark-article-as-unread (mark)
10079 "Mark the current article quickly as unread with MARK."
10080 (let* ((article (gnus-summary-article-number))
10081 (old-mark (gnus-summary-article-mark article)))
10082 ;; Allow the backend to change the mark.
10083 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10084 (if (eq mark old-mark)
10085 t
10086 (if (<= article 0)
10087 (progn
10088 (gnus-error 1 "Can't mark negative article numbers")
10089 nil)
10090 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10091 (setq gnus-newsgroup-spam-marked
10092 (delq article gnus-newsgroup-spam-marked))
10093 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10094 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10095 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10096 (cond ((= mark gnus-ticked-mark)
10097 (setq gnus-newsgroup-marked
10098 (gnus-add-to-sorted-list gnus-newsgroup-marked
10099 article)))
10100 ((= mark gnus-spam-mark)
10101 (setq gnus-newsgroup-spam-marked
10102 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10103 article)))
10104 ((= mark gnus-dormant-mark)
10105 (setq gnus-newsgroup-dormant
10106 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10107 article)))
10108 (t
10109 (setq gnus-newsgroup-unreads
10110 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10111 article))))
10112 (gnus-pull article gnus-newsgroup-reads)
10113
10114 ;; See whether the article is to be put in the cache.
10115 (and gnus-use-cache
10116 (vectorp (gnus-summary-article-header article))
10117 (save-excursion
10118 (gnus-cache-possibly-enter-article
10119 gnus-newsgroup-name article
10120 (= mark gnus-ticked-mark)
10121 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10122
10123 ;; Fix the mark.
10124 (gnus-summary-update-mark mark 'unread)
10125 t))))
10126
10127 (defun gnus-summary-mark-article (&optional article mark no-expire)
10128 "Mark ARTICLE with MARK. MARK can be any character.
10129 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10130 `??' (dormant) and `?E' (expirable).
10131 If MARK is nil, then the default character `?r' is used.
10132 If ARTICLE is nil, then the article on the current line will be
10133 marked.
10134 If NO-EXPIRE, auto-expiry will be inhibited."
10135 ;; The mark might be a string.
10136 (when (stringp mark)
10137 (setq mark (aref mark 0)))
10138 ;; If no mark is given, then we check auto-expiring.
10139 (when (null mark)
10140 (setq mark gnus-del-mark))
10141 (when (and (not no-expire)
10142 gnus-newsgroup-auto-expire
10143 (memq mark gnus-auto-expirable-marks))
10144 (setq mark gnus-expirable-mark))
10145 (let ((article (or article (gnus-summary-article-number)))
10146 (old-mark (gnus-summary-article-mark article)))
10147 ;; Allow the backend to change the mark.
10148 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10149 (if (eq mark old-mark)
10150 t
10151 (unless article
10152 (error "No article on current line"))
10153 (if (not (if (or (= mark gnus-unread-mark)
10154 (= mark gnus-ticked-mark)
10155 (= mark gnus-spam-mark)
10156 (= mark gnus-dormant-mark))
10157 (gnus-mark-article-as-unread article mark)
10158 (gnus-mark-article-as-read article mark)))
10159 t
10160 ;; See whether the article is to be put in the cache.
10161 (and gnus-use-cache
10162 (not (= mark gnus-canceled-mark))
10163 (vectorp (gnus-summary-article-header article))
10164 (save-excursion
10165 (gnus-cache-possibly-enter-article
10166 gnus-newsgroup-name article
10167 (= mark gnus-ticked-mark)
10168 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10169
10170 (when (gnus-summary-goto-subject article nil t)
10171 (let ((buffer-read-only nil))
10172 (gnus-summary-show-thread)
10173 ;; Fix the mark.
10174 (gnus-summary-update-mark mark 'unread)
10175 t))))))
10176
10177 (defun gnus-summary-update-secondary-mark (article)
10178 "Update the secondary (read, process, cache) mark."
10179 (gnus-summary-update-mark
10180 (cond ((memq article gnus-newsgroup-processable)
10181 gnus-process-mark)
10182 ((memq article gnus-newsgroup-cached)
10183 gnus-cached-mark)
10184 ((memq article gnus-newsgroup-replied)
10185 gnus-replied-mark)
10186 ((memq article gnus-newsgroup-forwarded)
10187 gnus-forwarded-mark)
10188 ((memq article gnus-newsgroup-saved)
10189 gnus-saved-mark)
10190 ((memq article gnus-newsgroup-recent)
10191 gnus-recent-mark)
10192 ((memq article gnus-newsgroup-unseen)
10193 gnus-unseen-mark)
10194 (t gnus-no-mark))
10195 'replied)
10196 (when (gnus-visual-p 'summary-highlight 'highlight)
10197 (gnus-run-hooks 'gnus-summary-update-hook))
10198 t)
10199
10200 (defun gnus-summary-update-download-mark (article)
10201 "Update the download mark."
10202 (gnus-summary-update-mark
10203 (cond ((memq article gnus-newsgroup-undownloaded)
10204 gnus-undownloaded-mark)
10205 (gnus-newsgroup-agentized
10206 gnus-downloaded-mark)
10207 (t
10208 gnus-no-mark))
10209 'download)
10210 (gnus-summary-update-line t)
10211 t)
10212
10213 (defun gnus-summary-update-mark (mark type)
10214 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10215 (buffer-read-only nil))
10216 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10217 (when forward
10218 (when (looking-at "\r")
10219 (incf forward))
10220 (when (<= (+ forward (point)) (point-max))
10221 ;; Go to the right position on the line.
10222 (goto-char (+ forward (point)))
10223 ;; Replace the old mark with the new mark.
10224 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10225 ;; Optionally update the marks by some user rule.
10226 (when (eq type 'unread)
10227 (gnus-data-set-mark
10228 (gnus-data-find (gnus-summary-article-number)) mark)
10229 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10230
10231 (defun gnus-mark-article-as-read (article &optional mark)
10232 "Enter ARTICLE in the pertinent lists and remove it from others."
10233 ;; Make the article expirable.
10234 (let ((mark (or mark gnus-del-mark)))
10235 (setq gnus-newsgroup-expirable
10236 (if (= mark gnus-expirable-mark)
10237 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10238 (delq article gnus-newsgroup-expirable)))
10239 ;; Remove from unread and marked lists.
10240 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10241 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10242 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10243 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10244 (push (cons article mark) gnus-newsgroup-reads)
10245 ;; Possibly remove from cache, if that is used.
10246 (when gnus-use-cache
10247 (gnus-cache-enter-remove-article article))
10248 t))
10249
10250 (defun gnus-mark-article-as-unread (article &optional mark)
10251 "Enter ARTICLE in the pertinent lists and remove it from others."
10252 (let ((mark (or mark gnus-ticked-mark)))
10253 (if (<= article 0)
10254 (progn
10255 (gnus-error 1 "Can't mark negative article numbers")
10256 nil)
10257 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10258 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10259 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10260 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10261 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10262
10263 ;; Unsuppress duplicates?
10264 (when gnus-suppress-duplicates
10265 (gnus-dup-unsuppress-article article))
10266
10267 (cond ((= mark gnus-ticked-mark)
10268 (setq gnus-newsgroup-marked
10269 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10270 ((= mark gnus-spam-mark)
10271 (setq gnus-newsgroup-spam-marked
10272 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10273 article)))
10274 ((= mark gnus-dormant-mark)
10275 (setq gnus-newsgroup-dormant
10276 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10277 (t
10278 (setq gnus-newsgroup-unreads
10279 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10280 (gnus-pull article gnus-newsgroup-reads)
10281 t)))
10282
10283 (defalias 'gnus-summary-mark-as-unread-forward
10284 'gnus-summary-tick-article-forward)
10285 (make-obsolete 'gnus-summary-mark-as-unread-forward
10286 'gnus-summary-tick-article-forward)
10287 (defun gnus-summary-tick-article-forward (n)
10288 "Tick N articles forwards.
10289 If N is negative, tick backwards instead.
10290 The difference between N and the number of articles ticked is returned."
10291 (interactive "p")
10292 (gnus-summary-mark-forward n gnus-ticked-mark))
10293
10294 (defalias 'gnus-summary-mark-as-unread-backward
10295 'gnus-summary-tick-article-backward)
10296 (make-obsolete 'gnus-summary-mark-as-unread-backward
10297 'gnus-summary-tick-article-backward)
10298 (defun gnus-summary-tick-article-backward (n)
10299 "Tick N articles backwards.
10300 The difference between N and the number of articles ticked is returned."
10301 (interactive "p")
10302 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10303
10304 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10305 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10306 (defun gnus-summary-tick-article (&optional article clear-mark)
10307 "Mark current article as unread.
10308 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10309 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10310 (interactive)
10311 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10312 gnus-ticked-mark)))
10313
10314 (defun gnus-summary-mark-as-read-forward (n)
10315 "Mark N articles as read forwards.
10316 If N is negative, mark backwards instead.
10317 The difference between N and the actual number of articles marked is
10318 returned."
10319 (interactive "p")
10320 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10321
10322 (defun gnus-summary-mark-as-read-backward (n)
10323 "Mark the N articles as read backwards.
10324 The difference between N and the actual number of articles marked is
10325 returned."
10326 (interactive "p")
10327 (gnus-summary-mark-forward
10328 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10329
10330 (defun gnus-summary-mark-as-read (&optional article mark)
10331 "Mark current article as read.
10332 ARTICLE specifies the article to be marked as read.
10333 MARK specifies a string to be inserted at the beginning of the line."
10334 (gnus-summary-mark-article article mark))
10335
10336 (defun gnus-summary-clear-mark-forward (n)
10337 "Clear marks from N articles forward.
10338 If N is negative, clear backward instead.
10339 The difference between N and the number of marks cleared is returned."
10340 (interactive "p")
10341 (gnus-summary-mark-forward n gnus-unread-mark))
10342
10343 (defun gnus-summary-clear-mark-backward (n)
10344 "Clear marks from N articles backward.
10345 The difference between N and the number of marks cleared is returned."
10346 (interactive "p")
10347 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10348
10349 (defun gnus-summary-mark-unread-as-read ()
10350 "Intended to be used by `gnus-summary-mark-article-hook'."
10351 (when (memq gnus-current-article gnus-newsgroup-unreads)
10352 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10353
10354 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10355 "Intended to be used by `gnus-summary-mark-article-hook'."
10356 (let ((mark (gnus-summary-article-mark)))
10357 (when (or (gnus-unread-mark-p mark)
10358 (gnus-read-mark-p mark))
10359 (gnus-summary-mark-article gnus-current-article
10360 (or new-mark gnus-read-mark)))))
10361
10362 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10363 "Intended to be used by `gnus-summary-mark-article-hook'."
10364 (let ((mark (gnus-summary-article-mark)))
10365 (when (or (gnus-unread-mark-p mark)
10366 (gnus-read-mark-p mark))
10367 (gnus-summary-mark-article (gnus-summary-article-number)
10368 (or new-mark gnus-read-mark)))))
10369
10370 (defun gnus-summary-mark-unread-as-ticked ()
10371 "Intended to be used by `gnus-summary-mark-article-hook'."
10372 (when (memq gnus-current-article gnus-newsgroup-unreads)
10373 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10374
10375 (defun gnus-summary-mark-region-as-read (point mark all)
10376 "Mark all unread articles between point and mark as read.
10377 If given a prefix, mark all articles between point and mark as read,
10378 even ticked and dormant ones."
10379 (interactive "r\nP")
10380 (save-excursion
10381 (let (article)
10382 (goto-char point)
10383 (beginning-of-line)
10384 (while (and
10385 (< (point) mark)
10386 (progn
10387 (when (or all
10388 (memq (setq article (gnus-summary-article-number))
10389 gnus-newsgroup-unreads))
10390 (gnus-summary-mark-article article gnus-del-mark))
10391 t)
10392 (gnus-summary-find-next))))))
10393
10394 (defun gnus-summary-mark-below (score mark)
10395 "Mark articles with score less than SCORE with MARK."
10396 (interactive "P\ncMark: ")
10397 (setq score (if score
10398 (prefix-numeric-value score)
10399 (or gnus-summary-default-score 0)))
10400 (save-excursion
10401 (set-buffer gnus-summary-buffer)
10402 (goto-char (point-min))
10403 (while
10404 (progn
10405 (and (< (gnus-summary-article-score) score)
10406 (gnus-summary-mark-article nil mark))
10407 (gnus-summary-find-next)))))
10408
10409 (defun gnus-summary-kill-below (&optional score)
10410 "Mark articles with score below SCORE as read."
10411 (interactive "P")
10412 (gnus-summary-mark-below score gnus-killed-mark))
10413
10414 (defun gnus-summary-clear-above (&optional score)
10415 "Clear all marks from articles with score above SCORE."
10416 (interactive "P")
10417 (gnus-summary-mark-above score gnus-unread-mark))
10418
10419 (defun gnus-summary-tick-above (&optional score)
10420 "Tick all articles with score above SCORE."
10421 (interactive "P")
10422 (gnus-summary-mark-above score gnus-ticked-mark))
10423
10424 (defun gnus-summary-mark-above (score mark)
10425 "Mark articles with score over SCORE with MARK."
10426 (interactive "P\ncMark: ")
10427 (setq score (if score
10428 (prefix-numeric-value score)
10429 (or gnus-summary-default-score 0)))
10430 (save-excursion
10431 (set-buffer gnus-summary-buffer)
10432 (goto-char (point-min))
10433 (while (and (progn
10434 (when (> (gnus-summary-article-score) score)
10435 (gnus-summary-mark-article nil mark))
10436 t)
10437 (gnus-summary-find-next)))))
10438
10439 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10440 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10441 (defun gnus-summary-limit-include-expunged (&optional no-error)
10442 "Display all the hidden articles that were expunged for low scores."
10443 (interactive)
10444 (let ((buffer-read-only nil))
10445 (let ((scored gnus-newsgroup-scored)
10446 headers h)
10447 (while scored
10448 (unless (gnus-summary-article-header (caar scored))
10449 (and (setq h (gnus-number-to-header (caar scored)))
10450 (< (cdar scored) gnus-summary-expunge-below)
10451 (push h headers)))
10452 (setq scored (cdr scored)))
10453 (if (not headers)
10454 (when (not no-error)
10455 (error "No expunged articles hidden"))
10456 (goto-char (point-min))
10457 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10458 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10459 (mapcar (lambda (x) (push (mail-header-number x)
10460 gnus-newsgroup-limit))
10461 headers)
10462 (gnus-summary-prepare-unthreaded (nreverse headers))
10463 (goto-char (point-min))
10464 (gnus-summary-position-point)
10465 t))))
10466
10467 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10468 "Mark all unread articles in this newsgroup as read.
10469 If prefix argument ALL is non-nil, ticked and dormant articles will
10470 also be marked as read.
10471 If QUIETLY is non-nil, no questions will be asked.
10472
10473 If TO-HERE is non-nil, it should be a point in the buffer. All
10474 articles before (after, if REVERSE is set) this point will be marked
10475 as read.
10476
10477 Note that this function will only catch up the unread article
10478 in the current summary buffer limitation.
10479
10480 The number of articles marked as read is returned."
10481 (interactive "P")
10482 (prog1
10483 (save-excursion
10484 (when (or quietly
10485 (not gnus-interactive-catchup) ;Without confirmation?
10486 gnus-expert-user
10487 (gnus-y-or-n-p
10488 (if all
10489 "Mark absolutely all articles as read? "
10490 "Mark all unread articles as read? ")))
10491 (if (and not-mark
10492 (not gnus-newsgroup-adaptive)
10493 (not gnus-newsgroup-auto-expire)
10494 (not gnus-suppress-duplicates)
10495 (or (not gnus-use-cache)
10496 (eq gnus-use-cache 'passive)))
10497 (progn
10498 (when all
10499 (setq gnus-newsgroup-marked nil
10500 gnus-newsgroup-spam-marked nil
10501 gnus-newsgroup-dormant nil))
10502 (setq gnus-newsgroup-unreads
10503 (gnus-sorted-nunion
10504 (gnus-sorted-intersection gnus-newsgroup-unreads
10505 gnus-newsgroup-downloadable)
10506 gnus-newsgroup-unfetched)))
10507 ;; We actually mark all articles as canceled, which we
10508 ;; have to do when using auto-expiry or adaptive scoring.
10509 (gnus-summary-show-all-threads)
10510 (if (and to-here reverse)
10511 (progn
10512 (goto-char to-here)
10513 (gnus-summary-mark-current-read-and-unread-as-read
10514 gnus-catchup-mark)
10515 (while (gnus-summary-find-next (not all))
10516 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10517 (when (gnus-summary-first-subject (not all))
10518 (while (and
10519 (if to-here (< (point) to-here) t)
10520 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10521 (gnus-summary-find-next (not all))))))
10522 (gnus-set-mode-line 'summary))
10523 t))
10524 (gnus-summary-position-point)))
10525
10526 (defun gnus-summary-catchup-to-here (&optional all)
10527 "Mark all unticked articles before the current one as read.
10528 If ALL is non-nil, also mark ticked and dormant articles as read."
10529 (interactive "P")
10530 (save-excursion
10531 (gnus-save-hidden-threads
10532 (let ((beg (point)))
10533 ;; We check that there are unread articles.
10534 (when (or all (gnus-summary-find-prev))
10535 (gnus-summary-catchup all t beg)))))
10536 (gnus-summary-position-point))
10537
10538 (defun gnus-summary-catchup-from-here (&optional all)
10539 "Mark all unticked articles after (and including) the current one as read.
10540 If ALL is non-nil, also mark ticked and dormant articles as read."
10541 (interactive "P")
10542 (save-excursion
10543 (gnus-save-hidden-threads
10544 (let ((beg (point)))
10545 ;; We check that there are unread articles.
10546 (when (or all (gnus-summary-find-next))
10547 (gnus-summary-catchup all t beg nil t)))))
10548 (gnus-summary-position-point))
10549
10550 (defun gnus-summary-catchup-all (&optional quietly)
10551 "Mark all articles in this newsgroup as read.
10552 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10553 instead, which marks only unread articles as read."
10554 (interactive "P")
10555 (gnus-summary-catchup t quietly))
10556
10557 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10558 "Mark all unread articles in this group as read, then exit.
10559 If prefix argument ALL is non-nil, all articles are marked as read.
10560 If QUIETLY is non-nil, no questions will be asked."
10561 (interactive "P")
10562 (when (gnus-summary-catchup all quietly nil 'fast)
10563 ;; Select next newsgroup or exit.
10564 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10565 (eq gnus-auto-select-next 'quietly))
10566 (gnus-summary-next-group nil)
10567 (gnus-summary-exit))))
10568
10569 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10570 "Mark all articles in this newsgroup as read, and then exit.
10571 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10572 instead, which marks only unread articles as read."
10573 (interactive "P")
10574 (gnus-summary-catchup-and-exit t quietly))
10575
10576 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10577 "Mark all articles in this group as read and select the next group.
10578 If given a prefix, mark all articles, unread as well as ticked, as
10579 read."
10580 (interactive "P")
10581 (save-excursion
10582 (gnus-summary-catchup all))
10583 (gnus-summary-next-group))
10584
10585 ;;;
10586 ;;; with article
10587 ;;;
10588
10589 (defmacro gnus-with-article (article &rest forms)
10590 "Select ARTICLE and perform FORMS in the original article buffer.
10591 Then replace the article with the result."
10592 `(progn
10593 ;; We don't want the article to be marked as read.
10594 (let (gnus-mark-article-hook)
10595 (gnus-summary-select-article t t nil ,article))
10596 (set-buffer gnus-original-article-buffer)
10597 ,@forms
10598 (if (not (gnus-check-backend-function
10599 'request-replace-article (car gnus-article-current)))
10600 (gnus-message 5 "Read-only group; not replacing")
10601 (unless (gnus-request-replace-article
10602 ,article (car gnus-article-current)
10603 (current-buffer) t)
10604 (error "Couldn't replace article")))
10605 ;; The cache and backlog have to be flushed somewhat.
10606 (when gnus-keep-backlog
10607 (gnus-backlog-remove-article
10608 (car gnus-article-current) (cdr gnus-article-current)))
10609 (when gnus-use-cache
10610 (gnus-cache-update-article
10611 (car gnus-article-current) (cdr gnus-article-current)))))
10612
10613 (put 'gnus-with-article 'lisp-indent-function 1)
10614 (put 'gnus-with-article 'edebug-form-spec '(form body))
10615
10616 ;; Thread-based commands.
10617
10618 (defun gnus-summary-articles-in-thread (&optional article)
10619 "Return a list of all articles in the current thread.
10620 If ARTICLE is non-nil, return all articles in the thread that starts
10621 with that article."
10622 (let* ((article (or article (gnus-summary-article-number)))
10623 (data (gnus-data-find-list article))
10624 (top-level (gnus-data-level (car data)))
10625 (top-subject
10626 (cond ((null gnus-thread-operation-ignore-subject)
10627 (gnus-simplify-subject-re
10628 (mail-header-subject (gnus-data-header (car data)))))
10629 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10630 (gnus-simplify-subject-fuzzy
10631 (mail-header-subject (gnus-data-header (car data)))))
10632 (t nil)))
10633 (end-point (save-excursion
10634 (if (gnus-summary-go-to-next-thread)
10635 (point) (point-max))))
10636 articles)
10637 (while (and data
10638 (< (gnus-data-pos (car data)) end-point))
10639 (when (or (not top-subject)
10640 (string= top-subject
10641 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10642 (gnus-simplify-subject-fuzzy
10643 (mail-header-subject
10644 (gnus-data-header (car data))))
10645 (gnus-simplify-subject-re
10646 (mail-header-subject
10647 (gnus-data-header (car data)))))))
10648 (push (gnus-data-number (car data)) articles))
10649 (unless (and (setq data (cdr data))
10650 (> (gnus-data-level (car data)) top-level))
10651 (setq data nil)))
10652 ;; Return the list of articles.
10653 (nreverse articles)))
10654
10655 (defun gnus-summary-rethread-current ()
10656 "Rethread the thread the current article is part of."
10657 (interactive)
10658 (let* ((gnus-show-threads t)
10659 (article (gnus-summary-article-number))
10660 (id (mail-header-id (gnus-summary-article-header)))
10661 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10662 (unless id
10663 (error "No article on the current line"))
10664 (gnus-rebuild-thread id)
10665 (gnus-summary-goto-subject article)))
10666
10667 (defun gnus-summary-reparent-thread ()
10668 "Make the current article child of the marked (or previous) article.
10669
10670 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10671 is non-nil or the Subject: of both articles are the same."
10672 (interactive)
10673 (unless (not (gnus-group-read-only-p))
10674 (error "The current newsgroup does not support article editing"))
10675 (unless (<= (length gnus-newsgroup-processable) 1)
10676 (error "No more than one article may be marked"))
10677 (save-window-excursion
10678 (let ((gnus-article-buffer " *reparent*")
10679 (current-article (gnus-summary-article-number))
10680 ;; First grab the marked article, otherwise one line up.
10681 (parent-article (if (not (null gnus-newsgroup-processable))
10682 (car gnus-newsgroup-processable)
10683 (save-excursion
10684 (if (eq (forward-line -1) 0)
10685 (gnus-summary-article-number)
10686 (error "Beginning of summary buffer"))))))
10687 (unless (not (eq current-article parent-article))
10688 (error "An article may not be self-referential"))
10689 (let ((message-id (mail-header-id
10690 (gnus-summary-article-header parent-article))))
10691 (unless (and message-id (not (equal message-id "")))
10692 (error "No message-id in desired parent"))
10693 (gnus-with-article current-article
10694 (save-restriction
10695 (goto-char (point-min))
10696 (message-narrow-to-head)
10697 (if (re-search-forward "^References: " nil t)
10698 (progn
10699 (re-search-forward "^[^ \t]" nil t)
10700 (forward-line -1)
10701 (end-of-line)
10702 (insert " " message-id))
10703 (insert "References: " message-id "\n"))))
10704 (set-buffer gnus-summary-buffer)
10705 (gnus-summary-unmark-all-processable)
10706 (gnus-summary-update-article current-article)
10707 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10708 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10709 (gnus-summary-rethread-current)
10710 (gnus-message 3 "Article %d is now the child of article %d"
10711 current-article parent-article)))))
10712
10713 (defun gnus-summary-toggle-threads (&optional arg)
10714 "Toggle showing conversation threads.
10715 If ARG is positive number, turn showing conversation threads on."
10716 (interactive "P")
10717 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10718 (setq gnus-show-threads
10719 (if (null arg) (not gnus-show-threads)
10720 (> (prefix-numeric-value arg) 0)))
10721 (gnus-summary-prepare)
10722 (gnus-summary-goto-subject current)
10723 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10724 (gnus-summary-position-point)))
10725
10726 (defun gnus-summary-show-all-threads ()
10727 "Show all threads."
10728 (interactive)
10729 (save-excursion
10730 (let ((buffer-read-only nil))
10731 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10732 (gnus-summary-position-point))
10733
10734 (defun gnus-summary-show-thread ()
10735 "Show thread subtrees.
10736 Returns nil if no thread was there to be shown."
10737 (interactive)
10738 (let ((buffer-read-only nil)
10739 (orig (point))
10740 (end (gnus-point-at-eol))
10741 ;; Leave point at bol
10742 (beg (progn (beginning-of-line) (point))))
10743 (prog1
10744 ;; Any hidden lines here?
10745 (search-forward "\r" end t)
10746 (subst-char-in-region beg end ?\^M ?\n t)
10747 (goto-char orig)
10748 (gnus-summary-position-point))))
10749
10750 (defun gnus-summary-maybe-hide-threads ()
10751 "If requested, hide the threads that should be hidden."
10752 (when (and gnus-show-threads
10753 gnus-thread-hide-subtree)
10754 (gnus-summary-hide-all-threads
10755 (if (or (consp gnus-thread-hide-subtree)
10756 (functionp gnus-thread-hide-subtree))
10757 (gnus-make-predicate gnus-thread-hide-subtree)
10758 nil))))
10759
10760 ;;; Hiding predicates.
10761
10762 (defun gnus-article-unread-p (header)
10763 (memq (mail-header-number header) gnus-newsgroup-unreads))
10764
10765 (defun gnus-article-unseen-p (header)
10766 (memq (mail-header-number header) gnus-newsgroup-unseen))
10767
10768 (defun gnus-map-articles (predicate articles)
10769 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10770 (apply 'gnus-or (mapcar predicate
10771 (mapcar (lambda (number)
10772 (gnus-summary-article-header number))
10773 articles))))
10774
10775 (defun gnus-summary-hide-all-threads (&optional predicate)
10776 "Hide all thread subtrees.
10777 If PREDICATE is supplied, threads that satisfy this predicate
10778 will not be hidden."
10779 (interactive)
10780 (save-excursion
10781 (goto-char (point-min))
10782 (let ((end nil))
10783 (while (not end)
10784 (when (or (not predicate)
10785 (gnus-map-articles
10786 predicate (gnus-summary-article-children)))
10787 (gnus-summary-hide-thread))
10788 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10789 (gnus-summary-position-point))
10790
10791 (defun gnus-summary-hide-thread ()
10792 "Hide thread subtrees.
10793 If PREDICATE is supplied, threads that satisfy this predicate
10794 will not be hidden.
10795 Returns nil if no threads were there to be hidden."
10796 (interactive)
10797 (let ((buffer-read-only nil)
10798 (start (point))
10799 (article (gnus-summary-article-number)))
10800 (goto-char start)
10801 ;; Go forward until either the buffer ends or the subthread
10802 ;; ends.
10803 (when (and (not (eobp))
10804 (or (zerop (gnus-summary-next-thread 1 t))
10805 (goto-char (point-max))))
10806 (prog1
10807 (if (and (> (point) start)
10808 (search-backward "\n" start t))
10809 (progn
10810 (subst-char-in-region start (point) ?\n ?\^M)
10811 (gnus-summary-goto-subject article))
10812 (goto-char start)
10813 nil)))))
10814
10815 (defun gnus-summary-go-to-next-thread (&optional previous)
10816 "Go to the same level (or less) next thread.
10817 If PREVIOUS is non-nil, go to previous thread instead.
10818 Return the article number moved to, or nil if moving was impossible."
10819 (let ((level (gnus-summary-thread-level))
10820 (way (if previous -1 1))
10821 (beg (point)))
10822 (forward-line way)
10823 (while (and (not (eobp))
10824 (< level (gnus-summary-thread-level)))
10825 (forward-line way))
10826 (if (eobp)
10827 (progn
10828 (goto-char beg)
10829 nil)
10830 (setq beg (point))
10831 (prog1
10832 (gnus-summary-article-number)
10833 (goto-char beg)))))
10834
10835 (defun gnus-summary-next-thread (n &optional silent)
10836 "Go to the same level next N'th thread.
10837 If N is negative, search backward instead.
10838 Returns the difference between N and the number of skips actually
10839 done.
10840
10841 If SILENT, don't output messages."
10842 (interactive "p")
10843 (let ((backward (< n 0))
10844 (n (abs n)))
10845 (while (and (> n 0)
10846 (gnus-summary-go-to-next-thread backward))
10847 (decf n))
10848 (unless silent
10849 (gnus-summary-position-point))
10850 (when (and (not silent) (/= 0 n))
10851 (gnus-message 7 "No more threads"))
10852 n))
10853
10854 (defun gnus-summary-prev-thread (n)
10855 "Go to the same level previous N'th thread.
10856 Returns the difference between N and the number of skips actually
10857 done."
10858 (interactive "p")
10859 (gnus-summary-next-thread (- n)))
10860
10861 (defun gnus-summary-go-down-thread ()
10862 "Go down one level in the current thread."
10863 (let ((children (gnus-summary-article-children)))
10864 (when children
10865 (gnus-summary-goto-subject (car children)))))
10866
10867 (defun gnus-summary-go-up-thread ()
10868 "Go up one level in the current thread."
10869 (let ((parent (gnus-summary-article-parent)))
10870 (when parent
10871 (gnus-summary-goto-subject parent))))
10872
10873 (defun gnus-summary-down-thread (n)
10874 "Go down thread N steps.
10875 If N is negative, go up instead.
10876 Returns the difference between N and how many steps down that were
10877 taken."
10878 (interactive "p")
10879 (let ((up (< n 0))
10880 (n (abs n)))
10881 (while (and (> n 0)
10882 (if up (gnus-summary-go-up-thread)
10883 (gnus-summary-go-down-thread)))
10884 (setq n (1- n)))
10885 (gnus-summary-position-point)
10886 (when (/= 0 n)
10887 (gnus-message 7 "Can't go further"))
10888 n))
10889
10890 (defun gnus-summary-up-thread (n)
10891 "Go up thread N steps.
10892 If N is negative, go down instead.
10893 Returns the difference between N and how many steps down that were
10894 taken."
10895 (interactive "p")
10896 (gnus-summary-down-thread (- n)))
10897
10898 (defun gnus-summary-top-thread ()
10899 "Go to the top of the thread."
10900 (interactive)
10901 (while (gnus-summary-go-up-thread))
10902 (gnus-summary-article-number))
10903
10904 (defun gnus-summary-kill-thread (&optional unmark)
10905 "Mark articles under current thread as read.
10906 If the prefix argument is positive, remove any kinds of marks.
10907 If the prefix argument is negative, tick articles instead."
10908 (interactive "P")
10909 (when unmark
10910 (setq unmark (prefix-numeric-value unmark)))
10911 (let ((articles (gnus-summary-articles-in-thread)))
10912 (save-excursion
10913 ;; Expand the thread.
10914 (gnus-summary-show-thread)
10915 ;; Mark all the articles.
10916 (while articles
10917 (gnus-summary-goto-subject (car articles))
10918 (cond ((null unmark)
10919 (gnus-summary-mark-article-as-read gnus-killed-mark))
10920 ((> unmark 0)
10921 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10922 (t
10923 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10924 (setq articles (cdr articles))))
10925 ;; Hide killed subtrees.
10926 (and (null unmark)
10927 gnus-thread-hide-killed
10928 (gnus-summary-hide-thread))
10929 ;; If marked as read, go to next unread subject.
10930 (when (null unmark)
10931 ;; Go to next unread subject.
10932 (gnus-summary-next-subject 1 t)))
10933 (gnus-set-mode-line 'summary))
10934
10935 ;; Summary sorting commands
10936
10937 (defun gnus-summary-sort-by-number (&optional reverse)
10938 "Sort the summary buffer by article number.
10939 Argument REVERSE means reverse order."
10940 (interactive "P")
10941 (gnus-summary-sort 'number reverse))
10942
10943 (defun gnus-summary-sort-by-random (&optional reverse)
10944 "Randomize the order in the summary buffer.
10945 Argument REVERSE means to randomize in reverse order."
10946 (interactive "P")
10947 (gnus-summary-sort 'random reverse))
10948
10949 (defun gnus-summary-sort-by-author (&optional reverse)
10950 "Sort the summary buffer by author name alphabetically.
10951 If `case-fold-search' is non-nil, case of letters is ignored.
10952 Argument REVERSE means reverse order."
10953 (interactive "P")
10954 (gnus-summary-sort 'author reverse))
10955
10956 (defun gnus-summary-sort-by-subject (&optional reverse)
10957 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10958 If `case-fold-search' is non-nil, case of letters is ignored.
10959 Argument REVERSE means reverse order."
10960 (interactive "P")
10961 (gnus-summary-sort 'subject reverse))
10962
10963 (defun gnus-summary-sort-by-date (&optional reverse)
10964 "Sort the summary buffer by date.
10965 Argument REVERSE means reverse order."
10966 (interactive "P")
10967 (gnus-summary-sort 'date reverse))
10968
10969 (defun gnus-summary-sort-by-score (&optional reverse)
10970 "Sort the summary buffer by score.
10971 Argument REVERSE means reverse order."
10972 (interactive "P")
10973 (gnus-summary-sort 'score reverse))
10974
10975 (defun gnus-summary-sort-by-lines (&optional reverse)
10976 "Sort the summary buffer by the number of lines.
10977 Argument REVERSE means reverse order."
10978 (interactive "P")
10979 (gnus-summary-sort 'lines reverse))
10980
10981 (defun gnus-summary-sort-by-chars (&optional reverse)
10982 "Sort the summary buffer by article length.
10983 Argument REVERSE means reverse order."
10984 (interactive "P")
10985 (gnus-summary-sort 'chars reverse))
10986
10987 (defun gnus-summary-sort-by-original (&optional reverse)
10988 "Sort the summary buffer using the default sorting method.
10989 Argument REVERSE means reverse order."
10990 (interactive "P")
10991 (let* ((buffer-read-only)
10992 (gnus-summary-prepare-hook nil))
10993 ;; We do the sorting by regenerating the threads.
10994 (gnus-summary-prepare)
10995 ;; Hide subthreads if needed.
10996 (gnus-summary-maybe-hide-threads)))
10997
10998 (defun gnus-summary-sort (predicate reverse)
10999 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11000 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11001 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11002 (gnus-thread-sort-functions
11003 (if (not reverse)
11004 thread
11005 `(lambda (t1 t2)
11006 (,thread t2 t1))))
11007 (gnus-sort-gathered-threads-function
11008 gnus-thread-sort-functions)
11009 (gnus-article-sort-functions
11010 (if (not reverse)
11011 article
11012 `(lambda (t1 t2)
11013 (,article t2 t1))))
11014 (buffer-read-only)
11015 (gnus-summary-prepare-hook nil))
11016 ;; We do the sorting by regenerating the threads.
11017 (gnus-summary-prepare)
11018 ;; Hide subthreads if needed.
11019 (gnus-summary-maybe-hide-threads)))
11020
11021 ;; Summary saving commands.
11022
11023 (defun gnus-summary-save-article (&optional n not-saved)
11024 "Save the current article using the default saver function.
11025 If N is a positive number, save the N next articles.
11026 If N is a negative number, save the N previous articles.
11027 If N is nil and any articles have been marked with the process mark,
11028 save those articles instead.
11029 The variable `gnus-default-article-saver' specifies the saver function.
11030
11031 If the optional second argument NOT-SAVED is non-nil, articles saved
11032 will not be marked as saved."
11033 (interactive "P")
11034 (require 'gnus-art)
11035 (let* ((articles (gnus-summary-work-articles n))
11036 (save-buffer (save-excursion
11037 (nnheader-set-temp-buffer " *Gnus Save*")))
11038 (num (length articles))
11039 ;; Whether to save decoded articles or raw articles.
11040 (decode (when gnus-article-save-coding-system
11041 (get gnus-default-article-saver :decode)))
11042 ;; When saving many articles in a single file, use the other
11043 ;; function to save articles other than the first one.
11044 (saver2 (get gnus-default-article-saver :function))
11045 (gnus-prompt-before-saving (if saver2
11046 t
11047 gnus-prompt-before-saving))
11048 (gnus-default-article-saver gnus-default-article-saver)
11049 header file)
11050 (dolist (article articles)
11051 (setq header (gnus-summary-article-header article))
11052 (if (not (vectorp header))
11053 ;; This is a pseudo-article.
11054 (if (assq 'name header)
11055 (gnus-copy-file (cdr (assq 'name header)))
11056 (gnus-message 1 "Article %d is unsaveable" article))
11057 ;; This is a real article.
11058 (save-window-excursion
11059 (let ((gnus-display-mime-function (when decode
11060 gnus-display-mime-function))
11061 (gnus-article-prepare-hook (when decode
11062 gnus-article-prepare-hook)))
11063 (gnus-summary-select-article t nil nil article)
11064 (gnus-summary-goto-subject article)))
11065 (save-excursion
11066 (set-buffer save-buffer)
11067 (erase-buffer)
11068 (insert-buffer-substring (if decode
11069 gnus-article-buffer
11070 gnus-original-article-buffer)))
11071 (setq file (gnus-article-save save-buffer file num))
11072 (gnus-summary-remove-process-mark article)
11073 (unless not-saved
11074 (gnus-summary-set-saved-mark article)))
11075 (when saver2
11076 (setq gnus-default-article-saver saver2
11077 saver2 nil)))
11078 (gnus-kill-buffer save-buffer)
11079 (gnus-summary-position-point)
11080 (gnus-set-mode-line 'summary)
11081 n))
11082
11083 (defun gnus-summary-pipe-output (&optional arg headers)
11084 "Pipe the current article to a subprocess.
11085 If N is a positive number, pipe the N next articles.
11086 If N is a negative number, pipe the N previous articles.
11087 If N is nil and any articles have been marked with the process mark,
11088 pipe those articles instead.
11089 If HEADERS (the symbolic prefix), include the headers, too."
11090 (interactive (gnus-interactive "P\ny"))
11091 (require 'gnus-art)
11092 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11093 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11094 (gnus-summary-save-article arg t))
11095 (let ((buffer (get-buffer "*Shell Command Output*")))
11096 (when (and buffer
11097 (not (zerop (buffer-size buffer))))
11098 (gnus-configure-windows 'pipe))))
11099
11100 (defun gnus-summary-save-article-mail (&optional arg)
11101 "Append the current article to a Unix mail box file.
11102 If N is a positive number, save the N next articles.
11103 If N is a negative number, save the N previous articles.
11104 If N is nil and any articles have been marked with the process mark,
11105 save those articles instead."
11106 (interactive "P")
11107 (require 'gnus-art)
11108 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11109 (gnus-summary-save-article arg)))
11110
11111 (defun gnus-summary-save-article-rmail (&optional arg)
11112 "Append the current article to an rmail file.
11113 If N is a positive number, save the N next articles.
11114 If N is a negative number, save the N previous articles.
11115 If N is nil and any articles have been marked with the process mark,
11116 save those articles instead."
11117 (interactive "P")
11118 (require 'gnus-art)
11119 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11120 (gnus-summary-save-article arg)))
11121
11122 (defun gnus-summary-save-article-file (&optional arg)
11123 "Append the current article to a file.
11124 If N is a positive number, save the N next articles.
11125 If N is a negative number, save the N previous articles.
11126 If N is nil and any articles have been marked with the process mark,
11127 save those articles instead."
11128 (interactive "P")
11129 (require 'gnus-art)
11130 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11131 (gnus-summary-save-article arg)))
11132
11133 (defun gnus-summary-write-article-file (&optional arg)
11134 "Write the current article to a file, deleting the previous file.
11135 If N is a positive number, save the N next articles.
11136 If N is a negative number, save the N previous articles.
11137 If N is nil and any articles have been marked with the process mark,
11138 save those articles instead."
11139 (interactive "P")
11140 (require 'gnus-art)
11141 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11142 (gnus-summary-save-article arg)))
11143
11144 (defun gnus-summary-save-article-body-file (&optional arg)
11145 "Append the current article body to a file.
11146 If N is a positive number, save the N next articles.
11147 If N is a negative number, save the N previous articles.
11148 If N is nil and any articles have been marked with the process mark,
11149 save those articles instead."
11150 (interactive "P")
11151 (require 'gnus-art)
11152 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11153 (gnus-summary-save-article arg)))
11154
11155 (defun gnus-summary-write-article-body-file (&optional arg)
11156 "Write the current article body to a file, deleting the previous file.
11157 If N is a positive number, save the N next articles.
11158 If N is a negative number, save the N previous articles.
11159 If N is nil and any articles have been marked with the process mark,
11160 save those articles instead."
11161 (interactive "P")
11162 (require 'gnus-art)
11163 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11164 (gnus-summary-save-article arg)))
11165
11166 (defun gnus-summary-muttprint (&optional arg)
11167 "Print the current article using Muttprint.
11168 If N is a positive number, save the N next articles.
11169 If N is a negative number, save the N previous articles.
11170 If N is nil and any articles have been marked with the process mark,
11171 save those articles instead."
11172 (interactive "P")
11173 (require 'gnus-art)
11174 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11175 (gnus-summary-save-article arg t)))
11176
11177 (defun gnus-summary-pipe-message (program)
11178 "Pipe the current article through PROGRAM."
11179 (interactive "sProgram: ")
11180 (gnus-summary-select-article)
11181 (let ((mail-header-separator ""))
11182 (gnus-eval-in-buffer-window gnus-article-buffer
11183 (save-restriction
11184 (widen)
11185 (let ((start (window-start))
11186 buffer-read-only)
11187 (message-pipe-buffer-body program)
11188 (set-window-start (get-buffer-window (current-buffer)) start))))))
11189
11190 (defun gnus-get-split-value (methods)
11191 "Return a value based on the split METHODS."
11192 (let (split-name method result match)
11193 (when methods
11194 (save-excursion
11195 (set-buffer gnus-original-article-buffer)
11196 (save-restriction
11197 (nnheader-narrow-to-headers)
11198 (while (and methods (not split-name))
11199 (goto-char (point-min))
11200 (setq method (pop methods))
11201 (setq match (car method))
11202 (when (cond
11203 ((stringp match)
11204 ;; Regular expression.
11205 (ignore-errors
11206 (re-search-forward match nil t)))
11207 ((functionp match)
11208 ;; Function.
11209 (save-restriction
11210 (widen)
11211 (setq result (funcall match gnus-newsgroup-name))))
11212 ((consp match)
11213 ;; Form.
11214 (save-restriction
11215 (widen)
11216 (setq result (eval match)))))
11217 (setq split-name (cdr method))
11218 (cond ((stringp result)
11219 (push (expand-file-name
11220 result gnus-article-save-directory)
11221 split-name))
11222 ((consp result)
11223 (setq split-name (append result split-name)))))))))
11224 (nreverse split-name)))
11225
11226 (defun gnus-valid-move-group-p (group)
11227 (and (boundp group)
11228 (symbol-name group)
11229 (symbol-value group)
11230 (gnus-get-function (gnus-find-method-for-group
11231 (symbol-name group)) 'request-accept-article t)))
11232
11233 (defun gnus-read-move-group-name (prompt default articles prefix)
11234 "Read a group name."
11235 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11236 (minibuffer-confirm-incomplete nil) ; XEmacs
11237 (prom
11238 (format "%s %s to"
11239 prompt
11240 (if (> (length articles) 1)
11241 (format "these %d articles" (length articles))
11242 "this article")))
11243 (to-newsgroup
11244 (cond
11245 ((null split-name)
11246 (gnus-completing-read-with-default
11247 default prom
11248 gnus-active-hashtb
11249 'gnus-valid-move-group-p
11250 nil prefix
11251 'gnus-group-history))
11252 ((= 1 (length split-name))
11253 (gnus-completing-read-with-default
11254 (car split-name) prom
11255 gnus-active-hashtb
11256 'gnus-valid-move-group-p
11257 nil nil
11258 'gnus-group-history))
11259 (t
11260 (gnus-completing-read-with-default
11261 nil prom
11262 (mapcar (lambda (el) (list el))
11263 (nreverse split-name))
11264 nil nil nil
11265 'gnus-group-history))))
11266 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11267 (when to-newsgroup
11268 (if (or (string= to-newsgroup "")
11269 (string= to-newsgroup prefix))
11270 (setq to-newsgroup default))
11271 (unless to-newsgroup
11272 (error "No group name entered"))
11273 (or (gnus-active to-newsgroup)
11274 (gnus-activate-group to-newsgroup nil nil to-method)
11275 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11276 to-newsgroup))
11277 (or (and (gnus-request-create-group to-newsgroup to-method)
11278 (gnus-activate-group
11279 to-newsgroup nil nil to-method)
11280 (gnus-subscribe-group to-newsgroup))
11281 (error "Couldn't create group %s" to-newsgroup)))
11282 (error "No such group: %s" to-newsgroup)))
11283 to-newsgroup))
11284
11285 (defun gnus-summary-save-parts (type dir n &optional reverse)
11286 "Save parts matching TYPE to DIR.
11287 If REVERSE, save parts that do not match TYPE."
11288 (interactive
11289 (list (read-string "Save parts of type: "
11290 (or (car gnus-summary-save-parts-type-history)
11291 gnus-summary-save-parts-default-mime)
11292 'gnus-summary-save-parts-type-history)
11293 (setq gnus-summary-save-parts-last-directory
11294 (read-file-name "Save to directory: "
11295 gnus-summary-save-parts-last-directory
11296 nil t))
11297 current-prefix-arg))
11298 (gnus-summary-iterate n
11299 (let ((gnus-display-mime-function nil)
11300 (gnus-inhibit-treatment t))
11301 (gnus-summary-select-article))
11302 (save-excursion
11303 (set-buffer gnus-article-buffer)
11304 (let ((handles (or gnus-article-mime-handles
11305 (mm-dissect-buffer nil gnus-article-loose-mime)
11306 (and gnus-article-emulate-mime
11307 (mm-uu-dissect)))))
11308 (when handles
11309 (gnus-summary-save-parts-1 type dir handles reverse)
11310 (unless gnus-article-mime-handles ;; Don't destroy this case.
11311 (mm-destroy-parts handles)))))))
11312
11313 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11314 (if (stringp (car handle))
11315 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11316 (cdr handle))
11317 (when (if reverse
11318 (not (string-match type (mm-handle-media-type handle)))
11319 (string-match type (mm-handle-media-type handle)))
11320 (let ((file (expand-file-name
11321 (gnus-map-function
11322 mm-file-name-rewrite-functions
11323 (file-name-nondirectory
11324 (or
11325 (mail-content-type-get
11326 (mm-handle-disposition handle) 'filename)
11327 (mail-content-type-get
11328 (mm-handle-type handle) 'name)
11329 (concat gnus-newsgroup-name
11330 "." (number-to-string
11331 (cdr gnus-article-current))))))
11332 dir)))
11333 (unless (file-exists-p file)
11334 (mm-save-part-to-file handle file))))))
11335
11336 ;; Summary extract commands
11337
11338 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11339 (let ((buffer-read-only nil)
11340 (article (gnus-summary-article-number))
11341 after-article b e)
11342 (unless (gnus-summary-goto-subject article)
11343 (error "No such article: %d" article))
11344 (gnus-summary-position-point)
11345 ;; If all commands are to be bunched up on one line, we collect
11346 ;; them here.
11347 (unless gnus-view-pseudos-separately
11348 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11349 files action)
11350 (while ps
11351 (setq action (cdr (assq 'action (car ps))))
11352 (setq files (list (cdr (assq 'name (car ps)))))
11353 (while (and ps (cdr ps)
11354 (string= (or action "1")
11355 (or (cdr (assq 'action (cadr ps))) "2")))
11356 (push (cdr (assq 'name (cadr ps))) files)
11357 (setcdr ps (cddr ps)))
11358 (when files
11359 (when (not (string-match "%s" action))
11360 (push " " files))
11361 (push " " files)
11362 (when (assq 'execute (car ps))
11363 (setcdr (assq 'execute (car ps))
11364 (funcall (if (string-match "%s" action)
11365 'format 'concat)
11366 action
11367 (mapconcat
11368 (lambda (f)
11369 (if (equal f " ")
11370 f
11371 (mm-quote-arg f)))
11372 files " ")))))
11373 (setq ps (cdr ps)))))
11374 (if (and gnus-view-pseudos (not not-view))
11375 (while pslist
11376 (when (assq 'execute (car pslist))
11377 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11378 (eq gnus-view-pseudos 'not-confirm)))
11379 (setq pslist (cdr pslist)))
11380 (save-excursion
11381 (while pslist
11382 (setq after-article (or (cdr (assq 'article (car pslist)))
11383 (gnus-summary-article-number)))
11384 (gnus-summary-goto-subject after-article)
11385 (forward-line 1)
11386 (setq b (point))
11387 (insert " " (file-name-nondirectory
11388 (cdr (assq 'name (car pslist))))
11389 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11390 (setq e (point))
11391 (forward-line -1) ; back to `b'
11392 (gnus-add-text-properties
11393 b (1- e) (list 'gnus-number gnus-reffed-article-number
11394 gnus-mouse-face-prop gnus-mouse-face))
11395 (gnus-data-enter
11396 after-article gnus-reffed-article-number
11397 gnus-unread-mark b (car pslist) 0 (- e b))
11398 (setq gnus-newsgroup-unreads
11399 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11400 gnus-reffed-article-number))
11401 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11402 (setq pslist (cdr pslist)))))))
11403
11404 (defun gnus-pseudos< (p1 p2)
11405 (let ((c1 (cdr (assq 'action p1)))
11406 (c2 (cdr (assq 'action p2))))
11407 (and c1 c2 (string< c1 c2))))
11408
11409 (defun gnus-request-pseudo-article (props)
11410 (cond ((assq 'execute props)
11411 (gnus-execute-command (cdr (assq 'execute props)))))
11412 (let ((gnus-current-article (gnus-summary-article-number)))
11413 (gnus-run-hooks 'gnus-mark-article-hook)))
11414
11415 (defun gnus-execute-command (command &optional automatic)
11416 (save-excursion
11417 (gnus-article-setup-buffer)
11418 (set-buffer gnus-article-buffer)
11419 (setq buffer-read-only nil)
11420 (let ((command (if automatic command
11421 (read-string "Command: " (cons command 0)))))
11422 (erase-buffer)
11423 (insert "$ " command "\n\n")
11424 (if gnus-view-pseudo-asynchronously
11425 (start-process "gnus-execute" (current-buffer) shell-file-name
11426 shell-command-switch command)
11427 (call-process shell-file-name nil t nil
11428 shell-command-switch command)))))
11429
11430 ;; Summary kill commands.
11431
11432 (defun gnus-summary-edit-global-kill (article)
11433 "Edit the \"global\" kill file."
11434 (interactive (list (gnus-summary-article-number)))
11435 (gnus-group-edit-global-kill article))
11436
11437 (defun gnus-summary-edit-local-kill ()
11438 "Edit a local kill file applied to the current newsgroup."
11439 (interactive)
11440 (setq gnus-current-headers (gnus-summary-article-header))
11441 (gnus-group-edit-local-kill
11442 (gnus-summary-article-number) gnus-newsgroup-name))
11443
11444 ;;; Header reading.
11445
11446 (defun gnus-read-header (id &optional header)
11447 "Read the headers of article ID and enter them into the Gnus system."
11448 (let ((group gnus-newsgroup-name)
11449 (gnus-override-method
11450 (or
11451 gnus-override-method
11452 (and (gnus-news-group-p gnus-newsgroup-name)
11453 (car (gnus-refer-article-methods)))))
11454 where)
11455 ;; First we check to see whether the header in question is already
11456 ;; fetched.
11457 (if (stringp id)
11458 ;; This is a Message-ID.
11459 (setq header (or header (gnus-id-to-header id)))
11460 ;; This is an article number.
11461 (setq header (or header (gnus-summary-article-header id))))
11462 (if (and header
11463 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11464 ;; We have found the header.
11465 header
11466 ;; We have to really fetch the header to this article.
11467 (save-excursion
11468 (set-buffer nntp-server-buffer)
11469 (when (setq where (gnus-request-head id group))
11470 (nnheader-fold-continuation-lines)
11471 (goto-char (point-max))
11472 (insert ".\n")
11473 (goto-char (point-min))
11474 (insert "211 ")
11475 (princ (cond
11476 ((numberp id) id)
11477 ((cdr where) (cdr where))
11478 (header (mail-header-number header))
11479 (t gnus-reffed-article-number))
11480 (current-buffer))
11481 (insert " Article retrieved.\n"))
11482 (if (or (not where)
11483 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11484 () ; Malformed head.
11485 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11486 (when (and (stringp id)
11487 (not (string= (gnus-group-real-name group)
11488 (car where))))
11489 ;; If we fetched by Message-ID and the article came
11490 ;; from a different group, we fudge some bogus article
11491 ;; numbers for this article.
11492 (mail-header-set-number header gnus-reffed-article-number))
11493 (save-excursion
11494 (set-buffer gnus-summary-buffer)
11495 (decf gnus-reffed-article-number)
11496 (gnus-remove-header (mail-header-number header))
11497 (push header gnus-newsgroup-headers)
11498 (setq gnus-current-headers header)
11499 (push (mail-header-number header) gnus-newsgroup-limit)))
11500 header)))))
11501
11502 (defun gnus-remove-header (number)
11503 "Remove header NUMBER from `gnus-newsgroup-headers'."
11504 (if (and gnus-newsgroup-headers
11505 (= number (mail-header-number (car gnus-newsgroup-headers))))
11506 (pop gnus-newsgroup-headers)
11507 (let ((headers gnus-newsgroup-headers))
11508 (while (and (cdr headers)
11509 (not (= number (mail-header-number (cadr headers)))))
11510 (pop headers))
11511 (when (cdr headers)
11512 (setcdr headers (cddr headers))))))
11513
11514 ;;;
11515 ;;; summary highlights
11516 ;;;
11517
11518 (defun gnus-highlight-selected-summary ()
11519 "Highlight selected article in summary buffer."
11520 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11521 (when gnus-summary-selected-face
11522 (save-excursion
11523 (let* ((beg (gnus-point-at-bol))
11524 (end (gnus-point-at-eol))
11525 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11526 (from (if (get-text-property beg gnus-mouse-face-prop)
11527 beg
11528 (or (next-single-property-change
11529 beg gnus-mouse-face-prop nil end)
11530 beg)))
11531 (to
11532 (if (= from end)
11533 (- from 2)
11534 (or (next-single-property-change
11535 from gnus-mouse-face-prop nil end)
11536 end))))
11537 ;; If no mouse-face prop on line we will have to = from = end,
11538 ;; so we highlight the entire line instead.
11539 (when (= (+ to 2) from)
11540 (setq from beg)
11541 (setq to end))
11542 (if gnus-newsgroup-selected-overlay
11543 ;; Move old overlay.
11544 (gnus-move-overlay
11545 gnus-newsgroup-selected-overlay from to (current-buffer))
11546 ;; Create new overlay.
11547 (gnus-overlay-put
11548 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11549 'face gnus-summary-selected-face))))))
11550
11551 (defvar gnus-summary-highlight-line-cached nil)
11552 (defvar gnus-summary-highlight-line-trigger nil)
11553
11554 (defun gnus-summary-highlight-line-0 ()
11555 (if (and (eq gnus-summary-highlight-line-trigger
11556 gnus-summary-highlight)
11557 gnus-summary-highlight-line-cached)
11558 gnus-summary-highlight-line-cached
11559 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11560 gnus-summary-highlight-line-cached
11561 (let* ((cond (list 'cond))
11562 (c cond)
11563 (list gnus-summary-highlight))
11564 (while list
11565 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11566 nil))
11567 (setq c (cdr c)
11568 list (cdr list)))
11569 (gnus-byte-compile (list 'lambda nil cond))))))
11570
11571 (defun gnus-summary-highlight-line ()
11572 "Highlight current line according to `gnus-summary-highlight'."
11573 (let* ((beg (gnus-point-at-bol))
11574 (article (or (gnus-summary-article-number) gnus-current-article))
11575 (score (or (cdr (assq article
11576 gnus-newsgroup-scored))
11577 gnus-summary-default-score 0))
11578 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11579 (inhibit-read-only t)
11580 (default gnus-summary-default-score)
11581 (default-high gnus-summary-default-high-score)
11582 (default-low gnus-summary-default-low-score)
11583 (uncached (and gnus-summary-use-undownloaded-faces
11584 (memq article gnus-newsgroup-undownloaded)
11585 (not (memq article gnus-newsgroup-cached)))))
11586 (let ((face (funcall (gnus-summary-highlight-line-0))))
11587 (unless (eq face (get-text-property beg 'face))
11588 (gnus-put-text-property-excluding-characters-with-faces
11589 beg (gnus-point-at-eol) 'face
11590 (setq face (if (boundp face) (symbol-value face) face)))
11591 (when gnus-summary-highlight-line-function
11592 (funcall gnus-summary-highlight-line-function article face))))))
11593
11594 (defun gnus-update-read-articles (group unread &optional compute)
11595 "Update the list of read articles in GROUP.
11596 UNREAD is a sorted list."
11597 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11598 (entry (gnus-gethash group gnus-newsrc-hashtb))
11599 (info (nth 2 entry))
11600 (prev 1)
11601 read)
11602 (if (or (not info) (not active))
11603 ;; There is no info on this group if it was, in fact,
11604 ;; killed. Gnus stores no information on killed groups, so
11605 ;; there's nothing to be done.
11606 ;; One could store the information somewhere temporarily,
11607 ;; perhaps... Hmmm...
11608 ()
11609 ;; Remove any negative articles numbers.
11610 (while (and unread (< (car unread) 0))
11611 (setq unread (cdr unread)))
11612 ;; Remove any expired article numbers
11613 (while (and unread (< (car unread) (car active)))
11614 (setq unread (cdr unread)))
11615 ;; Compute the ranges of read articles by looking at the list of
11616 ;; unread articles.
11617 (while unread
11618 (when (/= (car unread) prev)
11619 (push (if (= prev (1- (car unread))) prev
11620 (cons prev (1- (car unread))))
11621 read))
11622 (setq prev (1+ (car unread)))
11623 (setq unread (cdr unread)))
11624 (when (<= prev (cdr active))
11625 (push (cons prev (cdr active)) read))
11626 (setq read (if (> (length read) 1) (nreverse read) read))
11627 (if compute
11628 read
11629 (save-excursion
11630 (let (setmarkundo)
11631 ;; Propagate the read marks to the backend.
11632 (when (gnus-check-backend-function 'request-set-mark group)
11633 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11634 (add (gnus-remove-from-range read (gnus-info-read info))))
11635 (when (or add del)
11636 (unless (gnus-check-group group)
11637 (error "Can't open server for %s" group))
11638 (gnus-request-set-mark
11639 group (delq nil (list (if add (list add 'add '(read)))
11640 (if del (list del 'del '(read))))))
11641 (setq setmarkundo
11642 `(gnus-request-set-mark
11643 ,group
11644 ',(delq nil (list
11645 (if del (list del 'add '(read)))
11646 (if add (list add 'del '(read))))))))))
11647 (set-buffer gnus-group-buffer)
11648 (gnus-undo-register
11649 `(progn
11650 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11651 (gnus-info-set-read ',info ',(gnus-info-read info))
11652 (gnus-get-unread-articles-in-group ',info
11653 (gnus-active ,group))
11654 (gnus-group-update-group ,group t)
11655 ,setmarkundo))))
11656 ;; Enter this list into the group info.
11657 (gnus-info-set-read info read)
11658 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11659 (gnus-get-unread-articles-in-group info (gnus-active group))
11660 t))))
11661
11662 (defun gnus-offer-save-summaries ()
11663 "Offer to save all active summary buffers."
11664 (let (buffers)
11665 ;; Go through all buffers and find all summaries.
11666 (dolist (buffer (buffer-list))
11667 (when (and (setq buffer (buffer-name buffer))
11668 (string-match "Summary" buffer)
11669 (save-excursion
11670 (set-buffer buffer)
11671 ;; We check that this is, indeed, a summary buffer.
11672 (and (eq major-mode 'gnus-summary-mode)
11673 ;; Also make sure this isn't bogus.
11674 gnus-newsgroup-prepared
11675 ;; Also make sure that this isn't a
11676 ;; dead summary buffer.
11677 (not gnus-dead-summary-mode))))
11678 (push buffer buffers)))
11679 ;; Go through all these summary buffers and offer to save them.
11680 (when buffers
11681 (save-excursion
11682 (map-y-or-n-p
11683 "Update summary buffer %s? "
11684 (lambda (buf)
11685 (switch-to-buffer buf)
11686 (gnus-summary-exit))
11687 buffers)))))
11688
11689 (defun gnus-summary-setup-default-charset ()
11690 "Setup newsgroup default charset."
11691 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11692 (setq gnus-newsgroup-charset nil)
11693 (let* ((ignored-charsets
11694 (or gnus-newsgroup-ephemeral-ignored-charsets
11695 (append
11696 (and gnus-newsgroup-name
11697 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11698 gnus-newsgroup-ignored-charsets))))
11699 (setq gnus-newsgroup-charset
11700 (or gnus-newsgroup-ephemeral-charset
11701 (and gnus-newsgroup-name
11702 (gnus-parameter-charset gnus-newsgroup-name))
11703 gnus-default-charset))
11704 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11705 ignored-charsets))))
11706
11707 ;;;
11708 ;;; Mime Commands
11709 ;;;
11710
11711 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11712 "Display the current article buffer fully MIME-buttonized.
11713 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11714 treated as multipart/mixed."
11715 (interactive "P")
11716 (require 'gnus-art)
11717 (let ((gnus-unbuttonized-mime-types nil)
11718 (gnus-mime-display-multipart-as-mixed show-all-parts))
11719 (gnus-summary-show-article)))
11720
11721 (defun gnus-summary-repair-multipart (article)
11722 "Add a Content-Type header to a multipart article without one."
11723 (interactive (list (gnus-summary-article-number)))
11724 (gnus-with-article article
11725 (message-narrow-to-head)
11726 (message-remove-header "Mime-Version")
11727 (goto-char (point-max))
11728 (insert "Mime-Version: 1.0\n")
11729 (widen)
11730 (when (search-forward "\n--" nil t)
11731 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11732 (message-narrow-to-head)
11733 (message-remove-header "Content-Type")
11734 (goto-char (point-max))
11735 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11736 separator))
11737 (widen))))
11738 (let (gnus-mark-article-hook)
11739 (gnus-summary-select-article t t nil article)))
11740
11741 (defun gnus-summary-toggle-display-buttonized ()
11742 "Toggle the buttonizing of the article buffer."
11743 (interactive)
11744 (require 'gnus-art)
11745 (if (setq gnus-inhibit-mime-unbuttonizing
11746 (not gnus-inhibit-mime-unbuttonizing))
11747 (let ((gnus-unbuttonized-mime-types nil))
11748 (gnus-summary-show-article))
11749 (gnus-summary-show-article)))
11750
11751 ;;;
11752 ;;; Generic summary marking commands
11753 ;;;
11754
11755 (defvar gnus-summary-marking-alist
11756 '((read gnus-del-mark "d")
11757 (unread gnus-unread-mark "u")
11758 (ticked gnus-ticked-mark "!")
11759 (dormant gnus-dormant-mark "?")
11760 (expirable gnus-expirable-mark "e"))
11761 "An alist of names/marks/keystrokes.")
11762
11763 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11764 (defvar gnus-summary-mark-map)
11765
11766 (defun gnus-summary-make-all-marking-commands ()
11767 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11768 (dolist (elem gnus-summary-marking-alist)
11769 (apply 'gnus-summary-make-marking-command elem)))
11770
11771 (defun gnus-summary-make-marking-command (name mark keystroke)
11772 (let ((map (make-sparse-keymap)))
11773 (define-key gnus-summary-generic-mark-map keystroke map)
11774 (dolist (lway `((next "next" next nil "n")
11775 (next-unread "next unread" next t "N")
11776 (prev "previous" prev nil "p")
11777 (prev-unread "previous unread" prev t "P")
11778 (nomove "" nil nil ,keystroke)))
11779 (let ((func (gnus-summary-make-marking-command-1
11780 mark (car lway) lway name)))
11781 (setq func (eval func))
11782 (define-key map (nth 4 lway) func)))))
11783
11784 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11785 `(defun ,(intern
11786 (format "gnus-summary-put-mark-as-%s%s"
11787 name (if (eq way 'nomove)
11788 ""
11789 (concat "-" (symbol-name way)))))
11790 (n)
11791 ,(format
11792 "Mark the current article as %s%s.
11793 If N, the prefix, then repeat N times.
11794 If N is negative, move in reverse order.
11795 The difference between N and the actual number of articles marked is
11796 returned."
11797 name (cadr lway))
11798 (interactive "p")
11799 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11800
11801 (defun gnus-summary-generic-mark (n mark move unread)
11802 "Mark N articles with MARK."
11803 (unless (eq major-mode 'gnus-summary-mode)
11804 (error "This command can only be used in the summary buffer"))
11805 (gnus-summary-show-thread)
11806 (let ((nummove
11807 (cond
11808 ((eq move 'next) 1)
11809 ((eq move 'prev) -1)
11810 (t 0))))
11811 (if (zerop nummove)
11812 (setq n 1)
11813 (when (< n 0)
11814 (setq n (abs n)
11815 nummove (* -1 nummove))))
11816 (while (and (> n 0)
11817 (gnus-summary-mark-article nil mark)
11818 (zerop (gnus-summary-next-subject nummove unread t)))
11819 (setq n (1- n)))
11820 (when (/= 0 n)
11821 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11822 (gnus-summary-recenter)
11823 (gnus-summary-position-point)
11824 (gnus-set-mode-line 'summary)
11825 n))
11826
11827 (defun gnus-summary-insert-articles (articles)
11828 (when (setq articles
11829 (gnus-sorted-difference articles
11830 (mapcar (lambda (h)
11831 (mail-header-number h))
11832 gnus-newsgroup-headers)))
11833 (setq gnus-newsgroup-headers
11834 (gnus-merge 'list
11835 gnus-newsgroup-headers
11836 (gnus-fetch-headers articles)
11837 'gnus-article-sort-by-number))
11838 ;; Suppress duplicates?
11839 (when gnus-suppress-duplicates
11840 (gnus-dup-suppress-articles))
11841
11842 ;; We might want to build some more threads first.
11843 (when (and gnus-fetch-old-headers
11844 (eq gnus-headers-retrieved-by 'nov))
11845 (if (eq gnus-fetch-old-headers 'invisible)
11846 (gnus-build-all-threads)
11847 (gnus-build-old-threads)))
11848 ;; Let the Gnus agent mark articles as read.
11849 (when gnus-agent
11850 (gnus-agent-get-undownloaded-list))
11851 ;; Remove list identifiers from subject
11852 (when gnus-list-identifiers
11853 (gnus-summary-remove-list-identifiers))
11854 ;; First and last article in this newsgroup.
11855 (when gnus-newsgroup-headers
11856 (setq gnus-newsgroup-begin
11857 (mail-header-number (car gnus-newsgroup-headers))
11858 gnus-newsgroup-end
11859 (mail-header-number
11860 (gnus-last-element gnus-newsgroup-headers))))
11861 (when gnus-use-scoring
11862 (gnus-possibly-score-headers))))
11863
11864 (defun gnus-summary-insert-old-articles (&optional all)
11865 "Insert all old articles in this group.
11866 If ALL is non-nil, already read articles become readable.
11867 If ALL is a number, fetch this number of articles."
11868 (interactive "P")
11869 (prog1
11870 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11871 older len)
11872 (setq older
11873 ;; Some nntp servers lie about their active range. When
11874 ;; this happens, the active range can be in the millions.
11875 ;; Use a compressed range to avoid creating a huge list.
11876 (gnus-range-difference (list gnus-newsgroup-active) old))
11877 (setq len (gnus-range-length older))
11878 (cond
11879 ((null older) nil)
11880 ((numberp all)
11881 (if (< all len)
11882 (let ((older-range (nreverse older)))
11883 (setq older nil)
11884
11885 (while (> all 0)
11886 (let* ((r (pop older-range))
11887 (min (if (numberp r) r (car r)))
11888 (max (if (numberp r) r (cdr r))))
11889 (while (and (<= min max)
11890 (> all 0))
11891 (push max older)
11892 (setq all (1- all)
11893 max (1- max))))))
11894 (setq older (gnus-uncompress-range older))))
11895 (all
11896 (setq older (gnus-uncompress-range older)))
11897 (t
11898 (when (and (numberp gnus-large-newsgroup)
11899 (> len gnus-large-newsgroup))
11900 (let* ((cursor-in-echo-area nil)
11901 (initial (gnus-parameter-large-newsgroup-initial
11902 gnus-newsgroup-name))
11903 (input
11904 (read-string
11905 (format
11906 "How many articles from %s (%s %d): "
11907 (gnus-limit-string
11908 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11909 (if initial "max" "default")
11910 len)
11911 (if initial
11912 (cons (number-to-string initial)
11913 0)))))
11914 (unless (string-match "^[ \t]*$" input)
11915 (setq all (string-to-number input))
11916 (if (< all len)
11917 (let ((older-range (nreverse older)))
11918 (setq older nil)
11919
11920 (while (> all 0)
11921 (let* ((r (pop older-range))
11922 (min (if (numberp r) r (car r)))
11923 (max (if (numberp r) r (cdr r))))
11924 (while (and (<= min max)
11925 (> all 0))
11926 (push max older)
11927 (setq all (1- all)
11928 max (1- max))))))))))
11929 (setq older (gnus-uncompress-range older))))
11930 (if (not older)
11931 (message "No old news.")
11932 (gnus-summary-insert-articles older)
11933 (gnus-summary-limit (gnus-sorted-nunion old older))))
11934 (gnus-summary-position-point)))
11935
11936 (defun gnus-summary-insert-new-articles ()
11937 "Insert all new articles in this group."
11938 (interactive)
11939 (prog1
11940 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11941 (old-active gnus-newsgroup-active)
11942 (nnmail-fetched-sources (list t))
11943 i new)
11944 (setq gnus-newsgroup-active
11945 (gnus-activate-group gnus-newsgroup-name 'scan))
11946 (setq i (cdr gnus-newsgroup-active))
11947 (while (> i (cdr old-active))
11948 (push i new)
11949 (decf i))
11950 (if (not new)
11951 (message "No gnus is bad news.")
11952 (gnus-summary-insert-articles new)
11953 (setq gnus-newsgroup-unreads
11954 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11955 (gnus-summary-limit (gnus-sorted-nunion old new))))
11956 (gnus-summary-position-point)))
11957
11958 (gnus-summary-make-all-marking-commands)
11959
11960 (gnus-ems-redefine)
11961
11962 (provide 'gnus-sum)
11963
11964 (run-hooks 'gnus-sum-load-hook)
11965
11966 ;; Local Variables:
11967 ;; coding: iso-8859-1
11968 ;; End:
11969
11970 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11971 ;;; gnus-sum.el ends here