]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Merge from emacs-24; up to 2012-12-06T01:39:03Z!monnier@iro.umontreal.ca
[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 `gnus-ignored-from-addresses'."
1171 :version "22.1"
1172 :group 'gnus-summary
1173 :type 'string)
1174
1175 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1176 "List of charsets that should be ignored.
1177 When these charsets are used in the \"charset\" parameter, the
1178 default charset will be used instead."
1179 :version "21.1"
1180 :type '(repeat symbol)
1181 :group 'gnus-charset)
1182
1183 (defcustom gnus-newsgroup-maximum-articles nil
1184 "The maximum number of articles a newsgroup.
1185 If this is a number, old articles in a newsgroup exceeding this number
1186 are silently ignored. If it is nil, no article is ignored. Note that
1187 setting this variable to a number might prevent you from reading very
1188 old articles."
1189 :group 'gnus-group-select
1190 :version "22.2"
1191 :type '(choice (const :tag "No limit" nil)
1192 integer))
1193
1194 (gnus-define-group-parameter
1195 ignored-charsets
1196 :type list
1197 :function-document
1198 "Return the ignored charsets of GROUP."
1199 :variable gnus-group-ignored-charsets-alist
1200 :variable-default
1201 '(("alt\\.chinese\\.text" iso-8859-1))
1202 :variable-document
1203 "Alist of regexps (to match group names) and charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1206 :variable-group gnus-charset
1207 :variable-type '(repeat (cons (regexp :tag "Group")
1208 (repeat symbol)))
1209 :parameter-type '(choice :tag "Ignored charsets"
1210 :value nil
1211 (repeat (symbol)))
1212 :parameter-document "\
1213 List of charsets that should be ignored.
1214
1215 When these charsets are used in the \"charset\" parameter, the
1216 default charset will be used instead.")
1217
1218 (defcustom gnus-group-highlight-words-alist nil
1219 "Alist of group regexps and highlight regexps.
1220 This variable uses the same syntax as `gnus-emphasis-alist'."
1221 :version "21.1"
1222 :type '(repeat (cons (regexp :tag "Group")
1223 (repeat (list (regexp :tag "Highlight regexp")
1224 (number :tag "Group for entire word" 0)
1225 (number :tag "Group for displayed part" 0)
1226 (symbol :tag "Face"
1227 gnus-emphasis-highlight-words)))))
1228 :group 'gnus-summary-visual)
1229
1230 (defcustom gnus-summary-show-article-charset-alist
1231 nil
1232 "Alist of number and charset.
1233 The article will be shown with the charset corresponding to the
1234 numbered argument.
1235 For example: ((1 . cn-gb-2312) (2 . big5))."
1236 :version "21.1"
1237 :type '(repeat (cons (number :tag "Argument" 1)
1238 (symbol :tag "Charset")))
1239 :group 'gnus-charset)
1240
1241 (defcustom gnus-preserve-marks t
1242 "Whether marks are preserved when moving, copying and respooling messages."
1243 :version "21.1"
1244 :type 'boolean
1245 :group 'gnus-summary-marks)
1246
1247 (defcustom gnus-alter-articles-to-read-function nil
1248 "Function to be called to alter the list of articles to be selected."
1249 :type '(choice (const nil) function)
1250 :group 'gnus-summary)
1251
1252 (defcustom gnus-orphan-score nil
1253 "*All orphans get this score added. Set in the score file."
1254 :group 'gnus-score-default
1255 :type '(choice (const nil)
1256 integer))
1257
1258 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1259 "*A regexp to match MIME parts when saving multiple parts of a
1260 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1261 This regexp will be used by default when prompting the user for which
1262 type of files to save."
1263 :group 'gnus-summary
1264 :type 'regexp)
1265
1266 (defcustom gnus-read-all-available-headers nil
1267 "Whether Gnus should parse all headers made available to it.
1268 This is mostly relevant for slow back ends where the user may
1269 wish to widen the summary buffer to include all headers
1270 that were fetched."
1271 :version "22.1"
1272 :group 'gnus-summary
1273 :type '(choice boolean regexp))
1274
1275 (defcustom gnus-summary-pipe-output-default-command nil
1276 "Command (and optional arguments) used to pipe article to subprocess.
1277 This will be used as the default command if it is non-nil. The value
1278 will be updated if you modify it when executing the command
1279 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1280 :version "23.1" ;; No Gnus
1281 :group 'gnus-summary
1282 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1283
1284 (defcustom gnus-summary-muttprint-program "muttprint"
1285 "Command (and optional arguments) used to run Muttprint.
1286 The value will be updated if you modify it when executing the command
1287 `gnus-summary-muttprint'."
1288 :version "22.1"
1289 :group 'gnus-summary
1290 :type 'string)
1291
1292 (defcustom gnus-article-loose-mime t
1293 "If non-nil, don't require MIME-Version header.
1294 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1295 supply the MIME-Version header or deliberately strip it from the mail.
1296 If non-nil (the default), Gnus will treat some articles as MIME
1297 even if the MIME-Version header is missing."
1298 :version "22.1"
1299 :type 'boolean
1300 :group 'gnus-article-mime)
1301
1302 (defcustom gnus-article-emulate-mime t
1303 "If non-nil, use MIME emulation for uuencode and the like.
1304 This means that Gnus will search message bodies for text that look
1305 like uuencoded bits, yEncoded bits, and so on, and present that using
1306 the normal Gnus MIME machinery."
1307 :version "22.1"
1308 :type 'boolean
1309 :group 'gnus-article-mime)
1310
1311 ;;; Internal variables
1312
1313 (defvar gnus-summary-display-cache nil)
1314 (defvar gnus-article-mime-handles nil)
1315 (defvar gnus-article-decoded-p nil)
1316 (defvar gnus-article-charset nil)
1317 (defvar gnus-article-ignored-charsets nil)
1318 (defvar gnus-scores-exclude-files nil)
1319 (defvar gnus-page-broken nil)
1320
1321 (defvar gnus-original-article nil)
1322 (defvar gnus-article-internal-prepare-hook nil)
1323 (defvar gnus-newsgroup-process-stack nil)
1324
1325 (defvar gnus-thread-indent-array nil)
1326 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1327 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1328 "Function called to sort the articles within a thread after it has been gathered together.")
1329
1330 (defvar gnus-summary-save-parts-type-history nil)
1331 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1332
1333 ;; Avoid highlighting in kill files.
1334 (defvar gnus-summary-inhibit-highlight nil)
1335 (defvar gnus-newsgroup-selected-overlay nil)
1336 (defvar gnus-inhibit-limiting nil)
1337 (defvar gnus-newsgroup-adaptive-score-file nil)
1338 (defvar gnus-current-score-file nil)
1339 (defvar gnus-current-move-group nil)
1340 (defvar gnus-current-copy-group nil)
1341 (defvar gnus-current-crosspost-group nil)
1342 (defvar gnus-newsgroup-display nil)
1343
1344 (defvar gnus-newsgroup-dependencies nil)
1345 (defvar gnus-newsgroup-adaptive nil)
1346 (defvar gnus-summary-display-article-function nil)
1347 (defvar gnus-summary-highlight-line-function nil
1348 "Function called after highlighting a summary line.")
1349
1350 (defvar gnus-summary-line-format-alist
1351 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1352 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1353 (?s gnus-tmp-subject-or-nil ?s)
1354 (?n gnus-tmp-name ?s)
1355 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1356 ?s)
1357 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1358 gnus-tmp-from) ?s)
1359 (?F gnus-tmp-from ?s)
1360 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1361 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1362 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1363 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1364 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1365 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1366 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1367 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1368 (?L gnus-tmp-lines ?s)
1369 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1370 0) ?d)
1371 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1372 "") ?s)
1373 (?g (or (gnus-group-short-name
1374 (nnir-article-group (mail-header-number gnus-tmp-header)))
1375 "") ?s)
1376 (?O gnus-tmp-downloaded ?c)
1377 (?I gnus-tmp-indentation ?s)
1378 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1379 (?R gnus-tmp-replied ?c)
1380 (?\[ gnus-tmp-opening-bracket ?c)
1381 (?\] gnus-tmp-closing-bracket ?c)
1382 (?\> (make-string gnus-tmp-level ? ) ?s)
1383 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1384 (?i gnus-tmp-score ?d)
1385 (?z gnus-tmp-score-char ?c)
1386 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1387 (?U gnus-tmp-unread ?c)
1388 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1389 ?s)
1390 (?t (gnus-summary-number-of-articles-in-thread
1391 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1392 ?d)
1393 (?e (gnus-summary-number-of-articles-in-thread
1394 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1395 ?c)
1396 (?u gnus-tmp-user-defined ?s)
1397 (?P (gnus-pick-line-number) ?d)
1398 (?B gnus-tmp-thread-tree-header-string ?s)
1399 (user-date (gnus-user-date
1400 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1401 "An alist of format specifications that can appear in summary lines.
1402 These are paired with what variables they correspond with, along with
1403 the type of the variable (string, integer, character, etc).")
1404
1405 (defvar gnus-summary-dummy-line-format-alist
1406 `((?S gnus-tmp-subject ?s)
1407 (?N gnus-tmp-number ?d)
1408 (?u gnus-tmp-user-defined ?s)))
1409
1410 (defvar gnus-summary-mode-line-format-alist
1411 `((?G gnus-tmp-group-name ?s)
1412 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1413 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1414 (?A gnus-tmp-article-number ?d)
1415 (?Z gnus-tmp-unread-and-unselected ?s)
1416 (?V gnus-version ?s)
1417 (?U gnus-tmp-unread-and-unticked ?d)
1418 (?S gnus-tmp-subject ?s)
1419 (?e gnus-tmp-unselected ?d)
1420 (?u gnus-tmp-user-defined ?s)
1421 (?d (length gnus-newsgroup-dormant) ?d)
1422 (?t (length gnus-newsgroup-marked) ?d)
1423 (?h (length gnus-newsgroup-spam-marked) ?d)
1424 (?r (length gnus-newsgroup-reads) ?d)
1425 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1426 (?E gnus-newsgroup-expunged-tally ?d)
1427 (?s (gnus-current-score-file-nondirectory) ?s)))
1428
1429 ;; This is here rather than in gnus-art for compilation reasons.
1430 (defvar gnus-article-mode-line-format-alist
1431 (nconc '((?w (gnus-article-wash-status) ?s)
1432 (?m (gnus-article-mime-part-status) ?s))
1433 gnus-summary-mode-line-format-alist))
1434
1435 (defvar gnus-last-search-regexp nil
1436 "Default regexp for article search command.")
1437
1438 (defvar gnus-last-shell-command nil
1439 "Default shell command on article.")
1440
1441 (defvar gnus-newsgroup-agentized nil
1442 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1443 (defvar gnus-newsgroup-begin nil)
1444 (defvar gnus-newsgroup-end nil)
1445 (defvar gnus-newsgroup-last-rmail nil)
1446 (defvar gnus-newsgroup-last-mail nil)
1447 (defvar gnus-newsgroup-last-folder nil)
1448 (defvar gnus-newsgroup-last-file nil)
1449 (defvar gnus-newsgroup-last-directory nil)
1450 (defvar gnus-newsgroup-auto-expire nil)
1451 (defvar gnus-newsgroup-active nil)
1452 (defvar gnus-newsgroup-highest nil)
1453
1454 (defvar gnus-newsgroup-data nil)
1455 (defvar gnus-newsgroup-data-reverse nil)
1456 (defvar gnus-newsgroup-limit nil)
1457 (defvar gnus-newsgroup-limits nil)
1458 (defvar gnus-summary-use-undownloaded-faces nil)
1459
1460 (defvar gnus-newsgroup-unreads nil
1461 "Sorted list of unread articles in the current newsgroup.")
1462
1463 (defvar gnus-newsgroup-unselected nil
1464 "Sorted list of unselected unread articles in the current newsgroup.")
1465
1466 (defvar gnus-newsgroup-reads nil
1467 "Alist of read articles and article marks in the current newsgroup.")
1468
1469 (defvar gnus-newsgroup-expunged-tally nil)
1470
1471 (defvar gnus-newsgroup-marked nil
1472 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1473
1474 (defvar gnus-newsgroup-spam-marked nil
1475 "List of ranges of articles that have been marked as spam.")
1476
1477 (defvar gnus-newsgroup-killed nil
1478 "List of ranges of articles that have been through the scoring process.")
1479
1480 (defvar gnus-newsgroup-cached nil
1481 "Sorted list of articles that come from the article cache.")
1482
1483 (defvar gnus-newsgroup-saved nil
1484 "List of articles that have been saved.")
1485
1486 (defvar gnus-newsgroup-kill-headers nil)
1487
1488 (defvar gnus-newsgroup-replied nil
1489 "List of articles that have been replied to in the current newsgroup.")
1490
1491 (defvar gnus-newsgroup-forwarded nil
1492 "List of articles that have been forwarded in the current newsgroup.")
1493
1494 (defvar gnus-newsgroup-expirable nil
1495 "Sorted list of articles in the current newsgroup that can be expired.")
1496
1497 (defvar gnus-newsgroup-processable nil
1498 "List of articles in the current newsgroup that can be processed.")
1499
1500 (defvar gnus-newsgroup-downloadable nil
1501 "Sorted list of articles in the current newsgroup that can be processed.")
1502
1503 (defvar gnus-newsgroup-unfetched nil
1504 "Sorted list of articles in the current newsgroup whose headers have
1505 not been fetched into the agent.
1506
1507 This list will always be a subset of gnus-newsgroup-undownloaded.")
1508
1509 (defvar gnus-newsgroup-undownloaded nil
1510 "List of articles in the current newsgroup that haven't been downloaded.")
1511
1512 (defvar gnus-newsgroup-unsendable nil
1513 "List of articles in the current newsgroup that won't be sent.")
1514
1515 (defvar gnus-newsgroup-bookmarks nil
1516 "List of articles in the current newsgroup that have bookmarks.")
1517
1518 (defvar gnus-newsgroup-dormant nil
1519 "Sorted list of dormant articles in the current newsgroup.")
1520
1521 (defvar gnus-newsgroup-unseen nil
1522 "List of unseen articles in the current newsgroup.")
1523
1524 (defvar gnus-newsgroup-seen nil
1525 "Range of seen articles in the current newsgroup.")
1526
1527 (defvar gnus-newsgroup-articles nil
1528 "List of articles in the current newsgroup.")
1529
1530 (defvar gnus-newsgroup-scored nil
1531 "List of scored articles in the current newsgroup.")
1532
1533 (defvar gnus-newsgroup-headers nil
1534 "List of article headers in the current newsgroup.")
1535
1536 (defvar gnus-newsgroup-threads nil)
1537
1538 (defvar gnus-newsgroup-prepared nil
1539 "Whether the current group has been prepared properly.")
1540
1541 (defvar gnus-newsgroup-ancient nil
1542 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1543
1544 (defvar gnus-newsgroup-sparse nil)
1545
1546 (defvar gnus-current-article nil)
1547 (defvar gnus-article-current nil)
1548 (defvar gnus-current-headers nil)
1549 (defvar gnus-have-all-headers nil)
1550 (defvar gnus-last-article nil)
1551 (defvar gnus-newsgroup-history nil)
1552 (defvar gnus-newsgroup-charset nil)
1553 (defvar gnus-newsgroup-ephemeral-charset nil)
1554 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1555
1556 (defvar gnus-article-before-search nil)
1557
1558 (defvar gnus-summary-local-variables
1559 '(gnus-newsgroup-name
1560
1561 ;; Marks lists
1562 gnus-newsgroup-unreads
1563 gnus-newsgroup-unselected
1564 gnus-newsgroup-marked
1565 gnus-newsgroup-spam-marked
1566 gnus-newsgroup-reads
1567 gnus-newsgroup-saved
1568 gnus-newsgroup-replied
1569 gnus-newsgroup-forwarded
1570 gnus-newsgroup-expirable
1571 gnus-newsgroup-killed
1572 gnus-newsgroup-unseen
1573 gnus-newsgroup-seen
1574 gnus-newsgroup-cached
1575 gnus-newsgroup-downloadable
1576 gnus-newsgroup-undownloaded
1577 gnus-newsgroup-unsendable
1578
1579 gnus-newsgroup-begin gnus-newsgroup-end
1580 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1581 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1582 gnus-newsgroup-last-directory
1583 gnus-newsgroup-auto-expire
1584 gnus-newsgroup-processable
1585 gnus-newsgroup-unfetched
1586 gnus-newsgroup-articles
1587 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1588 gnus-newsgroup-headers gnus-newsgroup-threads
1589 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1590 gnus-current-article gnus-current-headers gnus-have-all-headers
1591 gnus-last-article gnus-article-internal-prepare-hook
1592 (gnus-summary-article-delete-hook . global)
1593 (gnus-summary-article-move-hook . global)
1594 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1595 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1596 gnus-thread-expunge-below
1597 gnus-score-alist gnus-current-score-file
1598 (gnus-summary-expunge-below . global)
1599 (gnus-summary-mark-below . global)
1600 (gnus-orphan-score . global)
1601 gnus-newsgroup-active gnus-scores-exclude-files
1602 gnus-newsgroup-highest
1603 gnus-newsgroup-history gnus-newsgroup-ancient
1604 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1605 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1606 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1607 (gnus-newsgroup-expunged-tally . 0)
1608 gnus-cache-removable-articles
1609 gnus-newsgroup-data gnus-newsgroup-data-reverse
1610 gnus-newsgroup-limit gnus-newsgroup-limits
1611 gnus-newsgroup-charset gnus-newsgroup-display
1612 gnus-summary-use-undownloaded-faces)
1613 "Variables that are buffer-local to the summary buffers.")
1614
1615 (defvar gnus-newsgroup-variables nil
1616 "A list of variables that have separate values in different newsgroups.
1617 A list of newsgroup (summary buffer) local variables, or cons of
1618 variables and their default expressions to be evalled (when the default
1619 values are not nil), that should be made global while the summary buffer
1620 is active.
1621
1622 Note: The default expressions will be evaluated (using function `eval')
1623 before assignment to the local variable rather than just assigned to it.
1624 If the default expression is the symbol `global', that symbol will not
1625 be evaluated but the global value of the local variable will be used
1626 instead.
1627
1628 These variables can be used to set variables in the group parameters
1629 while still allowing them to affect operations done in other buffers.
1630 For example:
1631
1632 \(setq gnus-newsgroup-variables
1633 '(message-use-followup-to
1634 (gnus-visible-headers .
1635 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1636 ")
1637
1638 (eval-when-compile
1639 ;; Bind features so that require will believe that gnus-sum has
1640 ;; already been loaded (avoids infinite recursion)
1641 (let ((features (cons 'gnus-sum features)))
1642 (require 'gnus-art)))
1643
1644 ;; MIME stuff.
1645
1646 (defvar gnus-decode-encoded-word-methods
1647 '(mail-decode-encoded-word-string)
1648 "List of methods used to decode encoded words.
1649
1650 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1651 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1652 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1653 whose names match REGEXP.
1654
1655 For example:
1656 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1657 mail-decode-encoded-word-string
1658 (\"chinese\" . rfc1843-decode-string))")
1659
1660 (defvar gnus-decode-encoded-word-methods-cache nil)
1661
1662 (defun gnus-multi-decode-encoded-word-string (string)
1663 "Apply the functions from `gnus-encoded-word-methods' that match."
1664 (unless (and gnus-decode-encoded-word-methods-cache
1665 (eq gnus-newsgroup-name
1666 (car gnus-decode-encoded-word-methods-cache)))
1667 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1668 (dolist (method gnus-decode-encoded-word-methods)
1669 (if (symbolp method)
1670 (nconc gnus-decode-encoded-word-methods-cache (list method))
1671 (if (and gnus-newsgroup-name
1672 (string-match (car method) gnus-newsgroup-name))
1673 (nconc gnus-decode-encoded-word-methods-cache
1674 (list (cdr method)))))))
1675 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1676 (setq string (funcall method string))))
1677
1678 ;; Subject simplification.
1679
1680 (defun gnus-simplify-whitespace (str)
1681 "Remove excessive whitespace from STR."
1682 ;; Multiple spaces.
1683 (while (string-match "[ \t][ \t]+" str)
1684 (setq str (concat (substring str 0 (match-beginning 0))
1685 " "
1686 (substring str (match-end 0)))))
1687 ;; Leading spaces.
1688 (when (string-match "^[ \t]+" str)
1689 (setq str (substring str (match-end 0))))
1690 ;; Trailing spaces.
1691 (when (string-match "[ \t]+$" str)
1692 (setq str (substring str 0 (match-beginning 0))))
1693 str)
1694
1695 (defun gnus-simplify-all-whitespace (str)
1696 "Remove all whitespace from STR."
1697 (while (string-match "[ \t\n]+" str)
1698 (setq str (replace-match "" nil nil str)))
1699 str)
1700
1701 (defsubst gnus-simplify-subject-re (subject)
1702 "Remove \"Re:\" from subject lines."
1703 (if (string-match message-subject-re-regexp subject)
1704 (substring subject (match-end 0))
1705 subject))
1706
1707 (defun gnus-simplify-subject (subject &optional re-only)
1708 "Remove `Re:' and words in parentheses.
1709 If RE-ONLY is non-nil, strip leading `Re:'s only."
1710 (let ((case-fold-search t)) ;Ignore case.
1711 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1712 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1713 (setq subject (substring subject (match-end 0))))
1714 ;; Remove uninteresting prefixes.
1715 (when (and (not re-only)
1716 gnus-simplify-ignored-prefixes
1717 (string-match gnus-simplify-ignored-prefixes subject))
1718 (setq subject (substring subject (match-end 0))))
1719 ;; Remove words in parentheses from end.
1720 (unless re-only
1721 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1722 (setq subject (substring subject 0 (match-beginning 0)))))
1723 ;; Return subject string.
1724 subject))
1725
1726 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1727 ;; all whitespace.
1728 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1729 (goto-char (point-min))
1730 (while (re-search-forward regexp nil t)
1731 (replace-match (or newtext ""))))
1732
1733 (defun gnus-simplify-buffer-fuzzy (regexp)
1734 "Simplify string in the buffer fuzzily.
1735 The string in the accessible portion of the current buffer is simplified.
1736 It is assumed to be a single-line subject.
1737 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1738 matter is removed. Additional things can be deleted by setting
1739 `gnus-simplify-subject-fuzzy-regexp'."
1740 (let ((case-fold-search t)
1741 (modified-tick))
1742 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1743
1744 (while (not (eq modified-tick (buffer-modified-tick)))
1745 (setq modified-tick (buffer-modified-tick))
1746 (cond
1747 ((listp regexp)
1748 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1749 (regexp
1750 (gnus-simplify-buffer-fuzzy-step regexp)))
1751 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1752 (gnus-simplify-buffer-fuzzy-step
1753 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1754 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1755
1756 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1757 (gnus-simplify-buffer-fuzzy-step " +" " ")
1758 (gnus-simplify-buffer-fuzzy-step " $")
1759 (gnus-simplify-buffer-fuzzy-step "^ +")))
1760
1761 (defun gnus-simplify-subject-fuzzy (subject)
1762 "Simplify a subject string fuzzily.
1763 See `gnus-simplify-buffer-fuzzy' for details."
1764 (save-excursion
1765 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1766 (gnus-set-work-buffer)
1767 (let ((case-fold-search t))
1768 ;; Remove uninteresting prefixes.
1769 (when (and gnus-simplify-ignored-prefixes
1770 (string-match gnus-simplify-ignored-prefixes subject))
1771 (setq subject (substring subject (match-end 0))))
1772 (insert subject)
1773 (inline (gnus-simplify-buffer-fuzzy regexp))
1774 (buffer-string)))))
1775
1776 (defsubst gnus-simplify-subject-fully (subject)
1777 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1778 (cond
1779 (gnus-simplify-subject-functions
1780 (gnus-map-function gnus-simplify-subject-functions subject))
1781 ((null gnus-summary-gather-subject-limit)
1782 (gnus-simplify-subject-re subject))
1783 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1784 (gnus-simplify-subject-fuzzy subject))
1785 ((numberp gnus-summary-gather-subject-limit)
1786 (truncate-string-to-width (gnus-simplify-subject-re subject)
1787 gnus-summary-gather-subject-limit))
1788 (t
1789 subject)))
1790
1791 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1792 "Check whether two subjects are equal.
1793 If optional argument SIMPLE-FIRST is t, first argument is already
1794 simplified."
1795 (cond
1796 ((null simple-first)
1797 (equal (gnus-simplify-subject-fully s1)
1798 (gnus-simplify-subject-fully s2)))
1799 (t
1800 (equal s1
1801 (gnus-simplify-subject-fully s2)))))
1802
1803 (defun gnus-summary-bubble-group ()
1804 "Increase the score of the current group.
1805 This is a handy function to add to `gnus-summary-exit-hook' to
1806 increase the score of each group you read."
1807 (gnus-group-add-score gnus-newsgroup-name))
1808
1809 \f
1810 ;;;
1811 ;;; Gnus summary mode
1812 ;;;
1813
1814 (put 'gnus-summary-mode 'mode-class 'special)
1815
1816 (defvar gnus-article-commands-menu)
1817
1818 ;; Non-orthogonal keys
1819
1820 (gnus-define-keys gnus-summary-mode-map
1821 " " gnus-summary-next-page
1822 "\177" gnus-summary-prev-page
1823 [delete] gnus-summary-prev-page
1824 [backspace] gnus-summary-prev-page
1825 "\r" gnus-summary-scroll-up
1826 "\M-\r" gnus-summary-scroll-down
1827 "n" gnus-summary-next-unread-article
1828 "p" gnus-summary-prev-unread-article
1829 "N" gnus-summary-next-article
1830 "P" gnus-summary-prev-article
1831 "\M-\C-n" gnus-summary-next-same-subject
1832 "\M-\C-p" gnus-summary-prev-same-subject
1833 "\M-n" gnus-summary-next-unread-subject
1834 "\M-p" gnus-summary-prev-unread-subject
1835 "." gnus-summary-first-unread-article
1836 "," gnus-summary-best-unread-article
1837 "\M-s" gnus-summary-search-article-forward
1838 "\M-r" gnus-summary-search-article-backward
1839 "\M-S" gnus-summary-repeat-search-article-forward
1840 "\M-R" gnus-summary-repeat-search-article-backward
1841 "<" gnus-summary-beginning-of-article
1842 ">" gnus-summary-end-of-article
1843 "j" gnus-summary-goto-article
1844 "^" gnus-summary-refer-parent-article
1845 "\M-^" gnus-summary-refer-article
1846 "u" gnus-summary-tick-article-forward
1847 "!" gnus-summary-tick-article-forward
1848 "U" gnus-summary-tick-article-backward
1849 "d" gnus-summary-mark-as-read-forward
1850 "D" gnus-summary-mark-as-read-backward
1851 "E" gnus-summary-mark-as-expirable
1852 "\M-u" gnus-summary-clear-mark-forward
1853 "\M-U" gnus-summary-clear-mark-backward
1854 "k" gnus-summary-kill-same-subject-and-select
1855 "\C-k" gnus-summary-kill-same-subject
1856 "\M-\C-k" gnus-summary-kill-thread
1857 "\M-\C-l" gnus-summary-lower-thread
1858 "e" gnus-summary-edit-article
1859 "#" gnus-summary-mark-as-processable
1860 "\M-#" gnus-summary-unmark-as-processable
1861 "\M-\C-t" gnus-summary-toggle-threads
1862 "\M-\C-s" gnus-summary-show-thread
1863 "\M-\C-h" gnus-summary-hide-thread
1864 "\M-\C-f" gnus-summary-next-thread
1865 "\M-\C-b" gnus-summary-prev-thread
1866 [(meta down)] gnus-summary-next-thread
1867 [(meta up)] gnus-summary-prev-thread
1868 "\M-\C-u" gnus-summary-up-thread
1869 "\M-\C-d" gnus-summary-down-thread
1870 "&" gnus-summary-execute-command
1871 "c" gnus-summary-catchup-and-exit
1872 "\C-w" gnus-summary-mark-region-as-read
1873 "\C-t" gnus-summary-toggle-truncation
1874 "?" gnus-summary-mark-as-dormant
1875 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1876 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1877 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1878 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1879 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1880 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1881 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1882 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1883 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1884 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1885 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1886 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1887 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1888 "=" gnus-summary-expand-window
1889 "\C-x\C-s" gnus-summary-reselect-current-group
1890 "\M-g" gnus-summary-rescan-group
1891 "\C-c\C-r" gnus-summary-caesar-message
1892 "f" gnus-summary-followup
1893 "F" gnus-summary-followup-with-original
1894 "C" gnus-summary-cancel-article
1895 "r" gnus-summary-reply
1896 "R" gnus-summary-reply-with-original
1897 "\C-c\C-f" gnus-summary-mail-forward
1898 "o" gnus-summary-save-article
1899 "\C-o" gnus-summary-save-article-mail
1900 "|" gnus-summary-pipe-output
1901 "\M-k" gnus-summary-edit-local-kill
1902 "\M-K" gnus-summary-edit-global-kill
1903 ;; "V" gnus-version
1904 "\C-c\C-d" gnus-summary-describe-group
1905 "q" gnus-summary-exit
1906 "Q" gnus-summary-exit-no-update
1907 "\C-c\C-i" gnus-info-find-node
1908 gnus-mouse-2 gnus-mouse-pick-article
1909 [follow-link] mouse-face
1910 "m" gnus-summary-mail-other-window
1911 "a" gnus-summary-post-news
1912 "x" gnus-summary-limit-to-unread
1913 "s" gnus-summary-isearch-article
1914 "\t" gnus-summary-widget-forward
1915 [backtab] gnus-summary-widget-backward
1916 "t" gnus-summary-toggle-header
1917 "g" gnus-summary-show-article
1918 "l" gnus-summary-goto-last-article
1919 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1920 "\C-d" gnus-summary-enter-digest-group
1921 "\M-\C-d" gnus-summary-read-document
1922 "\M-\C-e" gnus-summary-edit-parameters
1923 "\M-\C-a" gnus-summary-customize-parameters
1924 "\C-c\C-b" gnus-bug
1925 "*" gnus-cache-enter-article
1926 "\M-*" gnus-cache-remove-article
1927 "\M-&" gnus-summary-universal-argument
1928 "\C-l" gnus-recenter
1929 "I" gnus-summary-increase-score
1930 "L" gnus-summary-lower-score
1931 "\M-i" gnus-symbolic-argument
1932 "h" gnus-summary-select-article-buffer
1933
1934 "b" gnus-article-view-part
1935 "\M-t" gnus-summary-toggle-display-buttonized
1936
1937 "V" gnus-summary-score-map
1938 "X" gnus-uu-extract-map
1939 "S" gnus-summary-send-map)
1940
1941 ;; Sort of orthogonal keymap
1942 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1943 "t" gnus-summary-tick-article-forward
1944 "!" gnus-summary-tick-article-forward
1945 "d" gnus-summary-mark-as-read-forward
1946 "r" gnus-summary-mark-as-read-forward
1947 "c" gnus-summary-clear-mark-forward
1948 " " gnus-summary-clear-mark-forward
1949 "e" gnus-summary-mark-as-expirable
1950 "x" gnus-summary-mark-as-expirable
1951 "?" gnus-summary-mark-as-dormant
1952 "b" gnus-summary-set-bookmark
1953 "B" gnus-summary-remove-bookmark
1954 "#" gnus-summary-mark-as-processable
1955 "\M-#" gnus-summary-unmark-as-processable
1956 "S" gnus-summary-limit-include-expunged
1957 "C" gnus-summary-catchup
1958 "H" gnus-summary-catchup-to-here
1959 "h" gnus-summary-catchup-from-here
1960 "\C-c" gnus-summary-catchup-all
1961 "k" gnus-summary-kill-same-subject-and-select
1962 "K" gnus-summary-kill-same-subject
1963 "P" gnus-uu-mark-map)
1964
1965 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1966 "c" gnus-summary-clear-above
1967 "u" gnus-summary-tick-above
1968 "m" gnus-summary-mark-above
1969 "k" gnus-summary-kill-below)
1970
1971 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1972 "/" gnus-summary-limit-to-subject
1973 "n" gnus-summary-limit-to-articles
1974 "b" gnus-summary-limit-to-bodies
1975 "h" gnus-summary-limit-to-headers
1976 "w" gnus-summary-pop-limit
1977 "s" gnus-summary-limit-to-subject
1978 "a" gnus-summary-limit-to-author
1979 "u" gnus-summary-limit-to-unread
1980 "m" gnus-summary-limit-to-marks
1981 "M" gnus-summary-limit-exclude-marks
1982 "v" gnus-summary-limit-to-score
1983 "*" gnus-summary-limit-include-cached
1984 "D" gnus-summary-limit-include-dormant
1985 "T" gnus-summary-limit-include-thread
1986 "d" gnus-summary-limit-exclude-dormant
1987 "t" gnus-summary-limit-to-age
1988 "." gnus-summary-limit-to-unseen
1989 "x" gnus-summary-limit-to-extra
1990 "p" gnus-summary-limit-to-display-predicate
1991 "E" gnus-summary-limit-include-expunged
1992 "c" gnus-summary-limit-exclude-childless-dormant
1993 "C" gnus-summary-limit-mark-excluded-as-read
1994 "o" gnus-summary-insert-old-articles
1995 "N" gnus-summary-insert-new-articles
1996 "S" gnus-summary-limit-to-singletons
1997 "r" gnus-summary-limit-to-replied
1998 "R" gnus-summary-limit-to-recipient
1999 "A" gnus-summary-limit-to-address)
2000
2001 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2002 "n" gnus-summary-next-unread-article
2003 "p" gnus-summary-prev-unread-article
2004 "N" gnus-summary-next-article
2005 "P" gnus-summary-prev-article
2006 "\C-n" gnus-summary-next-same-subject
2007 "\C-p" gnus-summary-prev-same-subject
2008 "\M-n" gnus-summary-next-unread-subject
2009 "\M-p" gnus-summary-prev-unread-subject
2010 "f" gnus-summary-first-unread-article
2011 "b" gnus-summary-best-unread-article
2012 "j" gnus-summary-goto-article
2013 "g" gnus-summary-goto-subject
2014 "l" gnus-summary-goto-last-article
2015 "o" gnus-summary-pop-article)
2016
2017 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2018 "k" gnus-summary-kill-thread
2019 "E" gnus-summary-expire-thread
2020 "l" gnus-summary-lower-thread
2021 "i" gnus-summary-raise-thread
2022 "T" gnus-summary-toggle-threads
2023 "t" gnus-summary-rethread-current
2024 "^" gnus-summary-reparent-thread
2025 "\M-^" gnus-summary-reparent-children
2026 "s" gnus-summary-show-thread
2027 "S" gnus-summary-show-all-threads
2028 "h" gnus-summary-hide-thread
2029 "H" gnus-summary-hide-all-threads
2030 "n" gnus-summary-next-thread
2031 "p" gnus-summary-prev-thread
2032 "u" gnus-summary-up-thread
2033 "o" gnus-summary-top-thread
2034 "d" gnus-summary-down-thread
2035 "#" gnus-uu-mark-thread
2036 "\M-#" gnus-uu-unmark-thread)
2037
2038 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2039 "g" gnus-summary-prepare
2040 "c" gnus-summary-insert-cached-articles
2041 "d" gnus-summary-insert-dormant-articles
2042 "t" gnus-summary-insert-ticked-articles)
2043
2044 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2045 "c" gnus-summary-catchup-and-exit
2046 "C" gnus-summary-catchup-all-and-exit
2047 "E" gnus-summary-exit-no-update
2048 "Q" gnus-summary-exit
2049 "Z" gnus-summary-exit
2050 "n" gnus-summary-catchup-and-goto-next-group
2051 "p" gnus-summary-catchup-and-goto-prev-group
2052 "R" gnus-summary-reselect-current-group
2053 "G" gnus-summary-rescan-group
2054 "N" gnus-summary-next-group
2055 "s" gnus-summary-save-newsrc
2056 "P" gnus-summary-prev-group)
2057
2058 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2059 " " gnus-summary-next-page
2060 "n" gnus-summary-next-page
2061 "\177" gnus-summary-prev-page
2062 [delete] gnus-summary-prev-page
2063 "p" gnus-summary-prev-page
2064 "\r" gnus-summary-scroll-up
2065 "\M-\r" gnus-summary-scroll-down
2066 "<" gnus-summary-beginning-of-article
2067 ">" gnus-summary-end-of-article
2068 "b" gnus-summary-beginning-of-article
2069 "e" gnus-summary-end-of-article
2070 "^" gnus-summary-refer-parent-article
2071 "r" gnus-summary-refer-parent-article
2072 "C" gnus-summary-show-complete-article
2073 "D" gnus-summary-enter-digest-group
2074 "R" gnus-summary-refer-references
2075 "T" gnus-summary-refer-thread
2076 "W" gnus-warp-to-article
2077 "g" gnus-summary-show-article
2078 "s" gnus-summary-isearch-article
2079 "\t" gnus-summary-widget-forward
2080 [backtab] gnus-summary-widget-backward
2081 "P" gnus-summary-print-article
2082 "S" gnus-sticky-article
2083 "M" gnus-mailing-list-insinuate
2084 "t" gnus-article-babel)
2085
2086 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2087 "b" gnus-article-add-buttons
2088 "B" gnus-article-add-buttons-to-head
2089 "o" gnus-article-treat-overstrike
2090 "e" gnus-article-emphasize
2091 "w" gnus-article-fill-cited-article
2092 "Q" gnus-article-fill-long-lines
2093 "L" gnus-article-toggle-truncate-lines
2094 "C" gnus-article-capitalize-sentences
2095 "c" gnus-article-remove-cr
2096 "q" gnus-article-de-quoted-unreadable
2097 "6" gnus-article-de-base64-unreadable
2098 "Z" gnus-article-decode-HZ
2099 "A" gnus-article-treat-ansi-sequences
2100 "h" gnus-article-wash-html
2101 "u" gnus-article-unsplit-urls
2102 "s" gnus-summary-force-verify-and-decrypt
2103 "f" gnus-article-display-x-face
2104 "l" gnus-summary-stop-page-breaking
2105 "r" gnus-summary-caesar-message
2106 "m" gnus-summary-morse-message
2107 "t" gnus-summary-toggle-header
2108 "g" gnus-treat-smiley
2109 "v" gnus-summary-verbose-headers
2110 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2111 "p" gnus-article-verify-x-pgp-sig
2112 "d" gnus-article-treat-dumbquotes
2113 "U" gnus-article-treat-non-ascii
2114 "i" gnus-summary-idna-message)
2115
2116 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2117 ;; mnemonic: deuglif*Y*
2118 "u" gnus-article-outlook-unwrap-lines
2119 "a" gnus-article-outlook-repair-attribution
2120 "c" gnus-article-outlook-rearrange-citation
2121 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2122
2123 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2124 "a" gnus-article-hide
2125 "h" gnus-article-hide-headers
2126 "b" gnus-article-hide-boring-headers
2127 "s" gnus-article-hide-signature
2128 "c" gnus-article-hide-citation
2129 "C" gnus-article-hide-citation-in-followups
2130 "l" gnus-article-hide-list-identifiers
2131 "B" gnus-article-strip-banner
2132 "P" gnus-article-hide-pem
2133 "\C-c" gnus-article-hide-citation-maybe)
2134
2135 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2136 "a" gnus-article-highlight
2137 "h" gnus-article-highlight-headers
2138 "c" gnus-article-highlight-citation
2139 "s" gnus-article-highlight-signature)
2140
2141 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2142 "f" gnus-article-treat-fold-headers
2143 "u" gnus-article-treat-unfold-headers
2144 "n" gnus-article-treat-fold-newsgroups)
2145
2146 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2147 "x" gnus-article-display-x-face
2148 "d" gnus-article-display-face
2149 "s" gnus-treat-smiley
2150 "D" gnus-article-remove-images
2151 "W" gnus-article-show-images
2152 "f" gnus-treat-from-picon
2153 "m" gnus-treat-mail-picon
2154 "n" gnus-treat-newsgroups-picon
2155 "g" gnus-treat-from-gravatar
2156 "h" gnus-treat-mail-gravatar)
2157
2158 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2159 "w" gnus-article-decode-mime-words
2160 "c" gnus-article-decode-charset
2161 "v" gnus-mime-view-all-parts
2162 "b" gnus-article-view-part)
2163
2164 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2165 "z" gnus-article-date-ut
2166 "u" gnus-article-date-ut
2167 "l" gnus-article-date-local
2168 "p" gnus-article-date-english
2169 "e" gnus-article-date-lapsed
2170 "o" gnus-article-date-original
2171 "i" gnus-article-date-iso8601
2172 "s" gnus-article-date-user)
2173
2174 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2175 "t" gnus-article-remove-trailing-blank-lines
2176 "l" gnus-article-strip-leading-blank-lines
2177 "m" gnus-article-strip-multiple-blank-lines
2178 "a" gnus-article-strip-blank-lines
2179 "A" gnus-article-strip-all-blank-lines
2180 "s" gnus-article-strip-leading-space
2181 "e" gnus-article-strip-trailing-space
2182 "w" gnus-article-remove-leading-whitespace)
2183
2184 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2185 "v" gnus-version
2186 "d" gnus-summary-describe-group
2187 "h" gnus-summary-describe-briefly
2188 "i" gnus-info-find-node)
2189
2190 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2191 "e" gnus-summary-expire-articles
2192 "\M-\C-e" gnus-summary-expire-articles-now
2193 "\177" gnus-summary-delete-article
2194 [delete] gnus-summary-delete-article
2195 [backspace] gnus-summary-delete-article
2196 "m" gnus-summary-move-article
2197 "r" gnus-summary-respool-article
2198 "w" gnus-summary-edit-article
2199 "c" gnus-summary-copy-article
2200 "B" gnus-summary-crosspost-article
2201 "q" gnus-summary-respool-query
2202 "t" gnus-summary-respool-trace
2203 "i" gnus-summary-import-article
2204 "I" gnus-summary-create-article
2205 "p" gnus-summary-article-posted-p)
2206
2207 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2208 "o" gnus-summary-save-article
2209 "m" gnus-summary-save-article-mail
2210 "F" gnus-summary-write-article-file
2211 "r" gnus-summary-save-article-rmail
2212 "f" gnus-summary-save-article-file
2213 "b" gnus-summary-save-article-body-file
2214 "B" gnus-summary-write-article-body-file
2215 "h" gnus-summary-save-article-folder
2216 "v" gnus-summary-save-article-vm
2217 "p" gnus-summary-pipe-output
2218 "P" gnus-summary-muttprint)
2219
2220 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2221 "b" gnus-summary-display-buttonized
2222 "m" gnus-summary-repair-multipart
2223 "v" gnus-article-view-part
2224 "o" gnus-article-save-part
2225 "O" gnus-article-save-part-and-strip
2226 "r" gnus-article-replace-part
2227 "d" gnus-article-delete-part
2228 "t" gnus-article-view-part-as-type
2229 "j" gnus-article-jump-to-part
2230 "c" gnus-article-copy-part
2231 "C" gnus-article-view-part-as-charset
2232 "e" gnus-article-view-part-externally
2233 "H" gnus-article-browse-html-article
2234 "E" gnus-article-encrypt-body
2235 "i" gnus-article-inline-part
2236 "|" gnus-article-pipe-part)
2237
2238 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2239 "p" gnus-summary-mark-as-processable
2240 "u" gnus-summary-unmark-as-processable
2241 "U" gnus-summary-unmark-all-processable
2242 "v" gnus-uu-mark-over
2243 "s" gnus-uu-mark-series
2244 "r" gnus-uu-mark-region
2245 "g" gnus-uu-unmark-region
2246 "R" gnus-uu-mark-by-regexp
2247 "G" gnus-uu-unmark-by-regexp
2248 "t" gnus-uu-mark-thread
2249 "T" gnus-uu-unmark-thread
2250 "a" gnus-uu-mark-all
2251 "b" gnus-uu-mark-buffer
2252 "S" gnus-uu-mark-sparse
2253 "k" gnus-summary-kill-process-mark
2254 "y" gnus-summary-yank-process-mark
2255 "w" gnus-summary-save-process-mark
2256 "i" gnus-uu-invert-processable)
2257
2258 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2259 ;;"x" gnus-uu-extract-any
2260 "m" gnus-summary-save-parts
2261 "u" gnus-uu-decode-uu
2262 "U" gnus-uu-decode-uu-and-save
2263 "s" gnus-uu-decode-unshar
2264 "S" gnus-uu-decode-unshar-and-save
2265 "o" gnus-uu-decode-save
2266 "O" gnus-uu-decode-save
2267 "b" gnus-uu-decode-binhex
2268 "B" gnus-uu-decode-binhex
2269 "Y" gnus-uu-decode-yenc
2270 "p" gnus-uu-decode-postscript
2271 "P" gnus-uu-decode-postscript-and-save)
2272
2273 (gnus-define-keys
2274 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2275 "u" gnus-uu-decode-uu-view
2276 "U" gnus-uu-decode-uu-and-save-view
2277 "s" gnus-uu-decode-unshar-view
2278 "S" gnus-uu-decode-unshar-and-save-view
2279 "o" gnus-uu-decode-save-view
2280 "O" gnus-uu-decode-save-view
2281 "b" gnus-uu-decode-binhex-view
2282 "B" gnus-uu-decode-binhex-view
2283 "p" gnus-uu-decode-postscript-view
2284 "P" gnus-uu-decode-postscript-and-save-view)
2285
2286 (defvar gnus-article-post-menu nil)
2287
2288 (defconst gnus-summary-menu-maxlen 20)
2289
2290 (defun gnus-summary-menu-split (menu)
2291 ;; If we have lots of elements, divide them into groups of 20
2292 ;; and make a pane (or submenu) for each one.
2293 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2294 (let ((menu menu) sublists next
2295 (i 1))
2296 (while menu
2297 ;; Pull off the next gnus-summary-menu-maxlen elements
2298 ;; and make them the next element of sublist.
2299 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2300 (if next
2301 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2302 nil))
2303 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2304 (aref (car (last menu)) 0)) menu)
2305 sublists))
2306 (setq i (1+ i))
2307 (setq menu next))
2308 (nreverse sublists))
2309 ;; Few elements--put them all in one pane.
2310 menu))
2311
2312 (defun gnus-summary-make-menu-bar ()
2313 (gnus-turn-off-edit-menu 'summary)
2314
2315 (unless (boundp 'gnus-summary-misc-menu)
2316
2317 (easy-menu-define
2318 gnus-summary-kill-menu gnus-summary-mode-map ""
2319 (cons
2320 "Score"
2321 (nconc
2322 (list
2323 ["Customize" gnus-score-customize t])
2324 (gnus-make-score-map 'increase)
2325 (gnus-make-score-map 'lower)
2326 '(("Mark"
2327 ["Kill below" gnus-summary-kill-below t]
2328 ["Mark above" gnus-summary-mark-above t]
2329 ["Tick above" gnus-summary-tick-above t]
2330 ["Clear above" gnus-summary-clear-above t])
2331 ["Current score" gnus-summary-current-score t]
2332 ["Set score" gnus-summary-set-score t]
2333 ["Switch current score file..." gnus-score-change-score-file t]
2334 ["Set mark below..." gnus-score-set-mark-below t]
2335 ["Set expunge below..." gnus-score-set-expunge-below t]
2336 ["Edit current score file" gnus-score-edit-current-scores t]
2337 ["Edit score file..." gnus-score-edit-file t]
2338 ["Trace score" gnus-score-find-trace t]
2339 ["Find words" gnus-score-find-favourite-words t]
2340 ["Rescore buffer" gnus-summary-rescore t]
2341 ["Increase score..." gnus-summary-increase-score t]
2342 ["Lower score..." gnus-summary-lower-score t]))))
2343
2344 ;; Define both the Article menu in the summary buffer and the
2345 ;; equivalent Commands menu in the article buffer here for
2346 ;; consistency.
2347 (let ((innards
2348 `(("Hide"
2349 ["All" gnus-article-hide t]
2350 ["Headers" gnus-article-hide-headers t]
2351 ["Signature" gnus-article-hide-signature t]
2352 ["Citation" gnus-article-hide-citation t]
2353 ["List identifiers" gnus-article-hide-list-identifiers t]
2354 ["Banner" gnus-article-strip-banner t]
2355 ["Boring headers" gnus-article-hide-boring-headers t])
2356 ("Highlight"
2357 ["All" gnus-article-highlight t]
2358 ["Headers" gnus-article-highlight-headers t]
2359 ["Signature" gnus-article-highlight-signature t]
2360 ["Citation" gnus-article-highlight-citation t])
2361 ("MIME"
2362 ["Words" gnus-article-decode-mime-words t]
2363 ["Charset" gnus-article-decode-charset t]
2364 ["QP" gnus-article-de-quoted-unreadable t]
2365 ["Base64" gnus-article-de-base64-unreadable t]
2366 ["View MIME buttons" gnus-summary-display-buttonized t]
2367 ["View all" gnus-mime-view-all-parts t]
2368 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2369 ["Encrypt body" gnus-article-encrypt-body
2370 :active (not (gnus-group-read-only-p))
2371 ,@(if (featurep 'xemacs) nil
2372 '(:help "Encrypt the message body on disk"))]
2373 ["Extract all parts..." gnus-summary-save-parts t]
2374 ("Multipart"
2375 ["Repair multipart" gnus-summary-repair-multipart t]
2376 ["Pipe part..." gnus-article-pipe-part t]
2377 ["Inline part" gnus-article-inline-part t]
2378 ["View part as type..." gnus-article-view-part-as-type t]
2379 ["Encrypt body" gnus-article-encrypt-body
2380 :active (not (gnus-group-read-only-p))
2381 ,@(if (featurep 'xemacs) nil
2382 '(:help "Encrypt the message body on disk"))]
2383 ["View part externally" gnus-article-view-part-externally t]
2384 ["View HTML parts in browser" gnus-article-browse-html-article t]
2385 ["View part with charset..." gnus-article-view-part-as-charset t]
2386 ["Copy part" gnus-article-copy-part t]
2387 ["Save part..." gnus-article-save-part t]
2388 ["View part" gnus-article-view-part t]))
2389 ("Date"
2390 ["Local" gnus-article-date-local t]
2391 ["ISO8601" gnus-article-date-iso8601 t]
2392 ["UT" gnus-article-date-ut t]
2393 ["Original" gnus-article-date-original t]
2394 ["Lapsed" gnus-article-date-lapsed t]
2395 ["User-defined" gnus-article-date-user t])
2396 ("Display"
2397 ["Remove images" gnus-article-remove-images t]
2398 ["Toggle smiley" gnus-treat-smiley t]
2399 ["Show X-Face" gnus-article-display-x-face t]
2400 ["Show picons in From" gnus-treat-from-picon t]
2401 ["Show picons in mail headers" gnus-treat-mail-picon t]
2402 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2403 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2404 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2405 ("View as different encoding"
2406 ,@(gnus-summary-menu-split
2407 (mapcar
2408 (lambda (cs)
2409 ;; Since easymenu under Emacs doesn't allow
2410 ;; lambda forms for menu commands, we should
2411 ;; provide intern'ed function symbols.
2412 (let ((command (intern (format "\
2413 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2414 (fset command
2415 `(lambda ()
2416 (interactive)
2417 (let ((gnus-summary-show-article-charset-alist
2418 '((1 . ,cs))))
2419 (gnus-summary-show-article 1))))
2420 `[,(symbol-name cs) ,command t]))
2421 (sort (if (fboundp 'coding-system-list)
2422 (coding-system-list)
2423 (mapcar 'car mm-mime-mule-charset-alist))
2424 'string<)))))
2425 ("Washing"
2426 ("Remove Blanks"
2427 ["Leading" gnus-article-strip-leading-blank-lines t]
2428 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2429 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2430 ["All of the above" gnus-article-strip-blank-lines t]
2431 ["All" gnus-article-strip-all-blank-lines t]
2432 ["Leading space" gnus-article-strip-leading-space t]
2433 ["Trailing space" gnus-article-strip-trailing-space t]
2434 ["Leading space in headers"
2435 gnus-article-remove-leading-whitespace t])
2436 ["Overstrike" gnus-article-treat-overstrike t]
2437 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2438 ["Non-ASCII" gnus-article-treat-non-ascii t]
2439 ["Emphasis" gnus-article-emphasize t]
2440 ["Word wrap" gnus-article-fill-cited-article t]
2441 ["Fill long lines" gnus-article-fill-long-lines t]
2442 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2443 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2444 ["Remove CR" gnus-article-remove-cr t]
2445 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2446 ["Base64" gnus-article-de-base64-unreadable t]
2447 ["Rot 13" gnus-summary-caesar-message
2448 ,@(if (featurep 'xemacs) '(t)
2449 '(:help "\"Caesar rotate\" article by 13"))]
2450 ["De-IDNA" gnus-summary-idna-message t]
2451 ["Morse decode" gnus-summary-morse-message t]
2452 ["Unix pipe..." gnus-summary-pipe-message t]
2453 ["Add buttons" gnus-article-add-buttons t]
2454 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2455 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2456 ["Verbose header" gnus-summary-verbose-headers t]
2457 ["Toggle header" gnus-summary-toggle-header t]
2458 ["Unfold headers" gnus-article-treat-unfold-headers t]
2459 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2460 ["Html" gnus-article-wash-html t]
2461 ["Unsplit URLs" gnus-article-unsplit-urls t]
2462 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2463 ["Decode HZ" gnus-article-decode-HZ t]
2464 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2465 ("(Outlook) Deuglify"
2466 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2467 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2468 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2469 ["Full (Outlook) deuglify"
2470 gnus-article-outlook-deuglify-article t])
2471 )
2472 ("Output"
2473 ["Save in default format..." gnus-summary-save-article
2474 ,@(if (featurep 'xemacs) '(t)
2475 '(:help "Save article using default method"))]
2476 ["Save in file..." gnus-summary-save-article-file
2477 ,@(if (featurep 'xemacs) '(t)
2478 '(:help "Save article in file"))]
2479 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2480 ["Save in MH folder..." gnus-summary-save-article-folder t]
2481 ["Save in VM folder..." gnus-summary-save-article-vm t]
2482 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2483 ["Save body in file..." gnus-summary-save-article-body-file t]
2484 ["Pipe through a filter..." gnus-summary-pipe-output t]
2485 ["Print with Muttprint..." gnus-summary-muttprint t]
2486 ["Print" gnus-summary-print-article
2487 ,@(if (featurep 'xemacs) '(t)
2488 '(:help "Generate and print a PostScript image"))])
2489 ("Copy, move,... (Backend)"
2490 ,@(if (featurep 'xemacs) nil
2491 '(:help "Copying, moving, expiring articles..."))
2492 ["Respool article..." gnus-summary-respool-article t]
2493 ["Move article..." gnus-summary-move-article
2494 (gnus-check-backend-function
2495 'request-move-article gnus-newsgroup-name)]
2496 ["Copy article..." gnus-summary-copy-article t]
2497 ["Crosspost article..." gnus-summary-crosspost-article
2498 (gnus-check-backend-function
2499 'request-replace-article gnus-newsgroup-name)]
2500 ["Import file..." gnus-summary-import-article
2501 (gnus-check-backend-function
2502 'request-accept-article gnus-newsgroup-name)]
2503 ["Create article..." gnus-summary-create-article
2504 (gnus-check-backend-function
2505 'request-accept-article gnus-newsgroup-name)]
2506 ["Check if posted" gnus-summary-article-posted-p t]
2507 ["Edit article" gnus-summary-edit-article
2508 (not (gnus-group-read-only-p))]
2509 ["Delete article" gnus-summary-delete-article
2510 (gnus-check-backend-function
2511 'request-expire-articles gnus-newsgroup-name)]
2512 ["Query respool" gnus-summary-respool-query t]
2513 ["Trace respool" gnus-summary-respool-trace t]
2514 ["Delete expirable articles" gnus-summary-expire-articles-now
2515 (gnus-check-backend-function
2516 'request-expire-articles gnus-newsgroup-name)])
2517 ("Extract"
2518 ["Uudecode" gnus-uu-decode-uu
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Decode uuencoded article(s)"))]
2521 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2522 ["Unshar" gnus-uu-decode-unshar t]
2523 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2524 ["Save" gnus-uu-decode-save t]
2525 ["Binhex" gnus-uu-decode-binhex t]
2526 ["PostScript" gnus-uu-decode-postscript t]
2527 ["All MIME parts" gnus-summary-save-parts t])
2528 ("Cache"
2529 ["Enter article" gnus-cache-enter-article t]
2530 ["Remove article" gnus-cache-remove-article t])
2531 ["Translate" gnus-article-babel t]
2532 ["Select article buffer" gnus-summary-select-article-buffer t]
2533 ["Make article buffer sticky" gnus-sticky-article t]
2534 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2535 ["Isearch article..." gnus-summary-isearch-article t]
2536 ["Beginning of the article" gnus-summary-beginning-of-article t]
2537 ["End of the article" gnus-summary-end-of-article t]
2538 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2539 ["Fetch referenced articles" gnus-summary-refer-references t]
2540 ["Fetch current thread" gnus-summary-refer-thread t]
2541 ["Fetch article with id..." gnus-summary-refer-article t]
2542 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2543 ["Redisplay" gnus-summary-show-article t]
2544 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2545 (easy-menu-define
2546 gnus-summary-article-menu gnus-summary-mode-map ""
2547 (cons "Article" innards))
2548
2549 (if (not (keymapp gnus-summary-article-menu))
2550 (easy-menu-define
2551 gnus-article-commands-menu gnus-article-mode-map ""
2552 (cons "Commands" innards))
2553 ;; in Emacs, don't share menu.
2554 (setq gnus-article-commands-menu
2555 (copy-keymap gnus-summary-article-menu))
2556 (define-key gnus-article-mode-map [menu-bar commands]
2557 (cons "Commands" gnus-article-commands-menu))))
2558
2559 (easy-menu-define
2560 gnus-summary-thread-menu gnus-summary-mode-map ""
2561 '("Threads"
2562 ["Find all messages in thread" gnus-summary-refer-thread t]
2563 ["Toggle threading" gnus-summary-toggle-threads t]
2564 ["Hide threads" gnus-summary-hide-all-threads t]
2565 ["Show threads" gnus-summary-show-all-threads t]
2566 ["Hide thread" gnus-summary-hide-thread t]
2567 ["Show thread" gnus-summary-show-thread t]
2568 ["Go to next thread" gnus-summary-next-thread t]
2569 ["Go to previous thread" gnus-summary-prev-thread t]
2570 ["Go down thread" gnus-summary-down-thread t]
2571 ["Go up thread" gnus-summary-up-thread t]
2572 ["Top of thread" gnus-summary-top-thread t]
2573 ["Mark thread as read" gnus-summary-kill-thread t]
2574 ["Mark thread as expired" gnus-summary-expire-thread t]
2575 ["Lower thread score" gnus-summary-lower-thread t]
2576 ["Raise thread score" gnus-summary-raise-thread t]
2577 ["Rethread current" gnus-summary-rethread-current t]))
2578
2579 (easy-menu-define
2580 gnus-summary-post-menu gnus-summary-mode-map ""
2581 `("Post"
2582 ["Send a message (mail or news)" gnus-summary-post-news
2583 ,@(if (featurep 'xemacs) '(t)
2584 '(:help "Compose a new message (mail or news)"))]
2585 ["Followup" gnus-summary-followup
2586 ,@(if (featurep 'xemacs) '(t)
2587 '(:help "Post followup to this article"))]
2588 ["Followup and yank" gnus-summary-followup-with-original
2589 ,@(if (featurep 'xemacs) '(t)
2590 '(:help "Post followup to this article, quoting its contents"))]
2591 ["Supersede article" gnus-summary-supersede-article t]
2592 ["Cancel article" gnus-summary-cancel-article
2593 ,@(if (featurep 'xemacs) '(t)
2594 '(:help "Cancel an article you posted"))]
2595 ["Reply" gnus-summary-reply t]
2596 ["Reply and yank" gnus-summary-reply-with-original t]
2597 ["Wide reply" gnus-summary-wide-reply t]
2598 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2599 ,@(if (featurep 'xemacs) '(t)
2600 '(:help "Mail a reply, quoting this article"))]
2601 ["Very wide reply" gnus-summary-very-wide-reply t]
2602 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2603 ,@(if (featurep 'xemacs) '(t)
2604 '(:help "Mail a very wide reply, quoting this article"))]
2605 ["Mail forward" gnus-summary-mail-forward t]
2606 ["Post forward" gnus-summary-post-forward t]
2607 ["Digest and mail" gnus-uu-digest-mail-forward t]
2608 ["Digest and post" gnus-uu-digest-post-forward t]
2609 ["Resend message" gnus-summary-resend-message t]
2610 ["Resend message edit" gnus-summary-resend-message-edit t]
2611 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2612 ["Send a mail" gnus-summary-mail-other-window t]
2613 ["Create a local message" gnus-summary-news-other-window t]
2614 ["Uuencode and post" gnus-uu-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Post a uuencoded article"))]
2617 ["Followup via news" gnus-summary-followup-to-mail t]
2618 ["Followup via news and yank"
2619 gnus-summary-followup-to-mail-with-original t]
2620 ["Strip signature on reply"
2621 (lambda ()
2622 (interactive)
2623 (if (not (memq message-cite-function
2624 '(message-cite-original-without-signature
2625 message-cite-original)))
2626 ;; Stupid workaround for XEmacs not honoring :visible.
2627 (message "Can't toggle this value of `message-cite-function'")
2628 (setq message-cite-function
2629 (if (eq message-cite-function
2630 'message-cite-original-without-signature)
2631 'message-cite-original
2632 'message-cite-original-without-signature))))
2633 ;; XEmacs barfs on :visible.
2634 ,@(if (featurep 'xemacs) nil
2635 '(:visible (memq message-cite-function
2636 '(message-cite-original-without-signature
2637 message-cite-original))))
2638 :style toggle
2639 :selected (eq message-cite-function
2640 'message-cite-original-without-signature)
2641 ,@(if (featurep 'xemacs) nil
2642 '(:help "Strip signature from cited article when replying."))]
2643 ;;("Draft"
2644 ;;["Send" gnus-summary-send-draft t]
2645 ;;["Send bounced" gnus-resend-bounced-mail t])
2646 ))
2647
2648 (cond
2649 ((not (keymapp gnus-summary-post-menu))
2650 (setq gnus-article-post-menu gnus-summary-post-menu))
2651 ((not gnus-article-post-menu)
2652 ;; Don't share post menu.
2653 (setq gnus-article-post-menu
2654 (copy-keymap gnus-summary-post-menu))))
2655 (define-key gnus-article-mode-map [menu-bar post]
2656 (cons "Post" gnus-article-post-menu))
2657
2658 (easy-menu-define
2659 gnus-summary-misc-menu gnus-summary-mode-map ""
2660 `("Gnus"
2661 ("Mark Read"
2662 ["Mark as read" gnus-summary-mark-as-read-forward t]
2663 ["Mark same subject and select"
2664 gnus-summary-kill-same-subject-and-select t]
2665 ["Mark same subject" gnus-summary-kill-same-subject t]
2666 ["Catchup" gnus-summary-catchup
2667 ,@(if (featurep 'xemacs) '(t)
2668 '(:help "Mark unread articles in this group as read"))]
2669 ["Catchup all" gnus-summary-catchup-all t]
2670 ["Catchup to here" gnus-summary-catchup-to-here t]
2671 ["Catchup from here" gnus-summary-catchup-from-here t]
2672 ["Catchup region" gnus-summary-mark-region-as-read
2673 (gnus-mark-active-p)]
2674 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2675 ("Mark Various"
2676 ["Tick" gnus-summary-tick-article-forward t]
2677 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2678 ["Remove marks" gnus-summary-clear-mark-forward t]
2679 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2680 ["Set bookmark" gnus-summary-set-bookmark t]
2681 ["Remove bookmark" gnus-summary-remove-bookmark t])
2682 ("Limit to"
2683 ["Marks..." gnus-summary-limit-to-marks t]
2684 ["Subject..." gnus-summary-limit-to-subject t]
2685 ["Author..." gnus-summary-limit-to-author t]
2686 ["Recipient..." gnus-summary-limit-to-recipient t]
2687 ["Address..." gnus-summary-limit-to-address t]
2688 ["Age..." gnus-summary-limit-to-age t]
2689 ["Extra..." gnus-summary-limit-to-extra t]
2690 ["Score..." gnus-summary-limit-to-score t]
2691 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2692 ["Unread" gnus-summary-limit-to-unread t]
2693 ["Unseen" gnus-summary-limit-to-unseen t]
2694 ["Singletons" gnus-summary-limit-to-singletons t]
2695 ["Replied" gnus-summary-limit-to-replied t]
2696 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2697 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2698 ["Pop limit" gnus-summary-pop-limit t]
2699 ["Show dormant" gnus-summary-limit-include-dormant t]
2700 ["Hide childless dormant"
2701 gnus-summary-limit-exclude-childless-dormant t]
2702 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2703 ["Hide marked" gnus-summary-limit-exclude-marks t]
2704 ["Show expunged" gnus-summary-limit-include-expunged t])
2705 ("Process Mark"
2706 ["Set mark" gnus-summary-mark-as-processable t]
2707 ["Remove mark" gnus-summary-unmark-as-processable t]
2708 ["Remove all marks" gnus-summary-unmark-all-processable t]
2709 ["Invert marks" gnus-uu-invert-processable t]
2710 ["Mark above" gnus-uu-mark-over t]
2711 ["Mark series" gnus-uu-mark-series t]
2712 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2713 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2714 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2715 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2716 ["Mark all" gnus-uu-mark-all t]
2717 ["Mark buffer" gnus-uu-mark-buffer t]
2718 ["Mark sparse" gnus-uu-mark-sparse t]
2719 ["Mark thread" gnus-uu-mark-thread t]
2720 ["Unmark thread" gnus-uu-unmark-thread t]
2721 ("Process Mark Sets"
2722 ["Kill" gnus-summary-kill-process-mark t]
2723 ["Yank" gnus-summary-yank-process-mark
2724 gnus-newsgroup-process-stack]
2725 ["Save" gnus-summary-save-process-mark t]
2726 ["Run command on marked..." gnus-summary-universal-argument t]))
2727 ("Registry Marks")
2728 ("Scroll article"
2729 ["Page forward" gnus-summary-next-page
2730 ,@(if (featurep 'xemacs) '(t)
2731 '(:help "Show next page of article"))]
2732 ["Page backward" gnus-summary-prev-page
2733 ,@(if (featurep 'xemacs) '(t)
2734 '(:help "Show previous page of article"))]
2735 ["Line forward" gnus-summary-scroll-up t])
2736 ("Move"
2737 ["Next unread article" gnus-summary-next-unread-article t]
2738 ["Previous unread article" gnus-summary-prev-unread-article t]
2739 ["Next article" gnus-summary-next-article t]
2740 ["Previous article" gnus-summary-prev-article t]
2741 ["Next unread subject" gnus-summary-next-unread-subject t]
2742 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2743 ["Next article same subject" gnus-summary-next-same-subject t]
2744 ["Previous article same subject" gnus-summary-prev-same-subject t]
2745 ["First unread article" gnus-summary-first-unread-article t]
2746 ["Best unread article" gnus-summary-best-unread-article t]
2747 ["Go to subject number..." gnus-summary-goto-subject t]
2748 ["Go to article number..." gnus-summary-goto-article t]
2749 ["Go to the last article" gnus-summary-goto-last-article t]
2750 ["Pop article off history" gnus-summary-pop-article t])
2751 ("Sort"
2752 ["Sort by number" gnus-summary-sort-by-number t]
2753 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2754 ["Sort by author" gnus-summary-sort-by-author t]
2755 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2756 ["Sort by subject" gnus-summary-sort-by-subject t]
2757 ["Sort by date" gnus-summary-sort-by-date t]
2758 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2759 ["Sort by score" gnus-summary-sort-by-score t]
2760 ["Sort by lines" gnus-summary-sort-by-lines t]
2761 ["Sort by characters" gnus-summary-sort-by-chars t]
2762 ["Randomize" gnus-summary-sort-by-random t]
2763 ["Original sort" gnus-summary-sort-by-original t])
2764 ("Help"
2765 ["Describe group" gnus-summary-describe-group t]
2766 ["Read manual" gnus-info-find-node t])
2767 ("Modes"
2768 ["Pick and read" gnus-pick-mode t]
2769 ["Binary" gnus-binary-mode t])
2770 ("Regeneration"
2771 ["Regenerate" gnus-summary-prepare t]
2772 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2773 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2774 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2775 ["Toggle threading" gnus-summary-toggle-threads t])
2776 ["See old articles" gnus-summary-insert-old-articles t]
2777 ["See new articles" gnus-summary-insert-new-articles t]
2778 ["Filter articles..." gnus-summary-execute-command t]
2779 ["Run command on articles..." gnus-summary-universal-argument t]
2780 ["Search articles forward..." gnus-summary-search-article-forward t]
2781 ["Search articles backward..." gnus-summary-search-article-backward t]
2782 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2783 ["Expand window" gnus-summary-expand-window t]
2784 ["Expire expirable articles" gnus-summary-expire-articles
2785 (gnus-check-backend-function
2786 'request-expire-articles gnus-newsgroup-name)]
2787 ["Edit local kill file" gnus-summary-edit-local-kill t]
2788 ["Edit main kill file" gnus-summary-edit-global-kill t]
2789 ["Edit group parameters" gnus-summary-edit-parameters t]
2790 ["Customize group parameters" gnus-summary-customize-parameters t]
2791 ["Send a bug report" gnus-bug t]
2792 ("Exit"
2793 ["Catchup and exit" gnus-summary-catchup-and-exit
2794 ,@(if (featurep 'xemacs) '(t)
2795 '(:help "Mark unread articles in this group as read, then exit"))]
2796 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2797 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2798 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2799 ["Exit group" gnus-summary-exit
2800 ,@(if (featurep 'xemacs) '(t)
2801 '(:help "Exit current group, return to group selection mode"))]
2802 ["Exit group without updating" gnus-summary-exit-no-update t]
2803 ["Exit and goto next group" gnus-summary-next-group t]
2804 ["Exit and goto prev group" gnus-summary-prev-group t]
2805 ["Reselect group" gnus-summary-reselect-current-group t]
2806 ["Rescan group" gnus-summary-rescan-group t]
2807 ["Update dribble" gnus-summary-save-newsrc t])))
2808
2809 (gnus-run-hooks 'gnus-summary-menu-hook)))
2810
2811 (defvar gnus-summary-tool-bar-map nil)
2812
2813 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2814 ;; affect _new_ message buffers. We might add a function that walks thru all
2815 ;; summary-mode buffers and force the update.
2816 (defun gnus-summary-tool-bar-update (&optional symbol value)
2817 "Update summary mode toolbar.
2818 Setter function for custom variables."
2819 (setq-default gnus-summary-tool-bar-map nil)
2820 (when symbol
2821 ;; When used as ":set" function:
2822 (set-default symbol value))
2823 (when (gnus-buffer-live-p gnus-summary-buffer)
2824 (with-current-buffer gnus-summary-buffer
2825 (gnus-summary-make-tool-bar))))
2826
2827 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2828 'gnus-summary-tool-bar-gnome
2829 'gnus-summary-tool-bar-retro)
2830 "Specifies the Gnus summary tool bar.
2831
2832 It can be either a list or a symbol referring to a list. See
2833 `gmm-tool-bar-from-list' for the format of the list. The
2834 default key map is `gnus-summary-mode-map'.
2835
2836 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2837 `gnus-summary-tool-bar-retro'."
2838 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2839 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2840 (repeat :tag "User defined list" gmm-tool-bar-item)
2841 (symbol))
2842 :version "23.1" ;; No Gnus
2843 :initialize 'custom-initialize-default
2844 :set 'gnus-summary-tool-bar-update
2845 :group 'gnus-summary)
2846
2847 (defcustom gnus-summary-tool-bar-gnome
2848 '((gnus-summary-post-news "mail/compose" nil)
2849 (gnus-summary-insert-new-articles "mail/inbox" nil
2850 :visible (or (not gnus-agent)
2851 gnus-plugged))
2852 (gnus-summary-reply-with-original "mail/reply")
2853 (gnus-summary-reply "mail/reply" nil :visible nil)
2854 (gnus-summary-followup-with-original "mail/reply-all")
2855 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2856 (gnus-summary-mail-forward "mail/forward")
2857 (gnus-summary-save-article "mail/save")
2858 (gnus-summary-search-article-forward "search" nil :visible nil)
2859 (gnus-summary-print-article "print")
2860 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2861 ;; Some new commands that may need more suitable icons:
2862 (gnus-summary-save-newsrc "save" nil :visible nil)
2863 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2864 (gnus-summary-prev-article "left-arrow")
2865 (gnus-summary-next-article "right-arrow")
2866 (gnus-summary-next-page "next-page")
2867 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2868 ;;
2869 ;; Maybe some sort-by-... could be added:
2870 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2871 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2872 (gnus-summary-mark-as-expirable
2873 "delete" nil
2874 :visible (gnus-check-backend-function 'request-expire-articles
2875 gnus-newsgroup-name))
2876 (gnus-summary-mark-as-spam
2877 "mail/spam" t
2878 :visible (and (fboundp 'spam-group-ham-contents-p)
2879 (spam-group-ham-contents-p gnus-newsgroup-name))
2880 :help "Mark as spam")
2881 (gnus-summary-mark-as-read-forward
2882 "mail/not-spam" nil
2883 :visible (and (fboundp 'spam-group-spam-contents-p)
2884 (spam-group-spam-contents-p gnus-newsgroup-name)))
2885 ;;
2886 (gnus-summary-exit "exit")
2887 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2888 (gnus-info-find-node "help"))
2889 "List of functions for the summary tool bar (GNOME style).
2890
2891 See `gmm-tool-bar-from-list' for the format of the list."
2892 :type '(repeat gmm-tool-bar-item)
2893 :version "23.1" ;; No Gnus
2894 :initialize 'custom-initialize-default
2895 :set 'gnus-summary-tool-bar-update
2896 :group 'gnus-summary)
2897
2898 (defcustom gnus-summary-tool-bar-retro
2899 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2900 (gnus-summary-next-unread-article "gnus/next-ur")
2901 (gnus-summary-post-news "gnus/post")
2902 (gnus-summary-followup-with-original "gnus/fuwo")
2903 (gnus-summary-followup "gnus/followup")
2904 (gnus-summary-reply-with-original "gnus/reply-wo")
2905 (gnus-summary-reply "gnus/reply")
2906 (gnus-summary-caesar-message "gnus/rot13")
2907 (gnus-uu-decode-uu "gnus/uu-decode")
2908 (gnus-summary-save-article-file "gnus/save-aif")
2909 (gnus-summary-save-article "gnus/save-art")
2910 (gnus-uu-post-news "gnus/uu-post")
2911 (gnus-summary-catchup "gnus/catchup")
2912 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2913 (gnus-summary-exit "gnus/exit-summ")
2914 ;; Some new command that may need more suitable icons:
2915 (gnus-summary-print-article "gnus/print" nil :visible nil)
2916 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2917 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2918 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2919 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2920 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2921 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2922 ;;
2923 (gnus-info-find-node "gnus/help" nil :visible nil))
2924 "List of functions for the summary tool bar (retro look).
2925
2926 See `gmm-tool-bar-from-list' for the format of the list."
2927 :type '(repeat gmm-tool-bar-item)
2928 :version "23.1" ;; No Gnus
2929 :initialize 'custom-initialize-default
2930 :set 'gnus-summary-tool-bar-update
2931 :group 'gnus-summary)
2932
2933 (defcustom gnus-summary-tool-bar-zap-list t
2934 "List of icon items from the global tool bar.
2935 These items are not displayed in the Gnus summary mode tool bar.
2936
2937 See `gmm-tool-bar-from-list' for the format of the list."
2938 :type 'gmm-tool-bar-zap-list
2939 :version "23.1" ;; No Gnus
2940 :initialize 'custom-initialize-default
2941 :set 'gnus-summary-tool-bar-update
2942 :group 'gnus-summary)
2943
2944 (defvar image-load-path)
2945 (defvar tool-bar-map)
2946
2947 (defun gnus-summary-make-tool-bar (&optional force)
2948 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2949 When FORCE, rebuild the tool bar."
2950 (when (and (not (featurep 'xemacs))
2951 (boundp 'tool-bar-mode)
2952 tool-bar-mode
2953 (or (not gnus-summary-tool-bar-map) force))
2954 (let* ((load-path
2955 (gmm-image-load-path-for-library "gnus"
2956 "mail/save.xpm"
2957 nil t))
2958 (image-load-path (cons (car load-path)
2959 (when (boundp 'image-load-path)
2960 image-load-path)))
2961 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2962 gnus-summary-tool-bar-zap-list
2963 'gnus-summary-mode-map)))
2964 (when map
2965 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2966 ;; uses its value.
2967 (setq gnus-summary-tool-bar-map map))))
2968 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2969
2970 (defun gnus-make-score-map (type)
2971 "Make a summary score map of type TYPE."
2972 (if t
2973 nil
2974 (let ((headers '(("author" "from" string)
2975 ("subject" "subject" string)
2976 ("article body" "body" string)
2977 ("article head" "head" string)
2978 ("xref" "xref" string)
2979 ("extra header" "extra" string)
2980 ("lines" "lines" number)
2981 ("followups to author" "followup" string)))
2982 (types '((number ("less than" <)
2983 ("greater than" >)
2984 ("equal" =))
2985 (string ("substring" s)
2986 ("exact string" e)
2987 ("fuzzy string" f)
2988 ("regexp" r))))
2989 (perms '(("temporary" (current-time-string))
2990 ("permanent" nil)
2991 ("immediate" now)))
2992 header)
2993 (list
2994 (apply
2995 'nconc
2996 (list
2997 (if (eq type 'lower)
2998 "Lower score"
2999 "Increase score"))
3000 (let (outh)
3001 (while headers
3002 (setq header (car headers))
3003 (setq outh
3004 (cons
3005 (apply
3006 'nconc
3007 (list (car header))
3008 (let ((ts (cdr (assoc (nth 2 header) types)))
3009 outt)
3010 (while ts
3011 (setq outt
3012 (cons
3013 (apply
3014 'nconc
3015 (list (caar ts))
3016 (let ((ps perms)
3017 outp)
3018 (while ps
3019 (setq outp
3020 (cons
3021 (vector
3022 (caar ps)
3023 (list
3024 'gnus-summary-score-entry
3025 (nth 1 header)
3026 (if (or (string= (nth 1 header)
3027 "head")
3028 (string= (nth 1 header)
3029 "body"))
3030 ""
3031 (list 'gnus-summary-header
3032 (nth 1 header)))
3033 (list 'quote (nth 1 (car ts)))
3034 (list 'gnus-score-delta-default
3035 nil)
3036 (nth 1 (car ps))
3037 t)
3038 t)
3039 outp))
3040 (setq ps (cdr ps)))
3041 (list (nreverse outp))))
3042 outt))
3043 (setq ts (cdr ts)))
3044 (list (nreverse outt))))
3045 outh))
3046 (setq headers (cdr headers)))
3047 (list (nreverse outh))))))))
3048
3049
3050 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3051 (defvar bookmark-make-record-function)
3052 \f
3053 (defvar bidi-paragraph-direction)
3054
3055 (defun gnus-summary-mode (&optional group)
3056 "Major mode for reading articles.
3057
3058 All normal editing commands are switched off.
3059 \\<gnus-summary-mode-map>
3060 Each line in this buffer represents one article. To read an
3061 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3062 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3063 respectively.
3064
3065 You can also post articles and send mail from this buffer. To
3066 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3067 of an article, type `\\[gnus-summary-reply]'.
3068
3069 There are approx. one gazillion commands you can execute in this
3070 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3071
3072 The following commands are available:
3073
3074 \\{gnus-summary-mode-map}"
3075 (interactive)
3076 (kill-all-local-variables)
3077 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3078 (gnus-summary-make-local-variables))
3079 (gnus-summary-make-local-variables)
3080 (setq gnus-newsgroup-name group)
3081 (when (gnus-visual-p 'summary-menu 'menu)
3082 (gnus-summary-make-menu-bar)
3083 (gnus-summary-make-tool-bar))
3084 (gnus-make-thread-indent-array)
3085 (gnus-simplify-mode-line)
3086 (setq major-mode 'gnus-summary-mode)
3087 (setq mode-name "Summary")
3088 (use-local-map gnus-summary-mode-map)
3089 (buffer-disable-undo)
3090 (setq buffer-read-only t ;Disable modification
3091 show-trailing-whitespace nil)
3092 (setq truncate-lines t)
3093 ;; Force paragraph direction to be left-to-right. Don't make it
3094 ;; bound globally in old Emacsen and XEmacsen.
3095 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3096 (add-to-invisibility-spec '(gnus-sum . t))
3097 (gnus-summary-set-display-table)
3098 (gnus-set-default-directory)
3099 (make-local-variable 'gnus-summary-line-format)
3100 (make-local-variable 'gnus-summary-line-format-spec)
3101 (make-local-variable 'gnus-summary-dummy-line-format)
3102 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3103 (make-local-variable 'gnus-summary-mark-positions)
3104 (gnus-make-local-hook 'pre-command-hook)
3105 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3106 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3107 (turn-on-gnus-mailing-list-mode)
3108 (mm-enable-multibyte)
3109 (set (make-local-variable 'bookmark-make-record-function)
3110 'gnus-summary-bookmark-make-record)
3111 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3112 (gnus-update-summary-mark-positions))
3113
3114 (defun gnus-summary-make-local-variables ()
3115 "Make all the local summary buffer variables."
3116 (let (global)
3117 (dolist (local gnus-summary-local-variables)
3118 (if (consp local)
3119 (progn
3120 (if (eq (cdr local) 'global)
3121 ;; Copy the global value of the variable.
3122 (setq global (symbol-value (car local)))
3123 ;; Use the value from the list.
3124 (setq global (eval (cdr local))))
3125 (set (make-local-variable (car local)) global))
3126 ;; Simple nil-valued local variable.
3127 (set (make-local-variable local) nil)))))
3128
3129 ;; Summary data functions.
3130
3131 (defmacro gnus-data-number (data)
3132 `(car ,data))
3133
3134 (defmacro gnus-data-set-number (data number)
3135 `(setcar ,data ,number))
3136
3137 (defmacro gnus-data-mark (data)
3138 `(nth 1 ,data))
3139
3140 (defmacro gnus-data-set-mark (data mark)
3141 `(setcar (nthcdr 1 ,data) ,mark))
3142
3143 (defmacro gnus-data-pos (data)
3144 `(nth 2 ,data))
3145
3146 (defmacro gnus-data-set-pos (data pos)
3147 `(setcar (nthcdr 2 ,data) ,pos))
3148
3149 (defmacro gnus-data-header (data)
3150 `(nth 3 ,data))
3151
3152 (defmacro gnus-data-set-header (data header)
3153 `(setf (nth 3 ,data) ,header))
3154
3155 (defmacro gnus-data-level (data)
3156 `(nth 4 ,data))
3157
3158 (defmacro gnus-data-unread-p (data)
3159 `(= (nth 1 ,data) gnus-unread-mark))
3160
3161 (defmacro gnus-data-read-p (data)
3162 `(/= (nth 1 ,data) gnus-unread-mark))
3163
3164 (defmacro gnus-data-pseudo-p (data)
3165 `(consp (nth 3 ,data)))
3166
3167 (defmacro gnus-data-find (number)
3168 `(assq ,number gnus-newsgroup-data))
3169
3170 (defmacro gnus-data-find-list (number &optional data)
3171 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3172 (memq (assq ,number bdata)
3173 bdata)))
3174
3175 (defmacro gnus-data-make (number mark pos header level)
3176 `(list ,number ,mark ,pos ,header ,level))
3177
3178 (defun gnus-data-enter (after-article number mark pos header level offset)
3179 (let ((data (gnus-data-find-list after-article)))
3180 (unless data
3181 (error "No such article: %d" after-article))
3182 (setcdr data (cons (gnus-data-make number mark pos header level)
3183 (cdr data)))
3184 (setq gnus-newsgroup-data-reverse nil)
3185 (gnus-data-update-list (cddr data) offset)))
3186
3187 (defun gnus-data-enter-list (after-article list &optional offset)
3188 (when list
3189 (let ((data (and after-article (gnus-data-find-list after-article)))
3190 (ilist list))
3191 (if (not (or data
3192 after-article))
3193 (let ((odata gnus-newsgroup-data))
3194 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3195 (when offset
3196 (gnus-data-update-list odata offset)))
3197 ;; Find the last element in the list to be spliced into the main
3198 ;; list.
3199 (setq list (last list))
3200 (if (not data)
3201 (progn
3202 (setcdr list gnus-newsgroup-data)
3203 (setq gnus-newsgroup-data ilist)
3204 (when offset
3205 (gnus-data-update-list (cdr list) offset)))
3206 (setcdr list (cdr data))
3207 (setcdr data ilist)
3208 (when offset
3209 (gnus-data-update-list (cdr list) offset))))
3210 (setq gnus-newsgroup-data-reverse nil))))
3211
3212 (defun gnus-data-remove (article &optional offset)
3213 (let ((data gnus-newsgroup-data))
3214 (if (= (gnus-data-number (car data)) article)
3215 (progn
3216 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3217 gnus-newsgroup-data-reverse nil)
3218 (when offset
3219 (gnus-data-update-list gnus-newsgroup-data offset)))
3220 (while (cdr data)
3221 (when (= (gnus-data-number (cadr data)) article)
3222 (setcdr data (cddr data))
3223 (when offset
3224 (gnus-data-update-list (cdr data) offset))
3225 (setq data nil
3226 gnus-newsgroup-data-reverse nil))
3227 (setq data (cdr data))))))
3228
3229 (defmacro gnus-data-list (backward)
3230 `(if ,backward
3231 (or gnus-newsgroup-data-reverse
3232 (setq gnus-newsgroup-data-reverse
3233 (reverse gnus-newsgroup-data)))
3234 gnus-newsgroup-data))
3235
3236 (defun gnus-data-update-list (data offset)
3237 "Add OFFSET to the POS of all data entries in DATA."
3238 (setq gnus-newsgroup-data-reverse nil)
3239 (while data
3240 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3241 (setq data (cdr data))))
3242
3243 (defun gnus-summary-article-pseudo-p (article)
3244 "Say whether this article is a pseudo article or not."
3245 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3246
3247 (defmacro gnus-summary-article-sparse-p (article)
3248 "Say whether this article is a sparse article or not."
3249 `(memq ,article gnus-newsgroup-sparse))
3250
3251 (defmacro gnus-summary-article-ancient-p (article)
3252 "Say whether this article is a sparse article or not."
3253 `(memq ,article gnus-newsgroup-ancient))
3254
3255 (defun gnus-article-children (number)
3256 "Return a list of all children to NUMBER."
3257 (let* ((data (gnus-data-find-list number))
3258 (level (gnus-data-level (car data)))
3259 children)
3260 (setq data (cdr data))
3261 (while (and data
3262 (= (gnus-data-level (car data)) (1+ level)))
3263 (push (gnus-data-number (car data)) children)
3264 (setq data (cdr data)))
3265 children))
3266
3267 (defmacro gnus-summary-skip-intangible ()
3268 "If the current article is intangible, then jump to a different article."
3269 '(let ((to (get-text-property (point) 'gnus-intangible)))
3270 (and to (gnus-summary-goto-subject to))))
3271
3272 (defmacro gnus-summary-article-intangible-p ()
3273 "Say whether this article is intangible or not."
3274 '(get-text-property (point) 'gnus-intangible))
3275
3276 ;; Some summary mode macros.
3277
3278 (defmacro gnus-summary-article-number ()
3279 "The article number of the article on the current line.
3280 If there isn't an article number here, then we return the current
3281 article number."
3282 '(progn
3283 (gnus-summary-skip-intangible)
3284 (or (get-text-property (point) 'gnus-number)
3285 (gnus-summary-last-subject))))
3286
3287 (defmacro gnus-summary-article-header (&optional number)
3288 "Return the header of article NUMBER."
3289 `(gnus-data-header (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3291
3292 (defmacro gnus-summary-thread-level (&optional number)
3293 "Return the level of thread that starts with article NUMBER."
3294 `(if (and (eq gnus-summary-make-false-root 'dummy)
3295 (get-text-property (point) 'gnus-intangible))
3296 0
3297 (gnus-data-level (gnus-data-find
3298 ,(or number '(gnus-summary-article-number))))))
3299
3300 (defmacro gnus-summary-article-mark (&optional number)
3301 "Return the mark of article NUMBER."
3302 `(gnus-data-mark (gnus-data-find
3303 ,(or number '(gnus-summary-article-number)))))
3304
3305 (defmacro gnus-summary-article-pos (&optional number)
3306 "Return the position of the line of article NUMBER."
3307 `(gnus-data-pos (gnus-data-find
3308 ,(or number '(gnus-summary-article-number)))))
3309
3310 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3311 (defmacro gnus-summary-article-subject (&optional number)
3312 "Return current subject string or nil if nothing."
3313 `(let ((headers
3314 ,(if number
3315 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3316 '(gnus-data-header (assq (gnus-summary-article-number)
3317 gnus-newsgroup-data)))))
3318 (and headers
3319 (vectorp headers)
3320 (mail-header-subject headers))))
3321
3322 (defmacro gnus-summary-article-score (&optional number)
3323 "Return current article score."
3324 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3325 gnus-newsgroup-scored))
3326 gnus-summary-default-score 0))
3327
3328 (defun gnus-summary-article-children (&optional number)
3329 "Return a list of article numbers that are children of article NUMBER."
3330 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3331 (level (gnus-data-level (car data)))
3332 l children)
3333 (while (and (setq data (cdr data))
3334 (> (setq l (gnus-data-level (car data))) level))
3335 (and (= (1+ level) l)
3336 (push (gnus-data-number (car data))
3337 children)))
3338 (nreverse children)))
3339
3340 (defun gnus-summary-article-parent (&optional number)
3341 "Return the article number of the parent of article NUMBER."
3342 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3343 (gnus-data-list t)))
3344 (level (gnus-data-level (car data))))
3345 (if (zerop level)
3346 () ; This is a root.
3347 ;; We search until we find an article with a level less than
3348 ;; this one. That function has to be the parent.
3349 (while (and (setq data (cdr data))
3350 (not (< (gnus-data-level (car data)) level))))
3351 (and data (gnus-data-number (car data))))))
3352
3353 (defun gnus-unread-mark-p (mark)
3354 "Say whether MARK is the unread mark."
3355 (= mark gnus-unread-mark))
3356
3357 (defun gnus-read-mark-p (mark)
3358 "Say whether MARK is one of the marks that mark as read.
3359 This is all marks except unread, ticked, dormant, and expirable."
3360 (not (or (= mark gnus-unread-mark)
3361 (= mark gnus-ticked-mark)
3362 (= mark gnus-spam-mark)
3363 (= mark gnus-dormant-mark)
3364 (= mark gnus-expirable-mark))))
3365
3366 (defmacro gnus-article-mark (number)
3367 "Return the MARK of article NUMBER.
3368 This macro should only be used when computing the mark the \"first\"
3369 time; i.e., when generating the summary lines. After that,
3370 `gnus-summary-article-mark' should be used to examine the
3371 marks of articles."
3372 `(cond
3373 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3374 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3375 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3376 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3377 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3378 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3379 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3380 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3381 gnus-ancient-mark))))
3382
3383 ;; Saving hidden threads.
3384
3385 (defmacro gnus-save-hidden-threads (&rest forms)
3386 "Save hidden threads, eval FORMS, and restore the hidden threads."
3387 (let ((config (make-symbol "config")))
3388 `(let ((,config (gnus-hidden-threads-configuration)))
3389 (unwind-protect
3390 (save-excursion
3391 ,@forms)
3392 (gnus-restore-hidden-threads-configuration ,config)))))
3393 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3394 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3395
3396 (defun gnus-data-compute-positions ()
3397 "Compute the positions of all articles."
3398 (setq gnus-newsgroup-data-reverse nil)
3399 (let ((data gnus-newsgroup-data))
3400 (save-excursion
3401 (gnus-save-hidden-threads
3402 (gnus-summary-show-all-threads)
3403 (goto-char (point-min))
3404 (while data
3405 (while (get-text-property (point) 'gnus-intangible)
3406 (forward-line 1))
3407 (gnus-data-set-pos (car data) (+ (point) 3))
3408 (setq data (cdr data))
3409 (forward-line 1))))))
3410
3411 (defun gnus-hidden-threads-configuration ()
3412 "Return the current hidden threads configuration."
3413 (save-excursion
3414 (let (config)
3415 (goto-char (point-min))
3416 (while (not (eobp))
3417 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3418 (push (save-excursion (forward-line 0) (point)) config))
3419 (forward-line 1))
3420 config)))
3421
3422 (defun gnus-restore-hidden-threads-configuration (config)
3423 "Restore hidden threads configuration from CONFIG."
3424 (save-excursion
3425 (let (point (inhibit-read-only t))
3426 (while (setq point (pop config))
3427 (goto-char point)
3428 (gnus-summary-hide-thread)))))
3429
3430 ;; Various summary mode internalish functions.
3431
3432 (defun gnus-mouse-pick-article (e)
3433 (interactive "e")
3434 (mouse-set-point e)
3435 (gnus-summary-next-page nil t))
3436
3437 (defun gnus-summary-set-display-table ()
3438 "Change the display table.
3439 Odd characters have a tendency to mess
3440 up nicely formatted displays - we make all possible glyphs
3441 display only a single character."
3442
3443 ;; We start from the standard display table, if any.
3444 (let ((table (or (copy-sequence standard-display-table)
3445 (make-display-table)))
3446 (i 32))
3447 ;; Nix out all the control chars...
3448 (while (>= (setq i (1- i)) 0)
3449 (gnus-put-display-table i [??] table))
3450 ;; ... but not newline and cr, of course. (cr is necessary for the
3451 ;; selective display).
3452 (gnus-put-display-table ?\n nil table)
3453 (gnus-put-display-table ?\r nil table)
3454 ;; We keep TAB as well.
3455 (gnus-put-display-table ?\t nil table)
3456 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3457 ;; Emacs 23 (unicode), that are not set already.
3458 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3459 160
3460 256)))
3461 (while (>= (setq i (1- i)) 127)
3462 ;; Only modify if the entry is nil.
3463 (unless (gnus-get-display-table i table)
3464 (gnus-put-display-table i [??] table))))
3465 (setq buffer-display-table table)))
3466
3467 (defun gnus-summary-set-article-display-arrow (pos)
3468 "Update the overlay arrow to point to line at position POS."
3469 (when gnus-summary-display-arrow
3470 (make-local-variable 'overlay-arrow-position)
3471 (make-local-variable 'overlay-arrow-string)
3472 (save-excursion
3473 (goto-char pos)
3474 (beginning-of-line)
3475 (unless overlay-arrow-position
3476 (setq overlay-arrow-position (make-marker)))
3477 (setq overlay-arrow-string "=>"
3478 overlay-arrow-position (set-marker overlay-arrow-position
3479 (point)
3480 (current-buffer))))))
3481
3482 (defun gnus-summary-setup-buffer (group)
3483 "Initialize summary buffer.
3484 If the setup was successful, non-nil is returned."
3485 (let ((buffer (gnus-summary-buffer-name group))
3486 (dead-name (concat "*Dead Summary "
3487 (gnus-group-decoded-name group) "*")))
3488 ;; If a dead summary buffer exists, we kill it.
3489 (when (gnus-buffer-live-p dead-name)
3490 (gnus-kill-buffer dead-name))
3491 (if (get-buffer buffer)
3492 (progn
3493 (set-buffer buffer)
3494 (setq gnus-summary-buffer (current-buffer))
3495 (not gnus-newsgroup-prepared))
3496 (set-buffer (gnus-get-buffer-create buffer))
3497 (setq gnus-summary-buffer (current-buffer))
3498 (gnus-summary-mode group)
3499 (when (gnus-group-quit-config group)
3500 (set (make-local-variable 'gnus-single-article-buffer) nil))
3501 (make-local-variable 'gnus-article-buffer)
3502 (make-local-variable 'gnus-article-current)
3503 (make-local-variable 'gnus-original-article-buffer)
3504 (setq gnus-newsgroup-name group)
3505 ;; Set any local variables in the group parameters.
3506 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3507 t)))
3508
3509 (defun gnus-set-global-variables ()
3510 "Set the global equivalents of the buffer-local variables.
3511 They are set to the latest values they had. These reflect the summary
3512 buffer that was in action when the last article was fetched."
3513 (when (eq major-mode 'gnus-summary-mode)
3514 (setq gnus-summary-buffer (current-buffer))
3515 (let ((name gnus-newsgroup-name)
3516 (marked gnus-newsgroup-marked)
3517 (spam gnus-newsgroup-spam-marked)
3518 (unread gnus-newsgroup-unreads)
3519 (headers gnus-current-headers)
3520 (data gnus-newsgroup-data)
3521 (summary gnus-summary-buffer)
3522 (article-buffer gnus-article-buffer)
3523 (original gnus-original-article-buffer)
3524 (gac gnus-article-current)
3525 (reffed gnus-reffed-article-number)
3526 (score-file gnus-current-score-file)
3527 (default-charset gnus-newsgroup-charset)
3528 vlist)
3529 (let ((locals gnus-newsgroup-variables))
3530 (while locals
3531 (if (consp (car locals))
3532 (push (eval (caar locals)) vlist)
3533 (push (eval (car locals)) vlist))
3534 (setq locals (cdr locals)))
3535 (setq vlist (nreverse vlist)))
3536 (with-temp-buffer
3537 (setq gnus-newsgroup-name name
3538 gnus-newsgroup-marked marked
3539 gnus-newsgroup-spam-marked spam
3540 gnus-newsgroup-unreads unread
3541 gnus-current-headers headers
3542 gnus-newsgroup-data data
3543 gnus-article-current gac
3544 gnus-summary-buffer summary
3545 gnus-article-buffer article-buffer
3546 gnus-original-article-buffer original
3547 gnus-reffed-article-number reffed
3548 gnus-current-score-file score-file
3549 gnus-newsgroup-charset default-charset)
3550 (let ((locals gnus-newsgroup-variables))
3551 (while locals
3552 (if (consp (car locals))
3553 (set (caar locals) (pop vlist))
3554 (set (car locals) (pop vlist)))
3555 (setq locals (cdr locals))))))))
3556
3557 (defun gnus-summary-article-unread-p (article)
3558 "Say whether ARTICLE is unread or not."
3559 (memq article gnus-newsgroup-unreads))
3560
3561 (defun gnus-summary-first-article-p (&optional article)
3562 "Return whether ARTICLE is the first article in the buffer."
3563 (if (not (setq article (or article (gnus-summary-article-number))))
3564 nil
3565 (eq article (caar gnus-newsgroup-data))))
3566
3567 (defun gnus-summary-last-article-p (&optional article)
3568 "Return whether ARTICLE is the last article in the buffer."
3569 (if (not (setq article (or article (gnus-summary-article-number))))
3570 ;; All non-existent numbers are the last article. :-)
3571 t
3572 (not (cdr (gnus-data-find-list article)))))
3573
3574 (defun gnus-make-thread-indent-array (&optional n)
3575 (when (or n
3576 (progn (setq n 200) nil)
3577 (null gnus-thread-indent-array)
3578 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3579 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3580 gnus-thread-indent-array-level gnus-thread-indent-level)
3581 (while (>= n 0)
3582 (aset gnus-thread-indent-array n
3583 (make-string (* n gnus-thread-indent-level) ? ))
3584 (setq n (1- n)))))
3585
3586 (defun gnus-update-summary-mark-positions ()
3587 "Compute where the summary marks are to go."
3588 (save-excursion
3589 (when (gnus-buffer-exists-p gnus-summary-buffer)
3590 (set-buffer gnus-summary-buffer))
3591 (let ((spec gnus-summary-line-format-spec)
3592 pos)
3593 (save-excursion
3594 (gnus-set-work-buffer)
3595 (let ((gnus-tmp-unread ?Z)
3596 (gnus-replied-mark ?Z)
3597 (gnus-score-below-mark ?Z)
3598 (gnus-score-over-mark ?Z)
3599 (gnus-undownloaded-mark ?Z)
3600 (gnus-summary-line-format-spec spec)
3601 (gnus-newsgroup-downloadable '(0))
3602 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3603 case-fold-search ignores)
3604 ;; Here, all marks are bound to Z.
3605 (gnus-summary-insert-line header
3606 0 nil t gnus-tmp-unread t nil "" nil 1)
3607 (goto-char (point-min))
3608 ;; Memorize the positions of the same characters as dummy marks.
3609 (while (re-search-forward "[A-D]" nil t)
3610 (push (point) ignores))
3611 (erase-buffer)
3612 ;; We use A-D as dummy marks in order to know column positions
3613 ;; where marks should be inserted.
3614 (setq gnus-tmp-unread ?A
3615 gnus-replied-mark ?B
3616 gnus-score-below-mark ?C
3617 gnus-score-over-mark ?C
3618 gnus-undownloaded-mark ?D)
3619 (gnus-summary-insert-line header
3620 0 nil t gnus-tmp-unread t nil "" nil 1)
3621 ;; Ignore characters which aren't dummy marks.
3622 (dolist (p ignores)
3623 (delete-region (goto-char (1- p)) p)
3624 (insert ?Z))
3625 (goto-char (point-min))
3626 (setq pos (list (cons 'unread
3627 (and (search-forward "A" nil t)
3628 (- (point) (point-min) 1)))))
3629 (goto-char (point-min))
3630 (push (cons 'replied (and (search-forward "B" nil t)
3631 (- (point) (point-min) 1)))
3632 pos)
3633 (goto-char (point-min))
3634 (push (cons 'score (and (search-forward "C" nil t)
3635 (- (point) (point-min) 1)))
3636 pos)
3637 (goto-char (point-min))
3638 (push (cons 'download (and (search-forward "D" nil t)
3639 (- (point) (point-min) 1)))
3640 pos)))
3641 (setq gnus-summary-mark-positions pos))))
3642
3643 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3644 "Insert a dummy root in the summary buffer."
3645 (beginning-of-line)
3646 (gnus-add-text-properties
3647 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3648 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3649
3650 (defun gnus-summary-extract-address-component (from)
3651 (or (car (funcall gnus-extract-address-components from))
3652 from))
3653
3654 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3655 (let ((mail-parse-charset gnus-newsgroup-charset)
3656 (ignored-from-addresses (gnus-ignored-from-addresses))
3657 ; Is it really necessary to do this next part for each summary line?
3658 ; Luckily, doesn't seem to slow things down much.
3659 (mail-parse-ignored-charsets
3660 (with-current-buffer gnus-summary-buffer
3661 gnus-newsgroup-ignored-charsets)))
3662 (or
3663 (and ignored-from-addresses
3664 (string-match ignored-from-addresses gnus-tmp-from)
3665 (let ((extra-headers (mail-header-extra header))
3666 to
3667 newsgroups)
3668 (cond
3669 ((setq to (cdr (assq 'To extra-headers)))
3670 (concat gnus-summary-to-prefix
3671 (inline
3672 (gnus-summary-extract-address-component
3673 (funcall gnus-decode-encoded-address-function to)))))
3674 ((setq newsgroups
3675 (or
3676 (cdr (assq 'Newsgroups extra-headers))
3677 (and
3678 (memq 'Newsgroups gnus-extra-headers)
3679 (eq (car (gnus-find-method-for-group
3680 gnus-newsgroup-name)) 'nntp)
3681 (gnus-group-real-name gnus-newsgroup-name))))
3682 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3683 (gnus-string-mark-left-to-right
3684 (inline
3685 (gnus-summary-extract-address-component gnus-tmp-from))))))
3686
3687 (defun gnus-summary-insert-line (gnus-tmp-header
3688 gnus-tmp-level gnus-tmp-current
3689 undownloaded gnus-tmp-unread gnus-tmp-replied
3690 gnus-tmp-expirable gnus-tmp-subject-or-nil
3691 &optional gnus-tmp-dummy gnus-tmp-score
3692 gnus-tmp-process)
3693 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3694 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3695 gnus-tmp-level)))
3696 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3697 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3698 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3699 (gnus-tmp-score-char
3700 (if (or (null gnus-summary-default-score)
3701 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3702 gnus-summary-zcore-fuzz))
3703 ? ;Whitespace
3704 (if (< gnus-tmp-score gnus-summary-default-score)
3705 gnus-score-below-mark gnus-score-over-mark)))
3706 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3707 (gnus-tmp-replied
3708 (cond (gnus-tmp-process gnus-process-mark)
3709 ((memq gnus-tmp-current gnus-newsgroup-cached)
3710 gnus-cached-mark)
3711 (gnus-tmp-replied gnus-replied-mark)
3712 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3713 gnus-forwarded-mark)
3714 ((memq gnus-tmp-current gnus-newsgroup-saved)
3715 gnus-saved-mark)
3716 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3717 gnus-unseen-mark)
3718 (t gnus-no-mark)))
3719 (gnus-tmp-downloaded
3720 (cond (undownloaded
3721 gnus-undownloaded-mark)
3722 (gnus-newsgroup-agentized
3723 gnus-downloaded-mark)
3724 (t
3725 gnus-no-mark)))
3726 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3727 (gnus-tmp-name
3728 (cond
3729 ((string-match "<[^>]+> *$" gnus-tmp-from)
3730 (let ((beg (match-beginning 0)))
3731 (or (and (string-match "^\".+\"" gnus-tmp-from)
3732 (substring gnus-tmp-from 1 (1- (match-end 0))))
3733 (substring gnus-tmp-from 0 beg))))
3734 ((string-match "(.+)" gnus-tmp-from)
3735 (substring gnus-tmp-from
3736 (1+ (match-beginning 0)) (1- (match-end 0))))
3737 (t gnus-tmp-from)))
3738 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3739 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3740 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3741 (inhibit-read-only t))
3742 (when (string= gnus-tmp-name "")
3743 (setq gnus-tmp-name gnus-tmp-from))
3744 (unless (numberp gnus-tmp-lines)
3745 (setq gnus-tmp-lines -1))
3746 (if (= gnus-tmp-lines -1)
3747 (setq gnus-tmp-lines "?")
3748 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3749 (condition-case ()
3750 (gnus-put-text-property
3751 (point)
3752 (progn (eval gnus-summary-line-format-spec) (point))
3753 'gnus-number gnus-tmp-number)
3754 (error (gnus-message 5 "Error updating the summary line")))
3755 (when (gnus-visual-p 'summary-highlight 'highlight)
3756 (forward-line -1)
3757 (gnus-summary-highlight-line)
3758 (gnus-run-hooks 'gnus-summary-update-hook)
3759 (forward-line 1))))
3760
3761 (defun gnus-summary-update-line (&optional dont-update)
3762 "Update summary line after change."
3763 (when (and gnus-summary-default-score
3764 (not gnus-summary-inhibit-highlight))
3765 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3766 (article (gnus-summary-article-number))
3767 (score (gnus-summary-article-score article)))
3768 (unless dont-update
3769 (if (and gnus-summary-mark-below
3770 (< (gnus-summary-article-score)
3771 gnus-summary-mark-below))
3772 ;; This article has a low score, so we mark it as read.
3773 (when (memq article gnus-newsgroup-unreads)
3774 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3775 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3776 ;; This article was previously marked as read on account
3777 ;; of a low score, but now it has risen, so we mark it as
3778 ;; unread.
3779 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3780 (gnus-summary-update-mark
3781 (if (or (null gnus-summary-default-score)
3782 (<= (abs (- score gnus-summary-default-score))
3783 gnus-summary-zcore-fuzz))
3784 ? ;Whitespace
3785 (if (< score gnus-summary-default-score)
3786 gnus-score-below-mark gnus-score-over-mark))
3787 'score))
3788 ;; Do visual highlighting.
3789 (when (gnus-visual-p 'summary-highlight 'highlight)
3790 (gnus-summary-highlight-line)
3791 (gnus-run-hooks 'gnus-summary-update-hook)))))
3792
3793 (defvar gnus-tmp-new-adopts nil)
3794
3795 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3796 "Return the number of articles in THREAD.
3797 This may be 0 in some cases -- if none of the articles in
3798 the thread are to be displayed."
3799 (let* ((number
3800 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3801 (cond
3802 ((not (listp thread))
3803 1)
3804 ((and (consp thread) (cdr thread))
3805 (apply
3806 '+ 1 (mapcar
3807 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3808 ((null thread)
3809 1)
3810 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3811 1)
3812 (t 0))))
3813 (when (and level (zerop level) gnus-tmp-new-adopts)
3814 (incf number
3815 (apply '+ (mapcar
3816 'gnus-summary-number-of-articles-in-thread
3817 gnus-tmp-new-adopts))))
3818 (if char
3819 (if (> number 1) gnus-not-empty-thread-mark
3820 gnus-empty-thread-mark)
3821 number)))
3822
3823 (defsubst gnus-summary-line-message-size (head)
3824 "Return pretty-printed version of message size.
3825 This function is intended to be used in
3826 `gnus-summary-line-format-alist'."
3827 (let ((c (or (mail-header-chars head) -1)))
3828 (cond ((< c 0) "n/a") ; chars not available
3829 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3830 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3831 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3832 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3833
3834 (defcustom gnus-user-date-format-alist
3835 '(((gnus-seconds-today) . "Today, %H:%M")
3836 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3837 (604800 . "%A %H:%M") ; That's one week
3838 ((gnus-seconds-month) . "%A %d")
3839 ((gnus-seconds-year) . "%B %d")
3840 (t . "%b %d %Y")) ; This one is used when no other
3841 ; does match
3842 "Specifies date format depending on age of article.
3843 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3844 seconds) or a Lisp expression evaluating to a number. When the age of
3845 the article is less than this number, then use `format-time-string'
3846 with the corresponding FORMAT for displaying the date of the article.
3847 If AGE is not a number or a Lisp expression evaluating to a
3848 non-number, then the corresponding FORMAT is used as a default value.
3849
3850 Note that the list is processed from the beginning, so it should be
3851 sorted by ascending AGE. Also note that items following the first
3852 non-number AGE will be ignored.
3853
3854 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3855 and `gnus-seconds-year' in the AGE spec. They return the number of
3856 seconds passed since the start of today, of this month, of this year,
3857 respectively."
3858 :version "24.1"
3859 :group 'gnus-summary-format
3860 :type '(alist :key-type sexp :value-type string))
3861
3862 (defun gnus-user-date (messy-date)
3863 "Format the messy-date according to `gnus-user-date-format-alist'.
3864 Returns \" ? \" if there's bad input or if another error occurs.
3865 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3866 (condition-case ()
3867 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3868 (now (gnus-float-time))
3869 ;;If we don't find something suitable we'll use this one
3870 (my-format "%b %d '%y"))
3871 (let* ((difference (- now messy-date))
3872 (templist gnus-user-date-format-alist)
3873 (top (eval (caar templist))))
3874 (while (if (numberp top) (< top difference) (not top))
3875 (progn
3876 (setq templist (cdr templist))
3877 (setq top (eval (caar templist)))))
3878 (if (stringp (cdr (car templist)))
3879 (setq my-format (cdr (car templist)))))
3880 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3881 (error " ? ")))
3882
3883 (defun gnus-summary-set-local-parameters (group)
3884 "Go through the local params of GROUP and set all variable specs in that list."
3885 (let ((vars '(quit-config active))) ; Ignore things that aren't
3886 ; really variables.
3887 (dolist (elem (gnus-group-find-parameter group))
3888 (and (consp elem) ; Has to be a cons.
3889 (consp (cdr elem)) ; The cdr has to be a list.
3890 (symbolp (car elem)) ; Has to be a symbol in there.
3891 (not (memq (car elem) vars))
3892 (ignore-errors
3893 (push (car elem) vars)
3894 ;; Variables like `gnus-show-threads' that are globally
3895 ;; bound, if used as group parameters, need to get to be
3896 ;; buffer-local, whereas just parameters like `gcc-self',
3897 ;; `timestamp', etc. should not be bound as variables.
3898 (if (boundp (car elem))
3899 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3900 (eval (nth 1 elem))))))))
3901
3902 (defun gnus-summary-read-group (group &optional show-all no-article
3903 kill-buffer no-display backward
3904 select-articles)
3905 "Start reading news in newsgroup GROUP.
3906 If SHOW-ALL is non-nil, already read articles are also listed.
3907 If NO-ARTICLE is non-nil, no article is selected initially.
3908 If NO-DISPLAY, don't generate the summary buffer contents.
3909 If KILL-BUFFER, it should be a buffer that's killed once the new
3910 summary buffer has been generated.
3911 If BACKWARD, move point to the previous group in the group buffer
3912 If SELECT-ARTICLES, only select those articles from GROUP."
3913 (let (result)
3914 (while (and group
3915 (null (setq result
3916 (let ((gnus-auto-select-next nil))
3917 (or (gnus-summary-read-group-1
3918 group show-all no-article
3919 kill-buffer no-display
3920 select-articles)
3921 (setq show-all nil
3922 select-articles nil)))))
3923 (eq gnus-auto-select-next 'quietly))
3924 (set-buffer gnus-group-buffer)
3925 ;; The entry function called above goes to the next
3926 ;; group automatically, so we go two groups back
3927 ;; if we are searching for the previous group.
3928 (when backward
3929 (gnus-group-prev-unread-group 2))
3930 (if (not (equal group (gnus-group-group-name)))
3931 (setq group (gnus-group-group-name))
3932 (setq group nil)))
3933 result))
3934
3935 (defun gnus-summary-read-group-1 (group show-all no-article
3936 kill-buffer no-display
3937 &optional select-articles)
3938 ;; Killed foreign groups can't be entered.
3939 ;; (when (and (not (gnus-group-native-p group))
3940 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3941 ;; (error "Dead non-native groups can't be entered"))
3942 (gnus-message 7 "Retrieving newsgroup: %s..."
3943 (gnus-group-decoded-name group))
3944 (let* ((new-group (gnus-summary-setup-buffer group))
3945 (quit-config (gnus-group-quit-config group))
3946 (did-select (and new-group (gnus-select-newsgroup
3947 group show-all select-articles))))
3948 (cond
3949 ;; This summary buffer exists already, so we just select it.
3950 ((not new-group)
3951 (gnus-set-global-variables)
3952 (when kill-buffer
3953 (gnus-kill-or-deaden-summary kill-buffer))
3954 (gnus-configure-windows 'summary 'force)
3955 (gnus-set-mode-line 'summary)
3956 (gnus-summary-position-point)
3957 (message "")
3958 t)
3959 ;; We couldn't select this group.
3960 ((null did-select)
3961 (when (and (eq major-mode 'gnus-summary-mode)
3962 (not (equal (current-buffer) kill-buffer)))
3963 (kill-buffer (current-buffer))
3964 (if (not quit-config)
3965 (progn
3966 ;; Update the info -- marks might need to be removed,
3967 ;; for instance.
3968 (gnus-summary-update-info)
3969 (set-buffer gnus-group-buffer)
3970 (gnus-group-jump-to-group group)
3971 (gnus-group-next-unread-group 1))
3972 (gnus-handle-ephemeral-exit quit-config)))
3973 (if (null (gnus-list-of-unread-articles group))
3974 (gnus-message 3 "Group %s contains no messages" group)
3975 (gnus-message 3 "Can't select group"))
3976 nil)
3977 ;; The user did a `C-g' while prompting for number of articles,
3978 ;; so we exit this group.
3979 ((eq did-select 'quit)
3980 (and (eq major-mode 'gnus-summary-mode)
3981 (not (equal (current-buffer) kill-buffer))
3982 (kill-buffer (current-buffer)))
3983 (when kill-buffer
3984 (gnus-kill-or-deaden-summary kill-buffer))
3985 (if (not quit-config)
3986 (progn
3987 (set-buffer gnus-group-buffer)
3988 (gnus-group-jump-to-group group)
3989 (gnus-configure-windows 'group 'force))
3990 (gnus-handle-ephemeral-exit quit-config))
3991 ;; Finally signal the quit.
3992 (signal 'quit nil))
3993 ;; The group was successfully selected.
3994 (t
3995 (gnus-set-global-variables)
3996 ;; Save the active value in effect when the group was entered.
3997 (setq gnus-newsgroup-active
3998 (gnus-copy-sequence
3999 (gnus-active gnus-newsgroup-name)))
4000 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4001 ;; You can change the summary buffer in some way with this hook.
4002 (gnus-run-hooks 'gnus-select-group-hook)
4003 (when (memq 'summary (gnus-update-format-specifications
4004 nil 'summary 'summary-mode 'summary-dummy))
4005 ;; The format specification for the summary line was updated,
4006 ;; so we need to update the mark positions as well.
4007 (gnus-update-summary-mark-positions))
4008 ;; Do score processing.
4009 (when gnus-use-scoring
4010 (gnus-possibly-score-headers))
4011 ;; Check whether to fill in the gaps in the threads.
4012 (when gnus-build-sparse-threads
4013 (gnus-build-sparse-threads))
4014 ;; Find the initial limit.
4015 (if show-all
4016 (let ((gnus-newsgroup-dormant nil))
4017 (gnus-summary-initial-limit show-all))
4018 (gnus-summary-initial-limit show-all))
4019 ;; Generate the summary buffer.
4020 (unless no-display
4021 (gnus-summary-prepare))
4022 (when gnus-use-trees
4023 (gnus-tree-open group)
4024 (setq gnus-summary-highlight-line-function
4025 'gnus-tree-highlight-article))
4026 ;; If the summary buffer is empty, but there are some low-scored
4027 ;; articles or some excluded dormants, we include these in the
4028 ;; buffer.
4029 (when (and (zerop (buffer-size))
4030 (not no-display))
4031 (cond (gnus-newsgroup-dormant
4032 (gnus-summary-limit-include-dormant))
4033 ((and gnus-newsgroup-scored show-all)
4034 (gnus-summary-limit-include-expunged t))))
4035 ;; Function `gnus-apply-kill-file' must be called in this hook.
4036 (gnus-run-hooks 'gnus-apply-kill-hook)
4037 (if (and (zerop (buffer-size))
4038 (not no-display))
4039 (progn
4040 ;; This newsgroup is empty.
4041 (gnus-summary-catchup-and-exit nil t)
4042 (gnus-message 6 "No unread news")
4043 (when kill-buffer
4044 (gnus-kill-or-deaden-summary kill-buffer))
4045 ;; Return nil from this function.
4046 nil)
4047 ;; Hide conversation thread subtrees. We cannot do this in
4048 ;; gnus-summary-prepare-hook since kill processing may not
4049 ;; work with hidden articles.
4050 (gnus-summary-maybe-hide-threads)
4051 (gnus-configure-windows 'summary)
4052 (when kill-buffer
4053 (gnus-kill-or-deaden-summary kill-buffer))
4054 (gnus-summary-auto-select-subject)
4055 ;; Show first unread article if requested.
4056 (if (and (not no-article)
4057 (not no-display)
4058 gnus-newsgroup-unreads
4059 gnus-auto-select-first)
4060 (progn
4061 (let ((art (gnus-summary-article-number)))
4062 (unless (and (not gnus-plugged)
4063 (or (memq art gnus-newsgroup-undownloaded)
4064 (memq art gnus-newsgroup-downloadable)))
4065 (gnus-summary-goto-article art))))
4066 ;; Don't select any articles.
4067 (gnus-summary-position-point)
4068 (gnus-configure-windows 'summary 'force)
4069 (gnus-set-mode-line 'summary))
4070 (when (and gnus-auto-center-group
4071 (get-buffer-window gnus-group-buffer t))
4072 ;; Gotta use windows, because recenter does weird stuff if
4073 ;; the current buffer ain't the displayed window.
4074 (let ((owin (selected-window)))
4075 (select-window (get-buffer-window gnus-group-buffer t))
4076 (when (gnus-group-goto-group group)
4077 (recenter))
4078 (select-window owin)))
4079 ;; Mark this buffer as "prepared".
4080 (setq gnus-newsgroup-prepared t)
4081 (gnus-run-hooks 'gnus-summary-prepared-hook)
4082 (unless (gnus-ephemeral-group-p group)
4083 (gnus-group-update-group group nil t))
4084 t)))))
4085
4086 (defun gnus-summary-auto-select-subject ()
4087 "Select the subject line on initial group entry."
4088 (goto-char (point-min))
4089 (cond
4090 ((eq gnus-auto-select-subject 'best)
4091 (gnus-summary-best-unread-subject))
4092 ((eq gnus-auto-select-subject 'unread)
4093 (gnus-summary-first-unread-subject))
4094 ((eq gnus-auto-select-subject 'unseen)
4095 (gnus-summary-first-unseen-subject))
4096 ((eq gnus-auto-select-subject 'unseen-or-unread)
4097 (gnus-summary-first-unseen-or-unread-subject))
4098 ((eq gnus-auto-select-subject 'first)
4099 ;; Do nothing.
4100 )
4101 ((functionp gnus-auto-select-subject)
4102 (funcall gnus-auto-select-subject))))
4103
4104 (defun gnus-summary-prepare ()
4105 "Generate the summary buffer."
4106 (interactive)
4107 (let ((inhibit-read-only t))
4108 (erase-buffer)
4109 (setq gnus-newsgroup-data nil
4110 gnus-newsgroup-data-reverse nil)
4111 (gnus-run-hooks 'gnus-summary-generate-hook)
4112 ;; Generate the buffer, either with threads or without.
4113 (when gnus-newsgroup-headers
4114 (gnus-summary-prepare-threads
4115 (if gnus-show-threads
4116 (gnus-sort-gathered-threads
4117 (funcall gnus-summary-thread-gathering-function
4118 (gnus-sort-threads
4119 (gnus-cut-threads (gnus-make-threads)))))
4120 ;; Unthreaded display.
4121 (gnus-sort-articles gnus-newsgroup-headers))))
4122 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4123 ;; Call hooks for modifying summary buffer.
4124 (goto-char (point-min))
4125 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4126
4127 (defsubst gnus-general-simplify-subject (subject)
4128 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4129 (setq subject
4130 (cond
4131 ;; Truncate the subject.
4132 (gnus-simplify-subject-functions
4133 (gnus-map-function gnus-simplify-subject-functions subject))
4134 ((numberp gnus-summary-gather-subject-limit)
4135 (setq subject (gnus-simplify-subject-re subject))
4136 (if (> (length subject) gnus-summary-gather-subject-limit)
4137 (substring subject 0 gnus-summary-gather-subject-limit)
4138 subject))
4139 ;; Fuzzily simplify it.
4140 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4141 (gnus-simplify-subject-fuzzy subject))
4142 ;; Just remove the leading "Re:".
4143 (t
4144 (gnus-simplify-subject-re subject))))
4145
4146 (if (and gnus-summary-gather-exclude-subject
4147 (string-match gnus-summary-gather-exclude-subject subject))
4148 nil ; This article shouldn't be gathered
4149 subject))
4150
4151 (defun gnus-summary-simplify-subject-query ()
4152 "Query where the respool algorithm would put this article."
4153 (interactive)
4154 (gnus-summary-select-article)
4155 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4156
4157 (defun gnus-gather-threads-by-subject (threads)
4158 "Gather threads by looking at Subject headers."
4159 (if (not gnus-summary-make-false-root)
4160 threads
4161 (let ((hashtb (gnus-make-hashtable 1024))
4162 (prev threads)
4163 (result threads)
4164 subject hthread whole-subject)
4165 (while threads
4166 (setq subject (gnus-general-simplify-subject
4167 (setq whole-subject (mail-header-subject
4168 (caar threads)))))
4169 (when subject
4170 (if (setq hthread (gnus-gethash subject hashtb))
4171 (progn
4172 ;; We enter a dummy root into the thread, if we
4173 ;; haven't done that already.
4174 (unless (stringp (caar hthread))
4175 (setcar hthread (list whole-subject (car hthread))))
4176 ;; We add this new gathered thread to this gathered
4177 ;; thread.
4178 (setcdr (car hthread)
4179 (nconc (cdar hthread) (list (car threads))))
4180 ;; Remove it from the list of threads.
4181 (setcdr prev (cdr threads))
4182 (setq threads prev))
4183 ;; Enter this thread into the hash table.
4184 (gnus-sethash subject
4185 (if gnus-summary-make-false-root-always
4186 (progn
4187 ;; If you want a dummy root above all
4188 ;; threads...
4189 (setcar threads (list whole-subject
4190 (car threads)))
4191 threads)
4192 threads)
4193 hashtb)))
4194 (setq prev threads)
4195 (setq threads (cdr threads)))
4196 result)))
4197
4198 (defun gnus-gather-threads-by-references (threads)
4199 "Gather threads by looking at References headers."
4200 (let ((idhashtb (gnus-make-hashtable 1024))
4201 (thhashtb (gnus-make-hashtable 1024))
4202 (prev threads)
4203 (result threads)
4204 ids references id gthread gid entered ref)
4205 (while threads
4206 (when (setq references (mail-header-references (caar threads)))
4207 (setq id (mail-header-id (caar threads))
4208 ids (inline (gnus-split-references references))
4209 entered nil)
4210 (while (setq ref (pop ids))
4211 (setq ids (delete ref ids))
4212 (if (not (setq gid (gnus-gethash ref idhashtb)))
4213 (progn
4214 (gnus-sethash ref id idhashtb)
4215 (gnus-sethash id threads thhashtb))
4216 (setq gthread (gnus-gethash gid thhashtb))
4217 (unless entered
4218 ;; We enter a dummy root into the thread, if we
4219 ;; haven't done that already.
4220 (unless (stringp (caar gthread))
4221 (setcar gthread (list (mail-header-subject (caar gthread))
4222 (car gthread))))
4223 ;; We add this new gathered thread to this gathered
4224 ;; thread.
4225 (setcdr (car gthread)
4226 (nconc (cdar gthread) (list (car threads)))))
4227 ;; Add it into the thread hash table.
4228 (gnus-sethash id gthread thhashtb)
4229 (setq entered t)
4230 ;; Remove it from the list of threads.
4231 (setcdr prev (cdr threads))
4232 (setq threads prev))))
4233 (setq prev threads)
4234 (setq threads (cdr threads)))
4235 result))
4236
4237 (defun gnus-sort-gathered-threads (threads)
4238 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4239 (let ((result threads))
4240 (while threads
4241 (when (stringp (caar threads))
4242 (setcdr (car threads)
4243 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4244 (setq threads (cdr threads)))
4245 result))
4246
4247 (defun gnus-thread-loop-p (root thread)
4248 "Say whether ROOT is in THREAD."
4249 (let ((stack (list thread))
4250 (infloop 0)
4251 th)
4252 (while (setq thread (pop stack))
4253 (setq th (cdr thread))
4254 (while (and th
4255 (not (eq (caar th) root)))
4256 (pop th))
4257 (if th
4258 ;; We have found a loop.
4259 (let (ref-dep)
4260 (setcdr thread (delq (car th) (cdr thread)))
4261 (if (boundp (setq ref-dep (intern "none"
4262 gnus-newsgroup-dependencies)))
4263 (setcdr (symbol-value ref-dep)
4264 (nconc (cdr (symbol-value ref-dep))
4265 (list (car th))))
4266 (set ref-dep (list nil (car th))))
4267 (setq infloop 1
4268 stack nil))
4269 ;; Push all the subthreads onto the stack.
4270 (push (cdr thread) stack)))
4271 infloop))
4272
4273 (defun gnus-make-threads ()
4274 "Go through the dependency hashtb and find the roots. Return all threads."
4275 (let (threads)
4276 (while (catch 'infloop
4277 (mapatoms
4278 (lambda (refs)
4279 ;; Deal with self-referencing References loops.
4280 (when (and (car (symbol-value refs))
4281 (not (zerop
4282 (apply
4283 '+
4284 (mapcar
4285 (lambda (thread)
4286 (gnus-thread-loop-p
4287 (car (symbol-value refs)) thread))
4288 (cdr (symbol-value refs)))))))
4289 (setq threads nil)
4290 (throw 'infloop t))
4291 (unless (car (symbol-value refs))
4292 ;; These threads do not refer back to any other
4293 ;; articles, so they're roots.
4294 (setq threads (append (cdr (symbol-value refs)) threads))))
4295 gnus-newsgroup-dependencies)))
4296 threads))
4297
4298 ;; Build the thread tree.
4299 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4300 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4301
4302 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4303 if it was already present.
4304
4305 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4306 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4307 Message-IDs will be renamed to a unique Message-ID before being
4308 entered.
4309
4310 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4311 (let* ((id (mail-header-id header))
4312 (id-dep (and id (intern id dependencies)))
4313 parent-id ref ref-dep ref-header replaced)
4314 ;; Enter this `header' in the `dependencies' table.
4315 (cond
4316 ((not id-dep)
4317 (setq header nil))
4318 ;; The first two cases do the normal part: enter a new `header'
4319 ;; in the `dependencies' table.
4320 ((not (boundp id-dep))
4321 (set id-dep (list header)))
4322 ((null (car (symbol-value id-dep)))
4323 (setcar (symbol-value id-dep) header))
4324
4325 ;; From here the `header' was already present in the
4326 ;; `dependencies' table.
4327 (force-new
4328 ;; Overrides an existing entry;
4329 ;; just set the header part of the entry.
4330 (setcar (symbol-value id-dep) header)
4331 (setq replaced t))
4332
4333 ;; Renames the existing `header' to a unique Message-ID.
4334 ((not gnus-summary-ignore-duplicates)
4335 ;; An article with this Message-ID has already been seen.
4336 ;; We rename the Message-ID.
4337 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4338 (list header))
4339 (mail-header-set-id header id))
4340
4341 ;; The last case ignores an existing entry, except it adds any
4342 ;; additional Xrefs (in case the two articles came from different
4343 ;; servers.
4344 ;; Also sets `header' to `nil' meaning that the `dependencies'
4345 ;; table was *not* modified.
4346 (t
4347 (mail-header-set-xref
4348 (car (symbol-value id-dep))
4349 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4350 "")
4351 (or (mail-header-xref header) "")))
4352 (setq header nil)))
4353
4354 (when (and header (not replaced))
4355 ;; First check that we are not creating a References loop.
4356 (setq parent-id (gnus-parent-id (mail-header-references header)))
4357 (setq ref parent-id)
4358 (while (and ref
4359 (setq ref-dep (intern-soft ref dependencies))
4360 (boundp ref-dep)
4361 (setq ref-header (car (symbol-value ref-dep))))
4362 (if (string= id ref)
4363 ;; Yuk! This is a reference loop. Make the article be a
4364 ;; root article.
4365 (progn
4366 (mail-header-set-references (car (symbol-value id-dep)) "none")
4367 (setq ref nil)
4368 (setq parent-id nil))
4369 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4370 (setq ref-dep (intern (or parent-id "none") dependencies))
4371 (if (boundp ref-dep)
4372 (setcdr (symbol-value ref-dep)
4373 (nconc (cdr (symbol-value ref-dep))
4374 (list (symbol-value id-dep))))
4375 (set ref-dep (list nil (symbol-value id-dep)))))
4376 header))
4377
4378 (defun gnus-extract-message-id-from-in-reply-to (string)
4379 (if (string-match "<[^>]+>" string)
4380 (substring string (match-beginning 0) (match-end 0))
4381 nil))
4382
4383 (defun gnus-build-sparse-threads ()
4384 (let ((headers gnus-newsgroup-headers)
4385 (mail-parse-charset gnus-newsgroup-charset)
4386 (gnus-summary-ignore-duplicates t)
4387 header references generation relations
4388 subject child end new-child date)
4389 ;; First we create an alist of generations/relations, where
4390 ;; generations is how much we trust the relation, and the relation
4391 ;; is parent/child.
4392 (gnus-message 7 "Making sparse threads...")
4393 (save-excursion
4394 (nnheader-set-temp-buffer " *gnus sparse threads*")
4395 (while (setq header (pop headers))
4396 (when (and (setq references (mail-header-references header))
4397 (not (string= references "")))
4398 (insert references)
4399 (setq child (mail-header-id header)
4400 subject (mail-header-subject header)
4401 date (mail-header-date header)
4402 generation 0)
4403 (while (search-backward ">" nil t)
4404 (setq end (1+ (point)))
4405 (when (search-backward "<" nil t)
4406 (setq new-child (buffer-substring (point) end))
4407 (push (list (incf generation)
4408 child (setq child new-child)
4409 subject date)
4410 relations)))
4411 (when child
4412 (push (list (1+ generation) child nil subject) relations))
4413 (erase-buffer)))
4414 (kill-buffer (current-buffer)))
4415 ;; Sort over trustworthiness.
4416 (dolist (relation (sort relations 'car-less-than-car))
4417 (when (gnus-dependencies-add-header
4418 (make-full-mail-header
4419 gnus-reffed-article-number
4420 (nth 3 relation) "" (or (nth 4 relation) "")
4421 (nth 1 relation)
4422 (or (nth 2 relation) "") 0 0 "")
4423 gnus-newsgroup-dependencies nil)
4424 (push gnus-reffed-article-number gnus-newsgroup-limit)
4425 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4426 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4427 gnus-newsgroup-reads)
4428 (decf gnus-reffed-article-number)))
4429 (gnus-message 7 "Making sparse threads...done")))
4430
4431 (defun gnus-build-old-threads ()
4432 ;; Look at all the articles that refer back to old articles, and
4433 ;; fetch the headers for the articles that aren't there. This will
4434 ;; build complete threads - if the roots haven't been expired by the
4435 ;; server, that is.
4436 (let ((mail-parse-charset gnus-newsgroup-charset)
4437 id heads)
4438 (mapatoms
4439 (lambda (refs)
4440 (when (not (car (symbol-value refs)))
4441 (setq heads (cdr (symbol-value refs)))
4442 (while heads
4443 (if (memq (mail-header-number (caar heads))
4444 gnus-newsgroup-dormant)
4445 (setq heads (cdr heads))
4446 (setq id (symbol-name refs))
4447 (while (and (setq id (gnus-build-get-header id))
4448 (not (car (gnus-id-to-thread id)))))
4449 (setq heads nil)))))
4450 gnus-newsgroup-dependencies)))
4451
4452 (defsubst gnus-remove-odd-characters (string)
4453 "Translate STRING into something that doesn't contain weird characters."
4454 (mm-subst-char-in-string
4455 ?\r ?\-
4456 (mm-subst-char-in-string ?\n ?\- string t) t))
4457
4458 ;; This function has to be called with point after the article number
4459 ;; on the beginning of the line.
4460 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4461 (let ((eol (point-at-eol))
4462 (buffer (current-buffer))
4463 header references in-reply-to)
4464
4465 ;; overview: [num subject from date id refs chars lines misc]
4466 (unwind-protect
4467 (let (x)
4468 (narrow-to-region (point) eol)
4469 (unless (eobp)
4470 (forward-char))
4471
4472 (setq header
4473 (make-full-mail-header
4474 number ; number
4475 (condition-case () ; subject
4476 (gnus-remove-odd-characters
4477 (funcall gnus-decode-encoded-word-function
4478 (setq x (nnheader-nov-field))))
4479 (error x))
4480 (condition-case () ; from
4481 (gnus-remove-odd-characters
4482 (funcall gnus-decode-encoded-address-function
4483 (setq x (nnheader-nov-field))))
4484 (error x))
4485 (nnheader-nov-field) ; date
4486 (nnheader-nov-read-message-id number) ; id
4487 (setq references (nnheader-nov-field)) ; refs
4488 (nnheader-nov-read-integer) ; chars
4489 (nnheader-nov-read-integer) ; lines
4490 (unless (eobp)
4491 (if (looking-at "Xref: ")
4492 (goto-char (match-end 0)))
4493 (nnheader-nov-field)) ; Xref
4494 (nnheader-nov-parse-extra)))) ; extra
4495
4496 (widen))
4497
4498 (when (and (string= references "")
4499 (setq in-reply-to (mail-header-extra header))
4500 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4501 (mail-header-set-references
4502 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4503
4504 (when gnus-alter-header-function
4505 (funcall gnus-alter-header-function header))
4506 (gnus-dependencies-add-header header dependencies force-new)))
4507
4508 (defun gnus-build-get-header (id)
4509 "Look through the buffer of NOV lines and find the header to ID.
4510 Enter this line into the dependencies hash table, and return
4511 the id of the parent article (if any)."
4512 (let ((deps gnus-newsgroup-dependencies)
4513 found header)
4514 (prog1
4515 (with-current-buffer nntp-server-buffer
4516 (let ((case-fold-search nil))
4517 (goto-char (point-min))
4518 (while (and (not found)
4519 (search-forward id nil t))
4520 (beginning-of-line)
4521 (setq found (looking-at
4522 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4523 (regexp-quote id))))
4524 (or found (beginning-of-line 2)))
4525 (when found
4526 (beginning-of-line)
4527 (and
4528 (setq header (gnus-nov-parse-line
4529 (read (current-buffer)) deps))
4530 (gnus-parent-id (mail-header-references header))))))
4531 (when header
4532 (let ((number (mail-header-number header)))
4533 (push number gnus-newsgroup-limit)
4534 (push header gnus-newsgroup-headers)
4535 (if (memq number gnus-newsgroup-unselected)
4536 (progn
4537 (setq gnus-newsgroup-unreads
4538 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4539 number))
4540 (setq gnus-newsgroup-unselected
4541 (delq number gnus-newsgroup-unselected)))
4542 (push number gnus-newsgroup-ancient)))))))
4543
4544 (defun gnus-build-all-threads ()
4545 "Read all the headers."
4546 (let ((gnus-summary-ignore-duplicates t)
4547 (mail-parse-charset gnus-newsgroup-charset)
4548 (dependencies gnus-newsgroup-dependencies)
4549 header article)
4550 (with-current-buffer nntp-server-buffer
4551 (let ((case-fold-search nil))
4552 (goto-char (point-min))
4553 (while (not (eobp))
4554 (ignore-errors
4555 (setq article (read (current-buffer))
4556 header (gnus-nov-parse-line article dependencies t)))
4557 (when header
4558 (with-current-buffer gnus-summary-buffer
4559 (push header gnus-newsgroup-headers)
4560 (if (memq (setq article (mail-header-number header))
4561 gnus-newsgroup-unselected)
4562 (progn
4563 (setq gnus-newsgroup-unreads
4564 (gnus-add-to-sorted-list
4565 gnus-newsgroup-unreads article))
4566 (setq gnus-newsgroup-unselected
4567 (delq article gnus-newsgroup-unselected)))
4568 (push article gnus-newsgroup-ancient)))
4569 (forward-line 1)))))))
4570
4571 (defun gnus-summary-update-article-line (article header)
4572 "Update the line for ARTICLE using HEADER."
4573 (let* ((id (mail-header-id header))
4574 (thread (gnus-id-to-thread id)))
4575 (unless thread
4576 (error "Article in no thread"))
4577 ;; Update the thread.
4578 (setcar thread header)
4579 (gnus-summary-goto-subject article)
4580 (let* ((datal (gnus-data-find-list article))
4581 (data (car datal))
4582 (inhibit-read-only t)
4583 (level (gnus-summary-thread-level)))
4584 (gnus-delete-line)
4585 (let ((inserted (- (point)
4586 (progn
4587 (gnus-summary-insert-line
4588 header level nil
4589 (memq article gnus-newsgroup-undownloaded)
4590 (gnus-article-mark article)
4591 (memq article gnus-newsgroup-replied)
4592 (memq article gnus-newsgroup-expirable)
4593 ;; Only insert the Subject string when it's different
4594 ;; from the previous Subject string.
4595 (if (and
4596 gnus-show-threads
4597 (gnus-subject-equal
4598 (condition-case ()
4599 (mail-header-subject
4600 (gnus-data-header
4601 (cadr
4602 (gnus-data-find-list
4603 article
4604 (gnus-data-list t)))))
4605 ;; Error on the side of excessive subjects.
4606 (error ""))
4607 (mail-header-subject header)))
4608 ""
4609 (mail-header-subject header))
4610 nil (cdr (assq article gnus-newsgroup-scored))
4611 (memq article gnus-newsgroup-processable))
4612 (point)))))
4613 (when (cdr datal)
4614 (gnus-data-update-list
4615 (cdr datal)
4616 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4617
4618 (defun gnus-summary-update-article (article &optional iheader)
4619 "Update ARTICLE in the summary buffer."
4620 (set-buffer gnus-summary-buffer)
4621 (let* ((header (gnus-summary-article-header article))
4622 (id (mail-header-id header))
4623 (data (gnus-data-find article))
4624 (thread (gnus-id-to-thread id))
4625 (references (mail-header-references header))
4626 (parent
4627 (gnus-id-to-thread
4628 (or (gnus-parent-id
4629 (when (and references
4630 (not (equal "" references)))
4631 references))
4632 "none")))
4633 (inhibit-read-only t)
4634 (old (car thread)))
4635 (when thread
4636 (unless iheader
4637 (setcar thread nil)
4638 (when parent
4639 (delq thread parent)))
4640 (if (gnus-summary-insert-subject id header)
4641 ;; Set the (possibly) new article number in the data structure.
4642 (gnus-data-set-number data (gnus-id-to-article id))
4643 (setcar thread old)
4644 nil))))
4645
4646 (defun gnus-rebuild-thread (id &optional line)
4647 "Rebuild the thread containing ID.
4648 If LINE, insert the rebuilt thread starting on line LINE."
4649 (let ((inhibit-read-only t)
4650 old-pos current thread data)
4651 (if (not gnus-show-threads)
4652 (setq thread (list (car (gnus-id-to-thread id))))
4653 ;; Get the thread this article is part of.
4654 (setq thread (gnus-remove-thread id)))
4655 (setq old-pos (point-at-bol))
4656 (setq current (save-excursion
4657 (and (re-search-backward "[\r\n]" nil t)
4658 (gnus-summary-article-number))))
4659 ;; If this is a gathered thread, we have to go some re-gathering.
4660 (when (stringp (car thread))
4661 (let ((subject (car thread))
4662 roots thr)
4663 (setq thread (cdr thread))
4664 (while thread
4665 (unless (memq (setq thr (gnus-id-to-thread
4666 (gnus-root-id
4667 (mail-header-id (caar thread)))))
4668 roots)
4669 (push thr roots))
4670 (setq thread (cdr thread)))
4671 ;; We now have all (unique) roots.
4672 (if (= (length roots) 1)
4673 ;; All the loose roots are now one solid root.
4674 (setq thread (car roots))
4675 (setq thread (cons subject (gnus-sort-threads roots))))))
4676 (let (threads)
4677 ;; We then insert this thread into the summary buffer.
4678 (when line
4679 (goto-char (point-min))
4680 (forward-line (1- line)))
4681 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4682 (if gnus-show-threads
4683 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4684 (gnus-summary-prepare-unthreaded thread))
4685 (setq data (nreverse gnus-newsgroup-data))
4686 (setq threads gnus-newsgroup-threads))
4687 ;; We splice the new data into the data structure.
4688 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4689 ;;!!! then we want to insert at the beginning of the buffer.
4690 ;;!!! That happens to be true with Gnus now, but that may
4691 ;;!!! change in the future. Perhaps.
4692 (gnus-data-enter-list
4693 (if line nil current) data (- (point) old-pos))
4694 (setq gnus-newsgroup-threads
4695 (nconc threads gnus-newsgroup-threads))
4696 (gnus-data-compute-positions))))
4697
4698 (defun gnus-number-to-header (number)
4699 "Return the header for article NUMBER."
4700 (let ((headers gnus-newsgroup-headers))
4701 (while (and headers
4702 (not (= number (mail-header-number (car headers)))))
4703 (pop headers))
4704 (when headers
4705 (car headers))))
4706
4707 (defun gnus-parent-headers (in-headers &optional generation)
4708 "Return the headers of the GENERATIONth parent of HEADERS."
4709 (unless generation
4710 (setq generation 1))
4711 (let ((parent t)
4712 (headers in-headers)
4713 references)
4714 (while (and parent
4715 (not (zerop generation))
4716 (setq references (mail-header-references headers)))
4717 (setq headers (if (and references
4718 (setq parent (gnus-parent-id references)))
4719 (car (gnus-id-to-thread parent))
4720 nil))
4721 (decf generation))
4722 (and (not (eq headers in-headers))
4723 headers)))
4724
4725 (defun gnus-id-to-thread (id)
4726 "Return the (sub-)thread where ID appears."
4727 (gnus-gethash id gnus-newsgroup-dependencies))
4728
4729 (defun gnus-id-to-article (id)
4730 "Return the article number of ID."
4731 (let ((thread (gnus-id-to-thread id)))
4732 (when (and thread
4733 (car thread))
4734 (mail-header-number (car thread)))))
4735
4736 (defun gnus-id-to-header (id)
4737 "Return the article headers of ID."
4738 (car (gnus-id-to-thread id)))
4739
4740 (defun gnus-article-displayed-root-p (article)
4741 "Say whether ARTICLE is a root(ish) article."
4742 (let ((level (gnus-summary-thread-level article))
4743 (refs (mail-header-references (gnus-summary-article-header article)))
4744 particle)
4745 (cond
4746 ((null level) nil)
4747 ((zerop level) t)
4748 ((null refs) t)
4749 ((null (gnus-parent-id refs)) t)
4750 ((and (= 1 level)
4751 (null (setq particle (gnus-id-to-article
4752 (gnus-parent-id refs))))
4753 (null (gnus-summary-thread-level particle)))))))
4754
4755 (defun gnus-root-id (id)
4756 "Return the id of the root of the thread where ID appears."
4757 (let (last-id prev)
4758 (while (and id (setq prev (car (gnus-id-to-thread id))))
4759 (setq last-id id
4760 id (gnus-parent-id (mail-header-references prev))))
4761 last-id))
4762
4763 (defun gnus-articles-in-thread (thread)
4764 "Return the list of articles in THREAD."
4765 (cons (mail-header-number (car thread))
4766 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4767
4768 (defun gnus-remove-thread (id &optional dont-remove)
4769 "Remove the thread that has ID in it."
4770 (let (headers thread last-id)
4771 ;; First go up in this thread until we find the root.
4772 (setq last-id (gnus-root-id id)
4773 headers (message-flatten-list (gnus-id-to-thread last-id)))
4774 ;; We have now found the real root of this thread. It might have
4775 ;; been gathered into some loose thread, so we have to search
4776 ;; through the threads to find the thread we wanted.
4777 (let ((threads gnus-newsgroup-threads)
4778 sub)
4779 (while threads
4780 (setq sub (car threads))
4781 (if (stringp (car sub))
4782 ;; This is a gathered thread, so we look at the roots
4783 ;; below it to find whether this article is in this
4784 ;; gathered root.
4785 (progn
4786 (setq sub (cdr sub))
4787 (while sub
4788 (when (member (caar sub) headers)
4789 (setq thread (car threads)
4790 threads nil
4791 sub nil))
4792 (setq sub (cdr sub))))
4793 ;; It's an ordinary thread, so we check it.
4794 (when (eq (car sub) (car headers))
4795 (setq thread sub
4796 threads nil)))
4797 (setq threads (cdr threads)))
4798 ;; If this article is in no thread, then it's a root.
4799 (if thread
4800 (unless dont-remove
4801 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4802 (setq thread (gnus-id-to-thread last-id)))
4803 (when thread
4804 (prog1
4805 thread ; We return this thread.
4806 (unless dont-remove
4807 (if (stringp (car thread))
4808 (progn
4809 ;; If we use dummy roots, then we have to remove the
4810 ;; dummy root as well.
4811 (when (eq gnus-summary-make-false-root 'dummy)
4812 ;; We go to the dummy root by going to
4813 ;; the first sub-"thread", and then one line up.
4814 (gnus-summary-goto-article
4815 (mail-header-number (caadr thread)))
4816 (forward-line -1)
4817 (gnus-delete-line)
4818 (gnus-data-compute-positions))
4819 (setq thread (cdr thread))
4820 (while thread
4821 (gnus-remove-thread-1 (car thread))
4822 (setq thread (cdr thread))))
4823 (gnus-remove-thread-1 thread))))))))
4824
4825 (defun gnus-remove-thread-1 (thread)
4826 "Remove the thread THREAD recursively."
4827 (let ((number (mail-header-number (pop thread)))
4828 d)
4829 (setq thread (reverse thread))
4830 (while thread
4831 (gnus-remove-thread-1 (pop thread)))
4832 (when (setq d (gnus-data-find number))
4833 (goto-char (gnus-data-pos d))
4834 (gnus-summary-show-thread)
4835 (gnus-data-remove
4836 number
4837 (- (point-at-bol)
4838 (prog1
4839 (1+ (point-at-eol))
4840 (gnus-delete-line)))))))
4841
4842 (defun gnus-sort-threads-recursive (threads func)
4843 (sort (mapcar (lambda (thread)
4844 (cons (car thread)
4845 (and (cdr thread)
4846 (gnus-sort-threads-recursive (cdr thread) func))))
4847 threads) func))
4848
4849 (defun gnus-sort-threads-loop (threads func)
4850 (let* ((superthread (cons nil threads))
4851 (stack (list (cons superthread threads)))
4852 remaining-threads thread)
4853 (while stack
4854 (setq remaining-threads (cdr (car stack)))
4855 (if remaining-threads
4856 (progn (setq thread (car remaining-threads))
4857 (setcdr (car stack) (cdr remaining-threads))
4858 (if (cdr thread)
4859 (push (cons thread (cdr thread)) stack)))
4860 (setq thread (caar stack))
4861 (setcdr thread (sort (cdr thread) func))
4862 (pop stack)))
4863 (cdr superthread)))
4864
4865 (defun gnus-sort-threads (threads)
4866 "Sort THREADS."
4867 (if (not gnus-thread-sort-functions)
4868 threads
4869 (gnus-message 8 "Sorting threads...")
4870 (prog1
4871 (condition-case nil
4872 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000)))
4873 (gnus-sort-threads-recursive
4874 threads (gnus-make-sort-function gnus-thread-sort-functions)))
4875 ;; Even after binding max-lisp-eval-depth, the recursive
4876 ;; sorter might fail for very long threads. In that case,
4877 ;; try using a (less well-tested) non-recursive sorter.
4878 (error (gnus-message 9 "Sorting threads with loop...")
4879 (gnus-sort-threads-loop
4880 threads (gnus-make-sort-function
4881 gnus-thread-sort-functions))))
4882 (gnus-message 8 "Sorting threads...done"))))
4883
4884 (defun gnus-sort-articles (articles)
4885 "Sort ARTICLES."
4886 (when gnus-article-sort-functions
4887 (gnus-message 7 "Sorting articles...")
4888 (prog1
4889 (setq gnus-newsgroup-headers
4890 (sort articles (gnus-make-sort-function
4891 gnus-article-sort-functions)))
4892 (gnus-message 7 "Sorting articles...done"))))
4893
4894 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4895 (defmacro gnus-thread-header (thread)
4896 "Return header of first article in THREAD.
4897 Note that THREAD must never, ever be anything else than a variable -
4898 using some other form will lead to serious barfage."
4899 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4900 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4901 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4902 (vector thread) 2))
4903
4904 (defsubst gnus-article-sort-by-number (h1 h2)
4905 "Sort articles by article number."
4906 (< (mail-header-number h1)
4907 (mail-header-number h2)))
4908
4909 (defun gnus-thread-sort-by-number (h1 h2)
4910 "Sort threads by root article number."
4911 (gnus-article-sort-by-number
4912 (gnus-thread-header h1) (gnus-thread-header h2)))
4913
4914 (defsubst gnus-article-sort-by-random (h1 h2)
4915 "Sort articles randomly."
4916 (zerop (random 2)))
4917
4918 (defun gnus-thread-sort-by-random (h1 h2)
4919 "Sort threads randomly."
4920 (gnus-article-sort-by-random
4921 (gnus-thread-header h1) (gnus-thread-header h2)))
4922
4923 (defsubst gnus-article-sort-by-lines (h1 h2)
4924 "Sort articles by article Lines header."
4925 (< (mail-header-lines h1)
4926 (mail-header-lines h2)))
4927
4928 (defun gnus-thread-sort-by-lines (h1 h2)
4929 "Sort threads by root article Lines header."
4930 (gnus-article-sort-by-lines
4931 (gnus-thread-header h1) (gnus-thread-header h2)))
4932
4933 (defsubst gnus-article-sort-by-chars (h1 h2)
4934 "Sort articles by octet length."
4935 (< (mail-header-chars h1)
4936 (mail-header-chars h2)))
4937
4938 (defun gnus-thread-sort-by-chars (h1 h2)
4939 "Sort threads by root article octet length."
4940 (gnus-article-sort-by-chars
4941 (gnus-thread-header h1) (gnus-thread-header h2)))
4942
4943 (defsubst gnus-article-sort-by-author (h1 h2)
4944 "Sort articles by root author."
4945 (gnus-string<
4946 (let ((extract (funcall
4947 gnus-extract-address-components
4948 (mail-header-from h1))))
4949 (or (car extract) (cadr extract) ""))
4950 (let ((extract (funcall
4951 gnus-extract-address-components
4952 (mail-header-from h2))))
4953 (or (car extract) (cadr extract) ""))))
4954
4955 (defun gnus-thread-sort-by-author (h1 h2)
4956 "Sort threads by root author."
4957 (gnus-article-sort-by-author
4958 (gnus-thread-header h1) (gnus-thread-header h2)))
4959
4960 (defsubst gnus-article-sort-by-recipient (h1 h2)
4961 "Sort articles by recipient."
4962 (gnus-string<
4963 (let ((extract (funcall
4964 gnus-extract-address-components
4965 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4966 (or (car extract) (cadr extract)))
4967 (let ((extract (funcall
4968 gnus-extract-address-components
4969 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4970 (or (car extract) (cadr extract)))))
4971
4972 (defun gnus-thread-sort-by-recipient (h1 h2)
4973 "Sort threads by root recipient."
4974 (gnus-article-sort-by-recipient
4975 (gnus-thread-header h1) (gnus-thread-header h2)))
4976
4977 (defsubst gnus-article-sort-by-subject (h1 h2)
4978 "Sort articles by root subject."
4979 (gnus-string<
4980 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4981 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4982
4983 (defun gnus-thread-sort-by-subject (h1 h2)
4984 "Sort threads by root subject."
4985 (gnus-article-sort-by-subject
4986 (gnus-thread-header h1) (gnus-thread-header h2)))
4987
4988 (defsubst gnus-article-sort-by-date (h1 h2)
4989 "Sort articles by root article date."
4990 (time-less-p
4991 (gnus-date-get-time (mail-header-date h1))
4992 (gnus-date-get-time (mail-header-date h2))))
4993
4994 (defun gnus-thread-sort-by-date (h1 h2)
4995 "Sort threads by root article date."
4996 (gnus-article-sort-by-date
4997 (gnus-thread-header h1) (gnus-thread-header h2)))
4998
4999 (defsubst gnus-article-sort-by-score (h1 h2)
5000 "Sort articles by root article score.
5001 Unscored articles will be counted as having a score of zero."
5002 (> (or (cdr (assq (mail-header-number h1)
5003 gnus-newsgroup-scored))
5004 gnus-summary-default-score 0)
5005 (or (cdr (assq (mail-header-number h2)
5006 gnus-newsgroup-scored))
5007 gnus-summary-default-score 0)))
5008
5009 (defun gnus-thread-sort-by-score (h1 h2)
5010 "Sort threads by root article score."
5011 (gnus-article-sort-by-score
5012 (gnus-thread-header h1) (gnus-thread-header h2)))
5013
5014 (defun gnus-thread-sort-by-total-score (h1 h2)
5015 "Sort threads by the sum of all scores in the thread.
5016 Unscored articles will be counted as having a score of zero."
5017 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5018
5019 (defun gnus-thread-total-score (thread)
5020 ;; This function find the total score of THREAD.
5021 (cond
5022 ((null thread)
5023 0)
5024 ((consp thread)
5025 (if (stringp (car thread))
5026 (apply gnus-thread-score-function 0
5027 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5028 (gnus-thread-total-score-1 thread)))
5029 (t
5030 (gnus-thread-total-score-1 (list thread)))))
5031
5032 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5033 "Sort articles by number."
5034 (gnus-article-sort-by-number h1 h2))
5035
5036 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5037 "Sort threads such that the thread with the most recently arrived article comes first."
5038 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5039
5040 (defun gnus-thread-highest-number (thread)
5041 "Return the highest article number in THREAD."
5042 (apply 'max (mapcar (lambda (header)
5043 (mail-header-number header))
5044 (message-flatten-list thread))))
5045
5046 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5047 "Sort articles by number."
5048 (gnus-article-sort-by-date h1 h2))
5049
5050 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5051 "Sort threads such that the thread with the most recently dated article comes first."
5052 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5053
5054 ; Since this is called not only to sort the top-level threads, but
5055 ; also in recursive sorts to order the articles within a thread, each
5056 ; article will be processed many times. Thus it speeds things up
5057 ; quite a bit to use gnus-date-get-time, which caches the time value.
5058 (defun gnus-thread-latest-date (thread)
5059 "Return the highest article date in THREAD."
5060 (apply 'max
5061 (mapcar (lambda (header) (gnus-float-time
5062 (gnus-date-get-time
5063 (mail-header-date header))))
5064 (message-flatten-list thread))))
5065
5066 (defun gnus-thread-total-score-1 (root)
5067 ;; This function find the total score of the thread below ROOT.
5068 (setq root (car root))
5069 (apply gnus-thread-score-function
5070 (or (append
5071 (mapcar 'gnus-thread-total-score
5072 (cdr (gnus-id-to-thread (mail-header-id root))))
5073 (when (> (mail-header-number root) 0)
5074 (list (or (cdr (assq (mail-header-number root)
5075 gnus-newsgroup-scored))
5076 gnus-summary-default-score 0))))
5077 (list gnus-summary-default-score)
5078 '(0))))
5079
5080 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5081 (defvar gnus-tmp-prev-subject nil)
5082 (defvar gnus-tmp-false-parent nil)
5083 (defvar gnus-tmp-root-expunged nil)
5084 (defvar gnus-tmp-dummy-line nil)
5085
5086 (defun gnus-extra-header (type &optional header)
5087 "Return the extra header of TYPE."
5088 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5089 ""))
5090
5091 (defvar gnus-tmp-thread-tree-header-string "")
5092
5093 (defcustom gnus-sum-thread-tree-root "> "
5094 "With %B spec, used for the root of a thread.
5095 If nil, use subject instead."
5096 :version "22.1"
5097 :type '(radio (const :format "%v " nil) string)
5098 :group 'gnus-thread)
5099
5100 (defcustom gnus-sum-thread-tree-false-root "> "
5101 "With %B spec, used for a false root of a thread.
5102 If nil, use subject instead."
5103 :version "22.1"
5104 :type '(radio (const :format "%v " nil) string)
5105 :group 'gnus-thread)
5106
5107 (defcustom gnus-sum-thread-tree-single-indent ""
5108 "With %B spec, used for a thread with just one message.
5109 If nil, use subject instead."
5110 :version "22.1"
5111 :type '(radio (const :format "%v " nil) string)
5112 :group 'gnus-thread)
5113
5114 (defcustom gnus-sum-thread-tree-vertical "| "
5115 "With %B spec, used for drawing a vertical line."
5116 :version "22.1"
5117 :type 'string
5118 :group 'gnus-thread)
5119
5120 (defcustom gnus-sum-thread-tree-indent " "
5121 "With %B spec, used for indenting."
5122 :version "22.1"
5123 :type 'string
5124 :group 'gnus-thread)
5125
5126 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5127 "With %B spec, used for a leaf with brothers."
5128 :version "22.1"
5129 :type 'string
5130 :group 'gnus-thread)
5131
5132 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5133 "With %B spec, used for a leaf without brothers."
5134 :version "22.1"
5135 :type 'string
5136 :group 'gnus-thread)
5137
5138 (defcustom gnus-summary-display-while-building nil
5139 "If non-nil, show and update the summary buffer as it's being built.
5140 If the value is t, update the buffer after every line is inserted. If
5141 the value is an integer (N), update the display every N lines."
5142 :version "22.1"
5143 :group 'gnus-thread
5144 :type '(choice (const :tag "off" nil)
5145 number
5146 (const :tag "frequently" t)))
5147
5148 (defun gnus-summary-prepare-threads (threads)
5149 "Prepare summary buffer from THREADS and indentation LEVEL.
5150 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5151 or a straight list of headers."
5152 (gnus-message 7 "Generating summary...")
5153
5154 (setq gnus-newsgroup-threads threads)
5155 (beginning-of-line)
5156
5157 (let ((gnus-tmp-level 0)
5158 (default-score (or gnus-summary-default-score 0))
5159 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5160 (building-line-count gnus-summary-display-while-building)
5161 (building-count (integerp gnus-summary-display-while-building))
5162 thread number subject stack state gnus-tmp-gathered beg-match
5163 new-roots gnus-tmp-new-adopts thread-end simp-subject
5164 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5165 gnus-tmp-replied gnus-tmp-subject-or-nil
5166 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5167 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5168 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5169 tree-stack)
5170
5171 (setq gnus-tmp-prev-subject nil
5172 gnus-tmp-thread-tree-header-string "")
5173
5174 (if (vectorp (car threads))
5175 ;; If this is a straight (sic) list of headers, then a
5176 ;; threaded summary display isn't required, so we just create
5177 ;; an unthreaded one.
5178 (gnus-summary-prepare-unthreaded threads)
5179
5180 ;; Do the threaded display.
5181
5182 (if gnus-summary-display-while-building
5183 (switch-to-buffer (buffer-name)))
5184 (while (or threads stack gnus-tmp-new-adopts new-roots)
5185
5186 (if (and (= gnus-tmp-level 0)
5187 (or (not stack)
5188 (= (caar stack) 0))
5189 (not gnus-tmp-false-parent)
5190 (or gnus-tmp-new-adopts new-roots))
5191 (if gnus-tmp-new-adopts
5192 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5193 thread (list (car gnus-tmp-new-adopts))
5194 gnus-tmp-header (caar thread)
5195 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5196 (when new-roots
5197 (setq thread (list (car new-roots))
5198 gnus-tmp-header (caar thread)
5199 new-roots (cdr new-roots))))
5200
5201 (if threads
5202 ;; If there are some threads, we do them before the
5203 ;; threads on the stack.
5204 (setq thread threads
5205 gnus-tmp-header (caar thread))
5206 ;; There were no current threads, so we pop something off
5207 ;; the stack.
5208 (setq state (car stack)
5209 gnus-tmp-level (car state)
5210 tree-stack (cadr state)
5211 thread (caddr state)
5212 stack (cdr stack)
5213 gnus-tmp-header (caar thread))))
5214
5215 (setq gnus-tmp-false-parent nil)
5216 (setq gnus-tmp-root-expunged nil)
5217 (setq thread-end nil)
5218
5219 (if (stringp gnus-tmp-header)
5220 ;; The header is a dummy root.
5221 (cond
5222 ((eq gnus-summary-make-false-root 'adopt)
5223 ;; We let the first article adopt the rest.
5224 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5225 (cddar thread)))
5226 (setq gnus-tmp-gathered
5227 (nconc (mapcar
5228 (lambda (h) (mail-header-number (car h)))
5229 (cddar thread))
5230 gnus-tmp-gathered))
5231 (setq thread (cons (list (caar thread)
5232 (cadar thread))
5233 (cdr thread)))
5234 (setq gnus-tmp-level -1
5235 gnus-tmp-false-parent t))
5236 ((eq gnus-summary-make-false-root 'empty)
5237 ;; We print adopted articles with empty subject fields.
5238 (setq gnus-tmp-gathered
5239 (nconc (mapcar
5240 (lambda (h) (mail-header-number (car h)))
5241 (cddar thread))
5242 gnus-tmp-gathered))
5243 (setq gnus-tmp-level -1))
5244 ((eq gnus-summary-make-false-root 'dummy)
5245 ;; We remember that we probably want to output a dummy
5246 ;; root.
5247 (setq gnus-tmp-dummy-line gnus-tmp-header)
5248 (setq gnus-tmp-prev-subject gnus-tmp-header))
5249 (t
5250 ;; We do not make a root for the gathered
5251 ;; sub-threads at all.
5252 (setq gnus-tmp-level -1)))
5253
5254 (setq number (mail-header-number gnus-tmp-header)
5255 subject (mail-header-subject gnus-tmp-header)
5256 simp-subject (gnus-simplify-subject-fully subject))
5257
5258 (cond
5259 ;; If the thread has changed subject, we might want to make
5260 ;; this subthread into a root.
5261 ((and (null gnus-thread-ignore-subject)
5262 (not (zerop gnus-tmp-level))
5263 gnus-tmp-prev-subject
5264 (not (string= gnus-tmp-prev-subject simp-subject)))
5265 (setq new-roots (nconc new-roots (list (car thread)))
5266 thread-end t
5267 gnus-tmp-header nil))
5268 ;; If the article lies outside the current limit,
5269 ;; then we do not display it.
5270 ((not (memq number gnus-newsgroup-limit))
5271 (setq gnus-tmp-gathered
5272 (nconc (mapcar
5273 (lambda (h) (mail-header-number (car h)))
5274 (cdar thread))
5275 gnus-tmp-gathered))
5276 (setq gnus-tmp-new-adopts (if (cdar thread)
5277 (append gnus-tmp-new-adopts
5278 (cdar thread))
5279 gnus-tmp-new-adopts)
5280 thread-end t
5281 gnus-tmp-header nil)
5282 (when (zerop gnus-tmp-level)
5283 (setq gnus-tmp-root-expunged t)))
5284 ;; Perhaps this article is to be marked as read?
5285 ((and gnus-summary-mark-below
5286 (< (or (cdr (assq number gnus-newsgroup-scored))
5287 default-score)
5288 gnus-summary-mark-below)
5289 ;; Don't touch sparse articles.
5290 (not (gnus-summary-article-sparse-p number))
5291 (not (gnus-summary-article-ancient-p number)))
5292 (setq gnus-newsgroup-unreads
5293 (delq number gnus-newsgroup-unreads))
5294 (if gnus-newsgroup-auto-expire
5295 (setq gnus-newsgroup-expirable
5296 (gnus-add-to-sorted-list
5297 gnus-newsgroup-expirable number))
5298 (push (cons number gnus-low-score-mark)
5299 gnus-newsgroup-reads))))
5300
5301 (when gnus-tmp-header
5302 ;; We may have an old dummy line to output before this
5303 ;; article.
5304 (when (and gnus-tmp-dummy-line
5305 (gnus-subject-equal
5306 gnus-tmp-dummy-line
5307 (mail-header-subject gnus-tmp-header)))
5308 (gnus-summary-insert-dummy-line
5309 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5310 (setq gnus-tmp-dummy-line nil))
5311
5312 ;; Compute the mark.
5313 (setq gnus-tmp-unread (gnus-article-mark number))
5314
5315 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5316 gnus-tmp-header gnus-tmp-level)
5317 gnus-newsgroup-data)
5318
5319 ;; Actually insert the line.
5320 (setq
5321 gnus-tmp-subject-or-nil
5322 (cond
5323 ((and gnus-thread-ignore-subject
5324 gnus-tmp-prev-subject
5325 (not (string= gnus-tmp-prev-subject simp-subject)))
5326 subject)
5327 ((zerop gnus-tmp-level)
5328 (if (and (eq gnus-summary-make-false-root 'empty)
5329 (memq number gnus-tmp-gathered)
5330 gnus-tmp-prev-subject
5331 (string= gnus-tmp-prev-subject simp-subject))
5332 gnus-summary-same-subject
5333 subject))
5334 (t gnus-summary-same-subject)))
5335 (if (and (eq gnus-summary-make-false-root 'adopt)
5336 (= gnus-tmp-level 1)
5337 (memq number gnus-tmp-gathered))
5338 (setq gnus-tmp-opening-bracket ?\<
5339 gnus-tmp-closing-bracket ?\>)
5340 (setq gnus-tmp-opening-bracket ?\[
5341 gnus-tmp-closing-bracket ?\]))
5342 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5343 (gnus-make-thread-indent-array
5344 (max (* 2 (length gnus-thread-indent-array))
5345 gnus-tmp-level)))
5346 (setq
5347 gnus-tmp-indentation
5348 (aref gnus-thread-indent-array gnus-tmp-level)
5349 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5350 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5351 gnus-summary-default-score 0)
5352 gnus-tmp-score-char
5353 (if (or (null gnus-summary-default-score)
5354 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5355 gnus-summary-zcore-fuzz))
5356 ? ;Whitespace
5357 (if (< gnus-tmp-score gnus-summary-default-score)
5358 gnus-score-below-mark gnus-score-over-mark))
5359 gnus-tmp-replied
5360 (cond ((memq number gnus-newsgroup-processable)
5361 gnus-process-mark)
5362 ((memq number gnus-newsgroup-cached)
5363 gnus-cached-mark)
5364 ((memq number gnus-newsgroup-replied)
5365 gnus-replied-mark)
5366 ((memq number gnus-newsgroup-forwarded)
5367 gnus-forwarded-mark)
5368 ((memq number gnus-newsgroup-saved)
5369 gnus-saved-mark)
5370 ((memq number gnus-newsgroup-unseen)
5371 gnus-unseen-mark)
5372 (t gnus-no-mark))
5373 gnus-tmp-downloaded
5374 (cond ((memq number gnus-newsgroup-undownloaded)
5375 gnus-undownloaded-mark)
5376 (gnus-newsgroup-agentized
5377 gnus-downloaded-mark)
5378 (t
5379 gnus-no-mark))
5380 gnus-tmp-from (mail-header-from gnus-tmp-header)
5381 gnus-tmp-name
5382 (cond
5383 ((string-match "<[^>]+> *$" gnus-tmp-from)
5384 (setq beg-match (match-beginning 0))
5385 (or (and (string-match "^\".+\"" gnus-tmp-from)
5386 (substring gnus-tmp-from 1 (1- (match-end 0))))
5387 (substring gnus-tmp-from 0 beg-match)))
5388 ((string-match "(.+)" gnus-tmp-from)
5389 (substring gnus-tmp-from
5390 (1+ (match-beginning 0)) (1- (match-end 0))))
5391 (t gnus-tmp-from))
5392
5393 ;; Do the %B string
5394 gnus-tmp-thread-tree-header-string
5395 (cond
5396 ((not gnus-show-threads) "")
5397 ((zerop gnus-tmp-level)
5398 (cond ((cdar thread)
5399 (or gnus-sum-thread-tree-root subject))
5400 (gnus-tmp-new-adopts
5401 (or gnus-sum-thread-tree-false-root subject))
5402 (t
5403 (or gnus-sum-thread-tree-single-indent subject))))
5404 (t
5405 (concat (apply 'concat
5406 (mapcar (lambda (item)
5407 (if (= item 1)
5408 gnus-sum-thread-tree-vertical
5409 gnus-sum-thread-tree-indent))
5410 (cdr (reverse tree-stack))))
5411 (if (nth 1 thread)
5412 gnus-sum-thread-tree-leaf-with-other
5413 gnus-sum-thread-tree-single-leaf)))))
5414 (when (string= gnus-tmp-name "")
5415 (setq gnus-tmp-name gnus-tmp-from))
5416 (unless (numberp gnus-tmp-lines)
5417 (setq gnus-tmp-lines -1))
5418 (if (= gnus-tmp-lines -1)
5419 (setq gnus-tmp-lines "?")
5420 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5421 (gnus-put-text-property
5422 (point)
5423 (progn (eval gnus-summary-line-format-spec) (point))
5424 'gnus-number number)
5425 (when gnus-visual-p
5426 (forward-line -1)
5427 (gnus-summary-highlight-line)
5428 (when gnus-summary-update-hook
5429 (gnus-run-hooks 'gnus-summary-update-hook))
5430 (forward-line 1))
5431
5432 (setq gnus-tmp-prev-subject simp-subject)))
5433
5434 (when (nth 1 thread)
5435 (push (list (max 0 gnus-tmp-level)
5436 (copy-sequence tree-stack)
5437 (nthcdr 1 thread))
5438 stack))
5439 (push (if (nth 1 thread) 1 0) tree-stack)
5440 (incf gnus-tmp-level)
5441 (setq threads (if thread-end nil (cdar thread)))
5442 (if gnus-summary-display-while-building
5443 (if building-count
5444 (progn
5445 ;; use a set frequency
5446 (setq building-line-count (1- building-line-count))
5447 (when (= building-line-count 0)
5448 (sit-for 0)
5449 (setq building-line-count
5450 gnus-summary-display-while-building)))
5451 ;; always
5452 (sit-for 0)))
5453 (unless threads
5454 (setq gnus-tmp-level 0)))))
5455 (gnus-message 7 "Generating summary...done"))
5456
5457 (defun gnus-summary-prepare-unthreaded (headers)
5458 "Generate an unthreaded summary buffer based on HEADERS."
5459 (let (header number mark)
5460
5461 (beginning-of-line)
5462
5463 (while headers
5464 ;; We may have to root out some bad articles...
5465 (when (memq (setq number (mail-header-number
5466 (setq header (pop headers))))
5467 gnus-newsgroup-limit)
5468 ;; Mark article as read when it has a low score.
5469 (when (and gnus-summary-mark-below
5470 (< (or (cdr (assq number gnus-newsgroup-scored))
5471 gnus-summary-default-score 0)
5472 gnus-summary-mark-below)
5473 (not (gnus-summary-article-ancient-p number)))
5474 (setq gnus-newsgroup-unreads
5475 (delq number gnus-newsgroup-unreads))
5476 (if gnus-newsgroup-auto-expire
5477 (push number gnus-newsgroup-expirable)
5478 (push (cons number gnus-low-score-mark)
5479 gnus-newsgroup-reads)))
5480
5481 (setq mark (gnus-article-mark number))
5482 (push (gnus-data-make number mark (1+ (point)) header 0)
5483 gnus-newsgroup-data)
5484 (gnus-summary-insert-line
5485 header 0 number
5486 (memq number gnus-newsgroup-undownloaded)
5487 mark (memq number gnus-newsgroup-replied)
5488 (memq number gnus-newsgroup-expirable)
5489 (mail-header-subject header) nil
5490 (cdr (assq number gnus-newsgroup-scored))
5491 (memq number gnus-newsgroup-processable))))))
5492
5493 (defun gnus-group-get-list-identifiers (group)
5494 "Get list identifier regexp for GROUP."
5495 (or (gnus-parameter-list-identifier group)
5496 (if (consp gnus-list-identifiers)
5497 (mapconcat 'identity gnus-list-identifiers " *\\|")
5498 gnus-list-identifiers)))
5499
5500 (defun gnus-summary-remove-list-identifiers ()
5501 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5502 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5503 changed subject)
5504 (when regexp
5505 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5506 (dolist (header gnus-newsgroup-headers)
5507 (setq subject (mail-header-subject header)
5508 changed nil)
5509 (while (string-match regexp subject)
5510 (setq subject
5511 (concat (substring subject 0 (match-beginning 1))
5512 (substring subject (match-end 0)))
5513 changed t))
5514 (when changed
5515 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5516 (setq subject
5517 (concat (substring subject 0 (match-beginning 1))
5518 (substring subject (match-end 1)))))
5519 (mail-header-set-subject header subject))))))
5520
5521 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5522 "Fetch headers of ARTICLES."
5523 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5524 (gnus-message 7 "Fetching headers for %s..." name)
5525 (prog1
5526 (if (eq 'nov
5527 (setq gnus-headers-retrieved-by
5528 (gnus-retrieve-headers
5529 articles gnus-newsgroup-name
5530 (or limit
5531 ;; We might want to fetch old headers, but
5532 ;; not if there is only 1 article.
5533 (and (or (and
5534 (not (eq gnus-fetch-old-headers 'some))
5535 (not (numberp gnus-fetch-old-headers)))
5536 (> (length articles) 1))
5537 gnus-fetch-old-headers)))))
5538 (gnus-get-newsgroup-headers-xover
5539 articles force-new dependencies gnus-newsgroup-name t)
5540 (gnus-get-newsgroup-headers dependencies force-new))
5541 (gnus-message 7 "Fetching headers for %s...done" name))))
5542
5543 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5544 "Select newsgroup GROUP.
5545 If READ-ALL is non-nil, all articles in the group are selected.
5546 If SELECT-ARTICLES, only select those articles from GROUP."
5547 (let* ((entry (gnus-group-entry group))
5548 ;;!!! Dirty hack; should be removed.
5549 (gnus-summary-ignore-duplicates
5550 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5551 t
5552 gnus-summary-ignore-duplicates))
5553 (info (nth 2 entry))
5554 charset articles fetched-articles cached)
5555
5556 (unless (gnus-check-server
5557 (set (make-local-variable 'gnus-current-select-method)
5558 (gnus-find-method-for-group group)))
5559 (error "Couldn't open server"))
5560 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5561
5562 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5563 (gnus-activate-group group) ; Or we can activate it...
5564 (progn ; Or we bug out.
5565 (when (equal major-mode 'gnus-summary-mode)
5566 (gnus-kill-buffer (current-buffer)))
5567 (error
5568 "Couldn't activate group %s: %s"
5569 (mm-decode-coding-string group charset)
5570 (mm-decode-coding-string (gnus-status-message group) charset))))
5571
5572 (unless (gnus-request-group group t)
5573 (when (equal major-mode 'gnus-summary-mode)
5574 (gnus-kill-buffer (current-buffer)))
5575 (error "Couldn't request group %s: %s"
5576 (mm-decode-coding-string group charset)
5577 (mm-decode-coding-string (gnus-status-message group) charset)))
5578
5579 (when (and gnus-agent
5580 (gnus-active group))
5581 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5582
5583 (setq gnus-summary-use-undownloaded-faces
5584 (gnus-agent-find-parameter
5585 group
5586 'agent-enable-undownloaded-faces)))
5587
5588 (setq gnus-newsgroup-name group
5589 gnus-newsgroup-unselected nil
5590 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5591
5592 (let ((display (gnus-group-find-parameter group 'display)))
5593 (setq gnus-newsgroup-display
5594 (cond
5595 ((not (zerop (or (car-safe read-all) 0)))
5596 ;; The user entered the group with C-u SPC/RET, let's show
5597 ;; all articles.
5598 'gnus-not-ignore)
5599 ((eq display 'all)
5600 'gnus-not-ignore)
5601 ((arrayp display)
5602 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5603 ((numberp display)
5604 ;; The following is probably the "correct" solution, but
5605 ;; it makes Gnus fetch all headers and then limit the
5606 ;; articles (which is slow), so instead we hack the
5607 ;; select-articles parameter instead. -- Simon Josefsson
5608 ;; <jas@kth.se>
5609 ;;
5610 ;; (gnus-byte-compile
5611 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5612 ;; display)))))
5613 (setq select-articles
5614 (gnus-uncompress-range
5615 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5616 (if (> tmp 0)
5617 tmp
5618 1))
5619 (cdr (gnus-active group)))))
5620 nil)
5621 (t
5622 nil))))
5623
5624 (gnus-summary-setup-default-charset)
5625
5626 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5627 (when (gnus-virtual-group-p group)
5628 (setq cached gnus-newsgroup-cached))
5629
5630 (setq gnus-newsgroup-unreads
5631 (gnus-sorted-ndifference
5632 (gnus-sorted-ndifference gnus-newsgroup-unreads
5633 gnus-newsgroup-marked)
5634 gnus-newsgroup-dormant))
5635
5636 (setq gnus-newsgroup-processable nil)
5637
5638 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5639
5640 ;; Adjust and set lists of article marks.
5641 (when info
5642 (gnus-adjust-marked-articles info))
5643 (if (setq articles select-articles)
5644 (setq gnus-newsgroup-unselected
5645 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5646 (setq articles (gnus-articles-to-read group read-all)))
5647
5648 (cond
5649 ((null articles)
5650 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5651 'quit)
5652 ((eq articles 0) nil)
5653 (t
5654 ;; Init the dependencies hash table.
5655 (setq gnus-newsgroup-dependencies
5656 (gnus-make-hashtable (length articles)))
5657 (if (gnus-buffer-live-p gnus-group-buffer)
5658 (gnus-set-global-variables)
5659 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5660 ;; Retrieve the headers and read them in.
5661
5662 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5663
5664 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5665 (when cached
5666 (setq gnus-newsgroup-cached cached))
5667
5668 ;; Suppress duplicates?
5669 (when gnus-suppress-duplicates
5670 (gnus-dup-suppress-articles))
5671
5672 ;; Set the initial limit.
5673 (setq gnus-newsgroup-limit (copy-sequence articles))
5674 ;; Remove canceled articles from the list of unread articles.
5675 (setq fetched-articles
5676 (mapcar (lambda (headers) (mail-header-number headers))
5677 gnus-newsgroup-headers))
5678 (setq gnus-newsgroup-articles fetched-articles)
5679 (setq gnus-newsgroup-unreads
5680 (gnus-sorted-nintersection
5681 gnus-newsgroup-unreads fetched-articles))
5682 (gnus-compute-unseen-list)
5683
5684 ;; Removed marked articles that do not exist.
5685 (gnus-update-missing-marks
5686 (gnus-sorted-difference articles fetched-articles))
5687 ;; We might want to build some more threads first.
5688 (when (and gnus-fetch-old-headers
5689 (eq gnus-headers-retrieved-by 'nov))
5690 (if (eq gnus-fetch-old-headers 'invisible)
5691 (gnus-build-all-threads)
5692 (gnus-build-old-threads)))
5693 ;; Let the Gnus agent mark articles as read.
5694 (when gnus-agent
5695 (gnus-agent-get-undownloaded-list))
5696 ;; Remove list identifiers from subject
5697 (gnus-summary-remove-list-identifiers)
5698 ;; Check whether auto-expire is to be done in this group.
5699 (setq gnus-newsgroup-auto-expire
5700 (and (gnus-group-auto-expirable-p group)
5701 (not (gnus-group-read-only-p group))))
5702 ;; Set up the article buffer now, if necessary.
5703 (unless (and gnus-single-article-buffer
5704 (equal gnus-article-buffer "*Article*"))
5705 (gnus-article-setup-buffer))
5706 ;; First and last article in this newsgroup.
5707 (when gnus-newsgroup-headers
5708 (setq gnus-newsgroup-begin
5709 (mail-header-number (car gnus-newsgroup-headers))
5710 gnus-newsgroup-end
5711 (mail-header-number
5712 (gnus-last-element gnus-newsgroup-headers))))
5713 ;; GROUP is successfully selected.
5714 (or gnus-newsgroup-headers t)))))
5715
5716 (defun gnus-compute-unseen-list ()
5717 ;; The `seen' marks are treated specially.
5718 (if (not gnus-newsgroup-seen)
5719 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5720 (setq gnus-newsgroup-unseen
5721 (gnus-inverse-list-range-intersection
5722 gnus-newsgroup-articles gnus-newsgroup-seen))))
5723
5724 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5725
5726 (defun gnus-summary-display-make-predicate (display)
5727 (require 'gnus-agent)
5728 (when (= (length display) 1)
5729 (setq display (car display)))
5730 (unless gnus-summary-display-cache
5731 (dolist (elem (append '((unread . unread)
5732 (read . read)
5733 (unseen . unseen))
5734 gnus-article-mark-lists))
5735 (push (cons (cdr elem)
5736 (gnus-byte-compile ;Why bother?
5737 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5738 gnus-summary-display-cache)))
5739 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5740 (gnus-category-predicate-cache gnus-summary-display-cache))
5741 (gnus-get-predicate display)))
5742
5743 ;; Uses the dynamically bound `gnus-number' variable.
5744 (defvar gnus-number)
5745 (defun gnus-article-marked-p (type &optional article)
5746 (let ((article (or article gnus-number)))
5747 (cond
5748 ((eq type 'tick)
5749 (memq article gnus-newsgroup-marked))
5750 ((eq type 'spam)
5751 (memq article gnus-newsgroup-spam-marked))
5752 ((eq type 'unsend)
5753 (memq article gnus-newsgroup-unsendable))
5754 ((eq type 'undownload)
5755 (memq article gnus-newsgroup-undownloaded))
5756 ((eq type 'download)
5757 (memq article gnus-newsgroup-downloadable))
5758 ((eq type 'unread)
5759 (memq article gnus-newsgroup-unreads))
5760 ((eq type 'read)
5761 (memq article gnus-newsgroup-reads))
5762 ((eq type 'dormant)
5763 (memq article gnus-newsgroup-dormant) )
5764 ((eq type 'expire)
5765 (memq article gnus-newsgroup-expirable))
5766 ((eq type 'reply)
5767 (memq article gnus-newsgroup-replied))
5768 ((eq type 'killed)
5769 (memq article gnus-newsgroup-killed))
5770 ((eq type 'bookmark)
5771 (assq article gnus-newsgroup-bookmarks))
5772 ((eq type 'score)
5773 (assq article gnus-newsgroup-scored))
5774 ((eq type 'save)
5775 (memq article gnus-newsgroup-saved))
5776 ((eq type 'cache)
5777 (memq article gnus-newsgroup-cached))
5778 ((eq type 'forward)
5779 (memq article gnus-newsgroup-forwarded))
5780 ((eq type 'seen)
5781 (not (memq article gnus-newsgroup-unseen)))
5782 (t t))))
5783
5784 (defun gnus-articles-to-read (group &optional read-all)
5785 "Find out what articles the user wants to read."
5786 (let* ((only-read-p t)
5787 (articles
5788 ;; Select all articles if `read-all' is non-nil, or if there
5789 ;; are no unread articles.
5790 (if (or read-all
5791 (and (zerop (length gnus-newsgroup-marked))
5792 (zerop (length gnus-newsgroup-unreads)))
5793 ;; Fetch all if the predicate is non-nil.
5794 gnus-newsgroup-display)
5795 ;; We want to select the headers for all the articles in
5796 ;; the group, so we select either all the active
5797 ;; articles in the group, or (if that's nil), the
5798 ;; articles in the cache.
5799 (or
5800 (if gnus-newsgroup-maximum-articles
5801 (let ((active (gnus-active group)))
5802 (gnus-uncompress-range
5803 (cons (max (car active)
5804 (- (cdr active)
5805 gnus-newsgroup-maximum-articles
5806 -1))
5807 (cdr active))))
5808 (gnus-uncompress-range (gnus-active group)))
5809 (gnus-cache-articles-in-group group))
5810 ;; Select only the "normal" subset of articles.
5811 (setq only-read-p nil)
5812 (gnus-sorted-nunion
5813 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5814 gnus-newsgroup-unreads)))
5815 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5816 (scored (length scored-list))
5817 (number (length articles))
5818 (marked (+ (length gnus-newsgroup-marked)
5819 (length gnus-newsgroup-dormant)))
5820 (select
5821 (cond
5822 ((numberp read-all)
5823 read-all)
5824 ((numberp gnus-newsgroup-display)
5825 gnus-newsgroup-display)
5826 (t
5827 (condition-case ()
5828 (cond
5829 ((and (or (<= scored marked) (= scored number))
5830 (numberp gnus-large-newsgroup)
5831 (> number gnus-large-newsgroup))
5832 (let* ((cursor-in-echo-area nil)
5833 (initial (gnus-parameter-large-newsgroup-initial
5834 gnus-newsgroup-name))
5835 (default (if only-read-p
5836 (or initial gnus-large-newsgroup)
5837 number))
5838 (input
5839 (read-string
5840 (if only-read-p
5841 (format
5842 "How many articles from %s (available %d, default %d): "
5843 (gnus-group-decoded-name
5844 (gnus-group-real-name gnus-newsgroup-name))
5845 number default)
5846 (format
5847 "How many articles from %s (%d default): "
5848 (gnus-group-decoded-name
5849 (gnus-group-real-name gnus-newsgroup-name))
5850 default))
5851 nil
5852 nil
5853 (number-to-string default))))
5854 (if (string-match "^[ \t]*$" input) number input)))
5855 ((and (> scored marked) (< scored number)
5856 (> (- scored number) 20))
5857 (let ((input
5858 (read-string
5859 (format "%s %s (%d scored, %d total): "
5860 "How many articles from"
5861 (gnus-group-decoded-name
5862 (gnus-group-real-name gnus-newsgroup-name))
5863 scored number))))
5864 (if (string-match "^[ \t]*$" input)
5865 number input)))
5866 (t number))
5867 (quit
5868 (message "Quit getting the articles to read")
5869 nil))))))
5870 (setq select (if (stringp select) (string-to-number select) select))
5871 (if (or (null select) (zerop select))
5872 select
5873 (if (and (not (zerop scored)) (<= (abs select) scored))
5874 (progn
5875 (setq articles (sort scored-list '<))
5876 (setq number (length articles)))
5877 (setq articles (copy-sequence articles)))
5878
5879 (when (< (abs select) number)
5880 (if (< select 0)
5881 ;; Select the N oldest articles.
5882 (setcdr (nthcdr (1- (abs select)) articles) nil)
5883 ;; Select the N most recent articles.
5884 (setq articles (nthcdr (- number select) articles))))
5885 (setq gnus-newsgroup-unselected
5886 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5887 (when gnus-alter-articles-to-read-function
5888 (setq articles
5889 (sort
5890 (funcall gnus-alter-articles-to-read-function
5891 gnus-newsgroup-name articles)
5892 '<)))
5893 articles)))
5894
5895 (defun gnus-killed-articles (killed articles)
5896 (let (out)
5897 (while articles
5898 (when (inline (gnus-member-of-range (car articles) killed))
5899 (push (car articles) out))
5900 (setq articles (cdr articles)))
5901 out))
5902
5903 (defun gnus-article-mark-to-type (mark)
5904 "Return the type of MARK."
5905 (or (cadr (assq mark gnus-article-special-mark-lists))
5906 'list))
5907
5908 (defun gnus-article-unpropagatable-p (mark)
5909 "Return whether MARK should be propagated to back end."
5910 (memq mark gnus-article-unpropagated-mark-lists))
5911
5912 (defun gnus-adjust-marked-articles (info)
5913 "Set all article lists and remove all marks that are no longer valid."
5914 (let* ((marked-lists (gnus-info-marks info))
5915 (active (gnus-active (gnus-info-group info)))
5916 (min (car active))
5917 (max (cdr active))
5918 (types gnus-article-mark-lists)
5919 marks var articles article mark mark-type
5920 bgn end)
5921 ;; Hack to avoid adjusting marks for imap.
5922 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5923 'nnimap)
5924 (setq min 1))
5925
5926 (dolist (marks marked-lists)
5927 (setq mark (car marks)
5928 mark-type (gnus-article-mark-to-type mark)
5929 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5930 ;; We set the variable according to the type of the marks list,
5931 ;; and then adjust the marks to a subset of the active articles.
5932 (cond
5933 ;; Adjust "simple" lists - compressed yet unsorted
5934 ((eq mark-type 'list)
5935 ;; Simultaneously uncompress and clip to active range
5936 ;; See gnus-uncompress-range for a description of possible marks
5937 (let (l lh)
5938 (if (not (cadr marks))
5939 (set var nil)
5940 (setq articles (if (numberp (cddr marks))
5941 (list (cdr marks))
5942 (cdr marks))
5943 lh (cons nil nil)
5944 l lh)
5945
5946 (while (setq article (pop articles))
5947 (cond ((consp article)
5948 (setq bgn (max (car article) min)
5949 end (min (cdr article) max))
5950 (while (<= bgn end)
5951 (setq l (setcdr l (cons bgn nil))
5952 bgn (1+ bgn))))
5953 ((and (<= min article)
5954 (>= max article))
5955 (setq l (setcdr l (cons article nil))))))
5956 (set var (cdr lh)))))
5957 ;; Adjust assocs.
5958 ((eq mark-type 'tuple)
5959 (set var (setq articles (cdr marks)))
5960 (when (not (listp (cdr (symbol-value var))))
5961 (set var (list (symbol-value var))))
5962 (when (not (listp (cdr articles)))
5963 (setq articles (list articles)))
5964 (while articles
5965 (when (or (not (consp (setq article (pop articles))))
5966 (< (car article) min)
5967 (> (car article) max))
5968 (set var (delq article (symbol-value var))))))
5969 ;; Adjust ranges (sloppily).
5970 ((eq mark-type 'range)
5971 (cond
5972 ((eq mark 'seen)
5973 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5974 ;; It should be (seen (NUM1 . NUM2)).
5975 (when (numberp (cddr marks))
5976 (setcdr marks (list (cdr marks))))
5977 (setq articles (cdr marks))
5978 (while (and articles
5979 (or (and (consp (car articles))
5980 (> min (cdar articles)))
5981 (and (numberp (car articles))
5982 (> min (car articles)))))
5983 (pop articles))
5984 (set var articles))))))))
5985
5986 (defun gnus-update-missing-marks (missing)
5987 "Go through the list of MISSING articles and remove them from the mark lists."
5988 (when missing
5989 (let (var m)
5990 ;; Go through all types.
5991 (dolist (elem gnus-article-mark-lists)
5992 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5993 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5994 (when (symbol-value var)
5995 ;; This list has articles. So we delete all missing
5996 ;; articles from it.
5997 (setq m missing)
5998 (while m
5999 (set var (delq (pop m) (symbol-value var))))))))))
6000
6001 (defun gnus-update-marks ()
6002 "Enter the various lists of marked articles into the newsgroup info list."
6003 (let ((types gnus-article-mark-lists)
6004 (info (gnus-get-info gnus-newsgroup-name))
6005 type list newmarked symbol delta-marks)
6006 (when info
6007 ;; Add all marks lists to the list of marks lists.
6008 (while (setq type (pop types))
6009 (setq list (symbol-value
6010 (setq symbol
6011 (intern (format "gnus-newsgroup-%s" (car type))))))
6012
6013 (when list
6014 ;; Get rid of the entries of the articles that have the
6015 ;; default score.
6016 (when (and (eq (cdr type) 'score)
6017 gnus-save-score
6018 list)
6019 (let* ((arts list)
6020 (prev (cons nil list))
6021 (all prev))
6022 (while arts
6023 (if (or (not (consp (car arts)))
6024 (= (cdar arts) gnus-summary-default-score))
6025 (setcdr prev (cdr arts))
6026 (setq prev arts))
6027 (setq arts (cdr arts)))
6028 (setq list (cdr all)))))
6029
6030 (when (eq (cdr type) 'seen)
6031 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6032
6033 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6034 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6035
6036 (when (and (gnus-check-backend-function
6037 'request-set-mark gnus-newsgroup-name)
6038 (not (gnus-article-unpropagatable-p (cdr type))))
6039 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6040 ;; Don't do anything about marks for articles we
6041 ;; didn't actually get any headers for.
6042 (del
6043 (gnus-list-range-intersection
6044 gnus-newsgroup-articles
6045 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6046 (add
6047 (gnus-list-range-intersection
6048 gnus-newsgroup-articles
6049 (gnus-remove-from-range
6050 (gnus-copy-sequence list) old))))
6051 (when add
6052 (push (list add 'add (list (cdr type))) delta-marks))
6053 (when del
6054 ;; Don't delete marks from outside the active range.
6055 ;; This shouldn't happen, but is a sanity check.
6056 (setq del (gnus-sorted-range-intersection
6057 (gnus-active gnus-newsgroup-name) del))
6058 (push (list del 'del (list (cdr type))) delta-marks))))
6059
6060 (when list
6061 (push (cons (cdr type) list) newmarked)))
6062
6063 (when delta-marks
6064 (unless (gnus-check-group gnus-newsgroup-name)
6065 (error "Can't open server for %s" gnus-newsgroup-name))
6066 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6067
6068 ;; Enter these new marks into the info of the group.
6069 (if (nthcdr 3 info)
6070 (setcar (nthcdr 3 info) newmarked)
6071 ;; Add the marks lists to the end of the info.
6072 (when newmarked
6073 (setcdr (nthcdr 2 info) (list newmarked))))
6074
6075 ;; Cut off the end of the info if there's nothing else there.
6076 (let ((i 5))
6077 (while (and (> i 2)
6078 (not (nth i info)))
6079 (when (nthcdr (decf i) info)
6080 (setcdr (nthcdr i info) nil)))))))
6081
6082 (defun gnus-set-mode-line (where)
6083 "Set the mode line of the article or summary buffers.
6084 If WHERE is `summary', the summary mode line format will be used."
6085 ;; Is this mode line one we keep updated?
6086 (when (and (memq where gnus-updated-mode-lines)
6087 (symbol-value
6088 (intern (format "gnus-%s-mode-line-format-spec" where))))
6089 (let (mode-string)
6090 ;; We evaluate this in the summary buffer since these
6091 ;; variables are buffer-local to that buffer.
6092 (with-current-buffer gnus-summary-buffer
6093 ;; We bind all these variables that are used in the `eval' form
6094 ;; below.
6095 (let* ((mformat (symbol-value
6096 (intern
6097 (format "gnus-%s-mode-line-format-spec" where))))
6098 (gnus-tmp-group-name (gnus-mode-string-quote
6099 (gnus-group-decoded-name
6100 gnus-newsgroup-name)))
6101 (gnus-tmp-article-number (or gnus-current-article 0))
6102 (gnus-tmp-unread gnus-newsgroup-unreads)
6103 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6104 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6105 (gnus-tmp-unread-and-unselected
6106 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6107 (zerop gnus-tmp-unselected))
6108 "")
6109 ((zerop gnus-tmp-unselected)
6110 (format "{%d more}" gnus-tmp-unread-and-unticked))
6111 (t (format "{%d(+%d) more}"
6112 gnus-tmp-unread-and-unticked
6113 gnus-tmp-unselected))))
6114 (gnus-tmp-subject
6115 (if (and gnus-current-headers
6116 (vectorp gnus-current-headers))
6117 (gnus-mode-string-quote
6118 (mail-header-subject gnus-current-headers))
6119 ""))
6120 bufname-length max-len
6121 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6122 (setq mode-string (eval mformat))
6123 (setq bufname-length (if (string-match "%b" mode-string)
6124 (- (length
6125 (buffer-name
6126 (if (eq where 'summary)
6127 nil
6128 (get-buffer gnus-article-buffer))))
6129 2)
6130 0))
6131 (setq max-len (max 4 (if gnus-mode-non-string-length
6132 (- (window-width)
6133 gnus-mode-non-string-length
6134 bufname-length)
6135 (length mode-string))))
6136 ;; We might have to chop a bit of the string off...
6137 (when (> (length mode-string) max-len)
6138 (setq mode-string
6139 (concat (truncate-string-to-width mode-string (- max-len 3))
6140 "...")))))
6141 ;; Update the mode line.
6142 (setq mode-line-buffer-identification
6143 (gnus-mode-line-buffer-identification (list mode-string)))
6144 (set-buffer-modified-p t))))
6145
6146 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6147 "Go through the HEADERS list and add all Xrefs to a hash table.
6148 The resulting hash table is returned, or nil if no Xrefs were found."
6149 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6150 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6151 (xref-hashtb (gnus-make-hashtable))
6152 start group entry number xrefs header)
6153 (while headers
6154 (setq header (pop headers))
6155 (when (and (setq xrefs (mail-header-xref header))
6156 (not (memq (setq number (mail-header-number header))
6157 unreads)))
6158 (setq start 0)
6159 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6160 (setq start (match-end 0))
6161 (setq group (if prefix
6162 (concat prefix (substring xrefs (match-beginning 1)
6163 (match-end 1)))
6164 (substring xrefs (match-beginning 1) (match-end 1))))
6165 (setq number
6166 (string-to-number (substring xrefs (match-beginning 2)
6167 (match-end 2))))
6168 (if (setq entry (gnus-gethash group xref-hashtb))
6169 (setcdr entry (cons number (cdr entry)))
6170 (gnus-sethash group (cons number nil) xref-hashtb)))))
6171 (and start xref-hashtb)))
6172
6173 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6174 "Look through all the headers and mark the Xrefs as read."
6175 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6176 name info xref-hashtb idlist method nth4)
6177 (with-current-buffer gnus-group-buffer
6178 (when (setq xref-hashtb
6179 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6180 (mapatoms
6181 (lambda (group)
6182 (unless (string= from-newsgroup (setq name (symbol-name group)))
6183 (setq idlist (symbol-value group))
6184 ;; Dead groups are not updated.
6185 (and (prog1
6186 (setq info (gnus-get-info name))
6187 (when (stringp (setq nth4 (gnus-info-method info)))
6188 (setq nth4 (gnus-server-to-method nth4))))
6189 ;; Only do the xrefs if the group has the same
6190 ;; select method as the group we have just read.
6191 (or (gnus-methods-equal-p
6192 nth4 (gnus-find-method-for-group from-newsgroup))
6193 virtual
6194 (equal nth4 (setq method (gnus-find-method-for-group
6195 from-newsgroup)))
6196 (and (equal (car nth4) (car method))
6197 (equal (nth 1 nth4) (nth 1 method))))
6198 gnus-use-cross-reference
6199 (or (not (eq gnus-use-cross-reference t))
6200 virtual
6201 ;; Only do cross-references on subscribed
6202 ;; groups, if that is what is wanted.
6203 (<= (gnus-info-level info) gnus-level-subscribed))
6204 (gnus-group-make-articles-read name idlist))))
6205 xref-hashtb)))))
6206
6207 (defun gnus-compute-read-articles (group articles)
6208 (let* ((entry (gnus-group-entry group))
6209 (info (nth 2 entry))
6210 (active (gnus-active group))
6211 ninfo)
6212 (when entry
6213 ;; First peel off all invalid article numbers.
6214 (when active
6215 (let ((ids articles)
6216 id first)
6217 (while (setq id (pop ids))
6218 (when (and first (> id (cdr active)))
6219 ;; We'll end up in this situation in one particular
6220 ;; obscure situation. If you re-scan a group and get
6221 ;; a new article that is cross-posted to a different
6222 ;; group that has not been re-scanned, you might get
6223 ;; crossposted article that has a higher number than
6224 ;; Gnus believes possible. So we re-activate this
6225 ;; group as well. This might mean doing the
6226 ;; crossposting thingy will *increase* the number
6227 ;; of articles in some groups. Tsk, tsk.
6228 (setq active (or (gnus-activate-group group) active)))
6229 (when (or (> id (cdr active))
6230 (< id (car active)))
6231 (setq articles (delq id articles))))))
6232 ;; If the read list is nil, we init it.
6233 (if (and active
6234 (null (gnus-info-read info))
6235 (> (car active) 1))
6236 (setq ninfo (cons 1 (1- (car active))))
6237 (setq ninfo (gnus-info-read info)))
6238 ;; Then we add the read articles to the range.
6239 (gnus-add-to-range
6240 ninfo (setq articles (sort articles '<))))))
6241
6242 (defun gnus-group-make-articles-read (group articles)
6243 "Update the info of GROUP to say that ARTICLES are read."
6244 (let* ((num 0)
6245 (entry (gnus-group-entry group))
6246 (info (nth 2 entry))
6247 (active (gnus-active group))
6248 (set-marks
6249 (gnus-method-option-p
6250 (gnus-find-method-for-group group)
6251 'server-marks))
6252 range)
6253 (if (not entry)
6254 ;; Group that Gnus doesn't know exists, but still allow the
6255 ;; backend to set marks.
6256 (when set-marks
6257 (gnus-request-set-mark
6258 group (list (list (gnus-compress-sequence (sort articles #'<))
6259 'add '(read)))))
6260 ;; Normal, subscribed groups.
6261 (setq range (gnus-compute-read-articles group articles))
6262 (with-current-buffer gnus-group-buffer
6263 (gnus-undo-register
6264 `(progn
6265 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6266 (gnus-info-set-read ',info ',(gnus-info-read info))
6267 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6268 (when ,set-marks
6269 (gnus-request-set-mark
6270 ,group (list (list ',range 'del '(read)))))
6271 (gnus-group-update-group ,group t))))
6272 ;; Add the read articles to the range.
6273 (gnus-info-set-read info range)
6274 (when set-marks
6275 (gnus-request-set-mark group (list (list range 'add '(read)))))
6276 ;; Then we have to re-compute how many unread
6277 ;; articles there are in this group.
6278 (when active
6279 (cond
6280 ((not range)
6281 (setq num (- (1+ (cdr active)) (car active))))
6282 ((not (listp (cdr range)))
6283 (setq num (- (cdr active) (- (1+ (cdr range))
6284 (car range)))))
6285 (t
6286 (while range
6287 (if (numberp (car range))
6288 (setq num (1+ num))
6289 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6290 (setq range (cdr range)))
6291 (setq num (- (cdr active) num))))
6292 ;; Update the number of unread articles.
6293 (setcar entry num)
6294 ;; Update the group buffer.
6295 (unless (gnus-ephemeral-group-p group)
6296 (gnus-group-update-group group t))))))
6297
6298 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6299 (let ((cur nntp-server-buffer)
6300 (dependencies
6301 (or dependencies
6302 (with-current-buffer gnus-summary-buffer
6303 gnus-newsgroup-dependencies)))
6304 headers id end ref number
6305 (mail-parse-charset gnus-newsgroup-charset)
6306 (mail-parse-ignored-charsets
6307 (save-current-buffer (condition-case nil
6308 (set-buffer gnus-summary-buffer)
6309 (error))
6310 gnus-newsgroup-ignored-charsets)))
6311 (with-current-buffer nntp-server-buffer
6312 ;; Translate all TAB characters into SPACE characters.
6313 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6314 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6315 (ietf-drums-unfold-fws)
6316 (gnus-run-hooks 'gnus-parse-headers-hook)
6317 (let ((case-fold-search t)
6318 in-reply-to header p lines chars)
6319 (goto-char (point-min))
6320 ;; Search to the beginning of the next header. Error messages
6321 ;; do not begin with 2 or 3.
6322 (while (re-search-forward "^[23][0-9]+ " nil t)
6323 (setq id nil
6324 ref nil)
6325 ;; This implementation of this function, with nine
6326 ;; search-forwards instead of the one re-search-forward and
6327 ;; a case (which basically was the old function) is actually
6328 ;; about twice as fast, even though it looks messier. You
6329 ;; can't have everything, I guess. Speed and elegance
6330 ;; doesn't always go hand in hand.
6331 (setq
6332 header
6333 (vector
6334 ;; Number.
6335 (prog1
6336 (setq number (read cur))
6337 (end-of-line)
6338 (setq p (point))
6339 (narrow-to-region (point)
6340 (or (and (search-forward "\n.\n" nil t)
6341 (- (point) 2))
6342 (point))))
6343 ;; Subject.
6344 (progn
6345 (goto-char p)
6346 (if (search-forward "\nsubject:" nil t)
6347 (funcall gnus-decode-encoded-word-function
6348 (nnheader-header-value))
6349 "(none)"))
6350 ;; From.
6351 (progn
6352 (goto-char p)
6353 (if (search-forward "\nfrom:" nil t)
6354 (funcall gnus-decode-encoded-address-function
6355 (nnheader-header-value))
6356 "(nobody)"))
6357 ;; Date.
6358 (progn
6359 (goto-char p)
6360 (if (search-forward "\ndate:" nil t)
6361 (nnheader-header-value) ""))
6362 ;; Message-ID.
6363 (progn
6364 (goto-char p)
6365 (setq id (if (re-search-forward
6366 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6367 ;; We do it this way to make sure the Message-ID
6368 ;; is (somewhat) syntactically valid.
6369 (buffer-substring (match-beginning 1)
6370 (match-end 1))
6371 ;; If there was no message-id, we just fake one
6372 ;; to make subsequent routines simpler.
6373 (nnheader-generate-fake-message-id number))))
6374 ;; References.
6375 (progn
6376 (goto-char p)
6377 (if (search-forward "\nreferences:" nil t)
6378 (progn
6379 (setq end (point))
6380 (prog1
6381 (nnheader-header-value)
6382 (setq ref
6383 (buffer-substring
6384 (progn
6385 (end-of-line)
6386 (search-backward ">" end t)
6387 (1+ (point)))
6388 (progn
6389 (search-backward "<" end t)
6390 (point))))))
6391 ;; Get the references from the in-reply-to header if there
6392 ;; were no references and the in-reply-to header looks
6393 ;; promising.
6394 (if (and (search-forward "\nin-reply-to:" nil t)
6395 (setq in-reply-to (nnheader-header-value))
6396 (string-match "<[^>]+>" in-reply-to))
6397 (let (ref2)
6398 (setq ref (substring in-reply-to (match-beginning 0)
6399 (match-end 0)))
6400 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6401 (setq ref2 (substring in-reply-to (match-beginning 0)
6402 (match-end 0)))
6403 (when (> (length ref2) (length ref))
6404 (setq ref ref2)))
6405 ref)
6406 (setq ref nil))))
6407 ;; Chars.
6408 (progn
6409 (goto-char p)
6410 (if (search-forward "\nchars: " nil t)
6411 (if (numberp (setq chars (ignore-errors (read cur))))
6412 chars -1)
6413 -1))
6414 ;; Lines.
6415 (progn
6416 (goto-char p)
6417 (if (search-forward "\nlines: " nil t)
6418 (if (numberp (setq lines (ignore-errors (read cur))))
6419 lines -1)
6420 -1))
6421 ;; Xref.
6422 (progn
6423 (goto-char p)
6424 (and (search-forward "\nxref:" nil t)
6425 (nnheader-header-value)))
6426 ;; Extra.
6427 (when gnus-extra-headers
6428 (let ((extra gnus-extra-headers)
6429 out)
6430 (while extra
6431 (goto-char p)
6432 (when (search-forward
6433 (concat "\n" (symbol-name (car extra)) ":") nil t)
6434 (push (cons (car extra) (nnheader-header-value))
6435 out))
6436 (pop extra))
6437 out))))
6438 (when (equal id ref)
6439 (setq ref nil))
6440
6441 (when gnus-alter-header-function
6442 (funcall gnus-alter-header-function header)
6443 (setq id (mail-header-id header)
6444 ref (gnus-parent-id (mail-header-references header))))
6445
6446 (when (setq header
6447 (gnus-dependencies-add-header
6448 header dependencies force-new))
6449 (push header headers))
6450 (goto-char (point-max))
6451 (widen))
6452 (nreverse headers)))))
6453
6454 ;; Goes through the xover lines and returns a list of vectors
6455 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6456 force-new dependencies
6457 group also-fetch-heads)
6458 "Parse the news overview data in the server buffer.
6459 Return a list of headers that match SEQUENCE (see
6460 `nntp-retrieve-headers')."
6461 ;; Get the Xref when the users reads the articles since most/some
6462 ;; NNTP servers do not include Xrefs when using XOVER.
6463 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6464 (let ((mail-parse-charset gnus-newsgroup-charset)
6465 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6466 (cur nntp-server-buffer)
6467 (dependencies (or dependencies gnus-newsgroup-dependencies))
6468 (allp (cond
6469 ((eq gnus-read-all-available-headers t)
6470 t)
6471 ((and (stringp gnus-read-all-available-headers)
6472 group)
6473 (string-match gnus-read-all-available-headers group))
6474 (t
6475 nil)))
6476 number headers header)
6477 (with-current-buffer nntp-server-buffer
6478 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6479 ;; Allow the user to mangle the headers before parsing them.
6480 (gnus-run-hooks 'gnus-parse-headers-hook)
6481 (goto-char (point-min))
6482 (gnus-parse-without-error
6483 (while (and (or sequence allp)
6484 (not (eobp)))
6485 (setq number (read cur))
6486 (when (not allp)
6487 (while (and sequence
6488 (< (car sequence) number))
6489 (setq sequence (cdr sequence))))
6490 (when (and (or allp
6491 (and sequence
6492 (eq number (car sequence))))
6493 (progn
6494 (setq sequence (cdr sequence))
6495 (setq header (inline
6496 (gnus-nov-parse-line
6497 number dependencies force-new)))))
6498 (push header headers))
6499 (forward-line 1)))
6500 ;; A common bug in inn is that if you have posted an article and
6501 ;; then retrieves the active file, it will answer correctly --
6502 ;; the new article is included. However, a NOV entry for the
6503 ;; article may not have been generated yet, so this may fail.
6504 ;; We work around this problem by retrieving the last few
6505 ;; headers using HEAD.
6506 (if (or (not also-fetch-heads)
6507 (not sequence))
6508 ;; We (probably) got all the headers.
6509 (nreverse headers)
6510 (let ((gnus-nov-is-evil t))
6511 (nconc
6512 (nreverse headers)
6513 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6514 (gnus-get-newsgroup-headers))))))))
6515
6516 (defun gnus-article-get-xrefs ()
6517 "Fill in the Xref value in `gnus-current-headers', if necessary.
6518 This is meant to be called in `gnus-article-internal-prepare-hook'."
6519 (let ((headers (with-current-buffer gnus-summary-buffer
6520 gnus-current-headers)))
6521 (or (not gnus-use-cross-reference)
6522 (not headers)
6523 (and (mail-header-xref headers)
6524 (not (string= (mail-header-xref headers) "")))
6525 (let ((case-fold-search t)
6526 xref)
6527 (save-restriction
6528 (nnheader-narrow-to-headers)
6529 (goto-char (point-min))
6530 (when (or (and (not (eobp))
6531 (eq (downcase (char-after)) ?x)
6532 (looking-at "Xref:"))
6533 (search-forward "\nXref:" nil t))
6534 (goto-char (1+ (match-end 0)))
6535 (setq xref (buffer-substring (point) (point-at-eol)))
6536 (mail-header-set-xref headers xref)))))))
6537
6538 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6539 "Find article ID and insert the summary line for that article.
6540 OLD-HEADER can either be a header or a line number to insert
6541 the subject line on.
6542 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6543 and OLD-HEADER will be used when the summary line is inserted,
6544 too, instead of trying to fetch new headers."
6545 (let* ((line (and (numberp old-header) old-header))
6546 (old-header (and (vectorp old-header) old-header))
6547 (header (cond ((and old-header use-old-header)
6548 old-header)
6549 ((and (numberp id)
6550 (gnus-number-to-header id))
6551 (gnus-number-to-header id))
6552 (t
6553 (gnus-read-header id))))
6554 (number (and (numberp id) id))
6555 d)
6556 (when header
6557 ;; Rebuild the thread that this article is part of and go to the
6558 ;; article we have fetched.
6559 (when (and (not gnus-show-threads)
6560 old-header)
6561 (when (and number
6562 (setq d (gnus-data-find (mail-header-number old-header))))
6563 (goto-char (gnus-data-pos d))
6564 (gnus-data-remove
6565 number
6566 (- (point-at-bol)
6567 (prog1
6568 (1+ (point-at-eol))
6569 (gnus-delete-line))))))
6570 ;; Remove list identifiers from subject.
6571 (let ((gnus-newsgroup-headers (list header)))
6572 (gnus-summary-remove-list-identifiers))
6573 (when old-header
6574 (mail-header-set-number header (mail-header-number old-header)))
6575 (setq gnus-newsgroup-sparse
6576 (delq (setq number (mail-header-number header))
6577 gnus-newsgroup-sparse))
6578 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6579 (push number gnus-newsgroup-limit)
6580 (gnus-rebuild-thread (mail-header-id header) line)
6581 (gnus-summary-goto-subject number nil t))
6582 (when (and (numberp number)
6583 (> number 0))
6584 ;; We have to update the boundaries even if we can't fetch the
6585 ;; article if ID is a number -- so that the next `P' or `N'
6586 ;; command will fetch the previous (or next) article even
6587 ;; if the one we tried to fetch this time has been canceled.
6588 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6589 (setq gnus-newsgroup-end number))
6590 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6591 (setq gnus-newsgroup-begin number))
6592 (setq gnus-newsgroup-unselected
6593 (delq number gnus-newsgroup-unselected)))
6594 ;; Report back a success?
6595 (and header (mail-header-number header))))
6596
6597 ;;; Process/prefix in the summary buffer
6598
6599 (defun gnus-summary-work-articles (n)
6600 "Return a list of articles to be worked upon.
6601 The prefix argument, the list of process marked articles, and the
6602 current article will be taken into consideration."
6603 (with-current-buffer gnus-summary-buffer
6604 (cond
6605 (n
6606 ;; A numerical prefix has been given.
6607 (setq n (prefix-numeric-value n))
6608 (let ((backward (< n 0))
6609 (n (abs (prefix-numeric-value n)))
6610 articles article)
6611 (save-excursion
6612 (while
6613 (and (> n 0)
6614 (push (setq article (gnus-summary-article-number))
6615 articles)
6616 (if backward
6617 (gnus-summary-find-prev nil article)
6618 (gnus-summary-find-next nil article)))
6619 (decf n)))
6620 (nreverse articles)))
6621 ((and (gnus-region-active-p) (mark))
6622 (message "region active")
6623 ;; Work on the region between point and mark.
6624 (let ((max (max (point) (mark)))
6625 articles article)
6626 (save-excursion
6627 (goto-char (min (point) (mark)))
6628 (while
6629 (and
6630 (push (setq article (gnus-summary-article-number)) articles)
6631 (gnus-summary-find-next nil article)
6632 (< (point) max)))
6633 (nreverse articles))))
6634 (gnus-newsgroup-processable
6635 ;; There are process-marked articles present.
6636 ;; Save current state.
6637 (gnus-summary-save-process-mark)
6638 ;; Return the list.
6639 (reverse gnus-newsgroup-processable))
6640 (t
6641 ;; Just return the current article.
6642 (list (gnus-summary-article-number))))))
6643
6644 (defmacro gnus-summary-iterate (arg &rest forms)
6645 "Iterate over the process/prefixed articles and do FORMS.
6646 ARG is the interactive prefix given to the command. FORMS will be
6647 executed with point over the summary line of the articles."
6648 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6649 `(let ((,articles (gnus-summary-work-articles ,arg)))
6650 (while ,articles
6651 (gnus-summary-goto-subject (car ,articles))
6652 ,@forms
6653 (pop ,articles)))))
6654
6655 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6656 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6657
6658 (defun gnus-summary-save-process-mark ()
6659 "Push the current set of process marked articles on the stack."
6660 (interactive)
6661 (push (copy-sequence gnus-newsgroup-processable)
6662 gnus-newsgroup-process-stack))
6663
6664 (defun gnus-summary-kill-process-mark ()
6665 "Push the current set of process marked articles on the stack and unmark."
6666 (interactive)
6667 (gnus-summary-save-process-mark)
6668 (gnus-summary-unmark-all-processable))
6669
6670 (defun gnus-summary-yank-process-mark ()
6671 "Pop the last process mark state off the stack and restore it."
6672 (interactive)
6673 (unless gnus-newsgroup-process-stack
6674 (error "Empty mark stack"))
6675 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6676
6677 (defun gnus-summary-process-mark-set (set)
6678 "Make SET into the current process marked articles."
6679 (gnus-summary-unmark-all-processable)
6680 (mapc 'gnus-summary-set-process-mark set))
6681
6682 ;;; Searching and stuff
6683
6684 (defun gnus-summary-search-group (&optional backward use-level)
6685 "Search for next unread newsgroup.
6686 If optional argument BACKWARD is non-nil, search backward instead."
6687 (with-current-buffer gnus-group-buffer
6688 (when (gnus-group-search-forward
6689 backward nil (if use-level (gnus-group-group-level) nil))
6690 (gnus-group-group-name))))
6691
6692 (defun gnus-summary-best-group (&optional exclude-group)
6693 "Find the name of the best unread group.
6694 If EXCLUDE-GROUP, do not go to this group."
6695 (with-current-buffer gnus-group-buffer
6696 (save-excursion
6697 (gnus-group-best-unread-group exclude-group))))
6698
6699 (defun gnus-summary-find-next (&optional unread article backward)
6700 (if backward
6701 (gnus-summary-find-prev unread article)
6702 (let* ((dummy (gnus-summary-article-intangible-p))
6703 (article (or article (gnus-summary-article-number)))
6704 (data (gnus-data-find-list article))
6705 result)
6706 (when (and (not dummy)
6707 (or (not gnus-summary-check-current)
6708 (not unread)
6709 (not (gnus-data-unread-p (car data)))))
6710 (setq data (cdr data)))
6711 (when (setq result
6712 (if unread
6713 (progn
6714 (while data
6715 (unless (memq (gnus-data-number (car data))
6716 (cond
6717 ((eq gnus-auto-goto-ignores
6718 'always-undownloaded)
6719 gnus-newsgroup-undownloaded)
6720 (gnus-plugged
6721 nil)
6722 ((eq gnus-auto-goto-ignores
6723 'unfetched)
6724 gnus-newsgroup-unfetched)
6725 ((eq gnus-auto-goto-ignores
6726 'undownloaded)
6727 gnus-newsgroup-undownloaded)))
6728 (when (gnus-data-unread-p (car data))
6729 (setq result (car data)
6730 data nil)))
6731 (setq data (cdr data)))
6732 result)
6733 (car data)))
6734 (goto-char (gnus-data-pos result))
6735 (gnus-data-number result)))))
6736
6737 (defun gnus-summary-find-prev (&optional unread article)
6738 (let* ((eobp (eobp))
6739 (article (or article (gnus-summary-article-number)))
6740 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6741 result)
6742 (when (and (not eobp)
6743 (or (not gnus-summary-check-current)
6744 (not unread)
6745 (not (gnus-data-unread-p (car data)))))
6746 (setq data (cdr data)))
6747 (when (setq result
6748 (if unread
6749 (progn
6750 (while data
6751 (unless (memq (gnus-data-number (car data))
6752 (cond
6753 ((eq gnus-auto-goto-ignores
6754 'always-undownloaded)
6755 gnus-newsgroup-undownloaded)
6756 (gnus-plugged
6757 nil)
6758 ((eq gnus-auto-goto-ignores
6759 'unfetched)
6760 gnus-newsgroup-unfetched)
6761 ((eq gnus-auto-goto-ignores
6762 'undownloaded)
6763 gnus-newsgroup-undownloaded)))
6764 (when (gnus-data-unread-p (car data))
6765 (setq result (car data)
6766 data nil)))
6767 (setq data (cdr data)))
6768 result)
6769 (car data)))
6770 (goto-char (gnus-data-pos result))
6771 (gnus-data-number result))))
6772
6773 (defun gnus-summary-find-subject (subject &optional unread backward article)
6774 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6775 (article (or article (gnus-summary-article-number)))
6776 (articles (gnus-data-list backward))
6777 (arts (gnus-data-find-list article articles))
6778 result)
6779 (when (or (not gnus-summary-check-current)
6780 (not unread)
6781 (not (gnus-data-unread-p (car arts))))
6782 (setq arts (cdr arts)))
6783 (while arts
6784 (and (or (not unread)
6785 (gnus-data-unread-p (car arts)))
6786 (vectorp (gnus-data-header (car arts)))
6787 (gnus-subject-equal
6788 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6789 (setq result (car arts)
6790 arts nil))
6791 (setq arts (cdr arts)))
6792 (and result
6793 (goto-char (gnus-data-pos result))
6794 (gnus-data-number result))))
6795
6796 (defun gnus-summary-search-forward (&optional unread subject backward)
6797 "Search forward for an article.
6798 If UNREAD, look for unread articles. If SUBJECT, look for
6799 articles with that subject. If BACKWARD, search backward instead."
6800 (cond (subject (gnus-summary-find-subject subject unread backward))
6801 (backward (gnus-summary-find-prev unread))
6802 (t (gnus-summary-find-next unread))))
6803
6804 (defun gnus-recenter (&optional n)
6805 "Center point in window and redisplay frame.
6806 Also do horizontal recentering."
6807 (interactive "P")
6808 (when (and gnus-auto-center-summary
6809 (not (eq gnus-auto-center-summary 'vertical)))
6810 (gnus-horizontal-recenter))
6811 (if (fboundp 'recenter-top-bottom)
6812 (recenter-top-bottom n)
6813 (recenter n)))
6814
6815 (put 'gnus-recenter 'isearch-scroll t)
6816
6817 (defun gnus-forward-line-ignore-invisible (n)
6818 "Move N lines forward (backward if N is negative).
6819 Like forward-line, but skip over (and don't count) invisible lines."
6820 (let (done)
6821 (while (and (> n 0) (not done))
6822 ;; If the following character is currently invisible,
6823 ;; skip all characters with that same `invisible' property value.
6824 (while (gnus-invisible-p (point))
6825 (goto-char (gnus-next-char-property-change (point))))
6826 (forward-line 1)
6827 (if (eobp)
6828 (setq done t)
6829 (setq n (1- n))))
6830 (while (and (< n 0) (not done))
6831 (forward-line -1)
6832 (if (bobp) (setq done t)
6833 (setq n (1+ n))
6834 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6835 (goto-char (gnus-previous-char-property-change (point))))))))
6836
6837 (defun gnus-summary-recenter ()
6838 "Center point in the summary window.
6839 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6840 displayed, no centering will be performed."
6841 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6842 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6843 (interactive)
6844 ;; The user has to want it.
6845 (when gnus-auto-center-summary
6846 (let* ((top (cond ((< (window-height) 4) 0)
6847 ((< (window-height) 7) 1)
6848 (t (if (numberp gnus-auto-center-summary)
6849 gnus-auto-center-summary
6850 (/ (1- (window-height)) 2)))))
6851 (height (1- (window-height)))
6852 (bottom (save-excursion
6853 (goto-char (point-max))
6854 (gnus-forward-line-ignore-invisible (- height))
6855 (point)))
6856 (window (get-buffer-window (current-buffer))))
6857 (when (get-buffer-window gnus-article-buffer)
6858 ;; Only do recentering when the article buffer is displayed,
6859 ;; Set the window start to either `bottom', which is the biggest
6860 ;; possible valid number, or the second line from the top,
6861 ;; whichever is the least.
6862 (let ((top-pos (save-excursion
6863 (gnus-forward-line-ignore-invisible (- top))
6864 (point))))
6865 (if (> bottom top-pos)
6866 ;; Keep the second line from the top visible
6867 (set-window-start window top-pos)
6868 ;; Try to keep the bottom line visible; if it's partially
6869 ;; obscured, either scroll one more line to make it fully
6870 ;; visible, or revert to using TOP-POS.
6871 (save-excursion
6872 (goto-char (point-max))
6873 (gnus-forward-line-ignore-invisible -1)
6874 (let ((last-line-start (point)))
6875 (goto-char bottom)
6876 (set-window-start window (point) t)
6877 (when (not (pos-visible-in-window-p last-line-start window))
6878 (gnus-forward-line-ignore-invisible 1)
6879 (set-window-start window (min (point) top-pos) t)))))))
6880 ;; Do horizontal recentering while we're at it.
6881 (when (and (get-buffer-window (current-buffer) t)
6882 (not (eq gnus-auto-center-summary 'vertical)))
6883 (let ((selected (selected-window)))
6884 (select-window (get-buffer-window (current-buffer) t))
6885 (gnus-summary-position-point)
6886 (gnus-horizontal-recenter)
6887 (select-window selected))))))
6888
6889 (defun gnus-summary-jump-to-group (newsgroup)
6890 "Move point to NEWSGROUP in group mode buffer."
6891 ;; Keep update point of group mode buffer if visible.
6892 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6893 (save-window-excursion
6894 ;; Take care of tree window mode.
6895 (when (get-buffer-window gnus-group-buffer)
6896 (pop-to-buffer gnus-group-buffer))
6897 (gnus-group-jump-to-group newsgroup))
6898 (save-excursion
6899 ;; Take care of tree window mode.
6900 (if (get-buffer-window gnus-group-buffer 0)
6901 (pop-to-buffer gnus-group-buffer)
6902 (set-buffer gnus-group-buffer))
6903 (gnus-group-jump-to-group newsgroup))))
6904
6905 ;; This function returns a list of article numbers based on the
6906 ;; difference between the ranges of read articles in this group and
6907 ;; the range of active articles.
6908 (defun gnus-list-of-unread-articles (group)
6909 (let* ((read (gnus-info-read (gnus-get-info group)))
6910 (active (or (gnus-active group) (gnus-activate-group group)))
6911 (last (or (cdr active)
6912 (error "Group %s couldn't be activated " group)))
6913 (bottom (if gnus-newsgroup-maximum-articles
6914 (max (car active)
6915 (- last gnus-newsgroup-maximum-articles -1))
6916 (car active)))
6917 first nlast unread)
6918 ;; If none are read, then all are unread.
6919 (if (not read)
6920 (setq first bottom)
6921 ;; If the range of read articles is a single range, then the
6922 ;; first unread article is the article after the last read
6923 ;; article. Sounds logical, doesn't it?
6924 (if (and (not (listp (cdr read)))
6925 (or (< (car read) bottom)
6926 (progn (setq read (list read))
6927 nil)))
6928 (setq first (max bottom (1+ (cdr read))))
6929 ;; `read' is a list of ranges.
6930 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6931 (caar read)))
6932 1)
6933 (setq first bottom))
6934 (while read
6935 (when first
6936 (while (< first nlast)
6937 (setq unread (cons first unread)
6938 first (1+ first))))
6939 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6940 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6941 (setq read (cdr read)))))
6942 ;; And add the last unread articles.
6943 (while (<= first last)
6944 (setq unread (cons first unread)
6945 first (1+ first)))
6946 ;; Return the list of unread articles.
6947 (delq 0 (nreverse unread))))
6948
6949 (defun gnus-list-of-read-articles (group)
6950 "Return a list of unread, unticked and non-dormant articles."
6951 (let* ((info (gnus-get-info group))
6952 (marked (gnus-info-marks info))
6953 (active (gnus-active group)))
6954 (and info active
6955 (gnus-list-range-difference
6956 (gnus-list-range-difference
6957 (gnus-sorted-complement
6958 (gnus-uncompress-range
6959 (if gnus-newsgroup-maximum-articles
6960 (cons (max (car active)
6961 (- (cdr active)
6962 gnus-newsgroup-maximum-articles
6963 -1))
6964 (cdr active))
6965 active))
6966 (gnus-list-of-unread-articles group))
6967 (cdr (assq 'dormant marked)))
6968 (cdr (assq 'tick marked))))))
6969
6970 ;; This function returns a sequence of article numbers based on the
6971 ;; difference between the ranges of read articles in this group and
6972 ;; the range of active articles.
6973 (defun gnus-sequence-of-unread-articles (group)
6974 (let* ((read (gnus-info-read (gnus-get-info group)))
6975 (active (or (gnus-active group) (gnus-activate-group group)))
6976 (last (cdr active))
6977 (bottom (if gnus-newsgroup-maximum-articles
6978 (max (car active)
6979 (- last gnus-newsgroup-maximum-articles -1))
6980 (car active)))
6981 first nlast unread)
6982 ;; If none are read, then all are unread.
6983 (if (not read)
6984 (setq first bottom)
6985 ;; If the range of read articles is a single range, then the
6986 ;; first unread article is the article after the last read
6987 ;; article. Sounds logical, doesn't it?
6988 (if (and (not (listp (cdr read)))
6989 (or (< (car read) bottom)
6990 (progn (setq read (list read))
6991 nil)))
6992 (setq first (max bottom (1+ (cdr read))))
6993 ;; `read' is a list of ranges.
6994 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6995 (caar read)))
6996 1)
6997 (setq first bottom))
6998 (while read
6999 (when first
7000 (push (cons first nlast) unread))
7001 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7002 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7003 (setq read (cdr read)))))
7004 ;; And add the last unread articles.
7005 (cond ((not (and first last))
7006 nil)
7007 ((< first last)
7008 (push (cons first last) unread))
7009 ((= first last)
7010 (push first unread)))
7011 ;; Return the sequence of unread articles.
7012 (delq 0 (nreverse unread))))
7013
7014 ;; Various summary commands
7015
7016 (defun gnus-summary-select-article-buffer ()
7017 "Reconfigure windows to show the article buffer.
7018 If `gnus-widen-article-window' is set, show only the article
7019 buffer."
7020 (interactive)
7021 (if (not (gnus-buffer-live-p gnus-article-buffer))
7022 (error "There is no article buffer for this summary buffer")
7023 (unless (get-buffer-window gnus-article-buffer)
7024 (gnus-summary-show-article))
7025 (gnus-configure-windows
7026 (if gnus-widen-article-window
7027 'only-article
7028 'article)
7029 t)
7030 (select-window (get-buffer-window gnus-article-buffer))))
7031
7032 (defun gnus-summary-universal-argument (arg)
7033 "Perform any operation on all articles that are process/prefixed."
7034 (interactive "P")
7035 (let ((articles (gnus-summary-work-articles arg))
7036 func article)
7037 (if (eq
7038 (setq
7039 func
7040 (key-binding
7041 (read-key-sequence
7042 (substitute-command-keys
7043 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7044 'undefined)
7045 (gnus-error 1 "Undefined key")
7046 (save-excursion
7047 (while articles
7048 (gnus-summary-goto-subject (setq article (pop articles)))
7049 (let (gnus-newsgroup-processable)
7050 (command-execute func))
7051 (gnus-summary-remove-process-mark article)))))
7052 (gnus-summary-position-point))
7053
7054 (defun gnus-summary-toggle-truncation (&optional arg)
7055 "Toggle truncation of summary lines.
7056 With ARG, turn line truncation on if ARG is positive."
7057 (interactive "P")
7058 (setq truncate-lines
7059 (if (null arg) (not truncate-lines)
7060 (> (prefix-numeric-value arg) 0)))
7061 (redraw-display))
7062
7063 (defun gnus-summary-find-for-reselect ()
7064 "Return the number of an article to stay on across a reselect.
7065 The current article is considered, then following articles, then previous
7066 articles. An article is sought which is not canceled and isn't a temporary
7067 insertion from another group. If there's no such then return a dummy 0."
7068 (let (found)
7069 (dolist (rev '(nil t))
7070 (unless found ; don't demand the reverse list if we don't need it
7071 (let ((data (gnus-data-find-list
7072 (gnus-summary-article-number) (gnus-data-list rev))))
7073 (while (and data (not found))
7074 (if (and (< 0 (gnus-data-number (car data)))
7075 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7076 (setq found (gnus-data-number (car data))))
7077 (setq data (cdr data))))))
7078 (or found 0)))
7079
7080 (defun gnus-summary-reselect-current-group (&optional all rescan)
7081 "Exit and then reselect the current newsgroup.
7082 The prefix argument ALL means to select all articles."
7083 (interactive "P")
7084 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7085 (error "Ephemeral groups can't be reselected"))
7086 (let ((current-subject (gnus-summary-find-for-reselect))
7087 (group gnus-newsgroup-name))
7088 (setq gnus-newsgroup-begin nil)
7089 (gnus-summary-exit nil 'leave-hidden)
7090 ;; We have to adjust the point of group mode buffer because
7091 ;; point was moved to the next unread newsgroup by exiting.
7092 (gnus-summary-jump-to-group group)
7093 (when rescan
7094 (save-excursion
7095 (gnus-group-get-new-news-this-group 1)))
7096 (gnus-group-read-group all t)
7097 (gnus-summary-goto-subject current-subject nil t)))
7098
7099 (defun gnus-summary-rescan-group (&optional all)
7100 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7101 (interactive "P")
7102 (let ((config gnus-current-window-configuration))
7103 (gnus-summary-reselect-current-group all t)
7104 (gnus-configure-windows config)
7105 (when (eq config 'article)
7106 (gnus-summary-select-article))))
7107
7108 (defun gnus-summary-update-info (&optional non-destructive)
7109 (save-excursion
7110 (let ((group gnus-newsgroup-name))
7111 (when group
7112 (when gnus-newsgroup-kill-headers
7113 (setq gnus-newsgroup-killed
7114 (gnus-compress-sequence
7115 (gnus-sorted-union
7116 (gnus-list-range-intersection
7117 gnus-newsgroup-unselected gnus-newsgroup-killed)
7118 gnus-newsgroup-unreads)
7119 t)))
7120 (unless (listp (cdr gnus-newsgroup-killed))
7121 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7122 (let ((headers gnus-newsgroup-headers)
7123 (ephemeral-p (gnus-ephemeral-group-p group))
7124 info)
7125 (unless ephemeral-p
7126 (setq info (copy-sequence (gnus-get-info group))
7127 info (delq (gnus-info-params info) info)))
7128 ;; Set the new ranges of read articles.
7129 (with-current-buffer gnus-group-buffer
7130 (gnus-undo-force-boundary))
7131 (gnus-update-read-articles
7132 group (gnus-sorted-union
7133 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7134 ;; Set the current article marks.
7135 (let ((gnus-newsgroup-scored
7136 (if (and (not gnus-save-score)
7137 (not non-destructive))
7138 nil
7139 gnus-newsgroup-scored)))
7140 (save-excursion
7141 (gnus-update-marks)))
7142 ;; Do the cross-ref thing.
7143 (when gnus-use-cross-reference
7144 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7145 ;; Do not switch windows but change the buffer to work.
7146 (set-buffer gnus-group-buffer)
7147 (unless ephemeral-p
7148 (gnus-group-update-group
7149 group nil
7150 (equal info
7151 (setq info (copy-sequence (gnus-get-info group))
7152 info (delq (gnus-info-params info) info))))))))))
7153
7154 (defun gnus-summary-save-newsrc (&optional force)
7155 "Save the current number of read/marked articles in the dribble buffer.
7156 The dribble buffer will then be saved.
7157 If FORCE (the prefix), also save the .newsrc file(s)."
7158 (interactive "P")
7159 (gnus-summary-update-info t)
7160 (if force
7161 (gnus-save-newsrc-file)
7162 (gnus-dribble-save)))
7163
7164 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7165
7166 (defun gnus-summary-exit (&optional temporary leave-hidden)
7167 "Exit reading current newsgroup, and then return to group selection mode.
7168 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7169 (interactive)
7170 (gnus-set-global-variables)
7171 (when (gnus-buffer-live-p gnus-article-buffer)
7172 (with-current-buffer gnus-article-buffer
7173 (mm-destroy-parts gnus-article-mime-handles)
7174 ;; Set it to nil for safety reason.
7175 (setq gnus-article-mime-handle-alist nil)
7176 (setq gnus-article-mime-handles nil)))
7177 (gnus-kill-save-kill-buffer)
7178 (gnus-async-halt-prefetch)
7179 (let* ((group gnus-newsgroup-name)
7180 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7181 (gnus-group-is-exiting-p t)
7182 (article-buffer gnus-article-buffer)
7183 (original-article-buffer gnus-original-article-buffer)
7184 (mode major-mode)
7185 (group-point nil)
7186 (buf (current-buffer))
7187 ;; `gnus-single-article-buffer' is nil buffer-locally in
7188 ;; ephemeral group of which summary buffer will be killed,
7189 ;; but the global value may be non-nil.
7190 (single-article-buffer gnus-single-article-buffer))
7191 (unless quit-config
7192 ;; Do adaptive scoring, and possibly save score files.
7193 (when gnus-newsgroup-adaptive
7194 (gnus-score-adaptive))
7195 (when gnus-use-scoring
7196 (gnus-score-save)))
7197 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7198 (when gnus-use-cache
7199 (gnus-cache-possibly-remove-articles)
7200 (gnus-cache-save-buffers))
7201 (gnus-async-prefetch-remove-group group)
7202 (when gnus-suppress-duplicates
7203 (gnus-dup-enter-articles))
7204 (when gnus-use-trees
7205 (gnus-tree-close group))
7206 (when gnus-use-cache
7207 (gnus-cache-write-active))
7208 ;; Remove entries for this group.
7209 (nnmail-purge-split-history (gnus-group-real-name group))
7210 ;; Make all changes in this group permanent.
7211 (unless quit-config
7212 (gnus-run-hooks 'gnus-exit-group-hook)
7213 (gnus-summary-update-info))
7214 (gnus-close-group group)
7215 ;; Make sure where we were, and go to next newsgroup.
7216 (when (buffer-live-p (get-buffer gnus-group-buffer))
7217 (set-buffer gnus-group-buffer))
7218 (unless quit-config
7219 (gnus-group-jump-to-group group))
7220 (gnus-run-hooks 'gnus-summary-exit-hook)
7221 (unless (or quit-config
7222 (not gnus-summary-next-group-on-exit)
7223 ;; If this group has disappeared from the summary
7224 ;; buffer, don't skip forwards.
7225 (not (string= group (gnus-group-group-name))))
7226 (gnus-group-next-unread-group 1))
7227 (setq group-point (point))
7228 (if temporary
7229 nil ;Nothing to do.
7230 (set-buffer buf)
7231 (if (not gnus-kill-summary-on-exit)
7232 (progn
7233 (gnus-deaden-summary)
7234 (setq mode nil))
7235 (when (get-buffer gnus-article-buffer)
7236 (bury-buffer gnus-article-buffer))
7237 ;; Return to group mode buffer.
7238 (when (eq mode 'gnus-summary-mode)
7239 (gnus-kill-buffer buf)))
7240
7241 (setq gnus-current-select-method gnus-select-method)
7242 (when (gnus-buffer-live-p gnus-group-buffer)
7243 (set-buffer gnus-group-buffer))
7244 (if quit-config
7245 (gnus-handle-ephemeral-exit quit-config)
7246 (goto-char group-point)
7247 ;; If gnus-group-buffer is already displayed, make sure we also move
7248 ;; the cursor in the window that displays it.
7249 (let ((win (get-buffer-window (current-buffer) 0)))
7250 (if win (set-window-point win (point))))
7251 (unless leave-hidden
7252 (gnus-configure-windows 'group 'force)))
7253
7254 ;; If we have several article buffers, we kill them at exit.
7255 (unless single-article-buffer
7256 (when (gnus-buffer-live-p article-buffer)
7257 (with-current-buffer article-buffer
7258 ;; Don't kill sticky article buffers
7259 (unless (eq major-mode 'gnus-sticky-article-mode)
7260 (gnus-kill-buffer article-buffer)
7261 (setq gnus-article-current nil))))
7262 (gnus-kill-buffer original-article-buffer))
7263
7264 ;; Clear the current group name.
7265 (unless quit-config
7266 (setq gnus-newsgroup-name nil)))))
7267
7268 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7269 (defun gnus-summary-exit-no-update (&optional no-questions)
7270 "Quit reading current newsgroup without updating read article info."
7271 (interactive)
7272 (let* ((group gnus-newsgroup-name)
7273 (gnus-group-is-exiting-p t)
7274 (gnus-group-is-exiting-without-update-p t)
7275 (quit-config (gnus-group-quit-config group)))
7276 (when (or no-questions
7277 gnus-expert-user
7278 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7279 (gnus-async-halt-prefetch)
7280 (run-hooks 'gnus-summary-prepare-exit-hook)
7281 (when (gnus-buffer-live-p gnus-article-buffer)
7282 (with-current-buffer gnus-article-buffer
7283 (gnus-article-stop-animations)
7284 (gnus-stop-downloads)
7285 (mm-destroy-parts gnus-article-mime-handles)
7286 ;; Set it to nil for safety reason.
7287 (setq gnus-article-mime-handle-alist nil)
7288 (setq gnus-article-mime-handles nil)))
7289 ;; If we have several article buffers, we kill them at exit.
7290 (unless gnus-single-article-buffer
7291 (gnus-kill-buffer gnus-article-buffer)
7292 (gnus-kill-buffer gnus-original-article-buffer)
7293 (setq gnus-article-current nil))
7294 ;; Return to the group buffer.
7295 (if (not gnus-kill-summary-on-exit)
7296 (progn
7297 (gnus-deaden-summary)
7298 (gnus-configure-windows 'group 'force))
7299 (gnus-configure-windows 'group 'force)
7300 (gnus-close-group group)
7301 (gnus-kill-buffer gnus-summary-buffer))
7302 (unless gnus-single-article-buffer
7303 (setq gnus-article-current nil))
7304 (when gnus-use-trees
7305 (gnus-tree-close group))
7306 (gnus-async-prefetch-remove-group group)
7307 (when (get-buffer gnus-article-buffer)
7308 (bury-buffer gnus-article-buffer))
7309 ;; Clear the current group name.
7310 (setq gnus-newsgroup-name nil)
7311 (unless (gnus-ephemeral-group-p group)
7312 (gnus-group-update-group group nil t))
7313 (when (equal (gnus-group-group-name) group)
7314 (gnus-group-next-unread-group 1))
7315 (when quit-config
7316 (gnus-handle-ephemeral-exit quit-config)))))
7317
7318 (defun gnus-handle-ephemeral-exit (quit-config)
7319 "Handle movement when leaving an ephemeral group.
7320 The state which existed when entering the ephemeral is reset."
7321 (if (not (buffer-live-p (car quit-config)))
7322 (when (gnus-buffer-live-p gnus-group-buffer)
7323 (gnus-configure-windows 'group 'force))
7324 (set-buffer (car quit-config))
7325 (unless (eq (cdr quit-config) 'group)
7326 (setq gnus-current-select-method
7327 (gnus-find-method-for-group gnus-newsgroup-name)))
7328 (cond ((eq major-mode 'gnus-summary-mode)
7329 (gnus-set-global-variables))
7330 ((eq major-mode 'gnus-article-mode)
7331 (save-current-buffer
7332 ;; The `gnus-summary-buffer' variable may point
7333 ;; to the old summary buffer when using a single
7334 ;; article buffer.
7335 (unless (gnus-buffer-live-p gnus-summary-buffer)
7336 (set-buffer gnus-group-buffer))
7337 (set-buffer gnus-summary-buffer)
7338 (gnus-set-global-variables))))
7339 (if (or (eq (cdr quit-config) 'article)
7340 (eq (cdr quit-config) 'pick))
7341 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7342 (gnus-configure-windows 'pick 'force)
7343 (gnus-configure-windows (cdr quit-config) 'force))
7344 (gnus-configure-windows (cdr quit-config) 'force))
7345 (when (eq major-mode 'gnus-summary-mode)
7346 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7347 next-unread-noselect))
7348 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7349 'next-noselect)
7350 (gnus-summary-next-subject 1 nil t))
7351 ((eq gnus-auto-select-on-ephemeral-exit
7352 'next-unread-noselect)
7353 (gnus-summary-next-subject 1 t t))))
7354 ;; Hide the article buffer which displays the article different
7355 ;; from the one that the cursor points to in the summary buffer.
7356 (gnus-configure-windows 'summary 'force))
7357 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7358 (gnus-summary-next-subject 1))
7359 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7360 (gnus-summary-next-subject 1 t))))
7361 (gnus-summary-recenter)
7362 (gnus-summary-position-point))))
7363
7364 ;;; Dead summaries.
7365
7366 (defvar gnus-dead-summary-mode-map
7367 (let ((map (make-keymap)))
7368 (suppress-keymap map)
7369 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7370 (dolist (key '("\C-d" "\r" "\177" [delete]))
7371 (define-key map key 'gnus-summary-wake-up-the-dead))
7372 (dolist (key '("q" "Q"))
7373 (define-key map key 'bury-buffer))
7374 map))
7375
7376 (define-minor-mode gnus-dead-summary-mode
7377 "Minor mode for Gnus summary buffers."
7378 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7379 (unless (derived-mode-p 'gnus-summary-mode)
7380 (setq gnus-dead-summary-mode nil)))
7381
7382 (defun gnus-deaden-summary ()
7383 "Make the current summary buffer into a dead summary buffer."
7384 ;; Kill any previous dead summary buffer.
7385 (when (and gnus-dead-summary
7386 (buffer-name gnus-dead-summary))
7387 (with-current-buffer gnus-dead-summary
7388 (when gnus-dead-summary-mode
7389 (kill-buffer (current-buffer)))))
7390 ;; Make this the current dead summary.
7391 (setq gnus-dead-summary (current-buffer))
7392 (gnus-dead-summary-mode 1)
7393 (let ((name (buffer-name)))
7394 (when (string-match "Summary" name)
7395 (rename-buffer
7396 (concat (substring name 0 (match-beginning 0)) "Dead "
7397 (substring name (match-beginning 0)))
7398 t)
7399 (bury-buffer))))
7400
7401 (defun gnus-kill-or-deaden-summary (buffer)
7402 "Kill or deaden the summary BUFFER."
7403 (save-excursion
7404 (when (and (buffer-name buffer)
7405 (not gnus-single-article-buffer))
7406 (with-current-buffer buffer
7407 (gnus-kill-buffer gnus-article-buffer)
7408 (gnus-kill-buffer gnus-original-article-buffer)))
7409 (cond
7410 ;; Kill the buffer.
7411 (gnus-kill-summary-on-exit
7412 (when (and gnus-use-trees
7413 (gnus-buffer-exists-p buffer))
7414 (with-current-buffer buffer
7415 (gnus-tree-close gnus-newsgroup-name)))
7416 (gnus-kill-buffer buffer))
7417 ;; Deaden the buffer.
7418 ((gnus-buffer-exists-p buffer)
7419 (with-current-buffer buffer
7420 (gnus-deaden-summary))))))
7421
7422 (defun gnus-summary-wake-up-the-dead (&rest args)
7423 "Wake up the dead summary buffer."
7424 (interactive)
7425 (gnus-dead-summary-mode -1)
7426 (let ((name (buffer-name)))
7427 (when (string-match "Dead " name)
7428 (rename-buffer
7429 (concat (substring name 0 (match-beginning 0))
7430 (substring name (match-end 0)))
7431 t)))
7432 (gnus-message 3 "This dead summary is now alive again"))
7433
7434 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7435 (defun gnus-summary-describe-group (&optional force)
7436 "Describe the current newsgroup."
7437 (interactive "P")
7438 (gnus-group-describe-group force gnus-newsgroup-name))
7439
7440 (defun gnus-summary-describe-briefly ()
7441 "Describe summary mode commands briefly."
7442 (interactive)
7443 (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")))
7444
7445 ;; Walking around group mode buffer from summary mode.
7446
7447 (defun gnus-summary-next-group (&optional no-article target-group backward)
7448 "Exit current newsgroup and then select next unread newsgroup.
7449 If prefix argument NO-ARTICLE is non-nil, no article is selected
7450 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7451 previous group instead."
7452 (interactive "P")
7453 ;; Stop pre-fetching.
7454 (gnus-async-halt-prefetch)
7455 (let ((current-group gnus-newsgroup-name)
7456 (current-buffer (current-buffer))
7457 entered)
7458 ;; First we semi-exit this group to update Xrefs and all variables.
7459 ;; We can't do a real exit, because the window conf must remain
7460 ;; the same in case the user is prompted for info, and we don't
7461 ;; want the window conf to change before that...
7462 (gnus-summary-exit t)
7463 (while (not entered)
7464 ;; Then we find what group we are supposed to enter.
7465 (set-buffer gnus-group-buffer)
7466 (gnus-group-jump-to-group current-group)
7467 (setq target-group
7468 (or target-group
7469 (if (eq gnus-keep-same-level 'best)
7470 (gnus-summary-best-group gnus-newsgroup-name)
7471 (gnus-summary-search-group backward gnus-keep-same-level))))
7472 (if (not target-group)
7473 ;; There are no further groups, so we return to the group
7474 ;; buffer.
7475 (progn
7476 (gnus-message 5 "Returning to the group buffer")
7477 (setq entered t)
7478 (when (gnus-buffer-live-p current-buffer)
7479 (set-buffer current-buffer)
7480 (gnus-summary-exit))
7481 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7482 ;; We try to enter the target group.
7483 (gnus-group-jump-to-group target-group)
7484 (let ((unreads (gnus-group-group-unread)))
7485 (if (and (or (eq t unreads)
7486 (and unreads (not (zerop unreads))))
7487 (gnus-summary-read-group
7488 target-group nil no-article
7489 (and (buffer-name current-buffer) current-buffer)
7490 nil backward))
7491 (setq entered t)
7492 (setq current-group target-group
7493 target-group nil)))))))
7494
7495 (defun gnus-summary-prev-group (&optional no-article)
7496 "Exit current newsgroup and then select previous unread newsgroup.
7497 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7498 (interactive "P")
7499 (gnus-summary-next-group no-article nil t))
7500
7501 ;; Walking around summary lines.
7502
7503 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7504 "Go to the first subject satisfying any non-nil constraint.
7505 If UNREAD is non-nil, the article should be unread.
7506 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7507 If UNSEEN is non-nil, the article should be unseen as well as unread.
7508 Returns the article selected or nil if there are no matching articles."
7509 (interactive "P")
7510 (cond
7511 ;; Empty summary.
7512 ((null gnus-newsgroup-data)
7513 (gnus-message 3 "No articles in the group")
7514 nil)
7515 ;; Pick the first article.
7516 ((not (or unread undownloaded unseen))
7517 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7518 (gnus-data-number (car gnus-newsgroup-data)))
7519 ;; Find the first unread article.
7520 (t
7521 (let ((data gnus-newsgroup-data))
7522 (while (and data
7523 (let ((num (gnus-data-number (car data))))
7524 (or (memq num gnus-newsgroup-unfetched)
7525 (not (or (and unread
7526 (memq num gnus-newsgroup-unreads))
7527 (and undownloaded
7528 (memq num gnus-newsgroup-undownloaded))
7529 (and unseen
7530 (memq num gnus-newsgroup-unseen)
7531 (memq num gnus-newsgroup-unreads)))))))
7532 (setq data (cdr data)))
7533 (prog1
7534 (if data
7535 (progn
7536 (goto-char (gnus-data-pos (car data)))
7537 (gnus-data-number (car data)))
7538 (gnus-message 3 "No more%s articles"
7539 (let* ((r (when unread " unread"))
7540 (d (when undownloaded " undownloaded"))
7541 (s (when unseen " unseen"))
7542 (l (delq nil (list r d s))))
7543 (cond ((= 3 (length l))
7544 (concat r "," d ", or" s))
7545 ((= 2 (length l))
7546 (concat (car l) ", or" (cadr l)))
7547 ((= 1 (length l))
7548 (car l))
7549 (t
7550 ""))))
7551 nil
7552 )
7553 (gnus-summary-position-point))))))
7554
7555 (defun gnus-summary-next-subject (n &optional unread dont-display)
7556 "Go to next N'th summary line.
7557 If N is negative, go to the previous N'th subject line.
7558 If UNREAD is non-nil, only unread articles are selected.
7559 The difference between N and the actual number of steps taken is
7560 returned."
7561 (interactive "p")
7562 (let ((backward (< n 0))
7563 (n (abs n)))
7564 (while (and (> n 0)
7565 (if backward
7566 (gnus-summary-find-prev unread)
7567 (gnus-summary-find-next unread)))
7568 (unless (zerop (setq n (1- n)))
7569 (gnus-summary-show-thread)))
7570 (when (/= 0 n)
7571 (gnus-message 7 "No more%s articles"
7572 (if unread " unread" "")))
7573 (unless dont-display
7574 (gnus-summary-recenter)
7575 (gnus-summary-position-point))
7576 n))
7577
7578 (defun gnus-summary-next-unread-subject (n)
7579 "Go to next N'th unread summary line."
7580 (interactive "p")
7581 (gnus-summary-next-subject n t))
7582
7583 (defun gnus-summary-prev-subject (n &optional unread)
7584 "Go to previous N'th summary line.
7585 If optional argument UNREAD is non-nil, only unread article is selected."
7586 (interactive "p")
7587 (gnus-summary-next-subject (- n) unread))
7588
7589 (defun gnus-summary-prev-unread-subject (n)
7590 "Go to previous N'th unread summary line."
7591 (interactive "p")
7592 (gnus-summary-next-subject (- n) t))
7593
7594 (defun gnus-summary-goto-subjects (articles)
7595 "Insert the subject header for ARTICLES in the current buffer."
7596 (save-excursion
7597 (dolist (article articles)
7598 (gnus-summary-goto-subject article t)))
7599 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7600 (gnus-summary-position-point))
7601
7602 (defun gnus-summary-goto-subject (article &optional force silent)
7603 "Go to the subject line of ARTICLE.
7604 If FORCE, also allow jumping to articles not currently shown."
7605 (interactive "nArticle number: ")
7606 (unless (numberp article)
7607 (error "Article %s is not a number" article))
7608 (let ((b (point))
7609 (data (gnus-data-find article)))
7610 ;; We read in the article if we have to.
7611 (and (not data)
7612 force
7613 (gnus-summary-insert-subject
7614 article
7615 (if (or (numberp force) (vectorp force)) force)
7616 t)
7617 (setq data (gnus-data-find article)))
7618 (goto-char b)
7619 (if (not data)
7620 (progn
7621 (unless silent
7622 (gnus-message 3 "Can't find article %d" article))
7623 nil)
7624 (let ((pt (gnus-data-pos data)))
7625 (goto-char pt)
7626 (gnus-summary-set-article-display-arrow pt))
7627 (gnus-summary-position-point)
7628 article)))
7629
7630 ;; Walking around summary lines with displaying articles.
7631
7632 (defun gnus-summary-expand-window (&optional arg)
7633 "Make the summary buffer take up the entire Emacs frame.
7634 Given a prefix, will force an `article' buffer configuration."
7635 (interactive "P")
7636 (if arg
7637 (gnus-configure-windows 'article 'force)
7638 (gnus-configure-windows 'summary 'force)))
7639
7640 (defun gnus-summary-display-article (article &optional all-header)
7641 "Display ARTICLE in article buffer."
7642 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7643 (with-current-buffer gnus-article-buffer
7644 (eq major-mode 'gnus-article-mode)))
7645 (gnus-article-setup-buffer))
7646 (gnus-set-global-variables)
7647 (with-current-buffer gnus-article-buffer
7648 (setq gnus-article-charset gnus-newsgroup-charset)
7649 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7650 (mm-enable-multibyte))
7651 (if (null article)
7652 nil
7653 (prog1
7654 (if gnus-summary-display-article-function
7655 (funcall gnus-summary-display-article-function article all-header)
7656 (gnus-article-prepare article all-header))
7657 (gnus-run-hooks 'gnus-select-article-hook)
7658 (when (and gnus-current-article
7659 (not (zerop gnus-current-article)))
7660 (gnus-summary-goto-subject gnus-current-article))
7661 (gnus-summary-recenter)
7662 (when (and gnus-use-trees gnus-show-threads)
7663 (gnus-possibly-generate-tree article)
7664 (gnus-highlight-selected-tree article))
7665 ;; Successfully display article.
7666 (gnus-article-set-window-start
7667 (cdr (assq article gnus-newsgroup-bookmarks))))))
7668
7669 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7670 "Select the current article.
7671 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7672 non-nil, the article will be re-fetched even if it already present in
7673 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7674 be displayed."
7675 ;; Make sure we are in the summary buffer to work around bbdb bug.
7676 (unless (eq major-mode 'gnus-summary-mode)
7677 (set-buffer gnus-summary-buffer))
7678 (let ((article (or article (gnus-summary-article-number)))
7679 (all-headers (not (not all-headers))) ;Must be t or nil.
7680 gnus-summary-display-article-function)
7681 (and (not pseudo)
7682 (gnus-summary-article-pseudo-p article)
7683 (error "This is a pseudo-article"))
7684 (with-current-buffer gnus-summary-buffer
7685 (if (or (and gnus-single-article-buffer
7686 (or (null gnus-current-article)
7687 (null gnus-article-current)
7688 (null (get-buffer gnus-article-buffer))
7689 (not (eq article (cdr gnus-article-current)))
7690 (not (equal (car gnus-article-current)
7691 gnus-newsgroup-name))
7692 (not (get-buffer gnus-original-article-buffer))))
7693 (and (not gnus-single-article-buffer)
7694 (or (null gnus-current-article)
7695 (not (get-buffer gnus-original-article-buffer))
7696 (not (eq gnus-current-article article))))
7697 force)
7698 ;; The requested article is different from the current article.
7699 (progn
7700 (gnus-summary-display-article article all-headers)
7701 (when (gnus-buffer-live-p gnus-article-buffer)
7702 (with-current-buffer gnus-article-buffer
7703 (if (not gnus-article-decoded-p) ;; a local variable
7704 (mm-disable-multibyte))))
7705 (gnus-article-set-window-start
7706 (cdr (assq article gnus-newsgroup-bookmarks)))
7707 article)
7708 'old))))
7709
7710 (defun gnus-summary-force-verify-and-decrypt ()
7711 "Display buttons for signed/encrypted parts and verify/decrypt them."
7712 (interactive)
7713 (let ((mm-verify-option 'known)
7714 (mm-decrypt-option 'known)
7715 (gnus-article-emulate-mime t)
7716 (gnus-buttonized-mime-types (append (list "multipart/signed"
7717 "multipart/encrypted")
7718 gnus-buttonized-mime-types)))
7719 (gnus-summary-select-article nil 'force)))
7720
7721 (defun gnus-summary-next-article (&optional unread subject backward push)
7722 "Select the next article.
7723 If UNREAD, only unread articles are selected.
7724 If SUBJECT, only articles with SUBJECT are selected.
7725 If BACKWARD, the previous article is selected instead of the next."
7726 (interactive "P")
7727 ;; Make sure we are in the summary buffer.
7728 (unless (eq major-mode 'gnus-summary-mode)
7729 (set-buffer gnus-summary-buffer))
7730 (cond
7731 ;; Is there such an article?
7732 ((and (gnus-summary-search-forward unread subject backward)
7733 (or (gnus-summary-display-article (gnus-summary-article-number))
7734 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7735 (gnus-summary-position-point))
7736 ;; If not, we try the first unread, if that is wanted.
7737 ((and subject
7738 gnus-auto-select-same
7739 (gnus-summary-first-unread-article))
7740 (gnus-summary-position-point)
7741 (gnus-message 6 "Wrapped"))
7742 ;; Try to get next/previous article not displayed in this group.
7743 ((and gnus-auto-extend-newsgroup
7744 (not unread) (not subject))
7745 (gnus-summary-goto-article
7746 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7747 nil (count-lines (point-min) (point))))
7748 ;; Go to next/previous group.
7749 (t
7750 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7751 (gnus-summary-jump-to-group gnus-newsgroup-name))
7752 (let ((cmd (if (featurep 'xemacs)
7753 last-command-char
7754 last-command-event))
7755 (point
7756 (with-current-buffer gnus-group-buffer
7757 (point)))
7758 (current-summary (current-buffer))
7759 (group
7760 (if (eq gnus-keep-same-level 'best)
7761 (gnus-summary-best-group gnus-newsgroup-name)
7762 (gnus-summary-search-group backward gnus-keep-same-level))))
7763 ;; Select next unread newsgroup automagically.
7764 (cond
7765 ((or (not gnus-auto-select-next)
7766 (not cmd))
7767 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7768 ((or (eq gnus-auto-select-next 'quietly)
7769 (and (eq gnus-auto-select-next 'slightly-quietly)
7770 push)
7771 (and (eq gnus-auto-select-next 'almost-quietly)
7772 (gnus-summary-last-article-p)))
7773 ;; Select quietly.
7774 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7775 (gnus-summary-exit)
7776 (gnus-message 7 "No more%s articles (%s)..."
7777 (if unread " unread" "")
7778 (if group (concat "selecting " group)
7779 "exiting"))
7780 (gnus-summary-next-group nil group backward)))
7781 (t
7782 (when (gnus-key-press-event-p last-input-event)
7783 ;; Somehow or other, we may now have selected a different
7784 ;; window. Make point go back to the summary buffer.
7785 (when (eq current-summary (current-buffer))
7786 ;; FIXME: This burps when get-buffer-window returns nil.
7787 (select-window (get-buffer-window current-summary 0)))
7788 (gnus-summary-walk-group-buffer
7789 gnus-newsgroup-name cmd unread backward point))))))))
7790
7791 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7792 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7793 (?\C-p (gnus-group-prev-unread-group 1))))
7794 (cursor-in-echo-area t)
7795 keve key group ended prompt)
7796 (with-current-buffer gnus-group-buffer
7797 (goto-char start)
7798 (setq group
7799 (if (eq gnus-keep-same-level 'best)
7800 (gnus-summary-best-group gnus-newsgroup-name)
7801 (gnus-summary-search-group backward gnus-keep-same-level))))
7802 (while (not ended)
7803 (setq prompt
7804 (format
7805 "No more%s articles%s " (if unread " unread" "")
7806 (if (and group
7807 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7808 (format " (Type %s for %s [%s])"
7809 (single-key-description cmd)
7810 (gnus-group-decoded-name group)
7811 (gnus-group-unread group))
7812 (format " (Type %s to exit %s)"
7813 (single-key-description cmd)
7814 (gnus-group-decoded-name gnus-newsgroup-name)))))
7815 ;; Confirm auto selection.
7816 (setq key (car (setq keve (gnus-read-event-char prompt)))
7817 ended t)
7818 (cond
7819 ((assq key keystrokes)
7820 (let ((obuf (current-buffer)))
7821 (switch-to-buffer gnus-group-buffer)
7822 (when group
7823 (gnus-group-jump-to-group group))
7824 (eval (cadr (assq key keystrokes)))
7825 (setq group (gnus-group-group-name))
7826 (switch-to-buffer obuf))
7827 (setq ended nil))
7828 ((equal key cmd)
7829 (if (or (not group)
7830 (gnus-ephemeral-group-p gnus-newsgroup-name))
7831 (gnus-summary-exit)
7832 (gnus-summary-next-group nil group backward)))
7833 (t
7834 (push (cdr keve) unread-command-events))))))
7835
7836 (defun gnus-summary-next-unread-article ()
7837 "Select unread article after current one."
7838 (interactive)
7839 (gnus-summary-next-article
7840 (or (not (eq gnus-summary-goto-unread 'never))
7841 (gnus-summary-last-article-p (gnus-summary-article-number)))
7842 (and gnus-auto-select-same
7843 (gnus-summary-article-subject))))
7844
7845 (defun gnus-summary-prev-article (&optional unread subject)
7846 "Select the article before the current one.
7847 If UNREAD is non-nil, only unread articles are selected."
7848 (interactive "P")
7849 (gnus-summary-next-article unread subject t))
7850
7851 (defun gnus-summary-prev-unread-article ()
7852 "Select unread article before current one."
7853 (interactive)
7854 (gnus-summary-prev-article
7855 (or (not (eq gnus-summary-goto-unread 'never))
7856 (gnus-summary-first-article-p (gnus-summary-article-number)))
7857 (and gnus-auto-select-same
7858 (gnus-summary-article-subject))))
7859
7860 (defun gnus-summary-next-page (&optional lines circular stop)
7861 "Show next page of the selected article.
7862 If at the end of the current article, select the next article.
7863 LINES says how many lines should be scrolled up.
7864
7865 If CIRCULAR is non-nil, go to the start of the article instead of
7866 selecting the next article when reaching the end of the current
7867 article.
7868
7869 If STOP is non-nil, just stop when reaching the end of the message.
7870
7871 Also see the variable `gnus-article-skip-boring'."
7872 (interactive "P")
7873 (gnus-set-global-variables)
7874 (let ((article (gnus-summary-article-number))
7875 (article-window (get-buffer-window gnus-article-buffer t))
7876 endp)
7877 ;; If the buffer is empty, we have no article.
7878 (unless article
7879 (error "No article to select"))
7880 (gnus-configure-windows 'article)
7881 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7882 (if (and (eq gnus-summary-goto-unread 'never)
7883 (not (gnus-summary-last-article-p article)))
7884 (gnus-summary-next-article)
7885 (gnus-summary-next-unread-article))
7886 (if (or (null gnus-current-article)
7887 (null gnus-article-current)
7888 (/= article (cdr gnus-article-current))
7889 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7890 ;; Selected subject is different from current article's.
7891 (gnus-summary-display-article article)
7892 (when article-window
7893 (gnus-eval-in-buffer-window gnus-article-buffer
7894 (setq endp (or (gnus-article-next-page lines)
7895 (gnus-article-only-boring-p))))
7896 (when endp
7897 (cond ((or stop gnus-summary-stop-at-end-of-message)
7898 (gnus-message 3 "End of message"))
7899 (circular
7900 (gnus-summary-beginning-of-article))
7901 (lines
7902 (gnus-message 3 "End of message"))
7903 ((null lines)
7904 (if (and (eq gnus-summary-goto-unread 'never)
7905 (not (gnus-summary-last-article-p article)))
7906 (gnus-summary-next-article)
7907 (gnus-summary-next-unread-article))))))))
7908 (gnus-summary-recenter)
7909 (gnus-summary-position-point)))
7910
7911 (defun gnus-summary-prev-page (&optional lines move)
7912 "Show previous page of selected article.
7913 Argument LINES specifies lines to be scrolled down.
7914 If MOVE, move to the previous unread article if point is at
7915 the beginning of the buffer."
7916 (interactive "P")
7917 (let ((article (gnus-summary-article-number))
7918 (article-window (get-buffer-window gnus-article-buffer t))
7919 endp)
7920 (gnus-configure-windows 'article)
7921 (if (or (null gnus-current-article)
7922 (null gnus-article-current)
7923 (/= article (cdr gnus-article-current))
7924 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7925 ;; Selected subject is different from current article's.
7926 (gnus-summary-display-article article)
7927 (gnus-summary-recenter)
7928 (when article-window
7929 (gnus-eval-in-buffer-window gnus-article-buffer
7930 (setq endp (gnus-article-prev-page lines)))
7931 (when (and move endp)
7932 (cond (lines
7933 (gnus-message 3 "Beginning of message"))
7934 ((null lines)
7935 (if (and (eq gnus-summary-goto-unread 'never)
7936 (not (gnus-summary-first-article-p article)))
7937 (gnus-summary-prev-article)
7938 (gnus-summary-prev-unread-article))))))))
7939 (gnus-summary-position-point))
7940
7941 (defun gnus-summary-prev-page-or-article (&optional lines)
7942 "Show previous page of selected article.
7943 Argument LINES specifies lines to be scrolled down.
7944 If at the beginning of the article, go to the next article."
7945 (interactive "P")
7946 (gnus-summary-prev-page lines t))
7947
7948 (defun gnus-summary-scroll-up (lines)
7949 "Scroll up (or down) one line current article.
7950 Argument LINES specifies lines to be scrolled up (or down if negative).
7951 If no article is selected, then the current article will be selected first."
7952 (interactive "p")
7953 (gnus-configure-windows 'article)
7954 (gnus-summary-show-thread)
7955 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7956 (gnus-eval-in-buffer-window gnus-article-buffer
7957 (cond ((> lines 0)
7958 (when (gnus-article-next-page lines)
7959 (gnus-message 3 "End of message")))
7960 ((< lines 0)
7961 (gnus-article-prev-page (- lines))))))
7962 (gnus-summary-recenter)
7963 (gnus-summary-position-point))
7964
7965 (defun gnus-summary-scroll-down (lines)
7966 "Scroll down (or up) one line current article.
7967 Argument LINES specifies lines to be scrolled down (or up if negative).
7968 If no article is selected, then the current article will be selected first."
7969 (interactive "p")
7970 (gnus-summary-scroll-up (- lines)))
7971
7972 (defun gnus-summary-next-same-subject ()
7973 "Select next article which has the same subject as current one."
7974 (interactive)
7975 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7976
7977 (defun gnus-summary-prev-same-subject ()
7978 "Select previous article which has the same subject as current one."
7979 (interactive)
7980 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7981
7982 (defun gnus-summary-next-unread-same-subject ()
7983 "Select next unread article which has the same subject as current one."
7984 (interactive)
7985 (gnus-summary-next-article t (gnus-summary-article-subject)))
7986
7987 (defun gnus-summary-prev-unread-same-subject ()
7988 "Select previous unread article which has the same subject as current one."
7989 (interactive)
7990 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7991
7992 (defun gnus-summary-first-unread-article ()
7993 "Select the first unread article.
7994 Return nil if there are no unread articles."
7995 (interactive)
7996 (prog1
7997 (when (gnus-summary-first-subject t)
7998 (gnus-summary-show-thread)
7999 (gnus-summary-first-subject t)
8000 (gnus-summary-display-article (gnus-summary-article-number)))
8001 (gnus-summary-position-point)))
8002
8003 (defun gnus-summary-first-unread-subject ()
8004 "Place the point on the subject line of the first unread article.
8005 Return nil if there are no unread articles."
8006 (interactive)
8007 (prog1
8008 (when (gnus-summary-first-subject t)
8009 (gnus-summary-show-thread)
8010 (gnus-summary-first-subject t))
8011 (gnus-summary-position-point)))
8012
8013 (defun gnus-summary-first-unseen-subject ()
8014 "Place the point on the subject line of the first unseen article.
8015 Return nil if there are no unseen articles."
8016 (interactive)
8017 (prog1
8018 (when (gnus-summary-first-subject nil nil t)
8019 (gnus-summary-show-thread)
8020 (gnus-summary-first-subject nil nil t))
8021 (gnus-summary-position-point)))
8022
8023 (defun gnus-summary-first-unseen-or-unread-subject ()
8024 "Place the point on the subject line of the first unseen and unread article.
8025 If all article have been seen, on the subject line of the first unread
8026 article."
8027 (interactive)
8028 (prog1
8029 (unless (when (gnus-summary-first-subject nil nil t)
8030 (gnus-summary-show-thread)
8031 (gnus-summary-first-subject nil nil t))
8032 (when (gnus-summary-first-subject t)
8033 (gnus-summary-show-thread)
8034 (gnus-summary-first-subject t)))
8035 (gnus-summary-position-point)))
8036
8037 (defun gnus-summary-first-article ()
8038 "Select the first article.
8039 Return nil if there are no articles."
8040 (interactive)
8041 (prog1
8042 (when (gnus-summary-first-subject)
8043 (gnus-summary-show-thread)
8044 (gnus-summary-first-subject)
8045 (gnus-summary-display-article (gnus-summary-article-number)))
8046 (gnus-summary-position-point)))
8047
8048 (defun gnus-summary-best-unread-article (&optional arg)
8049 "Select the unread article with the highest score.
8050 If given a prefix argument, select the next unread article that has a
8051 score higher than the default score."
8052 (interactive "P")
8053 (let ((article (if arg
8054 (gnus-summary-better-unread-subject)
8055 (gnus-summary-best-unread-subject))))
8056 (if article
8057 (gnus-summary-goto-article article)
8058 (error "No unread articles"))))
8059
8060 (defun gnus-summary-best-unread-subject ()
8061 "Select the unread subject with the highest score."
8062 (interactive)
8063 (let ((best -1000000)
8064 (data gnus-newsgroup-data)
8065 article score)
8066 (while data
8067 (and (gnus-data-unread-p (car data))
8068 (> (setq score
8069 (gnus-summary-article-score (gnus-data-number (car data))))
8070 best)
8071 (setq best score
8072 article (gnus-data-number (car data))))
8073 (setq data (cdr data)))
8074 (when article
8075 (gnus-summary-goto-subject article))
8076 (gnus-summary-position-point)
8077 article))
8078
8079 (defun gnus-summary-better-unread-subject ()
8080 "Select the first unread subject that has a score over the default score."
8081 (interactive)
8082 (let ((data gnus-newsgroup-data)
8083 article score)
8084 (while (and (setq article (gnus-data-number (car data)))
8085 (or (gnus-data-read-p (car data))
8086 (not (> (gnus-summary-article-score article)
8087 gnus-summary-default-score))))
8088 (setq data (cdr data)))
8089 (when article
8090 (gnus-summary-goto-subject article))
8091 (gnus-summary-position-point)
8092 article))
8093
8094 (defun gnus-summary-last-subject ()
8095 "Go to the last displayed subject line in the group."
8096 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8097 (when article
8098 (gnus-summary-goto-subject article))))
8099
8100 (defun gnus-summary-goto-article (article &optional all-headers force)
8101 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8102 If ALL-HEADERS is non-nil, no header lines are hidden.
8103 If FORCE, go to the article even if it isn't displayed. If FORCE
8104 is a number, it is the line the article is to be displayed on."
8105 (interactive
8106 (list
8107 (gnus-completing-read
8108 "Article number or Message-ID"
8109 (mapcar 'int-to-string gnus-newsgroup-limit))
8110 current-prefix-arg
8111 t))
8112 (prog1
8113 (if (and (stringp article)
8114 (string-match "@\\|%40" article))
8115 (gnus-summary-refer-article article)
8116 (when (stringp article)
8117 (setq article (string-to-number article)))
8118 (if (gnus-summary-goto-subject article force)
8119 (gnus-summary-display-article article all-headers)
8120 (gnus-message 4 "Couldn't go to article %s" article) nil))
8121 (gnus-summary-position-point)))
8122
8123 (defun gnus-summary-goto-last-article ()
8124 "Go to the previously read article."
8125 (interactive)
8126 (prog1
8127 (when gnus-last-article
8128 (gnus-summary-goto-article gnus-last-article nil t))
8129 (gnus-summary-position-point)))
8130
8131 (defun gnus-summary-pop-article (number)
8132 "Pop one article off the history and go to the previous.
8133 NUMBER articles will be popped off."
8134 (interactive "p")
8135 (let (to)
8136 (setq gnus-newsgroup-history
8137 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8138 (if to
8139 (gnus-summary-goto-article (car to) nil t)
8140 (error "Article history empty")))
8141 (gnus-summary-position-point))
8142
8143 ;; Summary commands and functions for limiting the summary buffer.
8144
8145 (defun gnus-summary-limit-to-articles (n)
8146 "Limit the summary buffer to the next N articles.
8147 If not given a prefix, use the process marked articles instead."
8148 (interactive "P")
8149 (prog1
8150 (let ((articles (gnus-summary-work-articles n)))
8151 (setq gnus-newsgroup-processable nil)
8152 (gnus-summary-limit articles))
8153 (gnus-summary-position-point)))
8154
8155 (defun gnus-summary-pop-limit (&optional total)
8156 "Restore the previous limit.
8157 If given a prefix, remove all limits."
8158 (interactive "P")
8159 (when total
8160 (setq gnus-newsgroup-limits
8161 (list (mapcar (lambda (h) (mail-header-number h))
8162 gnus-newsgroup-headers))))
8163 (unless gnus-newsgroup-limits
8164 (error "No limit to pop"))
8165 (prog1
8166 (gnus-summary-limit nil 'pop)
8167 (gnus-summary-position-point)))
8168
8169 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8170 "Limit the summary buffer to articles that have subjects that match a regexp.
8171 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8172 (interactive
8173 (list (read-string (if current-prefix-arg
8174 "Exclude subject (regexp): "
8175 "Limit to subject (regexp): "))
8176 nil current-prefix-arg))
8177 (unless header
8178 (setq header "subject"))
8179 (when (not (equal "" subject))
8180 (prog1
8181 (let ((articles (gnus-summary-find-matching
8182 (or header "subject") subject 'all nil nil
8183 not-matching)))
8184 (unless articles
8185 (error "Found no matches for \"%s\"" subject))
8186 (gnus-summary-limit articles))
8187 (gnus-summary-position-point))))
8188
8189 (defun gnus-summary-limit-to-author (from &optional not-matching)
8190 "Limit the summary buffer to articles that have authors that match a regexp.
8191 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8192 (interactive
8193 (list (let* ((header (gnus-summary-article-header))
8194 (default (and header (car (mail-header-parse-address
8195 (mail-header-from header))))))
8196 (read-string (concat (if current-prefix-arg
8197 "Exclude author (regexp"
8198 "Limit to author (regexp")
8199 (if default
8200 (concat ", default \"" default "\"): ")
8201 "): "))
8202 nil nil
8203 default))
8204 current-prefix-arg))
8205 (gnus-summary-limit-to-subject from "from" not-matching))
8206
8207 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8208 "Limit the summary buffer to articles with the given RECIPIENT.
8209
8210 If NOT-MATCHING, exclude RECIPIENT.
8211
8212 To and Cc headers are checked. You need to include them in
8213 `nnmail-extra-headers'."
8214 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8215 (interactive
8216 (list (read-string (format "%s recipient (regexp): "
8217 (if current-prefix-arg "Exclude" "Limit to")))
8218 current-prefix-arg))
8219 (when (not (equal "" recipient))
8220 (prog1 (let* ((to
8221 (if (memq 'To nnmail-extra-headers)
8222 (gnus-summary-find-matching
8223 (cons 'extra 'To) recipient 'all nil nil
8224 not-matching)
8225 (gnus-message
8226 1 "`To' isn't present in `nnmail-extra-headers'")
8227 (sit-for 1)
8228 nil))
8229 (cc
8230 (if (memq 'Cc nnmail-extra-headers)
8231 (gnus-summary-find-matching
8232 (cons 'extra 'Cc) recipient 'all nil nil
8233 not-matching)
8234 (gnus-message
8235 1 "`Cc' isn't present in `nnmail-extra-headers'")
8236 (sit-for 1)
8237 nil))
8238 (articles
8239 (if not-matching
8240 ;; We need the numbers that are in both lists:
8241 (mapcar (lambda (a)
8242 (and (memq a to) a))
8243 cc)
8244 (nconc to cc))))
8245 (unless articles
8246 (error "Found no matches for \"%s\"" recipient))
8247 (gnus-summary-limit articles))
8248 (gnus-summary-position-point))))
8249
8250 (defun gnus-summary-limit-to-address (address &optional not-matching)
8251 "Limit the summary buffer to articles with the given ADDRESS.
8252
8253 If NOT-MATCHING, exclude ADDRESS.
8254
8255 To, Cc and From headers are checked. You need to include `To' and `Cc'
8256 in `nnmail-extra-headers'."
8257 (interactive
8258 (list (read-string (format "%s address (regexp): "
8259 (if current-prefix-arg "Exclude" "Limit to")))
8260 current-prefix-arg))
8261 (when (not (equal "" address))
8262 (prog1 (let* ((to
8263 (if (memq 'To nnmail-extra-headers)
8264 (gnus-summary-find-matching
8265 (cons 'extra 'To) address 'all nil nil
8266 not-matching)
8267 (gnus-message
8268 1 "`To' isn't present in `nnmail-extra-headers'")
8269 (sit-for 1)
8270 t))
8271 (cc
8272 (if (memq 'Cc nnmail-extra-headers)
8273 (gnus-summary-find-matching
8274 (cons 'extra 'Cc) address 'all nil nil
8275 not-matching)
8276 (gnus-message
8277 1 "`Cc' isn't present in `nnmail-extra-headers'")
8278 (sit-for 1)
8279 t))
8280 (from
8281 (gnus-summary-find-matching "from" address
8282 'all nil nil not-matching))
8283 (articles
8284 (if not-matching
8285 ;; We need the numbers that are in all lists:
8286 (if (eq cc t)
8287 (if (eq to t)
8288 from
8289 (mapcar (lambda (a) (car (memq a from))) to))
8290 (if (eq to t)
8291 (mapcar (lambda (a) (car (memq a from))) cc)
8292 (mapcar (lambda (a) (car (memq a from)))
8293 (mapcar (lambda (a) (car (memq a to)))
8294 cc))))
8295 (nconc (if (eq to t) nil to)
8296 (if (eq cc t) nil cc)
8297 from))))
8298 (unless articles
8299 (error "Found no matches for \"%s\"" address))
8300 (gnus-summary-limit articles))
8301 (gnus-summary-position-point))))
8302
8303 (defun gnus-summary-limit-strange-charsets-predicate (header)
8304 (when (fboundp 'char-charset)
8305 (let ((string (concat (mail-header-subject header)
8306 (mail-header-from header)))
8307 charset found)
8308 (dotimes (i (1- (length string)))
8309 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8310 (when (string-match "unicode\\|big\\|japanese" charset)
8311 (setq found t)))
8312 found)))
8313
8314 (defun gnus-summary-limit-to-predicate (predicate)
8315 "Limit to articles where PREDICATE returns non-nil.
8316 PREDICATE will be called with the header structures of the
8317 articles."
8318 (let ((articles nil)
8319 (case-fold-search t))
8320 (dolist (header gnus-newsgroup-headers)
8321 (when (funcall predicate header)
8322 (push (mail-header-number header) articles)))
8323 (gnus-summary-limit (nreverse articles))))
8324
8325 (defun gnus-summary-limit-to-age (age &optional younger-p)
8326 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8327 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8328 articles that are younger than AGE days."
8329 (interactive
8330 (let ((younger current-prefix-arg)
8331 (days-got nil)
8332 days)
8333 (while (not days-got)
8334 (setq days (if younger
8335 (read-string "Limit to articles younger than (in days, older when negative): ")
8336 (read-string
8337 "Limit to articles older than (in days, younger when negative): ")))
8338 (when (> (length days) 0)
8339 (setq days (read days)))
8340 (if (numberp days)
8341 (progn
8342 (setq days-got t)
8343 (when (< days 0)
8344 (setq younger (not younger))
8345 (setq days (* days -1))))
8346 (message "Please enter a number.")
8347 (sleep-for 1)))
8348 (list days younger)))
8349 (prog1
8350 (let ((data gnus-newsgroup-data)
8351 (cutoff (days-to-time age))
8352 articles d date is-younger)
8353 (while (setq d (pop data))
8354 (when (and (vectorp (gnus-data-header d))
8355 (setq date (mail-header-date (gnus-data-header d))))
8356 (setq is-younger (time-less-p
8357 (time-since (gnus-date-get-time date))
8358 cutoff))
8359 (when (if younger-p
8360 is-younger
8361 (not is-younger))
8362 (push (gnus-data-number d) articles))))
8363 (gnus-summary-limit (nreverse articles)))
8364 (gnus-summary-position-point)))
8365
8366 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8367 "Limit the summary buffer to articles that match an 'extra' header."
8368 (interactive
8369 (let ((header
8370 (intern
8371 (gnus-completing-read
8372 (if current-prefix-arg
8373 "Exclude extra header"
8374 "Limit extra header")
8375 (mapcar 'symbol-name gnus-extra-headers)
8376 t nil nil
8377 (symbol-name (car gnus-extra-headers))))))
8378 (list header
8379 (read-string (format "%s header %s (regexp): "
8380 (if current-prefix-arg "Exclude" "Limit to")
8381 header))
8382 current-prefix-arg)))
8383 (when (not (equal "" regexp))
8384 (prog1
8385 (let ((articles (gnus-summary-find-matching
8386 (cons 'extra header) regexp 'all nil nil
8387 not-matching)))
8388 (unless articles
8389 (error "Found no matches for \"%s\"" regexp))
8390 (gnus-summary-limit articles))
8391 (gnus-summary-position-point))))
8392
8393 (defun gnus-summary-limit-to-display-predicate ()
8394 "Limit the summary buffer to the predicated in the `display' group parameter."
8395 (interactive)
8396 (unless gnus-newsgroup-display
8397 (error "There is no `display' group parameter"))
8398 (let (articles)
8399 (dolist (gnus-number gnus-newsgroup-articles)
8400 (when (funcall gnus-newsgroup-display)
8401 (push gnus-number articles)))
8402 (gnus-summary-limit articles))
8403 (gnus-summary-position-point))
8404
8405 (defun gnus-summary-limit-to-unread (&optional all)
8406 "Limit the summary buffer to articles that are not marked as read.
8407 If ALL is non-nil, limit strictly to unread articles."
8408 (interactive "P")
8409 (if all
8410 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8411 (gnus-summary-limit-to-marks
8412 ;; Concat all the marks that say that an article is read and have
8413 ;; those removed.
8414 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8415 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8416 gnus-low-score-mark gnus-expirable-mark
8417 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8418 gnus-duplicate-mark)
8419 'reverse)))
8420
8421 (defun gnus-summary-limit-to-headers (match &optional reverse)
8422 "Limit the summary buffer to articles that have headers that match MATCH.
8423 If REVERSE (the prefix), limit to articles that don't match."
8424 (interactive "sMatch headers (regexp): \nP")
8425 (gnus-summary-limit-to-bodies match reverse t))
8426
8427 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8428 "Limit the summary buffer to articles that have bodies that match MATCH.
8429 If REVERSE (the prefix), limit to articles that don't match."
8430 (interactive "sMatch body (regexp): \nP")
8431 (let ((articles nil)
8432 (gnus-select-article-hook nil) ;Disable hook.
8433 (gnus-article-prepare-hook nil)
8434 (gnus-use-article-prefetch nil)
8435 (gnus-keep-backlog nil)
8436 (gnus-break-pages nil)
8437 (gnus-summary-display-arrow nil)
8438 (gnus-updated-mode-lines nil)
8439 (gnus-auto-center-summary nil)
8440 (gnus-display-mime-function nil))
8441 (dolist (data gnus-newsgroup-data)
8442 (let (gnus-mark-article-hook)
8443 (gnus-summary-select-article t t nil (gnus-data-number data)))
8444 (with-current-buffer gnus-article-buffer
8445 (article-goto-body)
8446 (let* ((case-fold-search t)
8447 (found (if headersp
8448 (re-search-backward match nil t)
8449 (re-search-forward match nil t))))
8450 (when (or (and found
8451 (not reverse))
8452 (and (not found)
8453 reverse))
8454 (push (gnus-data-number data) articles)))))
8455 (if (not articles)
8456 (message "No messages matched")
8457 (gnus-summary-limit articles)))
8458 (gnus-summary-position-point))
8459
8460 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8461 "Limit the summary buffer to articles that aren't part on any thread.
8462 If THREADSP (the prefix), limit to articles that are in threads."
8463 (interactive "P")
8464 (let ((articles nil)
8465 thread-articles
8466 threads)
8467 (dolist (thread gnus-newsgroup-threads)
8468 (if (stringp (car thread))
8469 (dolist (thread (cdr thread))
8470 (push thread threads))
8471 (push thread threads)))
8472 (dolist (thread threads)
8473 (setq thread-articles (gnus-articles-in-thread thread))
8474 (when (or (and threadsp
8475 (> (length thread-articles) 1))
8476 (and (not threadsp)
8477 (= (length thread-articles) 1)))
8478 (setq articles (nconc thread-articles articles))))
8479 (if (not articles)
8480 (message "No messages matched")
8481 (gnus-summary-limit articles))
8482 (gnus-summary-position-point)))
8483
8484 (defun gnus-summary-limit-to-replied (&optional unreplied)
8485 "Limit the summary buffer to replied articles.
8486 If UNREPLIED (the prefix), limit to unreplied articles."
8487 (interactive "P")
8488 (if unreplied
8489 (gnus-summary-limit
8490 (gnus-set-difference gnus-newsgroup-articles
8491 gnus-newsgroup-replied))
8492 (gnus-summary-limit gnus-newsgroup-replied))
8493 (gnus-summary-position-point))
8494
8495 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8496 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8497 If REVERSE, limit the summary buffer to articles that are marked
8498 with MARKS. MARKS can either be a string of marks or a list of marks.
8499 Returns how many articles were removed."
8500 (interactive "sMarks: ")
8501 (gnus-summary-limit-to-marks marks t))
8502
8503 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8504 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8505 If REVERSE (the prefix), limit the summary buffer to articles that are
8506 not marked with MARKS. MARKS can either be a string of marks or a
8507 list of marks.
8508 Returns how many articles were removed."
8509 (interactive "sMarks: \nP")
8510 (prog1
8511 (let ((data gnus-newsgroup-data)
8512 (marks (if (listp marks) marks
8513 (append marks nil))) ; Transform to list.
8514 articles)
8515 (while data
8516 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8517 (memq (gnus-data-mark (car data)) marks))
8518 (push (gnus-data-number (car data)) articles))
8519 (setq data (cdr data)))
8520 (gnus-summary-limit articles))
8521 (gnus-summary-position-point)))
8522
8523 (defun gnus-summary-limit-to-score (score)
8524 "Limit to articles with score at or above SCORE."
8525 (interactive "NLimit to articles with score of at least: ")
8526 (let ((data gnus-newsgroup-data)
8527 articles)
8528 (while data
8529 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8530 score)
8531 (push (gnus-data-number (car data)) articles))
8532 (setq data (cdr data)))
8533 (prog1
8534 (gnus-summary-limit articles)
8535 (gnus-summary-position-point))))
8536
8537 (defun gnus-summary-limit-to-unseen ()
8538 "Limit to unseen articles."
8539 (interactive)
8540 (prog1
8541 (gnus-summary-limit gnus-newsgroup-unseen)
8542 (gnus-summary-position-point)))
8543
8544 (defun gnus-summary-limit-include-thread (id)
8545 "Display all the hidden articles that is in the thread with ID in it.
8546 When called interactively, ID is the Message-ID of the current
8547 article."
8548 (interactive (list (mail-header-id (gnus-summary-article-header))))
8549 (let ((articles (gnus-articles-in-thread
8550 (gnus-id-to-thread (gnus-root-id id))))
8551 ;;we REALLY want the whole thread---this prevents cut-threads
8552 ;;from removing the thread we want to include.
8553 (gnus-fetch-old-headers nil)
8554 (gnus-build-sparse-threads nil))
8555 (prog1
8556 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8557 (gnus-summary-limit-include-matching-articles
8558 "subject"
8559 (regexp-quote (gnus-simplify-subject-re
8560 (mail-header-subject (gnus-id-to-header id)))))
8561 (gnus-summary-position-point))))
8562
8563 (defun gnus-summary-limit-include-matching-articles (header regexp)
8564 "Display all the hidden articles that have HEADERs that match REGEXP."
8565 (interactive (list (read-string "Match on header: ")
8566 (read-string "Regexp: ")))
8567 (let ((articles (gnus-find-matching-articles header regexp)))
8568 (prog1
8569 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8570 (gnus-summary-position-point))))
8571
8572 (defun gnus-summary-insert-dormant-articles ()
8573 "Insert all the dormant articles for this group into the current buffer."
8574 (interactive)
8575 (let ((gnus-verbose (max 6 gnus-verbose)))
8576 (if (not gnus-newsgroup-dormant)
8577 (gnus-message 3 "No dormant articles for this group")
8578 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8579
8580 (defun gnus-summary-insert-ticked-articles ()
8581 "Insert ticked articles for this group into the current buffer."
8582 (interactive)
8583 (let ((gnus-verbose (max 6 gnus-verbose)))
8584 (if (not gnus-newsgroup-marked)
8585 (gnus-message 3 "No ticked articles for this group")
8586 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8587
8588 (defun gnus-summary-limit-include-dormant ()
8589 "Display all the hidden articles that are marked as dormant.
8590 Note that this command only works on a subset of the articles currently
8591 fetched for this group."
8592 (interactive)
8593 (unless gnus-newsgroup-dormant
8594 (error "There are no dormant articles in this group"))
8595 (prog1
8596 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8597 (gnus-summary-position-point)))
8598
8599 (defun gnus-summary-include-articles (articles)
8600 "Fetch the headers for ARTICLES and then display the summary lines."
8601 (let ((gnus-inhibit-demon t)
8602 (gnus-agent nil)
8603 (gnus-read-all-available-headers t))
8604 (setq gnus-newsgroup-headers
8605 (gnus-merge
8606 'list gnus-newsgroup-headers
8607 (gnus-fetch-headers articles nil t)
8608 'gnus-article-sort-by-number))
8609 (setq gnus-newsgroup-articles
8610 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8611 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8612
8613 (defun gnus-summary-limit-exclude-dormant ()
8614 "Hide all dormant articles."
8615 (interactive)
8616 (prog1
8617 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8618 (gnus-summary-position-point)))
8619
8620 (defun gnus-summary-limit-exclude-childless-dormant ()
8621 "Hide all dormant articles that have no children."
8622 (interactive)
8623 (let ((data (gnus-data-list t))
8624 articles d children)
8625 ;; Find all articles that are either not dormant or have
8626 ;; children.
8627 (while (setq d (pop data))
8628 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8629 (and (setq children
8630 (gnus-article-children (gnus-data-number d)))
8631 (let (found)
8632 (while children
8633 (when (memq (car children) articles)
8634 (setq children nil
8635 found t))
8636 (pop children))
8637 found)))
8638 (push (gnus-data-number d) articles)))
8639 ;; Do the limiting.
8640 (prog1
8641 (gnus-summary-limit articles)
8642 (gnus-summary-position-point))))
8643
8644 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8645 "Mark all unread excluded articles as read.
8646 If ALL, mark even excluded ticked and dormants as read."
8647 (interactive "P")
8648 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8649 (let ((articles (gnus-sorted-ndifference
8650 (sort
8651 (mapcar (lambda (h) (mail-header-number h))
8652 gnus-newsgroup-headers)
8653 '<)
8654 gnus-newsgroup-limit))
8655 article)
8656 (setq gnus-newsgroup-unreads
8657 (gnus-sorted-intersection gnus-newsgroup-unreads
8658 gnus-newsgroup-limit))
8659 (if all
8660 (setq gnus-newsgroup-dormant nil
8661 gnus-newsgroup-marked nil
8662 gnus-newsgroup-reads
8663 (nconc
8664 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8665 gnus-newsgroup-reads))
8666 (while (setq article (pop articles))
8667 (unless (or (memq article gnus-newsgroup-dormant)
8668 (memq article gnus-newsgroup-marked))
8669 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8670
8671 (defun gnus-summary-limit (articles &optional pop)
8672 (if pop
8673 ;; We pop the previous limit off the stack and use that.
8674 (setq articles (car gnus-newsgroup-limits)
8675 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8676 ;; We use the new limit, so we push the old limit on the stack.
8677 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8678 ;; Set the limit.
8679 (setq gnus-newsgroup-limit articles)
8680 (let ((total (length gnus-newsgroup-data))
8681 (data (gnus-data-find-list (gnus-summary-article-number)))
8682 (gnus-summary-mark-below nil) ; Inhibit this.
8683 found)
8684 ;; This will do all the work of generating the new summary buffer
8685 ;; according to the new limit.
8686 (gnus-summary-prepare)
8687 ;; Hide any threads, possibly.
8688 (gnus-summary-maybe-hide-threads)
8689 ;; Try to return to the article you were at, or one in the
8690 ;; neighborhood.
8691 (when data
8692 ;; We try to find some article after the current one.
8693 (while data
8694 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8695 (setq data nil
8696 found t))
8697 (setq data (cdr data))))
8698 (unless found
8699 ;; If there is no data, that means that we were after the last
8700 ;; article. The same goes when we can't find any articles
8701 ;; after the current one.
8702 (goto-char (point-max))
8703 (gnus-summary-find-prev))
8704 (gnus-set-mode-line 'summary)
8705 ;; We return how many articles were removed from the summary
8706 ;; buffer as a result of the new limit.
8707 (- total (length gnus-newsgroup-data))))
8708
8709 (defsubst gnus-invisible-cut-children (threads)
8710 (let ((num 0))
8711 (while threads
8712 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8713 (incf num))
8714 (pop threads))
8715 (< num 2)))
8716
8717 (defsubst gnus-cut-thread (thread)
8718 "Go forwards in the thread until we find an article that we want to display."
8719 (when (or (eq gnus-fetch-old-headers 'some)
8720 (eq gnus-fetch-old-headers 'invisible)
8721 (numberp gnus-fetch-old-headers)
8722 (eq gnus-build-sparse-threads 'some)
8723 (eq gnus-build-sparse-threads 'more))
8724 ;; Deal with old-fetched headers and sparse threads.
8725 (while (and
8726 thread
8727 (or
8728 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8729 (gnus-summary-article-ancient-p
8730 (mail-header-number (car thread))))
8731 (if (or (<= (length (cdr thread)) 1)
8732 (eq gnus-fetch-old-headers 'invisible))
8733 (setq gnus-newsgroup-limit
8734 (delq (mail-header-number (car thread))
8735 gnus-newsgroup-limit)
8736 thread (cadr thread))
8737 (when (gnus-invisible-cut-children (cdr thread))
8738 (let ((th (cdr thread)))
8739 (while th
8740 (if (memq (mail-header-number (caar th))
8741 gnus-newsgroup-limit)
8742 (setq thread (car th)
8743 th nil)
8744 (setq th (cdr th))))))))))
8745 thread)
8746
8747 (defun gnus-cut-threads (threads)
8748 "Cut off all uninteresting articles from the beginning of THREADS."
8749 (when (or (eq gnus-fetch-old-headers 'some)
8750 (eq gnus-fetch-old-headers 'invisible)
8751 (numberp gnus-fetch-old-headers)
8752 (eq gnus-build-sparse-threads 'some)
8753 (eq gnus-build-sparse-threads 'more))
8754 (let ((th threads))
8755 (while th
8756 (setcar th (gnus-cut-thread (car th)))
8757 (setq th (cdr th)))))
8758 ;; Remove nixed out threads.
8759 (delq nil threads))
8760
8761 (defun gnus-summary-initial-limit (&optional show-if-empty)
8762 "Figure out what the initial limit is supposed to be on group entry.
8763 This entails weeding out unwanted dormants, low-scored articles,
8764 fetch-old-headers verbiage, and so on."
8765 ;; Most groups have nothing to remove.
8766 (unless (or gnus-inhibit-limiting
8767 (and (null gnus-newsgroup-dormant)
8768 (eq gnus-newsgroup-display 'gnus-not-ignore)
8769 (not (eq gnus-fetch-old-headers 'some))
8770 (not (numberp gnus-fetch-old-headers))
8771 (not (eq gnus-fetch-old-headers 'invisible))
8772 (null gnus-summary-expunge-below)
8773 (not (eq gnus-build-sparse-threads 'some))
8774 (not (eq gnus-build-sparse-threads 'more))
8775 (null gnus-thread-expunge-below)))
8776 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8777 (setq gnus-newsgroup-limit nil)
8778 (mapatoms
8779 (lambda (node)
8780 (unless (car (symbol-value node))
8781 ;; These threads have no parents -- they are roots.
8782 (let ((nodes (cdr (symbol-value node)))
8783 thread)
8784 (while nodes
8785 (if (and gnus-thread-expunge-below
8786 (< (gnus-thread-total-score (car nodes))
8787 gnus-thread-expunge-below))
8788 (gnus-expunge-thread (pop nodes))
8789 (setq thread (pop nodes))
8790 (gnus-summary-limit-children thread))))))
8791 gnus-newsgroup-dependencies)
8792 ;; If this limitation resulted in an empty group, we might
8793 ;; pop the previous limit and use it instead.
8794 (when (and (not gnus-newsgroup-limit)
8795 show-if-empty)
8796 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8797 gnus-newsgroup-limit))
8798
8799 (defun gnus-summary-limit-children (thread)
8800 "Return 1 if this subthread is visible and 0 if it is not."
8801 ;; First we get the number of visible children to this thread. This
8802 ;; is done by recursing down the thread using this function, so this
8803 ;; will really go down to a leaf article first, before slowly
8804 ;; working its way up towards the root.
8805 (when thread
8806 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8807 (children
8808 (if (cdr thread)
8809 (apply '+ (mapcar 'gnus-summary-limit-children
8810 (cdr thread)))
8811 0))
8812 (number (mail-header-number (car thread)))
8813 score)
8814 (if (and
8815 (not (memq number gnus-newsgroup-marked))
8816 (or
8817 ;; If this article is dormant and has absolutely no visible
8818 ;; children, then this article isn't visible.
8819 (and (memq number gnus-newsgroup-dormant)
8820 (zerop children))
8821 ;; If this is "fetch-old-headered" and there is no
8822 ;; visible children, then we don't want this article.
8823 (and (or (eq gnus-fetch-old-headers 'some)
8824 (numberp gnus-fetch-old-headers))
8825 (gnus-summary-article-ancient-p number)
8826 (zerop children))
8827 ;; If this is "fetch-old-headered" and `invisible', then
8828 ;; we don't want this article.
8829 (and (eq gnus-fetch-old-headers 'invisible)
8830 (gnus-summary-article-ancient-p number))
8831 ;; If this is a sparsely inserted article with no children,
8832 ;; we don't want it.
8833 (and (eq gnus-build-sparse-threads 'some)
8834 (gnus-summary-article-sparse-p number)
8835 (zerop children))
8836 ;; If we use expunging, and this article is really
8837 ;; low-scored, then we don't want this article.
8838 (when (and gnus-summary-expunge-below
8839 (< (setq score
8840 (or (cdr (assq number gnus-newsgroup-scored))
8841 gnus-summary-default-score))
8842 gnus-summary-expunge-below))
8843 ;; We increase the expunge-tally here, but that has
8844 ;; nothing to do with the limits, really.
8845 (incf gnus-newsgroup-expunged-tally)
8846 ;; We also mark as read here, if that's wanted.
8847 (when (and gnus-summary-mark-below
8848 (< score gnus-summary-mark-below))
8849 (setq gnus-newsgroup-unreads
8850 (delq number gnus-newsgroup-unreads))
8851 (if gnus-newsgroup-auto-expire
8852 (push number gnus-newsgroup-expirable)
8853 (push (cons number gnus-low-score-mark)
8854 gnus-newsgroup-reads)))
8855 t)
8856 ;; Do the `display' group parameter.
8857 (and gnus-newsgroup-display
8858 (let ((gnus-number number))
8859 (not (funcall gnus-newsgroup-display))))))
8860 ;; Nope, invisible article.
8861 0
8862 ;; Ok, this article is to be visible, so we add it to the limit
8863 ;; and return 1.
8864 (push number gnus-newsgroup-limit)
8865 1))))
8866
8867 (defun gnus-expunge-thread (thread)
8868 "Mark all articles in THREAD as read."
8869 (let* ((number (mail-header-number (car thread))))
8870 (incf gnus-newsgroup-expunged-tally)
8871 ;; We also mark as read here, if that's wanted.
8872 (setq gnus-newsgroup-unreads
8873 (delq number gnus-newsgroup-unreads))
8874 (if gnus-newsgroup-auto-expire
8875 (push number gnus-newsgroup-expirable)
8876 (push (cons number gnus-low-score-mark)
8877 gnus-newsgroup-reads)))
8878 ;; Go recursively through all subthreads.
8879 (mapcar 'gnus-expunge-thread (cdr thread)))
8880
8881 ;; Summary article oriented commands
8882
8883 (defun gnus-summary-refer-parent-article (n)
8884 "Refer parent article N times.
8885 If N is negative, go to ancestor -N instead.
8886 The difference between N and the number of articles fetched is returned."
8887 (interactive "p")
8888 (let ((skip 1)
8889 error header ref)
8890 (when (not (natnump n))
8891 (setq skip (abs n)
8892 n 1))
8893 (while (and (> n 0)
8894 (not error))
8895 (setq header (gnus-summary-article-header))
8896 (if (and (eq (mail-header-number header)
8897 (cdr gnus-article-current))
8898 (equal gnus-newsgroup-name
8899 (car gnus-article-current)))
8900 ;; If we try to find the parent of the currently
8901 ;; displayed article, then we take a look at the actual
8902 ;; References header, since this is slightly more
8903 ;; reliable than the References field we got from the
8904 ;; server.
8905 (with-current-buffer gnus-original-article-buffer
8906 (nnheader-narrow-to-headers)
8907 (unless (setq ref (message-fetch-field "references"))
8908 (when (setq ref (message-fetch-field "in-reply-to"))
8909 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8910 (widen))
8911 (setq ref
8912 ;; It's not the current article, so we take a bet on
8913 ;; the value we got from the server.
8914 (mail-header-references header)))
8915 (if (and ref
8916 (not (equal ref "")))
8917 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8918 (gnus-message 1 "Couldn't find parent"))
8919 (gnus-message 1 "No references in article %d"
8920 (gnus-summary-article-number))
8921 (setq error t))
8922 (decf n))
8923 (gnus-summary-position-point)
8924 n))
8925
8926 (defun gnus-summary-refer-references ()
8927 "Fetch all articles mentioned in the References header.
8928 Return the number of articles fetched."
8929 (interactive)
8930 (let ((ref (mail-header-references (gnus-summary-article-header)))
8931 (current (gnus-summary-article-number))
8932 (n 0))
8933 (if (or (not ref)
8934 (equal ref ""))
8935 (error "No References in the current article")
8936 ;; For each Message-ID in the References header...
8937 (while (string-match "<[^>]*>" ref)
8938 (incf n)
8939 ;; ... fetch that article.
8940 (gnus-summary-refer-article
8941 (prog1 (match-string 0 ref)
8942 (setq ref (substring ref (match-end 0))))))
8943 (gnus-summary-goto-subject current)
8944 (gnus-summary-position-point)
8945 n)))
8946
8947 (defun gnus-delete-duplicate-headers (headers)
8948 ;; First remove leading duplicates.
8949 (while (and (> (length headers) 1)
8950 (= (mail-header-number (car headers))
8951 (mail-header-number (cadr headers))))
8952 (pop headers))
8953 ;; Then the rest.
8954 (let ((result headers))
8955 (while (> (length headers) 1)
8956 (if (= (mail-header-number (car headers))
8957 (mail-header-number (cadr headers)))
8958 (setcdr headers (cddr headers))
8959 (pop headers)))
8960 result))
8961
8962 (defun gnus-summary-refer-thread (&optional limit)
8963 "Fetch all articles in the current thread. For backends that
8964 know how to search for threads (currently only 'nnimap) a
8965 non-numeric prefix arg will use nnir to search the entire
8966 server; without a prefix arg only the current group is
8967 searched. If the variable `gnus-refer-thread-use-nnir' is
8968 non-nil the prefix arg has the reverse meaning. If no
8969 backend-specific 'request-thread function is available fetch
8970 LIMIT (the numerical prefix) old headers. If LIMIT is
8971 non-numeric or nil fetch the number specified by the
8972 `gnus-refer-thread-limit' variable."
8973 (interactive "P")
8974 (gnus-warp-to-article)
8975 (let* ((header (gnus-summary-article-header))
8976 (id (mail-header-id header))
8977 (gnus-inhibit-demon t)
8978 (gnus-summary-ignore-duplicates t)
8979 (gnus-read-all-available-headers t)
8980 (gnus-refer-thread-use-nnir
8981 (if (and (not (null limit)) (listp limit))
8982 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
8983 (new-headers
8984 (if (gnus-check-backend-function
8985 'request-thread gnus-newsgroup-name)
8986 (gnus-request-thread header gnus-newsgroup-name)
8987 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
8988 gnus-refer-thread-limit))
8989 (last (if (numberp limit)
8990 (min (+ (mail-header-number header)
8991 limit)
8992 gnus-newsgroup-highest)
8993 gnus-newsgroup-highest))
8994 (subject (gnus-simplify-subject
8995 (mail-header-subject header)))
8996 (refs (split-string (or (mail-header-references header)
8997 "")))
8998 (gnus-parse-headers-hook
8999 `(lambda () (goto-char (point-min))
9000 (keep-lines
9001 (regexp-opt ',(append refs (list id subject)))))))
9002 (gnus-fetch-headers (list last) (if (numberp limit)
9003 (* 2 limit) limit) t))))
9004 article-ids)
9005 (when (listp new-headers)
9006 (dolist (header new-headers)
9007 (push (mail-header-number header) article-ids)
9008 (when (member (mail-header-number header) gnus-newsgroup-unselected)
9009 (push (mail-header-number header) gnus-newsgroup-unreads)
9010 (setq gnus-newsgroup-unselected
9011 (delete (mail-header-number header)
9012 gnus-newsgroup-unselected))))
9013 (setq gnus-newsgroup-headers
9014 (gnus-delete-duplicate-headers
9015 (gnus-merge
9016 'list gnus-newsgroup-headers new-headers
9017 'gnus-article-sort-by-number)))
9018 (setq gnus-newsgroup-articles
9019 (gnus-sorted-nunion gnus-newsgroup-articles (nreverse article-ids)))
9020 (gnus-summary-limit-include-thread id)))
9021 (gnus-summary-show-thread))
9022
9023 (defun gnus-summary-refer-article (message-id)
9024 "Fetch an article specified by MESSAGE-ID."
9025 (interactive "sMessage-ID: ")
9026 (gnus-warp-to-article)
9027 (when (and (stringp message-id)
9028 (not (zerop (length message-id))))
9029 (setq message-id (gnus-replace-in-string message-id " " ""))
9030 ;; Construct the correct Message-ID if necessary.
9031 ;; Suggested by tale@pawl.rpi.edu.
9032 (unless (string-match "^<" message-id)
9033 (setq message-id (concat "<" message-id)))
9034 (unless (string-match ">$" message-id)
9035 (setq message-id (concat message-id ">")))
9036 ;; People often post MIDs from URLs, so unhex it:
9037 (unless (string-match "@" message-id)
9038 (setq message-id (gnus-url-unhex-string message-id)))
9039 (let* ((header (gnus-id-to-header message-id))
9040 (sparse (and header
9041 (gnus-summary-article-sparse-p
9042 (mail-header-number header))
9043 (memq (mail-header-number header)
9044 gnus-newsgroup-limit)))
9045 number)
9046 (cond
9047 ;; If the article is present in the buffer we just go to it.
9048 ((and header
9049 (or (not (gnus-summary-article-sparse-p
9050 (mail-header-number header)))
9051 sparse))
9052 (prog1
9053 (gnus-summary-goto-article
9054 (mail-header-number header) nil t)
9055 (when sparse
9056 (gnus-summary-update-article (mail-header-number header)))))
9057 (t
9058 ;; We fetch the article.
9059 (catch 'found
9060 (dolist (gnus-override-method (gnus-refer-article-methods))
9061 (when (and (gnus-check-server gnus-override-method)
9062 ;; Fetch the header,
9063 (setq number (gnus-summary-insert-subject message-id)))
9064 ;; and display the article.
9065 (gnus-summary-select-article nil nil nil number)
9066 (throw 'found t)))
9067 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9068
9069 (defun gnus-refer-article-methods ()
9070 "Return a list of referable methods."
9071 (cond
9072 ;; No method, so we default to current and native.
9073 ((null gnus-refer-article-method)
9074 (list gnus-current-select-method gnus-select-method))
9075 ;; Current.
9076 ((eq 'current gnus-refer-article-method)
9077 (list gnus-current-select-method))
9078 ;; List of select methods.
9079 ((not (and (symbolp (car gnus-refer-article-method))
9080 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9081 (let (out)
9082 (dolist (method gnus-refer-article-method)
9083 (push (if (eq 'current method)
9084 gnus-current-select-method
9085 (if (eq 'nnir (car method))
9086 (list
9087 'nnir
9088 (or (cadr method)
9089 (gnus-method-to-server gnus-current-select-method)))
9090 method))
9091 out))
9092 (nreverse out)))
9093 ;; One single select method.
9094 (t
9095 (list gnus-refer-article-method))))
9096
9097 (defun gnus-summary-edit-parameters ()
9098 "Edit the group parameters of the current group."
9099 (interactive)
9100 (gnus-group-edit-group gnus-newsgroup-name 'params))
9101
9102 (defun gnus-summary-customize-parameters ()
9103 "Customize the group parameters of the current group."
9104 (interactive)
9105 (gnus-group-customize gnus-newsgroup-name))
9106
9107 (defun gnus-summary-enter-digest-group (&optional force)
9108 "Enter an nndoc group based on the current article.
9109 If FORCE, force a digest interpretation. If not, try to guess
9110 what the document format is.
9111
9112 To control what happens when you exit the group, see the
9113 `gnus-auto-select-on-ephemeral-exit' variable."
9114 (interactive "P")
9115 (let ((conf gnus-current-window-configuration))
9116 (save-window-excursion
9117 (save-excursion
9118 (let (gnus-article-prepare-hook
9119 gnus-display-mime-function
9120 gnus-break-pages)
9121 (gnus-summary-select-article))))
9122 (setq gnus-current-window-configuration conf)
9123 (let* ((name (format "%s-%d"
9124 (gnus-group-prefixed-name
9125 gnus-newsgroup-name (list 'nndoc ""))
9126 (with-current-buffer gnus-summary-buffer
9127 gnus-current-article)))
9128 (ogroup gnus-newsgroup-name)
9129 (params (append (gnus-info-params (gnus-get-info ogroup))
9130 (list (cons 'to-group ogroup))
9131 (list (cons 'parent-group ogroup))
9132 (list (cons 'save-article-group ogroup))))
9133 (case-fold-search t)
9134 (buf (current-buffer))
9135 dig to-address charset)
9136 (with-current-buffer gnus-original-article-buffer
9137 ;; Have the digest group inherit the main mail address of
9138 ;; the parent article.
9139 (when (setq to-address (or (gnus-fetch-field "reply-to")
9140 (gnus-fetch-field "from")))
9141 (setq params
9142 (append
9143 (list (cons 'to-address
9144 (funcall gnus-decode-encoded-address-function
9145 to-address))))))
9146 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9147 (insert-buffer-substring gnus-original-article-buffer)
9148 (narrow-to-region
9149 (goto-char (point-min))
9150 (or (search-forward "\n\n" nil t) (point)))
9151 ;; Remove lines that may lead nndoc to misinterpret the
9152 ;; document type.
9153 (goto-char (point-min))
9154 (delete-matching-lines "^Path:\\|^From ")
9155 ;; Parse charset, and decode content transfer encoding.
9156 (setq charset (mail-content-type-get
9157 (mail-header-parse-content-type
9158 (or (gnus-fetch-field "content-type") ""))
9159 'charset))
9160 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9161 (when encoding
9162 (message-remove-header "content-transfer-encoding")
9163 (goto-char (point-max))
9164 (widen)
9165 (narrow-to-region (point) (point-max))
9166 (mm-decode-content-transfer-encoding
9167 (intern (downcase (mail-header-strip encoding))))))
9168 (widen))
9169 (unwind-protect
9170 (if (let ((gnus-newsgroup-ephemeral-charset
9171 (if charset
9172 (intern (downcase (gnus-strip-whitespace charset)))
9173 gnus-newsgroup-charset))
9174 (gnus-newsgroup-ephemeral-ignored-charsets
9175 gnus-newsgroup-ignored-charsets))
9176 (gnus-group-read-ephemeral-group
9177 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9178 (nndoc-article-type
9179 ,(if force 'mbox 'guess)))
9180 t nil nil nil
9181 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9182 "ADAPT")))))
9183 ;; Make all postings to this group go to the parent group.
9184 (nconc (gnus-info-params (gnus-get-info name))
9185 params)
9186 ;; Couldn't select this doc group.
9187 (switch-to-buffer buf)
9188 (gnus-set-global-variables)
9189 (gnus-configure-windows 'summary)
9190 (gnus-message 3 "Article couldn't be entered?"))
9191 (kill-buffer dig)))))
9192
9193 (defun gnus-summary-read-document (n)
9194 "Open a new group based on the current article(s).
9195 This will allow you to read digests and other similar
9196 documents as newsgroups.
9197 Obeys the standard process/prefix convention."
9198 (interactive "P")
9199 (let* ((ogroup gnus-newsgroup-name)
9200 (params (append (gnus-info-params (gnus-get-info ogroup))
9201 (list (cons 'to-group ogroup))))
9202 group egroup groups vgroup)
9203 (dolist (article (gnus-summary-work-articles n))
9204 (setq group (format "%s-%d" gnus-newsgroup-name article))
9205 (gnus-summary-remove-process-mark article)
9206 (when (gnus-summary-display-article article)
9207 (save-excursion ;;What for?
9208 (with-temp-buffer
9209 (insert-buffer-substring gnus-original-article-buffer)
9210 ;; Remove some headers that may lead nndoc to make
9211 ;; the wrong guess.
9212 (message-narrow-to-head)
9213 (goto-char (point-min))
9214 (delete-matching-lines "^Path:\\|^From ")
9215 (widen)
9216 (if (setq egroup
9217 (gnus-group-read-ephemeral-group
9218 group `(nndoc ,group (nndoc-address ,(current-buffer))
9219 (nndoc-article-type guess))
9220 t nil t))
9221 (progn
9222 ;; Make all postings to this group go to the parent group.
9223 (nconc (gnus-info-params (gnus-get-info egroup))
9224 params)
9225 (push egroup groups))
9226 ;; Couldn't select this doc group.
9227 (gnus-error 3 "Article couldn't be entered"))))))
9228 ;; Now we have selected all the documents.
9229 (cond
9230 ((not groups)
9231 (error "None of the articles could be interpreted as documents"))
9232 ((gnus-group-read-ephemeral-group
9233 (setq vgroup (format
9234 "nnvirtual:%s-%s" gnus-newsgroup-name
9235 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
9236 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9237 t
9238 (cons (current-buffer) 'summary)))
9239 (t
9240 (error "Couldn't select virtual nndoc group")))))
9241
9242 (defun gnus-summary-widget-forward (arg)
9243 "Move point to the next field or button in the article.
9244 With optional ARG, move across that many fields."
9245 (interactive "p")
9246 (gnus-summary-select-article)
9247 (gnus-configure-windows 'article)
9248 (select-window (gnus-get-buffer-window gnus-article-buffer))
9249 (widget-forward arg))
9250
9251 (defun gnus-summary-widget-backward (arg)
9252 "Move point to the previous field or button in the article.
9253 With optional ARG, move across that many fields."
9254 (interactive "p")
9255 (gnus-summary-select-article)
9256 (gnus-configure-windows 'article)
9257 (select-window (gnus-get-buffer-window gnus-article-buffer))
9258 (unless (widget-at (point))
9259 (goto-char (point-max)))
9260 (widget-backward arg))
9261
9262 (defun gnus-summary-isearch-article (&optional regexp-p)
9263 "Do incremental search forward on the current article.
9264 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9265 (interactive "P")
9266 (gnus-summary-select-article)
9267 (gnus-configure-windows 'article)
9268 (gnus-eval-in-buffer-window gnus-article-buffer
9269 (save-restriction
9270 (widen)
9271 (isearch-forward regexp-p))))
9272
9273 (defun gnus-summary-repeat-search-article-forward ()
9274 "Repeat the previous search forwards."
9275 (interactive)
9276 (unless gnus-last-search-regexp
9277 (error "No previous search"))
9278 (gnus-summary-search-article-forward gnus-last-search-regexp))
9279
9280 (defun gnus-summary-repeat-search-article-backward ()
9281 "Repeat the previous search backwards."
9282 (interactive)
9283 (unless gnus-last-search-regexp
9284 (error "No previous search"))
9285 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9286
9287 (defun gnus-summary-search-article-forward (regexp &optional backward)
9288 "Search for an article containing REGEXP forward.
9289 If BACKWARD, search backward instead."
9290 (interactive
9291 (list (read-string
9292 (format "Search article %s (regexp%s): "
9293 (if current-prefix-arg "backward" "forward")
9294 (if gnus-last-search-regexp
9295 (concat ", default " gnus-last-search-regexp)
9296 "")))
9297 current-prefix-arg))
9298 (if (string-equal regexp "")
9299 (setq regexp (or gnus-last-search-regexp ""))
9300 (setq gnus-last-search-regexp regexp)
9301 (setq gnus-article-before-search gnus-current-article))
9302 ;; Intentionally set gnus-last-article.
9303 (setq gnus-last-article gnus-article-before-search)
9304 (let ((gnus-last-article gnus-last-article))
9305 (if (gnus-summary-search-article regexp backward)
9306 (gnus-summary-show-thread)
9307 (signal 'search-failed (list regexp)))))
9308
9309 (defun gnus-summary-search-article-backward (regexp)
9310 "Search for an article containing REGEXP backward."
9311 (interactive
9312 (list (read-string
9313 (format "Search article backward (regexp%s): "
9314 (if gnus-last-search-regexp
9315 (concat ", default " gnus-last-search-regexp)
9316 "")))))
9317 (gnus-summary-search-article-forward regexp 'backward))
9318
9319 (defun gnus-summary-search-article (regexp &optional backward)
9320 "Search for an article containing REGEXP.
9321 Optional argument BACKWARD means do search for backward.
9322 `gnus-select-article-hook' is not called during the search."
9323 ;; We have to require this here to make sure that the following
9324 ;; dynamic binding isn't shadowed by autoloading.
9325 (require 'gnus-async)
9326 (require 'gnus-art)
9327 (let ((gnus-select-article-hook nil) ;Disable hook.
9328 (gnus-article-prepare-hook nil)
9329 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9330 (gnus-use-article-prefetch nil)
9331 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9332 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9333 (gnus-visual nil)
9334 (gnus-keep-backlog nil)
9335 (gnus-break-pages nil)
9336 (gnus-summary-display-arrow nil)
9337 (gnus-updated-mode-lines nil)
9338 (gnus-auto-center-summary nil)
9339 (sum (current-buffer))
9340 (gnus-display-mime-function nil)
9341 (found nil)
9342 point)
9343 (gnus-save-hidden-threads
9344 (gnus-summary-select-article)
9345 (set-buffer gnus-article-buffer)
9346 (goto-char (window-point (get-buffer-window (current-buffer))))
9347 (when backward
9348 (forward-line -1))
9349 (while (not found)
9350 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9351 (if (if backward
9352 (re-search-backward regexp nil t)
9353 (re-search-forward regexp nil t))
9354 ;; We found the regexp.
9355 (progn
9356 (setq found 'found)
9357 (beginning-of-line)
9358 (set-window-start
9359 (get-buffer-window (current-buffer))
9360 (point))
9361 (forward-line 1)
9362 (set-window-point
9363 (get-buffer-window (current-buffer))
9364 (point))
9365 (set-buffer sum)
9366 (setq point (point)))
9367 ;; We didn't find it, so we go to the next article.
9368 (set-buffer sum)
9369 (setq found 'not)
9370 (while (eq found 'not)
9371 (if (not (if backward (gnus-summary-find-prev)
9372 (gnus-summary-find-next)))
9373 ;; No more articles.
9374 (setq found t)
9375 ;; Select the next article and adjust point.
9376 (unless (gnus-summary-article-sparse-p
9377 (gnus-summary-article-number))
9378 (setq found nil)
9379 (gnus-summary-select-article)
9380 (set-buffer gnus-article-buffer)
9381 (widen)
9382 (goto-char (if backward (point-max) (point-min))))))))
9383 (gnus-message 7 ""))
9384 ;; Return whether we found the regexp.
9385 (when (eq found 'found)
9386 (goto-char point)
9387 (gnus-summary-show-thread)
9388 (gnus-summary-goto-subject gnus-current-article)
9389 (gnus-summary-position-point)
9390 t)))
9391
9392 (defun gnus-find-matching-articles (header regexp)
9393 "Return a list of all articles that match REGEXP on HEADER.
9394 This search includes all articles in the current group that Gnus has
9395 fetched headers for, whether they are displayed or not."
9396 (let ((articles nil)
9397 ;; Can't eta-reduce because it's a macro.
9398 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9399 (case-fold-search t))
9400 (dolist (header gnus-newsgroup-headers)
9401 (when (string-match regexp (funcall func header))
9402 (push (mail-header-number header) articles)))
9403 (nreverse articles)))
9404
9405 (defun gnus-summary-find-matching (header regexp &optional backward unread
9406 not-case-fold not-matching)
9407 "Return a list of all articles that match REGEXP on HEADER.
9408 The search stars on the current article and goes forwards unless
9409 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9410 If UNREAD is non-nil, only unread articles will
9411 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9412 in the comparisons. If NOT-MATCHING, return a list of all articles that
9413 not match REGEXP on HEADER."
9414 (let ((case-fold-search (not not-case-fold))
9415 articles d func)
9416 (if (consp header)
9417 (if (eq (car header) 'extra)
9418 (setq func
9419 `(lambda (h)
9420 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9421 "")))
9422 (error "%s is an invalid header" header))
9423 (unless (fboundp (intern (concat "mail-header-" header)))
9424 (error "%s is not a valid header" header))
9425 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9426 (dolist (d (if (eq backward 'all)
9427 gnus-newsgroup-data
9428 (gnus-data-find-list
9429 (gnus-summary-article-number)
9430 (gnus-data-list backward))))
9431 (when (and (or (not unread) ; We want all articles...
9432 (gnus-data-unread-p d)) ; Or just unreads.
9433 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9434 (if not-matching
9435 (not (string-match
9436 regexp
9437 (funcall func (gnus-data-header d))))
9438 (string-match regexp
9439 (funcall func (gnus-data-header d)))))
9440 (push (gnus-data-number d) articles))) ; Success!
9441 (nreverse articles)))
9442
9443 (defun gnus-summary-execute-command (header regexp command &optional backward)
9444 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9445 If HEADER is an empty string (or nil), the match is done on the entire
9446 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9447 (interactive
9448 (list (let ((completion-ignore-case t))
9449 (gnus-completing-read
9450 "Header name"
9451 (mapcar 'symbol-name
9452 (append
9453 '(Number Subject From Lines Date
9454 Message-ID Xref References Body)
9455 gnus-extra-headers))
9456 'require-match))
9457 (read-string "Regexp: ")
9458 (read-key-sequence "Command: ")
9459 current-prefix-arg))
9460 (when (equal header "Body")
9461 (setq header ""))
9462 ;; Hidden thread subtrees must be searched as well.
9463 (gnus-summary-show-all-threads)
9464 ;; We don't want to change current point nor window configuration.
9465 (save-excursion
9466 (save-window-excursion
9467 (let (gnus-visual
9468 gnus-treat-strip-trailing-blank-lines
9469 gnus-treat-strip-leading-blank-lines
9470 gnus-treat-strip-multiple-blank-lines
9471 gnus-treat-hide-boring-headers
9472 gnus-treat-fold-newsgroups
9473 gnus-article-prepare-hook)
9474 (gnus-message 6 "Executing %s..." (key-description command))
9475 ;; We'd like to execute COMMAND interactively so as to give arguments.
9476 (gnus-execute header regexp
9477 `(call-interactively ',(key-binding command))
9478 backward)
9479 (gnus-message 6 "Executing %s...done" (key-description command))))))
9480
9481 (defun gnus-summary-beginning-of-article ()
9482 "Scroll the article back to the beginning."
9483 (interactive)
9484 (gnus-summary-select-article)
9485 (gnus-configure-windows 'article)
9486 (gnus-eval-in-buffer-window gnus-article-buffer
9487 (widen)
9488 (goto-char (point-min))
9489 (when gnus-break-pages
9490 (gnus-narrow-to-page))))
9491
9492 (defun gnus-summary-end-of-article ()
9493 "Scroll to the end of the article."
9494 (interactive)
9495 (gnus-summary-select-article)
9496 (gnus-configure-windows 'article)
9497 (gnus-eval-in-buffer-window gnus-article-buffer
9498 (widen)
9499 (goto-char (point-max))
9500 (recenter -3)
9501 (when gnus-break-pages
9502 (gnus-narrow-to-page))))
9503
9504 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9505 "Truncate to LEN and quote all \"(\"'s in STRING."
9506 (gnus-replace-in-string (if (and len (> (length string) len))
9507 (substring string 0 len)
9508 string)
9509 "[()]" "\\\\\\&"))
9510
9511 (defun gnus-summary-print-article (&optional filename n)
9512 "Generate and print a PostScript image of the process-marked (mail) articles.
9513
9514 If used interactively, print the current article if none are
9515 process-marked. With prefix arg, prompt the user for the name of the
9516 file to save in.
9517
9518 When used from Lisp, accept two optional args FILENAME and N. N means
9519 to print the next N articles. If N is negative, print the N previous
9520 articles. If N is nil and articles have been marked with the process
9521 mark, print these instead.
9522
9523 If the optional first argument FILENAME is nil, send the image to the
9524 printer. If FILENAME is a string, save the PostScript image in a file with
9525 that name. If FILENAME is a number, prompt the user for the name of the file
9526 to save in."
9527 (interactive (list (ps-print-preprint current-prefix-arg)))
9528 (dolist (article (gnus-summary-work-articles n))
9529 (gnus-summary-select-article nil nil 'pseudo article)
9530 (gnus-eval-in-buffer-window gnus-article-buffer
9531 (gnus-print-buffer))
9532 (gnus-summary-remove-process-mark article))
9533 (ps-despool filename))
9534
9535 (defun gnus-print-buffer ()
9536 (let ((ps-left-header
9537 (list
9538 (concat "("
9539 (gnus-summary-print-truncate-and-quote
9540 (mail-header-subject gnus-current-headers)
9541 66) ")")
9542 (concat "("
9543 (gnus-summary-print-truncate-and-quote
9544 (mail-header-from gnus-current-headers)
9545 45) ")")))
9546 (ps-right-header
9547 (list
9548 "/pagenumberstring load"
9549 (concat "("
9550 (mail-header-date gnus-current-headers) ")"))))
9551 (gnus-run-hooks 'gnus-ps-print-hook)
9552 (save-excursion
9553 (if ps-print-color-p
9554 (ps-spool-buffer-with-faces)
9555 (ps-spool-buffer)))))
9556
9557 (defun gnus-summary-show-complete-article ()
9558 "Show a complete version of the current article.
9559 This is only useful if you're looking at a partial version of the
9560 article currently."
9561 (interactive)
9562 (let ((gnus-keep-backlog nil)
9563 (gnus-use-cache nil)
9564 (gnus-agent nil)
9565 (variable (intern
9566 (format "%s-fetch-partial-articles"
9567 (car (gnus-find-method-for-group
9568 gnus-newsgroup-name)))
9569 obarray))
9570 old-val)
9571 (unwind-protect
9572 (progn
9573 (setq old-val (symbol-value variable))
9574 (set variable nil)
9575 (gnus-flush-original-article-buffer)
9576 (gnus-summary-show-article))
9577 (set variable old-val))))
9578
9579 (defun gnus-summary-show-article (&optional arg)
9580 "Force redisplaying of the current article.
9581 If ARG (the prefix) is a number, show the article with the charset
9582 defined in `gnus-summary-show-article-charset-alist', or the charset
9583 input.
9584 If ARG (the prefix) is non-nil and not a number, show the article,
9585 but without running any of the article treatment functions
9586 article. Normally, the keystroke is `C-u g'. When using `C-u
9587 C-u g', show the raw article."
9588 (interactive "P")
9589 (cond
9590 ((numberp arg)
9591 (gnus-summary-show-article t)
9592 (let ((gnus-newsgroup-charset
9593 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9594 (mm-read-coding-system
9595 "View as charset: " ;; actually it is coding system.
9596 (with-current-buffer gnus-article-buffer
9597 (mm-detect-coding-region (point) (point-max))))))
9598 (gnus-newsgroup-ignored-charsets 'gnus-all))
9599 (gnus-summary-select-article nil 'force)
9600 (let ((deps gnus-newsgroup-dependencies)
9601 head header lines)
9602 (with-current-buffer gnus-original-article-buffer
9603 (save-restriction
9604 (message-narrow-to-head)
9605 (setq head (buffer-string))
9606 (goto-char (point-min))
9607 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9608 (goto-char (point-max))
9609 (widen)
9610 (setq lines (1- (count-lines (point) (point-max))))))
9611 (with-temp-buffer
9612 (insert (format "211 %d Article retrieved.\n"
9613 (cdr gnus-article-current)))
9614 (insert head)
9615 (if lines (insert (format "Lines: %d\n" lines)))
9616 (insert ".\n")
9617 (let ((nntp-server-buffer (current-buffer)))
9618 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9619 (gnus-data-set-header
9620 (gnus-data-find (cdr gnus-article-current))
9621 header)
9622 (gnus-summary-update-article-line
9623 (cdr gnus-article-current) header)
9624 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9625 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9626 ((not arg)
9627 ;; Select the article the normal way.
9628 (if (eq mm-text-html-renderer 'shr)
9629 (progn
9630 (require 'shr)
9631 (let ((shr-ignore-cache t))
9632 (gnus-summary-select-article nil 'force)))
9633 (gnus-summary-select-article nil 'force)))
9634 ((equal arg '(16))
9635 ;; C-u C-u g
9636 (let ((gnus-inhibit-article-treatments t))
9637 (gnus-summary-select-article nil 'force)))
9638 (t
9639 ;; We have to require this here to make sure that the following
9640 ;; dynamic binding isn't shadowed by autoloading.
9641 (require 'gnus-async)
9642 (require 'gnus-art)
9643 ;; Bind the article treatment functions to nil.
9644 (let ((gnus-have-all-headers t)
9645 gnus-article-prepare-hook
9646 gnus-article-decode-hook
9647 gnus-display-mime-function
9648 gnus-break-pages)
9649 ;; Destroy any MIME parts.
9650 (when (gnus-buffer-live-p gnus-article-buffer)
9651 (with-current-buffer gnus-article-buffer
9652 (gnus-article-stop-animations)
9653 (gnus-stop-downloads)
9654 (mm-destroy-parts gnus-article-mime-handles)
9655 ;; Set it to nil for safety reason.
9656 (setq gnus-article-mime-handle-alist nil)
9657 (setq gnus-article-mime-handles nil)))
9658 (gnus-summary-select-article nil 'force))))
9659 (gnus-summary-goto-subject gnus-current-article)
9660 (gnus-summary-position-point))
9661
9662 (defun gnus-summary-show-raw-article ()
9663 "Show the raw article without any article massaging functions being run."
9664 (interactive)
9665 (gnus-summary-show-article t))
9666
9667 (defun gnus-summary-verbose-headers (&optional arg)
9668 "Toggle permanent full header display.
9669 If ARG is a positive number, turn header display on.
9670 If ARG is a negative number, turn header display off."
9671 (interactive "P")
9672 (setq gnus-show-all-headers
9673 (cond ((or (not (numberp arg))
9674 (zerop arg))
9675 (not gnus-show-all-headers))
9676 ((natnump arg)
9677 t)))
9678 (gnus-summary-show-article))
9679
9680 (defun gnus-summary-toggle-header (&optional arg)
9681 "Show the headers if they are hidden, or hide them if they are shown.
9682 If ARG is a positive number, show the entire header.
9683 If ARG is a negative number, hide the unwanted header lines."
9684 (interactive "P")
9685 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9686 (get-buffer-window gnus-article-buffer t))))
9687 (with-current-buffer gnus-article-buffer
9688 (widen)
9689 (article-narrow-to-head)
9690 (let* ((inhibit-read-only t)
9691 (inhibit-point-motion-hooks t)
9692 (hidden (if (numberp arg)
9693 (>= arg 0)
9694 (or (not (looking-at "[^ \t\n]+:"))
9695 (gnus-article-hidden-text-p 'headers))))
9696 s e)
9697 (delete-region (point-min) (point-max))
9698 (with-current-buffer gnus-original-article-buffer
9699 (goto-char (setq s (point-min)))
9700 (setq e (if (search-forward "\n\n" nil t)
9701 (1- (point))
9702 (point-max))))
9703 (insert-buffer-substring gnus-original-article-buffer s e)
9704 (run-hooks 'gnus-article-decode-hook)
9705 (if hidden
9706 (let ((gnus-treat-hide-headers nil)
9707 (gnus-treat-hide-boring-headers nil))
9708 (gnus-delete-wash-type 'headers)
9709 (gnus-treat-article 'head))
9710 (gnus-treat-article 'head))
9711 (widen)
9712 (if window
9713 (set-window-start window (goto-char (point-min))))
9714 (if gnus-break-pages
9715 (gnus-narrow-to-page)
9716 (when (gnus-visual-p 'page-marker)
9717 (let ((inhibit-read-only t))
9718 (gnus-remove-text-with-property 'gnus-prev)
9719 (gnus-remove-text-with-property 'gnus-next))))
9720 (gnus-set-mode-line 'article)))))
9721
9722 (defun gnus-summary-show-all-headers ()
9723 "Make all header lines visible."
9724 (interactive)
9725 (gnus-summary-toggle-header 1))
9726
9727 (defun gnus-summary-caesar-message (&optional arg)
9728 "Caesar rotate the current article by 13.
9729 With a non-numerical prefix, also rotate headers. A numerical
9730 prefix specifies how many places to rotate each letter forward."
9731 (interactive "P")
9732 (gnus-summary-select-article)
9733 (let ((mail-header-separator ""))
9734 (gnus-eval-in-buffer-window gnus-article-buffer
9735 (save-restriction
9736 (widen)
9737 (let ((start (window-start))
9738 (inhibit-read-only t))
9739 (if (equal arg '(4))
9740 (message-caesar-buffer-body nil t)
9741 (message-caesar-buffer-body arg))
9742 (set-window-start (get-buffer-window (current-buffer)) start)))))
9743 ;; Create buttons and stuff...
9744 (gnus-treat-article nil))
9745
9746 (declare-function idna-to-unicode "ext:idna" (str))
9747
9748 (defun gnus-summary-idna-message (&optional arg)
9749 "Decode IDNA encoded domain names in the current articles.
9750 IDNA encoded domain names looks like `xn--bar'. If a string
9751 remain unencoded after running this function, it is likely an
9752 invalid IDNA string (`xn--bar' is invalid).
9753
9754 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9755 installed for this command to work."
9756 (interactive "P")
9757 (if (not (and (condition-case nil (require 'idna)
9758 (file-error))
9759 (mm-coding-system-p 'utf-8)
9760 (executable-find (symbol-value 'idna-program))))
9761 (gnus-message
9762 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9763 (gnus-summary-select-article)
9764 (let ((mail-header-separator ""))
9765 (gnus-eval-in-buffer-window gnus-article-buffer
9766 (save-restriction
9767 (widen)
9768 (let ((start (window-start))
9769 buffer-read-only)
9770 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9771 (replace-match (idna-to-unicode (match-string 1))))
9772 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9773
9774 (defun gnus-summary-morse-message (&optional arg)
9775 "Morse decode the current article."
9776 (interactive "P")
9777 (gnus-summary-select-article)
9778 (let ((mail-header-separator ""))
9779 (gnus-eval-in-buffer-window gnus-article-buffer
9780 (save-excursion
9781 (save-restriction
9782 (widen)
9783 (let ((pos (window-start))
9784 (inhibit-read-only t))
9785 (goto-char (point-min))
9786 (when (message-goto-body)
9787 (gnus-narrow-to-body))
9788 (goto-char (point-min))
9789 (while (search-forward "·" (point-max) t)
9790 (replace-match "."))
9791 (unmorse-region (point-min) (point-max))
9792 (widen)
9793 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9794
9795 (defun gnus-summary-stop-page-breaking ()
9796 "Stop page breaking in the current article."
9797 (interactive)
9798 (gnus-summary-select-article)
9799 (gnus-eval-in-buffer-window gnus-article-buffer
9800 (widen)
9801 (when (gnus-visual-p 'page-marker)
9802 (let ((inhibit-read-only t))
9803 (gnus-remove-text-with-property 'gnus-prev)
9804 (gnus-remove-text-with-property 'gnus-next))
9805 (setq gnus-page-broken nil))))
9806
9807 (defun gnus-summary-move-article (&optional n to-newsgroup
9808 select-method action)
9809 "Move the current article to a different newsgroup.
9810 If N is a positive number, move the N next articles.
9811 If N is a negative number, move the N previous articles.
9812 If N is nil and any articles have been marked with the process mark,
9813 move those articles instead.
9814 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9815 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9816 re-spool using this method.
9817
9818 When called interactively with TO-NEWSGROUP being nil, the value of
9819 the variable `gnus-move-split-methods' is used for finding a default
9820 for the target newsgroup.
9821
9822 For this function to work, both the current newsgroup and the
9823 newsgroup that you want to move to have to support the `request-move'
9824 and `request-accept' functions.
9825
9826 ACTION can be either `move' (the default), `crosspost' or `copy'."
9827 (interactive "P")
9828 (unless action
9829 (setq action 'move))
9830 ;; Check whether the source group supports the required functions.
9831 (cond ((and (eq action 'move)
9832 (not (gnus-check-backend-function
9833 'request-move-article gnus-newsgroup-name)))
9834 (error "The current group does not support article moving"))
9835 ((and (eq action 'crosspost)
9836 (not (gnus-check-backend-function
9837 'request-replace-article gnus-newsgroup-name)))
9838 (error "The current group does not support article editing")))
9839 (let ((articles (gnus-summary-work-articles n))
9840 (prefix (if (gnus-check-backend-function
9841 'request-move-article gnus-newsgroup-name)
9842 (funcall gnus-move-group-prefix-function
9843 gnus-newsgroup-name)
9844 ""))
9845 (names '((move "Move" "Moving")
9846 (copy "Copy" "Copying")
9847 (crosspost "Crosspost" "Crossposting")))
9848 (copy-buf (save-excursion
9849 (nnheader-set-temp-buffer " *copy article*")))
9850 art-group to-method new-xref article to-groups
9851 articles-to-update-marks encoded)
9852 (unless (assq action names)
9853 (error "Unknown action %s" action))
9854 ;; Read the newsgroup name.
9855 (when (and (not to-newsgroup)
9856 (not select-method))
9857 (if (and gnus-move-split-methods
9858 (not
9859 (and (memq gnus-current-article articles)
9860 (gnus-buffer-live-p gnus-original-article-buffer))))
9861 ;; When `gnus-move-split-methods' is non-nil, we have to
9862 ;; select an article to give `gnus-read-move-group-name' an
9863 ;; opportunity to suggest an appropriate default. However,
9864 ;; we needn't render or mark the article.
9865 (let ((gnus-display-mime-function nil)
9866 (gnus-article-prepare-hook nil)
9867 (gnus-mark-article-hook nil))
9868 (gnus-summary-select-article nil nil nil (car articles))))
9869 (setq to-newsgroup (gnus-read-move-group-name
9870 (cadr (assq action names))
9871 (symbol-value
9872 (intern (format "gnus-current-%s-group" action)))
9873 articles prefix)
9874 encoded to-newsgroup
9875 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9876 (set (intern (format "gnus-current-%s-group" action))
9877 (mm-decode-coding-string
9878 to-newsgroup
9879 (gnus-group-name-charset to-method to-newsgroup))))
9880 (unless to-method
9881 (setq to-method (or select-method
9882 (gnus-server-to-method
9883 (gnus-group-method to-newsgroup)))))
9884 (setq to-newsgroup
9885 (or encoded
9886 (and to-newsgroup
9887 (mm-encode-coding-string
9888 to-newsgroup
9889 (gnus-group-name-charset to-method to-newsgroup)))))
9890 ;; Check the method we are to move this article to...
9891 (unless (gnus-check-backend-function
9892 'request-accept-article (car to-method))
9893 (error "%s does not support article copying" (car to-method)))
9894 (unless (gnus-check-server to-method)
9895 (error "Can't open server %s" (car to-method)))
9896 (gnus-message 6 "%s to %s: %s..."
9897 (caddr (assq action names))
9898 (or (car select-method)
9899 (gnus-group-decoded-name to-newsgroup))
9900 articles)
9901 (while articles
9902 (setq article (pop articles))
9903 ;; Set any marks that may have changed in the summary buffer.
9904 (when gnus-preserve-marks
9905 (gnus-summary-push-marks-to-backend article))
9906 (setq
9907 art-group
9908 (cond
9909 ;; Move the article.
9910 ((eq action 'move)
9911 ;; Remove this article from future suppression.
9912 (gnus-dup-unsuppress-article article)
9913 (let* ((from-method (gnus-find-method-for-group
9914 gnus-newsgroup-name))
9915 (to-method (or select-method
9916 (gnus-find-method-for-group to-newsgroup)))
9917 (move-is-internal (gnus-server-equal from-method to-method)))
9918 (gnus-request-move-article
9919 article ; Article to move
9920 gnus-newsgroup-name ; From newsgroup
9921 (nth 1 (gnus-find-method-for-group
9922 gnus-newsgroup-name)) ; Server
9923 (list 'gnus-request-accept-article
9924 to-newsgroup (list 'quote select-method)
9925 (not articles) t) ; Accept form
9926 (not articles) ; Only save nov last time
9927 (and move-is-internal
9928 to-newsgroup ; Not respooling
9929 ; Is this move internal?
9930 (gnus-group-real-name to-newsgroup)))))
9931 ;; Copy the article.
9932 ((eq action 'copy)
9933 (with-current-buffer copy-buf
9934 (when (gnus-request-article-this-buffer article
9935 gnus-newsgroup-name)
9936 (save-restriction
9937 (nnheader-narrow-to-headers)
9938 (dolist (hdr gnus-copy-article-ignored-headers)
9939 (message-remove-header hdr t)))
9940 (gnus-request-accept-article
9941 to-newsgroup select-method (not articles) t))))
9942 ;; Crosspost the article.
9943 ((eq action 'crosspost)
9944 (let ((xref (message-tokenize-header
9945 (mail-header-xref (gnus-summary-article-header
9946 article))
9947 " ")))
9948 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9949 ":" (number-to-string article)))
9950 (unless xref
9951 (setq xref (list (system-name))))
9952 (setq new-xref
9953 (concat
9954 (mapconcat 'identity
9955 (delete "Xref:" (delete new-xref xref))
9956 " ")
9957 " " new-xref))
9958 (with-current-buffer copy-buf
9959 ;; First put the article in the destination group.
9960 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9961 (when (consp (setq art-group
9962 (gnus-request-accept-article
9963 to-newsgroup select-method (not articles)
9964 t)))
9965 (setq new-xref (concat new-xref " " (car art-group)
9966 ":"
9967 (number-to-string (cdr art-group))))
9968 ;; Now we have the new Xrefs header, so we insert
9969 ;; it and replace the new article.
9970 (nnheader-replace-header "Xref" new-xref)
9971 (gnus-request-replace-article
9972 (cdr art-group) to-newsgroup (current-buffer) t)
9973 art-group))))))
9974 (cond
9975 ((not art-group)
9976 (gnus-message 1 "Couldn't %s article %s: %s"
9977 (cadr (assq action names)) article
9978 (nnheader-get-report (car to-method))))
9979 ((eq art-group 'junk)
9980 (when (eq action 'move)
9981 (gnus-summary-mark-article article gnus-canceled-mark)
9982 (gnus-message 4 "Deleted article %s" article)
9983 ;; run the delete hook
9984 (run-hook-with-args 'gnus-summary-article-delete-hook
9985 action
9986 (gnus-data-header
9987 (assoc article (gnus-data-list nil)))
9988 gnus-newsgroup-name nil
9989 select-method)))
9990 (t
9991 (let* ((pto-group (gnus-group-prefixed-name
9992 (car art-group) to-method))
9993 (info (gnus-get-info pto-group))
9994 (to-group (gnus-info-group info))
9995 to-marks)
9996 ;; Update the group that has been moved to.
9997 (when (and info
9998 (memq action '(move copy)))
9999 (unless (member to-group to-groups)
10000 (push to-group to-groups))
10001
10002 (when (and (not (memq article gnus-newsgroup-unreads))
10003 (cdr art-group))
10004 (push 'read to-marks)
10005 (gnus-info-set-read
10006 info (gnus-add-to-range (gnus-info-read info)
10007 (list (cdr art-group)))))
10008
10009 ;; See whether the article is to be put in the cache.
10010 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10011 (marks (if expirable
10012 gnus-article-mark-lists
10013 (delete '(expirable . expire)
10014 (copy-sequence
10015 gnus-article-mark-lists))))
10016 (to-article (cdr art-group)))
10017
10018 ;; Enter the article into the cache in the new group,
10019 ;; if that is required.
10020 (when (and to-article
10021 gnus-use-cache)
10022 (gnus-cache-possibly-enter-article
10023 to-group to-article
10024 (memq article gnus-newsgroup-marked)
10025 (memq article gnus-newsgroup-dormant)
10026 (memq article gnus-newsgroup-unreads)))
10027
10028 (when (and gnus-preserve-marks
10029 to-article)
10030 ;; Copy any marks over to the new group.
10031 (when (and (equal to-group gnus-newsgroup-name)
10032 (not (memq article gnus-newsgroup-unreads)))
10033 ;; Mark this article as read in this group.
10034 (push (cons to-article gnus-read-mark)
10035 gnus-newsgroup-reads)
10036 ;; Increase the active status of this group.
10037 (setcdr (gnus-active to-group) to-article)
10038 (setcdr gnus-newsgroup-active to-article))
10039
10040 (while marks
10041 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10042 (when (memq article (symbol-value
10043 (intern (format "gnus-newsgroup-%s"
10044 (caar marks)))))
10045 (push (cdar marks) to-marks)
10046 ;; If the other group is the same as this group,
10047 ;; then we have to add the mark to the list.
10048 (when (equal to-group gnus-newsgroup-name)
10049 (set (intern (format "gnus-newsgroup-%s"
10050 (caar marks)))
10051 (cons to-article
10052 (symbol-value
10053 (intern (format "gnus-newsgroup-%s"
10054 (caar marks)))))))
10055 ;; Copy the marks to other group.
10056 (gnus-add-marked-articles
10057 to-group (cdar marks) (list to-article) info)))
10058 (setq marks (cdr marks)))
10059
10060 (when (and expirable
10061 gnus-mark-copied-or-moved-articles-as-expirable
10062 (not (memq 'expire to-marks)))
10063 ;; Mark this article as expirable.
10064 (push 'expire to-marks)
10065 (when (equal to-group gnus-newsgroup-name)
10066 (push to-article gnus-newsgroup-expirable))
10067 ;; Copy the expirable mark to other group.
10068 (gnus-add-marked-articles
10069 to-group 'expire (list to-article) info))
10070
10071 (when (and to-marks
10072 (gnus-method-option-p
10073 (gnus-find-method-for-group to-group)
10074 'server-marks))
10075 (gnus-request-set-mark
10076 to-group (list (list (list to-article) 'add to-marks)))))
10077
10078 (gnus-dribble-enter
10079 (concat "(gnus-group-set-info '"
10080 (gnus-prin1-to-string (gnus-get-info to-group))
10081 ")")
10082 (concat "^(gnus-group-set-info '(\""
10083 (regexp-quote to-group) "\""))))
10084
10085 ;; Update the Xref header in this article to point to
10086 ;; the new crossposted article we have just created.
10087 (when (eq action 'crosspost)
10088 (with-current-buffer copy-buf
10089 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10090 (nnheader-replace-header "Xref" new-xref)
10091 (gnus-request-replace-article
10092 article gnus-newsgroup-name (current-buffer) t)))
10093
10094 ;; run the move/copy/crosspost/respool hook
10095 (run-hook-with-args 'gnus-summary-article-move-hook
10096 action
10097 (gnus-data-header
10098 (assoc article (gnus-data-list nil)))
10099 gnus-newsgroup-name
10100 to-newsgroup
10101 select-method))
10102
10103 ;;;!!!Why is this necessary?
10104 (set-buffer gnus-summary-buffer)
10105
10106 (when (eq action 'move)
10107 (save-excursion
10108 (gnus-summary-goto-subject article)
10109 (gnus-summary-mark-article article gnus-canceled-mark)))))
10110 (push article articles-to-update-marks))
10111
10112 (save-excursion
10113 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10114 ;; Re-activate all groups that have been moved to.
10115 (with-current-buffer gnus-group-buffer
10116 (let ((gnus-group-marked to-groups))
10117 (gnus-group-get-new-news-this-group nil t)))
10118
10119 (gnus-kill-buffer copy-buf)
10120 (gnus-summary-position-point)
10121 (gnus-set-mode-line 'summary)))
10122
10123 (defun gnus-summary-push-marks-to-backend (article)
10124 (let ((set nil)
10125 (del nil)
10126 (marks gnus-article-mark-lists))
10127 (unless (memq article gnus-newsgroup-unreads)
10128 (push 'read set))
10129 (while marks
10130 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10131 (memq article (symbol-value
10132 (intern (format "gnus-newsgroup-%s"
10133 (caar marks))))))
10134 (push (cdar marks) set)
10135 (push (cdar marks) del))
10136 (pop marks))
10137 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10138 ((,article) del ,del)))))
10139
10140 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10141 "Copy the current article to some other group.
10142 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10143 When called interactively, if TO-NEWSGROUP is nil, use the value of
10144 the variable `gnus-move-split-methods' for finding a default target
10145 newsgroup.
10146 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10147 re-spool using this method."
10148 (interactive "P")
10149 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10150
10151 (defun gnus-summary-crosspost-article (&optional n)
10152 "Crosspost the current article to some other group."
10153 (interactive "P")
10154 (gnus-summary-move-article n nil nil 'crosspost))
10155
10156 (defcustom gnus-summary-respool-default-method nil
10157 "Default method type for respooling an article.
10158 If nil, use to the current newsgroup method."
10159 :type 'symbol
10160 :group 'gnus-summary-mail)
10161
10162 (defun gnus-summary-respool-article (&optional n method)
10163 "Respool the current article.
10164 The article will be squeezed through the mail spooling process again,
10165 which means that it will be put in some mail newsgroup or other
10166 depending on `nnmail-split-methods'.
10167 If N is a positive number, respool the N next articles.
10168 If N is a negative number, respool the N previous articles.
10169 If N is nil and any articles have been marked with the process mark,
10170 respool those articles instead.
10171
10172 Respooling can be done both from mail groups and \"real\" newsgroups.
10173 In the former case, the articles in question will be moved from the
10174 current group into whatever groups they are destined to. In the
10175 latter case, they will be copied into the relevant groups."
10176 (interactive
10177 (list current-prefix-arg
10178 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10179 (methname
10180 (symbol-name (or gnus-summary-respool-default-method
10181 (car (gnus-find-method-for-group
10182 gnus-newsgroup-name)))))
10183 (method
10184 (gnus-completing-read
10185 "Backend to use when respooling"
10186 methods t nil 'gnus-mail-method-history methname))
10187 ms)
10188 (cond
10189 ((zerop (length (setq ms (gnus-servers-using-backend
10190 (intern method)))))
10191 (list (intern method) ""))
10192 ((= 1 (length ms))
10193 (car ms))
10194 (t
10195 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10196 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10197 ms-alist))))))))
10198 (unless method
10199 (error "No method given for respooling"))
10200 (if (assoc (symbol-name
10201 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10202 (gnus-methods-using 'respool))
10203 (gnus-summary-move-article n nil method)
10204 (gnus-summary-copy-article n nil method)))
10205
10206 (defun gnus-summary-import-article (file &optional edit)
10207 "Import an arbitrary file into a mail newsgroup."
10208 (interactive "fImport file: \nP")
10209 (let ((group gnus-newsgroup-name)
10210 (now (current-time))
10211 atts lines group-art)
10212 (unless (gnus-check-backend-function 'request-accept-article group)
10213 (error "%s does not support article importing" group))
10214 (or (file-readable-p file)
10215 (not (file-regular-p file))
10216 (error "Can't read %s" file))
10217 (with-current-buffer (gnus-get-buffer-create " *import file*")
10218 (erase-buffer)
10219 (nnheader-insert-file-contents file)
10220 (goto-char (point-min))
10221 (if (nnheader-article-p)
10222 (save-restriction
10223 (goto-char (point-min))
10224 (search-forward "\n\n" nil t)
10225 (narrow-to-region (point-min) (1- (point)))
10226 (goto-char (point-min))
10227 (unless (re-search-forward "^date:" nil t)
10228 (goto-char (point-max))
10229 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10230 ;; This doesn't look like an article, so we fudge some headers.
10231 (setq atts (file-attributes file)
10232 lines (count-lines (point-min) (point-max)))
10233 (insert "From: " (read-string "From: ") "\n"
10234 "Subject: " (read-string "Subject: ") "\n"
10235 "Date: " (message-make-date (nth 5 atts)) "\n"
10236 "Message-ID: " (message-make-message-id) "\n"
10237 "Lines: " (int-to-string lines) "\n"
10238 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10239 (setq group-art (gnus-request-accept-article group nil t))
10240 (kill-buffer (current-buffer)))
10241 (setq gnus-newsgroup-active (gnus-activate-group group))
10242 (forward-line 1)
10243 (gnus-summary-goto-article (cdr group-art) nil t)
10244 (when edit
10245 (gnus-summary-edit-article))))
10246
10247 (defun gnus-summary-create-article ()
10248 "Create an article in a mail newsgroup."
10249 (interactive)
10250 (let ((group gnus-newsgroup-name)
10251 (now (current-time))
10252 group-art)
10253 (unless (gnus-check-backend-function 'request-accept-article group)
10254 (error "%s does not support article importing" group))
10255 (with-current-buffer (gnus-get-buffer-create " *import file*")
10256 (erase-buffer)
10257 (goto-char (point-min))
10258 ;; This doesn't look like an article, so we fudge some headers.
10259 (insert "From: " (read-string "From: ") "\n"
10260 "Subject: " (read-string "Subject: ") "\n"
10261 "Date: " (message-make-date now) "\n"
10262 "Message-ID: " (message-make-message-id) "\n")
10263 (setq group-art (gnus-request-accept-article group nil t))
10264 (kill-buffer (current-buffer)))
10265 (setq gnus-newsgroup-active (gnus-activate-group group))
10266 (forward-line 1)
10267 (gnus-summary-goto-article (cdr group-art) nil t)
10268 (gnus-summary-edit-article)))
10269
10270 (defun gnus-summary-article-posted-p ()
10271 "Say whether the current (mail) article is available from news as well.
10272 This will be the case if the article has both been mailed and posted."
10273 (interactive)
10274 (let ((id (mail-header-references (gnus-summary-article-header)))
10275 (gnus-override-method (car (gnus-refer-article-methods))))
10276 (if (gnus-request-head id "")
10277 (gnus-message 2 "The current message was found on %s"
10278 gnus-override-method)
10279 (gnus-message 2 "The current message couldn't be found on %s"
10280 gnus-override-method)
10281 nil)))
10282
10283 (defun gnus-summary-expire-articles (&optional now)
10284 "Expire all articles that are marked as expirable in the current group."
10285 (interactive)
10286 (when (and (not gnus-group-is-exiting-without-update-p)
10287 (gnus-check-backend-function
10288 'request-expire-articles gnus-newsgroup-name))
10289 ;; This backend supports expiry.
10290 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10291 (expirable (if total
10292 (progn
10293 ;; We need to update the info for
10294 ;; this group for `gnus-list-of-read-articles'
10295 ;; to give us the right answer.
10296 (gnus-run-hooks 'gnus-exit-group-hook)
10297 (gnus-summary-update-info)
10298 (gnus-list-of-read-articles gnus-newsgroup-name))
10299 (setq gnus-newsgroup-expirable
10300 (sort gnus-newsgroup-expirable '<))))
10301 (expiry-wait (if now 'immediate
10302 (gnus-group-find-parameter
10303 gnus-newsgroup-name 'expiry-wait)))
10304 (nnmail-expiry-target
10305 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10306 nnmail-expiry-target))
10307 es)
10308 (when expirable
10309 ;; There are expirable articles in this group, so we run them
10310 ;; through the expiry process.
10311 (gnus-message 6 "Expiring articles...")
10312 (when (gnus-check-group gnus-newsgroup-name)
10313 ;; The list of articles that weren't expired is returned.
10314 (save-excursion
10315 (if expiry-wait
10316 (let ((nnmail-expiry-wait-function nil)
10317 (nnmail-expiry-wait expiry-wait))
10318 (setq es (gnus-request-expire-articles
10319 expirable gnus-newsgroup-name)))
10320 (setq es (gnus-request-expire-articles
10321 expirable gnus-newsgroup-name)))
10322 (unless total
10323 (setq gnus-newsgroup-expirable es))
10324 ;; We go through the old list of expirable, and mark all
10325 ;; really expired articles as nonexistent.
10326 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10327 (let ((gnus-use-cache nil))
10328 (dolist (article expirable)
10329 (when (and (not (memq article es))
10330 (gnus-data-find article))
10331 (gnus-summary-mark-article article gnus-canceled-mark)
10332 (run-hook-with-args 'gnus-summary-article-expire-hook
10333 'delete
10334 (gnus-data-header
10335 (assoc article (gnus-data-list nil)))
10336 gnus-newsgroup-name
10337 nil
10338 nil)))))))
10339 (gnus-message 6 "Expiring articles...done")))))
10340
10341 (defun gnus-summary-expire-articles-now ()
10342 "Expunge all expirable articles in the current group.
10343 This means that *all* articles that are marked as expirable will be
10344 deleted forever, right now."
10345 (interactive)
10346 (or gnus-expert-user
10347 (gnus-yes-or-no-p
10348 "Are you really, really sure you want to delete all expirable messages? ")
10349 (error "Phew!"))
10350 (gnus-summary-expire-articles t))
10351
10352 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10353 (defun gnus-summary-delete-article (&optional n)
10354 "Delete the N next (mail) articles.
10355 This command actually deletes articles. This is not a marking
10356 command. The article will disappear forever from your life, never to
10357 return.
10358
10359 If N is negative, delete backwards.
10360 If N is nil and articles have been marked with the process mark,
10361 delete these instead.
10362
10363 If `gnus-novice-user' is non-nil you will be asked for
10364 confirmation before the articles are deleted."
10365 (interactive "P")
10366 (unless (gnus-check-backend-function 'request-expire-articles
10367 gnus-newsgroup-name)
10368 (error "The current newsgroup does not support article deletion"))
10369 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10370 (error "Couldn't open server"))
10371 ;; Compute the list of articles to delete.
10372 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10373 (nnmail-expiry-target 'delete)
10374 not-deleted)
10375 (if (and gnus-novice-user
10376 (not (gnus-yes-or-no-p
10377 (format "Do you really want to delete %s forever? "
10378 (if (> (length articles) 1)
10379 (format "these %s articles" (length articles))
10380 "this article")))))
10381 ()
10382 ;; Delete the articles.
10383 (setq not-deleted (gnus-request-expire-articles
10384 articles gnus-newsgroup-name 'force))
10385 (save-excursion
10386 (while articles
10387 (gnus-summary-remove-process-mark (car articles))
10388 ;; The backend might not have been able to delete the article
10389 ;; after all.
10390 (unless (memq (car articles) not-deleted)
10391 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10392 (let* ((article (car articles))
10393 (ghead (gnus-data-header
10394 (assoc article (gnus-data-list nil)))))
10395 (run-hook-with-args 'gnus-summary-article-delete-hook
10396 'delete ghead gnus-newsgroup-name nil
10397 nil)))
10398 (setq articles (cdr articles))))
10399 (when not-deleted
10400 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10401 (gnus-summary-position-point)
10402 (gnus-set-mode-line 'summary)
10403 not-deleted))
10404
10405 (defun gnus-summary-edit-article (&optional arg)
10406 "Edit the current article.
10407 This will have permanent effect only in mail groups.
10408 If ARG is nil, edit the decoded articles.
10409 If ARG is 1, edit the raw articles.
10410 If ARG is 2, edit the raw articles even in read-only groups.
10411 If ARG is 3, edit the articles with the current handles.
10412 Otherwise, allow editing of articles even in read-only
10413 groups."
10414 (interactive "P")
10415 (let (force raw current-handles)
10416 (cond
10417 ((null arg))
10418 ((eq arg 1)
10419 (setq raw t))
10420 ((eq arg 2)
10421 (setq raw t
10422 force t))
10423 ((eq arg 3)
10424 (setq current-handles
10425 (and (gnus-buffer-live-p gnus-article-buffer)
10426 (with-current-buffer gnus-article-buffer
10427 (prog1
10428 gnus-article-mime-handles
10429 (setq gnus-article-mime-handles nil))))))
10430 (t
10431 (setq force t)))
10432 (when (and raw (not force)
10433 (member gnus-newsgroup-name '("nndraft:delayed"
10434 "nndraft:drafts"
10435 "nndraft:queue")))
10436 (error "Can't edit the raw article in group %s"
10437 gnus-newsgroup-name))
10438 (with-current-buffer gnus-summary-buffer
10439 (let ((mail-parse-charset gnus-newsgroup-charset)
10440 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10441 (gnus-set-global-variables)
10442 (when (and (not force)
10443 (gnus-group-read-only-p))
10444 (error "The current newsgroup does not support article editing"))
10445 (gnus-summary-show-article t)
10446 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10447 (with-current-buffer gnus-article-buffer
10448 (mm-enable-multibyte)))
10449 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10450 (setq raw t))
10451 (gnus-article-edit-article
10452 (if raw 'ignore
10453 `(lambda ()
10454 (let ((mbl mml-buffer-list))
10455 (setq mml-buffer-list nil)
10456 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10457 (mime-to-mml ,'current-handles))
10458 (let ((mbl1 mml-buffer-list))
10459 (setq mml-buffer-list mbl)
10460 (set (make-local-variable 'mml-buffer-list) mbl1))
10461 (gnus-make-local-hook 'kill-buffer-hook)
10462 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10463 `(lambda (no-highlight)
10464 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10465 (message-options message-options)
10466 (message-options-set-recipient)
10467 (mail-parse-ignored-charsets
10468 ',gnus-newsgroup-ignored-charsets)
10469 (rfc2047-header-encoding-alist
10470 ',(let ((charset (gnus-group-name-charset
10471 (gnus-find-method-for-group
10472 gnus-newsgroup-name)
10473 gnus-newsgroup-name)))
10474 (append (list (cons "Newsgroups" charset)
10475 (cons "Followup-To" charset)
10476 (cons "Xref" charset))
10477 rfc2047-header-encoding-alist))))
10478 ,(if (not raw) '(progn
10479 (mml-to-mime)
10480 (mml-destroy-buffers)
10481 (remove-hook 'kill-buffer-hook
10482 'mml-destroy-buffers t)
10483 (kill-local-variable 'mml-buffer-list)))
10484 (gnus-summary-edit-article-done
10485 ,(or (mail-header-references gnus-current-headers) "")
10486 ,(gnus-group-read-only-p)
10487 ,gnus-summary-buffer no-highlight))))))))
10488
10489 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10490
10491 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10492 no-highlight)
10493 "Make edits to the current article permanent."
10494 (interactive)
10495 (save-excursion
10496 ;; The buffer restriction contains the entire article if it exists.
10497 (when (article-goto-body)
10498 (let ((lines (count-lines (point) (point-max)))
10499 (length (- (point-max) (point)))
10500 (case-fold-search t)
10501 (body (copy-marker (point))))
10502 (goto-char (point-min))
10503 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10504 (delete-region (match-beginning 1) (match-end 1))
10505 (insert (number-to-string length)))
10506 (goto-char (point-min))
10507 (when (re-search-forward
10508 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10509 (delete-region (match-beginning 1) (match-end 1))
10510 (insert (number-to-string length)))
10511 (goto-char (point-min))
10512 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10513 (delete-region (match-beginning 1) (match-end 1))
10514 (insert (number-to-string lines))))))
10515 ;; Replace the article.
10516 (let ((buf (current-buffer))
10517 (article (cdr gnus-article-current))
10518 replace-result)
10519 (with-temp-buffer
10520 (insert-buffer-substring buf)
10521 (if (and (not read-only)
10522 (not (setq replace-result
10523 (gnus-request-replace-article
10524 article (car gnus-article-current)
10525 (current-buffer) t))))
10526 (error "Couldn't replace article")
10527 ;; If we got a number back, then that's the new article number
10528 ;; for this article. Otherwise, the article number didn't change.
10529 (when (numberp replace-result)
10530 (with-current-buffer gnus-summary-buffer
10531 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10532 (gnus-summary-limit gnus-newsgroup-limit)
10533 (setq article replace-result)
10534 (gnus-summary-goto-subject article t)))
10535 ;; Update the summary buffer.
10536 (if (and references
10537 (equal (message-tokenize-header references " ")
10538 (message-tokenize-header
10539 (or (message-fetch-field "references") "") " ")))
10540 ;; We only have to update this line.
10541 (save-excursion
10542 (save-restriction
10543 (message-narrow-to-head)
10544 (let ((head (buffer-substring-no-properties
10545 (point-min) (point-max)))
10546 header)
10547 (with-temp-buffer
10548 (insert (format "211 %d Article retrieved.\n" article))
10549 (insert head)
10550 (insert ".\n")
10551 (let ((nntp-server-buffer (current-buffer)))
10552 (setq header (car (gnus-get-newsgroup-headers nil t))))
10553 (with-current-buffer gnus-summary-buffer
10554 (gnus-data-set-header (gnus-data-find article) header)
10555 (gnus-summary-update-article-line article header)
10556 (if (gnus-summary-goto-subject article nil t)
10557 (gnus-summary-update-secondary-mark article)))))))
10558 ;; Update threads.
10559 (set-buffer (or buffer gnus-summary-buffer))
10560 (gnus-summary-update-article article)
10561 (if (gnus-summary-goto-subject article nil t)
10562 (gnus-summary-update-secondary-mark article)))
10563 ;; Prettify the article buffer again.
10564 (unless no-highlight
10565 (with-current-buffer gnus-article-buffer
10566 ;;!!! Fix this -- article should be rehighlighted.
10567 ;;(gnus-run-hooks 'gnus-article-display-hook)
10568 (set-buffer gnus-original-article-buffer)
10569 (gnus-request-article
10570 article (car gnus-article-current) (current-buffer))))
10571 ;; Prettify the summary buffer line.
10572 (when (gnus-visual-p 'summary-highlight 'highlight)
10573 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10574
10575 (defun gnus-summary-edit-wash (key)
10576 "Perform editing command KEY in the article buffer."
10577 (interactive
10578 (list
10579 (progn
10580 (message "%s" (concat (this-command-keys) "- "))
10581 (read-char))))
10582 (message "")
10583 (gnus-summary-edit-article)
10584 (execute-kbd-macro (concat (this-command-keys) key))
10585 (gnus-article-edit-done))
10586
10587 ;;; Respooling
10588
10589 (defun gnus-summary-respool-query (&optional silent trace)
10590 "Query where the respool algorithm would put this article."
10591 (interactive)
10592 (let (gnus-mark-article-hook)
10593 (gnus-summary-select-article)
10594 (with-current-buffer gnus-original-article-buffer
10595 (let ((groups (nnmail-article-group 'identity trace)))
10596 (unless silent
10597 (if groups
10598 (message "This message would go to %s"
10599 (mapconcat 'car groups ", "))
10600 (message "This message would go to no groups"))
10601 groups)))))
10602
10603 (defun gnus-summary-respool-trace ()
10604 "Trace where the respool algorithm would put this article.
10605 Display a buffer showing all fancy splitting patterns which matched."
10606 (interactive)
10607 (gnus-summary-respool-query nil t))
10608
10609 ;; Summary marking commands.
10610
10611 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10612 "Mark articles which has the same subject as read, and then select the next.
10613 If UNMARK is positive, remove any kind of mark.
10614 If UNMARK is negative, tick articles."
10615 (interactive "P")
10616 (when unmark
10617 (setq unmark (prefix-numeric-value unmark)))
10618 (let ((count
10619 (gnus-summary-mark-same-subject
10620 (gnus-summary-article-subject) unmark)))
10621 ;; Select next unread article. If auto-select-same mode, should
10622 ;; select the first unread article.
10623 (gnus-summary-next-article t (and gnus-auto-select-same
10624 (gnus-summary-article-subject)))
10625 (gnus-message 7 "%d article%s marked as %s"
10626 count (if (= count 1) " is" "s are")
10627 (if unmark "unread" "read"))))
10628
10629 (defun gnus-summary-kill-same-subject (&optional unmark)
10630 "Mark articles which has the same subject as read.
10631 If UNMARK is positive, remove any kind of mark.
10632 If UNMARK is negative, tick articles."
10633 (interactive "P")
10634 (when unmark
10635 (setq unmark (prefix-numeric-value unmark)))
10636 (let ((count
10637 (gnus-summary-mark-same-subject
10638 (gnus-summary-article-subject) unmark)))
10639 ;; If marked as read, go to next unread subject.
10640 (when (null unmark)
10641 ;; Go to next unread subject.
10642 (gnus-summary-next-subject 1 t))
10643 (gnus-message 7 "%d articles are marked as %s"
10644 count (if unmark "unread" "read"))))
10645
10646 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10647 "Mark articles with same SUBJECT as read, and return marked number.
10648 If optional argument UNMARK is positive, remove any kinds of marks.
10649 If optional argument UNMARK is negative, mark articles as unread instead."
10650 (let ((count 1))
10651 (save-excursion
10652 (cond
10653 ((null unmark) ; Mark as read.
10654 (while (and
10655 (progn
10656 (gnus-summary-mark-article-as-read gnus-killed-mark)
10657 (gnus-summary-show-thread) t)
10658 (gnus-summary-find-subject subject))
10659 (setq count (1+ count))))
10660 ((> unmark 0) ; Tick.
10661 (while (and
10662 (progn
10663 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10664 (gnus-summary-show-thread) t)
10665 (gnus-summary-find-subject subject))
10666 (setq count (1+ count))))
10667 (t ; Mark as unread.
10668 (while (and
10669 (progn
10670 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10671 (gnus-summary-show-thread) t)
10672 (gnus-summary-find-subject subject))
10673 (setq count (1+ count)))))
10674 (gnus-set-mode-line 'summary)
10675 ;; Return the number of marked articles.
10676 count)))
10677
10678 (defun gnus-summary-mark-as-processable (n &optional unmark)
10679 "Set the process mark on the next N articles.
10680 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10681 the process mark instead. The difference between N and the actual
10682 number of articles marked is returned."
10683 (interactive "P")
10684 (if (and (null n) (gnus-region-active-p))
10685 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10686 (setq n (prefix-numeric-value n))
10687 (let ((backward (< n 0))
10688 (n (abs n)))
10689 (while (and
10690 (> n 0)
10691 (if unmark
10692 (gnus-summary-remove-process-mark
10693 (gnus-summary-article-number))
10694 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10695 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10696 (setq n (1- n)))
10697 (when (/= 0 n)
10698 (gnus-message 7 "No more articles"))
10699 (gnus-summary-recenter)
10700 (gnus-summary-position-point)
10701 n)))
10702
10703 (defun gnus-summary-unmark-as-processable (n)
10704 "Remove the process mark from the next N articles.
10705 If N is negative, unmark backward instead. The difference between N and
10706 the actual number of articles unmarked is returned."
10707 (interactive "P")
10708 (gnus-summary-mark-as-processable n t))
10709
10710 (defun gnus-summary-unmark-all-processable ()
10711 "Remove the process mark from all articles."
10712 (interactive)
10713 (save-excursion
10714 (while gnus-newsgroup-processable
10715 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10716 (gnus-summary-position-point))
10717
10718 (defun gnus-summary-add-mark (article type)
10719 "Mark ARTICLE with a mark of TYPE."
10720 (let ((vtype (car (assq type gnus-article-mark-lists)))
10721 var)
10722 (if (not vtype)
10723 (error "No such mark type: %s" type)
10724 (setq var (intern (format "gnus-newsgroup-%s" type)))
10725 (set var (cons article (symbol-value var)))
10726 (if (memq type '(processable cached replied forwarded recent saved))
10727 (gnus-summary-update-secondary-mark article)
10728 ;;; !!! This is bogus. We should find out what primary
10729 ;;; !!! mark we want to set.
10730 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10731
10732 (defun gnus-summary-mark-as-expirable (n)
10733 "Mark N articles forward as expirable.
10734 If N is negative, mark backward instead. The difference between N and
10735 the actual number of articles marked is returned."
10736 (interactive "p")
10737 (gnus-summary-mark-forward n gnus-expirable-mark))
10738
10739 (defun gnus-summary-mark-as-spam (n)
10740 "Mark N articles forward as spam.
10741 If N is negative, mark backward instead. The difference between N and
10742 the actual number of articles marked is returned."
10743 (interactive "p")
10744 (gnus-summary-mark-forward n gnus-spam-mark))
10745
10746 (defun gnus-summary-mark-article-as-replied (article)
10747 "Mark ARTICLE as replied to and update the summary line.
10748 ARTICLE can also be a list of articles."
10749 (interactive (list (gnus-summary-article-number)))
10750 (let ((articles (if (listp article) article (list article))))
10751 (dolist (article articles)
10752 (unless (numberp article)
10753 (error "%s is not a number" article))
10754 (push article gnus-newsgroup-replied)
10755 (let ((inhibit-read-only t))
10756 (when (gnus-summary-goto-subject article nil t)
10757 (gnus-summary-update-secondary-mark article))))))
10758
10759 (defun gnus-summary-mark-article-as-forwarded (article)
10760 "Mark ARTICLE as forwarded and update the summary line.
10761 ARTICLE can also be a list of articles."
10762 (let ((articles (if (listp article) article (list article))))
10763 (dolist (article articles)
10764 (push article gnus-newsgroup-forwarded)
10765 (let ((inhibit-read-only t))
10766 (when (gnus-summary-goto-subject article nil t)
10767 (gnus-summary-update-secondary-mark article))))))
10768
10769 (defun gnus-summary-set-bookmark (article)
10770 "Set a bookmark in current article."
10771 (interactive (list (gnus-summary-article-number)))
10772 (when (or (not (get-buffer gnus-article-buffer))
10773 (not gnus-current-article)
10774 (not gnus-article-current)
10775 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10776 (error "No current article selected"))
10777 ;; Remove old bookmark, if one exists.
10778 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10779 ;; Set the new bookmark, which is on the form
10780 ;; (article-number . line-number-in-body).
10781 (push
10782 (cons article
10783 (with-current-buffer gnus-article-buffer
10784 (count-lines
10785 (min (point)
10786 (save-excursion
10787 (article-goto-body)
10788 (point)))
10789 (point))))
10790 gnus-newsgroup-bookmarks)
10791 (gnus-message 6 "A bookmark has been added to the current article."))
10792
10793 (defun gnus-summary-remove-bookmark (article)
10794 "Remove the bookmark from the current article."
10795 (interactive (list (gnus-summary-article-number)))
10796 ;; Remove old bookmark, if one exists.
10797 (if (not (assq article gnus-newsgroup-bookmarks))
10798 (gnus-message 6 "No bookmark in current article.")
10799 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10800 (gnus-message 6 "Removed bookmark.")))
10801
10802 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10803 (defun gnus-summary-mark-as-dormant (n)
10804 "Mark N articles forward as dormant.
10805 If N is negative, mark backward instead. The difference between N and
10806 the actual number of articles marked is returned."
10807 (interactive "p")
10808 (gnus-summary-mark-forward n gnus-dormant-mark))
10809
10810 (defun gnus-summary-set-process-mark (article)
10811 "Set the process mark on ARTICLE and update the summary line."
10812 (setq gnus-newsgroup-processable
10813 (cons article
10814 (delq article gnus-newsgroup-processable)))
10815 (when (gnus-summary-goto-subject article)
10816 (gnus-summary-show-thread)
10817 (gnus-summary-goto-subject article)
10818 (gnus-summary-update-secondary-mark article)))
10819
10820 (defun gnus-summary-remove-process-mark (&rest articles)
10821 "Remove the process mark from ARTICLES and update the summary line."
10822 (dolist (article articles)
10823 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10824 (when (gnus-summary-goto-subject article)
10825 (gnus-summary-show-thread)
10826 (gnus-summary-goto-subject article)
10827 (gnus-summary-update-secondary-mark article)))
10828 t)
10829
10830 (defun gnus-summary-set-saved-mark (article)
10831 "Set the process mark on ARTICLE and update the summary line."
10832 (push article gnus-newsgroup-saved)
10833 (when (gnus-summary-goto-subject article)
10834 (gnus-summary-update-secondary-mark article)))
10835
10836 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10837 "Mark N articles as read forwards.
10838 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10839 The difference between N and the actual number of articles marked is
10840 returned.
10841 If NO-EXPIRE, auto-expiry will be inhibited."
10842 (interactive "p")
10843 (gnus-summary-show-thread)
10844 (let ((backward (< n 0))
10845 (gnus-summary-goto-unread
10846 (and gnus-summary-goto-unread
10847 (not (eq gnus-summary-goto-unread 'never))
10848 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10849 gnus-ticked-mark gnus-dormant-mark)))))
10850 (n (abs n))
10851 (mark (or mark gnus-del-mark)))
10852 (while (and (> n 0)
10853 (gnus-summary-mark-article nil mark no-expire)
10854 (zerop (gnus-summary-next-subject
10855 (if backward -1 1)
10856 (and gnus-summary-goto-unread
10857 (not (eq gnus-summary-goto-unread 'never)))
10858 t)))
10859 (setq n (1- n)))
10860 (when (/= 0 n)
10861 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10862 (gnus-summary-recenter)
10863 (gnus-summary-position-point)
10864 (gnus-set-mode-line 'summary)
10865 n))
10866
10867 (defun gnus-summary-mark-article-as-read (mark)
10868 "Mark the current article quickly as read with MARK."
10869 (let ((article (gnus-summary-article-number)))
10870 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10871 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10872 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10873 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10874 (push (cons article mark) gnus-newsgroup-reads)
10875 ;; Possibly remove from cache, if that is used.
10876 (when gnus-use-cache
10877 (gnus-cache-enter-remove-article article))
10878 ;; Allow the backend to change the mark.
10879 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10880 ;; Check for auto-expiry.
10881 (when (and gnus-newsgroup-auto-expire
10882 (memq mark gnus-auto-expirable-marks))
10883 (setq mark gnus-expirable-mark)
10884 ;; Let the backend know about the mark change.
10885 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10886 (push article gnus-newsgroup-expirable))
10887 ;; Set the mark in the buffer.
10888 (gnus-summary-update-mark mark 'unread)
10889 t))
10890
10891 (defun gnus-summary-mark-article-as-unread (mark)
10892 "Mark the current article quickly as unread with MARK."
10893 (let* ((article (gnus-summary-article-number))
10894 (old-mark (gnus-summary-article-mark article)))
10895 ;; Allow the backend to change the mark.
10896 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10897 (if (eq mark old-mark)
10898 t
10899 (if (<= article 0)
10900 (progn
10901 (gnus-error 1 "Can't mark negative article numbers")
10902 nil)
10903 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10904 (setq gnus-newsgroup-spam-marked
10905 (delq article gnus-newsgroup-spam-marked))
10906 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10907 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10908 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10909 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10910 (cond ((= mark gnus-ticked-mark)
10911 (setq gnus-newsgroup-marked
10912 (gnus-add-to-sorted-list gnus-newsgroup-marked
10913 article)))
10914 ((= mark gnus-spam-mark)
10915 (setq gnus-newsgroup-spam-marked
10916 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10917 article)))
10918 ((= mark gnus-dormant-mark)
10919 (setq gnus-newsgroup-dormant
10920 (gnus-add-to-sorted-list gnus-newsgroup-dormant
10921 article)))
10922 (t
10923 (setq gnus-newsgroup-unreads
10924 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10925 article))))
10926 (gnus-alist-pull article gnus-newsgroup-reads)
10927
10928 ;; See whether the article is to be put in the cache.
10929 (and gnus-use-cache
10930 (vectorp (gnus-summary-article-header article))
10931 (save-excursion
10932 (gnus-cache-possibly-enter-article
10933 gnus-newsgroup-name article
10934 (= mark gnus-ticked-mark)
10935 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10936
10937 ;; Fix the mark.
10938 (gnus-summary-update-mark mark 'unread)
10939 t))))
10940
10941 (defun gnus-summary-mark-article (&optional article mark no-expire)
10942 "Mark ARTICLE with MARK. MARK can be any character.
10943 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
10944 `??' (dormant) and `?E' (expirable).
10945 If MARK is nil, then the default character `?r' is used.
10946 If ARTICLE is nil, then the article on the current line will be
10947 marked.
10948 If NO-EXPIRE, auto-expiry will be inhibited."
10949 ;; The mark might be a string.
10950 (when (stringp mark)
10951 (setq mark (aref mark 0)))
10952 ;; If no mark is given, then we check auto-expiring.
10953 (when (null mark)
10954 (setq mark gnus-del-mark))
10955 (when (and (not no-expire)
10956 gnus-newsgroup-auto-expire
10957 (memq mark gnus-auto-expirable-marks))
10958 (setq mark gnus-expirable-mark))
10959 (let ((article (or article (gnus-summary-article-number)))
10960 (old-mark (gnus-summary-article-mark article)))
10961 ;; Allow the backend to change the mark.
10962 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10963 (if (eq mark old-mark)
10964 t
10965 (unless article
10966 (error "No article on current line"))
10967 (if (not (if (or (= mark gnus-unread-mark)
10968 (= mark gnus-ticked-mark)
10969 (= mark gnus-spam-mark)
10970 (= mark gnus-dormant-mark))
10971 (gnus-mark-article-as-unread article mark)
10972 (gnus-mark-article-as-read article mark)))
10973 t
10974 ;; See whether the article is to be put in the cache.
10975 (and gnus-use-cache
10976 (not (= mark gnus-canceled-mark))
10977 (vectorp (gnus-summary-article-header article))
10978 (save-excursion
10979 (gnus-cache-possibly-enter-article
10980 gnus-newsgroup-name article
10981 (= mark gnus-ticked-mark)
10982 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10983
10984 (when (gnus-summary-goto-subject article nil t)
10985 (let ((inhibit-read-only t))
10986 (gnus-summary-show-thread)
10987 ;; Fix the mark.
10988 (gnus-summary-update-mark mark 'unread)
10989 t))))))
10990
10991 (defun gnus-summary-update-secondary-mark (article)
10992 "Update the secondary (read, process, cache) mark."
10993 (gnus-summary-update-mark
10994 (cond ((memq article gnus-newsgroup-processable)
10995 gnus-process-mark)
10996 ((memq article gnus-newsgroup-cached)
10997 gnus-cached-mark)
10998 ((memq article gnus-newsgroup-replied)
10999 gnus-replied-mark)
11000 ((memq article gnus-newsgroup-forwarded)
11001 gnus-forwarded-mark)
11002 ((memq article gnus-newsgroup-saved)
11003 gnus-saved-mark)
11004 ((memq article gnus-newsgroup-unseen)
11005 gnus-unseen-mark)
11006 (t gnus-no-mark))
11007 'replied)
11008 (when (gnus-visual-p 'summary-highlight 'highlight)
11009 (gnus-summary-highlight-line)
11010 (gnus-run-hooks 'gnus-summary-update-hook))
11011 t)
11012
11013 (defun gnus-summary-update-download-mark (article)
11014 "Update the download mark."
11015 (gnus-summary-update-mark
11016 (cond ((memq article gnus-newsgroup-undownloaded)
11017 gnus-undownloaded-mark)
11018 (gnus-newsgroup-agentized
11019 gnus-downloaded-mark)
11020 (t
11021 gnus-no-mark))
11022 'download)
11023 (gnus-summary-update-line t)
11024 t)
11025
11026 (defun gnus-summary-update-mark (mark type)
11027 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11028 (inhibit-read-only t))
11029 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11030 (when forward
11031 (when (looking-at "\r")
11032 (incf forward))
11033 (when (<= (+ forward (point)) (point-max))
11034 ;; Go to the right position on the line.
11035 (goto-char (+ forward (point)))
11036 ;; Replace the old mark with the new mark.
11037 (let ((to-insert
11038 (mm-subst-char-in-string
11039 (char-after) mark
11040 (buffer-substring (point) (1+ (point))))))
11041 (delete-region (point) (1+ (point)))
11042 (insert to-insert))
11043 ;; Optionally update the marks by some user rule.
11044 (when (eq type 'unread)
11045 (gnus-data-set-mark
11046 (gnus-data-find (gnus-summary-article-number)) mark)
11047 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11048
11049 (defun gnus-mark-article-as-read (article &optional mark)
11050 "Enter ARTICLE in the pertinent lists and remove it from others."
11051 ;; Make the article expirable.
11052 (let ((mark (or mark gnus-del-mark)))
11053 (setq gnus-newsgroup-expirable
11054 (if (= mark gnus-expirable-mark)
11055 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11056 (delq article gnus-newsgroup-expirable)))
11057 ;; Remove from unread and marked lists.
11058 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11059 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11060 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11061 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11062 (push (cons article mark) gnus-newsgroup-reads)
11063 ;; Possibly remove from cache, if that is used.
11064 (when gnus-use-cache
11065 (gnus-cache-enter-remove-article article))
11066 t))
11067
11068 (defun gnus-mark-article-as-unread (article &optional mark)
11069 "Enter ARTICLE in the pertinent lists and remove it from others."
11070 (let ((mark (or mark gnus-ticked-mark)))
11071 (if (<= article 0)
11072 (progn
11073 (gnus-error 1 "Can't mark negative article numbers")
11074 nil)
11075 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11076 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11077 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11078 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11079 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11080
11081 ;; Unsuppress duplicates?
11082 (when gnus-suppress-duplicates
11083 (gnus-dup-unsuppress-article article))
11084
11085 (cond ((= mark gnus-ticked-mark)
11086 (setq gnus-newsgroup-marked
11087 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11088 ((= mark gnus-spam-mark)
11089 (setq gnus-newsgroup-spam-marked
11090 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11091 article)))
11092 ((= mark gnus-dormant-mark)
11093 (setq gnus-newsgroup-dormant
11094 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11095 (t
11096 (setq gnus-newsgroup-unreads
11097 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11098 (gnus-alist-pull article gnus-newsgroup-reads)
11099 t)))
11100
11101 (defun gnus-summary-tick-article-forward (n)
11102 "Tick N articles forwards.
11103 If N is negative, tick backwards instead.
11104 The difference between N and the number of articles ticked is returned."
11105 (interactive "p")
11106 (gnus-summary-mark-forward n gnus-ticked-mark))
11107
11108 (defun gnus-summary-tick-article-backward (n)
11109 "Tick N articles backwards.
11110 The difference between N and the number of articles ticked is returned."
11111 (interactive "p")
11112 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11113
11114 (defun gnus-summary-tick-article (&optional article clear-mark)
11115 "Mark current article as unread.
11116 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11117 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11118 (interactive)
11119 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11120 gnus-ticked-mark)))
11121
11122 (defun gnus-summary-mark-as-read-forward (n)
11123 "Mark N articles as read forwards.
11124 If N is negative, mark backwards instead.
11125 The difference between N and the actual number of articles marked is
11126 returned."
11127 (interactive "p")
11128 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11129
11130 (defun gnus-summary-mark-as-read-backward (n)
11131 "Mark the N articles as read backwards.
11132 The difference between N and the actual number of articles marked is
11133 returned."
11134 (interactive "p")
11135 (gnus-summary-mark-forward
11136 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11137
11138 (defun gnus-summary-mark-as-read (&optional article mark)
11139 "Mark current article as read.
11140 ARTICLE specifies the article to be marked as read.
11141 MARK specifies a string to be inserted at the beginning of the line."
11142 (gnus-summary-mark-article article mark))
11143
11144 (defun gnus-summary-clear-mark-forward (n)
11145 "Clear marks from N articles forward.
11146 If N is negative, clear backward instead.
11147 The difference between N and the number of marks cleared is returned."
11148 (interactive "p")
11149 (gnus-summary-mark-forward n gnus-unread-mark))
11150
11151 (defun gnus-summary-clear-mark-backward (n)
11152 "Clear marks from N articles backward.
11153 The difference between N and the number of marks cleared is returned."
11154 (interactive "p")
11155 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11156
11157 (defun gnus-summary-mark-unread-as-read ()
11158 "Intended to be used by `gnus-mark-article-hook'."
11159 (when (memq gnus-current-article gnus-newsgroup-unreads)
11160 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11161
11162 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11163 "Intended to be used by `gnus-mark-article-hook'."
11164 (let ((mark (gnus-summary-article-mark)))
11165 (when (or (gnus-unread-mark-p mark)
11166 (gnus-read-mark-p mark))
11167 (gnus-summary-mark-article gnus-current-article
11168 (or new-mark gnus-read-mark)))))
11169
11170 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11171 "Intended to be used by `gnus-mark-article-hook'."
11172 (let ((mark (gnus-summary-article-mark)))
11173 (when (or (gnus-unread-mark-p mark)
11174 (gnus-read-mark-p mark))
11175 (gnus-summary-mark-article (gnus-summary-article-number)
11176 (or new-mark gnus-read-mark)))))
11177
11178 (defun gnus-summary-mark-unread-as-ticked ()
11179 "Intended to be used by `gnus-mark-article-hook'."
11180 (when (memq gnus-current-article gnus-newsgroup-unreads)
11181 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11182
11183 (defun gnus-summary-mark-region-as-read (point mark all)
11184 "Mark all unread articles between point and mark as read.
11185 If given a prefix, mark all articles between point and mark as read,
11186 even ticked and dormant ones."
11187 (interactive "r\nP")
11188 (save-excursion
11189 (let (article)
11190 (goto-char point)
11191 (beginning-of-line)
11192 (while (and
11193 (< (point) mark)
11194 (progn
11195 (when (or all
11196 (memq (setq article (gnus-summary-article-number))
11197 gnus-newsgroup-unreads))
11198 (gnus-summary-mark-article article gnus-del-mark))
11199 t)
11200 (gnus-summary-find-next))))))
11201
11202 (defun gnus-summary-mark-below (score mark)
11203 "Mark articles with score less than SCORE with MARK."
11204 (interactive "P\ncMark: ")
11205 (setq score (if score
11206 (prefix-numeric-value score)
11207 (or gnus-summary-default-score 0)))
11208 (with-current-buffer gnus-summary-buffer
11209 (goto-char (point-min))
11210 (while
11211 (progn
11212 (and (< (gnus-summary-article-score) score)
11213 (gnus-summary-mark-article nil mark))
11214 (gnus-summary-find-next)))))
11215
11216 (defun gnus-summary-kill-below (&optional score)
11217 "Mark articles with score below SCORE as read."
11218 (interactive "P")
11219 (gnus-summary-mark-below score gnus-killed-mark))
11220
11221 (defun gnus-summary-clear-above (&optional score)
11222 "Clear all marks from articles with score above SCORE."
11223 (interactive "P")
11224 (gnus-summary-mark-above score gnus-unread-mark))
11225
11226 (defun gnus-summary-tick-above (&optional score)
11227 "Tick all articles with score above SCORE."
11228 (interactive "P")
11229 (gnus-summary-mark-above score gnus-ticked-mark))
11230
11231 (defun gnus-summary-mark-above (score mark)
11232 "Mark articles with score over SCORE with MARK."
11233 (interactive "P\ncMark: ")
11234 (setq score (if score
11235 (prefix-numeric-value score)
11236 (or gnus-summary-default-score 0)))
11237 (with-current-buffer gnus-summary-buffer
11238 (goto-char (point-min))
11239 (while (and (progn
11240 (when (> (gnus-summary-article-score) score)
11241 (gnus-summary-mark-article nil mark))
11242 t)
11243 (gnus-summary-find-next)))))
11244
11245 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11246 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11247 (defun gnus-summary-limit-include-expunged (&optional no-error)
11248 "Display all the hidden articles that were expunged for low scores."
11249 (interactive)
11250 (let ((inhibit-read-only t))
11251 (let ((scored gnus-newsgroup-scored)
11252 headers h)
11253 (while scored
11254 (unless (gnus-summary-article-header (caar scored))
11255 (and (setq h (gnus-number-to-header (caar scored)))
11256 (< (cdar scored) gnus-summary-expunge-below)
11257 (push h headers)))
11258 (setq scored (cdr scored)))
11259 (if (not headers)
11260 (when (not no-error)
11261 (error "No expunged articles hidden"))
11262 (goto-char (point-min))
11263 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11264 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11265 (dolist (x headers)
11266 (push (mail-header-number x) gnus-newsgroup-limit))
11267 (gnus-summary-prepare-unthreaded (nreverse headers))
11268 (goto-char (point-min))
11269 (gnus-summary-position-point)
11270 t))))
11271
11272 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11273 "Mark all unread articles in this newsgroup as read.
11274 If prefix argument ALL is non-nil, ticked and dormant articles will
11275 also be marked as read.
11276 If QUIETLY is non-nil, no questions will be asked.
11277
11278 If TO-HERE is non-nil, it should be a point in the buffer. All
11279 articles before (after, if REVERSE is set) this point will be marked
11280 as read.
11281
11282 Note that this function will only catch up the unread article
11283 in the current summary buffer limitation.
11284
11285 The number of articles marked as read is returned."
11286 (interactive "P")
11287 (prog1
11288 (save-excursion
11289 (when (or quietly
11290 (not gnus-interactive-catchup) ;Without confirmation?
11291 gnus-expert-user
11292 (gnus-y-or-n-p
11293 (if all
11294 "Mark absolutely all articles as read? "
11295 "Mark all unread articles as read? ")))
11296 (if (and not-mark
11297 (not gnus-newsgroup-adaptive)
11298 (not gnus-newsgroup-auto-expire)
11299 (not gnus-suppress-duplicates)
11300 (or (not gnus-use-cache)
11301 (eq gnus-use-cache 'passive)))
11302 (progn
11303 (when all
11304 (setq gnus-newsgroup-marked nil
11305 gnus-newsgroup-spam-marked nil
11306 gnus-newsgroup-dormant nil))
11307 (setq gnus-newsgroup-unreads
11308 (gnus-sorted-nunion
11309 (gnus-sorted-intersection gnus-newsgroup-unreads
11310 gnus-newsgroup-downloadable)
11311 (gnus-sorted-difference gnus-newsgroup-unfetched
11312 gnus-newsgroup-cached))))
11313 ;; We actually mark all articles as canceled, which we
11314 ;; have to do when using auto-expiry or adaptive scoring.
11315 (gnus-summary-show-all-threads)
11316 (if (and to-here reverse)
11317 (progn
11318 (goto-char to-here)
11319 (gnus-summary-mark-current-read-and-unread-as-read
11320 gnus-catchup-mark)
11321 (while (gnus-summary-find-next (not all))
11322 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11323 (when (gnus-summary-first-subject (not all))
11324 (while (and
11325 (if to-here (< (point) to-here) t)
11326 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11327 (gnus-summary-find-next (not all))))))
11328 (gnus-set-mode-line 'summary))
11329 t))
11330 (gnus-summary-position-point)))
11331
11332 (defun gnus-summary-catchup-to-here (&optional all)
11333 "Mark all unticked articles before the current one as read.
11334 If ALL is non-nil, also mark ticked and dormant articles as read."
11335 (interactive "P")
11336 (save-excursion
11337 (gnus-save-hidden-threads
11338 (let ((beg (point)))
11339 ;; We check that there are unread articles.
11340 (when (or all (gnus-summary-find-prev))
11341 (gnus-summary-catchup all t beg)))))
11342 (gnus-summary-position-point))
11343
11344 (defun gnus-summary-catchup-from-here (&optional all)
11345 "Mark all unticked articles after (and including) the current one as read.
11346 If ALL is non-nil, also mark ticked and dormant articles as read."
11347 (interactive "P")
11348 (save-excursion
11349 (gnus-save-hidden-threads
11350 (let ((beg (point)))
11351 ;; We check that there are unread articles.
11352 (when (or all (gnus-summary-find-next))
11353 (gnus-summary-catchup all t beg nil t)))))
11354 (gnus-summary-position-point))
11355
11356 (defun gnus-summary-catchup-all (&optional quietly)
11357 "Mark all articles in this newsgroup as read.
11358 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11359 instead, which marks only unread articles as read."
11360 (interactive "P")
11361 (gnus-summary-catchup t quietly))
11362
11363 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11364 "Mark all unread articles in this group as read, then exit.
11365 If prefix argument ALL is non-nil, all articles are marked as read.
11366 If QUIETLY is non-nil, no questions will be asked."
11367 (interactive "P")
11368 (when (gnus-summary-catchup all quietly nil 'fast)
11369 ;; Select next newsgroup or exit.
11370 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11371 (eq gnus-auto-select-next 'quietly))
11372 (gnus-summary-next-group nil)
11373 (gnus-summary-exit))))
11374
11375 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11376 "Mark all articles in this newsgroup as read, and then exit.
11377 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11378 instead, which marks only unread articles as read."
11379 (interactive "P")
11380 (gnus-summary-catchup-and-exit t quietly))
11381
11382 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11383 "Mark all articles in this group as read and select the next group.
11384 If given a prefix, mark all articles, unread as well as ticked, as
11385 read."
11386 (interactive "P")
11387 (save-excursion
11388 (gnus-summary-catchup all))
11389 (gnus-summary-next-group))
11390
11391 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11392 "Mark all articles in this group as read and select the previous group.
11393 If given a prefix, mark all articles, unread as well as ticked, as
11394 read."
11395 (interactive "P")
11396 (save-excursion
11397 (gnus-summary-catchup all))
11398 (gnus-summary-next-group nil nil t))
11399
11400 ;;;
11401 ;;; with article
11402 ;;;
11403
11404 (defmacro gnus-with-article (article &rest forms)
11405 "Select ARTICLE and perform FORMS in the original article buffer.
11406 Then replace the article with the result."
11407 `(progn
11408 ;; We don't want the article to be marked as read.
11409 (let (gnus-mark-article-hook)
11410 (gnus-summary-select-article t t nil ,article))
11411 (set-buffer gnus-original-article-buffer)
11412 ,@forms
11413 (if (not (gnus-check-backend-function
11414 'request-replace-article (car gnus-article-current)))
11415 (gnus-message 5 "Read-only group; not replacing")
11416 (unless (gnus-request-replace-article
11417 ,article (car gnus-article-current)
11418 (current-buffer) t)
11419 (error "Couldn't replace article")))
11420 ;; The cache and backlog have to be flushed somewhat.
11421 (when gnus-keep-backlog
11422 (gnus-backlog-remove-article
11423 (car gnus-article-current) (cdr gnus-article-current)))
11424 (when gnus-use-cache
11425 (gnus-cache-update-article
11426 (car gnus-article-current) (cdr gnus-article-current)))))
11427
11428 (put 'gnus-with-article 'lisp-indent-function 1)
11429 (put 'gnus-with-article 'edebug-form-spec '(form body))
11430
11431 ;; Thread-based commands.
11432
11433 (defun gnus-summary-articles-in-thread (&optional article)
11434 "Return a list of all articles in the current thread.
11435 If ARTICLE is non-nil, return all articles in the thread that starts
11436 with that article."
11437 (let* ((article (or article (gnus-summary-article-number)))
11438 (data (gnus-data-find-list article))
11439 (top-level (gnus-data-level (car data)))
11440 (top-subject
11441 (cond ((null gnus-thread-operation-ignore-subject)
11442 (gnus-simplify-subject-re
11443 (mail-header-subject (gnus-data-header (car data)))))
11444 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11445 (gnus-simplify-subject-fuzzy
11446 (mail-header-subject (gnus-data-header (car data)))))
11447 (t nil)))
11448 (end-point (save-excursion
11449 (goto-char (gnus-data-pos (car data)))
11450 (if (gnus-summary-go-to-next-thread)
11451 (point) (point-max))))
11452 articles)
11453 (while (and data
11454 (< (gnus-data-pos (car data)) end-point))
11455 (when (or (not top-subject)
11456 (string= top-subject
11457 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11458 (gnus-simplify-subject-fuzzy
11459 (mail-header-subject
11460 (gnus-data-header (car data))))
11461 (gnus-simplify-subject-re
11462 (mail-header-subject
11463 (gnus-data-header (car data)))))))
11464 (push (gnus-data-number (car data)) articles))
11465 (unless (and (setq data (cdr data))
11466 (> (gnus-data-level (car data)) top-level))
11467 (setq data nil)))
11468 ;; Return the list of articles.
11469 (nreverse articles)))
11470
11471 (defun gnus-summary-rethread-current ()
11472 "Rethread the thread the current article is part of."
11473 (interactive)
11474 (let* ((gnus-show-threads t)
11475 (article (gnus-summary-article-number))
11476 (id (mail-header-id (gnus-summary-article-header)))
11477 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11478 (unless id
11479 (error "No article on the current line"))
11480 (gnus-rebuild-thread id)
11481 (gnus-summary-goto-subject article)))
11482
11483 (defun gnus-summary-reparent-thread ()
11484 "Make the current article child of the marked (or previous) article.
11485
11486 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11487 is non-nil or the Subject: of both articles are the same."
11488 (interactive)
11489 (unless (not (gnus-group-read-only-p))
11490 (error "The current newsgroup does not support article editing"))
11491 (unless (<= (length gnus-newsgroup-processable) 1)
11492 (error "No more than one article may be marked"))
11493 (let ((child (gnus-summary-article-number))
11494 ;; First grab the marked article, otherwise one line up.
11495 (parent (if (not (null gnus-newsgroup-processable))
11496 (car gnus-newsgroup-processable)
11497 (save-excursion
11498 (if (eq (forward-line -1) 0)
11499 (gnus-summary-article-number)
11500 (error "Beginning of summary buffer"))))))
11501 (gnus-summary-reparent-children parent (list child))))
11502
11503 (defun gnus-summary-reparent-children (parent children)
11504 "Make PARENT the parent of CHILDREN.
11505 When called interactively, PARENT is the current article and CHILDREN
11506 are the process-marked articles."
11507 (interactive
11508 (list (gnus-summary-article-number)
11509 (gnus-summary-work-articles nil)))
11510 (dolist (child children)
11511 (save-window-excursion
11512 (let ((gnus-article-buffer " *reparent*"))
11513 (unless (not (eq parent child))
11514 (error "An article may not be self-referential"))
11515 (let ((message-id (mail-header-id
11516 (gnus-summary-article-header parent))))
11517 (unless (and message-id (not (equal message-id "")))
11518 (error "No message-id in desired parent"))
11519 (gnus-with-article child
11520 (save-restriction
11521 (goto-char (point-min))
11522 (message-narrow-to-head)
11523 (if (re-search-forward "^References: " nil t)
11524 (progn
11525 (re-search-forward "^[^ \t]" nil t)
11526 (forward-line -1)
11527 (end-of-line)
11528 (insert " " message-id))
11529 (insert "References: " message-id "\n"))))
11530 (set-buffer gnus-summary-buffer)
11531 (gnus-summary-unmark-all-processable)
11532 (gnus-summary-update-article child)
11533 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11534 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11535 (gnus-summary-rethread-current)
11536 (gnus-message 3 "Article %d is now the child of article %d"
11537 child parent))))))
11538
11539 (defun gnus-summary-toggle-threads (&optional arg)
11540 "Toggle showing conversation threads.
11541 If ARG is positive number, turn showing conversation threads on."
11542 (interactive "P")
11543 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11544 (setq gnus-show-threads
11545 (if (null arg) (not gnus-show-threads)
11546 (> (prefix-numeric-value arg) 0)))
11547 (gnus-summary-prepare)
11548 (gnus-summary-goto-subject current)
11549 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11550 (gnus-summary-position-point)))
11551
11552 (eval-and-compile
11553 (if (fboundp 'remove-overlays)
11554 (defalias 'gnus-remove-overlays 'remove-overlays)
11555 (defun gnus-remove-overlays (beg end name val)
11556 "Clear BEG and END of overlays whose property NAME has value VAL.
11557 For compatibility with XEmacs."
11558 (dolist (ov (gnus-overlays-in beg end))
11559 (when (eq (gnus-overlay-get ov name) val)
11560 (gnus-delete-overlay ov))))))
11561
11562 (defun gnus-summary-show-all-threads ()
11563 "Show all threads."
11564 (interactive)
11565 (gnus-remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11566 (gnus-summary-position-point))
11567
11568 (defsubst gnus-summary--inv (p)
11569 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11570
11571 (defun gnus-summary-show-thread ()
11572 "Show thread subtrees.
11573 Returns nil if no thread was there to be shown."
11574 (interactive)
11575 (let* ((orig (point))
11576 (end (point-at-eol))
11577 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11578 ;; Leave point at bol
11579 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11580 (eoi (when end
11581 (if (fboundp 'next-single-char-property-change)
11582 ;; Note: XEmacs version of n-s-c-p-c may return nil
11583 (or (next-single-char-property-change end 'invisible)
11584 (point-max))
11585 (while (progn
11586 (end-of-line 2)
11587 (and (not (eobp))
11588 (eq (get-char-property (point) 'invisible)
11589 'gnus-sum))))
11590 (point)))))
11591 (when eoi
11592 (gnus-remove-overlays beg eoi 'invisible 'gnus-sum)
11593 (goto-char orig)
11594 (gnus-summary-position-point)
11595 eoi)))
11596
11597 (defun gnus-summary-maybe-hide-threads ()
11598 "If requested, hide the threads that should be hidden."
11599 (when (and gnus-show-threads
11600 gnus-thread-hide-subtree)
11601 (gnus-summary-hide-all-threads
11602 (if (or (consp gnus-thread-hide-subtree)
11603 (functionp gnus-thread-hide-subtree))
11604 (gnus-make-predicate gnus-thread-hide-subtree)
11605 nil))))
11606
11607 ;;; Hiding predicates.
11608
11609 (defun gnus-article-unread-p (header)
11610 (memq (mail-header-number header) gnus-newsgroup-unreads))
11611
11612 (defun gnus-article-unseen-p (header)
11613 (memq (mail-header-number header) gnus-newsgroup-unseen))
11614
11615 (defun gnus-map-articles (predicate articles)
11616 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11617 (apply 'gnus-or (mapcar predicate
11618 (mapcar (lambda (number)
11619 (gnus-summary-article-header number))
11620 articles))))
11621
11622 (defun gnus-summary-hide-all-threads (&optional predicate)
11623 "Hide all thread subtrees.
11624 If PREDICATE is supplied, threads that satisfy this predicate
11625 will not be hidden."
11626 (interactive)
11627 (save-excursion
11628 (goto-char (point-min))
11629 (let ((end nil)
11630 (count 0))
11631 (while (not end)
11632 (incf count)
11633 (when (zerop (mod count 1000))
11634 (message "Hiding all threads... %d" count))
11635 (when (or (not predicate)
11636 (gnus-map-articles
11637 predicate (gnus-summary-article-children)))
11638 (gnus-summary-hide-thread))
11639 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11640 (gnus-summary-position-point))
11641
11642 (defun gnus-summary-hide-thread ()
11643 "Hide thread subtrees.
11644 If PREDICATE is supplied, threads that satisfy this predicate
11645 will not be hidden.
11646 Returns nil if no threads were there to be hidden."
11647 (interactive)
11648 (beginning-of-line)
11649 (let ((start (point))
11650 (starteol (line-end-position))
11651 (article (gnus-summary-article-number)))
11652 ;; Go forward until either the buffer ends or the subthread ends.
11653 (when (and (not (eobp))
11654 (or (zerop (gnus-summary-next-thread 1 t))
11655 (goto-char (point-max))))
11656 (if (and (> (point) start)
11657 ;; FIXME: this should actually search for a non-invisible \n.
11658 (search-backward "\n" start t))
11659 (progn
11660 (when (> (point) starteol)
11661 (gnus-remove-overlays starteol (point) 'invisible 'gnus-sum)
11662 (let ((ol (gnus-make-overlay starteol (point) nil t nil)))
11663 (gnus-overlay-put ol 'invisible 'gnus-sum)
11664 (gnus-overlay-put ol 'evaporate t)))
11665 (gnus-summary-goto-subject article)
11666 (when (> start (point))
11667 (message "Hiding the thread moved us backwards, aborting!")
11668 (goto-char (point-max))))
11669 (goto-char start)
11670 nil))))
11671
11672 (defun gnus-summary-go-to-next-thread (&optional previous)
11673 "Go to the same level (or less) next thread.
11674 If PREVIOUS is non-nil, go to previous thread instead.
11675 Return the article number moved to, or nil if moving was impossible."
11676 (let ((level (gnus-summary-thread-level))
11677 (way (if previous -1 1))
11678 (beg (point)))
11679 (forward-line way)
11680 (while (and (not (eobp))
11681 (< level (gnus-summary-thread-level)))
11682 (forward-line way))
11683 (if (eobp)
11684 (progn
11685 (goto-char beg)
11686 nil)
11687 (setq beg (point))
11688 (prog1
11689 (gnus-summary-article-number)
11690 (goto-char beg)))))
11691
11692 (defun gnus-summary-next-thread (n &optional silent)
11693 "Go to the same level next N'th thread.
11694 If N is negative, search backward instead.
11695 Returns the difference between N and the number of skips actually
11696 done.
11697
11698 If SILENT, don't output messages."
11699 (interactive "p")
11700 (let ((backward (< n 0))
11701 (n (abs n)))
11702 (while (and (> n 0)
11703 (gnus-summary-go-to-next-thread backward))
11704 (decf n))
11705 (unless silent
11706 (gnus-summary-position-point))
11707 (when (and (not silent) (/= 0 n))
11708 (gnus-message 7 "No more threads"))
11709 n))
11710
11711 (defun gnus-summary-prev-thread (n)
11712 "Go to the same level previous N'th thread.
11713 Returns the difference between N and the number of skips actually
11714 done."
11715 (interactive "p")
11716 (gnus-summary-next-thread (- n)))
11717
11718 (defun gnus-summary-go-down-thread ()
11719 "Go down one level in the current thread."
11720 (let ((children (gnus-summary-article-children)))
11721 (when children
11722 (gnus-summary-goto-subject (car children)))))
11723
11724 (defun gnus-summary-go-up-thread ()
11725 "Go up one level in the current thread."
11726 (let ((parent (gnus-summary-article-parent)))
11727 (when parent
11728 (gnus-summary-goto-subject parent))))
11729
11730 (defun gnus-summary-down-thread (n)
11731 "Go down thread N steps.
11732 If N is negative, go up instead.
11733 Returns the difference between N and how many steps down that were
11734 taken."
11735 (interactive "p")
11736 (let ((up (< n 0))
11737 (n (abs n)))
11738 (while (and (> n 0)
11739 (if up (gnus-summary-go-up-thread)
11740 (gnus-summary-go-down-thread)))
11741 (setq n (1- n)))
11742 (gnus-summary-position-point)
11743 (when (/= 0 n)
11744 (gnus-message 7 "Can't go further"))
11745 n))
11746
11747 (defun gnus-summary-up-thread (n)
11748 "Go up thread N steps.
11749 If N is negative, go down instead.
11750 Returns the difference between N and how many steps down that were
11751 taken."
11752 (interactive "p")
11753 (gnus-summary-down-thread (- n)))
11754
11755 (defun gnus-summary-top-thread ()
11756 "Go to the top of the thread."
11757 (interactive)
11758 (while (gnus-summary-go-up-thread))
11759 (gnus-summary-article-number))
11760
11761 (defun gnus-summary-expire-thread ()
11762 "Mark articles under current thread as expired."
11763 (interactive)
11764 (gnus-summary-kill-thread 0))
11765
11766 (defun gnus-summary-kill-thread (&optional unmark)
11767 "Mark articles under current thread as read.
11768 If the prefix argument is positive, remove any kinds of marks.
11769 If the prefix argument is zero, mark thread as expired.
11770 If the prefix argument is negative, tick articles instead."
11771 (interactive "P")
11772 (when unmark
11773 (setq unmark (prefix-numeric-value unmark)))
11774 (let ((articles (gnus-summary-articles-in-thread))
11775 (hide (or (null unmark) (= unmark 0))))
11776 (save-excursion
11777 ;; Expand the thread.
11778 (gnus-summary-show-thread)
11779 ;; Mark all the articles.
11780 (while articles
11781 (gnus-summary-goto-subject (car articles))
11782 (cond ((null unmark)
11783 (gnus-summary-mark-article-as-read gnus-killed-mark))
11784 ((> unmark 0)
11785 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11786 ((= unmark 0)
11787 (gnus-summary-mark-article nil gnus-expirable-mark))
11788 (t
11789 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11790 (setq articles (cdr articles))))
11791 ;; Hide killed subtrees when hide is true.
11792 (and hide
11793 gnus-thread-hide-killed
11794 (gnus-summary-hide-thread))
11795 ;; If hide is t, go to next unread subject.
11796 (when hide
11797 ;; Go to next unread subject.
11798 (gnus-summary-next-subject 1 t)))
11799 (gnus-set-mode-line 'summary))
11800
11801 ;; Summary sorting commands
11802
11803 (defun gnus-summary-sort-by-number (&optional reverse)
11804 "Sort the summary buffer by article number.
11805 Argument REVERSE means reverse order."
11806 (interactive "P")
11807 (gnus-summary-sort 'number reverse))
11808
11809 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11810 "Sort the summary buffer by most recent article number.
11811 Argument REVERSE means reverse order."
11812 (interactive "P")
11813 (gnus-summary-sort 'most-recent-number reverse))
11814
11815 (defun gnus-summary-sort-by-random (&optional reverse)
11816 "Randomize the order in the summary buffer.
11817 Argument REVERSE means to randomize in reverse order."
11818 (interactive "P")
11819 (gnus-summary-sort 'random reverse))
11820
11821 (defun gnus-summary-sort-by-author (&optional reverse)
11822 "Sort the summary buffer by author name alphabetically.
11823 If `case-fold-search' is non-nil, case of letters is ignored.
11824 Argument REVERSE means reverse order."
11825 (interactive "P")
11826 (gnus-summary-sort 'author reverse))
11827
11828 (defun gnus-summary-sort-by-recipient (&optional reverse)
11829 "Sort the summary buffer by recipient name alphabetically.
11830 If `case-fold-search' is non-nil, case of letters is ignored.
11831 Argument REVERSE means reverse order."
11832 (interactive "P")
11833 (gnus-summary-sort 'recipient reverse))
11834
11835 (defun gnus-summary-sort-by-subject (&optional reverse)
11836 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11837 If `case-fold-search' is non-nil, case of letters is ignored.
11838 Argument REVERSE means reverse order."
11839 (interactive "P")
11840 (gnus-summary-sort 'subject reverse))
11841
11842 (defun gnus-summary-sort-by-date (&optional reverse)
11843 "Sort the summary buffer by date.
11844 Argument REVERSE means reverse order."
11845 (interactive "P")
11846 (gnus-summary-sort 'date reverse))
11847
11848 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11849 "Sort the summary buffer by most recent date.
11850 Argument REVERSE means reverse order."
11851 (interactive "P")
11852 (gnus-summary-sort 'most-recent-date reverse))
11853
11854 (defun gnus-summary-sort-by-score (&optional reverse)
11855 "Sort the summary buffer by score.
11856 Argument REVERSE means reverse order."
11857 (interactive "P")
11858 (gnus-summary-sort 'score reverse))
11859
11860 (defun gnus-summary-sort-by-lines (&optional reverse)
11861 "Sort the summary buffer by the number of lines.
11862 Argument REVERSE means reverse order."
11863 (interactive "P")
11864 (gnus-summary-sort 'lines reverse))
11865
11866 (defun gnus-summary-sort-by-chars (&optional reverse)
11867 "Sort the summary buffer by article length.
11868 Argument REVERSE means reverse order."
11869 (interactive "P")
11870 (gnus-summary-sort 'chars reverse))
11871
11872 (defun gnus-summary-sort-by-original (&optional reverse)
11873 "Sort the summary buffer using the default sorting method.
11874 Argument REVERSE means reverse order."
11875 (interactive "P")
11876 (let* ((inhibit-read-only t)
11877 (gnus-summary-prepare-hook nil))
11878 ;; We do the sorting by regenerating the threads.
11879 (gnus-summary-prepare)
11880 ;; Hide subthreads if needed.
11881 (gnus-summary-maybe-hide-threads)))
11882
11883 (defun gnus-summary-sort (predicate reverse)
11884 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11885 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11886 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11887 (gnus-thread-sort-functions
11888 (if (not reverse)
11889 thread
11890 `(lambda (t1 t2)
11891 (,thread t2 t1))))
11892 (gnus-sort-gathered-threads-function
11893 gnus-thread-sort-functions)
11894 (gnus-article-sort-functions
11895 (if (not reverse)
11896 article
11897 `(lambda (t1 t2)
11898 (,article t2 t1))))
11899 (inhibit-read-only t)
11900 (gnus-summary-prepare-hook nil))
11901 ;; We do the sorting by regenerating the threads.
11902 (gnus-summary-prepare)
11903 ;; Hide subthreads if needed.
11904 (gnus-summary-maybe-hide-threads)))
11905
11906 ;; Summary saving commands.
11907
11908 (defun gnus-summary-save-article (&optional n not-saved)
11909 "Save the current article using the default saver function.
11910 If N is a positive number, save the N next articles.
11911 If N is a negative number, save the N previous articles.
11912 If N is nil and any articles have been marked with the process mark,
11913 save those articles instead.
11914 The variable `gnus-default-article-saver' specifies the saver function.
11915
11916 If the optional second argument NOT-SAVED is non-nil, articles saved
11917 will not be marked as saved."
11918 (interactive "P")
11919 (require 'gnus-art)
11920 (let* ((articles (gnus-summary-work-articles n))
11921 (save-buffer (save-excursion
11922 (nnheader-set-temp-buffer " *Gnus Save*")))
11923 (num (length articles))
11924 ;; Whether to save decoded articles or raw articles.
11925 (decode (when gnus-article-save-coding-system
11926 (get gnus-default-article-saver :decode)))
11927 ;; When saving many articles in a single file, use the other
11928 ;; function to save articles other than the first one.
11929 (saver2 (get gnus-default-article-saver :function))
11930 (gnus-prompt-before-saving (if saver2
11931 t
11932 gnus-prompt-before-saving))
11933 (gnus-default-article-saver gnus-default-article-saver)
11934 header file)
11935 (dolist (article articles)
11936 (setq header (gnus-summary-article-header article))
11937 (if (not (vectorp header))
11938 ;; This is a pseudo-article.
11939 (if (assq 'name header)
11940 (gnus-copy-file (cdr (assq 'name header)))
11941 (gnus-message 1 "Article %d is unsavable" article))
11942 ;; This is a real article.
11943 (save-window-excursion
11944 (gnus-summary-select-article decode decode nil article)
11945 (gnus-summary-goto-subject article))
11946 (with-current-buffer save-buffer
11947 (erase-buffer)
11948 (insert-buffer-substring (if decode
11949 gnus-article-buffer
11950 gnus-original-article-buffer)))
11951 (setq file (gnus-article-save save-buffer file num))
11952 (gnus-summary-remove-process-mark article)
11953 (unless not-saved
11954 (gnus-summary-set-saved-mark article)))
11955 (when saver2
11956 (setq gnus-default-article-saver saver2
11957 saver2 nil)))
11958 (gnus-kill-buffer save-buffer)
11959 (gnus-summary-position-point)
11960 (gnus-set-mode-line 'summary)
11961 n))
11962
11963 (defun gnus-summary-pipe-output (&optional n sym)
11964 "Pipe the current article to a subprocess.
11965 If N is a positive number, pipe the N next articles.
11966 If N is a negative number, pipe the N previous articles.
11967 If N is nil and any articles have been marked with the process mark,
11968 pipe those articles instead.
11969 The default command to which articles are piped is specified by the
11970 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
11971 will be prompted for the command.
11972
11973 The properties `:decode' and `:headers' that are put to the function
11974 symbol `gnus-summary-save-in-pipe' control whether this function
11975 decodes articles and what headers to keep (see the doc string for the
11976 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
11977 is neither omitted nor the symbol `r', force including all headers
11978 regardless of the `:headers' property. If it is the symbol `r',
11979 articles that are not decoded and include all headers will be piped
11980 no matter what the properties `:decode' and `:headers' are."
11981 (interactive (gnus-interactive "P\ny"))
11982 (require 'gnus-art)
11983 (let* ((articles (gnus-summary-work-articles n))
11984 (result-buffer "*Shell Command Output*")
11985 (all-headers (not (memq sym '(nil r))))
11986 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
11987 (raw (eq sym 'r))
11988 (headers (get 'gnus-summary-save-in-pipe :headers))
11989 command result)
11990 (unless (numberp (car articles))
11991 (error "No article to pipe"))
11992 (setq command (gnus-read-shell-command
11993 (concat "Shell command on "
11994 (if (cdr articles)
11995 (format "these %d articles" (length articles))
11996 "this article")
11997 ": ")
11998 gnus-summary-pipe-output-default-command))
11999 (when (string-equal command "")
12000 (error "A command is required"))
12001 (when all-headers
12002 (put 'gnus-summary-save-in-pipe :headers nil))
12003 (unwind-protect
12004 (while articles
12005 (gnus-summary-goto-subject (pop articles))
12006 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12007 (when (and (get-buffer result-buffer)
12008 (not (zerop (buffer-size (get-buffer result-buffer)))))
12009 (setq result (concat result (with-current-buffer result-buffer
12010 (buffer-string))))))
12011 (put 'gnus-summary-save-in-pipe :headers headers))
12012 (unless (zerop (length result))
12013 (if (with-current-buffer (get-buffer-create result-buffer)
12014 (erase-buffer)
12015 (insert result)
12016 (prog1
12017 (and (= (count-lines (point-min) (point)) 1)
12018 (progn
12019 (end-of-line 0)
12020 (<= (current-column)
12021 (window-width (minibuffer-window)))))
12022 (goto-char (point-min))))
12023 (message "%s" (substring result 0 -1))
12024 (message nil)
12025 (gnus-configure-windows 'pipe)))))
12026
12027 (defun gnus-summary-save-article-mail (&optional arg)
12028 "Append the current article to a Unix mail box file.
12029 If N is a positive number, save the N next articles.
12030 If N is a negative number, save the N previous articles.
12031 If N is nil and any articles have been marked with the process mark,
12032 save those articles instead."
12033 (interactive "P")
12034 (require 'gnus-art)
12035 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12036 (gnus-summary-save-article arg)))
12037
12038 (defun gnus-summary-save-article-rmail (&optional arg)
12039 "Append the current article to an rmail file.
12040 If N is a positive number, save the N next articles.
12041 If N is a negative number, save the N previous articles.
12042 If N is nil and any articles have been marked with the process mark,
12043 save those articles instead."
12044 (interactive "P")
12045 (require 'gnus-art)
12046 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12047 (gnus-summary-save-article arg)))
12048
12049 (defun gnus-summary-save-article-file (&optional arg)
12050 "Append the current article to a file.
12051 If N is a positive number, save the N next articles.
12052 If N is a negative number, save the N previous articles.
12053 If N is nil and any articles have been marked with the process mark,
12054 save those articles instead."
12055 (interactive "P")
12056 (require 'gnus-art)
12057 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12058 (gnus-summary-save-article arg)))
12059
12060 (defun gnus-summary-write-article-file (&optional arg)
12061 "Write the current article to a file, deleting the previous file.
12062 If N is a positive number, save the N next articles.
12063 If N is a negative number, save the N previous articles.
12064 If N is nil and any articles have been marked with the process mark,
12065 save those articles instead."
12066 (interactive "P")
12067 (require 'gnus-art)
12068 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12069 (gnus-summary-save-article arg)))
12070
12071 (defun gnus-summary-save-article-body-file (&optional arg)
12072 "Append the current article body to a file.
12073 If N is a positive number, save the N next articles.
12074 If N is a negative number, save the N previous articles.
12075 If N is nil and any articles have been marked with the process mark,
12076 save those articles instead."
12077 (interactive "P")
12078 (require 'gnus-art)
12079 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12080 (gnus-summary-save-article arg)))
12081
12082 (defun gnus-summary-write-article-body-file (&optional arg)
12083 "Write the current article body to a file, deleting the previous file.
12084 If N is a positive number, save the N next articles.
12085 If N is a negative number, save the N previous articles.
12086 If N is nil and any articles have been marked with the process mark,
12087 save those articles instead."
12088 (interactive "P")
12089 (require 'gnus-art)
12090 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12091 (gnus-summary-save-article arg)))
12092
12093 (defun gnus-summary-muttprint (&optional arg)
12094 "Print the current article using Muttprint.
12095 If N is a positive number, save the N next articles.
12096 If N is a negative number, save the N previous articles.
12097 If N is nil and any articles have been marked with the process mark,
12098 save those articles instead."
12099 (interactive "P")
12100 (require 'gnus-art)
12101 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12102 (gnus-summary-save-article arg t)))
12103
12104 (defun gnus-summary-pipe-message (program)
12105 "Pipe the current article through PROGRAM."
12106 (interactive "sProgram: ")
12107 (gnus-summary-select-article)
12108 (let ((mail-header-separator ""))
12109 (gnus-eval-in-buffer-window gnus-article-buffer
12110 (save-restriction
12111 (widen)
12112 (let ((start (window-start))
12113 (inhibit-read-only t))
12114 (message-pipe-buffer-body program)
12115 (set-window-start (get-buffer-window (current-buffer)) start))))))
12116
12117 (defun gnus-get-split-value (methods)
12118 "Return a value based on the split METHODS."
12119 (let (split-name method result match)
12120 (when methods
12121 (with-current-buffer gnus-original-article-buffer
12122 (save-restriction
12123 (nnheader-narrow-to-headers)
12124 (while (and methods (not split-name))
12125 (goto-char (point-min))
12126 (setq method (pop methods))
12127 (setq match (car method))
12128 (when (cond
12129 ((stringp match)
12130 ;; Regular expression.
12131 (ignore-errors
12132 (re-search-forward match nil t)))
12133 ((functionp match)
12134 ;; Function.
12135 (save-restriction
12136 (widen)
12137 (setq result (funcall match gnus-newsgroup-name))))
12138 ((consp match)
12139 ;; Form.
12140 (save-restriction
12141 (widen)
12142 (setq result (eval match)))))
12143 (setq split-name (cdr method))
12144 (cond ((stringp result)
12145 (push (expand-file-name
12146 result gnus-article-save-directory)
12147 split-name))
12148 ((consp result)
12149 (setq split-name (append result split-name)))))))))
12150 (nreverse split-name)))
12151
12152 (defun gnus-valid-move-group-p (group)
12153 (and (symbolp group)
12154 (boundp group)
12155 (symbol-name group)
12156 (symbol-value group)
12157 (gnus-get-function (gnus-find-method-for-group
12158 (symbol-name group)) 'request-accept-article t)))
12159
12160 (defun gnus-read-move-group-name (prompt default articles prefix)
12161 "Read a group name."
12162 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12163 (minibuffer-confirm-incomplete nil) ; XEmacs
12164 (prom
12165 (format "%s %s to"
12166 prompt
12167 (if (> (length articles) 1)
12168 (format "these %d articles" (length articles))
12169 "this article")))
12170 (to-newsgroup
12171 (cond
12172 ((null split-name)
12173 (gnus-group-completing-read
12174 prom
12175 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12176 nil prefix nil default))
12177 ((= 1 (length split-name))
12178 (gnus-group-completing-read
12179 prom
12180 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12181 nil prefix 'gnus-group-history (car split-name)))
12182 (t
12183 (gnus-completing-read
12184 prom (nreverse split-name) nil nil 'gnus-group-history))))
12185 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12186 encoded)
12187 (when to-newsgroup
12188 (if (or (string= to-newsgroup "")
12189 (string= to-newsgroup prefix))
12190 (setq to-newsgroup default))
12191 (unless to-newsgroup
12192 (error "No group name entered"))
12193 (setq encoded (mm-encode-coding-string
12194 to-newsgroup
12195 (gnus-group-name-charset to-method to-newsgroup)))
12196 (or (gnus-active encoded)
12197 (gnus-activate-group encoded nil nil to-method)
12198 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12199 to-newsgroup))
12200 (or (and (gnus-request-create-group encoded to-method)
12201 (gnus-activate-group encoded nil nil to-method)
12202 (gnus-subscribe-group encoded))
12203 (error "Couldn't create group %s" to-newsgroup)))
12204 (error "No such group: %s" to-newsgroup))
12205 encoded)))
12206
12207 (defvar gnus-summary-save-parts-counter)
12208 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12209
12210 (defun gnus-summary-save-parts (type dir n &optional reverse)
12211 "Save parts matching TYPE to DIR.
12212 If REVERSE, save parts that do not match TYPE."
12213 (interactive
12214 (list (read-string "Save parts of type: "
12215 (or (car gnus-summary-save-parts-type-history)
12216 gnus-summary-save-parts-default-mime)
12217 'gnus-summary-save-parts-type-history)
12218 (setq gnus-summary-save-parts-last-directory
12219 (read-directory-name "Save to directory: "
12220 gnus-summary-save-parts-last-directory
12221 nil t))
12222 current-prefix-arg))
12223 (gnus-summary-iterate n
12224 (let ((gnus-display-mime-function nil)
12225 gnus-article-prepare-hook
12226 gnus-article-decode-hook
12227 gnus-display-mime-function
12228 gnus-break-pages
12229 (gnus-inhibit-treatment t))
12230 (gnus-summary-select-article))
12231 (with-current-buffer gnus-article-buffer
12232 (let ((handles (or gnus-article-mime-handles
12233 (mm-dissect-buffer nil gnus-article-loose-mime)
12234 (and gnus-article-emulate-mime
12235 (mm-uu-dissect))))
12236 (gnus-summary-save-parts-counter 1))
12237 (when handles
12238 (gnus-summary-save-parts-1 type dir handles reverse)
12239 (unless gnus-article-mime-handles ;; Don't destroy this case.
12240 (mm-destroy-parts handles)))))))
12241
12242 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12243 (if (stringp (car handle))
12244 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12245 (cdr handle))
12246 (when (if reverse
12247 (not (string-match type (mm-handle-media-type handle)))
12248 (string-match type (mm-handle-media-type handle)))
12249 (let ((file (expand-file-name
12250 (gnus-map-function
12251 mm-file-name-rewrite-functions
12252 (file-name-nondirectory
12253 (or
12254 (mm-handle-filename handle)
12255 (format "%s.%d.%d" gnus-newsgroup-name
12256 (cdr gnus-article-current)
12257 gnus-summary-save-parts-counter))))
12258 dir)))
12259 (incf gnus-summary-save-parts-counter)
12260 (unless (file-exists-p file)
12261 (mm-save-part-to-file handle file))))))
12262
12263 ;; Summary extract commands
12264
12265 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12266 (let ((inhibit-read-only t)
12267 (article (gnus-summary-article-number))
12268 after-article b e)
12269 (unless (gnus-summary-goto-subject article)
12270 (error "No such article: %d" article))
12271 (gnus-summary-position-point)
12272 ;; If all commands are to be bunched up on one line, we collect
12273 ;; them here.
12274 (unless gnus-view-pseudos-separately
12275 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12276 files action)
12277 (while ps
12278 (setq action (cdr (assq 'action (car ps))))
12279 (setq files (list (cdr (assq 'name (car ps)))))
12280 (while (and ps (cdr ps)
12281 (string= (or action "1")
12282 (or (cdr (assq 'action (cadr ps))) "2")))
12283 (push (cdr (assq 'name (cadr ps))) files)
12284 (setcdr ps (cddr ps)))
12285 (when files
12286 (when (not (string-match "%s" action))
12287 (push " " files))
12288 (push " " files)
12289 (when (assq 'execute (car ps))
12290 (setcdr (assq 'execute (car ps))
12291 (funcall (if (string-match "%s" action)
12292 'format 'concat)
12293 action
12294 (mapconcat
12295 (lambda (f)
12296 (if (equal f " ")
12297 f
12298 (shell-quote-argument f)))
12299 files " ")))))
12300 (setq ps (cdr ps)))))
12301 (if (and gnus-view-pseudos (not not-view))
12302 (while pslist
12303 (when (assq 'execute (car pslist))
12304 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12305 (eq gnus-view-pseudos 'not-confirm)))
12306 (setq pslist (cdr pslist)))
12307 (save-excursion
12308 (while pslist
12309 (setq after-article (or (cdr (assq 'article (car pslist)))
12310 (gnus-summary-article-number)))
12311 (gnus-summary-goto-subject after-article)
12312 (forward-line 1)
12313 (setq b (point))
12314 (insert " " (file-name-nondirectory
12315 (cdr (assq 'name (car pslist))))
12316 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12317 (setq e (point))
12318 (forward-line -1) ; back to `b'
12319 (gnus-add-text-properties
12320 b (1- e) (list 'gnus-number gnus-reffed-article-number
12321 gnus-mouse-face-prop gnus-mouse-face))
12322 (gnus-data-enter
12323 after-article gnus-reffed-article-number
12324 gnus-unread-mark b (car pslist) 0 (- e b))
12325 (setq gnus-newsgroup-unreads
12326 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12327 gnus-reffed-article-number))
12328 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12329 (setq pslist (cdr pslist)))))))
12330
12331 (defun gnus-pseudos< (p1 p2)
12332 (let ((c1 (cdr (assq 'action p1)))
12333 (c2 (cdr (assq 'action p2))))
12334 (and c1 c2 (string< c1 c2))))
12335
12336 (defun gnus-request-pseudo-article (props)
12337 (cond ((assq 'execute props)
12338 (gnus-execute-command (cdr (assq 'execute props)))))
12339 (let ((gnus-current-article (gnus-summary-article-number)))
12340 (gnus-run-hooks 'gnus-mark-article-hook)))
12341
12342 (defun gnus-execute-command (command &optional automatic)
12343 (save-excursion
12344 (gnus-article-setup-buffer)
12345 (set-buffer gnus-article-buffer)
12346 (setq buffer-read-only nil)
12347 (let ((command (if automatic command
12348 (read-string "Command: " (cons command 0)))))
12349 (erase-buffer)
12350 (insert "$ " command "\n\n")
12351 (if gnus-view-pseudo-asynchronously
12352 (start-process "gnus-execute" (current-buffer) shell-file-name
12353 shell-command-switch command)
12354 (call-process shell-file-name nil t nil
12355 shell-command-switch command)))))
12356
12357 ;; Summary kill commands.
12358
12359 (defun gnus-summary-edit-global-kill (article)
12360 "Edit the \"global\" kill file."
12361 (interactive (list (gnus-summary-article-number)))
12362 (gnus-group-edit-global-kill article))
12363
12364 (defun gnus-summary-edit-local-kill ()
12365 "Edit a local kill file applied to the current newsgroup."
12366 (interactive)
12367 (setq gnus-current-headers (gnus-summary-article-header))
12368 (gnus-group-edit-local-kill
12369 (gnus-summary-article-number) gnus-newsgroup-name))
12370
12371 ;;; Header reading.
12372
12373 (defun gnus-read-header (id &optional header)
12374 "Read the headers of article ID and enter them into the Gnus system."
12375 (let ((group gnus-newsgroup-name)
12376 (gnus-override-method
12377 (or
12378 gnus-override-method
12379 (and (gnus-news-group-p gnus-newsgroup-name)
12380 (car (gnus-refer-article-methods)))))
12381 where)
12382 ;; First we check to see whether the header in question is already
12383 ;; fetched.
12384 (if (stringp id)
12385 ;; This is a Message-ID.
12386 (setq header (or header (gnus-id-to-header id)))
12387 ;; This is an article number.
12388 (setq header (or header (gnus-summary-article-header id))))
12389 (if (and header
12390 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12391 ;; We have found the header.
12392 header
12393 ;; We have to really fetch the header to this article.
12394 (with-current-buffer nntp-server-buffer
12395 (when (setq where (gnus-request-head id group))
12396 (nnheader-fold-continuation-lines)
12397 (goto-char (point-max))
12398 (insert ".\n")
12399 (goto-char (point-min))
12400 (insert "211 ")
12401 (princ (cond
12402 ((numberp id) id)
12403 ((cdr where) (cdr where))
12404 (header (mail-header-number header))
12405 (t gnus-reffed-article-number))
12406 (current-buffer))
12407 (insert " Article retrieved.\n"))
12408 (if (or (not where)
12409 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12410 () ; Malformed head.
12411 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12412 (when (and (bound-and-true-p gnus-registry-enabled)
12413 (not (gnus-ephemeral-group-p (car where))))
12414 (gnus-registry-handle-action
12415 (mail-header-id header) nil
12416 (gnus-group-prefixed-name (car where) gnus-override-method)
12417 (mail-header-subject header)
12418 (mail-header-from header)))
12419 (when (and (stringp id)
12420 (or
12421 (not (string= (gnus-group-real-name group)
12422 (car where)))
12423 (not (gnus-server-equal gnus-override-method
12424 (gnus-group-method group)))))
12425 ;; If we fetched by Message-ID and the article came from
12426 ;; a different group (or server), we fudge some bogus
12427 ;; article numbers for this article.
12428 (mail-header-set-number header gnus-reffed-article-number))
12429 (with-current-buffer gnus-summary-buffer
12430 (decf gnus-reffed-article-number)
12431 (gnus-remove-header (mail-header-number header))
12432 (push header gnus-newsgroup-headers)
12433 (setq gnus-current-headers header)
12434 (push (mail-header-number header) gnus-newsgroup-limit)))
12435 header)))))
12436
12437 (defun gnus-remove-header (number)
12438 "Remove header NUMBER from `gnus-newsgroup-headers'."
12439 (if (and gnus-newsgroup-headers
12440 (= number (mail-header-number (car gnus-newsgroup-headers))))
12441 (pop gnus-newsgroup-headers)
12442 (let ((headers gnus-newsgroup-headers))
12443 (while (and (cdr headers)
12444 (not (= number (mail-header-number (cadr headers)))))
12445 (pop headers))
12446 (when (cdr headers)
12447 (setcdr headers (cddr headers))))))
12448
12449 ;;;
12450 ;;; summary highlights
12451 ;;;
12452
12453 (defun gnus-highlight-selected-summary ()
12454 "Highlight selected article in summary buffer."
12455 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12456 (when gnus-summary-selected-face
12457 (save-excursion
12458 (let* ((beg (point-at-bol))
12459 (end (point-at-eol))
12460 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12461 (from (if (get-text-property beg gnus-mouse-face-prop)
12462 beg
12463 (or (next-single-property-change
12464 beg gnus-mouse-face-prop nil end)
12465 beg)))
12466 (to
12467 (if (= from end)
12468 (- from 2)
12469 (or (next-single-property-change
12470 from gnus-mouse-face-prop nil end)
12471 end))))
12472 ;; If no mouse-face prop on line we will have to = from = end,
12473 ;; so we highlight the entire line instead.
12474 (when (= (+ to 2) from)
12475 (setq from beg)
12476 (setq to end))
12477 (if gnus-newsgroup-selected-overlay
12478 ;; Move old overlay.
12479 (gnus-move-overlay
12480 gnus-newsgroup-selected-overlay from to (current-buffer))
12481 ;; Create new overlay.
12482 (gnus-overlay-put
12483 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
12484 'face gnus-summary-selected-face))))))
12485
12486 (defvar gnus-summary-highlight-line-cached nil)
12487 (defvar gnus-summary-highlight-line-trigger nil)
12488
12489 (defun gnus-summary-highlight-line-0 ()
12490 (if (and (eq gnus-summary-highlight-line-trigger
12491 gnus-summary-highlight)
12492 gnus-summary-highlight-line-cached)
12493 gnus-summary-highlight-line-cached
12494 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12495 gnus-summary-highlight-line-cached
12496 (let* ((cond (list 'cond))
12497 (c cond)
12498 (list gnus-summary-highlight))
12499 (while list
12500 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12501 nil))
12502 (setq c (cdr c)
12503 list (cdr list)))
12504 (gnus-byte-compile (list 'lambda nil cond))))))
12505
12506 (defun gnus-summary-highlight-line ()
12507 "Highlight current line according to `gnus-summary-highlight'."
12508 (let* ((beg (point-at-bol))
12509 (article (or (gnus-summary-article-number) gnus-current-article))
12510 (score (or (cdr (assq article
12511 gnus-newsgroup-scored))
12512 gnus-summary-default-score 0))
12513 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12514 (inhibit-read-only t)
12515 (default gnus-summary-default-score)
12516 (default-high gnus-summary-default-high-score)
12517 (default-low gnus-summary-default-low-score)
12518 (uncached (and gnus-summary-use-undownloaded-faces
12519 (memq article gnus-newsgroup-undownloaded)
12520 (not (memq article gnus-newsgroup-cached)))))
12521 (let ((face (funcall (gnus-summary-highlight-line-0))))
12522 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12523 (gnus-put-text-property-excluding-characters-with-faces
12524 beg (point-at-eol) 'face
12525 (setq face (if (boundp face) (symbol-value face) face)))
12526 (when gnus-summary-highlight-line-function
12527 (funcall gnus-summary-highlight-line-function article face))))))
12528
12529 (defun gnus-update-read-articles (group unread &optional compute)
12530 "Update the list of read articles in GROUP.
12531 UNREAD is a sorted list."
12532 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12533 (info (gnus-get-info group))
12534 (prev 1)
12535 read)
12536 (if (or (not info) (not active))
12537 ;; There is no info on this group if it was, in fact,
12538 ;; killed. Gnus stores no information on killed groups, so
12539 ;; there's nothing to be done.
12540 ;; One could store the information somewhere temporarily,
12541 ;; perhaps... Hmmm...
12542 ()
12543 ;; Remove any negative articles numbers.
12544 (while (and unread (< (car unread) 0))
12545 (setq unread (cdr unread)))
12546 ;; Remove any expired article numbers
12547 (while (and unread (< (car unread) (car active)))
12548 (setq unread (cdr unread)))
12549 ;; Compute the ranges of read articles by looking at the list of
12550 ;; unread articles.
12551 (while unread
12552 (when (/= (car unread) prev)
12553 (push (if (= prev (1- (car unread))) prev
12554 (cons prev (1- (car unread))))
12555 read))
12556 (setq prev (1+ (car unread)))
12557 (setq unread (cdr unread)))
12558 (when (<= prev (cdr active))
12559 (push (cons prev (cdr active)) read))
12560 (setq read (if (> (length read) 1) (nreverse read) read))
12561 (if compute
12562 read
12563 (save-excursion
12564 (let (setmarkundo)
12565 ;; Propagate the read marks to the backend.
12566 (when (and (gnus-method-option-p
12567 (gnus-find-method-for-group group)
12568 'server-marks)
12569 (gnus-check-backend-function 'request-set-mark group))
12570 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12571 (add (gnus-remove-from-range read (gnus-info-read info))))
12572 (when (or add del)
12573 (unless (gnus-check-group group)
12574 (error "Can't open server for %s" group))
12575 (gnus-request-set-mark
12576 group (delq nil (list (if add (list add 'add '(read)))
12577 (if del (list del 'del '(read))))))
12578 (setq setmarkundo
12579 `(gnus-request-set-mark
12580 ,group
12581 ',(delq nil (list
12582 (if del (list del 'add '(read)))
12583 (if add (list add 'del '(read))))))))))
12584 (set-buffer gnus-group-buffer)
12585 (gnus-undo-register
12586 `(progn
12587 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12588 (gnus-info-set-read ',info ',(gnus-info-read info))
12589 (gnus-get-unread-articles-in-group ',info
12590 (gnus-active ,group))
12591 (gnus-group-update-group ,group t)
12592 ,setmarkundo))))
12593 ;; Enter this list into the group info.
12594 (gnus-info-set-read info read)
12595 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12596 (gnus-get-unread-articles-in-group info (gnus-active group))
12597 t))))
12598
12599 (defun gnus-offer-save-summaries ()
12600 "Offer to save all active summary buffers."
12601 (let (buffers)
12602 ;; Go through all buffers and find all summaries.
12603 (dolist (buffer (buffer-list))
12604 (when (and (setq buffer (buffer-name buffer))
12605 (string-match "Summary" buffer)
12606 (with-current-buffer buffer
12607 ;; We check that this is, indeed, a summary buffer.
12608 (and (eq major-mode 'gnus-summary-mode)
12609 ;; Also make sure this isn't bogus.
12610 gnus-newsgroup-prepared
12611 ;; Also make sure that this isn't a
12612 ;; dead summary buffer.
12613 (not gnus-dead-summary-mode))))
12614 (push buffer buffers)))
12615 ;; Go through all these summary buffers and offer to save them.
12616 (when buffers
12617 (save-excursion
12618 (if (eq gnus-interactive-exit 'quiet)
12619 (dolist (buffer buffers)
12620 (switch-to-buffer buffer)
12621 (gnus-summary-exit))
12622 (map-y-or-n-p
12623 "Update summary buffer %s? "
12624 (lambda (buf)
12625 (switch-to-buffer buf)
12626 (gnus-summary-exit))
12627 buffers))))))
12628
12629 (defun gnus-summary-setup-default-charset ()
12630 "Setup newsgroup default charset."
12631 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12632 (setq gnus-newsgroup-charset nil)
12633 (let* ((ignored-charsets
12634 (or gnus-newsgroup-ephemeral-ignored-charsets
12635 (append
12636 (and gnus-newsgroup-name
12637 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12638 gnus-newsgroup-ignored-charsets))))
12639 (setq gnus-newsgroup-charset
12640 (or gnus-newsgroup-ephemeral-charset
12641 (and gnus-newsgroup-name
12642 (gnus-parameter-charset gnus-newsgroup-name))
12643 gnus-default-charset))
12644 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12645 ignored-charsets))))
12646
12647 ;;;
12648 ;;; Mime Commands
12649 ;;;
12650
12651 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12652 "Display the current article buffer fully MIME-buttonized.
12653 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12654 treated as multipart/mixed."
12655 (interactive "P")
12656 (require 'gnus-art)
12657 (let ((gnus-unbuttonized-mime-types nil)
12658 (gnus-mime-display-multipart-as-mixed show-all-parts))
12659 (gnus-summary-show-article)))
12660
12661 (defun gnus-summary-repair-multipart (article)
12662 "Add a Content-Type header to a multipart article without one."
12663 (interactive (list (gnus-summary-article-number)))
12664 (gnus-with-article article
12665 (message-narrow-to-head)
12666 (message-remove-header "Mime-Version")
12667 (goto-char (point-max))
12668 (insert "Mime-Version: 1.0\n")
12669 (widen)
12670 (when (search-forward "\n--" nil t)
12671 (let ((separator (buffer-substring (point) (point-at-eol))))
12672 (message-narrow-to-head)
12673 (message-remove-header "Content-Type")
12674 (goto-char (point-max))
12675 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12676 separator))
12677 (widen))))
12678 (let (gnus-mark-article-hook)
12679 (gnus-summary-select-article t t nil article)))
12680
12681 (defun gnus-summary-toggle-display-buttonized ()
12682 "Toggle the buttonizing of the article buffer."
12683 (interactive)
12684 (require 'gnus-art)
12685 (if (setq gnus-inhibit-mime-unbuttonizing
12686 (not gnus-inhibit-mime-unbuttonizing))
12687 (let ((gnus-unbuttonized-mime-types nil))
12688 (gnus-summary-show-article))
12689 (gnus-summary-show-article)))
12690
12691 ;;;
12692 ;;; Generic summary marking commands
12693 ;;;
12694
12695 (defvar gnus-summary-marking-alist
12696 '((read gnus-del-mark "d")
12697 (unread gnus-unread-mark "u")
12698 (ticked gnus-ticked-mark "!")
12699 (dormant gnus-dormant-mark "?")
12700 (expirable gnus-expirable-mark "e"))
12701 "An alist of names/marks/keystrokes.")
12702
12703 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12704 (defvar gnus-summary-mark-map)
12705
12706 (defun gnus-summary-make-all-marking-commands ()
12707 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12708 (dolist (elem gnus-summary-marking-alist)
12709 (apply 'gnus-summary-make-marking-command elem)))
12710
12711 (defun gnus-summary-make-marking-command (name mark keystroke)
12712 (let ((map (make-sparse-keymap)))
12713 (define-key gnus-summary-generic-mark-map keystroke map)
12714 (dolist (lway `((next "next" next nil "n")
12715 (next-unread "next unread" next t "N")
12716 (prev "previous" prev nil "p")
12717 (prev-unread "previous unread" prev t "P")
12718 (nomove "" nil nil ,keystroke)))
12719 (let ((func (gnus-summary-make-marking-command-1
12720 mark (car lway) lway name)))
12721 (setq func (eval func))
12722 (define-key map (nth 4 lway) func)))))
12723
12724 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12725 `(defun ,(intern
12726 (format "gnus-summary-put-mark-as-%s%s"
12727 name (if (eq way 'nomove)
12728 ""
12729 (concat "-" (symbol-name way)))))
12730 (n)
12731 ,(format
12732 "Mark the current article as %s%s.
12733 If N, the prefix, then repeat N times.
12734 If N is negative, move in reverse order.
12735 The difference between N and the actual number of articles marked is
12736 returned."
12737 name (cadr lway))
12738 (interactive "p")
12739 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12740
12741 (defun gnus-summary-generic-mark (n mark move unread)
12742 "Mark N articles with MARK."
12743 (unless (eq major-mode 'gnus-summary-mode)
12744 (error "This command can only be used in the summary buffer"))
12745 (gnus-summary-show-thread)
12746 (let ((nummove
12747 (cond
12748 ((eq move 'next) 1)
12749 ((eq move 'prev) -1)
12750 (t 0))))
12751 (if (zerop nummove)
12752 (setq n 1)
12753 (when (< n 0)
12754 (setq n (abs n)
12755 nummove (* -1 nummove))))
12756 (while (and (> n 0)
12757 (gnus-summary-mark-article nil mark)
12758 (zerop (gnus-summary-next-subject nummove unread t)))
12759 (setq n (1- n)))
12760 (when (/= 0 n)
12761 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12762 (gnus-summary-recenter)
12763 (gnus-summary-position-point)
12764 (gnus-set-mode-line 'summary)
12765 n))
12766
12767 (defun gnus-summary-insert-articles (articles)
12768 (when (setq articles
12769 (gnus-sorted-difference articles
12770 (mapcar (lambda (h)
12771 (mail-header-number h))
12772 gnus-newsgroup-headers)))
12773 (setq gnus-newsgroup-headers
12774 (gnus-merge 'list
12775 gnus-newsgroup-headers
12776 (gnus-fetch-headers articles)
12777 'gnus-article-sort-by-number))
12778 (setq gnus-newsgroup-articles
12779 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12780 ;; Suppress duplicates?
12781 (when gnus-suppress-duplicates
12782 (gnus-dup-suppress-articles))
12783
12784 (if (and gnus-fetch-old-headers
12785 (eq gnus-headers-retrieved-by 'nov))
12786 ;; We might want to build some more threads first.
12787 (if (eq gnus-fetch-old-headers 'invisible)
12788 (gnus-build-all-threads)
12789 (gnus-build-old-threads))
12790 ;; Mark the inserted articles that are unread as unread.
12791 (setq gnus-newsgroup-unreads
12792 (gnus-sorted-nunion
12793 gnus-newsgroup-unreads
12794 (gnus-sorted-nintersection
12795 (gnus-list-of-unread-articles gnus-newsgroup-name)
12796 articles)))
12797 ;; Mark the inserted articles as selected so that the information
12798 ;; of the marks having been changed by a user may be updated when
12799 ;; exiting this group. See `gnus-summary-update-info'.
12800 (dolist (art articles)
12801 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12802 ;; Let the Gnus agent mark articles as read.
12803 (when gnus-agent
12804 (gnus-agent-get-undownloaded-list))
12805 ;; Remove list identifiers from subject
12806 (gnus-summary-remove-list-identifiers)
12807 ;; First and last article in this newsgroup.
12808 (when gnus-newsgroup-headers
12809 (setq gnus-newsgroup-begin
12810 (mail-header-number (car gnus-newsgroup-headers))
12811 gnus-newsgroup-end
12812 (mail-header-number
12813 (gnus-last-element gnus-newsgroup-headers))))
12814 (when gnus-use-scoring
12815 (gnus-possibly-score-headers))))
12816
12817 (defun gnus-summary-insert-old-articles (&optional all)
12818 "Insert all old articles in this group.
12819 If ALL is non-nil, already read articles become readable.
12820 If ALL is a number, fetch this number of articles."
12821 (interactive "P")
12822 (prog1
12823 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12824 older len)
12825 (setq older
12826 ;; Some nntp servers lie about their active range. When
12827 ;; this happens, the active range can be in the millions.
12828 ;; Use a compressed range to avoid creating a huge list.
12829 (gnus-range-difference (list gnus-newsgroup-active) old))
12830 (setq len (gnus-range-length older))
12831 (cond
12832 ((null older) nil)
12833 ((numberp all)
12834 (if (< all len)
12835 (let ((older-range (nreverse older)))
12836 (setq older nil)
12837
12838 (while (> all 0)
12839 (let* ((r (pop older-range))
12840 (min (if (numberp r) r (car r)))
12841 (max (if (numberp r) r (cdr r))))
12842 (while (and (<= min max)
12843 (> all 0))
12844 (push max older)
12845 (setq all (1- all)
12846 max (1- max))))))
12847 (setq older (gnus-uncompress-range older))))
12848 (all
12849 (setq older (gnus-uncompress-range older)))
12850 (t
12851 (when (and (numberp gnus-large-newsgroup)
12852 (> len gnus-large-newsgroup))
12853 (let* ((cursor-in-echo-area nil)
12854 (initial (gnus-parameter-large-newsgroup-initial
12855 gnus-newsgroup-name))
12856 (input
12857 (read-string
12858 (format
12859 "How many articles from %s (%s %d): "
12860 (gnus-group-decoded-name gnus-newsgroup-name)
12861 (if initial "max" "default")
12862 len)
12863 nil nil
12864 (and initial
12865 (number-to-string initial)))))
12866 (unless (string-match "^[ \t]*$" input)
12867 (setq all (string-to-number input))
12868 (if (< all len)
12869 (let ((older-range (nreverse older)))
12870 (setq older nil)
12871
12872 (while (> all 0)
12873 (let* ((r (pop older-range))
12874 (min (if (numberp r) r (car r)))
12875 (max (if (numberp r) r (cdr r))))
12876 (while (and (<= min max)
12877 (> all 0))
12878 (push max older)
12879 (setq all (1- all)
12880 max (1- max))))))))))
12881 (setq older (gnus-uncompress-range older))))
12882 (if (not older)
12883 (message "No old news.")
12884 (gnus-summary-insert-articles older)
12885 (gnus-summary-limit (gnus-sorted-nunion old older))))
12886 (gnus-summary-position-point)))
12887
12888 (defun gnus-summary-insert-new-articles ()
12889 "Insert all new articles in this group."
12890 (interactive)
12891 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12892 (old-high gnus-newsgroup-highest)
12893 (nnmail-fetched-sources (list t))
12894 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12895 i new)
12896 (unless new-active
12897 (error "Couldn't fetch new data"))
12898 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12899 (setq i (cdr gnus-newsgroup-active)
12900 gnus-newsgroup-highest i)
12901 (while (> i old-high)
12902 (push i new)
12903 (decf i))
12904 (if (not new)
12905 (message "No gnus is bad news")
12906 (gnus-summary-insert-articles new)
12907 (setq gnus-newsgroup-unreads
12908 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12909 (gnus-summary-limit (gnus-sorted-nunion old new))))
12910 (gnus-summary-position-point))
12911
12912 ;;; Bookmark support for Gnus.
12913 (declare-function bookmark-make-record-default
12914 "bookmark" (&optional no-file no-context posn))
12915 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12916 (declare-function bookmark-default-handler "bookmark" (bmk))
12917 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12918 (defvar bookmark-yank-point)
12919 (defvar bookmark-current-buffer)
12920
12921 (defun gnus-summary-bookmark-make-record ()
12922 "Make a bookmark entry for a Gnus summary buffer."
12923 (let (pos buf)
12924 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12925 (save-restriction ; FIXME is it necessary to widen?
12926 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12927 (setq buf "art") ; We are recording bookmark from article buffer.
12928 (setq bookmark-yank-point (point))
12929 (setq bookmark-current-buffer (current-buffer))
12930 (gnus-article-show-summary)) ; Go back in summary buffer.
12931 ;; We are now recording bookmark from summary buffer.
12932 (unless buf (setq buf "sum"))
12933 (let* ((subject (elt (gnus-summary-article-header) 1))
12934 (grp (car gnus-article-current))
12935 (art (cdr gnus-article-current))
12936 (head (gnus-summary-article-header art))
12937 (id (mail-header-id head)))
12938 `(,subject
12939 ,@(condition-case nil
12940 (bookmark-make-record-default 'no-file 'no-context pos)
12941 (wrong-number-of-arguments
12942 (bookmark-make-record-default 'point-only)))
12943 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
12944 (group . ,grp) (article . ,art)
12945 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
12946
12947 ;;;###autoload
12948 (defun gnus-summary-bookmark-jump (bookmark)
12949 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
12950 BOOKMARK is a bookmark name or a bookmark record."
12951 (let ((group (bookmark-prop-get bookmark 'group))
12952 (article (bookmark-prop-get bookmark 'article))
12953 (id (bookmark-prop-get bookmark 'message-id))
12954 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
12955 (gnus-fetch-group group (list article))
12956 (gnus-summary-insert-cached-articles)
12957 (gnus-summary-goto-article id nil 'force)
12958 ;; FIXME we have to wait article buffer is ready (only large buffer)
12959 ;; Is there a better solution to know that?
12960 ;; If we don't wait `bookmark-default-handler' will have no chance
12961 ;; to set position. However there is no error, just wrong pos.
12962 (sit-for 1)
12963 (when (string= buf "Gnus-art")
12964 (other-window 1))
12965 (bookmark-default-handler
12966 `(""
12967 (buffer . ,(current-buffer))
12968 . ,(bookmark-get-bookmark-record bookmark)))))
12969
12970 (gnus-summary-make-all-marking-commands)
12971
12972 (gnus-ems-redefine)
12973
12974 (provide 'gnus-sum)
12975
12976 (run-hooks 'gnus-sum-load-hook)
12977
12978 ;; Local Variables:
12979 ;; coding: iso-8859-1
12980 ;; End:
12981
12982 ;;; gnus-sum.el ends here