ea68a6a2fa54535ec11d5f4ca4ad561d2cc42640
[bpt/emacs.git] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2
3 ;; Copyright (C) 1996-2013 Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22
23 ;;; Commentary:
24
25 ;;; Code:
26
27 ;; For Emacs <22.2 and XEmacs.
28 (eval-and-compile
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
30 (eval-when-compile
31 (require 'cl))
32 (eval-when-compile
33 (when (featurep 'xemacs)
34 (require 'easy-mmode))) ; for `define-minor-mode'
35
36 (defvar tool-bar-mode)
37 (defvar gnus-tmp-header)
38
39 (require 'gnus)
40 (require 'gnus-group)
41 (require 'gnus-spec)
42 (require 'gnus-range)
43 (require 'gnus-int)
44 (require 'gnus-undo)
45 (require 'gnus-util)
46 (require 'gmm-utils)
47 (require 'mm-decode)
48 (require 'nnoo)
49
50 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
51 (autoload 'gnus-cache-write-active "gnus-cache")
52 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
53 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
54 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
55 (autoload 'mm-uu-dissect "mm-uu")
56 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
57 "Deuglify broken Outlook (Express) articles and redisplay."
58 t)
59 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
60 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
61 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
62 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
63 (autoload 'nnir-article-group "nnir" nil nil 'macro)
64
65 (defcustom gnus-kill-summary-on-exit t
66 "*If non-nil, kill the summary buffer when you exit from it.
67 If nil, the summary will become a \"*Dead Summary*\" buffer, and
68 it will be killed sometime later."
69 :group 'gnus-summary-exit
70 :type 'boolean)
71
72 (defcustom gnus-summary-next-group-on-exit t
73 "If non-nil, go to the next unread newsgroup on summary exit.
74 See `gnus-group-goto-unread'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-exit
77 :version "23.1" ;; No Gnus
78 :type 'boolean)
79
80 (defcustom gnus-summary-stop-at-end-of-message nil
81 "If non-nil, don't select the next message when using `SPC'."
82 :link '(custom-manual "(gnus)Group Maneuvering")
83 :group 'gnus-summary-maneuvering
84 :version "24.1"
85 :type 'boolean)
86
87 (defcustom gnus-fetch-old-headers nil
88 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
89 If an unread article in the group refers to an older, already
90 read (or just marked as read) article, the old article will not
91 normally be displayed in the Summary buffer. If this variable is
92 t, Gnus will attempt to grab the headers to the old articles, and
93 thereby build complete threads. If it has the value `some', all
94 old headers will be fetched but only enough headers to connect
95 otherwise loose threads will be displayed. This variable can
96 also be a number. In that case, no more than that number of old
97 headers will be fetched. If it has the value `invisible', all
98 old headers will be fetched, but none will be displayed.
99
100 The server has to support NOV for any of this to work.
101
102 This feature can seriously impact performance it ignores all
103 locally cached header entries. Setting it to t for groups for a
104 server that doesn't expire articles (such as news.gmane.org),
105 leads to very slow summary generation."
106 :group 'gnus-thread
107 :type '(choice (const :tag "off" nil)
108 (const :tag "on" t)
109 (const some)
110 (const invisible)
111 number
112 (sexp :menu-tag "other" t)))
113
114 (defcustom gnus-refer-thread-limit 500
115 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
116 If t, fetch all the available old headers."
117 :group 'gnus-thread
118 :type '(choice number
119 (sexp :menu-tag "other" t)))
120
121 (defcustom gnus-refer-thread-use-nnir nil
122 "*Use nnir to search an entire server when referring threads. A
123 nil value will only search for thread-related articles in the
124 current group."
125 :version "24.1"
126 :group 'gnus-thread
127 :type 'boolean)
128
129 (defcustom gnus-summary-make-false-root 'adopt
130 "*nil means that Gnus won't gather loose threads.
131 If the root of a thread has expired or been read in a previous
132 session, the information necessary to build a complete thread has been
133 lost. Instead of having many small sub-threads from this original thread
134 scattered all over the summary buffer, Gnus can gather them.
135
136 If non-nil, Gnus will try to gather all loose sub-threads from an
137 original thread into one large thread.
138
139 If this variable is non-nil, it should be one of `none', `adopt',
140 `dummy' or `empty'.
141
142 If this variable is `none', Gnus will not make a false root, but just
143 present the sub-threads after another.
144 If this variable is `dummy', Gnus will create a dummy root that will
145 have all the sub-threads as children.
146 If this variable is `adopt', Gnus will make one of the \"children\"
147 the parent and mark all the step-children as such.
148 If this variable is `empty', the \"children\" are printed with empty
149 subject fields. (Or rather, they will be printed with a string
150 given by the `gnus-summary-same-subject' variable.)"
151 :group 'gnus-thread
152 :type '(choice (const :tag "off" nil)
153 (const none)
154 (const dummy)
155 (const adopt)
156 (const empty)))
157
158 (defcustom gnus-summary-make-false-root-always nil
159 "Always make a false dummy root."
160 :version "22.1"
161 :group 'gnus-thread
162 :type 'boolean)
163
164 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
165 "*A regexp to match subjects to be excluded from loose thread gathering.
166 As loose thread gathering is done on subjects only, that means that
167 there can be many false gatherings performed. By rooting out certain
168 common subjects, gathering might become saner."
169 :group 'gnus-thread
170 :type 'regexp)
171
172 (defcustom gnus-summary-gather-subject-limit nil
173 "*Maximum length of subject comparisons when gathering loose threads.
174 Use nil to compare full subjects. Setting this variable to a low
175 number will help gather threads that have been corrupted by
176 newsreaders chopping off subject lines, but it might also mean that
177 unrelated articles that have subject that happen to begin with the
178 same few characters will be incorrectly gathered.
179
180 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
181 comparing subjects."
182 :group 'gnus-thread
183 :type '(choice (const :tag "off" nil)
184 (const fuzzy)
185 (sexp :menu-tag "on" t)))
186
187 (defcustom gnus-simplify-subject-functions nil
188 "List of functions taking a string argument that simplify subjects.
189 The functions are applied recursively.
190
191 Useful functions to put in this list include:
192 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
193 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
194 :group 'gnus-thread
195 :type '(repeat function))
196
197 (defcustom gnus-simplify-ignored-prefixes nil
198 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
199 :group 'gnus-thread
200 :type '(choice (const :tag "off" nil)
201 regexp))
202
203 (defcustom gnus-build-sparse-threads nil
204 "*If non-nil, fill in the gaps in threads.
205 If `some', only fill in the gaps that are needed to tie loose threads
206 together. If `more', fill in all leaf nodes that Gnus can find. If
207 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
208 :group 'gnus-thread
209 :type '(choice (const :tag "off" nil)
210 (const some)
211 (const more)
212 (sexp :menu-tag "all" t)))
213
214 (defcustom gnus-summary-thread-gathering-function
215 'gnus-gather-threads-by-subject
216 "*Function used for gathering loose threads.
217 There are two pre-defined functions: `gnus-gather-threads-by-subject',
218 which only takes Subjects into consideration; and
219 `gnus-gather-threads-by-references', which compared the References
220 headers of the articles to find matches."
221 :group 'gnus-thread
222 :type '(radio (function-item gnus-gather-threads-by-subject)
223 (function-item gnus-gather-threads-by-references)
224 (function :tag "other")))
225
226 (defcustom gnus-summary-same-subject ""
227 "*String indicating that the current article has the same subject as the previous.
228 This variable will only be used if the value of
229 `gnus-summary-make-false-root' is `empty'."
230 :group 'gnus-summary-format
231 :type 'string)
232
233 (defcustom gnus-summary-goto-unread nil
234 "*If t, many commands will go to the next unread article.
235 This applies to marking commands as well as other commands that
236 \"naturally\" select the next article, like, for instance, `SPC' at
237 the end of an article.
238
239 If nil, the marking commands do NOT go to the next unread article
240 \(they go to the next article instead). If `never', commands that
241 usually go to the next unread article, will go to the next article,
242 whether it is read or not."
243 :version "24.1"
244 :group 'gnus-summary-marks
245 :link '(custom-manual "(gnus)Setting Marks")
246 :type '(choice (const :tag "off" nil)
247 (const never)
248 (sexp :menu-tag "on" t)))
249
250 (defcustom gnus-summary-default-score 0
251 "*Default article score level.
252 All scores generated by the score files will be added to this score.
253 If this variable is nil, scoring will be disabled."
254 :group 'gnus-score-default
255 :type '(choice (const :tag "disable")
256 integer))
257
258 (defcustom gnus-summary-default-high-score 0
259 "*Default threshold for a high scored article.
260 An article will be highlighted as high scored if its score is greater
261 than this score."
262 :version "22.1"
263 :group 'gnus-score-default
264 :type 'integer)
265
266 (defcustom gnus-summary-default-low-score 0
267 "*Default threshold for a low scored article.
268 An article will be highlighted as low scored if its score is smaller
269 than this score."
270 :version "22.1"
271 :group 'gnus-score-default
272 :type 'integer)
273
274 (defcustom gnus-summary-zcore-fuzz 0
275 "*Fuzziness factor for the zcore in the summary buffer.
276 Articles with scores closer than this to `gnus-summary-default-score'
277 will not be marked."
278 :group 'gnus-summary-format
279 :type 'integer)
280
281 (defcustom gnus-simplify-subject-fuzzy-regexp nil
282 "*Strings to be removed when doing fuzzy matches.
283 This can either be a regular expression or list of regular expressions
284 that will be removed from subject strings if fuzzy subject
285 simplification is selected."
286 :group 'gnus-thread
287 :type '(repeat regexp))
288
289 (defcustom gnus-show-threads t
290 "*If non-nil, display threads in summary mode."
291 :group 'gnus-thread
292 :type 'boolean)
293
294 (defcustom gnus-thread-hide-subtree nil
295 "*If non-nil, hide all threads initially.
296 This can be a predicate specifier which says which threads to hide.
297 If threads are hidden, you have to run the command
298 `gnus-summary-show-thread' by hand or select an article."
299 :group 'gnus-thread
300 :type '(radio (sexp :format "Non-nil\n"
301 :match (lambda (widget value)
302 (not (or (consp value) (functionp value))))
303 :value t)
304 (const nil)
305 (sexp :tag "Predicate specifier")))
306
307 (defcustom gnus-thread-hide-killed t
308 "*If non-nil, hide killed threads automatically."
309 :group 'gnus-thread
310 :type 'boolean)
311
312 (defcustom gnus-thread-ignore-subject t
313 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
314 If nil, articles that have different subjects from their parents will
315 start separate threads."
316 :group 'gnus-thread
317 :type 'boolean)
318
319 (defcustom gnus-thread-operation-ignore-subject t
320 "*If non-nil, subjects will be ignored when doing thread commands.
321 This affects commands like `gnus-summary-kill-thread' and
322 `gnus-summary-lower-thread'.
323
324 If this variable is nil, articles in the same thread with different
325 subjects will not be included in the operation in question. If this
326 variable is `fuzzy', only articles that have subjects that are fuzzily
327 equal will be included."
328 :group 'gnus-thread
329 :type '(choice (const :tag "off" nil)
330 (const fuzzy)
331 (sexp :tag "on" t)))
332
333 (defcustom gnus-thread-indent-level 4
334 "*Number that says how much each sub-thread should be indented."
335 :group 'gnus-thread
336 :type 'integer)
337
338 (defcustom gnus-auto-extend-newsgroup t
339 "*If non-nil, extend newsgroup forward and backward when requested."
340 :group 'gnus-summary-choose
341 :type 'boolean)
342
343 (defcustom gnus-auto-select-first t
344 "If non-nil, select an article on group entry.
345 An article is selected automatically when entering a group
346 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
347 `gnus-summary-catchup-and-goto-next-group'.
348
349 Which article is selected is controlled by the variable
350 `gnus-auto-select-subject'.
351
352 If you want to prevent automatic selection of articles in some
353 newsgroups, set the variable to nil in `gnus-select-group-hook'."
354 ;; Commands include...
355 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
356 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
357 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
358 :group 'gnus-group-select
359 :type '(choice (const :tag "none" nil)
360 (sexp :menu-tag "first" t)))
361
362 (defcustom gnus-auto-select-subject 'unseen-or-unread
363 "*Says what subject to place under point when entering a group.
364
365 This variable can either be the symbols `first' (place point on the
366 first subject), `unread' (place point on the subject line of the first
367 unread article), `best' (place point on the subject line of the
368 highest-scored article), `unseen' (place point on the subject line of
369 the first unseen article), `unseen-or-unread' (place point on the subject
370 line of the first unseen article or, if all articles have been seen, on the
371 subject line of the first unread article), or a function to be called to
372 place point on some subject line."
373 :version "24.1"
374 :group 'gnus-group-select
375 :type '(choice (const best)
376 (const unread)
377 (const first)
378 (const unseen)
379 (const unseen-or-unread)
380 (function :tag "Function to call")))
381
382 (defcustom gnus-auto-select-next t
383 "*If non-nil, offer to go to the next group from the end of the previous.
384 If the value is t and the next newsgroup is empty, Gnus will exit
385 summary mode and go back to group mode. If the value is neither nil
386 nor t, Gnus will select the following unread newsgroup. In
387 particular, if the value is the symbol `quietly', the next unread
388 newsgroup will be selected without any confirmation, and if it is
389 `almost-quietly', the next group will be selected without any
390 confirmation if you are located on the last article in the group.
391 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
392 will go to the next group without confirmation."
393 :group 'gnus-summary-maneuvering
394 :type '(choice (const :tag "off" nil)
395 (const quietly)
396 (const almost-quietly)
397 (const slightly-quietly)
398 (sexp :menu-tag "on" t)))
399
400 (defcustom gnus-auto-select-same nil
401 "*If non-nil, select the next article with the same subject.
402 If there are no more articles with the same subject, go to
403 the first unread article."
404 :group 'gnus-summary-maneuvering
405 :type 'boolean)
406
407 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
408 "What article should be selected after exiting an ephemeral group.
409 Valid values include:
410
411 `next'
412 Select the next article.
413 `next-unread'
414 Select the next unread article.
415 `next-noselect'
416 Move the cursor to the next article. This is the default.
417 `next-unread-noselect'
418 Move the cursor to the next unread article.
419
420 If it has any other value or there is no next (unread) article, the
421 article selected before entering to the ephemeral group will appear."
422 :version "23.1" ;; No Gnus
423 :group 'gnus-summary-maneuvering
424 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
425 (const next) (const next-unread)
426 (const next-noselect) (const next-unread-noselect)
427 (sexp :tag "other" :value nil)))
428
429 (defcustom gnus-auto-goto-ignores 'unfetched
430 "*Says how to handle unfetched articles when maneuvering.
431
432 This variable can either be the symbols nil (maneuver to any
433 article), `undownloaded' (maneuvering while unplugged ignores articles
434 that have not been fetched), `always-undownloaded' (maneuvering always
435 ignores articles that have not been fetched), `unfetched' (maneuvering
436 ignores articles whose headers have not been fetched).
437
438 NOTE: The list of unfetched articles will always be nil when plugged
439 and, when unplugged, a subset of the undownloaded article list."
440 :version "22.1"
441 :group 'gnus-summary-maneuvering
442 :type '(choice (const :tag "None" nil)
443 (const :tag "Undownloaded when unplugged" undownloaded)
444 (const :tag "Undownloaded" always-undownloaded)
445 (const :tag "Unfetched" unfetched)))
446
447 (defcustom gnus-summary-check-current nil
448 "*If non-nil, consider the current article when moving.
449 The \"unread\" movement commands will stay on the same line if the
450 current article is unread."
451 :group 'gnus-summary-maneuvering
452 :type 'boolean)
453
454 (defcustom gnus-auto-center-summary
455 (max (or (bound-and-true-p scroll-margin) 0) 2)
456 "*If non-nil, always center the current summary buffer.
457 In particular, if `vertical' do only vertical recentering. If non-nil
458 and non-`vertical', do both horizontal and vertical recentering."
459 :group 'gnus-summary-maneuvering
460 :type '(choice (const :tag "none" nil)
461 (const vertical)
462 (integer :tag "height")
463 (sexp :menu-tag "both" t)))
464
465 (defcustom gnus-auto-center-group t
466 "If non-nil, always center the group buffer."
467 :group 'gnus-summary-maneuvering
468 :type 'boolean)
469
470 (defcustom gnus-show-all-headers nil
471 "*If non-nil, don't hide any headers."
472 :group 'gnus-article-hiding
473 :group 'gnus-article-headers
474 :type 'boolean)
475
476 (defcustom gnus-summary-ignore-duplicates nil
477 "*If non-nil, ignore articles with identical Message-ID headers."
478 :group 'gnus-summary
479 :type 'boolean)
480
481 (defcustom gnus-single-article-buffer nil
482 "*If non-nil, display all articles in the same buffer.
483 If nil, each group will get its own article buffer."
484 :version "24.1"
485 :group 'gnus-article-various
486 :type 'boolean)
487
488 (defcustom gnus-widen-article-window nil
489 "If non-nil, selecting the article buffer will display only the article buffer."
490 :version "24.1"
491 :group 'gnus-article-various
492 :type 'boolean)
493
494 (defcustom gnus-break-pages t
495 "*If non-nil, do page breaking on articles.
496 The page delimiter is specified by the `gnus-page-delimiter'
497 variable."
498 :group 'gnus-article-various
499 :type 'boolean)
500
501 (defcustom gnus-move-split-methods nil
502 "*Variable used to suggest where articles are to be moved to.
503 It uses the same syntax as the `gnus-split-methods' variable.
504 However, whereas `gnus-split-methods' specifies file names as targets,
505 this variable specifies group names."
506 :group 'gnus-summary-mail
507 :type '(repeat (choice (list :value (fun) function)
508 (cons :value ("" "") regexp (repeat string))
509 (sexp :value nil))))
510
511 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
512 "Function used to compute default prefix for article move/copy/etc prompts.
513 The function should take one argument, a group name, and return a
514 string with the suggested prefix."
515 :group 'gnus-summary-mail
516 :type 'function)
517
518 ;; FIXME: Although the custom type is `character' for the following variables,
519 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
520
521 (defcustom gnus-unread-mark ? ;Whitespace
522 "*Mark used for unread articles."
523 :group 'gnus-summary-marks
524 :type 'character)
525
526 (defcustom gnus-ticked-mark ?!
527 "*Mark used for ticked articles."
528 :group 'gnus-summary-marks
529 :type 'character)
530
531 (defcustom gnus-dormant-mark ??
532 "*Mark used for dormant articles."
533 :group 'gnus-summary-marks
534 :type 'character)
535
536 (defcustom gnus-del-mark ?r
537 "*Mark used for del'd articles."
538 :group 'gnus-summary-marks
539 :type 'character)
540
541 (defcustom gnus-read-mark ?R
542 "*Mark used for read articles."
543 :group 'gnus-summary-marks
544 :type 'character)
545
546 (defcustom gnus-expirable-mark ?E
547 "*Mark used for expirable articles."
548 :group 'gnus-summary-marks
549 :type 'character)
550
551 (defcustom gnus-killed-mark ?K
552 "*Mark used for killed articles."
553 :group 'gnus-summary-marks
554 :type 'character)
555
556 (defcustom gnus-spam-mark ?$
557 "*Mark used for spam articles."
558 :version "22.1"
559 :group 'gnus-summary-marks
560 :type 'character)
561
562 (defcustom gnus-kill-file-mark ?X
563 "*Mark used for articles killed by kill files."
564 :group 'gnus-summary-marks
565 :type 'character)
566
567 (defcustom gnus-low-score-mark ?Y
568 "*Mark used for articles with a low score."
569 :group 'gnus-summary-marks
570 :type 'character)
571
572 (defcustom gnus-catchup-mark ?C
573 "*Mark used for articles that are caught up."
574 :group 'gnus-summary-marks
575 :type 'character)
576
577 (defcustom gnus-replied-mark ?A
578 "*Mark used for articles that have been replied to."
579 :group 'gnus-summary-marks
580 :type 'character)
581
582 (defcustom gnus-forwarded-mark ?F
583 "*Mark used for articles that have been forwarded."
584 :version "22.1"
585 :group 'gnus-summary-marks
586 :type 'character)
587
588 (defcustom gnus-recent-mark ?N
589 "*Mark used for articles that are recent."
590 :version "22.1"
591 :group 'gnus-summary-marks
592 :type 'character)
593
594 (defcustom gnus-cached-mark ?*
595 "*Mark used for articles that are in the cache."
596 :group 'gnus-summary-marks
597 :type 'character)
598
599 (defcustom gnus-saved-mark ?S
600 "*Mark used for articles that have been saved."
601 :group 'gnus-summary-marks
602 :type 'character)
603
604 (defcustom gnus-unseen-mark ?.
605 "*Mark used for articles that haven't been seen."
606 :version "22.1"
607 :group 'gnus-summary-marks
608 :type 'character)
609
610 (defcustom gnus-no-mark ? ;Whitespace
611 "*Mark used for articles that have no other secondary mark."
612 :version "22.1"
613 :group 'gnus-summary-marks
614 :type 'character)
615
616 (defcustom gnus-ancient-mark ?O
617 "*Mark used for ancient articles."
618 :group 'gnus-summary-marks
619 :type 'character)
620
621 (defcustom gnus-sparse-mark ?Q
622 "*Mark used for sparsely reffed articles."
623 :group 'gnus-summary-marks
624 :type 'character)
625
626 (defcustom gnus-canceled-mark ?G
627 "*Mark used for canceled articles."
628 :group 'gnus-summary-marks
629 :type 'character)
630
631 (defcustom gnus-duplicate-mark ?M
632 "*Mark used for duplicate articles."
633 :group 'gnus-summary-marks
634 :type 'character)
635
636 (defcustom gnus-undownloaded-mark ?-
637 "*Mark used for articles that weren't downloaded."
638 :version "22.1"
639 :group 'gnus-summary-marks
640 :type 'character)
641
642 (defcustom gnus-downloaded-mark ?+
643 "*Mark used for articles that were downloaded."
644 :group 'gnus-summary-marks
645 :type 'character)
646
647 (defcustom gnus-downloadable-mark ?%
648 "*Mark used for articles that are to be downloaded."
649 :group 'gnus-summary-marks
650 :type 'character)
651
652 (defcustom gnus-unsendable-mark ?=
653 "*Mark used for articles that won't be sent."
654 :group 'gnus-summary-marks
655 :type 'character)
656
657 (defcustom gnus-score-over-mark ?+
658 "*Score mark used for articles with high scores."
659 :group 'gnus-summary-marks
660 :type 'character)
661
662 (defcustom gnus-score-below-mark ?-
663 "*Score mark used for articles with low scores."
664 :group 'gnus-summary-marks
665 :type 'character)
666
667 (defcustom gnus-empty-thread-mark ? ;Whitespace
668 "*There is no thread under the article."
669 :group 'gnus-summary-marks
670 :type 'character)
671
672 (defcustom gnus-not-empty-thread-mark ?=
673 "*There is a thread under the article."
674 :group 'gnus-summary-marks
675 :type 'character)
676
677 (defcustom gnus-view-pseudo-asynchronously nil
678 "*If non-nil, Gnus will view pseudo-articles asynchronously."
679 :group 'gnus-extract-view
680 :type 'boolean)
681
682 (defcustom gnus-auto-expirable-marks
683 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
684 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
685 gnus-duplicate-mark)
686 "*The list of marks converted into expiration if a group is auto-expirable."
687 :version "24.1"
688 :group 'gnus-summary
689 :type '(repeat character))
690
691 (defcustom gnus-inhibit-user-auto-expire t
692 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
693 :version "21.1"
694 :group 'gnus-summary
695 :type 'boolean)
696
697 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
698 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
699 If nil, the expirable marks will be unchanged except that the marks
700 will be removed when copying or moving articles to a group that has
701 not turned auto-expire on. If non-nil, articles that have been read
702 will be marked as expirable when being copied or moved to a group in
703 which auto-expire is turned on."
704 :version "23.2"
705 :type 'boolean
706 :group 'gnus-summary-marks)
707
708 (defcustom gnus-view-pseudos nil
709 "*If `automatic', pseudo-articles will be viewed automatically.
710 If `not-confirm', pseudos will be viewed automatically, and the user
711 will not be asked to confirm the command."
712 :group 'gnus-extract-view
713 :type '(choice (const :tag "off" nil)
714 (const automatic)
715 (const not-confirm)))
716
717 (defcustom gnus-view-pseudos-separately t
718 "*If non-nil, one pseudo-article will be created for each file to be viewed.
719 If nil, all files that use the same viewing command will be given as a
720 list of parameters to that command."
721 :group 'gnus-extract-view
722 :type 'boolean)
723
724 (defcustom gnus-insert-pseudo-articles t
725 "*If non-nil, insert pseudo-articles when decoding articles."
726 :group 'gnus-extract-view
727 :type 'boolean)
728
729 (defcustom gnus-summary-dummy-line-format
730 " %(: :%) %S\n"
731 "*The format specification for the dummy roots in the summary buffer.
732 It works along the same lines as a normal formatting string,
733 with some simple extensions.
734
735 %S The subject
736
737 General format specifiers can also be used.
738 See `(gnus)Formatting Variables'."
739 :link '(custom-manual "(gnus)Formatting Variables")
740 :group 'gnus-threading
741 :type 'string)
742
743 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
744 "*The format specification for the summary mode line.
745 It works along the same lines as a normal formatting string,
746 with some simple extensions:
747
748 %G Group name
749 %p Unprefixed group name
750 %A Current article number
751 %z Current article score
752 %V Gnus version
753 %U Number of unread articles in the group
754 %e Number of unselected articles in the group
755 %Z A string with unread/unselected article counts
756 %g Shortish group name
757 %S Subject of the current article
758 %u User-defined spec
759 %s Current score file name
760 %d Number of dormant articles
761 %r Number of articles that have been marked as read in this session
762 %E Number of articles expunged by the score files"
763 :group 'gnus-summary-format
764 :type 'string)
765
766 (defcustom gnus-list-identifiers nil
767 "Regexp that matches list identifiers to be removed from subject.
768 This can also be a list of regexps."
769 :version "21.1"
770 :group 'gnus-summary-format
771 :group 'gnus-article-hiding
772 :type '(choice (const :tag "none" nil)
773 (regexp :value ".*")
774 (repeat :value (".*") regexp)))
775
776 (defcustom gnus-summary-mark-below 0
777 "*Mark all articles with a score below this variable as read.
778 This variable is local to each summary buffer and usually set by the
779 score file."
780 :group 'gnus-score-default
781 :type 'integer)
782
783 (defun gnus-widget-reversible-match (widget value)
784 "Ignoring WIDGET, convert VALUE to internal form.
785 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
786 ;; (debug value)
787 (or (symbolp value)
788 (and (listp value)
789 (eq (length value) 2)
790 (eq (nth 0 value) 'not)
791 (symbolp (nth 1 value)))))
792
793 (defun gnus-widget-reversible-to-internal (widget value)
794 "Ignoring WIDGET, convert VALUE to internal form.
795 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
796 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
797 ;; (debug value)
798 (if (atom value)
799 (list value nil)
800 (list (nth 1 value) t)))
801
802 (defun gnus-widget-reversible-to-external (widget value)
803 "Ignoring WIDGET, convert VALUE to external form.
804 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
805 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
806 ;; (debug value)
807 (if (nth 1 value)
808 (list 'not (nth 0 value))
809 (nth 0 value)))
810
811 (define-widget 'gnus-widget-reversible 'group
812 "A `group' that convert values."
813 :match 'gnus-widget-reversible-match
814 :value-to-internal 'gnus-widget-reversible-to-internal
815 :value-to-external 'gnus-widget-reversible-to-external)
816
817 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
818 "*List of functions used for sorting articles in the summary buffer.
819
820 Each function takes two articles and returns non-nil if the first
821 article should be sorted before the other. If you use more than one
822 function, the primary sort function should be the last. You should
823 probably always include `gnus-article-sort-by-number' in the list of
824 sorting functions -- preferably first. Also note that sorting by date
825 is often much slower than sorting by number, and the sorting order is
826 very similar. (Sorting by date means sorting by the time the message
827 was sent, sorting by number means sorting by arrival time.)
828
829 Each item can also be a list `(not F)' where F is a function;
830 this reverses the sort order.
831
832 Ready-made functions include `gnus-article-sort-by-number',
833 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
834 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
835 and `gnus-article-sort-by-score'.
836
837 When threading is turned on, the variable `gnus-thread-sort-functions'
838 controls how articles are sorted."
839 :group 'gnus-summary-sort
840 :type '(repeat (gnus-widget-reversible
841 (choice (function-item gnus-article-sort-by-number)
842 (function-item gnus-article-sort-by-author)
843 (function-item gnus-article-sort-by-subject)
844 (function-item gnus-article-sort-by-date)
845 (function-item gnus-article-sort-by-score)
846 (function-item gnus-article-sort-by-random)
847 (function :tag "other"))
848 (boolean :tag "Reverse order"))))
849
850
851 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
852 "*List of functions used for sorting threads in the summary buffer.
853 By default, threads are sorted by article number.
854
855 Each function takes two threads and returns non-nil if the first
856 thread should be sorted before the other. If you use more than one
857 function, the primary sort function should be the last. You should
858 probably always include `gnus-thread-sort-by-number' in the list of
859 sorting functions -- preferably first. Also note that sorting by date
860 is often much slower than sorting by number, and the sorting order is
861 very similar. (Sorting by date means sorting by the time the message
862 was sent, sorting by number means sorting by arrival time.)
863
864 Each list item can also be a list `(not F)' where F is a
865 function; this specifies reversed sort order.
866
867 Ready-made functions include `gnus-thread-sort-by-number',
868 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
869 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
870 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
871 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
872 and `gnus-thread-sort-by-total-score' (see
873 `gnus-thread-score-function').
874
875 When threading is turned off, the variable
876 `gnus-article-sort-functions' controls how articles are sorted."
877 :group 'gnus-summary-sort
878 :type '(repeat
879 (gnus-widget-reversible
880 (choice (function-item gnus-thread-sort-by-number)
881 (function-item gnus-thread-sort-by-author)
882 (function-item gnus-thread-sort-by-recipient)
883 (function-item gnus-thread-sort-by-subject)
884 (function-item gnus-thread-sort-by-date)
885 (function-item gnus-thread-sort-by-score)
886 (function-item gnus-thread-sort-by-most-recent-number)
887 (function-item gnus-thread-sort-by-most-recent-date)
888 (function-item gnus-thread-sort-by-random)
889 (function-item gnus-thread-sort-by-total-score)
890 (function :tag "other"))
891 (boolean :tag "Reverse order"))))
892
893 (defcustom gnus-thread-score-function '+
894 "*Function used for calculating the total score of a thread.
895
896 The function is called with the scores of the article and each
897 subthread and should then return the score of the thread.
898
899 Some functions you can use are `+', `max', or `min'."
900 :group 'gnus-summary-sort
901 :type 'function)
902
903 (defcustom gnus-summary-expunge-below nil
904 "All articles that have a score less than this variable will be expunged.
905 This variable is local to the summary buffers."
906 :group 'gnus-score-default
907 :type '(choice (const :tag "off" nil)
908 integer))
909
910 (defcustom gnus-thread-expunge-below nil
911 "All threads that have a total score less than this variable will be expunged.
912 See `gnus-thread-score-function' for en explanation of what a
913 \"thread score\" is.
914
915 This variable is local to the summary buffers."
916 :group 'gnus-threading
917 :group 'gnus-score-default
918 :type '(choice (const :tag "off" nil)
919 integer))
920
921 (defcustom gnus-summary-mode-hook nil
922 "*A hook for Gnus summary mode.
923 This hook is run before any variables are set in the summary buffer."
924 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
925 :group 'gnus-summary-various
926 :type 'hook)
927
928 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
929 (when (featurep 'xemacs)
930 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
931 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
932 (add-hook 'gnus-summary-mode-hook
933 'gnus-xmas-switch-horizontal-scrollbar-off))
934
935 (defcustom gnus-summary-menu-hook nil
936 "*Hook run after the creation of the summary mode menu."
937 :group 'gnus-summary-visual
938 :type 'hook)
939
940 (defcustom gnus-summary-exit-hook nil
941 "*A hook called on exit from the summary buffer.
942 It will be called with point in the group buffer."
943 :group 'gnus-summary-exit
944 :type 'hook)
945
946 (defcustom gnus-summary-prepare-hook nil
947 "*A hook called after the summary buffer has been generated.
948 If you want to modify the summary buffer, you can use this hook."
949 :group 'gnus-summary-various
950 :type 'hook)
951
952 (defcustom gnus-summary-prepared-hook nil
953 "*A hook called as the last thing after the summary buffer has been generated."
954 :group 'gnus-summary-various
955 :type 'hook)
956
957 (defcustom gnus-summary-generate-hook nil
958 "*A hook run just before generating the summary buffer.
959 This hook is commonly used to customize threading variables and the
960 like."
961 :group 'gnus-summary-various
962 :type 'hook)
963
964 (defcustom gnus-select-group-hook nil
965 "*A hook called when a newsgroup is selected.
966
967 If you'd like to simplify subjects like the
968 `gnus-summary-next-same-subject' command does, you can use the
969 following hook:
970
971 (add-hook gnus-select-group-hook
972 (lambda ()
973 (mapcar (lambda (header)
974 (mail-header-set-subject
975 header
976 (gnus-simplify-subject
977 (mail-header-subject header) 're-only)))
978 gnus-newsgroup-headers)))"
979 :group 'gnus-group-select
980 :type 'hook)
981
982 (defcustom gnus-select-article-hook nil
983 "*A hook called when an article is selected."
984 :group 'gnus-summary-choose
985 :options '(gnus-agent-fetch-selected-article)
986 :type 'hook)
987
988 (defcustom gnus-visual-mark-article-hook
989 (list 'gnus-highlight-selected-summary)
990 "*Hook run after selecting an article in the summary buffer.
991 It is meant to be used for highlighting the article in some way. It
992 is not run if `gnus-visual' is nil."
993 :group 'gnus-summary-visual
994 :type 'hook)
995
996 (defcustom gnus-parse-headers-hook nil
997 "*A hook called before parsing the headers."
998 :group 'gnus-various
999 :type 'hook)
1000
1001 (defcustom gnus-exit-group-hook nil
1002 "*A hook called when exiting summary mode.
1003 This hook is not called from the non-updating exit commands like `Q'."
1004 :group 'gnus-various
1005 :type 'hook)
1006
1007 (defcustom gnus-summary-update-hook nil
1008 "*A hook called when a summary line is changed.
1009 The hook will not be called if `gnus-visual' is nil.
1010
1011 The default function `gnus-summary-highlight-line' will
1012 highlight the line according to the `gnus-summary-highlight'
1013 variable."
1014 :group 'gnus-summary-visual
1015 :type 'hook)
1016
1017 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1018 "*A hook called when an article is selected for the first time.
1019 The hook is intended to mark an article as read (or unread)
1020 automatically when it is selected."
1021 :group 'gnus-summary-choose
1022 :type 'hook)
1023
1024 (defcustom gnus-group-no-more-groups-hook nil
1025 "*A hook run when returning to group mode having no more (unread) groups."
1026 :group 'gnus-group-select
1027 :type 'hook)
1028
1029 (defcustom gnus-ps-print-hook nil
1030 "*A hook run before ps-printing something from Gnus."
1031 :group 'gnus-summary
1032 :type 'hook)
1033
1034 (defcustom gnus-summary-article-move-hook nil
1035 "*A hook called after an article is moved, copied, respooled, or crossposted."
1036 :version "22.1"
1037 :group 'gnus-summary
1038 :type 'hook)
1039
1040 (defcustom gnus-summary-article-delete-hook nil
1041 "*A hook called after an article is deleted."
1042 :version "22.1"
1043 :group 'gnus-summary
1044 :type 'hook)
1045
1046 (defcustom gnus-summary-article-expire-hook nil
1047 "*A hook called after an article is expired."
1048 :version "22.1"
1049 :group 'gnus-summary
1050 :type 'hook)
1051
1052 (defcustom gnus-summary-display-arrow
1053 (and (fboundp 'display-graphic-p)
1054 (display-graphic-p))
1055 "*If non-nil, display an arrow highlighting the current article."
1056 :version "22.1"
1057 :group 'gnus-summary
1058 :type 'boolean)
1059
1060 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1061 "Face used for highlighting the current article in the summary buffer."
1062 :group 'gnus-summary-visual
1063 :type 'face)
1064
1065 (defvar gnus-tmp-downloaded nil)
1066
1067 (defcustom gnus-summary-highlight
1068 '(((eq mark gnus-canceled-mark)
1069 . gnus-summary-cancelled)
1070 ((and uncached (> score default-high))
1071 . gnus-summary-high-undownloaded)
1072 ((and uncached (< score default-low))
1073 . gnus-summary-low-undownloaded)
1074 (uncached
1075 . gnus-summary-normal-undownloaded)
1076 ((and (> score default-high)
1077 (or (eq mark gnus-dormant-mark)
1078 (eq mark gnus-ticked-mark)))
1079 . gnus-summary-high-ticked)
1080 ((and (< score default-low)
1081 (or (eq mark gnus-dormant-mark)
1082 (eq mark gnus-ticked-mark)))
1083 . gnus-summary-low-ticked)
1084 ((or (eq mark gnus-dormant-mark)
1085 (eq mark gnus-ticked-mark))
1086 . gnus-summary-normal-ticked)
1087 ((and (> score default-high) (eq mark gnus-ancient-mark))
1088 . gnus-summary-high-ancient)
1089 ((and (< score default-low) (eq mark gnus-ancient-mark))
1090 . gnus-summary-low-ancient)
1091 ((eq mark gnus-ancient-mark)
1092 . gnus-summary-normal-ancient)
1093 ((and (> score default-high) (eq mark gnus-unread-mark))
1094 . gnus-summary-high-unread)
1095 ((and (< score default-low) (eq mark gnus-unread-mark))
1096 . gnus-summary-low-unread)
1097 ((eq mark gnus-unread-mark)
1098 . gnus-summary-normal-unread)
1099 ((> score default-high)
1100 . gnus-summary-high-read)
1101 ((< score default-low)
1102 . gnus-summary-low-read)
1103 (t
1104 . gnus-summary-normal-read))
1105 "*Controls the highlighting of summary buffer lines.
1106
1107 A list of (FORM . FACE) pairs. When deciding how a particular
1108 summary line should be displayed, each form is evaluated. The content
1109 of the face field after the first true form is used. You can change
1110 how those summary lines are displayed, by editing the face field.
1111
1112 You can use the following variables in the FORM field.
1113
1114 score: The article's score.
1115 default: The default article score.
1116 default-high: The default score for high scored articles.
1117 default-low: The default score for low scored articles.
1118 below: The score below which articles are automatically marked as read.
1119 mark: The article's mark.
1120 uncached: Non-nil if the article is uncached."
1121 :group 'gnus-summary-visual
1122 :type '(repeat (cons (sexp :tag "Form" nil)
1123 face)))
1124 (put 'gnus-summary-highlight 'risky-local-variable t)
1125
1126 (defcustom gnus-alter-header-function nil
1127 "Function called to allow alteration of article header structures.
1128 The function is called with one parameter, the article header vector,
1129 which it may alter in any way."
1130 :type '(choice (const :tag "None" nil)
1131 function)
1132 :group 'gnus-summary)
1133
1134 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1135 "Function used to decode a string with encoded words.")
1136
1137 (defvar gnus-decode-encoded-address-function
1138 'mail-decode-encoded-address-string
1139 "Function used to decode addresses with encoded words.")
1140
1141 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups)
1142 "*Extra headers to parse."
1143 :version "24.1" ; added Cc Keywords Gcc
1144 :group 'gnus-summary
1145 :type '(repeat symbol))
1146
1147 (defcustom gnus-ignored-from-addresses
1148 (and user-mail-address
1149 (not (string= user-mail-address ""))
1150 (regexp-quote user-mail-address))
1151 "*From headers that may be suppressed in favor of To headers.
1152 This can be a regexp or a list of regexps."
1153 :version "21.1"
1154 :group 'gnus-summary
1155 :type '(choice regexp
1156 (repeat :tag "Regexp List" regexp)))
1157
1158 (defsubst gnus-ignored-from-addresses ()
1159 (gmm-regexp-concat gnus-ignored-from-addresses))
1160
1161 (defcustom gnus-summary-to-prefix "-> "
1162 "*String prefixed to the To field in the summary line when
1163 using `gnus-ignored-from-addresses'."
1164 :version "22.1"
1165 :group 'gnus-summary
1166 :type 'string)
1167
1168 (defcustom gnus-summary-newsgroup-prefix "=> "
1169 "*String prefixed to the Newsgroup field in the summary
1170 line when using the option `gnus-ignored-from-addresses'."
1171 :version "22.1"
1172 :group 'gnus-summary
1173 :type 'string)
1174
1175 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1176 "List of charsets that should be ignored.
1177 When these charsets are used in the \"charset\" parameter, the
1178 default charset will be used instead."
1179 :version "21.1"
1180 :type '(repeat symbol)
1181 :group 'gnus-charset)
1182
1183 (defcustom gnus-newsgroup-maximum-articles nil
1184 "The maximum number of articles a newsgroup.
1185 If this is a number, old articles in a newsgroup exceeding this number
1186 are silently ignored. If it is nil, no article is ignored. Note that
1187 setting this variable to a number might prevent you from reading very
1188 old articles."
1189 :group 'gnus-group-select
1190 :version "22.2"
1191 :type '(choice (const :tag "No limit" nil)
1192 integer))
1193
1194 (gnus-define-group-parameter
1195 ignored-charsets
1196 :type list
1197 :function-document
1198 "Return the ignored charsets of GROUP."
1199 :variable gnus-group-ignored-charsets-alist
1200 :variable-default
1201 '(("alt\\.chinese\\.text" iso-8859-1))
1202 :variable-document
1203 "Alist of regexps (to match group names) and charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1206 :variable-group gnus-charset
1207 :variable-type '(repeat (cons (regexp :tag "Group")
1208 (repeat symbol)))
1209 :parameter-type '(choice :tag "Ignored charsets"
1210 :value nil
1211 (repeat (symbol)))
1212 :parameter-document "\
1213 List of charsets that should be ignored.
1214
1215 When these charsets are used in the \"charset\" parameter, the
1216 default charset will be used instead.")
1217
1218 (defcustom gnus-group-highlight-words-alist nil
1219 "Alist of group regexps and highlight regexps.
1220 This variable uses the same syntax as `gnus-emphasis-alist'."
1221 :version "21.1"
1222 :type '(repeat (cons (regexp :tag "Group")
1223 (repeat (list (regexp :tag "Highlight regexp")
1224 (number :tag "Group for entire word" 0)
1225 (number :tag "Group for displayed part" 0)
1226 (symbol :tag "Face"
1227 gnus-emphasis-highlight-words)))))
1228 :group 'gnus-summary-visual)
1229
1230 (defcustom gnus-summary-show-article-charset-alist
1231 nil
1232 "Alist of number and charset.
1233 The article will be shown with the charset corresponding to the
1234 numbered argument.
1235 For example: ((1 . cn-gb-2312) (2 . big5))."
1236 :version "21.1"
1237 :type '(repeat (cons (number :tag "Argument" 1)
1238 (symbol :tag "Charset")))
1239 :group 'gnus-charset)
1240
1241 (defcustom gnus-preserve-marks t
1242 "Whether marks are preserved when moving, copying and respooling messages."
1243 :version "21.1"
1244 :type 'boolean
1245 :group 'gnus-summary-marks)
1246
1247 (defcustom gnus-alter-articles-to-read-function nil
1248 "Function to be called to alter the list of articles to be selected."
1249 :type '(choice (const nil) function)
1250 :group 'gnus-summary)
1251
1252 (defcustom gnus-orphan-score nil
1253 "*All orphans get this score added. Set in the score file."
1254 :group 'gnus-score-default
1255 :type '(choice (const nil)
1256 integer))
1257
1258 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1259 "*A regexp to match MIME parts when saving multiple parts of a
1260 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1261 This regexp will be used by default when prompting the user for which
1262 type of files to save."
1263 :group 'gnus-summary
1264 :type 'regexp)
1265
1266 (defcustom gnus-read-all-available-headers nil
1267 "Whether Gnus should parse all headers made available to it.
1268 This is mostly relevant for slow back ends where the user may
1269 wish to widen the summary buffer to include all headers
1270 that were fetched."
1271 :version "22.1"
1272 :group 'gnus-summary
1273 :type '(choice boolean regexp))
1274
1275 (defcustom gnus-summary-pipe-output-default-command nil
1276 "Command (and optional arguments) used to pipe article to subprocess.
1277 This will be used as the default command if it is non-nil. The value
1278 will be updated if you modify it when executing the command
1279 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1280 :version "23.1" ;; No Gnus
1281 :group 'gnus-summary
1282 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1283
1284 (defcustom gnus-summary-muttprint-program "muttprint"
1285 "Command (and optional arguments) used to run Muttprint.
1286 The value will be updated if you modify it when executing the command
1287 `gnus-summary-muttprint'."
1288 :version "22.1"
1289 :group 'gnus-summary
1290 :type 'string)
1291
1292 (defcustom gnus-article-loose-mime t
1293 "If non-nil, don't require MIME-Version header.
1294 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1295 supply the MIME-Version header or deliberately strip it from the mail.
1296 If non-nil (the default), Gnus will treat some articles as MIME
1297 even if the MIME-Version header is missing."
1298 :version "22.1"
1299 :type 'boolean
1300 :group 'gnus-article-mime)
1301
1302 (defcustom gnus-article-emulate-mime t
1303 "If non-nil, use MIME emulation for uuencode and the like.
1304 This means that Gnus will search message bodies for text that look
1305 like uuencoded bits, yEncoded bits, and so on, and present that using
1306 the normal Gnus MIME machinery."
1307 :version "22.1"
1308 :type 'boolean
1309 :group 'gnus-article-mime)
1310
1311 ;;; Internal variables
1312
1313 (defvar gnus-summary-display-cache nil)
1314 (defvar gnus-article-mime-handles nil)
1315 (defvar gnus-article-decoded-p nil)
1316 (defvar gnus-article-charset nil)
1317 (defvar gnus-article-ignored-charsets nil)
1318 (defvar gnus-scores-exclude-files nil)
1319 (defvar gnus-page-broken nil)
1320
1321 (defvar gnus-original-article nil)
1322 (defvar gnus-article-internal-prepare-hook nil)
1323 (defvar gnus-newsgroup-process-stack nil)
1324
1325 (defvar gnus-thread-indent-array nil)
1326 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1327 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1328 "Function called to sort the articles within a thread after it has been gathered together.")
1329
1330 (defvar gnus-summary-save-parts-type-history nil)
1331 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1332
1333 ;; Avoid highlighting in kill files.
1334 (defvar gnus-summary-inhibit-highlight nil)
1335 (defvar gnus-newsgroup-selected-overlay nil)
1336 (defvar gnus-inhibit-limiting nil)
1337 (defvar gnus-newsgroup-adaptive-score-file nil)
1338 (defvar gnus-current-score-file nil)
1339 (defvar gnus-current-move-group nil)
1340 (defvar gnus-current-copy-group nil)
1341 (defvar gnus-current-crosspost-group nil)
1342 (defvar gnus-newsgroup-display nil)
1343
1344 (defvar gnus-newsgroup-dependencies nil)
1345 (defvar gnus-newsgroup-adaptive nil)
1346 (defvar gnus-summary-display-article-function nil)
1347 (defvar gnus-summary-highlight-line-function nil
1348 "Function called after highlighting a summary line.")
1349
1350 (defvar gnus-summary-line-format-alist
1351 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1352 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1353 (?s gnus-tmp-subject-or-nil ?s)
1354 (?n gnus-tmp-name ?s)
1355 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1356 ?s)
1357 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1358 gnus-tmp-from) ?s)
1359 (?F gnus-tmp-from ?s)
1360 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1361 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1362 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1363 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1364 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1365 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1366 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1367 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1368 (?L gnus-tmp-lines ?s)
1369 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1370 0) ?d)
1371 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1372 "") ?s)
1373 (?g (or (gnus-group-short-name
1374 (nnir-article-group (mail-header-number gnus-tmp-header)))
1375 "") ?s)
1376 (?O gnus-tmp-downloaded ?c)
1377 (?I gnus-tmp-indentation ?s)
1378 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1379 (?R gnus-tmp-replied ?c)
1380 (?\[ gnus-tmp-opening-bracket ?c)
1381 (?\] gnus-tmp-closing-bracket ?c)
1382 (?\> (make-string gnus-tmp-level ? ) ?s)
1383 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1384 (?i gnus-tmp-score ?d)
1385 (?z gnus-tmp-score-char ?c)
1386 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1387 (?U gnus-tmp-unread ?c)
1388 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1389 ?s)
1390 (?t (gnus-summary-number-of-articles-in-thread
1391 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1392 ?d)
1393 (?e (gnus-summary-number-of-articles-in-thread
1394 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1395 ?c)
1396 (?u gnus-tmp-user-defined ?s)
1397 (?P (gnus-pick-line-number) ?d)
1398 (?B gnus-tmp-thread-tree-header-string ?s)
1399 (user-date (gnus-user-date
1400 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1401 "An alist of format specifications that can appear in summary lines.
1402 These are paired with what variables they correspond with, along with
1403 the type of the variable (string, integer, character, etc).")
1404
1405 (defvar gnus-summary-dummy-line-format-alist
1406 `((?S gnus-tmp-subject ?s)
1407 (?N gnus-tmp-number ?d)
1408 (?u gnus-tmp-user-defined ?s)))
1409
1410 (defvar gnus-summary-mode-line-format-alist
1411 `((?G gnus-tmp-group-name ?s)
1412 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1413 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1414 (?A gnus-tmp-article-number ?d)
1415 (?Z gnus-tmp-unread-and-unselected ?s)
1416 (?V gnus-version ?s)
1417 (?U gnus-tmp-unread-and-unticked ?d)
1418 (?S gnus-tmp-subject ?s)
1419 (?e gnus-tmp-unselected ?d)
1420 (?u gnus-tmp-user-defined ?s)
1421 (?d (length gnus-newsgroup-dormant) ?d)
1422 (?t (length gnus-newsgroup-marked) ?d)
1423 (?h (length gnus-newsgroup-spam-marked) ?d)
1424 (?r (length gnus-newsgroup-reads) ?d)
1425 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1426 (?E gnus-newsgroup-expunged-tally ?d)
1427 (?s (gnus-current-score-file-nondirectory) ?s)))
1428
1429 ;; This is here rather than in gnus-art for compilation reasons.
1430 (defvar gnus-article-mode-line-format-alist
1431 (nconc '((?w (gnus-article-wash-status) ?s)
1432 (?m (gnus-article-mime-part-status) ?s))
1433 gnus-summary-mode-line-format-alist))
1434
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1437
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1440
1441 (defvar gnus-newsgroup-agentized nil
1442 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1443 (defvar gnus-newsgroup-begin nil)
1444 (defvar gnus-newsgroup-end nil)
1445 (defvar gnus-newsgroup-last-rmail nil)
1446 (defvar gnus-newsgroup-last-mail nil)
1447 (defvar gnus-newsgroup-last-folder nil)
1448 (defvar gnus-newsgroup-last-file nil)
1449 (defvar gnus-newsgroup-last-directory nil)
1450 (defvar gnus-newsgroup-auto-expire nil)
1451 (defvar gnus-newsgroup-active nil)
1452 (defvar gnus-newsgroup-highest nil)
1453
1454 (defvar gnus-newsgroup-data nil)
1455 (defvar gnus-newsgroup-data-reverse nil)
1456 (defvar gnus-newsgroup-limit nil)
1457 (defvar gnus-newsgroup-limits nil)
1458 (defvar gnus-summary-use-undownloaded-faces nil)
1459
1460 (defvar gnus-newsgroup-unreads nil
1461 "Sorted list of unread articles in the current newsgroup.")
1462
1463 (defvar gnus-newsgroup-unselected nil
1464 "Sorted list of unselected unread articles in the current newsgroup.")
1465
1466 (defvar gnus-newsgroup-reads nil
1467 "Alist of read articles and article marks in the current newsgroup.")
1468
1469 (defvar gnus-newsgroup-expunged-tally nil)
1470
1471 (defvar gnus-newsgroup-marked nil
1472 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1473
1474 (defvar gnus-newsgroup-spam-marked nil
1475 "List of ranges of articles that have been marked as spam.")
1476
1477 (defvar gnus-newsgroup-killed nil
1478 "List of ranges of articles that have been through the scoring process.")
1479
1480 (defvar gnus-newsgroup-cached nil
1481 "Sorted list of articles that come from the article cache.")
1482
1483 (defvar gnus-newsgroup-saved nil
1484 "List of articles that have been saved.")
1485
1486 (defvar gnus-newsgroup-kill-headers nil)
1487
1488 (defvar gnus-newsgroup-replied nil
1489 "List of articles that have been replied to in the current newsgroup.")
1490
1491 (defvar gnus-newsgroup-forwarded nil
1492 "List of articles that have been forwarded in the current newsgroup.")
1493
1494 (defvar gnus-newsgroup-expirable nil
1495 "Sorted list of articles in the current newsgroup that can be expired.")
1496
1497 (defvar gnus-newsgroup-processable nil
1498 "List of articles in the current newsgroup that can be processed.")
1499
1500 (defvar gnus-newsgroup-downloadable nil
1501 "Sorted list of articles in the current newsgroup that can be processed.")
1502
1503 (defvar gnus-newsgroup-unfetched nil
1504 "Sorted list of articles in the current newsgroup whose headers have
1505 not been fetched into the agent.
1506
1507 This list will always be a subset of gnus-newsgroup-undownloaded.")
1508
1509 (defvar gnus-newsgroup-undownloaded nil
1510 "List of articles in the current newsgroup that haven't been downloaded.")
1511
1512 (defvar gnus-newsgroup-unsendable nil
1513 "List of articles in the current newsgroup that won't be sent.")
1514
1515 (defvar gnus-newsgroup-bookmarks nil
1516 "List of articles in the current newsgroup that have bookmarks.")
1517
1518 (defvar gnus-newsgroup-dormant nil
1519 "Sorted list of dormant articles in the current newsgroup.")
1520
1521 (defvar gnus-newsgroup-unseen nil
1522 "List of unseen articles in the current newsgroup.")
1523
1524 (defvar gnus-newsgroup-seen nil
1525 "Range of seen articles in the current newsgroup.")
1526
1527 (defvar gnus-newsgroup-articles nil
1528 "List of articles in the current newsgroup.")
1529
1530 (defvar gnus-newsgroup-scored nil
1531 "List of scored articles in the current newsgroup.")
1532
1533 (defvar gnus-newsgroup-headers nil
1534 "List of article headers in the current newsgroup.")
1535
1536 (defvar gnus-newsgroup-threads nil)
1537
1538 (defvar gnus-newsgroup-prepared nil
1539 "Whether the current group has been prepared properly.")
1540
1541 (defvar gnus-newsgroup-ancient nil
1542 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1543
1544 (defvar gnus-newsgroup-sparse nil)
1545
1546 (defvar gnus-current-article nil)
1547 (defvar gnus-article-current nil)
1548 (defvar gnus-current-headers nil)
1549 (defvar gnus-have-all-headers nil)
1550 (defvar gnus-last-article nil)
1551 (defvar gnus-newsgroup-history nil)
1552 (defvar gnus-newsgroup-charset nil)
1553 (defvar gnus-newsgroup-ephemeral-charset nil)
1554 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1555
1556 (defvar gnus-article-before-search nil)
1557
1558 (defvar gnus-summary-local-variables
1559 '(gnus-newsgroup-name
1560
1561 ;; Marks lists
1562 gnus-newsgroup-unreads
1563 gnus-newsgroup-unselected
1564 gnus-newsgroup-marked
1565 gnus-newsgroup-spam-marked
1566 gnus-newsgroup-reads
1567 gnus-newsgroup-saved
1568 gnus-newsgroup-replied
1569 gnus-newsgroup-forwarded
1570 gnus-newsgroup-expirable
1571 gnus-newsgroup-killed
1572 gnus-newsgroup-unseen
1573 gnus-newsgroup-seen
1574 gnus-newsgroup-cached
1575 gnus-newsgroup-downloadable
1576 gnus-newsgroup-undownloaded
1577 gnus-newsgroup-unsendable
1578
1579 gnus-newsgroup-begin gnus-newsgroup-end
1580 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1581 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1582 gnus-newsgroup-last-directory
1583 gnus-newsgroup-auto-expire
1584 gnus-newsgroup-processable
1585 gnus-newsgroup-unfetched
1586 gnus-newsgroup-articles
1587 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1588 gnus-newsgroup-headers gnus-newsgroup-threads
1589 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1590 gnus-current-article gnus-current-headers gnus-have-all-headers
1591 gnus-last-article gnus-article-internal-prepare-hook
1592 (gnus-summary-article-delete-hook . global)
1593 (gnus-summary-article-move-hook . global)
1594 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1595 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1596 gnus-thread-expunge-below
1597 gnus-score-alist gnus-current-score-file
1598 (gnus-summary-expunge-below . global)
1599 (gnus-summary-mark-below . global)
1600 (gnus-orphan-score . global)
1601 gnus-newsgroup-active gnus-scores-exclude-files
1602 gnus-newsgroup-highest
1603 gnus-newsgroup-history gnus-newsgroup-ancient
1604 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1605 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1606 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1607 (gnus-newsgroup-expunged-tally . 0)
1608 gnus-cache-removable-articles
1609 gnus-newsgroup-data gnus-newsgroup-data-reverse
1610 gnus-newsgroup-limit gnus-newsgroup-limits
1611 gnus-newsgroup-charset gnus-newsgroup-display
1612 gnus-summary-use-undownloaded-faces)
1613 "Variables that are buffer-local to the summary buffers.")
1614
1615 (defvar gnus-newsgroup-variables nil
1616 "A list of variables that have separate values in different newsgroups.
1617 A list of newsgroup (summary buffer) local variables, or cons of
1618 variables and their default expressions to be evalled (when the default
1619 values are not nil), that should be made global while the summary buffer
1620 is active.
1621
1622 Note: The default expressions will be evaluated (using function `eval')
1623 before assignment to the local variable rather than just assigned to it.
1624 If the default expression is the symbol `global', that symbol will not
1625 be evaluated but the global value of the local variable will be used
1626 instead.
1627
1628 These variables can be used to set variables in the group parameters
1629 while still allowing them to affect operations done in other buffers.
1630 For example:
1631
1632 \(setq gnus-newsgroup-variables
1633 '(message-use-followup-to
1634 (gnus-visible-headers .
1635 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1636 ")
1637
1638 (eval-when-compile
1639 ;; Bind features so that require will believe that gnus-sum has
1640 ;; already been loaded (avoids infinite recursion)
1641 (let ((features (cons 'gnus-sum features)))
1642 (require 'gnus-art)))
1643
1644 ;; MIME stuff.
1645
1646 (defvar gnus-decode-encoded-word-methods
1647 '(mail-decode-encoded-word-string)
1648 "List of methods used to decode encoded words.
1649
1650 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1651 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1652 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1653 whose names match REGEXP.
1654
1655 For example:
1656 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1657 mail-decode-encoded-word-string
1658 (\"chinese\" . rfc1843-decode-string))")
1659
1660 (defvar gnus-decode-encoded-word-methods-cache nil)
1661
1662 (defun gnus-multi-decode-encoded-word-string (string)
1663 "Apply the functions from `gnus-encoded-word-methods' that match."
1664 (unless (and gnus-decode-encoded-word-methods-cache
1665 (eq gnus-newsgroup-name
1666 (car gnus-decode-encoded-word-methods-cache)))
1667 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1668 (dolist (method gnus-decode-encoded-word-methods)
1669 (if (symbolp method)
1670 (nconc gnus-decode-encoded-word-methods-cache (list method))
1671 (if (and gnus-newsgroup-name
1672 (string-match (car method) gnus-newsgroup-name))
1673 (nconc gnus-decode-encoded-word-methods-cache
1674 (list (cdr method)))))))
1675 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1676 (setq string (funcall method string))))
1677
1678 ;; Subject simplification.
1679
1680 (defun gnus-simplify-whitespace (str)
1681 "Remove excessive whitespace from STR."
1682 ;; Multiple spaces.
1683 (while (string-match "[ \t][ \t]+" str)
1684 (setq str (concat (substring str 0 (match-beginning 0))
1685 " "
1686 (substring str (match-end 0)))))
1687 ;; Leading spaces.
1688 (when (string-match "^[ \t]+" str)
1689 (setq str (substring str (match-end 0))))
1690 ;; Trailing spaces.
1691 (when (string-match "[ \t]+$" str)
1692 (setq str (substring str 0 (match-beginning 0))))
1693 str)
1694
1695 (defun gnus-simplify-all-whitespace (str)
1696 "Remove all whitespace from STR."
1697 (while (string-match "[ \t\n]+" str)
1698 (setq str (replace-match "" nil nil str)))
1699 str)
1700
1701 (defsubst gnus-simplify-subject-re (subject)
1702 "Remove \"Re:\" from subject lines."
1703 (if (string-match message-subject-re-regexp subject)
1704 (substring subject (match-end 0))
1705 subject))
1706
1707 (defun gnus-simplify-subject (subject &optional re-only)
1708 "Remove `Re:' and words in parentheses.
1709 If RE-ONLY is non-nil, strip leading `Re:'s only."
1710 (let ((case-fold-search t)) ;Ignore case.
1711 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1712 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1713 (setq subject (substring subject (match-end 0))))
1714 ;; Remove uninteresting prefixes.
1715 (when (and (not re-only)
1716 gnus-simplify-ignored-prefixes
1717 (string-match gnus-simplify-ignored-prefixes subject))
1718 (setq subject (substring subject (match-end 0))))
1719 ;; Remove words in parentheses from end.
1720 (unless re-only
1721 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1722 (setq subject (substring subject 0 (match-beginning 0)))))
1723 ;; Return subject string.
1724 subject))
1725
1726 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1727 ;; all whitespace.
1728 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1729 (goto-char (point-min))
1730 (while (re-search-forward regexp nil t)
1731 (replace-match (or newtext ""))))
1732
1733 (defun gnus-simplify-buffer-fuzzy (regexp)
1734 "Simplify string in the buffer fuzzily.
1735 The string in the accessible portion of the current buffer is simplified.
1736 It is assumed to be a single-line subject.
1737 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1738 matter is removed. Additional things can be deleted by setting
1739 `gnus-simplify-subject-fuzzy-regexp'."
1740 (let ((case-fold-search t)
1741 (modified-tick))
1742 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1743
1744 (while (not (eq modified-tick (buffer-modified-tick)))
1745 (setq modified-tick (buffer-modified-tick))
1746 (cond
1747 ((listp regexp)
1748 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1749 (regexp
1750 (gnus-simplify-buffer-fuzzy-step regexp)))
1751 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1752 (gnus-simplify-buffer-fuzzy-step
1753 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1754 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1755
1756 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1757 (gnus-simplify-buffer-fuzzy-step " +" " ")
1758 (gnus-simplify-buffer-fuzzy-step " $")
1759 (gnus-simplify-buffer-fuzzy-step "^ +")))
1760
1761 (defun gnus-simplify-subject-fuzzy (subject)
1762 "Simplify a subject string fuzzily.
1763 See `gnus-simplify-buffer-fuzzy' for details."
1764 (save-excursion
1765 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1766 (gnus-set-work-buffer)
1767 (let ((case-fold-search t))
1768 ;; Remove uninteresting prefixes.
1769 (when (and gnus-simplify-ignored-prefixes
1770 (string-match gnus-simplify-ignored-prefixes subject))
1771 (setq subject (substring subject (match-end 0))))
1772 (insert subject)
1773 (inline (gnus-simplify-buffer-fuzzy regexp))
1774 (buffer-string)))))
1775
1776 (defsubst gnus-simplify-subject-fully (subject)
1777 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1778 (cond
1779 (gnus-simplify-subject-functions
1780 (gnus-map-function gnus-simplify-subject-functions subject))
1781 ((null gnus-summary-gather-subject-limit)
1782 (gnus-simplify-subject-re subject))
1783 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1784 (gnus-simplify-subject-fuzzy subject))
1785 ((numberp gnus-summary-gather-subject-limit)
1786 (truncate-string-to-width (gnus-simplify-subject-re subject)
1787 gnus-summary-gather-subject-limit))
1788 (t
1789 subject)))
1790
1791 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1792 "Check whether two subjects are equal.
1793 If optional argument SIMPLE-FIRST is t, first argument is already
1794 simplified."
1795 (cond
1796 ((null simple-first)
1797 (equal (gnus-simplify-subject-fully s1)
1798 (gnus-simplify-subject-fully s2)))
1799 (t
1800 (equal s1
1801 (gnus-simplify-subject-fully s2)))))
1802
1803 (defun gnus-summary-bubble-group ()
1804 "Increase the score of the current group.
1805 This is a handy function to add to `gnus-summary-exit-hook' to
1806 increase the score of each group you read."
1807 (gnus-group-add-score gnus-newsgroup-name))
1808
1809 \f
1810 ;;;
1811 ;;; Gnus summary mode
1812 ;;;
1813
1814 (put 'gnus-summary-mode 'mode-class 'special)
1815
1816 (defvar gnus-article-commands-menu)
1817
1818 ;; Non-orthogonal keys
1819
1820 (gnus-define-keys gnus-summary-mode-map
1821 " " gnus-summary-next-page
1822 "\177" gnus-summary-prev-page
1823 [delete] gnus-summary-prev-page
1824 [backspace] gnus-summary-prev-page
1825 "\r" gnus-summary-scroll-up
1826 "\M-\r" gnus-summary-scroll-down
1827 "n" gnus-summary-next-unread-article
1828 "p" gnus-summary-prev-unread-article
1829 "N" gnus-summary-next-article
1830 "P" gnus-summary-prev-article
1831 "\M-\C-n" gnus-summary-next-same-subject
1832 "\M-\C-p" gnus-summary-prev-same-subject
1833 "\M-n" gnus-summary-next-unread-subject
1834 "\M-p" gnus-summary-prev-unread-subject
1835 "." gnus-summary-first-unread-article
1836 "," gnus-summary-best-unread-article
1837 "\M-s" gnus-summary-search-article-forward
1838 "\M-r" gnus-summary-search-article-backward
1839 "\M-S" gnus-summary-repeat-search-article-forward
1840 "\M-R" gnus-summary-repeat-search-article-backward
1841 "<" gnus-summary-beginning-of-article
1842 ">" gnus-summary-end-of-article
1843 "j" gnus-summary-goto-article
1844 "^" gnus-summary-refer-parent-article
1845 "\M-^" gnus-summary-refer-article
1846 "u" gnus-summary-tick-article-forward
1847 "!" gnus-summary-tick-article-forward
1848 "U" gnus-summary-tick-article-backward
1849 "d" gnus-summary-mark-as-read-forward
1850 "D" gnus-summary-mark-as-read-backward
1851 "E" gnus-summary-mark-as-expirable
1852 "\M-u" gnus-summary-clear-mark-forward
1853 "\M-U" gnus-summary-clear-mark-backward
1854 "k" gnus-summary-kill-same-subject-and-select
1855 "\C-k" gnus-summary-kill-same-subject
1856 "\M-\C-k" gnus-summary-kill-thread
1857 "\M-\C-l" gnus-summary-lower-thread
1858 "e" gnus-summary-edit-article
1859 "#" gnus-summary-mark-as-processable
1860 "\M-#" gnus-summary-unmark-as-processable
1861 "\M-\C-t" gnus-summary-toggle-threads
1862 "\M-\C-s" gnus-summary-show-thread
1863 "\M-\C-h" gnus-summary-hide-thread
1864 "\M-\C-f" gnus-summary-next-thread
1865 "\M-\C-b" gnus-summary-prev-thread
1866 [(meta down)] gnus-summary-next-thread
1867 [(meta up)] gnus-summary-prev-thread
1868 "\M-\C-u" gnus-summary-up-thread
1869 "\M-\C-d" gnus-summary-down-thread
1870 "&" gnus-summary-execute-command
1871 "c" gnus-summary-catchup-and-exit
1872 "\C-w" gnus-summary-mark-region-as-read
1873 "\C-t" gnus-summary-toggle-truncation
1874 "?" gnus-summary-mark-as-dormant
1875 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1876 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1877 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1878 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1879 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1880 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1881 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1882 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1883 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1884 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1885 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1886 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1887 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1888 "=" gnus-summary-expand-window
1889 "\C-x\C-s" gnus-summary-reselect-current-group
1890 "\M-g" gnus-summary-rescan-group
1891 "\C-c\C-r" gnus-summary-caesar-message
1892 "f" gnus-summary-followup
1893 "F" gnus-summary-followup-with-original
1894 "C" gnus-summary-cancel-article
1895 "r" gnus-summary-reply
1896 "R" gnus-summary-reply-with-original
1897 "\C-c\C-f" gnus-summary-mail-forward
1898 "o" gnus-summary-save-article
1899 "\C-o" gnus-summary-save-article-mail
1900 "|" gnus-summary-pipe-output
1901 "\M-k" gnus-summary-edit-local-kill
1902 "\M-K" gnus-summary-edit-global-kill
1903 ;; "V" gnus-version
1904 "\C-c\C-d" gnus-summary-describe-group
1905 "q" gnus-summary-exit
1906 "Q" gnus-summary-exit-no-update
1907 "\C-c\C-i" gnus-info-find-node
1908 gnus-mouse-2 gnus-mouse-pick-article
1909 [follow-link] mouse-face
1910 "m" gnus-summary-mail-other-window
1911 "a" gnus-summary-post-news
1912 "x" gnus-summary-limit-to-unread
1913 "s" gnus-summary-isearch-article
1914 "\t" gnus-summary-widget-forward
1915 [backtab] gnus-summary-widget-backward
1916 "t" gnus-summary-toggle-header
1917 "g" gnus-summary-show-article
1918 "l" gnus-summary-goto-last-article
1919 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1920 "\C-d" gnus-summary-enter-digest-group
1921 "\M-\C-d" gnus-summary-read-document
1922 "\M-\C-e" gnus-summary-edit-parameters
1923 "\M-\C-a" gnus-summary-customize-parameters
1924 "\C-c\C-b" gnus-bug
1925 "*" gnus-cache-enter-article
1926 "\M-*" gnus-cache-remove-article
1927 "\M-&" gnus-summary-universal-argument
1928 "\C-l" gnus-recenter
1929 "I" gnus-summary-increase-score
1930 "L" gnus-summary-lower-score
1931 "\M-i" gnus-symbolic-argument
1932 "h" gnus-summary-select-article-buffer
1933
1934 "b" gnus-article-view-part
1935 "\M-t" gnus-summary-toggle-display-buttonized
1936
1937 "V" gnus-summary-score-map
1938 "X" gnus-uu-extract-map
1939 "S" gnus-summary-send-map)
1940
1941 ;; Sort of orthogonal keymap
1942 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1943 "t" gnus-summary-tick-article-forward
1944 "!" gnus-summary-tick-article-forward
1945 "d" gnus-summary-mark-as-read-forward
1946 "r" gnus-summary-mark-as-read-forward
1947 "c" gnus-summary-clear-mark-forward
1948 " " gnus-summary-clear-mark-forward
1949 "e" gnus-summary-mark-as-expirable
1950 "x" gnus-summary-mark-as-expirable
1951 "?" gnus-summary-mark-as-dormant
1952 "b" gnus-summary-set-bookmark
1953 "B" gnus-summary-remove-bookmark
1954 "#" gnus-summary-mark-as-processable
1955 "\M-#" gnus-summary-unmark-as-processable
1956 "S" gnus-summary-limit-include-expunged
1957 "C" gnus-summary-catchup
1958 "H" gnus-summary-catchup-to-here
1959 "h" gnus-summary-catchup-from-here
1960 "\C-c" gnus-summary-catchup-all
1961 "k" gnus-summary-kill-same-subject-and-select
1962 "K" gnus-summary-kill-same-subject
1963 "P" gnus-uu-mark-map)
1964
1965 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1966 "c" gnus-summary-clear-above
1967 "u" gnus-summary-tick-above
1968 "m" gnus-summary-mark-above
1969 "k" gnus-summary-kill-below)
1970
1971 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1972 "/" gnus-summary-limit-to-subject
1973 "n" gnus-summary-limit-to-articles
1974 "b" gnus-summary-limit-to-bodies
1975 "h" gnus-summary-limit-to-headers
1976 "w" gnus-summary-pop-limit
1977 "s" gnus-summary-limit-to-subject
1978 "a" gnus-summary-limit-to-author
1979 "u" gnus-summary-limit-to-unread
1980 "m" gnus-summary-limit-to-marks
1981 "M" gnus-summary-limit-exclude-marks
1982 "v" gnus-summary-limit-to-score
1983 "*" gnus-summary-limit-include-cached
1984 "D" gnus-summary-limit-include-dormant
1985 "T" gnus-summary-limit-include-thread
1986 "d" gnus-summary-limit-exclude-dormant
1987 "t" gnus-summary-limit-to-age
1988 "." gnus-summary-limit-to-unseen
1989 "x" gnus-summary-limit-to-extra
1990 "p" gnus-summary-limit-to-display-predicate
1991 "E" gnus-summary-limit-include-expunged
1992 "c" gnus-summary-limit-exclude-childless-dormant
1993 "C" gnus-summary-limit-mark-excluded-as-read
1994 "o" gnus-summary-insert-old-articles
1995 "N" gnus-summary-insert-new-articles
1996 "S" gnus-summary-limit-to-singletons
1997 "r" gnus-summary-limit-to-replied
1998 "R" gnus-summary-limit-to-recipient
1999 "A" gnus-summary-limit-to-address)
2000
2001 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2002 "n" gnus-summary-next-unread-article
2003 "p" gnus-summary-prev-unread-article
2004 "N" gnus-summary-next-article
2005 "P" gnus-summary-prev-article
2006 "\C-n" gnus-summary-next-same-subject
2007 "\C-p" gnus-summary-prev-same-subject
2008 "\M-n" gnus-summary-next-unread-subject
2009 "\M-p" gnus-summary-prev-unread-subject
2010 "f" gnus-summary-first-unread-article
2011 "b" gnus-summary-best-unread-article
2012 "j" gnus-summary-goto-article
2013 "g" gnus-summary-goto-subject
2014 "l" gnus-summary-goto-last-article
2015 "o" gnus-summary-pop-article)
2016
2017 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2018 "k" gnus-summary-kill-thread
2019 "E" gnus-summary-expire-thread
2020 "l" gnus-summary-lower-thread
2021 "i" gnus-summary-raise-thread
2022 "T" gnus-summary-toggle-threads
2023 "t" gnus-summary-rethread-current
2024 "^" gnus-summary-reparent-thread
2025 "\M-^" gnus-summary-reparent-children
2026 "s" gnus-summary-show-thread
2027 "S" gnus-summary-show-all-threads
2028 "h" gnus-summary-hide-thread
2029 "H" gnus-summary-hide-all-threads
2030 "n" gnus-summary-next-thread
2031 "p" gnus-summary-prev-thread
2032 "u" gnus-summary-up-thread
2033 "o" gnus-summary-top-thread
2034 "d" gnus-summary-down-thread
2035 "#" gnus-uu-mark-thread
2036 "\M-#" gnus-uu-unmark-thread)
2037
2038 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2039 "g" gnus-summary-prepare
2040 "c" gnus-summary-insert-cached-articles
2041 "d" gnus-summary-insert-dormant-articles
2042 "t" gnus-summary-insert-ticked-articles)
2043
2044 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2045 "c" gnus-summary-catchup-and-exit
2046 "C" gnus-summary-catchup-all-and-exit
2047 "E" gnus-summary-exit-no-update
2048 "Q" gnus-summary-exit
2049 "Z" gnus-summary-exit
2050 "n" gnus-summary-catchup-and-goto-next-group
2051 "p" gnus-summary-catchup-and-goto-prev-group
2052 "R" gnus-summary-reselect-current-group
2053 "G" gnus-summary-rescan-group
2054 "N" gnus-summary-next-group
2055 "s" gnus-summary-save-newsrc
2056 "P" gnus-summary-prev-group)
2057
2058 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2059 " " gnus-summary-next-page
2060 "n" gnus-summary-next-page
2061 "\177" gnus-summary-prev-page
2062 [delete] gnus-summary-prev-page
2063 "p" gnus-summary-prev-page
2064 "\r" gnus-summary-scroll-up
2065 "\M-\r" gnus-summary-scroll-down
2066 "<" gnus-summary-beginning-of-article
2067 ">" gnus-summary-end-of-article
2068 "b" gnus-summary-beginning-of-article
2069 "e" gnus-summary-end-of-article
2070 "^" gnus-summary-refer-parent-article
2071 "r" gnus-summary-refer-parent-article
2072 "C" gnus-summary-show-complete-article
2073 "D" gnus-summary-enter-digest-group
2074 "R" gnus-summary-refer-references
2075 "T" gnus-summary-refer-thread
2076 "W" gnus-warp-to-article
2077 "g" gnus-summary-show-article
2078 "s" gnus-summary-isearch-article
2079 "\t" gnus-summary-widget-forward
2080 [backtab] gnus-summary-widget-backward
2081 "P" gnus-summary-print-article
2082 "S" gnus-sticky-article
2083 "M" gnus-mailing-list-insinuate
2084 "t" gnus-article-babel)
2085
2086 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2087 "b" gnus-article-add-buttons
2088 "B" gnus-article-add-buttons-to-head
2089 "o" gnus-article-treat-overstrike
2090 "e" gnus-article-emphasize
2091 "w" gnus-article-fill-cited-article
2092 "Q" gnus-article-fill-long-lines
2093 "L" gnus-article-toggle-truncate-lines
2094 "C" gnus-article-capitalize-sentences
2095 "c" gnus-article-remove-cr
2096 "q" gnus-article-de-quoted-unreadable
2097 "6" gnus-article-de-base64-unreadable
2098 "Z" gnus-article-decode-HZ
2099 "A" gnus-article-treat-ansi-sequences
2100 "h" gnus-article-wash-html
2101 "u" gnus-article-unsplit-urls
2102 "s" gnus-summary-force-verify-and-decrypt
2103 "f" gnus-article-display-x-face
2104 "l" gnus-summary-stop-page-breaking
2105 "r" gnus-summary-caesar-message
2106 "m" gnus-summary-morse-message
2107 "t" gnus-summary-toggle-header
2108 "g" gnus-treat-smiley
2109 "v" gnus-summary-verbose-headers
2110 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2111 "p" gnus-article-verify-x-pgp-sig
2112 "d" gnus-article-treat-dumbquotes
2113 "U" gnus-article-treat-non-ascii
2114 "i" gnus-summary-idna-message)
2115
2116 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2117 ;; mnemonic: deuglif*Y*
2118 "u" gnus-article-outlook-unwrap-lines
2119 "a" gnus-article-outlook-repair-attribution
2120 "c" gnus-article-outlook-rearrange-citation
2121 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2122
2123 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2124 "a" gnus-article-hide
2125 "h" gnus-article-hide-headers
2126 "b" gnus-article-hide-boring-headers
2127 "s" gnus-article-hide-signature
2128 "c" gnus-article-hide-citation
2129 "C" gnus-article-hide-citation-in-followups
2130 "l" gnus-article-hide-list-identifiers
2131 "B" gnus-article-strip-banner
2132 "P" gnus-article-hide-pem
2133 "\C-c" gnus-article-hide-citation-maybe)
2134
2135 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2136 "a" gnus-article-highlight
2137 "h" gnus-article-highlight-headers
2138 "c" gnus-article-highlight-citation
2139 "s" gnus-article-highlight-signature)
2140
2141 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2142 "f" gnus-article-treat-fold-headers
2143 "u" gnus-article-treat-unfold-headers
2144 "n" gnus-article-treat-fold-newsgroups)
2145
2146 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2147 "x" gnus-article-display-x-face
2148 "d" gnus-article-display-face
2149 "s" gnus-treat-smiley
2150 "D" gnus-article-remove-images
2151 "W" gnus-article-show-images
2152 "f" gnus-treat-from-picon
2153 "m" gnus-treat-mail-picon
2154 "n" gnus-treat-newsgroups-picon
2155 "g" gnus-treat-from-gravatar
2156 "h" gnus-treat-mail-gravatar)
2157
2158 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2159 "w" gnus-article-decode-mime-words
2160 "c" gnus-article-decode-charset
2161 "v" gnus-mime-view-all-parts
2162 "b" gnus-article-view-part)
2163
2164 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2165 "z" gnus-article-date-ut
2166 "u" gnus-article-date-ut
2167 "l" gnus-article-date-local
2168 "p" gnus-article-date-english
2169 "e" gnus-article-date-lapsed
2170 "o" gnus-article-date-original
2171 "i" gnus-article-date-iso8601
2172 "s" gnus-article-date-user)
2173
2174 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2175 "t" gnus-article-remove-trailing-blank-lines
2176 "l" gnus-article-strip-leading-blank-lines
2177 "m" gnus-article-strip-multiple-blank-lines
2178 "a" gnus-article-strip-blank-lines
2179 "A" gnus-article-strip-all-blank-lines
2180 "s" gnus-article-strip-leading-space
2181 "e" gnus-article-strip-trailing-space
2182 "w" gnus-article-remove-leading-whitespace)
2183
2184 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2185 "v" gnus-version
2186 "d" gnus-summary-describe-group
2187 "h" gnus-summary-describe-briefly
2188 "i" gnus-info-find-node)
2189
2190 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2191 "e" gnus-summary-expire-articles
2192 "\M-\C-e" gnus-summary-expire-articles-now
2193 "\177" gnus-summary-delete-article
2194 [delete] gnus-summary-delete-article
2195 [backspace] gnus-summary-delete-article
2196 "m" gnus-summary-move-article
2197 "r" gnus-summary-respool-article
2198 "w" gnus-summary-edit-article
2199 "c" gnus-summary-copy-article
2200 "B" gnus-summary-crosspost-article
2201 "q" gnus-summary-respool-query
2202 "t" gnus-summary-respool-trace
2203 "i" gnus-summary-import-article
2204 "I" gnus-summary-create-article
2205 "p" gnus-summary-article-posted-p)
2206
2207 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2208 "o" gnus-summary-save-article
2209 "m" gnus-summary-save-article-mail
2210 "F" gnus-summary-write-article-file
2211 "r" gnus-summary-save-article-rmail
2212 "f" gnus-summary-save-article-file
2213 "b" gnus-summary-save-article-body-file
2214 "B" gnus-summary-write-article-body-file
2215 "h" gnus-summary-save-article-folder
2216 "v" gnus-summary-save-article-vm
2217 "p" gnus-summary-pipe-output
2218 "P" gnus-summary-muttprint)
2219
2220 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2221 "b" gnus-summary-display-buttonized
2222 "m" gnus-summary-repair-multipart
2223 "v" gnus-article-view-part
2224 "o" gnus-article-save-part
2225 "O" gnus-article-save-part-and-strip
2226 "r" gnus-article-replace-part
2227 "d" gnus-article-delete-part
2228 "t" gnus-article-view-part-as-type
2229 "j" gnus-article-jump-to-part
2230 "c" gnus-article-copy-part
2231 "C" gnus-article-view-part-as-charset
2232 "e" gnus-article-view-part-externally
2233 "H" gnus-article-browse-html-article
2234 "E" gnus-article-encrypt-body
2235 "i" gnus-article-inline-part
2236 "|" gnus-article-pipe-part)
2237
2238 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2239 "p" gnus-summary-mark-as-processable
2240 "u" gnus-summary-unmark-as-processable
2241 "U" gnus-summary-unmark-all-processable
2242 "v" gnus-uu-mark-over
2243 "s" gnus-uu-mark-series
2244 "r" gnus-uu-mark-region
2245 "g" gnus-uu-unmark-region
2246 "R" gnus-uu-mark-by-regexp
2247 "G" gnus-uu-unmark-by-regexp
2248 "t" gnus-uu-mark-thread
2249 "T" gnus-uu-unmark-thread
2250 "a" gnus-uu-mark-all
2251 "b" gnus-uu-mark-buffer
2252 "S" gnus-uu-mark-sparse
2253 "k" gnus-summary-kill-process-mark
2254 "y" gnus-summary-yank-process-mark
2255 "w" gnus-summary-save-process-mark
2256 "i" gnus-uu-invert-processable)
2257
2258 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2259 ;;"x" gnus-uu-extract-any
2260 "m" gnus-summary-save-parts
2261 "u" gnus-uu-decode-uu
2262 "U" gnus-uu-decode-uu-and-save
2263 "s" gnus-uu-decode-unshar
2264 "S" gnus-uu-decode-unshar-and-save
2265 "o" gnus-uu-decode-save
2266 "O" gnus-uu-decode-save
2267 "b" gnus-uu-decode-binhex
2268 "B" gnus-uu-decode-binhex
2269 "Y" gnus-uu-decode-yenc
2270 "p" gnus-uu-decode-postscript
2271 "P" gnus-uu-decode-postscript-and-save)
2272
2273 (gnus-define-keys
2274 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2275 "u" gnus-uu-decode-uu-view
2276 "U" gnus-uu-decode-uu-and-save-view
2277 "s" gnus-uu-decode-unshar-view
2278 "S" gnus-uu-decode-unshar-and-save-view
2279 "o" gnus-uu-decode-save-view
2280 "O" gnus-uu-decode-save-view
2281 "b" gnus-uu-decode-binhex-view
2282 "B" gnus-uu-decode-binhex-view
2283 "p" gnus-uu-decode-postscript-view
2284 "P" gnus-uu-decode-postscript-and-save-view)
2285
2286 (defvar gnus-article-post-menu nil)
2287
2288 (defconst gnus-summary-menu-maxlen 20)
2289
2290 (defun gnus-summary-menu-split (menu)
2291 ;; If we have lots of elements, divide them into groups of 20
2292 ;; and make a pane (or submenu) for each one.
2293 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2294 (let ((menu menu) sublists next
2295 (i 1))
2296 (while menu
2297 ;; Pull off the next gnus-summary-menu-maxlen elements
2298 ;; and make them the next element of sublist.
2299 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2300 (if next
2301 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2302 nil))
2303 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2304 (aref (car (last menu)) 0)) menu)
2305 sublists))
2306 (setq i (1+ i))
2307 (setq menu next))
2308 (nreverse sublists))
2309 ;; Few elements--put them all in one pane.
2310 menu))
2311
2312 (defun gnus-summary-make-menu-bar ()
2313 (gnus-turn-off-edit-menu 'summary)
2314
2315 (unless (boundp 'gnus-summary-misc-menu)
2316
2317 (easy-menu-define
2318 gnus-summary-kill-menu gnus-summary-mode-map ""
2319 (cons
2320 "Score"
2321 (nconc
2322 (list
2323 ["Customize" gnus-score-customize t])
2324 (gnus-make-score-map 'increase)
2325 (gnus-make-score-map 'lower)
2326 '(("Mark"
2327 ["Kill below" gnus-summary-kill-below t]
2328 ["Mark above" gnus-summary-mark-above t]
2329 ["Tick above" gnus-summary-tick-above t]
2330 ["Clear above" gnus-summary-clear-above t])
2331 ["Current score" gnus-summary-current-score t]
2332 ["Set score" gnus-summary-set-score t]
2333 ["Switch current score file..." gnus-score-change-score-file t]
2334 ["Set mark below..." gnus-score-set-mark-below t]
2335 ["Set expunge below..." gnus-score-set-expunge-below t]
2336 ["Edit current score file" gnus-score-edit-current-scores t]
2337 ["Edit score file..." gnus-score-edit-file t]
2338 ["Trace score" gnus-score-find-trace t]
2339 ["Find words" gnus-score-find-favourite-words t]
2340 ["Rescore buffer" gnus-summary-rescore t]
2341 ["Increase score..." gnus-summary-increase-score t]
2342 ["Lower score..." gnus-summary-lower-score t]))))
2343
2344 ;; Define both the Article menu in the summary buffer and the
2345 ;; equivalent Commands menu in the article buffer here for
2346 ;; consistency.
2347 (let ((innards
2348 `(("Hide"
2349 ["All" gnus-article-hide t]
2350 ["Headers" gnus-article-hide-headers t]
2351 ["Signature" gnus-article-hide-signature t]
2352 ["Citation" gnus-article-hide-citation t]
2353 ["List identifiers" gnus-article-hide-list-identifiers t]
2354 ["Banner" gnus-article-strip-banner t]
2355 ["Boring headers" gnus-article-hide-boring-headers t])
2356 ("Highlight"
2357 ["All" gnus-article-highlight t]
2358 ["Headers" gnus-article-highlight-headers t]
2359 ["Signature" gnus-article-highlight-signature t]
2360 ["Citation" gnus-article-highlight-citation t])
2361 ("MIME"
2362 ["Words" gnus-article-decode-mime-words t]
2363 ["Charset" gnus-article-decode-charset t]
2364 ["QP" gnus-article-de-quoted-unreadable t]
2365 ["Base64" gnus-article-de-base64-unreadable t]
2366 ["View MIME buttons" gnus-summary-display-buttonized t]
2367 ["View all" gnus-mime-view-all-parts t]
2368 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2369 ["Encrypt body" gnus-article-encrypt-body
2370 :active (not (gnus-group-read-only-p))
2371 ,@(if (featurep 'xemacs) nil
2372 '(:help "Encrypt the message body on disk"))]
2373 ["Extract all parts..." gnus-summary-save-parts t]
2374 ("Multipart"
2375 ["Repair multipart" gnus-summary-repair-multipart t]
2376 ["Pipe part..." gnus-article-pipe-part t]
2377 ["Inline part" gnus-article-inline-part t]
2378 ["View part as type..." gnus-article-view-part-as-type t]
2379 ["Encrypt body" gnus-article-encrypt-body
2380 :active (not (gnus-group-read-only-p))
2381 ,@(if (featurep 'xemacs) nil
2382 '(:help "Encrypt the message body on disk"))]
2383 ["View part externally" gnus-article-view-part-externally t]
2384 ["View HTML parts in browser" gnus-article-browse-html-article t]
2385 ["View part with charset..." gnus-article-view-part-as-charset t]
2386 ["Copy part" gnus-article-copy-part t]
2387 ["Save part..." gnus-article-save-part t]
2388 ["View part" gnus-article-view-part t]))
2389 ("Date"
2390 ["Local" gnus-article-date-local t]
2391 ["ISO8601" gnus-article-date-iso8601 t]
2392 ["UT" gnus-article-date-ut t]
2393 ["Original" gnus-article-date-original t]
2394 ["Lapsed" gnus-article-date-lapsed t]
2395 ["User-defined" gnus-article-date-user t])
2396 ("Display"
2397 ["Remove images" gnus-article-remove-images t]
2398 ["Toggle smiley" gnus-treat-smiley t]
2399 ["Show X-Face" gnus-article-display-x-face t]
2400 ["Show picons in From" gnus-treat-from-picon t]
2401 ["Show picons in mail headers" gnus-treat-mail-picon t]
2402 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2403 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2404 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2405 ("View as different encoding"
2406 ,@(gnus-summary-menu-split
2407 (mapcar
2408 (lambda (cs)
2409 ;; Since easymenu under Emacs doesn't allow
2410 ;; lambda forms for menu commands, we should
2411 ;; provide intern'ed function symbols.
2412 (let ((command (intern (format "\
2413 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2414 (fset command
2415 `(lambda ()
2416 (interactive)
2417 (let ((gnus-summary-show-article-charset-alist
2418 '((1 . ,cs))))
2419 (gnus-summary-show-article 1))))
2420 `[,(symbol-name cs) ,command t]))
2421 (sort (if (fboundp 'coding-system-list)
2422 (coding-system-list)
2423 (mapcar 'car mm-mime-mule-charset-alist))
2424 'string<)))))
2425 ("Washing"
2426 ("Remove Blanks"
2427 ["Leading" gnus-article-strip-leading-blank-lines t]
2428 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2429 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2430 ["All of the above" gnus-article-strip-blank-lines t]
2431 ["All" gnus-article-strip-all-blank-lines t]
2432 ["Leading space" gnus-article-strip-leading-space t]
2433 ["Trailing space" gnus-article-strip-trailing-space t]
2434 ["Leading space in headers"
2435 gnus-article-remove-leading-whitespace t])
2436 ["Overstrike" gnus-article-treat-overstrike t]
2437 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2438 ["Non-ASCII" gnus-article-treat-non-ascii t]
2439 ["Emphasis" gnus-article-emphasize t]
2440 ["Word wrap" gnus-article-fill-cited-article t]
2441 ["Fill long lines" gnus-article-fill-long-lines t]
2442 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2443 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2444 ["Remove CR" gnus-article-remove-cr t]
2445 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2446 ["Base64" gnus-article-de-base64-unreadable t]
2447 ["Rot 13" gnus-summary-caesar-message
2448 ,@(if (featurep 'xemacs) '(t)
2449 '(:help "\"Caesar rotate\" article by 13"))]
2450 ["De-IDNA" gnus-summary-idna-message t]
2451 ["Morse decode" gnus-summary-morse-message t]
2452 ["Unix pipe..." gnus-summary-pipe-message t]
2453 ["Add buttons" gnus-article-add-buttons t]
2454 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2455 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2456 ["Verbose header" gnus-summary-verbose-headers t]
2457 ["Toggle header" gnus-summary-toggle-header t]
2458 ["Unfold headers" gnus-article-treat-unfold-headers t]
2459 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2460 ["Html" gnus-article-wash-html t]
2461 ["Unsplit URLs" gnus-article-unsplit-urls t]
2462 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2463 ["Decode HZ" gnus-article-decode-HZ t]
2464 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2465 ("(Outlook) Deuglify"
2466 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2467 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2468 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2469 ["Full (Outlook) deuglify"
2470 gnus-article-outlook-deuglify-article t])
2471 )
2472 ("Output"
2473 ["Save in default format..." gnus-summary-save-article
2474 ,@(if (featurep 'xemacs) '(t)
2475 '(:help "Save article using default method"))]
2476 ["Save in file..." gnus-summary-save-article-file
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Save article in file"))]
2479 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2480 ["Save in MH folder..." gnus-summary-save-article-folder t]
2481 ["Save in VM folder..." gnus-summary-save-article-vm t]
2482 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2483 ["Save body in file..." gnus-summary-save-article-body-file t]
2484 ["Pipe through a filter..." gnus-summary-pipe-output t]
2485 ["Print with Muttprint..." gnus-summary-muttprint t]
2486 ["Print" gnus-summary-print-article
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Generate and print a PostScript image"))])
2489 ("Copy, move,... (Backend)"
2490 ,@(if (featurep 'xemacs) nil
2491 '(:help "Copying, moving, expiring articles..."))
2492 ["Respool article..." gnus-summary-respool-article t]
2493 ["Move article..." gnus-summary-move-article
2494 (gnus-check-backend-function
2495 'request-move-article gnus-newsgroup-name)]
2496 ["Copy article..." gnus-summary-copy-article t]
2497 ["Crosspost article..." gnus-summary-crosspost-article
2498 (gnus-check-backend-function
2499 'request-replace-article gnus-newsgroup-name)]
2500 ["Import file..." gnus-summary-import-article
2501 (gnus-check-backend-function
2502 'request-accept-article gnus-newsgroup-name)]
2503 ["Create article..." gnus-summary-create-article
2504 (gnus-check-backend-function
2505 'request-accept-article gnus-newsgroup-name)]
2506 ["Check if posted" gnus-summary-article-posted-p t]
2507 ["Edit article" gnus-summary-edit-article
2508 (not (gnus-group-read-only-p))]
2509 ["Delete article" gnus-summary-delete-article
2510 (gnus-check-backend-function
2511 'request-expire-articles gnus-newsgroup-name)]
2512 ["Query respool" gnus-summary-respool-query t]
2513 ["Trace respool" gnus-summary-respool-trace t]
2514 ["Delete expirable articles" gnus-summary-expire-articles-now
2515 (gnus-check-backend-function
2516 'request-expire-articles gnus-newsgroup-name)])
2517 ("Extract"
2518 ["Uudecode" gnus-uu-decode-uu
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Decode uuencoded article(s)"))]
2521 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2522 ["Unshar" gnus-uu-decode-unshar t]
2523 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2524 ["Save" gnus-uu-decode-save t]
2525 ["Binhex" gnus-uu-decode-binhex t]
2526 ["PostScript" gnus-uu-decode-postscript t]
2527 ["All MIME parts" gnus-summary-save-parts t])
2528 ("Cache"
2529 ["Enter article" gnus-cache-enter-article t]
2530 ["Remove article" gnus-cache-remove-article t])
2531 ["Translate" gnus-article-babel t]
2532 ["Select article buffer" gnus-summary-select-article-buffer t]
2533 ["Make article buffer sticky" gnus-sticky-article t]
2534 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2535 ["Isearch article..." gnus-summary-isearch-article t]
2536 ["Beginning of the article" gnus-summary-beginning-of-article t]
2537 ["End of the article" gnus-summary-end-of-article t]
2538 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2539 ["Fetch referenced articles" gnus-summary-refer-references t]
2540 ["Fetch current thread" gnus-summary-refer-thread t]
2541 ["Fetch article with id..." gnus-summary-refer-article t]
2542 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2543 ["Redisplay" gnus-summary-show-article t]
2544 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2545 (easy-menu-define
2546 gnus-summary-article-menu gnus-summary-mode-map ""
2547 (cons "Article" innards))
2548
2549 (if (not (keymapp gnus-summary-article-menu))
2550 (easy-menu-define
2551 gnus-article-commands-menu gnus-article-mode-map ""
2552 (cons "Commands" innards))
2553 ;; in Emacs, don't share menu.
2554 (setq gnus-article-commands-menu
2555 (copy-keymap gnus-summary-article-menu))
2556 (define-key gnus-article-mode-map [menu-bar commands]
2557 (cons "Commands" gnus-article-commands-menu))))
2558
2559 (easy-menu-define
2560 gnus-summary-thread-menu gnus-summary-mode-map ""
2561 '("Threads"
2562 ["Find all messages in thread" gnus-summary-refer-thread t]
2563 ["Toggle threading" gnus-summary-toggle-threads t]
2564 ["Hide threads" gnus-summary-hide-all-threads t]
2565 ["Show threads" gnus-summary-show-all-threads t]
2566 ["Hide thread" gnus-summary-hide-thread t]
2567 ["Show thread" gnus-summary-show-thread t]
2568 ["Go to next thread" gnus-summary-next-thread t]
2569 ["Go to previous thread" gnus-summary-prev-thread t]
2570 ["Go down thread" gnus-summary-down-thread t]
2571 ["Go up thread" gnus-summary-up-thread t]
2572 ["Top of thread" gnus-summary-top-thread t]
2573 ["Mark thread as read" gnus-summary-kill-thread t]
2574 ["Mark thread as expired" gnus-summary-expire-thread t]
2575 ["Lower thread score" gnus-summary-lower-thread t]
2576 ["Raise thread score" gnus-summary-raise-thread t]
2577 ["Rethread current" gnus-summary-rethread-current t]))
2578
2579 (easy-menu-define
2580 gnus-summary-post-menu gnus-summary-mode-map ""
2581 `("Post"
2582 ["Send a message (mail or news)" gnus-summary-post-news
2583 ,@(if (featurep 'xemacs) '(t)
2584 '(:help "Compose a new message (mail or news)"))]
2585 ["Followup" gnus-summary-followup
2586 ,@(if (featurep 'xemacs) '(t)
2587 '(:help "Post followup to this article"))]
2588 ["Followup and yank" gnus-summary-followup-with-original
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Post followup to this article, quoting its contents"))]
2591 ["Supersede article" gnus-summary-supersede-article t]
2592 ["Cancel article" gnus-summary-cancel-article
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Cancel an article you posted"))]
2595 ["Reply" gnus-summary-reply t]
2596 ["Reply and yank" gnus-summary-reply-with-original t]
2597 ["Wide reply" gnus-summary-wide-reply t]
2598 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2599 ,@(if (featurep 'xemacs) '(t)
2600 '(:help "Mail a reply, quoting this article"))]
2601 ["Very wide reply" gnus-summary-very-wide-reply t]
2602 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2603 ,@(if (featurep 'xemacs) '(t)
2604 '(:help "Mail a very wide reply, quoting this article"))]
2605 ["Mail forward" gnus-summary-mail-forward t]
2606 ["Post forward" gnus-summary-post-forward t]
2607 ["Digest and mail" gnus-uu-digest-mail-forward t]
2608 ["Digest and post" gnus-uu-digest-post-forward t]
2609 ["Resend message" gnus-summary-resend-message t]
2610 ["Resend message edit" gnus-summary-resend-message-edit t]
2611 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2612 ["Send a mail" gnus-summary-mail-other-window t]
2613 ["Create a local message" gnus-summary-news-other-window t]
2614 ["Uuencode and post" gnus-uu-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Post a uuencoded article"))]
2617 ["Followup via news" gnus-summary-followup-to-mail t]
2618 ["Followup via news and yank"
2619 gnus-summary-followup-to-mail-with-original t]
2620 ["Strip signature on reply"
2621 (lambda ()
2622 (interactive)
2623 (if (not (memq message-cite-function
2624 '(message-cite-original-without-signature
2625 message-cite-original)))
2626 ;; Stupid workaround for XEmacs not honoring :visible.
2627 (message "Can't toggle this value of `message-cite-function'")
2628 (setq message-cite-function
2629 (if (eq message-cite-function
2630 'message-cite-original-without-signature)
2631 'message-cite-original
2632 'message-cite-original-without-signature))))
2633 ;; XEmacs barfs on :visible.
2634 ,@(if (featurep 'xemacs) nil
2635 '(:visible (memq message-cite-function
2636 '(message-cite-original-without-signature
2637 message-cite-original))))
2638 :style toggle
2639 :selected (eq message-cite-function
2640 'message-cite-original-without-signature)
2641 ,@(if (featurep 'xemacs) nil
2642 '(:help "Strip signature from cited article when replying."))]
2643 ;;("Draft"
2644 ;;["Send" gnus-summary-send-draft t]
2645 ;;["Send bounced" gnus-resend-bounced-mail t])
2646 ))
2647
2648 (cond
2649 ((not (keymapp gnus-summary-post-menu))
2650 (setq gnus-article-post-menu gnus-summary-post-menu))
2651 ((not gnus-article-post-menu)
2652 ;; Don't share post menu.
2653 (setq gnus-article-post-menu
2654 (copy-keymap gnus-summary-post-menu))))
2655 (define-key gnus-article-mode-map [menu-bar post]
2656 (cons "Post" gnus-article-post-menu))
2657
2658 (easy-menu-define
2659 gnus-summary-misc-menu gnus-summary-mode-map ""
2660 `("Gnus"
2661 ("Mark Read"
2662 ["Mark as read" gnus-summary-mark-as-read-forward t]
2663 ["Mark same subject and select"
2664 gnus-summary-kill-same-subject-and-select t]
2665 ["Mark same subject" gnus-summary-kill-same-subject t]
2666 ["Catchup" gnus-summary-catchup
2667 ,@(if (featurep 'xemacs) '(t)
2668 '(:help "Mark unread articles in this group as read"))]
2669 ["Catchup all" gnus-summary-catchup-all t]
2670 ["Catchup to here" gnus-summary-catchup-to-here t]
2671 ["Catchup from here" gnus-summary-catchup-from-here t]
2672 ["Catchup region" gnus-summary-mark-region-as-read
2673 (gnus-mark-active-p)]
2674 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2675 ("Mark Various"
2676 ["Tick" gnus-summary-tick-article-forward t]
2677 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2678 ["Remove marks" gnus-summary-clear-mark-forward t]
2679 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2680 ["Set bookmark" gnus-summary-set-bookmark t]
2681 ["Remove bookmark" gnus-summary-remove-bookmark t])
2682 ("Limit to"
2683 ["Marks..." gnus-summary-limit-to-marks t]
2684 ["Subject..." gnus-summary-limit-to-subject t]
2685 ["Author..." gnus-summary-limit-to-author t]
2686 ["Recipient..." gnus-summary-limit-to-recipient t]
2687 ["Address..." gnus-summary-limit-to-address t]
2688 ["Age..." gnus-summary-limit-to-age t]
2689 ["Extra..." gnus-summary-limit-to-extra t]
2690 ["Score..." gnus-summary-limit-to-score t]
2691 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2692 ["Unread" gnus-summary-limit-to-unread t]
2693 ["Unseen" gnus-summary-limit-to-unseen t]
2694 ["Singletons" gnus-summary-limit-to-singletons t]
2695 ["Replied" gnus-summary-limit-to-replied t]
2696 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2697 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2698 ["Pop limit" gnus-summary-pop-limit t]
2699 ["Show dormant" gnus-summary-limit-include-dormant t]
2700 ["Hide childless dormant"
2701 gnus-summary-limit-exclude-childless-dormant t]
2702 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2703 ["Hide marked" gnus-summary-limit-exclude-marks t]
2704 ["Show expunged" gnus-summary-limit-include-expunged t])
2705 ("Process Mark"
2706 ["Set mark" gnus-summary-mark-as-processable t]
2707 ["Remove mark" gnus-summary-unmark-as-processable t]
2708 ["Remove all marks" gnus-summary-unmark-all-processable t]
2709 ["Invert marks" gnus-uu-invert-processable t]
2710 ["Mark above" gnus-uu-mark-over t]
2711 ["Mark series" gnus-uu-mark-series t]
2712 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2713 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2714 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2715 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2716 ["Mark all" gnus-uu-mark-all t]
2717 ["Mark buffer" gnus-uu-mark-buffer t]
2718 ["Mark sparse" gnus-uu-mark-sparse t]
2719 ["Mark thread" gnus-uu-mark-thread t]
2720 ["Unmark thread" gnus-uu-unmark-thread t]
2721 ("Process Mark Sets"
2722 ["Kill" gnus-summary-kill-process-mark t]
2723 ["Yank" gnus-summary-yank-process-mark
2724 gnus-newsgroup-process-stack]
2725 ["Save" gnus-summary-save-process-mark t]
2726 ["Run command on marked..." gnus-summary-universal-argument t]))
2727 ("Registry Marks")
2728 ("Scroll article"
2729 ["Page forward" gnus-summary-next-page
2730 ,@(if (featurep 'xemacs) '(t)
2731 '(:help "Show next page of article"))]
2732 ["Page backward" gnus-summary-prev-page
2733 ,@(if (featurep 'xemacs) '(t)
2734 '(:help "Show previous page of article"))]
2735 ["Line forward" gnus-summary-scroll-up t])
2736 ("Move"
2737 ["Next unread article" gnus-summary-next-unread-article t]
2738 ["Previous unread article" gnus-summary-prev-unread-article t]
2739 ["Next article" gnus-summary-next-article t]
2740 ["Previous article" gnus-summary-prev-article t]
2741 ["Next unread subject" gnus-summary-next-unread-subject t]
2742 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2743 ["Next article same subject" gnus-summary-next-same-subject t]
2744 ["Previous article same subject" gnus-summary-prev-same-subject t]
2745 ["First unread article" gnus-summary-first-unread-article t]
2746 ["Best unread article" gnus-summary-best-unread-article t]
2747 ["Go to subject number..." gnus-summary-goto-subject t]
2748 ["Go to article number..." gnus-summary-goto-article t]
2749 ["Go to the last article" gnus-summary-goto-last-article t]
2750 ["Pop article off history" gnus-summary-pop-article t])
2751 ("Sort"
2752 ["Sort by number" gnus-summary-sort-by-number t]
2753 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2754 ["Sort by author" gnus-summary-sort-by-author t]
2755 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2756 ["Sort by subject" gnus-summary-sort-by-subject t]
2757 ["Sort by date" gnus-summary-sort-by-date t]
2758 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2759 ["Sort by score" gnus-summary-sort-by-score t]
2760 ["Sort by lines" gnus-summary-sort-by-lines t]
2761 ["Sort by characters" gnus-summary-sort-by-chars t]
2762 ["Randomize" gnus-summary-sort-by-random t]
2763 ["Original sort" gnus-summary-sort-by-original t])
2764 ("Help"
2765 ["Describe group" gnus-summary-describe-group t]
2766 ["Read manual" gnus-info-find-node t])
2767 ("Modes"
2768 ["Pick and read" gnus-pick-mode t]
2769 ["Binary" gnus-binary-mode t])
2770 ("Regeneration"
2771 ["Regenerate" gnus-summary-prepare t]
2772 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2773 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2774 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2775 ["Toggle threading" gnus-summary-toggle-threads t])
2776 ["See old articles" gnus-summary-insert-old-articles t]
2777 ["See new articles" gnus-summary-insert-new-articles t]
2778 ["Filter articles..." gnus-summary-execute-command t]
2779 ["Run command on articles..." gnus-summary-universal-argument t]
2780 ["Search articles forward..." gnus-summary-search-article-forward t]
2781 ["Search articles backward..." gnus-summary-search-article-backward t]
2782 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2783 ["Expand window" gnus-summary-expand-window t]
2784 ["Expire expirable articles" gnus-summary-expire-articles
2785 (gnus-check-backend-function
2786 'request-expire-articles gnus-newsgroup-name)]
2787 ["Edit local kill file" gnus-summary-edit-local-kill t]
2788 ["Edit main kill file" gnus-summary-edit-global-kill t]
2789 ["Edit group parameters" gnus-summary-edit-parameters t]
2790 ["Customize group parameters" gnus-summary-customize-parameters t]
2791 ["Send a bug report" gnus-bug t]
2792 ("Exit"
2793 ["Catchup and exit" gnus-summary-catchup-and-exit
2794 ,@(if (featurep 'xemacs) '(t)
2795 '(:help "Mark unread articles in this group as read, then exit"))]
2796 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2797 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2798 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2799 ["Exit group" gnus-summary-exit
2800 ,@(if (featurep 'xemacs) '(t)
2801 '(:help "Exit current group, return to group selection mode"))]
2802 ["Exit group without updating" gnus-summary-exit-no-update t]
2803 ["Exit and goto next group" gnus-summary-next-group t]
2804 ["Exit and goto prev group" gnus-summary-prev-group t]
2805 ["Reselect group" gnus-summary-reselect-current-group t]
2806 ["Rescan group" gnus-summary-rescan-group t]
2807 ["Update dribble" gnus-summary-save-newsrc t])))
2808
2809 (gnus-run-hooks 'gnus-summary-menu-hook)))
2810
2811 (defvar gnus-summary-tool-bar-map nil)
2812
2813 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2814 ;; affect _new_ message buffers. We might add a function that walks thru all
2815 ;; summary-mode buffers and force the update.
2816 (defun gnus-summary-tool-bar-update (&optional symbol value)
2817 "Update summary mode toolbar.
2818 Setter function for custom variables."
2819 (setq-default gnus-summary-tool-bar-map nil)
2820 (when symbol
2821 ;; When used as ":set" function:
2822 (set-default symbol value))
2823 (when (gnus-buffer-live-p gnus-summary-buffer)
2824 (with-current-buffer gnus-summary-buffer
2825 (gnus-summary-make-tool-bar))))
2826
2827 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2828 'gnus-summary-tool-bar-gnome
2829 'gnus-summary-tool-bar-retro)
2830 "Specifies the Gnus summary tool bar.
2831
2832 It can be either a list or a symbol referring to a list. See
2833 `gmm-tool-bar-from-list' for the format of the list. The
2834 default key map is `gnus-summary-mode-map'.
2835
2836 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2837 `gnus-summary-tool-bar-retro'."
2838 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2839 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2840 (repeat :tag "User defined list" gmm-tool-bar-item)
2841 (symbol))
2842 :version "23.1" ;; No Gnus
2843 :initialize 'custom-initialize-default
2844 :set 'gnus-summary-tool-bar-update
2845 :group 'gnus-summary)
2846
2847 (defcustom gnus-summary-tool-bar-gnome
2848 '((gnus-summary-post-news "mail/compose" nil)
2849 (gnus-summary-insert-new-articles "mail/inbox" nil
2850 :visible (or (not gnus-agent)
2851 gnus-plugged))
2852 (gnus-summary-reply-with-original "mail/reply")
2853 (gnus-summary-reply "mail/reply" nil :visible nil)
2854 (gnus-summary-followup-with-original "mail/reply-all")
2855 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2856 (gnus-summary-mail-forward "mail/forward")
2857 (gnus-summary-save-article "mail/save")
2858 (gnus-summary-search-article-forward "search" nil :visible nil)
2859 (gnus-summary-print-article "print")
2860 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2861 ;; Some new commands that may need more suitable icons:
2862 (gnus-summary-save-newsrc "save" nil :visible nil)
2863 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2864 (gnus-summary-prev-article "left-arrow")
2865 (gnus-summary-next-article "right-arrow")
2866 (gnus-summary-next-page "next-page")
2867 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2868 ;;
2869 ;; Maybe some sort-by-... could be added:
2870 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2871 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2872 (gnus-summary-mark-as-expirable
2873 "delete" nil
2874 :visible (gnus-check-backend-function 'request-expire-articles
2875 gnus-newsgroup-name))
2876 (gnus-summary-mark-as-spam
2877 "mail/spam" t
2878 :visible (and (fboundp 'spam-group-ham-contents-p)
2879 (spam-group-ham-contents-p gnus-newsgroup-name))
2880 :help "Mark as spam")
2881 (gnus-summary-mark-as-read-forward
2882 "mail/not-spam" nil
2883 :visible (and (fboundp 'spam-group-spam-contents-p)
2884 (spam-group-spam-contents-p gnus-newsgroup-name)))
2885 ;;
2886 (gnus-summary-exit "exit")
2887 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2888 (gnus-info-find-node "help"))
2889 "List of functions for the summary tool bar (GNOME style).
2890
2891 See `gmm-tool-bar-from-list' for the format of the list."
2892 :type '(repeat gmm-tool-bar-item)
2893 :version "23.1" ;; No Gnus
2894 :initialize 'custom-initialize-default
2895 :set 'gnus-summary-tool-bar-update
2896 :group 'gnus-summary)
2897
2898 (defcustom gnus-summary-tool-bar-retro
2899 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2900 (gnus-summary-next-unread-article "gnus/next-ur")
2901 (gnus-summary-post-news "gnus/post")
2902 (gnus-summary-followup-with-original "gnus/fuwo")
2903 (gnus-summary-followup "gnus/followup")
2904 (gnus-summary-reply-with-original "gnus/reply-wo")
2905 (gnus-summary-reply "gnus/reply")
2906 (gnus-summary-caesar-message "gnus/rot13")
2907 (gnus-uu-decode-uu "gnus/uu-decode")
2908 (gnus-summary-save-article-file "gnus/save-aif")
2909 (gnus-summary-save-article "gnus/save-art")
2910 (gnus-uu-post-news "gnus/uu-post")
2911 (gnus-summary-catchup "gnus/catchup")
2912 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2913 (gnus-summary-exit "gnus/exit-summ")
2914 ;; Some new command that may need more suitable icons:
2915 (gnus-summary-print-article "gnus/print" nil :visible nil)
2916 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2917 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2918 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2919 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2920 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2921 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2922 ;;
2923 (gnus-info-find-node "gnus/help" nil :visible nil))
2924 "List of functions for the summary tool bar (retro look).
2925
2926 See `gmm-tool-bar-from-list' for the format of the list."
2927 :type '(repeat gmm-tool-bar-item)
2928 :version "23.1" ;; No Gnus
2929 :initialize 'custom-initialize-default
2930 :set 'gnus-summary-tool-bar-update
2931 :group 'gnus-summary)
2932
2933 (defcustom gnus-summary-tool-bar-zap-list t
2934 "List of icon items from the global tool bar.
2935 These items are not displayed in the Gnus summary mode tool bar.
2936
2937 See `gmm-tool-bar-from-list' for the format of the list."
2938 :type 'gmm-tool-bar-zap-list
2939 :version "23.1" ;; No Gnus
2940 :initialize 'custom-initialize-default
2941 :set 'gnus-summary-tool-bar-update
2942 :group 'gnus-summary)
2943
2944 (defvar image-load-path)
2945 (defvar tool-bar-map)
2946
2947 (defun gnus-summary-make-tool-bar (&optional force)
2948 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2949 When FORCE, rebuild the tool bar."
2950 (when (and (not (featurep 'xemacs))
2951 (boundp 'tool-bar-mode)
2952 tool-bar-mode
2953 (or (not gnus-summary-tool-bar-map) force))
2954 (let* ((load-path
2955 (gmm-image-load-path-for-library "gnus"
2956 "mail/save.xpm"
2957 nil t))
2958 (image-load-path (cons (car load-path)
2959 (when (boundp 'image-load-path)
2960 image-load-path)))
2961 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2962 gnus-summary-tool-bar-zap-list
2963 'gnus-summary-mode-map)))
2964 (when map
2965 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2966 ;; uses its value.
2967 (setq gnus-summary-tool-bar-map map))))
2968 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2969
2970 (defun gnus-make-score-map (type)
2971 "Make a summary score map of type TYPE."
2972 (if t
2973 nil
2974 (let ((headers '(("author" "from" string)
2975 ("subject" "subject" string)
2976 ("article body" "body" string)
2977 ("article head" "head" string)
2978 ("xref" "xref" string)
2979 ("extra header" "extra" string)
2980 ("lines" "lines" number)
2981 ("followups to author" "followup" string)))
2982 (types '((number ("less than" <)
2983 ("greater than" >)
2984 ("equal" =))
2985 (string ("substring" s)
2986 ("exact string" e)
2987 ("fuzzy string" f)
2988 ("regexp" r))))
2989 (perms '(("temporary" (current-time-string))
2990 ("permanent" nil)
2991 ("immediate" now)))
2992 header)
2993 (list
2994 (apply
2995 'nconc
2996 (list
2997 (if (eq type 'lower)
2998 "Lower score"
2999 "Increase score"))
3000 (let (outh)
3001 (while headers
3002 (setq header (car headers))
3003 (setq outh
3004 (cons
3005 (apply
3006 'nconc
3007 (list (car header))
3008 (let ((ts (cdr (assoc (nth 2 header) types)))
3009 outt)
3010 (while ts
3011 (setq outt
3012 (cons
3013 (apply
3014 'nconc
3015 (list (caar ts))
3016 (let ((ps perms)
3017 outp)
3018 (while ps
3019 (setq outp
3020 (cons
3021 (vector
3022 (caar ps)
3023 (list
3024 'gnus-summary-score-entry
3025 (nth 1 header)
3026 (if (or (string= (nth 1 header)
3027 "head")
3028 (string= (nth 1 header)
3029 "body"))
3030 ""
3031 (list 'gnus-summary-header
3032 (nth 1 header)))
3033 (list 'quote (nth 1 (car ts)))
3034 (list 'gnus-score-delta-default
3035 nil)
3036 (nth 1 (car ps))
3037 t)
3038 t)
3039 outp))
3040 (setq ps (cdr ps)))
3041 (list (nreverse outp))))
3042 outt))
3043 (setq ts (cdr ts)))
3044 (list (nreverse outt))))
3045 outh))
3046 (setq headers (cdr headers)))
3047 (list (nreverse outh))))))))
3048
3049
3050 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3051 (defvar bookmark-make-record-function)
3052 \f
3053 (defvar bidi-paragraph-direction)
3054
3055 (defun gnus-summary-mode (&optional group)
3056 "Major mode for reading articles.
3057
3058 All normal editing commands are switched off.
3059 \\<gnus-summary-mode-map>
3060 Each line in this buffer represents one article. To read an
3061 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3062 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3063 respectively.
3064
3065 You can also post articles and send mail from this buffer. To
3066 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3067 of an article, type `\\[gnus-summary-reply]'.
3068
3069 There are approx. one gazillion commands you can execute in this
3070 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3071
3072 The following commands are available:
3073
3074 \\{gnus-summary-mode-map}"
3075 (interactive)
3076 (kill-all-local-variables)
3077 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3078 (gnus-summary-make-local-variables))
3079 (gnus-summary-make-local-variables)
3080 (setq gnus-newsgroup-name group)
3081 (when (gnus-visual-p 'summary-menu 'menu)
3082 (gnus-summary-make-menu-bar)
3083 (gnus-summary-make-tool-bar))
3084 (gnus-make-thread-indent-array)
3085 (gnus-simplify-mode-line)
3086 (setq major-mode 'gnus-summary-mode)
3087 (setq mode-name "Summary")
3088 (use-local-map gnus-summary-mode-map)
3089 (buffer-disable-undo)
3090 (setq buffer-read-only t ;Disable modification
3091 show-trailing-whitespace nil)
3092 (setq truncate-lines t)
3093 ;; Force paragraph direction to be left-to-right. Don't make it
3094 ;; bound globally in old Emacsen and XEmacsen.
3095 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3096 (add-to-invisibility-spec '(gnus-sum . t))
3097 (gnus-summary-set-display-table)
3098 (gnus-set-default-directory)
3099 (make-local-variable 'gnus-summary-line-format)
3100 (make-local-variable 'gnus-summary-line-format-spec)
3101 (make-local-variable 'gnus-summary-dummy-line-format)
3102 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3103 (make-local-variable 'gnus-summary-mark-positions)
3104 (gnus-make-local-hook 'pre-command-hook)
3105 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3106 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3107 (turn-on-gnus-mailing-list-mode)
3108 (mm-enable-multibyte)
3109 (set (make-local-variable 'bookmark-make-record-function)
3110 'gnus-summary-bookmark-make-record)
3111 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3112 (gnus-update-summary-mark-positions))
3113
3114 (defun gnus-summary-make-local-variables ()
3115 "Make all the local summary buffer variables."
3116 (let (global)
3117 (dolist (local gnus-summary-local-variables)
3118 (if (consp local)
3119 (progn
3120 (if (eq (cdr local) 'global)
3121 ;; Copy the global value of the variable.
3122 (setq global (symbol-value (car local)))
3123 ;; Use the value from the list.
3124 (setq global (eval (cdr local))))
3125 (set (make-local-variable (car local)) global))
3126 ;; Simple nil-valued local variable.
3127 (set (make-local-variable local) nil)))))
3128
3129 ;; Summary data functions.
3130
3131 (defmacro gnus-data-number (data)
3132 `(car ,data))
3133
3134 (defmacro gnus-data-set-number (data number)
3135 `(setcar ,data ,number))
3136
3137 (defmacro gnus-data-mark (data)
3138 `(nth 1 ,data))
3139
3140 (defmacro gnus-data-set-mark (data mark)
3141 `(setcar (nthcdr 1 ,data) ,mark))
3142
3143 (defmacro gnus-data-pos (data)
3144 `(nth 2 ,data))
3145
3146 (defmacro gnus-data-set-pos (data pos)
3147 `(setcar (nthcdr 2 ,data) ,pos))
3148
3149 (defmacro gnus-data-header (data)
3150 `(nth 3 ,data))
3151
3152 (defmacro gnus-data-set-header (data header)
3153 `(setf (nth 3 ,data) ,header))
3154
3155 (defmacro gnus-data-level (data)
3156 `(nth 4 ,data))
3157
3158 (defmacro gnus-data-unread-p (data)
3159 `(= (nth 1 ,data) gnus-unread-mark))
3160
3161 (defmacro gnus-data-read-p (data)
3162 `(/= (nth 1 ,data) gnus-unread-mark))
3163
3164 (defmacro gnus-data-pseudo-p (data)
3165 `(consp (nth 3 ,data)))
3166
3167 (defmacro gnus-data-find (number)
3168 `(assq ,number gnus-newsgroup-data))
3169
3170 (defmacro gnus-data-find-list (number &optional data)
3171 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3172 (memq (assq ,number bdata)
3173 bdata)))
3174
3175 (defmacro gnus-data-make (number mark pos header level)
3176 `(list ,number ,mark ,pos ,header ,level))
3177
3178 (defun gnus-data-enter (after-article number mark pos header level offset)
3179 (let ((data (gnus-data-find-list after-article)))
3180 (unless data
3181 (error "No such article: %d" after-article))
3182 (setcdr data (cons (gnus-data-make number mark pos header level)
3183 (cdr data)))
3184 (setq gnus-newsgroup-data-reverse nil)
3185 (gnus-data-update-list (cddr data) offset)))
3186
3187 (defun gnus-data-enter-list (after-article list &optional offset)
3188 (when list
3189 (let ((data (and after-article (gnus-data-find-list after-article)))
3190 (ilist list))
3191 (if (not (or data
3192 after-article))
3193 (let ((odata gnus-newsgroup-data))
3194 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3195 (when offset
3196 (gnus-data-update-list odata offset)))
3197 ;; Find the last element in the list to be spliced into the main
3198 ;; list.
3199 (setq list (last list))
3200 (if (not data)
3201 (progn
3202 (setcdr list gnus-newsgroup-data)
3203 (setq gnus-newsgroup-data ilist)
3204 (when offset
3205 (gnus-data-update-list (cdr list) offset)))
3206 (setcdr list (cdr data))
3207 (setcdr data ilist)
3208 (when offset
3209 (gnus-data-update-list (cdr list) offset))))
3210 (setq gnus-newsgroup-data-reverse nil))))
3211
3212 (defun gnus-data-remove (article &optional offset)
3213 (let ((data gnus-newsgroup-data))
3214 (if (= (gnus-data-number (car data)) article)
3215 (progn
3216 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3217 gnus-newsgroup-data-reverse nil)
3218 (when offset
3219 (gnus-data-update-list gnus-newsgroup-data offset)))
3220 (while (cdr data)
3221 (when (= (gnus-data-number (cadr data)) article)
3222 (setcdr data (cddr data))
3223 (when offset
3224 (gnus-data-update-list (cdr data) offset))
3225 (setq data nil
3226 gnus-newsgroup-data-reverse nil))
3227 (setq data (cdr data))))))
3228
3229 (defmacro gnus-data-list (backward)
3230 `(if ,backward
3231 (or gnus-newsgroup-data-reverse
3232 (setq gnus-newsgroup-data-reverse
3233 (reverse gnus-newsgroup-data)))
3234 gnus-newsgroup-data))
3235
3236 (defun gnus-data-update-list (data offset)
3237 "Add OFFSET to the POS of all data entries in DATA."
3238 (setq gnus-newsgroup-data-reverse nil)
3239 (while data
3240 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3241 (setq data (cdr data))))
3242
3243 (defun gnus-summary-article-pseudo-p (article)
3244 "Say whether this article is a pseudo article or not."
3245 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3246
3247 (defmacro gnus-summary-article-sparse-p (article)
3248 "Say whether this article is a sparse article or not."
3249 `(memq ,article gnus-newsgroup-sparse))
3250
3251 (defmacro gnus-summary-article-ancient-p (article)
3252 "Say whether this article is a sparse article or not."
3253 `(memq ,article gnus-newsgroup-ancient))
3254
3255 (defun gnus-article-children (number)
3256 "Return a list of all children to NUMBER."
3257 (let* ((data (gnus-data-find-list number))
3258 (level (gnus-data-level (car data)))
3259 children)
3260 (setq data (cdr data))
3261 (while (and data
3262 (= (gnus-data-level (car data)) (1+ level)))
3263 (push (gnus-data-number (car data)) children)
3264 (setq data (cdr data)))
3265 children))
3266
3267 (defmacro gnus-summary-skip-intangible ()
3268 "If the current article is intangible, then jump to a different article."
3269 '(let ((to (get-text-property (point) 'gnus-intangible)))
3270 (and to (gnus-summary-goto-subject to))))
3271
3272 (defmacro gnus-summary-article-intangible-p ()
3273 "Say whether this article is intangible or not."
3274 '(get-text-property (point) 'gnus-intangible))
3275
3276 ;; Some summary mode macros.
3277
3278 (defmacro gnus-summary-article-number ()
3279 "The article number of the article on the current line.
3280 If there isn't an article number here, then we return the current
3281 article number."
3282 '(progn
3283 (gnus-summary-skip-intangible)
3284 (or (get-text-property (point) 'gnus-number)
3285 (gnus-summary-last-subject))))
3286
3287 (defmacro gnus-summary-article-header (&optional number)
3288 "Return the header of article NUMBER."
3289 `(gnus-data-header (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3291
3292 (defmacro gnus-summary-thread-level (&optional number)
3293 "Return the level of thread that starts with article NUMBER."
3294 `(if (and (eq gnus-summary-make-false-root 'dummy)
3295 (get-text-property (point) 'gnus-intangible))
3296 0
3297 (gnus-data-level (gnus-data-find
3298 ,(or number '(gnus-summary-article-number))))))
3299
3300 (defmacro gnus-summary-article-mark (&optional number)
3301 "Return the mark of article NUMBER."
3302 `(gnus-data-mark (gnus-data-find
3303 ,(or number '(gnus-summary-article-number)))))
3304
3305 (defmacro gnus-summary-article-pos (&optional number)
3306 "Return the position of the line of article NUMBER."
3307 `(gnus-data-pos (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3309
3310 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3311 (defmacro gnus-summary-article-subject (&optional number)
3312 "Return current subject string or nil if nothing."
3313 `(let ((headers
3314 ,(if number
3315 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3316 '(gnus-data-header (assq (gnus-summary-article-number)
3317 gnus-newsgroup-data)))))
3318 (and headers
3319 (vectorp headers)
3320 (mail-header-subject headers))))
3321
3322 (defmacro gnus-summary-article-score (&optional number)
3323 "Return current article score."
3324 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3325 gnus-newsgroup-scored))
3326 gnus-summary-default-score 0))
3327
3328 (defun gnus-summary-article-children (&optional number)
3329 "Return a list of article numbers that are children of article NUMBER."
3330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3331 (level (gnus-data-level (car data)))
3332 l children)
3333 (while (and (setq data (cdr data))
3334 (> (setq l (gnus-data-level (car data))) level))
3335 (and (= (1+ level) l)
3336 (push (gnus-data-number (car data))
3337 children)))
3338 (nreverse children)))
3339
3340 (defun gnus-summary-article-parent (&optional number)
3341 "Return the article number of the parent of article NUMBER."
3342 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3343 (gnus-data-list t)))
3344 (level (gnus-data-level (car data))))
3345 (if (zerop level)
3346 () ; This is a root.
3347 ;; We search until we find an article with a level less than
3348 ;; this one. That function has to be the parent.
3349 (while (and (setq data (cdr data))
3350 (not (< (gnus-data-level (car data)) level))))
3351 (and data (gnus-data-number (car data))))))
3352
3353 (defun gnus-unread-mark-p (mark)
3354 "Say whether MARK is the unread mark."
3355 (= mark gnus-unread-mark))
3356
3357 (defun gnus-read-mark-p (mark)
3358 "Say whether MARK is one of the marks that mark as read.
3359 This is all marks except unread, ticked, dormant, and expirable."
3360 (not (or (= mark gnus-unread-mark)
3361 (= mark gnus-ticked-mark)
3362 (= mark gnus-spam-mark)
3363 (= mark gnus-dormant-mark)
3364 (= mark gnus-expirable-mark))))
3365
3366 (defmacro gnus-article-mark (number)
3367 "Return the MARK of article NUMBER.
3368 This macro should only be used when computing the mark the \"first\"
3369 time; i.e., when generating the summary lines. After that,
3370 `gnus-summary-article-mark' should be used to examine the
3371 marks of articles."
3372 `(cond
3373 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3374 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3375 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3376 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3377 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3378 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3379 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3380 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3381 gnus-ancient-mark))))
3382
3383 ;; Saving hidden threads.
3384
3385 (defmacro gnus-save-hidden-threads (&rest forms)
3386 "Save hidden threads, eval FORMS, and restore the hidden threads."
3387 (let ((config (make-symbol "config")))
3388 `(let ((,config (gnus-hidden-threads-configuration)))
3389 (unwind-protect
3390 (save-excursion
3391 ,@forms)
3392 (gnus-restore-hidden-threads-configuration ,config)))))
3393 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3394 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3395
3396 (defun gnus-data-compute-positions ()
3397 "Compute the positions of all articles."
3398 (setq gnus-newsgroup-data-reverse nil)
3399 (let ((data gnus-newsgroup-data))
3400 (save-excursion
3401 (gnus-save-hidden-threads
3402 (gnus-summary-show-all-threads)
3403 (goto-char (point-min))
3404 (while data
3405 (while (get-text-property (point) 'gnus-intangible)
3406 (forward-line 1))
3407 (gnus-data-set-pos (car data) (+ (point) 3))
3408 (setq data (cdr data))
3409 (forward-line 1))))))
3410
3411 (defun gnus-hidden-threads-configuration ()
3412 "Return the current hidden threads configuration."
3413 (save-excursion
3414 (let (config)
3415 (goto-char (point-min))
3416 (while (not (eobp))
3417 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3418 (push (save-excursion (forward-line 0) (point)) config))
3419 (forward-line 1))
3420 config)))
3421
3422 (defun gnus-restore-hidden-threads-configuration (config)
3423 "Restore hidden threads configuration from CONFIG."
3424 (save-excursion
3425 (let (point (inhibit-read-only t))
3426 (while (setq point (pop config))
3427 (goto-char point)
3428 (gnus-summary-hide-thread)))))
3429
3430 ;; Various summary mode internalish functions.
3431
3432 (defun gnus-mouse-pick-article (e)
3433 (interactive "e")
3434 (mouse-set-point e)
3435 (gnus-summary-next-page nil t))
3436
3437 (defun gnus-summary-set-display-table ()
3438 "Change the display table.
3439 Odd characters have a tendency to mess
3440 up nicely formatted displays - we make all possible glyphs
3441 display only a single character."
3442
3443 ;; We start from the standard display table, if any.
3444 (let ((table (or (copy-sequence standard-display-table)
3445 (make-display-table)))
3446 (i 32))
3447 ;; Nix out all the control chars...
3448 (while (>= (setq i (1- i)) 0)
3449 (gnus-put-display-table i [??] table))
3450 ;; ... but not newline and cr, of course. (cr is necessary for the
3451 ;; selective display).
3452 (gnus-put-display-table ?\n nil table)
3453 (gnus-put-display-table ?\r nil table)
3454 ;; We keep TAB as well.
3455 (gnus-put-display-table ?\t nil table)
3456 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3457 ;; Emacs 23 (unicode), that are not set already.
3458 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3459 160
3460 256)))
3461 (while (>= (setq i (1- i)) 127)
3462 ;; Only modify if the entry is nil.
3463 (unless (gnus-get-display-table i table)
3464 (gnus-put-display-table i [??] table))))
3465 (setq buffer-display-table table)))
3466
3467 (defun gnus-summary-set-article-display-arrow (pos)
3468 "Update the overlay arrow to point to line at position POS."
3469 (when gnus-summary-display-arrow
3470 (make-local-variable 'overlay-arrow-position)
3471 (make-local-variable 'overlay-arrow-string)
3472 (save-excursion
3473 (goto-char pos)
3474 (beginning-of-line)
3475 (unless overlay-arrow-position
3476 (setq overlay-arrow-position (make-marker)))
3477 (setq overlay-arrow-string "=>"
3478 overlay-arrow-position (set-marker overlay-arrow-position
3479 (point)
3480 (current-buffer))))))
3481
3482 (defun gnus-summary-setup-buffer (group)
3483 "Initialize summary buffer.
3484 If the setup was successful, non-nil is returned."
3485 (let ((buffer (gnus-summary-buffer-name group))
3486 (dead-name (concat "*Dead Summary "
3487 (gnus-group-decoded-name group) "*")))
3488 ;; If a dead summary buffer exists, we kill it.
3489 (when (gnus-buffer-live-p dead-name)
3490 (gnus-kill-buffer dead-name))
3491 (if (get-buffer buffer)
3492 (progn
3493 (set-buffer buffer)
3494 (setq gnus-summary-buffer (current-buffer))
3495 (not gnus-newsgroup-prepared))
3496 (set-buffer (gnus-get-buffer-create buffer))
3497 (setq gnus-summary-buffer (current-buffer))
3498 (gnus-summary-mode group)
3499 (when (gnus-group-quit-config group)
3500 (set (make-local-variable 'gnus-single-article-buffer) nil))
3501 (make-local-variable 'gnus-article-buffer)
3502 (make-local-variable 'gnus-article-current)
3503 (make-local-variable 'gnus-original-article-buffer)
3504 (setq gnus-newsgroup-name group)
3505 ;; Set any local variables in the group parameters.
3506 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3507 t)))
3508
3509 (defun gnus-set-global-variables ()
3510 "Set the global equivalents of the buffer-local variables.
3511 They are set to the latest values they had. These reflect the summary
3512 buffer that was in action when the last article was fetched."
3513 (when (eq major-mode 'gnus-summary-mode)
3514 (setq gnus-summary-buffer (current-buffer))
3515 (let ((name gnus-newsgroup-name)
3516 (marked gnus-newsgroup-marked)
3517 (spam gnus-newsgroup-spam-marked)
3518 (unread gnus-newsgroup-unreads)
3519 (headers gnus-current-headers)
3520 (data gnus-newsgroup-data)
3521 (summary gnus-summary-buffer)
3522 (article-buffer gnus-article-buffer)
3523 (original gnus-original-article-buffer)
3524 (gac gnus-article-current)
3525 (reffed gnus-reffed-article-number)
3526 (score-file gnus-current-score-file)
3527 (default-charset gnus-newsgroup-charset)
3528 vlist)
3529 (let ((locals gnus-newsgroup-variables))
3530 (while locals
3531 (if (consp (car locals))
3532 (push (eval (caar locals)) vlist)
3533 (push (eval (car locals)) vlist))
3534 (setq locals (cdr locals)))
3535 (setq vlist (nreverse vlist)))
3536 (with-temp-buffer
3537 (setq gnus-newsgroup-name name
3538 gnus-newsgroup-marked marked
3539 gnus-newsgroup-spam-marked spam
3540 gnus-newsgroup-unreads unread
3541 gnus-current-headers headers
3542 gnus-newsgroup-data data
3543 gnus-article-current gac
3544 gnus-summary-buffer summary
3545 gnus-article-buffer article-buffer
3546 gnus-original-article-buffer original
3547 gnus-reffed-article-number reffed
3548 gnus-current-score-file score-file
3549 gnus-newsgroup-charset default-charset)
3550 (let ((locals gnus-newsgroup-variables))
3551 (while locals
3552 (if (consp (car locals))
3553 (set (caar locals) (pop vlist))
3554 (set (car locals) (pop vlist)))
3555 (setq locals (cdr locals))))))))
3556
3557 (defun gnus-summary-article-unread-p (article)
3558 "Say whether ARTICLE is unread or not."
3559 (memq article gnus-newsgroup-unreads))
3560
3561 (defun gnus-summary-first-article-p (&optional article)
3562 "Return whether ARTICLE is the first article in the buffer."
3563 (if (not (setq article (or article (gnus-summary-article-number))))
3564 nil
3565 (eq article (caar gnus-newsgroup-data))))
3566
3567 (defun gnus-summary-last-article-p (&optional article)
3568 "Return whether ARTICLE is the last article in the buffer."
3569 (if (not (setq article (or article (gnus-summary-article-number))))
3570 ;; All non-existent numbers are the last article. :-)
3571 t
3572 (not (cdr (gnus-data-find-list article)))))
3573
3574 (defun gnus-make-thread-indent-array (&optional n)
3575 (when (or n
3576 (progn (setq n 200) nil)
3577 (null gnus-thread-indent-array)
3578 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3579 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3580 gnus-thread-indent-array-level gnus-thread-indent-level)
3581 (while (>= n 0)
3582 (aset gnus-thread-indent-array n
3583 (make-string (* n gnus-thread-indent-level) ? ))
3584 (setq n (1- n)))))
3585
3586 (defun gnus-update-summary-mark-positions ()
3587 "Compute where the summary marks are to go."
3588 (save-excursion
3589 (when (gnus-buffer-exists-p gnus-summary-buffer)
3590 (set-buffer gnus-summary-buffer))
3591 (let ((spec gnus-summary-line-format-spec)
3592 pos)
3593 (save-excursion
3594 (gnus-set-work-buffer)
3595 (let ((gnus-tmp-unread ?Z)
3596 (gnus-replied-mark ?Z)
3597 (gnus-score-below-mark ?Z)
3598 (gnus-score-over-mark ?Z)
3599 (gnus-undownloaded-mark ?Z)
3600 (gnus-summary-line-format-spec spec)
3601 (gnus-newsgroup-downloadable '(0))
3602 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3603 case-fold-search ignores)
3604 ;; Here, all marks are bound to Z.
3605 (gnus-summary-insert-line header
3606 0 nil t gnus-tmp-unread t nil "" nil 1)
3607 (goto-char (point-min))
3608 ;; Memorize the positions of the same characters as dummy marks.
3609 (while (re-search-forward "[A-D]" nil t)
3610 (push (point) ignores))
3611 (erase-buffer)
3612 ;; We use A-D as dummy marks in order to know column positions
3613 ;; where marks should be inserted.
3614 (setq gnus-tmp-unread ?A
3615 gnus-replied-mark ?B
3616 gnus-score-below-mark ?C
3617 gnus-score-over-mark ?C
3618 gnus-undownloaded-mark ?D)
3619 (gnus-summary-insert-line header
3620 0 nil t gnus-tmp-unread t nil "" nil 1)
3621 ;; Ignore characters which aren't dummy marks.
3622 (dolist (p ignores)
3623 (delete-region (goto-char (1- p)) p)
3624 (insert ?Z))
3625 (goto-char (point-min))
3626 (setq pos (list (cons 'unread
3627 (and (search-forward "A" nil t)
3628 (- (point) (point-min) 1)))))
3629 (goto-char (point-min))
3630 (push (cons 'replied (and (search-forward "B" nil t)
3631 (- (point) (point-min) 1)))
3632 pos)
3633 (goto-char (point-min))
3634 (push (cons 'score (and (search-forward "C" nil t)
3635 (- (point) (point-min) 1)))
3636 pos)
3637 (goto-char (point-min))
3638 (push (cons 'download (and (search-forward "D" nil t)
3639 (- (point) (point-min) 1)))
3640 pos)))
3641 (setq gnus-summary-mark-positions pos))))
3642
3643 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3644 "Insert a dummy root in the summary buffer."
3645 (beginning-of-line)
3646 (gnus-add-text-properties
3647 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3648 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3649
3650 (defun gnus-summary-extract-address-component (from)
3651 (or (car (funcall gnus-extract-address-components from))
3652 from))
3653
3654 (defun gnus-summary-from-or-to-or-newsgroups (header from)
3655 (let ((mail-parse-charset gnus-newsgroup-charset)
3656 (ignored-from-addresses (gnus-ignored-from-addresses))
3657 ;; Is it really necessary to do this next part for each summary line?
3658 ;; Luckily, doesn't seem to slow things down much.
3659 (mail-parse-ignored-charsets
3660 (with-current-buffer gnus-summary-buffer
3661 gnus-newsgroup-ignored-charsets))
3662 (address (cadr (gnus-extract-address-components from))))
3663 (or
3664 (and ignored-from-addresses
3665 (string-match ignored-from-addresses address)
3666 (let ((extra-headers (mail-header-extra header))
3667 to
3668 newsgroups)
3669 (cond
3670 ((setq to (cdr (assq 'To extra-headers)))
3671 (concat gnus-summary-to-prefix
3672 (inline
3673 (gnus-summary-extract-address-component
3674 (funcall gnus-decode-encoded-address-function to)))))
3675 ((setq newsgroups
3676 (or
3677 (cdr (assq 'Newsgroups extra-headers))
3678 (and
3679 (memq 'Newsgroups gnus-extra-headers)
3680 (eq (car (gnus-find-method-for-group
3681 gnus-newsgroup-name)) 'nntp)
3682 (gnus-group-real-name gnus-newsgroup-name))))
3683 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3684 (gnus-string-mark-left-to-right (gnus-summary-extract-address-component from)))))
3685
3686 (defun gnus-summary-insert-line (gnus-tmp-header
3687 gnus-tmp-level gnus-tmp-current
3688 undownloaded gnus-tmp-unread gnus-tmp-replied
3689 gnus-tmp-expirable gnus-tmp-subject-or-nil
3690 &optional gnus-tmp-dummy gnus-tmp-score
3691 gnus-tmp-process)
3692 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3693 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3694 gnus-tmp-level)))
3695 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3696 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3697 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3698 (gnus-tmp-score-char
3699 (if (or (null gnus-summary-default-score)
3700 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3701 gnus-summary-zcore-fuzz))
3702 ? ;Whitespace
3703 (if (< gnus-tmp-score gnus-summary-default-score)
3704 gnus-score-below-mark gnus-score-over-mark)))
3705 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3706 (gnus-tmp-replied
3707 (cond (gnus-tmp-process gnus-process-mark)
3708 ((memq gnus-tmp-current gnus-newsgroup-cached)
3709 gnus-cached-mark)
3710 (gnus-tmp-replied gnus-replied-mark)
3711 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3712 gnus-forwarded-mark)
3713 ((memq gnus-tmp-current gnus-newsgroup-saved)
3714 gnus-saved-mark)
3715 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3716 gnus-unseen-mark)
3717 (t gnus-no-mark)))
3718 (gnus-tmp-downloaded
3719 (cond (undownloaded
3720 gnus-undownloaded-mark)
3721 (gnus-newsgroup-agentized
3722 gnus-downloaded-mark)
3723 (t
3724 gnus-no-mark)))
3725 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3726 (gnus-tmp-name
3727 (cond
3728 ((string-match "<[^>]+> *$" gnus-tmp-from)
3729 (let ((beg (match-beginning 0)))
3730 (or (and (string-match "^\".+\"" gnus-tmp-from)
3731 (substring gnus-tmp-from 1 (1- (match-end 0))))
3732 (substring gnus-tmp-from 0 beg))))
3733 ((string-match "(.+)" gnus-tmp-from)
3734 (substring gnus-tmp-from
3735 (1+ (match-beginning 0)) (1- (match-end 0))))
3736 (t gnus-tmp-from)))
3737 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3738 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3739 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3740 (inhibit-read-only t))
3741 (when (string= gnus-tmp-name "")
3742 (setq gnus-tmp-name gnus-tmp-from))
3743 (unless (numberp gnus-tmp-lines)
3744 (setq gnus-tmp-lines -1))
3745 (if (= gnus-tmp-lines -1)
3746 (setq gnus-tmp-lines "?")
3747 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3748 (condition-case ()
3749 (gnus-put-text-property
3750 (point)
3751 (progn (eval gnus-summary-line-format-spec) (point))
3752 'gnus-number gnus-tmp-number)
3753 (error (gnus-message 5 "Error updating the summary line")))
3754 (when (gnus-visual-p 'summary-highlight 'highlight)
3755 (forward-line -1)
3756 (gnus-summary-highlight-line)
3757 (gnus-run-hooks 'gnus-summary-update-hook)
3758 (forward-line 1))))
3759
3760 (defun gnus-summary-update-line (&optional dont-update)
3761 "Update summary line after change."
3762 (when (and gnus-summary-default-score
3763 (not gnus-summary-inhibit-highlight))
3764 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3765 (article (gnus-summary-article-number))
3766 (score (gnus-summary-article-score article)))
3767 (unless dont-update
3768 (if (and gnus-summary-mark-below
3769 (< (gnus-summary-article-score)
3770 gnus-summary-mark-below))
3771 ;; This article has a low score, so we mark it as read.
3772 (when (memq article gnus-newsgroup-unreads)
3773 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3774 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3775 ;; This article was previously marked as read on account
3776 ;; of a low score, but now it has risen, so we mark it as
3777 ;; unread.
3778 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3779 (gnus-summary-update-mark
3780 (if (or (null gnus-summary-default-score)
3781 (<= (abs (- score gnus-summary-default-score))
3782 gnus-summary-zcore-fuzz))
3783 ? ;Whitespace
3784 (if (< score gnus-summary-default-score)
3785 gnus-score-below-mark gnus-score-over-mark))
3786 'score))
3787 ;; Do visual highlighting.
3788 (when (gnus-visual-p 'summary-highlight 'highlight)
3789 (gnus-summary-highlight-line)
3790 (gnus-run-hooks 'gnus-summary-update-hook)))))
3791
3792 (defvar gnus-tmp-new-adopts nil)
3793
3794 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3795 "Return the number of articles in THREAD.
3796 This may be 0 in some cases -- if none of the articles in
3797 the thread are to be displayed."
3798 (let* ((number
3799 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3800 (cond
3801 ((not (listp thread))
3802 1)
3803 ((and (consp thread) (cdr thread))
3804 (apply
3805 '+ 1 (mapcar
3806 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3807 ((null thread)
3808 1)
3809 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3810 1)
3811 (t 0))))
3812 (when (and level (zerop level) gnus-tmp-new-adopts)
3813 (incf number
3814 (apply '+ (mapcar
3815 'gnus-summary-number-of-articles-in-thread
3816 gnus-tmp-new-adopts))))
3817 (if char
3818 (if (> number 1) gnus-not-empty-thread-mark
3819 gnus-empty-thread-mark)
3820 number)))
3821
3822 (defsubst gnus-summary-line-message-size (head)
3823 "Return pretty-printed version of message size.
3824 This function is intended to be used in
3825 `gnus-summary-line-format-alist'."
3826 (let ((c (or (mail-header-chars head) -1)))
3827 (cond ((< c 0) "n/a") ; chars not available
3828 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3829 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3830 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3831 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3832
3833 (defcustom gnus-user-date-format-alist
3834 '(((gnus-seconds-today) . "Today, %H:%M")
3835 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3836 (604800 . "%A %H:%M") ; That's one week
3837 ((gnus-seconds-month) . "%A %d")
3838 ((gnus-seconds-year) . "%B %d")
3839 (t . "%b %d %Y")) ; This one is used when no other
3840 ; does match
3841 "Specifies date format depending on age of article.
3842 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3843 seconds) or a Lisp expression evaluating to a number. When the age of
3844 the article is less than this number, then use `format-time-string'
3845 with the corresponding FORMAT for displaying the date of the article.
3846 If AGE is not a number or a Lisp expression evaluating to a
3847 non-number, then the corresponding FORMAT is used as a default value.
3848
3849 Note that the list is processed from the beginning, so it should be
3850 sorted by ascending AGE. Also note that items following the first
3851 non-number AGE will be ignored.
3852
3853 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3854 and `gnus-seconds-year' in the AGE spec. They return the number of
3855 seconds passed since the start of today, of this month, of this year,
3856 respectively."
3857 :version "24.1"
3858 :group 'gnus-summary-format
3859 :type '(alist :key-type sexp :value-type string))
3860
3861 (defun gnus-user-date (messy-date)
3862 "Format the messy-date according to `gnus-user-date-format-alist'.
3863 Returns \" ? \" if there's bad input or if another error occurs.
3864 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3865 (condition-case ()
3866 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3867 (now (gnus-float-time))
3868 ;;If we don't find something suitable we'll use this one
3869 (my-format "%b %d '%y"))
3870 (let* ((difference (- now messy-date))
3871 (templist gnus-user-date-format-alist)
3872 (top (eval (caar templist))))
3873 (while (if (numberp top) (< top difference) (not top))
3874 (progn
3875 (setq templist (cdr templist))
3876 (setq top (eval (caar templist)))))
3877 (if (stringp (cdr (car templist)))
3878 (setq my-format (cdr (car templist)))))
3879 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3880 (error " ? ")))
3881
3882 (defun gnus-summary-set-local-parameters (group)
3883 "Go through the local params of GROUP and set all variable specs in that list."
3884 (let ((vars '(quit-config active))) ; Ignore things that aren't
3885 ; really variables.
3886 (dolist (elem (gnus-group-find-parameter group))
3887 (and (consp elem) ; Has to be a cons.
3888 (consp (cdr elem)) ; The cdr has to be a list.
3889 (symbolp (car elem)) ; Has to be a symbol in there.
3890 (not (memq (car elem) vars))
3891 (ignore-errors
3892 (push (car elem) vars)
3893 ;; Variables like `gnus-show-threads' that are globally
3894 ;; bound, if used as group parameters, need to get to be
3895 ;; buffer-local, whereas just parameters like `gcc-self',
3896 ;; `timestamp', etc. should not be bound as variables.
3897 (if (boundp (car elem))
3898 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3899 (eval (nth 1 elem))))))))
3900
3901 (defun gnus-summary-read-group (group &optional show-all no-article
3902 kill-buffer no-display backward
3903 select-articles)
3904 "Start reading news in newsgroup GROUP.
3905 If SHOW-ALL is non-nil, already read articles are also listed.
3906 If NO-ARTICLE is non-nil, no article is selected initially.
3907 If NO-DISPLAY, don't generate the summary buffer contents.
3908 If KILL-BUFFER, it should be a buffer that's killed once the new
3909 summary buffer has been generated.
3910 If BACKWARD, move point to the previous group in the group buffer
3911 If SELECT-ARTICLES, only select those articles from GROUP."
3912 (let (result)
3913 (while (and group
3914 (null (setq result
3915 (let ((gnus-auto-select-next nil))
3916 (or (gnus-summary-read-group-1
3917 group show-all no-article
3918 kill-buffer no-display
3919 select-articles)
3920 (setq show-all nil
3921 select-articles nil)))))
3922 (eq gnus-auto-select-next 'quietly))
3923 (set-buffer gnus-group-buffer)
3924 ;; The entry function called above goes to the next
3925 ;; group automatically, so we go two groups back
3926 ;; if we are searching for the previous group.
3927 (when backward
3928 (gnus-group-prev-unread-group 2))
3929 (if (not (equal group (gnus-group-group-name)))
3930 (setq group (gnus-group-group-name))
3931 (setq group nil)))
3932 result))
3933
3934 (defun gnus-summary-read-group-1 (group show-all no-article
3935 kill-buffer no-display
3936 &optional select-articles)
3937 ;; Killed foreign groups can't be entered.
3938 ;; (when (and (not (gnus-group-native-p group))
3939 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3940 ;; (error "Dead non-native groups can't be entered"))
3941 (gnus-message 7 "Retrieving newsgroup: %s..."
3942 (gnus-group-decoded-name group))
3943 (let* ((new-group (gnus-summary-setup-buffer group))
3944 (quit-config (gnus-group-quit-config group))
3945 (did-select (and new-group (gnus-select-newsgroup
3946 group show-all select-articles))))
3947 (cond
3948 ;; This summary buffer exists already, so we just select it.
3949 ((not new-group)
3950 (gnus-set-global-variables)
3951 (when kill-buffer
3952 (gnus-kill-or-deaden-summary kill-buffer))
3953 (gnus-configure-windows 'summary 'force)
3954 (gnus-set-mode-line 'summary)
3955 (gnus-summary-position-point)
3956 (message "")
3957 t)
3958 ;; We couldn't select this group.
3959 ((null did-select)
3960 (when (and (eq major-mode 'gnus-summary-mode)
3961 (not (equal (current-buffer) kill-buffer)))
3962 (kill-buffer (current-buffer))
3963 (if (not quit-config)
3964 (progn
3965 ;; Update the info -- marks might need to be removed,
3966 ;; for instance.
3967 (gnus-summary-update-info)
3968 (set-buffer gnus-group-buffer)
3969 (gnus-group-jump-to-group group)
3970 (gnus-group-next-unread-group 1))
3971 (gnus-handle-ephemeral-exit quit-config)))
3972 (if (null (gnus-list-of-unread-articles group))
3973 (gnus-message 3 "Group %s contains no messages" group)
3974 (gnus-message 3 "Can't select group"))
3975 nil)
3976 ;; The user did a `C-g' while prompting for number of articles,
3977 ;; so we exit this group.
3978 ((eq did-select 'quit)
3979 (and (eq major-mode 'gnus-summary-mode)
3980 (not (equal (current-buffer) kill-buffer))
3981 (kill-buffer (current-buffer)))
3982 (when kill-buffer
3983 (gnus-kill-or-deaden-summary kill-buffer))
3984 (if (not quit-config)
3985 (progn
3986 (set-buffer gnus-group-buffer)
3987 (gnus-group-jump-to-group group)
3988 (gnus-configure-windows 'group 'force))
3989 (gnus-handle-ephemeral-exit quit-config))
3990 ;; Finally signal the quit.
3991 (signal 'quit nil))
3992 ;; The group was successfully selected.
3993 (t
3994 (gnus-set-global-variables)
3995 ;; Save the active value in effect when the group was entered.
3996 (setq gnus-newsgroup-active
3997 (gnus-copy-sequence
3998 (gnus-active gnus-newsgroup-name)))
3999 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4000 ;; You can change the summary buffer in some way with this hook.
4001 (gnus-run-hooks 'gnus-select-group-hook)
4002 (when (memq 'summary (gnus-update-format-specifications
4003 nil 'summary 'summary-mode 'summary-dummy))
4004 ;; The format specification for the summary line was updated,
4005 ;; so we need to update the mark positions as well.
4006 (gnus-update-summary-mark-positions))
4007 ;; Do score processing.
4008 (when gnus-use-scoring
4009 (gnus-possibly-score-headers))
4010 ;; Check whether to fill in the gaps in the threads.
4011 (when gnus-build-sparse-threads
4012 (gnus-build-sparse-threads))
4013 ;; Find the initial limit.
4014 (if show-all
4015 (let ((gnus-newsgroup-dormant nil))
4016 (gnus-summary-initial-limit show-all))
4017 (gnus-summary-initial-limit show-all))
4018 ;; Generate the summary buffer.
4019 (unless no-display
4020 (gnus-summary-prepare))
4021 (when gnus-use-trees
4022 (gnus-tree-open group)
4023 (setq gnus-summary-highlight-line-function
4024 'gnus-tree-highlight-article))
4025 ;; If the summary buffer is empty, but there are some low-scored
4026 ;; articles or some excluded dormants, we include these in the
4027 ;; buffer.
4028 (when (and (zerop (buffer-size))
4029 (not no-display))
4030 (cond (gnus-newsgroup-dormant
4031 (gnus-summary-limit-include-dormant))
4032 ((and gnus-newsgroup-scored show-all)
4033 (gnus-summary-limit-include-expunged t))))
4034 ;; Function `gnus-apply-kill-file' must be called in this hook.
4035 (gnus-run-hooks 'gnus-apply-kill-hook)
4036 (if (and (zerop (buffer-size))
4037 (not no-display))
4038 (progn
4039 ;; This newsgroup is empty.
4040 (gnus-summary-catchup-and-exit nil t)
4041 (gnus-message 6 "No unread news")
4042 (when kill-buffer
4043 (gnus-kill-or-deaden-summary kill-buffer))
4044 ;; Return nil from this function.
4045 nil)
4046 ;; Hide conversation thread subtrees. We cannot do this in
4047 ;; gnus-summary-prepare-hook since kill processing may not
4048 ;; work with hidden articles.
4049 (gnus-summary-maybe-hide-threads)
4050 (gnus-configure-windows 'summary)
4051 (when kill-buffer
4052 (gnus-kill-or-deaden-summary kill-buffer))
4053 (gnus-summary-auto-select-subject)
4054 ;; Show first unread article if requested.
4055 (if (and (not no-article)
4056 (not no-display)
4057 gnus-newsgroup-unreads
4058 gnus-auto-select-first)
4059 (progn
4060 (let ((art (gnus-summary-article-number)))
4061 (unless (and (not gnus-plugged)
4062 (or (memq art gnus-newsgroup-undownloaded)
4063 (memq art gnus-newsgroup-downloadable)))
4064 (gnus-summary-goto-article art))))
4065 ;; Don't select any articles.
4066 (gnus-summary-position-point)
4067 (gnus-configure-windows 'summary 'force)
4068 (gnus-set-mode-line 'summary))
4069 (when (and gnus-auto-center-group
4070 (get-buffer-window gnus-group-buffer t))
4071 ;; Gotta use windows, because recenter does weird stuff if
4072 ;; the current buffer ain't the displayed window.
4073 (let ((owin (selected-window)))
4074 (select-window (get-buffer-window gnus-group-buffer t))
4075 (when (gnus-group-goto-group group)
4076 (recenter))
4077 (select-window owin)))
4078 ;; Mark this buffer as "prepared".
4079 (setq gnus-newsgroup-prepared t)
4080 (gnus-run-hooks 'gnus-summary-prepared-hook)
4081 (unless (gnus-ephemeral-group-p group)
4082 (gnus-group-update-group group nil t))
4083 t)))))
4084
4085 (defun gnus-summary-auto-select-subject ()
4086 "Select the subject line on initial group entry."
4087 (goto-char (point-min))
4088 (cond
4089 ((eq gnus-auto-select-subject 'best)
4090 (gnus-summary-best-unread-subject))
4091 ((eq gnus-auto-select-subject 'unread)
4092 (gnus-summary-first-unread-subject))
4093 ((eq gnus-auto-select-subject 'unseen)
4094 (gnus-summary-first-unseen-subject))
4095 ((eq gnus-auto-select-subject 'unseen-or-unread)
4096 (gnus-summary-first-unseen-or-unread-subject))
4097 ((eq gnus-auto-select-subject 'first)
4098 ;; Do nothing.
4099 )
4100 ((functionp gnus-auto-select-subject)
4101 (funcall gnus-auto-select-subject))))
4102
4103 (defun gnus-summary-prepare ()
4104 "Generate the summary buffer."
4105 (interactive)
4106 (let ((inhibit-read-only t))
4107 (erase-buffer)
4108 (setq gnus-newsgroup-data nil
4109 gnus-newsgroup-data-reverse nil)
4110 (gnus-run-hooks 'gnus-summary-generate-hook)
4111 ;; Generate the buffer, either with threads or without.
4112 (when gnus-newsgroup-headers
4113 (gnus-summary-prepare-threads
4114 (if gnus-show-threads
4115 (gnus-sort-gathered-threads
4116 (funcall gnus-summary-thread-gathering-function
4117 (gnus-sort-threads
4118 (gnus-cut-threads (gnus-make-threads)))))
4119 ;; Unthreaded display.
4120 (gnus-sort-articles gnus-newsgroup-headers))))
4121 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4122 ;; Call hooks for modifying summary buffer.
4123 (goto-char (point-min))
4124 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4125
4126 (defsubst gnus-general-simplify-subject (subject)
4127 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4128 (setq subject
4129 (cond
4130 ;; Truncate the subject.
4131 (gnus-simplify-subject-functions
4132 (gnus-map-function gnus-simplify-subject-functions subject))
4133 ((numberp gnus-summary-gather-subject-limit)
4134 (setq subject (gnus-simplify-subject-re subject))
4135 (if (> (length subject) gnus-summary-gather-subject-limit)
4136 (substring subject 0 gnus-summary-gather-subject-limit)
4137 subject))
4138 ;; Fuzzily simplify it.
4139 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4140 (gnus-simplify-subject-fuzzy subject))
4141 ;; Just remove the leading "Re:".
4142 (t
4143 (gnus-simplify-subject-re subject))))
4144
4145 (if (and gnus-summary-gather-exclude-subject
4146 (string-match gnus-summary-gather-exclude-subject subject))
4147 nil ; This article shouldn't be gathered
4148 subject))
4149
4150 (defun gnus-summary-simplify-subject-query ()
4151 "Query where the respool algorithm would put this article."
4152 (interactive)
4153 (gnus-summary-select-article)
4154 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4155
4156 (defun gnus-gather-threads-by-subject (threads)
4157 "Gather threads by looking at Subject headers."
4158 (if (not gnus-summary-make-false-root)
4159 threads
4160 (let ((hashtb (gnus-make-hashtable 1024))
4161 (prev threads)
4162 (result threads)
4163 subject hthread whole-subject)
4164 (while threads
4165 (setq subject (gnus-general-simplify-subject
4166 (setq whole-subject (mail-header-subject
4167 (caar threads)))))
4168 (when subject
4169 (if (setq hthread (gnus-gethash subject hashtb))
4170 (progn
4171 ;; We enter a dummy root into the thread, if we
4172 ;; haven't done that already.
4173 (unless (stringp (caar hthread))
4174 (setcar hthread (list whole-subject (car hthread))))
4175 ;; We add this new gathered thread to this gathered
4176 ;; thread.
4177 (setcdr (car hthread)
4178 (nconc (cdar hthread) (list (car threads))))
4179 ;; Remove it from the list of threads.
4180 (setcdr prev (cdr threads))
4181 (setq threads prev))
4182 ;; Enter this thread into the hash table.
4183 (gnus-sethash subject
4184 (if gnus-summary-make-false-root-always
4185 (progn
4186 ;; If you want a dummy root above all
4187 ;; threads...
4188 (setcar threads (list whole-subject
4189 (car threads)))
4190 threads)
4191 threads)
4192 hashtb)))
4193 (setq prev threads)
4194 (setq threads (cdr threads)))
4195 result)))
4196
4197 (defun gnus-gather-threads-by-references (threads)
4198 "Gather threads by looking at References headers."
4199 (let ((idhashtb (gnus-make-hashtable 1024))
4200 (thhashtb (gnus-make-hashtable 1024))
4201 (prev threads)
4202 (result threads)
4203 ids references id gthread gid entered ref)
4204 (while threads
4205 (when (setq references (mail-header-references (caar threads)))
4206 (setq id (mail-header-id (caar threads))
4207 ids (inline (gnus-split-references references))
4208 entered nil)
4209 (while (setq ref (pop ids))
4210 (setq ids (delete ref ids))
4211 (if (not (setq gid (gnus-gethash ref idhashtb)))
4212 (progn
4213 (gnus-sethash ref id idhashtb)
4214 (gnus-sethash id threads thhashtb))
4215 (setq gthread (gnus-gethash gid thhashtb))
4216 (unless entered
4217 ;; We enter a dummy root into the thread, if we
4218 ;; haven't done that already.
4219 (unless (stringp (caar gthread))
4220 (setcar gthread (list (mail-header-subject (caar gthread))
4221 (car gthread))))
4222 ;; We add this new gathered thread to this gathered
4223 ;; thread.
4224 (setcdr (car gthread)
4225 (nconc (cdar gthread) (list (car threads)))))
4226 ;; Add it into the thread hash table.
4227 (gnus-sethash id gthread thhashtb)
4228 (setq entered t)
4229 ;; Remove it from the list of threads.
4230 (setcdr prev (cdr threads))
4231 (setq threads prev))))
4232 (setq prev threads)
4233 (setq threads (cdr threads)))
4234 result))
4235
4236 (defun gnus-sort-gathered-threads (threads)
4237 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4238 (let ((result threads))
4239 (while threads
4240 (when (stringp (caar threads))
4241 (setcdr (car threads)
4242 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4243 (setq threads (cdr threads)))
4244 result))
4245
4246 (defun gnus-thread-loop-p (root thread)
4247 "Say whether ROOT is in THREAD."
4248 (let ((stack (list thread))
4249 (infloop 0)
4250 th)
4251 (while (setq thread (pop stack))
4252 (setq th (cdr thread))
4253 (while (and th
4254 (not (eq (caar th) root)))
4255 (pop th))
4256 (if th
4257 ;; We have found a loop.
4258 (let (ref-dep)
4259 (setcdr thread (delq (car th) (cdr thread)))
4260 (if (boundp (setq ref-dep (intern "none"
4261 gnus-newsgroup-dependencies)))
4262 (setcdr (symbol-value ref-dep)
4263 (nconc (cdr (symbol-value ref-dep))
4264 (list (car th))))
4265 (set ref-dep (list nil (car th))))
4266 (setq infloop 1
4267 stack nil))
4268 ;; Push all the subthreads onto the stack.
4269 (push (cdr thread) stack)))
4270 infloop))
4271
4272 (defun gnus-make-threads ()
4273 "Go through the dependency hashtb and find the roots. Return all threads."
4274 (let (threads)
4275 (while (catch 'infloop
4276 (mapatoms
4277 (lambda (refs)
4278 ;; Deal with self-referencing References loops.
4279 (when (and (car (symbol-value refs))
4280 (not (zerop
4281 (apply
4282 '+
4283 (mapcar
4284 (lambda (thread)
4285 (gnus-thread-loop-p
4286 (car (symbol-value refs)) thread))
4287 (cdr (symbol-value refs)))))))
4288 (setq threads nil)
4289 (throw 'infloop t))
4290 (unless (car (symbol-value refs))
4291 ;; These threads do not refer back to any other
4292 ;; articles, so they're roots.
4293 (setq threads (append (cdr (symbol-value refs)) threads))))
4294 gnus-newsgroup-dependencies)))
4295 threads))
4296
4297 ;; Build the thread tree.
4298 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4299 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4300
4301 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4302 if it was already present.
4303
4304 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4305 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4306 Message-IDs will be renamed to a unique Message-ID before being
4307 entered.
4308
4309 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4310 (let* ((id (mail-header-id header))
4311 (id-dep (and id (intern id dependencies)))
4312 parent-id ref ref-dep ref-header replaced)
4313 ;; Enter this `header' in the `dependencies' table.
4314 (cond
4315 ((not id-dep)
4316 (setq header nil))
4317 ;; The first two cases do the normal part: enter a new `header'
4318 ;; in the `dependencies' table.
4319 ((not (boundp id-dep))
4320 (set id-dep (list header)))
4321 ((null (car (symbol-value id-dep)))
4322 (setcar (symbol-value id-dep) header))
4323
4324 ;; From here the `header' was already present in the
4325 ;; `dependencies' table.
4326 (force-new
4327 ;; Overrides an existing entry;
4328 ;; just set the header part of the entry.
4329 (setcar (symbol-value id-dep) header)
4330 (setq replaced t))
4331
4332 ;; Renames the existing `header' to a unique Message-ID.
4333 ((not gnus-summary-ignore-duplicates)
4334 ;; An article with this Message-ID has already been seen.
4335 ;; We rename the Message-ID.
4336 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4337 (list header))
4338 (mail-header-set-id header id))
4339
4340 ;; The last case ignores an existing entry, except it adds any
4341 ;; additional Xrefs (in case the two articles came from different
4342 ;; servers.
4343 ;; Also sets `header' to `nil' meaning that the `dependencies'
4344 ;; table was *not* modified.
4345 (t
4346 (mail-header-set-xref
4347 (car (symbol-value id-dep))
4348 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4349 "")
4350 (or (mail-header-xref header) "")))
4351 (setq header nil)))
4352
4353 (when (and header (not replaced))
4354 ;; First check that we are not creating a References loop.
4355 (setq parent-id (gnus-parent-id (mail-header-references header)))
4356 (setq ref parent-id)
4357 (while (and ref
4358 (setq ref-dep (intern-soft ref dependencies))
4359 (boundp ref-dep)
4360 (setq ref-header (car (symbol-value ref-dep))))
4361 (if (string= id ref)
4362 ;; Yuk! This is a reference loop. Make the article be a
4363 ;; root article.
4364 (progn
4365 (mail-header-set-references (car (symbol-value id-dep)) "none")
4366 (setq ref nil)
4367 (setq parent-id nil))
4368 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4369 (setq ref-dep (intern (or parent-id "none") dependencies))
4370 (if (boundp ref-dep)
4371 (setcdr (symbol-value ref-dep)
4372 (nconc (cdr (symbol-value ref-dep))
4373 (list (symbol-value id-dep))))
4374 (set ref-dep (list nil (symbol-value id-dep)))))
4375 header))
4376
4377 (defun gnus-extract-message-id-from-in-reply-to (string)
4378 (if (string-match "<[^>]+>" string)
4379 (substring string (match-beginning 0) (match-end 0))
4380 nil))
4381
4382 (defun gnus-build-sparse-threads ()
4383 (let ((headers gnus-newsgroup-headers)
4384 (mail-parse-charset gnus-newsgroup-charset)
4385 (gnus-summary-ignore-duplicates t)
4386 header references generation relations
4387 subject child end new-child date)
4388 ;; First we create an alist of generations/relations, where
4389 ;; generations is how much we trust the relation, and the relation
4390 ;; is parent/child.
4391 (gnus-message 7 "Making sparse threads...")
4392 (save-excursion
4393 (nnheader-set-temp-buffer " *gnus sparse threads*")
4394 (while (setq header (pop headers))
4395 (when (and (setq references (mail-header-references header))
4396 (not (string= references "")))
4397 (insert references)
4398 (setq child (mail-header-id header)
4399 subject (mail-header-subject header)
4400 date (mail-header-date header)
4401 generation 0)
4402 (while (search-backward ">" nil t)
4403 (setq end (1+ (point)))
4404 (when (search-backward "<" nil t)
4405 (setq new-child (buffer-substring (point) end))
4406 (push (list (incf generation)
4407 child (setq child new-child)
4408 subject date)
4409 relations)))
4410 (when child
4411 (push (list (1+ generation) child nil subject) relations))
4412 (erase-buffer)))
4413 (kill-buffer (current-buffer)))
4414 ;; Sort over trustworthiness.
4415 (dolist (relation (sort relations 'car-less-than-car))
4416 (when (gnus-dependencies-add-header
4417 (make-full-mail-header
4418 gnus-reffed-article-number
4419 (nth 3 relation) "" (or (nth 4 relation) "")
4420 (nth 1 relation)
4421 (or (nth 2 relation) "") 0 0 "")
4422 gnus-newsgroup-dependencies nil)
4423 (push gnus-reffed-article-number gnus-newsgroup-limit)
4424 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4425 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4426 gnus-newsgroup-reads)
4427 (decf gnus-reffed-article-number)))
4428 (gnus-message 7 "Making sparse threads...done")))
4429
4430 (defun gnus-build-old-threads ()
4431 ;; Look at all the articles that refer back to old articles, and
4432 ;; fetch the headers for the articles that aren't there. This will
4433 ;; build complete threads - if the roots haven't been expired by the
4434 ;; server, that is.
4435 (let ((mail-parse-charset gnus-newsgroup-charset)
4436 id heads)
4437 (mapatoms
4438 (lambda (refs)
4439 (when (not (car (symbol-value refs)))
4440 (setq heads (cdr (symbol-value refs)))
4441 (while heads
4442 (if (memq (mail-header-number (caar heads))
4443 gnus-newsgroup-dormant)
4444 (setq heads (cdr heads))
4445 (setq id (symbol-name refs))
4446 (while (and (setq id (gnus-build-get-header id))
4447 (not (car (gnus-id-to-thread id)))))
4448 (setq heads nil)))))
4449 gnus-newsgroup-dependencies)))
4450
4451 (defsubst gnus-remove-odd-characters (string)
4452 "Translate STRING into something that doesn't contain weird characters."
4453 (mm-subst-char-in-string
4454 ?\r ?\-
4455 (mm-subst-char-in-string ?\n ?\- string t) t))
4456
4457 ;; This function has to be called with point after the article number
4458 ;; on the beginning of the line.
4459 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4460 (let ((eol (point-at-eol))
4461 (buffer (current-buffer))
4462 header references in-reply-to)
4463
4464 ;; overview: [num subject from date id refs chars lines misc]
4465 (unwind-protect
4466 (let (x)
4467 (narrow-to-region (point) eol)
4468 (unless (eobp)
4469 (forward-char))
4470
4471 (setq header
4472 (make-full-mail-header
4473 number ; number
4474 (condition-case () ; subject
4475 (gnus-remove-odd-characters
4476 (funcall gnus-decode-encoded-word-function
4477 (setq x (nnheader-nov-field))))
4478 (error x))
4479 (condition-case () ; from
4480 (gnus-remove-odd-characters
4481 (funcall gnus-decode-encoded-address-function
4482 (setq x (nnheader-nov-field))))
4483 (error x))
4484 (nnheader-nov-field) ; date
4485 (nnheader-nov-read-message-id number) ; id
4486 (setq references (nnheader-nov-field)) ; refs
4487 (nnheader-nov-read-integer) ; chars
4488 (nnheader-nov-read-integer) ; lines
4489 (unless (eobp)
4490 (if (looking-at "Xref: ")
4491 (goto-char (match-end 0)))
4492 (nnheader-nov-field)) ; Xref
4493 (nnheader-nov-parse-extra)))) ; extra
4494
4495 (widen))
4496
4497 (when (and (string= references "")
4498 (setq in-reply-to (mail-header-extra header))
4499 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4500 (mail-header-set-references
4501 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4502
4503 (when gnus-alter-header-function
4504 (funcall gnus-alter-header-function header))
4505 (gnus-dependencies-add-header header dependencies force-new)))
4506
4507 (defun gnus-build-get-header (id)
4508 "Look through the buffer of NOV lines and find the header to ID.
4509 Enter this line into the dependencies hash table, and return
4510 the id of the parent article (if any)."
4511 (let ((deps gnus-newsgroup-dependencies)
4512 found header)
4513 (prog1
4514 (with-current-buffer nntp-server-buffer
4515 (let ((case-fold-search nil))
4516 (goto-char (point-min))
4517 (while (and (not found)
4518 (search-forward id nil t))
4519 (beginning-of-line)
4520 (setq found (looking-at
4521 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4522 (regexp-quote id))))
4523 (or found (beginning-of-line 2)))
4524 (when found
4525 (beginning-of-line)
4526 (and
4527 (setq header (gnus-nov-parse-line
4528 (read (current-buffer)) deps))
4529 (gnus-parent-id (mail-header-references header))))))
4530 (when header
4531 (let ((number (mail-header-number header)))
4532 (push number gnus-newsgroup-limit)
4533 (push header gnus-newsgroup-headers)
4534 (if (memq number gnus-newsgroup-unselected)
4535 (progn
4536 (setq gnus-newsgroup-unreads
4537 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4538 number))
4539 (setq gnus-newsgroup-unselected
4540 (delq number gnus-newsgroup-unselected)))
4541 (push number gnus-newsgroup-ancient)))))))
4542
4543 (defun gnus-build-all-threads ()
4544 "Read all the headers."
4545 (let ((gnus-summary-ignore-duplicates t)
4546 (mail-parse-charset gnus-newsgroup-charset)
4547 (dependencies gnus-newsgroup-dependencies)
4548 header article)
4549 (with-current-buffer nntp-server-buffer
4550 (let ((case-fold-search nil))
4551 (goto-char (point-min))
4552 (while (not (eobp))
4553 (ignore-errors
4554 (setq article (read (current-buffer))
4555 header (gnus-nov-parse-line article dependencies t)))
4556 (when header
4557 (with-current-buffer gnus-summary-buffer
4558 (push header gnus-newsgroup-headers)
4559 (if (memq (setq article (mail-header-number header))
4560 gnus-newsgroup-unselected)
4561 (progn
4562 (setq gnus-newsgroup-unreads
4563 (gnus-add-to-sorted-list
4564 gnus-newsgroup-unreads article))
4565 (setq gnus-newsgroup-unselected
4566 (delq article gnus-newsgroup-unselected)))
4567 (push article gnus-newsgroup-ancient)))
4568 (forward-line 1)))))))
4569
4570 (defun gnus-summary-update-article-line (article header)
4571 "Update the line for ARTICLE using HEADER."
4572 (let* ((id (mail-header-id header))
4573 (thread (gnus-id-to-thread id)))
4574 (unless thread
4575 (error "Article in no thread"))
4576 ;; Update the thread.
4577 (setcar thread header)
4578 (gnus-summary-goto-subject article)
4579 (let* ((datal (gnus-data-find-list article))
4580 (data (car datal))
4581 (inhibit-read-only t)
4582 (level (gnus-summary-thread-level)))
4583 (gnus-delete-line)
4584 (let ((inserted (- (point)
4585 (progn
4586 (gnus-summary-insert-line
4587 header level nil
4588 (memq article gnus-newsgroup-undownloaded)
4589 (gnus-article-mark article)
4590 (memq article gnus-newsgroup-replied)
4591 (memq article gnus-newsgroup-expirable)
4592 ;; Only insert the Subject string when it's different
4593 ;; from the previous Subject string.
4594 (if (and
4595 gnus-show-threads
4596 (gnus-subject-equal
4597 (condition-case ()
4598 (mail-header-subject
4599 (gnus-data-header
4600 (cadr
4601 (gnus-data-find-list
4602 article
4603 (gnus-data-list t)))))
4604 ;; Error on the side of excessive subjects.
4605 (error ""))
4606 (mail-header-subject header)))
4607 ""
4608 (mail-header-subject header))
4609 nil (cdr (assq article gnus-newsgroup-scored))
4610 (memq article gnus-newsgroup-processable))
4611 (point)))))
4612 (when (cdr datal)
4613 (gnus-data-update-list
4614 (cdr datal)
4615 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4616
4617 (defun gnus-summary-update-article (article &optional iheader)
4618 "Update ARTICLE in the summary buffer."
4619 (set-buffer gnus-summary-buffer)
4620 (let* ((header (gnus-summary-article-header article))
4621 (id (mail-header-id header))
4622 (data (gnus-data-find article))
4623 (thread (gnus-id-to-thread id))
4624 (references (mail-header-references header))
4625 (parent
4626 (gnus-id-to-thread
4627 (or (gnus-parent-id
4628 (when (and references
4629 (not (equal "" references)))
4630 references))
4631 "none")))
4632 (inhibit-read-only t)
4633 (old (car thread)))
4634 (when thread
4635 (unless iheader
4636 (setcar thread nil)
4637 (when parent
4638 (delq thread parent)))
4639 (if (gnus-summary-insert-subject id header)
4640 ;; Set the (possibly) new article number in the data structure.
4641 (gnus-data-set-number data (gnus-id-to-article id))
4642 (setcar thread old)
4643 nil))))
4644
4645 (defun gnus-rebuild-thread (id &optional line)
4646 "Rebuild the thread containing ID.
4647 If LINE, insert the rebuilt thread starting on line LINE."
4648 (let ((inhibit-read-only t)
4649 old-pos current thread data)
4650 (if (not gnus-show-threads)
4651 (setq thread (list (car (gnus-id-to-thread id))))
4652 ;; Get the thread this article is part of.
4653 (setq thread (gnus-remove-thread id)))
4654 (setq old-pos (point-at-bol))
4655 (setq current (save-excursion
4656 (and (re-search-backward "[\r\n]" nil t)
4657 (gnus-summary-article-number))))
4658 ;; If this is a gathered thread, we have to go some re-gathering.
4659 (when (stringp (car thread))
4660 (let ((subject (car thread))
4661 roots thr)
4662 (setq thread (cdr thread))
4663 (while thread
4664 (unless (memq (setq thr (gnus-id-to-thread
4665 (gnus-root-id
4666 (mail-header-id (caar thread)))))
4667 roots)
4668 (push thr roots))
4669 (setq thread (cdr thread)))
4670 ;; We now have all (unique) roots.
4671 (if (= (length roots) 1)
4672 ;; All the loose roots are now one solid root.
4673 (setq thread (car roots))
4674 (setq thread (cons subject (gnus-sort-threads roots))))))
4675 (let (threads)
4676 ;; We then insert this thread into the summary buffer.
4677 (when line
4678 (goto-char (point-min))
4679 (forward-line (1- line)))
4680 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4681 (if gnus-show-threads
4682 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4683 (gnus-summary-prepare-unthreaded thread))
4684 (setq data (nreverse gnus-newsgroup-data))
4685 (setq threads gnus-newsgroup-threads))
4686 ;; We splice the new data into the data structure.
4687 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4688 ;;!!! then we want to insert at the beginning of the buffer.
4689 ;;!!! That happens to be true with Gnus now, but that may
4690 ;;!!! change in the future. Perhaps.
4691 (gnus-data-enter-list
4692 (if line nil current) data (- (point) old-pos))
4693 (setq gnus-newsgroup-threads
4694 (nconc threads gnus-newsgroup-threads))
4695 (gnus-data-compute-positions))))
4696
4697 (defun gnus-number-to-header (number)
4698 "Return the header for article NUMBER."
4699 (let ((headers gnus-newsgroup-headers))
4700 (while (and headers
4701 (not (= number (mail-header-number (car headers)))))
4702 (pop headers))
4703 (when headers
4704 (car headers))))
4705
4706 (defun gnus-parent-headers (in-headers &optional generation)
4707 "Return the headers of the GENERATIONth parent of HEADERS."
4708 (unless generation
4709 (setq generation 1))
4710 (let ((parent t)
4711 (headers in-headers)
4712 references)
4713 (while (and parent
4714 (not (zerop generation))
4715 (setq references (mail-header-references headers)))
4716 (setq headers (if (and references
4717 (setq parent (gnus-parent-id references)))
4718 (car (gnus-id-to-thread parent))
4719 nil))
4720 (decf generation))
4721 (and (not (eq headers in-headers))
4722 headers)))
4723
4724 (defun gnus-id-to-thread (id)
4725 "Return the (sub-)thread where ID appears."
4726 (gnus-gethash id gnus-newsgroup-dependencies))
4727
4728 (defun gnus-id-to-article (id)
4729 "Return the article number of ID."
4730 (let ((thread (gnus-id-to-thread id)))
4731 (when (and thread
4732 (car thread))
4733 (mail-header-number (car thread)))))
4734
4735 (defun gnus-id-to-header (id)
4736 "Return the article headers of ID."
4737 (car (gnus-id-to-thread id)))
4738
4739 (defun gnus-article-displayed-root-p (article)
4740 "Say whether ARTICLE is a root(ish) article."
4741 (let ((level (gnus-summary-thread-level article))
4742 (refs (mail-header-references (gnus-summary-article-header article)))
4743 particle)
4744 (cond
4745 ((null level) nil)
4746 ((zerop level) t)
4747 ((null refs) t)
4748 ((null (gnus-parent-id refs)) t)
4749 ((and (= 1 level)
4750 (null (setq particle (gnus-id-to-article
4751 (gnus-parent-id refs))))
4752 (null (gnus-summary-thread-level particle)))))))
4753
4754 (defun gnus-root-id (id)
4755 "Return the id of the root of the thread where ID appears."
4756 (let (last-id prev)
4757 (while (and id (setq prev (car (gnus-id-to-thread id))))
4758 (setq last-id id
4759 id (gnus-parent-id (mail-header-references prev))))
4760 last-id))
4761
4762 (defun gnus-articles-in-thread (thread)
4763 "Return the list of articles in THREAD."
4764 (cons (mail-header-number (car thread))
4765 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4766
4767 (defun gnus-remove-thread (id &optional dont-remove)
4768 "Remove the thread that has ID in it."
4769 (let (headers thread last-id)
4770 ;; First go up in this thread until we find the root.
4771 (setq last-id (gnus-root-id id)
4772 headers (message-flatten-list (gnus-id-to-thread last-id)))
4773 ;; We have now found the real root of this thread. It might have
4774 ;; been gathered into some loose thread, so we have to search
4775 ;; through the threads to find the thread we wanted.
4776 (let ((threads gnus-newsgroup-threads)
4777 sub)
4778 (while threads
4779 (setq sub (car threads))
4780 (if (stringp (car sub))
4781 ;; This is a gathered thread, so we look at the roots
4782 ;; below it to find whether this article is in this
4783 ;; gathered root.
4784 (progn
4785 (setq sub (cdr sub))
4786 (while sub
4787 (when (member (caar sub) headers)
4788 (setq thread (car threads)
4789 threads nil
4790 sub nil))
4791 (setq sub (cdr sub))))
4792 ;; It's an ordinary thread, so we check it.
4793 (when (eq (car sub) (car headers))
4794 (setq thread sub
4795 threads nil)))
4796 (setq threads (cdr threads)))
4797 ;; If this article is in no thread, then it's a root.
4798 (if thread
4799 (unless dont-remove
4800 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4801 (setq thread (gnus-id-to-thread last-id)))
4802 (when thread
4803 (prog1
4804 thread ; We return this thread.
4805 (unless dont-remove
4806 (if (stringp (car thread))
4807 (progn
4808 ;; If we use dummy roots, then we have to remove the
4809 ;; dummy root as well.
4810 (when (eq gnus-summary-make-false-root 'dummy)
4811 ;; We go to the dummy root by going to
4812 ;; the first sub-"thread", and then one line up.
4813 (gnus-summary-goto-article
4814 (mail-header-number (caadr thread)))
4815 (forward-line -1)
4816 (gnus-delete-line)
4817 (gnus-data-compute-positions))
4818 (setq thread (cdr thread))
4819 (while thread
4820 (gnus-remove-thread-1 (car thread))
4821 (setq thread (cdr thread))))
4822 (gnus-remove-thread-1 thread))))))))
4823
4824 (defun gnus-remove-thread-1 (thread)
4825 "Remove the thread THREAD recursively."
4826 (let ((number (mail-header-number (pop thread)))
4827 d)
4828 (setq thread (reverse thread))
4829 (while thread
4830 (gnus-remove-thread-1 (pop thread)))
4831 (when (setq d (gnus-data-find number))
4832 (goto-char (gnus-data-pos d))
4833 (gnus-summary-show-thread)
4834 (gnus-data-remove
4835 number
4836 (- (point-at-bol)
4837 (prog1
4838 (1+ (point-at-eol))
4839 (gnus-delete-line)))))))
4840
4841 (defun gnus-sort-threads-recursive (threads func)
4842 (sort (mapcar (lambda (thread)
4843 (cons (car thread)
4844 (and (cdr thread)
4845 (gnus-sort-threads-recursive (cdr thread) func))))
4846 threads) func))
4847
4848 (defun gnus-sort-threads-loop (threads func)
4849 (let* ((superthread (cons nil threads))
4850 (stack (list (cons superthread threads)))
4851 remaining-threads thread)
4852 (while stack
4853 (setq remaining-threads (cdr (car stack)))
4854 (if remaining-threads
4855 (progn (setq thread (car remaining-threads))
4856 (setcdr (car stack) (cdr remaining-threads))
4857 (if (cdr thread)
4858 (push (cons thread (cdr thread)) stack)))
4859 (setq thread (caar stack))
4860 (setcdr thread (sort (cdr thread) func))
4861 (pop stack)))
4862 (cdr superthread)))
4863
4864 (defun gnus-sort-threads (threads)
4865 "Sort THREADS."
4866 (if (not gnus-thread-sort-functions)
4867 threads
4868 (gnus-message 8 "Sorting threads...")
4869 (prog1
4870 (condition-case nil
4871 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4872 (gnus-sort-threads-recursive
4873 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4874 ;; Even after binding max-lisp-eval-depth, the recursive
4875 ;; sorter might fail for very long threads. In that case,
4876 ;; try using a (less well-tested) non-recursive sorter.
4877 (error (gnus-message 9 "Sorting threads with loop...")
4878 (gnus-sort-threads-loop
4879 threads (gnus-make-sort-function
4880 gnus-thread-sort-functions))))
4881 (gnus-message 8 "Sorting threads...done"))))
4882
4883 (defun gnus-sort-articles (articles)
4884 "Sort ARTICLES."
4885 (when gnus-article-sort-functions
4886 (gnus-message 7 "Sorting articles...")
4887 (prog1
4888 (setq gnus-newsgroup-headers
4889 (sort articles (gnus-make-sort-function
4890 gnus-article-sort-functions)))
4891 (gnus-message 7 "Sorting articles...done"))))
4892
4893 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4894 (defmacro gnus-thread-header (thread)
4895 "Return header of first article in THREAD.
4896 Note that THREAD must never, ever be anything else than a variable -
4897 using some other form will lead to serious barfage."
4898 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4899 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4900 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4901 (vector thread) 2))
4902
4903 (defsubst gnus-article-sort-by-number (h1 h2)
4904 "Sort articles by article number."
4905 (< (mail-header-number h1)
4906 (mail-header-number h2)))
4907
4908 (defun gnus-thread-sort-by-number (h1 h2)
4909 "Sort threads by root article number."
4910 (gnus-article-sort-by-number
4911 (gnus-thread-header h1) (gnus-thread-header h2)))
4912
4913 (defsubst gnus-article-sort-by-random (h1 h2)
4914 "Sort articles randomly."
4915 (zerop (random 2)))
4916
4917 (defun gnus-thread-sort-by-random (h1 h2)
4918 "Sort threads randomly."
4919 (gnus-article-sort-by-random
4920 (gnus-thread-header h1) (gnus-thread-header h2)))
4921
4922 (defsubst gnus-article-sort-by-lines (h1 h2)
4923 "Sort articles by article Lines header."
4924 (< (mail-header-lines h1)
4925 (mail-header-lines h2)))
4926
4927 (defun gnus-thread-sort-by-lines (h1 h2)
4928 "Sort threads by root article Lines header."
4929 (gnus-article-sort-by-lines
4930 (gnus-thread-header h1) (gnus-thread-header h2)))
4931
4932 (defsubst gnus-article-sort-by-chars (h1 h2)
4933 "Sort articles by octet length."
4934 (< (mail-header-chars h1)
4935 (mail-header-chars h2)))
4936
4937 (defun gnus-thread-sort-by-chars (h1 h2)
4938 "Sort threads by root article octet length."
4939 (gnus-article-sort-by-chars
4940 (gnus-thread-header h1) (gnus-thread-header h2)))
4941
4942 (defsubst gnus-article-sort-by-author (h1 h2)
4943 "Sort articles by root author."
4944 (gnus-string<
4945 (let ((extract (funcall
4946 gnus-extract-address-components
4947 (mail-header-from h1))))
4948 (or (car extract) (cadr extract) ""))
4949 (let ((extract (funcall
4950 gnus-extract-address-components
4951 (mail-header-from h2))))
4952 (or (car extract) (cadr extract) ""))))
4953
4954 (defun gnus-thread-sort-by-author (h1 h2)
4955 "Sort threads by root author."
4956 (gnus-article-sort-by-author
4957 (gnus-thread-header h1) (gnus-thread-header h2)))
4958
4959 (defsubst gnus-article-sort-by-recipient (h1 h2)
4960 "Sort articles by recipient."
4961 (gnus-string<
4962 (let ((extract (funcall
4963 gnus-extract-address-components
4964 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4965 (or (car extract) (cadr extract)))
4966 (let ((extract (funcall
4967 gnus-extract-address-components
4968 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4969 (or (car extract) (cadr extract)))))
4970
4971 (defun gnus-thread-sort-by-recipient (h1 h2)
4972 "Sort threads by root recipient."
4973 (gnus-article-sort-by-recipient
4974 (gnus-thread-header h1) (gnus-thread-header h2)))
4975
4976 (defsubst gnus-article-sort-by-subject (h1 h2)
4977 "Sort articles by root subject."
4978 (gnus-string<
4979 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4980 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4981
4982 (defun gnus-thread-sort-by-subject (h1 h2)
4983 "Sort threads by root subject."
4984 (gnus-article-sort-by-subject
4985 (gnus-thread-header h1) (gnus-thread-header h2)))
4986
4987 (defsubst gnus-article-sort-by-date (h1 h2)
4988 "Sort articles by root article date."
4989 (time-less-p
4990 (gnus-date-get-time (mail-header-date h1))
4991 (gnus-date-get-time (mail-header-date h2))))
4992
4993 (defun gnus-thread-sort-by-date (h1 h2)
4994 "Sort threads by root article date."
4995 (gnus-article-sort-by-date
4996 (gnus-thread-header h1) (gnus-thread-header h2)))
4997
4998 (defsubst gnus-article-sort-by-score (h1 h2)
4999 "Sort articles by root article score.
5000 Unscored articles will be counted as having a score of zero."
5001 (> (or (cdr (assq (mail-header-number h1)
5002 gnus-newsgroup-scored))
5003 gnus-summary-default-score 0)
5004 (or (cdr (assq (mail-header-number h2)
5005 gnus-newsgroup-scored))
5006 gnus-summary-default-score 0)))
5007
5008 (defun gnus-thread-sort-by-score (h1 h2)
5009 "Sort threads by root article score."
5010 (gnus-article-sort-by-score
5011 (gnus-thread-header h1) (gnus-thread-header h2)))
5012
5013 (defun gnus-thread-sort-by-total-score (h1 h2)
5014 "Sort threads by the sum of all scores in the thread.
5015 Unscored articles will be counted as having a score of zero."
5016 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5017
5018 (defun gnus-thread-total-score (thread)
5019 ;; This function find the total score of THREAD.
5020 (cond
5021 ((null thread)
5022 0)
5023 ((consp thread)
5024 (if (stringp (car thread))
5025 (apply gnus-thread-score-function 0
5026 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5027 (gnus-thread-total-score-1 thread)))
5028 (t
5029 (gnus-thread-total-score-1 (list thread)))))
5030
5031 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5032 "Sort articles by number."
5033 (gnus-article-sort-by-number h1 h2))
5034
5035 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5036 "Sort threads such that the thread with the most recently arrived article comes first."
5037 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5038
5039 (defun gnus-thread-highest-number (thread)
5040 "Return the highest article number in THREAD."
5041 (apply 'max (mapcar (lambda (header)
5042 (mail-header-number header))
5043 (message-flatten-list thread))))
5044
5045 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5046 "Sort articles by number."
5047 (gnus-article-sort-by-date h1 h2))
5048
5049 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5050 "Sort threads such that the thread with the most recently dated article comes first."
5051 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5052
5053 ; Since this is called not only to sort the top-level threads, but
5054 ; also in recursive sorts to order the articles within a thread, each
5055 ; article will be processed many times. Thus it speeds things up
5056 ; quite a bit to use gnus-date-get-time, which caches the time value.
5057 (defun gnus-thread-latest-date (thread)
5058 "Return the highest article date in THREAD."
5059 (apply 'max
5060 (mapcar (lambda (header) (gnus-float-time
5061 (gnus-date-get-time
5062 (mail-header-date header))))
5063 (message-flatten-list thread))))
5064
5065 (defun gnus-thread-total-score-1 (root)
5066 ;; This function find the total score of the thread below ROOT.
5067 (setq root (car root))
5068 (apply gnus-thread-score-function
5069 (or (append
5070 (mapcar 'gnus-thread-total-score
5071 (cdr (gnus-id-to-thread (mail-header-id root))))
5072 (when (> (mail-header-number root) 0)
5073 (list (or (cdr (assq (mail-header-number root)
5074 gnus-newsgroup-scored))
5075 gnus-summary-default-score 0))))
5076 (list gnus-summary-default-score)
5077 '(0))))
5078
5079 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5080 (defvar gnus-tmp-prev-subject nil)
5081 (defvar gnus-tmp-false-parent nil)
5082 (defvar gnus-tmp-root-expunged nil)
5083 (defvar gnus-tmp-dummy-line nil)
5084
5085 (defun gnus-extra-header (type &optional header)
5086 "Return the extra header of TYPE."
5087 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5088 ""))
5089
5090 (defvar gnus-tmp-thread-tree-header-string "")
5091
5092 (defcustom gnus-sum-thread-tree-root "> "
5093 "With %B spec, used for the root of a thread.
5094 If nil, use subject instead."
5095 :version "22.1"
5096 :type '(radio (const :format "%v " nil) string)
5097 :group 'gnus-thread)
5098
5099 (defcustom gnus-sum-thread-tree-false-root "> "
5100 "With %B spec, used for a false root of a thread.
5101 If nil, use subject instead."
5102 :version "22.1"
5103 :type '(radio (const :format "%v " nil) string)
5104 :group 'gnus-thread)
5105
5106 (defcustom gnus-sum-thread-tree-single-indent ""
5107 "With %B spec, used for a thread with just one message.
5108 If nil, use subject instead."
5109 :version "22.1"
5110 :type '(radio (const :format "%v " nil) string)
5111 :group 'gnus-thread)
5112
5113 (defcustom gnus-sum-thread-tree-vertical "| "
5114 "With %B spec, used for drawing a vertical line."
5115 :version "22.1"
5116 :type 'string
5117 :group 'gnus-thread)
5118
5119 (defcustom gnus-sum-thread-tree-indent " "
5120 "With %B spec, used for indenting."
5121 :version "22.1"
5122 :type 'string
5123 :group 'gnus-thread)
5124
5125 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5126 "With %B spec, used for a leaf with brothers."
5127 :version "22.1"
5128 :type 'string
5129 :group 'gnus-thread)
5130
5131 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5132 "With %B spec, used for a leaf without brothers."
5133 :version "22.1"
5134 :type 'string
5135 :group 'gnus-thread)
5136
5137 (defcustom gnus-summary-display-while-building nil
5138 "If non-nil, show and update the summary buffer as it's being built.
5139 If the value is t, update the buffer after every line is inserted. If
5140 the value is an integer (N), update the display every N lines."
5141 :version "22.1"
5142 :group 'gnus-thread
5143 :type '(choice (const :tag "off" nil)
5144 number
5145 (const :tag "frequently" t)))
5146
5147 (defun gnus-summary-prepare-threads (threads)
5148 "Prepare summary buffer from THREADS and indentation LEVEL.
5149 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5150 or a straight list of headers."
5151 (gnus-message 7 "Generating summary...")
5152
5153 (setq gnus-newsgroup-threads threads)
5154 (beginning-of-line)
5155
5156 (let ((gnus-tmp-level 0)
5157 (default-score (or gnus-summary-default-score 0))
5158 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5159 (building-line-count gnus-summary-display-while-building)
5160 (building-count (integerp gnus-summary-display-while-building))
5161 thread number subject stack state gnus-tmp-gathered beg-match
5162 new-roots gnus-tmp-new-adopts thread-end simp-subject
5163 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5164 gnus-tmp-replied gnus-tmp-subject-or-nil
5165 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5166 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5167 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5168 tree-stack)
5169
5170 (setq gnus-tmp-prev-subject nil
5171 gnus-tmp-thread-tree-header-string "")
5172
5173 (if (vectorp (car threads))
5174 ;; If this is a straight (sic) list of headers, then a
5175 ;; threaded summary display isn't required, so we just create
5176 ;; an unthreaded one.
5177 (gnus-summary-prepare-unthreaded threads)
5178
5179 ;; Do the threaded display.
5180
5181 (if gnus-summary-display-while-building
5182 (switch-to-buffer (buffer-name)))
5183 (while (or threads stack gnus-tmp-new-adopts new-roots)
5184
5185 (if (and (= gnus-tmp-level 0)
5186 (or (not stack)
5187 (= (caar stack) 0))
5188 (not gnus-tmp-false-parent)
5189 (or gnus-tmp-new-adopts new-roots))
5190 (if gnus-tmp-new-adopts
5191 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5192 thread (list (car gnus-tmp-new-adopts))
5193 gnus-tmp-header (caar thread)
5194 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5195 (when new-roots
5196 (setq thread (list (car new-roots))
5197 gnus-tmp-header (caar thread)
5198 new-roots (cdr new-roots))))
5199
5200 (if threads
5201 ;; If there are some threads, we do them before the
5202 ;; threads on the stack.
5203 (setq thread threads
5204 gnus-tmp-header (caar thread))
5205 ;; There were no current threads, so we pop something off
5206 ;; the stack.
5207 (setq state (car stack)
5208 gnus-tmp-level (car state)
5209 tree-stack (cadr state)
5210 thread (caddr state)
5211 stack (cdr stack)
5212 gnus-tmp-header (caar thread))))
5213
5214 (setq gnus-tmp-false-parent nil)
5215 (setq gnus-tmp-root-expunged nil)
5216 (setq thread-end nil)
5217
5218 (if (stringp gnus-tmp-header)
5219 ;; The header is a dummy root.
5220 (cond
5221 ((eq gnus-summary-make-false-root 'adopt)
5222 ;; We let the first article adopt the rest.
5223 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5224 (cddar thread)))
5225 (setq gnus-tmp-gathered
5226 (nconc (mapcar
5227 (lambda (h) (mail-header-number (car h)))
5228 (cddar thread))
5229 gnus-tmp-gathered))
5230 (setq thread (cons (list (caar thread)
5231 (cadar thread))
5232 (cdr thread)))
5233 (setq gnus-tmp-level -1
5234 gnus-tmp-false-parent t))
5235 ((eq gnus-summary-make-false-root 'empty)
5236 ;; We print adopted articles with empty subject fields.
5237 (setq gnus-tmp-gathered
5238 (nconc (mapcar
5239 (lambda (h) (mail-header-number (car h)))
5240 (cddar thread))
5241 gnus-tmp-gathered))
5242 (setq gnus-tmp-level -1))
5243 ((eq gnus-summary-make-false-root 'dummy)
5244 ;; We remember that we probably want to output a dummy
5245 ;; root.
5246 (setq gnus-tmp-dummy-line gnus-tmp-header)
5247 (setq gnus-tmp-prev-subject gnus-tmp-header))
5248 (t
5249 ;; We do not make a root for the gathered
5250 ;; sub-threads at all.
5251 (setq gnus-tmp-level -1)))
5252
5253 (setq number (mail-header-number gnus-tmp-header)
5254 subject (mail-header-subject gnus-tmp-header)
5255 simp-subject (gnus-simplify-subject-fully subject))
5256
5257 (cond
5258 ;; If the thread has changed subject, we might want to make
5259 ;; this subthread into a root.
5260 ((and (null gnus-thread-ignore-subject)
5261 (not (zerop gnus-tmp-level))
5262 gnus-tmp-prev-subject
5263 (not (string= gnus-tmp-prev-subject simp-subject)))
5264 (setq new-roots (nconc new-roots (list (car thread)))
5265 thread-end t
5266 gnus-tmp-header nil))
5267 ;; If the article lies outside the current limit,
5268 ;; then we do not display it.
5269 ((not (memq number gnus-newsgroup-limit))
5270 (setq gnus-tmp-gathered
5271 (nconc (mapcar
5272 (lambda (h) (mail-header-number (car h)))
5273 (cdar thread))
5274 gnus-tmp-gathered))
5275 (setq gnus-tmp-new-adopts (if (cdar thread)
5276 (append gnus-tmp-new-adopts
5277 (cdar thread))
5278 gnus-tmp-new-adopts)
5279 thread-end t
5280 gnus-tmp-header nil)
5281 (when (zerop gnus-tmp-level)
5282 (setq gnus-tmp-root-expunged t)))
5283 ;; Perhaps this article is to be marked as read?
5284 ((and gnus-summary-mark-below
5285 (< (or (cdr (assq number gnus-newsgroup-scored))
5286 default-score)
5287 gnus-summary-mark-below)
5288 ;; Don't touch sparse articles.
5289 (not (gnus-summary-article-sparse-p number))
5290 (not (gnus-summary-article-ancient-p number)))
5291 (setq gnus-newsgroup-unreads
5292 (delq number gnus-newsgroup-unreads))
5293 (if gnus-newsgroup-auto-expire
5294 (setq gnus-newsgroup-expirable
5295 (gnus-add-to-sorted-list
5296 gnus-newsgroup-expirable number))
5297 (push (cons number gnus-low-score-mark)
5298 gnus-newsgroup-reads))))
5299
5300 (when gnus-tmp-header
5301 ;; We may have an old dummy line to output before this
5302 ;; article.
5303 (when (and gnus-tmp-dummy-line
5304 (gnus-subject-equal
5305 gnus-tmp-dummy-line
5306 (mail-header-subject gnus-tmp-header)))
5307 (gnus-summary-insert-dummy-line
5308 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5309 (setq gnus-tmp-dummy-line nil))
5310
5311 ;; Compute the mark.
5312 (setq gnus-tmp-unread (gnus-article-mark number))
5313
5314 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5315 gnus-tmp-header gnus-tmp-level)
5316 gnus-newsgroup-data)
5317
5318 ;; Actually insert the line.
5319 (setq
5320 gnus-tmp-subject-or-nil
5321 (cond
5322 ((and gnus-thread-ignore-subject
5323 gnus-tmp-prev-subject
5324 (not (string= gnus-tmp-prev-subject simp-subject)))
5325 subject)
5326 ((zerop gnus-tmp-level)
5327 (if (and (eq gnus-summary-make-false-root 'empty)
5328 (memq number gnus-tmp-gathered)
5329 gnus-tmp-prev-subject
5330 (string= gnus-tmp-prev-subject simp-subject))
5331 gnus-summary-same-subject
5332 subject))
5333 (t gnus-summary-same-subject)))
5334 (if (and (eq gnus-summary-make-false-root 'adopt)
5335 (= gnus-tmp-level 1)
5336 (memq number gnus-tmp-gathered))
5337 (setq gnus-tmp-opening-bracket ?\<
5338 gnus-tmp-closing-bracket ?\>)
5339 (setq gnus-tmp-opening-bracket ?\[
5340 gnus-tmp-closing-bracket ?\]))
5341 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5342 (gnus-make-thread-indent-array
5343 (max (* 2 (length gnus-thread-indent-array))
5344 gnus-tmp-level)))
5345 (setq
5346 gnus-tmp-indentation
5347 (aref gnus-thread-indent-array gnus-tmp-level)
5348 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5349 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5350 gnus-summary-default-score 0)
5351 gnus-tmp-score-char
5352 (if (or (null gnus-summary-default-score)
5353 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5354 gnus-summary-zcore-fuzz))
5355 ? ;Whitespace
5356 (if (< gnus-tmp-score gnus-summary-default-score)
5357 gnus-score-below-mark gnus-score-over-mark))
5358 gnus-tmp-replied
5359 (cond ((memq number gnus-newsgroup-processable)
5360 gnus-process-mark)
5361 ((memq number gnus-newsgroup-cached)
5362 gnus-cached-mark)
5363 ((memq number gnus-newsgroup-replied)
5364 gnus-replied-mark)
5365 ((memq number gnus-newsgroup-forwarded)
5366 gnus-forwarded-mark)
5367 ((memq number gnus-newsgroup-saved)
5368 gnus-saved-mark)
5369 ((memq number gnus-newsgroup-unseen)
5370 gnus-unseen-mark)
5371 (t gnus-no-mark))
5372 gnus-tmp-downloaded
5373 (cond ((memq number gnus-newsgroup-undownloaded)
5374 gnus-undownloaded-mark)
5375 (gnus-newsgroup-agentized
5376 gnus-downloaded-mark)
5377 (t
5378 gnus-no-mark))
5379 gnus-tmp-from (mail-header-from gnus-tmp-header)
5380 gnus-tmp-name
5381 (cond
5382 ((string-match "<[^>]+> *$" gnus-tmp-from)
5383 (setq beg-match (match-beginning 0))
5384 (or (and (string-match "^\".+\"" gnus-tmp-from)
5385 (substring gnus-tmp-from 1 (1- (match-end 0))))
5386 (substring gnus-tmp-from 0 beg-match)))
5387 ((string-match "(.+)" gnus-tmp-from)
5388 (substring gnus-tmp-from
5389 (1+ (match-beginning 0)) (1- (match-end 0))))
5390 (t gnus-tmp-from))
5391
5392 ;; Do the %B string
5393 gnus-tmp-thread-tree-header-string
5394 (cond
5395 ((not gnus-show-threads) "")
5396 ((zerop gnus-tmp-level)
5397 (cond ((cdar thread)
5398 (or gnus-sum-thread-tree-root subject))
5399 (gnus-tmp-new-adopts
5400 (or gnus-sum-thread-tree-false-root subject))
5401 (t
5402 (or gnus-sum-thread-tree-single-indent subject))))
5403 (t
5404 (concat (apply 'concat
5405 (mapcar (lambda (item)
5406 (if (= item 1)
5407 gnus-sum-thread-tree-vertical
5408 gnus-sum-thread-tree-indent))
5409 (cdr (reverse tree-stack))))
5410 (if (nth 1 thread)
5411 gnus-sum-thread-tree-leaf-with-other
5412 gnus-sum-thread-tree-single-leaf)))))
5413 (when (string= gnus-tmp-name "")
5414 (setq gnus-tmp-name gnus-tmp-from))
5415 (unless (numberp gnus-tmp-lines)
5416 (setq gnus-tmp-lines -1))
5417 (if (= gnus-tmp-lines -1)
5418 (setq gnus-tmp-lines "?")
5419 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5420 (gnus-put-text-property
5421 (point)
5422 (progn (eval gnus-summary-line-format-spec) (point))
5423 'gnus-number number)
5424 (when gnus-visual-p
5425 (forward-line -1)
5426 (gnus-summary-highlight-line)
5427 (when gnus-summary-update-hook
5428 (gnus-run-hooks 'gnus-summary-update-hook))
5429 (forward-line 1))
5430
5431 (setq gnus-tmp-prev-subject simp-subject)))
5432
5433 (when (nth 1 thread)
5434 (push (list (max 0 gnus-tmp-level)
5435 (copy-sequence tree-stack)
5436 (nthcdr 1 thread))
5437 stack))
5438 (push (if (nth 1 thread) 1 0) tree-stack)
5439 (incf gnus-tmp-level)
5440 (setq threads (if thread-end nil (cdar thread)))
5441 (if gnus-summary-display-while-building
5442 (if building-count
5443 (progn
5444 ;; use a set frequency
5445 (setq building-line-count (1- building-line-count))
5446 (when (= building-line-count 0)
5447 (sit-for 0)
5448 (setq building-line-count
5449 gnus-summary-display-while-building)))
5450 ;; always
5451 (sit-for 0)))
5452 (unless threads
5453 (setq gnus-tmp-level 0)))))
5454 (gnus-message 7 "Generating summary...done"))
5455
5456 (defun gnus-summary-prepare-unthreaded (headers)
5457 "Generate an unthreaded summary buffer based on HEADERS."
5458 (let (header number mark)
5459
5460 (beginning-of-line)
5461
5462 (while headers
5463 ;; We may have to root out some bad articles...
5464 (when (memq (setq number (mail-header-number
5465 (setq header (pop headers))))
5466 gnus-newsgroup-limit)
5467 ;; Mark article as read when it has a low score.
5468 (when (and gnus-summary-mark-below
5469 (< (or (cdr (assq number gnus-newsgroup-scored))
5470 gnus-summary-default-score 0)
5471 gnus-summary-mark-below)
5472 (not (gnus-summary-article-ancient-p number)))
5473 (setq gnus-newsgroup-unreads
5474 (delq number gnus-newsgroup-unreads))
5475 (if gnus-newsgroup-auto-expire
5476 (push number gnus-newsgroup-expirable)
5477 (push (cons number gnus-low-score-mark)
5478 gnus-newsgroup-reads)))
5479
5480 (setq mark (gnus-article-mark number))
5481 (push (gnus-data-make number mark (1+ (point)) header 0)
5482 gnus-newsgroup-data)
5483 (gnus-summary-insert-line
5484 header 0 number
5485 (memq number gnus-newsgroup-undownloaded)
5486 mark (memq number gnus-newsgroup-replied)
5487 (memq number gnus-newsgroup-expirable)
5488 (mail-header-subject header) nil
5489 (cdr (assq number gnus-newsgroup-scored))
5490 (memq number gnus-newsgroup-processable))))))
5491
5492 (defun gnus-group-get-list-identifiers (group)
5493 "Get list identifier regexp for GROUP."
5494 (or (gnus-parameter-list-identifier group)
5495 (if (consp gnus-list-identifiers)
5496 (mapconcat 'identity gnus-list-identifiers " *\\|")
5497 gnus-list-identifiers)))
5498
5499 (defun gnus-summary-remove-list-identifiers ()
5500 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5501 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5502 changed subject)
5503 (when regexp
5504 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5505 (dolist (header gnus-newsgroup-headers)
5506 (setq subject (mail-header-subject header)
5507 changed nil)
5508 (while (string-match regexp subject)
5509 (setq subject
5510 (concat (substring subject 0 (match-beginning 1))
5511 (substring subject (match-end 0)))
5512 changed t))
5513 (when changed
5514 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5515 (setq subject
5516 (concat (substring subject 0 (match-beginning 1))
5517 (substring subject (match-end 1)))))
5518 (mail-header-set-subject header subject))))))
5519
5520 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5521 "Fetch headers of ARTICLES."
5522 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5523 (gnus-message 7 "Fetching headers for %s..." name)
5524 (prog1
5525 (if (eq 'nov
5526 (setq gnus-headers-retrieved-by
5527 (gnus-retrieve-headers
5528 articles gnus-newsgroup-name
5529 (or limit
5530 ;; We might want to fetch old headers, but
5531 ;; not if there is only 1 article.
5532 (and (or (and
5533 (not (eq gnus-fetch-old-headers 'some))
5534 (not (numberp gnus-fetch-old-headers)))
5535 (> (length articles) 1))
5536 gnus-fetch-old-headers)))))
5537 (gnus-get-newsgroup-headers-xover
5538 articles force-new dependencies gnus-newsgroup-name t)
5539 (gnus-get-newsgroup-headers dependencies force-new))
5540 (gnus-message 7 "Fetching headers for %s...done" name))))
5541
5542 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5543 "Select newsgroup GROUP.
5544 If READ-ALL is non-nil, all articles in the group are selected.
5545 If SELECT-ARTICLES, only select those articles from GROUP."
5546 (let* ((entry (gnus-group-entry group))
5547 ;;!!! Dirty hack; should be removed.
5548 (gnus-summary-ignore-duplicates
5549 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5550 t
5551 gnus-summary-ignore-duplicates))
5552 (info (nth 2 entry))
5553 charset articles fetched-articles cached)
5554
5555 (unless (gnus-check-server
5556 (set (make-local-variable 'gnus-current-select-method)
5557 (gnus-find-method-for-group group)))
5558 (error "Couldn't open server"))
5559 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5560
5561 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5562 (gnus-activate-group group) ; Or we can activate it...
5563 (progn ; Or we bug out.
5564 (when (equal major-mode 'gnus-summary-mode)
5565 (gnus-kill-buffer (current-buffer)))
5566 (error
5567 "Couldn't activate group %s: %s"
5568 (mm-decode-coding-string group charset)
5569 (mm-decode-coding-string (gnus-status-message group) charset))))
5570
5571 (unless (gnus-request-group group t)
5572 (when (equal major-mode 'gnus-summary-mode)
5573 (gnus-kill-buffer (current-buffer)))
5574 (error "Couldn't request group %s: %s"
5575 (mm-decode-coding-string group charset)
5576 (mm-decode-coding-string (gnus-status-message group) charset)))
5577
5578 (when (and gnus-agent
5579 (gnus-active group))
5580 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5581
5582 (setq gnus-summary-use-undownloaded-faces
5583 (gnus-agent-find-parameter
5584 group
5585 'agent-enable-undownloaded-faces)))
5586
5587 (setq gnus-newsgroup-name group
5588 gnus-newsgroup-unselected nil
5589 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5590
5591 (let ((display (gnus-group-find-parameter group 'display)))
5592 (setq gnus-newsgroup-display
5593 (cond
5594 ((not (zerop (or (car-safe read-all) 0)))
5595 ;; The user entered the group with C-u SPC/RET, let's show
5596 ;; all articles.
5597 'gnus-not-ignore)
5598 ((eq display 'all)
5599 'gnus-not-ignore)
5600 ((arrayp display)
5601 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5602 ((numberp display)
5603 ;; The following is probably the "correct" solution, but
5604 ;; it makes Gnus fetch all headers and then limit the
5605 ;; articles (which is slow), so instead we hack the
5606 ;; select-articles parameter instead. -- Simon Josefsson
5607 ;; <jas@kth.se>
5608 ;;
5609 ;; (gnus-byte-compile
5610 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5611 ;; display)))))
5612 (setq select-articles
5613 (gnus-uncompress-range
5614 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5615 (if (> tmp 0)
5616 tmp
5617 1))
5618 (cdr (gnus-active group)))))
5619 nil)
5620 (t
5621 nil))))
5622
5623 (gnus-summary-setup-default-charset)
5624
5625 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5626 (when (gnus-virtual-group-p group)
5627 (setq cached gnus-newsgroup-cached))
5628
5629 (setq gnus-newsgroup-unreads
5630 (gnus-sorted-ndifference
5631 (gnus-sorted-ndifference gnus-newsgroup-unreads
5632 gnus-newsgroup-marked)
5633 gnus-newsgroup-dormant))
5634
5635 (setq gnus-newsgroup-processable nil)
5636
5637 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5638
5639 ;; Adjust and set lists of article marks.
5640 (when info
5641 (gnus-adjust-marked-articles info))
5642 (if (setq articles select-articles)
5643 (setq gnus-newsgroup-unselected
5644 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5645 (setq articles (gnus-articles-to-read group read-all)))
5646
5647 (cond
5648 ((null articles)
5649 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5650 'quit)
5651 ((eq articles 0) nil)
5652 (t
5653 ;; Init the dependencies hash table.
5654 (setq gnus-newsgroup-dependencies
5655 (gnus-make-hashtable (length articles)))
5656 (if (gnus-buffer-live-p gnus-group-buffer)
5657 (gnus-set-global-variables)
5658 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5659 ;; Retrieve the headers and read them in.
5660
5661 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5662
5663 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5664 (when cached
5665 (setq gnus-newsgroup-cached cached))
5666
5667 ;; Suppress duplicates?
5668 (when gnus-suppress-duplicates
5669 (gnus-dup-suppress-articles))
5670
5671 ;; Set the initial limit.
5672 (setq gnus-newsgroup-limit (copy-sequence articles))
5673 ;; Remove canceled articles from the list of unread articles.
5674 (setq fetched-articles
5675 (mapcar (lambda (headers) (mail-header-number headers))
5676 gnus-newsgroup-headers))
5677 (setq gnus-newsgroup-articles fetched-articles)
5678 (setq gnus-newsgroup-unreads
5679 (gnus-sorted-nintersection
5680 gnus-newsgroup-unreads fetched-articles))
5681 (gnus-compute-unseen-list)
5682
5683 ;; Removed marked articles that do not exist.
5684 (gnus-update-missing-marks
5685 (gnus-sorted-difference articles fetched-articles))
5686 ;; We might want to build some more threads first.
5687 (when (and gnus-fetch-old-headers
5688 (eq gnus-headers-retrieved-by 'nov))
5689 (if (eq gnus-fetch-old-headers 'invisible)
5690 (gnus-build-all-threads)
5691 (gnus-build-old-threads)))
5692 ;; Let the Gnus agent mark articles as read.
5693 (when gnus-agent
5694 (gnus-agent-get-undownloaded-list))
5695 ;; Remove list identifiers from subject
5696 (gnus-summary-remove-list-identifiers)
5697 ;; Check whether auto-expire is to be done in this group.
5698 (setq gnus-newsgroup-auto-expire
5699 (and (gnus-group-auto-expirable-p group)
5700 (not (gnus-group-read-only-p group))))
5701 ;; Set up the article buffer now, if necessary.
5702 (unless (and gnus-single-article-buffer
5703 (equal gnus-article-buffer "*Article*"))
5704 (gnus-article-setup-buffer))
5705 ;; First and last article in this newsgroup.
5706 (when gnus-newsgroup-headers
5707 (setq gnus-newsgroup-begin
5708 (mail-header-number (car gnus-newsgroup-headers))
5709 gnus-newsgroup-end
5710 (mail-header-number
5711 (gnus-last-element gnus-newsgroup-headers))))
5712 ;; GROUP is successfully selected.
5713 (or gnus-newsgroup-headers t)))))
5714
5715 (defun gnus-compute-unseen-list ()
5716 ;; The `seen' marks are treated specially.
5717 (if (not gnus-newsgroup-seen)
5718 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5719 (setq gnus-newsgroup-unseen
5720 (gnus-inverse-list-range-intersection
5721 gnus-newsgroup-articles gnus-newsgroup-seen))))
5722
5723 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5724
5725 (defun gnus-summary-display-make-predicate (display)
5726 (require 'gnus-agent)
5727 (when (= (length display) 1)
5728 (setq display (car display)))
5729 (unless gnus-summary-display-cache
5730 (dolist (elem (append '((unread . unread)
5731 (read . read)
5732 (unseen . unseen))
5733 gnus-article-mark-lists))
5734 (push (cons (cdr elem)
5735 (gnus-byte-compile ;Why bother?
5736 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5737 gnus-summary-display-cache)))
5738 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5739 (gnus-category-predicate-cache gnus-summary-display-cache))
5740 (gnus-get-predicate display)))
5741
5742 ;; Uses the dynamically bound `gnus-number' variable.
5743 (defvar gnus-number)
5744 (defun gnus-article-marked-p (type &optional article)
5745 (let ((article (or article gnus-number)))
5746 (cond
5747 ((eq type 'tick)
5748 (memq article gnus-newsgroup-marked))
5749 ((eq type 'spam)
5750 (memq article gnus-newsgroup-spam-marked))
5751 ((eq type 'unsend)
5752 (memq article gnus-newsgroup-unsendable))
5753 ((eq type 'undownload)
5754 (memq article gnus-newsgroup-undownloaded))
5755 ((eq type 'download)
5756 (memq article gnus-newsgroup-downloadable))
5757 ((eq type 'unread)
5758 (memq article gnus-newsgroup-unreads))
5759 ((eq type 'read)
5760 (memq article gnus-newsgroup-reads))
5761 ((eq type 'dormant)
5762 (memq article gnus-newsgroup-dormant) )
5763 ((eq type 'expire)
5764 (memq article gnus-newsgroup-expirable))
5765 ((eq type 'reply)
5766 (memq article gnus-newsgroup-replied))
5767 ((eq type 'killed)
5768 (memq article gnus-newsgroup-killed))
5769 ((eq type 'bookmark)
5770 (assq article gnus-newsgroup-bookmarks))
5771 ((eq type 'score)
5772 (assq article gnus-newsgroup-scored))
5773 ((eq type 'save)
5774 (memq article gnus-newsgroup-saved))
5775 ((eq type 'cache)
5776 (memq article gnus-newsgroup-cached))
5777 ((eq type 'forward)
5778 (memq article gnus-newsgroup-forwarded))
5779 ((eq type 'seen)
5780 (not (memq article gnus-newsgroup-unseen)))
5781 (t t))))
5782
5783 (defun gnus-articles-to-read (group &optional read-all)
5784 "Find out what articles the user wants to read."
5785 (let* ((only-read-p t)
5786 (articles
5787 ;; Select all articles if `read-all' is non-nil, or if there
5788 ;; are no unread articles.
5789 (if (or read-all
5790 (and (zerop (length gnus-newsgroup-marked))
5791 (zerop (length gnus-newsgroup-unreads)))
5792 ;; Fetch all if the predicate is non-nil.
5793 gnus-newsgroup-display)
5794 ;; We want to select the headers for all the articles in
5795 ;; the group, so we select either all the active
5796 ;; articles in the group, or (if that's nil), the
5797 ;; articles in the cache.
5798 (or
5799 (if gnus-newsgroup-maximum-articles
5800 (let ((active (gnus-active group)))
5801 (gnus-uncompress-range
5802 (cons (max (car active)
5803 (- (cdr active)
5804 gnus-newsgroup-maximum-articles
5805 -1))
5806 (cdr active))))
5807 (gnus-uncompress-range (gnus-active group)))
5808 (gnus-cache-articles-in-group group))
5809 ;; Select only the "normal" subset of articles.
5810 (setq only-read-p nil)
5811 (gnus-sorted-nunion
5812 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5813 gnus-newsgroup-unreads)))
5814 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5815 (scored (length scored-list))
5816 (number (length articles))
5817 (marked (+ (length gnus-newsgroup-marked)
5818 (length gnus-newsgroup-dormant)))
5819 (select
5820 (cond
5821 ((numberp read-all)
5822 read-all)
5823 ((numberp gnus-newsgroup-display)
5824 gnus-newsgroup-display)
5825 (t
5826 (condition-case ()
5827 (cond
5828 ((and (or (<= scored marked) (= scored number))
5829 (numberp gnus-large-newsgroup)
5830 (> number gnus-large-newsgroup))
5831 (let* ((cursor-in-echo-area nil)
5832 (initial (gnus-parameter-large-newsgroup-initial
5833 gnus-newsgroup-name))
5834 (default (if only-read-p
5835 (or initial gnus-large-newsgroup)
5836 number))
5837 (input
5838 (read-string
5839 (if only-read-p
5840 (format
5841 "How many articles from %s (available %d, default %d): "
5842 (gnus-group-decoded-name
5843 (gnus-group-real-name gnus-newsgroup-name))
5844 number default)
5845 (format
5846 "How many articles from %s (%d default): "
5847 (gnus-group-decoded-name
5848 (gnus-group-real-name gnus-newsgroup-name))
5849 default))
5850 nil
5851 nil
5852 (number-to-string default))))
5853 (if (string-match "^[ \t]*$" input) number input)))
5854 ((and (> scored marked) (< scored number)
5855 (> (- scored number) 20))
5856 (let ((input
5857 (read-string
5858 (format "%s %s (%d scored, %d total): "
5859 "How many articles from"
5860 (gnus-group-decoded-name
5861 (gnus-group-real-name gnus-newsgroup-name))
5862 scored number))))
5863 (if (string-match "^[ \t]*$" input)
5864 number input)))
5865 (t number))
5866 (quit
5867 (message "Quit getting the articles to read")
5868 nil))))))
5869 (setq select (if (stringp select) (string-to-number select) select))
5870 (if (or (null select) (zerop select))
5871 select
5872 (if (and (not (zerop scored)) (<= (abs select) scored))
5873 (progn
5874 (setq articles (sort scored-list '<))
5875 (setq number (length articles)))
5876 (setq articles (copy-sequence articles)))
5877
5878 (when (< (abs select) number)
5879 (if (< select 0)
5880 ;; Select the N oldest articles.
5881 (setcdr (nthcdr (1- (abs select)) articles) nil)
5882 ;; Select the N most recent articles.
5883 (setq articles (nthcdr (- number select) articles))))
5884 (setq gnus-newsgroup-unselected
5885 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5886 (when gnus-alter-articles-to-read-function
5887 (setq articles
5888 (sort
5889 (funcall gnus-alter-articles-to-read-function
5890 gnus-newsgroup-name articles)
5891 '<)))
5892 articles)))
5893
5894 (defun gnus-killed-articles (killed articles)
5895 (let (out)
5896 (while articles
5897 (when (inline (gnus-member-of-range (car articles) killed))
5898 (push (car articles) out))
5899 (setq articles (cdr articles)))
5900 out))
5901
5902 (defun gnus-article-mark-to-type (mark)
5903 "Return the type of MARK."
5904 (or (cadr (assq mark gnus-article-special-mark-lists))
5905 'list))
5906
5907 (defun gnus-article-unpropagatable-p (mark)
5908 "Return whether MARK should be propagated to back end."
5909 (memq mark gnus-article-unpropagated-mark-lists))
5910
5911 (defun gnus-adjust-marked-articles (info)
5912 "Set all article lists and remove all marks that are no longer valid."
5913 (let* ((marked-lists (gnus-info-marks info))
5914 (active (gnus-active (gnus-info-group info)))
5915 (min (car active))
5916 (max (cdr active))
5917 (types gnus-article-mark-lists)
5918 marks var articles article mark mark-type
5919 bgn end)
5920 ;; Hack to avoid adjusting marks for imap.
5921 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5922 'nnimap)
5923 (setq min 1))
5924
5925 (dolist (marks marked-lists)
5926 (setq mark (car marks)
5927 mark-type (gnus-article-mark-to-type mark)
5928 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5929 ;; We set the variable according to the type of the marks list,
5930 ;; and then adjust the marks to a subset of the active articles.
5931 (cond
5932 ;; Adjust "simple" lists - compressed yet unsorted
5933 ((eq mark-type 'list)
5934 ;; Simultaneously uncompress and clip to active range
5935 ;; See gnus-uncompress-range for a description of possible marks
5936 (let (l lh)
5937 (if (not (cadr marks))
5938 (set var nil)
5939 (setq articles (if (numberp (cddr marks))
5940 (list (cdr marks))
5941 (cdr marks))
5942 lh (cons nil nil)
5943 l lh)
5944
5945 (while (setq article (pop articles))
5946 (cond ((consp article)
5947 (setq bgn (max (car article) min)
5948 end (min (cdr article) max))
5949 (while (<= bgn end)
5950 (setq l (setcdr l (cons bgn nil))
5951 bgn (1+ bgn))))
5952 ((and (<= min article)
5953 (>= max article))
5954 (setq l (setcdr l (cons article nil))))))
5955 (set var (cdr lh)))))
5956 ;; Adjust assocs.
5957 ((eq mark-type 'tuple)
5958 (set var (setq articles (cdr marks)))
5959 (when (not (listp (cdr (symbol-value var))))
5960 (set var (list (symbol-value var))))
5961 (when (not (listp (cdr articles)))
5962 (setq articles (list articles)))
5963 (while articles
5964 (when (or (not (consp (setq article (pop articles))))
5965 (< (car article) min)
5966 (> (car article) max))
5967 (set var (delq article (symbol-value var))))))
5968 ;; Adjust ranges (sloppily).
5969 ((eq mark-type 'range)
5970 (cond
5971 ((eq mark 'seen)
5972 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5973 ;; It should be (seen (NUM1 . NUM2)).
5974 (when (numberp (cddr marks))
5975 (setcdr marks (list (cdr marks))))
5976 (setq articles (cdr marks))
5977 (while (and articles
5978 (or (and (consp (car articles))
5979 (> min (cdar articles)))
5980 (and (numberp (car articles))
5981 (> min (car articles)))))
5982 (pop articles))
5983 (set var articles))))))))
5984
5985 (defun gnus-update-missing-marks (missing)
5986 "Go through the list of MISSING articles and remove them from the mark lists."
5987 (when missing
5988 (let (var m)
5989 ;; Go through all types.
5990 (dolist (elem gnus-article-mark-lists)
5991 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5992 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5993 (when (symbol-value var)
5994 ;; This list has articles. So we delete all missing
5995 ;; articles from it.
5996 (setq m missing)
5997 (while m
5998 (set var (delq (pop m) (symbol-value var))))))))))
5999
6000 (defun gnus-update-marks ()
6001 "Enter the various lists of marked articles into the newsgroup info list."
6002 (let ((types gnus-article-mark-lists)
6003 (info (gnus-get-info gnus-newsgroup-name))
6004 type list newmarked symbol delta-marks)
6005 (when info
6006 ;; Add all marks lists to the list of marks lists.
6007 (while (setq type (pop types))
6008 (setq list (symbol-value
6009 (setq symbol
6010 (intern (format "gnus-newsgroup-%s" (car type))))))
6011
6012 (when list
6013 ;; Get rid of the entries of the articles that have the
6014 ;; default score.
6015 (when (and (eq (cdr type) 'score)
6016 gnus-save-score
6017 list)
6018 (let* ((arts list)
6019 (prev (cons nil list))
6020 (all prev))
6021 (while arts
6022 (if (or (not (consp (car arts)))
6023 (= (cdar arts) gnus-summary-default-score))
6024 (setcdr prev (cdr arts))
6025 (setq prev arts))
6026 (setq arts (cdr arts)))
6027 (setq list (cdr all)))))
6028
6029 (when (eq (cdr type) 'seen)
6030 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6031
6032 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6033 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6034
6035 (when (and (gnus-check-backend-function
6036 'request-set-mark gnus-newsgroup-name)
6037 (not (gnus-article-unpropagatable-p (cdr type))))
6038 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6039 ;; Don't do anything about marks for articles we
6040 ;; didn't actually get any headers for.
6041 (del
6042 (gnus-list-range-intersection
6043 gnus-newsgroup-articles
6044 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6045 (add
6046 (gnus-list-range-intersection
6047 gnus-newsgroup-articles
6048 (gnus-remove-from-range
6049 (gnus-copy-sequence list) old))))
6050 (when add
6051 (push (list add 'add (list (cdr type))) delta-marks))
6052 (when del
6053 ;; Don't delete marks from outside the active range.
6054 ;; This shouldn't happen, but is a sanity check.
6055 (setq del (gnus-sorted-range-intersection
6056 (gnus-active gnus-newsgroup-name) del))
6057 (push (list del 'del (list (cdr type))) delta-marks))))
6058
6059 (when list
6060 (push (cons (cdr type) list) newmarked)))
6061
6062 (when delta-marks
6063 (unless (gnus-check-group gnus-newsgroup-name)
6064 (error "Can't open server for %s" gnus-newsgroup-name))
6065 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6066
6067 ;; Enter these new marks into the info of the group.
6068 (if (nthcdr 3 info)
6069 (setcar (nthcdr 3 info) newmarked)
6070 ;; Add the marks lists to the end of the info.
6071 (when newmarked
6072 (setcdr (nthcdr 2 info) (list newmarked))))
6073
6074 ;; Cut off the end of the info if there's nothing else there.
6075 (let ((i 5))
6076 (while (and (> i 2)
6077 (not (nth i info)))
6078 (when (nthcdr (decf i) info)
6079 (setcdr (nthcdr i info) nil)))))))
6080
6081 (defun gnus-set-mode-line (where)
6082 "Set the mode line of the article or summary buffers.
6083 If WHERE is `summary', the summary mode line format will be used."
6084 ;; Is this mode line one we keep updated?
6085 (when (and (memq where gnus-updated-mode-lines)
6086 (symbol-value
6087 (intern (format "gnus-%s-mode-line-format-spec" where))))
6088 (let (mode-string)
6089 ;; We evaluate this in the summary buffer since these
6090 ;; variables are buffer-local to that buffer.
6091 (with-current-buffer gnus-summary-buffer
6092 ;; We bind all these variables that are used in the `eval' form
6093 ;; below.
6094 (let* ((mformat (symbol-value
6095 (intern
6096 (format "gnus-%s-mode-line-format-spec" where))))
6097 (gnus-tmp-group-name (gnus-mode-string-quote
6098 (gnus-group-decoded-name
6099 gnus-newsgroup-name)))
6100 (gnus-tmp-article-number (or gnus-current-article 0))
6101 (gnus-tmp-unread gnus-newsgroup-unreads)
6102 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6103 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6104 (gnus-tmp-unread-and-unselected
6105 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6106 (zerop gnus-tmp-unselected))
6107 "")
6108 ((zerop gnus-tmp-unselected)
6109 (format "{%d more}" gnus-tmp-unread-and-unticked))
6110 (t (format "{%d(+%d) more}"
6111 gnus-tmp-unread-and-unticked
6112 gnus-tmp-unselected))))
6113 (gnus-tmp-subject
6114 (if (and gnus-current-headers
6115 (vectorp gnus-current-headers))
6116 (gnus-mode-string-quote
6117 (mail-header-subject gnus-current-headers))
6118 ""))
6119 bufname-length max-len
6120 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6121 (setq mode-string (eval mformat))
6122 (setq bufname-length (if (string-match "%b" mode-string)
6123 (- (length
6124 (buffer-name
6125 (if (eq where 'summary)
6126 nil
6127 (get-buffer gnus-article-buffer))))
6128 2)
6129 0))
6130 (setq max-len (max 4 (if gnus-mode-non-string-length
6131 (- (window-width)
6132 gnus-mode-non-string-length
6133 bufname-length)
6134 (length mode-string))))
6135 ;; We might have to chop a bit of the string off...
6136 (when (> (length mode-string) max-len)
6137 (setq mode-string
6138 (concat (truncate-string-to-width mode-string (- max-len 3))
6139 "...")))))
6140 ;; Update the mode line.
6141 (setq mode-line-buffer-identification
6142 (gnus-mode-line-buffer-identification (list mode-string)))
6143 (set-buffer-modified-p t))))
6144
6145 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6146 "Go through the HEADERS list and add all Xrefs to a hash table.
6147 The resulting hash table is returned, or nil if no Xrefs were found."
6148 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6149 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6150 (xref-hashtb (gnus-make-hashtable))
6151 start group entry number xrefs header)
6152 (while headers
6153 (setq header (pop headers))
6154 (when (and (setq xrefs (mail-header-xref header))
6155 (not (memq (setq number (mail-header-number header))
6156 unreads)))
6157 (setq start 0)
6158 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6159 (setq start (match-end 0))
6160 (setq group (if prefix
6161 (concat prefix (substring xrefs (match-beginning 1)
6162 (match-end 1)))
6163 (substring xrefs (match-beginning 1) (match-end 1))))
6164 (setq number
6165 (string-to-number (substring xrefs (match-beginning 2)
6166 (match-end 2))))
6167 (if (setq entry (gnus-gethash group xref-hashtb))
6168 (setcdr entry (cons number (cdr entry)))
6169 (gnus-sethash group (cons number nil) xref-hashtb)))))
6170 (and start xref-hashtb)))
6171
6172 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6173 "Look through all the headers and mark the Xrefs as read."
6174 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6175 name info xref-hashtb idlist method nth4)
6176 (with-current-buffer gnus-group-buffer
6177 (when (setq xref-hashtb
6178 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6179 (mapatoms
6180 (lambda (group)
6181 (unless (string= from-newsgroup (setq name (symbol-name group)))
6182 (setq idlist (symbol-value group))
6183 ;; Dead groups are not updated.
6184 (and (prog1
6185 (setq info (gnus-get-info name))
6186 (when (stringp (setq nth4 (gnus-info-method info)))
6187 (setq nth4 (gnus-server-to-method nth4))))
6188 ;; Only do the xrefs if the group has the same
6189 ;; select method as the group we have just read.
6190 (or (gnus-methods-equal-p
6191 nth4 (gnus-find-method-for-group from-newsgroup))
6192 virtual
6193 (equal nth4 (setq method (gnus-find-method-for-group
6194 from-newsgroup)))
6195 (and (equal (car nth4) (car method))
6196 (equal (nth 1 nth4) (nth 1 method))))
6197 gnus-use-cross-reference
6198 (or (not (eq gnus-use-cross-reference t))
6199 virtual
6200 ;; Only do cross-references on subscribed
6201 ;; groups, if that is what is wanted.
6202 (<= (gnus-info-level info) gnus-level-subscribed))
6203 (gnus-group-make-articles-read name idlist))))
6204 xref-hashtb)))))
6205
6206 (defun gnus-compute-read-articles (group articles)
6207 (let* ((entry (gnus-group-entry group))
6208 (info (nth 2 entry))
6209 (active (gnus-active group))
6210 ninfo)
6211 (when entry
6212 ;; First peel off all invalid article numbers.
6213 (when active
6214 (let ((ids articles)
6215 id first)
6216 (while (setq id (pop ids))
6217 (when (and first (> id (cdr active)))
6218 ;; We'll end up in this situation in one particular
6219 ;; obscure situation. If you re-scan a group and get
6220 ;; a new article that is cross-posted to a different
6221 ;; group that has not been re-scanned, you might get
6222 ;; crossposted article that has a higher number than
6223 ;; Gnus believes possible. So we re-activate this
6224 ;; group as well. This might mean doing the
6225 ;; crossposting thingy will *increase* the number
6226 ;; of articles in some groups. Tsk, tsk.
6227 (setq active (or (gnus-activate-group group) active)))
6228 (when (or (> id (cdr active))
6229 (< id (car active)))
6230 (setq articles (delq id articles))))))
6231 ;; If the read list is nil, we init it.
6232 (if (and active
6233 (null (gnus-info-read info))
6234 (> (car active) 1))
6235 (setq ninfo (cons 1 (1- (car active))))
6236 (setq ninfo (gnus-info-read info)))
6237 ;; Then we add the read articles to the range.
6238 (gnus-add-to-range
6239 ninfo (setq articles (sort articles '<))))))
6240
6241 (defun gnus-group-make-articles-read (group articles)
6242 "Update the info of GROUP to say that ARTICLES are read."
6243 (let* ((num 0)
6244 (entry (gnus-group-entry group))
6245 (info (nth 2 entry))
6246 (active (gnus-active group))
6247 (set-marks
6248 (gnus-method-option-p
6249 (gnus-find-method-for-group group)
6250 'server-marks))
6251 range)
6252 (if (not entry)
6253 ;; Group that Gnus doesn't know exists, but still allow the
6254 ;; backend to set marks.
6255 (when set-marks
6256 (gnus-request-set-mark
6257 group (list (list (gnus-compress-sequence (sort articles #'<))
6258 'add '(read)))))
6259 ;; Normal, subscribed groups.
6260 (setq range (gnus-compute-read-articles group articles))
6261 (with-current-buffer gnus-group-buffer
6262 (gnus-undo-register
6263 `(progn
6264 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6265 (gnus-info-set-read ',info ',(gnus-info-read info))
6266 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6267 (when ,set-marks
6268 (gnus-request-set-mark
6269 ,group (list (list ',range 'del '(read)))))
6270 (gnus-group-update-group ,group t))))
6271 ;; Add the read articles to the range.
6272 (gnus-info-set-read info range)
6273 (when set-marks
6274 (gnus-request-set-mark group (list (list range 'add '(read)))))
6275 ;; Then we have to re-compute how many unread
6276 ;; articles there are in this group.
6277 (when active
6278 (cond
6279 ((not range)
6280 (setq num (- (1+ (cdr active)) (car active))))
6281 ((not (listp (cdr range)))
6282 (setq num (- (cdr active) (- (1+ (cdr range))
6283 (car range)))))
6284 (t
6285 (while range
6286 (if (numberp (car range))
6287 (setq num (1+ num))
6288 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6289 (setq range (cdr range)))
6290 (setq num (- (cdr active) num))))
6291 ;; Update the number of unread articles.
6292 (setcar entry num)
6293 ;; Update the group buffer.
6294 (unless (gnus-ephemeral-group-p group)
6295 (gnus-group-update-group group t))))))
6296
6297 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6298 (let ((cur nntp-server-buffer)
6299 (dependencies
6300 (or dependencies
6301 (with-current-buffer gnus-summary-buffer
6302 gnus-newsgroup-dependencies)))
6303 headers id end ref number
6304 (mail-parse-charset gnus-newsgroup-charset)
6305 (mail-parse-ignored-charsets
6306 (save-current-buffer (condition-case nil
6307 (set-buffer gnus-summary-buffer)
6308 (error))
6309 gnus-newsgroup-ignored-charsets)))
6310 (with-current-buffer nntp-server-buffer
6311 ;; Translate all TAB characters into SPACE characters.
6312 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6313 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6314 (ietf-drums-unfold-fws)
6315 (gnus-run-hooks 'gnus-parse-headers-hook)
6316 (let ((case-fold-search t)
6317 in-reply-to header p lines chars)
6318 (goto-char (point-min))
6319 ;; Search to the beginning of the next header. Error messages
6320 ;; do not begin with 2 or 3.
6321 (while (re-search-forward "^[23][0-9]+ " nil t)
6322 (setq id nil
6323 ref nil)
6324 ;; This implementation of this function, with nine
6325 ;; search-forwards instead of the one re-search-forward and
6326 ;; a case (which basically was the old function) is actually
6327 ;; about twice as fast, even though it looks messier. You
6328 ;; can't have everything, I guess. Speed and elegance
6329 ;; doesn't always go hand in hand.
6330 (setq
6331 header
6332 (vector
6333 ;; Number.
6334 (prog1
6335 (setq number (read cur))
6336 (end-of-line)
6337 (setq p (point))
6338 (narrow-to-region (point)
6339 (or (and (search-forward "\n.\n" nil t)
6340 (- (point) 2))
6341 (point))))
6342 ;; Subject.
6343 (progn
6344 (goto-char p)
6345 (if (search-forward "\nsubject:" nil t)
6346 (funcall gnus-decode-encoded-word-function
6347 (nnheader-header-value))
6348 "(none)"))
6349 ;; From.
6350 (progn
6351 (goto-char p)
6352 (if (search-forward "\nfrom:" nil t)
6353 (funcall gnus-decode-encoded-address-function
6354 (nnheader-header-value))
6355 "(nobody)"))
6356 ;; Date.
6357 (progn
6358 (goto-char p)
6359 (if (search-forward "\ndate:" nil t)
6360 (nnheader-header-value) ""))
6361 ;; Message-ID.
6362 (progn
6363 (goto-char p)
6364 (setq id (if (re-search-forward
6365 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6366 ;; We do it this way to make sure the Message-ID
6367 ;; is (somewhat) syntactically valid.
6368 (buffer-substring (match-beginning 1)
6369 (match-end 1))
6370 ;; If there was no message-id, we just fake one
6371 ;; to make subsequent routines simpler.
6372 (nnheader-generate-fake-message-id number))))
6373 ;; References.
6374 (progn
6375 (goto-char p)
6376 (if (search-forward "\nreferences:" nil t)
6377 (progn
6378 (setq end (point))
6379 (prog1
6380 (nnheader-header-value)
6381 (setq ref
6382 (buffer-substring
6383 (progn
6384 (end-of-line)
6385 (search-backward ">" end t)
6386 (1+ (point)))
6387 (progn
6388 (search-backward "<" end t)
6389 (point))))))
6390 ;; Get the references from the in-reply-to header if there
6391 ;; were no references and the in-reply-to header looks
6392 ;; promising.
6393 (if (and (search-forward "\nin-reply-to:" nil t)
6394 (setq in-reply-to (nnheader-header-value))
6395 (string-match "<[^>]+>" in-reply-to))
6396 (let (ref2)
6397 (setq ref (substring in-reply-to (match-beginning 0)
6398 (match-end 0)))
6399 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6400 (setq ref2 (substring in-reply-to (match-beginning 0)
6401 (match-end 0)))
6402 (when (> (length ref2) (length ref))
6403 (setq ref ref2)))
6404 ref)
6405 (setq ref nil))))
6406 ;; Chars.
6407 (progn
6408 (goto-char p)
6409 (if (search-forward "\nchars: " nil t)
6410 (if (numberp (setq chars (ignore-errors (read cur))))
6411 chars -1)
6412 -1))
6413 ;; Lines.
6414 (progn
6415 (goto-char p)
6416 (if (search-forward "\nlines: " nil t)
6417 (if (numberp (setq lines (ignore-errors (read cur))))
6418 lines -1)
6419 -1))
6420 ;; Xref.
6421 (progn
6422 (goto-char p)
6423 (and (search-forward "\nxref:" nil t)
6424 (nnheader-header-value)))
6425 ;; Extra.
6426 (when gnus-extra-headers
6427 (let ((extra gnus-extra-headers)
6428 out)
6429 (while extra
6430 (goto-char p)
6431 (when (search-forward
6432 (concat "\n" (symbol-name (car extra)) ":") nil t)
6433 (push (cons (car extra) (nnheader-header-value))
6434 out))
6435 (pop extra))
6436 out))))
6437 (when (equal id ref)
6438 (setq ref nil))
6439
6440 (when gnus-alter-header-function
6441 (funcall gnus-alter-header-function header)
6442 (setq id (mail-header-id header)
6443 ref (gnus-parent-id (mail-header-references header))))
6444
6445 (when (setq header
6446 (gnus-dependencies-add-header
6447 header dependencies force-new))
6448 (push header headers))
6449 (goto-char (point-max))
6450 (widen))
6451 (nreverse headers)))))
6452
6453 ;; Goes through the xover lines and returns a list of vectors
6454 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6455 force-new dependencies
6456 group also-fetch-heads)
6457 "Parse the news overview data in the server buffer.
6458 Return a list of headers that match SEQUENCE (see
6459 `nntp-retrieve-headers')."
6460 ;; Get the Xref when the users reads the articles since most/some
6461 ;; NNTP servers do not include Xrefs when using XOVER.
6462 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6463 (let ((mail-parse-charset gnus-newsgroup-charset)
6464 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6465 (cur nntp-server-buffer)
6466 (dependencies (or dependencies gnus-newsgroup-dependencies))
6467 (allp (cond
6468 ((eq gnus-read-all-available-headers t)
6469 t)
6470 ((and (stringp gnus-read-all-available-headers)
6471 group)
6472 (string-match gnus-read-all-available-headers group))
6473 (t
6474 nil)))
6475 number headers header)
6476 (with-current-buffer nntp-server-buffer
6477 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6478 ;; Allow the user to mangle the headers before parsing them.
6479 (gnus-run-hooks 'gnus-parse-headers-hook)
6480 (goto-char (point-min))
6481 (gnus-parse-without-error
6482 (while (and (or sequence allp)
6483 (not (eobp)))
6484 (setq number (read cur))
6485 (when (not allp)
6486 (while (and sequence
6487 (< (car sequence) number))
6488 (setq sequence (cdr sequence))))
6489 (when (and (or allp
6490 (and sequence
6491 (eq number (car sequence))))
6492 (progn
6493 (setq sequence (cdr sequence))
6494 (setq header (inline
6495 (gnus-nov-parse-line
6496 number dependencies force-new)))))
6497 (push header headers))
6498 (forward-line 1)))
6499 ;; A common bug in inn is that if you have posted an article and
6500 ;; then retrieves the active file, it will answer correctly --
6501 ;; the new article is included. However, a NOV entry for the
6502 ;; article may not have been generated yet, so this may fail.
6503 ;; We work around this problem by retrieving the last few
6504 ;; headers using HEAD.
6505 (if (or (not also-fetch-heads)
6506 (not sequence))
6507 ;; We (probably) got all the headers.
6508 (nreverse headers)
6509 (let ((gnus-nov-is-evil t))
6510 (nconc
6511 (nreverse headers)
6512 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6513 (gnus-get-newsgroup-headers))))))))
6514
6515 (defun gnus-article-get-xrefs ()
6516 "Fill in the Xref value in `gnus-current-headers', if necessary.
6517 This is meant to be called in `gnus-article-internal-prepare-hook'."
6518 (let ((headers (with-current-buffer gnus-summary-buffer
6519 gnus-current-headers)))
6520 (or (not gnus-use-cross-reference)
6521 (not headers)
6522 (and (mail-header-xref headers)
6523 (not (string= (mail-header-xref headers) "")))
6524 (let ((case-fold-search t)
6525 xref)
6526 (save-restriction
6527 (nnheader-narrow-to-headers)
6528 (goto-char (point-min))
6529 (when (or (and (not (eobp))
6530 (eq (downcase (char-after)) ?x)
6531 (looking-at "Xref:"))
6532 (search-forward "\nXref:" nil t))
6533 (goto-char (1+ (match-end 0)))
6534 (setq xref (buffer-substring (point) (point-at-eol)))
6535 (mail-header-set-xref headers xref)))))))
6536
6537 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6538 "Find article ID and insert the summary line for that article.
6539 OLD-HEADER can either be a header or a line number to insert
6540 the subject line on.
6541 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6542 and OLD-HEADER will be used when the summary line is inserted,
6543 too, instead of trying to fetch new headers."
6544 (let* ((line (and (numberp old-header) old-header))
6545 (old-header (and (vectorp old-header) old-header))
6546 (header (cond ((and old-header use-old-header)
6547 old-header)
6548 ((and (numberp id)
6549 (gnus-number-to-header id))
6550 (gnus-number-to-header id))
6551 (t
6552 (gnus-read-header id))))
6553 (number (and (numberp id) id))
6554 d)
6555 (when header
6556 ;; Rebuild the thread that this article is part of and go to the
6557 ;; article we have fetched.
6558 (when (and (not gnus-show-threads)
6559 old-header)
6560 (when (and number
6561 (setq d (gnus-data-find (mail-header-number old-header))))
6562 (goto-char (gnus-data-pos d))
6563 (gnus-data-remove
6564 number
6565 (- (point-at-bol)
6566 (prog1
6567 (1+ (point-at-eol))
6568 (gnus-delete-line))))))
6569 ;; Remove list identifiers from subject.
6570 (let ((gnus-newsgroup-headers (list header)))
6571 (gnus-summary-remove-list-identifiers))
6572 (when old-header
6573 (mail-header-set-number header (mail-header-number old-header)))
6574 (setq gnus-newsgroup-sparse
6575 (delq (setq number (mail-header-number header))
6576 gnus-newsgroup-sparse))
6577 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6578 (push number gnus-newsgroup-limit)
6579 (gnus-rebuild-thread (mail-header-id header) line)
6580 (gnus-summary-goto-subject number nil t))
6581 (when (and (numberp number)
6582 (> number 0))
6583 ;; We have to update the boundaries even if we can't fetch the
6584 ;; article if ID is a number -- so that the next `P' or `N'
6585 ;; command will fetch the previous (or next) article even
6586 ;; if the one we tried to fetch this time has been canceled.
6587 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6588 (setq gnus-newsgroup-end number))
6589 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6590 (setq gnus-newsgroup-begin number))
6591 (setq gnus-newsgroup-unselected
6592 (delq number gnus-newsgroup-unselected)))
6593 ;; Report back a success?
6594 (and header (mail-header-number header))))
6595
6596 ;;; Process/prefix in the summary buffer
6597
6598 (defun gnus-summary-work-articles (n)
6599 "Return a list of articles to be worked upon.
6600 The prefix argument, the list of process marked articles, and the
6601 current article will be taken into consideration."
6602 (with-current-buffer gnus-summary-buffer
6603 (cond
6604 (n
6605 ;; A numerical prefix has been given.
6606 (setq n (prefix-numeric-value n))
6607 (let ((backward (< n 0))
6608 (n (abs (prefix-numeric-value n)))
6609 articles article)
6610 (save-excursion
6611 (while
6612 (and (> n 0)
6613 (push (setq article (gnus-summary-article-number))
6614 articles)
6615 (if backward
6616 (gnus-summary-find-prev nil article)
6617 (gnus-summary-find-next nil article)))
6618 (decf n)))
6619 (nreverse articles)))
6620 ((and (gnus-region-active-p) (mark))
6621 (message "region active")
6622 ;; Work on the region between point and mark.
6623 (let ((max (max (point) (mark)))
6624 articles article)
6625 (save-excursion
6626 (goto-char (min (point) (mark)))
6627 (while
6628 (and
6629 (push (setq article (gnus-summary-article-number)) articles)
6630 (gnus-summary-find-next nil article)
6631 (< (point) max)))
6632 (nreverse articles))))
6633 (gnus-newsgroup-processable
6634 ;; There are process-marked articles present.
6635 ;; Save current state.
6636 (gnus-summary-save-process-mark)
6637 ;; Return the list.
6638 (reverse gnus-newsgroup-processable))
6639 (t
6640 ;; Just return the current article.
6641 (list (gnus-summary-article-number))))))
6642
6643 (defmacro gnus-summary-iterate (arg &rest forms)
6644 "Iterate over the process/prefixed articles and do FORMS.
6645 ARG is the interactive prefix given to the command. FORMS will be
6646 executed with point over the summary line of the articles."
6647 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6648 `(let ((,articles (gnus-summary-work-articles ,arg)))
6649 (while ,articles
6650 (gnus-summary-goto-subject (car ,articles))
6651 ,@forms
6652 (pop ,articles)))))
6653
6654 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6655 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6656
6657 (defun gnus-summary-save-process-mark ()
6658 "Push the current set of process marked articles on the stack."
6659 (interactive)
6660 (push (copy-sequence gnus-newsgroup-processable)
6661 gnus-newsgroup-process-stack))
6662
6663 (defun gnus-summary-kill-process-mark ()
6664 "Push the current set of process marked articles on the stack and unmark."
6665 (interactive)
6666 (gnus-summary-save-process-mark)
6667 (gnus-summary-unmark-all-processable))
6668
6669 (defun gnus-summary-yank-process-mark ()
6670 "Pop the last process mark state off the stack and restore it."
6671 (interactive)
6672 (unless gnus-newsgroup-process-stack
6673 (error "Empty mark stack"))
6674 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6675
6676 (defun gnus-summary-process-mark-set (set)
6677 "Make SET into the current process marked articles."
6678 (gnus-summary-unmark-all-processable)
6679 (mapc 'gnus-summary-set-process-mark set))
6680
6681 ;;; Searching and stuff
6682
6683 (defun gnus-summary-search-group (&optional backward use-level)
6684 "Search for next unread newsgroup.
6685 If optional argument BACKWARD is non-nil, search backward instead."
6686 (with-current-buffer gnus-group-buffer
6687 (when (gnus-group-search-forward
6688 backward nil (if use-level (gnus-group-group-level) nil))
6689 (gnus-group-group-name))))
6690
6691 (defun gnus-summary-best-group (&optional exclude-group)
6692 "Find the name of the best unread group.
6693 If EXCLUDE-GROUP, do not go to this group."
6694 (with-current-buffer gnus-group-buffer
6695 (save-excursion
6696 (gnus-group-best-unread-group exclude-group))))
6697
6698 (defun gnus-summary-find-next (&optional unread article backward)
6699 (if backward
6700 (gnus-summary-find-prev unread article)
6701 (let* ((dummy (gnus-summary-article-intangible-p))
6702 (article (or article (gnus-summary-article-number)))
6703 (data (gnus-data-find-list article))
6704 result)
6705 (when (and (not dummy)
6706 (or (not gnus-summary-check-current)
6707 (not unread)
6708 (not (gnus-data-unread-p (car data)))))
6709 (setq data (cdr data)))
6710 (when (setq result
6711 (if unread
6712 (progn
6713 (while data
6714 (unless (memq (gnus-data-number (car data))
6715 (cond
6716 ((eq gnus-auto-goto-ignores
6717 'always-undownloaded)
6718 gnus-newsgroup-undownloaded)
6719 (gnus-plugged
6720 nil)
6721 ((eq gnus-auto-goto-ignores
6722 'unfetched)
6723 gnus-newsgroup-unfetched)
6724 ((eq gnus-auto-goto-ignores
6725 'undownloaded)
6726 gnus-newsgroup-undownloaded)))
6727 (when (gnus-data-unread-p (car data))
6728 (setq result (car data)
6729 data nil)))
6730 (setq data (cdr data)))
6731 result)
6732 (car data)))
6733 (goto-char (gnus-data-pos result))
6734 (gnus-data-number result)))))
6735
6736 (defun gnus-summary-find-prev (&optional unread article)
6737 (let* ((eobp (eobp))
6738 (article (or article (gnus-summary-article-number)))
6739 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6740 result)
6741 (when (and (not eobp)
6742 (or (not gnus-summary-check-current)
6743 (not unread)
6744 (not (gnus-data-unread-p (car data)))))
6745 (setq data (cdr data)))
6746 (when (setq result
6747 (if unread
6748 (progn
6749 (while data
6750 (unless (memq (gnus-data-number (car data))
6751 (cond
6752 ((eq gnus-auto-goto-ignores
6753 'always-undownloaded)
6754 gnus-newsgroup-undownloaded)
6755 (gnus-plugged
6756 nil)
6757 ((eq gnus-auto-goto-ignores
6758 'unfetched)
6759 gnus-newsgroup-unfetched)
6760 ((eq gnus-auto-goto-ignores
6761 'undownloaded)
6762 gnus-newsgroup-undownloaded)))
6763 (when (gnus-data-unread-p (car data))
6764 (setq result (car data)
6765 data nil)))
6766 (setq data (cdr data)))
6767 result)
6768 (car data)))
6769 (goto-char (gnus-data-pos result))
6770 (gnus-data-number result))))
6771
6772 (defun gnus-summary-find-subject (subject &optional unread backward article)
6773 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6774 (article (or article (gnus-summary-article-number)))
6775 (articles (gnus-data-list backward))
6776 (arts (gnus-data-find-list article articles))
6777 result)
6778 (when (or (not gnus-summary-check-current)
6779 (not unread)
6780 (not (gnus-data-unread-p (car arts))))
6781 (setq arts (cdr arts)))
6782 (while arts
6783 (and (or (not unread)
6784 (gnus-data-unread-p (car arts)))
6785 (vectorp (gnus-data-header (car arts)))
6786 (gnus-subject-equal
6787 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6788 (setq result (car arts)
6789 arts nil))
6790 (setq arts (cdr arts)))
6791 (and result
6792 (goto-char (gnus-data-pos result))
6793 (gnus-data-number result))))
6794
6795 (defun gnus-summary-search-forward (&optional unread subject backward)
6796 "Search forward for an article.
6797 If UNREAD, look for unread articles. If SUBJECT, look for
6798 articles with that subject. If BACKWARD, search backward instead."
6799 (cond (subject (gnus-summary-find-subject subject unread backward))
6800 (backward (gnus-summary-find-prev unread))
6801 (t (gnus-summary-find-next unread))))
6802
6803 (defun gnus-recenter (&optional n)
6804 "Center point in window and redisplay frame.
6805 Also do horizontal recentering."
6806 (interactive "P")
6807 (when (and gnus-auto-center-summary
6808 (not (eq gnus-auto-center-summary 'vertical)))
6809 (gnus-horizontal-recenter))
6810 (if (fboundp 'recenter-top-bottom)
6811 (recenter-top-bottom n)
6812 (recenter n)))
6813
6814 (put 'gnus-recenter 'isearch-scroll t)
6815
6816 (defun gnus-forward-line-ignore-invisible (n)
6817 "Move N lines forward (backward if N is negative).
6818 Like forward-line, but skip over (and don't count) invisible lines."
6819 (let (done)
6820 (while (and (> n 0) (not done))
6821 ;; If the following character is currently invisible,
6822 ;; skip all characters with that same `invisible' property value.
6823 (while (gnus-invisible-p (point))
6824 (goto-char (gnus-next-char-property-change (point))))
6825 (forward-line 1)
6826 (if (eobp)
6827 (setq done t)
6828 (setq n (1- n))))
6829 (while (and (< n 0) (not done))
6830 (forward-line -1)
6831 (if (bobp) (setq done t)
6832 (setq n (1+ n))
6833 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6834 (goto-char (gnus-previous-char-property-change (point))))))))
6835
6836 (defun gnus-summary-recenter ()
6837 "Center point in the summary window.
6838 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6839 displayed, no centering will be performed."
6840 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6841 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6842 (interactive)
6843 ;; The user has to want it.
6844 (when gnus-auto-center-summary
6845 (let* ((top (cond ((< (window-height) 4) 0)
6846 ((< (window-height) 7) 1)
6847 (t (if (numberp gnus-auto-center-summary)
6848 gnus-auto-center-summary
6849 (/ (1- (window-height)) 2)))))
6850 (height (1- (window-height)))
6851 (bottom (save-excursion
6852 (goto-char (point-max))
6853 (gnus-forward-line-ignore-invisible (- height))
6854 (point)))
6855 (window (get-buffer-window (current-buffer))))
6856 (when (get-buffer-window gnus-article-buffer)
6857 ;; Only do recentering when the article buffer is displayed,
6858 ;; Set the window start to either `bottom', which is the biggest
6859 ;; possible valid number, or the second line from the top,
6860 ;; whichever is the least.
6861 (let ((top-pos (save-excursion
6862 (gnus-forward-line-ignore-invisible (- top))
6863 (point))))
6864 (if (> bottom top-pos)
6865 ;; Keep the second line from the top visible
6866 (set-window-start window top-pos)
6867 ;; Try to keep the bottom line visible; if it's partially
6868 ;; obscured, either scroll one more line to make it fully
6869 ;; visible, or revert to using TOP-POS.
6870 (save-excursion
6871 (goto-char (point-max))
6872 (gnus-forward-line-ignore-invisible -1)
6873 (let ((last-line-start (point)))
6874 (goto-char bottom)
6875 (set-window-start window (point) t)
6876 (when (not (pos-visible-in-window-p last-line-start window))
6877 (gnus-forward-line-ignore-invisible 1)
6878 (set-window-start window (min (point) top-pos) t)))))))
6879 ;; Do horizontal recentering while we're at it.
6880 (when (and (get-buffer-window (current-buffer) t)
6881 (not (eq gnus-auto-center-summary 'vertical)))
6882 (let ((selected (selected-window)))
6883 (select-window (get-buffer-window (current-buffer) t))
6884 (gnus-summary-position-point)
6885 (gnus-horizontal-recenter)
6886 (select-window selected))))))
6887
6888 (defun gnus-summary-jump-to-group (newsgroup)
6889 "Move point to NEWSGROUP in group mode buffer."
6890 ;; Keep update point of group mode buffer if visible.
6891 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6892 (save-window-excursion
6893 ;; Take care of tree window mode.
6894 (when (get-buffer-window gnus-group-buffer)
6895 (pop-to-buffer gnus-group-buffer))
6896 (gnus-group-jump-to-group newsgroup))
6897 (save-excursion
6898 ;; Take care of tree window mode.
6899 (if (get-buffer-window gnus-group-buffer 0)
6900 (pop-to-buffer gnus-group-buffer)
6901 (set-buffer gnus-group-buffer))
6902 (gnus-group-jump-to-group newsgroup))))
6903
6904 ;; This function returns a list of article numbers based on the
6905 ;; difference between the ranges of read articles in this group and
6906 ;; the range of active articles.
6907 (defun gnus-list-of-unread-articles (group)
6908 (let* ((read (gnus-info-read (gnus-get-info group)))
6909 (active (or (gnus-active group) (gnus-activate-group group)))
6910 (last (or (cdr active)
6911 (error "Group %s couldn't be activated " group)))
6912 (bottom (if gnus-newsgroup-maximum-articles
6913 (max (car active)
6914 (- last gnus-newsgroup-maximum-articles -1))
6915 (car active)))
6916 first nlast unread)
6917 ;; If none are read, then all are unread.
6918 (if (not read)
6919 (setq first bottom)
6920 ;; If the range of read articles is a single range, then the
6921 ;; first unread article is the article after the last read
6922 ;; article. Sounds logical, doesn't it?
6923 (if (and (not (listp (cdr read)))
6924 (or (< (car read) bottom)
6925 (progn (setq read (list read))
6926 nil)))
6927 (setq first (max bottom (1+ (cdr read))))
6928 ;; `read' is a list of ranges.
6929 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6930 (caar read)))
6931 1)
6932 (setq first bottom))
6933 (while read
6934 (when first
6935 (while (< first nlast)
6936 (setq unread (cons first unread)
6937 first (1+ first))))
6938 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6939 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6940 (setq read (cdr read)))))
6941 ;; And add the last unread articles.
6942 (while (<= first last)
6943 (setq unread (cons first unread)
6944 first (1+ first)))
6945 ;; Return the list of unread articles.
6946 (delq 0 (nreverse unread))))
6947
6948 (defun gnus-list-of-read-articles (group)
6949 "Return a list of unread, unticked and non-dormant articles."
6950 (let* ((info (gnus-get-info group))
6951 (marked (gnus-info-marks info))
6952 (active (gnus-active group)))
6953 (and info active
6954 (gnus-list-range-difference
6955 (gnus-list-range-difference
6956 (gnus-sorted-complement
6957 (gnus-uncompress-range
6958 (if gnus-newsgroup-maximum-articles
6959 (cons (max (car active)
6960 (- (cdr active)
6961 gnus-newsgroup-maximum-articles
6962 -1))
6963 (cdr active))
6964 active))
6965 (gnus-list-of-unread-articles group))
6966 (cdr (assq 'dormant marked)))
6967 (cdr (assq 'tick marked))))))
6968
6969 ;; This function returns a sequence of article numbers based on the
6970 ;; difference between the ranges of read articles in this group and
6971 ;; the range of active articles.
6972 (defun gnus-sequence-of-unread-articles (group)
6973 (let* ((read (gnus-info-read (gnus-get-info group)))
6974 (active (or (gnus-active group) (gnus-activate-group group)))
6975 (last (cdr active))
6976 (bottom (if gnus-newsgroup-maximum-articles
6977 (max (car active)
6978 (- last gnus-newsgroup-maximum-articles -1))
6979 (car active)))
6980 first nlast unread)
6981 ;; If none are read, then all are unread.
6982 (if (not read)
6983 (setq first bottom)
6984 ;; If the range of read articles is a single range, then the
6985 ;; first unread article is the article after the last read
6986 ;; article. Sounds logical, doesn't it?
6987 (if (and (not (listp (cdr read)))
6988 (or (< (car read) bottom)
6989 (progn (setq read (list read))
6990 nil)))
6991 (setq first (max bottom (1+ (cdr read))))
6992 ;; `read' is a list of ranges.
6993 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6994 (caar read)))
6995 1)
6996 (setq first bottom))
6997 (while read
6998 (when first
6999 (push (cons first nlast) unread))
7000 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7001 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7002 (setq read (cdr read)))))
7003 ;; And add the last unread articles.
7004 (cond ((not (and first last))
7005 nil)
7006 ((< first last)
7007 (push (cons first last) unread))
7008 ((= first last)
7009 (push first unread)))
7010 ;; Return the sequence of unread articles.
7011 (delq 0 (nreverse unread))))
7012
7013 ;; Various summary commands
7014
7015 (defun gnus-summary-select-article-buffer ()
7016 "Reconfigure windows to show the article buffer.
7017 If `gnus-widen-article-window' is set, show only the article
7018 buffer."
7019 (interactive)
7020 (if (not (gnus-buffer-live-p gnus-article-buffer))
7021 (error "There is no article buffer for this summary buffer")
7022 (unless (get-buffer-window gnus-article-buffer)
7023 (gnus-summary-show-article))
7024 (gnus-configure-windows
7025 (if gnus-widen-article-window
7026 'only-article
7027 'article)
7028 t)
7029 (select-window (get-buffer-window gnus-article-buffer))))
7030
7031 (defun gnus-summary-universal-argument (arg)
7032 "Perform any operation on all articles that are process/prefixed."
7033 (interactive "P")
7034 (let ((articles (gnus-summary-work-articles arg))
7035 func article)
7036 (if (eq
7037 (setq
7038 func
7039 (key-binding
7040 (read-key-sequence
7041 (substitute-command-keys
7042 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7043 'undefined)
7044 (gnus-error 1 "Undefined key")
7045 (save-excursion
7046 (while articles
7047 (gnus-summary-goto-subject (setq article (pop articles)))
7048 (let (gnus-newsgroup-processable)
7049 (command-execute func))
7050 (gnus-summary-remove-process-mark article)))))
7051 (gnus-summary-position-point))
7052
7053 (defun gnus-summary-toggle-truncation (&optional arg)
7054 "Toggle truncation of summary lines.
7055 With ARG, turn line truncation on if ARG is positive."
7056 (interactive "P")
7057 (setq truncate-lines
7058 (if (null arg) (not truncate-lines)
7059 (> (prefix-numeric-value arg) 0)))
7060 (redraw-display))
7061
7062 (defun gnus-summary-find-for-reselect ()
7063 "Return the number of an article to stay on across a reselect.
7064 The current article is considered, then following articles, then previous
7065 articles. An article is sought which is not canceled and isn't a temporary
7066 insertion from another group. If there's no such then return a dummy 0."
7067 (let (found)
7068 (dolist (rev '(nil t))
7069 (unless found ; don't demand the reverse list if we don't need it
7070 (let ((data (gnus-data-find-list
7071 (gnus-summary-article-number) (gnus-data-list rev))))
7072 (while (and data (not found))
7073 (if (and (< 0 (gnus-data-number (car data)))
7074 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7075 (setq found (gnus-data-number (car data))))
7076 (setq data (cdr data))))))
7077 (or found 0)))
7078
7079 (defun gnus-summary-reselect-current-group (&optional all rescan)
7080 "Exit and then reselect the current newsgroup.
7081 The prefix argument ALL means to select all articles."
7082 (interactive "P")
7083 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7084 (error "Ephemeral groups can't be reselected"))
7085 (let ((current-subject (gnus-summary-find-for-reselect))
7086 (group gnus-newsgroup-name))
7087 (setq gnus-newsgroup-begin nil)
7088 (gnus-summary-exit nil 'leave-hidden)
7089 ;; We have to adjust the point of group mode buffer because
7090 ;; point was moved to the next unread newsgroup by exiting.
7091 (gnus-summary-jump-to-group group)
7092 (when rescan
7093 (save-excursion
7094 (gnus-group-get-new-news-this-group 1)))
7095 (gnus-group-read-group all t)
7096 (gnus-summary-goto-subject current-subject nil t)))
7097
7098 (defun gnus-summary-rescan-group (&optional all)
7099 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7100 (interactive "P")
7101 (let ((config gnus-current-window-configuration))
7102 (gnus-summary-reselect-current-group all t)
7103 (gnus-configure-windows config)
7104 (when (eq config 'article)
7105 (gnus-summary-select-article))))
7106
7107 (defun gnus-summary-update-info (&optional non-destructive)
7108 (save-excursion
7109 (let ((group gnus-newsgroup-name))
7110 (when group
7111 (when gnus-newsgroup-kill-headers
7112 (setq gnus-newsgroup-killed
7113 (gnus-compress-sequence
7114 (gnus-sorted-union
7115 (gnus-list-range-intersection
7116 gnus-newsgroup-unselected gnus-newsgroup-killed)
7117 gnus-newsgroup-unreads)
7118 t)))
7119 (unless (listp (cdr gnus-newsgroup-killed))
7120 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7121 (let ((headers gnus-newsgroup-headers)
7122 (ephemeral-p (gnus-ephemeral-group-p group))
7123 info)
7124 (unless ephemeral-p
7125 (setq info (copy-sequence (gnus-get-info group))
7126 info (delq (gnus-info-params info) info)))
7127 ;; Set the new ranges of read articles.
7128 (with-current-buffer gnus-group-buffer
7129 (gnus-undo-force-boundary))
7130 (gnus-update-read-articles
7131 group (gnus-sorted-union
7132 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7133 ;; Set the current article marks.
7134 (let ((gnus-newsgroup-scored
7135 (if (and (not gnus-save-score)
7136 (not non-destructive))
7137 nil
7138 gnus-newsgroup-scored)))
7139 (save-excursion
7140 (gnus-update-marks)))
7141 ;; Do the cross-ref thing.
7142 (when gnus-use-cross-reference
7143 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7144 ;; Do not switch windows but change the buffer to work.
7145 (set-buffer gnus-group-buffer)
7146 (unless ephemeral-p
7147 (gnus-group-update-group
7148 group nil
7149 (equal info
7150 (setq info (copy-sequence (gnus-get-info group))
7151 info (delq (gnus-info-params info) info))))))))))
7152
7153 (defun gnus-summary-save-newsrc (&optional force)
7154 "Save the current number of read/marked articles in the dribble buffer.
7155 The dribble buffer will then be saved.
7156 If FORCE (the prefix), also save the .newsrc file(s)."
7157 (interactive "P")
7158 (gnus-summary-update-info t)
7159 (if force
7160 (gnus-save-newsrc-file)
7161 (gnus-dribble-save)))
7162
7163 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7164
7165 (defun gnus-summary-exit (&optional temporary leave-hidden)
7166 "Exit reading current newsgroup, and then return to group selection mode.
7167 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7168 (interactive)
7169 (gnus-set-global-variables)
7170 (when (gnus-buffer-live-p gnus-article-buffer)
7171 (with-current-buffer gnus-article-buffer
7172 (mm-destroy-parts gnus-article-mime-handles)
7173 ;; Set it to nil for safety reason.
7174 (setq gnus-article-mime-handle-alist nil)
7175 (setq gnus-article-mime-handles nil)))
7176 (gnus-kill-save-kill-buffer)
7177 (gnus-async-halt-prefetch)
7178 (let* ((group gnus-newsgroup-name)
7179 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7180 (gnus-group-is-exiting-p t)
7181 (article-buffer gnus-article-buffer)
7182 (original-article-buffer gnus-original-article-buffer)
7183 (mode major-mode)
7184 (group-point nil)
7185 (buf (current-buffer))
7186 ;; `gnus-single-article-buffer' is nil buffer-locally in
7187 ;; ephemeral group of which summary buffer will be killed,
7188 ;; but the global value may be non-nil.
7189 (single-article-buffer gnus-single-article-buffer))
7190 (unless quit-config
7191 ;; Do adaptive scoring, and possibly save score files.
7192 (when gnus-newsgroup-adaptive
7193 (gnus-score-adaptive))
7194 (when gnus-use-scoring
7195 (gnus-score-save)))
7196 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7197 (when gnus-use-cache
7198 (gnus-cache-possibly-remove-articles)
7199 (gnus-cache-save-buffers))
7200 (gnus-async-prefetch-remove-group group)
7201 (when gnus-suppress-duplicates
7202 (gnus-dup-enter-articles))
7203 (when gnus-use-trees
7204 (gnus-tree-close group))
7205 (when gnus-use-cache
7206 (gnus-cache-write-active))
7207 ;; Remove entries for this group.
7208 (nnmail-purge-split-history (gnus-group-real-name group))
7209 ;; Make all changes in this group permanent.
7210 (unless quit-config
7211 (gnus-run-hooks 'gnus-exit-group-hook)
7212 (gnus-summary-update-info))
7213 (gnus-close-group group)
7214 ;; Make sure where we were, and go to next newsgroup.
7215 (when (buffer-live-p (get-buffer gnus-group-buffer))
7216 (set-buffer gnus-group-buffer))
7217 (unless quit-config
7218 (gnus-group-jump-to-group group))
7219 (gnus-run-hooks 'gnus-summary-exit-hook)
7220 (unless (or quit-config
7221 (not gnus-summary-next-group-on-exit)
7222 ;; If this group has disappeared from the summary
7223 ;; buffer, don't skip forwards.
7224 (not (string= group (gnus-group-group-name))))
7225 (gnus-group-next-unread-group 1))
7226 (setq group-point (point))
7227 (if temporary
7228 nil ;Nothing to do.
7229 (set-buffer buf)
7230 (if (not gnus-kill-summary-on-exit)
7231 (progn
7232 (gnus-deaden-summary)
7233 (setq mode nil))
7234 (when (get-buffer gnus-article-buffer)
7235 (bury-buffer gnus-article-buffer))
7236 ;; Return to group mode buffer.
7237 (when (eq mode 'gnus-summary-mode)
7238 (gnus-kill-buffer buf)))
7239
7240 (setq gnus-current-select-method gnus-select-method)
7241 (when (gnus-buffer-live-p gnus-group-buffer)
7242 (set-buffer gnus-group-buffer))
7243 (if quit-config
7244 (gnus-handle-ephemeral-exit quit-config)
7245 (goto-char group-point)
7246 ;; If gnus-group-buffer is already displayed, make sure we also move
7247 ;; the cursor in the window that displays it.
7248 (let ((win (get-buffer-window (current-buffer) 0)))
7249 (if win (set-window-point win (point))))
7250 (unless leave-hidden
7251 (gnus-configure-windows 'group 'force)))
7252
7253 ;; If we have several article buffers, we kill them at exit.
7254 (unless single-article-buffer
7255 (when (gnus-buffer-live-p article-buffer)
7256 (with-current-buffer article-buffer
7257 ;; Don't kill sticky article buffers
7258 (unless (eq major-mode 'gnus-sticky-article-mode)
7259 (gnus-kill-buffer article-buffer)
7260 (setq gnus-article-current nil))))
7261 (gnus-kill-buffer original-article-buffer))
7262
7263 ;; Clear the current group name.
7264 (unless quit-config
7265 (setq gnus-newsgroup-name nil)))))
7266
7267 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7268 (defun gnus-summary-exit-no-update (&optional no-questions)
7269 "Quit reading current newsgroup without updating read article info."
7270 (interactive)
7271 (let* ((group gnus-newsgroup-name)
7272 (gnus-group-is-exiting-p t)
7273 (gnus-group-is-exiting-without-update-p t)
7274 (quit-config (gnus-group-quit-config group)))
7275 (when (or no-questions
7276 gnus-expert-user
7277 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7278 (gnus-async-halt-prefetch)
7279 (run-hooks 'gnus-summary-prepare-exit-hook)
7280 (when (gnus-buffer-live-p gnus-article-buffer)
7281 (with-current-buffer gnus-article-buffer
7282 (gnus-article-stop-animations)
7283 (gnus-stop-downloads)
7284 (mm-destroy-parts gnus-article-mime-handles)
7285 ;; Set it to nil for safety reason.
7286 (setq gnus-article-mime-handle-alist nil)
7287 (setq gnus-article-mime-handles nil)))
7288 ;; If we have several article buffers, we kill them at exit.
7289 (unless gnus-single-article-buffer
7290 (gnus-kill-buffer gnus-article-buffer)
7291 (gnus-kill-buffer gnus-original-article-buffer)
7292 (setq gnus-article-current nil))
7293 ;; Return to the group buffer.
7294 (if (not gnus-kill-summary-on-exit)
7295 (progn
7296 (gnus-deaden-summary)
7297 (gnus-configure-windows 'group 'force))
7298 (gnus-configure-windows 'group 'force)
7299 (gnus-close-group group)
7300 (gnus-kill-buffer gnus-summary-buffer))
7301 (unless gnus-single-article-buffer
7302 (setq gnus-article-current nil))
7303 (when gnus-use-trees
7304 (gnus-tree-close group))
7305 (gnus-async-prefetch-remove-group group)
7306 (when (get-buffer gnus-article-buffer)
7307 (bury-buffer gnus-article-buffer))
7308 ;; Clear the current group name.
7309 (setq gnus-newsgroup-name nil)
7310 (unless (gnus-ephemeral-group-p group)
7311 (gnus-group-update-group group nil t))
7312 (when (equal (gnus-group-group-name) group)
7313 (gnus-group-next-unread-group 1))
7314 (when quit-config
7315 (gnus-handle-ephemeral-exit quit-config)))))
7316
7317 (defun gnus-handle-ephemeral-exit (quit-config)
7318 "Handle movement when leaving an ephemeral group.
7319 The state which existed when entering the ephemeral is reset."
7320 (if (not (buffer-live-p (car quit-config)))
7321 (when (gnus-buffer-live-p gnus-group-buffer)
7322 (gnus-configure-windows 'group 'force))
7323 (set-buffer (car quit-config))
7324 (unless (eq (cdr quit-config) 'group)
7325 (setq gnus-current-select-method
7326 (gnus-find-method-for-group gnus-newsgroup-name)))
7327 (cond ((eq major-mode 'gnus-summary-mode)
7328 (gnus-set-global-variables))
7329 ((eq major-mode 'gnus-article-mode)
7330 (save-current-buffer
7331 ;; The `gnus-summary-buffer' variable may point
7332 ;; to the old summary buffer when using a single
7333 ;; article buffer.
7334 (unless (gnus-buffer-live-p gnus-summary-buffer)
7335 (set-buffer gnus-group-buffer))
7336 (set-buffer gnus-summary-buffer)
7337 (gnus-set-global-variables))))
7338 (if (or (eq (cdr quit-config) 'article)
7339 (eq (cdr quit-config) 'pick))
7340 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7341 (gnus-configure-windows 'pick 'force)
7342 (gnus-configure-windows (cdr quit-config) 'force))
7343 (gnus-configure-windows (cdr quit-config) 'force))
7344 (when (eq major-mode 'gnus-summary-mode)
7345 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7346 next-unread-noselect))
7347 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7348 'next-noselect)
7349 (gnus-summary-next-subject 1 nil t))
7350 ((eq gnus-auto-select-on-ephemeral-exit
7351 'next-unread-noselect)
7352 (gnus-summary-next-subject 1 t t))))
7353 ;; Hide the article buffer which displays the article different
7354 ;; from the one that the cursor points to in the summary buffer.
7355 (gnus-configure-windows 'summary 'force))
7356 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7357 (gnus-summary-next-subject 1))
7358 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7359 (gnus-summary-next-subject 1 t))))
7360 (gnus-summary-recenter)
7361 (gnus-summary-position-point))))
7362
7363 ;;; Dead summaries.
7364
7365 (defvar gnus-dead-summary-mode-map
7366 (let ((map (make-keymap)))
7367 (suppress-keymap map)
7368 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7369 (dolist (key '("\C-d" "\r" "\177" [delete]))
7370 (define-key map key 'gnus-summary-wake-up-the-dead))
7371 (dolist (key '("q" "Q"))
7372 (define-key map key 'bury-buffer))
7373 map))
7374
7375 (define-minor-mode gnus-dead-summary-mode
7376 "Minor mode for Gnus summary buffers."
7377 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7378 (unless (derived-mode-p 'gnus-summary-mode)
7379 (setq gnus-dead-summary-mode nil)))
7380
7381 (defun gnus-deaden-summary ()
7382 "Make the current summary buffer into a dead summary buffer."
7383 ;; Kill any previous dead summary buffer.
7384 (when (and gnus-dead-summary
7385 (buffer-name gnus-dead-summary))
7386 (with-current-buffer gnus-dead-summary
7387 (when gnus-dead-summary-mode
7388 (kill-buffer (current-buffer)))))
7389 ;; Make this the current dead summary.
7390 (setq gnus-dead-summary (current-buffer))
7391 (gnus-dead-summary-mode 1)
7392 (let ((name (buffer-name)))
7393 (when (string-match "Summary" name)
7394 (rename-buffer
7395 (concat (substring name 0 (match-beginning 0)) "Dead "
7396 (substring name (match-beginning 0)))
7397 t)
7398 (bury-buffer))))
7399
7400 (defun gnus-kill-or-deaden-summary (buffer)
7401 "Kill or deaden the summary BUFFER."
7402 (save-excursion
7403 (when (and (buffer-name buffer)
7404 (not gnus-single-article-buffer))
7405 (with-current-buffer buffer
7406 (gnus-kill-buffer gnus-article-buffer)
7407 (gnus-kill-buffer gnus-original-article-buffer)))
7408 (cond
7409 ;; Kill the buffer.
7410 (gnus-kill-summary-on-exit
7411 (when (and gnus-use-trees
7412 (gnus-buffer-exists-p buffer))
7413 (with-current-buffer buffer
7414 (gnus-tree-close gnus-newsgroup-name)))
7415 (gnus-kill-buffer buffer))
7416 ;; Deaden the buffer.
7417 ((gnus-buffer-exists-p buffer)
7418 (with-current-buffer buffer
7419 (gnus-deaden-summary))))))
7420
7421 (defun gnus-summary-wake-up-the-dead (&rest args)
7422 "Wake up the dead summary buffer."
7423 (interactive)
7424 (gnus-dead-summary-mode -1)
7425 (let ((name (buffer-name)))
7426 (when (string-match "Dead " name)
7427 (rename-buffer
7428 (concat (substring name 0 (match-beginning 0))
7429 (substring name (match-end 0)))
7430 t)))
7431 (gnus-message 3 "This dead summary is now alive again"))
7432
7433 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7434 (defun gnus-summary-describe-group (&optional force)
7435 "Describe the current newsgroup."
7436 (interactive "P")
7437 (gnus-group-describe-group force gnus-newsgroup-name))
7438
7439 (defun gnus-summary-describe-briefly ()
7440 "Describe summary mode commands briefly."
7441 (interactive)
7442 (gnus-message 6 "%s" (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")))
7443
7444 ;; Walking around group mode buffer from summary mode.
7445
7446 (defun gnus-summary-next-group (&optional no-article target-group backward)
7447 "Exit current newsgroup and then select next unread newsgroup.
7448 If prefix argument NO-ARTICLE is non-nil, no article is selected
7449 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7450 previous group instead."
7451 (interactive "P")
7452 ;; Stop pre-fetching.
7453 (gnus-async-halt-prefetch)
7454 (let ((current-group gnus-newsgroup-name)
7455 (current-buffer (current-buffer))
7456 entered)
7457 ;; First we semi-exit this group to update Xrefs and all variables.
7458 ;; We can't do a real exit, because the window conf must remain
7459 ;; the same in case the user is prompted for info, and we don't
7460 ;; want the window conf to change before that...
7461 (gnus-summary-exit t)
7462 (while (not entered)
7463 ;; Then we find what group we are supposed to enter.
7464 (set-buffer gnus-group-buffer)
7465 (gnus-group-jump-to-group current-group)
7466 (setq target-group
7467 (or target-group
7468 (if (eq gnus-keep-same-level 'best)
7469 (gnus-summary-best-group gnus-newsgroup-name)
7470 (gnus-summary-search-group backward gnus-keep-same-level))))
7471 (if (not target-group)
7472 ;; There are no further groups, so we return to the group
7473 ;; buffer.
7474 (progn
7475 (gnus-message 5 "Returning to the group buffer")
7476 (setq entered t)
7477 (when (gnus-buffer-live-p current-buffer)
7478 (set-buffer current-buffer)
7479 (gnus-summary-exit))
7480 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7481 ;; We try to enter the target group.
7482 (gnus-group-jump-to-group target-group)
7483 (let ((unreads (gnus-group-group-unread)))
7484 (if (and (or (eq t unreads)
7485 (and unreads (not (zerop unreads))))
7486 (gnus-summary-read-group
7487 target-group nil no-article
7488 (and (buffer-name current-buffer) current-buffer)
7489 nil backward))
7490 (setq entered t)
7491 (setq current-group target-group
7492 target-group nil)))))))
7493
7494 (defun gnus-summary-prev-group (&optional no-article)
7495 "Exit current newsgroup and then select previous unread newsgroup.
7496 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7497 (interactive "P")
7498 (gnus-summary-next-group no-article nil t))
7499
7500 ;; Walking around summary lines.
7501
7502 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7503 "Go to the first subject satisfying any non-nil constraint.
7504 If UNREAD is non-nil, the article should be unread.
7505 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7506 If UNSEEN is non-nil, the article should be unseen as well as unread.
7507 Returns the article selected or nil if there are no matching articles."
7508 (interactive "P")
7509 (cond
7510 ;; Empty summary.
7511 ((null gnus-newsgroup-data)
7512 (gnus-message 3 "No articles in the group")
7513 nil)
7514 ;; Pick the first article.
7515 ((not (or unread undownloaded unseen))
7516 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7517 (gnus-data-number (car gnus-newsgroup-data)))
7518 ;; Find the first unread article.
7519 (t
7520 (let ((data gnus-newsgroup-data))
7521 (while (and data
7522 (let ((num (gnus-data-number (car data))))
7523 (or (memq num gnus-newsgroup-unfetched)
7524 (not (or (and unread
7525 (memq num gnus-newsgroup-unreads))
7526 (and undownloaded
7527 (memq num gnus-newsgroup-undownloaded))
7528 (and unseen
7529 (memq num gnus-newsgroup-unseen)
7530 (memq num gnus-newsgroup-unreads)))))))
7531 (setq data (cdr data)))
7532 (prog1
7533 (if data
7534 (progn
7535 (goto-char (gnus-data-pos (car data)))
7536 (gnus-data-number (car data)))
7537 (gnus-message 3 "No more%s articles"
7538 (let* ((r (when unread " unread"))
7539 (d (when undownloaded " undownloaded"))
7540 (s (when unseen " unseen"))
7541 (l (delq nil (list r d s))))
7542 (cond ((= 3 (length l))
7543 (concat r "," d ", or" s))
7544 ((= 2 (length l))
7545 (concat (car l) ", or" (cadr l)))
7546 ((= 1 (length l))
7547 (car l))
7548 (t
7549 ""))))
7550 nil
7551 )
7552 (gnus-summary-position-point))))))
7553
7554 (defun gnus-summary-next-subject (n &optional unread dont-display)
7555 "Go to next N'th summary line.
7556 If N is negative, go to the previous N'th subject line.
7557 If UNREAD is non-nil, only unread articles are selected.
7558 The difference between N and the actual number of steps taken is
7559 returned."
7560 (interactive "p")
7561 (let ((backward (< n 0))
7562 (n (abs n)))
7563 (while (and (> n 0)
7564 (if backward
7565 (gnus-summary-find-prev unread)
7566 (gnus-summary-find-next unread)))
7567 (unless (zerop (setq n (1- n)))
7568 (gnus-summary-show-thread)))
7569 (when (/= 0 n)
7570 (gnus-message 7 "No more%s articles"
7571 (if unread " unread" "")))
7572 (unless dont-display
7573 (gnus-summary-recenter)
7574 (gnus-summary-position-point))
7575 n))
7576
7577 (defun gnus-summary-next-unread-subject (n)
7578 "Go to next N'th unread summary line."
7579 (interactive "p")
7580 (gnus-summary-next-subject n t))
7581
7582 (defun gnus-summary-prev-subject (n &optional unread)
7583 "Go to previous N'th summary line.
7584 If optional argument UNREAD is non-nil, only unread article is selected."
7585 (interactive "p")
7586 (gnus-summary-next-subject (- n) unread))
7587
7588 (defun gnus-summary-prev-unread-subject (n)
7589 "Go to previous N'th unread summary line."
7590 (interactive "p")
7591 (gnus-summary-next-subject (- n) t))
7592
7593 (defun gnus-summary-goto-subjects (articles)
7594 "Insert the subject header for ARTICLES in the current buffer."
7595 (save-excursion
7596 (dolist (article articles)
7597 (gnus-summary-goto-subject article t)))
7598 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7599 (gnus-summary-position-point))
7600
7601 (defun gnus-summary-goto-subject (article &optional force silent)
7602 "Go to the subject line of ARTICLE.
7603 If FORCE, also allow jumping to articles not currently shown."
7604 (interactive "nArticle number: ")
7605 (unless (numberp article)
7606 (error "Article %s is not a number" article))
7607 (let ((b (point))
7608 (data (gnus-data-find article)))
7609 ;; We read in the article if we have to.
7610 (and (not data)
7611 force
7612 (gnus-summary-insert-subject
7613 article
7614 (if (or (numberp force) (vectorp force)) force)
7615 t)
7616 (setq data (gnus-data-find article)))
7617 (goto-char b)
7618 (if (not data)
7619 (progn
7620 (unless silent
7621 (gnus-message 3 "Can't find article %d" article))
7622 nil)
7623 (let ((pt (gnus-data-pos data)))
7624 (goto-char pt)
7625 (gnus-summary-set-article-display-arrow pt))
7626 (gnus-summary-position-point)
7627 article)))
7628
7629 ;; Walking around summary lines with displaying articles.
7630
7631 (defun gnus-summary-expand-window (&optional arg)
7632 "Make the summary buffer take up the entire Emacs frame.
7633 Given a prefix, will force an `article' buffer configuration."
7634 (interactive "P")
7635 (if arg
7636 (gnus-configure-windows 'article 'force)
7637 (gnus-configure-windows 'summary 'force)))
7638
7639 (defun gnus-summary-display-article (article &optional all-header)
7640 "Display ARTICLE in article buffer."
7641 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7642 (with-current-buffer gnus-article-buffer
7643 (eq major-mode 'gnus-article-mode)))
7644 (gnus-article-setup-buffer))
7645 (gnus-set-global-variables)
7646 (with-current-buffer gnus-article-buffer
7647 (setq gnus-article-charset gnus-newsgroup-charset)
7648 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7649 (mm-enable-multibyte))
7650 (if (null article)
7651 nil
7652 (prog1
7653 (if gnus-summary-display-article-function
7654 (funcall gnus-summary-display-article-function article all-header)
7655 (gnus-article-prepare article all-header))
7656 (gnus-run-hooks 'gnus-select-article-hook)
7657 (when (and gnus-current-article
7658 (not (zerop gnus-current-article)))
7659 (gnus-summary-goto-subject gnus-current-article))
7660 (gnus-summary-recenter)
7661 (when (and gnus-use-trees gnus-show-threads)
7662 (gnus-possibly-generate-tree article)
7663 (gnus-highlight-selected-tree article))
7664 ;; Successfully display article.
7665 (gnus-article-set-window-start
7666 (cdr (assq article gnus-newsgroup-bookmarks))))))
7667
7668 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7669 "Select the current article.
7670 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7671 non-nil, the article will be re-fetched even if it already present in
7672 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7673 be displayed."
7674 ;; Make sure we are in the summary buffer to work around bbdb bug.
7675 (unless (eq major-mode 'gnus-summary-mode)
7676 (set-buffer gnus-summary-buffer))
7677 (let ((article (or article (gnus-summary-article-number)))
7678 (all-headers (not (not all-headers))) ;Must be t or nil.
7679 gnus-summary-display-article-function)
7680 (and (not pseudo)
7681 (gnus-summary-article-pseudo-p article)
7682 (error "This is a pseudo-article"))
7683 (with-current-buffer gnus-summary-buffer
7684 (if (or (and gnus-single-article-buffer
7685 (or (null gnus-current-article)
7686 (null gnus-article-current)
7687 (null (get-buffer gnus-article-buffer))
7688 (not (eq article (cdr gnus-article-current)))
7689 (not (equal (car gnus-article-current)
7690 gnus-newsgroup-name))
7691 (not (get-buffer gnus-original-article-buffer))))
7692 (and (not gnus-single-article-buffer)
7693 (or (null gnus-current-article)
7694 (not (get-buffer gnus-original-article-buffer))
7695 (not (eq gnus-current-article article))))
7696 force)
7697 ;; The requested article is different from the current article.
7698 (progn
7699 (gnus-summary-display-article article all-headers)
7700 (when (gnus-buffer-live-p gnus-article-buffer)
7701 (with-current-buffer gnus-article-buffer
7702 (if (not gnus-article-decoded-p) ;; a local variable
7703 (mm-disable-multibyte))))
7704 (gnus-article-set-window-start
7705 (cdr (assq article gnus-newsgroup-bookmarks)))
7706 article)
7707 'old))))
7708
7709 (defun gnus-summary-force-verify-and-decrypt ()
7710 "Display buttons for signed/encrypted parts and verify/decrypt them."
7711 (interactive)
7712 (let ((mm-verify-option 'known)
7713 (mm-decrypt-option 'known)
7714 (gnus-article-emulate-mime t)
7715 (gnus-buttonized-mime-types (append (list "multipart/signed"
7716 "multipart/encrypted")
7717 gnus-buttonized-mime-types)))
7718 (gnus-summary-select-article nil 'force)))
7719
7720 (defun gnus-summary-next-article (&optional unread subject backward push)
7721 "Select the next article.
7722 If UNREAD, only unread articles are selected.
7723 If SUBJECT, only articles with SUBJECT are selected.
7724 If BACKWARD, the previous article is selected instead of the next."
7725 (interactive "P")
7726 ;; Make sure we are in the summary buffer.
7727 (unless (eq major-mode 'gnus-summary-mode)
7728 (set-buffer gnus-summary-buffer))
7729 (cond
7730 ;; Is there such an article?
7731 ((and (gnus-summary-search-forward unread subject backward)
7732 (or (gnus-summary-display-article (gnus-summary-article-number))
7733 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7734 (gnus-summary-position-point))
7735 ;; If not, we try the first unread, if that is wanted.
7736 ((and subject
7737 gnus-auto-select-same
7738 (gnus-summary-first-unread-article))
7739 (gnus-summary-position-point)
7740 (gnus-message 6 "Wrapped"))
7741 ;; Try to get next/previous article not displayed in this group.
7742 ((and gnus-auto-extend-newsgroup
7743 (not unread) (not subject))
7744 (gnus-summary-goto-article
7745 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7746 nil (count-lines (point-min) (point))))
7747 ;; Go to next/previous group.
7748 (t
7749 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7750 (gnus-summary-jump-to-group gnus-newsgroup-name))
7751 (let ((cmd (if (featurep 'xemacs)
7752 last-command-char
7753 last-command-event))
7754 (point
7755 (with-current-buffer gnus-group-buffer
7756 (point)))
7757 (current-summary (current-buffer))
7758 (group
7759 (if (eq gnus-keep-same-level 'best)
7760 (gnus-summary-best-group gnus-newsgroup-name)
7761 (gnus-summary-search-group backward gnus-keep-same-level))))
7762 ;; Select next unread newsgroup automagically.
7763 (cond
7764 ((or (not gnus-auto-select-next)
7765 (not cmd))
7766 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7767 ((or (eq gnus-auto-select-next 'quietly)
7768 (and (eq gnus-auto-select-next 'slightly-quietly)
7769 push)
7770 (and (eq gnus-auto-select-next 'almost-quietly)
7771 (gnus-summary-last-article-p)))
7772 ;; Select quietly.
7773 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7774 (gnus-summary-exit)
7775 (gnus-message 7 "No more%s articles (%s)..."
7776 (if unread " unread" "")
7777 (if group (concat "selecting " group)
7778 "exiting"))
7779 (gnus-summary-next-group nil group backward)))
7780 (t
7781 (when (gnus-key-press-event-p last-input-event)
7782 ;; Somehow or other, we may now have selected a different
7783 ;; window. Make point go back to the summary buffer.
7784 (when (eq current-summary (current-buffer))
7785 ;; FIXME: This burps when get-buffer-window returns nil.
7786 (select-window (get-buffer-window current-summary 0)))
7787 (gnus-summary-walk-group-buffer
7788 gnus-newsgroup-name cmd unread backward point))))))))
7789
7790 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7791 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7792 (?\C-p (gnus-group-prev-unread-group 1))))
7793 (cursor-in-echo-area t)
7794 keve key group ended prompt)
7795 (with-current-buffer gnus-group-buffer
7796 (goto-char start)
7797 (setq group
7798 (if (eq gnus-keep-same-level 'best)
7799 (gnus-summary-best-group gnus-newsgroup-name)
7800 (gnus-summary-search-group backward gnus-keep-same-level))))
7801 (while (not ended)
7802 (setq prompt
7803 (format
7804 "No more%s articles%s " (if unread " unread" "")
7805 (if (and group
7806 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7807 (format " (Type %s for %s [%s])"
7808 (single-key-description cmd)
7809 (gnus-group-decoded-name group)
7810 (gnus-group-unread group))
7811 (format " (Type %s to exit %s)"
7812 (single-key-description cmd)
7813 (gnus-group-decoded-name gnus-newsgroup-name)))))
7814 ;; Confirm auto selection.
7815 (setq key (car (setq keve (gnus-read-event-char prompt)))
7816 ended t)
7817 (cond
7818 ((assq key keystrokes)
7819 (let ((obuf (current-buffer)))
7820 (switch-to-buffer gnus-group-buffer)
7821 (when group
7822 (gnus-group-jump-to-group group))
7823 (eval (cadr (assq key keystrokes)))
7824 (setq group (gnus-group-group-name))
7825 (switch-to-buffer obuf))
7826 (setq ended nil))
7827 ((equal key cmd)
7828 (if (or (not group)
7829 (gnus-ephemeral-group-p gnus-newsgroup-name))
7830 (gnus-summary-exit)
7831 (gnus-summary-next-group nil group backward)))
7832 (t
7833 (push (cdr keve) unread-command-events))))))
7834
7835 (defun gnus-summary-next-unread-article ()
7836 "Select unread article after current one."
7837 (interactive)
7838 (gnus-summary-next-article
7839 (or (not (eq gnus-summary-goto-unread 'never))
7840 (gnus-summary-last-article-p (gnus-summary-article-number)))
7841 (and gnus-auto-select-same
7842 (gnus-summary-article-subject))))
7843
7844 (defun gnus-summary-prev-article (&optional unread subject)
7845 "Select the article before the current one.
7846 If UNREAD is non-nil, only unread articles are selected."
7847 (interactive "P")
7848 (gnus-summary-next-article unread subject t))
7849
7850 (defun gnus-summary-prev-unread-article ()
7851 "Select unread article before current one."
7852 (interactive)
7853 (gnus-summary-prev-article
7854 (or (not (eq gnus-summary-goto-unread 'never))
7855 (gnus-summary-first-article-p (gnus-summary-article-number)))
7856 (and gnus-auto-select-same
7857 (gnus-summary-article-subject))))
7858
7859 (defun gnus-summary-next-page (&optional lines circular stop)
7860 "Show next page of the selected article.
7861 If at the end of the current article, select the next article.
7862 LINES says how many lines should be scrolled up.
7863
7864 If CIRCULAR is non-nil, go to the start of the article instead of
7865 selecting the next article when reaching the end of the current
7866 article.
7867
7868 If STOP is non-nil, just stop when reaching the end of the message.
7869
7870 Also see the variable `gnus-article-skip-boring'."
7871 (interactive "P")
7872 (gnus-set-global-variables)
7873 (let ((article (gnus-summary-article-number))
7874 (article-window (get-buffer-window gnus-article-buffer t))
7875 endp)
7876 ;; If the buffer is empty, we have no article.
7877 (unless article
7878 (error "No article to select"))
7879 (gnus-configure-windows 'article)
7880 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7881 (if (and (eq gnus-summary-goto-unread 'never)
7882 (not (gnus-summary-last-article-p article)))
7883 (gnus-summary-next-article)
7884 (gnus-summary-next-unread-article))
7885 (if (or (null gnus-current-article)
7886 (null gnus-article-current)
7887 (/= article (cdr gnus-article-current))
7888 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7889 ;; Selected subject is different from current article's.
7890 (gnus-summary-display-article article)
7891 (when article-window
7892 (gnus-eval-in-buffer-window gnus-article-buffer
7893 (setq endp (or (gnus-article-next-page lines)
7894 (gnus-article-only-boring-p))))
7895 (when endp
7896 (cond ((or stop gnus-summary-stop-at-end-of-message)
7897 (gnus-message 3 "End of message"))
7898 (circular
7899 (gnus-summary-beginning-of-article))
7900 (lines
7901 (gnus-message 3 "End of message"))
7902 ((null lines)
7903 (if (and (eq gnus-summary-goto-unread 'never)
7904 (not (gnus-summary-last-article-p article)))
7905 (gnus-summary-next-article)
7906 (gnus-summary-next-unread-article))))))))
7907 (gnus-summary-recenter)
7908 (gnus-summary-position-point)))
7909
7910 (defun gnus-summary-prev-page (&optional lines move)
7911 "Show previous page of selected article.
7912 Argument LINES specifies lines to be scrolled down.
7913 If MOVE, move to the previous unread article if point is at
7914 the beginning of the buffer."
7915 (interactive "P")
7916 (let ((article (gnus-summary-article-number))
7917 (article-window (get-buffer-window gnus-article-buffer t))
7918 endp)
7919 (gnus-configure-windows 'article)
7920 (if (or (null gnus-current-article)
7921 (null gnus-article-current)
7922 (/= article (cdr gnus-article-current))
7923 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7924 ;; Selected subject is different from current article's.
7925 (gnus-summary-display-article article)
7926 (gnus-summary-recenter)
7927 (when article-window
7928 (gnus-eval-in-buffer-window gnus-article-buffer
7929 (setq endp (gnus-article-prev-page lines)))
7930 (when (and move endp)
7931 (cond (lines
7932 (gnus-message 3 "Beginning of message"))
7933 ((null lines)
7934 (if (and (eq gnus-summary-goto-unread 'never)
7935 (not (gnus-summary-first-article-p article)))
7936 (gnus-summary-prev-article)
7937 (gnus-summary-prev-unread-article))))))))
7938 (gnus-summary-position-point))
7939
7940 (defun gnus-summary-prev-page-or-article (&optional lines)
7941 "Show previous page of selected article.
7942 Argument LINES specifies lines to be scrolled down.
7943 If at the beginning of the article, go to the next article."
7944 (interactive "P")
7945 (gnus-summary-prev-page lines t))
7946
7947 (defun gnus-summary-scroll-up (lines)
7948 "Scroll up (or down) one line current article.
7949 Argument LINES specifies lines to be scrolled up (or down if negative).
7950 If no article is selected, then the current article will be selected first."
7951 (interactive "p")
7952 (gnus-configure-windows 'article)
7953 (gnus-summary-show-thread)
7954 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7955 (gnus-eval-in-buffer-window gnus-article-buffer
7956 (cond ((> lines 0)
7957 (when (gnus-article-next-page lines)
7958 (gnus-message 3 "End of message")))
7959 ((< lines 0)
7960 (gnus-article-prev-page (- lines))))))
7961 (gnus-summary-recenter)
7962 (gnus-summary-position-point))
7963
7964 (defun gnus-summary-scroll-down (lines)
7965 "Scroll down (or up) one line current article.
7966 Argument LINES specifies lines to be scrolled down (or up if negative).
7967 If no article is selected, then the current article will be selected first."
7968 (interactive "p")
7969 (gnus-summary-scroll-up (- lines)))
7970
7971 (defun gnus-summary-next-same-subject ()
7972 "Select next article which has the same subject as current one."
7973 (interactive)
7974 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7975
7976 (defun gnus-summary-prev-same-subject ()
7977 "Select previous article which has the same subject as current one."
7978 (interactive)
7979 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7980
7981 (defun gnus-summary-next-unread-same-subject ()
7982 "Select next unread article which has the same subject as current one."
7983 (interactive)
7984 (gnus-summary-next-article t (gnus-summary-article-subject)))
7985
7986 (defun gnus-summary-prev-unread-same-subject ()
7987 "Select previous unread article which has the same subject as current one."
7988 (interactive)
7989 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7990
7991 (defun gnus-summary-first-unread-article ()
7992 "Select the first unread article.
7993 Return nil if there are no unread articles."
7994 (interactive)
7995 (prog1
7996 (when (gnus-summary-first-subject t)
7997 (gnus-summary-show-thread)
7998 (gnus-summary-first-subject t)
7999 (gnus-summary-display-article (gnus-summary-article-number)))
8000 (gnus-summary-position-point)))
8001
8002 (defun gnus-summary-first-unread-subject ()
8003 "Place the point on the subject line of the first unread article.
8004 Return nil if there are no unread articles."
8005 (interactive)
8006 (prog1
8007 (when (gnus-summary-first-subject t)
8008 (gnus-summary-show-thread)
8009 (gnus-summary-first-subject t))
8010 (gnus-summary-position-point)))
8011
8012 (defun gnus-summary-first-unseen-subject ()
8013 "Place the point on the subject line of the first unseen article.
8014 Return nil if there are no unseen articles."
8015 (interactive)
8016 (prog1
8017 (when (gnus-summary-first-subject nil nil t)
8018 (gnus-summary-show-thread)
8019 (gnus-summary-first-subject nil nil t))
8020 (gnus-summary-position-point)))
8021
8022 (defun gnus-summary-first-unseen-or-unread-subject ()
8023 "Place the point on the subject line of the first unseen and unread article.
8024 If all article have been seen, on the subject line of the first unread
8025 article."
8026 (interactive)
8027 (prog1
8028 (unless (when (gnus-summary-first-subject nil nil t)
8029 (gnus-summary-show-thread)
8030 (gnus-summary-first-subject nil nil t))
8031 (when (gnus-summary-first-subject t)
8032 (gnus-summary-show-thread)
8033 (gnus-summary-first-subject t)))
8034 (gnus-summary-position-point)))
8035
8036 (defun gnus-summary-first-article ()
8037 "Select the first article.
8038 Return nil if there are no articles."
8039 (interactive)
8040 (prog1
8041 (when (gnus-summary-first-subject)
8042 (gnus-summary-show-thread)
8043 (gnus-summary-first-subject)
8044 (gnus-summary-display-article (gnus-summary-article-number)))
8045 (gnus-summary-position-point)))
8046
8047 (defun gnus-summary-best-unread-article (&optional arg)
8048 "Select the unread article with the highest score.
8049 If given a prefix argument, select the next unread article that has a
8050 score higher than the default score."
8051 (interactive "P")
8052 (let ((article (if arg
8053 (gnus-summary-better-unread-subject)
8054 (gnus-summary-best-unread-subject))))
8055 (if article
8056 (gnus-summary-goto-article article)
8057 (error "No unread articles"))))
8058
8059 (defun gnus-summary-best-unread-subject ()
8060 "Select the unread subject with the highest score."
8061 (interactive)
8062 (let ((best -1000000)
8063 (data gnus-newsgroup-data)
8064 article score)
8065 (while data
8066 (and (gnus-data-unread-p (car data))
8067 (> (setq score
8068 (gnus-summary-article-score (gnus-data-number (car data))))
8069 best)
8070 (setq best score
8071 article (gnus-data-number (car data))))
8072 (setq data (cdr data)))
8073 (when article
8074 (gnus-summary-goto-subject article))
8075 (gnus-summary-position-point)
8076 article))
8077
8078 (defun gnus-summary-better-unread-subject ()
8079 "Select the first unread subject that has a score over the default score."
8080 (interactive)
8081 (let ((data gnus-newsgroup-data)
8082 article score)
8083 (while (and (setq article (gnus-data-number (car data)))
8084 (or (gnus-data-read-p (car data))
8085 (not (> (gnus-summary-article-score article)
8086 gnus-summary-default-score))))
8087 (setq data (cdr data)))
8088 (when article
8089 (gnus-summary-goto-subject article))
8090 (gnus-summary-position-point)
8091 article))
8092
8093 (defun gnus-summary-last-subject ()
8094 "Go to the last displayed subject line in the group."
8095 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8096 (when article
8097 (gnus-summary-goto-subject article))))
8098
8099 (defun gnus-summary-goto-article (article &optional all-headers force)
8100 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8101 If ALL-HEADERS is non-nil, no header lines are hidden.
8102 If FORCE, go to the article even if it isn't displayed. If FORCE
8103 is a number, it is the line the article is to be displayed on."
8104 (interactive
8105 (list
8106 (gnus-completing-read
8107 "Article number or Message-ID"
8108 (mapcar 'int-to-string gnus-newsgroup-limit))
8109 current-prefix-arg
8110 t))
8111 (prog1
8112 (if (and (stringp article)
8113 (string-match "@\\|%40" article))
8114 (gnus-summary-refer-article article)
8115 (when (stringp article)
8116 (setq article (string-to-number article)))
8117 (if (gnus-summary-goto-subject article force)
8118 (gnus-summary-display-article article all-headers)
8119 (gnus-message 4 "Couldn't go to article %s" article) nil))
8120 (gnus-summary-position-point)))
8121
8122 (defun gnus-summary-goto-last-article ()
8123 "Go to the previously read article."
8124 (interactive)
8125 (prog1
8126 (when gnus-last-article
8127 (gnus-summary-goto-article gnus-last-article nil t))
8128 (gnus-summary-position-point)))
8129
8130 (defun gnus-summary-pop-article (number)
8131 "Pop one article off the history and go to the previous.
8132 NUMBER articles will be popped off."
8133 (interactive "p")
8134 (let (to)
8135 (setq gnus-newsgroup-history
8136 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8137 (if to
8138 (gnus-summary-goto-article (car to) nil t)
8139 (error "Article history empty")))
8140 (gnus-summary-position-point))
8141
8142 ;; Summary commands and functions for limiting the summary buffer.
8143
8144 (defun gnus-summary-limit-to-articles (n)
8145 "Limit the summary buffer to the next N articles.
8146 If not given a prefix, use the process marked articles instead."
8147 (interactive "P")
8148 (prog1
8149 (let ((articles (gnus-summary-work-articles n)))
8150 (setq gnus-newsgroup-processable nil)
8151 (gnus-summary-limit articles))
8152 (gnus-summary-position-point)))
8153
8154 (defun gnus-summary-pop-limit (&optional total)
8155 "Restore the previous limit.
8156 If given a prefix, remove all limits."
8157 (interactive "P")
8158 (when total
8159 (setq gnus-newsgroup-limits
8160 (list (mapcar (lambda (h) (mail-header-number h))
8161 gnus-newsgroup-headers))))
8162 (unless gnus-newsgroup-limits
8163 (error "No limit to pop"))
8164 (prog1
8165 (gnus-summary-limit nil 'pop)
8166 (gnus-summary-position-point)))
8167
8168 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8169 "Limit the summary buffer to articles that have subjects that match a regexp.
8170 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8171 (interactive
8172 (list (read-string (if current-prefix-arg
8173 "Exclude subject (regexp): "
8174 "Limit to subject (regexp): "))
8175 nil current-prefix-arg))
8176 (unless header
8177 (setq header "subject"))
8178 (when (not (equal "" subject))
8179 (prog1
8180 (let ((articles (gnus-summary-find-matching
8181 (or header "subject") subject 'all nil nil
8182 not-matching)))
8183 (unless articles
8184 (error "Found no matches for \"%s\"" subject))
8185 (gnus-summary-limit articles))
8186 (gnus-summary-position-point))))
8187
8188 (defun gnus-summary-limit-to-author (from &optional not-matching)
8189 "Limit the summary buffer to articles that have authors that match a regexp.
8190 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8191 (interactive
8192 (list (let* ((header (gnus-summary-article-header))
8193 (default (and header (car (mail-header-parse-address
8194 (mail-header-from header))))))
8195 (read-string (concat (if current-prefix-arg
8196 "Exclude author (regexp"
8197 "Limit to author (regexp")
8198 (if default
8199 (concat ", default \"" default "\"): ")
8200 "): "))
8201 nil nil
8202 default))
8203 current-prefix-arg))
8204 (gnus-summary-limit-to-subject from "from" not-matching))
8205
8206 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8207 "Limit the summary buffer to articles with the given RECIPIENT.
8208
8209 If NOT-MATCHING, exclude RECIPIENT.
8210
8211 To and Cc headers are checked. You need to include them in
8212 `nnmail-extra-headers'."
8213 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8214 (interactive
8215 (list (read-string (format "%s recipient (regexp): "
8216 (if current-prefix-arg "Exclude" "Limit to")))
8217 current-prefix-arg))
8218 (when (not (equal "" recipient))
8219 (prog1 (let* ((to
8220 (if (memq 'To nnmail-extra-headers)
8221 (gnus-summary-find-matching
8222 (cons 'extra 'To) recipient 'all nil nil
8223 not-matching)
8224 (gnus-message
8225 1 "`To' isn't present in `nnmail-extra-headers'")
8226 (sit-for 1)
8227 nil))
8228 (cc
8229 (if (memq 'Cc nnmail-extra-headers)
8230 (gnus-summary-find-matching
8231 (cons 'extra 'Cc) recipient 'all nil nil
8232 not-matching)
8233 (gnus-message
8234 1 "`Cc' isn't present in `nnmail-extra-headers'")
8235 (sit-for 1)
8236 nil))
8237 (articles
8238 (if not-matching
8239 ;; We need the numbers that are in both lists:
8240 (mapcar (lambda (a)
8241 (and (memq a to) a))
8242 cc)
8243 (nconc to cc))))
8244 (unless articles
8245 (error "Found no matches for \"%s\"" recipient))
8246 (gnus-summary-limit articles))
8247 (gnus-summary-position-point))))
8248
8249 (defun gnus-summary-limit-to-address (address &optional not-matching)
8250 "Limit the summary buffer to articles with the given ADDRESS.
8251
8252 If NOT-MATCHING, exclude ADDRESS.
8253
8254 To, Cc and From headers are checked. You need to include `To' and `Cc'
8255 in `nnmail-extra-headers'."
8256 (interactive
8257 (list (read-string (format "%s address (regexp): "
8258 (if current-prefix-arg "Exclude" "Limit to")))
8259 current-prefix-arg))
8260 (when (not (equal "" address))
8261 (prog1 (let* ((to
8262 (if (memq 'To nnmail-extra-headers)
8263 (gnus-summary-find-matching
8264 (cons 'extra 'To) address 'all nil nil
8265 not-matching)
8266 (gnus-message
8267 1 "`To' isn't present in `nnmail-extra-headers'")
8268 (sit-for 1)
8269 t))
8270 (cc
8271 (if (memq 'Cc nnmail-extra-headers)
8272 (gnus-summary-find-matching
8273 (cons 'extra 'Cc) address 'all nil nil
8274 not-matching)
8275 (gnus-message
8276 1 "`Cc' isn't present in `nnmail-extra-headers'")
8277 (sit-for 1)
8278 t))
8279 (from
8280 (gnus-summary-find-matching "from" address
8281 'all nil nil not-matching))
8282 (articles
8283 (if not-matching
8284 ;; We need the numbers that are in all lists:
8285 (if (eq cc t)
8286 (if (eq to t)
8287 from
8288 (mapcar (lambda (a) (car (memq a from))) to))
8289 (if (eq to t)
8290 (mapcar (lambda (a) (car (memq a from))) cc)
8291 (mapcar (lambda (a) (car (memq a from)))
8292 (mapcar (lambda (a) (car (memq a to)))
8293 cc))))
8294 (nconc (if (eq to t) nil to)
8295 (if (eq cc t) nil cc)
8296 from))))
8297 (unless articles
8298 (error "Found no matches for \"%s\"" address))
8299 (gnus-summary-limit articles))
8300 (gnus-summary-position-point))))
8301
8302 (defun gnus-summary-limit-strange-charsets-predicate (header)
8303 (when (fboundp 'char-charset)
8304 (let ((string (concat (mail-header-subject header)
8305 (mail-header-from header)))
8306 charset found)
8307 (dotimes (i (1- (length string)))
8308 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8309 (when (string-match "unicode\\|big\\|japanese" charset)
8310 (setq found t)))
8311 found)))
8312
8313 (defun gnus-summary-limit-to-predicate (predicate)
8314 "Limit to articles where PREDICATE returns non-nil.
8315 PREDICATE will be called with the header structures of the
8316 articles."
8317 (let ((articles nil)
8318 (case-fold-search t))
8319 (dolist (header gnus-newsgroup-headers)
8320 (when (funcall predicate header)
8321 (push (mail-header-number header) articles)))
8322 (gnus-summary-limit (nreverse articles))))
8323
8324 (defun gnus-summary-limit-to-age (age &optional younger-p)
8325 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8326 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8327 articles that are younger than AGE days."
8328 (interactive
8329 (let ((younger current-prefix-arg)
8330 (days-got nil)
8331 days)
8332 (while (not days-got)
8333 (setq days (if younger
8334 (read-string "Limit to articles younger than (in days, older when negative): ")
8335 (read-string
8336 "Limit to articles older than (in days, younger when negative): ")))
8337 (when (> (length days) 0)
8338 (setq days (read days)))
8339 (if (numberp days)
8340 (progn
8341 (setq days-got t)
8342 (when (< days 0)
8343 (setq younger (not younger))
8344 (setq days (* days -1))))
8345 (message "Please enter a number.")
8346 (sleep-for 1)))
8347 (list days younger)))
8348 (prog1
8349 (let ((data gnus-newsgroup-data)
8350 (cutoff (days-to-time age))
8351 articles d date is-younger)
8352 (while (setq d (pop data))
8353 (when (and (vectorp (gnus-data-header d))
8354 (setq date (mail-header-date (gnus-data-header d))))
8355 (setq is-younger (time-less-p
8356 (time-since (gnus-date-get-time date))
8357 cutoff))
8358 (when (if younger-p
8359 is-younger
8360 (not is-younger))
8361 (push (gnus-data-number d) articles))))
8362 (gnus-summary-limit (nreverse articles)))
8363 (gnus-summary-position-point)))
8364
8365 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8366 "Limit the summary buffer to articles that match an 'extra' header."
8367 (interactive
8368 (let ((header
8369 (intern
8370 (gnus-completing-read
8371 (if current-prefix-arg
8372 "Exclude extra header"
8373 "Limit extra header")
8374 (mapcar 'symbol-name gnus-extra-headers)
8375 t nil nil
8376 (symbol-name (car gnus-extra-headers))))))
8377 (list header
8378 (read-string (format "%s header %s (regexp): "
8379 (if current-prefix-arg "Exclude" "Limit to")
8380 header))
8381 current-prefix-arg)))
8382 (when (not (equal "" regexp))
8383 (prog1
8384 (let ((articles (gnus-summary-find-matching
8385 (cons 'extra header) regexp 'all nil nil
8386 not-matching)))
8387 (unless articles
8388 (error "Found no matches for \"%s\"" regexp))
8389 (gnus-summary-limit articles))
8390 (gnus-summary-position-point))))
8391
8392 (defun gnus-summary-limit-to-display-predicate ()
8393 "Limit the summary buffer to the predicated in the `display' group parameter."
8394 (interactive)
8395 (unless gnus-newsgroup-display
8396 (error "There is no `display' group parameter"))
8397 (let (articles)
8398 (dolist (gnus-number gnus-newsgroup-articles)
8399 (when (funcall gnus-newsgroup-display)
8400 (push gnus-number articles)))
8401 (gnus-summary-limit articles))
8402 (gnus-summary-position-point))
8403
8404 (defun gnus-summary-limit-to-unread (&optional all)
8405 "Limit the summary buffer to articles that are not marked as read.
8406 If ALL is non-nil, limit strictly to unread articles."
8407 (interactive "P")
8408 (if all
8409 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8410 (gnus-summary-limit-to-marks
8411 ;; Concat all the marks that say that an article is read and have
8412 ;; those removed.
8413 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8414 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8415 gnus-low-score-mark gnus-expirable-mark
8416 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8417 gnus-duplicate-mark)
8418 'reverse)))
8419
8420 (defun gnus-summary-limit-to-headers (match &optional reverse)
8421 "Limit the summary buffer to articles that have headers that match MATCH.
8422 If REVERSE (the prefix), limit to articles that don't match."
8423 (interactive "sMatch headers (regexp): \nP")
8424 (gnus-summary-limit-to-bodies match reverse t))
8425
8426 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8427 "Limit the summary buffer to articles that have bodies that match MATCH.
8428 If REVERSE (the prefix), limit to articles that don't match."
8429 (interactive "sMatch body (regexp): \nP")
8430 (let ((articles nil)
8431 (gnus-select-article-hook nil) ;Disable hook.
8432 (gnus-article-prepare-hook nil)
8433 (gnus-use-article-prefetch nil)
8434 (gnus-keep-backlog nil)
8435 (gnus-break-pages nil)
8436 (gnus-summary-display-arrow nil)
8437 (gnus-updated-mode-lines nil)
8438 (gnus-auto-center-summary nil)
8439 (gnus-display-mime-function nil))
8440 (dolist (data gnus-newsgroup-data)
8441 (let (gnus-mark-article-hook)
8442 (gnus-summary-select-article t t nil (gnus-data-number data)))
8443 (with-current-buffer gnus-article-buffer
8444 (article-goto-body)
8445 (let* ((case-fold-search t)
8446 (found (if headersp
8447 (re-search-backward match nil t)
8448 (re-search-forward match nil t))))
8449 (when (or (and found
8450 (not reverse))
8451 (and (not found)
8452 reverse))
8453 (push (gnus-data-number data) articles)))))
8454 (if (not articles)
8455 (message "No messages matched")
8456 (gnus-summary-limit articles)))
8457 (gnus-summary-position-point))
8458
8459 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8460 "Limit the summary buffer to articles that aren't part on any thread.
8461 If THREADSP (the prefix), limit to articles that are in threads."
8462 (interactive "P")
8463 (let ((articles nil)
8464 thread-articles
8465 threads)
8466 (dolist (thread gnus-newsgroup-threads)
8467 (if (stringp (car thread))
8468 (dolist (thread (cdr thread))
8469 (push thread threads))
8470 (push thread threads)))
8471 (dolist (thread threads)
8472 (setq thread-articles (gnus-articles-in-thread thread))
8473 (when (or (and threadsp
8474 (> (length thread-articles) 1))
8475 (and (not threadsp)
8476 (= (length thread-articles) 1)))
8477 (setq articles (nconc thread-articles articles))))
8478 (if (not articles)
8479 (message "No messages matched")
8480 (gnus-summary-limit articles))
8481 (gnus-summary-position-point)))
8482
8483 (defun gnus-summary-limit-to-replied (&optional unreplied)
8484 "Limit the summary buffer to replied articles.
8485 If UNREPLIED (the prefix), limit to unreplied articles."
8486 (interactive "P")
8487 (if unreplied
8488 (gnus-summary-limit
8489 (gnus-set-difference gnus-newsgroup-articles
8490 gnus-newsgroup-replied))
8491 (gnus-summary-limit gnus-newsgroup-replied))
8492 (gnus-summary-position-point))
8493
8494 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8495 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8496 If REVERSE, limit the summary buffer to articles that are marked
8497 with MARKS. MARKS can either be a string of marks or a list of marks.
8498 Returns how many articles were removed."
8499 (interactive "sMarks: ")
8500 (gnus-summary-limit-to-marks marks t))
8501
8502 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8503 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8504 If REVERSE (the prefix), limit the summary buffer to articles that are
8505 not marked with MARKS. MARKS can either be a string of marks or a
8506 list of marks.
8507 Returns how many articles were removed."
8508 (interactive "sMarks: \nP")
8509 (prog1
8510 (let ((data gnus-newsgroup-data)
8511 (marks (if (listp marks) marks
8512 (append marks nil))) ; Transform to list.
8513 articles)
8514 (while data
8515 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8516 (memq (gnus-data-mark (car data)) marks))
8517 (push (gnus-data-number (car data)) articles))
8518 (setq data (cdr data)))
8519 (gnus-summary-limit articles))
8520 (gnus-summary-position-point)))
8521
8522 (defun gnus-summary-limit-to-score (score)
8523 "Limit to articles with score at or above SCORE."
8524 (interactive "NLimit to articles with score of at least: ")
8525 (let ((data gnus-newsgroup-data)
8526 articles)
8527 (while data
8528 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8529 score)
8530 (push (gnus-data-number (car data)) articles))
8531 (setq data (cdr data)))
8532 (prog1
8533 (gnus-summary-limit articles)
8534 (gnus-summary-position-point))))
8535
8536 (defun gnus-summary-limit-to-unseen ()
8537 "Limit to unseen articles."
8538 (interactive)
8539 (prog1
8540 (gnus-summary-limit gnus-newsgroup-unseen)
8541 (gnus-summary-position-point)))
8542
8543 (defun gnus-summary-limit-include-thread (id)
8544 "Display all the hidden articles that is in the thread with ID in it.
8545 When called interactively, ID is the Message-ID of the current
8546 article."
8547 (interactive (list (mail-header-id (gnus-summary-article-header))))
8548 (let ((articles (gnus-articles-in-thread
8549 (gnus-id-to-thread (gnus-root-id id))))
8550 ;;we REALLY want the whole thread---this prevents cut-threads
8551 ;;from removing the thread we want to include.
8552 (gnus-fetch-old-headers nil)
8553 (gnus-build-sparse-threads nil))
8554 (prog1
8555 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8556 (gnus-summary-limit-include-matching-articles
8557 "subject"
8558 (regexp-quote (gnus-simplify-subject-re
8559 (mail-header-subject (gnus-id-to-header id)))))
8560 (gnus-summary-position-point))))
8561
8562 (defun gnus-summary-limit-include-matching-articles (header regexp)
8563 "Display all the hidden articles that have HEADERs that match REGEXP."
8564 (interactive (list (read-string "Match on header: ")
8565 (read-string "Regexp: ")))
8566 (let ((articles (gnus-find-matching-articles header regexp)))
8567 (prog1
8568 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8569 (gnus-summary-position-point))))
8570
8571 (defun gnus-summary-insert-dormant-articles ()
8572 "Insert all the dormant articles for this group into the current buffer."
8573 (interactive)
8574 (let ((gnus-verbose (max 6 gnus-verbose)))
8575 (if (not gnus-newsgroup-dormant)
8576 (gnus-message 3 "No dormant articles for this group")
8577 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8578
8579 (defun gnus-summary-insert-ticked-articles ()
8580 "Insert ticked articles for this group into the current buffer."
8581 (interactive)
8582 (let ((gnus-verbose (max 6 gnus-verbose)))
8583 (if (not gnus-newsgroup-marked)
8584 (gnus-message 3 "No ticked articles for this group")
8585 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8586
8587 (defun gnus-summary-limit-include-dormant ()
8588 "Display all the hidden articles that are marked as dormant.
8589 Note that this command only works on a subset of the articles currently
8590 fetched for this group."
8591 (interactive)
8592 (unless gnus-newsgroup-dormant
8593 (error "There are no dormant articles in this group"))
8594 (prog1
8595 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8596 (gnus-summary-position-point)))
8597
8598 (defun gnus-summary-include-articles (articles)
8599 "Fetch the headers for ARTICLES and then display the summary lines."
8600 (let ((gnus-inhibit-demon t)
8601 (gnus-agent nil)
8602 (gnus-read-all-available-headers t))
8603 (setq gnus-newsgroup-headers
8604 (gnus-merge
8605 'list gnus-newsgroup-headers
8606 (gnus-fetch-headers articles nil t)
8607 'gnus-article-sort-by-number))
8608 (setq gnus-newsgroup-articles
8609 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8610 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8611
8612 (defun gnus-summary-limit-exclude-dormant ()
8613 "Hide all dormant articles."
8614 (interactive)
8615 (prog1
8616 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8617 (gnus-summary-position-point)))
8618
8619 (defun gnus-summary-limit-exclude-childless-dormant ()
8620 "Hide all dormant articles that have no children."
8621 (interactive)
8622 (let ((data (gnus-data-list t))
8623 articles d children)
8624 ;; Find all articles that are either not dormant or have
8625 ;; children.
8626 (while (setq d (pop data))
8627 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8628 (and (setq children
8629 (gnus-article-children (gnus-data-number d)))
8630 (let (found)
8631 (while children
8632 (when (memq (car children) articles)
8633 (setq children nil
8634 found t))
8635 (pop children))
8636 found)))
8637 (push (gnus-data-number d) articles)))
8638 ;; Do the limiting.
8639 (prog1
8640 (gnus-summary-limit articles)
8641 (gnus-summary-position-point))))
8642
8643 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8644 "Mark all unread excluded articles as read.
8645 If ALL, mark even excluded ticked and dormants as read."
8646 (interactive "P")
8647 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8648 (let ((articles (gnus-sorted-ndifference
8649 (sort
8650 (mapcar (lambda (h) (mail-header-number h))
8651 gnus-newsgroup-headers)
8652 '<)
8653 gnus-newsgroup-limit))
8654 article)
8655 (setq gnus-newsgroup-unreads
8656 (gnus-sorted-intersection gnus-newsgroup-unreads
8657 gnus-newsgroup-limit))
8658 (if all
8659 (setq gnus-newsgroup-dormant nil
8660 gnus-newsgroup-marked nil
8661 gnus-newsgroup-reads
8662 (nconc
8663 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8664 gnus-newsgroup-reads))
8665 (while (setq article (pop articles))
8666 (unless (or (memq article gnus-newsgroup-dormant)
8667 (memq article gnus-newsgroup-marked))
8668 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8669
8670 (defun gnus-summary-limit (articles &optional pop)
8671 (if pop
8672 ;; We pop the previous limit off the stack and use that.
8673 (setq articles (car gnus-newsgroup-limits)
8674 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8675 ;; We use the new limit, so we push the old limit on the stack.
8676 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8677 ;; Set the limit.
8678 (setq gnus-newsgroup-limit articles)
8679 (let ((total (length gnus-newsgroup-data))
8680 (data (gnus-data-find-list (gnus-summary-article-number)))
8681 (gnus-summary-mark-below nil) ; Inhibit this.
8682 found)
8683 ;; This will do all the work of generating the new summary buffer
8684 ;; according to the new limit.
8685 (gnus-summary-prepare)
8686 ;; Hide any threads, possibly.
8687 (gnus-summary-maybe-hide-threads)
8688 ;; Try to return to the article you were at, or one in the
8689 ;; neighborhood.
8690 (when data
8691 ;; We try to find some article after the current one.
8692 (while data
8693 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8694 (setq data nil
8695 found t))
8696 (setq data (cdr data))))
8697 (unless found
8698 ;; If there is no data, that means that we were after the last
8699 ;; article. The same goes when we can't find any articles
8700 ;; after the current one.
8701 (goto-char (point-max))
8702 (gnus-summary-find-prev))
8703 (gnus-set-mode-line 'summary)
8704 ;; We return how many articles were removed from the summary
8705 ;; buffer as a result of the new limit.
8706 (- total (length gnus-newsgroup-data))))
8707
8708 (defsubst gnus-invisible-cut-children (threads)
8709 (let ((num 0))
8710 (while threads
8711 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8712 (incf num))
8713 (pop threads))
8714 (< num 2)))
8715
8716 (defsubst gnus-cut-thread (thread)
8717 "Go forwards in the thread until we find an article that we want to display."
8718 (when (or (eq gnus-fetch-old-headers 'some)
8719 (eq gnus-fetch-old-headers 'invisible)
8720 (numberp gnus-fetch-old-headers)
8721 (eq gnus-build-sparse-threads 'some)
8722 (eq gnus-build-sparse-threads 'more))
8723 ;; Deal with old-fetched headers and sparse threads.
8724 (while (and
8725 thread
8726 (or
8727 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8728 (gnus-summary-article-ancient-p
8729 (mail-header-number (car thread))))
8730 (if (or (<= (length (cdr thread)) 1)
8731 (eq gnus-fetch-old-headers 'invisible))
8732 (setq gnus-newsgroup-limit
8733 (delq (mail-header-number (car thread))
8734 gnus-newsgroup-limit)
8735 thread (cadr thread))
8736 (when (gnus-invisible-cut-children (cdr thread))
8737 (let ((th (cdr thread)))
8738 (while th
8739 (if (memq (mail-header-number (caar th))
8740 gnus-newsgroup-limit)
8741 (setq thread (car th)
8742 th nil)
8743 (setq th (cdr th))))))))))
8744 thread)
8745
8746 (defun gnus-cut-threads (threads)
8747 "Cut off all uninteresting articles from the beginning of THREADS."
8748 (when (or (eq gnus-fetch-old-headers 'some)
8749 (eq gnus-fetch-old-headers 'invisible)
8750 (numberp gnus-fetch-old-headers)
8751 (eq gnus-build-sparse-threads 'some)
8752 (eq gnus-build-sparse-threads 'more))
8753 (let ((th threads))
8754 (while th
8755 (setcar th (gnus-cut-thread (car th)))
8756 (setq th (cdr th)))))
8757 ;; Remove nixed out threads.
8758 (delq nil threads))
8759
8760 (defun gnus-summary-initial-limit (&optional show-if-empty)
8761 "Figure out what the initial limit is supposed to be on group entry.
8762 This entails weeding out unwanted dormants, low-scored articles,
8763 fetch-old-headers verbiage, and so on."
8764 ;; Most groups have nothing to remove.
8765 (unless (or gnus-inhibit-limiting
8766 (and (null gnus-newsgroup-dormant)
8767 (eq gnus-newsgroup-display 'gnus-not-ignore)
8768 (not (eq gnus-fetch-old-headers 'some))
8769 (not (numberp gnus-fetch-old-headers))
8770 (not (eq gnus-fetch-old-headers 'invisible))
8771 (null gnus-summary-expunge-below)
8772 (not (eq gnus-build-sparse-threads 'some))
8773 (not (eq gnus-build-sparse-threads 'more))
8774 (null gnus-thread-expunge-below)))
8775 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8776 (setq gnus-newsgroup-limit nil)
8777 (mapatoms
8778 (lambda (node)
8779 (unless (car (symbol-value node))
8780 ;; These threads have no parents -- they are roots.
8781 (let ((nodes (cdr (symbol-value node)))
8782 thread)
8783 (while nodes
8784 (if (and gnus-thread-expunge-below
8785 (< (gnus-thread-total-score (car nodes))
8786 gnus-thread-expunge-below))
8787 (gnus-expunge-thread (pop nodes))
8788 (setq thread (pop nodes))
8789 (gnus-summary-limit-children thread))))))
8790 gnus-newsgroup-dependencies)
8791 ;; If this limitation resulted in an empty group, we might
8792 ;; pop the previous limit and use it instead.
8793 (when (and (not gnus-newsgroup-limit)
8794 show-if-empty)
8795 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8796 gnus-newsgroup-limit))
8797
8798 (defun gnus-summary-limit-children (thread)
8799 "Return 1 if this subthread is visible and 0 if it is not."
8800 ;; First we get the number of visible children to this thread. This
8801 ;; is done by recursing down the thread using this function, so this
8802 ;; will really go down to a leaf article first, before slowly
8803 ;; working its way up towards the root.
8804 (when thread
8805 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8806 (children
8807 (if (cdr thread)
8808 (apply '+ (mapcar 'gnus-summary-limit-children
8809 (cdr thread)))
8810 0))
8811 (number (mail-header-number (car thread)))
8812 score)
8813 (if (and
8814 (not (memq number gnus-newsgroup-marked))
8815 (or
8816 ;; If this article is dormant and has absolutely no visible
8817 ;; children, then this article isn't visible.
8818 (and (memq number gnus-newsgroup-dormant)
8819 (zerop children))
8820 ;; If this is "fetch-old-headered" and there is no
8821 ;; visible children, then we don't want this article.
8822 (and (or (eq gnus-fetch-old-headers 'some)
8823 (numberp gnus-fetch-old-headers))
8824 (gnus-summary-article-ancient-p number)
8825 (zerop children))
8826 ;; If this is "fetch-old-headered" and `invisible', then
8827 ;; we don't want this article.
8828 (and (eq gnus-fetch-old-headers 'invisible)
8829 (gnus-summary-article-ancient-p number))
8830 ;; If this is a sparsely inserted article with no children,
8831 ;; we don't want it.
8832 (and (eq gnus-build-sparse-threads 'some)
8833 (gnus-summary-article-sparse-p number)
8834 (zerop children))
8835 ;; If we use expunging, and this article is really
8836 ;; low-scored, then we don't want this article.
8837 (when (and gnus-summary-expunge-below
8838 (< (setq score
8839 (or (cdr (assq number gnus-newsgroup-scored))
8840 gnus-summary-default-score))
8841 gnus-summary-expunge-below))
8842 ;; We increase the expunge-tally here, but that has
8843 ;; nothing to do with the limits, really.
8844 (incf gnus-newsgroup-expunged-tally)
8845 ;; We also mark as read here, if that's wanted.
8846 (when (and gnus-summary-mark-below
8847 (< score gnus-summary-mark-below))
8848 (setq gnus-newsgroup-unreads
8849 (delq number gnus-newsgroup-unreads))
8850 (if gnus-newsgroup-auto-expire
8851 (push number gnus-newsgroup-expirable)
8852 (push (cons number gnus-low-score-mark)
8853 gnus-newsgroup-reads)))
8854 t)
8855 ;; Do the `display' group parameter.
8856 (and gnus-newsgroup-display
8857 (let ((gnus-number number))
8858 (not (funcall gnus-newsgroup-display))))))
8859 ;; Nope, invisible article.
8860 0
8861 ;; Ok, this article is to be visible, so we add it to the limit
8862 ;; and return 1.
8863 (push number gnus-newsgroup-limit)
8864 1))))
8865
8866 (defun gnus-expunge-thread (thread)
8867 "Mark all articles in THREAD as read."
8868 (let* ((number (mail-header-number (car thread))))
8869 (incf gnus-newsgroup-expunged-tally)
8870 ;; We also mark as read here, if that's wanted.
8871 (setq gnus-newsgroup-unreads
8872 (delq number gnus-newsgroup-unreads))
8873 (if gnus-newsgroup-auto-expire
8874 (push number gnus-newsgroup-expirable)
8875 (push (cons number gnus-low-score-mark)
8876 gnus-newsgroup-reads)))
8877 ;; Go recursively through all subthreads.
8878 (mapcar 'gnus-expunge-thread (cdr thread)))
8879
8880 ;; Summary article oriented commands
8881
8882 (defun gnus-summary-refer-parent-article (n)
8883 "Refer parent article N times.
8884 If N is negative, go to ancestor -N instead.
8885 The difference between N and the number of articles fetched is returned."
8886 (interactive "p")
8887 (let ((skip 1)
8888 error header ref)
8889 (when (not (natnump n))
8890 (setq skip (abs n)
8891 n 1))
8892 (while (and (> n 0)
8893 (not error))
8894 (setq header (gnus-summary-article-header))
8895 (if (and (eq (mail-header-number header)
8896 (cdr gnus-article-current))
8897 (equal gnus-newsgroup-name
8898 (car gnus-article-current)))
8899 ;; If we try to find the parent of the currently
8900 ;; displayed article, then we take a look at the actual
8901 ;; References header, since this is slightly more
8902 ;; reliable than the References field we got from the
8903 ;; server.
8904 (with-current-buffer gnus-original-article-buffer
8905 (nnheader-narrow-to-headers)
8906 (unless (setq ref (message-fetch-field "references"))
8907 (when (setq ref (message-fetch-field "in-reply-to"))
8908 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8909 (widen))
8910 (setq ref
8911 ;; It's not the current article, so we take a bet on
8912 ;; the value we got from the server.
8913 (mail-header-references header)))
8914 (if (and ref
8915 (not (equal ref "")))
8916 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8917 (gnus-message 1 "Couldn't find parent"))
8918 (gnus-message 1 "No references in article %d"
8919 (gnus-summary-article-number))
8920 (setq error t))
8921 (decf n))
8922 (gnus-summary-position-point)
8923 n))
8924
8925 (defun gnus-summary-refer-references ()
8926 "Fetch all articles mentioned in the References header.
8927 Return the number of articles fetched."
8928 (interactive)
8929 (let ((ref (mail-header-references (gnus-summary-article-header)))
8930 (current (gnus-summary-article-number))
8931 (n 0))
8932 (if (or (not ref)
8933 (equal ref ""))
8934 (error "No References in the current article")
8935 ;; For each Message-ID in the References header...
8936 (while (string-match "<[^>]*>" ref)
8937 (incf n)
8938 ;; ... fetch that article.
8939 (gnus-summary-refer-article
8940 (prog1 (match-string 0 ref)
8941 (setq ref (substring ref (match-end 0))))))
8942 (gnus-summary-goto-subject current)
8943 (gnus-summary-position-point)
8944 n)))
8945
8946 (defun gnus-delete-duplicate-headers (headers)
8947 ;; First remove leading duplicates.
8948 (while (and (> (length headers) 1)
8949 (= (mail-header-number (car headers))
8950 (mail-header-number (cadr headers))))
8951 (pop headers))
8952 ;; Then the rest.
8953 (let ((result headers))
8954 (while (> (length headers) 1)
8955 (if (= (mail-header-number (car headers))
8956 (mail-header-number (cadr headers)))
8957 (setcdr headers (cddr headers))
8958 (pop headers)))
8959 result))
8960
8961 (defun gnus-summary-refer-thread (&optional limit)
8962 "Fetch all articles in the current thread. For backends that
8963 know how to search for threads (currently only 'nnimap) a
8964 non-numeric prefix arg will use nnir to search the entire
8965 server; without a prefix arg only the current group is
8966 searched. If the variable `gnus-refer-thread-use-nnir' is
8967 non-nil the prefix arg has the reverse meaning. If no
8968 backend-specific 'request-thread function is available fetch
8969 LIMIT (the numerical prefix) old headers. If LIMIT is
8970 non-numeric or nil fetch the number specified by the
8971 `gnus-refer-thread-limit' variable."
8972 (interactive "P")
8973 (gnus-warp-to-article)
8974 (let* ((header (gnus-summary-article-header))
8975 (id (mail-header-id header))
8976 (gnus-inhibit-demon t)
8977 (gnus-summary-ignore-duplicates t)
8978 (gnus-read-all-available-headers t)
8979 (gnus-refer-thread-use-nnir
8980 (if (and (not (null limit)) (listp limit))
8981 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
8982 (new-headers
8983 (if (gnus-check-backend-function
8984 'request-thread gnus-newsgroup-name)
8985 (gnus-request-thread header gnus-newsgroup-name)
8986 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
8987 gnus-refer-thread-limit))
8988 (last (if (numberp limit)
8989 (min (+ (mail-header-number header)
8990 limit)
8991 gnus-newsgroup-highest)
8992 gnus-newsgroup-highest))
8993 (subject (gnus-simplify-subject
8994 (mail-header-subject header)))
8995 (refs (split-string (or (mail-header-references header)
8996 "")))
8997 (gnus-parse-headers-hook
8998 `(lambda () (goto-char (point-min))
8999 (keep-lines
9000 (regexp-opt ',(append refs (list id subject)))))))
9001 (gnus-fetch-headers (list last) (if (numberp limit)
9002 (* 2 limit) limit) t))))
9003 article-ids)
9004 (when (listp new-headers)
9005 (dolist (header new-headers)
9006 (push (mail-header-number header) article-ids)
9007 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9008 (push (mail-header-number header) gnus-newsgroup-unreads)
9009 (setq gnus-newsgroup-unselected
9010 (delete (mail-header-number header)
9011 gnus-newsgroup-unselected))))
9012 (setq gnus-newsgroup-headers
9013 (gnus-delete-duplicate-headers
9014 (gnus-merge
9015 'list gnus-newsgroup-headers new-headers
9016 'gnus-article-sort-by-number)))
9017 (setq gnus-newsgroup-articles
9018 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9019 (gnus-summary-limit-include-thread id)))
9020 (gnus-summary-show-thread))
9021
9022 (defun gnus-summary-refer-article (message-id)
9023 "Fetch an article specified by MESSAGE-ID."
9024 (interactive "sMessage-ID: ")
9025 (gnus-warp-to-article)
9026 (when (and (stringp message-id)
9027 (not (zerop (length message-id))))
9028 (setq message-id (gnus-replace-in-string message-id " " ""))
9029 ;; Construct the correct Message-ID if necessary.
9030 ;; Suggested by tale@pawl.rpi.edu.
9031 (unless (string-match "^<" message-id)
9032 (setq message-id (concat "<" message-id)))
9033 (unless (string-match ">$" message-id)
9034 (setq message-id (concat message-id ">")))
9035 ;; People often post MIDs from URLs, so unhex it:
9036 (unless (string-match "@" message-id)
9037 (setq message-id (gnus-url-unhex-string message-id)))
9038 (let* ((header (gnus-id-to-header message-id))
9039 (sparse (and header
9040 (gnus-summary-article-sparse-p
9041 (mail-header-number header))
9042 (memq (mail-header-number header)
9043 gnus-newsgroup-limit)))
9044 number)
9045 (cond
9046 ;; If the article is present in the buffer we just go to it.
9047 ((and header
9048 (or (not (gnus-summary-article-sparse-p
9049 (mail-header-number header)))
9050 sparse))
9051 (prog1
9052 (gnus-summary-goto-article
9053 (mail-header-number header) nil t)
9054 (when sparse
9055 (gnus-summary-update-article (mail-header-number header)))))
9056 (t
9057 ;; We fetch the article.
9058 (catch 'found
9059 (dolist (gnus-override-method (gnus-refer-article-methods))
9060 (when (and (gnus-check-server gnus-override-method)
9061 ;; Fetch the header,
9062 (setq number (gnus-summary-insert-subject message-id)))
9063 ;; and display the article.
9064 (gnus-summary-select-article nil nil nil number)
9065 (throw 'found t)))
9066 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9067
9068 (defun gnus-refer-article-methods ()
9069 "Return a list of referable methods."
9070 (cond
9071 ;; No method, so we default to current and native.
9072 ((null gnus-refer-article-method)
9073 (list gnus-current-select-method gnus-select-method))
9074 ;; Current.
9075 ((eq 'current gnus-refer-article-method)
9076 (list gnus-current-select-method))
9077 ;; List of select methods.
9078 ((not (and (symbolp (car gnus-refer-article-method))
9079 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9080 (let (out)
9081 (dolist (method gnus-refer-article-method)
9082 (push (if (eq 'current method)
9083 gnus-current-select-method
9084 (if (eq 'nnir (car method))
9085 (list
9086 'nnir
9087 (or (cadr method)
9088 (gnus-method-to-server gnus-current-select-method)))
9089 method))
9090 out))
9091 (nreverse out)))
9092 ;; One single select method.
9093 (t
9094 (list gnus-refer-article-method))))
9095
9096 (defun gnus-summary-edit-parameters ()
9097 "Edit the group parameters of the current group."
9098 (interactive)
9099 (gnus-group-edit-group gnus-newsgroup-name 'params))
9100
9101 (defun gnus-summary-customize-parameters ()
9102 "Customize the group parameters of the current group."
9103 (interactive)
9104 (gnus-group-customize gnus-newsgroup-name))
9105
9106 (defun gnus-summary-enter-digest-group (&optional force)
9107 "Enter an nndoc group based on the current article.
9108 If FORCE, force a digest interpretation. If not, try to guess
9109 what the document format is.
9110
9111 To control what happens when you exit the group, see the
9112 `gnus-auto-select-on-ephemeral-exit' variable."
9113 (interactive "P")
9114 (let ((conf gnus-current-window-configuration))
9115 (save-window-excursion
9116 (save-excursion
9117 (let (gnus-article-prepare-hook
9118 gnus-display-mime-function
9119 gnus-break-pages)
9120 (gnus-summary-select-article))))
9121 (setq gnus-current-window-configuration conf)
9122 (let* ((name (format "%s-%d"
9123 (gnus-group-prefixed-name
9124 gnus-newsgroup-name (list 'nndoc ""))
9125 (with-current-buffer gnus-summary-buffer
9126 gnus-current-article)))
9127 (ogroup gnus-newsgroup-name)
9128 (params (append (gnus-info-params (gnus-get-info ogroup))
9129 (list (cons 'to-group ogroup))
9130 (list (cons 'parent-group ogroup))
9131 (list (cons 'save-article-group ogroup))))
9132 (case-fold-search t)
9133 (buf (current-buffer))
9134 dig to-address charset)
9135 (with-current-buffer gnus-original-article-buffer
9136 ;; Have the digest group inherit the main mail address of
9137 ;; the parent article.
9138 (when (setq to-address (or (gnus-fetch-field "reply-to")
9139 (gnus-fetch-field "from")))
9140 (setq params
9141 (append
9142 (list (cons 'to-address
9143 (funcall gnus-decode-encoded-address-function
9144 to-address))))))
9145 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9146 (insert-buffer-substring gnus-original-article-buffer)
9147 (narrow-to-region
9148 (goto-char (point-min))
9149 (or (search-forward "\n\n" nil t) (point)))
9150 ;; Remove lines that may lead nndoc to misinterpret the
9151 ;; document type.
9152 (goto-char (point-min))
9153 (delete-matching-lines "^Path:\\|^From ")
9154 ;; Parse charset, and decode content transfer encoding.
9155 (setq charset (mail-content-type-get
9156 (mail-header-parse-content-type
9157 (or (gnus-fetch-field "content-type") ""))
9158 'charset))
9159 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9160 (when encoding
9161 (message-remove-header "content-transfer-encoding")
9162 (goto-char (point-max))
9163 (widen)
9164 (narrow-to-region (point) (point-max))
9165 (mm-decode-content-transfer-encoding
9166 (intern (downcase (mail-header-strip encoding))))))
9167 (widen))
9168 (unwind-protect
9169 (if (let ((gnus-newsgroup-ephemeral-charset
9170 (if charset
9171 (intern (downcase (gnus-strip-whitespace charset)))
9172 gnus-newsgroup-charset))
9173 (gnus-newsgroup-ephemeral-ignored-charsets
9174 gnus-newsgroup-ignored-charsets))
9175 (gnus-group-read-ephemeral-group
9176 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9177 (nndoc-article-type
9178 ,(if force 'mbox 'guess)))
9179 t nil nil nil
9180 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9181 "ADAPT")))))
9182 ;; Make all postings to this group go to the parent group.
9183 (nconc (gnus-info-params (gnus-get-info name))
9184 params)
9185 ;; Couldn't select this doc group.
9186 (switch-to-buffer buf)
9187 (gnus-set-global-variables)
9188 (gnus-configure-windows 'summary)
9189 (gnus-message 3 "Article couldn't be entered?"))
9190 (kill-buffer dig)))))
9191
9192 (defun gnus-summary-read-document (n)
9193 "Open a new group based on the current article(s).
9194 This will allow you to read digests and other similar
9195 documents as newsgroups.
9196 Obeys the standard process/prefix convention."
9197 (interactive "P")
9198 (let* ((ogroup gnus-newsgroup-name)
9199 (params (append (gnus-info-params (gnus-get-info ogroup))
9200 (list (cons 'to-group ogroup))))
9201 group egroup groups vgroup)
9202 (dolist (article (gnus-summary-work-articles n))
9203 (setq group (format "%s-%d" gnus-newsgroup-name article))
9204 (gnus-summary-remove-process-mark article)
9205 (when (gnus-summary-display-article article)
9206 (save-excursion ;;What for?
9207 (with-temp-buffer
9208 (insert-buffer-substring gnus-original-article-buffer)
9209 ;; Remove some headers that may lead nndoc to make
9210 ;; the wrong guess.
9211 (message-narrow-to-head)
9212 (goto-char (point-min))
9213 (delete-matching-lines "^Path:\\|^From ")
9214 (widen)
9215 (if (setq egroup
9216 (gnus-group-read-ephemeral-group
9217 group `(nndoc ,group (nndoc-address ,(current-buffer))
9218 (nndoc-article-type guess))
9219 t nil t))
9220 (progn
9221 ;; Make all postings to this group go to the parent group.
9222 (nconc (gnus-info-params (gnus-get-info egroup))
9223 params)
9224 (push egroup groups))
9225 ;; Couldn't select this doc group.
9226 (gnus-error 3 "Article couldn't be entered"))))))
9227 ;; Now we have selected all the documents.
9228 (cond
9229 ((not groups)
9230 (error "None of the articles could be interpreted as documents"))
9231 ((gnus-group-read-ephemeral-group
9232 (setq vgroup (format
9233 "nnvirtual:%s-%s" gnus-newsgroup-name
9234 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9235 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9236 t
9237 (cons (current-buffer) 'summary)))
9238 (t
9239 (error "Couldn't select virtual nndoc group")))))
9240
9241 (defun gnus-summary-widget-forward (arg)
9242 "Move point to the next field or button in the article.
9243 With optional ARG, move across that many fields."
9244 (interactive "p")
9245 (gnus-summary-select-article)
9246 (gnus-configure-windows 'article)
9247 (select-window (gnus-get-buffer-window gnus-article-buffer))
9248 (widget-forward arg))
9249
9250 (defun gnus-summary-widget-backward (arg)
9251 "Move point to the previous field or button in the article.
9252 With optional ARG, move across that many fields."
9253 (interactive "p")
9254 (gnus-summary-select-article)
9255 (gnus-configure-windows 'article)
9256 (select-window (gnus-get-buffer-window gnus-article-buffer))
9257 (unless (widget-at (point))
9258 (goto-char (point-max)))
9259 (widget-backward arg))
9260
9261 (defun gnus-summary-isearch-article (&optional regexp-p)
9262 "Do incremental search forward on the current article.
9263 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9264 (interactive "P")
9265 (gnus-summary-select-article)
9266 (gnus-configure-windows 'article)
9267 (gnus-eval-in-buffer-window gnus-article-buffer
9268 (save-restriction
9269 (widen)
9270 (isearch-forward regexp-p))))
9271
9272 (defun gnus-summary-repeat-search-article-forward ()
9273 "Repeat the previous search forwards."
9274 (interactive)
9275 (unless gnus-last-search-regexp
9276 (error "No previous search"))
9277 (gnus-summary-search-article-forward gnus-last-search-regexp))
9278
9279 (defun gnus-summary-repeat-search-article-backward ()
9280 "Repeat the previous search backwards."
9281 (interactive)
9282 (unless gnus-last-search-regexp
9283 (error "No previous search"))
9284 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9285
9286 (defun gnus-summary-search-article-forward (regexp &optional backward)
9287 "Search for an article containing REGEXP forward.
9288 If BACKWARD, search backward instead."
9289 (interactive
9290 (list (read-string
9291 (format "Search article %s (regexp%s): "
9292 (if current-prefix-arg "backward" "forward")
9293 (if gnus-last-search-regexp
9294 (concat ", default " gnus-last-search-regexp)
9295 "")))
9296 current-prefix-arg))
9297 (if (string-equal regexp "")
9298 (setq regexp (or gnus-last-search-regexp ""))
9299 (setq gnus-last-search-regexp regexp)
9300 (setq gnus-article-before-search gnus-current-article))
9301 ;; Intentionally set gnus-last-article.
9302 (setq gnus-last-article gnus-article-before-search)
9303 (let ((gnus-last-article gnus-last-article))
9304 (if (gnus-summary-search-article regexp backward)
9305 (gnus-summary-show-thread)
9306 (signal 'search-failed (list regexp)))))
9307
9308 (defun gnus-summary-search-article-backward (regexp)
9309 "Search for an article containing REGEXP backward."
9310 (interactive
9311 (list (read-string
9312 (format "Search article backward (regexp%s): "
9313 (if gnus-last-search-regexp
9314 (concat ", default " gnus-last-search-regexp)
9315 "")))))
9316 (gnus-summary-search-article-forward regexp 'backward))
9317
9318 (defun gnus-summary-search-article (regexp &optional backward)
9319 "Search for an article containing REGEXP.
9320 Optional argument BACKWARD means do search for backward.
9321 `gnus-select-article-hook' is not called during the search."
9322 ;; We have to require this here to make sure that the following
9323 ;; dynamic binding isn't shadowed by autoloading.
9324 (require 'gnus-async)
9325 (require 'gnus-art)
9326 (let ((gnus-select-article-hook nil) ;Disable hook.
9327 (gnus-article-prepare-hook nil)
9328 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9329 (gnus-use-article-prefetch nil)
9330 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9331 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9332 (gnus-visual nil)
9333 (gnus-keep-backlog nil)
9334 (gnus-break-pages nil)
9335 (gnus-summary-display-arrow nil)
9336 (gnus-updated-mode-lines nil)
9337 (gnus-auto-center-summary nil)
9338 (sum (current-buffer))
9339 (gnus-display-mime-function nil)
9340 (found nil)
9341 point)
9342 (gnus-save-hidden-threads
9343 (gnus-summary-select-article)
9344 (set-buffer gnus-article-buffer)
9345 (goto-char (window-point (get-buffer-window (current-buffer))))
9346 (when backward
9347 (forward-line -1))
9348 (while (not found)
9349 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9350 (if (if backward
9351 (re-search-backward regexp nil t)
9352 (re-search-forward regexp nil t))
9353 ;; We found the regexp.
9354 (progn
9355 (setq found 'found)
9356 (beginning-of-line)
9357 (set-window-start
9358 (get-buffer-window (current-buffer))
9359 (point))
9360 (forward-line 1)
9361 (set-window-point
9362 (get-buffer-window (current-buffer))
9363 (point))
9364 (set-buffer sum)
9365 (setq point (point)))
9366 ;; We didn't find it, so we go to the next article.
9367 (set-buffer sum)
9368 (setq found 'not)
9369 (while (eq found 'not)
9370 (if (not (if backward (gnus-summary-find-prev)
9371 (gnus-summary-find-next)))
9372 ;; No more articles.
9373 (setq found t)
9374 ;; Select the next article and adjust point.
9375 (unless (gnus-summary-article-sparse-p
9376 (gnus-summary-article-number))
9377 (setq found nil)
9378 (gnus-summary-select-article)
9379 (set-buffer gnus-article-buffer)
9380 (widen)
9381 (goto-char (if backward (point-max) (point-min))))))))
9382 (gnus-message 7 ""))
9383 ;; Return whether we found the regexp.
9384 (when (eq found 'found)
9385 (goto-char point)
9386 (gnus-summary-show-thread)
9387 (gnus-summary-goto-subject gnus-current-article)
9388 (gnus-summary-position-point)
9389 t)))
9390
9391 (defun gnus-find-matching-articles (header regexp)
9392 "Return a list of all articles that match REGEXP on HEADER.
9393 This search includes all articles in the current group that Gnus has
9394 fetched headers for, whether they are displayed or not."
9395 (let ((articles nil)
9396 ;; Can't eta-reduce because it's a macro.
9397 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9398 (case-fold-search t))
9399 (dolist (header gnus-newsgroup-headers)
9400 (when (string-match regexp (funcall func header))
9401 (push (mail-header-number header) articles)))
9402 (nreverse articles)))
9403
9404 (defun gnus-summary-find-matching (header regexp &optional backward unread
9405 not-case-fold not-matching)
9406 "Return a list of all articles that match REGEXP on HEADER.
9407 The search stars on the current article and goes forwards unless
9408 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9409 If UNREAD is non-nil, only unread articles will
9410 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9411 in the comparisons. If NOT-MATCHING, return a list of all articles that
9412 not match REGEXP on HEADER."
9413 (let ((case-fold-search (not not-case-fold))
9414 articles d func)
9415 (if (consp header)
9416 (if (eq (car header) 'extra)
9417 (setq func
9418 `(lambda (h)
9419 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9420 "")))
9421 (error "%s is an invalid header" header))
9422 (unless (fboundp (intern (concat "mail-header-" header)))
9423 (error "%s is not a valid header" header))
9424 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9425 (dolist (d (if (eq backward 'all)
9426 gnus-newsgroup-data
9427 (gnus-data-find-list
9428 (gnus-summary-article-number)
9429 (gnus-data-list backward))))
9430 (when (and (or (not unread) ; We want all articles...
9431 (gnus-data-unread-p d)) ; Or just unreads.
9432 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9433 (if not-matching
9434 (not (string-match
9435 regexp
9436 (funcall func (gnus-data-header d))))
9437 (string-match regexp
9438 (funcall func (gnus-data-header d)))))
9439 (push (gnus-data-number d) articles))) ; Success!
9440 (nreverse articles)))
9441
9442 (defun gnus-summary-execute-command (header regexp command &optional backward)
9443 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9444 If HEADER is an empty string (or nil), the match is done on the entire
9445 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9446 (interactive
9447 (list (let ((completion-ignore-case t))
9448 (gnus-completing-read
9449 "Header name"
9450 (mapcar 'symbol-name
9451 (append
9452 '(Number Subject From Lines Date
9453 Message-ID Xref References Body)
9454 gnus-extra-headers))
9455 'require-match))
9456 (read-string "Regexp: ")
9457 (read-key-sequence "Command: ")
9458 current-prefix-arg))
9459 (when (equal header "Body")
9460 (setq header ""))
9461 ;; Hidden thread subtrees must be searched as well.
9462 (gnus-summary-show-all-threads)
9463 ;; We don't want to change current point nor window configuration.
9464 (save-excursion
9465 (save-window-excursion
9466 (let (gnus-visual
9467 gnus-treat-strip-trailing-blank-lines
9468 gnus-treat-strip-leading-blank-lines
9469 gnus-treat-strip-multiple-blank-lines
9470 gnus-treat-hide-boring-headers
9471 gnus-treat-fold-newsgroups
9472 gnus-article-prepare-hook)
9473 (gnus-message 6 "Executing %s..." (key-description command))
9474 ;; We'd like to execute COMMAND interactively so as to give arguments.
9475 (gnus-execute header regexp
9476 `(call-interactively ',(key-binding command))
9477 backward)
9478 (gnus-message 6 "Executing %s...done" (key-description command))))))
9479
9480 (defun gnus-summary-beginning-of-article ()
9481 "Scroll the article back to the beginning."
9482 (interactive)
9483 (gnus-summary-select-article)
9484 (gnus-configure-windows 'article)
9485 (gnus-eval-in-buffer-window gnus-article-buffer
9486 (widen)
9487 (goto-char (point-min))
9488 (when gnus-break-pages
9489 (gnus-narrow-to-page))))
9490
9491 (defun gnus-summary-end-of-article ()
9492 "Scroll to the end of the article."
9493 (interactive)
9494 (gnus-summary-select-article)
9495 (gnus-configure-windows 'article)
9496 (gnus-eval-in-buffer-window gnus-article-buffer
9497 (widen)
9498 (goto-char (point-max))
9499 (recenter -3)
9500 (when gnus-break-pages
9501 (gnus-narrow-to-page))))
9502
9503 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9504 "Truncate to LEN and quote all \"(\"'s in STRING."
9505 (gnus-replace-in-string (if (and len (> (length string) len))
9506 (substring string 0 len)
9507 string)
9508 "[()]" "\\\\\\&"))
9509
9510 (defun gnus-summary-print-article (&optional filename n)
9511 "Generate and print a PostScript image of the process-marked (mail) articles.
9512
9513 If used interactively, print the current article if none are
9514 process-marked. With prefix arg, prompt the user for the name of the
9515 file to save in.
9516
9517 When used from Lisp, accept two optional args FILENAME and N. N means
9518 to print the next N articles. If N is negative, print the N previous
9519 articles. If N is nil and articles have been marked with the process
9520 mark, print these instead.
9521
9522 If the optional first argument FILENAME is nil, send the image to the
9523 printer. If FILENAME is a string, save the PostScript image in a file with
9524 that name. If FILENAME is a number, prompt the user for the name of the file
9525 to save in."
9526 (interactive (list (ps-print-preprint current-prefix-arg)))
9527 (dolist (article (gnus-summary-work-articles n))
9528 (gnus-summary-select-article nil nil 'pseudo article)
9529 (gnus-eval-in-buffer-window gnus-article-buffer
9530 (gnus-print-buffer))
9531 (gnus-summary-remove-process-mark article))
9532 (ps-despool filename))
9533
9534 (defun gnus-print-buffer ()
9535 (let ((ps-left-header
9536 (list
9537 (concat "("
9538 (gnus-summary-print-truncate-and-quote
9539 (mail-header-subject gnus-current-headers)
9540 66) ")")
9541 (concat "("
9542 (gnus-summary-print-truncate-and-quote
9543 (mail-header-from gnus-current-headers)
9544 45) ")")))
9545 (ps-right-header
9546 (list
9547 "/pagenumberstring load"
9548 (concat "("
9549 (mail-header-date gnus-current-headers) ")"))))
9550 (gnus-run-hooks 'gnus-ps-print-hook)
9551 (save-excursion
9552 (if ps-print-color-p
9553 (ps-spool-buffer-with-faces)
9554 (ps-spool-buffer)))))
9555
9556 (defun gnus-summary-show-complete-article ()
9557 "Show a complete version of the current article.
9558 This is only useful if you're looking at a partial version of the
9559 article currently."
9560 (interactive)
9561 (let ((gnus-keep-backlog nil)
9562 (gnus-use-cache nil)
9563 (gnus-agent nil)
9564 (variable (intern
9565 (format "%s-fetch-partial-articles"
9566 (car (gnus-find-method-for-group
9567 gnus-newsgroup-name)))
9568 obarray))
9569 old-val)
9570 (unwind-protect
9571 (progn
9572 (setq old-val (symbol-value variable))
9573 (set variable nil)
9574 (gnus-flush-original-article-buffer)
9575 (gnus-summary-show-article))
9576 (set variable old-val))))
9577
9578 (defun gnus-summary-show-article (&optional arg)
9579 "Force redisplaying of the current article.
9580 If ARG (the prefix) is a number, show the article with the charset
9581 defined in `gnus-summary-show-article-charset-alist', or the charset
9582 input.
9583 If ARG (the prefix) is non-nil and not a number, show the article,
9584 but without running any of the article treatment functions
9585 article. Normally, the keystroke is `C-u g'. When using `C-u
9586 C-u g', show the raw article."
9587 (interactive "P")
9588 (cond
9589 ((numberp arg)
9590 (gnus-summary-show-article t)
9591 (let ((gnus-newsgroup-charset
9592 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9593 (mm-read-coding-system
9594 "View as charset: " ;; actually it is coding system.
9595 (with-current-buffer gnus-article-buffer
9596 (mm-detect-coding-region (point) (point-max))))))
9597 (gnus-newsgroup-ignored-charsets 'gnus-all))
9598 (gnus-summary-select-article nil 'force)
9599 (let ((deps gnus-newsgroup-dependencies)
9600 head header lines)
9601 (with-current-buffer gnus-original-article-buffer
9602 (save-restriction
9603 (message-narrow-to-head)
9604 (setq head (buffer-string))
9605 (goto-char (point-min))
9606 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9607 (goto-char (point-max))
9608 (widen)
9609 (setq lines (1- (count-lines (point) (point-max))))))
9610 (with-temp-buffer
9611 (insert (format "211 %d Article retrieved.\n"
9612 (cdr gnus-article-current)))
9613 (insert head)
9614 (if lines (insert (format "Lines: %d\n" lines)))
9615 (insert ".\n")
9616 (let ((nntp-server-buffer (current-buffer)))
9617 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9618 (gnus-data-set-header
9619 (gnus-data-find (cdr gnus-article-current))
9620 header)
9621 (gnus-summary-update-article-line
9622 (cdr gnus-article-current) header)
9623 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9624 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9625 ((not arg)
9626 ;; Select the article the normal way.
9627 (if (eq mm-text-html-renderer 'shr)
9628 (progn
9629 (require 'shr)
9630 (let ((shr-ignore-cache t))
9631 (gnus-summary-select-article nil 'force)))
9632 (gnus-summary-select-article nil 'force)))
9633 ((equal arg '(16))
9634 ;; C-u C-u g
9635 (let ((gnus-inhibit-article-treatments t))
9636 (gnus-summary-select-article nil 'force)))
9637 (t
9638 ;; We have to require this here to make sure that the following
9639 ;; dynamic binding isn't shadowed by autoloading.
9640 (require 'gnus-async)
9641 (require 'gnus-art)
9642 ;; Bind the article treatment functions to nil.
9643 (let ((gnus-have-all-headers t)
9644 gnus-article-prepare-hook
9645 gnus-article-decode-hook
9646 gnus-display-mime-function
9647 gnus-break-pages)
9648 ;; Destroy any MIME parts.
9649 (when (gnus-buffer-live-p gnus-article-buffer)
9650 (with-current-buffer gnus-article-buffer
9651 (gnus-article-stop-animations)
9652 (gnus-stop-downloads)
9653 (mm-destroy-parts gnus-article-mime-handles)
9654 ;; Set it to nil for safety reason.
9655 (setq gnus-article-mime-handle-alist nil)
9656 (setq gnus-article-mime-handles nil)))
9657 (gnus-summary-select-article nil 'force))))
9658 (gnus-summary-goto-subject gnus-current-article)
9659 (gnus-summary-position-point))
9660
9661 (defun gnus-summary-show-raw-article ()
9662 "Show the raw article without any article massaging functions being run."
9663 (interactive)
9664 (gnus-summary-show-article t))
9665
9666 (defun gnus-summary-verbose-headers (&optional arg)
9667 "Toggle permanent full header display.
9668 If ARG is a positive number, turn header display on.
9669 If ARG is a negative number, turn header display off."
9670 (interactive "P")
9671 (setq gnus-show-all-headers
9672 (cond ((or (not (numberp arg))
9673 (zerop arg))
9674 (not gnus-show-all-headers))
9675 ((natnump arg)
9676 t)))
9677 (gnus-summary-show-article))
9678
9679 (defun gnus-summary-toggle-header (&optional arg)
9680 "Show the headers if they are hidden, or hide them if they are shown.
9681 If ARG is a positive number, show the entire header.
9682 If ARG is a negative number, hide the unwanted header lines."
9683 (interactive "P")
9684 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9685 (get-buffer-window gnus-article-buffer t))))
9686 (with-current-buffer gnus-article-buffer
9687 (widen)
9688 (article-narrow-to-head)
9689 (let* ((inhibit-read-only t)
9690 (inhibit-point-motion-hooks t)
9691 (hidden (if (numberp arg)
9692 (>= arg 0)
9693 (or (not (looking-at "[^ \t\n]+:"))
9694 (gnus-article-hidden-text-p 'headers))))
9695 s e)
9696 (delete-region (point-min) (point-max))
9697 (with-current-buffer gnus-original-article-buffer
9698 (goto-char (setq s (point-min)))
9699 (setq e (if (search-forward "\n\n" nil t)
9700 (1- (point))
9701 (point-max))))
9702 (insert-buffer-substring gnus-original-article-buffer s e)
9703 (run-hooks 'gnus-article-decode-hook)
9704 (if hidden
9705 (let ((gnus-treat-hide-headers nil)
9706 (gnus-treat-hide-boring-headers nil))
9707 (gnus-delete-wash-type 'headers)
9708 (gnus-treat-article 'head))
9709 (gnus-treat-article 'head))
9710 (widen)
9711 (if window
9712 (set-window-start window (goto-char (point-min))))
9713 (if gnus-break-pages
9714 (gnus-narrow-to-page)
9715 (when (gnus-visual-p 'page-marker)
9716 (let ((inhibit-read-only t))
9717 (gnus-remove-text-with-property 'gnus-prev)
9718 (gnus-remove-text-with-property 'gnus-next))))
9719 (gnus-set-mode-line 'article)))))
9720
9721 (defun gnus-summary-show-all-headers ()
9722 "Make all header lines visible."
9723 (interactive)
9724 (gnus-summary-toggle-header 1))
9725
9726 (defun gnus-summary-caesar-message (&optional arg)
9727 "Caesar rotate the current article by 13.
9728 With a non-numerical prefix, also rotate headers. A numerical
9729 prefix specifies how many places to rotate each letter forward."
9730 (interactive "P")
9731 (gnus-summary-select-article)
9732 (let ((mail-header-separator ""))
9733 (gnus-eval-in-buffer-window gnus-article-buffer
9734 (save-restriction
9735 (widen)
9736 (let ((start (window-start))
9737 (inhibit-read-only t))
9738 (if (equal arg '(4))
9739 (message-caesar-buffer-body nil t)
9740 (message-caesar-buffer-body arg))
9741 (set-window-start (get-buffer-window (current-buffer)) start)))))
9742 ;; Create buttons and stuff...
9743 (gnus-treat-article nil))
9744
9745 (declare-function idna-to-unicode "ext:idna" (str))
9746
9747 (defun gnus-summary-idna-message (&optional arg)
9748 "Decode IDNA encoded domain names in the current articles.
9749 IDNA encoded domain names looks like `xn--bar'. If a string
9750 remain unencoded after running this function, it is likely an
9751 invalid IDNA string (`xn--bar' is invalid).
9752
9753 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9754 installed for this command to work."
9755 (interactive "P")
9756 (if (not (and (condition-case nil (require 'idna)
9757 (file-error))
9758 (mm-coding-system-p 'utf-8)
9759 (executable-find (symbol-value 'idna-program))))
9760 (gnus-message
9761 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9762 (gnus-summary-select-article)
9763 (let ((mail-header-separator ""))
9764 (gnus-eval-in-buffer-window gnus-article-buffer
9765 (save-restriction
9766 (widen)
9767 (let ((start (window-start))
9768 buffer-read-only)
9769 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9770 (replace-match (idna-to-unicode (match-string 1))))
9771 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9772
9773 (defun gnus-summary-morse-message (&optional arg)
9774 "Morse decode the current article."
9775 (interactive "P")
9776 (gnus-summary-select-article)
9777 (let ((mail-header-separator ""))
9778 (gnus-eval-in-buffer-window gnus-article-buffer
9779 (save-excursion
9780 (save-restriction
9781 (widen)
9782 (let ((pos (window-start))
9783 (inhibit-read-only t))
9784 (goto-char (point-min))
9785 (when (message-goto-body)
9786 (gnus-narrow-to-body))
9787 (goto-char (point-min))
9788 (while (search-forward "·" (point-max) t)
9789 (replace-match "."))
9790 (unmorse-region (point-min) (point-max))
9791 (widen)
9792 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9793
9794 (defun gnus-summary-stop-page-breaking ()
9795 "Stop page breaking in the current article."
9796 (interactive)
9797 (gnus-summary-select-article)
9798 (gnus-eval-in-buffer-window gnus-article-buffer
9799 (widen)
9800 (when (gnus-visual-p 'page-marker)
9801 (let ((inhibit-read-only t))
9802 (gnus-remove-text-with-property 'gnus-prev)
9803 (gnus-remove-text-with-property 'gnus-next))
9804 (setq gnus-page-broken nil))))
9805
9806 (defun gnus-summary-move-article (&optional n to-newsgroup
9807 select-method action)
9808 "Move the current article to a different newsgroup.
9809 If N is a positive number, move the N next articles.
9810 If N is a negative number, move the N previous articles.
9811 If N is nil and any articles have been marked with the process mark,
9812 move those articles instead.
9813 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9814 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9815 re-spool using this method.
9816
9817 When called interactively with TO-NEWSGROUP being nil, the value of
9818 the variable `gnus-move-split-methods' is used for finding a default
9819 for the target newsgroup.
9820
9821 For this function to work, both the current newsgroup and the
9822 newsgroup that you want to move to have to support the `request-move'
9823 and `request-accept' functions.
9824
9825 ACTION can be either `move' (the default), `crosspost' or `copy'."
9826 (interactive "P")
9827 (unless action
9828 (setq action 'move))
9829 ;; Check whether the source group supports the required functions.
9830 (cond ((and (eq action 'move)
9831 (not (gnus-check-backend-function
9832 'request-move-article gnus-newsgroup-name)))
9833 (error "The current group does not support article moving"))
9834 ((and (eq action 'crosspost)
9835 (not (gnus-check-backend-function
9836 'request-replace-article gnus-newsgroup-name)))
9837 (error "The current group does not support article editing")))
9838 (let ((articles (gnus-summary-work-articles n))
9839 (prefix (if (gnus-check-backend-function
9840 'request-move-article gnus-newsgroup-name)
9841 (funcall gnus-move-group-prefix-function
9842 gnus-newsgroup-name)
9843 ""))
9844 (names '((move "Move" "Moving")
9845 (copy "Copy" "Copying")
9846 (crosspost "Crosspost" "Crossposting")))
9847 (copy-buf (save-excursion
9848 (nnheader-set-temp-buffer " *copy article*")))
9849 art-group to-method new-xref article to-groups
9850 articles-to-update-marks encoded)
9851 (unless (assq action names)
9852 (error "Unknown action %s" action))
9853 ;; Read the newsgroup name.
9854 (when (and (not to-newsgroup)
9855 (not select-method))
9856 (if (and gnus-move-split-methods
9857 (not
9858 (and (memq gnus-current-article articles)
9859 (gnus-buffer-live-p gnus-original-article-buffer))))
9860 ;; When `gnus-move-split-methods' is non-nil, we have to
9861 ;; select an article to give `gnus-read-move-group-name' an
9862 ;; opportunity to suggest an appropriate default. However,
9863 ;; we needn't render or mark the article.
9864 (let ((gnus-display-mime-function nil)
9865 (gnus-article-prepare-hook nil)
9866 (gnus-mark-article-hook nil))
9867 (gnus-summary-select-article nil nil nil (car articles))))
9868 (setq to-newsgroup (gnus-read-move-group-name
9869 (cadr (assq action names))
9870 (symbol-value
9871 (intern (format "gnus-current-%s-group" action)))
9872 articles prefix)
9873 encoded to-newsgroup
9874 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9875 (set (intern (format "gnus-current-%s-group" action))
9876 (mm-decode-coding-string
9877 to-newsgroup
9878 (gnus-group-name-charset to-method to-newsgroup))))
9879 (unless to-method
9880 (setq to-method (or select-method
9881 (gnus-server-to-method
9882 (gnus-group-method to-newsgroup)))))
9883 (setq to-newsgroup
9884 (or encoded
9885 (and to-newsgroup
9886 (mm-encode-coding-string
9887 to-newsgroup
9888 (gnus-group-name-charset to-method to-newsgroup)))))
9889 ;; Check the method we are to move this article to...
9890 (unless (gnus-check-backend-function
9891 'request-accept-article (car to-method))
9892 (error "%s does not support article copying" (car to-method)))
9893 (unless (gnus-check-server to-method)
9894 (error "Can't open server %s" (car to-method)))
9895 (gnus-message 6 "%s to %s: %s..."
9896 (caddr (assq action names))
9897 (or (car select-method)
9898 (gnus-group-decoded-name to-newsgroup))
9899 articles)
9900 (while articles
9901 (setq article (pop articles))
9902 ;; Set any marks that may have changed in the summary buffer.
9903 (when gnus-preserve-marks
9904 (gnus-summary-push-marks-to-backend article))
9905 (setq
9906 art-group
9907 (cond
9908 ;; Move the article.
9909 ((eq action 'move)
9910 ;; Remove this article from future suppression.
9911 (gnus-dup-unsuppress-article article)
9912 (let* ((from-method (gnus-find-method-for-group
9913 gnus-newsgroup-name))
9914 (to-method (or select-method
9915 (gnus-find-method-for-group to-newsgroup)))
9916 (move-is-internal (gnus-server-equal from-method to-method)))
9917 (gnus-request-move-article
9918 article ; Article to move
9919 gnus-newsgroup-name ; From newsgroup
9920 (nth 1 (gnus-find-method-for-group
9921 gnus-newsgroup-name)) ; Server
9922 (list 'gnus-request-accept-article
9923 to-newsgroup (list 'quote select-method)
9924 (not articles) t) ; Accept form
9925 (not articles) ; Only save nov last time
9926 (and move-is-internal
9927 to-newsgroup ; Not respooling
9928 ; Is this move internal?
9929 (gnus-group-real-name to-newsgroup)))))
9930 ;; Copy the article.
9931 ((eq action 'copy)
9932 (with-current-buffer copy-buf
9933 (when (gnus-request-article-this-buffer article
9934 gnus-newsgroup-name)
9935 (save-restriction
9936 (nnheader-narrow-to-headers)
9937 (dolist (hdr gnus-copy-article-ignored-headers)
9938 (message-remove-header hdr t)))
9939 (gnus-request-accept-article
9940 to-newsgroup select-method (not articles) t))))
9941 ;; Crosspost the article.
9942 ((eq action 'crosspost)
9943 (let ((xref (message-tokenize-header
9944 (mail-header-xref (gnus-summary-article-header
9945 article))
9946 " ")))
9947 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9948 ":" (number-to-string article)))
9949 (unless xref
9950 (setq xref (list (system-name))))
9951 (setq new-xref
9952 (concat
9953 (mapconcat 'identity
9954 (delete "Xref:" (delete new-xref xref))
9955 " ")
9956 " " new-xref))
9957 (with-current-buffer copy-buf
9958 ;; First put the article in the destination group.
9959 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9960 (when (consp (setq art-group
9961 (gnus-request-accept-article
9962 to-newsgroup select-method (not articles)
9963 t)))
9964 (setq new-xref (concat new-xref " " (car art-group)
9965 ":"
9966 (number-to-string (cdr art-group))))
9967 ;; Now we have the new Xrefs header, so we insert
9968 ;; it and replace the new article.
9969 (nnheader-replace-header "Xref" new-xref)
9970 (gnus-request-replace-article
9971 (cdr art-group) to-newsgroup (current-buffer) t)
9972 art-group))))))
9973 (cond
9974 ((not art-group)
9975 (gnus-message 1 "Couldn't %s article %s: %s"
9976 (cadr (assq action names)) article
9977 (nnheader-get-report (car to-method))))
9978 ((eq art-group 'junk)
9979 (when (eq action 'move)
9980 (gnus-summary-mark-article article gnus-canceled-mark)
9981 (gnus-message 4 "Deleted article %s" article)
9982 ;; run the delete hook
9983 (run-hook-with-args 'gnus-summary-article-delete-hook
9984 action
9985 (gnus-data-header
9986 (assoc article (gnus-data-list nil)))
9987 gnus-newsgroup-name nil
9988 select-method)))
9989 (t
9990 (let* ((pto-group (gnus-group-prefixed-name
9991 (car art-group) to-method))
9992 (info (gnus-get-info pto-group))
9993 (to-group (gnus-info-group info))
9994 to-marks)
9995 ;; Update the group that has been moved to.
9996 (when (and info
9997 (memq action '(move copy)))
9998 (unless (member to-group to-groups)
9999 (push to-group to-groups))
10000
10001 (when (and (not (memq article gnus-newsgroup-unreads))
10002 (cdr art-group))
10003 (push 'read to-marks)
10004 (gnus-info-set-read
10005 info (gnus-add-to-range (gnus-info-read info)
10006 (list (cdr art-group)))))
10007
10008 ;; See whether the article is to be put in the cache.
10009 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10010 (marks (if expirable
10011 gnus-article-mark-lists
10012 (delete '(expirable . expire)
10013 (copy-sequence
10014 gnus-article-mark-lists))))
10015 (to-article (cdr art-group)))
10016
10017 ;; Enter the article into the cache in the new group,
10018 ;; if that is required.
10019 (when (and to-article
10020 gnus-use-cache)
10021 (gnus-cache-possibly-enter-article
10022 to-group to-article
10023 (memq article gnus-newsgroup-marked)
10024 (memq article gnus-newsgroup-dormant)
10025 (memq article gnus-newsgroup-unreads)))
10026
10027 (when (and gnus-preserve-marks
10028 to-article)
10029 ;; Copy any marks over to the new group.
10030 (when (and (equal to-group gnus-newsgroup-name)
10031 (not (memq article gnus-newsgroup-unreads)))
10032 ;; Mark this article as read in this group.
10033 (push (cons to-article gnus-read-mark)
10034 gnus-newsgroup-reads)
10035 ;; Increase the active status of this group.
10036 (setcdr (gnus-active to-group) to-article)
10037 (setcdr gnus-newsgroup-active to-article))
10038
10039 (while marks
10040 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10041 (when (memq article (symbol-value
10042 (intern (format "gnus-newsgroup-%s"
10043 (caar marks)))))
10044 (push (cdar marks) to-marks)
10045 ;; If the other group is the same as this group,
10046 ;; then we have to add the mark to the list.
10047 (when (equal to-group gnus-newsgroup-name)
10048 (set (intern (format "gnus-newsgroup-%s"
10049 (caar marks)))
10050 (cons to-article
10051 (symbol-value
10052 (intern (format "gnus-newsgroup-%s"
10053 (caar marks)))))))
10054 ;; Copy the marks to other group.
10055 (gnus-add-marked-articles
10056 to-group (cdar marks) (list to-article) info)))
10057 (setq marks (cdr marks)))
10058
10059 (when (and expirable
10060 gnus-mark-copied-or-moved-articles-as-expirable
10061 (not (memq 'expire to-marks)))
10062 ;; Mark this article as expirable.
10063 (push 'expire to-marks)
10064 (when (equal to-group gnus-newsgroup-name)
10065 (push to-article gnus-newsgroup-expirable))
10066 ;; Copy the expirable mark to other group.
10067 (gnus-add-marked-articles
10068 to-group 'expire (list to-article) info))
10069
10070 (when (and to-marks
10071 (gnus-method-option-p
10072 (gnus-find-method-for-group to-group)
10073 'server-marks))
10074 (gnus-request-set-mark
10075 to-group (list (list (list to-article) 'add to-marks)))))
10076
10077 (gnus-dribble-enter
10078 (concat "(gnus-group-set-info '"
10079 (gnus-prin1-to-string (gnus-get-info to-group))
10080 ")")
10081 (concat "^(gnus-group-set-info '(\""
10082 (regexp-quote to-group) "\""))))
10083
10084 ;; Update the Xref header in this article to point to
10085 ;; the new crossposted article we have just created.
10086 (when (eq action 'crosspost)
10087 (with-current-buffer copy-buf
10088 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10089 (nnheader-replace-header "Xref" new-xref)
10090 (gnus-request-replace-article
10091 article gnus-newsgroup-name (current-buffer) t)))
10092
10093 ;; run the move/copy/crosspost/respool hook
10094 (run-hook-with-args 'gnus-summary-article-move-hook
10095 action
10096 (gnus-data-header
10097 (assoc article (gnus-data-list nil)))
10098 gnus-newsgroup-name
10099 to-newsgroup
10100 select-method))
10101
10102 ;;;!!!Why is this necessary?
10103 (set-buffer gnus-summary-buffer)
10104
10105 (when (eq action 'move)
10106 (save-excursion
10107 (gnus-summary-goto-subject article)
10108 (gnus-summary-mark-article article gnus-canceled-mark)))))
10109 (push article articles-to-update-marks))
10110
10111 (save-excursion
10112 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10113 ;; Re-activate all groups that have been moved to.
10114 (with-current-buffer gnus-group-buffer
10115 (let ((gnus-group-marked to-groups))
10116 (gnus-group-get-new-news-this-group nil t)))
10117
10118 (gnus-kill-buffer copy-buf)
10119 (gnus-summary-position-point)
10120 (gnus-set-mode-line 'summary)))
10121
10122 (defun gnus-summary-push-marks-to-backend (article)
10123 (let ((set nil)
10124 (del nil)
10125 (marks gnus-article-mark-lists))
10126 (unless (memq article gnus-newsgroup-unreads)
10127 (push 'read set))
10128 (while marks
10129 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10130 (memq article (symbol-value
10131 (intern (format "gnus-newsgroup-%s"
10132 (caar marks))))))
10133 (push (cdar marks) set)
10134 (push (cdar marks) del))
10135 (pop marks))
10136 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10137 ((,article) del ,del)))))
10138
10139 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10140 "Copy the current article to some other group.
10141 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10142 When called interactively, if TO-NEWSGROUP is nil, use the value of
10143 the variable `gnus-move-split-methods' for finding a default target
10144 newsgroup.
10145 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10146 re-spool using this method."
10147 (interactive "P")
10148 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10149
10150 (defun gnus-summary-crosspost-article (&optional n)
10151 "Crosspost the current article to some other group."
10152 (interactive "P")
10153 (gnus-summary-move-article n nil nil 'crosspost))
10154
10155 (defcustom gnus-summary-respool-default-method nil
10156 "Default method type for respooling an article.
10157 If nil, use to the current newsgroup method."
10158 :type 'symbol
10159 :group 'gnus-summary-mail)
10160
10161 (defun gnus-summary-respool-article (&optional n method)
10162 "Respool the current article.
10163 The article will be squeezed through the mail spooling process again,
10164 which means that it will be put in some mail newsgroup or other
10165 depending on `nnmail-split-methods'.
10166 If N is a positive number, respool the N next articles.
10167 If N is a negative number, respool the N previous articles.
10168 If N is nil and any articles have been marked with the process mark,
10169 respool those articles instead.
10170
10171 Respooling can be done both from mail groups and \"real\" newsgroups.
10172 In the former case, the articles in question will be moved from the
10173 current group into whatever groups they are destined to. In the
10174 latter case, they will be copied into the relevant groups."
10175 (interactive
10176 (list current-prefix-arg
10177 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10178 (methname
10179 (symbol-name (or gnus-summary-respool-default-method
10180 (car (gnus-find-method-for-group
10181 gnus-newsgroup-name)))))
10182 (method
10183 (gnus-completing-read
10184 "Backend to use when respooling"
10185 methods t nil 'gnus-mail-method-history methname))
10186 ms)
10187 (cond
10188 ((zerop (length (setq ms (gnus-servers-using-backend
10189 (intern method)))))
10190 (list (intern method) ""))
10191 ((= 1 (length ms))
10192 (car ms))
10193 (t
10194 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10195 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10196 ms-alist))))))))
10197 (unless method
10198 (error "No method given for respooling"))
10199 (if (assoc (symbol-name
10200 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10201 (gnus-methods-using 'respool))
10202 (gnus-summary-move-article n nil method)
10203 (gnus-summary-copy-article n nil method)))
10204
10205 (defun gnus-summary-import-article (file &optional edit)
10206 "Import an arbitrary file into a mail newsgroup."
10207 (interactive "fImport file: \nP")
10208 (let ((group gnus-newsgroup-name)
10209 (now (current-time))
10210 atts lines group-art)
10211 (unless (gnus-check-backend-function 'request-accept-article group)
10212 (error "%s does not support article importing" group))
10213 (or (file-readable-p file)
10214 (not (file-regular-p file))
10215 (error "Can't read %s" file))
10216 (with-current-buffer (gnus-get-buffer-create " *import file*")
10217 (erase-buffer)
10218 (nnheader-insert-file-contents file)
10219 (goto-char (point-min))
10220 (if (nnheader-article-p)
10221 (save-restriction
10222 (goto-char (point-min))
10223 (search-forward "\n\n" nil t)
10224 (narrow-to-region (point-min) (1- (point)))
10225 (goto-char (point-min))
10226 (unless (re-search-forward "^date:" nil t)
10227 (goto-char (point-max))
10228 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10229 ;; This doesn't look like an article, so we fudge some headers.
10230 (setq atts (file-attributes file)
10231 lines (count-lines (point-min) (point-max)))
10232 (insert "From: " (read-string "From: ") "\n"
10233 "Subject: " (read-string "Subject: ") "\n"
10234 "Date: " (message-make-date (nth 5 atts)) "\n"
10235 "Message-ID: " (message-make-message-id) "\n"
10236 "Lines: " (int-to-string lines) "\n"
10237 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10238 (setq group-art (gnus-request-accept-article group nil t))
10239 (kill-buffer (current-buffer)))
10240 (setq gnus-newsgroup-active (gnus-activate-group group))
10241 (forward-line 1)
10242 (gnus-summary-goto-article (cdr group-art) nil t)
10243 (when edit
10244 (gnus-summary-edit-article))))
10245
10246 (defun gnus-summary-create-article ()
10247 "Create an article in a mail newsgroup."
10248 (interactive)
10249 (let ((group gnus-newsgroup-name)
10250 (now (current-time))
10251 group-art)
10252 (unless (gnus-check-backend-function 'request-accept-article group)
10253 (error "%s does not support article importing" group))
10254 (with-current-buffer (gnus-get-buffer-create " *import file*")
10255 (erase-buffer)
10256 (goto-char (point-min))
10257 ;; This doesn't look like an article, so we fudge some headers.
10258 (insert "From: " (read-string "From: ") "\n"
10259 "Subject: " (read-string "Subject: ") "\n"
10260 "Date: " (message-make-date now) "\n"
10261 "Message-ID: " (message-make-message-id) "\n")
10262 (setq group-art (gnus-request-accept-article group nil t))
10263 (kill-buffer (current-buffer)))
10264 (setq gnus-newsgroup-active (gnus-activate-group group))
10265 (forward-line 1)
10266 (gnus-summary-goto-article (cdr group-art) nil t)
10267 (gnus-summary-edit-article)))
10268
10269 (defun gnus-summary-article-posted-p ()
10270 "Say whether the current (mail) article is available from news as well.
10271 This will be the case if the article has both been mailed and posted."
10272 (interactive)
10273 (let ((id (mail-header-references (gnus-summary-article-header)))
10274 (gnus-override-method (car (gnus-refer-article-methods))))
10275 (if (gnus-request-head id "")
10276 (gnus-message 2 "The current message was found on %s"
10277 gnus-override-method)
10278 (gnus-message 2 "The current message couldn't be found on %s"
10279 gnus-override-method)
10280 nil)))
10281
10282 (defun gnus-summary-expire-articles (&optional now)
10283 "Expire all articles that are marked as expirable in the current group."
10284 (interactive)
10285 (when (and (not gnus-group-is-exiting-without-update-p)
10286 (gnus-check-backend-function
10287 'request-expire-articles gnus-newsgroup-name))
10288 ;; This backend supports expiry.
10289 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10290 (expirable (if total
10291 (progn
10292 ;; We need to update the info for
10293 ;; this group for `gnus-list-of-read-articles'
10294 ;; to give us the right answer.
10295 (gnus-run-hooks 'gnus-exit-group-hook)
10296 (gnus-summary-update-info)
10297 (gnus-list-of-read-articles gnus-newsgroup-name))
10298 (setq gnus-newsgroup-expirable
10299 (sort gnus-newsgroup-expirable '<))))
10300 (expiry-wait (if now 'immediate
10301 (gnus-group-find-parameter
10302 gnus-newsgroup-name 'expiry-wait)))
10303 (nnmail-expiry-target
10304 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10305 nnmail-expiry-target))
10306 es)
10307 (when expirable
10308 ;; There are expirable articles in this group, so we run them
10309 ;; through the expiry process.
10310 (gnus-message 6 "Expiring articles...")
10311 (when (gnus-check-group gnus-newsgroup-name)
10312 ;; The list of articles that weren't expired is returned.
10313 (save-excursion
10314 (if expiry-wait
10315 (let ((nnmail-expiry-wait-function nil)
10316 (nnmail-expiry-wait expiry-wait))
10317 (setq es (gnus-request-expire-articles
10318 expirable gnus-newsgroup-name)))
10319 (setq es (gnus-request-expire-articles
10320 expirable gnus-newsgroup-name)))
10321 (unless total
10322 (setq gnus-newsgroup-expirable es))
10323 ;; We go through the old list of expirable, and mark all
10324 ;; really expired articles as nonexistent.
10325 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10326 (let ((gnus-use-cache nil))
10327 (dolist (article expirable)
10328 (when (and (not (memq article es))
10329 (gnus-data-find article))
10330 (gnus-summary-mark-article article gnus-canceled-mark)
10331 (run-hook-with-args 'gnus-summary-article-expire-hook
10332 'delete
10333 (gnus-data-header
10334 (assoc article (gnus-data-list nil)))
10335 gnus-newsgroup-name
10336 nil
10337 nil)))))))
10338 (gnus-message 6 "Expiring articles...done")))))
10339
10340 (defun gnus-summary-expire-articles-now ()
10341 "Expunge all expirable articles in the current group.
10342 This means that *all* articles that are marked as expirable will be
10343 deleted forever, right now."
10344 (interactive)
10345 (or gnus-expert-user
10346 (gnus-yes-or-no-p
10347 "Are you really, really sure you want to delete all expirable messages? ")
10348 (error "Phew!"))
10349 (gnus-summary-expire-articles t))
10350
10351 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10352 (defun gnus-summary-delete-article (&optional n)
10353 "Delete the N next (mail) articles.
10354 This command actually deletes articles. This is not a marking
10355 command. The article will disappear forever from your life, never to
10356 return.
10357
10358 If N is negative, delete backwards.
10359 If N is nil and articles have been marked with the process mark,
10360 delete these instead.
10361
10362 If `gnus-novice-user' is non-nil you will be asked for
10363 confirmation before the articles are deleted."
10364 (interactive "P")
10365 (unless (gnus-check-backend-function 'request-expire-articles
10366 gnus-newsgroup-name)
10367 (error "The current newsgroup does not support article deletion"))
10368 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10369 (error "Couldn't open server"))
10370 ;; Compute the list of articles to delete.
10371 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10372 (nnmail-expiry-target 'delete)
10373 not-deleted)
10374 (if (and gnus-novice-user
10375 (not (gnus-yes-or-no-p
10376 (format "Do you really want to delete %s forever? "
10377 (if (> (length articles) 1)
10378 (format "these %s articles" (length articles))
10379 "this article")))))
10380 ()
10381 ;; Delete the articles.
10382 (setq not-deleted (gnus-request-expire-articles
10383 articles gnus-newsgroup-name 'force))
10384 (save-excursion
10385 (while articles
10386 (gnus-summary-remove-process-mark (car articles))
10387 ;; The backend might not have been able to delete the article
10388 ;; after all.
10389 (unless (memq (car articles) not-deleted)
10390 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10391 (let* ((article (car articles))
10392 (ghead (gnus-data-header
10393 (assoc article (gnus-data-list nil)))))
10394 (run-hook-with-args 'gnus-summary-article-delete-hook
10395 'delete ghead gnus-newsgroup-name nil
10396 nil)))
10397 (setq articles (cdr articles))))
10398 (when not-deleted
10399 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10400 (gnus-summary-position-point)
10401 (gnus-set-mode-line 'summary)
10402 not-deleted))
10403
10404 (defun gnus-summary-edit-article (&optional arg)
10405 "Edit the current article.
10406 This will have permanent effect only in mail groups.
10407 If ARG is nil, edit the decoded articles.
10408 If ARG is 1, edit the raw articles.
10409 If ARG is 2, edit the raw articles even in read-only groups.
10410 If ARG is 3, edit the articles with the current handles.
10411 Otherwise, allow editing of articles even in read-only
10412 groups."
10413 (interactive "P")
10414 (let (force raw current-handles)
10415 (cond
10416 ((null arg))
10417 ((eq arg 1)
10418 (setq raw t))
10419 ((eq arg 2)
10420 (setq raw t
10421 force t))
10422 ((eq arg 3)
10423 (setq current-handles
10424 (and (gnus-buffer-live-p gnus-article-buffer)
10425 (with-current-buffer gnus-article-buffer
10426 (prog1
10427 gnus-article-mime-handles
10428 (setq gnus-article-mime-handles nil))))))
10429 (t
10430 (setq force t)))
10431 (when (and raw (not force)
10432 (member gnus-newsgroup-name '("nndraft:delayed"
10433 "nndraft:drafts"
10434 "nndraft:queue")))
10435 (error "Can't edit the raw article in group %s"
10436 gnus-newsgroup-name))
10437 (with-current-buffer gnus-summary-buffer
10438 (let ((mail-parse-charset gnus-newsgroup-charset)
10439 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10440 (gnus-set-global-variables)
10441 (when (and (not force)
10442 (gnus-group-read-only-p))
10443 (error "The current newsgroup does not support article editing"))
10444 (gnus-summary-show-article t)
10445 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10446 (with-current-buffer gnus-article-buffer
10447 (mm-enable-multibyte)))
10448 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10449 (setq raw t))
10450 (gnus-article-edit-article
10451 (if raw 'ignore
10452 `(lambda ()
10453 (let ((mbl mml-buffer-list))
10454 (setq mml-buffer-list nil)
10455 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10456 (mime-to-mml ,'current-handles))
10457 (let ((mbl1 mml-buffer-list))
10458 (setq mml-buffer-list mbl)
10459 (set (make-local-variable 'mml-buffer-list) mbl1))
10460 (gnus-make-local-hook 'kill-buffer-hook)
10461 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10462 `(lambda (no-highlight)
10463 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10464 (message-options message-options)
10465 (message-options-set-recipient)
10466 (mail-parse-ignored-charsets
10467 ',gnus-newsgroup-ignored-charsets)
10468 (rfc2047-header-encoding-alist
10469 ',(let ((charset (gnus-group-name-charset
10470 (gnus-find-method-for-group
10471 gnus-newsgroup-name)
10472 gnus-newsgroup-name)))
10473 (append (list (cons "Newsgroups" charset)
10474 (cons "Followup-To" charset)
10475 (cons "Xref" charset))
10476 rfc2047-header-encoding-alist))))
10477 ,(if (not raw) '(progn
10478 (mml-to-mime)
10479 (mml-destroy-buffers)
10480 (remove-hook 'kill-buffer-hook
10481 'mml-destroy-buffers t)
10482 (kill-local-variable 'mml-buffer-list)))
10483 (gnus-summary-edit-article-done
10484 ,(or (mail-header-references gnus-current-headers) "")
10485 ,(gnus-group-read-only-p)
10486 ,gnus-summary-buffer no-highlight))))))))
10487
10488 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10489
10490 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10491 no-highlight)
10492 "Make edits to the current article permanent."
10493 (interactive)
10494 (save-excursion
10495 ;; The buffer restriction contains the entire article if it exists.
10496 (when (article-goto-body)
10497 (let ((lines (count-lines (point) (point-max)))
10498 (length (- (point-max) (point)))
10499 (case-fold-search t)
10500 (body (copy-marker (point))))
10501 (goto-char (point-min))
10502 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10503 (delete-region (match-beginning 1) (match-end 1))
10504 (insert (number-to-string length)))
10505 (goto-char (point-min))
10506 (when (re-search-forward
10507 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10508 (delete-region (match-beginning 1) (match-end 1))
10509 (insert (number-to-string length)))
10510 (goto-char (point-min))
10511 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10512 (delete-region (match-beginning 1) (match-end 1))
10513 (insert (number-to-string lines))))))
10514 ;; Replace the article.
10515 (let ((buf (current-buffer))
10516 (article (cdr gnus-article-current))
10517 replace-result)
10518 (with-temp-buffer
10519 (insert-buffer-substring buf)
10520 (if (and (not read-only)
10521 (not (setq replace-result
10522 (gnus-request-replace-article
10523 article (car gnus-article-current)
10524 (current-buffer) t))))
10525 (error "Couldn't replace article")
10526 ;; If we got a number back, then that's the new article number
10527 ;; for this article. Otherwise, the article number didn't change.
10528 (when (numberp replace-result)
10529 (with-current-buffer gnus-summary-buffer
10530 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10531 (gnus-summary-limit gnus-newsgroup-limit)
10532 (setq article replace-result)
10533 (gnus-summary-goto-subject article t)))
10534 ;; Update the summary buffer.
10535 (if (and references
10536 (equal (message-tokenize-header references " ")
10537 (message-tokenize-header
10538 (or (message-fetch-field "references") "") " ")))
10539 ;; We only have to update this line.
10540 (save-excursion
10541 (save-restriction
10542 (message-narrow-to-head)
10543 (let ((head (buffer-substring-no-properties
10544 (point-min) (point-max)))
10545 header)
10546 (with-temp-buffer
10547 (insert (format "211 %d Article retrieved.\n" article))
10548 (insert head)
10549 (insert ".\n")
10550 (let ((nntp-server-buffer (current-buffer)))
10551 (setq header (car (gnus-get-newsgroup-headers nil t))))
10552 (with-current-buffer gnus-summary-buffer
10553 (gnus-data-set-header (gnus-data-find article) header)
10554 (gnus-summary-update-article-line article header)
10555 (if (gnus-summary-goto-subject article nil t)
10556 (gnus-summary-update-secondary-mark article)))))))
10557 ;; Update threads.
10558 (set-buffer (or buffer gnus-summary-buffer))
10559 (gnus-summary-update-article article)
10560 (if (gnus-summary-goto-subject article nil t)
10561 (gnus-summary-update-secondary-mark article)))
10562 ;; Prettify the article buffer again.
10563 (unless no-highlight
10564 (with-current-buffer gnus-article-buffer
10565 ;;!!! Fix this -- article should be rehighlighted.
10566 ;;(gnus-run-hooks 'gnus-article-display-hook)
10567 (set-buffer gnus-original-article-buffer)
10568 (gnus-request-article
10569 article (car gnus-article-current) (current-buffer))))
10570 ;; Prettify the summary buffer line.
10571 (when (gnus-visual-p 'summary-highlight 'highlight)
10572 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10573
10574 (defun gnus-summary-edit-wash (key)
10575 "Perform editing command KEY in the article buffer."
10576 (interactive
10577 (list
10578 (progn
10579 (message "%s" (concat (this-command-keys) "- "))
10580 (read-char))))
10581 (message "")
10582 (gnus-summary-edit-article)
10583 (execute-kbd-macro (concat (this-command-keys) key))
10584 (gnus-article-edit-done))
10585
10586 ;;; Respooling
10587
10588 (defun gnus-summary-respool-query (&optional silent trace)
10589 "Query where the respool algorithm would put this article."
10590 (interactive)
10591 (let (gnus-mark-article-hook)
10592 (gnus-summary-select-article)
10593 (with-current-buffer gnus-original-article-buffer
10594 (let ((groups (nnmail-article-group 'identity trace)))
10595 (unless silent
10596 (if groups
10597 (message "This message would go to %s"
10598 (mapconcat 'car groups ", "))
10599 (message "This message would go to no groups"))
10600 groups)))))
10601
10602 (defun gnus-summary-respool-trace ()
10603 "Trace where the respool algorithm would put this article.
10604 Display a buffer showing all fancy splitting patterns which matched."
10605 (interactive)
10606 (gnus-summary-respool-query nil t))
10607
10608 ;; Summary marking commands.
10609
10610 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10611 "Mark articles which has the same subject as read, and then select the next.
10612 If UNMARK is positive, remove any kind of mark.
10613 If UNMARK is negative, tick articles."
10614 (interactive "P")
10615 (when unmark
10616 (setq unmark (prefix-numeric-value unmark)))
10617 (let ((count
10618 (gnus-summary-mark-same-subject
10619 (gnus-summary-article-subject) unmark)))
10620 ;; Select next unread article. If auto-select-same mode, should
10621 ;; select the first unread article.
10622 (gnus-summary-next-article t (and gnus-auto-select-same
10623 (gnus-summary-article-subject)))
10624 (gnus-message 7 "%d article%s marked as %s"
10625 count (if (= count 1) " is" "s are")
10626 (if unmark "unread" "read"))))
10627
10628 (defun gnus-summary-kill-same-subject (&optional unmark)
10629 "Mark articles which has the same subject as read.
10630 If UNMARK is positive, remove any kind of mark.
10631 If UNMARK is negative, tick articles."
10632 (interactive "P")
10633 (when unmark
10634 (setq unmark (prefix-numeric-value unmark)))
10635 (let ((count
10636 (gnus-summary-mark-same-subject
10637 (gnus-summary-article-subject) unmark)))
10638 ;; If marked as read, go to next unread subject.
10639 (when (null unmark)
10640 ;; Go to next unread subject.
10641 (gnus-summary-next-subject 1 t))
10642 (gnus-message 7 "%d articles are marked as %s"
10643 count (if unmark "unread" "read"))))
10644
10645 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10646 "Mark articles with same SUBJECT as read, and return marked number.
10647 If optional argument UNMARK is positive, remove any kinds of marks.
10648 If optional argument UNMARK is negative, mark articles as unread instead."
10649 (let ((count 1))
10650 (save-excursion
10651 (cond
10652 ((null unmark) ; Mark as read.
10653 (while (and
10654 (progn
10655 (gnus-summary-mark-article-as-read gnus-killed-mark)
10656 (gnus-summary-show-thread) t)
10657 (gnus-summary-find-subject subject))
10658 (setq count (1+ count))))
10659 ((> unmark 0) ; Tick.
10660 (while (and
10661 (progn
10662 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10663 (gnus-summary-show-thread) t)
10664 (gnus-summary-find-subject subject))
10665 (setq count (1+ count))))
10666 (t ; Mark as unread.
10667 (while (and
10668 (progn
10669 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10670 (gnus-summary-show-thread) t)
10671 (gnus-summary-find-subject subject))
10672 (setq count (1+ count)))))
10673 (gnus-set-mode-line 'summary)
10674 ;; Return the number of marked articles.
10675 count)))
10676
10677 (defun gnus-summary-mark-as-processable (n &optional unmark)
10678 "Set the process mark on the next N articles.
10679 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10680 the process mark instead. The difference between N and the actual
10681 number of articles marked is returned."
10682 (interactive "P")
10683 (if (and (null n) (gnus-region-active-p))
10684 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10685 (setq n (prefix-numeric-value n))
10686 (let ((backward (< n 0))
10687 (n (abs n)))
10688 (while (and
10689 (> n 0)
10690 (if unmark
10691 (gnus-summary-remove-process-mark
10692 (gnus-summary-article-number))
10693 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10694 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10695 (setq n (1- n)))
10696 (when (/= 0 n)
10697 (gnus-message 7 "No more articles"))
10698 (gnus-summary-recenter)
10699 (gnus-summary-position-point)
10700 n)))
10701
10702 (defun gnus-summary-unmark-as-processable (n)
10703 "Remove the process mark from the next N articles.
10704 If N is negative, unmark backward instead. The difference between N and
10705 the actual number of articles unmarked is returned."
10706 (interactive "P")
10707 (gnus-summary-mark-as-processable n t))
10708
10709 (defun gnus-summary-unmark-all-processable ()
10710 "Remove the process mark from all articles."
10711 (interactive)
10712 (save-excursion
10713 (while gnus-newsgroup-processable
10714 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10715 (gnus-summary-position-point))
10716
10717 (defun gnus-summary-add-mark (article type)
10718 "Mark ARTICLE with a mark of TYPE."
10719 (let ((vtype (car (assq type gnus-article-mark-lists)))
10720 var)
10721 (if (not vtype)
10722 (error "No such mark type: %s" type)
10723 (setq var (intern (format "gnus-newsgroup-%s" type)))
10724 (set var (cons article (symbol-value var)))
10725 (if (memq type '(processable cached replied forwarded recent saved))
10726 (gnus-summary-update-secondary-mark article)
10727 ;;; !!! This is bogus. We should find out what primary
10728 ;;; !!! mark we want to set.
10729 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10730
10731 (defun gnus-summary-mark-as-expirable (n)
10732 "Mark N articles forward as expirable.
10733 If N is negative, mark backward instead. The difference between N and
10734 the actual number of articles marked is returned."
10735 (interactive "p")
10736 (gnus-summary-mark-forward n gnus-expirable-mark))
10737
10738 (defun gnus-summary-mark-as-spam (n)
10739 "Mark N articles forward as spam.
10740 If N is negative, mark backward instead. The difference between N and
10741 the actual number of articles marked is returned."
10742 (interactive "p")
10743 (gnus-summary-mark-forward n gnus-spam-mark))
10744
10745 (defun gnus-summary-mark-article-as-replied (article)
10746 "Mark ARTICLE as replied to and update the summary line.
10747 ARTICLE can also be a list of articles."
10748 (interactive (list (gnus-summary-article-number)))
10749 (let ((articles (if (listp article) article (list article))))
10750 (dolist (article articles)
10751 (unless (numberp article)
10752 (error "%s is not a number" article))
10753 (push article gnus-newsgroup-replied)
10754 (let ((inhibit-read-only t))
10755 (when (gnus-summary-goto-subject article nil t)
10756 (gnus-summary-update-secondary-mark article))))))
10757
10758 (defun gnus-summary-mark-article-as-forwarded (article)
10759 "Mark ARTICLE as forwarded and update the summary line.
10760 ARTICLE can also be a list of articles."
10761 (let ((articles (if (listp article) article (list article))))
10762 (dolist (article articles)
10763 (push article gnus-newsgroup-forwarded)
10764 (let ((inhibit-read-only t))
10765 (when (gnus-summary-goto-subject article nil t)
10766 (gnus-summary-update-secondary-mark article))))))
10767
10768 (defun gnus-summary-set-bookmark (article)
10769 "Set a bookmark in current article."
10770 (interactive (list (gnus-summary-article-number)))
10771 (when (or (not (get-buffer gnus-article-buffer))
10772 (not gnus-current-article)
10773 (not gnus-article-current)
10774 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10775 (error "No current article selected"))
10776 ;; Remove old bookmark, if one exists.
10777 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10778 ;; Set the new bookmark, which is on the form
10779 ;; (article-number . line-number-in-body).
10780 (push
10781 (cons article
10782 (with-current-buffer gnus-article-buffer
10783 (count-lines
10784 (min (point)
10785 (save-excursion
10786 (article-goto-body)
10787 (point)))
10788 (point))))
10789 gnus-newsgroup-bookmarks)
10790 (gnus-message 6 "A bookmark has been added to the current article."))
10791
10792 (defun gnus-summary-remove-bookmark (article)
10793 "Remove the bookmark from the current article."
10794 (interactive (list (gnus-summary-article-number)))
10795 ;; Remove old bookmark, if one exists.
10796 (if (not (assq article gnus-newsgroup-bookmarks))
10797 (gnus-message 6 "No bookmark in current article.")
10798 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10799 (gnus-message 6 "Removed bookmark.")))
10800
10801 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10802 (defun gnus-summary-mark-as-dormant (n)
10803 "Mark N articles forward as dormant.
10804 If N is negative, mark backward instead. The difference between N and
10805 the actual number of articles marked is returned."
10806 (interactive "p")
10807 (gnus-summary-mark-forward n gnus-dormant-mark))
10808
10809 (defun gnus-summary-set-process-mark (article)
10810 "Set the process mark on ARTICLE and update the summary line."
10811 (setq gnus-newsgroup-processable
10812 (cons article
10813 (delq article gnus-newsgroup-processable)))
10814 (when (gnus-summary-goto-subject article)
10815 (gnus-summary-show-thread)
10816 (gnus-summary-goto-subject article)
10817 (gnus-summary-update-secondary-mark article)))
10818
10819 (defun gnus-summary-remove-process-mark (&rest articles)
10820 "Remove the process mark from ARTICLES and update the summary line."
10821 (dolist (article articles)
10822 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10823 (when (gnus-summary-goto-subject article)
10824 (gnus-summary-show-thread)
10825 (gnus-summary-goto-subject article)
10826 (gnus-summary-update-secondary-mark article)))
10827 t)
10828
10829 (defun gnus-summary-set-saved-mark (article)
10830 "Set the process mark on ARTICLE and update the summary line."
10831 (push article gnus-newsgroup-saved)
10832 (when (gnus-summary-goto-subject article)
10833 (gnus-summary-update-secondary-mark article)))
10834
10835 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10836 "Mark N articles as read forwards.
10837 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10838 The difference between N and the actual number of articles marked is
10839 returned.
10840 If NO-EXPIRE, auto-expiry will be inhibited."
10841 (interactive "p")
10842 (gnus-summary-show-thread)
10843 (let ((backward (< n 0))
10844 (gnus-summary-goto-unread
10845 (and gnus-summary-goto-unread
10846 (not (eq gnus-summary-goto-unread 'never))
10847 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10848 gnus-ticked-mark gnus-dormant-mark)))))
10849 (n (abs n))
10850 (mark (or mark gnus-del-mark)))
10851 (while (and (> n 0)
10852 (gnus-summary-mark-article nil mark no-expire)
10853 (zerop (gnus-summary-next-subject
10854 (if backward -1 1)
10855 (and gnus-summary-goto-unread
10856 (not (eq gnus-summary-goto-unread 'never)))
10857 t)))
10858 (setq n (1- n)))
10859 (when (/= 0 n)
10860 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10861 (gnus-summary-recenter)
10862 (gnus-summary-position-point)
10863 (gnus-set-mode-line 'summary)
10864 n))
10865
10866 (defun gnus-summary-mark-article-as-read (mark)
10867 "Mark the current article quickly as read with MARK."
10868 (let ((article (gnus-summary-article-number)))
10869 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10870 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10871 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10872 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10873 (push (cons article mark) gnus-newsgroup-reads)
10874 ;; Possibly remove from cache, if that is used.
10875 (when gnus-use-cache
10876 (gnus-cache-enter-remove-article article))
10877 ;; Allow the backend to change the mark.
10878 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10879 ;; Check for auto-expiry.
10880 (when (and gnus-newsgroup-auto-expire
10881 (memq mark gnus-auto-expirable-marks))
10882 (setq mark gnus-expirable-mark)
10883 ;; Let the backend know about the mark change.
10884 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10885 (push article gnus-newsgroup-expirable))
10886 ;; Set the mark in the buffer.
10887 (gnus-summary-update-mark mark 'unread)
10888 t))
10889
10890 (defun gnus-summary-mark-article-as-unread (mark)
10891 "Mark the current article quickly as unread with MARK."
10892 (let* ((article (gnus-summary-article-number))
10893 (old-mark (gnus-summary-article-mark article)))
10894 ;; Allow the backend to change the mark.
10895 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10896 (if (eq mark old-mark)
10897 t
10898 (if (<= article 0)
10899 (progn
10900 (gnus-error 1 "Can't mark negative article numbers")
10901 nil)
10902 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10903 (setq gnus-newsgroup-spam-marked
10904 (delq article gnus-newsgroup-spam-marked))
10905 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10906 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10907 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10908 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10909 (cond ((= mark gnus-ticked-mark)
10910 (setq gnus-newsgroup-marked
10911 (gnus-add-to-sorted-list gnus-newsgroup-marked
10912 article)))
10913 ((= mark gnus-spam-mark)
10914 (setq gnus-newsgroup-spam-marked
10915 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10916 article)))
10917 ((= mark gnus-dormant-mark)
10918 (setq gnus-newsgroup-dormant
10919 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10920 article)))
10921 (t
10922 (setq gnus-newsgroup-unreads
10923 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10924 article))))
10925 (gnus-alist-pull article gnus-newsgroup-reads)
10926
10927 ;; See whether the article is to be put in the cache.
10928 (and gnus-use-cache
10929 (vectorp (gnus-summary-article-header article))
10930 (save-excursion
10931 (gnus-cache-possibly-enter-article
10932 gnus-newsgroup-name article
10933 (= mark gnus-ticked-mark)
10934 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10935
10936 ;; Fix the mark.
10937 (gnus-summary-update-mark mark 'unread)
10938 t))))
10939
10940 (defun gnus-summary-mark-article (&optional article mark no-expire)
10941 "Mark ARTICLE with MARK. MARK can be any character.
10942 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10943 `??' (dormant) and `?E' (expirable).
10944 If MARK is nil, then the default character `?r' is used.
10945 If ARTICLE is nil, then the article on the current line will be
10946 marked.
10947 If NO-EXPIRE, auto-expiry will be inhibited."
10948 ;; The mark might be a string.
10949 (when (stringp mark)
10950 (setq mark (aref mark 0)))
10951 ;; If no mark is given, then we check auto-expiring.
10952 (when (null mark)
10953 (setq mark gnus-del-mark))
10954 (when (and (not no-expire)
10955 gnus-newsgroup-auto-expire
10956 (memq mark gnus-auto-expirable-marks))
10957 (setq mark gnus-expirable-mark))
10958 (let ((article (or article (gnus-summary-article-number)))
10959 (old-mark (gnus-summary-article-mark article)))
10960 ;; Allow the backend to change the mark.
10961 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10962 (if (eq mark old-mark)
10963 t
10964 (unless article
10965 (error "No article on current line"))
10966 (if (not (if (or (= mark gnus-unread-mark)
10967 (= mark gnus-ticked-mark)
10968 (= mark gnus-spam-mark)
10969 (= mark gnus-dormant-mark))
10970 (gnus-mark-article-as-unread article mark)
10971 (gnus-mark-article-as-read article mark)))
10972 t
10973 ;; See whether the article is to be put in the cache.
10974 (and gnus-use-cache
10975 (not (= mark gnus-canceled-mark))
10976 (vectorp (gnus-summary-article-header article))
10977 (save-excursion
10978 (gnus-cache-possibly-enter-article
10979 gnus-newsgroup-name article
10980 (= mark gnus-ticked-mark)
10981 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10982
10983 (when (gnus-summary-goto-subject article nil t)
10984 (let ((inhibit-read-only t))
10985 (gnus-summary-show-thread)
10986 ;; Fix the mark.
10987 (gnus-summary-update-mark mark 'unread)
10988 t))))))
10989
10990 (defun gnus-summary-update-secondary-mark (article)
10991 "Update the secondary (read, process, cache) mark."
10992 (gnus-summary-update-mark
10993 (cond ((memq article gnus-newsgroup-processable)
10994 gnus-process-mark)
10995 ((memq article gnus-newsgroup-cached)
10996 gnus-cached-mark)
10997 ((memq article gnus-newsgroup-replied)
10998 gnus-replied-mark)
10999 ((memq article gnus-newsgroup-forwarded)
11000 gnus-forwarded-mark)
11001 ((memq article gnus-newsgroup-saved)
11002 gnus-saved-mark)
11003 ((memq article gnus-newsgroup-unseen)
11004 gnus-unseen-mark)
11005 (t gnus-no-mark))
11006 'replied)
11007 (when (gnus-visual-p 'summary-highlight 'highlight)
11008 (gnus-summary-highlight-line)
11009 (gnus-run-hooks 'gnus-summary-update-hook))
11010 t)
11011
11012 (defun gnus-summary-update-download-mark (article)
11013 "Update the download mark."
11014 (gnus-summary-update-mark
11015 (cond ((memq article gnus-newsgroup-undownloaded)
11016 gnus-undownloaded-mark)
11017 (gnus-newsgroup-agentized
11018 gnus-downloaded-mark)
11019 (t
11020 gnus-no-mark))
11021 'download)
11022 (gnus-summary-update-line t)
11023 t)
11024
11025 (defun gnus-summary-update-mark (mark type)
11026 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11027 (inhibit-read-only t))
11028 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11029 (when forward
11030 (when (looking-at "\r")
11031 (incf forward))
11032 (when (<= (+ forward (point)) (point-max))
11033 ;; Go to the right position on the line.
11034 (goto-char (+ forward (point)))
11035 ;; Replace the old mark with the new mark.
11036 (let ((to-insert
11037 (mm-subst-char-in-string
11038 (char-after) mark
11039 (buffer-substring (point) (1+ (point))))))
11040 (delete-region (point) (1+ (point)))
11041 (insert to-insert))
11042 ;; Optionally update the marks by some user rule.
11043 (when (eq type 'unread)
11044 (gnus-data-set-mark
11045 (gnus-data-find (gnus-summary-article-number)) mark)
11046 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11047
11048 (defun gnus-mark-article-as-read (article &optional mark)
11049 "Enter ARTICLE in the pertinent lists and remove it from others."
11050 ;; Make the article expirable.
11051 (let ((mark (or mark gnus-del-mark)))
11052 (setq gnus-newsgroup-expirable
11053 (if (= mark gnus-expirable-mark)
11054 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11055 (delq article gnus-newsgroup-expirable)))
11056 ;; Remove from unread and marked lists.
11057 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11058 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11059 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11060 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11061 (push (cons article mark) gnus-newsgroup-reads)
11062 ;; Possibly remove from cache, if that is used.
11063 (when gnus-use-cache
11064 (gnus-cache-enter-remove-article article))
11065 t))
11066
11067 (defun gnus-mark-article-as-unread (article &optional mark)
11068 "Enter ARTICLE in the pertinent lists and remove it from others."
11069 (let ((mark (or mark gnus-ticked-mark)))
11070 (if (<= article 0)
11071 (progn
11072 (gnus-error 1 "Can't mark negative article numbers")
11073 nil)
11074 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11075 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11076 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11077 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11078 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11079
11080 ;; Unsuppress duplicates?
11081 (when gnus-suppress-duplicates
11082 (gnus-dup-unsuppress-article article))
11083
11084 (cond ((= mark gnus-ticked-mark)
11085 (setq gnus-newsgroup-marked
11086 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11087 ((= mark gnus-spam-mark)
11088 (setq gnus-newsgroup-spam-marked
11089 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11090 article)))
11091 ((= mark gnus-dormant-mark)
11092 (setq gnus-newsgroup-dormant
11093 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11094 (t
11095 (setq gnus-newsgroup-unreads
11096 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11097 (gnus-alist-pull article gnus-newsgroup-reads)
11098 t)))
11099
11100 (defun gnus-summary-tick-article-forward (n)
11101 "Tick N articles forwards.
11102 If N is negative, tick backwards instead.
11103 The difference between N and the number of articles ticked is returned."
11104 (interactive "p")
11105 (gnus-summary-mark-forward n gnus-ticked-mark))
11106
11107 (defun gnus-summary-tick-article-backward (n)
11108 "Tick N articles backwards.
11109 The difference between N and the number of articles ticked is returned."
11110 (interactive "p")
11111 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11112
11113 (defun gnus-summary-tick-article (&optional article clear-mark)
11114 "Mark current article as unread.
11115 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11116 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11117 (interactive)
11118 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11119 gnus-ticked-mark)))
11120
11121 (defun gnus-summary-mark-as-read-forward (n)
11122 "Mark N articles as read forwards.
11123 If N is negative, mark backwards instead.
11124 The difference between N and the actual number of articles marked is
11125 returned."
11126 (interactive "p")
11127 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11128
11129 (defun gnus-summary-mark-as-read-backward (n)
11130 "Mark the N articles as read backwards.
11131 The difference between N and the actual number of articles marked is
11132 returned."
11133 (interactive "p")
11134 (gnus-summary-mark-forward
11135 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11136
11137 (defun gnus-summary-mark-as-read (&optional article mark)
11138 "Mark current article as read.
11139 ARTICLE specifies the article to be marked as read.
11140 MARK specifies a string to be inserted at the beginning of the line."
11141 (gnus-summary-mark-article article mark))
11142
11143 (defun gnus-summary-clear-mark-forward (n)
11144 "Clear marks from N articles forward.
11145 If N is negative, clear backward instead.
11146 The difference between N and the number of marks cleared is returned."
11147 (interactive "p")
11148 (gnus-summary-mark-forward n gnus-unread-mark))
11149
11150 (defun gnus-summary-clear-mark-backward (n)
11151 "Clear marks from N articles backward.
11152 The difference between N and the number of marks cleared is returned."
11153 (interactive "p")
11154 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11155
11156 (defun gnus-summary-mark-unread-as-read ()
11157 "Intended to be used by `gnus-mark-article-hook'."
11158 (when (memq gnus-current-article gnus-newsgroup-unreads)
11159 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11160
11161 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11162 "Intended to be used by `gnus-mark-article-hook'."
11163 (let ((mark (gnus-summary-article-mark)))
11164 (when (or (gnus-unread-mark-p mark)
11165 (gnus-read-mark-p mark))
11166 (gnus-summary-mark-article gnus-current-article
11167 (or new-mark gnus-read-mark)))))
11168
11169 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11170 "Intended to be used by `gnus-mark-article-hook'."
11171 (let ((mark (gnus-summary-article-mark)))
11172 (when (or (gnus-unread-mark-p mark)
11173 (gnus-read-mark-p mark))
11174 (gnus-summary-mark-article (gnus-summary-article-number)
11175 (or new-mark gnus-read-mark)))))
11176
11177 (defun gnus-summary-mark-unread-as-ticked ()
11178 "Intended to be used by `gnus-mark-article-hook'."
11179 (when (memq gnus-current-article gnus-newsgroup-unreads)
11180 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11181
11182 (defun gnus-summary-mark-region-as-read (point mark all)
11183 "Mark all unread articles between point and mark as read.
11184 If given a prefix, mark all articles between point and mark as read,
11185 even ticked and dormant ones."
11186 (interactive "r\nP")
11187 (save-excursion
11188 (let (article)
11189 (goto-char point)
11190 (beginning-of-line)
11191 (while (and
11192 (< (point) mark)
11193 (progn
11194 (when (or all
11195 (memq (setq article (gnus-summary-article-number))
11196 gnus-newsgroup-unreads))
11197 (gnus-summary-mark-article article gnus-del-mark))
11198 t)
11199 (gnus-summary-find-next))))))
11200
11201 (defun gnus-summary-mark-below (score mark)
11202 "Mark articles with score less than SCORE with MARK."
11203 (interactive "P\ncMark: ")
11204 (setq score (if score
11205 (prefix-numeric-value score)
11206 (or gnus-summary-default-score 0)))
11207 (with-current-buffer gnus-summary-buffer
11208 (goto-char (point-min))
11209 (while
11210 (progn
11211 (and (< (gnus-summary-article-score) score)
11212 (gnus-summary-mark-article nil mark))
11213 (gnus-summary-find-next)))))
11214
11215 (defun gnus-summary-kill-below (&optional score)
11216 "Mark articles with score below SCORE as read."
11217 (interactive "P")
11218 (gnus-summary-mark-below score gnus-killed-mark))
11219
11220 (defun gnus-summary-clear-above (&optional score)
11221 "Clear all marks from articles with score above SCORE."
11222 (interactive "P")
11223 (gnus-summary-mark-above score gnus-unread-mark))
11224
11225 (defun gnus-summary-tick-above (&optional score)
11226 "Tick all articles with score above SCORE."
11227 (interactive "P")
11228 (gnus-summary-mark-above score gnus-ticked-mark))
11229
11230 (defun gnus-summary-mark-above (score mark)
11231 "Mark articles with score over SCORE with MARK."
11232 (interactive "P\ncMark: ")
11233 (setq score (if score
11234 (prefix-numeric-value score)
11235 (or gnus-summary-default-score 0)))
11236 (with-current-buffer gnus-summary-buffer
11237 (goto-char (point-min))
11238 (while (and (progn
11239 (when (> (gnus-summary-article-score) score)
11240 (gnus-summary-mark-article nil mark))
11241 t)
11242 (gnus-summary-find-next)))))
11243
11244 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11245 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11246 (defun gnus-summary-limit-include-expunged (&optional no-error)
11247 "Display all the hidden articles that were expunged for low scores."
11248 (interactive)
11249 (let ((inhibit-read-only t))
11250 (let ((scored gnus-newsgroup-scored)
11251 headers h)
11252 (while scored
11253 (unless (gnus-summary-article-header (caar scored))
11254 (and (setq h (gnus-number-to-header (caar scored)))
11255 (< (cdar scored) gnus-summary-expunge-below)
11256 (push h headers)))
11257 (setq scored (cdr scored)))
11258 (if (not headers)
11259 (when (not no-error)
11260 (error "No expunged articles hidden"))
11261 (goto-char (point-min))
11262 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11263 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11264 (dolist (x headers)
11265 (push (mail-header-number x) gnus-newsgroup-limit))
11266 (gnus-summary-prepare-unthreaded (nreverse headers))
11267 (goto-char (point-min))
11268 (gnus-summary-position-point)
11269 t))))
11270
11271 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11272 "Mark all unread articles in this newsgroup as read.
11273 If prefix argument ALL is non-nil, ticked and dormant articles will
11274 also be marked as read.
11275 If QUIETLY is non-nil, no questions will be asked.
11276
11277 If TO-HERE is non-nil, it should be a point in the buffer. All
11278 articles before (after, if REVERSE is set) this point will be marked
11279 as read.
11280
11281 Note that this function will only catch up the unread article
11282 in the current summary buffer limitation.
11283
11284 The number of articles marked as read is returned."
11285 (interactive "P")
11286 (prog1
11287 (save-excursion
11288 (when (or quietly
11289 (not gnus-interactive-catchup) ;Without confirmation?
11290 gnus-expert-user
11291 (gnus-y-or-n-p
11292 (if all
11293 "Mark absolutely all articles as read? "
11294 "Mark all unread articles as read? ")))
11295 (if (and not-mark
11296 (not gnus-newsgroup-adaptive)
11297 (not gnus-newsgroup-auto-expire)
11298 (not gnus-suppress-duplicates)
11299 (or (not gnus-use-cache)
11300 (eq gnus-use-cache 'passive)))
11301 (progn
11302 (when all
11303 (setq gnus-newsgroup-marked nil
11304 gnus-newsgroup-spam-marked nil
11305 gnus-newsgroup-dormant nil))
11306 (setq gnus-newsgroup-unreads
11307 (gnus-sorted-nunion
11308 (gnus-sorted-intersection gnus-newsgroup-unreads
11309 gnus-newsgroup-downloadable)
11310 (gnus-sorted-difference gnus-newsgroup-unfetched
11311 gnus-newsgroup-cached))))
11312 ;; We actually mark all articles as canceled, which we
11313 ;; have to do when using auto-expiry or adaptive scoring.
11314 (gnus-summary-show-all-threads)
11315 (if (and to-here reverse)
11316 (progn
11317 (goto-char to-here)
11318 (gnus-summary-mark-current-read-and-unread-as-read
11319 gnus-catchup-mark)
11320 (while (gnus-summary-find-next (not all))
11321 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11322 (when (gnus-summary-first-subject (not all))
11323 (while (and
11324 (if to-here (< (point) to-here) t)
11325 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11326 (gnus-summary-find-next (not all))))))
11327 (gnus-set-mode-line 'summary))
11328 t))
11329 (gnus-summary-position-point)))
11330
11331 (defun gnus-summary-catchup-to-here (&optional all)
11332 "Mark all unticked articles before the current one as read.
11333 If ALL is non-nil, also mark ticked and dormant articles as read."
11334 (interactive "P")
11335 (save-excursion
11336 (gnus-save-hidden-threads
11337 (let ((beg (point)))
11338 ;; We check that there are unread articles.
11339 (when (or all (gnus-summary-find-prev))
11340 (gnus-summary-catchup all t beg)))))
11341 (gnus-summary-position-point))
11342
11343 (defun gnus-summary-catchup-from-here (&optional all)
11344 "Mark all unticked articles after (and including) the current one as read.
11345 If ALL is non-nil, also mark ticked and dormant articles as read."
11346 (interactive "P")
11347 (save-excursion
11348 (gnus-save-hidden-threads
11349 (let ((beg (point)))
11350 ;; We check that there are unread articles.
11351 (when (or all (gnus-summary-find-next))
11352 (gnus-summary-catchup all t beg nil t)))))
11353 (gnus-summary-position-point))
11354
11355 (defun gnus-summary-catchup-all (&optional quietly)
11356 "Mark all articles in this newsgroup as read.
11357 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11358 instead, which marks only unread articles as read."
11359 (interactive "P")
11360 (gnus-summary-catchup t quietly))
11361
11362 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11363 "Mark all unread articles in this group as read, then exit.
11364 If prefix argument ALL is non-nil, all articles are marked as read.
11365 If QUIETLY is non-nil, no questions will be asked."
11366 (interactive "P")
11367 (when (gnus-summary-catchup all quietly nil 'fast)
11368 ;; Select next newsgroup or exit.
11369 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11370 (eq gnus-auto-select-next 'quietly))
11371 (gnus-summary-next-group nil)
11372 (gnus-summary-exit))))
11373
11374 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11375 "Mark all articles in this newsgroup as read, and then exit.
11376 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11377 instead, which marks only unread articles as read."
11378 (interactive "P")
11379 (gnus-summary-catchup-and-exit t quietly))
11380
11381 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11382 "Mark all articles in this group as read and select the next group.
11383 If given a prefix, mark all articles, unread as well as ticked, as
11384 read."
11385 (interactive "P")
11386 (save-excursion
11387 (gnus-summary-catchup all))
11388 (gnus-summary-next-group))
11389
11390 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11391 "Mark all articles in this group as read and select the previous group.
11392 If given a prefix, mark all articles, unread as well as ticked, as
11393 read."
11394 (interactive "P")
11395 (save-excursion
11396 (gnus-summary-catchup all))
11397 (gnus-summary-next-group nil nil t))
11398
11399 ;;;
11400 ;;; with article
11401 ;;;
11402
11403 (defmacro gnus-with-article (article &rest forms)
11404 "Select ARTICLE and perform FORMS in the original article buffer.
11405 Then replace the article with the result."
11406 `(progn
11407 ;; We don't want the article to be marked as read.
11408 (let (gnus-mark-article-hook)
11409 (gnus-summary-select-article t t nil ,article))
11410 (set-buffer gnus-original-article-buffer)
11411 ,@forms
11412 (if (not (gnus-check-backend-function
11413 'request-replace-article (car gnus-article-current)))
11414 (gnus-message 5 "Read-only group; not replacing")
11415 (unless (gnus-request-replace-article
11416 ,article (car gnus-article-current)
11417 (current-buffer) t)
11418 (error "Couldn't replace article")))
11419 ;; The cache and backlog have to be flushed somewhat.
11420 (when gnus-keep-backlog
11421 (gnus-backlog-remove-article
11422 (car gnus-article-current) (cdr gnus-article-current)))
11423 (when gnus-use-cache
11424 (gnus-cache-update-article
11425 (car gnus-article-current) (cdr gnus-article-current)))))
11426
11427 (put 'gnus-with-article 'lisp-indent-function 1)
11428 (put 'gnus-with-article 'edebug-form-spec '(form body))
11429
11430 ;; Thread-based commands.
11431
11432 (defun gnus-summary-articles-in-thread (&optional article)
11433 "Return a list of all articles in the current thread.
11434 If ARTICLE is non-nil, return all articles in the thread that starts
11435 with that article."
11436 (let* ((article (or article (gnus-summary-article-number)))
11437 (data (gnus-data-find-list article))
11438 (top-level (gnus-data-level (car data)))
11439 (top-subject
11440 (cond ((null gnus-thread-operation-ignore-subject)
11441 (gnus-simplify-subject-re
11442 (mail-header-subject (gnus-data-header (car data)))))
11443 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11444 (gnus-simplify-subject-fuzzy
11445 (mail-header-subject (gnus-data-header (car data)))))
11446 (t nil)))
11447 (end-point (save-excursion
11448 (goto-char (gnus-data-pos (car data)))
11449 (if (gnus-summary-go-to-next-thread)
11450 (point) (point-max))))
11451 articles)
11452 (while (and data
11453 (< (gnus-data-pos (car data)) end-point))
11454 (when (or (not top-subject)
11455 (string= top-subject
11456 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11457 (gnus-simplify-subject-fuzzy
11458 (mail-header-subject
11459 (gnus-data-header (car data))))
11460 (gnus-simplify-subject-re
11461 (mail-header-subject
11462 (gnus-data-header (car data)))))))
11463 (push (gnus-data-number (car data)) articles))
11464 (unless (and (setq data (cdr data))
11465 (> (gnus-data-level (car data)) top-level))
11466 (setq data nil)))
11467 ;; Return the list of articles.
11468 (nreverse articles)))
11469
11470 (defun gnus-summary-rethread-current ()
11471 "Rethread the thread the current article is part of."
11472 (interactive)
11473 (let* ((gnus-show-threads t)
11474 (article (gnus-summary-article-number))
11475 (id (mail-header-id (gnus-summary-article-header)))
11476 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11477 (unless id
11478 (error "No article on the current line"))
11479 (gnus-rebuild-thread id)
11480 (gnus-summary-goto-subject article)))
11481
11482 (defun gnus-summary-reparent-thread ()
11483 "Make the current article child of the marked (or previous) article.
11484
11485 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11486 is non-nil or the Subject: of both articles are the same."
11487 (interactive)
11488 (unless (not (gnus-group-read-only-p))
11489 (error "The current newsgroup does not support article editing"))
11490 (unless (<= (length gnus-newsgroup-processable) 1)
11491 (error "No more than one article may be marked"))
11492 (let ((child (gnus-summary-article-number))
11493 ;; First grab the marked article, otherwise one line up.
11494 (parent (if (not (null gnus-newsgroup-processable))
11495 (car gnus-newsgroup-processable)
11496 (save-excursion
11497 (if (eq (forward-line -1) 0)
11498 (gnus-summary-article-number)
11499 (error "Beginning of summary buffer"))))))
11500 (gnus-summary-reparent-children parent (list child))))
11501
11502 (defun gnus-summary-reparent-children (parent children)
11503 "Make PARENT the parent of CHILDREN.
11504 When called interactively, PARENT is the current article and CHILDREN
11505 are the process-marked articles."
11506 (interactive
11507 (list (gnus-summary-article-number)
11508 (gnus-summary-work-articles nil)))
11509 (dolist (child children)
11510 (save-window-excursion
11511 (let ((gnus-article-buffer " *reparent*"))
11512 (unless (not (eq parent child))
11513 (error "An article may not be self-referential"))
11514 (let ((message-id (mail-header-id
11515 (gnus-summary-article-header parent))))
11516 (unless (and message-id (not (equal message-id "")))
11517 (error "No message-id in desired parent"))
11518 (gnus-with-article child
11519 (save-restriction
11520 (goto-char (point-min))
11521 (message-narrow-to-head)
11522 (if (re-search-forward "^References: " nil t)
11523 (progn
11524 (re-search-forward "^[^ \t]" nil t)
11525 (forward-line -1)
11526 (end-of-line)
11527 (insert " " message-id))
11528 (insert "References: " message-id "\n"))))
11529 (set-buffer gnus-summary-buffer)
11530 (gnus-summary-unmark-all-processable)
11531 (gnus-summary-update-article child)
11532 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11533 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11534 (gnus-summary-rethread-current)
11535 (gnus-message 3 "Article %d is now the child of article %d"
11536 child parent))))))
11537
11538 (defun gnus-summary-toggle-threads (&optional arg)
11539 "Toggle showing conversation threads.
11540 If ARG is positive number, turn showing conversation threads on."
11541 (interactive "P")
11542 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11543 (setq gnus-show-threads
11544 (if (null arg) (not gnus-show-threads)
11545 (> (prefix-numeric-value arg) 0)))
11546 (gnus-summary-prepare)
11547 (gnus-summary-goto-subject current)
11548 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11549 (gnus-summary-position-point)))
11550
11551 (eval-and-compile
11552 (if (fboundp 'remove-overlays)
11553 (defalias 'gnus-remove-overlays 'remove-overlays)
11554 (defun gnus-remove-overlays (beg end name val)
11555 "Clear BEG and END of overlays whose property NAME has value VAL.
11556 For compatibility with XEmacs."
11557 (dolist (ov (gnus-overlays-in beg end))
11558 (when (eq (gnus-overlay-get ov name) val)
11559 (gnus-delete-overlay ov))))))
11560
11561 (defun gnus-summary-show-all-threads ()
11562 "Show all threads."
11563 (interactive)
11564 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11565 (gnus-summary-position-point))
11566
11567 (defsubst gnus-summary--inv (p)
11568 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11569
11570 (defun gnus-summary-show-thread ()
11571 "Show thread subtrees.
11572 Returns nil if no thread was there to be shown."
11573 (interactive)
11574 (let* ((orig (point))
11575 (end (point-at-eol))
11576 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11577 ;; Leave point at bol
11578 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11579 (eoi (when end
11580 (if (fboundp 'next-single-char-property-change)
11581 ;; Note: XEmacs version of n-s-c-p-c may return nil
11582 (or (next-single-char-property-change end 'invisible)
11583 (point-max))
11584 (while (progn
11585 (end-of-line 2)
11586 (and (not (eobp))
11587 (eq (get-char-property (point) 'invisible)
11588 'gnus-sum))))
11589 (point)))))
11590 (when eoi
11591 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11592 (goto-char orig)
11593 (gnus-summary-position-point)
11594 eoi)))
11595
11596 (defun gnus-summary-maybe-hide-threads ()
11597 "If requested, hide the threads that should be hidden."
11598 (when (and gnus-show-threads
11599 gnus-thread-hide-subtree)
11600 (gnus-summary-hide-all-threads
11601 (if (or (consp gnus-thread-hide-subtree)
11602 (functionp gnus-thread-hide-subtree))
11603 (gnus-make-predicate gnus-thread-hide-subtree)
11604 nil))))
11605
11606 ;;; Hiding predicates.
11607
11608 (defun gnus-article-unread-p (header)
11609 (memq (mail-header-number header) gnus-newsgroup-unreads))
11610
11611 (defun gnus-article-unseen-p (header)
11612 (memq (mail-header-number header) gnus-newsgroup-unseen))
11613
11614 (defun gnus-map-articles (predicate articles)
11615 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11616 (apply 'gnus-or (mapcar predicate
11617 (mapcar (lambda (number)
11618 (gnus-summary-article-header number))
11619 articles))))
11620
11621 (defun gnus-summary-hide-all-threads (&optional predicate)
11622 "Hide all thread subtrees.
11623 If PREDICATE is supplied, threads that satisfy this predicate
11624 will not be hidden."
11625 (interactive)
11626 (save-excursion
11627 (goto-char (point-min))
11628 (let ((end nil)
11629 (count 0))
11630 (while (not end)
11631 (incf count)
11632 (when (zerop (mod count 1000))
11633 (message "Hiding all threads... %d" count))
11634 (when (or (not predicate)
11635 (gnus-map-articles
11636 predicate (gnus-summary-article-children)))
11637 (gnus-summary-hide-thread))
11638 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11639 (gnus-summary-position-point))
11640
11641 (defun gnus-summary-hide-thread ()
11642 "Hide thread subtrees.
11643 If PREDICATE is supplied, threads that satisfy this predicate
11644 will not be hidden.
11645 Returns nil if no threads were there to be hidden."
11646 (interactive)
11647 (beginning-of-line)
11648 (let ((start (point))
11649 (starteol (line-end-position))
11650 (article (gnus-summary-article-number)))
11651 ;; Go forward until either the buffer ends or the subthread ends.
11652 (when (and (not (eobp))
11653 (or (zerop (gnus-summary-next-thread 1 t))
11654 (goto-char (point-max))))
11655 (if (and (> (point) start)
11656 ;; FIXME: this should actually search for a non-invisible \n.
11657 (search-backward "\n" start t))
11658 (progn
11659 (when (> (point) starteol)
11660 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11661 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11662 (gnus-overlay-put ol 'invisible 'gnus-sum)
11663 (gnus-overlay-put ol 'evaporate t)))
11664 (gnus-summary-goto-subject article)
11665 (when (> start (point))
11666 (message "Hiding the thread moved us backwards, aborting!")
11667 (goto-char (point-max))))
11668 (goto-char start)
11669 nil))))
11670
11671 (defun gnus-summary-go-to-next-thread (&optional previous)
11672 "Go to the same level (or less) next thread.
11673 If PREVIOUS is non-nil, go to previous thread instead.
11674 Return the article number moved to, or nil if moving was impossible."
11675 (let ((level (gnus-summary-thread-level))
11676 (way (if previous -1 1))
11677 (beg (point)))
11678 (forward-line way)
11679 (while (and (not (eobp))
11680 (< level (gnus-summary-thread-level)))
11681 (forward-line way))
11682 (if (eobp)
11683 (progn
11684 (goto-char beg)
11685 nil)
11686 (setq beg (point))
11687 (prog1
11688 (gnus-summary-article-number)
11689 (goto-char beg)))))
11690
11691 (defun gnus-summary-next-thread (n &optional silent)
11692 "Go to the same level next N'th thread.
11693 If N is negative, search backward instead.
11694 Returns the difference between N and the number of skips actually
11695 done.
11696
11697 If SILENT, don't output messages."
11698 (interactive "p")
11699 (let ((backward (< n 0))
11700 (n (abs n)))
11701 (while (and (> n 0)
11702 (gnus-summary-go-to-next-thread backward))
11703 (decf n))
11704 (unless silent
11705 (gnus-summary-position-point))
11706 (when (and (not silent) (/= 0 n))
11707 (gnus-message 7 "No more threads"))
11708 n))
11709
11710 (defun gnus-summary-prev-thread (n)
11711 "Go to the same level previous N'th thread.
11712 Returns the difference between N and the number of skips actually
11713 done."
11714 (interactive "p")
11715 (gnus-summary-next-thread (- n)))
11716
11717 (defun gnus-summary-go-down-thread ()
11718 "Go down one level in the current thread."
11719 (let ((children (gnus-summary-article-children)))
11720 (when children
11721 (gnus-summary-goto-subject (car children)))))
11722
11723 (defun gnus-summary-go-up-thread ()
11724 "Go up one level in the current thread."
11725 (let ((parent (gnus-summary-article-parent)))
11726 (when parent
11727 (gnus-summary-goto-subject parent))))
11728
11729 (defun gnus-summary-down-thread (n)
11730 "Go down thread N steps.
11731 If N is negative, go up instead.
11732 Returns the difference between N and how many steps down that were
11733 taken."
11734 (interactive "p")
11735 (let ((up (< n 0))
11736 (n (abs n)))
11737 (while (and (> n 0)
11738 (if up (gnus-summary-go-up-thread)
11739 (gnus-summary-go-down-thread)))
11740 (setq n (1- n)))
11741 (gnus-summary-position-point)
11742 (when (/= 0 n)
11743 (gnus-message 7 "Can't go further"))
11744 n))
11745
11746 (defun gnus-summary-up-thread (n)
11747 "Go up thread N steps.
11748 If N is negative, go down instead.
11749 Returns the difference between N and how many steps down that were
11750 taken."
11751 (interactive "p")
11752 (gnus-summary-down-thread (- n)))
11753
11754 (defun gnus-summary-top-thread ()
11755 "Go to the top of the thread."
11756 (interactive)
11757 (while (gnus-summary-go-up-thread))
11758 (gnus-summary-article-number))
11759
11760 (defun gnus-summary-expire-thread ()
11761 "Mark articles under current thread as expired."
11762 (interactive)
11763 (gnus-summary-kill-thread 0))
11764
11765 (defun gnus-summary-kill-thread (&optional unmark)
11766 "Mark articles under current thread as read.
11767 If the prefix argument is positive, remove any kinds of marks.
11768 If the prefix argument is zero, mark thread as expired.
11769 If the prefix argument is negative, tick articles instead."
11770 (interactive "P")
11771 (when unmark
11772 (setq unmark (prefix-numeric-value unmark)))
11773 (let ((articles (gnus-summary-articles-in-thread))
11774 (hide (or (null unmark) (= unmark 0))))
11775 (save-excursion
11776 ;; Expand the thread.
11777 (gnus-summary-show-thread)
11778 ;; Mark all the articles.
11779 (while articles
11780 (gnus-summary-goto-subject (car articles))
11781 (cond ((null unmark)
11782 (gnus-summary-mark-article-as-read gnus-killed-mark))
11783 ((> unmark 0)
11784 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11785 ((= unmark 0)
11786 (gnus-summary-mark-article nil gnus-expirable-mark))
11787 (t
11788 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11789 (setq articles (cdr articles))))
11790 ;; Hide killed subtrees when hide is true.
11791 (and hide
11792 gnus-thread-hide-killed
11793 (gnus-summary-hide-thread))
11794 ;; If hide is t, go to next unread subject.
11795 (when hide
11796 ;; Go to next unread subject.
11797 (gnus-summary-next-subject 1 t)))
11798 (gnus-set-mode-line 'summary))
11799
11800 ;; Summary sorting commands
11801
11802 (defun gnus-summary-sort-by-number (&optional reverse)
11803 "Sort the summary buffer by article number.
11804 Argument REVERSE means reverse order."
11805 (interactive "P")
11806 (gnus-summary-sort 'number reverse))
11807
11808 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11809 "Sort the summary buffer by most recent article number.
11810 Argument REVERSE means reverse order."
11811 (interactive "P")
11812 (gnus-summary-sort 'most-recent-number reverse))
11813
11814 (defun gnus-summary-sort-by-random (&optional reverse)
11815 "Randomize the order in the summary buffer.
11816 Argument REVERSE means to randomize in reverse order."
11817 (interactive "P")
11818 (gnus-summary-sort 'random reverse))
11819
11820 (defun gnus-summary-sort-by-author (&optional reverse)
11821 "Sort the summary buffer by author name alphabetically.
11822 If `case-fold-search' is non-nil, case of letters is ignored.
11823 Argument REVERSE means reverse order."
11824 (interactive "P")
11825 (gnus-summary-sort 'author reverse))
11826
11827 (defun gnus-summary-sort-by-recipient (&optional reverse)
11828 "Sort the summary buffer by recipient name alphabetically.
11829 If `case-fold-search' is non-nil, case of letters is ignored.
11830 Argument REVERSE means reverse order."
11831 (interactive "P")
11832 (gnus-summary-sort 'recipient reverse))
11833
11834 (defun gnus-summary-sort-by-subject (&optional reverse)
11835 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11836 If `case-fold-search' is non-nil, case of letters is ignored.
11837 Argument REVERSE means reverse order."
11838 (interactive "P")
11839 (gnus-summary-sort 'subject reverse))
11840
11841 (defun gnus-summary-sort-by-date (&optional reverse)
11842 "Sort the summary buffer by date.
11843 Argument REVERSE means reverse order."
11844 (interactive "P")
11845 (gnus-summary-sort 'date reverse))
11846
11847 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11848 "Sort the summary buffer by most recent date.
11849 Argument REVERSE means reverse order."
11850 (interactive "P")
11851 (gnus-summary-sort 'most-recent-date reverse))
11852
11853 (defun gnus-summary-sort-by-score (&optional reverse)
11854 "Sort the summary buffer by score.
11855 Argument REVERSE means reverse order."
11856 (interactive "P")
11857 (gnus-summary-sort 'score reverse))
11858
11859 (defun gnus-summary-sort-by-lines (&optional reverse)
11860 "Sort the summary buffer by the number of lines.
11861 Argument REVERSE means reverse order."
11862 (interactive "P")
11863 (gnus-summary-sort 'lines reverse))
11864
11865 (defun gnus-summary-sort-by-chars (&optional reverse)
11866 "Sort the summary buffer by article length.
11867 Argument REVERSE means reverse order."
11868 (interactive "P")
11869 (gnus-summary-sort 'chars reverse))
11870
11871 (defun gnus-summary-sort-by-original (&optional reverse)
11872 "Sort the summary buffer using the default sorting method.
11873 Argument REVERSE means reverse order."
11874 (interactive "P")
11875 (let* ((inhibit-read-only t)
11876 (gnus-summary-prepare-hook nil))
11877 ;; We do the sorting by regenerating the threads.
11878 (gnus-summary-prepare)
11879 ;; Hide subthreads if needed.
11880 (gnus-summary-maybe-hide-threads)))
11881
11882 (defun gnus-summary-sort (predicate reverse)
11883 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11884 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11885 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11886 (gnus-thread-sort-functions
11887 (if (not reverse)
11888 thread
11889 `(lambda (t1 t2)
11890 (,thread t2 t1))))
11891 (gnus-sort-gathered-threads-function
11892 gnus-thread-sort-functions)
11893 (gnus-article-sort-functions
11894 (if (not reverse)
11895 article
11896 `(lambda (t1 t2)
11897 (,article t2 t1))))
11898 (inhibit-read-only t)
11899 (gnus-summary-prepare-hook nil))
11900 ;; We do the sorting by regenerating the threads.
11901 (gnus-summary-prepare)
11902 ;; Hide subthreads if needed.
11903 (gnus-summary-maybe-hide-threads)))
11904
11905 ;; Summary saving commands.
11906
11907 (defun gnus-summary-save-article (&optional n not-saved)
11908 "Save the current article using the default saver function.
11909 If N is a positive number, save the N next articles.
11910 If N is a negative number, save the N previous articles.
11911 If N is nil and any articles have been marked with the process mark,
11912 save those articles instead.
11913 The variable `gnus-default-article-saver' specifies the saver function.
11914
11915 If the optional second argument NOT-SAVED is non-nil, articles saved
11916 will not be marked as saved."
11917 (interactive "P")
11918 (require 'gnus-art)
11919 (let* ((articles (gnus-summary-work-articles n))
11920 (save-buffer (save-excursion
11921 (nnheader-set-temp-buffer " *Gnus Save*")))
11922 (num (length articles))
11923 ;; Whether to save decoded articles or raw articles.
11924 (decode (when gnus-article-save-coding-system
11925 (get gnus-default-article-saver :decode)))
11926 ;; When saving many articles in a single file, use the other
11927 ;; function to save articles other than the first one.
11928 (saver2 (get gnus-default-article-saver :function))
11929 (gnus-prompt-before-saving (if saver2
11930 t
11931 gnus-prompt-before-saving))
11932 (gnus-default-article-saver gnus-default-article-saver)
11933 header file)
11934 (dolist (article articles)
11935 (setq header (gnus-summary-article-header article))
11936 (if (not (vectorp header))
11937 ;; This is a pseudo-article.
11938 (if (assq 'name header)
11939 (gnus-copy-file (cdr (assq 'name header)))
11940 (gnus-message 1 "Article %d is unsavable" article))
11941 ;; This is a real article.
11942 (save-window-excursion
11943 (gnus-summary-select-article decode decode nil article)
11944 (gnus-summary-goto-subject article))
11945 (with-current-buffer save-buffer
11946 (erase-buffer)
11947 (insert-buffer-substring (if decode
11948 gnus-article-buffer
11949 gnus-original-article-buffer)))
11950 (setq file (gnus-article-save save-buffer file num))
11951 (gnus-summary-remove-process-mark article)
11952 (unless not-saved
11953 (gnus-summary-set-saved-mark article)))
11954 (when saver2
11955 (setq gnus-default-article-saver saver2
11956 saver2 nil)))
11957 (gnus-kill-buffer save-buffer)
11958 (gnus-summary-position-point)
11959 (gnus-set-mode-line 'summary)
11960 n))
11961
11962 (defun gnus-summary-pipe-output (&optional n sym)
11963 "Pipe the current article to a subprocess.
11964 If N is a positive number, pipe the N next articles.
11965 If N is a negative number, pipe the N previous articles.
11966 If N is nil and any articles have been marked with the process mark,
11967 pipe those articles instead.
11968 The default command to which articles are piped is specified by the
11969 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11970 will be prompted for the command.
11971
11972 The properties `:decode' and `:headers' that are put to the function
11973 symbol `gnus-summary-save-in-pipe' control whether this function
11974 decodes articles and what headers to keep (see the doc string for the
11975 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11976 is neither omitted nor the symbol `r', force including all headers
11977 regardless of the `:headers' property. If it is the symbol `r',
11978 articles that are not decoded and include all headers will be piped
11979 no matter what the properties `:decode' and `:headers' are."
11980 (interactive (gnus-interactive "P\ny"))
11981 (require 'gnus-art)
11982 (let* ((articles (gnus-summary-work-articles n))
11983 (result-buffer "*Shell Command Output*")
11984 (all-headers (not (memq sym '(nil r))))
11985 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11986 (raw (eq sym 'r))
11987 (headers (get 'gnus-summary-save-in-pipe :headers))
11988 command result)
11989 (unless (numberp (car articles))
11990 (error "No article to pipe"))
11991 (setq command (gnus-read-shell-command
11992 (concat "Shell command on "
11993 (if (cdr articles)
11994 (format "these %d articles" (length articles))
11995 "this article")
11996 ": ")
11997 gnus-summary-pipe-output-default-command))
11998 (when (string-equal command "")
11999 (error "A command is required"))
12000 (when all-headers
12001 (put 'gnus-summary-save-in-pipe :headers nil))
12002 (unwind-protect
12003 (while articles
12004 (gnus-summary-goto-subject (pop articles))
12005 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12006 (when (and (get-buffer result-buffer)
12007 (not (zerop (buffer-size (get-buffer result-buffer)))))
12008 (setq result (concat result (with-current-buffer result-buffer
12009 (buffer-string))))))
12010 (put 'gnus-summary-save-in-pipe :headers headers))
12011 (unless (zerop (length result))
12012 (if (with-current-buffer (get-buffer-create result-buffer)
12013 (erase-buffer)
12014 (insert result)
12015 (prog1
12016 (and (= (count-lines (point-min) (point)) 1)
12017 (progn
12018 (end-of-line 0)
12019 (<= (current-column)
12020 (window-width (minibuffer-window)))))
12021 (goto-char (point-min))))
12022 (message "%s" (substring result 0 -1))
12023 (message nil)
12024 (gnus-configure-windows 'pipe)))))
12025
12026 (defun gnus-summary-save-article-mail (&optional arg)
12027 "Append the current article to a Unix mail box file.
12028 If N is a positive number, save the N next articles.
12029 If N is a negative number, save the N previous articles.
12030 If N is nil and any articles have been marked with the process mark,
12031 save those articles instead."
12032 (interactive "P")
12033 (require 'gnus-art)
12034 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12035 (gnus-summary-save-article arg)))
12036
12037 (defun gnus-summary-save-article-rmail (&optional arg)
12038 "Append the current article to an rmail file.
12039 If N is a positive number, save the N next articles.
12040 If N is a negative number, save the N previous articles.
12041 If N is nil and any articles have been marked with the process mark,
12042 save those articles instead."
12043 (interactive "P")
12044 (require 'gnus-art)
12045 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12046 (gnus-summary-save-article arg)))
12047
12048 (defun gnus-summary-save-article-file (&optional arg)
12049 "Append the current article to a file.
12050 If N is a positive number, save the N next articles.
12051 If N is a negative number, save the N previous articles.
12052 If N is nil and any articles have been marked with the process mark,
12053 save those articles instead."
12054 (interactive "P")
12055 (require 'gnus-art)
12056 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12057 (gnus-summary-save-article arg)))
12058
12059 (defun gnus-summary-write-article-file (&optional arg)
12060 "Write the current article to a file, deleting the previous file.
12061 If N is a positive number, save the N next articles.
12062 If N is a negative number, save the N previous articles.
12063 If N is nil and any articles have been marked with the process mark,
12064 save those articles instead."
12065 (interactive "P")
12066 (require 'gnus-art)
12067 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12068 (gnus-summary-save-article arg)))
12069
12070 (defun gnus-summary-save-article-body-file (&optional arg)
12071 "Append the current article body to a file.
12072 If N is a positive number, save the N next articles.
12073 If N is a negative number, save the N previous articles.
12074 If N is nil and any articles have been marked with the process mark,
12075 save those articles instead."
12076 (interactive "P")
12077 (require 'gnus-art)
12078 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12079 (gnus-summary-save-article arg)))
12080
12081 (defun gnus-summary-write-article-body-file (&optional arg)
12082 "Write the current article body to a file, deleting the previous file.
12083 If N is a positive number, save the N next articles.
12084 If N is a negative number, save the N previous articles.
12085 If N is nil and any articles have been marked with the process mark,
12086 save those articles instead."
12087 (interactive "P")
12088 (require 'gnus-art)
12089 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12090 (gnus-summary-save-article arg)))
12091
12092 (defun gnus-summary-muttprint (&optional arg)
12093 "Print the current article using Muttprint.
12094 If N is a positive number, save the N next articles.
12095 If N is a negative number, save the N previous articles.
12096 If N is nil and any articles have been marked with the process mark,
12097 save those articles instead."
12098 (interactive "P")
12099 (require 'gnus-art)
12100 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12101 (gnus-summary-save-article arg t)))
12102
12103 (defun gnus-summary-pipe-message (program)
12104 "Pipe the current article through PROGRAM."
12105 (interactive "sProgram: ")
12106 (gnus-summary-select-article)
12107 (let ((mail-header-separator ""))
12108 (gnus-eval-in-buffer-window gnus-article-buffer
12109 (save-restriction
12110 (widen)
12111 (let ((start (window-start))
12112 (inhibit-read-only t))
12113 (message-pipe-buffer-body program)
12114 (set-window-start (get-buffer-window (current-buffer)) start))))))
12115
12116 (defun gnus-get-split-value (methods)
12117 "Return a value based on the split METHODS."
12118 (let (split-name method result match)
12119 (when methods
12120 (with-current-buffer gnus-original-article-buffer
12121 (save-restriction
12122 (nnheader-narrow-to-headers)
12123 (while (and methods (not split-name))
12124 (goto-char (point-min))
12125 (setq method (pop methods))
12126 (setq match (car method))
12127 (when (cond
12128 ((stringp match)
12129 ;; Regular expression.
12130 (ignore-errors
12131 (re-search-forward match nil t)))
12132 ((functionp match)
12133 ;; Function.
12134 (save-restriction
12135 (widen)
12136 (setq result (funcall match gnus-newsgroup-name))))
12137 ((consp match)
12138 ;; Form.
12139 (save-restriction
12140 (widen)
12141 (setq result (eval match)))))
12142 (setq split-name (cdr method))
12143 (cond ((stringp result)
12144 (push (expand-file-name
12145 result gnus-article-save-directory)
12146 split-name))
12147 ((consp result)
12148 (setq split-name (append result split-name)))))))))
12149 (nreverse split-name)))
12150
12151 (defun gnus-valid-move-group-p (group)
12152 (and (symbolp group)
12153 (boundp group)
12154 (symbol-name group)
12155 (symbol-value group)
12156 (gnus-get-function (gnus-find-method-for-group
12157 (symbol-name group)) 'request-accept-article t)))
12158
12159 (defun gnus-read-move-group-name (prompt default articles prefix)
12160 "Read a group name."
12161 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12162 (minibuffer-confirm-incomplete nil) ; XEmacs
12163 (prom
12164 (format "%s %s to"
12165 prompt
12166 (if (> (length articles) 1)
12167 (format "these %d articles" (length articles))
12168 "this article")))
12169 (to-newsgroup
12170 (cond
12171 ((null split-name)
12172 (gnus-group-completing-read
12173 prom
12174 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12175 nil prefix nil default))
12176 ((= 1 (length split-name))
12177 (gnus-group-completing-read
12178 prom
12179 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12180 nil prefix 'gnus-group-history (car split-name)))
12181 (t
12182 (gnus-completing-read
12183 prom (nreverse split-name) nil nil 'gnus-group-history))))
12184 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12185 encoded)
12186 (when to-newsgroup
12187 (if (or (string= to-newsgroup "")
12188 (string= to-newsgroup prefix))
12189 (setq to-newsgroup default))
12190 (unless to-newsgroup
12191 (error "No group name entered"))
12192 (setq encoded (mm-encode-coding-string
12193 to-newsgroup
12194 (gnus-group-name-charset to-method to-newsgroup)))
12195 (or (gnus-active encoded)
12196 (gnus-activate-group encoded nil nil to-method)
12197 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12198 to-newsgroup))
12199 (or (and (gnus-request-create-group encoded to-method)
12200 (gnus-activate-group encoded nil nil to-method)
12201 (gnus-subscribe-group encoded))
12202 (error "Couldn't create group %s" to-newsgroup)))
12203 (error "No such group: %s" to-newsgroup))
12204 encoded)))
12205
12206 (defvar gnus-summary-save-parts-counter)
12207 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12208
12209 (defun gnus-summary-save-parts (type dir n &optional reverse)
12210 "Save parts matching TYPE to DIR.
12211 If REVERSE, save parts that do not match TYPE."
12212 (interactive
12213 (list (read-string "Save parts of type: "
12214 (or (car gnus-summary-save-parts-type-history)
12215 gnus-summary-save-parts-default-mime)
12216 'gnus-summary-save-parts-type-history)
12217 (setq gnus-summary-save-parts-last-directory
12218 (read-directory-name "Save to directory: "
12219 gnus-summary-save-parts-last-directory
12220 nil t))
12221 current-prefix-arg))
12222 (gnus-summary-iterate n
12223 (let ((gnus-display-mime-function nil)
12224 gnus-article-prepare-hook
12225 gnus-article-decode-hook
12226 gnus-display-mime-function
12227 gnus-break-pages
12228 (gnus-inhibit-treatment t))
12229 (gnus-summary-select-article))
12230 (with-current-buffer gnus-article-buffer
12231 (let ((handles (or gnus-article-mime-handles
12232 (mm-dissect-buffer nil gnus-article-loose-mime)
12233 (and gnus-article-emulate-mime
12234 (mm-uu-dissect))))
12235 (gnus-summary-save-parts-counter 1))
12236 (when handles
12237 (gnus-summary-save-parts-1 type dir handles reverse)
12238 (unless gnus-article-mime-handles ;; Don't destroy this case.
12239 (mm-destroy-parts handles)))))))
12240
12241 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12242 (if (stringp (car handle))
12243 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12244 (cdr handle))
12245 (when (if reverse
12246 (not (string-match type (mm-handle-media-type handle)))
12247 (string-match type (mm-handle-media-type handle)))
12248 (let ((file (expand-file-name
12249 (gnus-map-function
12250 mm-file-name-rewrite-functions
12251 (file-name-nondirectory
12252 (or
12253 (mm-handle-filename handle)
12254 (format "%s.%d.%d" gnus-newsgroup-name
12255 (cdr gnus-article-current)
12256 gnus-summary-save-parts-counter))))
12257 dir)))
12258 (incf gnus-summary-save-parts-counter)
12259 (unless (file-exists-p file)
12260 (mm-save-part-to-file handle file))))))
12261
12262 ;; Summary extract commands
12263
12264 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12265 (let ((inhibit-read-only t)
12266 (article (gnus-summary-article-number))
12267 after-article b e)
12268 (unless (gnus-summary-goto-subject article)
12269 (error "No such article: %d" article))
12270 (gnus-summary-position-point)
12271 ;; If all commands are to be bunched up on one line, we collect
12272 ;; them here.
12273 (unless gnus-view-pseudos-separately
12274 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12275 files action)
12276 (while ps
12277 (setq action (cdr (assq 'action (car ps))))
12278 (setq files (list (cdr (assq 'name (car ps)))))
12279 (while (and ps (cdr ps)
12280 (string= (or action "1")
12281 (or (cdr (assq 'action (cadr ps))) "2")))
12282 (push (cdr (assq 'name (cadr ps))) files)
12283 (setcdr ps (cddr ps)))
12284 (when files
12285 (when (not (string-match "%s" action))
12286 (push " " files))
12287 (push " " files)
12288 (when (assq 'execute (car ps))
12289 (setcdr (assq 'execute (car ps))
12290 (funcall (if (string-match "%s" action)
12291 'format 'concat)
12292 action
12293 (mapconcat
12294 (lambda (f)
12295 (if (equal f " ")
12296 f
12297 (shell-quote-argument f)))
12298 files " ")))))
12299 (setq ps (cdr ps)))))
12300 (if (and gnus-view-pseudos (not not-view))
12301 (while pslist
12302 (when (assq 'execute (car pslist))
12303 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12304 (eq gnus-view-pseudos 'not-confirm)))
12305 (setq pslist (cdr pslist)))
12306 (save-excursion
12307 (while pslist
12308 (setq after-article (or (cdr (assq 'article (car pslist)))
12309 (gnus-summary-article-number)))
12310 (gnus-summary-goto-subject after-article)
12311 (forward-line 1)
12312 (setq b (point))
12313 (insert " " (file-name-nondirectory
12314 (cdr (assq 'name (car pslist))))
12315 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12316 (setq e (point))
12317 (forward-line -1) ; back to `b'
12318 (gnus-add-text-properties
12319 b (1- e) (list 'gnus-number gnus-reffed-article-number
12320 gnus-mouse-face-prop gnus-mouse-face))
12321 (gnus-data-enter
12322 after-article gnus-reffed-article-number
12323 gnus-unread-mark b (car pslist) 0 (- e b))
12324 (setq gnus-newsgroup-unreads
12325 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12326 gnus-reffed-article-number))
12327 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12328 (setq pslist (cdr pslist)))))))
12329
12330 (defun gnus-pseudos< (p1 p2)
12331 (let ((c1 (cdr (assq 'action p1)))
12332 (c2 (cdr (assq 'action p2))))
12333 (and c1 c2 (string< c1 c2))))
12334
12335 (defun gnus-request-pseudo-article (props)
12336 (cond ((assq 'execute props)
12337 (gnus-execute-command (cdr (assq 'execute props)))))
12338 (let ((gnus-current-article (gnus-summary-article-number)))
12339 (gnus-run-hooks 'gnus-mark-article-hook)))
12340
12341 (defun gnus-execute-command (command &optional automatic)
12342 (save-excursion
12343 (gnus-article-setup-buffer)
12344 (set-buffer gnus-article-buffer)
12345 (setq buffer-read-only nil)
12346 (let ((command (if automatic command
12347 (read-string "Command: " (cons command 0)))))
12348 (erase-buffer)
12349 (insert "$ " command "\n\n")
12350 (if gnus-view-pseudo-asynchronously
12351 (start-process "gnus-execute" (current-buffer) shell-file-name
12352 shell-command-switch command)
12353 (call-process shell-file-name nil t nil
12354 shell-command-switch command)))))
12355
12356 ;; Summary kill commands.
12357
12358 (defun gnus-summary-edit-global-kill (article)
12359 "Edit the \"global\" kill file."
12360 (interactive (list (gnus-summary-article-number)))
12361 (gnus-group-edit-global-kill article))
12362
12363 (defun gnus-summary-edit-local-kill ()
12364 "Edit a local kill file applied to the current newsgroup."
12365 (interactive)
12366 (setq gnus-current-headers (gnus-summary-article-header))
12367 (gnus-group-edit-local-kill
12368 (gnus-summary-article-number) gnus-newsgroup-name))
12369
12370 ;;; Header reading.
12371
12372 (defun gnus-read-header (id &optional header)
12373 "Read the headers of article ID and enter them into the Gnus system."
12374 (let ((group gnus-newsgroup-name)
12375 (gnus-override-method
12376 (or
12377 gnus-override-method
12378 (and (gnus-news-group-p gnus-newsgroup-name)
12379 (car (gnus-refer-article-methods)))))
12380 where)
12381 ;; First we check to see whether the header in question is already
12382 ;; fetched.
12383 (if (stringp id)
12384 ;; This is a Message-ID.
12385 (setq header (or header (gnus-id-to-header id)))
12386 ;; This is an article number.
12387 (setq header (or header (gnus-summary-article-header id))))
12388 (if (and header
12389 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12390 ;; We have found the header.
12391 header
12392 ;; We have to really fetch the header to this article.
12393 (with-current-buffer nntp-server-buffer
12394 (when (setq where (gnus-request-head id group))
12395 (nnheader-fold-continuation-lines)
12396 (goto-char (point-max))
12397 (insert ".\n")
12398 (goto-char (point-min))
12399 (insert "211 ")
12400 (princ (cond
12401 ((numberp id) id)
12402 ((cdr where) (cdr where))
12403 (header (mail-header-number header))
12404 (t gnus-reffed-article-number))
12405 (current-buffer))
12406 (insert " Article retrieved.\n"))
12407 (if (or (not where)
12408 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12409 () ; Malformed head.
12410 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12411 (when (and (bound-and-true-p gnus-registry-enabled)
12412 (not (gnus-ephemeral-group-p (car where))))
12413 (gnus-registry-handle-action
12414 (mail-header-id header) nil
12415 (gnus-group-prefixed-name (car where) gnus-override-method)
12416 (mail-header-subject header)
12417 (mail-header-from header)))
12418 (when (and (stringp id)
12419 (or
12420 (not (string= (gnus-group-real-name group)
12421 (car where)))
12422 (not (gnus-server-equal gnus-override-method
12423 (gnus-group-method group)))))
12424 ;; If we fetched by Message-ID and the article came from
12425 ;; a different group (or server), we fudge some bogus
12426 ;; article numbers for this article.
12427 (mail-header-set-number header gnus-reffed-article-number))
12428 (with-current-buffer gnus-summary-buffer
12429 (decf gnus-reffed-article-number)
12430 (gnus-remove-header (mail-header-number header))
12431 (push header gnus-newsgroup-headers)
12432 (setq gnus-current-headers header)
12433 (push (mail-header-number header) gnus-newsgroup-limit)))
12434 header)))))
12435
12436 (defun gnus-remove-header (number)
12437 "Remove header NUMBER from `gnus-newsgroup-headers'."
12438 (if (and gnus-newsgroup-headers
12439 (= number (mail-header-number (car gnus-newsgroup-headers))))
12440 (pop gnus-newsgroup-headers)
12441 (let ((headers gnus-newsgroup-headers))
12442 (while (and (cdr headers)
12443 (not (= number (mail-header-number (cadr headers)))))
12444 (pop headers))
12445 (when (cdr headers)
12446 (setcdr headers (cddr headers))))))
12447
12448 ;;;
12449 ;;; summary highlights
12450 ;;;
12451
12452 (defun gnus-highlight-selected-summary ()
12453 "Highlight selected article in summary buffer."
12454 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12455 (when gnus-summary-selected-face
12456 (save-excursion
12457 (let* ((beg (point-at-bol))
12458 (end (point-at-eol))
12459 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12460 (from (if (get-text-property beg gnus-mouse-face-prop)
12461 beg
12462 (or (next-single-property-change
12463 beg gnus-mouse-face-prop nil end)
12464 beg)))
12465 (to
12466 (if (= from end)
12467 (- from 2)
12468 (or (next-single-property-change
12469 from gnus-mouse-face-prop nil end)
12470 end))))
12471 ;; If no mouse-face prop on line we will have to = from = end,
12472 ;; so we highlight the entire line instead.
12473 (when (= (+ to 2) from)
12474 (setq from beg)
12475 (setq to end))
12476 (if gnus-newsgroup-selected-overlay
12477 ;; Move old overlay.
12478 (gnus-move-overlay
12479 gnus-newsgroup-selected-overlay from to (current-buffer))
12480 ;; Create new overlay.
12481 (gnus-overlay-put
12482 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12483 'face gnus-summary-selected-face))))))
12484
12485 (defvar gnus-summary-highlight-line-cached nil)
12486 (defvar gnus-summary-highlight-line-trigger nil)
12487
12488 (defun gnus-summary-highlight-line-0 ()
12489 (if (and (eq gnus-summary-highlight-line-trigger
12490 gnus-summary-highlight)
12491 gnus-summary-highlight-line-cached)
12492 gnus-summary-highlight-line-cached
12493 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12494 gnus-summary-highlight-line-cached
12495 (let* ((cond (list 'cond))
12496 (c cond)
12497 (list gnus-summary-highlight))
12498 (while list
12499 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12500 nil))
12501 (setq c (cdr c)
12502 list (cdr list)))
12503 (gnus-byte-compile (list 'lambda nil cond))))))
12504
12505 (defun gnus-summary-highlight-line ()
12506 "Highlight current line according to `gnus-summary-highlight'."
12507 (let* ((beg (point-at-bol))
12508 (article (or (gnus-summary-article-number) gnus-current-article))
12509 (score (or (cdr (assq article
12510 gnus-newsgroup-scored))
12511 gnus-summary-default-score 0))
12512 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12513 (inhibit-read-only t)
12514 (default gnus-summary-default-score)
12515 (default-high gnus-summary-default-high-score)
12516 (default-low gnus-summary-default-low-score)
12517 (uncached (and gnus-summary-use-undownloaded-faces
12518 (memq article gnus-newsgroup-undownloaded)
12519 (not (memq article gnus-newsgroup-cached)))))
12520 (let ((face (funcall (gnus-summary-highlight-line-0))))
12521 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12522 (gnus-put-text-property-excluding-characters-with-faces
12523 beg (point-at-eol) 'face
12524 (setq face (if (boundp face) (symbol-value face) face)))
12525 (when gnus-summary-highlight-line-function
12526 (funcall gnus-summary-highlight-line-function article face))))))
12527
12528 (defun gnus-update-read-articles (group unread &optional compute)
12529 "Update the list of read articles in GROUP.
12530 UNREAD is a sorted list."
12531 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12532 (info (gnus-get-info group))
12533 (prev 1)
12534 read)
12535 (if (or (not info) (not active))
12536 ;; There is no info on this group if it was, in fact,
12537 ;; killed. Gnus stores no information on killed groups, so
12538 ;; there's nothing to be done.
12539 ;; One could store the information somewhere temporarily,
12540 ;; perhaps... Hmmm...
12541 ()
12542 ;; Remove any negative articles numbers.
12543 (while (and unread (< (car unread) 0))
12544 (setq unread (cdr unread)))
12545 ;; Remove any expired article numbers
12546 (while (and unread (< (car unread) (car active)))
12547 (setq unread (cdr unread)))
12548 ;; Compute the ranges of read articles by looking at the list of
12549 ;; unread articles.
12550 (while unread
12551 (when (/= (car unread) prev)
12552 (push (if (= prev (1- (car unread))) prev
12553 (cons prev (1- (car unread))))
12554 read))
12555 (setq prev (1+ (car unread)))
12556 (setq unread (cdr unread)))
12557 (when (<= prev (cdr active))
12558 (push (cons prev (cdr active)) read))
12559 (setq read (if (> (length read) 1) (nreverse read) read))
12560 (if compute
12561 read
12562 (save-excursion
12563 (let (setmarkundo)
12564 ;; Propagate the read marks to the backend.
12565 (when (and (gnus-method-option-p
12566 (gnus-find-method-for-group group)
12567 'server-marks)
12568 (gnus-check-backend-function 'request-set-mark group))
12569 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12570 (add (gnus-remove-from-range read (gnus-info-read info))))
12571 (when (or add del)
12572 (unless (gnus-check-group group)
12573 (error "Can't open server for %s" group))
12574 (gnus-request-set-mark
12575 group (delq nil (list (if add (list add 'add '(read)))
12576 (if del (list del 'del '(read))))))
12577 (setq setmarkundo
12578 `(gnus-request-set-mark
12579 ,group
12580 ',(delq nil (list
12581 (if del (list del 'add '(read)))
12582 (if add (list add 'del '(read))))))))))
12583 (set-buffer gnus-group-buffer)
12584 (gnus-undo-register
12585 `(progn
12586 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12587 (gnus-info-set-read ',info ',(gnus-info-read info))
12588 (gnus-get-unread-articles-in-group ',info
12589 (gnus-active ,group))
12590 (gnus-group-update-group ,group t)
12591 ,setmarkundo))))
12592 ;; Enter this list into the group info.
12593 (gnus-info-set-read info read)
12594 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12595 (gnus-get-unread-articles-in-group info (gnus-active group))
12596 t))))
12597
12598 (defun gnus-offer-save-summaries ()
12599 "Offer to save all active summary buffers."
12600 (let (buffers)
12601 ;; Go through all buffers and find all summaries.
12602 (dolist (buffer (buffer-list))
12603 (when (and (setq buffer (buffer-name buffer))
12604 (string-match "Summary" buffer)
12605 (with-current-buffer buffer
12606 ;; We check that this is, indeed, a summary buffer.
12607 (and (eq major-mode 'gnus-summary-mode)
12608 ;; Also make sure this isn't bogus.
12609 gnus-newsgroup-prepared
12610 ;; Also make sure that this isn't a
12611 ;; dead summary buffer.
12612 (not gnus-dead-summary-mode))))
12613 (push buffer buffers)))
12614 ;; Go through all these summary buffers and offer to save them.
12615 (when buffers
12616 (save-excursion
12617 (if (eq gnus-interactive-exit 'quiet)
12618 (dolist (buffer buffers)
12619 (switch-to-buffer buffer)
12620 (gnus-summary-exit))
12621 (map-y-or-n-p
12622 "Update summary buffer %s? "
12623 (lambda (buf)
12624 (switch-to-buffer buf)
12625 (gnus-summary-exit))
12626 buffers))))))
12627
12628 (defun gnus-summary-setup-default-charset ()
12629 "Setup newsgroup default charset."
12630 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12631 (setq gnus-newsgroup-charset nil)
12632 (let* ((ignored-charsets
12633 (or gnus-newsgroup-ephemeral-ignored-charsets
12634 (append
12635 (and gnus-newsgroup-name
12636 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12637 gnus-newsgroup-ignored-charsets))))
12638 (setq gnus-newsgroup-charset
12639 (or gnus-newsgroup-ephemeral-charset
12640 (and gnus-newsgroup-name
12641 (gnus-parameter-charset gnus-newsgroup-name))
12642 gnus-default-charset))
12643 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12644 ignored-charsets))))
12645
12646 ;;;
12647 ;;; Mime Commands
12648 ;;;
12649
12650 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12651 "Display the current article buffer fully MIME-buttonized.
12652 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12653 treated as multipart/mixed."
12654 (interactive "P")
12655 (require 'gnus-art)
12656 (let ((gnus-unbuttonized-mime-types nil)
12657 (gnus-mime-display-multipart-as-mixed show-all-parts))
12658 (gnus-summary-show-article)))
12659
12660 (defun gnus-summary-repair-multipart (article)
12661 "Add a Content-Type header to a multipart article without one."
12662 (interactive (list (gnus-summary-article-number)))
12663 (gnus-with-article article
12664 (message-narrow-to-head)
12665 (message-remove-header "Mime-Version")
12666 (goto-char (point-max))
12667 (insert "Mime-Version: 1.0\n")
12668 (widen)
12669 (when (search-forward "\n--" nil t)
12670 (let ((separator (buffer-substring (point) (point-at-eol))))
12671 (message-narrow-to-head)
12672 (message-remove-header "Content-Type")
12673 (goto-char (point-max))
12674 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12675 separator))
12676 (widen))))
12677 (let (gnus-mark-article-hook)
12678 (gnus-summary-select-article t t nil article)))
12679
12680 (defun gnus-summary-toggle-display-buttonized ()
12681 "Toggle the buttonizing of the article buffer."
12682 (interactive)
12683 (require 'gnus-art)
12684 (if (setq gnus-inhibit-mime-unbuttonizing
12685 (not gnus-inhibit-mime-unbuttonizing))
12686 (let ((gnus-unbuttonized-mime-types nil))
12687 (gnus-summary-show-article))
12688 (gnus-summary-show-article)))
12689
12690 ;;;
12691 ;;; Generic summary marking commands
12692 ;;;
12693
12694 (defvar gnus-summary-marking-alist
12695 '((read gnus-del-mark "d")
12696 (unread gnus-unread-mark "u")
12697 (ticked gnus-ticked-mark "!")
12698 (dormant gnus-dormant-mark "?")
12699 (expirable gnus-expirable-mark "e"))
12700 "An alist of names/marks/keystrokes.")
12701
12702 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12703 (defvar gnus-summary-mark-map)
12704
12705 (defun gnus-summary-make-all-marking-commands ()
12706 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12707 (dolist (elem gnus-summary-marking-alist)
12708 (apply 'gnus-summary-make-marking-command elem)))
12709
12710 (defun gnus-summary-make-marking-command (name mark keystroke)
12711 (let ((map (make-sparse-keymap)))
12712 (define-key gnus-summary-generic-mark-map keystroke map)
12713 (dolist (lway `((next "next" next nil "n")
12714 (next-unread "next unread" next t "N")
12715 (prev "previous" prev nil "p")
12716 (prev-unread "previous unread" prev t "P")
12717 (nomove "" nil nil ,keystroke)))
12718 (let ((func (gnus-summary-make-marking-command-1
12719 mark (car lway) lway name)))
12720 (setq func (eval func))
12721 (define-key map (nth 4 lway) func)))))
12722
12723 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12724 `(defun ,(intern
12725 (format "gnus-summary-put-mark-as-%s%s"
12726 name (if (eq way 'nomove)
12727 ""
12728 (concat "-" (symbol-name way)))))
12729 (n)
12730 ,(format
12731 "Mark the current article as %s%s.
12732 If N, the prefix, then repeat N times.
12733 If N is negative, move in reverse order.
12734 The difference between N and the actual number of articles marked is
12735 returned."
12736 name (cadr lway))
12737 (interactive "p")
12738 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12739
12740 (defun gnus-summary-generic-mark (n mark move unread)
12741 "Mark N articles with MARK."
12742 (unless (eq major-mode 'gnus-summary-mode)
12743 (error "This command can only be used in the summary buffer"))
12744 (gnus-summary-show-thread)
12745 (let ((nummove
12746 (cond
12747 ((eq move 'next) 1)
12748 ((eq move 'prev) -1)
12749 (t 0))))
12750 (if (zerop nummove)
12751 (setq n 1)
12752 (when (< n 0)
12753 (setq n (abs n)
12754 nummove (* -1 nummove))))
12755 (while (and (> n 0)
12756 (gnus-summary-mark-article nil mark)
12757 (zerop (gnus-summary-next-subject nummove unread t)))
12758 (setq n (1- n)))
12759 (when (/= 0 n)
12760 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12761 (gnus-summary-recenter)
12762 (gnus-summary-position-point)
12763 (gnus-set-mode-line 'summary)
12764 n))
12765
12766 (defun gnus-summary-insert-articles (articles)
12767 (when (setq articles
12768 (gnus-sorted-difference articles
12769 (mapcar (lambda (h)
12770 (mail-header-number h))
12771 gnus-newsgroup-headers)))
12772 (setq gnus-newsgroup-headers
12773 (gnus-merge 'list
12774 gnus-newsgroup-headers
12775 (gnus-fetch-headers articles)
12776 'gnus-article-sort-by-number))
12777 (setq gnus-newsgroup-articles
12778 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12779 ;; Suppress duplicates?
12780 (when gnus-suppress-duplicates
12781 (gnus-dup-suppress-articles))
12782
12783 (if (and gnus-fetch-old-headers
12784 (eq gnus-headers-retrieved-by 'nov))
12785 ;; We might want to build some more threads first.
12786 (if (eq gnus-fetch-old-headers 'invisible)
12787 (gnus-build-all-threads)
12788 (gnus-build-old-threads))
12789 ;; Mark the inserted articles that are unread as unread.
12790 (setq gnus-newsgroup-unreads
12791 (gnus-sorted-nunion
12792 gnus-newsgroup-unreads
12793 (gnus-sorted-nintersection
12794 (gnus-list-of-unread-articles gnus-newsgroup-name)
12795 articles)))
12796 ;; Mark the inserted articles as selected so that the information
12797 ;; of the marks having been changed by a user may be updated when
12798 ;; exiting this group. See `gnus-summary-update-info'.
12799 (dolist (art articles)
12800 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12801 ;; Let the Gnus agent mark articles as read.
12802 (when gnus-agent
12803 (gnus-agent-get-undownloaded-list))
12804 ;; Remove list identifiers from subject
12805 (gnus-summary-remove-list-identifiers)
12806 ;; First and last article in this newsgroup.
12807 (when gnus-newsgroup-headers
12808 (setq gnus-newsgroup-begin
12809 (mail-header-number (car gnus-newsgroup-headers))
12810 gnus-newsgroup-end
12811 (mail-header-number
12812 (gnus-last-element gnus-newsgroup-headers))))
12813 (when gnus-use-scoring
12814 (gnus-possibly-score-headers))))
12815
12816 (defun gnus-summary-insert-old-articles (&optional all)
12817 "Insert all old articles in this group.
12818 If ALL is non-nil, already read articles become readable.
12819 If ALL is a number, fetch this number of articles."
12820 (interactive "P")
12821 (prog1
12822 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12823 older len)
12824 (setq older
12825 ;; Some nntp servers lie about their active range. When
12826 ;; this happens, the active range can be in the millions.
12827 ;; Use a compressed range to avoid creating a huge list.
12828 (gnus-range-difference (list gnus-newsgroup-active) old))
12829 (setq len (gnus-range-length older))
12830 (cond
12831 ((null older) nil)
12832 ((numberp all)
12833 (if (< all len)
12834 (let ((older-range (nreverse older)))
12835 (setq older nil)
12836
12837 (while (> all 0)
12838 (let* ((r (pop older-range))
12839 (min (if (numberp r) r (car r)))
12840 (max (if (numberp r) r (cdr r))))
12841 (while (and (<= min max)
12842 (> all 0))
12843 (push max older)
12844 (setq all (1- all)
12845 max (1- max))))))
12846 (setq older (gnus-uncompress-range older))))
12847 (all
12848 (setq older (gnus-uncompress-range older)))
12849 (t
12850 (when (and (numberp gnus-large-newsgroup)
12851 (> len gnus-large-newsgroup))
12852 (let* ((cursor-in-echo-area nil)
12853 (initial (gnus-parameter-large-newsgroup-initial
12854 gnus-newsgroup-name))
12855 (input
12856 (read-string
12857 (format
12858 "How many articles from %s (%s %d): "
12859 (gnus-group-decoded-name gnus-newsgroup-name)
12860 (if initial "max" "default")
12861 len)
12862 nil nil
12863 (and initial
12864 (number-to-string initial)))))
12865 (unless (string-match "^[ \t]*$" input)
12866 (setq all (string-to-number input))
12867 (if (< all len)
12868 (let ((older-range (nreverse older)))
12869 (setq older nil)
12870
12871 (while (> all 0)
12872 (let* ((r (pop older-range))
12873 (min (if (numberp r) r (car r)))
12874 (max (if (numberp r) r (cdr r))))
12875 (while (and (<= min max)
12876 (> all 0))
12877 (push max older)
12878 (setq all (1- all)
12879 max (1- max))))))))))
12880 (setq older (gnus-uncompress-range older))))
12881 (if (not older)
12882 (message "No old news.")
12883 (gnus-summary-insert-articles older)
12884 (gnus-summary-limit (gnus-sorted-nunion old older))))
12885 (gnus-summary-position-point)))
12886
12887 (defun gnus-summary-insert-new-articles ()
12888 "Insert all new articles in this group."
12889 (interactive)
12890 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12891 (old-high gnus-newsgroup-highest)
12892 (nnmail-fetched-sources (list t))
12893 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12894 i new)
12895 (unless new-active
12896 (error "Couldn't fetch new data"))
12897 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12898 (setq i (cdr gnus-newsgroup-active)
12899 gnus-newsgroup-highest i)
12900 (while (> i old-high)
12901 (push i new)
12902 (decf i))
12903 (if (not new)
12904 (message "No gnus is bad news")
12905 (gnus-summary-insert-articles new)
12906 (setq gnus-newsgroup-unreads
12907 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12908 (gnus-summary-limit (gnus-sorted-nunion old new))))
12909 (gnus-summary-position-point))
12910
12911 ;;; Bookmark support for Gnus.
12912 (declare-function bookmark-make-record-default
12913 "bookmark" (&optional no-file no-context posn))
12914 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12915 (declare-function bookmark-default-handler "bookmark" (bmk))
12916 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12917 (defvar bookmark-yank-point)
12918 (defvar bookmark-current-buffer)
12919
12920 (defun gnus-summary-bookmark-make-record ()
12921 "Make a bookmark entry for a Gnus summary buffer."
12922 (let (pos buf)
12923 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12924 (save-restriction ; FIXME is it necessary to widen?
12925 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12926 (setq buf "art") ; We are recording bookmark from article buffer.
12927 (setq bookmark-yank-point (point))
12928 (setq bookmark-current-buffer (current-buffer))
12929 (gnus-article-show-summary)) ; Go back in summary buffer.
12930 ;; We are now recording bookmark from summary buffer.
12931 (unless buf (setq buf "sum"))
12932 (let* ((subject (elt (gnus-summary-article-header) 1))
12933 (grp (car gnus-article-current))
12934 (art (cdr gnus-article-current))
12935 (head (gnus-summary-article-header art))
12936 (id (mail-header-id head)))
12937 `(,subject
12938 ,@(condition-case nil
12939 (bookmark-make-record-default 'no-file 'no-context pos)
12940 (wrong-number-of-arguments
12941 (bookmark-make-record-default 'point-only)))
12942 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12943 (group . ,grp) (article . ,art)
12944 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12945
12946 ;;;###autoload
12947 (defun gnus-summary-bookmark-jump (bookmark)
12948 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12949 BOOKMARK is a bookmark name or a bookmark record."
12950 (let ((group (bookmark-prop-get bookmark 'group))
12951 (article (bookmark-prop-get bookmark 'article))
12952 (id (bookmark-prop-get bookmark 'message-id))
12953 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12954 (gnus-fetch-group group (list article))
12955 (gnus-summary-insert-cached-articles)
12956 (gnus-summary-goto-article id nil 'force)
12957 ;; FIXME we have to wait article buffer is ready (only large buffer)
12958 ;; Is there a better solution to know that?
12959 ;; If we don't wait `bookmark-default-handler' will have no chance
12960 ;; to set position. However there is no error, just wrong pos.
12961 (sit-for 1)
12962 (when (string= buf "Gnus-art")
12963 (other-window 1))
12964 (bookmark-default-handler
12965 `(""
12966 (buffer . ,(current-buffer))
12967 . ,(bookmark-get-bookmark-record bookmark)))))
12968
12969 (gnus-summary-make-all-marking-commands)
12970
12971 (gnus-ems-redefine)
12972
12973 (provide 'gnus-sum)
12974
12975 (run-hooks 'gnus-sum-load-hook)
12976
12977 ;; Local Variables:
12978 ;; coding: iso-8859-1
12979 ;; End:
12980
12981 ;;; gnus-sum.el ends here