]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Merge from gnus--rel--5.10
[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, 2007, 2008 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 3, 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 an article on group entry.
308 An article is selected automatically when entering a group
309 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
310 `gnus-summary-catchup-and-goto-next-group'.
311
312 Which article is selected is controlled by the variable
313 `gnus-auto-select-subject'.
314
315 If you want to prevent automatic selection of articles in some
316 newsgroups, set the variable to nil in `gnus-select-group-hook'."
317 ;; Commands include...
318 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
319 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
320 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
321 :group 'gnus-group-select
322 :type '(choice (const :tag "none" nil)
323 (sexp :menu-tag "first" t)))
324
325 (defcustom gnus-auto-select-subject 'unread
326 "*Says what subject to place under point when entering a group.
327
328 This variable can either be the symbols `first' (place point on the
329 first subject), `unread' (place point on the subject line of the first
330 unread article), `best' (place point on the subject line of the
331 higest-scored article), `unseen' (place point on the subject line of
332 the first unseen article), `unseen-or-unread' (place point on the subject
333 line of the first unseen article or, if all article have been seen, on the
334 subject line of the first unread article), or a function to be called to
335 place point on some subject line."
336 :version "22.1"
337 :group 'gnus-group-select
338 :type '(choice (const best)
339 (const unread)
340 (const first)
341 (const unseen)
342 (const unseen-or-unread)))
343
344 (defcustom gnus-auto-select-next t
345 "*If non-nil, offer to go to the next group from the end of the previous.
346 If the value is t and the next newsgroup is empty, Gnus will exit
347 summary mode and go back to group mode. If the value is neither nil
348 nor t, Gnus will select the following unread newsgroup. In
349 particular, if the value is the symbol `quietly', the next unread
350 newsgroup will be selected without any confirmation, and if it is
351 `almost-quietly', the next group will be selected without any
352 confirmation if you are located on the last article in the group.
353 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
354 will go to the next group without confirmation."
355 :group 'gnus-summary-maneuvering
356 :type '(choice (const :tag "off" nil)
357 (const quietly)
358 (const almost-quietly)
359 (const slightly-quietly)
360 (sexp :menu-tag "on" t)))
361
362 (defcustom gnus-auto-select-same nil
363 "*If non-nil, select the next article with the same subject.
364 If there are no more articles with the same subject, go to
365 the first unread article."
366 :group 'gnus-summary-maneuvering
367 :type 'boolean)
368
369 (defcustom gnus-auto-goto-ignores 'unfetched
370 "*Says how to handle unfetched articles when maneuvering.
371
372 This variable can either be the symbols nil (maneuver to any
373 article), `undownloaded' (maneuvering while unplugged ignores articles
374 that have not been fetched), `always-undownloaded' (maneuvering always
375 ignores articles that have not been fetched), `unfetched' (maneuvering
376 ignores articles whose headers have not been fetched).
377
378 NOTE: The list of unfetched articles will always be nil when plugged
379 and, when unplugged, a subset of the undownloaded article list."
380 :version "22.1"
381 :group 'gnus-summary-maneuvering
382 :type '(choice (const :tag "None" nil)
383 (const :tag "Undownloaded when unplugged" undownloaded)
384 (const :tag "Undownloaded" always-undownloaded)
385 (const :tag "Unfetched" unfetched)))
386
387 (defcustom gnus-summary-check-current nil
388 "*If non-nil, consider the current article when moving.
389 The \"unread\" movement commands will stay on the same line if the
390 current article is unread."
391 :group 'gnus-summary-maneuvering
392 :type 'boolean)
393
394 (defcustom gnus-auto-center-summary t
395 "*If non-nil, always center the current summary buffer.
396 In particular, if `vertical' do only vertical recentering. If non-nil
397 and non-`vertical', do both horizontal and vertical recentering."
398 :group 'gnus-summary-maneuvering
399 :type '(choice (const :tag "none" nil)
400 (const vertical)
401 (integer :tag "height")
402 (sexp :menu-tag "both" t)))
403
404 (defvar gnus-auto-center-group t
405 "*If non-nil, always center the group buffer.")
406
407 (defcustom gnus-show-all-headers nil
408 "*If non-nil, don't hide any headers."
409 :group 'gnus-article-hiding
410 :group 'gnus-article-headers
411 :type 'boolean)
412
413 (defcustom gnus-summary-ignore-duplicates nil
414 "*If non-nil, ignore articles with identical Message-ID headers."
415 :group 'gnus-summary
416 :type 'boolean)
417
418 (defcustom gnus-single-article-buffer t
419 "*If non-nil, display all articles in the same buffer.
420 If nil, each group will get its own article buffer."
421 :group 'gnus-article-various
422 :type 'boolean)
423
424 (defcustom gnus-break-pages t
425 "*If non-nil, do page breaking on articles.
426 The page delimiter is specified by the `gnus-page-delimiter'
427 variable."
428 :group 'gnus-article-various
429 :type 'boolean)
430
431 (defcustom gnus-move-split-methods nil
432 "*Variable used to suggest where articles are to be moved to.
433 It uses the same syntax as the `gnus-split-methods' variable.
434 However, whereas `gnus-split-methods' specifies file names as targets,
435 this variable specifies group names."
436 :group 'gnus-summary-mail
437 :type '(repeat (choice (list :value (fun) function)
438 (cons :value ("" "") regexp (repeat string))
439 (sexp :value nil))))
440
441 ;; FIXME: Although the custom type is `character' for the following variables,
442 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
443
444 (defcustom gnus-unread-mark ? ;Whitespace
445 "*Mark used for unread articles."
446 :group 'gnus-summary-marks
447 :type 'character)
448
449 (defcustom gnus-ticked-mark ?!
450 "*Mark used for ticked articles."
451 :group 'gnus-summary-marks
452 :type 'character)
453
454 (defcustom gnus-dormant-mark ??
455 "*Mark used for dormant articles."
456 :group 'gnus-summary-marks
457 :type 'character)
458
459 (defcustom gnus-del-mark ?r
460 "*Mark used for del'd articles."
461 :group 'gnus-summary-marks
462 :type 'character)
463
464 (defcustom gnus-read-mark ?R
465 "*Mark used for read articles."
466 :group 'gnus-summary-marks
467 :type 'character)
468
469 (defcustom gnus-expirable-mark ?E
470 "*Mark used for expirable articles."
471 :group 'gnus-summary-marks
472 :type 'character)
473
474 (defcustom gnus-killed-mark ?K
475 "*Mark used for killed articles."
476 :group 'gnus-summary-marks
477 :type 'character)
478
479 (defcustom gnus-spam-mark ?$
480 "*Mark used for spam articles."
481 :version "22.1"
482 :group 'gnus-summary-marks
483 :type 'character)
484
485 (defcustom gnus-souped-mark ?F
486 "*Mark used for souped articles."
487 :group 'gnus-summary-marks
488 :type 'character)
489
490 (defcustom gnus-kill-file-mark ?X
491 "*Mark used for articles killed by kill files."
492 :group 'gnus-summary-marks
493 :type 'character)
494
495 (defcustom gnus-low-score-mark ?Y
496 "*Mark used for articles with a low score."
497 :group 'gnus-summary-marks
498 :type 'character)
499
500 (defcustom gnus-catchup-mark ?C
501 "*Mark used for articles that are caught up."
502 :group 'gnus-summary-marks
503 :type 'character)
504
505 (defcustom gnus-replied-mark ?A
506 "*Mark used for articles that have been replied to."
507 :group 'gnus-summary-marks
508 :type 'character)
509
510 (defcustom gnus-forwarded-mark ?F
511 "*Mark used for articles that have been forwarded."
512 :version "22.1"
513 :group 'gnus-summary-marks
514 :type 'character)
515
516 (defcustom gnus-recent-mark ?N
517 "*Mark used for articles that are recent."
518 :version "22.1"
519 :group 'gnus-summary-marks
520 :type 'character)
521
522 (defcustom gnus-cached-mark ?*
523 "*Mark used for articles that are in the cache."
524 :group 'gnus-summary-marks
525 :type 'character)
526
527 (defcustom gnus-saved-mark ?S
528 "*Mark used for articles that have been saved."
529 :group 'gnus-summary-marks
530 :type 'character)
531
532 (defcustom gnus-unseen-mark ?.
533 "*Mark used for articles that haven't been seen."
534 :version "22.1"
535 :group 'gnus-summary-marks
536 :type 'character)
537
538 (defcustom gnus-no-mark ? ;Whitespace
539 "*Mark used for articles that have no other secondary mark."
540 :version "22.1"
541 :group 'gnus-summary-marks
542 :type 'character)
543
544 (defcustom gnus-ancient-mark ?O
545 "*Mark used for ancient articles."
546 :group 'gnus-summary-marks
547 :type 'character)
548
549 (defcustom gnus-sparse-mark ?Q
550 "*Mark used for sparsely reffed articles."
551 :group 'gnus-summary-marks
552 :type 'character)
553
554 (defcustom gnus-canceled-mark ?G
555 "*Mark used for canceled articles."
556 :group 'gnus-summary-marks
557 :type 'character)
558
559 (defcustom gnus-duplicate-mark ?M
560 "*Mark used for duplicate articles."
561 :group 'gnus-summary-marks
562 :type 'character)
563
564 (defcustom gnus-undownloaded-mark ?-
565 "*Mark used for articles that weren't downloaded."
566 :version "22.1"
567 :group 'gnus-summary-marks
568 :type 'character)
569
570 (defcustom gnus-downloaded-mark ?+
571 "*Mark used for articles that were downloaded."
572 :group 'gnus-summary-marks
573 :type 'character)
574
575 (defcustom gnus-downloadable-mark ?%
576 "*Mark used for articles that are to be downloaded."
577 :group 'gnus-summary-marks
578 :type 'character)
579
580 (defcustom gnus-unsendable-mark ?=
581 "*Mark used for articles that won't be sent."
582 :group 'gnus-summary-marks
583 :type 'character)
584
585 (defcustom gnus-score-over-mark ?+
586 "*Score mark used for articles with high scores."
587 :group 'gnus-summary-marks
588 :type 'character)
589
590 (defcustom gnus-score-below-mark ?-
591 "*Score mark used for articles with low scores."
592 :group 'gnus-summary-marks
593 :type 'character)
594
595 (defcustom gnus-empty-thread-mark ? ;Whitespace
596 "*There is no thread under the article."
597 :group 'gnus-summary-marks
598 :type 'character)
599
600 (defcustom gnus-not-empty-thread-mark ?=
601 "*There is a thread under the article."
602 :group 'gnus-summary-marks
603 :type 'character)
604
605 (defcustom gnus-view-pseudo-asynchronously nil
606 "*If non-nil, Gnus will view pseudo-articles asynchronously."
607 :group 'gnus-extract-view
608 :type 'boolean)
609
610 (defcustom gnus-auto-expirable-marks
611 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
612 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
613 gnus-souped-mark gnus-duplicate-mark)
614 "*The list of marks converted into expiration if a group is auto-expirable."
615 :version "21.1"
616 :group 'gnus-summary
617 :type '(repeat character))
618
619 (defcustom gnus-inhibit-user-auto-expire t
620 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
621 :version "21.1"
622 :group 'gnus-summary
623 :type 'boolean)
624
625 (defcustom gnus-view-pseudos nil
626 "*If `automatic', pseudo-articles will be viewed automatically.
627 If `not-confirm', pseudos will be viewed automatically, and the user
628 will not be asked to confirm the command."
629 :group 'gnus-extract-view
630 :type '(choice (const :tag "off" nil)
631 (const automatic)
632 (const not-confirm)))
633
634 (defcustom gnus-view-pseudos-separately t
635 "*If non-nil, one pseudo-article will be created for each file to be viewed.
636 If nil, all files that use the same viewing command will be given as a
637 list of parameters to that command."
638 :group 'gnus-extract-view
639 :type 'boolean)
640
641 (defcustom gnus-insert-pseudo-articles t
642 "*If non-nil, insert pseudo-articles when decoding articles."
643 :group 'gnus-extract-view
644 :type 'boolean)
645
646 (defcustom gnus-summary-dummy-line-format
647 " %(: :%) %S\n"
648 "*The format specification for the dummy roots in the summary buffer.
649 It works along the same lines as a normal formatting string,
650 with some simple extensions.
651
652 %S The subject
653
654 General format specifiers can also be used.
655 See `(gnus)Formatting Variables'."
656 :link '(custom-manual "(gnus)Formatting Variables")
657 :group 'gnus-threading
658 :type 'string)
659
660 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
661 "*The format specification for the summary mode line.
662 It works along the same lines as a normal formatting string,
663 with some simple extensions:
664
665 %G Group name
666 %p Unprefixed group name
667 %A Current article number
668 %z Current article score
669 %V Gnus version
670 %U Number of unread articles in the group
671 %e Number of unselected articles in the group
672 %Z A string with unread/unselected article counts
673 %g Shortish group name
674 %S Subject of the current article
675 %u User-defined spec
676 %s Current score file name
677 %d Number of dormant articles
678 %r Number of articles that have been marked as read in this session
679 %E Number of articles expunged by the score files"
680 :group 'gnus-summary-format
681 :type 'string)
682
683 (defcustom gnus-list-identifiers nil
684 "Regexp that matches list identifiers to be removed from subject.
685 This can also be a list of regexps."
686 :version "21.1"
687 :group 'gnus-summary-format
688 :group 'gnus-article-hiding
689 :type '(choice (const :tag "none" nil)
690 (regexp :value ".*")
691 (repeat :value (".*") regexp)))
692
693 (defcustom gnus-summary-mark-below 0
694 "*Mark all articles with a score below this variable as read.
695 This variable is local to each summary buffer and usually set by the
696 score file."
697 :group 'gnus-score-default
698 :type 'integer)
699
700 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
701 "*List of functions used for sorting articles in the summary buffer.
702
703 Each function takes two articles and returns non-nil if the first
704 article should be sorted before the other. If you use more than one
705 function, the primary sort function should be the last. You should
706 probably always include `gnus-article-sort-by-number' in the list of
707 sorting functions -- preferably first. Also note that sorting by date
708 is often much slower than sorting by number, and the sorting order is
709 very similar. (Sorting by date means sorting by the time the message
710 was sent, sorting by number means sorting by arrival time.)
711
712 Ready-made functions include `gnus-article-sort-by-number',
713 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
714 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
715 and `gnus-article-sort-by-score'.
716
717 When threading is turned on, the variable `gnus-thread-sort-functions'
718 controls how articles are sorted."
719 :group 'gnus-summary-sort
720 :type '(repeat (choice (function-item gnus-article-sort-by-number)
721 (function-item gnus-article-sort-by-author)
722 (function-item gnus-article-sort-by-subject)
723 (function-item gnus-article-sort-by-date)
724 (function-item gnus-article-sort-by-score)
725 (function-item gnus-article-sort-by-random)
726 (function :tag "other"))))
727
728 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
729 "*List of functions used for sorting threads in the summary buffer.
730 By default, threads are sorted by article number.
731
732 Each function takes two threads and returns non-nil if the first
733 thread should be sorted before the other. If you use more than one
734 function, the primary sort function should be the last. You should
735 probably always include `gnus-thread-sort-by-number' in the list of
736 sorting functions -- preferably first. Also note that sorting by date
737 is often much slower than sorting by number, and the sorting order is
738 very similar. (Sorting by date means sorting by the time the message
739 was sent, sorting by number means sorting by arrival time.)
740
741 Ready-made functions include `gnus-thread-sort-by-number',
742 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
743 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
744 `gnus-thread-sort-by-most-recent-number',
745 `gnus-thread-sort-by-most-recent-date',
746 `gnus-thread-sort-by-random', and
747 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
748
749 When threading is turned off, the variable
750 `gnus-article-sort-functions' controls how articles are sorted."
751 :group 'gnus-summary-sort
752 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
753 (function-item gnus-thread-sort-by-author)
754 (function-item gnus-thread-sort-by-subject)
755 (function-item gnus-thread-sort-by-date)
756 (function-item gnus-thread-sort-by-score)
757 (function-item gnus-thread-sort-by-total-score)
758 (function-item gnus-thread-sort-by-random)
759 (function :tag "other"))))
760
761 (defcustom gnus-thread-score-function '+
762 "*Function used for calculating the total score of a thread.
763
764 The function is called with the scores of the article and each
765 subthread and should then return the score of the thread.
766
767 Some functions you can use are `+', `max', or `min'."
768 :group 'gnus-summary-sort
769 :type 'function)
770
771 (defcustom gnus-summary-expunge-below nil
772 "All articles that have a score less than this variable will be expunged.
773 This variable is local to the summary buffers."
774 :group 'gnus-score-default
775 :type '(choice (const :tag "off" nil)
776 integer))
777
778 (defcustom gnus-thread-expunge-below nil
779 "All threads that have a total score less than this variable will be expunged.
780 See `gnus-thread-score-function' for en explanation of what a
781 \"thread score\" is.
782
783 This variable is local to the summary buffers."
784 :group 'gnus-threading
785 :group 'gnus-score-default
786 :type '(choice (const :tag "off" nil)
787 integer))
788
789 (defcustom gnus-summary-mode-hook nil
790 "*A hook for Gnus summary mode.
791 This hook is run before any variables are set in the summary buffer."
792 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
793 :group 'gnus-summary-various
794 :type 'hook)
795
796 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
797 (when (featurep 'xemacs)
798 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
799 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
800 (add-hook 'gnus-summary-mode-hook
801 'gnus-xmas-switch-horizontal-scrollbar-off))
802
803 (defcustom gnus-summary-menu-hook nil
804 "*Hook run after the creation of the summary mode menu."
805 :group 'gnus-summary-visual
806 :type 'hook)
807
808 (defcustom gnus-summary-exit-hook nil
809 "*A hook called on exit from the summary buffer.
810 It will be called with point in the group buffer."
811 :group 'gnus-summary-exit
812 :type 'hook)
813
814 (defcustom gnus-summary-prepare-hook nil
815 "*A hook called after the summary buffer has been generated.
816 If you want to modify the summary buffer, you can use this hook."
817 :group 'gnus-summary-various
818 :type 'hook)
819
820 (defcustom gnus-summary-prepared-hook nil
821 "*A hook called as the last thing after the summary buffer has been generated."
822 :group 'gnus-summary-various
823 :type 'hook)
824
825 (defcustom gnus-summary-generate-hook nil
826 "*A hook run just before generating the summary buffer.
827 This hook is commonly used to customize threading variables and the
828 like."
829 :group 'gnus-summary-various
830 :type 'hook)
831
832 (defcustom gnus-select-group-hook nil
833 "*A hook called when a newsgroup is selected.
834
835 If you'd like to simplify subjects like the
836 `gnus-summary-next-same-subject' command does, you can use the
837 following hook:
838
839 (add-hook gnus-select-group-hook
840 (lambda ()
841 (mapcar (lambda (header)
842 (mail-header-set-subject
843 header
844 (gnus-simplify-subject
845 (mail-header-subject header) 're-only)))
846 gnus-newsgroup-headers)))"
847 :group 'gnus-group-select
848 :type 'hook)
849
850 (defcustom gnus-select-article-hook nil
851 "*A hook called when an article is selected."
852 :group 'gnus-summary-choose
853 :options '(gnus-agent-fetch-selected-article)
854 :type 'hook)
855
856 (defcustom gnus-visual-mark-article-hook
857 (list 'gnus-highlight-selected-summary)
858 "*Hook run after selecting an article in the summary buffer.
859 It is meant to be used for highlighting the article in some way. It
860 is not run if `gnus-visual' is nil."
861 :group 'gnus-summary-visual
862 :type 'hook)
863
864 (defcustom gnus-parse-headers-hook nil
865 "*A hook called before parsing the headers."
866 :group 'gnus-various
867 :type 'hook)
868
869 (defcustom gnus-exit-group-hook nil
870 "*A hook called when exiting summary mode.
871 This hook is not called from the non-updating exit commands like `Q'."
872 :group 'gnus-various
873 :type 'hook)
874
875 (defcustom gnus-summary-update-hook
876 (list 'gnus-summary-highlight-line)
877 "*A hook called when a summary line is changed.
878 The hook will not be called if `gnus-visual' is nil.
879
880 The default function `gnus-summary-highlight-line' will
881 highlight the line according to the `gnus-summary-highlight'
882 variable."
883 :group 'gnus-summary-visual
884 :type 'hook)
885
886 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
887 "*A hook called when an article is selected for the first time.
888 The hook is intended to mark an article as read (or unread)
889 automatically when it is selected."
890 :group 'gnus-summary-choose
891 :type 'hook)
892
893 (defcustom gnus-group-no-more-groups-hook nil
894 "*A hook run when returning to group mode having no more (unread) groups."
895 :group 'gnus-group-select
896 :type 'hook)
897
898 (defcustom gnus-ps-print-hook nil
899 "*A hook run before ps-printing something from Gnus."
900 :group 'gnus-summary
901 :type 'hook)
902
903 (defcustom gnus-summary-article-move-hook nil
904 "*A hook called after an article is moved, copied, respooled, or crossposted."
905 :version "22.1"
906 :group 'gnus-summary
907 :type 'hook)
908
909 (defcustom gnus-summary-article-delete-hook nil
910 "*A hook called after an article is deleted."
911 :version "22.1"
912 :group 'gnus-summary
913 :type 'hook)
914
915 (defcustom gnus-summary-article-expire-hook nil
916 "*A hook called after an article is expired."
917 :version "22.1"
918 :group 'gnus-summary
919 :type 'hook)
920
921 (defcustom gnus-summary-display-arrow
922 (and (fboundp 'display-graphic-p)
923 (display-graphic-p))
924 "*If non-nil, display an arrow highlighting the current article."
925 :version "22.1"
926 :group 'gnus-summary
927 :type 'boolean)
928
929 (defcustom gnus-summary-selected-face 'gnus-summary-selected
930 "Face used for highlighting the current article in the summary buffer."
931 :group 'gnus-summary-visual
932 :type 'face)
933
934 (defvar gnus-tmp-downloaded nil)
935
936 (defcustom gnus-summary-highlight
937 '(((eq mark gnus-canceled-mark)
938 . gnus-summary-cancelled)
939 ((and uncached (> score default-high))
940 . gnus-summary-high-undownloaded)
941 ((and uncached (< score default-low))
942 . gnus-summary-low-undownloaded)
943 (uncached
944 . gnus-summary-normal-undownloaded)
945 ((and (> score default-high)
946 (or (eq mark gnus-dormant-mark)
947 (eq mark gnus-ticked-mark)))
948 . gnus-summary-high-ticked)
949 ((and (< score default-low)
950 (or (eq mark gnus-dormant-mark)
951 (eq mark gnus-ticked-mark)))
952 . gnus-summary-low-ticked)
953 ((or (eq mark gnus-dormant-mark)
954 (eq mark gnus-ticked-mark))
955 . gnus-summary-normal-ticked)
956 ((and (> score default-high) (eq mark gnus-ancient-mark))
957 . gnus-summary-high-ancient)
958 ((and (< score default-low) (eq mark gnus-ancient-mark))
959 . gnus-summary-low-ancient)
960 ((eq mark gnus-ancient-mark)
961 . gnus-summary-normal-ancient)
962 ((and (> score default-high) (eq mark gnus-unread-mark))
963 . gnus-summary-high-unread)
964 ((and (< score default-low) (eq mark gnus-unread-mark))
965 . gnus-summary-low-unread)
966 ((eq mark gnus-unread-mark)
967 . gnus-summary-normal-unread)
968 ((> score default-high)
969 . gnus-summary-high-read)
970 ((< score default-low)
971 . gnus-summary-low-read)
972 (t
973 . gnus-summary-normal-read))
974 "*Controls the highlighting of summary buffer lines.
975
976 A list of (FORM . FACE) pairs. When deciding how a particular
977 summary line should be displayed, each form is evaluated. The content
978 of the face field after the first true form is used. You can change
979 how those summary lines are displayed, by editing the face field.
980
981 You can use the following variables in the FORM field.
982
983 score: The article's score.
984 default: The default article score.
985 default-high: The default score for high scored articles.
986 default-low: The default score for low scored articles.
987 below: The score below which articles are automatically marked as read.
988 mark: The article's mark.
989 uncached: Non-nil if the article is uncached."
990 :group 'gnus-summary-visual
991 :type '(repeat (cons (sexp :tag "Form" nil)
992 face)))
993 (put 'gnus-summary-highlight 'risky-local-variable t)
994
995 (defcustom gnus-alter-header-function nil
996 "Function called to allow alteration of article header structures.
997 The function is called with one parameter, the article header vector,
998 which it may alter in any way."
999 :type '(choice (const :tag "None" nil)
1000 function)
1001 :group 'gnus-summary)
1002
1003 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1004 "Function used to decode a string with encoded words.")
1005
1006 (defvar gnus-decode-encoded-address-function
1007 'mail-decode-encoded-address-string
1008 "Function used to decode addresses with encoded words.")
1009
1010 (defcustom gnus-extra-headers '(To Newsgroups)
1011 "*Extra headers to parse."
1012 :version "21.1"
1013 :group 'gnus-summary
1014 :type '(repeat symbol))
1015
1016 (defcustom gnus-ignored-from-addresses
1017 (and user-mail-address
1018 (not (string= user-mail-address ""))
1019 (regexp-quote user-mail-address))
1020 "*Regexp of From headers that may be suppressed in favor of To headers."
1021 :version "21.1"
1022 :group 'gnus-summary
1023 :type 'regexp)
1024
1025 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1026 "List of charsets that should be ignored.
1027 When these charsets are used in the \"charset\" parameter, the
1028 default charset will be used instead."
1029 :version "21.1"
1030 :type '(repeat symbol)
1031 :group 'gnus-charset)
1032
1033 (defcustom gnus-newsgroup-maximum-articles nil
1034 "The maximum number of articles a newsgroup.
1035 If this is a number, old articles in a newsgroup exceeding this number
1036 are silently ignored. If it is nil, no article is ignored. Note that
1037 setting this variable to a number might prevent you from reading very
1038 old articles."
1039 :group 'gnus-group-select
1040 :version "22.2"
1041 :type '(choice (const :tag "No limit" nil)
1042 integer))
1043
1044 (gnus-define-group-parameter
1045 ignored-charsets
1046 :type list
1047 :function-document
1048 "Return the ignored charsets of GROUP."
1049 :variable gnus-group-ignored-charsets-alist
1050 :variable-default
1051 '(("alt\\.chinese\\.text" iso-8859-1))
1052 :variable-document
1053 "Alist of regexps (to match group names) and charsets that should be ignored.
1054 When these charsets are used in the \"charset\" parameter, the
1055 default charset will be used instead."
1056 :variable-group gnus-charset
1057 :variable-type '(repeat (cons (regexp :tag "Group")
1058 (repeat symbol)))
1059 :parameter-type '(choice :tag "Ignored charsets"
1060 :value nil
1061 (repeat (symbol)))
1062 :parameter-document "\
1063 List of charsets that should be ignored.
1064
1065 When these charsets are used in the \"charset\" parameter, the
1066 default charset will be used instead.")
1067
1068 (defcustom gnus-group-highlight-words-alist nil
1069 "Alist of group regexps and highlight regexps.
1070 This variable uses the same syntax as `gnus-emphasis-alist'."
1071 :version "21.1"
1072 :type '(repeat (cons (regexp :tag "Group")
1073 (repeat (list (regexp :tag "Highlight regexp")
1074 (number :tag "Group for entire word" 0)
1075 (number :tag "Group for displayed part" 0)
1076 (symbol :tag "Face"
1077 gnus-emphasis-highlight-words)))))
1078 :group 'gnus-summary-visual)
1079
1080 (defcustom gnus-summary-show-article-charset-alist
1081 nil
1082 "Alist of number and charset.
1083 The article will be shown with the charset corresponding to the
1084 numbered argument.
1085 For example: ((1 . cn-gb-2312) (2 . big5))."
1086 :version "21.1"
1087 :type '(repeat (cons (number :tag "Argument" 1)
1088 (symbol :tag "Charset")))
1089 :group 'gnus-charset)
1090
1091 (defcustom gnus-preserve-marks t
1092 "Whether marks are preserved when moving, copying and respooling messages."
1093 :version "21.1"
1094 :type 'boolean
1095 :group 'gnus-summary-marks)
1096
1097 (defcustom gnus-alter-articles-to-read-function nil
1098 "Function to be called to alter the list of articles to be selected."
1099 :type '(choice (const nil) function)
1100 :group 'gnus-summary)
1101
1102 (defcustom gnus-orphan-score nil
1103 "*All orphans get this score added. Set in the score file."
1104 :group 'gnus-score-default
1105 :type '(choice (const nil)
1106 integer))
1107
1108 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1109 "*A regexp to match MIME parts when saving multiple parts of a
1110 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1111 This regexp will be used by default when prompting the user for which
1112 type of files to save."
1113 :group 'gnus-summary
1114 :type 'regexp)
1115
1116 (defcustom gnus-read-all-available-headers nil
1117 "Whether Gnus should parse all headers made available to it.
1118 This is mostly relevant for slow back ends where the user may
1119 wish to widen the summary buffer to include all headers
1120 that were fetched. Say, for nnultimate groups."
1121 :version "22.1"
1122 :group 'gnus-summary
1123 :type '(choice boolean regexp))
1124
1125 (defcustom gnus-summary-muttprint-program "muttprint"
1126 "Command (and optional arguments) used to run Muttprint."
1127 :version "22.1"
1128 :group 'gnus-summary
1129 :type 'string)
1130
1131 (defcustom gnus-article-loose-mime nil
1132 "If non-nil, don't require MIME-Version header.
1133 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1134 supply the MIME-Version header or deliberately strip it from the mail.
1135 Set it to non-nil, Gnus will treat some articles as MIME even if
1136 the MIME-Version header is missed."
1137 :version "22.1"
1138 :type 'boolean
1139 :group 'gnus-article-mime)
1140
1141 (defcustom gnus-article-emulate-mime t
1142 "If non-nil, use MIME emulation for uuencode and the like.
1143 This means that Gnus will search message bodies for text that look
1144 like uuencoded bits, yEncoded bits, and so on, and present that using
1145 the normal Gnus MIME machinery."
1146 :version "22.1"
1147 :type 'boolean
1148 :group 'gnus-article-mime)
1149
1150 ;;; Internal variables
1151
1152 (defvar gnus-summary-display-cache nil)
1153 (defvar gnus-article-mime-handles nil)
1154 (defvar gnus-article-decoded-p nil)
1155 (defvar gnus-article-charset nil)
1156 (defvar gnus-article-ignored-charsets nil)
1157 (defvar gnus-scores-exclude-files nil)
1158 (defvar gnus-page-broken nil)
1159
1160 (defvar gnus-original-article nil)
1161 (defvar gnus-article-internal-prepare-hook nil)
1162 (defvar gnus-newsgroup-process-stack nil)
1163
1164 (defvar gnus-thread-indent-array nil)
1165 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1166 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1167 "Function called to sort the articles within a thread after it has been gathered together.")
1168
1169 (defvar gnus-summary-save-parts-type-history nil)
1170 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1171
1172 ;; Avoid highlighting in kill files.
1173 (defvar gnus-summary-inhibit-highlight nil)
1174 (defvar gnus-newsgroup-selected-overlay nil)
1175 (defvar gnus-inhibit-limiting nil)
1176 (defvar gnus-newsgroup-adaptive-score-file nil)
1177 (defvar gnus-current-score-file nil)
1178 (defvar gnus-current-move-group nil)
1179 (defvar gnus-current-copy-group nil)
1180 (defvar gnus-current-crosspost-group nil)
1181 (defvar gnus-newsgroup-display nil)
1182
1183 (defvar gnus-newsgroup-dependencies nil)
1184 (defvar gnus-newsgroup-adaptive nil)
1185 (defvar gnus-summary-display-article-function nil)
1186 (defvar gnus-summary-highlight-line-function nil
1187 "Function called after highlighting a summary line.")
1188
1189 (defvar gnus-summary-line-format-alist
1190 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1191 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1192 (?s gnus-tmp-subject-or-nil ?s)
1193 (?n gnus-tmp-name ?s)
1194 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1195 ?s)
1196 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1197 gnus-tmp-from) ?s)
1198 (?F gnus-tmp-from ?s)
1199 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1200 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1201 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1202 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1203 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1204 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1205 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1206 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1207 (?L gnus-tmp-lines ?s)
1208 (?O gnus-tmp-downloaded ?c)
1209 (?I gnus-tmp-indentation ?s)
1210 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1211 (?R gnus-tmp-replied ?c)
1212 (?\[ gnus-tmp-opening-bracket ?c)
1213 (?\] gnus-tmp-closing-bracket ?c)
1214 (?\> (make-string gnus-tmp-level ? ) ?s)
1215 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1216 (?i gnus-tmp-score ?d)
1217 (?z gnus-tmp-score-char ?c)
1218 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1219 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1220 (?U gnus-tmp-unread ?c)
1221 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1222 ?s)
1223 (?t (gnus-summary-number-of-articles-in-thread
1224 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1225 ?d)
1226 (?e (gnus-summary-number-of-articles-in-thread
1227 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1228 ?c)
1229 (?u gnus-tmp-user-defined ?s)
1230 (?P (gnus-pick-line-number) ?d)
1231 (?B gnus-tmp-thread-tree-header-string ?s)
1232 (user-date (gnus-user-date
1233 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1234 "An alist of format specifications that can appear in summary lines.
1235 These are paired with what variables they correspond with, along with
1236 the type of the variable (string, integer, character, etc).")
1237
1238 (defvar gnus-summary-dummy-line-format-alist
1239 `((?S gnus-tmp-subject ?s)
1240 (?N gnus-tmp-number ?d)
1241 (?u gnus-tmp-user-defined ?s)))
1242
1243 (defvar gnus-summary-mode-line-format-alist
1244 `((?G gnus-tmp-group-name ?s)
1245 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1246 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1247 (?A gnus-tmp-article-number ?d)
1248 (?Z gnus-tmp-unread-and-unselected ?s)
1249 (?V gnus-version ?s)
1250 (?U gnus-tmp-unread-and-unticked ?d)
1251 (?S gnus-tmp-subject ?s)
1252 (?e gnus-tmp-unselected ?d)
1253 (?u gnus-tmp-user-defined ?s)
1254 (?d (length gnus-newsgroup-dormant) ?d)
1255 (?t (length gnus-newsgroup-marked) ?d)
1256 (?h (length gnus-newsgroup-spam-marked) ?d)
1257 (?r (length gnus-newsgroup-reads) ?d)
1258 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1259 (?E gnus-newsgroup-expunged-tally ?d)
1260 (?s (gnus-current-score-file-nondirectory) ?s)))
1261
1262 (defvar gnus-last-search-regexp nil
1263 "Default regexp for article search command.")
1264
1265 (defvar gnus-last-shell-command nil
1266 "Default shell command on article.")
1267
1268 (defvar gnus-newsgroup-agentized nil
1269 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1270 (defvar gnus-newsgroup-begin nil)
1271 (defvar gnus-newsgroup-end nil)
1272 (defvar gnus-newsgroup-last-rmail nil)
1273 (defvar gnus-newsgroup-last-mail nil)
1274 (defvar gnus-newsgroup-last-folder nil)
1275 (defvar gnus-newsgroup-last-file nil)
1276 (defvar gnus-newsgroup-last-directory nil)
1277 (defvar gnus-newsgroup-auto-expire nil)
1278 (defvar gnus-newsgroup-active nil)
1279
1280 (defvar gnus-newsgroup-data nil)
1281 (defvar gnus-newsgroup-data-reverse nil)
1282 (defvar gnus-newsgroup-limit nil)
1283 (defvar gnus-newsgroup-limits nil)
1284 (defvar gnus-summary-use-undownloaded-faces nil)
1285
1286 (defvar gnus-newsgroup-unreads nil
1287 "Sorted list of unread articles in the current newsgroup.")
1288
1289 (defvar gnus-newsgroup-unselected nil
1290 "Sorted list of unselected unread articles in the current newsgroup.")
1291
1292 (defvar gnus-newsgroup-reads nil
1293 "Alist of read articles and article marks in the current newsgroup.")
1294
1295 (defvar gnus-newsgroup-expunged-tally nil)
1296
1297 (defvar gnus-newsgroup-marked nil
1298 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1299
1300 (defvar gnus-newsgroup-spam-marked nil
1301 "List of ranges of articles that have been marked as spam.")
1302
1303 (defvar gnus-newsgroup-killed nil
1304 "List of ranges of articles that have been through the scoring process.")
1305
1306 (defvar gnus-newsgroup-cached nil
1307 "Sorted list of articles that come from the article cache.")
1308
1309 (defvar gnus-newsgroup-saved nil
1310 "List of articles that have been saved.")
1311
1312 (defvar gnus-newsgroup-kill-headers nil)
1313
1314 (defvar gnus-newsgroup-replied nil
1315 "List of articles that have been replied to in the current newsgroup.")
1316
1317 (defvar gnus-newsgroup-forwarded nil
1318 "List of articles that have been forwarded in the current newsgroup.")
1319
1320 (defvar gnus-newsgroup-recent nil
1321 "List of articles that have are recent in the current newsgroup.")
1322
1323 (defvar gnus-newsgroup-expirable nil
1324 "Sorted list of articles in the current newsgroup that can be expired.")
1325
1326 (defvar gnus-newsgroup-processable nil
1327 "List of articles in the current newsgroup that can be processed.")
1328
1329 (defvar gnus-newsgroup-downloadable nil
1330 "Sorted list of articles in the current newsgroup that can be processed.")
1331
1332 (defvar gnus-newsgroup-unfetched nil
1333 "Sorted list of articles in the current newsgroup whose headers have
1334 not been fetched into the agent.
1335
1336 This list will always be a subset of gnus-newsgroup-undownloaded.")
1337
1338 (defvar gnus-newsgroup-undownloaded nil
1339 "List of articles in the current newsgroup that haven't been downloaded.")
1340
1341 (defvar gnus-newsgroup-unsendable nil
1342 "List of articles in the current newsgroup that won't be sent.")
1343
1344 (defvar gnus-newsgroup-bookmarks nil
1345 "List of articles in the current newsgroup that have bookmarks.")
1346
1347 (defvar gnus-newsgroup-dormant nil
1348 "Sorted list of dormant articles in the current newsgroup.")
1349
1350 (defvar gnus-newsgroup-unseen nil
1351 "List of unseen articles in the current newsgroup.")
1352
1353 (defvar gnus-newsgroup-seen nil
1354 "Range of seen articles in the current newsgroup.")
1355
1356 (defvar gnus-newsgroup-articles nil
1357 "List of articles in the current newsgroup.")
1358
1359 (defvar gnus-newsgroup-scored nil
1360 "List of scored articles in the current newsgroup.")
1361
1362 (defvar gnus-newsgroup-headers nil
1363 "List of article headers in the current newsgroup.")
1364
1365 (defvar gnus-newsgroup-threads nil)
1366
1367 (defvar gnus-newsgroup-prepared nil
1368 "Whether the current group has been prepared properly.")
1369
1370 (defvar gnus-newsgroup-ancient nil
1371 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1372
1373 (defvar gnus-newsgroup-sparse nil)
1374
1375 (defvar gnus-current-article nil)
1376 (defvar gnus-article-current nil)
1377 (defvar gnus-current-headers nil)
1378 (defvar gnus-have-all-headers nil)
1379 (defvar gnus-last-article nil)
1380 (defvar gnus-newsgroup-history nil)
1381 (defvar gnus-newsgroup-charset nil)
1382 (defvar gnus-newsgroup-ephemeral-charset nil)
1383 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1384
1385 (defvar gnus-article-before-search nil)
1386
1387 (defvar gnus-summary-local-variables
1388 '(gnus-newsgroup-name
1389 gnus-newsgroup-begin gnus-newsgroup-end
1390 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1391 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1392 gnus-newsgroup-last-directory
1393 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1394 gnus-newsgroup-unselected gnus-newsgroup-marked
1395 gnus-newsgroup-spam-marked
1396 gnus-newsgroup-reads gnus-newsgroup-saved
1397 gnus-newsgroup-replied gnus-newsgroup-forwarded
1398 gnus-newsgroup-recent
1399 gnus-newsgroup-expirable
1400 gnus-newsgroup-processable gnus-newsgroup-killed
1401 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1402 gnus-newsgroup-unfetched
1403 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1404 gnus-newsgroup-seen gnus-newsgroup-articles
1405 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1406 gnus-newsgroup-headers gnus-newsgroup-threads
1407 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1408 gnus-current-article gnus-current-headers gnus-have-all-headers
1409 gnus-last-article gnus-article-internal-prepare-hook
1410 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1411 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1412 gnus-thread-expunge-below
1413 gnus-score-alist gnus-current-score-file
1414 (gnus-summary-expunge-below . global)
1415 (gnus-summary-mark-below . global)
1416 (gnus-orphan-score . global)
1417 gnus-newsgroup-active gnus-scores-exclude-files
1418 gnus-newsgroup-history gnus-newsgroup-ancient
1419 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1420 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1421 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1422 (gnus-newsgroup-expunged-tally . 0)
1423 gnus-cache-removable-articles gnus-newsgroup-cached
1424 gnus-newsgroup-data gnus-newsgroup-data-reverse
1425 gnus-newsgroup-limit gnus-newsgroup-limits
1426 gnus-newsgroup-charset gnus-newsgroup-display
1427 gnus-summary-use-undownloaded-faces)
1428 "Variables that are buffer-local to the summary buffers.")
1429
1430 (defvar gnus-newsgroup-variables nil
1431 "A list of variables that have separate values in different newsgroups.
1432 A list of newsgroup (summary buffer) local variables, or cons of
1433 variables and their default expressions to be evalled (when the default
1434 values are not nil), that should be made global while the summary buffer
1435 is active.
1436
1437 Note: The default expressions will be evaluated (using function `eval')
1438 before assignment to the local variable rather than just assigned to it.
1439 If the default expression is the symbol `global', that symbol will not
1440 be evaluated but the global value of the local variable will be used
1441 instead.
1442
1443 These variables can be used to set variables in the group parameters
1444 while still allowing them to affect operations done in other buffers.
1445 For example:
1446
1447 \(setq gnus-newsgroup-variables
1448 '(message-use-followup-to
1449 (gnus-visible-headers .
1450 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1451 ")
1452
1453 ;; Byte-compiler warning.
1454 (eval-when-compile
1455 ;; Bind features so that require will believe that gnus-sum has
1456 ;; already been loaded (avoids infinite recursion)
1457 (let ((features (cons 'gnus-sum features)))
1458 ;; Several of the declarations in gnus-sum are needed to load the
1459 ;; following files. Right now, these definitions have been
1460 ;; compiled but not defined (evaluated). We could either do a
1461 ;; eval-and-compile about all of the declarations or evaluate the
1462 ;; source file.
1463 (if (boundp 'gnus-newsgroup-variables)
1464 nil
1465 (load "gnus-sum.el" t t t))
1466 (require 'gnus)
1467 (require 'gnus-agent)
1468 (require 'gnus-art)))
1469
1470 ;; MIME stuff.
1471
1472 (defvar gnus-decode-encoded-word-methods
1473 '(mail-decode-encoded-word-string)
1474 "List of methods used to decode encoded words.
1475
1476 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1477 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1478 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1479 whose names match REGEXP.
1480
1481 For example:
1482 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1483 mail-decode-encoded-word-string
1484 (\"chinese\" . rfc1843-decode-string))")
1485
1486 (defvar gnus-decode-encoded-word-methods-cache nil)
1487
1488 (defun gnus-multi-decode-encoded-word-string (string)
1489 "Apply the functions from `gnus-encoded-word-methods' that match."
1490 (unless (and gnus-decode-encoded-word-methods-cache
1491 (eq gnus-newsgroup-name
1492 (car gnus-decode-encoded-word-methods-cache)))
1493 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1494 (mapcar (lambda (x)
1495 (if (symbolp x)
1496 (nconc gnus-decode-encoded-word-methods-cache (list x))
1497 (if (and gnus-newsgroup-name
1498 (string-match (car x) gnus-newsgroup-name))
1499 (nconc gnus-decode-encoded-word-methods-cache
1500 (list (cdr x))))))
1501 gnus-decode-encoded-word-methods))
1502 (let ((xlist gnus-decode-encoded-word-methods-cache))
1503 (pop xlist)
1504 (while xlist
1505 (setq string (funcall (pop xlist) string))))
1506 string)
1507
1508 ;; Subject simplification.
1509
1510 (defun gnus-simplify-whitespace (str)
1511 "Remove excessive whitespace from STR."
1512 ;; Multiple spaces.
1513 (while (string-match "[ \t][ \t]+" str)
1514 (setq str (concat (substring str 0 (match-beginning 0))
1515 " "
1516 (substring str (match-end 0)))))
1517 ;; Leading spaces.
1518 (when (string-match "^[ \t]+" str)
1519 (setq str (substring str (match-end 0))))
1520 ;; Trailing spaces.
1521 (when (string-match "[ \t]+$" str)
1522 (setq str (substring str 0 (match-beginning 0))))
1523 str)
1524
1525 (defun gnus-simplify-all-whitespace (str)
1526 "Remove all whitespace from STR."
1527 (while (string-match "[ \t\n]+" str)
1528 (setq str (replace-match "" nil nil str)))
1529 str)
1530
1531 (defsubst gnus-simplify-subject-re (subject)
1532 "Remove \"Re:\" from subject lines."
1533 (if (string-match message-subject-re-regexp subject)
1534 (substring subject (match-end 0))
1535 subject))
1536
1537 (defun gnus-simplify-subject (subject &optional re-only)
1538 "Remove `Re:' and words in parentheses.
1539 If RE-ONLY is non-nil, strip leading `Re:'s only."
1540 (let ((case-fold-search t)) ;Ignore case.
1541 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1542 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1543 (setq subject (substring subject (match-end 0))))
1544 ;; Remove uninteresting prefixes.
1545 (when (and (not re-only)
1546 gnus-simplify-ignored-prefixes
1547 (string-match gnus-simplify-ignored-prefixes subject))
1548 (setq subject (substring subject (match-end 0))))
1549 ;; Remove words in parentheses from end.
1550 (unless re-only
1551 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1552 (setq subject (substring subject 0 (match-beginning 0)))))
1553 ;; Return subject string.
1554 subject))
1555
1556 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1557 ;; all whitespace.
1558 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1559 (goto-char (point-min))
1560 (while (re-search-forward regexp nil t)
1561 (replace-match (or newtext ""))))
1562
1563 (defun gnus-simplify-buffer-fuzzy ()
1564 "Simplify string in the buffer fuzzily.
1565 The string in the accessible portion of the current buffer is simplified.
1566 It is assumed to be a single-line subject.
1567 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1568 matter is removed. Additional things can be deleted by setting
1569 `gnus-simplify-subject-fuzzy-regexp'."
1570 (let ((case-fold-search t)
1571 (modified-tick))
1572 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1573
1574 (while (not (eq modified-tick (buffer-modified-tick)))
1575 (setq modified-tick (buffer-modified-tick))
1576 (cond
1577 ((listp gnus-simplify-subject-fuzzy-regexp)
1578 (mapcar 'gnus-simplify-buffer-fuzzy-step
1579 gnus-simplify-subject-fuzzy-regexp))
1580 (gnus-simplify-subject-fuzzy-regexp
1581 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1582 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1583 (gnus-simplify-buffer-fuzzy-step
1584 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1585 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1586
1587 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1588 (gnus-simplify-buffer-fuzzy-step " +" " ")
1589 (gnus-simplify-buffer-fuzzy-step " $")
1590 (gnus-simplify-buffer-fuzzy-step "^ +")))
1591
1592 (defun gnus-simplify-subject-fuzzy (subject)
1593 "Simplify a subject string fuzzily.
1594 See `gnus-simplify-buffer-fuzzy' for details."
1595 (save-excursion
1596 (gnus-set-work-buffer)
1597 (let ((case-fold-search t))
1598 ;; Remove uninteresting prefixes.
1599 (when (and gnus-simplify-ignored-prefixes
1600 (string-match gnus-simplify-ignored-prefixes subject))
1601 (setq subject (substring subject (match-end 0))))
1602 (insert subject)
1603 (inline (gnus-simplify-buffer-fuzzy))
1604 (buffer-string))))
1605
1606 (defsubst gnus-simplify-subject-fully (subject)
1607 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1608 (cond
1609 (gnus-simplify-subject-functions
1610 (gnus-map-function gnus-simplify-subject-functions subject))
1611 ((null gnus-summary-gather-subject-limit)
1612 (gnus-simplify-subject-re subject))
1613 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1614 (gnus-simplify-subject-fuzzy subject))
1615 ((numberp gnus-summary-gather-subject-limit)
1616 (gnus-limit-string (gnus-simplify-subject-re subject)
1617 gnus-summary-gather-subject-limit))
1618 (t
1619 subject)))
1620
1621 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1622 "Check whether two subjects are equal.
1623 If optional argument SIMPLE-FIRST is t, first argument is already
1624 simplified."
1625 (cond
1626 ((null simple-first)
1627 (equal (gnus-simplify-subject-fully s1)
1628 (gnus-simplify-subject-fully s2)))
1629 (t
1630 (equal s1
1631 (gnus-simplify-subject-fully s2)))))
1632
1633 (defun gnus-summary-bubble-group ()
1634 "Increase the score of the current group.
1635 This is a handy function to add to `gnus-summary-exit-hook' to
1636 increase the score of each group you read."
1637 (gnus-group-add-score gnus-newsgroup-name))
1638
1639 \f
1640 ;;;
1641 ;;; Gnus summary mode
1642 ;;;
1643
1644 (put 'gnus-summary-mode 'mode-class 'special)
1645
1646 (defvar gnus-article-commands-menu)
1647
1648 ;; Non-orthogonal keys
1649
1650 (gnus-define-keys gnus-summary-mode-map
1651 " " gnus-summary-next-page
1652 "\177" gnus-summary-prev-page
1653 [delete] gnus-summary-prev-page
1654 [backspace] gnus-summary-prev-page
1655 "\r" gnus-summary-scroll-up
1656 "\M-\r" gnus-summary-scroll-down
1657 "n" gnus-summary-next-unread-article
1658 "p" gnus-summary-prev-unread-article
1659 "N" gnus-summary-next-article
1660 "P" gnus-summary-prev-article
1661 "\M-\C-n" gnus-summary-next-same-subject
1662 "\M-\C-p" gnus-summary-prev-same-subject
1663 "\M-n" gnus-summary-next-unread-subject
1664 "\M-p" gnus-summary-prev-unread-subject
1665 "." gnus-summary-first-unread-article
1666 "," gnus-summary-best-unread-article
1667 "\M-s" gnus-summary-search-article-forward
1668 "\M-r" gnus-summary-search-article-backward
1669 "<" gnus-summary-beginning-of-article
1670 ">" gnus-summary-end-of-article
1671 "j" gnus-summary-goto-article
1672 "^" gnus-summary-refer-parent-article
1673 "\M-^" gnus-summary-refer-article
1674 "u" gnus-summary-tick-article-forward
1675 "!" gnus-summary-tick-article-forward
1676 "U" gnus-summary-tick-article-backward
1677 "d" gnus-summary-mark-as-read-forward
1678 "D" gnus-summary-mark-as-read-backward
1679 "E" gnus-summary-mark-as-expirable
1680 "\M-u" gnus-summary-clear-mark-forward
1681 "\M-U" gnus-summary-clear-mark-backward
1682 "k" gnus-summary-kill-same-subject-and-select
1683 "\C-k" gnus-summary-kill-same-subject
1684 "\M-\C-k" gnus-summary-kill-thread
1685 "\M-\C-l" gnus-summary-lower-thread
1686 "e" gnus-summary-edit-article
1687 "#" gnus-summary-mark-as-processable
1688 "\M-#" gnus-summary-unmark-as-processable
1689 "\M-\C-t" gnus-summary-toggle-threads
1690 "\M-\C-s" gnus-summary-show-thread
1691 "\M-\C-h" gnus-summary-hide-thread
1692 "\M-\C-f" gnus-summary-next-thread
1693 "\M-\C-b" gnus-summary-prev-thread
1694 [(meta down)] gnus-summary-next-thread
1695 [(meta up)] gnus-summary-prev-thread
1696 "\M-\C-u" gnus-summary-up-thread
1697 "\M-\C-d" gnus-summary-down-thread
1698 "&" gnus-summary-execute-command
1699 "c" gnus-summary-catchup-and-exit
1700 "\C-w" gnus-summary-mark-region-as-read
1701 "\C-t" gnus-summary-toggle-truncation
1702 "?" gnus-summary-mark-as-dormant
1703 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1704 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1705 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1706 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1707 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1708 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1709 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1710 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1711 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1712 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1713 "=" gnus-summary-expand-window
1714 "\C-x\C-s" gnus-summary-reselect-current-group
1715 "\M-g" gnus-summary-rescan-group
1716 "w" gnus-summary-stop-page-breaking
1717 "\C-c\C-r" gnus-summary-caesar-message
1718 "f" gnus-summary-followup
1719 "F" gnus-summary-followup-with-original
1720 "C" gnus-summary-cancel-article
1721 "r" gnus-summary-reply
1722 "R" gnus-summary-reply-with-original
1723 "\C-c\C-f" gnus-summary-mail-forward
1724 "o" gnus-summary-save-article
1725 "\C-o" gnus-summary-save-article-mail
1726 "|" gnus-summary-pipe-output
1727 "\M-k" gnus-summary-edit-local-kill
1728 "\M-K" gnus-summary-edit-global-kill
1729 ;; "V" gnus-version
1730 "\C-c\C-d" gnus-summary-describe-group
1731 "q" gnus-summary-exit
1732 "Q" gnus-summary-exit-no-update
1733 "\C-c\C-i" gnus-info-find-node
1734 gnus-mouse-2 gnus-mouse-pick-article
1735 [follow-link] mouse-face
1736 "m" gnus-summary-mail-other-window
1737 "a" gnus-summary-post-news
1738 "i" gnus-summary-news-other-window
1739 "x" gnus-summary-limit-to-unread
1740 "s" gnus-summary-isearch-article
1741 "t" gnus-summary-toggle-header
1742 "g" gnus-summary-show-article
1743 "l" gnus-summary-goto-last-article
1744 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1745 "\C-d" gnus-summary-enter-digest-group
1746 "\M-\C-d" gnus-summary-read-document
1747 "\M-\C-e" gnus-summary-edit-parameters
1748 "\M-\C-a" gnus-summary-customize-parameters
1749 "\C-c\C-b" gnus-bug
1750 "*" gnus-cache-enter-article
1751 "\M-*" gnus-cache-remove-article
1752 "\M-&" gnus-summary-universal-argument
1753 "\C-l" gnus-recenter
1754 "I" gnus-summary-increase-score
1755 "L" gnus-summary-lower-score
1756 "\M-i" gnus-symbolic-argument
1757 "h" gnus-summary-select-article-buffer
1758
1759 "b" gnus-article-view-part
1760 "\M-t" gnus-summary-toggle-display-buttonized
1761
1762 "V" gnus-summary-score-map
1763 "X" gnus-uu-extract-map
1764 "S" gnus-summary-send-map)
1765
1766 ;; Sort of orthogonal keymap
1767 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1768 "t" gnus-summary-tick-article-forward
1769 "!" gnus-summary-tick-article-forward
1770 "d" gnus-summary-mark-as-read-forward
1771 "r" gnus-summary-mark-as-read-forward
1772 "c" gnus-summary-clear-mark-forward
1773 " " gnus-summary-clear-mark-forward
1774 "e" gnus-summary-mark-as-expirable
1775 "x" gnus-summary-mark-as-expirable
1776 "?" gnus-summary-mark-as-dormant
1777 "b" gnus-summary-set-bookmark
1778 "B" gnus-summary-remove-bookmark
1779 "#" gnus-summary-mark-as-processable
1780 "\M-#" gnus-summary-unmark-as-processable
1781 "S" gnus-summary-limit-include-expunged
1782 "C" gnus-summary-catchup
1783 "H" gnus-summary-catchup-to-here
1784 "h" gnus-summary-catchup-from-here
1785 "\C-c" gnus-summary-catchup-all
1786 "k" gnus-summary-kill-same-subject-and-select
1787 "K" gnus-summary-kill-same-subject
1788 "P" gnus-uu-mark-map)
1789
1790 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1791 "c" gnus-summary-clear-above
1792 "u" gnus-summary-tick-above
1793 "m" gnus-summary-mark-above
1794 "k" gnus-summary-kill-below)
1795
1796 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1797 "/" gnus-summary-limit-to-subject
1798 "n" gnus-summary-limit-to-articles
1799 "w" gnus-summary-pop-limit
1800 "s" gnus-summary-limit-to-subject
1801 "a" gnus-summary-limit-to-author
1802 "u" gnus-summary-limit-to-unread
1803 "m" gnus-summary-limit-to-marks
1804 "M" gnus-summary-limit-exclude-marks
1805 "v" gnus-summary-limit-to-score
1806 "*" gnus-summary-limit-include-cached
1807 "D" gnus-summary-limit-include-dormant
1808 "T" gnus-summary-limit-include-thread
1809 "d" gnus-summary-limit-exclude-dormant
1810 "t" gnus-summary-limit-to-age
1811 "." gnus-summary-limit-to-unseen
1812 "x" gnus-summary-limit-to-extra
1813 "p" gnus-summary-limit-to-display-predicate
1814 "E" gnus-summary-limit-include-expunged
1815 "c" gnus-summary-limit-exclude-childless-dormant
1816 "C" gnus-summary-limit-mark-excluded-as-read
1817 "o" gnus-summary-insert-old-articles
1818 "N" gnus-summary-insert-new-articles)
1819
1820 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1821 "n" gnus-summary-next-unread-article
1822 "p" gnus-summary-prev-unread-article
1823 "N" gnus-summary-next-article
1824 "P" gnus-summary-prev-article
1825 "\C-n" gnus-summary-next-same-subject
1826 "\C-p" gnus-summary-prev-same-subject
1827 "\M-n" gnus-summary-next-unread-subject
1828 "\M-p" gnus-summary-prev-unread-subject
1829 "f" gnus-summary-first-unread-article
1830 "b" gnus-summary-best-unread-article
1831 "j" gnus-summary-goto-article
1832 "g" gnus-summary-goto-subject
1833 "l" gnus-summary-goto-last-article
1834 "o" gnus-summary-pop-article)
1835
1836 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1837 "k" gnus-summary-kill-thread
1838 "l" gnus-summary-lower-thread
1839 "i" gnus-summary-raise-thread
1840 "T" gnus-summary-toggle-threads
1841 "t" gnus-summary-rethread-current
1842 "^" gnus-summary-reparent-thread
1843 "s" gnus-summary-show-thread
1844 "S" gnus-summary-show-all-threads
1845 "h" gnus-summary-hide-thread
1846 "H" gnus-summary-hide-all-threads
1847 "n" gnus-summary-next-thread
1848 "p" gnus-summary-prev-thread
1849 "u" gnus-summary-up-thread
1850 "o" gnus-summary-top-thread
1851 "d" gnus-summary-down-thread
1852 "#" gnus-uu-mark-thread
1853 "\M-#" gnus-uu-unmark-thread)
1854
1855 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1856 "g" gnus-summary-prepare
1857 "c" gnus-summary-insert-cached-articles
1858 "d" gnus-summary-insert-dormant-articles)
1859
1860 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1861 "c" gnus-summary-catchup-and-exit
1862 "C" gnus-summary-catchup-all-and-exit
1863 "E" gnus-summary-exit-no-update
1864 "Q" gnus-summary-exit
1865 "Z" gnus-summary-exit
1866 "n" gnus-summary-catchup-and-goto-next-group
1867 "R" gnus-summary-reselect-current-group
1868 "G" gnus-summary-rescan-group
1869 "N" gnus-summary-next-group
1870 "s" gnus-summary-save-newsrc
1871 "P" gnus-summary-prev-group)
1872
1873 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1874 " " gnus-summary-next-page
1875 "n" gnus-summary-next-page
1876 "\177" gnus-summary-prev-page
1877 [delete] gnus-summary-prev-page
1878 "p" gnus-summary-prev-page
1879 "\r" gnus-summary-scroll-up
1880 "\M-\r" gnus-summary-scroll-down
1881 "<" gnus-summary-beginning-of-article
1882 ">" gnus-summary-end-of-article
1883 "b" gnus-summary-beginning-of-article
1884 "e" gnus-summary-end-of-article
1885 "^" gnus-summary-refer-parent-article
1886 "r" gnus-summary-refer-parent-article
1887 "D" gnus-summary-enter-digest-group
1888 "R" gnus-summary-refer-references
1889 "T" gnus-summary-refer-thread
1890 "g" gnus-summary-show-article
1891 "s" gnus-summary-isearch-article
1892 "P" gnus-summary-print-article
1893 "M" gnus-mailing-list-insinuate
1894 "t" gnus-article-babel)
1895
1896 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1897 "b" gnus-article-add-buttons
1898 "B" gnus-article-add-buttons-to-head
1899 "o" gnus-article-treat-overstrike
1900 "e" gnus-article-emphasize
1901 "w" gnus-article-fill-cited-article
1902 "Q" gnus-article-fill-long-lines
1903 "C" gnus-article-capitalize-sentences
1904 "c" gnus-article-remove-cr
1905 "q" gnus-article-de-quoted-unreadable
1906 "6" gnus-article-de-base64-unreadable
1907 "Z" gnus-article-decode-HZ
1908 "h" gnus-article-wash-html
1909 "u" gnus-article-unsplit-urls
1910 "s" gnus-summary-force-verify-and-decrypt
1911 "f" gnus-article-display-x-face
1912 "l" gnus-summary-stop-page-breaking
1913 "r" gnus-summary-caesar-message
1914 "m" gnus-summary-morse-message
1915 "t" gnus-summary-toggle-header
1916 "g" gnus-treat-smiley
1917 "v" gnus-summary-verbose-headers
1918 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1919 "p" gnus-article-verify-x-pgp-sig
1920 "d" gnus-article-treat-dumbquotes)
1921
1922 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1923 ;; mnemonic: deuglif*Y*
1924 "u" gnus-article-outlook-unwrap-lines
1925 "a" gnus-article-outlook-repair-attribution
1926 "c" gnus-article-outlook-rearrange-citation
1927 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1928
1929 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1930 "a" gnus-article-hide
1931 "h" gnus-article-hide-headers
1932 "b" gnus-article-hide-boring-headers
1933 "s" gnus-article-hide-signature
1934 "c" gnus-article-hide-citation
1935 "C" gnus-article-hide-citation-in-followups
1936 "l" gnus-article-hide-list-identifiers
1937 "B" gnus-article-strip-banner
1938 "P" gnus-article-hide-pem
1939 "\C-c" gnus-article-hide-citation-maybe)
1940
1941 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1942 "a" gnus-article-highlight
1943 "h" gnus-article-highlight-headers
1944 "c" gnus-article-highlight-citation
1945 "s" gnus-article-highlight-signature)
1946
1947 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1948 "f" gnus-article-treat-fold-headers
1949 "u" gnus-article-treat-unfold-headers
1950 "n" gnus-article-treat-fold-newsgroups)
1951
1952 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1953 "x" gnus-article-display-x-face
1954 "d" gnus-article-display-face
1955 "s" gnus-treat-smiley
1956 "D" gnus-article-remove-images
1957 "f" gnus-treat-from-picon
1958 "m" gnus-treat-mail-picon
1959 "n" gnus-treat-newsgroups-picon)
1960
1961 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1962 "w" gnus-article-decode-mime-words
1963 "c" gnus-article-decode-charset
1964 "v" gnus-mime-view-all-parts
1965 "b" gnus-article-view-part)
1966
1967 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1968 "z" gnus-article-date-ut
1969 "u" gnus-article-date-ut
1970 "l" gnus-article-date-local
1971 "p" gnus-article-date-english
1972 "e" gnus-article-date-lapsed
1973 "o" gnus-article-date-original
1974 "i" gnus-article-date-iso8601
1975 "s" gnus-article-date-user)
1976
1977 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1978 "t" gnus-article-remove-trailing-blank-lines
1979 "l" gnus-article-strip-leading-blank-lines
1980 "m" gnus-article-strip-multiple-blank-lines
1981 "a" gnus-article-strip-blank-lines
1982 "A" gnus-article-strip-all-blank-lines
1983 "s" gnus-article-strip-leading-space
1984 "e" gnus-article-strip-trailing-space
1985 "w" gnus-article-remove-leading-whitespace)
1986
1987 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1988 "v" gnus-version
1989 "f" gnus-summary-fetch-faq
1990 "d" gnus-summary-describe-group
1991 "h" gnus-summary-describe-briefly
1992 "i" gnus-info-find-node
1993 "c" gnus-group-fetch-charter
1994 "C" gnus-group-fetch-control)
1995
1996 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1997 "e" gnus-summary-expire-articles
1998 "\M-\C-e" gnus-summary-expire-articles-now
1999 "\177" gnus-summary-delete-article
2000 [delete] gnus-summary-delete-article
2001 [backspace] gnus-summary-delete-article
2002 "m" gnus-summary-move-article
2003 "r" gnus-summary-respool-article
2004 "w" gnus-summary-edit-article
2005 "c" gnus-summary-copy-article
2006 "B" gnus-summary-crosspost-article
2007 "q" gnus-summary-respool-query
2008 "t" gnus-summary-respool-trace
2009 "i" gnus-summary-import-article
2010 "I" gnus-summary-create-article
2011 "p" gnus-summary-article-posted-p)
2012
2013 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2014 "o" gnus-summary-save-article
2015 "m" gnus-summary-save-article-mail
2016 "F" gnus-summary-write-article-file
2017 "r" gnus-summary-save-article-rmail
2018 "f" gnus-summary-save-article-file
2019 "b" gnus-summary-save-article-body-file
2020 "B" gnus-summary-write-article-body-file
2021 "h" gnus-summary-save-article-folder
2022 "v" gnus-summary-save-article-vm
2023 "p" gnus-summary-pipe-output
2024 "P" gnus-summary-muttprint
2025 "s" gnus-soup-add-article)
2026
2027 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2028 "b" gnus-summary-display-buttonized
2029 "m" gnus-summary-repair-multipart
2030 "v" gnus-article-view-part
2031 "o" gnus-article-save-part
2032 "c" gnus-article-copy-part
2033 "C" gnus-article-view-part-as-charset
2034 "e" gnus-article-view-part-externally
2035 "E" gnus-article-encrypt-body
2036 "i" gnus-article-inline-part
2037 "|" gnus-article-pipe-part)
2038
2039 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2040 "p" gnus-summary-mark-as-processable
2041 "u" gnus-summary-unmark-as-processable
2042 "U" gnus-summary-unmark-all-processable
2043 "v" gnus-uu-mark-over
2044 "s" gnus-uu-mark-series
2045 "r" gnus-uu-mark-region
2046 "g" gnus-uu-unmark-region
2047 "R" gnus-uu-mark-by-regexp
2048 "G" gnus-uu-unmark-by-regexp
2049 "t" gnus-uu-mark-thread
2050 "T" gnus-uu-unmark-thread
2051 "a" gnus-uu-mark-all
2052 "b" gnus-uu-mark-buffer
2053 "S" gnus-uu-mark-sparse
2054 "k" gnus-summary-kill-process-mark
2055 "y" gnus-summary-yank-process-mark
2056 "w" gnus-summary-save-process-mark
2057 "i" gnus-uu-invert-processable)
2058
2059 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2060 ;;"x" gnus-uu-extract-any
2061 "m" gnus-summary-save-parts
2062 "u" gnus-uu-decode-uu
2063 "U" gnus-uu-decode-uu-and-save
2064 "s" gnus-uu-decode-unshar
2065 "S" gnus-uu-decode-unshar-and-save
2066 "o" gnus-uu-decode-save
2067 "O" gnus-uu-decode-save
2068 "b" gnus-uu-decode-binhex
2069 "B" gnus-uu-decode-binhex
2070 "p" gnus-uu-decode-postscript
2071 "P" gnus-uu-decode-postscript-and-save)
2072
2073 (gnus-define-keys
2074 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2075 "u" gnus-uu-decode-uu-view
2076 "U" gnus-uu-decode-uu-and-save-view
2077 "s" gnus-uu-decode-unshar-view
2078 "S" gnus-uu-decode-unshar-and-save-view
2079 "o" gnus-uu-decode-save-view
2080 "O" gnus-uu-decode-save-view
2081 "b" gnus-uu-decode-binhex-view
2082 "B" gnus-uu-decode-binhex-view
2083 "p" gnus-uu-decode-postscript-view
2084 "P" gnus-uu-decode-postscript-and-save-view)
2085
2086 (defvar gnus-article-post-menu nil)
2087
2088 (defconst gnus-summary-menu-maxlen 20)
2089
2090 (defun gnus-summary-menu-split (menu)
2091 ;; If we have lots of elements, divide them into groups of 20
2092 ;; and make a pane (or submenu) for each one.
2093 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2094 (let ((menu menu) sublists next
2095 (i 1))
2096 (while menu
2097 ;; Pull off the next gnus-summary-menu-maxlen elements
2098 ;; and make them the next element of sublist.
2099 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2100 (if next
2101 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2102 nil))
2103 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2104 (aref (car (last menu)) 0)) menu)
2105 sublists))
2106 (setq i (1+ i))
2107 (setq menu next))
2108 (nreverse sublists))
2109 ;; Few elements--put them all in one pane.
2110 menu))
2111
2112 (defun gnus-summary-make-menu-bar ()
2113 (gnus-turn-off-edit-menu 'summary)
2114
2115 (unless (boundp 'gnus-summary-misc-menu)
2116
2117 (easy-menu-define
2118 gnus-summary-kill-menu gnus-summary-mode-map ""
2119 (cons
2120 "Score"
2121 (nconc
2122 (list
2123 ["Customize" gnus-score-customize t])
2124 (gnus-make-score-map 'increase)
2125 (gnus-make-score-map 'lower)
2126 '(("Mark"
2127 ["Kill below" gnus-summary-kill-below t]
2128 ["Mark above" gnus-summary-mark-above t]
2129 ["Tick above" gnus-summary-tick-above t]
2130 ["Clear above" gnus-summary-clear-above t])
2131 ["Current score" gnus-summary-current-score t]
2132 ["Set score" gnus-summary-set-score t]
2133 ["Switch current score file..." gnus-score-change-score-file t]
2134 ["Set mark below..." gnus-score-set-mark-below t]
2135 ["Set expunge below..." gnus-score-set-expunge-below t]
2136 ["Edit current score file" gnus-score-edit-current-scores t]
2137 ["Edit score file..." gnus-score-edit-file t]
2138 ["Trace score" gnus-score-find-trace t]
2139 ["Find words" gnus-score-find-favourite-words t]
2140 ["Rescore buffer" gnus-summary-rescore t]
2141 ["Increase score..." gnus-summary-increase-score t]
2142 ["Lower score..." gnus-summary-lower-score t]))))
2143
2144 ;; Define both the Article menu in the summary buffer and the
2145 ;; equivalent Commands menu in the article buffer here for
2146 ;; consistency.
2147 (let ((innards
2148 `(("Hide"
2149 ["All" gnus-article-hide t]
2150 ["Headers" gnus-article-hide-headers t]
2151 ["Signature" gnus-article-hide-signature t]
2152 ["Citation" gnus-article-hide-citation t]
2153 ["List identifiers" gnus-article-hide-list-identifiers t]
2154 ["Banner" gnus-article-strip-banner t]
2155 ["Boring headers" gnus-article-hide-boring-headers t])
2156 ("Highlight"
2157 ["All" gnus-article-highlight t]
2158 ["Headers" gnus-article-highlight-headers t]
2159 ["Signature" gnus-article-highlight-signature t]
2160 ["Citation" gnus-article-highlight-citation t])
2161 ("MIME"
2162 ["Words" gnus-article-decode-mime-words t]
2163 ["Charset" gnus-article-decode-charset t]
2164 ["QP" gnus-article-de-quoted-unreadable t]
2165 ["Base64" gnus-article-de-base64-unreadable t]
2166 ["View MIME buttons" gnus-summary-display-buttonized t]
2167 ["View all" gnus-mime-view-all-parts t]
2168 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2169 ["Encrypt body" gnus-article-encrypt-body
2170 :active (not (gnus-group-read-only-p))
2171 ,@(if (featurep 'xemacs) nil
2172 '(:help "Encrypt the message body on disk"))]
2173 ["Extract all parts..." gnus-summary-save-parts t]
2174 ("Multipart"
2175 ["Repair multipart" gnus-summary-repair-multipart t]
2176 ["Pipe part..." gnus-article-pipe-part t]
2177 ["Inline part" gnus-article-inline-part t]
2178 ["Encrypt body" gnus-article-encrypt-body
2179 :active (not (gnus-group-read-only-p))
2180 ,@(if (featurep 'xemacs) nil
2181 '(:help "Encrypt the message body on disk"))]
2182 ["View part externally" gnus-article-view-part-externally t]
2183 ["View part with charset..." gnus-article-view-part-as-charset t]
2184 ["Copy part" gnus-article-copy-part t]
2185 ["Save part..." gnus-article-save-part t]
2186 ["View part" gnus-article-view-part t]))
2187 ("Date"
2188 ["Local" gnus-article-date-local t]
2189 ["ISO8601" gnus-article-date-iso8601 t]
2190 ["UT" gnus-article-date-ut t]
2191 ["Original" gnus-article-date-original t]
2192 ["Lapsed" gnus-article-date-lapsed t]
2193 ["User-defined" gnus-article-date-user t])
2194 ("Display"
2195 ["Remove images" gnus-article-remove-images t]
2196 ["Toggle smiley" gnus-treat-smiley t]
2197 ["Show X-Face" gnus-article-display-x-face t]
2198 ["Show picons in From" gnus-treat-from-picon t]
2199 ["Show picons in mail headers" gnus-treat-mail-picon t]
2200 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2201 ("View as different encoding"
2202 ,@(gnus-summary-menu-split
2203 (mapcar
2204 (lambda (cs)
2205 ;; Since easymenu under Emacs doesn't allow
2206 ;; lambda forms for menu commands, we should
2207 ;; provide intern'ed function symbols.
2208 (let ((command (intern (format "\
2209 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2210 (fset command
2211 `(lambda ()
2212 (interactive)
2213 (let ((gnus-summary-show-article-charset-alist
2214 '((1 . ,cs))))
2215 (gnus-summary-show-article 1))))
2216 `[,(symbol-name cs) ,command t]))
2217 (sort (if (fboundp 'coding-system-list)
2218 (coding-system-list)
2219 (mapcar 'car mm-mime-mule-charset-alist))
2220 'string<)))))
2221 ("Washing"
2222 ("Remove Blanks"
2223 ["Leading" gnus-article-strip-leading-blank-lines t]
2224 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2225 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2226 ["All of the above" gnus-article-strip-blank-lines t]
2227 ["All" gnus-article-strip-all-blank-lines t]
2228 ["Leading space" gnus-article-strip-leading-space t]
2229 ["Trailing space" gnus-article-strip-trailing-space t]
2230 ["Leading space in headers"
2231 gnus-article-remove-leading-whitespace t])
2232 ["Overstrike" gnus-article-treat-overstrike t]
2233 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2234 ["Emphasis" gnus-article-emphasize t]
2235 ["Word wrap" gnus-article-fill-cited-article t]
2236 ["Fill long lines" gnus-article-fill-long-lines t]
2237 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2238 ["Remove CR" gnus-article-remove-cr t]
2239 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2240 ["Base64" gnus-article-de-base64-unreadable t]
2241 ["Rot 13" gnus-summary-caesar-message
2242 ,@(if (featurep 'xemacs) '(t)
2243 '(:help "\"Caesar rotate\" article by 13"))]
2244 ["Morse decode" gnus-summary-morse-message t]
2245 ["Unix pipe..." gnus-summary-pipe-message t]
2246 ["Add buttons" gnus-article-add-buttons t]
2247 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2248 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2249 ["Verbose header" gnus-summary-verbose-headers t]
2250 ["Toggle header" gnus-summary-toggle-header t]
2251 ["Unfold headers" gnus-article-treat-unfold-headers t]
2252 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2253 ["Html" gnus-article-wash-html t]
2254 ["Unsplit URLs" gnus-article-unsplit-urls t]
2255 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2256 ["Decode HZ" gnus-article-decode-HZ t]
2257 ("(Outlook) Deuglify"
2258 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2259 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2260 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2261 ["Full (Outlook) deuglify"
2262 gnus-article-outlook-deuglify-article t])
2263 )
2264 ("Output"
2265 ["Save in default format..." gnus-summary-save-article
2266 ,@(if (featurep 'xemacs) '(t)
2267 '(:help "Save article using default method"))]
2268 ["Save in file..." gnus-summary-save-article-file
2269 ,@(if (featurep 'xemacs) '(t)
2270 '(:help "Save article in file"))]
2271 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2272 ["Save in MH folder..." gnus-summary-save-article-folder t]
2273 ["Save in VM folder..." gnus-summary-save-article-vm t]
2274 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2275 ["Save body in file..." gnus-summary-save-article-body-file t]
2276 ["Pipe through a filter..." gnus-summary-pipe-output t]
2277 ["Add to SOUP packet" gnus-soup-add-article t]
2278 ["Print with Muttprint..." gnus-summary-muttprint t]
2279 ["Print" gnus-summary-print-article
2280 ,@(if (featurep 'xemacs) '(t)
2281 '(:help "Generate and print a PostScript image"))])
2282 ("Copy, move,... (Backend)"
2283 ,@(if (featurep 'xemacs) nil
2284 '(:help "Copying, moving, expiring articles..."))
2285 ["Respool article..." gnus-summary-respool-article t]
2286 ["Move article..." gnus-summary-move-article
2287 (gnus-check-backend-function
2288 'request-move-article gnus-newsgroup-name)]
2289 ["Copy article..." gnus-summary-copy-article t]
2290 ["Crosspost article..." gnus-summary-crosspost-article
2291 (gnus-check-backend-function
2292 'request-replace-article gnus-newsgroup-name)]
2293 ["Import file..." gnus-summary-import-article
2294 (gnus-check-backend-function
2295 'request-accept-article gnus-newsgroup-name)]
2296 ["Create article..." gnus-summary-create-article
2297 (gnus-check-backend-function
2298 'request-accept-article gnus-newsgroup-name)]
2299 ["Check if posted" gnus-summary-article-posted-p t]
2300 ["Edit article" gnus-summary-edit-article
2301 (not (gnus-group-read-only-p))]
2302 ["Delete article" gnus-summary-delete-article
2303 (gnus-check-backend-function
2304 'request-expire-articles gnus-newsgroup-name)]
2305 ["Query respool" gnus-summary-respool-query t]
2306 ["Trace respool" gnus-summary-respool-trace t]
2307 ["Delete expirable articles" gnus-summary-expire-articles-now
2308 (gnus-check-backend-function
2309 'request-expire-articles gnus-newsgroup-name)])
2310 ("Extract"
2311 ["Uudecode" gnus-uu-decode-uu
2312 ,@(if (featurep 'xemacs) '(t)
2313 '(:help "Decode uuencoded article(s)"))]
2314 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2315 ["Unshar" gnus-uu-decode-unshar t]
2316 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2317 ["Save" gnus-uu-decode-save t]
2318 ["Binhex" gnus-uu-decode-binhex t]
2319 ["Postscript" gnus-uu-decode-postscript t]
2320 ["All MIME parts" gnus-summary-save-parts t])
2321 ("Cache"
2322 ["Enter article" gnus-cache-enter-article t]
2323 ["Remove article" gnus-cache-remove-article t])
2324 ["Translate" gnus-article-babel t]
2325 ["Select article buffer" gnus-summary-select-article-buffer t]
2326 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2327 ["Isearch article..." gnus-summary-isearch-article t]
2328 ["Beginning of the article" gnus-summary-beginning-of-article t]
2329 ["End of the article" gnus-summary-end-of-article t]
2330 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2331 ["Fetch referenced articles" gnus-summary-refer-references t]
2332 ["Fetch current thread" gnus-summary-refer-thread t]
2333 ["Fetch article with id..." gnus-summary-refer-article t]
2334 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2335 ["Redisplay" gnus-summary-show-article t]
2336 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2337 (easy-menu-define
2338 gnus-summary-article-menu gnus-summary-mode-map ""
2339 (cons "Article" innards))
2340
2341 (if (not (keymapp gnus-summary-article-menu))
2342 (easy-menu-define
2343 gnus-article-commands-menu gnus-article-mode-map ""
2344 (cons "Commands" innards))
2345 ;; in Emacs, don't share menu.
2346 (setq gnus-article-commands-menu
2347 (copy-keymap gnus-summary-article-menu))
2348 (define-key gnus-article-mode-map [menu-bar commands]
2349 (cons "Commands" gnus-article-commands-menu))))
2350
2351 (easy-menu-define
2352 gnus-summary-thread-menu gnus-summary-mode-map ""
2353 '("Threads"
2354 ["Find all messages in thread" gnus-summary-refer-thread t]
2355 ["Toggle threading" gnus-summary-toggle-threads t]
2356 ["Hide threads" gnus-summary-hide-all-threads t]
2357 ["Show threads" gnus-summary-show-all-threads t]
2358 ["Hide thread" gnus-summary-hide-thread t]
2359 ["Show thread" gnus-summary-show-thread t]
2360 ["Go to next thread" gnus-summary-next-thread t]
2361 ["Go to previous thread" gnus-summary-prev-thread t]
2362 ["Go down thread" gnus-summary-down-thread t]
2363 ["Go up thread" gnus-summary-up-thread t]
2364 ["Top of thread" gnus-summary-top-thread t]
2365 ["Mark thread as read" gnus-summary-kill-thread t]
2366 ["Lower thread score" gnus-summary-lower-thread t]
2367 ["Raise thread score" gnus-summary-raise-thread t]
2368 ["Rethread current" gnus-summary-rethread-current t]))
2369
2370 (easy-menu-define
2371 gnus-summary-post-menu gnus-summary-mode-map ""
2372 `("Post"
2373 ["Send a message (mail or news)" gnus-summary-post-news
2374 ,@(if (featurep 'xemacs) '(t)
2375 '(:help "Compose a new message (mail or news)"))]
2376 ["Followup" gnus-summary-followup
2377 ,@(if (featurep 'xemacs) '(t)
2378 '(:help "Post followup to this article"))]
2379 ["Followup and yank" gnus-summary-followup-with-original
2380 ,@(if (featurep 'xemacs) '(t)
2381 '(:help "Post followup to this article, quoting its contents"))]
2382 ["Supersede article" gnus-summary-supersede-article t]
2383 ["Cancel article" gnus-summary-cancel-article
2384 ,@(if (featurep 'xemacs) '(t)
2385 '(:help "Cancel an article you posted"))]
2386 ["Reply" gnus-summary-reply t]
2387 ["Reply and yank" gnus-summary-reply-with-original t]
2388 ["Wide reply" gnus-summary-wide-reply t]
2389 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2390 ,@(if (featurep 'xemacs) '(t)
2391 '(:help "Mail a reply, quoting this article"))]
2392 ["Very wide reply" gnus-summary-very-wide-reply t]
2393 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2394 ,@(if (featurep 'xemacs) '(t)
2395 '(:help "Mail a very wide reply, quoting this article"))]
2396 ["Mail forward" gnus-summary-mail-forward t]
2397 ["Post forward" gnus-summary-post-forward t]
2398 ["Digest and mail" gnus-uu-digest-mail-forward t]
2399 ["Digest and post" gnus-uu-digest-post-forward t]
2400 ["Resend message" gnus-summary-resend-message t]
2401 ["Resend message edit" gnus-summary-resend-message-edit t]
2402 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2403 ["Send a mail" gnus-summary-mail-other-window t]
2404 ["Create a local message" gnus-summary-news-other-window t]
2405 ["Uuencode and post" gnus-uu-post-news
2406 ,@(if (featurep 'xemacs) '(t)
2407 '(:help "Post a uuencoded article"))]
2408 ["Followup via news" gnus-summary-followup-to-mail t]
2409 ["Followup via news and yank"
2410 gnus-summary-followup-to-mail-with-original t]
2411 ["Strip signature on reply"
2412 (lambda ()
2413 (interactive)
2414 (if (not (memq message-cite-function
2415 '(message-cite-original-without-signature
2416 message-cite-original)))
2417 ;; Stupid workaround for XEmacs not honoring :visible.
2418 (message "Can't toggle this value of `message-cite-function'")
2419 (setq message-cite-function
2420 (if (eq message-cite-function
2421 'message-cite-original-without-signature)
2422 'message-cite-original
2423 'message-cite-original-without-signature))))
2424 ;; XEmacs barfs on :visible.
2425 ,@(if (featurep 'xemacs) nil
2426 '(:visible (memq message-cite-function
2427 '(message-cite-original-without-signature
2428 message-cite-original))))
2429 :style toggle
2430 :selected (eq message-cite-function
2431 'message-cite-original-without-signature)
2432 ,@(if (featurep 'xemacs) nil
2433 '(:help "Strip signature from cited article when replying."))]
2434 ;;("Draft"
2435 ;;["Send" gnus-summary-send-draft t]
2436 ;;["Send bounced" gnus-resend-bounced-mail t])
2437 ))
2438
2439 (cond
2440 ((not (keymapp gnus-summary-post-menu))
2441 (setq gnus-article-post-menu gnus-summary-post-menu))
2442 ((not gnus-article-post-menu)
2443 ;; Don't share post menu.
2444 (setq gnus-article-post-menu
2445 (copy-keymap gnus-summary-post-menu))))
2446 (define-key gnus-article-mode-map [menu-bar post]
2447 (cons "Post" gnus-article-post-menu))
2448
2449 (easy-menu-define
2450 gnus-summary-misc-menu gnus-summary-mode-map ""
2451 `("Gnus"
2452 ("Mark Read"
2453 ["Mark as read" gnus-summary-mark-as-read-forward t]
2454 ["Mark same subject and select"
2455 gnus-summary-kill-same-subject-and-select t]
2456 ["Mark same subject" gnus-summary-kill-same-subject t]
2457 ["Catchup" gnus-summary-catchup
2458 ,@(if (featurep 'xemacs) '(t)
2459 '(:help "Mark unread articles in this group as read"))]
2460 ["Catchup all" gnus-summary-catchup-all t]
2461 ["Catchup to here" gnus-summary-catchup-to-here t]
2462 ["Catchup from here" gnus-summary-catchup-from-here t]
2463 ["Catchup region" gnus-summary-mark-region-as-read
2464 (gnus-mark-active-p)]
2465 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2466 ("Mark Various"
2467 ["Tick" gnus-summary-tick-article-forward t]
2468 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2469 ["Remove marks" gnus-summary-clear-mark-forward t]
2470 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2471 ["Set bookmark" gnus-summary-set-bookmark t]
2472 ["Remove bookmark" gnus-summary-remove-bookmark t])
2473 ("Limit to"
2474 ["Marks..." gnus-summary-limit-to-marks t]
2475 ["Subject..." gnus-summary-limit-to-subject t]
2476 ["Author..." gnus-summary-limit-to-author t]
2477 ["Age..." gnus-summary-limit-to-age t]
2478 ["Extra..." gnus-summary-limit-to-extra t]
2479 ["Score..." gnus-summary-limit-to-score t]
2480 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2481 ["Unread" gnus-summary-limit-to-unread t]
2482 ["Unseen" gnus-summary-limit-to-unseen t]
2483 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2484 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2485 ["Pop limit" gnus-summary-pop-limit t]
2486 ["Show dormant" gnus-summary-limit-include-dormant t]
2487 ["Hide childless dormant"
2488 gnus-summary-limit-exclude-childless-dormant t]
2489 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2490 ["Hide marked" gnus-summary-limit-exclude-marks t]
2491 ["Show expunged" gnus-summary-limit-include-expunged t])
2492 ("Process Mark"
2493 ["Set mark" gnus-summary-mark-as-processable t]
2494 ["Remove mark" gnus-summary-unmark-as-processable t]
2495 ["Remove all marks" gnus-summary-unmark-all-processable t]
2496 ["Mark above" gnus-uu-mark-over t]
2497 ["Mark series" gnus-uu-mark-series t]
2498 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2499 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2500 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2501 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2502 ["Mark all" gnus-uu-mark-all t]
2503 ["Mark buffer" gnus-uu-mark-buffer t]
2504 ["Mark sparse" gnus-uu-mark-sparse t]
2505 ["Mark thread" gnus-uu-mark-thread t]
2506 ["Unmark thread" gnus-uu-unmark-thread t]
2507 ("Process Mark Sets"
2508 ["Kill" gnus-summary-kill-process-mark t]
2509 ["Yank" gnus-summary-yank-process-mark
2510 gnus-newsgroup-process-stack]
2511 ["Save" gnus-summary-save-process-mark t]
2512 ["Run command on marked..." gnus-summary-universal-argument t]))
2513 ("Scroll article"
2514 ["Page forward" gnus-summary-next-page
2515 ,@(if (featurep 'xemacs) '(t)
2516 '(:help "Show next page of article"))]
2517 ["Page backward" gnus-summary-prev-page
2518 ,@(if (featurep 'xemacs) '(t)
2519 '(:help "Show previous page of article"))]
2520 ["Line forward" gnus-summary-scroll-up t])
2521 ("Move"
2522 ["Next unread article" gnus-summary-next-unread-article t]
2523 ["Previous unread article" gnus-summary-prev-unread-article t]
2524 ["Next article" gnus-summary-next-article t]
2525 ["Previous article" gnus-summary-prev-article t]
2526 ["Next unread subject" gnus-summary-next-unread-subject t]
2527 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2528 ["Next article same subject" gnus-summary-next-same-subject t]
2529 ["Previous article same subject" gnus-summary-prev-same-subject t]
2530 ["First unread article" gnus-summary-first-unread-article t]
2531 ["Best unread article" gnus-summary-best-unread-article t]
2532 ["Go to subject number..." gnus-summary-goto-subject t]
2533 ["Go to article number..." gnus-summary-goto-article t]
2534 ["Go to the last article" gnus-summary-goto-last-article t]
2535 ["Pop article off history" gnus-summary-pop-article t])
2536 ("Sort"
2537 ["Sort by number" gnus-summary-sort-by-number t]
2538 ["Sort by author" gnus-summary-sort-by-author t]
2539 ["Sort by subject" gnus-summary-sort-by-subject t]
2540 ["Sort by date" gnus-summary-sort-by-date t]
2541 ["Sort by score" gnus-summary-sort-by-score t]
2542 ["Sort by lines" gnus-summary-sort-by-lines t]
2543 ["Sort by characters" gnus-summary-sort-by-chars t]
2544 ["Randomize" gnus-summary-sort-by-random t]
2545 ["Original sort" gnus-summary-sort-by-original t])
2546 ("Help"
2547 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2548 ["Describe group" gnus-summary-describe-group t]
2549 ["Fetch charter" gnus-group-fetch-charter
2550 ,@(if (featurep 'xemacs) nil
2551 '(:help "Display the charter of the current group"))]
2552 ["Fetch control message" gnus-group-fetch-control
2553 ,@(if (featurep 'xemacs) nil
2554 '(:help "Display the archived control message for the current group"))]
2555 ["Read manual" gnus-info-find-node t])
2556 ("Modes"
2557 ["Pick and read" gnus-pick-mode t]
2558 ["Binary" gnus-binary-mode t])
2559 ("Regeneration"
2560 ["Regenerate" gnus-summary-prepare t]
2561 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2562 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2563 ["Toggle threading" gnus-summary-toggle-threads t])
2564 ["See old articles" gnus-summary-insert-old-articles t]
2565 ["See new articles" gnus-summary-insert-new-articles t]
2566 ["Filter articles..." gnus-summary-execute-command t]
2567 ["Run command on articles..." gnus-summary-universal-argument t]
2568 ["Search articles forward..." gnus-summary-search-article-forward t]
2569 ["Search articles backward..." gnus-summary-search-article-backward t]
2570 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2571 ["Expand window" gnus-summary-expand-window t]
2572 ["Expire expirable articles" gnus-summary-expire-articles
2573 (gnus-check-backend-function
2574 'request-expire-articles gnus-newsgroup-name)]
2575 ["Edit local kill file" gnus-summary-edit-local-kill t]
2576 ["Edit main kill file" gnus-summary-edit-global-kill t]
2577 ["Edit group parameters" gnus-summary-edit-parameters t]
2578 ["Customize group parameters" gnus-summary-customize-parameters t]
2579 ["Send a bug report" gnus-bug t]
2580 ("Exit"
2581 ["Catchup and exit" gnus-summary-catchup-and-exit
2582 ,@(if (featurep 'xemacs) '(t)
2583 '(:help "Mark unread articles in this group as read, then exit"))]
2584 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2585 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2586 ["Exit group" gnus-summary-exit
2587 ,@(if (featurep 'xemacs) '(t)
2588 '(:help "Exit current group, return to group selection mode"))]
2589 ["Exit group without updating" gnus-summary-exit-no-update t]
2590 ["Exit and goto next group" gnus-summary-next-group t]
2591 ["Exit and goto prev group" gnus-summary-prev-group t]
2592 ["Reselect group" gnus-summary-reselect-current-group t]
2593 ["Rescan group" gnus-summary-rescan-group t]
2594 ["Update dribble" gnus-summary-save-newsrc t])))
2595
2596 (gnus-run-hooks 'gnus-summary-menu-hook)))
2597
2598 (defvar gnus-summary-tool-bar-map nil)
2599
2600 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2601 ;; affect _new_ message buffers. We might add a function that walks thru all
2602 ;; summary-mode buffers and force the update.
2603 (defun gnus-summary-tool-bar-update (&optional symbol value)
2604 "Update summary mode toolbar.
2605 Setter function for custom variables."
2606 (setq-default gnus-summary-tool-bar-map nil)
2607 (when symbol
2608 ;; When used as ":set" function:
2609 (set-default symbol value))
2610 (when (gnus-buffer-live-p gnus-summary-buffer)
2611 (with-current-buffer gnus-summary-buffer
2612 (gnus-summary-make-tool-bar))))
2613
2614 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2615 'gnus-summary-tool-bar-gnome
2616 'gnus-summary-tool-bar-retro)
2617 "Specifies the Gnus summary tool bar.
2618
2619 It can be either a list or a symbol refering to a list. See
2620 `gmm-tool-bar-from-list' for the format of the list. The
2621 default key map is `gnus-summary-mode-map'.
2622
2623 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2624 `gnus-summary-tool-bar-retro'."
2625 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2626 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2627 (repeat :tag "User defined list" gmm-tool-bar-item)
2628 (symbol))
2629 :version "22.1" ;; Gnus 5.10.9
2630 :initialize 'custom-initialize-default
2631 :set 'gnus-summary-tool-bar-update
2632 :group 'gnus-summary)
2633
2634 (defcustom gnus-summary-tool-bar-gnome
2635 '((gnus-summary-post-news "mail/compose" nil)
2636 (gnus-summary-insert-new-articles "mail/inbox" nil
2637 :visible (or (not gnus-agent)
2638 gnus-plugged))
2639 (gnus-summary-reply-with-original "mail/reply")
2640 (gnus-summary-reply "mail/reply" nil :visible nil)
2641 (gnus-summary-followup-with-original "mail/reply-all")
2642 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2643 (gnus-summary-mail-forward "mail/forward")
2644 (gnus-summary-save-article "mail/save")
2645 (gnus-summary-search-article-forward "search" nil :visible nil)
2646 (gnus-summary-print-article "print")
2647 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2648 ;; Some new commands that may need more suitable icons:
2649 (gnus-summary-save-newsrc "save" nil :visible nil)
2650 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2651 (gnus-summary-prev-article "left-arrow")
2652 (gnus-summary-next-article "right-arrow")
2653 (gnus-summary-next-page "next-page")
2654 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2655 ;;
2656 ;; Maybe some sort-by-... could be added:
2657 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2658 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2659 (gnus-summary-mark-as-expirable
2660 "delete" nil
2661 :visible (gnus-check-backend-function 'request-expire-articles
2662 gnus-newsgroup-name))
2663 (gnus-summary-mark-as-spam
2664 "mail/spam" t
2665 :visible (and (fboundp 'spam-group-ham-contents-p)
2666 (spam-group-ham-contents-p gnus-newsgroup-name))
2667 :help "Mark as spam")
2668 (gnus-summary-mark-as-read-forward
2669 "mail/not-spam" nil
2670 :visible (and (fboundp 'spam-group-spam-contents-p)
2671 (spam-group-spam-contents-p gnus-newsgroup-name)))
2672 ;;
2673 (gnus-summary-exit "exit")
2674 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2675 (gnus-info-find-node "help"))
2676 "List of functions for the summary tool bar (GNOME style).
2677
2678 See `gmm-tool-bar-from-list' for the format of the list."
2679 :type '(repeat gmm-tool-bar-item)
2680 :version "22.1" ;; Gnus 5.10.9
2681 :initialize 'custom-initialize-default
2682 :set 'gnus-summary-tool-bar-update
2683 :group 'gnus-summary)
2684
2685 (defcustom gnus-summary-tool-bar-retro
2686 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2687 (gnus-summary-next-unread-article "gnus/next-ur")
2688 (gnus-summary-post-news "gnus/post")
2689 (gnus-summary-followup-with-original "gnus/fuwo")
2690 (gnus-summary-followup "gnus/followup")
2691 (gnus-summary-reply-with-original "gnus/reply-wo")
2692 (gnus-summary-reply "gnus/reply")
2693 (gnus-summary-caesar-message "gnus/rot13")
2694 (gnus-uu-decode-uu "gnus/uu-decode")
2695 (gnus-summary-save-article-file "gnus/save-aif")
2696 (gnus-summary-save-article "gnus/save-art")
2697 (gnus-uu-post-news "gnus/uu-post")
2698 (gnus-summary-catchup "gnus/catchup")
2699 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2700 (gnus-summary-exit "gnus/exit-summ")
2701 ;; Some new command that may need more suitable icons:
2702 (gnus-summary-print-article "gnus/print" nil :visible nil)
2703 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2704 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2705 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2706 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2707 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2708 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2709 ;;
2710 (gnus-info-find-node "gnus/help" nil :visible nil))
2711 "List of functions for the summary tool bar (retro look).
2712
2713 See `gmm-tool-bar-from-list' for the format of the list."
2714 :type '(repeat gmm-tool-bar-item)
2715 :version "22.1" ;; Gnus 5.10.9
2716 :initialize 'custom-initialize-default
2717 :set 'gnus-summary-tool-bar-update
2718 :group 'gnus-summary)
2719
2720 (defcustom gnus-summary-tool-bar-zap-list t
2721 "List of icon items from the global tool bar.
2722 These items are not displayed in the Gnus summary mode tool bar.
2723
2724 See `gmm-tool-bar-from-list' for the format of the list."
2725 :type 'gmm-tool-bar-zap-list
2726 :version "22.1" ;; Gnus 5.10.9
2727 :initialize 'custom-initialize-default
2728 :set 'gnus-summary-tool-bar-update
2729 :group 'gnus-summary)
2730
2731 (defvar image-load-path)
2732
2733 (defun gnus-summary-make-tool-bar (&optional force)
2734 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2735 When FORCE, rebuild the tool bar."
2736 (when (and (not (featurep 'xemacs))
2737 (boundp 'tool-bar-mode)
2738 tool-bar-mode
2739 (or (not gnus-summary-tool-bar-map) force))
2740 (let* ((load-path
2741 (gmm-image-load-path-for-library "gnus"
2742 "mail/save.xpm"
2743 nil t))
2744 (image-load-path (cons (car load-path)
2745 (when (boundp 'image-load-path)
2746 image-load-path)))
2747 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2748 gnus-summary-tool-bar-zap-list
2749 'gnus-summary-mode-map)))
2750 (when map
2751 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2752 ;; uses it's value.
2753 (setq gnus-summary-tool-bar-map map))))
2754 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2755
2756 (defun gnus-score-set-default (var value)
2757 "A version of set that updates the GNU Emacs menu-bar."
2758 (set var value)
2759 ;; It is the message that forces the active status to be updated.
2760 (message ""))
2761
2762 (defun gnus-make-score-map (type)
2763 "Make a summary score map of type TYPE."
2764 (if t
2765 nil
2766 (let ((headers '(("author" "from" string)
2767 ("subject" "subject" string)
2768 ("article body" "body" string)
2769 ("article head" "head" string)
2770 ("xref" "xref" string)
2771 ("extra header" "extra" string)
2772 ("lines" "lines" number)
2773 ("followups to author" "followup" string)))
2774 (types '((number ("less than" <)
2775 ("greater than" >)
2776 ("equal" =))
2777 (string ("substring" s)
2778 ("exact string" e)
2779 ("fuzzy string" f)
2780 ("regexp" r))))
2781 (perms '(("temporary" (current-time-string))
2782 ("permanent" nil)
2783 ("immediate" now)))
2784 header)
2785 (list
2786 (apply
2787 'nconc
2788 (list
2789 (if (eq type 'lower)
2790 "Lower score"
2791 "Increase score"))
2792 (let (outh)
2793 (while headers
2794 (setq header (car headers))
2795 (setq outh
2796 (cons
2797 (apply
2798 'nconc
2799 (list (car header))
2800 (let ((ts (cdr (assoc (nth 2 header) types)))
2801 outt)
2802 (while ts
2803 (setq outt
2804 (cons
2805 (apply
2806 'nconc
2807 (list (caar ts))
2808 (let ((ps perms)
2809 outp)
2810 (while ps
2811 (setq outp
2812 (cons
2813 (vector
2814 (caar ps)
2815 (list
2816 'gnus-summary-score-entry
2817 (nth 1 header)
2818 (if (or (string= (nth 1 header)
2819 "head")
2820 (string= (nth 1 header)
2821 "body"))
2822 ""
2823 (list 'gnus-summary-header
2824 (nth 1 header)))
2825 (list 'quote (nth 1 (car ts)))
2826 (list 'gnus-score-delta-default
2827 nil)
2828 (nth 1 (car ps))
2829 t)
2830 t)
2831 outp))
2832 (setq ps (cdr ps)))
2833 (list (nreverse outp))))
2834 outt))
2835 (setq ts (cdr ts)))
2836 (list (nreverse outt))))
2837 outh))
2838 (setq headers (cdr headers)))
2839 (list (nreverse outh))))))))
2840
2841 \f
2842
2843 (defun gnus-summary-mode (&optional group)
2844 "Major mode for reading articles.
2845
2846 All normal editing commands are switched off.
2847 \\<gnus-summary-mode-map>
2848 Each line in this buffer represents one article. To read an
2849 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2850 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2851 respectively.
2852
2853 You can also post articles and send mail from this buffer. To
2854 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2855 of an article, type `\\[gnus-summary-reply]'.
2856
2857 There are approx. one gazillion commands you can execute in this
2858 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2859
2860 The following commands are available:
2861
2862 \\{gnus-summary-mode-map}"
2863 (interactive)
2864 (kill-all-local-variables)
2865 (when (gnus-visual-p 'summary-menu 'menu)
2866 (gnus-summary-make-menu-bar)
2867 (gnus-summary-make-tool-bar))
2868 (gnus-summary-make-local-variables)
2869 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2870 (gnus-summary-make-local-variables))
2871 (gnus-make-thread-indent-array)
2872 (gnus-simplify-mode-line)
2873 (setq major-mode 'gnus-summary-mode)
2874 (setq mode-name "Summary")
2875 (make-local-variable 'minor-mode-alist)
2876 (use-local-map gnus-summary-mode-map)
2877 (buffer-disable-undo)
2878 (setq buffer-read-only t) ;Disable modification
2879 (setq truncate-lines t)
2880 (setq selective-display t)
2881 (setq selective-display-ellipses t) ;Display `...'
2882 (gnus-summary-set-display-table)
2883 (gnus-set-default-directory)
2884 (setq gnus-newsgroup-name group)
2885 (make-local-variable 'gnus-summary-line-format)
2886 (make-local-variable 'gnus-summary-line-format-spec)
2887 (make-local-variable 'gnus-summary-dummy-line-format)
2888 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2889 (make-local-variable 'gnus-summary-mark-positions)
2890 (gnus-make-local-hook 'pre-command-hook)
2891 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2892 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2893 (turn-on-gnus-mailing-list-mode)
2894 (mm-enable-multibyte)
2895 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2896 (gnus-update-summary-mark-positions))
2897
2898 (defun gnus-summary-make-local-variables ()
2899 "Make all the local summary buffer variables."
2900 (let (global)
2901 (dolist (local gnus-summary-local-variables)
2902 (if (consp local)
2903 (progn
2904 (if (eq (cdr local) 'global)
2905 ;; Copy the global value of the variable.
2906 (setq global (symbol-value (car local)))
2907 ;; Use the value from the list.
2908 (setq global (eval (cdr local))))
2909 (set (make-local-variable (car local)) global))
2910 ;; Simple nil-valued local variable.
2911 (set (make-local-variable local) nil)))))
2912
2913 (defun gnus-summary-clear-local-variables ()
2914 (let ((locals gnus-summary-local-variables))
2915 (while locals
2916 (if (consp (car locals))
2917 (and (vectorp (caar locals))
2918 (set (caar locals) nil))
2919 (and (vectorp (car locals))
2920 (set (car locals) nil)))
2921 (setq locals (cdr locals)))))
2922
2923 ;; Summary data functions.
2924
2925 (defmacro gnus-data-number (data)
2926 `(car ,data))
2927
2928 (defmacro gnus-data-set-number (data number)
2929 `(setcar ,data ,number))
2930
2931 (defmacro gnus-data-mark (data)
2932 `(nth 1 ,data))
2933
2934 (defmacro gnus-data-set-mark (data mark)
2935 `(setcar (nthcdr 1 ,data) ,mark))
2936
2937 (defmacro gnus-data-pos (data)
2938 `(nth 2 ,data))
2939
2940 (defmacro gnus-data-set-pos (data pos)
2941 `(setcar (nthcdr 2 ,data) ,pos))
2942
2943 (defmacro gnus-data-header (data)
2944 `(nth 3 ,data))
2945
2946 (defmacro gnus-data-set-header (data header)
2947 `(setf (nth 3 ,data) ,header))
2948
2949 (defmacro gnus-data-level (data)
2950 `(nth 4 ,data))
2951
2952 (defmacro gnus-data-unread-p (data)
2953 `(= (nth 1 ,data) gnus-unread-mark))
2954
2955 (defmacro gnus-data-read-p (data)
2956 `(/= (nth 1 ,data) gnus-unread-mark))
2957
2958 (defmacro gnus-data-pseudo-p (data)
2959 `(consp (nth 3 ,data)))
2960
2961 (defmacro gnus-data-find (number)
2962 `(assq ,number gnus-newsgroup-data))
2963
2964 (defmacro gnus-data-find-list (number &optional data)
2965 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2966 (memq (assq ,number bdata)
2967 bdata)))
2968
2969 (defmacro gnus-data-make (number mark pos header level)
2970 `(list ,number ,mark ,pos ,header ,level))
2971
2972 (defun gnus-data-enter (after-article number mark pos header level offset)
2973 (let ((data (gnus-data-find-list after-article)))
2974 (unless data
2975 (error "No such article: %d" after-article))
2976 (setcdr data (cons (gnus-data-make number mark pos header level)
2977 (cdr data)))
2978 (setq gnus-newsgroup-data-reverse nil)
2979 (gnus-data-update-list (cddr data) offset)))
2980
2981 (defun gnus-data-enter-list (after-article list &optional offset)
2982 (when list
2983 (let ((data (and after-article (gnus-data-find-list after-article)))
2984 (ilist list))
2985 (if (not (or data
2986 after-article))
2987 (let ((odata gnus-newsgroup-data))
2988 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2989 (when offset
2990 (gnus-data-update-list odata offset)))
2991 ;; Find the last element in the list to be spliced into the main
2992 ;; list.
2993 (while (cdr list)
2994 (setq list (cdr list)))
2995 (if (not data)
2996 (progn
2997 (setcdr list gnus-newsgroup-data)
2998 (setq gnus-newsgroup-data ilist)
2999 (when offset
3000 (gnus-data-update-list (cdr list) offset)))
3001 (setcdr list (cdr data))
3002 (setcdr data ilist)
3003 (when offset
3004 (gnus-data-update-list (cdr list) offset))))
3005 (setq gnus-newsgroup-data-reverse nil))))
3006
3007 (defun gnus-data-remove (article &optional offset)
3008 (let ((data gnus-newsgroup-data))
3009 (if (= (gnus-data-number (car data)) article)
3010 (progn
3011 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3012 gnus-newsgroup-data-reverse nil)
3013 (when offset
3014 (gnus-data-update-list gnus-newsgroup-data offset)))
3015 (while (cdr data)
3016 (when (= (gnus-data-number (cadr data)) article)
3017 (setcdr data (cddr data))
3018 (when offset
3019 (gnus-data-update-list (cdr data) offset))
3020 (setq data nil
3021 gnus-newsgroup-data-reverse nil))
3022 (setq data (cdr data))))))
3023
3024 (defmacro gnus-data-list (backward)
3025 `(if ,backward
3026 (or gnus-newsgroup-data-reverse
3027 (setq gnus-newsgroup-data-reverse
3028 (reverse gnus-newsgroup-data)))
3029 gnus-newsgroup-data))
3030
3031 (defun gnus-data-update-list (data offset)
3032 "Add OFFSET to the POS of all data entries in DATA."
3033 (setq gnus-newsgroup-data-reverse nil)
3034 (while data
3035 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3036 (setq data (cdr data))))
3037
3038 (defun gnus-summary-article-pseudo-p (article)
3039 "Say whether this article is a pseudo article or not."
3040 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3041
3042 (defmacro gnus-summary-article-sparse-p (article)
3043 "Say whether this article is a sparse article or not."
3044 `(memq ,article gnus-newsgroup-sparse))
3045
3046 (defmacro gnus-summary-article-ancient-p (article)
3047 "Say whether this article is a sparse article or not."
3048 `(memq ,article gnus-newsgroup-ancient))
3049
3050 (defun gnus-article-parent-p (number)
3051 "Say whether this article is a parent or not."
3052 (let ((data (gnus-data-find-list number)))
3053 (and (cdr data) ; There has to be an article after...
3054 (< (gnus-data-level (car data)) ; And it has to have a higher level.
3055 (gnus-data-level (nth 1 data))))))
3056
3057 (defun gnus-article-children (number)
3058 "Return a list of all children to NUMBER."
3059 (let* ((data (gnus-data-find-list number))
3060 (level (gnus-data-level (car data)))
3061 children)
3062 (setq data (cdr data))
3063 (while (and data
3064 (= (gnus-data-level (car data)) (1+ level)))
3065 (push (gnus-data-number (car data)) children)
3066 (setq data (cdr data)))
3067 children))
3068
3069 (defmacro gnus-summary-skip-intangible ()
3070 "If the current article is intangible, then jump to a different article."
3071 '(let ((to (get-text-property (point) 'gnus-intangible)))
3072 (and to (gnus-summary-goto-subject to))))
3073
3074 (defmacro gnus-summary-article-intangible-p ()
3075 "Say whether this article is intangible or not."
3076 '(get-text-property (point) 'gnus-intangible))
3077
3078 (defun gnus-article-read-p (article)
3079 "Say whether ARTICLE is read or not."
3080 (not (or (memq article gnus-newsgroup-marked)
3081 (memq article gnus-newsgroup-spam-marked)
3082 (memq article gnus-newsgroup-unreads)
3083 (memq article gnus-newsgroup-unselected)
3084 (memq article gnus-newsgroup-dormant))))
3085
3086 ;; Some summary mode macros.
3087
3088 (defmacro gnus-summary-article-number ()
3089 "The article number of the article on the current line.
3090 If there isn't an article number here, then we return the current
3091 article number."
3092 '(progn
3093 (gnus-summary-skip-intangible)
3094 (or (get-text-property (point) 'gnus-number)
3095 (gnus-summary-last-subject))))
3096
3097 (defmacro gnus-summary-article-header (&optional number)
3098 "Return the header of article NUMBER."
3099 `(gnus-data-header (gnus-data-find
3100 ,(or number '(gnus-summary-article-number)))))
3101
3102 (defmacro gnus-summary-thread-level (&optional number)
3103 "Return the level of thread that starts with article NUMBER."
3104 `(if (and (eq gnus-summary-make-false-root 'dummy)
3105 (get-text-property (point) 'gnus-intangible))
3106 0
3107 (gnus-data-level (gnus-data-find
3108 ,(or number '(gnus-summary-article-number))))))
3109
3110 (defmacro gnus-summary-article-mark (&optional number)
3111 "Return the mark of article NUMBER."
3112 `(gnus-data-mark (gnus-data-find
3113 ,(or number '(gnus-summary-article-number)))))
3114
3115 (defmacro gnus-summary-article-pos (&optional number)
3116 "Return the position of the line of article NUMBER."
3117 `(gnus-data-pos (gnus-data-find
3118 ,(or number '(gnus-summary-article-number)))))
3119
3120 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3121 (defmacro gnus-summary-article-subject (&optional number)
3122 "Return current subject string or nil if nothing."
3123 `(let ((headers
3124 ,(if number
3125 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3126 '(gnus-data-header (assq (gnus-summary-article-number)
3127 gnus-newsgroup-data)))))
3128 (and headers
3129 (vectorp headers)
3130 (mail-header-subject headers))))
3131
3132 (defmacro gnus-summary-article-score (&optional number)
3133 "Return current article score."
3134 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3135 gnus-newsgroup-scored))
3136 gnus-summary-default-score 0))
3137
3138 (defun gnus-summary-article-children (&optional number)
3139 "Return a list of article numbers that are children of article NUMBER."
3140 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3141 (level (gnus-data-level (car data)))
3142 l children)
3143 (while (and (setq data (cdr data))
3144 (> (setq l (gnus-data-level (car data))) level))
3145 (and (= (1+ level) l)
3146 (push (gnus-data-number (car data))
3147 children)))
3148 (nreverse children)))
3149
3150 (defun gnus-summary-article-parent (&optional number)
3151 "Return the article number of the parent of article NUMBER."
3152 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3153 (gnus-data-list t)))
3154 (level (gnus-data-level (car data))))
3155 (if (zerop level)
3156 () ; This is a root.
3157 ;; We search until we find an article with a level less than
3158 ;; this one. That function has to be the parent.
3159 (while (and (setq data (cdr data))
3160 (not (< (gnus-data-level (car data)) level))))
3161 (and data (gnus-data-number (car data))))))
3162
3163 (defun gnus-unread-mark-p (mark)
3164 "Say whether MARK is the unread mark."
3165 (= mark gnus-unread-mark))
3166
3167 (defun gnus-read-mark-p (mark)
3168 "Say whether MARK is one of the marks that mark as read.
3169 This is all marks except unread, ticked, dormant, and expirable."
3170 (not (or (= mark gnus-unread-mark)
3171 (= mark gnus-ticked-mark)
3172 (= mark gnus-spam-mark)
3173 (= mark gnus-dormant-mark)
3174 (= mark gnus-expirable-mark))))
3175
3176 (defmacro gnus-article-mark (number)
3177 "Return the MARK of article NUMBER.
3178 This macro should only be used when computing the mark the \"first\"
3179 time; i.e., when generating the summary lines. After that,
3180 `gnus-summary-article-mark' should be used to examine the
3181 marks of articles."
3182 `(cond
3183 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3184 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3185 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3186 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3187 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3188 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3189 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3190 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3191 gnus-ancient-mark))))
3192
3193 ;; Saving hidden threads.
3194
3195 (defmacro gnus-save-hidden-threads (&rest forms)
3196 "Save hidden threads, eval FORMS, and restore the hidden threads."
3197 (let ((config (make-symbol "config")))
3198 `(let ((,config (gnus-hidden-threads-configuration)))
3199 (unwind-protect
3200 (save-excursion
3201 ,@forms)
3202 (gnus-restore-hidden-threads-configuration ,config)))))
3203 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3204 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3205
3206 (defun gnus-data-compute-positions ()
3207 "Compute the positions of all articles."
3208 (setq gnus-newsgroup-data-reverse nil)
3209 (let ((data gnus-newsgroup-data))
3210 (save-excursion
3211 (gnus-save-hidden-threads
3212 (gnus-summary-show-all-threads)
3213 (goto-char (point-min))
3214 (while data
3215 (while (get-text-property (point) 'gnus-intangible)
3216 (forward-line 1))
3217 (gnus-data-set-pos (car data) (+ (point) 3))
3218 (setq data (cdr data))
3219 (forward-line 1))))))
3220
3221 (defun gnus-hidden-threads-configuration ()
3222 "Return the current hidden threads configuration."
3223 (save-excursion
3224 (let (config)
3225 (goto-char (point-min))
3226 (while (search-forward "\r" nil t)
3227 (push (1- (point)) config))
3228 config)))
3229
3230 (defun gnus-restore-hidden-threads-configuration (config)
3231 "Restore hidden threads configuration from CONFIG."
3232 (save-excursion
3233 (let (point buffer-read-only)
3234 (while (setq point (pop config))
3235 (when (and (< point (point-max))
3236 (goto-char point)
3237 (eq (char-after) ?\n))
3238 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3239
3240 ;; Various summary mode internalish functions.
3241
3242 (defun gnus-mouse-pick-article (e)
3243 (interactive "e")
3244 (mouse-set-point e)
3245 (gnus-summary-next-page nil t))
3246
3247 (defun gnus-summary-set-display-table ()
3248 "Change the display table.
3249 Odd characters have a tendency to mess
3250 up nicely formatted displays - we make all possible glyphs
3251 display only a single character."
3252
3253 ;; We start from the standard display table, if any.
3254 (let ((table (or (copy-sequence standard-display-table)
3255 (make-display-table)))
3256 (i 32))
3257 ;; Nix out all the control chars...
3258 (while (>= (setq i (1- i)) 0)
3259 (aset table i [??]))
3260 ;; ... but not newline and cr, of course. (cr is necessary for the
3261 ;; selective display).
3262 (aset table ?\n nil)
3263 (aset table ?\r nil)
3264 ;; We keep TAB as well.
3265 (aset table ?\t nil)
3266 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3267 ;; Emacs 23 (unicode), that are not set already.
3268 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3269 160
3270 256)))
3271 (while (>= (setq i (1- i)) 127)
3272 ;; Only modify if the entry is nil.
3273 (unless (aref table i)
3274 (aset table i [??]))))
3275 (setq buffer-display-table table)))
3276
3277 (defun gnus-summary-set-article-display-arrow (pos)
3278 "Update the overlay arrow to point to line at position POS."
3279 (when (and gnus-summary-display-arrow
3280 (boundp 'overlay-arrow-position)
3281 (boundp 'overlay-arrow-string))
3282 (save-excursion
3283 (goto-char pos)
3284 (beginning-of-line)
3285 (unless overlay-arrow-position
3286 (setq overlay-arrow-position (make-marker)))
3287 (setq overlay-arrow-string "=>"
3288 overlay-arrow-position (set-marker overlay-arrow-position
3289 (point)
3290 (current-buffer))))))
3291
3292 (defun gnus-summary-setup-buffer (group)
3293 "Initialize summary buffer."
3294 (let ((buffer (gnus-summary-buffer-name group))
3295 (dead-name (concat "*Dead Summary "
3296 (gnus-group-decoded-name group) "*")))
3297 ;; If a dead summary buffer exists, we kill it.
3298 (when (gnus-buffer-live-p dead-name)
3299 (gnus-kill-buffer dead-name))
3300 (if (get-buffer buffer)
3301 (progn
3302 (set-buffer buffer)
3303 (setq gnus-summary-buffer (current-buffer))
3304 (not gnus-newsgroup-prepared))
3305 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3306 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3307 (gnus-summary-mode group)
3308 (when gnus-carpal
3309 (gnus-carpal-setup-buffer 'summary))
3310 (unless gnus-single-article-buffer
3311 (make-local-variable 'gnus-article-buffer)
3312 (make-local-variable 'gnus-article-current)
3313 (make-local-variable 'gnus-original-article-buffer))
3314 (setq gnus-newsgroup-name group)
3315 ;; Set any local variables in the group parameters.
3316 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3317 t)))
3318
3319 (defun gnus-set-global-variables ()
3320 "Set the global equivalents of the buffer-local variables.
3321 They are set to the latest values they had. These reflect the summary
3322 buffer that was in action when the last article was fetched."
3323 (when (eq major-mode 'gnus-summary-mode)
3324 (setq gnus-summary-buffer (current-buffer))
3325 (let ((name gnus-newsgroup-name)
3326 (marked gnus-newsgroup-marked)
3327 (spam gnus-newsgroup-spam-marked)
3328 (unread gnus-newsgroup-unreads)
3329 (headers gnus-current-headers)
3330 (data gnus-newsgroup-data)
3331 (summary gnus-summary-buffer)
3332 (article-buffer gnus-article-buffer)
3333 (original gnus-original-article-buffer)
3334 (gac gnus-article-current)
3335 (reffed gnus-reffed-article-number)
3336 (score-file gnus-current-score-file)
3337 (default-charset gnus-newsgroup-charset)
3338 vlist)
3339 (let ((locals gnus-newsgroup-variables))
3340 (while locals
3341 (if (consp (car locals))
3342 (push (eval (caar locals)) vlist)
3343 (push (eval (car locals)) vlist))
3344 (setq locals (cdr locals)))
3345 (setq vlist (nreverse vlist)))
3346 (save-excursion
3347 (set-buffer gnus-group-buffer)
3348 (setq gnus-newsgroup-name name
3349 gnus-newsgroup-marked marked
3350 gnus-newsgroup-spam-marked spam
3351 gnus-newsgroup-unreads unread
3352 gnus-current-headers headers
3353 gnus-newsgroup-data data
3354 gnus-article-current gac
3355 gnus-summary-buffer summary
3356 gnus-article-buffer article-buffer
3357 gnus-original-article-buffer original
3358 gnus-reffed-article-number reffed
3359 gnus-current-score-file score-file
3360 gnus-newsgroup-charset default-charset)
3361 (let ((locals gnus-newsgroup-variables))
3362 (while locals
3363 (if (consp (car locals))
3364 (set (caar locals) (pop vlist))
3365 (set (car locals) (pop vlist)))
3366 (setq locals (cdr locals))))
3367 ;; The article buffer also has local variables.
3368 (when (gnus-buffer-live-p gnus-article-buffer)
3369 (set-buffer gnus-article-buffer)
3370 (setq gnus-summary-buffer summary))))))
3371
3372 (defun gnus-summary-article-unread-p (article)
3373 "Say whether ARTICLE is unread or not."
3374 (memq article gnus-newsgroup-unreads))
3375
3376 (defun gnus-summary-first-article-p (&optional article)
3377 "Return whether ARTICLE is the first article in the buffer."
3378 (if (not (setq article (or article (gnus-summary-article-number))))
3379 nil
3380 (eq article (caar gnus-newsgroup-data))))
3381
3382 (defun gnus-summary-last-article-p (&optional article)
3383 "Return whether ARTICLE is the last article in the buffer."
3384 (if (not (setq article (or article (gnus-summary-article-number))))
3385 ;; All non-existent numbers are the last article. :-)
3386 t
3387 (not (cdr (gnus-data-find-list article)))))
3388
3389 (defun gnus-make-thread-indent-array (&optional n)
3390 (when (or n
3391 (progn (setq n 200) nil)
3392 (null gnus-thread-indent-array)
3393 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3394 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3395 gnus-thread-indent-array-level gnus-thread-indent-level)
3396 (while (>= n 0)
3397 (aset gnus-thread-indent-array n
3398 (make-string (* n gnus-thread-indent-level) ? ))
3399 (setq n (1- n)))))
3400
3401 (defun gnus-update-summary-mark-positions ()
3402 "Compute where the summary marks are to go."
3403 (save-excursion
3404 (when (gnus-buffer-exists-p gnus-summary-buffer)
3405 (set-buffer gnus-summary-buffer))
3406 (let ((spec gnus-summary-line-format-spec)
3407 pos)
3408 (save-excursion
3409 (gnus-set-work-buffer)
3410 (let ((gnus-tmp-unread ?Z)
3411 (gnus-replied-mark ?Z)
3412 (gnus-score-below-mark ?Z)
3413 (gnus-score-over-mark ?Z)
3414 (gnus-undownloaded-mark ?Z)
3415 (gnus-summary-line-format-spec spec)
3416 (gnus-newsgroup-downloadable '(0))
3417 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3418 case-fold-search ignores)
3419 ;; Here, all marks are bound to Z.
3420 (gnus-summary-insert-line header
3421 0 nil t gnus-tmp-unread t nil "" nil 1)
3422 (goto-char (point-min))
3423 ;; Memorize the positions of the same characters as dummy marks.
3424 (while (re-search-forward "[A-D]" nil t)
3425 (push (point) ignores))
3426 (erase-buffer)
3427 ;; We use A-D as dummy marks in order to know column positions
3428 ;; where marks should be inserted.
3429 (setq gnus-tmp-unread ?A
3430 gnus-replied-mark ?B
3431 gnus-score-below-mark ?C
3432 gnus-score-over-mark ?C
3433 gnus-undownloaded-mark ?D)
3434 (gnus-summary-insert-line header
3435 0 nil t gnus-tmp-unread t nil "" nil 1)
3436 ;; Ignore characters which aren't dummy marks.
3437 (dolist (p ignores)
3438 (delete-region (goto-char (1- p)) p)
3439 (insert ?Z))
3440 (goto-char (point-min))
3441 (setq pos (list (cons 'unread
3442 (and (search-forward "A" nil t)
3443 (- (point) (point-min) 1)))))
3444 (goto-char (point-min))
3445 (push (cons 'replied (and (search-forward "B" nil t)
3446 (- (point) (point-min) 1)))
3447 pos)
3448 (goto-char (point-min))
3449 (push (cons 'score (and (search-forward "C" nil t)
3450 (- (point) (point-min) 1)))
3451 pos)
3452 (goto-char (point-min))
3453 (push (cons 'download (and (search-forward "D" nil t)
3454 (- (point) (point-min) 1)))
3455 pos)))
3456 (setq gnus-summary-mark-positions pos))))
3457
3458 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3459 "Insert a dummy root in the summary buffer."
3460 (beginning-of-line)
3461 (gnus-add-text-properties
3462 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3463 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3464
3465 (defun gnus-summary-extract-address-component (from)
3466 (or (car (funcall gnus-extract-address-components from))
3467 from))
3468
3469 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3470 (let ((mail-parse-charset gnus-newsgroup-charset)
3471 ; Is it really necessary to do this next part for each summary line?
3472 ; Luckily, doesn't seem to slow things down much.
3473 (mail-parse-ignored-charsets
3474 (save-excursion (set-buffer gnus-summary-buffer)
3475 gnus-newsgroup-ignored-charsets)))
3476 (or
3477 (and gnus-ignored-from-addresses
3478 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3479 (let ((extra-headers (mail-header-extra header))
3480 to
3481 newsgroups)
3482 (cond
3483 ((setq to (cdr (assq 'To extra-headers)))
3484 (concat "-> "
3485 (inline
3486 (gnus-summary-extract-address-component
3487 (funcall gnus-decode-encoded-address-function to)))))
3488 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3489 (concat "=> " newsgroups)))))
3490 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3491
3492 (defun gnus-summary-insert-line (gnus-tmp-header
3493 gnus-tmp-level gnus-tmp-current
3494 undownloaded gnus-tmp-unread gnus-tmp-replied
3495 gnus-tmp-expirable gnus-tmp-subject-or-nil
3496 &optional gnus-tmp-dummy gnus-tmp-score
3497 gnus-tmp-process)
3498 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3499 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3500 gnus-tmp-level)))
3501 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3502 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3503 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3504 (gnus-tmp-score-char
3505 (if (or (null gnus-summary-default-score)
3506 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3507 gnus-summary-zcore-fuzz))
3508 ? ;Whitespace
3509 (if (< gnus-tmp-score gnus-summary-default-score)
3510 gnus-score-below-mark gnus-score-over-mark)))
3511 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3512 (gnus-tmp-replied
3513 (cond (gnus-tmp-process gnus-process-mark)
3514 ((memq gnus-tmp-current gnus-newsgroup-cached)
3515 gnus-cached-mark)
3516 (gnus-tmp-replied gnus-replied-mark)
3517 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3518 gnus-forwarded-mark)
3519 ((memq gnus-tmp-current gnus-newsgroup-saved)
3520 gnus-saved-mark)
3521 ((memq gnus-tmp-number gnus-newsgroup-recent)
3522 gnus-recent-mark)
3523 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3524 gnus-unseen-mark)
3525 (t gnus-no-mark)))
3526 (gnus-tmp-downloaded
3527 (cond (undownloaded
3528 gnus-undownloaded-mark)
3529 (gnus-newsgroup-agentized
3530 gnus-downloaded-mark)
3531 (t
3532 gnus-no-mark)))
3533 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3534 (gnus-tmp-name
3535 (cond
3536 ((string-match "<[^>]+> *$" gnus-tmp-from)
3537 (let ((beg (match-beginning 0)))
3538 (or (and (string-match "^\".+\"" gnus-tmp-from)
3539 (substring gnus-tmp-from 1 (1- (match-end 0))))
3540 (substring gnus-tmp-from 0 beg))))
3541 ((string-match "(.+)" gnus-tmp-from)
3542 (substring gnus-tmp-from
3543 (1+ (match-beginning 0)) (1- (match-end 0))))
3544 (t gnus-tmp-from)))
3545 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3546 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3547 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3548 (buffer-read-only nil))
3549 (when (string= gnus-tmp-name "")
3550 (setq gnus-tmp-name gnus-tmp-from))
3551 (unless (numberp gnus-tmp-lines)
3552 (setq gnus-tmp-lines -1))
3553 (if (= gnus-tmp-lines -1)
3554 (setq gnus-tmp-lines "?")
3555 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3556 (gnus-put-text-property
3557 (point)
3558 (progn (eval gnus-summary-line-format-spec) (point))
3559 'gnus-number gnus-tmp-number)
3560 (when (gnus-visual-p 'summary-highlight 'highlight)
3561 (forward-line -1)
3562 (gnus-run-hooks 'gnus-summary-update-hook)
3563 (forward-line 1))))
3564
3565 (defun gnus-summary-update-line (&optional dont-update)
3566 "Update summary line after change."
3567 (when (and gnus-summary-default-score
3568 (not gnus-summary-inhibit-highlight))
3569 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3570 (article (gnus-summary-article-number))
3571 (score (gnus-summary-article-score article)))
3572 (unless dont-update
3573 (if (and gnus-summary-mark-below
3574 (< (gnus-summary-article-score)
3575 gnus-summary-mark-below))
3576 ;; This article has a low score, so we mark it as read.
3577 (when (memq article gnus-newsgroup-unreads)
3578 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3579 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3580 ;; This article was previously marked as read on account
3581 ;; of a low score, but now it has risen, so we mark it as
3582 ;; unread.
3583 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3584 (gnus-summary-update-mark
3585 (if (or (null gnus-summary-default-score)
3586 (<= (abs (- score gnus-summary-default-score))
3587 gnus-summary-zcore-fuzz))
3588 ? ;Whitespace
3589 (if (< score gnus-summary-default-score)
3590 gnus-score-below-mark gnus-score-over-mark))
3591 'score))
3592 ;; Do visual highlighting.
3593 (when (gnus-visual-p 'summary-highlight 'highlight)
3594 (gnus-run-hooks 'gnus-summary-update-hook)))))
3595
3596 (defvar gnus-tmp-new-adopts nil)
3597
3598 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3599 "Return the number of articles in THREAD.
3600 This may be 0 in some cases -- if none of the articles in
3601 the thread are to be displayed."
3602 (let* ((number
3603 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3604 (cond
3605 ((not (listp thread))
3606 1)
3607 ((and (consp thread) (cdr thread))
3608 (apply
3609 '+ 1 (mapcar
3610 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3611 ((null thread)
3612 1)
3613 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3614 1)
3615 (t 0))))
3616 (when (and level (zerop level) gnus-tmp-new-adopts)
3617 (incf number
3618 (apply '+ (mapcar
3619 'gnus-summary-number-of-articles-in-thread
3620 gnus-tmp-new-adopts))))
3621 (if char
3622 (if (> number 1) gnus-not-empty-thread-mark
3623 gnus-empty-thread-mark)
3624 number)))
3625
3626 (defsubst gnus-summary-line-message-size (head)
3627 "Return pretty-printed version of message size.
3628 This function is intended to be used in
3629 `gnus-summary-line-format-alist'."
3630 (let ((c (or (mail-header-chars head) -1)))
3631 (cond ((< c 0) "n/a") ; chars not available
3632 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3633 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3634 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3635 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3636
3637
3638 (defun gnus-summary-set-local-parameters (group)
3639 "Go through the local params of GROUP and set all variable specs in that list."
3640 (let ((params (gnus-group-find-parameter group))
3641 (vars '(quit-config)) ; Ignore quit-config.
3642 elem)
3643 (while params
3644 (setq elem (car params)
3645 params (cdr params))
3646 (and (consp elem) ; Has to be a cons.
3647 (consp (cdr elem)) ; The cdr has to be a list.
3648 (symbolp (car elem)) ; Has to be a symbol in there.
3649 (not (memq (car elem) vars))
3650 (ignore-errors ; So we set it.
3651 (push (car elem) vars)
3652 (make-local-variable (car elem))
3653 (set (car elem) (eval (nth 1 elem))))))))
3654
3655 (defun gnus-summary-read-group (group &optional show-all no-article
3656 kill-buffer no-display backward
3657 select-articles)
3658 "Start reading news in newsgroup GROUP.
3659 If SHOW-ALL is non-nil, already read articles are also listed.
3660 If NO-ARTICLE is non-nil, no article is selected initially.
3661 If NO-DISPLAY, don't generate a summary buffer."
3662 (let (result)
3663 (while (and group
3664 (null (setq result
3665 (let ((gnus-auto-select-next nil))
3666 (or (gnus-summary-read-group-1
3667 group show-all no-article
3668 kill-buffer no-display
3669 select-articles)
3670 (setq show-all nil
3671 select-articles nil)))))
3672 (eq gnus-auto-select-next 'quietly))
3673 (set-buffer gnus-group-buffer)
3674 ;; The entry function called above goes to the next
3675 ;; group automatically, so we go two groups back
3676 ;; if we are searching for the previous group.
3677 (when backward
3678 (gnus-group-prev-unread-group 2))
3679 (if (not (equal group (gnus-group-group-name)))
3680 (setq group (gnus-group-group-name))
3681 (setq group nil)))
3682 result))
3683
3684 (defun gnus-summary-read-group-1 (group show-all no-article
3685 kill-buffer no-display
3686 &optional select-articles)
3687 ;; Killed foreign groups can't be entered.
3688 ;; (when (and (not (gnus-group-native-p group))
3689 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3690 ;; (error "Dead non-native groups can't be entered"))
3691 (gnus-message 5 "Retrieving newsgroup: %s..."
3692 (gnus-group-decoded-name group))
3693 (let* ((new-group (gnus-summary-setup-buffer group))
3694 (quit-config (gnus-group-quit-config group))
3695 (did-select (and new-group (gnus-select-newsgroup
3696 group show-all select-articles))))
3697 (cond
3698 ;; This summary buffer exists already, so we just select it.
3699 ((not new-group)
3700 (gnus-set-global-variables)
3701 (when kill-buffer
3702 (gnus-kill-or-deaden-summary kill-buffer))
3703 (gnus-configure-windows 'summary 'force)
3704 (gnus-set-mode-line 'summary)
3705 (gnus-summary-position-point)
3706 (message "")
3707 t)
3708 ;; We couldn't select this group.
3709 ((null did-select)
3710 (when (and (eq major-mode 'gnus-summary-mode)
3711 (not (equal (current-buffer) kill-buffer)))
3712 (kill-buffer (current-buffer))
3713 (if (not quit-config)
3714 (progn
3715 ;; Update the info -- marks might need to be removed,
3716 ;; for instance.
3717 (gnus-summary-update-info)
3718 (set-buffer gnus-group-buffer)
3719 (gnus-group-jump-to-group group)
3720 (gnus-group-next-unread-group 1))
3721 (gnus-handle-ephemeral-exit quit-config)))
3722 (let ((grpinfo (gnus-get-info group)))
3723 (if (null (gnus-info-read grpinfo))
3724 (gnus-message 3 "Group %s contains no messages"
3725 (gnus-group-decoded-name group))
3726 (gnus-message 3 "Can't select group")))
3727 nil)
3728 ;; The user did a `C-g' while prompting for number of articles,
3729 ;; so we exit this group.
3730 ((eq did-select 'quit)
3731 (and (eq major-mode 'gnus-summary-mode)
3732 (not (equal (current-buffer) kill-buffer))
3733 (kill-buffer (current-buffer)))
3734 (when kill-buffer
3735 (gnus-kill-or-deaden-summary kill-buffer))
3736 (if (not quit-config)
3737 (progn
3738 (set-buffer gnus-group-buffer)
3739 (gnus-group-jump-to-group group)
3740 (gnus-group-next-unread-group 1)
3741 (gnus-configure-windows 'group 'force))
3742 (gnus-handle-ephemeral-exit quit-config))
3743 ;; Finally signal the quit.
3744 (signal 'quit nil))
3745 ;; The group was successfully selected.
3746 (t
3747 (gnus-set-global-variables)
3748 ;; Save the active value in effect when the group was entered.
3749 (setq gnus-newsgroup-active
3750 (gnus-copy-sequence
3751 (gnus-active gnus-newsgroup-name)))
3752 ;; You can change the summary buffer in some way with this hook.
3753 (gnus-run-hooks 'gnus-select-group-hook)
3754 (when (memq 'summary (gnus-update-format-specifications
3755 nil 'summary 'summary-mode 'summary-dummy))
3756 ;; The format specification for the summary line was updated,
3757 ;; so we need to update the mark positions as well.
3758 (gnus-update-summary-mark-positions))
3759 ;; Do score processing.
3760 (when gnus-use-scoring
3761 (gnus-possibly-score-headers))
3762 ;; Check whether to fill in the gaps in the threads.
3763 (when gnus-build-sparse-threads
3764 (gnus-build-sparse-threads))
3765 ;; Find the initial limit.
3766 (if show-all
3767 (let ((gnus-newsgroup-dormant nil))
3768 (gnus-summary-initial-limit show-all))
3769 (gnus-summary-initial-limit show-all))
3770 ;; Generate the summary buffer.
3771 (unless no-display
3772 (gnus-summary-prepare))
3773 (when gnus-use-trees
3774 (gnus-tree-open group)
3775 (setq gnus-summary-highlight-line-function
3776 'gnus-tree-highlight-article))
3777 ;; If the summary buffer is empty, but there are some low-scored
3778 ;; articles or some excluded dormants, we include these in the
3779 ;; buffer.
3780 (when (and (zerop (buffer-size))
3781 (not no-display))
3782 (cond (gnus-newsgroup-dormant
3783 (gnus-summary-limit-include-dormant))
3784 ((and gnus-newsgroup-scored show-all)
3785 (gnus-summary-limit-include-expunged t))))
3786 ;; Function `gnus-apply-kill-file' must be called in this hook.
3787 (gnus-run-hooks 'gnus-apply-kill-hook)
3788 (if (and (zerop (buffer-size))
3789 (not no-display))
3790 (progn
3791 ;; This newsgroup is empty.
3792 (gnus-summary-catchup-and-exit nil t)
3793 (gnus-message 6 "No unread news")
3794 (when kill-buffer
3795 (gnus-kill-or-deaden-summary kill-buffer))
3796 ;; Return nil from this function.
3797 nil)
3798 ;; Hide conversation thread subtrees. We cannot do this in
3799 ;; gnus-summary-prepare-hook since kill processing may not
3800 ;; work with hidden articles.
3801 (gnus-summary-maybe-hide-threads)
3802 (when kill-buffer
3803 (gnus-kill-or-deaden-summary kill-buffer))
3804 (gnus-summary-auto-select-subject)
3805 ;; Show first unread article if requested.
3806 (if (and (not no-article)
3807 (not no-display)
3808 gnus-newsgroup-unreads
3809 gnus-auto-select-first)
3810 (progn
3811 (gnus-configure-windows 'summary)
3812 (let ((art (gnus-summary-article-number)))
3813 (unless (and (not gnus-plugged)
3814 (or (memq art gnus-newsgroup-undownloaded)
3815 (memq art gnus-newsgroup-downloadable)))
3816 (gnus-summary-goto-article art))))
3817 ;; Don't select any articles.
3818 (gnus-summary-position-point)
3819 (gnus-configure-windows 'summary 'force)
3820 (gnus-set-mode-line 'summary))
3821 (when (and gnus-auto-center-group
3822 (get-buffer-window gnus-group-buffer t))
3823 ;; Gotta use windows, because recenter does weird stuff if
3824 ;; the current buffer ain't the displayed window.
3825 (let ((owin (selected-window)))
3826 (select-window (get-buffer-window gnus-group-buffer t))
3827 (when (gnus-group-goto-group group)
3828 (recenter))
3829 (select-window owin)))
3830 ;; Mark this buffer as "prepared".
3831 (setq gnus-newsgroup-prepared t)
3832 (gnus-run-hooks 'gnus-summary-prepared-hook)
3833 (unless (gnus-ephemeral-group-p group)
3834 (gnus-group-update-group group))
3835 t)))))
3836
3837 (defun gnus-summary-auto-select-subject ()
3838 "Select the subject line on initial group entry."
3839 (goto-char (point-min))
3840 (cond
3841 ((eq gnus-auto-select-subject 'best)
3842 (gnus-summary-best-unread-subject))
3843 ((eq gnus-auto-select-subject 'unread)
3844 (gnus-summary-first-unread-subject))
3845 ((eq gnus-auto-select-subject 'unseen)
3846 (gnus-summary-first-unseen-subject))
3847 ((eq gnus-auto-select-subject 'unseen-or-unread)
3848 (gnus-summary-first-unseen-or-unread-subject))
3849 ((eq gnus-auto-select-subject 'first)
3850 ;; Do nothing.
3851 )
3852 ((functionp gnus-auto-select-subject)
3853 (funcall gnus-auto-select-subject))))
3854
3855 (defun gnus-summary-prepare ()
3856 "Generate the summary buffer."
3857 (interactive)
3858 (let ((buffer-read-only nil))
3859 (erase-buffer)
3860 (setq gnus-newsgroup-data nil
3861 gnus-newsgroup-data-reverse nil)
3862 (gnus-run-hooks 'gnus-summary-generate-hook)
3863 ;; Generate the buffer, either with threads or without.
3864 (when gnus-newsgroup-headers
3865 (gnus-summary-prepare-threads
3866 (if gnus-show-threads
3867 (gnus-sort-gathered-threads
3868 (funcall gnus-summary-thread-gathering-function
3869 (gnus-sort-threads
3870 (gnus-cut-threads (gnus-make-threads)))))
3871 ;; Unthreaded display.
3872 (gnus-sort-articles gnus-newsgroup-headers))))
3873 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3874 ;; Call hooks for modifying summary buffer.
3875 (goto-char (point-min))
3876 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3877
3878 (defsubst gnus-general-simplify-subject (subject)
3879 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3880 (setq subject
3881 (cond
3882 ;; Truncate the subject.
3883 (gnus-simplify-subject-functions
3884 (gnus-map-function gnus-simplify-subject-functions subject))
3885 ((numberp gnus-summary-gather-subject-limit)
3886 (setq subject (gnus-simplify-subject-re subject))
3887 (if (> (length subject) gnus-summary-gather-subject-limit)
3888 (substring subject 0 gnus-summary-gather-subject-limit)
3889 subject))
3890 ;; Fuzzily simplify it.
3891 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3892 (gnus-simplify-subject-fuzzy subject))
3893 ;; Just remove the leading "Re:".
3894 (t
3895 (gnus-simplify-subject-re subject))))
3896
3897 (if (and gnus-summary-gather-exclude-subject
3898 (string-match gnus-summary-gather-exclude-subject subject))
3899 nil ; This article shouldn't be gathered
3900 subject))
3901
3902 (defun gnus-summary-simplify-subject-query ()
3903 "Query where the respool algorithm would put this article."
3904 (interactive)
3905 (gnus-summary-select-article)
3906 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3907
3908 (defun gnus-gather-threads-by-subject (threads)
3909 "Gather threads by looking at Subject headers."
3910 (if (not gnus-summary-make-false-root)
3911 threads
3912 (let ((hashtb (gnus-make-hashtable 1024))
3913 (prev threads)
3914 (result threads)
3915 subject hthread whole-subject)
3916 (while threads
3917 (setq subject (gnus-general-simplify-subject
3918 (setq whole-subject (mail-header-subject
3919 (caar threads)))))
3920 (when subject
3921 (if (setq hthread (gnus-gethash subject hashtb))
3922 (progn
3923 ;; We enter a dummy root into the thread, if we
3924 ;; haven't done that already.
3925 (unless (stringp (caar hthread))
3926 (setcar hthread (list whole-subject (car hthread))))
3927 ;; We add this new gathered thread to this gathered
3928 ;; thread.
3929 (setcdr (car hthread)
3930 (nconc (cdar hthread) (list (car threads))))
3931 ;; Remove it from the list of threads.
3932 (setcdr prev (cdr threads))
3933 (setq threads prev))
3934 ;; Enter this thread into the hash table.
3935 (gnus-sethash subject
3936 (if gnus-summary-make-false-root-always
3937 (progn
3938 ;; If you want a dummy root above all
3939 ;; threads...
3940 (setcar threads (list whole-subject
3941 (car threads)))
3942 threads)
3943 threads)
3944 hashtb)))
3945 (setq prev threads)
3946 (setq threads (cdr threads)))
3947 result)))
3948
3949 (defun gnus-gather-threads-by-references (threads)
3950 "Gather threads by looking at References headers."
3951 (let ((idhashtb (gnus-make-hashtable 1024))
3952 (thhashtb (gnus-make-hashtable 1024))
3953 (prev threads)
3954 (result threads)
3955 ids references id gthread gid entered ref)
3956 (while threads
3957 (when (setq references (mail-header-references (caar threads)))
3958 (setq id (mail-header-id (caar threads))
3959 ids (inline (gnus-split-references references))
3960 entered nil)
3961 (while (setq ref (pop ids))
3962 (setq ids (delete ref ids))
3963 (if (not (setq gid (gnus-gethash ref idhashtb)))
3964 (progn
3965 (gnus-sethash ref id idhashtb)
3966 (gnus-sethash id threads thhashtb))
3967 (setq gthread (gnus-gethash gid thhashtb))
3968 (unless entered
3969 ;; We enter a dummy root into the thread, if we
3970 ;; haven't done that already.
3971 (unless (stringp (caar gthread))
3972 (setcar gthread (list (mail-header-subject (caar gthread))
3973 (car gthread))))
3974 ;; We add this new gathered thread to this gathered
3975 ;; thread.
3976 (setcdr (car gthread)
3977 (nconc (cdar gthread) (list (car threads)))))
3978 ;; Add it into the thread hash table.
3979 (gnus-sethash id gthread thhashtb)
3980 (setq entered t)
3981 ;; Remove it from the list of threads.
3982 (setcdr prev (cdr threads))
3983 (setq threads prev))))
3984 (setq prev threads)
3985 (setq threads (cdr threads)))
3986 result))
3987
3988 (defun gnus-sort-gathered-threads (threads)
3989 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3990 (let ((result threads))
3991 (while threads
3992 (when (stringp (caar threads))
3993 (setcdr (car threads)
3994 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3995 (setq threads (cdr threads)))
3996 result))
3997
3998 (defun gnus-thread-loop-p (root thread)
3999 "Say whether ROOT is in THREAD."
4000 (let ((stack (list thread))
4001 (infloop 0)
4002 th)
4003 (while (setq thread (pop stack))
4004 (setq th (cdr thread))
4005 (while (and th
4006 (not (eq (caar th) root)))
4007 (pop th))
4008 (if th
4009 ;; We have found a loop.
4010 (let (ref-dep)
4011 (setcdr thread (delq (car th) (cdr thread)))
4012 (if (boundp (setq ref-dep (intern "none"
4013 gnus-newsgroup-dependencies)))
4014 (setcdr (symbol-value ref-dep)
4015 (nconc (cdr (symbol-value ref-dep))
4016 (list (car th))))
4017 (set ref-dep (list nil (car th))))
4018 (setq infloop 1
4019 stack nil))
4020 ;; Push all the subthreads onto the stack.
4021 (push (cdr thread) stack)))
4022 infloop))
4023
4024 (defun gnus-make-threads ()
4025 "Go through the dependency hashtb and find the roots. Return all threads."
4026 (let (threads)
4027 (while (catch 'infloop
4028 (mapatoms
4029 (lambda (refs)
4030 ;; Deal with self-referencing References loops.
4031 (when (and (car (symbol-value refs))
4032 (not (zerop
4033 (apply
4034 '+
4035 (mapcar
4036 (lambda (thread)
4037 (gnus-thread-loop-p
4038 (car (symbol-value refs)) thread))
4039 (cdr (symbol-value refs)))))))
4040 (setq threads nil)
4041 (throw 'infloop t))
4042 (unless (car (symbol-value refs))
4043 ;; These threads do not refer back to any other
4044 ;; articles, so they're roots.
4045 (setq threads (append (cdr (symbol-value refs)) threads))))
4046 gnus-newsgroup-dependencies)))
4047 threads))
4048
4049 ;; Build the thread tree.
4050 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4051 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4052
4053 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4054 if it was already present.
4055
4056 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4057 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4058 Message-IDs will be renamed to a unique Message-ID before being
4059 entered.
4060
4061 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4062 (let* ((id (mail-header-id header))
4063 (id-dep (and id (intern id dependencies)))
4064 parent-id ref ref-dep ref-header replaced)
4065 ;; Enter this `header' in the `dependencies' table.
4066 (cond
4067 ((not id-dep)
4068 (setq header nil))
4069 ;; The first two cases do the normal part: enter a new `header'
4070 ;; in the `dependencies' table.
4071 ((not (boundp id-dep))
4072 (set id-dep (list header)))
4073 ((null (car (symbol-value id-dep)))
4074 (setcar (symbol-value id-dep) header))
4075
4076 ;; From here the `header' was already present in the
4077 ;; `dependencies' table.
4078 (force-new
4079 ;; Overrides an existing entry;
4080 ;; just set the header part of the entry.
4081 (setcar (symbol-value id-dep) header)
4082 (setq replaced t))
4083
4084 ;; Renames the existing `header' to a unique Message-ID.
4085 ((not gnus-summary-ignore-duplicates)
4086 ;; An article with this Message-ID has already been seen.
4087 ;; We rename the Message-ID.
4088 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4089 (list header))
4090 (mail-header-set-id header id))
4091
4092 ;; The last case ignores an existing entry, except it adds any
4093 ;; additional Xrefs (in case the two articles came from different
4094 ;; servers.
4095 ;; Also sets `header' to `nil' meaning that the `dependencies'
4096 ;; table was *not* modified.
4097 (t
4098 (mail-header-set-xref
4099 (car (symbol-value id-dep))
4100 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4101 "")
4102 (or (mail-header-xref header) "")))
4103 (setq header nil)))
4104
4105 (when (and header (not replaced))
4106 ;; First check that we are not creating a References loop.
4107 (setq parent-id (gnus-parent-id (mail-header-references header)))
4108 (setq ref parent-id)
4109 (while (and ref
4110 (setq ref-dep (intern-soft ref dependencies))
4111 (boundp ref-dep)
4112 (setq ref-header (car (symbol-value ref-dep))))
4113 (if (string= id ref)
4114 ;; Yuk! This is a reference loop. Make the article be a
4115 ;; root article.
4116 (progn
4117 (mail-header-set-references (car (symbol-value id-dep)) "none")
4118 (setq ref nil)
4119 (setq parent-id nil))
4120 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4121 (setq ref-dep (intern (or parent-id "none") dependencies))
4122 (if (boundp ref-dep)
4123 (setcdr (symbol-value ref-dep)
4124 (nconc (cdr (symbol-value ref-dep))
4125 (list (symbol-value id-dep))))
4126 (set ref-dep (list nil (symbol-value id-dep)))))
4127 header))
4128
4129 (defun gnus-extract-message-id-from-in-reply-to (string)
4130 (if (string-match "<[^>]+>" string)
4131 (substring string (match-beginning 0) (match-end 0))
4132 nil))
4133
4134 (defun gnus-build-sparse-threads ()
4135 (let ((headers gnus-newsgroup-headers)
4136 (mail-parse-charset gnus-newsgroup-charset)
4137 (gnus-summary-ignore-duplicates t)
4138 header references generation relations
4139 subject child end new-child date)
4140 ;; First we create an alist of generations/relations, where
4141 ;; generations is how much we trust the relation, and the relation
4142 ;; is parent/child.
4143 (gnus-message 7 "Making sparse threads...")
4144 (save-excursion
4145 (nnheader-set-temp-buffer " *gnus sparse threads*")
4146 (while (setq header (pop headers))
4147 (when (and (setq references (mail-header-references header))
4148 (not (string= references "")))
4149 (insert references)
4150 (setq child (mail-header-id header)
4151 subject (mail-header-subject header)
4152 date (mail-header-date header)
4153 generation 0)
4154 (while (search-backward ">" nil t)
4155 (setq end (1+ (point)))
4156 (when (search-backward "<" nil t)
4157 (setq new-child (buffer-substring (point) end))
4158 (push (list (incf generation)
4159 child (setq child new-child)
4160 subject date)
4161 relations)))
4162 (when child
4163 (push (list (1+ generation) child nil subject) relations))
4164 (erase-buffer)))
4165 (kill-buffer (current-buffer)))
4166 ;; Sort over trustworthiness.
4167 (mapcar
4168 (lambda (relation)
4169 (when (gnus-dependencies-add-header
4170 (make-full-mail-header
4171 gnus-reffed-article-number
4172 (nth 3 relation) "" (or (nth 4 relation) "")
4173 (nth 1 relation)
4174 (or (nth 2 relation) "") 0 0 "")
4175 gnus-newsgroup-dependencies nil)
4176 (push gnus-reffed-article-number gnus-newsgroup-limit)
4177 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4178 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4179 gnus-newsgroup-reads)
4180 (decf gnus-reffed-article-number)))
4181 (sort relations 'car-less-than-car))
4182 (gnus-message 7 "Making sparse threads...done")))
4183
4184 (defun gnus-build-old-threads ()
4185 ;; Look at all the articles that refer back to old articles, and
4186 ;; fetch the headers for the articles that aren't there. This will
4187 ;; build complete threads - if the roots haven't been expired by the
4188 ;; server, that is.
4189 (let ((mail-parse-charset gnus-newsgroup-charset)
4190 id heads)
4191 (mapatoms
4192 (lambda (refs)
4193 (when (not (car (symbol-value refs)))
4194 (setq heads (cdr (symbol-value refs)))
4195 (while heads
4196 (if (memq (mail-header-number (caar heads))
4197 gnus-newsgroup-dormant)
4198 (setq heads (cdr heads))
4199 (setq id (symbol-name refs))
4200 (while (and (setq id (gnus-build-get-header id))
4201 (not (car (gnus-id-to-thread id)))))
4202 (setq heads nil)))))
4203 gnus-newsgroup-dependencies)))
4204
4205 (defsubst gnus-remove-odd-characters (string)
4206 "Translate STRING into something that doesn't contain weird characters."
4207 (mm-subst-char-in-string
4208 ?\r ?\-
4209 (mm-subst-char-in-string
4210 ?\n ?\- string)))
4211
4212 ;; This function has to be called with point after the article number
4213 ;; on the beginning of the line.
4214 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4215 (let ((eol (gnus-point-at-eol))
4216 (buffer (current-buffer))
4217 header references in-reply-to)
4218
4219 ;; overview: [num subject from date id refs chars lines misc]
4220 (unwind-protect
4221 (let (x)
4222 (narrow-to-region (point) eol)
4223 (unless (eobp)
4224 (forward-char))
4225
4226 (setq header
4227 (make-full-mail-header
4228 number ; number
4229 (condition-case () ; subject
4230 (gnus-remove-odd-characters
4231 (funcall gnus-decode-encoded-word-function
4232 (setq x (nnheader-nov-field))))
4233 (error x))
4234 (condition-case () ; from
4235 (gnus-remove-odd-characters
4236 (funcall gnus-decode-encoded-address-function
4237 (setq x (nnheader-nov-field))))
4238 (error x))
4239 (nnheader-nov-field) ; date
4240 (nnheader-nov-read-message-id) ; id
4241 (setq references (nnheader-nov-field)) ; refs
4242 (nnheader-nov-read-integer) ; chars
4243 (nnheader-nov-read-integer) ; lines
4244 (unless (eobp)
4245 (if (looking-at "Xref: ")
4246 (goto-char (match-end 0)))
4247 (nnheader-nov-field)) ; Xref
4248 (nnheader-nov-parse-extra)))) ; extra
4249
4250 (widen))
4251
4252 (when (and (string= references "")
4253 (setq in-reply-to (mail-header-extra header))
4254 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4255 (mail-header-set-references
4256 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4257
4258 (when gnus-alter-header-function
4259 (funcall gnus-alter-header-function header))
4260 (gnus-dependencies-add-header header dependencies force-new)))
4261
4262 (defun gnus-build-get-header (id)
4263 "Look through the buffer of NOV lines and find the header to ID.
4264 Enter this line into the dependencies hash table, and return
4265 the id of the parent article (if any)."
4266 (let ((deps gnus-newsgroup-dependencies)
4267 found header)
4268 (prog1
4269 (save-excursion
4270 (set-buffer nntp-server-buffer)
4271 (let ((case-fold-search nil))
4272 (goto-char (point-min))
4273 (while (and (not found)
4274 (search-forward id nil t))
4275 (beginning-of-line)
4276 (setq found (looking-at
4277 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4278 (regexp-quote id))))
4279 (or found (beginning-of-line 2)))
4280 (when found
4281 (beginning-of-line)
4282 (and
4283 (setq header (gnus-nov-parse-line
4284 (read (current-buffer)) deps))
4285 (gnus-parent-id (mail-header-references header))))))
4286 (when header
4287 (let ((number (mail-header-number header)))
4288 (push number gnus-newsgroup-limit)
4289 (push header gnus-newsgroup-headers)
4290 (if (memq number gnus-newsgroup-unselected)
4291 (progn
4292 (setq gnus-newsgroup-unreads
4293 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4294 number))
4295 (setq gnus-newsgroup-unselected
4296 (delq number gnus-newsgroup-unselected)))
4297 (push number gnus-newsgroup-ancient)))))))
4298
4299 (defun gnus-build-all-threads ()
4300 "Read all the headers."
4301 (let ((gnus-summary-ignore-duplicates t)
4302 (mail-parse-charset gnus-newsgroup-charset)
4303 (dependencies gnus-newsgroup-dependencies)
4304 header article)
4305 (save-excursion
4306 (set-buffer nntp-server-buffer)
4307 (let ((case-fold-search nil))
4308 (goto-char (point-min))
4309 (while (not (eobp))
4310 (ignore-errors
4311 (setq article (read (current-buffer))
4312 header (gnus-nov-parse-line article dependencies)))
4313 (when header
4314 (save-excursion
4315 (set-buffer gnus-summary-buffer)
4316 (push header gnus-newsgroup-headers)
4317 (if (memq (setq article (mail-header-number header))
4318 gnus-newsgroup-unselected)
4319 (progn
4320 (setq gnus-newsgroup-unreads
4321 (gnus-add-to-sorted-list
4322 gnus-newsgroup-unreads article))
4323 (setq gnus-newsgroup-unselected
4324 (delq article gnus-newsgroup-unselected)))
4325 (push article gnus-newsgroup-ancient)))
4326 (forward-line 1)))))))
4327
4328 (defun gnus-summary-update-article-line (article header)
4329 "Update the line for ARTICLE using HEADER."
4330 (let* ((id (mail-header-id header))
4331 (thread (gnus-id-to-thread id)))
4332 (unless thread
4333 (error "Article in no thread"))
4334 ;; Update the thread.
4335 (setcar thread header)
4336 (gnus-summary-goto-subject article)
4337 (let* ((datal (gnus-data-find-list article))
4338 (data (car datal))
4339 (buffer-read-only nil)
4340 (level (gnus-summary-thread-level)))
4341 (gnus-delete-line)
4342 (let ((inserted (- (point)
4343 (progn
4344 (gnus-summary-insert-line
4345 header level nil
4346 (memq article gnus-newsgroup-undownloaded)
4347 (gnus-article-mark article)
4348 (memq article gnus-newsgroup-replied)
4349 (memq article gnus-newsgroup-expirable)
4350 ;; Only insert the Subject string when it's different
4351 ;; from the previous Subject string.
4352 (if (and
4353 gnus-show-threads
4354 (gnus-subject-equal
4355 (condition-case ()
4356 (mail-header-subject
4357 (gnus-data-header
4358 (cadr
4359 (gnus-data-find-list
4360 article
4361 (gnus-data-list t)))))
4362 ;; Error on the side of excessive subjects.
4363 (error ""))
4364 (mail-header-subject header)))
4365 ""
4366 (mail-header-subject header))
4367 nil (cdr (assq article gnus-newsgroup-scored))
4368 (memq article gnus-newsgroup-processable))
4369 (point)))))
4370 (when (cdr datal)
4371 (gnus-data-update-list
4372 (cdr datal)
4373 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4374
4375 (defun gnus-summary-update-article (article &optional iheader)
4376 "Update ARTICLE in the summary buffer."
4377 (set-buffer gnus-summary-buffer)
4378 (let* ((header (gnus-summary-article-header article))
4379 (id (mail-header-id header))
4380 (data (gnus-data-find article))
4381 (thread (gnus-id-to-thread id))
4382 (references (mail-header-references header))
4383 (parent
4384 (gnus-id-to-thread
4385 (or (gnus-parent-id
4386 (when (and references
4387 (not (equal "" references)))
4388 references))
4389 "none")))
4390 (buffer-read-only nil)
4391 (old (car thread)))
4392 (when thread
4393 (unless iheader
4394 (setcar thread nil)
4395 (when parent
4396 (delq thread parent)))
4397 (if (gnus-summary-insert-subject id header)
4398 ;; Set the (possibly) new article number in the data structure.
4399 (gnus-data-set-number data (gnus-id-to-article id))
4400 (setcar thread old)
4401 nil))))
4402
4403 (defun gnus-rebuild-thread (id &optional line)
4404 "Rebuild the thread containing ID.
4405 If LINE, insert the rebuilt thread starting on line LINE."
4406 (let ((buffer-read-only nil)
4407 old-pos current thread data)
4408 (if (not gnus-show-threads)
4409 (setq thread (list (car (gnus-id-to-thread id))))
4410 ;; Get the thread this article is part of.
4411 (setq thread (gnus-remove-thread id)))
4412 (setq old-pos (gnus-point-at-bol))
4413 (setq current (save-excursion
4414 (and (re-search-backward "[\r\n]" nil t)
4415 (gnus-summary-article-number))))
4416 ;; If this is a gathered thread, we have to go some re-gathering.
4417 (when (stringp (car thread))
4418 (let ((subject (car thread))
4419 roots thr)
4420 (setq thread (cdr thread))
4421 (while thread
4422 (unless (memq (setq thr (gnus-id-to-thread
4423 (gnus-root-id
4424 (mail-header-id (caar thread)))))
4425 roots)
4426 (push thr roots))
4427 (setq thread (cdr thread)))
4428 ;; We now have all (unique) roots.
4429 (if (= (length roots) 1)
4430 ;; All the loose roots are now one solid root.
4431 (setq thread (car roots))
4432 (setq thread (cons subject (gnus-sort-threads roots))))))
4433 (let (threads)
4434 ;; We then insert this thread into the summary buffer.
4435 (when line
4436 (goto-char (point-min))
4437 (forward-line (1- line)))
4438 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4439 (if gnus-show-threads
4440 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4441 (gnus-summary-prepare-unthreaded thread))
4442 (setq data (nreverse gnus-newsgroup-data))
4443 (setq threads gnus-newsgroup-threads))
4444 ;; We splice the new data into the data structure.
4445 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4446 ;;!!! then we want to insert at the beginning of the buffer.
4447 ;;!!! That happens to be true with Gnus now, but that may
4448 ;;!!! change in the future. Perhaps.
4449 (gnus-data-enter-list
4450 (if line nil current) data (- (point) old-pos))
4451 (setq gnus-newsgroup-threads
4452 (nconc threads gnus-newsgroup-threads))
4453 (gnus-data-compute-positions))))
4454
4455 (defun gnus-number-to-header (number)
4456 "Return the header for article NUMBER."
4457 (let ((headers gnus-newsgroup-headers))
4458 (while (and headers
4459 (not (= number (mail-header-number (car headers)))))
4460 (pop headers))
4461 (when headers
4462 (car headers))))
4463
4464 (defun gnus-parent-headers (in-headers &optional generation)
4465 "Return the headers of the GENERATIONeth parent of HEADERS."
4466 (unless generation
4467 (setq generation 1))
4468 (let ((parent t)
4469 (headers in-headers)
4470 references)
4471 (while (and parent
4472 (not (zerop generation))
4473 (setq references (mail-header-references headers)))
4474 (setq headers (if (and references
4475 (setq parent (gnus-parent-id references)))
4476 (car (gnus-id-to-thread parent))
4477 nil))
4478 (decf generation))
4479 (and (not (eq headers in-headers))
4480 headers)))
4481
4482 (defun gnus-id-to-thread (id)
4483 "Return the (sub-)thread where ID appears."
4484 (gnus-gethash id gnus-newsgroup-dependencies))
4485
4486 (defun gnus-id-to-article (id)
4487 "Return the article number of ID."
4488 (let ((thread (gnus-id-to-thread id)))
4489 (when (and thread
4490 (car thread))
4491 (mail-header-number (car thread)))))
4492
4493 (defun gnus-id-to-header (id)
4494 "Return the article headers of ID."
4495 (car (gnus-id-to-thread id)))
4496
4497 (defun gnus-article-displayed-root-p (article)
4498 "Say whether ARTICLE is a root(ish) article."
4499 (let ((level (gnus-summary-thread-level article))
4500 (refs (mail-header-references (gnus-summary-article-header article)))
4501 particle)
4502 (cond
4503 ((null level) nil)
4504 ((zerop level) t)
4505 ((null refs) t)
4506 ((null (gnus-parent-id refs)) t)
4507 ((and (= 1 level)
4508 (null (setq particle (gnus-id-to-article
4509 (gnus-parent-id refs))))
4510 (null (gnus-summary-thread-level particle)))))))
4511
4512 (defun gnus-root-id (id)
4513 "Return the id of the root of the thread where ID appears."
4514 (let (last-id prev)
4515 (while (and id (setq prev (car (gnus-id-to-thread id))))
4516 (setq last-id id
4517 id (gnus-parent-id (mail-header-references prev))))
4518 last-id))
4519
4520 (defun gnus-articles-in-thread (thread)
4521 "Return the list of articles in THREAD."
4522 (cons (mail-header-number (car thread))
4523 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4524
4525 (defun gnus-remove-thread (id &optional dont-remove)
4526 "Remove the thread that has ID in it."
4527 (let (headers thread last-id)
4528 ;; First go up in this thread until we find the root.
4529 (setq last-id (gnus-root-id id)
4530 headers (message-flatten-list (gnus-id-to-thread last-id)))
4531 ;; We have now found the real root of this thread. It might have
4532 ;; been gathered into some loose thread, so we have to search
4533 ;; through the threads to find the thread we wanted.
4534 (let ((threads gnus-newsgroup-threads)
4535 sub)
4536 (while threads
4537 (setq sub (car threads))
4538 (if (stringp (car sub))
4539 ;; This is a gathered thread, so we look at the roots
4540 ;; below it to find whether this article is in this
4541 ;; gathered root.
4542 (progn
4543 (setq sub (cdr sub))
4544 (while sub
4545 (when (member (caar sub) headers)
4546 (setq thread (car threads)
4547 threads nil
4548 sub nil))
4549 (setq sub (cdr sub))))
4550 ;; It's an ordinary thread, so we check it.
4551 (when (eq (car sub) (car headers))
4552 (setq thread sub
4553 threads nil)))
4554 (setq threads (cdr threads)))
4555 ;; If this article is in no thread, then it's a root.
4556 (if thread
4557 (unless dont-remove
4558 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4559 (setq thread (gnus-id-to-thread last-id)))
4560 (when thread
4561 (prog1
4562 thread ; We return this thread.
4563 (unless dont-remove
4564 (if (stringp (car thread))
4565 (progn
4566 ;; If we use dummy roots, then we have to remove the
4567 ;; dummy root as well.
4568 (when (eq gnus-summary-make-false-root 'dummy)
4569 ;; We go to the dummy root by going to
4570 ;; the first sub-"thread", and then one line up.
4571 (gnus-summary-goto-article
4572 (mail-header-number (caadr thread)))
4573 (forward-line -1)
4574 (gnus-delete-line)
4575 (gnus-data-compute-positions))
4576 (setq thread (cdr thread))
4577 (while thread
4578 (gnus-remove-thread-1 (car thread))
4579 (setq thread (cdr thread))))
4580 (gnus-remove-thread-1 thread))))))))
4581
4582 (defun gnus-remove-thread-1 (thread)
4583 "Remove the thread THREAD recursively."
4584 (let ((number (mail-header-number (pop thread)))
4585 d)
4586 (setq thread (reverse thread))
4587 (while thread
4588 (gnus-remove-thread-1 (pop thread)))
4589 (when (setq d (gnus-data-find number))
4590 (goto-char (gnus-data-pos d))
4591 (gnus-summary-show-thread)
4592 (gnus-data-remove
4593 number
4594 (- (gnus-point-at-bol)
4595 (prog1
4596 (1+ (gnus-point-at-eol))
4597 (gnus-delete-line)))))))
4598
4599 (defun gnus-sort-threads-recursive (threads func)
4600 (sort (mapcar (lambda (thread)
4601 (cons (car thread)
4602 (and (cdr thread)
4603 (gnus-sort-threads-recursive (cdr thread) func))))
4604 threads) func))
4605
4606 (defun gnus-sort-threads-loop (threads func)
4607 (let* ((superthread (cons nil threads))
4608 (stack (list (cons superthread threads)))
4609 remaining-threads thread)
4610 (while stack
4611 (setq remaining-threads (cdr (car stack)))
4612 (if remaining-threads
4613 (progn (setq thread (car remaining-threads))
4614 (setcdr (car stack) (cdr remaining-threads))
4615 (if (cdr thread)
4616 (push (cons thread (cdr thread)) stack)))
4617 (setq thread (caar stack))
4618 (setcdr thread (sort (cdr thread) func))
4619 (pop stack)))
4620 (cdr superthread)))
4621
4622 (defun gnus-sort-threads (threads)
4623 "Sort THREADS."
4624 (if (not gnus-thread-sort-functions)
4625 threads
4626 (gnus-message 8 "Sorting threads...")
4627 (prog1
4628 (condition-case nil
4629 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4630 (gnus-sort-threads-recursive
4631 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4632 ;; Even after binding max-lisp-eval-depth, the recursive
4633 ;; sorter might fail for very long threads. In that case,
4634 ;; try using a (less well-tested) non-recursive sorter.
4635 (error (gnus-sort-threads-loop
4636 threads (gnus-make-sort-function
4637 gnus-thread-sort-functions))))
4638 (gnus-message 8 "Sorting threads...done"))))
4639
4640 (defun gnus-sort-articles (articles)
4641 "Sort ARTICLES."
4642 (when gnus-article-sort-functions
4643 (gnus-message 7 "Sorting articles...")
4644 (prog1
4645 (setq gnus-newsgroup-headers
4646 (sort articles (gnus-make-sort-function
4647 gnus-article-sort-functions)))
4648 (gnus-message 7 "Sorting articles...done"))))
4649
4650 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4651 (defmacro gnus-thread-header (thread)
4652 "Return header of first article in THREAD.
4653 Note that THREAD must never, ever be anything else than a variable -
4654 using some other form will lead to serious barfage."
4655 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4656 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4657 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4658 (vector thread) 2))
4659
4660 (defsubst gnus-article-sort-by-number (h1 h2)
4661 "Sort articles by article number."
4662 (< (mail-header-number h1)
4663 (mail-header-number h2)))
4664
4665 (defun gnus-thread-sort-by-number (h1 h2)
4666 "Sort threads by root article number."
4667 (gnus-article-sort-by-number
4668 (gnus-thread-header h1) (gnus-thread-header h2)))
4669
4670 (defsubst gnus-article-sort-by-random (h1 h2)
4671 "Sort articles randomly."
4672 (zerop (random 2)))
4673
4674 (defun gnus-thread-sort-by-random (h1 h2)
4675 "Sort threads randomly."
4676 (gnus-article-sort-by-random
4677 (gnus-thread-header h1) (gnus-thread-header h2)))
4678
4679 (defsubst gnus-article-sort-by-lines (h1 h2)
4680 "Sort articles by article Lines header."
4681 (< (mail-header-lines h1)
4682 (mail-header-lines h2)))
4683
4684 (defun gnus-thread-sort-by-lines (h1 h2)
4685 "Sort threads by root article Lines header."
4686 (gnus-article-sort-by-lines
4687 (gnus-thread-header h1) (gnus-thread-header h2)))
4688
4689 (defsubst gnus-article-sort-by-chars (h1 h2)
4690 "Sort articles by octet length."
4691 (< (mail-header-chars h1)
4692 (mail-header-chars h2)))
4693
4694 (defun gnus-thread-sort-by-chars (h1 h2)
4695 "Sort threads by root article octet length."
4696 (gnus-article-sort-by-chars
4697 (gnus-thread-header h1) (gnus-thread-header h2)))
4698
4699 (defsubst gnus-article-sort-by-author (h1 h2)
4700 "Sort articles by root author."
4701 (gnus-string<
4702 (let ((extract (funcall
4703 gnus-extract-address-components
4704 (mail-header-from h1))))
4705 (or (car extract) (cadr extract) ""))
4706 (let ((extract (funcall
4707 gnus-extract-address-components
4708 (mail-header-from h2))))
4709 (or (car extract) (cadr extract) ""))))
4710
4711 (defun gnus-thread-sort-by-author (h1 h2)
4712 "Sort threads by root author."
4713 (gnus-article-sort-by-author
4714 (gnus-thread-header h1) (gnus-thread-header h2)))
4715
4716 (defsubst gnus-article-sort-by-subject (h1 h2)
4717 "Sort articles by root subject."
4718 (gnus-string<
4719 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4720 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4721
4722 (defun gnus-thread-sort-by-subject (h1 h2)
4723 "Sort threads by root subject."
4724 (gnus-article-sort-by-subject
4725 (gnus-thread-header h1) (gnus-thread-header h2)))
4726
4727 (defsubst gnus-article-sort-by-date (h1 h2)
4728 "Sort articles by root article date."
4729 (time-less-p
4730 (gnus-date-get-time (mail-header-date h1))
4731 (gnus-date-get-time (mail-header-date h2))))
4732
4733 (defun gnus-thread-sort-by-date (h1 h2)
4734 "Sort threads by root article date."
4735 (gnus-article-sort-by-date
4736 (gnus-thread-header h1) (gnus-thread-header h2)))
4737
4738 (defsubst gnus-article-sort-by-score (h1 h2)
4739 "Sort articles by root article score.
4740 Unscored articles will be counted as having a score of zero."
4741 (> (or (cdr (assq (mail-header-number h1)
4742 gnus-newsgroup-scored))
4743 gnus-summary-default-score 0)
4744 (or (cdr (assq (mail-header-number h2)
4745 gnus-newsgroup-scored))
4746 gnus-summary-default-score 0)))
4747
4748 (defun gnus-thread-sort-by-score (h1 h2)
4749 "Sort threads by root article score."
4750 (gnus-article-sort-by-score
4751 (gnus-thread-header h1) (gnus-thread-header h2)))
4752
4753 (defun gnus-thread-sort-by-total-score (h1 h2)
4754 "Sort threads by the sum of all scores in the thread.
4755 Unscored articles will be counted as having a score of zero."
4756 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4757
4758 (defun gnus-thread-total-score (thread)
4759 ;; This function find the total score of THREAD.
4760 (cond
4761 ((null thread)
4762 0)
4763 ((consp thread)
4764 (if (stringp (car thread))
4765 (apply gnus-thread-score-function 0
4766 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4767 (gnus-thread-total-score-1 thread)))
4768 (t
4769 (gnus-thread-total-score-1 (list thread)))))
4770
4771 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4772 "Sort threads such that the thread with the most recently arrived article comes first."
4773 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4774
4775 (defun gnus-thread-highest-number (thread)
4776 "Return the highest article number in THREAD."
4777 (apply 'max (mapcar (lambda (header)
4778 (mail-header-number header))
4779 (message-flatten-list thread))))
4780
4781 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4782 "Sort threads such that the thread with the most recently dated article comes first."
4783 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4784
4785 (defun gnus-thread-latest-date (thread)
4786 "Return the highest article date in THREAD."
4787 (let ((previous-time 0))
4788 (apply 'max
4789 (mapcar
4790 (lambda (header)
4791 (setq previous-time
4792 (condition-case ()
4793 (time-to-seconds (mail-header-parse-date
4794 (mail-header-date header)))
4795 (error previous-time))))
4796 (sort
4797 (message-flatten-list thread)
4798 (lambda (h1 h2)
4799 (< (mail-header-number h1)
4800 (mail-header-number h2))))))))
4801
4802 (defun gnus-thread-total-score-1 (root)
4803 ;; This function find the total score of the thread below ROOT.
4804 (setq root (car root))
4805 (apply gnus-thread-score-function
4806 (or (append
4807 (mapcar 'gnus-thread-total-score
4808 (cdr (gnus-id-to-thread (mail-header-id root))))
4809 (when (> (mail-header-number root) 0)
4810 (list (or (cdr (assq (mail-header-number root)
4811 gnus-newsgroup-scored))
4812 gnus-summary-default-score 0))))
4813 (list gnus-summary-default-score)
4814 '(0))))
4815
4816 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4817 (defvar gnus-tmp-prev-subject nil)
4818 (defvar gnus-tmp-false-parent nil)
4819 (defvar gnus-tmp-root-expunged nil)
4820 (defvar gnus-tmp-dummy-line nil)
4821
4822 (eval-when-compile (defvar gnus-tmp-header))
4823 (defun gnus-extra-header (type &optional header)
4824 "Return the extra header of TYPE."
4825 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4826 ""))
4827
4828 (defvar gnus-tmp-thread-tree-header-string "")
4829
4830 (defcustom gnus-sum-thread-tree-root "> "
4831 "With %B spec, used for the root of a thread.
4832 If nil, use subject instead."
4833 :version "22.1"
4834 :type '(radio (const :format "%v " nil) string)
4835 :group 'gnus-thread)
4836 (defcustom gnus-sum-thread-tree-false-root "> "
4837 "With %B spec, used for a false root of a thread.
4838 If nil, use subject instead."
4839 :version "22.1"
4840 :type '(radio (const :format "%v " nil) string)
4841 :group 'gnus-thread)
4842 (defcustom gnus-sum-thread-tree-single-indent ""
4843 "With %B spec, used for a thread with just one message.
4844 If nil, use subject instead."
4845 :version "22.1"
4846 :type '(radio (const :format "%v " nil) string)
4847 :group 'gnus-thread)
4848 (defcustom gnus-sum-thread-tree-vertical "| "
4849 "With %B spec, used for drawing a vertical line."
4850 :version "22.1"
4851 :type 'string
4852 :group 'gnus-thread)
4853 (defcustom gnus-sum-thread-tree-indent " "
4854 "With %B spec, used for indenting."
4855 :version "22.1"
4856 :type 'string
4857 :group 'gnus-thread)
4858 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4859 "With %B spec, used for a leaf with brothers."
4860 :version "22.1"
4861 :type 'string
4862 :group 'gnus-thread)
4863 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4864 "With %B spec, used for a leaf without brothers."
4865 :version "22.1"
4866 :type 'string
4867 :group 'gnus-thread)
4868
4869 (defun gnus-summary-prepare-threads (threads)
4870 "Prepare summary buffer from THREADS and indentation LEVEL.
4871 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4872 or a straight list of headers."
4873 (gnus-message 7 "Generating summary...")
4874
4875 (setq gnus-newsgroup-threads threads)
4876 (beginning-of-line)
4877
4878 (let ((gnus-tmp-level 0)
4879 (default-score (or gnus-summary-default-score 0))
4880 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4881 (building-line-count gnus-summary-display-while-building)
4882 (building-count (integerp gnus-summary-display-while-building))
4883 thread number subject stack state gnus-tmp-gathered beg-match
4884 new-roots gnus-tmp-new-adopts thread-end simp-subject
4885 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4886 gnus-tmp-replied gnus-tmp-subject-or-nil
4887 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4888 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4889 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4890 tree-stack)
4891
4892 (setq gnus-tmp-prev-subject nil
4893 gnus-tmp-thread-tree-header-string "")
4894
4895 (if (vectorp (car threads))
4896 ;; If this is a straight (sic) list of headers, then a
4897 ;; threaded summary display isn't required, so we just create
4898 ;; an unthreaded one.
4899 (gnus-summary-prepare-unthreaded threads)
4900
4901 ;; Do the threaded display.
4902
4903 (if gnus-summary-display-while-building
4904 (switch-to-buffer (buffer-name)))
4905 (while (or threads stack gnus-tmp-new-adopts new-roots)
4906
4907 (if (and (= gnus-tmp-level 0)
4908 (or (not stack)
4909 (= (caar stack) 0))
4910 (not gnus-tmp-false-parent)
4911 (or gnus-tmp-new-adopts new-roots))
4912 (if gnus-tmp-new-adopts
4913 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4914 thread (list (car gnus-tmp-new-adopts))
4915 gnus-tmp-header (caar thread)
4916 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4917 (when new-roots
4918 (setq thread (list (car new-roots))
4919 gnus-tmp-header (caar thread)
4920 new-roots (cdr new-roots))))
4921
4922 (if threads
4923 ;; If there are some threads, we do them before the
4924 ;; threads on the stack.
4925 (setq thread threads
4926 gnus-tmp-header (caar thread))
4927 ;; There were no current threads, so we pop something off
4928 ;; the stack.
4929 (setq state (car stack)
4930 gnus-tmp-level (car state)
4931 tree-stack (cadr state)
4932 thread (caddr state)
4933 stack (cdr stack)
4934 gnus-tmp-header (caar thread))))
4935
4936 (setq gnus-tmp-false-parent nil)
4937 (setq gnus-tmp-root-expunged nil)
4938 (setq thread-end nil)
4939
4940 (if (stringp gnus-tmp-header)
4941 ;; The header is a dummy root.
4942 (cond
4943 ((eq gnus-summary-make-false-root 'adopt)
4944 ;; We let the first article adopt the rest.
4945 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4946 (cddar thread)))
4947 (setq gnus-tmp-gathered
4948 (nconc (mapcar
4949 (lambda (h) (mail-header-number (car h)))
4950 (cddar thread))
4951 gnus-tmp-gathered))
4952 (setq thread (cons (list (caar thread)
4953 (cadar thread))
4954 (cdr thread)))
4955 (setq gnus-tmp-level -1
4956 gnus-tmp-false-parent t))
4957 ((eq gnus-summary-make-false-root 'empty)
4958 ;; We print adopted articles with empty subject fields.
4959 (setq gnus-tmp-gathered
4960 (nconc (mapcar
4961 (lambda (h) (mail-header-number (car h)))
4962 (cddar thread))
4963 gnus-tmp-gathered))
4964 (setq gnus-tmp-level -1))
4965 ((eq gnus-summary-make-false-root 'dummy)
4966 ;; We remember that we probably want to output a dummy
4967 ;; root.
4968 (setq gnus-tmp-dummy-line gnus-tmp-header)
4969 (setq gnus-tmp-prev-subject gnus-tmp-header))
4970 (t
4971 ;; We do not make a root for the gathered
4972 ;; sub-threads at all.
4973 (setq gnus-tmp-level -1)))
4974
4975 (setq number (mail-header-number gnus-tmp-header)
4976 subject (mail-header-subject gnus-tmp-header)
4977 simp-subject (gnus-simplify-subject-fully subject))
4978
4979 (cond
4980 ;; If the thread has changed subject, we might want to make
4981 ;; this subthread into a root.
4982 ((and (null gnus-thread-ignore-subject)
4983 (not (zerop gnus-tmp-level))
4984 gnus-tmp-prev-subject
4985 (not (string= gnus-tmp-prev-subject simp-subject)))
4986 (setq new-roots (nconc new-roots (list (car thread)))
4987 thread-end t
4988 gnus-tmp-header nil))
4989 ;; If the article lies outside the current limit,
4990 ;; then we do not display it.
4991 ((not (memq number gnus-newsgroup-limit))
4992 (setq gnus-tmp-gathered
4993 (nconc (mapcar
4994 (lambda (h) (mail-header-number (car h)))
4995 (cdar thread))
4996 gnus-tmp-gathered))
4997 (setq gnus-tmp-new-adopts (if (cdar thread)
4998 (append gnus-tmp-new-adopts
4999 (cdar thread))
5000 gnus-tmp-new-adopts)
5001 thread-end t
5002 gnus-tmp-header nil)
5003 (when (zerop gnus-tmp-level)
5004 (setq gnus-tmp-root-expunged t)))
5005 ;; Perhaps this article is to be marked as read?
5006 ((and gnus-summary-mark-below
5007 (< (or (cdr (assq number gnus-newsgroup-scored))
5008 default-score)
5009 gnus-summary-mark-below)
5010 ;; Don't touch sparse articles.
5011 (not (gnus-summary-article-sparse-p number))
5012 (not (gnus-summary-article-ancient-p number)))
5013 (setq gnus-newsgroup-unreads
5014 (delq number gnus-newsgroup-unreads))
5015 (if gnus-newsgroup-auto-expire
5016 (setq gnus-newsgroup-expirable
5017 (gnus-add-to-sorted-list
5018 gnus-newsgroup-expirable number))
5019 (push (cons number gnus-low-score-mark)
5020 gnus-newsgroup-reads))))
5021
5022 (when gnus-tmp-header
5023 ;; We may have an old dummy line to output before this
5024 ;; article.
5025 (when (and gnus-tmp-dummy-line
5026 (gnus-subject-equal
5027 gnus-tmp-dummy-line
5028 (mail-header-subject gnus-tmp-header)))
5029 (gnus-summary-insert-dummy-line
5030 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5031 (setq gnus-tmp-dummy-line nil))
5032
5033 ;; Compute the mark.
5034 (setq gnus-tmp-unread (gnus-article-mark number))
5035
5036 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5037 gnus-tmp-header gnus-tmp-level)
5038 gnus-newsgroup-data)
5039
5040 ;; Actually insert the line.
5041 (setq
5042 gnus-tmp-subject-or-nil
5043 (cond
5044 ((and gnus-thread-ignore-subject
5045 gnus-tmp-prev-subject
5046 (not (string= gnus-tmp-prev-subject simp-subject)))
5047 subject)
5048 ((zerop gnus-tmp-level)
5049 (if (and (eq gnus-summary-make-false-root 'empty)
5050 (memq number gnus-tmp-gathered)
5051 gnus-tmp-prev-subject
5052 (string= gnus-tmp-prev-subject simp-subject))
5053 gnus-summary-same-subject
5054 subject))
5055 (t gnus-summary-same-subject)))
5056 (if (and (eq gnus-summary-make-false-root 'adopt)
5057 (= gnus-tmp-level 1)
5058 (memq number gnus-tmp-gathered))
5059 (setq gnus-tmp-opening-bracket ?\<
5060 gnus-tmp-closing-bracket ?\>)
5061 (setq gnus-tmp-opening-bracket ?\[
5062 gnus-tmp-closing-bracket ?\]))
5063 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5064 (gnus-make-thread-indent-array
5065 (max (* 2 (length gnus-thread-indent-array))
5066 gnus-tmp-level)))
5067 (setq
5068 gnus-tmp-indentation
5069 (aref gnus-thread-indent-array gnus-tmp-level)
5070 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5071 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5072 gnus-summary-default-score 0)
5073 gnus-tmp-score-char
5074 (if (or (null gnus-summary-default-score)
5075 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5076 gnus-summary-zcore-fuzz))
5077 ? ;Whitespace
5078 (if (< gnus-tmp-score gnus-summary-default-score)
5079 gnus-score-below-mark gnus-score-over-mark))
5080 gnus-tmp-replied
5081 (cond ((memq number gnus-newsgroup-processable)
5082 gnus-process-mark)
5083 ((memq number gnus-newsgroup-cached)
5084 gnus-cached-mark)
5085 ((memq number gnus-newsgroup-replied)
5086 gnus-replied-mark)
5087 ((memq number gnus-newsgroup-forwarded)
5088 gnus-forwarded-mark)
5089 ((memq number gnus-newsgroup-saved)
5090 gnus-saved-mark)
5091 ((memq number gnus-newsgroup-recent)
5092 gnus-recent-mark)
5093 ((memq number gnus-newsgroup-unseen)
5094 gnus-unseen-mark)
5095 (t gnus-no-mark))
5096 gnus-tmp-downloaded
5097 (cond ((memq number gnus-newsgroup-undownloaded)
5098 gnus-undownloaded-mark)
5099 (gnus-newsgroup-agentized
5100 gnus-downloaded-mark)
5101 (t
5102 gnus-no-mark))
5103 gnus-tmp-from (mail-header-from gnus-tmp-header)
5104 gnus-tmp-name
5105 (cond
5106 ((string-match "<[^>]+> *$" gnus-tmp-from)
5107 (setq beg-match (match-beginning 0))
5108 (or (and (string-match "^\".+\"" gnus-tmp-from)
5109 (substring gnus-tmp-from 1 (1- (match-end 0))))
5110 (substring gnus-tmp-from 0 beg-match)))
5111 ((string-match "(.+)" gnus-tmp-from)
5112 (substring gnus-tmp-from
5113 (1+ (match-beginning 0)) (1- (match-end 0))))
5114 (t gnus-tmp-from))
5115
5116 ;; Do the %B string
5117 gnus-tmp-thread-tree-header-string
5118 (cond
5119 ((not gnus-show-threads) "")
5120 ((zerop gnus-tmp-level)
5121 (cond ((cdar thread)
5122 (or gnus-sum-thread-tree-root subject))
5123 (gnus-tmp-new-adopts
5124 (or gnus-sum-thread-tree-false-root subject))
5125 (t
5126 (or gnus-sum-thread-tree-single-indent subject))))
5127 (t
5128 (concat (apply 'concat
5129 (mapcar (lambda (item)
5130 (if (= item 1)
5131 gnus-sum-thread-tree-vertical
5132 gnus-sum-thread-tree-indent))
5133 (cdr (reverse tree-stack))))
5134 (if (nth 1 thread)
5135 gnus-sum-thread-tree-leaf-with-other
5136 gnus-sum-thread-tree-single-leaf)))))
5137 (when (string= gnus-tmp-name "")
5138 (setq gnus-tmp-name gnus-tmp-from))
5139 (unless (numberp gnus-tmp-lines)
5140 (setq gnus-tmp-lines -1))
5141 (if (= gnus-tmp-lines -1)
5142 (setq gnus-tmp-lines "?")
5143 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5144 (gnus-put-text-property
5145 (point)
5146 (progn (eval gnus-summary-line-format-spec) (point))
5147 'gnus-number number)
5148 (when gnus-visual-p
5149 (forward-line -1)
5150 (gnus-run-hooks 'gnus-summary-update-hook)
5151 (forward-line 1))
5152
5153 (setq gnus-tmp-prev-subject simp-subject)))
5154
5155 (when (nth 1 thread)
5156 (push (list (max 0 gnus-tmp-level)
5157 (copy-sequence tree-stack)
5158 (nthcdr 1 thread))
5159 stack))
5160 (push (if (nth 1 thread) 1 0) tree-stack)
5161 (incf gnus-tmp-level)
5162 (setq threads (if thread-end nil (cdar thread)))
5163 (if gnus-summary-display-while-building
5164 (if building-count
5165 (progn
5166 ;; use a set frequency
5167 (setq building-line-count (1- building-line-count))
5168 (when (= building-line-count 0)
5169 (sit-for 0)
5170 (setq building-line-count
5171 gnus-summary-display-while-building)))
5172 ;; always
5173 (sit-for 0)))
5174 (unless threads
5175 (setq gnus-tmp-level 0)))))
5176 (gnus-message 7 "Generating summary...done"))
5177
5178 (defun gnus-summary-prepare-unthreaded (headers)
5179 "Generate an unthreaded summary buffer based on HEADERS."
5180 (let (header number mark)
5181
5182 (beginning-of-line)
5183
5184 (while headers
5185 ;; We may have to root out some bad articles...
5186 (when (memq (setq number (mail-header-number
5187 (setq header (pop headers))))
5188 gnus-newsgroup-limit)
5189 ;; Mark article as read when it has a low score.
5190 (when (and gnus-summary-mark-below
5191 (< (or (cdr (assq number gnus-newsgroup-scored))
5192 gnus-summary-default-score 0)
5193 gnus-summary-mark-below)
5194 (not (gnus-summary-article-ancient-p number)))
5195 (setq gnus-newsgroup-unreads
5196 (delq number gnus-newsgroup-unreads))
5197 (if gnus-newsgroup-auto-expire
5198 (push number gnus-newsgroup-expirable)
5199 (push (cons number gnus-low-score-mark)
5200 gnus-newsgroup-reads)))
5201
5202 (setq mark (gnus-article-mark number))
5203 (push (gnus-data-make number mark (1+ (point)) header 0)
5204 gnus-newsgroup-data)
5205 (gnus-summary-insert-line
5206 header 0 number
5207 (memq number gnus-newsgroup-undownloaded)
5208 mark (memq number gnus-newsgroup-replied)
5209 (memq number gnus-newsgroup-expirable)
5210 (mail-header-subject header) nil
5211 (cdr (assq number gnus-newsgroup-scored))
5212 (memq number gnus-newsgroup-processable))))))
5213
5214 (defun gnus-summary-remove-list-identifiers ()
5215 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5216 (let ((regexp (if (consp gnus-list-identifiers)
5217 (mapconcat 'identity gnus-list-identifiers " *\\|")
5218 gnus-list-identifiers))
5219 changed subject)
5220 (when regexp
5221 (dolist (header gnus-newsgroup-headers)
5222 (setq subject (mail-header-subject header)
5223 changed nil)
5224 (while (string-match
5225 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5226 subject)
5227 (setq subject
5228 (concat (substring subject 0 (match-beginning 2))
5229 (substring subject (match-end 0)))
5230 changed t))
5231 (when (and changed
5232 (string-match
5233 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5234 (setq subject
5235 (concat (substring subject 0 (match-beginning 1))
5236 (substring subject (match-end 1)))))
5237 (when changed
5238 (mail-header-set-subject header subject))))))
5239
5240 (defun gnus-fetch-headers (articles)
5241 "Fetch headers of ARTICLES."
5242 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5243 (gnus-message 5 "Fetching headers for %s..." name)
5244 (prog1
5245 (if (eq 'nov
5246 (setq gnus-headers-retrieved-by
5247 (gnus-retrieve-headers
5248 articles gnus-newsgroup-name
5249 ;; We might want to fetch old headers, but
5250 ;; not if there is only 1 article.
5251 (and (or (and
5252 (not (eq gnus-fetch-old-headers 'some))
5253 (not (numberp gnus-fetch-old-headers)))
5254 (> (length articles) 1))
5255 gnus-fetch-old-headers))))
5256 (gnus-get-newsgroup-headers-xover
5257 articles nil nil gnus-newsgroup-name t)
5258 (gnus-get-newsgroup-headers))
5259 (gnus-message 5 "Fetching headers for %s...done" name))))
5260
5261 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5262 "Select newsgroup GROUP.
5263 If READ-ALL is non-nil, all articles in the group are selected.
5264 If SELECT-ARTICLES, only select those articles from GROUP."
5265 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5266 ;;!!! Dirty hack; should be removed.
5267 (gnus-summary-ignore-duplicates
5268 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5269 t
5270 gnus-summary-ignore-duplicates))
5271 (info (nth 2 entry))
5272 articles fetched-articles cached)
5273
5274 (unless (gnus-check-server
5275 (set (make-local-variable 'gnus-current-select-method)
5276 (gnus-find-method-for-group group)))
5277 (error "Couldn't open server"))
5278
5279 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5280 (gnus-activate-group group) ; Or we can activate it...
5281 (progn ; Or we bug out.
5282 (when (equal major-mode 'gnus-summary-mode)
5283 (gnus-kill-buffer (current-buffer)))
5284 (error "Couldn't activate group %s: %s"
5285 (gnus-group-decoded-name group) (gnus-status-message group))))
5286
5287 (unless (gnus-request-group group t)
5288 (when (equal major-mode 'gnus-summary-mode)
5289 (gnus-kill-buffer (current-buffer)))
5290 (error "Couldn't request group %s: %s"
5291 (gnus-group-decoded-name group) (gnus-status-message group)))
5292
5293 (when gnus-agent
5294 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5295
5296 (setq gnus-summary-use-undownloaded-faces
5297 (gnus-agent-find-parameter
5298 group
5299 'agent-enable-undownloaded-faces)))
5300
5301 (setq gnus-newsgroup-name group
5302 gnus-newsgroup-unselected nil
5303 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5304
5305 (let ((display (gnus-group-find-parameter group 'display)))
5306 (setq gnus-newsgroup-display
5307 (cond
5308 ((not (zerop (or (car-safe read-all) 0)))
5309 ;; The user entered the group with C-u SPC/RET, let's show
5310 ;; all articles.
5311 'gnus-not-ignore)
5312 ((eq display 'all)
5313 'gnus-not-ignore)
5314 ((arrayp display)
5315 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5316 ((numberp display)
5317 ;; The following is probably the "correct" solution, but
5318 ;; it makes Gnus fetch all headers and then limit the
5319 ;; articles (which is slow), so instead we hack the
5320 ;; select-articles parameter instead. -- Simon Josefsson
5321 ;; <jas@kth.se>
5322 ;;
5323 ;; (gnus-byte-compile
5324 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5325 ;; display)))))
5326 (setq select-articles
5327 (gnus-uncompress-range
5328 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5329 (if (> tmp 0)
5330 tmp
5331 1))
5332 (cdr (gnus-active group)))))
5333 nil)
5334 (t
5335 nil))))
5336
5337 (gnus-summary-setup-default-charset)
5338
5339 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5340 (when (gnus-virtual-group-p group)
5341 (setq cached gnus-newsgroup-cached))
5342
5343 (setq gnus-newsgroup-unreads
5344 (gnus-sorted-ndifference
5345 (gnus-sorted-ndifference gnus-newsgroup-unreads
5346 gnus-newsgroup-marked)
5347 gnus-newsgroup-dormant))
5348
5349 (setq gnus-newsgroup-processable nil)
5350
5351 (gnus-update-read-articles group gnus-newsgroup-unreads)
5352
5353 ;; Adjust and set lists of article marks.
5354 (when info
5355 (gnus-adjust-marked-articles info))
5356 (if (setq articles select-articles)
5357 (setq gnus-newsgroup-unselected
5358 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5359 (setq articles (gnus-articles-to-read group read-all)))
5360
5361 (cond
5362 ((null articles)
5363 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5364 'quit)
5365 ((eq articles 0) nil)
5366 (t
5367 ;; Init the dependencies hash table.
5368 (setq gnus-newsgroup-dependencies
5369 (gnus-make-hashtable (length articles)))
5370 (gnus-set-global-variables)
5371 ;; Retrieve the headers and read them in.
5372
5373 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5374
5375 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5376 (when cached
5377 (setq gnus-newsgroup-cached cached))
5378
5379 ;; Suppress duplicates?
5380 (when gnus-suppress-duplicates
5381 (gnus-dup-suppress-articles))
5382
5383 ;; Set the initial limit.
5384 (setq gnus-newsgroup-limit (copy-sequence articles))
5385 ;; Remove canceled articles from the list of unread articles.
5386 (setq fetched-articles
5387 (mapcar (lambda (headers) (mail-header-number headers))
5388 gnus-newsgroup-headers))
5389 (setq gnus-newsgroup-articles fetched-articles)
5390 (setq gnus-newsgroup-unreads
5391 (gnus-sorted-nintersection
5392 gnus-newsgroup-unreads fetched-articles))
5393 (gnus-compute-unseen-list)
5394
5395 ;; Removed marked articles that do not exist.
5396 (gnus-update-missing-marks
5397 (gnus-sorted-difference articles fetched-articles))
5398 ;; We might want to build some more threads first.
5399 (when (and gnus-fetch-old-headers
5400 (eq gnus-headers-retrieved-by 'nov))
5401 (if (eq gnus-fetch-old-headers 'invisible)
5402 (gnus-build-all-threads)
5403 (gnus-build-old-threads)))
5404 ;; Let the Gnus agent mark articles as read.
5405 (when gnus-agent
5406 (gnus-agent-get-undownloaded-list))
5407 ;; Remove list identifiers from subject
5408 (when gnus-list-identifiers
5409 (gnus-summary-remove-list-identifiers))
5410 ;; Check whether auto-expire is to be done in this group.
5411 (setq gnus-newsgroup-auto-expire
5412 (gnus-group-auto-expirable-p group))
5413 ;; Set up the article buffer now, if necessary.
5414 (unless gnus-single-article-buffer
5415 (gnus-article-setup-buffer))
5416 ;; First and last article in this newsgroup.
5417 (when gnus-newsgroup-headers
5418 (setq gnus-newsgroup-begin
5419 (mail-header-number (car gnus-newsgroup-headers))
5420 gnus-newsgroup-end
5421 (mail-header-number
5422 (gnus-last-element gnus-newsgroup-headers))))
5423 ;; GROUP is successfully selected.
5424 (or gnus-newsgroup-headers t)))))
5425
5426 (defun gnus-compute-unseen-list ()
5427 ;; The `seen' marks are treated specially.
5428 (if (not gnus-newsgroup-seen)
5429 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5430 (setq gnus-newsgroup-unseen
5431 (gnus-inverse-list-range-intersection
5432 gnus-newsgroup-articles gnus-newsgroup-seen))))
5433
5434 (defun gnus-summary-display-make-predicate (display)
5435 (require 'gnus-agent)
5436 (when (= (length display) 1)
5437 (setq display (car display)))
5438 (unless gnus-summary-display-cache
5439 (dolist (elem (append '((unread . unread)
5440 (read . read)
5441 (unseen . unseen))
5442 gnus-article-mark-lists))
5443 (push (cons (cdr elem)
5444 (gnus-byte-compile
5445 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5446 gnus-summary-display-cache)))
5447 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5448 (gnus-category-predicate-cache gnus-summary-display-cache))
5449 (gnus-get-predicate display)))
5450
5451 ;; Uses the dynamically bound `number' variable.
5452 (eval-when-compile
5453 (defvar number))
5454 (defun gnus-article-marked-p (type &optional article)
5455 (let ((article (or article number)))
5456 (cond
5457 ((eq type 'tick)
5458 (memq article gnus-newsgroup-marked))
5459 ((eq type 'spam)
5460 (memq article gnus-newsgroup-spam-marked))
5461 ((eq type 'unsend)
5462 (memq article gnus-newsgroup-unsendable))
5463 ((eq type 'undownload)
5464 (memq article gnus-newsgroup-undownloaded))
5465 ((eq type 'download)
5466 (memq article gnus-newsgroup-downloadable))
5467 ((eq type 'unread)
5468 (memq article gnus-newsgroup-unreads))
5469 ((eq type 'read)
5470 (memq article gnus-newsgroup-reads))
5471 ((eq type 'dormant)
5472 (memq article gnus-newsgroup-dormant) )
5473 ((eq type 'expire)
5474 (memq article gnus-newsgroup-expirable))
5475 ((eq type 'reply)
5476 (memq article gnus-newsgroup-replied))
5477 ((eq type 'killed)
5478 (memq article gnus-newsgroup-killed))
5479 ((eq type 'bookmark)
5480 (assq article gnus-newsgroup-bookmarks))
5481 ((eq type 'score)
5482 (assq article gnus-newsgroup-scored))
5483 ((eq type 'save)
5484 (memq article gnus-newsgroup-saved))
5485 ((eq type 'cache)
5486 (memq article gnus-newsgroup-cached))
5487 ((eq type 'forward)
5488 (memq article gnus-newsgroup-forwarded))
5489 ((eq type 'seen)
5490 (not (memq article gnus-newsgroup-unseen)))
5491 ((eq type 'recent)
5492 (memq article gnus-newsgroup-recent))
5493 (t t))))
5494
5495 (defun gnus-articles-to-read (group &optional read-all)
5496 "Find out what articles the user wants to read."
5497 (let* ((articles
5498 ;; Select all articles if `read-all' is non-nil, or if there
5499 ;; are no unread articles.
5500 (if (or read-all
5501 (and (zerop (length gnus-newsgroup-marked))
5502 (zerop (length gnus-newsgroup-unreads)))
5503 ;; Fetch all if the predicate is non-nil.
5504 gnus-newsgroup-display)
5505 ;; We want to select the headers for all the articles in
5506 ;; the group, so we select either all the active
5507 ;; articles in the group, or (if that's nil), the
5508 ;; articles in the cache.
5509 (or
5510 (if gnus-newsgroup-maximum-articles
5511 (let ((active (gnus-active group)))
5512 (gnus-uncompress-range
5513 (cons (max (car active)
5514 (- (cdr active)
5515 gnus-newsgroup-maximum-articles
5516 -1))
5517 (cdr active))))
5518 (gnus-uncompress-range (gnus-active group)))
5519 (gnus-cache-articles-in-group group))
5520 ;; Select only the "normal" subset of articles.
5521 (gnus-sorted-nunion
5522 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5523 gnus-newsgroup-unreads)))
5524 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5525 (scored (length scored-list))
5526 (number (length articles))
5527 (marked (+ (length gnus-newsgroup-marked)
5528 (length gnus-newsgroup-dormant)))
5529 (select
5530 (cond
5531 ((numberp read-all)
5532 read-all)
5533 ((numberp gnus-newsgroup-display)
5534 gnus-newsgroup-display)
5535 (t
5536 (condition-case ()
5537 (cond
5538 ((and (or (<= scored marked) (= scored number))
5539 (numberp gnus-large-newsgroup)
5540 (> number gnus-large-newsgroup))
5541 (let* ((cursor-in-echo-area nil)
5542 (initial (gnus-parameter-large-newsgroup-initial
5543 gnus-newsgroup-name))
5544 (input
5545 (read-string
5546 (format
5547 "How many articles from %s (%s %d): "
5548 (gnus-limit-string
5549 (gnus-group-decoded-name gnus-newsgroup-name)
5550 35)
5551 (if initial "max" "default")
5552 number)
5553 (if initial
5554 (cons (number-to-string initial)
5555 0)))))
5556 (if (string-match "^[ \t]*$" input) number input)))
5557 ((and (> scored marked) (< scored number)
5558 (> (- scored number) 20))
5559 (let ((input
5560 (read-string
5561 (format "%s %s (%d scored, %d total): "
5562 "How many articles from"
5563 (gnus-group-decoded-name group)
5564 scored number))))
5565 (if (string-match "^[ \t]*$" input)
5566 number input)))
5567 (t number))
5568 (quit
5569 (message "Quit getting the articles to read")
5570 nil))))))
5571 (setq select (if (stringp select) (string-to-number select) select))
5572 (if (or (null select) (zerop select))
5573 select
5574 (if (and (not (zerop scored)) (<= (abs select) scored))
5575 (progn
5576 (setq articles (sort scored-list '<))
5577 (setq number (length articles)))
5578 (setq articles (copy-sequence articles)))
5579
5580 (when (< (abs select) number)
5581 (if (< select 0)
5582 ;; Select the N oldest articles.
5583 (setcdr (nthcdr (1- (abs select)) articles) nil)
5584 ;; Select the N most recent articles.
5585 (setq articles (nthcdr (- number select) articles))))
5586 (setq gnus-newsgroup-unselected
5587 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5588 (when gnus-alter-articles-to-read-function
5589 (setq articles
5590 (sort
5591 (funcall gnus-alter-articles-to-read-function
5592 gnus-newsgroup-name articles)
5593 '<)))
5594 articles)))
5595
5596 (defun gnus-killed-articles (killed articles)
5597 (let (out)
5598 (while articles
5599 (when (inline (gnus-member-of-range (car articles) killed))
5600 (push (car articles) out))
5601 (setq articles (cdr articles)))
5602 out))
5603
5604 (defun gnus-uncompress-marks (marks)
5605 "Uncompress the mark ranges in MARKS."
5606 (let ((uncompressed '(score bookmark))
5607 out)
5608 (while marks
5609 (if (memq (caar marks) uncompressed)
5610 (push (car marks) out)
5611 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5612 (setq marks (cdr marks)))
5613 out))
5614
5615 (defun gnus-article-mark-to-type (mark)
5616 "Return the type of MARK."
5617 (or (cadr (assq mark gnus-article-special-mark-lists))
5618 'list))
5619
5620 (defun gnus-article-unpropagatable-p (mark)
5621 "Return whether MARK should be propagated to back end."
5622 (memq mark gnus-article-unpropagated-mark-lists))
5623
5624 (defun gnus-adjust-marked-articles (info)
5625 "Set all article lists and remove all marks that are no longer valid."
5626 (let* ((marked-lists (gnus-info-marks info))
5627 (active (gnus-active (gnus-info-group info)))
5628 (min (car active))
5629 (max (cdr active))
5630 (types gnus-article-mark-lists)
5631 marks var articles article mark mark-type
5632 bgn end)
5633
5634 (dolist (marks marked-lists)
5635 (setq mark (car marks)
5636 mark-type (gnus-article-mark-to-type mark)
5637 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5638
5639 ;; We set the variable according to the type of the marks list,
5640 ;; and then adjust the marks to a subset of the active articles.
5641 (cond
5642 ;; Adjust "simple" lists - compressed yet unsorted
5643 ((eq mark-type 'list)
5644 ;; Simultaneously uncompress and clip to active range
5645 ;; See gnus-uncompress-range for a description of possible marks
5646 (let (l lh)
5647 (if (not (cadr marks))
5648 (set var nil)
5649 (setq articles (if (numberp (cddr marks))
5650 (list (cdr marks))
5651 (cdr marks))
5652 lh (cons nil nil)
5653 l lh)
5654
5655 (while (setq article (pop articles))
5656 (cond ((consp article)
5657 (setq bgn (max (car article) min)
5658 end (min (cdr article) max))
5659 (while (<= bgn end)
5660 (setq l (setcdr l (cons bgn nil))
5661 bgn (1+ bgn))))
5662 ((and (<= min article)
5663 (>= max article))
5664 (setq l (setcdr l (cons article nil))))))
5665 (set var (cdr lh)))))
5666 ;; Adjust assocs.
5667 ((eq mark-type 'tuple)
5668 (set var (setq articles (cdr marks)))
5669 (when (not (listp (cdr (symbol-value var))))
5670 (set var (list (symbol-value var))))
5671 (when (not (listp (cdr articles)))
5672 (setq articles (list articles)))
5673 (while articles
5674 (when (or (not (consp (setq article (pop articles))))
5675 (< (car article) min)
5676 (> (car article) max))
5677 (set var (delq article (symbol-value var))))))
5678 ;; Adjust ranges (sloppily).
5679 ((eq mark-type 'range)
5680 (cond
5681 ((eq mark 'seen)
5682 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5683 ;; It should be (seen (NUM1 . NUM2)).
5684 (when (numberp (cddr marks))
5685 (setcdr marks (list (cdr marks))))
5686 (setq articles (cdr marks))
5687 (while (and articles
5688 (or (and (consp (car articles))
5689 (> min (cdar articles)))
5690 (and (numberp (car articles))
5691 (> min (car articles)))))
5692 (pop articles))
5693 (set var articles))))))))
5694
5695 (defun gnus-update-missing-marks (missing)
5696 "Go through the list of MISSING articles and remove them from the mark lists."
5697 (when missing
5698 (let (var m)
5699 ;; Go through all types.
5700 (dolist (elem gnus-article-mark-lists)
5701 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5702 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5703 (when (symbol-value var)
5704 ;; This list has articles. So we delete all missing
5705 ;; articles from it.
5706 (setq m missing)
5707 (while m
5708 (set var (delq (pop m) (symbol-value var))))))))))
5709
5710 (defun gnus-update-marks ()
5711 "Enter the various lists of marked articles into the newsgroup info list."
5712 (let ((types gnus-article-mark-lists)
5713 (info (gnus-get-info gnus-newsgroup-name))
5714 type list newmarked symbol delta-marks)
5715 (when info
5716 ;; Add all marks lists to the list of marks lists.
5717 (while (setq type (pop types))
5718 (setq list (symbol-value
5719 (setq symbol
5720 (intern (format "gnus-newsgroup-%s" (car type))))))
5721
5722 (when list
5723 ;; Get rid of the entries of the articles that have the
5724 ;; default score.
5725 (when (and (eq (cdr type) 'score)
5726 gnus-save-score
5727 list)
5728 (let* ((arts list)
5729 (prev (cons nil list))
5730 (all prev))
5731 (while arts
5732 (if (or (not (consp (car arts)))
5733 (= (cdar arts) gnus-summary-default-score))
5734 (setcdr prev (cdr arts))
5735 (setq prev arts))
5736 (setq arts (cdr arts)))
5737 (setq list (cdr all)))))
5738
5739 (when (eq (cdr type) 'seen)
5740 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5741
5742 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5743 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5744
5745 (when (and (gnus-check-backend-function
5746 'request-set-mark gnus-newsgroup-name)
5747 (not (gnus-article-unpropagatable-p (cdr type))))
5748 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5749 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5750 (add (gnus-remove-from-range
5751 (gnus-copy-sequence list) old)))
5752 (when add
5753 (push (list add 'add (list (cdr type))) delta-marks))
5754 (when del
5755 (push (list del 'del (list (cdr type))) delta-marks))))
5756
5757 (when list
5758 (push (cons (cdr type) list) newmarked)))
5759
5760 (when delta-marks
5761 (unless (gnus-check-group gnus-newsgroup-name)
5762 (error "Can't open server for %s" gnus-newsgroup-name))
5763 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5764
5765 ;; Enter these new marks into the info of the group.
5766 (if (nthcdr 3 info)
5767 (setcar (nthcdr 3 info) newmarked)
5768 ;; Add the marks lists to the end of the info.
5769 (when newmarked
5770 (setcdr (nthcdr 2 info) (list newmarked))))
5771
5772 ;; Cut off the end of the info if there's nothing else there.
5773 (let ((i 5))
5774 (while (and (> i 2)
5775 (not (nth i info)))
5776 (when (nthcdr (decf i) info)
5777 (setcdr (nthcdr i info) nil)))))))
5778
5779 (defun gnus-set-mode-line (where)
5780 "Set the mode line of the article or summary buffers.
5781 If WHERE is `summary', the summary mode line format will be used."
5782 ;; Is this mode line one we keep updated?
5783 (when (and (memq where gnus-updated-mode-lines)
5784 (symbol-value
5785 (intern (format "gnus-%s-mode-line-format-spec" where))))
5786 (let (mode-string)
5787 (save-excursion
5788 ;; We evaluate this in the summary buffer since these
5789 ;; variables are buffer-local to that buffer.
5790 (set-buffer gnus-summary-buffer)
5791 ;; We bind all these variables that are used in the `eval' form
5792 ;; below.
5793 (let* ((mformat (symbol-value
5794 (intern
5795 (format "gnus-%s-mode-line-format-spec" where))))
5796 (gnus-tmp-group-name (gnus-mode-string-quote
5797 (gnus-group-decoded-name
5798 gnus-newsgroup-name)))
5799 (gnus-tmp-article-number (or gnus-current-article 0))
5800 (gnus-tmp-unread gnus-newsgroup-unreads)
5801 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5802 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5803 (gnus-tmp-unread-and-unselected
5804 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5805 (zerop gnus-tmp-unselected))
5806 "")
5807 ((zerop gnus-tmp-unselected)
5808 (format "{%d more}" gnus-tmp-unread-and-unticked))
5809 (t (format "{%d(+%d) more}"
5810 gnus-tmp-unread-and-unticked
5811 gnus-tmp-unselected))))
5812 (gnus-tmp-subject
5813 (if (and gnus-current-headers
5814 (vectorp gnus-current-headers))
5815 (gnus-mode-string-quote
5816 (mail-header-subject gnus-current-headers))
5817 ""))
5818 bufname-length max-len
5819 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5820 (setq mode-string (eval mformat))
5821 (setq bufname-length (if (string-match "%b" mode-string)
5822 (- (length
5823 (buffer-name
5824 (if (eq where 'summary)
5825 nil
5826 (get-buffer gnus-article-buffer))))
5827 2)
5828 0))
5829 (setq max-len (max 4 (if gnus-mode-non-string-length
5830 (- (window-width)
5831 gnus-mode-non-string-length
5832 bufname-length)
5833 (length mode-string))))
5834 ;; We might have to chop a bit of the string off...
5835 (when (> (length mode-string) max-len)
5836 (setq mode-string
5837 (concat (truncate-string-to-width mode-string (- max-len 3))
5838 "...")))
5839 ;; Pad the mode string a bit.
5840 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5841 ;; Update the mode line.
5842 (setq mode-line-buffer-identification
5843 (gnus-mode-line-buffer-identification (list mode-string)))
5844 (set-buffer-modified-p t))))
5845
5846 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5847 "Go through the HEADERS list and add all Xrefs to a hash table.
5848 The resulting hash table is returned, or nil if no Xrefs were found."
5849 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5850 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5851 (xref-hashtb (gnus-make-hashtable))
5852 start group entry number xrefs header)
5853 (while headers
5854 (setq header (pop headers))
5855 (when (and (setq xrefs (mail-header-xref header))
5856 (not (memq (setq number (mail-header-number header))
5857 unreads)))
5858 (setq start 0)
5859 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5860 (setq start (match-end 0))
5861 (setq group (if prefix
5862 (concat prefix (substring xrefs (match-beginning 1)
5863 (match-end 1)))
5864 (substring xrefs (match-beginning 1) (match-end 1))))
5865 (setq number
5866 (string-to-number (substring xrefs (match-beginning 2)
5867 (match-end 2))))
5868 (if (setq entry (gnus-gethash group xref-hashtb))
5869 (setcdr entry (cons number (cdr entry)))
5870 (gnus-sethash group (cons number nil) xref-hashtb)))))
5871 (and start xref-hashtb)))
5872
5873 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5874 "Look through all the headers and mark the Xrefs as read."
5875 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5876 name entry info xref-hashtb idlist method nth4)
5877 (save-excursion
5878 (set-buffer gnus-group-buffer)
5879 (when (setq xref-hashtb
5880 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5881 (mapatoms
5882 (lambda (group)
5883 (unless (string= from-newsgroup (setq name (symbol-name group)))
5884 (setq idlist (symbol-value group))
5885 ;; Dead groups are not updated.
5886 (and (prog1
5887 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5888 info (nth 2 entry))
5889 (when (stringp (setq nth4 (gnus-info-method info)))
5890 (setq nth4 (gnus-server-to-method nth4))))
5891 ;; Only do the xrefs if the group has the same
5892 ;; select method as the group we have just read.
5893 (or (gnus-methods-equal-p
5894 nth4 (gnus-find-method-for-group from-newsgroup))
5895 virtual
5896 (equal nth4 (setq method (gnus-find-method-for-group
5897 from-newsgroup)))
5898 (and (equal (car nth4) (car method))
5899 (equal (nth 1 nth4) (nth 1 method))))
5900 gnus-use-cross-reference
5901 (or (not (eq gnus-use-cross-reference t))
5902 virtual
5903 ;; Only do cross-references on subscribed
5904 ;; groups, if that is what is wanted.
5905 (<= (gnus-info-level info) gnus-level-subscribed))
5906 (gnus-group-make-articles-read name idlist))))
5907 xref-hashtb)))))
5908
5909 (defun gnus-compute-read-articles (group articles)
5910 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5911 (info (nth 2 entry))
5912 (active (gnus-active group))
5913 ninfo)
5914 (when entry
5915 ;; First peel off all invalid article numbers.
5916 (when active
5917 (let ((ids articles)
5918 id first)
5919 (while (setq id (pop ids))
5920 (when (and first (> id (cdr active)))
5921 ;; We'll end up in this situation in one particular
5922 ;; obscure situation. If you re-scan a group and get
5923 ;; a new article that is cross-posted to a different
5924 ;; group that has not been re-scanned, you might get
5925 ;; crossposted article that has a higher number than
5926 ;; Gnus believes possible. So we re-activate this
5927 ;; group as well. This might mean doing the
5928 ;; crossposting thingy will *increase* the number
5929 ;; of articles in some groups. Tsk, tsk.
5930 (setq active (or (gnus-activate-group group) active)))
5931 (when (or (> id (cdr active))
5932 (< id (car active)))
5933 (setq articles (delq id articles))))))
5934 ;; If the read list is nil, we init it.
5935 (if (and active
5936 (null (gnus-info-read info))
5937 (> (car active) 1))
5938 (setq ninfo (cons 1 (1- (car active))))
5939 (setq ninfo (gnus-info-read info)))
5940 ;; Then we add the read articles to the range.
5941 (gnus-add-to-range
5942 ninfo (setq articles (sort articles '<))))))
5943
5944 (defun gnus-group-make-articles-read (group articles)
5945 "Update the info of GROUP to say that ARTICLES are read."
5946 (let* ((num 0)
5947 (entry (gnus-gethash group gnus-newsrc-hashtb))
5948 (info (nth 2 entry))
5949 (active (gnus-active group))
5950 range)
5951 (when entry
5952 (setq range (gnus-compute-read-articles group articles))
5953 (save-excursion
5954 (set-buffer gnus-group-buffer)
5955 (gnus-undo-register
5956 `(progn
5957 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5958 (gnus-info-set-read ',info ',(gnus-info-read info))
5959 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5960 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5961 (gnus-group-update-group ,group t))))
5962 ;; Add the read articles to the range.
5963 (gnus-info-set-read info range)
5964 (gnus-request-set-mark group (list (list range 'add '(read))))
5965 ;; Then we have to re-compute how many unread
5966 ;; articles there are in this group.
5967 (when active
5968 (cond
5969 ((not range)
5970 (setq num (- (1+ (cdr active)) (car active))))
5971 ((not (listp (cdr range)))
5972 (setq num (- (cdr active) (- (1+ (cdr range))
5973 (car range)))))
5974 (t
5975 (while range
5976 (if (numberp (car range))
5977 (setq num (1+ num))
5978 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5979 (setq range (cdr range)))
5980 (setq num (- (cdr active) num))))
5981 ;; Update the number of unread articles.
5982 (setcar entry num)
5983 ;; Update the group buffer.
5984 (unless (gnus-ephemeral-group-p group)
5985 (gnus-group-update-group group t))))))
5986
5987 (defvar gnus-newsgroup-none-id 0)
5988
5989 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5990 (let ((cur nntp-server-buffer)
5991 (dependencies
5992 (or dependencies
5993 (save-excursion (set-buffer gnus-summary-buffer)
5994 gnus-newsgroup-dependencies)))
5995 headers id end ref
5996 (mail-parse-charset gnus-newsgroup-charset)
5997 (mail-parse-ignored-charsets
5998 (save-excursion (condition-case nil
5999 (set-buffer gnus-summary-buffer)
6000 (error))
6001 gnus-newsgroup-ignored-charsets)))
6002 (save-excursion
6003 (set-buffer nntp-server-buffer)
6004 ;; Translate all TAB characters into SPACE characters.
6005 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6006 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6007 (ietf-drums-unfold-fws)
6008 (gnus-run-hooks 'gnus-parse-headers-hook)
6009 (let ((case-fold-search t)
6010 in-reply-to header p lines chars)
6011 (goto-char (point-min))
6012 ;; Search to the beginning of the next header. Error messages
6013 ;; do not begin with 2 or 3.
6014 (while (re-search-forward "^[23][0-9]+ " nil t)
6015 (setq id nil
6016 ref nil)
6017 ;; This implementation of this function, with nine
6018 ;; search-forwards instead of the one re-search-forward and
6019 ;; a case (which basically was the old function) is actually
6020 ;; about twice as fast, even though it looks messier. You
6021 ;; can't have everything, I guess. Speed and elegance
6022 ;; doesn't always go hand in hand.
6023 (setq
6024 header
6025 (vector
6026 ;; Number.
6027 (prog1
6028 (read cur)
6029 (end-of-line)
6030 (setq p (point))
6031 (narrow-to-region (point)
6032 (or (and (search-forward "\n.\n" nil t)
6033 (- (point) 2))
6034 (point))))
6035 ;; Subject.
6036 (progn
6037 (goto-char p)
6038 (if (search-forward "\nsubject:" nil t)
6039 (funcall gnus-decode-encoded-word-function
6040 (nnheader-header-value))
6041 "(none)"))
6042 ;; From.
6043 (progn
6044 (goto-char p)
6045 (if (search-forward "\nfrom:" nil t)
6046 (funcall gnus-decode-encoded-address-function
6047 (nnheader-header-value))
6048 "(nobody)"))
6049 ;; Date.
6050 (progn
6051 (goto-char p)
6052 (if (search-forward "\ndate:" nil t)
6053 (nnheader-header-value) ""))
6054 ;; Message-ID.
6055 (progn
6056 (goto-char p)
6057 (setq id (if (re-search-forward
6058 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6059 ;; We do it this way to make sure the Message-ID
6060 ;; is (somewhat) syntactically valid.
6061 (buffer-substring (match-beginning 1)
6062 (match-end 1))
6063 ;; If there was no message-id, we just fake one
6064 ;; to make subsequent routines simpler.
6065 (nnheader-generate-fake-message-id))))
6066 ;; References.
6067 (progn
6068 (goto-char p)
6069 (if (search-forward "\nreferences:" nil t)
6070 (progn
6071 (setq end (point))
6072 (prog1
6073 (nnheader-header-value)
6074 (setq ref
6075 (buffer-substring
6076 (progn
6077 (end-of-line)
6078 (search-backward ">" end t)
6079 (1+ (point)))
6080 (progn
6081 (search-backward "<" end t)
6082 (point))))))
6083 ;; Get the references from the in-reply-to header if there
6084 ;; were no references and the in-reply-to header looks
6085 ;; promising.
6086 (if (and (search-forward "\nin-reply-to:" nil t)
6087 (setq in-reply-to (nnheader-header-value))
6088 (string-match "<[^>]+>" in-reply-to))
6089 (let (ref2)
6090 (setq ref (substring in-reply-to (match-beginning 0)
6091 (match-end 0)))
6092 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6093 (setq ref2 (substring in-reply-to (match-beginning 0)
6094 (match-end 0)))
6095 (when (> (length ref2) (length ref))
6096 (setq ref ref2)))
6097 ref)
6098 (setq ref nil))))
6099 ;; Chars.
6100 (progn
6101 (goto-char p)
6102 (if (search-forward "\nchars: " nil t)
6103 (if (numberp (setq chars (ignore-errors (read cur))))
6104 chars -1)
6105 -1))
6106 ;; Lines.
6107 (progn
6108 (goto-char p)
6109 (if (search-forward "\nlines: " nil t)
6110 (if (numberp (setq lines (ignore-errors (read cur))))
6111 lines -1)
6112 -1))
6113 ;; Xref.
6114 (progn
6115 (goto-char p)
6116 (and (search-forward "\nxref:" nil t)
6117 (nnheader-header-value)))
6118 ;; Extra.
6119 (when gnus-extra-headers
6120 (let ((extra gnus-extra-headers)
6121 out)
6122 (while extra
6123 (goto-char p)
6124 (when (search-forward
6125 (concat "\n" (symbol-name (car extra)) ":") nil t)
6126 (push (cons (car extra) (nnheader-header-value))
6127 out))
6128 (pop extra))
6129 out))))
6130 (when (equal id ref)
6131 (setq ref nil))
6132
6133 (when gnus-alter-header-function
6134 (funcall gnus-alter-header-function header)
6135 (setq id (mail-header-id header)
6136 ref (gnus-parent-id (mail-header-references header))))
6137
6138 (when (setq header
6139 (gnus-dependencies-add-header
6140 header dependencies force-new))
6141 (push header headers))
6142 (goto-char (point-max))
6143 (widen))
6144 (nreverse headers)))))
6145
6146 ;; Goes through the xover lines and returns a list of vectors
6147 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6148 force-new dependencies
6149 group also-fetch-heads)
6150 "Parse the news overview data in the server buffer.
6151 Return a list of headers that match SEQUENCE (see
6152 `nntp-retrieve-headers')."
6153 ;; Get the Xref when the users reads the articles since most/some
6154 ;; NNTP servers do not include Xrefs when using XOVER.
6155 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6156 (let ((mail-parse-charset gnus-newsgroup-charset)
6157 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6158 (cur nntp-server-buffer)
6159 (dependencies (or dependencies gnus-newsgroup-dependencies))
6160 (allp (cond
6161 ((eq gnus-read-all-available-headers t)
6162 t)
6163 ((and (stringp gnus-read-all-available-headers)
6164 group)
6165 (string-match gnus-read-all-available-headers group))
6166 (t
6167 nil)))
6168 number headers header)
6169 (save-excursion
6170 (set-buffer nntp-server-buffer)
6171 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6172 ;; Allow the user to mangle the headers before parsing them.
6173 (gnus-run-hooks 'gnus-parse-headers-hook)
6174 (goto-char (point-min))
6175 (gnus-parse-without-error
6176 (while (and (or sequence allp)
6177 (not (eobp)))
6178 (setq number (read cur))
6179 (when (not allp)
6180 (while (and sequence
6181 (< (car sequence) number))
6182 (setq sequence (cdr sequence))))
6183 (when (and (or allp
6184 (and sequence
6185 (eq number (car sequence))))
6186 (progn
6187 (setq sequence (cdr sequence))
6188 (setq header (inline
6189 (gnus-nov-parse-line
6190 number dependencies force-new)))))
6191 (push header headers))
6192 (forward-line 1)))
6193 ;; A common bug in inn is that if you have posted an article and
6194 ;; then retrieves the active file, it will answer correctly --
6195 ;; the new article is included. However, a NOV entry for the
6196 ;; article may not have been generated yet, so this may fail.
6197 ;; We work around this problem by retrieving the last few
6198 ;; headers using HEAD.
6199 (if (or (not also-fetch-heads)
6200 (not sequence))
6201 ;; We (probably) got all the headers.
6202 (nreverse headers)
6203 (let ((gnus-nov-is-evil t))
6204 (nconc
6205 (nreverse headers)
6206 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6207 (gnus-get-newsgroup-headers))))))))
6208
6209 (defun gnus-article-get-xrefs ()
6210 "Fill in the Xref value in `gnus-current-headers', if necessary.
6211 This is meant to be called in `gnus-article-internal-prepare-hook'."
6212 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6213 gnus-current-headers)))
6214 (or (not gnus-use-cross-reference)
6215 (not headers)
6216 (and (mail-header-xref headers)
6217 (not (string= (mail-header-xref headers) "")))
6218 (let ((case-fold-search t)
6219 xref)
6220 (save-restriction
6221 (nnheader-narrow-to-headers)
6222 (goto-char (point-min))
6223 (when (or (and (not (eobp))
6224 (eq (downcase (char-after)) ?x)
6225 (looking-at "Xref:"))
6226 (search-forward "\nXref:" nil t))
6227 (goto-char (1+ (match-end 0)))
6228 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6229 (mail-header-set-xref headers xref)))))))
6230
6231 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6232 "Find article ID and insert the summary line for that article.
6233 OLD-HEADER can either be a header or a line number to insert
6234 the subject line on."
6235 (let* ((line (and (numberp old-header) old-header))
6236 (old-header (and (vectorp old-header) old-header))
6237 (header (cond ((and old-header use-old-header)
6238 old-header)
6239 ((and (numberp id)
6240 (gnus-number-to-header id))
6241 (gnus-number-to-header id))
6242 (t
6243 (gnus-read-header id))))
6244 (number (and (numberp id) id))
6245 d)
6246 (when header
6247 ;; Rebuild the thread that this article is part of and go to the
6248 ;; article we have fetched.
6249 (when (and (not gnus-show-threads)
6250 old-header)
6251 (when (and number
6252 (setq d (gnus-data-find (mail-header-number old-header))))
6253 (goto-char (gnus-data-pos d))
6254 (gnus-data-remove
6255 number
6256 (- (gnus-point-at-bol)
6257 (prog1
6258 (1+ (gnus-point-at-eol))
6259 (gnus-delete-line))))))
6260 ;; Remove list identifiers from subject.
6261 (when gnus-list-identifiers
6262 (let ((gnus-newsgroup-headers (list header)))
6263 (gnus-summary-remove-list-identifiers)))
6264 (when old-header
6265 (mail-header-set-number header (mail-header-number old-header)))
6266 (setq gnus-newsgroup-sparse
6267 (delq (setq number (mail-header-number header))
6268 gnus-newsgroup-sparse))
6269 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6270 (push number gnus-newsgroup-limit)
6271 (gnus-rebuild-thread (mail-header-id header) line)
6272 (gnus-summary-goto-subject number nil t))
6273 (when (and (numberp number)
6274 (> number 0))
6275 ;; We have to update the boundaries even if we can't fetch the
6276 ;; article if ID is a number -- so that the next `P' or `N'
6277 ;; command will fetch the previous (or next) article even
6278 ;; if the one we tried to fetch this time has been canceled.
6279 (when (> number gnus-newsgroup-end)
6280 (setq gnus-newsgroup-end number))
6281 (when (< number gnus-newsgroup-begin)
6282 (setq gnus-newsgroup-begin number))
6283 (setq gnus-newsgroup-unselected
6284 (delq number gnus-newsgroup-unselected)))
6285 ;; Report back a success?
6286 (and header (mail-header-number header))))
6287
6288 ;;; Process/prefix in the summary buffer
6289
6290 (defun gnus-summary-work-articles (n)
6291 "Return a list of articles to be worked upon.
6292 The prefix argument, the list of process marked articles, and the
6293 current article will be taken into consideration."
6294 (save-excursion
6295 (set-buffer gnus-summary-buffer)
6296 (cond
6297 (n
6298 ;; A numerical prefix has been given.
6299 (setq n (prefix-numeric-value n))
6300 (let ((backward (< n 0))
6301 (n (abs (prefix-numeric-value n)))
6302 articles article)
6303 (save-excursion
6304 (while
6305 (and (> n 0)
6306 (push (setq article (gnus-summary-article-number))
6307 articles)
6308 (if backward
6309 (gnus-summary-find-prev nil article)
6310 (gnus-summary-find-next nil article)))
6311 (decf n)))
6312 (nreverse articles)))
6313 ((and (gnus-region-active-p) (mark))
6314 (message "region active")
6315 ;; Work on the region between point and mark.
6316 (let ((max (max (point) (mark)))
6317 articles article)
6318 (save-excursion
6319 (goto-char (min (point) (mark)))
6320 (while
6321 (and
6322 (push (setq article (gnus-summary-article-number)) articles)
6323 (gnus-summary-find-next nil article)
6324 (< (point) max)))
6325 (nreverse articles))))
6326 (gnus-newsgroup-processable
6327 ;; There are process-marked articles present.
6328 ;; Save current state.
6329 (gnus-summary-save-process-mark)
6330 ;; Return the list.
6331 (reverse gnus-newsgroup-processable))
6332 (t
6333 ;; Just return the current article.
6334 (list (gnus-summary-article-number))))))
6335
6336 (defmacro gnus-summary-iterate (arg &rest forms)
6337 "Iterate over the process/prefixed articles and do FORMS.
6338 ARG is the interactive prefix given to the command. FORMS will be
6339 executed with point over the summary line of the articles."
6340 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6341 `(let ((,articles (gnus-summary-work-articles ,arg)))
6342 (while ,articles
6343 (gnus-summary-goto-subject (car ,articles))
6344 ,@forms
6345 (pop ,articles)))))
6346
6347 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6348 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6349
6350 (defun gnus-summary-save-process-mark ()
6351 "Push the current set of process marked articles on the stack."
6352 (interactive)
6353 (push (copy-sequence gnus-newsgroup-processable)
6354 gnus-newsgroup-process-stack))
6355
6356 (defun gnus-summary-kill-process-mark ()
6357 "Push the current set of process marked articles on the stack and unmark."
6358 (interactive)
6359 (gnus-summary-save-process-mark)
6360 (gnus-summary-unmark-all-processable))
6361
6362 (defun gnus-summary-yank-process-mark ()
6363 "Pop the last process mark state off the stack and restore it."
6364 (interactive)
6365 (unless gnus-newsgroup-process-stack
6366 (error "Empty mark stack"))
6367 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6368
6369 (defun gnus-summary-process-mark-set (set)
6370 "Make SET into the current process marked articles."
6371 (gnus-summary-unmark-all-processable)
6372 (while set
6373 (gnus-summary-set-process-mark (pop set))))
6374
6375 ;;; Searching and stuff
6376
6377 (defun gnus-summary-search-group (&optional backward use-level)
6378 "Search for next unread newsgroup.
6379 If optional argument BACKWARD is non-nil, search backward instead."
6380 (save-excursion
6381 (set-buffer gnus-group-buffer)
6382 (when (gnus-group-search-forward
6383 backward nil (if use-level (gnus-group-group-level) nil))
6384 (gnus-group-group-name))))
6385
6386 (defun gnus-summary-best-group (&optional exclude-group)
6387 "Find the name of the best unread group.
6388 If EXCLUDE-GROUP, do not go to this group."
6389 (save-excursion
6390 (set-buffer gnus-group-buffer)
6391 (save-excursion
6392 (gnus-group-best-unread-group exclude-group))))
6393
6394 (defun gnus-summary-find-next (&optional unread article backward)
6395 (if backward
6396 (gnus-summary-find-prev unread article)
6397 (let* ((dummy (gnus-summary-article-intangible-p))
6398 (article (or article (gnus-summary-article-number)))
6399 (data (gnus-data-find-list article))
6400 result)
6401 (when (and (not dummy)
6402 (or (not gnus-summary-check-current)
6403 (not unread)
6404 (not (gnus-data-unread-p (car data)))))
6405 (setq data (cdr data)))
6406 (when (setq result
6407 (if unread
6408 (progn
6409 (while data
6410 (unless (memq (gnus-data-number (car data))
6411 (cond
6412 ((eq gnus-auto-goto-ignores
6413 'always-undownloaded)
6414 gnus-newsgroup-undownloaded)
6415 (gnus-plugged
6416 nil)
6417 ((eq gnus-auto-goto-ignores
6418 'unfetched)
6419 gnus-newsgroup-unfetched)
6420 ((eq gnus-auto-goto-ignores
6421 'undownloaded)
6422 gnus-newsgroup-undownloaded)))
6423 (when (gnus-data-unread-p (car data))
6424 (setq result (car data)
6425 data nil)))
6426 (setq data (cdr data)))
6427 result)
6428 (car data)))
6429 (goto-char (gnus-data-pos result))
6430 (gnus-data-number result)))))
6431
6432 (defun gnus-summary-find-prev (&optional unread article)
6433 (let* ((eobp (eobp))
6434 (article (or article (gnus-summary-article-number)))
6435 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6436 result)
6437 (when (and (not eobp)
6438 (or (not gnus-summary-check-current)
6439 (not unread)
6440 (not (gnus-data-unread-p (car data)))))
6441 (setq data (cdr data)))
6442 (when (setq result
6443 (if unread
6444 (progn
6445 (while data
6446 (unless (memq (gnus-data-number (car data))
6447 (cond
6448 ((eq gnus-auto-goto-ignores
6449 'always-undownloaded)
6450 gnus-newsgroup-undownloaded)
6451 (gnus-plugged
6452 nil)
6453 ((eq gnus-auto-goto-ignores
6454 'unfetched)
6455 gnus-newsgroup-unfetched)
6456 ((eq gnus-auto-goto-ignores
6457 'undownloaded)
6458 gnus-newsgroup-undownloaded)))
6459 (when (gnus-data-unread-p (car data))
6460 (setq result (car data)
6461 data nil)))
6462 (setq data (cdr data)))
6463 result)
6464 (car data)))
6465 (goto-char (gnus-data-pos result))
6466 (gnus-data-number result))))
6467
6468 (defun gnus-summary-find-subject (subject &optional unread backward article)
6469 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6470 (article (or article (gnus-summary-article-number)))
6471 (articles (gnus-data-list backward))
6472 (arts (gnus-data-find-list article articles))
6473 result)
6474 (when (or (not gnus-summary-check-current)
6475 (not unread)
6476 (not (gnus-data-unread-p (car arts))))
6477 (setq arts (cdr arts)))
6478 (while arts
6479 (and (or (not unread)
6480 (gnus-data-unread-p (car arts)))
6481 (vectorp (gnus-data-header (car arts)))
6482 (gnus-subject-equal
6483 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6484 (setq result (car arts)
6485 arts nil))
6486 (setq arts (cdr arts)))
6487 (and result
6488 (goto-char (gnus-data-pos result))
6489 (gnus-data-number result))))
6490
6491 (defun gnus-summary-search-forward (&optional unread subject backward)
6492 "Search forward for an article.
6493 If UNREAD, look for unread articles. If SUBJECT, look for
6494 articles with that subject. If BACKWARD, search backward instead."
6495 (cond (subject (gnus-summary-find-subject subject unread backward))
6496 (backward (gnus-summary-find-prev unread))
6497 (t (gnus-summary-find-next unread))))
6498
6499 (defun gnus-recenter (&optional n)
6500 "Center point in window and redisplay frame.
6501 Also do horizontal recentering."
6502 (interactive "P")
6503 (when (and gnus-auto-center-summary
6504 (not (eq gnus-auto-center-summary 'vertical)))
6505 (gnus-horizontal-recenter))
6506 (recenter n))
6507
6508 (defun gnus-summary-recenter ()
6509 "Center point in the summary window.
6510 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6511 displayed, no centering will be performed."
6512 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6513 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6514 (interactive)
6515 ;; The user has to want it.
6516 (when gnus-auto-center-summary
6517 (let* ((top (cond ((< (window-height) 4) 0)
6518 ((< (window-height) 7) 1)
6519 (t (if (numberp gnus-auto-center-summary)
6520 gnus-auto-center-summary
6521 2))))
6522 (height (1- (window-height)))
6523 (bottom (save-excursion (goto-char (point-max))
6524 (forward-line (- height))
6525 (point)))
6526 (window (get-buffer-window (current-buffer))))
6527 (when (get-buffer-window gnus-article-buffer)
6528 ;; Only do recentering when the article buffer is displayed,
6529 ;; Set the window start to either `bottom', which is the biggest
6530 ;; possible valid number, or the second line from the top,
6531 ;; whichever is the least.
6532 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6533 (if (> bottom top-pos)
6534 ;; Keep the second line from the top visible
6535 (set-window-start window top-pos t)
6536 ;; Try to keep the bottom line visible; if it's partially
6537 ;; obscured, either scroll one more line to make it fully
6538 ;; visible, or revert to using TOP-POS.
6539 (save-excursion
6540 (goto-char (point-max))
6541 (forward-line -1)
6542 (let ((last-line-start (point)))
6543 (goto-char bottom)
6544 (set-window-start window (point) t)
6545 (when (not (pos-visible-in-window-p last-line-start window))
6546 (forward-line 1)
6547 (set-window-start window (min (point) top-pos) t)))))))
6548 ;; Do horizontal recentering while we're at it.
6549 (when (and (get-buffer-window (current-buffer) t)
6550 (not (eq gnus-auto-center-summary 'vertical)))
6551 (let ((selected (selected-window)))
6552 (select-window (get-buffer-window (current-buffer) t))
6553 (gnus-summary-position-point)
6554 (gnus-horizontal-recenter)
6555 (select-window selected))))))
6556
6557 (defun gnus-summary-jump-to-group (newsgroup)
6558 "Move point to NEWSGROUP in group mode buffer."
6559 ;; Keep update point of group mode buffer if visible.
6560 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6561 (save-window-excursion
6562 ;; Take care of tree window mode.
6563 (when (get-buffer-window gnus-group-buffer)
6564 (pop-to-buffer gnus-group-buffer))
6565 (gnus-group-jump-to-group newsgroup))
6566 (save-excursion
6567 ;; Take care of tree window mode.
6568 (if (get-buffer-window gnus-group-buffer)
6569 (pop-to-buffer gnus-group-buffer)
6570 (set-buffer gnus-group-buffer))
6571 (gnus-group-jump-to-group newsgroup))))
6572
6573 ;; This function returns a list of article numbers based on the
6574 ;; difference between the ranges of read articles in this group and
6575 ;; the range of active articles.
6576 (defun gnus-list-of-unread-articles (group)
6577 (let* ((read (gnus-info-read (gnus-get-info group)))
6578 (active (or (gnus-active group) (gnus-activate-group group)))
6579 (last (cdr active))
6580 (bottom (if gnus-newsgroup-maximum-articles
6581 (max (car active)
6582 (- last gnus-newsgroup-maximum-articles -1))
6583 (car active)))
6584 first nlast unread)
6585 ;; If none are read, then all are unread.
6586 (if (not read)
6587 (setq first bottom)
6588 ;; If the range of read articles is a single range, then the
6589 ;; first unread article is the article after the last read
6590 ;; article. Sounds logical, doesn't it?
6591 (if (and (not (listp (cdr read)))
6592 (or (< (car read) bottom)
6593 (progn (setq read (list read))
6594 nil)))
6595 (setq first (max bottom (1+ (cdr read))))
6596 ;; `read' is a list of ranges.
6597 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6598 (caar read)))
6599 1)
6600 (setq first bottom))
6601 (while read
6602 (when first
6603 (while (< first nlast)
6604 (setq unread (cons first unread)
6605 first (1+ first))))
6606 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6607 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6608 (setq read (cdr read)))))
6609 ;; And add the last unread articles.
6610 (while (<= first last)
6611 (setq unread (cons first unread)
6612 first (1+ first)))
6613 ;; Return the list of unread articles.
6614 (delq 0 (nreverse unread))))
6615
6616 (defun gnus-list-of-read-articles (group)
6617 "Return a list of unread, unticked and non-dormant articles."
6618 (let* ((info (gnus-get-info group))
6619 (marked (gnus-info-marks info))
6620 (active (gnus-active group)))
6621 (and info active
6622 (gnus-list-range-difference
6623 (gnus-list-range-difference
6624 (gnus-sorted-complement
6625 (gnus-uncompress-range
6626 (if gnus-newsgroup-maximum-articles
6627 (cons (max (car active)
6628 (- (cdr active)
6629 gnus-newsgroup-maximum-articles
6630 -1))
6631 (cdr active))
6632 active))
6633 (gnus-list-of-unread-articles group))
6634 (cdr (assq 'dormant marked)))
6635 (cdr (assq 'tick marked))))))
6636
6637 ;; This function returns a sequence of article numbers based on the
6638 ;; difference between the ranges of read articles in this group and
6639 ;; the range of active articles.
6640 (defun gnus-sequence-of-unread-articles (group)
6641 (let* ((read (gnus-info-read (gnus-get-info group)))
6642 (active (or (gnus-active group) (gnus-activate-group group)))
6643 (last (cdr active))
6644 (bottom (if gnus-newsgroup-maximum-articles
6645 (max (car active)
6646 (- last gnus-newsgroup-maximum-articles -1))
6647 (car active)))
6648 first nlast unread)
6649 ;; If none are read, then all are unread.
6650 (if (not read)
6651 (setq first bottom)
6652 ;; If the range of read articles is a single range, then the
6653 ;; first unread article is the article after the last read
6654 ;; article. Sounds logical, doesn't it?
6655 (if (and (not (listp (cdr read)))
6656 (or (< (car read) bottom)
6657 (progn (setq read (list read))
6658 nil)))
6659 (setq first (max bottom (1+ (cdr read))))
6660 ;; `read' is a list of ranges.
6661 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6662 (caar read)))
6663 1)
6664 (setq first bottom))
6665 (while read
6666 (when first
6667 (push (cons first nlast) unread))
6668 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6669 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6670 (setq read (cdr read)))))
6671 ;; And add the last unread articles.
6672 (cond ((not (and first last))
6673 nil)
6674 ((< first last)
6675 (push (cons first last) unread))
6676 ((= first last)
6677 (push first unread)))
6678 ;; Return the sequence of unread articles.
6679 (delq 0 (nreverse unread))))
6680
6681 ;; Various summary commands
6682
6683 (defun gnus-summary-select-article-buffer ()
6684 "Reconfigure windows to show article buffer."
6685 (interactive)
6686 (if (not (gnus-buffer-live-p gnus-article-buffer))
6687 (error "There is no article buffer for this summary buffer")
6688 (gnus-configure-windows 'article)
6689 (select-window (get-buffer-window gnus-article-buffer))))
6690
6691 (defun gnus-summary-universal-argument (arg)
6692 "Perform any operation on all articles that are process/prefixed."
6693 (interactive "P")
6694 (let ((articles (gnus-summary-work-articles arg))
6695 func article)
6696 (if (eq
6697 (setq
6698 func
6699 (key-binding
6700 (read-key-sequence
6701 (substitute-command-keys
6702 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6703 'undefined)
6704 (gnus-error 1 "Undefined key")
6705 (save-excursion
6706 (while articles
6707 (gnus-summary-goto-subject (setq article (pop articles)))
6708 (let (gnus-newsgroup-processable)
6709 (command-execute func))
6710 (gnus-summary-remove-process-mark article)))))
6711 (gnus-summary-position-point))
6712
6713 (defun gnus-summary-toggle-truncation (&optional arg)
6714 "Toggle truncation of summary lines.
6715 With ARG, turn line truncation on if ARG is positive."
6716 (interactive "P")
6717 (setq truncate-lines
6718 (if (null arg) (not truncate-lines)
6719 (> (prefix-numeric-value arg) 0)))
6720 (redraw-display))
6721
6722 (defun gnus-summary-find-for-reselect ()
6723 "Return the number of an article to stay on across a reselect.
6724 The current article is considered, then following articles, then previous
6725 articles. An article is sought which is not cancelled and isn't a temporary
6726 insertion from another group. If there's no such then return a dummy 0."
6727 (let (found)
6728 (dolist (rev '(nil t))
6729 (unless found ; don't demand the reverse list if we don't need it
6730 (let ((data (gnus-data-find-list
6731 (gnus-summary-article-number) (gnus-data-list rev))))
6732 (while (and data (not found))
6733 (if (and (< 0 (gnus-data-number (car data)))
6734 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6735 (setq found (gnus-data-number (car data))))
6736 (setq data (cdr data))))))
6737 (or found 0)))
6738
6739 (defun gnus-summary-reselect-current-group (&optional all rescan)
6740 "Exit and then reselect the current newsgroup.
6741 The prefix argument ALL means to select all articles."
6742 (interactive "P")
6743 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6744 (error "Ephemeral groups can't be reselected"))
6745 (let ((current-subject (gnus-summary-find-for-reselect))
6746 (group gnus-newsgroup-name))
6747 (setq gnus-newsgroup-begin nil)
6748 (gnus-summary-exit nil 'leave-hidden)
6749 ;; We have to adjust the point of group mode buffer because
6750 ;; point was moved to the next unread newsgroup by exiting.
6751 (gnus-summary-jump-to-group group)
6752 (when rescan
6753 (save-excursion
6754 (gnus-group-get-new-news-this-group 1)))
6755 (gnus-group-read-group all t)
6756 (gnus-summary-goto-subject current-subject nil t)))
6757
6758 (defun gnus-summary-rescan-group (&optional all)
6759 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6760 (interactive "P")
6761 (gnus-summary-reselect-current-group all t))
6762
6763 (defun gnus-summary-update-info (&optional non-destructive)
6764 (save-excursion
6765 (let ((group gnus-newsgroup-name))
6766 (when group
6767 (when gnus-newsgroup-kill-headers
6768 (setq gnus-newsgroup-killed
6769 (gnus-compress-sequence
6770 (gnus-sorted-union
6771 (gnus-list-range-intersection
6772 gnus-newsgroup-unselected gnus-newsgroup-killed)
6773 gnus-newsgroup-unreads)
6774 t)))
6775 (unless (listp (cdr gnus-newsgroup-killed))
6776 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6777 (let ((headers gnus-newsgroup-headers))
6778 ;; Set the new ranges of read articles.
6779 (save-excursion
6780 (set-buffer gnus-group-buffer)
6781 (gnus-undo-force-boundary))
6782 (gnus-update-read-articles
6783 group (gnus-sorted-union
6784 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6785 ;; Set the current article marks.
6786 (let ((gnus-newsgroup-scored
6787 (if (and (not gnus-save-score)
6788 (not non-destructive))
6789 nil
6790 gnus-newsgroup-scored)))
6791 (save-excursion
6792 (gnus-update-marks)))
6793 ;; Do the cross-ref thing.
6794 (when gnus-use-cross-reference
6795 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6796 ;; Do not switch windows but change the buffer to work.
6797 (set-buffer gnus-group-buffer)
6798 (unless (gnus-ephemeral-group-p group)
6799 (gnus-group-update-group group)))))))
6800
6801 (defun gnus-summary-save-newsrc (&optional force)
6802 "Save the current number of read/marked articles in the dribble buffer.
6803 The dribble buffer will then be saved.
6804 If FORCE (the prefix), also save the .newsrc file(s)."
6805 (interactive "P")
6806 (gnus-summary-update-info t)
6807 (if force
6808 (gnus-save-newsrc-file)
6809 (gnus-dribble-save)))
6810
6811 (defun gnus-summary-exit (&optional temporary leave-hidden)
6812 "Exit reading current newsgroup, and then return to group selection mode.
6813 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6814 (interactive)
6815 (gnus-set-global-variables)
6816 (when (gnus-buffer-live-p gnus-article-buffer)
6817 (save-excursion
6818 (set-buffer gnus-article-buffer)
6819 (mm-destroy-parts gnus-article-mime-handles)
6820 ;; Set it to nil for safety reason.
6821 (setq gnus-article-mime-handle-alist nil)
6822 (setq gnus-article-mime-handles nil)))
6823 (gnus-kill-save-kill-buffer)
6824 (gnus-async-halt-prefetch)
6825 (let* ((group gnus-newsgroup-name)
6826 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6827 (gnus-group-is-exiting-p t)
6828 (mode major-mode)
6829 (group-point nil)
6830 (buf (current-buffer)))
6831 (unless quit-config
6832 ;; Do adaptive scoring, and possibly save score files.
6833 (when gnus-newsgroup-adaptive
6834 (gnus-score-adaptive))
6835 (when gnus-use-scoring
6836 (gnus-score-save)))
6837 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6838 ;; If we have several article buffers, we kill them at exit.
6839 (unless gnus-single-article-buffer
6840 (gnus-kill-buffer gnus-original-article-buffer)
6841 (setq gnus-article-current nil))
6842 (when gnus-use-cache
6843 (gnus-cache-possibly-remove-articles)
6844 (gnus-cache-save-buffers))
6845 (gnus-async-prefetch-remove-group group)
6846 (when gnus-suppress-duplicates
6847 (gnus-dup-enter-articles))
6848 (when gnus-use-trees
6849 (gnus-tree-close group))
6850 (when gnus-use-cache
6851 (gnus-cache-write-active))
6852 ;; Remove entries for this group.
6853 (nnmail-purge-split-history (gnus-group-real-name group))
6854 ;; Make all changes in this group permanent.
6855 (unless quit-config
6856 (gnus-run-hooks 'gnus-exit-group-hook)
6857 (gnus-summary-update-info))
6858 (gnus-close-group group)
6859 ;; Make sure where we were, and go to next newsgroup.
6860 (set-buffer gnus-group-buffer)
6861 (unless quit-config
6862 (gnus-group-jump-to-group group))
6863 (gnus-run-hooks 'gnus-summary-exit-hook)
6864 (unless (or quit-config
6865 ;; If this group has disappeared from the summary
6866 ;; buffer, don't skip forwards.
6867 (not (string= group (gnus-group-group-name))))
6868 (gnus-group-next-unread-group 1))
6869 (setq group-point (point))
6870 (if temporary
6871 nil ;Nothing to do.
6872 ;; If we have several article buffers, we kill them at exit.
6873 (unless gnus-single-article-buffer
6874 (gnus-kill-buffer gnus-article-buffer)
6875 (gnus-kill-buffer gnus-original-article-buffer)
6876 (setq gnus-article-current nil))
6877 (set-buffer buf)
6878 (if (not gnus-kill-summary-on-exit)
6879 (progn
6880 (gnus-deaden-summary)
6881 (setq mode nil))
6882 ;; We set all buffer-local variables to nil. It is unclear why
6883 ;; this is needed, but if we don't, buffer-local variables are
6884 ;; not garbage-collected, it seems. This would the lead to en
6885 ;; ever-growing Emacs.
6886 (gnus-summary-clear-local-variables)
6887 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6888 (gnus-summary-clear-local-variables))
6889 (when (get-buffer gnus-article-buffer)
6890 (bury-buffer gnus-article-buffer))
6891 ;; We clear the global counterparts of the buffer-local
6892 ;; variables as well, just to be on the safe side.
6893 (set-buffer gnus-group-buffer)
6894 (gnus-summary-clear-local-variables)
6895 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6896 (gnus-summary-clear-local-variables))
6897 ;; Return to group mode buffer.
6898 (when (eq mode 'gnus-summary-mode)
6899 (gnus-kill-buffer buf)))
6900 (setq gnus-current-select-method gnus-select-method)
6901 (set-buffer gnus-group-buffer)
6902 (if quit-config
6903 (gnus-handle-ephemeral-exit quit-config)
6904 (goto-char group-point)
6905 ;; If gnus-group-buffer is already displayed, make sure we also move
6906 ;; the cursor in the window that displays it.
6907 (let ((win (get-buffer-window (current-buffer) 0)))
6908 (if win (set-window-point win (point))))
6909 (unless leave-hidden
6910 (gnus-configure-windows 'group 'force)))
6911 ;; Clear the current group name.
6912 (unless quit-config
6913 (setq gnus-newsgroup-name nil)))))
6914
6915 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6916 (defun gnus-summary-exit-no-update (&optional no-questions)
6917 "Quit reading current newsgroup without updating read article info."
6918 (interactive)
6919 (let* ((group gnus-newsgroup-name)
6920 (gnus-group-is-exiting-p t)
6921 (gnus-group-is-exiting-without-update-p t)
6922 (quit-config (gnus-group-quit-config group)))
6923 (when (or no-questions
6924 gnus-expert-user
6925 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6926 (gnus-async-halt-prefetch)
6927 (run-hooks 'gnus-summary-prepare-exit-hook)
6928 (when (gnus-buffer-live-p gnus-article-buffer)
6929 (save-excursion
6930 (set-buffer gnus-article-buffer)
6931 (mm-destroy-parts gnus-article-mime-handles)
6932 ;; Set it to nil for safety reason.
6933 (setq gnus-article-mime-handle-alist nil)
6934 (setq gnus-article-mime-handles nil)))
6935 ;; If we have several article buffers, we kill them at exit.
6936 (unless gnus-single-article-buffer
6937 (gnus-kill-buffer gnus-article-buffer)
6938 (gnus-kill-buffer gnus-original-article-buffer)
6939 (setq gnus-article-current nil))
6940 (if (not gnus-kill-summary-on-exit)
6941 (gnus-deaden-summary)
6942 (gnus-close-group group)
6943 (gnus-summary-clear-local-variables)
6944 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6945 (gnus-summary-clear-local-variables))
6946 (set-buffer gnus-group-buffer)
6947 (gnus-summary-clear-local-variables)
6948 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6949 (gnus-summary-clear-local-variables))
6950 (gnus-kill-buffer gnus-summary-buffer))
6951 (unless gnus-single-article-buffer
6952 (setq gnus-article-current nil))
6953 (when gnus-use-trees
6954 (gnus-tree-close group))
6955 (gnus-async-prefetch-remove-group group)
6956 (when (get-buffer gnus-article-buffer)
6957 (bury-buffer gnus-article-buffer))
6958 ;; Return to the group buffer.
6959 (gnus-configure-windows 'group 'force)
6960 ;; Clear the current group name.
6961 (setq gnus-newsgroup-name nil)
6962 (unless (gnus-ephemeral-group-p group)
6963 (gnus-group-update-group group))
6964 (when (equal (gnus-group-group-name) group)
6965 (gnus-group-next-unread-group 1))
6966 (when quit-config
6967 (gnus-handle-ephemeral-exit quit-config)))))
6968
6969 (defun gnus-handle-ephemeral-exit (quit-config)
6970 "Handle movement when leaving an ephemeral group.
6971 The state which existed when entering the ephemeral is reset."
6972 (if (not (buffer-name (car quit-config)))
6973 (gnus-configure-windows 'group 'force)
6974 (set-buffer (car quit-config))
6975 (cond ((eq major-mode 'gnus-summary-mode)
6976 (gnus-set-global-variables))
6977 ((eq major-mode 'gnus-article-mode)
6978 (save-excursion
6979 ;; The `gnus-summary-buffer' variable may point
6980 ;; to the old summary buffer when using a single
6981 ;; article buffer.
6982 (unless (gnus-buffer-live-p gnus-summary-buffer)
6983 (set-buffer gnus-group-buffer))
6984 (set-buffer gnus-summary-buffer)
6985 (gnus-set-global-variables))))
6986 (if (or (eq (cdr quit-config) 'article)
6987 (eq (cdr quit-config) 'pick))
6988 (progn
6989 ;; The current article may be from the ephemeral group
6990 ;; thus it is best that we reload this article
6991 ;;
6992 ;; If we're exiting from a large digest, this can be
6993 ;; extremely slow. So, it's better not to reload it. -- jh.
6994 ;;(gnus-summary-show-article)
6995 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6996 (gnus-configure-windows 'pick 'force)
6997 (gnus-configure-windows (cdr quit-config) 'force)))
6998 (gnus-configure-windows (cdr quit-config) 'force))
6999 (when (eq major-mode 'gnus-summary-mode)
7000 (gnus-summary-next-subject 1 nil t)
7001 (gnus-summary-recenter)
7002 (gnus-summary-position-point))))
7003
7004 ;;; Dead summaries.
7005
7006 (defvar gnus-dead-summary-mode-map nil)
7007
7008 (unless gnus-dead-summary-mode-map
7009 (setq gnus-dead-summary-mode-map (make-keymap))
7010 (suppress-keymap gnus-dead-summary-mode-map)
7011 (substitute-key-definition
7012 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
7013 (dolist (key '("\C-d" "\r" "\177" [delete]))
7014 (define-key gnus-dead-summary-mode-map
7015 key 'gnus-summary-wake-up-the-dead))
7016 (dolist (key '("q" "Q"))
7017 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
7018
7019 (defvar gnus-dead-summary-mode nil
7020 "Minor mode for Gnus summary buffers.")
7021
7022 (defun gnus-dead-summary-mode (&optional arg)
7023 "Minor mode for Gnus summary buffers."
7024 (interactive "P")
7025 (when (eq major-mode 'gnus-summary-mode)
7026 (make-local-variable 'gnus-dead-summary-mode)
7027 (setq gnus-dead-summary-mode
7028 (if (null arg) (not gnus-dead-summary-mode)
7029 (> (prefix-numeric-value arg) 0)))
7030 (when gnus-dead-summary-mode
7031 (gnus-add-minor-mode
7032 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
7033
7034 (defun gnus-deaden-summary ()
7035 "Make the current summary buffer into a dead summary buffer."
7036 ;; Kill any previous dead summary buffer.
7037 (when (and gnus-dead-summary
7038 (buffer-name gnus-dead-summary))
7039 (save-excursion
7040 (set-buffer gnus-dead-summary)
7041 (when gnus-dead-summary-mode
7042 (kill-buffer (current-buffer)))))
7043 ;; Make this the current dead summary.
7044 (setq gnus-dead-summary (current-buffer))
7045 (gnus-dead-summary-mode 1)
7046 (let ((name (buffer-name)))
7047 (when (string-match "Summary" name)
7048 (rename-buffer
7049 (concat (substring name 0 (match-beginning 0)) "Dead "
7050 (substring name (match-beginning 0)))
7051 t)
7052 (bury-buffer))))
7053
7054 (defun gnus-kill-or-deaden-summary (buffer)
7055 "Kill or deaden the summary BUFFER."
7056 (save-excursion
7057 (when (and (buffer-name buffer)
7058 (not gnus-single-article-buffer))
7059 (save-excursion
7060 (set-buffer buffer)
7061 (gnus-kill-buffer gnus-article-buffer)
7062 (gnus-kill-buffer gnus-original-article-buffer)))
7063 (cond
7064 ;; Kill the buffer.
7065 (gnus-kill-summary-on-exit
7066 (when (and gnus-use-trees
7067 (gnus-buffer-exists-p buffer))
7068 (save-excursion
7069 (set-buffer buffer)
7070 (gnus-tree-close gnus-newsgroup-name)))
7071 (gnus-kill-buffer buffer))
7072 ;; Deaden the buffer.
7073 ((gnus-buffer-exists-p buffer)
7074 (save-excursion
7075 (set-buffer buffer)
7076 (gnus-deaden-summary))))))
7077
7078 (defun gnus-summary-wake-up-the-dead (&rest args)
7079 "Wake up the dead summary buffer."
7080 (interactive)
7081 (gnus-dead-summary-mode -1)
7082 (let ((name (buffer-name)))
7083 (when (string-match "Dead " name)
7084 (rename-buffer
7085 (concat (substring name 0 (match-beginning 0))
7086 (substring name (match-end 0)))
7087 t)))
7088 (gnus-message 3 "This dead summary is now alive again"))
7089
7090 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
7091 (defun gnus-summary-fetch-faq (&optional faq-dir)
7092 "Fetch the FAQ for the current group.
7093 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
7094 in."
7095 (interactive
7096 (list
7097 (when current-prefix-arg
7098 (completing-read
7099 "FAQ dir: " (and (listp gnus-group-faq-directory)
7100 (mapcar (lambda (file) (list file))
7101 gnus-group-faq-directory))))))
7102 (let (gnus-faq-buffer)
7103 (when (setq gnus-faq-buffer
7104 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
7105 (gnus-configure-windows 'summary-faq))))
7106
7107 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7108 (defun gnus-summary-describe-group (&optional force)
7109 "Describe the current newsgroup."
7110 (interactive "P")
7111 (gnus-group-describe-group force gnus-newsgroup-name))
7112
7113 (defun gnus-summary-describe-briefly ()
7114 "Describe summary mode commands briefly."
7115 (interactive)
7116 (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")))
7117
7118 ;; Walking around group mode buffer from summary mode.
7119
7120 (defun gnus-summary-next-group (&optional no-article target-group backward)
7121 "Exit current newsgroup and then select next unread newsgroup.
7122 If prefix argument NO-ARTICLE is non-nil, no article is selected
7123 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7124 previous group instead."
7125 (interactive "P")
7126 ;; Stop pre-fetching.
7127 (gnus-async-halt-prefetch)
7128 (let ((current-group gnus-newsgroup-name)
7129 (current-buffer (current-buffer))
7130 entered)
7131 ;; First we semi-exit this group to update Xrefs and all variables.
7132 ;; We can't do a real exit, because the window conf must remain
7133 ;; the same in case the user is prompted for info, and we don't
7134 ;; want the window conf to change before that...
7135 (gnus-summary-exit t)
7136 (while (not entered)
7137 ;; Then we find what group we are supposed to enter.
7138 (set-buffer gnus-group-buffer)
7139 (gnus-group-jump-to-group current-group)
7140 (setq target-group
7141 (or target-group
7142 (if (eq gnus-keep-same-level 'best)
7143 (gnus-summary-best-group gnus-newsgroup-name)
7144 (gnus-summary-search-group backward gnus-keep-same-level))))
7145 (if (not target-group)
7146 ;; There are no further groups, so we return to the group
7147 ;; buffer.
7148 (progn
7149 (gnus-message 5 "Returning to the group buffer")
7150 (setq entered t)
7151 (when (gnus-buffer-live-p current-buffer)
7152 (set-buffer current-buffer)
7153 (gnus-summary-exit))
7154 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7155 ;; We try to enter the target group.
7156 (gnus-group-jump-to-group target-group)
7157 (let ((unreads (gnus-group-group-unread)))
7158 (if (and (or (eq t unreads)
7159 (and unreads (not (zerop unreads))))
7160 (gnus-summary-read-group
7161 target-group nil no-article
7162 (and (buffer-name current-buffer) current-buffer)
7163 nil backward))
7164 (setq entered t)
7165 (setq current-group target-group
7166 target-group nil)))))))
7167
7168 (defun gnus-summary-prev-group (&optional no-article)
7169 "Exit current newsgroup and then select previous unread newsgroup.
7170 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7171 (interactive "P")
7172 (gnus-summary-next-group no-article nil t))
7173
7174 ;; Walking around summary lines.
7175
7176 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7177 "Go to the first subject satisfying any non-nil constraint.
7178 If UNREAD is non-nil, the article should be unread.
7179 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7180 If UNSEEN is non-nil, the article should be unseen.
7181 Returns the article selected or nil if there are no matching articles."
7182 (interactive "P")
7183 (cond
7184 ;; Empty summary.
7185 ((null gnus-newsgroup-data)
7186 (gnus-message 3 "No articles in the group")
7187 nil)
7188 ;; Pick the first article.
7189 ((not (or unread undownloaded unseen))
7190 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7191 (gnus-data-number (car gnus-newsgroup-data)))
7192 ;; Find the first unread article.
7193 (t
7194 (let ((data gnus-newsgroup-data))
7195 (while (and data
7196 (let ((num (gnus-data-number (car data))))
7197 (or (memq num gnus-newsgroup-unfetched)
7198 (not (or (and unread
7199 (memq num gnus-newsgroup-unreads))
7200 (and undownloaded
7201 (memq num gnus-newsgroup-undownloaded))
7202 (and unseen
7203 (memq num gnus-newsgroup-unseen)))))))
7204 (setq data (cdr data)))
7205 (prog1
7206 (if data
7207 (progn
7208 (goto-char (gnus-data-pos (car data)))
7209 (gnus-data-number (car data)))
7210 (gnus-message 3 "No more%s articles"
7211 (let* ((r (when unread " unread"))
7212 (d (when undownloaded " undownloaded"))
7213 (s (when unseen " unseen"))
7214 (l (delq nil (list r d s))))
7215 (cond ((= 3 (length l))
7216 (concat r "," d ", or" s))
7217 ((= 2 (length l))
7218 (concat (car l) ", or" (cadr l)))
7219 ((= 1 (length l))
7220 (car l))
7221 (t
7222 ""))))
7223 nil
7224 )
7225 (gnus-summary-position-point))))))
7226
7227 (defun gnus-summary-next-subject (n &optional unread dont-display)
7228 "Go to next N'th summary line.
7229 If N is negative, go to the previous N'th subject line.
7230 If UNREAD is non-nil, only unread articles are selected.
7231 The difference between N and the actual number of steps taken is
7232 returned."
7233 (interactive "p")
7234 (let ((backward (< n 0))
7235 (n (abs n)))
7236 (while (and (> n 0)
7237 (if backward
7238 (gnus-summary-find-prev unread)
7239 (gnus-summary-find-next unread)))
7240 (unless (zerop (setq n (1- n)))
7241 (gnus-summary-show-thread)))
7242 (when (/= 0 n)
7243 (gnus-message 7 "No more%s articles"
7244 (if unread " unread" "")))
7245 (unless dont-display
7246 (gnus-summary-recenter)
7247 (gnus-summary-position-point))
7248 n))
7249
7250 (defun gnus-summary-next-unread-subject (n)
7251 "Go to next N'th unread summary line."
7252 (interactive "p")
7253 (gnus-summary-next-subject n t))
7254
7255 (defun gnus-summary-prev-subject (n &optional unread)
7256 "Go to previous N'th summary line.
7257 If optional argument UNREAD is non-nil, only unread article is selected."
7258 (interactive "p")
7259 (gnus-summary-next-subject (- n) unread))
7260
7261 (defun gnus-summary-prev-unread-subject (n)
7262 "Go to previous N'th unread summary line."
7263 (interactive "p")
7264 (gnus-summary-next-subject (- n) t))
7265
7266 (defun gnus-summary-goto-subjects (articles)
7267 "Insert the subject header for ARTICLES in the current buffer."
7268 (save-excursion
7269 (dolist (article articles)
7270 (gnus-summary-goto-subject article t)))
7271 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7272 (gnus-summary-position-point))
7273
7274 (defun gnus-summary-goto-subject (article &optional force silent)
7275 "Go to the subject line of ARTICLE.
7276 If FORCE, also allow jumping to articles not currently shown."
7277 (interactive "nArticle number: ")
7278 (unless (numberp article)
7279 (error "Article %s is not a number" article))
7280 (let ((b (point))
7281 (data (gnus-data-find article)))
7282 ;; We read in the article if we have to.
7283 (and (not data)
7284 force
7285 (gnus-summary-insert-subject
7286 article
7287 (if (or (numberp force) (vectorp force)) force)
7288 t)
7289 (setq data (gnus-data-find article)))
7290 (goto-char b)
7291 (if (not data)
7292 (progn
7293 (unless silent
7294 (gnus-message 3 "Can't find article %d" article))
7295 nil)
7296 (let ((pt (gnus-data-pos data)))
7297 (goto-char pt)
7298 (gnus-summary-set-article-display-arrow pt))
7299 (gnus-summary-position-point)
7300 article)))
7301
7302 ;; Walking around summary lines with displaying articles.
7303
7304 (defun gnus-summary-expand-window (&optional arg)
7305 "Make the summary buffer take up the entire Emacs frame.
7306 Given a prefix, will force an `article' buffer configuration."
7307 (interactive "P")
7308 (if arg
7309 (gnus-configure-windows 'article 'force)
7310 (gnus-configure-windows 'summary 'force)))
7311
7312 (defun gnus-summary-display-article (article &optional all-header)
7313 "Display ARTICLE in article buffer."
7314 (when (gnus-buffer-live-p gnus-article-buffer)
7315 (with-current-buffer gnus-article-buffer
7316 (mm-enable-multibyte)))
7317 (gnus-set-global-variables)
7318 (when (gnus-buffer-live-p gnus-article-buffer)
7319 (with-current-buffer gnus-article-buffer
7320 (setq gnus-article-charset gnus-newsgroup-charset)
7321 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7322 (mm-enable-multibyte)))
7323 (if (null article)
7324 nil
7325 (prog1
7326 (if gnus-summary-display-article-function
7327 (funcall gnus-summary-display-article-function article all-header)
7328 (gnus-article-prepare article all-header))
7329 (gnus-run-hooks 'gnus-select-article-hook)
7330 (when (and gnus-current-article
7331 (not (zerop gnus-current-article)))
7332 (gnus-summary-goto-subject gnus-current-article))
7333 (gnus-summary-recenter)
7334 (when (and gnus-use-trees gnus-show-threads)
7335 (gnus-possibly-generate-tree article)
7336 (gnus-highlight-selected-tree article))
7337 ;; Successfully display article.
7338 (gnus-article-set-window-start
7339 (cdr (assq article gnus-newsgroup-bookmarks))))))
7340
7341 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7342 "Select the current article.
7343 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7344 non-nil, the article will be re-fetched even if it already present in
7345 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7346 be displayed."
7347 ;; Make sure we are in the summary buffer to work around bbdb bug.
7348 (unless (eq major-mode 'gnus-summary-mode)
7349 (set-buffer gnus-summary-buffer))
7350 (let ((article (or article (gnus-summary-article-number)))
7351 (all-headers (not (not all-headers))) ;Must be t or nil.
7352 gnus-summary-display-article-function)
7353 (and (not pseudo)
7354 (gnus-summary-article-pseudo-p article)
7355 (error "This is a pseudo-article"))
7356 (save-excursion
7357 (set-buffer gnus-summary-buffer)
7358 (if (or (and gnus-single-article-buffer
7359 (or (null gnus-current-article)
7360 (null gnus-article-current)
7361 (null (get-buffer gnus-article-buffer))
7362 (not (eq article (cdr gnus-article-current)))
7363 (not (equal (car gnus-article-current)
7364 gnus-newsgroup-name))))
7365 (and (not gnus-single-article-buffer)
7366 (or (null gnus-current-article)
7367 (not (eq gnus-current-article article))))
7368 force)
7369 ;; The requested article is different from the current article.
7370 (progn
7371 (gnus-summary-display-article article all-headers)
7372 (when (gnus-buffer-live-p gnus-article-buffer)
7373 (with-current-buffer gnus-article-buffer
7374 (if (not gnus-article-decoded-p) ;; a local variable
7375 (mm-disable-multibyte))))
7376 (gnus-article-set-window-start
7377 (cdr (assq article gnus-newsgroup-bookmarks)))
7378 article)
7379 'old))))
7380
7381 (defun gnus-summary-force-verify-and-decrypt ()
7382 "Display buttons for signed/encrypted parts and verify/decrypt them."
7383 (interactive)
7384 (let ((mm-verify-option 'known)
7385 (mm-decrypt-option 'known)
7386 (gnus-article-emulate-mime t)
7387 (gnus-buttonized-mime-types (append (list "multipart/signed"
7388 "multipart/encrypted")
7389 gnus-buttonized-mime-types)))
7390 (gnus-summary-select-article nil 'force)))
7391
7392 (defun gnus-summary-set-current-mark (&optional current-mark)
7393 "Obsolete function."
7394 nil)
7395
7396 (defun gnus-summary-next-article (&optional unread subject backward push)
7397 "Select the next article.
7398 If UNREAD, only unread articles are selected.
7399 If SUBJECT, only articles with SUBJECT are selected.
7400 If BACKWARD, the previous article is selected instead of the next."
7401 (interactive "P")
7402 ;; Make sure we are in the summary buffer.
7403 (unless (eq major-mode 'gnus-summary-mode)
7404 (set-buffer gnus-summary-buffer))
7405 (cond
7406 ;; Is there such an article?
7407 ((and (gnus-summary-search-forward unread subject backward)
7408 (or (gnus-summary-display-article (gnus-summary-article-number))
7409 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7410 (gnus-summary-position-point))
7411 ;; If not, we try the first unread, if that is wanted.
7412 ((and subject
7413 gnus-auto-select-same
7414 (gnus-summary-first-unread-article))
7415 (gnus-summary-position-point)
7416 (gnus-message 6 "Wrapped"))
7417 ;; Try to get next/previous article not displayed in this group.
7418 ((and gnus-auto-extend-newsgroup
7419 (not unread) (not subject))
7420 (gnus-summary-goto-article
7421 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7422 nil (count-lines (point-min) (point))))
7423 ;; Go to next/previous group.
7424 (t
7425 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7426 (gnus-summary-jump-to-group gnus-newsgroup-name))
7427 (let ((cmd last-command-char)
7428 (point
7429 (save-excursion
7430 (set-buffer gnus-group-buffer)
7431 (point)))
7432 (group
7433 (if (eq gnus-keep-same-level 'best)
7434 (gnus-summary-best-group gnus-newsgroup-name)
7435 (gnus-summary-search-group backward gnus-keep-same-level))))
7436 ;; For some reason, the group window gets selected. We change
7437 ;; it back.
7438 (select-window (get-buffer-window (current-buffer)))
7439 ;; Select next unread newsgroup automagically.
7440 (cond
7441 ((or (not gnus-auto-select-next)
7442 (not cmd))
7443 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7444 ((or (eq gnus-auto-select-next 'quietly)
7445 (and (eq gnus-auto-select-next 'slightly-quietly)
7446 push)
7447 (and (eq gnus-auto-select-next 'almost-quietly)
7448 (gnus-summary-last-article-p)))
7449 ;; Select quietly.
7450 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7451 (gnus-summary-exit)
7452 (gnus-message 7 "No more%s articles (%s)..."
7453 (if unread " unread" "")
7454 (if group (concat "selecting " group)
7455 "exiting"))
7456 (gnus-summary-next-group nil group backward)))
7457 (t
7458 (when (gnus-key-press-event-p last-input-event)
7459 (gnus-summary-walk-group-buffer
7460 gnus-newsgroup-name cmd unread backward point))))))))
7461
7462 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7463 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7464 (?\C-p (gnus-group-prev-unread-group 1))))
7465 (cursor-in-echo-area t)
7466 keve key group ended prompt)
7467 (save-excursion
7468 (set-buffer gnus-group-buffer)
7469 (goto-char start)
7470 (setq group
7471 (if (eq gnus-keep-same-level 'best)
7472 (gnus-summary-best-group gnus-newsgroup-name)
7473 (gnus-summary-search-group backward gnus-keep-same-level))))
7474 (while (not ended)
7475 (setq prompt
7476 (format
7477 "No more%s articles%s " (if unread " unread" "")
7478 (if (and group
7479 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7480 (format " (Type %s for %s [%s])"
7481 (single-key-description cmd)
7482 (gnus-group-decoded-name group)
7483 (car (gnus-gethash group gnus-newsrc-hashtb)))
7484 (format " (Type %s to exit %s)"
7485 (single-key-description cmd)
7486 (gnus-group-decoded-name gnus-newsgroup-name)))))
7487 ;; Confirm auto selection.
7488 (setq key (car (setq keve (gnus-read-event-char prompt)))
7489 ended t)
7490 (cond
7491 ((assq key keystrokes)
7492 (let ((obuf (current-buffer)))
7493 (switch-to-buffer gnus-group-buffer)
7494 (when group
7495 (gnus-group-jump-to-group group))
7496 (eval (cadr (assq key keystrokes)))
7497 (setq group (gnus-group-group-name))
7498 (switch-to-buffer obuf))
7499 (setq ended nil))
7500 ((equal key cmd)
7501 (if (or (not group)
7502 (gnus-ephemeral-group-p gnus-newsgroup-name))
7503 (gnus-summary-exit)
7504 (gnus-summary-next-group nil group backward)))
7505 (t
7506 (push (cdr keve) unread-command-events))))))
7507
7508 (defun gnus-summary-next-unread-article ()
7509 "Select unread article after current one."
7510 (interactive)
7511 (gnus-summary-next-article
7512 (or (not (eq gnus-summary-goto-unread 'never))
7513 (gnus-summary-last-article-p (gnus-summary-article-number)))
7514 (and gnus-auto-select-same
7515 (gnus-summary-article-subject))))
7516
7517 (defun gnus-summary-prev-article (&optional unread subject)
7518 "Select the article before the current one.
7519 If UNREAD is non-nil, only unread articles are selected."
7520 (interactive "P")
7521 (gnus-summary-next-article unread subject t))
7522
7523 (defun gnus-summary-prev-unread-article ()
7524 "Select unread article before current one."
7525 (interactive)
7526 (gnus-summary-prev-article
7527 (or (not (eq gnus-summary-goto-unread 'never))
7528 (gnus-summary-first-article-p (gnus-summary-article-number)))
7529 (and gnus-auto-select-same
7530 (gnus-summary-article-subject))))
7531
7532 (defun gnus-summary-next-page (&optional lines circular stop)
7533 "Show next page of the selected article.
7534 If at the end of the current article, select the next article.
7535 LINES says how many lines should be scrolled up.
7536
7537 If CIRCULAR is non-nil, go to the start of the article instead of
7538 selecting the next article when reaching the end of the current
7539 article.
7540
7541 If STOP is non-nil, just stop when reaching the end of the message.
7542
7543 Also see the variable `gnus-article-skip-boring'."
7544 (interactive "P")
7545 (setq gnus-summary-buffer (current-buffer))
7546 (gnus-set-global-variables)
7547 (let ((article (gnus-summary-article-number))
7548 (article-window (get-buffer-window gnus-article-buffer t))
7549 endp)
7550 ;; If the buffer is empty, we have no article.
7551 (unless article
7552 (error "No article to select"))
7553 (gnus-configure-windows 'article)
7554 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7555 (if (and (eq gnus-summary-goto-unread 'never)
7556 (not (gnus-summary-last-article-p article)))
7557 (gnus-summary-next-article)
7558 (gnus-summary-next-unread-article))
7559 (if (or (null gnus-current-article)
7560 (null gnus-article-current)
7561 (/= article (cdr gnus-article-current))
7562 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7563 ;; Selected subject is different from current article's.
7564 (gnus-summary-display-article article)
7565 (when article-window
7566 (gnus-eval-in-buffer-window gnus-article-buffer
7567 (setq endp (or (gnus-article-next-page lines)
7568 (gnus-article-only-boring-p))))
7569 (when endp
7570 (cond (stop
7571 (gnus-message 3 "End of message"))
7572 (circular
7573 (gnus-summary-beginning-of-article))
7574 (lines
7575 (gnus-message 3 "End of message"))
7576 ((null lines)
7577 (if (and (eq gnus-summary-goto-unread 'never)
7578 (not (gnus-summary-last-article-p article)))
7579 (gnus-summary-next-article)
7580 (gnus-summary-next-unread-article))))))))
7581 (gnus-summary-recenter)
7582 (gnus-summary-position-point)))
7583
7584 (defun gnus-summary-prev-page (&optional lines move)
7585 "Show previous page of selected article.
7586 Argument LINES specifies lines to be scrolled down.
7587 If MOVE, move to the previous unread article if point is at
7588 the beginning of the buffer."
7589 (interactive "P")
7590 (let ((article (gnus-summary-article-number))
7591 (article-window (get-buffer-window gnus-article-buffer t))
7592 endp)
7593 (gnus-configure-windows 'article)
7594 (if (or (null gnus-current-article)
7595 (null gnus-article-current)
7596 (/= article (cdr gnus-article-current))
7597 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7598 ;; Selected subject is different from current article's.
7599 (gnus-summary-display-article article)
7600 (gnus-summary-recenter)
7601 (when article-window
7602 (gnus-eval-in-buffer-window gnus-article-buffer
7603 (setq endp (gnus-article-prev-page lines)))
7604 (when (and move endp)
7605 (cond (lines
7606 (gnus-message 3 "Beginning of message"))
7607 ((null lines)
7608 (if (and (eq gnus-summary-goto-unread 'never)
7609 (not (gnus-summary-first-article-p article)))
7610 (gnus-summary-prev-article)
7611 (gnus-summary-prev-unread-article))))))))
7612 (gnus-summary-position-point))
7613
7614 (defun gnus-summary-prev-page-or-article (&optional lines)
7615 "Show previous page of selected article.
7616 Argument LINES specifies lines to be scrolled down.
7617 If at the beginning of the article, go to the next article."
7618 (interactive "P")
7619 (gnus-summary-prev-page lines t))
7620
7621 (defun gnus-summary-scroll-up (lines)
7622 "Scroll up (or down) one line current article.
7623 Argument LINES specifies lines to be scrolled up (or down if negative)."
7624 (interactive "p")
7625 (gnus-configure-windows 'article)
7626 (gnus-summary-show-thread)
7627 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7628 (gnus-eval-in-buffer-window gnus-article-buffer
7629 (cond ((> lines 0)
7630 (when (gnus-article-next-page lines)
7631 (gnus-message 3 "End of message")))
7632 ((< lines 0)
7633 (gnus-article-prev-page (- lines))))))
7634 (gnus-summary-recenter)
7635 (gnus-summary-position-point))
7636
7637 (defun gnus-summary-scroll-down (lines)
7638 "Scroll down (or up) one line current article.
7639 Argument LINES specifies lines to be scrolled down (or up if negative)."
7640 (interactive "p")
7641 (gnus-summary-scroll-up (- lines)))
7642
7643 (defun gnus-summary-next-same-subject ()
7644 "Select next article which has the same subject as current one."
7645 (interactive)
7646 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7647
7648 (defun gnus-summary-prev-same-subject ()
7649 "Select previous article which has the same subject as current one."
7650 (interactive)
7651 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7652
7653 (defun gnus-summary-next-unread-same-subject ()
7654 "Select next unread article which has the same subject as current one."
7655 (interactive)
7656 (gnus-summary-next-article t (gnus-summary-article-subject)))
7657
7658 (defun gnus-summary-prev-unread-same-subject ()
7659 "Select previous unread article which has the same subject as current one."
7660 (interactive)
7661 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7662
7663 (defun gnus-summary-first-unread-article ()
7664 "Select the first unread article.
7665 Return nil if there are no unread articles."
7666 (interactive)
7667 (prog1
7668 (when (gnus-summary-first-subject t)
7669 (gnus-summary-show-thread)
7670 (gnus-summary-first-subject t)
7671 (gnus-summary-display-article (gnus-summary-article-number)))
7672 (gnus-summary-position-point)))
7673
7674 (defun gnus-summary-first-unread-subject ()
7675 "Place the point on the subject line of the first unread article.
7676 Return nil if there are no unread articles."
7677 (interactive)
7678 (prog1
7679 (when (gnus-summary-first-subject t)
7680 (gnus-summary-show-thread)
7681 (gnus-summary-first-subject t))
7682 (gnus-summary-position-point)))
7683
7684 (defun gnus-summary-first-unseen-subject ()
7685 "Place the point on the subject line of the first unseen article.
7686 Return nil if there are no unseen articles."
7687 (interactive)
7688 (prog1
7689 (when (gnus-summary-first-subject nil nil t)
7690 (gnus-summary-show-thread)
7691 (gnus-summary-first-subject nil nil t))
7692 (gnus-summary-position-point)))
7693
7694 (defun gnus-summary-first-unseen-or-unread-subject ()
7695 "Place the point on the subject line of the first unseen article or,
7696 if all article have been seen, on the subject line of the first unread
7697 article."
7698 (interactive)
7699 (prog1
7700 (unless (when (gnus-summary-first-subject nil nil t)
7701 (gnus-summary-show-thread)
7702 (gnus-summary-first-subject nil nil t))
7703 (when (gnus-summary-first-subject t)
7704 (gnus-summary-show-thread)
7705 (gnus-summary-first-subject t)))
7706 (gnus-summary-position-point)))
7707
7708 (defun gnus-summary-first-article ()
7709 "Select the first article.
7710 Return nil if there are no articles."
7711 (interactive)
7712 (prog1
7713 (when (gnus-summary-first-subject)
7714 (gnus-summary-show-thread)
7715 (gnus-summary-first-subject)
7716 (gnus-summary-display-article (gnus-summary-article-number)))
7717 (gnus-summary-position-point)))
7718
7719 (defun gnus-summary-best-unread-article (&optional arg)
7720 "Select the unread article with the highest score.
7721 If given a prefix argument, select the next unread article that has a
7722 score higher than the default score."
7723 (interactive "P")
7724 (let ((article (if arg
7725 (gnus-summary-better-unread-subject)
7726 (gnus-summary-best-unread-subject))))
7727 (if article
7728 (gnus-summary-goto-article article)
7729 (error "No unread articles"))))
7730
7731 (defun gnus-summary-best-unread-subject ()
7732 "Select the unread subject with the highest score."
7733 (interactive)
7734 (let ((best -1000000)
7735 (data gnus-newsgroup-data)
7736 article score)
7737 (while data
7738 (and (gnus-data-unread-p (car data))
7739 (> (setq score
7740 (gnus-summary-article-score (gnus-data-number (car data))))
7741 best)
7742 (setq best score
7743 article (gnus-data-number (car data))))
7744 (setq data (cdr data)))
7745 (when article
7746 (gnus-summary-goto-subject article))
7747 (gnus-summary-position-point)
7748 article))
7749
7750 (defun gnus-summary-better-unread-subject ()
7751 "Select the first unread subject that has a score over the default score."
7752 (interactive)
7753 (let ((data gnus-newsgroup-data)
7754 article score)
7755 (while (and (setq article (gnus-data-number (car data)))
7756 (or (gnus-data-read-p (car data))
7757 (not (> (gnus-summary-article-score article)
7758 gnus-summary-default-score))))
7759 (setq data (cdr data)))
7760 (when article
7761 (gnus-summary-goto-subject article))
7762 (gnus-summary-position-point)
7763 article))
7764
7765 (defun gnus-summary-last-subject ()
7766 "Go to the last displayed subject line in the group."
7767 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7768 (when article
7769 (gnus-summary-goto-subject article))))
7770
7771 (defun gnus-summary-goto-article (article &optional all-headers force)
7772 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7773 If ALL-HEADERS is non-nil, no header lines are hidden.
7774 If FORCE, go to the article even if it isn't displayed. If FORCE
7775 is a number, it is the line the article is to be displayed on."
7776 (interactive
7777 (list
7778 (completing-read
7779 "Article number or Message-ID: "
7780 (mapcar (lambda (number) (list (int-to-string number)))
7781 gnus-newsgroup-limit))
7782 current-prefix-arg
7783 t))
7784 (prog1
7785 (if (and (stringp article)
7786 (string-match "@\\|%40" article))
7787 (gnus-summary-refer-article article)
7788 (when (stringp article)
7789 (setq article (string-to-number article)))
7790 (if (gnus-summary-goto-subject article force)
7791 (gnus-summary-display-article article all-headers)
7792 (gnus-message 4 "Couldn't go to article %s" article) nil))
7793 (gnus-summary-position-point)))
7794
7795 (defun gnus-summary-goto-last-article ()
7796 "Go to the previously read article."
7797 (interactive)
7798 (prog1
7799 (when gnus-last-article
7800 (gnus-summary-goto-article gnus-last-article nil t))
7801 (gnus-summary-position-point)))
7802
7803 (defun gnus-summary-pop-article (number)
7804 "Pop one article off the history and go to the previous.
7805 NUMBER articles will be popped off."
7806 (interactive "p")
7807 (let (to)
7808 (setq gnus-newsgroup-history
7809 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7810 (if to
7811 (gnus-summary-goto-article (car to) nil t)
7812 (error "Article history empty")))
7813 (gnus-summary-position-point))
7814
7815 ;; Summary commands and functions for limiting the summary buffer.
7816
7817 (defun gnus-summary-limit-to-articles (n)
7818 "Limit the summary buffer to the next N articles.
7819 If not given a prefix, use the process marked articles instead."
7820 (interactive "P")
7821 (prog1
7822 (let ((articles (gnus-summary-work-articles n)))
7823 (setq gnus-newsgroup-processable nil)
7824 (gnus-summary-limit articles))
7825 (gnus-summary-position-point)))
7826
7827 (defun gnus-summary-pop-limit (&optional total)
7828 "Restore the previous limit.
7829 If given a prefix, remove all limits."
7830 (interactive "P")
7831 (when total
7832 (setq gnus-newsgroup-limits
7833 (list (mapcar (lambda (h) (mail-header-number h))
7834 gnus-newsgroup-headers))))
7835 (unless gnus-newsgroup-limits
7836 (error "No limit to pop"))
7837 (prog1
7838 (gnus-summary-limit nil 'pop)
7839 (gnus-summary-position-point)))
7840
7841 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7842 "Limit the summary buffer to articles that have subjects that match a regexp.
7843 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7844 (interactive
7845 (list (read-string (if current-prefix-arg
7846 "Exclude subject (regexp): "
7847 "Limit to subject (regexp): "))
7848 nil current-prefix-arg))
7849 (unless header
7850 (setq header "subject"))
7851 (when (not (equal "" subject))
7852 (prog1
7853 (let ((articles (gnus-summary-find-matching
7854 (or header "subject") subject 'all nil nil
7855 not-matching)))
7856 (unless articles
7857 (error "Found no matches for \"%s\"" subject))
7858 (gnus-summary-limit articles))
7859 (gnus-summary-position-point))))
7860
7861 (defun gnus-summary-limit-to-author (from &optional not-matching)
7862 "Limit the summary buffer to articles that have authors that match a regexp.
7863 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7864 (interactive
7865 (list (read-string (if current-prefix-arg
7866 "Exclude author (regexp): "
7867 "Limit to author (regexp): "))
7868 current-prefix-arg))
7869 (gnus-summary-limit-to-subject from "from" not-matching))
7870
7871 (defun gnus-summary-limit-to-age (age &optional younger-p)
7872 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7873 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7874 articles that are younger than AGE days."
7875 (interactive
7876 (let ((younger current-prefix-arg)
7877 (days-got nil)
7878 days)
7879 (while (not days-got)
7880 (setq days (if younger
7881 (read-string "Limit to articles younger than (in days, older when negative): ")
7882 (read-string
7883 "Limit to articles older than (in days, younger when negative): ")))
7884 (when (> (length days) 0)
7885 (setq days (read days)))
7886 (if (numberp days)
7887 (progn
7888 (setq days-got t)
7889 (if (< days 0)
7890 (progn
7891 (setq younger (not younger))
7892 (setq days (* days -1)))))
7893 (message "Please enter a number.")
7894 (sleep-for 1)))
7895 (list days younger)))
7896 (prog1
7897 (let ((data gnus-newsgroup-data)
7898 (cutoff (days-to-time age))
7899 articles d date is-younger)
7900 (while (setq d (pop data))
7901 (when (and (vectorp (gnus-data-header d))
7902 (setq date (mail-header-date (gnus-data-header d))))
7903 (setq is-younger (time-less-p
7904 (time-since (condition-case ()
7905 (date-to-time date)
7906 (error '(0 0))))
7907 cutoff))
7908 (when (if younger-p
7909 is-younger
7910 (not is-younger))
7911 (push (gnus-data-number d) articles))))
7912 (gnus-summary-limit (nreverse articles)))
7913 (gnus-summary-position-point)))
7914
7915 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7916 "Limit the summary buffer to articles that match an 'extra' header."
7917 (interactive
7918 (let ((header
7919 (intern
7920 (gnus-completing-read-with-default
7921 (symbol-name (car gnus-extra-headers))
7922 (if current-prefix-arg
7923 "Exclude extra header"
7924 "Limit extra header")
7925 (mapcar (lambda (x)
7926 (cons (symbol-name x) x))
7927 gnus-extra-headers)
7928 nil
7929 t))))
7930 (list header
7931 (read-string (format "%s header %s (regexp): "
7932 (if current-prefix-arg "Exclude" "Limit to")
7933 header))
7934 current-prefix-arg)))
7935 (when (not (equal "" regexp))
7936 (prog1
7937 (let ((articles (gnus-summary-find-matching
7938 (cons 'extra header) regexp 'all nil nil
7939 not-matching)))
7940 (unless articles
7941 (error "Found no matches for \"%s\"" regexp))
7942 (gnus-summary-limit articles))
7943 (gnus-summary-position-point))))
7944
7945 (defun gnus-summary-limit-to-display-predicate ()
7946 "Limit the summary buffer to the predicated in the `display' group parameter."
7947 (interactive)
7948 (unless gnus-newsgroup-display
7949 (error "There is no `display' group parameter"))
7950 (let (articles)
7951 (dolist (number gnus-newsgroup-articles)
7952 (when (funcall gnus-newsgroup-display)
7953 (push number articles)))
7954 (gnus-summary-limit articles))
7955 (gnus-summary-position-point))
7956
7957 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7958 (make-obsolete
7959 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7960
7961 (defun gnus-summary-limit-to-unread (&optional all)
7962 "Limit the summary buffer to articles that are not marked as read.
7963 If ALL is non-nil, limit strictly to unread articles."
7964 (interactive "P")
7965 (if all
7966 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7967 (gnus-summary-limit-to-marks
7968 ;; Concat all the marks that say that an article is read and have
7969 ;; those removed.
7970 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7971 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7972 gnus-low-score-mark gnus-expirable-mark
7973 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7974 gnus-duplicate-mark gnus-souped-mark)
7975 'reverse)))
7976
7977 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7978 (make-obsolete 'gnus-summary-delete-marked-with
7979 'gnus-summary-limit-exclude-marks)
7980
7981 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7982 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7983 If REVERSE, limit the summary buffer to articles that are marked
7984 with MARKS. MARKS can either be a string of marks or a list of marks.
7985 Returns how many articles were removed."
7986 (interactive "sMarks: ")
7987 (gnus-summary-limit-to-marks marks t))
7988
7989 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7990 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7991 If REVERSE (the prefix), limit the summary buffer to articles that are
7992 not marked with MARKS. MARKS can either be a string of marks or a
7993 list of marks.
7994 Returns how many articles were removed."
7995 (interactive "sMarks: \nP")
7996 (prog1
7997 (let ((data gnus-newsgroup-data)
7998 (marks (if (listp marks) marks
7999 (append marks nil))) ; Transform to list.
8000 articles)
8001 (while data
8002 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8003 (memq (gnus-data-mark (car data)) marks))
8004 (push (gnus-data-number (car data)) articles))
8005 (setq data (cdr data)))
8006 (gnus-summary-limit articles))
8007 (gnus-summary-position-point)))
8008
8009 (defun gnus-summary-limit-to-score (score)
8010 "Limit to articles with score at or above SCORE."
8011 (interactive "NLimit to articles with score of at least: ")
8012 (let ((data gnus-newsgroup-data)
8013 articles)
8014 (while data
8015 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8016 score)
8017 (push (gnus-data-number (car data)) articles))
8018 (setq data (cdr data)))
8019 (prog1
8020 (gnus-summary-limit articles)
8021 (gnus-summary-position-point))))
8022
8023 (defun gnus-summary-limit-to-unseen ()
8024 "Limit to unseen articles."
8025 (interactive)
8026 (prog1
8027 (gnus-summary-limit gnus-newsgroup-unseen)
8028 (gnus-summary-position-point)))
8029
8030 (defun gnus-summary-limit-include-thread (id)
8031 "Display all the hidden articles that is in the thread with ID in it.
8032 When called interactively, ID is the Message-ID of the current
8033 article."
8034 (interactive (list (mail-header-id (gnus-summary-article-header))))
8035 (let ((articles (gnus-articles-in-thread
8036 (gnus-id-to-thread (gnus-root-id id)))))
8037 (prog1
8038 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8039 (gnus-summary-limit-include-matching-articles
8040 "subject"
8041 (regexp-quote (gnus-simplify-subject-re
8042 (mail-header-subject (gnus-id-to-header id)))))
8043 (gnus-summary-position-point))))
8044
8045 (defun gnus-summary-limit-include-matching-articles (header regexp)
8046 "Display all the hidden articles that have HEADERs that match REGEXP."
8047 (interactive (list (read-string "Match on header: ")
8048 (read-string "Regexp: ")))
8049 (let ((articles (gnus-find-matching-articles header regexp)))
8050 (prog1
8051 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8052 (gnus-summary-position-point))))
8053
8054 (defun gnus-summary-insert-dormant-articles ()
8055 "Insert all the dormant articles for this group into the current buffer."
8056 (interactive)
8057 (let ((gnus-verbose (max 6 gnus-verbose)))
8058 (if (not gnus-newsgroup-dormant)
8059 (gnus-message 3 "No dormant articles for this group")
8060 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8061
8062 (defun gnus-summary-limit-include-dormant ()
8063 "Display all the hidden articles that are marked as dormant.
8064 Note that this command only works on a subset of the articles currently
8065 fetched for this group."
8066 (interactive)
8067 (unless gnus-newsgroup-dormant
8068 (error "There are no dormant articles in this group"))
8069 (prog1
8070 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8071 (gnus-summary-position-point)))
8072
8073 (defun gnus-summary-limit-exclude-dormant ()
8074 "Hide all dormant articles."
8075 (interactive)
8076 (prog1
8077 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8078 (gnus-summary-position-point)))
8079
8080 (defun gnus-summary-limit-exclude-childless-dormant ()
8081 "Hide all dormant articles that have no children."
8082 (interactive)
8083 (let ((data (gnus-data-list t))
8084 articles d children)
8085 ;; Find all articles that are either not dormant or have
8086 ;; children.
8087 (while (setq d (pop data))
8088 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8089 (and (setq children
8090 (gnus-article-children (gnus-data-number d)))
8091 (let (found)
8092 (while children
8093 (when (memq (car children) articles)
8094 (setq children nil
8095 found t))
8096 (pop children))
8097 found)))
8098 (push (gnus-data-number d) articles)))
8099 ;; Do the limiting.
8100 (prog1
8101 (gnus-summary-limit articles)
8102 (gnus-summary-position-point))))
8103
8104 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8105 "Mark all unread excluded articles as read.
8106 If ALL, mark even excluded ticked and dormants as read."
8107 (interactive "P")
8108 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8109 (let ((articles (gnus-sorted-ndifference
8110 (sort
8111 (mapcar (lambda (h) (mail-header-number h))
8112 gnus-newsgroup-headers)
8113 '<)
8114 gnus-newsgroup-limit))
8115 article)
8116 (setq gnus-newsgroup-unreads
8117 (gnus-sorted-intersection gnus-newsgroup-unreads
8118 gnus-newsgroup-limit))
8119 (if all
8120 (setq gnus-newsgroup-dormant nil
8121 gnus-newsgroup-marked nil
8122 gnus-newsgroup-reads
8123 (nconc
8124 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8125 gnus-newsgroup-reads))
8126 (while (setq article (pop articles))
8127 (unless (or (memq article gnus-newsgroup-dormant)
8128 (memq article gnus-newsgroup-marked))
8129 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8130
8131 (defun gnus-summary-limit (articles &optional pop)
8132 (if pop
8133 ;; We pop the previous limit off the stack and use that.
8134 (setq articles (car gnus-newsgroup-limits)
8135 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8136 ;; We use the new limit, so we push the old limit on the stack.
8137 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8138 ;; Set the limit.
8139 (setq gnus-newsgroup-limit articles)
8140 (let ((total (length gnus-newsgroup-data))
8141 (data (gnus-data-find-list (gnus-summary-article-number)))
8142 (gnus-summary-mark-below nil) ; Inhibit this.
8143 found)
8144 ;; This will do all the work of generating the new summary buffer
8145 ;; according to the new limit.
8146 (gnus-summary-prepare)
8147 ;; Hide any threads, possibly.
8148 (gnus-summary-maybe-hide-threads)
8149 ;; Try to return to the article you were at, or one in the
8150 ;; neighborhood.
8151 (when data
8152 ;; We try to find some article after the current one.
8153 (while data
8154 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8155 (setq data nil
8156 found t))
8157 (setq data (cdr data))))
8158 (unless found
8159 ;; If there is no data, that means that we were after the last
8160 ;; article. The same goes when we can't find any articles
8161 ;; after the current one.
8162 (goto-char (point-max))
8163 (gnus-summary-find-prev))
8164 (gnus-set-mode-line 'summary)
8165 ;; We return how many articles were removed from the summary
8166 ;; buffer as a result of the new limit.
8167 (- total (length gnus-newsgroup-data))))
8168
8169 (defsubst gnus-invisible-cut-children (threads)
8170 (let ((num 0))
8171 (while threads
8172 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8173 (incf num))
8174 (pop threads))
8175 (< num 2)))
8176
8177 (defsubst gnus-cut-thread (thread)
8178 "Go forwards in the thread until we find an article that we want to display."
8179 (when (or (eq gnus-fetch-old-headers 'some)
8180 (eq gnus-fetch-old-headers 'invisible)
8181 (numberp gnus-fetch-old-headers)
8182 (eq gnus-build-sparse-threads 'some)
8183 (eq gnus-build-sparse-threads 'more))
8184 ;; Deal with old-fetched headers and sparse threads.
8185 (while (and
8186 thread
8187 (or
8188 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8189 (gnus-summary-article-ancient-p
8190 (mail-header-number (car thread))))
8191 (if (or (<= (length (cdr thread)) 1)
8192 (eq gnus-fetch-old-headers 'invisible))
8193 (setq gnus-newsgroup-limit
8194 (delq (mail-header-number (car thread))
8195 gnus-newsgroup-limit)
8196 thread (cadr thread))
8197 (when (gnus-invisible-cut-children (cdr thread))
8198 (let ((th (cdr thread)))
8199 (while th
8200 (if (memq (mail-header-number (caar th))
8201 gnus-newsgroup-limit)
8202 (setq thread (car th)
8203 th nil)
8204 (setq th (cdr th))))))))))
8205 thread)
8206
8207 (defun gnus-cut-threads (threads)
8208 "Cut off all uninteresting articles from the beginning of THREADS."
8209 (when (or (eq gnus-fetch-old-headers 'some)
8210 (eq gnus-fetch-old-headers 'invisible)
8211 (numberp gnus-fetch-old-headers)
8212 (eq gnus-build-sparse-threads 'some)
8213 (eq gnus-build-sparse-threads 'more))
8214 (let ((th threads))
8215 (while th
8216 (setcar th (gnus-cut-thread (car th)))
8217 (setq th (cdr th)))))
8218 ;; Remove nixed out threads.
8219 (delq nil threads))
8220
8221 (defun gnus-summary-initial-limit (&optional show-if-empty)
8222 "Figure out what the initial limit is supposed to be on group entry.
8223 This entails weeding out unwanted dormants, low-scored articles,
8224 fetch-old-headers verbiage, and so on."
8225 ;; Most groups have nothing to remove.
8226 (if (or gnus-inhibit-limiting
8227 (and (null gnus-newsgroup-dormant)
8228 (eq gnus-newsgroup-display 'gnus-not-ignore)
8229 (not (eq gnus-fetch-old-headers 'some))
8230 (not (numberp gnus-fetch-old-headers))
8231 (not (eq gnus-fetch-old-headers 'invisible))
8232 (null gnus-summary-expunge-below)
8233 (not (eq gnus-build-sparse-threads 'some))
8234 (not (eq gnus-build-sparse-threads 'more))
8235 (null gnus-thread-expunge-below)
8236 (not gnus-use-nocem)))
8237 () ; Do nothing.
8238 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8239 (setq gnus-newsgroup-limit nil)
8240 (mapatoms
8241 (lambda (node)
8242 (unless (car (symbol-value node))
8243 ;; These threads have no parents -- they are roots.
8244 (let ((nodes (cdr (symbol-value node)))
8245 thread)
8246 (while nodes
8247 (if (and gnus-thread-expunge-below
8248 (< (gnus-thread-total-score (car nodes))
8249 gnus-thread-expunge-below))
8250 (gnus-expunge-thread (pop nodes))
8251 (setq thread (pop nodes))
8252 (gnus-summary-limit-children thread))))))
8253 gnus-newsgroup-dependencies)
8254 ;; If this limitation resulted in an empty group, we might
8255 ;; pop the previous limit and use it instead.
8256 (when (and (not gnus-newsgroup-limit)
8257 show-if-empty)
8258 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8259 gnus-newsgroup-limit))
8260
8261 (defun gnus-summary-limit-children (thread)
8262 "Return 1 if this subthread is visible and 0 if it is not."
8263 ;; First we get the number of visible children to this thread. This
8264 ;; is done by recursing down the thread using this function, so this
8265 ;; will really go down to a leaf article first, before slowly
8266 ;; working its way up towards the root.
8267 (when thread
8268 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8269 (children
8270 (if (cdr thread)
8271 (apply '+ (mapcar 'gnus-summary-limit-children
8272 (cdr thread)))
8273 0))
8274 (number (mail-header-number (car thread)))
8275 score)
8276 (if (and
8277 (not (memq number gnus-newsgroup-marked))
8278 (or
8279 ;; If this article is dormant and has absolutely no visible
8280 ;; children, then this article isn't visible.
8281 (and (memq number gnus-newsgroup-dormant)
8282 (zerop children))
8283 ;; If this is "fetch-old-headered" and there is no
8284 ;; visible children, then we don't want this article.
8285 (and (or (eq gnus-fetch-old-headers 'some)
8286 (numberp gnus-fetch-old-headers))
8287 (gnus-summary-article-ancient-p number)
8288 (zerop children))
8289 ;; If this is "fetch-old-headered" and `invisible', then
8290 ;; we don't want this article.
8291 (and (eq gnus-fetch-old-headers 'invisible)
8292 (gnus-summary-article-ancient-p number))
8293 ;; If this is a sparsely inserted article with no children,
8294 ;; we don't want it.
8295 (and (eq gnus-build-sparse-threads 'some)
8296 (gnus-summary-article-sparse-p number)
8297 (zerop children))
8298 ;; If we use expunging, and this article is really
8299 ;; low-scored, then we don't want this article.
8300 (when (and gnus-summary-expunge-below
8301 (< (setq score
8302 (or (cdr (assq number gnus-newsgroup-scored))
8303 gnus-summary-default-score))
8304 gnus-summary-expunge-below))
8305 ;; We increase the expunge-tally here, but that has
8306 ;; nothing to do with the limits, really.
8307 (incf gnus-newsgroup-expunged-tally)
8308 ;; We also mark as read here, if that's wanted.
8309 (when (and gnus-summary-mark-below
8310 (< score gnus-summary-mark-below))
8311 (setq gnus-newsgroup-unreads
8312 (delq number gnus-newsgroup-unreads))
8313 (if gnus-newsgroup-auto-expire
8314 (push number gnus-newsgroup-expirable)
8315 (push (cons number gnus-low-score-mark)
8316 gnus-newsgroup-reads)))
8317 t)
8318 ;; Do the `display' group parameter.
8319 (and gnus-newsgroup-display
8320 (not (funcall gnus-newsgroup-display)))
8321 ;; Check NoCeM things.
8322 (if (and gnus-use-nocem
8323 (gnus-nocem-unwanted-article-p
8324 (mail-header-id (car thread))))
8325 (progn
8326 (setq gnus-newsgroup-unreads
8327 (delq number gnus-newsgroup-unreads))
8328 t))))
8329 ;; Nope, invisible article.
8330 0
8331 ;; Ok, this article is to be visible, so we add it to the limit
8332 ;; and return 1.
8333 (push number gnus-newsgroup-limit)
8334 1))))
8335
8336 (defun gnus-expunge-thread (thread)
8337 "Mark all articles in THREAD as read."
8338 (let* ((number (mail-header-number (car thread))))
8339 (incf gnus-newsgroup-expunged-tally)
8340 ;; We also mark as read here, if that's wanted.
8341 (setq gnus-newsgroup-unreads
8342 (delq number gnus-newsgroup-unreads))
8343 (if gnus-newsgroup-auto-expire
8344 (push number gnus-newsgroup-expirable)
8345 (push (cons number gnus-low-score-mark)
8346 gnus-newsgroup-reads)))
8347 ;; Go recursively through all subthreads.
8348 (mapcar 'gnus-expunge-thread (cdr thread)))
8349
8350 ;; Summary article oriented commands
8351
8352 (defun gnus-summary-refer-parent-article (n)
8353 "Refer parent article N times.
8354 If N is negative, go to ancestor -N instead.
8355 The difference between N and the number of articles fetched is returned."
8356 (interactive "p")
8357 (let ((skip 1)
8358 error header ref)
8359 (when (not (natnump n))
8360 (setq skip (abs n)
8361 n 1))
8362 (while (and (> n 0)
8363 (not error))
8364 (setq header (gnus-summary-article-header))
8365 (if (and (eq (mail-header-number header)
8366 (cdr gnus-article-current))
8367 (equal gnus-newsgroup-name
8368 (car gnus-article-current)))
8369 ;; If we try to find the parent of the currently
8370 ;; displayed article, then we take a look at the actual
8371 ;; References header, since this is slightly more
8372 ;; reliable than the References field we got from the
8373 ;; server.
8374 (save-excursion
8375 (set-buffer gnus-original-article-buffer)
8376 (nnheader-narrow-to-headers)
8377 (unless (setq ref (message-fetch-field "references"))
8378 (when (setq ref (message-fetch-field "in-reply-to"))
8379 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8380 (widen))
8381 (setq ref
8382 ;; It's not the current article, so we take a bet on
8383 ;; the value we got from the server.
8384 (mail-header-references header)))
8385 (if (and ref
8386 (not (equal ref "")))
8387 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8388 (gnus-message 1 "Couldn't find parent"))
8389 (gnus-message 1 "No references in article %d"
8390 (gnus-summary-article-number))
8391 (setq error t))
8392 (decf n))
8393 (gnus-summary-position-point)
8394 n))
8395
8396 (defun gnus-summary-refer-references ()
8397 "Fetch all articles mentioned in the References header.
8398 Return the number of articles fetched."
8399 (interactive)
8400 (let ((ref (mail-header-references (gnus-summary-article-header)))
8401 (current (gnus-summary-article-number))
8402 (n 0))
8403 (if (or (not ref)
8404 (equal ref ""))
8405 (error "No References in the current article")
8406 ;; For each Message-ID in the References header...
8407 (while (string-match "<[^>]*>" ref)
8408 (incf n)
8409 ;; ... fetch that article.
8410 (gnus-summary-refer-article
8411 (prog1 (match-string 0 ref)
8412 (setq ref (substring ref (match-end 0))))))
8413 (gnus-summary-goto-subject current)
8414 (gnus-summary-position-point)
8415 n)))
8416
8417 (defun gnus-summary-refer-thread (&optional limit)
8418 "Fetch all articles in the current thread.
8419 If LIMIT (the numerical prefix), fetch that many old headers instead
8420 of what's specified by the `gnus-refer-thread-limit' variable."
8421 (interactive "P")
8422 (let ((id (mail-header-id (gnus-summary-article-header)))
8423 (limit (if limit (prefix-numeric-value limit)
8424 gnus-refer-thread-limit)))
8425 (unless (eq gnus-fetch-old-headers 'invisible)
8426 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8427 ;; Retrieve the headers and read them in.
8428 (if (eq (if (numberp limit)
8429 (gnus-retrieve-headers
8430 (list (min
8431 (+ (mail-header-number
8432 (gnus-summary-article-header))
8433 limit)
8434 gnus-newsgroup-end))
8435 gnus-newsgroup-name (* limit 2))
8436 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8437 ;; headers.
8438 (gnus-retrieve-headers (list gnus-newsgroup-end)
8439 gnus-newsgroup-name limit))
8440 'nov)
8441 (gnus-build-all-threads)
8442 (error "Can't fetch thread from back ends that don't support NOV"))
8443 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8444 (gnus-summary-limit-include-thread id)))
8445
8446 (defun gnus-summary-refer-article (message-id)
8447 "Fetch an article specified by MESSAGE-ID."
8448 (interactive "sMessage-ID: ")
8449 (when (and (stringp message-id)
8450 (not (zerop (length message-id))))
8451 (setq message-id (gnus-replace-in-string message-id " " ""))
8452 ;; Construct the correct Message-ID if necessary.
8453 ;; Suggested by tale@pawl.rpi.edu.
8454 (unless (string-match "^<" message-id)
8455 (setq message-id (concat "<" message-id)))
8456 (unless (string-match ">$" message-id)
8457 (setq message-id (concat message-id ">")))
8458 ;; People often post MIDs from URLs, so unhex it:
8459 (unless (string-match "@" message-id)
8460 (setq message-id (gnus-url-unhex-string message-id)))
8461 (let* ((header (gnus-id-to-header message-id))
8462 (sparse (and header
8463 (gnus-summary-article-sparse-p
8464 (mail-header-number header))
8465 (memq (mail-header-number header)
8466 gnus-newsgroup-limit)))
8467 number)
8468 (cond
8469 ;; If the article is present in the buffer we just go to it.
8470 ((and header
8471 (or (not (gnus-summary-article-sparse-p
8472 (mail-header-number header)))
8473 sparse))
8474 (prog1
8475 (gnus-summary-goto-article
8476 (mail-header-number header) nil t)
8477 (when sparse
8478 (gnus-summary-update-article (mail-header-number header)))))
8479 (t
8480 ;; We fetch the article.
8481 (catch 'found
8482 (dolist (gnus-override-method (gnus-refer-article-methods))
8483 (when (and (gnus-check-server gnus-override-method)
8484 ;; Fetch the header,
8485 (setq number (gnus-summary-insert-subject message-id)))
8486 ;; and display the article.
8487 (gnus-summary-select-article nil nil nil number)
8488 (throw 'found t)))
8489 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8490
8491 (defun gnus-refer-article-methods ()
8492 "Return a list of referable methods."
8493 (cond
8494 ;; No method, so we default to current and native.
8495 ((null gnus-refer-article-method)
8496 (list gnus-current-select-method gnus-select-method))
8497 ;; Current.
8498 ((eq 'current gnus-refer-article-method)
8499 (list gnus-current-select-method))
8500 ;; List of select methods.
8501 ((not (and (symbolp (car gnus-refer-article-method))
8502 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8503 (let (out)
8504 (dolist (method gnus-refer-article-method)
8505 (push (if (eq 'current method)
8506 gnus-current-select-method
8507 method)
8508 out))
8509 (nreverse out)))
8510 ;; One single select method.
8511 (t
8512 (list gnus-refer-article-method))))
8513
8514 (defun gnus-summary-edit-parameters ()
8515 "Edit the group parameters of the current group."
8516 (interactive)
8517 (gnus-group-edit-group gnus-newsgroup-name 'params))
8518
8519 (defun gnus-summary-customize-parameters ()
8520 "Customize the group parameters of the current group."
8521 (interactive)
8522 (gnus-group-customize gnus-newsgroup-name))
8523
8524 (defun gnus-summary-enter-digest-group (&optional force)
8525 "Enter an nndoc group based on the current article.
8526 If FORCE, force a digest interpretation. If not, try
8527 to guess what the document format is."
8528 (interactive "P")
8529 (let ((conf gnus-current-window-configuration))
8530 (save-window-excursion
8531 (save-excursion
8532 (let (gnus-article-prepare-hook
8533 gnus-display-mime-function
8534 gnus-break-pages)
8535 (gnus-summary-select-article))))
8536 (setq gnus-current-window-configuration conf)
8537 (let* ((name (format "%s-%d"
8538 (gnus-group-prefixed-name
8539 gnus-newsgroup-name (list 'nndoc ""))
8540 (save-excursion
8541 (set-buffer gnus-summary-buffer)
8542 gnus-current-article)))
8543 (ogroup gnus-newsgroup-name)
8544 (params (append (gnus-info-params (gnus-get-info ogroup))
8545 (list (cons 'to-group ogroup))
8546 (list (cons 'parent-group ogroup))
8547 (list (cons 'save-article-group ogroup))))
8548 (case-fold-search t)
8549 (buf (current-buffer))
8550 dig to-address)
8551 (save-excursion
8552 (set-buffer gnus-original-article-buffer)
8553 ;; Have the digest group inherit the main mail address of
8554 ;; the parent article.
8555 (when (setq to-address (or (gnus-fetch-field "reply-to")
8556 (gnus-fetch-field "from")))
8557 (setq params
8558 (append
8559 (list (cons 'to-address
8560 (funcall gnus-decode-encoded-address-function
8561 to-address))))))
8562 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8563 (insert-buffer-substring gnus-original-article-buffer)
8564 ;; Remove lines that may lead nndoc to misinterpret the
8565 ;; document type.
8566 (narrow-to-region
8567 (goto-char (point-min))
8568 (or (search-forward "\n\n" nil t) (point)))
8569 (goto-char (point-min))
8570 (delete-matching-lines "^Path:\\|^From ")
8571 (widen))
8572 (unwind-protect
8573 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8574 (gnus-newsgroup-ephemeral-ignored-charsets
8575 gnus-newsgroup-ignored-charsets))
8576 (gnus-group-read-ephemeral-group
8577 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8578 (nndoc-article-type
8579 ,(if force 'mbox 'guess)))
8580 t nil nil nil
8581 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8582 "ADAPT")))))
8583 ;; Make all postings to this group go to the parent group.
8584 (nconc (gnus-info-params (gnus-get-info name))
8585 params)
8586 ;; Couldn't select this doc group.
8587 (switch-to-buffer buf)
8588 (gnus-set-global-variables)
8589 (gnus-configure-windows 'summary)
8590 (gnus-message 3 "Article couldn't be entered?"))
8591 (kill-buffer dig)))))
8592
8593 (defun gnus-summary-read-document (n)
8594 "Open a new group based on the current article(s).
8595 This will allow you to read digests and other similar
8596 documents as newsgroups.
8597 Obeys the standard process/prefix convention."
8598 (interactive "P")
8599 (let* ((articles (gnus-summary-work-articles n))
8600 (ogroup gnus-newsgroup-name)
8601 (params (append (gnus-info-params (gnus-get-info ogroup))
8602 (list (cons 'to-group ogroup))))
8603 article group egroup groups vgroup)
8604 (while (setq article (pop articles))
8605 (setq group (format "%s-%d" gnus-newsgroup-name article))
8606 (gnus-summary-remove-process-mark article)
8607 (when (gnus-summary-display-article article)
8608 (save-excursion
8609 (with-temp-buffer
8610 (insert-buffer-substring gnus-original-article-buffer)
8611 ;; Remove some headers that may lead nndoc to make
8612 ;; the wrong guess.
8613 (message-narrow-to-head)
8614 (goto-char (point-min))
8615 (delete-matching-lines "^\\(Path\\):\\|^From ")
8616 (widen)
8617 (if (setq egroup
8618 (gnus-group-read-ephemeral-group
8619 group `(nndoc ,group (nndoc-address ,(current-buffer))
8620 (nndoc-article-type guess))
8621 t nil t))
8622 (progn
8623 ;; Make all postings to this group go to the parent group.
8624 (nconc (gnus-info-params (gnus-get-info egroup))
8625 params)
8626 (push egroup groups))
8627 ;; Couldn't select this doc group.
8628 (gnus-error 3 "Article couldn't be entered"))))))
8629 ;; Now we have selected all the documents.
8630 (cond
8631 ((not groups)
8632 (error "None of the articles could be interpreted as documents"))
8633 ((gnus-group-read-ephemeral-group
8634 (setq vgroup (format
8635 "nnvirtual:%s-%s" gnus-newsgroup-name
8636 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8637 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8638 t
8639 (cons (current-buffer) 'summary)))
8640 (t
8641 (error "Couldn't select virtual nndoc group")))))
8642
8643 (defun gnus-summary-isearch-article (&optional regexp-p)
8644 "Do incremental search forward on the current article.
8645 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8646 (interactive "P")
8647 (gnus-summary-select-article)
8648 (gnus-configure-windows 'article)
8649 (gnus-eval-in-buffer-window gnus-article-buffer
8650 (save-restriction
8651 (widen)
8652 (isearch-forward regexp-p))))
8653
8654 (defun gnus-summary-search-article-forward (regexp &optional backward)
8655 "Search for an article containing REGEXP forward.
8656 If BACKWARD, search backward instead."
8657 (interactive
8658 (list (read-string
8659 (format "Search article %s (regexp%s): "
8660 (if current-prefix-arg "backward" "forward")
8661 (if gnus-last-search-regexp
8662 (concat ", default " gnus-last-search-regexp)
8663 "")))
8664 current-prefix-arg))
8665 (if (string-equal regexp "")
8666 (setq regexp (or gnus-last-search-regexp ""))
8667 (setq gnus-last-search-regexp regexp)
8668 (setq gnus-article-before-search gnus-current-article))
8669 ;; Intentionally set gnus-last-article.
8670 (setq gnus-last-article gnus-article-before-search)
8671 (let ((gnus-last-article gnus-last-article))
8672 (if (gnus-summary-search-article regexp backward)
8673 (gnus-summary-show-thread)
8674 (signal 'search-failed (list regexp)))))
8675
8676 (defun gnus-summary-search-article-backward (regexp)
8677 "Search for an article containing REGEXP backward."
8678 (interactive
8679 (list (read-string
8680 (format "Search article backward (regexp%s): "
8681 (if gnus-last-search-regexp
8682 (concat ", default " gnus-last-search-regexp)
8683 "")))))
8684 (gnus-summary-search-article-forward regexp 'backward))
8685
8686 (defun gnus-summary-search-article (regexp &optional backward)
8687 "Search for an article containing REGEXP.
8688 Optional argument BACKWARD means do search for backward.
8689 `gnus-select-article-hook' is not called during the search."
8690 ;; We have to require this here to make sure that the following
8691 ;; dynamic binding isn't shadowed by autoloading.
8692 (require 'gnus-async)
8693 (require 'gnus-art)
8694 (let ((gnus-select-article-hook nil) ;Disable hook.
8695 (gnus-article-prepare-hook nil)
8696 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8697 (gnus-use-article-prefetch nil)
8698 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8699 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8700 (gnus-visual nil)
8701 (gnus-keep-backlog nil)
8702 (gnus-break-pages nil)
8703 (gnus-summary-display-arrow nil)
8704 (gnus-updated-mode-lines nil)
8705 (gnus-auto-center-summary nil)
8706 (sum (current-buffer))
8707 (gnus-display-mime-function nil)
8708 (found nil)
8709 point)
8710 (gnus-save-hidden-threads
8711 (gnus-summary-select-article)
8712 (set-buffer gnus-article-buffer)
8713 (goto-char (window-point (get-buffer-window (current-buffer))))
8714 (when backward
8715 (forward-line -1))
8716 (while (not found)
8717 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8718 (if (if backward
8719 (re-search-backward regexp nil t)
8720 (re-search-forward regexp nil t))
8721 ;; We found the regexp.
8722 (progn
8723 (setq found 'found)
8724 (beginning-of-line)
8725 (set-window-start
8726 (get-buffer-window (current-buffer))
8727 (point))
8728 (forward-line 1)
8729 (set-window-point
8730 (get-buffer-window (current-buffer))
8731 (point))
8732 (set-buffer sum)
8733 (setq point (point)))
8734 ;; We didn't find it, so we go to the next article.
8735 (set-buffer sum)
8736 (setq found 'not)
8737 (while (eq found 'not)
8738 (if (not (if backward (gnus-summary-find-prev)
8739 (gnus-summary-find-next)))
8740 ;; No more articles.
8741 (setq found t)
8742 ;; Select the next article and adjust point.
8743 (unless (gnus-summary-article-sparse-p
8744 (gnus-summary-article-number))
8745 (setq found nil)
8746 (gnus-summary-select-article)
8747 (set-buffer gnus-article-buffer)
8748 (widen)
8749 (goto-char (if backward (point-max) (point-min))))))))
8750 (gnus-message 7 ""))
8751 ;; Return whether we found the regexp.
8752 (when (eq found 'found)
8753 (goto-char point)
8754 (gnus-summary-show-thread)
8755 (gnus-summary-goto-subject gnus-current-article)
8756 (gnus-summary-position-point)
8757 t)))
8758
8759 (defun gnus-find-matching-articles (header regexp)
8760 "Return a list of all articles that match REGEXP on HEADER.
8761 This search includes all articles in the current group that Gnus has
8762 fetched headers for, whether they are displayed or not."
8763 (let ((articles nil)
8764 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8765 (case-fold-search t))
8766 (dolist (header gnus-newsgroup-headers)
8767 (when (string-match regexp (funcall func header))
8768 (push (mail-header-number header) articles)))
8769 (nreverse articles)))
8770
8771 (defun gnus-summary-find-matching (header regexp &optional backward unread
8772 not-case-fold not-matching)
8773 "Return a list of all articles that match REGEXP on HEADER.
8774 The search stars on the current article and goes forwards unless
8775 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8776 If UNREAD is non-nil, only unread articles will
8777 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8778 in the comparisons. If NOT-MATCHING, return a list of all articles that
8779 not match REGEXP on HEADER."
8780 (let ((case-fold-search (not not-case-fold))
8781 articles d func)
8782 (if (consp header)
8783 (if (eq (car header) 'extra)
8784 (setq func
8785 `(lambda (h)
8786 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8787 "")))
8788 (error "%s is an invalid header" header))
8789 (unless (fboundp (intern (concat "mail-header-" header)))
8790 (error "%s is not a valid header" header))
8791 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8792 (dolist (d (if (eq backward 'all)
8793 gnus-newsgroup-data
8794 (gnus-data-find-list
8795 (gnus-summary-article-number)
8796 (gnus-data-list backward))))
8797 (when (and (or (not unread) ; We want all articles...
8798 (gnus-data-unread-p d)) ; Or just unreads.
8799 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8800 (if not-matching
8801 (not (string-match
8802 regexp
8803 (funcall func (gnus-data-header d))))
8804 (string-match regexp
8805 (funcall func (gnus-data-header d)))))
8806 (push (gnus-data-number d) articles))) ; Success!
8807 (nreverse articles)))
8808
8809 (defun gnus-summary-execute-command (header regexp command &optional backward)
8810 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8811 If HEADER is an empty string (or nil), the match is done on the entire
8812 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8813 (interactive
8814 (list (let ((completion-ignore-case t))
8815 (completing-read
8816 "Header name: "
8817 (mapcar (lambda (header) (list (format "%s" header)))
8818 (append
8819 '("Number" "Subject" "From" "Lines" "Date"
8820 "Message-ID" "Xref" "References" "Body")
8821 gnus-extra-headers))
8822 nil 'require-match))
8823 (read-string "Regexp: ")
8824 (read-key-sequence "Command: ")
8825 current-prefix-arg))
8826 (when (equal header "Body")
8827 (setq header ""))
8828 ;; Hidden thread subtrees must be searched as well.
8829 (gnus-summary-show-all-threads)
8830 ;; We don't want to change current point nor window configuration.
8831 (save-excursion
8832 (save-window-excursion
8833 (let (gnus-visual
8834 gnus-treat-strip-trailing-blank-lines
8835 gnus-treat-strip-leading-blank-lines
8836 gnus-treat-strip-multiple-blank-lines
8837 gnus-treat-hide-boring-headers
8838 gnus-treat-fold-newsgroups
8839 gnus-article-prepare-hook)
8840 (gnus-message 6 "Executing %s..." (key-description command))
8841 ;; We'd like to execute COMMAND interactively so as to give arguments.
8842 (gnus-execute header regexp
8843 `(call-interactively ',(key-binding command))
8844 backward)
8845 (gnus-message 6 "Executing %s...done" (key-description command))))))
8846
8847 (defun gnus-summary-beginning-of-article ()
8848 "Scroll the article back to the beginning."
8849 (interactive)
8850 (gnus-summary-select-article)
8851 (gnus-configure-windows 'article)
8852 (gnus-eval-in-buffer-window gnus-article-buffer
8853 (widen)
8854 (goto-char (point-min))
8855 (when gnus-break-pages
8856 (gnus-narrow-to-page))))
8857
8858 (defun gnus-summary-end-of-article ()
8859 "Scroll to the end of the article."
8860 (interactive)
8861 (gnus-summary-select-article)
8862 (gnus-configure-windows 'article)
8863 (gnus-eval-in-buffer-window gnus-article-buffer
8864 (widen)
8865 (goto-char (point-max))
8866 (recenter -3)
8867 (when gnus-break-pages
8868 (gnus-narrow-to-page))))
8869
8870 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8871 "Truncate to LEN and quote all \"(\"'s in STRING."
8872 (gnus-replace-in-string (if (and len (> (length string) len))
8873 (substring string 0 len)
8874 string)
8875 "[()]" "\\\\\\&"))
8876
8877 (defun gnus-summary-print-article (&optional filename n)
8878 "Generate and print a PostScript image of the process-marked (mail) articles.
8879
8880 If used interactively, print the current article if none are
8881 process-marked. With prefix arg, prompt the user for the name of the
8882 file to save in.
8883
8884 When used from Lisp, accept two optional args FILENAME and N. N means
8885 to print the next N articles. If N is negative, print the N previous
8886 articles. If N is nil and articles have been marked with the process
8887 mark, print these instead.
8888
8889 If the optional first argument FILENAME is nil, send the image to the
8890 printer. If FILENAME is a string, save the PostScript image in a file with
8891 that name. If FILENAME is a number, prompt the user for the name of the file
8892 to save in."
8893 (interactive (list (ps-print-preprint current-prefix-arg)))
8894 (dolist (article (gnus-summary-work-articles n))
8895 (gnus-summary-select-article nil nil 'pseudo article)
8896 (gnus-eval-in-buffer-window gnus-article-buffer
8897 (gnus-print-buffer))
8898 (gnus-summary-remove-process-mark article))
8899 (ps-despool filename))
8900
8901 (defun gnus-print-buffer ()
8902 (let ((buffer (generate-new-buffer " *print*")))
8903 (unwind-protect
8904 (progn
8905 (copy-to-buffer buffer (point-min) (point-max))
8906 (set-buffer buffer)
8907 (gnus-remove-text-with-property 'gnus-decoration)
8908 (when (gnus-visual-p 'article-highlight 'highlight)
8909 ;; Copy-to-buffer doesn't copy overlay. So redo
8910 ;; highlight.
8911 (let ((gnus-article-buffer buffer))
8912 (gnus-article-highlight-citation t)
8913 (gnus-article-highlight-signature)
8914 (gnus-article-emphasize)
8915 (gnus-article-delete-invisible-text)))
8916 (let ((ps-left-header
8917 (list
8918 (concat "("
8919 (gnus-summary-print-truncate-and-quote
8920 (mail-header-subject gnus-current-headers)
8921 66) ")")
8922 (concat "("
8923 (gnus-summary-print-truncate-and-quote
8924 (mail-header-from gnus-current-headers)
8925 45) ")")))
8926 (ps-right-header
8927 (list
8928 "/pagenumberstring load"
8929 (concat "("
8930 (mail-header-date gnus-current-headers) ")"))))
8931 (gnus-run-hooks 'gnus-ps-print-hook)
8932 (save-excursion
8933 (if ps-print-color-p
8934 (ps-spool-buffer-with-faces)
8935 (ps-spool-buffer)))))
8936 (kill-buffer buffer))))
8937
8938 (defun gnus-summary-show-article (&optional arg)
8939 "Force redisplaying of the current article.
8940 If ARG (the prefix) is a number, show the article with the charset
8941 defined in `gnus-summary-show-article-charset-alist', or the charset
8942 input.
8943 If ARG (the prefix) is non-nil and not a number, show the raw article
8944 without any article massaging functions being run. Normally, the key
8945 strokes are `C-u g'."
8946 (interactive "P")
8947 (cond
8948 ((numberp arg)
8949 (gnus-summary-show-article t)
8950 (let ((gnus-newsgroup-charset
8951 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8952 (mm-read-coding-system
8953 "View as charset: " ;; actually it is coding system.
8954 (save-excursion
8955 (set-buffer gnus-article-buffer)
8956 (mm-detect-coding-region (point) (point-max))))))
8957 (gnus-newsgroup-ignored-charsets 'gnus-all))
8958 (gnus-summary-select-article nil 'force)
8959 (let ((deps gnus-newsgroup-dependencies)
8960 head header lines)
8961 (save-excursion
8962 (set-buffer gnus-original-article-buffer)
8963 (save-restriction
8964 (message-narrow-to-head)
8965 (setq head (buffer-string))
8966 (goto-char (point-min))
8967 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8968 (goto-char (point-max))
8969 (widen)
8970 (setq lines (1- (count-lines (point) (point-max))))))
8971 (with-temp-buffer
8972 (insert (format "211 %d Article retrieved.\n"
8973 (cdr gnus-article-current)))
8974 (insert head)
8975 (if lines (insert (format "Lines: %d\n" lines)))
8976 (insert ".\n")
8977 (let ((nntp-server-buffer (current-buffer)))
8978 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8979 (gnus-data-set-header
8980 (gnus-data-find (cdr gnus-article-current))
8981 header)
8982 (gnus-summary-update-article-line
8983 (cdr gnus-article-current) header)
8984 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8985 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8986 ((not arg)
8987 ;; Select the article the normal way.
8988 (gnus-summary-select-article nil 'force))
8989 (t
8990 ;; We have to require this here to make sure that the following
8991 ;; dynamic binding isn't shadowed by autoloading.
8992 (require 'gnus-async)
8993 (require 'gnus-art)
8994 ;; Bind the article treatment functions to nil.
8995 (let ((gnus-have-all-headers t)
8996 gnus-article-prepare-hook
8997 gnus-article-decode-hook
8998 gnus-display-mime-function
8999 gnus-break-pages)
9000 ;; Destroy any MIME parts.
9001 (when (gnus-buffer-live-p gnus-article-buffer)
9002 (save-excursion
9003 (set-buffer gnus-article-buffer)
9004 (mm-destroy-parts gnus-article-mime-handles)
9005 ;; Set it to nil for safety reason.
9006 (setq gnus-article-mime-handle-alist nil)
9007 (setq gnus-article-mime-handles nil)))
9008 (gnus-summary-select-article nil 'force))))
9009 (gnus-summary-goto-subject gnus-current-article)
9010 (gnus-summary-position-point))
9011
9012 (defun gnus-summary-show-raw-article ()
9013 "Show the raw article without any article massaging functions being run."
9014 (interactive)
9015 (gnus-summary-show-article t))
9016
9017 (defun gnus-summary-verbose-headers (&optional arg)
9018 "Toggle permanent full header display.
9019 If ARG is a positive number, turn header display on.
9020 If ARG is a negative number, turn header display off."
9021 (interactive "P")
9022 (setq gnus-show-all-headers
9023 (cond ((or (not (numberp arg))
9024 (zerop arg))
9025 (not gnus-show-all-headers))
9026 ((natnump arg)
9027 t)))
9028 (gnus-summary-show-article))
9029
9030 (defun gnus-summary-toggle-header (&optional arg)
9031 "Show the headers if they are hidden, or hide them if they are shown.
9032 If ARG is a positive number, show the entire header.
9033 If ARG is a negative number, hide the unwanted header lines."
9034 (interactive "P")
9035 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9036 (get-buffer-window gnus-article-buffer t))))
9037 (with-current-buffer gnus-article-buffer
9038 (widen)
9039 (article-narrow-to-head)
9040 (let* ((buffer-read-only nil)
9041 (inhibit-point-motion-hooks t)
9042 (hidden (if (numberp arg)
9043 (>= arg 0)
9044 (or (not (looking-at "[^ \t\n]+:"))
9045 (gnus-article-hidden-text-p 'headers))))
9046 s e)
9047 (delete-region (point-min) (point-max))
9048 (with-current-buffer gnus-original-article-buffer
9049 (goto-char (setq s (point-min)))
9050 (setq e (if (search-forward "\n\n" nil t)
9051 (1- (point))
9052 (point-max))))
9053 (insert-buffer-substring gnus-original-article-buffer s e)
9054 (run-hooks 'gnus-article-decode-hook)
9055 (if hidden
9056 (let ((gnus-treat-hide-headers nil)
9057 (gnus-treat-hide-boring-headers nil))
9058 (gnus-delete-wash-type 'headers)
9059 (gnus-treat-article 'head))
9060 (gnus-treat-article 'head))
9061 (widen)
9062 (if window
9063 (set-window-start window (goto-char (point-min))))
9064 (if gnus-break-pages
9065 (gnus-narrow-to-page)
9066 (when (gnus-visual-p 'page-marker)
9067 (let ((buffer-read-only nil))
9068 (gnus-remove-text-with-property 'gnus-prev)
9069 (gnus-remove-text-with-property 'gnus-next))))
9070 (gnus-set-mode-line 'article)))))
9071
9072 (defun gnus-summary-show-all-headers ()
9073 "Make all header lines visible."
9074 (interactive)
9075 (gnus-summary-toggle-header 1))
9076
9077 (defun gnus-summary-caesar-message (&optional arg)
9078 "Caesar rotate the current article by 13.
9079 The numerical prefix specifies how many places to rotate each letter
9080 forward."
9081 (interactive "P")
9082 (gnus-summary-select-article)
9083 (let ((mail-header-separator ""))
9084 (gnus-eval-in-buffer-window gnus-article-buffer
9085 (save-restriction
9086 (widen)
9087 (let ((start (window-start))
9088 buffer-read-only)
9089 (message-caesar-buffer-body arg)
9090 (set-window-start (get-buffer-window (current-buffer)) start)))))
9091 ;; Create buttons and stuff...
9092 (gnus-treat-article nil))
9093
9094 (autoload 'unmorse-region "morse"
9095 "Convert morse coded text in region to ordinary ASCII text."
9096 t)
9097
9098 (defun gnus-summary-morse-message (&optional arg)
9099 "Morse decode the current article."
9100 (interactive "P")
9101 (gnus-summary-select-article)
9102 (let ((mail-header-separator ""))
9103 (gnus-eval-in-buffer-window gnus-article-buffer
9104 (save-excursion
9105 (save-restriction
9106 (widen)
9107 (let ((pos (window-start))
9108 buffer-read-only)
9109 (goto-char (point-min))
9110 (when (message-goto-body)
9111 (gnus-narrow-to-body))
9112 (goto-char (point-min))
9113 (while (re-search-forward "·" (point-max) t)
9114 (replace-match "."))
9115 (unmorse-region (point-min) (point-max))
9116 (widen)
9117 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9118
9119 (defun gnus-summary-stop-page-breaking ()
9120 "Stop page breaking in the current article."
9121 (interactive)
9122 (gnus-summary-select-article)
9123 (gnus-eval-in-buffer-window gnus-article-buffer
9124 (widen)
9125 (when (gnus-visual-p 'page-marker)
9126 (let ((buffer-read-only nil))
9127 (gnus-remove-text-with-property 'gnus-prev)
9128 (gnus-remove-text-with-property 'gnus-next))
9129 (setq gnus-page-broken nil))))
9130
9131 (defun gnus-summary-move-article (&optional n to-newsgroup
9132 select-method action)
9133 "Move the current article to a different newsgroup.
9134 If N is a positive number, move the N next articles.
9135 If N is a negative number, move the N previous articles.
9136 If N is nil and any articles have been marked with the process mark,
9137 move those articles instead.
9138 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9139 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9140 re-spool using this method.
9141
9142 When called interactively with TO-NEWSGROUP being nil, the value of
9143 the variable `gnus-move-split-methods' is used for finding a default
9144 for the target newsgroup.
9145
9146 For this function to work, both the current newsgroup and the
9147 newsgroup that you want to move to have to support the `request-move'
9148 and `request-accept' functions.
9149
9150 ACTION can be either `move' (the default), `crosspost' or `copy'."
9151 (interactive "P")
9152 (unless action
9153 (setq action 'move))
9154 ;; Check whether the source group supports the required functions.
9155 (cond ((and (eq action 'move)
9156 (not (gnus-check-backend-function
9157 'request-move-article gnus-newsgroup-name)))
9158 (error "The current group does not support article moving"))
9159 ((and (eq action 'crosspost)
9160 (not (gnus-check-backend-function
9161 'request-replace-article gnus-newsgroup-name)))
9162 (error "The current group does not support article editing")))
9163 (let ((articles (gnus-summary-work-articles n))
9164 (prefix (if (gnus-check-backend-function
9165 'request-move-article gnus-newsgroup-name)
9166 (gnus-group-real-prefix gnus-newsgroup-name)
9167 ""))
9168 (names '((move "Move" "Moving")
9169 (copy "Copy" "Copying")
9170 (crosspost "Crosspost" "Crossposting")))
9171 (copy-buf (save-excursion
9172 (nnheader-set-temp-buffer " *copy article*")))
9173 art-group to-method new-xref article to-groups)
9174 (unless (assq action names)
9175 (error "Unknown action %s" action))
9176 ;; Read the newsgroup name.
9177 (when (and (not to-newsgroup)
9178 (not select-method))
9179 (if (and gnus-move-split-methods
9180 (not
9181 (and (memq gnus-current-article articles)
9182 (gnus-buffer-live-p gnus-original-article-buffer))))
9183 ;; When `gnus-move-split-methods' is non-nil, we have to
9184 ;; select an article to give `gnus-read-move-group-name' an
9185 ;; opportunity to suggest an appropriate default. However,
9186 ;; we needn't render or mark the article.
9187 (let ((gnus-display-mime-function nil)
9188 (gnus-article-prepare-hook nil)
9189 (gnus-mark-article-hook nil))
9190 (gnus-summary-select-article nil nil nil (car articles))))
9191 (setq to-newsgroup
9192 (gnus-read-move-group-name
9193 (cadr (assq action names))
9194 (symbol-value (intern (format "gnus-current-%s-group" action)))
9195 articles prefix))
9196 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
9197 (setq to-method (or select-method
9198 (gnus-server-to-method
9199 (gnus-group-method to-newsgroup))))
9200 ;; Check the method we are to move this article to...
9201 (unless (gnus-check-backend-function
9202 'request-accept-article (car to-method))
9203 (error "%s does not support article copying" (car to-method)))
9204 (unless (gnus-check-server to-method)
9205 (error "Can't open server %s" (car to-method)))
9206 (gnus-message 6 "%s to %s: %s..."
9207 (caddr (assq action names))
9208 (or (car select-method) to-newsgroup) articles)
9209 (while articles
9210 (setq article (pop articles))
9211 (setq
9212 art-group
9213 (cond
9214 ;; Move the article.
9215 ((eq action 'move)
9216 ;; Remove this article from future suppression.
9217 (gnus-dup-unsuppress-article article)
9218 (gnus-request-move-article
9219 article ; Article to move
9220 gnus-newsgroup-name ; From newsgroup
9221 (nth 1 (gnus-find-method-for-group
9222 gnus-newsgroup-name)) ; Server
9223 (list 'gnus-request-accept-article
9224 to-newsgroup (list 'quote select-method)
9225 (not articles) t) ; Accept form
9226 (not articles))) ; Only save nov last time
9227 ;; Copy the article.
9228 ((eq action 'copy)
9229 (save-excursion
9230 (set-buffer copy-buf)
9231 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9232 (gnus-request-accept-article
9233 to-newsgroup select-method (not articles) t))))
9234 ;; Crosspost the article.
9235 ((eq action 'crosspost)
9236 (let ((xref (message-tokenize-header
9237 (mail-header-xref (gnus-summary-article-header article))
9238 " ")))
9239 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9240 ":" (number-to-string article)))
9241 (unless xref
9242 (setq xref (list (system-name))))
9243 (setq new-xref
9244 (concat
9245 (mapconcat 'identity
9246 (delete "Xref:" (delete new-xref xref))
9247 " ")
9248 " " new-xref))
9249 (save-excursion
9250 (set-buffer copy-buf)
9251 ;; First put the article in the destination group.
9252 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9253 (when (consp (setq art-group
9254 (gnus-request-accept-article
9255 to-newsgroup select-method (not articles) t)))
9256 (setq new-xref (concat new-xref " " (car art-group)
9257 ":"
9258 (number-to-string (cdr art-group))))
9259 ;; Now we have the new Xrefs header, so we insert
9260 ;; it and replace the new article.
9261 (nnheader-replace-header "Xref" new-xref)
9262 (gnus-request-replace-article
9263 (cdr art-group) to-newsgroup (current-buffer) t)
9264 art-group))))))
9265 (cond
9266 ((not art-group)
9267 (gnus-message 1 "Couldn't %s article %s: %s"
9268 (cadr (assq action names)) article
9269 (nnheader-get-report (car to-method))))
9270 ((eq art-group 'junk)
9271 (when (eq action 'move)
9272 (gnus-summary-mark-article article gnus-canceled-mark)
9273 (gnus-message 4 "Deleted article %s" article)
9274 ;; run the delete hook
9275 (run-hook-with-args 'gnus-summary-article-delete-hook
9276 action
9277 (gnus-data-header
9278 (assoc article (gnus-data-list nil)))
9279 gnus-newsgroup-name nil
9280 select-method)))
9281 (t
9282 (let* ((pto-group (gnus-group-prefixed-name
9283 (car art-group) to-method))
9284 (entry
9285 (gnus-gethash pto-group gnus-newsrc-hashtb))
9286 (info (nth 2 entry))
9287 (to-group (gnus-info-group info))
9288 to-marks)
9289 ;; Update the group that has been moved to.
9290 (when (and info
9291 (memq action '(move copy)))
9292 (unless (member to-group to-groups)
9293 (push to-group to-groups))
9294
9295 (unless (memq article gnus-newsgroup-unreads)
9296 (push 'read to-marks)
9297 (gnus-info-set-read
9298 info (gnus-add-to-range (gnus-info-read info)
9299 (list (cdr art-group)))))
9300
9301 ;; See whether the article is to be put in the cache.
9302 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9303 gnus-article-mark-lists
9304 (delete '(expirable . expire)
9305 (copy-sequence gnus-article-mark-lists))))
9306 (to-article (cdr art-group)))
9307
9308 ;; Enter the article into the cache in the new group,
9309 ;; if that is required.
9310 (when gnus-use-cache
9311 (gnus-cache-possibly-enter-article
9312 to-group to-article
9313 (memq article gnus-newsgroup-marked)
9314 (memq article gnus-newsgroup-dormant)
9315 (memq article gnus-newsgroup-unreads)))
9316
9317 (when gnus-preserve-marks
9318 ;; Copy any marks over to the new group.
9319 (when (and (equal to-group gnus-newsgroup-name)
9320 (not (memq article gnus-newsgroup-unreads)))
9321 ;; Mark this article as read in this group.
9322 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9323 (setcdr (gnus-active to-group) to-article)
9324 (setcdr gnus-newsgroup-active to-article))
9325
9326 (while marks
9327 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9328 (when (memq article (symbol-value
9329 (intern (format "gnus-newsgroup-%s"
9330 (caar marks)))))
9331 (push (cdar marks) to-marks)
9332 ;; If the other group is the same as this group,
9333 ;; then we have to add the mark to the list.
9334 (when (equal to-group gnus-newsgroup-name)
9335 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9336 (cons to-article
9337 (symbol-value
9338 (intern (format "gnus-newsgroup-%s"
9339 (caar marks)))))))
9340 ;; Copy the marks to other group.
9341 (gnus-add-marked-articles
9342 to-group (cdar marks) (list to-article) info)))
9343 (setq marks (cdr marks)))
9344
9345 (gnus-request-set-mark
9346 to-group (list (list (list to-article) 'add to-marks))))
9347
9348 (gnus-dribble-enter
9349 (concat "(gnus-group-set-info '"
9350 (gnus-prin1-to-string (gnus-get-info to-group))
9351 ")"))))
9352
9353 ;; Update the Xref header in this article to point to
9354 ;; the new crossposted article we have just created.
9355 (when (eq action 'crosspost)
9356 (save-excursion
9357 (set-buffer copy-buf)
9358 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9359 (nnheader-replace-header "Xref" new-xref)
9360 (gnus-request-replace-article
9361 article gnus-newsgroup-name (current-buffer) t)))
9362
9363 ;; run the move/copy/crosspost/respool hook
9364 (run-hook-with-args 'gnus-summary-article-move-hook
9365 action
9366 (gnus-data-header
9367 (assoc article (gnus-data-list nil)))
9368 gnus-newsgroup-name
9369 to-newsgroup
9370 select-method))
9371
9372 ;;;!!!Why is this necessary?
9373 (set-buffer gnus-summary-buffer)
9374
9375 (gnus-summary-goto-subject article)
9376 (when (eq action 'move)
9377 (gnus-summary-mark-article article gnus-canceled-mark))))
9378 (gnus-summary-remove-process-mark article))
9379 ;; Re-activate all groups that have been moved to.
9380 (save-excursion
9381 (set-buffer gnus-group-buffer)
9382 (let ((gnus-group-marked to-groups))
9383 (gnus-group-get-new-news-this-group nil t)))
9384
9385 (gnus-kill-buffer copy-buf)
9386 (gnus-summary-position-point)
9387 (gnus-set-mode-line 'summary)))
9388
9389 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9390 "Copy the current article to some other group.
9391 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9392 When called interactively, if TO-NEWSGROUP is nil, use the value of
9393 the variable `gnus-move-split-methods' for finding a default target
9394 newsgroup.
9395 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9396 re-spool using this method."
9397 (interactive "P")
9398 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9399
9400 (defun gnus-summary-crosspost-article (&optional n)
9401 "Crosspost the current article to some other group."
9402 (interactive "P")
9403 (gnus-summary-move-article n nil nil 'crosspost))
9404
9405 (defcustom gnus-summary-respool-default-method nil
9406 "Default method type for respooling an article.
9407 If nil, use to the current newsgroup method."
9408 :type 'symbol
9409 :group 'gnus-summary-mail)
9410
9411 (defcustom gnus-summary-display-while-building nil
9412 "If non-nil, show and update the summary buffer as it's being built.
9413 If the value is t, update the buffer after every line is inserted. If
9414 the value is an integer (N), update the display every N lines."
9415 :version "22.1"
9416 :group 'gnus-thread
9417 :type '(choice (const :tag "off" nil)
9418 number
9419 (const :tag "frequently" t)))
9420
9421 (defun gnus-summary-respool-article (&optional n method)
9422 "Respool the current article.
9423 The article will be squeezed through the mail spooling process again,
9424 which means that it will be put in some mail newsgroup or other
9425 depending on `nnmail-split-methods'.
9426 If N is a positive number, respool the N next articles.
9427 If N is a negative number, respool the N previous articles.
9428 If N is nil and any articles have been marked with the process mark,
9429 respool those articles instead.
9430
9431 Respooling can be done both from mail groups and \"real\" newsgroups.
9432 In the former case, the articles in question will be moved from the
9433 current group into whatever groups they are destined to. In the
9434 latter case, they will be copied into the relevant groups."
9435 (interactive
9436 (list current-prefix-arg
9437 (let* ((methods (gnus-methods-using 'respool))
9438 (methname
9439 (symbol-name (or gnus-summary-respool-default-method
9440 (car (gnus-find-method-for-group
9441 gnus-newsgroup-name)))))
9442 (method
9443 (gnus-completing-read-with-default
9444 methname "Backend to use when respooling"
9445 methods nil t nil 'gnus-mail-method-history))
9446 ms)
9447 (cond
9448 ((zerop (length (setq ms (gnus-servers-using-backend
9449 (intern method)))))
9450 (list (intern method) ""))
9451 ((= 1 (length ms))
9452 (car ms))
9453 (t
9454 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9455 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9456 ms-alist))))))))
9457 (unless method
9458 (error "No method given for respooling"))
9459 (if (assoc (symbol-name
9460 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9461 (gnus-methods-using 'respool))
9462 (gnus-summary-move-article n nil method)
9463 (gnus-summary-copy-article n nil method)))
9464
9465 (defun gnus-summary-import-article (file &optional edit)
9466 "Import an arbitrary file into a mail newsgroup."
9467 (interactive "fImport file: \nP")
9468 (let ((group gnus-newsgroup-name)
9469 (now (current-time))
9470 atts lines group-art)
9471 (unless (gnus-check-backend-function 'request-accept-article group)
9472 (error "%s does not support article importing" group))
9473 (or (file-readable-p file)
9474 (not (file-regular-p file))
9475 (error "Can't read %s" file))
9476 (save-excursion
9477 (set-buffer (gnus-get-buffer-create " *import file*"))
9478 (erase-buffer)
9479 (nnheader-insert-file-contents file)
9480 (goto-char (point-min))
9481 (if (nnheader-article-p)
9482 (save-restriction
9483 (goto-char (point-min))
9484 (search-forward "\n\n" nil t)
9485 (narrow-to-region (point-min) (1- (point)))
9486 (goto-char (point-min))
9487 (unless (re-search-forward "^date:" nil t)
9488 (goto-char (point-max))
9489 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9490 ;; This doesn't look like an article, so we fudge some headers.
9491 (setq atts (file-attributes file)
9492 lines (count-lines (point-min) (point-max)))
9493 (insert "From: " (read-string "From: ") "\n"
9494 "Subject: " (read-string "Subject: ") "\n"
9495 "Date: " (message-make-date (nth 5 atts)) "\n"
9496 "Message-ID: " (message-make-message-id) "\n"
9497 "Lines: " (int-to-string lines) "\n"
9498 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9499 (setq group-art (gnus-request-accept-article group nil t))
9500 (kill-buffer (current-buffer)))
9501 (setq gnus-newsgroup-active (gnus-activate-group group))
9502 (forward-line 1)
9503 (gnus-summary-goto-article (cdr group-art) nil t)
9504 (when edit
9505 (gnus-summary-edit-article))))
9506
9507 (defun gnus-summary-create-article ()
9508 "Create an article in a mail newsgroup."
9509 (interactive)
9510 (let ((group gnus-newsgroup-name)
9511 (now (current-time))
9512 group-art)
9513 (unless (gnus-check-backend-function 'request-accept-article group)
9514 (error "%s does not support article importing" group))
9515 (save-excursion
9516 (set-buffer (gnus-get-buffer-create " *import file*"))
9517 (erase-buffer)
9518 (goto-char (point-min))
9519 ;; This doesn't look like an article, so we fudge some headers.
9520 (insert "From: " (read-string "From: ") "\n"
9521 "Subject: " (read-string "Subject: ") "\n"
9522 "Date: " (message-make-date now) "\n"
9523 "Message-ID: " (message-make-message-id) "\n")
9524 (setq group-art (gnus-request-accept-article group nil t))
9525 (kill-buffer (current-buffer)))
9526 (setq gnus-newsgroup-active (gnus-activate-group group))
9527 (forward-line 1)
9528 (gnus-summary-goto-article (cdr group-art) nil t)
9529 (gnus-summary-edit-article)))
9530
9531 (defun gnus-summary-article-posted-p ()
9532 "Say whether the current (mail) article is available from news as well.
9533 This will be the case if the article has both been mailed and posted."
9534 (interactive)
9535 (let ((id (mail-header-references (gnus-summary-article-header)))
9536 (gnus-override-method (car (gnus-refer-article-methods))))
9537 (if (gnus-request-head id "")
9538 (gnus-message 2 "The current message was found on %s"
9539 gnus-override-method)
9540 (gnus-message 2 "The current message couldn't be found on %s"
9541 gnus-override-method)
9542 nil)))
9543
9544 (defun gnus-summary-expire-articles (&optional now)
9545 "Expire all articles that are marked as expirable in the current group."
9546 (interactive)
9547 (when (and (not gnus-group-is-exiting-without-update-p)
9548 (gnus-check-backend-function
9549 'request-expire-articles gnus-newsgroup-name))
9550 ;; This backend supports expiry.
9551 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9552 (expirable (if total
9553 (progn
9554 ;; We need to update the info for
9555 ;; this group for `gnus-list-of-read-articles'
9556 ;; to give us the right answer.
9557 (gnus-run-hooks 'gnus-exit-group-hook)
9558 (gnus-summary-update-info)
9559 (gnus-list-of-read-articles gnus-newsgroup-name))
9560 (setq gnus-newsgroup-expirable
9561 (sort gnus-newsgroup-expirable '<))))
9562 (expiry-wait (if now 'immediate
9563 (gnus-group-find-parameter
9564 gnus-newsgroup-name 'expiry-wait)))
9565 (nnmail-expiry-target
9566 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9567 nnmail-expiry-target))
9568 es)
9569 (when expirable
9570 ;; There are expirable articles in this group, so we run them
9571 ;; through the expiry process.
9572 (gnus-message 6 "Expiring articles...")
9573 (unless (gnus-check-group gnus-newsgroup-name)
9574 (error "Can't open server for %s" gnus-newsgroup-name))
9575 ;; The list of articles that weren't expired is returned.
9576 (save-excursion
9577 (if expiry-wait
9578 (let ((nnmail-expiry-wait-function nil)
9579 (nnmail-expiry-wait expiry-wait))
9580 (setq es (gnus-request-expire-articles
9581 expirable gnus-newsgroup-name)))
9582 (setq es (gnus-request-expire-articles
9583 expirable gnus-newsgroup-name)))
9584 (unless total
9585 (setq gnus-newsgroup-expirable es))
9586 ;; We go through the old list of expirable, and mark all
9587 ;; really expired articles as nonexistent.
9588 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9589 (let ((gnus-use-cache nil))
9590 (dolist (article expirable)
9591 (when (and (not (memq article es))
9592 (gnus-data-find article))
9593 (gnus-summary-mark-article article gnus-canceled-mark)
9594 (run-hook-with-args 'gnus-summary-article-expire-hook
9595 'delete
9596 (gnus-data-header
9597 (assoc article (gnus-data-list nil)))
9598 gnus-newsgroup-name
9599 nil
9600 nil))))))
9601 (gnus-message 6 "Expiring articles...done")))))
9602
9603 (defun gnus-summary-expire-articles-now ()
9604 "Expunge all expirable articles in the current group.
9605 This means that *all* articles that are marked as expirable will be
9606 deleted forever, right now."
9607 (interactive)
9608 (or gnus-expert-user
9609 (gnus-yes-or-no-p
9610 "Are you really, really sure you want to delete all expirable messages? ")
9611 (error "Phew!"))
9612 (gnus-summary-expire-articles t))
9613
9614 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9615 (defun gnus-summary-delete-article (&optional n)
9616 "Delete the N next (mail) articles.
9617 This command actually deletes articles. This is not a marking
9618 command. The article will disappear forever from your life, never to
9619 return.
9620
9621 If N is negative, delete backwards.
9622 If N is nil and articles have been marked with the process mark,
9623 delete these instead.
9624
9625 If `gnus-novice-user' is non-nil you will be asked for
9626 confirmation before the articles are deleted."
9627 (interactive "P")
9628 (unless (gnus-check-backend-function 'request-expire-articles
9629 gnus-newsgroup-name)
9630 (error "The current newsgroup does not support article deletion"))
9631 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9632 (error "Couldn't open server"))
9633 ;; Compute the list of articles to delete.
9634 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9635 (nnmail-expiry-target 'delete)
9636 not-deleted)
9637 (if (and gnus-novice-user
9638 (not (gnus-yes-or-no-p
9639 (format "Do you really want to delete %s forever? "
9640 (if (> (length articles) 1)
9641 (format "these %s articles" (length articles))
9642 "this article")))))
9643 ()
9644 ;; Delete the articles.
9645 (setq not-deleted (gnus-request-expire-articles
9646 articles gnus-newsgroup-name 'force))
9647 (while articles
9648 (gnus-summary-remove-process-mark (car articles))
9649 ;; The backend might not have been able to delete the article
9650 ;; after all.
9651 (unless (memq (car articles) not-deleted)
9652 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9653 (let* ((article (car articles))
9654 (id (mail-header-id (gnus-data-header
9655 (assoc article (gnus-data-list nil))))))
9656 (run-hook-with-args 'gnus-summary-article-delete-hook
9657 'delete id gnus-newsgroup-name nil
9658 nil))
9659 (setq articles (cdr articles)))
9660 (when not-deleted
9661 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9662 (gnus-summary-position-point)
9663 (gnus-set-mode-line 'summary)
9664 not-deleted))
9665
9666 (defun gnus-summary-edit-article (&optional arg)
9667 "Edit the current article.
9668 This will have permanent effect only in mail groups.
9669 If ARG is nil, edit the decoded articles.
9670 If ARG is 1, edit the raw articles.
9671 If ARG is 2, edit the raw articles even in read-only groups.
9672 If ARG is 3, edit the articles with the current handles.
9673 Otherwise, allow editing of articles even in read-only
9674 groups."
9675 (interactive "P")
9676 (let (force raw current-handles)
9677 (cond
9678 ((null arg))
9679 ((eq arg 1)
9680 (setq raw t))
9681 ((eq arg 2)
9682 (setq raw t
9683 force t))
9684 ((eq arg 3)
9685 (setq current-handles
9686 (and (gnus-buffer-live-p gnus-article-buffer)
9687 (with-current-buffer gnus-article-buffer
9688 (prog1
9689 gnus-article-mime-handles
9690 (setq gnus-article-mime-handles nil))))))
9691 (t
9692 (setq force t)))
9693 (when (and raw (not force)
9694 (member gnus-newsgroup-name '("nndraft:delayed"
9695 "nndraft:drafts"
9696 "nndraft:queue")))
9697 (error "Can't edit the raw article in group %s"
9698 gnus-newsgroup-name))
9699 (save-excursion
9700 (set-buffer gnus-summary-buffer)
9701 (let ((mail-parse-charset gnus-newsgroup-charset)
9702 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9703 (gnus-set-global-variables)
9704 (when (and (not force)
9705 (gnus-group-read-only-p))
9706 (error "The current newsgroup does not support article editing"))
9707 (gnus-summary-show-article t)
9708 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9709 (with-current-buffer gnus-article-buffer
9710 (mm-enable-multibyte)))
9711 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9712 (setq raw t))
9713 (gnus-article-edit-article
9714 (if raw 'ignore
9715 `(lambda ()
9716 (let ((mbl mml-buffer-list))
9717 (setq mml-buffer-list nil)
9718 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9719 (mime-to-mml ,'current-handles))
9720 (let ((mbl1 mml-buffer-list))
9721 (setq mml-buffer-list mbl)
9722 (set (make-local-variable 'mml-buffer-list) mbl1))
9723 (gnus-make-local-hook 'kill-buffer-hook)
9724 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9725 `(lambda (no-highlight)
9726 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9727 (message-options message-options)
9728 (message-options-set-recipient)
9729 (mail-parse-ignored-charsets
9730 ',gnus-newsgroup-ignored-charsets))
9731 ,(if (not raw) '(progn
9732 (mml-to-mime)
9733 (mml-destroy-buffers)
9734 (remove-hook 'kill-buffer-hook
9735 'mml-destroy-buffers t)
9736 (kill-local-variable 'mml-buffer-list)))
9737 (gnus-summary-edit-article-done
9738 ,(or (mail-header-references gnus-current-headers) "")
9739 ,(gnus-group-read-only-p)
9740 ,gnus-summary-buffer no-highlight))))))))
9741
9742 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9743
9744 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9745 no-highlight)
9746 "Make edits to the current article permanent."
9747 (interactive)
9748 (save-excursion
9749 ;; The buffer restriction contains the entire article if it exists.
9750 (when (article-goto-body)
9751 (let ((lines (count-lines (point) (point-max)))
9752 (length (- (point-max) (point)))
9753 (case-fold-search t)
9754 (body (copy-marker (point))))
9755 (goto-char (point-min))
9756 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9757 (delete-region (match-beginning 1) (match-end 1))
9758 (insert (number-to-string length)))
9759 (goto-char (point-min))
9760 (when (re-search-forward
9761 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9762 (delete-region (match-beginning 1) (match-end 1))
9763 (insert (number-to-string length)))
9764 (goto-char (point-min))
9765 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9766 (delete-region (match-beginning 1) (match-end 1))
9767 (insert (number-to-string lines))))))
9768 ;; Replace the article.
9769 (let ((buf (current-buffer)))
9770 (with-temp-buffer
9771 (insert-buffer-substring buf)
9772
9773 (if (and (not read-only)
9774 (not (gnus-request-replace-article
9775 (cdr gnus-article-current) (car gnus-article-current)
9776 (current-buffer) t)))
9777 (error "Couldn't replace article")
9778 ;; Update the summary buffer.
9779 (if (and references
9780 (equal (message-tokenize-header references " ")
9781 (message-tokenize-header
9782 (or (message-fetch-field "references") "") " ")))
9783 ;; We only have to update this line.
9784 (save-excursion
9785 (save-restriction
9786 (message-narrow-to-head)
9787 (let ((head (buffer-substring-no-properties
9788 (point-min) (point-max)))
9789 header)
9790 (with-temp-buffer
9791 (insert (format "211 %d Article retrieved.\n"
9792 (cdr gnus-article-current)))
9793 (insert head)
9794 (insert ".\n")
9795 (let ((nntp-server-buffer (current-buffer)))
9796 (setq header (car (gnus-get-newsgroup-headers
9797 nil t))))
9798 (save-excursion
9799 (set-buffer gnus-summary-buffer)
9800 (gnus-data-set-header
9801 (gnus-data-find (cdr gnus-article-current))
9802 header)
9803 (gnus-summary-update-article-line
9804 (cdr gnus-article-current) header)
9805 (if (gnus-summary-goto-subject
9806 (cdr gnus-article-current) nil t)
9807 (gnus-summary-update-secondary-mark
9808 (cdr gnus-article-current))))))))
9809 ;; Update threads.
9810 (set-buffer (or buffer gnus-summary-buffer))
9811 (gnus-summary-update-article (cdr gnus-article-current))
9812 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9813 (gnus-summary-update-secondary-mark
9814 (cdr gnus-article-current))))
9815 ;; Prettify the article buffer again.
9816 (unless no-highlight
9817 (save-excursion
9818 (set-buffer gnus-article-buffer)
9819 ;;;!!! Fix this -- article should be rehighlighted.
9820 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9821 (set-buffer gnus-original-article-buffer)
9822 (gnus-request-article
9823 (cdr gnus-article-current)
9824 (car gnus-article-current) (current-buffer))))
9825 ;; Prettify the summary buffer line.
9826 (when (gnus-visual-p 'summary-highlight 'highlight)
9827 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9828
9829 (defun gnus-summary-edit-wash (key)
9830 "Perform editing command KEY in the article buffer."
9831 (interactive
9832 (list
9833 (progn
9834 (message "%s" (concat (this-command-keys) "- "))
9835 (read-char))))
9836 (message "")
9837 (gnus-summary-edit-article)
9838 (execute-kbd-macro (concat (this-command-keys) key))
9839 (gnus-article-edit-done))
9840
9841 ;;; Respooling
9842
9843 (defun gnus-summary-respool-query (&optional silent trace)
9844 "Query where the respool algorithm would put this article."
9845 (interactive)
9846 (let (gnus-mark-article-hook)
9847 (gnus-summary-select-article)
9848 (save-excursion
9849 (set-buffer gnus-original-article-buffer)
9850 (let ((groups (nnmail-article-group 'identity trace)))
9851 (unless silent
9852 (if groups
9853 (message "This message would go to %s"
9854 (mapconcat 'car groups ", "))
9855 (message "This message would go to no groups"))
9856 groups)))))
9857
9858 (defun gnus-summary-respool-trace ()
9859 "Trace where the respool algorithm would put this article.
9860 Display a buffer showing all fancy splitting patterns which matched."
9861 (interactive)
9862 (gnus-summary-respool-query nil t))
9863
9864 ;; Summary marking commands.
9865
9866 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9867 "Mark articles which has the same subject as read, and then select the next.
9868 If UNMARK is positive, remove any kind of mark.
9869 If UNMARK is negative, tick articles."
9870 (interactive "P")
9871 (when unmark
9872 (setq unmark (prefix-numeric-value unmark)))
9873 (let ((count
9874 (gnus-summary-mark-same-subject
9875 (gnus-summary-article-subject) unmark)))
9876 ;; Select next unread article. If auto-select-same mode, should
9877 ;; select the first unread article.
9878 (gnus-summary-next-article t (and gnus-auto-select-same
9879 (gnus-summary-article-subject)))
9880 (gnus-message 7 "%d article%s marked as %s"
9881 count (if (= count 1) " is" "s are")
9882 (if unmark "unread" "read"))))
9883
9884 (defun gnus-summary-kill-same-subject (&optional unmark)
9885 "Mark articles which has the same subject as read.
9886 If UNMARK is positive, remove any kind of mark.
9887 If UNMARK is negative, tick articles."
9888 (interactive "P")
9889 (when unmark
9890 (setq unmark (prefix-numeric-value unmark)))
9891 (let ((count
9892 (gnus-summary-mark-same-subject
9893 (gnus-summary-article-subject) unmark)))
9894 ;; If marked as read, go to next unread subject.
9895 (when (null unmark)
9896 ;; Go to next unread subject.
9897 (gnus-summary-next-subject 1 t))
9898 (gnus-message 7 "%d articles are marked as %s"
9899 count (if unmark "unread" "read"))))
9900
9901 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9902 "Mark articles with same SUBJECT as read, and return marked number.
9903 If optional argument UNMARK is positive, remove any kinds of marks.
9904 If optional argument UNMARK is negative, mark articles as unread instead."
9905 (let ((count 1))
9906 (save-excursion
9907 (cond
9908 ((null unmark) ; Mark as read.
9909 (while (and
9910 (progn
9911 (gnus-summary-mark-article-as-read gnus-killed-mark)
9912 (gnus-summary-show-thread) t)
9913 (gnus-summary-find-subject subject))
9914 (setq count (1+ count))))
9915 ((> unmark 0) ; Tick.
9916 (while (and
9917 (progn
9918 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9919 (gnus-summary-show-thread) t)
9920 (gnus-summary-find-subject subject))
9921 (setq count (1+ count))))
9922 (t ; Mark as unread.
9923 (while (and
9924 (progn
9925 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9926 (gnus-summary-show-thread) t)
9927 (gnus-summary-find-subject subject))
9928 (setq count (1+ count)))))
9929 (gnus-set-mode-line 'summary)
9930 ;; Return the number of marked articles.
9931 count)))
9932
9933 (defun gnus-summary-mark-as-processable (n &optional unmark)
9934 "Set the process mark on the next N articles.
9935 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9936 the process mark instead. The difference between N and the actual
9937 number of articles marked is returned."
9938 (interactive "P")
9939 (if (and (null n) (gnus-region-active-p))
9940 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9941 (setq n (prefix-numeric-value n))
9942 (let ((backward (< n 0))
9943 (n (abs n)))
9944 (while (and
9945 (> n 0)
9946 (if unmark
9947 (gnus-summary-remove-process-mark
9948 (gnus-summary-article-number))
9949 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9950 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9951 (setq n (1- n)))
9952 (when (/= 0 n)
9953 (gnus-message 7 "No more articles"))
9954 (gnus-summary-recenter)
9955 (gnus-summary-position-point)
9956 n)))
9957
9958 (defun gnus-summary-unmark-as-processable (n)
9959 "Remove the process mark from the next N articles.
9960 If N is negative, unmark backward instead. The difference between N and
9961 the actual number of articles unmarked is returned."
9962 (interactive "P")
9963 (gnus-summary-mark-as-processable n t))
9964
9965 (defun gnus-summary-unmark-all-processable ()
9966 "Remove the process mark from all articles."
9967 (interactive)
9968 (save-excursion
9969 (while gnus-newsgroup-processable
9970 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9971 (gnus-summary-position-point))
9972
9973 (defun gnus-summary-add-mark (article type)
9974 "Mark ARTICLE with a mark of TYPE."
9975 (let ((vtype (car (assq type gnus-article-mark-lists)))
9976 var)
9977 (if (not vtype)
9978 (error "No such mark type: %s" type)
9979 (setq var (intern (format "gnus-newsgroup-%s" type)))
9980 (set var (cons article (symbol-value var)))
9981 (if (memq type '(processable cached replied forwarded recent saved))
9982 (gnus-summary-update-secondary-mark article)
9983 ;;; !!! This is bogus. We should find out what primary
9984 ;;; !!! mark we want to set.
9985 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9986
9987 (defun gnus-summary-mark-as-expirable (n)
9988 "Mark N articles forward as expirable.
9989 If N is negative, mark backward instead. The difference between N and
9990 the actual number of articles marked is returned."
9991 (interactive "p")
9992 (gnus-summary-mark-forward n gnus-expirable-mark))
9993
9994 (defun gnus-summary-mark-as-spam (n)
9995 "Mark N articles forward as spam.
9996 If N is negative, mark backward instead. The difference between N and
9997 the actual number of articles marked is returned."
9998 (interactive "p")
9999 (gnus-summary-mark-forward n gnus-spam-mark))
10000
10001 (defun gnus-summary-mark-article-as-replied (article)
10002 "Mark ARTICLE as replied to and update the summary line.
10003 ARTICLE can also be a list of articles."
10004 (interactive (list (gnus-summary-article-number)))
10005 (let ((articles (if (listp article) article (list article))))
10006 (dolist (article articles)
10007 (unless (numberp article)
10008 (error "%s is not a number" article))
10009 (push article gnus-newsgroup-replied)
10010 (let ((buffer-read-only nil))
10011 (when (gnus-summary-goto-subject article nil t)
10012 (gnus-summary-update-secondary-mark article))))))
10013
10014 (defun gnus-summary-mark-article-as-forwarded (article)
10015 "Mark ARTICLE as forwarded and update the summary line.
10016 ARTICLE can also be a list of articles."
10017 (let ((articles (if (listp article) article (list article))))
10018 (dolist (article articles)
10019 (push article gnus-newsgroup-forwarded)
10020 (let ((buffer-read-only nil))
10021 (when (gnus-summary-goto-subject article nil t)
10022 (gnus-summary-update-secondary-mark article))))))
10023
10024 (defun gnus-summary-set-bookmark (article)
10025 "Set a bookmark in current article."
10026 (interactive (list (gnus-summary-article-number)))
10027 (when (or (not (get-buffer gnus-article-buffer))
10028 (not gnus-current-article)
10029 (not gnus-article-current)
10030 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10031 (error "No current article selected"))
10032 ;; Remove old bookmark, if one exists.
10033 (gnus-pull article gnus-newsgroup-bookmarks)
10034 ;; Set the new bookmark, which is on the form
10035 ;; (article-number . line-number-in-body).
10036 (push
10037 (cons article
10038 (save-excursion
10039 (set-buffer gnus-article-buffer)
10040 (count-lines
10041 (min (point)
10042 (save-excursion
10043 (article-goto-body)
10044 (point)))
10045 (point))))
10046 gnus-newsgroup-bookmarks)
10047 (gnus-message 6 "A bookmark has been added to the current article."))
10048
10049 (defun gnus-summary-remove-bookmark (article)
10050 "Remove the bookmark from the current article."
10051 (interactive (list (gnus-summary-article-number)))
10052 ;; Remove old bookmark, if one exists.
10053 (if (not (assq article gnus-newsgroup-bookmarks))
10054 (gnus-message 6 "No bookmark in current article.")
10055 (gnus-pull article gnus-newsgroup-bookmarks)
10056 (gnus-message 6 "Removed bookmark.")))
10057
10058 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10059 (defun gnus-summary-mark-as-dormant (n)
10060 "Mark N articles forward as dormant.
10061 If N is negative, mark backward instead. The difference between N and
10062 the actual number of articles marked is returned."
10063 (interactive "p")
10064 (gnus-summary-mark-forward n gnus-dormant-mark))
10065
10066 (defun gnus-summary-set-process-mark (article)
10067 "Set the process mark on ARTICLE and update the summary line."
10068 (setq gnus-newsgroup-processable
10069 (cons article
10070 (delq article gnus-newsgroup-processable)))
10071 (when (gnus-summary-goto-subject article)
10072 (gnus-summary-show-thread)
10073 (gnus-summary-goto-subject article)
10074 (gnus-summary-update-secondary-mark article)))
10075
10076 (defun gnus-summary-remove-process-mark (article)
10077 "Remove the process mark from ARTICLE and update the summary line."
10078 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10079 (when (gnus-summary-goto-subject article)
10080 (gnus-summary-show-thread)
10081 (gnus-summary-goto-subject article)
10082 (gnus-summary-update-secondary-mark article)))
10083
10084 (defun gnus-summary-set-saved-mark (article)
10085 "Set the process mark on ARTICLE and update the summary line."
10086 (push article gnus-newsgroup-saved)
10087 (when (gnus-summary-goto-subject article)
10088 (gnus-summary-update-secondary-mark article)))
10089
10090 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10091 "Mark N articles as read forwards.
10092 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10093 The difference between N and the actual number of articles marked is
10094 returned.
10095 If NO-EXPIRE, auto-expiry will be inhibited."
10096 (interactive "p")
10097 (gnus-summary-show-thread)
10098 (let ((backward (< n 0))
10099 (gnus-summary-goto-unread
10100 (and gnus-summary-goto-unread
10101 (not (eq gnus-summary-goto-unread 'never))
10102 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10103 gnus-ticked-mark gnus-dormant-mark)))))
10104 (n (abs n))
10105 (mark (or mark gnus-del-mark)))
10106 (while (and (> n 0)
10107 (gnus-summary-mark-article nil mark no-expire)
10108 (zerop (gnus-summary-next-subject
10109 (if backward -1 1)
10110 (and gnus-summary-goto-unread
10111 (not (eq gnus-summary-goto-unread 'never)))
10112 t)))
10113 (setq n (1- n)))
10114 (when (/= 0 n)
10115 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10116 (gnus-summary-recenter)
10117 (gnus-summary-position-point)
10118 (gnus-set-mode-line 'summary)
10119 n))
10120
10121 (defun gnus-summary-mark-article-as-read (mark)
10122 "Mark the current article quickly as read with MARK."
10123 (let ((article (gnus-summary-article-number)))
10124 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10125 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10126 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10127 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10128 (push (cons article mark) gnus-newsgroup-reads)
10129 ;; Possibly remove from cache, if that is used.
10130 (when gnus-use-cache
10131 (gnus-cache-enter-remove-article article))
10132 ;; Allow the backend to change the mark.
10133 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10134 ;; Check for auto-expiry.
10135 (when (and gnus-newsgroup-auto-expire
10136 (memq mark gnus-auto-expirable-marks))
10137 (setq mark gnus-expirable-mark)
10138 ;; Let the backend know about the mark change.
10139 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10140 (push article gnus-newsgroup-expirable))
10141 ;; Set the mark in the buffer.
10142 (gnus-summary-update-mark mark 'unread)
10143 t))
10144
10145 (defun gnus-summary-mark-article-as-unread (mark)
10146 "Mark the current article quickly as unread with MARK."
10147 (let* ((article (gnus-summary-article-number))
10148 (old-mark (gnus-summary-article-mark article)))
10149 ;; Allow the backend to change the mark.
10150 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10151 (if (eq mark old-mark)
10152 t
10153 (if (<= article 0)
10154 (progn
10155 (gnus-error 1 "Can't mark negative article numbers")
10156 nil)
10157 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10158 (setq gnus-newsgroup-spam-marked
10159 (delq article gnus-newsgroup-spam-marked))
10160 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10161 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10162 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10163 (cond ((= mark gnus-ticked-mark)
10164 (setq gnus-newsgroup-marked
10165 (gnus-add-to-sorted-list gnus-newsgroup-marked
10166 article)))
10167 ((= mark gnus-spam-mark)
10168 (setq gnus-newsgroup-spam-marked
10169 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10170 article)))
10171 ((= mark gnus-dormant-mark)
10172 (setq gnus-newsgroup-dormant
10173 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10174 article)))
10175 (t
10176 (setq gnus-newsgroup-unreads
10177 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10178 article))))
10179 (gnus-pull article gnus-newsgroup-reads)
10180
10181 ;; See whether the article is to be put in the cache.
10182 (and gnus-use-cache
10183 (vectorp (gnus-summary-article-header article))
10184 (save-excursion
10185 (gnus-cache-possibly-enter-article
10186 gnus-newsgroup-name article
10187 (= mark gnus-ticked-mark)
10188 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10189
10190 ;; Fix the mark.
10191 (gnus-summary-update-mark mark 'unread)
10192 t))))
10193
10194 (defun gnus-summary-mark-article (&optional article mark no-expire)
10195 "Mark ARTICLE with MARK. MARK can be any character.
10196 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10197 `??' (dormant) and `?E' (expirable).
10198 If MARK is nil, then the default character `?r' is used.
10199 If ARTICLE is nil, then the article on the current line will be
10200 marked.
10201 If NO-EXPIRE, auto-expiry will be inhibited."
10202 ;; The mark might be a string.
10203 (when (stringp mark)
10204 (setq mark (aref mark 0)))
10205 ;; If no mark is given, then we check auto-expiring.
10206 (when (null mark)
10207 (setq mark gnus-del-mark))
10208 (when (and (not no-expire)
10209 gnus-newsgroup-auto-expire
10210 (memq mark gnus-auto-expirable-marks))
10211 (setq mark gnus-expirable-mark))
10212 (let ((article (or article (gnus-summary-article-number)))
10213 (old-mark (gnus-summary-article-mark article)))
10214 ;; Allow the backend to change the mark.
10215 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10216 (if (eq mark old-mark)
10217 t
10218 (unless article
10219 (error "No article on current line"))
10220 (if (not (if (or (= mark gnus-unread-mark)
10221 (= mark gnus-ticked-mark)
10222 (= mark gnus-spam-mark)
10223 (= mark gnus-dormant-mark))
10224 (gnus-mark-article-as-unread article mark)
10225 (gnus-mark-article-as-read article mark)))
10226 t
10227 ;; See whether the article is to be put in the cache.
10228 (and gnus-use-cache
10229 (not (= mark gnus-canceled-mark))
10230 (vectorp (gnus-summary-article-header article))
10231 (save-excursion
10232 (gnus-cache-possibly-enter-article
10233 gnus-newsgroup-name article
10234 (= mark gnus-ticked-mark)
10235 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10236
10237 (when (gnus-summary-goto-subject article nil t)
10238 (let ((buffer-read-only nil))
10239 (gnus-summary-show-thread)
10240 ;; Fix the mark.
10241 (gnus-summary-update-mark mark 'unread)
10242 t))))))
10243
10244 (defun gnus-summary-update-secondary-mark (article)
10245 "Update the secondary (read, process, cache) mark."
10246 (gnus-summary-update-mark
10247 (cond ((memq article gnus-newsgroup-processable)
10248 gnus-process-mark)
10249 ((memq article gnus-newsgroup-cached)
10250 gnus-cached-mark)
10251 ((memq article gnus-newsgroup-replied)
10252 gnus-replied-mark)
10253 ((memq article gnus-newsgroup-forwarded)
10254 gnus-forwarded-mark)
10255 ((memq article gnus-newsgroup-saved)
10256 gnus-saved-mark)
10257 ((memq article gnus-newsgroup-recent)
10258 gnus-recent-mark)
10259 ((memq article gnus-newsgroup-unseen)
10260 gnus-unseen-mark)
10261 (t gnus-no-mark))
10262 'replied)
10263 (when (gnus-visual-p 'summary-highlight 'highlight)
10264 (gnus-run-hooks 'gnus-summary-update-hook))
10265 t)
10266
10267 (defun gnus-summary-update-download-mark (article)
10268 "Update the download mark."
10269 (gnus-summary-update-mark
10270 (cond ((memq article gnus-newsgroup-undownloaded)
10271 gnus-undownloaded-mark)
10272 (gnus-newsgroup-agentized
10273 gnus-downloaded-mark)
10274 (t
10275 gnus-no-mark))
10276 'download)
10277 (gnus-summary-update-line t)
10278 t)
10279
10280 (defun gnus-summary-update-mark (mark type)
10281 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10282 (buffer-read-only nil))
10283 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10284 (when forward
10285 (when (looking-at "\r")
10286 (incf forward))
10287 (when (<= (+ forward (point)) (point-max))
10288 ;; Go to the right position on the line.
10289 (goto-char (+ forward (point)))
10290 ;; Replace the old mark with the new mark.
10291 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10292 ;; Optionally update the marks by some user rule.
10293 (when (eq type 'unread)
10294 (gnus-data-set-mark
10295 (gnus-data-find (gnus-summary-article-number)) mark)
10296 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10297
10298 (defun gnus-mark-article-as-read (article &optional mark)
10299 "Enter ARTICLE in the pertinent lists and remove it from others."
10300 ;; Make the article expirable.
10301 (let ((mark (or mark gnus-del-mark)))
10302 (setq gnus-newsgroup-expirable
10303 (if (= mark gnus-expirable-mark)
10304 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10305 (delq article gnus-newsgroup-expirable)))
10306 ;; Remove from unread and marked lists.
10307 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10308 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10309 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10310 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10311 (push (cons article mark) gnus-newsgroup-reads)
10312 ;; Possibly remove from cache, if that is used.
10313 (when gnus-use-cache
10314 (gnus-cache-enter-remove-article article))
10315 t))
10316
10317 (defun gnus-mark-article-as-unread (article &optional mark)
10318 "Enter ARTICLE in the pertinent lists and remove it from others."
10319 (let ((mark (or mark gnus-ticked-mark)))
10320 (if (<= article 0)
10321 (progn
10322 (gnus-error 1 "Can't mark negative article numbers")
10323 nil)
10324 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10325 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10326 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10327 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10328 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10329
10330 ;; Unsuppress duplicates?
10331 (when gnus-suppress-duplicates
10332 (gnus-dup-unsuppress-article article))
10333
10334 (cond ((= mark gnus-ticked-mark)
10335 (setq gnus-newsgroup-marked
10336 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10337 ((= mark gnus-spam-mark)
10338 (setq gnus-newsgroup-spam-marked
10339 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10340 article)))
10341 ((= mark gnus-dormant-mark)
10342 (setq gnus-newsgroup-dormant
10343 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10344 (t
10345 (setq gnus-newsgroup-unreads
10346 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10347 (gnus-pull article gnus-newsgroup-reads)
10348 t)))
10349
10350 (defalias 'gnus-summary-mark-as-unread-forward
10351 'gnus-summary-tick-article-forward)
10352 (make-obsolete 'gnus-summary-mark-as-unread-forward
10353 'gnus-summary-tick-article-forward)
10354 (defun gnus-summary-tick-article-forward (n)
10355 "Tick N articles forwards.
10356 If N is negative, tick backwards instead.
10357 The difference between N and the number of articles ticked is returned."
10358 (interactive "p")
10359 (gnus-summary-mark-forward n gnus-ticked-mark))
10360
10361 (defalias 'gnus-summary-mark-as-unread-backward
10362 'gnus-summary-tick-article-backward)
10363 (make-obsolete 'gnus-summary-mark-as-unread-backward
10364 'gnus-summary-tick-article-backward)
10365 (defun gnus-summary-tick-article-backward (n)
10366 "Tick N articles backwards.
10367 The difference between N and the number of articles ticked is returned."
10368 (interactive "p")
10369 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10370
10371 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10372 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10373 (defun gnus-summary-tick-article (&optional article clear-mark)
10374 "Mark current article as unread.
10375 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10376 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10377 (interactive)
10378 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10379 gnus-ticked-mark)))
10380
10381 (defun gnus-summary-mark-as-read-forward (n)
10382 "Mark N articles as read forwards.
10383 If N is negative, mark backwards instead.
10384 The difference between N and the actual number of articles marked is
10385 returned."
10386 (interactive "p")
10387 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10388
10389 (defun gnus-summary-mark-as-read-backward (n)
10390 "Mark the N articles as read backwards.
10391 The difference between N and the actual number of articles marked is
10392 returned."
10393 (interactive "p")
10394 (gnus-summary-mark-forward
10395 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10396
10397 (defun gnus-summary-mark-as-read (&optional article mark)
10398 "Mark current article as read.
10399 ARTICLE specifies the article to be marked as read.
10400 MARK specifies a string to be inserted at the beginning of the line."
10401 (gnus-summary-mark-article article mark))
10402
10403 (defun gnus-summary-clear-mark-forward (n)
10404 "Clear marks from N articles forward.
10405 If N is negative, clear backward instead.
10406 The difference between N and the number of marks cleared is returned."
10407 (interactive "p")
10408 (gnus-summary-mark-forward n gnus-unread-mark))
10409
10410 (defun gnus-summary-clear-mark-backward (n)
10411 "Clear marks from N articles backward.
10412 The difference between N and the number of marks cleared is returned."
10413 (interactive "p")
10414 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10415
10416 (defun gnus-summary-mark-unread-as-read ()
10417 "Intended to be used by `gnus-mark-article-hook'."
10418 (when (memq gnus-current-article gnus-newsgroup-unreads)
10419 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10420
10421 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10422 "Intended to be used by `gnus-mark-article-hook'."
10423 (let ((mark (gnus-summary-article-mark)))
10424 (when (or (gnus-unread-mark-p mark)
10425 (gnus-read-mark-p mark))
10426 (gnus-summary-mark-article gnus-current-article
10427 (or new-mark gnus-read-mark)))))
10428
10429 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10430 "Intended to be used by `gnus-mark-article-hook'."
10431 (let ((mark (gnus-summary-article-mark)))
10432 (when (or (gnus-unread-mark-p mark)
10433 (gnus-read-mark-p mark))
10434 (gnus-summary-mark-article (gnus-summary-article-number)
10435 (or new-mark gnus-read-mark)))))
10436
10437 (defun gnus-summary-mark-unread-as-ticked ()
10438 "Intended to be used by `gnus-mark-article-hook'."
10439 (when (memq gnus-current-article gnus-newsgroup-unreads)
10440 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10441
10442 (defun gnus-summary-mark-region-as-read (point mark all)
10443 "Mark all unread articles between point and mark as read.
10444 If given a prefix, mark all articles between point and mark as read,
10445 even ticked and dormant ones."
10446 (interactive "r\nP")
10447 (save-excursion
10448 (let (article)
10449 (goto-char point)
10450 (beginning-of-line)
10451 (while (and
10452 (< (point) mark)
10453 (progn
10454 (when (or all
10455 (memq (setq article (gnus-summary-article-number))
10456 gnus-newsgroup-unreads))
10457 (gnus-summary-mark-article article gnus-del-mark))
10458 t)
10459 (gnus-summary-find-next))))))
10460
10461 (defun gnus-summary-mark-below (score mark)
10462 "Mark articles with score less than SCORE with MARK."
10463 (interactive "P\ncMark: ")
10464 (setq score (if score
10465 (prefix-numeric-value score)
10466 (or gnus-summary-default-score 0)))
10467 (save-excursion
10468 (set-buffer gnus-summary-buffer)
10469 (goto-char (point-min))
10470 (while
10471 (progn
10472 (and (< (gnus-summary-article-score) score)
10473 (gnus-summary-mark-article nil mark))
10474 (gnus-summary-find-next)))))
10475
10476 (defun gnus-summary-kill-below (&optional score)
10477 "Mark articles with score below SCORE as read."
10478 (interactive "P")
10479 (gnus-summary-mark-below score gnus-killed-mark))
10480
10481 (defun gnus-summary-clear-above (&optional score)
10482 "Clear all marks from articles with score above SCORE."
10483 (interactive "P")
10484 (gnus-summary-mark-above score gnus-unread-mark))
10485
10486 (defun gnus-summary-tick-above (&optional score)
10487 "Tick all articles with score above SCORE."
10488 (interactive "P")
10489 (gnus-summary-mark-above score gnus-ticked-mark))
10490
10491 (defun gnus-summary-mark-above (score mark)
10492 "Mark articles with score over SCORE with MARK."
10493 (interactive "P\ncMark: ")
10494 (setq score (if score
10495 (prefix-numeric-value score)
10496 (or gnus-summary-default-score 0)))
10497 (save-excursion
10498 (set-buffer gnus-summary-buffer)
10499 (goto-char (point-min))
10500 (while (and (progn
10501 (when (> (gnus-summary-article-score) score)
10502 (gnus-summary-mark-article nil mark))
10503 t)
10504 (gnus-summary-find-next)))))
10505
10506 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10507 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10508 (defun gnus-summary-limit-include-expunged (&optional no-error)
10509 "Display all the hidden articles that were expunged for low scores."
10510 (interactive)
10511 (let ((buffer-read-only nil))
10512 (let ((scored gnus-newsgroup-scored)
10513 headers h)
10514 (while scored
10515 (unless (gnus-summary-article-header (caar scored))
10516 (and (setq h (gnus-number-to-header (caar scored)))
10517 (< (cdar scored) gnus-summary-expunge-below)
10518 (push h headers)))
10519 (setq scored (cdr scored)))
10520 (if (not headers)
10521 (when (not no-error)
10522 (error "No expunged articles hidden"))
10523 (goto-char (point-min))
10524 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10525 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10526 (mapcar (lambda (x) (push (mail-header-number x)
10527 gnus-newsgroup-limit))
10528 headers)
10529 (gnus-summary-prepare-unthreaded (nreverse headers))
10530 (goto-char (point-min))
10531 (gnus-summary-position-point)
10532 t))))
10533
10534 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10535 "Mark all unread articles in this newsgroup as read.
10536 If prefix argument ALL is non-nil, ticked and dormant articles will
10537 also be marked as read.
10538 If QUIETLY is non-nil, no questions will be asked.
10539
10540 If TO-HERE is non-nil, it should be a point in the buffer. All
10541 articles before (after, if REVERSE is set) this point will be marked
10542 as read.
10543
10544 Note that this function will only catch up the unread article
10545 in the current summary buffer limitation.
10546
10547 The number of articles marked as read is returned."
10548 (interactive "P")
10549 (prog1
10550 (save-excursion
10551 (when (or quietly
10552 (not gnus-interactive-catchup) ;Without confirmation?
10553 gnus-expert-user
10554 (gnus-y-or-n-p
10555 (if all
10556 "Mark absolutely all articles as read? "
10557 "Mark all unread articles as read? ")))
10558 (if (and not-mark
10559 (not gnus-newsgroup-adaptive)
10560 (not gnus-newsgroup-auto-expire)
10561 (not gnus-suppress-duplicates)
10562 (or (not gnus-use-cache)
10563 (eq gnus-use-cache 'passive)))
10564 (progn
10565 (when all
10566 (setq gnus-newsgroup-marked nil
10567 gnus-newsgroup-spam-marked nil
10568 gnus-newsgroup-dormant nil))
10569 (setq gnus-newsgroup-unreads
10570 (gnus-sorted-nunion
10571 (gnus-sorted-intersection gnus-newsgroup-unreads
10572 gnus-newsgroup-downloadable)
10573 (gnus-sorted-difference gnus-newsgroup-unfetched
10574 gnus-newsgroup-cached))))
10575 ;; We actually mark all articles as canceled, which we
10576 ;; have to do when using auto-expiry or adaptive scoring.
10577 (gnus-summary-show-all-threads)
10578 (if (and to-here reverse)
10579 (progn
10580 (goto-char to-here)
10581 (gnus-summary-mark-current-read-and-unread-as-read
10582 gnus-catchup-mark)
10583 (while (gnus-summary-find-next (not all))
10584 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10585 (when (gnus-summary-first-subject (not all))
10586 (while (and
10587 (if to-here (< (point) to-here) t)
10588 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10589 (gnus-summary-find-next (not all))))))
10590 (gnus-set-mode-line 'summary))
10591 t))
10592 (gnus-summary-position-point)))
10593
10594 (defun gnus-summary-catchup-to-here (&optional all)
10595 "Mark all unticked articles before the current one as read.
10596 If ALL is non-nil, also mark ticked and dormant articles as read."
10597 (interactive "P")
10598 (save-excursion
10599 (gnus-save-hidden-threads
10600 (let ((beg (point)))
10601 ;; We check that there are unread articles.
10602 (when (or all (gnus-summary-find-prev))
10603 (gnus-summary-catchup all t beg)))))
10604 (gnus-summary-position-point))
10605
10606 (defun gnus-summary-catchup-from-here (&optional all)
10607 "Mark all unticked articles after (and including) the current one as read.
10608 If ALL is non-nil, also mark ticked and dormant articles as read."
10609 (interactive "P")
10610 (save-excursion
10611 (gnus-save-hidden-threads
10612 (let ((beg (point)))
10613 ;; We check that there are unread articles.
10614 (when (or all (gnus-summary-find-next))
10615 (gnus-summary-catchup all t beg nil t)))))
10616 (gnus-summary-position-point))
10617
10618 (defun gnus-summary-catchup-all (&optional quietly)
10619 "Mark all articles in this newsgroup as read.
10620 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10621 instead, which marks only unread articles as read."
10622 (interactive "P")
10623 (gnus-summary-catchup t quietly))
10624
10625 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10626 "Mark all unread articles in this group as read, then exit.
10627 If prefix argument ALL is non-nil, all articles are marked as read.
10628 If QUIETLY is non-nil, no questions will be asked."
10629 (interactive "P")
10630 (when (gnus-summary-catchup all quietly nil 'fast)
10631 ;; Select next newsgroup or exit.
10632 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10633 (eq gnus-auto-select-next 'quietly))
10634 (gnus-summary-next-group nil)
10635 (gnus-summary-exit))))
10636
10637 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10638 "Mark all articles in this newsgroup as read, and then exit.
10639 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10640 instead, which marks only unread articles as read."
10641 (interactive "P")
10642 (gnus-summary-catchup-and-exit t quietly))
10643
10644 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10645 "Mark all articles in this group as read and select the next group.
10646 If given a prefix, mark all articles, unread as well as ticked, as
10647 read."
10648 (interactive "P")
10649 (save-excursion
10650 (gnus-summary-catchup all))
10651 (gnus-summary-next-group))
10652
10653 ;;;
10654 ;;; with article
10655 ;;;
10656
10657 (defmacro gnus-with-article (article &rest forms)
10658 "Select ARTICLE and perform FORMS in the original article buffer.
10659 Then replace the article with the result."
10660 `(progn
10661 ;; We don't want the article to be marked as read.
10662 (let (gnus-mark-article-hook)
10663 (gnus-summary-select-article t t nil ,article))
10664 (set-buffer gnus-original-article-buffer)
10665 ,@forms
10666 (if (not (gnus-check-backend-function
10667 'request-replace-article (car gnus-article-current)))
10668 (gnus-message 5 "Read-only group; not replacing")
10669 (unless (gnus-request-replace-article
10670 ,article (car gnus-article-current)
10671 (current-buffer) t)
10672 (error "Couldn't replace article")))
10673 ;; The cache and backlog have to be flushed somewhat.
10674 (when gnus-keep-backlog
10675 (gnus-backlog-remove-article
10676 (car gnus-article-current) (cdr gnus-article-current)))
10677 (when gnus-use-cache
10678 (gnus-cache-update-article
10679 (car gnus-article-current) (cdr gnus-article-current)))))
10680
10681 (put 'gnus-with-article 'lisp-indent-function 1)
10682 (put 'gnus-with-article 'edebug-form-spec '(form body))
10683
10684 ;; Thread-based commands.
10685
10686 (defun gnus-summary-articles-in-thread (&optional article)
10687 "Return a list of all articles in the current thread.
10688 If ARTICLE is non-nil, return all articles in the thread that starts
10689 with that article."
10690 (let* ((article (or article (gnus-summary-article-number)))
10691 (data (gnus-data-find-list article))
10692 (top-level (gnus-data-level (car data)))
10693 (top-subject
10694 (cond ((null gnus-thread-operation-ignore-subject)
10695 (gnus-simplify-subject-re
10696 (mail-header-subject (gnus-data-header (car data)))))
10697 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10698 (gnus-simplify-subject-fuzzy
10699 (mail-header-subject (gnus-data-header (car data)))))
10700 (t nil)))
10701 (end-point (save-excursion
10702 (if (gnus-summary-go-to-next-thread)
10703 (point) (point-max))))
10704 articles)
10705 (while (and data
10706 (< (gnus-data-pos (car data)) end-point))
10707 (when (or (not top-subject)
10708 (string= top-subject
10709 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10710 (gnus-simplify-subject-fuzzy
10711 (mail-header-subject
10712 (gnus-data-header (car data))))
10713 (gnus-simplify-subject-re
10714 (mail-header-subject
10715 (gnus-data-header (car data)))))))
10716 (push (gnus-data-number (car data)) articles))
10717 (unless (and (setq data (cdr data))
10718 (> (gnus-data-level (car data)) top-level))
10719 (setq data nil)))
10720 ;; Return the list of articles.
10721 (nreverse articles)))
10722
10723 (defun gnus-summary-rethread-current ()
10724 "Rethread the thread the current article is part of."
10725 (interactive)
10726 (let* ((gnus-show-threads t)
10727 (article (gnus-summary-article-number))
10728 (id (mail-header-id (gnus-summary-article-header)))
10729 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10730 (unless id
10731 (error "No article on the current line"))
10732 (gnus-rebuild-thread id)
10733 (gnus-summary-goto-subject article)))
10734
10735 (defun gnus-summary-reparent-thread ()
10736 "Make the current article child of the marked (or previous) article.
10737
10738 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10739 is non-nil or the Subject: of both articles are the same."
10740 (interactive)
10741 (unless (not (gnus-group-read-only-p))
10742 (error "The current newsgroup does not support article editing"))
10743 (unless (<= (length gnus-newsgroup-processable) 1)
10744 (error "No more than one article may be marked"))
10745 (save-window-excursion
10746 (let ((gnus-article-buffer " *reparent*")
10747 (current-article (gnus-summary-article-number))
10748 ;; First grab the marked article, otherwise one line up.
10749 (parent-article (if (not (null gnus-newsgroup-processable))
10750 (car gnus-newsgroup-processable)
10751 (save-excursion
10752 (if (eq (forward-line -1) 0)
10753 (gnus-summary-article-number)
10754 (error "Beginning of summary buffer"))))))
10755 (unless (not (eq current-article parent-article))
10756 (error "An article may not be self-referential"))
10757 (let ((message-id (mail-header-id
10758 (gnus-summary-article-header parent-article))))
10759 (unless (and message-id (not (equal message-id "")))
10760 (error "No message-id in desired parent"))
10761 (gnus-with-article current-article
10762 (save-restriction
10763 (goto-char (point-min))
10764 (message-narrow-to-head)
10765 (if (re-search-forward "^References: " nil t)
10766 (progn
10767 (re-search-forward "^[^ \t]" nil t)
10768 (forward-line -1)
10769 (end-of-line)
10770 (insert " " message-id))
10771 (insert "References: " message-id "\n"))))
10772 (set-buffer gnus-summary-buffer)
10773 (gnus-summary-unmark-all-processable)
10774 (gnus-summary-update-article current-article)
10775 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10776 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10777 (gnus-summary-rethread-current)
10778 (gnus-message 3 "Article %d is now the child of article %d"
10779 current-article parent-article)))))
10780
10781 (defun gnus-summary-toggle-threads (&optional arg)
10782 "Toggle showing conversation threads.
10783 If ARG is positive number, turn showing conversation threads on."
10784 (interactive "P")
10785 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10786 (setq gnus-show-threads
10787 (if (null arg) (not gnus-show-threads)
10788 (> (prefix-numeric-value arg) 0)))
10789 (gnus-summary-prepare)
10790 (gnus-summary-goto-subject current)
10791 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10792 (gnus-summary-position-point)))
10793
10794 (defun gnus-summary-show-all-threads ()
10795 "Show all threads."
10796 (interactive)
10797 (save-excursion
10798 (let ((buffer-read-only nil))
10799 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10800 (gnus-summary-position-point))
10801
10802 (defun gnus-summary-show-thread ()
10803 "Show thread subtrees.
10804 Returns nil if no thread was there to be shown."
10805 (interactive)
10806 (let ((buffer-read-only nil)
10807 (orig (point))
10808 (end (gnus-point-at-eol))
10809 ;; Leave point at bol
10810 (beg (progn (beginning-of-line) (point))))
10811 (prog1
10812 ;; Any hidden lines here?
10813 (search-forward "\r" end t)
10814 (subst-char-in-region beg end ?\^M ?\n t)
10815 (goto-char orig)
10816 (gnus-summary-position-point))))
10817
10818 (defun gnus-summary-maybe-hide-threads ()
10819 "If requested, hide the threads that should be hidden."
10820 (when (and gnus-show-threads
10821 gnus-thread-hide-subtree)
10822 (gnus-summary-hide-all-threads
10823 (if (or (consp gnus-thread-hide-subtree)
10824 (functionp gnus-thread-hide-subtree))
10825 (gnus-make-predicate gnus-thread-hide-subtree)
10826 nil))))
10827
10828 ;;; Hiding predicates.
10829
10830 (defun gnus-article-unread-p (header)
10831 (memq (mail-header-number header) gnus-newsgroup-unreads))
10832
10833 (defun gnus-article-unseen-p (header)
10834 (memq (mail-header-number header) gnus-newsgroup-unseen))
10835
10836 (defun gnus-map-articles (predicate articles)
10837 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10838 (apply 'gnus-or (mapcar predicate
10839 (mapcar (lambda (number)
10840 (gnus-summary-article-header number))
10841 articles))))
10842
10843 (defun gnus-summary-hide-all-threads (&optional predicate)
10844 "Hide all thread subtrees.
10845 If PREDICATE is supplied, threads that satisfy this predicate
10846 will not be hidden."
10847 (interactive)
10848 (save-excursion
10849 (goto-char (point-min))
10850 (let ((end nil))
10851 (while (not end)
10852 (when (or (not predicate)
10853 (gnus-map-articles
10854 predicate (gnus-summary-article-children)))
10855 (gnus-summary-hide-thread))
10856 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10857 (gnus-summary-position-point))
10858
10859 (defun gnus-summary-hide-thread ()
10860 "Hide thread subtrees.
10861 If PREDICATE is supplied, threads that satisfy this predicate
10862 will not be hidden.
10863 Returns nil if no threads were there to be hidden."
10864 (interactive)
10865 (let ((buffer-read-only nil)
10866 (start (point))
10867 (article (gnus-summary-article-number)))
10868 (goto-char start)
10869 ;; Go forward until either the buffer ends or the subthread
10870 ;; ends.
10871 (when (and (not (eobp))
10872 (or (zerop (gnus-summary-next-thread 1 t))
10873 (goto-char (point-max))))
10874 (prog1
10875 (if (and (> (point) start)
10876 (search-backward "\n" start t))
10877 (progn
10878 (subst-char-in-region start (point) ?\n ?\^M)
10879 (gnus-summary-goto-subject article))
10880 (goto-char start)
10881 nil)))))
10882
10883 (defun gnus-summary-go-to-next-thread (&optional previous)
10884 "Go to the same level (or less) next thread.
10885 If PREVIOUS is non-nil, go to previous thread instead.
10886 Return the article number moved to, or nil if moving was impossible."
10887 (let ((level (gnus-summary-thread-level))
10888 (way (if previous -1 1))
10889 (beg (point)))
10890 (forward-line way)
10891 (while (and (not (eobp))
10892 (< level (gnus-summary-thread-level)))
10893 (forward-line way))
10894 (if (eobp)
10895 (progn
10896 (goto-char beg)
10897 nil)
10898 (setq beg (point))
10899 (prog1
10900 (gnus-summary-article-number)
10901 (goto-char beg)))))
10902
10903 (defun gnus-summary-next-thread (n &optional silent)
10904 "Go to the same level next N'th thread.
10905 If N is negative, search backward instead.
10906 Returns the difference between N and the number of skips actually
10907 done.
10908
10909 If SILENT, don't output messages."
10910 (interactive "p")
10911 (let ((backward (< n 0))
10912 (n (abs n)))
10913 (while (and (> n 0)
10914 (gnus-summary-go-to-next-thread backward))
10915 (decf n))
10916 (unless silent
10917 (gnus-summary-position-point))
10918 (when (and (not silent) (/= 0 n))
10919 (gnus-message 7 "No more threads"))
10920 n))
10921
10922 (defun gnus-summary-prev-thread (n)
10923 "Go to the same level previous N'th thread.
10924 Returns the difference between N and the number of skips actually
10925 done."
10926 (interactive "p")
10927 (gnus-summary-next-thread (- n)))
10928
10929 (defun gnus-summary-go-down-thread ()
10930 "Go down one level in the current thread."
10931 (let ((children (gnus-summary-article-children)))
10932 (when children
10933 (gnus-summary-goto-subject (car children)))))
10934
10935 (defun gnus-summary-go-up-thread ()
10936 "Go up one level in the current thread."
10937 (let ((parent (gnus-summary-article-parent)))
10938 (when parent
10939 (gnus-summary-goto-subject parent))))
10940
10941 (defun gnus-summary-down-thread (n)
10942 "Go down thread N steps.
10943 If N is negative, go up instead.
10944 Returns the difference between N and how many steps down that were
10945 taken."
10946 (interactive "p")
10947 (let ((up (< n 0))
10948 (n (abs n)))
10949 (while (and (> n 0)
10950 (if up (gnus-summary-go-up-thread)
10951 (gnus-summary-go-down-thread)))
10952 (setq n (1- n)))
10953 (gnus-summary-position-point)
10954 (when (/= 0 n)
10955 (gnus-message 7 "Can't go further"))
10956 n))
10957
10958 (defun gnus-summary-up-thread (n)
10959 "Go up thread N steps.
10960 If N is negative, go down instead.
10961 Returns the difference between N and how many steps down that were
10962 taken."
10963 (interactive "p")
10964 (gnus-summary-down-thread (- n)))
10965
10966 (defun gnus-summary-top-thread ()
10967 "Go to the top of the thread."
10968 (interactive)
10969 (while (gnus-summary-go-up-thread))
10970 (gnus-summary-article-number))
10971
10972 (defun gnus-summary-kill-thread (&optional unmark)
10973 "Mark articles under current thread as read.
10974 If the prefix argument is positive, remove any kinds of marks.
10975 If the prefix argument is negative, tick articles instead."
10976 (interactive "P")
10977 (when unmark
10978 (setq unmark (prefix-numeric-value unmark)))
10979 (let ((articles (gnus-summary-articles-in-thread)))
10980 (save-excursion
10981 ;; Expand the thread.
10982 (gnus-summary-show-thread)
10983 ;; Mark all the articles.
10984 (while articles
10985 (gnus-summary-goto-subject (car articles))
10986 (cond ((null unmark)
10987 (gnus-summary-mark-article-as-read gnus-killed-mark))
10988 ((> unmark 0)
10989 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10990 (t
10991 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10992 (setq articles (cdr articles))))
10993 ;; Hide killed subtrees.
10994 (and (null unmark)
10995 gnus-thread-hide-killed
10996 (gnus-summary-hide-thread))
10997 ;; If marked as read, go to next unread subject.
10998 (when (null unmark)
10999 ;; Go to next unread subject.
11000 (gnus-summary-next-subject 1 t)))
11001 (gnus-set-mode-line 'summary))
11002
11003 ;; Summary sorting commands
11004
11005 (defun gnus-summary-sort-by-number (&optional reverse)
11006 "Sort the summary buffer by article number.
11007 Argument REVERSE means reverse order."
11008 (interactive "P")
11009 (gnus-summary-sort 'number reverse))
11010
11011 (defun gnus-summary-sort-by-random (&optional reverse)
11012 "Randomize the order in the summary buffer.
11013 Argument REVERSE means to randomize in reverse order."
11014 (interactive "P")
11015 (gnus-summary-sort 'random reverse))
11016
11017 (defun gnus-summary-sort-by-author (&optional reverse)
11018 "Sort the summary buffer by author name alphabetically.
11019 If `case-fold-search' is non-nil, case of letters is ignored.
11020 Argument REVERSE means reverse order."
11021 (interactive "P")
11022 (gnus-summary-sort 'author reverse))
11023
11024 (defun gnus-summary-sort-by-subject (&optional reverse)
11025 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11026 If `case-fold-search' is non-nil, case of letters is ignored.
11027 Argument REVERSE means reverse order."
11028 (interactive "P")
11029 (gnus-summary-sort 'subject reverse))
11030
11031 (defun gnus-summary-sort-by-date (&optional reverse)
11032 "Sort the summary buffer by date.
11033 Argument REVERSE means reverse order."
11034 (interactive "P")
11035 (gnus-summary-sort 'date reverse))
11036
11037 (defun gnus-summary-sort-by-score (&optional reverse)
11038 "Sort the summary buffer by score.
11039 Argument REVERSE means reverse order."
11040 (interactive "P")
11041 (gnus-summary-sort 'score reverse))
11042
11043 (defun gnus-summary-sort-by-lines (&optional reverse)
11044 "Sort the summary buffer by the number of lines.
11045 Argument REVERSE means reverse order."
11046 (interactive "P")
11047 (gnus-summary-sort 'lines reverse))
11048
11049 (defun gnus-summary-sort-by-chars (&optional reverse)
11050 "Sort the summary buffer by article length.
11051 Argument REVERSE means reverse order."
11052 (interactive "P")
11053 (gnus-summary-sort 'chars reverse))
11054
11055 (defun gnus-summary-sort-by-original (&optional reverse)
11056 "Sort the summary buffer using the default sorting method.
11057 Argument REVERSE means reverse order."
11058 (interactive "P")
11059 (let* ((buffer-read-only)
11060 (gnus-summary-prepare-hook nil))
11061 ;; We do the sorting by regenerating the threads.
11062 (gnus-summary-prepare)
11063 ;; Hide subthreads if needed.
11064 (gnus-summary-maybe-hide-threads)))
11065
11066 (defun gnus-summary-sort (predicate reverse)
11067 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11068 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11069 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11070 (gnus-thread-sort-functions
11071 (if (not reverse)
11072 thread
11073 `(lambda (t1 t2)
11074 (,thread t2 t1))))
11075 (gnus-sort-gathered-threads-function
11076 gnus-thread-sort-functions)
11077 (gnus-article-sort-functions
11078 (if (not reverse)
11079 article
11080 `(lambda (t1 t2)
11081 (,article t2 t1))))
11082 (buffer-read-only)
11083 (gnus-summary-prepare-hook nil))
11084 ;; We do the sorting by regenerating the threads.
11085 (gnus-summary-prepare)
11086 ;; Hide subthreads if needed.
11087 (gnus-summary-maybe-hide-threads)))
11088
11089 ;; Summary saving commands.
11090
11091 (defun gnus-summary-save-article (&optional n not-saved)
11092 "Save the current article using the default saver function.
11093 If N is a positive number, save the N next articles.
11094 If N is a negative number, save the N previous articles.
11095 If N is nil and any articles have been marked with the process mark,
11096 save those articles instead.
11097 The variable `gnus-default-article-saver' specifies the saver function.
11098
11099 If the optional second argument NOT-SAVED is non-nil, articles saved
11100 will not be marked as saved."
11101 (interactive "P")
11102 (require 'gnus-art)
11103 (let* ((articles (gnus-summary-work-articles n))
11104 (save-buffer (save-excursion
11105 (nnheader-set-temp-buffer " *Gnus Save*")))
11106 (num (length articles))
11107 ;; Whether to save decoded articles or raw articles.
11108 (decode (when gnus-article-save-coding-system
11109 (get gnus-default-article-saver :decode)))
11110 ;; When saving many articles in a single file, use the other
11111 ;; function to save articles other than the first one.
11112 (saver2 (get gnus-default-article-saver :function))
11113 (gnus-prompt-before-saving (if saver2
11114 t
11115 gnus-prompt-before-saving))
11116 (gnus-default-article-saver gnus-default-article-saver)
11117 header file)
11118 (dolist (article articles)
11119 (setq header (gnus-summary-article-header article))
11120 (if (not (vectorp header))
11121 ;; This is a pseudo-article.
11122 (if (assq 'name header)
11123 (gnus-copy-file (cdr (assq 'name header)))
11124 (gnus-message 1 "Article %d is unsaveable" article))
11125 ;; This is a real article.
11126 (save-window-excursion
11127 (let ((gnus-display-mime-function (when decode
11128 gnus-display-mime-function))
11129 (gnus-article-prepare-hook (when decode
11130 gnus-article-prepare-hook)))
11131 (gnus-summary-select-article t nil nil article)
11132 (gnus-summary-goto-subject article)))
11133 (save-excursion
11134 (set-buffer save-buffer)
11135 (erase-buffer)
11136 (insert-buffer-substring (if decode
11137 gnus-article-buffer
11138 gnus-original-article-buffer)))
11139 (setq file (gnus-article-save save-buffer file num))
11140 (gnus-summary-remove-process-mark article)
11141 (unless not-saved
11142 (gnus-summary-set-saved-mark article)))
11143 (when saver2
11144 (setq gnus-default-article-saver saver2
11145 saver2 nil)))
11146 (gnus-kill-buffer save-buffer)
11147 (gnus-summary-position-point)
11148 (gnus-set-mode-line 'summary)
11149 n))
11150
11151 (defun gnus-summary-pipe-output (&optional arg headers)
11152 "Pipe the current article to a subprocess.
11153 If N is a positive number, pipe the N next articles.
11154 If N is a negative number, pipe the N previous articles.
11155 If N is nil and any articles have been marked with the process mark,
11156 pipe those articles instead.
11157 If HEADERS (the symbolic prefix), include the headers, too."
11158 (interactive (gnus-interactive "P\ny"))
11159 (require 'gnus-art)
11160 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
11161 (gnus-save-all-headers (or headers gnus-save-all-headers)))
11162 (gnus-summary-save-article arg t))
11163 (let ((buffer (get-buffer "*Shell Command Output*")))
11164 (when (and buffer
11165 (not (zerop (buffer-size buffer))))
11166 (gnus-configure-windows 'pipe))))
11167
11168 (defun gnus-summary-save-article-mail (&optional arg)
11169 "Append the current article to a Unix mail box file.
11170 If N is a positive number, save the N next articles.
11171 If N is a negative number, save the N previous articles.
11172 If N is nil and any articles have been marked with the process mark,
11173 save those articles instead."
11174 (interactive "P")
11175 (require 'gnus-art)
11176 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
11177 (gnus-summary-save-article arg)))
11178
11179 (defun gnus-summary-save-article-rmail (&optional arg)
11180 "Append the current article to an rmail file.
11181 If N is a positive number, save the N next articles.
11182 If N is a negative number, save the N previous articles.
11183 If N is nil and any articles have been marked with the process mark,
11184 save those articles instead."
11185 (interactive "P")
11186 (require 'gnus-art)
11187 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
11188 (gnus-summary-save-article arg)))
11189
11190 (defun gnus-summary-save-article-file (&optional arg)
11191 "Append the current article to a file.
11192 If N is a positive number, save the N next articles.
11193 If N is a negative number, save the N previous articles.
11194 If N is nil and any articles have been marked with the process mark,
11195 save those articles instead."
11196 (interactive "P")
11197 (require 'gnus-art)
11198 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
11199 (gnus-summary-save-article arg)))
11200
11201 (defun gnus-summary-write-article-file (&optional arg)
11202 "Write the current article to a file, deleting the previous file.
11203 If N is a positive number, save the N next articles.
11204 If N is a negative number, save the N previous articles.
11205 If N is nil and any articles have been marked with the process mark,
11206 save those articles instead."
11207 (interactive "P")
11208 (require 'gnus-art)
11209 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
11210 (gnus-summary-save-article arg)))
11211
11212 (defun gnus-summary-save-article-body-file (&optional arg)
11213 "Append the current article body to a file.
11214 If N is a positive number, save the N next articles.
11215 If N is a negative number, save the N previous articles.
11216 If N is nil and any articles have been marked with the process mark,
11217 save those articles instead."
11218 (interactive "P")
11219 (require 'gnus-art)
11220 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
11221 (gnus-summary-save-article arg)))
11222
11223 (defun gnus-summary-write-article-body-file (&optional arg)
11224 "Write the current article body to a file, deleting the previous file.
11225 If N is a positive number, save the N next articles.
11226 If N is a negative number, save the N previous articles.
11227 If N is nil and any articles have been marked with the process mark,
11228 save those articles instead."
11229 (interactive "P")
11230 (require 'gnus-art)
11231 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
11232 (gnus-summary-save-article arg)))
11233
11234 (defun gnus-summary-muttprint (&optional arg)
11235 "Print the current article using Muttprint.
11236 If N is a positive number, save the N next articles.
11237 If N is a negative number, save the N previous articles.
11238 If N is nil and any articles have been marked with the process mark,
11239 save those articles instead."
11240 (interactive "P")
11241 (require 'gnus-art)
11242 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
11243 (gnus-summary-save-article arg t)))
11244
11245 (defun gnus-summary-pipe-message (program)
11246 "Pipe the current article through PROGRAM."
11247 (interactive "sProgram: ")
11248 (gnus-summary-select-article)
11249 (let ((mail-header-separator ""))
11250 (gnus-eval-in-buffer-window gnus-article-buffer
11251 (save-restriction
11252 (widen)
11253 (let ((start (window-start))
11254 buffer-read-only)
11255 (message-pipe-buffer-body program)
11256 (set-window-start (get-buffer-window (current-buffer)) start))))))
11257
11258 (defun gnus-get-split-value (methods)
11259 "Return a value based on the split METHODS."
11260 (let (split-name method result match)
11261 (when methods
11262 (save-excursion
11263 (set-buffer gnus-original-article-buffer)
11264 (save-restriction
11265 (nnheader-narrow-to-headers)
11266 (while (and methods (not split-name))
11267 (goto-char (point-min))
11268 (setq method (pop methods))
11269 (setq match (car method))
11270 (when (cond
11271 ((stringp match)
11272 ;; Regular expression.
11273 (ignore-errors
11274 (re-search-forward match nil t)))
11275 ((functionp match)
11276 ;; Function.
11277 (save-restriction
11278 (widen)
11279 (setq result (funcall match gnus-newsgroup-name))))
11280 ((consp match)
11281 ;; Form.
11282 (save-restriction
11283 (widen)
11284 (setq result (eval match)))))
11285 (setq split-name (cdr method))
11286 (cond ((stringp result)
11287 (push (expand-file-name
11288 result gnus-article-save-directory)
11289 split-name))
11290 ((consp result)
11291 (setq split-name (append result split-name)))))))))
11292 (nreverse split-name)))
11293
11294 (defun gnus-valid-move-group-p (group)
11295 (and (boundp group)
11296 (symbol-name group)
11297 (symbol-value group)
11298 (gnus-get-function (gnus-find-method-for-group
11299 (symbol-name group)) 'request-accept-article t)))
11300
11301 (defun gnus-read-move-group-name (prompt default articles prefix)
11302 "Read a group name."
11303 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11304 (minibuffer-confirm-incomplete nil) ; XEmacs
11305 (prom
11306 (format "%s %s to"
11307 prompt
11308 (if (> (length articles) 1)
11309 (format "these %d articles" (length articles))
11310 "this article")))
11311 (to-newsgroup
11312 (cond
11313 ((null split-name)
11314 (gnus-completing-read-with-default
11315 default prom
11316 gnus-active-hashtb
11317 'gnus-valid-move-group-p
11318 nil prefix
11319 'gnus-group-history))
11320 ((= 1 (length split-name))
11321 (gnus-completing-read-with-default
11322 (car split-name) prom
11323 gnus-active-hashtb
11324 'gnus-valid-move-group-p
11325 nil nil
11326 'gnus-group-history))
11327 (t
11328 (gnus-completing-read-with-default
11329 nil prom
11330 (mapcar (lambda (el) (list el))
11331 (nreverse split-name))
11332 nil nil nil
11333 'gnus-group-history))))
11334 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11335 (when to-newsgroup
11336 (if (or (string= to-newsgroup "")
11337 (string= to-newsgroup prefix))
11338 (setq to-newsgroup default))
11339 (unless to-newsgroup
11340 (error "No group name entered"))
11341 (or (gnus-active to-newsgroup)
11342 (gnus-activate-group to-newsgroup nil nil to-method)
11343 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11344 to-newsgroup))
11345 (or (and (gnus-request-create-group to-newsgroup to-method)
11346 (gnus-activate-group
11347 to-newsgroup nil nil to-method)
11348 (gnus-subscribe-group to-newsgroup))
11349 (error "Couldn't create group %s" to-newsgroup)))
11350 (error "No such group: %s" to-newsgroup)))
11351 to-newsgroup))
11352
11353 (defun gnus-summary-save-parts (type dir n &optional reverse)
11354 "Save parts matching TYPE to DIR.
11355 If REVERSE, save parts that do not match TYPE."
11356 (interactive
11357 (list (read-string "Save parts of type: "
11358 (or (car gnus-summary-save-parts-type-history)
11359 gnus-summary-save-parts-default-mime)
11360 'gnus-summary-save-parts-type-history)
11361 (setq gnus-summary-save-parts-last-directory
11362 (read-file-name "Save to directory: "
11363 gnus-summary-save-parts-last-directory
11364 nil t))
11365 current-prefix-arg))
11366 (gnus-summary-iterate n
11367 (let ((gnus-display-mime-function nil)
11368 (gnus-inhibit-treatment t))
11369 (gnus-summary-select-article))
11370 (save-excursion
11371 (set-buffer gnus-article-buffer)
11372 (let ((handles (or gnus-article-mime-handles
11373 (mm-dissect-buffer nil gnus-article-loose-mime)
11374 (and gnus-article-emulate-mime
11375 (mm-uu-dissect)))))
11376 (when handles
11377 (gnus-summary-save-parts-1 type dir handles reverse)
11378 (unless gnus-article-mime-handles ;; Don't destroy this case.
11379 (mm-destroy-parts handles)))))))
11380
11381 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11382 (if (stringp (car handle))
11383 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11384 (cdr handle))
11385 (when (if reverse
11386 (not (string-match type (mm-handle-media-type handle)))
11387 (string-match type (mm-handle-media-type handle)))
11388 (let ((file (expand-file-name
11389 (gnus-map-function
11390 mm-file-name-rewrite-functions
11391 (file-name-nondirectory
11392 (or
11393 (mail-content-type-get
11394 (mm-handle-disposition handle) 'filename)
11395 (mail-content-type-get
11396 (mm-handle-type handle) 'name)
11397 (concat gnus-newsgroup-name
11398 "." (number-to-string
11399 (cdr gnus-article-current))))))
11400 dir)))
11401 (unless (file-exists-p file)
11402 (mm-save-part-to-file handle file))))))
11403
11404 ;; Summary extract commands
11405
11406 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11407 (let ((buffer-read-only nil)
11408 (article (gnus-summary-article-number))
11409 after-article b e)
11410 (unless (gnus-summary-goto-subject article)
11411 (error "No such article: %d" article))
11412 (gnus-summary-position-point)
11413 ;; If all commands are to be bunched up on one line, we collect
11414 ;; them here.
11415 (unless gnus-view-pseudos-separately
11416 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11417 files action)
11418 (while ps
11419 (setq action (cdr (assq 'action (car ps))))
11420 (setq files (list (cdr (assq 'name (car ps)))))
11421 (while (and ps (cdr ps)
11422 (string= (or action "1")
11423 (or (cdr (assq 'action (cadr ps))) "2")))
11424 (push (cdr (assq 'name (cadr ps))) files)
11425 (setcdr ps (cddr ps)))
11426 (when files
11427 (when (not (string-match "%s" action))
11428 (push " " files))
11429 (push " " files)
11430 (when (assq 'execute (car ps))
11431 (setcdr (assq 'execute (car ps))
11432 (funcall (if (string-match "%s" action)
11433 'format 'concat)
11434 action
11435 (mapconcat
11436 (lambda (f)
11437 (if (equal f " ")
11438 f
11439 (mm-quote-arg f)))
11440 files " ")))))
11441 (setq ps (cdr ps)))))
11442 (if (and gnus-view-pseudos (not not-view))
11443 (while pslist
11444 (when (assq 'execute (car pslist))
11445 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11446 (eq gnus-view-pseudos 'not-confirm)))
11447 (setq pslist (cdr pslist)))
11448 (save-excursion
11449 (while pslist
11450 (setq after-article (or (cdr (assq 'article (car pslist)))
11451 (gnus-summary-article-number)))
11452 (gnus-summary-goto-subject after-article)
11453 (forward-line 1)
11454 (setq b (point))
11455 (insert " " (file-name-nondirectory
11456 (cdr (assq 'name (car pslist))))
11457 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11458 (setq e (point))
11459 (forward-line -1) ; back to `b'
11460 (gnus-add-text-properties
11461 b (1- e) (list 'gnus-number gnus-reffed-article-number
11462 gnus-mouse-face-prop gnus-mouse-face))
11463 (gnus-data-enter
11464 after-article gnus-reffed-article-number
11465 gnus-unread-mark b (car pslist) 0 (- e b))
11466 (setq gnus-newsgroup-unreads
11467 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11468 gnus-reffed-article-number))
11469 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11470 (setq pslist (cdr pslist)))))))
11471
11472 (defun gnus-pseudos< (p1 p2)
11473 (let ((c1 (cdr (assq 'action p1)))
11474 (c2 (cdr (assq 'action p2))))
11475 (and c1 c2 (string< c1 c2))))
11476
11477 (defun gnus-request-pseudo-article (props)
11478 (cond ((assq 'execute props)
11479 (gnus-execute-command (cdr (assq 'execute props)))))
11480 (let ((gnus-current-article (gnus-summary-article-number)))
11481 (gnus-run-hooks 'gnus-mark-article-hook)))
11482
11483 (defun gnus-execute-command (command &optional automatic)
11484 (save-excursion
11485 (gnus-article-setup-buffer)
11486 (set-buffer gnus-article-buffer)
11487 (setq buffer-read-only nil)
11488 (let ((command (if automatic command
11489 (read-string "Command: " (cons command 0)))))
11490 (erase-buffer)
11491 (insert "$ " command "\n\n")
11492 (if gnus-view-pseudo-asynchronously
11493 (start-process "gnus-execute" (current-buffer) shell-file-name
11494 shell-command-switch command)
11495 (call-process shell-file-name nil t nil
11496 shell-command-switch command)))))
11497
11498 ;; Summary kill commands.
11499
11500 (defun gnus-summary-edit-global-kill (article)
11501 "Edit the \"global\" kill file."
11502 (interactive (list (gnus-summary-article-number)))
11503 (gnus-group-edit-global-kill article))
11504
11505 (defun gnus-summary-edit-local-kill ()
11506 "Edit a local kill file applied to the current newsgroup."
11507 (interactive)
11508 (setq gnus-current-headers (gnus-summary-article-header))
11509 (gnus-group-edit-local-kill
11510 (gnus-summary-article-number) gnus-newsgroup-name))
11511
11512 ;;; Header reading.
11513
11514 (defun gnus-read-header (id &optional header)
11515 "Read the headers of article ID and enter them into the Gnus system."
11516 (let ((group gnus-newsgroup-name)
11517 (gnus-override-method
11518 (or
11519 gnus-override-method
11520 (and (gnus-news-group-p gnus-newsgroup-name)
11521 (car (gnus-refer-article-methods)))))
11522 where)
11523 ;; First we check to see whether the header in question is already
11524 ;; fetched.
11525 (if (stringp id)
11526 ;; This is a Message-ID.
11527 (setq header (or header (gnus-id-to-header id)))
11528 ;; This is an article number.
11529 (setq header (or header (gnus-summary-article-header id))))
11530 (if (and header
11531 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11532 ;; We have found the header.
11533 header
11534 ;; We have to really fetch the header to this article.
11535 (save-excursion
11536 (set-buffer nntp-server-buffer)
11537 (when (setq where (gnus-request-head id group))
11538 (nnheader-fold-continuation-lines)
11539 (goto-char (point-max))
11540 (insert ".\n")
11541 (goto-char (point-min))
11542 (insert "211 ")
11543 (princ (cond
11544 ((numberp id) id)
11545 ((cdr where) (cdr where))
11546 (header (mail-header-number header))
11547 (t gnus-reffed-article-number))
11548 (current-buffer))
11549 (insert " Article retrieved.\n"))
11550 (if (or (not where)
11551 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11552 () ; Malformed head.
11553 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11554 (when (and (stringp id)
11555 (not (string= (gnus-group-real-name group)
11556 (car where))))
11557 ;; If we fetched by Message-ID and the article came
11558 ;; from a different group, we fudge some bogus article
11559 ;; numbers for this article.
11560 (mail-header-set-number header gnus-reffed-article-number))
11561 (save-excursion
11562 (set-buffer gnus-summary-buffer)
11563 (decf gnus-reffed-article-number)
11564 (gnus-remove-header (mail-header-number header))
11565 (push header gnus-newsgroup-headers)
11566 (setq gnus-current-headers header)
11567 (push (mail-header-number header) gnus-newsgroup-limit)))
11568 header)))))
11569
11570 (defun gnus-remove-header (number)
11571 "Remove header NUMBER from `gnus-newsgroup-headers'."
11572 (if (and gnus-newsgroup-headers
11573 (= number (mail-header-number (car gnus-newsgroup-headers))))
11574 (pop gnus-newsgroup-headers)
11575 (let ((headers gnus-newsgroup-headers))
11576 (while (and (cdr headers)
11577 (not (= number (mail-header-number (cadr headers)))))
11578 (pop headers))
11579 (when (cdr headers)
11580 (setcdr headers (cddr headers))))))
11581
11582 ;;;
11583 ;;; summary highlights
11584 ;;;
11585
11586 (defun gnus-highlight-selected-summary ()
11587 "Highlight selected article in summary buffer."
11588 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11589 (when gnus-summary-selected-face
11590 (save-excursion
11591 (let* ((beg (gnus-point-at-bol))
11592 (end (gnus-point-at-eol))
11593 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11594 (from (if (get-text-property beg gnus-mouse-face-prop)
11595 beg
11596 (or (next-single-property-change
11597 beg gnus-mouse-face-prop nil end)
11598 beg)))
11599 (to
11600 (if (= from end)
11601 (- from 2)
11602 (or (next-single-property-change
11603 from gnus-mouse-face-prop nil end)
11604 end))))
11605 ;; If no mouse-face prop on line we will have to = from = end,
11606 ;; so we highlight the entire line instead.
11607 (when (= (+ to 2) from)
11608 (setq from beg)
11609 (setq to end))
11610 (if gnus-newsgroup-selected-overlay
11611 ;; Move old overlay.
11612 (gnus-move-overlay
11613 gnus-newsgroup-selected-overlay from to (current-buffer))
11614 ;; Create new overlay.
11615 (gnus-overlay-put
11616 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11617 'face gnus-summary-selected-face))))))
11618
11619 (defvar gnus-summary-highlight-line-cached nil)
11620 (defvar gnus-summary-highlight-line-trigger nil)
11621
11622 (defun gnus-summary-highlight-line-0 ()
11623 (if (and (eq gnus-summary-highlight-line-trigger
11624 gnus-summary-highlight)
11625 gnus-summary-highlight-line-cached)
11626 gnus-summary-highlight-line-cached
11627 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11628 gnus-summary-highlight-line-cached
11629 (let* ((cond (list 'cond))
11630 (c cond)
11631 (list gnus-summary-highlight))
11632 (while list
11633 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11634 nil))
11635 (setq c (cdr c)
11636 list (cdr list)))
11637 (gnus-byte-compile (list 'lambda nil cond))))))
11638
11639 (defun gnus-summary-highlight-line ()
11640 "Highlight current line according to `gnus-summary-highlight'."
11641 (let* ((beg (gnus-point-at-bol))
11642 (article (or (gnus-summary-article-number) gnus-current-article))
11643 (score (or (cdr (assq article
11644 gnus-newsgroup-scored))
11645 gnus-summary-default-score 0))
11646 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11647 (inhibit-read-only t)
11648 (default gnus-summary-default-score)
11649 (default-high gnus-summary-default-high-score)
11650 (default-low gnus-summary-default-low-score)
11651 (uncached (and gnus-summary-use-undownloaded-faces
11652 (memq article gnus-newsgroup-undownloaded)
11653 (not (memq article gnus-newsgroup-cached)))))
11654 (let ((face (funcall (gnus-summary-highlight-line-0))))
11655 (unless (eq face (get-text-property beg 'face))
11656 (gnus-put-text-property-excluding-characters-with-faces
11657 beg (gnus-point-at-eol) 'face
11658 (setq face (if (boundp face) (symbol-value face) face)))
11659 (when gnus-summary-highlight-line-function
11660 (funcall gnus-summary-highlight-line-function article face))))))
11661
11662 (defun gnus-update-read-articles (group unread &optional compute)
11663 "Update the list of read articles in GROUP.
11664 UNREAD is a sorted list."
11665 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11666 (entry (gnus-gethash group gnus-newsrc-hashtb))
11667 (info (nth 2 entry))
11668 (prev 1)
11669 read)
11670 (if (or (not info) (not active))
11671 ;; There is no info on this group if it was, in fact,
11672 ;; killed. Gnus stores no information on killed groups, so
11673 ;; there's nothing to be done.
11674 ;; One could store the information somewhere temporarily,
11675 ;; perhaps... Hmmm...
11676 ()
11677 ;; Remove any negative articles numbers.
11678 (while (and unread (< (car unread) 0))
11679 (setq unread (cdr unread)))
11680 ;; Remove any expired article numbers
11681 (while (and unread (< (car unread) (car active)))
11682 (setq unread (cdr unread)))
11683 ;; Compute the ranges of read articles by looking at the list of
11684 ;; unread articles.
11685 (while unread
11686 (when (/= (car unread) prev)
11687 (push (if (= prev (1- (car unread))) prev
11688 (cons prev (1- (car unread))))
11689 read))
11690 (setq prev (1+ (car unread)))
11691 (setq unread (cdr unread)))
11692 (when (<= prev (cdr active))
11693 (push (cons prev (cdr active)) read))
11694 (setq read (if (> (length read) 1) (nreverse read) read))
11695 (if compute
11696 read
11697 (save-excursion
11698 (let (setmarkundo)
11699 ;; Propagate the read marks to the backend.
11700 (when (gnus-check-backend-function 'request-set-mark group)
11701 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11702 (add (gnus-remove-from-range read (gnus-info-read info))))
11703 (when (or add del)
11704 (unless (gnus-check-group group)
11705 (error "Can't open server for %s" group))
11706 (gnus-request-set-mark
11707 group (delq nil (list (if add (list add 'add '(read)))
11708 (if del (list del 'del '(read))))))
11709 (setq setmarkundo
11710 `(gnus-request-set-mark
11711 ,group
11712 ',(delq nil (list
11713 (if del (list del 'add '(read)))
11714 (if add (list add 'del '(read))))))))))
11715 (set-buffer gnus-group-buffer)
11716 (gnus-undo-register
11717 `(progn
11718 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11719 (gnus-info-set-read ',info ',(gnus-info-read info))
11720 (gnus-get-unread-articles-in-group ',info
11721 (gnus-active ,group))
11722 (gnus-group-update-group ,group t)
11723 ,setmarkundo))))
11724 ;; Enter this list into the group info.
11725 (gnus-info-set-read info read)
11726 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11727 (gnus-get-unread-articles-in-group info (gnus-active group))
11728 t))))
11729
11730 (defun gnus-offer-save-summaries ()
11731 "Offer to save all active summary buffers."
11732 (let (buffers)
11733 ;; Go through all buffers and find all summaries.
11734 (dolist (buffer (buffer-list))
11735 (when (and (setq buffer (buffer-name buffer))
11736 (string-match "Summary" buffer)
11737 (save-excursion
11738 (set-buffer buffer)
11739 ;; We check that this is, indeed, a summary buffer.
11740 (and (eq major-mode 'gnus-summary-mode)
11741 ;; Also make sure this isn't bogus.
11742 gnus-newsgroup-prepared
11743 ;; Also make sure that this isn't a
11744 ;; dead summary buffer.
11745 (not gnus-dead-summary-mode))))
11746 (push buffer buffers)))
11747 ;; Go through all these summary buffers and offer to save them.
11748 (when buffers
11749 (save-excursion
11750 (map-y-or-n-p
11751 "Update summary buffer %s? "
11752 (lambda (buf)
11753 (switch-to-buffer buf)
11754 (gnus-summary-exit))
11755 buffers)))))
11756
11757 (defun gnus-summary-setup-default-charset ()
11758 "Setup newsgroup default charset."
11759 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11760 (setq gnus-newsgroup-charset nil)
11761 (let* ((ignored-charsets
11762 (or gnus-newsgroup-ephemeral-ignored-charsets
11763 (append
11764 (and gnus-newsgroup-name
11765 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11766 gnus-newsgroup-ignored-charsets))))
11767 (setq gnus-newsgroup-charset
11768 (or gnus-newsgroup-ephemeral-charset
11769 (and gnus-newsgroup-name
11770 (gnus-parameter-charset gnus-newsgroup-name))
11771 gnus-default-charset))
11772 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11773 ignored-charsets))))
11774
11775 ;;;
11776 ;;; Mime Commands
11777 ;;;
11778
11779 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11780 "Display the current article buffer fully MIME-buttonized.
11781 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11782 treated as multipart/mixed."
11783 (interactive "P")
11784 (require 'gnus-art)
11785 (let ((gnus-unbuttonized-mime-types nil)
11786 (gnus-mime-display-multipart-as-mixed show-all-parts))
11787 (gnus-summary-show-article)))
11788
11789 (defun gnus-summary-repair-multipart (article)
11790 "Add a Content-Type header to a multipart article without one."
11791 (interactive (list (gnus-summary-article-number)))
11792 (gnus-with-article article
11793 (message-narrow-to-head)
11794 (message-remove-header "Mime-Version")
11795 (goto-char (point-max))
11796 (insert "Mime-Version: 1.0\n")
11797 (widen)
11798 (when (search-forward "\n--" nil t)
11799 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11800 (message-narrow-to-head)
11801 (message-remove-header "Content-Type")
11802 (goto-char (point-max))
11803 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11804 separator))
11805 (widen))))
11806 (let (gnus-mark-article-hook)
11807 (gnus-summary-select-article t t nil article)))
11808
11809 (defun gnus-summary-toggle-display-buttonized ()
11810 "Toggle the buttonizing of the article buffer."
11811 (interactive)
11812 (require 'gnus-art)
11813 (if (setq gnus-inhibit-mime-unbuttonizing
11814 (not gnus-inhibit-mime-unbuttonizing))
11815 (let ((gnus-unbuttonized-mime-types nil))
11816 (gnus-summary-show-article))
11817 (gnus-summary-show-article)))
11818
11819 ;;;
11820 ;;; Generic summary marking commands
11821 ;;;
11822
11823 (defvar gnus-summary-marking-alist
11824 '((read gnus-del-mark "d")
11825 (unread gnus-unread-mark "u")
11826 (ticked gnus-ticked-mark "!")
11827 (dormant gnus-dormant-mark "?")
11828 (expirable gnus-expirable-mark "e"))
11829 "An alist of names/marks/keystrokes.")
11830
11831 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11832 (defvar gnus-summary-mark-map)
11833
11834 (defun gnus-summary-make-all-marking-commands ()
11835 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11836 (dolist (elem gnus-summary-marking-alist)
11837 (apply 'gnus-summary-make-marking-command elem)))
11838
11839 (defun gnus-summary-make-marking-command (name mark keystroke)
11840 (let ((map (make-sparse-keymap)))
11841 (define-key gnus-summary-generic-mark-map keystroke map)
11842 (dolist (lway `((next "next" next nil "n")
11843 (next-unread "next unread" next t "N")
11844 (prev "previous" prev nil "p")
11845 (prev-unread "previous unread" prev t "P")
11846 (nomove "" nil nil ,keystroke)))
11847 (let ((func (gnus-summary-make-marking-command-1
11848 mark (car lway) lway name)))
11849 (setq func (eval func))
11850 (define-key map (nth 4 lway) func)))))
11851
11852 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11853 `(defun ,(intern
11854 (format "gnus-summary-put-mark-as-%s%s"
11855 name (if (eq way 'nomove)
11856 ""
11857 (concat "-" (symbol-name way)))))
11858 (n)
11859 ,(format
11860 "Mark the current article as %s%s.
11861 If N, the prefix, then repeat N times.
11862 If N is negative, move in reverse order.
11863 The difference between N and the actual number of articles marked is
11864 returned."
11865 name (cadr lway))
11866 (interactive "p")
11867 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11868
11869 (defun gnus-summary-generic-mark (n mark move unread)
11870 "Mark N articles with MARK."
11871 (unless (eq major-mode 'gnus-summary-mode)
11872 (error "This command can only be used in the summary buffer"))
11873 (gnus-summary-show-thread)
11874 (let ((nummove
11875 (cond
11876 ((eq move 'next) 1)
11877 ((eq move 'prev) -1)
11878 (t 0))))
11879 (if (zerop nummove)
11880 (setq n 1)
11881 (when (< n 0)
11882 (setq n (abs n)
11883 nummove (* -1 nummove))))
11884 (while (and (> n 0)
11885 (gnus-summary-mark-article nil mark)
11886 (zerop (gnus-summary-next-subject nummove unread t)))
11887 (setq n (1- n)))
11888 (when (/= 0 n)
11889 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11890 (gnus-summary-recenter)
11891 (gnus-summary-position-point)
11892 (gnus-set-mode-line 'summary)
11893 n))
11894
11895 (defun gnus-summary-insert-articles (articles)
11896 (when (setq articles
11897 (gnus-sorted-difference articles
11898 (mapcar (lambda (h)
11899 (mail-header-number h))
11900 gnus-newsgroup-headers)))
11901 (setq gnus-newsgroup-headers
11902 (gnus-merge 'list
11903 gnus-newsgroup-headers
11904 (gnus-fetch-headers articles)
11905 'gnus-article-sort-by-number))
11906 ;; Suppress duplicates?
11907 (when gnus-suppress-duplicates
11908 (gnus-dup-suppress-articles))
11909
11910 ;; We might want to build some more threads first.
11911 (when (and gnus-fetch-old-headers
11912 (eq gnus-headers-retrieved-by 'nov))
11913 (if (eq gnus-fetch-old-headers 'invisible)
11914 (gnus-build-all-threads)
11915 (gnus-build-old-threads)))
11916 ;; Let the Gnus agent mark articles as read.
11917 (when gnus-agent
11918 (gnus-agent-get-undownloaded-list))
11919 ;; Remove list identifiers from subject
11920 (when gnus-list-identifiers
11921 (gnus-summary-remove-list-identifiers))
11922 ;; First and last article in this newsgroup.
11923 (when gnus-newsgroup-headers
11924 (setq gnus-newsgroup-begin
11925 (mail-header-number (car gnus-newsgroup-headers))
11926 gnus-newsgroup-end
11927 (mail-header-number
11928 (gnus-last-element gnus-newsgroup-headers))))
11929 (when gnus-use-scoring
11930 (gnus-possibly-score-headers))))
11931
11932 (defun gnus-summary-insert-old-articles (&optional all)
11933 "Insert all old articles in this group.
11934 If ALL is non-nil, already read articles become readable.
11935 If ALL is a number, fetch this number of articles."
11936 (interactive "P")
11937 (prog1
11938 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11939 older len)
11940 (setq older
11941 ;; Some nntp servers lie about their active range. When
11942 ;; this happens, the active range can be in the millions.
11943 ;; Use a compressed range to avoid creating a huge list.
11944 (gnus-range-difference (list gnus-newsgroup-active) old))
11945 (setq len (gnus-range-length older))
11946 (cond
11947 ((null older) nil)
11948 ((numberp all)
11949 (if (< all len)
11950 (let ((older-range (nreverse older)))
11951 (setq older nil)
11952
11953 (while (> all 0)
11954 (let* ((r (pop older-range))
11955 (min (if (numberp r) r (car r)))
11956 (max (if (numberp r) r (cdr r))))
11957 (while (and (<= min max)
11958 (> all 0))
11959 (push max older)
11960 (setq all (1- all)
11961 max (1- max))))))
11962 (setq older (gnus-uncompress-range older))))
11963 (all
11964 (setq older (gnus-uncompress-range older)))
11965 (t
11966 (when (and (numberp gnus-large-newsgroup)
11967 (> len gnus-large-newsgroup))
11968 (let* ((cursor-in-echo-area nil)
11969 (initial (gnus-parameter-large-newsgroup-initial
11970 gnus-newsgroup-name))
11971 (input
11972 (read-string
11973 (format
11974 "How many articles from %s (%s %d): "
11975 (gnus-limit-string
11976 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11977 (if initial "max" "default")
11978 len)
11979 (if initial
11980 (cons (number-to-string initial)
11981 0)))))
11982 (unless (string-match "^[ \t]*$" input)
11983 (setq all (string-to-number input))
11984 (if (< all len)
11985 (let ((older-range (nreverse older)))
11986 (setq older nil)
11987
11988 (while (> all 0)
11989 (let* ((r (pop older-range))
11990 (min (if (numberp r) r (car r)))
11991 (max (if (numberp r) r (cdr r))))
11992 (while (and (<= min max)
11993 (> all 0))
11994 (push max older)
11995 (setq all (1- all)
11996 max (1- max))))))))))
11997 (setq older (gnus-uncompress-range older))))
11998 (if (not older)
11999 (message "No old news.")
12000 (gnus-summary-insert-articles older)
12001 (gnus-summary-limit (gnus-sorted-nunion old older))))
12002 (gnus-summary-position-point)))
12003
12004 (defun gnus-summary-insert-new-articles ()
12005 "Insert all new articles in this group."
12006 (interactive)
12007 (prog1
12008 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12009 (old-active gnus-newsgroup-active)
12010 (nnmail-fetched-sources (list t))
12011 i new)
12012 (setq gnus-newsgroup-active
12013 (gnus-activate-group gnus-newsgroup-name 'scan))
12014 (setq i (cdr gnus-newsgroup-active))
12015 (while (> i (cdr old-active))
12016 (push i new)
12017 (decf i))
12018 (if (not new)
12019 (message "No gnus is bad news.")
12020 (gnus-summary-insert-articles new)
12021 (setq gnus-newsgroup-unreads
12022 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12023 (gnus-summary-limit (gnus-sorted-nunion old new))))
12024 (gnus-summary-position-point)))
12025
12026 (gnus-summary-make-all-marking-commands)
12027
12028 (gnus-ems-redefine)
12029
12030 (provide 'gnus-sum)
12031
12032 (run-hooks 'gnus-sum-load-hook)
12033
12034 ;; Local Variables:
12035 ;; coding: iso-8859-1
12036 ;; End:
12037
12038 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
12039 ;;; gnus-sum.el ends here