]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Merge from emacs-24
[gnu-emacs] / 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 [?\S-\ ] gnus-summary-prev-page
1823 "\177" gnus-summary-prev-page
1824 [delete] gnus-summary-prev-page
1825 [backspace] gnus-summary-prev-page
1826 "\r" gnus-summary-scroll-up
1827 "\M-\r" gnus-summary-scroll-down
1828 "n" gnus-summary-next-unread-article
1829 "p" gnus-summary-prev-unread-article
1830 "N" gnus-summary-next-article
1831 "P" gnus-summary-prev-article
1832 "\M-\C-n" gnus-summary-next-same-subject
1833 "\M-\C-p" gnus-summary-prev-same-subject
1834 "\M-n" gnus-summary-next-unread-subject
1835 "\M-p" gnus-summary-prev-unread-subject
1836 "." gnus-summary-first-unread-article
1837 "," gnus-summary-best-unread-article
1838 "\M-s" gnus-summary-search-article-forward
1839 "\M-r" gnus-summary-search-article-backward
1840 "\M-S" gnus-summary-repeat-search-article-forward
1841 "\M-R" gnus-summary-repeat-search-article-backward
1842 "<" gnus-summary-beginning-of-article
1843 ">" gnus-summary-end-of-article
1844 "j" gnus-summary-goto-article
1845 "^" gnus-summary-refer-parent-article
1846 "\M-^" gnus-summary-refer-article
1847 "u" gnus-summary-tick-article-forward
1848 "!" gnus-summary-tick-article-forward
1849 "U" gnus-summary-tick-article-backward
1850 "d" gnus-summary-mark-as-read-forward
1851 "D" gnus-summary-mark-as-read-backward
1852 "E" gnus-summary-mark-as-expirable
1853 "\M-u" gnus-summary-clear-mark-forward
1854 "\M-U" gnus-summary-clear-mark-backward
1855 "k" gnus-summary-kill-same-subject-and-select
1856 "\C-k" gnus-summary-kill-same-subject
1857 "\M-\C-k" gnus-summary-kill-thread
1858 "\M-\C-l" gnus-summary-lower-thread
1859 "e" gnus-summary-edit-article
1860 "#" gnus-summary-mark-as-processable
1861 "\M-#" gnus-summary-unmark-as-processable
1862 "\M-\C-t" gnus-summary-toggle-threads
1863 "\M-\C-s" gnus-summary-show-thread
1864 "\M-\C-h" gnus-summary-hide-thread
1865 "\M-\C-f" gnus-summary-next-thread
1866 "\M-\C-b" gnus-summary-prev-thread
1867 [(meta down)] gnus-summary-next-thread
1868 [(meta up)] gnus-summary-prev-thread
1869 "\M-\C-u" gnus-summary-up-thread
1870 "\M-\C-d" gnus-summary-down-thread
1871 "&" gnus-summary-execute-command
1872 "c" gnus-summary-catchup-and-exit
1873 "\C-w" gnus-summary-mark-region-as-read
1874 "\C-t" gnus-summary-toggle-truncation
1875 "?" gnus-summary-mark-as-dormant
1876 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1877 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1878 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1879 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1880 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1881 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1882 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1883 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1884 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1885 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1886 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1887 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1888 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1889 "=" gnus-summary-expand-window
1890 "\C-x\C-s" gnus-summary-reselect-current-group
1891 "\M-g" gnus-summary-rescan-group
1892 "\C-c\C-r" gnus-summary-caesar-message
1893 "f" gnus-summary-followup
1894 "F" gnus-summary-followup-with-original
1895 "C" gnus-summary-cancel-article
1896 "r" gnus-summary-reply
1897 "R" gnus-summary-reply-with-original
1898 "\C-c\C-f" gnus-summary-mail-forward
1899 "o" gnus-summary-save-article
1900 "\C-o" gnus-summary-save-article-mail
1901 "|" gnus-summary-pipe-output
1902 "\M-k" gnus-summary-edit-local-kill
1903 "\M-K" gnus-summary-edit-global-kill
1904 ;; "V" gnus-version
1905 "\C-c\C-d" gnus-summary-describe-group
1906 "q" gnus-summary-exit
1907 "Q" gnus-summary-exit-no-update
1908 "\C-c\C-i" gnus-info-find-node
1909 gnus-mouse-2 gnus-mouse-pick-article
1910 [follow-link] mouse-face
1911 "m" gnus-summary-mail-other-window
1912 "a" gnus-summary-post-news
1913 "x" gnus-summary-limit-to-unread
1914 "s" gnus-summary-isearch-article
1915 "\t" gnus-summary-widget-forward
1916 [backtab] gnus-summary-widget-backward
1917 "t" gnus-summary-toggle-header
1918 "g" gnus-summary-show-article
1919 "l" gnus-summary-goto-last-article
1920 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1921 "\C-d" gnus-summary-enter-digest-group
1922 "\M-\C-d" gnus-summary-read-document
1923 "\M-\C-e" gnus-summary-edit-parameters
1924 "\M-\C-a" gnus-summary-customize-parameters
1925 "\C-c\C-b" gnus-bug
1926 "*" gnus-cache-enter-article
1927 "\M-*" gnus-cache-remove-article
1928 "\M-&" gnus-summary-universal-argument
1929 "\C-l" gnus-recenter
1930 "I" gnus-summary-increase-score
1931 "L" gnus-summary-lower-score
1932 "\M-i" gnus-symbolic-argument
1933 "h" gnus-summary-select-article-buffer
1934
1935 "b" gnus-article-view-part
1936 "\M-t" gnus-summary-toggle-display-buttonized
1937
1938 "V" gnus-summary-score-map
1939 "X" gnus-uu-extract-map
1940 "S" gnus-summary-send-map)
1941
1942 ;; Sort of orthogonal keymap
1943 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1944 "t" gnus-summary-tick-article-forward
1945 "!" gnus-summary-tick-article-forward
1946 "d" gnus-summary-mark-as-read-forward
1947 "r" gnus-summary-mark-as-read-forward
1948 "c" gnus-summary-clear-mark-forward
1949 " " gnus-summary-clear-mark-forward
1950 "e" gnus-summary-mark-as-expirable
1951 "x" gnus-summary-mark-as-expirable
1952 "?" gnus-summary-mark-as-dormant
1953 "b" gnus-summary-set-bookmark
1954 "B" gnus-summary-remove-bookmark
1955 "#" gnus-summary-mark-as-processable
1956 "\M-#" gnus-summary-unmark-as-processable
1957 "S" gnus-summary-limit-include-expunged
1958 "C" gnus-summary-catchup
1959 "H" gnus-summary-catchup-to-here
1960 "h" gnus-summary-catchup-from-here
1961 "\C-c" gnus-summary-catchup-all
1962 "k" gnus-summary-kill-same-subject-and-select
1963 "K" gnus-summary-kill-same-subject
1964 "P" gnus-uu-mark-map)
1965
1966 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1967 "c" gnus-summary-clear-above
1968 "u" gnus-summary-tick-above
1969 "m" gnus-summary-mark-above
1970 "k" gnus-summary-kill-below)
1971
1972 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1973 "/" gnus-summary-limit-to-subject
1974 "n" gnus-summary-limit-to-articles
1975 "b" gnus-summary-limit-to-bodies
1976 "h" gnus-summary-limit-to-headers
1977 "w" gnus-summary-pop-limit
1978 "s" gnus-summary-limit-to-subject
1979 "a" gnus-summary-limit-to-author
1980 "u" gnus-summary-limit-to-unread
1981 "m" gnus-summary-limit-to-marks
1982 "M" gnus-summary-limit-exclude-marks
1983 "v" gnus-summary-limit-to-score
1984 "*" gnus-summary-limit-include-cached
1985 "D" gnus-summary-limit-include-dormant
1986 "T" gnus-summary-limit-include-thread
1987 "d" gnus-summary-limit-exclude-dormant
1988 "t" gnus-summary-limit-to-age
1989 "." gnus-summary-limit-to-unseen
1990 "x" gnus-summary-limit-to-extra
1991 "p" gnus-summary-limit-to-display-predicate
1992 "E" gnus-summary-limit-include-expunged
1993 "c" gnus-summary-limit-exclude-childless-dormant
1994 "C" gnus-summary-limit-mark-excluded-as-read
1995 "o" gnus-summary-insert-old-articles
1996 "N" gnus-summary-insert-new-articles
1997 "S" gnus-summary-limit-to-singletons
1998 "r" gnus-summary-limit-to-replied
1999 "R" gnus-summary-limit-to-recipient
2000 "A" gnus-summary-limit-to-address)
2001
2002 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2003 "n" gnus-summary-next-unread-article
2004 "p" gnus-summary-prev-unread-article
2005 "N" gnus-summary-next-article
2006 "P" gnus-summary-prev-article
2007 "\C-n" gnus-summary-next-same-subject
2008 "\C-p" gnus-summary-prev-same-subject
2009 "\M-n" gnus-summary-next-unread-subject
2010 "\M-p" gnus-summary-prev-unread-subject
2011 "f" gnus-summary-first-unread-article
2012 "b" gnus-summary-best-unread-article
2013 "j" gnus-summary-goto-article
2014 "g" gnus-summary-goto-subject
2015 "l" gnus-summary-goto-last-article
2016 "o" gnus-summary-pop-article)
2017
2018 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2019 "k" gnus-summary-kill-thread
2020 "E" gnus-summary-expire-thread
2021 "l" gnus-summary-lower-thread
2022 "i" gnus-summary-raise-thread
2023 "T" gnus-summary-toggle-threads
2024 "t" gnus-summary-rethread-current
2025 "^" gnus-summary-reparent-thread
2026 "\M-^" gnus-summary-reparent-children
2027 "s" gnus-summary-show-thread
2028 "S" gnus-summary-show-all-threads
2029 "h" gnus-summary-hide-thread
2030 "H" gnus-summary-hide-all-threads
2031 "n" gnus-summary-next-thread
2032 "p" gnus-summary-prev-thread
2033 "u" gnus-summary-up-thread
2034 "o" gnus-summary-top-thread
2035 "d" gnus-summary-down-thread
2036 "#" gnus-uu-mark-thread
2037 "\M-#" gnus-uu-unmark-thread)
2038
2039 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2040 "g" gnus-summary-prepare
2041 "c" gnus-summary-insert-cached-articles
2042 "d" gnus-summary-insert-dormant-articles
2043 "t" gnus-summary-insert-ticked-articles)
2044
2045 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2046 "c" gnus-summary-catchup-and-exit
2047 "C" gnus-summary-catchup-all-and-exit
2048 "E" gnus-summary-exit-no-update
2049 "Q" gnus-summary-exit
2050 "Z" gnus-summary-exit
2051 "n" gnus-summary-catchup-and-goto-next-group
2052 "p" gnus-summary-catchup-and-goto-prev-group
2053 "R" gnus-summary-reselect-current-group
2054 "G" gnus-summary-rescan-group
2055 "N" gnus-summary-next-group
2056 "s" gnus-summary-save-newsrc
2057 "P" gnus-summary-prev-group)
2058
2059 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2060 " " gnus-summary-next-page
2061 "n" gnus-summary-next-page
2062 [?\S-\ ] gnus-summary-prev-page
2063 "\177" gnus-summary-prev-page
2064 [delete] gnus-summary-prev-page
2065 "p" gnus-summary-prev-page
2066 "\r" gnus-summary-scroll-up
2067 "\M-\r" gnus-summary-scroll-down
2068 "<" gnus-summary-beginning-of-article
2069 ">" gnus-summary-end-of-article
2070 "b" gnus-summary-beginning-of-article
2071 "e" gnus-summary-end-of-article
2072 "^" gnus-summary-refer-parent-article
2073 "r" gnus-summary-refer-parent-article
2074 "C" gnus-summary-show-complete-article
2075 "D" gnus-summary-enter-digest-group
2076 "R" gnus-summary-refer-references
2077 "T" gnus-summary-refer-thread
2078 "W" gnus-warp-to-article
2079 "g" gnus-summary-show-article
2080 "s" gnus-summary-isearch-article
2081 "\t" gnus-summary-widget-forward
2082 [backtab] gnus-summary-widget-backward
2083 "P" gnus-summary-print-article
2084 "S" gnus-sticky-article
2085 "M" gnus-mailing-list-insinuate
2086 "t" gnus-article-babel)
2087
2088 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2089 "b" gnus-article-add-buttons
2090 "B" gnus-article-add-buttons-to-head
2091 "o" gnus-article-treat-overstrike
2092 "e" gnus-article-emphasize
2093 "w" gnus-article-fill-cited-article
2094 "Q" gnus-article-fill-long-lines
2095 "L" gnus-article-toggle-truncate-lines
2096 "C" gnus-article-capitalize-sentences
2097 "c" gnus-article-remove-cr
2098 "q" gnus-article-de-quoted-unreadable
2099 "6" gnus-article-de-base64-unreadable
2100 "Z" gnus-article-decode-HZ
2101 "A" gnus-article-treat-ansi-sequences
2102 "h" gnus-article-wash-html
2103 "u" gnus-article-unsplit-urls
2104 "s" gnus-summary-force-verify-and-decrypt
2105 "f" gnus-article-display-x-face
2106 "l" gnus-summary-stop-page-breaking
2107 "r" gnus-summary-caesar-message
2108 "m" gnus-summary-morse-message
2109 "t" gnus-summary-toggle-header
2110 "g" gnus-treat-smiley
2111 "v" gnus-summary-verbose-headers
2112 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2113 "p" gnus-article-verify-x-pgp-sig
2114 "d" gnus-article-treat-dumbquotes
2115 "U" gnus-article-treat-non-ascii
2116 "i" gnus-summary-idna-message)
2117
2118 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2119 ;; mnemonic: deuglif*Y*
2120 "u" gnus-article-outlook-unwrap-lines
2121 "a" gnus-article-outlook-repair-attribution
2122 "c" gnus-article-outlook-rearrange-citation
2123 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2124
2125 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2126 "a" gnus-article-hide
2127 "h" gnus-article-hide-headers
2128 "b" gnus-article-hide-boring-headers
2129 "s" gnus-article-hide-signature
2130 "c" gnus-article-hide-citation
2131 "C" gnus-article-hide-citation-in-followups
2132 "l" gnus-article-hide-list-identifiers
2133 "B" gnus-article-strip-banner
2134 "P" gnus-article-hide-pem
2135 "\C-c" gnus-article-hide-citation-maybe)
2136
2137 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2138 "a" gnus-article-highlight
2139 "h" gnus-article-highlight-headers
2140 "c" gnus-article-highlight-citation
2141 "s" gnus-article-highlight-signature)
2142
2143 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2144 "f" gnus-article-treat-fold-headers
2145 "u" gnus-article-treat-unfold-headers
2146 "n" gnus-article-treat-fold-newsgroups)
2147
2148 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2149 "x" gnus-article-display-x-face
2150 "d" gnus-article-display-face
2151 "s" gnus-treat-smiley
2152 "D" gnus-article-remove-images
2153 "W" gnus-article-show-images
2154 "f" gnus-treat-from-picon
2155 "m" gnus-treat-mail-picon
2156 "n" gnus-treat-newsgroups-picon
2157 "g" gnus-treat-from-gravatar
2158 "h" gnus-treat-mail-gravatar)
2159
2160 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2161 "w" gnus-article-decode-mime-words
2162 "c" gnus-article-decode-charset
2163 "v" gnus-mime-view-all-parts
2164 "b" gnus-article-view-part)
2165
2166 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2167 "z" gnus-article-date-ut
2168 "u" gnus-article-date-ut
2169 "l" gnus-article-date-local
2170 "p" gnus-article-date-english
2171 "e" gnus-article-date-lapsed
2172 "o" gnus-article-date-original
2173 "i" gnus-article-date-iso8601
2174 "s" gnus-article-date-user)
2175
2176 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2177 "t" gnus-article-remove-trailing-blank-lines
2178 "l" gnus-article-strip-leading-blank-lines
2179 "m" gnus-article-strip-multiple-blank-lines
2180 "a" gnus-article-strip-blank-lines
2181 "A" gnus-article-strip-all-blank-lines
2182 "s" gnus-article-strip-leading-space
2183 "e" gnus-article-strip-trailing-space
2184 "w" gnus-article-remove-leading-whitespace)
2185
2186 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2187 "v" gnus-version
2188 "d" gnus-summary-describe-group
2189 "h" gnus-summary-describe-briefly
2190 "i" gnus-info-find-node)
2191
2192 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2193 "e" gnus-summary-expire-articles
2194 "\M-\C-e" gnus-summary-expire-articles-now
2195 "\177" gnus-summary-delete-article
2196 [delete] gnus-summary-delete-article
2197 [backspace] gnus-summary-delete-article
2198 "m" gnus-summary-move-article
2199 "r" gnus-summary-respool-article
2200 "w" gnus-summary-edit-article
2201 "c" gnus-summary-copy-article
2202 "B" gnus-summary-crosspost-article
2203 "q" gnus-summary-respool-query
2204 "t" gnus-summary-respool-trace
2205 "i" gnus-summary-import-article
2206 "I" gnus-summary-create-article
2207 "p" gnus-summary-article-posted-p)
2208
2209 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2210 "o" gnus-summary-save-article
2211 "m" gnus-summary-save-article-mail
2212 "F" gnus-summary-write-article-file
2213 "r" gnus-summary-save-article-rmail
2214 "f" gnus-summary-save-article-file
2215 "b" gnus-summary-save-article-body-file
2216 "B" gnus-summary-write-article-body-file
2217 "h" gnus-summary-save-article-folder
2218 "v" gnus-summary-save-article-vm
2219 "p" gnus-summary-pipe-output
2220 "P" gnus-summary-muttprint)
2221
2222 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2223 "b" gnus-summary-display-buttonized
2224 "m" gnus-summary-repair-multipart
2225 "v" gnus-article-view-part
2226 "o" gnus-article-save-part
2227 "O" gnus-article-save-part-and-strip
2228 "r" gnus-article-replace-part
2229 "d" gnus-article-delete-part
2230 "t" gnus-article-view-part-as-type
2231 "j" gnus-article-jump-to-part
2232 "c" gnus-article-copy-part
2233 "C" gnus-article-view-part-as-charset
2234 "e" gnus-article-view-part-externally
2235 "H" gnus-article-browse-html-article
2236 "E" gnus-article-encrypt-body
2237 "i" gnus-article-inline-part
2238 "|" gnus-article-pipe-part)
2239
2240 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2241 "p" gnus-summary-mark-as-processable
2242 "u" gnus-summary-unmark-as-processable
2243 "U" gnus-summary-unmark-all-processable
2244 "v" gnus-uu-mark-over
2245 "s" gnus-uu-mark-series
2246 "r" gnus-uu-mark-region
2247 "g" gnus-uu-unmark-region
2248 "R" gnus-uu-mark-by-regexp
2249 "G" gnus-uu-unmark-by-regexp
2250 "t" gnus-uu-mark-thread
2251 "T" gnus-uu-unmark-thread
2252 "a" gnus-uu-mark-all
2253 "b" gnus-uu-mark-buffer
2254 "S" gnus-uu-mark-sparse
2255 "k" gnus-summary-kill-process-mark
2256 "y" gnus-summary-yank-process-mark
2257 "w" gnus-summary-save-process-mark
2258 "i" gnus-uu-invert-processable)
2259
2260 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2261 ;;"x" gnus-uu-extract-any
2262 "m" gnus-summary-save-parts
2263 "u" gnus-uu-decode-uu
2264 "U" gnus-uu-decode-uu-and-save
2265 "s" gnus-uu-decode-unshar
2266 "S" gnus-uu-decode-unshar-and-save
2267 "o" gnus-uu-decode-save
2268 "O" gnus-uu-decode-save
2269 "b" gnus-uu-decode-binhex
2270 "B" gnus-uu-decode-binhex
2271 "Y" gnus-uu-decode-yenc
2272 "p" gnus-uu-decode-postscript
2273 "P" gnus-uu-decode-postscript-and-save)
2274
2275 (gnus-define-keys
2276 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2277 "u" gnus-uu-decode-uu-view
2278 "U" gnus-uu-decode-uu-and-save-view
2279 "s" gnus-uu-decode-unshar-view
2280 "S" gnus-uu-decode-unshar-and-save-view
2281 "o" gnus-uu-decode-save-view
2282 "O" gnus-uu-decode-save-view
2283 "b" gnus-uu-decode-binhex-view
2284 "B" gnus-uu-decode-binhex-view
2285 "p" gnus-uu-decode-postscript-view
2286 "P" gnus-uu-decode-postscript-and-save-view)
2287
2288 (defvar gnus-article-post-menu nil)
2289
2290 (defconst gnus-summary-menu-maxlen 20)
2291
2292 (defun gnus-summary-menu-split (menu)
2293 ;; If we have lots of elements, divide them into groups of 20
2294 ;; and make a pane (or submenu) for each one.
2295 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2296 (let ((menu menu) sublists next
2297 (i 1))
2298 (while menu
2299 ;; Pull off the next gnus-summary-menu-maxlen elements
2300 ;; and make them the next element of sublist.
2301 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2302 (if next
2303 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2304 nil))
2305 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2306 (aref (car (last menu)) 0)) menu)
2307 sublists))
2308 (setq i (1+ i))
2309 (setq menu next))
2310 (nreverse sublists))
2311 ;; Few elements--put them all in one pane.
2312 menu))
2313
2314 (defun gnus-summary-make-menu-bar ()
2315 (gnus-turn-off-edit-menu 'summary)
2316
2317 (unless (boundp 'gnus-summary-misc-menu)
2318
2319 (easy-menu-define
2320 gnus-summary-kill-menu gnus-summary-mode-map ""
2321 (cons
2322 "Score"
2323 (nconc
2324 (list
2325 ["Customize" gnus-score-customize t])
2326 (gnus-make-score-map 'increase)
2327 (gnus-make-score-map 'lower)
2328 '(("Mark"
2329 ["Kill below" gnus-summary-kill-below t]
2330 ["Mark above" gnus-summary-mark-above t]
2331 ["Tick above" gnus-summary-tick-above t]
2332 ["Clear above" gnus-summary-clear-above t])
2333 ["Current score" gnus-summary-current-score t]
2334 ["Set score" gnus-summary-set-score t]
2335 ["Switch current score file..." gnus-score-change-score-file t]
2336 ["Set mark below..." gnus-score-set-mark-below t]
2337 ["Set expunge below..." gnus-score-set-expunge-below t]
2338 ["Edit current score file" gnus-score-edit-current-scores t]
2339 ["Edit score file..." gnus-score-edit-file t]
2340 ["Trace score" gnus-score-find-trace t]
2341 ["Find words" gnus-score-find-favourite-words t]
2342 ["Rescore buffer" gnus-summary-rescore t]
2343 ["Increase score..." gnus-summary-increase-score t]
2344 ["Lower score..." gnus-summary-lower-score t]))))
2345
2346 ;; Define both the Article menu in the summary buffer and the
2347 ;; equivalent Commands menu in the article buffer here for
2348 ;; consistency.
2349 (let ((innards
2350 `(("Hide"
2351 ["All" gnus-article-hide t]
2352 ["Headers" gnus-article-hide-headers t]
2353 ["Signature" gnus-article-hide-signature t]
2354 ["Citation" gnus-article-hide-citation t]
2355 ["List identifiers" gnus-article-hide-list-identifiers t]
2356 ["Banner" gnus-article-strip-banner t]
2357 ["Boring headers" gnus-article-hide-boring-headers t])
2358 ("Highlight"
2359 ["All" gnus-article-highlight t]
2360 ["Headers" gnus-article-highlight-headers t]
2361 ["Signature" gnus-article-highlight-signature t]
2362 ["Citation" gnus-article-highlight-citation t])
2363 ("MIME"
2364 ["Words" gnus-article-decode-mime-words t]
2365 ["Charset" gnus-article-decode-charset t]
2366 ["QP" gnus-article-de-quoted-unreadable t]
2367 ["Base64" gnus-article-de-base64-unreadable t]
2368 ["View MIME buttons" gnus-summary-display-buttonized t]
2369 ["View all" gnus-mime-view-all-parts t]
2370 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2371 ["Encrypt body" gnus-article-encrypt-body
2372 :active (not (gnus-group-read-only-p))
2373 ,@(if (featurep 'xemacs) nil
2374 '(:help "Encrypt the message body on disk"))]
2375 ["Extract all parts..." gnus-summary-save-parts t]
2376 ("Multipart"
2377 ["Repair multipart" gnus-summary-repair-multipart t]
2378 ["Pipe part..." gnus-article-pipe-part t]
2379 ["Inline part" gnus-article-inline-part t]
2380 ["View part as type..." gnus-article-view-part-as-type t]
2381 ["Encrypt body" gnus-article-encrypt-body
2382 :active (not (gnus-group-read-only-p))
2383 ,@(if (featurep 'xemacs) nil
2384 '(:help "Encrypt the message body on disk"))]
2385 ["View part externally" gnus-article-view-part-externally t]
2386 ["View HTML parts in browser" gnus-article-browse-html-article t]
2387 ["View part with charset..." gnus-article-view-part-as-charset t]
2388 ["Copy part" gnus-article-copy-part t]
2389 ["Save part..." gnus-article-save-part t]
2390 ["View part" gnus-article-view-part t]))
2391 ("Date"
2392 ["Local" gnus-article-date-local t]
2393 ["ISO8601" gnus-article-date-iso8601 t]
2394 ["UT" gnus-article-date-ut t]
2395 ["Original" gnus-article-date-original t]
2396 ["Lapsed" gnus-article-date-lapsed t]
2397 ["User-defined" gnus-article-date-user t])
2398 ("Display"
2399 ["Remove images" gnus-article-remove-images t]
2400 ["Toggle smiley" gnus-treat-smiley t]
2401 ["Show X-Face" gnus-article-display-x-face t]
2402 ["Show picons in From" gnus-treat-from-picon t]
2403 ["Show picons in mail headers" gnus-treat-mail-picon t]
2404 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2405 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2406 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2407 ("View as different encoding"
2408 ,@(gnus-summary-menu-split
2409 (mapcar
2410 (lambda (cs)
2411 ;; Since easymenu under Emacs doesn't allow
2412 ;; lambda forms for menu commands, we should
2413 ;; provide intern'ed function symbols.
2414 (let ((command (intern (format "\
2415 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2416 (fset command
2417 `(lambda ()
2418 (interactive)
2419 (let ((gnus-summary-show-article-charset-alist
2420 '((1 . ,cs))))
2421 (gnus-summary-show-article 1))))
2422 `[,(symbol-name cs) ,command t]))
2423 (sort (if (fboundp 'coding-system-list)
2424 (coding-system-list)
2425 (mapcar 'car mm-mime-mule-charset-alist))
2426 'string<)))))
2427 ("Washing"
2428 ("Remove Blanks"
2429 ["Leading" gnus-article-strip-leading-blank-lines t]
2430 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2431 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2432 ["All of the above" gnus-article-strip-blank-lines t]
2433 ["All" gnus-article-strip-all-blank-lines t]
2434 ["Leading space" gnus-article-strip-leading-space t]
2435 ["Trailing space" gnus-article-strip-trailing-space t]
2436 ["Leading space in headers"
2437 gnus-article-remove-leading-whitespace t])
2438 ["Overstrike" gnus-article-treat-overstrike t]
2439 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2440 ["Non-ASCII" gnus-article-treat-non-ascii t]
2441 ["Emphasis" gnus-article-emphasize t]
2442 ["Word wrap" gnus-article-fill-cited-article t]
2443 ["Fill long lines" gnus-article-fill-long-lines t]
2444 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2445 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2446 ["Remove CR" gnus-article-remove-cr t]
2447 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2448 ["Base64" gnus-article-de-base64-unreadable t]
2449 ["Rot 13" gnus-summary-caesar-message
2450 ,@(if (featurep 'xemacs) '(t)
2451 '(:help "\"Caesar rotate\" article by 13"))]
2452 ["De-IDNA" gnus-summary-idna-message t]
2453 ["Morse decode" gnus-summary-morse-message t]
2454 ["Unix pipe..." gnus-summary-pipe-message t]
2455 ["Add buttons" gnus-article-add-buttons t]
2456 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2457 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2458 ["Verbose header" gnus-summary-verbose-headers t]
2459 ["Toggle header" gnus-summary-toggle-header t]
2460 ["Unfold headers" gnus-article-treat-unfold-headers t]
2461 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2462 ["Html" gnus-article-wash-html t]
2463 ["Unsplit URLs" gnus-article-unsplit-urls t]
2464 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2465 ["Decode HZ" gnus-article-decode-HZ t]
2466 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2467 ("(Outlook) Deuglify"
2468 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2469 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2470 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2471 ["Full (Outlook) deuglify"
2472 gnus-article-outlook-deuglify-article t])
2473 )
2474 ("Output"
2475 ["Save in default format..." gnus-summary-save-article
2476 ,@(if (featurep 'xemacs) '(t)
2477 '(:help "Save article using default method"))]
2478 ["Save in file..." gnus-summary-save-article-file
2479 ,@(if (featurep 'xemacs) '(t)
2480 '(:help "Save article in file"))]
2481 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2482 ["Save in MH folder..." gnus-summary-save-article-folder t]
2483 ["Save in VM folder..." gnus-summary-save-article-vm t]
2484 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2485 ["Save body in file..." gnus-summary-save-article-body-file t]
2486 ["Pipe through a filter..." gnus-summary-pipe-output t]
2487 ["Print with Muttprint..." gnus-summary-muttprint t]
2488 ["Print" gnus-summary-print-article
2489 ,@(if (featurep 'xemacs) '(t)
2490 '(:help "Generate and print a PostScript image"))])
2491 ("Copy, move,... (Backend)"
2492 ,@(if (featurep 'xemacs) nil
2493 '(:help "Copying, moving, expiring articles..."))
2494 ["Respool article..." gnus-summary-respool-article t]
2495 ["Move article..." gnus-summary-move-article
2496 (gnus-check-backend-function
2497 'request-move-article gnus-newsgroup-name)]
2498 ["Copy article..." gnus-summary-copy-article t]
2499 ["Crosspost article..." gnus-summary-crosspost-article
2500 (gnus-check-backend-function
2501 'request-replace-article gnus-newsgroup-name)]
2502 ["Import file..." gnus-summary-import-article
2503 (gnus-check-backend-function
2504 'request-accept-article gnus-newsgroup-name)]
2505 ["Create article..." gnus-summary-create-article
2506 (gnus-check-backend-function
2507 'request-accept-article gnus-newsgroup-name)]
2508 ["Check if posted" gnus-summary-article-posted-p t]
2509 ["Edit article" gnus-summary-edit-article
2510 (not (gnus-group-read-only-p))]
2511 ["Delete article" gnus-summary-delete-article
2512 (gnus-check-backend-function
2513 'request-expire-articles gnus-newsgroup-name)]
2514 ["Query respool" gnus-summary-respool-query t]
2515 ["Trace respool" gnus-summary-respool-trace t]
2516 ["Delete expirable articles" gnus-summary-expire-articles-now
2517 (gnus-check-backend-function
2518 'request-expire-articles gnus-newsgroup-name)])
2519 ("Extract"
2520 ["Uudecode" gnus-uu-decode-uu
2521 ,@(if (featurep 'xemacs) '(t)
2522 '(:help "Decode uuencoded article(s)"))]
2523 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2524 ["Unshar" gnus-uu-decode-unshar t]
2525 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2526 ["Save" gnus-uu-decode-save t]
2527 ["Binhex" gnus-uu-decode-binhex t]
2528 ["PostScript" gnus-uu-decode-postscript t]
2529 ["All MIME parts" gnus-summary-save-parts t])
2530 ("Cache"
2531 ["Enter article" gnus-cache-enter-article t]
2532 ["Remove article" gnus-cache-remove-article t])
2533 ["Translate" gnus-article-babel t]
2534 ["Select article buffer" gnus-summary-select-article-buffer t]
2535 ["Make article buffer sticky" gnus-sticky-article t]
2536 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2537 ["Isearch article..." gnus-summary-isearch-article t]
2538 ["Beginning of the article" gnus-summary-beginning-of-article t]
2539 ["End of the article" gnus-summary-end-of-article t]
2540 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2541 ["Fetch referenced articles" gnus-summary-refer-references t]
2542 ["Fetch current thread" gnus-summary-refer-thread t]
2543 ["Fetch article with id..." gnus-summary-refer-article t]
2544 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2545 ["Redisplay" gnus-summary-show-article t]
2546 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2547 (easy-menu-define
2548 gnus-summary-article-menu gnus-summary-mode-map ""
2549 (cons "Article" innards))
2550
2551 (if (not (keymapp gnus-summary-article-menu))
2552 (easy-menu-define
2553 gnus-article-commands-menu gnus-article-mode-map ""
2554 (cons "Commands" innards))
2555 ;; in Emacs, don't share menu.
2556 (setq gnus-article-commands-menu
2557 (copy-keymap gnus-summary-article-menu))
2558 (define-key gnus-article-mode-map [menu-bar commands]
2559 (cons "Commands" gnus-article-commands-menu))))
2560
2561 (easy-menu-define
2562 gnus-summary-thread-menu gnus-summary-mode-map ""
2563 '("Threads"
2564 ["Find all messages in thread" gnus-summary-refer-thread t]
2565 ["Toggle threading" gnus-summary-toggle-threads t]
2566 ["Hide threads" gnus-summary-hide-all-threads t]
2567 ["Show threads" gnus-summary-show-all-threads t]
2568 ["Hide thread" gnus-summary-hide-thread t]
2569 ["Show thread" gnus-summary-show-thread t]
2570 ["Go to next thread" gnus-summary-next-thread t]
2571 ["Go to previous thread" gnus-summary-prev-thread t]
2572 ["Go down thread" gnus-summary-down-thread t]
2573 ["Go up thread" gnus-summary-up-thread t]
2574 ["Top of thread" gnus-summary-top-thread t]
2575 ["Mark thread as read" gnus-summary-kill-thread t]
2576 ["Mark thread as expired" gnus-summary-expire-thread t]
2577 ["Lower thread score" gnus-summary-lower-thread t]
2578 ["Raise thread score" gnus-summary-raise-thread t]
2579 ["Rethread current" gnus-summary-rethread-current t]))
2580
2581 (easy-menu-define
2582 gnus-summary-post-menu gnus-summary-mode-map ""
2583 `("Post"
2584 ["Send a message (mail or news)" gnus-summary-post-news
2585 ,@(if (featurep 'xemacs) '(t)
2586 '(:help "Compose a new message (mail or news)"))]
2587 ["Followup" gnus-summary-followup
2588 ,@(if (featurep 'xemacs) '(t)
2589 '(:help "Post followup to this article"))]
2590 ["Followup and yank" gnus-summary-followup-with-original
2591 ,@(if (featurep 'xemacs) '(t)
2592 '(:help "Post followup to this article, quoting its contents"))]
2593 ["Supersede article" gnus-summary-supersede-article t]
2594 ["Cancel article" gnus-summary-cancel-article
2595 ,@(if (featurep 'xemacs) '(t)
2596 '(:help "Cancel an article you posted"))]
2597 ["Reply" gnus-summary-reply t]
2598 ["Reply and yank" gnus-summary-reply-with-original t]
2599 ["Wide reply" gnus-summary-wide-reply t]
2600 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2601 ,@(if (featurep 'xemacs) '(t)
2602 '(:help "Mail a reply, quoting this article"))]
2603 ["Very wide reply" gnus-summary-very-wide-reply t]
2604 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2605 ,@(if (featurep 'xemacs) '(t)
2606 '(:help "Mail a very wide reply, quoting this article"))]
2607 ["Mail forward" gnus-summary-mail-forward t]
2608 ["Post forward" gnus-summary-post-forward t]
2609 ["Digest and mail" gnus-uu-digest-mail-forward t]
2610 ["Digest and post" gnus-uu-digest-post-forward t]
2611 ["Resend message" gnus-summary-resend-message t]
2612 ["Resend message edit" gnus-summary-resend-message-edit t]
2613 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2614 ["Send a mail" gnus-summary-mail-other-window t]
2615 ["Create a local message" gnus-summary-news-other-window t]
2616 ["Uuencode and post" gnus-uu-post-news
2617 ,@(if (featurep 'xemacs) '(t)
2618 '(:help "Post a uuencoded article"))]
2619 ["Followup via news" gnus-summary-followup-to-mail t]
2620 ["Followup via news and yank"
2621 gnus-summary-followup-to-mail-with-original t]
2622 ["Strip signature on reply"
2623 (lambda ()
2624 (interactive)
2625 (if (not (memq message-cite-function
2626 '(message-cite-original-without-signature
2627 message-cite-original)))
2628 ;; Stupid workaround for XEmacs not honoring :visible.
2629 (message "Can't toggle this value of `message-cite-function'")
2630 (setq message-cite-function
2631 (if (eq message-cite-function
2632 'message-cite-original-without-signature)
2633 'message-cite-original
2634 'message-cite-original-without-signature))))
2635 ;; XEmacs barfs on :visible.
2636 ,@(if (featurep 'xemacs) nil
2637 '(:visible (memq message-cite-function
2638 '(message-cite-original-without-signature
2639 message-cite-original))))
2640 :style toggle
2641 :selected (eq message-cite-function
2642 'message-cite-original-without-signature)
2643 ,@(if (featurep 'xemacs) nil
2644 '(:help "Strip signature from cited article when replying."))]
2645 ;;("Draft"
2646 ;;["Send" gnus-summary-send-draft t]
2647 ;;["Send bounced" gnus-resend-bounced-mail t])
2648 ))
2649
2650 (cond
2651 ((not (keymapp gnus-summary-post-menu))
2652 (setq gnus-article-post-menu gnus-summary-post-menu))
2653 ((not gnus-article-post-menu)
2654 ;; Don't share post menu.
2655 (setq gnus-article-post-menu
2656 (copy-keymap gnus-summary-post-menu))))
2657 (define-key gnus-article-mode-map [menu-bar post]
2658 (cons "Post" gnus-article-post-menu))
2659
2660 (easy-menu-define
2661 gnus-summary-misc-menu gnus-summary-mode-map ""
2662 `("Gnus"
2663 ("Mark Read"
2664 ["Mark as read" gnus-summary-mark-as-read-forward t]
2665 ["Mark same subject and select"
2666 gnus-summary-kill-same-subject-and-select t]
2667 ["Mark same subject" gnus-summary-kill-same-subject t]
2668 ["Catchup" gnus-summary-catchup
2669 ,@(if (featurep 'xemacs) '(t)
2670 '(:help "Mark unread articles in this group as read"))]
2671 ["Catchup all" gnus-summary-catchup-all t]
2672 ["Catchup to here" gnus-summary-catchup-to-here t]
2673 ["Catchup from here" gnus-summary-catchup-from-here t]
2674 ["Catchup region" gnus-summary-mark-region-as-read
2675 (gnus-mark-active-p)]
2676 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2677 ("Mark Various"
2678 ["Tick" gnus-summary-tick-article-forward t]
2679 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2680 ["Remove marks" gnus-summary-clear-mark-forward t]
2681 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2682 ["Set bookmark" gnus-summary-set-bookmark t]
2683 ["Remove bookmark" gnus-summary-remove-bookmark t])
2684 ("Limit to"
2685 ["Marks..." gnus-summary-limit-to-marks t]
2686 ["Subject..." gnus-summary-limit-to-subject t]
2687 ["Author..." gnus-summary-limit-to-author t]
2688 ["Recipient..." gnus-summary-limit-to-recipient t]
2689 ["Address..." gnus-summary-limit-to-address t]
2690 ["Age..." gnus-summary-limit-to-age t]
2691 ["Extra..." gnus-summary-limit-to-extra t]
2692 ["Score..." gnus-summary-limit-to-score t]
2693 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2694 ["Unread" gnus-summary-limit-to-unread t]
2695 ["Unseen" gnus-summary-limit-to-unseen t]
2696 ["Singletons" gnus-summary-limit-to-singletons t]
2697 ["Replied" gnus-summary-limit-to-replied t]
2698 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2699 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2700 ["Pop limit" gnus-summary-pop-limit t]
2701 ["Show dormant" gnus-summary-limit-include-dormant t]
2702 ["Hide childless dormant"
2703 gnus-summary-limit-exclude-childless-dormant t]
2704 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2705 ["Hide marked" gnus-summary-limit-exclude-marks t]
2706 ["Show expunged" gnus-summary-limit-include-expunged t])
2707 ("Process Mark"
2708 ["Set mark" gnus-summary-mark-as-processable t]
2709 ["Remove mark" gnus-summary-unmark-as-processable t]
2710 ["Remove all marks" gnus-summary-unmark-all-processable t]
2711 ["Invert marks" gnus-uu-invert-processable t]
2712 ["Mark above" gnus-uu-mark-over t]
2713 ["Mark series" gnus-uu-mark-series t]
2714 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2715 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2716 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2717 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2718 ["Mark all" gnus-uu-mark-all t]
2719 ["Mark buffer" gnus-uu-mark-buffer t]
2720 ["Mark sparse" gnus-uu-mark-sparse t]
2721 ["Mark thread" gnus-uu-mark-thread t]
2722 ["Unmark thread" gnus-uu-unmark-thread t]
2723 ("Process Mark Sets"
2724 ["Kill" gnus-summary-kill-process-mark t]
2725 ["Yank" gnus-summary-yank-process-mark
2726 gnus-newsgroup-process-stack]
2727 ["Save" gnus-summary-save-process-mark t]
2728 ["Run command on marked..." gnus-summary-universal-argument t]))
2729 ("Registry Marks")
2730 ("Scroll article"
2731 ["Page forward" gnus-summary-next-page
2732 ,@(if (featurep 'xemacs) '(t)
2733 '(:help "Show next page of article"))]
2734 ["Page backward" gnus-summary-prev-page
2735 ,@(if (featurep 'xemacs) '(t)
2736 '(:help "Show previous page of article"))]
2737 ["Line forward" gnus-summary-scroll-up t])
2738 ("Move"
2739 ["Next unread article" gnus-summary-next-unread-article t]
2740 ["Previous unread article" gnus-summary-prev-unread-article t]
2741 ["Next article" gnus-summary-next-article t]
2742 ["Previous article" gnus-summary-prev-article t]
2743 ["Next unread subject" gnus-summary-next-unread-subject t]
2744 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2745 ["Next article same subject" gnus-summary-next-same-subject t]
2746 ["Previous article same subject" gnus-summary-prev-same-subject t]
2747 ["First unread article" gnus-summary-first-unread-article t]
2748 ["Best unread article" gnus-summary-best-unread-article t]
2749 ["Go to subject number..." gnus-summary-goto-subject t]
2750 ["Go to article number..." gnus-summary-goto-article t]
2751 ["Go to the last article" gnus-summary-goto-last-article t]
2752 ["Pop article off history" gnus-summary-pop-article t])
2753 ("Sort"
2754 ["Sort by number" gnus-summary-sort-by-number t]
2755 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2756 ["Sort by author" gnus-summary-sort-by-author t]
2757 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2758 ["Sort by subject" gnus-summary-sort-by-subject t]
2759 ["Sort by date" gnus-summary-sort-by-date t]
2760 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2761 ["Sort by score" gnus-summary-sort-by-score t]
2762 ["Sort by lines" gnus-summary-sort-by-lines t]
2763 ["Sort by characters" gnus-summary-sort-by-chars t]
2764 ["Randomize" gnus-summary-sort-by-random t]
2765 ["Original sort" gnus-summary-sort-by-original t])
2766 ("Help"
2767 ["Describe group" gnus-summary-describe-group t]
2768 ["Read manual" gnus-info-find-node t])
2769 ("Modes"
2770 ["Pick and read" gnus-pick-mode t]
2771 ["Binary" gnus-binary-mode t])
2772 ("Regeneration"
2773 ["Regenerate" gnus-summary-prepare t]
2774 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2775 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2776 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2777 ["Toggle threading" gnus-summary-toggle-threads t])
2778 ["See old articles" gnus-summary-insert-old-articles t]
2779 ["See new articles" gnus-summary-insert-new-articles t]
2780 ["Filter articles..." gnus-summary-execute-command t]
2781 ["Run command on articles..." gnus-summary-universal-argument t]
2782 ["Search articles forward..." gnus-summary-search-article-forward t]
2783 ["Search articles backward..." gnus-summary-search-article-backward t]
2784 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2785 ["Expand window" gnus-summary-expand-window t]
2786 ["Expire expirable articles" gnus-summary-expire-articles
2787 (gnus-check-backend-function
2788 'request-expire-articles gnus-newsgroup-name)]
2789 ["Edit local kill file" gnus-summary-edit-local-kill t]
2790 ["Edit main kill file" gnus-summary-edit-global-kill t]
2791 ["Edit group parameters" gnus-summary-edit-parameters t]
2792 ["Customize group parameters" gnus-summary-customize-parameters t]
2793 ["Send a bug report" gnus-bug t]
2794 ("Exit"
2795 ["Catchup and exit" gnus-summary-catchup-and-exit
2796 ,@(if (featurep 'xemacs) '(t)
2797 '(:help "Mark unread articles in this group as read, then exit"))]
2798 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2799 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2800 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2801 ["Exit group" gnus-summary-exit
2802 ,@(if (featurep 'xemacs) '(t)
2803 '(:help "Exit current group, return to group selection mode"))]
2804 ["Exit group without updating" gnus-summary-exit-no-update t]
2805 ["Exit and goto next group" gnus-summary-next-group t]
2806 ["Exit and goto prev group" gnus-summary-prev-group t]
2807 ["Reselect group" gnus-summary-reselect-current-group t]
2808 ["Rescan group" gnus-summary-rescan-group t]
2809 ["Update dribble" gnus-summary-save-newsrc t])))
2810
2811 (gnus-run-hooks 'gnus-summary-menu-hook)))
2812
2813 (defvar gnus-summary-tool-bar-map nil)
2814
2815 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2816 ;; affect _new_ message buffers. We might add a function that walks thru all
2817 ;; summary-mode buffers and force the update.
2818 (defun gnus-summary-tool-bar-update (&optional symbol value)
2819 "Update summary mode toolbar.
2820 Setter function for custom variables."
2821 (setq-default gnus-summary-tool-bar-map nil)
2822 (when symbol
2823 ;; When used as ":set" function:
2824 (set-default symbol value))
2825 (when (gnus-buffer-live-p gnus-summary-buffer)
2826 (with-current-buffer gnus-summary-buffer
2827 (gnus-summary-make-tool-bar))))
2828
2829 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2830 'gnus-summary-tool-bar-gnome
2831 'gnus-summary-tool-bar-retro)
2832 "Specifies the Gnus summary tool bar.
2833
2834 It can be either a list or a symbol referring to a list. See
2835 `gmm-tool-bar-from-list' for the format of the list. The
2836 default key map is `gnus-summary-mode-map'.
2837
2838 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2839 `gnus-summary-tool-bar-retro'."
2840 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2841 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2842 (repeat :tag "User defined list" gmm-tool-bar-item)
2843 (symbol))
2844 :version "23.1" ;; No Gnus
2845 :initialize 'custom-initialize-default
2846 :set 'gnus-summary-tool-bar-update
2847 :group 'gnus-summary)
2848
2849 (defcustom gnus-summary-tool-bar-gnome
2850 '((gnus-summary-post-news "mail/compose" nil)
2851 (gnus-summary-insert-new-articles "mail/inbox" nil
2852 :visible (or (not gnus-agent)
2853 gnus-plugged))
2854 (gnus-summary-reply-with-original "mail/reply")
2855 (gnus-summary-reply "mail/reply" nil :visible nil)
2856 (gnus-summary-followup-with-original "mail/reply-all")
2857 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2858 (gnus-summary-mail-forward "mail/forward")
2859 (gnus-summary-save-article "mail/save")
2860 (gnus-summary-search-article-forward "search" nil :visible nil)
2861 (gnus-summary-print-article "print")
2862 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2863 ;; Some new commands that may need more suitable icons:
2864 (gnus-summary-save-newsrc "save" nil :visible nil)
2865 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2866 (gnus-summary-prev-article "left-arrow")
2867 (gnus-summary-next-article "right-arrow")
2868 (gnus-summary-next-page "next-page")
2869 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2870 ;;
2871 ;; Maybe some sort-by-... could be added:
2872 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2873 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2874 (gnus-summary-mark-as-expirable
2875 "delete" nil
2876 :visible (gnus-check-backend-function 'request-expire-articles
2877 gnus-newsgroup-name))
2878 (gnus-summary-mark-as-spam
2879 "mail/spam" t
2880 :visible (and (fboundp 'spam-group-ham-contents-p)
2881 (spam-group-ham-contents-p gnus-newsgroup-name))
2882 :help "Mark as spam")
2883 (gnus-summary-mark-as-read-forward
2884 "mail/not-spam" nil
2885 :visible (and (fboundp 'spam-group-spam-contents-p)
2886 (spam-group-spam-contents-p gnus-newsgroup-name)))
2887 ;;
2888 (gnus-summary-exit "exit")
2889 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2890 (gnus-info-find-node "help"))
2891 "List of functions for the summary tool bar (GNOME style).
2892
2893 See `gmm-tool-bar-from-list' for the format of the list."
2894 :type '(repeat gmm-tool-bar-item)
2895 :version "23.1" ;; No Gnus
2896 :initialize 'custom-initialize-default
2897 :set 'gnus-summary-tool-bar-update
2898 :group 'gnus-summary)
2899
2900 (defcustom gnus-summary-tool-bar-retro
2901 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2902 (gnus-summary-next-unread-article "gnus/next-ur")
2903 (gnus-summary-post-news "gnus/post")
2904 (gnus-summary-followup-with-original "gnus/fuwo")
2905 (gnus-summary-followup "gnus/followup")
2906 (gnus-summary-reply-with-original "gnus/reply-wo")
2907 (gnus-summary-reply "gnus/reply")
2908 (gnus-summary-caesar-message "gnus/rot13")
2909 (gnus-uu-decode-uu "gnus/uu-decode")
2910 (gnus-summary-save-article-file "gnus/save-aif")
2911 (gnus-summary-save-article "gnus/save-art")
2912 (gnus-uu-post-news "gnus/uu-post")
2913 (gnus-summary-catchup "gnus/catchup")
2914 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2915 (gnus-summary-exit "gnus/exit-summ")
2916 ;; Some new command that may need more suitable icons:
2917 (gnus-summary-print-article "gnus/print" nil :visible nil)
2918 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2919 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2920 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2921 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2922 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2923 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2924 ;;
2925 (gnus-info-find-node "gnus/help" nil :visible nil))
2926 "List of functions for the summary tool bar (retro look).
2927
2928 See `gmm-tool-bar-from-list' for the format of the list."
2929 :type '(repeat gmm-tool-bar-item)
2930 :version "23.1" ;; No Gnus
2931 :initialize 'custom-initialize-default
2932 :set 'gnus-summary-tool-bar-update
2933 :group 'gnus-summary)
2934
2935 (defcustom gnus-summary-tool-bar-zap-list t
2936 "List of icon items from the global tool bar.
2937 These items are not displayed in the Gnus summary mode tool bar.
2938
2939 See `gmm-tool-bar-from-list' for the format of the list."
2940 :type 'gmm-tool-bar-zap-list
2941 :version "23.1" ;; No Gnus
2942 :initialize 'custom-initialize-default
2943 :set 'gnus-summary-tool-bar-update
2944 :group 'gnus-summary)
2945
2946 (defvar image-load-path)
2947 (defvar tool-bar-map)
2948
2949 (defun gnus-summary-make-tool-bar (&optional force)
2950 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2951 When FORCE, rebuild the tool bar."
2952 (when (and (not (featurep 'xemacs))
2953 (boundp 'tool-bar-mode)
2954 tool-bar-mode
2955 (or (not gnus-summary-tool-bar-map) force))
2956 (let* ((load-path
2957 (gmm-image-load-path-for-library "gnus"
2958 "mail/save.xpm"
2959 nil t))
2960 (image-load-path (cons (car load-path)
2961 (when (boundp 'image-load-path)
2962 image-load-path)))
2963 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2964 gnus-summary-tool-bar-zap-list
2965 'gnus-summary-mode-map)))
2966 (when map
2967 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2968 ;; uses its value.
2969 (setq gnus-summary-tool-bar-map map))))
2970 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2971
2972 (defun gnus-make-score-map (type)
2973 "Make a summary score map of type TYPE."
2974 (if t
2975 nil
2976 (let ((headers '(("author" "from" string)
2977 ("subject" "subject" string)
2978 ("article body" "body" string)
2979 ("article head" "head" string)
2980 ("xref" "xref" string)
2981 ("extra header" "extra" string)
2982 ("lines" "lines" number)
2983 ("followups to author" "followup" string)))
2984 (types '((number ("less than" <)
2985 ("greater than" >)
2986 ("equal" =))
2987 (string ("substring" s)
2988 ("exact string" e)
2989 ("fuzzy string" f)
2990 ("regexp" r))))
2991 (perms '(("temporary" (current-time-string))
2992 ("permanent" nil)
2993 ("immediate" now)))
2994 header)
2995 (list
2996 (apply
2997 'nconc
2998 (list
2999 (if (eq type 'lower)
3000 "Lower score"
3001 "Increase score"))
3002 (let (outh)
3003 (while headers
3004 (setq header (car headers))
3005 (setq outh
3006 (cons
3007 (apply
3008 'nconc
3009 (list (car header))
3010 (let ((ts (cdr (assoc (nth 2 header) types)))
3011 outt)
3012 (while ts
3013 (setq outt
3014 (cons
3015 (apply
3016 'nconc
3017 (list (caar ts))
3018 (let ((ps perms)
3019 outp)
3020 (while ps
3021 (setq outp
3022 (cons
3023 (vector
3024 (caar ps)
3025 (list
3026 'gnus-summary-score-entry
3027 (nth 1 header)
3028 (if (or (string= (nth 1 header)
3029 "head")
3030 (string= (nth 1 header)
3031 "body"))
3032 ""
3033 (list 'gnus-summary-header
3034 (nth 1 header)))
3035 (list 'quote (nth 1 (car ts)))
3036 (list 'gnus-score-delta-default
3037 nil)
3038 (nth 1 (car ps))
3039 t)
3040 t)
3041 outp))
3042 (setq ps (cdr ps)))
3043 (list (nreverse outp))))
3044 outt))
3045 (setq ts (cdr ts)))
3046 (list (nreverse outt))))
3047 outh))
3048 (setq headers (cdr headers)))
3049 (list (nreverse outh))))))))
3050
3051
3052 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3053 (defvar bookmark-make-record-function)
3054 \f
3055 (defvar bidi-paragraph-direction)
3056
3057 (defun gnus-summary-mode (&optional group)
3058 "Major mode for reading articles.
3059
3060 All normal editing commands are switched off.
3061 \\<gnus-summary-mode-map>
3062 Each line in this buffer represents one article. To read an
3063 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3064 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3065 respectively.
3066
3067 You can also post articles and send mail from this buffer. To
3068 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3069 of an article, type `\\[gnus-summary-reply]'.
3070
3071 There are approx. one gazillion commands you can execute in this
3072 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3073
3074 The following commands are available:
3075
3076 \\{gnus-summary-mode-map}"
3077 (interactive)
3078 (kill-all-local-variables)
3079 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3080 (gnus-summary-make-local-variables))
3081 (gnus-summary-make-local-variables)
3082 (setq gnus-newsgroup-name group)
3083 (when (gnus-visual-p 'summary-menu 'menu)
3084 (gnus-summary-make-menu-bar)
3085 (gnus-summary-make-tool-bar))
3086 (gnus-make-thread-indent-array)
3087 (gnus-simplify-mode-line)
3088 (setq major-mode 'gnus-summary-mode)
3089 (setq mode-name "Summary")
3090 (use-local-map gnus-summary-mode-map)
3091 (buffer-disable-undo)
3092 (setq buffer-read-only t ;Disable modification
3093 show-trailing-whitespace nil)
3094 (setq truncate-lines t)
3095 ;; Force paragraph direction to be left-to-right. Don't make it
3096 ;; bound globally in old Emacsen and XEmacsen.
3097 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3098 (add-to-invisibility-spec '(gnus-sum . t))
3099 (gnus-summary-set-display-table)
3100 (gnus-set-default-directory)
3101 (make-local-variable 'gnus-summary-line-format)
3102 (make-local-variable 'gnus-summary-line-format-spec)
3103 (make-local-variable 'gnus-summary-dummy-line-format)
3104 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3105 (make-local-variable 'gnus-summary-mark-positions)
3106 (gnus-make-local-hook 'pre-command-hook)
3107 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3108 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3109 (turn-on-gnus-mailing-list-mode)
3110 (mm-enable-multibyte)
3111 (set (make-local-variable 'bookmark-make-record-function)
3112 'gnus-summary-bookmark-make-record)
3113 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3114 (gnus-update-summary-mark-positions))
3115
3116 (defun gnus-summary-make-local-variables ()
3117 "Make all the local summary buffer variables."
3118 (let (global)
3119 (dolist (local gnus-summary-local-variables)
3120 (if (consp local)
3121 (progn
3122 (if (eq (cdr local) 'global)
3123 ;; Copy the global value of the variable.
3124 (setq global (symbol-value (car local)))
3125 ;; Use the value from the list.
3126 (setq global (eval (cdr local))))
3127 (set (make-local-variable (car local)) global))
3128 ;; Simple nil-valued local variable.
3129 (set (make-local-variable local) nil)))))
3130
3131 ;; Summary data functions.
3132
3133 (defmacro gnus-data-number (data)
3134 `(car ,data))
3135
3136 (defmacro gnus-data-set-number (data number)
3137 `(setcar ,data ,number))
3138
3139 (defmacro gnus-data-mark (data)
3140 `(nth 1 ,data))
3141
3142 (defmacro gnus-data-set-mark (data mark)
3143 `(setcar (nthcdr 1 ,data) ,mark))
3144
3145 (defmacro gnus-data-pos (data)
3146 `(nth 2 ,data))
3147
3148 (defmacro gnus-data-set-pos (data pos)
3149 `(setcar (nthcdr 2 ,data) ,pos))
3150
3151 (defmacro gnus-data-header (data)
3152 `(nth 3 ,data))
3153
3154 (defmacro gnus-data-set-header (data header)
3155 `(setf (nth 3 ,data) ,header))
3156
3157 (defmacro gnus-data-level (data)
3158 `(nth 4 ,data))
3159
3160 (defmacro gnus-data-unread-p (data)
3161 `(= (nth 1 ,data) gnus-unread-mark))
3162
3163 (defmacro gnus-data-read-p (data)
3164 `(/= (nth 1 ,data) gnus-unread-mark))
3165
3166 (defmacro gnus-data-pseudo-p (data)
3167 `(consp (nth 3 ,data)))
3168
3169 (defmacro gnus-data-find (number)
3170 `(assq ,number gnus-newsgroup-data))
3171
3172 (defmacro gnus-data-find-list (number &optional data)
3173 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3174 (memq (assq ,number bdata)
3175 bdata)))
3176
3177 (defmacro gnus-data-make (number mark pos header level)
3178 `(list ,number ,mark ,pos ,header ,level))
3179
3180 (defun gnus-data-enter (after-article number mark pos header level offset)
3181 (let ((data (gnus-data-find-list after-article)))
3182 (unless data
3183 (error "No such article: %d" after-article))
3184 (setcdr data (cons (gnus-data-make number mark pos header level)
3185 (cdr data)))
3186 (setq gnus-newsgroup-data-reverse nil)
3187 (gnus-data-update-list (cddr data) offset)))
3188
3189 (defun gnus-data-enter-list (after-article list &optional offset)
3190 (when list
3191 (let ((data (and after-article (gnus-data-find-list after-article)))
3192 (ilist list))
3193 (if (not (or data
3194 after-article))
3195 (let ((odata gnus-newsgroup-data))
3196 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3197 (when offset
3198 (gnus-data-update-list odata offset)))
3199 ;; Find the last element in the list to be spliced into the main
3200 ;; list.
3201 (setq list (last list))
3202 (if (not data)
3203 (progn
3204 (setcdr list gnus-newsgroup-data)
3205 (setq gnus-newsgroup-data ilist)
3206 (when offset
3207 (gnus-data-update-list (cdr list) offset)))
3208 (setcdr list (cdr data))
3209 (setcdr data ilist)
3210 (when offset
3211 (gnus-data-update-list (cdr list) offset))))
3212 (setq gnus-newsgroup-data-reverse nil))))
3213
3214 (defun gnus-data-remove (article &optional offset)
3215 (let ((data gnus-newsgroup-data))
3216 (if (= (gnus-data-number (car data)) article)
3217 (progn
3218 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3219 gnus-newsgroup-data-reverse nil)
3220 (when offset
3221 (gnus-data-update-list gnus-newsgroup-data offset)))
3222 (while (cdr data)
3223 (when (= (gnus-data-number (cadr data)) article)
3224 (setcdr data (cddr data))
3225 (when offset
3226 (gnus-data-update-list (cdr data) offset))
3227 (setq data nil
3228 gnus-newsgroup-data-reverse nil))
3229 (setq data (cdr data))))))
3230
3231 (defmacro gnus-data-list (backward)
3232 `(if ,backward
3233 (or gnus-newsgroup-data-reverse
3234 (setq gnus-newsgroup-data-reverse
3235 (reverse gnus-newsgroup-data)))
3236 gnus-newsgroup-data))
3237
3238 (defun gnus-data-update-list (data offset)
3239 "Add OFFSET to the POS of all data entries in DATA."
3240 (setq gnus-newsgroup-data-reverse nil)
3241 (while data
3242 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3243 (setq data (cdr data))))
3244
3245 (defun gnus-summary-article-pseudo-p (article)
3246 "Say whether this article is a pseudo article or not."
3247 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3248
3249 (defmacro gnus-summary-article-sparse-p (article)
3250 "Say whether this article is a sparse article or not."
3251 `(memq ,article gnus-newsgroup-sparse))
3252
3253 (defmacro gnus-summary-article-ancient-p (article)
3254 "Say whether this article is a sparse article or not."
3255 `(memq ,article gnus-newsgroup-ancient))
3256
3257 (defun gnus-article-children (number)
3258 "Return a list of all children to NUMBER."
3259 (let* ((data (gnus-data-find-list number))
3260 (level (gnus-data-level (car data)))
3261 children)
3262 (setq data (cdr data))
3263 (while (and data
3264 (= (gnus-data-level (car data)) (1+ level)))
3265 (push (gnus-data-number (car data)) children)
3266 (setq data (cdr data)))
3267 children))
3268
3269 (defmacro gnus-summary-skip-intangible ()
3270 "If the current article is intangible, then jump to a different article."
3271 '(let ((to (get-text-property (point) 'gnus-intangible)))
3272 (and to (gnus-summary-goto-subject to))))
3273
3274 (defmacro gnus-summary-article-intangible-p ()
3275 "Say whether this article is intangible or not."
3276 '(get-text-property (point) 'gnus-intangible))
3277
3278 ;; Some summary mode macros.
3279
3280 (defmacro gnus-summary-article-number ()
3281 "The article number of the article on the current line.
3282 If there isn't an article number here, then we return the current
3283 article number."
3284 '(progn
3285 (gnus-summary-skip-intangible)
3286 (or (get-text-property (point) 'gnus-number)
3287 (gnus-summary-last-subject))))
3288
3289 (defmacro gnus-summary-article-header (&optional number)
3290 "Return the header of article NUMBER."
3291 `(gnus-data-header (gnus-data-find
3292 ,(or number '(gnus-summary-article-number)))))
3293
3294 (defmacro gnus-summary-thread-level (&optional number)
3295 "Return the level of thread that starts with article NUMBER."
3296 `(if (and (eq gnus-summary-make-false-root 'dummy)
3297 (get-text-property (point) 'gnus-intangible))
3298 0
3299 (gnus-data-level (gnus-data-find
3300 ,(or number '(gnus-summary-article-number))))))
3301
3302 (defmacro gnus-summary-article-mark (&optional number)
3303 "Return the mark of article NUMBER."
3304 `(gnus-data-mark (gnus-data-find
3305 ,(or number '(gnus-summary-article-number)))))
3306
3307 (defmacro gnus-summary-article-pos (&optional number)
3308 "Return the position of the line of article NUMBER."
3309 `(gnus-data-pos (gnus-data-find
3310 ,(or number '(gnus-summary-article-number)))))
3311
3312 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3313 (defmacro gnus-summary-article-subject (&optional number)
3314 "Return current subject string or nil if nothing."
3315 `(let ((headers
3316 ,(if number
3317 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3318 '(gnus-data-header (assq (gnus-summary-article-number)
3319 gnus-newsgroup-data)))))
3320 (and headers
3321 (vectorp headers)
3322 (mail-header-subject headers))))
3323
3324 (defmacro gnus-summary-article-score (&optional number)
3325 "Return current article score."
3326 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3327 gnus-newsgroup-scored))
3328 gnus-summary-default-score 0))
3329
3330 (defun gnus-summary-article-children (&optional number)
3331 "Return a list of article numbers that are children of article NUMBER."
3332 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3333 (level (gnus-data-level (car data)))
3334 l children)
3335 (while (and (setq data (cdr data))
3336 (> (setq l (gnus-data-level (car data))) level))
3337 (and (= (1+ level) l)
3338 (push (gnus-data-number (car data))
3339 children)))
3340 (nreverse children)))
3341
3342 (defun gnus-summary-article-parent (&optional number)
3343 "Return the article number of the parent of article NUMBER."
3344 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3345 (gnus-data-list t)))
3346 (level (gnus-data-level (car data))))
3347 (if (zerop level)
3348 () ; This is a root.
3349 ;; We search until we find an article with a level less than
3350 ;; this one. That function has to be the parent.
3351 (while (and (setq data (cdr data))
3352 (not (< (gnus-data-level (car data)) level))))
3353 (and data (gnus-data-number (car data))))))
3354
3355 (defun gnus-unread-mark-p (mark)
3356 "Say whether MARK is the unread mark."
3357 (= mark gnus-unread-mark))
3358
3359 (defun gnus-read-mark-p (mark)
3360 "Say whether MARK is one of the marks that mark as read.
3361 This is all marks except unread, ticked, dormant, and expirable."
3362 (not (or (= mark gnus-unread-mark)
3363 (= mark gnus-ticked-mark)
3364 (= mark gnus-spam-mark)
3365 (= mark gnus-dormant-mark)
3366 (= mark gnus-expirable-mark))))
3367
3368 (defmacro gnus-article-mark (number)
3369 "Return the MARK of article NUMBER.
3370 This macro should only be used when computing the mark the \"first\"
3371 time; i.e., when generating the summary lines. After that,
3372 `gnus-summary-article-mark' should be used to examine the
3373 marks of articles."
3374 `(cond
3375 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3376 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3377 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3378 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3379 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3380 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3381 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3382 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3383 gnus-ancient-mark))))
3384
3385 ;; Saving hidden threads.
3386
3387 (defmacro gnus-save-hidden-threads (&rest forms)
3388 "Save hidden threads, eval FORMS, and restore the hidden threads."
3389 (let ((config (make-symbol "config")))
3390 `(let ((,config (gnus-hidden-threads-configuration)))
3391 (unwind-protect
3392 (save-excursion
3393 ,@forms)
3394 (gnus-restore-hidden-threads-configuration ,config)))))
3395 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3396 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3397
3398 (defun gnus-data-compute-positions ()
3399 "Compute the positions of all articles."
3400 (setq gnus-newsgroup-data-reverse nil)
3401 (let ((data gnus-newsgroup-data))
3402 (save-excursion
3403 (gnus-save-hidden-threads
3404 (gnus-summary-show-all-threads)
3405 (goto-char (point-min))
3406 (while data
3407 (while (get-text-property (point) 'gnus-intangible)
3408 (forward-line 1))
3409 (gnus-data-set-pos (car data) (+ (point) 3))
3410 (setq data (cdr data))
3411 (forward-line 1))))))
3412
3413 (defun gnus-hidden-threads-configuration ()
3414 "Return the current hidden threads configuration."
3415 (save-excursion
3416 (let (config)
3417 (goto-char (point-min))
3418 (while (not (eobp))
3419 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3420 (push (save-excursion (forward-line 0) (point)) config))
3421 (forward-line 1))
3422 config)))
3423
3424 (defun gnus-restore-hidden-threads-configuration (config)
3425 "Restore hidden threads configuration from CONFIG."
3426 (save-excursion
3427 (let (point (inhibit-read-only t))
3428 (while (setq point (pop config))
3429 (goto-char point)
3430 (gnus-summary-hide-thread)))))
3431
3432 ;; Various summary mode internalish functions.
3433
3434 (defun gnus-mouse-pick-article (e)
3435 (interactive "e")
3436 (mouse-set-point e)
3437 (gnus-summary-next-page nil t))
3438
3439 (defun gnus-summary-set-display-table ()
3440 "Change the display table.
3441 Odd characters have a tendency to mess
3442 up nicely formatted displays - we make all possible glyphs
3443 display only a single character."
3444
3445 ;; We start from the standard display table, if any.
3446 (let ((table (or (copy-sequence standard-display-table)
3447 (make-display-table)))
3448 (i 32))
3449 ;; Nix out all the control chars...
3450 (while (>= (setq i (1- i)) 0)
3451 (gnus-put-display-table i [??] table))
3452 ;; ... but not newline and cr, of course. (cr is necessary for the
3453 ;; selective display).
3454 (gnus-put-display-table ?\n nil table)
3455 (gnus-put-display-table ?\r nil table)
3456 ;; We keep TAB as well.
3457 (gnus-put-display-table ?\t nil table)
3458 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3459 ;; Emacs 23 (unicode), that are not set already.
3460 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3461 160
3462 256)))
3463 (while (>= (setq i (1- i)) 127)
3464 ;; Only modify if the entry is nil.
3465 (unless (gnus-get-display-table i table)
3466 (gnus-put-display-table i [??] table))))
3467 (setq buffer-display-table table)))
3468
3469 (defun gnus-summary-set-article-display-arrow (pos)
3470 "Update the overlay arrow to point to line at position POS."
3471 (when gnus-summary-display-arrow
3472 (make-local-variable 'overlay-arrow-position)
3473 (make-local-variable 'overlay-arrow-string)
3474 (save-excursion
3475 (goto-char pos)
3476 (beginning-of-line)
3477 (unless overlay-arrow-position
3478 (setq overlay-arrow-position (make-marker)))
3479 (setq overlay-arrow-string "=>"
3480 overlay-arrow-position (set-marker overlay-arrow-position
3481 (point)
3482 (current-buffer))))))
3483
3484 (defun gnus-summary-setup-buffer (group)
3485 "Initialize summary buffer.
3486 If the setup was successful, non-nil is returned."
3487 (let ((buffer (gnus-summary-buffer-name group))
3488 (dead-name (concat "*Dead Summary "
3489 (gnus-group-decoded-name group) "*")))
3490 ;; If a dead summary buffer exists, we kill it.
3491 (when (gnus-buffer-live-p dead-name)
3492 (gnus-kill-buffer dead-name))
3493 (if (get-buffer buffer)
3494 (progn
3495 (set-buffer buffer)
3496 (setq gnus-summary-buffer (current-buffer))
3497 (not gnus-newsgroup-prepared))
3498 (set-buffer (gnus-get-buffer-create buffer))
3499 (setq gnus-summary-buffer (current-buffer))
3500 (gnus-summary-mode group)
3501 (when (gnus-group-quit-config group)
3502 (set (make-local-variable 'gnus-single-article-buffer) nil))
3503 (make-local-variable 'gnus-article-buffer)
3504 (make-local-variable 'gnus-article-current)
3505 (make-local-variable 'gnus-original-article-buffer)
3506 (setq gnus-newsgroup-name group)
3507 ;; Set any local variables in the group parameters.
3508 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3509 t)))
3510
3511 (defun gnus-set-global-variables ()
3512 "Set the global equivalents of the buffer-local variables.
3513 They are set to the latest values they had. These reflect the summary
3514 buffer that was in action when the last article was fetched."
3515 (when (eq major-mode 'gnus-summary-mode)
3516 (setq gnus-summary-buffer (current-buffer))
3517 (let ((name gnus-newsgroup-name)
3518 (marked gnus-newsgroup-marked)
3519 (spam gnus-newsgroup-spam-marked)
3520 (unread gnus-newsgroup-unreads)
3521 (headers gnus-current-headers)
3522 (data gnus-newsgroup-data)
3523 (summary gnus-summary-buffer)
3524 (article-buffer gnus-article-buffer)
3525 (original gnus-original-article-buffer)
3526 (gac gnus-article-current)
3527 (reffed gnus-reffed-article-number)
3528 (score-file gnus-current-score-file)
3529 (default-charset gnus-newsgroup-charset)
3530 vlist)
3531 (let ((locals gnus-newsgroup-variables))
3532 (while locals
3533 (if (consp (car locals))
3534 (push (eval (caar locals)) vlist)
3535 (push (eval (car locals)) vlist))
3536 (setq locals (cdr locals)))
3537 (setq vlist (nreverse vlist)))
3538 (with-temp-buffer
3539 (setq gnus-newsgroup-name name
3540 gnus-newsgroup-marked marked
3541 gnus-newsgroup-spam-marked spam
3542 gnus-newsgroup-unreads unread
3543 gnus-current-headers headers
3544 gnus-newsgroup-data data
3545 gnus-article-current gac
3546 gnus-summary-buffer summary
3547 gnus-article-buffer article-buffer
3548 gnus-original-article-buffer original
3549 gnus-reffed-article-number reffed
3550 gnus-current-score-file score-file
3551 gnus-newsgroup-charset default-charset)
3552 (let ((locals gnus-newsgroup-variables))
3553 (while locals
3554 (if (consp (car locals))
3555 (set (caar locals) (pop vlist))
3556 (set (car locals) (pop vlist)))
3557 (setq locals (cdr locals))))))))
3558
3559 (defun gnus-summary-article-unread-p (article)
3560 "Say whether ARTICLE is unread or not."
3561 (memq article gnus-newsgroup-unreads))
3562
3563 (defun gnus-summary-first-article-p (&optional article)
3564 "Return whether ARTICLE is the first article in the buffer."
3565 (if (not (setq article (or article (gnus-summary-article-number))))
3566 nil
3567 (eq article (caar gnus-newsgroup-data))))
3568
3569 (defun gnus-summary-last-article-p (&optional article)
3570 "Return whether ARTICLE is the last article in the buffer."
3571 (if (not (setq article (or article (gnus-summary-article-number))))
3572 ;; All non-existent numbers are the last article. :-)
3573 t
3574 (not (cdr (gnus-data-find-list article)))))
3575
3576 (defun gnus-make-thread-indent-array (&optional n)
3577 (when (or n
3578 (progn (setq n 200) nil)
3579 (null gnus-thread-indent-array)
3580 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3581 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3582 gnus-thread-indent-array-level gnus-thread-indent-level)
3583 (while (>= n 0)
3584 (aset gnus-thread-indent-array n
3585 (make-string (* n gnus-thread-indent-level) ? ))
3586 (setq n (1- n)))))
3587
3588 (defun gnus-update-summary-mark-positions ()
3589 "Compute where the summary marks are to go."
3590 (save-excursion
3591 (when (gnus-buffer-exists-p gnus-summary-buffer)
3592 (set-buffer gnus-summary-buffer))
3593 (let ((spec gnus-summary-line-format-spec)
3594 pos)
3595 (save-excursion
3596 (gnus-set-work-buffer)
3597 (let ((gnus-tmp-unread ?Z)
3598 (gnus-replied-mark ?Z)
3599 (gnus-score-below-mark ?Z)
3600 (gnus-score-over-mark ?Z)
3601 (gnus-undownloaded-mark ?Z)
3602 (gnus-summary-line-format-spec spec)
3603 (gnus-newsgroup-downloadable '(0))
3604 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3605 case-fold-search ignores)
3606 ;; Here, all marks are bound to Z.
3607 (gnus-summary-insert-line header
3608 0 nil t gnus-tmp-unread t nil "" nil 1)
3609 (goto-char (point-min))
3610 ;; Memorize the positions of the same characters as dummy marks.
3611 (while (re-search-forward "[A-D]" nil t)
3612 (push (point) ignores))
3613 (erase-buffer)
3614 ;; We use A-D as dummy marks in order to know column positions
3615 ;; where marks should be inserted.
3616 (setq gnus-tmp-unread ?A
3617 gnus-replied-mark ?B
3618 gnus-score-below-mark ?C
3619 gnus-score-over-mark ?C
3620 gnus-undownloaded-mark ?D)
3621 (gnus-summary-insert-line header
3622 0 nil t gnus-tmp-unread t nil "" nil 1)
3623 ;; Ignore characters which aren't dummy marks.
3624 (dolist (p ignores)
3625 (delete-region (goto-char (1- p)) p)
3626 (insert ?Z))
3627 (goto-char (point-min))
3628 (setq pos (list (cons 'unread
3629 (and (search-forward "A" nil t)
3630 (- (point) (point-min) 1)))))
3631 (goto-char (point-min))
3632 (push (cons 'replied (and (search-forward "B" nil t)
3633 (- (point) (point-min) 1)))
3634 pos)
3635 (goto-char (point-min))
3636 (push (cons 'score (and (search-forward "C" nil t)
3637 (- (point) (point-min) 1)))
3638 pos)
3639 (goto-char (point-min))
3640 (push (cons 'download (and (search-forward "D" nil t)
3641 (- (point) (point-min) 1)))
3642 pos)))
3643 (setq gnus-summary-mark-positions pos))))
3644
3645 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3646 "Insert a dummy root in the summary buffer."
3647 (beginning-of-line)
3648 (gnus-add-text-properties
3649 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3650 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3651
3652 (defun gnus-summary-extract-address-component (from)
3653 (or (car (funcall gnus-extract-address-components from))
3654 from))
3655
3656 (defun gnus-summary-from-or-to-or-newsgroups (header from)
3657 (let ((mail-parse-charset gnus-newsgroup-charset)
3658 (ignored-from-addresses (gnus-ignored-from-addresses))
3659 ;; Is it really necessary to do this next part for each summary line?
3660 ;; Luckily, doesn't seem to slow things down much.
3661 (mail-parse-ignored-charsets
3662 (with-current-buffer gnus-summary-buffer
3663 gnus-newsgroup-ignored-charsets))
3664 (address (cadr (gnus-extract-address-components from))))
3665 (or
3666 (and ignored-from-addresses
3667 (string-match ignored-from-addresses address)
3668 (let ((extra-headers (mail-header-extra header))
3669 to
3670 newsgroups)
3671 (cond
3672 ((setq to (cdr (assq 'To extra-headers)))
3673 (concat gnus-summary-to-prefix
3674 (inline
3675 (gnus-summary-extract-address-component
3676 (funcall gnus-decode-encoded-address-function to)))))
3677 ((setq newsgroups
3678 (or
3679 (cdr (assq 'Newsgroups extra-headers))
3680 (and
3681 (memq 'Newsgroups gnus-extra-headers)
3682 (eq (car (gnus-find-method-for-group
3683 gnus-newsgroup-name)) 'nntp)
3684 (gnus-group-real-name gnus-newsgroup-name))))
3685 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3686 (gnus-string-mark-left-to-right (gnus-summary-extract-address-component from)))))
3687
3688 (defun gnus-summary-insert-line (gnus-tmp-header
3689 gnus-tmp-level gnus-tmp-current
3690 undownloaded gnus-tmp-unread gnus-tmp-replied
3691 gnus-tmp-expirable gnus-tmp-subject-or-nil
3692 &optional gnus-tmp-dummy gnus-tmp-score
3693 gnus-tmp-process)
3694 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3695 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3696 gnus-tmp-level)))
3697 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3698 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3699 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3700 (gnus-tmp-score-char
3701 (if (or (null gnus-summary-default-score)
3702 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3703 gnus-summary-zcore-fuzz))
3704 ? ;Whitespace
3705 (if (< gnus-tmp-score gnus-summary-default-score)
3706 gnus-score-below-mark gnus-score-over-mark)))
3707 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3708 (gnus-tmp-replied
3709 (cond (gnus-tmp-process gnus-process-mark)
3710 ((memq gnus-tmp-current gnus-newsgroup-cached)
3711 gnus-cached-mark)
3712 (gnus-tmp-replied gnus-replied-mark)
3713 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3714 gnus-forwarded-mark)
3715 ((memq gnus-tmp-current gnus-newsgroup-saved)
3716 gnus-saved-mark)
3717 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3718 gnus-unseen-mark)
3719 (t gnus-no-mark)))
3720 (gnus-tmp-downloaded
3721 (cond (undownloaded
3722 gnus-undownloaded-mark)
3723 (gnus-newsgroup-agentized
3724 gnus-downloaded-mark)
3725 (t
3726 gnus-no-mark)))
3727 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3728 (gnus-tmp-name
3729 (cond
3730 ((string-match "<[^>]+> *$" gnus-tmp-from)
3731 (let ((beg (match-beginning 0)))
3732 (or (and (string-match "^\".+\"" gnus-tmp-from)
3733 (substring gnus-tmp-from 1 (1- (match-end 0))))
3734 (substring gnus-tmp-from 0 beg))))
3735 ((string-match "(.+)" gnus-tmp-from)
3736 (substring gnus-tmp-from
3737 (1+ (match-beginning 0)) (1- (match-end 0))))
3738 (t gnus-tmp-from)))
3739 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3740 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3741 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3742 (inhibit-read-only t))
3743 (when (string= gnus-tmp-name "")
3744 (setq gnus-tmp-name gnus-tmp-from))
3745 (unless (numberp gnus-tmp-lines)
3746 (setq gnus-tmp-lines -1))
3747 (if (= gnus-tmp-lines -1)
3748 (setq gnus-tmp-lines "?")
3749 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3750 (condition-case ()
3751 (gnus-put-text-property
3752 (point)
3753 (progn (eval gnus-summary-line-format-spec) (point))
3754 'gnus-number gnus-tmp-number)
3755 (error (gnus-message 5 "Error updating the summary line")))
3756 (when (gnus-visual-p 'summary-highlight 'highlight)
3757 (forward-line -1)
3758 (gnus-summary-highlight-line)
3759 (gnus-run-hooks 'gnus-summary-update-hook)
3760 (forward-line 1))))
3761
3762 (defun gnus-summary-update-line (&optional dont-update)
3763 "Update summary line after change."
3764 (when (and gnus-summary-default-score
3765 (not gnus-summary-inhibit-highlight))
3766 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3767 (article (gnus-summary-article-number))
3768 (score (gnus-summary-article-score article)))
3769 (unless dont-update
3770 (if (and gnus-summary-mark-below
3771 (< (gnus-summary-article-score)
3772 gnus-summary-mark-below))
3773 ;; This article has a low score, so we mark it as read.
3774 (when (memq article gnus-newsgroup-unreads)
3775 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3776 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3777 ;; This article was previously marked as read on account
3778 ;; of a low score, but now it has risen, so we mark it as
3779 ;; unread.
3780 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3781 (gnus-summary-update-mark
3782 (if (or (null gnus-summary-default-score)
3783 (<= (abs (- score gnus-summary-default-score))
3784 gnus-summary-zcore-fuzz))
3785 ? ;Whitespace
3786 (if (< score gnus-summary-default-score)
3787 gnus-score-below-mark gnus-score-over-mark))
3788 'score))
3789 ;; Do visual highlighting.
3790 (when (gnus-visual-p 'summary-highlight 'highlight)
3791 (gnus-summary-highlight-line)
3792 (gnus-run-hooks 'gnus-summary-update-hook)))))
3793
3794 (defvar gnus-tmp-new-adopts nil)
3795
3796 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3797 "Return the number of articles in THREAD.
3798 This may be 0 in some cases -- if none of the articles in
3799 the thread are to be displayed."
3800 (let* ((number
3801 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3802 (cond
3803 ((not (listp thread))
3804 1)
3805 ((and (consp thread) (cdr thread))
3806 (apply
3807 '+ 1 (mapcar
3808 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3809 ((null thread)
3810 1)
3811 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3812 1)
3813 (t 0))))
3814 (when (and level (zerop level) gnus-tmp-new-adopts)
3815 (incf number
3816 (apply '+ (mapcar
3817 'gnus-summary-number-of-articles-in-thread
3818 gnus-tmp-new-adopts))))
3819 (if char
3820 (if (> number 1) gnus-not-empty-thread-mark
3821 gnus-empty-thread-mark)
3822 number)))
3823
3824 (defsubst gnus-summary-line-message-size (head)
3825 "Return pretty-printed version of message size.
3826 This function is intended to be used in
3827 `gnus-summary-line-format-alist'."
3828 (let ((c (or (mail-header-chars head) -1)))
3829 (cond ((< c 0) "n/a") ; chars not available
3830 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3831 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3832 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3833 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3834
3835 (defcustom gnus-user-date-format-alist
3836 '(((gnus-seconds-today) . "Today, %H:%M")
3837 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3838 (604800 . "%A %H:%M") ; That's one week
3839 ((gnus-seconds-month) . "%A %d")
3840 ((gnus-seconds-year) . "%B %d")
3841 (t . "%b %d %Y")) ; This one is used when no other
3842 ; does match
3843 "Specifies date format depending on age of article.
3844 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3845 seconds) or a Lisp expression evaluating to a number. When the age of
3846 the article is less than this number, then use `format-time-string'
3847 with the corresponding FORMAT for displaying the date of the article.
3848 If AGE is not a number or a Lisp expression evaluating to a
3849 non-number, then the corresponding FORMAT is used as a default value.
3850
3851 Note that the list is processed from the beginning, so it should be
3852 sorted by ascending AGE. Also note that items following the first
3853 non-number AGE will be ignored.
3854
3855 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3856 and `gnus-seconds-year' in the AGE spec. They return the number of
3857 seconds passed since the start of today, of this month, of this year,
3858 respectively."
3859 :version "24.1"
3860 :group 'gnus-summary-format
3861 :type '(alist :key-type sexp :value-type string))
3862
3863 (defun gnus-user-date (messy-date)
3864 "Format the messy-date according to `gnus-user-date-format-alist'.
3865 Returns \" ? \" if there's bad input or if another error occurs.
3866 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3867 (condition-case ()
3868 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3869 (now (gnus-float-time))
3870 ;;If we don't find something suitable we'll use this one
3871 (my-format "%b %d '%y"))
3872 (let* ((difference (- now messy-date))
3873 (templist gnus-user-date-format-alist)
3874 (top (eval (caar templist))))
3875 (while (if (numberp top) (< top difference) (not top))
3876 (progn
3877 (setq templist (cdr templist))
3878 (setq top (eval (caar templist)))))
3879 (if (stringp (cdr (car templist)))
3880 (setq my-format (cdr (car templist)))))
3881 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3882 (error " ? ")))
3883
3884 (defun gnus-summary-set-local-parameters (group)
3885 "Go through the local params of GROUP and set all variable specs in that list."
3886 (let ((vars '(quit-config active))) ; Ignore things that aren't
3887 ; really variables.
3888 (dolist (elem (gnus-group-find-parameter group))
3889 (and (consp elem) ; Has to be a cons.
3890 (consp (cdr elem)) ; The cdr has to be a list.
3891 (symbolp (car elem)) ; Has to be a symbol in there.
3892 (not (memq (car elem) vars))
3893 (ignore-errors
3894 (push (car elem) vars)
3895 ;; Variables like `gnus-show-threads' that are globally
3896 ;; bound, if used as group parameters, need to get to be
3897 ;; buffer-local, whereas just parameters like `gcc-self',
3898 ;; `timestamp', etc. should not be bound as variables.
3899 (if (boundp (car elem))
3900 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3901 (eval (nth 1 elem))))))))
3902
3903 (defun gnus-summary-read-group (group &optional show-all no-article
3904 kill-buffer no-display backward
3905 select-articles)
3906 "Start reading news in newsgroup GROUP.
3907 If SHOW-ALL is non-nil, already read articles are also listed.
3908 If NO-ARTICLE is non-nil, no article is selected initially.
3909 If NO-DISPLAY, don't generate the summary buffer contents.
3910 If KILL-BUFFER, it should be a buffer that's killed once the new
3911 summary buffer has been generated.
3912 If BACKWARD, move point to the previous group in the group buffer
3913 If SELECT-ARTICLES, only select those articles from GROUP."
3914 (let (result)
3915 (while (and group
3916 (null (setq result
3917 (let ((gnus-auto-select-next nil))
3918 (or (gnus-summary-read-group-1
3919 group show-all no-article
3920 kill-buffer no-display
3921 select-articles)
3922 (setq show-all nil
3923 select-articles nil)))))
3924 (eq gnus-auto-select-next 'quietly))
3925 (set-buffer gnus-group-buffer)
3926 ;; The entry function called above goes to the next
3927 ;; group automatically, so we go two groups back
3928 ;; if we are searching for the previous group.
3929 (when backward
3930 (gnus-group-prev-unread-group 2))
3931 (if (not (equal group (gnus-group-group-name)))
3932 (setq group (gnus-group-group-name))
3933 (setq group nil)))
3934 result))
3935
3936 (defun gnus-summary-read-group-1 (group show-all no-article
3937 kill-buffer no-display
3938 &optional select-articles)
3939 ;; Killed foreign groups can't be entered.
3940 ;; (when (and (not (gnus-group-native-p group))
3941 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3942 ;; (error "Dead non-native groups can't be entered"))
3943 (gnus-message 7 "Retrieving newsgroup: %s..."
3944 (gnus-group-decoded-name group))
3945 (let* ((new-group (gnus-summary-setup-buffer group))
3946 (quit-config (gnus-group-quit-config group))
3947 (did-select (and new-group (gnus-select-newsgroup
3948 group show-all select-articles))))
3949 (cond
3950 ;; This summary buffer exists already, so we just select it.
3951 ((not new-group)
3952 (gnus-set-global-variables)
3953 (when kill-buffer
3954 (gnus-kill-or-deaden-summary kill-buffer))
3955 (gnus-configure-windows 'summary 'force)
3956 (gnus-set-mode-line 'summary)
3957 (gnus-summary-position-point)
3958 (message "")
3959 t)
3960 ;; We couldn't select this group.
3961 ((null did-select)
3962 (when (and (eq major-mode 'gnus-summary-mode)
3963 (not (equal (current-buffer) kill-buffer)))
3964 (kill-buffer (current-buffer))
3965 (if (not quit-config)
3966 (progn
3967 ;; Update the info -- marks might need to be removed,
3968 ;; for instance.
3969 (gnus-summary-update-info)
3970 (set-buffer gnus-group-buffer)
3971 (gnus-group-jump-to-group group)
3972 (gnus-group-next-unread-group 1))
3973 (gnus-handle-ephemeral-exit quit-config)))
3974 (if (null (gnus-list-of-unread-articles group))
3975 (gnus-message 3 "Group %s contains no messages" group)
3976 (gnus-message 3 "Can't select group"))
3977 nil)
3978 ;; The user did a `C-g' while prompting for number of articles,
3979 ;; so we exit this group.
3980 ((eq did-select 'quit)
3981 (and (eq major-mode 'gnus-summary-mode)
3982 (not (equal (current-buffer) kill-buffer))
3983 (kill-buffer (current-buffer)))
3984 (when kill-buffer
3985 (gnus-kill-or-deaden-summary kill-buffer))
3986 (if (not quit-config)
3987 (progn
3988 (set-buffer gnus-group-buffer)
3989 (gnus-group-jump-to-group group)
3990 (gnus-configure-windows 'group 'force))
3991 (gnus-handle-ephemeral-exit quit-config))
3992 ;; Finally signal the quit.
3993 (signal 'quit nil))
3994 ;; The group was successfully selected.
3995 (t
3996 (gnus-set-global-variables)
3997 ;; Save the active value in effect when the group was entered.
3998 (setq gnus-newsgroup-active
3999 (gnus-copy-sequence
4000 (gnus-active gnus-newsgroup-name)))
4001 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4002 ;; You can change the summary buffer in some way with this hook.
4003 (gnus-run-hooks 'gnus-select-group-hook)
4004 (when (memq 'summary (gnus-update-format-specifications
4005 nil 'summary 'summary-mode 'summary-dummy))
4006 ;; The format specification for the summary line was updated,
4007 ;; so we need to update the mark positions as well.
4008 (gnus-update-summary-mark-positions))
4009 ;; Do score processing.
4010 (when gnus-use-scoring
4011 (gnus-possibly-score-headers))
4012 ;; Check whether to fill in the gaps in the threads.
4013 (when gnus-build-sparse-threads
4014 (gnus-build-sparse-threads))
4015 ;; Find the initial limit.
4016 (if show-all
4017 (let ((gnus-newsgroup-dormant nil))
4018 (gnus-summary-initial-limit show-all))
4019 (gnus-summary-initial-limit show-all))
4020 ;; Generate the summary buffer.
4021 (unless no-display
4022 (gnus-summary-prepare))
4023 (when gnus-use-trees
4024 (gnus-tree-open group)
4025 (setq gnus-summary-highlight-line-function
4026 'gnus-tree-highlight-article))
4027 ;; If the summary buffer is empty, but there are some low-scored
4028 ;; articles or some excluded dormants, we include these in the
4029 ;; buffer.
4030 (when (and (zerop (buffer-size))
4031 (not no-display))
4032 (cond (gnus-newsgroup-dormant
4033 (gnus-summary-limit-include-dormant))
4034 ((and gnus-newsgroup-scored show-all)
4035 (gnus-summary-limit-include-expunged t))))
4036 ;; Function `gnus-apply-kill-file' must be called in this hook.
4037 (gnus-run-hooks 'gnus-apply-kill-hook)
4038 (if (and (zerop (buffer-size))
4039 (not no-display))
4040 (progn
4041 ;; This newsgroup is empty.
4042 (gnus-summary-catchup-and-exit nil t)
4043 (gnus-message 6 "No unread news")
4044 (when kill-buffer
4045 (gnus-kill-or-deaden-summary kill-buffer))
4046 ;; Return nil from this function.
4047 nil)
4048 ;; Hide conversation thread subtrees. We cannot do this in
4049 ;; gnus-summary-prepare-hook since kill processing may not
4050 ;; work with hidden articles.
4051 (gnus-summary-maybe-hide-threads)
4052 (gnus-configure-windows 'summary)
4053 (when kill-buffer
4054 (gnus-kill-or-deaden-summary kill-buffer))
4055 (gnus-summary-auto-select-subject)
4056 ;; Show first unread article if requested.
4057 (if (and (not no-article)
4058 (not no-display)
4059 gnus-newsgroup-unreads
4060 gnus-auto-select-first)
4061 (progn
4062 (let ((art (gnus-summary-article-number)))
4063 (when (and art
4064 gnus-plugged
4065 (not (memq art gnus-newsgroup-undownloaded))
4066 (not (memq art gnus-newsgroup-downloadable)))
4067 (gnus-summary-goto-article art))))
4068 ;; Don't select any articles.
4069 (gnus-summary-position-point)
4070 (gnus-configure-windows 'summary 'force)
4071 (gnus-set-mode-line 'summary))
4072 (when (and gnus-auto-center-group
4073 (get-buffer-window gnus-group-buffer t))
4074 ;; Gotta use windows, because recenter does weird stuff if
4075 ;; the current buffer ain't the displayed window.
4076 (let ((owin (selected-window)))
4077 (select-window (get-buffer-window gnus-group-buffer t))
4078 (when (gnus-group-goto-group group)
4079 (recenter))
4080 (select-window owin)))
4081 ;; Mark this buffer as "prepared".
4082 (setq gnus-newsgroup-prepared t)
4083 (gnus-run-hooks 'gnus-summary-prepared-hook)
4084 (unless (gnus-ephemeral-group-p group)
4085 (gnus-group-update-group group nil t))
4086 t)))))
4087
4088 (defun gnus-summary-auto-select-subject ()
4089 "Select the subject line on initial group entry."
4090 (goto-char (point-min))
4091 (cond
4092 ((eq gnus-auto-select-subject 'best)
4093 (gnus-summary-best-unread-subject))
4094 ((eq gnus-auto-select-subject 'unread)
4095 (gnus-summary-first-unread-subject))
4096 ((eq gnus-auto-select-subject 'unseen)
4097 (gnus-summary-first-unseen-subject))
4098 ((eq gnus-auto-select-subject 'unseen-or-unread)
4099 (gnus-summary-first-unseen-or-unread-subject))
4100 ((eq gnus-auto-select-subject 'first)
4101 ;; Do nothing.
4102 )
4103 ((functionp gnus-auto-select-subject)
4104 (funcall gnus-auto-select-subject))))
4105
4106 (defun gnus-summary-prepare ()
4107 "Generate the summary buffer."
4108 (interactive)
4109 (let ((inhibit-read-only t))
4110 (erase-buffer)
4111 (setq gnus-newsgroup-data nil
4112 gnus-newsgroup-data-reverse nil)
4113 (gnus-run-hooks 'gnus-summary-generate-hook)
4114 ;; Generate the buffer, either with threads or without.
4115 (when gnus-newsgroup-headers
4116 (gnus-summary-prepare-threads
4117 (if gnus-show-threads
4118 (gnus-sort-gathered-threads
4119 (funcall gnus-summary-thread-gathering-function
4120 (gnus-sort-threads
4121 (gnus-cut-threads (gnus-make-threads)))))
4122 ;; Unthreaded display.
4123 (gnus-sort-articles gnus-newsgroup-headers))))
4124 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4125 ;; Call hooks for modifying summary buffer.
4126 (goto-char (point-min))
4127 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4128
4129 (defsubst gnus-general-simplify-subject (subject)
4130 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4131 (setq subject
4132 (cond
4133 ;; Truncate the subject.
4134 (gnus-simplify-subject-functions
4135 (gnus-map-function gnus-simplify-subject-functions subject))
4136 ((numberp gnus-summary-gather-subject-limit)
4137 (setq subject (gnus-simplify-subject-re subject))
4138 (if (> (length subject) gnus-summary-gather-subject-limit)
4139 (substring subject 0 gnus-summary-gather-subject-limit)
4140 subject))
4141 ;; Fuzzily simplify it.
4142 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4143 (gnus-simplify-subject-fuzzy subject))
4144 ;; Just remove the leading "Re:".
4145 (t
4146 (gnus-simplify-subject-re subject))))
4147
4148 (if (and gnus-summary-gather-exclude-subject
4149 (string-match gnus-summary-gather-exclude-subject subject))
4150 nil ; This article shouldn't be gathered
4151 subject))
4152
4153 (defun gnus-summary-simplify-subject-query ()
4154 "Query where the respool algorithm would put this article."
4155 (interactive)
4156 (gnus-summary-select-article)
4157 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4158
4159 (defun gnus-gather-threads-by-subject (threads)
4160 "Gather threads by looking at Subject headers."
4161 (if (not gnus-summary-make-false-root)
4162 threads
4163 (let ((hashtb (gnus-make-hashtable 1024))
4164 (prev threads)
4165 (result threads)
4166 subject hthread whole-subject)
4167 (while threads
4168 (setq subject (gnus-general-simplify-subject
4169 (setq whole-subject (mail-header-subject
4170 (caar threads)))))
4171 (when subject
4172 (if (setq hthread (gnus-gethash subject hashtb))
4173 (progn
4174 ;; We enter a dummy root into the thread, if we
4175 ;; haven't done that already.
4176 (unless (stringp (caar hthread))
4177 (setcar hthread (list whole-subject (car hthread))))
4178 ;; We add this new gathered thread to this gathered
4179 ;; thread.
4180 (setcdr (car hthread)
4181 (nconc (cdar hthread) (list (car threads))))
4182 ;; Remove it from the list of threads.
4183 (setcdr prev (cdr threads))
4184 (setq threads prev))
4185 ;; Enter this thread into the hash table.
4186 (gnus-sethash subject
4187 (if gnus-summary-make-false-root-always
4188 (progn
4189 ;; If you want a dummy root above all
4190 ;; threads...
4191 (setcar threads (list whole-subject
4192 (car threads)))
4193 threads)
4194 threads)
4195 hashtb)))
4196 (setq prev threads)
4197 (setq threads (cdr threads)))
4198 result)))
4199
4200 (defun gnus-gather-threads-by-references (threads)
4201 "Gather threads by looking at References headers."
4202 (let ((idhashtb (gnus-make-hashtable 1024))
4203 (thhashtb (gnus-make-hashtable 1024))
4204 (prev threads)
4205 (result threads)
4206 ids references id gthread gid entered ref)
4207 (while threads
4208 (when (setq references (mail-header-references (caar threads)))
4209 (setq id (mail-header-id (caar threads))
4210 ids (inline (gnus-split-references references))
4211 entered nil)
4212 (while (setq ref (pop ids))
4213 (setq ids (delete ref ids))
4214 (if (not (setq gid (gnus-gethash ref idhashtb)))
4215 (progn
4216 (gnus-sethash ref id idhashtb)
4217 (gnus-sethash id threads thhashtb))
4218 (setq gthread (gnus-gethash gid thhashtb))
4219 (unless entered
4220 ;; We enter a dummy root into the thread, if we
4221 ;; haven't done that already.
4222 (unless (stringp (caar gthread))
4223 (setcar gthread (list (mail-header-subject (caar gthread))
4224 (car gthread))))
4225 ;; We add this new gathered thread to this gathered
4226 ;; thread.
4227 (setcdr (car gthread)
4228 (nconc (cdar gthread) (list (car threads)))))
4229 ;; Add it into the thread hash table.
4230 (gnus-sethash id gthread thhashtb)
4231 (setq entered t)
4232 ;; Remove it from the list of threads.
4233 (setcdr prev (cdr threads))
4234 (setq threads prev))))
4235 (setq prev threads)
4236 (setq threads (cdr threads)))
4237 result))
4238
4239 (defun gnus-sort-gathered-threads (threads)
4240 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4241 (let ((result threads))
4242 (while threads
4243 (when (stringp (caar threads))
4244 (setcdr (car threads)
4245 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4246 (setq threads (cdr threads)))
4247 result))
4248
4249 (defun gnus-thread-loop-p (root thread)
4250 "Say whether ROOT is in THREAD."
4251 (let ((stack (list thread))
4252 (infloop 0)
4253 th)
4254 (while (setq thread (pop stack))
4255 (setq th (cdr thread))
4256 (while (and th
4257 (not (eq (caar th) root)))
4258 (pop th))
4259 (if th
4260 ;; We have found a loop.
4261 (let (ref-dep)
4262 (setcdr thread (delq (car th) (cdr thread)))
4263 (if (boundp (setq ref-dep (intern "none"
4264 gnus-newsgroup-dependencies)))
4265 (setcdr (symbol-value ref-dep)
4266 (nconc (cdr (symbol-value ref-dep))
4267 (list (car th))))
4268 (set ref-dep (list nil (car th))))
4269 (setq infloop 1
4270 stack nil))
4271 ;; Push all the subthreads onto the stack.
4272 (push (cdr thread) stack)))
4273 infloop))
4274
4275 (defun gnus-make-threads ()
4276 "Go through the dependency hashtb and find the roots. Return all threads."
4277 (let (threads)
4278 (while (catch 'infloop
4279 (mapatoms
4280 (lambda (refs)
4281 ;; Deal with self-referencing References loops.
4282 (when (and (car (symbol-value refs))
4283 (not (zerop
4284 (apply
4285 '+
4286 (mapcar
4287 (lambda (thread)
4288 (gnus-thread-loop-p
4289 (car (symbol-value refs)) thread))
4290 (cdr (symbol-value refs)))))))
4291 (setq threads nil)
4292 (throw 'infloop t))
4293 (unless (car (symbol-value refs))
4294 ;; These threads do not refer back to any other
4295 ;; articles, so they're roots.
4296 (setq threads (append (cdr (symbol-value refs)) threads))))
4297 gnus-newsgroup-dependencies)))
4298 threads))
4299
4300 ;; Build the thread tree.
4301 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4302 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4303
4304 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4305 if it was already present.
4306
4307 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4308 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4309 Message-IDs will be renamed to a unique Message-ID before being
4310 entered.
4311
4312 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4313 (let* ((id (mail-header-id header))
4314 (id-dep (and id (intern id dependencies)))
4315 parent-id ref ref-dep ref-header replaced)
4316 ;; Enter this `header' in the `dependencies' table.
4317 (cond
4318 ((not id-dep)
4319 (setq header nil))
4320 ;; The first two cases do the normal part: enter a new `header'
4321 ;; in the `dependencies' table.
4322 ((not (boundp id-dep))
4323 (set id-dep (list header)))
4324 ((null (car (symbol-value id-dep)))
4325 (setcar (symbol-value id-dep) header))
4326
4327 ;; From here the `header' was already present in the
4328 ;; `dependencies' table.
4329 (force-new
4330 ;; Overrides an existing entry;
4331 ;; just set the header part of the entry.
4332 (setcar (symbol-value id-dep) header)
4333 (setq replaced t))
4334
4335 ;; Renames the existing `header' to a unique Message-ID.
4336 ((not gnus-summary-ignore-duplicates)
4337 ;; An article with this Message-ID has already been seen.
4338 ;; We rename the Message-ID.
4339 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4340 (list header))
4341 (mail-header-set-id header id))
4342
4343 ;; The last case ignores an existing entry, except it adds any
4344 ;; additional Xrefs (in case the two articles came from different
4345 ;; servers.
4346 ;; Also sets `header' to `nil' meaning that the `dependencies'
4347 ;; table was *not* modified.
4348 (t
4349 (mail-header-set-xref
4350 (car (symbol-value id-dep))
4351 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4352 "")
4353 (or (mail-header-xref header) "")))
4354 (setq header nil)))
4355
4356 (when (and header (not replaced))
4357 ;; First check that we are not creating a References loop.
4358 (setq parent-id (gnus-parent-id (mail-header-references header)))
4359 (setq ref parent-id)
4360 (while (and ref
4361 (setq ref-dep (intern-soft ref dependencies))
4362 (boundp ref-dep)
4363 (setq ref-header (car (symbol-value ref-dep))))
4364 (if (string= id ref)
4365 ;; Yuk! This is a reference loop. Make the article be a
4366 ;; root article.
4367 (progn
4368 (mail-header-set-references (car (symbol-value id-dep)) "none")
4369 (setq ref nil)
4370 (setq parent-id nil))
4371 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4372 (setq ref-dep (intern (or parent-id "none") dependencies))
4373 (if (boundp ref-dep)
4374 (setcdr (symbol-value ref-dep)
4375 (nconc (cdr (symbol-value ref-dep))
4376 (list (symbol-value id-dep))))
4377 (set ref-dep (list nil (symbol-value id-dep)))))
4378 header))
4379
4380 (defun gnus-extract-message-id-from-in-reply-to (string)
4381 (if (string-match "<[^>]+>" string)
4382 (substring string (match-beginning 0) (match-end 0))
4383 nil))
4384
4385 (defun gnus-build-sparse-threads ()
4386 (let ((headers gnus-newsgroup-headers)
4387 (mail-parse-charset gnus-newsgroup-charset)
4388 (gnus-summary-ignore-duplicates t)
4389 header references generation relations
4390 subject child end new-child date)
4391 ;; First we create an alist of generations/relations, where
4392 ;; generations is how much we trust the relation, and the relation
4393 ;; is parent/child.
4394 (gnus-message 7 "Making sparse threads...")
4395 (save-excursion
4396 (nnheader-set-temp-buffer " *gnus sparse threads*")
4397 (while (setq header (pop headers))
4398 (when (and (setq references (mail-header-references header))
4399 (not (string= references "")))
4400 (insert references)
4401 (setq child (mail-header-id header)
4402 subject (mail-header-subject header)
4403 date (mail-header-date header)
4404 generation 0)
4405 (while (search-backward ">" nil t)
4406 (setq end (1+ (point)))
4407 (when (search-backward "<" nil t)
4408 (setq new-child (buffer-substring (point) end))
4409 (push (list (incf generation)
4410 child (setq child new-child)
4411 subject date)
4412 relations)))
4413 (when child
4414 (push (list (1+ generation) child nil subject) relations))
4415 (erase-buffer)))
4416 (kill-buffer (current-buffer)))
4417 ;; Sort over trustworthiness.
4418 (dolist (relation (sort relations 'car-less-than-car))
4419 (when (gnus-dependencies-add-header
4420 (make-full-mail-header
4421 gnus-reffed-article-number
4422 (nth 3 relation) "" (or (nth 4 relation) "")
4423 (nth 1 relation)
4424 (or (nth 2 relation) "") 0 0 "")
4425 gnus-newsgroup-dependencies nil)
4426 (push gnus-reffed-article-number gnus-newsgroup-limit)
4427 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4428 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4429 gnus-newsgroup-reads)
4430 (decf gnus-reffed-article-number)))
4431 (gnus-message 7 "Making sparse threads...done")))
4432
4433 (defun gnus-build-old-threads ()
4434 ;; Look at all the articles that refer back to old articles, and
4435 ;; fetch the headers for the articles that aren't there. This will
4436 ;; build complete threads - if the roots haven't been expired by the
4437 ;; server, that is.
4438 (let ((mail-parse-charset gnus-newsgroup-charset)
4439 id heads)
4440 (mapatoms
4441 (lambda (refs)
4442 (when (not (car (symbol-value refs)))
4443 (setq heads (cdr (symbol-value refs)))
4444 (while heads
4445 (if (memq (mail-header-number (caar heads))
4446 gnus-newsgroup-dormant)
4447 (setq heads (cdr heads))
4448 (setq id (symbol-name refs))
4449 (while (and (setq id (gnus-build-get-header id))
4450 (not (car (gnus-id-to-thread id)))))
4451 (setq heads nil)))))
4452 gnus-newsgroup-dependencies)))
4453
4454 (defsubst gnus-remove-odd-characters (string)
4455 "Translate STRING into something that doesn't contain weird characters."
4456 (mm-subst-char-in-string
4457 ?\r ?\-
4458 (mm-subst-char-in-string ?\n ?\- string t) t))
4459
4460 ;; This function has to be called with point after the article number
4461 ;; on the beginning of the line.
4462 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4463 (let ((eol (point-at-eol))
4464 (buffer (current-buffer))
4465 header references in-reply-to)
4466
4467 ;; overview: [num subject from date id refs chars lines misc]
4468 (unwind-protect
4469 (let (x)
4470 (narrow-to-region (point) eol)
4471 (unless (eobp)
4472 (forward-char))
4473
4474 (setq header
4475 (make-full-mail-header
4476 number ; number
4477 (condition-case () ; subject
4478 (gnus-remove-odd-characters
4479 (funcall gnus-decode-encoded-word-function
4480 (setq x (nnheader-nov-field))))
4481 (error x))
4482 (condition-case () ; from
4483 (gnus-remove-odd-characters
4484 (funcall gnus-decode-encoded-address-function
4485 (setq x (nnheader-nov-field))))
4486 (error x))
4487 (nnheader-nov-field) ; date
4488 (nnheader-nov-read-message-id number) ; id
4489 (setq references (nnheader-nov-field)) ; refs
4490 (nnheader-nov-read-integer) ; chars
4491 (nnheader-nov-read-integer) ; lines
4492 (unless (eobp)
4493 (if (looking-at "Xref: ")
4494 (goto-char (match-end 0)))
4495 (nnheader-nov-field)) ; Xref
4496 (nnheader-nov-parse-extra)))) ; extra
4497
4498 (widen))
4499
4500 (when (and (string= references "")
4501 (setq in-reply-to (mail-header-extra header))
4502 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4503 (mail-header-set-references
4504 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4505
4506 (when gnus-alter-header-function
4507 (funcall gnus-alter-header-function header))
4508 (gnus-dependencies-add-header header dependencies force-new)))
4509
4510 (defun gnus-build-get-header (id)
4511 "Look through the buffer of NOV lines and find the header to ID.
4512 Enter this line into the dependencies hash table, and return
4513 the id of the parent article (if any)."
4514 (let ((deps gnus-newsgroup-dependencies)
4515 found header)
4516 (prog1
4517 (with-current-buffer nntp-server-buffer
4518 (let ((case-fold-search nil))
4519 (goto-char (point-min))
4520 (while (and (not found)
4521 (search-forward id nil t))
4522 (beginning-of-line)
4523 (setq found (looking-at
4524 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4525 (regexp-quote id))))
4526 (or found (beginning-of-line 2)))
4527 (when found
4528 (beginning-of-line)
4529 (and
4530 (setq header (gnus-nov-parse-line
4531 (read (current-buffer)) deps))
4532 (gnus-parent-id (mail-header-references header))))))
4533 (when header
4534 (let ((number (mail-header-number header)))
4535 (push number gnus-newsgroup-limit)
4536 (push header gnus-newsgroup-headers)
4537 (if (memq number gnus-newsgroup-unselected)
4538 (progn
4539 (setq gnus-newsgroup-unreads
4540 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4541 number))
4542 (setq gnus-newsgroup-unselected
4543 (delq number gnus-newsgroup-unselected)))
4544 (push number gnus-newsgroup-ancient)))))))
4545
4546 (defun gnus-build-all-threads ()
4547 "Read all the headers."
4548 (let ((gnus-summary-ignore-duplicates t)
4549 (mail-parse-charset gnus-newsgroup-charset)
4550 (dependencies gnus-newsgroup-dependencies)
4551 header article)
4552 (with-current-buffer nntp-server-buffer
4553 (let ((case-fold-search nil))
4554 (goto-char (point-min))
4555 (while (not (eobp))
4556 (ignore-errors
4557 (setq article (read (current-buffer))
4558 header (gnus-nov-parse-line article dependencies t)))
4559 (when header
4560 (with-current-buffer gnus-summary-buffer
4561 (push header gnus-newsgroup-headers)
4562 (if (memq (setq article (mail-header-number header))
4563 gnus-newsgroup-unselected)
4564 (progn
4565 (setq gnus-newsgroup-unreads
4566 (gnus-add-to-sorted-list
4567 gnus-newsgroup-unreads article))
4568 (setq gnus-newsgroup-unselected
4569 (delq article gnus-newsgroup-unselected)))
4570 (push article gnus-newsgroup-ancient)))
4571 (forward-line 1)))))))
4572
4573 (defun gnus-summary-update-article-line (article header)
4574 "Update the line for ARTICLE using HEADER."
4575 (let* ((id (mail-header-id header))
4576 (thread (gnus-id-to-thread id)))
4577 (unless thread
4578 (error "Article in no thread"))
4579 ;; Update the thread.
4580 (setcar thread header)
4581 (gnus-summary-goto-subject article)
4582 (let* ((datal (gnus-data-find-list article))
4583 (data (car datal))
4584 (inhibit-read-only t)
4585 (level (gnus-summary-thread-level)))
4586 (gnus-delete-line)
4587 (let ((inserted (- (point)
4588 (progn
4589 (gnus-summary-insert-line
4590 header level nil
4591 (memq article gnus-newsgroup-undownloaded)
4592 (gnus-article-mark article)
4593 (memq article gnus-newsgroup-replied)
4594 (memq article gnus-newsgroup-expirable)
4595 ;; Only insert the Subject string when it's different
4596 ;; from the previous Subject string.
4597 (if (and
4598 gnus-show-threads
4599 (gnus-subject-equal
4600 (condition-case ()
4601 (mail-header-subject
4602 (gnus-data-header
4603 (cadr
4604 (gnus-data-find-list
4605 article
4606 (gnus-data-list t)))))
4607 ;; Error on the side of excessive subjects.
4608 (error ""))
4609 (mail-header-subject header)))
4610 ""
4611 (mail-header-subject header))
4612 nil (cdr (assq article gnus-newsgroup-scored))
4613 (memq article gnus-newsgroup-processable))
4614 (point)))))
4615 (when (cdr datal)
4616 (gnus-data-update-list
4617 (cdr datal)
4618 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4619
4620 (defun gnus-summary-update-article (article &optional iheader)
4621 "Update ARTICLE in the summary buffer."
4622 (set-buffer gnus-summary-buffer)
4623 (let* ((header (gnus-summary-article-header article))
4624 (id (mail-header-id header))
4625 (data (gnus-data-find article))
4626 (thread (gnus-id-to-thread id))
4627 (references (mail-header-references header))
4628 (parent
4629 (gnus-id-to-thread
4630 (or (gnus-parent-id
4631 (when (and references
4632 (not (equal "" references)))
4633 references))
4634 "none")))
4635 (inhibit-read-only t)
4636 (old (car thread)))
4637 (when thread
4638 (unless iheader
4639 (setcar thread nil)
4640 (when parent
4641 (delq thread parent)))
4642 (if (gnus-summary-insert-subject id header)
4643 ;; Set the (possibly) new article number in the data structure.
4644 (gnus-data-set-number data (gnus-id-to-article id))
4645 (setcar thread old)
4646 nil))))
4647
4648 (defun gnus-rebuild-thread (id &optional line)
4649 "Rebuild the thread containing ID.
4650 If LINE, insert the rebuilt thread starting on line LINE."
4651 (let ((inhibit-read-only t)
4652 old-pos current thread data)
4653 (if (not gnus-show-threads)
4654 (setq thread (list (car (gnus-id-to-thread id))))
4655 ;; Get the thread this article is part of.
4656 (setq thread (gnus-remove-thread id)))
4657 (setq old-pos (point-at-bol))
4658 (setq current (save-excursion
4659 (and (re-search-backward "[\r\n]" nil t)
4660 (gnus-summary-article-number))))
4661 ;; If this is a gathered thread, we have to go some re-gathering.
4662 (when (stringp (car thread))
4663 (let ((subject (car thread))
4664 roots thr)
4665 (setq thread (cdr thread))
4666 (while thread
4667 (unless (memq (setq thr (gnus-id-to-thread
4668 (gnus-root-id
4669 (mail-header-id (caar thread)))))
4670 roots)
4671 (push thr roots))
4672 (setq thread (cdr thread)))
4673 ;; We now have all (unique) roots.
4674 (if (= (length roots) 1)
4675 ;; All the loose roots are now one solid root.
4676 (setq thread (car roots))
4677 (setq thread (cons subject (gnus-sort-threads roots))))))
4678 (let (threads)
4679 ;; We then insert this thread into the summary buffer.
4680 (when line
4681 (goto-char (point-min))
4682 (forward-line (1- line)))
4683 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4684 (if gnus-show-threads
4685 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4686 (gnus-summary-prepare-unthreaded thread))
4687 (setq data (nreverse gnus-newsgroup-data))
4688 (setq threads gnus-newsgroup-threads))
4689 ;; We splice the new data into the data structure.
4690 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4691 ;;!!! then we want to insert at the beginning of the buffer.
4692 ;;!!! That happens to be true with Gnus now, but that may
4693 ;;!!! change in the future. Perhaps.
4694 (gnus-data-enter-list
4695 (if line nil current) data (- (point) old-pos))
4696 (setq gnus-newsgroup-threads
4697 (nconc threads gnus-newsgroup-threads))
4698 (gnus-data-compute-positions))))
4699
4700 (defun gnus-number-to-header (number)
4701 "Return the header for article NUMBER."
4702 (let ((headers gnus-newsgroup-headers))
4703 (while (and headers
4704 (not (= number (mail-header-number (car headers)))))
4705 (pop headers))
4706 (when headers
4707 (car headers))))
4708
4709 (defun gnus-parent-headers (in-headers &optional generation)
4710 "Return the headers of the GENERATIONth parent of HEADERS."
4711 (unless generation
4712 (setq generation 1))
4713 (let ((parent t)
4714 (headers in-headers)
4715 references)
4716 (while (and parent
4717 (not (zerop generation))
4718 (setq references (mail-header-references headers)))
4719 (setq headers (if (and references
4720 (setq parent (gnus-parent-id references)))
4721 (car (gnus-id-to-thread parent))
4722 nil))
4723 (decf generation))
4724 (and (not (eq headers in-headers))
4725 headers)))
4726
4727 (defun gnus-id-to-thread (id)
4728 "Return the (sub-)thread where ID appears."
4729 (gnus-gethash id gnus-newsgroup-dependencies))
4730
4731 (defun gnus-id-to-article (id)
4732 "Return the article number of ID."
4733 (let ((thread (gnus-id-to-thread id)))
4734 (when (and thread
4735 (car thread))
4736 (mail-header-number (car thread)))))
4737
4738 (defun gnus-id-to-header (id)
4739 "Return the article headers of ID."
4740 (car (gnus-id-to-thread id)))
4741
4742 (defun gnus-article-displayed-root-p (article)
4743 "Say whether ARTICLE is a root(ish) article."
4744 (let ((level (gnus-summary-thread-level article))
4745 (refs (mail-header-references (gnus-summary-article-header article)))
4746 particle)
4747 (cond
4748 ((null level) nil)
4749 ((zerop level) t)
4750 ((null refs) t)
4751 ((null (gnus-parent-id refs)) t)
4752 ((and (= 1 level)
4753 (null (setq particle (gnus-id-to-article
4754 (gnus-parent-id refs))))
4755 (null (gnus-summary-thread-level particle)))))))
4756
4757 (defun gnus-root-id (id)
4758 "Return the id of the root of the thread where ID appears."
4759 (let (last-id prev)
4760 (while (and id (setq prev (car (gnus-id-to-thread id))))
4761 (setq last-id id
4762 id (gnus-parent-id (mail-header-references prev))))
4763 last-id))
4764
4765 (defun gnus-articles-in-thread (thread)
4766 "Return the list of articles in THREAD."
4767 (cons (mail-header-number (car thread))
4768 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4769
4770 (defun gnus-remove-thread (id &optional dont-remove)
4771 "Remove the thread that has ID in it."
4772 (let (headers thread last-id)
4773 ;; First go up in this thread until we find the root.
4774 (setq last-id (gnus-root-id id)
4775 headers (message-flatten-list (gnus-id-to-thread last-id)))
4776 ;; We have now found the real root of this thread. It might have
4777 ;; been gathered into some loose thread, so we have to search
4778 ;; through the threads to find the thread we wanted.
4779 (let ((threads gnus-newsgroup-threads)
4780 sub)
4781 (while threads
4782 (setq sub (car threads))
4783 (if (stringp (car sub))
4784 ;; This is a gathered thread, so we look at the roots
4785 ;; below it to find whether this article is in this
4786 ;; gathered root.
4787 (progn
4788 (setq sub (cdr sub))
4789 (while sub
4790 (when (member (caar sub) headers)
4791 (setq thread (car threads)
4792 threads nil
4793 sub nil))
4794 (setq sub (cdr sub))))
4795 ;; It's an ordinary thread, so we check it.
4796 (when (eq (car sub) (car headers))
4797 (setq thread sub
4798 threads nil)))
4799 (setq threads (cdr threads)))
4800 ;; If this article is in no thread, then it's a root.
4801 (if thread
4802 (unless dont-remove
4803 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4804 (setq thread (gnus-id-to-thread last-id)))
4805 (when thread
4806 (prog1
4807 thread ; We return this thread.
4808 (unless dont-remove
4809 (if (stringp (car thread))
4810 (progn
4811 ;; If we use dummy roots, then we have to remove the
4812 ;; dummy root as well.
4813 (when (eq gnus-summary-make-false-root 'dummy)
4814 ;; We go to the dummy root by going to
4815 ;; the first sub-"thread", and then one line up.
4816 (gnus-summary-goto-article
4817 (mail-header-number (caadr thread)))
4818 (forward-line -1)
4819 (gnus-delete-line)
4820 (gnus-data-compute-positions))
4821 (setq thread (cdr thread))
4822 (while thread
4823 (gnus-remove-thread-1 (car thread))
4824 (setq thread (cdr thread))))
4825 (gnus-remove-thread-1 thread))))))))
4826
4827 (defun gnus-remove-thread-1 (thread)
4828 "Remove the thread THREAD recursively."
4829 (let ((number (mail-header-number (pop thread)))
4830 d)
4831 (setq thread (reverse thread))
4832 (while thread
4833 (gnus-remove-thread-1 (pop thread)))
4834 (when (setq d (gnus-data-find number))
4835 (goto-char (gnus-data-pos d))
4836 (gnus-summary-show-thread)
4837 (gnus-data-remove
4838 number
4839 (- (point-at-bol)
4840 (prog1
4841 (1+ (point-at-eol))
4842 (gnus-delete-line)))))))
4843
4844 (defun gnus-sort-threads-recursive (threads func)
4845 (sort (mapcar (lambda (thread)
4846 (cons (car thread)
4847 (and (cdr thread)
4848 (gnus-sort-threads-recursive (cdr thread) func))))
4849 threads) func))
4850
4851 (defun gnus-sort-threads-loop (threads func)
4852 (let* ((superthread (cons nil threads))
4853 (stack (list (cons superthread threads)))
4854 remaining-threads thread)
4855 (while stack
4856 (setq remaining-threads (cdr (car stack)))
4857 (if remaining-threads
4858 (progn (setq thread (car remaining-threads))
4859 (setcdr (car stack) (cdr remaining-threads))
4860 (if (cdr thread)
4861 (push (cons thread (cdr thread)) stack)))
4862 (setq thread (caar stack))
4863 (setcdr thread (sort (cdr thread) func))
4864 (pop stack)))
4865 (cdr superthread)))
4866
4867 (defun gnus-sort-threads (threads)
4868 "Sort THREADS."
4869 (if (not gnus-thread-sort-functions)
4870 threads
4871 (gnus-message 8 "Sorting threads...")
4872 (prog1
4873 (condition-case nil
4874 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4875 (gnus-sort-threads-recursive
4876 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4877 ;; Even after binding max-lisp-eval-depth, the recursive
4878 ;; sorter might fail for very long threads. In that case,
4879 ;; try using a (less well-tested) non-recursive sorter.
4880 (error (gnus-message 9 "Sorting threads with loop...")
4881 (gnus-sort-threads-loop
4882 threads (gnus-make-sort-function
4883 gnus-thread-sort-functions))))
4884 (gnus-message 8 "Sorting threads...done"))))
4885
4886 (defun gnus-sort-articles (articles)
4887 "Sort ARTICLES."
4888 (when gnus-article-sort-functions
4889 (gnus-message 7 "Sorting articles...")
4890 (prog1
4891 (setq gnus-newsgroup-headers
4892 (sort articles (gnus-make-sort-function
4893 gnus-article-sort-functions)))
4894 (gnus-message 7 "Sorting articles...done"))))
4895
4896 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4897 (defmacro gnus-thread-header (thread)
4898 "Return header of first article in THREAD.
4899 Note that THREAD must never, ever be anything else than a variable -
4900 using some other form will lead to serious barfage."
4901 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4902 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4903 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4904 (vector thread) 2))
4905
4906 (defsubst gnus-article-sort-by-number (h1 h2)
4907 "Sort articles by article number."
4908 (< (mail-header-number h1)
4909 (mail-header-number h2)))
4910
4911 (defun gnus-thread-sort-by-number (h1 h2)
4912 "Sort threads by root article number."
4913 (gnus-article-sort-by-number
4914 (gnus-thread-header h1) (gnus-thread-header h2)))
4915
4916 (defsubst gnus-article-sort-by-random (h1 h2)
4917 "Sort articles randomly."
4918 (zerop (random 2)))
4919
4920 (defun gnus-thread-sort-by-random (h1 h2)
4921 "Sort threads randomly."
4922 (gnus-article-sort-by-random
4923 (gnus-thread-header h1) (gnus-thread-header h2)))
4924
4925 (defsubst gnus-article-sort-by-lines (h1 h2)
4926 "Sort articles by article Lines header."
4927 (< (mail-header-lines h1)
4928 (mail-header-lines h2)))
4929
4930 (defun gnus-thread-sort-by-lines (h1 h2)
4931 "Sort threads by root article Lines header."
4932 (gnus-article-sort-by-lines
4933 (gnus-thread-header h1) (gnus-thread-header h2)))
4934
4935 (defsubst gnus-article-sort-by-chars (h1 h2)
4936 "Sort articles by octet length."
4937 (< (mail-header-chars h1)
4938 (mail-header-chars h2)))
4939
4940 (defun gnus-thread-sort-by-chars (h1 h2)
4941 "Sort threads by root article octet length."
4942 (gnus-article-sort-by-chars
4943 (gnus-thread-header h1) (gnus-thread-header h2)))
4944
4945 (defsubst gnus-article-sort-by-author (h1 h2)
4946 "Sort articles by root author."
4947 (gnus-string<
4948 (let ((extract (funcall
4949 gnus-extract-address-components
4950 (mail-header-from h1))))
4951 (or (car extract) (cadr extract) ""))
4952 (let ((extract (funcall
4953 gnus-extract-address-components
4954 (mail-header-from h2))))
4955 (or (car extract) (cadr extract) ""))))
4956
4957 (defun gnus-thread-sort-by-author (h1 h2)
4958 "Sort threads by root author."
4959 (gnus-article-sort-by-author
4960 (gnus-thread-header h1) (gnus-thread-header h2)))
4961
4962 (defsubst gnus-article-sort-by-recipient (h1 h2)
4963 "Sort articles by recipient."
4964 (gnus-string<
4965 (let ((extract (funcall
4966 gnus-extract-address-components
4967 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4968 (or (car extract) (cadr extract)))
4969 (let ((extract (funcall
4970 gnus-extract-address-components
4971 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4972 (or (car extract) (cadr extract)))))
4973
4974 (defun gnus-thread-sort-by-recipient (h1 h2)
4975 "Sort threads by root recipient."
4976 (gnus-article-sort-by-recipient
4977 (gnus-thread-header h1) (gnus-thread-header h2)))
4978
4979 (defsubst gnus-article-sort-by-subject (h1 h2)
4980 "Sort articles by root subject."
4981 (gnus-string<
4982 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4983 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4984
4985 (defun gnus-thread-sort-by-subject (h1 h2)
4986 "Sort threads by root subject."
4987 (gnus-article-sort-by-subject
4988 (gnus-thread-header h1) (gnus-thread-header h2)))
4989
4990 (defsubst gnus-article-sort-by-date (h1 h2)
4991 "Sort articles by root article date."
4992 (time-less-p
4993 (gnus-date-get-time (mail-header-date h1))
4994 (gnus-date-get-time (mail-header-date h2))))
4995
4996 (defun gnus-thread-sort-by-date (h1 h2)
4997 "Sort threads by root article date."
4998 (gnus-article-sort-by-date
4999 (gnus-thread-header h1) (gnus-thread-header h2)))
5000
5001 (defsubst gnus-article-sort-by-score (h1 h2)
5002 "Sort articles by root article score.
5003 Unscored articles will be counted as having a score of zero."
5004 (> (or (cdr (assq (mail-header-number h1)
5005 gnus-newsgroup-scored))
5006 gnus-summary-default-score 0)
5007 (or (cdr (assq (mail-header-number h2)
5008 gnus-newsgroup-scored))
5009 gnus-summary-default-score 0)))
5010
5011 (defun gnus-thread-sort-by-score (h1 h2)
5012 "Sort threads by root article score."
5013 (gnus-article-sort-by-score
5014 (gnus-thread-header h1) (gnus-thread-header h2)))
5015
5016 (defun gnus-thread-sort-by-total-score (h1 h2)
5017 "Sort threads by the sum of all scores in the thread.
5018 Unscored articles will be counted as having a score of zero."
5019 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5020
5021 (defun gnus-thread-total-score (thread)
5022 ;; This function find the total score of THREAD.
5023 (cond
5024 ((null thread)
5025 0)
5026 ((consp thread)
5027 (if (stringp (car thread))
5028 (apply gnus-thread-score-function 0
5029 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5030 (gnus-thread-total-score-1 thread)))
5031 (t
5032 (gnus-thread-total-score-1 (list thread)))))
5033
5034 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5035 "Sort articles by number."
5036 (gnus-article-sort-by-number h1 h2))
5037
5038 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5039 "Sort threads such that the thread with the most recently arrived article comes first."
5040 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5041
5042 (defun gnus-thread-highest-number (thread)
5043 "Return the highest article number in THREAD."
5044 (apply 'max (mapcar (lambda (header)
5045 (mail-header-number header))
5046 (message-flatten-list thread))))
5047
5048 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5049 "Sort articles by number."
5050 (gnus-article-sort-by-date h1 h2))
5051
5052 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5053 "Sort threads such that the thread with the most recently dated article comes first."
5054 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5055
5056 ; Since this is called not only to sort the top-level threads, but
5057 ; also in recursive sorts to order the articles within a thread, each
5058 ; article will be processed many times. Thus it speeds things up
5059 ; quite a bit to use gnus-date-get-time, which caches the time value.
5060 (defun gnus-thread-latest-date (thread)
5061 "Return the highest article date in THREAD."
5062 (apply 'max
5063 (mapcar (lambda (header) (gnus-float-time
5064 (gnus-date-get-time
5065 (mail-header-date header))))
5066 (message-flatten-list thread))))
5067
5068 (defun gnus-thread-total-score-1 (root)
5069 ;; This function find the total score of the thread below ROOT.
5070 (setq root (car root))
5071 (apply gnus-thread-score-function
5072 (or (append
5073 (mapcar 'gnus-thread-total-score
5074 (cdr (gnus-id-to-thread (mail-header-id root))))
5075 (when (> (mail-header-number root) 0)
5076 (list (or (cdr (assq (mail-header-number root)
5077 gnus-newsgroup-scored))
5078 gnus-summary-default-score 0))))
5079 (list gnus-summary-default-score)
5080 '(0))))
5081
5082 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5083 (defvar gnus-tmp-prev-subject nil)
5084 (defvar gnus-tmp-false-parent nil)
5085 (defvar gnus-tmp-root-expunged nil)
5086 (defvar gnus-tmp-dummy-line nil)
5087
5088 (defun gnus-extra-header (type &optional header)
5089 "Return the extra header of TYPE."
5090 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5091 ""))
5092
5093 (defvar gnus-tmp-thread-tree-header-string "")
5094
5095 (defcustom gnus-sum-thread-tree-root "> "
5096 "With %B spec, used for the root of a thread.
5097 If nil, use subject instead."
5098 :version "22.1"
5099 :type '(radio (const :format "%v " nil) string)
5100 :group 'gnus-thread)
5101
5102 (defcustom gnus-sum-thread-tree-false-root "> "
5103 "With %B spec, used for a false root of a thread.
5104 If nil, use subject instead."
5105 :version "22.1"
5106 :type '(radio (const :format "%v " nil) string)
5107 :group 'gnus-thread)
5108
5109 (defcustom gnus-sum-thread-tree-single-indent ""
5110 "With %B spec, used for a thread with just one message.
5111 If nil, use subject instead."
5112 :version "22.1"
5113 :type '(radio (const :format "%v " nil) string)
5114 :group 'gnus-thread)
5115
5116 (defcustom gnus-sum-thread-tree-vertical "| "
5117 "With %B spec, used for drawing a vertical line."
5118 :version "22.1"
5119 :type 'string
5120 :group 'gnus-thread)
5121
5122 (defcustom gnus-sum-thread-tree-indent " "
5123 "With %B spec, used for indenting."
5124 :version "22.1"
5125 :type 'string
5126 :group 'gnus-thread)
5127
5128 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5129 "With %B spec, used for a leaf with brothers."
5130 :version "22.1"
5131 :type 'string
5132 :group 'gnus-thread)
5133
5134 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5135 "With %B spec, used for a leaf without brothers."
5136 :version "22.1"
5137 :type 'string
5138 :group 'gnus-thread)
5139
5140 (defcustom gnus-summary-display-while-building nil
5141 "If non-nil, show and update the summary buffer as it's being built.
5142 If the value is t, update the buffer after every line is inserted. If
5143 the value is an integer (N), update the display every N lines."
5144 :version "22.1"
5145 :group 'gnus-thread
5146 :type '(choice (const :tag "off" nil)
5147 number
5148 (const :tag "frequently" t)))
5149
5150 (defun gnus-summary-prepare-threads (threads)
5151 "Prepare summary buffer from THREADS and indentation LEVEL.
5152 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5153 or a straight list of headers."
5154 (gnus-message 7 "Generating summary...")
5155
5156 (setq gnus-newsgroup-threads threads)
5157 (beginning-of-line)
5158
5159 (let ((gnus-tmp-level 0)
5160 (default-score (or gnus-summary-default-score 0))
5161 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5162 (building-line-count gnus-summary-display-while-building)
5163 (building-count (integerp gnus-summary-display-while-building))
5164 thread number subject stack state gnus-tmp-gathered beg-match
5165 new-roots gnus-tmp-new-adopts thread-end simp-subject
5166 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5167 gnus-tmp-replied gnus-tmp-subject-or-nil
5168 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5169 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5170 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5171 tree-stack)
5172
5173 (setq gnus-tmp-prev-subject nil
5174 gnus-tmp-thread-tree-header-string "")
5175
5176 (if (vectorp (car threads))
5177 ;; If this is a straight (sic) list of headers, then a
5178 ;; threaded summary display isn't required, so we just create
5179 ;; an unthreaded one.
5180 (gnus-summary-prepare-unthreaded threads)
5181
5182 ;; Do the threaded display.
5183
5184 (if gnus-summary-display-while-building
5185 (switch-to-buffer (buffer-name)))
5186 (while (or threads stack gnus-tmp-new-adopts new-roots)
5187
5188 (if (and (= gnus-tmp-level 0)
5189 (or (not stack)
5190 (= (caar stack) 0))
5191 (not gnus-tmp-false-parent)
5192 (or gnus-tmp-new-adopts new-roots))
5193 (if gnus-tmp-new-adopts
5194 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5195 thread (list (car gnus-tmp-new-adopts))
5196 gnus-tmp-header (caar thread)
5197 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5198 (when new-roots
5199 (setq thread (list (car new-roots))
5200 gnus-tmp-header (caar thread)
5201 new-roots (cdr new-roots))))
5202
5203 (if threads
5204 ;; If there are some threads, we do them before the
5205 ;; threads on the stack.
5206 (setq thread threads
5207 gnus-tmp-header (caar thread))
5208 ;; There were no current threads, so we pop something off
5209 ;; the stack.
5210 (setq state (car stack)
5211 gnus-tmp-level (car state)
5212 tree-stack (cadr state)
5213 thread (caddr state)
5214 stack (cdr stack)
5215 gnus-tmp-header (caar thread))))
5216
5217 (setq gnus-tmp-false-parent nil)
5218 (setq gnus-tmp-root-expunged nil)
5219 (setq thread-end nil)
5220
5221 (if (stringp gnus-tmp-header)
5222 ;; The header is a dummy root.
5223 (cond
5224 ((eq gnus-summary-make-false-root 'adopt)
5225 ;; We let the first article adopt the rest.
5226 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5227 (cddar thread)))
5228 (setq gnus-tmp-gathered
5229 (nconc (mapcar
5230 (lambda (h) (mail-header-number (car h)))
5231 (cddar thread))
5232 gnus-tmp-gathered))
5233 (setq thread (cons (list (caar thread)
5234 (cadar thread))
5235 (cdr thread)))
5236 (setq gnus-tmp-level -1
5237 gnus-tmp-false-parent t))
5238 ((eq gnus-summary-make-false-root 'empty)
5239 ;; We print adopted articles with empty subject fields.
5240 (setq gnus-tmp-gathered
5241 (nconc (mapcar
5242 (lambda (h) (mail-header-number (car h)))
5243 (cddar thread))
5244 gnus-tmp-gathered))
5245 (setq gnus-tmp-level -1))
5246 ((eq gnus-summary-make-false-root 'dummy)
5247 ;; We remember that we probably want to output a dummy
5248 ;; root.
5249 (setq gnus-tmp-dummy-line gnus-tmp-header)
5250 (setq gnus-tmp-prev-subject gnus-tmp-header))
5251 (t
5252 ;; We do not make a root for the gathered
5253 ;; sub-threads at all.
5254 (setq gnus-tmp-level -1)))
5255
5256 (setq number (mail-header-number gnus-tmp-header)
5257 subject (mail-header-subject gnus-tmp-header)
5258 simp-subject (gnus-simplify-subject-fully subject))
5259
5260 (cond
5261 ;; If the thread has changed subject, we might want to make
5262 ;; this subthread into a root.
5263 ((and (null gnus-thread-ignore-subject)
5264 (not (zerop gnus-tmp-level))
5265 gnus-tmp-prev-subject
5266 (not (string= gnus-tmp-prev-subject simp-subject)))
5267 (setq new-roots (nconc new-roots (list (car thread)))
5268 thread-end t
5269 gnus-tmp-header nil))
5270 ;; If the article lies outside the current limit,
5271 ;; then we do not display it.
5272 ((not (memq number gnus-newsgroup-limit))
5273 (setq gnus-tmp-gathered
5274 (nconc (mapcar
5275 (lambda (h) (mail-header-number (car h)))
5276 (cdar thread))
5277 gnus-tmp-gathered))
5278 (setq gnus-tmp-new-adopts (if (cdar thread)
5279 (append gnus-tmp-new-adopts
5280 (cdar thread))
5281 gnus-tmp-new-adopts)
5282 thread-end t
5283 gnus-tmp-header nil)
5284 (when (zerop gnus-tmp-level)
5285 (setq gnus-tmp-root-expunged t)))
5286 ;; Perhaps this article is to be marked as read?
5287 ((and gnus-summary-mark-below
5288 (< (or (cdr (assq number gnus-newsgroup-scored))
5289 default-score)
5290 gnus-summary-mark-below)
5291 ;; Don't touch sparse articles.
5292 (not (gnus-summary-article-sparse-p number))
5293 (not (gnus-summary-article-ancient-p number)))
5294 (setq gnus-newsgroup-unreads
5295 (delq number gnus-newsgroup-unreads))
5296 (if gnus-newsgroup-auto-expire
5297 (setq gnus-newsgroup-expirable
5298 (gnus-add-to-sorted-list
5299 gnus-newsgroup-expirable number))
5300 (push (cons number gnus-low-score-mark)
5301 gnus-newsgroup-reads))))
5302
5303 (when gnus-tmp-header
5304 ;; We may have an old dummy line to output before this
5305 ;; article.
5306 (when (and gnus-tmp-dummy-line
5307 (gnus-subject-equal
5308 gnus-tmp-dummy-line
5309 (mail-header-subject gnus-tmp-header)))
5310 (gnus-summary-insert-dummy-line
5311 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5312 (setq gnus-tmp-dummy-line nil))
5313
5314 ;; Compute the mark.
5315 (setq gnus-tmp-unread (gnus-article-mark number))
5316
5317 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5318 gnus-tmp-header gnus-tmp-level)
5319 gnus-newsgroup-data)
5320
5321 ;; Actually insert the line.
5322 (setq
5323 gnus-tmp-subject-or-nil
5324 (cond
5325 ((and gnus-thread-ignore-subject
5326 gnus-tmp-prev-subject
5327 (not (string= gnus-tmp-prev-subject simp-subject)))
5328 subject)
5329 ((zerop gnus-tmp-level)
5330 (if (and (eq gnus-summary-make-false-root 'empty)
5331 (memq number gnus-tmp-gathered)
5332 gnus-tmp-prev-subject
5333 (string= gnus-tmp-prev-subject simp-subject))
5334 gnus-summary-same-subject
5335 subject))
5336 (t gnus-summary-same-subject)))
5337 (if (and (eq gnus-summary-make-false-root 'adopt)
5338 (= gnus-tmp-level 1)
5339 (memq number gnus-tmp-gathered))
5340 (setq gnus-tmp-opening-bracket ?\<
5341 gnus-tmp-closing-bracket ?\>)
5342 (setq gnus-tmp-opening-bracket ?\[
5343 gnus-tmp-closing-bracket ?\]))
5344 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5345 (gnus-make-thread-indent-array
5346 (max (* 2 (length gnus-thread-indent-array))
5347 gnus-tmp-level)))
5348 (setq
5349 gnus-tmp-indentation
5350 (aref gnus-thread-indent-array gnus-tmp-level)
5351 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5352 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5353 gnus-summary-default-score 0)
5354 gnus-tmp-score-char
5355 (if (or (null gnus-summary-default-score)
5356 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5357 gnus-summary-zcore-fuzz))
5358 ? ;Whitespace
5359 (if (< gnus-tmp-score gnus-summary-default-score)
5360 gnus-score-below-mark gnus-score-over-mark))
5361 gnus-tmp-replied
5362 (cond ((memq number gnus-newsgroup-processable)
5363 gnus-process-mark)
5364 ((memq number gnus-newsgroup-cached)
5365 gnus-cached-mark)
5366 ((memq number gnus-newsgroup-replied)
5367 gnus-replied-mark)
5368 ((memq number gnus-newsgroup-forwarded)
5369 gnus-forwarded-mark)
5370 ((memq number gnus-newsgroup-saved)
5371 gnus-saved-mark)
5372 ((memq number gnus-newsgroup-unseen)
5373 gnus-unseen-mark)
5374 (t gnus-no-mark))
5375 gnus-tmp-downloaded
5376 (cond ((memq number gnus-newsgroup-undownloaded)
5377 gnus-undownloaded-mark)
5378 (gnus-newsgroup-agentized
5379 gnus-downloaded-mark)
5380 (t
5381 gnus-no-mark))
5382 gnus-tmp-from (mail-header-from gnus-tmp-header)
5383 gnus-tmp-name
5384 (cond
5385 ((string-match "<[^>]+> *$" gnus-tmp-from)
5386 (setq beg-match (match-beginning 0))
5387 (or (and (string-match "^\".+\"" gnus-tmp-from)
5388 (substring gnus-tmp-from 1 (1- (match-end 0))))
5389 (substring gnus-tmp-from 0 beg-match)))
5390 ((string-match "(.+)" gnus-tmp-from)
5391 (substring gnus-tmp-from
5392 (1+ (match-beginning 0)) (1- (match-end 0))))
5393 (t gnus-tmp-from))
5394
5395 ;; Do the %B string
5396 gnus-tmp-thread-tree-header-string
5397 (cond
5398 ((not gnus-show-threads) "")
5399 ((zerop gnus-tmp-level)
5400 (cond ((cdar thread)
5401 (or gnus-sum-thread-tree-root subject))
5402 (gnus-tmp-new-adopts
5403 (or gnus-sum-thread-tree-false-root subject))
5404 (t
5405 (or gnus-sum-thread-tree-single-indent subject))))
5406 (t
5407 (concat (apply 'concat
5408 (mapcar (lambda (item)
5409 (if (= item 1)
5410 gnus-sum-thread-tree-vertical
5411 gnus-sum-thread-tree-indent))
5412 (cdr (reverse tree-stack))))
5413 (if (nth 1 thread)
5414 gnus-sum-thread-tree-leaf-with-other
5415 gnus-sum-thread-tree-single-leaf)))))
5416 (when (string= gnus-tmp-name "")
5417 (setq gnus-tmp-name gnus-tmp-from))
5418 (unless (numberp gnus-tmp-lines)
5419 (setq gnus-tmp-lines -1))
5420 (if (= gnus-tmp-lines -1)
5421 (setq gnus-tmp-lines "?")
5422 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5423 (gnus-put-text-property
5424 (point)
5425 (progn (eval gnus-summary-line-format-spec) (point))
5426 'gnus-number number)
5427 (when gnus-visual-p
5428 (forward-line -1)
5429 (gnus-summary-highlight-line)
5430 (when gnus-summary-update-hook
5431 (gnus-run-hooks 'gnus-summary-update-hook))
5432 (forward-line 1))
5433
5434 (setq gnus-tmp-prev-subject simp-subject)))
5435
5436 (when (nth 1 thread)
5437 (push (list (max 0 gnus-tmp-level)
5438 (copy-sequence tree-stack)
5439 (nthcdr 1 thread))
5440 stack))
5441 (push (if (nth 1 thread) 1 0) tree-stack)
5442 (incf gnus-tmp-level)
5443 (setq threads (if thread-end nil (cdar thread)))
5444 (if gnus-summary-display-while-building
5445 (if building-count
5446 (progn
5447 ;; use a set frequency
5448 (setq building-line-count (1- building-line-count))
5449 (when (= building-line-count 0)
5450 (sit-for 0)
5451 (setq building-line-count
5452 gnus-summary-display-while-building)))
5453 ;; always
5454 (sit-for 0)))
5455 (unless threads
5456 (setq gnus-tmp-level 0)))))
5457 (gnus-message 7 "Generating summary...done"))
5458
5459 (defun gnus-summary-prepare-unthreaded (headers)
5460 "Generate an unthreaded summary buffer based on HEADERS."
5461 (let (header number mark)
5462
5463 (beginning-of-line)
5464
5465 (while headers
5466 ;; We may have to root out some bad articles...
5467 (when (memq (setq number (mail-header-number
5468 (setq header (pop headers))))
5469 gnus-newsgroup-limit)
5470 ;; Mark article as read when it has a low score.
5471 (when (and gnus-summary-mark-below
5472 (< (or (cdr (assq number gnus-newsgroup-scored))
5473 gnus-summary-default-score 0)
5474 gnus-summary-mark-below)
5475 (not (gnus-summary-article-ancient-p number)))
5476 (setq gnus-newsgroup-unreads
5477 (delq number gnus-newsgroup-unreads))
5478 (if gnus-newsgroup-auto-expire
5479 (push number gnus-newsgroup-expirable)
5480 (push (cons number gnus-low-score-mark)
5481 gnus-newsgroup-reads)))
5482
5483 (setq mark (gnus-article-mark number))
5484 (push (gnus-data-make number mark (1+ (point)) header 0)
5485 gnus-newsgroup-data)
5486 (gnus-summary-insert-line
5487 header 0 number
5488 (memq number gnus-newsgroup-undownloaded)
5489 mark (memq number gnus-newsgroup-replied)
5490 (memq number gnus-newsgroup-expirable)
5491 (mail-header-subject header) nil
5492 (cdr (assq number gnus-newsgroup-scored))
5493 (memq number gnus-newsgroup-processable))))))
5494
5495 (defun gnus-group-get-list-identifiers (group)
5496 "Get list identifier regexp for GROUP."
5497 (or (gnus-parameter-list-identifier group)
5498 (if (consp gnus-list-identifiers)
5499 (mapconcat 'identity gnus-list-identifiers " *\\|")
5500 gnus-list-identifiers)))
5501
5502 (defun gnus-summary-remove-list-identifiers ()
5503 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5504 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5505 changed subject)
5506 (when regexp
5507 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5508 (dolist (header gnus-newsgroup-headers)
5509 (setq subject (mail-header-subject header)
5510 changed nil)
5511 (while (string-match regexp subject)
5512 (setq subject
5513 (concat (substring subject 0 (match-beginning 1))
5514 (substring subject (match-end 0)))
5515 changed t))
5516 (when changed
5517 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5518 (setq subject
5519 (concat (substring subject 0 (match-beginning 1))
5520 (substring subject (match-end 1)))))
5521 (mail-header-set-subject header subject))))))
5522
5523 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5524 "Fetch headers of ARTICLES."
5525 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5526 (gnus-message 7 "Fetching headers for %s..." name)
5527 (prog1
5528 (if (eq 'nov
5529 (setq gnus-headers-retrieved-by
5530 (gnus-retrieve-headers
5531 articles gnus-newsgroup-name
5532 (or limit
5533 ;; We might want to fetch old headers, but
5534 ;; not if there is only 1 article.
5535 (and (or (and
5536 (not (eq gnus-fetch-old-headers 'some))
5537 (not (numberp gnus-fetch-old-headers)))
5538 (> (length articles) 1))
5539 gnus-fetch-old-headers)))))
5540 (gnus-get-newsgroup-headers-xover
5541 articles force-new dependencies gnus-newsgroup-name t)
5542 (gnus-get-newsgroup-headers dependencies force-new))
5543 (gnus-message 7 "Fetching headers for %s...done" name))))
5544
5545 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5546 "Select newsgroup GROUP.
5547 If READ-ALL is non-nil, all articles in the group are selected.
5548 If SELECT-ARTICLES, only select those articles from GROUP."
5549 (let* ((entry (gnus-group-entry group))
5550 ;;!!! Dirty hack; should be removed.
5551 (gnus-summary-ignore-duplicates
5552 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5553 t
5554 gnus-summary-ignore-duplicates))
5555 (info (nth 2 entry))
5556 charset articles fetched-articles cached)
5557
5558 (unless (gnus-check-server
5559 (set (make-local-variable 'gnus-current-select-method)
5560 (gnus-find-method-for-group group)))
5561 (error "Couldn't open server"))
5562 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5563
5564 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5565 (gnus-activate-group group) ; Or we can activate it...
5566 (progn ; Or we bug out.
5567 (when (equal major-mode 'gnus-summary-mode)
5568 (gnus-kill-buffer (current-buffer)))
5569 (error
5570 "Couldn't activate group %s: %s"
5571 (mm-decode-coding-string group charset)
5572 (mm-decode-coding-string (gnus-status-message group) charset))))
5573
5574 (unless (gnus-request-group group t)
5575 (when (equal major-mode 'gnus-summary-mode)
5576 (gnus-kill-buffer (current-buffer)))
5577 (error "Couldn't request group %s: %s"
5578 (mm-decode-coding-string group charset)
5579 (mm-decode-coding-string (gnus-status-message group) charset)))
5580
5581 (when (and gnus-agent
5582 (gnus-active group))
5583 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5584
5585 (setq gnus-summary-use-undownloaded-faces
5586 (gnus-agent-find-parameter
5587 group
5588 'agent-enable-undownloaded-faces)))
5589
5590 (setq gnus-newsgroup-name group
5591 gnus-newsgroup-unselected nil
5592 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5593
5594 (let ((display (gnus-group-find-parameter group 'display)))
5595 (setq gnus-newsgroup-display
5596 (cond
5597 ((not (zerop (or (car-safe read-all) 0)))
5598 ;; The user entered the group with C-u SPC/RET, let's show
5599 ;; all articles.
5600 'gnus-not-ignore)
5601 ((eq display 'all)
5602 'gnus-not-ignore)
5603 ((arrayp display)
5604 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5605 ((numberp display)
5606 ;; The following is probably the "correct" solution, but
5607 ;; it makes Gnus fetch all headers and then limit the
5608 ;; articles (which is slow), so instead we hack the
5609 ;; select-articles parameter instead. -- Simon Josefsson
5610 ;; <jas@kth.se>
5611 ;;
5612 ;; (gnus-byte-compile
5613 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5614 ;; display)))))
5615 (setq select-articles
5616 (gnus-uncompress-range
5617 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5618 (if (> tmp 0)
5619 tmp
5620 1))
5621 (cdr (gnus-active group)))))
5622 nil)
5623 (t
5624 nil))))
5625
5626 (gnus-summary-setup-default-charset)
5627
5628 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5629 (when (gnus-virtual-group-p group)
5630 (setq cached gnus-newsgroup-cached))
5631
5632 (setq gnus-newsgroup-unreads
5633 (gnus-sorted-ndifference
5634 (gnus-sorted-ndifference gnus-newsgroup-unreads
5635 gnus-newsgroup-marked)
5636 gnus-newsgroup-dormant))
5637
5638 (setq gnus-newsgroup-processable nil)
5639
5640 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5641
5642 ;; Adjust and set lists of article marks.
5643 (when info
5644 (gnus-adjust-marked-articles info))
5645 (if (setq articles select-articles)
5646 (setq gnus-newsgroup-unselected
5647 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5648 (setq articles (gnus-articles-to-read group read-all)))
5649
5650 (cond
5651 ((null articles)
5652 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5653 'quit)
5654 ((eq articles 0) nil)
5655 (t
5656 ;; Init the dependencies hash table.
5657 (setq gnus-newsgroup-dependencies
5658 (gnus-make-hashtable (length articles)))
5659 (if (gnus-buffer-live-p gnus-group-buffer)
5660 (gnus-set-global-variables)
5661 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5662 ;; Retrieve the headers and read them in.
5663
5664 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5665
5666 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5667 (when cached
5668 (setq gnus-newsgroup-cached cached))
5669
5670 ;; Suppress duplicates?
5671 (when gnus-suppress-duplicates
5672 (gnus-dup-suppress-articles))
5673
5674 ;; Set the initial limit.
5675 (setq gnus-newsgroup-limit (copy-sequence articles))
5676 ;; Remove canceled articles from the list of unread articles.
5677 (setq fetched-articles
5678 (mapcar (lambda (headers) (mail-header-number headers))
5679 gnus-newsgroup-headers))
5680 (setq gnus-newsgroup-articles fetched-articles)
5681 (setq gnus-newsgroup-unreads
5682 (gnus-sorted-nintersection
5683 gnus-newsgroup-unreads fetched-articles))
5684 (gnus-compute-unseen-list)
5685
5686 ;; Removed marked articles that do not exist.
5687 (gnus-update-missing-marks
5688 (gnus-sorted-difference articles fetched-articles))
5689 ;; We might want to build some more threads first.
5690 (when (and gnus-fetch-old-headers
5691 (eq gnus-headers-retrieved-by 'nov))
5692 (if (eq gnus-fetch-old-headers 'invisible)
5693 (gnus-build-all-threads)
5694 (gnus-build-old-threads)))
5695 ;; Let the Gnus agent mark articles as read.
5696 (when gnus-agent
5697 (gnus-agent-get-undownloaded-list))
5698 ;; Remove list identifiers from subject
5699 (gnus-summary-remove-list-identifiers)
5700 ;; Check whether auto-expire is to be done in this group.
5701 (setq gnus-newsgroup-auto-expire
5702 (and (gnus-group-auto-expirable-p group)
5703 (not (gnus-group-read-only-p group))))
5704 ;; Set up the article buffer now, if necessary.
5705 (unless (and gnus-single-article-buffer
5706 (equal gnus-article-buffer "*Article*"))
5707 (gnus-article-setup-buffer))
5708 ;; First and last article in this newsgroup.
5709 (when gnus-newsgroup-headers
5710 (setq gnus-newsgroup-begin
5711 (mail-header-number (car gnus-newsgroup-headers))
5712 gnus-newsgroup-end
5713 (mail-header-number
5714 (gnus-last-element gnus-newsgroup-headers))))
5715 ;; GROUP is successfully selected.
5716 (or gnus-newsgroup-headers t)))))
5717
5718 (defun gnus-compute-unseen-list ()
5719 ;; The `seen' marks are treated specially.
5720 (if (not gnus-newsgroup-seen)
5721 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5722 (setq gnus-newsgroup-unseen
5723 (gnus-inverse-list-range-intersection
5724 gnus-newsgroup-articles gnus-newsgroup-seen))))
5725
5726 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5727
5728 (defun gnus-summary-display-make-predicate (display)
5729 (require 'gnus-agent)
5730 (when (= (length display) 1)
5731 (setq display (car display)))
5732 (unless gnus-summary-display-cache
5733 (dolist (elem (append '((unread . unread)
5734 (read . read)
5735 (unseen . unseen))
5736 gnus-article-mark-lists))
5737 (push (cons (cdr elem)
5738 (gnus-byte-compile ;Why bother?
5739 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5740 gnus-summary-display-cache)))
5741 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5742 (gnus-category-predicate-cache gnus-summary-display-cache))
5743 (gnus-get-predicate display)))
5744
5745 ;; Uses the dynamically bound `gnus-number' variable.
5746 (defvar gnus-number)
5747 (defun gnus-article-marked-p (type &optional article)
5748 (let ((article (or article gnus-number)))
5749 (cond
5750 ((eq type 'tick)
5751 (memq article gnus-newsgroup-marked))
5752 ((eq type 'spam)
5753 (memq article gnus-newsgroup-spam-marked))
5754 ((eq type 'unsend)
5755 (memq article gnus-newsgroup-unsendable))
5756 ((eq type 'undownload)
5757 (memq article gnus-newsgroup-undownloaded))
5758 ((eq type 'download)
5759 (memq article gnus-newsgroup-downloadable))
5760 ((eq type 'unread)
5761 (memq article gnus-newsgroup-unreads))
5762 ((eq type 'read)
5763 (memq article gnus-newsgroup-reads))
5764 ((eq type 'dormant)
5765 (memq article gnus-newsgroup-dormant) )
5766 ((eq type 'expire)
5767 (memq article gnus-newsgroup-expirable))
5768 ((eq type 'reply)
5769 (memq article gnus-newsgroup-replied))
5770 ((eq type 'killed)
5771 (memq article gnus-newsgroup-killed))
5772 ((eq type 'bookmark)
5773 (assq article gnus-newsgroup-bookmarks))
5774 ((eq type 'score)
5775 (assq article gnus-newsgroup-scored))
5776 ((eq type 'save)
5777 (memq article gnus-newsgroup-saved))
5778 ((eq type 'cache)
5779 (memq article gnus-newsgroup-cached))
5780 ((eq type 'forward)
5781 (memq article gnus-newsgroup-forwarded))
5782 ((eq type 'seen)
5783 (not (memq article gnus-newsgroup-unseen)))
5784 (t t))))
5785
5786 (defun gnus-articles-to-read (group &optional read-all)
5787 "Find out what articles the user wants to read."
5788 (let* ((only-read-p t)
5789 (articles
5790 ;; Select all articles if `read-all' is non-nil, or if there
5791 ;; are no unread articles.
5792 (if (or read-all
5793 (and (zerop (length gnus-newsgroup-marked))
5794 (zerop (length gnus-newsgroup-unreads)))
5795 ;; Fetch all if the predicate is non-nil.
5796 gnus-newsgroup-display)
5797 ;; We want to select the headers for all the articles in
5798 ;; the group, so we select either all the active
5799 ;; articles in the group, or (if that's nil), the
5800 ;; articles in the cache.
5801 (or
5802 (if gnus-newsgroup-maximum-articles
5803 (let ((active (gnus-active group)))
5804 (gnus-uncompress-range
5805 (cons (max (car active)
5806 (- (cdr active)
5807 gnus-newsgroup-maximum-articles
5808 -1))
5809 (cdr active))))
5810 (gnus-uncompress-range (gnus-active group)))
5811 (gnus-cache-articles-in-group group))
5812 ;; Select only the "normal" subset of articles.
5813 (setq only-read-p nil)
5814 (gnus-sorted-nunion
5815 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5816 gnus-newsgroup-unreads)))
5817 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5818 (scored (length scored-list))
5819 (number (length articles))
5820 (marked (+ (length gnus-newsgroup-marked)
5821 (length gnus-newsgroup-dormant)))
5822 (select
5823 (cond
5824 ((numberp read-all)
5825 read-all)
5826 ((numberp gnus-newsgroup-display)
5827 gnus-newsgroup-display)
5828 (t
5829 (condition-case ()
5830 (cond
5831 ((and (or (<= scored marked) (= scored number))
5832 (numberp gnus-large-newsgroup)
5833 (> number gnus-large-newsgroup))
5834 (let* ((cursor-in-echo-area nil)
5835 (initial (gnus-parameter-large-newsgroup-initial
5836 gnus-newsgroup-name))
5837 (default (if only-read-p
5838 (or initial gnus-large-newsgroup)
5839 number))
5840 (input
5841 (read-string
5842 (if only-read-p
5843 (format
5844 "How many articles from %s (available %d, default %d): "
5845 (gnus-group-decoded-name
5846 (gnus-group-real-name gnus-newsgroup-name))
5847 number default)
5848 (format
5849 "How many articles from %s (%d default): "
5850 (gnus-group-decoded-name
5851 (gnus-group-real-name gnus-newsgroup-name))
5852 default))
5853 nil
5854 nil
5855 (number-to-string default))))
5856 (if (string-match "^[ \t]*$" input) number input)))
5857 ((and (> scored marked) (< scored number)
5858 (> (- scored number) 20))
5859 (let ((input
5860 (read-string
5861 (format "%s %s (%d scored, %d total): "
5862 "How many articles from"
5863 (gnus-group-decoded-name
5864 (gnus-group-real-name gnus-newsgroup-name))
5865 scored number))))
5866 (if (string-match "^[ \t]*$" input)
5867 number input)))
5868 (t number))
5869 (quit
5870 (message "Quit getting the articles to read")
5871 nil))))))
5872 (setq select (if (stringp select) (string-to-number select) select))
5873 (if (or (null select) (zerop select))
5874 select
5875 (if (and (not (zerop scored)) (<= (abs select) scored))
5876 (progn
5877 (setq articles (sort scored-list '<))
5878 (setq number (length articles)))
5879 (setq articles (copy-sequence articles)))
5880
5881 (when (< (abs select) number)
5882 (if (< select 0)
5883 ;; Select the N oldest articles.
5884 (setcdr (nthcdr (1- (abs select)) articles) nil)
5885 ;; Select the N most recent articles.
5886 (setq articles (nthcdr (- number select) articles))))
5887 (setq gnus-newsgroup-unselected
5888 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5889 (when gnus-alter-articles-to-read-function
5890 (setq articles
5891 (sort
5892 (funcall gnus-alter-articles-to-read-function
5893 gnus-newsgroup-name articles)
5894 '<)))
5895 articles)))
5896
5897 (defun gnus-killed-articles (killed articles)
5898 (let (out)
5899 (while articles
5900 (when (inline (gnus-member-of-range (car articles) killed))
5901 (push (car articles) out))
5902 (setq articles (cdr articles)))
5903 out))
5904
5905 (defun gnus-article-mark-to-type (mark)
5906 "Return the type of MARK."
5907 (or (cadr (assq mark gnus-article-special-mark-lists))
5908 'list))
5909
5910 (defun gnus-article-unpropagatable-p (mark)
5911 "Return whether MARK should be propagated to back end."
5912 (memq mark gnus-article-unpropagated-mark-lists))
5913
5914 (defun gnus-adjust-marked-articles (info)
5915 "Set all article lists and remove all marks that are no longer valid."
5916 (let* ((marked-lists (gnus-info-marks info))
5917 (active (gnus-active (gnus-info-group info)))
5918 (min (car active))
5919 (max (cdr active))
5920 (types gnus-article-mark-lists)
5921 marks var articles article mark mark-type
5922 bgn end)
5923 ;; Hack to avoid adjusting marks for imap.
5924 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5925 'nnimap)
5926 (setq min 1))
5927
5928 (dolist (marks marked-lists)
5929 (setq mark (car marks)
5930 mark-type (gnus-article-mark-to-type mark)
5931 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5932 ;; We set the variable according to the type of the marks list,
5933 ;; and then adjust the marks to a subset of the active articles.
5934 (cond
5935 ;; Adjust "simple" lists - compressed yet unsorted
5936 ((eq mark-type 'list)
5937 ;; Simultaneously uncompress and clip to active range
5938 ;; See gnus-uncompress-range for a description of possible marks
5939 (let (l lh)
5940 (if (not (cadr marks))
5941 (set var nil)
5942 (setq articles (if (numberp (cddr marks))
5943 (list (cdr marks))
5944 (cdr marks))
5945 lh (cons nil nil)
5946 l lh)
5947
5948 (while (setq article (pop articles))
5949 (cond ((consp article)
5950 (setq bgn (max (car article) min)
5951 end (min (cdr article) max))
5952 (while (<= bgn end)
5953 (setq l (setcdr l (cons bgn nil))
5954 bgn (1+ bgn))))
5955 ((and (<= min article)
5956 (>= max article))
5957 (setq l (setcdr l (cons article nil))))))
5958 (set var (cdr lh)))))
5959 ;; Adjust assocs.
5960 ((eq mark-type 'tuple)
5961 (set var (setq articles (cdr marks)))
5962 (when (not (listp (cdr (symbol-value var))))
5963 (set var (list (symbol-value var))))
5964 (when (not (listp (cdr articles)))
5965 (setq articles (list articles)))
5966 (while articles
5967 (when (or (not (consp (setq article (pop articles))))
5968 (< (car article) min)
5969 (> (car article) max))
5970 (set var (delq article (symbol-value var))))))
5971 ;; Adjust ranges (sloppily).
5972 ((eq mark-type 'range)
5973 (cond
5974 ((eq mark 'seen)
5975 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5976 ;; It should be (seen (NUM1 . NUM2)).
5977 (when (numberp (cddr marks))
5978 (setcdr marks (list (cdr marks))))
5979 (setq articles (cdr marks))
5980 (while (and articles
5981 (or (and (consp (car articles))
5982 (> min (cdar articles)))
5983 (and (numberp (car articles))
5984 (> min (car articles)))))
5985 (pop articles))
5986 (set var articles))))))))
5987
5988 (defun gnus-update-missing-marks (missing)
5989 "Go through the list of MISSING articles and remove them from the mark lists."
5990 (when missing
5991 (let (var m)
5992 ;; Go through all types.
5993 (dolist (elem gnus-article-mark-lists)
5994 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5995 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5996 (when (symbol-value var)
5997 ;; This list has articles. So we delete all missing
5998 ;; articles from it.
5999 (setq m missing)
6000 (while m
6001 (set var (delq (pop m) (symbol-value var))))))))))
6002
6003 (defun gnus-update-marks ()
6004 "Enter the various lists of marked articles into the newsgroup info list."
6005 (let ((types gnus-article-mark-lists)
6006 (info (gnus-get-info gnus-newsgroup-name))
6007 type list newmarked symbol delta-marks)
6008 (when info
6009 ;; Add all marks lists to the list of marks lists.
6010 (while (setq type (pop types))
6011 (setq list (symbol-value
6012 (setq symbol
6013 (intern (format "gnus-newsgroup-%s" (car type))))))
6014
6015 (when list
6016 ;; Get rid of the entries of the articles that have the
6017 ;; default score.
6018 (when (and (eq (cdr type) 'score)
6019 gnus-save-score
6020 list)
6021 (let* ((arts list)
6022 (prev (cons nil list))
6023 (all prev))
6024 (while arts
6025 (if (or (not (consp (car arts)))
6026 (= (cdar arts) gnus-summary-default-score))
6027 (setcdr prev (cdr arts))
6028 (setq prev arts))
6029 (setq arts (cdr arts)))
6030 (setq list (cdr all)))))
6031
6032 (when (eq (cdr type) 'seen)
6033 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6034
6035 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6036 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6037
6038 (when (and (gnus-check-backend-function
6039 'request-set-mark gnus-newsgroup-name)
6040 (not (gnus-article-unpropagatable-p (cdr type))))
6041 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6042 ;; Don't do anything about marks for articles we
6043 ;; didn't actually get any headers for.
6044 (del
6045 (gnus-list-range-intersection
6046 gnus-newsgroup-articles
6047 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6048 (add
6049 (gnus-list-range-intersection
6050 gnus-newsgroup-articles
6051 (gnus-remove-from-range
6052 (gnus-copy-sequence list) old))))
6053 (when add
6054 (push (list add 'add (list (cdr type))) delta-marks))
6055 (when del
6056 ;; Don't delete marks from outside the active range.
6057 ;; This shouldn't happen, but is a sanity check.
6058 (setq del (gnus-sorted-range-intersection
6059 (gnus-active gnus-newsgroup-name) del))
6060 (push (list del 'del (list (cdr type))) delta-marks))))
6061
6062 (when list
6063 (push (cons (cdr type) list) newmarked)))
6064
6065 (when delta-marks
6066 (unless (gnus-check-group gnus-newsgroup-name)
6067 (error "Can't open server for %s" gnus-newsgroup-name))
6068 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6069
6070 ;; Enter these new marks into the info of the group.
6071 (if (nthcdr 3 info)
6072 (setcar (nthcdr 3 info) newmarked)
6073 ;; Add the marks lists to the end of the info.
6074 (when newmarked
6075 (setcdr (nthcdr 2 info) (list newmarked))))
6076
6077 ;; Cut off the end of the info if there's nothing else there.
6078 (let ((i 5))
6079 (while (and (> i 2)
6080 (not (nth i info)))
6081 (when (nthcdr (decf i) info)
6082 (setcdr (nthcdr i info) nil)))))))
6083
6084 (defun gnus-set-mode-line (where)
6085 "Set the mode line of the article or summary buffers.
6086 If WHERE is `summary', the summary mode line format will be used."
6087 ;; Is this mode line one we keep updated?
6088 (when (and (memq where gnus-updated-mode-lines)
6089 (symbol-value
6090 (intern (format "gnus-%s-mode-line-format-spec" where))))
6091 (let (mode-string)
6092 ;; We evaluate this in the summary buffer since these
6093 ;; variables are buffer-local to that buffer.
6094 (with-current-buffer gnus-summary-buffer
6095 ;; We bind all these variables that are used in the `eval' form
6096 ;; below.
6097 (let* ((mformat (symbol-value
6098 (intern
6099 (format "gnus-%s-mode-line-format-spec" where))))
6100 (gnus-tmp-group-name (gnus-mode-string-quote
6101 (gnus-group-decoded-name
6102 gnus-newsgroup-name)))
6103 (gnus-tmp-article-number (or gnus-current-article 0))
6104 (gnus-tmp-unread gnus-newsgroup-unreads)
6105 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6106 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6107 (gnus-tmp-unread-and-unselected
6108 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6109 (zerop gnus-tmp-unselected))
6110 "")
6111 ((zerop gnus-tmp-unselected)
6112 (format "{%d more}" gnus-tmp-unread-and-unticked))
6113 (t (format "{%d(+%d) more}"
6114 gnus-tmp-unread-and-unticked
6115 gnus-tmp-unselected))))
6116 (gnus-tmp-subject
6117 (if (and gnus-current-headers
6118 (vectorp gnus-current-headers))
6119 (gnus-mode-string-quote
6120 (mail-header-subject gnus-current-headers))
6121 ""))
6122 bufname-length max-len
6123 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6124 (setq mode-string (eval mformat))
6125 (setq bufname-length (if (string-match "%b" mode-string)
6126 (- (length
6127 (buffer-name
6128 (if (eq where 'summary)
6129 nil
6130 (get-buffer gnus-article-buffer))))
6131 2)
6132 0))
6133 (setq max-len (max 4 (if gnus-mode-non-string-length
6134 (- (window-width)
6135 gnus-mode-non-string-length
6136 bufname-length)
6137 (length mode-string))))
6138 ;; We might have to chop a bit of the string off...
6139 (when (> (length mode-string) max-len)
6140 (setq mode-string
6141 (concat (truncate-string-to-width mode-string (- max-len 3))
6142 "...")))))
6143 ;; Update the mode line.
6144 (setq mode-line-buffer-identification
6145 (gnus-mode-line-buffer-identification (list mode-string)))
6146 (set-buffer-modified-p t))))
6147
6148 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6149 "Go through the HEADERS list and add all Xrefs to a hash table.
6150 The resulting hash table is returned, or nil if no Xrefs were found."
6151 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6152 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6153 (xref-hashtb (gnus-make-hashtable))
6154 start group entry number xrefs header)
6155 (while headers
6156 (setq header (pop headers))
6157 (when (and (setq xrefs (mail-header-xref header))
6158 (not (memq (setq number (mail-header-number header))
6159 unreads)))
6160 (setq start 0)
6161 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6162 (setq start (match-end 0))
6163 (setq group (if prefix
6164 (concat prefix (substring xrefs (match-beginning 1)
6165 (match-end 1)))
6166 (substring xrefs (match-beginning 1) (match-end 1))))
6167 (setq number
6168 (string-to-number (substring xrefs (match-beginning 2)
6169 (match-end 2))))
6170 (if (setq entry (gnus-gethash group xref-hashtb))
6171 (setcdr entry (cons number (cdr entry)))
6172 (gnus-sethash group (cons number nil) xref-hashtb)))))
6173 (and start xref-hashtb)))
6174
6175 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6176 "Look through all the headers and mark the Xrefs as read."
6177 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6178 name info xref-hashtb idlist method nth4)
6179 (with-current-buffer gnus-group-buffer
6180 (when (setq xref-hashtb
6181 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6182 (mapatoms
6183 (lambda (group)
6184 (unless (string= from-newsgroup (setq name (symbol-name group)))
6185 (setq idlist (symbol-value group))
6186 ;; Dead groups are not updated.
6187 (and (prog1
6188 (setq info (gnus-get-info name))
6189 (when (stringp (setq nth4 (gnus-info-method info)))
6190 (setq nth4 (gnus-server-to-method nth4))))
6191 ;; Only do the xrefs if the group has the same
6192 ;; select method as the group we have just read.
6193 (or (gnus-methods-equal-p
6194 nth4 (gnus-find-method-for-group from-newsgroup))
6195 virtual
6196 (equal nth4 (setq method (gnus-find-method-for-group
6197 from-newsgroup)))
6198 (and (equal (car nth4) (car method))
6199 (equal (nth 1 nth4) (nth 1 method))))
6200 gnus-use-cross-reference
6201 (or (not (eq gnus-use-cross-reference t))
6202 virtual
6203 ;; Only do cross-references on subscribed
6204 ;; groups, if that is what is wanted.
6205 (<= (gnus-info-level info) gnus-level-subscribed))
6206 (gnus-group-make-articles-read name idlist))))
6207 xref-hashtb)))))
6208
6209 (defun gnus-compute-read-articles (group articles)
6210 (let* ((entry (gnus-group-entry group))
6211 (info (nth 2 entry))
6212 (active (gnus-active group))
6213 ninfo)
6214 (when entry
6215 ;; First peel off all invalid article numbers.
6216 (when active
6217 (let ((ids articles)
6218 id first)
6219 (while (setq id (pop ids))
6220 (when (and first (> id (cdr active)))
6221 ;; We'll end up in this situation in one particular
6222 ;; obscure situation. If you re-scan a group and get
6223 ;; a new article that is cross-posted to a different
6224 ;; group that has not been re-scanned, you might get
6225 ;; crossposted article that has a higher number than
6226 ;; Gnus believes possible. So we re-activate this
6227 ;; group as well. This might mean doing the
6228 ;; crossposting thingy will *increase* the number
6229 ;; of articles in some groups. Tsk, tsk.
6230 (setq active (or (gnus-activate-group group) active)))
6231 (when (or (> id (cdr active))
6232 (< id (car active)))
6233 (setq articles (delq id articles))))))
6234 ;; If the read list is nil, we init it.
6235 (if (and active
6236 (null (gnus-info-read info))
6237 (> (car active) 1))
6238 (setq ninfo (cons 1 (1- (car active))))
6239 (setq ninfo (gnus-info-read info)))
6240 ;; Then we add the read articles to the range.
6241 (gnus-add-to-range
6242 ninfo (setq articles (sort articles '<))))))
6243
6244 (defun gnus-group-make-articles-read (group articles)
6245 "Update the info of GROUP to say that ARTICLES are read."
6246 (let* ((num 0)
6247 (entry (gnus-group-entry group))
6248 (info (nth 2 entry))
6249 (active (gnus-active group))
6250 (set-marks
6251 (gnus-method-option-p
6252 (gnus-find-method-for-group group)
6253 'server-marks))
6254 range)
6255 (if (not entry)
6256 ;; Group that Gnus doesn't know exists, but still allow the
6257 ;; backend to set marks.
6258 (when set-marks
6259 (gnus-request-set-mark
6260 group (list (list (gnus-compress-sequence (sort articles #'<))
6261 'add '(read)))))
6262 ;; Normal, subscribed groups.
6263 (setq range (gnus-compute-read-articles group articles))
6264 (with-current-buffer gnus-group-buffer
6265 (gnus-undo-register
6266 `(progn
6267 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6268 (gnus-info-set-read ',info ',(gnus-info-read info))
6269 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6270 (when ,set-marks
6271 (gnus-request-set-mark
6272 ,group (list (list ',range 'del '(read)))))
6273 (gnus-group-update-group ,group t))))
6274 ;; Add the read articles to the range.
6275 (gnus-info-set-read info range)
6276 (when set-marks
6277 (gnus-request-set-mark group (list (list range 'add '(read)))))
6278 ;; Then we have to re-compute how many unread
6279 ;; articles there are in this group.
6280 (when active
6281 (cond
6282 ((not range)
6283 (setq num (- (1+ (cdr active)) (car active))))
6284 ((not (listp (cdr range)))
6285 (setq num (- (cdr active) (- (1+ (cdr range))
6286 (car range)))))
6287 (t
6288 (while range
6289 (if (numberp (car range))
6290 (setq num (1+ num))
6291 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6292 (setq range (cdr range)))
6293 (setq num (- (cdr active) num))))
6294 ;; Update the number of unread articles.
6295 (setcar entry num)
6296 ;; Update the group buffer.
6297 (unless (gnus-ephemeral-group-p group)
6298 (gnus-group-update-group group t))))))
6299
6300 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6301 (let ((cur nntp-server-buffer)
6302 (dependencies
6303 (or dependencies
6304 (with-current-buffer gnus-summary-buffer
6305 gnus-newsgroup-dependencies)))
6306 headers id end ref number
6307 (mail-parse-charset gnus-newsgroup-charset)
6308 (mail-parse-ignored-charsets
6309 (save-current-buffer (condition-case nil
6310 (set-buffer gnus-summary-buffer)
6311 (error))
6312 gnus-newsgroup-ignored-charsets)))
6313 (with-current-buffer nntp-server-buffer
6314 ;; Translate all TAB characters into SPACE characters.
6315 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6316 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6317 (ietf-drums-unfold-fws)
6318 (gnus-run-hooks 'gnus-parse-headers-hook)
6319 (let ((case-fold-search t)
6320 in-reply-to header p lines chars)
6321 (goto-char (point-min))
6322 ;; Search to the beginning of the next header. Error messages
6323 ;; do not begin with 2 or 3.
6324 (while (re-search-forward "^[23][0-9]+ " nil t)
6325 (setq id nil
6326 ref nil)
6327 ;; This implementation of this function, with nine
6328 ;; search-forwards instead of the one re-search-forward and
6329 ;; a case (which basically was the old function) is actually
6330 ;; about twice as fast, even though it looks messier. You
6331 ;; can't have everything, I guess. Speed and elegance
6332 ;; doesn't always go hand in hand.
6333 (setq
6334 header
6335 (vector
6336 ;; Number.
6337 (prog1
6338 (setq number (read cur))
6339 (end-of-line)
6340 (setq p (point))
6341 (narrow-to-region (point)
6342 (or (and (search-forward "\n.\n" nil t)
6343 (- (point) 2))
6344 (point))))
6345 ;; Subject.
6346 (progn
6347 (goto-char p)
6348 (if (search-forward "\nsubject:" nil t)
6349 (funcall gnus-decode-encoded-word-function
6350 (nnheader-header-value))
6351 "(none)"))
6352 ;; From.
6353 (progn
6354 (goto-char p)
6355 (if (search-forward "\nfrom:" nil t)
6356 (funcall gnus-decode-encoded-address-function
6357 (nnheader-header-value))
6358 "(nobody)"))
6359 ;; Date.
6360 (progn
6361 (goto-char p)
6362 (if (search-forward "\ndate:" nil t)
6363 (nnheader-header-value) ""))
6364 ;; Message-ID.
6365 (progn
6366 (goto-char p)
6367 (setq id (if (re-search-forward
6368 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6369 ;; We do it this way to make sure the Message-ID
6370 ;; is (somewhat) syntactically valid.
6371 (buffer-substring (match-beginning 1)
6372 (match-end 1))
6373 ;; If there was no message-id, we just fake one
6374 ;; to make subsequent routines simpler.
6375 (nnheader-generate-fake-message-id number))))
6376 ;; References.
6377 (progn
6378 (goto-char p)
6379 (if (search-forward "\nreferences:" nil t)
6380 (progn
6381 (setq end (point))
6382 (prog1
6383 (nnheader-header-value)
6384 (setq ref
6385 (buffer-substring
6386 (progn
6387 (end-of-line)
6388 (search-backward ">" end t)
6389 (1+ (point)))
6390 (progn
6391 (search-backward "<" end t)
6392 (point))))))
6393 ;; Get the references from the in-reply-to header if there
6394 ;; were no references and the in-reply-to header looks
6395 ;; promising.
6396 (if (and (search-forward "\nin-reply-to:" nil t)
6397 (setq in-reply-to (nnheader-header-value))
6398 (string-match "<[^>]+>" in-reply-to))
6399 (let (ref2)
6400 (setq ref (substring in-reply-to (match-beginning 0)
6401 (match-end 0)))
6402 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6403 (setq ref2 (substring in-reply-to (match-beginning 0)
6404 (match-end 0)))
6405 (when (> (length ref2) (length ref))
6406 (setq ref ref2)))
6407 ref)
6408 (setq ref nil))))
6409 ;; Chars.
6410 (progn
6411 (goto-char p)
6412 (if (search-forward "\nchars: " nil t)
6413 (if (numberp (setq chars (ignore-errors (read cur))))
6414 chars -1)
6415 -1))
6416 ;; Lines.
6417 (progn
6418 (goto-char p)
6419 (if (search-forward "\nlines: " nil t)
6420 (if (numberp (setq lines (ignore-errors (read cur))))
6421 lines -1)
6422 -1))
6423 ;; Xref.
6424 (progn
6425 (goto-char p)
6426 (and (search-forward "\nxref:" nil t)
6427 (nnheader-header-value)))
6428 ;; Extra.
6429 (when gnus-extra-headers
6430 (let ((extra gnus-extra-headers)
6431 out)
6432 (while extra
6433 (goto-char p)
6434 (when (search-forward
6435 (concat "\n" (symbol-name (car extra)) ":") nil t)
6436 (push (cons (car extra) (nnheader-header-value))
6437 out))
6438 (pop extra))
6439 out))))
6440 (when (equal id ref)
6441 (setq ref nil))
6442
6443 (when gnus-alter-header-function
6444 (funcall gnus-alter-header-function header)
6445 (setq id (mail-header-id header)
6446 ref (gnus-parent-id (mail-header-references header))))
6447
6448 (when (setq header
6449 (gnus-dependencies-add-header
6450 header dependencies force-new))
6451 (push header headers))
6452 (goto-char (point-max))
6453 (widen))
6454 (nreverse headers)))))
6455
6456 ;; Goes through the xover lines and returns a list of vectors
6457 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6458 force-new dependencies
6459 group also-fetch-heads)
6460 "Parse the news overview data in the server buffer.
6461 Return a list of headers that match SEQUENCE (see
6462 `nntp-retrieve-headers')."
6463 ;; Get the Xref when the users reads the articles since most/some
6464 ;; NNTP servers do not include Xrefs when using XOVER.
6465 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6466 (let ((mail-parse-charset gnus-newsgroup-charset)
6467 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6468 (cur nntp-server-buffer)
6469 (dependencies (or dependencies gnus-newsgroup-dependencies))
6470 (allp (cond
6471 ((eq gnus-read-all-available-headers t)
6472 t)
6473 ((and (stringp gnus-read-all-available-headers)
6474 group)
6475 (string-match gnus-read-all-available-headers group))
6476 (t
6477 nil)))
6478 number headers header)
6479 (with-current-buffer nntp-server-buffer
6480 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6481 ;; Allow the user to mangle the headers before parsing them.
6482 (gnus-run-hooks 'gnus-parse-headers-hook)
6483 (goto-char (point-min))
6484 (gnus-parse-without-error
6485 (while (and (or sequence allp)
6486 (not (eobp)))
6487 (setq number (read cur))
6488 (when (not allp)
6489 (while (and sequence
6490 (< (car sequence) number))
6491 (setq sequence (cdr sequence))))
6492 (when (and (or allp
6493 (and sequence
6494 (eq number (car sequence))))
6495 (progn
6496 (setq sequence (cdr sequence))
6497 (setq header (inline
6498 (gnus-nov-parse-line
6499 number dependencies force-new)))))
6500 (push header headers))
6501 (forward-line 1)))
6502 ;; A common bug in inn is that if you have posted an article and
6503 ;; then retrieves the active file, it will answer correctly --
6504 ;; the new article is included. However, a NOV entry for the
6505 ;; article may not have been generated yet, so this may fail.
6506 ;; We work around this problem by retrieving the last few
6507 ;; headers using HEAD.
6508 (if (or (not also-fetch-heads)
6509 (not sequence))
6510 ;; We (probably) got all the headers.
6511 (nreverse headers)
6512 (let ((gnus-nov-is-evil t))
6513 (nconc
6514 (nreverse headers)
6515 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6516 (gnus-get-newsgroup-headers))))))))
6517
6518 (defun gnus-article-get-xrefs ()
6519 "Fill in the Xref value in `gnus-current-headers', if necessary.
6520 This is meant to be called in `gnus-article-internal-prepare-hook'."
6521 (let ((headers (with-current-buffer gnus-summary-buffer
6522 gnus-current-headers)))
6523 (or (not gnus-use-cross-reference)
6524 (not headers)
6525 (and (mail-header-xref headers)
6526 (not (string= (mail-header-xref headers) "")))
6527 (let ((case-fold-search t)
6528 xref)
6529 (save-restriction
6530 (nnheader-narrow-to-headers)
6531 (goto-char (point-min))
6532 (when (or (and (not (eobp))
6533 (eq (downcase (char-after)) ?x)
6534 (looking-at "Xref:"))
6535 (search-forward "\nXref:" nil t))
6536 (goto-char (1+ (match-end 0)))
6537 (setq xref (buffer-substring (point) (point-at-eol)))
6538 (mail-header-set-xref headers xref)))))))
6539
6540 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6541 "Find article ID and insert the summary line for that article.
6542 OLD-HEADER can either be a header or a line number to insert
6543 the subject line on.
6544 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6545 and OLD-HEADER will be used when the summary line is inserted,
6546 too, instead of trying to fetch new headers."
6547 (let* ((line (and (numberp old-header) old-header))
6548 (old-header (and (vectorp old-header) old-header))
6549 (header (cond ((and old-header use-old-header)
6550 old-header)
6551 ((and (numberp id)
6552 (gnus-number-to-header id))
6553 (gnus-number-to-header id))
6554 (t
6555 (gnus-read-header id))))
6556 (number (and (numberp id) id))
6557 d)
6558 (when header
6559 ;; Rebuild the thread that this article is part of and go to the
6560 ;; article we have fetched.
6561 (when (and (not gnus-show-threads)
6562 old-header)
6563 (when (and number
6564 (setq d (gnus-data-find (mail-header-number old-header))))
6565 (goto-char (gnus-data-pos d))
6566 (gnus-data-remove
6567 number
6568 (- (point-at-bol)
6569 (prog1
6570 (1+ (point-at-eol))
6571 (gnus-delete-line))))))
6572 ;; Remove list identifiers from subject.
6573 (let ((gnus-newsgroup-headers (list header)))
6574 (gnus-summary-remove-list-identifiers))
6575 (when old-header
6576 (mail-header-set-number header (mail-header-number old-header)))
6577 (setq gnus-newsgroup-sparse
6578 (delq (setq number (mail-header-number header))
6579 gnus-newsgroup-sparse))
6580 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6581 (push number gnus-newsgroup-limit)
6582 (gnus-rebuild-thread (mail-header-id header) line)
6583 (gnus-summary-goto-subject number nil t))
6584 (when (and (numberp number)
6585 (> number 0))
6586 ;; We have to update the boundaries even if we can't fetch the
6587 ;; article if ID is a number -- so that the next `P' or `N'
6588 ;; command will fetch the previous (or next) article even
6589 ;; if the one we tried to fetch this time has been canceled.
6590 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6591 (setq gnus-newsgroup-end number))
6592 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6593 (setq gnus-newsgroup-begin number))
6594 (setq gnus-newsgroup-unselected
6595 (delq number gnus-newsgroup-unselected)))
6596 ;; Report back a success?
6597 (and header (mail-header-number header))))
6598
6599 ;;; Process/prefix in the summary buffer
6600
6601 (defun gnus-summary-work-articles (n)
6602 "Return a list of articles to be worked upon.
6603 The prefix argument, the list of process marked articles, and the
6604 current article will be taken into consideration."
6605 (with-current-buffer gnus-summary-buffer
6606 (cond
6607 (n
6608 ;; A numerical prefix has been given.
6609 (setq n (prefix-numeric-value n))
6610 (let ((backward (< n 0))
6611 (n (abs (prefix-numeric-value n)))
6612 articles article)
6613 (save-excursion
6614 (while
6615 (and (> n 0)
6616 (push (setq article (gnus-summary-article-number))
6617 articles)
6618 (if backward
6619 (gnus-summary-find-prev nil article)
6620 (gnus-summary-find-next nil article)))
6621 (decf n)))
6622 (nreverse articles)))
6623 ((and (gnus-region-active-p) (mark))
6624 (message "region active")
6625 ;; Work on the region between point and mark.
6626 (let ((max (max (point) (mark)))
6627 articles article)
6628 (save-excursion
6629 (goto-char (min (point) (mark)))
6630 (while
6631 (and
6632 (push (setq article (gnus-summary-article-number)) articles)
6633 (gnus-summary-find-next nil article)
6634 (< (point) max)))
6635 (nreverse articles))))
6636 (gnus-newsgroup-processable
6637 ;; There are process-marked articles present.
6638 ;; Save current state.
6639 (gnus-summary-save-process-mark)
6640 ;; Return the list.
6641 (reverse gnus-newsgroup-processable))
6642 (t
6643 ;; Just return the current article.
6644 (list (gnus-summary-article-number))))))
6645
6646 (defmacro gnus-summary-iterate (arg &rest forms)
6647 "Iterate over the process/prefixed articles and do FORMS.
6648 ARG is the interactive prefix given to the command. FORMS will be
6649 executed with point over the summary line of the articles."
6650 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6651 `(let ((,articles (gnus-summary-work-articles ,arg)))
6652 (while ,articles
6653 (gnus-summary-goto-subject (car ,articles))
6654 ,@forms
6655 (pop ,articles)))))
6656
6657 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6658 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6659
6660 (defun gnus-summary-save-process-mark ()
6661 "Push the current set of process marked articles on the stack."
6662 (interactive)
6663 (push (copy-sequence gnus-newsgroup-processable)
6664 gnus-newsgroup-process-stack))
6665
6666 (defun gnus-summary-kill-process-mark ()
6667 "Push the current set of process marked articles on the stack and unmark."
6668 (interactive)
6669 (gnus-summary-save-process-mark)
6670 (gnus-summary-unmark-all-processable))
6671
6672 (defun gnus-summary-yank-process-mark ()
6673 "Pop the last process mark state off the stack and restore it."
6674 (interactive)
6675 (unless gnus-newsgroup-process-stack
6676 (error "Empty mark stack"))
6677 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6678
6679 (defun gnus-summary-process-mark-set (set)
6680 "Make SET into the current process marked articles."
6681 (gnus-summary-unmark-all-processable)
6682 (mapc 'gnus-summary-set-process-mark set))
6683
6684 ;;; Searching and stuff
6685
6686 (defun gnus-summary-search-group (&optional backward use-level)
6687 "Search for next unread newsgroup.
6688 If optional argument BACKWARD is non-nil, search backward instead."
6689 (with-current-buffer gnus-group-buffer
6690 (when (gnus-group-search-forward
6691 backward nil (if use-level (gnus-group-group-level) nil))
6692 (gnus-group-group-name))))
6693
6694 (defun gnus-summary-best-group (&optional exclude-group)
6695 "Find the name of the best unread group.
6696 If EXCLUDE-GROUP, do not go to this group."
6697 (with-current-buffer gnus-group-buffer
6698 (save-excursion
6699 (gnus-group-best-unread-group exclude-group))))
6700
6701 (defun gnus-summary-find-next (&optional unread article backward)
6702 (if backward
6703 (gnus-summary-find-prev unread article)
6704 (let* ((dummy (gnus-summary-article-intangible-p))
6705 (article (or article (gnus-summary-article-number)))
6706 (data (gnus-data-find-list article))
6707 result)
6708 (when (and (not dummy)
6709 (or (not gnus-summary-check-current)
6710 (not unread)
6711 (not (gnus-data-unread-p (car data)))))
6712 (setq data (cdr data)))
6713 (when (setq result
6714 (if unread
6715 (progn
6716 (while data
6717 (unless (memq (gnus-data-number (car data))
6718 (cond
6719 ((eq gnus-auto-goto-ignores
6720 'always-undownloaded)
6721 gnus-newsgroup-undownloaded)
6722 (gnus-plugged
6723 nil)
6724 ((eq gnus-auto-goto-ignores
6725 'unfetched)
6726 gnus-newsgroup-unfetched)
6727 ((eq gnus-auto-goto-ignores
6728 'undownloaded)
6729 gnus-newsgroup-undownloaded)))
6730 (when (gnus-data-unread-p (car data))
6731 (setq result (car data)
6732 data nil)))
6733 (setq data (cdr data)))
6734 result)
6735 (car data)))
6736 (goto-char (gnus-data-pos result))
6737 (gnus-data-number result)))))
6738
6739 (defun gnus-summary-find-prev (&optional unread article)
6740 (let* ((eobp (eobp))
6741 (article (or article (gnus-summary-article-number)))
6742 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6743 result)
6744 (when (and (not eobp)
6745 (or (not gnus-summary-check-current)
6746 (not unread)
6747 (not (gnus-data-unread-p (car data)))))
6748 (setq data (cdr data)))
6749 (when (setq result
6750 (if unread
6751 (progn
6752 (while data
6753 (unless (memq (gnus-data-number (car data))
6754 (cond
6755 ((eq gnus-auto-goto-ignores
6756 'always-undownloaded)
6757 gnus-newsgroup-undownloaded)
6758 (gnus-plugged
6759 nil)
6760 ((eq gnus-auto-goto-ignores
6761 'unfetched)
6762 gnus-newsgroup-unfetched)
6763 ((eq gnus-auto-goto-ignores
6764 'undownloaded)
6765 gnus-newsgroup-undownloaded)))
6766 (when (gnus-data-unread-p (car data))
6767 (setq result (car data)
6768 data nil)))
6769 (setq data (cdr data)))
6770 result)
6771 (car data)))
6772 (goto-char (gnus-data-pos result))
6773 (gnus-data-number result))))
6774
6775 (defun gnus-summary-find-subject (subject &optional unread backward article)
6776 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6777 (article (or article (gnus-summary-article-number)))
6778 (articles (gnus-data-list backward))
6779 (arts (gnus-data-find-list article articles))
6780 result)
6781 (when (or (not gnus-summary-check-current)
6782 (not unread)
6783 (not (gnus-data-unread-p (car arts))))
6784 (setq arts (cdr arts)))
6785 (while arts
6786 (and (or (not unread)
6787 (gnus-data-unread-p (car arts)))
6788 (vectorp (gnus-data-header (car arts)))
6789 (gnus-subject-equal
6790 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6791 (setq result (car arts)
6792 arts nil))
6793 (setq arts (cdr arts)))
6794 (and result
6795 (goto-char (gnus-data-pos result))
6796 (gnus-data-number result))))
6797
6798 (defun gnus-summary-search-forward (&optional unread subject backward)
6799 "Search forward for an article.
6800 If UNREAD, look for unread articles. If SUBJECT, look for
6801 articles with that subject. If BACKWARD, search backward instead."
6802 (cond (subject (gnus-summary-find-subject subject unread backward))
6803 (backward (gnus-summary-find-prev unread))
6804 (t (gnus-summary-find-next unread))))
6805
6806 (defun gnus-recenter (&optional n)
6807 "Center point in window and redisplay frame.
6808 Also do horizontal recentering."
6809 (interactive "P")
6810 (when (and gnus-auto-center-summary
6811 (not (eq gnus-auto-center-summary 'vertical)))
6812 (gnus-horizontal-recenter))
6813 (if (fboundp 'recenter-top-bottom)
6814 (recenter-top-bottom n)
6815 (recenter n)))
6816
6817 (put 'gnus-recenter 'isearch-scroll t)
6818
6819 (defun gnus-forward-line-ignore-invisible (n)
6820 "Move N lines forward (backward if N is negative).
6821 Like forward-line, but skip over (and don't count) invisible lines."
6822 (let (done)
6823 (while (and (> n 0) (not done))
6824 ;; If the following character is currently invisible,
6825 ;; skip all characters with that same `invisible' property value.
6826 (while (gnus-invisible-p (point))
6827 (goto-char (gnus-next-char-property-change (point))))
6828 (forward-line 1)
6829 (if (eobp)
6830 (setq done t)
6831 (setq n (1- n))))
6832 (while (and (< n 0) (not done))
6833 (forward-line -1)
6834 (if (bobp) (setq done t)
6835 (setq n (1+ n))
6836 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6837 (goto-char (gnus-previous-char-property-change (point))))))))
6838
6839 (defun gnus-summary-recenter ()
6840 "Center point in the summary window.
6841 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6842 displayed, no centering will be performed."
6843 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6844 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6845 (interactive)
6846 ;; The user has to want it.
6847 (when gnus-auto-center-summary
6848 (let* ((top (cond ((< (window-height) 4) 0)
6849 ((< (window-height) 7) 1)
6850 (t (if (numberp gnus-auto-center-summary)
6851 gnus-auto-center-summary
6852 (/ (1- (window-height)) 2)))))
6853 (height (1- (window-height)))
6854 (bottom (save-excursion
6855 (goto-char (point-max))
6856 (gnus-forward-line-ignore-invisible (- height))
6857 (point)))
6858 (window (get-buffer-window (current-buffer))))
6859 (when (get-buffer-window gnus-article-buffer)
6860 ;; Only do recentering when the article buffer is displayed,
6861 ;; Set the window start to either `bottom', which is the biggest
6862 ;; possible valid number, or the second line from the top,
6863 ;; whichever is the least.
6864 (let ((top-pos (save-excursion
6865 (gnus-forward-line-ignore-invisible (- top))
6866 (point))))
6867 (if (> bottom top-pos)
6868 ;; Keep the second line from the top visible
6869 (set-window-start window top-pos)
6870 ;; Try to keep the bottom line visible; if it's partially
6871 ;; obscured, either scroll one more line to make it fully
6872 ;; visible, or revert to using TOP-POS.
6873 (save-excursion
6874 (goto-char (point-max))
6875 (gnus-forward-line-ignore-invisible -1)
6876 (let ((last-line-start (point)))
6877 (goto-char bottom)
6878 (set-window-start window (point) t)
6879 (when (not (pos-visible-in-window-p last-line-start window))
6880 (gnus-forward-line-ignore-invisible 1)
6881 (set-window-start window (min (point) top-pos) t)))))))
6882 ;; Do horizontal recentering while we're at it.
6883 (when (and (get-buffer-window (current-buffer) t)
6884 (not (eq gnus-auto-center-summary 'vertical)))
6885 (let ((selected (selected-window)))
6886 (select-window (get-buffer-window (current-buffer) t))
6887 (gnus-summary-position-point)
6888 (gnus-horizontal-recenter)
6889 (select-window selected))))))
6890
6891 (defun gnus-summary-jump-to-group (newsgroup)
6892 "Move point to NEWSGROUP in group mode buffer."
6893 ;; Keep update point of group mode buffer if visible.
6894 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6895 (save-window-excursion
6896 ;; Take care of tree window mode.
6897 (when (get-buffer-window gnus-group-buffer)
6898 (pop-to-buffer gnus-group-buffer))
6899 (gnus-group-jump-to-group newsgroup))
6900 (save-excursion
6901 ;; Take care of tree window mode.
6902 (if (get-buffer-window gnus-group-buffer 0)
6903 (pop-to-buffer gnus-group-buffer)
6904 (set-buffer gnus-group-buffer))
6905 (gnus-group-jump-to-group newsgroup))))
6906
6907 ;; This function returns a list of article numbers based on the
6908 ;; difference between the ranges of read articles in this group and
6909 ;; the range of active articles.
6910 (defun gnus-list-of-unread-articles (group)
6911 (let* ((read (gnus-info-read (gnus-get-info group)))
6912 (active (or (gnus-active group) (gnus-activate-group group)))
6913 (last (or (cdr active)
6914 (error "Group %s couldn't be activated " group)))
6915 (bottom (if gnus-newsgroup-maximum-articles
6916 (max (car active)
6917 (- last gnus-newsgroup-maximum-articles -1))
6918 (car active)))
6919 first nlast unread)
6920 ;; If none are read, then all are unread.
6921 (if (not read)
6922 (setq first bottom)
6923 ;; If the range of read articles is a single range, then the
6924 ;; first unread article is the article after the last read
6925 ;; article. Sounds logical, doesn't it?
6926 (if (and (not (listp (cdr read)))
6927 (or (< (car read) bottom)
6928 (progn (setq read (list read))
6929 nil)))
6930 (setq first (max bottom (1+ (cdr read))))
6931 ;; `read' is a list of ranges.
6932 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6933 (caar read)))
6934 1)
6935 (setq first bottom))
6936 (while read
6937 (when first
6938 (while (< first nlast)
6939 (setq unread (cons first unread)
6940 first (1+ first))))
6941 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6942 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6943 (setq read (cdr read)))))
6944 ;; And add the last unread articles.
6945 (while (<= first last)
6946 (setq unread (cons first unread)
6947 first (1+ first)))
6948 ;; Return the list of unread articles.
6949 (delq 0 (nreverse unread))))
6950
6951 (defun gnus-list-of-read-articles (group)
6952 "Return a list of unread, unticked and non-dormant articles."
6953 (let* ((info (gnus-get-info group))
6954 (marked (gnus-info-marks info))
6955 (active (gnus-active group)))
6956 (and info active
6957 (gnus-list-range-difference
6958 (gnus-list-range-difference
6959 (gnus-sorted-complement
6960 (gnus-uncompress-range
6961 (if gnus-newsgroup-maximum-articles
6962 (cons (max (car active)
6963 (- (cdr active)
6964 gnus-newsgroup-maximum-articles
6965 -1))
6966 (cdr active))
6967 active))
6968 (gnus-list-of-unread-articles group))
6969 (cdr (assq 'dormant marked)))
6970 (cdr (assq 'tick marked))))))
6971
6972 ;; This function returns a sequence of article numbers based on the
6973 ;; difference between the ranges of read articles in this group and
6974 ;; the range of active articles.
6975 (defun gnus-sequence-of-unread-articles (group)
6976 (let* ((read (gnus-info-read (gnus-get-info group)))
6977 (active (or (gnus-active group) (gnus-activate-group group)))
6978 (last (cdr active))
6979 (bottom (if gnus-newsgroup-maximum-articles
6980 (max (car active)
6981 (- last gnus-newsgroup-maximum-articles -1))
6982 (car active)))
6983 first nlast unread)
6984 ;; If none are read, then all are unread.
6985 (if (not read)
6986 (setq first bottom)
6987 ;; If the range of read articles is a single range, then the
6988 ;; first unread article is the article after the last read
6989 ;; article. Sounds logical, doesn't it?
6990 (if (and (not (listp (cdr read)))
6991 (or (< (car read) bottom)
6992 (progn (setq read (list read))
6993 nil)))
6994 (setq first (max bottom (1+ (cdr read))))
6995 ;; `read' is a list of ranges.
6996 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6997 (caar read)))
6998 1)
6999 (setq first bottom))
7000 (while read
7001 (when first
7002 (push (cons first nlast) unread))
7003 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7004 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7005 (setq read (cdr read)))))
7006 ;; And add the last unread articles.
7007 (cond ((not (and first last))
7008 nil)
7009 ((< first last)
7010 (push (cons first last) unread))
7011 ((= first last)
7012 (push first unread)))
7013 ;; Return the sequence of unread articles.
7014 (delq 0 (nreverse unread))))
7015
7016 ;; Various summary commands
7017
7018 (defun gnus-summary-select-article-buffer ()
7019 "Reconfigure windows to show the article buffer.
7020 If `gnus-widen-article-window' is set, show only the article
7021 buffer."
7022 (interactive)
7023 (if (not (gnus-buffer-live-p gnus-article-buffer))
7024 (error "There is no article buffer for this summary buffer")
7025 (unless (get-buffer-window gnus-article-buffer)
7026 (gnus-summary-show-article))
7027 (gnus-configure-windows
7028 (if gnus-widen-article-window
7029 'only-article
7030 'article)
7031 t)
7032 (select-window (get-buffer-window gnus-article-buffer))))
7033
7034 (defun gnus-summary-universal-argument (arg)
7035 "Perform any operation on all articles that are process/prefixed."
7036 (interactive "P")
7037 (let ((articles (gnus-summary-work-articles arg))
7038 func article)
7039 (if (eq
7040 (setq
7041 func
7042 (key-binding
7043 (read-key-sequence
7044 (substitute-command-keys
7045 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7046 'undefined)
7047 (gnus-error 1 "Undefined key")
7048 (save-excursion
7049 (while articles
7050 (gnus-summary-goto-subject (setq article (pop articles)))
7051 (let (gnus-newsgroup-processable)
7052 (command-execute func))
7053 (gnus-summary-remove-process-mark article)))))
7054 (gnus-summary-position-point))
7055
7056 (defun gnus-summary-toggle-truncation (&optional arg)
7057 "Toggle truncation of summary lines.
7058 With ARG, turn line truncation on if ARG is positive."
7059 (interactive "P")
7060 (setq truncate-lines
7061 (if (null arg) (not truncate-lines)
7062 (> (prefix-numeric-value arg) 0)))
7063 (redraw-display))
7064
7065 (defun gnus-summary-find-for-reselect ()
7066 "Return the number of an article to stay on across a reselect.
7067 The current article is considered, then following articles, then previous
7068 articles. An article is sought which is not canceled and isn't a temporary
7069 insertion from another group. If there's no such then return a dummy 0."
7070 (let (found)
7071 (dolist (rev '(nil t))
7072 (unless found ; don't demand the reverse list if we don't need it
7073 (let ((data (gnus-data-find-list
7074 (gnus-summary-article-number) (gnus-data-list rev))))
7075 (while (and data (not found))
7076 (if (and (< 0 (gnus-data-number (car data)))
7077 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7078 (setq found (gnus-data-number (car data))))
7079 (setq data (cdr data))))))
7080 (or found 0)))
7081
7082 (defun gnus-summary-reselect-current-group (&optional all rescan)
7083 "Exit and then reselect the current newsgroup.
7084 The prefix argument ALL means to select all articles."
7085 (interactive "P")
7086 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7087 (error "Ephemeral groups can't be reselected"))
7088 (let ((current-subject (gnus-summary-find-for-reselect))
7089 (group gnus-newsgroup-name))
7090 (setq gnus-newsgroup-begin nil)
7091 (gnus-summary-exit nil 'leave-hidden)
7092 ;; We have to adjust the point of group mode buffer because
7093 ;; point was moved to the next unread newsgroup by exiting.
7094 (gnus-summary-jump-to-group group)
7095 (when rescan
7096 (save-excursion
7097 (gnus-group-get-new-news-this-group 1)))
7098 (gnus-group-read-group all t)
7099 (gnus-summary-goto-subject current-subject nil t)))
7100
7101 (defun gnus-summary-rescan-group (&optional all)
7102 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7103 (interactive "P")
7104 (let ((config gnus-current-window-configuration))
7105 (gnus-summary-reselect-current-group all t)
7106 (gnus-configure-windows config)
7107 (when (eq config 'article)
7108 (gnus-summary-select-article))))
7109
7110 (defun gnus-summary-update-info (&optional non-destructive)
7111 (save-excursion
7112 (let ((group gnus-newsgroup-name))
7113 (when group
7114 (when gnus-newsgroup-kill-headers
7115 (setq gnus-newsgroup-killed
7116 (gnus-compress-sequence
7117 (gnus-sorted-union
7118 (gnus-list-range-intersection
7119 gnus-newsgroup-unselected gnus-newsgroup-killed)
7120 gnus-newsgroup-unreads)
7121 t)))
7122 (unless (listp (cdr gnus-newsgroup-killed))
7123 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7124 (let ((headers gnus-newsgroup-headers)
7125 (ephemeral-p (gnus-ephemeral-group-p group))
7126 info)
7127 (unless ephemeral-p
7128 (setq info (copy-sequence (gnus-get-info group))
7129 info (delq (gnus-info-params info) info)))
7130 ;; Set the new ranges of read articles.
7131 (with-current-buffer gnus-group-buffer
7132 (gnus-undo-force-boundary))
7133 (gnus-update-read-articles
7134 group (gnus-sorted-union
7135 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7136 ;; Set the current article marks.
7137 (let ((gnus-newsgroup-scored
7138 (if (and (not gnus-save-score)
7139 (not non-destructive))
7140 nil
7141 gnus-newsgroup-scored)))
7142 (save-excursion
7143 (gnus-update-marks)))
7144 ;; Do the cross-ref thing.
7145 (when gnus-use-cross-reference
7146 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7147 ;; Do not switch windows but change the buffer to work.
7148 (set-buffer gnus-group-buffer)
7149 (unless ephemeral-p
7150 (gnus-group-update-group
7151 group nil
7152 (equal info
7153 (setq info (copy-sequence (gnus-get-info group))
7154 info (delq (gnus-info-params info) info))))))))))
7155
7156 (defun gnus-summary-save-newsrc (&optional force)
7157 "Save the current number of read/marked articles in the dribble buffer.
7158 The dribble buffer will then be saved.
7159 If FORCE (the prefix), also save the .newsrc file(s)."
7160 (interactive "P")
7161 (gnus-summary-update-info t)
7162 (if force
7163 (gnus-save-newsrc-file)
7164 (gnus-dribble-save)))
7165
7166 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7167
7168 (defun gnus-summary-exit (&optional temporary leave-hidden)
7169 "Exit reading current newsgroup, and then return to group selection mode.
7170 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7171 (interactive)
7172 (gnus-set-global-variables)
7173 (when (gnus-buffer-live-p gnus-article-buffer)
7174 (with-current-buffer gnus-article-buffer
7175 (mm-destroy-parts gnus-article-mime-handles)
7176 ;; Set it to nil for safety reason.
7177 (setq gnus-article-mime-handle-alist nil)
7178 (setq gnus-article-mime-handles nil)))
7179 (gnus-kill-save-kill-buffer)
7180 (gnus-async-halt-prefetch)
7181 (let* ((group gnus-newsgroup-name)
7182 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7183 (gnus-group-is-exiting-p t)
7184 (article-buffer gnus-article-buffer)
7185 (original-article-buffer gnus-original-article-buffer)
7186 (mode major-mode)
7187 (group-point nil)
7188 (buf (current-buffer))
7189 ;; `gnus-single-article-buffer' is nil buffer-locally in
7190 ;; ephemeral group of which summary buffer will be killed,
7191 ;; but the global value may be non-nil.
7192 (single-article-buffer gnus-single-article-buffer))
7193 (unless quit-config
7194 ;; Do adaptive scoring, and possibly save score files.
7195 (when gnus-newsgroup-adaptive
7196 (gnus-score-adaptive))
7197 (when gnus-use-scoring
7198 (gnus-score-save)))
7199 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7200 (when gnus-use-cache
7201 (gnus-cache-possibly-remove-articles)
7202 (gnus-cache-save-buffers))
7203 (gnus-async-prefetch-remove-group group)
7204 (when gnus-suppress-duplicates
7205 (gnus-dup-enter-articles))
7206 (when gnus-use-trees
7207 (gnus-tree-close group))
7208 (when gnus-use-cache
7209 (gnus-cache-write-active))
7210 ;; Remove entries for this group.
7211 (nnmail-purge-split-history (gnus-group-real-name group))
7212 ;; Make all changes in this group permanent.
7213 (unless quit-config
7214 (gnus-run-hooks 'gnus-exit-group-hook)
7215 (gnus-summary-update-info))
7216 (gnus-close-group group)
7217 ;; Make sure where we were, and go to next newsgroup.
7218 (when (buffer-live-p (get-buffer gnus-group-buffer))
7219 (set-buffer gnus-group-buffer))
7220 (unless quit-config
7221 (gnus-group-jump-to-group group))
7222 (gnus-run-hooks 'gnus-summary-exit-hook)
7223 (unless (or quit-config
7224 (not gnus-summary-next-group-on-exit)
7225 ;; If this group has disappeared from the summary
7226 ;; buffer, don't skip forwards.
7227 (not (string= group (gnus-group-group-name))))
7228 (gnus-group-next-unread-group 1))
7229 (setq group-point (point))
7230 (if temporary
7231 nil ;Nothing to do.
7232 (set-buffer buf)
7233 (if (not gnus-kill-summary-on-exit)
7234 (progn
7235 (gnus-deaden-summary)
7236 (setq mode nil))
7237 (when (get-buffer gnus-article-buffer)
7238 (bury-buffer gnus-article-buffer))
7239 ;; Return to group mode buffer.
7240 (when (eq mode 'gnus-summary-mode)
7241 (gnus-kill-buffer buf)))
7242
7243 (setq gnus-current-select-method gnus-select-method)
7244 (when (gnus-buffer-live-p gnus-group-buffer)
7245 (set-buffer gnus-group-buffer))
7246 (if quit-config
7247 (gnus-handle-ephemeral-exit quit-config)
7248 (goto-char group-point)
7249 ;; If gnus-group-buffer is already displayed, make sure we also move
7250 ;; the cursor in the window that displays it.
7251 (let ((win (get-buffer-window (current-buffer) 0)))
7252 (if win (set-window-point win (point))))
7253 (unless leave-hidden
7254 (gnus-configure-windows 'group 'force)))
7255
7256 ;; If we have several article buffers, we kill them at exit.
7257 (unless single-article-buffer
7258 (when (gnus-buffer-live-p article-buffer)
7259 (with-current-buffer article-buffer
7260 ;; Don't kill sticky article buffers
7261 (unless (eq major-mode 'gnus-sticky-article-mode)
7262 (gnus-kill-buffer article-buffer)
7263 (setq gnus-article-current nil))))
7264 (gnus-kill-buffer original-article-buffer))
7265
7266 ;; Clear the current group name.
7267 (unless quit-config
7268 (setq gnus-newsgroup-name nil)))))
7269
7270 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7271 (defun gnus-summary-exit-no-update (&optional no-questions)
7272 "Quit reading current newsgroup without updating read article info."
7273 (interactive)
7274 (let* ((group gnus-newsgroup-name)
7275 (gnus-group-is-exiting-p t)
7276 (gnus-group-is-exiting-without-update-p t)
7277 (quit-config (gnus-group-quit-config group)))
7278 (when (or no-questions
7279 gnus-expert-user
7280 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7281 (gnus-async-halt-prefetch)
7282 (run-hooks 'gnus-summary-prepare-exit-hook)
7283 (when (gnus-buffer-live-p gnus-article-buffer)
7284 (with-current-buffer gnus-article-buffer
7285 (gnus-article-stop-animations)
7286 (gnus-stop-downloads)
7287 (mm-destroy-parts gnus-article-mime-handles)
7288 ;; Set it to nil for safety reason.
7289 (setq gnus-article-mime-handle-alist nil)
7290 (setq gnus-article-mime-handles nil)))
7291 ;; If we have several article buffers, we kill them at exit.
7292 (unless gnus-single-article-buffer
7293 (gnus-kill-buffer gnus-article-buffer)
7294 (gnus-kill-buffer gnus-original-article-buffer)
7295 (setq gnus-article-current nil))
7296 ;; Return to the group buffer.
7297 (if (not gnus-kill-summary-on-exit)
7298 (progn
7299 (gnus-deaden-summary)
7300 (gnus-configure-windows 'group 'force))
7301 (gnus-configure-windows 'group 'force)
7302 (gnus-close-group group)
7303 (gnus-kill-buffer gnus-summary-buffer))
7304 (unless gnus-single-article-buffer
7305 (setq gnus-article-current nil))
7306 (when gnus-use-trees
7307 (gnus-tree-close group))
7308 (gnus-async-prefetch-remove-group group)
7309 (when (get-buffer gnus-article-buffer)
7310 (bury-buffer gnus-article-buffer))
7311 ;; Clear the current group name.
7312 (setq gnus-newsgroup-name nil)
7313 (unless (gnus-ephemeral-group-p group)
7314 (gnus-group-update-group group nil t))
7315 (when (equal (gnus-group-group-name) group)
7316 (gnus-group-next-unread-group 1))
7317 (when quit-config
7318 (gnus-handle-ephemeral-exit quit-config)))))
7319
7320 (defun gnus-handle-ephemeral-exit (quit-config)
7321 "Handle movement when leaving an ephemeral group.
7322 The state which existed when entering the ephemeral is reset."
7323 (if (not (buffer-live-p (car quit-config)))
7324 (when (gnus-buffer-live-p gnus-group-buffer)
7325 (gnus-configure-windows 'group 'force))
7326 (set-buffer (car quit-config))
7327 (unless (eq (cdr quit-config) 'group)
7328 (setq gnus-current-select-method
7329 (gnus-find-method-for-group gnus-newsgroup-name)))
7330 (cond ((eq major-mode 'gnus-summary-mode)
7331 (gnus-set-global-variables))
7332 ((eq major-mode 'gnus-article-mode)
7333 (save-current-buffer
7334 ;; The `gnus-summary-buffer' variable may point
7335 ;; to the old summary buffer when using a single
7336 ;; article buffer.
7337 (unless (gnus-buffer-live-p gnus-summary-buffer)
7338 (set-buffer gnus-group-buffer))
7339 (set-buffer gnus-summary-buffer)
7340 (gnus-set-global-variables))))
7341 (if (or (eq (cdr quit-config) 'article)
7342 (eq (cdr quit-config) 'pick))
7343 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7344 (gnus-configure-windows 'pick 'force)
7345 (gnus-configure-windows (cdr quit-config) 'force))
7346 (gnus-configure-windows (cdr quit-config) 'force))
7347 (when (eq major-mode 'gnus-summary-mode)
7348 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7349 next-unread-noselect))
7350 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7351 'next-noselect)
7352 (gnus-summary-next-subject 1 nil t))
7353 ((eq gnus-auto-select-on-ephemeral-exit
7354 'next-unread-noselect)
7355 (gnus-summary-next-subject 1 t t))))
7356 ;; Hide the article buffer which displays the article different
7357 ;; from the one that the cursor points to in the summary buffer.
7358 (gnus-configure-windows 'summary 'force))
7359 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7360 (gnus-summary-next-subject 1))
7361 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7362 (gnus-summary-next-subject 1 t))))
7363 (gnus-summary-recenter)
7364 (gnus-summary-position-point))))
7365
7366 ;;; Dead summaries.
7367
7368 (defvar gnus-dead-summary-mode-map
7369 (let ((map (make-keymap)))
7370 (suppress-keymap map)
7371 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7372 (dolist (key '("\C-d" "\r" "\177" [delete]))
7373 (define-key map key 'gnus-summary-wake-up-the-dead))
7374 (dolist (key '("q" "Q"))
7375 (define-key map key 'bury-buffer))
7376 map))
7377
7378 (define-minor-mode gnus-dead-summary-mode
7379 "Minor mode for Gnus summary buffers."
7380 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7381 (unless (derived-mode-p 'gnus-summary-mode)
7382 (setq gnus-dead-summary-mode nil)))
7383
7384 (defun gnus-deaden-summary ()
7385 "Make the current summary buffer into a dead summary buffer."
7386 ;; Kill any previous dead summary buffer.
7387 (when (and gnus-dead-summary
7388 (buffer-name gnus-dead-summary))
7389 (with-current-buffer gnus-dead-summary
7390 (when gnus-dead-summary-mode
7391 (kill-buffer (current-buffer)))))
7392 ;; Make this the current dead summary.
7393 (setq gnus-dead-summary (current-buffer))
7394 (gnus-dead-summary-mode 1)
7395 (let ((name (buffer-name)))
7396 (when (string-match "Summary" name)
7397 (rename-buffer
7398 (concat (substring name 0 (match-beginning 0)) "Dead "
7399 (substring name (match-beginning 0)))
7400 t)
7401 (bury-buffer))))
7402
7403 (defun gnus-kill-or-deaden-summary (buffer)
7404 "Kill or deaden the summary BUFFER."
7405 (save-excursion
7406 (when (and (buffer-name buffer)
7407 (not gnus-single-article-buffer))
7408 (with-current-buffer buffer
7409 (gnus-kill-buffer gnus-article-buffer)
7410 (gnus-kill-buffer gnus-original-article-buffer)))
7411 (cond
7412 ;; Kill the buffer.
7413 (gnus-kill-summary-on-exit
7414 (when (and gnus-use-trees
7415 (gnus-buffer-exists-p buffer))
7416 (with-current-buffer buffer
7417 (gnus-tree-close gnus-newsgroup-name)))
7418 (gnus-kill-buffer buffer))
7419 ;; Deaden the buffer.
7420 ((gnus-buffer-exists-p buffer)
7421 (with-current-buffer buffer
7422 (gnus-deaden-summary))))))
7423
7424 (defun gnus-summary-wake-up-the-dead (&rest args)
7425 "Wake up the dead summary buffer."
7426 (interactive)
7427 (gnus-dead-summary-mode -1)
7428 (let ((name (buffer-name)))
7429 (when (string-match "Dead " name)
7430 (rename-buffer
7431 (concat (substring name 0 (match-beginning 0))
7432 (substring name (match-end 0)))
7433 t)))
7434 (gnus-message 3 "This dead summary is now alive again"))
7435
7436 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7437 (defun gnus-summary-describe-group (&optional force)
7438 "Describe the current newsgroup."
7439 (interactive "P")
7440 (gnus-group-describe-group force gnus-newsgroup-name))
7441
7442 (defun gnus-summary-describe-briefly ()
7443 "Describe summary mode commands briefly."
7444 (interactive)
7445 (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")))
7446
7447 ;; Walking around group mode buffer from summary mode.
7448
7449 (defun gnus-summary-next-group (&optional no-article target-group backward)
7450 "Exit current newsgroup and then select next unread newsgroup.
7451 If prefix argument NO-ARTICLE is non-nil, no article is selected
7452 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7453 previous group instead."
7454 (interactive "P")
7455 ;; Stop pre-fetching.
7456 (gnus-async-halt-prefetch)
7457 (let ((current-group gnus-newsgroup-name)
7458 (current-buffer (current-buffer))
7459 entered)
7460 ;; First we semi-exit this group to update Xrefs and all variables.
7461 ;; We can't do a real exit, because the window conf must remain
7462 ;; the same in case the user is prompted for info, and we don't
7463 ;; want the window conf to change before that...
7464 (gnus-summary-exit t)
7465 (while (not entered)
7466 ;; Then we find what group we are supposed to enter.
7467 (set-buffer gnus-group-buffer)
7468 (gnus-group-jump-to-group current-group)
7469 (setq target-group
7470 (or target-group
7471 (if (eq gnus-keep-same-level 'best)
7472 (gnus-summary-best-group gnus-newsgroup-name)
7473 (gnus-summary-search-group backward gnus-keep-same-level))))
7474 (if (not target-group)
7475 ;; There are no further groups, so we return to the group
7476 ;; buffer.
7477 (progn
7478 (gnus-message 5 "Returning to the group buffer")
7479 (setq entered t)
7480 (when (gnus-buffer-live-p current-buffer)
7481 (set-buffer current-buffer)
7482 (gnus-summary-exit))
7483 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7484 ;; We try to enter the target group.
7485 (gnus-group-jump-to-group target-group)
7486 (let ((unreads (gnus-group-group-unread)))
7487 (if (and (or (eq t unreads)
7488 (and unreads (not (zerop unreads))))
7489 (gnus-summary-read-group
7490 target-group nil no-article
7491 (and (buffer-name current-buffer) current-buffer)
7492 nil backward))
7493 (setq entered t)
7494 (setq current-group target-group
7495 target-group nil)))))))
7496
7497 (defun gnus-summary-prev-group (&optional no-article)
7498 "Exit current newsgroup and then select previous unread newsgroup.
7499 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7500 (interactive "P")
7501 (gnus-summary-next-group no-article nil t))
7502
7503 ;; Walking around summary lines.
7504
7505 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7506 "Go to the first subject satisfying any non-nil constraint.
7507 If UNREAD is non-nil, the article should be unread.
7508 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7509 If UNSEEN is non-nil, the article should be unseen as well as unread.
7510 Returns the article selected or nil if there are no matching articles."
7511 (interactive "P")
7512 (cond
7513 ;; Empty summary.
7514 ((null gnus-newsgroup-data)
7515 (gnus-message 3 "No articles in the group")
7516 nil)
7517 ;; Pick the first article.
7518 ((not (or unread undownloaded unseen))
7519 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7520 (gnus-data-number (car gnus-newsgroup-data)))
7521 ;; Find the first unread article.
7522 (t
7523 (let ((data gnus-newsgroup-data))
7524 (while (and data
7525 (let ((num (gnus-data-number (car data))))
7526 (or (memq num gnus-newsgroup-unfetched)
7527 (not (or (and unread
7528 (memq num gnus-newsgroup-unreads))
7529 (and undownloaded
7530 (memq num gnus-newsgroup-undownloaded))
7531 (and unseen
7532 (memq num gnus-newsgroup-unseen)
7533 (memq num gnus-newsgroup-unreads)))))))
7534 (setq data (cdr data)))
7535 (prog1
7536 (if data
7537 (progn
7538 (goto-char (gnus-data-pos (car data)))
7539 (gnus-data-number (car data)))
7540 (gnus-message 3 "No more%s articles"
7541 (let* ((r (when unread " unread"))
7542 (d (when undownloaded " undownloaded"))
7543 (s (when unseen " unseen"))
7544 (l (delq nil (list r d s))))
7545 (cond ((= 3 (length l))
7546 (concat r "," d ", or" s))
7547 ((= 2 (length l))
7548 (concat (car l) ", or" (cadr l)))
7549 ((= 1 (length l))
7550 (car l))
7551 (t
7552 ""))))
7553 nil
7554 )
7555 (gnus-summary-position-point))))))
7556
7557 (defun gnus-summary-next-subject (n &optional unread dont-display)
7558 "Go to next N'th summary line.
7559 If N is negative, go to the previous N'th subject line.
7560 If UNREAD is non-nil, only unread articles are selected.
7561 The difference between N and the actual number of steps taken is
7562 returned."
7563 (interactive "p")
7564 (let ((backward (< n 0))
7565 (n (abs n)))
7566 (while (and (> n 0)
7567 (if backward
7568 (gnus-summary-find-prev unread)
7569 (gnus-summary-find-next unread)))
7570 (unless (zerop (setq n (1- n)))
7571 (gnus-summary-show-thread)))
7572 (when (/= 0 n)
7573 (gnus-message 7 "No more%s articles"
7574 (if unread " unread" "")))
7575 (unless dont-display
7576 (gnus-summary-recenter)
7577 (gnus-summary-position-point))
7578 n))
7579
7580 (defun gnus-summary-next-unread-subject (n)
7581 "Go to next N'th unread summary line."
7582 (interactive "p")
7583 (gnus-summary-next-subject n t))
7584
7585 (defun gnus-summary-prev-subject (n &optional unread)
7586 "Go to previous N'th summary line.
7587 If optional argument UNREAD is non-nil, only unread article is selected."
7588 (interactive "p")
7589 (gnus-summary-next-subject (- n) unread))
7590
7591 (defun gnus-summary-prev-unread-subject (n)
7592 "Go to previous N'th unread summary line."
7593 (interactive "p")
7594 (gnus-summary-next-subject (- n) t))
7595
7596 (defun gnus-summary-goto-subjects (articles)
7597 "Insert the subject header for ARTICLES in the current buffer."
7598 (save-excursion
7599 (dolist (article articles)
7600 (gnus-summary-goto-subject article t)))
7601 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7602 (gnus-summary-position-point))
7603
7604 (defun gnus-summary-goto-subject (article &optional force silent)
7605 "Go to the subject line of ARTICLE.
7606 If FORCE, also allow jumping to articles not currently shown."
7607 (interactive "nArticle number: ")
7608 (unless (numberp article)
7609 (error "Article %s is not a number" article))
7610 (let ((b (point))
7611 (data (gnus-data-find article)))
7612 ;; We read in the article if we have to.
7613 (and (not data)
7614 force
7615 (gnus-summary-insert-subject
7616 article
7617 (if (or (numberp force) (vectorp force)) force)
7618 t)
7619 (setq data (gnus-data-find article)))
7620 (goto-char b)
7621 (if (not data)
7622 (progn
7623 (unless silent
7624 (gnus-message 3 "Can't find article %d" article))
7625 nil)
7626 (let ((pt (gnus-data-pos data)))
7627 (goto-char pt)
7628 (gnus-summary-set-article-display-arrow pt))
7629 (gnus-summary-position-point)
7630 article)))
7631
7632 ;; Walking around summary lines with displaying articles.
7633
7634 (defun gnus-summary-expand-window (&optional arg)
7635 "Make the summary buffer take up the entire Emacs frame.
7636 Given a prefix, will force an `article' buffer configuration."
7637 (interactive "P")
7638 (if arg
7639 (gnus-configure-windows 'article 'force)
7640 (gnus-configure-windows 'summary 'force)))
7641
7642 (defun gnus-summary-display-article (article &optional all-header)
7643 "Display ARTICLE in article buffer."
7644 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7645 (with-current-buffer gnus-article-buffer
7646 (eq major-mode 'gnus-article-mode)))
7647 (gnus-article-setup-buffer))
7648 (gnus-set-global-variables)
7649 (with-current-buffer gnus-article-buffer
7650 (setq gnus-article-charset gnus-newsgroup-charset)
7651 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7652 (mm-enable-multibyte))
7653 (if (null article)
7654 nil
7655 (prog1
7656 (if gnus-summary-display-article-function
7657 (funcall gnus-summary-display-article-function article all-header)
7658 (gnus-article-prepare article all-header))
7659 (gnus-run-hooks 'gnus-select-article-hook)
7660 (when (and gnus-current-article
7661 (not (zerop gnus-current-article)))
7662 (gnus-summary-goto-subject gnus-current-article))
7663 (gnus-summary-recenter)
7664 (when (and gnus-use-trees gnus-show-threads)
7665 (gnus-possibly-generate-tree article)
7666 (gnus-highlight-selected-tree article))
7667 ;; Successfully display article.
7668 (gnus-article-set-window-start
7669 (cdr (assq article gnus-newsgroup-bookmarks))))))
7670
7671 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7672 "Select the current article.
7673 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7674 non-nil, the article will be re-fetched even if it already present in
7675 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7676 be displayed."
7677 ;; Make sure we are in the summary buffer to work around bbdb bug.
7678 (unless (eq major-mode 'gnus-summary-mode)
7679 (set-buffer gnus-summary-buffer))
7680 (let ((article (or article (gnus-summary-article-number)))
7681 (all-headers (not (not all-headers))) ;Must be t or nil.
7682 gnus-summary-display-article-function)
7683 (and (not pseudo)
7684 (gnus-summary-article-pseudo-p article)
7685 (error "This is a pseudo-article"))
7686 (with-current-buffer gnus-summary-buffer
7687 (if (or (and gnus-single-article-buffer
7688 (or (null gnus-current-article)
7689 (null gnus-article-current)
7690 (null (get-buffer gnus-article-buffer))
7691 (not (eq article (cdr gnus-article-current)))
7692 (not (equal (car gnus-article-current)
7693 gnus-newsgroup-name))
7694 (not (get-buffer gnus-original-article-buffer))))
7695 (and (not gnus-single-article-buffer)
7696 (or (null gnus-current-article)
7697 (not (get-buffer gnus-original-article-buffer))
7698 (not (eq gnus-current-article article))))
7699 force)
7700 ;; The requested article is different from the current article.
7701 (progn
7702 (gnus-summary-display-article article all-headers)
7703 (when (gnus-buffer-live-p gnus-article-buffer)
7704 (with-current-buffer gnus-article-buffer
7705 (if (not gnus-article-decoded-p) ;; a local variable
7706 (mm-disable-multibyte))))
7707 (gnus-article-set-window-start
7708 (cdr (assq article gnus-newsgroup-bookmarks)))
7709 article)
7710 'old))))
7711
7712 (defun gnus-summary-force-verify-and-decrypt ()
7713 "Display buttons for signed/encrypted parts and verify/decrypt them."
7714 (interactive)
7715 (let ((mm-verify-option 'known)
7716 (mm-decrypt-option 'known)
7717 (gnus-article-emulate-mime t)
7718 (gnus-buttonized-mime-types (append (list "multipart/signed"
7719 "multipart/encrypted")
7720 gnus-buttonized-mime-types)))
7721 (gnus-summary-select-article nil 'force)))
7722
7723 (defun gnus-summary-next-article (&optional unread subject backward push)
7724 "Select the next article.
7725 If UNREAD, only unread articles are selected.
7726 If SUBJECT, only articles with SUBJECT are selected.
7727 If BACKWARD, the previous article is selected instead of the next."
7728 (interactive "P")
7729 ;; Make sure we are in the summary buffer.
7730 (unless (eq major-mode 'gnus-summary-mode)
7731 (set-buffer gnus-summary-buffer))
7732 (cond
7733 ;; Is there such an article?
7734 ((and (gnus-summary-search-forward unread subject backward)
7735 (or (gnus-summary-display-article (gnus-summary-article-number))
7736 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7737 (gnus-summary-position-point))
7738 ;; If not, we try the first unread, if that is wanted.
7739 ((and subject
7740 gnus-auto-select-same
7741 (gnus-summary-first-unread-article))
7742 (gnus-summary-position-point)
7743 (gnus-message 6 "Wrapped"))
7744 ;; Try to get next/previous article not displayed in this group.
7745 ((and gnus-auto-extend-newsgroup
7746 (not unread) (not subject))
7747 (gnus-summary-goto-article
7748 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7749 nil (count-lines (point-min) (point))))
7750 ;; Go to next/previous group.
7751 (t
7752 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7753 (gnus-summary-jump-to-group gnus-newsgroup-name))
7754 (let ((cmd (if (featurep 'xemacs)
7755 last-command-char
7756 last-command-event))
7757 (point
7758 (with-current-buffer gnus-group-buffer
7759 (point)))
7760 (current-summary (current-buffer))
7761 (group
7762 (if (eq gnus-keep-same-level 'best)
7763 (gnus-summary-best-group gnus-newsgroup-name)
7764 (gnus-summary-search-group backward gnus-keep-same-level))))
7765 ;; Select next unread newsgroup automagically.
7766 (cond
7767 ((or (not gnus-auto-select-next)
7768 (not cmd))
7769 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7770 ((or (eq gnus-auto-select-next 'quietly)
7771 (and (eq gnus-auto-select-next 'slightly-quietly)
7772 push)
7773 (and (eq gnus-auto-select-next 'almost-quietly)
7774 (gnus-summary-last-article-p)))
7775 ;; Select quietly.
7776 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7777 (gnus-summary-exit)
7778 (gnus-message 7 "No more%s articles (%s)..."
7779 (if unread " unread" "")
7780 (if group (concat "selecting " group)
7781 "exiting"))
7782 (gnus-summary-next-group nil group backward)))
7783 (t
7784 (when (gnus-key-press-event-p last-input-event)
7785 ;; Somehow or other, we may now have selected a different
7786 ;; window. Make point go back to the summary buffer.
7787 (when (eq current-summary (current-buffer))
7788 ;; FIXME: This burps when get-buffer-window returns nil.
7789 (select-window (get-buffer-window current-summary 0)))
7790 (gnus-summary-walk-group-buffer
7791 gnus-newsgroup-name cmd unread backward point))))))))
7792
7793 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7794 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7795 (?\C-p (gnus-group-prev-unread-group 1))))
7796 (cursor-in-echo-area t)
7797 keve key group ended prompt)
7798 (with-current-buffer gnus-group-buffer
7799 (goto-char start)
7800 (setq group
7801 (if (eq gnus-keep-same-level 'best)
7802 (gnus-summary-best-group gnus-newsgroup-name)
7803 (gnus-summary-search-group backward gnus-keep-same-level))))
7804 (while (not ended)
7805 (setq prompt
7806 (format
7807 "No more%s articles%s " (if unread " unread" "")
7808 (if (and group
7809 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7810 (format " (Type %s for %s [%s])"
7811 (single-key-description cmd)
7812 (gnus-group-decoded-name group)
7813 (gnus-group-unread group))
7814 (format " (Type %s to exit %s)"
7815 (single-key-description cmd)
7816 (gnus-group-decoded-name gnus-newsgroup-name)))))
7817 ;; Confirm auto selection.
7818 (setq key (car (setq keve (gnus-read-event-char prompt)))
7819 ended t)
7820 (cond
7821 ((assq key keystrokes)
7822 (let ((obuf (current-buffer)))
7823 (switch-to-buffer gnus-group-buffer)
7824 (when group
7825 (gnus-group-jump-to-group group))
7826 (eval (cadr (assq key keystrokes)))
7827 (setq group (gnus-group-group-name))
7828 (switch-to-buffer obuf))
7829 (setq ended nil))
7830 ((equal key cmd)
7831 (if (or (not group)
7832 (gnus-ephemeral-group-p gnus-newsgroup-name))
7833 (gnus-summary-exit)
7834 (gnus-summary-next-group nil group backward)))
7835 (t
7836 (push (cdr keve) unread-command-events))))))
7837
7838 (defun gnus-summary-next-unread-article ()
7839 "Select unread article after current one."
7840 (interactive)
7841 (gnus-summary-next-article
7842 (or (not (eq gnus-summary-goto-unread 'never))
7843 (gnus-summary-last-article-p (gnus-summary-article-number)))
7844 (and gnus-auto-select-same
7845 (gnus-summary-article-subject))))
7846
7847 (defun gnus-summary-prev-article (&optional unread subject)
7848 "Select the article before the current one.
7849 If UNREAD is non-nil, only unread articles are selected."
7850 (interactive "P")
7851 (gnus-summary-next-article unread subject t))
7852
7853 (defun gnus-summary-prev-unread-article ()
7854 "Select unread article before current one."
7855 (interactive)
7856 (gnus-summary-prev-article
7857 (or (not (eq gnus-summary-goto-unread 'never))
7858 (gnus-summary-first-article-p (gnus-summary-article-number)))
7859 (and gnus-auto-select-same
7860 (gnus-summary-article-subject))))
7861
7862 (defun gnus-summary-next-page (&optional lines circular stop)
7863 "Show next page of the selected article.
7864 If at the end of the current article, select the next article.
7865 LINES says how many lines should be scrolled up.
7866
7867 If CIRCULAR is non-nil, go to the start of the article instead of
7868 selecting the next article when reaching the end of the current
7869 article.
7870
7871 If STOP is non-nil, just stop when reaching the end of the message.
7872
7873 Also see the variable `gnus-article-skip-boring'."
7874 (interactive "P")
7875 (gnus-set-global-variables)
7876 (let ((article (gnus-summary-article-number))
7877 (article-window (get-buffer-window gnus-article-buffer t))
7878 endp)
7879 ;; If the buffer is empty, we have no article.
7880 (unless article
7881 (error "No article to select"))
7882 (gnus-configure-windows 'article)
7883 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7884 (if (and (eq gnus-summary-goto-unread 'never)
7885 (not (gnus-summary-last-article-p article)))
7886 (gnus-summary-next-article)
7887 (gnus-summary-next-unread-article))
7888 (if (or (null gnus-current-article)
7889 (null gnus-article-current)
7890 (/= article (cdr gnus-article-current))
7891 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7892 ;; Selected subject is different from current article's.
7893 (gnus-summary-display-article article)
7894 (when article-window
7895 (gnus-eval-in-buffer-window gnus-article-buffer
7896 (setq endp (or (gnus-article-next-page lines)
7897 (gnus-article-only-boring-p))))
7898 (when endp
7899 (cond ((or stop gnus-summary-stop-at-end-of-message)
7900 (gnus-message 3 "End of message"))
7901 (circular
7902 (gnus-summary-beginning-of-article))
7903 (lines
7904 (gnus-message 3 "End of message"))
7905 ((null lines)
7906 (if (and (eq gnus-summary-goto-unread 'never)
7907 (not (gnus-summary-last-article-p article)))
7908 (gnus-summary-next-article)
7909 (gnus-summary-next-unread-article))))))))
7910 (gnus-summary-recenter)
7911 (gnus-summary-position-point)))
7912
7913 (defun gnus-summary-prev-page (&optional lines move)
7914 "Show previous page of selected article.
7915 Argument LINES specifies lines to be scrolled down.
7916 If MOVE, move to the previous unread article if point is at
7917 the beginning of the buffer."
7918 (interactive "P")
7919 (let ((article (gnus-summary-article-number))
7920 (article-window (get-buffer-window gnus-article-buffer t))
7921 endp)
7922 (gnus-configure-windows 'article)
7923 (if (or (null gnus-current-article)
7924 (null gnus-article-current)
7925 (/= article (cdr gnus-article-current))
7926 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7927 ;; Selected subject is different from current article's.
7928 (gnus-summary-display-article article)
7929 (gnus-summary-recenter)
7930 (when article-window
7931 (gnus-eval-in-buffer-window gnus-article-buffer
7932 (setq endp (gnus-article-prev-page lines)))
7933 (when (and move endp)
7934 (cond (lines
7935 (gnus-message 3 "Beginning of message"))
7936 ((null lines)
7937 (if (and (eq gnus-summary-goto-unread 'never)
7938 (not (gnus-summary-first-article-p article)))
7939 (gnus-summary-prev-article)
7940 (gnus-summary-prev-unread-article))))))))
7941 (gnus-summary-position-point))
7942
7943 (defun gnus-summary-prev-page-or-article (&optional lines)
7944 "Show previous page of selected article.
7945 Argument LINES specifies lines to be scrolled down.
7946 If at the beginning of the article, go to the next article."
7947 (interactive "P")
7948 (gnus-summary-prev-page lines t))
7949
7950 (defun gnus-summary-scroll-up (lines)
7951 "Scroll up (or down) one line current article.
7952 Argument LINES specifies lines to be scrolled up (or down if negative).
7953 If no article is selected, then the current article will be selected first."
7954 (interactive "p")
7955 (gnus-configure-windows 'article)
7956 (gnus-summary-show-thread)
7957 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7958 (gnus-eval-in-buffer-window gnus-article-buffer
7959 (cond ((> lines 0)
7960 (when (gnus-article-next-page lines)
7961 (gnus-message 3 "End of message")))
7962 ((< lines 0)
7963 (gnus-article-prev-page (- lines))))))
7964 (gnus-summary-recenter)
7965 (gnus-summary-position-point))
7966
7967 (defun gnus-summary-scroll-down (lines)
7968 "Scroll down (or up) one line current article.
7969 Argument LINES specifies lines to be scrolled down (or up if negative).
7970 If no article is selected, then the current article will be selected first."
7971 (interactive "p")
7972 (gnus-summary-scroll-up (- lines)))
7973
7974 (defun gnus-summary-next-same-subject ()
7975 "Select next article which has the same subject as current one."
7976 (interactive)
7977 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7978
7979 (defun gnus-summary-prev-same-subject ()
7980 "Select previous article which has the same subject as current one."
7981 (interactive)
7982 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7983
7984 (defun gnus-summary-next-unread-same-subject ()
7985 "Select next unread article which has the same subject as current one."
7986 (interactive)
7987 (gnus-summary-next-article t (gnus-summary-article-subject)))
7988
7989 (defun gnus-summary-prev-unread-same-subject ()
7990 "Select previous unread article which has the same subject as current one."
7991 (interactive)
7992 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7993
7994 (defun gnus-summary-first-unread-article ()
7995 "Select the first unread article.
7996 Return nil if there are no unread articles."
7997 (interactive)
7998 (prog1
7999 (when (gnus-summary-first-subject t)
8000 (gnus-summary-show-thread)
8001 (gnus-summary-first-subject t)
8002 (gnus-summary-display-article (gnus-summary-article-number)))
8003 (gnus-summary-position-point)))
8004
8005 (defun gnus-summary-first-unread-subject ()
8006 "Place the point on the subject line of the first unread article.
8007 Return nil if there are no unread articles."
8008 (interactive)
8009 (prog1
8010 (when (gnus-summary-first-subject t)
8011 (gnus-summary-show-thread)
8012 (gnus-summary-first-subject t))
8013 (gnus-summary-position-point)))
8014
8015 (defun gnus-summary-first-unseen-subject ()
8016 "Place the point on the subject line of the first unseen article.
8017 Return nil if there are no unseen articles."
8018 (interactive)
8019 (prog1
8020 (when (gnus-summary-first-subject nil nil t)
8021 (gnus-summary-show-thread)
8022 (gnus-summary-first-subject nil nil t))
8023 (gnus-summary-position-point)))
8024
8025 (defun gnus-summary-first-unseen-or-unread-subject ()
8026 "Place the point on the subject line of the first unseen and unread article.
8027 If all article have been seen, on the subject line of the first unread
8028 article."
8029 (interactive)
8030 (prog1
8031 (unless (when (gnus-summary-first-subject nil nil t)
8032 (gnus-summary-show-thread)
8033 (gnus-summary-first-subject nil nil t))
8034 (when (gnus-summary-first-subject t)
8035 (gnus-summary-show-thread)
8036 (gnus-summary-first-subject t)))
8037 (gnus-summary-position-point)))
8038
8039 (defun gnus-summary-first-article ()
8040 "Select the first article.
8041 Return nil if there are no articles."
8042 (interactive)
8043 (prog1
8044 (when (gnus-summary-first-subject)
8045 (gnus-summary-show-thread)
8046 (gnus-summary-first-subject)
8047 (gnus-summary-display-article (gnus-summary-article-number)))
8048 (gnus-summary-position-point)))
8049
8050 (defun gnus-summary-best-unread-article (&optional arg)
8051 "Select the unread article with the highest score.
8052 If given a prefix argument, select the next unread article that has a
8053 score higher than the default score."
8054 (interactive "P")
8055 (let ((article (if arg
8056 (gnus-summary-better-unread-subject)
8057 (gnus-summary-best-unread-subject))))
8058 (if article
8059 (gnus-summary-goto-article article)
8060 (error "No unread articles"))))
8061
8062 (defun gnus-summary-best-unread-subject ()
8063 "Select the unread subject with the highest score."
8064 (interactive)
8065 (let ((best -1000000)
8066 (data gnus-newsgroup-data)
8067 article score)
8068 (while data
8069 (and (gnus-data-unread-p (car data))
8070 (> (setq score
8071 (gnus-summary-article-score (gnus-data-number (car data))))
8072 best)
8073 (setq best score
8074 article (gnus-data-number (car data))))
8075 (setq data (cdr data)))
8076 (when article
8077 (gnus-summary-goto-subject article))
8078 (gnus-summary-position-point)
8079 article))
8080
8081 (defun gnus-summary-better-unread-subject ()
8082 "Select the first unread subject that has a score over the default score."
8083 (interactive)
8084 (let ((data gnus-newsgroup-data)
8085 article score)
8086 (while (and (setq article (gnus-data-number (car data)))
8087 (or (gnus-data-read-p (car data))
8088 (not (> (gnus-summary-article-score article)
8089 gnus-summary-default-score))))
8090 (setq data (cdr data)))
8091 (when article
8092 (gnus-summary-goto-subject article))
8093 (gnus-summary-position-point)
8094 article))
8095
8096 (defun gnus-summary-last-subject ()
8097 "Go to the last displayed subject line in the group."
8098 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8099 (when article
8100 (gnus-summary-goto-subject article))))
8101
8102 (defun gnus-summary-goto-article (article &optional all-headers force)
8103 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8104 If ALL-HEADERS is non-nil, no header lines are hidden.
8105 If FORCE, go to the article even if it isn't displayed. If FORCE
8106 is a number, it is the line the article is to be displayed on."
8107 (interactive
8108 (list
8109 (gnus-completing-read
8110 "Article number or Message-ID"
8111 (mapcar 'int-to-string gnus-newsgroup-limit))
8112 current-prefix-arg
8113 t))
8114 (prog1
8115 (if (and (stringp article)
8116 (string-match "@\\|%40" article))
8117 (gnus-summary-refer-article article)
8118 (when (stringp article)
8119 (setq article (string-to-number article)))
8120 (if (gnus-summary-goto-subject article force)
8121 (gnus-summary-display-article article all-headers)
8122 (gnus-message 4 "Couldn't go to article %s" article) nil))
8123 (gnus-summary-position-point)))
8124
8125 (defun gnus-summary-goto-last-article ()
8126 "Go to the previously read article."
8127 (interactive)
8128 (prog1
8129 (when gnus-last-article
8130 (gnus-summary-goto-article gnus-last-article nil t))
8131 (gnus-summary-position-point)))
8132
8133 (defun gnus-summary-pop-article (number)
8134 "Pop one article off the history and go to the previous.
8135 NUMBER articles will be popped off."
8136 (interactive "p")
8137 (let (to)
8138 (setq gnus-newsgroup-history
8139 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8140 (if to
8141 (gnus-summary-goto-article (car to) nil t)
8142 (error "Article history empty")))
8143 (gnus-summary-position-point))
8144
8145 ;; Summary commands and functions for limiting the summary buffer.
8146
8147 (defun gnus-summary-limit-to-articles (n)
8148 "Limit the summary buffer to the next N articles.
8149 If not given a prefix, use the process marked articles instead."
8150 (interactive "P")
8151 (prog1
8152 (let ((articles (gnus-summary-work-articles n)))
8153 (setq gnus-newsgroup-processable nil)
8154 (gnus-summary-limit articles))
8155 (gnus-summary-position-point)))
8156
8157 (defun gnus-summary-pop-limit (&optional total)
8158 "Restore the previous limit.
8159 If given a prefix, remove all limits."
8160 (interactive "P")
8161 (when total
8162 (setq gnus-newsgroup-limits
8163 (list (mapcar (lambda (h) (mail-header-number h))
8164 gnus-newsgroup-headers))))
8165 (unless gnus-newsgroup-limits
8166 (error "No limit to pop"))
8167 (prog1
8168 (gnus-summary-limit nil 'pop)
8169 (gnus-summary-position-point)))
8170
8171 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8172 "Limit the summary buffer to articles that have subjects that match a regexp.
8173 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8174 (interactive
8175 (list (read-string (if current-prefix-arg
8176 "Exclude subject (regexp): "
8177 "Limit to subject (regexp): "))
8178 nil current-prefix-arg))
8179 (unless header
8180 (setq header "subject"))
8181 (when (not (equal "" subject))
8182 (prog1
8183 (let ((articles (gnus-summary-find-matching
8184 (or header "subject") subject 'all nil nil
8185 not-matching)))
8186 (unless articles
8187 (error "Found no matches for \"%s\"" subject))
8188 (gnus-summary-limit articles))
8189 (gnus-summary-position-point))))
8190
8191 (defun gnus-summary-limit-to-author (from &optional not-matching)
8192 "Limit the summary buffer to articles that have authors that match a regexp.
8193 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8194 (interactive
8195 (list (let* ((header (gnus-summary-article-header))
8196 (default (and header (car (mail-header-parse-address
8197 (mail-header-from header))))))
8198 (read-string (concat (if current-prefix-arg
8199 "Exclude author (regexp"
8200 "Limit to author (regexp")
8201 (if default
8202 (concat ", default \"" default "\"): ")
8203 "): "))
8204 nil nil
8205 default))
8206 current-prefix-arg))
8207 (gnus-summary-limit-to-subject from "from" not-matching))
8208
8209 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8210 "Limit the summary buffer to articles with the given RECIPIENT.
8211
8212 If NOT-MATCHING, exclude RECIPIENT.
8213
8214 To and Cc headers are checked. You need to include them in
8215 `nnmail-extra-headers'."
8216 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8217 (interactive
8218 (list (read-string (format "%s recipient (regexp): "
8219 (if current-prefix-arg "Exclude" "Limit to")))
8220 current-prefix-arg))
8221 (when (not (equal "" recipient))
8222 (prog1 (let* ((to
8223 (if (memq 'To nnmail-extra-headers)
8224 (gnus-summary-find-matching
8225 (cons 'extra 'To) recipient 'all nil nil
8226 not-matching)
8227 (gnus-message
8228 1 "`To' isn't present in `nnmail-extra-headers'")
8229 (sit-for 1)
8230 nil))
8231 (cc
8232 (if (memq 'Cc nnmail-extra-headers)
8233 (gnus-summary-find-matching
8234 (cons 'extra 'Cc) recipient 'all nil nil
8235 not-matching)
8236 (gnus-message
8237 1 "`Cc' isn't present in `nnmail-extra-headers'")
8238 (sit-for 1)
8239 nil))
8240 (articles
8241 (if not-matching
8242 ;; We need the numbers that are in both lists:
8243 (mapcar (lambda (a)
8244 (and (memq a to) a))
8245 cc)
8246 (nconc to cc))))
8247 (unless articles
8248 (error "Found no matches for \"%s\"" recipient))
8249 (gnus-summary-limit articles))
8250 (gnus-summary-position-point))))
8251
8252 (defun gnus-summary-limit-to-address (address &optional not-matching)
8253 "Limit the summary buffer to articles with the given ADDRESS.
8254
8255 If NOT-MATCHING, exclude ADDRESS.
8256
8257 To, Cc and From headers are checked. You need to include `To' and `Cc'
8258 in `nnmail-extra-headers'."
8259 (interactive
8260 (list (read-string (format "%s address (regexp): "
8261 (if current-prefix-arg "Exclude" "Limit to")))
8262 current-prefix-arg))
8263 (when (not (equal "" address))
8264 (prog1 (let* ((to
8265 (if (memq 'To nnmail-extra-headers)
8266 (gnus-summary-find-matching
8267 (cons 'extra 'To) address 'all nil nil
8268 not-matching)
8269 (gnus-message
8270 1 "`To' isn't present in `nnmail-extra-headers'")
8271 (sit-for 1)
8272 t))
8273 (cc
8274 (if (memq 'Cc nnmail-extra-headers)
8275 (gnus-summary-find-matching
8276 (cons 'extra 'Cc) address 'all nil nil
8277 not-matching)
8278 (gnus-message
8279 1 "`Cc' isn't present in `nnmail-extra-headers'")
8280 (sit-for 1)
8281 t))
8282 (from
8283 (gnus-summary-find-matching "from" address
8284 'all nil nil not-matching))
8285 (articles
8286 (if not-matching
8287 ;; We need the numbers that are in all lists:
8288 (if (eq cc t)
8289 (if (eq to t)
8290 from
8291 (mapcar (lambda (a) (car (memq a from))) to))
8292 (if (eq to t)
8293 (mapcar (lambda (a) (car (memq a from))) cc)
8294 (mapcar (lambda (a) (car (memq a from)))
8295 (mapcar (lambda (a) (car (memq a to)))
8296 cc))))
8297 (nconc (if (eq to t) nil to)
8298 (if (eq cc t) nil cc)
8299 from))))
8300 (unless articles
8301 (error "Found no matches for \"%s\"" address))
8302 (gnus-summary-limit articles))
8303 (gnus-summary-position-point))))
8304
8305 (defun gnus-summary-limit-strange-charsets-predicate (header)
8306 (when (fboundp 'char-charset)
8307 (let ((string (concat (mail-header-subject header)
8308 (mail-header-from header)))
8309 charset found)
8310 (dotimes (i (1- (length string)))
8311 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8312 (when (string-match "unicode\\|big\\|japanese" charset)
8313 (setq found t)))
8314 found)))
8315
8316 (defun gnus-summary-limit-to-predicate (predicate)
8317 "Limit to articles where PREDICATE returns non-nil.
8318 PREDICATE will be called with the header structures of the
8319 articles."
8320 (let ((articles nil)
8321 (case-fold-search t))
8322 (dolist (header gnus-newsgroup-headers)
8323 (when (funcall predicate header)
8324 (push (mail-header-number header) articles)))
8325 (gnus-summary-limit (nreverse articles))))
8326
8327 (defun gnus-summary-limit-to-age (age &optional younger-p)
8328 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8329 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8330 articles that are younger than AGE days."
8331 (interactive
8332 (let ((younger current-prefix-arg)
8333 (days-got nil)
8334 days)
8335 (while (not days-got)
8336 (setq days (if younger
8337 (read-string "Limit to articles younger than (in days, older when negative): ")
8338 (read-string
8339 "Limit to articles older than (in days, younger when negative): ")))
8340 (when (> (length days) 0)
8341 (setq days (read days)))
8342 (if (numberp days)
8343 (progn
8344 (setq days-got t)
8345 (when (< days 0)
8346 (setq younger (not younger))
8347 (setq days (* days -1))))
8348 (message "Please enter a number.")
8349 (sleep-for 1)))
8350 (list days younger)))
8351 (prog1
8352 (let ((data gnus-newsgroup-data)
8353 (cutoff (days-to-time age))
8354 articles d date is-younger)
8355 (while (setq d (pop data))
8356 (when (and (vectorp (gnus-data-header d))
8357 (setq date (mail-header-date (gnus-data-header d))))
8358 (setq is-younger (time-less-p
8359 (time-since (gnus-date-get-time date))
8360 cutoff))
8361 (when (if younger-p
8362 is-younger
8363 (not is-younger))
8364 (push (gnus-data-number d) articles))))
8365 (gnus-summary-limit (nreverse articles)))
8366 (gnus-summary-position-point)))
8367
8368 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8369 "Limit the summary buffer to articles that match an 'extra' header."
8370 (interactive
8371 (let ((header
8372 (intern
8373 (gnus-completing-read
8374 (if current-prefix-arg
8375 "Exclude extra header"
8376 "Limit extra header")
8377 (mapcar 'symbol-name gnus-extra-headers)
8378 t nil nil
8379 (symbol-name (car gnus-extra-headers))))))
8380 (list header
8381 (read-string (format "%s header %s (regexp): "
8382 (if current-prefix-arg "Exclude" "Limit to")
8383 header))
8384 current-prefix-arg)))
8385 (when (not (equal "" regexp))
8386 (prog1
8387 (let ((articles (gnus-summary-find-matching
8388 (cons 'extra header) regexp 'all nil nil
8389 not-matching)))
8390 (unless articles
8391 (error "Found no matches for \"%s\"" regexp))
8392 (gnus-summary-limit articles))
8393 (gnus-summary-position-point))))
8394
8395 (defun gnus-summary-limit-to-display-predicate ()
8396 "Limit the summary buffer to the predicated in the `display' group parameter."
8397 (interactive)
8398 (unless gnus-newsgroup-display
8399 (error "There is no `display' group parameter"))
8400 (let (articles)
8401 (dolist (gnus-number gnus-newsgroup-articles)
8402 (when (funcall gnus-newsgroup-display)
8403 (push gnus-number articles)))
8404 (gnus-summary-limit articles))
8405 (gnus-summary-position-point))
8406
8407 (defun gnus-summary-limit-to-unread (&optional all)
8408 "Limit the summary buffer to articles that are not marked as read.
8409 If ALL is non-nil, limit strictly to unread articles."
8410 (interactive "P")
8411 (if all
8412 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8413 (gnus-summary-limit-to-marks
8414 ;; Concat all the marks that say that an article is read and have
8415 ;; those removed.
8416 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8417 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8418 gnus-low-score-mark gnus-expirable-mark
8419 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8420 gnus-duplicate-mark)
8421 'reverse)))
8422
8423 (defun gnus-summary-limit-to-headers (match &optional reverse)
8424 "Limit the summary buffer to articles that have headers that match MATCH.
8425 If REVERSE (the prefix), limit to articles that don't match."
8426 (interactive "sMatch headers (regexp): \nP")
8427 (gnus-summary-limit-to-bodies match reverse t))
8428
8429 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8430 "Limit the summary buffer to articles that have bodies that match MATCH.
8431 If REVERSE (the prefix), limit to articles that don't match."
8432 (interactive "sMatch body (regexp): \nP")
8433 (let ((articles nil)
8434 (gnus-select-article-hook nil) ;Disable hook.
8435 (gnus-article-prepare-hook nil)
8436 (gnus-use-article-prefetch nil)
8437 (gnus-keep-backlog nil)
8438 (gnus-break-pages nil)
8439 (gnus-summary-display-arrow nil)
8440 (gnus-updated-mode-lines nil)
8441 (gnus-auto-center-summary nil)
8442 (gnus-display-mime-function nil))
8443 (dolist (data gnus-newsgroup-data)
8444 (let (gnus-mark-article-hook)
8445 (gnus-summary-select-article t t nil (gnus-data-number data)))
8446 (with-current-buffer gnus-article-buffer
8447 (article-goto-body)
8448 (let* ((case-fold-search t)
8449 (found (if headersp
8450 (re-search-backward match nil t)
8451 (re-search-forward match nil t))))
8452 (when (or (and found
8453 (not reverse))
8454 (and (not found)
8455 reverse))
8456 (push (gnus-data-number data) articles)))))
8457 (if (not articles)
8458 (message "No messages matched")
8459 (gnus-summary-limit articles)))
8460 (gnus-summary-position-point))
8461
8462 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8463 "Limit the summary buffer to articles that aren't part on any thread.
8464 If THREADSP (the prefix), limit to articles that are in threads."
8465 (interactive "P")
8466 (let ((articles nil)
8467 thread-articles
8468 threads)
8469 (dolist (thread gnus-newsgroup-threads)
8470 (if (stringp (car thread))
8471 (dolist (thread (cdr thread))
8472 (push thread threads))
8473 (push thread threads)))
8474 (dolist (thread threads)
8475 (setq thread-articles (gnus-articles-in-thread thread))
8476 (when (or (and threadsp
8477 (> (length thread-articles) 1))
8478 (and (not threadsp)
8479 (= (length thread-articles) 1)))
8480 (setq articles (nconc thread-articles articles))))
8481 (if (not articles)
8482 (message "No messages matched")
8483 (gnus-summary-limit articles))
8484 (gnus-summary-position-point)))
8485
8486 (defun gnus-summary-limit-to-replied (&optional unreplied)
8487 "Limit the summary buffer to replied articles.
8488 If UNREPLIED (the prefix), limit to unreplied articles."
8489 (interactive "P")
8490 (if unreplied
8491 (gnus-summary-limit
8492 (gnus-set-difference gnus-newsgroup-articles
8493 gnus-newsgroup-replied))
8494 (gnus-summary-limit gnus-newsgroup-replied))
8495 (gnus-summary-position-point))
8496
8497 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8498 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8499 If REVERSE, limit the summary buffer to articles that are marked
8500 with MARKS. MARKS can either be a string of marks or a list of marks.
8501 Returns how many articles were removed."
8502 (interactive "sMarks: ")
8503 (gnus-summary-limit-to-marks marks t))
8504
8505 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8506 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8507 If REVERSE (the prefix), limit the summary buffer to articles that are
8508 not marked with MARKS. MARKS can either be a string of marks or a
8509 list of marks.
8510 Returns how many articles were removed."
8511 (interactive "sMarks: \nP")
8512 (prog1
8513 (let ((data gnus-newsgroup-data)
8514 (marks (if (listp marks) marks
8515 (append marks nil))) ; Transform to list.
8516 articles)
8517 (while data
8518 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8519 (memq (gnus-data-mark (car data)) marks))
8520 (push (gnus-data-number (car data)) articles))
8521 (setq data (cdr data)))
8522 (gnus-summary-limit articles))
8523 (gnus-summary-position-point)))
8524
8525 (defun gnus-summary-limit-to-score (score)
8526 "Limit to articles with score at or above SCORE."
8527 (interactive "NLimit to articles with score of at least: ")
8528 (let ((data gnus-newsgroup-data)
8529 articles)
8530 (while data
8531 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8532 score)
8533 (push (gnus-data-number (car data)) articles))
8534 (setq data (cdr data)))
8535 (prog1
8536 (gnus-summary-limit articles)
8537 (gnus-summary-position-point))))
8538
8539 (defun gnus-summary-limit-to-unseen ()
8540 "Limit to unseen articles."
8541 (interactive)
8542 (prog1
8543 (gnus-summary-limit gnus-newsgroup-unseen)
8544 (gnus-summary-position-point)))
8545
8546 (defun gnus-summary-limit-include-thread (id)
8547 "Display all the hidden articles that is in the thread with ID in it.
8548 When called interactively, ID is the Message-ID of the current
8549 article."
8550 (interactive (list (mail-header-id (gnus-summary-article-header))))
8551 (let ((articles (gnus-articles-in-thread
8552 (gnus-id-to-thread (gnus-root-id id))))
8553 ;;we REALLY want the whole thread---this prevents cut-threads
8554 ;;from removing the thread we want to include.
8555 (gnus-fetch-old-headers nil)
8556 (gnus-build-sparse-threads nil))
8557 (prog1
8558 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8559 (gnus-summary-limit-include-matching-articles
8560 "subject"
8561 (regexp-quote (gnus-simplify-subject-re
8562 (mail-header-subject (gnus-id-to-header id)))))
8563 (gnus-summary-position-point))))
8564
8565 (defun gnus-summary-limit-include-matching-articles (header regexp)
8566 "Display all the hidden articles that have HEADERs that match REGEXP."
8567 (interactive (list (read-string "Match on header: ")
8568 (read-string "Regexp: ")))
8569 (let ((articles (gnus-find-matching-articles header regexp)))
8570 (prog1
8571 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8572 (gnus-summary-position-point))))
8573
8574 (defun gnus-summary-insert-dormant-articles ()
8575 "Insert all the dormant articles for this group into the current buffer."
8576 (interactive)
8577 (let ((gnus-verbose (max 6 gnus-verbose)))
8578 (if (not gnus-newsgroup-dormant)
8579 (gnus-message 3 "No dormant articles for this group")
8580 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8581
8582 (defun gnus-summary-insert-ticked-articles ()
8583 "Insert ticked articles for this group into the current buffer."
8584 (interactive)
8585 (let ((gnus-verbose (max 6 gnus-verbose)))
8586 (if (not gnus-newsgroup-marked)
8587 (gnus-message 3 "No ticked articles for this group")
8588 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8589
8590 (defun gnus-summary-limit-include-dormant ()
8591 "Display all the hidden articles that are marked as dormant.
8592 Note that this command only works on a subset of the articles currently
8593 fetched for this group."
8594 (interactive)
8595 (unless gnus-newsgroup-dormant
8596 (error "There are no dormant articles in this group"))
8597 (prog1
8598 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8599 (gnus-summary-position-point)))
8600
8601 (defun gnus-summary-include-articles (articles)
8602 "Fetch the headers for ARTICLES and then display the summary lines."
8603 (let ((gnus-inhibit-demon t)
8604 (gnus-agent nil)
8605 (gnus-read-all-available-headers t))
8606 (setq gnus-newsgroup-headers
8607 (gnus-merge
8608 'list gnus-newsgroup-headers
8609 (gnus-fetch-headers articles nil t)
8610 'gnus-article-sort-by-number))
8611 (setq gnus-newsgroup-articles
8612 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8613 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8614
8615 (defun gnus-summary-limit-exclude-dormant ()
8616 "Hide all dormant articles."
8617 (interactive)
8618 (prog1
8619 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8620 (gnus-summary-position-point)))
8621
8622 (defun gnus-summary-limit-exclude-childless-dormant ()
8623 "Hide all dormant articles that have no children."
8624 (interactive)
8625 (let ((data (gnus-data-list t))
8626 articles d children)
8627 ;; Find all articles that are either not dormant or have
8628 ;; children.
8629 (while (setq d (pop data))
8630 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8631 (and (setq children
8632 (gnus-article-children (gnus-data-number d)))
8633 (let (found)
8634 (while children
8635 (when (memq (car children) articles)
8636 (setq children nil
8637 found t))
8638 (pop children))
8639 found)))
8640 (push (gnus-data-number d) articles)))
8641 ;; Do the limiting.
8642 (prog1
8643 (gnus-summary-limit articles)
8644 (gnus-summary-position-point))))
8645
8646 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8647 "Mark all unread excluded articles as read.
8648 If ALL, mark even excluded ticked and dormants as read."
8649 (interactive "P")
8650 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8651 (let ((articles (gnus-sorted-ndifference
8652 (sort
8653 (mapcar (lambda (h) (mail-header-number h))
8654 gnus-newsgroup-headers)
8655 '<)
8656 gnus-newsgroup-limit))
8657 article)
8658 (setq gnus-newsgroup-unreads
8659 (gnus-sorted-intersection gnus-newsgroup-unreads
8660 gnus-newsgroup-limit))
8661 (if all
8662 (setq gnus-newsgroup-dormant nil
8663 gnus-newsgroup-marked nil
8664 gnus-newsgroup-reads
8665 (nconc
8666 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8667 gnus-newsgroup-reads))
8668 (while (setq article (pop articles))
8669 (unless (or (memq article gnus-newsgroup-dormant)
8670 (memq article gnus-newsgroup-marked))
8671 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8672
8673 (defun gnus-summary-limit (articles &optional pop)
8674 (if pop
8675 ;; We pop the previous limit off the stack and use that.
8676 (setq articles (car gnus-newsgroup-limits)
8677 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8678 ;; We use the new limit, so we push the old limit on the stack.
8679 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8680 ;; Set the limit.
8681 (setq gnus-newsgroup-limit articles)
8682 (let ((total (length gnus-newsgroup-data))
8683 (data (gnus-data-find-list (gnus-summary-article-number)))
8684 (gnus-summary-mark-below nil) ; Inhibit this.
8685 found)
8686 ;; This will do all the work of generating the new summary buffer
8687 ;; according to the new limit.
8688 (gnus-summary-prepare)
8689 ;; Hide any threads, possibly.
8690 (gnus-summary-maybe-hide-threads)
8691 ;; Try to return to the article you were at, or one in the
8692 ;; neighborhood.
8693 (when data
8694 ;; We try to find some article after the current one.
8695 (while data
8696 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8697 (setq data nil
8698 found t))
8699 (setq data (cdr data))))
8700 (unless found
8701 ;; If there is no data, that means that we were after the last
8702 ;; article. The same goes when we can't find any articles
8703 ;; after the current one.
8704 (goto-char (point-max))
8705 (gnus-summary-find-prev))
8706 (gnus-set-mode-line 'summary)
8707 ;; We return how many articles were removed from the summary
8708 ;; buffer as a result of the new limit.
8709 (- total (length gnus-newsgroup-data))))
8710
8711 (defsubst gnus-invisible-cut-children (threads)
8712 (let ((num 0))
8713 (while threads
8714 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8715 (incf num))
8716 (pop threads))
8717 (< num 2)))
8718
8719 (defsubst gnus-cut-thread (thread)
8720 "Go forwards in the thread until we find an article that we want to display."
8721 (when (or (eq gnus-fetch-old-headers 'some)
8722 (eq gnus-fetch-old-headers 'invisible)
8723 (numberp gnus-fetch-old-headers)
8724 (eq gnus-build-sparse-threads 'some)
8725 (eq gnus-build-sparse-threads 'more))
8726 ;; Deal with old-fetched headers and sparse threads.
8727 (while (and
8728 thread
8729 (or
8730 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8731 (gnus-summary-article-ancient-p
8732 (mail-header-number (car thread))))
8733 (if (or (<= (length (cdr thread)) 1)
8734 (eq gnus-fetch-old-headers 'invisible))
8735 (setq gnus-newsgroup-limit
8736 (delq (mail-header-number (car thread))
8737 gnus-newsgroup-limit)
8738 thread (cadr thread))
8739 (when (gnus-invisible-cut-children (cdr thread))
8740 (let ((th (cdr thread)))
8741 (while th
8742 (if (memq (mail-header-number (caar th))
8743 gnus-newsgroup-limit)
8744 (setq thread (car th)
8745 th nil)
8746 (setq th (cdr th))))))))))
8747 thread)
8748
8749 (defun gnus-cut-threads (threads)
8750 "Cut off all uninteresting articles from the beginning of THREADS."
8751 (when (or (eq gnus-fetch-old-headers 'some)
8752 (eq gnus-fetch-old-headers 'invisible)
8753 (numberp gnus-fetch-old-headers)
8754 (eq gnus-build-sparse-threads 'some)
8755 (eq gnus-build-sparse-threads 'more))
8756 (let ((th threads))
8757 (while th
8758 (setcar th (gnus-cut-thread (car th)))
8759 (setq th (cdr th)))))
8760 ;; Remove nixed out threads.
8761 (delq nil threads))
8762
8763 (defun gnus-summary-initial-limit (&optional show-if-empty)
8764 "Figure out what the initial limit is supposed to be on group entry.
8765 This entails weeding out unwanted dormants, low-scored articles,
8766 fetch-old-headers verbiage, and so on."
8767 ;; Most groups have nothing to remove.
8768 (unless (or gnus-inhibit-limiting
8769 (and (null gnus-newsgroup-dormant)
8770 (eq gnus-newsgroup-display 'gnus-not-ignore)
8771 (not (eq gnus-fetch-old-headers 'some))
8772 (not (numberp gnus-fetch-old-headers))
8773 (not (eq gnus-fetch-old-headers 'invisible))
8774 (null gnus-summary-expunge-below)
8775 (not (eq gnus-build-sparse-threads 'some))
8776 (not (eq gnus-build-sparse-threads 'more))
8777 (null gnus-thread-expunge-below)))
8778 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8779 (setq gnus-newsgroup-limit nil)
8780 (mapatoms
8781 (lambda (node)
8782 (unless (car (symbol-value node))
8783 ;; These threads have no parents -- they are roots.
8784 (let ((nodes (cdr (symbol-value node)))
8785 thread)
8786 (while nodes
8787 (if (and gnus-thread-expunge-below
8788 (< (gnus-thread-total-score (car nodes))
8789 gnus-thread-expunge-below))
8790 (gnus-expunge-thread (pop nodes))
8791 (setq thread (pop nodes))
8792 (gnus-summary-limit-children thread))))))
8793 gnus-newsgroup-dependencies)
8794 ;; If this limitation resulted in an empty group, we might
8795 ;; pop the previous limit and use it instead.
8796 (when (and (not gnus-newsgroup-limit)
8797 show-if-empty)
8798 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8799 gnus-newsgroup-limit))
8800
8801 (defun gnus-summary-limit-children (thread)
8802 "Return 1 if this subthread is visible and 0 if it is not."
8803 ;; First we get the number of visible children to this thread. This
8804 ;; is done by recursing down the thread using this function, so this
8805 ;; will really go down to a leaf article first, before slowly
8806 ;; working its way up towards the root.
8807 (when thread
8808 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8809 (children
8810 (if (cdr thread)
8811 (apply '+ (mapcar 'gnus-summary-limit-children
8812 (cdr thread)))
8813 0))
8814 (number (mail-header-number (car thread)))
8815 score)
8816 (if (and
8817 (not (memq number gnus-newsgroup-marked))
8818 (or
8819 ;; If this article is dormant and has absolutely no visible
8820 ;; children, then this article isn't visible.
8821 (and (memq number gnus-newsgroup-dormant)
8822 (zerop children))
8823 ;; If this is "fetch-old-headered" and there is no
8824 ;; visible children, then we don't want this article.
8825 (and (or (eq gnus-fetch-old-headers 'some)
8826 (numberp gnus-fetch-old-headers))
8827 (gnus-summary-article-ancient-p number)
8828 (zerop children))
8829 ;; If this is "fetch-old-headered" and `invisible', then
8830 ;; we don't want this article.
8831 (and (eq gnus-fetch-old-headers 'invisible)
8832 (gnus-summary-article-ancient-p number))
8833 ;; If this is a sparsely inserted article with no children,
8834 ;; we don't want it.
8835 (and (eq gnus-build-sparse-threads 'some)
8836 (gnus-summary-article-sparse-p number)
8837 (zerop children))
8838 ;; If we use expunging, and this article is really
8839 ;; low-scored, then we don't want this article.
8840 (when (and gnus-summary-expunge-below
8841 (< (setq score
8842 (or (cdr (assq number gnus-newsgroup-scored))
8843 gnus-summary-default-score))
8844 gnus-summary-expunge-below))
8845 ;; We increase the expunge-tally here, but that has
8846 ;; nothing to do with the limits, really.
8847 (incf gnus-newsgroup-expunged-tally)
8848 ;; We also mark as read here, if that's wanted.
8849 (when (and gnus-summary-mark-below
8850 (< score gnus-summary-mark-below))
8851 (setq gnus-newsgroup-unreads
8852 (delq number gnus-newsgroup-unreads))
8853 (if gnus-newsgroup-auto-expire
8854 (push number gnus-newsgroup-expirable)
8855 (push (cons number gnus-low-score-mark)
8856 gnus-newsgroup-reads)))
8857 t)
8858 ;; Do the `display' group parameter.
8859 (and gnus-newsgroup-display
8860 (let ((gnus-number number))
8861 (not (funcall gnus-newsgroup-display))))))
8862 ;; Nope, invisible article.
8863 0
8864 ;; Ok, this article is to be visible, so we add it to the limit
8865 ;; and return 1.
8866 (push number gnus-newsgroup-limit)
8867 1))))
8868
8869 (defun gnus-expunge-thread (thread)
8870 "Mark all articles in THREAD as read."
8871 (let* ((number (mail-header-number (car thread))))
8872 (incf gnus-newsgroup-expunged-tally)
8873 ;; We also mark as read here, if that's wanted.
8874 (setq gnus-newsgroup-unreads
8875 (delq number gnus-newsgroup-unreads))
8876 (if gnus-newsgroup-auto-expire
8877 (push number gnus-newsgroup-expirable)
8878 (push (cons number gnus-low-score-mark)
8879 gnus-newsgroup-reads)))
8880 ;; Go recursively through all subthreads.
8881 (mapcar 'gnus-expunge-thread (cdr thread)))
8882
8883 ;; Summary article oriented commands
8884
8885 (defun gnus-summary-refer-parent-article (n)
8886 "Refer parent article N times.
8887 If N is negative, go to ancestor -N instead.
8888 The difference between N and the number of articles fetched is returned."
8889 (interactive "p")
8890 (let ((skip 1)
8891 error header ref)
8892 (when (not (natnump n))
8893 (setq skip (abs n)
8894 n 1))
8895 (while (and (> n 0)
8896 (not error))
8897 (setq header (gnus-summary-article-header))
8898 (if (and (eq (mail-header-number header)
8899 (cdr gnus-article-current))
8900 (equal gnus-newsgroup-name
8901 (car gnus-article-current)))
8902 ;; If we try to find the parent of the currently
8903 ;; displayed article, then we take a look at the actual
8904 ;; References header, since this is slightly more
8905 ;; reliable than the References field we got from the
8906 ;; server.
8907 (with-current-buffer gnus-original-article-buffer
8908 (nnheader-narrow-to-headers)
8909 (unless (setq ref (message-fetch-field "references"))
8910 (when (setq ref (message-fetch-field "in-reply-to"))
8911 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8912 (widen))
8913 (setq ref
8914 ;; It's not the current article, so we take a bet on
8915 ;; the value we got from the server.
8916 (mail-header-references header)))
8917 (if (and ref
8918 (not (equal ref "")))
8919 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8920 (gnus-message 1 "Couldn't find parent"))
8921 (gnus-message 1 "No references in article %d"
8922 (gnus-summary-article-number))
8923 (setq error t))
8924 (decf n))
8925 (gnus-summary-position-point)
8926 n))
8927
8928 (defun gnus-summary-refer-references ()
8929 "Fetch all articles mentioned in the References header.
8930 Return the number of articles fetched."
8931 (interactive)
8932 (let ((ref (mail-header-references (gnus-summary-article-header)))
8933 (current (gnus-summary-article-number))
8934 (n 0))
8935 (if (or (not ref)
8936 (equal ref ""))
8937 (error "No References in the current article")
8938 ;; For each Message-ID in the References header...
8939 (while (string-match "<[^>]*>" ref)
8940 (incf n)
8941 ;; ... fetch that article.
8942 (gnus-summary-refer-article
8943 (prog1 (match-string 0 ref)
8944 (setq ref (substring ref (match-end 0))))))
8945 (gnus-summary-goto-subject current)
8946 (gnus-summary-position-point)
8947 n)))
8948
8949 (defun gnus-delete-duplicate-headers (headers)
8950 ;; First remove leading duplicates.
8951 (while (and (> (length headers) 1)
8952 (= (mail-header-number (car headers))
8953 (mail-header-number (cadr headers))))
8954 (pop headers))
8955 ;; Then the rest.
8956 (let ((result headers))
8957 (while (> (length headers) 1)
8958 (if (= (mail-header-number (car headers))
8959 (mail-header-number (cadr headers)))
8960 (setcdr headers (cddr headers))
8961 (pop headers)))
8962 result))
8963
8964 (defun gnus-summary-refer-thread (&optional limit)
8965 "Fetch all articles in the current thread. For backends that
8966 know how to search for threads (currently only 'nnimap) a
8967 non-numeric prefix arg will use nnir to search the entire
8968 server; without a prefix arg only the current group is
8969 searched. If the variable `gnus-refer-thread-use-nnir' is
8970 non-nil the prefix arg has the reverse meaning. If no
8971 backend-specific 'request-thread function is available fetch
8972 LIMIT (the numerical prefix) old headers. If LIMIT is
8973 non-numeric or nil fetch the number specified by the
8974 `gnus-refer-thread-limit' variable."
8975 (interactive "P")
8976 (gnus-warp-to-article)
8977 (let* ((header (gnus-summary-article-header))
8978 (id (mail-header-id header))
8979 (gnus-inhibit-demon t)
8980 (gnus-summary-ignore-duplicates t)
8981 (gnus-read-all-available-headers t)
8982 (gnus-refer-thread-use-nnir
8983 (if (and (not (null limit)) (listp limit))
8984 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
8985 (new-headers
8986 (if (gnus-check-backend-function
8987 'request-thread gnus-newsgroup-name)
8988 (gnus-request-thread header gnus-newsgroup-name)
8989 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
8990 gnus-refer-thread-limit))
8991 (last (if (numberp limit)
8992 (min (+ (mail-header-number header)
8993 limit)
8994 gnus-newsgroup-highest)
8995 gnus-newsgroup-highest))
8996 (subject (gnus-simplify-subject
8997 (mail-header-subject header)))
8998 (refs (split-string (or (mail-header-references header)
8999 "")))
9000 (gnus-parse-headers-hook
9001 `(lambda () (goto-char (point-min))
9002 (keep-lines
9003 (regexp-opt ',(append refs (list id subject)))))))
9004 (gnus-fetch-headers (list last) (if (numberp limit)
9005 (* 2 limit) limit) t))))
9006 article-ids)
9007 (when (listp new-headers)
9008 (dolist (header new-headers)
9009 (push (mail-header-number header) article-ids)
9010 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9011 (push (mail-header-number header) gnus-newsgroup-unreads)
9012 (setq gnus-newsgroup-unselected
9013 (delete (mail-header-number header)
9014 gnus-newsgroup-unselected))))
9015 (setq gnus-newsgroup-headers
9016 (gnus-delete-duplicate-headers
9017 (gnus-merge
9018 'list gnus-newsgroup-headers new-headers
9019 'gnus-article-sort-by-number)))
9020 (setq gnus-newsgroup-articles
9021 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9022 (gnus-summary-limit-include-thread id)))
9023 (gnus-summary-show-thread))
9024
9025 (defun gnus-summary-refer-article (message-id)
9026 "Fetch an article specified by MESSAGE-ID."
9027 (interactive "sMessage-ID: ")
9028 (gnus-warp-to-article)
9029 (when (and (stringp message-id)
9030 (not (zerop (length message-id))))
9031 (setq message-id (gnus-replace-in-string message-id " " ""))
9032 ;; Construct the correct Message-ID if necessary.
9033 ;; Suggested by tale@pawl.rpi.edu.
9034 (unless (string-match "^<" message-id)
9035 (setq message-id (concat "<" message-id)))
9036 (unless (string-match ">$" message-id)
9037 (setq message-id (concat message-id ">")))
9038 ;; People often post MIDs from URLs, so unhex it:
9039 (unless (string-match "@" message-id)
9040 (setq message-id (gnus-url-unhex-string message-id)))
9041 (let* ((header (gnus-id-to-header message-id))
9042 (sparse (and header
9043 (gnus-summary-article-sparse-p
9044 (mail-header-number header))
9045 (memq (mail-header-number header)
9046 gnus-newsgroup-limit)))
9047 number)
9048 (cond
9049 ;; If the article is present in the buffer we just go to it.
9050 ((and header
9051 (or (not (gnus-summary-article-sparse-p
9052 (mail-header-number header)))
9053 sparse))
9054 (prog1
9055 (gnus-summary-goto-article
9056 (mail-header-number header) nil t)
9057 (when sparse
9058 (gnus-summary-update-article (mail-header-number header)))))
9059 (t
9060 ;; We fetch the article.
9061 (catch 'found
9062 (dolist (gnus-override-method (gnus-refer-article-methods))
9063 (when (and (gnus-check-server gnus-override-method)
9064 ;; Fetch the header,
9065 (setq number (gnus-summary-insert-subject message-id)))
9066 ;; and display the article.
9067 (gnus-summary-select-article nil nil nil number)
9068 (throw 'found t)))
9069 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9070
9071 (defun gnus-refer-article-methods ()
9072 "Return a list of referable methods."
9073 (cond
9074 ;; No method, so we default to current and native.
9075 ((null gnus-refer-article-method)
9076 (list gnus-current-select-method gnus-select-method))
9077 ;; Current.
9078 ((eq 'current gnus-refer-article-method)
9079 (list gnus-current-select-method))
9080 ;; List of select methods.
9081 ((not (and (symbolp (car gnus-refer-article-method))
9082 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9083 (let (out)
9084 (dolist (method gnus-refer-article-method)
9085 (push (if (eq 'current method)
9086 gnus-current-select-method
9087 (if (eq 'nnir (car method))
9088 (list
9089 'nnir
9090 (or (cadr method)
9091 (gnus-method-to-server gnus-current-select-method)))
9092 method))
9093 out))
9094 (nreverse out)))
9095 ;; One single select method.
9096 (t
9097 (list gnus-refer-article-method))))
9098
9099 (defun gnus-summary-edit-parameters ()
9100 "Edit the group parameters of the current group."
9101 (interactive)
9102 (gnus-group-edit-group gnus-newsgroup-name 'params))
9103
9104 (defun gnus-summary-customize-parameters ()
9105 "Customize the group parameters of the current group."
9106 (interactive)
9107 (gnus-group-customize gnus-newsgroup-name))
9108
9109 (defun gnus-summary-enter-digest-group (&optional force)
9110 "Enter an nndoc group based on the current article.
9111 If FORCE, force a digest interpretation. If not, try to guess
9112 what the document format is.
9113
9114 To control what happens when you exit the group, see the
9115 `gnus-auto-select-on-ephemeral-exit' variable."
9116 (interactive "P")
9117 (let ((conf gnus-current-window-configuration))
9118 (save-window-excursion
9119 (save-excursion
9120 (let (gnus-article-prepare-hook
9121 gnus-display-mime-function
9122 gnus-break-pages)
9123 (gnus-summary-select-article))))
9124 (setq gnus-current-window-configuration conf)
9125 (let* ((name (format "%s-%d"
9126 (gnus-group-prefixed-name
9127 gnus-newsgroup-name (list 'nndoc ""))
9128 (with-current-buffer gnus-summary-buffer
9129 gnus-current-article)))
9130 (ogroup gnus-newsgroup-name)
9131 (params (append (gnus-info-params (gnus-get-info ogroup))
9132 (list (cons 'to-group ogroup))
9133 (list (cons 'parent-group ogroup))
9134 (list (cons 'save-article-group ogroup))))
9135 (case-fold-search t)
9136 (buf (current-buffer))
9137 dig to-address charset)
9138 (with-current-buffer gnus-original-article-buffer
9139 ;; Have the digest group inherit the main mail address of
9140 ;; the parent article.
9141 (when (setq to-address (or (gnus-fetch-field "reply-to")
9142 (gnus-fetch-field "from")))
9143 (setq params
9144 (append
9145 (list (cons 'to-address
9146 (funcall gnus-decode-encoded-address-function
9147 to-address))))))
9148 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9149 (insert-buffer-substring gnus-original-article-buffer)
9150 (narrow-to-region
9151 (goto-char (point-min))
9152 (or (search-forward "\n\n" nil t) (point)))
9153 ;; Remove lines that may lead nndoc to misinterpret the
9154 ;; document type.
9155 (goto-char (point-min))
9156 (delete-matching-lines "^Path:\\|^From ")
9157 ;; Parse charset, and decode content transfer encoding.
9158 (setq charset (mail-content-type-get
9159 (mail-header-parse-content-type
9160 (or (gnus-fetch-field "content-type") ""))
9161 'charset))
9162 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9163 (when encoding
9164 (message-remove-header "content-transfer-encoding")
9165 (goto-char (point-max))
9166 (widen)
9167 (narrow-to-region (point) (point-max))
9168 (mm-decode-content-transfer-encoding
9169 (intern (downcase (mail-header-strip encoding))))))
9170 (widen))
9171 (unwind-protect
9172 (if (let ((gnus-newsgroup-ephemeral-charset
9173 (if charset
9174 (intern (downcase (gnus-strip-whitespace charset)))
9175 gnus-newsgroup-charset))
9176 (gnus-newsgroup-ephemeral-ignored-charsets
9177 gnus-newsgroup-ignored-charsets))
9178 (gnus-group-read-ephemeral-group
9179 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9180 (nndoc-article-type
9181 ,(if force 'mbox 'guess)))
9182 t nil nil nil
9183 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9184 "ADAPT")))))
9185 ;; Make all postings to this group go to the parent group.
9186 (nconc (gnus-info-params (gnus-get-info name))
9187 params)
9188 ;; Couldn't select this doc group.
9189 (switch-to-buffer buf)
9190 (gnus-set-global-variables)
9191 (gnus-configure-windows 'summary)
9192 (gnus-message 3 "Article couldn't be entered?"))
9193 (kill-buffer dig)))))
9194
9195 (defun gnus-summary-read-document (n)
9196 "Open a new group based on the current article(s).
9197 This will allow you to read digests and other similar
9198 documents as newsgroups.
9199 Obeys the standard process/prefix convention."
9200 (interactive "P")
9201 (let* ((ogroup gnus-newsgroup-name)
9202 (params (append (gnus-info-params (gnus-get-info ogroup))
9203 (list (cons 'to-group ogroup))))
9204 group egroup groups vgroup)
9205 (dolist (article (gnus-summary-work-articles n))
9206 (setq group (format "%s-%d" gnus-newsgroup-name article))
9207 (gnus-summary-remove-process-mark article)
9208 (when (gnus-summary-display-article article)
9209 (save-excursion ;;What for?
9210 (with-temp-buffer
9211 (insert-buffer-substring gnus-original-article-buffer)
9212 ;; Remove some headers that may lead nndoc to make
9213 ;; the wrong guess.
9214 (message-narrow-to-head)
9215 (goto-char (point-min))
9216 (delete-matching-lines "^Path:\\|^From ")
9217 (widen)
9218 (if (setq egroup
9219 (gnus-group-read-ephemeral-group
9220 group `(nndoc ,group (nndoc-address ,(current-buffer))
9221 (nndoc-article-type guess))
9222 t nil t))
9223 (progn
9224 ;; Make all postings to this group go to the parent group.
9225 (nconc (gnus-info-params (gnus-get-info egroup))
9226 params)
9227 (push egroup groups))
9228 ;; Couldn't select this doc group.
9229 (gnus-error 3 "Article couldn't be entered"))))))
9230 ;; Now we have selected all the documents.
9231 (cond
9232 ((not groups)
9233 (error "None of the articles could be interpreted as documents"))
9234 ((gnus-group-read-ephemeral-group
9235 (setq vgroup (format
9236 "nnvirtual:%s-%s" gnus-newsgroup-name
9237 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9238 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9239 t
9240 (cons (current-buffer) 'summary)))
9241 (t
9242 (error "Couldn't select virtual nndoc group")))))
9243
9244 (defun gnus-summary-widget-forward (arg)
9245 "Move point to the next field or button in the article.
9246 With optional ARG, move across that many fields."
9247 (interactive "p")
9248 (gnus-summary-select-article)
9249 (gnus-configure-windows 'article)
9250 (select-window (gnus-get-buffer-window gnus-article-buffer))
9251 (widget-forward arg))
9252
9253 (defun gnus-summary-widget-backward (arg)
9254 "Move point to the previous field or button in the article.
9255 With optional ARG, move across that many fields."
9256 (interactive "p")
9257 (gnus-summary-select-article)
9258 (gnus-configure-windows 'article)
9259 (select-window (gnus-get-buffer-window gnus-article-buffer))
9260 (unless (widget-at (point))
9261 (goto-char (point-max)))
9262 (widget-backward arg))
9263
9264 (defun gnus-summary-isearch-article (&optional regexp-p)
9265 "Do incremental search forward on the current article.
9266 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9267 (interactive "P")
9268 (gnus-summary-select-article)
9269 (gnus-configure-windows 'article)
9270 (gnus-eval-in-buffer-window gnus-article-buffer
9271 (save-restriction
9272 (widen)
9273 (isearch-forward regexp-p))))
9274
9275 (defun gnus-summary-repeat-search-article-forward ()
9276 "Repeat the previous search forwards."
9277 (interactive)
9278 (unless gnus-last-search-regexp
9279 (error "No previous search"))
9280 (gnus-summary-search-article-forward gnus-last-search-regexp))
9281
9282 (defun gnus-summary-repeat-search-article-backward ()
9283 "Repeat the previous search backwards."
9284 (interactive)
9285 (unless gnus-last-search-regexp
9286 (error "No previous search"))
9287 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9288
9289 (defun gnus-summary-search-article-forward (regexp &optional backward)
9290 "Search for an article containing REGEXP forward.
9291 If BACKWARD, search backward instead."
9292 (interactive
9293 (list (read-string
9294 (format "Search article %s (regexp%s): "
9295 (if current-prefix-arg "backward" "forward")
9296 (if gnus-last-search-regexp
9297 (concat ", default " gnus-last-search-regexp)
9298 "")))
9299 current-prefix-arg))
9300 (if (string-equal regexp "")
9301 (setq regexp (or gnus-last-search-regexp ""))
9302 (setq gnus-last-search-regexp regexp)
9303 (setq gnus-article-before-search gnus-current-article))
9304 ;; Intentionally set gnus-last-article.
9305 (setq gnus-last-article gnus-article-before-search)
9306 (let ((gnus-last-article gnus-last-article))
9307 (if (gnus-summary-search-article regexp backward)
9308 (gnus-summary-show-thread)
9309 (signal 'search-failed (list regexp)))))
9310
9311 (defun gnus-summary-search-article-backward (regexp)
9312 "Search for an article containing REGEXP backward."
9313 (interactive
9314 (list (read-string
9315 (format "Search article backward (regexp%s): "
9316 (if gnus-last-search-regexp
9317 (concat ", default " gnus-last-search-regexp)
9318 "")))))
9319 (gnus-summary-search-article-forward regexp 'backward))
9320
9321 (defun gnus-summary-search-article (regexp &optional backward)
9322 "Search for an article containing REGEXP.
9323 Optional argument BACKWARD means do search for backward.
9324 `gnus-select-article-hook' is not called during the search."
9325 ;; We have to require this here to make sure that the following
9326 ;; dynamic binding isn't shadowed by autoloading.
9327 (require 'gnus-async)
9328 (require 'gnus-art)
9329 (let ((gnus-select-article-hook nil) ;Disable hook.
9330 (gnus-article-prepare-hook nil)
9331 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9332 (gnus-use-article-prefetch nil)
9333 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9334 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9335 (gnus-visual nil)
9336 (gnus-keep-backlog nil)
9337 (gnus-break-pages nil)
9338 (gnus-summary-display-arrow nil)
9339 (gnus-updated-mode-lines nil)
9340 (gnus-auto-center-summary nil)
9341 (sum (current-buffer))
9342 (gnus-display-mime-function nil)
9343 (found nil)
9344 point)
9345 (gnus-save-hidden-threads
9346 (gnus-summary-select-article)
9347 (set-buffer gnus-article-buffer)
9348 (goto-char (window-point (get-buffer-window (current-buffer))))
9349 (when backward
9350 (forward-line -1))
9351 (while (not found)
9352 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9353 (if (if backward
9354 (re-search-backward regexp nil t)
9355 (re-search-forward regexp nil t))
9356 ;; We found the regexp.
9357 (progn
9358 (setq found 'found)
9359 (beginning-of-line)
9360 (set-window-start
9361 (get-buffer-window (current-buffer))
9362 (point))
9363 (forward-line 1)
9364 (set-window-point
9365 (get-buffer-window (current-buffer))
9366 (point))
9367 (set-buffer sum)
9368 (setq point (point)))
9369 ;; We didn't find it, so we go to the next article.
9370 (set-buffer sum)
9371 (setq found 'not)
9372 (while (eq found 'not)
9373 (if (not (if backward (gnus-summary-find-prev)
9374 (gnus-summary-find-next)))
9375 ;; No more articles.
9376 (setq found t)
9377 ;; Select the next article and adjust point.
9378 (unless (gnus-summary-article-sparse-p
9379 (gnus-summary-article-number))
9380 (setq found nil)
9381 (gnus-summary-select-article)
9382 (set-buffer gnus-article-buffer)
9383 (widen)
9384 (goto-char (if backward (point-max) (point-min))))))))
9385 (gnus-message 7 ""))
9386 ;; Return whether we found the regexp.
9387 (when (eq found 'found)
9388 (goto-char point)
9389 (gnus-summary-show-thread)
9390 (gnus-summary-goto-subject gnus-current-article)
9391 (gnus-summary-position-point)
9392 t)))
9393
9394 (defun gnus-find-matching-articles (header regexp)
9395 "Return a list of all articles that match REGEXP on HEADER.
9396 This search includes all articles in the current group that Gnus has
9397 fetched headers for, whether they are displayed or not."
9398 (let ((articles nil)
9399 ;; Can't eta-reduce because it's a macro.
9400 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9401 (case-fold-search t))
9402 (dolist (header gnus-newsgroup-headers)
9403 (when (string-match regexp (funcall func header))
9404 (push (mail-header-number header) articles)))
9405 (nreverse articles)))
9406
9407 (defun gnus-summary-find-matching (header regexp &optional backward unread
9408 not-case-fold not-matching)
9409 "Return a list of all articles that match REGEXP on HEADER.
9410 The search stars on the current article and goes forwards unless
9411 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9412 If UNREAD is non-nil, only unread articles will
9413 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9414 in the comparisons. If NOT-MATCHING, return a list of all articles that
9415 not match REGEXP on HEADER."
9416 (let ((case-fold-search (not not-case-fold))
9417 articles d func)
9418 (if (consp header)
9419 (if (eq (car header) 'extra)
9420 (setq func
9421 `(lambda (h)
9422 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9423 "")))
9424 (error "%s is an invalid header" header))
9425 (unless (fboundp (intern (concat "mail-header-" header)))
9426 (error "%s is not a valid header" header))
9427 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9428 (dolist (d (if (eq backward 'all)
9429 gnus-newsgroup-data
9430 (gnus-data-find-list
9431 (gnus-summary-article-number)
9432 (gnus-data-list backward))))
9433 (when (and (or (not unread) ; We want all articles...
9434 (gnus-data-unread-p d)) ; Or just unreads.
9435 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9436 (if not-matching
9437 (not (string-match
9438 regexp
9439 (funcall func (gnus-data-header d))))
9440 (string-match regexp
9441 (funcall func (gnus-data-header d)))))
9442 (push (gnus-data-number d) articles))) ; Success!
9443 (nreverse articles)))
9444
9445 (defun gnus-summary-execute-command (header regexp command &optional backward)
9446 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9447 If HEADER is an empty string (or nil), the match is done on the entire
9448 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9449 (interactive
9450 (list (let ((completion-ignore-case t))
9451 (gnus-completing-read
9452 "Header name"
9453 (mapcar 'symbol-name
9454 (append
9455 '(Number Subject From Lines Date
9456 Message-ID Xref References Body)
9457 gnus-extra-headers))
9458 'require-match))
9459 (read-string "Regexp: ")
9460 (read-key-sequence "Command: ")
9461 current-prefix-arg))
9462 (when (equal header "Body")
9463 (setq header ""))
9464 ;; Hidden thread subtrees must be searched as well.
9465 (gnus-summary-show-all-threads)
9466 ;; We don't want to change current point nor window configuration.
9467 (save-excursion
9468 (save-window-excursion
9469 (let (gnus-visual
9470 gnus-treat-strip-trailing-blank-lines
9471 gnus-treat-strip-leading-blank-lines
9472 gnus-treat-strip-multiple-blank-lines
9473 gnus-treat-hide-boring-headers
9474 gnus-treat-fold-newsgroups
9475 gnus-article-prepare-hook)
9476 (gnus-message 6 "Executing %s..." (key-description command))
9477 ;; We'd like to execute COMMAND interactively so as to give arguments.
9478 (gnus-execute header regexp
9479 `(call-interactively ',(key-binding command))
9480 backward)
9481 (gnus-message 6 "Executing %s...done" (key-description command))))))
9482
9483 (defun gnus-summary-beginning-of-article ()
9484 "Scroll the article back to the beginning."
9485 (interactive)
9486 (gnus-summary-select-article)
9487 (gnus-configure-windows 'article)
9488 (gnus-eval-in-buffer-window gnus-article-buffer
9489 (widen)
9490 (goto-char (point-min))
9491 (when gnus-break-pages
9492 (gnus-narrow-to-page))))
9493
9494 (defun gnus-summary-end-of-article ()
9495 "Scroll to the end of the article."
9496 (interactive)
9497 (gnus-summary-select-article)
9498 (gnus-configure-windows 'article)
9499 (gnus-eval-in-buffer-window gnus-article-buffer
9500 (widen)
9501 (goto-char (point-max))
9502 (recenter -3)
9503 (when gnus-break-pages
9504 (gnus-narrow-to-page))))
9505
9506 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9507 "Truncate to LEN and quote all \"(\"'s in STRING."
9508 (gnus-replace-in-string (if (and len (> (length string) len))
9509 (substring string 0 len)
9510 string)
9511 "[()]" "\\\\\\&"))
9512
9513 (defun gnus-summary-print-article (&optional filename n)
9514 "Generate and print a PostScript image of the process-marked (mail) articles.
9515
9516 If used interactively, print the current article if none are
9517 process-marked. With prefix arg, prompt the user for the name of the
9518 file to save in.
9519
9520 When used from Lisp, accept two optional args FILENAME and N. N means
9521 to print the next N articles. If N is negative, print the N previous
9522 articles. If N is nil and articles have been marked with the process
9523 mark, print these instead.
9524
9525 If the optional first argument FILENAME is nil, send the image to the
9526 printer. If FILENAME is a string, save the PostScript image in a file with
9527 that name. If FILENAME is a number, prompt the user for the name of the file
9528 to save in."
9529 (interactive (list (ps-print-preprint current-prefix-arg)))
9530 (dolist (article (gnus-summary-work-articles n))
9531 (gnus-summary-select-article nil nil 'pseudo article)
9532 (gnus-eval-in-buffer-window gnus-article-buffer
9533 (gnus-print-buffer))
9534 (gnus-summary-remove-process-mark article))
9535 (ps-despool filename))
9536
9537 (defun gnus-print-buffer ()
9538 (let ((ps-left-header
9539 (list
9540 (concat "("
9541 (gnus-summary-print-truncate-and-quote
9542 (mail-header-subject gnus-current-headers)
9543 66) ")")
9544 (concat "("
9545 (gnus-summary-print-truncate-and-quote
9546 (mail-header-from gnus-current-headers)
9547 45) ")")))
9548 (ps-right-header
9549 (list
9550 "/pagenumberstring load"
9551 (concat "("
9552 (mail-header-date gnus-current-headers) ")"))))
9553 (gnus-run-hooks 'gnus-ps-print-hook)
9554 (save-excursion
9555 (if ps-print-color-p
9556 (ps-spool-buffer-with-faces)
9557 (ps-spool-buffer)))))
9558
9559 (defun gnus-summary-show-complete-article ()
9560 "Show a complete version of the current article.
9561 This is only useful if you're looking at a partial version of the
9562 article currently."
9563 (interactive)
9564 (let ((gnus-keep-backlog nil)
9565 (gnus-use-cache nil)
9566 (gnus-agent nil)
9567 (variable (intern
9568 (format "%s-fetch-partial-articles"
9569 (car (gnus-find-method-for-group
9570 gnus-newsgroup-name)))
9571 obarray))
9572 old-val)
9573 (unwind-protect
9574 (progn
9575 (setq old-val (symbol-value variable))
9576 (set variable nil)
9577 (gnus-flush-original-article-buffer)
9578 (gnus-summary-show-article))
9579 (set variable old-val))))
9580
9581 (defun gnus-summary-show-article (&optional arg)
9582 "Force redisplaying of the current article.
9583 If ARG (the prefix) is a number, show the article with the charset
9584 defined in `gnus-summary-show-article-charset-alist', or the charset
9585 input.
9586 If ARG (the prefix) is non-nil and not a number, show the article,
9587 but without running any of the article treatment functions
9588 article. Normally, the keystroke is `C-u g'. When using `C-u
9589 C-u g', show the raw article."
9590 (interactive "P")
9591 (cond
9592 ((numberp arg)
9593 (gnus-summary-show-article t)
9594 (let ((gnus-newsgroup-charset
9595 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9596 (mm-read-coding-system
9597 "View as charset: " ;; actually it is coding system.
9598 (with-current-buffer gnus-article-buffer
9599 (mm-detect-coding-region (point) (point-max))))))
9600 (gnus-newsgroup-ignored-charsets 'gnus-all))
9601 (gnus-summary-select-article nil 'force)
9602 (let ((deps gnus-newsgroup-dependencies)
9603 head header lines)
9604 (with-current-buffer gnus-original-article-buffer
9605 (save-restriction
9606 (message-narrow-to-head)
9607 (setq head (buffer-string))
9608 (goto-char (point-min))
9609 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9610 (goto-char (point-max))
9611 (widen)
9612 (setq lines (1- (count-lines (point) (point-max))))))
9613 (with-temp-buffer
9614 (insert (format "211 %d Article retrieved.\n"
9615 (cdr gnus-article-current)))
9616 (insert head)
9617 (if lines (insert (format "Lines: %d\n" lines)))
9618 (insert ".\n")
9619 (let ((nntp-server-buffer (current-buffer)))
9620 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9621 (gnus-data-set-header
9622 (gnus-data-find (cdr gnus-article-current))
9623 header)
9624 (gnus-summary-update-article-line
9625 (cdr gnus-article-current) header)
9626 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9627 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9628 ((not arg)
9629 ;; Select the article the normal way.
9630 (if (eq mm-text-html-renderer 'shr)
9631 (progn
9632 (require 'shr)
9633 (let ((shr-ignore-cache t))
9634 (gnus-summary-select-article nil 'force)))
9635 (gnus-summary-select-article nil 'force)))
9636 ((equal arg '(16))
9637 ;; C-u C-u g
9638 (let ((gnus-inhibit-article-treatments t))
9639 (gnus-summary-select-article nil 'force)))
9640 (t
9641 ;; We have to require this here to make sure that the following
9642 ;; dynamic binding isn't shadowed by autoloading.
9643 (require 'gnus-async)
9644 (require 'gnus-art)
9645 ;; Bind the article treatment functions to nil.
9646 (let ((gnus-have-all-headers t)
9647 gnus-article-prepare-hook
9648 gnus-article-decode-hook
9649 gnus-display-mime-function
9650 gnus-break-pages)
9651 ;; Destroy any MIME parts.
9652 (when (gnus-buffer-live-p gnus-article-buffer)
9653 (with-current-buffer gnus-article-buffer
9654 (gnus-article-stop-animations)
9655 (gnus-stop-downloads)
9656 (mm-destroy-parts gnus-article-mime-handles)
9657 ;; Set it to nil for safety reason.
9658 (setq gnus-article-mime-handle-alist nil)
9659 (setq gnus-article-mime-handles nil)))
9660 (gnus-summary-select-article nil 'force))))
9661 (gnus-summary-goto-subject gnus-current-article)
9662 (gnus-summary-position-point))
9663
9664 (defun gnus-summary-show-raw-article ()
9665 "Show the raw article without any article massaging functions being run."
9666 (interactive)
9667 (gnus-summary-show-article t))
9668
9669 (defun gnus-summary-verbose-headers (&optional arg)
9670 "Toggle permanent full header display.
9671 If ARG is a positive number, turn header display on.
9672 If ARG is a negative number, turn header display off."
9673 (interactive "P")
9674 (setq gnus-show-all-headers
9675 (cond ((or (not (numberp arg))
9676 (zerop arg))
9677 (not gnus-show-all-headers))
9678 ((natnump arg)
9679 t)))
9680 (gnus-summary-show-article))
9681
9682 (defun gnus-summary-toggle-header (&optional arg)
9683 "Show the headers if they are hidden, or hide them if they are shown.
9684 If ARG is a positive number, show the entire header.
9685 If ARG is a negative number, hide the unwanted header lines."
9686 (interactive "P")
9687 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9688 (get-buffer-window gnus-article-buffer t))))
9689 (with-current-buffer gnus-article-buffer
9690 (widen)
9691 (article-narrow-to-head)
9692 (let* ((inhibit-read-only t)
9693 (inhibit-point-motion-hooks t)
9694 (hidden (if (numberp arg)
9695 (>= arg 0)
9696 (or (not (looking-at "[^ \t\n]+:"))
9697 (gnus-article-hidden-text-p 'headers))))
9698 s e)
9699 (delete-region (point-min) (point-max))
9700 (with-current-buffer gnus-original-article-buffer
9701 (goto-char (setq s (point-min)))
9702 (setq e (if (search-forward "\n\n" nil t)
9703 (1- (point))
9704 (point-max))))
9705 (insert-buffer-substring gnus-original-article-buffer s e)
9706 (run-hooks 'gnus-article-decode-hook)
9707 (if hidden
9708 (let ((gnus-treat-hide-headers nil)
9709 (gnus-treat-hide-boring-headers nil))
9710 (gnus-delete-wash-type 'headers)
9711 (gnus-treat-article 'head))
9712 (gnus-treat-article 'head))
9713 (widen)
9714 (if window
9715 (set-window-start window (goto-char (point-min))))
9716 (if gnus-break-pages
9717 (gnus-narrow-to-page)
9718 (when (gnus-visual-p 'page-marker)
9719 (let ((inhibit-read-only t))
9720 (gnus-remove-text-with-property 'gnus-prev)
9721 (gnus-remove-text-with-property 'gnus-next))))
9722 (gnus-set-mode-line 'article)))))
9723
9724 (defun gnus-summary-show-all-headers ()
9725 "Make all header lines visible."
9726 (interactive)
9727 (gnus-summary-toggle-header 1))
9728
9729 (defun gnus-summary-caesar-message (&optional arg)
9730 "Caesar rotate the current article by 13.
9731 With a non-numerical prefix, also rotate headers. A numerical
9732 prefix specifies how many places to rotate each letter forward."
9733 (interactive "P")
9734 (gnus-summary-select-article)
9735 (let ((mail-header-separator ""))
9736 (gnus-eval-in-buffer-window gnus-article-buffer
9737 (save-restriction
9738 (widen)
9739 (let ((start (window-start))
9740 (inhibit-read-only t))
9741 (if (equal arg '(4))
9742 (message-caesar-buffer-body nil t)
9743 (message-caesar-buffer-body arg))
9744 (set-window-start (get-buffer-window (current-buffer)) start)))))
9745 ;; Create buttons and stuff...
9746 (gnus-treat-article nil))
9747
9748 (declare-function idna-to-unicode "ext:idna" (str))
9749
9750 (defun gnus-summary-idna-message (&optional arg)
9751 "Decode IDNA encoded domain names in the current articles.
9752 IDNA encoded domain names looks like `xn--bar'. If a string
9753 remain unencoded after running this function, it is likely an
9754 invalid IDNA string (`xn--bar' is invalid).
9755
9756 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9757 installed for this command to work."
9758 (interactive "P")
9759 (if (not (and (condition-case nil (require 'idna)
9760 (file-error))
9761 (mm-coding-system-p 'utf-8)
9762 (executable-find (symbol-value 'idna-program))))
9763 (gnus-message
9764 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9765 (gnus-summary-select-article)
9766 (let ((mail-header-separator ""))
9767 (gnus-eval-in-buffer-window gnus-article-buffer
9768 (save-restriction
9769 (widen)
9770 (let ((start (window-start))
9771 buffer-read-only)
9772 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9773 (replace-match (idna-to-unicode (match-string 1))))
9774 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9775
9776 (defun gnus-summary-morse-message (&optional arg)
9777 "Morse decode the current article."
9778 (interactive "P")
9779 (gnus-summary-select-article)
9780 (let ((mail-header-separator ""))
9781 (gnus-eval-in-buffer-window gnus-article-buffer
9782 (save-excursion
9783 (save-restriction
9784 (widen)
9785 (let ((pos (window-start))
9786 (inhibit-read-only t))
9787 (goto-char (point-min))
9788 (when (message-goto-body)
9789 (gnus-narrow-to-body))
9790 (goto-char (point-min))
9791 (while (search-forward "·" (point-max) t)
9792 (replace-match "."))
9793 (unmorse-region (point-min) (point-max))
9794 (widen)
9795 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9796
9797 (defun gnus-summary-stop-page-breaking ()
9798 "Stop page breaking in the current article."
9799 (interactive)
9800 (gnus-summary-select-article)
9801 (gnus-eval-in-buffer-window gnus-article-buffer
9802 (widen)
9803 (when (gnus-visual-p 'page-marker)
9804 (let ((inhibit-read-only t))
9805 (gnus-remove-text-with-property 'gnus-prev)
9806 (gnus-remove-text-with-property 'gnus-next))
9807 (setq gnus-page-broken nil))))
9808
9809 (defun gnus-summary-move-article (&optional n to-newsgroup
9810 select-method action)
9811 "Move the current article to a different newsgroup.
9812 If N is a positive number, move the N next articles.
9813 If N is a negative number, move the N previous articles.
9814 If N is nil and any articles have been marked with the process mark,
9815 move those articles instead.
9816 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9817 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9818 re-spool using this method.
9819
9820 When called interactively with TO-NEWSGROUP being nil, the value of
9821 the variable `gnus-move-split-methods' is used for finding a default
9822 for the target newsgroup.
9823
9824 For this function to work, both the current newsgroup and the
9825 newsgroup that you want to move to have to support the `request-move'
9826 and `request-accept' functions.
9827
9828 ACTION can be either `move' (the default), `crosspost' or `copy'."
9829 (interactive "P")
9830 (unless action
9831 (setq action 'move))
9832 ;; Check whether the source group supports the required functions.
9833 (cond ((and (eq action 'move)
9834 (not (gnus-check-backend-function
9835 'request-move-article gnus-newsgroup-name)))
9836 (error "The current group does not support article moving"))
9837 ((and (eq action 'crosspost)
9838 (not (gnus-check-backend-function
9839 'request-replace-article gnus-newsgroup-name)))
9840 (error "The current group does not support article editing")))
9841 (let ((articles (gnus-summary-work-articles n))
9842 (prefix (if (gnus-check-backend-function
9843 'request-move-article gnus-newsgroup-name)
9844 (funcall gnus-move-group-prefix-function
9845 gnus-newsgroup-name)
9846 ""))
9847 (names '((move "Move" "Moving")
9848 (copy "Copy" "Copying")
9849 (crosspost "Crosspost" "Crossposting")))
9850 (copy-buf (save-excursion
9851 (nnheader-set-temp-buffer " *copy article*")))
9852 art-group to-method new-xref article to-groups
9853 articles-to-update-marks encoded)
9854 (unless (assq action names)
9855 (error "Unknown action %s" action))
9856 ;; Read the newsgroup name.
9857 (when (and (not to-newsgroup)
9858 (not select-method))
9859 (if (and gnus-move-split-methods
9860 (not
9861 (and (memq gnus-current-article articles)
9862 (gnus-buffer-live-p gnus-original-article-buffer))))
9863 ;; When `gnus-move-split-methods' is non-nil, we have to
9864 ;; select an article to give `gnus-read-move-group-name' an
9865 ;; opportunity to suggest an appropriate default. However,
9866 ;; we needn't render or mark the article.
9867 (let ((gnus-display-mime-function nil)
9868 (gnus-article-prepare-hook nil)
9869 (gnus-mark-article-hook nil))
9870 (gnus-summary-select-article nil nil nil (car articles))))
9871 (setq to-newsgroup (gnus-read-move-group-name
9872 (cadr (assq action names))
9873 (symbol-value
9874 (intern (format "gnus-current-%s-group" action)))
9875 articles prefix)
9876 encoded to-newsgroup
9877 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9878 (set (intern (format "gnus-current-%s-group" action))
9879 (mm-decode-coding-string
9880 to-newsgroup
9881 (gnus-group-name-charset to-method to-newsgroup))))
9882 (unless to-method
9883 (setq to-method (or select-method
9884 (gnus-server-to-method
9885 (gnus-group-method to-newsgroup)))))
9886 (setq to-newsgroup
9887 (or encoded
9888 (and to-newsgroup
9889 (mm-encode-coding-string
9890 to-newsgroup
9891 (gnus-group-name-charset to-method to-newsgroup)))))
9892 ;; Check the method we are to move this article to...
9893 (unless (gnus-check-backend-function
9894 'request-accept-article (car to-method))
9895 (error "%s does not support article copying" (car to-method)))
9896 (unless (gnus-check-server to-method)
9897 (error "Can't open server %s" (car to-method)))
9898 (gnus-message 6 "%s to %s: %s..."
9899 (caddr (assq action names))
9900 (or (car select-method)
9901 (gnus-group-decoded-name to-newsgroup))
9902 articles)
9903 (while articles
9904 (setq article (pop articles))
9905 ;; Set any marks that may have changed in the summary buffer.
9906 (when gnus-preserve-marks
9907 (gnus-summary-push-marks-to-backend article))
9908 (setq
9909 art-group
9910 (cond
9911 ;; Move the article.
9912 ((eq action 'move)
9913 ;; Remove this article from future suppression.
9914 (gnus-dup-unsuppress-article article)
9915 (let* ((from-method (gnus-find-method-for-group
9916 gnus-newsgroup-name))
9917 (to-method (or select-method
9918 (gnus-find-method-for-group to-newsgroup)))
9919 (move-is-internal (gnus-server-equal from-method to-method)))
9920 (gnus-request-move-article
9921 article ; Article to move
9922 gnus-newsgroup-name ; From newsgroup
9923 (nth 1 (gnus-find-method-for-group
9924 gnus-newsgroup-name)) ; Server
9925 (list 'gnus-request-accept-article
9926 to-newsgroup (list 'quote select-method)
9927 (not articles) t) ; Accept form
9928 (not articles) ; Only save nov last time
9929 (and move-is-internal
9930 to-newsgroup ; Not respooling
9931 ; Is this move internal?
9932 (gnus-group-real-name to-newsgroup)))))
9933 ;; Copy the article.
9934 ((eq action 'copy)
9935 (with-current-buffer copy-buf
9936 (when (gnus-request-article-this-buffer article
9937 gnus-newsgroup-name)
9938 (save-restriction
9939 (nnheader-narrow-to-headers)
9940 (dolist (hdr gnus-copy-article-ignored-headers)
9941 (message-remove-header hdr t)))
9942 (gnus-request-accept-article
9943 to-newsgroup select-method (not articles) t))))
9944 ;; Crosspost the article.
9945 ((eq action 'crosspost)
9946 (let ((xref (message-tokenize-header
9947 (mail-header-xref (gnus-summary-article-header
9948 article))
9949 " ")))
9950 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9951 ":" (number-to-string article)))
9952 (unless xref
9953 (setq xref (list (system-name))))
9954 (setq new-xref
9955 (concat
9956 (mapconcat 'identity
9957 (delete "Xref:" (delete new-xref xref))
9958 " ")
9959 " " new-xref))
9960 (with-current-buffer copy-buf
9961 ;; First put the article in the destination group.
9962 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9963 (when (consp (setq art-group
9964 (gnus-request-accept-article
9965 to-newsgroup select-method (not articles)
9966 t)))
9967 (setq new-xref (concat new-xref " " (car art-group)
9968 ":"
9969 (number-to-string (cdr art-group))))
9970 ;; Now we have the new Xrefs header, so we insert
9971 ;; it and replace the new article.
9972 (nnheader-replace-header "Xref" new-xref)
9973 (gnus-request-replace-article
9974 (cdr art-group) to-newsgroup (current-buffer) t)
9975 art-group))))))
9976 (cond
9977 ((not art-group)
9978 (gnus-message 1 "Couldn't %s article %s: %s"
9979 (cadr (assq action names)) article
9980 (nnheader-get-report (car to-method))))
9981 ((eq art-group 'junk)
9982 (when (eq action 'move)
9983 (gnus-summary-mark-article article gnus-canceled-mark)
9984 (gnus-message 4 "Deleted article %s" article)
9985 ;; run the delete hook
9986 (run-hook-with-args 'gnus-summary-article-delete-hook
9987 action
9988 (gnus-data-header
9989 (assoc article (gnus-data-list nil)))
9990 gnus-newsgroup-name nil
9991 select-method)))
9992 (t
9993 (let* ((pto-group (gnus-group-prefixed-name
9994 (car art-group) to-method))
9995 (info (gnus-get-info pto-group))
9996 (to-group (gnus-info-group info))
9997 to-marks)
9998 ;; Update the group that has been moved to.
9999 (when (and info
10000 (memq action '(move copy)))
10001 (unless (member to-group to-groups)
10002 (push to-group to-groups))
10003
10004 (when (and (not (memq article gnus-newsgroup-unreads))
10005 (cdr art-group))
10006 (push 'read to-marks)
10007 (gnus-info-set-read
10008 info (gnus-add-to-range (gnus-info-read info)
10009 (list (cdr art-group)))))
10010
10011 ;; See whether the article is to be put in the cache.
10012 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10013 (marks (if expirable
10014 gnus-article-mark-lists
10015 (delete '(expirable . expire)
10016 (copy-sequence
10017 gnus-article-mark-lists))))
10018 (to-article (cdr art-group)))
10019
10020 ;; Enter the article into the cache in the new group,
10021 ;; if that is required.
10022 (when (and to-article
10023 gnus-use-cache)
10024 (gnus-cache-possibly-enter-article
10025 to-group to-article
10026 (memq article gnus-newsgroup-marked)
10027 (memq article gnus-newsgroup-dormant)
10028 (memq article gnus-newsgroup-unreads)))
10029
10030 (when (and gnus-preserve-marks
10031 to-article)
10032 ;; Copy any marks over to the new group.
10033 (when (and (equal to-group gnus-newsgroup-name)
10034 (not (memq article gnus-newsgroup-unreads)))
10035 ;; Mark this article as read in this group.
10036 (push (cons to-article gnus-read-mark)
10037 gnus-newsgroup-reads)
10038 ;; Increase the active status of this group.
10039 (setcdr (gnus-active to-group) to-article)
10040 (setcdr gnus-newsgroup-active to-article))
10041
10042 (while marks
10043 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10044 (when (memq article (symbol-value
10045 (intern (format "gnus-newsgroup-%s"
10046 (caar marks)))))
10047 (push (cdar marks) to-marks)
10048 ;; If the other group is the same as this group,
10049 ;; then we have to add the mark to the list.
10050 (when (equal to-group gnus-newsgroup-name)
10051 (set (intern (format "gnus-newsgroup-%s"
10052 (caar marks)))
10053 (cons to-article
10054 (symbol-value
10055 (intern (format "gnus-newsgroup-%s"
10056 (caar marks)))))))
10057 ;; Copy the marks to other group.
10058 (gnus-add-marked-articles
10059 to-group (cdar marks) (list to-article) info)))
10060 (setq marks (cdr marks)))
10061
10062 (when (and expirable
10063 gnus-mark-copied-or-moved-articles-as-expirable
10064 (not (memq 'expire to-marks)))
10065 ;; Mark this article as expirable.
10066 (push 'expire to-marks)
10067 (when (equal to-group gnus-newsgroup-name)
10068 (push to-article gnus-newsgroup-expirable))
10069 ;; Copy the expirable mark to other group.
10070 (gnus-add-marked-articles
10071 to-group 'expire (list to-article) info))
10072
10073 (when (and to-marks
10074 (gnus-method-option-p
10075 (gnus-find-method-for-group to-group)
10076 'server-marks))
10077 (gnus-request-set-mark
10078 to-group (list (list (list to-article) 'add to-marks)))))
10079
10080 (gnus-dribble-enter
10081 (concat "(gnus-group-set-info '"
10082 (gnus-prin1-to-string (gnus-get-info to-group))
10083 ")")
10084 (concat "^(gnus-group-set-info '(\""
10085 (regexp-quote to-group) "\""))))
10086
10087 ;; Update the Xref header in this article to point to
10088 ;; the new crossposted article we have just created.
10089 (when (eq action 'crosspost)
10090 (with-current-buffer copy-buf
10091 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10092 (nnheader-replace-header "Xref" new-xref)
10093 (gnus-request-replace-article
10094 article gnus-newsgroup-name (current-buffer) t)))
10095
10096 ;; run the move/copy/crosspost/respool hook
10097 (run-hook-with-args 'gnus-summary-article-move-hook
10098 action
10099 (gnus-data-header
10100 (assoc article (gnus-data-list nil)))
10101 gnus-newsgroup-name
10102 to-newsgroup
10103 select-method))
10104
10105 ;;;!!!Why is this necessary?
10106 (set-buffer gnus-summary-buffer)
10107
10108 (when (eq action 'move)
10109 (save-excursion
10110 (gnus-summary-goto-subject article)
10111 (gnus-summary-mark-article article gnus-canceled-mark)))))
10112 (push article articles-to-update-marks))
10113
10114 (save-excursion
10115 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10116 ;; Re-activate all groups that have been moved to.
10117 (with-current-buffer gnus-group-buffer
10118 (let ((gnus-group-marked to-groups))
10119 (gnus-group-get-new-news-this-group nil t)))
10120
10121 (gnus-kill-buffer copy-buf)
10122 (gnus-summary-position-point)
10123 (gnus-set-mode-line 'summary)))
10124
10125 (defun gnus-summary-push-marks-to-backend (article)
10126 (let ((set nil)
10127 (del nil)
10128 (marks gnus-article-mark-lists))
10129 (unless (memq article gnus-newsgroup-unreads)
10130 (push 'read set))
10131 (while marks
10132 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10133 (memq article (symbol-value
10134 (intern (format "gnus-newsgroup-%s"
10135 (caar marks))))))
10136 (push (cdar marks) set)
10137 (push (cdar marks) del))
10138 (pop marks))
10139 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10140 ((,article) del ,del)))))
10141
10142 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10143 "Copy the current article to some other group.
10144 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10145 When called interactively, if TO-NEWSGROUP is nil, use the value of
10146 the variable `gnus-move-split-methods' for finding a default target
10147 newsgroup.
10148 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10149 re-spool using this method."
10150 (interactive "P")
10151 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10152
10153 (defun gnus-summary-crosspost-article (&optional n)
10154 "Crosspost the current article to some other group."
10155 (interactive "P")
10156 (gnus-summary-move-article n nil nil 'crosspost))
10157
10158 (defcustom gnus-summary-respool-default-method nil
10159 "Default method type for respooling an article.
10160 If nil, use to the current newsgroup method."
10161 :type 'symbol
10162 :group 'gnus-summary-mail)
10163
10164 (defun gnus-summary-respool-article (&optional n method)
10165 "Respool the current article.
10166 The article will be squeezed through the mail spooling process again,
10167 which means that it will be put in some mail newsgroup or other
10168 depending on `nnmail-split-methods'.
10169 If N is a positive number, respool the N next articles.
10170 If N is a negative number, respool the N previous articles.
10171 If N is nil and any articles have been marked with the process mark,
10172 respool those articles instead.
10173
10174 Respooling can be done both from mail groups and \"real\" newsgroups.
10175 In the former case, the articles in question will be moved from the
10176 current group into whatever groups they are destined to. In the
10177 latter case, they will be copied into the relevant groups."
10178 (interactive
10179 (list current-prefix-arg
10180 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10181 (methname
10182 (symbol-name (or gnus-summary-respool-default-method
10183 (car (gnus-find-method-for-group
10184 gnus-newsgroup-name)))))
10185 (method
10186 (gnus-completing-read
10187 "Backend to use when respooling"
10188 methods t nil 'gnus-mail-method-history methname))
10189 ms)
10190 (cond
10191 ((zerop (length (setq ms (gnus-servers-using-backend
10192 (intern method)))))
10193 (list (intern method) ""))
10194 ((= 1 (length ms))
10195 (car ms))
10196 (t
10197 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10198 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10199 ms-alist))))))))
10200 (unless method
10201 (error "No method given for respooling"))
10202 (if (assoc (symbol-name
10203 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10204 (gnus-methods-using 'respool))
10205 (gnus-summary-move-article n nil method)
10206 (gnus-summary-copy-article n nil method)))
10207
10208 (defun gnus-summary-import-article (file &optional edit)
10209 "Import an arbitrary file into a mail newsgroup."
10210 (interactive "fImport file: \nP")
10211 (let ((group gnus-newsgroup-name)
10212 (now (current-time))
10213 atts lines group-art)
10214 (unless (gnus-check-backend-function 'request-accept-article group)
10215 (error "%s does not support article importing" group))
10216 (or (file-readable-p file)
10217 (not (file-regular-p file))
10218 (error "Can't read %s" file))
10219 (with-current-buffer (gnus-get-buffer-create " *import file*")
10220 (erase-buffer)
10221 (nnheader-insert-file-contents file)
10222 (goto-char (point-min))
10223 (if (nnheader-article-p)
10224 (save-restriction
10225 (goto-char (point-min))
10226 (search-forward "\n\n" nil t)
10227 (narrow-to-region (point-min) (1- (point)))
10228 (goto-char (point-min))
10229 (unless (re-search-forward "^date:" nil t)
10230 (goto-char (point-max))
10231 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10232 ;; This doesn't look like an article, so we fudge some headers.
10233 (setq atts (file-attributes file)
10234 lines (count-lines (point-min) (point-max)))
10235 (insert "From: " (read-string "From: ") "\n"
10236 "Subject: " (read-string "Subject: ") "\n"
10237 "Date: " (message-make-date (nth 5 atts)) "\n"
10238 "Message-ID: " (message-make-message-id) "\n"
10239 "Lines: " (int-to-string lines) "\n"
10240 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10241 (setq group-art (gnus-request-accept-article group nil t))
10242 (kill-buffer (current-buffer)))
10243 (setq gnus-newsgroup-active (gnus-activate-group group))
10244 (forward-line 1)
10245 (gnus-summary-goto-article (cdr group-art) nil t)
10246 (when edit
10247 (gnus-summary-edit-article))))
10248
10249 (defun gnus-summary-create-article ()
10250 "Create an article in a mail newsgroup."
10251 (interactive)
10252 (let ((group gnus-newsgroup-name)
10253 (now (current-time))
10254 group-art)
10255 (unless (gnus-check-backend-function 'request-accept-article group)
10256 (error "%s does not support article importing" group))
10257 (with-current-buffer (gnus-get-buffer-create " *import file*")
10258 (erase-buffer)
10259 (goto-char (point-min))
10260 ;; This doesn't look like an article, so we fudge some headers.
10261 (insert "From: " (read-string "From: ") "\n"
10262 "Subject: " (read-string "Subject: ") "\n"
10263 "Date: " (message-make-date now) "\n"
10264 "Message-ID: " (message-make-message-id) "\n")
10265 (setq group-art (gnus-request-accept-article group nil t))
10266 (kill-buffer (current-buffer)))
10267 (setq gnus-newsgroup-active (gnus-activate-group group))
10268 (forward-line 1)
10269 (gnus-summary-goto-article (cdr group-art) nil t)
10270 (gnus-summary-edit-article)))
10271
10272 (defun gnus-summary-article-posted-p ()
10273 "Say whether the current (mail) article is available from news as well.
10274 This will be the case if the article has both been mailed and posted."
10275 (interactive)
10276 (let ((id (mail-header-references (gnus-summary-article-header)))
10277 (gnus-override-method (car (gnus-refer-article-methods))))
10278 (if (gnus-request-head id "")
10279 (gnus-message 2 "The current message was found on %s"
10280 gnus-override-method)
10281 (gnus-message 2 "The current message couldn't be found on %s"
10282 gnus-override-method)
10283 nil)))
10284
10285 (defun gnus-summary-expire-articles (&optional now)
10286 "Expire all articles that are marked as expirable in the current group."
10287 (interactive)
10288 (when (and (not gnus-group-is-exiting-without-update-p)
10289 (gnus-check-backend-function
10290 'request-expire-articles gnus-newsgroup-name))
10291 ;; This backend supports expiry.
10292 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10293 (expirable (if total
10294 (progn
10295 ;; We need to update the info for
10296 ;; this group for `gnus-list-of-read-articles'
10297 ;; to give us the right answer.
10298 (gnus-run-hooks 'gnus-exit-group-hook)
10299 (gnus-summary-update-info)
10300 (gnus-list-of-read-articles gnus-newsgroup-name))
10301 (setq gnus-newsgroup-expirable
10302 (sort gnus-newsgroup-expirable '<))))
10303 (expiry-wait (if now 'immediate
10304 (gnus-group-find-parameter
10305 gnus-newsgroup-name 'expiry-wait)))
10306 (nnmail-expiry-target
10307 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10308 nnmail-expiry-target))
10309 es)
10310 (when expirable
10311 ;; There are expirable articles in this group, so we run them
10312 ;; through the expiry process.
10313 (gnus-message 6 "Expiring articles...")
10314 (when (gnus-check-group gnus-newsgroup-name)
10315 ;; The list of articles that weren't expired is returned.
10316 (save-excursion
10317 (if expiry-wait
10318 (let ((nnmail-expiry-wait-function nil)
10319 (nnmail-expiry-wait expiry-wait))
10320 (setq es (gnus-request-expire-articles
10321 expirable gnus-newsgroup-name)))
10322 (setq es (gnus-request-expire-articles
10323 expirable gnus-newsgroup-name)))
10324 (unless total
10325 (setq gnus-newsgroup-expirable es))
10326 ;; We go through the old list of expirable, and mark all
10327 ;; really expired articles as nonexistent.
10328 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10329 (let ((gnus-use-cache nil))
10330 (dolist (article expirable)
10331 (when (and (not (memq article es))
10332 (gnus-data-find article))
10333 (gnus-summary-mark-article article gnus-canceled-mark)
10334 (run-hook-with-args 'gnus-summary-article-expire-hook
10335 'delete
10336 (gnus-data-header
10337 (assoc article (gnus-data-list nil)))
10338 gnus-newsgroup-name
10339 nil
10340 nil)))))))
10341 (gnus-message 6 "Expiring articles...done")))))
10342
10343 (defun gnus-summary-expire-articles-now ()
10344 "Expunge all expirable articles in the current group.
10345 This means that *all* articles that are marked as expirable will be
10346 deleted forever, right now."
10347 (interactive)
10348 (or gnus-expert-user
10349 (gnus-yes-or-no-p
10350 "Are you really, really sure you want to delete all expirable messages? ")
10351 (error "Phew!"))
10352 (gnus-summary-expire-articles t))
10353
10354 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10355 (defun gnus-summary-delete-article (&optional n)
10356 "Delete the N next (mail) articles.
10357 This command actually deletes articles. This is not a marking
10358 command. The article will disappear forever from your life, never to
10359 return.
10360
10361 If N is negative, delete backwards.
10362 If N is nil and articles have been marked with the process mark,
10363 delete these instead.
10364
10365 If `gnus-novice-user' is non-nil you will be asked for
10366 confirmation before the articles are deleted."
10367 (interactive "P")
10368 (unless (gnus-check-backend-function 'request-expire-articles
10369 gnus-newsgroup-name)
10370 (error "The current newsgroup does not support article deletion"))
10371 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10372 (error "Couldn't open server"))
10373 ;; Compute the list of articles to delete.
10374 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10375 (nnmail-expiry-target 'delete)
10376 not-deleted)
10377 (if (and gnus-novice-user
10378 (not (gnus-yes-or-no-p
10379 (format "Do you really want to delete %s forever? "
10380 (if (> (length articles) 1)
10381 (format "these %s articles" (length articles))
10382 "this article")))))
10383 ()
10384 ;; Delete the articles.
10385 (setq not-deleted (gnus-request-expire-articles
10386 articles gnus-newsgroup-name 'force))
10387 (save-excursion
10388 (while articles
10389 (gnus-summary-remove-process-mark (car articles))
10390 ;; The backend might not have been able to delete the article
10391 ;; after all.
10392 (unless (memq (car articles) not-deleted)
10393 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10394 (let* ((article (car articles))
10395 (ghead (gnus-data-header
10396 (assoc article (gnus-data-list nil)))))
10397 (run-hook-with-args 'gnus-summary-article-delete-hook
10398 'delete ghead gnus-newsgroup-name nil
10399 nil)))
10400 (setq articles (cdr articles))))
10401 (when not-deleted
10402 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10403 (gnus-summary-position-point)
10404 (gnus-set-mode-line 'summary)
10405 not-deleted))
10406
10407 (defun gnus-summary-edit-article (&optional arg)
10408 "Edit the current article.
10409 This will have permanent effect only in mail groups.
10410 If ARG is nil, edit the decoded articles.
10411 If ARG is 1, edit the raw articles.
10412 If ARG is 2, edit the raw articles even in read-only groups.
10413 If ARG is 3, edit the articles with the current handles.
10414 Otherwise, allow editing of articles even in read-only
10415 groups."
10416 (interactive "P")
10417 (let (force raw current-handles)
10418 (cond
10419 ((null arg))
10420 ((eq arg 1)
10421 (setq raw t))
10422 ((eq arg 2)
10423 (setq raw t
10424 force t))
10425 ((eq arg 3)
10426 (setq current-handles
10427 (and (gnus-buffer-live-p gnus-article-buffer)
10428 (with-current-buffer gnus-article-buffer
10429 (prog1
10430 gnus-article-mime-handles
10431 (setq gnus-article-mime-handles nil))))))
10432 (t
10433 (setq force t)))
10434 (when (and raw (not force)
10435 (member gnus-newsgroup-name '("nndraft:delayed"
10436 "nndraft:drafts"
10437 "nndraft:queue")))
10438 (error "Can't edit the raw article in group %s"
10439 gnus-newsgroup-name))
10440 (with-current-buffer gnus-summary-buffer
10441 (let ((mail-parse-charset gnus-newsgroup-charset)
10442 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10443 (gnus-set-global-variables)
10444 (when (and (not force)
10445 (gnus-group-read-only-p))
10446 (error "The current newsgroup does not support article editing"))
10447 (gnus-summary-show-article t)
10448 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10449 (with-current-buffer gnus-article-buffer
10450 (mm-enable-multibyte)))
10451 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10452 (setq raw t))
10453 (gnus-article-edit-article
10454 (if raw 'ignore
10455 `(lambda ()
10456 (let ((mbl mml-buffer-list))
10457 (setq mml-buffer-list nil)
10458 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10459 (mime-to-mml ,'current-handles))
10460 (let ((mbl1 mml-buffer-list))
10461 (setq mml-buffer-list mbl)
10462 (set (make-local-variable 'mml-buffer-list) mbl1))
10463 (gnus-make-local-hook 'kill-buffer-hook)
10464 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10465 `(lambda (no-highlight)
10466 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10467 (message-options message-options)
10468 (message-options-set-recipient)
10469 (mail-parse-ignored-charsets
10470 ',gnus-newsgroup-ignored-charsets)
10471 (rfc2047-header-encoding-alist
10472 ',(let ((charset (gnus-group-name-charset
10473 (gnus-find-method-for-group
10474 gnus-newsgroup-name)
10475 gnus-newsgroup-name)))
10476 (append (list (cons "Newsgroups" charset)
10477 (cons "Followup-To" charset)
10478 (cons "Xref" charset))
10479 rfc2047-header-encoding-alist))))
10480 ,(if (not raw) '(progn
10481 (mml-to-mime)
10482 (mml-destroy-buffers)
10483 (remove-hook 'kill-buffer-hook
10484 'mml-destroy-buffers t)
10485 (kill-local-variable 'mml-buffer-list)))
10486 (gnus-summary-edit-article-done
10487 ,(or (mail-header-references gnus-current-headers) "")
10488 ,(gnus-group-read-only-p)
10489 ,gnus-summary-buffer no-highlight))))))))
10490
10491 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10492
10493 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10494 no-highlight)
10495 "Make edits to the current article permanent."
10496 (interactive)
10497 (save-excursion
10498 ;; The buffer restriction contains the entire article if it exists.
10499 (when (article-goto-body)
10500 (let ((lines (count-lines (point) (point-max)))
10501 (length (- (point-max) (point)))
10502 (case-fold-search t)
10503 (body (copy-marker (point))))
10504 (goto-char (point-min))
10505 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10506 (delete-region (match-beginning 1) (match-end 1))
10507 (insert (number-to-string length)))
10508 (goto-char (point-min))
10509 (when (re-search-forward
10510 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10511 (delete-region (match-beginning 1) (match-end 1))
10512 (insert (number-to-string length)))
10513 (goto-char (point-min))
10514 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10515 (delete-region (match-beginning 1) (match-end 1))
10516 (insert (number-to-string lines))))))
10517 ;; Replace the article.
10518 (let ((buf (current-buffer))
10519 (article (cdr gnus-article-current))
10520 replace-result)
10521 (with-temp-buffer
10522 (insert-buffer-substring buf)
10523 (if (and (not read-only)
10524 (not (setq replace-result
10525 (gnus-request-replace-article
10526 article (car gnus-article-current)
10527 (current-buffer) t))))
10528 (error "Couldn't replace article")
10529 ;; If we got a number back, then that's the new article number
10530 ;; for this article. Otherwise, the article number didn't change.
10531 (when (numberp replace-result)
10532 (with-current-buffer gnus-summary-buffer
10533 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10534 (gnus-summary-limit gnus-newsgroup-limit)
10535 (setq article replace-result)
10536 (gnus-summary-goto-subject article t)))
10537 ;; Update the summary buffer.
10538 (if (and references
10539 (equal (message-tokenize-header references " ")
10540 (message-tokenize-header
10541 (or (message-fetch-field "references") "") " ")))
10542 ;; We only have to update this line.
10543 (save-excursion
10544 (save-restriction
10545 (message-narrow-to-head)
10546 (let ((head (buffer-substring-no-properties
10547 (point-min) (point-max)))
10548 header)
10549 (with-temp-buffer
10550 (insert (format "211 %d Article retrieved.\n" article))
10551 (insert head)
10552 (insert ".\n")
10553 (let ((nntp-server-buffer (current-buffer)))
10554 (setq header (car (gnus-get-newsgroup-headers nil t))))
10555 (with-current-buffer gnus-summary-buffer
10556 (gnus-data-set-header (gnus-data-find article) header)
10557 (gnus-summary-update-article-line article header)
10558 (if (gnus-summary-goto-subject article nil t)
10559 (gnus-summary-update-secondary-mark article)))))))
10560 ;; Update threads.
10561 (set-buffer (or buffer gnus-summary-buffer))
10562 (gnus-summary-update-article article)
10563 (if (gnus-summary-goto-subject article nil t)
10564 (gnus-summary-update-secondary-mark article)))
10565 ;; Prettify the article buffer again.
10566 (unless no-highlight
10567 (with-current-buffer gnus-article-buffer
10568 ;;!!! Fix this -- article should be rehighlighted.
10569 ;;(gnus-run-hooks 'gnus-article-display-hook)
10570 (set-buffer gnus-original-article-buffer)
10571 (gnus-request-article
10572 article (car gnus-article-current) (current-buffer))))
10573 ;; Prettify the summary buffer line.
10574 (when (gnus-visual-p 'summary-highlight 'highlight)
10575 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10576
10577 (defun gnus-summary-edit-wash (key)
10578 "Perform editing command KEY in the article buffer."
10579 (interactive
10580 (list
10581 (progn
10582 (message "%s" (concat (this-command-keys) "- "))
10583 (read-char))))
10584 (message "")
10585 (gnus-summary-edit-article)
10586 (execute-kbd-macro (concat (this-command-keys) key))
10587 (gnus-article-edit-done))
10588
10589 ;;; Respooling
10590
10591 (defun gnus-summary-respool-query (&optional silent trace)
10592 "Query where the respool algorithm would put this article."
10593 (interactive)
10594 (let (gnus-mark-article-hook)
10595 (gnus-summary-select-article)
10596 (with-current-buffer gnus-original-article-buffer
10597 (let ((groups (nnmail-article-group 'identity trace)))
10598 (unless silent
10599 (if groups
10600 (message "This message would go to %s"
10601 (mapconcat 'car groups ", "))
10602 (message "This message would go to no groups"))
10603 groups)))))
10604
10605 (defun gnus-summary-respool-trace ()
10606 "Trace where the respool algorithm would put this article.
10607 Display a buffer showing all fancy splitting patterns which matched."
10608 (interactive)
10609 (gnus-summary-respool-query nil t))
10610
10611 ;; Summary marking commands.
10612
10613 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10614 "Mark articles which has the same subject as read, and then select the next.
10615 If UNMARK is positive, remove any kind of mark.
10616 If UNMARK is negative, tick articles."
10617 (interactive "P")
10618 (when unmark
10619 (setq unmark (prefix-numeric-value unmark)))
10620 (let ((count
10621 (gnus-summary-mark-same-subject
10622 (gnus-summary-article-subject) unmark)))
10623 ;; Select next unread article. If auto-select-same mode, should
10624 ;; select the first unread article.
10625 (gnus-summary-next-article t (and gnus-auto-select-same
10626 (gnus-summary-article-subject)))
10627 (gnus-message 7 "%d article%s marked as %s"
10628 count (if (= count 1) " is" "s are")
10629 (if unmark "unread" "read"))))
10630
10631 (defun gnus-summary-kill-same-subject (&optional unmark)
10632 "Mark articles which has the same subject as read.
10633 If UNMARK is positive, remove any kind of mark.
10634 If UNMARK is negative, tick articles."
10635 (interactive "P")
10636 (when unmark
10637 (setq unmark (prefix-numeric-value unmark)))
10638 (let ((count
10639 (gnus-summary-mark-same-subject
10640 (gnus-summary-article-subject) unmark)))
10641 ;; If marked as read, go to next unread subject.
10642 (when (null unmark)
10643 ;; Go to next unread subject.
10644 (gnus-summary-next-subject 1 t))
10645 (gnus-message 7 "%d articles are marked as %s"
10646 count (if unmark "unread" "read"))))
10647
10648 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10649 "Mark articles with same SUBJECT as read, and return marked number.
10650 If optional argument UNMARK is positive, remove any kinds of marks.
10651 If optional argument UNMARK is negative, mark articles as unread instead."
10652 (let ((count 1))
10653 (save-excursion
10654 (cond
10655 ((null unmark) ; Mark as read.
10656 (while (and
10657 (progn
10658 (gnus-summary-mark-article-as-read gnus-killed-mark)
10659 (gnus-summary-show-thread) t)
10660 (gnus-summary-find-subject subject))
10661 (setq count (1+ count))))
10662 ((> unmark 0) ; Tick.
10663 (while (and
10664 (progn
10665 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10666 (gnus-summary-show-thread) t)
10667 (gnus-summary-find-subject subject))
10668 (setq count (1+ count))))
10669 (t ; Mark as unread.
10670 (while (and
10671 (progn
10672 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10673 (gnus-summary-show-thread) t)
10674 (gnus-summary-find-subject subject))
10675 (setq count (1+ count)))))
10676 (gnus-set-mode-line 'summary)
10677 ;; Return the number of marked articles.
10678 count)))
10679
10680 (defun gnus-summary-mark-as-processable (n &optional unmark)
10681 "Set the process mark on the next N articles.
10682 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10683 the process mark instead. The difference between N and the actual
10684 number of articles marked is returned."
10685 (interactive "P")
10686 (if (and (null n) (gnus-region-active-p))
10687 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10688 (setq n (prefix-numeric-value n))
10689 (let ((backward (< n 0))
10690 (n (abs n)))
10691 (while (and
10692 (> n 0)
10693 (if unmark
10694 (gnus-summary-remove-process-mark
10695 (gnus-summary-article-number))
10696 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10697 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10698 (setq n (1- n)))
10699 (when (/= 0 n)
10700 (gnus-message 7 "No more articles"))
10701 (gnus-summary-recenter)
10702 (gnus-summary-position-point)
10703 n)))
10704
10705 (defun gnus-summary-unmark-as-processable (n)
10706 "Remove the process mark from the next N articles.
10707 If N is negative, unmark backward instead. The difference between N and
10708 the actual number of articles unmarked is returned."
10709 (interactive "P")
10710 (gnus-summary-mark-as-processable n t))
10711
10712 (defun gnus-summary-unmark-all-processable ()
10713 "Remove the process mark from all articles."
10714 (interactive)
10715 (save-excursion
10716 (while gnus-newsgroup-processable
10717 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10718 (gnus-summary-position-point))
10719
10720 (defun gnus-summary-add-mark (article type)
10721 "Mark ARTICLE with a mark of TYPE."
10722 (let ((vtype (car (assq type gnus-article-mark-lists)))
10723 var)
10724 (if (not vtype)
10725 (error "No such mark type: %s" type)
10726 (setq var (intern (format "gnus-newsgroup-%s" type)))
10727 (set var (cons article (symbol-value var)))
10728 (if (memq type '(processable cached replied forwarded recent saved))
10729 (gnus-summary-update-secondary-mark article)
10730 ;;; !!! This is bogus. We should find out what primary
10731 ;;; !!! mark we want to set.
10732 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10733
10734 (defun gnus-summary-mark-as-expirable (n)
10735 "Mark N articles forward as expirable.
10736 If N is negative, mark backward instead. The difference between N and
10737 the actual number of articles marked is returned."
10738 (interactive "p")
10739 (gnus-summary-mark-forward n gnus-expirable-mark))
10740
10741 (defun gnus-summary-mark-as-spam (n)
10742 "Mark N articles forward as spam.
10743 If N is negative, mark backward instead. The difference between N and
10744 the actual number of articles marked is returned."
10745 (interactive "p")
10746 (gnus-summary-mark-forward n gnus-spam-mark))
10747
10748 (defun gnus-summary-mark-article-as-replied (article)
10749 "Mark ARTICLE as replied to and update the summary line.
10750 ARTICLE can also be a list of articles."
10751 (interactive (list (gnus-summary-article-number)))
10752 (let ((articles (if (listp article) article (list article))))
10753 (dolist (article articles)
10754 (unless (numberp article)
10755 (error "%s is not a number" article))
10756 (push article gnus-newsgroup-replied)
10757 (let ((inhibit-read-only t))
10758 (when (gnus-summary-goto-subject article nil t)
10759 (gnus-summary-update-secondary-mark article))))))
10760
10761 (defun gnus-summary-mark-article-as-forwarded (article)
10762 "Mark ARTICLE as forwarded and update the summary line.
10763 ARTICLE can also be a list of articles."
10764 (let ((articles (if (listp article) article (list article))))
10765 (dolist (article articles)
10766 (push article gnus-newsgroup-forwarded)
10767 (let ((inhibit-read-only t))
10768 (when (gnus-summary-goto-subject article nil t)
10769 (gnus-summary-update-secondary-mark article))))))
10770
10771 (defun gnus-summary-set-bookmark (article)
10772 "Set a bookmark in current article."
10773 (interactive (list (gnus-summary-article-number)))
10774 (when (or (not (get-buffer gnus-article-buffer))
10775 (not gnus-current-article)
10776 (not gnus-article-current)
10777 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10778 (error "No current article selected"))
10779 ;; Remove old bookmark, if one exists.
10780 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10781 ;; Set the new bookmark, which is on the form
10782 ;; (article-number . line-number-in-body).
10783 (push
10784 (cons article
10785 (with-current-buffer gnus-article-buffer
10786 (count-lines
10787 (min (point)
10788 (save-excursion
10789 (article-goto-body)
10790 (point)))
10791 (point))))
10792 gnus-newsgroup-bookmarks)
10793 (gnus-message 6 "A bookmark has been added to the current article."))
10794
10795 (defun gnus-summary-remove-bookmark (article)
10796 "Remove the bookmark from the current article."
10797 (interactive (list (gnus-summary-article-number)))
10798 ;; Remove old bookmark, if one exists.
10799 (if (not (assq article gnus-newsgroup-bookmarks))
10800 (gnus-message 6 "No bookmark in current article.")
10801 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10802 (gnus-message 6 "Removed bookmark.")))
10803
10804 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10805 (defun gnus-summary-mark-as-dormant (n)
10806 "Mark N articles forward as dormant.
10807 If N is negative, mark backward instead. The difference between N and
10808 the actual number of articles marked is returned."
10809 (interactive "p")
10810 (gnus-summary-mark-forward n gnus-dormant-mark))
10811
10812 (defun gnus-summary-set-process-mark (article)
10813 "Set the process mark on ARTICLE and update the summary line."
10814 (setq gnus-newsgroup-processable
10815 (cons article
10816 (delq article gnus-newsgroup-processable)))
10817 (when (gnus-summary-goto-subject article)
10818 (gnus-summary-show-thread)
10819 (gnus-summary-goto-subject article)
10820 (gnus-summary-update-secondary-mark article)))
10821
10822 (defun gnus-summary-remove-process-mark (&rest articles)
10823 "Remove the process mark from ARTICLES and update the summary line."
10824 (dolist (article articles)
10825 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10826 (when (gnus-summary-goto-subject article)
10827 (gnus-summary-show-thread)
10828 (gnus-summary-goto-subject article)
10829 (gnus-summary-update-secondary-mark article)))
10830 t)
10831
10832 (defun gnus-summary-set-saved-mark (article)
10833 "Set the process mark on ARTICLE and update the summary line."
10834 (push article gnus-newsgroup-saved)
10835 (when (gnus-summary-goto-subject article)
10836 (gnus-summary-update-secondary-mark article)))
10837
10838 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10839 "Mark N articles as read forwards.
10840 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10841 The difference between N and the actual number of articles marked is
10842 returned.
10843 If NO-EXPIRE, auto-expiry will be inhibited."
10844 (interactive "p")
10845 (gnus-summary-show-thread)
10846 (let ((backward (< n 0))
10847 (gnus-summary-goto-unread
10848 (and gnus-summary-goto-unread
10849 (not (eq gnus-summary-goto-unread 'never))
10850 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10851 gnus-ticked-mark gnus-dormant-mark)))))
10852 (n (abs n))
10853 (mark (or mark gnus-del-mark)))
10854 (while (and (> n 0)
10855 (gnus-summary-mark-article nil mark no-expire)
10856 (zerop (gnus-summary-next-subject
10857 (if backward -1 1)
10858 (and gnus-summary-goto-unread
10859 (not (eq gnus-summary-goto-unread 'never)))
10860 t)))
10861 (setq n (1- n)))
10862 (when (/= 0 n)
10863 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10864 (gnus-summary-recenter)
10865 (gnus-summary-position-point)
10866 (gnus-set-mode-line 'summary)
10867 n))
10868
10869 (defun gnus-summary-mark-article-as-read (mark)
10870 "Mark the current article quickly as read with MARK."
10871 (let ((article (gnus-summary-article-number)))
10872 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10873 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10874 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10875 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10876 (push (cons article mark) gnus-newsgroup-reads)
10877 ;; Possibly remove from cache, if that is used.
10878 (when gnus-use-cache
10879 (gnus-cache-enter-remove-article article))
10880 ;; Allow the backend to change the mark.
10881 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10882 ;; Check for auto-expiry.
10883 (when (and gnus-newsgroup-auto-expire
10884 (memq mark gnus-auto-expirable-marks))
10885 (setq mark gnus-expirable-mark)
10886 ;; Let the backend know about the mark change.
10887 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10888 (push article gnus-newsgroup-expirable))
10889 ;; Set the mark in the buffer.
10890 (gnus-summary-update-mark mark 'unread)
10891 t))
10892
10893 (defun gnus-summary-mark-article-as-unread (mark)
10894 "Mark the current article quickly as unread with MARK."
10895 (let* ((article (gnus-summary-article-number))
10896 (old-mark (gnus-summary-article-mark article)))
10897 ;; Allow the backend to change the mark.
10898 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10899 (if (eq mark old-mark)
10900 t
10901 (if (<= article 0)
10902 (progn
10903 (gnus-error 1 "Can't mark negative article numbers")
10904 nil)
10905 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10906 (setq gnus-newsgroup-spam-marked
10907 (delq article gnus-newsgroup-spam-marked))
10908 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10909 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10910 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10911 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10912 (cond ((= mark gnus-ticked-mark)
10913 (setq gnus-newsgroup-marked
10914 (gnus-add-to-sorted-list gnus-newsgroup-marked
10915 article)))
10916 ((= mark gnus-spam-mark)
10917 (setq gnus-newsgroup-spam-marked
10918 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10919 article)))
10920 ((= mark gnus-dormant-mark)
10921 (setq gnus-newsgroup-dormant
10922 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10923 article)))
10924 (t
10925 (setq gnus-newsgroup-unreads
10926 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10927 article))))
10928 (gnus-alist-pull article gnus-newsgroup-reads)
10929
10930 ;; See whether the article is to be put in the cache.
10931 (and gnus-use-cache
10932 (vectorp (gnus-summary-article-header article))
10933 (save-excursion
10934 (gnus-cache-possibly-enter-article
10935 gnus-newsgroup-name article
10936 (= mark gnus-ticked-mark)
10937 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10938
10939 ;; Fix the mark.
10940 (gnus-summary-update-mark mark 'unread)
10941 t))))
10942
10943 (defun gnus-summary-mark-article (&optional article mark no-expire)
10944 "Mark ARTICLE with MARK. MARK can be any character.
10945 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10946 `??' (dormant) and `?E' (expirable).
10947 If MARK is nil, then the default character `?r' is used.
10948 If ARTICLE is nil, then the article on the current line will be
10949 marked.
10950 If NO-EXPIRE, auto-expiry will be inhibited."
10951 ;; The mark might be a string.
10952 (when (stringp mark)
10953 (setq mark (aref mark 0)))
10954 ;; If no mark is given, then we check auto-expiring.
10955 (when (null mark)
10956 (setq mark gnus-del-mark))
10957 (when (and (not no-expire)
10958 gnus-newsgroup-auto-expire
10959 (memq mark gnus-auto-expirable-marks))
10960 (setq mark gnus-expirable-mark))
10961 (let ((article (or article (gnus-summary-article-number)))
10962 (old-mark (gnus-summary-article-mark article)))
10963 ;; Allow the backend to change the mark.
10964 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10965 (if (eq mark old-mark)
10966 t
10967 (unless article
10968 (error "No article on current line"))
10969 (if (not (if (or (= mark gnus-unread-mark)
10970 (= mark gnus-ticked-mark)
10971 (= mark gnus-spam-mark)
10972 (= mark gnus-dormant-mark))
10973 (gnus-mark-article-as-unread article mark)
10974 (gnus-mark-article-as-read article mark)))
10975 t
10976 ;; See whether the article is to be put in the cache.
10977 (and gnus-use-cache
10978 (not (= mark gnus-canceled-mark))
10979 (vectorp (gnus-summary-article-header article))
10980 (save-excursion
10981 (gnus-cache-possibly-enter-article
10982 gnus-newsgroup-name article
10983 (= mark gnus-ticked-mark)
10984 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10985
10986 (when (gnus-summary-goto-subject article nil t)
10987 (let ((inhibit-read-only t))
10988 (gnus-summary-show-thread)
10989 ;; Fix the mark.
10990 (gnus-summary-update-mark mark 'unread)
10991 t))))))
10992
10993 (defun gnus-summary-update-secondary-mark (article)
10994 "Update the secondary (read, process, cache) mark."
10995 (gnus-summary-update-mark
10996 (cond ((memq article gnus-newsgroup-processable)
10997 gnus-process-mark)
10998 ((memq article gnus-newsgroup-cached)
10999 gnus-cached-mark)
11000 ((memq article gnus-newsgroup-replied)
11001 gnus-replied-mark)
11002 ((memq article gnus-newsgroup-forwarded)
11003 gnus-forwarded-mark)
11004 ((memq article gnus-newsgroup-saved)
11005 gnus-saved-mark)
11006 ((memq article gnus-newsgroup-unseen)
11007 gnus-unseen-mark)
11008 (t gnus-no-mark))
11009 'replied)
11010 (when (gnus-visual-p 'summary-highlight 'highlight)
11011 (gnus-summary-highlight-line)
11012 (gnus-run-hooks 'gnus-summary-update-hook))
11013 t)
11014
11015 (defun gnus-summary-update-download-mark (article)
11016 "Update the download mark."
11017 (gnus-summary-update-mark
11018 (cond ((memq article gnus-newsgroup-undownloaded)
11019 gnus-undownloaded-mark)
11020 (gnus-newsgroup-agentized
11021 gnus-downloaded-mark)
11022 (t
11023 gnus-no-mark))
11024 'download)
11025 (gnus-summary-update-line t)
11026 t)
11027
11028 (defun gnus-summary-update-mark (mark type)
11029 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11030 (inhibit-read-only t))
11031 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11032 (when forward
11033 (when (looking-at "\r")
11034 (incf forward))
11035 (when (<= (+ forward (point)) (point-max))
11036 ;; Go to the right position on the line.
11037 (goto-char (+ forward (point)))
11038 ;; Replace the old mark with the new mark.
11039 (let ((to-insert
11040 (mm-subst-char-in-string
11041 (char-after) mark
11042 (buffer-substring (point) (1+ (point))))))
11043 (delete-region (point) (1+ (point)))
11044 (insert to-insert))
11045 ;; Optionally update the marks by some user rule.
11046 (when (eq type 'unread)
11047 (gnus-data-set-mark
11048 (gnus-data-find (gnus-summary-article-number)) mark)
11049 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11050
11051 (defun gnus-mark-article-as-read (article &optional mark)
11052 "Enter ARTICLE in the pertinent lists and remove it from others."
11053 ;; Make the article expirable.
11054 (let ((mark (or mark gnus-del-mark)))
11055 (setq gnus-newsgroup-expirable
11056 (if (= mark gnus-expirable-mark)
11057 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11058 (delq article gnus-newsgroup-expirable)))
11059 ;; Remove from unread and marked lists.
11060 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11061 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11062 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11063 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11064 (push (cons article mark) gnus-newsgroup-reads)
11065 ;; Possibly remove from cache, if that is used.
11066 (when gnus-use-cache
11067 (gnus-cache-enter-remove-article article))
11068 t))
11069
11070 (defun gnus-mark-article-as-unread (article &optional mark)
11071 "Enter ARTICLE in the pertinent lists and remove it from others."
11072 (let ((mark (or mark gnus-ticked-mark)))
11073 (if (<= article 0)
11074 (progn
11075 (gnus-error 1 "Can't mark negative article numbers")
11076 nil)
11077 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11078 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11079 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11080 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11081 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11082
11083 ;; Unsuppress duplicates?
11084 (when gnus-suppress-duplicates
11085 (gnus-dup-unsuppress-article article))
11086
11087 (cond ((= mark gnus-ticked-mark)
11088 (setq gnus-newsgroup-marked
11089 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11090 ((= mark gnus-spam-mark)
11091 (setq gnus-newsgroup-spam-marked
11092 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11093 article)))
11094 ((= mark gnus-dormant-mark)
11095 (setq gnus-newsgroup-dormant
11096 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11097 (t
11098 (setq gnus-newsgroup-unreads
11099 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11100 (gnus-alist-pull article gnus-newsgroup-reads)
11101 t)))
11102
11103 (defun gnus-summary-tick-article-forward (n)
11104 "Tick N articles forwards.
11105 If N is negative, tick backwards instead.
11106 The difference between N and the number of articles ticked is returned."
11107 (interactive "p")
11108 (gnus-summary-mark-forward n gnus-ticked-mark))
11109
11110 (defun gnus-summary-tick-article-backward (n)
11111 "Tick N articles backwards.
11112 The difference between N and the number of articles ticked is returned."
11113 (interactive "p")
11114 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11115
11116 (defun gnus-summary-tick-article (&optional article clear-mark)
11117 "Mark current article as unread.
11118 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11119 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11120 (interactive)
11121 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11122 gnus-ticked-mark)))
11123
11124 (defun gnus-summary-mark-as-read-forward (n)
11125 "Mark N articles as read forwards.
11126 If N is negative, mark backwards instead.
11127 The difference between N and the actual number of articles marked is
11128 returned."
11129 (interactive "p")
11130 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11131
11132 (defun gnus-summary-mark-as-read-backward (n)
11133 "Mark the N articles as read backwards.
11134 The difference between N and the actual number of articles marked is
11135 returned."
11136 (interactive "p")
11137 (gnus-summary-mark-forward
11138 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11139
11140 (defun gnus-summary-mark-as-read (&optional article mark)
11141 "Mark current article as read.
11142 ARTICLE specifies the article to be marked as read.
11143 MARK specifies a string to be inserted at the beginning of the line."
11144 (gnus-summary-mark-article article mark))
11145
11146 (defun gnus-summary-clear-mark-forward (n)
11147 "Clear marks from N articles forward.
11148 If N is negative, clear backward instead.
11149 The difference between N and the number of marks cleared is returned."
11150 (interactive "p")
11151 (gnus-summary-mark-forward n gnus-unread-mark))
11152
11153 (defun gnus-summary-clear-mark-backward (n)
11154 "Clear marks from N articles backward.
11155 The difference between N and the number of marks cleared is returned."
11156 (interactive "p")
11157 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11158
11159 (defun gnus-summary-mark-unread-as-read ()
11160 "Intended to be used by `gnus-mark-article-hook'."
11161 (when (memq gnus-current-article gnus-newsgroup-unreads)
11162 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11163
11164 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11165 "Intended to be used by `gnus-mark-article-hook'."
11166 (let ((mark (gnus-summary-article-mark)))
11167 (when (or (gnus-unread-mark-p mark)
11168 (gnus-read-mark-p mark))
11169 (gnus-summary-mark-article gnus-current-article
11170 (or new-mark gnus-read-mark)))))
11171
11172 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11173 "Intended to be used by `gnus-mark-article-hook'."
11174 (let ((mark (gnus-summary-article-mark)))
11175 (when (or (gnus-unread-mark-p mark)
11176 (gnus-read-mark-p mark))
11177 (gnus-summary-mark-article (gnus-summary-article-number)
11178 (or new-mark gnus-read-mark)))))
11179
11180 (defun gnus-summary-mark-unread-as-ticked ()
11181 "Intended to be used by `gnus-mark-article-hook'."
11182 (when (memq gnus-current-article gnus-newsgroup-unreads)
11183 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11184
11185 (defun gnus-summary-mark-region-as-read (point mark all)
11186 "Mark all unread articles between point and mark as read.
11187 If given a prefix, mark all articles between point and mark as read,
11188 even ticked and dormant ones."
11189 (interactive "r\nP")
11190 (save-excursion
11191 (let (article)
11192 (goto-char point)
11193 (beginning-of-line)
11194 (while (and
11195 (< (point) mark)
11196 (progn
11197 (when (or all
11198 (memq (setq article (gnus-summary-article-number))
11199 gnus-newsgroup-unreads))
11200 (gnus-summary-mark-article article gnus-del-mark))
11201 t)
11202 (gnus-summary-find-next))))))
11203
11204 (defun gnus-summary-mark-below (score mark)
11205 "Mark articles with score less than SCORE with MARK."
11206 (interactive "P\ncMark: ")
11207 (setq score (if score
11208 (prefix-numeric-value score)
11209 (or gnus-summary-default-score 0)))
11210 (with-current-buffer gnus-summary-buffer
11211 (goto-char (point-min))
11212 (while
11213 (progn
11214 (and (< (gnus-summary-article-score) score)
11215 (gnus-summary-mark-article nil mark))
11216 (gnus-summary-find-next)))))
11217
11218 (defun gnus-summary-kill-below (&optional score)
11219 "Mark articles with score below SCORE as read."
11220 (interactive "P")
11221 (gnus-summary-mark-below score gnus-killed-mark))
11222
11223 (defun gnus-summary-clear-above (&optional score)
11224 "Clear all marks from articles with score above SCORE."
11225 (interactive "P")
11226 (gnus-summary-mark-above score gnus-unread-mark))
11227
11228 (defun gnus-summary-tick-above (&optional score)
11229 "Tick all articles with score above SCORE."
11230 (interactive "P")
11231 (gnus-summary-mark-above score gnus-ticked-mark))
11232
11233 (defun gnus-summary-mark-above (score mark)
11234 "Mark articles with score over SCORE with MARK."
11235 (interactive "P\ncMark: ")
11236 (setq score (if score
11237 (prefix-numeric-value score)
11238 (or gnus-summary-default-score 0)))
11239 (with-current-buffer gnus-summary-buffer
11240 (goto-char (point-min))
11241 (while (and (progn
11242 (when (> (gnus-summary-article-score) score)
11243 (gnus-summary-mark-article nil mark))
11244 t)
11245 (gnus-summary-find-next)))))
11246
11247 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11248 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11249 (defun gnus-summary-limit-include-expunged (&optional no-error)
11250 "Display all the hidden articles that were expunged for low scores."
11251 (interactive)
11252 (let ((inhibit-read-only t))
11253 (let ((scored gnus-newsgroup-scored)
11254 headers h)
11255 (while scored
11256 (unless (gnus-summary-article-header (caar scored))
11257 (and (setq h (gnus-number-to-header (caar scored)))
11258 (< (cdar scored) gnus-summary-expunge-below)
11259 (push h headers)))
11260 (setq scored (cdr scored)))
11261 (if (not headers)
11262 (when (not no-error)
11263 (error "No expunged articles hidden"))
11264 (goto-char (point-min))
11265 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11266 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11267 (dolist (x headers)
11268 (push (mail-header-number x) gnus-newsgroup-limit))
11269 (gnus-summary-prepare-unthreaded (nreverse headers))
11270 (goto-char (point-min))
11271 (gnus-summary-position-point)
11272 t))))
11273
11274 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11275 "Mark all unread articles in this newsgroup as read.
11276 If prefix argument ALL is non-nil, ticked and dormant articles will
11277 also be marked as read.
11278 If QUIETLY is non-nil, no questions will be asked.
11279
11280 If TO-HERE is non-nil, it should be a point in the buffer. All
11281 articles before (after, if REVERSE is set) this point will be marked
11282 as read.
11283
11284 Note that this function will only catch up the unread article
11285 in the current summary buffer limitation.
11286
11287 The number of articles marked as read is returned."
11288 (interactive "P")
11289 (prog1
11290 (save-excursion
11291 (when (or quietly
11292 (not gnus-interactive-catchup) ;Without confirmation?
11293 gnus-expert-user
11294 (gnus-y-or-n-p
11295 (if all
11296 "Mark absolutely all articles as read? "
11297 "Mark all unread articles as read? ")))
11298 (if (and not-mark
11299 (not gnus-newsgroup-adaptive)
11300 (not gnus-newsgroup-auto-expire)
11301 (not gnus-suppress-duplicates)
11302 (or (not gnus-use-cache)
11303 (eq gnus-use-cache 'passive)))
11304 (progn
11305 (when all
11306 (setq gnus-newsgroup-marked nil
11307 gnus-newsgroup-spam-marked nil
11308 gnus-newsgroup-dormant nil))
11309 (setq gnus-newsgroup-unreads
11310 (gnus-sorted-nunion
11311 (gnus-sorted-intersection gnus-newsgroup-unreads
11312 gnus-newsgroup-downloadable)
11313 (gnus-sorted-difference gnus-newsgroup-unfetched
11314 gnus-newsgroup-cached))))
11315 ;; We actually mark all articles as canceled, which we
11316 ;; have to do when using auto-expiry or adaptive scoring.
11317 (gnus-summary-show-all-threads)
11318 (if (and to-here reverse)
11319 (progn
11320 (goto-char to-here)
11321 (gnus-summary-mark-current-read-and-unread-as-read
11322 gnus-catchup-mark)
11323 (while (gnus-summary-find-next (not all))
11324 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11325 (when (gnus-summary-first-subject (not all))
11326 (while (and
11327 (if to-here (< (point) to-here) t)
11328 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11329 (gnus-summary-find-next (not all))))))
11330 (gnus-set-mode-line 'summary))
11331 t))
11332 (gnus-summary-position-point)))
11333
11334 (defun gnus-summary-catchup-to-here (&optional all)
11335 "Mark all unticked articles before the current one as read.
11336 If ALL is non-nil, also mark ticked and dormant articles as read."
11337 (interactive "P")
11338 (save-excursion
11339 (gnus-save-hidden-threads
11340 (let ((beg (point)))
11341 ;; We check that there are unread articles.
11342 (when (or all (gnus-summary-find-prev))
11343 (gnus-summary-catchup all t beg)))))
11344 (gnus-summary-position-point))
11345
11346 (defun gnus-summary-catchup-from-here (&optional all)
11347 "Mark all unticked articles after (and including) the current one as read.
11348 If ALL is non-nil, also mark ticked and dormant articles as read."
11349 (interactive "P")
11350 (save-excursion
11351 (gnus-save-hidden-threads
11352 (let ((beg (point)))
11353 ;; We check that there are unread articles.
11354 (when (or all (gnus-summary-find-next))
11355 (gnus-summary-catchup all t beg nil t)))))
11356 (gnus-summary-position-point))
11357
11358 (defun gnus-summary-catchup-all (&optional quietly)
11359 "Mark all articles in this newsgroup as read.
11360 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11361 instead, which marks only unread articles as read."
11362 (interactive "P")
11363 (gnus-summary-catchup t quietly))
11364
11365 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11366 "Mark all unread articles in this group as read, then exit.
11367 If prefix argument ALL is non-nil, all articles are marked as read.
11368 If QUIETLY is non-nil, no questions will be asked."
11369 (interactive "P")
11370 (when (gnus-summary-catchup all quietly nil 'fast)
11371 ;; Select next newsgroup or exit.
11372 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11373 (eq gnus-auto-select-next 'quietly))
11374 (gnus-summary-next-group nil)
11375 (gnus-summary-exit))))
11376
11377 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11378 "Mark all articles in this newsgroup as read, and then exit.
11379 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11380 instead, which marks only unread articles as read."
11381 (interactive "P")
11382 (gnus-summary-catchup-and-exit t quietly))
11383
11384 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11385 "Mark all articles in this group as read and select the next group.
11386 If given a prefix, mark all articles, unread as well as ticked, as
11387 read."
11388 (interactive "P")
11389 (save-excursion
11390 (gnus-summary-catchup all))
11391 (gnus-summary-next-group))
11392
11393 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11394 "Mark all articles in this group as read and select the previous group.
11395 If given a prefix, mark all articles, unread as well as ticked, as
11396 read."
11397 (interactive "P")
11398 (save-excursion
11399 (gnus-summary-catchup all))
11400 (gnus-summary-next-group nil nil t))
11401
11402 ;;;
11403 ;;; with article
11404 ;;;
11405
11406 (defmacro gnus-with-article (article &rest forms)
11407 "Select ARTICLE and perform FORMS in the original article buffer.
11408 Then replace the article with the result."
11409 `(progn
11410 ;; We don't want the article to be marked as read.
11411 (let (gnus-mark-article-hook)
11412 (gnus-summary-select-article t t nil ,article))
11413 (set-buffer gnus-original-article-buffer)
11414 ,@forms
11415 (if (not (gnus-check-backend-function
11416 'request-replace-article (car gnus-article-current)))
11417 (gnus-message 5 "Read-only group; not replacing")
11418 (unless (gnus-request-replace-article
11419 ,article (car gnus-article-current)
11420 (current-buffer) t)
11421 (error "Couldn't replace article")))
11422 ;; The cache and backlog have to be flushed somewhat.
11423 (when gnus-keep-backlog
11424 (gnus-backlog-remove-article
11425 (car gnus-article-current) (cdr gnus-article-current)))
11426 (when gnus-use-cache
11427 (gnus-cache-update-article
11428 (car gnus-article-current) (cdr gnus-article-current)))))
11429
11430 (put 'gnus-with-article 'lisp-indent-function 1)
11431 (put 'gnus-with-article 'edebug-form-spec '(form body))
11432
11433 ;; Thread-based commands.
11434
11435 (defun gnus-summary-articles-in-thread (&optional article)
11436 "Return a list of all articles in the current thread.
11437 If ARTICLE is non-nil, return all articles in the thread that starts
11438 with that article."
11439 (let* ((article (or article (gnus-summary-article-number)))
11440 (data (gnus-data-find-list article))
11441 (top-level (gnus-data-level (car data)))
11442 (top-subject
11443 (cond ((null gnus-thread-operation-ignore-subject)
11444 (gnus-simplify-subject-re
11445 (mail-header-subject (gnus-data-header (car data)))))
11446 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11447 (gnus-simplify-subject-fuzzy
11448 (mail-header-subject (gnus-data-header (car data)))))
11449 (t nil)))
11450 (end-point (save-excursion
11451 (goto-char (gnus-data-pos (car data)))
11452 (if (gnus-summary-go-to-next-thread)
11453 (point) (point-max))))
11454 articles)
11455 (while (and data
11456 (< (gnus-data-pos (car data)) end-point))
11457 (when (or (not top-subject)
11458 (string= top-subject
11459 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11460 (gnus-simplify-subject-fuzzy
11461 (mail-header-subject
11462 (gnus-data-header (car data))))
11463 (gnus-simplify-subject-re
11464 (mail-header-subject
11465 (gnus-data-header (car data)))))))
11466 (push (gnus-data-number (car data)) articles))
11467 (unless (and (setq data (cdr data))
11468 (> (gnus-data-level (car data)) top-level))
11469 (setq data nil)))
11470 ;; Return the list of articles.
11471 (nreverse articles)))
11472
11473 (defun gnus-summary-rethread-current ()
11474 "Rethread the thread the current article is part of."
11475 (interactive)
11476 (let* ((gnus-show-threads t)
11477 (article (gnus-summary-article-number))
11478 (id (mail-header-id (gnus-summary-article-header)))
11479 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11480 (unless id
11481 (error "No article on the current line"))
11482 (gnus-rebuild-thread id)
11483 (gnus-summary-goto-subject article)))
11484
11485 (defun gnus-summary-reparent-thread ()
11486 "Make the current article child of the marked (or previous) article.
11487
11488 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11489 is non-nil or the Subject: of both articles are the same."
11490 (interactive)
11491 (unless (not (gnus-group-read-only-p))
11492 (error "The current newsgroup does not support article editing"))
11493 (unless (<= (length gnus-newsgroup-processable) 1)
11494 (error "No more than one article may be marked"))
11495 (let ((child (gnus-summary-article-number))
11496 ;; First grab the marked article, otherwise one line up.
11497 (parent (if (not (null gnus-newsgroup-processable))
11498 (car gnus-newsgroup-processable)
11499 (save-excursion
11500 (if (eq (forward-line -1) 0)
11501 (gnus-summary-article-number)
11502 (error "Beginning of summary buffer"))))))
11503 (gnus-summary-reparent-children parent (list child))))
11504
11505 (defun gnus-summary-reparent-children (parent children)
11506 "Make PARENT the parent of CHILDREN.
11507 When called interactively, PARENT is the current article and CHILDREN
11508 are the process-marked articles."
11509 (interactive
11510 (list (gnus-summary-article-number)
11511 (gnus-summary-work-articles nil)))
11512 (dolist (child children)
11513 (save-window-excursion
11514 (let ((gnus-article-buffer " *reparent*"))
11515 (unless (not (eq parent child))
11516 (error "An article may not be self-referential"))
11517 (let ((message-id (mail-header-id
11518 (gnus-summary-article-header parent))))
11519 (unless (and message-id (not (equal message-id "")))
11520 (error "No message-id in desired parent"))
11521 (gnus-with-article child
11522 (save-restriction
11523 (goto-char (point-min))
11524 (message-narrow-to-head)
11525 (if (re-search-forward "^References: " nil t)
11526 (progn
11527 (re-search-forward "^[^ \t]" nil t)
11528 (forward-line -1)
11529 (end-of-line)
11530 (insert " " message-id))
11531 (insert "References: " message-id "\n"))))
11532 (set-buffer gnus-summary-buffer)
11533 (gnus-summary-unmark-all-processable)
11534 (gnus-summary-update-article child)
11535 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11536 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11537 (gnus-summary-rethread-current)
11538 (gnus-message 3 "Article %d is now the child of article %d"
11539 child parent))))))
11540
11541 (defun gnus-summary-toggle-threads (&optional arg)
11542 "Toggle showing conversation threads.
11543 If ARG is positive number, turn showing conversation threads on."
11544 (interactive "P")
11545 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11546 (setq gnus-show-threads
11547 (if (null arg) (not gnus-show-threads)
11548 (> (prefix-numeric-value arg) 0)))
11549 (gnus-summary-prepare)
11550 (gnus-summary-goto-subject current)
11551 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11552 (gnus-summary-position-point)))
11553
11554 (eval-and-compile
11555 (if (fboundp 'remove-overlays)
11556 (defalias 'gnus-remove-overlays 'remove-overlays)
11557 (defun gnus-remove-overlays (beg end name val)
11558 "Clear BEG and END of overlays whose property NAME has value VAL.
11559 For compatibility with XEmacs."
11560 (dolist (ov (gnus-overlays-in beg end))
11561 (when (eq (gnus-overlay-get ov name) val)
11562 (gnus-delete-overlay ov))))))
11563
11564 (defun gnus-summary-show-all-threads ()
11565 "Show all threads."
11566 (interactive)
11567 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11568 (gnus-summary-position-point))
11569
11570 (defsubst gnus-summary--inv (p)
11571 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11572
11573 (defun gnus-summary-show-thread ()
11574 "Show thread subtrees.
11575 Returns nil if no thread was there to be shown."
11576 (interactive)
11577 (let* ((orig (point))
11578 (end (point-at-eol))
11579 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11580 ;; Leave point at bol
11581 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11582 (eoi (when end
11583 (if (fboundp 'next-single-char-property-change)
11584 ;; Note: XEmacs version of n-s-c-p-c may return nil
11585 (or (next-single-char-property-change end 'invisible)
11586 (point-max))
11587 (while (progn
11588 (end-of-line 2)
11589 (and (not (eobp))
11590 (eq (get-char-property (point) 'invisible)
11591 'gnus-sum))))
11592 (point)))))
11593 (when eoi
11594 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11595 (goto-char orig)
11596 (gnus-summary-position-point)
11597 eoi)))
11598
11599 (defun gnus-summary-maybe-hide-threads ()
11600 "If requested, hide the threads that should be hidden."
11601 (when (and gnus-show-threads
11602 gnus-thread-hide-subtree)
11603 (gnus-summary-hide-all-threads
11604 (if (or (consp gnus-thread-hide-subtree)
11605 (functionp gnus-thread-hide-subtree))
11606 (gnus-make-predicate gnus-thread-hide-subtree)
11607 nil))))
11608
11609 ;;; Hiding predicates.
11610
11611 (defun gnus-article-unread-p (header)
11612 (memq (mail-header-number header) gnus-newsgroup-unreads))
11613
11614 (defun gnus-article-unseen-p (header)
11615 (memq (mail-header-number header) gnus-newsgroup-unseen))
11616
11617 (defun gnus-map-articles (predicate articles)
11618 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11619 (apply 'gnus-or (mapcar predicate
11620 (mapcar (lambda (number)
11621 (gnus-summary-article-header number))
11622 articles))))
11623
11624 (defun gnus-summary-hide-all-threads (&optional predicate)
11625 "Hide all thread subtrees.
11626 If PREDICATE is supplied, threads that satisfy this predicate
11627 will not be hidden."
11628 (interactive)
11629 (save-excursion
11630 (goto-char (point-min))
11631 (let ((end nil)
11632 (count 0))
11633 (while (not end)
11634 (incf count)
11635 (when (zerop (mod count 1000))
11636 (message "Hiding all threads... %d" count))
11637 (when (or (not predicate)
11638 (gnus-map-articles
11639 predicate (gnus-summary-article-children)))
11640 (gnus-summary-hide-thread))
11641 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11642 (gnus-summary-position-point))
11643
11644 (defun gnus-summary-hide-thread ()
11645 "Hide thread subtrees.
11646 If PREDICATE is supplied, threads that satisfy this predicate
11647 will not be hidden.
11648 Returns nil if no threads were there to be hidden."
11649 (interactive)
11650 (beginning-of-line)
11651 (let ((start (point))
11652 (starteol (line-end-position))
11653 (article (gnus-summary-article-number)))
11654 ;; Go forward until either the buffer ends or the subthread ends.
11655 (when (and (not (eobp))
11656 (or (zerop (gnus-summary-next-thread 1 t))
11657 (goto-char (point-max))))
11658 (if (and (> (point) start)
11659 ;; FIXME: this should actually search for a non-invisible \n.
11660 (search-backward "\n" start t))
11661 (progn
11662 (when (> (point) starteol)
11663 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11664 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11665 (gnus-overlay-put ol 'invisible 'gnus-sum)
11666 (gnus-overlay-put ol 'evaporate t)))
11667 (gnus-summary-goto-subject article)
11668 (when (> start (point))
11669 (message "Hiding the thread moved us backwards, aborting!")
11670 (goto-char (point-max))))
11671 (goto-char start)
11672 nil))))
11673
11674 (defun gnus-summary-go-to-next-thread (&optional previous)
11675 "Go to the same level (or less) next thread.
11676 If PREVIOUS is non-nil, go to previous thread instead.
11677 Return the article number moved to, or nil if moving was impossible."
11678 (let ((level (gnus-summary-thread-level))
11679 (way (if previous -1 1))
11680 (beg (point)))
11681 (forward-line way)
11682 (while (and (not (eobp))
11683 (< level (gnus-summary-thread-level)))
11684 (forward-line way))
11685 (if (eobp)
11686 (progn
11687 (goto-char beg)
11688 nil)
11689 (setq beg (point))
11690 (prog1
11691 (gnus-summary-article-number)
11692 (goto-char beg)))))
11693
11694 (defun gnus-summary-next-thread (n &optional silent)
11695 "Go to the same level next N'th thread.
11696 If N is negative, search backward instead.
11697 Returns the difference between N and the number of skips actually
11698 done.
11699
11700 If SILENT, don't output messages."
11701 (interactive "p")
11702 (let ((backward (< n 0))
11703 (n (abs n)))
11704 (while (and (> n 0)
11705 (gnus-summary-go-to-next-thread backward))
11706 (decf n))
11707 (unless silent
11708 (gnus-summary-position-point))
11709 (when (and (not silent) (/= 0 n))
11710 (gnus-message 7 "No more threads"))
11711 n))
11712
11713 (defun gnus-summary-prev-thread (n)
11714 "Go to the same level previous N'th thread.
11715 Returns the difference between N and the number of skips actually
11716 done."
11717 (interactive "p")
11718 (gnus-summary-next-thread (- n)))
11719
11720 (defun gnus-summary-go-down-thread ()
11721 "Go down one level in the current thread."
11722 (let ((children (gnus-summary-article-children)))
11723 (when children
11724 (gnus-summary-goto-subject (car children)))))
11725
11726 (defun gnus-summary-go-up-thread ()
11727 "Go up one level in the current thread."
11728 (let ((parent (gnus-summary-article-parent)))
11729 (when parent
11730 (gnus-summary-goto-subject parent))))
11731
11732 (defun gnus-summary-down-thread (n)
11733 "Go down thread N steps.
11734 If N is negative, go up instead.
11735 Returns the difference between N and how many steps down that were
11736 taken."
11737 (interactive "p")
11738 (let ((up (< n 0))
11739 (n (abs n)))
11740 (while (and (> n 0)
11741 (if up (gnus-summary-go-up-thread)
11742 (gnus-summary-go-down-thread)))
11743 (setq n (1- n)))
11744 (gnus-summary-position-point)
11745 (when (/= 0 n)
11746 (gnus-message 7 "Can't go further"))
11747 n))
11748
11749 (defun gnus-summary-up-thread (n)
11750 "Go up thread N steps.
11751 If N is negative, go down instead.
11752 Returns the difference between N and how many steps down that were
11753 taken."
11754 (interactive "p")
11755 (gnus-summary-down-thread (- n)))
11756
11757 (defun gnus-summary-top-thread ()
11758 "Go to the top of the thread."
11759 (interactive)
11760 (while (gnus-summary-go-up-thread))
11761 (gnus-summary-article-number))
11762
11763 (defun gnus-summary-expire-thread ()
11764 "Mark articles under current thread as expired."
11765 (interactive)
11766 (gnus-summary-kill-thread 0))
11767
11768 (defun gnus-summary-kill-thread (&optional unmark)
11769 "Mark articles under current thread as read.
11770 If the prefix argument is positive, remove any kinds of marks.
11771 If the prefix argument is zero, mark thread as expired.
11772 If the prefix argument is negative, tick articles instead."
11773 (interactive "P")
11774 (when unmark
11775 (setq unmark (prefix-numeric-value unmark)))
11776 (let ((articles (gnus-summary-articles-in-thread))
11777 (hide (or (null unmark) (= unmark 0))))
11778 (save-excursion
11779 ;; Expand the thread.
11780 (gnus-summary-show-thread)
11781 ;; Mark all the articles.
11782 (while articles
11783 (gnus-summary-goto-subject (car articles))
11784 (cond ((null unmark)
11785 (gnus-summary-mark-article-as-read gnus-killed-mark))
11786 ((> unmark 0)
11787 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11788 ((= unmark 0)
11789 (gnus-summary-mark-article nil gnus-expirable-mark))
11790 (t
11791 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11792 (setq articles (cdr articles))))
11793 ;; Hide killed subtrees when hide is true.
11794 (and hide
11795 gnus-thread-hide-killed
11796 (gnus-summary-hide-thread))
11797 ;; If hide is t, go to next unread subject.
11798 (when hide
11799 ;; Go to next unread subject.
11800 (gnus-summary-next-subject 1 t)))
11801 (gnus-set-mode-line 'summary))
11802
11803 ;; Summary sorting commands
11804
11805 (defun gnus-summary-sort-by-number (&optional reverse)
11806 "Sort the summary buffer by article number.
11807 Argument REVERSE means reverse order."
11808 (interactive "P")
11809 (gnus-summary-sort 'number reverse))
11810
11811 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11812 "Sort the summary buffer by most recent article number.
11813 Argument REVERSE means reverse order."
11814 (interactive "P")
11815 (gnus-summary-sort 'most-recent-number reverse))
11816
11817 (defun gnus-summary-sort-by-random (&optional reverse)
11818 "Randomize the order in the summary buffer.
11819 Argument REVERSE means to randomize in reverse order."
11820 (interactive "P")
11821 (gnus-summary-sort 'random reverse))
11822
11823 (defun gnus-summary-sort-by-author (&optional reverse)
11824 "Sort the summary buffer by author name alphabetically.
11825 If `case-fold-search' is non-nil, case of letters is ignored.
11826 Argument REVERSE means reverse order."
11827 (interactive "P")
11828 (gnus-summary-sort 'author reverse))
11829
11830 (defun gnus-summary-sort-by-recipient (&optional reverse)
11831 "Sort the summary buffer by recipient name alphabetically.
11832 If `case-fold-search' is non-nil, case of letters is ignored.
11833 Argument REVERSE means reverse order."
11834 (interactive "P")
11835 (gnus-summary-sort 'recipient reverse))
11836
11837 (defun gnus-summary-sort-by-subject (&optional reverse)
11838 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11839 If `case-fold-search' is non-nil, case of letters is ignored.
11840 Argument REVERSE means reverse order."
11841 (interactive "P")
11842 (gnus-summary-sort 'subject reverse))
11843
11844 (defun gnus-summary-sort-by-date (&optional reverse)
11845 "Sort the summary buffer by date.
11846 Argument REVERSE means reverse order."
11847 (interactive "P")
11848 (gnus-summary-sort 'date reverse))
11849
11850 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11851 "Sort the summary buffer by most recent date.
11852 Argument REVERSE means reverse order."
11853 (interactive "P")
11854 (gnus-summary-sort 'most-recent-date reverse))
11855
11856 (defun gnus-summary-sort-by-score (&optional reverse)
11857 "Sort the summary buffer by score.
11858 Argument REVERSE means reverse order."
11859 (interactive "P")
11860 (gnus-summary-sort 'score reverse))
11861
11862 (defun gnus-summary-sort-by-lines (&optional reverse)
11863 "Sort the summary buffer by the number of lines.
11864 Argument REVERSE means reverse order."
11865 (interactive "P")
11866 (gnus-summary-sort 'lines reverse))
11867
11868 (defun gnus-summary-sort-by-chars (&optional reverse)
11869 "Sort the summary buffer by article length.
11870 Argument REVERSE means reverse order."
11871 (interactive "P")
11872 (gnus-summary-sort 'chars reverse))
11873
11874 (defun gnus-summary-sort-by-original (&optional reverse)
11875 "Sort the summary buffer using the default sorting method.
11876 Argument REVERSE means reverse order."
11877 (interactive "P")
11878 (let* ((inhibit-read-only t)
11879 (gnus-summary-prepare-hook nil))
11880 ;; We do the sorting by regenerating the threads.
11881 (gnus-summary-prepare)
11882 ;; Hide subthreads if needed.
11883 (gnus-summary-maybe-hide-threads)))
11884
11885 (defun gnus-summary-sort (predicate reverse)
11886 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11887 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11888 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11889 (gnus-thread-sort-functions
11890 (if (not reverse)
11891 thread
11892 `(lambda (t1 t2)
11893 (,thread t2 t1))))
11894 (gnus-sort-gathered-threads-function
11895 gnus-thread-sort-functions)
11896 (gnus-article-sort-functions
11897 (if (not reverse)
11898 article
11899 `(lambda (t1 t2)
11900 (,article t2 t1))))
11901 (inhibit-read-only t)
11902 (gnus-summary-prepare-hook nil))
11903 ;; We do the sorting by regenerating the threads.
11904 (gnus-summary-prepare)
11905 ;; Hide subthreads if needed.
11906 (gnus-summary-maybe-hide-threads)))
11907
11908 ;; Summary saving commands.
11909
11910 (defun gnus-summary-save-article (&optional n not-saved)
11911 "Save the current article using the default saver function.
11912 If N is a positive number, save the N next articles.
11913 If N is a negative number, save the N previous articles.
11914 If N is nil and any articles have been marked with the process mark,
11915 save those articles instead.
11916 The variable `gnus-default-article-saver' specifies the saver function.
11917
11918 If the optional second argument NOT-SAVED is non-nil, articles saved
11919 will not be marked as saved."
11920 (interactive "P")
11921 (require 'gnus-art)
11922 (let* ((articles (gnus-summary-work-articles n))
11923 (save-buffer (save-excursion
11924 (nnheader-set-temp-buffer " *Gnus Save*")))
11925 (num (length articles))
11926 ;; Whether to save decoded articles or raw articles.
11927 (decode (when gnus-article-save-coding-system
11928 (get gnus-default-article-saver :decode)))
11929 ;; When saving many articles in a single file, use the other
11930 ;; function to save articles other than the first one.
11931 (saver2 (get gnus-default-article-saver :function))
11932 (gnus-prompt-before-saving (if saver2
11933 t
11934 gnus-prompt-before-saving))
11935 (gnus-default-article-saver gnus-default-article-saver)
11936 header file)
11937 (dolist (article articles)
11938 (setq header (gnus-summary-article-header article))
11939 (if (not (vectorp header))
11940 ;; This is a pseudo-article.
11941 (if (assq 'name header)
11942 (gnus-copy-file (cdr (assq 'name header)))
11943 (gnus-message 1 "Article %d is unsavable" article))
11944 ;; This is a real article.
11945 (save-window-excursion
11946 (gnus-summary-select-article decode decode nil article)
11947 (gnus-summary-goto-subject article))
11948 (with-current-buffer save-buffer
11949 (erase-buffer)
11950 (insert-buffer-substring (if decode
11951 gnus-article-buffer
11952 gnus-original-article-buffer)))
11953 (setq file (gnus-article-save save-buffer file num))
11954 (gnus-summary-remove-process-mark article)
11955 (unless not-saved
11956 (gnus-summary-set-saved-mark article)))
11957 (when saver2
11958 (setq gnus-default-article-saver saver2
11959 saver2 nil)))
11960 (gnus-kill-buffer save-buffer)
11961 (gnus-summary-position-point)
11962 (gnus-set-mode-line 'summary)
11963 n))
11964
11965 (defun gnus-summary-pipe-output (&optional n sym)
11966 "Pipe the current article to a subprocess.
11967 If N is a positive number, pipe the N next articles.
11968 If N is a negative number, pipe the N previous articles.
11969 If N is nil and any articles have been marked with the process mark,
11970 pipe those articles instead.
11971 The default command to which articles are piped is specified by the
11972 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11973 will be prompted for the command.
11974
11975 The properties `:decode' and `:headers' that are put to the function
11976 symbol `gnus-summary-save-in-pipe' control whether this function
11977 decodes articles and what headers to keep (see the doc string for the
11978 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11979 is neither omitted nor the symbol `r', force including all headers
11980 regardless of the `:headers' property. If it is the symbol `r',
11981 articles that are not decoded and include all headers will be piped
11982 no matter what the properties `:decode' and `:headers' are."
11983 (interactive (gnus-interactive "P\ny"))
11984 (require 'gnus-art)
11985 (let* ((articles (gnus-summary-work-articles n))
11986 (result-buffer "*Shell Command Output*")
11987 (all-headers (not (memq sym '(nil r))))
11988 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11989 (raw (eq sym 'r))
11990 (headers (get 'gnus-summary-save-in-pipe :headers))
11991 command result)
11992 (unless (numberp (car articles))
11993 (error "No article to pipe"))
11994 (setq command (gnus-read-shell-command
11995 (concat "Shell command on "
11996 (if (cdr articles)
11997 (format "these %d articles" (length articles))
11998 "this article")
11999 ": ")
12000 gnus-summary-pipe-output-default-command))
12001 (when (string-equal command "")
12002 (error "A command is required"))
12003 (when all-headers
12004 (put 'gnus-summary-save-in-pipe :headers nil))
12005 (unwind-protect
12006 (while articles
12007 (gnus-summary-goto-subject (pop articles))
12008 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12009 (when (and (get-buffer result-buffer)
12010 (not (zerop (buffer-size (get-buffer result-buffer)))))
12011 (setq result (concat result (with-current-buffer result-buffer
12012 (buffer-string))))))
12013 (put 'gnus-summary-save-in-pipe :headers headers))
12014 (unless (zerop (length result))
12015 (if (with-current-buffer (get-buffer-create result-buffer)
12016 (erase-buffer)
12017 (insert result)
12018 (prog1
12019 (and (= (count-lines (point-min) (point)) 1)
12020 (progn
12021 (end-of-line 0)
12022 (<= (current-column)
12023 (window-width (minibuffer-window)))))
12024 (goto-char (point-min))))
12025 (message "%s" (substring result 0 -1))
12026 (message nil)
12027 (gnus-configure-windows 'pipe)))))
12028
12029 (defun gnus-summary-save-article-mail (&optional arg)
12030 "Append the current article to a Unix mail box file.
12031 If N is a positive number, save the N next articles.
12032 If N is a negative number, save the N previous articles.
12033 If N is nil and any articles have been marked with the process mark,
12034 save those articles instead."
12035 (interactive "P")
12036 (require 'gnus-art)
12037 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12038 (gnus-summary-save-article arg)))
12039
12040 (defun gnus-summary-save-article-rmail (&optional arg)
12041 "Append the current article to an rmail file.
12042 If N is a positive number, save the N next articles.
12043 If N is a negative number, save the N previous articles.
12044 If N is nil and any articles have been marked with the process mark,
12045 save those articles instead."
12046 (interactive "P")
12047 (require 'gnus-art)
12048 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12049 (gnus-summary-save-article arg)))
12050
12051 (defun gnus-summary-save-article-file (&optional arg)
12052 "Append the current article to a file.
12053 If N is a positive number, save the N next articles.
12054 If N is a negative number, save the N previous articles.
12055 If N is nil and any articles have been marked with the process mark,
12056 save those articles instead."
12057 (interactive "P")
12058 (require 'gnus-art)
12059 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12060 (gnus-summary-save-article arg)))
12061
12062 (defun gnus-summary-write-article-file (&optional arg)
12063 "Write the current article to a file, deleting the previous file.
12064 If N is a positive number, save the N next articles.
12065 If N is a negative number, save the N previous articles.
12066 If N is nil and any articles have been marked with the process mark,
12067 save those articles instead."
12068 (interactive "P")
12069 (require 'gnus-art)
12070 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12071 (gnus-summary-save-article arg)))
12072
12073 (defun gnus-summary-save-article-body-file (&optional arg)
12074 "Append the current article body to a file.
12075 If N is a positive number, save the N next articles.
12076 If N is a negative number, save the N previous articles.
12077 If N is nil and any articles have been marked with the process mark,
12078 save those articles instead."
12079 (interactive "P")
12080 (require 'gnus-art)
12081 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12082 (gnus-summary-save-article arg)))
12083
12084 (defun gnus-summary-write-article-body-file (&optional arg)
12085 "Write the current article body to a file, deleting the previous file.
12086 If N is a positive number, save the N next articles.
12087 If N is a negative number, save the N previous articles.
12088 If N is nil and any articles have been marked with the process mark,
12089 save those articles instead."
12090 (interactive "P")
12091 (require 'gnus-art)
12092 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12093 (gnus-summary-save-article arg)))
12094
12095 (defun gnus-summary-muttprint (&optional arg)
12096 "Print the current article using Muttprint.
12097 If N is a positive number, save the N next articles.
12098 If N is a negative number, save the N previous articles.
12099 If N is nil and any articles have been marked with the process mark,
12100 save those articles instead."
12101 (interactive "P")
12102 (require 'gnus-art)
12103 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12104 (gnus-summary-save-article arg t)))
12105
12106 (defun gnus-summary-pipe-message (program)
12107 "Pipe the current article through PROGRAM."
12108 (interactive "sProgram: ")
12109 (gnus-summary-select-article)
12110 (let ((mail-header-separator ""))
12111 (gnus-eval-in-buffer-window gnus-article-buffer
12112 (save-restriction
12113 (widen)
12114 (let ((start (window-start))
12115 (inhibit-read-only t))
12116 (message-pipe-buffer-body program)
12117 (set-window-start (get-buffer-window (current-buffer)) start))))))
12118
12119 (defun gnus-get-split-value (methods)
12120 "Return a value based on the split METHODS."
12121 (let (split-name method result match)
12122 (when methods
12123 (with-current-buffer gnus-original-article-buffer
12124 (save-restriction
12125 (nnheader-narrow-to-headers)
12126 (while (and methods (not split-name))
12127 (goto-char (point-min))
12128 (setq method (pop methods))
12129 (setq match (car method))
12130 (when (cond
12131 ((stringp match)
12132 ;; Regular expression.
12133 (ignore-errors
12134 (re-search-forward match nil t)))
12135 ((functionp match)
12136 ;; Function.
12137 (save-restriction
12138 (widen)
12139 (setq result (funcall match gnus-newsgroup-name))))
12140 ((consp match)
12141 ;; Form.
12142 (save-restriction
12143 (widen)
12144 (setq result (eval match)))))
12145 (setq split-name (cdr method))
12146 (cond ((stringp result)
12147 (push (expand-file-name
12148 result gnus-article-save-directory)
12149 split-name))
12150 ((consp result)
12151 (setq split-name (append result split-name)))))))))
12152 (nreverse split-name)))
12153
12154 (defun gnus-valid-move-group-p (group)
12155 (and (symbolp group)
12156 (boundp group)
12157 (symbol-name group)
12158 (symbol-value group)
12159 (gnus-get-function (gnus-find-method-for-group
12160 (symbol-name group)) 'request-accept-article t)))
12161
12162 (defun gnus-read-move-group-name (prompt default articles prefix)
12163 "Read a group name."
12164 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12165 (minibuffer-confirm-incomplete nil) ; XEmacs
12166 (prom
12167 (format "%s %s to"
12168 prompt
12169 (if (> (length articles) 1)
12170 (format "these %d articles" (length articles))
12171 "this article")))
12172 (to-newsgroup
12173 (cond
12174 ((null split-name)
12175 (gnus-group-completing-read
12176 prom
12177 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12178 nil prefix nil default))
12179 ((= 1 (length split-name))
12180 (gnus-group-completing-read
12181 prom
12182 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12183 nil prefix 'gnus-group-history (car split-name)))
12184 (t
12185 (gnus-completing-read
12186 prom (nreverse split-name) nil nil 'gnus-group-history))))
12187 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12188 encoded)
12189 (when to-newsgroup
12190 (if (or (string= to-newsgroup "")
12191 (string= to-newsgroup prefix))
12192 (setq to-newsgroup default))
12193 (unless to-newsgroup
12194 (error "No group name entered"))
12195 (setq encoded (mm-encode-coding-string
12196 to-newsgroup
12197 (gnus-group-name-charset to-method to-newsgroup)))
12198 (or (gnus-active encoded)
12199 (gnus-activate-group encoded nil nil to-method)
12200 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12201 to-newsgroup))
12202 (or (and (gnus-request-create-group encoded to-method)
12203 (gnus-activate-group encoded nil nil to-method)
12204 (gnus-subscribe-group encoded))
12205 (error "Couldn't create group %s" to-newsgroup)))
12206 (error "No such group: %s" to-newsgroup))
12207 encoded)))
12208
12209 (defvar gnus-summary-save-parts-counter)
12210 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12211
12212 (defun gnus-summary-save-parts (type dir n &optional reverse)
12213 "Save parts matching TYPE to DIR.
12214 If REVERSE, save parts that do not match TYPE."
12215 (interactive
12216 (list (read-string "Save parts of type: "
12217 (or (car gnus-summary-save-parts-type-history)
12218 gnus-summary-save-parts-default-mime)
12219 'gnus-summary-save-parts-type-history)
12220 (setq gnus-summary-save-parts-last-directory
12221 (read-directory-name "Save to directory: "
12222 gnus-summary-save-parts-last-directory
12223 nil t))
12224 current-prefix-arg))
12225 (gnus-summary-iterate n
12226 (let ((gnus-display-mime-function nil)
12227 gnus-article-prepare-hook
12228 gnus-article-decode-hook
12229 gnus-display-mime-function
12230 gnus-break-pages
12231 (gnus-inhibit-treatment t))
12232 (gnus-summary-select-article))
12233 (with-current-buffer gnus-article-buffer
12234 (let ((handles (or gnus-article-mime-handles
12235 (mm-dissect-buffer nil gnus-article-loose-mime)
12236 (and gnus-article-emulate-mime
12237 (mm-uu-dissect))))
12238 (gnus-summary-save-parts-counter 1))
12239 (when handles
12240 (gnus-summary-save-parts-1 type dir handles reverse)
12241 (unless gnus-article-mime-handles ;; Don't destroy this case.
12242 (mm-destroy-parts handles)))))))
12243
12244 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12245 (if (stringp (car handle))
12246 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12247 (cdr handle))
12248 (when (if reverse
12249 (not (string-match type (mm-handle-media-type handle)))
12250 (string-match type (mm-handle-media-type handle)))
12251 (let ((file (expand-file-name
12252 (gnus-map-function
12253 mm-file-name-rewrite-functions
12254 (file-name-nondirectory
12255 (or
12256 (mm-handle-filename handle)
12257 (format "%s.%d.%d" gnus-newsgroup-name
12258 (cdr gnus-article-current)
12259 gnus-summary-save-parts-counter))))
12260 dir)))
12261 (incf gnus-summary-save-parts-counter)
12262 (unless (file-exists-p file)
12263 (mm-save-part-to-file handle file))))))
12264
12265 ;; Summary extract commands
12266
12267 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12268 (let ((inhibit-read-only t)
12269 (article (gnus-summary-article-number))
12270 after-article b e)
12271 (unless (gnus-summary-goto-subject article)
12272 (error "No such article: %d" article))
12273 (gnus-summary-position-point)
12274 ;; If all commands are to be bunched up on one line, we collect
12275 ;; them here.
12276 (unless gnus-view-pseudos-separately
12277 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12278 files action)
12279 (while ps
12280 (setq action (cdr (assq 'action (car ps))))
12281 (setq files (list (cdr (assq 'name (car ps)))))
12282 (while (and ps (cdr ps)
12283 (string= (or action "1")
12284 (or (cdr (assq 'action (cadr ps))) "2")))
12285 (push (cdr (assq 'name (cadr ps))) files)
12286 (setcdr ps (cddr ps)))
12287 (when files
12288 (when (not (string-match "%s" action))
12289 (push " " files))
12290 (push " " files)
12291 (when (assq 'execute (car ps))
12292 (setcdr (assq 'execute (car ps))
12293 (funcall (if (string-match "%s" action)
12294 'format 'concat)
12295 action
12296 (mapconcat
12297 (lambda (f)
12298 (if (equal f " ")
12299 f
12300 (shell-quote-argument f)))
12301 files " ")))))
12302 (setq ps (cdr ps)))))
12303 (if (and gnus-view-pseudos (not not-view))
12304 (while pslist
12305 (when (assq 'execute (car pslist))
12306 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12307 (eq gnus-view-pseudos 'not-confirm)))
12308 (setq pslist (cdr pslist)))
12309 (save-excursion
12310 (while pslist
12311 (setq after-article (or (cdr (assq 'article (car pslist)))
12312 (gnus-summary-article-number)))
12313 (gnus-summary-goto-subject after-article)
12314 (forward-line 1)
12315 (setq b (point))
12316 (insert " " (file-name-nondirectory
12317 (cdr (assq 'name (car pslist))))
12318 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12319 (setq e (point))
12320 (forward-line -1) ; back to `b'
12321 (gnus-add-text-properties
12322 b (1- e) (list 'gnus-number gnus-reffed-article-number
12323 gnus-mouse-face-prop gnus-mouse-face))
12324 (gnus-data-enter
12325 after-article gnus-reffed-article-number
12326 gnus-unread-mark b (car pslist) 0 (- e b))
12327 (setq gnus-newsgroup-unreads
12328 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12329 gnus-reffed-article-number))
12330 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12331 (setq pslist (cdr pslist)))))))
12332
12333 (defun gnus-pseudos< (p1 p2)
12334 (let ((c1 (cdr (assq 'action p1)))
12335 (c2 (cdr (assq 'action p2))))
12336 (and c1 c2 (string< c1 c2))))
12337
12338 (defun gnus-request-pseudo-article (props)
12339 (cond ((assq 'execute props)
12340 (gnus-execute-command (cdr (assq 'execute props)))))
12341 (let ((gnus-current-article (gnus-summary-article-number)))
12342 (gnus-run-hooks 'gnus-mark-article-hook)))
12343
12344 (defun gnus-execute-command (command &optional automatic)
12345 (save-excursion
12346 (gnus-article-setup-buffer)
12347 (set-buffer gnus-article-buffer)
12348 (setq buffer-read-only nil)
12349 (let ((command (if automatic command
12350 (read-string "Command: " (cons command 0)))))
12351 (erase-buffer)
12352 (insert "$ " command "\n\n")
12353 (if gnus-view-pseudo-asynchronously
12354 (start-process "gnus-execute" (current-buffer) shell-file-name
12355 shell-command-switch command)
12356 (call-process shell-file-name nil t nil
12357 shell-command-switch command)))))
12358
12359 ;; Summary kill commands.
12360
12361 (defun gnus-summary-edit-global-kill (article)
12362 "Edit the \"global\" kill file."
12363 (interactive (list (gnus-summary-article-number)))
12364 (gnus-group-edit-global-kill article))
12365
12366 (defun gnus-summary-edit-local-kill ()
12367 "Edit a local kill file applied to the current newsgroup."
12368 (interactive)
12369 (setq gnus-current-headers (gnus-summary-article-header))
12370 (gnus-group-edit-local-kill
12371 (gnus-summary-article-number) gnus-newsgroup-name))
12372
12373 ;;; Header reading.
12374
12375 (defun gnus-read-header (id &optional header)
12376 "Read the headers of article ID and enter them into the Gnus system."
12377 (let ((group gnus-newsgroup-name)
12378 (gnus-override-method
12379 (or
12380 gnus-override-method
12381 (and (gnus-news-group-p gnus-newsgroup-name)
12382 (car (gnus-refer-article-methods)))))
12383 where)
12384 ;; First we check to see whether the header in question is already
12385 ;; fetched.
12386 (if (stringp id)
12387 ;; This is a Message-ID.
12388 (setq header (or header (gnus-id-to-header id)))
12389 ;; This is an article number.
12390 (setq header (or header (gnus-summary-article-header id))))
12391 (if (and header
12392 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12393 ;; We have found the header.
12394 header
12395 ;; We have to really fetch the header to this article.
12396 (with-current-buffer nntp-server-buffer
12397 (when (setq where (gnus-request-head id group))
12398 (nnheader-fold-continuation-lines)
12399 (goto-char (point-max))
12400 (insert ".\n")
12401 (goto-char (point-min))
12402 (insert "211 ")
12403 (princ (cond
12404 ((numberp id) id)
12405 ((cdr where) (cdr where))
12406 (header (mail-header-number header))
12407 (t gnus-reffed-article-number))
12408 (current-buffer))
12409 (insert " Article retrieved.\n"))
12410 (if (or (not where)
12411 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12412 () ; Malformed head.
12413 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12414 (when (and (bound-and-true-p gnus-registry-enabled)
12415 (not (gnus-ephemeral-group-p (car where))))
12416 (gnus-registry-handle-action
12417 (mail-header-id header) nil
12418 (gnus-group-prefixed-name (car where) gnus-override-method)
12419 (mail-header-subject header)
12420 (mail-header-from header)))
12421 (when (and (stringp id)
12422 (or
12423 (not (string= (gnus-group-real-name group)
12424 (car where)))
12425 (not (gnus-server-equal gnus-override-method
12426 (gnus-group-method group)))))
12427 ;; If we fetched by Message-ID and the article came from
12428 ;; a different group (or server), we fudge some bogus
12429 ;; article numbers for this article.
12430 (mail-header-set-number header gnus-reffed-article-number))
12431 (with-current-buffer gnus-summary-buffer
12432 (decf gnus-reffed-article-number)
12433 (gnus-remove-header (mail-header-number header))
12434 (push header gnus-newsgroup-headers)
12435 (setq gnus-current-headers header)
12436 (push (mail-header-number header) gnus-newsgroup-limit)))
12437 header)))))
12438
12439 (defun gnus-remove-header (number)
12440 "Remove header NUMBER from `gnus-newsgroup-headers'."
12441 (if (and gnus-newsgroup-headers
12442 (= number (mail-header-number (car gnus-newsgroup-headers))))
12443 (pop gnus-newsgroup-headers)
12444 (let ((headers gnus-newsgroup-headers))
12445 (while (and (cdr headers)
12446 (not (= number (mail-header-number (cadr headers)))))
12447 (pop headers))
12448 (when (cdr headers)
12449 (setcdr headers (cddr headers))))))
12450
12451 ;;;
12452 ;;; summary highlights
12453 ;;;
12454
12455 (defun gnus-highlight-selected-summary ()
12456 "Highlight selected article in summary buffer."
12457 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12458 (when gnus-summary-selected-face
12459 (save-excursion
12460 (let* ((beg (point-at-bol))
12461 (end (point-at-eol))
12462 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12463 (from (if (get-text-property beg gnus-mouse-face-prop)
12464 beg
12465 (or (next-single-property-change
12466 beg gnus-mouse-face-prop nil end)
12467 beg)))
12468 (to
12469 (if (= from end)
12470 (- from 2)
12471 (or (next-single-property-change
12472 from gnus-mouse-face-prop nil end)
12473 end))))
12474 ;; If no mouse-face prop on line we will have to = from = end,
12475 ;; so we highlight the entire line instead.
12476 (when (= (+ to 2) from)
12477 (setq from beg)
12478 (setq to end))
12479 (if gnus-newsgroup-selected-overlay
12480 ;; Move old overlay.
12481 (gnus-move-overlay
12482 gnus-newsgroup-selected-overlay from to (current-buffer))
12483 ;; Create new overlay.
12484 (gnus-overlay-put
12485 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12486 'face gnus-summary-selected-face))))))
12487
12488 (defvar gnus-summary-highlight-line-cached nil)
12489 (defvar gnus-summary-highlight-line-trigger nil)
12490
12491 (defun gnus-summary-highlight-line-0 ()
12492 (if (and (eq gnus-summary-highlight-line-trigger
12493 gnus-summary-highlight)
12494 gnus-summary-highlight-line-cached)
12495 gnus-summary-highlight-line-cached
12496 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12497 gnus-summary-highlight-line-cached
12498 (let* ((cond (list 'cond))
12499 (c cond)
12500 (list gnus-summary-highlight))
12501 (while list
12502 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12503 nil))
12504 (setq c (cdr c)
12505 list (cdr list)))
12506 (gnus-byte-compile (list 'lambda nil cond))))))
12507
12508 (defun gnus-summary-highlight-line ()
12509 "Highlight current line according to `gnus-summary-highlight'."
12510 (let* ((beg (point-at-bol))
12511 (article (or (gnus-summary-article-number) gnus-current-article))
12512 (score (or (cdr (assq article
12513 gnus-newsgroup-scored))
12514 gnus-summary-default-score 0))
12515 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12516 (inhibit-read-only t)
12517 (default gnus-summary-default-score)
12518 (default-high gnus-summary-default-high-score)
12519 (default-low gnus-summary-default-low-score)
12520 (uncached (and gnus-summary-use-undownloaded-faces
12521 (memq article gnus-newsgroup-undownloaded)
12522 (not (memq article gnus-newsgroup-cached)))))
12523 (let ((face (funcall (gnus-summary-highlight-line-0))))
12524 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12525 (gnus-put-text-property-excluding-characters-with-faces
12526 beg (point-at-eol) 'face
12527 (setq face (if (boundp face) (symbol-value face) face)))
12528 (when gnus-summary-highlight-line-function
12529 (funcall gnus-summary-highlight-line-function article face))))))
12530
12531 (defun gnus-update-read-articles (group unread &optional compute)
12532 "Update the list of read articles in GROUP.
12533 UNREAD is a sorted list."
12534 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12535 (info (gnus-get-info group))
12536 (prev 1)
12537 read)
12538 (if (or (not info) (not active))
12539 ;; There is no info on this group if it was, in fact,
12540 ;; killed. Gnus stores no information on killed groups, so
12541 ;; there's nothing to be done.
12542 ;; One could store the information somewhere temporarily,
12543 ;; perhaps... Hmmm...
12544 ()
12545 ;; Remove any negative articles numbers.
12546 (while (and unread (< (car unread) 0))
12547 (setq unread (cdr unread)))
12548 ;; Remove any expired article numbers
12549 (while (and unread (< (car unread) (car active)))
12550 (setq unread (cdr unread)))
12551 ;; Compute the ranges of read articles by looking at the list of
12552 ;; unread articles.
12553 (while unread
12554 (when (/= (car unread) prev)
12555 (push (if (= prev (1- (car unread))) prev
12556 (cons prev (1- (car unread))))
12557 read))
12558 (setq prev (1+ (car unread)))
12559 (setq unread (cdr unread)))
12560 (when (<= prev (cdr active))
12561 (push (cons prev (cdr active)) read))
12562 (setq read (if (> (length read) 1) (nreverse read) read))
12563 (if compute
12564 read
12565 (save-excursion
12566 (let (setmarkundo)
12567 ;; Propagate the read marks to the backend.
12568 (when (and (gnus-method-option-p
12569 (gnus-find-method-for-group group)
12570 'server-marks)
12571 (gnus-check-backend-function 'request-set-mark group))
12572 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12573 (add (gnus-remove-from-range read (gnus-info-read info))))
12574 (when (or add del)
12575 (unless (gnus-check-group group)
12576 (error "Can't open server for %s" group))
12577 (gnus-request-set-mark
12578 group (delq nil (list (if add (list add 'add '(read)))
12579 (if del (list del 'del '(read))))))
12580 (setq setmarkundo
12581 `(gnus-request-set-mark
12582 ,group
12583 ',(delq nil (list
12584 (if del (list del 'add '(read)))
12585 (if add (list add 'del '(read))))))))))
12586 (set-buffer gnus-group-buffer)
12587 (gnus-undo-register
12588 `(progn
12589 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12590 (gnus-info-set-read ',info ',(gnus-info-read info))
12591 (gnus-get-unread-articles-in-group ',info
12592 (gnus-active ,group))
12593 (gnus-group-update-group ,group t)
12594 ,setmarkundo))))
12595 ;; Enter this list into the group info.
12596 (gnus-info-set-read info read)
12597 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12598 (gnus-get-unread-articles-in-group info (gnus-active group))
12599 t))))
12600
12601 (defun gnus-offer-save-summaries ()
12602 "Offer to save all active summary buffers."
12603 (let (buffers)
12604 ;; Go through all buffers and find all summaries.
12605 (dolist (buffer (buffer-list))
12606 (when (and (setq buffer (buffer-name buffer))
12607 (string-match "Summary" buffer)
12608 (with-current-buffer buffer
12609 ;; We check that this is, indeed, a summary buffer.
12610 (and (eq major-mode 'gnus-summary-mode)
12611 ;; Also make sure this isn't bogus.
12612 gnus-newsgroup-prepared
12613 ;; Also make sure that this isn't a
12614 ;; dead summary buffer.
12615 (not gnus-dead-summary-mode))))
12616 (push buffer buffers)))
12617 ;; Go through all these summary buffers and offer to save them.
12618 (when buffers
12619 (save-excursion
12620 (if (eq gnus-interactive-exit 'quiet)
12621 (dolist (buffer buffers)
12622 (switch-to-buffer buffer)
12623 (gnus-summary-exit))
12624 (map-y-or-n-p
12625 "Update summary buffer %s? "
12626 (lambda (buf)
12627 (switch-to-buffer buf)
12628 (gnus-summary-exit))
12629 buffers))))))
12630
12631 (defun gnus-summary-setup-default-charset ()
12632 "Setup newsgroup default charset."
12633 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12634 (setq gnus-newsgroup-charset nil)
12635 (let* ((ignored-charsets
12636 (or gnus-newsgroup-ephemeral-ignored-charsets
12637 (append
12638 (and gnus-newsgroup-name
12639 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12640 gnus-newsgroup-ignored-charsets))))
12641 (setq gnus-newsgroup-charset
12642 (or gnus-newsgroup-ephemeral-charset
12643 (and gnus-newsgroup-name
12644 (gnus-parameter-charset gnus-newsgroup-name))
12645 gnus-default-charset))
12646 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12647 ignored-charsets))))
12648
12649 ;;;
12650 ;;; Mime Commands
12651 ;;;
12652
12653 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12654 "Display the current article buffer fully MIME-buttonized.
12655 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12656 treated as multipart/mixed."
12657 (interactive "P")
12658 (require 'gnus-art)
12659 (let ((gnus-unbuttonized-mime-types nil)
12660 (gnus-mime-display-multipart-as-mixed show-all-parts))
12661 (gnus-summary-show-article)))
12662
12663 (defun gnus-summary-repair-multipart (article)
12664 "Add a Content-Type header to a multipart article without one."
12665 (interactive (list (gnus-summary-article-number)))
12666 (gnus-with-article article
12667 (message-narrow-to-head)
12668 (message-remove-header "Mime-Version")
12669 (goto-char (point-max))
12670 (insert "Mime-Version: 1.0\n")
12671 (widen)
12672 (when (search-forward "\n--" nil t)
12673 (let ((separator (buffer-substring (point) (point-at-eol))))
12674 (message-narrow-to-head)
12675 (message-remove-header "Content-Type")
12676 (goto-char (point-max))
12677 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12678 separator))
12679 (widen))))
12680 (let (gnus-mark-article-hook)
12681 (gnus-summary-select-article t t nil article)))
12682
12683 (defun gnus-summary-toggle-display-buttonized ()
12684 "Toggle the buttonizing of the article buffer."
12685 (interactive)
12686 (require 'gnus-art)
12687 (if (setq gnus-inhibit-mime-unbuttonizing
12688 (not gnus-inhibit-mime-unbuttonizing))
12689 (let ((gnus-unbuttonized-mime-types nil))
12690 (gnus-summary-show-article))
12691 (gnus-summary-show-article)))
12692
12693 ;;;
12694 ;;; Generic summary marking commands
12695 ;;;
12696
12697 (defvar gnus-summary-marking-alist
12698 '((read gnus-del-mark "d")
12699 (unread gnus-unread-mark "u")
12700 (ticked gnus-ticked-mark "!")
12701 (dormant gnus-dormant-mark "?")
12702 (expirable gnus-expirable-mark "e"))
12703 "An alist of names/marks/keystrokes.")
12704
12705 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12706 (defvar gnus-summary-mark-map)
12707
12708 (defun gnus-summary-make-all-marking-commands ()
12709 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12710 (dolist (elem gnus-summary-marking-alist)
12711 (apply 'gnus-summary-make-marking-command elem)))
12712
12713 (defun gnus-summary-make-marking-command (name mark keystroke)
12714 (let ((map (make-sparse-keymap)))
12715 (define-key gnus-summary-generic-mark-map keystroke map)
12716 (dolist (lway `((next "next" next nil "n")
12717 (next-unread "next unread" next t "N")
12718 (prev "previous" prev nil "p")
12719 (prev-unread "previous unread" prev t "P")
12720 (nomove "" nil nil ,keystroke)))
12721 (let ((func (gnus-summary-make-marking-command-1
12722 mark (car lway) lway name)))
12723 (setq func (eval func))
12724 (define-key map (nth 4 lway) func)))))
12725
12726 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12727 `(defun ,(intern
12728 (format "gnus-summary-put-mark-as-%s%s"
12729 name (if (eq way 'nomove)
12730 ""
12731 (concat "-" (symbol-name way)))))
12732 (n)
12733 ,(format
12734 "Mark the current article as %s%s.
12735 If N, the prefix, then repeat N times.
12736 If N is negative, move in reverse order.
12737 The difference between N and the actual number of articles marked is
12738 returned."
12739 name (cadr lway))
12740 (interactive "p")
12741 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12742
12743 (defun gnus-summary-generic-mark (n mark move unread)
12744 "Mark N articles with MARK."
12745 (unless (eq major-mode 'gnus-summary-mode)
12746 (error "This command can only be used in the summary buffer"))
12747 (gnus-summary-show-thread)
12748 (let ((nummove
12749 (cond
12750 ((eq move 'next) 1)
12751 ((eq move 'prev) -1)
12752 (t 0))))
12753 (if (zerop nummove)
12754 (setq n 1)
12755 (when (< n 0)
12756 (setq n (abs n)
12757 nummove (* -1 nummove))))
12758 (while (and (> n 0)
12759 (gnus-summary-mark-article nil mark)
12760 (zerop (gnus-summary-next-subject nummove unread t)))
12761 (setq n (1- n)))
12762 (when (/= 0 n)
12763 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12764 (gnus-summary-recenter)
12765 (gnus-summary-position-point)
12766 (gnus-set-mode-line 'summary)
12767 n))
12768
12769 (defun gnus-summary-insert-articles (articles)
12770 (when (setq articles
12771 (gnus-sorted-difference articles
12772 (mapcar (lambda (h)
12773 (mail-header-number h))
12774 gnus-newsgroup-headers)))
12775 (setq gnus-newsgroup-headers
12776 (gnus-merge 'list
12777 gnus-newsgroup-headers
12778 (gnus-fetch-headers articles)
12779 'gnus-article-sort-by-number))
12780 (setq gnus-newsgroup-articles
12781 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12782 ;; Suppress duplicates?
12783 (when gnus-suppress-duplicates
12784 (gnus-dup-suppress-articles))
12785
12786 (if (and gnus-fetch-old-headers
12787 (eq gnus-headers-retrieved-by 'nov))
12788 ;; We might want to build some more threads first.
12789 (if (eq gnus-fetch-old-headers 'invisible)
12790 (gnus-build-all-threads)
12791 (gnus-build-old-threads))
12792 ;; Mark the inserted articles that are unread as unread.
12793 (setq gnus-newsgroup-unreads
12794 (gnus-sorted-nunion
12795 gnus-newsgroup-unreads
12796 (gnus-sorted-nintersection
12797 (gnus-list-of-unread-articles gnus-newsgroup-name)
12798 articles)))
12799 ;; Mark the inserted articles as selected so that the information
12800 ;; of the marks having been changed by a user may be updated when
12801 ;; exiting this group. See `gnus-summary-update-info'.
12802 (dolist (art articles)
12803 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12804 ;; Let the Gnus agent mark articles as read.
12805 (when gnus-agent
12806 (gnus-agent-get-undownloaded-list))
12807 ;; Remove list identifiers from subject
12808 (gnus-summary-remove-list-identifiers)
12809 ;; First and last article in this newsgroup.
12810 (when gnus-newsgroup-headers
12811 (setq gnus-newsgroup-begin
12812 (mail-header-number (car gnus-newsgroup-headers))
12813 gnus-newsgroup-end
12814 (mail-header-number
12815 (gnus-last-element gnus-newsgroup-headers))))
12816 (when gnus-use-scoring
12817 (gnus-possibly-score-headers))))
12818
12819 (defun gnus-summary-insert-old-articles (&optional all)
12820 "Insert all old articles in this group.
12821 If ALL is non-nil, already read articles become readable.
12822 If ALL is a number, fetch this number of articles."
12823 (interactive "P")
12824 (prog1
12825 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12826 older len)
12827 (setq older
12828 ;; Some nntp servers lie about their active range. When
12829 ;; this happens, the active range can be in the millions.
12830 ;; Use a compressed range to avoid creating a huge list.
12831 (gnus-range-difference (list gnus-newsgroup-active) old))
12832 (setq len (gnus-range-length older))
12833 (cond
12834 ((null older) nil)
12835 ((numberp all)
12836 (if (< all len)
12837 (let ((older-range (nreverse older)))
12838 (setq older nil)
12839
12840 (while (> all 0)
12841 (let* ((r (pop older-range))
12842 (min (if (numberp r) r (car r)))
12843 (max (if (numberp r) r (cdr r))))
12844 (while (and (<= min max)
12845 (> all 0))
12846 (push max older)
12847 (setq all (1- all)
12848 max (1- max))))))
12849 (setq older (gnus-uncompress-range older))))
12850 (all
12851 (setq older (gnus-uncompress-range older)))
12852 (t
12853 (when (and (numberp gnus-large-newsgroup)
12854 (> len gnus-large-newsgroup))
12855 (let* ((cursor-in-echo-area nil)
12856 (initial (gnus-parameter-large-newsgroup-initial
12857 gnus-newsgroup-name))
12858 (input
12859 (read-string
12860 (format
12861 "How many articles from %s (%s %d): "
12862 (gnus-group-decoded-name gnus-newsgroup-name)
12863 (if initial "max" "default")
12864 len)
12865 nil nil
12866 (and initial
12867 (number-to-string initial)))))
12868 (unless (string-match "^[ \t]*$" input)
12869 (setq all (string-to-number input))
12870 (if (< all len)
12871 (let ((older-range (nreverse older)))
12872 (setq older nil)
12873
12874 (while (> all 0)
12875 (let* ((r (pop older-range))
12876 (min (if (numberp r) r (car r)))
12877 (max (if (numberp r) r (cdr r))))
12878 (while (and (<= min max)
12879 (> all 0))
12880 (push max older)
12881 (setq all (1- all)
12882 max (1- max))))))))))
12883 (setq older (gnus-uncompress-range older))))
12884 (if (not older)
12885 (message "No old news.")
12886 (gnus-summary-insert-articles older)
12887 (gnus-summary-limit (gnus-sorted-nunion old older))))
12888 (gnus-summary-position-point)))
12889
12890 (defun gnus-summary-insert-new-articles ()
12891 "Insert all new articles in this group."
12892 (interactive)
12893 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12894 (old-high gnus-newsgroup-highest)
12895 (nnmail-fetched-sources (list t))
12896 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12897 i new)
12898 (unless new-active
12899 (error "Couldn't fetch new data"))
12900 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12901 (setq i (cdr gnus-newsgroup-active)
12902 gnus-newsgroup-highest i)
12903 (while (> i old-high)
12904 (push i new)
12905 (decf i))
12906 (if (not new)
12907 (message "No gnus is bad news")
12908 (gnus-summary-insert-articles new)
12909 (setq gnus-newsgroup-unreads
12910 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12911 (gnus-summary-limit (gnus-sorted-nunion old new))))
12912 (gnus-summary-position-point))
12913
12914 ;;; Bookmark support for Gnus.
12915 (declare-function bookmark-make-record-default
12916 "bookmark" (&optional no-file no-context posn))
12917 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12918 (declare-function bookmark-default-handler "bookmark" (bmk))
12919 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12920 (defvar bookmark-yank-point)
12921 (defvar bookmark-current-buffer)
12922
12923 (defun gnus-summary-bookmark-make-record ()
12924 "Make a bookmark entry for a Gnus summary buffer."
12925 (let (pos buf)
12926 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12927 (save-restriction ; FIXME is it necessary to widen?
12928 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12929 (setq buf "art") ; We are recording bookmark from article buffer.
12930 (setq bookmark-yank-point (point))
12931 (setq bookmark-current-buffer (current-buffer))
12932 (gnus-article-show-summary)) ; Go back in summary buffer.
12933 ;; We are now recording bookmark from summary buffer.
12934 (unless buf (setq buf "sum"))
12935 (let* ((subject (elt (gnus-summary-article-header) 1))
12936 (grp (car gnus-article-current))
12937 (art (cdr gnus-article-current))
12938 (head (gnus-summary-article-header art))
12939 (id (mail-header-id head)))
12940 `(,subject
12941 ,@(condition-case nil
12942 (bookmark-make-record-default 'no-file 'no-context pos)
12943 (wrong-number-of-arguments
12944 (bookmark-make-record-default 'point-only)))
12945 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12946 (group . ,grp) (article . ,art)
12947 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12948
12949 ;;;###autoload
12950 (defun gnus-summary-bookmark-jump (bookmark)
12951 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12952 BOOKMARK is a bookmark name or a bookmark record."
12953 (let ((group (bookmark-prop-get bookmark 'group))
12954 (article (bookmark-prop-get bookmark 'article))
12955 (id (bookmark-prop-get bookmark 'message-id))
12956 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12957 (gnus-fetch-group group (list article))
12958 (gnus-summary-insert-cached-articles)
12959 (gnus-summary-goto-article id nil 'force)
12960 ;; FIXME we have to wait article buffer is ready (only large buffer)
12961 ;; Is there a better solution to know that?
12962 ;; If we don't wait `bookmark-default-handler' will have no chance
12963 ;; to set position. However there is no error, just wrong pos.
12964 (sit-for 1)
12965 (when (string= buf "Gnus-art")
12966 (other-window 1))
12967 (bookmark-default-handler
12968 `(""
12969 (buffer . ,(current-buffer))
12970 . ,(bookmark-get-bookmark-record bookmark)))))
12971
12972 (gnus-summary-make-all-marking-commands)
12973
12974 (gnus-ems-redefine)
12975
12976 (provide 'gnus-sum)
12977
12978 (run-hooks 'gnus-sum-load-hook)
12979
12980 ;; Local Variables:
12981 ;; coding: utf-8
12982 ;; End:
12983
12984 ;;; gnus-sum.el ends here