*** empty log message ***
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000
3 ;; Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Maintainer: bugs@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., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Commentary:
27
28 ;;; Code:
29
30 (eval-when-compile (require 'cl))
31
32 (require 'gnus)
33 (require 'gnus-group)
34 (require 'gnus-spec)
35 (require 'gnus-range)
36 (require 'gnus-int)
37 (require 'gnus-undo)
38 (require 'gnus-util)
39 (require 'mm-decode)
40 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
41 (autoload 'gnus-cache-write-active "gnus-cache")
42
43 (defcustom gnus-kill-summary-on-exit t
44 "*If non-nil, kill the summary buffer when you exit from it.
45 If nil, the summary will become a \"*Dead Summary*\" buffer, and
46 it will be killed sometime later."
47 :group 'gnus-summary-exit
48 :type 'boolean)
49
50 (defcustom gnus-fetch-old-headers nil
51 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
52 If an unread article in the group refers to an older, already read (or
53 just marked as read) article, the old article will not normally be
54 displayed in the Summary buffer. If this variable is non-nil, Gnus
55 will attempt to grab the headers to the old articles, and thereby
56 build complete threads. If it has the value `some', only enough
57 headers to connect otherwise loose threads will be displayed. This
58 variable can also be a number. In that case, no more than that number
59 of old headers will be fetched. If it has the value `invisible', all
60 old headers will be fetched, but none will be displayed.
61
62 The server has to support NOV for any of this to work."
63 :group 'gnus-thread
64 :type '(choice (const :tag "off" nil)
65 (const some)
66 number
67 (sexp :menu-tag "other" t)))
68
69 (defcustom gnus-refer-thread-limit 200
70 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
71 If t, fetch all the available old headers."
72 :group 'gnus-thread
73 :type '(choice number
74 (sexp :menu-tag "other" t)))
75
76 (defcustom gnus-summary-make-false-root 'adopt
77 "*nil means that Gnus won't gather loose threads.
78 If the root of a thread has expired or been read in a previous
79 session, the information necessary to build a complete thread has been
80 lost. Instead of having many small sub-threads from this original thread
81 scattered all over the summary buffer, Gnus can gather them.
82
83 If non-nil, Gnus will try to gather all loose sub-threads from an
84 original thread into one large thread.
85
86 If this variable is non-nil, it should be one of `none', `adopt',
87 `dummy' or `empty'.
88
89 If this variable is `none', Gnus will not make a false root, but just
90 present the sub-threads after another.
91 If this variable is `dummy', Gnus will create a dummy root that will
92 have all the sub-threads as children.
93 If this variable is `adopt', Gnus will make one of the \"children\"
94 the parent and mark all the step-children as such.
95 If this variable is `empty', the \"children\" are printed with empty
96 subject fields. (Or rather, they will be printed with a string
97 given by the `gnus-summary-same-subject' variable.)"
98 :group 'gnus-thread
99 :type '(choice (const :tag "off" nil)
100 (const none)
101 (const dummy)
102 (const adopt)
103 (const empty)))
104
105 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
106 "*A regexp to match subjects to be excluded from loose thread gathering.
107 As loose thread gathering is done on subjects only, that means that
108 there can be many false gatherings performed. By rooting out certain
109 common subjects, gathering might become saner."
110 :group 'gnus-thread
111 :type 'regexp)
112
113 (defcustom gnus-summary-gather-subject-limit nil
114 "*Maximum length of subject comparisons when gathering loose threads.
115 Use nil to compare full subjects. Setting this variable to a low
116 number will help gather threads that have been corrupted by
117 newsreaders chopping off subject lines, but it might also mean that
118 unrelated articles that have subject that happen to begin with the
119 same few characters will be incorrectly gathered.
120
121 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
122 comparing subjects."
123 :group 'gnus-thread
124 :type '(choice (const :tag "off" nil)
125 (const fuzzy)
126 (sexp :menu-tag "on" t)))
127
128 (defcustom gnus-simplify-subject-functions nil
129 "List of functions taking a string argument that simplify subjects.
130 The functions are applied recursively.
131
132 Useful functions to put in this list include: `gnus-simplify-subject-re',
133 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
134 :group 'gnus-thread
135 :type '(repeat function))
136
137 (defcustom gnus-simplify-ignored-prefixes nil
138 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
139 :group 'gnus-thread
140 :type '(choice (const :tag "off" nil)
141 regexp))
142
143 (defcustom gnus-build-sparse-threads nil
144 "*If non-nil, fill in the gaps in threads.
145 If `some', only fill in the gaps that are needed to tie loose threads
146 together. If `more', fill in all leaf nodes that Gnus can find. If
147 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
148 :group 'gnus-thread
149 :type '(choice (const :tag "off" nil)
150 (const some)
151 (const more)
152 (sexp :menu-tag "all" t)))
153
154 (defcustom gnus-summary-thread-gathering-function
155 'gnus-gather-threads-by-subject
156 "*Function used for gathering loose threads.
157 There are two pre-defined functions: `gnus-gather-threads-by-subject',
158 which only takes Subjects into consideration; and
159 `gnus-gather-threads-by-references', which compared the References
160 headers of the articles to find matches."
161 :group 'gnus-thread
162 :type '(radio (function-item gnus-gather-threads-by-subject)
163 (function-item gnus-gather-threads-by-references)
164 (function :tag "other")))
165
166 (defcustom gnus-summary-same-subject ""
167 "*String indicating that the current article has the same subject as the previous.
168 This variable will only be used if the value of
169 `gnus-summary-make-false-root' is `empty'."
170 :group 'gnus-summary-format
171 :type 'string)
172
173 (defcustom gnus-summary-goto-unread t
174 "*If t, many commands will go to the next unread article.
175 This applies to marking commands as well as other commands that
176 \"naturally\" select the next article, like, for instance, `SPC' at
177 the end of an article.
178
179 If nil, the marking commands do NOT go to the next unread article
180 (they go to the next article instead). If `never', commands that
181 usually go to the next unread article, will go to the next article,
182 whether it is read or not."
183 :group 'gnus-summary-marks
184 :link '(custom-manual "(gnus)Setting Marks")
185 :type '(choice (const :tag "off" nil)
186 (const never)
187 (sexp :menu-tag "on" t)))
188
189 (defcustom gnus-summary-default-score 0
190 "*Default article score level.
191 All scores generated by the score files will be added to this score.
192 If this variable is nil, scoring will be disabled."
193 :group 'gnus-score-default
194 :type '(choice (const :tag "disable")
195 integer))
196
197 (defcustom gnus-summary-zcore-fuzz 0
198 "*Fuzziness factor for the zcore in the summary buffer.
199 Articles with scores closer than this to `gnus-summary-default-score'
200 will not be marked."
201 :group 'gnus-summary-format
202 :type 'integer)
203
204 (defcustom gnus-simplify-subject-fuzzy-regexp nil
205 "*Strings to be removed when doing fuzzy matches.
206 This can either be a regular expression or list of regular expressions
207 that will be removed from subject strings if fuzzy subject
208 simplification is selected."
209 :group 'gnus-thread
210 :type '(repeat regexp))
211
212 (defcustom gnus-show-threads t
213 "*If non-nil, display threads in summary mode."
214 :group 'gnus-thread
215 :type 'boolean)
216
217 (defcustom gnus-thread-hide-subtree nil
218 "*If non-nil, hide all threads initially.
219 If threads are hidden, you have to run the command
220 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
221 to expose hidden threads."
222 :group 'gnus-thread
223 :type 'boolean)
224
225 (defcustom gnus-thread-hide-killed t
226 "*If non-nil, hide killed threads automatically."
227 :group 'gnus-thread
228 :type 'boolean)
229
230 (defcustom gnus-thread-ignore-subject t
231 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
232 If nil, articles that have different subjects from their parents will
233 start separate threads."
234 :group 'gnus-thread
235 :type 'boolean)
236
237 (defcustom gnus-thread-operation-ignore-subject t
238 "*If non-nil, subjects will be ignored when doing thread commands.
239 This affects commands like `gnus-summary-kill-thread' and
240 `gnus-summary-lower-thread'.
241
242 If this variable is nil, articles in the same thread with different
243 subjects will not be included in the operation in question. If this
244 variable is `fuzzy', only articles that have subjects that are fuzzily
245 equal will be included."
246 :group 'gnus-thread
247 :type '(choice (const :tag "off" nil)
248 (const fuzzy)
249 (sexp :tag "on" t)))
250
251 (defcustom gnus-thread-indent-level 4
252 "*Number that says how much each sub-thread should be indented."
253 :group 'gnus-thread
254 :type 'integer)
255
256 (defcustom gnus-auto-extend-newsgroup t
257 "*If non-nil, extend newsgroup forward and backward when requested."
258 :group 'gnus-summary-choose
259 :type 'boolean)
260
261 (defcustom gnus-auto-select-first t
262 "*If nil, don't select the first unread article when entering a group.
263 If this variable is `best', select the highest-scored unread article
264 in the group. If t, select the first unread article.
265
266 This variable can also be a function to place point on a likely
267 subject line. Useful values include `gnus-summary-first-unread-subject',
268 `gnus-summary-first-unread-article' and
269 `gnus-summary-best-unread-article'.
270
271 If you want to prevent automatic selection of the first unread article
272 in some newsgroups, set the variable to nil in
273 `gnus-select-group-hook'."
274 :group 'gnus-group-select
275 :type '(choice (const :tag "none" nil)
276 (const best)
277 (sexp :menu-tag "first" t)
278 (function-item gnus-summary-first-unread-subject)
279 (function-item gnus-summary-first-unread-article)
280 (function-item gnus-summary-best-unread-article)))
281
282 (defcustom gnus-auto-select-next t
283 "*If non-nil, offer to go to the next group from the end of the previous.
284 If the value is t and the next newsgroup is empty, Gnus will exit
285 summary mode and go back to group mode. If the value is neither nil
286 nor t, Gnus will select the following unread newsgroup. In
287 particular, if the value is the symbol `quietly', the next unread
288 newsgroup will be selected without any confirmation, and if it is
289 `almost-quietly', the next group will be selected without any
290 confirmation if you are located on the last article in the group.
291 Finally, if this variable is `slightly-quietly', the `Z n' command
292 will go to the next group without confirmation."
293 :group 'gnus-summary-maneuvering
294 :type '(choice (const :tag "off" nil)
295 (const quietly)
296 (const almost-quietly)
297 (const slightly-quietly)
298 (sexp :menu-tag "on" t)))
299
300 (defcustom gnus-auto-select-same nil
301 "*If non-nil, select the next article with the same subject.
302 If there are no more articles with the same subject, go to
303 the first unread article."
304 :group 'gnus-summary-maneuvering
305 :type 'boolean)
306
307 (defcustom gnus-summary-check-current nil
308 "*If non-nil, consider the current article when moving.
309 The \"unread\" movement commands will stay on the same line if the
310 current article is unread."
311 :group 'gnus-summary-maneuvering
312 :type 'boolean)
313
314 (defcustom gnus-auto-center-summary t
315 "*If non-nil, always center the current summary buffer.
316 In particular, if `vertical' do only vertical recentering. If non-nil
317 and non-`vertical', do both horizontal and vertical recentering."
318 :group 'gnus-summary-maneuvering
319 :type '(choice (const :tag "none" nil)
320 (const vertical)
321 (integer :tag "height")
322 (sexp :menu-tag "both" t)))
323
324 (defcustom gnus-show-all-headers nil
325 "*If non-nil, don't hide any headers."
326 :group 'gnus-article-hiding
327 :group 'gnus-article-headers
328 :type 'boolean)
329
330 (defcustom gnus-summary-ignore-duplicates nil
331 "*If non-nil, ignore articles with identical Message-ID headers."
332 :group 'gnus-summary
333 :type 'boolean)
334
335 (defcustom gnus-single-article-buffer t
336 "*If non-nil, display all articles in the same buffer.
337 If nil, each group will get its own article buffer."
338 :group 'gnus-article-various
339 :type 'boolean)
340
341 (defcustom gnus-break-pages t
342 "*If non-nil, do page breaking on articles.
343 The page delimiter is specified by the `gnus-page-delimiter'
344 variable."
345 :group 'gnus-article-various
346 :type 'boolean)
347
348 (defcustom gnus-move-split-methods nil
349 "*Variable used to suggest where articles are to be moved to.
350 It uses the same syntax as the `gnus-split-methods' variable."
351 :group 'gnus-summary-mail
352 :type '(repeat (choice (list :value (fun) function)
353 (cons :value ("" "") regexp (repeat string))
354 (sexp :value nil))))
355
356 (defcustom gnus-unread-mark ? ;Whitespace
357 "*Mark used for unread articles."
358 :group 'gnus-summary-marks
359 :type 'character)
360
361 (defcustom gnus-ticked-mark ?!
362 "*Mark used for ticked articles."
363 :group 'gnus-summary-marks
364 :type 'character)
365
366 (defcustom gnus-dormant-mark ??
367 "*Mark used for dormant articles."
368 :group 'gnus-summary-marks
369 :type 'character)
370
371 (defcustom gnus-del-mark ?r
372 "*Mark used for del'd articles."
373 :group 'gnus-summary-marks
374 :type 'character)
375
376 (defcustom gnus-read-mark ?R
377 "*Mark used for read articles."
378 :group 'gnus-summary-marks
379 :type 'character)
380
381 (defcustom gnus-expirable-mark ?E
382 "*Mark used for expirable articles."
383 :group 'gnus-summary-marks
384 :type 'character)
385
386 (defcustom gnus-killed-mark ?K
387 "*Mark used for killed articles."
388 :group 'gnus-summary-marks
389 :type 'character)
390
391 (defcustom gnus-souped-mark ?F
392 "*Mark used for killed articles."
393 :group 'gnus-summary-marks
394 :type 'character)
395
396 (defcustom gnus-kill-file-mark ?X
397 "*Mark used for articles killed by kill files."
398 :group 'gnus-summary-marks
399 :type 'character)
400
401 (defcustom gnus-low-score-mark ?Y
402 "*Mark used for articles with a low score."
403 :group 'gnus-summary-marks
404 :type 'character)
405
406 (defcustom gnus-catchup-mark ?C
407 "*Mark used for articles that are caught up."
408 :group 'gnus-summary-marks
409 :type 'character)
410
411 (defcustom gnus-replied-mark ?A
412 "*Mark used for articles that have been replied to."
413 :group 'gnus-summary-marks
414 :type 'character)
415
416 (defcustom gnus-cached-mark ?*
417 "*Mark used for articles that are in the cache."
418 :group 'gnus-summary-marks
419 :type 'character)
420
421 (defcustom gnus-saved-mark ?S
422 "*Mark used for articles that have been saved to."
423 :group 'gnus-summary-marks
424 :type 'character)
425
426 (defcustom gnus-ancient-mark ?O
427 "*Mark used for ancient articles."
428 :group 'gnus-summary-marks
429 :type 'character)
430
431 (defcustom gnus-sparse-mark ?Q
432 "*Mark used for sparsely reffed articles."
433 :group 'gnus-summary-marks
434 :type 'character)
435
436 (defcustom gnus-canceled-mark ?G
437 "*Mark used for canceled articles."
438 :group 'gnus-summary-marks
439 :type 'character)
440
441 (defcustom gnus-duplicate-mark ?M
442 "*Mark used for duplicate articles."
443 :group 'gnus-summary-marks
444 :type 'character)
445
446 (defcustom gnus-undownloaded-mark ?@
447 "*Mark used for articles that weren't downloaded."
448 :group 'gnus-summary-marks
449 :type 'character)
450
451 (defcustom gnus-downloadable-mark ?%
452 "*Mark used for articles that are to be downloaded."
453 :group 'gnus-summary-marks
454 :type 'character)
455
456 (defcustom gnus-unsendable-mark ?=
457 "*Mark used for articles that won't be sent."
458 :group 'gnus-summary-marks
459 :type 'character)
460
461 (defcustom gnus-score-over-mark ?+
462 "*Score mark used for articles with high scores."
463 :group 'gnus-summary-marks
464 :type 'character)
465
466 (defcustom gnus-score-below-mark ?-
467 "*Score mark used for articles with low scores."
468 :group 'gnus-summary-marks
469 :type 'character)
470
471 (defcustom gnus-empty-thread-mark ? ;Whitespace
472 "*There is no thread under the article."
473 :group 'gnus-summary-marks
474 :type 'character)
475
476 (defcustom gnus-not-empty-thread-mark ?=
477 "*There is a thread under the article."
478 :group 'gnus-summary-marks
479 :type 'character)
480
481 (defcustom gnus-view-pseudo-asynchronously nil
482 "*If non-nil, Gnus will view pseudo-articles asynchronously."
483 :group 'gnus-extract-view
484 :type 'boolean)
485
486 (defcustom gnus-auto-expirable-marks
487 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
488 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
489 gnus-souped-mark gnus-duplicate-mark)
490 "*The list of marks converted into expiration if a group is auto-expirable."
491 :group 'gnus-summary
492 :type '(repeat character))
493
494 (defcustom gnus-inhibit-user-auto-expire t
495 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
496 :group 'gnus-summary
497 :type 'boolean)
498
499 (defcustom gnus-view-pseudos nil
500 "*If `automatic', pseudo-articles will be viewed automatically.
501 If `not-confirm', pseudos will be viewed automatically, and the user
502 will not be asked to confirm the command."
503 :group 'gnus-extract-view
504 :type '(choice (const :tag "off" nil)
505 (const automatic)
506 (const not-confirm)))
507
508 (defcustom gnus-view-pseudos-separately t
509 "*If non-nil, one pseudo-article will be created for each file to be viewed.
510 If nil, all files that use the same viewing command will be given as a
511 list of parameters to that command."
512 :group 'gnus-extract-view
513 :type 'boolean)
514
515 (defcustom gnus-insert-pseudo-articles t
516 "*If non-nil, insert pseudo-articles when decoding articles."
517 :group 'gnus-extract-view
518 :type 'boolean)
519
520 (defcustom gnus-summary-dummy-line-format
521 " %(: :%) %S\n"
522 "*The format specification for the dummy roots in the summary buffer.
523 It works along the same lines as a normal formatting string,
524 with some simple extensions.
525
526 %S The subject"
527 :group 'gnus-threading
528 :type 'string)
529
530 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
531 "*The format specification for the summary mode line.
532 It works along the same lines as a normal formatting string,
533 with some simple extensions:
534
535 %G Group name
536 %p Unprefixed group name
537 %A Current article number
538 %z Current article score
539 %V Gnus version
540 %U Number of unread articles in the group
541 %e Number of unselected articles in the group
542 %Z A string with unread/unselected article counts
543 %g Shortish group name
544 %S Subject of the current article
545 %u User-defined spec
546 %s Current score file name
547 %d Number of dormant articles
548 %r Number of articles that have been marked as read in this session
549 %E Number of articles expunged by the score files"
550 :group 'gnus-summary-format
551 :type 'string)
552
553 (defcustom gnus-list-identifiers nil
554 "Regexp that matches list identifiers to be removed from subject.
555 This can also be a list of regexps."
556 :group 'gnus-summary-format
557 :group 'gnus-article-hiding
558 :type '(choice (const :tag "none" nil)
559 (regexp :value ".*")
560 (repeat :value (".*") regexp)))
561
562 (defcustom gnus-summary-mark-below 0
563 "*Mark all articles with a score below this variable as read.
564 This variable is local to each summary buffer and usually set by the
565 score file."
566 :group 'gnus-score-default
567 :type 'integer)
568
569 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
570 "*List of functions used for sorting articles in the summary buffer.
571 This variable is only used when not using a threaded display."
572 :group 'gnus-summary-sort
573 :type '(repeat (choice (function-item gnus-article-sort-by-number)
574 (function-item gnus-article-sort-by-author)
575 (function-item gnus-article-sort-by-subject)
576 (function-item gnus-article-sort-by-date)
577 (function-item gnus-article-sort-by-score)
578 (function :tag "other"))))
579
580 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
581 "*List of functions used for sorting threads in the summary buffer.
582 By default, threads are sorted by article number.
583
584 Each function takes two threads and return non-nil if the first thread
585 should be sorted before the other. If you use more than one function,
586 the primary sort function should be the last. You should probably
587 always include `gnus-thread-sort-by-number' in the list of sorting
588 functions -- preferably first.
589
590 Ready-made functions include `gnus-thread-sort-by-number',
591 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
592 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
593 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
594 :group 'gnus-summary-sort
595 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
596 (function-item gnus-thread-sort-by-author)
597 (function-item gnus-thread-sort-by-subject)
598 (function-item gnus-thread-sort-by-date)
599 (function-item gnus-thread-sort-by-score)
600 (function-item gnus-thread-sort-by-total-score)
601 (function :tag "other"))))
602
603 (defcustom gnus-thread-score-function '+
604 "*Function used for calculating the total score of a thread.
605
606 The function is called with the scores of the article and each
607 subthread and should then return the score of the thread.
608
609 Some functions you can use are `+', `max', or `min'."
610 :group 'gnus-summary-sort
611 :type 'function)
612
613 (defcustom gnus-summary-expunge-below nil
614 "All articles that have a score less than this variable will be expunged.
615 This variable is local to the summary buffers."
616 :group 'gnus-score-default
617 :type '(choice (const :tag "off" nil)
618 integer))
619
620 (defcustom gnus-thread-expunge-below nil
621 "All threads that have a total score less than this variable will be expunged.
622 See `gnus-thread-score-function' for en explanation of what a
623 \"thread score\" is.
624
625 This variable is local to the summary buffers."
626 :group 'gnus-threading
627 :group 'gnus-score-default
628 :type '(choice (const :tag "off" nil)
629 integer))
630
631 (defcustom gnus-summary-mode-hook nil
632 "*A hook for Gnus summary mode.
633 This hook is run before any variables are set in the summary buffer."
634 :group 'gnus-summary-various
635 :type 'hook)
636
637 (defcustom gnus-summary-menu-hook nil
638 "*Hook run after the creation of the summary mode menu."
639 :group 'gnus-summary-visual
640 :type 'hook)
641
642 (defcustom gnus-summary-exit-hook nil
643 "*A hook called on exit from the summary buffer.
644 It will be called with point in the group buffer."
645 :group 'gnus-summary-exit
646 :type 'hook)
647
648 (defcustom gnus-summary-prepare-hook nil
649 "*A hook called after the summary buffer has been generated.
650 If you want to modify the summary buffer, you can use this hook."
651 :group 'gnus-summary-various
652 :type 'hook)
653
654 (defcustom gnus-summary-prepared-hook nil
655 "*A hook called as the last thing after the summary buffer has been generated."
656 :group 'gnus-summary-various
657 :type 'hook)
658
659 (defcustom gnus-summary-generate-hook nil
660 "*A hook run just before generating the summary buffer.
661 This hook is commonly used to customize threading variables and the
662 like."
663 :group 'gnus-summary-various
664 :type 'hook)
665
666 (defcustom gnus-select-group-hook nil
667 "*A hook called when a newsgroup is selected.
668
669 If you'd like to simplify subjects like the
670 `gnus-summary-next-same-subject' command does, you can use the
671 following hook:
672
673 (setq gnus-select-group-hook
674 (list
675 (lambda ()
676 (mapcar (lambda (header)
677 (mail-header-set-subject
678 header
679 (gnus-simplify-subject
680 (mail-header-subject header) 're-only)))
681 gnus-newsgroup-headers))))"
682 :group 'gnus-group-select
683 :type 'hook)
684
685 (defcustom gnus-select-article-hook nil
686 "*A hook called when an article is selected."
687 :group 'gnus-summary-choose
688 :type 'hook)
689
690 (defcustom gnus-visual-mark-article-hook
691 (list 'gnus-highlight-selected-summary)
692 "*Hook run after selecting an article in the summary buffer.
693 It is meant to be used for highlighting the article in some way. It
694 is not run if `gnus-visual' is nil."
695 :group 'gnus-summary-visual
696 :type 'hook)
697
698 (defcustom gnus-parse-headers-hook nil
699 "*A hook called before parsing the headers."
700 :group 'gnus-various
701 :type 'hook)
702
703 (defcustom gnus-exit-group-hook nil
704 "*A hook called when exiting summary mode.
705 This hook is not called from the non-updating exit commands like `Q'."
706 :group 'gnus-various
707 :type 'hook)
708
709 (defcustom gnus-summary-update-hook
710 (list 'gnus-summary-highlight-line)
711 "*A hook called when a summary line is changed.
712 The hook will not be called if `gnus-visual' is nil.
713
714 The default function `gnus-summary-highlight-line' will
715 highlight the line according to the `gnus-summary-highlight'
716 variable."
717 :group 'gnus-summary-visual
718 :type 'hook)
719
720 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
721 "*A hook called when an article is selected for the first time.
722 The hook is intended to mark an article as read (or unread)
723 automatically when it is selected."
724 :group 'gnus-summary-choose
725 :type 'hook)
726
727 (defcustom gnus-group-no-more-groups-hook nil
728 "*A hook run when returning to group mode having no more (unread) groups."
729 :group 'gnus-group-select
730 :type 'hook)
731
732 (defcustom gnus-ps-print-hook nil
733 "*A hook run before ps-printing something from Gnus."
734 :group 'gnus-summary
735 :type 'hook)
736
737 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
738 "Face used for highlighting the current article in the summary buffer."
739 :group 'gnus-summary-visual
740 :type 'face)
741
742 (defcustom gnus-summary-highlight
743 '(((= mark gnus-canceled-mark)
744 . gnus-summary-cancelled-face)
745 ((and (> score default)
746 (or (= mark gnus-dormant-mark)
747 (= mark gnus-ticked-mark)))
748 . gnus-summary-high-ticked-face)
749 ((and (< score default)
750 (or (= mark gnus-dormant-mark)
751 (= mark gnus-ticked-mark)))
752 . gnus-summary-low-ticked-face)
753 ((or (= mark gnus-dormant-mark)
754 (= mark gnus-ticked-mark))
755 . gnus-summary-normal-ticked-face)
756 ((and (> score default) (= mark gnus-ancient-mark))
757 . gnus-summary-high-ancient-face)
758 ((and (< score default) (= mark gnus-ancient-mark))
759 . gnus-summary-low-ancient-face)
760 ((= mark gnus-ancient-mark)
761 . gnus-summary-normal-ancient-face)
762 ((and (> score default) (= mark gnus-unread-mark))
763 . gnus-summary-high-unread-face)
764 ((and (< score default) (= mark gnus-unread-mark))
765 . gnus-summary-low-unread-face)
766 ((= mark gnus-unread-mark)
767 . gnus-summary-normal-unread-face)
768 ((and (> score default) (memq mark (list gnus-downloadable-mark
769 gnus-undownloaded-mark)))
770 . gnus-summary-high-unread-face)
771 ((and (< score default) (memq mark (list gnus-downloadable-mark
772 gnus-undownloaded-mark)))
773 . gnus-summary-low-unread-face)
774 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
775 . gnus-summary-normal-unread-face)
776 ((> score default)
777 . gnus-summary-high-read-face)
778 ((< score default)
779 . gnus-summary-low-read-face)
780 (t
781 . gnus-summary-normal-read-face))
782 "*Controls the highlighting of summary buffer lines.
783
784 A list of (FORM . FACE) pairs. When deciding how a a particular
785 summary line should be displayed, each form is evaluated. The content
786 of the face field after the first true form is used. You can change
787 how those summary lines are displayed, by editing the face field.
788
789 You can use the following variables in the FORM field.
790
791 score: The articles score
792 default: The default article score.
793 below: The score below which articles are automatically marked as read.
794 mark: The articles mark."
795 :group 'gnus-summary-visual
796 :type '(repeat (cons (sexp :tag "Form" nil)
797 face)))
798
799 (defcustom gnus-alter-header-function nil
800 "Function called to allow alteration of article header structures.
801 The function is called with one parameter, the article header vector,
802 which it may alter in any way.")
803
804 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
805 "Variable that says which function should be used to decode a string with encoded words.")
806
807 (defcustom gnus-extra-headers nil
808 "*Extra headers to parse."
809 :group 'gnus-summary
810 :type '(repeat symbol))
811
812 (defcustom gnus-ignored-from-addresses
813 (and user-mail-address (regexp-quote user-mail-address))
814 "*Regexp of From headers that may be suppressed in favor of To headers."
815 :group 'gnus-summary
816 :type 'regexp)
817
818 (defcustom gnus-group-charset-alist
819 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
820 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
821 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
822 ("^tnn\\>\\|^pin\\>\\|^sci.lang.japan" iso-2022-7bit)
823 ("^relcom\\>" koi8-r)
824 ("^fido7\\>" koi8-r)
825 ("^\\(cz\\|hun\\|pl\\|sk\\|hr\\)\\>" iso-8859-2)
826 ("^israel\\>" iso-8859-1)
827 ("^han\\>" euc-kr)
828 ("^alt.chinese.text.big5\\>" chinese-big5)
829 ("^soc.culture.vietnamese\\>" vietnamese-viqr)
830 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
831 (".*" iso-8859-1))
832 "Alist of regexps (to match group names) and default charsets to be used when reading."
833 :type '(repeat (list (regexp :tag "Group")
834 (symbol :tag "Charset")))
835 :group 'gnus-charset)
836
837 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
838 "List of charsets that should be ignored.
839 When these charsets are used in the \"charset\" parameter, the
840 default charset will be used instead."
841 :type '(repeat symbol)
842 :group 'gnus-charset)
843
844 (defcustom gnus-group-ignored-charsets-alist
845 '(("alt\\.chinese\\.text" iso-8859-1))
846 "Alist of regexps (to match group names) and charsets that should be ignored.
847 When these charsets are used in the \"charset\" parameter, the
848 default charset will be used instead."
849 :type '(repeat (cons (regexp :tag "Group")
850 (repeat symbol)))
851 :group 'gnus-charset)
852
853 (defcustom gnus-group-highlight-words-alist nil
854 "Alist of group regexps and highlight regexps.
855 This variable uses the same syntax as `gnus-emphasis-alist'."
856 :type '(repeat (cons (regexp :tag "Group")
857 (repeat (list (regexp :tag "Highlight regexp")
858 (number :tag "Group for entire word" 0)
859 (number :tag "Group for displayed part" 0)
860 (symbol :tag "Face"
861 gnus-emphasis-highlight-words)))))
862 :group 'gnus-summary-visual)
863
864 (defcustom gnus-summary-show-article-charset-alist
865 nil
866 "Alist of number and charset.
867 The article will be shown with the charset corresponding to the
868 numbered argument.
869 For example: ((1 . cn-gb-2312) (2 . big5))."
870 :type '(repeat (cons (number :tag "Argument" 1)
871 (symbol :tag "Charset")))
872 :group 'gnus-charset)
873
874 (defcustom gnus-preserve-marks t
875 "Whether marks are preserved when moving, copying and respooling messages."
876 :type 'boolean
877 :group 'gnus-summary-marks)
878
879 (defcustom gnus-alter-articles-to-read-function nil
880 "Function to be called to alter the list of articles to be selected."
881 :type 'function
882 :group 'gnus-summary)
883
884 (defcustom gnus-orphan-score nil
885 "*All orphans get this score added. Set in the score file."
886 :group 'gnus-score-default
887 :type '(choice (const nil)
888 integer))
889
890 (defcustom gnus-summary-save-parts-default-mime "image/.*"
891 "*A regexp to match MIME parts when saving multiple parts of a message
892 with gnus-summary-save-parts (X m). This regexp will be used by default
893 when prompting the user for which type of files to save."
894 :group 'gnus-summary
895 :type 'regexp)
896
897
898 ;;; Internal variables
899
900 (defvar gnus-article-mime-handles nil)
901 (defvar gnus-article-decoded-p nil)
902 (defvar gnus-scores-exclude-files nil)
903 (defvar gnus-page-broken nil)
904 (defvar gnus-inhibit-mime-unbuttonizing nil)
905
906 (defvar gnus-original-article nil)
907 (defvar gnus-article-internal-prepare-hook nil)
908 (defvar gnus-newsgroup-process-stack nil)
909
910 (defvar gnus-thread-indent-array nil)
911 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
912 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
913 "Function called to sort the articles within a thread after it has been gathered together.")
914
915 (defvar gnus-summary-save-parts-type-history nil)
916 (defvar gnus-summary-save-parts-last-directory nil)
917
918 ;; Avoid highlighting in kill files.
919 (defvar gnus-summary-inhibit-highlight nil)
920 (defvar gnus-newsgroup-selected-overlay nil)
921 (defvar gnus-inhibit-limiting nil)
922 (defvar gnus-newsgroup-adaptive-score-file nil)
923 (defvar gnus-current-score-file nil)
924 (defvar gnus-current-move-group nil)
925 (defvar gnus-current-copy-group nil)
926 (defvar gnus-current-crosspost-group nil)
927
928 (defvar gnus-newsgroup-dependencies nil)
929 (defvar gnus-newsgroup-adaptive nil)
930 (defvar gnus-summary-display-article-function nil)
931 (defvar gnus-summary-highlight-line-function nil
932 "Function called after highlighting a summary line.")
933
934 (defvar gnus-summary-line-format-alist
935 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
936 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
937 (?s gnus-tmp-subject-or-nil ?s)
938 (?n gnus-tmp-name ?s)
939 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
940 ?s)
941 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
942 gnus-tmp-from) ?s)
943 (?F gnus-tmp-from ?s)
944 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
945 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
946 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
947 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
948 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
949 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
950 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
951 (?L gnus-tmp-lines ?d)
952 (?I gnus-tmp-indentation ?s)
953 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
954 (?R gnus-tmp-replied ?c)
955 (?\[ gnus-tmp-opening-bracket ?c)
956 (?\] gnus-tmp-closing-bracket ?c)
957 (?\> (make-string gnus-tmp-level ? ) ?s)
958 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
959 (?i gnus-tmp-score ?d)
960 (?z gnus-tmp-score-char ?c)
961 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
962 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
963 (?U gnus-tmp-unread ?c)
964 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
965 (?t (gnus-summary-number-of-articles-in-thread
966 (and (boundp 'thread) (car thread)) gnus-tmp-level)
967 ?d)
968 (?e (gnus-summary-number-of-articles-in-thread
969 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
970 ?c)
971 (?u gnus-tmp-user-defined ?s)
972 (?P (gnus-pick-line-number) ?d))
973 "An alist of format specifications that can appear in summary lines.
974 These are paired with what variables they correspond with, along with
975 the type of the variable (string, integer, character, etc).")
976
977 (defvar gnus-summary-dummy-line-format-alist
978 `((?S gnus-tmp-subject ?s)
979 (?N gnus-tmp-number ?d)
980 (?u gnus-tmp-user-defined ?s)))
981
982 (defvar gnus-summary-mode-line-format-alist
983 `((?G gnus-tmp-group-name ?s)
984 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
985 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
986 (?A gnus-tmp-article-number ?d)
987 (?Z gnus-tmp-unread-and-unselected ?s)
988 (?V gnus-version ?s)
989 (?U gnus-tmp-unread-and-unticked ?d)
990 (?S gnus-tmp-subject ?s)
991 (?e gnus-tmp-unselected ?d)
992 (?u gnus-tmp-user-defined ?s)
993 (?d (length gnus-newsgroup-dormant) ?d)
994 (?t (length gnus-newsgroup-marked) ?d)
995 (?r (length gnus-newsgroup-reads) ?d)
996 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
997 (?E gnus-newsgroup-expunged-tally ?d)
998 (?s (gnus-current-score-file-nondirectory) ?s)))
999
1000 (defvar gnus-last-search-regexp nil
1001 "Default regexp for article search command.")
1002
1003 (defvar gnus-last-shell-command nil
1004 "Default shell command on article.")
1005
1006 (defvar gnus-newsgroup-begin nil)
1007 (defvar gnus-newsgroup-end nil)
1008 (defvar gnus-newsgroup-last-rmail nil)
1009 (defvar gnus-newsgroup-last-mail nil)
1010 (defvar gnus-newsgroup-last-folder nil)
1011 (defvar gnus-newsgroup-last-file nil)
1012 (defvar gnus-newsgroup-auto-expire nil)
1013 (defvar gnus-newsgroup-active nil)
1014
1015 (defvar gnus-newsgroup-data nil)
1016 (defvar gnus-newsgroup-data-reverse nil)
1017 (defvar gnus-newsgroup-limit nil)
1018 (defvar gnus-newsgroup-limits nil)
1019
1020 (defvar gnus-newsgroup-unreads nil
1021 "List of unread articles in the current newsgroup.")
1022
1023 (defvar gnus-newsgroup-unselected nil
1024 "List of unselected unread articles in the current newsgroup.")
1025
1026 (defvar gnus-newsgroup-reads nil
1027 "Alist of read articles and article marks in the current newsgroup.")
1028
1029 (defvar gnus-newsgroup-expunged-tally nil)
1030
1031 (defvar gnus-newsgroup-marked nil
1032 "List of ticked articles in the current newsgroup (a subset of unread art).")
1033
1034 (defvar gnus-newsgroup-killed nil
1035 "List of ranges of articles that have been through the scoring process.")
1036
1037 (defvar gnus-newsgroup-cached nil
1038 "List of articles that come from the article cache.")
1039
1040 (defvar gnus-newsgroup-saved nil
1041 "List of articles that have been saved.")
1042
1043 (defvar gnus-newsgroup-kill-headers nil)
1044
1045 (defvar gnus-newsgroup-replied nil
1046 "List of articles that have been replied to in the current newsgroup.")
1047
1048 (defvar gnus-newsgroup-expirable nil
1049 "List of articles in the current newsgroup that can be expired.")
1050
1051 (defvar gnus-newsgroup-processable nil
1052 "List of articles in the current newsgroup that can be processed.")
1053
1054 (defvar gnus-newsgroup-downloadable nil
1055 "List of articles in the current newsgroup that can be processed.")
1056
1057 (defvar gnus-newsgroup-undownloaded nil
1058 "List of articles in the current newsgroup that haven't been downloaded..")
1059
1060 (defvar gnus-newsgroup-unsendable nil
1061 "List of articles in the current newsgroup that won't be sent.")
1062
1063 (defvar gnus-newsgroup-bookmarks nil
1064 "List of articles in the current newsgroup that have bookmarks.")
1065
1066 (defvar gnus-newsgroup-dormant nil
1067 "List of dormant articles in the current newsgroup.")
1068
1069 (defvar gnus-newsgroup-scored nil
1070 "List of scored articles in the current newsgroup.")
1071
1072 (defvar gnus-newsgroup-headers nil
1073 "List of article headers in the current newsgroup.")
1074
1075 (defvar gnus-newsgroup-threads nil)
1076
1077 (defvar gnus-newsgroup-prepared nil
1078 "Whether the current group has been prepared properly.")
1079
1080 (defvar gnus-newsgroup-ancient nil
1081 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1082
1083 (defvar gnus-newsgroup-sparse nil)
1084
1085 (defvar gnus-current-article nil)
1086 (defvar gnus-article-current nil)
1087 (defvar gnus-current-headers nil)
1088 (defvar gnus-have-all-headers nil)
1089 (defvar gnus-last-article nil)
1090 (defvar gnus-newsgroup-history nil)
1091 (defvar gnus-newsgroup-charset nil)
1092 (defvar gnus-newsgroup-ephemeral-charset nil)
1093 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1094
1095 (defconst gnus-summary-local-variables
1096 '(gnus-newsgroup-name
1097 gnus-newsgroup-begin gnus-newsgroup-end
1098 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1099 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1100 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1101 gnus-newsgroup-unselected gnus-newsgroup-marked
1102 gnus-newsgroup-reads gnus-newsgroup-saved
1103 gnus-newsgroup-replied gnus-newsgroup-expirable
1104 gnus-newsgroup-processable gnus-newsgroup-killed
1105 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1106 gnus-newsgroup-unsendable
1107 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1108 gnus-newsgroup-headers gnus-newsgroup-threads
1109 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1110 gnus-current-article gnus-current-headers gnus-have-all-headers
1111 gnus-last-article gnus-article-internal-prepare-hook
1112 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1113 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1114 gnus-thread-expunge-below
1115 gnus-score-alist gnus-current-score-file
1116 (gnus-summary-expunge-below . global)
1117 (gnus-summary-mark-below . global)
1118 (gnus-orphan-score . global)
1119 gnus-newsgroup-active gnus-scores-exclude-files
1120 gnus-newsgroup-history gnus-newsgroup-ancient
1121 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1122 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1123 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1124 (gnus-newsgroup-expunged-tally . 0)
1125 gnus-cache-removable-articles gnus-newsgroup-cached
1126 gnus-newsgroup-data gnus-newsgroup-data-reverse
1127 gnus-newsgroup-limit gnus-newsgroup-limits
1128 gnus-newsgroup-charset)
1129 "Variables that are buffer-local to the summary buffers.")
1130
1131 ;; Byte-compiler warning.
1132 (defvar gnus-article-mode-map)
1133
1134 ;; MIME stuff.
1135
1136 (defvar gnus-decode-encoded-word-methods
1137 '(mail-decode-encoded-word-string)
1138 "List of methods used to decode encoded words.
1139
1140 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
1141 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1142 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1143 whose names match REGEXP.
1144
1145 For example:
1146 ((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1147 mail-decode-encoded-word-string
1148 (\"chinese\" . rfc1843-decode-string))")
1149
1150 (defvar gnus-decode-encoded-word-methods-cache nil)
1151
1152 (defun gnus-multi-decode-encoded-word-string (string)
1153 "Apply the functions from `gnus-encoded-word-methods' that match."
1154 (unless (and gnus-decode-encoded-word-methods-cache
1155 (eq gnus-newsgroup-name
1156 (car gnus-decode-encoded-word-methods-cache)))
1157 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1158 (mapcar (lambda (x)
1159 (if (symbolp x)
1160 (nconc gnus-decode-encoded-word-methods-cache (list x))
1161 (if (and gnus-newsgroup-name
1162 (string-match (car x) gnus-newsgroup-name))
1163 (nconc gnus-decode-encoded-word-methods-cache
1164 (list (cdr x))))))
1165 gnus-decode-encoded-word-methods))
1166 (let ((xlist gnus-decode-encoded-word-methods-cache))
1167 (pop xlist)
1168 (while xlist
1169 (setq string (funcall (pop xlist) string))))
1170 string)
1171
1172 ;; Subject simplification.
1173
1174 (defun gnus-simplify-whitespace (str)
1175 "Remove excessive whitespace from STR."
1176 (let ((mystr str))
1177 ;; Multiple spaces.
1178 (while (string-match "[ \t][ \t]+" mystr)
1179 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1180 " "
1181 (substring mystr (match-end 0)))))
1182 ;; Leading spaces.
1183 (when (string-match "^[ \t]+" mystr)
1184 (setq mystr (substring mystr (match-end 0))))
1185 ;; Trailing spaces.
1186 (when (string-match "[ \t]+$" mystr)
1187 (setq mystr (substring mystr 0 (match-beginning 0))))
1188 mystr))
1189
1190 (defsubst gnus-simplify-subject-re (subject)
1191 "Remove \"Re:\" from subject lines."
1192 (if (string-match "^[Rr][Ee]: *" subject)
1193 (substring subject (match-end 0))
1194 subject))
1195
1196 (defun gnus-simplify-subject (subject &optional re-only)
1197 "Remove `Re:' and words in parentheses.
1198 If RE-ONLY is non-nil, strip leading `Re:'s only."
1199 (let ((case-fold-search t)) ;Ignore case.
1200 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1201 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1202 (setq subject (substring subject (match-end 0))))
1203 ;; Remove uninteresting prefixes.
1204 (when (and (not re-only)
1205 gnus-simplify-ignored-prefixes
1206 (string-match gnus-simplify-ignored-prefixes subject))
1207 (setq subject (substring subject (match-end 0))))
1208 ;; Remove words in parentheses from end.
1209 (unless re-only
1210 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1211 (setq subject (substring subject 0 (match-beginning 0)))))
1212 ;; Return subject string.
1213 subject))
1214
1215 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1216 ;; all whitespace.
1217 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1218 (goto-char (point-min))
1219 (while (re-search-forward regexp nil t)
1220 (replace-match (or newtext ""))))
1221
1222 (defun gnus-simplify-buffer-fuzzy ()
1223 "Simplify string in the buffer fuzzily.
1224 The string in the accessible portion of the current buffer is simplified.
1225 It is assumed to be a single-line subject.
1226 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1227 matter is removed. Additional things can be deleted by setting
1228 `gnus-simplify-subject-fuzzy-regexp'."
1229 (let ((case-fold-search t)
1230 (modified-tick))
1231 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1232
1233 (while (not (eq modified-tick (buffer-modified-tick)))
1234 (setq modified-tick (buffer-modified-tick))
1235 (cond
1236 ((listp gnus-simplify-subject-fuzzy-regexp)
1237 (mapcar 'gnus-simplify-buffer-fuzzy-step
1238 gnus-simplify-subject-fuzzy-regexp))
1239 (gnus-simplify-subject-fuzzy-regexp
1240 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1241 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1242 (gnus-simplify-buffer-fuzzy-step
1243 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1244 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1245
1246 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1247 (gnus-simplify-buffer-fuzzy-step " +" " ")
1248 (gnus-simplify-buffer-fuzzy-step " $")
1249 (gnus-simplify-buffer-fuzzy-step "^ +")))
1250
1251 (defun gnus-simplify-subject-fuzzy (subject)
1252 "Simplify a subject string fuzzily.
1253 See `gnus-simplify-buffer-fuzzy' for details."
1254 (save-excursion
1255 (gnus-set-work-buffer)
1256 (let ((case-fold-search t))
1257 ;; Remove uninteresting prefixes.
1258 (when (and gnus-simplify-ignored-prefixes
1259 (string-match gnus-simplify-ignored-prefixes subject))
1260 (setq subject (substring subject (match-end 0))))
1261 (insert subject)
1262 (inline (gnus-simplify-buffer-fuzzy))
1263 (buffer-string))))
1264
1265 (defsubst gnus-simplify-subject-fully (subject)
1266 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1267 (cond
1268 (gnus-simplify-subject-functions
1269 (gnus-map-function gnus-simplify-subject-functions subject))
1270 ((null gnus-summary-gather-subject-limit)
1271 (gnus-simplify-subject-re subject))
1272 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1273 (gnus-simplify-subject-fuzzy subject))
1274 ((numberp gnus-summary-gather-subject-limit)
1275 (gnus-limit-string (gnus-simplify-subject-re subject)
1276 gnus-summary-gather-subject-limit))
1277 (t
1278 subject)))
1279
1280 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1281 "Check whether two subjects are equal.
1282 If optional argument simple-first is t, first argument is already
1283 simplified."
1284 (cond
1285 ((null simple-first)
1286 (equal (gnus-simplify-subject-fully s1)
1287 (gnus-simplify-subject-fully s2)))
1288 (t
1289 (equal s1
1290 (gnus-simplify-subject-fully s2)))))
1291
1292 (defun gnus-summary-bubble-group ()
1293 "Increase the score of the current group.
1294 This is a handy function to add to `gnus-summary-exit-hook' to
1295 increase the score of each group you read."
1296 (gnus-group-add-score gnus-newsgroup-name))
1297
1298 \f
1299 ;;;
1300 ;;; Gnus summary mode
1301 ;;;
1302
1303 (put 'gnus-summary-mode 'mode-class 'special)
1304
1305 (when t
1306 ;; Non-orthogonal keys
1307
1308 (gnus-define-keys gnus-summary-mode-map
1309 " " gnus-summary-next-page
1310 "\177" gnus-summary-prev-page
1311 [delete] gnus-summary-prev-page
1312 [backspace] gnus-summary-prev-page
1313 "\r" gnus-summary-scroll-up
1314 "\M-\r" gnus-summary-scroll-down
1315 "n" gnus-summary-next-unread-article
1316 "p" gnus-summary-prev-unread-article
1317 "N" gnus-summary-next-article
1318 "P" gnus-summary-prev-article
1319 "\M-\C-n" gnus-summary-next-same-subject
1320 "\M-\C-p" gnus-summary-prev-same-subject
1321 "\M-n" gnus-summary-next-unread-subject
1322 "\M-p" gnus-summary-prev-unread-subject
1323 "." gnus-summary-first-unread-article
1324 "," gnus-summary-best-unread-article
1325 "\M-s" gnus-summary-search-article-forward
1326 "\M-r" gnus-summary-search-article-backward
1327 "<" gnus-summary-beginning-of-article
1328 ">" gnus-summary-end-of-article
1329 "j" gnus-summary-goto-article
1330 "^" gnus-summary-refer-parent-article
1331 "\M-^" gnus-summary-refer-article
1332 "u" gnus-summary-tick-article-forward
1333 "!" gnus-summary-tick-article-forward
1334 "U" gnus-summary-tick-article-backward
1335 "d" gnus-summary-mark-as-read-forward
1336 "D" gnus-summary-mark-as-read-backward
1337 "E" gnus-summary-mark-as-expirable
1338 "\M-u" gnus-summary-clear-mark-forward
1339 "\M-U" gnus-summary-clear-mark-backward
1340 "k" gnus-summary-kill-same-subject-and-select
1341 "\C-k" gnus-summary-kill-same-subject
1342 "\M-\C-k" gnus-summary-kill-thread
1343 "\M-\C-l" gnus-summary-lower-thread
1344 "e" gnus-summary-edit-article
1345 "#" gnus-summary-mark-as-processable
1346 "\M-#" gnus-summary-unmark-as-processable
1347 "\M-\C-t" gnus-summary-toggle-threads
1348 "\M-\C-s" gnus-summary-show-thread
1349 "\M-\C-h" gnus-summary-hide-thread
1350 "\M-\C-f" gnus-summary-next-thread
1351 "\M-\C-b" gnus-summary-prev-thread
1352 [(meta down)] gnus-summary-next-thread
1353 [(meta up)] gnus-summary-prev-thread
1354 "\M-\C-u" gnus-summary-up-thread
1355 "\M-\C-d" gnus-summary-down-thread
1356 "&" gnus-summary-execute-command
1357 "c" gnus-summary-catchup-and-exit
1358 "\C-w" gnus-summary-mark-region-as-read
1359 "\C-t" gnus-summary-toggle-truncation
1360 "?" gnus-summary-mark-as-dormant
1361 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1362 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1363 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1364 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1365 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1366 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1367 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1368 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1369 "=" gnus-summary-expand-window
1370 "\C-x\C-s" gnus-summary-reselect-current-group
1371 "\M-g" gnus-summary-rescan-group
1372 "w" gnus-summary-stop-page-breaking
1373 "\C-c\C-r" gnus-summary-caesar-message
1374 "f" gnus-summary-followup
1375 "F" gnus-summary-followup-with-original
1376 "C" gnus-summary-cancel-article
1377 "r" gnus-summary-reply
1378 "R" gnus-summary-reply-with-original
1379 "\C-c\C-f" gnus-summary-mail-forward
1380 "o" gnus-summary-save-article
1381 "\C-o" gnus-summary-save-article-mail
1382 "|" gnus-summary-pipe-output
1383 "\M-k" gnus-summary-edit-local-kill
1384 "\M-K" gnus-summary-edit-global-kill
1385 ;; "V" gnus-version
1386 "\C-c\C-d" gnus-summary-describe-group
1387 "q" gnus-summary-exit
1388 "Q" gnus-summary-exit-no-update
1389 "\C-c\C-i" gnus-info-find-node
1390 gnus-mouse-2 gnus-mouse-pick-article
1391 "m" gnus-summary-mail-other-window
1392 "a" gnus-summary-post-news
1393 "x" gnus-summary-limit-to-unread
1394 "s" gnus-summary-isearch-article
1395 "t" gnus-summary-toggle-header
1396 "g" gnus-summary-show-article
1397 "l" gnus-summary-goto-last-article
1398 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1399 "\C-d" gnus-summary-enter-digest-group
1400 "\M-\C-d" gnus-summary-read-document
1401 "\M-\C-e" gnus-summary-edit-parameters
1402 "\M-\C-a" gnus-summary-customize-parameters
1403 "\C-c\C-b" gnus-bug
1404 "*" gnus-cache-enter-article
1405 "\M-*" gnus-cache-remove-article
1406 "\M-&" gnus-summary-universal-argument
1407 "\C-l" gnus-recenter
1408 "I" gnus-summary-increase-score
1409 "L" gnus-summary-lower-score
1410 "\M-i" gnus-symbolic-argument
1411 "h" gnus-summary-select-article-buffer
1412
1413 "b" gnus-article-view-part
1414 "\M-t" gnus-summary-toggle-display-buttonized
1415
1416 "V" gnus-summary-score-map
1417 "X" gnus-uu-extract-map
1418 "S" gnus-summary-send-map)
1419
1420 ;; Sort of orthogonal keymap
1421 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1422 "t" gnus-summary-tick-article-forward
1423 "!" gnus-summary-tick-article-forward
1424 "d" gnus-summary-mark-as-read-forward
1425 "r" gnus-summary-mark-as-read-forward
1426 "c" gnus-summary-clear-mark-forward
1427 " " gnus-summary-clear-mark-forward
1428 "e" gnus-summary-mark-as-expirable
1429 "x" gnus-summary-mark-as-expirable
1430 "?" gnus-summary-mark-as-dormant
1431 "b" gnus-summary-set-bookmark
1432 "B" gnus-summary-remove-bookmark
1433 "#" gnus-summary-mark-as-processable
1434 "\M-#" gnus-summary-unmark-as-processable
1435 "S" gnus-summary-limit-include-expunged
1436 "C" gnus-summary-catchup
1437 "H" gnus-summary-catchup-to-here
1438 "\C-c" gnus-summary-catchup-all
1439 "k" gnus-summary-kill-same-subject-and-select
1440 "K" gnus-summary-kill-same-subject
1441 "P" gnus-uu-mark-map)
1442
1443 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1444 "c" gnus-summary-clear-above
1445 "u" gnus-summary-tick-above
1446 "m" gnus-summary-mark-above
1447 "k" gnus-summary-kill-below)
1448
1449 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1450 "/" gnus-summary-limit-to-subject
1451 "n" gnus-summary-limit-to-articles
1452 "w" gnus-summary-pop-limit
1453 "s" gnus-summary-limit-to-subject
1454 "a" gnus-summary-limit-to-author
1455 "u" gnus-summary-limit-to-unread
1456 "m" gnus-summary-limit-to-marks
1457 "M" gnus-summary-limit-exclude-marks
1458 "v" gnus-summary-limit-to-score
1459 "*" gnus-summary-limit-include-cached
1460 "D" gnus-summary-limit-include-dormant
1461 "T" gnus-summary-limit-include-thread
1462 "d" gnus-summary-limit-exclude-dormant
1463 "t" gnus-summary-limit-to-age
1464 "x" gnus-summary-limit-to-extra
1465 "E" gnus-summary-limit-include-expunged
1466 "c" gnus-summary-limit-exclude-childless-dormant
1467 "C" gnus-summary-limit-mark-excluded-as-read)
1468
1469 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1470 "n" gnus-summary-next-unread-article
1471 "p" gnus-summary-prev-unread-article
1472 "N" gnus-summary-next-article
1473 "P" gnus-summary-prev-article
1474 "\C-n" gnus-summary-next-same-subject
1475 "\C-p" gnus-summary-prev-same-subject
1476 "\M-n" gnus-summary-next-unread-subject
1477 "\M-p" gnus-summary-prev-unread-subject
1478 "f" gnus-summary-first-unread-article
1479 "b" gnus-summary-best-unread-article
1480 "j" gnus-summary-goto-article
1481 "g" gnus-summary-goto-subject
1482 "l" gnus-summary-goto-last-article
1483 "o" gnus-summary-pop-article)
1484
1485 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1486 "k" gnus-summary-kill-thread
1487 "l" gnus-summary-lower-thread
1488 "i" gnus-summary-raise-thread
1489 "T" gnus-summary-toggle-threads
1490 "t" gnus-summary-rethread-current
1491 "^" gnus-summary-reparent-thread
1492 "s" gnus-summary-show-thread
1493 "S" gnus-summary-show-all-threads
1494 "h" gnus-summary-hide-thread
1495 "H" gnus-summary-hide-all-threads
1496 "n" gnus-summary-next-thread
1497 "p" gnus-summary-prev-thread
1498 "u" gnus-summary-up-thread
1499 "o" gnus-summary-top-thread
1500 "d" gnus-summary-down-thread
1501 "#" gnus-uu-mark-thread
1502 "\M-#" gnus-uu-unmark-thread)
1503
1504 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1505 "g" gnus-summary-prepare
1506 "c" gnus-summary-insert-cached-articles)
1507
1508 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1509 "c" gnus-summary-catchup-and-exit
1510 "C" gnus-summary-catchup-all-and-exit
1511 "E" gnus-summary-exit-no-update
1512 "Q" gnus-summary-exit
1513 "Z" gnus-summary-exit
1514 "n" gnus-summary-catchup-and-goto-next-group
1515 "R" gnus-summary-reselect-current-group
1516 "G" gnus-summary-rescan-group
1517 "N" gnus-summary-next-group
1518 "s" gnus-summary-save-newsrc
1519 "P" gnus-summary-prev-group)
1520
1521 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1522 " " gnus-summary-next-page
1523 "n" gnus-summary-next-page
1524 "\177" gnus-summary-prev-page
1525 [delete] gnus-summary-prev-page
1526 "p" gnus-summary-prev-page
1527 "\r" gnus-summary-scroll-up
1528 "\M-\r" gnus-summary-scroll-down
1529 "<" gnus-summary-beginning-of-article
1530 ">" gnus-summary-end-of-article
1531 "b" gnus-summary-beginning-of-article
1532 "e" gnus-summary-end-of-article
1533 "^" gnus-summary-refer-parent-article
1534 "r" gnus-summary-refer-parent-article
1535 "D" gnus-summary-enter-digest-group
1536 "R" gnus-summary-refer-references
1537 "T" gnus-summary-refer-thread
1538 "g" gnus-summary-show-article
1539 "s" gnus-summary-isearch-article
1540 "P" gnus-summary-print-article
1541 "t" gnus-article-babel)
1542
1543 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1544 "b" gnus-article-add-buttons
1545 "B" gnus-article-add-buttons-to-head
1546 "o" gnus-article-treat-overstrike
1547 "e" gnus-article-emphasize
1548 "w" gnus-article-fill-cited-article
1549 "Q" gnus-article-fill-long-lines
1550 "C" gnus-article-capitalize-sentences
1551 "c" gnus-article-remove-cr
1552 "q" gnus-article-de-quoted-unreadable
1553 "6" gnus-article-de-base64-unreadable
1554 "Z" gnus-article-decode-HZ
1555 "h" gnus-article-wash-html
1556 "f" gnus-article-display-x-face
1557 "l" gnus-summary-stop-page-breaking
1558 "r" gnus-summary-caesar-message
1559 "t" gnus-summary-toggle-header
1560 "v" gnus-summary-verbose-headers
1561 "H" gnus-article-strip-headers-in-body
1562 "d" gnus-article-treat-dumbquotes)
1563
1564 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1565 "a" gnus-article-hide
1566 "h" gnus-article-hide-headers
1567 "b" gnus-article-hide-boring-headers
1568 "s" gnus-article-hide-signature
1569 "c" gnus-article-hide-citation
1570 "C" gnus-article-hide-citation-in-followups
1571 "l" gnus-article-hide-list-identifiers
1572 "p" gnus-article-hide-pgp
1573 "B" gnus-article-strip-banner
1574 "P" gnus-article-hide-pem
1575 "\C-c" gnus-article-hide-citation-maybe)
1576
1577 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1578 "a" gnus-article-highlight
1579 "h" gnus-article-highlight-headers
1580 "c" gnus-article-highlight-citation
1581 "s" gnus-article-highlight-signature)
1582
1583 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1584 "w" gnus-article-decode-mime-words
1585 "c" gnus-article-decode-charset
1586 "v" gnus-mime-view-all-parts
1587 "b" gnus-article-view-part)
1588
1589 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1590 "z" gnus-article-date-ut
1591 "u" gnus-article-date-ut
1592 "l" gnus-article-date-local
1593 "e" gnus-article-date-lapsed
1594 "o" gnus-article-date-original
1595 "i" gnus-article-date-iso8601
1596 "s" gnus-article-date-user)
1597
1598 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1599 "t" gnus-article-remove-trailing-blank-lines
1600 "l" gnus-article-strip-leading-blank-lines
1601 "m" gnus-article-strip-multiple-blank-lines
1602 "a" gnus-article-strip-blank-lines
1603 "A" gnus-article-strip-all-blank-lines
1604 "s" gnus-article-strip-leading-space
1605 "e" gnus-article-strip-trailing-space)
1606
1607 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1608 "v" gnus-version
1609 "f" gnus-summary-fetch-faq
1610 "d" gnus-summary-describe-group
1611 "h" gnus-summary-describe-briefly
1612 "i" gnus-info-find-node)
1613
1614 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1615 "e" gnus-summary-expire-articles
1616 "\M-\C-e" gnus-summary-expire-articles-now
1617 "\177" gnus-summary-delete-article
1618 [delete] gnus-summary-delete-article
1619 [backspace] gnus-summary-delete-article
1620 "m" gnus-summary-move-article
1621 "r" gnus-summary-respool-article
1622 "w" gnus-summary-edit-article
1623 "c" gnus-summary-copy-article
1624 "B" gnus-summary-crosspost-article
1625 "q" gnus-summary-respool-query
1626 "t" gnus-summary-respool-trace
1627 "i" gnus-summary-import-article
1628 "p" gnus-summary-article-posted-p)
1629
1630 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1631 "o" gnus-summary-save-article
1632 "m" gnus-summary-save-article-mail
1633 "F" gnus-summary-write-article-file
1634 "r" gnus-summary-save-article-rmail
1635 "f" gnus-summary-save-article-file
1636 "b" gnus-summary-save-article-body-file
1637 "h" gnus-summary-save-article-folder
1638 "v" gnus-summary-save-article-vm
1639 "p" gnus-summary-pipe-output
1640 "s" gnus-soup-add-article)
1641
1642 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1643 "b" gnus-summary-display-buttonized
1644 "m" gnus-summary-repair-multipart
1645 "v" gnus-article-view-part
1646 "o" gnus-article-save-part
1647 "c" gnus-article-copy-part
1648 "e" gnus-article-externalize-part
1649 "i" gnus-article-inline-part
1650 "|" gnus-article-pipe-part))
1651
1652 (defun gnus-summary-make-menu-bar ()
1653 (gnus-turn-off-edit-menu 'summary)
1654
1655 (unless (boundp 'gnus-summary-misc-menu)
1656
1657 (easy-menu-define
1658 gnus-summary-kill-menu gnus-summary-mode-map ""
1659 (cons
1660 "Score"
1661 (nconc
1662 (list
1663 ["Enter score..." gnus-summary-score-entry t]
1664 ["Customize" gnus-score-customize t])
1665 (gnus-make-score-map 'increase)
1666 (gnus-make-score-map 'lower)
1667 '(("Mark"
1668 ["Kill below" gnus-summary-kill-below t]
1669 ["Mark above" gnus-summary-mark-above t]
1670 ["Tick above" gnus-summary-tick-above t]
1671 ["Clear above" gnus-summary-clear-above t])
1672 ["Current score" gnus-summary-current-score t]
1673 ["Set score" gnus-summary-set-score t]
1674 ["Switch current score file..." gnus-score-change-score-file t]
1675 ["Set mark below..." gnus-score-set-mark-below t]
1676 ["Set expunge below..." gnus-score-set-expunge-below t]
1677 ["Edit current score file" gnus-score-edit-current-scores t]
1678 ["Edit score file" gnus-score-edit-file t]
1679 ["Trace score" gnus-score-find-trace t]
1680 ["Find words" gnus-score-find-favourite-words t]
1681 ["Rescore buffer" gnus-summary-rescore t]
1682 ["Increase score..." gnus-summary-increase-score t]
1683 ["Lower score..." gnus-summary-lower-score t]))))
1684
1685 ;; Define both the Article menu in the summary buffer and the equivalent
1686 ;; Commands menu in the article buffer here for consistency.
1687 (let ((innards
1688 '(("Hide"
1689 ["All" gnus-article-hide t]
1690 ["Headers" gnus-article-hide-headers t]
1691 ["Signature" gnus-article-hide-signature t]
1692 ["Citation" gnus-article-hide-citation t]
1693 ["List identifiers" gnus-article-hide-list-identifiers t]
1694 ["PGP" gnus-article-hide-pgp t]
1695 ["Banner" gnus-article-strip-banner t]
1696 ["Boring headers" gnus-article-hide-boring-headers t])
1697 ("Highlight"
1698 ["All" gnus-article-highlight t]
1699 ["Headers" gnus-article-highlight-headers t]
1700 ["Signature" gnus-article-highlight-signature t]
1701 ["Citation" gnus-article-highlight-citation t])
1702 ("MIME"
1703 ["Words" gnus-article-decode-mime-words t]
1704 ["Charset" gnus-article-decode-charset t]
1705 ["QP" gnus-article-de-quoted-unreadable t]
1706 ["Base64" gnus-article-de-base64-unreadable t]
1707 ["View all" gnus-mime-view-all-parts t])
1708 ("Date"
1709 ["Local" gnus-article-date-local t]
1710 ["ISO8601" gnus-article-date-iso8601 t]
1711 ["UT" gnus-article-date-ut t]
1712 ["Original" gnus-article-date-original t]
1713 ["Lapsed" gnus-article-date-lapsed t]
1714 ["User-defined" gnus-article-date-user t])
1715 ("Washing"
1716 ("Remove Blanks"
1717 ["Leading" gnus-article-strip-leading-blank-lines t]
1718 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1719 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1720 ["All of the above" gnus-article-strip-blank-lines t]
1721 ["All" gnus-article-strip-all-blank-lines t]
1722 ["Leading space" gnus-article-strip-leading-space t]
1723 ["Trailing space" gnus-article-strip-trailing-space t])
1724 ["Overstrike" gnus-article-treat-overstrike t]
1725 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1726 ["Emphasis" gnus-article-emphasize t]
1727 ["Word wrap" gnus-article-fill-cited-article t]
1728 ["Fill long lines" gnus-article-fill-long-lines t]
1729 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1730 ["CR" gnus-article-remove-cr t]
1731 ["Show X-Face" gnus-article-display-x-face t]
1732 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
1733 ["Base64" gnus-article-de-base64-unreadable t]
1734 ["Rot 13" gnus-summary-caesar-message t]
1735 ["Unix pipe" gnus-summary-pipe-message t]
1736 ["Add buttons" gnus-article-add-buttons t]
1737 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1738 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1739 ["Verbose header" gnus-summary-verbose-headers t]
1740 ["Toggle header" gnus-summary-toggle-header t]
1741 ["Html" gnus-article-wash-html t]
1742 ["HZ" gnus-article-decode-HZ t])
1743 ("Output"
1744 ["Save in default format" gnus-summary-save-article t]
1745 ["Save in file" gnus-summary-save-article-file t]
1746 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1747 ["Save in MH folder" gnus-summary-save-article-folder t]
1748 ["Save in VM folder" gnus-summary-save-article-vm t]
1749 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1750 ["Save body in file" gnus-summary-save-article-body-file t]
1751 ["Pipe through a filter" gnus-summary-pipe-output t]
1752 ["Add to SOUP packet" gnus-soup-add-article t]
1753 ["Print" gnus-summary-print-article t])
1754 ("Backend"
1755 ["Respool article..." gnus-summary-respool-article t]
1756 ["Move article..." gnus-summary-move-article
1757 (gnus-check-backend-function
1758 'request-move-article gnus-newsgroup-name)]
1759 ["Copy article..." gnus-summary-copy-article t]
1760 ["Crosspost article..." gnus-summary-crosspost-article
1761 (gnus-check-backend-function
1762 'request-replace-article gnus-newsgroup-name)]
1763 ["Import file..." gnus-summary-import-article t]
1764 ["Check if posted" gnus-summary-article-posted-p t]
1765 ["Edit article" gnus-summary-edit-article
1766 (not (gnus-group-read-only-p))]
1767 ["Delete article" gnus-summary-delete-article
1768 (gnus-check-backend-function
1769 'request-expire-articles gnus-newsgroup-name)]
1770 ["Query respool" gnus-summary-respool-query t]
1771 ["Trace respool" gnus-summary-respool-trace t]
1772 ["Delete expirable articles" gnus-summary-expire-articles-now
1773 (gnus-check-backend-function
1774 'request-expire-articles gnus-newsgroup-name)])
1775 ("Extract"
1776 ["Uudecode" gnus-uu-decode-uu t]
1777 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1778 ["Unshar" gnus-uu-decode-unshar t]
1779 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1780 ["Save" gnus-uu-decode-save t]
1781 ["Binhex" gnus-uu-decode-binhex t]
1782 ["Postscript" gnus-uu-decode-postscript t])
1783 ("Cache"
1784 ["Enter article" gnus-cache-enter-article t]
1785 ["Remove article" gnus-cache-remove-article t])
1786 ["Translate" gnus-article-babel t]
1787 ["Select article buffer" gnus-summary-select-article-buffer t]
1788 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1789 ["Isearch article..." gnus-summary-isearch-article t]
1790 ["Beginning of the article" gnus-summary-beginning-of-article t]
1791 ["End of the article" gnus-summary-end-of-article t]
1792 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1793 ["Fetch referenced articles" gnus-summary-refer-references t]
1794 ["Fetch current thread" gnus-summary-refer-thread t]
1795 ["Fetch article with id..." gnus-summary-refer-article t]
1796 ["Redisplay" gnus-summary-show-article t])))
1797 (easy-menu-define
1798 gnus-summary-article-menu gnus-summary-mode-map ""
1799 (cons "Article" innards))
1800
1801 (easy-menu-define
1802 gnus-article-commands-menu gnus-article-mode-map ""
1803 (cons "Commands" innards)))
1804
1805 (easy-menu-define
1806 gnus-summary-thread-menu gnus-summary-mode-map ""
1807 '("Threads"
1808 ["Toggle threading" gnus-summary-toggle-threads t]
1809 ["Hide threads" gnus-summary-hide-all-threads t]
1810 ["Show threads" gnus-summary-show-all-threads t]
1811 ["Hide thread" gnus-summary-hide-thread t]
1812 ["Show thread" gnus-summary-show-thread t]
1813 ["Go to next thread" gnus-summary-next-thread t]
1814 ["Go to previous thread" gnus-summary-prev-thread t]
1815 ["Go down thread" gnus-summary-down-thread t]
1816 ["Go up thread" gnus-summary-up-thread t]
1817 ["Top of thread" gnus-summary-top-thread t]
1818 ["Mark thread as read" gnus-summary-kill-thread t]
1819 ["Lower thread score" gnus-summary-lower-thread t]
1820 ["Raise thread score" gnus-summary-raise-thread t]
1821 ["Rethread current" gnus-summary-rethread-current t]))
1822
1823 (easy-menu-define
1824 gnus-summary-post-menu gnus-summary-mode-map ""
1825 '("Post"
1826 ["Post an article" gnus-summary-post-news t]
1827 ["Followup" gnus-summary-followup t]
1828 ["Followup and yank" gnus-summary-followup-with-original t]
1829 ["Supersede article" gnus-summary-supersede-article t]
1830 ["Cancel article" gnus-summary-cancel-article t]
1831 ["Reply" gnus-summary-reply t]
1832 ["Reply and yank" gnus-summary-reply-with-original t]
1833 ["Wide reply" gnus-summary-wide-reply t]
1834 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1835 ["Mail forward" gnus-summary-mail-forward t]
1836 ["Post forward" gnus-summary-post-forward t]
1837 ["Digest and mail" gnus-uu-digest-mail-forward t]
1838 ["Digest and post" gnus-uu-digest-post-forward t]
1839 ["Resend message" gnus-summary-resend-message t]
1840 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1841 ["Send a mail" gnus-summary-mail-other-window t]
1842 ["Uuencode and post" gnus-uu-post-news t]
1843 ["Followup via news" gnus-summary-followup-to-mail t]
1844 ["Followup via news and yank"
1845 gnus-summary-followup-to-mail-with-original t]
1846 ;;("Draft"
1847 ;;["Send" gnus-summary-send-draft t]
1848 ;;["Send bounced" gnus-resend-bounced-mail t])
1849 ))
1850
1851 (easy-menu-define
1852 gnus-summary-misc-menu gnus-summary-mode-map ""
1853 '("Misc"
1854 ("Mark Read"
1855 ["Mark as read" gnus-summary-mark-as-read-forward t]
1856 ["Mark same subject and select"
1857 gnus-summary-kill-same-subject-and-select t]
1858 ["Mark same subject" gnus-summary-kill-same-subject t]
1859 ["Catchup" gnus-summary-catchup t]
1860 ["Catchup all" gnus-summary-catchup-all t]
1861 ["Catchup to here" gnus-summary-catchup-to-here t]
1862 ["Catchup region" gnus-summary-mark-region-as-read t]
1863 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1864 ("Mark Various"
1865 ["Tick" gnus-summary-tick-article-forward t]
1866 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1867 ["Remove marks" gnus-summary-clear-mark-forward t]
1868 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1869 ["Set bookmark" gnus-summary-set-bookmark t]
1870 ["Remove bookmark" gnus-summary-remove-bookmark t])
1871 ("Mark Limit"
1872 ["Marks..." gnus-summary-limit-to-marks t]
1873 ["Subject..." gnus-summary-limit-to-subject t]
1874 ["Author..." gnus-summary-limit-to-author t]
1875 ["Age..." gnus-summary-limit-to-age t]
1876 ["Extra..." gnus-summary-limit-to-extra t]
1877 ["Score" gnus-summary-limit-to-score t]
1878 ["Unread" gnus-summary-limit-to-unread t]
1879 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1880 ["Articles" gnus-summary-limit-to-articles t]
1881 ["Pop limit" gnus-summary-pop-limit t]
1882 ["Show dormant" gnus-summary-limit-include-dormant t]
1883 ["Hide childless dormant"
1884 gnus-summary-limit-exclude-childless-dormant t]
1885 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1886 ["Hide marked" gnus-summary-limit-exclude-marks t]
1887 ["Show expunged" gnus-summary-show-all-expunged t])
1888 ("Process Mark"
1889 ["Set mark" gnus-summary-mark-as-processable t]
1890 ["Remove mark" gnus-summary-unmark-as-processable t]
1891 ["Remove all marks" gnus-summary-unmark-all-processable t]
1892 ["Mark above" gnus-uu-mark-over t]
1893 ["Mark series" gnus-uu-mark-series t]
1894 ["Mark region" gnus-uu-mark-region t]
1895 ["Unmark region" gnus-uu-unmark-region t]
1896 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1897 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1898 ["Mark all" gnus-uu-mark-all t]
1899 ["Mark buffer" gnus-uu-mark-buffer t]
1900 ["Mark sparse" gnus-uu-mark-sparse t]
1901 ["Mark thread" gnus-uu-mark-thread t]
1902 ["Unmark thread" gnus-uu-unmark-thread t]
1903 ("Process Mark Sets"
1904 ["Kill" gnus-summary-kill-process-mark t]
1905 ["Yank" gnus-summary-yank-process-mark
1906 gnus-newsgroup-process-stack]
1907 ["Save" gnus-summary-save-process-mark t]))
1908 ("Scroll article"
1909 ["Page forward" gnus-summary-next-page t]
1910 ["Page backward" gnus-summary-prev-page t]
1911 ["Line forward" gnus-summary-scroll-up t])
1912 ("Move"
1913 ["Next unread article" gnus-summary-next-unread-article t]
1914 ["Previous unread article" gnus-summary-prev-unread-article t]
1915 ["Next article" gnus-summary-next-article t]
1916 ["Previous article" gnus-summary-prev-article t]
1917 ["Next unread subject" gnus-summary-next-unread-subject t]
1918 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1919 ["Next article same subject" gnus-summary-next-same-subject t]
1920 ["Previous article same subject" gnus-summary-prev-same-subject t]
1921 ["First unread article" gnus-summary-first-unread-article t]
1922 ["Best unread article" gnus-summary-best-unread-article t]
1923 ["Go to subject number..." gnus-summary-goto-subject t]
1924 ["Go to article number..." gnus-summary-goto-article t]
1925 ["Go to the last article" gnus-summary-goto-last-article t]
1926 ["Pop article off history" gnus-summary-pop-article t])
1927 ("Sort"
1928 ["Sort by number" gnus-summary-sort-by-number t]
1929 ["Sort by author" gnus-summary-sort-by-author t]
1930 ["Sort by subject" gnus-summary-sort-by-subject t]
1931 ["Sort by date" gnus-summary-sort-by-date t]
1932 ["Sort by score" gnus-summary-sort-by-score t]
1933 ["Sort by lines" gnus-summary-sort-by-lines t]
1934 ["Sort by characters" gnus-summary-sort-by-chars t])
1935 ("Help"
1936 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1937 ["Describe group" gnus-summary-describe-group t]
1938 ["Read manual" gnus-info-find-node t])
1939 ("Modes"
1940 ["Pick and read" gnus-pick-mode t]
1941 ["Binary" gnus-binary-mode t])
1942 ("Regeneration"
1943 ["Regenerate" gnus-summary-prepare t]
1944 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1945 ["Toggle threading" gnus-summary-toggle-threads t])
1946 ["Filter articles..." gnus-summary-execute-command t]
1947 ["Run command on subjects..." gnus-summary-universal-argument t]
1948 ["Search articles forward..." gnus-summary-search-article-forward t]
1949 ["Search articles backward..." gnus-summary-search-article-backward t]
1950 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1951 ["Expand window" gnus-summary-expand-window t]
1952 ["Expire expirable articles" gnus-summary-expire-articles
1953 (gnus-check-backend-function
1954 'request-expire-articles gnus-newsgroup-name)]
1955 ["Edit local kill file" gnus-summary-edit-local-kill t]
1956 ["Edit main kill file" gnus-summary-edit-global-kill t]
1957 ["Edit group parameters" gnus-summary-edit-parameters t]
1958 ["Customize group parameters" gnus-summary-customize-parameters t]
1959 ["Send a bug report" gnus-bug t]
1960 ("Exit"
1961 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1962 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1963 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1964 ["Exit group" gnus-summary-exit t]
1965 ["Exit group without updating" gnus-summary-exit-no-update t]
1966 ["Exit and goto next group" gnus-summary-next-group t]
1967 ["Exit and goto prev group" gnus-summary-prev-group t]
1968 ["Reselect group" gnus-summary-reselect-current-group t]
1969 ["Rescan group" gnus-summary-rescan-group t]
1970 ["Update dribble" gnus-summary-save-newsrc t])))
1971
1972 (gnus-run-hooks 'gnus-summary-menu-hook)))
1973
1974 (defun gnus-score-set-default (var value)
1975 "A version of set that updates the GNU Emacs menu-bar."
1976 (set var value)
1977 ;; It is the message that forces the active status to be updated.
1978 (message ""))
1979
1980 (defun gnus-make-score-map (type)
1981 "Make a summary score map of type TYPE."
1982 (if t
1983 nil
1984 (let ((headers '(("author" "from" string)
1985 ("subject" "subject" string)
1986 ("article body" "body" string)
1987 ("article head" "head" string)
1988 ("xref" "xref" string)
1989 ("extra header" "extra" string)
1990 ("lines" "lines" number)
1991 ("followups to author" "followup" string)))
1992 (types '((number ("less than" <)
1993 ("greater than" >)
1994 ("equal" =))
1995 (string ("substring" s)
1996 ("exact string" e)
1997 ("fuzzy string" f)
1998 ("regexp" r))))
1999 (perms '(("temporary" (current-time-string))
2000 ("permanent" nil)
2001 ("immediate" now)))
2002 header)
2003 (list
2004 (apply
2005 'nconc
2006 (list
2007 (if (eq type 'lower)
2008 "Lower score"
2009 "Increase score"))
2010 (let (outh)
2011 (while headers
2012 (setq header (car headers))
2013 (setq outh
2014 (cons
2015 (apply
2016 'nconc
2017 (list (car header))
2018 (let ((ts (cdr (assoc (nth 2 header) types)))
2019 outt)
2020 (while ts
2021 (setq outt
2022 (cons
2023 (apply
2024 'nconc
2025 (list (caar ts))
2026 (let ((ps perms)
2027 outp)
2028 (while ps
2029 (setq outp
2030 (cons
2031 (vector
2032 (caar ps)
2033 (list
2034 'gnus-summary-score-entry
2035 (nth 1 header)
2036 (if (or (string= (nth 1 header)
2037 "head")
2038 (string= (nth 1 header)
2039 "body"))
2040 ""
2041 (list 'gnus-summary-header
2042 (nth 1 header)))
2043 (list 'quote (nth 1 (car ts)))
2044 (list 'gnus-score-delta-default
2045 nil)
2046 (nth 1 (car ps))
2047 t)
2048 t)
2049 outp))
2050 (setq ps (cdr ps)))
2051 (list (nreverse outp))))
2052 outt))
2053 (setq ts (cdr ts)))
2054 (list (nreverse outt))))
2055 outh))
2056 (setq headers (cdr headers)))
2057 (list (nreverse outh))))))))
2058
2059 \f
2060
2061 (defun gnus-summary-mode (&optional group)
2062 "Major mode for reading articles.
2063
2064 All normal editing commands are switched off.
2065 \\<gnus-summary-mode-map>
2066 Each line in this buffer represents one article. To read an
2067 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2068 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2069 respectively.
2070
2071 You can also post articles and send mail from this buffer. To
2072 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2073 of an article, type `\\[gnus-summary-reply]'.
2074
2075 There are approx. one gazillion commands you can execute in this
2076 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2077
2078 The following commands are available:
2079
2080 \\{gnus-summary-mode-map}"
2081 (interactive)
2082 (when (gnus-visual-p 'summary-menu 'menu)
2083 (gnus-summary-make-menu-bar))
2084 (kill-all-local-variables)
2085 (gnus-summary-make-local-variables)
2086 (gnus-make-thread-indent-array)
2087 (gnus-simplify-mode-line)
2088 (setq major-mode 'gnus-summary-mode)
2089 (setq mode-name "Summary")
2090 (make-local-variable 'minor-mode-alist)
2091 (use-local-map gnus-summary-mode-map)
2092 (buffer-disable-undo)
2093 (setq buffer-read-only t) ;Disable modification
2094 (setq truncate-lines t)
2095 (setq selective-display t)
2096 (setq selective-display-ellipses t) ;Display `...'
2097 (gnus-summary-set-display-table)
2098 (gnus-set-default-directory)
2099 (setq gnus-newsgroup-name group)
2100 (make-local-variable 'gnus-summary-line-format)
2101 (make-local-variable 'gnus-summary-line-format-spec)
2102 (make-local-variable 'gnus-summary-dummy-line-format)
2103 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2104 (make-local-variable 'gnus-summary-mark-positions)
2105 (make-local-hook 'pre-command-hook)
2106 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2107 (gnus-run-hooks 'gnus-summary-mode-hook)
2108 (mm-enable-multibyte-mule4)
2109 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2110 (gnus-update-summary-mark-positions))
2111
2112 (defun gnus-summary-make-local-variables ()
2113 "Make all the local summary buffer variables."
2114 (let (global)
2115 (dolist (local gnus-summary-local-variables)
2116 (if (consp local)
2117 (progn
2118 (if (eq (cdr local) 'global)
2119 ;; Copy the global value of the variable.
2120 (setq global (symbol-value (car local)))
2121 ;; Use the value from the list.
2122 (setq global (eval (cdr local))))
2123 (set (make-local-variable (car local)) global))
2124 ;; Simple nil-valued local variable.
2125 (set (make-local-variable local) nil)))))
2126
2127 (defun gnus-summary-clear-local-variables ()
2128 (let ((locals gnus-summary-local-variables))
2129 (while locals
2130 (if (consp (car locals))
2131 (and (vectorp (caar locals))
2132 (set (caar locals) nil))
2133 (and (vectorp (car locals))
2134 (set (car locals) nil)))
2135 (setq locals (cdr locals)))))
2136
2137 ;; Summary data functions.
2138
2139 (defmacro gnus-data-number (data)
2140 `(car ,data))
2141
2142 (defmacro gnus-data-set-number (data number)
2143 `(setcar ,data ,number))
2144
2145 (defmacro gnus-data-mark (data)
2146 `(nth 1 ,data))
2147
2148 (defmacro gnus-data-set-mark (data mark)
2149 `(setcar (nthcdr 1 ,data) ,mark))
2150
2151 (defmacro gnus-data-pos (data)
2152 `(nth 2 ,data))
2153
2154 (defmacro gnus-data-set-pos (data pos)
2155 `(setcar (nthcdr 2 ,data) ,pos))
2156
2157 (defmacro gnus-data-header (data)
2158 `(nth 3 ,data))
2159
2160 (defmacro gnus-data-set-header (data header)
2161 `(setf (nth 3 ,data) ,header))
2162
2163 (defmacro gnus-data-level (data)
2164 `(nth 4 ,data))
2165
2166 (defmacro gnus-data-unread-p (data)
2167 `(= (nth 1 ,data) gnus-unread-mark))
2168
2169 (defmacro gnus-data-read-p (data)
2170 `(/= (nth 1 ,data) gnus-unread-mark))
2171
2172 (defmacro gnus-data-pseudo-p (data)
2173 `(consp (nth 3 ,data)))
2174
2175 (defmacro gnus-data-find (number)
2176 `(assq ,number gnus-newsgroup-data))
2177
2178 (defmacro gnus-data-find-list (number &optional data)
2179 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2180 (memq (assq ,number bdata)
2181 bdata)))
2182
2183 (defmacro gnus-data-make (number mark pos header level)
2184 `(list ,number ,mark ,pos ,header ,level))
2185
2186 (defun gnus-data-enter (after-article number mark pos header level offset)
2187 (let ((data (gnus-data-find-list after-article)))
2188 (unless data
2189 (error "No such article: %d" after-article))
2190 (setcdr data (cons (gnus-data-make number mark pos header level)
2191 (cdr data)))
2192 (setq gnus-newsgroup-data-reverse nil)
2193 (gnus-data-update-list (cddr data) offset)))
2194
2195 (defun gnus-data-enter-list (after-article list &optional offset)
2196 (when list
2197 (let ((data (and after-article (gnus-data-find-list after-article)))
2198 (ilist list))
2199 (if (not (or data
2200 after-article))
2201 (let ((odata gnus-newsgroup-data))
2202 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2203 (when offset
2204 (gnus-data-update-list odata offset)))
2205 ;; Find the last element in the list to be spliced into the main
2206 ;; list.
2207 (while (cdr list)
2208 (setq list (cdr list)))
2209 (if (not data)
2210 (progn
2211 (setcdr list gnus-newsgroup-data)
2212 (setq gnus-newsgroup-data ilist)
2213 (when offset
2214 (gnus-data-update-list (cdr list) offset)))
2215 (setcdr list (cdr data))
2216 (setcdr data ilist)
2217 (when offset
2218 (gnus-data-update-list (cdr list) offset))))
2219 (setq gnus-newsgroup-data-reverse nil))))
2220
2221 (defun gnus-data-remove (article &optional offset)
2222 (let ((data gnus-newsgroup-data))
2223 (if (= (gnus-data-number (car data)) article)
2224 (progn
2225 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2226 gnus-newsgroup-data-reverse nil)
2227 (when offset
2228 (gnus-data-update-list gnus-newsgroup-data offset)))
2229 (while (cdr data)
2230 (when (= (gnus-data-number (cadr data)) article)
2231 (setcdr data (cddr data))
2232 (when offset
2233 (gnus-data-update-list (cdr data) offset))
2234 (setq data nil
2235 gnus-newsgroup-data-reverse nil))
2236 (setq data (cdr data))))))
2237
2238 (defmacro gnus-data-list (backward)
2239 `(if ,backward
2240 (or gnus-newsgroup-data-reverse
2241 (setq gnus-newsgroup-data-reverse
2242 (reverse gnus-newsgroup-data)))
2243 gnus-newsgroup-data))
2244
2245 (defun gnus-data-update-list (data offset)
2246 "Add OFFSET to the POS of all data entries in DATA."
2247 (setq gnus-newsgroup-data-reverse nil)
2248 (while data
2249 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2250 (setq data (cdr data))))
2251
2252 (defun gnus-summary-article-pseudo-p (article)
2253 "Say whether this article is a pseudo article or not."
2254 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2255
2256 (defmacro gnus-summary-article-sparse-p (article)
2257 "Say whether this article is a sparse article or not."
2258 `(memq ,article gnus-newsgroup-sparse))
2259
2260 (defmacro gnus-summary-article-ancient-p (article)
2261 "Say whether this article is a sparse article or not."
2262 `(memq ,article gnus-newsgroup-ancient))
2263
2264 (defun gnus-article-parent-p (number)
2265 "Say whether this article is a parent or not."
2266 (let ((data (gnus-data-find-list number)))
2267 (and (cdr data) ; There has to be an article after...
2268 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2269 (gnus-data-level (nth 1 data))))))
2270
2271 (defun gnus-article-children (number)
2272 "Return a list of all children to NUMBER."
2273 (let* ((data (gnus-data-find-list number))
2274 (level (gnus-data-level (car data)))
2275 children)
2276 (setq data (cdr data))
2277 (while (and data
2278 (= (gnus-data-level (car data)) (1+ level)))
2279 (push (gnus-data-number (car data)) children)
2280 (setq data (cdr data)))
2281 children))
2282
2283 (defmacro gnus-summary-skip-intangible ()
2284 "If the current article is intangible, then jump to a different article."
2285 '(let ((to (get-text-property (point) 'gnus-intangible)))
2286 (and to (gnus-summary-goto-subject to))))
2287
2288 (defmacro gnus-summary-article-intangible-p ()
2289 "Say whether this article is intangible or not."
2290 '(get-text-property (point) 'gnus-intangible))
2291
2292 (defun gnus-article-read-p (article)
2293 "Say whether ARTICLE is read or not."
2294 (not (or (memq article gnus-newsgroup-marked)
2295 (memq article gnus-newsgroup-unreads)
2296 (memq article gnus-newsgroup-unselected)
2297 (memq article gnus-newsgroup-dormant))))
2298
2299 ;; Some summary mode macros.
2300
2301 (defmacro gnus-summary-article-number ()
2302 "The article number of the article on the current line.
2303 If there isn's an article number here, then we return the current
2304 article number."
2305 '(progn
2306 (gnus-summary-skip-intangible)
2307 (or (get-text-property (point) 'gnus-number)
2308 (gnus-summary-last-subject))))
2309
2310 (defmacro gnus-summary-article-header (&optional number)
2311 "Return the header of article NUMBER."
2312 `(gnus-data-header (gnus-data-find
2313 ,(or number '(gnus-summary-article-number)))))
2314
2315 (defmacro gnus-summary-thread-level (&optional number)
2316 "Return the level of thread that starts with article NUMBER."
2317 `(if (and (eq gnus-summary-make-false-root 'dummy)
2318 (get-text-property (point) 'gnus-intangible))
2319 0
2320 (gnus-data-level (gnus-data-find
2321 ,(or number '(gnus-summary-article-number))))))
2322
2323 (defmacro gnus-summary-article-mark (&optional number)
2324 "Return the mark of article NUMBER."
2325 `(gnus-data-mark (gnus-data-find
2326 ,(or number '(gnus-summary-article-number)))))
2327
2328 (defmacro gnus-summary-article-pos (&optional number)
2329 "Return the position of the line of article NUMBER."
2330 `(gnus-data-pos (gnus-data-find
2331 ,(or number '(gnus-summary-article-number)))))
2332
2333 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2334 (defmacro gnus-summary-article-subject (&optional number)
2335 "Return current subject string or nil if nothing."
2336 `(let ((headers
2337 ,(if number
2338 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2339 '(gnus-data-header (assq (gnus-summary-article-number)
2340 gnus-newsgroup-data)))))
2341 (and headers
2342 (vectorp headers)
2343 (mail-header-subject headers))))
2344
2345 (defmacro gnus-summary-article-score (&optional number)
2346 "Return current article score."
2347 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2348 gnus-newsgroup-scored))
2349 gnus-summary-default-score 0))
2350
2351 (defun gnus-summary-article-children (&optional number)
2352 "Return a list of article numbers that are children of article NUMBER."
2353 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2354 (level (gnus-data-level (car data)))
2355 l children)
2356 (while (and (setq data (cdr data))
2357 (> (setq l (gnus-data-level (car data))) level))
2358 (and (= (1+ level) l)
2359 (push (gnus-data-number (car data))
2360 children)))
2361 (nreverse children)))
2362
2363 (defun gnus-summary-article-parent (&optional number)
2364 "Return the article number of the parent of article NUMBER."
2365 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2366 (gnus-data-list t)))
2367 (level (gnus-data-level (car data))))
2368 (if (zerop level)
2369 () ; This is a root.
2370 ;; We search until we find an article with a level less than
2371 ;; this one. That function has to be the parent.
2372 (while (and (setq data (cdr data))
2373 (not (< (gnus-data-level (car data)) level))))
2374 (and data (gnus-data-number (car data))))))
2375
2376 (defun gnus-unread-mark-p (mark)
2377 "Say whether MARK is the unread mark."
2378 (= mark gnus-unread-mark))
2379
2380 (defun gnus-read-mark-p (mark)
2381 "Say whether MARK is one of the marks that mark as read.
2382 This is all marks except unread, ticked, dormant, and expirable."
2383 (not (or (= mark gnus-unread-mark)
2384 (= mark gnus-ticked-mark)
2385 (= mark gnus-dormant-mark)
2386 (= mark gnus-expirable-mark))))
2387
2388 (defmacro gnus-article-mark (number)
2389 "Return the MARK of article NUMBER.
2390 This macro should only be used when computing the mark the \"first\"
2391 time; i.e., when generating the summary lines. After that,
2392 `gnus-summary-article-mark' should be used to examine the
2393 marks of articles."
2394 `(cond
2395 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2396 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2397 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2398 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2399 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2400 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2401 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2402 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2403 gnus-ancient-mark))))
2404
2405 ;; Saving hidden threads.
2406
2407 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2408 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2409
2410 (defmacro gnus-save-hidden-threads (&rest forms)
2411 "Save hidden threads, eval FORMS, and restore the hidden threads."
2412 (let ((config (make-symbol "config")))
2413 `(let ((,config (gnus-hidden-threads-configuration)))
2414 (unwind-protect
2415 (save-excursion
2416 ,@forms)
2417 (gnus-restore-hidden-threads-configuration ,config)))))
2418
2419 (defun gnus-data-compute-positions ()
2420 "Compute the positions of all articles."
2421 (setq gnus-newsgroup-data-reverse nil)
2422 (let ((data gnus-newsgroup-data))
2423 (save-excursion
2424 (gnus-save-hidden-threads
2425 (gnus-summary-show-all-threads)
2426 (goto-char (point-min))
2427 (while data
2428 (while (get-text-property (point) 'gnus-intangible)
2429 (forward-line 1))
2430 (gnus-data-set-pos (car data) (+ (point) 3))
2431 (setq data (cdr data))
2432 (forward-line 1))))))
2433
2434 (defun gnus-hidden-threads-configuration ()
2435 "Return the current hidden threads configuration."
2436 (save-excursion
2437 (let (config)
2438 (goto-char (point-min))
2439 (while (search-forward "\r" nil t)
2440 (push (1- (point)) config))
2441 config)))
2442
2443 (defun gnus-restore-hidden-threads-configuration (config)
2444 "Restore hidden threads configuration from CONFIG."
2445 (save-excursion
2446 (let (point buffer-read-only)
2447 (while (setq point (pop config))
2448 (when (and (< point (point-max))
2449 (goto-char point)
2450 (eq (char-after) ?\n))
2451 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2452
2453 ;; Various summary mode internalish functions.
2454
2455 (defun gnus-mouse-pick-article (e)
2456 (interactive "e")
2457 (mouse-set-point e)
2458 (gnus-summary-next-page nil t))
2459
2460 (defun gnus-summary-set-display-table ()
2461 "Change the display table.
2462 Odd characters have a tendency to mess
2463 up nicely formatted displays - we make all possible glyphs
2464 display only a single character."
2465
2466 ;; We start from the standard display table, if any.
2467 (let ((table (or (copy-sequence standard-display-table)
2468 (make-display-table)))
2469 (i 32))
2470 ;; Nix out all the control chars...
2471 (while (>= (setq i (1- i)) 0)
2472 (aset table i [??]))
2473 ;; ... but not newline and cr, of course. (cr is necessary for the
2474 ;; selective display).
2475 (aset table ?\n nil)
2476 (aset table ?\r nil)
2477 ;; We keep TAB as well.
2478 (aset table ?\t nil)
2479 ;; We nix out any glyphs over 126 that are not set already.
2480 (let ((i 256))
2481 (while (>= (setq i (1- i)) 127)
2482 ;; Only modify if the entry is nil.
2483 (unless (aref table i)
2484 (aset table i [??]))))
2485 (setq buffer-display-table table)))
2486
2487 (defun gnus-summary-setup-buffer (group)
2488 "Initialize summary buffer."
2489 (let ((buffer (concat "*Summary " group "*")))
2490 (if (get-buffer buffer)
2491 (progn
2492 (set-buffer buffer)
2493 (setq gnus-summary-buffer (current-buffer))
2494 (not gnus-newsgroup-prepared))
2495 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2496 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2497 (gnus-summary-mode group)
2498 (when gnus-carpal
2499 (gnus-carpal-setup-buffer 'summary))
2500 (unless gnus-single-article-buffer
2501 (make-local-variable 'gnus-article-buffer)
2502 (make-local-variable 'gnus-article-current)
2503 (make-local-variable 'gnus-original-article-buffer))
2504 (setq gnus-newsgroup-name group)
2505 t)))
2506
2507 (defun gnus-set-global-variables ()
2508 "Set the global equivalents of the buffer-local variables.
2509 They are set to the latest values they had. These reflect the summary
2510 buffer that was in action when the last article was fetched."
2511 (when (eq major-mode 'gnus-summary-mode)
2512 (setq gnus-summary-buffer (current-buffer))
2513 (let ((name gnus-newsgroup-name)
2514 (marked gnus-newsgroup-marked)
2515 (unread gnus-newsgroup-unreads)
2516 (headers gnus-current-headers)
2517 (data gnus-newsgroup-data)
2518 (summary gnus-summary-buffer)
2519 (article-buffer gnus-article-buffer)
2520 (original gnus-original-article-buffer)
2521 (gac gnus-article-current)
2522 (reffed gnus-reffed-article-number)
2523 (score-file gnus-current-score-file)
2524 (default-charset gnus-newsgroup-charset))
2525 (save-excursion
2526 (set-buffer gnus-group-buffer)
2527 (setq gnus-newsgroup-name name
2528 gnus-newsgroup-marked marked
2529 gnus-newsgroup-unreads unread
2530 gnus-current-headers headers
2531 gnus-newsgroup-data data
2532 gnus-article-current gac
2533 gnus-summary-buffer summary
2534 gnus-article-buffer article-buffer
2535 gnus-original-article-buffer original
2536 gnus-reffed-article-number reffed
2537 gnus-current-score-file score-file
2538 gnus-newsgroup-charset default-charset)
2539 ;; The article buffer also has local variables.
2540 (when (gnus-buffer-live-p gnus-article-buffer)
2541 (set-buffer gnus-article-buffer)
2542 (setq gnus-summary-buffer summary))))))
2543
2544 (defun gnus-summary-article-unread-p (article)
2545 "Say whether ARTICLE is unread or not."
2546 (memq article gnus-newsgroup-unreads))
2547
2548 (defun gnus-summary-first-article-p (&optional article)
2549 "Return whether ARTICLE is the first article in the buffer."
2550 (if (not (setq article (or article (gnus-summary-article-number))))
2551 nil
2552 (eq article (caar gnus-newsgroup-data))))
2553
2554 (defun gnus-summary-last-article-p (&optional article)
2555 "Return whether ARTICLE is the last article in the buffer."
2556 (if (not (setq article (or article (gnus-summary-article-number))))
2557 ;; All non-existent numbers are the last article. :-)
2558 t
2559 (not (cdr (gnus-data-find-list article)))))
2560
2561 (defun gnus-make-thread-indent-array ()
2562 (let ((n 200))
2563 (unless (and gnus-thread-indent-array
2564 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2565 (setq gnus-thread-indent-array (make-vector 201 "")
2566 gnus-thread-indent-array-level gnus-thread-indent-level)
2567 (while (>= n 0)
2568 (aset gnus-thread-indent-array n
2569 (make-string (* n gnus-thread-indent-level) ? ))
2570 (setq n (1- n))))))
2571
2572 (defun gnus-update-summary-mark-positions ()
2573 "Compute where the summary marks are to go."
2574 (save-excursion
2575 (when (gnus-buffer-exists-p gnus-summary-buffer)
2576 (set-buffer gnus-summary-buffer))
2577 (let ((gnus-replied-mark 129)
2578 (gnus-score-below-mark 130)
2579 (gnus-score-over-mark 130)
2580 (gnus-download-mark 131)
2581 (spec gnus-summary-line-format-spec)
2582 gnus-visual pos)
2583 (save-excursion
2584 (gnus-set-work-buffer)
2585 (let ((gnus-summary-line-format-spec spec)
2586 (gnus-newsgroup-downloadable '((0 . t))))
2587 (gnus-summary-insert-line
2588 [0 "" "" "" "" "" 0 0 "" nil] 0 nil 128 t nil "" nil 1)
2589 (goto-char (point-min))
2590 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2591 (- (point) 2)))))
2592 (goto-char (point-min))
2593 (push (cons 'replied (and (search-forward "\201" nil t)
2594 (- (point) 2)))
2595 pos)
2596 (goto-char (point-min))
2597 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2598 pos)
2599 (goto-char (point-min))
2600 (push (cons 'download
2601 (and (search-forward "\203" nil t) (- (point) 2)))
2602 pos)))
2603 (setq gnus-summary-mark-positions pos))))
2604
2605 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2606 "Insert a dummy root in the summary buffer."
2607 (beginning-of-line)
2608 (gnus-add-text-properties
2609 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2610 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2611
2612 (defun gnus-summary-from-or-to-or-newsgroups (header)
2613 (let ((to (cdr (assq 'To (mail-header-extra header))))
2614 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2615 (mail-parse-charset gnus-newsgroup-charset)
2616 (mail-parse-ignored-charsets
2617 (save-excursion (set-buffer gnus-summary-buffer)
2618 gnus-newsgroup-ignored-charsets)))
2619 (cond
2620 ((and to
2621 gnus-ignored-from-addresses
2622 (string-match gnus-ignored-from-addresses
2623 (mail-header-from header)))
2624 (concat "-> "
2625 (or (car (funcall gnus-extract-address-components
2626 (funcall
2627 gnus-decode-encoded-word-function to)))
2628 (funcall gnus-decode-encoded-word-function to))))
2629 ((and newsgroups
2630 gnus-ignored-from-addresses
2631 (string-match gnus-ignored-from-addresses
2632 (mail-header-from header)))
2633 (concat "=> " newsgroups))
2634 (t
2635 (or (car (funcall gnus-extract-address-components
2636 (mail-header-from header)))
2637 (mail-header-from header))))))
2638
2639 (defun gnus-summary-insert-line (gnus-tmp-header
2640 gnus-tmp-level gnus-tmp-current
2641 gnus-tmp-unread gnus-tmp-replied
2642 gnus-tmp-expirable gnus-tmp-subject-or-nil
2643 &optional gnus-tmp-dummy gnus-tmp-score
2644 gnus-tmp-process)
2645 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2646 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2647 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2648 (gnus-tmp-score-char
2649 (if (or (null gnus-summary-default-score)
2650 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2651 gnus-summary-zcore-fuzz))
2652 ? ;Whitespace
2653 (if (< gnus-tmp-score gnus-summary-default-score)
2654 gnus-score-below-mark gnus-score-over-mark)))
2655 (gnus-tmp-replied
2656 (cond (gnus-tmp-process gnus-process-mark)
2657 ((memq gnus-tmp-current gnus-newsgroup-cached)
2658 gnus-cached-mark)
2659 (gnus-tmp-replied gnus-replied-mark)
2660 ((memq gnus-tmp-current gnus-newsgroup-saved)
2661 gnus-saved-mark)
2662 (t gnus-unread-mark)))
2663 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2664 (gnus-tmp-name
2665 (cond
2666 ((string-match "<[^>]+> *$" gnus-tmp-from)
2667 (let ((beg (match-beginning 0)))
2668 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2669 (substring gnus-tmp-from (1+ (match-beginning 0))
2670 (1- (match-end 0))))
2671 (substring gnus-tmp-from 0 beg))))
2672 ((string-match "(.+)" gnus-tmp-from)
2673 (substring gnus-tmp-from
2674 (1+ (match-beginning 0)) (1- (match-end 0))))
2675 (t gnus-tmp-from)))
2676 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2677 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2678 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2679 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2680 (buffer-read-only nil))
2681 (when (string= gnus-tmp-name "")
2682 (setq gnus-tmp-name gnus-tmp-from))
2683 (unless (numberp gnus-tmp-lines)
2684 (setq gnus-tmp-lines 0))
2685 (gnus-put-text-property
2686 (point)
2687 (progn (eval gnus-summary-line-format-spec) (point))
2688 'gnus-number gnus-tmp-number)
2689 (when (gnus-visual-p 'summary-highlight 'highlight)
2690 (forward-line -1)
2691 (gnus-run-hooks 'gnus-summary-update-hook)
2692 (forward-line 1))))
2693
2694 (defun gnus-summary-update-line (&optional dont-update)
2695 "Update summary line after change."
2696 (when (and gnus-summary-default-score
2697 (not gnus-summary-inhibit-highlight))
2698 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2699 (article (gnus-summary-article-number))
2700 (score (gnus-summary-article-score article)))
2701 (unless dont-update
2702 (if (and gnus-summary-mark-below
2703 (< (gnus-summary-article-score)
2704 gnus-summary-mark-below))
2705 ;; This article has a low score, so we mark it as read.
2706 (when (memq article gnus-newsgroup-unreads)
2707 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2708 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2709 ;; This article was previously marked as read on account
2710 ;; of a low score, but now it has risen, so we mark it as
2711 ;; unread.
2712 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2713 (gnus-summary-update-mark
2714 (if (or (null gnus-summary-default-score)
2715 (<= (abs (- score gnus-summary-default-score))
2716 gnus-summary-zcore-fuzz))
2717 ? ;Whitespace
2718 (if (< score gnus-summary-default-score)
2719 gnus-score-below-mark gnus-score-over-mark))
2720 'score))
2721 ;; Do visual highlighting.
2722 (when (gnus-visual-p 'summary-highlight 'highlight)
2723 (gnus-run-hooks 'gnus-summary-update-hook)))))
2724
2725 (defvar gnus-tmp-new-adopts nil)
2726
2727 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2728 "Return the number of articles in THREAD.
2729 This may be 0 in some cases -- if none of the articles in
2730 the thread are to be displayed."
2731 (let* ((number
2732 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2733 (cond
2734 ((not (listp thread))
2735 1)
2736 ((and (consp thread) (cdr thread))
2737 (apply
2738 '+ 1 (mapcar
2739 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2740 ((null thread)
2741 1)
2742 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2743 1)
2744 (t 0))))
2745 (when (and level (zerop level) gnus-tmp-new-adopts)
2746 (incf number
2747 (apply '+ (mapcar
2748 'gnus-summary-number-of-articles-in-thread
2749 gnus-tmp-new-adopts))))
2750 (if char
2751 (if (> number 1) gnus-not-empty-thread-mark
2752 gnus-empty-thread-mark)
2753 number)))
2754
2755 (defun gnus-summary-set-local-parameters (group)
2756 "Go through the local params of GROUP and set all variable specs in that list."
2757 (let ((params (gnus-group-find-parameter group))
2758 elem)
2759 (while params
2760 (setq elem (car params)
2761 params (cdr params))
2762 (and (consp elem) ; Has to be a cons.
2763 (consp (cdr elem)) ; The cdr has to be a list.
2764 (symbolp (car elem)) ; Has to be a symbol in there.
2765 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2766 (ignore-errors ; So we set it.
2767 (make-local-variable (car elem))
2768 (set (car elem) (eval (nth 1 elem))))))))
2769
2770 (defun gnus-summary-read-group (group &optional show-all no-article
2771 kill-buffer no-display backward
2772 select-articles)
2773 "Start reading news in newsgroup GROUP.
2774 If SHOW-ALL is non-nil, already read articles are also listed.
2775 If NO-ARTICLE is non-nil, no article is selected initially.
2776 If NO-DISPLAY, don't generate a summary buffer."
2777 (let (result)
2778 (while (and group
2779 (null (setq result
2780 (let ((gnus-auto-select-next nil))
2781 (or (gnus-summary-read-group-1
2782 group show-all no-article
2783 kill-buffer no-display
2784 select-articles)
2785 (setq show-all nil
2786 select-articles nil)))))
2787 (eq gnus-auto-select-next 'quietly))
2788 (set-buffer gnus-group-buffer)
2789 ;; The entry function called above goes to the next
2790 ;; group automatically, so we go two groups back
2791 ;; if we are searching for the previous group.
2792 (when backward
2793 (gnus-group-prev-unread-group 2))
2794 (if (not (equal group (gnus-group-group-name)))
2795 (setq group (gnus-group-group-name))
2796 (setq group nil)))
2797 result))
2798
2799 (defun gnus-summary-read-group-1 (group show-all no-article
2800 kill-buffer no-display
2801 &optional select-articles)
2802 ;; Killed foreign groups can't be entered.
2803 (when (and (not (gnus-group-native-p group))
2804 (not (gnus-gethash group gnus-newsrc-hashtb)))
2805 (error "Dead non-native groups can't be entered"))
2806 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2807 (let* ((new-group (gnus-summary-setup-buffer group))
2808 (quit-config (gnus-group-quit-config group))
2809 (did-select (and new-group (gnus-select-newsgroup
2810 group show-all select-articles))))
2811 (cond
2812 ;; This summary buffer exists already, so we just select it.
2813 ((not new-group)
2814 (gnus-set-global-variables)
2815 (when kill-buffer
2816 (gnus-kill-or-deaden-summary kill-buffer))
2817 (gnus-configure-windows 'summary 'force)
2818 (gnus-set-mode-line 'summary)
2819 (gnus-summary-position-point)
2820 (message "")
2821 t)
2822 ;; We couldn't select this group.
2823 ((null did-select)
2824 (when (and (eq major-mode 'gnus-summary-mode)
2825 (not (equal (current-buffer) kill-buffer)))
2826 (kill-buffer (current-buffer))
2827 (if (not quit-config)
2828 (progn
2829 ;; Update the info -- marks might need to be removed,
2830 ;; for instance.
2831 (gnus-summary-update-info)
2832 (set-buffer gnus-group-buffer)
2833 (gnus-group-jump-to-group group)
2834 (gnus-group-next-unread-group 1))
2835 (gnus-handle-ephemeral-exit quit-config)))
2836 (gnus-message 3 "Can't select group")
2837 nil)
2838 ;; The user did a `C-g' while prompting for number of articles,
2839 ;; so we exit this group.
2840 ((eq did-select 'quit)
2841 (and (eq major-mode 'gnus-summary-mode)
2842 (not (equal (current-buffer) kill-buffer))
2843 (kill-buffer (current-buffer)))
2844 (when kill-buffer
2845 (gnus-kill-or-deaden-summary kill-buffer))
2846 (if (not quit-config)
2847 (progn
2848 (set-buffer gnus-group-buffer)
2849 (gnus-group-jump-to-group group)
2850 (gnus-group-next-unread-group 1)
2851 (gnus-configure-windows 'group 'force))
2852 (gnus-handle-ephemeral-exit quit-config))
2853 ;; Finally signal the quit.
2854 (signal 'quit nil))
2855 ;; The group was successfully selected.
2856 (t
2857 (gnus-set-global-variables)
2858 ;; Save the active value in effect when the group was entered.
2859 (setq gnus-newsgroup-active
2860 (gnus-copy-sequence
2861 (gnus-active gnus-newsgroup-name)))
2862 ;; You can change the summary buffer in some way with this hook.
2863 (gnus-run-hooks 'gnus-select-group-hook)
2864 ;; Set any local variables in the group parameters.
2865 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2866 (gnus-update-format-specifications
2867 nil 'summary 'summary-mode 'summary-dummy)
2868 (gnus-update-summary-mark-positions)
2869 ;; Do score processing.
2870 (when gnus-use-scoring
2871 (gnus-possibly-score-headers))
2872 ;; Check whether to fill in the gaps in the threads.
2873 (when gnus-build-sparse-threads
2874 (gnus-build-sparse-threads))
2875 ;; Find the initial limit.
2876 (if gnus-show-threads
2877 (if show-all
2878 (let ((gnus-newsgroup-dormant nil))
2879 (gnus-summary-initial-limit show-all))
2880 (gnus-summary-initial-limit show-all))
2881 ;; When untreaded, all articles are always shown.
2882 (setq gnus-newsgroup-limit
2883 (mapcar
2884 (lambda (header) (mail-header-number header))
2885 gnus-newsgroup-headers)))
2886 ;; Generate the summary buffer.
2887 (unless no-display
2888 (gnus-summary-prepare))
2889 (when gnus-use-trees
2890 (gnus-tree-open group)
2891 (setq gnus-summary-highlight-line-function
2892 'gnus-tree-highlight-article))
2893 ;; If the summary buffer is empty, but there are some low-scored
2894 ;; articles or some excluded dormants, we include these in the
2895 ;; buffer.
2896 (when (and (zerop (buffer-size))
2897 (not no-display))
2898 (cond (gnus-newsgroup-dormant
2899 (gnus-summary-limit-include-dormant))
2900 ((and gnus-newsgroup-scored show-all)
2901 (gnus-summary-limit-include-expunged t))))
2902 ;; Function `gnus-apply-kill-file' must be called in this hook.
2903 (gnus-run-hooks 'gnus-apply-kill-hook)
2904 (if (and (zerop (buffer-size))
2905 (not no-display))
2906 (progn
2907 ;; This newsgroup is empty.
2908 (gnus-summary-catchup-and-exit nil t)
2909 (gnus-message 6 "No unread news")
2910 (when kill-buffer
2911 (gnus-kill-or-deaden-summary kill-buffer))
2912 ;; Return nil from this function.
2913 nil)
2914 ;; Hide conversation thread subtrees. We cannot do this in
2915 ;; gnus-summary-prepare-hook since kill processing may not
2916 ;; work with hidden articles.
2917 (and gnus-show-threads
2918 gnus-thread-hide-subtree
2919 (gnus-summary-hide-all-threads))
2920 (when kill-buffer
2921 (gnus-kill-or-deaden-summary kill-buffer))
2922 ;; Show first unread article if requested.
2923 (if (and (not no-article)
2924 (not no-display)
2925 gnus-newsgroup-unreads
2926 gnus-auto-select-first)
2927 (progn
2928 (gnus-configure-windows 'summary)
2929 (cond
2930 ((eq gnus-auto-select-first 'best)
2931 (gnus-summary-best-unread-article))
2932 ((eq gnus-auto-select-first t)
2933 (gnus-summary-first-unread-article))
2934 ((gnus-functionp gnus-auto-select-first)
2935 (funcall gnus-auto-select-first))))
2936 ;; Don't select any articles, just move point to the first
2937 ;; article in the group.
2938 (goto-char (point-min))
2939 (gnus-summary-position-point)
2940 (gnus-configure-windows 'summary 'force)
2941 (gnus-set-mode-line 'summary))
2942 (when (get-buffer-window gnus-group-buffer t)
2943 ;; Gotta use windows, because recenter does weird stuff if
2944 ;; the current buffer ain't the displayed window.
2945 (let ((owin (selected-window)))
2946 (select-window (get-buffer-window gnus-group-buffer t))
2947 (when (gnus-group-goto-group group)
2948 (recenter))
2949 (select-window owin)))
2950 ;; Mark this buffer as "prepared".
2951 (setq gnus-newsgroup-prepared t)
2952 (gnus-run-hooks 'gnus-summary-prepared-hook)
2953 t)))))
2954
2955 (defun gnus-summary-prepare ()
2956 "Generate the summary buffer."
2957 (interactive)
2958 (let ((buffer-read-only nil))
2959 (erase-buffer)
2960 (setq gnus-newsgroup-data nil
2961 gnus-newsgroup-data-reverse nil)
2962 (gnus-run-hooks 'gnus-summary-generate-hook)
2963 ;; Generate the buffer, either with threads or without.
2964 (when gnus-newsgroup-headers
2965 (gnus-summary-prepare-threads
2966 (if gnus-show-threads
2967 (gnus-sort-gathered-threads
2968 (funcall gnus-summary-thread-gathering-function
2969 (gnus-sort-threads
2970 (gnus-cut-threads (gnus-make-threads)))))
2971 ;; Unthreaded display.
2972 (gnus-sort-articles gnus-newsgroup-headers))))
2973 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2974 ;; Call hooks for modifying summary buffer.
2975 (goto-char (point-min))
2976 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2977
2978 (defsubst gnus-general-simplify-subject (subject)
2979 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2980 (setq subject
2981 (cond
2982 ;; Truncate the subject.
2983 (gnus-simplify-subject-functions
2984 (gnus-map-function gnus-simplify-subject-functions subject))
2985 ((numberp gnus-summary-gather-subject-limit)
2986 (setq subject (gnus-simplify-subject-re subject))
2987 (if (> (length subject) gnus-summary-gather-subject-limit)
2988 (substring subject 0 gnus-summary-gather-subject-limit)
2989 subject))
2990 ;; Fuzzily simplify it.
2991 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2992 (gnus-simplify-subject-fuzzy subject))
2993 ;; Just remove the leading "Re:".
2994 (t
2995 (gnus-simplify-subject-re subject))))
2996
2997 (if (and gnus-summary-gather-exclude-subject
2998 (string-match gnus-summary-gather-exclude-subject subject))
2999 nil ; This article shouldn't be gathered
3000 subject))
3001
3002 (defun gnus-summary-simplify-subject-query ()
3003 "Query where the respool algorithm would put this article."
3004 (interactive)
3005 (gnus-summary-select-article)
3006 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3007
3008 (defun gnus-gather-threads-by-subject (threads)
3009 "Gather threads by looking at Subject headers."
3010 (if (not gnus-summary-make-false-root)
3011 threads
3012 (let ((hashtb (gnus-make-hashtable 1024))
3013 (prev threads)
3014 (result threads)
3015 subject hthread whole-subject)
3016 (while threads
3017 (setq subject (gnus-general-simplify-subject
3018 (setq whole-subject (mail-header-subject
3019 (caar threads)))))
3020 (when subject
3021 (if (setq hthread (gnus-gethash subject hashtb))
3022 (progn
3023 ;; We enter a dummy root into the thread, if we
3024 ;; haven't done that already.
3025 (unless (stringp (caar hthread))
3026 (setcar hthread (list whole-subject (car hthread))))
3027 ;; We add this new gathered thread to this gathered
3028 ;; thread.
3029 (setcdr (car hthread)
3030 (nconc (cdar hthread) (list (car threads))))
3031 ;; Remove it from the list of threads.
3032 (setcdr prev (cdr threads))
3033 (setq threads prev))
3034 ;; Enter this thread into the hash table.
3035 (gnus-sethash subject threads hashtb)))
3036 (setq prev threads)
3037 (setq threads (cdr threads)))
3038 result)))
3039
3040 (defun gnus-gather-threads-by-references (threads)
3041 "Gather threads by looking at References headers."
3042 (let ((idhashtb (gnus-make-hashtable 1024))
3043 (thhashtb (gnus-make-hashtable 1024))
3044 (prev threads)
3045 (result threads)
3046 ids references id gthread gid entered ref)
3047 (while threads
3048 (when (setq references (mail-header-references (caar threads)))
3049 (setq id (mail-header-id (caar threads))
3050 ids (gnus-split-references references)
3051 entered nil)
3052 (while (setq ref (pop ids))
3053 (setq ids (delete ref ids))
3054 (if (not (setq gid (gnus-gethash ref idhashtb)))
3055 (progn
3056 (gnus-sethash ref id idhashtb)
3057 (gnus-sethash id threads thhashtb))
3058 (setq gthread (gnus-gethash gid thhashtb))
3059 (unless entered
3060 ;; We enter a dummy root into the thread, if we
3061 ;; haven't done that already.
3062 (unless (stringp (caar gthread))
3063 (setcar gthread (list (mail-header-subject (caar gthread))
3064 (car gthread))))
3065 ;; We add this new gathered thread to this gathered
3066 ;; thread.
3067 (setcdr (car gthread)
3068 (nconc (cdar gthread) (list (car threads)))))
3069 ;; Add it into the thread hash table.
3070 (gnus-sethash id gthread thhashtb)
3071 (setq entered t)
3072 ;; Remove it from the list of threads.
3073 (setcdr prev (cdr threads))
3074 (setq threads prev))))
3075 (setq prev threads)
3076 (setq threads (cdr threads)))
3077 result))
3078
3079 (defun gnus-sort-gathered-threads (threads)
3080 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3081 (let ((result threads))
3082 (while threads
3083 (when (stringp (caar threads))
3084 (setcdr (car threads)
3085 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3086 (setq threads (cdr threads)))
3087 result))
3088
3089 (defun gnus-thread-loop-p (root thread)
3090 "Say whether ROOT is in THREAD."
3091 (let ((stack (list thread))
3092 (infloop 0)
3093 th)
3094 (while (setq thread (pop stack))
3095 (setq th (cdr thread))
3096 (while (and th
3097 (not (eq (caar th) root)))
3098 (pop th))
3099 (if th
3100 ;; We have found a loop.
3101 (let (ref-dep)
3102 (setcdr thread (delq (car th) (cdr thread)))
3103 (if (boundp (setq ref-dep (intern "none"
3104 gnus-newsgroup-dependencies)))
3105 (setcdr (symbol-value ref-dep)
3106 (nconc (cdr (symbol-value ref-dep))
3107 (list (car th))))
3108 (set ref-dep (list nil (car th))))
3109 (setq infloop 1
3110 stack nil))
3111 ;; Push all the subthreads onto the stack.
3112 (push (cdr thread) stack)))
3113 infloop))
3114
3115 (defun gnus-make-threads ()
3116 "Go through the dependency hashtb and find the roots. Return all threads."
3117 (let (threads)
3118 (while (catch 'infloop
3119 (mapatoms
3120 (lambda (refs)
3121 ;; Deal with self-referencing References loops.
3122 (when (and (car (symbol-value refs))
3123 (not (zerop
3124 (apply
3125 '+
3126 (mapcar
3127 (lambda (thread)
3128 (gnus-thread-loop-p
3129 (car (symbol-value refs)) thread))
3130 (cdr (symbol-value refs)))))))
3131 (setq threads nil)
3132 (throw 'infloop t))
3133 (unless (car (symbol-value refs))
3134 ;; These threads do not refer back to any other articles,
3135 ;; so they're roots.
3136 (setq threads (append (cdr (symbol-value refs)) threads))))
3137 gnus-newsgroup-dependencies)))
3138 threads))
3139
3140 ;; Build the thread tree.
3141 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3142 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3143
3144 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3145 if it was already present.
3146
3147 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3148 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3149 Message-IDs will be renamed be renamed to a unique Message-ID before
3150 being entered.
3151
3152 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3153 (let* ((id (mail-header-id header))
3154 (id-dep (and id (intern id dependencies)))
3155 ref ref-dep ref-header)
3156 ;; Enter this `header' in the `dependencies' table.
3157 (cond
3158 ((not id-dep)
3159 (setq header nil))
3160 ;; The first two cases do the normal part: enter a new `header'
3161 ;; in the `dependencies' table.
3162 ((not (boundp id-dep))
3163 (set id-dep (list header)))
3164 ((null (car (symbol-value id-dep)))
3165 (setcar (symbol-value id-dep) header))
3166
3167 ;; From here the `header' was already present in the
3168 ;; `dependencies' table.
3169 (force-new
3170 ;; Overrides an existing entry;
3171 ;; just set the header part of the entry.
3172 (setcar (symbol-value id-dep) header))
3173
3174 ;; Renames the existing `header' to a unique Message-ID.
3175 ((not gnus-summary-ignore-duplicates)
3176 ;; An article with this Message-ID has already been seen.
3177 ;; We rename the Message-ID.
3178 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3179 (list header))
3180 (mail-header-set-id header id))
3181
3182 ;; The last case ignores an existing entry, except it adds any
3183 ;; additional Xrefs (in case the two articles came from different
3184 ;; servers.
3185 ;; Also sets `header' to `nil' meaning that the `dependencies'
3186 ;; table was *not* modified.
3187 (t
3188 (mail-header-set-xref
3189 (car (symbol-value id-dep))
3190 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3191 "")
3192 (or (mail-header-xref header) "")))
3193 (setq header nil)))
3194
3195 (when header
3196 ;; First check if that we are not creating a References loop.
3197 (setq ref (gnus-parent-id (mail-header-references header)))
3198 (while (and ref
3199 (setq ref-dep (intern-soft ref dependencies))
3200 (boundp ref-dep)
3201 (setq ref-header (car (symbol-value ref-dep))))
3202 (if (string= id ref)
3203 ;; Yuk! This is a reference loop. Make the article be a
3204 ;; root article.
3205 (progn
3206 (mail-header-set-references (car (symbol-value id-dep)) "none")
3207 (setq ref nil))
3208 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3209 (setq ref (gnus-parent-id (mail-header-references header)))
3210 (setq ref-dep (intern (or ref "none") dependencies))
3211 (if (boundp ref-dep)
3212 (setcdr (symbol-value ref-dep)
3213 (nconc (cdr (symbol-value ref-dep))
3214 (list (symbol-value id-dep))))
3215 (set ref-dep (list nil (symbol-value id-dep)))))
3216 header))
3217
3218 (defun gnus-build-sparse-threads ()
3219 (let ((headers gnus-newsgroup-headers)
3220 (mail-parse-charset gnus-newsgroup-charset)
3221 (gnus-summary-ignore-duplicates t)
3222 header references generation relations
3223 subject child end new-child date)
3224 ;; First we create an alist of generations/relations, where
3225 ;; generations is how much we trust the relation, and the relation
3226 ;; is parent/child.
3227 (gnus-message 7 "Making sparse threads...")
3228 (save-excursion
3229 (nnheader-set-temp-buffer " *gnus sparse threads*")
3230 (while (setq header (pop headers))
3231 (when (and (setq references (mail-header-references header))
3232 (not (string= references "")))
3233 (insert references)
3234 (setq child (mail-header-id header)
3235 subject (mail-header-subject header)
3236 date (mail-header-date header)
3237 generation 0)
3238 (while (search-backward ">" nil t)
3239 (setq end (1+ (point)))
3240 (when (search-backward "<" nil t)
3241 (setq new-child (buffer-substring (point) end))
3242 (push (list (incf generation)
3243 child (setq child new-child)
3244 subject date)
3245 relations)))
3246 (when child
3247 (push (list (1+ generation) child nil subject) relations))
3248 (erase-buffer)))
3249 (kill-buffer (current-buffer)))
3250 ;; Sort over trustworthiness.
3251 (mapcar
3252 (lambda (relation)
3253 (when (gnus-dependencies-add-header
3254 (make-full-mail-header
3255 gnus-reffed-article-number
3256 (nth 3 relation) "" (or (nth 4 relation) "")
3257 (nth 1 relation)
3258 (or (nth 2 relation) "") 0 0 "")
3259 gnus-newsgroup-dependencies nil)
3260 (push gnus-reffed-article-number gnus-newsgroup-limit)
3261 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3262 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3263 gnus-newsgroup-reads)
3264 (decf gnus-reffed-article-number)))
3265 (sort relations 'car-less-than-car))
3266 (gnus-message 7 "Making sparse threads...done")))
3267
3268 (defun gnus-build-old-threads ()
3269 ;; Look at all the articles that refer back to old articles, and
3270 ;; fetch the headers for the articles that aren't there. This will
3271 ;; build complete threads - if the roots haven't been expired by the
3272 ;; server, that is.
3273 (let ((mail-parse-charset gnus-newsgroup-charset)
3274 id heads)
3275 (mapatoms
3276 (lambda (refs)
3277 (when (not (car (symbol-value refs)))
3278 (setq heads (cdr (symbol-value refs)))
3279 (while heads
3280 (if (memq (mail-header-number (caar heads))
3281 gnus-newsgroup-dormant)
3282 (setq heads (cdr heads))
3283 (setq id (symbol-name refs))
3284 (while (and (setq id (gnus-build-get-header id))
3285 (not (car (gnus-id-to-thread id)))))
3286 (setq heads nil)))))
3287 gnus-newsgroup-dependencies)))
3288
3289 ;; This function has to be called with point after the article number
3290 ;; on the beginning of the line.
3291 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3292 (let ((eol (gnus-point-at-eol))
3293 (buffer (current-buffer))
3294 header)
3295
3296 ;; overview: [num subject from date id refs chars lines misc]
3297 (unwind-protect
3298 (progn
3299 (narrow-to-region (point) eol)
3300 (unless (eobp)
3301 (forward-char))
3302
3303 (setq header
3304 (make-full-mail-header
3305 number ; number
3306 (funcall gnus-decode-encoded-word-function
3307 (nnheader-nov-field)) ; subject
3308 (funcall gnus-decode-encoded-word-function
3309 (nnheader-nov-field)) ; from
3310 (nnheader-nov-field) ; date
3311 (nnheader-nov-read-message-id) ; id
3312 (nnheader-nov-field) ; refs
3313 (nnheader-nov-read-integer) ; chars
3314 (nnheader-nov-read-integer) ; lines
3315 (unless (eobp)
3316 (if (looking-at "Xref: ")
3317 (goto-char (match-end 0)))
3318 (nnheader-nov-field)) ; Xref
3319 (nnheader-nov-parse-extra)))) ; extra
3320
3321 (widen))
3322
3323 (when gnus-alter-header-function
3324 (funcall gnus-alter-header-function header))
3325 (gnus-dependencies-add-header header dependencies force-new)))
3326
3327 (defun gnus-build-get-header (id)
3328 "Look through the buffer of NOV lines and find the header to ID.
3329 Enter this line into the dependencies hash table, and return
3330 the id of the parent article (if any)."
3331 (let ((deps gnus-newsgroup-dependencies)
3332 found header)
3333 (prog1
3334 (save-excursion
3335 (set-buffer nntp-server-buffer)
3336 (let ((case-fold-search nil))
3337 (goto-char (point-min))
3338 (while (and (not found)
3339 (search-forward id nil t))
3340 (beginning-of-line)
3341 (setq found (looking-at
3342 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3343 (regexp-quote id))))
3344 (or found (beginning-of-line 2)))
3345 (when found
3346 (beginning-of-line)
3347 (and
3348 (setq header (gnus-nov-parse-line
3349 (read (current-buffer)) deps))
3350 (gnus-parent-id (mail-header-references header))))))
3351 (when header
3352 (let ((number (mail-header-number header)))
3353 (push number gnus-newsgroup-limit)
3354 (push header gnus-newsgroup-headers)
3355 (if (memq number gnus-newsgroup-unselected)
3356 (progn
3357 (push number gnus-newsgroup-unreads)
3358 (setq gnus-newsgroup-unselected
3359 (delq number gnus-newsgroup-unselected)))
3360 (push number gnus-newsgroup-ancient)))))))
3361
3362 (defun gnus-build-all-threads ()
3363 "Read all the headers."
3364 (let ((gnus-summary-ignore-duplicates t)
3365 (mail-parse-charset gnus-newsgroup-charset)
3366 (dependencies gnus-newsgroup-dependencies)
3367 header article)
3368 (save-excursion
3369 (set-buffer nntp-server-buffer)
3370 (let ((case-fold-search nil))
3371 (goto-char (point-min))
3372 (while (not (eobp))
3373 (ignore-errors
3374 (setq article (read (current-buffer))
3375 header (gnus-nov-parse-line article dependencies)))
3376 (when header
3377 (save-excursion
3378 (set-buffer gnus-summary-buffer)
3379 (push header gnus-newsgroup-headers)
3380 (if (memq (setq article (mail-header-number header))
3381 gnus-newsgroup-unselected)
3382 (progn
3383 (push article gnus-newsgroup-unreads)
3384 (setq gnus-newsgroup-unselected
3385 (delq article gnus-newsgroup-unselected)))
3386 (push article gnus-newsgroup-ancient)))
3387 (forward-line 1)))))))
3388
3389 (defun gnus-summary-update-article-line (article header)
3390 "Update the line for ARTICLE using HEADERS."
3391 (let* ((id (mail-header-id header))
3392 (thread (gnus-id-to-thread id)))
3393 (unless thread
3394 (error "Article in no thread"))
3395 ;; Update the thread.
3396 (setcar thread header)
3397 (gnus-summary-goto-subject article)
3398 (let* ((datal (gnus-data-find-list article))
3399 (data (car datal))
3400 (length (when (cdr datal)
3401 (- (gnus-data-pos data)
3402 (gnus-data-pos (cadr datal)))))
3403 (buffer-read-only nil)
3404 (level (gnus-summary-thread-level)))
3405 (gnus-delete-line)
3406 (gnus-summary-insert-line
3407 header level nil (gnus-article-mark article)
3408 (memq article gnus-newsgroup-replied)
3409 (memq article gnus-newsgroup-expirable)
3410 ;; Only insert the Subject string when it's different
3411 ;; from the previous Subject string.
3412 (if (and
3413 gnus-show-threads
3414 (gnus-subject-equal
3415 (condition-case ()
3416 (mail-header-subject
3417 (gnus-data-header
3418 (cadr
3419 (gnus-data-find-list
3420 article
3421 (gnus-data-list t)))))
3422 ;; Error on the side of excessive subjects.
3423 (error ""))
3424 (mail-header-subject header)))
3425 ""
3426 (mail-header-subject header))
3427 nil (cdr (assq article gnus-newsgroup-scored))
3428 (memq article gnus-newsgroup-processable))
3429 (when length
3430 (gnus-data-update-list
3431 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3432
3433 (defun gnus-summary-update-article (article &optional iheader)
3434 "Update ARTICLE in the summary buffer."
3435 (set-buffer gnus-summary-buffer)
3436 (let* ((header (gnus-summary-article-header article))
3437 (id (mail-header-id header))
3438 (data (gnus-data-find article))
3439 (thread (gnus-id-to-thread id))
3440 (references (mail-header-references header))
3441 (parent
3442 (gnus-id-to-thread
3443 (or (gnus-parent-id
3444 (when (and references
3445 (not (equal "" references)))
3446 references))
3447 "none")))
3448 (buffer-read-only nil)
3449 (old (car thread)))
3450 (when thread
3451 (unless iheader
3452 (setcar thread nil)
3453 (when parent
3454 (delq thread parent)))
3455 (if (gnus-summary-insert-subject id header)
3456 ;; Set the (possibly) new article number in the data structure.
3457 (gnus-data-set-number data (gnus-id-to-article id))
3458 (setcar thread old)
3459 nil))))
3460
3461 (defun gnus-rebuild-thread (id &optional line)
3462 "Rebuild the thread containing ID.
3463 If LINE, insert the rebuilt thread starting on line LINE."
3464 (let ((buffer-read-only nil)
3465 old-pos current thread data)
3466 (if (not gnus-show-threads)
3467 (setq thread (list (car (gnus-id-to-thread id))))
3468 ;; Get the thread this article is part of.
3469 (setq thread (gnus-remove-thread id)))
3470 (setq old-pos (gnus-point-at-bol))
3471 (setq current (save-excursion
3472 (and (zerop (forward-line -1))
3473 (gnus-summary-article-number))))
3474 ;; If this is a gathered thread, we have to go some re-gathering.
3475 (when (stringp (car thread))
3476 (let ((subject (car thread))
3477 roots thr)
3478 (setq thread (cdr thread))
3479 (while thread
3480 (unless (memq (setq thr (gnus-id-to-thread
3481 (gnus-root-id
3482 (mail-header-id (caar thread)))))
3483 roots)
3484 (push thr roots))
3485 (setq thread (cdr thread)))
3486 ;; We now have all (unique) roots.
3487 (if (= (length roots) 1)
3488 ;; All the loose roots are now one solid root.
3489 (setq thread (car roots))
3490 (setq thread (cons subject (gnus-sort-threads roots))))))
3491 (let (threads)
3492 ;; We then insert this thread into the summary buffer.
3493 (when line
3494 (goto-char (point-min))
3495 (forward-line (1- line)))
3496 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3497 (if gnus-show-threads
3498 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3499 (gnus-summary-prepare-unthreaded thread))
3500 (setq data (nreverse gnus-newsgroup-data))
3501 (setq threads gnus-newsgroup-threads))
3502 ;; We splice the new data into the data structure.
3503 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3504 ;;!!! then we want to insert at the beginning of the buffer.
3505 ;;!!! That happens to be true with Gnus now, but that may
3506 ;;!!! change in the future. Perhaps.
3507 (gnus-data-enter-list
3508 (if line nil current) data (- (point) old-pos))
3509 (setq gnus-newsgroup-threads
3510 (nconc threads gnus-newsgroup-threads))
3511 (gnus-data-compute-positions))))
3512
3513 (defun gnus-number-to-header (number)
3514 "Return the header for article NUMBER."
3515 (let ((headers gnus-newsgroup-headers))
3516 (while (and headers
3517 (not (= number (mail-header-number (car headers)))))
3518 (pop headers))
3519 (when headers
3520 (car headers))))
3521
3522 (defun gnus-parent-headers (in-headers &optional generation)
3523 "Return the headers of the GENERATIONeth parent of HEADERS."
3524 (unless generation
3525 (setq generation 1))
3526 (let ((parent t)
3527 (headers in-headers)
3528 references)
3529 (while (and parent
3530 (not (zerop generation))
3531 (setq references (mail-header-references headers)))
3532 (setq headers (if (and references
3533 (setq parent (gnus-parent-id references)))
3534 (car (gnus-id-to-thread parent))
3535 nil))
3536 (decf generation))
3537 (and (not (eq headers in-headers))
3538 headers)))
3539
3540 (defun gnus-id-to-thread (id)
3541 "Return the (sub-)thread where ID appears."
3542 (gnus-gethash id gnus-newsgroup-dependencies))
3543
3544 (defun gnus-id-to-article (id)
3545 "Return the article number of ID."
3546 (let ((thread (gnus-id-to-thread id)))
3547 (when (and thread
3548 (car thread))
3549 (mail-header-number (car thread)))))
3550
3551 (defun gnus-id-to-header (id)
3552 "Return the article headers of ID."
3553 (car (gnus-id-to-thread id)))
3554
3555 (defun gnus-article-displayed-root-p (article)
3556 "Say whether ARTICLE is a root(ish) article."
3557 (let ((level (gnus-summary-thread-level article))
3558 (refs (mail-header-references (gnus-summary-article-header article)))
3559 particle)
3560 (cond
3561 ((null level) nil)
3562 ((zerop level) t)
3563 ((null refs) t)
3564 ((null (gnus-parent-id refs)) t)
3565 ((and (= 1 level)
3566 (null (setq particle (gnus-id-to-article
3567 (gnus-parent-id refs))))
3568 (null (gnus-summary-thread-level particle)))))))
3569
3570 (defun gnus-root-id (id)
3571 "Return the id of the root of the thread where ID appears."
3572 (let (last-id prev)
3573 (while (and id (setq prev (car (gnus-id-to-thread id))))
3574 (setq last-id id
3575 id (gnus-parent-id (mail-header-references prev))))
3576 last-id))
3577
3578 (defun gnus-articles-in-thread (thread)
3579 "Return the list of articles in THREAD."
3580 (cons (mail-header-number (car thread))
3581 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3582
3583 (defun gnus-remove-thread (id &optional dont-remove)
3584 "Remove the thread that has ID in it."
3585 (let (headers thread last-id)
3586 ;; First go up in this thread until we find the root.
3587 (setq last-id (gnus-root-id id)
3588 headers (message-flatten-list (gnus-id-to-thread last-id)))
3589 ;; We have now found the real root of this thread. It might have
3590 ;; been gathered into some loose thread, so we have to search
3591 ;; through the threads to find the thread we wanted.
3592 (let ((threads gnus-newsgroup-threads)
3593 sub)
3594 (while threads
3595 (setq sub (car threads))
3596 (if (stringp (car sub))
3597 ;; This is a gathered thread, so we look at the roots
3598 ;; below it to find whether this article is in this
3599 ;; gathered root.
3600 (progn
3601 (setq sub (cdr sub))
3602 (while sub
3603 (when (member (caar sub) headers)
3604 (setq thread (car threads)
3605 threads nil
3606 sub nil))
3607 (setq sub (cdr sub))))
3608 ;; It's an ordinary thread, so we check it.
3609 (when (eq (car sub) (car headers))
3610 (setq thread sub
3611 threads nil)))
3612 (setq threads (cdr threads)))
3613 ;; If this article is in no thread, then it's a root.
3614 (if thread
3615 (unless dont-remove
3616 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3617 (setq thread (gnus-id-to-thread last-id)))
3618 (when thread
3619 (prog1
3620 thread ; We return this thread.
3621 (unless dont-remove
3622 (if (stringp (car thread))
3623 (progn
3624 ;; If we use dummy roots, then we have to remove the
3625 ;; dummy root as well.
3626 (when (eq gnus-summary-make-false-root 'dummy)
3627 ;; We go to the dummy root by going to
3628 ;; the first sub-"thread", and then one line up.
3629 (gnus-summary-goto-article
3630 (mail-header-number (caadr thread)))
3631 (forward-line -1)
3632 (gnus-delete-line)
3633 (gnus-data-compute-positions))
3634 (setq thread (cdr thread))
3635 (while thread
3636 (gnus-remove-thread-1 (car thread))
3637 (setq thread (cdr thread))))
3638 (gnus-remove-thread-1 thread))))))))
3639
3640 (defun gnus-remove-thread-1 (thread)
3641 "Remove the thread THREAD recursively."
3642 (let ((number (mail-header-number (pop thread)))
3643 d)
3644 (setq thread (reverse thread))
3645 (while thread
3646 (gnus-remove-thread-1 (pop thread)))
3647 (when (setq d (gnus-data-find number))
3648 (goto-char (gnus-data-pos d))
3649 (gnus-summary-show-thread)
3650 (gnus-data-remove
3651 number
3652 (- (gnus-point-at-bol)
3653 (prog1
3654 (1+ (gnus-point-at-eol))
3655 (gnus-delete-line)))))))
3656
3657 (defun gnus-sort-threads-1 (threads func)
3658 (sort (mapcar (lambda (thread)
3659 (cons (car thread)
3660 (and (cdr thread)
3661 (gnus-sort-threads-1 (cdr thread) func))))
3662 threads) func))
3663
3664 (defun gnus-sort-threads (threads)
3665 "Sort THREADS."
3666 (if (not gnus-thread-sort-functions)
3667 threads
3668 (gnus-message 8 "Sorting threads...")
3669 (prog1
3670 (gnus-sort-threads-1
3671 threads
3672 (gnus-make-sort-function gnus-thread-sort-functions))
3673 (gnus-message 8 "Sorting threads...done"))))
3674
3675 (defun gnus-sort-articles (articles)
3676 "Sort ARTICLES."
3677 (when gnus-article-sort-functions
3678 (gnus-message 7 "Sorting articles...")
3679 (prog1
3680 (setq gnus-newsgroup-headers
3681 (sort articles (gnus-make-sort-function
3682 gnus-article-sort-functions)))
3683 (gnus-message 7 "Sorting articles...done"))))
3684
3685 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3686 (defmacro gnus-thread-header (thread)
3687 "Return header of first article in THREAD.
3688 Note that THREAD must never, ever be anything else than a variable -
3689 using some other form will lead to serious barfage."
3690 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3691 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3692 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
3693 (vector thread) 2))
3694
3695 (defsubst gnus-article-sort-by-number (h1 h2)
3696 "Sort articles by article number."
3697 (< (mail-header-number h1)
3698 (mail-header-number h2)))
3699
3700 (defun gnus-thread-sort-by-number (h1 h2)
3701 "Sort threads by root article number."
3702 (gnus-article-sort-by-number
3703 (gnus-thread-header h1) (gnus-thread-header h2)))
3704
3705 (defsubst gnus-article-sort-by-lines (h1 h2)
3706 "Sort articles by article Lines header."
3707 (< (mail-header-lines h1)
3708 (mail-header-lines h2)))
3709
3710 (defun gnus-thread-sort-by-lines (h1 h2)
3711 "Sort threads by root article Lines header."
3712 (gnus-article-sort-by-lines
3713 (gnus-thread-header h1) (gnus-thread-header h2)))
3714
3715 (defsubst gnus-article-sort-by-chars (h1 h2)
3716 "Sort articles by octet length."
3717 (< (mail-header-chars h1)
3718 (mail-header-chars h2)))
3719
3720 (defun gnus-thread-sort-by-chars (h1 h2)
3721 "Sort threads by root article octet length."
3722 (gnus-article-sort-by-chars
3723 (gnus-thread-header h1) (gnus-thread-header h2)))
3724
3725 (defsubst gnus-article-sort-by-author (h1 h2)
3726 "Sort articles by root author."
3727 (string-lessp
3728 (let ((extract (funcall
3729 gnus-extract-address-components
3730 (mail-header-from h1))))
3731 (or (car extract) (cadr extract) ""))
3732 (let ((extract (funcall
3733 gnus-extract-address-components
3734 (mail-header-from h2))))
3735 (or (car extract) (cadr extract) ""))))
3736
3737 (defun gnus-thread-sort-by-author (h1 h2)
3738 "Sort threads by root author."
3739 (gnus-article-sort-by-author
3740 (gnus-thread-header h1) (gnus-thread-header h2)))
3741
3742 (defsubst gnus-article-sort-by-subject (h1 h2)
3743 "Sort articles by root subject."
3744 (string-lessp
3745 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3746 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3747
3748 (defun gnus-thread-sort-by-subject (h1 h2)
3749 "Sort threads by root subject."
3750 (gnus-article-sort-by-subject
3751 (gnus-thread-header h1) (gnus-thread-header h2)))
3752
3753 (defsubst gnus-article-sort-by-date (h1 h2)
3754 "Sort articles by root article date."
3755 (time-less-p
3756 (gnus-date-get-time (mail-header-date h1))
3757 (gnus-date-get-time (mail-header-date h2))))
3758
3759 (defun gnus-thread-sort-by-date (h1 h2)
3760 "Sort threads by root article date."
3761 (gnus-article-sort-by-date
3762 (gnus-thread-header h1) (gnus-thread-header h2)))
3763
3764 (defsubst gnus-article-sort-by-score (h1 h2)
3765 "Sort articles by root article score.
3766 Unscored articles will be counted as having a score of zero."
3767 (> (or (cdr (assq (mail-header-number h1)
3768 gnus-newsgroup-scored))
3769 gnus-summary-default-score 0)
3770 (or (cdr (assq (mail-header-number h2)
3771 gnus-newsgroup-scored))
3772 gnus-summary-default-score 0)))
3773
3774 (defun gnus-thread-sort-by-score (h1 h2)
3775 "Sort threads by root article score."
3776 (gnus-article-sort-by-score
3777 (gnus-thread-header h1) (gnus-thread-header h2)))
3778
3779 (defun gnus-thread-sort-by-total-score (h1 h2)
3780 "Sort threads by the sum of all scores in the thread.
3781 Unscored articles will be counted as having a score of zero."
3782 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3783
3784 (defun gnus-thread-total-score (thread)
3785 ;; This function find the total score of THREAD.
3786 (cond ((null thread)
3787 0)
3788 ((consp thread)
3789 (if (stringp (car thread))
3790 (apply gnus-thread-score-function 0
3791 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3792 (gnus-thread-total-score-1 thread)))
3793 (t
3794 (gnus-thread-total-score-1 (list thread)))))
3795
3796 (defun gnus-thread-total-score-1 (root)
3797 ;; This function find the total score of the thread below ROOT.
3798 (setq root (car root))
3799 (apply gnus-thread-score-function
3800 (or (append
3801 (mapcar 'gnus-thread-total-score
3802 (cdr (gnus-id-to-thread (mail-header-id root))))
3803 (when (> (mail-header-number root) 0)
3804 (list (or (cdr (assq (mail-header-number root)
3805 gnus-newsgroup-scored))
3806 gnus-summary-default-score 0))))
3807 (list gnus-summary-default-score)
3808 '(0))))
3809
3810 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3811 (defvar gnus-tmp-prev-subject nil)
3812 (defvar gnus-tmp-false-parent nil)
3813 (defvar gnus-tmp-root-expunged nil)
3814 (defvar gnus-tmp-dummy-line nil)
3815
3816 (defvar gnus-tmp-header)
3817 (defun gnus-extra-header (type &optional header)
3818 "Return the extra header of TYPE."
3819 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3820 ""))
3821
3822 (defun gnus-summary-prepare-threads (threads)
3823 "Prepare summary buffer from THREADS and indentation LEVEL.
3824 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3825 or a straight list of headers."
3826 (gnus-message 7 "Generating summary...")
3827
3828 (setq gnus-newsgroup-threads threads)
3829 (beginning-of-line)
3830
3831 (let ((gnus-tmp-level 0)
3832 (default-score (or gnus-summary-default-score 0))
3833 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3834 thread number subject stack state gnus-tmp-gathered beg-match
3835 new-roots gnus-tmp-new-adopts thread-end
3836 gnus-tmp-header gnus-tmp-unread
3837 gnus-tmp-replied gnus-tmp-subject-or-nil
3838 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3839 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3840 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3841
3842 (setq gnus-tmp-prev-subject nil)
3843
3844 (if (vectorp (car threads))
3845 ;; If this is a straight (sic) list of headers, then a
3846 ;; threaded summary display isn't required, so we just create
3847 ;; an unthreaded one.
3848 (gnus-summary-prepare-unthreaded threads)
3849
3850 ;; Do the threaded display.
3851
3852 (while (or threads stack gnus-tmp-new-adopts new-roots)
3853
3854 (if (and (= gnus-tmp-level 0)
3855 (or (not stack)
3856 (= (caar stack) 0))
3857 (not gnus-tmp-false-parent)
3858 (or gnus-tmp-new-adopts new-roots))
3859 (if gnus-tmp-new-adopts
3860 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3861 thread (list (car gnus-tmp-new-adopts))
3862 gnus-tmp-header (caar thread)
3863 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3864 (when new-roots
3865 (setq thread (list (car new-roots))
3866 gnus-tmp-header (caar thread)
3867 new-roots (cdr new-roots))))
3868
3869 (if threads
3870 ;; If there are some threads, we do them before the
3871 ;; threads on the stack.
3872 (setq thread threads
3873 gnus-tmp-header (caar thread))
3874 ;; There were no current threads, so we pop something off
3875 ;; the stack.
3876 (setq state (car stack)
3877 gnus-tmp-level (car state)
3878 thread (cdr state)
3879 stack (cdr stack)
3880 gnus-tmp-header (caar thread))))
3881
3882 (setq gnus-tmp-false-parent nil)
3883 (setq gnus-tmp-root-expunged nil)
3884 (setq thread-end nil)
3885
3886 (if (stringp gnus-tmp-header)
3887 ;; The header is a dummy root.
3888 (cond
3889 ((eq gnus-summary-make-false-root 'adopt)
3890 ;; We let the first article adopt the rest.
3891 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3892 (cddar thread)))
3893 (setq gnus-tmp-gathered
3894 (nconc (mapcar
3895 (lambda (h) (mail-header-number (car h)))
3896 (cddar thread))
3897 gnus-tmp-gathered))
3898 (setq thread (cons (list (caar thread)
3899 (cadar thread))
3900 (cdr thread)))
3901 (setq gnus-tmp-level -1
3902 gnus-tmp-false-parent t))
3903 ((eq gnus-summary-make-false-root 'empty)
3904 ;; We print adopted articles with empty subject fields.
3905 (setq gnus-tmp-gathered
3906 (nconc (mapcar
3907 (lambda (h) (mail-header-number (car h)))
3908 (cddar thread))
3909 gnus-tmp-gathered))
3910 (setq gnus-tmp-level -1))
3911 ((eq gnus-summary-make-false-root 'dummy)
3912 ;; We remember that we probably want to output a dummy
3913 ;; root.
3914 (setq gnus-tmp-dummy-line gnus-tmp-header)
3915 (setq gnus-tmp-prev-subject gnus-tmp-header))
3916 (t
3917 ;; We do not make a root for the gathered
3918 ;; sub-threads at all.
3919 (setq gnus-tmp-level -1)))
3920
3921 (setq number (mail-header-number gnus-tmp-header)
3922 subject (mail-header-subject gnus-tmp-header))
3923
3924 (cond
3925 ;; If the thread has changed subject, we might want to make
3926 ;; this subthread into a root.
3927 ((and (null gnus-thread-ignore-subject)
3928 (not (zerop gnus-tmp-level))
3929 gnus-tmp-prev-subject
3930 (not (inline
3931 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3932 (setq new-roots (nconc new-roots (list (car thread)))
3933 thread-end t
3934 gnus-tmp-header nil))
3935 ;; If the article lies outside the current limit,
3936 ;; then we do not display it.
3937 ((not (memq number gnus-newsgroup-limit))
3938 (setq gnus-tmp-gathered
3939 (nconc (mapcar
3940 (lambda (h) (mail-header-number (car h)))
3941 (cdar thread))
3942 gnus-tmp-gathered))
3943 (setq gnus-tmp-new-adopts (if (cdar thread)
3944 (append gnus-tmp-new-adopts
3945 (cdar thread))
3946 gnus-tmp-new-adopts)
3947 thread-end t
3948 gnus-tmp-header nil)
3949 (when (zerop gnus-tmp-level)
3950 (setq gnus-tmp-root-expunged t)))
3951 ;; Perhaps this article is to be marked as read?
3952 ((and gnus-summary-mark-below
3953 (< (or (cdr (assq number gnus-newsgroup-scored))
3954 default-score)
3955 gnus-summary-mark-below)
3956 ;; Don't touch sparse articles.
3957 (not (gnus-summary-article-sparse-p number))
3958 (not (gnus-summary-article-ancient-p number)))
3959 (setq gnus-newsgroup-unreads
3960 (delq number gnus-newsgroup-unreads))
3961 (if gnus-newsgroup-auto-expire
3962 (push number gnus-newsgroup-expirable)
3963 (push (cons number gnus-low-score-mark)
3964 gnus-newsgroup-reads))))
3965
3966 (when gnus-tmp-header
3967 ;; We may have an old dummy line to output before this
3968 ;; article.
3969 (when (and gnus-tmp-dummy-line
3970 (gnus-subject-equal
3971 gnus-tmp-dummy-line
3972 (mail-header-subject gnus-tmp-header)))
3973 (gnus-summary-insert-dummy-line
3974 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3975 (setq gnus-tmp-dummy-line nil))
3976
3977 ;; Compute the mark.
3978 (setq gnus-tmp-unread (gnus-article-mark number))
3979
3980 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3981 gnus-tmp-header gnus-tmp-level)
3982 gnus-newsgroup-data)
3983
3984 ;; Actually insert the line.
3985 (setq
3986 gnus-tmp-subject-or-nil
3987 (cond
3988 ((and gnus-thread-ignore-subject
3989 gnus-tmp-prev-subject
3990 (not (inline (gnus-subject-equal
3991 gnus-tmp-prev-subject subject))))
3992 subject)
3993 ((zerop gnus-tmp-level)
3994 (if (and (eq gnus-summary-make-false-root 'empty)
3995 (memq number gnus-tmp-gathered)
3996 gnus-tmp-prev-subject
3997 (inline (gnus-subject-equal
3998 gnus-tmp-prev-subject subject)))
3999 gnus-summary-same-subject
4000 subject))
4001 (t gnus-summary-same-subject)))
4002 (if (and (eq gnus-summary-make-false-root 'adopt)
4003 (= gnus-tmp-level 1)
4004 (memq number gnus-tmp-gathered))
4005 (setq gnus-tmp-opening-bracket ?\<
4006 gnus-tmp-closing-bracket ?\>)
4007 (setq gnus-tmp-opening-bracket ?\[
4008 gnus-tmp-closing-bracket ?\]))
4009 (setq
4010 gnus-tmp-indentation
4011 (aref gnus-thread-indent-array gnus-tmp-level)
4012 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4013 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4014 gnus-summary-default-score 0)
4015 gnus-tmp-score-char
4016 (if (or (null gnus-summary-default-score)
4017 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4018 gnus-summary-zcore-fuzz))
4019 ? ;Whitespace
4020 (if (< gnus-tmp-score gnus-summary-default-score)
4021 gnus-score-below-mark gnus-score-over-mark))
4022 gnus-tmp-replied
4023 (cond ((memq number gnus-newsgroup-processable)
4024 gnus-process-mark)
4025 ((memq number gnus-newsgroup-cached)
4026 gnus-cached-mark)
4027 ((memq number gnus-newsgroup-replied)
4028 gnus-replied-mark)
4029 ((memq number gnus-newsgroup-saved)
4030 gnus-saved-mark)
4031 (t gnus-unread-mark))
4032 gnus-tmp-from (mail-header-from gnus-tmp-header)
4033 gnus-tmp-name
4034 (cond
4035 ((string-match "<[^>]+> *$" gnus-tmp-from)
4036 (setq beg-match (match-beginning 0))
4037 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
4038 (substring gnus-tmp-from (1+ (match-beginning 0))
4039 (1- (match-end 0))))
4040 (substring gnus-tmp-from 0 beg-match)))
4041 ((string-match "(.+)" gnus-tmp-from)
4042 (substring gnus-tmp-from
4043 (1+ (match-beginning 0)) (1- (match-end 0))))
4044 (t gnus-tmp-from)))
4045 (when (string= gnus-tmp-name "")
4046 (setq gnus-tmp-name gnus-tmp-from))
4047 (unless (numberp gnus-tmp-lines)
4048 (setq gnus-tmp-lines 0))
4049 (gnus-put-text-property
4050 (point)
4051 (progn (eval gnus-summary-line-format-spec) (point))
4052 'gnus-number number)
4053 (when gnus-visual-p
4054 (forward-line -1)
4055 (gnus-run-hooks 'gnus-summary-update-hook)
4056 (forward-line 1))
4057
4058 (setq gnus-tmp-prev-subject subject)))
4059
4060 (when (nth 1 thread)
4061 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
4062 (incf gnus-tmp-level)
4063 (setq threads (if thread-end nil (cdar thread)))
4064 (unless threads
4065 (setq gnus-tmp-level 0)))))
4066 (gnus-message 7 "Generating summary...done"))
4067
4068 (defun gnus-summary-prepare-unthreaded (headers)
4069 "Generate an unthreaded summary buffer based on HEADERS."
4070 (let (header number mark)
4071
4072 (beginning-of-line)
4073
4074 (while headers
4075 ;; We may have to root out some bad articles...
4076 (when (memq (setq number (mail-header-number
4077 (setq header (pop headers))))
4078 gnus-newsgroup-limit)
4079 ;; Mark article as read when it has a low score.
4080 (when (and gnus-summary-mark-below
4081 (< (or (cdr (assq number gnus-newsgroup-scored))
4082 gnus-summary-default-score 0)
4083 gnus-summary-mark-below)
4084 (not (gnus-summary-article-ancient-p number)))
4085 (setq gnus-newsgroup-unreads
4086 (delq number gnus-newsgroup-unreads))
4087 (if gnus-newsgroup-auto-expire
4088 (push number gnus-newsgroup-expirable)
4089 (push (cons number gnus-low-score-mark)
4090 gnus-newsgroup-reads)))
4091
4092 (setq mark (gnus-article-mark number))
4093 (push (gnus-data-make number mark (1+ (point)) header 0)
4094 gnus-newsgroup-data)
4095 (gnus-summary-insert-line
4096 header 0 number
4097 mark (memq number gnus-newsgroup-replied)
4098 (memq number gnus-newsgroup-expirable)
4099 (mail-header-subject header) nil
4100 (cdr (assq number gnus-newsgroup-scored))
4101 (memq number gnus-newsgroup-processable))))))
4102
4103 (defun gnus-summary-remove-list-identifiers ()
4104 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4105 (let ((regexp (if (stringp gnus-list-identifiers)
4106 gnus-list-identifiers
4107 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
4108 (dolist (header gnus-newsgroup-headers)
4109 (when (string-match (concat "\\(\\(\\(Re: +\\)?\\(" regexp
4110 " *\\)\\)+\\(Re: +\\)?\\)")
4111 (mail-header-subject header))
4112 (mail-header-set-subject
4113 header (concat (substring (mail-header-subject header)
4114 0 (match-beginning 1))
4115 (or
4116 (match-string 3 (mail-header-subject header))
4117 (match-string 5 (mail-header-subject header)))
4118 (substring (mail-header-subject header)
4119 (match-end 1))))))))
4120
4121 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4122 "Select newsgroup GROUP.
4123 If READ-ALL is non-nil, all articles in the group are selected.
4124 If SELECT-ARTICLES, only select those articles from GROUP."
4125 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4126 ;;!!! Dirty hack; should be removed.
4127 (gnus-summary-ignore-duplicates
4128 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4129 t
4130 gnus-summary-ignore-duplicates))
4131 (info (nth 2 entry))
4132 articles fetched-articles cached)
4133
4134 (unless (gnus-check-server
4135 (setq gnus-current-select-method
4136 (gnus-find-method-for-group group)))
4137 (error "Couldn't open server"))
4138
4139 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4140 (gnus-activate-group group) ; Or we can activate it...
4141 (progn ; Or we bug out.
4142 (when (equal major-mode 'gnus-summary-mode)
4143 (kill-buffer (current-buffer)))
4144 (error "Couldn't request group %s: %s"
4145 group (gnus-status-message group))))
4146
4147 (unless (gnus-request-group group t)
4148 (when (equal major-mode 'gnus-summary-mode)
4149 (kill-buffer (current-buffer)))
4150 (error "Couldn't request group %s: %s"
4151 group (gnus-status-message group)))
4152
4153 (setq gnus-newsgroup-name group)
4154 (setq gnus-newsgroup-unselected nil)
4155 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4156 (gnus-summary-setup-default-charset)
4157
4158 ;; Adjust and set lists of article marks.
4159 (when info
4160 (gnus-adjust-marked-articles info))
4161
4162 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4163 (when (gnus-virtual-group-p group)
4164 (setq cached gnus-newsgroup-cached))
4165
4166 (setq gnus-newsgroup-unreads
4167 (gnus-set-difference
4168 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
4169 gnus-newsgroup-dormant))
4170
4171 (setq gnus-newsgroup-processable nil)
4172
4173 (gnus-update-read-articles group gnus-newsgroup-unreads)
4174
4175 (if (setq articles select-articles)
4176 (setq gnus-newsgroup-unselected
4177 (gnus-sorted-intersection
4178 gnus-newsgroup-unreads
4179 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4180 (setq articles (gnus-articles-to-read group read-all)))
4181
4182 (cond
4183 ((null articles)
4184 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4185 'quit)
4186 ((eq articles 0) nil)
4187 (t
4188 ;; Init the dependencies hash table.
4189 (setq gnus-newsgroup-dependencies
4190 (gnus-make-hashtable (length articles)))
4191 (gnus-set-global-variables)
4192 ;; Retrieve the headers and read them in.
4193 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
4194 (setq gnus-newsgroup-headers
4195 (if (eq 'nov
4196 (setq gnus-headers-retrieved-by
4197 (gnus-retrieve-headers
4198 articles gnus-newsgroup-name
4199 ;; We might want to fetch old headers, but
4200 ;; not if there is only 1 article.
4201 (and (or (and
4202 (not (eq gnus-fetch-old-headers 'some))
4203 (not (numberp gnus-fetch-old-headers)))
4204 (> (length articles) 1))
4205 gnus-fetch-old-headers))))
4206 (gnus-get-newsgroup-headers-xover
4207 articles nil nil gnus-newsgroup-name t)
4208 (gnus-get-newsgroup-headers)))
4209 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4210
4211 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4212 (when cached
4213 (setq gnus-newsgroup-cached cached))
4214
4215 ;; Suppress duplicates?
4216 (when gnus-suppress-duplicates
4217 (gnus-dup-suppress-articles))
4218
4219 ;; Set the initial limit.
4220 (setq gnus-newsgroup-limit (copy-sequence articles))
4221 ;; Remove canceled articles from the list of unread articles.
4222 (setq gnus-newsgroup-unreads
4223 (gnus-set-sorted-intersection
4224 gnus-newsgroup-unreads
4225 (setq fetched-articles
4226 (mapcar (lambda (headers) (mail-header-number headers))
4227 gnus-newsgroup-headers))))
4228 ;; Removed marked articles that do not exist.
4229 (gnus-update-missing-marks
4230 (gnus-sorted-complement fetched-articles articles))
4231 ;; We might want to build some more threads first.
4232 (when (and gnus-fetch-old-headers
4233 (eq gnus-headers-retrieved-by 'nov))
4234 (if (eq gnus-fetch-old-headers 'invisible)
4235 (gnus-build-all-threads)
4236 (gnus-build-old-threads)))
4237 ;; Let the Gnus agent mark articles as read.
4238 (when gnus-agent
4239 (gnus-agent-get-undownloaded-list))
4240 ;; Remove list identifiers from subject
4241 (when gnus-list-identifiers
4242 (gnus-summary-remove-list-identifiers))
4243 ;; Check whether auto-expire is to be done in this group.
4244 (setq gnus-newsgroup-auto-expire
4245 (gnus-group-auto-expirable-p group))
4246 ;; Set up the article buffer now, if necessary.
4247 (unless gnus-single-article-buffer
4248 (gnus-article-setup-buffer))
4249 ;; First and last article in this newsgroup.
4250 (when gnus-newsgroup-headers
4251 (setq gnus-newsgroup-begin
4252 (mail-header-number (car gnus-newsgroup-headers))
4253 gnus-newsgroup-end
4254 (mail-header-number
4255 (gnus-last-element gnus-newsgroup-headers))))
4256 ;; GROUP is successfully selected.
4257 (or gnus-newsgroup-headers t)))))
4258
4259 (defun gnus-articles-to-read (group &optional read-all)
4260 "Find out what articles the user wants to read."
4261 (let* ((articles
4262 ;; Select all articles if `read-all' is non-nil, or if there
4263 ;; are no unread articles.
4264 (if (or read-all
4265 (and (zerop (length gnus-newsgroup-marked))
4266 (zerop (length gnus-newsgroup-unreads)))
4267 (eq (gnus-group-find-parameter group 'display)
4268 'all))
4269 (or
4270 (gnus-uncompress-range (gnus-active group))
4271 (gnus-cache-articles-in-group group))
4272 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4273 (copy-sequence gnus-newsgroup-unreads))
4274 '<)))
4275 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4276 (scored (length scored-list))
4277 (number (length articles))
4278 (marked (+ (length gnus-newsgroup-marked)
4279 (length gnus-newsgroup-dormant)))
4280 (select
4281 (cond
4282 ((numberp read-all)
4283 read-all)
4284 (t
4285 (condition-case ()
4286 (cond
4287 ((and (or (<= scored marked) (= scored number))
4288 (numberp gnus-large-newsgroup)
4289 (> number gnus-large-newsgroup))
4290 (let ((input
4291 (read-string
4292 (format
4293 "How many articles from %s (default %d): "
4294 (gnus-limit-string gnus-newsgroup-name 35)
4295 number))))
4296 (if (string-match "^[ \t]*$" input) number input)))
4297 ((and (> scored marked) (< scored number)
4298 (> (- scored number) 20))
4299 (let ((input
4300 (read-string
4301 (format "%s %s (%d scored, %d total): "
4302 "How many articles from"
4303 group scored number))))
4304 (if (string-match "^[ \t]*$" input)
4305 number input)))
4306 (t number))
4307 (quit
4308 (message "Quit getting the articles to read")
4309 nil))))))
4310 (setq select (if (stringp select) (string-to-number select) select))
4311 (if (or (null select) (zerop select))
4312 select
4313 (if (and (not (zerop scored)) (<= (abs select) scored))
4314 (progn
4315 (setq articles (sort scored-list '<))
4316 (setq number (length articles)))
4317 (setq articles (copy-sequence articles)))
4318
4319 (when (< (abs select) number)
4320 (if (< select 0)
4321 ;; Select the N oldest articles.
4322 (setcdr (nthcdr (1- (abs select)) articles) nil)
4323 ;; Select the N most recent articles.
4324 (setq articles (nthcdr (- number select) articles))))
4325 (setq gnus-newsgroup-unselected
4326 (gnus-sorted-intersection
4327 gnus-newsgroup-unreads
4328 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4329 (when gnus-alter-articles-to-read-function
4330 (setq gnus-newsgroup-unreads
4331 (sort
4332 (funcall gnus-alter-articles-to-read-function
4333 gnus-newsgroup-name gnus-newsgroup-unreads)
4334 '<)))
4335 articles)))
4336
4337 (defun gnus-killed-articles (killed articles)
4338 (let (out)
4339 (while articles
4340 (when (inline (gnus-member-of-range (car articles) killed))
4341 (push (car articles) out))
4342 (setq articles (cdr articles)))
4343 out))
4344
4345 (defun gnus-uncompress-marks (marks)
4346 "Uncompress the mark ranges in MARKS."
4347 (let ((uncompressed '(score bookmark))
4348 out)
4349 (while marks
4350 (if (memq (caar marks) uncompressed)
4351 (push (car marks) out)
4352 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4353 (setq marks (cdr marks)))
4354 out))
4355
4356 (defun gnus-adjust-marked-articles (info)
4357 "Set all article lists and remove all marks that are no longer valid."
4358 (let* ((marked-lists (gnus-info-marks info))
4359 (active (gnus-active (gnus-info-group info)))
4360 (min (car active))
4361 (max (cdr active))
4362 (types gnus-article-mark-lists)
4363 (uncompressed '(score bookmark killed))
4364 marks var articles article mark)
4365
4366 (while marked-lists
4367 (setq marks (pop marked-lists))
4368 (set (setq var (intern (format "gnus-newsgroup-%s"
4369 (car (rassq (setq mark (car marks))
4370 types)))))
4371 (if (memq (car marks) uncompressed) (cdr marks)
4372 (gnus-uncompress-range (cdr marks))))
4373
4374 (setq articles (symbol-value var))
4375
4376 ;; All articles have to be subsets of the active articles.
4377 (cond
4378 ;; Adjust "simple" lists.
4379 ((memq mark '(tick dormant expire reply save))
4380 (while articles
4381 (when (or (< (setq article (pop articles)) min) (> article max))
4382 (set var (delq article (symbol-value var))))))
4383 ;; Adjust assocs.
4384 ((memq mark uncompressed)
4385 (when (not (listp (cdr (symbol-value var))))
4386 (set var (list (symbol-value var))))
4387 (when (not (listp (cdr articles)))
4388 (setq articles (list articles)))
4389 (while articles
4390 (when (or (not (consp (setq article (pop articles))))
4391 (< (car article) min)
4392 (> (car article) max))
4393 (set var (delq article (symbol-value var))))))))))
4394
4395 (defun gnus-update-missing-marks (missing)
4396 "Go through the list of MISSING articles and remove them from the mark lists."
4397 (when missing
4398 (let ((types gnus-article-mark-lists)
4399 var m)
4400 ;; Go through all types.
4401 (while types
4402 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4403 (when (symbol-value var)
4404 ;; This list has articles. So we delete all missing articles
4405 ;; from it.
4406 (setq m missing)
4407 (while m
4408 (set var (delq (pop m) (symbol-value var)))))))))
4409
4410 (defun gnus-update-marks ()
4411 "Enter the various lists of marked articles into the newsgroup info list."
4412 (let ((types gnus-article-mark-lists)
4413 (info (gnus-get-info gnus-newsgroup-name))
4414 (uncompressed '(score bookmark killed))
4415 type list newmarked symbol delta-marks)
4416 (when info
4417 ;; Add all marks lists to the list of marks lists.
4418 (while (setq type (pop types))
4419 (setq list (symbol-value
4420 (setq symbol
4421 (intern (format "gnus-newsgroup-%s"
4422 (car type))))))
4423
4424 (when list
4425 ;; Get rid of the entries of the articles that have the
4426 ;; default score.
4427 (when (and (eq (cdr type) 'score)
4428 gnus-save-score
4429 list)
4430 (let* ((arts list)
4431 (prev (cons nil list))
4432 (all prev))
4433 (while arts
4434 (if (or (not (consp (car arts)))
4435 (= (cdar arts) gnus-summary-default-score))
4436 (setcdr prev (cdr arts))
4437 (setq prev arts))
4438 (setq arts (cdr arts)))
4439 (setq list (cdr all)))))
4440
4441 (unless (memq (cdr type) uncompressed)
4442 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
4443
4444 (when (gnus-check-backend-function
4445 'request-set-mark gnus-newsgroup-name)
4446 ;; propagate flags to server, with the following exceptions:
4447 ;; uncompressed:s are not proper flags (they are cons cells)
4448 ;; cache is a internal gnus flag
4449 ;; download are local to one gnus installation (well)
4450 ;; unsend are for nndraft groups only
4451 ;; xxx: generality of this? this suits nnimap anyway
4452 (unless (memq (cdr type) (append '(cache download unsend)
4453 uncompressed))
4454 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4455 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
4456 (add (gnus-remove-from-range
4457 (gnus-copy-sequence list) old)))
4458 (when add
4459 (push (list add 'add (list (cdr type))) delta-marks))
4460 (when del
4461 (push (list del 'del (list (cdr type))) delta-marks)))))
4462
4463 (when list
4464 (push (cons (cdr type) list) newmarked)))
4465
4466 (when delta-marks
4467 (unless (gnus-check-group gnus-newsgroup-name)
4468 (error "Can't open server for %s" gnus-newsgroup-name))
4469 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4470
4471 ;; Enter these new marks into the info of the group.
4472 (if (nthcdr 3 info)
4473 (setcar (nthcdr 3 info) newmarked)
4474 ;; Add the marks lists to the end of the info.
4475 (when newmarked
4476 (setcdr (nthcdr 2 info) (list newmarked))))
4477
4478 ;; Cut off the end of the info if there's nothing else there.
4479 (let ((i 5))
4480 (while (and (> i 2)
4481 (not (nth i info)))
4482 (when (nthcdr (decf i) info)
4483 (setcdr (nthcdr i info) nil)))))))
4484
4485 (defun gnus-set-mode-line (where)
4486 "Set the mode line of the article or summary buffers.
4487 If WHERE is `summary', the summary mode line format will be used."
4488 ;; Is this mode line one we keep updated?
4489 (when (and (memq where gnus-updated-mode-lines)
4490 (symbol-value
4491 (intern (format "gnus-%s-mode-line-format-spec" where))))
4492 (let (mode-string)
4493 (save-excursion
4494 ;; We evaluate this in the summary buffer since these
4495 ;; variables are buffer-local to that buffer.
4496 (set-buffer gnus-summary-buffer)
4497 ;; We bind all these variables that are used in the `eval' form
4498 ;; below.
4499 (let* ((mformat (symbol-value
4500 (intern
4501 (format "gnus-%s-mode-line-format-spec" where))))
4502 (gnus-tmp-group-name (gnus-group-name-decode
4503 gnus-newsgroup-name
4504 (gnus-group-name-charset
4505 nil
4506 gnus-newsgroup-name)))
4507 (gnus-tmp-article-number (or gnus-current-article 0))
4508 (gnus-tmp-unread gnus-newsgroup-unreads)
4509 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4510 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4511 (gnus-tmp-unread-and-unselected
4512 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4513 (zerop gnus-tmp-unselected))
4514 "")
4515 ((zerop gnus-tmp-unselected)
4516 (format "{%d more}" gnus-tmp-unread-and-unticked))
4517 (t (format "{%d(+%d) more}"
4518 gnus-tmp-unread-and-unticked
4519 gnus-tmp-unselected))))
4520 (gnus-tmp-subject
4521 (if (and gnus-current-headers
4522 (vectorp gnus-current-headers))
4523 (gnus-mode-string-quote
4524 (mail-header-subject gnus-current-headers))
4525 ""))
4526 bufname-length max-len
4527 gnus-tmp-header);; passed as argument to any user-format-funcs
4528 (setq mode-string (eval mformat))
4529 (setq bufname-length (if (string-match "%b" mode-string)
4530 (- (length
4531 (buffer-name
4532 (if (eq where 'summary)
4533 nil
4534 (get-buffer gnus-article-buffer))))
4535 2)
4536 0))
4537 (setq max-len (max 4 (if gnus-mode-non-string-length
4538 (- (window-width)
4539 gnus-mode-non-string-length
4540 bufname-length)
4541 (length mode-string))))
4542 ;; We might have to chop a bit of the string off...
4543 (when (> (length mode-string) max-len)
4544 (setq mode-string
4545 (concat (truncate-string-to-width mode-string (- max-len 3))
4546 "...")))
4547 ;; Pad the mode string a bit.
4548 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4549 ;; Update the mode line.
4550 (setq mode-line-buffer-identification
4551 (gnus-mode-line-buffer-identification (list mode-string)))
4552 (set-buffer-modified-p t))))
4553
4554 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4555 "Go through the HEADERS list and add all Xrefs to a hash table.
4556 The resulting hash table is returned, or nil if no Xrefs were found."
4557 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4558 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4559 (xref-hashtb (gnus-make-hashtable))
4560 start group entry number xrefs header)
4561 (while headers
4562 (setq header (pop headers))
4563 (when (and (setq xrefs (mail-header-xref header))
4564 (not (memq (setq number (mail-header-number header))
4565 unreads)))
4566 (setq start 0)
4567 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4568 (setq start (match-end 0))
4569 (setq group (if prefix
4570 (concat prefix (substring xrefs (match-beginning 1)
4571 (match-end 1)))
4572 (substring xrefs (match-beginning 1) (match-end 1))))
4573 (setq number
4574 (string-to-int (substring xrefs (match-beginning 2)
4575 (match-end 2))))
4576 (if (setq entry (gnus-gethash group xref-hashtb))
4577 (setcdr entry (cons number (cdr entry)))
4578 (gnus-sethash group (cons number nil) xref-hashtb)))))
4579 (and start xref-hashtb)))
4580
4581 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4582 "Look through all the headers and mark the Xrefs as read."
4583 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4584 name entry info xref-hashtb idlist method nth4)
4585 (save-excursion
4586 (set-buffer gnus-group-buffer)
4587 (when (setq xref-hashtb
4588 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4589 (mapatoms
4590 (lambda (group)
4591 (unless (string= from-newsgroup (setq name (symbol-name group)))
4592 (setq idlist (symbol-value group))
4593 ;; Dead groups are not updated.
4594 (and (prog1
4595 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4596 info (nth 2 entry))
4597 (when (stringp (setq nth4 (gnus-info-method info)))
4598 (setq nth4 (gnus-server-to-method nth4))))
4599 ;; Only do the xrefs if the group has the same
4600 ;; select method as the group we have just read.
4601 (or (gnus-methods-equal-p
4602 nth4 (gnus-find-method-for-group from-newsgroup))
4603 virtual
4604 (equal nth4 (setq method (gnus-find-method-for-group
4605 from-newsgroup)))
4606 (and (equal (car nth4) (car method))
4607 (equal (nth 1 nth4) (nth 1 method))))
4608 gnus-use-cross-reference
4609 (or (not (eq gnus-use-cross-reference t))
4610 virtual
4611 ;; Only do cross-references on subscribed
4612 ;; groups, if that is what is wanted.
4613 (<= (gnus-info-level info) gnus-level-subscribed))
4614 (gnus-group-make-articles-read name idlist))))
4615 xref-hashtb)))))
4616
4617 (defun gnus-compute-read-articles (group articles)
4618 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4619 (info (nth 2 entry))
4620 (active (gnus-active group))
4621 ninfo)
4622 (when entry
4623 ;; First peel off all invalid article numbers.
4624 (when active
4625 (let ((ids articles)
4626 id first)
4627 (while (setq id (pop ids))
4628 (when (and first (> id (cdr active)))
4629 ;; We'll end up in this situation in one particular
4630 ;; obscure situation. If you re-scan a group and get
4631 ;; a new article that is cross-posted to a different
4632 ;; group that has not been re-scanned, you might get
4633 ;; crossposted article that has a higher number than
4634 ;; Gnus believes possible. So we re-activate this
4635 ;; group as well. This might mean doing the
4636 ;; crossposting thingy will *increase* the number
4637 ;; of articles in some groups. Tsk, tsk.
4638 (setq active (or (gnus-activate-group group) active)))
4639 (when (or (> id (cdr active))
4640 (< id (car active)))
4641 (setq articles (delq id articles))))))
4642 ;; If the read list is nil, we init it.
4643 (if (and active
4644 (null (gnus-info-read info))
4645 (> (car active) 1))
4646 (setq ninfo (cons 1 (1- (car active))))
4647 (setq ninfo (gnus-info-read info)))
4648 ;; Then we add the read articles to the range.
4649 (gnus-add-to-range
4650 ninfo (setq articles (sort articles '<))))))
4651
4652 (defun gnus-group-make-articles-read (group articles)
4653 "Update the info of GROUP to say that ARTICLES are read."
4654 (let* ((num 0)
4655 (entry (gnus-gethash group gnus-newsrc-hashtb))
4656 (info (nth 2 entry))
4657 (active (gnus-active group))
4658 range)
4659 (when entry
4660 (setq range (gnus-compute-read-articles group articles))
4661 (save-excursion
4662 (set-buffer gnus-group-buffer)
4663 (gnus-undo-register
4664 `(progn
4665 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4666 (gnus-info-set-read ',info ',(gnus-info-read info))
4667 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4668 (gnus-group-update-group ,group t))))
4669 ;; Add the read articles to the range.
4670 (gnus-info-set-read info range)
4671 ;; Then we have to re-compute how many unread
4672 ;; articles there are in this group.
4673 (when active
4674 (cond
4675 ((not range)
4676 (setq num (- (1+ (cdr active)) (car active))))
4677 ((not (listp (cdr range)))
4678 (setq num (- (cdr active) (- (1+ (cdr range))
4679 (car range)))))
4680 (t
4681 (while range
4682 (if (numberp (car range))
4683 (setq num (1+ num))
4684 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4685 (setq range (cdr range)))
4686 (setq num (- (cdr active) num))))
4687 ;; Update the number of unread articles.
4688 (setcar entry num)
4689 ;; Update the group buffer.
4690 (gnus-group-update-group group t)))))
4691
4692 (defvar gnus-newsgroup-none-id 0)
4693
4694 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4695 (let ((cur nntp-server-buffer)
4696 (dependencies
4697 (or dependencies
4698 (save-excursion (set-buffer gnus-summary-buffer)
4699 gnus-newsgroup-dependencies)))
4700 headers id end ref
4701 (mail-parse-charset gnus-newsgroup-charset)
4702 (mail-parse-ignored-charsets
4703 (save-excursion (condition-case nil
4704 (set-buffer gnus-summary-buffer)
4705 (error))
4706 gnus-newsgroup-ignored-charsets)))
4707 (save-excursion
4708 (set-buffer nntp-server-buffer)
4709 ;; Translate all TAB characters into SPACE characters.
4710 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4711 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4712 (gnus-run-hooks 'gnus-parse-headers-hook)
4713 (let ((case-fold-search t)
4714 in-reply-to header p lines chars)
4715 (goto-char (point-min))
4716 ;; Search to the beginning of the next header. Error messages
4717 ;; do not begin with 2 or 3.
4718 (while (re-search-forward "^[23][0-9]+ " nil t)
4719 (setq id nil
4720 ref nil)
4721 ;; This implementation of this function, with nine
4722 ;; search-forwards instead of the one re-search-forward and
4723 ;; a case (which basically was the old function) is actually
4724 ;; about twice as fast, even though it looks messier. You
4725 ;; can't have everything, I guess. Speed and elegance
4726 ;; doesn't always go hand in hand.
4727 (setq
4728 header
4729 (vector
4730 ;; Number.
4731 (prog1
4732 (read cur)
4733 (end-of-line)
4734 (setq p (point))
4735 (narrow-to-region (point)
4736 (or (and (search-forward "\n.\n" nil t)
4737 (- (point) 2))
4738 (point))))
4739 ;; Subject.
4740 (progn
4741 (goto-char p)
4742 (if (search-forward "\nsubject: " nil t)
4743 (funcall gnus-decode-encoded-word-function
4744 (nnheader-header-value))
4745 "(none)"))
4746 ;; From.
4747 (progn
4748 (goto-char p)
4749 (if (or (search-forward "\nfrom: " nil t)
4750 (search-forward "\nfrom:" nil t))
4751 (funcall gnus-decode-encoded-word-function
4752 (nnheader-header-value))
4753 "(nobody)"))
4754 ;; Date.
4755 (progn
4756 (goto-char p)
4757 (if (search-forward "\ndate: " nil t)
4758 (nnheader-header-value) ""))
4759 ;; Message-ID.
4760 (progn
4761 (goto-char p)
4762 (setq id (if (re-search-forward
4763 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4764 ;; We do it this way to make sure the Message-ID
4765 ;; is (somewhat) syntactically valid.
4766 (buffer-substring (match-beginning 1)
4767 (match-end 1))
4768 ;; If there was no message-id, we just fake one
4769 ;; to make subsequent routines simpler.
4770 (nnheader-generate-fake-message-id))))
4771 ;; References.
4772 (progn
4773 (goto-char p)
4774 (if (search-forward "\nreferences: " nil t)
4775 (progn
4776 (setq end (point))
4777 (prog1
4778 (nnheader-header-value)
4779 (setq ref
4780 (buffer-substring
4781 (progn
4782 (end-of-line)
4783 (search-backward ">" end t)
4784 (1+ (point)))
4785 (progn
4786 (search-backward "<" end t)
4787 (point))))))
4788 ;; Get the references from the in-reply-to header if there
4789 ;; were no references and the in-reply-to header looks
4790 ;; promising.
4791 (if (and (search-forward "\nin-reply-to: " nil t)
4792 (setq in-reply-to (nnheader-header-value))
4793 (string-match "<[^>]+>" in-reply-to))
4794 (let (ref2)
4795 (setq ref (substring in-reply-to (match-beginning 0)
4796 (match-end 0)))
4797 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4798 (setq ref2 (substring in-reply-to (match-beginning 0)
4799 (match-end 0)))
4800 (when (> (length ref2) (length ref))
4801 (setq ref ref2)))
4802 ref)
4803 (setq ref nil))))
4804 ;; Chars.
4805 (progn
4806 (goto-char p)
4807 (if (search-forward "\nchars: " nil t)
4808 (if (numberp (setq chars (ignore-errors (read cur))))
4809 chars 0)
4810 0))
4811 ;; Lines.
4812 (progn
4813 (goto-char p)
4814 (if (search-forward "\nlines: " nil t)
4815 (if (numberp (setq lines (ignore-errors (read cur))))
4816 lines 0)
4817 0))
4818 ;; Xref.
4819 (progn
4820 (goto-char p)
4821 (and (search-forward "\nxref: " nil t)
4822 (nnheader-header-value)))
4823 ;; Extra.
4824 (when gnus-extra-headers
4825 (let ((extra gnus-extra-headers)
4826 out)
4827 (while extra
4828 (goto-char p)
4829 (when (search-forward
4830 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4831 (push (cons (car extra) (nnheader-header-value))
4832 out))
4833 (pop extra))
4834 out))))
4835 (when (equal id ref)
4836 (setq ref nil))
4837
4838 (when gnus-alter-header-function
4839 (funcall gnus-alter-header-function header)
4840 (setq id (mail-header-id header)
4841 ref (gnus-parent-id (mail-header-references header))))
4842
4843 (when (setq header
4844 (gnus-dependencies-add-header
4845 header dependencies force-new))
4846 (push header headers))
4847 (goto-char (point-max))
4848 (widen))
4849 (nreverse headers)))))
4850
4851 ;; Goes through the xover lines and returns a list of vectors
4852 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4853 force-new dependencies
4854 group also-fetch-heads)
4855 "Parse the news overview data in the server buffer.
4856 Return a list of headers that match SEQUENCE (see
4857 `nntp-retrieve-headers')."
4858 ;; Get the Xref when the users reads the articles since most/some
4859 ;; NNTP servers do not include Xrefs when using XOVER.
4860 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4861 (let ((mail-parse-charset gnus-newsgroup-charset)
4862 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4863 (cur nntp-server-buffer)
4864 (dependencies (or dependencies gnus-newsgroup-dependencies))
4865 number headers header)
4866 (save-excursion
4867 (set-buffer nntp-server-buffer)
4868 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4869 ;; Allow the user to mangle the headers before parsing them.
4870 (gnus-run-hooks 'gnus-parse-headers-hook)
4871 (goto-char (point-min))
4872 (while (not (eobp))
4873 (condition-case ()
4874 (while (and sequence (not (eobp)))
4875 (setq number (read cur))
4876 (while (and sequence
4877 (< (car sequence) number))
4878 (setq sequence (cdr sequence)))
4879 (and sequence
4880 (eq number (car sequence))
4881 (progn
4882 (setq sequence (cdr sequence))
4883 (setq header (inline
4884 (gnus-nov-parse-line
4885 number dependencies force-new))))
4886 (push header headers))
4887 (forward-line 1))
4888 (error
4889 (gnus-error 4 "Strange nov line (%d)"
4890 (count-lines (point-min) (point)))))
4891 (forward-line 1))
4892 ;; A common bug in inn is that if you have posted an article and
4893 ;; then retrieves the active file, it will answer correctly --
4894 ;; the new article is included. However, a NOV entry for the
4895 ;; article may not have been generated yet, so this may fail.
4896 ;; We work around this problem by retrieving the last few
4897 ;; headers using HEAD.
4898 (if (or (not also-fetch-heads)
4899 (not sequence))
4900 ;; We (probably) got all the headers.
4901 (nreverse headers)
4902 (let ((gnus-nov-is-evil t))
4903 (nconc
4904 (nreverse headers)
4905 (when (gnus-retrieve-headers sequence group)
4906 (gnus-get-newsgroup-headers))))))))
4907
4908 (defun gnus-article-get-xrefs ()
4909 "Fill in the Xref value in `gnus-current-headers', if necessary.
4910 This is meant to be called in `gnus-article-internal-prepare-hook'."
4911 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4912 gnus-current-headers)))
4913 (or (not gnus-use-cross-reference)
4914 (not headers)
4915 (and (mail-header-xref headers)
4916 (not (string= (mail-header-xref headers) "")))
4917 (let ((case-fold-search t)
4918 xref)
4919 (save-restriction
4920 (nnheader-narrow-to-headers)
4921 (goto-char (point-min))
4922 (when (or (and (not (eobp))
4923 (eq (downcase (char-after)) ?x)
4924 (looking-at "Xref:"))
4925 (search-forward "\nXref:" nil t))
4926 (goto-char (1+ (match-end 0)))
4927 (setq xref (buffer-substring (point)
4928 (progn (end-of-line) (point))))
4929 (mail-header-set-xref headers xref)))))))
4930
4931 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4932 "Find article ID and insert the summary line for that article.
4933 OLD-HEADER can either be a header or a line number to insert
4934 the subject line on."
4935 (let* ((line (and (numberp old-header) old-header))
4936 (old-header (and (vectorp old-header) old-header))
4937 (header (cond ((and old-header use-old-header)
4938 old-header)
4939 ((and (numberp id)
4940 (gnus-number-to-header id))
4941 (gnus-number-to-header id))
4942 (t
4943 (gnus-read-header id))))
4944 (number (and (numberp id) id))
4945 d)
4946 (when header
4947 ;; Rebuild the thread that this article is part of and go to the
4948 ;; article we have fetched.
4949 (when (and (not gnus-show-threads)
4950 old-header)
4951 (when (and number
4952 (setq d (gnus-data-find (mail-header-number old-header))))
4953 (goto-char (gnus-data-pos d))
4954 (gnus-data-remove
4955 number
4956 (- (gnus-point-at-bol)
4957 (prog1
4958 (1+ (gnus-point-at-eol))
4959 (gnus-delete-line))))))
4960 (when old-header
4961 (mail-header-set-number header (mail-header-number old-header)))
4962 (setq gnus-newsgroup-sparse
4963 (delq (setq number (mail-header-number header))
4964 gnus-newsgroup-sparse))
4965 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4966 (push number gnus-newsgroup-limit)
4967 (gnus-rebuild-thread (mail-header-id header) line)
4968 (gnus-summary-goto-subject number nil t))
4969 (when (and (numberp number)
4970 (> number 0))
4971 ;; We have to update the boundaries even if we can't fetch the
4972 ;; article if ID is a number -- so that the next `P' or `N'
4973 ;; command will fetch the previous (or next) article even
4974 ;; if the one we tried to fetch this time has been canceled.
4975 (when (> number gnus-newsgroup-end)
4976 (setq gnus-newsgroup-end number))
4977 (when (< number gnus-newsgroup-begin)
4978 (setq gnus-newsgroup-begin number))
4979 (setq gnus-newsgroup-unselected
4980 (delq number gnus-newsgroup-unselected)))
4981 ;; Report back a success?
4982 (and header (mail-header-number header))))
4983
4984 ;;; Process/prefix in the summary buffer
4985
4986 (defun gnus-summary-work-articles (n)
4987 "Return a list of articles to be worked upon.
4988 The prefix argument, the list of process marked articles, and the
4989 current article will be taken into consideration."
4990 (save-excursion
4991 (set-buffer gnus-summary-buffer)
4992 (cond
4993 (n
4994 ;; A numerical prefix has been given.
4995 (setq n (prefix-numeric-value n))
4996 (let ((backward (< n 0))
4997 (n (abs (prefix-numeric-value n)))
4998 articles article)
4999 (save-excursion
5000 (while
5001 (and (> n 0)
5002 (push (setq article (gnus-summary-article-number))
5003 articles)
5004 (if backward
5005 (gnus-summary-find-prev nil article)
5006 (gnus-summary-find-next nil article)))
5007 (decf n)))
5008 (nreverse articles)))
5009 ((and (gnus-region-active-p) (mark))
5010 (message "region active")
5011 ;; Work on the region between point and mark.
5012 (let ((max (max (point) (mark)))
5013 articles article)
5014 (save-excursion
5015 (goto-char (min (min (point) (mark))))
5016 (while
5017 (and
5018 (push (setq article (gnus-summary-article-number)) articles)
5019 (gnus-summary-find-next nil article)
5020 (< (point) max)))
5021 (nreverse articles))))
5022 (gnus-newsgroup-processable
5023 ;; There are process-marked articles present.
5024 ;; Save current state.
5025 (gnus-summary-save-process-mark)
5026 ;; Return the list.
5027 (reverse gnus-newsgroup-processable))
5028 (t
5029 ;; Just return the current article.
5030 (list (gnus-summary-article-number))))))
5031
5032 (defmacro gnus-summary-iterate (arg &rest forms)
5033 "Iterate over the process/prefixed articles and do FORMS.
5034 ARG is the interactive prefix given to the command. FORMS will be
5035 executed with point over the summary line of the articles."
5036 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5037 `(let ((,articles (gnus-summary-work-articles ,arg)))
5038 (while ,articles
5039 (gnus-summary-goto-subject (car ,articles))
5040 ,@forms
5041 (pop ,articles)))))
5042
5043 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5044 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5045
5046 (defun gnus-summary-save-process-mark ()
5047 "Push the current set of process marked articles on the stack."
5048 (interactive)
5049 (push (copy-sequence gnus-newsgroup-processable)
5050 gnus-newsgroup-process-stack))
5051
5052 (defun gnus-summary-kill-process-mark ()
5053 "Push the current set of process marked articles on the stack and unmark."
5054 (interactive)
5055 (gnus-summary-save-process-mark)
5056 (gnus-summary-unmark-all-processable))
5057
5058 (defun gnus-summary-yank-process-mark ()
5059 "Pop the last process mark state off the stack and restore it."
5060 (interactive)
5061 (unless gnus-newsgroup-process-stack
5062 (error "Empty mark stack"))
5063 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5064
5065 (defun gnus-summary-process-mark-set (set)
5066 "Make SET into the current process marked articles."
5067 (gnus-summary-unmark-all-processable)
5068 (while set
5069 (gnus-summary-set-process-mark (pop set))))
5070
5071 ;;; Searching and stuff
5072
5073 (defun gnus-summary-search-group (&optional backward use-level)
5074 "Search for next unread newsgroup.
5075 If optional argument BACKWARD is non-nil, search backward instead."
5076 (save-excursion
5077 (set-buffer gnus-group-buffer)
5078 (when (gnus-group-search-forward
5079 backward nil (if use-level (gnus-group-group-level) nil))
5080 (gnus-group-group-name))))
5081
5082 (defun gnus-summary-best-group (&optional exclude-group)
5083 "Find the name of the best unread group.
5084 If EXCLUDE-GROUP, do not go to this group."
5085 (save-excursion
5086 (set-buffer gnus-group-buffer)
5087 (save-excursion
5088 (gnus-group-best-unread-group exclude-group))))
5089
5090 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5091 (if backward (gnus-summary-find-prev)
5092 (let* ((dummy (gnus-summary-article-intangible-p))
5093 (article (or article (gnus-summary-article-number)))
5094 (arts (gnus-data-find-list article))
5095 result)
5096 (when (and (not dummy)
5097 (or (not gnus-summary-check-current)
5098 (not unread)
5099 (not (gnus-data-unread-p (car arts)))))
5100 (setq arts (cdr arts)))
5101 (when (setq result
5102 (if unread
5103 (progn
5104 (while arts
5105 (when (or (and undownloaded
5106 (eq gnus-undownloaded-mark
5107 (gnus-data-mark (car arts))))
5108 (gnus-data-unread-p (car arts)))
5109 (setq result (car arts)
5110 arts nil))
5111 (setq arts (cdr arts)))
5112 result)
5113 (car arts)))
5114 (goto-char (gnus-data-pos result))
5115 (gnus-data-number result)))))
5116
5117 (defun gnus-summary-find-prev (&optional unread article)
5118 (let* ((eobp (eobp))
5119 (article (or article (gnus-summary-article-number)))
5120 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5121 result)
5122 (when (and (not eobp)
5123 (or (not gnus-summary-check-current)
5124 (not unread)
5125 (not (gnus-data-unread-p (car arts)))))
5126 (setq arts (cdr arts)))
5127 (when (setq result
5128 (if unread
5129 (progn
5130 (while arts
5131 (when (gnus-data-unread-p (car arts))
5132 (setq result (car arts)
5133 arts nil))
5134 (setq arts (cdr arts)))
5135 result)
5136 (car arts)))
5137 (goto-char (gnus-data-pos result))
5138 (gnus-data-number result))))
5139
5140 (defun gnus-summary-find-subject (subject &optional unread backward article)
5141 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5142 (article (or article (gnus-summary-article-number)))
5143 (articles (gnus-data-list backward))
5144 (arts (gnus-data-find-list article articles))
5145 result)
5146 (when (or (not gnus-summary-check-current)
5147 (not unread)
5148 (not (gnus-data-unread-p (car arts))))
5149 (setq arts (cdr arts)))
5150 (while arts
5151 (and (or (not unread)
5152 (gnus-data-unread-p (car arts)))
5153 (vectorp (gnus-data-header (car arts)))
5154 (gnus-subject-equal
5155 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5156 (setq result (car arts)
5157 arts nil))
5158 (setq arts (cdr arts)))
5159 (and result
5160 (goto-char (gnus-data-pos result))
5161 (gnus-data-number result))))
5162
5163 (defun gnus-summary-search-forward (&optional unread subject backward)
5164 "Search forward for an article.
5165 If UNREAD, look for unread articles. If SUBJECT, look for
5166 articles with that subject. If BACKWARD, search backward instead."
5167 (cond (subject (gnus-summary-find-subject subject unread backward))
5168 (backward (gnus-summary-find-prev unread))
5169 (t (gnus-summary-find-next unread))))
5170
5171 (defun gnus-recenter (&optional n)
5172 "Center point in window and redisplay frame.
5173 Also do horizontal recentering."
5174 (interactive "P")
5175 (when (and gnus-auto-center-summary
5176 (not (eq gnus-auto-center-summary 'vertical)))
5177 (gnus-horizontal-recenter))
5178 (recenter n))
5179
5180 (defun gnus-summary-recenter ()
5181 "Center point in the summary window.
5182 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5183 displayed, no centering will be performed."
5184 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5185 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
5186 (interactive)
5187 (let* ((top (cond ((< (window-height) 4) 0)
5188 ((< (window-height) 7) 1)
5189 (t (if (numberp gnus-auto-center-summary)
5190 gnus-auto-center-summary
5191 2))))
5192 (height (1- (window-height)))
5193 (bottom (save-excursion (goto-char (point-max))
5194 (forward-line (- height))
5195 (point)))
5196 (window (get-buffer-window (current-buffer))))
5197 ;; The user has to want it.
5198 (when gnus-auto-center-summary
5199 (when (get-buffer-window gnus-article-buffer)
5200 ;; Only do recentering when the article buffer is displayed,
5201 ;; Set the window start to either `bottom', which is the biggest
5202 ;; possible valid number, or the second line from the top,
5203 ;; whichever is the least.
5204 (set-window-start
5205 window (min bottom (save-excursion
5206 (forward-line (- top)) (point)))
5207 t))
5208 ;; Do horizontal recentering while we're at it.
5209 (when (and (get-buffer-window (current-buffer) t)
5210 (not (eq gnus-auto-center-summary 'vertical)))
5211 (let ((selected (selected-window)))
5212 (select-window (get-buffer-window (current-buffer) t))
5213 (gnus-summary-position-point)
5214 (gnus-horizontal-recenter)
5215 (select-window selected))))))
5216
5217 (defun gnus-summary-jump-to-group (newsgroup)
5218 "Move point to NEWSGROUP in group mode buffer."
5219 ;; Keep update point of group mode buffer if visible.
5220 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5221 (save-window-excursion
5222 ;; Take care of tree window mode.
5223 (when (get-buffer-window gnus-group-buffer)
5224 (pop-to-buffer gnus-group-buffer))
5225 (gnus-group-jump-to-group newsgroup))
5226 (save-excursion
5227 ;; Take care of tree window mode.
5228 (if (get-buffer-window gnus-group-buffer)
5229 (pop-to-buffer gnus-group-buffer)
5230 (set-buffer gnus-group-buffer))
5231 (gnus-group-jump-to-group newsgroup))))
5232
5233 ;; This function returns a list of article numbers based on the
5234 ;; difference between the ranges of read articles in this group and
5235 ;; the range of active articles.
5236 (defun gnus-list-of-unread-articles (group)
5237 (let* ((read (gnus-info-read (gnus-get-info group)))
5238 (active (or (gnus-active group) (gnus-activate-group group)))
5239 (last (cdr active))
5240 first nlast unread)
5241 ;; If none are read, then all are unread.
5242 (if (not read)
5243 (setq first (car active))
5244 ;; If the range of read articles is a single range, then the
5245 ;; first unread article is the article after the last read
5246 ;; article. Sounds logical, doesn't it?
5247 (if (and (not (listp (cdr read)))
5248 (or (< (car read) (car active))
5249 (progn (setq read (list read))
5250 nil)))
5251 (setq first (max (car active) (1+ (cdr read))))
5252 ;; `read' is a list of ranges.
5253 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5254 (caar read)))
5255 1)
5256 (setq first (car active)))
5257 (while read
5258 (when first
5259 (while (< first nlast)
5260 (push first unread)
5261 (setq first (1+ first))))
5262 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5263 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5264 (setq read (cdr read)))))
5265 ;; And add the last unread articles.
5266 (while (<= first last)
5267 (push first unread)
5268 (setq first (1+ first)))
5269 ;; Return the list of unread articles.
5270 (delq 0 (nreverse unread))))
5271
5272 (defun gnus-list-of-read-articles (group)
5273 "Return a list of unread, unticked and non-dormant articles."
5274 (let* ((info (gnus-get-info group))
5275 (marked (gnus-info-marks info))
5276 (active (gnus-active group)))
5277 (and info active
5278 (gnus-set-difference
5279 (gnus-sorted-complement
5280 (gnus-uncompress-range active)
5281 (gnus-list-of-unread-articles group))
5282 (append
5283 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5284 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5285
5286 ;; Various summary commands
5287
5288 (defun gnus-summary-select-article-buffer ()
5289 "Reconfigure windows to show article buffer."
5290 (interactive)
5291 (if (not (gnus-buffer-live-p gnus-article-buffer))
5292 (error "There is no article buffer for this summary buffer")
5293 (gnus-configure-windows 'article)
5294 (select-window (get-buffer-window gnus-article-buffer))))
5295
5296 (defun gnus-summary-universal-argument (arg)
5297 "Perform any operation on all articles that are process/prefixed."
5298 (interactive "P")
5299 (let ((articles (gnus-summary-work-articles arg))
5300 func article)
5301 (if (eq
5302 (setq
5303 func
5304 (key-binding
5305 (read-key-sequence
5306 (substitute-command-keys
5307 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
5308 'undefined)
5309 (gnus-error 1 "Undefined key")
5310 (save-excursion
5311 (while articles
5312 (gnus-summary-goto-subject (setq article (pop articles)))
5313 (let (gnus-newsgroup-processable)
5314 (command-execute func))
5315 (gnus-summary-remove-process-mark article)))))
5316 (gnus-summary-position-point))
5317
5318 (defun gnus-summary-toggle-truncation (&optional arg)
5319 "Toggle truncation of summary lines.
5320 With arg, turn line truncation on iff arg is positive."
5321 (interactive "P")
5322 (setq truncate-lines
5323 (if (null arg) (not truncate-lines)
5324 (> (prefix-numeric-value arg) 0)))
5325 (redraw-display))
5326
5327 (defun gnus-summary-reselect-current-group (&optional all rescan)
5328 "Exit and then reselect the current newsgroup.
5329 The prefix argument ALL means to select all articles."
5330 (interactive "P")
5331 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5332 (error "Ephemeral groups can't be reselected"))
5333 (let ((current-subject (gnus-summary-article-number))
5334 (group gnus-newsgroup-name))
5335 (setq gnus-newsgroup-begin nil)
5336 (gnus-summary-exit)
5337 ;; We have to adjust the point of group mode buffer because
5338 ;; point was moved to the next unread newsgroup by exiting.
5339 (gnus-summary-jump-to-group group)
5340 (when rescan
5341 (save-excursion
5342 (gnus-group-get-new-news-this-group 1)))
5343 (gnus-group-read-group all t)
5344 (gnus-summary-goto-subject current-subject nil t)))
5345
5346 (defun gnus-summary-rescan-group (&optional all)
5347 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5348 (interactive "P")
5349 (gnus-summary-reselect-current-group all t))
5350
5351 (defun gnus-summary-update-info (&optional non-destructive)
5352 (save-excursion
5353 (let ((group gnus-newsgroup-name))
5354 (when group
5355 (when gnus-newsgroup-kill-headers
5356 (setq gnus-newsgroup-killed
5357 (gnus-compress-sequence
5358 (nconc
5359 (gnus-set-sorted-intersection
5360 (gnus-uncompress-range gnus-newsgroup-killed)
5361 (setq gnus-newsgroup-unselected
5362 (sort gnus-newsgroup-unselected '<)))
5363 (setq gnus-newsgroup-unreads
5364 (sort gnus-newsgroup-unreads '<)))
5365 t)))
5366 (unless (listp (cdr gnus-newsgroup-killed))
5367 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5368 (let ((headers gnus-newsgroup-headers))
5369 ;; Set the new ranges of read articles.
5370 (save-excursion
5371 (set-buffer gnus-group-buffer)
5372 (gnus-undo-force-boundary))
5373 (gnus-update-read-articles
5374 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5375 ;; Set the current article marks.
5376 (let ((gnus-newsgroup-scored
5377 (if (and (not gnus-save-score)
5378 (not non-destructive))
5379 nil
5380 gnus-newsgroup-scored)))
5381 (save-excursion
5382 (gnus-update-marks)))
5383 ;; Do the cross-ref thing.
5384 (when gnus-use-cross-reference
5385 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5386 ;; Do not switch windows but change the buffer to work.
5387 (set-buffer gnus-group-buffer)
5388 (unless (gnus-ephemeral-group-p group)
5389 (gnus-group-update-group group)))))))
5390
5391 (defun gnus-summary-save-newsrc (&optional force)
5392 "Save the current number of read/marked articles in the dribble buffer.
5393 The dribble buffer will then be saved.
5394 If FORCE (the prefix), also save the .newsrc file(s)."
5395 (interactive "P")
5396 (gnus-summary-update-info t)
5397 (if force
5398 (gnus-save-newsrc-file)
5399 (gnus-dribble-save)))
5400
5401 (defun gnus-summary-exit (&optional temporary)
5402 "Exit reading current newsgroup, and then return to group selection mode.
5403 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
5404 (interactive)
5405 (gnus-set-global-variables)
5406 (when (gnus-buffer-live-p gnus-article-buffer)
5407 (save-excursion
5408 (set-buffer gnus-article-buffer)
5409 (mm-destroy-parts gnus-article-mime-handles)
5410 ;; Set it to nil for safety reason.
5411 (setq gnus-article-mime-handle-alist nil)
5412 (setq gnus-article-mime-handles nil)))
5413 (gnus-kill-save-kill-buffer)
5414 (gnus-async-halt-prefetch)
5415 (let* ((group gnus-newsgroup-name)
5416 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5417 (mode major-mode)
5418 (group-point nil)
5419 (buf (current-buffer)))
5420 (unless quit-config
5421 ;; Do adaptive scoring, and possibly save score files.
5422 (when gnus-newsgroup-adaptive
5423 (gnus-score-adaptive))
5424 (when gnus-use-scoring
5425 (gnus-score-save)))
5426 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5427 ;; If we have several article buffers, we kill them at exit.
5428 (unless gnus-single-article-buffer
5429 (gnus-kill-buffer gnus-original-article-buffer)
5430 (setq gnus-article-current nil))
5431 (when gnus-use-cache
5432 (gnus-cache-possibly-remove-articles)
5433 (gnus-cache-save-buffers))
5434 (gnus-async-prefetch-remove-group group)
5435 (when gnus-suppress-duplicates
5436 (gnus-dup-enter-articles))
5437 (when gnus-use-trees
5438 (gnus-tree-close group))
5439 (when gnus-use-cache
5440 (gnus-cache-write-active))
5441 ;; Remove entries for this group.
5442 (nnmail-purge-split-history (gnus-group-real-name group))
5443 ;; Make all changes in this group permanent.
5444 (unless quit-config
5445 (gnus-run-hooks 'gnus-exit-group-hook)
5446 (gnus-summary-update-info))
5447 (gnus-close-group group)
5448 ;; Make sure where we were, and go to next newsgroup.
5449 (set-buffer gnus-group-buffer)
5450 (unless quit-config
5451 (gnus-group-jump-to-group group))
5452 (gnus-run-hooks 'gnus-summary-exit-hook)
5453 (unless (or quit-config
5454 ;; If this group has disappeared from the summary
5455 ;; buffer, don't skip forwards.
5456 (not (string= group (gnus-group-group-name))))
5457 (gnus-group-next-unread-group 1))
5458 (setq group-point (point))
5459 (if temporary
5460 nil ;Nothing to do.
5461 ;; If we have several article buffers, we kill them at exit.
5462 (unless gnus-single-article-buffer
5463 (gnus-kill-buffer gnus-article-buffer)
5464 (gnus-kill-buffer gnus-original-article-buffer)
5465 (setq gnus-article-current nil))
5466 (set-buffer buf)
5467 (if (not gnus-kill-summary-on-exit)
5468 (gnus-deaden-summary)
5469 ;; We set all buffer-local variables to nil. It is unclear why
5470 ;; this is needed, but if we don't, buffer-local variables are
5471 ;; not garbage-collected, it seems. This would the lead to en
5472 ;; ever-growing Emacs.
5473 (gnus-summary-clear-local-variables)
5474 (when (get-buffer gnus-article-buffer)
5475 (bury-buffer gnus-article-buffer))
5476 ;; We clear the global counterparts of the buffer-local
5477 ;; variables as well, just to be on the safe side.
5478 (set-buffer gnus-group-buffer)
5479 (gnus-summary-clear-local-variables)
5480 ;; Return to group mode buffer.
5481 (when (eq mode 'gnus-summary-mode)
5482 (gnus-kill-buffer buf)))
5483 (setq gnus-current-select-method gnus-select-method)
5484 (pop-to-buffer gnus-group-buffer)
5485 (if (not quit-config)
5486 (progn
5487 (goto-char group-point)
5488 (gnus-configure-windows 'group 'force))
5489 (gnus-handle-ephemeral-exit quit-config))
5490 ;; Clear the current group name.
5491 (unless quit-config
5492 (setq gnus-newsgroup-name nil)))))
5493
5494 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5495 (defun gnus-summary-exit-no-update (&optional no-questions)
5496 "Quit reading current newsgroup without updating read article info."
5497 (interactive)
5498 (let* ((group gnus-newsgroup-name)
5499 (quit-config (gnus-group-quit-config group)))
5500 (when (or no-questions
5501 gnus-expert-user
5502 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5503 (gnus-async-halt-prefetch)
5504 (mapcar 'funcall
5505 (delq 'gnus-summary-expire-articles
5506 (copy-sequence gnus-summary-prepare-exit-hook)))
5507 (when (gnus-buffer-live-p gnus-article-buffer)
5508 (save-excursion
5509 (set-buffer gnus-article-buffer)
5510 (mm-destroy-parts gnus-article-mime-handles)
5511 ;; Set it to nil for safety reason.
5512 (setq gnus-article-mime-handle-alist nil)
5513 (setq gnus-article-mime-handles nil)))
5514 ;; If we have several article buffers, we kill them at exit.
5515 (unless gnus-single-article-buffer
5516 (gnus-kill-buffer gnus-article-buffer)
5517 (gnus-kill-buffer gnus-original-article-buffer)
5518 (setq gnus-article-current nil))
5519 (if (not gnus-kill-summary-on-exit)
5520 (gnus-deaden-summary)
5521 (gnus-close-group group)
5522 (gnus-summary-clear-local-variables)
5523 (set-buffer gnus-group-buffer)
5524 (gnus-summary-clear-local-variables)
5525 (when (get-buffer gnus-summary-buffer)
5526 (kill-buffer gnus-summary-buffer)))
5527 (unless gnus-single-article-buffer
5528 (setq gnus-article-current nil))
5529 (when gnus-use-trees
5530 (gnus-tree-close group))
5531 (gnus-async-prefetch-remove-group group)
5532 (when (get-buffer gnus-article-buffer)
5533 (bury-buffer gnus-article-buffer))
5534 ;; Return to the group buffer.
5535 (gnus-configure-windows 'group 'force)
5536 ;; Clear the current group name.
5537 (setq gnus-newsgroup-name nil)
5538 (when (equal (gnus-group-group-name) group)
5539 (gnus-group-next-unread-group 1))
5540 (when quit-config
5541 (gnus-handle-ephemeral-exit quit-config)))))
5542
5543 (defun gnus-handle-ephemeral-exit (quit-config)
5544 "Handle movement when leaving an ephemeral group.
5545 The state which existed when entering the ephemeral is reset."
5546 (if (not (buffer-name (car quit-config)))
5547 (gnus-configure-windows 'group 'force)
5548 (set-buffer (car quit-config))
5549 (cond ((eq major-mode 'gnus-summary-mode)
5550 (gnus-set-global-variables))
5551 ((eq major-mode 'gnus-article-mode)
5552 (save-excursion
5553 ;; The `gnus-summary-buffer' variable may point
5554 ;; to the old summary buffer when using a single
5555 ;; article buffer.
5556 (unless (gnus-buffer-live-p gnus-summary-buffer)
5557 (set-buffer gnus-group-buffer))
5558 (set-buffer gnus-summary-buffer)
5559 (gnus-set-global-variables))))
5560 (if (or (eq (cdr quit-config) 'article)
5561 (eq (cdr quit-config) 'pick))
5562 (progn
5563 ;; The current article may be from the ephemeral group
5564 ;; thus it is best that we reload this article
5565 (gnus-summary-show-article)
5566 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5567 (gnus-configure-windows 'pick 'force)
5568 (gnus-configure-windows (cdr quit-config) 'force)))
5569 (gnus-configure-windows (cdr quit-config) 'force))
5570 (when (eq major-mode 'gnus-summary-mode)
5571 (gnus-summary-next-subject 1 nil t)
5572 (gnus-summary-recenter)
5573 (gnus-summary-position-point))))
5574
5575 ;;; Dead summaries.
5576
5577 (defvar gnus-dead-summary-mode-map nil)
5578
5579 (unless gnus-dead-summary-mode-map
5580 (setq gnus-dead-summary-mode-map (make-keymap))
5581 (suppress-keymap gnus-dead-summary-mode-map)
5582 (substitute-key-definition
5583 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5584 (let ((keys '("\C-d" "\r" "\177" [delete])))
5585 (while keys
5586 (define-key gnus-dead-summary-mode-map
5587 (pop keys) 'gnus-summary-wake-up-the-dead))))
5588
5589 (defvar gnus-dead-summary-mode nil
5590 "Minor mode for Gnus summary buffers.")
5591
5592 (defun gnus-dead-summary-mode (&optional arg)
5593 "Minor mode for Gnus summary buffers."
5594 (interactive "P")
5595 (when (eq major-mode 'gnus-summary-mode)
5596 (make-local-variable 'gnus-dead-summary-mode)
5597 (setq gnus-dead-summary-mode
5598 (if (null arg) (not gnus-dead-summary-mode)
5599 (> (prefix-numeric-value arg) 0)))
5600 (when gnus-dead-summary-mode
5601 (gnus-add-minor-mode
5602 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5603
5604 (defun gnus-deaden-summary ()
5605 "Make the current summary buffer into a dead summary buffer."
5606 ;; Kill any previous dead summary buffer.
5607 (when (and gnus-dead-summary
5608 (buffer-name gnus-dead-summary))
5609 (save-excursion
5610 (set-buffer gnus-dead-summary)
5611 (when gnus-dead-summary-mode
5612 (kill-buffer (current-buffer)))))
5613 ;; Make this the current dead summary.
5614 (setq gnus-dead-summary (current-buffer))
5615 (gnus-dead-summary-mode 1)
5616 (let ((name (buffer-name)))
5617 (when (string-match "Summary" name)
5618 (rename-buffer
5619 (concat (substring name 0 (match-beginning 0)) "Dead "
5620 (substring name (match-beginning 0)))
5621 t)
5622 (bury-buffer))))
5623
5624 (defun gnus-kill-or-deaden-summary (buffer)
5625 "Kill or deaden the summary BUFFER."
5626 (save-excursion
5627 (when (and (buffer-name buffer)
5628 (not gnus-single-article-buffer))
5629 (save-excursion
5630 (set-buffer buffer)
5631 (gnus-kill-buffer gnus-article-buffer)
5632 (gnus-kill-buffer gnus-original-article-buffer)))
5633 (cond (gnus-kill-summary-on-exit
5634 (when (and gnus-use-trees
5635 (gnus-buffer-exists-p buffer))
5636 (save-excursion
5637 (set-buffer buffer)
5638 (gnus-tree-close gnus-newsgroup-name)))
5639 (gnus-kill-buffer buffer))
5640 ((gnus-buffer-exists-p buffer)
5641 (save-excursion
5642 (set-buffer buffer)
5643 (gnus-deaden-summary))))))
5644
5645 (defun gnus-summary-wake-up-the-dead (&rest args)
5646 "Wake up the dead summary buffer."
5647 (interactive)
5648 (gnus-dead-summary-mode -1)
5649 (let ((name (buffer-name)))
5650 (when (string-match "Dead " name)
5651 (rename-buffer
5652 (concat (substring name 0 (match-beginning 0))
5653 (substring name (match-end 0)))
5654 t)))
5655 (gnus-message 3 "This dead summary is now alive again"))
5656
5657 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5658 (defun gnus-summary-fetch-faq (&optional faq-dir)
5659 "Fetch the FAQ for the current group.
5660 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5661 in."
5662 (interactive
5663 (list
5664 (when current-prefix-arg
5665 (completing-read
5666 "Faq dir: " (and (listp gnus-group-faq-directory)
5667 (mapcar (lambda (file) (list file))
5668 gnus-group-faq-directory))))))
5669 (let (gnus-faq-buffer)
5670 (when (setq gnus-faq-buffer
5671 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5672 (gnus-configure-windows 'summary-faq))))
5673
5674 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5675 (defun gnus-summary-describe-group (&optional force)
5676 "Describe the current newsgroup."
5677 (interactive "P")
5678 (gnus-group-describe-group force gnus-newsgroup-name))
5679
5680 (defun gnus-summary-describe-briefly ()
5681 "Describe summary mode commands briefly."
5682 (interactive)
5683 (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")))
5684
5685 ;; Walking around group mode buffer from summary mode.
5686
5687 (defun gnus-summary-next-group (&optional no-article target-group backward)
5688 "Exit current newsgroup and then select next unread newsgroup.
5689 If prefix argument NO-ARTICLE is non-nil, no article is selected
5690 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5691 previous group instead."
5692 (interactive "P")
5693 ;; Stop pre-fetching.
5694 (gnus-async-halt-prefetch)
5695 (let ((current-group gnus-newsgroup-name)
5696 (current-buffer (current-buffer))
5697 entered)
5698 ;; First we semi-exit this group to update Xrefs and all variables.
5699 ;; We can't do a real exit, because the window conf must remain
5700 ;; the same in case the user is prompted for info, and we don't
5701 ;; want the window conf to change before that...
5702 (gnus-summary-exit t)
5703 (while (not entered)
5704 ;; Then we find what group we are supposed to enter.
5705 (set-buffer gnus-group-buffer)
5706 (gnus-group-jump-to-group current-group)
5707 (setq target-group
5708 (or target-group
5709 (if (eq gnus-keep-same-level 'best)
5710 (gnus-summary-best-group gnus-newsgroup-name)
5711 (gnus-summary-search-group backward gnus-keep-same-level))))
5712 (if (not target-group)
5713 ;; There are no further groups, so we return to the group
5714 ;; buffer.
5715 (progn
5716 (gnus-message 5 "Returning to the group buffer")
5717 (setq entered t)
5718 (when (gnus-buffer-live-p current-buffer)
5719 (set-buffer current-buffer)
5720 (gnus-summary-exit))
5721 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5722 ;; We try to enter the target group.
5723 (gnus-group-jump-to-group target-group)
5724 (let ((unreads (gnus-group-group-unread)))
5725 (if (and (or (eq t unreads)
5726 (and unreads (not (zerop unreads))))
5727 (gnus-summary-read-group
5728 target-group nil no-article
5729 (and (buffer-name current-buffer) current-buffer)
5730 nil backward))
5731 (setq entered t)
5732 (setq current-group target-group
5733 target-group nil)))))))
5734
5735 (defun gnus-summary-prev-group (&optional no-article)
5736 "Exit current newsgroup and then select previous unread newsgroup.
5737 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5738 (interactive "P")
5739 (gnus-summary-next-group no-article nil t))
5740
5741 ;; Walking around summary lines.
5742
5743 (defun gnus-summary-first-subject (&optional unread undownloaded)
5744 "Go to the first unread subject.
5745 If UNREAD is non-nil, go to the first unread article.
5746 Returns the article selected or nil if there are no unread articles."
5747 (interactive "P")
5748 (prog1
5749 (cond
5750 ;; Empty summary.
5751 ((null gnus-newsgroup-data)
5752 (gnus-message 3 "No articles in the group")
5753 nil)
5754 ;; Pick the first article.
5755 ((not unread)
5756 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5757 (gnus-data-number (car gnus-newsgroup-data)))
5758 ;; No unread articles.
5759 ((null gnus-newsgroup-unreads)
5760 (gnus-message 3 "No more unread articles")
5761 nil)
5762 ;; Find the first unread article.
5763 (t
5764 (let ((data gnus-newsgroup-data))
5765 (while (and data
5766 (and (not (and undownloaded
5767 (eq gnus-undownloaded-mark
5768 (gnus-data-mark (car data)))))
5769 (not (gnus-data-unread-p (car data)))))
5770 (setq data (cdr data)))
5771 (when data
5772 (goto-char (gnus-data-pos (car data)))
5773 (gnus-data-number (car data))))))
5774 (gnus-summary-position-point)))
5775
5776 (defun gnus-summary-next-subject (n &optional unread dont-display)
5777 "Go to next N'th summary line.
5778 If N is negative, go to the previous N'th subject line.
5779 If UNREAD is non-nil, only unread articles are selected.
5780 The difference between N and the actual number of steps taken is
5781 returned."
5782 (interactive "p")
5783 (let ((backward (< n 0))
5784 (n (abs n)))
5785 (while (and (> n 0)
5786 (if backward
5787 (gnus-summary-find-prev unread)
5788 (gnus-summary-find-next unread)))
5789 (unless (zerop (setq n (1- n)))
5790 (gnus-summary-show-thread)))
5791 (when (/= 0 n)
5792 (gnus-message 7 "No more%s articles"
5793 (if unread " unread" "")))
5794 (unless dont-display
5795 (gnus-summary-recenter)
5796 (gnus-summary-position-point))
5797 n))
5798
5799 (defun gnus-summary-next-unread-subject (n)
5800 "Go to next N'th unread summary line."
5801 (interactive "p")
5802 (gnus-summary-next-subject n t))
5803
5804 (defun gnus-summary-prev-subject (n &optional unread)
5805 "Go to previous N'th summary line.
5806 If optional argument UNREAD is non-nil, only unread article is selected."
5807 (interactive "p")
5808 (gnus-summary-next-subject (- n) unread))
5809
5810 (defun gnus-summary-prev-unread-subject (n)
5811 "Go to previous N'th unread summary line."
5812 (interactive "p")
5813 (gnus-summary-next-subject (- n) t))
5814
5815 (defun gnus-summary-goto-subject (article &optional force silent)
5816 "Go the subject line of ARTICLE.
5817 If FORCE, also allow jumping to articles not currently shown."
5818 (interactive "nArticle number: ")
5819 (let ((b (point))
5820 (data (gnus-data-find article)))
5821 ;; We read in the article if we have to.
5822 (and (not data)
5823 force
5824 (gnus-summary-insert-subject
5825 article
5826 (if (or (numberp force) (vectorp force)) force)
5827 t)
5828 (setq data (gnus-data-find article)))
5829 (goto-char b)
5830 (if (not data)
5831 (progn
5832 (unless silent
5833 (gnus-message 3 "Can't find article %d" article))
5834 nil)
5835 (goto-char (gnus-data-pos data))
5836 (gnus-summary-position-point)
5837 article)))
5838
5839 ;; Walking around summary lines with displaying articles.
5840
5841 (defun gnus-summary-expand-window (&optional arg)
5842 "Make the summary buffer take up the entire Emacs frame.
5843 Given a prefix, will force an `article' buffer configuration."
5844 (interactive "P")
5845 (if arg
5846 (gnus-configure-windows 'article 'force)
5847 (gnus-configure-windows 'summary 'force)))
5848
5849 (defun gnus-summary-display-article (article &optional all-header)
5850 "Display ARTICLE in article buffer."
5851 (when (gnus-buffer-live-p gnus-article-buffer)
5852 (with-current-buffer gnus-article-buffer
5853 (mm-enable-multibyte-mule4)))
5854 (gnus-set-global-variables)
5855 (if (null article)
5856 nil
5857 (prog1
5858 (if gnus-summary-display-article-function
5859 (funcall gnus-summary-display-article-function article all-header)
5860 (gnus-article-prepare article all-header))
5861 (gnus-run-hooks 'gnus-select-article-hook)
5862 (when (and gnus-current-article
5863 (not (zerop gnus-current-article)))
5864 (gnus-summary-goto-subject gnus-current-article))
5865 (gnus-summary-recenter)
5866 (when (and gnus-use-trees gnus-show-threads)
5867 (gnus-possibly-generate-tree article)
5868 (gnus-highlight-selected-tree article))
5869 ;; Successfully display article.
5870 (gnus-article-set-window-start
5871 (cdr (assq article gnus-newsgroup-bookmarks))))))
5872
5873 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5874 "Select the current article.
5875 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5876 non-nil, the article will be re-fetched even if it already present in
5877 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5878 be displayed."
5879 ;; Make sure we are in the summary buffer to work around bbdb bug.
5880 (unless (eq major-mode 'gnus-summary-mode)
5881 (set-buffer gnus-summary-buffer))
5882 (let ((article (or article (gnus-summary-article-number)))
5883 (all-headers (not (not all-headers))) ;Must be T or NIL.
5884 gnus-summary-display-article-function)
5885 (and (not pseudo)
5886 (gnus-summary-article-pseudo-p article)
5887 (error "This is a pseudo-article"))
5888 (save-excursion
5889 (set-buffer gnus-summary-buffer)
5890 (if (or (and gnus-single-article-buffer
5891 (or (null gnus-current-article)
5892 (null gnus-article-current)
5893 (null (get-buffer gnus-article-buffer))
5894 (not (eq article (cdr gnus-article-current)))
5895 (not (equal (car gnus-article-current)
5896 gnus-newsgroup-name))))
5897 (and (not gnus-single-article-buffer)
5898 (or (null gnus-current-article)
5899 (not (eq gnus-current-article article))))
5900 force)
5901 ;; The requested article is different from the current article.
5902 (progn
5903 (gnus-summary-display-article article all-headers)
5904 (when (gnus-buffer-live-p gnus-article-buffer)
5905 (with-current-buffer gnus-article-buffer
5906 (if (not gnus-article-decoded-p) ;; a local variable
5907 (mm-disable-multibyte-mule4))))
5908 (when (or all-headers gnus-show-all-headers)
5909 (gnus-article-show-all-headers))
5910 (gnus-article-set-window-start
5911 (cdr (assq article gnus-newsgroup-bookmarks)))
5912 article)
5913 (when (or all-headers gnus-show-all-headers)
5914 (gnus-article-show-all-headers))
5915 'old))))
5916
5917 (defun gnus-summary-set-current-mark (&optional current-mark)
5918 "Obsolete function."
5919 nil)
5920
5921 (defun gnus-summary-next-article (&optional unread subject backward push)
5922 "Select the next article.
5923 If UNREAD, only unread articles are selected.
5924 If SUBJECT, only articles with SUBJECT are selected.
5925 If BACKWARD, the previous article is selected instead of the next."
5926 (interactive "P")
5927 (cond
5928 ;; Is there such an article?
5929 ((and (gnus-summary-search-forward unread subject backward)
5930 (or (gnus-summary-display-article (gnus-summary-article-number))
5931 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5932 (gnus-summary-position-point))
5933 ;; If not, we try the first unread, if that is wanted.
5934 ((and subject
5935 gnus-auto-select-same
5936 (gnus-summary-first-unread-article))
5937 (gnus-summary-position-point)
5938 (gnus-message 6 "Wrapped"))
5939 ;; Try to get next/previous article not displayed in this group.
5940 ((and gnus-auto-extend-newsgroup
5941 (not unread) (not subject))
5942 (gnus-summary-goto-article
5943 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5944 nil (count-lines (point-min) (point))))
5945 ;; Go to next/previous group.
5946 (t
5947 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5948 (gnus-summary-jump-to-group gnus-newsgroup-name))
5949 (let ((cmd last-command-char)
5950 (point
5951 (save-excursion
5952 (set-buffer gnus-group-buffer)
5953 (point)))
5954 (group
5955 (if (eq gnus-keep-same-level 'best)
5956 (gnus-summary-best-group gnus-newsgroup-name)
5957 (gnus-summary-search-group backward gnus-keep-same-level))))
5958 ;; For some reason, the group window gets selected. We change
5959 ;; it back.
5960 (select-window (get-buffer-window (current-buffer)))
5961 ;; Select next unread newsgroup automagically.
5962 (cond
5963 ((or (not gnus-auto-select-next)
5964 (not cmd))
5965 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5966 ((or (eq gnus-auto-select-next 'quietly)
5967 (and (eq gnus-auto-select-next 'slightly-quietly)
5968 push)
5969 (and (eq gnus-auto-select-next 'almost-quietly)
5970 (gnus-summary-last-article-p)))
5971 ;; Select quietly.
5972 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5973 (gnus-summary-exit)
5974 (gnus-message 7 "No more%s articles (%s)..."
5975 (if unread " unread" "")
5976 (if group (concat "selecting " group)
5977 "exiting"))
5978 (gnus-summary-next-group nil group backward)))
5979 (t
5980 (when (gnus-key-press-event-p last-input-event)
5981 (gnus-summary-walk-group-buffer
5982 gnus-newsgroup-name cmd unread backward point))))))))
5983
5984 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5985 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5986 (?\C-p (gnus-group-prev-unread-group 1))))
5987 (cursor-in-echo-area t)
5988 keve key group ended)
5989 (save-excursion
5990 (set-buffer gnus-group-buffer)
5991 (goto-char start)
5992 (setq group
5993 (if (eq gnus-keep-same-level 'best)
5994 (gnus-summary-best-group gnus-newsgroup-name)
5995 (gnus-summary-search-group backward gnus-keep-same-level))))
5996 (while (not ended)
5997 (gnus-message
5998 5 "No more%s articles%s" (if unread " unread" "")
5999 (if (and group
6000 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6001 (format " (Type %s for %s [%s])"
6002 (single-key-description cmd) group
6003 (car (gnus-gethash group gnus-newsrc-hashtb)))
6004 (format " (Type %s to exit %s)"
6005 (single-key-description cmd)
6006 gnus-newsgroup-name)))
6007 ;; Confirm auto selection.
6008 (setq key (car (setq keve (gnus-read-event-char))))
6009 (setq ended t)
6010 (cond
6011 ((assq key keystrokes)
6012 (let ((obuf (current-buffer)))
6013 (switch-to-buffer gnus-group-buffer)
6014 (when group
6015 (gnus-group-jump-to-group group))
6016 (eval (cadr (assq key keystrokes)))
6017 (setq group (gnus-group-group-name))
6018 (switch-to-buffer obuf))
6019 (setq ended nil))
6020 ((equal key cmd)
6021 (if (or (not group)
6022 (gnus-ephemeral-group-p gnus-newsgroup-name))
6023 (gnus-summary-exit)
6024 (gnus-summary-next-group nil group backward)))
6025 (t
6026 (push (cdr keve) unread-command-events))))))
6027
6028 (defun gnus-summary-next-unread-article ()
6029 "Select unread article after current one."
6030 (interactive)
6031 (gnus-summary-next-article
6032 (or (not (eq gnus-summary-goto-unread 'never))
6033 (gnus-summary-last-article-p (gnus-summary-article-number)))
6034 (and gnus-auto-select-same
6035 (gnus-summary-article-subject))))
6036
6037 (defun gnus-summary-prev-article (&optional unread subject)
6038 "Select the article after the current one.
6039 If UNREAD is non-nil, only unread articles are selected."
6040 (interactive "P")
6041 (gnus-summary-next-article unread subject t))
6042
6043 (defun gnus-summary-prev-unread-article ()
6044 "Select unread article before current one."
6045 (interactive)
6046 (gnus-summary-prev-article
6047 (or (not (eq gnus-summary-goto-unread 'never))
6048 (gnus-summary-first-article-p (gnus-summary-article-number)))
6049 (and gnus-auto-select-same
6050 (gnus-summary-article-subject))))
6051
6052 (defun gnus-summary-next-page (&optional lines circular)
6053 "Show next page of the selected article.
6054 If at the end of the current article, select the next article.
6055 LINES says how many lines should be scrolled up.
6056
6057 If CIRCULAR is non-nil, go to the start of the article instead of
6058 selecting the next article when reaching the end of the current
6059 article."
6060 (interactive "P")
6061 (setq gnus-summary-buffer (current-buffer))
6062 (gnus-set-global-variables)
6063 (let ((article (gnus-summary-article-number))
6064 (article-window (get-buffer-window gnus-article-buffer t))
6065 endp)
6066 ;; If the buffer is empty, we have no article.
6067 (unless article
6068 (error "No article to select"))
6069 (gnus-configure-windows 'article)
6070 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6071 (if (and (eq gnus-summary-goto-unread 'never)
6072 (not (gnus-summary-last-article-p article)))
6073 (gnus-summary-next-article)
6074 (gnus-summary-next-unread-article))
6075 (if (or (null gnus-current-article)
6076 (null gnus-article-current)
6077 (/= article (cdr gnus-article-current))
6078 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6079 ;; Selected subject is different from current article's.
6080 (gnus-summary-display-article article)
6081 (when article-window
6082 (gnus-eval-in-buffer-window gnus-article-buffer
6083 (setq endp (gnus-article-next-page lines)))
6084 (when endp
6085 (cond (circular
6086 (gnus-summary-beginning-of-article))
6087 (lines
6088 (gnus-message 3 "End of message"))
6089 ((null lines)
6090 (if (and (eq gnus-summary-goto-unread 'never)
6091 (not (gnus-summary-last-article-p article)))
6092 (gnus-summary-next-article)
6093 (gnus-summary-next-unread-article))))))))
6094 (gnus-summary-recenter)
6095 (gnus-summary-position-point)))
6096
6097 (defun gnus-summary-prev-page (&optional lines move)
6098 "Show previous page of selected article.
6099 Argument LINES specifies lines to be scrolled down.
6100 If MOVE, move to the previous unread article if point is at
6101 the beginning of the buffer."
6102 (interactive "P")
6103 (let ((article (gnus-summary-article-number))
6104 (article-window (get-buffer-window gnus-article-buffer t))
6105 endp)
6106 (gnus-configure-windows 'article)
6107 (if (or (null gnus-current-article)
6108 (null gnus-article-current)
6109 (/= article (cdr gnus-article-current))
6110 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6111 ;; Selected subject is different from current article's.
6112 (gnus-summary-display-article article)
6113 (gnus-summary-recenter)
6114 (when article-window
6115 (gnus-eval-in-buffer-window gnus-article-buffer
6116 (setq endp (gnus-article-prev-page lines)))
6117 (when (and move endp)
6118 (cond (lines
6119 (gnus-message 3 "Beginning of message"))
6120 ((null lines)
6121 (if (and (eq gnus-summary-goto-unread 'never)
6122 (not (gnus-summary-first-article-p article)))
6123 (gnus-summary-prev-article)
6124 (gnus-summary-prev-unread-article))))))))
6125 (gnus-summary-position-point))
6126
6127 (defun gnus-summary-prev-page-or-article (&optional lines)
6128 "Show previous page of selected article.
6129 Argument LINES specifies lines to be scrolled down.
6130 If at the beginning of the article, go to the next article."
6131 (interactive "P")
6132 (gnus-summary-prev-page lines t))
6133
6134 (defun gnus-summary-scroll-up (lines)
6135 "Scroll up (or down) one line current article.
6136 Argument LINES specifies lines to be scrolled up (or down if negative)."
6137 (interactive "p")
6138 (gnus-configure-windows 'article)
6139 (gnus-summary-show-thread)
6140 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
6141 (gnus-eval-in-buffer-window gnus-article-buffer
6142 (cond ((> lines 0)
6143 (when (gnus-article-next-page lines)
6144 (gnus-message 3 "End of message")))
6145 ((< lines 0)
6146 (gnus-article-prev-page (- lines))))))
6147 (gnus-summary-recenter)
6148 (gnus-summary-position-point))
6149
6150 (defun gnus-summary-scroll-down (lines)
6151 "Scroll down (or up) one line current article.
6152 Argument LINES specifies lines to be scrolled down (or up if negative)."
6153 (interactive "p")
6154 (gnus-summary-scroll-up (- lines)))
6155
6156 (defun gnus-summary-next-same-subject ()
6157 "Select next article which has the same subject as current one."
6158 (interactive)
6159 (gnus-summary-next-article nil (gnus-summary-article-subject)))
6160
6161 (defun gnus-summary-prev-same-subject ()
6162 "Select previous article which has the same subject as current one."
6163 (interactive)
6164 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
6165
6166 (defun gnus-summary-next-unread-same-subject ()
6167 "Select next unread article which has the same subject as current one."
6168 (interactive)
6169 (gnus-summary-next-article t (gnus-summary-article-subject)))
6170
6171 (defun gnus-summary-prev-unread-same-subject ()
6172 "Select previous unread article which has the same subject as current one."
6173 (interactive)
6174 (gnus-summary-prev-article t (gnus-summary-article-subject)))
6175
6176 (defun gnus-summary-first-unread-article ()
6177 "Select the first unread article.
6178 Return nil if there are no unread articles."
6179 (interactive)
6180 (prog1
6181 (when (gnus-summary-first-subject t)
6182 (gnus-summary-show-thread)
6183 (gnus-summary-first-subject t)
6184 (gnus-summary-display-article (gnus-summary-article-number)))
6185 (gnus-summary-position-point)))
6186
6187 (defun gnus-summary-first-unread-subject ()
6188 "Place the point on the subject line of the first unread article.
6189 Return nil if there are no unread articles."
6190 (interactive)
6191 (prog1
6192 (when (gnus-summary-first-subject t)
6193 (gnus-summary-show-thread)
6194 (gnus-summary-first-subject t))
6195 (gnus-summary-position-point)))
6196
6197 (defun gnus-summary-first-article ()
6198 "Select the first article.
6199 Return nil if there are no articles."
6200 (interactive)
6201 (prog1
6202 (when (gnus-summary-first-subject)
6203 (gnus-summary-show-thread)
6204 (gnus-summary-first-subject)
6205 (gnus-summary-display-article (gnus-summary-article-number)))
6206 (gnus-summary-position-point)))
6207
6208 (defun gnus-summary-best-unread-article ()
6209 "Select the unread article with the highest score."
6210 (interactive)
6211 (let ((best -1000000)
6212 (data gnus-newsgroup-data)
6213 article score)
6214 (while data
6215 (and (gnus-data-unread-p (car data))
6216 (> (setq score
6217 (gnus-summary-article-score (gnus-data-number (car data))))
6218 best)
6219 (setq best score
6220 article (gnus-data-number (car data))))
6221 (setq data (cdr data)))
6222 (prog1
6223 (if article
6224 (gnus-summary-goto-article article)
6225 (error "No unread articles"))
6226 (gnus-summary-position-point))))
6227
6228 (defun gnus-summary-last-subject ()
6229 "Go to the last displayed subject line in the group."
6230 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6231 (when article
6232 (gnus-summary-goto-subject article))))
6233
6234 (defun gnus-summary-goto-article (article &optional all-headers force)
6235 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6236 If ALL-HEADERS is non-nil, no header lines are hidden.
6237 If FORCE, go to the article even if it isn't displayed. If FORCE
6238 is a number, it is the line the article is to be displayed on."
6239 (interactive
6240 (list
6241 (completing-read
6242 "Article number or Message-ID: "
6243 (mapcar (lambda (number) (list (int-to-string number)))
6244 gnus-newsgroup-limit))
6245 current-prefix-arg
6246 t))
6247 (prog1
6248 (if (and (stringp article)
6249 (string-match "@" article))
6250 (gnus-summary-refer-article article)
6251 (when (stringp article)
6252 (setq article (string-to-number article)))
6253 (if (gnus-summary-goto-subject article force)
6254 (gnus-summary-display-article article all-headers)
6255 (gnus-message 4 "Couldn't go to article %s" article) nil))
6256 (gnus-summary-position-point)))
6257
6258 (defun gnus-summary-goto-last-article ()
6259 "Go to the previously read article."
6260 (interactive)
6261 (prog1
6262 (when gnus-last-article
6263 (gnus-summary-goto-article gnus-last-article nil t))
6264 (gnus-summary-position-point)))
6265
6266 (defun gnus-summary-pop-article (number)
6267 "Pop one article off the history and go to the previous.
6268 NUMBER articles will be popped off."
6269 (interactive "p")
6270 (let (to)
6271 (setq gnus-newsgroup-history
6272 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6273 (if to
6274 (gnus-summary-goto-article (car to) nil t)
6275 (error "Article history empty")))
6276 (gnus-summary-position-point))
6277
6278 ;; Summary commands and functions for limiting the summary buffer.
6279
6280 (defun gnus-summary-limit-to-articles (n)
6281 "Limit the summary buffer to the next N articles.
6282 If not given a prefix, use the process marked articles instead."
6283 (interactive "P")
6284 (prog1
6285 (let ((articles (gnus-summary-work-articles n)))
6286 (setq gnus-newsgroup-processable nil)
6287 (gnus-summary-limit articles))
6288 (gnus-summary-position-point)))
6289
6290 (defun gnus-summary-pop-limit (&optional total)
6291 "Restore the previous limit.
6292 If given a prefix, remove all limits."
6293 (interactive "P")
6294 (when total
6295 (setq gnus-newsgroup-limits
6296 (list (mapcar (lambda (h) (mail-header-number h))
6297 gnus-newsgroup-headers))))
6298 (unless gnus-newsgroup-limits
6299 (error "No limit to pop"))
6300 (prog1
6301 (gnus-summary-limit nil 'pop)
6302 (gnus-summary-position-point)))
6303
6304 (defun gnus-summary-limit-to-subject (subject &optional header)
6305 "Limit the summary buffer to articles that have subjects that match a regexp."
6306 (interactive "sLimit to subject (regexp): ")
6307 (unless header
6308 (setq header "subject"))
6309 (when (not (equal "" subject))
6310 (prog1
6311 (let ((articles (gnus-summary-find-matching
6312 (or header "subject") subject 'all)))
6313 (unless articles
6314 (error "Found no matches for \"%s\"" subject))
6315 (gnus-summary-limit articles))
6316 (gnus-summary-position-point))))
6317
6318 (defun gnus-summary-limit-to-author (from)
6319 "Limit the summary buffer to articles that have authors that match a regexp."
6320 (interactive "sLimit to author (regexp): ")
6321 (gnus-summary-limit-to-subject from "from"))
6322
6323 (defun gnus-summary-limit-to-age (age &optional younger-p)
6324 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6325 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6326 articles that are younger than AGE days."
6327 (interactive
6328 (let ((younger current-prefix-arg)
6329 (days-got nil)
6330 days)
6331 (while (not days-got)
6332 (setq days (if younger
6333 (read-string "Limit to articles within (in days): ")
6334 (read-string "Limit to articles old than (in days): ")))
6335 (when (> (length days) 0)
6336 (setq days (read days)))
6337 (if (numberp days)
6338 (setq days-got t)
6339 (message "Please enter a number.")
6340 (sleep-for 1)))
6341 (list days younger)))
6342 (prog1
6343 (let ((data gnus-newsgroup-data)
6344 (cutoff (days-to-time age))
6345 articles d date is-younger)
6346 (while (setq d (pop data))
6347 (when (and (vectorp (gnus-data-header d))
6348 (setq date (mail-header-date (gnus-data-header d))))
6349 (setq is-younger (time-less-p
6350 (time-since (condition-case ()
6351 (date-to-time date)
6352 (error '(0 0))))
6353 cutoff))
6354 (when (if younger-p
6355 is-younger
6356 (not is-younger))
6357 (push (gnus-data-number d) articles))))
6358 (gnus-summary-limit (nreverse articles)))
6359 (gnus-summary-position-point)))
6360
6361 (defun gnus-summary-limit-to-extra (header regexp)
6362 "Limit the summary buffer to articles that match an 'extra' header."
6363 (interactive
6364 (let ((header
6365 (intern
6366 (gnus-completing-read
6367 (symbol-name (car gnus-extra-headers))
6368 "Limit extra header:"
6369 (mapcar (lambda (x)
6370 (cons (symbol-name x) x))
6371 gnus-extra-headers)
6372 nil
6373 t))))
6374 (list header
6375 (read-string (format "Limit to header %s (regexp): " header)))))
6376 (when (not (equal "" regexp))
6377 (prog1
6378 (let ((articles (gnus-summary-find-matching
6379 (cons 'extra header) regexp 'all)))
6380 (unless articles
6381 (error "Found no matches for \"%s\"" regexp))
6382 (gnus-summary-limit articles))
6383 (gnus-summary-position-point))))
6384
6385 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6386 (make-obsolete
6387 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6388
6389 (defun gnus-summary-limit-to-unread (&optional all)
6390 "Limit the summary buffer to articles that are not marked as read.
6391 If ALL is non-nil, limit strictly to unread articles."
6392 (interactive "P")
6393 (if all
6394 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6395 (gnus-summary-limit-to-marks
6396 ;; Concat all the marks that say that an article is read and have
6397 ;; those removed.
6398 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6399 gnus-killed-mark gnus-kill-file-mark
6400 gnus-low-score-mark gnus-expirable-mark
6401 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6402 gnus-duplicate-mark gnus-souped-mark)
6403 'reverse)))
6404
6405 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6406 (make-obsolete 'gnus-summary-delete-marked-with
6407 'gnus-summary-limit-exlude-marks)
6408
6409 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6410 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6411 If REVERSE, limit the summary buffer to articles that are marked
6412 with MARKS. MARKS can either be a string of marks or a list of marks.
6413 Returns how many articles were removed."
6414 (interactive "sMarks: ")
6415 (gnus-summary-limit-to-marks marks t))
6416
6417 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6418 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6419 If REVERSE (the prefix), limit the summary buffer to articles that are
6420 not marked with MARKS. MARKS can either be a string of marks or a
6421 list of marks.
6422 Returns how many articles were removed."
6423 (interactive "sMarks: \nP")
6424 (prog1
6425 (let ((data gnus-newsgroup-data)
6426 (marks (if (listp marks) marks
6427 (append marks nil))) ; Transform to list.
6428 articles)
6429 (while data
6430 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6431 (memq (gnus-data-mark (car data)) marks))
6432 (push (gnus-data-number (car data)) articles))
6433 (setq data (cdr data)))
6434 (gnus-summary-limit articles))
6435 (gnus-summary-position-point)))
6436
6437 (defun gnus-summary-limit-to-score (&optional score)
6438 "Limit to articles with score at or above SCORE."
6439 (interactive "P")
6440 (setq score (if score
6441 (prefix-numeric-value score)
6442 (or gnus-summary-default-score 0)))
6443 (let ((data gnus-newsgroup-data)
6444 articles)
6445 (while data
6446 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6447 score)
6448 (push (gnus-data-number (car data)) articles))
6449 (setq data (cdr data)))
6450 (prog1
6451 (gnus-summary-limit articles)
6452 (gnus-summary-position-point))))
6453
6454 (defun gnus-summary-limit-include-thread (id)
6455 "Display all the hidden articles that in the current thread."
6456 (interactive (list (mail-header-id (gnus-summary-article-header))))
6457 (let ((articles (gnus-articles-in-thread
6458 (gnus-id-to-thread (gnus-root-id id)))))
6459 (prog1
6460 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6461 (gnus-summary-position-point))))
6462
6463 (defun gnus-summary-limit-include-dormant ()
6464 "Display all the hidden articles that are marked as dormant.
6465 Note that this command only works on a subset of the articles currently
6466 fetched for this group."
6467 (interactive)
6468 (unless gnus-newsgroup-dormant
6469 (error "There are no dormant articles in this group"))
6470 (prog1
6471 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6472 (gnus-summary-position-point)))
6473
6474 (defun gnus-summary-limit-exclude-dormant ()
6475 "Hide all dormant articles."
6476 (interactive)
6477 (prog1
6478 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6479 (gnus-summary-position-point)))
6480
6481 (defun gnus-summary-limit-exclude-childless-dormant ()
6482 "Hide all dormant articles that have no children."
6483 (interactive)
6484 (let ((data (gnus-data-list t))
6485 articles d children)
6486 ;; Find all articles that are either not dormant or have
6487 ;; children.
6488 (while (setq d (pop data))
6489 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6490 (and (setq children
6491 (gnus-article-children (gnus-data-number d)))
6492 (let (found)
6493 (while children
6494 (when (memq (car children) articles)
6495 (setq children nil
6496 found t))
6497 (pop children))
6498 found)))
6499 (push (gnus-data-number d) articles)))
6500 ;; Do the limiting.
6501 (prog1
6502 (gnus-summary-limit articles)
6503 (gnus-summary-position-point))))
6504
6505 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6506 "Mark all unread excluded articles as read.
6507 If ALL, mark even excluded ticked and dormants as read."
6508 (interactive "P")
6509 (let ((articles (gnus-sorted-complement
6510 (sort
6511 (mapcar (lambda (h) (mail-header-number h))
6512 gnus-newsgroup-headers)
6513 '<)
6514 (sort gnus-newsgroup-limit '<)))
6515 article)
6516 (setq gnus-newsgroup-unreads
6517 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6518 (if all
6519 (setq gnus-newsgroup-dormant nil
6520 gnus-newsgroup-marked nil
6521 gnus-newsgroup-reads
6522 (nconc
6523 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6524 gnus-newsgroup-reads))
6525 (while (setq article (pop articles))
6526 (unless (or (memq article gnus-newsgroup-dormant)
6527 (memq article gnus-newsgroup-marked))
6528 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6529
6530 (defun gnus-summary-limit (articles &optional pop)
6531 (if pop
6532 ;; We pop the previous limit off the stack and use that.
6533 (setq articles (car gnus-newsgroup-limits)
6534 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6535 ;; We use the new limit, so we push the old limit on the stack.
6536 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6537 ;; Set the limit.
6538 (setq gnus-newsgroup-limit articles)
6539 (let ((total (length gnus-newsgroup-data))
6540 (data (gnus-data-find-list (gnus-summary-article-number)))
6541 (gnus-summary-mark-below nil) ; Inhibit this.
6542 found)
6543 ;; This will do all the work of generating the new summary buffer
6544 ;; according to the new limit.
6545 (gnus-summary-prepare)
6546 ;; Hide any threads, possibly.
6547 (and gnus-show-threads
6548 gnus-thread-hide-subtree
6549 (gnus-summary-hide-all-threads))
6550 ;; Try to return to the article you were at, or one in the
6551 ;; neighborhood.
6552 (when data
6553 ;; We try to find some article after the current one.
6554 (while data
6555 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6556 (setq data nil
6557 found t))
6558 (setq data (cdr data))))
6559 (unless found
6560 ;; If there is no data, that means that we were after the last
6561 ;; article. The same goes when we can't find any articles
6562 ;; after the current one.
6563 (goto-char (point-max))
6564 (gnus-summary-find-prev))
6565 (gnus-set-mode-line 'summary)
6566 ;; We return how many articles were removed from the summary
6567 ;; buffer as a result of the new limit.
6568 (- total (length gnus-newsgroup-data))))
6569
6570 (defsubst gnus-invisible-cut-children (threads)
6571 (let ((num 0))
6572 (while threads
6573 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6574 (incf num))
6575 (pop threads))
6576 (< num 2)))
6577
6578 (defsubst gnus-cut-thread (thread)
6579 "Go forwards in the thread until we find an article that we want to display."
6580 (when (or (eq gnus-fetch-old-headers 'some)
6581 (eq gnus-fetch-old-headers 'invisible)
6582 (numberp gnus-fetch-old-headers)
6583 (eq gnus-build-sparse-threads 'some)
6584 (eq gnus-build-sparse-threads 'more))
6585 ;; Deal with old-fetched headers and sparse threads.
6586 (while (and
6587 thread
6588 (or
6589 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6590 (gnus-summary-article-ancient-p
6591 (mail-header-number (car thread))))
6592 (if (or (<= (length (cdr thread)) 1)
6593 (eq gnus-fetch-old-headers 'invisible))
6594 (setq gnus-newsgroup-limit
6595 (delq (mail-header-number (car thread))
6596 gnus-newsgroup-limit)
6597 thread (cadr thread))
6598 (when (gnus-invisible-cut-children (cdr thread))
6599 (let ((th (cdr thread)))
6600 (while th
6601 (if (memq (mail-header-number (caar th))
6602 gnus-newsgroup-limit)
6603 (setq thread (car th)
6604 th nil)
6605 (setq th (cdr th))))))))))
6606 thread)
6607
6608 (defun gnus-cut-threads (threads)
6609 "Cut off all uninteresting articles from the beginning of threads."
6610 (when (or (eq gnus-fetch-old-headers 'some)
6611 (eq gnus-fetch-old-headers 'invisible)
6612 (numberp gnus-fetch-old-headers)
6613 (eq gnus-build-sparse-threads 'some)
6614 (eq gnus-build-sparse-threads 'more))
6615 (let ((th threads))
6616 (while th
6617 (setcar th (gnus-cut-thread (car th)))
6618 (setq th (cdr th)))))
6619 ;; Remove nixed out threads.
6620 (delq nil threads))
6621
6622 (defun gnus-summary-initial-limit (&optional show-if-empty)
6623 "Figure out what the initial limit is supposed to be on group entry.
6624 This entails weeding out unwanted dormants, low-scored articles,
6625 fetch-old-headers verbiage, and so on."
6626 ;; Most groups have nothing to remove.
6627 (if (or gnus-inhibit-limiting
6628 (and (null gnus-newsgroup-dormant)
6629 (not (eq gnus-fetch-old-headers 'some))
6630 (not (numberp gnus-fetch-old-headers))
6631 (not (eq gnus-fetch-old-headers 'invisible))
6632 (null gnus-summary-expunge-below)
6633 (not (eq gnus-build-sparse-threads 'some))
6634 (not (eq gnus-build-sparse-threads 'more))
6635 (null gnus-thread-expunge-below)
6636 (not gnus-use-nocem)))
6637 () ; Do nothing.
6638 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6639 (setq gnus-newsgroup-limit nil)
6640 (mapatoms
6641 (lambda (node)
6642 (unless (car (symbol-value node))
6643 ;; These threads have no parents -- they are roots.
6644 (let ((nodes (cdr (symbol-value node)))
6645 thread)
6646 (while nodes
6647 (if (and gnus-thread-expunge-below
6648 (< (gnus-thread-total-score (car nodes))
6649 gnus-thread-expunge-below))
6650 (gnus-expunge-thread (pop nodes))
6651 (setq thread (pop nodes))
6652 (gnus-summary-limit-children thread))))))
6653 gnus-newsgroup-dependencies)
6654 ;; If this limitation resulted in an empty group, we might
6655 ;; pop the previous limit and use it instead.
6656 (when (and (not gnus-newsgroup-limit)
6657 show-if-empty)
6658 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6659 gnus-newsgroup-limit))
6660
6661 (defun gnus-summary-limit-children (thread)
6662 "Return 1 if this subthread is visible and 0 if it is not."
6663 ;; First we get the number of visible children to this thread. This
6664 ;; is done by recursing down the thread using this function, so this
6665 ;; will really go down to a leaf article first, before slowly
6666 ;; working its way up towards the root.
6667 (when thread
6668 (let ((children
6669 (if (cdr thread)
6670 (apply '+ (mapcar 'gnus-summary-limit-children
6671 (cdr thread)))
6672 0))
6673 (number (mail-header-number (car thread)))
6674 score)
6675 (if (and
6676 (not (memq number gnus-newsgroup-marked))
6677 (or
6678 ;; If this article is dormant and has absolutely no visible
6679 ;; children, then this article isn't visible.
6680 (and (memq number gnus-newsgroup-dormant)
6681 (zerop children))
6682 ;; If this is "fetch-old-headered" and there is no
6683 ;; visible children, then we don't want this article.
6684 (and (or (eq gnus-fetch-old-headers 'some)
6685 (numberp gnus-fetch-old-headers))
6686 (gnus-summary-article-ancient-p number)
6687 (zerop children))
6688 ;; If this is "fetch-old-headered" and `invisible', then
6689 ;; we don't want this article.
6690 (and (eq gnus-fetch-old-headers 'invisible)
6691 (gnus-summary-article-ancient-p number))
6692 ;; If this is a sparsely inserted article with no children,
6693 ;; we don't want it.
6694 (and (eq gnus-build-sparse-threads 'some)
6695 (gnus-summary-article-sparse-p number)
6696 (zerop children))
6697 ;; If we use expunging, and this article is really
6698 ;; low-scored, then we don't want this article.
6699 (when (and gnus-summary-expunge-below
6700 (< (setq score
6701 (or (cdr (assq number gnus-newsgroup-scored))
6702 gnus-summary-default-score))
6703 gnus-summary-expunge-below))
6704 ;; We increase the expunge-tally here, but that has
6705 ;; nothing to do with the limits, really.
6706 (incf gnus-newsgroup-expunged-tally)
6707 ;; We also mark as read here, if that's wanted.
6708 (when (and gnus-summary-mark-below
6709 (< score gnus-summary-mark-below))
6710 (setq gnus-newsgroup-unreads
6711 (delq number gnus-newsgroup-unreads))
6712 (if gnus-newsgroup-auto-expire
6713 (push number gnus-newsgroup-expirable)
6714 (push (cons number gnus-low-score-mark)
6715 gnus-newsgroup-reads)))
6716 t)
6717 ;; Check NoCeM things.
6718 (if (and gnus-use-nocem
6719 (gnus-nocem-unwanted-article-p
6720 (mail-header-id (car thread))))
6721 (progn
6722 (setq gnus-newsgroup-unreads
6723 (delq number gnus-newsgroup-unreads))
6724 t))))
6725 ;; Nope, invisible article.
6726 0
6727 ;; Ok, this article is to be visible, so we add it to the limit
6728 ;; and return 1.
6729 (push number gnus-newsgroup-limit)
6730 1))))
6731
6732 (defun gnus-expunge-thread (thread)
6733 "Mark all articles in THREAD as read."
6734 (let* ((number (mail-header-number (car thread))))
6735 (incf gnus-newsgroup-expunged-tally)
6736 ;; We also mark as read here, if that's wanted.
6737 (setq gnus-newsgroup-unreads
6738 (delq number gnus-newsgroup-unreads))
6739 (if gnus-newsgroup-auto-expire
6740 (push number gnus-newsgroup-expirable)
6741 (push (cons number gnus-low-score-mark)
6742 gnus-newsgroup-reads)))
6743 ;; Go recursively through all subthreads.
6744 (mapcar 'gnus-expunge-thread (cdr thread)))
6745
6746 ;; Summary article oriented commands
6747
6748 (defun gnus-summary-refer-parent-article (n)
6749 "Refer parent article N times.
6750 If N is negative, go to ancestor -N instead.
6751 The difference between N and the number of articles fetched is returned."
6752 (interactive "p")
6753 (let ((skip 1)
6754 error header ref)
6755 (when (not (natnump n))
6756 (setq skip (abs n)
6757 n 1))
6758 (while (and (> n 0)
6759 (not error))
6760 (setq header (gnus-summary-article-header))
6761 (if (and (eq (mail-header-number header)
6762 (cdr gnus-article-current))
6763 (equal gnus-newsgroup-name
6764 (car gnus-article-current)))
6765 ;; If we try to find the parent of the currently
6766 ;; displayed article, then we take a look at the actual
6767 ;; References header, since this is slightly more
6768 ;; reliable than the References field we got from the
6769 ;; server.
6770 (save-excursion
6771 (set-buffer gnus-original-article-buffer)
6772 (nnheader-narrow-to-headers)
6773 (unless (setq ref (message-fetch-field "references"))
6774 (setq ref (message-fetch-field "in-reply-to")))
6775 (widen))
6776 (setq ref
6777 ;; It's not the current article, so we take a bet on
6778 ;; the value we got from the server.
6779 (mail-header-references header)))
6780 (if (and ref
6781 (not (equal ref "")))
6782 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6783 (gnus-message 1 "Couldn't find parent"))
6784 (gnus-message 1 "No references in article %d"
6785 (gnus-summary-article-number))
6786 (setq error t))
6787 (decf n))
6788 (gnus-summary-position-point)
6789 n))
6790
6791 (defun gnus-summary-refer-references ()
6792 "Fetch all articles mentioned in the References header.
6793 Return the number of articles fetched."
6794 (interactive)
6795 (let ((ref (mail-header-references (gnus-summary-article-header)))
6796 (current (gnus-summary-article-number))
6797 (n 0))
6798 (if (or (not ref)
6799 (equal ref ""))
6800 (error "No References in the current article")
6801 ;; For each Message-ID in the References header...
6802 (while (string-match "<[^>]*>" ref)
6803 (incf n)
6804 ;; ... fetch that article.
6805 (gnus-summary-refer-article
6806 (prog1 (match-string 0 ref)
6807 (setq ref (substring ref (match-end 0))))))
6808 (gnus-summary-goto-subject current)
6809 (gnus-summary-position-point)
6810 n)))
6811
6812 (defun gnus-summary-refer-thread (&optional limit)
6813 "Fetch all articles in the current thread.
6814 If LIMIT (the numerical prefix), fetch that many old headers instead
6815 of what's specified by the `gnus-refer-thread-limit' variable."
6816 (interactive "P")
6817 (let ((id (mail-header-id (gnus-summary-article-header)))
6818 (limit (if limit (prefix-numeric-value limit)
6819 gnus-refer-thread-limit)))
6820 ;; We want to fetch LIMIT *old* headers, but we also have to
6821 ;; re-fetch all the headers in the current buffer, because many of
6822 ;; them may be undisplayed. So we adjust LIMIT.
6823 (when (numberp limit)
6824 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6825 (unless (eq gnus-fetch-old-headers 'invisible)
6826 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6827 ;; Retrieve the headers and read them in.
6828 (if (eq (gnus-retrieve-headers
6829 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6830 'nov)
6831 (gnus-build-all-threads)
6832 (error "Can't fetch thread from backends that don't support NOV"))
6833 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6834 (gnus-summary-limit-include-thread id)))
6835
6836 (defun gnus-summary-refer-article (message-id)
6837 "Fetch an article specified by MESSAGE-ID."
6838 (interactive "sMessage-ID: ")
6839 (when (and (stringp message-id)
6840 (not (zerop (length message-id))))
6841 ;; Construct the correct Message-ID if necessary.
6842 ;; Suggested by tale@pawl.rpi.edu.
6843 (unless (string-match "^<" message-id)
6844 (setq message-id (concat "<" message-id)))
6845 (unless (string-match ">$" message-id)
6846 (setq message-id (concat message-id ">")))
6847 (let* ((header (gnus-id-to-header message-id))
6848 (sparse (and header
6849 (gnus-summary-article-sparse-p
6850 (mail-header-number header))
6851 (memq (mail-header-number header)
6852 gnus-newsgroup-limit)))
6853 number)
6854 (cond
6855 ;; If the article is present in the buffer we just go to it.
6856 ((and header
6857 (or (not (gnus-summary-article-sparse-p
6858 (mail-header-number header)))
6859 sparse))
6860 (prog1
6861 (gnus-summary-goto-article
6862 (mail-header-number header) nil t)
6863 (when sparse
6864 (gnus-summary-update-article (mail-header-number header)))))
6865 (t
6866 ;; We fetch the article.
6867 (catch 'found
6868 (dolist (gnus-override-method (gnus-refer-article-methods))
6869 (gnus-check-server gnus-override-method)
6870 ;; Fetch the header, and display the article.
6871 (when (setq number (gnus-summary-insert-subject message-id))
6872 (gnus-summary-select-article nil nil nil number)
6873 (throw 'found t)))
6874 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
6875
6876 (defun gnus-refer-article-methods ()
6877 "Return a list of referrable methods."
6878 (cond
6879 ;; No method, so we default to current and native.
6880 ((null gnus-refer-article-method)
6881 (list gnus-current-select-method gnus-select-method))
6882 ;; Current.
6883 ((eq 'current gnus-refer-article-method)
6884 (list gnus-current-select-method))
6885 ;; List of select methods.
6886 ((not (and (symbolp (car gnus-refer-article-method))
6887 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
6888 (let (out)
6889 (dolist (method gnus-refer-article-method)
6890 (push (if (eq 'current method)
6891 gnus-current-select-method
6892 method)
6893 out))
6894 (nreverse out)))
6895 ;; One single select method.
6896 (t
6897 (list gnus-refer-article-method))))
6898
6899 (defun gnus-summary-edit-parameters ()
6900 "Edit the group parameters of the current group."
6901 (interactive)
6902 (gnus-group-edit-group gnus-newsgroup-name 'params))
6903
6904 (defun gnus-summary-customize-parameters ()
6905 "Customize the group parameters of the current group."
6906 (interactive)
6907 (gnus-group-customize gnus-newsgroup-name))
6908
6909 (defun gnus-summary-enter-digest-group (&optional force)
6910 "Enter an nndoc group based on the current article.
6911 If FORCE, force a digest interpretation. If not, try
6912 to guess what the document format is."
6913 (interactive "P")
6914 (let ((conf gnus-current-window-configuration))
6915 (save-excursion
6916 (gnus-summary-select-article))
6917 (setq gnus-current-window-configuration conf)
6918 (let* ((name (format "%s-%d"
6919 (gnus-group-prefixed-name
6920 gnus-newsgroup-name (list 'nndoc ""))
6921 (save-excursion
6922 (set-buffer gnus-summary-buffer)
6923 gnus-current-article)))
6924 (ogroup gnus-newsgroup-name)
6925 (params (append (gnus-info-params (gnus-get-info ogroup))
6926 (list (cons 'to-group ogroup))
6927 (list (cons 'save-article-group ogroup))))
6928 (case-fold-search t)
6929 (buf (current-buffer))
6930 dig to-address)
6931 (save-excursion
6932 (set-buffer gnus-original-article-buffer)
6933 ;; Have the digest group inherit the main mail address of
6934 ;; the parent article.
6935 (when (setq to-address (or (message-fetch-field "reply-to")
6936 (message-fetch-field "from")))
6937 (setq params (append
6938 (list (cons 'to-address
6939 (funcall gnus-decode-encoded-word-function
6940 to-address))))))
6941 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6942 (insert-buffer-substring gnus-original-article-buffer)
6943 ;; Remove lines that may lead nndoc to misinterpret the
6944 ;; document type.
6945 (narrow-to-region
6946 (goto-char (point-min))
6947 (or (search-forward "\n\n" nil t) (point)))
6948 (goto-char (point-min))
6949 (delete-matching-lines "^Path:\\|^From ")
6950 (widen))
6951 (unwind-protect
6952 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
6953 (gnus-newsgroup-ephemeral-ignored-charsets
6954 gnus-newsgroup-ignored-charsets))
6955 (gnus-group-read-ephemeral-group
6956 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6957 (nndoc-article-type
6958 ,(if force 'mbox 'guess))) t))
6959 ;; Make all postings to this group go to the parent group.
6960 (nconc (gnus-info-params (gnus-get-info name))
6961 params)
6962 ;; Couldn't select this doc group.
6963 (switch-to-buffer buf)
6964 (gnus-set-global-variables)
6965 (gnus-configure-windows 'summary)
6966 (gnus-message 3 "Article couldn't be entered?"))
6967 (kill-buffer dig)))))
6968
6969 (defun gnus-summary-read-document (n)
6970 "Open a new group based on the current article(s).
6971 This will allow you to read digests and other similar
6972 documents as newsgroups.
6973 Obeys the standard process/prefix convention."
6974 (interactive "P")
6975 (let* ((articles (gnus-summary-work-articles n))
6976 (ogroup gnus-newsgroup-name)
6977 (params (append (gnus-info-params (gnus-get-info ogroup))
6978 (list (cons 'to-group ogroup))))
6979 article group egroup groups vgroup)
6980 (while (setq article (pop articles))
6981 (setq group (format "%s-%d" gnus-newsgroup-name article))
6982 (gnus-summary-remove-process-mark article)
6983 (when (gnus-summary-display-article article)
6984 (save-excursion
6985 (with-temp-buffer
6986 (insert-buffer-substring gnus-original-article-buffer)
6987 ;; Remove some headers that may lead nndoc to make
6988 ;; the wrong guess.
6989 (message-narrow-to-head)
6990 (goto-char (point-min))
6991 (delete-matching-lines "^\\(Path\\):\\|^From ")
6992 (widen)
6993 (if (setq egroup
6994 (gnus-group-read-ephemeral-group
6995 group `(nndoc ,group (nndoc-address ,(current-buffer))
6996 (nndoc-article-type guess))
6997 t nil t))
6998 (progn
6999 ;; Make all postings to this group go to the parent group.
7000 (nconc (gnus-info-params (gnus-get-info egroup))
7001 params)
7002 (push egroup groups))
7003 ;; Couldn't select this doc group.
7004 (gnus-error 3 "Article couldn't be entered"))))))
7005 ;; Now we have selected all the documents.
7006 (cond
7007 ((not groups)
7008 (error "None of the articles could be interpreted as documents"))
7009 ((gnus-group-read-ephemeral-group
7010 (setq vgroup (format
7011 "nnvirtual:%s-%s" gnus-newsgroup-name
7012 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7013 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7014 t
7015 (cons (current-buffer) 'summary)))
7016 (t
7017 (error "Couldn't select virtual nndoc group")))))
7018
7019 (defun gnus-summary-isearch-article (&optional regexp-p)
7020 "Do incremental search forward on the current article.
7021 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7022 (interactive "P")
7023 (gnus-summary-select-article)
7024 (gnus-configure-windows 'article)
7025 (gnus-eval-in-buffer-window gnus-article-buffer
7026 (save-restriction
7027 (widen)
7028 (isearch-forward regexp-p))))
7029
7030 (defun gnus-summary-search-article-forward (regexp &optional backward)
7031 "Search for an article containing REGEXP forward.
7032 If BACKWARD, search backward instead."
7033 (interactive
7034 (list (read-string
7035 (format "Search article %s (regexp%s): "
7036 (if current-prefix-arg "backward" "forward")
7037 (if gnus-last-search-regexp
7038 (concat ", default " gnus-last-search-regexp)
7039 "")))
7040 current-prefix-arg))
7041 (if (string-equal regexp "")
7042 (setq regexp (or gnus-last-search-regexp ""))
7043 (setq gnus-last-search-regexp regexp))
7044 (if (gnus-summary-search-article regexp backward)
7045 (gnus-summary-show-thread)
7046 (error "Search failed: \"%s\"" regexp)))
7047
7048 (defun gnus-summary-search-article-backward (regexp)
7049 "Search for an article containing REGEXP backward."
7050 (interactive
7051 (list (read-string
7052 (format "Search article backward (regexp%s): "
7053 (if gnus-last-search-regexp
7054 (concat ", default " gnus-last-search-regexp)
7055 "")))))
7056 (gnus-summary-search-article-forward regexp 'backward))
7057
7058 (defun gnus-summary-search-article (regexp &optional backward)
7059 "Search for an article containing REGEXP.
7060 Optional argument BACKWARD means do search for backward.
7061 `gnus-select-article-hook' is not called during the search."
7062 ;; We have to require this here to make sure that the following
7063 ;; dynamic binding isn't shadowed by autoloading.
7064 (require 'gnus-async)
7065 (require 'gnus-art)
7066 (let ((gnus-select-article-hook nil) ;Disable hook.
7067 (gnus-article-prepare-hook nil)
7068 (gnus-mark-article-hook nil) ;Inhibit marking as read.
7069 (gnus-use-article-prefetch nil)
7070 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
7071 (gnus-use-trees nil) ;Inhibit updating tree buffer.
7072 (sum (current-buffer))
7073 (gnus-display-mime-function nil)
7074 (found nil)
7075 point)
7076 (gnus-save-hidden-threads
7077 (gnus-summary-select-article)
7078 (set-buffer gnus-article-buffer)
7079 (goto-char (window-point (get-buffer-window (current-buffer))))
7080 (when backward
7081 (forward-line -1))
7082 (while (not found)
7083 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
7084 (if (if backward
7085 (re-search-backward regexp nil t)
7086 (re-search-forward regexp nil t))
7087 ;; We found the regexp.
7088 (progn
7089 (setq found 'found)
7090 (beginning-of-line)
7091 (set-window-start
7092 (get-buffer-window (current-buffer))
7093 (point))
7094 (forward-line 1)
7095 (set-window-point
7096 (get-buffer-window (current-buffer))
7097 (point))
7098 (set-buffer sum)
7099 (setq point (point)))
7100 ;; We didn't find it, so we go to the next article.
7101 (set-buffer sum)
7102 (setq found 'not)
7103 (while (eq found 'not)
7104 (if (not (if backward (gnus-summary-find-prev)
7105 (gnus-summary-find-next)))
7106 ;; No more articles.
7107 (setq found t)
7108 ;; Select the next article and adjust point.
7109 (unless (gnus-summary-article-sparse-p
7110 (gnus-summary-article-number))
7111 (setq found nil)
7112 (gnus-summary-select-article)
7113 (set-buffer gnus-article-buffer)
7114 (widen)
7115 (goto-char (if backward (point-max) (point-min))))))))
7116 (gnus-message 7 ""))
7117 ;; Return whether we found the regexp.
7118 (when (eq found 'found)
7119 (goto-char point)
7120 (gnus-summary-show-thread)
7121 (gnus-summary-goto-subject gnus-current-article)
7122 (gnus-summary-position-point)
7123 t)))
7124
7125 (defun gnus-summary-find-matching (header regexp &optional backward unread
7126 not-case-fold)
7127 "Return a list of all articles that match REGEXP on HEADER.
7128 The search stars on the current article and goes forwards unless
7129 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
7130 If UNREAD is non-nil, only unread articles will
7131 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
7132 in the comparisons."
7133 (let ((data (if (eq backward 'all) gnus-newsgroup-data
7134 (gnus-data-find-list
7135 (gnus-summary-article-number) (gnus-data-list backward))))
7136 (case-fold-search (not not-case-fold))
7137 articles d func)
7138 (if (consp header)
7139 (if (eq (car header) 'extra)
7140 (setq func
7141 `(lambda (h)
7142 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
7143 "")))
7144 (error "%s is an invalid header" header))
7145 (unless (fboundp (intern (concat "mail-header-" header)))
7146 (error "%s is not a valid header" header))
7147 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
7148 (while data
7149 (setq d (car data))
7150 (and (or (not unread) ; We want all articles...
7151 (gnus-data-unread-p d)) ; Or just unreads.
7152 (vectorp (gnus-data-header d)) ; It's not a pseudo.
7153 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
7154 (push (gnus-data-number d) articles)) ; Success!
7155 (setq data (cdr data)))
7156 (nreverse articles)))
7157
7158 (defun gnus-summary-execute-command (header regexp command &optional backward)
7159 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
7160 If HEADER is an empty string (or nil), the match is done on the entire
7161 article. If BACKWARD (the prefix) is non-nil, search backward instead."
7162 (interactive
7163 (list (let ((completion-ignore-case t))
7164 (completing-read
7165 "Header name: "
7166 (mapcar (lambda (string) (list string))
7167 '("Number" "Subject" "From" "Lines" "Date"
7168 "Message-ID" "Xref" "References" "Body"))
7169 nil 'require-match))
7170 (read-string "Regexp: ")
7171 (read-key-sequence "Command: ")
7172 current-prefix-arg))
7173 (when (equal header "Body")
7174 (setq header ""))
7175 ;; Hidden thread subtrees must be searched as well.
7176 (gnus-summary-show-all-threads)
7177 ;; We don't want to change current point nor window configuration.
7178 (save-excursion
7179 (save-window-excursion
7180 (gnus-message 6 "Executing %s..." (key-description command))
7181 ;; We'd like to execute COMMAND interactively so as to give arguments.
7182 (gnus-execute header regexp
7183 `(call-interactively ',(key-binding command))
7184 backward)
7185 (gnus-message 6 "Executing %s...done" (key-description command)))))
7186
7187 (defun gnus-summary-beginning-of-article ()
7188 "Scroll the article back to the beginning."
7189 (interactive)
7190 (gnus-summary-select-article)
7191 (gnus-configure-windows 'article)
7192 (gnus-eval-in-buffer-window gnus-article-buffer
7193 (widen)
7194 (goto-char (point-min))
7195 (when gnus-page-broken
7196 (gnus-narrow-to-page))))
7197
7198 (defun gnus-summary-end-of-article ()
7199 "Scroll to the end of the article."
7200 (interactive)
7201 (gnus-summary-select-article)
7202 (gnus-configure-windows 'article)
7203 (gnus-eval-in-buffer-window gnus-article-buffer
7204 (widen)
7205 (goto-char (point-max))
7206 (recenter -3)
7207 (when gnus-page-broken
7208 (gnus-narrow-to-page))))
7209
7210 (defun gnus-summary-print-article (&optional filename n)
7211 "Generate and print a PostScript image of the N next (mail) articles.
7212
7213 If N is negative, print the N previous articles. If N is nil and articles
7214 have been marked with the process mark, print these instead.
7215
7216 If the optional first argument FILENAME is nil, send the image to the
7217 printer. If FILENAME is a string, save the PostScript image in a file with
7218 that name. If FILENAME is a number, prompt the user for the name of the file
7219 to save in."
7220 (interactive (list (ps-print-preprint current-prefix-arg)
7221 current-prefix-arg))
7222 (dolist (article (gnus-summary-work-articles n))
7223 (gnus-summary-select-article nil nil 'pseudo article)
7224 (gnus-eval-in-buffer-window gnus-article-buffer
7225 (let ((buffer (generate-new-buffer " *print*")))
7226 (unwind-protect
7227 (progn
7228 (copy-to-buffer buffer (point-min) (point-max))
7229 (set-buffer buffer)
7230 (gnus-article-delete-invisible-text)
7231 (let ((ps-left-header
7232 (list
7233 (concat "("
7234 (mail-header-subject gnus-current-headers) ")")
7235 (concat "("
7236 (mail-header-from gnus-current-headers) ")")))
7237 (ps-right-header
7238 (list
7239 "/pagenumberstring load"
7240 (concat "("
7241 (mail-header-date gnus-current-headers) ")"))))
7242 (gnus-run-hooks 'gnus-ps-print-hook)
7243 (save-excursion
7244 (ps-print-buffer-with-faces filename))))
7245 (kill-buffer buffer))))))
7246
7247 (defun gnus-summary-show-article (&optional arg)
7248 "Force re-fetching of the current article.
7249 If ARG (the prefix) is a number, show the article with the charset
7250 defined in `gnus-summary-show-article-charset-alist', or the charset
7251 inputed.
7252 If ARG (the prefix) is non-nil and not a number, show the raw article
7253 without any article massaging functions being run."
7254 (interactive "P")
7255 (cond
7256 ((numberp arg)
7257 (let ((gnus-newsgroup-charset
7258 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
7259 (read-coding-system "Charset: ")))
7260 (gnus-newsgroup-ignored-charsets 'gnus-all))
7261 (gnus-summary-select-article nil 'force)))
7262 ((not arg)
7263 ;; Select the article the normal way.
7264 (gnus-summary-select-article nil 'force))
7265 (t
7266 ;; We have to require this here to make sure that the following
7267 ;; dynamic binding isn't shadowed by autoloading.
7268 (require 'gnus-async)
7269 (require 'gnus-art)
7270 ;; Bind the article treatment functions to nil.
7271 (let ((gnus-have-all-headers t)
7272 gnus-article-prepare-hook
7273 gnus-article-decode-hook
7274 gnus-display-mime-function
7275 gnus-break-pages)
7276 ;; Destroy any MIME parts.
7277 (when (gnus-buffer-live-p gnus-article-buffer)
7278 (save-excursion
7279 (set-buffer gnus-article-buffer)
7280 (mm-destroy-parts gnus-article-mime-handles)
7281 ;; Set it to nil for safety reason.
7282 (setq gnus-article-mime-handle-alist nil)
7283 (setq gnus-article-mime-handles nil)))
7284 (gnus-summary-select-article nil 'force))))
7285 (gnus-summary-goto-subject gnus-current-article)
7286 (gnus-summary-position-point))
7287
7288 (defun gnus-summary-verbose-headers (&optional arg)
7289 "Toggle permanent full header display.
7290 If ARG is a positive number, turn header display on.
7291 If ARG is a negative number, turn header display off."
7292 (interactive "P")
7293 (setq gnus-show-all-headers
7294 (cond ((or (not (numberp arg))
7295 (zerop arg))
7296 (not gnus-show-all-headers))
7297 ((natnump arg)
7298 t)))
7299 (gnus-summary-show-article))
7300
7301 (defun gnus-summary-toggle-header (&optional arg)
7302 "Show the headers if they are hidden, or hide them if they are shown.
7303 If ARG is a positive number, show the entire header.
7304 If ARG is a negative number, hide the unwanted header lines."
7305 (interactive "P")
7306 (save-excursion
7307 (set-buffer gnus-article-buffer)
7308 (save-restriction
7309 (let* ((buffer-read-only nil)
7310 (inhibit-point-motion-hooks t)
7311 hidden e)
7312 (setq hidden
7313 (if (numberp arg)
7314 (>= arg 0)
7315 (save-restriction
7316 (article-narrow-to-head)
7317 (gnus-article-hidden-text-p 'headers))))
7318 (goto-char (point-min))
7319 (when (search-forward "\n\n" nil t)
7320 (delete-region (point-min) (1- (point))))
7321 (goto-char (point-min))
7322 (save-excursion
7323 (set-buffer gnus-original-article-buffer)
7324 (goto-char (point-min))
7325 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
7326 (insert-buffer-substring gnus-original-article-buffer 1 e)
7327 (save-restriction
7328 (narrow-to-region (point-min) (point))
7329 (article-decode-encoded-words)
7330 (if hidden
7331 (let ((gnus-treat-hide-headers nil)
7332 (gnus-treat-hide-boring-headers nil))
7333 (setq gnus-article-wash-types
7334 (delq 'headers gnus-article-wash-types))
7335 (gnus-treat-article 'head))
7336 (gnus-treat-article 'head)))
7337 (gnus-set-mode-line 'article)))))
7338
7339 (defun gnus-summary-show-all-headers ()
7340 "Make all header lines visible."
7341 (interactive)
7342 (gnus-article-show-all-headers))
7343
7344 (defun gnus-summary-caesar-message (&optional arg)
7345 "Caesar rotate the current article by 13.
7346 The numerical prefix specifies how many places to rotate each letter
7347 forward."
7348 (interactive "P")
7349 (gnus-summary-select-article)
7350 (let ((mail-header-separator ""))
7351 (gnus-eval-in-buffer-window gnus-article-buffer
7352 (save-restriction
7353 (widen)
7354 (let ((start (window-start))
7355 buffer-read-only)
7356 (message-caesar-buffer-body arg)
7357 (set-window-start (get-buffer-window (current-buffer)) start))))))
7358
7359 (defun gnus-summary-stop-page-breaking ()
7360 "Stop page breaking in the current article."
7361 (interactive)
7362 (gnus-summary-select-article)
7363 (gnus-eval-in-buffer-window gnus-article-buffer
7364 (widen)
7365 (when (gnus-visual-p 'page-marker)
7366 (let ((buffer-read-only nil))
7367 (gnus-remove-text-with-property 'gnus-prev)
7368 (gnus-remove-text-with-property 'gnus-next))
7369 (setq gnus-page-broken nil))))
7370
7371 (defun gnus-summary-move-article (&optional n to-newsgroup
7372 select-method action)
7373 "Move the current article to a different newsgroup.
7374 If N is a positive number, move the N next articles.
7375 If N is a negative number, move the N previous articles.
7376 If N is nil and any articles have been marked with the process mark,
7377 move those articles instead.
7378 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7379 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7380 re-spool using this method.
7381
7382 For this function to work, both the current newsgroup and the
7383 newsgroup that you want to move to have to support the `request-move'
7384 and `request-accept' functions.
7385
7386 ACTION can be either `move' (the default), `crosspost' or `copy'."
7387 (interactive "P")
7388 (unless action
7389 (setq action 'move))
7390 ;; Disable marking as read.
7391 (let (gnus-mark-article-hook)
7392 (save-window-excursion
7393 (gnus-summary-select-article)))
7394 ;; Check whether the source group supports the required functions.
7395 (cond ((and (eq action 'move)
7396 (not (gnus-check-backend-function
7397 'request-move-article gnus-newsgroup-name)))
7398 (error "The current group does not support article moving"))
7399 ((and (eq action 'crosspost)
7400 (not (gnus-check-backend-function
7401 'request-replace-article gnus-newsgroup-name)))
7402 (error "The current group does not support article editing")))
7403 (let ((articles (gnus-summary-work-articles n))
7404 (prefix (if (gnus-check-backend-function
7405 'request-move-article gnus-newsgroup-name)
7406 (gnus-group-real-prefix gnus-newsgroup-name)
7407 ""))
7408 (names '((move "Move" "Moving")
7409 (copy "Copy" "Copying")
7410 (crosspost "Crosspost" "Crossposting")))
7411 (copy-buf (save-excursion
7412 (nnheader-set-temp-buffer " *copy article*")))
7413 art-group to-method new-xref article to-groups)
7414 (unless (assq action names)
7415 (error "Unknown action %s" action))
7416 ;; Read the newsgroup name.
7417 (when (and (not to-newsgroup)
7418 (not select-method))
7419 (setq to-newsgroup
7420 (gnus-read-move-group-name
7421 (cadr (assq action names))
7422 (symbol-value (intern (format "gnus-current-%s-group" action)))
7423 articles prefix))
7424 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7425 (setq to-method (or select-method
7426 (gnus-server-to-method
7427 (gnus-group-method to-newsgroup))))
7428 ;; Check the method we are to move this article to...
7429 (unless (gnus-check-backend-function
7430 'request-accept-article (car to-method))
7431 (error "%s does not support article copying" (car to-method)))
7432 (unless (gnus-check-server to-method)
7433 (error "Can't open server %s" (car to-method)))
7434 (gnus-message 6 "%s to %s: %s..."
7435 (caddr (assq action names))
7436 (or (car select-method) to-newsgroup) articles)
7437 (while articles
7438 (setq article (pop articles))
7439 (setq
7440 art-group
7441 (cond
7442 ;; Move the article.
7443 ((eq action 'move)
7444 ;; Remove this article from future suppression.
7445 (gnus-dup-unsuppress-article article)
7446 (gnus-request-move-article
7447 article ; Article to move
7448 gnus-newsgroup-name ; From newsgroup
7449 (nth 1 (gnus-find-method-for-group
7450 gnus-newsgroup-name)) ; Server
7451 (list 'gnus-request-accept-article
7452 to-newsgroup (list 'quote select-method)
7453 (not articles) t) ; Accept form
7454 (not articles))) ; Only save nov last time
7455 ;; Copy the article.
7456 ((eq action 'copy)
7457 (save-excursion
7458 (set-buffer copy-buf)
7459 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7460 (gnus-request-accept-article
7461 to-newsgroup select-method (not articles) t))))
7462 ;; Crosspost the article.
7463 ((eq action 'crosspost)
7464 (let ((xref (message-tokenize-header
7465 (mail-header-xref (gnus-summary-article-header article))
7466 " ")))
7467 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7468 ":" article))
7469 (unless xref
7470 (setq xref (list (system-name))))
7471 (setq new-xref
7472 (concat
7473 (mapconcat 'identity
7474 (delete "Xref:" (delete new-xref xref))
7475 " ")
7476 " " new-xref))
7477 (save-excursion
7478 (set-buffer copy-buf)
7479 ;; First put the article in the destination group.
7480 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7481 (when (consp (setq art-group
7482 (gnus-request-accept-article
7483 to-newsgroup select-method (not articles))))
7484 (setq new-xref (concat new-xref " " (car art-group)
7485 ":" (cdr art-group)))
7486 ;; Now we have the new Xrefs header, so we insert
7487 ;; it and replace the new article.
7488 (nnheader-replace-header "Xref" new-xref)
7489 (gnus-request-replace-article
7490 (cdr art-group) to-newsgroup (current-buffer))
7491 art-group))))))
7492 (cond
7493 ((not art-group)
7494 (gnus-message 1 "Couldn't %s article %s: %s"
7495 (cadr (assq action names)) article
7496 (nnheader-get-report (car to-method))))
7497 ((eq art-group 'junk)
7498 (when (eq action 'move)
7499 (gnus-summary-mark-article article gnus-canceled-mark)
7500 (gnus-message 4 "Deleted article %s" article)))
7501 (t
7502 (let* ((pto-group (gnus-group-prefixed-name
7503 (car art-group) to-method))
7504 (entry
7505 (gnus-gethash pto-group gnus-newsrc-hashtb))
7506 (info (nth 2 entry))
7507 (to-group (gnus-info-group info))
7508 to-marks)
7509 ;; Update the group that has been moved to.
7510 (when (and info
7511 (memq action '(move copy)))
7512 (unless (member to-group to-groups)
7513 (push to-group to-groups))
7514
7515 (unless (memq article gnus-newsgroup-unreads)
7516 (push 'read to-marks)
7517 (gnus-info-set-read
7518 info (gnus-add-to-range (gnus-info-read info)
7519 (list (cdr art-group)))))
7520
7521 ;; See whether the article is to be put in the cache.
7522 (let ((marks gnus-article-mark-lists)
7523 (to-article (cdr art-group)))
7524
7525 ;; Enter the article into the cache in the new group,
7526 ;; if that is required.
7527 (when gnus-use-cache
7528 (gnus-cache-possibly-enter-article
7529 to-group to-article
7530 (memq article gnus-newsgroup-marked)
7531 (memq article gnus-newsgroup-dormant)
7532 (memq article gnus-newsgroup-unreads)))
7533
7534 (when gnus-preserve-marks
7535 ;; Copy any marks over to the new group.
7536 (when (and (equal to-group gnus-newsgroup-name)
7537 (not (memq article gnus-newsgroup-unreads)))
7538 ;; Mark this article as read in this group.
7539 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7540 (setcdr (gnus-active to-group) to-article)
7541 (setcdr gnus-newsgroup-active to-article))
7542
7543 (while marks
7544 (when (memq article (symbol-value
7545 (intern (format "gnus-newsgroup-%s"
7546 (caar marks)))))
7547 (push (cdar marks) to-marks)
7548 ;; If the other group is the same as this group,
7549 ;; then we have to add the mark to the list.
7550 (when (equal to-group gnus-newsgroup-name)
7551 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7552 (cons to-article
7553 (symbol-value
7554 (intern (format "gnus-newsgroup-%s"
7555 (caar marks)))))))
7556 ;; Copy the marks to other group.
7557 (gnus-add-marked-articles
7558 to-group (cdar marks) (list to-article) info))
7559 (setq marks (cdr marks)))
7560
7561 (gnus-request-set-mark to-group (list (list (list to-article)
7562 'set
7563 to-marks))))
7564
7565 (gnus-dribble-enter
7566 (concat "(gnus-group-set-info '"
7567 (gnus-prin1-to-string (gnus-get-info to-group))
7568 ")"))))
7569
7570 ;; Update the Xref header in this article to point to
7571 ;; the new crossposted article we have just created.
7572 (when (eq action 'crosspost)
7573 (save-excursion
7574 (set-buffer copy-buf)
7575 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7576 (nnheader-replace-header "Xref" new-xref)
7577 (gnus-request-replace-article
7578 article gnus-newsgroup-name (current-buffer)))))
7579
7580 ;;;!!!Why is this necessary?
7581 (set-buffer gnus-summary-buffer)
7582
7583 (gnus-summary-goto-subject article)
7584 (when (eq action 'move)
7585 (gnus-summary-mark-article article gnus-canceled-mark))))
7586 (gnus-summary-remove-process-mark article))
7587 ;; Re-activate all groups that have been moved to.
7588 (while to-groups
7589 (save-excursion
7590 (set-buffer gnus-group-buffer)
7591 (when (gnus-group-goto-group (car to-groups) t)
7592 (gnus-group-get-new-news-this-group 1 t))
7593 (pop to-groups)))
7594
7595 (gnus-kill-buffer copy-buf)
7596 (gnus-summary-position-point)
7597 (gnus-set-mode-line 'summary)))
7598
7599 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7600 "Move the current article to a different newsgroup.
7601 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7602 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7603 re-spool using this method."
7604 (interactive "P")
7605 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7606
7607 (defun gnus-summary-crosspost-article (&optional n)
7608 "Crosspost the current article to some other group."
7609 (interactive "P")
7610 (gnus-summary-move-article n nil nil 'crosspost))
7611
7612 (defcustom gnus-summary-respool-default-method nil
7613 "Default method for respooling an article.
7614 If nil, use to the current newsgroup method."
7615 :type '(choice (gnus-select-method :value (nnml ""))
7616 (const nil))
7617 :group 'gnus-summary-mail)
7618
7619 (defun gnus-summary-respool-article (&optional n method)
7620 "Respool the current article.
7621 The article will be squeezed through the mail spooling process again,
7622 which means that it will be put in some mail newsgroup or other
7623 depending on `nnmail-split-methods'.
7624 If N is a positive number, respool the N next articles.
7625 If N is a negative number, respool the N previous articles.
7626 If N is nil and any articles have been marked with the process mark,
7627 respool those articles instead.
7628
7629 Respooling can be done both from mail groups and \"real\" newsgroups.
7630 In the former case, the articles in question will be moved from the
7631 current group into whatever groups they are destined to. In the
7632 latter case, they will be copied into the relevant groups."
7633 (interactive
7634 (list current-prefix-arg
7635 (let* ((methods (gnus-methods-using 'respool))
7636 (methname
7637 (symbol-name (or gnus-summary-respool-default-method
7638 (car (gnus-find-method-for-group
7639 gnus-newsgroup-name)))))
7640 (method
7641 (gnus-completing-read
7642 methname "What backend do you want to use when respooling?"
7643 methods nil t nil 'gnus-mail-method-history))
7644 ms)
7645 (cond
7646 ((zerop (length (setq ms (gnus-servers-using-backend
7647 (intern method)))))
7648 (list (intern method) ""))
7649 ((= 1 (length ms))
7650 (car ms))
7651 (t
7652 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7653 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7654 ms-alist))))))))
7655 (unless method
7656 (error "No method given for respooling"))
7657 (if (assoc (symbol-name
7658 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7659 (gnus-methods-using 'respool))
7660 (gnus-summary-move-article n nil method)
7661 (gnus-summary-copy-article n nil method)))
7662
7663 (defun gnus-summary-import-article (file)
7664 "Import an arbitrary file into a mail newsgroup."
7665 (interactive "fImport file: ")
7666 (let ((group gnus-newsgroup-name)
7667 (now (current-time))
7668 atts lines)
7669 (unless (gnus-check-backend-function 'request-accept-article group)
7670 (error "%s does not support article importing" group))
7671 (or (file-readable-p file)
7672 (not (file-regular-p file))
7673 (error "Can't read %s" file))
7674 (save-excursion
7675 (set-buffer (gnus-get-buffer-create " *import file*"))
7676 (erase-buffer)
7677 (nnheader-insert-file-contents file)
7678 (goto-char (point-min))
7679 (unless (nnheader-article-p)
7680 ;; This doesn't look like an article, so we fudge some headers.
7681 (setq atts (file-attributes file)
7682 lines (count-lines (point-min) (point-max)))
7683 (insert "From: " (read-string "From: ") "\n"
7684 "Subject: " (read-string "Subject: ") "\n"
7685 "Date: " (message-make-date (nth 5 atts))
7686 "\n"
7687 "Message-ID: " (message-make-message-id) "\n"
7688 "Lines: " (int-to-string lines) "\n"
7689 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7690 (gnus-request-accept-article group nil t)
7691 (kill-buffer (current-buffer)))))
7692
7693 (defun gnus-summary-article-posted-p ()
7694 "Say whether the current (mail) article is available from news as well.
7695 This will be the case if the article has both been mailed and posted."
7696 (interactive)
7697 (let ((id (mail-header-references (gnus-summary-article-header)))
7698 (gnus-override-method (car (gnus-refer-article-methods))))
7699 (if (gnus-request-head id "")
7700 (gnus-message 2 "The current message was found on %s"
7701 gnus-override-method)
7702 (gnus-message 2 "The current message couldn't be found on %s"
7703 gnus-override-method)
7704 nil)))
7705
7706 (defun gnus-summary-expire-articles (&optional now)
7707 "Expire all articles that are marked as expirable in the current group."
7708 (interactive)
7709 (when (gnus-check-backend-function
7710 'request-expire-articles gnus-newsgroup-name)
7711 ;; This backend supports expiry.
7712 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7713 (expirable (if total
7714 (progn
7715 ;; We need to update the info for
7716 ;; this group for `gnus-list-of-read-articles'
7717 ;; to give us the right answer.
7718 (gnus-run-hooks 'gnus-exit-group-hook)
7719 (gnus-summary-update-info)
7720 (gnus-list-of-read-articles gnus-newsgroup-name))
7721 (setq gnus-newsgroup-expirable
7722 (sort gnus-newsgroup-expirable '<))))
7723 (expiry-wait (if now 'immediate
7724 (gnus-group-find-parameter
7725 gnus-newsgroup-name 'expiry-wait)))
7726 (nnmail-expiry-target
7727 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
7728 nnmail-expiry-target))
7729 es)
7730 (when expirable
7731 ;; There are expirable articles in this group, so we run them
7732 ;; through the expiry process.
7733 (gnus-message 6 "Expiring articles...")
7734 (unless (gnus-check-group gnus-newsgroup-name)
7735 (error "Can't open server for %s" gnus-newsgroup-name))
7736 ;; The list of articles that weren't expired is returned.
7737 (save-excursion
7738 (if expiry-wait
7739 (let ((nnmail-expiry-wait-function nil)
7740 (nnmail-expiry-wait expiry-wait))
7741 (setq es (gnus-request-expire-articles
7742 expirable gnus-newsgroup-name)))
7743 (setq es (gnus-request-expire-articles
7744 expirable gnus-newsgroup-name))))
7745 (unless total
7746 (setq gnus-newsgroup-expirable es))
7747 ;; We go through the old list of expirable, and mark all
7748 ;; really expired articles as nonexistent.
7749 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7750 (let ((gnus-use-cache nil))
7751 (while expirable
7752 (unless (memq (car expirable) es)
7753 (when (gnus-data-find (car expirable))
7754 (gnus-summary-mark-article
7755 (car expirable) gnus-canceled-mark)))
7756 (setq expirable (cdr expirable)))))
7757 (gnus-message 6 "Expiring articles...done")))))
7758
7759 (defun gnus-summary-expire-articles-now ()
7760 "Expunge all expirable articles in the current group.
7761 This means that *all* articles that are marked as expirable will be
7762 deleted forever, right now."
7763 (interactive)
7764 (or gnus-expert-user
7765 (gnus-yes-or-no-p
7766 "Are you really, really, really sure you want to delete all these messages? ")
7767 (error "Phew!"))
7768 (gnus-summary-expire-articles t))
7769
7770 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7771 (defun gnus-summary-delete-article (&optional n)
7772 "Delete the N next (mail) articles.
7773 This command actually deletes articles. This is not a marking
7774 command. The article will disappear forever from your life, never to
7775 return.
7776 If N is negative, delete backwards.
7777 If N is nil and articles have been marked with the process mark,
7778 delete these instead."
7779 (interactive "P")
7780 (unless (gnus-check-backend-function 'request-expire-articles
7781 gnus-newsgroup-name)
7782 (error "The current newsgroup does not support article deletion"))
7783 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7784 (error "Couldn't open server"))
7785 ;; Compute the list of articles to delete.
7786 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7787 not-deleted)
7788 (if (and gnus-novice-user
7789 (not (gnus-yes-or-no-p
7790 (format "Do you really want to delete %s forever? "
7791 (if (> (length articles) 1)
7792 (format "these %s articles" (length articles))
7793 "this article")))))
7794 ()
7795 ;; Delete the articles.
7796 (setq not-deleted (gnus-request-expire-articles
7797 articles gnus-newsgroup-name 'force))
7798 (while articles
7799 (gnus-summary-remove-process-mark (car articles))
7800 ;; The backend might not have been able to delete the article
7801 ;; after all.
7802 (unless (memq (car articles) not-deleted)
7803 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7804 (setq articles (cdr articles)))
7805 (when not-deleted
7806 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7807 (gnus-summary-position-point)
7808 (gnus-set-mode-line 'summary)
7809 not-deleted))
7810
7811 (defun gnus-summary-edit-article (&optional arg)
7812 "Edit the current article.
7813 This will have permanent effect only in mail groups.
7814 If ARG is nil, edit the decoded articles.
7815 If ARG is 1, edit the raw articles.
7816 If ARG is 2, edit the raw articles even in read-only groups.
7817 Otherwise, allow editing of articles even in read-only
7818 groups."
7819 (interactive "P")
7820 (let (force raw)
7821 (cond
7822 ((null arg))
7823 ((eq arg 1) (setq raw t))
7824 ((eq arg 2) (setq raw t
7825 force t))
7826 (t (setq force t)))
7827 (if (and raw (not force) (equal gnus-newsgroup-name "nndraft:drafts"))
7828 (error "Can't edit the raw article in group nndraft:drafts."))
7829 (save-excursion
7830 (set-buffer gnus-summary-buffer)
7831 (let ((mail-parse-charset gnus-newsgroup-charset)
7832 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
7833 (gnus-set-global-variables)
7834 (when (and (not force)
7835 (gnus-group-read-only-p))
7836 (error "The current newsgroup does not support article editing"))
7837 (gnus-summary-show-article t)
7838 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
7839 (with-current-buffer gnus-article-buffer
7840 (mm-enable-multibyte-mule4)))
7841 (if (equal gnus-newsgroup-name "nndraft:drafts")
7842 (setq raw t))
7843 (gnus-article-edit-article
7844 (if raw 'ignore
7845 #'(lambda ()
7846 (let ((mbl mml-buffer-list))
7847 (setq mml-buffer-list nil)
7848 (mime-to-mml)
7849 (make-local-hook 'kill-buffer-hook)
7850 (let ((mml-buffer-list mml-buffer-list))
7851 (setq mml-buffer-list mbl)
7852 (make-local-variable 'mml-buffer-list))
7853 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
7854 `(lambda (no-highlight)
7855 (let ((mail-parse-charset ',gnus-newsgroup-charset)
7856 (mail-parse-ignored-charsets
7857 ',gnus-newsgroup-ignored-charsets))
7858 ,(if (not raw) '(progn
7859 (mml-to-mime)
7860 (mml-destroy-buffers)
7861 (remove-hook 'kill-buffer-hook
7862 'mml-destroy-buffers t)
7863 (kill-local-variable 'mml-buffer-list)))
7864 (gnus-summary-edit-article-done
7865 ,(or (mail-header-references gnus-current-headers) "")
7866 ,(gnus-group-read-only-p)
7867 ,gnus-summary-buffer no-highlight))))))))
7868
7869 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7870
7871 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7872 no-highlight)
7873 "Make edits to the current article permanent."
7874 (interactive)
7875 ;; Replace the article.
7876 (let ((buf (current-buffer)))
7877 (with-temp-buffer
7878 (insert-buffer-substring buf)
7879 (if (and (not read-only)
7880 (not (gnus-request-replace-article
7881 (cdr gnus-article-current) (car gnus-article-current)
7882 (current-buffer) t)))
7883 (error "Couldn't replace article")
7884 ;; Update the summary buffer.
7885 (if (and references
7886 (equal (message-tokenize-header references " ")
7887 (message-tokenize-header
7888 (or (message-fetch-field "references") "") " ")))
7889 ;; We only have to update this line.
7890 (save-excursion
7891 (save-restriction
7892 (message-narrow-to-head)
7893 (let ((head (buffer-string))
7894 header)
7895 (with-temp-buffer
7896 (insert (format "211 %d Article retrieved.\n"
7897 (cdr gnus-article-current)))
7898 (insert head)
7899 (insert ".\n")
7900 (let ((nntp-server-buffer (current-buffer)))
7901 (setq header (car (gnus-get-newsgroup-headers
7902 (save-excursion
7903 (set-buffer gnus-summary-buffer)
7904 gnus-newsgroup-dependencies)
7905 t))))
7906 (save-excursion
7907 (set-buffer gnus-summary-buffer)
7908 (gnus-data-set-header
7909 (gnus-data-find (cdr gnus-article-current))
7910 header)
7911 (gnus-summary-update-article-line
7912 (cdr gnus-article-current) header))))))
7913 ;; Update threads.
7914 (set-buffer (or buffer gnus-summary-buffer))
7915 (gnus-summary-update-article (cdr gnus-article-current)))
7916 ;; Prettify the article buffer again.
7917 (unless no-highlight
7918 (save-excursion
7919 (set-buffer gnus-article-buffer)
7920 ;;;!!! Fix this -- article should be rehighlighted.
7921 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7922 (set-buffer gnus-original-article-buffer)
7923 (gnus-request-article
7924 (cdr gnus-article-current)
7925 (car gnus-article-current) (current-buffer))))
7926 ;; Prettify the summary buffer line.
7927 (when (gnus-visual-p 'summary-highlight 'highlight)
7928 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7929
7930 (defun gnus-summary-edit-wash (key)
7931 "Perform editing command KEY in the article buffer."
7932 (interactive
7933 (list
7934 (progn
7935 (message "%s" (concat (this-command-keys) "- "))
7936 (read-char))))
7937 (message "")
7938 (gnus-summary-edit-article)
7939 (execute-kbd-macro (concat (this-command-keys) key))
7940 (gnus-article-edit-done))
7941
7942 ;;; Respooling
7943
7944 (defun gnus-summary-respool-query (&optional silent trace)
7945 "Query where the respool algorithm would put this article."
7946 (interactive)
7947 (let (gnus-mark-article-hook)
7948 (gnus-summary-select-article)
7949 (save-excursion
7950 (set-buffer gnus-original-article-buffer)
7951 (save-restriction
7952 (message-narrow-to-head)
7953 (let ((groups (nnmail-article-group 'identity trace)))
7954 (unless silent
7955 (if groups
7956 (message "This message would go to %s"
7957 (mapconcat 'car groups ", "))
7958 (message "This message would go to no groups"))
7959 groups))))))
7960
7961 (defun gnus-summary-respool-trace ()
7962 "Trace where the respool algorithm would put this article.
7963 Display a buffer showing all fancy splitting patterns which matched."
7964 (interactive)
7965 (gnus-summary-respool-query nil t))
7966
7967 ;; Summary marking commands.
7968
7969 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7970 "Mark articles which has the same subject as read, and then select the next.
7971 If UNMARK is positive, remove any kind of mark.
7972 If UNMARK is negative, tick articles."
7973 (interactive "P")
7974 (when unmark
7975 (setq unmark (prefix-numeric-value unmark)))
7976 (let ((count
7977 (gnus-summary-mark-same-subject
7978 (gnus-summary-article-subject) unmark)))
7979 ;; Select next unread article. If auto-select-same mode, should
7980 ;; select the first unread article.
7981 (gnus-summary-next-article t (and gnus-auto-select-same
7982 (gnus-summary-article-subject)))
7983 (gnus-message 7 "%d article%s marked as %s"
7984 count (if (= count 1) " is" "s are")
7985 (if unmark "unread" "read"))))
7986
7987 (defun gnus-summary-kill-same-subject (&optional unmark)
7988 "Mark articles which has the same subject as read.
7989 If UNMARK is positive, remove any kind of mark.
7990 If UNMARK is negative, tick articles."
7991 (interactive "P")
7992 (when unmark
7993 (setq unmark (prefix-numeric-value unmark)))
7994 (let ((count
7995 (gnus-summary-mark-same-subject
7996 (gnus-summary-article-subject) unmark)))
7997 ;; If marked as read, go to next unread subject.
7998 (when (null unmark)
7999 ;; Go to next unread subject.
8000 (gnus-summary-next-subject 1 t))
8001 (gnus-message 7 "%d articles are marked as %s"
8002 count (if unmark "unread" "read"))))
8003
8004 (defun gnus-summary-mark-same-subject (subject &optional unmark)
8005 "Mark articles with same SUBJECT as read, and return marked number.
8006 If optional argument UNMARK is positive, remove any kinds of marks.
8007 If optional argument UNMARK is negative, mark articles as unread instead."
8008 (let ((count 1))
8009 (save-excursion
8010 (cond
8011 ((null unmark) ; Mark as read.
8012 (while (and
8013 (progn
8014 (gnus-summary-mark-article-as-read gnus-killed-mark)
8015 (gnus-summary-show-thread) t)
8016 (gnus-summary-find-subject subject))
8017 (setq count (1+ count))))
8018 ((> unmark 0) ; Tick.
8019 (while (and
8020 (progn
8021 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
8022 (gnus-summary-show-thread) t)
8023 (gnus-summary-find-subject subject))
8024 (setq count (1+ count))))
8025 (t ; Mark as unread.
8026 (while (and
8027 (progn
8028 (gnus-summary-mark-article-as-unread gnus-unread-mark)
8029 (gnus-summary-show-thread) t)
8030 (gnus-summary-find-subject subject))
8031 (setq count (1+ count)))))
8032 (gnus-set-mode-line 'summary)
8033 ;; Return the number of marked articles.
8034 count)))
8035
8036 (defun gnus-summary-mark-as-processable (n &optional unmark)
8037 "Set the process mark on the next N articles.
8038 If N is negative, mark backward instead. If UNMARK is non-nil, remove
8039 the process mark instead. The difference between N and the actual
8040 number of articles marked is returned."
8041 (interactive "p")
8042 (let ((backward (< n 0))
8043 (n (abs n)))
8044 (while (and
8045 (> n 0)
8046 (if unmark
8047 (gnus-summary-remove-process-mark
8048 (gnus-summary-article-number))
8049 (gnus-summary-set-process-mark (gnus-summary-article-number)))
8050 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
8051 (setq n (1- n)))
8052 (when (/= 0 n)
8053 (gnus-message 7 "No more articles"))
8054 (gnus-summary-recenter)
8055 (gnus-summary-position-point)
8056 n))
8057
8058 (defun gnus-summary-unmark-as-processable (n)
8059 "Remove the process mark from the next N articles.
8060 If N is negative, unmark backward instead. The difference between N and
8061 the actual number of articles unmarked is returned."
8062 (interactive "p")
8063 (gnus-summary-mark-as-processable n t))
8064
8065 (defun gnus-summary-unmark-all-processable ()
8066 "Remove the process mark from all articles."
8067 (interactive)
8068 (save-excursion
8069 (while gnus-newsgroup-processable
8070 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
8071 (gnus-summary-position-point))
8072
8073 (defun gnus-summary-mark-as-expirable (n)
8074 "Mark N articles forward as expirable.
8075 If N is negative, mark backward instead. The difference between N and
8076 the actual number of articles marked is returned."
8077 (interactive "p")
8078 (gnus-summary-mark-forward n gnus-expirable-mark))
8079
8080 (defun gnus-summary-mark-article-as-replied (article)
8081 "Mark ARTICLE replied and update the summary line."
8082 (push article gnus-newsgroup-replied)
8083 (let ((buffer-read-only nil))
8084 (when (gnus-summary-goto-subject article nil t)
8085 (gnus-summary-update-secondary-mark article))))
8086
8087 (defun gnus-summary-set-bookmark (article)
8088 "Set a bookmark in current article."
8089 (interactive (list (gnus-summary-article-number)))
8090 (when (or (not (get-buffer gnus-article-buffer))
8091 (not gnus-current-article)
8092 (not gnus-article-current)
8093 (not (equal gnus-newsgroup-name (car gnus-article-current))))
8094 (error "No current article selected"))
8095 ;; Remove old bookmark, if one exists.
8096 (let ((old (assq article gnus-newsgroup-bookmarks)))
8097 (when old
8098 (setq gnus-newsgroup-bookmarks
8099 (delq old gnus-newsgroup-bookmarks))))
8100 ;; Set the new bookmark, which is on the form
8101 ;; (article-number . line-number-in-body).
8102 (push
8103 (cons article
8104 (save-excursion
8105 (set-buffer gnus-article-buffer)
8106 (count-lines
8107 (min (point)
8108 (save-excursion
8109 (goto-char (point-min))
8110 (search-forward "\n\n" nil t)
8111 (point)))
8112 (point))))
8113 gnus-newsgroup-bookmarks)
8114 (gnus-message 6 "A bookmark has been added to the current article."))
8115
8116 (defun gnus-summary-remove-bookmark (article)
8117 "Remove the bookmark from the current article."
8118 (interactive (list (gnus-summary-article-number)))
8119 ;; Remove old bookmark, if one exists.
8120 (let ((old (assq article gnus-newsgroup-bookmarks)))
8121 (if old
8122 (progn
8123 (setq gnus-newsgroup-bookmarks
8124 (delq old gnus-newsgroup-bookmarks))
8125 (gnus-message 6 "Removed bookmark."))
8126 (gnus-message 6 "No bookmark in current article."))))
8127
8128 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8129 (defun gnus-summary-mark-as-dormant (n)
8130 "Mark N articles forward as dormant.
8131 If N is negative, mark backward instead. The difference between N and
8132 the actual number of articles marked is returned."
8133 (interactive "p")
8134 (gnus-summary-mark-forward n gnus-dormant-mark))
8135
8136 (defun gnus-summary-set-process-mark (article)
8137 "Set the process mark on ARTICLE and update the summary line."
8138 (setq gnus-newsgroup-processable
8139 (cons article
8140 (delq article gnus-newsgroup-processable)))
8141 (when (gnus-summary-goto-subject article)
8142 (gnus-summary-show-thread)
8143 (gnus-summary-goto-subject article)
8144 (gnus-summary-update-secondary-mark article)))
8145
8146 (defun gnus-summary-remove-process-mark (article)
8147 "Remove the process mark from ARTICLE and update the summary line."
8148 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
8149 (when (gnus-summary-goto-subject article)
8150 (gnus-summary-show-thread)
8151 (gnus-summary-goto-subject article)
8152 (gnus-summary-update-secondary-mark article)))
8153
8154 (defun gnus-summary-set-saved-mark (article)
8155 "Set the process mark on ARTICLE and update the summary line."
8156 (push article gnus-newsgroup-saved)
8157 (when (gnus-summary-goto-subject article)
8158 (gnus-summary-update-secondary-mark article)))
8159
8160 (defun gnus-summary-mark-forward (n &optional mark no-expire)
8161 "Mark N articles as read forwards.
8162 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
8163 The difference between N and the actual number of articles marked is
8164 returned.
8165 Iff NO-EXPIRE, auto-expiry will be inhibited."
8166 (interactive "p")
8167 (gnus-summary-show-thread)
8168 (let ((backward (< n 0))
8169 (gnus-summary-goto-unread
8170 (and gnus-summary-goto-unread
8171 (not (eq gnus-summary-goto-unread 'never))
8172 (not (memq mark (list gnus-unread-mark
8173 gnus-ticked-mark gnus-dormant-mark)))))
8174 (n (abs n))
8175 (mark (or mark gnus-del-mark)))
8176 (while (and (> n 0)
8177 (gnus-summary-mark-article nil mark no-expire)
8178 (zerop (gnus-summary-next-subject
8179 (if backward -1 1)
8180 (and gnus-summary-goto-unread
8181 (not (eq gnus-summary-goto-unread 'never)))
8182 t)))
8183 (setq n (1- n)))
8184 (when (/= 0 n)
8185 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
8186 (gnus-summary-recenter)
8187 (gnus-summary-position-point)
8188 (gnus-set-mode-line 'summary)
8189 n))
8190
8191 (defun gnus-summary-mark-article-as-read (mark)
8192 "Mark the current article quickly as read with MARK."
8193 (let ((article (gnus-summary-article-number)))
8194 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8195 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8196 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8197 (push (cons article mark) gnus-newsgroup-reads)
8198 ;; Possibly remove from cache, if that is used.
8199 (when gnus-use-cache
8200 (gnus-cache-enter-remove-article article))
8201 ;; Allow the backend to change the mark.
8202 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8203 ;; Check for auto-expiry.
8204 (when (and gnus-newsgroup-auto-expire
8205 (memq mark gnus-auto-expirable-marks))
8206 (setq mark gnus-expirable-mark)
8207 ;; Let the backend know about the mark change.
8208 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8209 (push article gnus-newsgroup-expirable))
8210 ;; Set the mark in the buffer.
8211 (gnus-summary-update-mark mark 'unread)
8212 t))
8213
8214 (defun gnus-summary-mark-article-as-unread (mark)
8215 "Mark the current article quickly as unread with MARK."
8216 (let* ((article (gnus-summary-article-number))
8217 (old-mark (gnus-summary-article-mark article)))
8218 ;; Allow the backend to change the mark.
8219 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8220 (if (eq mark old-mark)
8221 t
8222 (if (<= article 0)
8223 (progn
8224 (gnus-error 1 "Can't mark negative article numbers")
8225 nil)
8226 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8227 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8228 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
8229 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
8230 (cond ((= mark gnus-ticked-mark)
8231 (push article gnus-newsgroup-marked))
8232 ((= mark gnus-dormant-mark)
8233 (push article gnus-newsgroup-dormant))
8234 (t
8235 (push article gnus-newsgroup-unreads)))
8236 (gnus-pull article gnus-newsgroup-reads)
8237
8238 ;; See whether the article is to be put in the cache.
8239 (and gnus-use-cache
8240 (vectorp (gnus-summary-article-header article))
8241 (save-excursion
8242 (gnus-cache-possibly-enter-article
8243 gnus-newsgroup-name article
8244 (= mark gnus-ticked-mark)
8245 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8246
8247 ;; Fix the mark.
8248 (gnus-summary-update-mark mark 'unread)
8249 t))))
8250
8251 (defun gnus-summary-mark-article (&optional article mark no-expire)
8252 "Mark ARTICLE with MARK. MARK can be any character.
8253 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
8254 `??' (dormant) and `?E' (expirable).
8255 If MARK is nil, then the default character `?r' is used.
8256 If ARTICLE is nil, then the article on the current line will be
8257 marked.
8258 Iff NO-EXPIRE, auto-expiry will be inhibited."
8259 ;; The mark might be a string.
8260 (when (stringp mark)
8261 (setq mark (aref mark 0)))
8262 ;; If no mark is given, then we check auto-expiring.
8263 (when (null mark)
8264 (setq mark gnus-del-mark))
8265 (when (and (not no-expire)
8266 gnus-newsgroup-auto-expire
8267 (memq mark gnus-auto-expirable-marks))
8268 (setq mark gnus-expirable-mark))
8269 (let ((article (or article (gnus-summary-article-number)))
8270 (old-mark (gnus-summary-article-mark article)))
8271 ;; Allow the backend to change the mark.
8272 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
8273 (if (eq mark old-mark)
8274 t
8275 (unless article
8276 (error "No article on current line"))
8277 (if (not (if (or (= mark gnus-unread-mark)
8278 (= mark gnus-ticked-mark)
8279 (= mark gnus-dormant-mark))
8280 (gnus-mark-article-as-unread article mark)
8281 (gnus-mark-article-as-read article mark)))
8282 t
8283 ;; See whether the article is to be put in the cache.
8284 (and gnus-use-cache
8285 (not (= mark gnus-canceled-mark))
8286 (vectorp (gnus-summary-article-header article))
8287 (save-excursion
8288 (gnus-cache-possibly-enter-article
8289 gnus-newsgroup-name article
8290 (= mark gnus-ticked-mark)
8291 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
8292
8293 (when (gnus-summary-goto-subject article nil t)
8294 (let ((buffer-read-only nil))
8295 (gnus-summary-show-thread)
8296 ;; Fix the mark.
8297 (gnus-summary-update-mark mark 'unread)
8298 t))))))
8299
8300 (defun gnus-summary-update-secondary-mark (article)
8301 "Update the secondary (read, process, cache) mark."
8302 (gnus-summary-update-mark
8303 (cond ((memq article gnus-newsgroup-processable)
8304 gnus-process-mark)
8305 ((memq article gnus-newsgroup-cached)
8306 gnus-cached-mark)
8307 ((memq article gnus-newsgroup-replied)
8308 gnus-replied-mark)
8309 ((memq article gnus-newsgroup-saved)
8310 gnus-saved-mark)
8311 (t gnus-unread-mark))
8312 'replied)
8313 (when (gnus-visual-p 'summary-highlight 'highlight)
8314 (gnus-run-hooks 'gnus-summary-update-hook))
8315 t)
8316
8317 (defun gnus-summary-update-mark (mark type)
8318 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
8319 (buffer-read-only nil))
8320 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
8321 (when forward
8322 (when (looking-at "\r")
8323 (incf forward))
8324 (when (<= (+ forward (point)) (point-max))
8325 ;; Go to the right position on the line.
8326 (goto-char (+ forward (point)))
8327 ;; Replace the old mark with the new mark.
8328 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
8329 ;; Optionally update the marks by some user rule.
8330 (when (eq type 'unread)
8331 (gnus-data-set-mark
8332 (gnus-data-find (gnus-summary-article-number)) mark)
8333 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
8334
8335 (defun gnus-mark-article-as-read (article &optional mark)
8336 "Enter ARTICLE in the pertinent lists and remove it from others."
8337 ;; Make the article expirable.
8338 (let ((mark (or mark gnus-del-mark)))
8339 (if (= mark gnus-expirable-mark)
8340 (push article gnus-newsgroup-expirable)
8341 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
8342 ;; Remove from unread and marked lists.
8343 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8344 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
8345 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
8346 (push (cons article mark) gnus-newsgroup-reads)
8347 ;; Possibly remove from cache, if that is used.
8348 (when gnus-use-cache
8349 (gnus-cache-enter-remove-article article))
8350 t))
8351
8352 (defun gnus-mark-article-as-unread (article &optional mark)
8353 "Enter ARTICLE in the pertinent lists and remove it from others."
8354 (let ((mark (or mark gnus-ticked-mark)))
8355 (if (<= article 0)
8356 (progn
8357 (gnus-error 1 "Can't mark negative article numbers")
8358 nil)
8359 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
8360 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
8361 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
8362 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
8363
8364 ;; Unsuppress duplicates?
8365 (when gnus-suppress-duplicates
8366 (gnus-dup-unsuppress-article article))
8367
8368 (cond ((= mark gnus-ticked-mark)
8369 (push article gnus-newsgroup-marked))
8370 ((= mark gnus-dormant-mark)
8371 (push article gnus-newsgroup-dormant))
8372 (t
8373 (push article gnus-newsgroup-unreads)))
8374 (gnus-pull article gnus-newsgroup-reads)
8375 t)))
8376
8377 (defalias 'gnus-summary-mark-as-unread-forward
8378 'gnus-summary-tick-article-forward)
8379 (make-obsolete 'gnus-summary-mark-as-unread-forward
8380 'gnus-summary-tick-article-forward)
8381 (defun gnus-summary-tick-article-forward (n)
8382 "Tick N articles forwards.
8383 If N is negative, tick backwards instead.
8384 The difference between N and the number of articles ticked is returned."
8385 (interactive "p")
8386 (gnus-summary-mark-forward n gnus-ticked-mark))
8387
8388 (defalias 'gnus-summary-mark-as-unread-backward
8389 'gnus-summary-tick-article-backward)
8390 (make-obsolete 'gnus-summary-mark-as-unread-backward
8391 'gnus-summary-tick-article-backward)
8392 (defun gnus-summary-tick-article-backward (n)
8393 "Tick N articles backwards.
8394 The difference between N and the number of articles ticked is returned."
8395 (interactive "p")
8396 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8397
8398 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8399 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8400 (defun gnus-summary-tick-article (&optional article clear-mark)
8401 "Mark current article as unread.
8402 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8403 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8404 (interactive)
8405 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8406 gnus-ticked-mark)))
8407
8408 (defun gnus-summary-mark-as-read-forward (n)
8409 "Mark N articles as read forwards.
8410 If N is negative, mark backwards instead.
8411 The difference between N and the actual number of articles marked is
8412 returned."
8413 (interactive "p")
8414 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8415
8416 (defun gnus-summary-mark-as-read-backward (n)
8417 "Mark the N articles as read backwards.
8418 The difference between N and the actual number of articles marked is
8419 returned."
8420 (interactive "p")
8421 (gnus-summary-mark-forward
8422 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8423
8424 (defun gnus-summary-mark-as-read (&optional article mark)
8425 "Mark current article as read.
8426 ARTICLE specifies the article to be marked as read.
8427 MARK specifies a string to be inserted at the beginning of the line."
8428 (gnus-summary-mark-article article mark))
8429
8430 (defun gnus-summary-clear-mark-forward (n)
8431 "Clear marks from N articles forward.
8432 If N is negative, clear backward instead.
8433 The difference between N and the number of marks cleared is returned."
8434 (interactive "p")
8435 (gnus-summary-mark-forward n gnus-unread-mark))
8436
8437 (defun gnus-summary-clear-mark-backward (n)
8438 "Clear marks from N articles backward.
8439 The difference between N and the number of marks cleared is returned."
8440 (interactive "p")
8441 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8442
8443 (defun gnus-summary-mark-unread-as-read ()
8444 "Intended to be used by `gnus-summary-mark-article-hook'."
8445 (when (memq gnus-current-article gnus-newsgroup-unreads)
8446 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8447
8448 (defun gnus-summary-mark-read-and-unread-as-read ()
8449 "Intended to be used by `gnus-summary-mark-article-hook'."
8450 (let ((mark (gnus-summary-article-mark)))
8451 (when (or (gnus-unread-mark-p mark)
8452 (gnus-read-mark-p mark))
8453 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8454
8455 (defun gnus-summary-mark-region-as-read (point mark all)
8456 "Mark all unread articles between point and mark as read.
8457 If given a prefix, mark all articles between point and mark as read,
8458 even ticked and dormant ones."
8459 (interactive "r\nP")
8460 (save-excursion
8461 (let (article)
8462 (goto-char point)
8463 (beginning-of-line)
8464 (while (and
8465 (< (point) mark)
8466 (progn
8467 (when (or all
8468 (memq (setq article (gnus-summary-article-number))
8469 gnus-newsgroup-unreads))
8470 (gnus-summary-mark-article article gnus-del-mark))
8471 t)
8472 (gnus-summary-find-next))))))
8473
8474 (defun gnus-summary-mark-below (score mark)
8475 "Mark articles with score less than SCORE with MARK."
8476 (interactive "P\ncMark: ")
8477 (setq score (if score
8478 (prefix-numeric-value score)
8479 (or gnus-summary-default-score 0)))
8480 (save-excursion
8481 (set-buffer gnus-summary-buffer)
8482 (goto-char (point-min))
8483 (while
8484 (progn
8485 (and (< (gnus-summary-article-score) score)
8486 (gnus-summary-mark-article nil mark))
8487 (gnus-summary-find-next)))))
8488
8489 (defun gnus-summary-kill-below (&optional score)
8490 "Mark articles with score below SCORE as read."
8491 (interactive "P")
8492 (gnus-summary-mark-below score gnus-killed-mark))
8493
8494 (defun gnus-summary-clear-above (&optional score)
8495 "Clear all marks from articles with score above SCORE."
8496 (interactive "P")
8497 (gnus-summary-mark-above score gnus-unread-mark))
8498
8499 (defun gnus-summary-tick-above (&optional score)
8500 "Tick all articles with score above SCORE."
8501 (interactive "P")
8502 (gnus-summary-mark-above score gnus-ticked-mark))
8503
8504 (defun gnus-summary-mark-above (score mark)
8505 "Mark articles with score over SCORE with MARK."
8506 (interactive "P\ncMark: ")
8507 (setq score (if score
8508 (prefix-numeric-value score)
8509 (or gnus-summary-default-score 0)))
8510 (save-excursion
8511 (set-buffer gnus-summary-buffer)
8512 (goto-char (point-min))
8513 (while (and (progn
8514 (when (> (gnus-summary-article-score) score)
8515 (gnus-summary-mark-article nil mark))
8516 t)
8517 (gnus-summary-find-next)))))
8518
8519 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8520 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8521 (defun gnus-summary-limit-include-expunged (&optional no-error)
8522 "Display all the hidden articles that were expunged for low scores."
8523 (interactive)
8524 (let ((buffer-read-only nil))
8525 (let ((scored gnus-newsgroup-scored)
8526 headers h)
8527 (while scored
8528 (unless (gnus-summary-goto-subject (caar scored))
8529 (and (setq h (gnus-summary-article-header (caar scored)))
8530 (< (cdar scored) gnus-summary-expunge-below)
8531 (push h headers)))
8532 (setq scored (cdr scored)))
8533 (if (not headers)
8534 (when (not no-error)
8535 (error "No expunged articles hidden"))
8536 (goto-char (point-min))
8537 (gnus-summary-prepare-unthreaded (nreverse headers))
8538 (goto-char (point-min))
8539 (gnus-summary-position-point)
8540 t))))
8541
8542 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8543 "Mark all unread articles in this newsgroup as read.
8544 If prefix argument ALL is non-nil, ticked and dormant articles will
8545 also be marked as read.
8546 If QUIETLY is non-nil, no questions will be asked.
8547 If TO-HERE is non-nil, it should be a point in the buffer. All
8548 articles before this point will be marked as read.
8549 Note that this function will only catch up the unread article
8550 in the current summary buffer limitation.
8551 The number of articles marked as read is returned."
8552 (interactive "P")
8553 (prog1
8554 (save-excursion
8555 (when (or quietly
8556 (not gnus-interactive-catchup) ;Without confirmation?
8557 gnus-expert-user
8558 (gnus-y-or-n-p
8559 (if all
8560 "Mark absolutely all articles as read? "
8561 "Mark all unread articles as read? ")))
8562 (if (and not-mark
8563 (not gnus-newsgroup-adaptive)
8564 (not gnus-newsgroup-auto-expire)
8565 (not gnus-suppress-duplicates)
8566 (or (not gnus-use-cache)
8567 (eq gnus-use-cache 'passive)))
8568 (progn
8569 (when all
8570 (setq gnus-newsgroup-marked nil
8571 gnus-newsgroup-dormant nil))
8572 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8573 ;; We actually mark all articles as canceled, which we
8574 ;; have to do when using auto-expiry or adaptive scoring.
8575 (gnus-summary-show-all-threads)
8576 (when (gnus-summary-first-subject (not all) t)
8577 (while (and
8578 (if to-here (< (point) to-here) t)
8579 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8580 (gnus-summary-find-next (not all) nil nil t))))
8581 (gnus-set-mode-line 'summary))
8582 t))
8583 (gnus-summary-position-point)))
8584
8585 (defun gnus-summary-catchup-to-here (&optional all)
8586 "Mark all unticked articles before the current one as read.
8587 If ALL is non-nil, also mark ticked and dormant articles as read."
8588 (interactive "P")
8589 (save-excursion
8590 (gnus-save-hidden-threads
8591 (let ((beg (point)))
8592 ;; We check that there are unread articles.
8593 (when (or all (gnus-summary-find-prev))
8594 (gnus-summary-catchup all t beg)))))
8595 (gnus-summary-position-point))
8596
8597 (defun gnus-summary-catchup-all (&optional quietly)
8598 "Mark all articles in this newsgroup as read."
8599 (interactive "P")
8600 (gnus-summary-catchup t quietly))
8601
8602 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8603 "Mark all unread articles in this group as read, then exit.
8604 If prefix argument ALL is non-nil, all articles are marked as read."
8605 (interactive "P")
8606 (when (gnus-summary-catchup all quietly nil 'fast)
8607 ;; Select next newsgroup or exit.
8608 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8609 (eq gnus-auto-select-next 'quietly))
8610 (gnus-summary-next-group nil)
8611 (gnus-summary-exit))))
8612
8613 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8614 "Mark all articles in this newsgroup as read, and then exit."
8615 (interactive "P")
8616 (gnus-summary-catchup-and-exit t quietly))
8617
8618 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8619 "Mark all articles in this group as read and select the next group.
8620 If given a prefix, mark all articles, unread as well as ticked, as
8621 read."
8622 (interactive "P")
8623 (save-excursion
8624 (gnus-summary-catchup all))
8625 (gnus-summary-next-group))
8626
8627 ;;;
8628 ;;; with article
8629 ;;;
8630
8631 (defmacro gnus-with-article (article &rest forms)
8632 "Select ARTICLE and perform FORMS in the original article buffer.
8633 Then replace the article with the result."
8634 `(progn
8635 ;; We don't want the article to be marked as read.
8636 (let (gnus-mark-article-hook)
8637 (gnus-summary-select-article t t nil ,article))
8638 (set-buffer gnus-original-article-buffer)
8639 ,@forms
8640 (if (not (gnus-check-backend-function
8641 'request-replace-article (car gnus-article-current)))
8642 (gnus-message 5 "Read-only group; not replacing")
8643 (unless (gnus-request-replace-article
8644 ,article (car gnus-article-current)
8645 (current-buffer) t)
8646 (error "Couldn't replace article")))
8647 ;; The cache and backlog have to be flushed somewhat.
8648 (when gnus-keep-backlog
8649 (gnus-backlog-remove-article
8650 (car gnus-article-current) (cdr gnus-article-current)))
8651 (when gnus-use-cache
8652 (gnus-cache-update-article
8653 (car gnus-article-current) (cdr gnus-article-current)))))
8654
8655 (put 'gnus-with-article 'lisp-indent-function 1)
8656 (put 'gnus-with-article 'edebug-form-spec '(form body))
8657
8658 ;; Thread-based commands.
8659
8660 (defun gnus-summary-articles-in-thread (&optional article)
8661 "Return a list of all articles in the current thread.
8662 If ARTICLE is non-nil, return all articles in the thread that starts
8663 with that article."
8664 (let* ((article (or article (gnus-summary-article-number)))
8665 (data (gnus-data-find-list article))
8666 (top-level (gnus-data-level (car data)))
8667 (top-subject
8668 (cond ((null gnus-thread-operation-ignore-subject)
8669 (gnus-simplify-subject-re
8670 (mail-header-subject (gnus-data-header (car data)))))
8671 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8672 (gnus-simplify-subject-fuzzy
8673 (mail-header-subject (gnus-data-header (car data)))))
8674 (t nil)))
8675 (end-point (save-excursion
8676 (if (gnus-summary-go-to-next-thread)
8677 (point) (point-max))))
8678 articles)
8679 (while (and data
8680 (< (gnus-data-pos (car data)) end-point))
8681 (when (or (not top-subject)
8682 (string= top-subject
8683 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8684 (gnus-simplify-subject-fuzzy
8685 (mail-header-subject
8686 (gnus-data-header (car data))))
8687 (gnus-simplify-subject-re
8688 (mail-header-subject
8689 (gnus-data-header (car data)))))))
8690 (push (gnus-data-number (car data)) articles))
8691 (unless (and (setq data (cdr data))
8692 (> (gnus-data-level (car data)) top-level))
8693 (setq data nil)))
8694 ;; Return the list of articles.
8695 (nreverse articles)))
8696
8697 (defun gnus-summary-rethread-current ()
8698 "Rethread the thread the current article is part of."
8699 (interactive)
8700 (let* ((gnus-show-threads t)
8701 (article (gnus-summary-article-number))
8702 (id (mail-header-id (gnus-summary-article-header)))
8703 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8704 (unless id
8705 (error "No article on the current line"))
8706 (gnus-rebuild-thread id)
8707 (gnus-summary-goto-subject article)))
8708
8709 (defun gnus-summary-reparent-thread ()
8710 "Make the current article child of the marked (or previous) article.
8711
8712 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8713 is non-nil or the Subject: of both articles are the same."
8714 (interactive)
8715 (unless (not (gnus-group-read-only-p))
8716 (error "The current newsgroup does not support article editing"))
8717 (unless (<= (length gnus-newsgroup-processable) 1)
8718 (error "No more than one article may be marked"))
8719 (save-window-excursion
8720 (let ((gnus-article-buffer " *reparent*")
8721 (current-article (gnus-summary-article-number))
8722 ;; First grab the marked article, otherwise one line up.
8723 (parent-article (if (not (null gnus-newsgroup-processable))
8724 (car gnus-newsgroup-processable)
8725 (save-excursion
8726 (if (eq (forward-line -1) 0)
8727 (gnus-summary-article-number)
8728 (error "Beginning of summary buffer"))))))
8729 (unless (not (eq current-article parent-article))
8730 (error "An article may not be self-referential"))
8731 (let ((message-id (mail-header-id
8732 (gnus-summary-article-header parent-article))))
8733 (unless (and message-id (not (equal message-id "")))
8734 (error "No message-id in desired parent"))
8735 (gnus-with-article current-article
8736 (save-restriction
8737 (goto-char (point-min))
8738 (message-narrow-to-head)
8739 (if (re-search-forward "^References: " nil t)
8740 (progn
8741 (re-search-forward "^[^ \t]" nil t)
8742 (forward-line -1)
8743 (end-of-line)
8744 (insert " " message-id))
8745 (insert "References: " message-id "\n"))))
8746 (set-buffer gnus-summary-buffer)
8747 (gnus-summary-unmark-all-processable)
8748 (gnus-summary-update-article current-article)
8749 (gnus-summary-rethread-current)
8750 (gnus-message 3 "Article %d is now the child of article %d"
8751 current-article parent-article)))))
8752
8753 (defun gnus-summary-toggle-threads (&optional arg)
8754 "Toggle showing conversation threads.
8755 If ARG is positive number, turn showing conversation threads on."
8756 (interactive "P")
8757 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8758 (setq gnus-show-threads
8759 (if (null arg) (not gnus-show-threads)
8760 (> (prefix-numeric-value arg) 0)))
8761 (gnus-summary-prepare)
8762 (gnus-summary-goto-subject current)
8763 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8764 (gnus-summary-position-point)))
8765
8766 (defun gnus-summary-show-all-threads ()
8767 "Show all threads."
8768 (interactive)
8769 (save-excursion
8770 (let ((buffer-read-only nil))
8771 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8772 (gnus-summary-position-point))
8773
8774 (defun gnus-summary-show-thread ()
8775 "Show thread subtrees.
8776 Returns nil if no thread was there to be shown."
8777 (interactive)
8778 (let ((buffer-read-only nil)
8779 (orig (point))
8780 ;; first goto end then to beg, to have point at beg after let
8781 (end (progn (end-of-line) (point)))
8782 (beg (progn (beginning-of-line) (point))))
8783 (prog1
8784 ;; Any hidden lines here?
8785 (search-forward "\r" end t)
8786 (subst-char-in-region beg end ?\^M ?\n t)
8787 (goto-char orig)
8788 (gnus-summary-position-point))))
8789
8790 (defun gnus-summary-hide-all-threads ()
8791 "Hide all thread subtrees."
8792 (interactive)
8793 (save-excursion
8794 (goto-char (point-min))
8795 (gnus-summary-hide-thread)
8796 (while (zerop (gnus-summary-next-thread 1 t))
8797 (gnus-summary-hide-thread)))
8798 (gnus-summary-position-point))
8799
8800 (defun gnus-summary-hide-thread ()
8801 "Hide thread subtrees.
8802 Returns nil if no threads were there to be hidden."
8803 (interactive)
8804 (let ((buffer-read-only nil)
8805 (start (point))
8806 (article (gnus-summary-article-number)))
8807 (goto-char start)
8808 ;; Go forward until either the buffer ends or the subthread
8809 ;; ends.
8810 (when (and (not (eobp))
8811 (or (zerop (gnus-summary-next-thread 1 t))
8812 (goto-char (point-max))))
8813 (prog1
8814 (if (and (> (point) start)
8815 (search-backward "\n" start t))
8816 (progn
8817 (subst-char-in-region start (point) ?\n ?\^M)
8818 (gnus-summary-goto-subject article))
8819 (goto-char start)
8820 nil)))))
8821
8822 (defun gnus-summary-go-to-next-thread (&optional previous)
8823 "Go to the same level (or less) next thread.
8824 If PREVIOUS is non-nil, go to previous thread instead.
8825 Return the article number moved to, or nil if moving was impossible."
8826 (let ((level (gnus-summary-thread-level))
8827 (way (if previous -1 1))
8828 (beg (point)))
8829 (forward-line way)
8830 (while (and (not (eobp))
8831 (< level (gnus-summary-thread-level)))
8832 (forward-line way))
8833 (if (eobp)
8834 (progn
8835 (goto-char beg)
8836 nil)
8837 (setq beg (point))
8838 (prog1
8839 (gnus-summary-article-number)
8840 (goto-char beg)))))
8841
8842 (defun gnus-summary-next-thread (n &optional silent)
8843 "Go to the same level next N'th thread.
8844 If N is negative, search backward instead.
8845 Returns the difference between N and the number of skips actually
8846 done.
8847
8848 If SILENT, don't output messages."
8849 (interactive "p")
8850 (let ((backward (< n 0))
8851 (n (abs n)))
8852 (while (and (> n 0)
8853 (gnus-summary-go-to-next-thread backward))
8854 (decf n))
8855 (unless silent
8856 (gnus-summary-position-point))
8857 (when (and (not silent) (/= 0 n))
8858 (gnus-message 7 "No more threads"))
8859 n))
8860
8861 (defun gnus-summary-prev-thread (n)
8862 "Go to the same level previous N'th thread.
8863 Returns the difference between N and the number of skips actually
8864 done."
8865 (interactive "p")
8866 (gnus-summary-next-thread (- n)))
8867
8868 (defun gnus-summary-go-down-thread ()
8869 "Go down one level in the current thread."
8870 (let ((children (gnus-summary-article-children)))
8871 (when children
8872 (gnus-summary-goto-subject (car children)))))
8873
8874 (defun gnus-summary-go-up-thread ()
8875 "Go up one level in the current thread."
8876 (let ((parent (gnus-summary-article-parent)))
8877 (when parent
8878 (gnus-summary-goto-subject parent))))
8879
8880 (defun gnus-summary-down-thread (n)
8881 "Go down thread N steps.
8882 If N is negative, go up instead.
8883 Returns the difference between N and how many steps down that were
8884 taken."
8885 (interactive "p")
8886 (let ((up (< n 0))
8887 (n (abs n)))
8888 (while (and (> n 0)
8889 (if up (gnus-summary-go-up-thread)
8890 (gnus-summary-go-down-thread)))
8891 (setq n (1- n)))
8892 (gnus-summary-position-point)
8893 (when (/= 0 n)
8894 (gnus-message 7 "Can't go further"))
8895 n))
8896
8897 (defun gnus-summary-up-thread (n)
8898 "Go up thread N steps.
8899 If N is negative, go up instead.
8900 Returns the difference between N and how many steps down that were
8901 taken."
8902 (interactive "p")
8903 (gnus-summary-down-thread (- n)))
8904
8905 (defun gnus-summary-top-thread ()
8906 "Go to the top of the thread."
8907 (interactive)
8908 (while (gnus-summary-go-up-thread))
8909 (gnus-summary-article-number))
8910
8911 (defun gnus-summary-kill-thread (&optional unmark)
8912 "Mark articles under current thread as read.
8913 If the prefix argument is positive, remove any kinds of marks.
8914 If the prefix argument is negative, tick articles instead."
8915 (interactive "P")
8916 (when unmark
8917 (setq unmark (prefix-numeric-value unmark)))
8918 (let ((articles (gnus-summary-articles-in-thread)))
8919 (save-excursion
8920 ;; Expand the thread.
8921 (gnus-summary-show-thread)
8922 ;; Mark all the articles.
8923 (while articles
8924 (gnus-summary-goto-subject (car articles))
8925 (cond ((null unmark)
8926 (gnus-summary-mark-article-as-read gnus-killed-mark))
8927 ((> unmark 0)
8928 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8929 (t
8930 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8931 (setq articles (cdr articles))))
8932 ;; Hide killed subtrees.
8933 (and (null unmark)
8934 gnus-thread-hide-killed
8935 (gnus-summary-hide-thread))
8936 ;; If marked as read, go to next unread subject.
8937 (when (null unmark)
8938 ;; Go to next unread subject.
8939 (gnus-summary-next-subject 1 t)))
8940 (gnus-set-mode-line 'summary))
8941
8942 ;; Summary sorting commands
8943
8944 (defun gnus-summary-sort-by-number (&optional reverse)
8945 "Sort the summary buffer by article number.
8946 Argument REVERSE means reverse order."
8947 (interactive "P")
8948 (gnus-summary-sort 'number reverse))
8949
8950 (defun gnus-summary-sort-by-author (&optional reverse)
8951 "Sort the summary buffer by author name alphabetically.
8952 If `case-fold-search' is non-nil, case of letters is ignored.
8953 Argument REVERSE means reverse order."
8954 (interactive "P")
8955 (gnus-summary-sort 'author reverse))
8956
8957 (defun gnus-summary-sort-by-subject (&optional reverse)
8958 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8959 If `case-fold-search' is non-nil, case of letters is ignored.
8960 Argument REVERSE means reverse order."
8961 (interactive "P")
8962 (gnus-summary-sort 'subject reverse))
8963
8964 (defun gnus-summary-sort-by-date (&optional reverse)
8965 "Sort the summary buffer by date.
8966 Argument REVERSE means reverse order."
8967 (interactive "P")
8968 (gnus-summary-sort 'date reverse))
8969
8970 (defun gnus-summary-sort-by-score (&optional reverse)
8971 "Sort the summary buffer by score.
8972 Argument REVERSE means reverse order."
8973 (interactive "P")
8974 (gnus-summary-sort 'score reverse))
8975
8976 (defun gnus-summary-sort-by-lines (&optional reverse)
8977 "Sort the summary buffer by the number of lines.
8978 Argument REVERSE means reverse order."
8979 (interactive "P")
8980 (gnus-summary-sort 'lines reverse))
8981
8982 (defun gnus-summary-sort-by-chars (&optional reverse)
8983 "Sort the summary buffer by article length.
8984 Argument REVERSE means reverse order."
8985 (interactive "P")
8986 (gnus-summary-sort 'chars reverse))
8987
8988 (defun gnus-summary-sort (predicate reverse)
8989 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8990 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8991 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8992 (gnus-thread-sort-functions
8993 (if (not reverse)
8994 thread
8995 `(lambda (t1 t2)
8996 (,thread t2 t1))))
8997 (gnus-sort-gathered-threads-function
8998 gnus-thread-sort-functions)
8999 (gnus-article-sort-functions
9000 (if (not reverse)
9001 article
9002 `(lambda (t1 t2)
9003 (,article t2 t1))))
9004 (buffer-read-only)
9005 (gnus-summary-prepare-hook nil))
9006 ;; We do the sorting by regenerating the threads.
9007 (gnus-summary-prepare)
9008 ;; Hide subthreads if needed.
9009 (when (and gnus-show-threads gnus-thread-hide-subtree)
9010 (gnus-summary-hide-all-threads))))
9011
9012 ;; Summary saving commands.
9013
9014 (defun gnus-summary-save-article (&optional n not-saved)
9015 "Save the current article using the default saver function.
9016 If N is a positive number, save the N next articles.
9017 If N is a negative number, save the N previous articles.
9018 If N is nil and any articles have been marked with the process mark,
9019 save those articles instead.
9020 The variable `gnus-default-article-saver' specifies the saver function."
9021 (interactive "P")
9022 (let* ((articles (gnus-summary-work-articles n))
9023 (save-buffer (save-excursion
9024 (nnheader-set-temp-buffer " *Gnus Save*")))
9025 (num (length articles))
9026 header file)
9027 (dolist (article articles)
9028 (setq header (gnus-summary-article-header article))
9029 (if (not (vectorp header))
9030 ;; This is a pseudo-article.
9031 (if (assq 'name header)
9032 (gnus-copy-file (cdr (assq 'name header)))
9033 (gnus-message 1 "Article %d is unsaveable" article))
9034 ;; This is a real article.
9035 (save-window-excursion
9036 (gnus-summary-select-article t nil nil article))
9037 (save-excursion
9038 (set-buffer save-buffer)
9039 (erase-buffer)
9040 (insert-buffer-substring gnus-original-article-buffer))
9041 (setq file (gnus-article-save save-buffer file num))
9042 (gnus-summary-remove-process-mark article)
9043 (unless not-saved
9044 (gnus-summary-set-saved-mark article))))
9045 (gnus-kill-buffer save-buffer)
9046 (gnus-summary-position-point)
9047 (gnus-set-mode-line 'summary)
9048 n))
9049
9050 (defun gnus-summary-pipe-output (&optional arg)
9051 "Pipe the current article to a subprocess.
9052 If N is a positive number, pipe the N next articles.
9053 If N is a negative number, pipe the N previous articles.
9054 If N is nil and any articles have been marked with the process mark,
9055 pipe those articles instead."
9056 (interactive "P")
9057 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
9058 (gnus-summary-save-article arg t))
9059 (gnus-configure-windows 'pipe))
9060
9061 (defun gnus-summary-save-article-mail (&optional arg)
9062 "Append the current article to an mail file.
9063 If N is a positive number, save the N next articles.
9064 If N is a negative number, save the N previous articles.
9065 If N is nil and any articles have been marked with the process mark,
9066 save those articles instead."
9067 (interactive "P")
9068 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
9069 (gnus-summary-save-article arg)))
9070
9071 (defun gnus-summary-save-article-rmail (&optional arg)
9072 "Append the current article to an rmail file.
9073 If N is a positive number, save the N next articles.
9074 If N is a negative number, save the N previous articles.
9075 If N is nil and any articles have been marked with the process mark,
9076 save those articles instead."
9077 (interactive "P")
9078 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
9079 (gnus-summary-save-article arg)))
9080
9081 (defun gnus-summary-save-article-file (&optional arg)
9082 "Append the current article to a file.
9083 If N is a positive number, save the N next articles.
9084 If N is a negative number, save the N previous articles.
9085 If N is nil and any articles have been marked with the process mark,
9086 save those articles instead."
9087 (interactive "P")
9088 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
9089 (gnus-summary-save-article arg)))
9090
9091 (defun gnus-summary-write-article-file (&optional arg)
9092 "Write the current article to a file, deleting the previous file.
9093 If N is a positive number, save the N next articles.
9094 If N is a negative number, save the N previous articles.
9095 If N is nil and any articles have been marked with the process mark,
9096 save those articles instead."
9097 (interactive "P")
9098 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
9099 (gnus-summary-save-article arg)))
9100
9101 (defun gnus-summary-save-article-body-file (&optional arg)
9102 "Append the current article body to a file.
9103 If N is a positive number, save the N next articles.
9104 If N is a negative number, save the N previous articles.
9105 If N is nil and any articles have been marked with the process mark,
9106 save those articles instead."
9107 (interactive "P")
9108 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
9109 (gnus-summary-save-article arg)))
9110
9111 (defun gnus-summary-pipe-message (program)
9112 "Pipe the current article through PROGRAM."
9113 (interactive "sProgram: ")
9114 (gnus-summary-select-article)
9115 (let ((mail-header-separator ""))
9116 (gnus-eval-in-buffer-window gnus-article-buffer
9117 (save-restriction
9118 (widen)
9119 (let ((start (window-start))
9120 buffer-read-only)
9121 (message-pipe-buffer-body program)
9122 (set-window-start (get-buffer-window (current-buffer)) start))))))
9123
9124 (defun gnus-get-split-value (methods)
9125 "Return a value based on the split METHODS."
9126 (let (split-name method result match)
9127 (when methods
9128 (save-excursion
9129 (set-buffer gnus-original-article-buffer)
9130 (save-restriction
9131 (nnheader-narrow-to-headers)
9132 (while (and methods (not split-name))
9133 (goto-char (point-min))
9134 (setq method (pop methods))
9135 (setq match (car method))
9136 (when (cond
9137 ((stringp match)
9138 ;; Regular expression.
9139 (ignore-errors
9140 (re-search-forward match nil t)))
9141 ((gnus-functionp match)
9142 ;; Function.
9143 (save-restriction
9144 (widen)
9145 (setq result (funcall match gnus-newsgroup-name))))
9146 ((consp match)
9147 ;; Form.
9148 (save-restriction
9149 (widen)
9150 (setq result (eval match)))))
9151 (setq split-name (cdr method))
9152 (cond ((stringp result)
9153 (push (expand-file-name
9154 result gnus-article-save-directory)
9155 split-name))
9156 ((consp result)
9157 (setq split-name (append result split-name)))))))))
9158 (nreverse split-name)))
9159
9160 (defun gnus-valid-move-group-p (group)
9161 (and (boundp group)
9162 (symbol-name group)
9163 (symbol-value group)
9164 (gnus-get-function (gnus-find-method-for-group
9165 (symbol-name group)) 'request-accept-article t)))
9166
9167 (defun gnus-read-move-group-name (prompt default articles prefix)
9168 "Read a group name."
9169 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
9170 (minibuffer-confirm-incomplete nil) ; XEmacs
9171 (prom
9172 (format "%s %s to:"
9173 prompt
9174 (if (> (length articles) 1)
9175 (format "these %d articles" (length articles))
9176 "this article")))
9177 (to-newsgroup
9178 (cond
9179 ((null split-name)
9180 (gnus-completing-read default prom
9181 gnus-active-hashtb
9182 'gnus-valid-move-group-p
9183 nil prefix
9184 'gnus-group-history))
9185 ((= 1 (length split-name))
9186 (gnus-completing-read (car split-name) prom
9187 gnus-active-hashtb
9188 'gnus-valid-move-group-p
9189 nil nil
9190 'gnus-group-history))
9191 (t
9192 (gnus-completing-read nil prom
9193 (mapcar (lambda (el) (list el))
9194 (nreverse split-name))
9195 nil nil nil
9196 'gnus-group-history))))
9197 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
9198 (when to-newsgroup
9199 (if (or (string= to-newsgroup "")
9200 (string= to-newsgroup prefix))
9201 (setq to-newsgroup default))
9202 (unless to-newsgroup
9203 (error "No group name entered"))
9204 (or (gnus-active to-newsgroup)
9205 (gnus-activate-group to-newsgroup nil nil to-method)
9206 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
9207 to-newsgroup))
9208 (or (and (gnus-request-create-group to-newsgroup to-method)
9209 (gnus-activate-group
9210 to-newsgroup nil nil to-method)
9211 (gnus-subscribe-group to-newsgroup))
9212 (error "Couldn't create group %s" to-newsgroup)))
9213 (error "No such group: %s" to-newsgroup)))
9214 to-newsgroup))
9215
9216 (defun gnus-summary-save-parts (type dir n &optional reverse)
9217 "Save parts matching TYPE to DIR.
9218 If REVERSE, save parts that do not match TYPE."
9219 (interactive
9220 (list (read-string "Save parts of type: "
9221 (or (car gnus-summary-save-parts-type-history)
9222 gnus-summary-save-parts-default-mime)
9223 'gnus-summary-save-parts-type-history)
9224 (setq gnus-summary-save-parts-last-directory
9225 (read-file-name "Save to directory: "
9226 gnus-summary-save-parts-last-directory
9227 nil t))
9228 current-prefix-arg))
9229 (gnus-summary-iterate n
9230 (let ((gnus-display-mime-function nil)
9231 (gnus-inhibit-treatment t))
9232 (gnus-summary-select-article))
9233 (save-excursion
9234 (set-buffer gnus-article-buffer)
9235 (let ((handles (or gnus-article-mime-handles
9236 (mm-dissect-buffer) (mm-uu-dissect))))
9237 (when handles
9238 (gnus-summary-save-parts-1 type dir handles reverse)
9239 (unless gnus-article-mime-handles ;; Don't destroy this case.
9240 (mm-destroy-parts handles)))))))
9241
9242 (defun gnus-summary-save-parts-1 (type dir handle reverse)
9243 (if (stringp (car handle))
9244 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
9245 (cdr handle))
9246 (when (if reverse
9247 (not (string-match type (mm-handle-media-type handle)))
9248 (string-match type (mm-handle-media-type handle)))
9249 (let ((file (expand-file-name
9250 (file-name-nondirectory
9251 (or
9252 (mail-content-type-get
9253 (mm-handle-disposition handle) 'filename)
9254 (concat gnus-newsgroup-name
9255 "." (number-to-string
9256 (cdr gnus-article-current)))))
9257 dir)))
9258 (unless (file-exists-p file)
9259 (mm-save-part-to-file handle file))))))
9260
9261 ;; Summary extract commands
9262
9263 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
9264 (let ((buffer-read-only nil)
9265 (article (gnus-summary-article-number))
9266 after-article b e)
9267 (unless (gnus-summary-goto-subject article)
9268 (error "No such article: %d" article))
9269 (gnus-summary-position-point)
9270 ;; If all commands are to be bunched up on one line, we collect
9271 ;; them here.
9272 (unless gnus-view-pseudos-separately
9273 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
9274 files action)
9275 (while ps
9276 (setq action (cdr (assq 'action (car ps))))
9277 (setq files (list (cdr (assq 'name (car ps)))))
9278 (while (and ps (cdr ps)
9279 (string= (or action "1")
9280 (or (cdr (assq 'action (cadr ps))) "2")))
9281 (push (cdr (assq 'name (cadr ps))) files)
9282 (setcdr ps (cddr ps)))
9283 (when files
9284 (when (not (string-match "%s" action))
9285 (push " " files))
9286 (push " " files)
9287 (when (assq 'execute (car ps))
9288 (setcdr (assq 'execute (car ps))
9289 (funcall (if (string-match "%s" action)
9290 'format 'concat)
9291 action
9292 (mapconcat
9293 (lambda (f)
9294 (if (equal f " ")
9295 f
9296 (mm-quote-arg f)))
9297 files " ")))))
9298 (setq ps (cdr ps)))))
9299 (if (and gnus-view-pseudos (not not-view))
9300 (while pslist
9301 (when (assq 'execute (car pslist))
9302 (gnus-execute-command (cdr (assq 'execute (car pslist)))
9303 (eq gnus-view-pseudos 'not-confirm)))
9304 (setq pslist (cdr pslist)))
9305 (save-excursion
9306 (while pslist
9307 (setq after-article (or (cdr (assq 'article (car pslist)))
9308 (gnus-summary-article-number)))
9309 (gnus-summary-goto-subject after-article)
9310 (forward-line 1)
9311 (setq b (point))
9312 (insert " " (file-name-nondirectory
9313 (cdr (assq 'name (car pslist))))
9314 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
9315 (setq e (point))
9316 (forward-line -1) ; back to `b'
9317 (gnus-add-text-properties
9318 b (1- e) (list 'gnus-number gnus-reffed-article-number
9319 gnus-mouse-face-prop gnus-mouse-face))
9320 (gnus-data-enter
9321 after-article gnus-reffed-article-number
9322 gnus-unread-mark b (car pslist) 0 (- e b))
9323 (push gnus-reffed-article-number gnus-newsgroup-unreads)
9324 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
9325 (setq pslist (cdr pslist)))))))
9326
9327 (defun gnus-pseudos< (p1 p2)
9328 (let ((c1 (cdr (assq 'action p1)))
9329 (c2 (cdr (assq 'action p2))))
9330 (and c1 c2 (string< c1 c2))))
9331
9332 (defun gnus-request-pseudo-article (props)
9333 (cond ((assq 'execute props)
9334 (gnus-execute-command (cdr (assq 'execute props)))))
9335 (let ((gnus-current-article (gnus-summary-article-number)))
9336 (gnus-run-hooks 'gnus-mark-article-hook)))
9337
9338 (defun gnus-execute-command (command &optional automatic)
9339 (save-excursion
9340 (gnus-article-setup-buffer)
9341 (set-buffer gnus-article-buffer)
9342 (setq buffer-read-only nil)
9343 (let ((command (if automatic command
9344 (read-string "Command: " (cons command 0)))))
9345 (erase-buffer)
9346 (insert "$ " command "\n\n")
9347 (if gnus-view-pseudo-asynchronously
9348 (start-process "gnus-execute" (current-buffer) shell-file-name
9349 shell-command-switch command)
9350 (call-process shell-file-name nil t nil
9351 shell-command-switch command)))))
9352
9353 ;; Summary kill commands.
9354
9355 (defun gnus-summary-edit-global-kill (article)
9356 "Edit the \"global\" kill file."
9357 (interactive (list (gnus-summary-article-number)))
9358 (gnus-group-edit-global-kill article))
9359
9360 (defun gnus-summary-edit-local-kill ()
9361 "Edit a local kill file applied to the current newsgroup."
9362 (interactive)
9363 (setq gnus-current-headers (gnus-summary-article-header))
9364 (gnus-group-edit-local-kill
9365 (gnus-summary-article-number) gnus-newsgroup-name))
9366
9367 ;;; Header reading.
9368
9369 (defun gnus-read-header (id &optional header)
9370 "Read the headers of article ID and enter them into the Gnus system."
9371 (let ((group gnus-newsgroup-name)
9372 (gnus-override-method
9373 (or
9374 gnus-override-method
9375 (and (gnus-news-group-p gnus-newsgroup-name)
9376 (car (gnus-refer-article-methods)))))
9377 where)
9378 ;; First we check to see whether the header in question is already
9379 ;; fetched.
9380 (if (stringp id)
9381 ;; This is a Message-ID.
9382 (setq header (or header (gnus-id-to-header id)))
9383 ;; This is an article number.
9384 (setq header (or header (gnus-summary-article-header id))))
9385 (if (and header
9386 (not (gnus-summary-article-sparse-p (mail-header-number header))))
9387 ;; We have found the header.
9388 header
9389 ;; If this is a sparse article, we have to nix out its
9390 ;; previous entry in the thread hashtb.
9391 (when (and header
9392 (gnus-summary-article-sparse-p (mail-header-number header)))
9393 (let* ((parent (gnus-parent-id (mail-header-references header)))
9394 (thread (and parent (gnus-id-to-thread parent))))
9395 (when thread
9396 (delq (assq header thread) thread))))
9397 ;; We have to really fetch the header to this article.
9398 (save-excursion
9399 (set-buffer nntp-server-buffer)
9400 (when (setq where (gnus-request-head id group))
9401 (nnheader-fold-continuation-lines)
9402 (goto-char (point-max))
9403 (insert ".\n")
9404 (goto-char (point-min))
9405 (insert "211 ")
9406 (princ (cond
9407 ((numberp id) id)
9408 ((cdr where) (cdr where))
9409 (header (mail-header-number header))
9410 (t gnus-reffed-article-number))
9411 (current-buffer))
9412 (insert " Article retrieved.\n"))
9413 (if (or (not where)
9414 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
9415 () ; Malformed head.
9416 (unless (gnus-summary-article-sparse-p (mail-header-number header))
9417 (when (and (stringp id)
9418 (not (string= (gnus-group-real-name group)
9419 (car where))))
9420 ;; If we fetched by Message-ID and the article came
9421 ;; from a different group, we fudge some bogus article
9422 ;; numbers for this article.
9423 (mail-header-set-number header gnus-reffed-article-number))
9424 (save-excursion
9425 (set-buffer gnus-summary-buffer)
9426 (decf gnus-reffed-article-number)
9427 (gnus-remove-header (mail-header-number header))
9428 (push header gnus-newsgroup-headers)
9429 (setq gnus-current-headers header)
9430 (push (mail-header-number header) gnus-newsgroup-limit)))
9431 header)))))
9432
9433 (defun gnus-remove-header (number)
9434 "Remove header NUMBER from `gnus-newsgroup-headers'."
9435 (if (and gnus-newsgroup-headers
9436 (= number (mail-header-number (car gnus-newsgroup-headers))))
9437 (pop gnus-newsgroup-headers)
9438 (let ((headers gnus-newsgroup-headers))
9439 (while (and (cdr headers)
9440 (not (= number (mail-header-number (cadr headers)))))
9441 (pop headers))
9442 (when (cdr headers)
9443 (setcdr headers (cddr headers))))))
9444
9445 ;;;
9446 ;;; summary highlights
9447 ;;;
9448
9449 (defun gnus-highlight-selected-summary ()
9450 "Highlight selected article in summary buffer."
9451 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
9452 (when gnus-summary-selected-face
9453 (save-excursion
9454 (let* ((beg (progn (beginning-of-line) (point)))
9455 (end (progn (end-of-line) (point)))
9456 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
9457 (from (if (get-text-property beg gnus-mouse-face-prop)
9458 beg
9459 (or (next-single-property-change
9460 beg gnus-mouse-face-prop nil end)
9461 beg)))
9462 (to
9463 (if (= from end)
9464 (- from 2)
9465 (or (next-single-property-change
9466 from gnus-mouse-face-prop nil end)
9467 end))))
9468 ;; If no mouse-face prop on line we will have to = from = end,
9469 ;; so we highlight the entire line instead.
9470 (when (= (+ to 2) from)
9471 (setq from beg)
9472 (setq to end))
9473 (if gnus-newsgroup-selected-overlay
9474 ;; Move old overlay.
9475 (gnus-move-overlay
9476 gnus-newsgroup-selected-overlay from to (current-buffer))
9477 ;; Create new overlay.
9478 (gnus-overlay-put
9479 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9480 'face gnus-summary-selected-face))))))
9481
9482 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9483 (defun gnus-summary-highlight-line ()
9484 "Highlight current line according to `gnus-summary-highlight'."
9485 (let* ((list gnus-summary-highlight)
9486 (p (point))
9487 (end (progn (end-of-line) (point)))
9488 ;; now find out where the line starts and leave point there.
9489 (beg (progn (beginning-of-line) (point)))
9490 (article (gnus-summary-article-number))
9491 (score (or (cdr (assq (or article gnus-current-article)
9492 gnus-newsgroup-scored))
9493 gnus-summary-default-score 0))
9494 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9495 (inhibit-read-only t))
9496 ;; Eval the cars of the lists until we find a match.
9497 (let ((default gnus-summary-default-score))
9498 (while (and list
9499 (not (eval (caar list))))
9500 (setq list (cdr list))))
9501 (let ((face (cdar list)))
9502 (unless (eq face (get-text-property beg 'face))
9503 (gnus-put-text-property-excluding-characters-with-faces
9504 beg end 'face
9505 (setq face (if (boundp face) (symbol-value face) face)))
9506 (when gnus-summary-highlight-line-function
9507 (funcall gnus-summary-highlight-line-function article face))))
9508 (goto-char p)))
9509
9510 (defun gnus-update-read-articles (group unread &optional compute)
9511 "Update the list of read articles in GROUP."
9512 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9513 (entry (gnus-gethash group gnus-newsrc-hashtb))
9514 (info (nth 2 entry))
9515 (prev 1)
9516 (unread (sort (copy-sequence unread) '<))
9517 read)
9518 (if (or (not info) (not active))
9519 ;; There is no info on this group if it was, in fact,
9520 ;; killed. Gnus stores no information on killed groups, so
9521 ;; there's nothing to be done.
9522 ;; One could store the information somewhere temporarily,
9523 ;; perhaps... Hmmm...
9524 ()
9525 ;; Remove any negative articles numbers.
9526 (while (and unread (< (car unread) 0))
9527 (setq unread (cdr unread)))
9528 ;; Remove any expired article numbers
9529 (while (and unread (< (car unread) (car active)))
9530 (setq unread (cdr unread)))
9531 ;; Compute the ranges of read articles by looking at the list of
9532 ;; unread articles.
9533 (while unread
9534 (when (/= (car unread) prev)
9535 (push (if (= prev (1- (car unread))) prev
9536 (cons prev (1- (car unread))))
9537 read))
9538 (setq prev (1+ (car unread)))
9539 (setq unread (cdr unread)))
9540 (when (<= prev (cdr active))
9541 (push (cons prev (cdr active)) read))
9542 (setq read (if (> (length read) 1) (nreverse read) read))
9543 (if compute
9544 read
9545 (save-excursion
9546 (let (setmarkundo)
9547 ;; Propagate the read marks to the backend.
9548 (when (gnus-check-backend-function 'request-set-mark group)
9549 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9550 (add (gnus-remove-from-range read (gnus-info-read info))))
9551 (when (or add del)
9552 (unless (gnus-check-group group)
9553 (error "Can't open server for %s" group))
9554 (gnus-request-set-mark
9555 group (delq nil (list (if add (list add 'add '(read)))
9556 (if del (list del 'del '(read))))))
9557 (setq setmarkundo
9558 `(gnus-request-set-mark
9559 ,group
9560 ',(delq nil (list
9561 (if del (list del 'add '(read)))
9562 (if add (list add 'del '(read))))))))))
9563 (set-buffer gnus-group-buffer)
9564 (gnus-undo-register
9565 `(progn
9566 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9567 (gnus-info-set-read ',info ',(gnus-info-read info))
9568 (gnus-get-unread-articles-in-group ',info
9569 (gnus-active ,group))
9570 (gnus-group-update-group ,group t)
9571 ,setmarkundo))))
9572 ;; Enter this list into the group info.
9573 (gnus-info-set-read info read)
9574 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9575 (gnus-get-unread-articles-in-group info (gnus-active group))
9576 t))))
9577
9578 (defun gnus-offer-save-summaries ()
9579 "Offer to save all active summary buffers."
9580 (save-excursion
9581 (let ((buflist (buffer-list))
9582 buffers bufname)
9583 ;; Go through all buffers and find all summaries.
9584 (while buflist
9585 (and (setq bufname (buffer-name (car buflist)))
9586 (string-match "Summary" bufname)
9587 (save-excursion
9588 (set-buffer bufname)
9589 ;; We check that this is, indeed, a summary buffer.
9590 (and (eq major-mode 'gnus-summary-mode)
9591 ;; Also make sure this isn't bogus.
9592 gnus-newsgroup-prepared
9593 ;; Also make sure that this isn't a dead summary buffer.
9594 (not gnus-dead-summary-mode)))
9595 (push bufname buffers))
9596 (setq buflist (cdr buflist)))
9597 ;; Go through all these summary buffers and offer to save them.
9598 (when buffers
9599 (map-y-or-n-p
9600 "Update summary buffer %s? "
9601 (lambda (buf)
9602 (switch-to-buffer buf)
9603 (gnus-summary-exit))
9604 buffers)))))
9605
9606 (defun gnus-summary-setup-default-charset ()
9607 "Setup newsgroup default charset."
9608 (if (equal gnus-newsgroup-name "nndraft:drafts")
9609 (setq gnus-newsgroup-charset nil)
9610 (let* ((name (and gnus-newsgroup-name
9611 (gnus-group-real-name gnus-newsgroup-name)))
9612 (ignored-charsets
9613 (or gnus-newsgroup-ephemeral-ignored-charsets
9614 (append
9615 (and gnus-newsgroup-name
9616 (or (gnus-group-find-parameter gnus-newsgroup-name
9617 'ignored-charsets t)
9618 (let ((alist gnus-group-ignored-charsets-alist)
9619 elem (charsets nil))
9620 (while (setq elem (pop alist))
9621 (when (and name
9622 (string-match (car elem) name))
9623 (setq alist nil
9624 charsets (cdr elem))))
9625 charsets)))
9626 gnus-newsgroup-ignored-charsets))))
9627 (setq gnus-newsgroup-charset
9628 (or gnus-newsgroup-ephemeral-charset
9629 (and gnus-newsgroup-name
9630 (or (gnus-group-find-parameter gnus-newsgroup-name 'charset)
9631 (let ((alist gnus-group-charset-alist)
9632 elem charset)
9633 (while (setq elem (pop alist))
9634 (when (and name
9635 (string-match (car elem) name))
9636 (setq alist nil
9637 charset (cadr elem))))
9638 charset)))
9639 gnus-default-charset))
9640 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
9641 ignored-charsets))))
9642
9643 ;;;
9644 ;;; Mime Commands
9645 ;;;
9646
9647 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9648 "Display the current article buffer fully MIME-buttonized.
9649 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9650 treated as multipart/mixed."
9651 (interactive "P")
9652 (require 'gnus-art)
9653 (let ((gnus-unbuttonized-mime-types nil)
9654 (gnus-mime-display-multipart-as-mixed show-all-parts))
9655 (gnus-summary-show-article)))
9656
9657 (defun gnus-summary-repair-multipart (article)
9658 "Add a Content-Type header to a multipart article without one."
9659 (interactive (list (gnus-summary-article-number)))
9660 (gnus-with-article article
9661 (message-narrow-to-head)
9662 (goto-char (point-max))
9663 (widen)
9664 (when (search-forward "\n--" nil t)
9665 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9666 (message-narrow-to-head)
9667 (message-remove-header "Mime-Version")
9668 (message-remove-header "Content-Type")
9669 (goto-char (point-max))
9670 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9671 separator))
9672 (insert "Mime-Version: 1.0\n")
9673 (widen))))
9674 (let (gnus-mark-article-hook)
9675 (gnus-summary-select-article t t nil article)))
9676
9677 (defun gnus-summary-toggle-display-buttonized ()
9678 "Toggle the buttonizing of the article buffer."
9679 (interactive)
9680 (require 'gnus-art)
9681 (if (setq gnus-inhibit-mime-unbuttonizing
9682 (not gnus-inhibit-mime-unbuttonizing))
9683 (let ((gnus-unbuttonized-mime-types nil))
9684 (gnus-summary-show-article))
9685 (gnus-summary-show-article)))
9686
9687 ;;;
9688 ;;; Generic summary marking commands
9689 ;;;
9690
9691 (defvar gnus-summary-marking-alist
9692 '((read gnus-del-mark "d")
9693 (unread gnus-unread-mark "u")
9694 (ticked gnus-ticked-mark "!")
9695 (dormant gnus-dormant-mark "?")
9696 (expirable gnus-expirable-mark "e"))
9697 "An alist of names/marks/keystrokes.")
9698
9699 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
9700 (defvar gnus-summary-mark-map)
9701
9702 (defun gnus-summary-make-all-marking-commands ()
9703 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
9704 (dolist (elem gnus-summary-marking-alist)
9705 (apply 'gnus-summary-make-marking-command elem)))
9706
9707 (defun gnus-summary-make-marking-command (name mark keystroke)
9708 (let ((map (make-sparse-keymap)))
9709 (define-key gnus-summary-generic-mark-map keystroke map)
9710 (dolist (lway `((next "next" next nil "n")
9711 (next-unread "next unread" next t "N")
9712 (prev "previous" prev nil "p")
9713 (prev-unread "previous unread" prev t "P")
9714 (nomove "" nil nil ,keystroke)))
9715 (let ((func (gnus-summary-make-marking-command-1
9716 mark (car lway) lway name)))
9717 (setq func (eval func))
9718 (define-key map (nth 4 lway) func)))))
9719
9720 (defun gnus-summary-make-marking-command-1 (mark way lway name)
9721 `(defun ,(intern
9722 (format "gnus-summary-put-mark-as-%s%s"
9723 name (if (eq way 'nomove)
9724 ""
9725 (concat "-" (symbol-name way)))))
9726 (n)
9727 ,(format
9728 "Mark the current article as %s%s.
9729 If N, the prefix, then repeat N times.
9730 If N is negative, move in reverse order.
9731 The difference between N and the actual number of articles marked is
9732 returned."
9733 name (cadr lway))
9734 (interactive "p")
9735 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
9736
9737 (defun gnus-summary-generic-mark (n mark move unread)
9738 "Mark N articles with MARK."
9739 (unless (eq major-mode 'gnus-summary-mode)
9740 (error "This command can only be used in the summary buffer"))
9741 (gnus-summary-show-thread)
9742 (let ((nummove
9743 (cond
9744 ((eq move 'next) 1)
9745 ((eq move 'prev) -1)
9746 (t 0))))
9747 (if (zerop nummove)
9748 (setq n 1)
9749 (when (< n 0)
9750 (setq n (abs n)
9751 nummove (* -1 nummove))))
9752 (while (and (> n 0)
9753 (gnus-summary-mark-article nil mark)
9754 (zerop (gnus-summary-next-subject nummove unread t)))
9755 (setq n (1- n)))
9756 (when (/= 0 n)
9757 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9758 (gnus-summary-recenter)
9759 (gnus-summary-position-point)
9760 (gnus-set-mode-line 'summary)
9761 n))
9762
9763 (gnus-summary-make-all-marking-commands)
9764
9765 (gnus-ems-redefine)
9766
9767 (provide 'gnus-sum)
9768
9769 (run-hooks 'gnus-sum-load-hook)
9770
9771 ;;; gnus-sum.el ends here