]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
*** empty log message ***
[gnu-emacs] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
5
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news
8
9 ;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile
31 (require 'cl)
32 (defvar tool-bar-map))
33
34 (require 'gnus)
35 (require 'gnus-group)
36 (require 'gnus-spec)
37 (require 'gnus-range)
38 (require 'gnus-int)
39 (require 'gnus-undo)
40 (require 'gnus-util)
41 (require 'mm-decode)
42 (require 'nnoo)
43
44 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
45 (autoload 'gnus-cache-write-active "gnus-cache")
46 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
47 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
48 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
49 (autoload 'mm-uu-dissect "mm-uu")
50 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
51 "Deuglify broken Outlook (Express) articles and redisplay."
52 t)
53 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
54 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
55 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
56
57 (defcustom gnus-kill-summary-on-exit t
58 "*If non-nil, kill the summary buffer when you exit from it.
59 If nil, the summary will become a \"*Dead Summary*\" buffer, and
60 it will be killed sometime later."
61 :group 'gnus-summary-exit
62 :type 'boolean)
63
64 (defcustom gnus-fetch-old-headers nil
65 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
66 If an unread article in the group refers to an older, already read (or
67 just marked as read) article, the old article will not normally be
68 displayed in the Summary buffer. If this variable is t, Gnus
69 will attempt to grab the headers to the old articles, and thereby
70 build complete threads. If it has the value `some', only enough
71 headers to connect otherwise loose threads will be displayed. This
72 variable can also be a number. In that case, no more than that number
73 of old headers will be fetched. If it has the value `invisible', all
74 old headers will be fetched, but none will be displayed.
75
76 The server has to support NOV for any of this to work."
77 :group 'gnus-thread
78 :type '(choice (const :tag "off" nil)
79 (const :tag "on" t)
80 (const some)
81 (const invisible)
82 number
83 (sexp :menu-tag "other" t)))
84
85 (defcustom gnus-refer-thread-limit 200
86 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
87 If t, fetch all the available old headers."
88 :group 'gnus-thread
89 :type '(choice number
90 (sexp :menu-tag "other" t)))
91
92 (defcustom gnus-summary-make-false-root 'adopt
93 "*nil means that Gnus won't gather loose threads.
94 If the root of a thread has expired or been read in a previous
95 session, the information necessary to build a complete thread has been
96 lost. Instead of having many small sub-threads from this original thread
97 scattered all over the summary buffer, Gnus can gather them.
98
99 If non-nil, Gnus will try to gather all loose sub-threads from an
100 original thread into one large thread.
101
102 If this variable is non-nil, it should be one of `none', `adopt',
103 `dummy' or `empty'.
104
105 If this variable is `none', Gnus will not make a false root, but just
106 present the sub-threads after another.
107 If this variable is `dummy', Gnus will create a dummy root that will
108 have all the sub-threads as children.
109 If this variable is `adopt', Gnus will make one of the \"children\"
110 the parent and mark all the step-children as such.
111 If this variable is `empty', the \"children\" are printed with empty
112 subject fields. (Or rather, they will be printed with a string
113 given by the `gnus-summary-same-subject' variable.)"
114 :group 'gnus-thread
115 :type '(choice (const :tag "off" nil)
116 (const none)
117 (const dummy)
118 (const adopt)
119 (const empty)))
120
121 (defcustom gnus-summary-make-false-root-always nil
122 "Always make a false dummy root."
123 :version "22.1"
124 :group 'gnus-thread
125 :type 'boolean)
126
127 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
128 "*A regexp to match subjects to be excluded from loose thread gathering.
129 As loose thread gathering is done on subjects only, that means that
130 there can be many false gatherings performed. By rooting out certain
131 common subjects, gathering might become saner."
132 :group 'gnus-thread
133 :type 'regexp)
134
135 (defcustom gnus-summary-gather-subject-limit nil
136 "*Maximum length of subject comparisons when gathering loose threads.
137 Use nil to compare full subjects. Setting this variable to a low
138 number will help gather threads that have been corrupted by
139 newsreaders chopping off subject lines, but it might also mean that
140 unrelated articles that have subject that happen to begin with the
141 same few characters will be incorrectly gathered.
142
143 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
144 comparing subjects."
145 :group 'gnus-thread
146 :type '(choice (const :tag "off" nil)
147 (const fuzzy)
148 (sexp :menu-tag "on" t)))
149
150 (defcustom gnus-simplify-subject-functions nil
151 "List of functions taking a string argument that simplify subjects.
152 The functions are applied recursively.
153
154 Useful functions to put in this list include:
155 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
156 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
157 :group 'gnus-thread
158 :type '(repeat function))
159
160 (defcustom gnus-simplify-ignored-prefixes nil
161 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
162 :group 'gnus-thread
163 :type '(choice (const :tag "off" nil)
164 regexp))
165
166 (defcustom gnus-build-sparse-threads nil
167 "*If non-nil, fill in the gaps in threads.
168 If `some', only fill in the gaps that are needed to tie loose threads
169 together. If `more', fill in all leaf nodes that Gnus can find. If
170 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
171 :group 'gnus-thread
172 :type '(choice (const :tag "off" nil)
173 (const some)
174 (const more)
175 (sexp :menu-tag "all" t)))
176
177 (defcustom gnus-summary-thread-gathering-function
178 'gnus-gather-threads-by-subject
179 "*Function used for gathering loose threads.
180 There are two pre-defined functions: `gnus-gather-threads-by-subject',
181 which only takes Subjects into consideration; and
182 `gnus-gather-threads-by-references', which compared the References
183 headers of the articles to find matches."
184 :group 'gnus-thread
185 :type '(radio (function-item gnus-gather-threads-by-subject)
186 (function-item gnus-gather-threads-by-references)
187 (function :tag "other")))
188
189 (defcustom gnus-summary-same-subject ""
190 "*String indicating that the current article has the same subject as the previous.
191 This variable will only be used if the value of
192 `gnus-summary-make-false-root' is `empty'."
193 :group 'gnus-summary-format
194 :type 'string)
195
196 (defcustom gnus-summary-goto-unread t
197 "*If t, many commands will go to the next unread article.
198 This applies to marking commands as well as other commands that
199 \"naturally\" select the next article, like, for instance, `SPC' at
200 the end of an article.
201
202 If nil, the marking commands do NOT go to the next unread article
203 \(they go to the next article instead). If `never', commands that
204 usually go to the next unread article, will go to the next article,
205 whether it is read or not."
206 :group 'gnus-summary-marks
207 :link '(custom-manual "(gnus)Setting Marks")
208 :type '(choice (const :tag "off" nil)
209 (const never)
210 (sexp :menu-tag "on" t)))
211
212 (defcustom gnus-summary-default-score 0
213 "*Default article score level.
214 All scores generated by the score files will be added to this score.
215 If this variable is nil, scoring will be disabled."
216 :group 'gnus-score-default
217 :type '(choice (const :tag "disable")
218 integer))
219
220 (defcustom gnus-summary-default-high-score 0
221 "*Default threshold for a high scored article.
222 An article will be highlighted as high scored if its score is greater
223 than this score."
224 :version "22.1"
225 :group 'gnus-score-default
226 :type 'integer)
227
228 (defcustom gnus-summary-default-low-score 0
229 "*Default threshold for a low scored article.
230 An article will be highlighted as low scored if its score is smaller
231 than this score."
232 :version "22.1"
233 :group 'gnus-score-default
234 :type 'integer)
235
236 (defcustom gnus-summary-zcore-fuzz 0
237 "*Fuzziness factor for the zcore in the summary buffer.
238 Articles with scores closer than this to `gnus-summary-default-score'
239 will not be marked."
240 :group 'gnus-summary-format
241 :type 'integer)
242
243 (defcustom gnus-simplify-subject-fuzzy-regexp nil
244 "*Strings to be removed when doing fuzzy matches.
245 This can either be a regular expression or list of regular expressions
246 that will be removed from subject strings if fuzzy subject
247 simplification is selected."
248 :group 'gnus-thread
249 :type '(repeat regexp))
250
251 (defcustom gnus-show-threads t
252 "*If non-nil, display threads in summary mode."
253 :group 'gnus-thread
254 :type 'boolean)
255
256 (defcustom gnus-thread-hide-subtree nil
257 "*If non-nil, hide all threads initially.
258 This can be a predicate specifier which says which threads to hide.
259 If threads are hidden, you have to run the command
260 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
261 to expose hidden threads."
262 :group 'gnus-thread
263 :type '(radio (sexp :format "Non-nil\n"
264 :match (lambda (widget value)
265 (not (or (consp value) (functionp value))))
266 :value t)
267 (const nil)
268 (sexp :tag "Predicate specifier")))
269
270 (defcustom gnus-thread-hide-killed t
271 "*If non-nil, hide killed threads automatically."
272 :group 'gnus-thread
273 :type 'boolean)
274
275 (defcustom gnus-thread-ignore-subject t
276 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
277 If nil, articles that have different subjects from their parents will
278 start separate threads."
279 :group 'gnus-thread
280 :type 'boolean)
281
282 (defcustom gnus-thread-operation-ignore-subject t
283 "*If non-nil, subjects will be ignored when doing thread commands.
284 This affects commands like `gnus-summary-kill-thread' and
285 `gnus-summary-lower-thread'.
286
287 If this variable is nil, articles in the same thread with different
288 subjects will not be included in the operation in question. If this
289 variable is `fuzzy', only articles that have subjects that are fuzzily
290 equal will be included."
291 :group 'gnus-thread
292 :type '(choice (const :tag "off" nil)
293 (const fuzzy)
294 (sexp :tag "on" t)))
295
296 (defcustom gnus-thread-indent-level 4
297 "*Number that says how much each sub-thread should be indented."
298 :group 'gnus-thread
299 :type 'integer)
300
301 (defcustom gnus-auto-extend-newsgroup t
302 "*If non-nil, extend newsgroup forward and backward when requested."
303 :group 'gnus-summary-choose
304 :type 'boolean)
305
306 (defcustom gnus-auto-select-first t
307 "*If non-nil, select the article under point.
308 Which article this is is controlled by the `gnus-auto-select-subject'
309 variable.
310
311 If you want to prevent automatic selection of articles in some
312 newsgroups, set the variable to nil in `gnus-select-group-hook'."
313 :group 'gnus-group-select
314 :type '(choice (const :tag "none" nil)
315 (sexp :menu-tag "first" t)))
316
317 (defcustom gnus-auto-select-subject 'unread
318 "*Says what subject to place under point when entering a group.
319
320 This variable can either be the symbols `first' (place point on the
321 first subject), `unread' (place point on the subject line of the first
322 unread article), `best' (place point on the subject line of the
323 higest-scored article), `unseen' (place point on the subject line of
324 the first unseen article), `unseen-or-unread' (place point on the subject
325 line of the first unseen article or, if all article have been seen, on the
326 subject line of the first unread article), or a function to be called to
327 place point on some subject line."
328 :version "22.1"
329 :group 'gnus-group-select
330 :type '(choice (const best)
331 (const unread)
332 (const first)
333 (const unseen)
334 (const unseen-or-unread)))
335
336 (defcustom gnus-auto-select-next t
337 "*If non-nil, offer to go to the next group from the end of the previous.
338 If the value is t and the next newsgroup is empty, Gnus will exit
339 summary mode and go back to group mode. If the value is neither nil
340 nor t, Gnus will select the following unread newsgroup. In
341 particular, if the value is the symbol `quietly', the next unread
342 newsgroup will be selected without any confirmation, and if it is
343 `almost-quietly', the next group will be selected without any
344 confirmation if you are located on the last article in the group.
345 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
346 will go to the next group without confirmation."
347 :group 'gnus-summary-maneuvering
348 :type '(choice (const :tag "off" nil)
349 (const quietly)
350 (const almost-quietly)
351 (const slightly-quietly)
352 (sexp :menu-tag "on" t)))
353
354 (defcustom gnus-auto-select-same nil
355 "*If non-nil, select the next article with the same subject.
356 If there are no more articles with the same subject, go to
357 the first unread article."
358 :group 'gnus-summary-maneuvering
359 :type 'boolean)
360
361 (defcustom gnus-auto-goto-ignores 'unfetched
362 "*Says how to handle unfetched articles when maneuvering.
363
364 This variable can either be the symbols nil (maneuver to any
365 article), `undownloaded' (maneuvering while unplugged ignores articles
366 that have not been fetched), `always-undownloaded' (maneuvering always
367 ignores articles that have not been fetched), `unfetched' (maneuvering
368 ignores articles whose headers have not been fetched).
369
370 NOTE: The list of unfetched articles will always be nil when plugged
371 and, when unplugged, a subset of the undownloaded article list."
372 :version "22.1"
373 :group 'gnus-summary-maneuvering
374 :type '(choice (const :tag "None" nil)
375 (const :tag "Undownloaded when unplugged" undownloaded)
376 (const :tag "Undownloaded" always-undownloaded)
377 (const :tag "Unfetched" unfetched)))
378
379 (defcustom gnus-summary-check-current nil
380 "*If non-nil, consider the current article when moving.
381 The \"unread\" movement commands will stay on the same line if the
382 current article is unread."
383 :group 'gnus-summary-maneuvering
384 :type 'boolean)
385
386 (defcustom gnus-auto-center-summary t
387 "*If non-nil, always center the current summary buffer.
388 In particular, if `vertical' do only vertical recentering. If non-nil
389 and non-`vertical', do both horizontal and vertical recentering."
390 :group 'gnus-summary-maneuvering
391 :type '(choice (const :tag "none" nil)
392 (const vertical)
393 (integer :tag "height")
394 (sexp :menu-tag "both" t)))
395
396 (defvar gnus-auto-center-group t
397 "*If non-nil, always center the group buffer.")
398
399 (defcustom gnus-show-all-headers nil
400 "*If non-nil, don't hide any headers."
401 :group 'gnus-article-hiding
402 :group 'gnus-article-headers
403 :type 'boolean)
404
405 (defcustom gnus-summary-ignore-duplicates nil
406 "*If non-nil, ignore articles with identical Message-ID headers."
407 :group 'gnus-summary
408 :type 'boolean)
409
410 (defcustom gnus-single-article-buffer t
411 "*If non-nil, display all articles in the same buffer.
412 If nil, each group will get its own article buffer."
413 :group 'gnus-article-various
414 :type 'boolean)
415
416 (defcustom gnus-break-pages t
417 "*If non-nil, do page breaking on articles.
418 The page delimiter is specified by the `gnus-page-delimiter'
419 variable."
420 :group 'gnus-article-various
421 :type 'boolean)
422
423 (defcustom gnus-move-split-methods nil
424 "*Variable used to suggest where articles are to be moved to.
425 It uses the same syntax as the `gnus-split-methods' variable.
426 However, whereas `gnus-split-methods' specifies file names as targets,
427 this variable specifies group names."
428 :group 'gnus-summary-mail
429 :type '(repeat (choice (list :value (fun) function)
430 (cons :value ("" "") regexp (repeat string))
431 (sexp :value nil))))
432
433 ;; FIXME: Although the custom type is `character' for the following variables,
434 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
435
436 (defcustom gnus-unread-mark ? ;Whitespace
437 "*Mark used for unread articles."
438 :group 'gnus-summary-marks
439 :type 'character)
440
441 (defcustom gnus-ticked-mark ?!
442 "*Mark used for ticked articles."
443 :group 'gnus-summary-marks
444 :type 'character)
445
446 (defcustom gnus-dormant-mark ??
447 "*Mark used for dormant articles."
448 :group 'gnus-summary-marks
449 :type 'character)
450
451 (defcustom gnus-del-mark ?r
452 "*Mark used for del'd articles."
453 :group 'gnus-summary-marks
454 :type 'character)
455
456 (defcustom gnus-read-mark ?R
457 "*Mark used for read articles."
458 :group 'gnus-summary-marks
459 :type 'character)
460
461 (defcustom gnus-expirable-mark ?E
462 "*Mark used for expirable articles."
463 :group 'gnus-summary-marks
464 :type 'character)
465
466 (defcustom gnus-killed-mark ?K
467 "*Mark used for killed articles."
468 :group 'gnus-summary-marks
469 :type 'character)
470
471 (defcustom gnus-spam-mark ?$
472 "*Mark used for spam articles."
473 :version "22.1"
474 :group 'gnus-summary-marks
475 :type 'character)
476
477 (defcustom gnus-souped-mark ?F
478 "*Mark used for souped articles."
479 :group 'gnus-summary-marks
480 :type 'character)
481
482 (defcustom gnus-kill-file-mark ?X
483 "*Mark used for articles killed by kill files."
484 :group 'gnus-summary-marks
485 :type 'character)
486
487 (defcustom gnus-low-score-mark ?Y
488 "*Mark used for articles with a low score."
489 :group 'gnus-summary-marks
490 :type 'character)
491
492 (defcustom gnus-catchup-mark ?C
493 "*Mark used for articles that are caught up."
494 :group 'gnus-summary-marks
495 :type 'character)
496
497 (defcustom gnus-replied-mark ?A
498 "*Mark used for articles that have been replied to."
499 :group 'gnus-summary-marks
500 :type 'character)
501
502 (defcustom gnus-forwarded-mark ?F
503 "*Mark used for articles that have been forwarded."
504 :version "22.1"
505 :group 'gnus-summary-marks
506 :type 'character)
507
508 (defcustom gnus-recent-mark ?N
509 "*Mark used for articles that are recent."
510 :version "22.1"
511 :group 'gnus-summary-marks
512 :type 'character)
513
514 (defcustom gnus-cached-mark ?*
515 "*Mark used for articles that are in the cache."
516 :group 'gnus-summary-marks
517 :type 'character)
518
519 (defcustom gnus-saved-mark ?S
520 "*Mark used for articles that have been saved."
521 :group 'gnus-summary-marks
522 :type 'character)
523
524 (defcustom gnus-unseen-mark ?.
525 "*Mark used for articles that haven't been seen."
526 :version "22.1"
527 :group 'gnus-summary-marks
528 :type 'character)
529
530 (defcustom gnus-no-mark ? ;Whitespace
531 "*Mark used for articles that have no other secondary mark."
532 :version "22.1"
533 :group 'gnus-summary-marks
534 :type 'character)
535
536 (defcustom gnus-ancient-mark ?O
537 "*Mark used for ancient articles."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541 (defcustom gnus-sparse-mark ?Q
542 "*Mark used for sparsely reffed articles."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546 (defcustom gnus-canceled-mark ?G
547 "*Mark used for canceled articles."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551 (defcustom gnus-duplicate-mark ?M
552 "*Mark used for duplicate articles."
553 :group 'gnus-summary-marks
554 :type 'character)
555
556 (defcustom gnus-undownloaded-mark ?-
557 "*Mark used for articles that weren't downloaded."
558 :version "22.1"
559 :group 'gnus-summary-marks
560 :type 'character)
561
562 (defcustom gnus-downloaded-mark ?+
563 "*Mark used for articles that were downloaded."
564 :group 'gnus-summary-marks
565 :type 'character)
566
567 (defcustom gnus-downloadable-mark ?%
568 "*Mark used for articles that are to be downloaded."
569 :group 'gnus-summary-marks
570 :type 'character)
571
572 (defcustom gnus-unsendable-mark ?=
573 "*Mark used for articles that won't be sent."
574 :group 'gnus-summary-marks
575 :type 'character)
576
577 (defcustom gnus-score-over-mark ?+
578 "*Score mark used for articles with high scores."
579 :group 'gnus-summary-marks
580 :type 'character)
581
582 (defcustom gnus-score-below-mark ?-
583 "*Score mark used for articles with low scores."
584 :group 'gnus-summary-marks
585 :type 'character)
586
587 (defcustom gnus-empty-thread-mark ? ;Whitespace
588 "*There is no thread under the article."
589 :group 'gnus-summary-marks
590 :type 'character)
591
592 (defcustom gnus-not-empty-thread-mark ?=
593 "*There is a thread under the article."
594 :group 'gnus-summary-marks
595 :type 'character)
596
597 (defcustom gnus-view-pseudo-asynchronously nil
598 "*If non-nil, Gnus will view pseudo-articles asynchronously."
599 :group 'gnus-extract-view
600 :type 'boolean)
601
602 (defcustom gnus-auto-expirable-marks
603 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
604 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
605 gnus-souped-mark gnus-duplicate-mark)
606 "*The list of marks converted into expiration if a group is auto-expirable."
607 :version "21.1"
608 :group 'gnus-summary
609 :type '(repeat character))
610
611 (defcustom gnus-inhibit-user-auto-expire t
612 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
613 :version "21.1"
614 :group 'gnus-summary
615 :type 'boolean)
616
617 (defcustom gnus-view-pseudos nil
618 "*If `automatic', pseudo-articles will be viewed automatically.
619 If `not-confirm', pseudos will be viewed automatically, and the user
620 will not be asked to confirm the command."
621 :group 'gnus-extract-view
622 :type '(choice (const :tag "off" nil)
623 (const automatic)
624 (const not-confirm)))
625
626 (defcustom gnus-view-pseudos-separately t
627 "*If non-nil, one pseudo-article will be created for each file to be viewed.
628 If nil, all files that use the same viewing command will be given as a
629 list of parameters to that command."
630 :group 'gnus-extract-view
631 :type 'boolean)
632
633 (defcustom gnus-insert-pseudo-articles t
634 "*If non-nil, insert pseudo-articles when decoding articles."
635 :group 'gnus-extract-view
636 :type 'boolean)
637
638 (defcustom gnus-summary-dummy-line-format
639 " %(: :%) %S\n"
640 "*The format specification for the dummy roots in the summary buffer.
641 It works along the same lines as a normal formatting string,
642 with some simple extensions.
643
644 %S The subject
645
646 General format specifiers can also be used.
647 See `(gnus)Formatting Variables'."
648 :link '(custom-manual "(gnus)Formatting Variables")
649 :group 'gnus-threading
650 :type 'string)
651
652 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
653 "*The format specification for the summary mode line.
654 It works along the same lines as a normal formatting string,
655 with some simple extensions:
656
657 %G Group name
658 %p Unprefixed group name
659 %A Current article number
660 %z Current article score
661 %V Gnus version
662 %U Number of unread articles in the group
663 %e Number of unselected articles in the group
664 %Z A string with unread/unselected article counts
665 %g Shortish group name
666 %S Subject of the current article
667 %u User-defined spec
668 %s Current score file name
669 %d Number of dormant articles
670 %r Number of articles that have been marked as read in this session
671 %E Number of articles expunged by the score files"
672 :group 'gnus-summary-format
673 :type 'string)
674
675 (defcustom gnus-list-identifiers nil
676 "Regexp that matches list identifiers to be removed from subject.
677 This can also be a list of regexps."
678 :version "21.1"
679 :group 'gnus-summary-format
680 :group 'gnus-article-hiding
681 :type '(choice (const :tag "none" nil)
682 (regexp :value ".*")
683 (repeat :value (".*") regexp)))
684
685 (defcustom gnus-summary-mark-below 0
686 "*Mark all articles with a score below this variable as read.
687 This variable is local to each summary buffer and usually set by the
688 score file."
689 :group 'gnus-score-default
690 :type 'integer)
691
692 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
693 "*List of functions used for sorting articles in the summary buffer.
694
695 Each function takes two articles and returns non-nil if the first
696 article should be sorted before the other. If you use more than one
697 function, the primary sort function should be the last. You should
698 probably always include `gnus-article-sort-by-number' in the list of
699 sorting functions -- preferably first. Also note that sorting by date
700 is often much slower than sorting by number, and the sorting order is
701 very similar. (Sorting by date means sorting by the time the message
702 was sent, sorting by number means sorting by arrival time.)
703
704 Ready-made functions include `gnus-article-sort-by-number',
705 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
706 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
707 and `gnus-article-sort-by-score'.
708
709 When threading is turned on, the variable `gnus-thread-sort-functions'
710 controls how articles are sorted."
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-article-sort-by-number)
713 (function-item gnus-article-sort-by-author)
714 (function-item gnus-article-sort-by-subject)
715 (function-item gnus-article-sort-by-date)
716 (function-item gnus-article-sort-by-score)
717 (function-item gnus-article-sort-by-random)
718 (function :tag "other"))))
719
720 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
721 "*List of functions used for sorting threads in the summary buffer.
722 By default, threads are sorted by article number.
723
724 Each function takes two threads and returns non-nil if the first
725 thread should be sorted before the other. If you use more than one
726 function, the primary sort function should be the last. You should
727 probably always include `gnus-thread-sort-by-number' in the list of
728 sorting functions -- preferably first. Also note that sorting by date
729 is often much slower than sorting by number, and the sorting order is
730 very similar. (Sorting by date means sorting by the time the message
731 was sent, sorting by number means sorting by arrival time.)
732
733 Ready-made functions include `gnus-thread-sort-by-number',
734 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
735 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
736 `gnus-thread-sort-by-most-recent-number',
737 `gnus-thread-sort-by-most-recent-date',
738 `gnus-thread-sort-by-random', and
739 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
740
741 When threading is turned off, the variable
742 `gnus-article-sort-functions' controls how articles are sorted."
743 :group 'gnus-summary-sort
744 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
745 (function-item gnus-thread-sort-by-author)
746 (function-item gnus-thread-sort-by-subject)
747 (function-item gnus-thread-sort-by-date)
748 (function-item gnus-thread-sort-by-score)
749 (function-item gnus-thread-sort-by-total-score)
750 (function-item gnus-thread-sort-by-random)
751 (function :tag "other"))))
752
753 (defcustom gnus-thread-score-function '+
754 "*Function used for calculating the total score of a thread.
755
756 The function is called with the scores of the article and each
757 subthread and should then return the score of the thread.
758
759 Some functions you can use are `+', `max', or `min'."
760 :group 'gnus-summary-sort
761 :type 'function)
762
763 (defcustom gnus-summary-expunge-below nil
764 "All articles that have a score less than this variable will be expunged.
765 This variable is local to the summary buffers."
766 :group 'gnus-score-default
767 :type '(choice (const :tag "off" nil)
768 integer))
769
770 (defcustom gnus-thread-expunge-below nil
771 "All threads that have a total score less than this variable will be expunged.
772 See `gnus-thread-score-function' for en explanation of what a
773 \"thread score\" is.
774
775 This variable is local to the summary buffers."
776 :group 'gnus-threading
777 :group 'gnus-score-default
778 :type '(choice (const :tag "off" nil)
779 integer))
780
781 (defcustom gnus-summary-mode-hook nil
782 "*A hook for Gnus summary mode.
783 This hook is run before any variables are set in the summary buffer."
784 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
785 :group 'gnus-summary-various
786 :type 'hook)
787
788 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
789 (when (featurep 'xemacs)
790 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
791 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
792 (add-hook 'gnus-summary-mode-hook
793 'gnus-xmas-switch-horizontal-scrollbar-off))
794
795 (defcustom gnus-summary-menu-hook nil
796 "*Hook run after the creation of the summary mode menu."
797 :group 'gnus-summary-visual
798 :type 'hook)
799
800 (defcustom gnus-summary-exit-hook nil
801 "*A hook called on exit from the summary buffer.
802 It will be called with point in the group buffer."
803 :group 'gnus-summary-exit
804 :type 'hook)
805
806 (defcustom gnus-summary-prepare-hook nil
807 "*A hook called after the summary buffer has been generated.
808 If you want to modify the summary buffer, you can use this hook."
809 :group 'gnus-summary-various
810 :type 'hook)
811
812 (defcustom gnus-summary-prepared-hook nil
813 "*A hook called as the last thing after the summary buffer has been generated."
814 :group 'gnus-summary-various
815 :type 'hook)
816
817 (defcustom gnus-summary-generate-hook nil
818 "*A hook run just before generating the summary buffer.
819 This hook is commonly used to customize threading variables and the
820 like."
821 :group 'gnus-summary-various
822 :type 'hook)
823
824 (defcustom gnus-select-group-hook nil
825 "*A hook called when a newsgroup is selected.
826
827 If you'd like to simplify subjects like the
828 `gnus-summary-next-same-subject' command does, you can use the
829 following hook:
830
831 (add-hook gnus-select-group-hook
832 (lambda ()
833 (mapcar (lambda (header)
834 (mail-header-set-subject
835 header
836 (gnus-simplify-subject
837 (mail-header-subject header) 're-only)))
838 gnus-newsgroup-headers)))"
839 :group 'gnus-group-select
840 :type 'hook)
841
842 (defcustom gnus-select-article-hook nil
843 "*A hook called when an article is selected."
844 :group 'gnus-summary-choose
845 :options '(gnus-agent-fetch-selected-article)
846 :type 'hook)
847
848 (defcustom gnus-visual-mark-article-hook
849 (list 'gnus-highlight-selected-summary)
850 "*Hook run after selecting an article in the summary buffer.
851 It is meant to be used for highlighting the article in some way. It
852 is not run if `gnus-visual' is nil."
853 :group 'gnus-summary-visual
854 :type 'hook)
855
856 (defcustom gnus-parse-headers-hook nil
857 "*A hook called before parsing the headers."
858 :group 'gnus-various
859 :type 'hook)
860
861 (defcustom gnus-exit-group-hook nil
862 "*A hook called when exiting summary mode.
863 This hook is not called from the non-updating exit commands like `Q'."
864 :group 'gnus-various
865 :type 'hook)
866
867 (defcustom gnus-summary-update-hook
868 (list 'gnus-summary-highlight-line)
869 "*A hook called when a summary line is changed.
870 The hook will not be called if `gnus-visual' is nil.
871
872 The default function `gnus-summary-highlight-line' will
873 highlight the line according to the `gnus-summary-highlight'
874 variable."
875 :group 'gnus-summary-visual
876 :type 'hook)
877
878 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
879 "*A hook called when an article is selected for the first time.
880 The hook is intended to mark an article as read (or unread)
881 automatically when it is selected."
882 :group 'gnus-summary-choose
883 :type 'hook)
884
885 (defcustom gnus-group-no-more-groups-hook nil
886 "*A hook run when returning to group mode having no more (unread) groups."
887 :group 'gnus-group-select
888 :type 'hook)
889
890 (defcustom gnus-ps-print-hook nil
891 "*A hook run before ps-printing something from Gnus."
892 :group 'gnus-summary
893 :type 'hook)
894
895 (defcustom gnus-summary-article-move-hook nil
896 "*A hook called after an article is moved, copied, respooled, or crossposted."
897 :version "22.1"
898 :group 'gnus-summary
899 :type 'hook)
900
901 (defcustom gnus-summary-article-delete-hook nil
902 "*A hook called after an article is deleted."
903 :version "22.1"
904 :group 'gnus-summary
905 :type 'hook)
906
907 (defcustom gnus-summary-article-expire-hook nil
908 "*A hook called after an article is expired."
909 :version "22.1"
910 :group 'gnus-summary
911 :type 'hook)
912
913 (defcustom gnus-summary-display-arrow
914 (and (fboundp 'display-graphic-p)
915 (display-graphic-p))
916 "*If non-nil, display an arrow highlighting the current article."
917 :version "22.1"
918 :group 'gnus-summary
919 :type 'boolean)
920
921 (defcustom gnus-summary-selected-face 'gnus-summary-selected
922 "Face used for highlighting the current article in the summary buffer."
923 :group 'gnus-summary-visual
924 :type 'face)
925
926 (defvar gnus-tmp-downloaded nil)
927
928 (defcustom gnus-summary-highlight
929 '(((eq mark gnus-canceled-mark)
930 . gnus-summary-cancelled)
931 ((and uncached (> score default-high))
932 . gnus-summary-high-undownloaded)
933 ((and uncached (< score default-low))
934 . gnus-summary-low-undownloaded)
935 (uncached
936 . gnus-summary-normal-undownloaded)
937 ((and (> score default-high)
938 (or (eq mark gnus-dormant-mark)
939 (eq mark gnus-ticked-mark)))
940 . gnus-summary-high-ticked)
941 ((and (< score default-low)
942 (or (eq mark gnus-dormant-mark)
943 (eq mark gnus-ticked-mark)))
944 . gnus-summary-low-ticked)
945 ((or (eq mark gnus-dormant-mark)
946 (eq mark gnus-ticked-mark))
947 . gnus-summary-normal-ticked)
948 ((and (> score default-high) (eq mark gnus-ancient-mark))
949 . gnus-summary-high-ancient)
950 ((and (< score default-low) (eq mark gnus-ancient-mark))
951 . gnus-summary-low-ancient)
952 ((eq mark gnus-ancient-mark)
953 . gnus-summary-normal-ancient)
954 ((and (> score default-high) (eq mark gnus-unread-mark))
955 . gnus-summary-high-unread)
956 ((and (< score default-low) (eq mark gnus-unread-mark))
957 . gnus-summary-low-unread)
958 ((eq mark gnus-unread-mark)
959 . gnus-summary-normal-unread)
960 ((> score default-high)
961 . gnus-summary-high-read)
962 ((< score default-low)
963 . gnus-summary-low-read)
964 (t
965 . gnus-summary-normal-read))
966 "*Controls the highlighting of summary buffer lines.
967
968 A list of (FORM . FACE) pairs. When deciding how a a particular
969 summary line should be displayed, each form is evaluated. The content
970 of the face field after the first true form is used. You can change
971 how those summary lines are displayed, by editing the face field.
972
973 You can use the following variables in the FORM field.
974
975 score: The article's score
976 default: The default article score.
977 default-high: The default score for high scored articles.
978 default-low: The default score for low scored articles.
979 below: The score below which articles are automatically marked as read.
980 mark: The article's mark.
981 uncached: Non-nil if the article is uncached."
982 :group 'gnus-summary-visual
983 :type '(repeat (cons (sexp :tag "Form" nil)
984 face)))
985
986 (defcustom gnus-alter-header-function nil
987 "Function called to allow alteration of article header structures.
988 The function is called with one parameter, the article header vector,
989 which it may alter in any way."
990 :type '(choice (const :tag "None" nil)
991 function)
992 :group 'gnus-summary)
993
994 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
995 "Variable that says which function should be used to decode a string with encoded words.")
996
997 (defcustom gnus-extra-headers '(To Newsgroups)
998 "*Extra headers to parse."
999 :version "21.1"
1000 :group 'gnus-summary
1001 :type '(repeat symbol))
1002
1003 (defcustom gnus-ignored-from-addresses
1004 (and user-mail-address (regexp-quote user-mail-address))
1005 "*Regexp of From headers that may be suppressed in favor of To headers."
1006 :version "21.1"
1007 :group 'gnus-summary
1008 :type 'regexp)
1009
1010 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1011 "List of charsets that should be ignored.
1012 When these charsets are used in the \"charset\" parameter, the
1013 default charset will be used instead."
1014 :version "21.1"
1015 :type '(repeat symbol)
1016 :group 'gnus-charset)
1017
1018 (gnus-define-group-parameter
1019 ignored-charsets
1020 :type list
1021 :function-document
1022 "Return the ignored charsets of GROUP."
1023 :variable gnus-group-ignored-charsets-alist
1024 :variable-default
1025 '(("alt\\.chinese\\.text" iso-8859-1))
1026 :variable-document
1027 "Alist of regexps (to match group names) and charsets that should be ignored.
1028 When these charsets are used in the \"charset\" parameter, the
1029 default charset will be used instead."
1030 :variable-group gnus-charset
1031 :variable-type '(repeat (cons (regexp :tag "Group")
1032 (repeat symbol)))
1033 :parameter-type '(choice :tag "Ignored charsets"
1034 :value nil
1035 (repeat (symbol)))
1036 :parameter-document "\
1037 List of charsets that should be ignored.
1038
1039 When these charsets are used in the \"charset\" parameter, the
1040 default charset will be used instead.")
1041
1042 (defcustom gnus-group-highlight-words-alist nil
1043 "Alist of group regexps and highlight regexps.
1044 This variable uses the same syntax as `gnus-emphasis-alist'."
1045 :version "21.1"
1046 :type '(repeat (cons (regexp :tag "Group")
1047 (repeat (list (regexp :tag "Highlight regexp")
1048 (number :tag "Group for entire word" 0)
1049 (number :tag "Group for displayed part" 0)
1050 (symbol :tag "Face"
1051 gnus-emphasis-highlight-words)))))
1052 :group 'gnus-summary-visual)
1053
1054 (defcustom gnus-summary-show-article-charset-alist
1055 nil
1056 "Alist of number and charset.
1057 The article will be shown with the charset corresponding to the
1058 numbered argument.
1059 For example: ((1 . cn-gb-2312) (2 . big5))."
1060 :version "21.1"
1061 :type '(repeat (cons (number :tag "Argument" 1)
1062 (symbol :tag "Charset")))
1063 :group 'gnus-charset)
1064
1065 (defcustom gnus-preserve-marks t
1066 "Whether marks are preserved when moving, copying and respooling messages."
1067 :version "21.1"
1068 :type 'boolean
1069 :group 'gnus-summary-marks)
1070
1071 (defcustom gnus-alter-articles-to-read-function nil
1072 "Function to be called to alter the list of articles to be selected."
1073 :type '(choice (const nil) function)
1074 :group 'gnus-summary)
1075
1076 (defcustom gnus-orphan-score nil
1077 "*All orphans get this score added. Set in the score file."
1078 :group 'gnus-score-default
1079 :type '(choice (const nil)
1080 integer))
1081
1082 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1083 "*A regexp to match MIME parts when saving multiple parts of a
1084 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1085 This regexp will be used by default when prompting the user for which
1086 type of files to save."
1087 :group 'gnus-summary
1088 :type 'regexp)
1089
1090 (defcustom gnus-read-all-available-headers nil
1091 "Whether Gnus should parse all headers made available to it.
1092 This is mostly relevant for slow back ends where the user may
1093 wish to widen the summary buffer to include all headers
1094 that were fetched. Say, for nnultimate groups."
1095 :version "22.1"
1096 :group 'gnus-summary
1097 :type '(choice boolean regexp))
1098
1099 (defcustom gnus-summary-muttprint-program "muttprint"
1100 "Command (and optional arguments) used to run Muttprint."
1101 :version "22.1"
1102 :group 'gnus-summary
1103 :type 'string)
1104
1105 (defcustom gnus-article-loose-mime nil
1106 "If non-nil, don't require MIME-Version header.
1107 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1108 supply the MIME-Version header or deliberately strip it from the mail.
1109 Set it to non-nil, Gnus will treat some articles as MIME even if
1110 the MIME-Version header is missed."
1111 :version "22.1"
1112 :type 'boolean
1113 :group 'gnus-article-mime)
1114
1115 (defcustom gnus-article-emulate-mime t
1116 "If non-nil, use MIME emulation for uuencode and the like.
1117 This means that Gnus will search message bodies for text that look
1118 like uuencoded bits, yEncoded bits, and so on, and present that using
1119 the normal Gnus MIME machinery."
1120 :version "22.1"
1121 :type 'boolean
1122 :group 'gnus-article-mime)
1123
1124 ;;; Internal variables
1125
1126 (defvar gnus-summary-display-cache nil)
1127 (defvar gnus-article-mime-handles nil)
1128 (defvar gnus-article-decoded-p nil)
1129 (defvar gnus-article-charset nil)
1130 (defvar gnus-article-ignored-charsets nil)
1131 (defvar gnus-scores-exclude-files nil)
1132 (defvar gnus-page-broken nil)
1133
1134 (defvar gnus-original-article nil)
1135 (defvar gnus-article-internal-prepare-hook nil)
1136 (defvar gnus-newsgroup-process-stack nil)
1137
1138 (defvar gnus-thread-indent-array nil)
1139 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1140 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1141 "Function called to sort the articles within a thread after it has been gathered together.")
1142
1143 (defvar gnus-summary-save-parts-type-history nil)
1144 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1145
1146 ;; Avoid highlighting in kill files.
1147 (defvar gnus-summary-inhibit-highlight nil)
1148 (defvar gnus-newsgroup-selected-overlay nil)
1149 (defvar gnus-inhibit-limiting nil)
1150 (defvar gnus-newsgroup-adaptive-score-file nil)
1151 (defvar gnus-current-score-file nil)
1152 (defvar gnus-current-move-group nil)
1153 (defvar gnus-current-copy-group nil)
1154 (defvar gnus-current-crosspost-group nil)
1155 (defvar gnus-newsgroup-display nil)
1156
1157 (defvar gnus-newsgroup-dependencies nil)
1158 (defvar gnus-newsgroup-adaptive nil)
1159 (defvar gnus-summary-display-article-function nil)
1160 (defvar gnus-summary-highlight-line-function nil
1161 "Function called after highlighting a summary line.")
1162
1163 (defvar gnus-summary-line-format-alist
1164 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1165 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1166 (?s gnus-tmp-subject-or-nil ?s)
1167 (?n gnus-tmp-name ?s)
1168 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1169 ?s)
1170 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1171 gnus-tmp-from) ?s)
1172 (?F gnus-tmp-from ?s)
1173 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1174 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1175 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1176 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1177 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1178 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1179 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1180 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1181 (?L gnus-tmp-lines ?s)
1182 (?O gnus-tmp-downloaded ?c)
1183 (?I gnus-tmp-indentation ?s)
1184 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1185 (?R gnus-tmp-replied ?c)
1186 (?\[ gnus-tmp-opening-bracket ?c)
1187 (?\] gnus-tmp-closing-bracket ?c)
1188 (?\> (make-string gnus-tmp-level ? ) ?s)
1189 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1190 (?i gnus-tmp-score ?d)
1191 (?z gnus-tmp-score-char ?c)
1192 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1193 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1194 (?U gnus-tmp-unread ?c)
1195 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1196 ?s)
1197 (?t (gnus-summary-number-of-articles-in-thread
1198 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1199 ?d)
1200 (?e (gnus-summary-number-of-articles-in-thread
1201 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1202 ?c)
1203 (?u gnus-tmp-user-defined ?s)
1204 (?P (gnus-pick-line-number) ?d)
1205 (?B gnus-tmp-thread-tree-header-string ?s)
1206 (user-date (gnus-user-date
1207 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1208 "An alist of format specifications that can appear in summary lines.
1209 These are paired with what variables they correspond with, along with
1210 the type of the variable (string, integer, character, etc).")
1211
1212 (defvar gnus-summary-dummy-line-format-alist
1213 `((?S gnus-tmp-subject ?s)
1214 (?N gnus-tmp-number ?d)
1215 (?u gnus-tmp-user-defined ?s)))
1216
1217 (defvar gnus-summary-mode-line-format-alist
1218 `((?G gnus-tmp-group-name ?s)
1219 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1220 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1221 (?A gnus-tmp-article-number ?d)
1222 (?Z gnus-tmp-unread-and-unselected ?s)
1223 (?V gnus-version ?s)
1224 (?U gnus-tmp-unread-and-unticked ?d)
1225 (?S gnus-tmp-subject ?s)
1226 (?e gnus-tmp-unselected ?d)
1227 (?u gnus-tmp-user-defined ?s)
1228 (?d (length gnus-newsgroup-dormant) ?d)
1229 (?t (length gnus-newsgroup-marked) ?d)
1230 (?h (length gnus-newsgroup-spam-marked) ?d)
1231 (?r (length gnus-newsgroup-reads) ?d)
1232 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1233 (?E gnus-newsgroup-expunged-tally ?d)
1234 (?s (gnus-current-score-file-nondirectory) ?s)))
1235
1236 (defvar gnus-last-search-regexp nil
1237 "Default regexp for article search command.")
1238
1239 (defvar gnus-last-shell-command nil
1240 "Default shell command on article.")
1241
1242 (defvar gnus-newsgroup-agentized nil
1243 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1244 (defvar gnus-newsgroup-begin nil)
1245 (defvar gnus-newsgroup-end nil)
1246 (defvar gnus-newsgroup-last-rmail nil)
1247 (defvar gnus-newsgroup-last-mail nil)
1248 (defvar gnus-newsgroup-last-folder nil)
1249 (defvar gnus-newsgroup-last-file nil)
1250 (defvar gnus-newsgroup-auto-expire nil)
1251 (defvar gnus-newsgroup-active nil)
1252
1253 (defvar gnus-newsgroup-data nil)
1254 (defvar gnus-newsgroup-data-reverse nil)
1255 (defvar gnus-newsgroup-limit nil)
1256 (defvar gnus-newsgroup-limits nil)
1257 (defvar gnus-summary-use-undownloaded-faces nil)
1258
1259 (defvar gnus-newsgroup-unreads nil
1260 "Sorted list of unread articles in the current newsgroup.")
1261
1262 (defvar gnus-newsgroup-unselected nil
1263 "Sorted list of unselected unread articles in the current newsgroup.")
1264
1265 (defvar gnus-newsgroup-reads nil
1266 "Alist of read articles and article marks in the current newsgroup.")
1267
1268 (defvar gnus-newsgroup-expunged-tally nil)
1269
1270 (defvar gnus-newsgroup-marked nil
1271 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1272
1273 (defvar gnus-newsgroup-spam-marked nil
1274 "List of ranges of articles that have been marked as spam.")
1275
1276 (defvar gnus-newsgroup-killed nil
1277 "List of ranges of articles that have been through the scoring process.")
1278
1279 (defvar gnus-newsgroup-cached nil
1280 "Sorted list of articles that come from the article cache.")
1281
1282 (defvar gnus-newsgroup-saved nil
1283 "List of articles that have been saved.")
1284
1285 (defvar gnus-newsgroup-kill-headers nil)
1286
1287 (defvar gnus-newsgroup-replied nil
1288 "List of articles that have been replied to in the current newsgroup.")
1289
1290 (defvar gnus-newsgroup-forwarded nil
1291 "List of articles that have been forwarded in the current newsgroup.")
1292
1293 (defvar gnus-newsgroup-recent nil
1294 "List of articles that have are recent in the current newsgroup.")
1295
1296 (defvar gnus-newsgroup-expirable nil
1297 "Sorted list of articles in the current newsgroup that can be expired.")
1298
1299 (defvar gnus-newsgroup-processable nil
1300 "List of articles in the current newsgroup that can be processed.")
1301
1302 (defvar gnus-newsgroup-downloadable nil
1303 "Sorted list of articles in the current newsgroup that can be processed.")
1304
1305 (defvar gnus-newsgroup-unfetched nil
1306 "Sorted list of articles in the current newsgroup whose headers have
1307 not been fetched into the agent.
1308
1309 This list will always be a subset of gnus-newsgroup-undownloaded.")
1310
1311 (defvar gnus-newsgroup-undownloaded nil
1312 "List of articles in the current newsgroup that haven't been downloaded.")
1313
1314 (defvar gnus-newsgroup-unsendable nil
1315 "List of articles in the current newsgroup that won't be sent.")
1316
1317 (defvar gnus-newsgroup-bookmarks nil
1318 "List of articles in the current newsgroup that have bookmarks.")
1319
1320 (defvar gnus-newsgroup-dormant nil
1321 "Sorted list of dormant articles in the current newsgroup.")
1322
1323 (defvar gnus-newsgroup-unseen nil
1324 "List of unseen articles in the current newsgroup.")
1325
1326 (defvar gnus-newsgroup-seen nil
1327 "Range of seen articles in the current newsgroup.")
1328
1329 (defvar gnus-newsgroup-articles nil
1330 "List of articles in the current newsgroup.")
1331
1332 (defvar gnus-newsgroup-scored nil
1333 "List of scored articles in the current newsgroup.")
1334
1335 (defvar gnus-newsgroup-headers nil
1336 "List of article headers in the current newsgroup.")
1337
1338 (defvar gnus-newsgroup-threads nil)
1339
1340 (defvar gnus-newsgroup-prepared nil
1341 "Whether the current group has been prepared properly.")
1342
1343 (defvar gnus-newsgroup-ancient nil
1344 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1345
1346 (defvar gnus-newsgroup-sparse nil)
1347
1348 (defvar gnus-current-article nil)
1349 (defvar gnus-article-current nil)
1350 (defvar gnus-current-headers nil)
1351 (defvar gnus-have-all-headers nil)
1352 (defvar gnus-last-article nil)
1353 (defvar gnus-newsgroup-history nil)
1354 (defvar gnus-newsgroup-charset nil)
1355 (defvar gnus-newsgroup-ephemeral-charset nil)
1356 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1357
1358 (defvar gnus-article-before-search nil)
1359
1360 (defvar gnus-summary-local-variables
1361 '(gnus-newsgroup-name
1362 gnus-newsgroup-begin gnus-newsgroup-end
1363 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1364 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1365 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1366 gnus-newsgroup-unselected gnus-newsgroup-marked
1367 gnus-newsgroup-spam-marked
1368 gnus-newsgroup-reads gnus-newsgroup-saved
1369 gnus-newsgroup-replied gnus-newsgroup-forwarded
1370 gnus-newsgroup-recent
1371 gnus-newsgroup-expirable
1372 gnus-newsgroup-processable gnus-newsgroup-killed
1373 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1374 gnus-newsgroup-unfetched
1375 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1376 gnus-newsgroup-seen gnus-newsgroup-articles
1377 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1378 gnus-newsgroup-headers gnus-newsgroup-threads
1379 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1380 gnus-current-article gnus-current-headers gnus-have-all-headers
1381 gnus-last-article gnus-article-internal-prepare-hook
1382 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1383 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1384 gnus-thread-expunge-below
1385 gnus-score-alist gnus-current-score-file
1386 (gnus-summary-expunge-below . global)
1387 (gnus-summary-mark-below . global)
1388 (gnus-orphan-score . global)
1389 gnus-newsgroup-active gnus-scores-exclude-files
1390 gnus-newsgroup-history gnus-newsgroup-ancient
1391 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1392 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1393 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1394 (gnus-newsgroup-expunged-tally . 0)
1395 gnus-cache-removable-articles gnus-newsgroup-cached
1396 gnus-newsgroup-data gnus-newsgroup-data-reverse
1397 gnus-newsgroup-limit gnus-newsgroup-limits
1398 gnus-newsgroup-charset gnus-newsgroup-display
1399 gnus-summary-use-undownloaded-faces)
1400 "Variables that are buffer-local to the summary buffers.")
1401
1402 (defvar gnus-newsgroup-variables nil
1403 "A list of variables that have separate values in different newsgroups.
1404 A list of newsgroup (summary buffer) local variables, or cons of
1405 variables and their default expressions to be evalled (when the default
1406 values are not nil), that should be made global while the summary buffer
1407 is active.
1408
1409 Note: The default expressions will be evaluated (using function `eval')
1410 before assignment to the local variable rather than just assigned to it.
1411 If the default expression is the symbol `global', that symbol will not
1412 be evaluated but the global value of the local variable will be used
1413 instead.
1414
1415 These variables can be used to set variables in the group parameters
1416 while still allowing them to affect operations done in other buffers.
1417 For example:
1418
1419 \(setq gnus-newsgroup-variables
1420 '(message-use-followup-to
1421 (gnus-visible-headers .
1422 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1423 ")
1424
1425 ;; Byte-compiler warning.
1426 (eval-when-compile
1427 ;; Bind features so that require will believe that gnus-sum has
1428 ;; already been loaded (avoids infinite recursion)
1429 (let ((features (cons 'gnus-sum features)))
1430 ;; Several of the declarations in gnus-sum are needed to load the
1431 ;; following files. Right now, these definitions have been
1432 ;; compiled but not defined (evaluated). We could either do a
1433 ;; eval-and-compile about all of the declarations or evaluate the
1434 ;; source file.
1435 (if (boundp 'gnus-newsgroup-variables)
1436 nil
1437 (load "gnus-sum.el" t t t))
1438 (require 'gnus)
1439 (require 'gnus-agent)
1440 (require 'gnus-art)))
1441
1442 ;; MIME stuff.
1443
1444 (defvar gnus-decode-encoded-word-methods
1445 '(mail-decode-encoded-word-string)
1446 "List of methods used to decode encoded words.
1447
1448 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1449 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1450 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1451 whose names match REGEXP.
1452
1453 For example:
1454 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1455 mail-decode-encoded-word-string
1456 (\"chinese\" . rfc1843-decode-string))")
1457
1458 (defvar gnus-decode-encoded-word-methods-cache nil)
1459
1460 (defun gnus-multi-decode-encoded-word-string (string)
1461 "Apply the functions from `gnus-encoded-word-methods' that match."
1462 (unless (and gnus-decode-encoded-word-methods-cache
1463 (eq gnus-newsgroup-name
1464 (car gnus-decode-encoded-word-methods-cache)))
1465 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1466 (mapcar (lambda (x)
1467 (if (symbolp x)
1468 (nconc gnus-decode-encoded-word-methods-cache (list x))
1469 (if (and gnus-newsgroup-name
1470 (string-match (car x) gnus-newsgroup-name))
1471 (nconc gnus-decode-encoded-word-methods-cache
1472 (list (cdr x))))))
1473 gnus-decode-encoded-word-methods))
1474 (let ((xlist gnus-decode-encoded-word-methods-cache))
1475 (pop xlist)
1476 (while xlist
1477 (setq string (funcall (pop xlist) string))))
1478 string)
1479
1480 ;; Subject simplification.
1481
1482 (defun gnus-simplify-whitespace (str)
1483 "Remove excessive whitespace from STR."
1484 ;; Multiple spaces.
1485 (while (string-match "[ \t][ \t]+" str)
1486 (setq str (concat (substring str 0 (match-beginning 0))
1487 " "
1488 (substring str (match-end 0)))))
1489 ;; Leading spaces.
1490 (when (string-match "^[ \t]+" str)
1491 (setq str (substring str (match-end 0))))
1492 ;; Trailing spaces.
1493 (when (string-match "[ \t]+$" str)
1494 (setq str (substring str 0 (match-beginning 0))))
1495 str)
1496
1497 (defun gnus-simplify-all-whitespace (str)
1498 "Remove all whitespace from STR."
1499 (while (string-match "[ \t\n]+" str)
1500 (setq str (replace-match "" nil nil str)))
1501 str)
1502
1503 (defsubst gnus-simplify-subject-re (subject)
1504 "Remove \"Re:\" from subject lines."
1505 (if (string-match message-subject-re-regexp subject)
1506 (substring subject (match-end 0))
1507 subject))
1508
1509 (defun gnus-simplify-subject (subject &optional re-only)
1510 "Remove `Re:' and words in parentheses.
1511 If RE-ONLY is non-nil, strip leading `Re:'s only."
1512 (let ((case-fold-search t)) ;Ignore case.
1513 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1514 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1515 (setq subject (substring subject (match-end 0))))
1516 ;; Remove uninteresting prefixes.
1517 (when (and (not re-only)
1518 gnus-simplify-ignored-prefixes
1519 (string-match gnus-simplify-ignored-prefixes subject))
1520 (setq subject (substring subject (match-end 0))))
1521 ;; Remove words in parentheses from end.
1522 (unless re-only
1523 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1524 (setq subject (substring subject 0 (match-beginning 0)))))
1525 ;; Return subject string.
1526 subject))
1527
1528 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1529 ;; all whitespace.
1530 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1531 (goto-char (point-min))
1532 (while (re-search-forward regexp nil t)
1533 (replace-match (or newtext ""))))
1534
1535 (defun gnus-simplify-buffer-fuzzy ()
1536 "Simplify string in the buffer fuzzily.
1537 The string in the accessible portion of the current buffer is simplified.
1538 It is assumed to be a single-line subject.
1539 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1540 matter is removed. Additional things can be deleted by setting
1541 `gnus-simplify-subject-fuzzy-regexp'."
1542 (let ((case-fold-search t)
1543 (modified-tick))
1544 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1545
1546 (while (not (eq modified-tick (buffer-modified-tick)))
1547 (setq modified-tick (buffer-modified-tick))
1548 (cond
1549 ((listp gnus-simplify-subject-fuzzy-regexp)
1550 (mapcar 'gnus-simplify-buffer-fuzzy-step
1551 gnus-simplify-subject-fuzzy-regexp))
1552 (gnus-simplify-subject-fuzzy-regexp
1553 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1554 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1555 (gnus-simplify-buffer-fuzzy-step
1556 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1557 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1558
1559 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1560 (gnus-simplify-buffer-fuzzy-step " +" " ")
1561 (gnus-simplify-buffer-fuzzy-step " $")
1562 (gnus-simplify-buffer-fuzzy-step "^ +")))
1563
1564 (defun gnus-simplify-subject-fuzzy (subject)
1565 "Simplify a subject string fuzzily.
1566 See `gnus-simplify-buffer-fuzzy' for details."
1567 (save-excursion
1568 (gnus-set-work-buffer)
1569 (let ((case-fold-search t))
1570 ;; Remove uninteresting prefixes.
1571 (when (and gnus-simplify-ignored-prefixes
1572 (string-match gnus-simplify-ignored-prefixes subject))
1573 (setq subject (substring subject (match-end 0))))
1574 (insert subject)
1575 (inline (gnus-simplify-buffer-fuzzy))
1576 (buffer-string))))
1577
1578 (defsubst gnus-simplify-subject-fully (subject)
1579 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1580 (cond
1581 (gnus-simplify-subject-functions
1582 (gnus-map-function gnus-simplify-subject-functions subject))
1583 ((null gnus-summary-gather-subject-limit)
1584 (gnus-simplify-subject-re subject))
1585 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1586 (gnus-simplify-subject-fuzzy subject))
1587 ((numberp gnus-summary-gather-subject-limit)
1588 (gnus-limit-string (gnus-simplify-subject-re subject)
1589 gnus-summary-gather-subject-limit))
1590 (t
1591 subject)))
1592
1593 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1594 "Check whether two subjects are equal.
1595 If optional argument SIMPLE-FIRST is t, first argument is already
1596 simplified."
1597 (cond
1598 ((null simple-first)
1599 (equal (gnus-simplify-subject-fully s1)
1600 (gnus-simplify-subject-fully s2)))
1601 (t
1602 (equal s1
1603 (gnus-simplify-subject-fully s2)))))
1604
1605 (defun gnus-summary-bubble-group ()
1606 "Increase the score of the current group.
1607 This is a handy function to add to `gnus-summary-exit-hook' to
1608 increase the score of each group you read."
1609 (gnus-group-add-score gnus-newsgroup-name))
1610
1611 \f
1612 ;;;
1613 ;;; Gnus summary mode
1614 ;;;
1615
1616 (put 'gnus-summary-mode 'mode-class 'special)
1617
1618 (defvar gnus-article-commands-menu)
1619
1620 ;; Non-orthogonal keys
1621
1622 (gnus-define-keys gnus-summary-mode-map
1623 " " gnus-summary-next-page
1624 "\177" gnus-summary-prev-page
1625 [delete] gnus-summary-prev-page
1626 [backspace] gnus-summary-prev-page
1627 "\r" gnus-summary-scroll-up
1628 "\M-\r" gnus-summary-scroll-down
1629 "n" gnus-summary-next-unread-article
1630 "p" gnus-summary-prev-unread-article
1631 "N" gnus-summary-next-article
1632 "P" gnus-summary-prev-article
1633 "\M-\C-n" gnus-summary-next-same-subject
1634 "\M-\C-p" gnus-summary-prev-same-subject
1635 "\M-n" gnus-summary-next-unread-subject
1636 "\M-p" gnus-summary-prev-unread-subject
1637 "." gnus-summary-first-unread-article
1638 "," gnus-summary-best-unread-article
1639 "\M-s" gnus-summary-search-article-forward
1640 "\M-r" gnus-summary-search-article-backward
1641 "<" gnus-summary-beginning-of-article
1642 ">" gnus-summary-end-of-article
1643 "j" gnus-summary-goto-article
1644 "^" gnus-summary-refer-parent-article
1645 "\M-^" gnus-summary-refer-article
1646 "u" gnus-summary-tick-article-forward
1647 "!" gnus-summary-tick-article-forward
1648 "U" gnus-summary-tick-article-backward
1649 "d" gnus-summary-mark-as-read-forward
1650 "D" gnus-summary-mark-as-read-backward
1651 "E" gnus-summary-mark-as-expirable
1652 "\M-u" gnus-summary-clear-mark-forward
1653 "\M-U" gnus-summary-clear-mark-backward
1654 "k" gnus-summary-kill-same-subject-and-select
1655 "\C-k" gnus-summary-kill-same-subject
1656 "\M-\C-k" gnus-summary-kill-thread
1657 "\M-\C-l" gnus-summary-lower-thread
1658 "e" gnus-summary-edit-article
1659 "#" gnus-summary-mark-as-processable
1660 "\M-#" gnus-summary-unmark-as-processable
1661 "\M-\C-t" gnus-summary-toggle-threads
1662 "\M-\C-s" gnus-summary-show-thread
1663 "\M-\C-h" gnus-summary-hide-thread
1664 "\M-\C-f" gnus-summary-next-thread
1665 "\M-\C-b" gnus-summary-prev-thread
1666 [(meta down)] gnus-summary-next-thread
1667 [(meta up)] gnus-summary-prev-thread
1668 "\M-\C-u" gnus-summary-up-thread
1669 "\M-\C-d" gnus-summary-down-thread
1670 "&" gnus-summary-execute-command
1671 "c" gnus-summary-catchup-and-exit
1672 "\C-w" gnus-summary-mark-region-as-read
1673 "\C-t" gnus-summary-toggle-truncation
1674 "?" gnus-summary-mark-as-dormant
1675 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1676 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1677 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1678 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1679 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1680 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1681 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1682 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1683 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1684 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1685 "=" gnus-summary-expand-window
1686 "\C-x\C-s" gnus-summary-reselect-current-group
1687 "\M-g" gnus-summary-rescan-group
1688 "w" gnus-summary-stop-page-breaking
1689 "\C-c\C-r" gnus-summary-caesar-message
1690 "f" gnus-summary-followup
1691 "F" gnus-summary-followup-with-original
1692 "C" gnus-summary-cancel-article
1693 "r" gnus-summary-reply
1694 "R" gnus-summary-reply-with-original
1695 "\C-c\C-f" gnus-summary-mail-forward
1696 "o" gnus-summary-save-article
1697 "\C-o" gnus-summary-save-article-mail
1698 "|" gnus-summary-pipe-output
1699 "\M-k" gnus-summary-edit-local-kill
1700 "\M-K" gnus-summary-edit-global-kill
1701 ;; "V" gnus-version
1702 "\C-c\C-d" gnus-summary-describe-group
1703 "q" gnus-summary-exit
1704 "Q" gnus-summary-exit-no-update
1705 "\C-c\C-i" gnus-info-find-node
1706 gnus-mouse-2 gnus-mouse-pick-article
1707 [follow-link] mouse-face
1708 "m" gnus-summary-mail-other-window
1709 "a" gnus-summary-post-news
1710 "i" gnus-summary-news-other-window
1711 "x" gnus-summary-limit-to-unread
1712 "s" gnus-summary-isearch-article
1713 "t" gnus-summary-toggle-header
1714 "g" gnus-summary-show-article
1715 "l" gnus-summary-goto-last-article
1716 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1717 "\C-d" gnus-summary-enter-digest-group
1718 "\M-\C-d" gnus-summary-read-document
1719 "\M-\C-e" gnus-summary-edit-parameters
1720 "\M-\C-a" gnus-summary-customize-parameters
1721 "\C-c\C-b" gnus-bug
1722 "*" gnus-cache-enter-article
1723 "\M-*" gnus-cache-remove-article
1724 "\M-&" gnus-summary-universal-argument
1725 "\C-l" gnus-recenter
1726 "I" gnus-summary-increase-score
1727 "L" gnus-summary-lower-score
1728 "\M-i" gnus-symbolic-argument
1729 "h" gnus-summary-select-article-buffer
1730
1731 "b" gnus-article-view-part
1732 "\M-t" gnus-summary-toggle-display-buttonized
1733
1734 "V" gnus-summary-score-map
1735 "X" gnus-uu-extract-map
1736 "S" gnus-summary-send-map)
1737
1738 ;; Sort of orthogonal keymap
1739 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1740 "t" gnus-summary-tick-article-forward
1741 "!" gnus-summary-tick-article-forward
1742 "d" gnus-summary-mark-as-read-forward
1743 "r" gnus-summary-mark-as-read-forward
1744 "c" gnus-summary-clear-mark-forward
1745 " " gnus-summary-clear-mark-forward
1746 "e" gnus-summary-mark-as-expirable
1747 "x" gnus-summary-mark-as-expirable
1748 "?" gnus-summary-mark-as-dormant
1749 "b" gnus-summary-set-bookmark
1750 "B" gnus-summary-remove-bookmark
1751 "#" gnus-summary-mark-as-processable
1752 "\M-#" gnus-summary-unmark-as-processable
1753 "S" gnus-summary-limit-include-expunged
1754 "C" gnus-summary-catchup
1755 "H" gnus-summary-catchup-to-here
1756 "h" gnus-summary-catchup-from-here
1757 "\C-c" gnus-summary-catchup-all
1758 "k" gnus-summary-kill-same-subject-and-select
1759 "K" gnus-summary-kill-same-subject
1760 "P" gnus-uu-mark-map)
1761
1762 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1763 "c" gnus-summary-clear-above
1764 "u" gnus-summary-tick-above
1765 "m" gnus-summary-mark-above
1766 "k" gnus-summary-kill-below)
1767
1768 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1769 "/" gnus-summary-limit-to-subject
1770 "n" gnus-summary-limit-to-articles
1771 "w" gnus-summary-pop-limit
1772 "s" gnus-summary-limit-to-subject
1773 "a" gnus-summary-limit-to-author
1774 "u" gnus-summary-limit-to-unread
1775 "m" gnus-summary-limit-to-marks
1776 "M" gnus-summary-limit-exclude-marks
1777 "v" gnus-summary-limit-to-score
1778 "*" gnus-summary-limit-include-cached
1779 "D" gnus-summary-limit-include-dormant
1780 "T" gnus-summary-limit-include-thread
1781 "d" gnus-summary-limit-exclude-dormant
1782 "t" gnus-summary-limit-to-age
1783 "." gnus-summary-limit-to-unseen
1784 "x" gnus-summary-limit-to-extra
1785 "p" gnus-summary-limit-to-display-predicate
1786 "E" gnus-summary-limit-include-expunged
1787 "c" gnus-summary-limit-exclude-childless-dormant
1788 "C" gnus-summary-limit-mark-excluded-as-read
1789 "o" gnus-summary-insert-old-articles
1790 "N" gnus-summary-insert-new-articles)
1791
1792 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1793 "n" gnus-summary-next-unread-article
1794 "p" gnus-summary-prev-unread-article
1795 "N" gnus-summary-next-article
1796 "P" gnus-summary-prev-article
1797 "\C-n" gnus-summary-next-same-subject
1798 "\C-p" gnus-summary-prev-same-subject
1799 "\M-n" gnus-summary-next-unread-subject
1800 "\M-p" gnus-summary-prev-unread-subject
1801 "f" gnus-summary-first-unread-article
1802 "b" gnus-summary-best-unread-article
1803 "j" gnus-summary-goto-article
1804 "g" gnus-summary-goto-subject
1805 "l" gnus-summary-goto-last-article
1806 "o" gnus-summary-pop-article)
1807
1808 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1809 "k" gnus-summary-kill-thread
1810 "l" gnus-summary-lower-thread
1811 "i" gnus-summary-raise-thread
1812 "T" gnus-summary-toggle-threads
1813 "t" gnus-summary-rethread-current
1814 "^" gnus-summary-reparent-thread
1815 "s" gnus-summary-show-thread
1816 "S" gnus-summary-show-all-threads
1817 "h" gnus-summary-hide-thread
1818 "H" gnus-summary-hide-all-threads
1819 "n" gnus-summary-next-thread
1820 "p" gnus-summary-prev-thread
1821 "u" gnus-summary-up-thread
1822 "o" gnus-summary-top-thread
1823 "d" gnus-summary-down-thread
1824 "#" gnus-uu-mark-thread
1825 "\M-#" gnus-uu-unmark-thread)
1826
1827 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1828 "g" gnus-summary-prepare
1829 "c" gnus-summary-insert-cached-articles
1830 "d" gnus-summary-insert-dormant-articles)
1831
1832 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1833 "c" gnus-summary-catchup-and-exit
1834 "C" gnus-summary-catchup-all-and-exit
1835 "E" gnus-summary-exit-no-update
1836 "Q" gnus-summary-exit
1837 "Z" gnus-summary-exit
1838 "n" gnus-summary-catchup-and-goto-next-group
1839 "R" gnus-summary-reselect-current-group
1840 "G" gnus-summary-rescan-group
1841 "N" gnus-summary-next-group
1842 "s" gnus-summary-save-newsrc
1843 "P" gnus-summary-prev-group)
1844
1845 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1846 " " gnus-summary-next-page
1847 "n" gnus-summary-next-page
1848 "\177" gnus-summary-prev-page
1849 [delete] gnus-summary-prev-page
1850 "p" gnus-summary-prev-page
1851 "\r" gnus-summary-scroll-up
1852 "\M-\r" gnus-summary-scroll-down
1853 "<" gnus-summary-beginning-of-article
1854 ">" gnus-summary-end-of-article
1855 "b" gnus-summary-beginning-of-article
1856 "e" gnus-summary-end-of-article
1857 "^" gnus-summary-refer-parent-article
1858 "r" gnus-summary-refer-parent-article
1859 "D" gnus-summary-enter-digest-group
1860 "R" gnus-summary-refer-references
1861 "T" gnus-summary-refer-thread
1862 "g" gnus-summary-show-article
1863 "s" gnus-summary-isearch-article
1864 "P" gnus-summary-print-article
1865 "M" gnus-mailing-list-insinuate
1866 "t" gnus-article-babel)
1867
1868 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1869 "b" gnus-article-add-buttons
1870 "B" gnus-article-add-buttons-to-head
1871 "o" gnus-article-treat-overstrike
1872 "e" gnus-article-emphasize
1873 "w" gnus-article-fill-cited-article
1874 "Q" gnus-article-fill-long-lines
1875 "C" gnus-article-capitalize-sentences
1876 "c" gnus-article-remove-cr
1877 "q" gnus-article-de-quoted-unreadable
1878 "6" gnus-article-de-base64-unreadable
1879 "Z" gnus-article-decode-HZ
1880 "h" gnus-article-wash-html
1881 "u" gnus-article-unsplit-urls
1882 "s" gnus-summary-force-verify-and-decrypt
1883 "f" gnus-article-display-x-face
1884 "l" gnus-summary-stop-page-breaking
1885 "r" gnus-summary-caesar-message
1886 "m" gnus-summary-morse-message
1887 "t" gnus-summary-toggle-header
1888 "g" gnus-treat-smiley
1889 "v" gnus-summary-verbose-headers
1890 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1891 "p" gnus-article-verify-x-pgp-sig
1892 "d" gnus-article-treat-dumbquotes)
1893
1894 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1895 ;; mnemonic: deuglif*Y*
1896 "u" gnus-article-outlook-unwrap-lines
1897 "a" gnus-article-outlook-repair-attribution
1898 "c" gnus-article-outlook-rearrange-citation
1899 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1900
1901 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1902 "a" gnus-article-hide
1903 "h" gnus-article-hide-headers
1904 "b" gnus-article-hide-boring-headers
1905 "s" gnus-article-hide-signature
1906 "c" gnus-article-hide-citation
1907 "C" gnus-article-hide-citation-in-followups
1908 "l" gnus-article-hide-list-identifiers
1909 "B" gnus-article-strip-banner
1910 "P" gnus-article-hide-pem
1911 "\C-c" gnus-article-hide-citation-maybe)
1912
1913 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1914 "a" gnus-article-highlight
1915 "h" gnus-article-highlight-headers
1916 "c" gnus-article-highlight-citation
1917 "s" gnus-article-highlight-signature)
1918
1919 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1920 "f" gnus-article-treat-fold-headers
1921 "u" gnus-article-treat-unfold-headers
1922 "n" gnus-article-treat-fold-newsgroups)
1923
1924 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1925 "x" gnus-article-display-x-face
1926 "d" gnus-article-display-face
1927 "s" gnus-treat-smiley
1928 "D" gnus-article-remove-images
1929 "f" gnus-treat-from-picon
1930 "m" gnus-treat-mail-picon
1931 "n" gnus-treat-newsgroups-picon)
1932
1933 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1934 "w" gnus-article-decode-mime-words
1935 "c" gnus-article-decode-charset
1936 "v" gnus-mime-view-all-parts
1937 "b" gnus-article-view-part)
1938
1939 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1940 "z" gnus-article-date-ut
1941 "u" gnus-article-date-ut
1942 "l" gnus-article-date-local
1943 "p" gnus-article-date-english
1944 "e" gnus-article-date-lapsed
1945 "o" gnus-article-date-original
1946 "i" gnus-article-date-iso8601
1947 "s" gnus-article-date-user)
1948
1949 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1950 "t" gnus-article-remove-trailing-blank-lines
1951 "l" gnus-article-strip-leading-blank-lines
1952 "m" gnus-article-strip-multiple-blank-lines
1953 "a" gnus-article-strip-blank-lines
1954 "A" gnus-article-strip-all-blank-lines
1955 "s" gnus-article-strip-leading-space
1956 "e" gnus-article-strip-trailing-space
1957 "w" gnus-article-remove-leading-whitespace)
1958
1959 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1960 "v" gnus-version
1961 "f" gnus-summary-fetch-faq
1962 "d" gnus-summary-describe-group
1963 "h" gnus-summary-describe-briefly
1964 "i" gnus-info-find-node
1965 "c" gnus-group-fetch-charter
1966 "C" gnus-group-fetch-control)
1967
1968 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1969 "e" gnus-summary-expire-articles
1970 "\M-\C-e" gnus-summary-expire-articles-now
1971 "\177" gnus-summary-delete-article
1972 [delete] gnus-summary-delete-article
1973 [backspace] gnus-summary-delete-article
1974 "m" gnus-summary-move-article
1975 "r" gnus-summary-respool-article
1976 "w" gnus-summary-edit-article
1977 "c" gnus-summary-copy-article
1978 "B" gnus-summary-crosspost-article
1979 "q" gnus-summary-respool-query
1980 "t" gnus-summary-respool-trace
1981 "i" gnus-summary-import-article
1982 "I" gnus-summary-create-article
1983 "p" gnus-summary-article-posted-p)
1984
1985 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1986 "o" gnus-summary-save-article
1987 "m" gnus-summary-save-article-mail
1988 "F" gnus-summary-write-article-file
1989 "r" gnus-summary-save-article-rmail
1990 "f" gnus-summary-save-article-file
1991 "b" gnus-summary-save-article-body-file
1992 "h" gnus-summary-save-article-folder
1993 "v" gnus-summary-save-article-vm
1994 "p" gnus-summary-pipe-output
1995 "P" gnus-summary-muttprint
1996 "s" gnus-soup-add-article)
1997
1998 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1999 "b" gnus-summary-display-buttonized
2000 "m" gnus-summary-repair-multipart
2001 "v" gnus-article-view-part
2002 "o" gnus-article-save-part
2003 "c" gnus-article-copy-part
2004 "C" gnus-article-view-part-as-charset
2005 "e" gnus-article-view-part-externally
2006 "E" gnus-article-encrypt-body
2007 "i" gnus-article-inline-part
2008 "|" gnus-article-pipe-part)
2009
2010 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2011 "p" gnus-summary-mark-as-processable
2012 "u" gnus-summary-unmark-as-processable
2013 "U" gnus-summary-unmark-all-processable
2014 "v" gnus-uu-mark-over
2015 "s" gnus-uu-mark-series
2016 "r" gnus-uu-mark-region
2017 "g" gnus-uu-unmark-region
2018 "R" gnus-uu-mark-by-regexp
2019 "G" gnus-uu-unmark-by-regexp
2020 "t" gnus-uu-mark-thread
2021 "T" gnus-uu-unmark-thread
2022 "a" gnus-uu-mark-all
2023 "b" gnus-uu-mark-buffer
2024 "S" gnus-uu-mark-sparse
2025 "k" gnus-summary-kill-process-mark
2026 "y" gnus-summary-yank-process-mark
2027 "w" gnus-summary-save-process-mark
2028 "i" gnus-uu-invert-processable)
2029
2030 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2031 ;;"x" gnus-uu-extract-any
2032 "m" gnus-summary-save-parts
2033 "u" gnus-uu-decode-uu
2034 "U" gnus-uu-decode-uu-and-save
2035 "s" gnus-uu-decode-unshar
2036 "S" gnus-uu-decode-unshar-and-save
2037 "o" gnus-uu-decode-save
2038 "O" gnus-uu-decode-save
2039 "b" gnus-uu-decode-binhex
2040 "B" gnus-uu-decode-binhex
2041 "p" gnus-uu-decode-postscript
2042 "P" gnus-uu-decode-postscript-and-save)
2043
2044 (gnus-define-keys
2045 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2046 "u" gnus-uu-decode-uu-view
2047 "U" gnus-uu-decode-uu-and-save-view
2048 "s" gnus-uu-decode-unshar-view
2049 "S" gnus-uu-decode-unshar-and-save-view
2050 "o" gnus-uu-decode-save-view
2051 "O" gnus-uu-decode-save-view
2052 "b" gnus-uu-decode-binhex-view
2053 "B" gnus-uu-decode-binhex-view
2054 "p" gnus-uu-decode-postscript-view
2055 "P" gnus-uu-decode-postscript-and-save-view)
2056
2057 (defvar gnus-article-post-menu nil)
2058
2059 (defconst gnus-summary-menu-maxlen 20)
2060
2061 (defun gnus-summary-menu-split (menu)
2062 ;; If we have lots of elements, divide them into groups of 20
2063 ;; and make a pane (or submenu) for each one.
2064 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2065 (let ((menu menu) sublists next
2066 (i 1))
2067 (while menu
2068 ;; Pull off the next gnus-summary-menu-maxlen elements
2069 ;; and make them the next element of sublist.
2070 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2071 (if next
2072 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2073 nil))
2074 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2075 (aref (car (last menu)) 0)) menu)
2076 sublists))
2077 (setq i (1+ i))
2078 (setq menu next))
2079 (nreverse sublists))
2080 ;; Few elements--put them all in one pane.
2081 menu))
2082
2083 (defun gnus-summary-make-menu-bar ()
2084 (gnus-turn-off-edit-menu 'summary)
2085
2086 (unless (boundp 'gnus-summary-misc-menu)
2087
2088 (easy-menu-define
2089 gnus-summary-kill-menu gnus-summary-mode-map ""
2090 (cons
2091 "Score"
2092 (nconc
2093 (list
2094 ["Customize" gnus-score-customize t])
2095 (gnus-make-score-map 'increase)
2096 (gnus-make-score-map 'lower)
2097 '(("Mark"
2098 ["Kill below" gnus-summary-kill-below t]
2099 ["Mark above" gnus-summary-mark-above t]
2100 ["Tick above" gnus-summary-tick-above t]
2101 ["Clear above" gnus-summary-clear-above t])
2102 ["Current score" gnus-summary-current-score t]
2103 ["Set score" gnus-summary-set-score t]
2104 ["Switch current score file..." gnus-score-change-score-file t]
2105 ["Set mark below..." gnus-score-set-mark-below t]
2106 ["Set expunge below..." gnus-score-set-expunge-below t]
2107 ["Edit current score file" gnus-score-edit-current-scores t]
2108 ["Edit score file" gnus-score-edit-file t]
2109 ["Trace score" gnus-score-find-trace t]
2110 ["Find words" gnus-score-find-favourite-words t]
2111 ["Rescore buffer" gnus-summary-rescore t]
2112 ["Increase score..." gnus-summary-increase-score t]
2113 ["Lower score..." gnus-summary-lower-score t]))))
2114
2115 ;; Define both the Article menu in the summary buffer and the
2116 ;; equivalent Commands menu in the article buffer here for
2117 ;; consistency.
2118 (let ((innards
2119 `(("Hide"
2120 ["All" gnus-article-hide t]
2121 ["Headers" gnus-article-hide-headers t]
2122 ["Signature" gnus-article-hide-signature t]
2123 ["Citation" gnus-article-hide-citation t]
2124 ["List identifiers" gnus-article-hide-list-identifiers t]
2125 ["Banner" gnus-article-strip-banner t]
2126 ["Boring headers" gnus-article-hide-boring-headers t])
2127 ("Highlight"
2128 ["All" gnus-article-highlight t]
2129 ["Headers" gnus-article-highlight-headers t]
2130 ["Signature" gnus-article-highlight-signature t]
2131 ["Citation" gnus-article-highlight-citation t])
2132 ("MIME"
2133 ["Words" gnus-article-decode-mime-words t]
2134 ["Charset" gnus-article-decode-charset t]
2135 ["QP" gnus-article-de-quoted-unreadable t]
2136 ["Base64" gnus-article-de-base64-unreadable t]
2137 ["View MIME buttons" gnus-summary-display-buttonized t]
2138 ["View all" gnus-mime-view-all-parts t]
2139 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2140 ["Encrypt body" gnus-article-encrypt-body
2141 :active (not (gnus-group-read-only-p))
2142 ,@(if (featurep 'xemacs) nil
2143 '(:help "Encrypt the message body on disk"))]
2144 ["Extract all parts..." gnus-summary-save-parts t]
2145 ("Multipart"
2146 ["Repair multipart" gnus-summary-repair-multipart t]
2147 ["Pipe part..." gnus-article-pipe-part t]
2148 ["Inline part" gnus-article-inline-part t]
2149 ["Encrypt body" gnus-article-encrypt-body
2150 :active (not (gnus-group-read-only-p))
2151 ,@(if (featurep 'xemacs) nil
2152 '(:help "Encrypt the message body on disk"))]
2153 ["View part externally" gnus-article-view-part-externally t]
2154 ["View part with charset..." gnus-article-view-part-as-charset t]
2155 ["Copy part" gnus-article-copy-part t]
2156 ["Save part..." gnus-article-save-part t]
2157 ["View part" gnus-article-view-part t]))
2158 ("Date"
2159 ["Local" gnus-article-date-local t]
2160 ["ISO8601" gnus-article-date-iso8601 t]
2161 ["UT" gnus-article-date-ut t]
2162 ["Original" gnus-article-date-original t]
2163 ["Lapsed" gnus-article-date-lapsed t]
2164 ["User-defined" gnus-article-date-user t])
2165 ("Display"
2166 ["Remove images" gnus-article-remove-images t]
2167 ["Toggle smiley" gnus-treat-smiley t]
2168 ["Show X-Face" gnus-article-display-x-face t]
2169 ["Show picons in From" gnus-treat-from-picon t]
2170 ["Show picons in mail headers" gnus-treat-mail-picon t]
2171 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2172 ("View as different encoding"
2173 ,@(gnus-summary-menu-split
2174 (mapcar
2175 (lambda (cs)
2176 ;; Since easymenu under Emacs doesn't allow
2177 ;; lambda forms for menu commands, we should
2178 ;; provide intern'ed function symbols.
2179 (let ((command (intern (format "\
2180 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2181 (fset command
2182 `(lambda ()
2183 (interactive)
2184 (let ((gnus-summary-show-article-charset-alist
2185 '((1 . ,cs))))
2186 (gnus-summary-show-article 1))))
2187 `[,(symbol-name cs) ,command t]))
2188 (sort (if (fboundp 'coding-system-list)
2189 (coding-system-list)
2190 (mapcar 'car mm-mime-mule-charset-alist))
2191 'string<)))))
2192 ("Washing"
2193 ("Remove Blanks"
2194 ["Leading" gnus-article-strip-leading-blank-lines t]
2195 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2196 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2197 ["All of the above" gnus-article-strip-blank-lines t]
2198 ["All" gnus-article-strip-all-blank-lines t]
2199 ["Leading space" gnus-article-strip-leading-space t]
2200 ["Trailing space" gnus-article-strip-trailing-space t]
2201 ["Leading space in headers"
2202 gnus-article-remove-leading-whitespace t])
2203 ["Overstrike" gnus-article-treat-overstrike t]
2204 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2205 ["Emphasis" gnus-article-emphasize t]
2206 ["Word wrap" gnus-article-fill-cited-article t]
2207 ["Fill long lines" gnus-article-fill-long-lines t]
2208 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2209 ["Remove CR" gnus-article-remove-cr t]
2210 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2211 ["Base64" gnus-article-de-base64-unreadable t]
2212 ["Rot 13" gnus-summary-caesar-message
2213 ,@(if (featurep 'xemacs) '(t)
2214 '(:help "\"Caesar rotate\" article by 13"))]
2215 ["Morse decode" gnus-summary-morse-message t]
2216 ["Unix pipe..." gnus-summary-pipe-message t]
2217 ["Add buttons" gnus-article-add-buttons t]
2218 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2219 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2220 ["Verbose header" gnus-summary-verbose-headers t]
2221 ["Toggle header" gnus-summary-toggle-header t]
2222 ["Unfold headers" gnus-article-treat-unfold-headers t]
2223 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2224 ["Html" gnus-article-wash-html t]
2225 ["Unsplit URLs" gnus-article-unsplit-urls t]
2226 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2227 ["Decode HZ" gnus-article-decode-HZ t]
2228 ("(Outlook) Deuglify"
2229 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2230 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2231 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2232 ["Full (Outlook) deuglify"
2233 gnus-article-outlook-deuglify-article t])
2234 )
2235 ("Output"
2236 ["Save in default format..." gnus-summary-save-article
2237 ,@(if (featurep 'xemacs) '(t)
2238 '(:help "Save article using default method"))]
2239 ["Save in file..." gnus-summary-save-article-file
2240 ,@(if (featurep 'xemacs) '(t)
2241 '(:help "Save article in file"))]
2242 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2243 ["Save in MH folder..." gnus-summary-save-article-folder t]
2244 ["Save in VM folder..." gnus-summary-save-article-vm t]
2245 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2246 ["Save body in file..." gnus-summary-save-article-body-file t]
2247 ["Pipe through a filter..." gnus-summary-pipe-output t]
2248 ["Add to SOUP packet" gnus-soup-add-article t]
2249 ["Print with Muttprint..." gnus-summary-muttprint t]
2250 ["Print" gnus-summary-print-article
2251 ,@(if (featurep 'xemacs) '(t)
2252 '(:help "Generate and print a PostScript image"))])
2253 ("Copy, move,... (Backend)"
2254 ,@(if (featurep 'xemacs) nil
2255 '(:help "Copying, moving, expiring articles..."))
2256 ["Respool article..." gnus-summary-respool-article t]
2257 ["Move article..." gnus-summary-move-article
2258 (gnus-check-backend-function
2259 'request-move-article gnus-newsgroup-name)]
2260 ["Copy article..." gnus-summary-copy-article t]
2261 ["Crosspost article..." gnus-summary-crosspost-article
2262 (gnus-check-backend-function
2263 'request-replace-article gnus-newsgroup-name)]
2264 ["Import file..." gnus-summary-import-article
2265 (gnus-check-backend-function
2266 'request-accept-article gnus-newsgroup-name)]
2267 ["Create article..." gnus-summary-create-article
2268 (gnus-check-backend-function
2269 'request-accept-article gnus-newsgroup-name)]
2270 ["Check if posted" gnus-summary-article-posted-p t]
2271 ["Edit article" gnus-summary-edit-article
2272 (not (gnus-group-read-only-p))]
2273 ["Delete article" gnus-summary-delete-article
2274 (gnus-check-backend-function
2275 'request-expire-articles gnus-newsgroup-name)]
2276 ["Query respool" gnus-summary-respool-query t]
2277 ["Trace respool" gnus-summary-respool-trace t]
2278 ["Delete expirable articles" gnus-summary-expire-articles-now
2279 (gnus-check-backend-function
2280 'request-expire-articles gnus-newsgroup-name)])
2281 ("Extract"
2282 ["Uudecode" gnus-uu-decode-uu
2283 ,@(if (featurep 'xemacs) '(t)
2284 '(:help "Decode uuencoded article(s)"))]
2285 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2286 ["Unshar" gnus-uu-decode-unshar t]
2287 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2288 ["Save" gnus-uu-decode-save t]
2289 ["Binhex" gnus-uu-decode-binhex t]
2290 ["Postscript" gnus-uu-decode-postscript t]
2291 ["All MIME parts" gnus-summary-save-parts t])
2292 ("Cache"
2293 ["Enter article" gnus-cache-enter-article t]
2294 ["Remove article" gnus-cache-remove-article t])
2295 ["Translate" gnus-article-babel t]
2296 ["Select article buffer" gnus-summary-select-article-buffer t]
2297 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2298 ["Isearch article..." gnus-summary-isearch-article t]
2299 ["Beginning of the article" gnus-summary-beginning-of-article t]
2300 ["End of the article" gnus-summary-end-of-article t]
2301 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2302 ["Fetch referenced articles" gnus-summary-refer-references t]
2303 ["Fetch current thread" gnus-summary-refer-thread t]
2304 ["Fetch article with id..." gnus-summary-refer-article t]
2305 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2306 ["Redisplay" gnus-summary-show-article t]
2307 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2308 (easy-menu-define
2309 gnus-summary-article-menu gnus-summary-mode-map ""
2310 (cons "Article" innards))
2311
2312 (if (not (keymapp gnus-summary-article-menu))
2313 (easy-menu-define
2314 gnus-article-commands-menu gnus-article-mode-map ""
2315 (cons "Commands" innards))
2316 ;; in Emacs, don't share menu.
2317 (setq gnus-article-commands-menu
2318 (copy-keymap gnus-summary-article-menu))
2319 (define-key gnus-article-mode-map [menu-bar commands]
2320 (cons "Commands" gnus-article-commands-menu))))
2321
2322 (easy-menu-define
2323 gnus-summary-thread-menu gnus-summary-mode-map ""
2324 '("Threads"
2325 ["Find all messages in thread" gnus-summary-refer-thread t]
2326 ["Toggle threading" gnus-summary-toggle-threads t]
2327 ["Hide threads" gnus-summary-hide-all-threads t]
2328 ["Show threads" gnus-summary-show-all-threads t]
2329 ["Hide thread" gnus-summary-hide-thread t]
2330 ["Show thread" gnus-summary-show-thread t]
2331 ["Go to next thread" gnus-summary-next-thread t]
2332 ["Go to previous thread" gnus-summary-prev-thread t]
2333 ["Go down thread" gnus-summary-down-thread t]
2334 ["Go up thread" gnus-summary-up-thread t]
2335 ["Top of thread" gnus-summary-top-thread t]
2336 ["Mark thread as read" gnus-summary-kill-thread t]
2337 ["Lower thread score" gnus-summary-lower-thread t]
2338 ["Raise thread score" gnus-summary-raise-thread t]
2339 ["Rethread current" gnus-summary-rethread-current t]))
2340
2341 (easy-menu-define
2342 gnus-summary-post-menu gnus-summary-mode-map ""
2343 `("Post"
2344 ["Send a message (mail or news)" gnus-summary-post-news
2345 ,@(if (featurep 'xemacs) '(t)
2346 '(:help "Compose a new message (mail or news)"))]
2347 ["Followup" gnus-summary-followup
2348 ,@(if (featurep 'xemacs) '(t)
2349 '(:help "Post followup to this article"))]
2350 ["Followup and yank" gnus-summary-followup-with-original
2351 ,@(if (featurep 'xemacs) '(t)
2352 '(:help "Post followup to this article, quoting its contents"))]
2353 ["Supersede article" gnus-summary-supersede-article t]
2354 ["Cancel article" gnus-summary-cancel-article
2355 ,@(if (featurep 'xemacs) '(t)
2356 '(:help "Cancel an article you posted"))]
2357 ["Reply" gnus-summary-reply t]
2358 ["Reply and yank" gnus-summary-reply-with-original t]
2359 ["Wide reply" gnus-summary-wide-reply t]
2360 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2361 ,@(if (featurep 'xemacs) '(t)
2362 '(:help "Mail a reply, quoting this article"))]
2363 ["Very wide reply" gnus-summary-very-wide-reply t]
2364 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2365 ,@(if (featurep 'xemacs) '(t)
2366 '(:help "Mail a very wide reply, quoting this article"))]
2367 ["Mail forward" gnus-summary-mail-forward t]
2368 ["Post forward" gnus-summary-post-forward t]
2369 ["Digest and mail" gnus-uu-digest-mail-forward t]
2370 ["Digest and post" gnus-uu-digest-post-forward t]
2371 ["Resend message" gnus-summary-resend-message t]
2372 ["Resend message edit" gnus-summary-resend-message-edit t]
2373 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2374 ["Send a mail" gnus-summary-mail-other-window t]
2375 ["Create a local message" gnus-summary-news-other-window t]
2376 ["Uuencode and post" gnus-uu-post-news
2377 ,@(if (featurep 'xemacs) '(t)
2378 '(:help "Post a uuencoded article"))]
2379 ["Followup via news" gnus-summary-followup-to-mail t]
2380 ["Followup via news and yank"
2381 gnus-summary-followup-to-mail-with-original t]
2382 ;;("Draft"
2383 ;;["Send" gnus-summary-send-draft t]
2384 ;;["Send bounced" gnus-resend-bounced-mail t])
2385 ))
2386
2387 (cond
2388 ((not (keymapp gnus-summary-post-menu))
2389 (setq gnus-article-post-menu gnus-summary-post-menu))
2390 ((not gnus-article-post-menu)
2391 ;; Don't share post menu.
2392 (setq gnus-article-post-menu
2393 (copy-keymap gnus-summary-post-menu))))
2394 (define-key gnus-article-mode-map [menu-bar post]
2395 (cons "Post" gnus-article-post-menu))
2396
2397 (easy-menu-define
2398 gnus-summary-misc-menu gnus-summary-mode-map ""
2399 `("Gnus"
2400 ("Mark Read"
2401 ["Mark as read" gnus-summary-mark-as-read-forward t]
2402 ["Mark same subject and select"
2403 gnus-summary-kill-same-subject-and-select t]
2404 ["Mark same subject" gnus-summary-kill-same-subject t]
2405 ["Catchup" gnus-summary-catchup
2406 ,@(if (featurep 'xemacs) '(t)
2407 '(:help "Mark unread articles in this group as read"))]
2408 ["Catchup all" gnus-summary-catchup-all t]
2409 ["Catchup to here" gnus-summary-catchup-to-here t]
2410 ["Catchup from here" gnus-summary-catchup-from-here t]
2411 ["Catchup region" gnus-summary-mark-region-as-read
2412 (gnus-mark-active-p)]
2413 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2414 ("Mark Various"
2415 ["Tick" gnus-summary-tick-article-forward t]
2416 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2417 ["Remove marks" gnus-summary-clear-mark-forward t]
2418 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2419 ["Set bookmark" gnus-summary-set-bookmark t]
2420 ["Remove bookmark" gnus-summary-remove-bookmark t])
2421 ("Limit to"
2422 ["Marks..." gnus-summary-limit-to-marks t]
2423 ["Subject..." gnus-summary-limit-to-subject t]
2424 ["Author..." gnus-summary-limit-to-author t]
2425 ["Age..." gnus-summary-limit-to-age t]
2426 ["Extra..." gnus-summary-limit-to-extra t]
2427 ["Score..." gnus-summary-limit-to-score t]
2428 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2429 ["Unread" gnus-summary-limit-to-unread t]
2430 ["Unseen" gnus-summary-limit-to-unseen t]
2431 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2432 ["Next articles" gnus-summary-limit-to-articles t]
2433 ["Pop limit" gnus-summary-pop-limit t]
2434 ["Show dormant" gnus-summary-limit-include-dormant t]
2435 ["Hide childless dormant"
2436 gnus-summary-limit-exclude-childless-dormant t]
2437 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2438 ["Hide marked" gnus-summary-limit-exclude-marks t]
2439 ["Show expunged" gnus-summary-limit-include-expunged t])
2440 ("Process Mark"
2441 ["Set mark" gnus-summary-mark-as-processable t]
2442 ["Remove mark" gnus-summary-unmark-as-processable t]
2443 ["Remove all marks" gnus-summary-unmark-all-processable t]
2444 ["Mark above" gnus-uu-mark-over t]
2445 ["Mark series" gnus-uu-mark-series t]
2446 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2447 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2448 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2449 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2450 ["Mark all" gnus-uu-mark-all t]
2451 ["Mark buffer" gnus-uu-mark-buffer t]
2452 ["Mark sparse" gnus-uu-mark-sparse t]
2453 ["Mark thread" gnus-uu-mark-thread t]
2454 ["Unmark thread" gnus-uu-unmark-thread t]
2455 ("Process Mark Sets"
2456 ["Kill" gnus-summary-kill-process-mark t]
2457 ["Yank" gnus-summary-yank-process-mark
2458 gnus-newsgroup-process-stack]
2459 ["Save" gnus-summary-save-process-mark t]
2460 ["Run command on marked..." gnus-summary-universal-argument t]))
2461 ("Scroll article"
2462 ["Page forward" gnus-summary-next-page
2463 ,@(if (featurep 'xemacs) '(t)
2464 '(:help "Show next page of article"))]
2465 ["Page backward" gnus-summary-prev-page
2466 ,@(if (featurep 'xemacs) '(t)
2467 '(:help "Show previous page of article"))]
2468 ["Line forward" gnus-summary-scroll-up t])
2469 ("Move"
2470 ["Next unread article" gnus-summary-next-unread-article t]
2471 ["Previous unread article" gnus-summary-prev-unread-article t]
2472 ["Next article" gnus-summary-next-article t]
2473 ["Previous article" gnus-summary-prev-article t]
2474 ["Next unread subject" gnus-summary-next-unread-subject t]
2475 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2476 ["Next article same subject" gnus-summary-next-same-subject t]
2477 ["Previous article same subject" gnus-summary-prev-same-subject t]
2478 ["First unread article" gnus-summary-first-unread-article t]
2479 ["Best unread article" gnus-summary-best-unread-article t]
2480 ["Go to subject number..." gnus-summary-goto-subject t]
2481 ["Go to article number..." gnus-summary-goto-article t]
2482 ["Go to the last article" gnus-summary-goto-last-article t]
2483 ["Pop article off history" gnus-summary-pop-article t])
2484 ("Sort"
2485 ["Sort by number" gnus-summary-sort-by-number t]
2486 ["Sort by author" gnus-summary-sort-by-author t]
2487 ["Sort by subject" gnus-summary-sort-by-subject t]
2488 ["Sort by date" gnus-summary-sort-by-date t]
2489 ["Sort by score" gnus-summary-sort-by-score t]
2490 ["Sort by lines" gnus-summary-sort-by-lines t]
2491 ["Sort by characters" gnus-summary-sort-by-chars t]
2492 ["Randomize" gnus-summary-sort-by-random t]
2493 ["Original sort" gnus-summary-sort-by-original t])
2494 ("Help"
2495 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2496 ["Describe group" gnus-summary-describe-group t]
2497 ["Fetch charter" gnus-group-fetch-charter
2498 ,@(if (featurep 'xemacs) nil
2499 '(:help "Display the charter of the current group"))]
2500 ["Fetch control message" gnus-group-fetch-control
2501 ,@(if (featurep 'xemacs) nil
2502 '(:help "Display the archived control message for the current group"))]
2503 ["Read manual" gnus-info-find-node t])
2504 ("Modes"
2505 ["Pick and read" gnus-pick-mode t]
2506 ["Binary" gnus-binary-mode t])
2507 ("Regeneration"
2508 ["Regenerate" gnus-summary-prepare t]
2509 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2510 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2511 ["Toggle threading" gnus-summary-toggle-threads t])
2512 ["See old articles" gnus-summary-insert-old-articles t]
2513 ["See new articles" gnus-summary-insert-new-articles t]
2514 ["Filter articles..." gnus-summary-execute-command t]
2515 ["Run command on articles..." gnus-summary-universal-argument t]
2516 ["Search articles forward..." gnus-summary-search-article-forward t]
2517 ["Search articles backward..." gnus-summary-search-article-backward t]
2518 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2519 ["Expand window" gnus-summary-expand-window t]
2520 ["Expire expirable articles" gnus-summary-expire-articles
2521 (gnus-check-backend-function
2522 'request-expire-articles gnus-newsgroup-name)]
2523 ["Edit local kill file" gnus-summary-edit-local-kill t]
2524 ["Edit main kill file" gnus-summary-edit-global-kill t]
2525 ["Edit group parameters" gnus-summary-edit-parameters t]
2526 ["Customize group parameters" gnus-summary-customize-parameters t]
2527 ["Send a bug report" gnus-bug t]
2528 ("Exit"
2529 ["Catchup and exit" gnus-summary-catchup-and-exit
2530 ,@(if (featurep 'xemacs) '(t)
2531 '(:help "Mark unread articles in this group as read, then exit"))]
2532 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2533 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2534 ["Exit group" gnus-summary-exit
2535 ,@(if (featurep 'xemacs) '(t)
2536 '(:help "Exit current group, return to group selection mode"))]
2537 ["Exit group without updating" gnus-summary-exit-no-update t]
2538 ["Exit and goto next group" gnus-summary-next-group t]
2539 ["Exit and goto prev group" gnus-summary-prev-group t]
2540 ["Reselect group" gnus-summary-reselect-current-group t]
2541 ["Rescan group" gnus-summary-rescan-group t]
2542 ["Update dribble" gnus-summary-save-newsrc t])))
2543
2544 (gnus-run-hooks 'gnus-summary-menu-hook)))
2545
2546 (defvar gnus-summary-tool-bar-map nil)
2547
2548 ;; Emacs 21 tool bar. Should be no-op otherwise.
2549 (defun gnus-summary-make-tool-bar ()
2550 (if (and (fboundp 'tool-bar-add-item-from-menu)
2551 (default-value 'tool-bar-mode)
2552 (not gnus-summary-tool-bar-map))
2553 (setq gnus-summary-tool-bar-map
2554 (let ((tool-bar-map (make-sparse-keymap))
2555 (load-path (mm-image-load-path)))
2556 (tool-bar-add-item-from-menu
2557 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2558 (tool-bar-add-item-from-menu
2559 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2560 (tool-bar-add-item-from-menu
2561 'gnus-summary-post-news "post" gnus-summary-mode-map)
2562 (tool-bar-add-item-from-menu
2563 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2564 (tool-bar-add-item-from-menu
2565 'gnus-summary-followup "followup" gnus-summary-mode-map)
2566 (tool-bar-add-item-from-menu
2567 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2568 (tool-bar-add-item-from-menu
2569 'gnus-summary-reply "reply" gnus-summary-mode-map)
2570 (tool-bar-add-item-from-menu
2571 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2572 (tool-bar-add-item-from-menu
2573 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2574 (tool-bar-add-item-from-menu
2575 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2576 (tool-bar-add-item-from-menu
2577 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2578 (tool-bar-add-item-from-menu
2579 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2580 (tool-bar-add-item-from-menu
2581 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2582 (tool-bar-add-item-from-menu
2583 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2584 (tool-bar-add-item-from-menu
2585 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2586 tool-bar-map)))
2587 (if gnus-summary-tool-bar-map
2588 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2589
2590 (defun gnus-score-set-default (var value)
2591 "A version of set that updates the GNU Emacs menu-bar."
2592 (set var value)
2593 ;; It is the message that forces the active status to be updated.
2594 (message ""))
2595
2596 (defun gnus-make-score-map (type)
2597 "Make a summary score map of type TYPE."
2598 (if t
2599 nil
2600 (let ((headers '(("author" "from" string)
2601 ("subject" "subject" string)
2602 ("article body" "body" string)
2603 ("article head" "head" string)
2604 ("xref" "xref" string)
2605 ("extra header" "extra" string)
2606 ("lines" "lines" number)
2607 ("followups to author" "followup" string)))
2608 (types '((number ("less than" <)
2609 ("greater than" >)
2610 ("equal" =))
2611 (string ("substring" s)
2612 ("exact string" e)
2613 ("fuzzy string" f)
2614 ("regexp" r))))
2615 (perms '(("temporary" (current-time-string))
2616 ("permanent" nil)
2617 ("immediate" now)))
2618 header)
2619 (list
2620 (apply
2621 'nconc
2622 (list
2623 (if (eq type 'lower)
2624 "Lower score"
2625 "Increase score"))
2626 (let (outh)
2627 (while headers
2628 (setq header (car headers))
2629 (setq outh
2630 (cons
2631 (apply
2632 'nconc
2633 (list (car header))
2634 (let ((ts (cdr (assoc (nth 2 header) types)))
2635 outt)
2636 (while ts
2637 (setq outt
2638 (cons
2639 (apply
2640 'nconc
2641 (list (caar ts))
2642 (let ((ps perms)
2643 outp)
2644 (while ps
2645 (setq outp
2646 (cons
2647 (vector
2648 (caar ps)
2649 (list
2650 'gnus-summary-score-entry
2651 (nth 1 header)
2652 (if (or (string= (nth 1 header)
2653 "head")
2654 (string= (nth 1 header)
2655 "body"))
2656 ""
2657 (list 'gnus-summary-header
2658 (nth 1 header)))
2659 (list 'quote (nth 1 (car ts)))
2660 (list 'gnus-score-delta-default
2661 nil)
2662 (nth 1 (car ps))
2663 t)
2664 t)
2665 outp))
2666 (setq ps (cdr ps)))
2667 (list (nreverse outp))))
2668 outt))
2669 (setq ts (cdr ts)))
2670 (list (nreverse outt))))
2671 outh))
2672 (setq headers (cdr headers)))
2673 (list (nreverse outh))))))))
2674
2675 \f
2676
2677 (defun gnus-summary-mode (&optional group)
2678 "Major mode for reading articles.
2679
2680 All normal editing commands are switched off.
2681 \\<gnus-summary-mode-map>
2682 Each line in this buffer represents one article. To read an
2683 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2684 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2685 respectively.
2686
2687 You can also post articles and send mail from this buffer. To
2688 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2689 of an article, type `\\[gnus-summary-reply]'.
2690
2691 There are approx. one gazillion commands you can execute in this
2692 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2693
2694 The following commands are available:
2695
2696 \\{gnus-summary-mode-map}"
2697 (interactive)
2698 (kill-all-local-variables)
2699 (when (gnus-visual-p 'summary-menu 'menu)
2700 (gnus-summary-make-menu-bar)
2701 (gnus-summary-make-tool-bar))
2702 (gnus-summary-make-local-variables)
2703 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2704 (gnus-summary-make-local-variables))
2705 (gnus-make-thread-indent-array)
2706 (gnus-simplify-mode-line)
2707 (setq major-mode 'gnus-summary-mode)
2708 (setq mode-name "Summary")
2709 (make-local-variable 'minor-mode-alist)
2710 (use-local-map gnus-summary-mode-map)
2711 (buffer-disable-undo)
2712 (setq buffer-read-only t) ;Disable modification
2713 (setq truncate-lines t)
2714 (setq selective-display t)
2715 (setq selective-display-ellipses t) ;Display `...'
2716 (gnus-summary-set-display-table)
2717 (gnus-set-default-directory)
2718 (setq gnus-newsgroup-name group)
2719 (make-local-variable 'gnus-summary-line-format)
2720 (make-local-variable 'gnus-summary-line-format-spec)
2721 (make-local-variable 'gnus-summary-dummy-line-format)
2722 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2723 (make-local-variable 'gnus-summary-mark-positions)
2724 (gnus-make-local-hook 'pre-command-hook)
2725 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2726 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
2727 (turn-on-gnus-mailing-list-mode)
2728 (mm-enable-multibyte)
2729 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2730 (gnus-update-summary-mark-positions))
2731
2732 (defun gnus-summary-make-local-variables ()
2733 "Make all the local summary buffer variables."
2734 (let (global)
2735 (dolist (local gnus-summary-local-variables)
2736 (if (consp local)
2737 (progn
2738 (if (eq (cdr local) 'global)
2739 ;; Copy the global value of the variable.
2740 (setq global (symbol-value (car local)))
2741 ;; Use the value from the list.
2742 (setq global (eval (cdr local))))
2743 (set (make-local-variable (car local)) global))
2744 ;; Simple nil-valued local variable.
2745 (set (make-local-variable local) nil)))))
2746
2747 (defun gnus-summary-clear-local-variables ()
2748 (let ((locals gnus-summary-local-variables))
2749 (while locals
2750 (if (consp (car locals))
2751 (and (vectorp (caar locals))
2752 (set (caar locals) nil))
2753 (and (vectorp (car locals))
2754 (set (car locals) nil)))
2755 (setq locals (cdr locals)))))
2756
2757 ;; Summary data functions.
2758
2759 (defmacro gnus-data-number (data)
2760 `(car ,data))
2761
2762 (defmacro gnus-data-set-number (data number)
2763 `(setcar ,data ,number))
2764
2765 (defmacro gnus-data-mark (data)
2766 `(nth 1 ,data))
2767
2768 (defmacro gnus-data-set-mark (data mark)
2769 `(setcar (nthcdr 1 ,data) ,mark))
2770
2771 (defmacro gnus-data-pos (data)
2772 `(nth 2 ,data))
2773
2774 (defmacro gnus-data-set-pos (data pos)
2775 `(setcar (nthcdr 2 ,data) ,pos))
2776
2777 (defmacro gnus-data-header (data)
2778 `(nth 3 ,data))
2779
2780 (defmacro gnus-data-set-header (data header)
2781 `(setf (nth 3 ,data) ,header))
2782
2783 (defmacro gnus-data-level (data)
2784 `(nth 4 ,data))
2785
2786 (defmacro gnus-data-unread-p (data)
2787 `(= (nth 1 ,data) gnus-unread-mark))
2788
2789 (defmacro gnus-data-read-p (data)
2790 `(/= (nth 1 ,data) gnus-unread-mark))
2791
2792 (defmacro gnus-data-pseudo-p (data)
2793 `(consp (nth 3 ,data)))
2794
2795 (defmacro gnus-data-find (number)
2796 `(assq ,number gnus-newsgroup-data))
2797
2798 (defmacro gnus-data-find-list (number &optional data)
2799 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2800 (memq (assq ,number bdata)
2801 bdata)))
2802
2803 (defmacro gnus-data-make (number mark pos header level)
2804 `(list ,number ,mark ,pos ,header ,level))
2805
2806 (defun gnus-data-enter (after-article number mark pos header level offset)
2807 (let ((data (gnus-data-find-list after-article)))
2808 (unless data
2809 (error "No such article: %d" after-article))
2810 (setcdr data (cons (gnus-data-make number mark pos header level)
2811 (cdr data)))
2812 (setq gnus-newsgroup-data-reverse nil)
2813 (gnus-data-update-list (cddr data) offset)))
2814
2815 (defun gnus-data-enter-list (after-article list &optional offset)
2816 (when list
2817 (let ((data (and after-article (gnus-data-find-list after-article)))
2818 (ilist list))
2819 (if (not (or data
2820 after-article))
2821 (let ((odata gnus-newsgroup-data))
2822 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2823 (when offset
2824 (gnus-data-update-list odata offset)))
2825 ;; Find the last element in the list to be spliced into the main
2826 ;; list.
2827 (while (cdr list)
2828 (setq list (cdr list)))
2829 (if (not data)
2830 (progn
2831 (setcdr list gnus-newsgroup-data)
2832 (setq gnus-newsgroup-data ilist)
2833 (when offset
2834 (gnus-data-update-list (cdr list) offset)))
2835 (setcdr list (cdr data))
2836 (setcdr data ilist)
2837 (when offset
2838 (gnus-data-update-list (cdr list) offset))))
2839 (setq gnus-newsgroup-data-reverse nil))))
2840
2841 (defun gnus-data-remove (article &optional offset)
2842 (let ((data gnus-newsgroup-data))
2843 (if (= (gnus-data-number (car data)) article)
2844 (progn
2845 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2846 gnus-newsgroup-data-reverse nil)
2847 (when offset
2848 (gnus-data-update-list gnus-newsgroup-data offset)))
2849 (while (cdr data)
2850 (when (= (gnus-data-number (cadr data)) article)
2851 (setcdr data (cddr data))
2852 (when offset
2853 (gnus-data-update-list (cdr data) offset))
2854 (setq data nil
2855 gnus-newsgroup-data-reverse nil))
2856 (setq data (cdr data))))))
2857
2858 (defmacro gnus-data-list (backward)
2859 `(if ,backward
2860 (or gnus-newsgroup-data-reverse
2861 (setq gnus-newsgroup-data-reverse
2862 (reverse gnus-newsgroup-data)))
2863 gnus-newsgroup-data))
2864
2865 (defun gnus-data-update-list (data offset)
2866 "Add OFFSET to the POS of all data entries in DATA."
2867 (setq gnus-newsgroup-data-reverse nil)
2868 (while data
2869 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2870 (setq data (cdr data))))
2871
2872 (defun gnus-summary-article-pseudo-p (article)
2873 "Say whether this article is a pseudo article or not."
2874 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2875
2876 (defmacro gnus-summary-article-sparse-p (article)
2877 "Say whether this article is a sparse article or not."
2878 `(memq ,article gnus-newsgroup-sparse))
2879
2880 (defmacro gnus-summary-article-ancient-p (article)
2881 "Say whether this article is a sparse article or not."
2882 `(memq ,article gnus-newsgroup-ancient))
2883
2884 (defun gnus-article-parent-p (number)
2885 "Say whether this article is a parent or not."
2886 (let ((data (gnus-data-find-list number)))
2887 (and (cdr data) ; There has to be an article after...
2888 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2889 (gnus-data-level (nth 1 data))))))
2890
2891 (defun gnus-article-children (number)
2892 "Return a list of all children to NUMBER."
2893 (let* ((data (gnus-data-find-list number))
2894 (level (gnus-data-level (car data)))
2895 children)
2896 (setq data (cdr data))
2897 (while (and data
2898 (= (gnus-data-level (car data)) (1+ level)))
2899 (push (gnus-data-number (car data)) children)
2900 (setq data (cdr data)))
2901 children))
2902
2903 (defmacro gnus-summary-skip-intangible ()
2904 "If the current article is intangible, then jump to a different article."
2905 '(let ((to (get-text-property (point) 'gnus-intangible)))
2906 (and to (gnus-summary-goto-subject to))))
2907
2908 (defmacro gnus-summary-article-intangible-p ()
2909 "Say whether this article is intangible or not."
2910 '(get-text-property (point) 'gnus-intangible))
2911
2912 (defun gnus-article-read-p (article)
2913 "Say whether ARTICLE is read or not."
2914 (not (or (memq article gnus-newsgroup-marked)
2915 (memq article gnus-newsgroup-spam-marked)
2916 (memq article gnus-newsgroup-unreads)
2917 (memq article gnus-newsgroup-unselected)
2918 (memq article gnus-newsgroup-dormant))))
2919
2920 ;; Some summary mode macros.
2921
2922 (defmacro gnus-summary-article-number ()
2923 "The article number of the article on the current line.
2924 If there isn't an article number here, then we return the current
2925 article number."
2926 '(progn
2927 (gnus-summary-skip-intangible)
2928 (or (get-text-property (point) 'gnus-number)
2929 (gnus-summary-last-subject))))
2930
2931 (defmacro gnus-summary-article-header (&optional number)
2932 "Return the header of article NUMBER."
2933 `(gnus-data-header (gnus-data-find
2934 ,(or number '(gnus-summary-article-number)))))
2935
2936 (defmacro gnus-summary-thread-level (&optional number)
2937 "Return the level of thread that starts with article NUMBER."
2938 `(if (and (eq gnus-summary-make-false-root 'dummy)
2939 (get-text-property (point) 'gnus-intangible))
2940 0
2941 (gnus-data-level (gnus-data-find
2942 ,(or number '(gnus-summary-article-number))))))
2943
2944 (defmacro gnus-summary-article-mark (&optional number)
2945 "Return the mark of article NUMBER."
2946 `(gnus-data-mark (gnus-data-find
2947 ,(or number '(gnus-summary-article-number)))))
2948
2949 (defmacro gnus-summary-article-pos (&optional number)
2950 "Return the position of the line of article NUMBER."
2951 `(gnus-data-pos (gnus-data-find
2952 ,(or number '(gnus-summary-article-number)))))
2953
2954 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2955 (defmacro gnus-summary-article-subject (&optional number)
2956 "Return current subject string or nil if nothing."
2957 `(let ((headers
2958 ,(if number
2959 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2960 '(gnus-data-header (assq (gnus-summary-article-number)
2961 gnus-newsgroup-data)))))
2962 (and headers
2963 (vectorp headers)
2964 (mail-header-subject headers))))
2965
2966 (defmacro gnus-summary-article-score (&optional number)
2967 "Return current article score."
2968 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2969 gnus-newsgroup-scored))
2970 gnus-summary-default-score 0))
2971
2972 (defun gnus-summary-article-children (&optional number)
2973 "Return a list of article numbers that are children of article NUMBER."
2974 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2975 (level (gnus-data-level (car data)))
2976 l children)
2977 (while (and (setq data (cdr data))
2978 (> (setq l (gnus-data-level (car data))) level))
2979 (and (= (1+ level) l)
2980 (push (gnus-data-number (car data))
2981 children)))
2982 (nreverse children)))
2983
2984 (defun gnus-summary-article-parent (&optional number)
2985 "Return the article number of the parent of article NUMBER."
2986 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2987 (gnus-data-list t)))
2988 (level (gnus-data-level (car data))))
2989 (if (zerop level)
2990 () ; This is a root.
2991 ;; We search until we find an article with a level less than
2992 ;; this one. That function has to be the parent.
2993 (while (and (setq data (cdr data))
2994 (not (< (gnus-data-level (car data)) level))))
2995 (and data (gnus-data-number (car data))))))
2996
2997 (defun gnus-unread-mark-p (mark)
2998 "Say whether MARK is the unread mark."
2999 (= mark gnus-unread-mark))
3000
3001 (defun gnus-read-mark-p (mark)
3002 "Say whether MARK is one of the marks that mark as read.
3003 This is all marks except unread, ticked, dormant, and expirable."
3004 (not (or (= mark gnus-unread-mark)
3005 (= mark gnus-ticked-mark)
3006 (= mark gnus-spam-mark)
3007 (= mark gnus-dormant-mark)
3008 (= mark gnus-expirable-mark))))
3009
3010 (defmacro gnus-article-mark (number)
3011 "Return the MARK of article NUMBER.
3012 This macro should only be used when computing the mark the \"first\"
3013 time; i.e., when generating the summary lines. After that,
3014 `gnus-summary-article-mark' should be used to examine the
3015 marks of articles."
3016 `(cond
3017 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3018 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3019 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3020 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3021 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3022 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3023 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3024 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3025 gnus-ancient-mark))))
3026
3027 ;; Saving hidden threads.
3028
3029 (defmacro gnus-save-hidden-threads (&rest forms)
3030 "Save hidden threads, eval FORMS, and restore the hidden threads."
3031 (let ((config (make-symbol "config")))
3032 `(let ((,config (gnus-hidden-threads-configuration)))
3033 (unwind-protect
3034 (save-excursion
3035 ,@forms)
3036 (gnus-restore-hidden-threads-configuration ,config)))))
3037 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3038 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3039
3040 (defun gnus-data-compute-positions ()
3041 "Compute the positions of all articles."
3042 (setq gnus-newsgroup-data-reverse nil)
3043 (let ((data gnus-newsgroup-data))
3044 (save-excursion
3045 (gnus-save-hidden-threads
3046 (gnus-summary-show-all-threads)
3047 (goto-char (point-min))
3048 (while data
3049 (while (get-text-property (point) 'gnus-intangible)
3050 (forward-line 1))
3051 (gnus-data-set-pos (car data) (+ (point) 3))
3052 (setq data (cdr data))
3053 (forward-line 1))))))
3054
3055 (defun gnus-hidden-threads-configuration ()
3056 "Return the current hidden threads configuration."
3057 (save-excursion
3058 (let (config)
3059 (goto-char (point-min))
3060 (while (search-forward "\r" nil t)
3061 (push (1- (point)) config))
3062 config)))
3063
3064 (defun gnus-restore-hidden-threads-configuration (config)
3065 "Restore hidden threads configuration from CONFIG."
3066 (save-excursion
3067 (let (point buffer-read-only)
3068 (while (setq point (pop config))
3069 (when (and (< point (point-max))
3070 (goto-char point)
3071 (eq (char-after) ?\n))
3072 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3073
3074 ;; Various summary mode internalish functions.
3075
3076 (defun gnus-mouse-pick-article (e)
3077 (interactive "e")
3078 (mouse-set-point e)
3079 (gnus-summary-next-page nil t))
3080
3081 (defun gnus-summary-set-display-table ()
3082 "Change the display table.
3083 Odd characters have a tendency to mess
3084 up nicely formatted displays - we make all possible glyphs
3085 display only a single character."
3086
3087 ;; We start from the standard display table, if any.
3088 (let ((table (or (copy-sequence standard-display-table)
3089 (make-display-table)))
3090 (i 32))
3091 ;; Nix out all the control chars...
3092 (while (>= (setq i (1- i)) 0)
3093 (aset table i [??]))
3094 ;; ... but not newline and cr, of course. (cr is necessary for the
3095 ;; selective display).
3096 (aset table ?\n nil)
3097 (aset table ?\r nil)
3098 ;; We keep TAB as well.
3099 (aset table ?\t nil)
3100 ;; We nix out any glyphs over 126 that are not set already.
3101 (let ((i 256))
3102 (while (>= (setq i (1- i)) 127)
3103 ;; Only modify if the entry is nil.
3104 (unless (aref table i)
3105 (aset table i [??]))))
3106 (setq buffer-display-table table)))
3107
3108 (defun gnus-summary-set-article-display-arrow (pos)
3109 "Update the overlay arrow to point to line at position POS."
3110 (when (and gnus-summary-display-arrow
3111 (boundp 'overlay-arrow-position)
3112 (boundp 'overlay-arrow-string))
3113 (save-excursion
3114 (goto-char pos)
3115 (beginning-of-line)
3116 (unless overlay-arrow-position
3117 (setq overlay-arrow-position (make-marker)))
3118 (setq overlay-arrow-string "=>"
3119 overlay-arrow-position (set-marker overlay-arrow-position
3120 (point)
3121 (current-buffer))))))
3122
3123 (defun gnus-summary-setup-buffer (group)
3124 "Initialize summary buffer."
3125 (let ((buffer (gnus-summary-buffer-name group))
3126 (dead-name (concat "*Dead Summary "
3127 (gnus-group-decoded-name group) "*")))
3128 ;; If a dead summary buffer exists, we kill it.
3129 (when (gnus-buffer-live-p dead-name)
3130 (gnus-kill-buffer dead-name))
3131 (if (get-buffer buffer)
3132 (progn
3133 (set-buffer buffer)
3134 (setq gnus-summary-buffer (current-buffer))
3135 (not gnus-newsgroup-prepared))
3136 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3137 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3138 (gnus-summary-mode group)
3139 (when gnus-carpal
3140 (gnus-carpal-setup-buffer 'summary))
3141 (unless gnus-single-article-buffer
3142 (make-local-variable 'gnus-article-buffer)
3143 (make-local-variable 'gnus-article-current)
3144 (make-local-variable 'gnus-original-article-buffer))
3145 (setq gnus-newsgroup-name group)
3146 ;; Set any local variables in the group parameters.
3147 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3148 t)))
3149
3150 (defun gnus-set-global-variables ()
3151 "Set the global equivalents of the buffer-local variables.
3152 They are set to the latest values they had. These reflect the summary
3153 buffer that was in action when the last article was fetched."
3154 (when (eq major-mode 'gnus-summary-mode)
3155 (setq gnus-summary-buffer (current-buffer))
3156 (let ((name gnus-newsgroup-name)
3157 (marked gnus-newsgroup-marked)
3158 (spam gnus-newsgroup-spam-marked)
3159 (unread gnus-newsgroup-unreads)
3160 (headers gnus-current-headers)
3161 (data gnus-newsgroup-data)
3162 (summary gnus-summary-buffer)
3163 (article-buffer gnus-article-buffer)
3164 (original gnus-original-article-buffer)
3165 (gac gnus-article-current)
3166 (reffed gnus-reffed-article-number)
3167 (score-file gnus-current-score-file)
3168 (default-charset gnus-newsgroup-charset)
3169 vlist)
3170 (let ((locals gnus-newsgroup-variables))
3171 (while locals
3172 (if (consp (car locals))
3173 (push (eval (caar locals)) vlist)
3174 (push (eval (car locals)) vlist))
3175 (setq locals (cdr locals)))
3176 (setq vlist (nreverse vlist)))
3177 (save-excursion
3178 (set-buffer gnus-group-buffer)
3179 (setq gnus-newsgroup-name name
3180 gnus-newsgroup-marked marked
3181 gnus-newsgroup-spam-marked spam
3182 gnus-newsgroup-unreads unread
3183 gnus-current-headers headers
3184 gnus-newsgroup-data data
3185 gnus-article-current gac
3186 gnus-summary-buffer summary
3187 gnus-article-buffer article-buffer
3188 gnus-original-article-buffer original
3189 gnus-reffed-article-number reffed
3190 gnus-current-score-file score-file
3191 gnus-newsgroup-charset default-charset)
3192 (let ((locals gnus-newsgroup-variables))
3193 (while locals
3194 (if (consp (car locals))
3195 (set (caar locals) (pop vlist))
3196 (set (car locals) (pop vlist)))
3197 (setq locals (cdr locals))))
3198 ;; The article buffer also has local variables.
3199 (when (gnus-buffer-live-p gnus-article-buffer)
3200 (set-buffer gnus-article-buffer)
3201 (setq gnus-summary-buffer summary))))))
3202
3203 (defun gnus-summary-article-unread-p (article)
3204 "Say whether ARTICLE is unread or not."
3205 (memq article gnus-newsgroup-unreads))
3206
3207 (defun gnus-summary-first-article-p (&optional article)
3208 "Return whether ARTICLE is the first article in the buffer."
3209 (if (not (setq article (or article (gnus-summary-article-number))))
3210 nil
3211 (eq article (caar gnus-newsgroup-data))))
3212
3213 (defun gnus-summary-last-article-p (&optional article)
3214 "Return whether ARTICLE is the last article in the buffer."
3215 (if (not (setq article (or article (gnus-summary-article-number))))
3216 ;; All non-existent numbers are the last article. :-)
3217 t
3218 (not (cdr (gnus-data-find-list article)))))
3219
3220 (defun gnus-make-thread-indent-array ()
3221 (let ((n 200))
3222 (unless (and gnus-thread-indent-array
3223 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3224 (setq gnus-thread-indent-array (make-vector 201 "")
3225 gnus-thread-indent-array-level gnus-thread-indent-level)
3226 (while (>= n 0)
3227 (aset gnus-thread-indent-array n
3228 (make-string (* n gnus-thread-indent-level) ? ))
3229 (setq n (1- n))))))
3230
3231 (defun gnus-update-summary-mark-positions ()
3232 "Compute where the summary marks are to go."
3233 (save-excursion
3234 (when (gnus-buffer-exists-p gnus-summary-buffer)
3235 (set-buffer gnus-summary-buffer))
3236 (let ((spec gnus-summary-line-format-spec)
3237 pos)
3238 (save-excursion
3239 (gnus-set-work-buffer)
3240 (let ((gnus-tmp-unread ?Z)
3241 (gnus-replied-mark ?Z)
3242 (gnus-score-below-mark ?Z)
3243 (gnus-score-over-mark ?Z)
3244 (gnus-undownloaded-mark ?Z)
3245 (gnus-summary-line-format-spec spec)
3246 (gnus-newsgroup-downloadable '(0))
3247 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3248 case-fold-search ignores)
3249 ;; Here, all marks are bound to Z.
3250 (gnus-summary-insert-line header
3251 0 nil t gnus-tmp-unread t nil "" nil 1)
3252 (goto-char (point-min))
3253 ;; Memorize the positions of the same characters as dummy marks.
3254 (while (re-search-forward "[A-D]" nil t)
3255 (push (point) ignores))
3256 (erase-buffer)
3257 ;; We use A-D as dummy marks in order to know column positions
3258 ;; where marks should be inserted.
3259 (setq gnus-tmp-unread ?A
3260 gnus-replied-mark ?B
3261 gnus-score-below-mark ?C
3262 gnus-score-over-mark ?C
3263 gnus-undownloaded-mark ?D)
3264 (gnus-summary-insert-line header
3265 0 nil t gnus-tmp-unread t nil "" nil 1)
3266 ;; Ignore characters which aren't dummy marks.
3267 (dolist (p ignores)
3268 (delete-region (goto-char (1- p)) p)
3269 (insert ?Z))
3270 (goto-char (point-min))
3271 (setq pos (list (cons 'unread
3272 (and (search-forward "A" nil t)
3273 (- (point) (point-min) 1)))))
3274 (goto-char (point-min))
3275 (push (cons 'replied (and (search-forward "B" nil t)
3276 (- (point) (point-min) 1)))
3277 pos)
3278 (goto-char (point-min))
3279 (push (cons 'score (and (search-forward "C" nil t)
3280 (- (point) (point-min) 1)))
3281 pos)
3282 (goto-char (point-min))
3283 (push (cons 'download (and (search-forward "D" nil t)
3284 (- (point) (point-min) 1)))
3285 pos)))
3286 (setq gnus-summary-mark-positions pos))))
3287
3288 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3289 "Insert a dummy root in the summary buffer."
3290 (beginning-of-line)
3291 (gnus-add-text-properties
3292 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3293 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3294
3295 (defun gnus-summary-extract-address-component (from)
3296 (or (car (funcall gnus-extract-address-components from))
3297 from))
3298
3299 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3300 (let ((mail-parse-charset gnus-newsgroup-charset)
3301 ; Is it really necessary to do this next part for each summary line?
3302 ; Luckily, doesn't seem to slow things down much.
3303 (mail-parse-ignored-charsets
3304 (save-excursion (set-buffer gnus-summary-buffer)
3305 gnus-newsgroup-ignored-charsets)))
3306 (or
3307 (and gnus-ignored-from-addresses
3308 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3309 (let ((extra-headers (mail-header-extra header))
3310 to
3311 newsgroups)
3312 (cond
3313 ((setq to (cdr (assq 'To extra-headers)))
3314 (concat "-> "
3315 (inline
3316 (gnus-summary-extract-address-component
3317 (funcall gnus-decode-encoded-word-function to)))))
3318 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3319 (concat "=> " newsgroups)))))
3320 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3321
3322 (defun gnus-summary-insert-line (gnus-tmp-header
3323 gnus-tmp-level gnus-tmp-current
3324 undownloaded gnus-tmp-unread gnus-tmp-replied
3325 gnus-tmp-expirable gnus-tmp-subject-or-nil
3326 &optional gnus-tmp-dummy gnus-tmp-score
3327 gnus-tmp-process)
3328 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3329 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3330 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3331 (gnus-tmp-score-char
3332 (if (or (null gnus-summary-default-score)
3333 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3334 gnus-summary-zcore-fuzz))
3335 ? ;Whitespace
3336 (if (< gnus-tmp-score gnus-summary-default-score)
3337 gnus-score-below-mark gnus-score-over-mark)))
3338 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3339 (gnus-tmp-replied
3340 (cond (gnus-tmp-process gnus-process-mark)
3341 ((memq gnus-tmp-current gnus-newsgroup-cached)
3342 gnus-cached-mark)
3343 (gnus-tmp-replied gnus-replied-mark)
3344 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3345 gnus-forwarded-mark)
3346 ((memq gnus-tmp-current gnus-newsgroup-saved)
3347 gnus-saved-mark)
3348 ((memq gnus-tmp-number gnus-newsgroup-recent)
3349 gnus-recent-mark)
3350 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3351 gnus-unseen-mark)
3352 (t gnus-no-mark)))
3353 (gnus-tmp-downloaded
3354 (cond (undownloaded
3355 gnus-undownloaded-mark)
3356 (gnus-newsgroup-agentized
3357 gnus-downloaded-mark)
3358 (t
3359 gnus-no-mark)))
3360 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3361 (gnus-tmp-name
3362 (cond
3363 ((string-match "<[^>]+> *$" gnus-tmp-from)
3364 (let ((beg (match-beginning 0)))
3365 (or (and (string-match "^\".+\"" gnus-tmp-from)
3366 (substring gnus-tmp-from 1 (1- (match-end 0))))
3367 (substring gnus-tmp-from 0 beg))))
3368 ((string-match "(.+)" gnus-tmp-from)
3369 (substring gnus-tmp-from
3370 (1+ (match-beginning 0)) (1- (match-end 0))))
3371 (t gnus-tmp-from)))
3372 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3373 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3374 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3375 (buffer-read-only nil))
3376 (when (string= gnus-tmp-name "")
3377 (setq gnus-tmp-name gnus-tmp-from))
3378 (unless (numberp gnus-tmp-lines)
3379 (setq gnus-tmp-lines -1))
3380 (if (= gnus-tmp-lines -1)
3381 (setq gnus-tmp-lines "?")
3382 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3383 (gnus-put-text-property
3384 (point)
3385 (progn (eval gnus-summary-line-format-spec) (point))
3386 'gnus-number gnus-tmp-number)
3387 (when (gnus-visual-p 'summary-highlight 'highlight)
3388 (forward-line -1)
3389 (gnus-run-hooks 'gnus-summary-update-hook)
3390 (forward-line 1))))
3391
3392 (defun gnus-summary-update-line (&optional dont-update)
3393 "Update summary line after change."
3394 (when (and gnus-summary-default-score
3395 (not gnus-summary-inhibit-highlight))
3396 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3397 (article (gnus-summary-article-number))
3398 (score (gnus-summary-article-score article)))
3399 (unless dont-update
3400 (if (and gnus-summary-mark-below
3401 (< (gnus-summary-article-score)
3402 gnus-summary-mark-below))
3403 ;; This article has a low score, so we mark it as read.
3404 (when (memq article gnus-newsgroup-unreads)
3405 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3406 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3407 ;; This article was previously marked as read on account
3408 ;; of a low score, but now it has risen, so we mark it as
3409 ;; unread.
3410 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3411 (gnus-summary-update-mark
3412 (if (or (null gnus-summary-default-score)
3413 (<= (abs (- score gnus-summary-default-score))
3414 gnus-summary-zcore-fuzz))
3415 ? ;Whitespace
3416 (if (< score gnus-summary-default-score)
3417 gnus-score-below-mark gnus-score-over-mark))
3418 'score))
3419 ;; Do visual highlighting.
3420 (when (gnus-visual-p 'summary-highlight 'highlight)
3421 (gnus-run-hooks 'gnus-summary-update-hook)))))
3422
3423 (defvar gnus-tmp-new-adopts nil)
3424
3425 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3426 "Return the number of articles in THREAD.
3427 This may be 0 in some cases -- if none of the articles in
3428 the thread are to be displayed."
3429 (let* ((number
3430 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3431 (cond
3432 ((not (listp thread))
3433 1)
3434 ((and (consp thread) (cdr thread))
3435 (apply
3436 '+ 1 (mapcar
3437 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3438 ((null thread)
3439 1)
3440 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3441 1)
3442 (t 0))))
3443 (when (and level (zerop level) gnus-tmp-new-adopts)
3444 (incf number
3445 (apply '+ (mapcar
3446 'gnus-summary-number-of-articles-in-thread
3447 gnus-tmp-new-adopts))))
3448 (if char
3449 (if (> number 1) gnus-not-empty-thread-mark
3450 gnus-empty-thread-mark)
3451 number)))
3452
3453 (defsubst gnus-summary-line-message-size (head)
3454 "Return pretty-printed version of message size.
3455 This function is intended to be used in
3456 `gnus-summary-line-format-alist'."
3457 (let ((c (or (mail-header-chars head) -1)))
3458 (cond ((< c 0) "n/a") ; chars not available
3459 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3460 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3461 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3462 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3463
3464
3465 (defun gnus-summary-set-local-parameters (group)
3466 "Go through the local params of GROUP and set all variable specs in that list."
3467 (let ((params (gnus-group-find-parameter group))
3468 (vars '(quit-config)) ; Ignore quit-config.
3469 elem)
3470 (while params
3471 (setq elem (car params)
3472 params (cdr params))
3473 (and (consp elem) ; Has to be a cons.
3474 (consp (cdr elem)) ; The cdr has to be a list.
3475 (symbolp (car elem)) ; Has to be a symbol in there.
3476 (not (memq (car elem) vars))
3477 (ignore-errors ; So we set it.
3478 (push (car elem) vars)
3479 (make-local-variable (car elem))
3480 (set (car elem) (eval (nth 1 elem))))))))
3481
3482 (defun gnus-summary-read-group (group &optional show-all no-article
3483 kill-buffer no-display backward
3484 select-articles)
3485 "Start reading news in newsgroup GROUP.
3486 If SHOW-ALL is non-nil, already read articles are also listed.
3487 If NO-ARTICLE is non-nil, no article is selected initially.
3488 If NO-DISPLAY, don't generate a summary buffer."
3489 (let (result)
3490 (while (and group
3491 (null (setq result
3492 (let ((gnus-auto-select-next nil))
3493 (or (gnus-summary-read-group-1
3494 group show-all no-article
3495 kill-buffer no-display
3496 select-articles)
3497 (setq show-all nil
3498 select-articles nil)))))
3499 (eq gnus-auto-select-next 'quietly))
3500 (set-buffer gnus-group-buffer)
3501 ;; The entry function called above goes to the next
3502 ;; group automatically, so we go two groups back
3503 ;; if we are searching for the previous group.
3504 (when backward
3505 (gnus-group-prev-unread-group 2))
3506 (if (not (equal group (gnus-group-group-name)))
3507 (setq group (gnus-group-group-name))
3508 (setq group nil)))
3509 result))
3510
3511 (defun gnus-summary-read-group-1 (group show-all no-article
3512 kill-buffer no-display
3513 &optional select-articles)
3514 ;; Killed foreign groups can't be entered.
3515 ;; (when (and (not (gnus-group-native-p group))
3516 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3517 ;; (error "Dead non-native groups can't be entered"))
3518 (gnus-message 5 "Retrieving newsgroup: %s..."
3519 (gnus-group-decoded-name group))
3520 (let* ((new-group (gnus-summary-setup-buffer group))
3521 (quit-config (gnus-group-quit-config group))
3522 (did-select (and new-group (gnus-select-newsgroup
3523 group show-all select-articles))))
3524 (cond
3525 ;; This summary buffer exists already, so we just select it.
3526 ((not new-group)
3527 (gnus-set-global-variables)
3528 (when kill-buffer
3529 (gnus-kill-or-deaden-summary kill-buffer))
3530 (gnus-configure-windows 'summary 'force)
3531 (gnus-set-mode-line 'summary)
3532 (gnus-summary-position-point)
3533 (message "")
3534 t)
3535 ;; We couldn't select this group.
3536 ((null did-select)
3537 (when (and (eq major-mode 'gnus-summary-mode)
3538 (not (equal (current-buffer) kill-buffer)))
3539 (kill-buffer (current-buffer))
3540 (if (not quit-config)
3541 (progn
3542 ;; Update the info -- marks might need to be removed,
3543 ;; for instance.
3544 (gnus-summary-update-info)
3545 (set-buffer gnus-group-buffer)
3546 (gnus-group-jump-to-group group)
3547 (gnus-group-next-unread-group 1))
3548 (gnus-handle-ephemeral-exit quit-config)))
3549 (let ((grpinfo (gnus-get-info group)))
3550 (if (null (gnus-info-read grpinfo))
3551 (gnus-message 3 "Group %s contains no messages"
3552 (gnus-group-decoded-name group))
3553 (gnus-message 3 "Can't select group")))
3554 nil)
3555 ;; The user did a `C-g' while prompting for number of articles,
3556 ;; so we exit this group.
3557 ((eq did-select 'quit)
3558 (and (eq major-mode 'gnus-summary-mode)
3559 (not (equal (current-buffer) kill-buffer))
3560 (kill-buffer (current-buffer)))
3561 (when kill-buffer
3562 (gnus-kill-or-deaden-summary kill-buffer))
3563 (if (not quit-config)
3564 (progn
3565 (set-buffer gnus-group-buffer)
3566 (gnus-group-jump-to-group group)
3567 (gnus-group-next-unread-group 1)
3568 (gnus-configure-windows 'group 'force))
3569 (gnus-handle-ephemeral-exit quit-config))
3570 ;; Finally signal the quit.
3571 (signal 'quit nil))
3572 ;; The group was successfully selected.
3573 (t
3574 (gnus-set-global-variables)
3575 ;; Save the active value in effect when the group was entered.
3576 (setq gnus-newsgroup-active
3577 (gnus-copy-sequence
3578 (gnus-active gnus-newsgroup-name)))
3579 ;; You can change the summary buffer in some way with this hook.
3580 (gnus-run-hooks 'gnus-select-group-hook)
3581 (when (memq 'summary (gnus-update-format-specifications
3582 nil 'summary 'summary-mode 'summary-dummy))
3583 ;; The format specification for the summary line was updated,
3584 ;; so we need to update the mark positions as well.
3585 (gnus-update-summary-mark-positions))
3586 ;; Do score processing.
3587 (when gnus-use-scoring
3588 (gnus-possibly-score-headers))
3589 ;; Check whether to fill in the gaps in the threads.
3590 (when gnus-build-sparse-threads
3591 (gnus-build-sparse-threads))
3592 ;; Find the initial limit.
3593 (if gnus-show-threads
3594 (if show-all
3595 (let ((gnus-newsgroup-dormant nil))
3596 (gnus-summary-initial-limit show-all))
3597 (gnus-summary-initial-limit show-all))
3598 ;; When unthreaded, all articles are always shown.
3599 (setq gnus-newsgroup-limit
3600 (mapcar
3601 (lambda (header) (mail-header-number header))
3602 gnus-newsgroup-headers)))
3603 ;; Generate the summary buffer.
3604 (unless no-display
3605 (gnus-summary-prepare))
3606 (when gnus-use-trees
3607 (gnus-tree-open group)
3608 (setq gnus-summary-highlight-line-function
3609 'gnus-tree-highlight-article))
3610 ;; If the summary buffer is empty, but there are some low-scored
3611 ;; articles or some excluded dormants, we include these in the
3612 ;; buffer.
3613 (when (and (zerop (buffer-size))
3614 (not no-display))
3615 (cond (gnus-newsgroup-dormant
3616 (gnus-summary-limit-include-dormant))
3617 ((and gnus-newsgroup-scored show-all)
3618 (gnus-summary-limit-include-expunged t))))
3619 ;; Function `gnus-apply-kill-file' must be called in this hook.
3620 (gnus-run-hooks 'gnus-apply-kill-hook)
3621 (if (and (zerop (buffer-size))
3622 (not no-display))
3623 (progn
3624 ;; This newsgroup is empty.
3625 (gnus-summary-catchup-and-exit nil t)
3626 (gnus-message 6 "No unread news")
3627 (when kill-buffer
3628 (gnus-kill-or-deaden-summary kill-buffer))
3629 ;; Return nil from this function.
3630 nil)
3631 ;; Hide conversation thread subtrees. We cannot do this in
3632 ;; gnus-summary-prepare-hook since kill processing may not
3633 ;; work with hidden articles.
3634 (gnus-summary-maybe-hide-threads)
3635 (when kill-buffer
3636 (gnus-kill-or-deaden-summary kill-buffer))
3637 (gnus-summary-auto-select-subject)
3638 ;; Show first unread article if requested.
3639 (if (and (not no-article)
3640 (not no-display)
3641 gnus-newsgroup-unreads
3642 gnus-auto-select-first)
3643 (progn
3644 (gnus-configure-windows 'summary)
3645 (let ((art (gnus-summary-article-number)))
3646 (unless (and (not gnus-plugged)
3647 (or (memq art gnus-newsgroup-undownloaded)
3648 (memq art gnus-newsgroup-downloadable)))
3649 (gnus-summary-goto-article art))))
3650 ;; Don't select any articles.
3651 (gnus-summary-position-point)
3652 (gnus-configure-windows 'summary 'force)
3653 (gnus-set-mode-line 'summary))
3654 (when (and gnus-auto-center-group
3655 (get-buffer-window gnus-group-buffer t))
3656 ;; Gotta use windows, because recenter does weird stuff if
3657 ;; the current buffer ain't the displayed window.
3658 (let ((owin (selected-window)))
3659 (select-window (get-buffer-window gnus-group-buffer t))
3660 (when (gnus-group-goto-group group)
3661 (recenter))
3662 (select-window owin)))
3663 ;; Mark this buffer as "prepared".
3664 (setq gnus-newsgroup-prepared t)
3665 (gnus-run-hooks 'gnus-summary-prepared-hook)
3666 (unless (gnus-ephemeral-group-p group)
3667 (gnus-group-update-group group))
3668 t)))))
3669
3670 (defun gnus-summary-auto-select-subject ()
3671 "Select the subject line on initial group entry."
3672 (goto-char (point-min))
3673 (cond
3674 ((eq gnus-auto-select-subject 'best)
3675 (gnus-summary-best-unread-subject))
3676 ((eq gnus-auto-select-subject 'unread)
3677 (gnus-summary-first-unread-subject))
3678 ((eq gnus-auto-select-subject 'unseen)
3679 (gnus-summary-first-unseen-subject))
3680 ((eq gnus-auto-select-subject 'unseen-or-unread)
3681 (gnus-summary-first-unseen-or-unread-subject))
3682 ((eq gnus-auto-select-subject 'first)
3683 ;; Do nothing.
3684 )
3685 ((functionp gnus-auto-select-subject)
3686 (funcall gnus-auto-select-subject))))
3687
3688 (defun gnus-summary-prepare ()
3689 "Generate the summary buffer."
3690 (interactive)
3691 (let ((buffer-read-only nil))
3692 (erase-buffer)
3693 (setq gnus-newsgroup-data nil
3694 gnus-newsgroup-data-reverse nil)
3695 (gnus-run-hooks 'gnus-summary-generate-hook)
3696 ;; Generate the buffer, either with threads or without.
3697 (when gnus-newsgroup-headers
3698 (gnus-summary-prepare-threads
3699 (if gnus-show-threads
3700 (gnus-sort-gathered-threads
3701 (funcall gnus-summary-thread-gathering-function
3702 (gnus-sort-threads
3703 (gnus-cut-threads (gnus-make-threads)))))
3704 ;; Unthreaded display.
3705 (gnus-sort-articles gnus-newsgroup-headers))))
3706 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3707 ;; Call hooks for modifying summary buffer.
3708 (goto-char (point-min))
3709 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3710
3711 (defsubst gnus-general-simplify-subject (subject)
3712 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3713 (setq subject
3714 (cond
3715 ;; Truncate the subject.
3716 (gnus-simplify-subject-functions
3717 (gnus-map-function gnus-simplify-subject-functions subject))
3718 ((numberp gnus-summary-gather-subject-limit)
3719 (setq subject (gnus-simplify-subject-re subject))
3720 (if (> (length subject) gnus-summary-gather-subject-limit)
3721 (substring subject 0 gnus-summary-gather-subject-limit)
3722 subject))
3723 ;; Fuzzily simplify it.
3724 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3725 (gnus-simplify-subject-fuzzy subject))
3726 ;; Just remove the leading "Re:".
3727 (t
3728 (gnus-simplify-subject-re subject))))
3729
3730 (if (and gnus-summary-gather-exclude-subject
3731 (string-match gnus-summary-gather-exclude-subject subject))
3732 nil ; This article shouldn't be gathered
3733 subject))
3734
3735 (defun gnus-summary-simplify-subject-query ()
3736 "Query where the respool algorithm would put this article."
3737 (interactive)
3738 (gnus-summary-select-article)
3739 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3740
3741 (defun gnus-gather-threads-by-subject (threads)
3742 "Gather threads by looking at Subject headers."
3743 (if (not gnus-summary-make-false-root)
3744 threads
3745 (let ((hashtb (gnus-make-hashtable 1024))
3746 (prev threads)
3747 (result threads)
3748 subject hthread whole-subject)
3749 (while threads
3750 (setq subject (gnus-general-simplify-subject
3751 (setq whole-subject (mail-header-subject
3752 (caar threads)))))
3753 (when subject
3754 (if (setq hthread (gnus-gethash subject hashtb))
3755 (progn
3756 ;; We enter a dummy root into the thread, if we
3757 ;; haven't done that already.
3758 (unless (stringp (caar hthread))
3759 (setcar hthread (list whole-subject (car hthread))))
3760 ;; We add this new gathered thread to this gathered
3761 ;; thread.
3762 (setcdr (car hthread)
3763 (nconc (cdar hthread) (list (car threads))))
3764 ;; Remove it from the list of threads.
3765 (setcdr prev (cdr threads))
3766 (setq threads prev))
3767 ;; Enter this thread into the hash table.
3768 (gnus-sethash subject
3769 (if gnus-summary-make-false-root-always
3770 (progn
3771 ;; If you want a dummy root above all
3772 ;; threads...
3773 (setcar threads (list whole-subject
3774 (car threads)))
3775 threads)
3776 threads)
3777 hashtb)))
3778 (setq prev threads)
3779 (setq threads (cdr threads)))
3780 result)))
3781
3782 (defun gnus-gather-threads-by-references (threads)
3783 "Gather threads by looking at References headers."
3784 (let ((idhashtb (gnus-make-hashtable 1024))
3785 (thhashtb (gnus-make-hashtable 1024))
3786 (prev threads)
3787 (result threads)
3788 ids references id gthread gid entered ref)
3789 (while threads
3790 (when (setq references (mail-header-references (caar threads)))
3791 (setq id (mail-header-id (caar threads))
3792 ids (inline (gnus-split-references references))
3793 entered nil)
3794 (while (setq ref (pop ids))
3795 (setq ids (delete ref ids))
3796 (if (not (setq gid (gnus-gethash ref idhashtb)))
3797 (progn
3798 (gnus-sethash ref id idhashtb)
3799 (gnus-sethash id threads thhashtb))
3800 (setq gthread (gnus-gethash gid thhashtb))
3801 (unless entered
3802 ;; We enter a dummy root into the thread, if we
3803 ;; haven't done that already.
3804 (unless (stringp (caar gthread))
3805 (setcar gthread (list (mail-header-subject (caar gthread))
3806 (car gthread))))
3807 ;; We add this new gathered thread to this gathered
3808 ;; thread.
3809 (setcdr (car gthread)
3810 (nconc (cdar gthread) (list (car threads)))))
3811 ;; Add it into the thread hash table.
3812 (gnus-sethash id gthread thhashtb)
3813 (setq entered t)
3814 ;; Remove it from the list of threads.
3815 (setcdr prev (cdr threads))
3816 (setq threads prev))))
3817 (setq prev threads)
3818 (setq threads (cdr threads)))
3819 result))
3820
3821 (defun gnus-sort-gathered-threads (threads)
3822 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3823 (let ((result threads))
3824 (while threads
3825 (when (stringp (caar threads))
3826 (setcdr (car threads)
3827 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3828 (setq threads (cdr threads)))
3829 result))
3830
3831 (defun gnus-thread-loop-p (root thread)
3832 "Say whether ROOT is in THREAD."
3833 (let ((stack (list thread))
3834 (infloop 0)
3835 th)
3836 (while (setq thread (pop stack))
3837 (setq th (cdr thread))
3838 (while (and th
3839 (not (eq (caar th) root)))
3840 (pop th))
3841 (if th
3842 ;; We have found a loop.
3843 (let (ref-dep)
3844 (setcdr thread (delq (car th) (cdr thread)))
3845 (if (boundp (setq ref-dep (intern "none"
3846 gnus-newsgroup-dependencies)))
3847 (setcdr (symbol-value ref-dep)
3848 (nconc (cdr (symbol-value ref-dep))
3849 (list (car th))))
3850 (set ref-dep (list nil (car th))))
3851 (setq infloop 1
3852 stack nil))
3853 ;; Push all the subthreads onto the stack.
3854 (push (cdr thread) stack)))
3855 infloop))
3856
3857 (defun gnus-make-threads ()
3858 "Go through the dependency hashtb and find the roots. Return all threads."
3859 (let (threads)
3860 (while (catch 'infloop
3861 (mapatoms
3862 (lambda (refs)
3863 ;; Deal with self-referencing References loops.
3864 (when (and (car (symbol-value refs))
3865 (not (zerop
3866 (apply
3867 '+
3868 (mapcar
3869 (lambda (thread)
3870 (gnus-thread-loop-p
3871 (car (symbol-value refs)) thread))
3872 (cdr (symbol-value refs)))))))
3873 (setq threads nil)
3874 (throw 'infloop t))
3875 (unless (car (symbol-value refs))
3876 ;; These threads do not refer back to any other
3877 ;; articles, so they're roots.
3878 (setq threads (append (cdr (symbol-value refs)) threads))))
3879 gnus-newsgroup-dependencies)))
3880 threads))
3881
3882 ;; Build the thread tree.
3883 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3884 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3885
3886 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3887 if it was already present.
3888
3889 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3890 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3891 Message-IDs will be renamed to a unique Message-ID before being
3892 entered.
3893
3894 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3895 (let* ((id (mail-header-id header))
3896 (id-dep (and id (intern id dependencies)))
3897 parent-id ref ref-dep ref-header replaced)
3898 ;; Enter this `header' in the `dependencies' table.
3899 (cond
3900 ((not id-dep)
3901 (setq header nil))
3902 ;; The first two cases do the normal part: enter a new `header'
3903 ;; in the `dependencies' table.
3904 ((not (boundp id-dep))
3905 (set id-dep (list header)))
3906 ((null (car (symbol-value id-dep)))
3907 (setcar (symbol-value id-dep) header))
3908
3909 ;; From here the `header' was already present in the
3910 ;; `dependencies' table.
3911 (force-new
3912 ;; Overrides an existing entry;
3913 ;; just set the header part of the entry.
3914 (setcar (symbol-value id-dep) header)
3915 (setq replaced t))
3916
3917 ;; Renames the existing `header' to a unique Message-ID.
3918 ((not gnus-summary-ignore-duplicates)
3919 ;; An article with this Message-ID has already been seen.
3920 ;; We rename the Message-ID.
3921 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3922 (list header))
3923 (mail-header-set-id header id))
3924
3925 ;; The last case ignores an existing entry, except it adds any
3926 ;; additional Xrefs (in case the two articles came from different
3927 ;; servers.
3928 ;; Also sets `header' to `nil' meaning that the `dependencies'
3929 ;; table was *not* modified.
3930 (t
3931 (mail-header-set-xref
3932 (car (symbol-value id-dep))
3933 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3934 "")
3935 (or (mail-header-xref header) "")))
3936 (setq header nil)))
3937
3938 (when (and header (not replaced))
3939 ;; First check that we are not creating a References loop.
3940 (setq parent-id (gnus-parent-id (mail-header-references header)))
3941 (setq ref parent-id)
3942 (while (and ref
3943 (setq ref-dep (intern-soft ref dependencies))
3944 (boundp ref-dep)
3945 (setq ref-header (car (symbol-value ref-dep))))
3946 (if (string= id ref)
3947 ;; Yuk! This is a reference loop. Make the article be a
3948 ;; root article.
3949 (progn
3950 (mail-header-set-references (car (symbol-value id-dep)) "none")
3951 (setq ref nil)
3952 (setq parent-id nil))
3953 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3954 (setq ref-dep (intern (or parent-id "none") dependencies))
3955 (if (boundp ref-dep)
3956 (setcdr (symbol-value ref-dep)
3957 (nconc (cdr (symbol-value ref-dep))
3958 (list (symbol-value id-dep))))
3959 (set ref-dep (list nil (symbol-value id-dep)))))
3960 header))
3961
3962 (defun gnus-extract-message-id-from-in-reply-to (string)
3963 (if (string-match "<[^>]+>" string)
3964 (substring string (match-beginning 0) (match-end 0))
3965 nil))
3966
3967 (defun gnus-build-sparse-threads ()
3968 (let ((headers gnus-newsgroup-headers)
3969 (mail-parse-charset gnus-newsgroup-charset)
3970 (gnus-summary-ignore-duplicates t)
3971 header references generation relations
3972 subject child end new-child date)
3973 ;; First we create an alist of generations/relations, where
3974 ;; generations is how much we trust the relation, and the relation
3975 ;; is parent/child.
3976 (gnus-message 7 "Making sparse threads...")
3977 (save-excursion
3978 (nnheader-set-temp-buffer " *gnus sparse threads*")
3979 (while (setq header (pop headers))
3980 (when (and (setq references (mail-header-references header))
3981 (not (string= references "")))
3982 (insert references)
3983 (setq child (mail-header-id header)
3984 subject (mail-header-subject header)
3985 date (mail-header-date header)
3986 generation 0)
3987 (while (search-backward ">" nil t)
3988 (setq end (1+ (point)))
3989 (when (search-backward "<" nil t)
3990 (setq new-child (buffer-substring (point) end))
3991 (push (list (incf generation)
3992 child (setq child new-child)
3993 subject date)
3994 relations)))
3995 (when child
3996 (push (list (1+ generation) child nil subject) relations))
3997 (erase-buffer)))
3998 (kill-buffer (current-buffer)))
3999 ;; Sort over trustworthiness.
4000 (mapcar
4001 (lambda (relation)
4002 (when (gnus-dependencies-add-header
4003 (make-full-mail-header
4004 gnus-reffed-article-number
4005 (nth 3 relation) "" (or (nth 4 relation) "")
4006 (nth 1 relation)
4007 (or (nth 2 relation) "") 0 0 "")
4008 gnus-newsgroup-dependencies nil)
4009 (push gnus-reffed-article-number gnus-newsgroup-limit)
4010 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4011 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4012 gnus-newsgroup-reads)
4013 (decf gnus-reffed-article-number)))
4014 (sort relations 'car-less-than-car))
4015 (gnus-message 7 "Making sparse threads...done")))
4016
4017 (defun gnus-build-old-threads ()
4018 ;; Look at all the articles that refer back to old articles, and
4019 ;; fetch the headers for the articles that aren't there. This will
4020 ;; build complete threads - if the roots haven't been expired by the
4021 ;; server, that is.
4022 (let ((mail-parse-charset gnus-newsgroup-charset)
4023 id heads)
4024 (mapatoms
4025 (lambda (refs)
4026 (when (not (car (symbol-value refs)))
4027 (setq heads (cdr (symbol-value refs)))
4028 (while heads
4029 (if (memq (mail-header-number (caar heads))
4030 gnus-newsgroup-dormant)
4031 (setq heads (cdr heads))
4032 (setq id (symbol-name refs))
4033 (while (and (setq id (gnus-build-get-header id))
4034 (not (car (gnus-id-to-thread id)))))
4035 (setq heads nil)))))
4036 gnus-newsgroup-dependencies)))
4037
4038 (defsubst gnus-remove-odd-characters (string)
4039 "Translate STRING into something that doesn't contain weird characters."
4040 (mm-subst-char-in-string
4041 ?\r ?\-
4042 (mm-subst-char-in-string
4043 ?\n ?\- string)))
4044
4045 ;; This function has to be called with point after the article number
4046 ;; on the beginning of the line.
4047 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4048 (let ((eol (gnus-point-at-eol))
4049 (buffer (current-buffer))
4050 header references in-reply-to)
4051
4052 ;; overview: [num subject from date id refs chars lines misc]
4053 (unwind-protect
4054 (let (x)
4055 (narrow-to-region (point) eol)
4056 (unless (eobp)
4057 (forward-char))
4058
4059 (setq header
4060 (make-full-mail-header
4061 number ; number
4062 (condition-case () ; subject
4063 (gnus-remove-odd-characters
4064 (funcall gnus-decode-encoded-word-function
4065 (setq x (nnheader-nov-field))))
4066 (error x))
4067 (condition-case () ; from
4068 (gnus-remove-odd-characters
4069 (funcall gnus-decode-encoded-word-function
4070 (setq x (nnheader-nov-field))))
4071 (error x))
4072 (nnheader-nov-field) ; date
4073 (nnheader-nov-read-message-id) ; id
4074 (setq references (nnheader-nov-field)) ; refs
4075 (nnheader-nov-read-integer) ; chars
4076 (nnheader-nov-read-integer) ; lines
4077 (unless (eobp)
4078 (if (looking-at "Xref: ")
4079 (goto-char (match-end 0)))
4080 (nnheader-nov-field)) ; Xref
4081 (nnheader-nov-parse-extra)))) ; extra
4082
4083 (widen))
4084
4085 (when (and (string= references "")
4086 (setq in-reply-to (mail-header-extra header))
4087 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4088 (mail-header-set-references
4089 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4090
4091 (when gnus-alter-header-function
4092 (funcall gnus-alter-header-function header))
4093 (gnus-dependencies-add-header header dependencies force-new)))
4094
4095 (defun gnus-build-get-header (id)
4096 "Look through the buffer of NOV lines and find the header to ID.
4097 Enter this line into the dependencies hash table, and return
4098 the id of the parent article (if any)."
4099 (let ((deps gnus-newsgroup-dependencies)
4100 found header)
4101 (prog1
4102 (save-excursion
4103 (set-buffer nntp-server-buffer)
4104 (let ((case-fold-search nil))
4105 (goto-char (point-min))
4106 (while (and (not found)
4107 (search-forward id nil t))
4108 (beginning-of-line)
4109 (setq found (looking-at
4110 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4111 (regexp-quote id))))
4112 (or found (beginning-of-line 2)))
4113 (when found
4114 (beginning-of-line)
4115 (and
4116 (setq header (gnus-nov-parse-line
4117 (read (current-buffer)) deps))
4118 (gnus-parent-id (mail-header-references header))))))
4119 (when header
4120 (let ((number (mail-header-number header)))
4121 (push number gnus-newsgroup-limit)
4122 (push header gnus-newsgroup-headers)
4123 (if (memq number gnus-newsgroup-unselected)
4124 (progn
4125 (setq gnus-newsgroup-unreads
4126 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4127 number))
4128 (setq gnus-newsgroup-unselected
4129 (delq number gnus-newsgroup-unselected)))
4130 (push number gnus-newsgroup-ancient)))))))
4131
4132 (defun gnus-build-all-threads ()
4133 "Read all the headers."
4134 (let ((gnus-summary-ignore-duplicates t)
4135 (mail-parse-charset gnus-newsgroup-charset)
4136 (dependencies gnus-newsgroup-dependencies)
4137 header article)
4138 (save-excursion
4139 (set-buffer nntp-server-buffer)
4140 (let ((case-fold-search nil))
4141 (goto-char (point-min))
4142 (while (not (eobp))
4143 (ignore-errors
4144 (setq article (read (current-buffer))
4145 header (gnus-nov-parse-line article dependencies)))
4146 (when header
4147 (save-excursion
4148 (set-buffer gnus-summary-buffer)
4149 (push header gnus-newsgroup-headers)
4150 (if (memq (setq article (mail-header-number header))
4151 gnus-newsgroup-unselected)
4152 (progn
4153 (setq gnus-newsgroup-unreads
4154 (gnus-add-to-sorted-list
4155 gnus-newsgroup-unreads article))
4156 (setq gnus-newsgroup-unselected
4157 (delq article gnus-newsgroup-unselected)))
4158 (push article gnus-newsgroup-ancient)))
4159 (forward-line 1)))))))
4160
4161 (defun gnus-summary-update-article-line (article header)
4162 "Update the line for ARTICLE using HEADER."
4163 (let* ((id (mail-header-id header))
4164 (thread (gnus-id-to-thread id)))
4165 (unless thread
4166 (error "Article in no thread"))
4167 ;; Update the thread.
4168 (setcar thread header)
4169 (gnus-summary-goto-subject article)
4170 (let* ((datal (gnus-data-find-list article))
4171 (data (car datal))
4172 (buffer-read-only nil)
4173 (level (gnus-summary-thread-level)))
4174 (gnus-delete-line)
4175 (let ((inserted (- (point)
4176 (progn
4177 (gnus-summary-insert-line
4178 header level nil
4179 (memq article gnus-newsgroup-undownloaded)
4180 (gnus-article-mark article)
4181 (memq article gnus-newsgroup-replied)
4182 (memq article gnus-newsgroup-expirable)
4183 ;; Only insert the Subject string when it's different
4184 ;; from the previous Subject string.
4185 (if (and
4186 gnus-show-threads
4187 (gnus-subject-equal
4188 (condition-case ()
4189 (mail-header-subject
4190 (gnus-data-header
4191 (cadr
4192 (gnus-data-find-list
4193 article
4194 (gnus-data-list t)))))
4195 ;; Error on the side of excessive subjects.
4196 (error ""))
4197 (mail-header-subject header)))
4198 ""
4199 (mail-header-subject header))
4200 nil (cdr (assq article gnus-newsgroup-scored))
4201 (memq article gnus-newsgroup-processable))
4202 (point)))))
4203 (when (cdr datal)
4204 (gnus-data-update-list
4205 (cdr datal)
4206 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4207
4208 (defun gnus-summary-update-article (article &optional iheader)
4209 "Update ARTICLE in the summary buffer."
4210 (set-buffer gnus-summary-buffer)
4211 (let* ((header (gnus-summary-article-header article))
4212 (id (mail-header-id header))
4213 (data (gnus-data-find article))
4214 (thread (gnus-id-to-thread id))
4215 (references (mail-header-references header))
4216 (parent
4217 (gnus-id-to-thread
4218 (or (gnus-parent-id
4219 (when (and references
4220 (not (equal "" references)))
4221 references))
4222 "none")))
4223 (buffer-read-only nil)
4224 (old (car thread)))
4225 (when thread
4226 (unless iheader
4227 (setcar thread nil)
4228 (when parent
4229 (delq thread parent)))
4230 (if (gnus-summary-insert-subject id header)
4231 ;; Set the (possibly) new article number in the data structure.
4232 (gnus-data-set-number data (gnus-id-to-article id))
4233 (setcar thread old)
4234 nil))))
4235
4236 (defun gnus-rebuild-thread (id &optional line)
4237 "Rebuild the thread containing ID.
4238 If LINE, insert the rebuilt thread starting on line LINE."
4239 (let ((buffer-read-only nil)
4240 old-pos current thread data)
4241 (if (not gnus-show-threads)
4242 (setq thread (list (car (gnus-id-to-thread id))))
4243 ;; Get the thread this article is part of.
4244 (setq thread (gnus-remove-thread id)))
4245 (setq old-pos (gnus-point-at-bol))
4246 (setq current (save-excursion
4247 (and (re-search-backward "[\r\n]" nil t)
4248 (gnus-summary-article-number))))
4249 ;; If this is a gathered thread, we have to go some re-gathering.
4250 (when (stringp (car thread))
4251 (let ((subject (car thread))
4252 roots thr)
4253 (setq thread (cdr thread))
4254 (while thread
4255 (unless (memq (setq thr (gnus-id-to-thread
4256 (gnus-root-id
4257 (mail-header-id (caar thread)))))
4258 roots)
4259 (push thr roots))
4260 (setq thread (cdr thread)))
4261 ;; We now have all (unique) roots.
4262 (if (= (length roots) 1)
4263 ;; All the loose roots are now one solid root.
4264 (setq thread (car roots))
4265 (setq thread (cons subject (gnus-sort-threads roots))))))
4266 (let (threads)
4267 ;; We then insert this thread into the summary buffer.
4268 (when line
4269 (goto-char (point-min))
4270 (forward-line (1- line)))
4271 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4272 (if gnus-show-threads
4273 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4274 (gnus-summary-prepare-unthreaded thread))
4275 (setq data (nreverse gnus-newsgroup-data))
4276 (setq threads gnus-newsgroup-threads))
4277 ;; We splice the new data into the data structure.
4278 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4279 ;;!!! then we want to insert at the beginning of the buffer.
4280 ;;!!! That happens to be true with Gnus now, but that may
4281 ;;!!! change in the future. Perhaps.
4282 (gnus-data-enter-list
4283 (if line nil current) data (- (point) old-pos))
4284 (setq gnus-newsgroup-threads
4285 (nconc threads gnus-newsgroup-threads))
4286 (gnus-data-compute-positions))))
4287
4288 (defun gnus-number-to-header (number)
4289 "Return the header for article NUMBER."
4290 (let ((headers gnus-newsgroup-headers))
4291 (while (and headers
4292 (not (= number (mail-header-number (car headers)))))
4293 (pop headers))
4294 (when headers
4295 (car headers))))
4296
4297 (defun gnus-parent-headers (in-headers &optional generation)
4298 "Return the headers of the GENERATIONeth parent of HEADERS."
4299 (unless generation
4300 (setq generation 1))
4301 (let ((parent t)
4302 (headers in-headers)
4303 references)
4304 (while (and parent
4305 (not (zerop generation))
4306 (setq references (mail-header-references headers)))
4307 (setq headers (if (and references
4308 (setq parent (gnus-parent-id references)))
4309 (car (gnus-id-to-thread parent))
4310 nil))
4311 (decf generation))
4312 (and (not (eq headers in-headers))
4313 headers)))
4314
4315 (defun gnus-id-to-thread (id)
4316 "Return the (sub-)thread where ID appears."
4317 (gnus-gethash id gnus-newsgroup-dependencies))
4318
4319 (defun gnus-id-to-article (id)
4320 "Return the article number of ID."
4321 (let ((thread (gnus-id-to-thread id)))
4322 (when (and thread
4323 (car thread))
4324 (mail-header-number (car thread)))))
4325
4326 (defun gnus-id-to-header (id)
4327 "Return the article headers of ID."
4328 (car (gnus-id-to-thread id)))
4329
4330 (defun gnus-article-displayed-root-p (article)
4331 "Say whether ARTICLE is a root(ish) article."
4332 (let ((level (gnus-summary-thread-level article))
4333 (refs (mail-header-references (gnus-summary-article-header article)))
4334 particle)
4335 (cond
4336 ((null level) nil)
4337 ((zerop level) t)
4338 ((null refs) t)
4339 ((null (gnus-parent-id refs)) t)
4340 ((and (= 1 level)
4341 (null (setq particle (gnus-id-to-article
4342 (gnus-parent-id refs))))
4343 (null (gnus-summary-thread-level particle)))))))
4344
4345 (defun gnus-root-id (id)
4346 "Return the id of the root of the thread where ID appears."
4347 (let (last-id prev)
4348 (while (and id (setq prev (car (gnus-id-to-thread id))))
4349 (setq last-id id
4350 id (gnus-parent-id (mail-header-references prev))))
4351 last-id))
4352
4353 (defun gnus-articles-in-thread (thread)
4354 "Return the list of articles in THREAD."
4355 (cons (mail-header-number (car thread))
4356 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4357
4358 (defun gnus-remove-thread (id &optional dont-remove)
4359 "Remove the thread that has ID in it."
4360 (let (headers thread last-id)
4361 ;; First go up in this thread until we find the root.
4362 (setq last-id (gnus-root-id id)
4363 headers (message-flatten-list (gnus-id-to-thread last-id)))
4364 ;; We have now found the real root of this thread. It might have
4365 ;; been gathered into some loose thread, so we have to search
4366 ;; through the threads to find the thread we wanted.
4367 (let ((threads gnus-newsgroup-threads)
4368 sub)
4369 (while threads
4370 (setq sub (car threads))
4371 (if (stringp (car sub))
4372 ;; This is a gathered thread, so we look at the roots
4373 ;; below it to find whether this article is in this
4374 ;; gathered root.
4375 (progn
4376 (setq sub (cdr sub))
4377 (while sub
4378 (when (member (caar sub) headers)
4379 (setq thread (car threads)
4380 threads nil
4381 sub nil))
4382 (setq sub (cdr sub))))
4383 ;; It's an ordinary thread, so we check it.
4384 (when (eq (car sub) (car headers))
4385 (setq thread sub
4386 threads nil)))
4387 (setq threads (cdr threads)))
4388 ;; If this article is in no thread, then it's a root.
4389 (if thread
4390 (unless dont-remove
4391 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4392 (setq thread (gnus-id-to-thread last-id)))
4393 (when thread
4394 (prog1
4395 thread ; We return this thread.
4396 (unless dont-remove
4397 (if (stringp (car thread))
4398 (progn
4399 ;; If we use dummy roots, then we have to remove the
4400 ;; dummy root as well.
4401 (when (eq gnus-summary-make-false-root 'dummy)
4402 ;; We go to the dummy root by going to
4403 ;; the first sub-"thread", and then one line up.
4404 (gnus-summary-goto-article
4405 (mail-header-number (caadr thread)))
4406 (forward-line -1)
4407 (gnus-delete-line)
4408 (gnus-data-compute-positions))
4409 (setq thread (cdr thread))
4410 (while thread
4411 (gnus-remove-thread-1 (car thread))
4412 (setq thread (cdr thread))))
4413 (gnus-remove-thread-1 thread))))))))
4414
4415 (defun gnus-remove-thread-1 (thread)
4416 "Remove the thread THREAD recursively."
4417 (let ((number (mail-header-number (pop thread)))
4418 d)
4419 (setq thread (reverse thread))
4420 (while thread
4421 (gnus-remove-thread-1 (pop thread)))
4422 (when (setq d (gnus-data-find number))
4423 (goto-char (gnus-data-pos d))
4424 (gnus-summary-show-thread)
4425 (gnus-data-remove
4426 number
4427 (- (gnus-point-at-bol)
4428 (prog1
4429 (1+ (gnus-point-at-eol))
4430 (gnus-delete-line)))))))
4431
4432 (defun gnus-sort-threads-1 (threads func)
4433 (sort (mapcar (lambda (thread)
4434 (cons (car thread)
4435 (and (cdr thread)
4436 (gnus-sort-threads-1 (cdr thread) func))))
4437 threads) func))
4438
4439 (defun gnus-sort-threads (threads)
4440 "Sort THREADS."
4441 (if (not gnus-thread-sort-functions)
4442 threads
4443 (gnus-message 8 "Sorting threads...")
4444 (let ((max-lisp-eval-depth 5000))
4445 (prog1 (gnus-sort-threads-1
4446 threads
4447 (gnus-make-sort-function gnus-thread-sort-functions))
4448 (gnus-message 8 "Sorting threads...done")))))
4449
4450 (defun gnus-sort-articles (articles)
4451 "Sort ARTICLES."
4452 (when gnus-article-sort-functions
4453 (gnus-message 7 "Sorting articles...")
4454 (prog1
4455 (setq gnus-newsgroup-headers
4456 (sort articles (gnus-make-sort-function
4457 gnus-article-sort-functions)))
4458 (gnus-message 7 "Sorting articles...done"))))
4459
4460 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4461 (defmacro gnus-thread-header (thread)
4462 "Return header of first article in THREAD.
4463 Note that THREAD must never, ever be anything else than a variable -
4464 using some other form will lead to serious barfage."
4465 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4466 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4467 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4468 (vector thread) 2))
4469
4470 (defsubst gnus-article-sort-by-number (h1 h2)
4471 "Sort articles by article number."
4472 (< (mail-header-number h1)
4473 (mail-header-number h2)))
4474
4475 (defun gnus-thread-sort-by-number (h1 h2)
4476 "Sort threads by root article number."
4477 (gnus-article-sort-by-number
4478 (gnus-thread-header h1) (gnus-thread-header h2)))
4479
4480 (defsubst gnus-article-sort-by-random (h1 h2)
4481 "Sort articles by article number."
4482 (zerop (random 2)))
4483
4484 (defun gnus-thread-sort-by-random (h1 h2)
4485 "Sort threads by root article number."
4486 (gnus-article-sort-by-random
4487 (gnus-thread-header h1) (gnus-thread-header h2)))
4488
4489 (defsubst gnus-article-sort-by-lines (h1 h2)
4490 "Sort articles by article Lines header."
4491 (< (mail-header-lines h1)
4492 (mail-header-lines h2)))
4493
4494 (defun gnus-thread-sort-by-lines (h1 h2)
4495 "Sort threads by root article Lines header."
4496 (gnus-article-sort-by-lines
4497 (gnus-thread-header h1) (gnus-thread-header h2)))
4498
4499 (defsubst gnus-article-sort-by-chars (h1 h2)
4500 "Sort articles by octet length."
4501 (< (mail-header-chars h1)
4502 (mail-header-chars h2)))
4503
4504 (defun gnus-thread-sort-by-chars (h1 h2)
4505 "Sort threads by root article octet length."
4506 (gnus-article-sort-by-chars
4507 (gnus-thread-header h1) (gnus-thread-header h2)))
4508
4509 (defsubst gnus-article-sort-by-author (h1 h2)
4510 "Sort articles by root author."
4511 (string-lessp
4512 (let ((extract (funcall
4513 gnus-extract-address-components
4514 (mail-header-from h1))))
4515 (or (car extract) (cadr extract) ""))
4516 (let ((extract (funcall
4517 gnus-extract-address-components
4518 (mail-header-from h2))))
4519 (or (car extract) (cadr extract) ""))))
4520
4521 (defun gnus-thread-sort-by-author (h1 h2)
4522 "Sort threads by root author."
4523 (gnus-article-sort-by-author
4524 (gnus-thread-header h1) (gnus-thread-header h2)))
4525
4526 (defsubst gnus-article-sort-by-subject (h1 h2)
4527 "Sort articles by root subject."
4528 (string-lessp
4529 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4530 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4531
4532 (defun gnus-thread-sort-by-subject (h1 h2)
4533 "Sort threads by root subject."
4534 (gnus-article-sort-by-subject
4535 (gnus-thread-header h1) (gnus-thread-header h2)))
4536
4537 (defsubst gnus-article-sort-by-date (h1 h2)
4538 "Sort articles by root article date."
4539 (time-less-p
4540 (gnus-date-get-time (mail-header-date h1))
4541 (gnus-date-get-time (mail-header-date h2))))
4542
4543 (defun gnus-thread-sort-by-date (h1 h2)
4544 "Sort threads by root article date."
4545 (gnus-article-sort-by-date
4546 (gnus-thread-header h1) (gnus-thread-header h2)))
4547
4548 (defsubst gnus-article-sort-by-score (h1 h2)
4549 "Sort articles by root article score.
4550 Unscored articles will be counted as having a score of zero."
4551 (> (or (cdr (assq (mail-header-number h1)
4552 gnus-newsgroup-scored))
4553 gnus-summary-default-score 0)
4554 (or (cdr (assq (mail-header-number h2)
4555 gnus-newsgroup-scored))
4556 gnus-summary-default-score 0)))
4557
4558 (defun gnus-thread-sort-by-score (h1 h2)
4559 "Sort threads by root article score."
4560 (gnus-article-sort-by-score
4561 (gnus-thread-header h1) (gnus-thread-header h2)))
4562
4563 (defun gnus-thread-sort-by-total-score (h1 h2)
4564 "Sort threads by the sum of all scores in the thread.
4565 Unscored articles will be counted as having a score of zero."
4566 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4567
4568 (defun gnus-thread-total-score (thread)
4569 ;; This function find the total score of THREAD.
4570 (cond
4571 ((null thread)
4572 0)
4573 ((consp thread)
4574 (if (stringp (car thread))
4575 (apply gnus-thread-score-function 0
4576 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4577 (gnus-thread-total-score-1 thread)))
4578 (t
4579 (gnus-thread-total-score-1 (list thread)))))
4580
4581 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4582 "Sort threads such that the thread with the most recently arrived article comes first."
4583 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4584
4585 (defun gnus-thread-highest-number (thread)
4586 "Return the highest article number in THREAD."
4587 (apply 'max (mapcar (lambda (header)
4588 (mail-header-number header))
4589 (message-flatten-list thread))))
4590
4591 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4592 "Sort threads such that the thread with the most recently dated article comes first."
4593 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4594
4595 (defun gnus-thread-latest-date (thread)
4596 "Return the highest article date in THREAD."
4597 (let ((previous-time 0))
4598 (apply 'max
4599 (mapcar
4600 (lambda (header)
4601 (setq previous-time
4602 (condition-case ()
4603 (time-to-seconds (mail-header-parse-date
4604 (mail-header-date header)))
4605 (error previous-time))))
4606 (sort
4607 (message-flatten-list thread)
4608 (lambda (h1 h2)
4609 (< (mail-header-number h1)
4610 (mail-header-number h2))))))))
4611
4612 (defun gnus-thread-total-score-1 (root)
4613 ;; This function find the total score of the thread below ROOT.
4614 (setq root (car root))
4615 (apply gnus-thread-score-function
4616 (or (append
4617 (mapcar 'gnus-thread-total-score
4618 (cdr (gnus-id-to-thread (mail-header-id root))))
4619 (when (> (mail-header-number root) 0)
4620 (list (or (cdr (assq (mail-header-number root)
4621 gnus-newsgroup-scored))
4622 gnus-summary-default-score 0))))
4623 (list gnus-summary-default-score)
4624 '(0))))
4625
4626 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4627 (defvar gnus-tmp-prev-subject nil)
4628 (defvar gnus-tmp-false-parent nil)
4629 (defvar gnus-tmp-root-expunged nil)
4630 (defvar gnus-tmp-dummy-line nil)
4631
4632 (eval-when-compile (defvar gnus-tmp-header))
4633 (defun gnus-extra-header (type &optional header)
4634 "Return the extra header of TYPE."
4635 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4636 ""))
4637
4638 (defvar gnus-tmp-thread-tree-header-string "")
4639
4640 (defcustom gnus-sum-thread-tree-root "> "
4641 "With %B spec, used for the root of a thread.
4642 If nil, use subject instead."
4643 :version "22.1"
4644 :type '(radio (const :format "%v " nil) string)
4645 :group 'gnus-thread)
4646 (defcustom gnus-sum-thread-tree-false-root "> "
4647 "With %B spec, used for a false root of a thread.
4648 If nil, use subject instead."
4649 :version "22.1"
4650 :type '(radio (const :format "%v " nil) string)
4651 :group 'gnus-thread)
4652 (defcustom gnus-sum-thread-tree-single-indent ""
4653 "With %B spec, used for a thread with just one message.
4654 If nil, use subject instead."
4655 :version "22.1"
4656 :type '(radio (const :format "%v " nil) string)
4657 :group 'gnus-thread)
4658 (defcustom gnus-sum-thread-tree-vertical "| "
4659 "With %B spec, used for drawing a vertical line."
4660 :version "22.1"
4661 :type 'string
4662 :group 'gnus-thread)
4663 (defcustom gnus-sum-thread-tree-indent " "
4664 "With %B spec, used for indenting."
4665 :version "22.1"
4666 :type 'string
4667 :group 'gnus-thread)
4668 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4669 "With %B spec, used for a leaf with brothers."
4670 :version "22.1"
4671 :type 'string
4672 :group 'gnus-thread)
4673 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4674 "With %B spec, used for a leaf without brothers."
4675 :version "22.1"
4676 :type 'string
4677 :group 'gnus-thread)
4678
4679 (defun gnus-summary-prepare-threads (threads)
4680 "Prepare summary buffer from THREADS and indentation LEVEL.
4681 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4682 or a straight list of headers."
4683 (gnus-message 7 "Generating summary...")
4684
4685 (setq gnus-newsgroup-threads threads)
4686 (beginning-of-line)
4687
4688 (let ((gnus-tmp-level 0)
4689 (default-score (or gnus-summary-default-score 0))
4690 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4691 (building-line-count gnus-summary-display-while-building)
4692 (building-count (integerp gnus-summary-display-while-building))
4693 thread number subject stack state gnus-tmp-gathered beg-match
4694 new-roots gnus-tmp-new-adopts thread-end simp-subject
4695 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4696 gnus-tmp-replied gnus-tmp-subject-or-nil
4697 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4698 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4699 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4700 tree-stack)
4701
4702 (setq gnus-tmp-prev-subject nil
4703 gnus-tmp-thread-tree-header-string "")
4704
4705 (if (vectorp (car threads))
4706 ;; If this is a straight (sic) list of headers, then a
4707 ;; threaded summary display isn't required, so we just create
4708 ;; an unthreaded one.
4709 (gnus-summary-prepare-unthreaded threads)
4710
4711 ;; Do the threaded display.
4712
4713 (if gnus-summary-display-while-building
4714 (switch-to-buffer (buffer-name)))
4715 (while (or threads stack gnus-tmp-new-adopts new-roots)
4716
4717 (if (and (= gnus-tmp-level 0)
4718 (or (not stack)
4719 (= (caar stack) 0))
4720 (not gnus-tmp-false-parent)
4721 (or gnus-tmp-new-adopts new-roots))
4722 (if gnus-tmp-new-adopts
4723 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4724 thread (list (car gnus-tmp-new-adopts))
4725 gnus-tmp-header (caar thread)
4726 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4727 (when new-roots
4728 (setq thread (list (car new-roots))
4729 gnus-tmp-header (caar thread)
4730 new-roots (cdr new-roots))))
4731
4732 (if threads
4733 ;; If there are some threads, we do them before the
4734 ;; threads on the stack.
4735 (setq thread threads
4736 gnus-tmp-header (caar thread))
4737 ;; There were no current threads, so we pop something off
4738 ;; the stack.
4739 (setq state (car stack)
4740 gnus-tmp-level (car state)
4741 tree-stack (cadr state)
4742 thread (caddr state)
4743 stack (cdr stack)
4744 gnus-tmp-header (caar thread))))
4745
4746 (setq gnus-tmp-false-parent nil)
4747 (setq gnus-tmp-root-expunged nil)
4748 (setq thread-end nil)
4749
4750 (if (stringp gnus-tmp-header)
4751 ;; The header is a dummy root.
4752 (cond
4753 ((eq gnus-summary-make-false-root 'adopt)
4754 ;; We let the first article adopt the rest.
4755 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4756 (cddar thread)))
4757 (setq gnus-tmp-gathered
4758 (nconc (mapcar
4759 (lambda (h) (mail-header-number (car h)))
4760 (cddar thread))
4761 gnus-tmp-gathered))
4762 (setq thread (cons (list (caar thread)
4763 (cadar thread))
4764 (cdr thread)))
4765 (setq gnus-tmp-level -1
4766 gnus-tmp-false-parent t))
4767 ((eq gnus-summary-make-false-root 'empty)
4768 ;; We print adopted articles with empty subject fields.
4769 (setq gnus-tmp-gathered
4770 (nconc (mapcar
4771 (lambda (h) (mail-header-number (car h)))
4772 (cddar thread))
4773 gnus-tmp-gathered))
4774 (setq gnus-tmp-level -1))
4775 ((eq gnus-summary-make-false-root 'dummy)
4776 ;; We remember that we probably want to output a dummy
4777 ;; root.
4778 (setq gnus-tmp-dummy-line gnus-tmp-header)
4779 (setq gnus-tmp-prev-subject gnus-tmp-header))
4780 (t
4781 ;; We do not make a root for the gathered
4782 ;; sub-threads at all.
4783 (setq gnus-tmp-level -1)))
4784
4785 (setq number (mail-header-number gnus-tmp-header)
4786 subject (mail-header-subject gnus-tmp-header)
4787 simp-subject (gnus-simplify-subject-fully subject))
4788
4789 (cond
4790 ;; If the thread has changed subject, we might want to make
4791 ;; this subthread into a root.
4792 ((and (null gnus-thread-ignore-subject)
4793 (not (zerop gnus-tmp-level))
4794 gnus-tmp-prev-subject
4795 (not (string= gnus-tmp-prev-subject simp-subject)))
4796 (setq new-roots (nconc new-roots (list (car thread)))
4797 thread-end t
4798 gnus-tmp-header nil))
4799 ;; If the article lies outside the current limit,
4800 ;; then we do not display it.
4801 ((not (memq number gnus-newsgroup-limit))
4802 (setq gnus-tmp-gathered
4803 (nconc (mapcar
4804 (lambda (h) (mail-header-number (car h)))
4805 (cdar thread))
4806 gnus-tmp-gathered))
4807 (setq gnus-tmp-new-adopts (if (cdar thread)
4808 (append gnus-tmp-new-adopts
4809 (cdar thread))
4810 gnus-tmp-new-adopts)
4811 thread-end t
4812 gnus-tmp-header nil)
4813 (when (zerop gnus-tmp-level)
4814 (setq gnus-tmp-root-expunged t)))
4815 ;; Perhaps this article is to be marked as read?
4816 ((and gnus-summary-mark-below
4817 (< (or (cdr (assq number gnus-newsgroup-scored))
4818 default-score)
4819 gnus-summary-mark-below)
4820 ;; Don't touch sparse articles.
4821 (not (gnus-summary-article-sparse-p number))
4822 (not (gnus-summary-article-ancient-p number)))
4823 (setq gnus-newsgroup-unreads
4824 (delq number gnus-newsgroup-unreads))
4825 (if gnus-newsgroup-auto-expire
4826 (setq gnus-newsgroup-expirable
4827 (gnus-add-to-sorted-list
4828 gnus-newsgroup-expirable number))
4829 (push (cons number gnus-low-score-mark)
4830 gnus-newsgroup-reads))))
4831
4832 (when gnus-tmp-header
4833 ;; We may have an old dummy line to output before this
4834 ;; article.
4835 (when (and gnus-tmp-dummy-line
4836 (gnus-subject-equal
4837 gnus-tmp-dummy-line
4838 (mail-header-subject gnus-tmp-header)))
4839 (gnus-summary-insert-dummy-line
4840 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4841 (setq gnus-tmp-dummy-line nil))
4842
4843 ;; Compute the mark.
4844 (setq gnus-tmp-unread (gnus-article-mark number))
4845
4846 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4847 gnus-tmp-header gnus-tmp-level)
4848 gnus-newsgroup-data)
4849
4850 ;; Actually insert the line.
4851 (setq
4852 gnus-tmp-subject-or-nil
4853 (cond
4854 ((and gnus-thread-ignore-subject
4855 gnus-tmp-prev-subject
4856 (not (string= gnus-tmp-prev-subject simp-subject)))
4857 subject)
4858 ((zerop gnus-tmp-level)
4859 (if (and (eq gnus-summary-make-false-root 'empty)
4860 (memq number gnus-tmp-gathered)
4861 gnus-tmp-prev-subject
4862 (string= gnus-tmp-prev-subject simp-subject))
4863 gnus-summary-same-subject
4864 subject))
4865 (t gnus-summary-same-subject)))
4866 (if (and (eq gnus-summary-make-false-root 'adopt)
4867 (= gnus-tmp-level 1)
4868 (memq number gnus-tmp-gathered))
4869 (setq gnus-tmp-opening-bracket ?\<
4870 gnus-tmp-closing-bracket ?\>)
4871 (setq gnus-tmp-opening-bracket ?\[
4872 gnus-tmp-closing-bracket ?\]))
4873 (setq
4874 gnus-tmp-indentation
4875 (aref gnus-thread-indent-array gnus-tmp-level)
4876 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4877 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4878 gnus-summary-default-score 0)
4879 gnus-tmp-score-char
4880 (if (or (null gnus-summary-default-score)
4881 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4882 gnus-summary-zcore-fuzz))
4883 ? ;Whitespace
4884 (if (< gnus-tmp-score gnus-summary-default-score)
4885 gnus-score-below-mark gnus-score-over-mark))
4886 gnus-tmp-replied
4887 (cond ((memq number gnus-newsgroup-processable)
4888 gnus-process-mark)
4889 ((memq number gnus-newsgroup-cached)
4890 gnus-cached-mark)
4891 ((memq number gnus-newsgroup-replied)
4892 gnus-replied-mark)
4893 ((memq number gnus-newsgroup-forwarded)
4894 gnus-forwarded-mark)
4895 ((memq number gnus-newsgroup-saved)
4896 gnus-saved-mark)
4897 ((memq number gnus-newsgroup-recent)
4898 gnus-recent-mark)
4899 ((memq number gnus-newsgroup-unseen)
4900 gnus-unseen-mark)
4901 (t gnus-no-mark))
4902 gnus-tmp-downloaded
4903 (cond ((memq number gnus-newsgroup-undownloaded)
4904 gnus-undownloaded-mark)
4905 (gnus-newsgroup-agentized
4906 gnus-downloaded-mark)
4907 (t
4908 gnus-no-mark))
4909 gnus-tmp-from (mail-header-from gnus-tmp-header)
4910 gnus-tmp-name
4911 (cond
4912 ((string-match "<[^>]+> *$" gnus-tmp-from)
4913 (setq beg-match (match-beginning 0))
4914 (or (and (string-match "^\".+\"" gnus-tmp-from)
4915 (substring gnus-tmp-from 1 (1- (match-end 0))))
4916 (substring gnus-tmp-from 0 beg-match)))
4917 ((string-match "(.+)" gnus-tmp-from)
4918 (substring gnus-tmp-from
4919 (1+ (match-beginning 0)) (1- (match-end 0))))
4920 (t gnus-tmp-from))
4921
4922 ;; Do the %B string
4923 gnus-tmp-thread-tree-header-string
4924 (cond
4925 ((not gnus-show-threads) "")
4926 ((zerop gnus-tmp-level)
4927 (cond ((cdar thread)
4928 (or gnus-sum-thread-tree-root subject))
4929 (gnus-tmp-new-adopts
4930 (or gnus-sum-thread-tree-false-root subject))
4931 (t
4932 (or gnus-sum-thread-tree-single-indent subject))))
4933 (t
4934 (concat (apply 'concat
4935 (mapcar (lambda (item)
4936 (if (= item 1)
4937 gnus-sum-thread-tree-vertical
4938 gnus-sum-thread-tree-indent))
4939 (cdr (reverse tree-stack))))
4940 (if (nth 1 thread)
4941 gnus-sum-thread-tree-leaf-with-other
4942 gnus-sum-thread-tree-single-leaf)))))
4943 (when (string= gnus-tmp-name "")
4944 (setq gnus-tmp-name gnus-tmp-from))
4945 (unless (numberp gnus-tmp-lines)
4946 (setq gnus-tmp-lines -1))
4947 (if (= gnus-tmp-lines -1)
4948 (setq gnus-tmp-lines "?")
4949 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4950 (gnus-put-text-property
4951 (point)
4952 (progn (eval gnus-summary-line-format-spec) (point))
4953 'gnus-number number)
4954 (when gnus-visual-p
4955 (forward-line -1)
4956 (gnus-run-hooks 'gnus-summary-update-hook)
4957 (forward-line 1))
4958
4959 (setq gnus-tmp-prev-subject simp-subject)))
4960
4961 (when (nth 1 thread)
4962 (push (list (max 0 gnus-tmp-level)
4963 (copy-sequence tree-stack)
4964 (nthcdr 1 thread))
4965 stack))
4966 (push (if (nth 1 thread) 1 0) tree-stack)
4967 (incf gnus-tmp-level)
4968 (setq threads (if thread-end nil (cdar thread)))
4969 (if gnus-summary-display-while-building
4970 (if building-count
4971 (progn
4972 ;; use a set frequency
4973 (setq building-line-count (1- building-line-count))
4974 (when (= building-line-count 0)
4975 (sit-for 0)
4976 (setq building-line-count
4977 gnus-summary-display-while-building)))
4978 ;; always
4979 (sit-for 0)))
4980 (unless threads
4981 (setq gnus-tmp-level 0)))))
4982 (gnus-message 7 "Generating summary...done"))
4983
4984 (defun gnus-summary-prepare-unthreaded (headers)
4985 "Generate an unthreaded summary buffer based on HEADERS."
4986 (let (header number mark)
4987
4988 (beginning-of-line)
4989
4990 (while headers
4991 ;; We may have to root out some bad articles...
4992 (when (memq (setq number (mail-header-number
4993 (setq header (pop headers))))
4994 gnus-newsgroup-limit)
4995 ;; Mark article as read when it has a low score.
4996 (when (and gnus-summary-mark-below
4997 (< (or (cdr (assq number gnus-newsgroup-scored))
4998 gnus-summary-default-score 0)
4999 gnus-summary-mark-below)
5000 (not (gnus-summary-article-ancient-p number)))
5001 (setq gnus-newsgroup-unreads
5002 (delq number gnus-newsgroup-unreads))
5003 (if gnus-newsgroup-auto-expire
5004 (push number gnus-newsgroup-expirable)
5005 (push (cons number gnus-low-score-mark)
5006 gnus-newsgroup-reads)))
5007
5008 (setq mark (gnus-article-mark number))
5009 (push (gnus-data-make number mark (1+ (point)) header 0)
5010 gnus-newsgroup-data)
5011 (gnus-summary-insert-line
5012 header 0 number
5013 (memq number gnus-newsgroup-undownloaded)
5014 mark (memq number gnus-newsgroup-replied)
5015 (memq number gnus-newsgroup-expirable)
5016 (mail-header-subject header) nil
5017 (cdr (assq number gnus-newsgroup-scored))
5018 (memq number gnus-newsgroup-processable))))))
5019
5020 (defun gnus-summary-remove-list-identifiers ()
5021 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5022 (let ((regexp (if (consp gnus-list-identifiers)
5023 (mapconcat 'identity gnus-list-identifiers " *\\|")
5024 gnus-list-identifiers))
5025 changed subject)
5026 (when regexp
5027 (dolist (header gnus-newsgroup-headers)
5028 (setq subject (mail-header-subject header)
5029 changed nil)
5030 (while (string-match
5031 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5032 subject)
5033 (setq subject
5034 (concat (substring subject 0 (match-beginning 2))
5035 (substring subject (match-end 0)))
5036 changed t))
5037 (when (and changed
5038 (string-match
5039 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5040 (setq subject
5041 (concat (substring subject 0 (match-beginning 1))
5042 (substring subject (match-end 1)))))
5043 (when changed
5044 (mail-header-set-subject header subject))))))
5045
5046 (defun gnus-fetch-headers (articles)
5047 "Fetch headers of ARTICLES."
5048 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5049 (gnus-message 5 "Fetching headers for %s..." name)
5050 (prog1
5051 (if (eq 'nov
5052 (setq gnus-headers-retrieved-by
5053 (gnus-retrieve-headers
5054 articles gnus-newsgroup-name
5055 ;; We might want to fetch old headers, but
5056 ;; not if there is only 1 article.
5057 (and (or (and
5058 (not (eq gnus-fetch-old-headers 'some))
5059 (not (numberp gnus-fetch-old-headers)))
5060 (> (length articles) 1))
5061 gnus-fetch-old-headers))))
5062 (gnus-get-newsgroup-headers-xover
5063 articles nil nil gnus-newsgroup-name t)
5064 (gnus-get-newsgroup-headers))
5065 (gnus-message 5 "Fetching headers for %s...done" name))))
5066
5067 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5068 "Select newsgroup GROUP.
5069 If READ-ALL is non-nil, all articles in the group are selected.
5070 If SELECT-ARTICLES, only select those articles from GROUP."
5071 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5072 ;;!!! Dirty hack; should be removed.
5073 (gnus-summary-ignore-duplicates
5074 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5075 t
5076 gnus-summary-ignore-duplicates))
5077 (info (nth 2 entry))
5078 articles fetched-articles cached)
5079
5080 (unless (gnus-check-server
5081 (set (make-local-variable 'gnus-current-select-method)
5082 (gnus-find-method-for-group group)))
5083 (error "Couldn't open server"))
5084
5085 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5086 (gnus-activate-group group) ; Or we can activate it...
5087 (progn ; Or we bug out.
5088 (when (equal major-mode 'gnus-summary-mode)
5089 (gnus-kill-buffer (current-buffer)))
5090 (error "Couldn't activate group %s: %s"
5091 group (gnus-status-message group))))
5092
5093 (unless (gnus-request-group group t)
5094 (when (equal major-mode 'gnus-summary-mode)
5095 (gnus-kill-buffer (current-buffer)))
5096 (error "Couldn't request group %s: %s"
5097 group (gnus-status-message group)))
5098
5099 (when gnus-agent
5100 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5101
5102 (setq gnus-summary-use-undownloaded-faces
5103 (gnus-agent-find-parameter
5104 group
5105 'agent-enable-undownloaded-faces)))
5106
5107 (setq gnus-newsgroup-name group
5108 gnus-newsgroup-unselected nil
5109 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5110
5111 (let ((display (gnus-group-find-parameter group 'display)))
5112 (setq gnus-newsgroup-display
5113 (cond
5114 ((not (zerop (or (car-safe read-all) 0)))
5115 ;; The user entered the group with C-u SPC/RET, let's show
5116 ;; all articles.
5117 'gnus-not-ignore)
5118 ((eq display 'all)
5119 'gnus-not-ignore)
5120 ((arrayp display)
5121 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5122 ((numberp display)
5123 ;; The following is probably the "correct" solution, but
5124 ;; it makes Gnus fetch all headers and then limit the
5125 ;; articles (which is slow), so instead we hack the
5126 ;; select-articles parameter instead. -- Simon Josefsson
5127 ;; <jas@kth.se>
5128 ;;
5129 ;; (gnus-byte-compile
5130 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5131 ;; display)))))
5132 (setq select-articles
5133 (gnus-uncompress-range
5134 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5135 (if (> tmp 0)
5136 tmp
5137 1))
5138 (cdr (gnus-active group)))))
5139 nil)
5140 (t
5141 nil))))
5142
5143 (gnus-summary-setup-default-charset)
5144
5145 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5146 (when (gnus-virtual-group-p group)
5147 (setq cached gnus-newsgroup-cached))
5148
5149 (setq gnus-newsgroup-unreads
5150 (gnus-sorted-ndifference
5151 (gnus-sorted-ndifference gnus-newsgroup-unreads
5152 gnus-newsgroup-marked)
5153 gnus-newsgroup-dormant))
5154
5155 (setq gnus-newsgroup-processable nil)
5156
5157 (gnus-update-read-articles group gnus-newsgroup-unreads)
5158
5159 ;; Adjust and set lists of article marks.
5160 (when info
5161 (gnus-adjust-marked-articles info))
5162 (if (setq articles select-articles)
5163 (setq gnus-newsgroup-unselected
5164 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5165 (setq articles (gnus-articles-to-read group read-all)))
5166
5167 (cond
5168 ((null articles)
5169 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5170 'quit)
5171 ((eq articles 0) nil)
5172 (t
5173 ;; Init the dependencies hash table.
5174 (setq gnus-newsgroup-dependencies
5175 (gnus-make-hashtable (length articles)))
5176 (gnus-set-global-variables)
5177 ;; Retrieve the headers and read them in.
5178
5179 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5180
5181 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5182 (when cached
5183 (setq gnus-newsgroup-cached cached))
5184
5185 ;; Suppress duplicates?
5186 (when gnus-suppress-duplicates
5187 (gnus-dup-suppress-articles))
5188
5189 ;; Set the initial limit.
5190 (setq gnus-newsgroup-limit (copy-sequence articles))
5191 ;; Remove canceled articles from the list of unread articles.
5192 (setq fetched-articles
5193 (mapcar (lambda (headers) (mail-header-number headers))
5194 gnus-newsgroup-headers))
5195 (setq gnus-newsgroup-articles fetched-articles)
5196 (setq gnus-newsgroup-unreads
5197 (gnus-sorted-nintersection
5198 gnus-newsgroup-unreads fetched-articles))
5199 (gnus-compute-unseen-list)
5200
5201 ;; Removed marked articles that do not exist.
5202 (gnus-update-missing-marks
5203 (gnus-sorted-difference articles fetched-articles))
5204 ;; We might want to build some more threads first.
5205 (when (and gnus-fetch-old-headers
5206 (eq gnus-headers-retrieved-by 'nov))
5207 (if (eq gnus-fetch-old-headers 'invisible)
5208 (gnus-build-all-threads)
5209 (gnus-build-old-threads)))
5210 ;; Let the Gnus agent mark articles as read.
5211 (when gnus-agent
5212 (gnus-agent-get-undownloaded-list))
5213 ;; Remove list identifiers from subject
5214 (when gnus-list-identifiers
5215 (gnus-summary-remove-list-identifiers))
5216 ;; Check whether auto-expire is to be done in this group.
5217 (setq gnus-newsgroup-auto-expire
5218 (gnus-group-auto-expirable-p group))
5219 ;; Set up the article buffer now, if necessary.
5220 (unless gnus-single-article-buffer
5221 (gnus-article-setup-buffer))
5222 ;; First and last article in this newsgroup.
5223 (when gnus-newsgroup-headers
5224 (setq gnus-newsgroup-begin
5225 (mail-header-number (car gnus-newsgroup-headers))
5226 gnus-newsgroup-end
5227 (mail-header-number
5228 (gnus-last-element gnus-newsgroup-headers))))
5229 ;; GROUP is successfully selected.
5230 (or gnus-newsgroup-headers t)))))
5231
5232 (defun gnus-compute-unseen-list ()
5233 ;; The `seen' marks are treated specially.
5234 (if (not gnus-newsgroup-seen)
5235 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5236 (setq gnus-newsgroup-unseen
5237 (gnus-inverse-list-range-intersection
5238 gnus-newsgroup-articles gnus-newsgroup-seen))))
5239
5240 (defun gnus-summary-display-make-predicate (display)
5241 (require 'gnus-agent)
5242 (when (= (length display) 1)
5243 (setq display (car display)))
5244 (unless gnus-summary-display-cache
5245 (dolist (elem (append '((unread . unread)
5246 (read . read)
5247 (unseen . unseen))
5248 gnus-article-mark-lists))
5249 (push (cons (cdr elem)
5250 (gnus-byte-compile
5251 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5252 gnus-summary-display-cache)))
5253 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5254 (gnus-category-predicate-cache gnus-summary-display-cache))
5255 (gnus-get-predicate display)))
5256
5257 ;; Uses the dynamically bound `number' variable.
5258 (eval-when-compile
5259 (defvar number))
5260 (defun gnus-article-marked-p (type &optional article)
5261 (let ((article (or article number)))
5262 (cond
5263 ((eq type 'tick)
5264 (memq article gnus-newsgroup-marked))
5265 ((eq type 'spam)
5266 (memq article gnus-newsgroup-spam-marked))
5267 ((eq type 'unsend)
5268 (memq article gnus-newsgroup-unsendable))
5269 ((eq type 'undownload)
5270 (memq article gnus-newsgroup-undownloaded))
5271 ((eq type 'download)
5272 (memq article gnus-newsgroup-downloadable))
5273 ((eq type 'unread)
5274 (memq article gnus-newsgroup-unreads))
5275 ((eq type 'read)
5276 (memq article gnus-newsgroup-reads))
5277 ((eq type 'dormant)
5278 (memq article gnus-newsgroup-dormant) )
5279 ((eq type 'expire)
5280 (memq article gnus-newsgroup-expirable))
5281 ((eq type 'reply)
5282 (memq article gnus-newsgroup-replied))
5283 ((eq type 'killed)
5284 (memq article gnus-newsgroup-killed))
5285 ((eq type 'bookmark)
5286 (assq article gnus-newsgroup-bookmarks))
5287 ((eq type 'score)
5288 (assq article gnus-newsgroup-scored))
5289 ((eq type 'save)
5290 (memq article gnus-newsgroup-saved))
5291 ((eq type 'cache)
5292 (memq article gnus-newsgroup-cached))
5293 ((eq type 'forward)
5294 (memq article gnus-newsgroup-forwarded))
5295 ((eq type 'seen)
5296 (not (memq article gnus-newsgroup-unseen)))
5297 ((eq type 'recent)
5298 (memq article gnus-newsgroup-recent))
5299 (t t))))
5300
5301 (defun gnus-articles-to-read (group &optional read-all)
5302 "Find out what articles the user wants to read."
5303 (let* ((display (gnus-group-find-parameter group 'display))
5304 (articles
5305 ;; Select all articles if `read-all' is non-nil, or if there
5306 ;; are no unread articles.
5307 (if (or read-all
5308 (and (zerop (length gnus-newsgroup-marked))
5309 (zerop (length gnus-newsgroup-unreads)))
5310 ;; Fetch all if the predicate is non-nil.
5311 gnus-newsgroup-display)
5312 ;; We want to select the headers for all the articles in
5313 ;; the group, so we select either all the active
5314 ;; articles in the group, or (if that's nil), the
5315 ;; articles in the cache.
5316 (or
5317 (gnus-uncompress-range (gnus-active group))
5318 (gnus-cache-articles-in-group group))
5319 ;; Select only the "normal" subset of articles.
5320 (gnus-sorted-nunion
5321 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5322 gnus-newsgroup-unreads)))
5323 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5324 (scored (length scored-list))
5325 (number (length articles))
5326 (marked (+ (length gnus-newsgroup-marked)
5327 (length gnus-newsgroup-dormant)))
5328 (select
5329 (cond
5330 ((numberp read-all)
5331 read-all)
5332 ((numberp gnus-newsgroup-display)
5333 gnus-newsgroup-display)
5334 (t
5335 (condition-case ()
5336 (cond
5337 ((and (or (<= scored marked) (= scored number))
5338 (numberp gnus-large-newsgroup)
5339 (> number gnus-large-newsgroup))
5340 (let* ((cursor-in-echo-area nil)
5341 (initial (gnus-parameter-large-newsgroup-initial
5342 gnus-newsgroup-name))
5343 (input
5344 (read-string
5345 (format
5346 "How many articles from %s (%s %d): "
5347 (gnus-limit-string
5348 (gnus-group-decoded-name gnus-newsgroup-name)
5349 35)
5350 (if initial "max" "default")
5351 number)
5352 (if initial
5353 (cons (number-to-string initial)
5354 0)))))
5355 (if (string-match "^[ \t]*$" input) number input)))
5356 ((and (> scored marked) (< scored number)
5357 (> (- scored number) 20))
5358 (let ((input
5359 (read-string
5360 (format "%s %s (%d scored, %d total): "
5361 "How many articles from"
5362 (gnus-group-decoded-name group)
5363 scored number))))
5364 (if (string-match "^[ \t]*$" input)
5365 number input)))
5366 (t number))
5367 (quit
5368 (message "Quit getting the articles to read")
5369 nil))))))
5370 (setq select (if (stringp select) (string-to-number select) select))
5371 (if (or (null select) (zerop select))
5372 select
5373 (if (and (not (zerop scored)) (<= (abs select) scored))
5374 (progn
5375 (setq articles (sort scored-list '<))
5376 (setq number (length articles)))
5377 (setq articles (copy-sequence articles)))
5378
5379 (when (< (abs select) number)
5380 (if (< select 0)
5381 ;; Select the N oldest articles.
5382 (setcdr (nthcdr (1- (abs select)) articles) nil)
5383 ;; Select the N most recent articles.
5384 (setq articles (nthcdr (- number select) articles))))
5385 (setq gnus-newsgroup-unselected
5386 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5387 (when gnus-alter-articles-to-read-function
5388 (setq articles
5389 (sort
5390 (funcall gnus-alter-articles-to-read-function
5391 gnus-newsgroup-name articles)
5392 '<)))
5393 articles)))
5394
5395 (defun gnus-killed-articles (killed articles)
5396 (let (out)
5397 (while articles
5398 (when (inline (gnus-member-of-range (car articles) killed))
5399 (push (car articles) out))
5400 (setq articles (cdr articles)))
5401 out))
5402
5403 (defun gnus-uncompress-marks (marks)
5404 "Uncompress the mark ranges in MARKS."
5405 (let ((uncompressed '(score bookmark))
5406 out)
5407 (while marks
5408 (if (memq (caar marks) uncompressed)
5409 (push (car marks) out)
5410 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5411 (setq marks (cdr marks)))
5412 out))
5413
5414 (defun gnus-article-mark-to-type (mark)
5415 "Return the type of MARK."
5416 (or (cadr (assq mark gnus-article-special-mark-lists))
5417 'list))
5418
5419 (defun gnus-article-unpropagatable-p (mark)
5420 "Return whether MARK should be propagated to back end."
5421 (memq mark gnus-article-unpropagated-mark-lists))
5422
5423 (defun gnus-adjust-marked-articles (info)
5424 "Set all article lists and remove all marks that are no longer valid."
5425 (let* ((marked-lists (gnus-info-marks info))
5426 (active (gnus-active (gnus-info-group info)))
5427 (min (car active))
5428 (max (cdr active))
5429 (types gnus-article-mark-lists)
5430 marks var articles article mark mark-type
5431 bgn end)
5432
5433 (dolist (marks marked-lists)
5434 (setq mark (car marks)
5435 mark-type (gnus-article-mark-to-type mark)
5436 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5437
5438 ;; We set the variable according to the type of the marks list,
5439 ;; and then adjust the marks to a subset of the active articles.
5440 (cond
5441 ;; Adjust "simple" lists - compressed yet unsorted
5442 ((eq mark-type 'list)
5443 ;; Simultaneously uncompress and clip to active range
5444 ;; See gnus-uncompress-range for a description of possible marks
5445 (let (l lh)
5446 (if (not (cadr marks))
5447 (set var nil)
5448 (setq articles (if (numberp (cddr marks))
5449 (list (cdr marks))
5450 (cdr marks))
5451 lh (cons nil nil)
5452 l lh)
5453
5454 (while (setq article (pop articles))
5455 (cond ((consp article)
5456 (setq bgn (max (car article) min)
5457 end (min (cdr article) max))
5458 (while (<= bgn end)
5459 (setq l (setcdr l (cons bgn nil))
5460 bgn (1+ bgn))))
5461 ((and (<= min article)
5462 (>= max article))
5463 (setq l (setcdr l (cons article nil))))))
5464 (set var (cdr lh)))))
5465 ;; Adjust assocs.
5466 ((eq mark-type 'tuple)
5467 (set var (setq articles (cdr marks)))
5468 (when (not (listp (cdr (symbol-value var))))
5469 (set var (list (symbol-value var))))
5470 (when (not (listp (cdr articles)))
5471 (setq articles (list articles)))
5472 (while articles
5473 (when (or (not (consp (setq article (pop articles))))
5474 (< (car article) min)
5475 (> (car article) max))
5476 (set var (delq article (symbol-value var))))))
5477 ;; Adjust ranges (sloppily).
5478 ((eq mark-type 'range)
5479 (cond
5480 ((eq mark 'seen)
5481 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5482 ;; It should be (seen (NUM1 . NUM2)).
5483 (when (numberp (cddr marks))
5484 (setcdr marks (list (cdr marks))))
5485 (setq articles (cdr marks))
5486 (while (and articles
5487 (or (and (consp (car articles))
5488 (> min (cdar articles)))
5489 (and (numberp (car articles))
5490 (> min (car articles)))))
5491 (pop articles))
5492 (set var articles))))))))
5493
5494 (defun gnus-update-missing-marks (missing)
5495 "Go through the list of MISSING articles and remove them from the mark lists."
5496 (when missing
5497 (let (var m)
5498 ;; Go through all types.
5499 (dolist (elem gnus-article-mark-lists)
5500 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5501 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5502 (when (symbol-value var)
5503 ;; This list has articles. So we delete all missing
5504 ;; articles from it.
5505 (setq m missing)
5506 (while m
5507 (set var (delq (pop m) (symbol-value var))))))))))
5508
5509 (defun gnus-update-marks ()
5510 "Enter the various lists of marked articles into the newsgroup info list."
5511 (let ((types gnus-article-mark-lists)
5512 (info (gnus-get-info gnus-newsgroup-name))
5513 type list newmarked symbol delta-marks)
5514 (when info
5515 ;; Add all marks lists to the list of marks lists.
5516 (while (setq type (pop types))
5517 (setq list (symbol-value
5518 (setq symbol
5519 (intern (format "gnus-newsgroup-%s" (car type))))))
5520
5521 (when list
5522 ;; Get rid of the entries of the articles that have the
5523 ;; default score.
5524 (when (and (eq (cdr type) 'score)
5525 gnus-save-score
5526 list)
5527 (let* ((arts list)
5528 (prev (cons nil list))
5529 (all prev))
5530 (while arts
5531 (if (or (not (consp (car arts)))
5532 (= (cdar arts) gnus-summary-default-score))
5533 (setcdr prev (cdr arts))
5534 (setq prev arts))
5535 (setq arts (cdr arts)))
5536 (setq list (cdr all)))))
5537
5538 (when (eq (cdr type) 'seen)
5539 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5540
5541 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5542 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5543
5544 (when (and (gnus-check-backend-function
5545 'request-set-mark gnus-newsgroup-name)
5546 (not (gnus-article-unpropagatable-p (cdr type))))
5547 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5548 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5549 (add (gnus-remove-from-range
5550 (gnus-copy-sequence list) old)))
5551 (when add
5552 (push (list add 'add (list (cdr type))) delta-marks))
5553 (when del
5554 (push (list del 'del (list (cdr type))) delta-marks))))
5555
5556 (when list
5557 (push (cons (cdr type) list) newmarked)))
5558
5559 (when delta-marks
5560 (unless (gnus-check-group gnus-newsgroup-name)
5561 (error "Can't open server for %s" gnus-newsgroup-name))
5562 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5563
5564 ;; Enter these new marks into the info of the group.
5565 (if (nthcdr 3 info)
5566 (setcar (nthcdr 3 info) newmarked)
5567 ;; Add the marks lists to the end of the info.
5568 (when newmarked
5569 (setcdr (nthcdr 2 info) (list newmarked))))
5570
5571 ;; Cut off the end of the info if there's nothing else there.
5572 (let ((i 5))
5573 (while (and (> i 2)
5574 (not (nth i info)))
5575 (when (nthcdr (decf i) info)
5576 (setcdr (nthcdr i info) nil)))))))
5577
5578 (defun gnus-set-mode-line (where)
5579 "Set the mode line of the article or summary buffers.
5580 If WHERE is `summary', the summary mode line format will be used."
5581 ;; Is this mode line one we keep updated?
5582 (when (and (memq where gnus-updated-mode-lines)
5583 (symbol-value
5584 (intern (format "gnus-%s-mode-line-format-spec" where))))
5585 (let (mode-string)
5586 (save-excursion
5587 ;; We evaluate this in the summary buffer since these
5588 ;; variables are buffer-local to that buffer.
5589 (set-buffer gnus-summary-buffer)
5590 ;; We bind all these variables that are used in the `eval' form
5591 ;; below.
5592 (let* ((mformat (symbol-value
5593 (intern
5594 (format "gnus-%s-mode-line-format-spec" where))))
5595 (gnus-tmp-group-name (gnus-group-decoded-name
5596 gnus-newsgroup-name))
5597 (gnus-tmp-article-number (or gnus-current-article 0))
5598 (gnus-tmp-unread gnus-newsgroup-unreads)
5599 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5600 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5601 (gnus-tmp-unread-and-unselected
5602 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5603 (zerop gnus-tmp-unselected))
5604 "")
5605 ((zerop gnus-tmp-unselected)
5606 (format "{%d more}" gnus-tmp-unread-and-unticked))
5607 (t (format "{%d(+%d) more}"
5608 gnus-tmp-unread-and-unticked
5609 gnus-tmp-unselected))))
5610 (gnus-tmp-subject
5611 (if (and gnus-current-headers
5612 (vectorp gnus-current-headers))
5613 (gnus-mode-string-quote
5614 (mail-header-subject gnus-current-headers))
5615 ""))
5616 bufname-length max-len
5617 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5618 (setq mode-string (eval mformat))
5619 (setq bufname-length (if (string-match "%b" mode-string)
5620 (- (length
5621 (buffer-name
5622 (if (eq where 'summary)
5623 nil
5624 (get-buffer gnus-article-buffer))))
5625 2)
5626 0))
5627 (setq max-len (max 4 (if gnus-mode-non-string-length
5628 (- (window-width)
5629 gnus-mode-non-string-length
5630 bufname-length)
5631 (length mode-string))))
5632 ;; We might have to chop a bit of the string off...
5633 (when (> (length mode-string) max-len)
5634 (setq mode-string
5635 (concat (truncate-string-to-width mode-string (- max-len 3))
5636 "...")))
5637 ;; Pad the mode string a bit.
5638 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5639 ;; Update the mode line.
5640 (setq mode-line-buffer-identification
5641 (gnus-mode-line-buffer-identification (list mode-string)))
5642 (set-buffer-modified-p t))))
5643
5644 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5645 "Go through the HEADERS list and add all Xrefs to a hash table.
5646 The resulting hash table is returned, or nil if no Xrefs were found."
5647 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5648 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5649 (xref-hashtb (gnus-make-hashtable))
5650 start group entry number xrefs header)
5651 (while headers
5652 (setq header (pop headers))
5653 (when (and (setq xrefs (mail-header-xref header))
5654 (not (memq (setq number (mail-header-number header))
5655 unreads)))
5656 (setq start 0)
5657 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5658 (setq start (match-end 0))
5659 (setq group (if prefix
5660 (concat prefix (substring xrefs (match-beginning 1)
5661 (match-end 1)))
5662 (substring xrefs (match-beginning 1) (match-end 1))))
5663 (setq number
5664 (string-to-number (substring xrefs (match-beginning 2)
5665 (match-end 2))))
5666 (if (setq entry (gnus-gethash group xref-hashtb))
5667 (setcdr entry (cons number (cdr entry)))
5668 (gnus-sethash group (cons number nil) xref-hashtb)))))
5669 (and start xref-hashtb)))
5670
5671 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5672 "Look through all the headers and mark the Xrefs as read."
5673 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5674 name entry info xref-hashtb idlist method nth4)
5675 (save-excursion
5676 (set-buffer gnus-group-buffer)
5677 (when (setq xref-hashtb
5678 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5679 (mapatoms
5680 (lambda (group)
5681 (unless (string= from-newsgroup (setq name (symbol-name group)))
5682 (setq idlist (symbol-value group))
5683 ;; Dead groups are not updated.
5684 (and (prog1
5685 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5686 info (nth 2 entry))
5687 (when (stringp (setq nth4 (gnus-info-method info)))
5688 (setq nth4 (gnus-server-to-method nth4))))
5689 ;; Only do the xrefs if the group has the same
5690 ;; select method as the group we have just read.
5691 (or (gnus-methods-equal-p
5692 nth4 (gnus-find-method-for-group from-newsgroup))
5693 virtual
5694 (equal nth4 (setq method (gnus-find-method-for-group
5695 from-newsgroup)))
5696 (and (equal (car nth4) (car method))
5697 (equal (nth 1 nth4) (nth 1 method))))
5698 gnus-use-cross-reference
5699 (or (not (eq gnus-use-cross-reference t))
5700 virtual
5701 ;; Only do cross-references on subscribed
5702 ;; groups, if that is what is wanted.
5703 (<= (gnus-info-level info) gnus-level-subscribed))
5704 (gnus-group-make-articles-read name idlist))))
5705 xref-hashtb)))))
5706
5707 (defun gnus-compute-read-articles (group articles)
5708 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5709 (info (nth 2 entry))
5710 (active (gnus-active group))
5711 ninfo)
5712 (when entry
5713 ;; First peel off all invalid article numbers.
5714 (when active
5715 (let ((ids articles)
5716 id first)
5717 (while (setq id (pop ids))
5718 (when (and first (> id (cdr active)))
5719 ;; We'll end up in this situation in one particular
5720 ;; obscure situation. If you re-scan a group and get
5721 ;; a new article that is cross-posted to a different
5722 ;; group that has not been re-scanned, you might get
5723 ;; crossposted article that has a higher number than
5724 ;; Gnus believes possible. So we re-activate this
5725 ;; group as well. This might mean doing the
5726 ;; crossposting thingy will *increase* the number
5727 ;; of articles in some groups. Tsk, tsk.
5728 (setq active (or (gnus-activate-group group) active)))
5729 (when (or (> id (cdr active))
5730 (< id (car active)))
5731 (setq articles (delq id articles))))))
5732 ;; If the read list is nil, we init it.
5733 (if (and active
5734 (null (gnus-info-read info))
5735 (> (car active) 1))
5736 (setq ninfo (cons 1 (1- (car active))))
5737 (setq ninfo (gnus-info-read info)))
5738 ;; Then we add the read articles to the range.
5739 (gnus-add-to-range
5740 ninfo (setq articles (sort articles '<))))))
5741
5742 (defun gnus-group-make-articles-read (group articles)
5743 "Update the info of GROUP to say that ARTICLES are read."
5744 (let* ((num 0)
5745 (entry (gnus-gethash group gnus-newsrc-hashtb))
5746 (info (nth 2 entry))
5747 (active (gnus-active group))
5748 range)
5749 (when entry
5750 (setq range (gnus-compute-read-articles group articles))
5751 (save-excursion
5752 (set-buffer gnus-group-buffer)
5753 (gnus-undo-register
5754 `(progn
5755 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5756 (gnus-info-set-read ',info ',(gnus-info-read info))
5757 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5758 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5759 (gnus-group-update-group ,group t))))
5760 ;; Add the read articles to the range.
5761 (gnus-info-set-read info range)
5762 (gnus-request-set-mark group (list (list range 'add '(read))))
5763 ;; Then we have to re-compute how many unread
5764 ;; articles there are in this group.
5765 (when active
5766 (cond
5767 ((not range)
5768 (setq num (- (1+ (cdr active)) (car active))))
5769 ((not (listp (cdr range)))
5770 (setq num (- (cdr active) (- (1+ (cdr range))
5771 (car range)))))
5772 (t
5773 (while range
5774 (if (numberp (car range))
5775 (setq num (1+ num))
5776 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5777 (setq range (cdr range)))
5778 (setq num (- (cdr active) num))))
5779 ;; Update the number of unread articles.
5780 (setcar entry num)
5781 ;; Update the group buffer.
5782 (unless (gnus-ephemeral-group-p group)
5783 (gnus-group-update-group group t))))))
5784
5785 (defvar gnus-newsgroup-none-id 0)
5786
5787 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5788 (let ((cur nntp-server-buffer)
5789 (dependencies
5790 (or dependencies
5791 (save-excursion (set-buffer gnus-summary-buffer)
5792 gnus-newsgroup-dependencies)))
5793 headers id end ref
5794 (mail-parse-charset gnus-newsgroup-charset)
5795 (mail-parse-ignored-charsets
5796 (save-excursion (condition-case nil
5797 (set-buffer gnus-summary-buffer)
5798 (error))
5799 gnus-newsgroup-ignored-charsets)))
5800 (save-excursion
5801 (set-buffer nntp-server-buffer)
5802 ;; Translate all TAB characters into SPACE characters.
5803 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5804 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5805 (ietf-drums-unfold-fws)
5806 (gnus-run-hooks 'gnus-parse-headers-hook)
5807 (let ((case-fold-search t)
5808 in-reply-to header p lines chars)
5809 (goto-char (point-min))
5810 ;; Search to the beginning of the next header. Error messages
5811 ;; do not begin with 2 or 3.
5812 (while (re-search-forward "^[23][0-9]+ " nil t)
5813 (setq id nil
5814 ref nil)
5815 ;; This implementation of this function, with nine
5816 ;; search-forwards instead of the one re-search-forward and
5817 ;; a case (which basically was the old function) is actually
5818 ;; about twice as fast, even though it looks messier. You
5819 ;; can't have everything, I guess. Speed and elegance
5820 ;; doesn't always go hand in hand.
5821 (setq
5822 header
5823 (vector
5824 ;; Number.
5825 (prog1
5826 (read cur)
5827 (end-of-line)
5828 (setq p (point))
5829 (narrow-to-region (point)
5830 (or (and (search-forward "\n.\n" nil t)
5831 (- (point) 2))
5832 (point))))
5833 ;; Subject.
5834 (progn
5835 (goto-char p)
5836 (if (search-forward "\nsubject:" nil t)
5837 (funcall gnus-decode-encoded-word-function
5838 (nnheader-header-value))
5839 "(none)"))
5840 ;; From.
5841 (progn
5842 (goto-char p)
5843 (if (search-forward "\nfrom:" nil t)
5844 (funcall gnus-decode-encoded-word-function
5845 (nnheader-header-value))
5846 "(nobody)"))
5847 ;; Date.
5848 (progn
5849 (goto-char p)
5850 (if (search-forward "\ndate:" nil t)
5851 (nnheader-header-value) ""))
5852 ;; Message-ID.
5853 (progn
5854 (goto-char p)
5855 (setq id (if (re-search-forward
5856 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5857 ;; We do it this way to make sure the Message-ID
5858 ;; is (somewhat) syntactically valid.
5859 (buffer-substring (match-beginning 1)
5860 (match-end 1))
5861 ;; If there was no message-id, we just fake one
5862 ;; to make subsequent routines simpler.
5863 (nnheader-generate-fake-message-id))))
5864 ;; References.
5865 (progn
5866 (goto-char p)
5867 (if (search-forward "\nreferences:" nil t)
5868 (progn
5869 (setq end (point))
5870 (prog1
5871 (nnheader-header-value)
5872 (setq ref
5873 (buffer-substring
5874 (progn
5875 (end-of-line)
5876 (search-backward ">" end t)
5877 (1+ (point)))
5878 (progn
5879 (search-backward "<" end t)
5880 (point))))))
5881 ;; Get the references from the in-reply-to header if there
5882 ;; were no references and the in-reply-to header looks
5883 ;; promising.
5884 (if (and (search-forward "\nin-reply-to:" nil t)
5885 (setq in-reply-to (nnheader-header-value))
5886 (string-match "<[^>]+>" in-reply-to))
5887 (let (ref2)
5888 (setq ref (substring in-reply-to (match-beginning 0)
5889 (match-end 0)))
5890 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5891 (setq ref2 (substring in-reply-to (match-beginning 0)
5892 (match-end 0)))
5893 (when (> (length ref2) (length ref))
5894 (setq ref ref2)))
5895 ref)
5896 (setq ref nil))))
5897 ;; Chars.
5898 (progn
5899 (goto-char p)
5900 (if (search-forward "\nchars: " nil t)
5901 (if (numberp (setq chars (ignore-errors (read cur))))
5902 chars -1)
5903 -1))
5904 ;; Lines.
5905 (progn
5906 (goto-char p)
5907 (if (search-forward "\nlines: " nil t)
5908 (if (numberp (setq lines (ignore-errors (read cur))))
5909 lines -1)
5910 -1))
5911 ;; Xref.
5912 (progn
5913 (goto-char p)
5914 (and (search-forward "\nxref:" nil t)
5915 (nnheader-header-value)))
5916 ;; Extra.
5917 (when gnus-extra-headers
5918 (let ((extra gnus-extra-headers)
5919 out)
5920 (while extra
5921 (goto-char p)
5922 (when (search-forward
5923 (concat "\n" (symbol-name (car extra)) ":") nil t)
5924 (push (cons (car extra) (nnheader-header-value))
5925 out))
5926 (pop extra))
5927 out))))
5928 (when (equal id ref)
5929 (setq ref nil))
5930
5931 (when gnus-alter-header-function
5932 (funcall gnus-alter-header-function header)
5933 (setq id (mail-header-id header)
5934 ref (gnus-parent-id (mail-header-references header))))
5935
5936 (when (setq header
5937 (gnus-dependencies-add-header
5938 header dependencies force-new))
5939 (push header headers))
5940 (goto-char (point-max))
5941 (widen))
5942 (nreverse headers)))))
5943
5944 ;; Goes through the xover lines and returns a list of vectors
5945 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5946 force-new dependencies
5947 group also-fetch-heads)
5948 "Parse the news overview data in the server buffer.
5949 Return a list of headers that match SEQUENCE (see
5950 `nntp-retrieve-headers')."
5951 ;; Get the Xref when the users reads the articles since most/some
5952 ;; NNTP servers do not include Xrefs when using XOVER.
5953 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5954 (let ((mail-parse-charset gnus-newsgroup-charset)
5955 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5956 (cur nntp-server-buffer)
5957 (dependencies (or dependencies gnus-newsgroup-dependencies))
5958 (allp (cond
5959 ((eq gnus-read-all-available-headers t)
5960 t)
5961 ((stringp gnus-read-all-available-headers)
5962 (string-match gnus-read-all-available-headers group))
5963 (t
5964 nil)))
5965 number headers header)
5966 (save-excursion
5967 (set-buffer nntp-server-buffer)
5968 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5969 ;; Allow the user to mangle the headers before parsing them.
5970 (gnus-run-hooks 'gnus-parse-headers-hook)
5971 (goto-char (point-min))
5972 (gnus-parse-without-error
5973 (while (and (or sequence allp)
5974 (not (eobp)))
5975 (setq number (read cur))
5976 (when (not allp)
5977 (while (and sequence
5978 (< (car sequence) number))
5979 (setq sequence (cdr sequence))))
5980 (when (and (or allp
5981 (and sequence
5982 (eq number (car sequence))))
5983 (progn
5984 (setq sequence (cdr sequence))
5985 (setq header (inline
5986 (gnus-nov-parse-line
5987 number dependencies force-new)))))
5988 (push header headers))
5989 (forward-line 1)))
5990 ;; A common bug in inn is that if you have posted an article and
5991 ;; then retrieves the active file, it will answer correctly --
5992 ;; the new article is included. However, a NOV entry for the
5993 ;; article may not have been generated yet, so this may fail.
5994 ;; We work around this problem by retrieving the last few
5995 ;; headers using HEAD.
5996 (if (or (not also-fetch-heads)
5997 (not sequence))
5998 ;; We (probably) got all the headers.
5999 (nreverse headers)
6000 (let ((gnus-nov-is-evil t))
6001 (nconc
6002 (nreverse headers)
6003 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6004 (gnus-get-newsgroup-headers))))))))
6005
6006 (defun gnus-article-get-xrefs ()
6007 "Fill in the Xref value in `gnus-current-headers', if necessary.
6008 This is meant to be called in `gnus-article-internal-prepare-hook'."
6009 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6010 gnus-current-headers)))
6011 (or (not gnus-use-cross-reference)
6012 (not headers)
6013 (and (mail-header-xref headers)
6014 (not (string= (mail-header-xref headers) "")))
6015 (let ((case-fold-search t)
6016 xref)
6017 (save-restriction
6018 (nnheader-narrow-to-headers)
6019 (goto-char (point-min))
6020 (when (or (and (not (eobp))
6021 (eq (downcase (char-after)) ?x)
6022 (looking-at "Xref:"))
6023 (search-forward "\nXref:" nil t))
6024 (goto-char (1+ (match-end 0)))
6025 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6026 (mail-header-set-xref headers xref)))))))
6027
6028 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6029 "Find article ID and insert the summary line for that article.
6030 OLD-HEADER can either be a header or a line number to insert
6031 the subject line on."
6032 (let* ((line (and (numberp old-header) old-header))
6033 (old-header (and (vectorp old-header) old-header))
6034 (header (cond ((and old-header use-old-header)
6035 old-header)
6036 ((and (numberp id)
6037 (gnus-number-to-header id))
6038 (gnus-number-to-header id))
6039 (t
6040 (gnus-read-header id))))
6041 (number (and (numberp id) id))
6042 d)
6043 (when header
6044 ;; Rebuild the thread that this article is part of and go to the
6045 ;; article we have fetched.
6046 (when (and (not gnus-show-threads)
6047 old-header)
6048 (when (and number
6049 (setq d (gnus-data-find (mail-header-number old-header))))
6050 (goto-char (gnus-data-pos d))
6051 (gnus-data-remove
6052 number
6053 (- (gnus-point-at-bol)
6054 (prog1
6055 (1+ (gnus-point-at-eol))
6056 (gnus-delete-line))))))
6057 ;; Remove list identifiers from subject.
6058 (when gnus-list-identifiers
6059 (let ((gnus-newsgroup-headers (list header)))
6060 (gnus-summary-remove-list-identifiers)))
6061 (when old-header
6062 (mail-header-set-number header (mail-header-number old-header)))
6063 (setq gnus-newsgroup-sparse
6064 (delq (setq number (mail-header-number header))
6065 gnus-newsgroup-sparse))
6066 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6067 (push number gnus-newsgroup-limit)
6068 (gnus-rebuild-thread (mail-header-id header) line)
6069 (gnus-summary-goto-subject number nil t))
6070 (when (and (numberp number)
6071 (> number 0))
6072 ;; We have to update the boundaries even if we can't fetch the
6073 ;; article if ID is a number -- so that the next `P' or `N'
6074 ;; command will fetch the previous (or next) article even
6075 ;; if the one we tried to fetch this time has been canceled.
6076 (when (> number gnus-newsgroup-end)
6077 (setq gnus-newsgroup-end number))
6078 (when (< number gnus-newsgroup-begin)
6079 (setq gnus-newsgroup-begin number))
6080 (setq gnus-newsgroup-unselected
6081 (delq number gnus-newsgroup-unselected)))
6082 ;; Report back a success?
6083 (and header (mail-header-number header))))
6084
6085 ;;; Process/prefix in the summary buffer
6086
6087 (defun gnus-summary-work-articles (n)
6088 "Return a list of articles to be worked upon.
6089 The prefix argument, the list of process marked articles, and the
6090 current article will be taken into consideration."
6091 (save-excursion
6092 (set-buffer gnus-summary-buffer)
6093 (cond
6094 (n
6095 ;; A numerical prefix has been given.
6096 (setq n (prefix-numeric-value n))
6097 (let ((backward (< n 0))
6098 (n (abs (prefix-numeric-value n)))
6099 articles article)
6100 (save-excursion
6101 (while
6102 (and (> n 0)
6103 (push (setq article (gnus-summary-article-number))
6104 articles)
6105 (if backward
6106 (gnus-summary-find-prev nil article)
6107 (gnus-summary-find-next nil article)))
6108 (decf n)))
6109 (nreverse articles)))
6110 ((and (gnus-region-active-p) (mark))
6111 (message "region active")
6112 ;; Work on the region between point and mark.
6113 (let ((max (max (point) (mark)))
6114 articles article)
6115 (save-excursion
6116 (goto-char (min (min (point) (mark))))
6117 (while
6118 (and
6119 (push (setq article (gnus-summary-article-number)) articles)
6120 (gnus-summary-find-next nil article)
6121 (< (point) max)))
6122 (nreverse articles))))
6123 (gnus-newsgroup-processable
6124 ;; There are process-marked articles present.
6125 ;; Save current state.
6126 (gnus-summary-save-process-mark)
6127 ;; Return the list.
6128 (reverse gnus-newsgroup-processable))
6129 (t
6130 ;; Just return the current article.
6131 (list (gnus-summary-article-number))))))
6132
6133 (defmacro gnus-summary-iterate (arg &rest forms)
6134 "Iterate over the process/prefixed articles and do FORMS.
6135 ARG is the interactive prefix given to the command. FORMS will be
6136 executed with point over the summary line of the articles."
6137 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6138 `(let ((,articles (gnus-summary-work-articles ,arg)))
6139 (while ,articles
6140 (gnus-summary-goto-subject (car ,articles))
6141 ,@forms
6142 (pop ,articles)))))
6143
6144 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6145 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6146
6147 (defun gnus-summary-save-process-mark ()
6148 "Push the current set of process marked articles on the stack."
6149 (interactive)
6150 (push (copy-sequence gnus-newsgroup-processable)
6151 gnus-newsgroup-process-stack))
6152
6153 (defun gnus-summary-kill-process-mark ()
6154 "Push the current set of process marked articles on the stack and unmark."
6155 (interactive)
6156 (gnus-summary-save-process-mark)
6157 (gnus-summary-unmark-all-processable))
6158
6159 (defun gnus-summary-yank-process-mark ()
6160 "Pop the last process mark state off the stack and restore it."
6161 (interactive)
6162 (unless gnus-newsgroup-process-stack
6163 (error "Empty mark stack"))
6164 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6165
6166 (defun gnus-summary-process-mark-set (set)
6167 "Make SET into the current process marked articles."
6168 (gnus-summary-unmark-all-processable)
6169 (while set
6170 (gnus-summary-set-process-mark (pop set))))
6171
6172 ;;; Searching and stuff
6173
6174 (defun gnus-summary-search-group (&optional backward use-level)
6175 "Search for next unread newsgroup.
6176 If optional argument BACKWARD is non-nil, search backward instead."
6177 (save-excursion
6178 (set-buffer gnus-group-buffer)
6179 (when (gnus-group-search-forward
6180 backward nil (if use-level (gnus-group-group-level) nil))
6181 (gnus-group-group-name))))
6182
6183 (defun gnus-summary-best-group (&optional exclude-group)
6184 "Find the name of the best unread group.
6185 If EXCLUDE-GROUP, do not go to this group."
6186 (save-excursion
6187 (set-buffer gnus-group-buffer)
6188 (save-excursion
6189 (gnus-group-best-unread-group exclude-group))))
6190
6191 (defun gnus-summary-find-next (&optional unread article backward)
6192 (if backward
6193 (gnus-summary-find-prev unread article)
6194 (let* ((dummy (gnus-summary-article-intangible-p))
6195 (article (or article (gnus-summary-article-number)))
6196 (data (gnus-data-find-list article))
6197 result)
6198 (when (and (not dummy)
6199 (or (not gnus-summary-check-current)
6200 (not unread)
6201 (not (gnus-data-unread-p (car data)))))
6202 (setq data (cdr data)))
6203 (when (setq result
6204 (if unread
6205 (progn
6206 (while data
6207 (unless (memq (gnus-data-number (car data))
6208 (cond
6209 ((eq gnus-auto-goto-ignores
6210 'always-undownloaded)
6211 gnus-newsgroup-undownloaded)
6212 (gnus-plugged
6213 nil)
6214 ((eq gnus-auto-goto-ignores
6215 'unfetched)
6216 gnus-newsgroup-unfetched)
6217 ((eq gnus-auto-goto-ignores
6218 'undownloaded)
6219 gnus-newsgroup-undownloaded)))
6220 (when (gnus-data-unread-p (car data))
6221 (setq result (car data)
6222 data nil)))
6223 (setq data (cdr data)))
6224 result)
6225 (car data)))
6226 (goto-char (gnus-data-pos result))
6227 (gnus-data-number result)))))
6228
6229 (defun gnus-summary-find-prev (&optional unread article)
6230 (let* ((eobp (eobp))
6231 (article (or article (gnus-summary-article-number)))
6232 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6233 result)
6234 (when (and (not eobp)
6235 (or (not gnus-summary-check-current)
6236 (not unread)
6237 (not (gnus-data-unread-p (car data)))))
6238 (setq data (cdr data)))
6239 (when (setq result
6240 (if unread
6241 (progn
6242 (while data
6243 (unless (memq (gnus-data-number (car data))
6244 (cond
6245 ((eq gnus-auto-goto-ignores
6246 'always-undownloaded)
6247 gnus-newsgroup-undownloaded)
6248 (gnus-plugged
6249 nil)
6250 ((eq gnus-auto-goto-ignores
6251 'unfetched)
6252 gnus-newsgroup-unfetched)
6253 ((eq gnus-auto-goto-ignores
6254 'undownloaded)
6255 gnus-newsgroup-undownloaded)))
6256 (when (gnus-data-unread-p (car data))
6257 (setq result (car data)
6258 data nil)))
6259 (setq data (cdr data)))
6260 result)
6261 (car data)))
6262 (goto-char (gnus-data-pos result))
6263 (gnus-data-number result))))
6264
6265 (defun gnus-summary-find-subject (subject &optional unread backward article)
6266 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6267 (article (or article (gnus-summary-article-number)))
6268 (articles (gnus-data-list backward))
6269 (arts (gnus-data-find-list article articles))
6270 result)
6271 (when (or (not gnus-summary-check-current)
6272 (not unread)
6273 (not (gnus-data-unread-p (car arts))))
6274 (setq arts (cdr arts)))
6275 (while arts
6276 (and (or (not unread)
6277 (gnus-data-unread-p (car arts)))
6278 (vectorp (gnus-data-header (car arts)))
6279 (gnus-subject-equal
6280 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6281 (setq result (car arts)
6282 arts nil))
6283 (setq arts (cdr arts)))
6284 (and result
6285 (goto-char (gnus-data-pos result))
6286 (gnus-data-number result))))
6287
6288 (defun gnus-summary-search-forward (&optional unread subject backward)
6289 "Search forward for an article.
6290 If UNREAD, look for unread articles. If SUBJECT, look for
6291 articles with that subject. If BACKWARD, search backward instead."
6292 (cond (subject (gnus-summary-find-subject subject unread backward))
6293 (backward (gnus-summary-find-prev unread))
6294 (t (gnus-summary-find-next unread))))
6295
6296 (defun gnus-recenter (&optional n)
6297 "Center point in window and redisplay frame.
6298 Also do horizontal recentering."
6299 (interactive "P")
6300 (when (and gnus-auto-center-summary
6301 (not (eq gnus-auto-center-summary 'vertical)))
6302 (gnus-horizontal-recenter))
6303 (recenter n))
6304
6305 (defun gnus-summary-recenter ()
6306 "Center point in the summary window.
6307 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6308 displayed, no centering will be performed."
6309 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6310 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6311 (interactive)
6312 ;; The user has to want it.
6313 (when gnus-auto-center-summary
6314 (let* ((top (cond ((< (window-height) 4) 0)
6315 ((< (window-height) 7) 1)
6316 (t (if (numberp gnus-auto-center-summary)
6317 gnus-auto-center-summary
6318 2))))
6319 (height (1- (window-height)))
6320 (bottom (save-excursion (goto-char (point-max))
6321 (forward-line (- height))
6322 (point)))
6323 (window (get-buffer-window (current-buffer))))
6324 (when (get-buffer-window gnus-article-buffer)
6325 ;; Only do recentering when the article buffer is displayed,
6326 ;; Set the window start to either `bottom', which is the biggest
6327 ;; possible valid number, or the second line from the top,
6328 ;; whichever is the least.
6329 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6330 (if (> bottom top-pos)
6331 ;; Keep the second line from the top visible
6332 (set-window-start window top-pos t)
6333 ;; Try to keep the bottom line visible; if it's partially
6334 ;; obscured, either scroll one more line to make it fully
6335 ;; visible, or revert to using TOP-POS.
6336 (save-excursion
6337 (goto-char (point-max))
6338 (forward-line -1)
6339 (let ((last-line-start (point)))
6340 (goto-char bottom)
6341 (set-window-start window (point) t)
6342 (when (not (pos-visible-in-window-p last-line-start window))
6343 (forward-line 1)
6344 (set-window-start window (min (point) top-pos) t)))))))
6345 ;; Do horizontal recentering while we're at it.
6346 (when (and (get-buffer-window (current-buffer) t)
6347 (not (eq gnus-auto-center-summary 'vertical)))
6348 (let ((selected (selected-window)))
6349 (select-window (get-buffer-window (current-buffer) t))
6350 (gnus-summary-position-point)
6351 (gnus-horizontal-recenter)
6352 (select-window selected))))))
6353
6354 (defun gnus-summary-jump-to-group (newsgroup)
6355 "Move point to NEWSGROUP in group mode buffer."
6356 ;; Keep update point of group mode buffer if visible.
6357 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6358 (save-window-excursion
6359 ;; Take care of tree window mode.
6360 (when (get-buffer-window gnus-group-buffer)
6361 (pop-to-buffer gnus-group-buffer))
6362 (gnus-group-jump-to-group newsgroup))
6363 (save-excursion
6364 ;; Take care of tree window mode.
6365 (if (get-buffer-window gnus-group-buffer)
6366 (pop-to-buffer gnus-group-buffer)
6367 (set-buffer gnus-group-buffer))
6368 (gnus-group-jump-to-group newsgroup))))
6369
6370 ;; This function returns a list of article numbers based on the
6371 ;; difference between the ranges of read articles in this group and
6372 ;; the range of active articles.
6373 (defun gnus-list-of-unread-articles (group)
6374 (let* ((read (gnus-info-read (gnus-get-info group)))
6375 (active (or (gnus-active group) (gnus-activate-group group)))
6376 (last (cdr active))
6377 first nlast unread)
6378 ;; If none are read, then all are unread.
6379 (if (not read)
6380 (setq first (car active))
6381 ;; If the range of read articles is a single range, then the
6382 ;; first unread article is the article after the last read
6383 ;; article. Sounds logical, doesn't it?
6384 (if (and (not (listp (cdr read)))
6385 (or (< (car read) (car active))
6386 (progn (setq read (list read))
6387 nil)))
6388 (setq first (max (car active) (1+ (cdr read))))
6389 ;; `read' is a list of ranges.
6390 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6391 (caar read)))
6392 1)
6393 (setq first (car active)))
6394 (while read
6395 (when first
6396 (while (< first nlast)
6397 (setq unread (cons first unread)
6398 first (1+ first))))
6399 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6400 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6401 (setq read (cdr read)))))
6402 ;; And add the last unread articles.
6403 (while (<= first last)
6404 (setq unread (cons first unread)
6405 first (1+ first)))
6406 ;; Return the list of unread articles.
6407 (delq 0 (nreverse unread))))
6408
6409 (defun gnus-list-of-read-articles (group)
6410 "Return a list of unread, unticked and non-dormant articles."
6411 (let* ((info (gnus-get-info group))
6412 (marked (gnus-info-marks info))
6413 (active (gnus-active group)))
6414 (and info active
6415 (gnus-list-range-difference
6416 (gnus-list-range-difference
6417 (gnus-sorted-complement
6418 (gnus-uncompress-range active)
6419 (gnus-list-of-unread-articles group))
6420 (cdr (assq 'dormant marked)))
6421 (cdr (assq 'tick marked))))))
6422
6423 ;; This function returns a sequence of article numbers based on the
6424 ;; difference between the ranges of read articles in this group and
6425 ;; the range of active articles.
6426 (defun gnus-sequence-of-unread-articles (group)
6427 (let* ((read (gnus-info-read (gnus-get-info group)))
6428 (active (or (gnus-active group) (gnus-activate-group group)))
6429 (last (cdr active))
6430 first nlast unread)
6431 ;; If none are read, then all are unread.
6432 (if (not read)
6433 (setq first (car active))
6434 ;; If the range of read articles is a single range, then the
6435 ;; first unread article is the article after the last read
6436 ;; article. Sounds logical, doesn't it?
6437 (if (and (not (listp (cdr read)))
6438 (or (< (car read) (car active))
6439 (progn (setq read (list read))
6440 nil)))
6441 (setq first (max (car active) (1+ (cdr read))))
6442 ;; `read' is a list of ranges.
6443 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6444 (caar read)))
6445 1)
6446 (setq first (car active)))
6447 (while read
6448 (when first
6449 (push (cons first nlast) unread))
6450 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6451 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6452 (setq read (cdr read)))))
6453 ;; And add the last unread articles.
6454 (cond ((< first last)
6455 (push (cons first last) unread))
6456 ((= first last)
6457 (push first unread)))
6458 ;; Return the sequence of unread articles.
6459 (delq 0 (nreverse unread))))
6460
6461 ;; Various summary commands
6462
6463 (defun gnus-summary-select-article-buffer ()
6464 "Reconfigure windows to show article buffer."
6465 (interactive)
6466 (if (not (gnus-buffer-live-p gnus-article-buffer))
6467 (error "There is no article buffer for this summary buffer")
6468 (gnus-configure-windows 'article)
6469 (select-window (get-buffer-window gnus-article-buffer))))
6470
6471 (defun gnus-summary-universal-argument (arg)
6472 "Perform any operation on all articles that are process/prefixed."
6473 (interactive "P")
6474 (let ((articles (gnus-summary-work-articles arg))
6475 func article)
6476 (if (eq
6477 (setq
6478 func
6479 (key-binding
6480 (read-key-sequence
6481 (substitute-command-keys
6482 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6483 'undefined)
6484 (gnus-error 1 "Undefined key")
6485 (save-excursion
6486 (while articles
6487 (gnus-summary-goto-subject (setq article (pop articles)))
6488 (let (gnus-newsgroup-processable)
6489 (command-execute func))
6490 (gnus-summary-remove-process-mark article)))))
6491 (gnus-summary-position-point))
6492
6493 (defun gnus-summary-toggle-truncation (&optional arg)
6494 "Toggle truncation of summary lines.
6495 With ARG, turn line truncation on if ARG is positive."
6496 (interactive "P")
6497 (setq truncate-lines
6498 (if (null arg) (not truncate-lines)
6499 (> (prefix-numeric-value arg) 0)))
6500 (redraw-display))
6501
6502 (defun gnus-summary-find-for-reselect ()
6503 "Return the number of an article to stay on across a reselect.
6504 The current article is considered, then following articles, then previous
6505 articles. An article is sought which is not cancelled and isn't a temporary
6506 insertion from another group. If there's no such then return a dummy 0."
6507 (let (found)
6508 (dolist (rev '(nil t))
6509 (unless found ; don't demand the reverse list if we don't need it
6510 (let ((data (gnus-data-find-list
6511 (gnus-summary-article-number) (gnus-data-list rev))))
6512 (while (and data (not found))
6513 (if (and (< 0 (gnus-data-number (car data)))
6514 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6515 (setq found (gnus-data-number (car data))))
6516 (setq data (cdr data))))))
6517 (or found 0)))
6518
6519 (defun gnus-summary-reselect-current-group (&optional all rescan)
6520 "Exit and then reselect the current newsgroup.
6521 The prefix argument ALL means to select all articles."
6522 (interactive "P")
6523 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6524 (error "Ephemeral groups can't be reselected"))
6525 (let ((current-subject (gnus-summary-find-for-reselect))
6526 (group gnus-newsgroup-name))
6527 (setq gnus-newsgroup-begin nil)
6528 (gnus-summary-exit nil 'leave-hidden)
6529 ;; We have to adjust the point of group mode buffer because
6530 ;; point was moved to the next unread newsgroup by exiting.
6531 (gnus-summary-jump-to-group group)
6532 (when rescan
6533 (save-excursion
6534 (gnus-group-get-new-news-this-group 1)))
6535 (gnus-group-read-group all t)
6536 (gnus-summary-goto-subject current-subject nil t)))
6537
6538 (defun gnus-summary-rescan-group (&optional all)
6539 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6540 (interactive "P")
6541 (gnus-summary-reselect-current-group all t))
6542
6543 (defun gnus-summary-update-info (&optional non-destructive)
6544 (save-excursion
6545 (let ((group gnus-newsgroup-name))
6546 (when group
6547 (when gnus-newsgroup-kill-headers
6548 (setq gnus-newsgroup-killed
6549 (gnus-compress-sequence
6550 (gnus-sorted-union
6551 (gnus-list-range-intersection
6552 gnus-newsgroup-unselected gnus-newsgroup-killed)
6553 gnus-newsgroup-unreads)
6554 t)))
6555 (unless (listp (cdr gnus-newsgroup-killed))
6556 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6557 (let ((headers gnus-newsgroup-headers))
6558 ;; Set the new ranges of read articles.
6559 (save-excursion
6560 (set-buffer gnus-group-buffer)
6561 (gnus-undo-force-boundary))
6562 (gnus-update-read-articles
6563 group (gnus-sorted-union
6564 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6565 ;; Set the current article marks.
6566 (let ((gnus-newsgroup-scored
6567 (if (and (not gnus-save-score)
6568 (not non-destructive))
6569 nil
6570 gnus-newsgroup-scored)))
6571 (save-excursion
6572 (gnus-update-marks)))
6573 ;; Do the cross-ref thing.
6574 (when gnus-use-cross-reference
6575 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6576 ;; Do not switch windows but change the buffer to work.
6577 (set-buffer gnus-group-buffer)
6578 (unless (gnus-ephemeral-group-p group)
6579 (gnus-group-update-group group)))))))
6580
6581 (defun gnus-summary-save-newsrc (&optional force)
6582 "Save the current number of read/marked articles in the dribble buffer.
6583 The dribble buffer will then be saved.
6584 If FORCE (the prefix), also save the .newsrc file(s)."
6585 (interactive "P")
6586 (gnus-summary-update-info t)
6587 (if force
6588 (gnus-save-newsrc-file)
6589 (gnus-dribble-save)))
6590
6591 (defun gnus-summary-exit (&optional temporary leave-hidden)
6592 "Exit reading current newsgroup, and then return to group selection mode.
6593 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6594 (interactive)
6595 (gnus-set-global-variables)
6596 (when (gnus-buffer-live-p gnus-article-buffer)
6597 (save-excursion
6598 (set-buffer gnus-article-buffer)
6599 (mm-destroy-parts gnus-article-mime-handles)
6600 ;; Set it to nil for safety reason.
6601 (setq gnus-article-mime-handle-alist nil)
6602 (setq gnus-article-mime-handles nil)))
6603 (gnus-kill-save-kill-buffer)
6604 (gnus-async-halt-prefetch)
6605 (let* ((group gnus-newsgroup-name)
6606 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6607 (gnus-group-is-exiting-p t)
6608 (mode major-mode)
6609 (group-point nil)
6610 (buf (current-buffer)))
6611 (unless quit-config
6612 ;; Do adaptive scoring, and possibly save score files.
6613 (when gnus-newsgroup-adaptive
6614 (gnus-score-adaptive))
6615 (when gnus-use-scoring
6616 (gnus-score-save)))
6617 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6618 ;; If we have several article buffers, we kill them at exit.
6619 (unless gnus-single-article-buffer
6620 (gnus-kill-buffer gnus-original-article-buffer)
6621 (setq gnus-article-current nil))
6622 (when gnus-use-cache
6623 (gnus-cache-possibly-remove-articles)
6624 (gnus-cache-save-buffers))
6625 (gnus-async-prefetch-remove-group group)
6626 (when gnus-suppress-duplicates
6627 (gnus-dup-enter-articles))
6628 (when gnus-use-trees
6629 (gnus-tree-close group))
6630 (when gnus-use-cache
6631 (gnus-cache-write-active))
6632 ;; Remove entries for this group.
6633 (nnmail-purge-split-history (gnus-group-real-name group))
6634 ;; Make all changes in this group permanent.
6635 (unless quit-config
6636 (gnus-run-hooks 'gnus-exit-group-hook)
6637 (gnus-summary-update-info))
6638 (gnus-close-group group)
6639 ;; Make sure where we were, and go to next newsgroup.
6640 (set-buffer gnus-group-buffer)
6641 (unless quit-config
6642 (gnus-group-jump-to-group group))
6643 (gnus-run-hooks 'gnus-summary-exit-hook)
6644 (unless (or quit-config
6645 ;; If this group has disappeared from the summary
6646 ;; buffer, don't skip forwards.
6647 (not (string= group (gnus-group-group-name))))
6648 (gnus-group-next-unread-group 1))
6649 (setq group-point (point))
6650 (if temporary
6651 nil ;Nothing to do.
6652 ;; If we have several article buffers, we kill them at exit.
6653 (unless gnus-single-article-buffer
6654 (gnus-kill-buffer gnus-article-buffer)
6655 (gnus-kill-buffer gnus-original-article-buffer)
6656 (setq gnus-article-current nil))
6657 (set-buffer buf)
6658 (if (not gnus-kill-summary-on-exit)
6659 (progn
6660 (gnus-deaden-summary)
6661 (setq mode nil))
6662 ;; We set all buffer-local variables to nil. It is unclear why
6663 ;; this is needed, but if we don't, buffer-local variables are
6664 ;; not garbage-collected, it seems. This would the lead to en
6665 ;; ever-growing Emacs.
6666 (gnus-summary-clear-local-variables)
6667 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6668 (gnus-summary-clear-local-variables))
6669 (when (get-buffer gnus-article-buffer)
6670 (bury-buffer gnus-article-buffer))
6671 ;; We clear the global counterparts of the buffer-local
6672 ;; variables as well, just to be on the safe side.
6673 (set-buffer gnus-group-buffer)
6674 (gnus-summary-clear-local-variables)
6675 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6676 (gnus-summary-clear-local-variables))
6677 ;; Return to group mode buffer.
6678 (when (eq mode 'gnus-summary-mode)
6679 (gnus-kill-buffer buf)))
6680 (setq gnus-current-select-method gnus-select-method)
6681 (set-buffer gnus-group-buffer)
6682 (if quit-config
6683 (gnus-handle-ephemeral-exit quit-config)
6684 (goto-char group-point)
6685 ;; If gnus-group-buffer is already displayed, make sure we also move
6686 ;; the cursor in the window that displays it.
6687 (let ((win (get-buffer-window (current-buffer) 0)))
6688 (if win (set-window-point win (point))))
6689 (unless leave-hidden
6690 (gnus-configure-windows 'group 'force)))
6691 ;; Clear the current group name.
6692 (unless quit-config
6693 (setq gnus-newsgroup-name nil)))))
6694
6695 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6696 (defun gnus-summary-exit-no-update (&optional no-questions)
6697 "Quit reading current newsgroup without updating read article info."
6698 (interactive)
6699 (let* ((group gnus-newsgroup-name)
6700 (gnus-group-is-exiting-p t)
6701 (gnus-group-is-exiting-without-update-p t)
6702 (quit-config (gnus-group-quit-config group)))
6703 (when (or no-questions
6704 gnus-expert-user
6705 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6706 (gnus-async-halt-prefetch)
6707 (run-hooks 'gnus-summary-prepare-exit-hook)
6708 (when (gnus-buffer-live-p gnus-article-buffer)
6709 (save-excursion
6710 (set-buffer gnus-article-buffer)
6711 (mm-destroy-parts gnus-article-mime-handles)
6712 ;; Set it to nil for safety reason.
6713 (setq gnus-article-mime-handle-alist nil)
6714 (setq gnus-article-mime-handles nil)))
6715 ;; If we have several article buffers, we kill them at exit.
6716 (unless gnus-single-article-buffer
6717 (gnus-kill-buffer gnus-article-buffer)
6718 (gnus-kill-buffer gnus-original-article-buffer)
6719 (setq gnus-article-current nil))
6720 (if (not gnus-kill-summary-on-exit)
6721 (gnus-deaden-summary)
6722 (gnus-close-group group)
6723 (gnus-summary-clear-local-variables)
6724 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6725 (gnus-summary-clear-local-variables))
6726 (set-buffer gnus-group-buffer)
6727 (gnus-summary-clear-local-variables)
6728 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6729 (gnus-summary-clear-local-variables))
6730 (gnus-kill-buffer gnus-summary-buffer))
6731 (unless gnus-single-article-buffer
6732 (setq gnus-article-current nil))
6733 (when gnus-use-trees
6734 (gnus-tree-close group))
6735 (gnus-async-prefetch-remove-group group)
6736 (when (get-buffer gnus-article-buffer)
6737 (bury-buffer gnus-article-buffer))
6738 ;; Return to the group buffer.
6739 (gnus-configure-windows 'group 'force)
6740 ;; Clear the current group name.
6741 (setq gnus-newsgroup-name nil)
6742 (unless (gnus-ephemeral-group-p group)
6743 (gnus-group-update-group group))
6744 (when (equal (gnus-group-group-name) group)
6745 (gnus-group-next-unread-group 1))
6746 (when quit-config
6747 (gnus-handle-ephemeral-exit quit-config)))))
6748
6749 (defun gnus-handle-ephemeral-exit (quit-config)
6750 "Handle movement when leaving an ephemeral group.
6751 The state which existed when entering the ephemeral is reset."
6752 (if (not (buffer-name (car quit-config)))
6753 (gnus-configure-windows 'group 'force)
6754 (set-buffer (car quit-config))
6755 (cond ((eq major-mode 'gnus-summary-mode)
6756 (gnus-set-global-variables))
6757 ((eq major-mode 'gnus-article-mode)
6758 (save-excursion
6759 ;; The `gnus-summary-buffer' variable may point
6760 ;; to the old summary buffer when using a single
6761 ;; article buffer.
6762 (unless (gnus-buffer-live-p gnus-summary-buffer)
6763 (set-buffer gnus-group-buffer))
6764 (set-buffer gnus-summary-buffer)
6765 (gnus-set-global-variables))))
6766 (if (or (eq (cdr quit-config) 'article)
6767 (eq (cdr quit-config) 'pick))
6768 (progn
6769 ;; The current article may be from the ephemeral group
6770 ;; thus it is best that we reload this article
6771 ;;
6772 ;; If we're exiting from a large digest, this can be
6773 ;; extremely slow. So, it's better not to reload it. -- jh.
6774 ;;(gnus-summary-show-article)
6775 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6776 (gnus-configure-windows 'pick 'force)
6777 (gnus-configure-windows (cdr quit-config) 'force)))
6778 (gnus-configure-windows (cdr quit-config) 'force))
6779 (when (eq major-mode 'gnus-summary-mode)
6780 (gnus-summary-next-subject 1 nil t)
6781 (gnus-summary-recenter)
6782 (gnus-summary-position-point))))
6783
6784 ;;; Dead summaries.
6785
6786 (defvar gnus-dead-summary-mode-map nil)
6787
6788 (unless gnus-dead-summary-mode-map
6789 (setq gnus-dead-summary-mode-map (make-keymap))
6790 (suppress-keymap gnus-dead-summary-mode-map)
6791 (substitute-key-definition
6792 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6793 (dolist (key '("\C-d" "\r" "\177" [delete]))
6794 (define-key gnus-dead-summary-mode-map
6795 key 'gnus-summary-wake-up-the-dead))
6796 (dolist (key '("q" "Q"))
6797 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6798
6799 (defvar gnus-dead-summary-mode nil
6800 "Minor mode for Gnus summary buffers.")
6801
6802 (defun gnus-dead-summary-mode (&optional arg)
6803 "Minor mode for Gnus summary buffers."
6804 (interactive "P")
6805 (when (eq major-mode 'gnus-summary-mode)
6806 (make-local-variable 'gnus-dead-summary-mode)
6807 (setq gnus-dead-summary-mode
6808 (if (null arg) (not gnus-dead-summary-mode)
6809 (> (prefix-numeric-value arg) 0)))
6810 (when gnus-dead-summary-mode
6811 (gnus-add-minor-mode
6812 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6813
6814 (defun gnus-deaden-summary ()
6815 "Make the current summary buffer into a dead summary buffer."
6816 ;; Kill any previous dead summary buffer.
6817 (when (and gnus-dead-summary
6818 (buffer-name gnus-dead-summary))
6819 (save-excursion
6820 (set-buffer gnus-dead-summary)
6821 (when gnus-dead-summary-mode
6822 (kill-buffer (current-buffer)))))
6823 ;; Make this the current dead summary.
6824 (setq gnus-dead-summary (current-buffer))
6825 (gnus-dead-summary-mode 1)
6826 (let ((name (buffer-name)))
6827 (when (string-match "Summary" name)
6828 (rename-buffer
6829 (concat (substring name 0 (match-beginning 0)) "Dead "
6830 (substring name (match-beginning 0)))
6831 t)
6832 (bury-buffer))))
6833
6834 (defun gnus-kill-or-deaden-summary (buffer)
6835 "Kill or deaden the summary BUFFER."
6836 (save-excursion
6837 (when (and (buffer-name buffer)
6838 (not gnus-single-article-buffer))
6839 (save-excursion
6840 (set-buffer buffer)
6841 (gnus-kill-buffer gnus-article-buffer)
6842 (gnus-kill-buffer gnus-original-article-buffer)))
6843 (cond
6844 ;; Kill the buffer.
6845 (gnus-kill-summary-on-exit
6846 (when (and gnus-use-trees
6847 (gnus-buffer-exists-p buffer))
6848 (save-excursion
6849 (set-buffer buffer)
6850 (gnus-tree-close gnus-newsgroup-name)))
6851 (gnus-kill-buffer buffer))
6852 ;; Deaden the buffer.
6853 ((gnus-buffer-exists-p buffer)
6854 (save-excursion
6855 (set-buffer buffer)
6856 (gnus-deaden-summary))))))
6857
6858 (defun gnus-summary-wake-up-the-dead (&rest args)
6859 "Wake up the dead summary buffer."
6860 (interactive)
6861 (gnus-dead-summary-mode -1)
6862 (let ((name (buffer-name)))
6863 (when (string-match "Dead " name)
6864 (rename-buffer
6865 (concat (substring name 0 (match-beginning 0))
6866 (substring name (match-end 0)))
6867 t)))
6868 (gnus-message 3 "This dead summary is now alive again"))
6869
6870 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6871 (defun gnus-summary-fetch-faq (&optional faq-dir)
6872 "Fetch the FAQ for the current group.
6873 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6874 in."
6875 (interactive
6876 (list
6877 (when current-prefix-arg
6878 (completing-read
6879 "FAQ dir: " (and (listp gnus-group-faq-directory)
6880 (mapcar (lambda (file) (list file))
6881 gnus-group-faq-directory))))))
6882 (let (gnus-faq-buffer)
6883 (when (setq gnus-faq-buffer
6884 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6885 (gnus-configure-windows 'summary-faq))))
6886
6887 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6888 (defun gnus-summary-describe-group (&optional force)
6889 "Describe the current newsgroup."
6890 (interactive "P")
6891 (gnus-group-describe-group force gnus-newsgroup-name))
6892
6893 (defun gnus-summary-describe-briefly ()
6894 "Describe summary mode commands briefly."
6895 (interactive)
6896 (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")))
6897
6898 ;; Walking around group mode buffer from summary mode.
6899
6900 (defun gnus-summary-next-group (&optional no-article target-group backward)
6901 "Exit current newsgroup and then select next unread newsgroup.
6902 If prefix argument NO-ARTICLE is non-nil, no article is selected
6903 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6904 previous group instead."
6905 (interactive "P")
6906 ;; Stop pre-fetching.
6907 (gnus-async-halt-prefetch)
6908 (let ((current-group gnus-newsgroup-name)
6909 (current-buffer (current-buffer))
6910 entered)
6911 ;; First we semi-exit this group to update Xrefs and all variables.
6912 ;; We can't do a real exit, because the window conf must remain
6913 ;; the same in case the user is prompted for info, and we don't
6914 ;; want the window conf to change before that...
6915 (gnus-summary-exit t)
6916 (while (not entered)
6917 ;; Then we find what group we are supposed to enter.
6918 (set-buffer gnus-group-buffer)
6919 (gnus-group-jump-to-group current-group)
6920 (setq target-group
6921 (or target-group
6922 (if (eq gnus-keep-same-level 'best)
6923 (gnus-summary-best-group gnus-newsgroup-name)
6924 (gnus-summary-search-group backward gnus-keep-same-level))))
6925 (if (not target-group)
6926 ;; There are no further groups, so we return to the group
6927 ;; buffer.
6928 (progn
6929 (gnus-message 5 "Returning to the group buffer")
6930 (setq entered t)
6931 (when (gnus-buffer-live-p current-buffer)
6932 (set-buffer current-buffer)
6933 (gnus-summary-exit))
6934 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6935 ;; We try to enter the target group.
6936 (gnus-group-jump-to-group target-group)
6937 (let ((unreads (gnus-group-group-unread)))
6938 (if (and (or (eq t unreads)
6939 (and unreads (not (zerop unreads))))
6940 (gnus-summary-read-group
6941 target-group nil no-article
6942 (and (buffer-name current-buffer) current-buffer)
6943 nil backward))
6944 (setq entered t)
6945 (setq current-group target-group
6946 target-group nil)))))))
6947
6948 (defun gnus-summary-prev-group (&optional no-article)
6949 "Exit current newsgroup and then select previous unread newsgroup.
6950 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6951 (interactive "P")
6952 (gnus-summary-next-group no-article nil t))
6953
6954 ;; Walking around summary lines.
6955
6956 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6957 "Go to the first subject satisfying any non-nil constraint.
6958 If UNREAD is non-nil, the article should be unread.
6959 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6960 If UNSEEN is non-nil, the article should be unseen.
6961 Returns the article selected or nil if there are no matching articles."
6962 (interactive "P")
6963 (cond
6964 ;; Empty summary.
6965 ((null gnus-newsgroup-data)
6966 (gnus-message 3 "No articles in the group")
6967 nil)
6968 ;; Pick the first article.
6969 ((not (or unread undownloaded unseen))
6970 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6971 (gnus-data-number (car gnus-newsgroup-data)))
6972 ;; Find the first unread article.
6973 (t
6974 (let ((data gnus-newsgroup-data))
6975 (while (and data
6976 (let ((num (gnus-data-number (car data))))
6977 (or (memq num gnus-newsgroup-unfetched)
6978 (not (or (and unread
6979 (memq num gnus-newsgroup-unreads))
6980 (and undownloaded
6981 (memq num gnus-newsgroup-undownloaded))
6982 (and unseen
6983 (memq num gnus-newsgroup-unseen)))))))
6984 (setq data (cdr data)))
6985 (prog1
6986 (if data
6987 (progn
6988 (goto-char (gnus-data-pos (car data)))
6989 (gnus-data-number (car data)))
6990 (gnus-message 3 "No more%s articles"
6991 (let* ((r (when unread " unread"))
6992 (d (when undownloaded " undownloaded"))
6993 (s (when unseen " unseen"))
6994 (l (delq nil (list r d s))))
6995 (cond ((= 3 (length l))
6996 (concat r "," d ", or" s))
6997 ((= 2 (length l))
6998 (concat (car l) ", or" (cadr l)))
6999 ((= 1 (length l))
7000 (car l))
7001 (t
7002 ""))))
7003 nil
7004 )
7005 (gnus-summary-position-point))))))
7006
7007 (defun gnus-summary-next-subject (n &optional unread dont-display)
7008 "Go to next N'th summary line.
7009 If N is negative, go to the previous N'th subject line.
7010 If UNREAD is non-nil, only unread articles are selected.
7011 The difference between N and the actual number of steps taken is
7012 returned."
7013 (interactive "p")
7014 (let ((backward (< n 0))
7015 (n (abs n)))
7016 (while (and (> n 0)
7017 (if backward
7018 (gnus-summary-find-prev unread)
7019 (gnus-summary-find-next unread)))
7020 (unless (zerop (setq n (1- n)))
7021 (gnus-summary-show-thread)))
7022 (when (/= 0 n)
7023 (gnus-message 7 "No more%s articles"
7024 (if unread " unread" "")))
7025 (unless dont-display
7026 (gnus-summary-recenter)
7027 (gnus-summary-position-point))
7028 n))
7029
7030 (defun gnus-summary-next-unread-subject (n)
7031 "Go to next N'th unread summary line."
7032 (interactive "p")
7033 (gnus-summary-next-subject n t))
7034
7035 (defun gnus-summary-prev-subject (n &optional unread)
7036 "Go to previous N'th summary line.
7037 If optional argument UNREAD is non-nil, only unread article is selected."
7038 (interactive "p")
7039 (gnus-summary-next-subject (- n) unread))
7040
7041 (defun gnus-summary-prev-unread-subject (n)
7042 "Go to previous N'th unread summary line."
7043 (interactive "p")
7044 (gnus-summary-next-subject (- n) t))
7045
7046 (defun gnus-summary-goto-subjects (articles)
7047 "Insert the subject header for ARTICLES in the current buffer."
7048 (save-excursion
7049 (dolist (article articles)
7050 (gnus-summary-goto-subject article t)))
7051 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7052 (gnus-summary-position-point))
7053
7054 (defun gnus-summary-goto-subject (article &optional force silent)
7055 "Go the subject line of ARTICLE.
7056 If FORCE, also allow jumping to articles not currently shown."
7057 (interactive "nArticle number: ")
7058 (unless (numberp article)
7059 (error "Article %s is not a number" article))
7060 (let ((b (point))
7061 (data (gnus-data-find article)))
7062 ;; We read in the article if we have to.
7063 (and (not data)
7064 force
7065 (gnus-summary-insert-subject
7066 article
7067 (if (or (numberp force) (vectorp force)) force)
7068 t)
7069 (setq data (gnus-data-find article)))
7070 (goto-char b)
7071 (if (not data)
7072 (progn
7073 (unless silent
7074 (gnus-message 3 "Can't find article %d" article))
7075 nil)
7076 (let ((pt (gnus-data-pos data)))
7077 (goto-char pt)
7078 (gnus-summary-set-article-display-arrow pt))
7079 (gnus-summary-position-point)
7080 article)))
7081
7082 ;; Walking around summary lines with displaying articles.
7083
7084 (defun gnus-summary-expand-window (&optional arg)
7085 "Make the summary buffer take up the entire Emacs frame.
7086 Given a prefix, will force an `article' buffer configuration."
7087 (interactive "P")
7088 (if arg
7089 (gnus-configure-windows 'article 'force)
7090 (gnus-configure-windows 'summary 'force)))
7091
7092 (defun gnus-summary-display-article (article &optional all-header)
7093 "Display ARTICLE in article buffer."
7094 (when (gnus-buffer-live-p gnus-article-buffer)
7095 (with-current-buffer gnus-article-buffer
7096 (mm-enable-multibyte)))
7097 (gnus-set-global-variables)
7098 (when (gnus-buffer-live-p gnus-article-buffer)
7099 (with-current-buffer gnus-article-buffer
7100 (setq gnus-article-charset gnus-newsgroup-charset)
7101 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7102 (mm-enable-multibyte)))
7103 (if (null article)
7104 nil
7105 (prog1
7106 (if gnus-summary-display-article-function
7107 (funcall gnus-summary-display-article-function article all-header)
7108 (gnus-article-prepare article all-header))
7109 (gnus-run-hooks 'gnus-select-article-hook)
7110 (when (and gnus-current-article
7111 (not (zerop gnus-current-article)))
7112 (gnus-summary-goto-subject gnus-current-article))
7113 (gnus-summary-recenter)
7114 (when (and gnus-use-trees gnus-show-threads)
7115 (gnus-possibly-generate-tree article)
7116 (gnus-highlight-selected-tree article))
7117 ;; Successfully display article.
7118 (gnus-article-set-window-start
7119 (cdr (assq article gnus-newsgroup-bookmarks))))))
7120
7121 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7122 "Select the current article.
7123 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7124 non-nil, the article will be re-fetched even if it already present in
7125 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7126 be displayed."
7127 ;; Make sure we are in the summary buffer to work around bbdb bug.
7128 (unless (eq major-mode 'gnus-summary-mode)
7129 (set-buffer gnus-summary-buffer))
7130 (let ((article (or article (gnus-summary-article-number)))
7131 (all-headers (not (not all-headers))) ;Must be t or nil.
7132 gnus-summary-display-article-function)
7133 (and (not pseudo)
7134 (gnus-summary-article-pseudo-p article)
7135 (error "This is a pseudo-article"))
7136 (save-excursion
7137 (set-buffer gnus-summary-buffer)
7138 (if (or (and gnus-single-article-buffer
7139 (or (null gnus-current-article)
7140 (null gnus-article-current)
7141 (null (get-buffer gnus-article-buffer))
7142 (not (eq article (cdr gnus-article-current)))
7143 (not (equal (car gnus-article-current)
7144 gnus-newsgroup-name))))
7145 (and (not gnus-single-article-buffer)
7146 (or (null gnus-current-article)
7147 (not (eq gnus-current-article article))))
7148 force)
7149 ;; The requested article is different from the current article.
7150 (progn
7151 (gnus-summary-display-article article all-headers)
7152 (when (gnus-buffer-live-p gnus-article-buffer)
7153 (with-current-buffer gnus-article-buffer
7154 (if (not gnus-article-decoded-p) ;; a local variable
7155 (mm-disable-multibyte))))
7156 (gnus-article-set-window-start
7157 (cdr (assq article gnus-newsgroup-bookmarks)))
7158 article)
7159 'old))))
7160
7161 (defun gnus-summary-force-verify-and-decrypt ()
7162 "Display buttons for signed/encrypted parts and verify/decrypt them."
7163 (interactive)
7164 (let ((mm-verify-option 'known)
7165 (mm-decrypt-option 'known)
7166 (gnus-article-emulate-mime t)
7167 (gnus-buttonized-mime-types (append (list "multipart/signed"
7168 "multipart/encrypted")
7169 gnus-buttonized-mime-types)))
7170 (gnus-summary-select-article nil 'force)))
7171
7172 (defun gnus-summary-set-current-mark (&optional current-mark)
7173 "Obsolete function."
7174 nil)
7175
7176 (defun gnus-summary-next-article (&optional unread subject backward push)
7177 "Select the next article.
7178 If UNREAD, only unread articles are selected.
7179 If SUBJECT, only articles with SUBJECT are selected.
7180 If BACKWARD, the previous article is selected instead of the next."
7181 (interactive "P")
7182 (cond
7183 ;; Is there such an article?
7184 ((and (gnus-summary-search-forward unread subject backward)
7185 (or (gnus-summary-display-article (gnus-summary-article-number))
7186 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7187 (gnus-summary-position-point))
7188 ;; If not, we try the first unread, if that is wanted.
7189 ((and subject
7190 gnus-auto-select-same
7191 (gnus-summary-first-unread-article))
7192 (gnus-summary-position-point)
7193 (gnus-message 6 "Wrapped"))
7194 ;; Try to get next/previous article not displayed in this group.
7195 ((and gnus-auto-extend-newsgroup
7196 (not unread) (not subject))
7197 (gnus-summary-goto-article
7198 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7199 nil (count-lines (point-min) (point))))
7200 ;; Go to next/previous group.
7201 (t
7202 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7203 (gnus-summary-jump-to-group gnus-newsgroup-name))
7204 (let ((cmd last-command-char)
7205 (point
7206 (save-excursion
7207 (set-buffer gnus-group-buffer)
7208 (point)))
7209 (group
7210 (if (eq gnus-keep-same-level 'best)
7211 (gnus-summary-best-group gnus-newsgroup-name)
7212 (gnus-summary-search-group backward gnus-keep-same-level))))
7213 ;; For some reason, the group window gets selected. We change
7214 ;; it back.
7215 (select-window (get-buffer-window (current-buffer)))
7216 ;; Select next unread newsgroup automagically.
7217 (cond
7218 ((or (not gnus-auto-select-next)
7219 (not cmd))
7220 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7221 ((or (eq gnus-auto-select-next 'quietly)
7222 (and (eq gnus-auto-select-next 'slightly-quietly)
7223 push)
7224 (and (eq gnus-auto-select-next 'almost-quietly)
7225 (gnus-summary-last-article-p)))
7226 ;; Select quietly.
7227 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7228 (gnus-summary-exit)
7229 (gnus-message 7 "No more%s articles (%s)..."
7230 (if unread " unread" "")
7231 (if group (concat "selecting " group)
7232 "exiting"))
7233 (gnus-summary-next-group nil group backward)))
7234 (t
7235 (when (gnus-key-press-event-p last-input-event)
7236 (gnus-summary-walk-group-buffer
7237 gnus-newsgroup-name cmd unread backward point))))))))
7238
7239 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7240 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7241 (?\C-p (gnus-group-prev-unread-group 1))))
7242 (cursor-in-echo-area t)
7243 keve key group ended prompt)
7244 (save-excursion
7245 (set-buffer gnus-group-buffer)
7246 (goto-char start)
7247 (setq group
7248 (if (eq gnus-keep-same-level 'best)
7249 (gnus-summary-best-group gnus-newsgroup-name)
7250 (gnus-summary-search-group backward gnus-keep-same-level))))
7251 (while (not ended)
7252 (setq prompt
7253 (format
7254 "No more%s articles%s " (if unread " unread" "")
7255 (if (and group
7256 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7257 (format " (Type %s for %s [%s])"
7258 (single-key-description cmd)
7259 (gnus-group-decoded-name group)
7260 (car (gnus-gethash group gnus-newsrc-hashtb)))
7261 (format " (Type %s to exit %s)"
7262 (single-key-description cmd)
7263 (gnus-group-decoded-name gnus-newsgroup-name)))))
7264 ;; Confirm auto selection.
7265 (setq key (car (setq keve (gnus-read-event-char prompt)))
7266 ended t)
7267 (cond
7268 ((assq key keystrokes)
7269 (let ((obuf (current-buffer)))
7270 (switch-to-buffer gnus-group-buffer)
7271 (when group
7272 (gnus-group-jump-to-group group))
7273 (eval (cadr (assq key keystrokes)))
7274 (setq group (gnus-group-group-name))
7275 (switch-to-buffer obuf))
7276 (setq ended nil))
7277 ((equal key cmd)
7278 (if (or (not group)
7279 (gnus-ephemeral-group-p gnus-newsgroup-name))
7280 (gnus-summary-exit)
7281 (gnus-summary-next-group nil group backward)))
7282 (t
7283 (push (cdr keve) unread-command-events))))))
7284
7285 (defun gnus-summary-next-unread-article ()
7286 "Select unread article after current one."
7287 (interactive)
7288 (gnus-summary-next-article
7289 (or (not (eq gnus-summary-goto-unread 'never))
7290 (gnus-summary-last-article-p (gnus-summary-article-number)))
7291 (and gnus-auto-select-same
7292 (gnus-summary-article-subject))))
7293
7294 (defun gnus-summary-prev-article (&optional unread subject)
7295 "Select the article after the current one.
7296 If UNREAD is non-nil, only unread articles are selected."
7297 (interactive "P")
7298 (gnus-summary-next-article unread subject t))
7299
7300 (defun gnus-summary-prev-unread-article ()
7301 "Select unread article before current one."
7302 (interactive)
7303 (gnus-summary-prev-article
7304 (or (not (eq gnus-summary-goto-unread 'never))
7305 (gnus-summary-first-article-p (gnus-summary-article-number)))
7306 (and gnus-auto-select-same
7307 (gnus-summary-article-subject))))
7308
7309 (defun gnus-summary-next-page (&optional lines circular stop)
7310 "Show next page of the selected article.
7311 If at the end of the current article, select the next article.
7312 LINES says how many lines should be scrolled up.
7313
7314 If CIRCULAR is non-nil, go to the start of the article instead of
7315 selecting the next article when reaching the end of the current
7316 article.
7317
7318 If STOP is non-nil, just stop when reaching the end of the message.
7319
7320 Also see the variable `gnus-article-skip-boring'."
7321 (interactive "P")
7322 (setq gnus-summary-buffer (current-buffer))
7323 (gnus-set-global-variables)
7324 (let ((article (gnus-summary-article-number))
7325 (article-window (get-buffer-window gnus-article-buffer t))
7326 endp)
7327 ;; If the buffer is empty, we have no article.
7328 (unless article
7329 (error "No article to select"))
7330 (gnus-configure-windows 'article)
7331 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7332 (if (and (eq gnus-summary-goto-unread 'never)
7333 (not (gnus-summary-last-article-p article)))
7334 (gnus-summary-next-article)
7335 (gnus-summary-next-unread-article))
7336 (if (or (null gnus-current-article)
7337 (null gnus-article-current)
7338 (/= article (cdr gnus-article-current))
7339 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7340 ;; Selected subject is different from current article's.
7341 (gnus-summary-display-article article)
7342 (when article-window
7343 (gnus-eval-in-buffer-window gnus-article-buffer
7344 (setq endp (or (gnus-article-next-page lines)
7345 (gnus-article-only-boring-p))))
7346 (when endp
7347 (cond (stop
7348 (gnus-message 3 "End of message"))
7349 (circular
7350 (gnus-summary-beginning-of-article))
7351 (lines
7352 (gnus-message 3 "End of message"))
7353 ((null lines)
7354 (if (and (eq gnus-summary-goto-unread 'never)
7355 (not (gnus-summary-last-article-p article)))
7356 (gnus-summary-next-article)
7357 (gnus-summary-next-unread-article))))))))
7358 (gnus-summary-recenter)
7359 (gnus-summary-position-point)))
7360
7361 (defun gnus-summary-prev-page (&optional lines move)
7362 "Show previous page of selected article.
7363 Argument LINES specifies lines to be scrolled down.
7364 If MOVE, move to the previous unread article if point is at
7365 the beginning of the buffer."
7366 (interactive "P")
7367 (let ((article (gnus-summary-article-number))
7368 (article-window (get-buffer-window gnus-article-buffer t))
7369 endp)
7370 (gnus-configure-windows 'article)
7371 (if (or (null gnus-current-article)
7372 (null gnus-article-current)
7373 (/= article (cdr gnus-article-current))
7374 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7375 ;; Selected subject is different from current article's.
7376 (gnus-summary-display-article article)
7377 (gnus-summary-recenter)
7378 (when article-window
7379 (gnus-eval-in-buffer-window gnus-article-buffer
7380 (setq endp (gnus-article-prev-page lines)))
7381 (when (and move endp)
7382 (cond (lines
7383 (gnus-message 3 "Beginning of message"))
7384 ((null lines)
7385 (if (and (eq gnus-summary-goto-unread 'never)
7386 (not (gnus-summary-first-article-p article)))
7387 (gnus-summary-prev-article)
7388 (gnus-summary-prev-unread-article))))))))
7389 (gnus-summary-position-point))
7390
7391 (defun gnus-summary-prev-page-or-article (&optional lines)
7392 "Show previous page of selected article.
7393 Argument LINES specifies lines to be scrolled down.
7394 If at the beginning of the article, go to the next article."
7395 (interactive "P")
7396 (gnus-summary-prev-page lines t))
7397
7398 (defun gnus-summary-scroll-up (lines)
7399 "Scroll up (or down) one line current article.
7400 Argument LINES specifies lines to be scrolled up (or down if negative)."
7401 (interactive "p")
7402 (gnus-configure-windows 'article)
7403 (gnus-summary-show-thread)
7404 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7405 (gnus-eval-in-buffer-window gnus-article-buffer
7406 (cond ((> lines 0)
7407 (when (gnus-article-next-page lines)
7408 (gnus-message 3 "End of message")))
7409 ((< lines 0)
7410 (gnus-article-prev-page (- lines))))))
7411 (gnus-summary-recenter)
7412 (gnus-summary-position-point))
7413
7414 (defun gnus-summary-scroll-down (lines)
7415 "Scroll down (or up) one line current article.
7416 Argument LINES specifies lines to be scrolled down (or up if negative)."
7417 (interactive "p")
7418 (gnus-summary-scroll-up (- lines)))
7419
7420 (defun gnus-summary-next-same-subject ()
7421 "Select next article which has the same subject as current one."
7422 (interactive)
7423 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7424
7425 (defun gnus-summary-prev-same-subject ()
7426 "Select previous article which has the same subject as current one."
7427 (interactive)
7428 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7429
7430 (defun gnus-summary-next-unread-same-subject ()
7431 "Select next unread article which has the same subject as current one."
7432 (interactive)
7433 (gnus-summary-next-article t (gnus-summary-article-subject)))
7434
7435 (defun gnus-summary-prev-unread-same-subject ()
7436 "Select previous unread article which has the same subject as current one."
7437 (interactive)
7438 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7439
7440 (defun gnus-summary-first-unread-article ()
7441 "Select the first unread article.
7442 Return nil if there are no unread articles."
7443 (interactive)
7444 (prog1
7445 (when (gnus-summary-first-subject t)
7446 (gnus-summary-show-thread)
7447 (gnus-summary-first-subject t)
7448 (gnus-summary-display-article (gnus-summary-article-number)))
7449 (gnus-summary-position-point)))
7450
7451 (defun gnus-summary-first-unread-subject ()
7452 "Place the point on the subject line of the first unread article.
7453 Return nil if there are no unread articles."
7454 (interactive)
7455 (prog1
7456 (when (gnus-summary-first-subject t)
7457 (gnus-summary-show-thread)
7458 (gnus-summary-first-subject t))
7459 (gnus-summary-position-point)))
7460
7461 (defun gnus-summary-first-unseen-subject ()
7462 "Place the point on the subject line of the first unseen article.
7463 Return nil if there are no unseen articles."
7464 (interactive)
7465 (prog1
7466 (when (gnus-summary-first-subject nil nil t)
7467 (gnus-summary-show-thread)
7468 (gnus-summary-first-subject nil nil t))
7469 (gnus-summary-position-point)))
7470
7471 (defun gnus-summary-first-unseen-or-unread-subject ()
7472 "Place the point on the subject line of the first unseen article or,
7473 if all article have been seen, on the subject line of the first unread
7474 article."
7475 (interactive)
7476 (prog1
7477 (unless (when (gnus-summary-first-subject nil nil t)
7478 (gnus-summary-show-thread)
7479 (gnus-summary-first-subject nil nil t))
7480 (when (gnus-summary-first-subject t)
7481 (gnus-summary-show-thread)
7482 (gnus-summary-first-subject t)))
7483 (gnus-summary-position-point)))
7484
7485 (defun gnus-summary-first-article ()
7486 "Select the first article.
7487 Return nil if there are no articles."
7488 (interactive)
7489 (prog1
7490 (when (gnus-summary-first-subject)
7491 (gnus-summary-show-thread)
7492 (gnus-summary-first-subject)
7493 (gnus-summary-display-article (gnus-summary-article-number)))
7494 (gnus-summary-position-point)))
7495
7496 (defun gnus-summary-best-unread-article (&optional arg)
7497 "Select the unread article with the highest score.
7498 If given a prefix argument, select the next unread article that has a
7499 score higher than the default score."
7500 (interactive "P")
7501 (let ((article (if arg
7502 (gnus-summary-better-unread-subject)
7503 (gnus-summary-best-unread-subject))))
7504 (if article
7505 (gnus-summary-goto-article article)
7506 (error "No unread articles"))))
7507
7508 (defun gnus-summary-best-unread-subject ()
7509 "Select the unread subject with the highest score."
7510 (interactive)
7511 (let ((best -1000000)
7512 (data gnus-newsgroup-data)
7513 article score)
7514 (while data
7515 (and (gnus-data-unread-p (car data))
7516 (> (setq score
7517 (gnus-summary-article-score (gnus-data-number (car data))))
7518 best)
7519 (setq best score
7520 article (gnus-data-number (car data))))
7521 (setq data (cdr data)))
7522 (when article
7523 (gnus-summary-goto-subject article))
7524 (gnus-summary-position-point)
7525 article))
7526
7527 (defun gnus-summary-better-unread-subject ()
7528 "Select the first unread subject that has a score over the default score."
7529 (interactive)
7530 (let ((data gnus-newsgroup-data)
7531 article score)
7532 (while (and (setq article (gnus-data-number (car data)))
7533 (or (gnus-data-read-p (car data))
7534 (not (> (gnus-summary-article-score article)
7535 gnus-summary-default-score))))
7536 (setq data (cdr data)))
7537 (when article
7538 (gnus-summary-goto-subject article))
7539 (gnus-summary-position-point)
7540 article))
7541
7542 (defun gnus-summary-last-subject ()
7543 "Go to the last displayed subject line in the group."
7544 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7545 (when article
7546 (gnus-summary-goto-subject article))))
7547
7548 (defun gnus-summary-goto-article (article &optional all-headers force)
7549 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7550 If ALL-HEADERS is non-nil, no header lines are hidden.
7551 If FORCE, go to the article even if it isn't displayed. If FORCE
7552 is a number, it is the line the article is to be displayed on."
7553 (interactive
7554 (list
7555 (completing-read
7556 "Article number or Message-ID: "
7557 (mapcar (lambda (number) (list (int-to-string number)))
7558 gnus-newsgroup-limit))
7559 current-prefix-arg
7560 t))
7561 (prog1
7562 (if (and (stringp article)
7563 (string-match "@\\|%40" article))
7564 (gnus-summary-refer-article article)
7565 (when (stringp article)
7566 (setq article (string-to-number article)))
7567 (if (gnus-summary-goto-subject article force)
7568 (gnus-summary-display-article article all-headers)
7569 (gnus-message 4 "Couldn't go to article %s" article) nil))
7570 (gnus-summary-position-point)))
7571
7572 (defun gnus-summary-goto-last-article ()
7573 "Go to the previously read article."
7574 (interactive)
7575 (prog1
7576 (when gnus-last-article
7577 (gnus-summary-goto-article gnus-last-article nil t))
7578 (gnus-summary-position-point)))
7579
7580 (defun gnus-summary-pop-article (number)
7581 "Pop one article off the history and go to the previous.
7582 NUMBER articles will be popped off."
7583 (interactive "p")
7584 (let (to)
7585 (setq gnus-newsgroup-history
7586 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7587 (if to
7588 (gnus-summary-goto-article (car to) nil t)
7589 (error "Article history empty")))
7590 (gnus-summary-position-point))
7591
7592 ;; Summary commands and functions for limiting the summary buffer.
7593
7594 (defun gnus-summary-limit-to-articles (n)
7595 "Limit the summary buffer to the next N articles.
7596 If not given a prefix, use the process marked articles instead."
7597 (interactive "P")
7598 (prog1
7599 (let ((articles (gnus-summary-work-articles n)))
7600 (setq gnus-newsgroup-processable nil)
7601 (gnus-summary-limit articles))
7602 (gnus-summary-position-point)))
7603
7604 (defun gnus-summary-pop-limit (&optional total)
7605 "Restore the previous limit.
7606 If given a prefix, remove all limits."
7607 (interactive "P")
7608 (when total
7609 (setq gnus-newsgroup-limits
7610 (list (mapcar (lambda (h) (mail-header-number h))
7611 gnus-newsgroup-headers))))
7612 (unless gnus-newsgroup-limits
7613 (error "No limit to pop"))
7614 (prog1
7615 (gnus-summary-limit nil 'pop)
7616 (gnus-summary-position-point)))
7617
7618 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7619 "Limit the summary buffer to articles that have subjects that match a regexp.
7620 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7621 (interactive
7622 (list (read-string (if current-prefix-arg
7623 "Exclude subject (regexp): "
7624 "Limit to subject (regexp): "))
7625 nil current-prefix-arg))
7626 (unless header
7627 (setq header "subject"))
7628 (when (not (equal "" subject))
7629 (prog1
7630 (let ((articles (gnus-summary-find-matching
7631 (or header "subject") subject 'all nil nil
7632 not-matching)))
7633 (unless articles
7634 (error "Found no matches for \"%s\"" subject))
7635 (gnus-summary-limit articles))
7636 (gnus-summary-position-point))))
7637
7638 (defun gnus-summary-limit-to-author (from &optional not-matching)
7639 "Limit the summary buffer to articles that have authors that match a regexp.
7640 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7641 (interactive
7642 (list (read-string (if current-prefix-arg
7643 "Exclude author (regexp): "
7644 "Limit to author (regexp): "))
7645 current-prefix-arg))
7646 (gnus-summary-limit-to-subject from "from" not-matching))
7647
7648 (defun gnus-summary-limit-to-age (age &optional younger-p)
7649 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7650 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7651 articles that are younger than AGE days."
7652 (interactive
7653 (let ((younger current-prefix-arg)
7654 (days-got nil)
7655 days)
7656 (while (not days-got)
7657 (setq days (if younger
7658 (read-string "Limit to articles younger than (in days, older when negative): ")
7659 (read-string
7660 "Limit to articles older than (in days, younger when negative): ")))
7661 (when (> (length days) 0)
7662 (setq days (read days)))
7663 (if (numberp days)
7664 (progn
7665 (setq days-got t)
7666 (if (< days 0)
7667 (progn
7668 (setq younger (not younger))
7669 (setq days (* days -1)))))
7670 (message "Please enter a number.")
7671 (sleep-for 1)))
7672 (list days younger)))
7673 (prog1
7674 (let ((data gnus-newsgroup-data)
7675 (cutoff (days-to-time age))
7676 articles d date is-younger)
7677 (while (setq d (pop data))
7678 (when (and (vectorp (gnus-data-header d))
7679 (setq date (mail-header-date (gnus-data-header d))))
7680 (setq is-younger (time-less-p
7681 (time-since (condition-case ()
7682 (date-to-time date)
7683 (error '(0 0))))
7684 cutoff))
7685 (when (if younger-p
7686 is-younger
7687 (not is-younger))
7688 (push (gnus-data-number d) articles))))
7689 (gnus-summary-limit (nreverse articles)))
7690 (gnus-summary-position-point)))
7691
7692 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7693 "Limit the summary buffer to articles that match an 'extra' header."
7694 (interactive
7695 (let ((header
7696 (intern
7697 (gnus-completing-read-with-default
7698 (symbol-name (car gnus-extra-headers))
7699 (if current-prefix-arg
7700 "Exclude extra header:"
7701 "Limit extra header:")
7702 (mapcar (lambda (x)
7703 (cons (symbol-name x) x))
7704 gnus-extra-headers)
7705 nil
7706 t))))
7707 (list header
7708 (read-string (format "%s header %s (regexp): "
7709 (if current-prefix-arg "Exclude" "Limit to")
7710 header))
7711 current-prefix-arg)))
7712 (when (not (equal "" regexp))
7713 (prog1
7714 (let ((articles (gnus-summary-find-matching
7715 (cons 'extra header) regexp 'all nil nil
7716 not-matching)))
7717 (unless articles
7718 (error "Found no matches for \"%s\"" regexp))
7719 (gnus-summary-limit articles))
7720 (gnus-summary-position-point))))
7721
7722 (defun gnus-summary-limit-to-display-predicate ()
7723 "Limit the summary buffer to the predicated in the `display' group parameter."
7724 (interactive)
7725 (unless gnus-newsgroup-display
7726 (error "There is no `display' group parameter"))
7727 (let (articles)
7728 (dolist (number gnus-newsgroup-articles)
7729 (when (funcall gnus-newsgroup-display)
7730 (push number articles)))
7731 (gnus-summary-limit articles))
7732 (gnus-summary-position-point))
7733
7734 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7735 (make-obsolete
7736 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7737
7738 (defun gnus-summary-limit-to-unread (&optional all)
7739 "Limit the summary buffer to articles that are not marked as read.
7740 If ALL is non-nil, limit strictly to unread articles."
7741 (interactive "P")
7742 (if all
7743 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7744 (gnus-summary-limit-to-marks
7745 ;; Concat all the marks that say that an article is read and have
7746 ;; those removed.
7747 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7748 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7749 gnus-low-score-mark gnus-expirable-mark
7750 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7751 gnus-duplicate-mark gnus-souped-mark)
7752 'reverse)))
7753
7754 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7755 (make-obsolete 'gnus-summary-delete-marked-with
7756 'gnus-summary-limit-exclude-marks)
7757
7758 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7759 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7760 If REVERSE, limit the summary buffer to articles that are marked
7761 with MARKS. MARKS can either be a string of marks or a list of marks.
7762 Returns how many articles were removed."
7763 (interactive "sMarks: ")
7764 (gnus-summary-limit-to-marks marks t))
7765
7766 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7767 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7768 If REVERSE (the prefix), limit the summary buffer to articles that are
7769 not marked with MARKS. MARKS can either be a string of marks or a
7770 list of marks.
7771 Returns how many articles were removed."
7772 (interactive "sMarks: \nP")
7773 (prog1
7774 (let ((data gnus-newsgroup-data)
7775 (marks (if (listp marks) marks
7776 (append marks nil))) ; Transform to list.
7777 articles)
7778 (while data
7779 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7780 (memq (gnus-data-mark (car data)) marks))
7781 (push (gnus-data-number (car data)) articles))
7782 (setq data (cdr data)))
7783 (gnus-summary-limit articles))
7784 (gnus-summary-position-point)))
7785
7786 (defun gnus-summary-limit-to-score (score)
7787 "Limit to articles with score at or above SCORE."
7788 (interactive "NLimit to articles with score of at least: ")
7789 (let ((data gnus-newsgroup-data)
7790 articles)
7791 (while data
7792 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7793 score)
7794 (push (gnus-data-number (car data)) articles))
7795 (setq data (cdr data)))
7796 (prog1
7797 (gnus-summary-limit articles)
7798 (gnus-summary-position-point))))
7799
7800 (defun gnus-summary-limit-to-unseen ()
7801 "Limit to unseen articles."
7802 (interactive)
7803 (prog1
7804 (gnus-summary-limit gnus-newsgroup-unseen)
7805 (gnus-summary-position-point)))
7806
7807 (defun gnus-summary-limit-include-thread (id)
7808 "Display all the hidden articles that is in the thread with ID in it.
7809 When called interactively, ID is the Message-ID of the current
7810 article."
7811 (interactive (list (mail-header-id (gnus-summary-article-header))))
7812 (let ((articles (gnus-articles-in-thread
7813 (gnus-id-to-thread (gnus-root-id id)))))
7814 (prog1
7815 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7816 (gnus-summary-limit-include-matching-articles
7817 "subject"
7818 (regexp-quote (gnus-simplify-subject-re
7819 (mail-header-subject (gnus-id-to-header id)))))
7820 (gnus-summary-position-point))))
7821
7822 (defun gnus-summary-limit-include-matching-articles (header regexp)
7823 "Display all the hidden articles that have HEADERs that match REGEXP."
7824 (interactive (list (read-string "Match on header: ")
7825 (read-string "Regexp: ")))
7826 (let ((articles (gnus-find-matching-articles header regexp)))
7827 (prog1
7828 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7829 (gnus-summary-position-point))))
7830
7831 (defun gnus-summary-insert-dormant-articles ()
7832 "Insert all the dormant articles for this group into the current buffer."
7833 (interactive)
7834 (let ((gnus-verbose (max 6 gnus-verbose)))
7835 (if (not gnus-newsgroup-dormant)
7836 (gnus-message 3 "No cached articles for this group")
7837 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7838
7839 (defun gnus-summary-limit-include-dormant ()
7840 "Display all the hidden articles that are marked as dormant.
7841 Note that this command only works on a subset of the articles currently
7842 fetched for this group."
7843 (interactive)
7844 (unless gnus-newsgroup-dormant
7845 (error "There are no dormant articles in this group"))
7846 (prog1
7847 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7848 (gnus-summary-position-point)))
7849
7850 (defun gnus-summary-limit-exclude-dormant ()
7851 "Hide all dormant articles."
7852 (interactive)
7853 (prog1
7854 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7855 (gnus-summary-position-point)))
7856
7857 (defun gnus-summary-limit-exclude-childless-dormant ()
7858 "Hide all dormant articles that have no children."
7859 (interactive)
7860 (let ((data (gnus-data-list t))
7861 articles d children)
7862 ;; Find all articles that are either not dormant or have
7863 ;; children.
7864 (while (setq d (pop data))
7865 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7866 (and (setq children
7867 (gnus-article-children (gnus-data-number d)))
7868 (let (found)
7869 (while children
7870 (when (memq (car children) articles)
7871 (setq children nil
7872 found t))
7873 (pop children))
7874 found)))
7875 (push (gnus-data-number d) articles)))
7876 ;; Do the limiting.
7877 (prog1
7878 (gnus-summary-limit articles)
7879 (gnus-summary-position-point))))
7880
7881 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7882 "Mark all unread excluded articles as read.
7883 If ALL, mark even excluded ticked and dormants as read."
7884 (interactive "P")
7885 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7886 (let ((articles (gnus-sorted-ndifference
7887 (sort
7888 (mapcar (lambda (h) (mail-header-number h))
7889 gnus-newsgroup-headers)
7890 '<)
7891 gnus-newsgroup-limit))
7892 article)
7893 (setq gnus-newsgroup-unreads
7894 (gnus-sorted-intersection gnus-newsgroup-unreads
7895 gnus-newsgroup-limit))
7896 (if all
7897 (setq gnus-newsgroup-dormant nil
7898 gnus-newsgroup-marked nil
7899 gnus-newsgroup-reads
7900 (nconc
7901 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7902 gnus-newsgroup-reads))
7903 (while (setq article (pop articles))
7904 (unless (or (memq article gnus-newsgroup-dormant)
7905 (memq article gnus-newsgroup-marked))
7906 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7907
7908 (defun gnus-summary-limit (articles &optional pop)
7909 (if pop
7910 ;; We pop the previous limit off the stack and use that.
7911 (setq articles (car gnus-newsgroup-limits)
7912 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7913 ;; We use the new limit, so we push the old limit on the stack.
7914 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7915 ;; Set the limit.
7916 (setq gnus-newsgroup-limit articles)
7917 (let ((total (length gnus-newsgroup-data))
7918 (data (gnus-data-find-list (gnus-summary-article-number)))
7919 (gnus-summary-mark-below nil) ; Inhibit this.
7920 found)
7921 ;; This will do all the work of generating the new summary buffer
7922 ;; according to the new limit.
7923 (gnus-summary-prepare)
7924 ;; Hide any threads, possibly.
7925 (gnus-summary-maybe-hide-threads)
7926 ;; Try to return to the article you were at, or one in the
7927 ;; neighborhood.
7928 (when data
7929 ;; We try to find some article after the current one.
7930 (while data
7931 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7932 (setq data nil
7933 found t))
7934 (setq data (cdr data))))
7935 (unless found
7936 ;; If there is no data, that means that we were after the last
7937 ;; article. The same goes when we can't find any articles
7938 ;; after the current one.
7939 (goto-char (point-max))
7940 (gnus-summary-find-prev))
7941 (gnus-set-mode-line 'summary)
7942 ;; We return how many articles were removed from the summary
7943 ;; buffer as a result of the new limit.
7944 (- total (length gnus-newsgroup-data))))
7945
7946 (defsubst gnus-invisible-cut-children (threads)
7947 (let ((num 0))
7948 (while threads
7949 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7950 (incf num))
7951 (pop threads))
7952 (< num 2)))
7953
7954 (defsubst gnus-cut-thread (thread)
7955 "Go forwards in the thread until we find an article that we want to display."
7956 (when (or (eq gnus-fetch-old-headers 'some)
7957 (eq gnus-fetch-old-headers 'invisible)
7958 (numberp gnus-fetch-old-headers)
7959 (eq gnus-build-sparse-threads 'some)
7960 (eq gnus-build-sparse-threads 'more))
7961 ;; Deal with old-fetched headers and sparse threads.
7962 (while (and
7963 thread
7964 (or
7965 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7966 (gnus-summary-article-ancient-p
7967 (mail-header-number (car thread))))
7968 (if (or (<= (length (cdr thread)) 1)
7969 (eq gnus-fetch-old-headers 'invisible))
7970 (setq gnus-newsgroup-limit
7971 (delq (mail-header-number (car thread))
7972 gnus-newsgroup-limit)
7973 thread (cadr thread))
7974 (when (gnus-invisible-cut-children (cdr thread))
7975 (let ((th (cdr thread)))
7976 (while th
7977 (if (memq (mail-header-number (caar th))
7978 gnus-newsgroup-limit)
7979 (setq thread (car th)
7980 th nil)
7981 (setq th (cdr th))))))))))
7982 thread)
7983
7984 (defun gnus-cut-threads (threads)
7985 "Cut off all uninteresting articles from the beginning of THREADS."
7986 (when (or (eq gnus-fetch-old-headers 'some)
7987 (eq gnus-fetch-old-headers 'invisible)
7988 (numberp gnus-fetch-old-headers)
7989 (eq gnus-build-sparse-threads 'some)
7990 (eq gnus-build-sparse-threads 'more))
7991 (let ((th threads))
7992 (while th
7993 (setcar th (gnus-cut-thread (car th)))
7994 (setq th (cdr th)))))
7995 ;; Remove nixed out threads.
7996 (delq nil threads))
7997
7998 (defun gnus-summary-initial-limit (&optional show-if-empty)
7999 "Figure out what the initial limit is supposed to be on group entry.
8000 This entails weeding out unwanted dormants, low-scored articles,
8001 fetch-old-headers verbiage, and so on."
8002 ;; Most groups have nothing to remove.
8003 (if (or gnus-inhibit-limiting
8004 (and (null gnus-newsgroup-dormant)
8005 (eq gnus-newsgroup-display 'gnus-not-ignore)
8006 (not (eq gnus-fetch-old-headers 'some))
8007 (not (numberp gnus-fetch-old-headers))
8008 (not (eq gnus-fetch-old-headers 'invisible))
8009 (null gnus-summary-expunge-below)
8010 (not (eq gnus-build-sparse-threads 'some))
8011 (not (eq gnus-build-sparse-threads 'more))
8012 (null gnus-thread-expunge-below)
8013 (not gnus-use-nocem)))
8014 () ; Do nothing.
8015 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8016 (setq gnus-newsgroup-limit nil)
8017 (mapatoms
8018 (lambda (node)
8019 (unless (car (symbol-value node))
8020 ;; These threads have no parents -- they are roots.
8021 (let ((nodes (cdr (symbol-value node)))
8022 thread)
8023 (while nodes
8024 (if (and gnus-thread-expunge-below
8025 (< (gnus-thread-total-score (car nodes))
8026 gnus-thread-expunge-below))
8027 (gnus-expunge-thread (pop nodes))
8028 (setq thread (pop nodes))
8029 (gnus-summary-limit-children thread))))))
8030 gnus-newsgroup-dependencies)
8031 ;; If this limitation resulted in an empty group, we might
8032 ;; pop the previous limit and use it instead.
8033 (when (and (not gnus-newsgroup-limit)
8034 show-if-empty)
8035 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8036 gnus-newsgroup-limit))
8037
8038 (defun gnus-summary-limit-children (thread)
8039 "Return 1 if this subthread is visible and 0 if it is not."
8040 ;; First we get the number of visible children to this thread. This
8041 ;; is done by recursing down the thread using this function, so this
8042 ;; will really go down to a leaf article first, before slowly
8043 ;; working its way up towards the root.
8044 (when thread
8045 (let* ((max-lisp-eval-depth 5000)
8046 (children
8047 (if (cdr thread)
8048 (apply '+ (mapcar 'gnus-summary-limit-children
8049 (cdr thread)))
8050 0))
8051 (number (mail-header-number (car thread)))
8052 score)
8053 (if (and
8054 (not (memq number gnus-newsgroup-marked))
8055 (or
8056 ;; If this article is dormant and has absolutely no visible
8057 ;; children, then this article isn't visible.
8058 (and (memq number gnus-newsgroup-dormant)
8059 (zerop children))
8060 ;; If this is "fetch-old-headered" and there is no
8061 ;; visible children, then we don't want this article.
8062 (and (or (eq gnus-fetch-old-headers 'some)
8063 (numberp gnus-fetch-old-headers))
8064 (gnus-summary-article-ancient-p number)
8065 (zerop children))
8066 ;; If this is "fetch-old-headered" and `invisible', then
8067 ;; we don't want this article.
8068 (and (eq gnus-fetch-old-headers 'invisible)
8069 (gnus-summary-article-ancient-p number))
8070 ;; If this is a sparsely inserted article with no children,
8071 ;; we don't want it.
8072 (and (eq gnus-build-sparse-threads 'some)
8073 (gnus-summary-article-sparse-p number)
8074 (zerop children))
8075 ;; If we use expunging, and this article is really
8076 ;; low-scored, then we don't want this article.
8077 (when (and gnus-summary-expunge-below
8078 (< (setq score
8079 (or (cdr (assq number gnus-newsgroup-scored))
8080 gnus-summary-default-score))
8081 gnus-summary-expunge-below))
8082 ;; We increase the expunge-tally here, but that has
8083 ;; nothing to do with the limits, really.
8084 (incf gnus-newsgroup-expunged-tally)
8085 ;; We also mark as read here, if that's wanted.
8086 (when (and gnus-summary-mark-below
8087 (< score gnus-summary-mark-below))
8088 (setq gnus-newsgroup-unreads
8089 (delq number gnus-newsgroup-unreads))
8090 (if gnus-newsgroup-auto-expire
8091 (push number gnus-newsgroup-expirable)
8092 (push (cons number gnus-low-score-mark)
8093 gnus-newsgroup-reads)))
8094 t)
8095 ;; Do the `display' group parameter.
8096 (and gnus-newsgroup-display
8097 (not (funcall gnus-newsgroup-display)))
8098 ;; Check NoCeM things.
8099 (if (and gnus-use-nocem
8100 (gnus-nocem-unwanted-article-p
8101 (mail-header-id (car thread))))
8102 (progn
8103 (setq gnus-newsgroup-unreads
8104 (delq number gnus-newsgroup-unreads))
8105 t))))
8106 ;; Nope, invisible article.
8107 0
8108 ;; Ok, this article is to be visible, so we add it to the limit
8109 ;; and return 1.
8110 (push number gnus-newsgroup-limit)
8111 1))))
8112
8113 (defun gnus-expunge-thread (thread)
8114 "Mark all articles in THREAD as read."
8115 (let* ((number (mail-header-number (car thread))))
8116 (incf gnus-newsgroup-expunged-tally)
8117 ;; We also mark as read here, if that's wanted.
8118 (setq gnus-newsgroup-unreads
8119 (delq number gnus-newsgroup-unreads))
8120 (if gnus-newsgroup-auto-expire
8121 (push number gnus-newsgroup-expirable)
8122 (push (cons number gnus-low-score-mark)
8123 gnus-newsgroup-reads)))
8124 ;; Go recursively through all subthreads.
8125 (mapcar 'gnus-expunge-thread (cdr thread)))
8126
8127 ;; Summary article oriented commands
8128
8129 (defun gnus-summary-refer-parent-article (n)
8130 "Refer parent article N times.
8131 If N is negative, go to ancestor -N instead.
8132 The difference between N and the number of articles fetched is returned."
8133 (interactive "p")
8134 (let ((skip 1)
8135 error header ref)
8136 (when (not (natnump n))
8137 (setq skip (abs n)
8138 n 1))
8139 (while (and (> n 0)
8140 (not error))
8141 (setq header (gnus-summary-article-header))
8142 (if (and (eq (mail-header-number header)
8143 (cdr gnus-article-current))
8144 (equal gnus-newsgroup-name
8145 (car gnus-article-current)))
8146 ;; If we try to find the parent of the currently
8147 ;; displayed article, then we take a look at the actual
8148 ;; References header, since this is slightly more
8149 ;; reliable than the References field we got from the
8150 ;; server.
8151 (save-excursion
8152 (set-buffer gnus-original-article-buffer)
8153 (nnheader-narrow-to-headers)
8154 (unless (setq ref (message-fetch-field "references"))
8155 (when (setq ref (message-fetch-field "in-reply-to"))
8156 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8157 (widen))
8158 (setq ref
8159 ;; It's not the current article, so we take a bet on
8160 ;; the value we got from the server.
8161 (mail-header-references header)))
8162 (if (and ref
8163 (not (equal ref "")))
8164 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8165 (gnus-message 1 "Couldn't find parent"))
8166 (gnus-message 1 "No references in article %d"
8167 (gnus-summary-article-number))
8168 (setq error t))
8169 (decf n))
8170 (gnus-summary-position-point)
8171 n))
8172
8173 (defun gnus-summary-refer-references ()
8174 "Fetch all articles mentioned in the References header.
8175 Return the number of articles fetched."
8176 (interactive)
8177 (let ((ref (mail-header-references (gnus-summary-article-header)))
8178 (current (gnus-summary-article-number))
8179 (n 0))
8180 (if (or (not ref)
8181 (equal ref ""))
8182 (error "No References in the current article")
8183 ;; For each Message-ID in the References header...
8184 (while (string-match "<[^>]*>" ref)
8185 (incf n)
8186 ;; ... fetch that article.
8187 (gnus-summary-refer-article
8188 (prog1 (match-string 0 ref)
8189 (setq ref (substring ref (match-end 0))))))
8190 (gnus-summary-goto-subject current)
8191 (gnus-summary-position-point)
8192 n)))
8193
8194 (defun gnus-summary-refer-thread (&optional limit)
8195 "Fetch all articles in the current thread.
8196 If LIMIT (the numerical prefix), fetch that many old headers instead
8197 of what's specified by the `gnus-refer-thread-limit' variable."
8198 (interactive "P")
8199 (let ((id (mail-header-id (gnus-summary-article-header)))
8200 (limit (if limit (prefix-numeric-value limit)
8201 gnus-refer-thread-limit)))
8202 (unless (eq gnus-fetch-old-headers 'invisible)
8203 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8204 ;; Retrieve the headers and read them in.
8205 (if (eq (if (numberp limit)
8206 (gnus-retrieve-headers
8207 (list (min
8208 (+ (mail-header-number
8209 (gnus-summary-article-header))
8210 limit)
8211 gnus-newsgroup-end))
8212 gnus-newsgroup-name (* limit 2))
8213 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8214 ;; headers.
8215 (gnus-retrieve-headers (list gnus-newsgroup-end)
8216 gnus-newsgroup-name limit))
8217 'nov)
8218 (gnus-build-all-threads)
8219 (error "Can't fetch thread from back ends that don't support NOV"))
8220 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8221 (gnus-summary-limit-include-thread id)))
8222
8223 (defun gnus-summary-refer-article (message-id)
8224 "Fetch an article specified by MESSAGE-ID."
8225 (interactive "sMessage-ID: ")
8226 (when (and (stringp message-id)
8227 (not (zerop (length message-id))))
8228 (setq message-id (gnus-replace-in-string message-id " " ""))
8229 ;; Construct the correct Message-ID if necessary.
8230 ;; Suggested by tale@pawl.rpi.edu.
8231 (unless (string-match "^<" message-id)
8232 (setq message-id (concat "<" message-id)))
8233 (unless (string-match ">$" message-id)
8234 (setq message-id (concat message-id ">")))
8235 ;; People often post MIDs from URLs, so unhex it:
8236 (unless (string-match "@" message-id)
8237 (setq message-id (gnus-url-unhex-string message-id)))
8238 (let* ((header (gnus-id-to-header message-id))
8239 (sparse (and header
8240 (gnus-summary-article-sparse-p
8241 (mail-header-number header))
8242 (memq (mail-header-number header)
8243 gnus-newsgroup-limit)))
8244 number)
8245 (cond
8246 ;; If the article is present in the buffer we just go to it.
8247 ((and header
8248 (or (not (gnus-summary-article-sparse-p
8249 (mail-header-number header)))
8250 sparse))
8251 (prog1
8252 (gnus-summary-goto-article
8253 (mail-header-number header) nil t)
8254 (when sparse
8255 (gnus-summary-update-article (mail-header-number header)))))
8256 (t
8257 ;; We fetch the article.
8258 (catch 'found
8259 (dolist (gnus-override-method (gnus-refer-article-methods))
8260 (when (and (gnus-check-server gnus-override-method)
8261 ;; Fetch the header,
8262 (setq number (gnus-summary-insert-subject message-id)))
8263 ;; and display the article.
8264 (gnus-summary-select-article nil nil nil number)
8265 (throw 'found t)))
8266 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8267
8268 (defun gnus-refer-article-methods ()
8269 "Return a list of referable methods."
8270 (cond
8271 ;; No method, so we default to current and native.
8272 ((null gnus-refer-article-method)
8273 (list gnus-current-select-method gnus-select-method))
8274 ;; Current.
8275 ((eq 'current gnus-refer-article-method)
8276 (list gnus-current-select-method))
8277 ;; List of select methods.
8278 ((not (and (symbolp (car gnus-refer-article-method))
8279 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8280 (let (out)
8281 (dolist (method gnus-refer-article-method)
8282 (push (if (eq 'current method)
8283 gnus-current-select-method
8284 method)
8285 out))
8286 (nreverse out)))
8287 ;; One single select method.
8288 (t
8289 (list gnus-refer-article-method))))
8290
8291 (defun gnus-summary-edit-parameters ()
8292 "Edit the group parameters of the current group."
8293 (interactive)
8294 (gnus-group-edit-group gnus-newsgroup-name 'params))
8295
8296 (defun gnus-summary-customize-parameters ()
8297 "Customize the group parameters of the current group."
8298 (interactive)
8299 (gnus-group-customize gnus-newsgroup-name))
8300
8301 (defun gnus-summary-enter-digest-group (&optional force)
8302 "Enter an nndoc group based on the current article.
8303 If FORCE, force a digest interpretation. If not, try
8304 to guess what the document format is."
8305 (interactive "P")
8306 (let ((conf gnus-current-window-configuration))
8307 (save-window-excursion
8308 (save-excursion
8309 (let (gnus-article-prepare-hook
8310 gnus-display-mime-function
8311 gnus-break-pages)
8312 (gnus-summary-select-article))))
8313 (setq gnus-current-window-configuration conf)
8314 (let* ((name (format "%s-%d"
8315 (gnus-group-prefixed-name
8316 gnus-newsgroup-name (list 'nndoc ""))
8317 (save-excursion
8318 (set-buffer gnus-summary-buffer)
8319 gnus-current-article)))
8320 (ogroup gnus-newsgroup-name)
8321 (params (append (gnus-info-params (gnus-get-info ogroup))
8322 (list (cons 'to-group ogroup))
8323 (list (cons 'parent-group ogroup))
8324 (list (cons 'save-article-group ogroup))))
8325 (case-fold-search t)
8326 (buf (current-buffer))
8327 dig to-address)
8328 (save-excursion
8329 (set-buffer gnus-original-article-buffer)
8330 ;; Have the digest group inherit the main mail address of
8331 ;; the parent article.
8332 (when (setq to-address (or (gnus-fetch-field "reply-to")
8333 (gnus-fetch-field "from")))
8334 (setq params (append
8335 (list (cons 'to-address
8336 (funcall gnus-decode-encoded-word-function
8337 to-address))))))
8338 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8339 (insert-buffer-substring gnus-original-article-buffer)
8340 ;; Remove lines that may lead nndoc to misinterpret the
8341 ;; document type.
8342 (narrow-to-region
8343 (goto-char (point-min))
8344 (or (search-forward "\n\n" nil t) (point)))
8345 (goto-char (point-min))
8346 (delete-matching-lines "^Path:\\|^From ")
8347 (widen))
8348 (unwind-protect
8349 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8350 (gnus-newsgroup-ephemeral-ignored-charsets
8351 gnus-newsgroup-ignored-charsets))
8352 (gnus-group-read-ephemeral-group
8353 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8354 (nndoc-article-type
8355 ,(if force 'mbox 'guess)))
8356 t nil nil nil
8357 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8358 "ADAPT")))))
8359 ;; Make all postings to this group go to the parent group.
8360 (nconc (gnus-info-params (gnus-get-info name))
8361 params)
8362 ;; Couldn't select this doc group.
8363 (switch-to-buffer buf)
8364 (gnus-set-global-variables)
8365 (gnus-configure-windows 'summary)
8366 (gnus-message 3 "Article couldn't be entered?"))
8367 (kill-buffer dig)))))
8368
8369 (defun gnus-summary-read-document (n)
8370 "Open a new group based on the current article(s).
8371 This will allow you to read digests and other similar
8372 documents as newsgroups.
8373 Obeys the standard process/prefix convention."
8374 (interactive "P")
8375 (let* ((articles (gnus-summary-work-articles n))
8376 (ogroup gnus-newsgroup-name)
8377 (params (append (gnus-info-params (gnus-get-info ogroup))
8378 (list (cons 'to-group ogroup))))
8379 article group egroup groups vgroup)
8380 (while (setq article (pop articles))
8381 (setq group (format "%s-%d" gnus-newsgroup-name article))
8382 (gnus-summary-remove-process-mark article)
8383 (when (gnus-summary-display-article article)
8384 (save-excursion
8385 (with-temp-buffer
8386 (insert-buffer-substring gnus-original-article-buffer)
8387 ;; Remove some headers that may lead nndoc to make
8388 ;; the wrong guess.
8389 (message-narrow-to-head)
8390 (goto-char (point-min))
8391 (delete-matching-lines "^\\(Path\\):\\|^From ")
8392 (widen)
8393 (if (setq egroup
8394 (gnus-group-read-ephemeral-group
8395 group `(nndoc ,group (nndoc-address ,(current-buffer))
8396 (nndoc-article-type guess))
8397 t nil t))
8398 (progn
8399 ;; Make all postings to this group go to the parent group.
8400 (nconc (gnus-info-params (gnus-get-info egroup))
8401 params)
8402 (push egroup groups))
8403 ;; Couldn't select this doc group.
8404 (gnus-error 3 "Article couldn't be entered"))))))
8405 ;; Now we have selected all the documents.
8406 (cond
8407 ((not groups)
8408 (error "None of the articles could be interpreted as documents"))
8409 ((gnus-group-read-ephemeral-group
8410 (setq vgroup (format
8411 "nnvirtual:%s-%s" gnus-newsgroup-name
8412 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8413 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8414 t
8415 (cons (current-buffer) 'summary)))
8416 (t
8417 (error "Couldn't select virtual nndoc group")))))
8418
8419 (defun gnus-summary-isearch-article (&optional regexp-p)
8420 "Do incremental search forward on the current article.
8421 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8422 (interactive "P")
8423 (gnus-summary-select-article)
8424 (gnus-configure-windows 'article)
8425 (gnus-eval-in-buffer-window gnus-article-buffer
8426 (save-restriction
8427 (widen)
8428 (isearch-forward regexp-p))))
8429
8430 (defun gnus-summary-search-article-forward (regexp &optional backward)
8431 "Search for an article containing REGEXP forward.
8432 If BACKWARD, search backward instead."
8433 (interactive
8434 (list (read-string
8435 (format "Search article %s (regexp%s): "
8436 (if current-prefix-arg "backward" "forward")
8437 (if gnus-last-search-regexp
8438 (concat ", default " gnus-last-search-regexp)
8439 "")))
8440 current-prefix-arg))
8441 (if (string-equal regexp "")
8442 (setq regexp (or gnus-last-search-regexp ""))
8443 (setq gnus-last-search-regexp regexp)
8444 (setq gnus-article-before-search gnus-current-article))
8445 ;; Intentionally set gnus-last-article.
8446 (setq gnus-last-article gnus-article-before-search)
8447 (let ((gnus-last-article gnus-last-article))
8448 (if (gnus-summary-search-article regexp backward)
8449 (gnus-summary-show-thread)
8450 (signal 'search-failed (list regexp)))))
8451
8452 (defun gnus-summary-search-article-backward (regexp)
8453 "Search for an article containing REGEXP backward."
8454 (interactive
8455 (list (read-string
8456 (format "Search article backward (regexp%s): "
8457 (if gnus-last-search-regexp
8458 (concat ", default " gnus-last-search-regexp)
8459 "")))))
8460 (gnus-summary-search-article-forward regexp 'backward))
8461
8462 (defun gnus-summary-search-article (regexp &optional backward)
8463 "Search for an article containing REGEXP.
8464 Optional argument BACKWARD means do search for backward.
8465 `gnus-select-article-hook' is not called during the search."
8466 ;; We have to require this here to make sure that the following
8467 ;; dynamic binding isn't shadowed by autoloading.
8468 (require 'gnus-async)
8469 (require 'gnus-art)
8470 (let ((gnus-select-article-hook nil) ;Disable hook.
8471 (gnus-article-prepare-hook nil)
8472 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8473 (gnus-use-article-prefetch nil)
8474 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8475 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8476 (gnus-visual nil)
8477 (gnus-keep-backlog nil)
8478 (gnus-break-pages nil)
8479 (gnus-summary-display-arrow nil)
8480 (gnus-updated-mode-lines nil)
8481 (gnus-auto-center-summary nil)
8482 (sum (current-buffer))
8483 (gnus-display-mime-function nil)
8484 (found nil)
8485 point)
8486 (gnus-save-hidden-threads
8487 (gnus-summary-select-article)
8488 (set-buffer gnus-article-buffer)
8489 (goto-char (window-point (get-buffer-window (current-buffer))))
8490 (when backward
8491 (forward-line -1))
8492 (while (not found)
8493 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8494 (if (if backward
8495 (re-search-backward regexp nil t)
8496 (re-search-forward regexp nil t))
8497 ;; We found the regexp.
8498 (progn
8499 (setq found 'found)
8500 (beginning-of-line)
8501 (set-window-start
8502 (get-buffer-window (current-buffer))
8503 (point))
8504 (forward-line 1)
8505 (set-window-point
8506 (get-buffer-window (current-buffer))
8507 (point))
8508 (set-buffer sum)
8509 (setq point (point)))
8510 ;; We didn't find it, so we go to the next article.
8511 (set-buffer sum)
8512 (setq found 'not)
8513 (while (eq found 'not)
8514 (if (not (if backward (gnus-summary-find-prev)
8515 (gnus-summary-find-next)))
8516 ;; No more articles.
8517 (setq found t)
8518 ;; Select the next article and adjust point.
8519 (unless (gnus-summary-article-sparse-p
8520 (gnus-summary-article-number))
8521 (setq found nil)
8522 (gnus-summary-select-article)
8523 (set-buffer gnus-article-buffer)
8524 (widen)
8525 (goto-char (if backward (point-max) (point-min))))))))
8526 (gnus-message 7 ""))
8527 ;; Return whether we found the regexp.
8528 (when (eq found 'found)
8529 (goto-char point)
8530 (gnus-summary-show-thread)
8531 (gnus-summary-goto-subject gnus-current-article)
8532 (gnus-summary-position-point)
8533 t)))
8534
8535 (defun gnus-find-matching-articles (header regexp)
8536 "Return a list of all articles that match REGEXP on HEADER.
8537 This search includes all articles in the current group that Gnus has
8538 fetched headers for, whether they are displayed or not."
8539 (let ((articles nil)
8540 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8541 (case-fold-search t))
8542 (dolist (header gnus-newsgroup-headers)
8543 (when (string-match regexp (funcall func header))
8544 (push (mail-header-number header) articles)))
8545 (nreverse articles)))
8546
8547 (defun gnus-summary-find-matching (header regexp &optional backward unread
8548 not-case-fold not-matching)
8549 "Return a list of all articles that match REGEXP on HEADER.
8550 The search stars on the current article and goes forwards unless
8551 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8552 If UNREAD is non-nil, only unread articles will
8553 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8554 in the comparisons. If NOT-MATCHING, return a list of all articles that
8555 not match REGEXP on HEADER."
8556 (let ((case-fold-search (not not-case-fold))
8557 articles d func)
8558 (if (consp header)
8559 (if (eq (car header) 'extra)
8560 (setq func
8561 `(lambda (h)
8562 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8563 "")))
8564 (error "%s is an invalid header" header))
8565 (unless (fboundp (intern (concat "mail-header-" header)))
8566 (error "%s is not a valid header" header))
8567 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8568 (dolist (d (if (eq backward 'all)
8569 gnus-newsgroup-data
8570 (gnus-data-find-list
8571 (gnus-summary-article-number)
8572 (gnus-data-list backward))))
8573 (when (and (or (not unread) ; We want all articles...
8574 (gnus-data-unread-p d)) ; Or just unreads.
8575 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8576 (if not-matching
8577 (not (string-match
8578 regexp
8579 (funcall func (gnus-data-header d))))
8580 (string-match regexp
8581 (funcall func (gnus-data-header d)))))
8582 (push (gnus-data-number d) articles))) ; Success!
8583 (nreverse articles)))
8584
8585 (defun gnus-summary-execute-command (header regexp command &optional backward)
8586 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8587 If HEADER is an empty string (or nil), the match is done on the entire
8588 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8589 (interactive
8590 (list (let ((completion-ignore-case t))
8591 (completing-read
8592 "Header name: "
8593 (mapcar (lambda (header) (list (format "%s" header)))
8594 (append
8595 '("Number" "Subject" "From" "Lines" "Date"
8596 "Message-ID" "Xref" "References" "Body")
8597 gnus-extra-headers))
8598 nil 'require-match))
8599 (read-string "Regexp: ")
8600 (read-key-sequence "Command: ")
8601 current-prefix-arg))
8602 (when (equal header "Body")
8603 (setq header ""))
8604 ;; Hidden thread subtrees must be searched as well.
8605 (gnus-summary-show-all-threads)
8606 ;; We don't want to change current point nor window configuration.
8607 (save-excursion
8608 (save-window-excursion
8609 (let (gnus-visual
8610 gnus-treat-strip-trailing-blank-lines
8611 gnus-treat-strip-leading-blank-lines
8612 gnus-treat-strip-multiple-blank-lines
8613 gnus-treat-hide-boring-headers
8614 gnus-treat-fold-newsgroups
8615 gnus-article-prepare-hook)
8616 (gnus-message 6 "Executing %s..." (key-description command))
8617 ;; We'd like to execute COMMAND interactively so as to give arguments.
8618 (gnus-execute header regexp
8619 `(call-interactively ',(key-binding command))
8620 backward)
8621 (gnus-message 6 "Executing %s...done" (key-description command))))))
8622
8623 (defun gnus-summary-beginning-of-article ()
8624 "Scroll the article back to the beginning."
8625 (interactive)
8626 (gnus-summary-select-article)
8627 (gnus-configure-windows 'article)
8628 (gnus-eval-in-buffer-window gnus-article-buffer
8629 (widen)
8630 (goto-char (point-min))
8631 (when gnus-break-pages
8632 (gnus-narrow-to-page))))
8633
8634 (defun gnus-summary-end-of-article ()
8635 "Scroll to the end of the article."
8636 (interactive)
8637 (gnus-summary-select-article)
8638 (gnus-configure-windows 'article)
8639 (gnus-eval-in-buffer-window gnus-article-buffer
8640 (widen)
8641 (goto-char (point-max))
8642 (recenter -3)
8643 (when gnus-break-pages
8644 (when (re-search-backward page-delimiter nil t)
8645 (narrow-to-region (match-end 0) (point-max)))
8646 (gnus-narrow-to-page))))
8647
8648 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8649 "Truncate to LEN and quote all \"(\"'s in STRING."
8650 (gnus-replace-in-string (if (and len (> (length string) len))
8651 (substring string 0 len)
8652 string)
8653 "[()]" "\\\\\\&"))
8654
8655 (defun gnus-summary-print-article (&optional filename n)
8656 "Generate and print a PostScript image of the process-marked (mail) articles.
8657
8658 If used interactively, print the current article if none are
8659 process-marked. With prefix arg, prompt the user for the name of the
8660 file to save in.
8661
8662 When used from Lisp, accept two optional args FILENAME and N. N means
8663 to print the next N articles. If N is negative, print the N previous
8664 articles. If N is nil and articles have been marked with the process
8665 mark, print these instead.
8666
8667 If the optional first argument FILENAME is nil, send the image to the
8668 printer. If FILENAME is a string, save the PostScript image in a file with
8669 that name. If FILENAME is a number, prompt the user for the name of the file
8670 to save in."
8671 (interactive (list (ps-print-preprint current-prefix-arg)))
8672 (dolist (article (gnus-summary-work-articles n))
8673 (gnus-summary-select-article nil nil 'pseudo article)
8674 (gnus-eval-in-buffer-window gnus-article-buffer
8675 (gnus-print-buffer))
8676 (gnus-summary-remove-process-mark article))
8677 (ps-despool filename))
8678
8679 (defun gnus-print-buffer ()
8680 (let ((buffer (generate-new-buffer " *print*")))
8681 (unwind-protect
8682 (progn
8683 (copy-to-buffer buffer (point-min) (point-max))
8684 (set-buffer buffer)
8685 (gnus-remove-text-with-property 'gnus-decoration)
8686 (when (gnus-visual-p 'article-highlight 'highlight)
8687 ;; Copy-to-buffer doesn't copy overlay. So redo
8688 ;; highlight.
8689 (let ((gnus-article-buffer buffer))
8690 (gnus-article-highlight-citation t)
8691 (gnus-article-highlight-signature)
8692 (gnus-article-emphasize)
8693 (gnus-article-delete-invisible-text)))
8694 (let ((ps-left-header
8695 (list
8696 (concat "("
8697 (gnus-summary-print-truncate-and-quote
8698 (mail-header-subject gnus-current-headers)
8699 66) ")")
8700 (concat "("
8701 (gnus-summary-print-truncate-and-quote
8702 (mail-header-from gnus-current-headers)
8703 45) ")")))
8704 (ps-right-header
8705 (list
8706 "/pagenumberstring load"
8707 (concat "("
8708 (mail-header-date gnus-current-headers) ")"))))
8709 (gnus-run-hooks 'gnus-ps-print-hook)
8710 (save-excursion
8711 (if window-system
8712 (ps-spool-buffer-with-faces)
8713 (ps-spool-buffer)))))
8714 (kill-buffer buffer))))
8715
8716 (defun gnus-summary-show-article (&optional arg)
8717 "Force redisplaying of the current article.
8718 If ARG (the prefix) is a number, show the article with the charset
8719 defined in `gnus-summary-show-article-charset-alist', or the charset
8720 input.
8721 If ARG (the prefix) is non-nil and not a number, show the raw article
8722 without any article massaging functions being run. Normally, the key
8723 strokes are `C-u g'."
8724 (interactive "P")
8725 (cond
8726 ((numberp arg)
8727 (gnus-summary-show-article t)
8728 (let ((gnus-newsgroup-charset
8729 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8730 (mm-read-coding-system
8731 "View as charset: " ;; actually it is coding system.
8732 (save-excursion
8733 (set-buffer gnus-article-buffer)
8734 (mm-detect-coding-region (point) (point-max))))))
8735 (gnus-newsgroup-ignored-charsets 'gnus-all))
8736 (gnus-summary-select-article nil 'force)
8737 (let ((deps gnus-newsgroup-dependencies)
8738 head header lines)
8739 (save-excursion
8740 (set-buffer gnus-original-article-buffer)
8741 (save-restriction
8742 (message-narrow-to-head)
8743 (setq head (buffer-string))
8744 (goto-char (point-min))
8745 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8746 (goto-char (point-max))
8747 (widen)
8748 (setq lines (1- (count-lines (point) (point-max))))))
8749 (with-temp-buffer
8750 (insert (format "211 %d Article retrieved.\n"
8751 (cdr gnus-article-current)))
8752 (insert head)
8753 (if lines (insert (format "Lines: %d\n" lines)))
8754 (insert ".\n")
8755 (let ((nntp-server-buffer (current-buffer)))
8756 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8757 (gnus-data-set-header
8758 (gnus-data-find (cdr gnus-article-current))
8759 header)
8760 (gnus-summary-update-article-line
8761 (cdr gnus-article-current) header)
8762 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8763 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8764 ((not arg)
8765 ;; Select the article the normal way.
8766 (gnus-summary-select-article nil 'force))
8767 (t
8768 ;; We have to require this here to make sure that the following
8769 ;; dynamic binding isn't shadowed by autoloading.
8770 (require 'gnus-async)
8771 (require 'gnus-art)
8772 ;; Bind the article treatment functions to nil.
8773 (let ((gnus-have-all-headers t)
8774 gnus-article-prepare-hook
8775 gnus-article-decode-hook
8776 gnus-display-mime-function
8777 gnus-break-pages)
8778 ;; Destroy any MIME parts.
8779 (when (gnus-buffer-live-p gnus-article-buffer)
8780 (save-excursion
8781 (set-buffer gnus-article-buffer)
8782 (mm-destroy-parts gnus-article-mime-handles)
8783 ;; Set it to nil for safety reason.
8784 (setq gnus-article-mime-handle-alist nil)
8785 (setq gnus-article-mime-handles nil)))
8786 (gnus-summary-select-article nil 'force))))
8787 (gnus-summary-goto-subject gnus-current-article)
8788 (gnus-summary-position-point))
8789
8790 (defun gnus-summary-show-raw-article ()
8791 "Show the raw article without any article massaging functions being run."
8792 (interactive)
8793 (gnus-summary-show-article t))
8794
8795 (defun gnus-summary-verbose-headers (&optional arg)
8796 "Toggle permanent full header display.
8797 If ARG is a positive number, turn header display on.
8798 If ARG is a negative number, turn header display off."
8799 (interactive "P")
8800 (setq gnus-show-all-headers
8801 (cond ((or (not (numberp arg))
8802 (zerop arg))
8803 (not gnus-show-all-headers))
8804 ((natnump arg)
8805 t)))
8806 (gnus-summary-show-article))
8807
8808 (defun gnus-summary-toggle-header (&optional arg)
8809 "Show the headers if they are hidden, or hide them if they are shown.
8810 If ARG is a positive number, show the entire header.
8811 If ARG is a negative number, hide the unwanted header lines."
8812 (interactive "P")
8813 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8814 (get-buffer-window gnus-article-buffer t))))
8815 (with-current-buffer gnus-article-buffer
8816 (widen)
8817 (article-narrow-to-head)
8818 (let* ((buffer-read-only nil)
8819 (inhibit-point-motion-hooks t)
8820 (hidden (if (numberp arg)
8821 (>= arg 0)
8822 (or (not (looking-at "[^ \t\n]+:"))
8823 (gnus-article-hidden-text-p 'headers))))
8824 s e)
8825 (delete-region (point-min) (point-max))
8826 (with-current-buffer gnus-original-article-buffer
8827 (goto-char (setq s (point-min)))
8828 (setq e (if (search-forward "\n\n" nil t)
8829 (1- (point))
8830 (point-max))))
8831 (insert-buffer-substring gnus-original-article-buffer s e)
8832 (run-hooks 'gnus-article-decode-hook)
8833 (if hidden
8834 (let ((gnus-treat-hide-headers nil)
8835 (gnus-treat-hide-boring-headers nil))
8836 (gnus-delete-wash-type 'headers)
8837 (gnus-treat-article 'head))
8838 (gnus-treat-article 'head))
8839 (widen)
8840 (if window
8841 (set-window-start window (goto-char (point-min))))
8842 (if gnus-break-pages
8843 (gnus-narrow-to-page)
8844 (when (gnus-visual-p 'page-marker)
8845 (let ((buffer-read-only nil))
8846 (gnus-remove-text-with-property 'gnus-prev)
8847 (gnus-remove-text-with-property 'gnus-next))))
8848 (gnus-set-mode-line 'article)))))
8849
8850 (defun gnus-summary-show-all-headers ()
8851 "Make all header lines visible."
8852 (interactive)
8853 (gnus-summary-toggle-header 1))
8854
8855 (defun gnus-summary-caesar-message (&optional arg)
8856 "Caesar rotate the current article by 13.
8857 The numerical prefix specifies how many places to rotate each letter
8858 forward."
8859 (interactive "P")
8860 (gnus-summary-select-article)
8861 (let ((mail-header-separator ""))
8862 (gnus-eval-in-buffer-window gnus-article-buffer
8863 (save-restriction
8864 (widen)
8865 (let ((start (window-start))
8866 buffer-read-only)
8867 (message-caesar-buffer-body arg)
8868 (set-window-start (get-buffer-window (current-buffer)) start)))))
8869 ;; Create buttons and stuff...
8870 (gnus-treat-article nil))
8871
8872 (autoload 'unmorse-region "morse"
8873 "Convert morse coded text in region to ordinary ASCII text."
8874 t)
8875
8876 (defun gnus-summary-morse-message (&optional arg)
8877 "Morse decode the current article."
8878 (interactive "P")
8879 (gnus-summary-select-article)
8880 (let ((mail-header-separator ""))
8881 (gnus-eval-in-buffer-window gnus-article-buffer
8882 (save-excursion
8883 (save-restriction
8884 (widen)
8885 (let ((pos (window-start))
8886 buffer-read-only)
8887 (goto-char (point-min))
8888 (when (message-goto-body)
8889 (gnus-narrow-to-body))
8890 (goto-char (point-min))
8891 (while (re-search-forward "·" (point-max) t)
8892 (replace-match "."))
8893 (unmorse-region (point-min) (point-max))
8894 (widen)
8895 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8896
8897 (defun gnus-summary-stop-page-breaking ()
8898 "Stop page breaking in the current article."
8899 (interactive)
8900 (gnus-summary-select-article)
8901 (gnus-eval-in-buffer-window gnus-article-buffer
8902 (widen)
8903 (when (gnus-visual-p 'page-marker)
8904 (let ((buffer-read-only nil))
8905 (gnus-remove-text-with-property 'gnus-prev)
8906 (gnus-remove-text-with-property 'gnus-next))
8907 (setq gnus-page-broken nil))))
8908
8909 (defun gnus-summary-move-article (&optional n to-newsgroup
8910 select-method action)
8911 "Move the current article to a different newsgroup.
8912 If N is a positive number, move the N next articles.
8913 If N is a negative number, move the N previous articles.
8914 If N is nil and any articles have been marked with the process mark,
8915 move those articles instead.
8916 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8917 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8918 re-spool using this method.
8919
8920 When called interactively with TO-NEWSGROUP being nil, the value of
8921 the variable `gnus-move-split-methods' is used for finding a default
8922 for the target newsgroup.
8923
8924 For this function to work, both the current newsgroup and the
8925 newsgroup that you want to move to have to support the `request-move'
8926 and `request-accept' functions.
8927
8928 ACTION can be either `move' (the default), `crosspost' or `copy'."
8929 (interactive "P")
8930 (unless action
8931 (setq action 'move))
8932 ;; Check whether the source group supports the required functions.
8933 (cond ((and (eq action 'move)
8934 (not (gnus-check-backend-function
8935 'request-move-article gnus-newsgroup-name)))
8936 (error "The current group does not support article moving"))
8937 ((and (eq action 'crosspost)
8938 (not (gnus-check-backend-function
8939 'request-replace-article gnus-newsgroup-name)))
8940 (error "The current group does not support article editing")))
8941 (let ((articles (gnus-summary-work-articles n))
8942 (prefix (if (gnus-check-backend-function
8943 'request-move-article gnus-newsgroup-name)
8944 (gnus-group-real-prefix gnus-newsgroup-name)
8945 ""))
8946 (names '((move "Move" "Moving")
8947 (copy "Copy" "Copying")
8948 (crosspost "Crosspost" "Crossposting")))
8949 (copy-buf (save-excursion
8950 (nnheader-set-temp-buffer " *copy article*")))
8951 art-group to-method new-xref article to-groups)
8952 (unless (assq action names)
8953 (error "Unknown action %s" action))
8954 ;; Read the newsgroup name.
8955 (when (and (not to-newsgroup)
8956 (not select-method))
8957 (if (and gnus-move-split-methods
8958 (not
8959 (and (memq gnus-current-article articles)
8960 (gnus-buffer-live-p gnus-original-article-buffer))))
8961 ;; When `gnus-move-split-methods' is non-nil, we have to
8962 ;; select an article to give `gnus-read-move-group-name' an
8963 ;; opportunity to suggest an appropriate default. However,
8964 ;; we needn't render or mark the article.
8965 (let ((gnus-display-mime-function nil)
8966 (gnus-article-prepare-hook nil)
8967 (gnus-mark-article-hook nil))
8968 (gnus-summary-select-article nil nil nil (car articles))))
8969 (setq to-newsgroup
8970 (gnus-read-move-group-name
8971 (cadr (assq action names))
8972 (symbol-value (intern (format "gnus-current-%s-group" action)))
8973 articles prefix))
8974 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8975 (setq to-method (or select-method
8976 (gnus-server-to-method
8977 (gnus-group-method to-newsgroup))))
8978 ;; Check the method we are to move this article to...
8979 (unless (gnus-check-backend-function
8980 'request-accept-article (car to-method))
8981 (error "%s does not support article copying" (car to-method)))
8982 (unless (gnus-check-server to-method)
8983 (error "Can't open server %s" (car to-method)))
8984 (gnus-message 6 "%s to %s: %s..."
8985 (caddr (assq action names))
8986 (or (car select-method) to-newsgroup) articles)
8987 (while articles
8988 (setq article (pop articles))
8989 (setq
8990 art-group
8991 (cond
8992 ;; Move the article.
8993 ((eq action 'move)
8994 ;; Remove this article from future suppression.
8995 (gnus-dup-unsuppress-article article)
8996 (gnus-request-move-article
8997 article ; Article to move
8998 gnus-newsgroup-name ; From newsgroup
8999 (nth 1 (gnus-find-method-for-group
9000 gnus-newsgroup-name)) ; Server
9001 (list 'gnus-request-accept-article
9002 to-newsgroup (list 'quote select-method)
9003 (not articles) t) ; Accept form
9004 (not articles))) ; Only save nov last time
9005 ;; Copy the article.
9006 ((eq action 'copy)
9007 (save-excursion
9008 (set-buffer copy-buf)
9009 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9010 (gnus-request-accept-article
9011 to-newsgroup select-method (not articles) t))))
9012 ;; Crosspost the article.
9013 ((eq action 'crosspost)
9014 (let ((xref (message-tokenize-header
9015 (mail-header-xref (gnus-summary-article-header article))
9016 " ")))
9017 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9018 ":" (number-to-string article)))
9019 (unless xref
9020 (setq xref (list (system-name))))
9021 (setq new-xref
9022 (concat
9023 (mapconcat 'identity
9024 (delete "Xref:" (delete new-xref xref))
9025 " ")
9026 " " new-xref))
9027 (save-excursion
9028 (set-buffer copy-buf)
9029 ;; First put the article in the destination group.
9030 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9031 (when (consp (setq art-group
9032 (gnus-request-accept-article
9033 to-newsgroup select-method (not articles))))
9034 (setq new-xref (concat new-xref " " (car art-group)
9035 ":"
9036 (number-to-string (cdr art-group))))
9037 ;; Now we have the new Xrefs header, so we insert
9038 ;; it and replace the new article.
9039 (nnheader-replace-header "Xref" new-xref)
9040 (gnus-request-replace-article
9041 (cdr art-group) to-newsgroup (current-buffer))
9042 art-group))))))
9043 (cond
9044 ((not art-group)
9045 (gnus-message 1 "Couldn't %s article %s: %s"
9046 (cadr (assq action names)) article
9047 (nnheader-get-report (car to-method))))
9048 ((eq art-group 'junk)
9049 (when (eq action 'move)
9050 (gnus-summary-mark-article article gnus-canceled-mark)
9051 (gnus-message 4 "Deleted article %s" article)
9052 ;; run the delete hook
9053 (run-hook-with-args 'gnus-summary-article-delete-hook
9054 action
9055 (gnus-data-header
9056 (assoc article (gnus-data-list nil)))
9057 gnus-newsgroup-name nil
9058 select-method)))
9059 (t
9060 (let* ((pto-group (gnus-group-prefixed-name
9061 (car art-group) to-method))
9062 (entry
9063 (gnus-gethash pto-group gnus-newsrc-hashtb))
9064 (info (nth 2 entry))
9065 (to-group (gnus-info-group info))
9066 to-marks)
9067 ;; Update the group that has been moved to.
9068 (when (and info
9069 (memq action '(move copy)))
9070 (unless (member to-group to-groups)
9071 (push to-group to-groups))
9072
9073 (unless (memq article gnus-newsgroup-unreads)
9074 (push 'read to-marks)
9075 (gnus-info-set-read
9076 info (gnus-add-to-range (gnus-info-read info)
9077 (list (cdr art-group)))))
9078
9079 ;; See whether the article is to be put in the cache.
9080 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9081 gnus-article-mark-lists
9082 (delete '(expirable . expire)
9083 (copy-sequence gnus-article-mark-lists))))
9084 (to-article (cdr art-group)))
9085
9086 ;; Enter the article into the cache in the new group,
9087 ;; if that is required.
9088 (when gnus-use-cache
9089 (gnus-cache-possibly-enter-article
9090 to-group to-article
9091 (memq article gnus-newsgroup-marked)
9092 (memq article gnus-newsgroup-dormant)
9093 (memq article gnus-newsgroup-unreads)))
9094
9095 (when gnus-preserve-marks
9096 ;; Copy any marks over to the new group.
9097 (when (and (equal to-group gnus-newsgroup-name)
9098 (not (memq article gnus-newsgroup-unreads)))
9099 ;; Mark this article as read in this group.
9100 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9101 (setcdr (gnus-active to-group) to-article)
9102 (setcdr gnus-newsgroup-active to-article))
9103
9104 (while marks
9105 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9106 (when (memq article (symbol-value
9107 (intern (format "gnus-newsgroup-%s"
9108 (caar marks)))))
9109 (push (cdar marks) to-marks)
9110 ;; If the other group is the same as this group,
9111 ;; then we have to add the mark to the list.
9112 (when (equal to-group gnus-newsgroup-name)
9113 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9114 (cons to-article
9115 (symbol-value
9116 (intern (format "gnus-newsgroup-%s"
9117 (caar marks)))))))
9118 ;; Copy the marks to other group.
9119 (gnus-add-marked-articles
9120 to-group (cdar marks) (list to-article) info)))
9121 (setq marks (cdr marks)))
9122
9123 (gnus-request-set-mark
9124 to-group (list (list (list to-article) 'add to-marks))))
9125
9126 (gnus-dribble-enter
9127 (concat "(gnus-group-set-info '"
9128 (gnus-prin1-to-string (gnus-get-info to-group))
9129 ")"))))
9130
9131 ;; Update the Xref header in this article to point to
9132 ;; the new crossposted article we have just created.
9133 (when (eq action 'crosspost)
9134 (save-excursion
9135 (set-buffer copy-buf)
9136 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9137 (nnheader-replace-header "Xref" new-xref)
9138 (gnus-request-replace-article
9139 article gnus-newsgroup-name (current-buffer))))
9140
9141 ;; run the move/copy/crosspost/respool hook
9142 (run-hook-with-args 'gnus-summary-article-move-hook
9143 action
9144 (gnus-data-header
9145 (assoc article (gnus-data-list nil)))
9146 gnus-newsgroup-name
9147 to-newsgroup
9148 select-method))
9149
9150 ;;;!!!Why is this necessary?
9151 (set-buffer gnus-summary-buffer)
9152
9153 (gnus-summary-goto-subject article)
9154 (when (eq action 'move)
9155 (gnus-summary-mark-article article gnus-canceled-mark))))
9156 (gnus-summary-remove-process-mark article))
9157 ;; Re-activate all groups that have been moved to.
9158 (save-excursion
9159 (set-buffer gnus-group-buffer)
9160 (let ((gnus-group-marked to-groups))
9161 (gnus-group-get-new-news-this-group nil t)))
9162
9163 (gnus-kill-buffer copy-buf)
9164 (gnus-summary-position-point)
9165 (gnus-set-mode-line 'summary)))
9166
9167 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9168 "Copy the current article to some other group.
9169 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9170 When called interactively, if TO-NEWSGROUP is nil, use the value of
9171 the variable `gnus-move-split-methods' for finding a default target
9172 newsgroup.
9173 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9174 re-spool using this method."
9175 (interactive "P")
9176 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9177
9178 (defun gnus-summary-crosspost-article (&optional n)
9179 "Crosspost the current article to some other group."
9180 (interactive "P")
9181 (gnus-summary-move-article n nil nil 'crosspost))
9182
9183 (defcustom gnus-summary-respool-default-method nil
9184 "Default method type for respooling an article.
9185 If nil, use to the current newsgroup method."
9186 :type 'symbol
9187 :group 'gnus-summary-mail)
9188
9189 (defcustom gnus-summary-display-while-building nil
9190 "If non-nil, show and update the summary buffer as it's being built.
9191 If the value is t, update the buffer after every line is inserted. If
9192 the value is an integer (N), update the display every N lines."
9193 :version "22.1"
9194 :group 'gnus-thread
9195 :type '(choice (const :tag "off" nil)
9196 number
9197 (const :tag "frequently" t)))
9198
9199 (defun gnus-summary-respool-article (&optional n method)
9200 "Respool the current article.
9201 The article will be squeezed through the mail spooling process again,
9202 which means that it will be put in some mail newsgroup or other
9203 depending on `nnmail-split-methods'.
9204 If N is a positive number, respool the N next articles.
9205 If N is a negative number, respool the N previous articles.
9206 If N is nil and any articles have been marked with the process mark,
9207 respool those articles instead.
9208
9209 Respooling can be done both from mail groups and \"real\" newsgroups.
9210 In the former case, the articles in question will be moved from the
9211 current group into whatever groups they are destined to. In the
9212 latter case, they will be copied into the relevant groups."
9213 (interactive
9214 (list current-prefix-arg
9215 (let* ((methods (gnus-methods-using 'respool))
9216 (methname
9217 (symbol-name (or gnus-summary-respool-default-method
9218 (car (gnus-find-method-for-group
9219 gnus-newsgroup-name)))))
9220 (method
9221 (gnus-completing-read-with-default
9222 methname "What backend do you want to use when respooling?"
9223 methods nil t nil 'gnus-mail-method-history))
9224 ms)
9225 (cond
9226 ((zerop (length (setq ms (gnus-servers-using-backend
9227 (intern method)))))
9228 (list (intern method) ""))
9229 ((= 1 (length ms))
9230 (car ms))
9231 (t
9232 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9233 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9234 ms-alist))))))))
9235 (unless method
9236 (error "No method given for respooling"))
9237 (if (assoc (symbol-name
9238 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9239 (gnus-methods-using 'respool))
9240 (gnus-summary-move-article n nil method)
9241 (gnus-summary-copy-article n nil method)))
9242
9243 (defun gnus-summary-import-article (file &optional edit)
9244 "Import an arbitrary file into a mail newsgroup."
9245 (interactive "fImport file: \nP")
9246 (let ((group gnus-newsgroup-name)
9247 (now (current-time))
9248 atts lines group-art)
9249 (unless (gnus-check-backend-function 'request-accept-article group)
9250 (error "%s does not support article importing" group))
9251 (or (file-readable-p file)
9252 (not (file-regular-p file))
9253 (error "Can't read %s" file))
9254 (save-excursion
9255 (set-buffer (gnus-get-buffer-create " *import file*"))
9256 (erase-buffer)
9257 (nnheader-insert-file-contents file)
9258 (goto-char (point-min))
9259 (if (nnheader-article-p)
9260 (save-restriction
9261 (goto-char (point-min))
9262 (search-forward "\n\n" nil t)
9263 (narrow-to-region (point-min) (1- (point)))
9264 (goto-char (point-min))
9265 (unless (re-search-forward "^date:" nil t)
9266 (goto-char (point-max))
9267 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9268 ;; This doesn't look like an article, so we fudge some headers.
9269 (setq atts (file-attributes file)
9270 lines (count-lines (point-min) (point-max)))
9271 (insert "From: " (read-string "From: ") "\n"
9272 "Subject: " (read-string "Subject: ") "\n"
9273 "Date: " (message-make-date (nth 5 atts)) "\n"
9274 "Message-ID: " (message-make-message-id) "\n"
9275 "Lines: " (int-to-string lines) "\n"
9276 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9277 (setq group-art (gnus-request-accept-article group nil t))
9278 (kill-buffer (current-buffer)))
9279 (setq gnus-newsgroup-active (gnus-activate-group group))
9280 (forward-line 1)
9281 (gnus-summary-goto-article (cdr group-art) nil t)
9282 (when edit
9283 (gnus-summary-edit-article))))
9284
9285 (defun gnus-summary-create-article ()
9286 "Create an article in a mail newsgroup."
9287 (interactive)
9288 (let ((group gnus-newsgroup-name)
9289 (now (current-time))
9290 group-art)
9291 (unless (gnus-check-backend-function 'request-accept-article group)
9292 (error "%s does not support article importing" group))
9293 (save-excursion
9294 (set-buffer (gnus-get-buffer-create " *import file*"))
9295 (erase-buffer)
9296 (goto-char (point-min))
9297 ;; This doesn't look like an article, so we fudge some headers.
9298 (insert "From: " (read-string "From: ") "\n"
9299 "Subject: " (read-string "Subject: ") "\n"
9300 "Date: " (message-make-date now) "\n"
9301 "Message-ID: " (message-make-message-id) "\n")
9302 (setq group-art (gnus-request-accept-article group nil t))
9303 (kill-buffer (current-buffer)))
9304 (setq gnus-newsgroup-active (gnus-activate-group group))
9305 (forward-line 1)
9306 (gnus-summary-goto-article (cdr group-art) nil t)
9307 (gnus-summary-edit-article)))
9308
9309 (defun gnus-summary-article-posted-p ()
9310 "Say whether the current (mail) article is available from news as well.
9311 This will be the case if the article has both been mailed and posted."
9312 (interactive)
9313 (let ((id (mail-header-references (gnus-summary-article-header)))
9314 (gnus-override-method (car (gnus-refer-article-methods))))
9315 (if (gnus-request-head id "")
9316 (gnus-message 2 "The current message was found on %s"
9317 gnus-override-method)
9318 (gnus-message 2 "The current message couldn't be found on %s"
9319 gnus-override-method)
9320 nil)))
9321
9322 (defun gnus-summary-expire-articles (&optional now)
9323 "Expire all articles that are marked as expirable in the current group."
9324 (interactive)
9325 (when (and (not gnus-group-is-exiting-without-update-p)
9326 (gnus-check-backend-function
9327 'request-expire-articles gnus-newsgroup-name))
9328 ;; This backend supports expiry.
9329 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9330 (expirable (if total
9331 (progn
9332 ;; We need to update the info for
9333 ;; this group for `gnus-list-of-read-articles'
9334 ;; to give us the right answer.
9335 (gnus-run-hooks 'gnus-exit-group-hook)
9336 (gnus-summary-update-info)
9337 (gnus-list-of-read-articles gnus-newsgroup-name))
9338 (setq gnus-newsgroup-expirable
9339 (sort gnus-newsgroup-expirable '<))))
9340 (expiry-wait (if now 'immediate
9341 (gnus-group-find-parameter
9342 gnus-newsgroup-name 'expiry-wait)))
9343 (nnmail-expiry-target
9344 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9345 nnmail-expiry-target))
9346 es)
9347 (when expirable
9348 ;; There are expirable articles in this group, so we run them
9349 ;; through the expiry process.
9350 (gnus-message 6 "Expiring articles...")
9351 (unless (gnus-check-group gnus-newsgroup-name)
9352 (error "Can't open server for %s" gnus-newsgroup-name))
9353 ;; The list of articles that weren't expired is returned.
9354 (save-excursion
9355 (if expiry-wait
9356 (let ((nnmail-expiry-wait-function nil)
9357 (nnmail-expiry-wait expiry-wait))
9358 (setq es (gnus-request-expire-articles
9359 expirable gnus-newsgroup-name)))
9360 (setq es (gnus-request-expire-articles
9361 expirable gnus-newsgroup-name)))
9362 (unless total
9363 (setq gnus-newsgroup-expirable es))
9364 ;; We go through the old list of expirable, and mark all
9365 ;; really expired articles as nonexistent.
9366 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9367 (let ((gnus-use-cache nil))
9368 (dolist (article expirable)
9369 (when (and (not (memq article es))
9370 (gnus-data-find article))
9371 (gnus-summary-mark-article article gnus-canceled-mark)
9372 (run-hook-with-args 'gnus-summary-article-expire-hook
9373 'delete
9374 (gnus-data-header
9375 (assoc article (gnus-data-list nil)))
9376 gnus-newsgroup-name
9377 nil
9378 nil))))))
9379 (gnus-message 6 "Expiring articles...done")))))
9380
9381 (defun gnus-summary-expire-articles-now ()
9382 "Expunge all expirable articles in the current group.
9383 This means that *all* articles that are marked as expirable will be
9384 deleted forever, right now."
9385 (interactive)
9386 (or gnus-expert-user
9387 (gnus-yes-or-no-p
9388 "Are you really, really, really sure you want to delete all these messages? ")
9389 (error "Phew!"))
9390 (gnus-summary-expire-articles t))
9391
9392 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9393 (defun gnus-summary-delete-article (&optional n)
9394 "Delete the N next (mail) articles.
9395 This command actually deletes articles. This is not a marking
9396 command. The article will disappear forever from your life, never to
9397 return.
9398
9399 If N is negative, delete backwards.
9400 If N is nil and articles have been marked with the process mark,
9401 delete these instead.
9402
9403 If `gnus-novice-user' is non-nil you will be asked for
9404 confirmation before the articles are deleted."
9405 (interactive "P")
9406 (unless (gnus-check-backend-function 'request-expire-articles
9407 gnus-newsgroup-name)
9408 (error "The current newsgroup does not support article deletion"))
9409 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9410 (error "Couldn't open server"))
9411 ;; Compute the list of articles to delete.
9412 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9413 (nnmail-expiry-target 'delete)
9414 not-deleted)
9415 (if (and gnus-novice-user
9416 (not (gnus-yes-or-no-p
9417 (format "Do you really want to delete %s forever? "
9418 (if (> (length articles) 1)
9419 (format "these %s articles" (length articles))
9420 "this article")))))
9421 ()
9422 ;; Delete the articles.
9423 (setq not-deleted (gnus-request-expire-articles
9424 articles gnus-newsgroup-name 'force))
9425 (while articles
9426 (gnus-summary-remove-process-mark (car articles))
9427 ;; The backend might not have been able to delete the article
9428 ;; after all.
9429 (unless (memq (car articles) not-deleted)
9430 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9431 (let* ((article (car articles))
9432 (id (mail-header-id (gnus-data-header
9433 (assoc article (gnus-data-list nil))))))
9434 (run-hook-with-args 'gnus-summary-article-delete-hook
9435 'delete id gnus-newsgroup-name nil
9436 nil))
9437 (setq articles (cdr articles)))
9438 (when not-deleted
9439 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9440 (gnus-summary-position-point)
9441 (gnus-set-mode-line 'summary)
9442 not-deleted))
9443
9444 (defun gnus-summary-edit-article (&optional arg)
9445 "Edit the current article.
9446 This will have permanent effect only in mail groups.
9447 If ARG is nil, edit the decoded articles.
9448 If ARG is 1, edit the raw articles.
9449 If ARG is 2, edit the raw articles even in read-only groups.
9450 If ARG is 3, edit the articles with the current handles.
9451 Otherwise, allow editing of articles even in read-only
9452 groups."
9453 (interactive "P")
9454 (let (force raw current-handles)
9455 (cond
9456 ((null arg))
9457 ((eq arg 1)
9458 (setq raw t))
9459 ((eq arg 2)
9460 (setq raw t
9461 force t))
9462 ((eq arg 3)
9463 (setq current-handles
9464 (and (gnus-buffer-live-p gnus-article-buffer)
9465 (with-current-buffer gnus-article-buffer
9466 (prog1
9467 gnus-article-mime-handles
9468 (setq gnus-article-mime-handles nil))))))
9469 (t
9470 (setq force t)))
9471 (when (and raw (not force)
9472 (member gnus-newsgroup-name '("nndraft:delayed"
9473 "nndraft:drafts"
9474 "nndraft:queue")))
9475 (error "Can't edit the raw article in group %s"
9476 gnus-newsgroup-name))
9477 (save-excursion
9478 (set-buffer gnus-summary-buffer)
9479 (let ((mail-parse-charset gnus-newsgroup-charset)
9480 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9481 (gnus-set-global-variables)
9482 (when (and (not force)
9483 (gnus-group-read-only-p))
9484 (error "The current newsgroup does not support article editing"))
9485 (gnus-summary-show-article t)
9486 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9487 (with-current-buffer gnus-article-buffer
9488 (mm-enable-multibyte)))
9489 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9490 (setq raw t))
9491 (gnus-article-edit-article
9492 (if raw 'ignore
9493 `(lambda ()
9494 (let ((mbl mml-buffer-list))
9495 (setq mml-buffer-list nil)
9496 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
9497 (mime-to-mml ,'current-handles))
9498 (let ((mbl1 mml-buffer-list))
9499 (setq mml-buffer-list mbl)
9500 (set (make-local-variable 'mml-buffer-list) mbl1))
9501 (gnus-make-local-hook 'kill-buffer-hook)
9502 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9503 `(lambda (no-highlight)
9504 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9505 (message-options message-options)
9506 (message-options-set-recipient)
9507 (mail-parse-ignored-charsets
9508 ',gnus-newsgroup-ignored-charsets))
9509 ,(if (not raw) '(progn
9510 (mml-to-mime)
9511 (mml-destroy-buffers)
9512 (remove-hook 'kill-buffer-hook
9513 'mml-destroy-buffers t)
9514 (kill-local-variable 'mml-buffer-list)))
9515 (gnus-summary-edit-article-done
9516 ,(or (mail-header-references gnus-current-headers) "")
9517 ,(gnus-group-read-only-p)
9518 ,gnus-summary-buffer no-highlight))))))))
9519
9520 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9521
9522 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9523 no-highlight)
9524 "Make edits to the current article permanent."
9525 (interactive)
9526 (save-excursion
9527 ;; The buffer restriction contains the entire article if it exists.
9528 (when (article-goto-body)
9529 (let ((lines (count-lines (point) (point-max)))
9530 (length (- (point-max) (point)))
9531 (case-fold-search t)
9532 (body (copy-marker (point))))
9533 (goto-char (point-min))
9534 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9535 (delete-region (match-beginning 1) (match-end 1))
9536 (insert (number-to-string length)))
9537 (goto-char (point-min))
9538 (when (re-search-forward
9539 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9540 (delete-region (match-beginning 1) (match-end 1))
9541 (insert (number-to-string length)))
9542 (goto-char (point-min))
9543 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9544 (delete-region (match-beginning 1) (match-end 1))
9545 (insert (number-to-string lines))))))
9546 ;; Replace the article.
9547 (let ((buf (current-buffer)))
9548 (with-temp-buffer
9549 (insert-buffer-substring buf)
9550
9551 (if (and (not read-only)
9552 (not (gnus-request-replace-article
9553 (cdr gnus-article-current) (car gnus-article-current)
9554 (current-buffer) t)))
9555 (error "Couldn't replace article")
9556 ;; Update the summary buffer.
9557 (if (and references
9558 (equal (message-tokenize-header references " ")
9559 (message-tokenize-header
9560 (or (message-fetch-field "references") "") " ")))
9561 ;; We only have to update this line.
9562 (save-excursion
9563 (save-restriction
9564 (message-narrow-to-head)
9565 (let ((head (buffer-string))
9566 header)
9567 (with-temp-buffer
9568 (insert (format "211 %d Article retrieved.\n"
9569 (cdr gnus-article-current)))
9570 (insert head)
9571 (insert ".\n")
9572 (let ((nntp-server-buffer (current-buffer)))
9573 (setq header (car (gnus-get-newsgroup-headers
9574 nil t))))
9575 (save-excursion
9576 (set-buffer gnus-summary-buffer)
9577 (gnus-data-set-header
9578 (gnus-data-find (cdr gnus-article-current))
9579 header)
9580 (gnus-summary-update-article-line
9581 (cdr gnus-article-current) header)
9582 (if (gnus-summary-goto-subject
9583 (cdr gnus-article-current) nil t)
9584 (gnus-summary-update-secondary-mark
9585 (cdr gnus-article-current))))))))
9586 ;; Update threads.
9587 (set-buffer (or buffer gnus-summary-buffer))
9588 (gnus-summary-update-article (cdr gnus-article-current))
9589 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9590 (gnus-summary-update-secondary-mark
9591 (cdr gnus-article-current))))
9592 ;; Prettify the article buffer again.
9593 (unless no-highlight
9594 (save-excursion
9595 (set-buffer gnus-article-buffer)
9596 ;;;!!! Fix this -- article should be rehighlighted.
9597 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9598 (set-buffer gnus-original-article-buffer)
9599 (gnus-request-article
9600 (cdr gnus-article-current)
9601 (car gnus-article-current) (current-buffer))))
9602 ;; Prettify the summary buffer line.
9603 (when (gnus-visual-p 'summary-highlight 'highlight)
9604 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9605
9606 (defun gnus-summary-edit-wash (key)
9607 "Perform editing command KEY in the article buffer."
9608 (interactive
9609 (list
9610 (progn
9611 (message "%s" (concat (this-command-keys) "- "))
9612 (read-char))))
9613 (message "")
9614 (gnus-summary-edit-article)
9615 (execute-kbd-macro (concat (this-command-keys) key))
9616 (gnus-article-edit-done))
9617
9618 ;;; Respooling
9619
9620 (defun gnus-summary-respool-query (&optional silent trace)
9621 "Query where the respool algorithm would put this article."
9622 (interactive)
9623 (let (gnus-mark-article-hook)
9624 (gnus-summary-select-article)
9625 (save-excursion
9626 (set-buffer gnus-original-article-buffer)
9627 (let ((groups (nnmail-article-group 'identity trace)))
9628 (unless silent
9629 (if groups
9630 (message "This message would go to %s"
9631 (mapconcat 'car groups ", "))
9632 (message "This message would go to no groups"))
9633 groups)))))
9634
9635 (defun gnus-summary-respool-trace ()
9636 "Trace where the respool algorithm would put this article.
9637 Display a buffer showing all fancy splitting patterns which matched."
9638 (interactive)
9639 (gnus-summary-respool-query nil t))
9640
9641 ;; Summary marking commands.
9642
9643 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9644 "Mark articles which has the same subject as read, and then select the next.
9645 If UNMARK is positive, remove any kind of mark.
9646 If UNMARK is negative, tick articles."
9647 (interactive "P")
9648 (when unmark
9649 (setq unmark (prefix-numeric-value unmark)))
9650 (let ((count
9651 (gnus-summary-mark-same-subject
9652 (gnus-summary-article-subject) unmark)))
9653 ;; Select next unread article. If auto-select-same mode, should
9654 ;; select the first unread article.
9655 (gnus-summary-next-article t (and gnus-auto-select-same
9656 (gnus-summary-article-subject)))
9657 (gnus-message 7 "%d article%s marked as %s"
9658 count (if (= count 1) " is" "s are")
9659 (if unmark "unread" "read"))))
9660
9661 (defun gnus-summary-kill-same-subject (&optional unmark)
9662 "Mark articles which has the same subject as read.
9663 If UNMARK is positive, remove any kind of mark.
9664 If UNMARK is negative, tick articles."
9665 (interactive "P")
9666 (when unmark
9667 (setq unmark (prefix-numeric-value unmark)))
9668 (let ((count
9669 (gnus-summary-mark-same-subject
9670 (gnus-summary-article-subject) unmark)))
9671 ;; If marked as read, go to next unread subject.
9672 (when (null unmark)
9673 ;; Go to next unread subject.
9674 (gnus-summary-next-subject 1 t))
9675 (gnus-message 7 "%d articles are marked as %s"
9676 count (if unmark "unread" "read"))))
9677
9678 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9679 "Mark articles with same SUBJECT as read, and return marked number.
9680 If optional argument UNMARK is positive, remove any kinds of marks.
9681 If optional argument UNMARK is negative, mark articles as unread instead."
9682 (let ((count 1))
9683 (save-excursion
9684 (cond
9685 ((null unmark) ; Mark as read.
9686 (while (and
9687 (progn
9688 (gnus-summary-mark-article-as-read gnus-killed-mark)
9689 (gnus-summary-show-thread) t)
9690 (gnus-summary-find-subject subject))
9691 (setq count (1+ count))))
9692 ((> unmark 0) ; Tick.
9693 (while (and
9694 (progn
9695 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9696 (gnus-summary-show-thread) t)
9697 (gnus-summary-find-subject subject))
9698 (setq count (1+ count))))
9699 (t ; Mark as unread.
9700 (while (and
9701 (progn
9702 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9703 (gnus-summary-show-thread) t)
9704 (gnus-summary-find-subject subject))
9705 (setq count (1+ count)))))
9706 (gnus-set-mode-line 'summary)
9707 ;; Return the number of marked articles.
9708 count)))
9709
9710 (defun gnus-summary-mark-as-processable (n &optional unmark)
9711 "Set the process mark on the next N articles.
9712 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9713 the process mark instead. The difference between N and the actual
9714 number of articles marked is returned."
9715 (interactive "P")
9716 (if (and (null n) (gnus-region-active-p))
9717 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9718 (setq n (prefix-numeric-value n))
9719 (let ((backward (< n 0))
9720 (n (abs n)))
9721 (while (and
9722 (> n 0)
9723 (if unmark
9724 (gnus-summary-remove-process-mark
9725 (gnus-summary-article-number))
9726 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9727 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9728 (setq n (1- n)))
9729 (when (/= 0 n)
9730 (gnus-message 7 "No more articles"))
9731 (gnus-summary-recenter)
9732 (gnus-summary-position-point)
9733 n)))
9734
9735 (defun gnus-summary-unmark-as-processable (n)
9736 "Remove the process mark from the next N articles.
9737 If N is negative, unmark backward instead. The difference between N and
9738 the actual number of articles unmarked is returned."
9739 (interactive "P")
9740 (gnus-summary-mark-as-processable n t))
9741
9742 (defun gnus-summary-unmark-all-processable ()
9743 "Remove the process mark from all articles."
9744 (interactive)
9745 (save-excursion
9746 (while gnus-newsgroup-processable
9747 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9748 (gnus-summary-position-point))
9749
9750 (defun gnus-summary-add-mark (article type)
9751 "Mark ARTICLE with a mark of TYPE."
9752 (let ((vtype (car (assq type gnus-article-mark-lists)))
9753 var)
9754 (if (not vtype)
9755 (error "No such mark type: %s" type)
9756 (setq var (intern (format "gnus-newsgroup-%s" type)))
9757 (set var (cons article (symbol-value var)))
9758 (if (memq type '(processable cached replied forwarded recent saved))
9759 (gnus-summary-update-secondary-mark article)
9760 ;;; !!! This is bogus. We should find out what primary
9761 ;;; !!! mark we want to set.
9762 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9763
9764 (defun gnus-summary-mark-as-expirable (n)
9765 "Mark N articles forward as expirable.
9766 If N is negative, mark backward instead. The difference between N and
9767 the actual number of articles marked is returned."
9768 (interactive "p")
9769 (gnus-summary-mark-forward n gnus-expirable-mark))
9770
9771 (defun gnus-summary-mark-as-spam (n)
9772 "Mark N articles forward as spam.
9773 If N is negative, mark backward instead. The difference between N and
9774 the actual number of articles marked is returned."
9775 (interactive "p")
9776 (gnus-summary-mark-forward n gnus-spam-mark))
9777
9778 (defun gnus-summary-mark-article-as-replied (article)
9779 "Mark ARTICLE as replied to and update the summary line.
9780 ARTICLE can also be a list of articles."
9781 (interactive (list (gnus-summary-article-number)))
9782 (let ((articles (if (listp article) article (list article))))
9783 (dolist (article articles)
9784 (unless (numberp article)
9785 (error "%s is not a number" article))
9786 (push article gnus-newsgroup-replied)
9787 (let ((buffer-read-only nil))
9788 (when (gnus-summary-goto-subject article nil t)
9789 (gnus-summary-update-secondary-mark article))))))
9790
9791 (defun gnus-summary-mark-article-as-forwarded (article)
9792 "Mark ARTICLE as forwarded and update the summary line.
9793 ARTICLE can also be a list of articles."
9794 (let ((articles (if (listp article) article (list article))))
9795 (dolist (article articles)
9796 (push article gnus-newsgroup-forwarded)
9797 (let ((buffer-read-only nil))
9798 (when (gnus-summary-goto-subject article nil t)
9799 (gnus-summary-update-secondary-mark article))))))
9800
9801 (defun gnus-summary-set-bookmark (article)
9802 "Set a bookmark in current article."
9803 (interactive (list (gnus-summary-article-number)))
9804 (when (or (not (get-buffer gnus-article-buffer))
9805 (not gnus-current-article)
9806 (not gnus-article-current)
9807 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9808 (error "No current article selected"))
9809 ;; Remove old bookmark, if one exists.
9810 (gnus-pull article gnus-newsgroup-bookmarks)
9811 ;; Set the new bookmark, which is on the form
9812 ;; (article-number . line-number-in-body).
9813 (push
9814 (cons article
9815 (save-excursion
9816 (set-buffer gnus-article-buffer)
9817 (count-lines
9818 (min (point)
9819 (save-excursion
9820 (article-goto-body)
9821 (point)))
9822 (point))))
9823 gnus-newsgroup-bookmarks)
9824 (gnus-message 6 "A bookmark has been added to the current article."))
9825
9826 (defun gnus-summary-remove-bookmark (article)
9827 "Remove the bookmark from the current article."
9828 (interactive (list (gnus-summary-article-number)))
9829 ;; Remove old bookmark, if one exists.
9830 (if (not (assq article gnus-newsgroup-bookmarks))
9831 (gnus-message 6 "No bookmark in current article.")
9832 (gnus-pull article gnus-newsgroup-bookmarks)
9833 (gnus-message 6 "Removed bookmark.")))
9834
9835 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9836 (defun gnus-summary-mark-as-dormant (n)
9837 "Mark N articles forward as dormant.
9838 If N is negative, mark backward instead. The difference between N and
9839 the actual number of articles marked is returned."
9840 (interactive "p")
9841 (gnus-summary-mark-forward n gnus-dormant-mark))
9842
9843 (defun gnus-summary-set-process-mark (article)
9844 "Set the process mark on ARTICLE and update the summary line."
9845 (setq gnus-newsgroup-processable
9846 (cons article
9847 (delq article gnus-newsgroup-processable)))
9848 (when (gnus-summary-goto-subject article)
9849 (gnus-summary-show-thread)
9850 (gnus-summary-goto-subject article)
9851 (gnus-summary-update-secondary-mark article)))
9852
9853 (defun gnus-summary-remove-process-mark (article)
9854 "Remove the process mark from ARTICLE and update the summary line."
9855 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9856 (when (gnus-summary-goto-subject article)
9857 (gnus-summary-show-thread)
9858 (gnus-summary-goto-subject article)
9859 (gnus-summary-update-secondary-mark article)))
9860
9861 (defun gnus-summary-set-saved-mark (article)
9862 "Set the process mark on ARTICLE and update the summary line."
9863 (push article gnus-newsgroup-saved)
9864 (when (gnus-summary-goto-subject article)
9865 (gnus-summary-update-secondary-mark article)))
9866
9867 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9868 "Mark N articles as read forwards.
9869 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9870 The difference between N and the actual number of articles marked is
9871 returned.
9872 If NO-EXPIRE, auto-expiry will be inhibited."
9873 (interactive "p")
9874 (gnus-summary-show-thread)
9875 (let ((backward (< n 0))
9876 (gnus-summary-goto-unread
9877 (and gnus-summary-goto-unread
9878 (not (eq gnus-summary-goto-unread 'never))
9879 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9880 gnus-ticked-mark gnus-dormant-mark)))))
9881 (n (abs n))
9882 (mark (or mark gnus-del-mark)))
9883 (while (and (> n 0)
9884 (gnus-summary-mark-article nil mark no-expire)
9885 (zerop (gnus-summary-next-subject
9886 (if backward -1 1)
9887 (and gnus-summary-goto-unread
9888 (not (eq gnus-summary-goto-unread 'never)))
9889 t)))
9890 (setq n (1- n)))
9891 (when (/= 0 n)
9892 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9893 (gnus-summary-recenter)
9894 (gnus-summary-position-point)
9895 (gnus-set-mode-line 'summary)
9896 n))
9897
9898 (defun gnus-summary-mark-article-as-read (mark)
9899 "Mark the current article quickly as read with MARK."
9900 (let ((article (gnus-summary-article-number)))
9901 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9902 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9903 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9904 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9905 (push (cons article mark) gnus-newsgroup-reads)
9906 ;; Possibly remove from cache, if that is used.
9907 (when gnus-use-cache
9908 (gnus-cache-enter-remove-article article))
9909 ;; Allow the backend to change the mark.
9910 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9911 ;; Check for auto-expiry.
9912 (when (and gnus-newsgroup-auto-expire
9913 (memq mark gnus-auto-expirable-marks))
9914 (setq mark gnus-expirable-mark)
9915 ;; Let the backend know about the mark change.
9916 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9917 (push article gnus-newsgroup-expirable))
9918 ;; Set the mark in the buffer.
9919 (gnus-summary-update-mark mark 'unread)
9920 t))
9921
9922 (defun gnus-summary-mark-article-as-unread (mark)
9923 "Mark the current article quickly as unread with MARK."
9924 (let* ((article (gnus-summary-article-number))
9925 (old-mark (gnus-summary-article-mark article)))
9926 ;; Allow the backend to change the mark.
9927 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9928 (if (eq mark old-mark)
9929 t
9930 (if (<= article 0)
9931 (progn
9932 (gnus-error 1 "Can't mark negative article numbers")
9933 nil)
9934 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9935 (setq gnus-newsgroup-spam-marked
9936 (delq article gnus-newsgroup-spam-marked))
9937 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9938 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9939 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9940 (cond ((= mark gnus-ticked-mark)
9941 (setq gnus-newsgroup-marked
9942 (gnus-add-to-sorted-list gnus-newsgroup-marked
9943 article)))
9944 ((= mark gnus-spam-mark)
9945 (setq gnus-newsgroup-spam-marked
9946 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9947 article)))
9948 ((= mark gnus-dormant-mark)
9949 (setq gnus-newsgroup-dormant
9950 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9951 article)))
9952 (t
9953 (setq gnus-newsgroup-unreads
9954 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9955 article))))
9956 (gnus-pull article gnus-newsgroup-reads)
9957
9958 ;; See whether the article is to be put in the cache.
9959 (and gnus-use-cache
9960 (vectorp (gnus-summary-article-header article))
9961 (save-excursion
9962 (gnus-cache-possibly-enter-article
9963 gnus-newsgroup-name article
9964 (= mark gnus-ticked-mark)
9965 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9966
9967 ;; Fix the mark.
9968 (gnus-summary-update-mark mark 'unread)
9969 t))))
9970
9971 (defun gnus-summary-mark-article (&optional article mark no-expire)
9972 "Mark ARTICLE with MARK. MARK can be any character.
9973 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9974 `??' (dormant) and `?E' (expirable).
9975 If MARK is nil, then the default character `?r' is used.
9976 If ARTICLE is nil, then the article on the current line will be
9977 marked.
9978 If NO-EXPIRE, auto-expiry will be inhibited."
9979 ;; The mark might be a string.
9980 (when (stringp mark)
9981 (setq mark (aref mark 0)))
9982 ;; If no mark is given, then we check auto-expiring.
9983 (when (null mark)
9984 (setq mark gnus-del-mark))
9985 (when (and (not no-expire)
9986 gnus-newsgroup-auto-expire
9987 (memq mark gnus-auto-expirable-marks))
9988 (setq mark gnus-expirable-mark))
9989 (let ((article (or article (gnus-summary-article-number)))
9990 (old-mark (gnus-summary-article-mark article)))
9991 ;; Allow the backend to change the mark.
9992 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9993 (if (eq mark old-mark)
9994 t
9995 (unless article
9996 (error "No article on current line"))
9997 (if (not (if (or (= mark gnus-unread-mark)
9998 (= mark gnus-ticked-mark)
9999 (= mark gnus-spam-mark)
10000 (= mark gnus-dormant-mark))
10001 (gnus-mark-article-as-unread article mark)
10002 (gnus-mark-article-as-read article mark)))
10003 t
10004 ;; See whether the article is to be put in the cache.
10005 (and gnus-use-cache
10006 (not (= mark gnus-canceled-mark))
10007 (vectorp (gnus-summary-article-header article))
10008 (save-excursion
10009 (gnus-cache-possibly-enter-article
10010 gnus-newsgroup-name article
10011 (= mark gnus-ticked-mark)
10012 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10013
10014 (when (gnus-summary-goto-subject article nil t)
10015 (let ((buffer-read-only nil))
10016 (gnus-summary-show-thread)
10017 ;; Fix the mark.
10018 (gnus-summary-update-mark mark 'unread)
10019 t))))))
10020
10021 (defun gnus-summary-update-secondary-mark (article)
10022 "Update the secondary (read, process, cache) mark."
10023 (gnus-summary-update-mark
10024 (cond ((memq article gnus-newsgroup-processable)
10025 gnus-process-mark)
10026 ((memq article gnus-newsgroup-cached)
10027 gnus-cached-mark)
10028 ((memq article gnus-newsgroup-replied)
10029 gnus-replied-mark)
10030 ((memq article gnus-newsgroup-forwarded)
10031 gnus-forwarded-mark)
10032 ((memq article gnus-newsgroup-saved)
10033 gnus-saved-mark)
10034 ((memq article gnus-newsgroup-recent)
10035 gnus-recent-mark)
10036 ((memq article gnus-newsgroup-unseen)
10037 gnus-unseen-mark)
10038 (t gnus-no-mark))
10039 'replied)
10040 (when (gnus-visual-p 'summary-highlight 'highlight)
10041 (gnus-run-hooks 'gnus-summary-update-hook))
10042 t)
10043
10044 (defun gnus-summary-update-download-mark (article)
10045 "Update the download mark."
10046 (gnus-summary-update-mark
10047 (cond ((memq article gnus-newsgroup-undownloaded)
10048 gnus-undownloaded-mark)
10049 (gnus-newsgroup-agentized
10050 gnus-downloaded-mark)
10051 (t
10052 gnus-no-mark))
10053 'download)
10054 (gnus-summary-update-line t)
10055 t)
10056
10057 (defun gnus-summary-update-mark (mark type)
10058 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10059 (buffer-read-only nil))
10060 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10061 (when forward
10062 (when (looking-at "\r")
10063 (incf forward))
10064 (when (<= (+ forward (point)) (point-max))
10065 ;; Go to the right position on the line.
10066 (goto-char (+ forward (point)))
10067 ;; Replace the old mark with the new mark.
10068 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10069 ;; Optionally update the marks by some user rule.
10070 (when (eq type 'unread)
10071 (gnus-data-set-mark
10072 (gnus-data-find (gnus-summary-article-number)) mark)
10073 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10074
10075 (defun gnus-mark-article-as-read (article &optional mark)
10076 "Enter ARTICLE in the pertinent lists and remove it from others."
10077 ;; Make the article expirable.
10078 (let ((mark (or mark gnus-del-mark)))
10079 (setq gnus-newsgroup-expirable
10080 (if (= mark gnus-expirable-mark)
10081 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10082 (delq article gnus-newsgroup-expirable)))
10083 ;; Remove from unread and marked lists.
10084 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10085 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10086 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10087 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10088 (push (cons article mark) gnus-newsgroup-reads)
10089 ;; Possibly remove from cache, if that is used.
10090 (when gnus-use-cache
10091 (gnus-cache-enter-remove-article article))
10092 t))
10093
10094 (defun gnus-mark-article-as-unread (article &optional mark)
10095 "Enter ARTICLE in the pertinent lists and remove it from others."
10096 (let ((mark (or mark gnus-ticked-mark)))
10097 (if (<= article 0)
10098 (progn
10099 (gnus-error 1 "Can't mark negative article numbers")
10100 nil)
10101 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10102 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10103 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10104 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10105 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10106
10107 ;; Unsuppress duplicates?
10108 (when gnus-suppress-duplicates
10109 (gnus-dup-unsuppress-article article))
10110
10111 (cond ((= mark gnus-ticked-mark)
10112 (setq gnus-newsgroup-marked
10113 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10114 ((= mark gnus-spam-mark)
10115 (setq gnus-newsgroup-spam-marked
10116 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10117 article)))
10118 ((= mark gnus-dormant-mark)
10119 (setq gnus-newsgroup-dormant
10120 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10121 (t
10122 (setq gnus-newsgroup-unreads
10123 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10124 (gnus-pull article gnus-newsgroup-reads)
10125 t)))
10126
10127 (defalias 'gnus-summary-mark-as-unread-forward
10128 'gnus-summary-tick-article-forward)
10129 (make-obsolete 'gnus-summary-mark-as-unread-forward
10130 'gnus-summary-tick-article-forward)
10131 (defun gnus-summary-tick-article-forward (n)
10132 "Tick N articles forwards.
10133 If N is negative, tick backwards instead.
10134 The difference between N and the number of articles ticked is returned."
10135 (interactive "p")
10136 (gnus-summary-mark-forward n gnus-ticked-mark))
10137
10138 (defalias 'gnus-summary-mark-as-unread-backward
10139 'gnus-summary-tick-article-backward)
10140 (make-obsolete 'gnus-summary-mark-as-unread-backward
10141 'gnus-summary-tick-article-backward)
10142 (defun gnus-summary-tick-article-backward (n)
10143 "Tick N articles backwards.
10144 The difference between N and the number of articles ticked is returned."
10145 (interactive "p")
10146 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10147
10148 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10149 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10150 (defun gnus-summary-tick-article (&optional article clear-mark)
10151 "Mark current article as unread.
10152 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10153 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10154 (interactive)
10155 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10156 gnus-ticked-mark)))
10157
10158 (defun gnus-summary-mark-as-read-forward (n)
10159 "Mark N articles as read forwards.
10160 If N is negative, mark backwards instead.
10161 The difference between N and the actual number of articles marked is
10162 returned."
10163 (interactive "p")
10164 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10165
10166 (defun gnus-summary-mark-as-read-backward (n)
10167 "Mark the N articles as read backwards.
10168 The difference between N and the actual number of articles marked is
10169 returned."
10170 (interactive "p")
10171 (gnus-summary-mark-forward
10172 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10173
10174 (defun gnus-summary-mark-as-read (&optional article mark)
10175 "Mark current article as read.
10176 ARTICLE specifies the article to be marked as read.
10177 MARK specifies a string to be inserted at the beginning of the line."
10178 (gnus-summary-mark-article article mark))
10179
10180 (defun gnus-summary-clear-mark-forward (n)
10181 "Clear marks from N articles forward.
10182 If N is negative, clear backward instead.
10183 The difference between N and the number of marks cleared is returned."
10184 (interactive "p")
10185 (gnus-summary-mark-forward n gnus-unread-mark))
10186
10187 (defun gnus-summary-clear-mark-backward (n)
10188 "Clear marks from N articles backward.
10189 The difference between N and the number of marks cleared is returned."
10190 (interactive "p")
10191 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10192
10193 (defun gnus-summary-mark-unread-as-read ()
10194 "Intended to be used by `gnus-summary-mark-article-hook'."
10195 (when (memq gnus-current-article gnus-newsgroup-unreads)
10196 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10197
10198 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10199 "Intended to be used by `gnus-summary-mark-article-hook'."
10200 (let ((mark (gnus-summary-article-mark)))
10201 (when (or (gnus-unread-mark-p mark)
10202 (gnus-read-mark-p mark))
10203 (gnus-summary-mark-article gnus-current-article
10204 (or new-mark gnus-read-mark)))))
10205
10206 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10207 "Intended to be used by `gnus-summary-mark-article-hook'."
10208 (let ((mark (gnus-summary-article-mark)))
10209 (when (or (gnus-unread-mark-p mark)
10210 (gnus-read-mark-p mark))
10211 (gnus-summary-mark-article (gnus-summary-article-number)
10212 (or new-mark gnus-read-mark)))))
10213
10214 (defun gnus-summary-mark-unread-as-ticked ()
10215 "Intended to be used by `gnus-summary-mark-article-hook'."
10216 (when (memq gnus-current-article gnus-newsgroup-unreads)
10217 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10218
10219 (defun gnus-summary-mark-region-as-read (point mark all)
10220 "Mark all unread articles between point and mark as read.
10221 If given a prefix, mark all articles between point and mark as read,
10222 even ticked and dormant ones."
10223 (interactive "r\nP")
10224 (save-excursion
10225 (let (article)
10226 (goto-char point)
10227 (beginning-of-line)
10228 (while (and
10229 (< (point) mark)
10230 (progn
10231 (when (or all
10232 (memq (setq article (gnus-summary-article-number))
10233 gnus-newsgroup-unreads))
10234 (gnus-summary-mark-article article gnus-del-mark))
10235 t)
10236 (gnus-summary-find-next))))))
10237
10238 (defun gnus-summary-mark-below (score mark)
10239 "Mark articles with score less than SCORE with MARK."
10240 (interactive "P\ncMark: ")
10241 (setq score (if score
10242 (prefix-numeric-value score)
10243 (or gnus-summary-default-score 0)))
10244 (save-excursion
10245 (set-buffer gnus-summary-buffer)
10246 (goto-char (point-min))
10247 (while
10248 (progn
10249 (and (< (gnus-summary-article-score) score)
10250 (gnus-summary-mark-article nil mark))
10251 (gnus-summary-find-next)))))
10252
10253 (defun gnus-summary-kill-below (&optional score)
10254 "Mark articles with score below SCORE as read."
10255 (interactive "P")
10256 (gnus-summary-mark-below score gnus-killed-mark))
10257
10258 (defun gnus-summary-clear-above (&optional score)
10259 "Clear all marks from articles with score above SCORE."
10260 (interactive "P")
10261 (gnus-summary-mark-above score gnus-unread-mark))
10262
10263 (defun gnus-summary-tick-above (&optional score)
10264 "Tick all articles with score above SCORE."
10265 (interactive "P")
10266 (gnus-summary-mark-above score gnus-ticked-mark))
10267
10268 (defun gnus-summary-mark-above (score mark)
10269 "Mark articles with score over SCORE with MARK."
10270 (interactive "P\ncMark: ")
10271 (setq score (if score
10272 (prefix-numeric-value score)
10273 (or gnus-summary-default-score 0)))
10274 (save-excursion
10275 (set-buffer gnus-summary-buffer)
10276 (goto-char (point-min))
10277 (while (and (progn
10278 (when (> (gnus-summary-article-score) score)
10279 (gnus-summary-mark-article nil mark))
10280 t)
10281 (gnus-summary-find-next)))))
10282
10283 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10284 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10285 (defun gnus-summary-limit-include-expunged (&optional no-error)
10286 "Display all the hidden articles that were expunged for low scores."
10287 (interactive)
10288 (let ((buffer-read-only nil))
10289 (let ((scored gnus-newsgroup-scored)
10290 headers h)
10291 (while scored
10292 (unless (gnus-summary-article-header (caar scored))
10293 (and (setq h (gnus-number-to-header (caar scored)))
10294 (< (cdar scored) gnus-summary-expunge-below)
10295 (push h headers)))
10296 (setq scored (cdr scored)))
10297 (if (not headers)
10298 (when (not no-error)
10299 (error "No expunged articles hidden"))
10300 (goto-char (point-min))
10301 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10302 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10303 (mapcar (lambda (x) (push (mail-header-number x)
10304 gnus-newsgroup-limit))
10305 headers)
10306 (gnus-summary-prepare-unthreaded (nreverse headers))
10307 (goto-char (point-min))
10308 (gnus-summary-position-point)
10309 t))))
10310
10311 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10312 "Mark all unread articles in this newsgroup as read.
10313 If prefix argument ALL is non-nil, ticked and dormant articles will
10314 also be marked as read.
10315 If QUIETLY is non-nil, no questions will be asked.
10316
10317 If TO-HERE is non-nil, it should be a point in the buffer. All
10318 articles before (after, if REVERSE is set) this point will be marked
10319 as read.
10320
10321 Note that this function will only catch up the unread article
10322 in the current summary buffer limitation.
10323
10324 The number of articles marked as read is returned."
10325 (interactive "P")
10326 (prog1
10327 (save-excursion
10328 (when (or quietly
10329 (not gnus-interactive-catchup) ;Without confirmation?
10330 gnus-expert-user
10331 (gnus-y-or-n-p
10332 (if all
10333 "Mark absolutely all articles as read? "
10334 "Mark all unread articles as read? ")))
10335 (if (and not-mark
10336 (not gnus-newsgroup-adaptive)
10337 (not gnus-newsgroup-auto-expire)
10338 (not gnus-suppress-duplicates)
10339 (or (not gnus-use-cache)
10340 (eq gnus-use-cache 'passive)))
10341 (progn
10342 (when all
10343 (setq gnus-newsgroup-marked nil
10344 gnus-newsgroup-spam-marked nil
10345 gnus-newsgroup-dormant nil))
10346 (setq gnus-newsgroup-unreads
10347 (gnus-sorted-nunion
10348 (gnus-intersection gnus-newsgroup-unreads
10349 gnus-newsgroup-downloadable)
10350 gnus-newsgroup-unfetched)))
10351 ;; We actually mark all articles as canceled, which we
10352 ;; have to do when using auto-expiry or adaptive scoring.
10353 (gnus-summary-show-all-threads)
10354 (if (and to-here reverse)
10355 (progn
10356 (goto-char to-here)
10357 (gnus-summary-mark-current-read-and-unread-as-read
10358 gnus-catchup-mark)
10359 (while (gnus-summary-find-next (not all))
10360 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10361 (when (gnus-summary-first-subject (not all))
10362 (while (and
10363 (if to-here (< (point) to-here) t)
10364 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10365 (gnus-summary-find-next (not all))))))
10366 (gnus-set-mode-line 'summary))
10367 t))
10368 (gnus-summary-position-point)))
10369
10370 (defun gnus-summary-catchup-to-here (&optional all)
10371 "Mark all unticked articles before the current one as read.
10372 If ALL is non-nil, also mark ticked and dormant articles as read."
10373 (interactive "P")
10374 (save-excursion
10375 (gnus-save-hidden-threads
10376 (let ((beg (point)))
10377 ;; We check that there are unread articles.
10378 (when (or all (gnus-summary-find-prev))
10379 (gnus-summary-catchup all t beg)))))
10380 (gnus-summary-position-point))
10381
10382 (defun gnus-summary-catchup-from-here (&optional all)
10383 "Mark all unticked articles after (and including) the current one as read.
10384 If ALL is non-nil, also mark ticked and dormant articles as read."
10385 (interactive "P")
10386 (save-excursion
10387 (gnus-save-hidden-threads
10388 (let ((beg (point)))
10389 ;; We check that there are unread articles.
10390 (when (or all (gnus-summary-find-next))
10391 (gnus-summary-catchup all t beg nil t)))))
10392 (gnus-summary-position-point))
10393
10394 (defun gnus-summary-catchup-all (&optional quietly)
10395 "Mark all articles in this newsgroup as read.
10396 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10397 instead, which marks only unread articles as read."
10398 (interactive "P")
10399 (gnus-summary-catchup t quietly))
10400
10401 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10402 "Mark all unread articles in this group as read, then exit.
10403 If prefix argument ALL is non-nil, all articles are marked as read.
10404 If QUIETLY is non-nil, no questions will be asked."
10405 (interactive "P")
10406 (when (gnus-summary-catchup all quietly nil 'fast)
10407 ;; Select next newsgroup or exit.
10408 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10409 (eq gnus-auto-select-next 'quietly))
10410 (gnus-summary-next-group nil)
10411 (gnus-summary-exit))))
10412
10413 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10414 "Mark all articles in this newsgroup as read, and then exit.
10415 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10416 instead, which marks only unread articles as read."
10417 (interactive "P")
10418 (gnus-summary-catchup-and-exit t quietly))
10419
10420 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10421 "Mark all articles in this group as read and select the next group.
10422 If given a prefix, mark all articles, unread as well as ticked, as
10423 read."
10424 (interactive "P")
10425 (save-excursion
10426 (gnus-summary-catchup all))
10427 (gnus-summary-next-group))
10428
10429 ;;;
10430 ;;; with article
10431 ;;;
10432
10433 (defmacro gnus-with-article (article &rest forms)
10434 "Select ARTICLE and perform FORMS in the original article buffer.
10435 Then replace the article with the result."
10436 `(progn
10437 ;; We don't want the article to be marked as read.
10438 (let (gnus-mark-article-hook)
10439 (gnus-summary-select-article t t nil ,article))
10440 (set-buffer gnus-original-article-buffer)
10441 ,@forms
10442 (if (not (gnus-check-backend-function
10443 'request-replace-article (car gnus-article-current)))
10444 (gnus-message 5 "Read-only group; not replacing")
10445 (unless (gnus-request-replace-article
10446 ,article (car gnus-article-current)
10447 (current-buffer) t)
10448 (error "Couldn't replace article")))
10449 ;; The cache and backlog have to be flushed somewhat.
10450 (when gnus-keep-backlog
10451 (gnus-backlog-remove-article
10452 (car gnus-article-current) (cdr gnus-article-current)))
10453 (when gnus-use-cache
10454 (gnus-cache-update-article
10455 (car gnus-article-current) (cdr gnus-article-current)))))
10456
10457 (put 'gnus-with-article 'lisp-indent-function 1)
10458 (put 'gnus-with-article 'edebug-form-spec '(form body))
10459
10460 ;; Thread-based commands.
10461
10462 (defun gnus-summary-articles-in-thread (&optional article)
10463 "Return a list of all articles in the current thread.
10464 If ARTICLE is non-nil, return all articles in the thread that starts
10465 with that article."
10466 (let* ((article (or article (gnus-summary-article-number)))
10467 (data (gnus-data-find-list article))
10468 (top-level (gnus-data-level (car data)))
10469 (top-subject
10470 (cond ((null gnus-thread-operation-ignore-subject)
10471 (gnus-simplify-subject-re
10472 (mail-header-subject (gnus-data-header (car data)))))
10473 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10474 (gnus-simplify-subject-fuzzy
10475 (mail-header-subject (gnus-data-header (car data)))))
10476 (t nil)))
10477 (end-point (save-excursion
10478 (if (gnus-summary-go-to-next-thread)
10479 (point) (point-max))))
10480 articles)
10481 (while (and data
10482 (< (gnus-data-pos (car data)) end-point))
10483 (when (or (not top-subject)
10484 (string= top-subject
10485 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10486 (gnus-simplify-subject-fuzzy
10487 (mail-header-subject
10488 (gnus-data-header (car data))))
10489 (gnus-simplify-subject-re
10490 (mail-header-subject
10491 (gnus-data-header (car data)))))))
10492 (push (gnus-data-number (car data)) articles))
10493 (unless (and (setq data (cdr data))
10494 (> (gnus-data-level (car data)) top-level))
10495 (setq data nil)))
10496 ;; Return the list of articles.
10497 (nreverse articles)))
10498
10499 (defun gnus-summary-rethread-current ()
10500 "Rethread the thread the current article is part of."
10501 (interactive)
10502 (let* ((gnus-show-threads t)
10503 (article (gnus-summary-article-number))
10504 (id (mail-header-id (gnus-summary-article-header)))
10505 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10506 (unless id
10507 (error "No article on the current line"))
10508 (gnus-rebuild-thread id)
10509 (gnus-summary-goto-subject article)))
10510
10511 (defun gnus-summary-reparent-thread ()
10512 "Make the current article child of the marked (or previous) article.
10513
10514 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10515 is non-nil or the Subject: of both articles are the same."
10516 (interactive)
10517 (unless (not (gnus-group-read-only-p))
10518 (error "The current newsgroup does not support article editing"))
10519 (unless (<= (length gnus-newsgroup-processable) 1)
10520 (error "No more than one article may be marked"))
10521 (save-window-excursion
10522 (let ((gnus-article-buffer " *reparent*")
10523 (current-article (gnus-summary-article-number))
10524 ;; First grab the marked article, otherwise one line up.
10525 (parent-article (if (not (null gnus-newsgroup-processable))
10526 (car gnus-newsgroup-processable)
10527 (save-excursion
10528 (if (eq (forward-line -1) 0)
10529 (gnus-summary-article-number)
10530 (error "Beginning of summary buffer"))))))
10531 (unless (not (eq current-article parent-article))
10532 (error "An article may not be self-referential"))
10533 (let ((message-id (mail-header-id
10534 (gnus-summary-article-header parent-article))))
10535 (unless (and message-id (not (equal message-id "")))
10536 (error "No message-id in desired parent"))
10537 (gnus-with-article current-article
10538 (save-restriction
10539 (goto-char (point-min))
10540 (message-narrow-to-head)
10541 (if (re-search-forward "^References: " nil t)
10542 (progn
10543 (re-search-forward "^[^ \t]" nil t)
10544 (forward-line -1)
10545 (end-of-line)
10546 (insert " " message-id))
10547 (insert "References: " message-id "\n"))))
10548 (set-buffer gnus-summary-buffer)
10549 (gnus-summary-unmark-all-processable)
10550 (gnus-summary-update-article current-article)
10551 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10552 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10553 (gnus-summary-rethread-current)
10554 (gnus-message 3 "Article %d is now the child of article %d"
10555 current-article parent-article)))))
10556
10557 (defun gnus-summary-toggle-threads (&optional arg)
10558 "Toggle showing conversation threads.
10559 If ARG is positive number, turn showing conversation threads on."
10560 (interactive "P")
10561 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10562 (setq gnus-show-threads
10563 (if (null arg) (not gnus-show-threads)
10564 (> (prefix-numeric-value arg) 0)))
10565 (gnus-summary-prepare)
10566 (gnus-summary-goto-subject current)
10567 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10568 (gnus-summary-position-point)))
10569
10570 (defun gnus-summary-show-all-threads ()
10571 "Show all threads."
10572 (interactive)
10573 (save-excursion
10574 (let ((buffer-read-only nil))
10575 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10576 (gnus-summary-position-point))
10577
10578 (defun gnus-summary-show-thread ()
10579 "Show thread subtrees.
10580 Returns nil if no thread was there to be shown."
10581 (interactive)
10582 (let ((buffer-read-only nil)
10583 (orig (point))
10584 (end (gnus-point-at-eol))
10585 ;; Leave point at bol
10586 (beg (progn (beginning-of-line) (point))))
10587 (prog1
10588 ;; Any hidden lines here?
10589 (search-forward "\r" end t)
10590 (subst-char-in-region beg end ?\^M ?\n t)
10591 (goto-char orig)
10592 (gnus-summary-position-point))))
10593
10594 (defun gnus-summary-maybe-hide-threads ()
10595 "If requested, hide the threads that should be hidden."
10596 (when (and gnus-show-threads
10597 gnus-thread-hide-subtree)
10598 (gnus-summary-hide-all-threads
10599 (if (or (consp gnus-thread-hide-subtree)
10600 (functionp gnus-thread-hide-subtree))
10601 (gnus-make-predicate gnus-thread-hide-subtree)
10602 nil))))
10603
10604 ;;; Hiding predicates.
10605
10606 (defun gnus-article-unread-p (header)
10607 (memq (mail-header-number header) gnus-newsgroup-unreads))
10608
10609 (defun gnus-article-unseen-p (header)
10610 (memq (mail-header-number header) gnus-newsgroup-unseen))
10611
10612 (defun gnus-map-articles (predicate articles)
10613 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10614 (apply 'gnus-or (mapcar predicate
10615 (mapcar 'gnus-summary-article-header articles))))
10616
10617 (defun gnus-summary-hide-all-threads (&optional predicate)
10618 "Hide all thread subtrees.
10619 If PREDICATE is supplied, threads that satisfy this predicate
10620 will not be hidden."
10621 (interactive)
10622 (save-excursion
10623 (goto-char (point-min))
10624 (let ((end nil))
10625 (while (not end)
10626 (when (or (not predicate)
10627 (gnus-map-articles
10628 predicate (gnus-summary-article-children)))
10629 (gnus-summary-hide-thread))
10630 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10631 (gnus-summary-position-point))
10632
10633 (defun gnus-summary-hide-thread ()
10634 "Hide thread subtrees.
10635 If PREDICATE is supplied, threads that satisfy this predicate
10636 will not be hidden.
10637 Returns nil if no threads were there to be hidden."
10638 (interactive)
10639 (let ((buffer-read-only nil)
10640 (start (point))
10641 (article (gnus-summary-article-number)))
10642 (goto-char start)
10643 ;; Go forward until either the buffer ends or the subthread
10644 ;; ends.
10645 (when (and (not (eobp))
10646 (or (zerop (gnus-summary-next-thread 1 t))
10647 (goto-char (point-max))))
10648 (prog1
10649 (if (and (> (point) start)
10650 (search-backward "\n" start t))
10651 (progn
10652 (subst-char-in-region start (point) ?\n ?\^M)
10653 (gnus-summary-goto-subject article))
10654 (goto-char start)
10655 nil)))))
10656
10657 (defun gnus-summary-go-to-next-thread (&optional previous)
10658 "Go to the same level (or less) next thread.
10659 If PREVIOUS is non-nil, go to previous thread instead.
10660 Return the article number moved to, or nil if moving was impossible."
10661 (let ((level (gnus-summary-thread-level))
10662 (way (if previous -1 1))
10663 (beg (point)))
10664 (forward-line way)
10665 (while (and (not (eobp))
10666 (< level (gnus-summary-thread-level)))
10667 (forward-line way))
10668 (if (eobp)
10669 (progn
10670 (goto-char beg)
10671 nil)
10672 (setq beg (point))
10673 (prog1
10674 (gnus-summary-article-number)
10675 (goto-char beg)))))
10676
10677 (defun gnus-summary-next-thread (n &optional silent)
10678 "Go to the same level next N'th thread.
10679 If N is negative, search backward instead.
10680 Returns the difference between N and the number of skips actually
10681 done.
10682
10683 If SILENT, don't output messages."
10684 (interactive "p")
10685 (let ((backward (< n 0))
10686 (n (abs n)))
10687 (while (and (> n 0)
10688 (gnus-summary-go-to-next-thread backward))
10689 (decf n))
10690 (unless silent
10691 (gnus-summary-position-point))
10692 (when (and (not silent) (/= 0 n))
10693 (gnus-message 7 "No more threads"))
10694 n))
10695
10696 (defun gnus-summary-prev-thread (n)
10697 "Go to the same level previous N'th thread.
10698 Returns the difference between N and the number of skips actually
10699 done."
10700 (interactive "p")
10701 (gnus-summary-next-thread (- n)))
10702
10703 (defun gnus-summary-go-down-thread ()
10704 "Go down one level in the current thread."
10705 (let ((children (gnus-summary-article-children)))
10706 (when children
10707 (gnus-summary-goto-subject (car children)))))
10708
10709 (defun gnus-summary-go-up-thread ()
10710 "Go up one level in the current thread."
10711 (let ((parent (gnus-summary-article-parent)))
10712 (when parent
10713 (gnus-summary-goto-subject parent))))
10714
10715 (defun gnus-summary-down-thread (n)
10716 "Go down thread N steps.
10717 If N is negative, go up instead.
10718 Returns the difference between N and how many steps down that were
10719 taken."
10720 (interactive "p")
10721 (let ((up (< n 0))
10722 (n (abs n)))
10723 (while (and (> n 0)
10724 (if up (gnus-summary-go-up-thread)
10725 (gnus-summary-go-down-thread)))
10726 (setq n (1- n)))
10727 (gnus-summary-position-point)
10728 (when (/= 0 n)
10729 (gnus-message 7 "Can't go further"))
10730 n))
10731
10732 (defun gnus-summary-up-thread (n)
10733 "Go up thread N steps.
10734 If N is negative, go down instead.
10735 Returns the difference between N and how many steps down that were
10736 taken."
10737 (interactive "p")
10738 (gnus-summary-down-thread (- n)))
10739
10740 (defun gnus-summary-top-thread ()
10741 "Go to the top of the thread."
10742 (interactive)
10743 (while (gnus-summary-go-up-thread))
10744 (gnus-summary-article-number))
10745
10746 (defun gnus-summary-kill-thread (&optional unmark)
10747 "Mark articles under current thread as read.
10748 If the prefix argument is positive, remove any kinds of marks.
10749 If the prefix argument is negative, tick articles instead."
10750 (interactive "P")
10751 (when unmark
10752 (setq unmark (prefix-numeric-value unmark)))
10753 (let ((articles (gnus-summary-articles-in-thread)))
10754 (save-excursion
10755 ;; Expand the thread.
10756 (gnus-summary-show-thread)
10757 ;; Mark all the articles.
10758 (while articles
10759 (gnus-summary-goto-subject (car articles))
10760 (cond ((null unmark)
10761 (gnus-summary-mark-article-as-read gnus-killed-mark))
10762 ((> unmark 0)
10763 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10764 (t
10765 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10766 (setq articles (cdr articles))))
10767 ;; Hide killed subtrees.
10768 (and (null unmark)
10769 gnus-thread-hide-killed
10770 (gnus-summary-hide-thread))
10771 ;; If marked as read, go to next unread subject.
10772 (when (null unmark)
10773 ;; Go to next unread subject.
10774 (gnus-summary-next-subject 1 t)))
10775 (gnus-set-mode-line 'summary))
10776
10777 ;; Summary sorting commands
10778
10779 (defun gnus-summary-sort-by-number (&optional reverse)
10780 "Sort the summary buffer by article number.
10781 Argument REVERSE means reverse order."
10782 (interactive "P")
10783 (gnus-summary-sort 'number reverse))
10784
10785 (defun gnus-summary-sort-by-random (&optional reverse)
10786 "Randomize the order in the summary buffer.
10787 Argument REVERSE means to randomize in reverse order."
10788 (interactive "P")
10789 (gnus-summary-sort 'random reverse))
10790
10791 (defun gnus-summary-sort-by-author (&optional reverse)
10792 "Sort the summary buffer by author name alphabetically.
10793 If `case-fold-search' is non-nil, case of letters is ignored.
10794 Argument REVERSE means reverse order."
10795 (interactive "P")
10796 (gnus-summary-sort 'author reverse))
10797
10798 (defun gnus-summary-sort-by-subject (&optional reverse)
10799 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10800 If `case-fold-search' is non-nil, case of letters is ignored.
10801 Argument REVERSE means reverse order."
10802 (interactive "P")
10803 (gnus-summary-sort 'subject reverse))
10804
10805 (defun gnus-summary-sort-by-date (&optional reverse)
10806 "Sort the summary buffer by date.
10807 Argument REVERSE means reverse order."
10808 (interactive "P")
10809 (gnus-summary-sort 'date reverse))
10810
10811 (defun gnus-summary-sort-by-score (&optional reverse)
10812 "Sort the summary buffer by score.
10813 Argument REVERSE means reverse order."
10814 (interactive "P")
10815 (gnus-summary-sort 'score reverse))
10816
10817 (defun gnus-summary-sort-by-lines (&optional reverse)
10818 "Sort the summary buffer by the number of lines.
10819 Argument REVERSE means reverse order."
10820 (interactive "P")
10821 (gnus-summary-sort 'lines reverse))
10822
10823 (defun gnus-summary-sort-by-chars (&optional reverse)
10824 "Sort the summary buffer by article length.
10825 Argument REVERSE means reverse order."
10826 (interactive "P")
10827 (gnus-summary-sort 'chars reverse))
10828
10829 (defun gnus-summary-sort-by-original (&optional reverse)
10830 "Sort the summary buffer using the default sorting method.
10831 Argument REVERSE means reverse order."
10832 (interactive "P")
10833 (let* ((buffer-read-only)
10834 (gnus-summary-prepare-hook nil))
10835 ;; We do the sorting by regenerating the threads.
10836 (gnus-summary-prepare)
10837 ;; Hide subthreads if needed.
10838 (gnus-summary-maybe-hide-threads)))
10839
10840 (defun gnus-summary-sort (predicate reverse)
10841 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10842 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10843 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10844 (gnus-thread-sort-functions
10845 (if (not reverse)
10846 thread
10847 `(lambda (t1 t2)
10848 (,thread t2 t1))))
10849 (gnus-sort-gathered-threads-function
10850 gnus-thread-sort-functions)
10851 (gnus-article-sort-functions
10852 (if (not reverse)
10853 article
10854 `(lambda (t1 t2)
10855 (,article t2 t1))))
10856 (buffer-read-only)
10857 (gnus-summary-prepare-hook nil))
10858 ;; We do the sorting by regenerating the threads.
10859 (gnus-summary-prepare)
10860 ;; Hide subthreads if needed.
10861 (gnus-summary-maybe-hide-threads)))
10862
10863 ;; Summary saving commands.
10864
10865 (defun gnus-summary-save-article (&optional n not-saved)
10866 "Save the current article using the default saver function.
10867 If N is a positive number, save the N next articles.
10868 If N is a negative number, save the N previous articles.
10869 If N is nil and any articles have been marked with the process mark,
10870 save those articles instead.
10871 The variable `gnus-default-article-saver' specifies the saver function."
10872 (interactive "P")
10873 (let* ((articles (gnus-summary-work-articles n))
10874 (save-buffer (save-excursion
10875 (nnheader-set-temp-buffer " *Gnus Save*")))
10876 (num (length articles))
10877 header file)
10878 (dolist (article articles)
10879 (setq header (gnus-summary-article-header article))
10880 (if (not (vectorp header))
10881 ;; This is a pseudo-article.
10882 (if (assq 'name header)
10883 (gnus-copy-file (cdr (assq 'name header)))
10884 (gnus-message 1 "Article %d is unsaveable" article))
10885 ;; This is a real article.
10886 (save-window-excursion
10887 (let ((gnus-display-mime-function nil)
10888 (gnus-article-prepare-hook nil))
10889 (gnus-summary-select-article t nil nil article)))
10890 (save-excursion
10891 (set-buffer save-buffer)
10892 (erase-buffer)
10893 (insert-buffer-substring gnus-original-article-buffer))
10894 (setq file (gnus-article-save save-buffer file num))
10895 (gnus-summary-remove-process-mark article)
10896 (unless not-saved
10897 (gnus-summary-set-saved-mark article))))
10898 (gnus-kill-buffer save-buffer)
10899 (gnus-summary-position-point)
10900 (gnus-set-mode-line 'summary)
10901 n))
10902
10903 (defun gnus-summary-pipe-output (&optional arg headers)
10904 "Pipe the current article to a subprocess.
10905 If N is a positive number, pipe the N next articles.
10906 If N is a negative number, pipe the N previous articles.
10907 If N is nil and any articles have been marked with the process mark,
10908 pipe those articles instead.
10909 If HEADERS (the symbolic prefix), include the headers, too."
10910 (interactive (gnus-interactive "P\ny"))
10911 (require 'gnus-art)
10912 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10913 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10914 (gnus-summary-save-article arg t))
10915 (let ((buffer (get-buffer "*Shell Command Output*")))
10916 (when (and buffer
10917 (not (zerop (buffer-size buffer))))
10918 (gnus-configure-windows 'pipe))))
10919
10920 (defun gnus-summary-save-article-mail (&optional arg)
10921 "Append the current article to an mail file.
10922 If N is a positive number, save the N next articles.
10923 If N is a negative number, save the N previous articles.
10924 If N is nil and any articles have been marked with the process mark,
10925 save those articles instead."
10926 (interactive "P")
10927 (require 'gnus-art)
10928 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10929 (gnus-summary-save-article arg)))
10930
10931 (defun gnus-summary-save-article-rmail (&optional arg)
10932 "Append the current article to an rmail file.
10933 If N is a positive number, save the N next articles.
10934 If N is a negative number, save the N previous articles.
10935 If N is nil and any articles have been marked with the process mark,
10936 save those articles instead."
10937 (interactive "P")
10938 (require 'gnus-art)
10939 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10940 (gnus-summary-save-article arg)))
10941
10942 (defun gnus-summary-save-article-file (&optional arg)
10943 "Append the current article to a file.
10944 If N is a positive number, save the N next articles.
10945 If N is a negative number, save the N previous articles.
10946 If N is nil and any articles have been marked with the process mark,
10947 save those articles instead."
10948 (interactive "P")
10949 (require 'gnus-art)
10950 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10951 (gnus-summary-save-article arg)))
10952
10953 (defun gnus-summary-write-article-file (&optional arg)
10954 "Write the current article to a file, deleting the previous file.
10955 If N is a positive number, save the N next articles.
10956 If N is a negative number, save the N previous articles.
10957 If N is nil and any articles have been marked with the process mark,
10958 save those articles instead."
10959 (interactive "P")
10960 (require 'gnus-art)
10961 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10962 (gnus-summary-save-article arg)))
10963
10964 (defun gnus-summary-save-article-body-file (&optional arg)
10965 "Append the current article body to a file.
10966 If N is a positive number, save the N next articles.
10967 If N is a negative number, save the N previous articles.
10968 If N is nil and any articles have been marked with the process mark,
10969 save those articles instead."
10970 (interactive "P")
10971 (require 'gnus-art)
10972 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10973 (gnus-summary-save-article arg)))
10974
10975 (defun gnus-summary-muttprint (&optional arg)
10976 "Print the current article using Muttprint.
10977 If N is a positive number, save the N next articles.
10978 If N is a negative number, save the N previous articles.
10979 If N is nil and any articles have been marked with the process mark,
10980 save those articles instead."
10981 (interactive "P")
10982 (require 'gnus-art)
10983 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10984 (gnus-summary-save-article arg t)))
10985
10986 (defun gnus-summary-pipe-message (program)
10987 "Pipe the current article through PROGRAM."
10988 (interactive "sProgram: ")
10989 (gnus-summary-select-article)
10990 (let ((mail-header-separator ""))
10991 (gnus-eval-in-buffer-window gnus-article-buffer
10992 (save-restriction
10993 (widen)
10994 (let ((start (window-start))
10995 buffer-read-only)
10996 (message-pipe-buffer-body program)
10997 (set-window-start (get-buffer-window (current-buffer)) start))))))
10998
10999 (defun gnus-get-split-value (methods)
11000 "Return a value based on the split METHODS."
11001 (let (split-name method result match)
11002 (when methods
11003 (save-excursion
11004 (set-buffer gnus-original-article-buffer)
11005 (save-restriction
11006 (nnheader-narrow-to-headers)
11007 (while (and methods (not split-name))
11008 (goto-char (point-min))
11009 (setq method (pop methods))
11010 (setq match (car method))
11011 (when (cond
11012 ((stringp match)
11013 ;; Regular expression.
11014 (ignore-errors
11015 (re-search-forward match nil t)))
11016 ((functionp match)
11017 ;; Function.
11018 (save-restriction
11019 (widen)
11020 (setq result (funcall match gnus-newsgroup-name))))
11021 ((consp match)
11022 ;; Form.
11023 (save-restriction
11024 (widen)
11025 (setq result (eval match)))))
11026 (setq split-name (cdr method))
11027 (cond ((stringp result)
11028 (push (expand-file-name
11029 result gnus-article-save-directory)
11030 split-name))
11031 ((consp result)
11032 (setq split-name (append result split-name)))))))))
11033 (nreverse split-name)))
11034
11035 (defun gnus-valid-move-group-p (group)
11036 (and (boundp group)
11037 (symbol-name group)
11038 (symbol-value group)
11039 (gnus-get-function (gnus-find-method-for-group
11040 (symbol-name group)) 'request-accept-article t)))
11041
11042 (defun gnus-read-move-group-name (prompt default articles prefix)
11043 "Read a group name."
11044 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11045 (minibuffer-confirm-incomplete nil) ; XEmacs
11046 (prom
11047 (format "%s %s to:"
11048 prompt
11049 (if (> (length articles) 1)
11050 (format "these %d articles" (length articles))
11051 "this article")))
11052 (to-newsgroup
11053 (cond
11054 ((null split-name)
11055 (gnus-completing-read-with-default
11056 default prom
11057 gnus-active-hashtb
11058 'gnus-valid-move-group-p
11059 nil prefix
11060 'gnus-group-history))
11061 ((= 1 (length split-name))
11062 (gnus-completing-read-with-default
11063 (car split-name) prom
11064 gnus-active-hashtb
11065 'gnus-valid-move-group-p
11066 nil nil
11067 'gnus-group-history))
11068 (t
11069 (gnus-completing-read-with-default
11070 nil prom
11071 (mapcar (lambda (el) (list el))
11072 (nreverse split-name))
11073 nil nil nil
11074 'gnus-group-history))))
11075 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11076 (when to-newsgroup
11077 (if (or (string= to-newsgroup "")
11078 (string= to-newsgroup prefix))
11079 (setq to-newsgroup default))
11080 (unless to-newsgroup
11081 (error "No group name entered"))
11082 (or (gnus-active to-newsgroup)
11083 (gnus-activate-group to-newsgroup nil nil to-method)
11084 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11085 to-newsgroup))
11086 (or (and (gnus-request-create-group to-newsgroup to-method)
11087 (gnus-activate-group
11088 to-newsgroup nil nil to-method)
11089 (gnus-subscribe-group to-newsgroup))
11090 (error "Couldn't create group %s" to-newsgroup)))
11091 (error "No such group: %s" to-newsgroup)))
11092 to-newsgroup))
11093
11094 (defun gnus-summary-save-parts (type dir n &optional reverse)
11095 "Save parts matching TYPE to DIR.
11096 If REVERSE, save parts that do not match TYPE."
11097 (interactive
11098 (list (read-string "Save parts of type: "
11099 (or (car gnus-summary-save-parts-type-history)
11100 gnus-summary-save-parts-default-mime)
11101 'gnus-summary-save-parts-type-history)
11102 (setq gnus-summary-save-parts-last-directory
11103 (read-file-name "Save to directory: "
11104 gnus-summary-save-parts-last-directory
11105 nil t))
11106 current-prefix-arg))
11107 (gnus-summary-iterate n
11108 (let ((gnus-display-mime-function nil)
11109 (gnus-inhibit-treatment t))
11110 (gnus-summary-select-article))
11111 (save-excursion
11112 (set-buffer gnus-article-buffer)
11113 (let ((handles (or gnus-article-mime-handles
11114 (mm-dissect-buffer nil gnus-article-loose-mime)
11115 (and gnus-article-emulate-mime
11116 (mm-uu-dissect)))))
11117 (when handles
11118 (gnus-summary-save-parts-1 type dir handles reverse)
11119 (unless gnus-article-mime-handles ;; Don't destroy this case.
11120 (mm-destroy-parts handles)))))))
11121
11122 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11123 (if (stringp (car handle))
11124 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11125 (cdr handle))
11126 (when (if reverse
11127 (not (string-match type (mm-handle-media-type handle)))
11128 (string-match type (mm-handle-media-type handle)))
11129 (let ((file (expand-file-name
11130 (gnus-map-function
11131 mm-file-name-rewrite-functions
11132 (file-name-nondirectory
11133 (or
11134 (mail-content-type-get
11135 (mm-handle-disposition handle) 'filename)
11136 (mail-content-type-get
11137 (mm-handle-type handle) 'name)
11138 (concat gnus-newsgroup-name
11139 "." (number-to-string
11140 (cdr gnus-article-current))))))
11141 dir)))
11142 (unless (file-exists-p file)
11143 (mm-save-part-to-file handle file))))))
11144
11145 ;; Summary extract commands
11146
11147 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11148 (let ((buffer-read-only nil)
11149 (article (gnus-summary-article-number))
11150 after-article b e)
11151 (unless (gnus-summary-goto-subject article)
11152 (error "No such article: %d" article))
11153 (gnus-summary-position-point)
11154 ;; If all commands are to be bunched up on one line, we collect
11155 ;; them here.
11156 (unless gnus-view-pseudos-separately
11157 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11158 files action)
11159 (while ps
11160 (setq action (cdr (assq 'action (car ps))))
11161 (setq files (list (cdr (assq 'name (car ps)))))
11162 (while (and ps (cdr ps)
11163 (string= (or action "1")
11164 (or (cdr (assq 'action (cadr ps))) "2")))
11165 (push (cdr (assq 'name (cadr ps))) files)
11166 (setcdr ps (cddr ps)))
11167 (when files
11168 (when (not (string-match "%s" action))
11169 (push " " files))
11170 (push " " files)
11171 (when (assq 'execute (car ps))
11172 (setcdr (assq 'execute (car ps))
11173 (funcall (if (string-match "%s" action)
11174 'format 'concat)
11175 action
11176 (mapconcat
11177 (lambda (f)
11178 (if (equal f " ")
11179 f
11180 (mm-quote-arg f)))
11181 files " ")))))
11182 (setq ps (cdr ps)))))
11183 (if (and gnus-view-pseudos (not not-view))
11184 (while pslist
11185 (when (assq 'execute (car pslist))
11186 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11187 (eq gnus-view-pseudos 'not-confirm)))
11188 (setq pslist (cdr pslist)))
11189 (save-excursion
11190 (while pslist
11191 (setq after-article (or (cdr (assq 'article (car pslist)))
11192 (gnus-summary-article-number)))
11193 (gnus-summary-goto-subject after-article)
11194 (forward-line 1)
11195 (setq b (point))
11196 (insert " " (file-name-nondirectory
11197 (cdr (assq 'name (car pslist))))
11198 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11199 (setq e (point))
11200 (forward-line -1) ; back to `b'
11201 (gnus-add-text-properties
11202 b (1- e) (list 'gnus-number gnus-reffed-article-number
11203 gnus-mouse-face-prop gnus-mouse-face))
11204 (gnus-data-enter
11205 after-article gnus-reffed-article-number
11206 gnus-unread-mark b (car pslist) 0 (- e b))
11207 (setq gnus-newsgroup-unreads
11208 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11209 gnus-reffed-article-number))
11210 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11211 (setq pslist (cdr pslist)))))))
11212
11213 (defun gnus-pseudos< (p1 p2)
11214 (let ((c1 (cdr (assq 'action p1)))
11215 (c2 (cdr (assq 'action p2))))
11216 (and c1 c2 (string< c1 c2))))
11217
11218 (defun gnus-request-pseudo-article (props)
11219 (cond ((assq 'execute props)
11220 (gnus-execute-command (cdr (assq 'execute props)))))
11221 (let ((gnus-current-article (gnus-summary-article-number)))
11222 (gnus-run-hooks 'gnus-mark-article-hook)))
11223
11224 (defun gnus-execute-command (command &optional automatic)
11225 (save-excursion
11226 (gnus-article-setup-buffer)
11227 (set-buffer gnus-article-buffer)
11228 (setq buffer-read-only nil)
11229 (let ((command (if automatic command
11230 (read-string "Command: " (cons command 0)))))
11231 (erase-buffer)
11232 (insert "$ " command "\n\n")
11233 (if gnus-view-pseudo-asynchronously
11234 (start-process "gnus-execute" (current-buffer) shell-file-name
11235 shell-command-switch command)
11236 (call-process shell-file-name nil t nil
11237 shell-command-switch command)))))
11238
11239 ;; Summary kill commands.
11240
11241 (defun gnus-summary-edit-global-kill (article)
11242 "Edit the \"global\" kill file."
11243 (interactive (list (gnus-summary-article-number)))
11244 (gnus-group-edit-global-kill article))
11245
11246 (defun gnus-summary-edit-local-kill ()
11247 "Edit a local kill file applied to the current newsgroup."
11248 (interactive)
11249 (setq gnus-current-headers (gnus-summary-article-header))
11250 (gnus-group-edit-local-kill
11251 (gnus-summary-article-number) gnus-newsgroup-name))
11252
11253 ;;; Header reading.
11254
11255 (defun gnus-read-header (id &optional header)
11256 "Read the headers of article ID and enter them into the Gnus system."
11257 (let ((group gnus-newsgroup-name)
11258 (gnus-override-method
11259 (or
11260 gnus-override-method
11261 (and (gnus-news-group-p gnus-newsgroup-name)
11262 (car (gnus-refer-article-methods)))))
11263 where)
11264 ;; First we check to see whether the header in question is already
11265 ;; fetched.
11266 (if (stringp id)
11267 ;; This is a Message-ID.
11268 (setq header (or header (gnus-id-to-header id)))
11269 ;; This is an article number.
11270 (setq header (or header (gnus-summary-article-header id))))
11271 (if (and header
11272 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11273 ;; We have found the header.
11274 header
11275 ;; We have to really fetch the header to this article.
11276 (save-excursion
11277 (set-buffer nntp-server-buffer)
11278 (when (setq where (gnus-request-head id group))
11279 (nnheader-fold-continuation-lines)
11280 (goto-char (point-max))
11281 (insert ".\n")
11282 (goto-char (point-min))
11283 (insert "211 ")
11284 (princ (cond
11285 ((numberp id) id)
11286 ((cdr where) (cdr where))
11287 (header (mail-header-number header))
11288 (t gnus-reffed-article-number))
11289 (current-buffer))
11290 (insert " Article retrieved.\n"))
11291 (if (or (not where)
11292 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11293 () ; Malformed head.
11294 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11295 (when (and (stringp id)
11296 (not (string= (gnus-group-real-name group)
11297 (car where))))
11298 ;; If we fetched by Message-ID and the article came
11299 ;; from a different group, we fudge some bogus article
11300 ;; numbers for this article.
11301 (mail-header-set-number header gnus-reffed-article-number))
11302 (save-excursion
11303 (set-buffer gnus-summary-buffer)
11304 (decf gnus-reffed-article-number)
11305 (gnus-remove-header (mail-header-number header))
11306 (push header gnus-newsgroup-headers)
11307 (setq gnus-current-headers header)
11308 (push (mail-header-number header) gnus-newsgroup-limit)))
11309 header)))))
11310
11311 (defun gnus-remove-header (number)
11312 "Remove header NUMBER from `gnus-newsgroup-headers'."
11313 (if (and gnus-newsgroup-headers
11314 (= number (mail-header-number (car gnus-newsgroup-headers))))
11315 (pop gnus-newsgroup-headers)
11316 (let ((headers gnus-newsgroup-headers))
11317 (while (and (cdr headers)
11318 (not (= number (mail-header-number (cadr headers)))))
11319 (pop headers))
11320 (when (cdr headers)
11321 (setcdr headers (cddr headers))))))
11322
11323 ;;;
11324 ;;; summary highlights
11325 ;;;
11326
11327 (defun gnus-highlight-selected-summary ()
11328 "Highlight selected article in summary buffer."
11329 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11330 (when gnus-summary-selected-face
11331 (save-excursion
11332 (let* ((beg (gnus-point-at-bol))
11333 (end (gnus-point-at-eol))
11334 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11335 (from (if (get-text-property beg gnus-mouse-face-prop)
11336 beg
11337 (or (next-single-property-change
11338 beg gnus-mouse-face-prop nil end)
11339 beg)))
11340 (to
11341 (if (= from end)
11342 (- from 2)
11343 (or (next-single-property-change
11344 from gnus-mouse-face-prop nil end)
11345 end))))
11346 ;; If no mouse-face prop on line we will have to = from = end,
11347 ;; so we highlight the entire line instead.
11348 (when (= (+ to 2) from)
11349 (setq from beg)
11350 (setq to end))
11351 (if gnus-newsgroup-selected-overlay
11352 ;; Move old overlay.
11353 (gnus-move-overlay
11354 gnus-newsgroup-selected-overlay from to (current-buffer))
11355 ;; Create new overlay.
11356 (gnus-overlay-put
11357 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11358 'face gnus-summary-selected-face))))))
11359
11360 (defvar gnus-summary-highlight-line-cached nil)
11361 (defvar gnus-summary-highlight-line-trigger nil)
11362
11363 (defun gnus-summary-highlight-line-0 ()
11364 (if (and (eq gnus-summary-highlight-line-trigger
11365 gnus-summary-highlight)
11366 gnus-summary-highlight-line-cached)
11367 gnus-summary-highlight-line-cached
11368 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11369 gnus-summary-highlight-line-cached
11370 (let* ((cond (list 'cond))
11371 (c cond)
11372 (list gnus-summary-highlight))
11373 (while list
11374 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11375 nil))
11376 (setq c (cdr c)
11377 list (cdr list)))
11378 (gnus-byte-compile (list 'lambda nil cond))))))
11379
11380 (defun gnus-summary-highlight-line ()
11381 "Highlight current line according to `gnus-summary-highlight'."
11382 (let* ((beg (gnus-point-at-bol))
11383 (article (or (gnus-summary-article-number) gnus-current-article))
11384 (score (or (cdr (assq article
11385 gnus-newsgroup-scored))
11386 gnus-summary-default-score 0))
11387 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11388 (inhibit-read-only t)
11389 (default gnus-summary-default-score)
11390 (default-high gnus-summary-default-high-score)
11391 (default-low gnus-summary-default-low-score)
11392 (uncached (and gnus-summary-use-undownloaded-faces
11393 (memq article gnus-newsgroup-undownloaded)
11394 (not (memq article gnus-newsgroup-cached)))))
11395 (let ((face (funcall (gnus-summary-highlight-line-0))))
11396 (unless (eq face (get-text-property beg 'face))
11397 (gnus-put-text-property-excluding-characters-with-faces
11398 beg (gnus-point-at-eol) 'face
11399 (setq face (if (boundp face) (symbol-value face) face)))
11400 (when gnus-summary-highlight-line-function
11401 (funcall gnus-summary-highlight-line-function article face))))))
11402
11403 (defun gnus-update-read-articles (group unread &optional compute)
11404 "Update the list of read articles in GROUP.
11405 UNREAD is a sorted list."
11406 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11407 (entry (gnus-gethash group gnus-newsrc-hashtb))
11408 (info (nth 2 entry))
11409 (prev 1)
11410 read)
11411 (if (or (not info) (not active))
11412 ;; There is no info on this group if it was, in fact,
11413 ;; killed. Gnus stores no information on killed groups, so
11414 ;; there's nothing to be done.
11415 ;; One could store the information somewhere temporarily,
11416 ;; perhaps... Hmmm...
11417 ()
11418 ;; Remove any negative articles numbers.
11419 (while (and unread (< (car unread) 0))
11420 (setq unread (cdr unread)))
11421 ;; Remove any expired article numbers
11422 (while (and unread (< (car unread) (car active)))
11423 (setq unread (cdr unread)))
11424 ;; Compute the ranges of read articles by looking at the list of
11425 ;; unread articles.
11426 (while unread
11427 (when (/= (car unread) prev)
11428 (push (if (= prev (1- (car unread))) prev
11429 (cons prev (1- (car unread))))
11430 read))
11431 (setq prev (1+ (car unread)))
11432 (setq unread (cdr unread)))
11433 (when (<= prev (cdr active))
11434 (push (cons prev (cdr active)) read))
11435 (setq read (if (> (length read) 1) (nreverse read) read))
11436 (if compute
11437 read
11438 (save-excursion
11439 (let (setmarkundo)
11440 ;; Propagate the read marks to the backend.
11441 (when (gnus-check-backend-function 'request-set-mark group)
11442 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11443 (add (gnus-remove-from-range read (gnus-info-read info))))
11444 (when (or add del)
11445 (unless (gnus-check-group group)
11446 (error "Can't open server for %s" group))
11447 (gnus-request-set-mark
11448 group (delq nil (list (if add (list add 'add '(read)))
11449 (if del (list del 'del '(read))))))
11450 (setq setmarkundo
11451 `(gnus-request-set-mark
11452 ,group
11453 ',(delq nil (list
11454 (if del (list del 'add '(read)))
11455 (if add (list add 'del '(read))))))))))
11456 (set-buffer gnus-group-buffer)
11457 (gnus-undo-register
11458 `(progn
11459 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11460 (gnus-info-set-read ',info ',(gnus-info-read info))
11461 (gnus-get-unread-articles-in-group ',info
11462 (gnus-active ,group))
11463 (gnus-group-update-group ,group t)
11464 ,setmarkundo))))
11465 ;; Enter this list into the group info.
11466 (gnus-info-set-read info read)
11467 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11468 (gnus-get-unread-articles-in-group info (gnus-active group))
11469 t))))
11470
11471 (defun gnus-offer-save-summaries ()
11472 "Offer to save all active summary buffers."
11473 (let (buffers)
11474 ;; Go through all buffers and find all summaries.
11475 (dolist (buffer (buffer-list))
11476 (when (and (setq buffer (buffer-name buffer))
11477 (string-match "Summary" buffer)
11478 (save-excursion
11479 (set-buffer buffer)
11480 ;; We check that this is, indeed, a summary buffer.
11481 (and (eq major-mode 'gnus-summary-mode)
11482 ;; Also make sure this isn't bogus.
11483 gnus-newsgroup-prepared
11484 ;; Also make sure that this isn't a
11485 ;; dead summary buffer.
11486 (not gnus-dead-summary-mode))))
11487 (push buffer buffers)))
11488 ;; Go through all these summary buffers and offer to save them.
11489 (when buffers
11490 (save-excursion
11491 (map-y-or-n-p
11492 "Update summary buffer %s? "
11493 (lambda (buf)
11494 (switch-to-buffer buf)
11495 (gnus-summary-exit))
11496 buffers)))))
11497
11498 (defun gnus-summary-setup-default-charset ()
11499 "Setup newsgroup default charset."
11500 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11501 (setq gnus-newsgroup-charset nil)
11502 (let* ((ignored-charsets
11503 (or gnus-newsgroup-ephemeral-ignored-charsets
11504 (append
11505 (and gnus-newsgroup-name
11506 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11507 gnus-newsgroup-ignored-charsets))))
11508 (setq gnus-newsgroup-charset
11509 (or gnus-newsgroup-ephemeral-charset
11510 (and gnus-newsgroup-name
11511 (gnus-parameter-charset gnus-newsgroup-name))
11512 gnus-default-charset))
11513 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11514 ignored-charsets))))
11515
11516 ;;;
11517 ;;; Mime Commands
11518 ;;;
11519
11520 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11521 "Display the current article buffer fully MIME-buttonized.
11522 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11523 treated as multipart/mixed."
11524 (interactive "P")
11525 (require 'gnus-art)
11526 (let ((gnus-unbuttonized-mime-types nil)
11527 (gnus-mime-display-multipart-as-mixed show-all-parts))
11528 (gnus-summary-show-article)))
11529
11530 (defun gnus-summary-repair-multipart (article)
11531 "Add a Content-Type header to a multipart article without one."
11532 (interactive (list (gnus-summary-article-number)))
11533 (gnus-with-article article
11534 (message-narrow-to-head)
11535 (message-remove-header "Mime-Version")
11536 (goto-char (point-max))
11537 (insert "Mime-Version: 1.0\n")
11538 (widen)
11539 (when (search-forward "\n--" nil t)
11540 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11541 (message-narrow-to-head)
11542 (message-remove-header "Content-Type")
11543 (goto-char (point-max))
11544 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11545 separator))
11546 (widen))))
11547 (let (gnus-mark-article-hook)
11548 (gnus-summary-select-article t t nil article)))
11549
11550 (defun gnus-summary-toggle-display-buttonized ()
11551 "Toggle the buttonizing of the article buffer."
11552 (interactive)
11553 (require 'gnus-art)
11554 (if (setq gnus-inhibit-mime-unbuttonizing
11555 (not gnus-inhibit-mime-unbuttonizing))
11556 (let ((gnus-unbuttonized-mime-types nil))
11557 (gnus-summary-show-article))
11558 (gnus-summary-show-article)))
11559
11560 ;;;
11561 ;;; Generic summary marking commands
11562 ;;;
11563
11564 (defvar gnus-summary-marking-alist
11565 '((read gnus-del-mark "d")
11566 (unread gnus-unread-mark "u")
11567 (ticked gnus-ticked-mark "!")
11568 (dormant gnus-dormant-mark "?")
11569 (expirable gnus-expirable-mark "e"))
11570 "An alist of names/marks/keystrokes.")
11571
11572 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11573 (defvar gnus-summary-mark-map)
11574
11575 (defun gnus-summary-make-all-marking-commands ()
11576 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11577 (dolist (elem gnus-summary-marking-alist)
11578 (apply 'gnus-summary-make-marking-command elem)))
11579
11580 (defun gnus-summary-make-marking-command (name mark keystroke)
11581 (let ((map (make-sparse-keymap)))
11582 (define-key gnus-summary-generic-mark-map keystroke map)
11583 (dolist (lway `((next "next" next nil "n")
11584 (next-unread "next unread" next t "N")
11585 (prev "previous" prev nil "p")
11586 (prev-unread "previous unread" prev t "P")
11587 (nomove "" nil nil ,keystroke)))
11588 (let ((func (gnus-summary-make-marking-command-1
11589 mark (car lway) lway name)))
11590 (setq func (eval func))
11591 (define-key map (nth 4 lway) func)))))
11592
11593 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11594 `(defun ,(intern
11595 (format "gnus-summary-put-mark-as-%s%s"
11596 name (if (eq way 'nomove)
11597 ""
11598 (concat "-" (symbol-name way)))))
11599 (n)
11600 ,(format
11601 "Mark the current article as %s%s.
11602 If N, the prefix, then repeat N times.
11603 If N is negative, move in reverse order.
11604 The difference between N and the actual number of articles marked is
11605 returned."
11606 name (cadr lway))
11607 (interactive "p")
11608 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11609
11610 (defun gnus-summary-generic-mark (n mark move unread)
11611 "Mark N articles with MARK."
11612 (unless (eq major-mode 'gnus-summary-mode)
11613 (error "This command can only be used in the summary buffer"))
11614 (gnus-summary-show-thread)
11615 (let ((nummove
11616 (cond
11617 ((eq move 'next) 1)
11618 ((eq move 'prev) -1)
11619 (t 0))))
11620 (if (zerop nummove)
11621 (setq n 1)
11622 (when (< n 0)
11623 (setq n (abs n)
11624 nummove (* -1 nummove))))
11625 (while (and (> n 0)
11626 (gnus-summary-mark-article nil mark)
11627 (zerop (gnus-summary-next-subject nummove unread t)))
11628 (setq n (1- n)))
11629 (when (/= 0 n)
11630 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11631 (gnus-summary-recenter)
11632 (gnus-summary-position-point)
11633 (gnus-set-mode-line 'summary)
11634 n))
11635
11636 (defun gnus-summary-insert-articles (articles)
11637 (when (setq articles
11638 (gnus-sorted-difference articles
11639 (mapcar (lambda (h)
11640 (mail-header-number h))
11641 gnus-newsgroup-headers)))
11642 (setq gnus-newsgroup-headers
11643 (gnus-merge 'list
11644 gnus-newsgroup-headers
11645 (gnus-fetch-headers articles)
11646 'gnus-article-sort-by-number))
11647 ;; Suppress duplicates?
11648 (when gnus-suppress-duplicates
11649 (gnus-dup-suppress-articles))
11650
11651 ;; We might want to build some more threads first.
11652 (when (and gnus-fetch-old-headers
11653 (eq gnus-headers-retrieved-by 'nov))
11654 (if (eq gnus-fetch-old-headers 'invisible)
11655 (gnus-build-all-threads)
11656 (gnus-build-old-threads)))
11657 ;; Let the Gnus agent mark articles as read.
11658 (when gnus-agent
11659 (gnus-agent-get-undownloaded-list))
11660 ;; Remove list identifiers from subject
11661 (when gnus-list-identifiers
11662 (gnus-summary-remove-list-identifiers))
11663 ;; First and last article in this newsgroup.
11664 (when gnus-newsgroup-headers
11665 (setq gnus-newsgroup-begin
11666 (mail-header-number (car gnus-newsgroup-headers))
11667 gnus-newsgroup-end
11668 (mail-header-number
11669 (gnus-last-element gnus-newsgroup-headers))))
11670 (when gnus-use-scoring
11671 (gnus-possibly-score-headers))))
11672
11673 (defun gnus-summary-insert-old-articles (&optional all)
11674 "Insert all old articles in this group.
11675 If ALL is non-nil, already read articles become readable.
11676 If ALL is a number, fetch this number of articles."
11677 (interactive "P")
11678 (prog1
11679 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11680 older len)
11681 (setq older
11682 ;; Some nntp servers lie about their active range. When
11683 ;; this happens, the active range can be in the millions.
11684 ;; Use a compressed range to avoid creating a huge list.
11685 (gnus-range-difference (list gnus-newsgroup-active) old))
11686 (setq len (gnus-range-length older))
11687 (cond
11688 ((null older) nil)
11689 ((numberp all)
11690 (if (< all len)
11691 (let ((older-range (nreverse older)))
11692 (setq older nil)
11693
11694 (while (> all 0)
11695 (let* ((r (pop older-range))
11696 (min (if (numberp r) r (car r)))
11697 (max (if (numberp r) r (cdr r))))
11698 (while (and (<= min max)
11699 (> all 0))
11700 (push max older)
11701 (setq all (1- all)
11702 max (1- max))))))
11703 (setq older (gnus-uncompress-range older))))
11704 (all
11705 (setq older (gnus-uncompress-range older)))
11706 (t
11707 (when (and (numberp gnus-large-newsgroup)
11708 (> len gnus-large-newsgroup))
11709 (let* ((cursor-in-echo-area nil)
11710 (initial (gnus-parameter-large-newsgroup-initial
11711 gnus-newsgroup-name))
11712 (input
11713 (read-string
11714 (format
11715 "How many articles from %s (%s %d): "
11716 (gnus-limit-string
11717 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11718 (if initial "max" "default")
11719 len)
11720 (if initial
11721 (cons (number-to-string initial)
11722 0)))))
11723 (unless (string-match "^[ \t]*$" input)
11724 (setq all (string-to-number input))
11725 (if (< all len)
11726 (let ((older-range (nreverse older)))
11727 (setq older nil)
11728
11729 (while (> all 0)
11730 (let* ((r (pop older-range))
11731 (min (if (numberp r) r (car r)))
11732 (max (if (numberp r) r (cdr r))))
11733 (while (and (<= min max)
11734 (> all 0))
11735 (push max older)
11736 (setq all (1- all)
11737 max (1- max))))))))))
11738 (setq older (gnus-uncompress-range older))))
11739 (if (not older)
11740 (message "No old news.")
11741 (gnus-summary-insert-articles older)
11742 (gnus-summary-limit (gnus-sorted-nunion old older))))
11743 (gnus-summary-position-point)))
11744
11745 (defun gnus-summary-insert-new-articles ()
11746 "Insert all new articles in this group."
11747 (interactive)
11748 (prog1
11749 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11750 (old-active gnus-newsgroup-active)
11751 (nnmail-fetched-sources (list t))
11752 i new)
11753 (setq gnus-newsgroup-active
11754 (gnus-activate-group gnus-newsgroup-name 'scan))
11755 (setq i (cdr gnus-newsgroup-active))
11756 (while (> i (cdr old-active))
11757 (push i new)
11758 (decf i))
11759 (if (not new)
11760 (message "No gnus is bad news.")
11761 (gnus-summary-insert-articles new)
11762 (setq gnus-newsgroup-unreads
11763 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11764 (gnus-summary-limit (gnus-sorted-nunion old new))))
11765 (gnus-summary-position-point)))
11766
11767 (gnus-summary-make-all-marking-commands)
11768
11769 (gnus-ems-redefine)
11770
11771 (provide 'gnus-sum)
11772
11773 (run-hooks 'gnus-sum-load-hook)
11774
11775 ;; Local Variables:
11776 ;; coding: iso-8859-1
11777 ;; End:
11778
11779 ;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11780 ;;; gnus-sum.el ends here