]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Remove Gnus compat names for mouse bindings
[gnu-emacs] / lisp / gnus / gnus-sum.el
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2
3 ;; Copyright (C) 1996-2016 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 (eval-when-compile
28 (require 'cl))
29 (eval-when-compile
30 (when (featurep 'xemacs)
31 (require 'easy-mmode))) ; for `define-minor-mode'
32
33 (defvar tool-bar-mode)
34 (defvar gnus-tmp-header)
35
36 (require 'gnus)
37 (require 'gnus-group)
38 (require 'gnus-spec)
39 (require 'gnus-range)
40 (require 'gnus-int)
41 (require 'gnus-undo)
42 (require 'gnus-util)
43 (require 'gmm-utils)
44 (require 'mm-decode)
45 (require 'nnoo)
46
47 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
48 (autoload 'gnus-cache-write-active "gnus-cache")
49 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
50 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
51 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
52 (autoload 'mm-uu-dissect "mm-uu")
53 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
54 "Deuglify broken Outlook (Express) articles and redisplay."
55 t)
56 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
57 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
58 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
59 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
60 (autoload 'nnir-article-group "nnir" nil nil 'macro)
61
62 (defcustom gnus-kill-summary-on-exit t
63 "*If non-nil, kill the summary buffer when you exit from it.
64 If nil, the summary will become a \"*Dead Summary*\" buffer, and
65 it will be killed sometime later."
66 :group 'gnus-summary-exit
67 :type 'boolean)
68
69 (defcustom gnus-summary-next-group-on-exit t
70 "If non-nil, go to the next unread newsgroup on summary exit.
71 See `gnus-group-goto-unread'."
72 :link '(custom-manual "(gnus)Group Maneuvering")
73 :group 'gnus-summary-exit
74 :version "23.1" ;; No Gnus
75 :type 'boolean)
76
77 (defcustom gnus-summary-stop-at-end-of-message nil
78 "If non-nil, don't select the next message when using `SPC'."
79 :link '(custom-manual "(gnus)Group Maneuvering")
80 :group 'gnus-summary-maneuvering
81 :version "24.1"
82 :type 'boolean)
83
84 (defcustom gnus-fetch-old-headers nil
85 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
86 If an unread article in the group refers to an older, already
87 read (or just marked as read) article, the old article will not
88 normally be displayed in the Summary buffer. If this variable is
89 t, Gnus will attempt to grab the headers to the old articles, and
90 thereby build complete threads. If it has the value `some', all
91 old headers will be fetched but only enough headers to connect
92 otherwise loose threads will be displayed. This variable can
93 also be a number. In that case, no more than that number of old
94 headers will be fetched. If it has the value `invisible', all
95 old headers will be fetched, but none will be displayed.
96
97 The server has to support NOV for any of this to work.
98
99 This feature can seriously impact performance it ignores all
100 locally cached header entries. Setting it to t for groups for a
101 server that doesn't expire articles (such as news.gmane.org),
102 leads to very slow summary generation."
103 :group 'gnus-thread
104 :type '(choice (const :tag "off" nil)
105 (const :tag "on" t)
106 (const some)
107 (const invisible)
108 number
109 (sexp :menu-tag "other" t)))
110
111 (defcustom gnus-refer-thread-limit 500
112 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
113 If t, fetch all the available old headers."
114 :group 'gnus-thread
115 :type '(choice number
116 (sexp :menu-tag "other" t)))
117
118 (defcustom gnus-refer-thread-use-nnir nil
119 "*Use nnir to search an entire server when referring threads. A
120 nil value will only search for thread-related articles in the
121 current group."
122 :version "24.1"
123 :group 'gnus-thread
124 :type 'boolean)
125
126 (defcustom gnus-summary-make-false-root 'adopt
127 "*nil means that Gnus won't gather loose threads.
128 If the root of a thread has expired or been read in a previous
129 session, the information necessary to build a complete thread has been
130 lost. Instead of having many small sub-threads from this original thread
131 scattered all over the summary buffer, Gnus can gather them.
132
133 If non-nil, Gnus will try to gather all loose sub-threads from an
134 original thread into one large thread.
135
136 If this variable is non-nil, it should be one of `none', `adopt',
137 `dummy' or `empty'.
138
139 If this variable is `none', Gnus will not make a false root, but just
140 present the sub-threads after another.
141 If this variable is `dummy', Gnus will create a dummy root that will
142 have all the sub-threads as children.
143 If this variable is `adopt', Gnus will make one of the \"children\"
144 the parent and mark all the step-children as such.
145 If this variable is `empty', the \"children\" are printed with empty
146 subject fields. (Or rather, they will be printed with a string
147 given by the `gnus-summary-same-subject' variable.)"
148 :group 'gnus-thread
149 :type '(choice (const :tag "off" nil)
150 (const none)
151 (const dummy)
152 (const adopt)
153 (const empty)))
154
155 (defcustom gnus-summary-make-false-root-always nil
156 "Always make a false dummy root."
157 :version "22.1"
158 :group 'gnus-thread
159 :type 'boolean)
160
161 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
162 "*A regexp to match subjects to be excluded from loose thread gathering.
163 As loose thread gathering is done on subjects only, that means that
164 there can be many false gatherings performed. By rooting out certain
165 common subjects, gathering might become saner."
166 :group 'gnus-thread
167 :type 'regexp)
168
169 (defcustom gnus-summary-gather-subject-limit nil
170 "*Maximum length of subject comparisons when gathering loose threads.
171 Use nil to compare full subjects. Setting this variable to a low
172 number will help gather threads that have been corrupted by
173 newsreaders chopping off subject lines, but it might also mean that
174 unrelated articles that have subject that happen to begin with the
175 same few characters will be incorrectly gathered.
176
177 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
178 comparing subjects."
179 :group 'gnus-thread
180 :type '(choice (const :tag "off" nil)
181 (const fuzzy)
182 (sexp :menu-tag "on" t)))
183
184 (defcustom gnus-simplify-subject-functions nil
185 "List of functions taking a string argument that simplify subjects.
186 The functions are applied recursively.
187
188 Useful functions to put in this list include:
189 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
190 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
191 :group 'gnus-thread
192 :type '(repeat function))
193
194 (defcustom gnus-simplify-ignored-prefixes nil
195 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
196 :group 'gnus-thread
197 :type '(choice (const :tag "off" nil)
198 regexp))
199
200 (defcustom gnus-build-sparse-threads nil
201 "*If non-nil, fill in the gaps in threads.
202 If `some', only fill in the gaps that are needed to tie loose threads
203 together. If `more', fill in all leaf nodes that Gnus can find. If
204 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
205 :group 'gnus-thread
206 :type '(choice (const :tag "off" nil)
207 (const some)
208 (const more)
209 (sexp :menu-tag "all" t)))
210
211 (defcustom gnus-summary-thread-gathering-function
212 'gnus-gather-threads-by-subject
213 "*Function used for gathering loose threads.
214 There are two pre-defined functions: `gnus-gather-threads-by-subject',
215 which only takes Subjects into consideration; and
216 `gnus-gather-threads-by-references', which compared the References
217 headers of the articles to find matches."
218 :group 'gnus-thread
219 :type '(radio (function-item gnus-gather-threads-by-subject)
220 (function-item gnus-gather-threads-by-references)
221 (function :tag "other")))
222
223 (defcustom gnus-summary-same-subject ""
224 "*String indicating that the current article has the same subject as the previous.
225 This variable will only be used if the value of
226 `gnus-summary-make-false-root' is `empty'."
227 :group 'gnus-summary-format
228 :type 'string)
229
230 (defcustom gnus-summary-goto-unread nil
231 "*If t, many commands will go to the next unread article.
232 This applies to marking commands as well as other commands that
233 \"naturally\" select the next article, like, for instance, `SPC' at
234 the end of an article.
235
236 If nil, the marking commands do NOT go to the next unread article
237 \(they go to the next article instead). If `never', commands that
238 usually go to the next unread article, will go to the next article,
239 whether it is read or not."
240 :version "24.1"
241 :group 'gnus-summary-marks
242 :link '(custom-manual "(gnus)Setting Marks")
243 :type '(choice (const :tag "off" nil)
244 (const never)
245 (sexp :menu-tag "on" t)))
246
247 (defcustom gnus-summary-default-score 0
248 "*Default article score level.
249 All scores generated by the score files will be added to this score.
250 If this variable is nil, scoring will be disabled."
251 :group 'gnus-score-default
252 :type '(choice (const :tag "disable")
253 integer))
254
255 (defcustom gnus-summary-default-high-score 0
256 "*Default threshold for a high scored article.
257 An article will be highlighted as high scored if its score is greater
258 than this score."
259 :version "22.1"
260 :group 'gnus-score-default
261 :type 'integer)
262
263 (defcustom gnus-summary-default-low-score 0
264 "*Default threshold for a low scored article.
265 An article will be highlighted as low scored if its score is smaller
266 than this score."
267 :version "22.1"
268 :group 'gnus-score-default
269 :type 'integer)
270
271 (defcustom gnus-summary-zcore-fuzz 0
272 "*Fuzziness factor for the zcore in the summary buffer.
273 Articles with scores closer than this to `gnus-summary-default-score'
274 will not be marked."
275 :group 'gnus-summary-format
276 :type 'integer)
277
278 (defcustom gnus-simplify-subject-fuzzy-regexp nil
279 "*Strings to be removed when doing fuzzy matches.
280 This can either be a regular expression or list of regular expressions
281 that will be removed from subject strings if fuzzy subject
282 simplification is selected."
283 :group 'gnus-thread
284 :type '(repeat regexp))
285
286 (defcustom gnus-show-threads t
287 "*If non-nil, display threads in summary mode."
288 :group 'gnus-thread
289 :type 'boolean)
290
291 (defcustom gnus-thread-hide-subtree nil
292 "*If non-nil, hide all threads initially.
293 This can be a predicate specifier which says which threads to hide.
294 If threads are hidden, you have to run the command
295 `gnus-summary-show-thread' by hand or select an article."
296 :group 'gnus-thread
297 :type '(radio (sexp :format "Non-nil\n"
298 :match (lambda (widget value)
299 (not (or (consp value) (functionp value))))
300 :value t)
301 (const nil)
302 (sexp :tag "Predicate specifier")))
303
304 (defcustom gnus-thread-hide-killed t
305 "*If non-nil, hide killed threads automatically."
306 :group 'gnus-thread
307 :type 'boolean)
308
309 (defcustom gnus-thread-ignore-subject t
310 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
311 If nil, articles that have different subjects from their parents will
312 start separate threads."
313 :group 'gnus-thread
314 :type 'boolean)
315
316 (defcustom gnus-thread-operation-ignore-subject t
317 "*If non-nil, subjects will be ignored when doing thread commands.
318 This affects commands like `gnus-summary-kill-thread' and
319 `gnus-summary-lower-thread'.
320
321 If this variable is nil, articles in the same thread with different
322 subjects will not be included in the operation in question. If this
323 variable is `fuzzy', only articles that have subjects that are fuzzily
324 equal will be included."
325 :group 'gnus-thread
326 :type '(choice (const :tag "off" nil)
327 (const fuzzy)
328 (sexp :tag "on" t)))
329
330 (defcustom gnus-thread-indent-level 4
331 "*Number that says how much each sub-thread should be indented."
332 :group 'gnus-thread
333 :type 'integer)
334
335 (defcustom gnus-auto-extend-newsgroup t
336 "*If non-nil, extend newsgroup forward and backward when requested."
337 :group 'gnus-summary-choose
338 :type 'boolean)
339
340 (defcustom gnus-auto-select-first t
341 "If non-nil, select an article on group entry.
342 An article is selected automatically when entering a group
343 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
344 `gnus-summary-catchup-and-goto-next-group'.
345
346 Which article is selected is controlled by the variable
347 `gnus-auto-select-subject'.
348
349 If you want to prevent automatic selection of articles in some
350 newsgroups, set the variable to nil in `gnus-select-group-hook'."
351 ;; Commands include...
352 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
353 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
354 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
355 :group 'gnus-group-select
356 :type '(choice (const :tag "none" nil)
357 (sexp :menu-tag "first" t)))
358
359 (defcustom gnus-auto-select-subject 'unseen-or-unread
360 "*Says what subject to place under point when entering a group.
361
362 This variable can either be the symbols `first' (place point on the
363 first subject), `unread' (place point on the subject line of the first
364 unread article), `best' (place point on the subject line of the
365 highest-scored article), `unseen' (place point on the subject line of
366 the first unseen article), `unseen-or-unread' (place point on the subject
367 line of the first unseen article or, if all articles have been seen, on the
368 subject line of the first unread article), or a function to be called to
369 place point on some subject line."
370 :version "24.1"
371 :group 'gnus-group-select
372 :type '(choice (const best)
373 (const unread)
374 (const first)
375 (const unseen)
376 (const unseen-or-unread)
377 (function :tag "Function to call")))
378
379 (defcustom gnus-auto-select-next t
380 "*If non-nil, offer to go to the next group from the end of the previous.
381 If the value is t and the next newsgroup is empty, Gnus will exit
382 summary mode and go back to group mode. If the value is neither nil
383 nor t, Gnus will select the following unread newsgroup. In
384 particular, if the value is the symbol `quietly', the next unread
385 newsgroup will be selected without any confirmation, and if it is
386 `almost-quietly', the next group will be selected without any
387 confirmation if you are located on the last article in the group.
388 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
389 will go to the next group without confirmation."
390 :group 'gnus-summary-maneuvering
391 :type '(choice (const :tag "off" nil)
392 (const quietly)
393 (const almost-quietly)
394 (const slightly-quietly)
395 (sexp :menu-tag "on" t)))
396
397 (defcustom gnus-auto-select-same nil
398 "*If non-nil, select the next article with the same subject.
399 If there are no more articles with the same subject, go to
400 the first unread article."
401 :group 'gnus-summary-maneuvering
402 :type 'boolean)
403
404 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
405 "What article should be selected after exiting an ephemeral group.
406 Valid values include:
407
408 `next'
409 Select the next article.
410 `next-unread'
411 Select the next unread article.
412 `next-noselect'
413 Move the cursor to the next article. This is the default.
414 `next-unread-noselect'
415 Move the cursor to the next unread article.
416
417 If it has any other value or there is no next (unread) article, the
418 article selected before entering to the ephemeral group will appear."
419 :version "23.1" ;; No Gnus
420 :group 'gnus-summary-maneuvering
421 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
422 (const next) (const next-unread)
423 (const next-noselect) (const next-unread-noselect)
424 (sexp :tag "other" :value nil)))
425
426 (defcustom gnus-auto-goto-ignores 'unfetched
427 "*Says how to handle unfetched articles when maneuvering.
428
429 This variable can either be the symbols nil (maneuver to any
430 article), `undownloaded' (maneuvering while unplugged ignores articles
431 that have not been fetched), `always-undownloaded' (maneuvering always
432 ignores articles that have not been fetched), `unfetched' (maneuvering
433 ignores articles whose headers have not been fetched).
434
435 NOTE: The list of unfetched articles will always be nil when plugged
436 and, when unplugged, a subset of the undownloaded article list."
437 :version "22.1"
438 :group 'gnus-summary-maneuvering
439 :type '(choice (const :tag "None" nil)
440 (const :tag "Undownloaded when unplugged" undownloaded)
441 (const :tag "Undownloaded" always-undownloaded)
442 (const :tag "Unfetched" unfetched)))
443
444 (defcustom gnus-summary-check-current nil
445 "*If non-nil, consider the current article when moving.
446 The \"unread\" movement commands will stay on the same line if the
447 current article is unread."
448 :group 'gnus-summary-maneuvering
449 :type 'boolean)
450
451 (defcustom gnus-auto-center-summary
452 (max (or (bound-and-true-p scroll-margin) 0) 2)
453 "*If non-nil, always center the current summary buffer.
454 In particular, if `vertical' do only vertical recentering. If non-nil
455 and non-`vertical', do both horizontal and vertical recentering."
456 :group 'gnus-summary-maneuvering
457 :type '(choice (const :tag "none" nil)
458 (const vertical)
459 (integer :tag "height")
460 (sexp :menu-tag "both" t)))
461
462 (defcustom gnus-auto-center-group t
463 "If non-nil, always center the group buffer."
464 :group 'gnus-summary-maneuvering
465 :type 'boolean)
466
467 (defcustom gnus-show-all-headers nil
468 "*If non-nil, don't hide any headers."
469 :group 'gnus-article-hiding
470 :group 'gnus-article-headers
471 :type 'boolean)
472
473 (defcustom gnus-summary-ignore-duplicates nil
474 "*If non-nil, ignore articles with identical Message-ID headers."
475 :group 'gnus-summary
476 :type 'boolean)
477
478 (defcustom gnus-single-article-buffer nil
479 "*If non-nil, display all articles in the same buffer.
480 If nil, each group will get its own article buffer."
481 :version "24.1"
482 :group 'gnus-article-various
483 :type 'boolean)
484
485 (defcustom gnus-widen-article-window nil
486 "If non-nil, selecting the article buffer will display only the article buffer."
487 :version "24.1"
488 :group 'gnus-article-various
489 :type 'boolean)
490
491 (defcustom gnus-break-pages t
492 "*If non-nil, do page breaking on articles.
493 The page delimiter is specified by the `gnus-page-delimiter'
494 variable."
495 :group 'gnus-article-various
496 :type 'boolean)
497
498 (defcustom gnus-move-split-methods nil
499 "*Variable used to suggest where articles are to be moved to.
500 It uses the same syntax as the `gnus-split-methods' variable.
501 However, whereas `gnus-split-methods' specifies file names as targets,
502 this variable specifies group names."
503 :group 'gnus-summary-mail
504 :type '(repeat (choice (list :value (fun) function)
505 (cons :value ("" "") regexp (repeat string))
506 (sexp :value nil))))
507
508 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
509 "Function used to compute default prefix for article move/copy/etc prompts.
510 The function should take one argument, a group name, and return a
511 string with the suggested prefix."
512 :group 'gnus-summary-mail
513 :type 'function)
514
515 ;; FIXME: Although the custom type is `character' for the following variables,
516 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
517
518 (defcustom gnus-unread-mark ? ;Whitespace
519 "*Mark used for unread articles."
520 :group 'gnus-summary-marks
521 :type 'character)
522
523 (defcustom gnus-ticked-mark ?!
524 "*Mark used for ticked articles."
525 :group 'gnus-summary-marks
526 :type 'character)
527
528 (defcustom gnus-dormant-mark ??
529 "*Mark used for dormant articles."
530 :group 'gnus-summary-marks
531 :type 'character)
532
533 (defcustom gnus-del-mark ?r
534 "*Mark used for del'd articles."
535 :group 'gnus-summary-marks
536 :type 'character)
537
538 (defcustom gnus-read-mark ?R
539 "*Mark used for read articles."
540 :group 'gnus-summary-marks
541 :type 'character)
542
543 (defcustom gnus-expirable-mark ?E
544 "*Mark used for expirable articles."
545 :group 'gnus-summary-marks
546 :type 'character)
547
548 (defcustom gnus-killed-mark ?K
549 "*Mark used for killed articles."
550 :group 'gnus-summary-marks
551 :type 'character)
552
553 (defcustom gnus-spam-mark ?$
554 "*Mark used for spam articles."
555 :version "22.1"
556 :group 'gnus-summary-marks
557 :type 'character)
558
559 (defcustom gnus-kill-file-mark ?X
560 "*Mark used for articles killed by kill files."
561 :group 'gnus-summary-marks
562 :type 'character)
563
564 (defcustom gnus-low-score-mark ?Y
565 "*Mark used for articles with a low score."
566 :group 'gnus-summary-marks
567 :type 'character)
568
569 (defcustom gnus-catchup-mark ?C
570 "*Mark used for articles that are caught up."
571 :group 'gnus-summary-marks
572 :type 'character)
573
574 (defcustom gnus-replied-mark ?A
575 "*Mark used for articles that have been replied to."
576 :group 'gnus-summary-marks
577 :type 'character)
578
579 (defcustom gnus-forwarded-mark ?F
580 "*Mark used for articles that have been forwarded."
581 :version "22.1"
582 :group 'gnus-summary-marks
583 :type 'character)
584
585 (defcustom gnus-recent-mark ?N
586 "*Mark used for articles that are recent."
587 :version "22.1"
588 :group 'gnus-summary-marks
589 :type 'character)
590
591 (defcustom gnus-cached-mark ?*
592 "*Mark used for articles that are in the cache."
593 :group 'gnus-summary-marks
594 :type 'character)
595
596 (defcustom gnus-saved-mark ?S
597 "*Mark used for articles that have been saved."
598 :group 'gnus-summary-marks
599 :type 'character)
600
601 (defcustom gnus-unseen-mark ?.
602 "*Mark used for articles that haven't been seen."
603 :version "22.1"
604 :group 'gnus-summary-marks
605 :type 'character)
606
607 (defcustom gnus-no-mark ? ;Whitespace
608 "*Mark used for articles that have no other secondary mark."
609 :version "22.1"
610 :group 'gnus-summary-marks
611 :type 'character)
612
613 (defcustom gnus-ancient-mark ?O
614 "*Mark used for ancient articles."
615 :group 'gnus-summary-marks
616 :type 'character)
617
618 (defcustom gnus-sparse-mark ?Q
619 "*Mark used for sparsely reffed articles."
620 :group 'gnus-summary-marks
621 :type 'character)
622
623 (defcustom gnus-canceled-mark ?G
624 "*Mark used for canceled articles."
625 :group 'gnus-summary-marks
626 :type 'character)
627
628 (defcustom gnus-duplicate-mark ?M
629 "*Mark used for duplicate articles."
630 :group 'gnus-summary-marks
631 :type 'character)
632
633 (defcustom gnus-undownloaded-mark ?-
634 "*Mark used for articles that weren't downloaded."
635 :version "22.1"
636 :group 'gnus-summary-marks
637 :type 'character)
638
639 (defcustom gnus-downloaded-mark ?+
640 "*Mark used for articles that were downloaded."
641 :group 'gnus-summary-marks
642 :type 'character)
643
644 (defcustom gnus-downloadable-mark ?%
645 "*Mark used for articles that are to be downloaded."
646 :group 'gnus-summary-marks
647 :type 'character)
648
649 (defcustom gnus-unsendable-mark ?=
650 "*Mark used for articles that won't be sent."
651 :group 'gnus-summary-marks
652 :type 'character)
653
654 (defcustom gnus-score-over-mark ?+
655 "*Score mark used for articles with high scores."
656 :group 'gnus-summary-marks
657 :type 'character)
658
659 (defcustom gnus-score-below-mark ?-
660 "*Score mark used for articles with low scores."
661 :group 'gnus-summary-marks
662 :type 'character)
663
664 (defcustom gnus-empty-thread-mark ? ;Whitespace
665 "*There is no thread under the article."
666 :group 'gnus-summary-marks
667 :type 'character)
668
669 (defcustom gnus-not-empty-thread-mark ?=
670 "*There is a thread under the article."
671 :group 'gnus-summary-marks
672 :type 'character)
673
674 (defcustom gnus-view-pseudo-asynchronously nil
675 "*If non-nil, Gnus will view pseudo-articles asynchronously."
676 :group 'gnus-extract-view
677 :type 'boolean)
678
679 (defcustom gnus-auto-expirable-marks
680 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
681 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
682 gnus-duplicate-mark)
683 "*The list of marks converted into expiration if a group is auto-expirable."
684 :version "24.1"
685 :group 'gnus-summary
686 :type '(repeat character))
687
688 (defcustom gnus-inhibit-user-auto-expire t
689 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
690 :version "21.1"
691 :group 'gnus-summary
692 :type 'boolean)
693
694 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
695 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
696 If nil, the expirable marks will be unchanged except that the marks
697 will be removed when copying or moving articles to a group that has
698 not turned auto-expire on. If non-nil, articles that have been read
699 will be marked as expirable when being copied or moved to a group in
700 which auto-expire is turned on."
701 :version "23.2"
702 :type 'boolean
703 :group 'gnus-summary-marks)
704
705 (defcustom gnus-view-pseudos nil
706 "*If `automatic', pseudo-articles will be viewed automatically.
707 If `not-confirm', pseudos will be viewed automatically, and the user
708 will not be asked to confirm the command."
709 :group 'gnus-extract-view
710 :type '(choice (const :tag "off" nil)
711 (const automatic)
712 (const not-confirm)))
713
714 (defcustom gnus-view-pseudos-separately t
715 "*If non-nil, one pseudo-article will be created for each file to be viewed.
716 If nil, all files that use the same viewing command will be given as a
717 list of parameters to that command."
718 :group 'gnus-extract-view
719 :type 'boolean)
720
721 (defcustom gnus-insert-pseudo-articles t
722 "*If non-nil, insert pseudo-articles when decoding articles."
723 :group 'gnus-extract-view
724 :type 'boolean)
725
726 (defcustom gnus-summary-dummy-line-format
727 " %(: :%) %S\n"
728 "*The format specification for the dummy roots in the summary buffer.
729 It works along the same lines as a normal formatting string,
730 with some simple extensions.
731
732 %S The subject
733
734 General format specifiers can also be used.
735 See `(gnus)Formatting Variables'."
736 :link '(custom-manual "(gnus)Formatting Variables")
737 :group 'gnus-threading
738 :type 'string)
739
740 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
741 "*The format specification for the summary mode line.
742 It works along the same lines as a normal formatting string,
743 with some simple extensions:
744
745 %G Group name
746 %p Unprefixed group name
747 %A Current article number
748 %z Current article score
749 %V Gnus version
750 %U Number of unread articles in the group
751 %e Number of unselected articles in the group
752 %Z A string with unread/unselected article counts
753 %g Shortish group name
754 %S Subject of the current article
755 %u User-defined spec
756 %s Current score file name
757 %d Number of dormant articles
758 %r Number of articles that have been marked as read in this session
759 %E Number of articles expunged by the score files"
760 :group 'gnus-summary-format
761 :type 'string)
762
763 (defcustom gnus-list-identifiers nil
764 "Regexp that matches list identifiers to be removed from subject.
765 This can also be a list of regexps."
766 :version "21.1"
767 :group 'gnus-summary-format
768 :group 'gnus-article-hiding
769 :type '(choice (const :tag "none" nil)
770 (regexp :value ".*")
771 (repeat :value (".*") regexp)))
772
773 (defcustom gnus-summary-mark-below 0
774 "*Mark all articles with a score below this variable as read.
775 This variable is local to each summary buffer and usually set by the
776 score file."
777 :group 'gnus-score-default
778 :type 'integer)
779
780 (defun gnus-widget-reversible-match (widget value)
781 "Ignoring WIDGET, convert VALUE to internal form.
782 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
783 ;; (debug value)
784 (or (symbolp value)
785 (and (listp value)
786 (eq (length value) 2)
787 (eq (nth 0 value) 'not)
788 (symbolp (nth 1 value)))))
789
790 (defun gnus-widget-reversible-to-internal (widget value)
791 "Ignoring WIDGET, convert VALUE to internal form.
792 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
793 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
794 ;; (debug value)
795 (if (atom value)
796 (list value nil)
797 (list (nth 1 value) t)))
798
799 (defun gnus-widget-reversible-to-external (widget value)
800 "Ignoring WIDGET, convert VALUE to external form.
801 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
802 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
803 ;; (debug value)
804 (if (nth 1 value)
805 (list 'not (nth 0 value))
806 (nth 0 value)))
807
808 (define-widget 'gnus-widget-reversible 'group
809 "A `group' that convert values."
810 :match 'gnus-widget-reversible-match
811 :value-to-internal 'gnus-widget-reversible-to-internal
812 :value-to-external 'gnus-widget-reversible-to-external)
813
814 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
815 "*List of functions used for sorting articles in the summary buffer.
816
817 Each function takes two articles and returns non-nil if the first
818 article should be sorted before the other. If you use more than one
819 function, the primary sort function should be the last. You should
820 probably always include `gnus-article-sort-by-number' in the list of
821 sorting functions -- preferably first. Also note that sorting by date
822 is often much slower than sorting by number, and the sorting order is
823 very similar. (Sorting by date means sorting by the time the message
824 was sent, sorting by number means sorting by arrival time.)
825
826 Each item can also be a list `(not F)' where F is a function;
827 this reverses the sort order.
828
829 Ready-made functions include `gnus-article-sort-by-number',
830 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
831 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
832 and `gnus-article-sort-by-score'.
833
834 When threading is turned on, the variable `gnus-thread-sort-functions'
835 controls how articles are sorted."
836 :group 'gnus-summary-sort
837 :type '(repeat (gnus-widget-reversible
838 (choice (function-item gnus-article-sort-by-number)
839 (function-item gnus-article-sort-by-author)
840 (function-item gnus-article-sort-by-subject)
841 (function-item gnus-article-sort-by-date)
842 (function-item gnus-article-sort-by-score)
843 (function-item gnus-article-sort-by-random)
844 (function :tag "other"))
845 (boolean :tag "Reverse order"))))
846
847 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
848 "*List of functions used for sorting threads in the summary buffer.
849 By default, threads are sorted by article number.
850
851 Each function takes two threads and returns non-nil if the first
852 thread should be sorted before the other. If you use more than one
853 function, the primary sort function should be the last. You should
854 probably always include `gnus-thread-sort-by-number' in the list of
855 sorting functions -- preferably first. Also note that sorting by date
856 is often much slower than sorting by number, and the sorting order is
857 very similar. (Sorting by date means sorting by the time the message
858 was sent, sorting by number means sorting by arrival time.)
859
860 Each list item can also be a list `(not F)' where F is a
861 function; this specifies reversed sort order.
862
863 Ready-made functions include `gnus-thread-sort-by-number',
864 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
865 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
866 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
867 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
868 and `gnus-thread-sort-by-total-score' (see
869 `gnus-thread-score-function').
870
871 When threading is turned off, the variable
872 `gnus-article-sort-functions' controls how articles are sorted.
873
874 By default, threads and their subthreads are sorted according to
875 the value of this variable. To use a different sorting order for
876 subthreads, customize `gnus-subthread-sort-functions'."
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-subthread-sort-functions 'gnus-thread-sort-functions
894 "*List of functions used for sorting subthreads in the summary buffer.
895 By default, subthreads are sorted the same as threads, i.e.,
896 according to the value of `gnus-thread-sort-functions'."
897 :version "24.4"
898 :group 'gnus-summary-sort
899 :type '(choice
900 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
901 (repeat
902 (gnus-widget-reversible
903 (choice (function-item gnus-thread-sort-by-number)
904 (function-item gnus-thread-sort-by-author)
905 (function-item gnus-thread-sort-by-recipient)
906 (function-item gnus-thread-sort-by-subject)
907 (function-item gnus-thread-sort-by-date)
908 (function-item gnus-thread-sort-by-score)
909 (function-item gnus-thread-sort-by-most-recent-number)
910 (function-item gnus-thread-sort-by-most-recent-date)
911 (function-item gnus-thread-sort-by-random)
912 (function-item gnus-thread-sort-by-total-score)
913 (function :tag "other"))
914 (boolean :tag "Reverse order")))))
915
916 (defcustom gnus-thread-score-function '+
917 "*Function used for calculating the total score of a thread.
918
919 The function is called with the scores of the article and each
920 subthread and should then return the score of the thread.
921
922 Some functions you can use are `+', `max', or `min'."
923 :group 'gnus-summary-sort
924 :type 'function)
925
926 (defcustom gnus-summary-expunge-below nil
927 "All articles that have a score less than this variable will be expunged.
928 This variable is local to the summary buffers."
929 :group 'gnus-score-default
930 :type '(choice (const :tag "off" nil)
931 integer))
932
933 (defcustom gnus-thread-expunge-below nil
934 "All threads that have a total score less than this variable will be expunged.
935 See `gnus-thread-score-function' for en explanation of what a
936 \"thread score\" is.
937
938 This variable is local to the summary buffers."
939 :group 'gnus-threading
940 :group 'gnus-score-default
941 :type '(choice (const :tag "off" nil)
942 integer))
943
944 (defcustom gnus-summary-mode-hook nil
945 "*A hook for Gnus summary mode.
946 This hook is run before any variables are set in the summary buffer."
947 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
948 :group 'gnus-summary-various
949 :type 'hook)
950
951 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
952 (when (featurep 'xemacs)
953 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
954 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
955 (add-hook 'gnus-summary-mode-hook
956 'gnus-xmas-switch-horizontal-scrollbar-off))
957
958 (defcustom gnus-summary-menu-hook nil
959 "*Hook run after the creation of the summary mode menu."
960 :group 'gnus-summary-visual
961 :type 'hook)
962
963 (defcustom gnus-summary-exit-hook nil
964 "*A hook called on exit from the summary buffer.
965 It will be called with point in the group buffer."
966 :group 'gnus-summary-exit
967 :type 'hook)
968
969 (defcustom gnus-summary-prepare-hook nil
970 "*A hook called after the summary buffer has been generated.
971 If you want to modify the summary buffer, you can use this hook."
972 :group 'gnus-summary-various
973 :type 'hook)
974
975 (defcustom gnus-summary-prepared-hook nil
976 "*A hook called as the last thing after the summary buffer has been generated."
977 :group 'gnus-summary-various
978 :type 'hook)
979
980 (defcustom gnus-summary-generate-hook nil
981 "*A hook run just before generating the summary buffer.
982 This hook is commonly used to customize threading variables and the
983 like."
984 :group 'gnus-summary-various
985 :type 'hook)
986
987 (defcustom gnus-select-group-hook nil
988 "*A hook called when a newsgroup is selected.
989
990 If you'd like to simplify subjects like the
991 `gnus-summary-next-same-subject' command does, you can use the
992 following hook:
993
994 (add-hook gnus-select-group-hook
995 (lambda ()
996 (mapcar (lambda (header)
997 (mail-header-set-subject
998 header
999 (gnus-simplify-subject
1000 (mail-header-subject header) \\='re-only)))
1001 gnus-newsgroup-headers)))"
1002 :group 'gnus-group-select
1003 :type 'hook)
1004
1005 (defcustom gnus-select-article-hook nil
1006 "*A hook called when an article is selected."
1007 :group 'gnus-summary-choose
1008 :options '(gnus-agent-fetch-selected-article)
1009 :type 'hook)
1010
1011 (defcustom gnus-visual-mark-article-hook
1012 (list 'gnus-highlight-selected-summary)
1013 "*Hook run after selecting an article in the summary buffer.
1014 It is meant to be used for highlighting the article in some way. It
1015 is not run if `gnus-visual' is nil."
1016 :group 'gnus-summary-visual
1017 :type 'hook)
1018
1019 (defcustom gnus-parse-headers-hook nil
1020 "*A hook called before parsing the headers."
1021 :group 'gnus-various
1022 :type 'hook)
1023
1024 (defcustom gnus-exit-group-hook nil
1025 "*A hook called when exiting summary mode.
1026 This hook is not called from the non-updating exit commands like `Q'."
1027 :group 'gnus-various
1028 :type 'hook)
1029
1030 (defcustom gnus-summary-update-hook nil
1031 "*A hook called when a summary line is changed.
1032 The hook will not be called if `gnus-visual' is nil.
1033
1034 The default function `gnus-summary-highlight-line' will
1035 highlight the line according to the `gnus-summary-highlight'
1036 variable."
1037 :group 'gnus-summary-visual
1038 :type 'hook)
1039
1040 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1041 "*A hook called when an article is selected for the first time.
1042 The hook is intended to mark an article as read (or unread)
1043 automatically when it is selected."
1044 :group 'gnus-summary-choose
1045 :type 'hook)
1046
1047 (defcustom gnus-group-no-more-groups-hook nil
1048 "*A hook run when returning to group mode having no more (unread) groups."
1049 :group 'gnus-group-select
1050 :type 'hook)
1051
1052 (defcustom gnus-ps-print-hook nil
1053 "*A hook run before ps-printing something from Gnus."
1054 :group 'gnus-summary
1055 :type 'hook)
1056
1057 (defcustom gnus-summary-article-move-hook nil
1058 "*A hook called after an article is moved, copied, respooled, or crossposted."
1059 :version "22.1"
1060 :group 'gnus-summary
1061 :type 'hook)
1062
1063 (defcustom gnus-summary-article-delete-hook nil
1064 "*A hook called after an article is deleted."
1065 :version "22.1"
1066 :group 'gnus-summary
1067 :type 'hook)
1068
1069 (defcustom gnus-summary-article-expire-hook nil
1070 "*A hook called after an article is expired."
1071 :version "22.1"
1072 :group 'gnus-summary
1073 :type 'hook)
1074
1075 (defcustom gnus-summary-display-arrow
1076 (and (fboundp 'display-graphic-p)
1077 (display-graphic-p))
1078 "*If non-nil, display an arrow highlighting the current article."
1079 :version "22.1"
1080 :group 'gnus-summary
1081 :type 'boolean)
1082
1083 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1084 "Face used for highlighting the current article in the summary buffer."
1085 :group 'gnus-summary-visual
1086 :type 'face)
1087
1088 (defvar gnus-tmp-downloaded nil)
1089
1090 (defcustom gnus-summary-highlight
1091 '(((eq mark gnus-canceled-mark)
1092 . gnus-summary-cancelled)
1093 ((and uncached (> score default-high))
1094 . gnus-summary-high-undownloaded)
1095 ((and uncached (< score default-low))
1096 . gnus-summary-low-undownloaded)
1097 (uncached
1098 . gnus-summary-normal-undownloaded)
1099 ((and (> score default-high)
1100 (or (eq mark gnus-dormant-mark)
1101 (eq mark gnus-ticked-mark)))
1102 . gnus-summary-high-ticked)
1103 ((and (< score default-low)
1104 (or (eq mark gnus-dormant-mark)
1105 (eq mark gnus-ticked-mark)))
1106 . gnus-summary-low-ticked)
1107 ((or (eq mark gnus-dormant-mark)
1108 (eq mark gnus-ticked-mark))
1109 . gnus-summary-normal-ticked)
1110 ((and (> score default-high) (eq mark gnus-ancient-mark))
1111 . gnus-summary-high-ancient)
1112 ((and (< score default-low) (eq mark gnus-ancient-mark))
1113 . gnus-summary-low-ancient)
1114 ((eq mark gnus-ancient-mark)
1115 . gnus-summary-normal-ancient)
1116 ((and (> score default-high) (eq mark gnus-unread-mark))
1117 . gnus-summary-high-unread)
1118 ((and (< score default-low) (eq mark gnus-unread-mark))
1119 . gnus-summary-low-unread)
1120 ((eq mark gnus-unread-mark)
1121 . gnus-summary-normal-unread)
1122 ((> score default-high)
1123 . gnus-summary-high-read)
1124 ((< score default-low)
1125 . gnus-summary-low-read)
1126 (t
1127 . gnus-summary-normal-read))
1128 "*Controls the highlighting of summary buffer lines.
1129
1130 A list of (FORM . FACE) pairs. When deciding how a particular
1131 summary line should be displayed, each form is evaluated. The content
1132 of the face field after the first true form is used. You can change
1133 how those summary lines are displayed, by editing the face field.
1134
1135 You can use the following variables in the FORM field.
1136
1137 score: The article's score.
1138 default: The default article score.
1139 default-high: The default score for high scored articles.
1140 default-low: The default score for low scored articles.
1141 mark: The article's mark.
1142 uncached: Non-nil if the article is uncached."
1143 :group 'gnus-summary-visual
1144 :type '(repeat (cons (sexp :tag "Form" nil)
1145 face)))
1146 (put 'gnus-summary-highlight 'risky-local-variable t)
1147
1148 (defcustom gnus-alter-header-function nil
1149 "Function called to allow alteration of article header structures.
1150 The function is called with one parameter, the article header vector,
1151 which it may alter in any way."
1152 :type '(choice (const :tag "None" nil)
1153 function)
1154 :group 'gnus-summary)
1155
1156 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1157 "Function used to decode a string with encoded words.")
1158
1159 (defvar gnus-decode-encoded-address-function
1160 'mail-decode-encoded-address-string
1161 "Function used to decode addresses with encoded words.")
1162
1163 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
1164 "*Extra headers to parse."
1165 :version "25.1"
1166 :group 'gnus-summary
1167 :type '(repeat symbol))
1168
1169 (defcustom gnus-ignored-from-addresses
1170 (and user-mail-address
1171 (not (string= user-mail-address ""))
1172 (regexp-quote user-mail-address))
1173 "*From headers that may be suppressed in favor of To headers.
1174 This can be a regexp, a list of regexps or a function.
1175
1176 If a function, an email string is passed as the argument."
1177 :version "21.1"
1178 :group 'gnus-summary
1179 :type '(choice regexp
1180 (repeat :tag "Regexp List" regexp)
1181 function))
1182
1183 (defsubst gnus-ignored-from-addresses ()
1184 (cond ((functionp gnus-ignored-from-addresses)
1185 gnus-ignored-from-addresses)
1186 (t (gmm-regexp-concat gnus-ignored-from-addresses))))
1187
1188 (defcustom gnus-summary-to-prefix "-> "
1189 "*String prefixed to the To field in the summary line when
1190 using `gnus-ignored-from-addresses'."
1191 :version "22.1"
1192 :group 'gnus-summary
1193 :type 'string)
1194
1195 (defcustom gnus-summary-newsgroup-prefix "=> "
1196 "*String prefixed to the Newsgroup field in the summary
1197 line when using the option `gnus-ignored-from-addresses'."
1198 :version "22.1"
1199 :group 'gnus-summary
1200 :type 'string)
1201
1202 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1203 "List of charsets that should be ignored.
1204 When these charsets are used in the \"charset\" parameter, the
1205 default charset will be used instead."
1206 :version "21.1"
1207 :type '(repeat symbol)
1208 :group 'gnus-charset)
1209
1210 (defcustom gnus-newsgroup-maximum-articles nil
1211 "The maximum number of articles a newsgroup.
1212 If this is a number, old articles in a newsgroup exceeding this number
1213 are silently ignored. If it is nil, no article is ignored. Note that
1214 setting this variable to a number might prevent you from reading very
1215 old articles."
1216 :group 'gnus-group-select
1217 :version "22.2"
1218 :type '(choice (const :tag "No limit" nil)
1219 integer))
1220
1221 (gnus-define-group-parameter
1222 ignored-charsets
1223 :type list
1224 :function-document
1225 "Return the ignored charsets of GROUP."
1226 :variable gnus-group-ignored-charsets-alist
1227 :variable-default
1228 '(("alt\\.chinese\\.text" iso-8859-1))
1229 :variable-document
1230 "Alist of regexps (to match group names) and charsets that should be ignored.
1231 When these charsets are used in the \"charset\" parameter, the
1232 default charset will be used instead."
1233 :variable-group gnus-charset
1234 :variable-type '(repeat (cons (regexp :tag "Group")
1235 (repeat symbol)))
1236 :parameter-type '(choice :tag "Ignored charsets"
1237 :value nil
1238 (repeat (symbol)))
1239 :parameter-document "\
1240 List of charsets that should be ignored.
1241
1242 When these charsets are used in the \"charset\" parameter, the
1243 default charset will be used instead.")
1244
1245 (defcustom gnus-group-highlight-words-alist nil
1246 "Alist of group regexps and highlight regexps.
1247 This variable uses the same syntax as `gnus-emphasis-alist'."
1248 :version "21.1"
1249 :type '(repeat (cons (regexp :tag "Group")
1250 (repeat (list (regexp :tag "Highlight regexp")
1251 (number :tag "Group for entire word" 0)
1252 (number :tag "Group for displayed part" 0)
1253 (symbol :tag "Face"
1254 gnus-emphasis-highlight-words)))))
1255 :group 'gnus-summary-visual)
1256
1257 (defcustom gnus-summary-show-article-charset-alist
1258 nil
1259 "Alist of number and charset.
1260 The article will be shown with the charset corresponding to the
1261 numbered argument.
1262 For example: ((1 . cn-gb-2312) (2 . big5))."
1263 :version "21.1"
1264 :type '(repeat (cons (number :tag "Argument" 1)
1265 (symbol :tag "Charset")))
1266 :group 'gnus-charset)
1267
1268 (defcustom gnus-preserve-marks t
1269 "Whether marks are preserved when moving, copying and respooling messages."
1270 :version "21.1"
1271 :type 'boolean
1272 :group 'gnus-summary-marks)
1273
1274 (defcustom gnus-alter-articles-to-read-function nil
1275 "Function to be called to alter the list of articles to be selected."
1276 :type '(choice (const nil) function)
1277 :group 'gnus-summary)
1278
1279 (defcustom gnus-orphan-score nil
1280 "*All orphans get this score added. Set in the score file."
1281 :group 'gnus-score-default
1282 :type '(choice (const nil)
1283 integer))
1284
1285 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1286 "*A regexp to match MIME parts when saving multiple parts of a
1287 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1288 This regexp will be used by default when prompting the user for which
1289 type of files to save."
1290 :group 'gnus-summary
1291 :type 'regexp)
1292
1293 (defcustom gnus-read-all-available-headers nil
1294 "Whether Gnus should parse all headers made available to it.
1295 This is mostly relevant for slow back ends where the user may
1296 wish to widen the summary buffer to include all headers
1297 that were fetched."
1298 :version "22.1"
1299 :group 'gnus-summary
1300 :type '(choice boolean regexp))
1301
1302 (defcustom gnus-summary-pipe-output-default-command nil
1303 "Command (and optional arguments) used to pipe article to subprocess.
1304 This will be used as the default command if it is non-nil. The value
1305 will be updated if you modify it when executing the command
1306 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1307 :version "23.1" ;; No Gnus
1308 :group 'gnus-summary
1309 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1310
1311 (defcustom gnus-summary-muttprint-program "muttprint"
1312 "Command (and optional arguments) used to run Muttprint.
1313 The value will be updated if you modify it when executing the command
1314 `gnus-summary-muttprint'."
1315 :version "22.1"
1316 :group 'gnus-summary
1317 :type 'string)
1318
1319 (defcustom gnus-article-loose-mime t
1320 "If non-nil, don't require MIME-Version header.
1321 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1322 supply the MIME-Version header or deliberately strip it from the mail.
1323 If non-nil (the default), Gnus will treat some articles as MIME
1324 even if the MIME-Version header is missing."
1325 :version "22.1"
1326 :type 'boolean
1327 :group 'gnus-article-mime)
1328
1329 (defcustom gnus-article-emulate-mime t
1330 "If non-nil, use MIME emulation for uuencode and the like.
1331 This means that Gnus will search message bodies for text that look
1332 like uuencoded bits, yEncoded bits, and so on, and present that using
1333 the normal Gnus MIME machinery."
1334 :version "22.1"
1335 :type 'boolean
1336 :group 'gnus-article-mime)
1337
1338 ;;; Internal variables
1339
1340 (defvar gnus-summary-display-cache nil)
1341 (defvar gnus-article-mime-handles nil)
1342 (defvar gnus-article-decoded-p nil)
1343 (defvar gnus-article-charset nil)
1344 (defvar gnus-article-ignored-charsets nil)
1345 (defvar gnus-scores-exclude-files nil)
1346 (defvar gnus-page-broken nil)
1347
1348 (defvar gnus-original-article nil)
1349 (defvar gnus-article-internal-prepare-hook nil)
1350 (defvar gnus-newsgroup-process-stack nil)
1351
1352 (defvar gnus-thread-indent-array nil)
1353 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1354 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1355 "Function called to sort the articles within a thread after it has been gathered together.")
1356
1357 (defvar gnus-summary-save-parts-type-history nil)
1358 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1359
1360 ;; Avoid highlighting in kill files.
1361 (defvar gnus-summary-inhibit-highlight nil)
1362 (defvar gnus-newsgroup-selected-overlay nil)
1363 (defvar gnus-inhibit-limiting nil)
1364 (defvar gnus-newsgroup-adaptive-score-file nil)
1365 (defvar gnus-current-score-file nil)
1366 (defvar gnus-current-move-group nil)
1367 (defvar gnus-current-copy-group nil)
1368 (defvar gnus-current-crosspost-group nil)
1369 (defvar gnus-newsgroup-display nil)
1370
1371 (defvar gnus-newsgroup-dependencies nil)
1372 (defvar gnus-newsgroup-adaptive nil)
1373 (defvar gnus-summary-display-article-function nil)
1374 (defvar gnus-summary-highlight-line-function nil
1375 "Function called after highlighting a summary line.")
1376
1377 (defvar gnus-summary-line-format-alist
1378 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1379 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1380 (?s gnus-tmp-subject-or-nil ?s)
1381 (?n gnus-tmp-name ?s)
1382 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1383 ?s)
1384 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1385 gnus-tmp-from) ?s)
1386 (?F gnus-tmp-from ?s)
1387 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1388 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1389 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1390 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1391 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1392 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1393 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1394 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1395 (?L gnus-tmp-lines ?s)
1396 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1397 0) ?d)
1398 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1399 "") ?s)
1400 (?g (or (gnus-group-short-name
1401 (nnir-article-group (mail-header-number gnus-tmp-header)))
1402 "") ?s)
1403 (?O gnus-tmp-downloaded ?c)
1404 (?I gnus-tmp-indentation ?s)
1405 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1406 (?R gnus-tmp-replied ?c)
1407 (?\[ gnus-tmp-opening-bracket ?c)
1408 (?\] gnus-tmp-closing-bracket ?c)
1409 (?\> (make-string gnus-tmp-level ? ) ?s)
1410 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1411 (?i gnus-tmp-score ?d)
1412 (?z gnus-tmp-score-char ?c)
1413 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1414 (?U gnus-tmp-unread ?c)
1415 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1416 ?s)
1417 (?t (gnus-summary-number-of-articles-in-thread
1418 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1419 ?d)
1420 (?e (gnus-summary-number-of-articles-in-thread
1421 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1422 ?c)
1423 (?u gnus-tmp-user-defined ?s)
1424 (?P (gnus-pick-line-number) ?d)
1425 (?B gnus-tmp-thread-tree-header-string ?s)
1426 (user-date (gnus-user-date
1427 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1428 "An alist of format specifications that can appear in summary lines.
1429 These are paired with what variables they correspond with, along with
1430 the type of the variable (string, integer, character, etc).")
1431
1432 (defvar gnus-summary-dummy-line-format-alist
1433 `((?S gnus-tmp-subject ?s)
1434 (?N gnus-tmp-number ?d)
1435 (?u gnus-tmp-user-defined ?s)))
1436
1437 (defvar gnus-summary-mode-line-format-alist
1438 `((?G gnus-tmp-group-name ?s)
1439 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1440 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1441 (?A gnus-tmp-article-number ?d)
1442 (?Z gnus-tmp-unread-and-unselected ?s)
1443 (?V gnus-version ?s)
1444 (?U gnus-tmp-unread-and-unticked ?d)
1445 (?S gnus-tmp-subject ?s)
1446 (?e gnus-tmp-unselected ?d)
1447 (?u gnus-tmp-user-defined ?s)
1448 (?d (length gnus-newsgroup-dormant) ?d)
1449 (?t (length gnus-newsgroup-marked) ?d)
1450 (?h (length gnus-newsgroup-spam-marked) ?d)
1451 (?r (length gnus-newsgroup-reads) ?d)
1452 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1453 (?E gnus-newsgroup-expunged-tally ?d)
1454 (?s (gnus-current-score-file-nondirectory) ?s)))
1455
1456 ;; This is here rather than in gnus-art for compilation reasons.
1457 (defvar gnus-article-mode-line-format-alist
1458 (nconc '((?w (gnus-article-wash-status) ?s)
1459 (?m (gnus-article-mime-part-status) ?s))
1460 gnus-summary-mode-line-format-alist))
1461
1462 (defvar gnus-last-search-regexp nil
1463 "Default regexp for article search command.")
1464
1465 (defvar gnus-last-shell-command nil
1466 "Default shell command on article.")
1467
1468 (defvar gnus-newsgroup-agentized nil
1469 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1470 (defvar gnus-newsgroup-begin nil)
1471 (defvar gnus-newsgroup-end nil)
1472 (defvar gnus-newsgroup-last-rmail nil)
1473 (defvar gnus-newsgroup-last-mail nil)
1474 (defvar gnus-newsgroup-last-folder nil)
1475 (defvar gnus-newsgroup-last-file nil)
1476 (defvar gnus-newsgroup-last-directory nil)
1477 (defvar gnus-newsgroup-auto-expire nil)
1478 (defvar gnus-newsgroup-active nil)
1479 (defvar gnus-newsgroup-highest nil)
1480
1481 (defvar gnus-newsgroup-data nil)
1482 (defvar gnus-newsgroup-data-reverse nil)
1483 (defvar gnus-newsgroup-limit nil)
1484 (defvar gnus-newsgroup-limits nil)
1485 (defvar gnus-summary-use-undownloaded-faces nil)
1486
1487 (defvar gnus-newsgroup-unreads nil
1488 "Sorted list of unread articles in the current newsgroup.")
1489
1490 (defvar gnus-newsgroup-unselected nil
1491 "Sorted list of unselected unread articles in the current newsgroup.")
1492
1493 (defvar gnus-newsgroup-reads nil
1494 "Alist of read articles and article marks in the current newsgroup.")
1495
1496 (defvar gnus-newsgroup-expunged-tally nil)
1497
1498 (defvar gnus-newsgroup-marked nil
1499 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1500
1501 (defvar gnus-newsgroup-spam-marked nil
1502 "List of ranges of articles that have been marked as spam.")
1503
1504 (defvar gnus-newsgroup-killed nil
1505 "List of ranges of articles that have been through the scoring process.")
1506
1507 (defvar gnus-newsgroup-cached nil
1508 "Sorted list of articles that come from the article cache.")
1509
1510 (defvar gnus-newsgroup-saved nil
1511 "List of articles that have been saved.")
1512
1513 (defvar gnus-newsgroup-kill-headers nil)
1514
1515 (defvar gnus-newsgroup-replied nil
1516 "List of articles that have been replied to in the current newsgroup.")
1517
1518 (defvar gnus-newsgroup-forwarded nil
1519 "List of articles that have been forwarded in the current newsgroup.")
1520
1521 (defvar gnus-newsgroup-expirable nil
1522 "Sorted list of articles in the current newsgroup that can be expired.")
1523
1524 (defvar gnus-newsgroup-processable nil
1525 "List of articles in the current newsgroup that can be processed.")
1526
1527 (defvar gnus-newsgroup-downloadable nil
1528 "Sorted list of articles in the current newsgroup that can be processed.")
1529
1530 (defvar gnus-newsgroup-unfetched nil
1531 "Sorted list of articles in the current newsgroup whose headers have
1532 not been fetched into the agent.
1533
1534 This list will always be a subset of gnus-newsgroup-undownloaded.")
1535
1536 (defvar gnus-newsgroup-undownloaded nil
1537 "List of articles in the current newsgroup that haven't been downloaded.")
1538
1539 (defvar gnus-newsgroup-unsendable nil
1540 "List of articles in the current newsgroup that won't be sent.")
1541
1542 (defvar gnus-newsgroup-bookmarks nil
1543 "List of articles in the current newsgroup that have bookmarks.")
1544
1545 (defvar gnus-newsgroup-dormant nil
1546 "Sorted list of dormant articles in the current newsgroup.")
1547
1548 (defvar gnus-newsgroup-unseen nil
1549 "List of unseen articles in the current newsgroup.")
1550
1551 (defvar gnus-newsgroup-seen nil
1552 "Range of seen articles in the current newsgroup.")
1553
1554 (defvar gnus-newsgroup-unexist nil
1555 "Range of unexisting articles in the current newsgroup.")
1556
1557 (defvar gnus-newsgroup-articles nil
1558 "List of articles in the current newsgroup.")
1559
1560 (defvar gnus-newsgroup-scored nil
1561 "List of scored articles in the current newsgroup.")
1562
1563 (defvar gnus-newsgroup-headers nil
1564 "List of article headers in the current newsgroup.")
1565
1566 (defvar gnus-newsgroup-threads nil)
1567
1568 (defvar gnus-newsgroup-prepared nil
1569 "Whether the current group has been prepared properly.")
1570
1571 (defvar gnus-newsgroup-ancient nil
1572 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1573
1574 (defvar gnus-newsgroup-sparse nil)
1575
1576 (defvar gnus-current-article nil)
1577 (defvar gnus-article-current nil)
1578 (defvar gnus-current-headers nil)
1579 (defvar gnus-have-all-headers nil)
1580 (defvar gnus-last-article nil)
1581 (defvar gnus-newsgroup-history nil)
1582 (defvar gnus-newsgroup-charset nil)
1583 (defvar gnus-newsgroup-ephemeral-charset nil)
1584 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1585
1586 (defvar gnus-article-before-search nil)
1587
1588 (defvar gnus-summary-local-variables
1589 '(gnus-newsgroup-name
1590
1591 ;; Marks lists
1592 gnus-newsgroup-unreads
1593 gnus-newsgroup-unselected
1594 gnus-newsgroup-marked
1595 gnus-newsgroup-spam-marked
1596 gnus-newsgroup-reads
1597 gnus-newsgroup-saved
1598 gnus-newsgroup-replied
1599 gnus-newsgroup-forwarded
1600 gnus-newsgroup-expirable
1601 gnus-newsgroup-killed
1602 gnus-newsgroup-unseen
1603 gnus-newsgroup-seen
1604 gnus-newsgroup-unexist
1605 gnus-newsgroup-cached
1606 gnus-newsgroup-downloadable
1607 gnus-newsgroup-undownloaded
1608 gnus-newsgroup-unsendable
1609
1610 gnus-newsgroup-begin gnus-newsgroup-end
1611 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1612 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1613 gnus-newsgroup-last-directory
1614 gnus-newsgroup-auto-expire
1615 gnus-newsgroup-processable
1616 gnus-newsgroup-unfetched
1617 gnus-newsgroup-articles
1618 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1619 gnus-newsgroup-headers gnus-newsgroup-threads
1620 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1621 gnus-current-article gnus-current-headers gnus-have-all-headers
1622 gnus-last-article gnus-article-internal-prepare-hook
1623 (gnus-summary-article-delete-hook . global)
1624 (gnus-summary-article-move-hook . global)
1625 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1626 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1627 gnus-thread-expunge-below
1628 gnus-score-alist gnus-current-score-file
1629 (gnus-summary-expunge-below . global)
1630 (gnus-summary-mark-below . global)
1631 (gnus-orphan-score . global)
1632 gnus-newsgroup-active gnus-scores-exclude-files
1633 gnus-newsgroup-highest
1634 gnus-newsgroup-history gnus-newsgroup-ancient
1635 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1636 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1637 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1638 (gnus-newsgroup-expunged-tally . 0)
1639 gnus-cache-removable-articles
1640 gnus-newsgroup-data gnus-newsgroup-data-reverse
1641 gnus-newsgroup-limit gnus-newsgroup-limits
1642 gnus-newsgroup-charset gnus-newsgroup-display
1643 gnus-summary-use-undownloaded-faces)
1644 "Variables that are buffer-local to the summary buffers.")
1645
1646 (defvar gnus-newsgroup-variables nil
1647 "A list of variables that have separate values in different newsgroups.
1648 A list of newsgroup (summary buffer) local variables, or cons of
1649 variables and their default expressions to be evalled (when the default
1650 values are not nil), that should be made global while the summary buffer
1651 is active.
1652
1653 Note: The default expressions will be evaluated (using function `eval')
1654 before assignment to the local variable rather than just assigned to it.
1655 If the default expression is the symbol `global', that symbol will not
1656 be evaluated but the global value of the local variable will be used
1657 instead.
1658
1659 These variables can be used to set variables in the group parameters
1660 while still allowing them to affect operations done in other buffers.
1661 For example:
1662
1663 \(setq gnus-newsgroup-variables
1664 \\='(message-use-followup-to
1665 (gnus-visible-headers .
1666 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1667 ")
1668
1669 (eval-when-compile
1670 ;; Bind features so that require will believe that gnus-sum has
1671 ;; already been loaded (avoids infinite recursion)
1672 (let ((features (cons 'gnus-sum features)))
1673 (require 'gnus-art)))
1674
1675 ;; MIME stuff.
1676
1677 (defvar gnus-decode-encoded-word-methods
1678 '(mail-decode-encoded-word-string)
1679 "List of methods used to decode encoded words.
1680
1681 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1682 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1683 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1684 whose names match REGEXP.
1685
1686 For example:
1687 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1688 mail-decode-encoded-word-string
1689 (\"chinese\" . rfc1843-decode-string))")
1690
1691 (defvar gnus-decode-encoded-word-methods-cache nil)
1692
1693 (defun gnus-multi-decode-encoded-word-string (string)
1694 "Apply the functions from `gnus-encoded-word-methods' that match."
1695 (unless (and gnus-decode-encoded-word-methods-cache
1696 (eq gnus-newsgroup-name
1697 (car gnus-decode-encoded-word-methods-cache)))
1698 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1699 (dolist (method gnus-decode-encoded-word-methods)
1700 (if (symbolp method)
1701 (nconc gnus-decode-encoded-word-methods-cache (list method))
1702 (if (and gnus-newsgroup-name
1703 (string-match (car method) gnus-newsgroup-name))
1704 (nconc gnus-decode-encoded-word-methods-cache
1705 (list (cdr method)))))))
1706 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1707 (setq string (funcall method string))))
1708
1709 ;; Subject simplification.
1710
1711 (defun gnus-simplify-whitespace (str)
1712 "Remove excessive whitespace from STR."
1713 ;; Multiple spaces.
1714 (while (string-match "[ \t][ \t]+" str)
1715 (setq str (concat (substring str 0 (match-beginning 0))
1716 " "
1717 (substring str (match-end 0)))))
1718 ;; Leading spaces.
1719 (when (string-match "^[ \t]+" str)
1720 (setq str (substring str (match-end 0))))
1721 ;; Trailing spaces.
1722 (when (string-match "[ \t]+$" str)
1723 (setq str (substring str 0 (match-beginning 0))))
1724 str)
1725
1726 (defun gnus-simplify-all-whitespace (str)
1727 "Remove all whitespace from STR."
1728 (while (string-match "[ \t\n]+" str)
1729 (setq str (replace-match "" nil nil str)))
1730 str)
1731
1732 (defsubst gnus-simplify-subject-re (subject)
1733 "Remove \"Re:\" from subject lines."
1734 (if (string-match message-subject-re-regexp subject)
1735 (substring subject (match-end 0))
1736 subject))
1737
1738 (defun gnus-simplify-subject (subject &optional re-only)
1739 "Remove `Re:' and words in parentheses.
1740 If RE-ONLY is non-nil, strip leading `Re:'s only."
1741 (let ((case-fold-search t)) ;Ignore case.
1742 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1743 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1744 (setq subject (substring subject (match-end 0))))
1745 ;; Remove uninteresting prefixes.
1746 (when (and (not re-only)
1747 gnus-simplify-ignored-prefixes
1748 (string-match gnus-simplify-ignored-prefixes subject))
1749 (setq subject (substring subject (match-end 0))))
1750 ;; Remove words in parentheses from end.
1751 (unless re-only
1752 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1753 (setq subject (substring subject 0 (match-beginning 0)))))
1754 ;; Return subject string.
1755 subject))
1756
1757 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1758 ;; all whitespace.
1759 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1760 (goto-char (point-min))
1761 (while (re-search-forward regexp nil t)
1762 (replace-match (or newtext ""))))
1763
1764 (defun gnus-simplify-buffer-fuzzy (regexp)
1765 "Simplify string in the buffer fuzzily.
1766 The string in the accessible portion of the current buffer is simplified.
1767 It is assumed to be a single-line subject.
1768 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1769 matter is removed. Additional things can be deleted by setting
1770 `gnus-simplify-subject-fuzzy-regexp'."
1771 (let ((case-fold-search t)
1772 (modified-tick))
1773 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1774
1775 (while (not (eq modified-tick (buffer-modified-tick)))
1776 (setq modified-tick (buffer-modified-tick))
1777 (cond
1778 ((listp regexp)
1779 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1780 (regexp
1781 (gnus-simplify-buffer-fuzzy-step regexp)))
1782 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1783 (gnus-simplify-buffer-fuzzy-step
1784 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1785 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1786
1787 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1788 (gnus-simplify-buffer-fuzzy-step " +" " ")
1789 (gnus-simplify-buffer-fuzzy-step " $")
1790 (gnus-simplify-buffer-fuzzy-step "^ +")))
1791
1792 (defun gnus-simplify-subject-fuzzy (subject)
1793 "Simplify a subject string fuzzily.
1794 See `gnus-simplify-buffer-fuzzy' for details."
1795 (save-excursion
1796 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1797 (gnus-set-work-buffer)
1798 (let ((case-fold-search t))
1799 ;; Remove uninteresting prefixes.
1800 (when (and gnus-simplify-ignored-prefixes
1801 (string-match gnus-simplify-ignored-prefixes subject))
1802 (setq subject (substring subject (match-end 0))))
1803 (insert subject)
1804 (inline (gnus-simplify-buffer-fuzzy regexp))
1805 (buffer-string)))))
1806
1807 (defsubst gnus-simplify-subject-fully (subject)
1808 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1809 (cond
1810 (gnus-simplify-subject-functions
1811 (gnus-map-function gnus-simplify-subject-functions subject))
1812 ((null gnus-summary-gather-subject-limit)
1813 (gnus-simplify-subject-re subject))
1814 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1815 (gnus-simplify-subject-fuzzy subject))
1816 ((numberp gnus-summary-gather-subject-limit)
1817 (truncate-string-to-width (gnus-simplify-subject-re subject)
1818 gnus-summary-gather-subject-limit))
1819 (t
1820 subject)))
1821
1822 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1823 "Check whether two subjects are equal.
1824 If optional argument SIMPLE-FIRST is t, first argument is already
1825 simplified."
1826 (cond
1827 ((null simple-first)
1828 (equal (gnus-simplify-subject-fully s1)
1829 (gnus-simplify-subject-fully s2)))
1830 (t
1831 (equal s1
1832 (gnus-simplify-subject-fully s2)))))
1833
1834 (defun gnus-summary-bubble-group ()
1835 "Increase the score of the current group.
1836 This is a handy function to add to `gnus-summary-exit-hook' to
1837 increase the score of each group you read."
1838 (gnus-group-add-score gnus-newsgroup-name))
1839
1840 \f
1841 ;;;
1842 ;;; Gnus summary mode
1843 ;;;
1844
1845 (put 'gnus-summary-mode 'mode-class 'special)
1846
1847 (defvar gnus-article-commands-menu)
1848
1849 ;; Non-orthogonal keys
1850
1851 (gnus-define-keys gnus-summary-mode-map
1852 " " gnus-summary-next-page
1853 [?\S-\ ] gnus-summary-prev-page
1854 "\177" gnus-summary-prev-page
1855 [delete] gnus-summary-prev-page
1856 "\r" gnus-summary-scroll-up
1857 "\M-\r" gnus-summary-scroll-down
1858 "n" gnus-summary-next-unread-article
1859 "p" gnus-summary-prev-unread-article
1860 "N" gnus-summary-next-article
1861 "P" gnus-summary-prev-article
1862 "\M-\C-n" gnus-summary-next-same-subject
1863 "\M-\C-p" gnus-summary-prev-same-subject
1864 "\M-n" gnus-summary-next-unread-subject
1865 "\M-p" gnus-summary-prev-unread-subject
1866 "." gnus-summary-first-unread-article
1867 "," gnus-summary-best-unread-article
1868 "\M-s" gnus-summary-search-article-forward
1869 "\M-r" gnus-summary-search-article-backward
1870 "\M-S" gnus-summary-repeat-search-article-forward
1871 "\M-R" gnus-summary-repeat-search-article-backward
1872 "<" gnus-summary-beginning-of-article
1873 ">" gnus-summary-end-of-article
1874 "j" gnus-summary-goto-article
1875 "^" gnus-summary-refer-parent-article
1876 "\M-^" gnus-summary-refer-article
1877 "u" gnus-summary-tick-article-forward
1878 "!" gnus-summary-tick-article-forward
1879 "U" gnus-summary-tick-article-backward
1880 "d" gnus-summary-mark-as-read-forward
1881 "D" gnus-summary-mark-as-read-backward
1882 "E" gnus-summary-mark-as-expirable
1883 "\M-u" gnus-summary-clear-mark-forward
1884 "\M-U" gnus-summary-clear-mark-backward
1885 "k" gnus-summary-kill-same-subject-and-select
1886 "\C-k" gnus-summary-kill-same-subject
1887 "\M-\C-k" gnus-summary-kill-thread
1888 "\M-\C-l" gnus-summary-lower-thread
1889 "e" gnus-summary-edit-article
1890 "#" gnus-summary-mark-as-processable
1891 "\M-#" gnus-summary-unmark-as-processable
1892 "\M-\C-t" gnus-summary-toggle-threads
1893 "\M-\C-s" gnus-summary-show-thread
1894 "\M-\C-h" gnus-summary-hide-thread
1895 "\M-\C-f" gnus-summary-next-thread
1896 "\M-\C-b" gnus-summary-prev-thread
1897 [(meta down)] gnus-summary-next-thread
1898 [(meta up)] gnus-summary-prev-thread
1899 "\M-\C-u" gnus-summary-up-thread
1900 "\M-\C-d" gnus-summary-down-thread
1901 "&" gnus-summary-execute-command
1902 "c" gnus-summary-catchup-and-exit
1903 "\C-w" gnus-summary-mark-region-as-read
1904 "\C-t" gnus-summary-toggle-truncation
1905 "?" gnus-summary-mark-as-dormant
1906 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1907 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1908 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1909 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1910 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1911 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1912 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1913 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1914 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1915 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1916 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1917 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1918 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1919 "=" gnus-summary-expand-window
1920 "\C-x\C-s" gnus-summary-reselect-current-group
1921 "\M-g" gnus-summary-rescan-group
1922 "\C-c\C-r" gnus-summary-caesar-message
1923 "f" gnus-summary-followup
1924 "F" gnus-summary-followup-with-original
1925 "C" gnus-summary-cancel-article
1926 "r" gnus-summary-reply
1927 "R" gnus-summary-reply-with-original
1928 "\C-c\C-f" gnus-summary-mail-forward
1929 "o" gnus-summary-save-article
1930 "\C-o" gnus-summary-save-article-mail
1931 "|" gnus-summary-pipe-output
1932 "\M-k" gnus-summary-edit-local-kill
1933 "\M-K" gnus-summary-edit-global-kill
1934 ;; "V" gnus-version
1935 "\C-c\C-d" gnus-summary-describe-group
1936 "q" gnus-summary-exit
1937 "Q" gnus-summary-exit-no-update
1938 "\C-c\C-i" gnus-info-find-node
1939 [mouse-2] gnus-mouse-pick-article
1940 [follow-link] mouse-face
1941 "m" gnus-summary-mail-other-window
1942 "a" gnus-summary-post-news
1943 "x" gnus-summary-limit-to-unread
1944 "s" gnus-summary-isearch-article
1945 "\t" gnus-summary-widget-forward
1946 [backtab] gnus-summary-widget-backward
1947 "t" gnus-summary-toggle-header
1948 "g" gnus-summary-show-article
1949 "l" gnus-summary-goto-last-article
1950 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1951 "\C-d" gnus-summary-enter-digest-group
1952 "\M-\C-d" gnus-summary-read-document
1953 "\M-\C-e" gnus-summary-edit-parameters
1954 "\M-\C-a" gnus-summary-customize-parameters
1955 "\C-c\C-b" gnus-bug
1956 "*" gnus-cache-enter-article
1957 "\M-*" gnus-cache-remove-article
1958 "\M-&" gnus-summary-universal-argument
1959 "\C-l" gnus-recenter
1960 "I" gnus-summary-increase-score
1961 "L" gnus-summary-lower-score
1962 "\M-i" gnus-symbolic-argument
1963 "h" gnus-summary-select-article-buffer
1964
1965 "b" gnus-article-view-part
1966 "\M-t" gnus-summary-toggle-display-buttonized
1967
1968 "V" gnus-summary-score-map
1969 "X" gnus-uu-extract-map
1970 "S" gnus-summary-send-map)
1971
1972 ;; Sort of orthogonal keymap
1973 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1974 "t" gnus-summary-tick-article-forward
1975 "!" gnus-summary-tick-article-forward
1976 "d" gnus-summary-mark-as-read-forward
1977 "r" gnus-summary-mark-as-read-forward
1978 "c" gnus-summary-clear-mark-forward
1979 " " gnus-summary-clear-mark-forward
1980 "e" gnus-summary-mark-as-expirable
1981 "x" gnus-summary-mark-as-expirable
1982 "?" gnus-summary-mark-as-dormant
1983 "b" gnus-summary-set-bookmark
1984 "B" gnus-summary-remove-bookmark
1985 "#" gnus-summary-mark-as-processable
1986 "\M-#" gnus-summary-unmark-as-processable
1987 "S" gnus-summary-limit-include-expunged
1988 "C" gnus-summary-catchup
1989 "H" gnus-summary-catchup-to-here
1990 "h" gnus-summary-catchup-from-here
1991 "\C-c" gnus-summary-catchup-all
1992 "k" gnus-summary-kill-same-subject-and-select
1993 "K" gnus-summary-kill-same-subject
1994 "P" gnus-uu-mark-map)
1995
1996 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1997 "c" gnus-summary-clear-above
1998 "u" gnus-summary-tick-above
1999 "m" gnus-summary-mark-above
2000 "k" gnus-summary-kill-below)
2001
2002 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
2003 "/" gnus-summary-limit-to-subject
2004 "n" gnus-summary-limit-to-articles
2005 "b" gnus-summary-limit-to-bodies
2006 "h" gnus-summary-limit-to-headers
2007 "w" gnus-summary-pop-limit
2008 "s" gnus-summary-limit-to-subject
2009 "a" gnus-summary-limit-to-author
2010 "u" gnus-summary-limit-to-unread
2011 "m" gnus-summary-limit-to-marks
2012 "M" gnus-summary-limit-exclude-marks
2013 "v" gnus-summary-limit-to-score
2014 "*" gnus-summary-limit-include-cached
2015 "D" gnus-summary-limit-include-dormant
2016 "T" gnus-summary-limit-include-thread
2017 "d" gnus-summary-limit-exclude-dormant
2018 "t" gnus-summary-limit-to-age
2019 "." gnus-summary-limit-to-unseen
2020 "x" gnus-summary-limit-to-extra
2021 "p" gnus-summary-limit-to-display-predicate
2022 "E" gnus-summary-limit-include-expunged
2023 "c" gnus-summary-limit-exclude-childless-dormant
2024 "C" gnus-summary-limit-mark-excluded-as-read
2025 "o" gnus-summary-insert-old-articles
2026 "N" gnus-summary-insert-new-articles
2027 "S" gnus-summary-limit-to-singletons
2028 "r" gnus-summary-limit-to-replied
2029 "R" gnus-summary-limit-to-recipient
2030 "A" gnus-summary-limit-to-address)
2031
2032 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2033 "n" gnus-summary-next-unread-article
2034 "p" gnus-summary-prev-unread-article
2035 "N" gnus-summary-next-article
2036 "P" gnus-summary-prev-article
2037 "\C-n" gnus-summary-next-same-subject
2038 "\C-p" gnus-summary-prev-same-subject
2039 "\M-n" gnus-summary-next-unread-subject
2040 "\M-p" gnus-summary-prev-unread-subject
2041 "f" gnus-summary-first-unread-article
2042 "b" gnus-summary-best-unread-article
2043 "j" gnus-summary-goto-article
2044 "g" gnus-summary-goto-subject
2045 "l" gnus-summary-goto-last-article
2046 "o" gnus-summary-pop-article)
2047
2048 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2049 "k" gnus-summary-kill-thread
2050 "E" gnus-summary-expire-thread
2051 "l" gnus-summary-lower-thread
2052 "i" gnus-summary-raise-thread
2053 "T" gnus-summary-toggle-threads
2054 "t" gnus-summary-rethread-current
2055 "^" gnus-summary-reparent-thread
2056 "\M-^" gnus-summary-reparent-children
2057 "s" gnus-summary-show-thread
2058 "S" gnus-summary-show-all-threads
2059 "h" gnus-summary-hide-thread
2060 "H" gnus-summary-hide-all-threads
2061 "n" gnus-summary-next-thread
2062 "p" gnus-summary-prev-thread
2063 "u" gnus-summary-up-thread
2064 "o" gnus-summary-top-thread
2065 "d" gnus-summary-down-thread
2066 "#" gnus-uu-mark-thread
2067 "\M-#" gnus-uu-unmark-thread)
2068
2069 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2070 "g" gnus-summary-prepare
2071 "c" gnus-summary-insert-cached-articles
2072 "d" gnus-summary-insert-dormant-articles
2073 "t" gnus-summary-insert-ticked-articles)
2074
2075 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2076 "c" gnus-summary-catchup-and-exit
2077 "C" gnus-summary-catchup-all-and-exit
2078 "E" gnus-summary-exit-no-update
2079 "Q" gnus-summary-exit
2080 "Z" gnus-summary-exit
2081 "n" gnus-summary-catchup-and-goto-next-group
2082 "p" gnus-summary-catchup-and-goto-prev-group
2083 "R" gnus-summary-reselect-current-group
2084 "G" gnus-summary-rescan-group
2085 "N" gnus-summary-next-group
2086 "s" gnus-summary-save-newsrc
2087 "P" gnus-summary-prev-group)
2088
2089 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2090 " " gnus-summary-next-page
2091 "n" gnus-summary-next-page
2092 [?\S-\ ] gnus-summary-prev-page
2093 "\177" gnus-summary-prev-page
2094 [delete] gnus-summary-prev-page
2095 "p" gnus-summary-prev-page
2096 "\r" gnus-summary-scroll-up
2097 "\M-\r" gnus-summary-scroll-down
2098 "<" gnus-summary-beginning-of-article
2099 ">" gnus-summary-end-of-article
2100 "b" gnus-summary-beginning-of-article
2101 "e" gnus-summary-end-of-article
2102 "^" gnus-summary-refer-parent-article
2103 "r" gnus-summary-refer-parent-article
2104 "C" gnus-summary-show-complete-article
2105 "D" gnus-summary-enter-digest-group
2106 "R" gnus-summary-refer-references
2107 "T" gnus-summary-refer-thread
2108 "W" gnus-warp-to-article
2109 "g" gnus-summary-show-article
2110 "s" gnus-summary-isearch-article
2111 "\t" gnus-summary-widget-forward
2112 [backtab] gnus-summary-widget-backward
2113 "P" gnus-summary-print-article
2114 "S" gnus-sticky-article
2115 "M" gnus-mailing-list-insinuate
2116 "t" gnus-article-babel)
2117
2118 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2119 "b" gnus-article-add-buttons
2120 "B" gnus-article-add-buttons-to-head
2121 "o" gnus-article-treat-overstrike
2122 "e" gnus-article-emphasize
2123 "w" gnus-article-fill-cited-article
2124 "Q" gnus-article-fill-long-lines
2125 "L" gnus-article-toggle-truncate-lines
2126 "C" gnus-article-capitalize-sentences
2127 "c" gnus-article-remove-cr
2128 "q" gnus-article-de-quoted-unreadable
2129 "6" gnus-article-de-base64-unreadable
2130 "Z" gnus-article-decode-HZ
2131 "A" gnus-article-treat-ansi-sequences
2132 "h" gnus-article-wash-html
2133 "u" gnus-article-unsplit-urls
2134 "s" gnus-summary-force-verify-and-decrypt
2135 "f" gnus-article-display-x-face
2136 "l" gnus-summary-stop-page-breaking
2137 "r" gnus-summary-caesar-message
2138 "m" gnus-summary-morse-message
2139 "t" gnus-summary-toggle-header
2140 "g" gnus-treat-smiley
2141 "v" gnus-summary-verbose-headers
2142 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2143 "p" gnus-article-verify-x-pgp-sig
2144 "d" gnus-article-treat-dumbquotes
2145 "U" gnus-article-treat-non-ascii
2146 "i" gnus-summary-idna-message)
2147
2148 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2149 ;; mnemonic: deuglif*Y*
2150 "u" gnus-article-outlook-unwrap-lines
2151 "a" gnus-article-outlook-repair-attribution
2152 "c" gnus-article-outlook-rearrange-citation
2153 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2154
2155 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2156 "a" gnus-article-hide
2157 "h" gnus-article-hide-headers
2158 "b" gnus-article-hide-boring-headers
2159 "s" gnus-article-hide-signature
2160 "c" gnus-article-hide-citation
2161 "C" gnus-article-hide-citation-in-followups
2162 "l" gnus-article-hide-list-identifiers
2163 "B" gnus-article-strip-banner
2164 "P" gnus-article-hide-pem
2165 "\C-c" gnus-article-hide-citation-maybe)
2166
2167 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2168 "a" gnus-article-highlight
2169 "h" gnus-article-highlight-headers
2170 "c" gnus-article-highlight-citation
2171 "s" gnus-article-highlight-signature)
2172
2173 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2174 "f" gnus-article-treat-fold-headers
2175 "u" gnus-article-treat-unfold-headers
2176 "n" gnus-article-treat-fold-newsgroups)
2177
2178 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2179 "x" gnus-article-display-x-face
2180 "d" gnus-article-display-face
2181 "s" gnus-treat-smiley
2182 "D" gnus-article-remove-images
2183 "W" gnus-article-show-images
2184 "f" gnus-treat-from-picon
2185 "m" gnus-treat-mail-picon
2186 "n" gnus-treat-newsgroups-picon
2187 "g" gnus-treat-from-gravatar
2188 "h" gnus-treat-mail-gravatar)
2189
2190 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2191 "w" gnus-article-decode-mime-words
2192 "c" gnus-article-decode-charset
2193 "h" gnus-mime-buttonize-attachments-in-header
2194 "v" gnus-mime-view-all-parts
2195 "b" gnus-article-view-part)
2196
2197 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2198 "z" gnus-article-date-ut
2199 "u" gnus-article-date-ut
2200 "l" gnus-article-date-local
2201 "p" gnus-article-date-english
2202 "e" gnus-article-date-lapsed
2203 "o" gnus-article-date-original
2204 "i" gnus-article-date-iso8601
2205 "s" gnus-article-date-user)
2206
2207 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2208 "t" gnus-article-remove-trailing-blank-lines
2209 "l" gnus-article-strip-leading-blank-lines
2210 "m" gnus-article-strip-multiple-blank-lines
2211 "a" gnus-article-strip-blank-lines
2212 "A" gnus-article-strip-all-blank-lines
2213 "s" gnus-article-strip-leading-space
2214 "e" gnus-article-strip-trailing-space
2215 "w" gnus-article-remove-leading-whitespace)
2216
2217 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2218 "v" gnus-version
2219 "d" gnus-summary-describe-group
2220 "h" gnus-summary-describe-briefly
2221 "i" gnus-info-find-node)
2222
2223 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2224 "e" gnus-summary-expire-articles
2225 "\M-\C-e" gnus-summary-expire-articles-now
2226 "\177" gnus-summary-delete-article
2227 [delete] gnus-summary-delete-article
2228 [backspace] gnus-summary-delete-article
2229 "m" gnus-summary-move-article
2230 "r" gnus-summary-respool-article
2231 "w" gnus-summary-edit-article
2232 "c" gnus-summary-copy-article
2233 "B" gnus-summary-crosspost-article
2234 "q" gnus-summary-respool-query
2235 "t" gnus-summary-respool-trace
2236 "i" gnus-summary-import-article
2237 "I" gnus-summary-create-article
2238 "p" gnus-summary-article-posted-p)
2239
2240 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2241 "o" gnus-summary-save-article
2242 "m" gnus-summary-save-article-mail
2243 "F" gnus-summary-write-article-file
2244 "r" gnus-summary-save-article-rmail
2245 "f" gnus-summary-save-article-file
2246 "b" gnus-summary-save-article-body-file
2247 "B" gnus-summary-write-article-body-file
2248 "h" gnus-summary-save-article-folder
2249 "v" gnus-summary-save-article-vm
2250 "p" gnus-summary-pipe-output
2251 "P" gnus-summary-muttprint)
2252
2253 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2254 "b" gnus-summary-display-buttonized
2255 "m" gnus-summary-repair-multipart
2256 "v" gnus-article-view-part
2257 "o" gnus-article-save-part
2258 "O" gnus-article-save-part-and-strip
2259 "r" gnus-article-replace-part
2260 "d" gnus-article-delete-part
2261 "t" gnus-article-view-part-as-type
2262 "j" gnus-article-jump-to-part
2263 "c" gnus-article-copy-part
2264 "C" gnus-article-view-part-as-charset
2265 "e" gnus-article-view-part-externally
2266 "H" gnus-article-browse-html-article
2267 "E" gnus-article-encrypt-body
2268 "i" gnus-article-inline-part
2269 "|" gnus-article-pipe-part)
2270
2271 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2272 "p" gnus-summary-mark-as-processable
2273 "u" gnus-summary-unmark-as-processable
2274 "U" gnus-summary-unmark-all-processable
2275 "v" gnus-uu-mark-over
2276 "s" gnus-uu-mark-series
2277 "r" gnus-uu-mark-region
2278 "g" gnus-uu-unmark-region
2279 "R" gnus-uu-mark-by-regexp
2280 "G" gnus-uu-unmark-by-regexp
2281 "t" gnus-uu-mark-thread
2282 "T" gnus-uu-unmark-thread
2283 "a" gnus-uu-mark-all
2284 "b" gnus-uu-mark-buffer
2285 "S" gnus-uu-mark-sparse
2286 "k" gnus-summary-kill-process-mark
2287 "y" gnus-summary-yank-process-mark
2288 "w" gnus-summary-save-process-mark
2289 "i" gnus-uu-invert-processable)
2290
2291 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2292 ;;"x" gnus-uu-extract-any
2293 "m" gnus-summary-save-parts
2294 "u" gnus-uu-decode-uu
2295 "U" gnus-uu-decode-uu-and-save
2296 "s" gnus-uu-decode-unshar
2297 "S" gnus-uu-decode-unshar-and-save
2298 "o" gnus-uu-decode-save
2299 "O" gnus-uu-decode-save
2300 "b" gnus-uu-decode-binhex
2301 "B" gnus-uu-decode-binhex
2302 "Y" gnus-uu-decode-yenc
2303 "p" gnus-uu-decode-postscript
2304 "P" gnus-uu-decode-postscript-and-save)
2305
2306 (gnus-define-keys
2307 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2308 "u" gnus-uu-decode-uu-view
2309 "U" gnus-uu-decode-uu-and-save-view
2310 "s" gnus-uu-decode-unshar-view
2311 "S" gnus-uu-decode-unshar-and-save-view
2312 "o" gnus-uu-decode-save-view
2313 "O" gnus-uu-decode-save-view
2314 "b" gnus-uu-decode-binhex-view
2315 "B" gnus-uu-decode-binhex-view
2316 "p" gnus-uu-decode-postscript-view
2317 "P" gnus-uu-decode-postscript-and-save-view)
2318
2319 (defvar gnus-article-post-menu nil)
2320
2321 (defconst gnus-summary-menu-maxlen 20)
2322
2323 (defun gnus-summary-menu-split (menu)
2324 ;; If we have lots of elements, divide them into groups of 20
2325 ;; and make a pane (or submenu) for each one.
2326 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2327 (let ((menu menu) sublists next
2328 (i 1))
2329 (while menu
2330 ;; Pull off the next gnus-summary-menu-maxlen elements
2331 ;; and make them the next element of sublist.
2332 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2333 (if next
2334 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2335 nil))
2336 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2337 (aref (car (last menu)) 0)) menu)
2338 sublists))
2339 (setq i (1+ i))
2340 (setq menu next))
2341 (nreverse sublists))
2342 ;; Few elements--put them all in one pane.
2343 menu))
2344
2345 (defun gnus-summary-make-menu-bar ()
2346 (gnus-turn-off-edit-menu 'summary)
2347
2348 (unless (boundp 'gnus-summary-misc-menu)
2349
2350 (easy-menu-define
2351 gnus-summary-kill-menu gnus-summary-mode-map ""
2352 (cons
2353 "Score"
2354 (nconc
2355 (list
2356 ["Customize" gnus-score-customize t])
2357 (gnus-make-score-map 'increase)
2358 (gnus-make-score-map 'lower)
2359 '(("Mark"
2360 ["Kill below" gnus-summary-kill-below t]
2361 ["Mark above" gnus-summary-mark-above t]
2362 ["Tick above" gnus-summary-tick-above t]
2363 ["Clear above" gnus-summary-clear-above t])
2364 ["Current article score" gnus-summary-current-score t]
2365 ["Current thread score" (gnus-summary-current-score 'total) t]
2366 ["Set score" gnus-summary-set-score t]
2367 ["Switch current score file..." gnus-score-change-score-file t]
2368 ["Set mark below..." gnus-score-set-mark-below t]
2369 ["Set expunge below..." gnus-score-set-expunge-below t]
2370 ["Edit current score file" gnus-score-edit-current-scores t]
2371 ["Edit score file..." gnus-score-edit-file t]
2372 ["Trace score" gnus-score-find-trace t]
2373 ["Find words" gnus-score-find-favourite-words t]
2374 ["Rescore buffer" gnus-summary-rescore t]
2375 ["Increase score..." gnus-summary-increase-score t]
2376 ["Lower score..." gnus-summary-lower-score t]))))
2377
2378 ;; Define both the Article menu in the summary buffer and the
2379 ;; equivalent Commands menu in the article buffer here for
2380 ;; consistency.
2381 (let ((innards
2382 `(("Hide"
2383 ["All" gnus-article-hide t]
2384 ["Headers" gnus-article-hide-headers t]
2385 ["Signature" gnus-article-hide-signature t]
2386 ["Citation" gnus-article-hide-citation t]
2387 ["List identifiers" gnus-article-hide-list-identifiers t]
2388 ["Banner" gnus-article-strip-banner t]
2389 ["Boring headers" gnus-article-hide-boring-headers t])
2390 ("Highlight"
2391 ["All" gnus-article-highlight t]
2392 ["Headers" gnus-article-highlight-headers t]
2393 ["Signature" gnus-article-highlight-signature t]
2394 ["Citation" gnus-article-highlight-citation t])
2395 ("MIME"
2396 ["Words" gnus-article-decode-mime-words t]
2397 ["Charset" gnus-article-decode-charset t]
2398 ["QP" gnus-article-de-quoted-unreadable t]
2399 ["Base64" gnus-article-de-base64-unreadable t]
2400 ["View MIME buttons" gnus-summary-display-buttonized t]
2401 ["View MIME buttons in header"
2402 gnus-mime-buttonize-attachments-in-header t]
2403 ["View all" gnus-mime-view-all-parts t]
2404 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2405 ["Encrypt body" gnus-article-encrypt-body
2406 :active (not (gnus-group-read-only-p))
2407 ,@(if (featurep 'xemacs) nil
2408 '(:help "Encrypt the message body on disk"))]
2409 ["Extract all parts..." gnus-summary-save-parts t]
2410 ("Multipart"
2411 ["Repair multipart" gnus-summary-repair-multipart t]
2412 ["Pipe part..." gnus-article-pipe-part t]
2413 ["Inline part" gnus-article-inline-part t]
2414 ["View part as type..." gnus-article-view-part-as-type t]
2415 ["Encrypt body" gnus-article-encrypt-body
2416 :active (not (gnus-group-read-only-p))
2417 ,@(if (featurep 'xemacs) nil
2418 '(:help "Encrypt the message body on disk"))]
2419 ["View part externally" gnus-article-view-part-externally t]
2420 ["View HTML parts in browser" gnus-article-browse-html-article t]
2421 ["View part with charset..." gnus-article-view-part-as-charset t]
2422 ["Copy part" gnus-article-copy-part t]
2423 ["Save part..." gnus-article-save-part t]
2424 ["View part" gnus-article-view-part t]))
2425 ("Date"
2426 ["Local" gnus-article-date-local t]
2427 ["ISO8601" gnus-article-date-iso8601 t]
2428 ["UT" gnus-article-date-ut t]
2429 ["Original" gnus-article-date-original t]
2430 ["Lapsed" gnus-article-date-lapsed t]
2431 ["User-defined" gnus-article-date-user t])
2432 ("Display"
2433 ["Display HTML images" gnus-article-show-images t]
2434 ["Remove images" gnus-article-remove-images t]
2435 ["Toggle smiley" gnus-treat-smiley t]
2436 ["Show X-Face" gnus-article-display-x-face t]
2437 ["Show picons in From" gnus-treat-from-picon t]
2438 ["Show picons in mail headers" gnus-treat-mail-picon t]
2439 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2440 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2441 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2442 ("View as different encoding"
2443 ,@(gnus-summary-menu-split
2444 (mapcar
2445 (lambda (cs)
2446 ;; Since easymenu under Emacs doesn't allow
2447 ;; lambda forms for menu commands, we should
2448 ;; provide intern'ed function symbols.
2449 (let ((command (intern (format "\
2450 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2451 (fset command
2452 `(lambda ()
2453 (interactive)
2454 (let ((gnus-summary-show-article-charset-alist
2455 '((1 . ,cs))))
2456 (gnus-summary-show-article 1))))
2457 `[,(symbol-name cs) ,command t]))
2458 (sort (if (fboundp 'coding-system-list)
2459 (coding-system-list)
2460 (mapcar 'car mm-mime-mule-charset-alist))
2461 'string<)))))
2462 ("Washing"
2463 ("Remove Blanks"
2464 ["Leading" gnus-article-strip-leading-blank-lines t]
2465 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2466 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2467 ["All of the above" gnus-article-strip-blank-lines t]
2468 ["All" gnus-article-strip-all-blank-lines t]
2469 ["Leading space" gnus-article-strip-leading-space t]
2470 ["Trailing space" gnus-article-strip-trailing-space t]
2471 ["Leading space in headers"
2472 gnus-article-remove-leading-whitespace t])
2473 ["Overstrike" gnus-article-treat-overstrike t]
2474 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2475 ["Non-ASCII" gnus-article-treat-non-ascii t]
2476 ["Emphasis" gnus-article-emphasize t]
2477 ["Word wrap" gnus-article-fill-cited-article t]
2478 ["Fill long lines" gnus-article-fill-long-lines t]
2479 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2480 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2481 ["Remove CR" gnus-article-remove-cr t]
2482 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2483 ["Base64" gnus-article-de-base64-unreadable t]
2484 ["Rot 13" gnus-summary-caesar-message
2485 ,@(if (featurep 'xemacs) '(t)
2486 '(:help "\"Caesar rotate\" article by 13"))]
2487 ["De-IDNA" gnus-summary-idna-message t]
2488 ["Morse decode" gnus-summary-morse-message t]
2489 ["Unix pipe..." gnus-summary-pipe-message t]
2490 ["Add buttons" gnus-article-add-buttons t]
2491 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2492 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2493 ["Verbose header" gnus-summary-verbose-headers t]
2494 ["Toggle header" gnus-summary-toggle-header t]
2495 ["Unfold headers" gnus-article-treat-unfold-headers t]
2496 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2497 ["Html" gnus-article-wash-html t]
2498 ["Unsplit URLs" gnus-article-unsplit-urls t]
2499 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2500 ["Decode HZ" gnus-article-decode-HZ t]
2501 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2502 ("(Outlook) Deuglify"
2503 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2504 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2505 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2506 ["Full (Outlook) deuglify"
2507 gnus-article-outlook-deuglify-article t])
2508 )
2509 ("Output"
2510 ["Save in default format..." gnus-summary-save-article
2511 ,@(if (featurep 'xemacs) '(t)
2512 '(:help "Save article using default method"))]
2513 ["Save in file..." gnus-summary-save-article-file
2514 ,@(if (featurep 'xemacs) '(t)
2515 '(:help "Save article in file"))]
2516 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2517 ["Save in MH folder..." gnus-summary-save-article-folder t]
2518 ["Save in VM folder..." gnus-summary-save-article-vm t]
2519 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2520 ["Save body in file..." gnus-summary-save-article-body-file t]
2521 ["Pipe through a filter..." gnus-summary-pipe-output t]
2522 ["Print with Muttprint..." gnus-summary-muttprint t]
2523 ["Print" gnus-summary-print-article
2524 ,@(if (featurep 'xemacs) '(t)
2525 '(:help "Generate and print a PostScript image"))])
2526 ("Copy, move,... (Backend)"
2527 ,@(if (featurep 'xemacs) nil
2528 '(:help "Copying, moving, expiring articles..."))
2529 ["Respool article..." gnus-summary-respool-article t]
2530 ["Move article..." gnus-summary-move-article
2531 (gnus-check-backend-function
2532 'request-move-article gnus-newsgroup-name)]
2533 ["Copy article..." gnus-summary-copy-article t]
2534 ["Crosspost article..." gnus-summary-crosspost-article
2535 (gnus-check-backend-function
2536 'request-replace-article gnus-newsgroup-name)]
2537 ["Import file..." gnus-summary-import-article
2538 (gnus-check-backend-function
2539 'request-accept-article gnus-newsgroup-name)]
2540 ["Create article..." gnus-summary-create-article
2541 (gnus-check-backend-function
2542 'request-accept-article gnus-newsgroup-name)]
2543 ["Check if posted" gnus-summary-article-posted-p t]
2544 ["Edit article" gnus-summary-edit-article
2545 (not (gnus-group-read-only-p))]
2546 ["Delete article" gnus-summary-delete-article
2547 (gnus-check-backend-function
2548 'request-expire-articles gnus-newsgroup-name)]
2549 ["Query respool" gnus-summary-respool-query t]
2550 ["Trace respool" gnus-summary-respool-trace t]
2551 ["Delete expirable articles" gnus-summary-expire-articles-now
2552 (gnus-check-backend-function
2553 'request-expire-articles gnus-newsgroup-name)])
2554 ("Extract"
2555 ["Uudecode" gnus-uu-decode-uu
2556 ,@(if (featurep 'xemacs) '(t)
2557 '(:help "Decode uuencoded article(s)"))]
2558 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2559 ["Unshar" gnus-uu-decode-unshar t]
2560 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2561 ["Save" gnus-uu-decode-save t]
2562 ["Binhex" gnus-uu-decode-binhex t]
2563 ["PostScript" gnus-uu-decode-postscript t]
2564 ["All MIME parts" gnus-summary-save-parts t])
2565 ("Cache"
2566 ["Enter article" gnus-cache-enter-article t]
2567 ["Remove article" gnus-cache-remove-article t])
2568 ["Translate" gnus-article-babel t]
2569 ["Select article buffer" gnus-summary-select-article-buffer t]
2570 ["Make article buffer sticky" gnus-sticky-article t]
2571 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2572 ["Isearch article..." gnus-summary-isearch-article t]
2573 ["Beginning of the article" gnus-summary-beginning-of-article t]
2574 ["End of the article" gnus-summary-end-of-article t]
2575 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2576 ["Fetch referenced articles" gnus-summary-refer-references t]
2577 ["Fetch current thread" gnus-summary-refer-thread t]
2578 ["Fetch article with id..." gnus-summary-refer-article t]
2579 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2580 ["Redisplay" gnus-summary-show-article t]
2581 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2582 (easy-menu-define
2583 gnus-summary-article-menu gnus-summary-mode-map ""
2584 (cons "Article" innards))
2585
2586 (if (not (keymapp gnus-summary-article-menu))
2587 (easy-menu-define
2588 gnus-article-commands-menu gnus-article-mode-map ""
2589 (cons "Commands" innards))
2590 ;; in Emacs, don't share menu.
2591 (setq gnus-article-commands-menu
2592 (copy-keymap gnus-summary-article-menu))
2593 (define-key gnus-article-mode-map [menu-bar commands]
2594 (cons "Commands" gnus-article-commands-menu))))
2595
2596 (easy-menu-define
2597 gnus-summary-thread-menu gnus-summary-mode-map ""
2598 '("Threads"
2599 ["Find all messages in thread" gnus-summary-refer-thread t]
2600 ["Toggle threading" gnus-summary-toggle-threads t]
2601 ["Hide threads" gnus-summary-hide-all-threads t]
2602 ["Show threads" gnus-summary-show-all-threads t]
2603 ["Hide thread" gnus-summary-hide-thread t]
2604 ["Show thread" gnus-summary-show-thread t]
2605 ["Go to next thread" gnus-summary-next-thread t]
2606 ["Go to previous thread" gnus-summary-prev-thread t]
2607 ["Go down thread" gnus-summary-down-thread t]
2608 ["Go up thread" gnus-summary-up-thread t]
2609 ["Top of thread" gnus-summary-top-thread t]
2610 ["Mark thread as read" gnus-summary-kill-thread t]
2611 ["Mark thread as expired" gnus-summary-expire-thread t]
2612 ["Lower thread score" gnus-summary-lower-thread t]
2613 ["Raise thread score" gnus-summary-raise-thread t]
2614 ["Rethread current" gnus-summary-rethread-current t]))
2615
2616 (easy-menu-define
2617 gnus-summary-post-menu gnus-summary-mode-map ""
2618 `("Post"
2619 ["Send a message (mail or news)" gnus-summary-post-news
2620 ,@(if (featurep 'xemacs) '(t)
2621 '(:help "Compose a new message (mail or news)"))]
2622 ["Followup" gnus-summary-followup
2623 ,@(if (featurep 'xemacs) '(t)
2624 '(:help "Post followup to this article"))]
2625 ["Followup and yank" gnus-summary-followup-with-original
2626 ,@(if (featurep 'xemacs) '(t)
2627 '(:help "Post followup to this article, quoting its contents"))]
2628 ["Supersede article" gnus-summary-supersede-article t]
2629 ["Cancel article" gnus-summary-cancel-article
2630 ,@(if (featurep 'xemacs) '(t)
2631 '(:help "Cancel an article you posted"))]
2632 ["Reply" gnus-summary-reply t]
2633 ["Reply and yank" gnus-summary-reply-with-original t]
2634 ["Wide reply" gnus-summary-wide-reply t]
2635 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2636 ,@(if (featurep 'xemacs) '(t)
2637 '(:help "Mail a reply, quoting this article"))]
2638 ["Very wide reply" gnus-summary-very-wide-reply t]
2639 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2640 ,@(if (featurep 'xemacs) '(t)
2641 '(:help "Mail a very wide reply, quoting this article"))]
2642 ["Mail forward" gnus-summary-mail-forward t]
2643 ["Post forward" gnus-summary-post-forward t]
2644 ["Digest and mail" gnus-uu-digest-mail-forward t]
2645 ["Digest and post" gnus-uu-digest-post-forward t]
2646 ["Resend message" gnus-summary-resend-message t]
2647 ["Resend message edit" gnus-summary-resend-message-edit t]
2648 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2649 ["Send a mail" gnus-summary-mail-other-window t]
2650 ["Create a local message" gnus-summary-news-other-window t]
2651 ["Uuencode and post" gnus-uu-post-news
2652 ,@(if (featurep 'xemacs) '(t)
2653 '(:help "Post a uuencoded article"))]
2654 ["Followup via news" gnus-summary-followup-to-mail t]
2655 ["Followup via news and yank"
2656 gnus-summary-followup-to-mail-with-original t]
2657 ["Strip signature on reply"
2658 (lambda ()
2659 (interactive)
2660 (if (not (memq message-cite-function
2661 '(message-cite-original-without-signature
2662 message-cite-original)))
2663 ;; Stupid workaround for XEmacs not honoring :visible.
2664 (message "Can't toggle this value of `message-cite-function'")
2665 (setq message-cite-function
2666 (if (eq message-cite-function
2667 'message-cite-original-without-signature)
2668 'message-cite-original
2669 'message-cite-original-without-signature))))
2670 ;; XEmacs barfs on :visible.
2671 ,@(if (featurep 'xemacs) nil
2672 '(:visible (memq message-cite-function
2673 '(message-cite-original-without-signature
2674 message-cite-original))))
2675 :style toggle
2676 :selected (eq message-cite-function
2677 'message-cite-original-without-signature)
2678 ,@(if (featurep 'xemacs) nil
2679 '(:help "Strip signature from cited article when replying."))]
2680 ;;("Draft"
2681 ;;["Send" gnus-summary-send-draft t]
2682 ;;["Send bounced" gnus-resend-bounced-mail t])
2683 ))
2684
2685 (cond
2686 ((not (keymapp gnus-summary-post-menu))
2687 (setq gnus-article-post-menu gnus-summary-post-menu))
2688 ((not gnus-article-post-menu)
2689 ;; Don't share post menu.
2690 (setq gnus-article-post-menu
2691 (copy-keymap gnus-summary-post-menu))))
2692 (define-key gnus-article-mode-map [menu-bar post]
2693 (cons "Post" gnus-article-post-menu))
2694
2695 (easy-menu-define
2696 gnus-summary-misc-menu gnus-summary-mode-map ""
2697 `("Gnus"
2698 ("Mark Read"
2699 ["Mark as read" gnus-summary-mark-as-read-forward t]
2700 ["Mark same subject and select"
2701 gnus-summary-kill-same-subject-and-select t]
2702 ["Mark same subject" gnus-summary-kill-same-subject t]
2703 ["Catchup" gnus-summary-catchup
2704 ,@(if (featurep 'xemacs) '(t)
2705 '(:help "Mark unread articles in this group as read"))]
2706 ["Catchup all" gnus-summary-catchup-all t]
2707 ["Catchup to here" gnus-summary-catchup-to-here t]
2708 ["Catchup from here" gnus-summary-catchup-from-here t]
2709 ["Catchup region" gnus-summary-mark-region-as-read mark-active]
2710 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2711 ("Mark Various"
2712 ["Tick" gnus-summary-tick-article-forward t]
2713 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2714 ["Remove marks" gnus-summary-clear-mark-forward t]
2715 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2716 ["Set bookmark" gnus-summary-set-bookmark t]
2717 ["Remove bookmark" gnus-summary-remove-bookmark t])
2718 ("Limit to"
2719 ["Marks..." gnus-summary-limit-to-marks t]
2720 ["Subject..." gnus-summary-limit-to-subject t]
2721 ["Author..." gnus-summary-limit-to-author t]
2722 ["Recipient..." gnus-summary-limit-to-recipient t]
2723 ["Address..." gnus-summary-limit-to-address t]
2724 ["Age..." gnus-summary-limit-to-age t]
2725 ["Extra..." gnus-summary-limit-to-extra t]
2726 ["Score..." gnus-summary-limit-to-score t]
2727 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2728 ["Unread" gnus-summary-limit-to-unread t]
2729 ["Unseen" gnus-summary-limit-to-unseen t]
2730 ["Singletons" gnus-summary-limit-to-singletons t]
2731 ["Replied" gnus-summary-limit-to-replied t]
2732 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2733 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2734 ["Pop limit" gnus-summary-pop-limit t]
2735 ["Show dormant" gnus-summary-limit-include-dormant t]
2736 ["Hide childless dormant"
2737 gnus-summary-limit-exclude-childless-dormant t]
2738 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2739 ["Hide marked" gnus-summary-limit-exclude-marks t]
2740 ["Show expunged" gnus-summary-limit-include-expunged t])
2741 ("Process Mark"
2742 ["Set mark" gnus-summary-mark-as-processable t]
2743 ["Remove mark" gnus-summary-unmark-as-processable t]
2744 ["Remove all marks" gnus-summary-unmark-all-processable t]
2745 ["Invert marks" gnus-uu-invert-processable t]
2746 ["Mark above" gnus-uu-mark-over t]
2747 ["Mark series" gnus-uu-mark-series t]
2748 ["Mark region" gnus-uu-mark-region mark-active]
2749 ["Unmark region" gnus-uu-unmark-region mark-active]
2750 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2751 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2752 ["Mark all" gnus-uu-mark-all t]
2753 ["Mark buffer" gnus-uu-mark-buffer t]
2754 ["Mark sparse" gnus-uu-mark-sparse t]
2755 ["Mark thread" gnus-uu-mark-thread t]
2756 ["Unmark thread" gnus-uu-unmark-thread t]
2757 ("Process Mark Sets"
2758 ["Kill" gnus-summary-kill-process-mark t]
2759 ["Yank" gnus-summary-yank-process-mark
2760 gnus-newsgroup-process-stack]
2761 ["Save" gnus-summary-save-process-mark t]
2762 ["Run command on marked..." gnus-summary-universal-argument t]))
2763 ("Registry Marks")
2764 ("Scroll article"
2765 ["Page forward" gnus-summary-next-page
2766 ,@(if (featurep 'xemacs) '(t)
2767 '(:help "Show next page of article"))]
2768 ["Page backward" gnus-summary-prev-page
2769 ,@(if (featurep 'xemacs) '(t)
2770 '(:help "Show previous page of article"))]
2771 ["Line forward" gnus-summary-scroll-up t])
2772 ("Move"
2773 ["Next unread article" gnus-summary-next-unread-article t]
2774 ["Previous unread article" gnus-summary-prev-unread-article t]
2775 ["Next article" gnus-summary-next-article t]
2776 ["Previous article" gnus-summary-prev-article t]
2777 ["Next unread subject" gnus-summary-next-unread-subject t]
2778 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2779 ["Next article same subject" gnus-summary-next-same-subject t]
2780 ["Previous article same subject" gnus-summary-prev-same-subject t]
2781 ["First unread article" gnus-summary-first-unread-article t]
2782 ["Best unread article" gnus-summary-best-unread-article t]
2783 ["Go to subject number..." gnus-summary-goto-subject t]
2784 ["Go to article number..." gnus-summary-goto-article t]
2785 ["Go to the last article" gnus-summary-goto-last-article t]
2786 ["Pop article off history" gnus-summary-pop-article t])
2787 ("Sort"
2788 ["Sort by number" gnus-summary-sort-by-number t]
2789 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2790 ["Sort by author" gnus-summary-sort-by-author t]
2791 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2792 ["Sort by subject" gnus-summary-sort-by-subject t]
2793 ["Sort by date" gnus-summary-sort-by-date t]
2794 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2795 ["Sort by score" gnus-summary-sort-by-score t]
2796 ["Sort by lines" gnus-summary-sort-by-lines t]
2797 ["Sort by characters" gnus-summary-sort-by-chars t]
2798 ["Randomize" gnus-summary-sort-by-random t]
2799 ["Original sort" gnus-summary-sort-by-original t])
2800 ("Help"
2801 ["Describe group" gnus-summary-describe-group t]
2802 ["Read manual" gnus-info-find-node t])
2803 ("Modes"
2804 ["Pick and read" gnus-pick-mode t]
2805 ["Binary" gnus-binary-mode t])
2806 ("Regeneration"
2807 ["Regenerate" gnus-summary-prepare t]
2808 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2809 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2810 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2811 ["Toggle threading" gnus-summary-toggle-threads t])
2812 ["See old articles" gnus-summary-insert-old-articles t]
2813 ["See new articles" gnus-summary-insert-new-articles t]
2814 ["Filter articles..." gnus-summary-execute-command t]
2815 ["Run command on articles..." gnus-summary-universal-argument t]
2816 ["Search articles forward..." gnus-summary-search-article-forward t]
2817 ["Search articles backward..." gnus-summary-search-article-backward t]
2818 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2819 ["Expand window" gnus-summary-expand-window t]
2820 ["Expire expirable articles" gnus-summary-expire-articles
2821 (gnus-check-backend-function
2822 'request-expire-articles gnus-newsgroup-name)]
2823 ["Edit local kill file" gnus-summary-edit-local-kill t]
2824 ["Edit main kill file" gnus-summary-edit-global-kill t]
2825 ["Edit group parameters" gnus-summary-edit-parameters t]
2826 ["Customize group parameters" gnus-summary-customize-parameters t]
2827 ["Send a bug report" gnus-bug t]
2828 ("Exit"
2829 ["Catchup and exit" gnus-summary-catchup-and-exit
2830 ,@(if (featurep 'xemacs) '(t)
2831 '(:help "Mark unread articles in this group as read, then exit"))]
2832 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2833 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2834 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2835 ["Exit group" gnus-summary-exit
2836 ,@(if (featurep 'xemacs) '(t)
2837 '(:help "Exit current group, return to group selection mode"))]
2838 ["Exit group without updating" gnus-summary-exit-no-update t]
2839 ["Exit and goto next group" gnus-summary-next-group t]
2840 ["Exit and goto prev group" gnus-summary-prev-group t]
2841 ["Reselect group" gnus-summary-reselect-current-group t]
2842 ["Rescan group" gnus-summary-rescan-group t]
2843 ["Update dribble" gnus-summary-save-newsrc t])))
2844
2845 (gnus-run-hooks 'gnus-summary-menu-hook)))
2846
2847 (defvar gnus-summary-tool-bar-map nil)
2848
2849 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2850 ;; affect _new_ message buffers. We might add a function that walks thru all
2851 ;; summary-mode buffers and force the update.
2852 (defun gnus-summary-tool-bar-update (&optional symbol value)
2853 "Update summary mode toolbar.
2854 Setter function for custom variables."
2855 (setq-default gnus-summary-tool-bar-map nil)
2856 (when symbol
2857 ;; When used as ":set" function:
2858 (set-default symbol value))
2859 (when (gnus-buffer-live-p gnus-summary-buffer)
2860 (with-current-buffer gnus-summary-buffer
2861 (gnus-summary-make-tool-bar))))
2862
2863 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2864 'gnus-summary-tool-bar-gnome
2865 'gnus-summary-tool-bar-retro)
2866 "Specifies the Gnus summary tool bar.
2867
2868 It can be either a list or a symbol referring to a list. See
2869 `gmm-tool-bar-from-list' for the format of the list. The
2870 default key map is `gnus-summary-mode-map'.
2871
2872 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2873 `gnus-summary-tool-bar-retro'."
2874 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2875 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2876 (repeat :tag "User defined list" gmm-tool-bar-item)
2877 (symbol))
2878 :version "23.1" ;; No Gnus
2879 :initialize 'custom-initialize-default
2880 :set 'gnus-summary-tool-bar-update
2881 :group 'gnus-summary)
2882
2883 (defcustom gnus-summary-tool-bar-gnome
2884 '((gnus-summary-post-news "mail/compose" nil)
2885 (gnus-summary-insert-new-articles "mail/inbox" nil
2886 :visible (or (not gnus-agent)
2887 gnus-plugged))
2888 (gnus-summary-reply-with-original "mail/reply")
2889 (gnus-summary-reply "mail/reply" nil :visible nil)
2890 (gnus-summary-followup-with-original "mail/reply-all")
2891 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2892 (gnus-summary-mail-forward "mail/forward")
2893 (gnus-summary-save-article "mail/save")
2894 (gnus-summary-search-article-forward "search" nil :visible nil)
2895 (gnus-summary-print-article "print")
2896 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2897 ;; Some new commands that may need more suitable icons:
2898 (gnus-summary-save-newsrc "save" nil :visible nil)
2899 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2900 (gnus-summary-prev-article "left-arrow")
2901 (gnus-summary-next-article "right-arrow")
2902 (gnus-summary-next-page "next-page")
2903 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2904 ;;
2905 ;; Maybe some sort-by-... could be added:
2906 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2907 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2908 (gnus-summary-mark-as-expirable
2909 "delete" nil
2910 :visible (gnus-check-backend-function 'request-expire-articles
2911 gnus-newsgroup-name))
2912 (gnus-summary-mark-as-spam
2913 "mail/spam" t
2914 :visible (and (fboundp 'spam-group-ham-contents-p)
2915 (spam-group-ham-contents-p gnus-newsgroup-name))
2916 :help "Mark as spam")
2917 (gnus-summary-mark-as-read-forward
2918 "mail/not-spam" nil
2919 :visible (and (fboundp 'spam-group-spam-contents-p)
2920 (spam-group-spam-contents-p gnus-newsgroup-name)))
2921 ;;
2922 (gnus-summary-exit "exit")
2923 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2924 (gnus-info-find-node "help"))
2925 "List of functions for the summary tool bar (GNOME style).
2926
2927 See `gmm-tool-bar-from-list' for the format of the list."
2928 :type '(repeat gmm-tool-bar-item)
2929 :version "23.1" ;; No Gnus
2930 :initialize 'custom-initialize-default
2931 :set 'gnus-summary-tool-bar-update
2932 :group 'gnus-summary)
2933
2934 (defcustom gnus-summary-tool-bar-retro
2935 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2936 (gnus-summary-next-unread-article "gnus/next-ur")
2937 (gnus-summary-post-news "gnus/post")
2938 (gnus-summary-followup-with-original "gnus/fuwo")
2939 (gnus-summary-followup "gnus/followup")
2940 (gnus-summary-reply-with-original "gnus/reply-wo")
2941 (gnus-summary-reply "gnus/reply")
2942 (gnus-summary-caesar-message "gnus/rot13")
2943 (gnus-uu-decode-uu "gnus/uu-decode")
2944 (gnus-summary-save-article-file "gnus/save-aif")
2945 (gnus-summary-save-article "gnus/save-art")
2946 (gnus-uu-post-news "gnus/uu-post")
2947 (gnus-summary-catchup "gnus/catchup")
2948 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2949 (gnus-summary-exit "gnus/exit-summ")
2950 ;; Some new command that may need more suitable icons:
2951 (gnus-summary-print-article "gnus/print" nil :visible nil)
2952 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2953 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2954 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2955 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2956 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2957 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2958 ;;
2959 (gnus-info-find-node "gnus/help" nil :visible nil))
2960 "List of functions for the summary tool bar (retro look).
2961
2962 See `gmm-tool-bar-from-list' for the format of the list."
2963 :type '(repeat gmm-tool-bar-item)
2964 :version "23.1" ;; No Gnus
2965 :initialize 'custom-initialize-default
2966 :set 'gnus-summary-tool-bar-update
2967 :group 'gnus-summary)
2968
2969 (defcustom gnus-summary-tool-bar-zap-list t
2970 "List of icon items from the global tool bar.
2971 These items are not displayed in the Gnus summary mode tool bar.
2972
2973 See `gmm-tool-bar-from-list' for the format of the list."
2974 :type 'gmm-tool-bar-zap-list
2975 :version "23.1" ;; No Gnus
2976 :initialize 'custom-initialize-default
2977 :set 'gnus-summary-tool-bar-update
2978 :group 'gnus-summary)
2979
2980 (defvar image-load-path)
2981 (defvar tool-bar-map)
2982
2983 (defun gnus-summary-make-tool-bar (&optional force)
2984 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2985 When FORCE, rebuild the tool bar."
2986 (when (and (not (featurep 'xemacs))
2987 (boundp 'tool-bar-mode)
2988 tool-bar-mode
2989 (or (not gnus-summary-tool-bar-map) force))
2990 (let* ((load-path
2991 (gmm-image-load-path-for-library "gnus"
2992 "mail/save.xpm"
2993 nil t))
2994 (image-load-path (cons (car load-path)
2995 (when (boundp 'image-load-path)
2996 image-load-path)))
2997 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2998 gnus-summary-tool-bar-zap-list
2999 'gnus-summary-mode-map)))
3000 (when map
3001 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
3002 ;; uses its value.
3003 (setq gnus-summary-tool-bar-map map))))
3004 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
3005
3006 (defun gnus-make-score-map (type)
3007 "Make a summary score map of type TYPE."
3008 (if t
3009 nil
3010 (let ((headers '(("author" "from" string)
3011 ("subject" "subject" string)
3012 ("article body" "body" string)
3013 ("article head" "head" string)
3014 ("xref" "xref" string)
3015 ("extra header" "extra" string)
3016 ("lines" "lines" number)
3017 ("followups to author" "followup" string)))
3018 (types '((number ("less than" <)
3019 ("greater than" >)
3020 ("equal" =))
3021 (string ("substring" s)
3022 ("exact string" e)
3023 ("fuzzy string" f)
3024 ("regexp" r))))
3025 (perms '(("temporary" (current-time-string))
3026 ("permanent" nil)
3027 ("immediate" now)))
3028 header)
3029 (list
3030 (apply
3031 'nconc
3032 (list
3033 (if (eq type 'lower)
3034 "Lower score"
3035 "Increase score"))
3036 (let (outh)
3037 (while headers
3038 (setq header (car headers))
3039 (setq outh
3040 (cons
3041 (apply
3042 'nconc
3043 (list (car header))
3044 (let ((ts (cdr (assoc (nth 2 header) types)))
3045 outt)
3046 (while ts
3047 (setq outt
3048 (cons
3049 (apply
3050 'nconc
3051 (list (caar ts))
3052 (let ((ps perms)
3053 outp)
3054 (while ps
3055 (setq outp
3056 (cons
3057 (vector
3058 (caar ps)
3059 (list
3060 'gnus-summary-score-entry
3061 (nth 1 header)
3062 (if (or (string= (nth 1 header)
3063 "head")
3064 (string= (nth 1 header)
3065 "body"))
3066 ""
3067 (list 'gnus-summary-header
3068 (nth 1 header)))
3069 (list 'quote (nth 1 (car ts)))
3070 (list 'gnus-score-delta-default
3071 nil)
3072 (nth 1 (car ps))
3073 t)
3074 t)
3075 outp))
3076 (setq ps (cdr ps)))
3077 (list (nreverse outp))))
3078 outt))
3079 (setq ts (cdr ts)))
3080 (list (nreverse outt))))
3081 outh))
3082 (setq headers (cdr headers)))
3083 (list (nreverse outh))))))))
3084
3085
3086 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3087 (defvar bookmark-make-record-function)
3088 \f
3089 (defvar bidi-paragraph-direction)
3090
3091 (defun gnus-summary-mode (&optional group)
3092 "Major mode for reading articles.
3093
3094 All normal editing commands are switched off.
3095 \\<gnus-summary-mode-map>
3096 Each line in this buffer represents one article. To read an
3097 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3098 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3099 respectively.
3100
3101 You can also post articles and send mail from this buffer. To
3102 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3103 of an article, type `\\[gnus-summary-reply]'.
3104
3105 There are approx. one gazillion commands you can execute in this
3106 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3107
3108 The following commands are available:
3109
3110 \\{gnus-summary-mode-map}"
3111 ;; FIXME: Use define-derived-mode.
3112 (interactive)
3113 (kill-all-local-variables)
3114 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3115 (gnus-summary-make-local-variables))
3116 (gnus-summary-make-local-variables)
3117 (setq gnus-newsgroup-name group)
3118 (when (gnus-visual-p 'summary-menu 'menu)
3119 (gnus-summary-make-menu-bar)
3120 (gnus-summary-make-tool-bar))
3121 (gnus-make-thread-indent-array)
3122 (gnus-simplify-mode-line)
3123 (setq major-mode 'gnus-summary-mode)
3124 (setq mode-name "Summary")
3125 (use-local-map gnus-summary-mode-map)
3126 (buffer-disable-undo)
3127 (setq buffer-read-only t ;Disable modification
3128 show-trailing-whitespace nil)
3129 (setq truncate-lines t)
3130 ;; Force paragraph direction to be left-to-right. Don't make it
3131 ;; bound globally in old Emacsen and XEmacsen.
3132 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3133 (add-to-invisibility-spec '(gnus-sum . t))
3134 (gnus-summary-set-display-table)
3135 (gnus-set-default-directory)
3136 (make-local-variable 'gnus-summary-line-format)
3137 (make-local-variable 'gnus-summary-line-format-spec)
3138 (make-local-variable 'gnus-summary-dummy-line-format)
3139 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3140 (make-local-variable 'gnus-summary-mark-positions)
3141 (gnus-make-local-hook 'pre-command-hook)
3142 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3143 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3144 (turn-on-gnus-mailing-list-mode)
3145 (mm-enable-multibyte)
3146 (set (make-local-variable 'bookmark-make-record-function)
3147 'gnus-summary-bookmark-make-record)
3148 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3149 (gnus-update-summary-mark-positions))
3150
3151 (defun gnus-summary-make-local-variables ()
3152 "Make all the local summary buffer variables."
3153 (let (global)
3154 (dolist (local gnus-summary-local-variables)
3155 (if (consp local)
3156 (progn
3157 (if (eq (cdr local) 'global)
3158 ;; Copy the global value of the variable.
3159 (setq global (symbol-value (car local)))
3160 ;; Use the value from the list.
3161 (setq global (eval (cdr local))))
3162 (set (make-local-variable (car local)) global))
3163 ;; Simple nil-valued local variable.
3164 (set (make-local-variable local) nil)))))
3165
3166 ;; Summary data functions.
3167
3168 (defmacro gnus-data-number (data)
3169 `(car ,data))
3170
3171 (defmacro gnus-data-set-number (data number)
3172 `(setcar ,data ,number))
3173
3174 (defmacro gnus-data-mark (data)
3175 `(nth 1 ,data))
3176
3177 (defmacro gnus-data-set-mark (data mark)
3178 `(setcar (nthcdr 1 ,data) ,mark))
3179
3180 (defmacro gnus-data-pos (data)
3181 `(nth 2 ,data))
3182
3183 (defmacro gnus-data-set-pos (data pos)
3184 `(setcar (nthcdr 2 ,data) ,pos))
3185
3186 (defmacro gnus-data-header (data)
3187 `(nth 3 ,data))
3188
3189 (defmacro gnus-data-set-header (data header)
3190 `(setf (nth 3 ,data) ,header))
3191
3192 (defmacro gnus-data-level (data)
3193 `(nth 4 ,data))
3194
3195 (defmacro gnus-data-unread-p (data)
3196 `(= (nth 1 ,data) gnus-unread-mark))
3197
3198 (defmacro gnus-data-read-p (data)
3199 `(/= (nth 1 ,data) gnus-unread-mark))
3200
3201 (defmacro gnus-data-pseudo-p (data)
3202 `(consp (nth 3 ,data)))
3203
3204 (defmacro gnus-data-find (number)
3205 `(assq ,number gnus-newsgroup-data))
3206
3207 (defmacro gnus-data-find-list (number &optional data)
3208 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3209 (memq (assq ,number bdata)
3210 bdata)))
3211
3212 (defmacro gnus-data-make (number mark pos header level)
3213 `(list ,number ,mark ,pos ,header ,level))
3214
3215 (defun gnus-data-enter (after-article number mark pos header level offset)
3216 (let ((data (gnus-data-find-list after-article)))
3217 (unless data
3218 (error "No such article: %d" after-article))
3219 (setcdr data (cons (gnus-data-make number mark pos header level)
3220 (cdr data)))
3221 (setq gnus-newsgroup-data-reverse nil)
3222 (gnus-data-update-list (cddr data) offset)))
3223
3224 (defun gnus-data-enter-list (after-article list &optional offset)
3225 (when list
3226 (let ((data (and after-article (gnus-data-find-list after-article)))
3227 (ilist list))
3228 (if (not (or data
3229 after-article))
3230 (let ((odata gnus-newsgroup-data))
3231 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3232 (when offset
3233 (gnus-data-update-list odata offset)))
3234 ;; Find the last element in the list to be spliced into the main
3235 ;; list.
3236 (setq list (last list))
3237 (if (not data)
3238 (progn
3239 (setcdr list gnus-newsgroup-data)
3240 (setq gnus-newsgroup-data ilist)
3241 (when offset
3242 (gnus-data-update-list (cdr list) offset)))
3243 (setcdr list (cdr data))
3244 (setcdr data ilist)
3245 (when offset
3246 (gnus-data-update-list (cdr list) offset))))
3247 (setq gnus-newsgroup-data-reverse nil))))
3248
3249 (defun gnus-data-remove (article &optional offset)
3250 (let ((data gnus-newsgroup-data))
3251 (if (= (gnus-data-number (car data)) article)
3252 (progn
3253 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3254 gnus-newsgroup-data-reverse nil)
3255 (when offset
3256 (gnus-data-update-list gnus-newsgroup-data offset)))
3257 (while (cdr data)
3258 (when (= (gnus-data-number (cadr data)) article)
3259 (setcdr data (cddr data))
3260 (when offset
3261 (gnus-data-update-list (cdr data) offset))
3262 (setq data nil
3263 gnus-newsgroup-data-reverse nil))
3264 (setq data (cdr data))))))
3265
3266 (defmacro gnus-data-list (backward)
3267 `(if ,backward
3268 (or gnus-newsgroup-data-reverse
3269 (setq gnus-newsgroup-data-reverse
3270 (reverse gnus-newsgroup-data)))
3271 gnus-newsgroup-data))
3272
3273 (defun gnus-data-update-list (data offset)
3274 "Add OFFSET to the POS of all data entries in DATA."
3275 (setq gnus-newsgroup-data-reverse nil)
3276 (while data
3277 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3278 (setq data (cdr data))))
3279
3280 (defun gnus-summary-article-pseudo-p (article)
3281 "Say whether this article is a pseudo article or not."
3282 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3283
3284 (defmacro gnus-summary-article-sparse-p (article)
3285 "Say whether this article is a sparse article or not."
3286 `(memq ,article gnus-newsgroup-sparse))
3287
3288 (defmacro gnus-summary-article-ancient-p (article)
3289 "Say whether this article is a sparse article or not."
3290 `(memq ,article gnus-newsgroup-ancient))
3291
3292 (defun gnus-article-children (number)
3293 "Return a list of all children to NUMBER."
3294 (let* ((data (gnus-data-find-list number))
3295 (level (gnus-data-level (car data)))
3296 children)
3297 (setq data (cdr data))
3298 (while (and data
3299 (= (gnus-data-level (car data)) (1+ level)))
3300 (push (gnus-data-number (car data)) children)
3301 (setq data (cdr data)))
3302 children))
3303
3304 (defmacro gnus-summary-skip-intangible ()
3305 "If the current article is intangible, then jump to a different article."
3306 '(let ((to (get-text-property (point) 'gnus-intangible)))
3307 (and to (gnus-summary-goto-subject to))))
3308
3309 (defmacro gnus-summary-article-intangible-p ()
3310 "Say whether this article is intangible or not."
3311 '(get-text-property (point) 'gnus-intangible))
3312
3313 ;; Some summary mode macros.
3314
3315 (defmacro gnus-summary-article-number ()
3316 "The article number of the article on the current line.
3317 If there isn't an article number here, then we return the current
3318 article number."
3319 '(progn
3320 (gnus-summary-skip-intangible)
3321 (or (get-text-property (point) 'gnus-number)
3322 (gnus-summary-last-subject))))
3323
3324 (defmacro gnus-summary-article-header (&optional number)
3325 "Return the header of article NUMBER."
3326 `(gnus-data-header (gnus-data-find
3327 ,(or number '(gnus-summary-article-number)))))
3328
3329 (defmacro gnus-summary-thread-level (&optional number)
3330 "Return the level of thread that starts with article NUMBER."
3331 `(if (and (eq gnus-summary-make-false-root 'dummy)
3332 (get-text-property (point) 'gnus-intangible))
3333 0
3334 (gnus-data-level (gnus-data-find
3335 ,(or number '(gnus-summary-article-number))))))
3336
3337 (defmacro gnus-summary-article-mark (&optional number)
3338 "Return the mark of article NUMBER."
3339 `(gnus-data-mark (gnus-data-find
3340 ,(or number '(gnus-summary-article-number)))))
3341
3342 (defmacro gnus-summary-article-pos (&optional number)
3343 "Return the position of the line of article NUMBER."
3344 `(gnus-data-pos (gnus-data-find
3345 ,(or number '(gnus-summary-article-number)))))
3346
3347 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3348 (defmacro gnus-summary-article-subject (&optional number)
3349 "Return current subject string or nil if nothing."
3350 `(let ((headers
3351 ,(if number
3352 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3353 '(gnus-data-header (assq (gnus-summary-article-number)
3354 gnus-newsgroup-data)))))
3355 (and headers
3356 (vectorp headers)
3357 (mail-header-subject headers))))
3358
3359 (defmacro gnus-summary-article-score (&optional number)
3360 "Return current article score."
3361 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3362 gnus-newsgroup-scored))
3363 gnus-summary-default-score 0))
3364
3365 (defun gnus-summary-article-children (&optional number)
3366 "Return a list of article numbers that are children of article NUMBER."
3367 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3368 (level (gnus-data-level (car data)))
3369 l children)
3370 (while (and (setq data (cdr data))
3371 (> (setq l (gnus-data-level (car data))) level))
3372 (and (= (1+ level) l)
3373 (push (gnus-data-number (car data))
3374 children)))
3375 (nreverse children)))
3376
3377 (defun gnus-summary-article-parent (&optional number)
3378 "Return the article number of the parent of article NUMBER."
3379 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3380 (gnus-data-list t)))
3381 (level (gnus-data-level (car data))))
3382 (if (zerop level)
3383 () ; This is a root.
3384 ;; We search until we find an article with a level less than
3385 ;; this one. That function has to be the parent.
3386 (while (and (setq data (cdr data))
3387 (not (< (gnus-data-level (car data)) level))))
3388 (and data (gnus-data-number (car data))))))
3389
3390 (defun gnus-unread-mark-p (mark)
3391 "Say whether MARK is the unread mark."
3392 (= mark gnus-unread-mark))
3393
3394 (defun gnus-read-mark-p (mark)
3395 "Say whether MARK is one of the marks that mark as read.
3396 This is all marks except unread, ticked, dormant, and expirable."
3397 (not (or (= mark gnus-unread-mark)
3398 (= mark gnus-ticked-mark)
3399 (= mark gnus-spam-mark)
3400 (= mark gnus-dormant-mark)
3401 (= mark gnus-expirable-mark))))
3402
3403 (defmacro gnus-article-mark (number)
3404 "Return the MARK of article NUMBER.
3405 This macro should only be used when computing the mark the \"first\"
3406 time; i.e., when generating the summary lines. After that,
3407 `gnus-summary-article-mark' should be used to examine the
3408 marks of articles."
3409 `(cond
3410 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3411 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3412 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3413 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3414 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3415 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3416 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3417 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3418 gnus-ancient-mark))))
3419
3420 ;; Saving hidden threads.
3421
3422 (defmacro gnus-save-hidden-threads (&rest forms)
3423 "Save hidden threads, eval FORMS, and restore the hidden threads."
3424 (let ((config (make-symbol "config")))
3425 `(let ((,config (gnus-hidden-threads-configuration)))
3426 (unwind-protect
3427 (save-excursion
3428 ,@forms)
3429 (gnus-restore-hidden-threads-configuration ,config)))))
3430 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3431 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3432
3433 (defun gnus-data-compute-positions ()
3434 "Compute the positions of all articles."
3435 (setq gnus-newsgroup-data-reverse nil)
3436 (let ((data gnus-newsgroup-data))
3437 (save-excursion
3438 (gnus-save-hidden-threads
3439 (gnus-summary-show-all-threads)
3440 (goto-char (point-min))
3441 (while data
3442 (while (get-text-property (point) 'gnus-intangible)
3443 (forward-line 1))
3444 (gnus-data-set-pos (car data) (+ (point) 3))
3445 (setq data (cdr data))
3446 (forward-line 1))))))
3447
3448 (defun gnus-hidden-threads-configuration ()
3449 "Return the current hidden threads configuration."
3450 (save-excursion
3451 (let (config)
3452 (goto-char (point-min))
3453 (while (not (eobp))
3454 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3455 (push (save-excursion (forward-line 0) (point)) config))
3456 (forward-line 1))
3457 config)))
3458
3459 (defun gnus-restore-hidden-threads-configuration (config)
3460 "Restore hidden threads configuration from CONFIG."
3461 (save-excursion
3462 (let (point (inhibit-read-only t))
3463 (while (setq point (pop config))
3464 (goto-char point)
3465 (gnus-summary-hide-thread)))))
3466
3467 ;; Various summary mode internalish functions.
3468
3469 (defun gnus-mouse-pick-article (e)
3470 (interactive "e")
3471 (mouse-set-point e)
3472 (gnus-summary-next-page nil t))
3473
3474 (defun gnus-summary-set-display-table ()
3475 "Change the display table.
3476 Odd characters have a tendency to mess
3477 up nicely formatted displays - we make all possible glyphs
3478 display only a single character."
3479
3480 ;; We start from the standard display table, if any.
3481 (let ((table (or (copy-sequence standard-display-table)
3482 (make-display-table)))
3483 (i 32))
3484 ;; Nix out all the control chars...
3485 (while (>= (setq i (1- i)) 0)
3486 (gnus-put-display-table i [??] table))
3487 ;; ... but not newline and cr, of course. (cr is necessary for the
3488 ;; selective display).
3489 (gnus-put-display-table ?\n nil table)
3490 (gnus-put-display-table ?\r nil table)
3491 ;; We keep TAB as well.
3492 (gnus-put-display-table ?\t nil table)
3493 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3494 ;; Emacs 23 (unicode), that are not set already.
3495 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3496 160
3497 256)))
3498 (while (>= (setq i (1- i)) 127)
3499 ;; Only modify if the entry is nil.
3500 (unless (gnus-get-display-table i table)
3501 (gnus-put-display-table i [??] table))))
3502 (setq buffer-display-table table)))
3503
3504 (defun gnus-summary-set-article-display-arrow (pos)
3505 "Update the overlay arrow to point to line at position POS."
3506 (when gnus-summary-display-arrow
3507 (make-local-variable 'overlay-arrow-position)
3508 (make-local-variable 'overlay-arrow-string)
3509 (save-excursion
3510 (goto-char pos)
3511 (beginning-of-line)
3512 (unless overlay-arrow-position
3513 (setq overlay-arrow-position (make-marker)))
3514 (setq overlay-arrow-string "=>"
3515 overlay-arrow-position (set-marker overlay-arrow-position
3516 (point)
3517 (current-buffer))))))
3518
3519 (defun gnus-summary-setup-buffer (group)
3520 "Initialize summary buffer.
3521 If the setup was successful, non-nil is returned."
3522 (let ((buffer (gnus-summary-buffer-name group))
3523 (dead-name (concat "*Dead Summary "
3524 (gnus-group-decoded-name group) "*")))
3525 ;; If a dead summary buffer exists, we kill it.
3526 (when (gnus-buffer-live-p dead-name)
3527 (gnus-kill-buffer dead-name))
3528 (if (get-buffer buffer)
3529 (progn
3530 (set-buffer buffer)
3531 (setq gnus-summary-buffer (current-buffer))
3532 (not gnus-newsgroup-prepared))
3533 (set-buffer (gnus-get-buffer-create buffer))
3534 (setq gnus-summary-buffer (current-buffer))
3535 (gnus-summary-mode group)
3536 (when (gnus-group-quit-config group)
3537 (set (make-local-variable 'gnus-single-article-buffer) nil))
3538 (make-local-variable 'gnus-article-buffer)
3539 (make-local-variable 'gnus-article-current)
3540 (make-local-variable 'gnus-original-article-buffer)
3541 (setq gnus-newsgroup-name group)
3542 ;; Set any local variables in the group parameters.
3543 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3544 t)))
3545
3546 (defun gnus-set-global-variables ()
3547 "Set the global equivalents of the buffer-local variables.
3548 They are set to the latest values they had. These reflect the summary
3549 buffer that was in action when the last article was fetched."
3550 (when (derived-mode-p 'gnus-summary-mode)
3551 (setq gnus-summary-buffer (current-buffer))
3552 (let ((name gnus-newsgroup-name)
3553 (marked gnus-newsgroup-marked)
3554 (spam gnus-newsgroup-spam-marked)
3555 (unread gnus-newsgroup-unreads)
3556 (headers gnus-current-headers)
3557 (data gnus-newsgroup-data)
3558 (summary gnus-summary-buffer)
3559 (article-buffer gnus-article-buffer)
3560 (original gnus-original-article-buffer)
3561 (gac gnus-article-current)
3562 (reffed gnus-reffed-article-number)
3563 (score-file gnus-current-score-file)
3564 (default-charset gnus-newsgroup-charset)
3565 vlist)
3566 (let ((locals gnus-newsgroup-variables))
3567 (while locals
3568 (if (consp (car locals))
3569 (push (eval (caar locals)) vlist)
3570 (push (eval (car locals)) vlist))
3571 (setq locals (cdr locals)))
3572 (setq vlist (nreverse vlist)))
3573 (with-temp-buffer
3574 (setq gnus-newsgroup-name name
3575 gnus-newsgroup-marked marked
3576 gnus-newsgroup-spam-marked spam
3577 gnus-newsgroup-unreads unread
3578 gnus-current-headers headers
3579 gnus-newsgroup-data data
3580 gnus-article-current gac
3581 gnus-summary-buffer summary
3582 gnus-article-buffer article-buffer
3583 gnus-original-article-buffer original
3584 gnus-reffed-article-number reffed
3585 gnus-current-score-file score-file
3586 gnus-newsgroup-charset default-charset)
3587 (let ((locals gnus-newsgroup-variables))
3588 (while locals
3589 (if (consp (car locals))
3590 (set (caar locals) (pop vlist))
3591 (set (car locals) (pop vlist)))
3592 (setq locals (cdr locals))))))))
3593
3594 (defun gnus-summary-article-unread-p (article)
3595 "Say whether ARTICLE is unread or not."
3596 (memq article gnus-newsgroup-unreads))
3597
3598 (defun gnus-summary-first-article-p (&optional article)
3599 "Return whether ARTICLE is the first article in the buffer."
3600 (if (not (setq article (or article (gnus-summary-article-number))))
3601 nil
3602 (eq article (caar gnus-newsgroup-data))))
3603
3604 (defun gnus-summary-last-article-p (&optional article)
3605 "Return whether ARTICLE is the last article in the buffer."
3606 (if (not (setq article (or article (gnus-summary-article-number))))
3607 ;; All non-existent numbers are the last article. :-)
3608 t
3609 (not (cdr (gnus-data-find-list article)))))
3610
3611 (defun gnus-make-thread-indent-array (&optional n)
3612 (when (or n
3613 (progn (setq n 200) nil)
3614 (null gnus-thread-indent-array)
3615 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3616 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3617 gnus-thread-indent-array-level gnus-thread-indent-level)
3618 (while (>= n 0)
3619 (aset gnus-thread-indent-array n
3620 (make-string (* n gnus-thread-indent-level) ? ))
3621 (setq n (1- n)))))
3622
3623 (defun gnus-update-summary-mark-positions ()
3624 "Compute where the summary marks are to go."
3625 (save-excursion
3626 (when (gnus-buffer-exists-p gnus-summary-buffer)
3627 (set-buffer gnus-summary-buffer))
3628 (let ((spec gnus-summary-line-format-spec)
3629 pos)
3630 (save-excursion
3631 (gnus-set-work-buffer)
3632 (let ((gnus-tmp-unread ?Z)
3633 (gnus-replied-mark ?Z)
3634 (gnus-score-below-mark ?Z)
3635 (gnus-score-over-mark ?Z)
3636 (gnus-undownloaded-mark ?Z)
3637 (gnus-summary-line-format-spec spec)
3638 (gnus-newsgroup-downloadable '(0))
3639 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3640 case-fold-search ignores)
3641 ;; Here, all marks are bound to Z.
3642 (gnus-summary-insert-line header
3643 0 nil t gnus-tmp-unread t nil "" nil 1)
3644 (goto-char (point-min))
3645 ;; Memorize the positions of the same characters as dummy marks.
3646 (while (re-search-forward "[A-D]" nil t)
3647 (push (point) ignores))
3648 (erase-buffer)
3649 ;; We use A-D as dummy marks in order to know column positions
3650 ;; where marks should be inserted.
3651 (setq gnus-tmp-unread ?A
3652 gnus-replied-mark ?B
3653 gnus-score-below-mark ?C
3654 gnus-score-over-mark ?C
3655 gnus-undownloaded-mark ?D)
3656 (gnus-summary-insert-line header
3657 0 nil t gnus-tmp-unread t nil "" nil 1)
3658 ;; Ignore characters which aren't dummy marks.
3659 (dolist (p ignores)
3660 (delete-region (goto-char (1- p)) p)
3661 (insert ?Z))
3662 (goto-char (point-min))
3663 (setq pos (list (cons 'unread
3664 (and (search-forward "A" nil t)
3665 (- (point) (point-min) 1)))))
3666 (goto-char (point-min))
3667 (push (cons 'replied (and (search-forward "B" nil t)
3668 (- (point) (point-min) 1)))
3669 pos)
3670 (goto-char (point-min))
3671 (push (cons 'score (and (search-forward "C" nil t)
3672 (- (point) (point-min) 1)))
3673 pos)
3674 (goto-char (point-min))
3675 (push (cons 'download (and (search-forward "D" nil t)
3676 (- (point) (point-min) 1)))
3677 pos)))
3678 (setq gnus-summary-mark-positions pos))))
3679
3680 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3681 "Insert a dummy root in the summary buffer."
3682 (beginning-of-line)
3683 (gnus-add-text-properties
3684 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3685 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3686
3687 (defun gnus-summary-extract-address-component (from)
3688 (or (car (funcall gnus-extract-address-components from))
3689 from))
3690
3691 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3692 (let ((mail-parse-charset gnus-newsgroup-charset)
3693 ;; Is it really necessary to do this next part for each summary line?
3694 ;; Luckily, doesn't seem to slow things down much.
3695 (mail-parse-ignored-charsets
3696 (with-current-buffer gnus-summary-buffer
3697 gnus-newsgroup-ignored-charsets)))
3698 (or
3699 (and gnus-ignored-from-addresses
3700 (cond ((functionp gnus-ignored-from-addresses)
3701 (funcall gnus-ignored-from-addresses
3702 (mail-strip-quoted-names gnus-tmp-from)))
3703 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3704 (let ((extra-headers (mail-header-extra header))
3705 to
3706 newsgroups)
3707 (cond
3708 ((setq to (cdr (assq 'To extra-headers)))
3709 (concat gnus-summary-to-prefix
3710 (inline
3711 (gnus-summary-extract-address-component
3712 (funcall gnus-decode-encoded-address-function to)))))
3713 ((setq newsgroups
3714 (or
3715 (cdr (assq 'Newsgroups extra-headers))
3716 (and
3717 (memq 'Newsgroups gnus-extra-headers)
3718 (eq (car (gnus-find-method-for-group
3719 gnus-newsgroup-name)) 'nntp)
3720 (gnus-group-real-name gnus-newsgroup-name))))
3721 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3722 (bidi-string-mark-left-to-right
3723 (inline
3724 (gnus-summary-extract-address-component gnus-tmp-from))))))
3725
3726 (defun gnus-summary-insert-line (gnus-tmp-header
3727 gnus-tmp-level gnus-tmp-current
3728 undownloaded gnus-tmp-unread gnus-tmp-replied
3729 gnus-tmp-expirable gnus-tmp-subject-or-nil
3730 &optional gnus-tmp-dummy gnus-tmp-score
3731 gnus-tmp-process)
3732 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3733 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3734 gnus-tmp-level)))
3735 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3736 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3737 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3738 (gnus-tmp-score-char
3739 (if (or (null gnus-summary-default-score)
3740 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3741 gnus-summary-zcore-fuzz))
3742 ? ;Whitespace
3743 (if (< gnus-tmp-score gnus-summary-default-score)
3744 gnus-score-below-mark gnus-score-over-mark)))
3745 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3746 (gnus-tmp-replied
3747 (cond (gnus-tmp-process gnus-process-mark)
3748 ((memq gnus-tmp-current gnus-newsgroup-cached)
3749 gnus-cached-mark)
3750 (gnus-tmp-replied gnus-replied-mark)
3751 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3752 gnus-forwarded-mark)
3753 ((memq gnus-tmp-current gnus-newsgroup-saved)
3754 gnus-saved-mark)
3755 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3756 gnus-unseen-mark)
3757 (t gnus-no-mark)))
3758 (gnus-tmp-downloaded
3759 (cond (undownloaded
3760 gnus-undownloaded-mark)
3761 (gnus-newsgroup-agentized
3762 gnus-downloaded-mark)
3763 (t
3764 gnus-no-mark)))
3765 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3766 (gnus-tmp-name
3767 (cond
3768 ((string-match "<[^>]+> *$" gnus-tmp-from)
3769 (let ((beg (match-beginning 0)))
3770 (or (and (string-match "^\".+\"" gnus-tmp-from)
3771 (substring gnus-tmp-from 1 (1- (match-end 0))))
3772 (substring gnus-tmp-from 0 beg))))
3773 ((string-match "(.+)" gnus-tmp-from)
3774 (substring gnus-tmp-from
3775 (1+ (match-beginning 0)) (1- (match-end 0))))
3776 (t gnus-tmp-from)))
3777 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3778 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3779 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3780 (inhibit-read-only t))
3781 (when (string= gnus-tmp-name "")
3782 (setq gnus-tmp-name gnus-tmp-from))
3783 (unless (numberp gnus-tmp-lines)
3784 (setq gnus-tmp-lines -1))
3785 (if (= gnus-tmp-lines -1)
3786 (setq gnus-tmp-lines "?")
3787 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3788 (condition-case ()
3789 (gnus-put-text-property
3790 (point)
3791 (progn (eval gnus-summary-line-format-spec) (point))
3792 'gnus-number gnus-tmp-number)
3793 (error (gnus-message 5 "Error updating the summary line")))
3794 (when (gnus-visual-p 'summary-highlight 'highlight)
3795 (forward-line -1)
3796 (gnus-summary-highlight-line)
3797 (gnus-run-hooks 'gnus-summary-update-hook)
3798 (forward-line 1))))
3799
3800 (defun gnus-summary-update-line (&optional dont-update)
3801 "Update summary line after change."
3802 (when (and gnus-summary-default-score
3803 (not gnus-summary-inhibit-highlight))
3804 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3805 (article (gnus-summary-article-number))
3806 (score (gnus-summary-article-score article)))
3807 (unless dont-update
3808 (if (and gnus-summary-mark-below
3809 (< (gnus-summary-article-score)
3810 gnus-summary-mark-below))
3811 ;; This article has a low score, so we mark it as read.
3812 (when (memq article gnus-newsgroup-unreads)
3813 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3814 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3815 ;; This article was previously marked as read on account
3816 ;; of a low score, but now it has risen, so we mark it as
3817 ;; unread.
3818 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3819 (gnus-summary-update-mark
3820 (if (or (null gnus-summary-default-score)
3821 (<= (abs (- score gnus-summary-default-score))
3822 gnus-summary-zcore-fuzz))
3823 ? ;Whitespace
3824 (if (< score gnus-summary-default-score)
3825 gnus-score-below-mark gnus-score-over-mark))
3826 'score))
3827 ;; Do visual highlighting.
3828 (when (gnus-visual-p 'summary-highlight 'highlight)
3829 (gnus-summary-highlight-line)
3830 (gnus-run-hooks 'gnus-summary-update-hook)))))
3831
3832 (defvar gnus-tmp-new-adopts nil)
3833
3834 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3835 "Return the number of articles in THREAD.
3836 This may be 0 in some cases -- if none of the articles in
3837 the thread are to be displayed."
3838 (let* ((number
3839 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3840 (cond
3841 ((not (listp thread))
3842 1)
3843 ((and (consp thread) (cdr thread))
3844 (apply
3845 '+ 1 (mapcar
3846 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3847 ((null thread)
3848 1)
3849 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3850 1)
3851 (t 0))))
3852 (when (and level (zerop level) gnus-tmp-new-adopts)
3853 (incf number
3854 (apply '+ (mapcar
3855 'gnus-summary-number-of-articles-in-thread
3856 gnus-tmp-new-adopts))))
3857 (if char
3858 (if (> number 1) gnus-not-empty-thread-mark
3859 gnus-empty-thread-mark)
3860 number)))
3861
3862 (defsubst gnus-summary-line-message-size (head)
3863 "Return pretty-printed version of message size.
3864 This function is intended to be used in
3865 `gnus-summary-line-format-alist'."
3866 (let ((c (or (mail-header-chars head) -1)))
3867 (cond ((< c 0) "n/a") ; chars not available
3868 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3869 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3870 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3871 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3872
3873 (defcustom gnus-user-date-format-alist
3874 '(((gnus-seconds-today) . "Today, %H:%M")
3875 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3876 (604800 . "%A %H:%M") ; That's one week
3877 ((gnus-seconds-month) . "%A %d")
3878 ((gnus-seconds-year) . "%B %d")
3879 (t . "%b %d %Y")) ; This one is used when no other
3880 ; does match
3881 "Specifies date format depending on age of article.
3882 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3883 seconds) or a Lisp expression evaluating to a number. When the age of
3884 the article is less than this number, then use `format-time-string'
3885 with the corresponding FORMAT for displaying the date of the article.
3886 If AGE is not a number or a Lisp expression evaluating to a
3887 non-number, then the corresponding FORMAT is used as a default value.
3888
3889 Note that the list is processed from the beginning, so it should be
3890 sorted by ascending AGE. Also note that items following the first
3891 non-number AGE will be ignored.
3892
3893 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3894 and `gnus-seconds-year' in the AGE spec. They return the number of
3895 seconds passed since the start of today, of this month, of this year,
3896 respectively."
3897 :version "24.1"
3898 :group 'gnus-summary-format
3899 :type '(alist :key-type sexp :value-type string))
3900
3901 (defun gnus-user-date (messy-date)
3902 "Format the messy-date according to `gnus-user-date-format-alist'.
3903 Returns \" ? \" if there's bad input or if another error occurs.
3904 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3905 (condition-case ()
3906 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3907 (now (gnus-float-time))
3908 ;;If we don't find something suitable we'll use this one
3909 (my-format "%b %d '%y"))
3910 (let* ((difference (- now messy-date))
3911 (templist gnus-user-date-format-alist)
3912 (top (eval (caar templist))))
3913 (while (if (numberp top) (< top difference) (not top))
3914 (progn
3915 (setq templist (cdr templist))
3916 (setq top (eval (caar templist)))))
3917 (if (stringp (cdr (car templist)))
3918 (setq my-format (cdr (car templist)))))
3919 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3920 (error " ? ")))
3921
3922 (defun gnus-summary-set-local-parameters (group)
3923 "Go through the local params of GROUP and set all variable specs in that list."
3924 (let ((vars '(quit-config active))) ; Ignore things that aren't
3925 ; really variables.
3926 (dolist (elem (gnus-group-find-parameter group))
3927 (and (consp elem) ; Has to be a cons.
3928 (consp (cdr elem)) ; The cdr has to be a list.
3929 (symbolp (car elem)) ; Has to be a symbol in there.
3930 (not (memq (car elem) vars))
3931 (ignore-errors
3932 (push (car elem) vars)
3933 ;; Variables like `gnus-show-threads' that are globally
3934 ;; bound, if used as group parameters, need to get to be
3935 ;; buffer-local, whereas just parameters like `gcc-self',
3936 ;; `timestamp', etc. should not be bound as variables.
3937 (if (boundp (car elem))
3938 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3939 (eval (nth 1 elem))))))))
3940
3941 (defun gnus-summary-read-group (group &optional show-all no-article
3942 kill-buffer no-display backward
3943 select-articles)
3944 "Start reading news in newsgroup GROUP.
3945 If SHOW-ALL is non-nil, already read articles are also listed.
3946 If NO-ARTICLE is non-nil, no article is selected initially.
3947 If NO-DISPLAY, don't generate the summary buffer contents.
3948 If KILL-BUFFER, it should be a buffer that's killed once the new
3949 summary buffer has been generated.
3950 If BACKWARD, move point to the previous group in the group buffer
3951 If SELECT-ARTICLES, only select those articles from GROUP."
3952 (let (result)
3953 (while (and group
3954 (null (setq result
3955 (let ((gnus-auto-select-next nil))
3956 (or (gnus-summary-read-group-1
3957 group show-all no-article
3958 kill-buffer no-display
3959 select-articles)
3960 (setq show-all nil
3961 select-articles nil)))))
3962 (eq gnus-auto-select-next 'quietly))
3963 (set-buffer gnus-group-buffer)
3964 ;; The entry function called above goes to the next
3965 ;; group automatically, so we go two groups back
3966 ;; if we are searching for the previous group.
3967 (when backward
3968 (gnus-group-prev-unread-group 2))
3969 (if (not (equal group (gnus-group-group-name)))
3970 (setq group (gnus-group-group-name))
3971 (setq group nil)))
3972 result))
3973
3974 (defun gnus-summary-read-group-1 (group show-all no-article
3975 kill-buffer no-display
3976 &optional select-articles)
3977 ;; Killed foreign groups can't be entered.
3978 ;; (when (and (not (gnus-group-native-p group))
3979 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3980 ;; (error "Dead non-native groups can't be entered"))
3981 (gnus-message 7 "Retrieving newsgroup: %s..."
3982 (gnus-group-decoded-name group))
3983 (let* ((new-group (gnus-summary-setup-buffer group))
3984 (quit-config (gnus-group-quit-config group))
3985 (did-select (and new-group (gnus-select-newsgroup
3986 group show-all select-articles))))
3987 (cond
3988 ;; This summary buffer exists already, so we just select it.
3989 ((not new-group)
3990 (gnus-set-global-variables)
3991 (when kill-buffer
3992 (gnus-kill-or-deaden-summary kill-buffer))
3993 (gnus-configure-windows 'summary 'force)
3994 (gnus-set-mode-line 'summary)
3995 (gnus-summary-position-point)
3996 (message "")
3997 t)
3998 ;; We couldn't select this group.
3999 ((null did-select)
4000 (when (and (derived-mode-p 'gnus-summary-mode)
4001 (not (equal (current-buffer) kill-buffer)))
4002 (kill-buffer (current-buffer))
4003 (if (not quit-config)
4004 (progn
4005 ;; Update the info -- marks might need to be removed,
4006 ;; for instance.
4007 (gnus-summary-update-info)
4008 (set-buffer gnus-group-buffer)
4009 (gnus-group-jump-to-group group)
4010 (gnus-group-next-unread-group 1))
4011 (gnus-handle-ephemeral-exit quit-config)))
4012 (if (null (gnus-list-of-unread-articles group))
4013 (gnus-message 3 "Group %s contains no messages"
4014 (gnus-group-decoded-name group))
4015 (gnus-message 3 "Can't select group"))
4016 nil)
4017 ;; The user did a `C-g' while prompting for number of articles,
4018 ;; so we exit this group.
4019 ((eq did-select 'quit)
4020 (and (derived-mode-p 'gnus-summary-mode)
4021 (not (equal (current-buffer) kill-buffer))
4022 (kill-buffer (current-buffer)))
4023 (when kill-buffer
4024 (gnus-kill-or-deaden-summary kill-buffer))
4025 (if (not quit-config)
4026 (progn
4027 (set-buffer gnus-group-buffer)
4028 (gnus-group-jump-to-group group)
4029 (gnus-configure-windows 'group 'force))
4030 (gnus-handle-ephemeral-exit quit-config))
4031 ;; Finally signal the quit.
4032 (signal 'quit nil))
4033 ;; The group was successfully selected.
4034 (t
4035 (gnus-set-global-variables)
4036 (when (boundp 'spam-install-hooks)
4037 (spam-initialize))
4038 ;; Save the active value in effect when the group was entered.
4039 (setq gnus-newsgroup-active
4040 (gnus-copy-sequence
4041 (gnus-active gnus-newsgroup-name)))
4042 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4043 ;; You can change the summary buffer in some way with this hook.
4044 (gnus-run-hooks 'gnus-select-group-hook)
4045 (when (memq 'summary (gnus-update-format-specifications
4046 nil 'summary 'summary-mode 'summary-dummy))
4047 ;; The format specification for the summary line was updated,
4048 ;; so we need to update the mark positions as well.
4049 (gnus-update-summary-mark-positions))
4050 ;; Do score processing.
4051 (when gnus-use-scoring
4052 (gnus-possibly-score-headers))
4053 ;; Check whether to fill in the gaps in the threads.
4054 (when gnus-build-sparse-threads
4055 (gnus-build-sparse-threads))
4056 ;; Find the initial limit.
4057 (if show-all
4058 (let ((gnus-newsgroup-dormant nil))
4059 (gnus-summary-initial-limit show-all))
4060 (gnus-summary-initial-limit show-all))
4061 ;; Generate the summary buffer.
4062 (unless no-display
4063 (gnus-summary-prepare))
4064 (when gnus-use-trees
4065 (gnus-tree-open)
4066 (setq gnus-summary-highlight-line-function
4067 'gnus-tree-highlight-article))
4068 ;; If the summary buffer is empty, but there are some low-scored
4069 ;; articles or some excluded dormants, we include these in the
4070 ;; buffer.
4071 (when (and (zerop (buffer-size))
4072 (not no-display))
4073 (cond (gnus-newsgroup-dormant
4074 (gnus-summary-limit-include-dormant))
4075 ((and gnus-newsgroup-scored show-all)
4076 (gnus-summary-limit-include-expunged t))))
4077 ;; Function `gnus-apply-kill-file' must be called in this hook.
4078 (gnus-run-hooks 'gnus-apply-kill-hook)
4079 (if (and (zerop (buffer-size))
4080 (not no-display))
4081 (progn
4082 ;; This newsgroup is empty.
4083 (gnus-summary-catchup-and-exit nil t)
4084 (gnus-message 6 "No unread news")
4085 (when kill-buffer
4086 (gnus-kill-or-deaden-summary kill-buffer))
4087 ;; Return nil from this function.
4088 nil)
4089 ;; Hide conversation thread subtrees. We cannot do this in
4090 ;; gnus-summary-prepare-hook since kill processing may not
4091 ;; work with hidden articles.
4092 (gnus-summary-maybe-hide-threads)
4093 (gnus-configure-windows 'summary)
4094 (when kill-buffer
4095 (gnus-kill-or-deaden-summary kill-buffer))
4096 (gnus-summary-auto-select-subject)
4097 ;; Show first unread article if requested.
4098 (if (and (not no-article)
4099 (not no-display)
4100 gnus-newsgroup-unreads
4101 gnus-auto-select-first)
4102 (progn
4103 (let ((art (gnus-summary-article-number)))
4104 (when (and art
4105 gnus-plugged
4106 (not (memq art gnus-newsgroup-undownloaded))
4107 (not (memq art gnus-newsgroup-downloadable)))
4108 (gnus-summary-goto-article art))))
4109 ;; Don't select any articles.
4110 (gnus-summary-position-point)
4111 (gnus-configure-windows 'summary 'force)
4112 (gnus-set-mode-line 'summary))
4113 (when (and gnus-auto-center-group
4114 (get-buffer-window gnus-group-buffer t))
4115 ;; Gotta use windows, because recenter does weird stuff if
4116 ;; the current buffer ain't the displayed window.
4117 (let ((owin (selected-window)))
4118 (select-window (get-buffer-window gnus-group-buffer t))
4119 (when (gnus-group-goto-group group)
4120 (recenter))
4121 (select-window owin)))
4122 ;; Mark this buffer as "prepared".
4123 (setq gnus-newsgroup-prepared t)
4124 (gnus-run-hooks 'gnus-summary-prepared-hook)
4125 (unless (gnus-ephemeral-group-p group)
4126 (gnus-group-update-group group nil t))
4127 t)))))
4128
4129 (defun gnus-summary-auto-select-subject ()
4130 "Select the subject line on initial group entry."
4131 (goto-char (point-min))
4132 (cond
4133 ((eq gnus-auto-select-subject 'best)
4134 (gnus-summary-best-unread-subject))
4135 ((eq gnus-auto-select-subject 'unread)
4136 (gnus-summary-first-unread-subject))
4137 ((eq gnus-auto-select-subject 'unseen)
4138 (gnus-summary-first-unseen-subject))
4139 ((eq gnus-auto-select-subject 'unseen-or-unread)
4140 (gnus-summary-first-unseen-or-unread-subject))
4141 ((eq gnus-auto-select-subject 'first)
4142 ;; Do nothing.
4143 )
4144 ((functionp gnus-auto-select-subject)
4145 (funcall gnus-auto-select-subject))))
4146
4147 (defun gnus-summary-prepare ()
4148 "Generate the summary buffer."
4149 (interactive)
4150 (let ((inhibit-read-only t))
4151 (erase-buffer)
4152 (setq gnus-newsgroup-data nil
4153 gnus-newsgroup-data-reverse nil)
4154 (gnus-run-hooks 'gnus-summary-generate-hook)
4155 ;; Generate the buffer, either with threads or without.
4156 (when gnus-newsgroup-headers
4157 (gnus-summary-prepare-threads
4158 (if gnus-show-threads
4159 (gnus-sort-gathered-threads
4160 (funcall gnus-summary-thread-gathering-function
4161 (gnus-sort-threads
4162 (gnus-cut-threads (gnus-make-threads)))))
4163 ;; Unthreaded display.
4164 (gnus-sort-articles gnus-newsgroup-headers))))
4165 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4166 ;; Call hooks for modifying summary buffer.
4167 (goto-char (point-min))
4168 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4169
4170 (defsubst gnus-general-simplify-subject (subject)
4171 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4172 (setq subject
4173 (cond
4174 ;; Truncate the subject.
4175 (gnus-simplify-subject-functions
4176 (gnus-map-function gnus-simplify-subject-functions subject))
4177 ((numberp gnus-summary-gather-subject-limit)
4178 (setq subject (gnus-simplify-subject-re subject))
4179 (if (> (length subject) gnus-summary-gather-subject-limit)
4180 (substring subject 0 gnus-summary-gather-subject-limit)
4181 subject))
4182 ;; Fuzzily simplify it.
4183 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4184 (gnus-simplify-subject-fuzzy subject))
4185 ;; Just remove the leading "Re:".
4186 (t
4187 (gnus-simplify-subject-re subject))))
4188
4189 (if (and gnus-summary-gather-exclude-subject
4190 (string-match gnus-summary-gather-exclude-subject subject))
4191 nil ; This article shouldn't be gathered
4192 subject))
4193
4194 (defun gnus-summary-simplify-subject-query ()
4195 "Query where the respool algorithm would put this article."
4196 (interactive)
4197 (gnus-summary-select-article)
4198 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4199
4200 (defun gnus-gather-threads-by-subject (threads)
4201 "Gather threads by looking at Subject headers."
4202 (if (not gnus-summary-make-false-root)
4203 threads
4204 (let ((hashtb (gnus-make-hashtable 1024))
4205 (prev threads)
4206 (result threads)
4207 subject hthread whole-subject)
4208 (while threads
4209 (setq subject (gnus-general-simplify-subject
4210 (setq whole-subject (mail-header-subject
4211 (caar threads)))))
4212 (when subject
4213 (if (setq hthread (gnus-gethash subject hashtb))
4214 (progn
4215 ;; We enter a dummy root into the thread, if we
4216 ;; haven't done that already.
4217 (unless (stringp (caar hthread))
4218 (setcar hthread (list whole-subject (car hthread))))
4219 ;; We add this new gathered thread to this gathered
4220 ;; thread.
4221 (setcdr (car hthread)
4222 (nconc (cdar hthread) (list (car threads))))
4223 ;; Remove it from the list of threads.
4224 (setcdr prev (cdr threads))
4225 (setq threads prev))
4226 ;; Enter this thread into the hash table.
4227 (gnus-sethash subject
4228 (if gnus-summary-make-false-root-always
4229 (progn
4230 ;; If you want a dummy root above all
4231 ;; threads...
4232 (setcar threads (list whole-subject
4233 (car threads)))
4234 threads)
4235 threads)
4236 hashtb)))
4237 (setq prev threads)
4238 (setq threads (cdr threads)))
4239 result)))
4240
4241 (defun gnus-gather-threads-by-references (threads)
4242 "Gather threads by looking at References headers."
4243 (let ((idhashtb (gnus-make-hashtable 1024))
4244 (thhashtb (gnus-make-hashtable 1024))
4245 (prev threads)
4246 (result threads)
4247 ids references id gthread gid entered ref)
4248 (while threads
4249 (when (setq references (mail-header-references (caar threads)))
4250 (setq id (mail-header-id (caar threads))
4251 ids (inline (gnus-split-references references))
4252 entered nil)
4253 (while (setq ref (pop ids))
4254 (setq ids (delete ref ids))
4255 (if (not (setq gid (gnus-gethash ref idhashtb)))
4256 (progn
4257 (gnus-sethash ref id idhashtb)
4258 (gnus-sethash id threads thhashtb))
4259 (setq gthread (gnus-gethash gid thhashtb))
4260 (unless entered
4261 ;; We enter a dummy root into the thread, if we
4262 ;; haven't done that already.
4263 (unless (stringp (caar gthread))
4264 (setcar gthread (list (mail-header-subject (caar gthread))
4265 (car gthread))))
4266 ;; We add this new gathered thread to this gathered
4267 ;; thread.
4268 (setcdr (car gthread)
4269 (nconc (cdar gthread) (list (car threads)))))
4270 ;; Add it into the thread hash table.
4271 (gnus-sethash id gthread thhashtb)
4272 (setq entered t)
4273 ;; Remove it from the list of threads.
4274 (setcdr prev (cdr threads))
4275 (setq threads prev))))
4276 (setq prev threads)
4277 (setq threads (cdr threads)))
4278 result))
4279
4280 (defun gnus-sort-gathered-threads (threads)
4281 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4282 (let ((result threads))
4283 (while threads
4284 (when (stringp (caar threads))
4285 (setcdr (car threads)
4286 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4287 (setq threads (cdr threads)))
4288 result))
4289
4290 (defun gnus-thread-loop-p (root thread)
4291 "Say whether ROOT is in THREAD."
4292 (let ((stack (list thread))
4293 (infloop 0)
4294 th)
4295 (while (setq thread (pop stack))
4296 (setq th (cdr thread))
4297 (while (and th
4298 (not (eq (caar th) root)))
4299 (pop th))
4300 (if th
4301 ;; We have found a loop.
4302 (let (ref-dep)
4303 (setcdr thread (delq (car th) (cdr thread)))
4304 (if (boundp (setq ref-dep (intern "none"
4305 gnus-newsgroup-dependencies)))
4306 (setcdr (symbol-value ref-dep)
4307 (nconc (cdr (symbol-value ref-dep))
4308 (list (car th))))
4309 (set ref-dep (list nil (car th))))
4310 (setq infloop 1
4311 stack nil))
4312 ;; Push all the subthreads onto the stack.
4313 (push (cdr thread) stack)))
4314 infloop))
4315
4316 (defun gnus-make-threads ()
4317 "Go through the dependency hashtb and find the roots. Return all threads."
4318 (let (threads)
4319 (while (catch 'infloop
4320 (mapatoms
4321 (lambda (refs)
4322 ;; Deal with self-referencing References loops.
4323 (when (and (car (symbol-value refs))
4324 (not (zerop
4325 (apply
4326 '+
4327 (mapcar
4328 (lambda (thread)
4329 (gnus-thread-loop-p
4330 (car (symbol-value refs)) thread))
4331 (cdr (symbol-value refs)))))))
4332 (setq threads nil)
4333 (throw 'infloop t))
4334 (unless (car (symbol-value refs))
4335 ;; These threads do not refer back to any other
4336 ;; articles, so they're roots.
4337 (setq threads (append (cdr (symbol-value refs)) threads))))
4338 gnus-newsgroup-dependencies)))
4339 threads))
4340
4341 ;; Build the thread tree.
4342 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4343 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4344
4345 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4346 if it was already present.
4347
4348 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4349 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4350 Message-IDs will be renamed to a unique Message-ID before being
4351 entered.
4352
4353 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4354 (let* ((id (mail-header-id header))
4355 (id-dep (and id (intern id dependencies)))
4356 parent-id ref ref-dep ref-header replaced)
4357 ;; Enter this `header' in the `dependencies' table.
4358 (cond
4359 ((not id-dep)
4360 (setq header nil))
4361 ;; The first two cases do the normal part: enter a new `header'
4362 ;; in the `dependencies' table.
4363 ((not (boundp id-dep))
4364 (set id-dep (list header)))
4365 ((null (car (symbol-value id-dep)))
4366 (setcar (symbol-value id-dep) header))
4367
4368 ;; From here the `header' was already present in the
4369 ;; `dependencies' table.
4370 (force-new
4371 ;; Overrides an existing entry;
4372 ;; just set the header part of the entry.
4373 (setcar (symbol-value id-dep) header)
4374 (setq replaced t))
4375
4376 ;; Renames the existing `header' to a unique Message-ID.
4377 ((not gnus-summary-ignore-duplicates)
4378 ;; An article with this Message-ID has already been seen.
4379 ;; We rename the Message-ID.
4380 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4381 (list header))
4382 (mail-header-set-id header id))
4383
4384 ;; The last case ignores an existing entry, except it adds any
4385 ;; additional Xrefs (in case the two articles came from different
4386 ;; servers.
4387 ;; Also sets `header' to nil meaning that the `dependencies'
4388 ;; table was *not* modified.
4389 (t
4390 (mail-header-set-xref
4391 (car (symbol-value id-dep))
4392 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4393 "")
4394 (or (mail-header-xref header) "")))
4395 (setq header nil)))
4396
4397 (when (and header (not replaced))
4398 ;; First check that we are not creating a References loop.
4399 (setq parent-id (gnus-parent-id (mail-header-references header)))
4400 (setq ref parent-id)
4401 (while (and ref
4402 (setq ref-dep (intern-soft ref dependencies))
4403 (boundp ref-dep)
4404 (setq ref-header (car (symbol-value ref-dep))))
4405 (if (string= id ref)
4406 ;; Yuk! This is a reference loop. Make the article be a
4407 ;; root article.
4408 (progn
4409 (mail-header-set-references (car (symbol-value id-dep)) "none")
4410 (setq ref nil)
4411 (setq parent-id nil))
4412 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4413 (setq ref-dep (intern (or parent-id "none") dependencies))
4414 (if (boundp ref-dep)
4415 (setcdr (symbol-value ref-dep)
4416 (nconc (cdr (symbol-value ref-dep))
4417 (list (symbol-value id-dep))))
4418 (set ref-dep (list nil (symbol-value id-dep)))))
4419 header))
4420
4421 (defun gnus-extract-message-id-from-in-reply-to (string)
4422 (if (string-match "<[^>]+>" string)
4423 (substring string (match-beginning 0) (match-end 0))
4424 nil))
4425
4426 (defun gnus-build-sparse-threads ()
4427 (let ((headers gnus-newsgroup-headers)
4428 (mail-parse-charset gnus-newsgroup-charset)
4429 (gnus-summary-ignore-duplicates t)
4430 header references generation relations
4431 subject child end new-child date)
4432 ;; First we create an alist of generations/relations, where
4433 ;; generations is how much we trust the relation, and the relation
4434 ;; is parent/child.
4435 (gnus-message 7 "Making sparse threads...")
4436 (save-excursion
4437 (nnheader-set-temp-buffer " *gnus sparse threads*")
4438 (while (setq header (pop headers))
4439 (when (and (setq references (mail-header-references header))
4440 (not (string= references "")))
4441 (insert references)
4442 (setq child (mail-header-id header)
4443 subject (mail-header-subject header)
4444 date (mail-header-date header)
4445 generation 0)
4446 (while (search-backward ">" nil t)
4447 (setq end (1+ (point)))
4448 (when (search-backward "<" nil t)
4449 (setq new-child (buffer-substring (point) end))
4450 (push (list (incf generation)
4451 child (setq child new-child)
4452 subject date)
4453 relations)))
4454 (when child
4455 (push (list (1+ generation) child nil subject) relations))
4456 (erase-buffer)))
4457 (kill-buffer (current-buffer)))
4458 ;; Sort over trustworthiness.
4459 (dolist (relation (sort relations 'car-less-than-car))
4460 (when (gnus-dependencies-add-header
4461 (make-full-mail-header
4462 gnus-reffed-article-number
4463 (nth 3 relation) "" (or (nth 4 relation) "")
4464 (nth 1 relation)
4465 (or (nth 2 relation) "") 0 0 "")
4466 gnus-newsgroup-dependencies nil)
4467 (push gnus-reffed-article-number gnus-newsgroup-limit)
4468 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4469 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4470 gnus-newsgroup-reads)
4471 (decf gnus-reffed-article-number)))
4472 (gnus-message 7 "Making sparse threads...done")))
4473
4474 (defun gnus-build-old-threads ()
4475 ;; Look at all the articles that refer back to old articles, and
4476 ;; fetch the headers for the articles that aren't there. This will
4477 ;; build complete threads - if the roots haven't been expired by the
4478 ;; server, that is.
4479 (let ((mail-parse-charset gnus-newsgroup-charset)
4480 id heads)
4481 (mapatoms
4482 (lambda (refs)
4483 (when (not (car (symbol-value refs)))
4484 (setq heads (cdr (symbol-value refs)))
4485 (while heads
4486 (if (memq (mail-header-number (caar heads))
4487 gnus-newsgroup-dormant)
4488 (setq heads (cdr heads))
4489 (setq id (symbol-name refs))
4490 (while (and (setq id (gnus-build-get-header id))
4491 (not (car (gnus-id-to-thread id)))))
4492 (setq heads nil)))))
4493 gnus-newsgroup-dependencies)))
4494
4495 (defsubst gnus-remove-odd-characters (string)
4496 "Translate STRING into something that doesn't contain weird characters."
4497 (mm-subst-char-in-string
4498 ?\r ?\-
4499 (mm-subst-char-in-string ?\n ?\- string t) t))
4500
4501 ;; This function has to be called with point after the article number
4502 ;; on the beginning of the line.
4503 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4504 (let ((eol (point-at-eol))
4505 (buffer (current-buffer))
4506 header references in-reply-to)
4507
4508 ;; overview: [num subject from date id refs chars lines misc]
4509 (unwind-protect
4510 (let (x)
4511 (narrow-to-region (point) eol)
4512 (unless (eobp)
4513 (forward-char))
4514
4515 (setq header
4516 (make-full-mail-header
4517 number ; number
4518 (condition-case () ; subject
4519 (gnus-remove-odd-characters
4520 (funcall gnus-decode-encoded-word-function
4521 (setq x (nnheader-nov-field))))
4522 (error x))
4523 (condition-case () ; from
4524 (gnus-remove-odd-characters
4525 (funcall gnus-decode-encoded-address-function
4526 (setq x (nnheader-nov-field))))
4527 (error x))
4528 (nnheader-nov-field) ; date
4529 (nnheader-nov-read-message-id number) ; id
4530 (setq references (nnheader-nov-field)) ; refs
4531 (nnheader-nov-read-integer) ; chars
4532 (nnheader-nov-read-integer) ; lines
4533 (unless (eobp)
4534 (if (looking-at "Xref: ")
4535 (goto-char (match-end 0)))
4536 (nnheader-nov-field)) ; Xref
4537 (nnheader-nov-parse-extra)))) ; extra
4538
4539 (widen))
4540
4541 (when (and (string= references "")
4542 (setq in-reply-to (mail-header-extra header))
4543 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4544 (mail-header-set-references
4545 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4546
4547 (when gnus-alter-header-function
4548 (funcall gnus-alter-header-function header))
4549 (gnus-dependencies-add-header header dependencies force-new)))
4550
4551 (defun gnus-build-get-header (id)
4552 "Look through the buffer of NOV lines and find the header to ID.
4553 Enter this line into the dependencies hash table, and return
4554 the id of the parent article (if any)."
4555 (let ((deps gnus-newsgroup-dependencies)
4556 found header)
4557 (prog1
4558 (with-current-buffer nntp-server-buffer
4559 (let ((case-fold-search nil))
4560 (goto-char (point-min))
4561 (while (and (not found)
4562 (search-forward id nil t))
4563 (beginning-of-line)
4564 (setq found (looking-at
4565 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4566 (regexp-quote id))))
4567 (or found (beginning-of-line 2)))
4568 (when found
4569 (beginning-of-line)
4570 (and
4571 (setq header (gnus-nov-parse-line
4572 (read (current-buffer)) deps))
4573 (gnus-parent-id (mail-header-references header))))))
4574 (when header
4575 (let ((number (mail-header-number header)))
4576 (push number gnus-newsgroup-limit)
4577 (push header gnus-newsgroup-headers)
4578 (if (memq number gnus-newsgroup-unselected)
4579 (progn
4580 (setq gnus-newsgroup-unreads
4581 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4582 number))
4583 (setq gnus-newsgroup-unselected
4584 (delq number gnus-newsgroup-unselected)))
4585 (push number gnus-newsgroup-ancient)))))))
4586
4587 (defun gnus-build-all-threads ()
4588 "Read all the headers."
4589 (let ((gnus-summary-ignore-duplicates t)
4590 (mail-parse-charset gnus-newsgroup-charset)
4591 (dependencies gnus-newsgroup-dependencies)
4592 header article)
4593 (with-current-buffer nntp-server-buffer
4594 (let ((case-fold-search nil))
4595 (goto-char (point-min))
4596 (while (not (eobp))
4597 (ignore-errors
4598 (setq article (read (current-buffer))
4599 header (gnus-nov-parse-line article dependencies t)))
4600 (when header
4601 (with-current-buffer gnus-summary-buffer
4602 (push header gnus-newsgroup-headers)
4603 (if (memq (setq article (mail-header-number header))
4604 gnus-newsgroup-unselected)
4605 (progn
4606 (setq gnus-newsgroup-unreads
4607 (gnus-add-to-sorted-list
4608 gnus-newsgroup-unreads article))
4609 (setq gnus-newsgroup-unselected
4610 (delq article gnus-newsgroup-unselected)))
4611 (push article gnus-newsgroup-ancient)))
4612 (forward-line 1)))))))
4613
4614 (defun gnus-summary-update-article-line (article header)
4615 "Update the line for ARTICLE using HEADER."
4616 (let* ((id (mail-header-id header))
4617 (thread (gnus-id-to-thread id)))
4618 (unless thread
4619 (error "Article in no thread"))
4620 ;; Update the thread.
4621 (setcar thread header)
4622 (gnus-summary-goto-subject article)
4623 (let* ((datal (gnus-data-find-list article))
4624 (data (car datal))
4625 (inhibit-read-only t)
4626 (level (gnus-summary-thread-level)))
4627 (gnus-delete-line)
4628 (let ((inserted (- (point)
4629 (progn
4630 (gnus-summary-insert-line
4631 header level nil
4632 (memq article gnus-newsgroup-undownloaded)
4633 (gnus-article-mark article)
4634 (memq article gnus-newsgroup-replied)
4635 (memq article gnus-newsgroup-expirable)
4636 ;; Only insert the Subject string when it's different
4637 ;; from the previous Subject string.
4638 (if (and
4639 gnus-show-threads
4640 (gnus-subject-equal
4641 (condition-case ()
4642 (mail-header-subject
4643 (gnus-data-header
4644 (cadr
4645 (gnus-data-find-list
4646 article
4647 (gnus-data-list t)))))
4648 ;; Error on the side of excessive subjects.
4649 (error ""))
4650 (mail-header-subject header)))
4651 ""
4652 (mail-header-subject header))
4653 nil (cdr (assq article gnus-newsgroup-scored))
4654 (memq article gnus-newsgroup-processable))
4655 (point)))))
4656 (when (cdr datal)
4657 (gnus-data-update-list
4658 (cdr datal)
4659 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4660
4661 (defun gnus-summary-update-article (article &optional iheader)
4662 "Update ARTICLE in the summary buffer."
4663 (set-buffer gnus-summary-buffer)
4664 (let* ((header (gnus-summary-article-header article))
4665 (id (mail-header-id header))
4666 (data (gnus-data-find article))
4667 (thread (gnus-id-to-thread id))
4668 (references (mail-header-references header))
4669 (parent
4670 (gnus-id-to-thread
4671 (or (gnus-parent-id
4672 (when (and references
4673 (not (equal "" references)))
4674 references))
4675 "none")))
4676 (inhibit-read-only t)
4677 (old (car thread)))
4678 (when thread
4679 (unless iheader
4680 (setcar thread nil)
4681 (when parent
4682 (delq thread parent)))
4683 (if (gnus-summary-insert-subject id header)
4684 ;; Set the (possibly) new article number in the data structure.
4685 (gnus-data-set-number data (gnus-id-to-article id))
4686 (setcar thread old)
4687 nil))))
4688
4689 (defun gnus-rebuild-thread (id &optional line)
4690 "Rebuild the thread containing ID.
4691 If LINE, insert the rebuilt thread starting on line LINE."
4692 (let ((inhibit-read-only t)
4693 old-pos current thread data)
4694 (if (not gnus-show-threads)
4695 (setq thread (list (car (gnus-id-to-thread id))))
4696 ;; Get the thread this article is part of.
4697 (setq thread (gnus-remove-thread id)))
4698 (setq old-pos (point-at-bol))
4699 (setq current (save-excursion
4700 (and (re-search-backward "[\r\n]" nil t)
4701 (gnus-summary-article-number))))
4702 ;; If this is a gathered thread, we have to go some re-gathering.
4703 (when (stringp (car thread))
4704 (let ((subject (car thread))
4705 roots thr)
4706 (setq thread (cdr thread))
4707 (while thread
4708 (unless (memq (setq thr (gnus-id-to-thread
4709 (gnus-root-id
4710 (mail-header-id (caar thread)))))
4711 roots)
4712 (push thr roots))
4713 (setq thread (cdr thread)))
4714 ;; We now have all (unique) roots.
4715 (if (= (length roots) 1)
4716 ;; All the loose roots are now one solid root.
4717 (setq thread (car roots))
4718 (setq thread (cons subject (gnus-sort-threads roots))))))
4719 (let (threads)
4720 ;; We then insert this thread into the summary buffer.
4721 (when line
4722 (goto-char (point-min))
4723 (forward-line (1- line)))
4724 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4725 (if gnus-show-threads
4726 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4727 (gnus-summary-prepare-unthreaded thread))
4728 (setq data (nreverse gnus-newsgroup-data))
4729 (setq threads gnus-newsgroup-threads))
4730 ;; We splice the new data into the data structure.
4731 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4732 ;;!!! then we want to insert at the beginning of the buffer.
4733 ;;!!! That happens to be true with Gnus now, but that may
4734 ;;!!! change in the future. Perhaps.
4735 (gnus-data-enter-list
4736 (if line nil current) data (- (point) old-pos))
4737 (setq gnus-newsgroup-threads
4738 (nconc threads gnus-newsgroup-threads))
4739 (gnus-data-compute-positions))))
4740
4741 (defun gnus-number-to-header (number)
4742 "Return the header for article NUMBER."
4743 (let ((headers gnus-newsgroup-headers))
4744 (while (and headers
4745 (not (= number (mail-header-number (car headers)))))
4746 (pop headers))
4747 (when headers
4748 (car headers))))
4749
4750 (defun gnus-parent-headers (in-headers &optional generation)
4751 "Return the headers of the GENERATIONth parent of HEADERS."
4752 (unless generation
4753 (setq generation 1))
4754 (let ((parent t)
4755 (headers in-headers)
4756 references)
4757 (while (and parent
4758 (not (zerop generation))
4759 (setq references (mail-header-references headers)))
4760 (setq headers (if (and references
4761 (setq parent (gnus-parent-id references)))
4762 (car (gnus-id-to-thread parent))
4763 nil))
4764 (decf generation))
4765 (and (not (eq headers in-headers))
4766 headers)))
4767
4768 (defun gnus-id-to-thread (id)
4769 "Return the (sub-)thread where ID appears."
4770 (gnus-gethash id gnus-newsgroup-dependencies))
4771
4772 (defun gnus-id-to-article (id)
4773 "Return the article number of ID."
4774 (let ((thread (gnus-id-to-thread id)))
4775 (when (and thread
4776 (car thread))
4777 (mail-header-number (car thread)))))
4778
4779 (defun gnus-id-to-header (id)
4780 "Return the article headers of ID."
4781 (car (gnus-id-to-thread id)))
4782
4783 (defun gnus-article-displayed-root-p (article)
4784 "Say whether ARTICLE is a root(ish) article."
4785 (let ((level (gnus-summary-thread-level article))
4786 (refs (mail-header-references (gnus-summary-article-header article)))
4787 particle)
4788 (cond
4789 ((null level) nil)
4790 ((zerop level) t)
4791 ((null refs) t)
4792 ((null (gnus-parent-id refs)) t)
4793 ((and (= 1 level)
4794 (null (setq particle (gnus-id-to-article
4795 (gnus-parent-id refs))))
4796 (null (gnus-summary-thread-level particle)))))))
4797
4798 (defun gnus-root-id (id)
4799 "Return the id of the root of the thread where ID appears."
4800 (let (last-id prev)
4801 (while (and id (setq prev (car (gnus-id-to-thread id))))
4802 (setq last-id id
4803 id (gnus-parent-id (mail-header-references prev))))
4804 last-id))
4805
4806 (defun gnus-articles-in-thread (thread)
4807 "Return the list of articles in THREAD."
4808 (cons (mail-header-number (car thread))
4809 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4810
4811 (defun gnus-remove-thread (id &optional dont-remove)
4812 "Remove the thread that has ID in it."
4813 (let (headers thread last-id)
4814 ;; First go up in this thread until we find the root.
4815 (setq last-id (gnus-root-id id)
4816 headers (message-flatten-list (gnus-id-to-thread last-id)))
4817 ;; We have now found the real root of this thread. It might have
4818 ;; been gathered into some loose thread, so we have to search
4819 ;; through the threads to find the thread we wanted.
4820 (let ((threads gnus-newsgroup-threads)
4821 sub)
4822 (while threads
4823 (setq sub (car threads))
4824 (if (stringp (car sub))
4825 ;; This is a gathered thread, so we look at the roots
4826 ;; below it to find whether this article is in this
4827 ;; gathered root.
4828 (progn
4829 (setq sub (cdr sub))
4830 (while sub
4831 (when (member (caar sub) headers)
4832 (setq thread (car threads)
4833 threads nil
4834 sub nil))
4835 (setq sub (cdr sub))))
4836 ;; It's an ordinary thread, so we check it.
4837 (when (eq (car sub) (car headers))
4838 (setq thread sub
4839 threads nil)))
4840 (setq threads (cdr threads)))
4841 ;; If this article is in no thread, then it's a root.
4842 (if thread
4843 (unless dont-remove
4844 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4845 (setq thread (gnus-id-to-thread last-id)))
4846 (when thread
4847 (prog1
4848 thread ; We return this thread.
4849 (unless dont-remove
4850 (if (stringp (car thread))
4851 (progn
4852 ;; If we use dummy roots, then we have to remove the
4853 ;; dummy root as well.
4854 (when (eq gnus-summary-make-false-root 'dummy)
4855 ;; We go to the dummy root by going to
4856 ;; the first sub-"thread", and then one line up.
4857 (gnus-summary-goto-article
4858 (mail-header-number (caadr thread)))
4859 (forward-line -1)
4860 (gnus-delete-line)
4861 (gnus-data-compute-positions))
4862 (setq thread (cdr thread))
4863 (while thread
4864 (gnus-remove-thread-1 (car thread))
4865 (setq thread (cdr thread))))
4866 (gnus-remove-thread-1 thread))))))))
4867
4868 (defun gnus-remove-thread-1 (thread)
4869 "Remove the thread THREAD recursively."
4870 (let ((number (mail-header-number (pop thread)))
4871 d)
4872 (setq thread (reverse thread))
4873 (while thread
4874 (gnus-remove-thread-1 (pop thread)))
4875 (when (setq d (gnus-data-find number))
4876 (goto-char (gnus-data-pos d))
4877 (gnus-summary-show-thread)
4878 (gnus-data-remove
4879 number
4880 (- (point-at-bol)
4881 (prog1
4882 (1+ (point-at-eol))
4883 (gnus-delete-line)))))))
4884
4885 (defun gnus-sort-threads-recursive (threads func)
4886 ;; Responsible for sorting the root articles of threads.
4887 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4888 'gnus-thread-sort-functions)
4889 func
4890 (gnus-make-sort-function
4891 gnus-subthread-sort-functions))))
4892 (sort (mapcar (lambda (thread)
4893 (cons (car thread)
4894 (and (cdr thread)
4895 (gnus-sort-subthreads-recursive
4896 (cdr thread) subthread-sort-func))))
4897 threads) func)))
4898
4899 (defun gnus-sort-subthreads-recursive (threads func)
4900 ;; Responsible for sorting subthreads.
4901 (sort (mapcar (lambda (thread)
4902 (cons (car thread)
4903 (and (cdr thread)
4904 (gnus-sort-subthreads-recursive (cdr thread) func))))
4905 threads) func))
4906
4907 (defun gnus-sort-threads-loop (threads func)
4908 (let* ((superthread (cons nil threads))
4909 (stack (list (cons superthread threads)))
4910 remaining-threads thread)
4911 (while stack
4912 (setq remaining-threads (cdr (car stack)))
4913 (if remaining-threads
4914 (progn (setq thread (car remaining-threads))
4915 (setcdr (car stack) (cdr remaining-threads))
4916 (if (cdr thread)
4917 (push (cons thread (cdr thread)) stack)))
4918 (setq thread (caar stack))
4919 (setcdr thread (sort (cdr thread) func))
4920 (pop stack)))
4921 (cdr superthread)))
4922
4923 (defun gnus-sort-threads (threads)
4924 "Sort THREADS."
4925 (if (not gnus-thread-sort-functions)
4926 threads
4927 (gnus-message 8 "Sorting threads...")
4928 (prog1
4929 (condition-case nil
4930 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4931 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4932 (gnus-sort-threads-recursive threads sort-func))
4933 ;; Even after binding max-lisp-eval-depth, the recursive
4934 ;; sorter might fail for very long threads. In that case,
4935 ;; try using a (less well-tested) non-recursive sorter.
4936 (error (gnus-message 9 "Sorting threads with loop...")
4937 (gnus-sort-threads-loop
4938 threads (gnus-make-sort-function
4939 gnus-thread-sort-functions))))
4940 (gnus-message 8 "Sorting threads...done"))))
4941
4942 (defun gnus-sort-articles (articles)
4943 "Sort ARTICLES."
4944 (when gnus-article-sort-functions
4945 (gnus-message 7 "Sorting articles...")
4946 (prog1
4947 (setq gnus-newsgroup-headers
4948 (sort articles (gnus-make-sort-function
4949 gnus-article-sort-functions)))
4950 (gnus-message 7 "Sorting articles...done"))))
4951
4952 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4953 (defmacro gnus-thread-header (thread)
4954 "Return header of first article in THREAD.
4955 Note that THREAD must never, ever be anything else than a variable -
4956 using some other form will lead to serious barfage."
4957 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4958 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4959 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4960 (vector thread) 2))
4961
4962 (defsubst gnus-article-sort-by-number (h1 h2)
4963 "Sort articles by article number."
4964 (< (mail-header-number h1)
4965 (mail-header-number h2)))
4966
4967 (defun gnus-thread-sort-by-number (h1 h2)
4968 "Sort threads by root article number."
4969 (gnus-article-sort-by-number
4970 (gnus-thread-header h1) (gnus-thread-header h2)))
4971
4972 (defsubst gnus-article-sort-by-random (h1 h2)
4973 "Sort articles randomly."
4974 (zerop (random 2)))
4975
4976 (defun gnus-thread-sort-by-random (h1 h2)
4977 "Sort threads randomly."
4978 (gnus-article-sort-by-random
4979 (gnus-thread-header h1) (gnus-thread-header h2)))
4980
4981 (defsubst gnus-article-sort-by-lines (h1 h2)
4982 "Sort articles by article Lines header."
4983 (< (mail-header-lines h1)
4984 (mail-header-lines h2)))
4985
4986 (defun gnus-thread-sort-by-lines (h1 h2)
4987 "Sort threads by root article Lines header."
4988 (gnus-article-sort-by-lines
4989 (gnus-thread-header h1) (gnus-thread-header h2)))
4990
4991 (defsubst gnus-article-sort-by-chars (h1 h2)
4992 "Sort articles by octet length."
4993 (< (mail-header-chars h1)
4994 (mail-header-chars h2)))
4995
4996 (defun gnus-thread-sort-by-chars (h1 h2)
4997 "Sort threads by root article octet length."
4998 (gnus-article-sort-by-chars
4999 (gnus-thread-header h1) (gnus-thread-header h2)))
5000
5001 (defsubst gnus-article-sort-by-author (h1 h2)
5002 "Sort articles by root author."
5003 (gnus-string<
5004 (let ((extract (funcall
5005 gnus-extract-address-components
5006 (mail-header-from h1))))
5007 (or (car extract) (cadr extract) ""))
5008 (let ((extract (funcall
5009 gnus-extract-address-components
5010 (mail-header-from h2))))
5011 (or (car extract) (cadr extract) ""))))
5012
5013 (defun gnus-thread-sort-by-author (h1 h2)
5014 "Sort threads by root author."
5015 (gnus-article-sort-by-author
5016 (gnus-thread-header h1) (gnus-thread-header h2)))
5017
5018 (defsubst gnus-article-sort-by-recipient (h1 h2)
5019 "Sort articles by recipient."
5020 (gnus-string<
5021 (let ((extract (funcall
5022 gnus-extract-address-components
5023 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5024 (or (car extract) (cadr extract)))
5025 (let ((extract (funcall
5026 gnus-extract-address-components
5027 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5028 (or (car extract) (cadr extract)))))
5029
5030 (defun gnus-thread-sort-by-recipient (h1 h2)
5031 "Sort threads by root recipient."
5032 (gnus-article-sort-by-recipient
5033 (gnus-thread-header h1) (gnus-thread-header h2)))
5034
5035 (defsubst gnus-article-sort-by-subject (h1 h2)
5036 "Sort articles by root subject."
5037 (gnus-string<
5038 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5039 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5040
5041 (defun gnus-thread-sort-by-subject (h1 h2)
5042 "Sort threads by root subject."
5043 (gnus-article-sort-by-subject
5044 (gnus-thread-header h1) (gnus-thread-header h2)))
5045
5046 (defsubst gnus-article-sort-by-date (h1 h2)
5047 "Sort articles by root article date."
5048 (time-less-p
5049 (gnus-date-get-time (mail-header-date h1))
5050 (gnus-date-get-time (mail-header-date h2))))
5051
5052 (defun gnus-thread-sort-by-date (h1 h2)
5053 "Sort threads by root article date."
5054 (gnus-article-sort-by-date
5055 (gnus-thread-header h1) (gnus-thread-header h2)))
5056
5057 (defsubst gnus-article-sort-by-score (h1 h2)
5058 "Sort articles by root article score.
5059 Unscored articles will be counted as having a score of zero."
5060 (> (or (cdr (assq (mail-header-number h1)
5061 gnus-newsgroup-scored))
5062 gnus-summary-default-score 0)
5063 (or (cdr (assq (mail-header-number h2)
5064 gnus-newsgroup-scored))
5065 gnus-summary-default-score 0)))
5066
5067 (defun gnus-thread-sort-by-score (h1 h2)
5068 "Sort threads by root article score."
5069 (gnus-article-sort-by-score
5070 (gnus-thread-header h1) (gnus-thread-header h2)))
5071
5072 (defun gnus-thread-sort-by-total-score (h1 h2)
5073 "Sort threads by the sum of all scores in the thread.
5074 Unscored articles will be counted as having a score of zero."
5075 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5076
5077 (defun gnus-thread-total-score (thread)
5078 ;; This function find the total score of THREAD.
5079 (cond
5080 ((null thread)
5081 0)
5082 ((consp thread)
5083 (if (stringp (car thread))
5084 (apply gnus-thread-score-function 0
5085 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5086 (gnus-thread-total-score-1 thread)))
5087 (t
5088 (gnus-thread-total-score-1 (list thread)))))
5089
5090 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5091 "Sort articles by number."
5092 (gnus-article-sort-by-number h1 h2))
5093
5094 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5095 "Sort threads such that the thread with the most recently arrived article comes first."
5096 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5097
5098 (defun gnus-thread-highest-number (thread)
5099 "Return the highest article number in THREAD."
5100 (apply 'max (mapcar (lambda (header)
5101 (mail-header-number header))
5102 (message-flatten-list thread))))
5103
5104 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5105 "Sort articles by number."
5106 (gnus-article-sort-by-date h1 h2))
5107
5108 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5109 "Sort threads such that the thread with the most recently dated article comes first."
5110 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5111
5112 ; Since this is called not only to sort the top-level threads, but
5113 ; also in recursive sorts to order the articles within a thread, each
5114 ; article will be processed many times. Thus it speeds things up
5115 ; quite a bit to use gnus-date-get-time, which caches the time value.
5116 (defun gnus-thread-latest-date (thread)
5117 "Return the highest article date in THREAD."
5118 (apply 'max
5119 (mapcar (lambda (header) (gnus-float-time
5120 (gnus-date-get-time
5121 (mail-header-date header))))
5122 (message-flatten-list thread))))
5123
5124 (defun gnus-thread-total-score-1 (root)
5125 ;; This function find the total score of the thread below ROOT.
5126 (setq root (car root))
5127 (apply gnus-thread-score-function
5128 (or (append
5129 (mapcar 'gnus-thread-total-score
5130 (cdr (gnus-id-to-thread (mail-header-id root))))
5131 (when (> (mail-header-number root) 0)
5132 (list (or (cdr (assq (mail-header-number root)
5133 gnus-newsgroup-scored))
5134 gnus-summary-default-score 0))))
5135 (list gnus-summary-default-score)
5136 '(0))))
5137
5138 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5139 (defvar gnus-tmp-prev-subject nil)
5140 (defvar gnus-tmp-false-parent nil)
5141 (defvar gnus-tmp-root-expunged nil)
5142 (defvar gnus-tmp-dummy-line nil)
5143
5144 (defun gnus-extra-header (type &optional header)
5145 "Return the extra header of TYPE."
5146 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5147 ""))
5148
5149 (defvar gnus-tmp-thread-tree-header-string "")
5150
5151 (defcustom gnus-sum-thread-tree-root "> "
5152 "With %B spec, used for the root of a thread.
5153 If nil, use subject instead."
5154 :version "22.1"
5155 :type '(radio (const :format "%v " nil) string)
5156 :group 'gnus-thread)
5157
5158 (defcustom gnus-sum-thread-tree-false-root "> "
5159 "With %B spec, used for a false root of a thread.
5160 If nil, use subject instead."
5161 :version "22.1"
5162 :type '(radio (const :format "%v " nil) string)
5163 :group 'gnus-thread)
5164
5165 (defcustom gnus-sum-thread-tree-single-indent ""
5166 "With %B spec, used for a thread with just one message.
5167 If nil, use subject instead."
5168 :version "22.1"
5169 :type '(radio (const :format "%v " nil) string)
5170 :group 'gnus-thread)
5171
5172 (defcustom gnus-sum-thread-tree-vertical "| "
5173 "With %B spec, used for drawing a vertical line."
5174 :version "22.1"
5175 :type 'string
5176 :group 'gnus-thread)
5177
5178 (defcustom gnus-sum-thread-tree-indent " "
5179 "With %B spec, used for indenting."
5180 :version "22.1"
5181 :type 'string
5182 :group 'gnus-thread)
5183
5184 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5185 "With %B spec, used for a leaf with brothers."
5186 :version "22.1"
5187 :type 'string
5188 :group 'gnus-thread)
5189
5190 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5191 "With %B spec, used for a leaf without brothers."
5192 :version "22.1"
5193 :type 'string
5194 :group 'gnus-thread)
5195
5196 (defcustom gnus-summary-display-while-building nil
5197 "If non-nil, show and update the summary buffer as it's being built.
5198 If the value is t, update the buffer after every line is inserted. If
5199 the value is an integer (N), update the display every N lines."
5200 :version "22.1"
5201 :group 'gnus-thread
5202 :type '(choice (const :tag "off" nil)
5203 number
5204 (const :tag "frequently" t)))
5205
5206 (defun gnus-summary-prepare-threads (threads)
5207 "Prepare summary buffer from THREADS and indentation LEVEL.
5208 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5209 or a straight list of headers."
5210 (gnus-message 7 "Generating summary...")
5211
5212 (setq gnus-newsgroup-threads threads)
5213 (beginning-of-line)
5214
5215 (let ((gnus-tmp-level 0)
5216 (default-score (or gnus-summary-default-score 0))
5217 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5218 (building-line-count gnus-summary-display-while-building)
5219 (building-count (integerp gnus-summary-display-while-building))
5220 thread number subject stack state gnus-tmp-gathered beg-match
5221 new-roots gnus-tmp-new-adopts thread-end simp-subject
5222 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5223 gnus-tmp-replied gnus-tmp-subject-or-nil
5224 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5225 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5226 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5227 tree-stack)
5228
5229 (setq gnus-tmp-prev-subject nil
5230 gnus-tmp-thread-tree-header-string "")
5231
5232 (if (vectorp (car threads))
5233 ;; If this is a straight (sic) list of headers, then a
5234 ;; threaded summary display isn't required, so we just create
5235 ;; an unthreaded one.
5236 (gnus-summary-prepare-unthreaded threads)
5237
5238 ;; Do the threaded display.
5239
5240 (if gnus-summary-display-while-building
5241 (switch-to-buffer (buffer-name)))
5242 (while (or threads stack gnus-tmp-new-adopts new-roots)
5243
5244 (if (and (= gnus-tmp-level 0)
5245 (or (not stack)
5246 (= (caar stack) 0))
5247 (not gnus-tmp-false-parent)
5248 (or gnus-tmp-new-adopts new-roots))
5249 (if gnus-tmp-new-adopts
5250 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5251 thread (list (car gnus-tmp-new-adopts))
5252 gnus-tmp-header (caar thread)
5253 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5254 (when new-roots
5255 (setq thread (list (car new-roots))
5256 gnus-tmp-header (caar thread)
5257 new-roots (cdr new-roots))))
5258
5259 (if threads
5260 ;; If there are some threads, we do them before the
5261 ;; threads on the stack.
5262 (setq thread threads
5263 gnus-tmp-header (caar thread))
5264 ;; There were no current threads, so we pop something off
5265 ;; the stack.
5266 (setq state (car stack)
5267 gnus-tmp-level (car state)
5268 tree-stack (cadr state)
5269 thread (caddr state)
5270 stack (cdr stack)
5271 gnus-tmp-header (caar thread))))
5272
5273 (setq gnus-tmp-false-parent nil)
5274 (setq gnus-tmp-root-expunged nil)
5275 (setq thread-end nil)
5276
5277 (if (stringp gnus-tmp-header)
5278 ;; The header is a dummy root.
5279 (cond
5280 ((eq gnus-summary-make-false-root 'adopt)
5281 ;; We let the first article adopt the rest.
5282 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5283 (cddar thread)))
5284 (setq gnus-tmp-gathered
5285 (nconc (mapcar
5286 (lambda (h) (mail-header-number (car h)))
5287 (cddar thread))
5288 gnus-tmp-gathered))
5289 (setq thread (cons (list (caar thread)
5290 (cadar thread))
5291 (cdr thread)))
5292 (setq gnus-tmp-level -1
5293 gnus-tmp-false-parent t))
5294 ((eq gnus-summary-make-false-root 'empty)
5295 ;; We print adopted articles with empty subject fields.
5296 (setq gnus-tmp-gathered
5297 (nconc (mapcar
5298 (lambda (h) (mail-header-number (car h)))
5299 (cddar thread))
5300 gnus-tmp-gathered))
5301 (setq gnus-tmp-level -1))
5302 ((eq gnus-summary-make-false-root 'dummy)
5303 ;; We remember that we probably want to output a dummy
5304 ;; root.
5305 (setq gnus-tmp-dummy-line gnus-tmp-header)
5306 (setq gnus-tmp-prev-subject gnus-tmp-header))
5307 (t
5308 ;; We do not make a root for the gathered
5309 ;; sub-threads at all.
5310 (setq gnus-tmp-level -1)))
5311
5312 (setq number (mail-header-number gnus-tmp-header)
5313 subject (mail-header-subject gnus-tmp-header)
5314 simp-subject (gnus-simplify-subject-fully subject))
5315
5316 (cond
5317 ;; If the thread has changed subject, we might want to make
5318 ;; this subthread into a root.
5319 ((and (null gnus-thread-ignore-subject)
5320 (not (zerop gnus-tmp-level))
5321 gnus-tmp-prev-subject
5322 (not (string= gnus-tmp-prev-subject simp-subject)))
5323 (setq new-roots (nconc new-roots (list (car thread)))
5324 thread-end t
5325 gnus-tmp-header nil))
5326 ;; If the article lies outside the current limit,
5327 ;; then we do not display it.
5328 ((not (memq number gnus-newsgroup-limit))
5329 (setq gnus-tmp-gathered
5330 (nconc (mapcar
5331 (lambda (h) (mail-header-number (car h)))
5332 (cdar thread))
5333 gnus-tmp-gathered))
5334 (setq gnus-tmp-new-adopts (if (cdar thread)
5335 (append gnus-tmp-new-adopts
5336 (cdar thread))
5337 gnus-tmp-new-adopts)
5338 thread-end t
5339 gnus-tmp-header nil)
5340 (when (zerop gnus-tmp-level)
5341 (setq gnus-tmp-root-expunged t)))
5342 ;; Perhaps this article is to be marked as read?
5343 ((and gnus-summary-mark-below
5344 (< (or (cdr (assq number gnus-newsgroup-scored))
5345 default-score)
5346 gnus-summary-mark-below)
5347 ;; Don't touch sparse articles.
5348 (not (gnus-summary-article-sparse-p number))
5349 (not (gnus-summary-article-ancient-p number)))
5350 (setq gnus-newsgroup-unreads
5351 (delq number gnus-newsgroup-unreads))
5352 (if gnus-newsgroup-auto-expire
5353 (setq gnus-newsgroup-expirable
5354 (gnus-add-to-sorted-list
5355 gnus-newsgroup-expirable number))
5356 (push (cons number gnus-low-score-mark)
5357 gnus-newsgroup-reads))))
5358
5359 (when gnus-tmp-header
5360 ;; We may have an old dummy line to output before this
5361 ;; article.
5362 (when (and gnus-tmp-dummy-line
5363 (gnus-subject-equal
5364 gnus-tmp-dummy-line
5365 (mail-header-subject gnus-tmp-header)))
5366 (gnus-summary-insert-dummy-line
5367 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5368 (setq gnus-tmp-dummy-line nil))
5369
5370 ;; Compute the mark.
5371 (setq gnus-tmp-unread (gnus-article-mark number))
5372
5373 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5374 gnus-tmp-header gnus-tmp-level)
5375 gnus-newsgroup-data)
5376
5377 ;; Actually insert the line.
5378 (setq
5379 gnus-tmp-subject-or-nil
5380 (cond
5381 ((and gnus-thread-ignore-subject
5382 gnus-tmp-prev-subject
5383 (not (string= gnus-tmp-prev-subject simp-subject)))
5384 subject)
5385 ((zerop gnus-tmp-level)
5386 (if (and (eq gnus-summary-make-false-root 'empty)
5387 (memq number gnus-tmp-gathered)
5388 gnus-tmp-prev-subject
5389 (string= gnus-tmp-prev-subject simp-subject))
5390 gnus-summary-same-subject
5391 subject))
5392 (t gnus-summary-same-subject)))
5393 (if (and (eq gnus-summary-make-false-root 'adopt)
5394 (= gnus-tmp-level 1)
5395 (memq number gnus-tmp-gathered))
5396 (setq gnus-tmp-opening-bracket ?\<
5397 gnus-tmp-closing-bracket ?\>)
5398 (setq gnus-tmp-opening-bracket ?\[
5399 gnus-tmp-closing-bracket ?\]))
5400 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5401 (gnus-make-thread-indent-array
5402 (max (* 2 (length gnus-thread-indent-array))
5403 gnus-tmp-level)))
5404 (setq
5405 gnus-tmp-indentation
5406 (aref gnus-thread-indent-array gnus-tmp-level)
5407 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5408 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5409 gnus-summary-default-score 0)
5410 gnus-tmp-score-char
5411 (if (or (null gnus-summary-default-score)
5412 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5413 gnus-summary-zcore-fuzz))
5414 ? ;Whitespace
5415 (if (< gnus-tmp-score gnus-summary-default-score)
5416 gnus-score-below-mark gnus-score-over-mark))
5417 gnus-tmp-replied
5418 (cond ((memq number gnus-newsgroup-processable)
5419 gnus-process-mark)
5420 ((memq number gnus-newsgroup-cached)
5421 gnus-cached-mark)
5422 ((memq number gnus-newsgroup-replied)
5423 gnus-replied-mark)
5424 ((memq number gnus-newsgroup-forwarded)
5425 gnus-forwarded-mark)
5426 ((memq number gnus-newsgroup-saved)
5427 gnus-saved-mark)
5428 ((memq number gnus-newsgroup-unseen)
5429 gnus-unseen-mark)
5430 (t gnus-no-mark))
5431 gnus-tmp-downloaded
5432 (cond ((memq number gnus-newsgroup-undownloaded)
5433 gnus-undownloaded-mark)
5434 (gnus-newsgroup-agentized
5435 gnus-downloaded-mark)
5436 (t
5437 gnus-no-mark))
5438 gnus-tmp-from (mail-header-from gnus-tmp-header)
5439 gnus-tmp-name
5440 (cond
5441 ((string-match "<[^>]+> *$" gnus-tmp-from)
5442 (setq beg-match (match-beginning 0))
5443 (or (and (string-match "^\".+\"" gnus-tmp-from)
5444 (substring gnus-tmp-from 1 (1- (match-end 0))))
5445 (substring gnus-tmp-from 0 beg-match)))
5446 ((string-match "(.+)" gnus-tmp-from)
5447 (substring gnus-tmp-from
5448 (1+ (match-beginning 0)) (1- (match-end 0))))
5449 (t gnus-tmp-from))
5450
5451 ;; Do the %B string
5452 gnus-tmp-thread-tree-header-string
5453 (cond
5454 ((not gnus-show-threads) "")
5455 ((zerop gnus-tmp-level)
5456 (cond ((cdar thread)
5457 (or gnus-sum-thread-tree-root subject))
5458 (gnus-tmp-new-adopts
5459 (or gnus-sum-thread-tree-false-root subject))
5460 (t
5461 (or gnus-sum-thread-tree-single-indent subject))))
5462 (t
5463 (concat (apply 'concat
5464 (mapcar (lambda (item)
5465 (if (= item 1)
5466 gnus-sum-thread-tree-vertical
5467 gnus-sum-thread-tree-indent))
5468 (cdr (reverse tree-stack))))
5469 (if (nth 1 thread)
5470 gnus-sum-thread-tree-leaf-with-other
5471 gnus-sum-thread-tree-single-leaf)))))
5472 (when (string= gnus-tmp-name "")
5473 (setq gnus-tmp-name gnus-tmp-from))
5474 (unless (numberp gnus-tmp-lines)
5475 (setq gnus-tmp-lines -1))
5476 (if (= gnus-tmp-lines -1)
5477 (setq gnus-tmp-lines "?")
5478 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5479 (gnus-put-text-property
5480 (point)
5481 (progn (eval gnus-summary-line-format-spec) (point))
5482 'gnus-number number)
5483 (when gnus-visual-p
5484 (forward-line -1)
5485 (gnus-summary-highlight-line)
5486 (when gnus-summary-update-hook
5487 (gnus-run-hooks 'gnus-summary-update-hook))
5488 (forward-line 1))
5489
5490 (setq gnus-tmp-prev-subject simp-subject)))
5491
5492 (when (nth 1 thread)
5493 (push (list (max 0 gnus-tmp-level)
5494 (copy-sequence tree-stack)
5495 (nthcdr 1 thread))
5496 stack))
5497 (push (if (nth 1 thread) 1 0) tree-stack)
5498 (incf gnus-tmp-level)
5499 (setq threads (if thread-end nil (cdar thread)))
5500 (if gnus-summary-display-while-building
5501 (if building-count
5502 (progn
5503 ;; use a set frequency
5504 (setq building-line-count (1- building-line-count))
5505 (when (= building-line-count 0)
5506 (sit-for 0)
5507 (setq building-line-count
5508 gnus-summary-display-while-building)))
5509 ;; always
5510 (sit-for 0)))
5511 (unless threads
5512 (setq gnus-tmp-level 0)))))
5513 (gnus-message 7 "Generating summary...done"))
5514
5515 (defun gnus-summary-prepare-unthreaded (headers)
5516 "Generate an unthreaded summary buffer based on HEADERS."
5517 (let (header number mark)
5518
5519 (beginning-of-line)
5520
5521 (while headers
5522 ;; We may have to root out some bad articles...
5523 (when (memq (setq number (mail-header-number
5524 (setq header (pop headers))))
5525 gnus-newsgroup-limit)
5526 ;; Mark article as read when it has a low score.
5527 (when (and gnus-summary-mark-below
5528 (< (or (cdr (assq number gnus-newsgroup-scored))
5529 gnus-summary-default-score 0)
5530 gnus-summary-mark-below)
5531 (not (gnus-summary-article-ancient-p number)))
5532 (setq gnus-newsgroup-unreads
5533 (delq number gnus-newsgroup-unreads))
5534 (if gnus-newsgroup-auto-expire
5535 (push number gnus-newsgroup-expirable)
5536 (push (cons number gnus-low-score-mark)
5537 gnus-newsgroup-reads)))
5538
5539 (setq mark (gnus-article-mark number))
5540 (push (gnus-data-make number mark (1+ (point)) header 0)
5541 gnus-newsgroup-data)
5542 (gnus-summary-insert-line
5543 header 0 number
5544 (memq number gnus-newsgroup-undownloaded)
5545 mark (memq number gnus-newsgroup-replied)
5546 (memq number gnus-newsgroup-expirable)
5547 (mail-header-subject header) nil
5548 (cdr (assq number gnus-newsgroup-scored))
5549 (memq number gnus-newsgroup-processable))))))
5550
5551 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5552
5553 (defun gnus-group-get-list-identifiers (group)
5554 "Get list identifier regexp for GROUP."
5555 (or (gnus-parameter-list-identifier group)
5556 (if (consp gnus-list-identifiers)
5557 (mapconcat 'identity gnus-list-identifiers " *\\|")
5558 gnus-list-identifiers)))
5559
5560 (defun gnus-summary-remove-list-identifiers ()
5561 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5562 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5563 changed subject)
5564 (when regexp
5565 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5566 (dolist (header gnus-newsgroup-headers)
5567 (setq subject (mail-header-subject header)
5568 changed nil)
5569 (while (string-match regexp subject)
5570 (setq subject
5571 (concat (substring subject 0 (match-beginning 1))
5572 (substring subject (match-end 0)))
5573 changed t))
5574 (when changed
5575 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5576 (setq subject
5577 (concat (substring subject 0 (match-beginning 1))
5578 (substring subject (match-end 1)))))
5579 (mail-header-set-subject header subject))))))
5580
5581 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5582 "Fetch headers of ARTICLES."
5583 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5584 (gnus-message 7 "Fetching headers for %s..." name)
5585 (prog1
5586 (if (eq 'nov
5587 (setq gnus-headers-retrieved-by
5588 (gnus-retrieve-headers
5589 articles gnus-newsgroup-name
5590 (or limit
5591 ;; We might want to fetch old headers, but
5592 ;; not if there is only 1 article.
5593 (and (or (and
5594 (not (eq gnus-fetch-old-headers 'some))
5595 (not (numberp gnus-fetch-old-headers)))
5596 (> (length articles) 1))
5597 gnus-fetch-old-headers)))))
5598 (gnus-get-newsgroup-headers-xover
5599 articles force-new dependencies gnus-newsgroup-name t)
5600 (gnus-get-newsgroup-headers dependencies force-new))
5601 (gnus-message 7 "Fetching headers for %s...done" name))))
5602
5603 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5604 "Select newsgroup GROUP.
5605 If READ-ALL is non-nil, all articles in the group are selected.
5606 If SELECT-ARTICLES, only select those articles from GROUP."
5607 (let* ((entry (gnus-group-entry group))
5608 ;;!!! Dirty hack; should be removed.
5609 (gnus-summary-ignore-duplicates
5610 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5611 t
5612 gnus-summary-ignore-duplicates))
5613 (info (nth 2 entry))
5614 charset articles fetched-articles cached)
5615
5616 (unless (gnus-check-server
5617 (set (make-local-variable 'gnus-current-select-method)
5618 (gnus-find-method-for-group group)))
5619 (error "Couldn't open server"))
5620 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5621
5622 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5623 (gnus-activate-group group) ; Or we can activate it...
5624 (progn ; Or we bug out.
5625 (when (derived-mode-p 'gnus-summary-mode)
5626 (gnus-kill-buffer (current-buffer)))
5627 (error
5628 "Couldn't activate group %s: %s"
5629 (mm-decode-coding-string group charset)
5630 (mm-decode-coding-string (gnus-status-message group) charset))))
5631
5632 (unless (gnus-request-group group t nil (gnus-get-info group))
5633 (when (derived-mode-p 'gnus-summary-mode)
5634 (gnus-kill-buffer (current-buffer)))
5635 (error "Couldn't request group %s: %s"
5636 (mm-decode-coding-string group charset)
5637 (mm-decode-coding-string (gnus-status-message group) charset)))
5638
5639 (when (and gnus-agent
5640 (gnus-active group))
5641 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5642
5643 (setq gnus-summary-use-undownloaded-faces
5644 (gnus-agent-find-parameter
5645 group
5646 'agent-enable-undownloaded-faces)))
5647
5648 (setq gnus-newsgroup-name group
5649 gnus-newsgroup-unselected nil
5650 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5651
5652 (let ((display (gnus-group-find-parameter group 'display)))
5653 (setq gnus-newsgroup-display
5654 (cond
5655 ((not (zerop (or (car-safe read-all) 0)))
5656 ;; The user entered the group with C-u SPC/RET, let's show
5657 ;; all articles.
5658 'gnus-not-ignore)
5659 ((eq display 'all)
5660 'gnus-not-ignore)
5661 ((arrayp display)
5662 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5663 ((numberp display)
5664 ;; The following is probably the "correct" solution, but
5665 ;; it makes Gnus fetch all headers and then limit the
5666 ;; articles (which is slow), so instead we hack the
5667 ;; select-articles parameter instead. -- Simon Josefsson
5668 ;; <jas@kth.se>
5669 ;;
5670 ;; (gnus-byte-compile
5671 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5672 ;; display)))))
5673 (setq select-articles
5674 (gnus-uncompress-range
5675 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5676 (if (> tmp 0)
5677 tmp
5678 1))
5679 (cdr (gnus-active group)))))
5680 nil)
5681 (t
5682 nil))))
5683
5684 (gnus-summary-setup-default-charset)
5685
5686 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5687 (when (gnus-virtual-group-p group)
5688 (setq cached gnus-newsgroup-cached))
5689
5690 (setq gnus-newsgroup-unreads
5691 (gnus-sorted-ndifference
5692 (gnus-sorted-ndifference gnus-newsgroup-unreads
5693 gnus-newsgroup-marked)
5694 gnus-newsgroup-dormant))
5695
5696 (setq gnus-newsgroup-processable nil)
5697
5698 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5699
5700 ;; Adjust and set lists of article marks.
5701 (when info
5702 (gnus-adjust-marked-articles info))
5703 (if (setq articles select-articles)
5704 (setq gnus-newsgroup-unselected
5705 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5706 (setq articles (gnus-articles-to-read group read-all)))
5707
5708 (cond
5709 ((null articles)
5710 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5711 'quit)
5712 ((eq articles 0) nil)
5713 (t
5714 ;; Init the dependencies hash table.
5715 (setq gnus-newsgroup-dependencies
5716 (gnus-make-hashtable (length articles)))
5717 (if (gnus-buffer-live-p gnus-group-buffer)
5718 (gnus-set-global-variables)
5719 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5720 ;; Retrieve the headers and read them in.
5721
5722 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5723
5724 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5725 (when cached
5726 (setq gnus-newsgroup-cached cached))
5727
5728 ;; Suppress duplicates?
5729 (when gnus-suppress-duplicates
5730 (gnus-dup-suppress-articles))
5731
5732 ;; Set the initial limit.
5733 (setq gnus-newsgroup-limit (copy-sequence articles))
5734 ;; Remove canceled articles from the list of unread articles.
5735 (setq fetched-articles
5736 (mapcar (lambda (headers) (mail-header-number headers))
5737 gnus-newsgroup-headers))
5738 (setq gnus-newsgroup-articles fetched-articles)
5739 (setq gnus-newsgroup-unreads
5740 (gnus-sorted-nintersection
5741 gnus-newsgroup-unreads fetched-articles))
5742 (gnus-compute-unseen-list)
5743
5744 ;; Removed marked articles that do not exist.
5745 (gnus-update-missing-marks
5746 (gnus-sorted-difference articles fetched-articles))
5747 ;; We might want to build some more threads first.
5748 (when (and gnus-fetch-old-headers
5749 (eq gnus-headers-retrieved-by 'nov))
5750 (if (eq gnus-fetch-old-headers 'invisible)
5751 (gnus-build-all-threads)
5752 (gnus-build-old-threads)))
5753 ;; Let the Gnus agent mark articles as read.
5754 (when gnus-agent
5755 (gnus-agent-get-undownloaded-list))
5756 ;; Remove list identifiers from subject
5757 (gnus-summary-remove-list-identifiers)
5758 ;; Check whether auto-expire is to be done in this group.
5759 (setq gnus-newsgroup-auto-expire
5760 (and (gnus-group-auto-expirable-p group)
5761 (not (gnus-group-read-only-p group))))
5762 ;; Set up the article buffer now, if necessary.
5763 (unless (and gnus-single-article-buffer
5764 (equal gnus-article-buffer "*Article*"))
5765 (gnus-article-setup-buffer))
5766 ;; First and last article in this newsgroup.
5767 (when gnus-newsgroup-headers
5768 (setq gnus-newsgroup-begin
5769 (mail-header-number (car gnus-newsgroup-headers))
5770 gnus-newsgroup-end
5771 (mail-header-number
5772 (gnus-last-element gnus-newsgroup-headers))))
5773 ;; GROUP is successfully selected.
5774 (or gnus-newsgroup-headers t)))))
5775
5776 (defun gnus-compute-unseen-list ()
5777 ;; The `seen' marks are treated specially.
5778 (if (not gnus-newsgroup-seen)
5779 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5780 (setq gnus-newsgroup-unseen
5781 (gnus-inverse-list-range-intersection
5782 gnus-newsgroup-articles gnus-newsgroup-seen))))
5783
5784 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5785
5786 (defun gnus-summary-display-make-predicate (display)
5787 (require 'gnus-agent)
5788 (when (= (length display) 1)
5789 (setq display (car display)))
5790 (unless gnus-summary-display-cache
5791 (dolist (elem (append '((unread . unread)
5792 (read . read)
5793 (unseen . unseen))
5794 gnus-article-mark-lists))
5795 (push (cons (cdr elem)
5796 (gnus-byte-compile ;Why bother?
5797 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5798 gnus-summary-display-cache)))
5799 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5800 (gnus-category-predicate-cache gnus-summary-display-cache))
5801 (gnus-get-predicate display)))
5802
5803 ;; Uses the dynamically bound `gnus-number' variable.
5804 (defvar gnus-number)
5805 (defun gnus-article-marked-p (type &optional article)
5806 (let ((article (or article gnus-number)))
5807 (cond
5808 ((eq type 'tick)
5809 (memq article gnus-newsgroup-marked))
5810 ((eq type 'spam)
5811 (memq article gnus-newsgroup-spam-marked))
5812 ((eq type 'unsend)
5813 (memq article gnus-newsgroup-unsendable))
5814 ((eq type 'undownload)
5815 (memq article gnus-newsgroup-undownloaded))
5816 ((eq type 'download)
5817 (memq article gnus-newsgroup-downloadable))
5818 ((eq type 'unread)
5819 (memq article gnus-newsgroup-unreads))
5820 ((eq type 'read)
5821 (memq article gnus-newsgroup-reads))
5822 ((eq type 'dormant)
5823 (memq article gnus-newsgroup-dormant) )
5824 ((eq type 'expire)
5825 (memq article gnus-newsgroup-expirable))
5826 ((eq type 'reply)
5827 (memq article gnus-newsgroup-replied))
5828 ((eq type 'killed)
5829 (memq article gnus-newsgroup-killed))
5830 ((eq type 'bookmark)
5831 (assq article gnus-newsgroup-bookmarks))
5832 ((eq type 'score)
5833 (assq article gnus-newsgroup-scored))
5834 ((eq type 'save)
5835 (memq article gnus-newsgroup-saved))
5836 ((eq type 'cache)
5837 (memq article gnus-newsgroup-cached))
5838 ((eq type 'forward)
5839 (memq article gnus-newsgroup-forwarded))
5840 ((eq type 'seen)
5841 (not (memq article gnus-newsgroup-unseen)))
5842 (t t))))
5843
5844 (defun gnus-articles-to-read (group &optional read-all)
5845 "Find out what articles the user wants to read."
5846 (let* ((only-read-p t)
5847 (articles
5848 (gnus-list-range-difference
5849 ;; Select all articles if `read-all' is non-nil, or if there
5850 ;; are no unread articles.
5851 (if (or read-all
5852 (and (zerop (length gnus-newsgroup-marked))
5853 (zerop (length gnus-newsgroup-unreads)))
5854 ;; Fetch all if the predicate is non-nil.
5855 gnus-newsgroup-display)
5856 ;; We want to select the headers for all the articles in
5857 ;; the group, so we select either all the active
5858 ;; articles in the group, or (if that's nil), the
5859 ;; articles in the cache.
5860 (or
5861 (if gnus-newsgroup-maximum-articles
5862 (let ((active (gnus-active group)))
5863 (gnus-uncompress-range
5864 (cons (max (car active)
5865 (- (cdr active)
5866 gnus-newsgroup-maximum-articles
5867 -1))
5868 (cdr active))))
5869 (gnus-uncompress-range (gnus-active group)))
5870 (gnus-cache-articles-in-group group))
5871 ;; Select only the "normal" subset of articles.
5872 (setq only-read-p nil)
5873 (gnus-sorted-nunion
5874 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5875 gnus-newsgroup-unreads))
5876 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5877 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5878 (scored (length scored-list))
5879 (number (length articles))
5880 (marked (+ (length gnus-newsgroup-marked)
5881 (length gnus-newsgroup-dormant)))
5882 (select
5883 (cond
5884 ((numberp read-all)
5885 read-all)
5886 ((numberp gnus-newsgroup-display)
5887 gnus-newsgroup-display)
5888 (t
5889 (condition-case ()
5890 (cond
5891 ((and (or (<= scored marked) (= scored number))
5892 (numberp gnus-large-newsgroup)
5893 (> number gnus-large-newsgroup))
5894 (let* ((cursor-in-echo-area nil)
5895 (initial (gnus-parameter-large-newsgroup-initial
5896 gnus-newsgroup-name))
5897 (default (if only-read-p
5898 (or initial gnus-large-newsgroup)
5899 number))
5900 (input
5901 (read-string
5902 (if only-read-p
5903 (format
5904 "How many articles from %s (available %d, default %d): "
5905 (gnus-group-real-name
5906 (gnus-group-decoded-name gnus-newsgroup-name))
5907 number default)
5908 (format
5909 "How many articles from %s (%d default): "
5910 (gnus-group-real-name
5911 (gnus-group-decoded-name gnus-newsgroup-name))
5912 default))
5913 nil
5914 nil
5915 (number-to-string default))))
5916 (if (string-match "^[ \t]*$" input) number input)))
5917 ((and (> scored marked) (< scored number)
5918 (> (- scored number) 20))
5919 (let ((input
5920 (read-string
5921 (format "%s %s (%d scored, %d total): "
5922 "How many articles from"
5923 (gnus-group-decoded-name
5924 (gnus-group-real-name gnus-newsgroup-name))
5925 scored number))))
5926 (if (string-match "^[ \t]*$" input)
5927 number input)))
5928 (t number))
5929 (quit
5930 (message "Quit getting the articles to read")
5931 nil))))))
5932 (setq select (if (stringp select) (string-to-number select) select))
5933 (if (or (null select) (zerop select))
5934 select
5935 (if (and (not (zerop scored)) (<= (abs select) scored))
5936 (progn
5937 (setq articles (sort scored-list '<))
5938 (setq number (length articles)))
5939 (setq articles (copy-sequence articles)))
5940
5941 (when (< (abs select) number)
5942 (if (< select 0)
5943 ;; Select the N oldest articles.
5944 (setcdr (nthcdr (1- (abs select)) articles) nil)
5945 ;; Select the N most recent articles.
5946 (setq articles (nthcdr (- number select) articles))))
5947 (setq gnus-newsgroup-unselected
5948 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5949 (when gnus-alter-articles-to-read-function
5950 (setq articles
5951 (sort
5952 (funcall gnus-alter-articles-to-read-function
5953 gnus-newsgroup-name articles)
5954 '<)))
5955 articles)))
5956
5957 (defun gnus-killed-articles (killed articles)
5958 (let (out)
5959 (while articles
5960 (when (inline (gnus-member-of-range (car articles) killed))
5961 (push (car articles) out))
5962 (setq articles (cdr articles)))
5963 out))
5964
5965 (defun gnus-article-mark-to-type (mark)
5966 "Return the type of MARK."
5967 (or (cadr (assq mark gnus-article-special-mark-lists))
5968 'list))
5969
5970 (defun gnus-article-unpropagatable-p (mark)
5971 "Return whether MARK should be propagated to back end."
5972 (memq mark gnus-article-unpropagated-mark-lists))
5973
5974 (defun gnus-adjust-marked-articles (info)
5975 "Set all article lists and remove all marks that are no longer valid."
5976 (let* ((marked-lists (gnus-info-marks info))
5977 (active (gnus-active (gnus-info-group info)))
5978 (min (car active))
5979 (max (cdr active))
5980 (types gnus-article-mark-lists)
5981 marks var articles article mark mark-type
5982 bgn end)
5983 ;; Hack to avoid adjusting marks for imap.
5984 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5985 'nnimap)
5986 (setq min 1))
5987
5988 (dolist (marks marked-lists)
5989 (setq mark (car marks)
5990 mark-type (gnus-article-mark-to-type mark)
5991 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5992 ;; We set the variable according to the type of the marks list,
5993 ;; and then adjust the marks to a subset of the active articles.
5994 (cond
5995 ;; Adjust "simple" lists - compressed yet unsorted
5996 ((eq mark-type 'list)
5997 ;; Simultaneously uncompress and clip to active range
5998 ;; See gnus-uncompress-range for a description of possible marks
5999 (let (l lh)
6000 (if (not (cadr marks))
6001 (set var nil)
6002 (setq articles (if (numberp (cddr marks))
6003 (list (cdr marks))
6004 (cdr marks))
6005 lh (cons nil nil)
6006 l lh)
6007
6008 (while (setq article (pop articles))
6009 (cond ((consp article)
6010 (setq bgn (max (car article) min)
6011 end (min (cdr article) max))
6012 (while (<= bgn end)
6013 (setq l (setcdr l (cons bgn nil))
6014 bgn (1+ bgn))))
6015 ((and (<= min article)
6016 (>= max article))
6017 (setq l (setcdr l (cons article nil))))))
6018 (set var (cdr lh)))))
6019 ;; Adjust assocs.
6020 ((eq mark-type 'tuple)
6021 (set var (setq articles (cdr marks)))
6022 (when (not (listp (cdr (symbol-value var))))
6023 (set var (list (symbol-value var))))
6024 (when (not (listp (cdr articles)))
6025 (setq articles (list articles)))
6026 (while articles
6027 (when (or (not (consp (setq article (pop articles))))
6028 (< (car article) min)
6029 (> (car article) max))
6030 (set var (delq article (symbol-value var))))))
6031 ;; Adjust ranges (sloppily).
6032 ((eq mark-type 'range)
6033 (cond
6034 ((eq mark 'seen)
6035 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6036 ;; It should be (seen (NUM1 . NUM2)).
6037 (when (numberp (cddr marks))
6038 (setcdr marks (list (cdr marks))))
6039 (setq articles (cdr marks))
6040 (while (and articles
6041 (or (and (consp (car articles))
6042 (> min (cdar articles)))
6043 (and (numberp (car articles))
6044 (> min (car articles)))))
6045 (pop articles))
6046 (set var articles))
6047 ((eq mark 'unexist)
6048 (set var (cdr marks)))))))))
6049
6050 (defun gnus-update-missing-marks (missing)
6051 "Go through the list of MISSING articles and remove them from the mark lists."
6052 (when missing
6053 (let (var m)
6054 ;; Go through all types.
6055 (dolist (elem gnus-article-mark-lists)
6056 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6057 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6058 (when (symbol-value var)
6059 ;; This list has articles. So we delete all missing
6060 ;; articles from it.
6061 (setq m missing)
6062 (while m
6063 (set var (delq (pop m) (symbol-value var))))))))))
6064
6065 (defun gnus-update-marks ()
6066 "Enter the various lists of marked articles into the newsgroup info list."
6067 (let ((types gnus-article-mark-lists)
6068 (info (gnus-get-info gnus-newsgroup-name))
6069 type list newmarked symbol delta-marks)
6070 (when info
6071 ;; Add all marks lists to the list of marks lists.
6072 (while (setq type (pop types))
6073 (setq list (symbol-value
6074 (setq symbol
6075 (intern (format "gnus-newsgroup-%s" (car type))))))
6076
6077 (when list
6078 ;; Get rid of the entries of the articles that have the
6079 ;; default score.
6080 (when (and (eq (cdr type) 'score)
6081 gnus-save-score
6082 list)
6083 (let* ((arts list)
6084 (prev (cons nil list))
6085 (all prev))
6086 (while arts
6087 (if (or (not (consp (car arts)))
6088 (= (cdar arts) gnus-summary-default-score))
6089 (setcdr prev (cdr arts))
6090 (setq prev arts))
6091 (setq arts (cdr arts)))
6092 (setq list (cdr all)))))
6093
6094 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6095 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6096
6097 (when (and (gnus-check-backend-function
6098 'request-set-mark gnus-newsgroup-name)
6099 (not (gnus-article-unpropagatable-p (cdr type))))
6100 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6101 ;; Don't do anything about marks for articles we
6102 ;; didn't actually get any headers for.
6103 (del
6104 (gnus-list-range-intersection
6105 gnus-newsgroup-articles
6106 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6107 (add
6108 (gnus-list-range-intersection
6109 gnus-newsgroup-articles
6110 (gnus-remove-from-range
6111 (gnus-copy-sequence list) old))))
6112 (when add
6113 (push (list add 'add (list (cdr type))) delta-marks))
6114 (when del
6115 ;; Don't delete marks from outside the active range.
6116 ;; This shouldn't happen, but is a sanity check.
6117 (setq del (gnus-sorted-range-intersection
6118 (gnus-active gnus-newsgroup-name) del))
6119 (push (list del 'del (list (cdr type))) delta-marks))))
6120
6121 (when (or list
6122 (eq (cdr type) 'unexist))
6123 (push (cons (cdr type) list) newmarked)))
6124
6125 (when delta-marks
6126 (unless (gnus-check-group gnus-newsgroup-name)
6127 (error "Can't open server for %s" gnus-newsgroup-name))
6128 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6129
6130 ;; Enter these new marks into the info of the group.
6131 (if (nthcdr 3 info)
6132 (setcar (nthcdr 3 info) newmarked)
6133 ;; Add the marks lists to the end of the info.
6134 (when newmarked
6135 (setcdr (nthcdr 2 info) (list newmarked))))
6136
6137 ;; Cut off the end of the info if there's nothing else there.
6138 (let ((i 5))
6139 (while (and (> i 2)
6140 (not (nth i info)))
6141 (when (nthcdr (decf i) info)
6142 (setcdr (nthcdr i info) nil)))))))
6143
6144 (defun gnus-set-mode-line (where)
6145 "Set the mode line of the article or summary buffers.
6146 If WHERE is `summary', the summary mode line format will be used."
6147 ;; Is this mode line one we keep updated?
6148 (when (and (memq where gnus-updated-mode-lines)
6149 (symbol-value
6150 (intern (format "gnus-%s-mode-line-format-spec" where))))
6151 (let (mode-string)
6152 ;; We evaluate this in the summary buffer since these
6153 ;; variables are buffer-local to that buffer.
6154 (with-current-buffer gnus-summary-buffer
6155 ;; We bind all these variables that are used in the `eval' form
6156 ;; below.
6157 (let* ((mformat (symbol-value
6158 (intern
6159 (format "gnus-%s-mode-line-format-spec" where))))
6160 (gnus-tmp-group-name (gnus-mode-string-quote
6161 (gnus-group-decoded-name
6162 gnus-newsgroup-name)))
6163 (gnus-tmp-article-number (or gnus-current-article 0))
6164 (gnus-tmp-unread gnus-newsgroup-unreads)
6165 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6166 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6167 (gnus-tmp-unread-and-unselected
6168 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6169 (zerop gnus-tmp-unselected))
6170 "")
6171 ((zerop gnus-tmp-unselected)
6172 (format "{%d more}" gnus-tmp-unread-and-unticked))
6173 (t (format "{%d(+%d) more}"
6174 gnus-tmp-unread-and-unticked
6175 gnus-tmp-unselected))))
6176 (gnus-tmp-subject
6177 (if (and gnus-current-headers
6178 (vectorp gnus-current-headers))
6179 (gnus-mode-string-quote
6180 (mail-header-subject gnus-current-headers))
6181 ""))
6182 bufname-length max-len
6183 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6184 (setq mode-string (eval mformat))
6185 (setq bufname-length (if (string-match "%b" mode-string)
6186 (- (length
6187 (buffer-name
6188 (if (eq where 'summary)
6189 nil
6190 (get-buffer gnus-article-buffer))))
6191 2)
6192 0))
6193 (setq max-len (max 4 (if gnus-mode-non-string-length
6194 (- (window-width)
6195 gnus-mode-non-string-length
6196 bufname-length)
6197 (length mode-string))))
6198 ;; We might have to chop a bit of the string off...
6199 (when (> (length mode-string) max-len)
6200 (setq mode-string
6201 (concat (truncate-string-to-width mode-string (- max-len 3))
6202 "...")))))
6203 ;; Update the mode line.
6204 (setq mode-line-buffer-identification
6205 (gnus-mode-line-buffer-identification (list mode-string)))
6206 (set-buffer-modified-p t))))
6207
6208 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6209 "Go through the HEADERS list and add all Xrefs to a hash table.
6210 The resulting hash table is returned, or nil if no Xrefs were found."
6211 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6212 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6213 (xref-hashtb (gnus-make-hashtable))
6214 start group entry number xrefs header)
6215 (while headers
6216 (setq header (pop headers))
6217 (when (and (setq xrefs (mail-header-xref header))
6218 (not (memq (setq number (mail-header-number header))
6219 unreads)))
6220 (setq start 0)
6221 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6222 (setq start (match-end 0))
6223 (setq group (if prefix
6224 (concat prefix (substring xrefs (match-beginning 1)
6225 (match-end 1)))
6226 (substring xrefs (match-beginning 1) (match-end 1))))
6227 (setq number
6228 (string-to-number (substring xrefs (match-beginning 2)
6229 (match-end 2))))
6230 (if (setq entry (gnus-gethash group xref-hashtb))
6231 (setcdr entry (cons number (cdr entry)))
6232 (gnus-sethash group (cons number nil) xref-hashtb)))))
6233 (and start xref-hashtb)))
6234
6235 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6236 "Look through all the headers and mark the Xrefs as read."
6237 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6238 name info xref-hashtb idlist method nth4)
6239 (with-current-buffer gnus-group-buffer
6240 (when (setq xref-hashtb
6241 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6242 (mapatoms
6243 (lambda (group)
6244 (unless (string= from-newsgroup (setq name (symbol-name group)))
6245 (setq idlist (symbol-value group))
6246 ;; Dead groups are not updated.
6247 (and (prog1
6248 (setq info (gnus-get-info name))
6249 (when (stringp (setq nth4 (gnus-info-method info)))
6250 (setq nth4 (gnus-server-to-method nth4))))
6251 ;; Only do the xrefs if the group has the same
6252 ;; select method as the group we have just read.
6253 (or (gnus-methods-equal-p
6254 nth4 (gnus-find-method-for-group from-newsgroup))
6255 virtual
6256 (equal nth4 (setq method (gnus-find-method-for-group
6257 from-newsgroup)))
6258 (and (equal (car nth4) (car method))
6259 (equal (nth 1 nth4) (nth 1 method))))
6260 gnus-use-cross-reference
6261 (or (not (eq gnus-use-cross-reference t))
6262 virtual
6263 ;; Only do cross-references on subscribed
6264 ;; groups, if that is what is wanted.
6265 (<= (gnus-info-level info) gnus-level-subscribed))
6266 (gnus-group-make-articles-read name idlist))))
6267 xref-hashtb)))))
6268
6269 (defun gnus-compute-read-articles (group articles)
6270 (let* ((entry (gnus-group-entry group))
6271 (info (nth 2 entry))
6272 (active (gnus-active group))
6273 ninfo)
6274 (when entry
6275 ;; First peel off all invalid article numbers.
6276 (when active
6277 (let ((ids articles)
6278 id first)
6279 (while (setq id (pop ids))
6280 (when (and first (> id (cdr active)))
6281 ;; We'll end up in this situation in one particular
6282 ;; obscure situation. If you re-scan a group and get
6283 ;; a new article that is cross-posted to a different
6284 ;; group that has not been re-scanned, you might get
6285 ;; crossposted article that has a higher number than
6286 ;; Gnus believes possible. So we re-activate this
6287 ;; group as well. This might mean doing the
6288 ;; crossposting thingy will *increase* the number
6289 ;; of articles in some groups. Tsk, tsk.
6290 (setq active (or (gnus-activate-group group) active)))
6291 (when (or (> id (cdr active))
6292 (< id (car active)))
6293 (setq articles (delq id articles))))))
6294 ;; If the read list is nil, we init it.
6295 (if (and active
6296 (null (gnus-info-read info))
6297 (> (car active) 1))
6298 (setq ninfo (cons 1 (1- (car active))))
6299 (setq ninfo (gnus-info-read info)))
6300 ;; Then we add the read articles to the range.
6301 (gnus-add-to-range
6302 ninfo (setq articles (sort articles '<))))))
6303
6304 (defun gnus-group-make-articles-read (group articles)
6305 "Update the info of GROUP to say that ARTICLES are read."
6306 (let* ((num 0)
6307 (entry (gnus-group-entry group))
6308 (info (nth 2 entry))
6309 (active (gnus-active group))
6310 (set-marks
6311 (gnus-method-option-p
6312 (gnus-find-method-for-group group)
6313 'server-marks))
6314 range)
6315 (if (not entry)
6316 ;; Group that Gnus doesn't know exists, but still allow the
6317 ;; backend to set marks.
6318 (when set-marks
6319 (gnus-request-set-mark
6320 group (list (list (gnus-compress-sequence (sort articles #'<))
6321 'add '(read)))))
6322 ;; Normal, subscribed groups.
6323 (setq range (gnus-compute-read-articles group articles))
6324 (with-current-buffer gnus-group-buffer
6325 (gnus-undo-register
6326 `(progn
6327 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6328 (gnus-info-set-read ',info ',(gnus-info-read info))
6329 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6330 (when ,set-marks
6331 (gnus-request-set-mark
6332 ,group (list (list ',range 'del '(read)))))
6333 (gnus-group-update-group ,group t))))
6334 ;; Add the read articles to the range.
6335 (gnus-info-set-read info range)
6336 (when set-marks
6337 (gnus-request-set-mark group (list (list range 'add '(read)))))
6338 ;; Then we have to re-compute how many unread
6339 ;; articles there are in this group.
6340 (when active
6341 (cond
6342 ((not range)
6343 (setq num (- (1+ (cdr active)) (car active))))
6344 ((not (listp (cdr range)))
6345 (setq num (- (cdr active) (- (1+ (cdr range))
6346 (car range)))))
6347 (t
6348 (while range
6349 (if (numberp (car range))
6350 (setq num (1+ num))
6351 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6352 (setq range (cdr range)))
6353 (setq num (- (cdr active) num))))
6354 ;; Update the number of unread articles.
6355 (setcar entry num)
6356 ;; Update the group buffer.
6357 (unless (gnus-ephemeral-group-p group)
6358 (gnus-group-update-group group t))))))
6359
6360 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6361 (let ((cur nntp-server-buffer)
6362 (dependencies
6363 (or dependencies
6364 (with-current-buffer gnus-summary-buffer
6365 gnus-newsgroup-dependencies)))
6366 headers id end ref number
6367 (mail-parse-charset gnus-newsgroup-charset)
6368 (mail-parse-ignored-charsets
6369 (save-current-buffer (condition-case nil
6370 (set-buffer gnus-summary-buffer)
6371 (error))
6372 gnus-newsgroup-ignored-charsets)))
6373 (with-current-buffer nntp-server-buffer
6374 ;; Translate all TAB characters into SPACE characters.
6375 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6376 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6377 (ietf-drums-unfold-fws)
6378 (gnus-run-hooks 'gnus-parse-headers-hook)
6379 (let ((case-fold-search t)
6380 in-reply-to header p lines chars)
6381 (goto-char (point-min))
6382 ;; Search to the beginning of the next header. Error messages
6383 ;; do not begin with 2 or 3.
6384 (while (re-search-forward "^[23][0-9]+ " nil t)
6385 (setq id nil
6386 ref nil)
6387 ;; This implementation of this function, with nine
6388 ;; search-forwards instead of the one re-search-forward and
6389 ;; a case (which basically was the old function) is actually
6390 ;; about twice as fast, even though it looks messier. You
6391 ;; can't have everything, I guess. Speed and elegance
6392 ;; doesn't always go hand in hand.
6393 (setq
6394 header
6395 (vector
6396 ;; Number.
6397 (prog1
6398 (setq number (read cur))
6399 (end-of-line)
6400 (setq p (point))
6401 (narrow-to-region (point)
6402 (or (and (search-forward "\n.\n" nil t)
6403 (- (point) 2))
6404 (point))))
6405 ;; Subject.
6406 (progn
6407 (goto-char p)
6408 (if (search-forward "\nsubject:" nil t)
6409 (funcall gnus-decode-encoded-word-function
6410 (nnheader-header-value))
6411 "(none)"))
6412 ;; From.
6413 (progn
6414 (goto-char p)
6415 (if (search-forward "\nfrom:" nil t)
6416 (funcall gnus-decode-encoded-address-function
6417 (nnheader-header-value))
6418 "(nobody)"))
6419 ;; Date.
6420 (progn
6421 (goto-char p)
6422 (if (search-forward "\ndate:" nil t)
6423 (nnheader-header-value) ""))
6424 ;; Message-ID.
6425 (progn
6426 (goto-char p)
6427 (setq id (if (re-search-forward
6428 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6429 ;; We do it this way to make sure the Message-ID
6430 ;; is (somewhat) syntactically valid.
6431 (buffer-substring (match-beginning 1)
6432 (match-end 1))
6433 ;; If there was no message-id, we just fake one
6434 ;; to make subsequent routines simpler.
6435 (nnheader-generate-fake-message-id number))))
6436 ;; References.
6437 (progn
6438 (goto-char p)
6439 (if (search-forward "\nreferences:" nil t)
6440 (progn
6441 (setq end (point))
6442 (prog1
6443 (nnheader-header-value)
6444 (setq ref
6445 (buffer-substring
6446 (progn
6447 (end-of-line)
6448 (search-backward ">" end t)
6449 (1+ (point)))
6450 (progn
6451 (search-backward "<" end t)
6452 (point))))))
6453 ;; Get the references from the in-reply-to header if there
6454 ;; were no references and the in-reply-to header looks
6455 ;; promising.
6456 (if (and (search-forward "\nin-reply-to:" nil t)
6457 (setq in-reply-to (nnheader-header-value))
6458 (string-match "<[^>]+>" in-reply-to))
6459 (let (ref2)
6460 (setq ref (substring in-reply-to (match-beginning 0)
6461 (match-end 0)))
6462 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6463 (setq ref2 (substring in-reply-to (match-beginning 0)
6464 (match-end 0)))
6465 (when (> (length ref2) (length ref))
6466 (setq ref ref2)))
6467 ref)
6468 (setq ref nil))))
6469 ;; Chars.
6470 (progn
6471 (goto-char p)
6472 (if (search-forward "\nchars: " nil t)
6473 (if (numberp (setq chars (ignore-errors (read cur))))
6474 chars -1)
6475 -1))
6476 ;; Lines.
6477 (progn
6478 (goto-char p)
6479 (if (search-forward "\nlines: " nil t)
6480 (if (numberp (setq lines (ignore-errors (read cur))))
6481 lines -1)
6482 -1))
6483 ;; Xref.
6484 (progn
6485 (goto-char p)
6486 (and (search-forward "\nxref:" nil t)
6487 (nnheader-header-value)))
6488 ;; Extra.
6489 (when gnus-extra-headers
6490 (let ((extra gnus-extra-headers)
6491 out)
6492 (while extra
6493 (goto-char p)
6494 (when (search-forward
6495 (concat "\n" (symbol-name (car extra)) ":") nil t)
6496 (push (cons (car extra) (nnheader-header-value))
6497 out))
6498 (pop extra))
6499 out))))
6500 (when (equal id ref)
6501 (setq ref nil))
6502
6503 (when gnus-alter-header-function
6504 (funcall gnus-alter-header-function header)
6505 (setq id (mail-header-id header)
6506 ref (gnus-parent-id (mail-header-references header))))
6507
6508 (when (setq header
6509 (gnus-dependencies-add-header
6510 header dependencies force-new))
6511 (push header headers))
6512 (goto-char (point-max))
6513 (widen))
6514 (nreverse headers)))))
6515
6516 ;; Goes through the xover lines and returns a list of vectors
6517 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6518 force-new dependencies
6519 group also-fetch-heads)
6520 "Parse the news overview data in the server buffer.
6521 Return a list of headers that match SEQUENCE (see
6522 `nntp-retrieve-headers')."
6523 ;; Get the Xref when the users reads the articles since most/some
6524 ;; NNTP servers do not include Xrefs when using XOVER.
6525 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6526 (let ((mail-parse-charset gnus-newsgroup-charset)
6527 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6528 (cur nntp-server-buffer)
6529 (dependencies (or dependencies gnus-newsgroup-dependencies))
6530 (allp (cond
6531 ((eq gnus-read-all-available-headers t)
6532 t)
6533 ((and (stringp gnus-read-all-available-headers)
6534 group)
6535 (string-match gnus-read-all-available-headers group))
6536 (t
6537 nil)))
6538 number headers header)
6539 (with-current-buffer nntp-server-buffer
6540 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6541 ;; Allow the user to mangle the headers before parsing them.
6542 (gnus-run-hooks 'gnus-parse-headers-hook)
6543 (goto-char (point-min))
6544 (gnus-parse-without-error
6545 (while (and (or sequence allp)
6546 (not (eobp)))
6547 (setq number (read cur))
6548 (when (not allp)
6549 (while (and sequence
6550 (< (car sequence) number))
6551 (setq sequence (cdr sequence))))
6552 (when (and (or allp
6553 (and sequence
6554 (eq number (car sequence))))
6555 (progn
6556 (setq sequence (cdr sequence))
6557 (setq header (inline
6558 (gnus-nov-parse-line
6559 number dependencies force-new)))))
6560 (push header headers))
6561 (forward-line 1)))
6562 ;; A common bug in inn is that if you have posted an article and
6563 ;; then retrieves the active file, it will answer correctly --
6564 ;; the new article is included. However, a NOV entry for the
6565 ;; article may not have been generated yet, so this may fail.
6566 ;; We work around this problem by retrieving the last few
6567 ;; headers using HEAD.
6568 (if (or (not also-fetch-heads)
6569 (not sequence))
6570 ;; We (probably) got all the headers.
6571 (nreverse headers)
6572 (let ((gnus-nov-is-evil t))
6573 (nconc
6574 (nreverse headers)
6575 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6576 (gnus-get-newsgroup-headers))))))))
6577
6578 (defun gnus-article-get-xrefs ()
6579 "Fill in the Xref value in `gnus-current-headers', if necessary.
6580 This is meant to be called in `gnus-article-internal-prepare-hook'."
6581 (let ((headers (with-current-buffer gnus-summary-buffer
6582 gnus-current-headers)))
6583 (or (not gnus-use-cross-reference)
6584 (not headers)
6585 (and (mail-header-xref headers)
6586 (not (string= (mail-header-xref headers) "")))
6587 (let ((case-fold-search t)
6588 xref)
6589 (save-restriction
6590 (nnheader-narrow-to-headers)
6591 (goto-char (point-min))
6592 (when (or (and (not (eobp))
6593 (eq (downcase (char-after)) ?x)
6594 (looking-at "Xref:"))
6595 (search-forward "\nXref:" nil t))
6596 (goto-char (1+ (match-end 0)))
6597 (setq xref (buffer-substring (point) (point-at-eol)))
6598 (mail-header-set-xref headers xref)))))))
6599
6600 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6601 "Find article ID and insert the summary line for that article.
6602 OLD-HEADER can either be a header or a line number to insert
6603 the subject line on.
6604 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6605 and OLD-HEADER will be used when the summary line is inserted,
6606 too, instead of trying to fetch new headers."
6607 (let* ((line (and (numberp old-header) old-header))
6608 (old-header (and (vectorp old-header) old-header))
6609 (header (cond ((and old-header use-old-header)
6610 old-header)
6611 ((and (numberp id)
6612 (gnus-number-to-header id))
6613 (gnus-number-to-header id))
6614 (t
6615 (gnus-read-header id))))
6616 (number (and (numberp id) id))
6617 d)
6618 (when header
6619 ;; Rebuild the thread that this article is part of and go to the
6620 ;; article we have fetched.
6621 (when (and (not gnus-show-threads)
6622 old-header)
6623 (when (and number
6624 (setq d (gnus-data-find (mail-header-number old-header))))
6625 (goto-char (gnus-data-pos d))
6626 (gnus-data-remove
6627 number
6628 (- (point-at-bol)
6629 (prog1
6630 (1+ (point-at-eol))
6631 (gnus-delete-line))))))
6632 ;; Remove list identifiers from subject.
6633 (let ((gnus-newsgroup-headers (list header)))
6634 (gnus-summary-remove-list-identifiers))
6635 (when old-header
6636 (mail-header-set-number header (mail-header-number old-header)))
6637 (setq gnus-newsgroup-sparse
6638 (delq (setq number (mail-header-number header))
6639 gnus-newsgroup-sparse))
6640 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6641 (push number gnus-newsgroup-limit)
6642 (gnus-rebuild-thread (mail-header-id header) line)
6643 (gnus-summary-goto-subject number nil t))
6644 (when (and (numberp number)
6645 (> number 0))
6646 ;; We have to update the boundaries even if we can't fetch the
6647 ;; article if ID is a number -- so that the next `P' or `N'
6648 ;; command will fetch the previous (or next) article even
6649 ;; if the one we tried to fetch this time has been canceled.
6650 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6651 (setq gnus-newsgroup-end number))
6652 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6653 (setq gnus-newsgroup-begin number))
6654 (setq gnus-newsgroup-unselected
6655 (delq number gnus-newsgroup-unselected)))
6656 ;; Report back a success?
6657 (and header (mail-header-number header))))
6658
6659 ;;; Process/prefix in the summary buffer
6660
6661 (defun gnus-summary-work-articles (n)
6662 "Return a list of articles to be worked upon.
6663 The prefix argument, the list of process marked articles, and the
6664 current article will be taken into consideration."
6665 (with-current-buffer gnus-summary-buffer
6666 (cond
6667 (n
6668 ;; A numerical prefix has been given.
6669 (setq n (prefix-numeric-value n))
6670 (let ((backward (< n 0))
6671 (n (abs (prefix-numeric-value n)))
6672 articles article)
6673 (save-excursion
6674 (while
6675 (and (> n 0)
6676 (push (setq article (gnus-summary-article-number))
6677 articles)
6678 (if backward
6679 (gnus-summary-find-prev nil article)
6680 (gnus-summary-find-next nil article)))
6681 (decf n)))
6682 (nreverse articles)))
6683 ((and (and transient-mark-mode mark-active) (mark))
6684 (message "region active")
6685 ;; Work on the region between point and mark.
6686 (let ((max (max (point) (mark)))
6687 articles article)
6688 (save-excursion
6689 (goto-char (min (point) (mark)))
6690 (while
6691 (and
6692 (push (setq article (gnus-summary-article-number)) articles)
6693 (gnus-summary-find-next nil article)
6694 (< (point) max)))
6695 (nreverse articles))))
6696 (gnus-newsgroup-processable
6697 ;; There are process-marked articles present.
6698 ;; Save current state.
6699 (gnus-summary-save-process-mark)
6700 ;; Return the list.
6701 (reverse gnus-newsgroup-processable))
6702 (t
6703 ;; Just return the current article.
6704 (list (gnus-summary-article-number))))))
6705
6706 (defmacro gnus-summary-iterate (arg &rest forms)
6707 "Iterate over the process/prefixed articles and do FORMS.
6708 ARG is the interactive prefix given to the command. FORMS will be
6709 executed with point over the summary line of the articles."
6710 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6711 `(let ((,articles (gnus-summary-work-articles ,arg)))
6712 (while ,articles
6713 (gnus-summary-goto-subject (car ,articles))
6714 ,@forms
6715 (pop ,articles)))))
6716
6717 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6718 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6719
6720 (defun gnus-summary-save-process-mark ()
6721 "Push the current set of process marked articles on the stack."
6722 (interactive)
6723 (push (copy-sequence gnus-newsgroup-processable)
6724 gnus-newsgroup-process-stack))
6725
6726 (defun gnus-summary-kill-process-mark ()
6727 "Push the current set of process marked articles on the stack and unmark."
6728 (interactive)
6729 (gnus-summary-save-process-mark)
6730 (gnus-summary-unmark-all-processable))
6731
6732 (defun gnus-summary-yank-process-mark ()
6733 "Pop the last process mark state off the stack and restore it."
6734 (interactive)
6735 (unless gnus-newsgroup-process-stack
6736 (error "Empty mark stack"))
6737 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6738
6739 (defun gnus-summary-process-mark-set (set)
6740 "Make SET into the current process marked articles."
6741 (gnus-summary-unmark-all-processable)
6742 (mapc 'gnus-summary-set-process-mark set))
6743
6744 ;;; Searching and stuff
6745
6746 (defun gnus-summary-search-group (&optional backward use-level)
6747 "Search for next unread newsgroup.
6748 If optional argument BACKWARD is non-nil, search backward instead."
6749 (with-current-buffer gnus-group-buffer
6750 (when (gnus-group-search-forward
6751 backward nil (if use-level (gnus-group-group-level) nil))
6752 (gnus-group-group-name))))
6753
6754 (defun gnus-summary-best-group (&optional exclude-group)
6755 "Find the name of the best unread group.
6756 If EXCLUDE-GROUP, do not go to this group."
6757 (with-current-buffer gnus-group-buffer
6758 (save-excursion
6759 (gnus-group-best-unread-group exclude-group))))
6760
6761 (defun gnus-summary-find-next (&optional unread article backward)
6762 (if backward
6763 (gnus-summary-find-prev unread article)
6764 (let* ((dummy (gnus-summary-article-intangible-p))
6765 (article (or article (gnus-summary-article-number)))
6766 (data (gnus-data-find-list article))
6767 result)
6768 (when (and (not dummy)
6769 (or (not gnus-summary-check-current)
6770 (not unread)
6771 (not (gnus-data-unread-p (car data)))))
6772 (setq data (cdr data)))
6773 (when (setq result
6774 (if unread
6775 (progn
6776 (while data
6777 (unless (memq (gnus-data-number (car data))
6778 (cond
6779 ((eq gnus-auto-goto-ignores
6780 'always-undownloaded)
6781 gnus-newsgroup-undownloaded)
6782 (gnus-plugged
6783 nil)
6784 ((eq gnus-auto-goto-ignores
6785 'unfetched)
6786 gnus-newsgroup-unfetched)
6787 ((eq gnus-auto-goto-ignores
6788 'undownloaded)
6789 gnus-newsgroup-undownloaded)))
6790 (when (gnus-data-unread-p (car data))
6791 (setq result (car data)
6792 data nil)))
6793 (setq data (cdr data)))
6794 result)
6795 (car data)))
6796 (goto-char (gnus-data-pos result))
6797 (gnus-data-number result)))))
6798
6799 (defun gnus-summary-find-prev (&optional unread article)
6800 (let* ((eobp (eobp))
6801 (article (or article (gnus-summary-article-number)))
6802 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6803 result)
6804 (when (and (not eobp)
6805 (or (not gnus-summary-check-current)
6806 (not unread)
6807 (not (gnus-data-unread-p (car data)))))
6808 (setq data (cdr data)))
6809 (when (setq result
6810 (if unread
6811 (progn
6812 (while data
6813 (unless (memq (gnus-data-number (car data))
6814 (cond
6815 ((eq gnus-auto-goto-ignores
6816 'always-undownloaded)
6817 gnus-newsgroup-undownloaded)
6818 (gnus-plugged
6819 nil)
6820 ((eq gnus-auto-goto-ignores
6821 'unfetched)
6822 gnus-newsgroup-unfetched)
6823 ((eq gnus-auto-goto-ignores
6824 'undownloaded)
6825 gnus-newsgroup-undownloaded)))
6826 (when (gnus-data-unread-p (car data))
6827 (setq result (car data)
6828 data nil)))
6829 (setq data (cdr data)))
6830 result)
6831 (car data)))
6832 (goto-char (gnus-data-pos result))
6833 (gnus-data-number result))))
6834
6835 (defun gnus-summary-find-subject (subject &optional unread backward article)
6836 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6837 (article (or article (gnus-summary-article-number)))
6838 (articles (gnus-data-list backward))
6839 (arts (gnus-data-find-list article articles))
6840 result)
6841 (when (or (not gnus-summary-check-current)
6842 (not unread)
6843 (not (gnus-data-unread-p (car arts))))
6844 (setq arts (cdr arts)))
6845 (while arts
6846 (and (or (not unread)
6847 (gnus-data-unread-p (car arts)))
6848 (vectorp (gnus-data-header (car arts)))
6849 (gnus-subject-equal
6850 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6851 (setq result (car arts)
6852 arts nil))
6853 (setq arts (cdr arts)))
6854 (and result
6855 (goto-char (gnus-data-pos result))
6856 (gnus-data-number result))))
6857
6858 (defun gnus-summary-search-forward (&optional unread subject backward)
6859 "Search forward for an article.
6860 If UNREAD, look for unread articles. If SUBJECT, look for
6861 articles with that subject. If BACKWARD, search backward instead."
6862 (cond (subject (gnus-summary-find-subject subject unread backward))
6863 (backward (gnus-summary-find-prev unread))
6864 (t (gnus-summary-find-next unread))))
6865
6866 (defun gnus-recenter (&optional n)
6867 "Center point in window and redisplay frame.
6868 Also do horizontal recentering."
6869 (interactive "P")
6870 (when (and gnus-auto-center-summary
6871 (not (eq gnus-auto-center-summary 'vertical)))
6872 (gnus-horizontal-recenter))
6873 (if (fboundp 'recenter-top-bottom)
6874 (recenter-top-bottom n)
6875 (recenter n)))
6876
6877 (put 'gnus-recenter 'isearch-scroll t)
6878
6879 (defun gnus-forward-line-ignore-invisible (n)
6880 "Move N lines forward (backward if N is negative).
6881 Like forward-line, but skip over (and don't count) invisible lines."
6882 (let (done)
6883 (while (and (> n 0) (not done))
6884 ;; If the following character is currently invisible,
6885 ;; skip all characters with that same `invisible' property value.
6886 (while (gnus-invisible-p (point))
6887 (goto-char (gnus-next-char-property-change (point))))
6888 (forward-line 1)
6889 (if (eobp)
6890 (setq done t)
6891 (setq n (1- n))))
6892 (while (and (< n 0) (not done))
6893 (forward-line -1)
6894 (if (bobp) (setq done t)
6895 (setq n (1+ n))
6896 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6897 (goto-char (gnus-previous-char-property-change (point))))))))
6898
6899 (defun gnus-summary-recenter ()
6900 "Center point in the summary window.
6901 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6902 displayed, no centering will be performed."
6903 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6904 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6905 (interactive)
6906 ;; The user has to want it.
6907 (when gnus-auto-center-summary
6908 (let* ((top (cond ((< (window-height) 4) 0)
6909 ((< (window-height) 7) 1)
6910 (t (if (numberp gnus-auto-center-summary)
6911 gnus-auto-center-summary
6912 (/ (1- (window-height)) 2)))))
6913 (height (1- (window-height)))
6914 (bottom (save-excursion
6915 (goto-char (point-max))
6916 (gnus-forward-line-ignore-invisible (- height))
6917 (point)))
6918 (window (get-buffer-window (current-buffer))))
6919 (when (get-buffer-window gnus-article-buffer)
6920 ;; Only do recentering when the article buffer is displayed,
6921 ;; Set the window start to either `bottom', which is the biggest
6922 ;; possible valid number, or the second line from the top,
6923 ;; whichever is the least.
6924 (let ((top-pos (save-excursion
6925 (gnus-forward-line-ignore-invisible (- top))
6926 (point))))
6927 (if (> bottom top-pos)
6928 ;; Keep the second line from the top visible
6929 (set-window-start window top-pos)
6930 ;; Try to keep the bottom line visible; if it's partially
6931 ;; obscured, either scroll one more line to make it fully
6932 ;; visible, or revert to using TOP-POS.
6933 (save-excursion
6934 (goto-char (point-max))
6935 (gnus-forward-line-ignore-invisible -1)
6936 (let ((last-line-start (point)))
6937 (goto-char bottom)
6938 (set-window-start window (point) t)
6939 (when (not (pos-visible-in-window-p last-line-start window))
6940 (gnus-forward-line-ignore-invisible 1)
6941 (set-window-start window (min (point) top-pos) t)))))))
6942 ;; Do horizontal recentering while we're at it.
6943 (when (and (get-buffer-window (current-buffer) t)
6944 (not (eq gnus-auto-center-summary 'vertical)))
6945 (let ((selected (selected-window)))
6946 (select-window (get-buffer-window (current-buffer) t))
6947 (gnus-summary-position-point)
6948 (gnus-horizontal-recenter)
6949 (select-window selected))))))
6950
6951 (defun gnus-summary-jump-to-group (newsgroup)
6952 "Move point to NEWSGROUP in group mode buffer."
6953 ;; Keep update point of group mode buffer if visible.
6954 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6955 (save-window-excursion
6956 ;; Take care of tree window mode.
6957 (when (get-buffer-window gnus-group-buffer)
6958 (pop-to-buffer gnus-group-buffer))
6959 (gnus-group-jump-to-group newsgroup))
6960 (save-excursion
6961 ;; Take care of tree window mode.
6962 (if (get-buffer-window gnus-group-buffer 0)
6963 (pop-to-buffer gnus-group-buffer)
6964 (set-buffer gnus-group-buffer))
6965 (gnus-group-jump-to-group newsgroup))))
6966
6967 ;; This function returns a list of article numbers based on the
6968 ;; difference between the ranges of read articles in this group and
6969 ;; the range of active articles.
6970 (defun gnus-list-of-unread-articles (group)
6971 (let* ((read (gnus-info-read (gnus-get-info group)))
6972 (active (or (gnus-active group) (gnus-activate-group group)))
6973 (last (or (cdr active)
6974 (error "Group %s couldn't be activated " group)))
6975 (bottom (if gnus-newsgroup-maximum-articles
6976 (max (car active)
6977 (- last gnus-newsgroup-maximum-articles -1))
6978 (car active)))
6979 first nlast unread)
6980 ;; If none are read, then all are unread.
6981 (if (not read)
6982 (setq first bottom)
6983 ;; If the range of read articles is a single range, then the
6984 ;; first unread article is the article after the last read
6985 ;; article. Sounds logical, doesn't it?
6986 (if (and (not (listp (cdr read)))
6987 (or (< (car read) bottom)
6988 (progn (setq read (list read))
6989 nil)))
6990 (setq first (max bottom (1+ (cdr read))))
6991 ;; `read' is a list of ranges.
6992 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6993 (caar read)))
6994 1)
6995 (setq first bottom))
6996 (while read
6997 (when first
6998 (while (< first nlast)
6999 (setq unread (cons first unread)
7000 first (1+ first))))
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 (while (<= first last)
7006 (setq unread (cons first unread)
7007 first (1+ first)))
7008 ;; Return the list of unread articles.
7009 (delq 0 (nreverse unread))))
7010
7011 (defun gnus-list-of-read-articles (group)
7012 "Return a list of unread, unticked and non-dormant articles."
7013 (let* ((info (gnus-get-info group))
7014 (marked (gnus-info-marks info))
7015 (active (gnus-active group)))
7016 (and info active
7017 (gnus-list-range-difference
7018 (gnus-list-range-difference
7019 (gnus-sorted-complement
7020 (gnus-uncompress-range
7021 (if gnus-newsgroup-maximum-articles
7022 (cons (max (car active)
7023 (- (cdr active)
7024 gnus-newsgroup-maximum-articles
7025 -1))
7026 (cdr active))
7027 active))
7028 (gnus-list-of-unread-articles group))
7029 (cdr (assq 'dormant marked)))
7030 (cdr (assq 'tick marked))))))
7031
7032 ;; This function returns a sequence of article numbers based on the
7033 ;; difference between the ranges of read articles in this group and
7034 ;; the range of active articles.
7035 (defun gnus-sequence-of-unread-articles (group)
7036 (let* ((read (gnus-info-read (gnus-get-info group)))
7037 (active (or (gnus-active group) (gnus-activate-group group)))
7038 (last (cdr active))
7039 (bottom (if gnus-newsgroup-maximum-articles
7040 (max (car active)
7041 (- last gnus-newsgroup-maximum-articles -1))
7042 (car active)))
7043 first nlast unread)
7044 ;; If none are read, then all are unread.
7045 (if (not read)
7046 (setq first bottom)
7047 ;; If the range of read articles is a single range, then the
7048 ;; first unread article is the article after the last read
7049 ;; article. Sounds logical, doesn't it?
7050 (if (and (not (listp (cdr read)))
7051 (or (< (car read) bottom)
7052 (progn (setq read (list read))
7053 nil)))
7054 (setq first (max bottom (1+ (cdr read))))
7055 ;; `read' is a list of ranges.
7056 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7057 (caar read)))
7058 1)
7059 (setq first bottom))
7060 (while read
7061 (when first
7062 (push (cons first nlast) unread))
7063 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7064 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7065 (setq read (cdr read)))))
7066 ;; And add the last unread articles.
7067 (cond ((not (and first last))
7068 nil)
7069 ((< first last)
7070 (push (cons first last) unread))
7071 ((= first last)
7072 (push first unread)))
7073 ;; Return the sequence of unread articles.
7074 (delq 0 (nreverse unread))))
7075
7076 ;; Various summary commands
7077
7078 (defun gnus-summary-select-article-buffer ()
7079 "Reconfigure windows to show the article buffer.
7080 If `gnus-widen-article-window' is set, show only the article
7081 buffer."
7082 (interactive)
7083 (if (not (gnus-buffer-live-p gnus-article-buffer))
7084 (error "There is no article buffer for this summary buffer")
7085 (unless (get-buffer-window gnus-article-buffer)
7086 (gnus-summary-show-article))
7087 (gnus-configure-windows
7088 (if gnus-widen-article-window
7089 'only-article
7090 'article)
7091 t)
7092 (select-window (get-buffer-window gnus-article-buffer))))
7093
7094 (defun gnus-summary-universal-argument (arg)
7095 "Perform any operation on all articles that are process/prefixed."
7096 (interactive "P")
7097 (let ((articles (gnus-summary-work-articles arg))
7098 func article)
7099 (if (eq
7100 (setq
7101 func
7102 (key-binding
7103 (read-key-sequence
7104 (substitute-command-keys
7105 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7106 'undefined)
7107 (gnus-error 1 "Undefined key")
7108 (save-excursion
7109 (while articles
7110 (gnus-summary-goto-subject (setq article (pop articles)))
7111 (let (gnus-newsgroup-processable)
7112 (command-execute func))
7113 (gnus-summary-remove-process-mark article)))))
7114 (gnus-summary-position-point))
7115
7116 (defun gnus-summary-toggle-truncation (&optional arg)
7117 "Toggle truncation of summary lines.
7118 With ARG, turn line truncation on if ARG is positive."
7119 (interactive "P")
7120 (setq truncate-lines
7121 (if (null arg) (not truncate-lines)
7122 (> (prefix-numeric-value arg) 0)))
7123 (redraw-display))
7124
7125 (defun gnus-summary-find-for-reselect ()
7126 "Return the number of an article to stay on across a reselect.
7127 The current article is considered, then following articles, then previous
7128 articles. An article is sought which is not canceled and isn't a temporary
7129 insertion from another group. If there's no such then return a dummy 0."
7130 (let (found)
7131 (dolist (rev '(nil t))
7132 (unless found ; don't demand the reverse list if we don't need it
7133 (let ((data (gnus-data-find-list
7134 (gnus-summary-article-number) (gnus-data-list rev))))
7135 (while (and data (not found))
7136 (if (and (< 0 (gnus-data-number (car data)))
7137 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7138 (setq found (gnus-data-number (car data))))
7139 (setq data (cdr data))))))
7140 (or found 0)))
7141
7142 (defun gnus-summary-reselect-current-group (&optional all rescan)
7143 "Exit and then reselect the current newsgroup.
7144 The prefix argument ALL means to select all articles."
7145 (interactive "P")
7146 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7147 (error "Ephemeral groups can't be reselected"))
7148 (let ((current-subject (gnus-summary-find-for-reselect))
7149 (group gnus-newsgroup-name))
7150 (setq gnus-newsgroup-begin nil)
7151 (gnus-summary-exit nil 'leave-hidden)
7152 ;; We have to adjust the point of group mode buffer because
7153 ;; point was moved to the next unread newsgroup by exiting.
7154 (gnus-summary-jump-to-group group)
7155 (when rescan
7156 (save-excursion
7157 (gnus-group-get-new-news-this-group 1)))
7158 (gnus-group-read-group all t)
7159 (gnus-summary-goto-subject current-subject nil t)))
7160
7161 (defun gnus-summary-rescan-group (&optional all)
7162 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7163 (interactive "P")
7164 (let ((config gnus-current-window-configuration))
7165 (gnus-summary-reselect-current-group all t)
7166 (gnus-configure-windows config)
7167 (when (eq config 'article)
7168 (gnus-summary-select-article))))
7169
7170 (defun gnus-summary-update-info (&optional non-destructive)
7171 (save-excursion
7172 (let ((group gnus-newsgroup-name))
7173 (when group
7174 (when gnus-newsgroup-kill-headers
7175 (setq gnus-newsgroup-killed
7176 (gnus-compress-sequence
7177 (gnus-sorted-union
7178 (gnus-list-range-intersection
7179 gnus-newsgroup-unselected gnus-newsgroup-killed)
7180 gnus-newsgroup-unreads)
7181 t)))
7182 (unless (listp (cdr gnus-newsgroup-killed))
7183 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7184 (let ((headers gnus-newsgroup-headers)
7185 (ephemeral-p (gnus-ephemeral-group-p group))
7186 info)
7187 (unless ephemeral-p
7188 (setq info (copy-sequence (gnus-get-info group))
7189 info (delq (gnus-info-params info) info)))
7190 ;; Set the new ranges of read articles.
7191 (with-current-buffer gnus-group-buffer
7192 (gnus-undo-force-boundary))
7193 (gnus-update-read-articles
7194 group (gnus-sorted-union
7195 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7196 ;; Set the current article marks.
7197 (let ((gnus-newsgroup-scored
7198 (if (and (not gnus-save-score)
7199 (not non-destructive))
7200 nil
7201 gnus-newsgroup-scored)))
7202 (save-excursion
7203 (gnus-update-marks)))
7204 ;; Do the cross-ref thing.
7205 (when gnus-use-cross-reference
7206 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7207 ;; Do not switch windows but change the buffer to work.
7208 (set-buffer gnus-group-buffer)
7209 (unless ephemeral-p
7210 (gnus-group-update-group
7211 group nil
7212 (equal info
7213 (setq info (copy-sequence (gnus-get-info group))
7214 info (delq (gnus-info-params info) info))))))))))
7215
7216 (defun gnus-summary-save-newsrc (&optional force)
7217 "Save the current number of read/marked articles in the dribble buffer.
7218 The dribble buffer will then be saved.
7219 If FORCE (the prefix), also save the .newsrc file(s)."
7220 (interactive "P")
7221 (gnus-summary-update-info t)
7222 (if force
7223 (gnus-save-newsrc-file)
7224 (gnus-dribble-save)))
7225
7226 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7227 (declare-function gnus-article-stop-animations "gnus-art" ())
7228
7229 (defun gnus-summary-exit (&optional temporary leave-hidden)
7230 "Exit reading current newsgroup, and then return to group selection mode.
7231 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7232 (interactive)
7233 (gnus-set-global-variables)
7234 (when (gnus-buffer-live-p gnus-article-buffer)
7235 (with-current-buffer gnus-article-buffer
7236 (mm-destroy-parts gnus-article-mime-handles)
7237 ;; Set it to nil for safety reason.
7238 (setq gnus-article-mime-handle-alist nil)
7239 (setq gnus-article-mime-handles nil)))
7240 (gnus-kill-save-kill-buffer)
7241 (gnus-async-halt-prefetch)
7242 (let* ((group gnus-newsgroup-name)
7243 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7244 (gnus-group-is-exiting-p t)
7245 (article-buffer gnus-article-buffer)
7246 (original-article-buffer gnus-original-article-buffer)
7247 (mode major-mode)
7248 (group-point nil)
7249 (buf (current-buffer))
7250 ;; `gnus-single-article-buffer' is nil buffer-locally in
7251 ;; ephemeral group of which summary buffer will be killed,
7252 ;; but the global value may be non-nil.
7253 (single-article-buffer gnus-single-article-buffer))
7254 (unless quit-config
7255 ;; Do adaptive scoring, and possibly save score files.
7256 (when gnus-newsgroup-adaptive
7257 (gnus-score-adaptive))
7258 (when gnus-use-scoring
7259 (gnus-score-save)))
7260 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7261 (when gnus-use-cache
7262 (gnus-cache-possibly-remove-articles)
7263 (gnus-cache-save-buffers))
7264 (gnus-async-prefetch-remove-group group)
7265 (when gnus-suppress-duplicates
7266 (gnus-dup-enter-articles))
7267 (when gnus-use-trees
7268 (gnus-tree-close))
7269 (when gnus-use-cache
7270 (gnus-cache-write-active))
7271 ;; Remove entries for this group.
7272 (nnmail-purge-split-history (gnus-group-real-name group))
7273 ;; Make all changes in this group permanent.
7274 (unless quit-config
7275 (gnus-run-hooks 'gnus-exit-group-hook)
7276 (gnus-summary-update-info))
7277 (gnus-close-group group)
7278 ;; Make sure where we were, and go to next newsgroup.
7279 (when (buffer-live-p (get-buffer gnus-group-buffer))
7280 (set-buffer gnus-group-buffer))
7281 (unless quit-config
7282 (gnus-group-jump-to-group group))
7283 (gnus-run-hooks 'gnus-summary-exit-hook)
7284 (unless (or quit-config
7285 (not gnus-summary-next-group-on-exit)
7286 ;; If this group has disappeared from the summary
7287 ;; buffer, don't skip forwards.
7288 (not (string= group (gnus-group-group-name))))
7289 (gnus-group-next-unread-group 1))
7290 (setq group-point (point))
7291 (gnus-article-stop-animations)
7292 (if temporary
7293 nil ;Nothing to do.
7294 (set-buffer buf)
7295 (if (not gnus-kill-summary-on-exit)
7296 (progn
7297 (gnus-deaden-summary)
7298 (setq mode nil))
7299 (when (get-buffer gnus-article-buffer)
7300 (bury-buffer gnus-article-buffer))
7301 ;; Return to group mode buffer.
7302 (when (eq mode 'gnus-summary-mode)
7303 (gnus-kill-buffer buf)))
7304
7305 (setq gnus-current-select-method gnus-select-method)
7306 (when (gnus-buffer-live-p gnus-group-buffer)
7307 (set-buffer gnus-group-buffer))
7308 (if quit-config
7309 (gnus-handle-ephemeral-exit quit-config)
7310 (goto-char group-point)
7311 ;; If gnus-group-buffer is already displayed, make sure we also move
7312 ;; the cursor in the window that displays it.
7313 (let ((win (get-buffer-window (current-buffer) 0)))
7314 (if win (set-window-point win (point))))
7315 (unless leave-hidden
7316 (gnus-configure-windows 'group 'force)))
7317
7318 ;; If we have several article buffers, we kill them at exit.
7319 (unless single-article-buffer
7320 (when (gnus-buffer-live-p article-buffer)
7321 (with-current-buffer article-buffer
7322 ;; Don't kill sticky article buffers
7323 (unless (eq major-mode 'gnus-sticky-article-mode)
7324 (gnus-kill-buffer article-buffer)
7325 (setq gnus-article-current nil))))
7326 (gnus-kill-buffer original-article-buffer))
7327
7328 ;; Clear the current group name.
7329 (unless quit-config
7330 (setq gnus-newsgroup-name nil)))))
7331
7332 (declare-function gnus-stop-downloads "gnus-art" ())
7333
7334 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7335 (defun gnus-summary-exit-no-update (&optional no-questions)
7336 "Quit reading current newsgroup without updating read article info."
7337 (interactive)
7338 (let* ((group gnus-newsgroup-name)
7339 (gnus-group-is-exiting-p t)
7340 (gnus-group-is-exiting-without-update-p t)
7341 (quit-config (gnus-group-quit-config group)))
7342 (when (or no-questions
7343 (gnus-ephemeral-group-p group)
7344 gnus-expert-user
7345 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7346 (gnus-async-halt-prefetch)
7347 (run-hooks 'gnus-summary-prepare-exit-hook)
7348 (when (gnus-buffer-live-p gnus-article-buffer)
7349 (with-current-buffer gnus-article-buffer
7350 (gnus-article-stop-animations)
7351 (gnus-stop-downloads)
7352 (mm-destroy-parts gnus-article-mime-handles)
7353 ;; Set it to nil for safety reason.
7354 (setq gnus-article-mime-handle-alist nil)
7355 (setq gnus-article-mime-handles nil)))
7356 ;; If we have several article buffers, we kill them at exit.
7357 (unless gnus-single-article-buffer
7358 (gnus-kill-buffer gnus-article-buffer)
7359 (gnus-kill-buffer gnus-original-article-buffer)
7360 (setq gnus-article-current nil))
7361 ;; Return to the group buffer.
7362 (if (not gnus-kill-summary-on-exit)
7363 (progn
7364 (gnus-deaden-summary)
7365 (gnus-configure-windows 'group 'force))
7366 (gnus-configure-windows 'group 'force)
7367 (gnus-close-group group)
7368 (gnus-kill-buffer gnus-summary-buffer))
7369 (unless gnus-single-article-buffer
7370 (setq gnus-article-current nil))
7371 (when gnus-use-trees
7372 (gnus-tree-close))
7373 (gnus-async-prefetch-remove-group group)
7374 (when (get-buffer gnus-article-buffer)
7375 (bury-buffer gnus-article-buffer))
7376 ;; Clear the current group name.
7377 (setq gnus-newsgroup-name nil)
7378 (unless (gnus-ephemeral-group-p group)
7379 (gnus-group-update-group group nil t))
7380 (when (equal (gnus-group-group-name) group)
7381 (gnus-group-next-unread-group 1))
7382 (gnus-article-stop-animations)
7383 (when quit-config
7384 (gnus-handle-ephemeral-exit quit-config)))))
7385
7386 (defun gnus-handle-ephemeral-exit (quit-config)
7387 "Handle movement when leaving an ephemeral group.
7388 The state which existed when entering the ephemeral is reset."
7389 (if (not (buffer-live-p (car quit-config)))
7390 (when (gnus-buffer-live-p gnus-group-buffer)
7391 (gnus-configure-windows 'group 'force))
7392 (set-buffer (car quit-config))
7393 (unless (eq (cdr quit-config) 'group)
7394 (setq gnus-current-select-method
7395 (gnus-find-method-for-group gnus-newsgroup-name)))
7396 (cond ((derived-mode-p 'gnus-summary-mode)
7397 (gnus-set-global-variables))
7398 ((derived-mode-p 'gnus-article-mode)
7399 (save-current-buffer
7400 ;; The `gnus-summary-buffer' variable may point
7401 ;; to the old summary buffer when using a single
7402 ;; article buffer.
7403 (unless (gnus-buffer-live-p gnus-summary-buffer)
7404 (set-buffer gnus-group-buffer))
7405 (set-buffer gnus-summary-buffer)
7406 (gnus-set-global-variables))))
7407 (if (or (eq (cdr quit-config) 'article)
7408 (eq (cdr quit-config) 'pick))
7409 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7410 (gnus-configure-windows 'pick 'force)
7411 (gnus-configure-windows (cdr quit-config) 'force))
7412 (gnus-configure-windows (cdr quit-config) 'force))
7413 (when (derived-mode-p 'gnus-summary-mode)
7414 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7415 next-unread-noselect))
7416 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7417 'next-noselect)
7418 (gnus-summary-next-subject 1 nil t))
7419 ((eq gnus-auto-select-on-ephemeral-exit
7420 'next-unread-noselect)
7421 (gnus-summary-next-subject 1 t t))))
7422 ;; Hide the article buffer which displays the article different
7423 ;; from the one that the cursor points to in the summary buffer.
7424 (gnus-configure-windows 'summary 'force))
7425 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7426 (gnus-summary-next-subject 1))
7427 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7428 (gnus-summary-next-subject 1 t))))
7429 (gnus-summary-recenter)
7430 (gnus-summary-position-point))))
7431
7432 ;;; Dead summaries.
7433
7434 (defvar gnus-dead-summary-mode-map
7435 (let ((map (make-keymap)))
7436 (suppress-keymap map)
7437 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7438 (dolist (key '("\C-d" "\r" "\177" [delete]))
7439 (define-key map key 'gnus-summary-wake-up-the-dead))
7440 (dolist (key '("q" "Q"))
7441 (define-key map key 'bury-buffer))
7442 map))
7443
7444 (define-minor-mode gnus-dead-summary-mode
7445 "Minor mode for Gnus summary buffers."
7446 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7447 (unless (derived-mode-p 'gnus-summary-mode)
7448 (setq gnus-dead-summary-mode nil)))
7449
7450 (defun gnus-deaden-summary ()
7451 "Make the current summary buffer into a dead summary buffer."
7452 ;; Kill any previous dead summary buffer.
7453 (when (and gnus-dead-summary
7454 (buffer-name gnus-dead-summary))
7455 (with-current-buffer gnus-dead-summary
7456 (when gnus-dead-summary-mode
7457 (kill-buffer (current-buffer)))))
7458 ;; Make this the current dead summary.
7459 (setq gnus-dead-summary (current-buffer))
7460 (gnus-dead-summary-mode 1)
7461 (let ((name (buffer-name)))
7462 (when (string-match "Summary" name)
7463 (rename-buffer
7464 (concat (substring name 0 (match-beginning 0)) "Dead "
7465 (substring name (match-beginning 0)))
7466 t)
7467 (bury-buffer))))
7468
7469 (defun gnus-kill-or-deaden-summary (buffer)
7470 "Kill or deaden the summary BUFFER."
7471 (save-excursion
7472 (when (and (buffer-name buffer)
7473 (not gnus-single-article-buffer))
7474 (with-current-buffer buffer
7475 (gnus-kill-buffer gnus-article-buffer)
7476 (gnus-kill-buffer gnus-original-article-buffer)))
7477 (cond
7478 ;; Kill the buffer.
7479 (gnus-kill-summary-on-exit
7480 (when (and gnus-use-trees
7481 (gnus-buffer-exists-p buffer))
7482 (with-current-buffer buffer
7483 (gnus-tree-close)))
7484 (gnus-kill-buffer buffer))
7485 ;; Deaden the buffer.
7486 ((gnus-buffer-exists-p buffer)
7487 (with-current-buffer buffer
7488 (gnus-deaden-summary))))))
7489
7490 (defun gnus-summary-wake-up-the-dead (&rest args)
7491 "Wake up the dead summary buffer."
7492 (interactive)
7493 (gnus-dead-summary-mode -1)
7494 (let ((name (buffer-name)))
7495 (when (string-match "Dead " name)
7496 (rename-buffer
7497 (concat (substring name 0 (match-beginning 0))
7498 (substring name (match-end 0)))
7499 t)))
7500 (gnus-message 3 "This dead summary is now alive again"))
7501
7502 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7503 (defun gnus-summary-describe-group (&optional force)
7504 "Describe the current newsgroup."
7505 (interactive "P")
7506 (gnus-group-describe-group force gnus-newsgroup-name))
7507
7508 (defun gnus-summary-describe-briefly ()
7509 "Describe summary mode commands briefly."
7510 (interactive)
7511 (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")))
7512
7513 ;; Walking around group mode buffer from summary mode.
7514
7515 (defun gnus-summary-next-group (&optional no-article target-group backward)
7516 "Exit current newsgroup and then select next unread newsgroup.
7517 If prefix argument NO-ARTICLE is non-nil, no article is selected
7518 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7519 previous group instead."
7520 (interactive "P")
7521 ;; Stop pre-fetching.
7522 (gnus-async-halt-prefetch)
7523 (let ((current-group gnus-newsgroup-name)
7524 (current-buffer (current-buffer))
7525 entered)
7526 ;; First we semi-exit this group to update Xrefs and all variables.
7527 ;; We can't do a real exit, because the window conf must remain
7528 ;; the same in case the user is prompted for info, and we don't
7529 ;; want the window conf to change before that...
7530 (gnus-summary-exit t)
7531 (while (not entered)
7532 ;; Then we find what group we are supposed to enter.
7533 (set-buffer gnus-group-buffer)
7534 (gnus-group-jump-to-group current-group)
7535 (setq target-group
7536 (or target-group
7537 (if (eq gnus-keep-same-level 'best)
7538 (gnus-summary-best-group gnus-newsgroup-name)
7539 (gnus-summary-search-group backward gnus-keep-same-level))))
7540 (if (not target-group)
7541 ;; There are no further groups, so we return to the group
7542 ;; buffer.
7543 (progn
7544 (gnus-message 5 "Returning to the group buffer")
7545 (setq entered t)
7546 (when (gnus-buffer-live-p current-buffer)
7547 (set-buffer current-buffer)
7548 (gnus-summary-exit))
7549 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7550 ;; We try to enter the target group.
7551 (gnus-group-jump-to-group target-group)
7552 (let ((unreads (gnus-group-group-unread)))
7553 (if (and (or (eq t unreads)
7554 (and unreads (not (zerop unreads))))
7555 (gnus-summary-read-group
7556 target-group nil no-article
7557 (and (buffer-name current-buffer) current-buffer)
7558 nil backward))
7559 (setq entered t)
7560 (setq current-group target-group
7561 target-group nil)))))))
7562
7563 (defun gnus-summary-prev-group (&optional no-article)
7564 "Exit current newsgroup and then select previous unread newsgroup.
7565 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7566 (interactive "P")
7567 (gnus-summary-next-group no-article nil t))
7568
7569 ;; Walking around summary lines.
7570
7571 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7572 "Go to the first subject satisfying any non-nil constraint.
7573 If UNREAD is non-nil, the article should be unread.
7574 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7575 If UNSEEN is non-nil, the article should be unseen as well as unread.
7576 Returns the article selected or nil if there are no matching articles."
7577 (interactive "P")
7578 (cond
7579 ;; Empty summary.
7580 ((null gnus-newsgroup-data)
7581 (gnus-message 3 "No articles in the group")
7582 nil)
7583 ;; Pick the first article.
7584 ((not (or unread undownloaded unseen))
7585 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7586 (gnus-data-number (car gnus-newsgroup-data)))
7587 ;; Find the first unread article.
7588 (t
7589 (let ((data gnus-newsgroup-data))
7590 (while (and data
7591 (let ((num (gnus-data-number (car data))))
7592 (or (memq num gnus-newsgroup-unfetched)
7593 (not (or (and unread
7594 (memq num gnus-newsgroup-unreads))
7595 (and undownloaded
7596 (memq num gnus-newsgroup-undownloaded))
7597 (and unseen
7598 (memq num gnus-newsgroup-unseen)
7599 (memq num gnus-newsgroup-unreads)))))))
7600 (setq data (cdr data)))
7601 (prog1
7602 (if data
7603 (progn
7604 (goto-char (gnus-data-pos (car data)))
7605 (gnus-data-number (car data)))
7606 (gnus-message 3 "No more%s articles"
7607 (let* ((r (when unread " unread"))
7608 (d (when undownloaded " undownloaded"))
7609 (s (when unseen " unseen"))
7610 (l (delq nil (list r d s))))
7611 (cond ((= 3 (length l))
7612 (concat r "," d ", or" s))
7613 ((= 2 (length l))
7614 (concat (car l) ", or" (cadr l)))
7615 ((= 1 (length l))
7616 (car l))
7617 (t
7618 ""))))
7619 nil
7620 )
7621 (gnus-summary-position-point))))))
7622
7623 (defun gnus-summary-next-subject (n &optional unread dont-display)
7624 "Go to next N'th summary line.
7625 If N is negative, go to the previous N'th subject line.
7626 If UNREAD is non-nil, only unread articles are selected.
7627 The difference between N and the actual number of steps taken is
7628 returned."
7629 (interactive "p")
7630 (let ((backward (< n 0))
7631 (n (abs n)))
7632 (while (and (> n 0)
7633 (if backward
7634 (gnus-summary-find-prev unread)
7635 (gnus-summary-find-next unread)))
7636 (unless (zerop (setq n (1- n)))
7637 (gnus-summary-show-thread)))
7638 (when (/= 0 n)
7639 (gnus-message 7 "No more%s articles"
7640 (if unread " unread" "")))
7641 (unless dont-display
7642 (gnus-summary-recenter)
7643 (gnus-summary-position-point))
7644 n))
7645
7646 (defun gnus-summary-next-unread-subject (n)
7647 "Go to next N'th unread summary line."
7648 (interactive "p")
7649 (gnus-summary-next-subject n t))
7650
7651 (defun gnus-summary-prev-subject (n &optional unread)
7652 "Go to previous N'th summary line.
7653 If optional argument UNREAD is non-nil, only unread article is selected."
7654 (interactive "p")
7655 (gnus-summary-next-subject (- n) unread))
7656
7657 (defun gnus-summary-prev-unread-subject (n)
7658 "Go to previous N'th unread summary line."
7659 (interactive "p")
7660 (gnus-summary-next-subject (- n) t))
7661
7662 (defun gnus-summary-goto-subjects (articles)
7663 "Insert the subject header for ARTICLES in the current buffer."
7664 (save-excursion
7665 (dolist (article articles)
7666 (gnus-summary-goto-subject article t)))
7667 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7668 (gnus-summary-position-point))
7669
7670 (defun gnus-summary-goto-subject (article &optional force silent)
7671 "Go to the subject line of ARTICLE.
7672 If FORCE, also allow jumping to articles not currently shown."
7673 (interactive "nArticle number: ")
7674 (unless (numberp article)
7675 (error "Article %s is not a number" article))
7676 (let ((b (point))
7677 (data (gnus-data-find article)))
7678 ;; We read in the article if we have to.
7679 (and (not data)
7680 force
7681 (gnus-summary-insert-subject
7682 article
7683 (if (or (numberp force) (vectorp force)) force)
7684 t)
7685 (setq data (gnus-data-find article)))
7686 (goto-char b)
7687 (if (not data)
7688 (progn
7689 (unless silent
7690 (gnus-message 3 "Can't find article %d" article))
7691 nil)
7692 (let ((pt (gnus-data-pos data)))
7693 (goto-char pt)
7694 (gnus-summary-set-article-display-arrow pt))
7695 (gnus-summary-position-point)
7696 article)))
7697
7698 ;; Walking around summary lines with displaying articles.
7699
7700 (defun gnus-summary-expand-window (&optional arg)
7701 "Make the summary buffer take up the entire Emacs frame.
7702 Given a prefix, will force an `article' buffer configuration."
7703 (interactive "P")
7704 (if arg
7705 (gnus-configure-windows 'article 'force)
7706 (gnus-configure-windows 'summary 'force)))
7707
7708 (defun gnus-summary-display-article (article &optional all-header)
7709 "Display ARTICLE in article buffer."
7710 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7711 (with-current-buffer gnus-article-buffer
7712 (derived-mode-p 'gnus-article-mode)))
7713 (gnus-article-setup-buffer))
7714 (gnus-set-global-variables)
7715 (with-current-buffer gnus-article-buffer
7716 (setq gnus-article-charset gnus-newsgroup-charset)
7717 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7718 (mm-enable-multibyte))
7719 (if (null article)
7720 nil
7721 (prog1
7722 (if gnus-summary-display-article-function
7723 (funcall gnus-summary-display-article-function article all-header)
7724 (gnus-article-prepare article all-header))
7725 (gnus-run-hooks 'gnus-select-article-hook)
7726 (when (and gnus-current-article
7727 (not (zerop gnus-current-article)))
7728 (gnus-summary-goto-subject gnus-current-article))
7729 (gnus-summary-recenter)
7730 (when (and gnus-use-trees gnus-show-threads)
7731 (gnus-possibly-generate-tree article)
7732 (gnus-highlight-selected-tree article))
7733 ;; Successfully display article.
7734 (gnus-article-set-window-start
7735 (cdr (assq article gnus-newsgroup-bookmarks))))))
7736
7737 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7738 "Select the current article.
7739 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7740 non-nil, the article will be re-fetched even if it already present in
7741 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7742 be displayed."
7743 ;; Make sure we are in the summary buffer to work around bbdb bug.
7744 (unless (derived-mode-p 'gnus-summary-mode)
7745 (set-buffer gnus-summary-buffer))
7746 (let ((article (or article (gnus-summary-article-number)))
7747 (all-headers (not (not all-headers))) ;Must be t or nil.
7748 gnus-summary-display-article-function)
7749 (and (not pseudo)
7750 (gnus-summary-article-pseudo-p article)
7751 (error "This is a pseudo-article"))
7752 (with-current-buffer gnus-summary-buffer
7753 (if (or (and gnus-single-article-buffer
7754 (or (null gnus-current-article)
7755 (null gnus-article-current)
7756 (null (get-buffer gnus-article-buffer))
7757 (not (eq article (cdr gnus-article-current)))
7758 (not (equal (car gnus-article-current)
7759 gnus-newsgroup-name))
7760 (not (get-buffer gnus-original-article-buffer))))
7761 (and (not gnus-single-article-buffer)
7762 (or (null gnus-current-article)
7763 (not (get-buffer gnus-original-article-buffer))
7764 (not (eq gnus-current-article article))))
7765 force)
7766 ;; The requested article is different from the current article.
7767 (progn
7768 (gnus-summary-display-article article all-headers)
7769 (when (gnus-buffer-live-p gnus-article-buffer)
7770 (with-current-buffer gnus-article-buffer
7771 (if (not gnus-article-decoded-p) ;; a local variable
7772 (mm-disable-multibyte))))
7773 (gnus-article-set-window-start
7774 (cdr (assq article gnus-newsgroup-bookmarks)))
7775 article)
7776 'old))))
7777
7778 (defun gnus-summary-force-verify-and-decrypt ()
7779 "Display buttons for signed/encrypted parts and verify/decrypt them."
7780 (interactive)
7781 (let ((mm-verify-option 'known)
7782 (mm-decrypt-option 'known)
7783 (gnus-article-emulate-mime t)
7784 (gnus-buttonized-mime-types (append (list "multipart/signed"
7785 "multipart/encrypted")
7786 gnus-buttonized-mime-types)))
7787 (gnus-summary-select-article nil 'force)))
7788
7789 (defun gnus-summary-next-article (&optional unread subject backward push)
7790 "Select the next article.
7791 If UNREAD, only unread articles are selected.
7792 If SUBJECT, only articles with SUBJECT are selected.
7793 If BACKWARD, the previous article is selected instead of the next."
7794 (interactive "P")
7795 ;; Make sure we are in the summary buffer.
7796 (unless (derived-mode-p 'gnus-summary-mode)
7797 (set-buffer gnus-summary-buffer))
7798 (cond
7799 ;; Is there such an article?
7800 ((and (gnus-summary-search-forward unread subject backward)
7801 (or (gnus-summary-display-article (gnus-summary-article-number))
7802 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7803 (gnus-summary-position-point))
7804 ;; If not, we try the first unread, if that is wanted.
7805 ((and subject
7806 gnus-auto-select-same
7807 (gnus-summary-first-unread-article))
7808 (gnus-summary-position-point)
7809 (gnus-message 6 "Wrapped"))
7810 ;; Try to get next/previous article not displayed in this group.
7811 ((and gnus-auto-extend-newsgroup
7812 (not unread) (not subject))
7813 (gnus-summary-goto-article
7814 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7815 nil (count-lines (point-min) (point))))
7816 ;; Go to next/previous group.
7817 (t
7818 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7819 (gnus-summary-jump-to-group gnus-newsgroup-name))
7820 (let ((cmd (if (featurep 'xemacs)
7821 last-command-char
7822 last-command-event))
7823 (point
7824 (with-current-buffer gnus-group-buffer
7825 (point)))
7826 (current-summary (current-buffer))
7827 (group
7828 (if (eq gnus-keep-same-level 'best)
7829 (gnus-summary-best-group gnus-newsgroup-name)
7830 (gnus-summary-search-group backward gnus-keep-same-level))))
7831 ;; Select next unread newsgroup automagically.
7832 (cond
7833 ((or (not gnus-auto-select-next)
7834 (not cmd))
7835 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7836 ((or (eq gnus-auto-select-next 'quietly)
7837 (and (eq gnus-auto-select-next 'slightly-quietly)
7838 push)
7839 (and (eq gnus-auto-select-next 'almost-quietly)
7840 (gnus-summary-last-article-p)))
7841 ;; Select quietly.
7842 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7843 (gnus-summary-exit)
7844 (gnus-message 7 "No more%s articles (%s)..."
7845 (if unread " unread" "")
7846 (if group (concat "selecting " group)
7847 "exiting"))
7848 (gnus-summary-next-group nil group backward)))
7849 (t
7850 (when (gnus-key-press-event-p last-input-event)
7851 ;; Somehow or other, we may now have selected a different
7852 ;; window. Make point go back to the summary buffer.
7853 (when (eq current-summary (current-buffer))
7854 ;; FIXME: This burps when get-buffer-window returns nil.
7855 (select-window (get-buffer-window current-summary 0)))
7856 (gnus-summary-walk-group-buffer
7857 gnus-newsgroup-name cmd unread backward point))))))))
7858
7859 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7860 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7861 (?\C-p (gnus-group-prev-unread-group 1))))
7862 (cursor-in-echo-area t)
7863 keve key group ended prompt)
7864 (with-current-buffer gnus-group-buffer
7865 (goto-char start)
7866 (setq group
7867 (if (eq gnus-keep-same-level 'best)
7868 (gnus-summary-best-group gnus-newsgroup-name)
7869 (gnus-summary-search-group backward gnus-keep-same-level))))
7870 (while (not ended)
7871 (setq prompt
7872 (format
7873 "No more%s articles%s " (if unread " unread" "")
7874 (if (and group
7875 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7876 (format " (Type %s for %s [%s])"
7877 (single-key-description cmd)
7878 (gnus-group-decoded-name group)
7879 (gnus-group-unread group))
7880 (format " (Type %s to exit %s)"
7881 (single-key-description cmd)
7882 (gnus-group-decoded-name gnus-newsgroup-name)))))
7883 ;; Confirm auto selection.
7884 (setq key (car (setq keve (gnus-read-event-char prompt)))
7885 ended t)
7886 (cond
7887 ((assq key keystrokes)
7888 (let ((obuf (current-buffer)))
7889 (switch-to-buffer gnus-group-buffer)
7890 (when group
7891 (gnus-group-jump-to-group group))
7892 (eval (cadr (assq key keystrokes)))
7893 (setq group (gnus-group-group-name))
7894 (switch-to-buffer obuf))
7895 (setq ended nil))
7896 ((equal key cmd)
7897 (if (or (not group)
7898 (gnus-ephemeral-group-p gnus-newsgroup-name))
7899 (gnus-summary-exit)
7900 (gnus-summary-next-group nil group backward)))
7901 (t
7902 (push (cdr keve) unread-command-events))))))
7903
7904 (defun gnus-summary-next-unread-article ()
7905 "Select unread article after current one."
7906 (interactive)
7907 (gnus-summary-next-article
7908 (or (not (eq gnus-summary-goto-unread 'never))
7909 (gnus-summary-last-article-p (gnus-summary-article-number)))
7910 (and gnus-auto-select-same
7911 (gnus-summary-article-subject))))
7912
7913 (defun gnus-summary-prev-article (&optional unread subject)
7914 "Select the article before the current one.
7915 If UNREAD is non-nil, only unread articles are selected."
7916 (interactive "P")
7917 (gnus-summary-next-article unread subject t))
7918
7919 (defun gnus-summary-prev-unread-article ()
7920 "Select unread article before current one."
7921 (interactive)
7922 (gnus-summary-prev-article
7923 (or (not (eq gnus-summary-goto-unread 'never))
7924 (gnus-summary-first-article-p (gnus-summary-article-number)))
7925 (and gnus-auto-select-same
7926 (gnus-summary-article-subject))))
7927
7928 (declare-function gnus-article-only-boring-p "gnus-art" ())
7929
7930 (defun gnus-summary-next-page (&optional lines circular stop)
7931 "Show next page of the selected article.
7932 If at the end of the current article, select the next article.
7933 LINES says how many lines should be scrolled up.
7934
7935 If CIRCULAR is non-nil, go to the start of the article instead of
7936 selecting the next article when reaching the end of the current
7937 article.
7938
7939 If STOP is non-nil, just stop when reaching the end of the message.
7940
7941 Also see the variable `gnus-article-skip-boring'."
7942 (interactive "P")
7943 (gnus-set-global-variables)
7944 (let ((article (gnus-summary-article-number))
7945 (article-window (get-buffer-window gnus-article-buffer t))
7946 endp)
7947 ;; If the buffer is empty, we have no article.
7948 (unless article
7949 (error "No article to select"))
7950 (gnus-configure-windows 'article)
7951 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7952 (if (and (eq gnus-summary-goto-unread 'never)
7953 (not (gnus-summary-last-article-p article)))
7954 (gnus-summary-next-article)
7955 (gnus-summary-next-unread-article))
7956 (if (or (null gnus-current-article)
7957 (null gnus-article-current)
7958 (/= article (cdr gnus-article-current))
7959 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7960 ;; Selected subject is different from current article's.
7961 (gnus-summary-display-article article)
7962 (when article-window
7963 (gnus-eval-in-buffer-window gnus-article-buffer
7964 (setq endp (or (gnus-article-next-page lines)
7965 (gnus-article-only-boring-p))))
7966 (when endp
7967 (cond ((or stop gnus-summary-stop-at-end-of-message)
7968 (gnus-message 3 "End of message"))
7969 (circular
7970 (gnus-summary-beginning-of-article))
7971 (lines
7972 (gnus-message 3 "End of message"))
7973 ((null lines)
7974 (if (and (eq gnus-summary-goto-unread 'never)
7975 (not (gnus-summary-last-article-p article)))
7976 (gnus-summary-next-article)
7977 (gnus-summary-next-unread-article))))))))
7978 (gnus-summary-recenter)
7979 (gnus-summary-position-point)))
7980
7981 (defun gnus-summary-prev-page (&optional lines move)
7982 "Show previous page of selected article.
7983 Argument LINES specifies lines to be scrolled down.
7984 If MOVE, move to the previous unread article if point is at
7985 the beginning of the buffer."
7986 (interactive "P")
7987 (let ((article (gnus-summary-article-number))
7988 (article-window (get-buffer-window gnus-article-buffer t))
7989 endp)
7990 (gnus-configure-windows 'article)
7991 (if (or (null gnus-current-article)
7992 (null gnus-article-current)
7993 (/= article (cdr gnus-article-current))
7994 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7995 ;; Selected subject is different from current article's.
7996 (gnus-summary-display-article article)
7997 (gnus-summary-recenter)
7998 (when article-window
7999 (gnus-eval-in-buffer-window gnus-article-buffer
8000 (setq endp (gnus-article-prev-page lines)))
8001 (when (and move endp)
8002 (cond (lines
8003 (gnus-message 3 "Beginning of message"))
8004 ((null lines)
8005 (if (and (eq gnus-summary-goto-unread 'never)
8006 (not (gnus-summary-first-article-p article)))
8007 (gnus-summary-prev-article)
8008 (gnus-summary-prev-unread-article))))))))
8009 (gnus-summary-position-point))
8010
8011 (defun gnus-summary-prev-page-or-article (&optional lines)
8012 "Show previous page of selected article.
8013 Argument LINES specifies lines to be scrolled down.
8014 If at the beginning of the article, go to the next article."
8015 (interactive "P")
8016 (gnus-summary-prev-page lines t))
8017
8018 (defun gnus-summary-scroll-up (lines)
8019 "Scroll up (or down) one line current article.
8020 Argument LINES specifies lines to be scrolled up (or down if negative).
8021 If no article is selected, then the current article will be selected first."
8022 (interactive "p")
8023 (gnus-configure-windows 'article)
8024 (gnus-summary-show-thread)
8025 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8026 (gnus-eval-in-buffer-window gnus-article-buffer
8027 (cond ((> lines 0)
8028 (when (gnus-article-next-page lines)
8029 (gnus-message 3 "End of message")))
8030 ((< lines 0)
8031 (gnus-article-prev-page (- lines))))))
8032 (gnus-summary-recenter)
8033 (gnus-summary-position-point))
8034
8035 (defun gnus-summary-scroll-down (lines)
8036 "Scroll down (or up) one line current article.
8037 Argument LINES specifies lines to be scrolled down (or up if negative).
8038 If no article is selected, then the current article will be selected first."
8039 (interactive "p")
8040 (gnus-summary-scroll-up (- lines)))
8041
8042 (defun gnus-summary-next-same-subject ()
8043 "Select next article which has the same subject as current one."
8044 (interactive)
8045 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8046
8047 (defun gnus-summary-prev-same-subject ()
8048 "Select previous article which has the same subject as current one."
8049 (interactive)
8050 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8051
8052 (defun gnus-summary-next-unread-same-subject ()
8053 "Select next unread article which has the same subject as current one."
8054 (interactive)
8055 (gnus-summary-next-article t (gnus-summary-article-subject)))
8056
8057 (defun gnus-summary-prev-unread-same-subject ()
8058 "Select previous unread article which has the same subject as current one."
8059 (interactive)
8060 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8061
8062 (defun gnus-summary-first-unread-article ()
8063 "Select the first unread article.
8064 Return nil if there are no unread articles."
8065 (interactive)
8066 (prog1
8067 (when (gnus-summary-first-subject t)
8068 (gnus-summary-show-thread)
8069 (gnus-summary-first-subject t)
8070 (gnus-summary-display-article (gnus-summary-article-number)))
8071 (gnus-summary-position-point)))
8072
8073 (defun gnus-summary-first-unread-subject ()
8074 "Place the point on the subject line of the first unread article.
8075 Return nil if there are no unread articles."
8076 (interactive)
8077 (prog1
8078 (when (gnus-summary-first-subject t)
8079 (gnus-summary-show-thread)
8080 (gnus-summary-first-subject t))
8081 (gnus-summary-position-point)))
8082
8083 (defun gnus-summary-first-unseen-subject ()
8084 "Place the point on the subject line of the first unseen article.
8085 Return nil if there are no unseen articles."
8086 (interactive)
8087 (prog1
8088 (when (gnus-summary-first-subject nil nil t)
8089 (gnus-summary-show-thread)
8090 (gnus-summary-first-subject nil nil t))
8091 (gnus-summary-position-point)))
8092
8093 (defun gnus-summary-first-unseen-or-unread-subject ()
8094 "Place the point on the subject line of the first unseen and unread article.
8095 If all article have been seen, on the subject line of the first unread
8096 article."
8097 (interactive)
8098 (prog1
8099 (unless (when (gnus-summary-first-subject nil nil t)
8100 (gnus-summary-show-thread)
8101 (gnus-summary-first-subject nil nil t))
8102 (when (gnus-summary-first-subject t)
8103 (gnus-summary-show-thread)
8104 (gnus-summary-first-subject t)))
8105 (gnus-summary-position-point)))
8106
8107 (defun gnus-summary-first-article ()
8108 "Select the first article.
8109 Return nil if there are no articles."
8110 (interactive)
8111 (prog1
8112 (when (gnus-summary-first-subject)
8113 (gnus-summary-show-thread)
8114 (gnus-summary-first-subject)
8115 (gnus-summary-display-article (gnus-summary-article-number)))
8116 (gnus-summary-position-point)))
8117
8118 (defun gnus-summary-best-unread-article (&optional arg)
8119 "Select the unread article with the highest score.
8120 If given a prefix argument, select the next unread article that has a
8121 score higher than the default score."
8122 (interactive "P")
8123 (let ((article (if arg
8124 (gnus-summary-better-unread-subject)
8125 (gnus-summary-best-unread-subject))))
8126 (if article
8127 (gnus-summary-goto-article article)
8128 (error "No unread articles"))))
8129
8130 (defun gnus-summary-best-unread-subject ()
8131 "Select the unread subject with the highest score."
8132 (interactive)
8133 (let ((best -1000000)
8134 (data gnus-newsgroup-data)
8135 article score)
8136 (while data
8137 (and (gnus-data-unread-p (car data))
8138 (> (setq score
8139 (gnus-summary-article-score (gnus-data-number (car data))))
8140 best)
8141 (setq best score
8142 article (gnus-data-number (car data))))
8143 (setq data (cdr data)))
8144 (when article
8145 (gnus-summary-goto-subject article))
8146 (gnus-summary-position-point)
8147 article))
8148
8149 (defun gnus-summary-better-unread-subject ()
8150 "Select the first unread subject that has a score over the default score."
8151 (interactive)
8152 (let ((data gnus-newsgroup-data)
8153 article score)
8154 (while (and (setq article (gnus-data-number (car data)))
8155 (or (gnus-data-read-p (car data))
8156 (not (> (gnus-summary-article-score article)
8157 gnus-summary-default-score))))
8158 (setq data (cdr data)))
8159 (when article
8160 (gnus-summary-goto-subject article))
8161 (gnus-summary-position-point)
8162 article))
8163
8164 (defun gnus-summary-last-subject ()
8165 "Go to the last displayed subject line in the group."
8166 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8167 (when article
8168 (gnus-summary-goto-subject article))))
8169
8170 (defun gnus-summary-goto-article (article &optional all-headers force)
8171 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8172 If ALL-HEADERS is non-nil, no header lines are hidden.
8173 If FORCE, go to the article even if it isn't displayed. If FORCE
8174 is a number, it is the line the article is to be displayed on."
8175 (interactive
8176 (list
8177 (gnus-completing-read
8178 "Article number or Message-ID"
8179 (mapcar 'int-to-string gnus-newsgroup-limit))
8180 current-prefix-arg
8181 t))
8182 (prog1
8183 (if (and (stringp article)
8184 (string-match "@\\|%40" article))
8185 (gnus-summary-refer-article article)
8186 (when (stringp article)
8187 (setq article (string-to-number article)))
8188 (if (gnus-summary-goto-subject article force)
8189 (gnus-summary-display-article article all-headers)
8190 (gnus-message 4 "Couldn't go to article %s" article) nil))
8191 (gnus-summary-position-point)))
8192
8193 (defun gnus-summary-goto-last-article ()
8194 "Go to the previously read article."
8195 (interactive)
8196 (prog1
8197 (when gnus-last-article
8198 (gnus-summary-goto-article gnus-last-article nil t))
8199 (gnus-summary-position-point)))
8200
8201 (defun gnus-summary-pop-article (number)
8202 "Pop one article off the history and go to the previous.
8203 NUMBER articles will be popped off."
8204 (interactive "p")
8205 (let (to)
8206 (setq gnus-newsgroup-history
8207 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8208 (if to
8209 (gnus-summary-goto-article (car to) nil t)
8210 (error "Article history empty")))
8211 (gnus-summary-position-point))
8212
8213 ;; Summary commands and functions for limiting the summary buffer.
8214
8215 (defun gnus-summary-limit-to-articles (n)
8216 "Limit the summary buffer to the next N articles.
8217 If not given a prefix, use the process marked articles instead."
8218 (interactive "P")
8219 (prog1
8220 (let ((articles (gnus-summary-work-articles n)))
8221 (setq gnus-newsgroup-processable nil)
8222 (gnus-summary-limit articles))
8223 (gnus-summary-position-point)))
8224
8225 (defun gnus-summary-pop-limit (&optional total)
8226 "Restore the previous limit.
8227 If given a prefix, remove all limits."
8228 (interactive "P")
8229 (when total
8230 (setq gnus-newsgroup-limits
8231 (list (mapcar (lambda (h) (mail-header-number h))
8232 gnus-newsgroup-headers))))
8233 (unless gnus-newsgroup-limits
8234 (error "No limit to pop"))
8235 (prog1
8236 (gnus-summary-limit nil 'pop)
8237 (gnus-summary-position-point)))
8238
8239 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8240 "Limit the summary buffer to articles that have subjects that match a regexp.
8241 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8242 (interactive
8243 (list (read-string (if current-prefix-arg
8244 "Exclude subject (regexp): "
8245 "Limit to subject (regexp): "))
8246 nil current-prefix-arg))
8247 (unless header
8248 (setq header "subject"))
8249 (when (not (equal "" subject))
8250 (prog1
8251 (let ((articles (gnus-summary-find-matching
8252 (or header "subject") subject 'all nil nil
8253 not-matching)))
8254 (unless articles
8255 (error "Found no matches for \"%s\"" subject))
8256 (gnus-summary-limit articles))
8257 (gnus-summary-position-point))))
8258
8259 (defun gnus-summary-limit-to-author (from &optional not-matching)
8260 "Limit the summary buffer to articles that have authors that match a regexp.
8261 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8262 (interactive
8263 (list (let* ((header (gnus-summary-article-header))
8264 (default (and header (car (mail-header-parse-address
8265 (mail-header-from header))))))
8266 (read-string (concat (if current-prefix-arg
8267 "Exclude author (regexp"
8268 "Limit to author (regexp")
8269 (if default
8270 (concat ", default \"" default "\"): ")
8271 "): "))
8272 nil nil
8273 default))
8274 current-prefix-arg))
8275 (gnus-summary-limit-to-subject from "from" not-matching))
8276
8277 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8278 "Limit the summary buffer to articles with the given RECIPIENT.
8279
8280 If NOT-MATCHING, exclude RECIPIENT.
8281
8282 To and Cc headers are checked. You need to include them in
8283 `nnmail-extra-headers'."
8284 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8285 (interactive
8286 (list (read-string (format "%s recipient (regexp): "
8287 (if current-prefix-arg "Exclude" "Limit to")))
8288 current-prefix-arg))
8289 (when (not (equal "" recipient))
8290 (prog1 (let* ((to
8291 (if (memq 'To nnmail-extra-headers)
8292 (gnus-summary-find-matching
8293 (cons 'extra 'To) recipient 'all nil nil
8294 not-matching)
8295 (gnus-message
8296 1 "`To' isn't present in `nnmail-extra-headers'")
8297 (sit-for 1)
8298 nil))
8299 (cc
8300 (if (memq 'Cc nnmail-extra-headers)
8301 (gnus-summary-find-matching
8302 (cons 'extra 'Cc) recipient 'all nil nil
8303 not-matching)
8304 (gnus-message
8305 1 "`Cc' isn't present in `nnmail-extra-headers'")
8306 (sit-for 1)
8307 nil))
8308 (articles
8309 (if not-matching
8310 ;; We need the numbers that are in both lists:
8311 (mapcar (lambda (a)
8312 (and (memq a to) a))
8313 cc)
8314 (nconc to cc))))
8315 (unless articles
8316 (error "Found no matches for \"%s\"" recipient))
8317 (gnus-summary-limit articles))
8318 (gnus-summary-position-point))))
8319
8320 (defun gnus-summary-limit-to-address (address &optional not-matching)
8321 "Limit the summary buffer to articles with the given ADDRESS.
8322
8323 If NOT-MATCHING, exclude ADDRESS.
8324
8325 To, Cc and From headers are checked. You need to include `To' and `Cc'
8326 in `nnmail-extra-headers'."
8327 (interactive
8328 (list (read-string (format "%s address (regexp): "
8329 (if current-prefix-arg "Exclude" "Limit to")))
8330 current-prefix-arg))
8331 (when (not (equal "" address))
8332 (prog1 (let* ((to
8333 (if (memq 'To nnmail-extra-headers)
8334 (gnus-summary-find-matching
8335 (cons 'extra 'To) address 'all nil nil
8336 not-matching)
8337 (gnus-message
8338 1 "`To' isn't present in `nnmail-extra-headers'")
8339 (sit-for 1)
8340 t))
8341 (cc
8342 (if (memq 'Cc nnmail-extra-headers)
8343 (gnus-summary-find-matching
8344 (cons 'extra 'Cc) address 'all nil nil
8345 not-matching)
8346 (gnus-message
8347 1 "`Cc' isn't present in `nnmail-extra-headers'")
8348 (sit-for 1)
8349 t))
8350 (from
8351 (gnus-summary-find-matching "from" address
8352 'all nil nil not-matching))
8353 (articles
8354 (if not-matching
8355 ;; We need the numbers that are in all lists:
8356 (if (eq cc t)
8357 (if (eq to t)
8358 from
8359 (mapcar (lambda (a) (car (memq a from))) to))
8360 (if (eq to t)
8361 (mapcar (lambda (a) (car (memq a from))) cc)
8362 (mapcar (lambda (a) (car (memq a from)))
8363 (mapcar (lambda (a) (car (memq a to)))
8364 cc))))
8365 (nconc (if (eq to t) nil to)
8366 (if (eq cc t) nil cc)
8367 from))))
8368 (unless articles
8369 (error "Found no matches for \"%s\"" address))
8370 (gnus-summary-limit articles))
8371 (gnus-summary-position-point))))
8372
8373 (defun gnus-summary-limit-strange-charsets-predicate (header)
8374 (when (fboundp 'char-charset)
8375 (let ((string (concat (mail-header-subject header)
8376 (mail-header-from header)))
8377 charset found)
8378 (dotimes (i (1- (length string)))
8379 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8380 (when (string-match "unicode\\|big\\|japanese" charset)
8381 (setq found t)))
8382 found)))
8383
8384 (defun gnus-summary-limit-to-predicate (predicate)
8385 "Limit to articles where PREDICATE returns non-nil.
8386 PREDICATE will be called with the header structures of the
8387 articles."
8388 (let ((articles nil)
8389 (case-fold-search t))
8390 (dolist (header gnus-newsgroup-headers)
8391 (when (funcall predicate header)
8392 (push (mail-header-number header) articles)))
8393 (gnus-summary-limit (nreverse articles))))
8394
8395 (defun gnus-summary-limit-to-age (age &optional younger-p)
8396 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8397 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8398 articles that are younger than AGE days."
8399 (interactive
8400 (let ((younger current-prefix-arg)
8401 (days-got nil)
8402 days)
8403 (while (not days-got)
8404 (setq days (if younger
8405 (read-string "Limit to articles younger than (in days, older when negative): ")
8406 (read-string
8407 "Limit to articles older than (in days, younger when negative): ")))
8408 (when (> (length days) 0)
8409 (setq days (read days)))
8410 (if (numberp days)
8411 (progn
8412 (setq days-got t)
8413 (when (< days 0)
8414 (setq younger (not younger))
8415 (setq days (* days -1))))
8416 (message "Please enter a number.")
8417 (sleep-for 1)))
8418 (list days younger)))
8419 (prog1
8420 (let ((data gnus-newsgroup-data)
8421 (cutoff (days-to-time age))
8422 articles d date is-younger)
8423 (while (setq d (pop data))
8424 (when (and (vectorp (gnus-data-header d))
8425 (setq date (mail-header-date (gnus-data-header d))))
8426 (setq is-younger (time-less-p
8427 (time-since (gnus-date-get-time date))
8428 cutoff))
8429 (when (if younger-p
8430 is-younger
8431 (not is-younger))
8432 (push (gnus-data-number d) articles))))
8433 (gnus-summary-limit (nreverse articles)))
8434 (gnus-summary-position-point)))
8435
8436 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8437 "Limit the summary buffer to articles that match an `extra' header."
8438 (interactive
8439 (let ((header
8440 (intern
8441 (gnus-completing-read
8442 (if current-prefix-arg
8443 "Exclude extra header"
8444 "Limit extra header")
8445 (mapcar 'symbol-name gnus-extra-headers)
8446 t nil nil
8447 (symbol-name (car gnus-extra-headers))))))
8448 (list header
8449 (read-string (format "%s header %s (regexp): "
8450 (if current-prefix-arg "Exclude" "Limit to")
8451 header))
8452 current-prefix-arg)))
8453 (when (not (equal "" regexp))
8454 (prog1
8455 (let ((articles (gnus-summary-find-matching
8456 (cons 'extra header) regexp 'all nil nil
8457 not-matching)))
8458 (unless articles
8459 (error "Found no matches for \"%s\"" regexp))
8460 (gnus-summary-limit articles))
8461 (gnus-summary-position-point))))
8462
8463 (defun gnus-summary-limit-to-display-predicate ()
8464 "Limit the summary buffer to the predicated in the `display' group parameter."
8465 (interactive)
8466 (unless gnus-newsgroup-display
8467 (error "There is no `display' group parameter"))
8468 (let (articles)
8469 (dolist (gnus-number gnus-newsgroup-articles)
8470 (when (funcall gnus-newsgroup-display)
8471 (push gnus-number articles)))
8472 (gnus-summary-limit articles))
8473 (gnus-summary-position-point))
8474
8475 (defun gnus-summary-limit-to-unread (&optional all)
8476 "Limit the summary buffer to articles that are not marked as read.
8477 If ALL is non-nil, limit strictly to unread articles."
8478 (interactive "P")
8479 (if all
8480 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8481 (gnus-summary-limit-to-marks
8482 ;; Concat all the marks that say that an article is read and have
8483 ;; those removed.
8484 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8485 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8486 gnus-low-score-mark gnus-expirable-mark
8487 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8488 gnus-duplicate-mark)
8489 'reverse)))
8490
8491 (defun gnus-summary-limit-to-headers (match &optional reverse)
8492 "Limit the summary buffer to articles that have headers that match MATCH.
8493 If REVERSE (the prefix), limit to articles that don't match."
8494 (interactive "sMatch headers (regexp): \nP")
8495 (gnus-summary-limit-to-bodies match reverse t))
8496
8497 (declare-function article-goto-body "gnus-art" ())
8498
8499 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8500 "Limit the summary buffer to articles that have bodies that match MATCH.
8501 If REVERSE (the prefix), limit to articles that don't match."
8502 (interactive "sMatch body (regexp): \nP")
8503 (let ((articles nil)
8504 (gnus-select-article-hook nil) ;Disable hook.
8505 (gnus-article-prepare-hook nil)
8506 (gnus-use-article-prefetch nil)
8507 (gnus-keep-backlog nil)
8508 (gnus-break-pages nil)
8509 (gnus-summary-display-arrow nil)
8510 (gnus-updated-mode-lines nil)
8511 (gnus-auto-center-summary nil)
8512 (gnus-display-mime-function nil))
8513 (dolist (data gnus-newsgroup-data)
8514 (let (gnus-mark-article-hook)
8515 (gnus-summary-select-article t t nil (gnus-data-number data)))
8516 (with-current-buffer gnus-article-buffer
8517 (article-goto-body)
8518 (let* ((case-fold-search t)
8519 (found (if headersp
8520 (re-search-backward match nil t)
8521 (re-search-forward match nil t))))
8522 (when (or (and found
8523 (not reverse))
8524 (and (not found)
8525 reverse))
8526 (push (gnus-data-number data) articles)))))
8527 (if (not articles)
8528 (message "No messages matched")
8529 (gnus-summary-limit articles)))
8530 (gnus-summary-position-point))
8531
8532 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8533 "Limit the summary buffer to articles that aren't part on any thread.
8534 If THREADSP (the prefix), limit to articles that are in threads."
8535 (interactive "P")
8536 (let ((articles nil)
8537 thread-articles
8538 threads)
8539 (dolist (thread gnus-newsgroup-threads)
8540 (if (stringp (car thread))
8541 (dolist (thread (cdr thread))
8542 (push thread threads))
8543 (push thread threads)))
8544 (dolist (thread threads)
8545 (setq thread-articles (gnus-articles-in-thread thread))
8546 (when (or (and threadsp
8547 (> (length thread-articles) 1))
8548 (and (not threadsp)
8549 (= (length thread-articles) 1)))
8550 (setq articles (nconc thread-articles articles))))
8551 (if (not articles)
8552 (message "No messages matched")
8553 (gnus-summary-limit articles))
8554 (gnus-summary-position-point)))
8555
8556 (defun gnus-summary-limit-to-replied (&optional unreplied)
8557 "Limit the summary buffer to replied articles.
8558 If UNREPLIED (the prefix), limit to unreplied articles."
8559 (interactive "P")
8560 (if unreplied
8561 (gnus-summary-limit
8562 (gnus-set-difference gnus-newsgroup-articles
8563 gnus-newsgroup-replied))
8564 (gnus-summary-limit gnus-newsgroup-replied))
8565 (gnus-summary-position-point))
8566
8567 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8568 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8569 If REVERSE, limit the summary buffer to articles that are marked
8570 with MARKS. MARKS can either be a string of marks or a list of marks.
8571 Returns how many articles were removed."
8572 (interactive "sMarks: ")
8573 (gnus-summary-limit-to-marks marks t))
8574
8575 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8576 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8577 If REVERSE (the prefix), limit the summary buffer to articles that are
8578 not marked with MARKS. MARKS can either be a string of marks or a
8579 list of marks.
8580 Returns how many articles were removed."
8581 (interactive "sMarks: \nP")
8582 (prog1
8583 (let ((data gnus-newsgroup-data)
8584 (marks (if (listp marks) marks
8585 (append marks nil))) ; Transform to list.
8586 articles)
8587 (while data
8588 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8589 (memq (gnus-data-mark (car data)) marks))
8590 (push (gnus-data-number (car data)) articles))
8591 (setq data (cdr data)))
8592 (gnus-summary-limit articles))
8593 (gnus-summary-position-point)))
8594
8595 (defun gnus-summary-limit-to-score (score)
8596 "Limit to articles with score at or above SCORE."
8597 (interactive "NLimit to articles with score of at least: ")
8598 (let ((data gnus-newsgroup-data)
8599 articles)
8600 (while data
8601 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8602 score)
8603 (push (gnus-data-number (car data)) articles))
8604 (setq data (cdr data)))
8605 (prog1
8606 (gnus-summary-limit articles)
8607 (gnus-summary-position-point))))
8608
8609 (defun gnus-summary-limit-to-unseen ()
8610 "Limit to unseen articles."
8611 (interactive)
8612 (prog1
8613 (gnus-summary-limit gnus-newsgroup-unseen)
8614 (gnus-summary-position-point)))
8615
8616 (defun gnus-summary-limit-include-thread (id)
8617 "Display all the hidden articles that is in the thread with ID in it.
8618 When called interactively, ID is the Message-ID of the current
8619 article."
8620 (interactive (list (mail-header-id (gnus-summary-article-header))))
8621 (let ((articles (gnus-articles-in-thread
8622 (gnus-id-to-thread (gnus-root-id id))))
8623 ;;we REALLY want the whole thread---this prevents cut-threads
8624 ;;from removing the thread we want to include.
8625 (gnus-fetch-old-headers nil)
8626 (gnus-build-sparse-threads nil))
8627 (prog1
8628 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8629 (gnus-summary-limit-include-matching-articles
8630 "subject"
8631 (regexp-quote (gnus-simplify-subject-re
8632 (mail-header-subject (gnus-id-to-header id)))))
8633 (gnus-summary-position-point))))
8634
8635 (defun gnus-summary-limit-include-matching-articles (header regexp)
8636 "Display all the hidden articles that have HEADERs that match REGEXP."
8637 (interactive (list (read-string "Match on header: ")
8638 (read-string "Regexp: ")))
8639 (let ((articles (gnus-find-matching-articles header regexp)))
8640 (prog1
8641 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8642 (gnus-summary-position-point))))
8643
8644 (defun gnus-summary-insert-dormant-articles ()
8645 "Insert all the dormant articles for this group into the current buffer."
8646 (interactive)
8647 (let ((gnus-verbose (max 6 gnus-verbose)))
8648 (if (not gnus-newsgroup-dormant)
8649 (gnus-message 3 "No dormant articles for this group")
8650 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8651
8652 (defun gnus-summary-insert-ticked-articles ()
8653 "Insert ticked articles for this group into the current buffer."
8654 (interactive)
8655 (let ((gnus-verbose (max 6 gnus-verbose)))
8656 (if (not gnus-newsgroup-marked)
8657 (gnus-message 3 "No ticked articles for this group")
8658 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8659
8660 (defun gnus-summary-limit-include-dormant ()
8661 "Display all the hidden articles that are marked as dormant.
8662 Note that this command only works on a subset of the articles currently
8663 fetched for this group."
8664 (interactive)
8665 (unless gnus-newsgroup-dormant
8666 (error "There are no dormant articles in this group"))
8667 (prog1
8668 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8669 (gnus-summary-position-point)))
8670
8671 (defun gnus-summary-include-articles (articles)
8672 "Fetch the headers for ARTICLES and then display the summary lines."
8673 (let ((gnus-inhibit-demon t)
8674 (gnus-agent nil)
8675 (gnus-read-all-available-headers t))
8676 (setq gnus-newsgroup-headers
8677 (gnus-merge
8678 'list gnus-newsgroup-headers
8679 (gnus-fetch-headers articles nil t)
8680 'gnus-article-sort-by-number))
8681 (setq gnus-newsgroup-articles
8682 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8683 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8684
8685 (defun gnus-summary-limit-exclude-dormant ()
8686 "Hide all dormant articles."
8687 (interactive)
8688 (prog1
8689 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8690 (gnus-summary-position-point)))
8691
8692 (defun gnus-summary-limit-exclude-childless-dormant ()
8693 "Hide all dormant articles that have no children."
8694 (interactive)
8695 (let ((data (gnus-data-list t))
8696 articles d children)
8697 ;; Find all articles that are either not dormant or have
8698 ;; children.
8699 (while (setq d (pop data))
8700 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8701 (and (setq children
8702 (gnus-article-children (gnus-data-number d)))
8703 (let (found)
8704 (while children
8705 (when (memq (car children) articles)
8706 (setq children nil
8707 found t))
8708 (pop children))
8709 found)))
8710 (push (gnus-data-number d) articles)))
8711 ;; Do the limiting.
8712 (prog1
8713 (gnus-summary-limit articles)
8714 (gnus-summary-position-point))))
8715
8716 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8717 "Mark all unread excluded articles as read.
8718 If ALL, mark even excluded ticked and dormants as read."
8719 (interactive "P")
8720 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8721 (let ((articles (gnus-sorted-ndifference
8722 (sort
8723 (mapcar (lambda (h) (mail-header-number h))
8724 gnus-newsgroup-headers)
8725 '<)
8726 gnus-newsgroup-limit))
8727 article)
8728 (setq gnus-newsgroup-unreads
8729 (gnus-sorted-intersection gnus-newsgroup-unreads
8730 gnus-newsgroup-limit))
8731 (if all
8732 (setq gnus-newsgroup-dormant nil
8733 gnus-newsgroup-marked nil
8734 gnus-newsgroup-reads
8735 (nconc
8736 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8737 gnus-newsgroup-reads))
8738 (while (setq article (pop articles))
8739 (unless (or (memq article gnus-newsgroup-dormant)
8740 (memq article gnus-newsgroup-marked))
8741 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8742
8743 (defun gnus-summary-limit (articles &optional pop)
8744 (if pop
8745 ;; We pop the previous limit off the stack and use that.
8746 (setq articles (car gnus-newsgroup-limits)
8747 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8748 ;; We use the new limit, so we push the old limit on the stack.
8749 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8750 ;; Set the limit.
8751 (setq gnus-newsgroup-limit articles)
8752 (let ((total (length gnus-newsgroup-data))
8753 (data (gnus-data-find-list (gnus-summary-article-number)))
8754 (gnus-summary-mark-below nil) ; Inhibit this.
8755 found)
8756 ;; This will do all the work of generating the new summary buffer
8757 ;; according to the new limit.
8758 (gnus-summary-prepare)
8759 ;; Hide any threads, possibly.
8760 (gnus-summary-maybe-hide-threads)
8761 ;; Try to return to the article you were at, or one in the
8762 ;; neighborhood.
8763 (when data
8764 ;; We try to find some article after the current one.
8765 (while data
8766 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8767 (setq data nil
8768 found t))
8769 (setq data (cdr data))))
8770 (unless found
8771 ;; If there is no data, that means that we were after the last
8772 ;; article. The same goes when we can't find any articles
8773 ;; after the current one.
8774 (goto-char (point-max))
8775 (gnus-summary-find-prev))
8776 (gnus-set-mode-line 'summary)
8777 ;; We return how many articles were removed from the summary
8778 ;; buffer as a result of the new limit.
8779 (- total (length gnus-newsgroup-data))))
8780
8781 (defsubst gnus-invisible-cut-children (threads)
8782 (let ((num 0))
8783 (while threads
8784 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8785 (incf num))
8786 (pop threads))
8787 (< num 2)))
8788
8789 (defsubst gnus-cut-thread (thread)
8790 "Go forwards in the thread until we find an article that we want to display."
8791 (when (or (eq gnus-fetch-old-headers 'some)
8792 (eq gnus-fetch-old-headers 'invisible)
8793 (numberp gnus-fetch-old-headers)
8794 (eq gnus-build-sparse-threads 'some)
8795 (eq gnus-build-sparse-threads 'more))
8796 ;; Deal with old-fetched headers and sparse threads.
8797 (while (and
8798 thread
8799 (or
8800 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8801 (gnus-summary-article-ancient-p
8802 (mail-header-number (car thread))))
8803 (if (or (<= (length (cdr thread)) 1)
8804 (eq gnus-fetch-old-headers 'invisible))
8805 (setq gnus-newsgroup-limit
8806 (delq (mail-header-number (car thread))
8807 gnus-newsgroup-limit)
8808 thread (cadr thread))
8809 (when (gnus-invisible-cut-children (cdr thread))
8810 (let ((th (cdr thread)))
8811 (while th
8812 (if (memq (mail-header-number (caar th))
8813 gnus-newsgroup-limit)
8814 (setq thread (car th)
8815 th nil)
8816 (setq th (cdr th))))))))))
8817 thread)
8818
8819 (defun gnus-cut-threads (threads)
8820 "Cut off all uninteresting articles from the beginning of THREADS."
8821 (when (or (eq gnus-fetch-old-headers 'some)
8822 (eq gnus-fetch-old-headers 'invisible)
8823 (numberp gnus-fetch-old-headers)
8824 (eq gnus-build-sparse-threads 'some)
8825 (eq gnus-build-sparse-threads 'more))
8826 (let ((th threads))
8827 (while th
8828 (setcar th (gnus-cut-thread (car th)))
8829 (setq th (cdr th)))))
8830 ;; Remove nixed out threads.
8831 (delq nil threads))
8832
8833 (defun gnus-summary-initial-limit (&optional show-if-empty)
8834 "Figure out what the initial limit is supposed to be on group entry.
8835 This entails weeding out unwanted dormants, low-scored articles,
8836 fetch-old-headers verbiage, and so on."
8837 ;; Most groups have nothing to remove.
8838 (unless (or gnus-inhibit-limiting
8839 (and (null gnus-newsgroup-dormant)
8840 (eq gnus-newsgroup-display 'gnus-not-ignore)
8841 (not (eq gnus-fetch-old-headers 'some))
8842 (not (numberp gnus-fetch-old-headers))
8843 (not (eq gnus-fetch-old-headers 'invisible))
8844 (null gnus-summary-expunge-below)
8845 (not (eq gnus-build-sparse-threads 'some))
8846 (not (eq gnus-build-sparse-threads 'more))
8847 (null gnus-thread-expunge-below)))
8848 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8849 (setq gnus-newsgroup-limit nil)
8850 (mapatoms
8851 (lambda (node)
8852 (unless (car (symbol-value node))
8853 ;; These threads have no parents -- they are roots.
8854 (let ((nodes (cdr (symbol-value node)))
8855 thread)
8856 (while nodes
8857 (if (and gnus-thread-expunge-below
8858 (< (gnus-thread-total-score (car nodes))
8859 gnus-thread-expunge-below))
8860 (gnus-expunge-thread (pop nodes))
8861 (setq thread (pop nodes))
8862 (gnus-summary-limit-children thread))))))
8863 gnus-newsgroup-dependencies)
8864 ;; If this limitation resulted in an empty group, we might
8865 ;; pop the previous limit and use it instead.
8866 (when (and (not gnus-newsgroup-limit)
8867 show-if-empty)
8868 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8869 gnus-newsgroup-limit))
8870
8871 (defun gnus-summary-limit-children (thread)
8872 "Return 1 if this subthread is visible and 0 if it is not."
8873 ;; First we get the number of visible children to this thread. This
8874 ;; is done by recursing down the thread using this function, so this
8875 ;; will really go down to a leaf article first, before slowly
8876 ;; working its way up towards the root.
8877 (when thread
8878 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8879 (children
8880 (if (cdr thread)
8881 (apply '+ (mapcar 'gnus-summary-limit-children
8882 (cdr thread)))
8883 0))
8884 (number (mail-header-number (car thread)))
8885 score)
8886 (if (and
8887 (not (memq number gnus-newsgroup-marked))
8888 (or
8889 ;; If this article is dormant and has absolutely no visible
8890 ;; children, then this article isn't visible.
8891 (and (memq number gnus-newsgroup-dormant)
8892 (zerop children))
8893 ;; If this is "fetch-old-headered" and there is no
8894 ;; visible children, then we don't want this article.
8895 (and (or (eq gnus-fetch-old-headers 'some)
8896 (numberp gnus-fetch-old-headers))
8897 (gnus-summary-article-ancient-p number)
8898 (zerop children))
8899 ;; If this is "fetch-old-headered" and `invisible', then
8900 ;; we don't want this article.
8901 (and (eq gnus-fetch-old-headers 'invisible)
8902 (gnus-summary-article-ancient-p number))
8903 ;; If this is a sparsely inserted article with no children,
8904 ;; we don't want it.
8905 (and (eq gnus-build-sparse-threads 'some)
8906 (gnus-summary-article-sparse-p number)
8907 (zerop children))
8908 ;; If we use expunging, and this article is really
8909 ;; low-scored, then we don't want this article.
8910 (when (and gnus-summary-expunge-below
8911 (< (setq score
8912 (or (cdr (assq number gnus-newsgroup-scored))
8913 gnus-summary-default-score))
8914 gnus-summary-expunge-below))
8915 ;; We increase the expunge-tally here, but that has
8916 ;; nothing to do with the limits, really.
8917 (incf gnus-newsgroup-expunged-tally)
8918 ;; We also mark as read here, if that's wanted.
8919 (when (and gnus-summary-mark-below
8920 (< score gnus-summary-mark-below))
8921 (setq gnus-newsgroup-unreads
8922 (delq number gnus-newsgroup-unreads))
8923 (if gnus-newsgroup-auto-expire
8924 (push number gnus-newsgroup-expirable)
8925 (push (cons number gnus-low-score-mark)
8926 gnus-newsgroup-reads)))
8927 t)
8928 ;; Do the `display' group parameter.
8929 (and gnus-newsgroup-display
8930 (let ((gnus-number number))
8931 (not (funcall gnus-newsgroup-display))))))
8932 ;; Nope, invisible article.
8933 0
8934 ;; Ok, this article is to be visible, so we add it to the limit
8935 ;; and return 1.
8936 (push number gnus-newsgroup-limit)
8937 1))))
8938
8939 (defun gnus-expunge-thread (thread)
8940 "Mark all articles in THREAD as read."
8941 (let* ((number (mail-header-number (car thread))))
8942 (incf gnus-newsgroup-expunged-tally)
8943 ;; We also mark as read here, if that's wanted.
8944 (setq gnus-newsgroup-unreads
8945 (delq number gnus-newsgroup-unreads))
8946 (if gnus-newsgroup-auto-expire
8947 (push number gnus-newsgroup-expirable)
8948 (push (cons number gnus-low-score-mark)
8949 gnus-newsgroup-reads)))
8950 ;; Go recursively through all subthreads.
8951 (mapcar 'gnus-expunge-thread (cdr thread)))
8952
8953 ;; Summary article oriented commands
8954
8955 (defun gnus-summary-refer-parent-article (n)
8956 "Refer parent article N times.
8957 If N is negative, go to ancestor -N instead.
8958 The difference between N and the number of articles fetched is returned."
8959 (interactive "p")
8960 (let ((skip 1)
8961 error header ref)
8962 (when (not (natnump n))
8963 (setq skip (abs n)
8964 n 1))
8965 (while (and (> n 0)
8966 (not error))
8967 (setq header (gnus-summary-article-header))
8968 (if (and (eq (mail-header-number header)
8969 (cdr gnus-article-current))
8970 (equal gnus-newsgroup-name
8971 (car gnus-article-current)))
8972 ;; If we try to find the parent of the currently
8973 ;; displayed article, then we take a look at the actual
8974 ;; References header, since this is slightly more
8975 ;; reliable than the References field we got from the
8976 ;; server.
8977 (with-current-buffer gnus-original-article-buffer
8978 (nnheader-narrow-to-headers)
8979 (unless (setq ref (message-fetch-field "references"))
8980 (when (setq ref (message-fetch-field "in-reply-to"))
8981 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8982 (widen))
8983 (setq ref
8984 ;; It's not the current article, so we take a bet on
8985 ;; the value we got from the server.
8986 (mail-header-references header)))
8987 (if (and ref
8988 (not (equal ref "")))
8989 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8990 (gnus-message 1 "Couldn't find parent"))
8991 (gnus-message 1 "No references in article %d"
8992 (gnus-summary-article-number))
8993 (setq error t))
8994 (decf n))
8995 (gnus-summary-position-point)
8996 n))
8997
8998 (defun gnus-summary-refer-references ()
8999 "Fetch all articles mentioned in the References header.
9000 Return the number of articles fetched."
9001 (interactive)
9002 (let ((ref (mail-header-references (gnus-summary-article-header)))
9003 (current (gnus-summary-article-number))
9004 (n 0))
9005 (if (or (not ref)
9006 (equal ref ""))
9007 (error "No References in the current article")
9008 ;; For each Message-ID in the References header...
9009 (while (string-match "<[^>]*>" ref)
9010 (incf n)
9011 ;; ... fetch that article.
9012 (gnus-summary-refer-article
9013 (prog1 (match-string 0 ref)
9014 (setq ref (substring ref (match-end 0))))))
9015 (gnus-summary-goto-subject current)
9016 (gnus-summary-position-point)
9017 n)))
9018
9019 (defun gnus-delete-duplicate-headers (headers)
9020 ;; First remove leading duplicates.
9021 (while (and (> (length headers) 1)
9022 (= (mail-header-number (car headers))
9023 (mail-header-number (cadr headers))))
9024 (pop headers))
9025 ;; Then the rest.
9026 (let ((result headers))
9027 (while (> (length headers) 1)
9028 (if (= (mail-header-number (car headers))
9029 (mail-header-number (cadr headers)))
9030 (setcdr headers (cddr headers))
9031 (pop headers)))
9032 result))
9033
9034 (defun gnus-summary-refer-thread (&optional limit)
9035 "Fetch all articles in the current thread. For backends that
9036 know how to search for threads (currently only 'nnimap) a
9037 non-numeric prefix arg will use nnir to search the entire
9038 server; without a prefix arg only the current group is
9039 searched. If the variable `gnus-refer-thread-use-nnir' is
9040 non-nil the prefix arg has the reverse meaning. If no
9041 backend-specific 'request-thread function is available fetch
9042 LIMIT (the numerical prefix) old headers. If LIMIT is
9043 non-numeric or nil fetch the number specified by the
9044 `gnus-refer-thread-limit' variable."
9045 (interactive "P")
9046 (gnus-warp-to-article)
9047 (let* ((header (gnus-summary-article-header))
9048 (id (mail-header-id header))
9049 (gnus-inhibit-demon t)
9050 (gnus-summary-ignore-duplicates t)
9051 (gnus-read-all-available-headers t)
9052 (gnus-refer-thread-use-nnir
9053 (if (and (not (null limit)) (listp limit))
9054 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9055 (new-headers
9056 (if (gnus-check-backend-function
9057 'request-thread gnus-newsgroup-name)
9058 (gnus-request-thread header gnus-newsgroup-name)
9059 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9060 gnus-refer-thread-limit))
9061 (last (if (numberp limit)
9062 (min (+ (mail-header-number header)
9063 limit)
9064 gnus-newsgroup-highest)
9065 gnus-newsgroup-highest))
9066 (subject (gnus-simplify-subject
9067 (mail-header-subject header)))
9068 (refs (split-string (or (mail-header-references header)
9069 "")))
9070 (gnus-parse-headers-hook
9071 `(lambda () (goto-char (point-min))
9072 (keep-lines
9073 (regexp-opt ',(append refs (list id subject)))))))
9074 (gnus-fetch-headers (list last) (if (numberp limit)
9075 (* 2 limit) limit) t))))
9076 article-ids new-unreads)
9077 (when (listp new-headers)
9078 (dolist (header new-headers)
9079 (push (mail-header-number header) article-ids))
9080 (setq article-ids (nreverse article-ids))
9081 (setq new-unreads
9082 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9083 (setq gnus-newsgroup-unselected
9084 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9085 (setq gnus-newsgroup-unreads
9086 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9087 (setq gnus-newsgroup-headers
9088 (gnus-delete-duplicate-headers
9089 (gnus-merge
9090 'list gnus-newsgroup-headers new-headers
9091 'gnus-article-sort-by-number)))
9092 (setq gnus-newsgroup-articles
9093 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9094 (gnus-summary-limit-include-thread id)))
9095 (gnus-summary-show-thread))
9096
9097 (defun gnus-summary-open-group-with-article (message-id)
9098 "Open a group containing the article with the given MESSAGE-ID."
9099 (interactive "sMessage-ID: ")
9100 (require 'nndoc)
9101 (with-temp-buffer
9102 ;; Prepare a dummy article
9103 (erase-buffer)
9104 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9105
9106 ;; Prepare pretty modelines for summary and article buffers
9107 (let ((gnus-summary-mode-line-format "Found %G")
9108 (gnus-article-mode-line-format
9109 ;; Group names just get in the way here, especially the
9110 ;; abbreviated ones
9111 (if (string-match "%[gG]" gnus-article-mode-line-format)
9112 (concat (substring gnus-article-mode-line-format
9113 0 (match-beginning 0))
9114 (substring gnus-article-mode-line-format (match-end 0)))
9115 gnus-article-mode-line-format)))
9116
9117 ;; Build an ephemeral group containing the dummy article (hidden)
9118 (gnus-group-read-ephemeral-group
9119 message-id
9120 `(nndoc ,message-id
9121 (nndoc-address ,(current-buffer))
9122 (nndoc-article-type mbox))
9123 :activate
9124 (cons (current-buffer) gnus-current-window-configuration)
9125 (not :request-only)
9126 '(-1) ; :select-articles
9127 (not :parameters)
9128 0)) ; :number
9129 ;; Fetch the desired article
9130 (gnus-summary-refer-article message-id)))
9131
9132 (defun gnus-summary-refer-article (message-id)
9133 "Fetch an article specified by MESSAGE-ID."
9134 (interactive "sMessage-ID: ")
9135 (gnus-warp-to-article)
9136 (when (and (stringp message-id)
9137 (not (zerop (length message-id))))
9138 (setq message-id (gnus-replace-in-string message-id " " ""))
9139 ;; Construct the correct Message-ID if necessary.
9140 ;; Suggested by tale@pawl.rpi.edu.
9141 (unless (string-match "^<" message-id)
9142 (setq message-id (concat "<" message-id)))
9143 (unless (string-match ">$" message-id)
9144 (setq message-id (concat message-id ">")))
9145 ;; People often post MIDs from URLs, so unhex it:
9146 (unless (string-match "@" message-id)
9147 (setq message-id (gnus-url-unhex-string message-id)))
9148 (let* ((header (gnus-id-to-header message-id))
9149 (sparse (and header
9150 (gnus-summary-article-sparse-p
9151 (mail-header-number header))
9152 (memq (mail-header-number header)
9153 gnus-newsgroup-limit)))
9154 number)
9155 (cond
9156 ;; If the article is present in the buffer we just go to it.
9157 ((and header
9158 (or (not (gnus-summary-article-sparse-p
9159 (mail-header-number header)))
9160 sparse))
9161 (prog1
9162 (gnus-summary-goto-article
9163 (mail-header-number header) nil t)
9164 (when sparse
9165 (gnus-summary-update-article (mail-header-number header)))))
9166 (t
9167 ;; We fetch the article.
9168 (catch 'found
9169 (dolist (gnus-override-method (gnus-refer-article-methods))
9170 (when (and (gnus-check-server gnus-override-method)
9171 ;; Fetch the header,
9172 (setq number (gnus-summary-insert-subject message-id)))
9173 ;; and display the article.
9174 (gnus-summary-select-article nil nil nil number)
9175 (throw 'found t)))
9176 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9177
9178 (defun gnus-refer-article-methods ()
9179 "Return a list of referable methods."
9180 (cond
9181 ;; No method, so we default to current and native.
9182 ((null gnus-refer-article-method)
9183 (list gnus-current-select-method gnus-select-method))
9184 ;; Current.
9185 ((eq 'current gnus-refer-article-method)
9186 (list gnus-current-select-method))
9187 ;; List of select methods.
9188 ((not (and (symbolp (car gnus-refer-article-method))
9189 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9190 (let (out)
9191 (dolist (method gnus-refer-article-method)
9192 (push (if (eq 'current method)
9193 gnus-current-select-method
9194 (if (eq 'nnir (car method))
9195 (list
9196 'nnir
9197 (or (cadr method)
9198 (gnus-method-to-server gnus-current-select-method)))
9199 method))
9200 out))
9201 (nreverse out)))
9202 ;; One single select method.
9203 (t
9204 (list gnus-refer-article-method))))
9205
9206 (defun gnus-summary-edit-parameters ()
9207 "Edit the group parameters of the current group."
9208 (interactive)
9209 (gnus-group-edit-group gnus-newsgroup-name 'params))
9210
9211 (defun gnus-summary-customize-parameters ()
9212 "Customize the group parameters of the current group."
9213 (interactive)
9214 (gnus-group-customize gnus-newsgroup-name))
9215
9216 (defun gnus-summary-enter-digest-group (&optional force)
9217 "Enter an nndoc group based on the current article.
9218 If FORCE, force a digest interpretation. If not, try to guess
9219 what the document format is.
9220
9221 To control what happens when you exit the group, see the
9222 `gnus-auto-select-on-ephemeral-exit' variable."
9223 (interactive "P")
9224 (let ((conf gnus-current-window-configuration))
9225 (save-window-excursion
9226 (save-excursion
9227 (let (gnus-article-prepare-hook
9228 gnus-display-mime-function
9229 gnus-break-pages)
9230 (gnus-summary-select-article))))
9231 (setq gnus-current-window-configuration conf)
9232 (let* ((name (format "%s-%d"
9233 (gnus-group-prefixed-name
9234 gnus-newsgroup-name (list 'nndoc ""))
9235 (with-current-buffer gnus-summary-buffer
9236 gnus-current-article)))
9237 (ogroup gnus-newsgroup-name)
9238 (params (append (gnus-info-params (gnus-get-info ogroup))
9239 (list (cons 'to-group ogroup))
9240 (list (cons 'parent-group ogroup))
9241 (list (cons 'save-article-group ogroup))))
9242 (case-fold-search t)
9243 (buf (current-buffer))
9244 dig to-address charset)
9245 (with-current-buffer gnus-original-article-buffer
9246 ;; Have the digest group inherit the main mail address of
9247 ;; the parent article.
9248 (when (setq to-address (or (gnus-fetch-field "reply-to")
9249 (gnus-fetch-field "from")))
9250 (setq params
9251 (append
9252 params
9253 (list (cons 'to-address
9254 (funcall gnus-decode-encoded-address-function
9255 to-address))))))
9256 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9257 (insert-buffer-substring gnus-original-article-buffer)
9258 (narrow-to-region
9259 (goto-char (point-min))
9260 (or (search-forward "\n\n" nil t) (point)))
9261 ;; Remove lines that may lead nndoc to misinterpret the
9262 ;; document type.
9263 (goto-char (point-min))
9264 (delete-matching-lines "^Path:\\|^From ")
9265 ;; Parse charset, and decode content transfer encoding.
9266 (setq charset (mail-content-type-get
9267 (mail-header-parse-content-type
9268 (or (gnus-fetch-field "content-type") ""))
9269 'charset))
9270 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9271 (when encoding
9272 (message-remove-header "content-transfer-encoding")
9273 (goto-char (point-max))
9274 (widen)
9275 (narrow-to-region (point) (point-max))
9276 (mm-decode-content-transfer-encoding
9277 (intern (downcase (mail-header-strip encoding))))))
9278 (widen))
9279 (unwind-protect
9280 (if (let ((gnus-newsgroup-ephemeral-charset
9281 (if charset
9282 (intern (downcase (gnus-strip-whitespace charset)))
9283 gnus-newsgroup-charset))
9284 (gnus-newsgroup-ephemeral-ignored-charsets
9285 gnus-newsgroup-ignored-charsets))
9286 (gnus-group-read-ephemeral-group
9287 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9288 (nndoc-article-type
9289 ,(if force 'mbox 'guess)))
9290 t nil nil nil
9291 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9292 "ADAPT")))))
9293 ;; Make all postings to this group go to the parent group.
9294 (nconc (gnus-info-params (gnus-get-info name))
9295 params)
9296 ;; Couldn't select this doc group.
9297 (switch-to-buffer buf)
9298 (gnus-set-global-variables)
9299 (gnus-configure-windows 'summary)
9300 (gnus-message 3 "Article couldn't be entered?"))
9301 (kill-buffer dig)))))
9302
9303 (defun gnus-summary-read-document (n)
9304 "Open a new group based on the current article(s).
9305 This will allow you to read digests and other similar
9306 documents as newsgroups.
9307 Obeys the standard process/prefix convention."
9308 (interactive "P")
9309 (let* ((ogroup gnus-newsgroup-name)
9310 (params (append (gnus-info-params (gnus-get-info ogroup))
9311 (list (cons 'to-group ogroup))))
9312 group egroup groups vgroup)
9313 (dolist (article (gnus-summary-work-articles n))
9314 (setq group (format "%s-%d" gnus-newsgroup-name article))
9315 (gnus-summary-remove-process-mark article)
9316 (when (gnus-summary-display-article article)
9317 (save-excursion ;;What for?
9318 (with-temp-buffer
9319 (insert-buffer-substring gnus-original-article-buffer)
9320 ;; Remove some headers that may lead nndoc to make
9321 ;; the wrong guess.
9322 (message-narrow-to-head)
9323 (goto-char (point-min))
9324 (delete-matching-lines "^Path:\\|^From ")
9325 (widen)
9326 (if (setq egroup
9327 (gnus-group-read-ephemeral-group
9328 group `(nndoc ,group (nndoc-address ,(current-buffer))
9329 (nndoc-article-type guess))
9330 t nil t))
9331 (progn
9332 ;; Make all postings to this group go to the parent group.
9333 (nconc (gnus-info-params (gnus-get-info egroup))
9334 params)
9335 (push egroup groups))
9336 ;; Couldn't select this doc group.
9337 (gnus-error 3 "Article couldn't be entered"))))))
9338 ;; Now we have selected all the documents.
9339 (cond
9340 ((not groups)
9341 (error "None of the articles could be interpreted as documents"))
9342 ((gnus-group-read-ephemeral-group
9343 (setq vgroup (format
9344 "nnvirtual:%s-%s" gnus-newsgroup-name
9345 (format-time-string "%Y%m%dT%H%M%S")))
9346 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9347 t
9348 (cons (current-buffer) 'summary)))
9349 (t
9350 (error "Couldn't select virtual nndoc group")))))
9351
9352 (defun gnus-summary-widget-forward (arg)
9353 "Move point to the next field or button in the article.
9354 With optional ARG, move across that many fields."
9355 (interactive "p")
9356 (gnus-summary-select-article)
9357 (gnus-configure-windows 'article)
9358 (select-window (gnus-get-buffer-window gnus-article-buffer))
9359 (widget-forward arg))
9360
9361 (defun gnus-summary-widget-backward (arg)
9362 "Move point to the previous field or button in the article.
9363 With optional ARG, move across that many fields."
9364 (interactive "p")
9365 (gnus-summary-select-article)
9366 (gnus-configure-windows 'article)
9367 (select-window (gnus-get-buffer-window gnus-article-buffer))
9368 (unless (widget-at (point))
9369 (goto-char (point-max)))
9370 (widget-backward arg))
9371
9372 (defun gnus-summary-isearch-article (&optional regexp-p)
9373 "Do incremental search forward on the current article.
9374 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9375 (interactive "P")
9376 (gnus-summary-select-article)
9377 (gnus-configure-windows 'article)
9378 (gnus-eval-in-buffer-window gnus-article-buffer
9379 (save-restriction
9380 (widen)
9381 (isearch-forward regexp-p))))
9382
9383 (defun gnus-summary-repeat-search-article-forward ()
9384 "Repeat the previous search forwards."
9385 (interactive)
9386 (unless gnus-last-search-regexp
9387 (error "No previous search"))
9388 (gnus-summary-search-article-forward gnus-last-search-regexp))
9389
9390 (defun gnus-summary-repeat-search-article-backward ()
9391 "Repeat the previous search backwards."
9392 (interactive)
9393 (unless gnus-last-search-regexp
9394 (error "No previous search"))
9395 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9396
9397 (defun gnus-summary-search-article-forward (regexp &optional backward)
9398 "Search for an article containing REGEXP forward.
9399 If BACKWARD, search backward instead."
9400 (interactive
9401 (list (read-string
9402 (format "Search article %s (regexp%s): "
9403 (if current-prefix-arg "backward" "forward")
9404 (if gnus-last-search-regexp
9405 (concat ", default " gnus-last-search-regexp)
9406 "")))
9407 current-prefix-arg))
9408 (if (string-equal regexp "")
9409 (setq regexp (or gnus-last-search-regexp ""))
9410 (setq gnus-last-search-regexp regexp)
9411 (setq gnus-article-before-search gnus-current-article))
9412 ;; Intentionally set gnus-last-article.
9413 (setq gnus-last-article gnus-article-before-search)
9414 (let ((gnus-last-article gnus-last-article))
9415 (if (gnus-summary-search-article regexp backward)
9416 (gnus-summary-show-thread)
9417 (signal 'search-failed (list regexp)))))
9418
9419 (defun gnus-summary-search-article-backward (regexp)
9420 "Search for an article containing REGEXP backward."
9421 (interactive
9422 (list (read-string
9423 (format "Search article backward (regexp%s): "
9424 (if gnus-last-search-regexp
9425 (concat ", default " gnus-last-search-regexp)
9426 "")))))
9427 (gnus-summary-search-article-forward regexp 'backward))
9428
9429 (defun gnus-summary-search-article (regexp &optional backward)
9430 "Search for an article containing REGEXP.
9431 Optional argument BACKWARD means do search for backward.
9432 `gnus-select-article-hook' is not called during the search."
9433 ;; We have to require this here to make sure that the following
9434 ;; dynamic binding isn't shadowed by autoloading.
9435 (require 'gnus-async)
9436 (require 'gnus-art)
9437 (let ((gnus-select-article-hook nil) ;Disable hook.
9438 (gnus-article-prepare-hook nil)
9439 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9440 (gnus-use-article-prefetch nil)
9441 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9442 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9443 (gnus-visual nil)
9444 (gnus-keep-backlog nil)
9445 (gnus-break-pages nil)
9446 (gnus-summary-display-arrow nil)
9447 (gnus-updated-mode-lines nil)
9448 (gnus-auto-center-summary nil)
9449 (sum (current-buffer))
9450 (gnus-display-mime-function nil)
9451 (found nil)
9452 point)
9453 (gnus-save-hidden-threads
9454 (gnus-summary-select-article)
9455 (set-buffer gnus-article-buffer)
9456 (goto-char (window-point (get-buffer-window (current-buffer))))
9457 (when backward
9458 (forward-line -1))
9459 (while (not found)
9460 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9461 (if (if backward
9462 (re-search-backward regexp nil t)
9463 (re-search-forward regexp nil t))
9464 ;; We found the regexp.
9465 (progn
9466 (setq found 'found)
9467 (beginning-of-line)
9468 (set-window-start
9469 (get-buffer-window (current-buffer))
9470 (point))
9471 (forward-line 1)
9472 (set-window-point
9473 (get-buffer-window (current-buffer))
9474 (point))
9475 (set-buffer sum)
9476 (setq point (point)))
9477 ;; We didn't find it, so we go to the next article.
9478 (set-buffer sum)
9479 (setq found 'not)
9480 (while (eq found 'not)
9481 (if (not (if backward (gnus-summary-find-prev)
9482 (gnus-summary-find-next)))
9483 ;; No more articles.
9484 (setq found t)
9485 ;; Select the next article and adjust point.
9486 (unless (gnus-summary-article-sparse-p
9487 (gnus-summary-article-number))
9488 (setq found nil)
9489 (gnus-summary-select-article)
9490 (set-buffer gnus-article-buffer)
9491 (widen)
9492 (goto-char (if backward (point-max) (point-min))))))))
9493 (gnus-message 7 ""))
9494 ;; Return whether we found the regexp.
9495 (when (eq found 'found)
9496 (goto-char point)
9497 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9498 (gnus-summary-show-thread)
9499 (gnus-summary-goto-subject gnus-current-article)
9500 (gnus-summary-position-point)
9501 t)))
9502
9503 (defun gnus-find-matching-articles (header regexp)
9504 "Return a list of all articles that match REGEXP on HEADER.
9505 This search includes all articles in the current group that Gnus has
9506 fetched headers for, whether they are displayed or not."
9507 (let ((articles nil)
9508 ;; Can't eta-reduce because it's a macro.
9509 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9510 (case-fold-search t))
9511 (dolist (header gnus-newsgroup-headers)
9512 (when (string-match regexp (funcall func header))
9513 (push (mail-header-number header) articles)))
9514 (nreverse articles)))
9515
9516 (defun gnus-summary-find-matching (header regexp &optional backward unread
9517 not-case-fold not-matching)
9518 "Return a list of all articles that match REGEXP on HEADER.
9519 The search stars on the current article and goes forwards unless
9520 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9521 If UNREAD is non-nil, only unread articles will
9522 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9523 in the comparisons. If NOT-MATCHING, return a list of all articles that
9524 not match REGEXP on HEADER."
9525 (let ((case-fold-search (not not-case-fold))
9526 articles d func)
9527 (if (consp header)
9528 (if (eq (car header) 'extra)
9529 (setq func
9530 `(lambda (h)
9531 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9532 "")))
9533 (error "%s is an invalid header" header))
9534 (unless (fboundp (intern (concat "mail-header-" header)))
9535 (error "%s is not a valid header" header))
9536 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9537 (dolist (d (if (eq backward 'all)
9538 gnus-newsgroup-data
9539 (gnus-data-find-list
9540 (gnus-summary-article-number)
9541 (gnus-data-list backward))))
9542 (when (and (or (not unread) ; We want all articles...
9543 (gnus-data-unread-p d)) ; Or just unreads.
9544 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9545 (if not-matching
9546 (not (string-match
9547 regexp
9548 (funcall func (gnus-data-header d))))
9549 (string-match regexp
9550 (funcall func (gnus-data-header d)))))
9551 (push (gnus-data-number d) articles))) ; Success!
9552 (nreverse articles)))
9553
9554 (defun gnus-summary-execute-command (header regexp command &optional backward)
9555 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9556 If HEADER is an empty string (or nil), the match is done on the entire
9557 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9558 (interactive
9559 (list (let ((completion-ignore-case t))
9560 (gnus-completing-read
9561 "Header name"
9562 (mapcar 'symbol-name
9563 (append
9564 '(Number Subject From Lines Date
9565 Message-ID Xref References Body)
9566 gnus-extra-headers))
9567 'require-match))
9568 (read-string "Regexp: ")
9569 (read-key-sequence "Command: ")
9570 current-prefix-arg))
9571 (when (equal header "Body")
9572 (setq header ""))
9573 ;; Hidden thread subtrees must be searched as well.
9574 (gnus-summary-show-all-threads)
9575 ;; We don't want to change current point nor window configuration.
9576 (save-excursion
9577 (save-window-excursion
9578 (let (gnus-visual
9579 gnus-treat-strip-trailing-blank-lines
9580 gnus-treat-strip-leading-blank-lines
9581 gnus-treat-strip-multiple-blank-lines
9582 gnus-treat-hide-boring-headers
9583 gnus-treat-fold-newsgroups
9584 gnus-article-prepare-hook)
9585 (gnus-message 6 "Executing %s..." (key-description command))
9586 ;; We'd like to execute COMMAND interactively so as to give arguments.
9587 (gnus-execute header regexp
9588 `(call-interactively ',(key-binding command))
9589 backward)
9590 (gnus-message 6 "Executing %s...done" (key-description command))))))
9591
9592 (defun gnus-summary-beginning-of-article ()
9593 "Scroll the article back to the beginning."
9594 (interactive)
9595 (gnus-summary-select-article)
9596 (gnus-configure-windows 'article)
9597 (gnus-eval-in-buffer-window gnus-article-buffer
9598 (widen)
9599 (goto-char (point-min))
9600 (when gnus-break-pages
9601 (gnus-narrow-to-page))))
9602
9603 (defun gnus-summary-end-of-article ()
9604 "Scroll to the end of the article."
9605 (interactive)
9606 (gnus-summary-select-article)
9607 (gnus-configure-windows 'article)
9608 (gnus-eval-in-buffer-window gnus-article-buffer
9609 (widen)
9610 (goto-char (point-max))
9611 (recenter -3)
9612 (when gnus-break-pages
9613 (gnus-narrow-to-page))))
9614
9615 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9616 "Truncate to LEN and quote all \"(\"'s in STRING."
9617 (gnus-replace-in-string (if (and len (> (length string) len))
9618 (substring string 0 len)
9619 string)
9620 "[()]" "\\\\\\&"))
9621
9622 (defun gnus-summary-print-article (&optional filename n)
9623 "Generate and print a PostScript image of the process-marked (mail) articles.
9624
9625 If used interactively, print the current article if none are
9626 process-marked. With prefix arg, prompt the user for the name of the
9627 file to save in.
9628
9629 When used from Lisp, accept two optional args FILENAME and N. N means
9630 to print the next N articles. If N is negative, print the N previous
9631 articles. If N is nil and articles have been marked with the process
9632 mark, print these instead.
9633
9634 If the optional first argument FILENAME is nil, send the image to the
9635 printer. If FILENAME is a string, save the PostScript image in a file with
9636 that name. If FILENAME is a number, prompt the user for the name of the file
9637 to save in."
9638 (interactive (list (ps-print-preprint current-prefix-arg)))
9639 (dolist (article (gnus-summary-work-articles n))
9640 (gnus-summary-select-article nil nil 'pseudo article)
9641 (gnus-eval-in-buffer-window gnus-article-buffer
9642 (gnus-print-buffer))
9643 (gnus-summary-remove-process-mark article))
9644 (ps-despool filename))
9645
9646 (defun gnus-print-buffer ()
9647 (let ((ps-left-header
9648 (list
9649 (concat "("
9650 (gnus-summary-print-truncate-and-quote
9651 (mail-header-subject gnus-current-headers)
9652 66) ")")
9653 (concat "("
9654 (gnus-summary-print-truncate-and-quote
9655 (mail-header-from gnus-current-headers)
9656 45) ")")))
9657 (ps-right-header
9658 (list
9659 "/pagenumberstring load"
9660 (concat "("
9661 (mail-header-date gnus-current-headers) ")"))))
9662 (gnus-run-hooks 'gnus-ps-print-hook)
9663 (save-excursion
9664 (if ps-print-color-p
9665 (ps-spool-buffer-with-faces)
9666 (ps-spool-buffer)))))
9667
9668 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9669
9670 (defun gnus-summary-show-complete-article ()
9671 "Show a complete version of the current article.
9672 This is only useful if you're looking at a partial version of the
9673 article currently."
9674 (interactive)
9675 (let ((gnus-keep-backlog nil)
9676 (gnus-use-cache nil)
9677 (gnus-agent nil)
9678 (variable (intern
9679 (format "%s-fetch-partial-articles"
9680 (car (gnus-find-method-for-group
9681 gnus-newsgroup-name)))
9682 obarray))
9683 old-val)
9684 (unwind-protect
9685 (progn
9686 (setq old-val (symbol-value variable))
9687 (set variable nil)
9688 (gnus-flush-original-article-buffer)
9689 (gnus-summary-show-article))
9690 (set variable old-val))))
9691
9692 (defun gnus-summary-show-article (&optional arg)
9693 "Force redisplaying of the current article.
9694 If ARG (the prefix) is a number, show the article with the charset
9695 defined in `gnus-summary-show-article-charset-alist', or the charset
9696 input.
9697 If ARG (the prefix) is non-nil and not a number, show the article,
9698 but without running any of the article treatment functions
9699 article. Normally, the keystroke is `C-u g'. When using `C-u
9700 C-u g', show the raw article."
9701 (interactive "P")
9702 (cond
9703 ((numberp arg)
9704 (gnus-summary-show-article t)
9705 (let ((gnus-newsgroup-charset
9706 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9707 (mm-read-coding-system
9708 "View as charset: " ;; actually it is coding system.
9709 (with-current-buffer gnus-article-buffer
9710 (mm-detect-coding-region (point) (point-max))))))
9711 (gnus-newsgroup-ignored-charsets 'gnus-all))
9712 (gnus-summary-select-article nil 'force)
9713 (let ((deps gnus-newsgroup-dependencies)
9714 head header lines)
9715 (with-current-buffer gnus-original-article-buffer
9716 (save-restriction
9717 (message-narrow-to-head)
9718 (setq head (buffer-string))
9719 (goto-char (point-min))
9720 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9721 (goto-char (point-max))
9722 (widen)
9723 (setq lines (1- (count-lines (point) (point-max))))))
9724 (with-temp-buffer
9725 (insert (format "211 %d Article retrieved.\n"
9726 (cdr gnus-article-current)))
9727 (insert head)
9728 (if lines (insert (format "Lines: %d\n" lines)))
9729 (insert ".\n")
9730 (let ((nntp-server-buffer (current-buffer)))
9731 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9732 (gnus-data-set-header
9733 (gnus-data-find (cdr gnus-article-current))
9734 header)
9735 (gnus-summary-update-article-line
9736 (cdr gnus-article-current) header)
9737 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9738 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9739 ((not arg)
9740 ;; Select the article the normal way.
9741 (if (eq mm-text-html-renderer 'shr)
9742 (progn
9743 (require 'shr)
9744 (let ((shr-ignore-cache t))
9745 (gnus-summary-select-article nil 'force)))
9746 (gnus-summary-select-article nil 'force)))
9747 ((equal arg '(16))
9748 ;; C-u C-u g
9749 (let ((gnus-inhibit-article-treatments t))
9750 (gnus-summary-select-article nil 'force)))
9751 (t
9752 ;; We have to require this here to make sure that the following
9753 ;; dynamic binding isn't shadowed by autoloading.
9754 (require 'gnus-async)
9755 (require 'gnus-art)
9756 ;; Bind the article treatment functions to nil.
9757 (let ((gnus-have-all-headers t)
9758 gnus-article-prepare-hook
9759 gnus-article-decode-hook
9760 gnus-display-mime-function
9761 gnus-break-pages)
9762 ;; Destroy any MIME parts.
9763 (when (gnus-buffer-live-p gnus-article-buffer)
9764 (with-current-buffer gnus-article-buffer
9765 (gnus-article-stop-animations)
9766 (gnus-stop-downloads)
9767 (mm-destroy-parts gnus-article-mime-handles)
9768 ;; Set it to nil for safety reason.
9769 (setq gnus-article-mime-handle-alist nil)
9770 (setq gnus-article-mime-handles nil)))
9771 (gnus-summary-select-article nil 'force))))
9772 (gnus-summary-goto-subject gnus-current-article)
9773 (gnus-summary-position-point))
9774
9775 (defun gnus-summary-show-raw-article ()
9776 "Show the raw article without any article massaging functions being run."
9777 (interactive)
9778 (gnus-summary-show-article t))
9779
9780 (defun gnus-summary-verbose-headers (&optional arg)
9781 "Toggle permanent full header display.
9782 If ARG is a positive number, turn header display on.
9783 If ARG is a negative number, turn header display off."
9784 (interactive "P")
9785 (setq gnus-show-all-headers
9786 (cond ((or (not (numberp arg))
9787 (zerop arg))
9788 (not gnus-show-all-headers))
9789 ((natnump arg)
9790 t)))
9791 (gnus-summary-show-article))
9792
9793 (declare-function article-narrow-to-head "gnus-art" ())
9794 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9795 (declare-function gnus-delete-wash-type "gnus-art" (type))
9796 (declare-function gnus-mime-buttonize-attachments-in-header
9797 "gnus-art" (&optional interactive))
9798
9799 (defun gnus-summary-toggle-header (&optional arg)
9800 "Show the headers if they are hidden, or hide them if they are shown.
9801 If ARG is a positive number, show the entire header.
9802 If ARG is a negative number, hide the unwanted header lines."
9803 (interactive "P")
9804 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9805 (get-buffer-window gnus-article-buffer t))))
9806 (with-current-buffer gnus-article-buffer
9807 (widen)
9808 (article-narrow-to-head)
9809 (let* ((inhibit-read-only t)
9810 (inhibit-point-motion-hooks t)
9811 (hidden (if (numberp arg)
9812 (>= arg 0)
9813 (or (not (looking-at "[^ \t\n]+:"))
9814 (gnus-article-hidden-text-p 'headers))))
9815 s e)
9816 (delete-region (point-min) (point-max))
9817 (with-current-buffer gnus-original-article-buffer
9818 (goto-char (setq s (point-min)))
9819 (setq e (if (search-forward "\n\n" nil t)
9820 (1- (point))
9821 (point-max))))
9822 (insert-buffer-substring gnus-original-article-buffer s e)
9823 (run-hooks 'gnus-article-decode-hook)
9824 (if hidden
9825 (let ((gnus-treat-hide-headers nil)
9826 (gnus-treat-hide-boring-headers nil))
9827 (gnus-delete-wash-type 'headers)
9828 (gnus-treat-article 'head))
9829 (gnus-treat-article 'head)
9830 ;; Add attachment buttons to the header.
9831 (when gnus-mime-display-attachment-buttons-in-header
9832 (gnus-mime-buttonize-attachments-in-header)))
9833 (widen)
9834 (if window
9835 (set-window-start window (goto-char (point-min))))
9836 (if gnus-break-pages
9837 (gnus-narrow-to-page)
9838 (when (gnus-visual-p 'page-marker)
9839 (let ((inhibit-read-only t))
9840 (gnus-remove-text-with-property 'gnus-prev)
9841 (gnus-remove-text-with-property 'gnus-next))))
9842 (gnus-set-mode-line 'article)))))
9843
9844 (defun gnus-summary-show-all-headers ()
9845 "Make all header lines visible."
9846 (interactive)
9847 (gnus-summary-toggle-header 1))
9848
9849 (defun gnus-summary-caesar-message (&optional arg)
9850 "Caesar rotate the current article by 13.
9851 With a non-numerical prefix, also rotate headers. A numerical
9852 prefix specifies how many places to rotate each letter forward."
9853 (interactive "P")
9854 (gnus-summary-select-article)
9855 (let ((mail-header-separator ""))
9856 (gnus-eval-in-buffer-window gnus-article-buffer
9857 (save-restriction
9858 (widen)
9859 (let ((start (window-start))
9860 (inhibit-read-only t))
9861 (if (equal arg '(4))
9862 (message-caesar-buffer-body nil t)
9863 (message-caesar-buffer-body arg))
9864 (set-window-start (get-buffer-window (current-buffer)) start)))))
9865 ;; Create buttons and stuff...
9866 (gnus-treat-article nil))
9867
9868 (declare-function idna-to-unicode "ext:idna" (str))
9869
9870 (defun gnus-summary-idna-message (&optional arg)
9871 "Decode IDNA encoded domain names in the current articles.
9872 IDNA encoded domain names looks like `xn--bar'. If a string
9873 remain unencoded after running this function, it is likely an
9874 invalid IDNA string (`xn--bar' is invalid).
9875
9876 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9877 installed for this command to work."
9878 (interactive "P")
9879 (if (not (and (mm-coding-system-p 'utf-8)
9880 (condition-case nil
9881 (require 'idna)
9882 (file-error)
9883 (invalid-operation))
9884 (symbol-value 'idna-program)
9885 (executable-find (symbol-value 'idna-program))))
9886 (gnus-message
9887 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9888 (gnus-summary-select-article)
9889 (let ((mail-header-separator ""))
9890 (gnus-eval-in-buffer-window gnus-article-buffer
9891 (save-restriction
9892 (widen)
9893 (let ((start (window-start))
9894 buffer-read-only)
9895 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9896 (replace-match (idna-to-unicode (match-string 1))))
9897 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9898
9899 (defun gnus-summary-morse-message (&optional arg)
9900 "Morse decode the current article."
9901 (interactive "P")
9902 (gnus-summary-select-article)
9903 (let ((mail-header-separator ""))
9904 (gnus-eval-in-buffer-window gnus-article-buffer
9905 (save-excursion
9906 (save-restriction
9907 (widen)
9908 (let ((pos (window-start))
9909 (inhibit-read-only t))
9910 (goto-char (point-min))
9911 (when (message-goto-body)
9912 (gnus-narrow-to-body))
9913 (goto-char (point-min))
9914 (while (search-forward "·" (point-max) t)
9915 (replace-match "."))
9916 (unmorse-region (point-min) (point-max))
9917 (widen)
9918 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9919
9920 (defun gnus-summary-stop-page-breaking ()
9921 "Stop page breaking in the current article."
9922 (interactive)
9923 (gnus-summary-select-article)
9924 (gnus-eval-in-buffer-window gnus-article-buffer
9925 (widen)
9926 (when (gnus-visual-p 'page-marker)
9927 (let ((inhibit-read-only t))
9928 (gnus-remove-text-with-property 'gnus-prev)
9929 (gnus-remove-text-with-property 'gnus-next))
9930 (setq gnus-page-broken nil))))
9931
9932 (defun gnus-summary-move-article (&optional n to-newsgroup
9933 select-method action)
9934 "Move the current article to a different newsgroup.
9935 If N is a positive number, move the N next articles.
9936 If N is a negative number, move the N previous articles.
9937 If N is nil and any articles have been marked with the process mark,
9938 move those articles instead.
9939 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9940 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9941 re-spool using this method.
9942
9943 When called interactively with TO-NEWSGROUP being nil, the value of
9944 the variable `gnus-move-split-methods' is used for finding a default
9945 for the target newsgroup.
9946
9947 For this function to work, both the current newsgroup and the
9948 newsgroup that you want to move to have to support the `request-move'
9949 and `request-accept' functions.
9950
9951 ACTION can be either `move' (the default), `crosspost' or `copy'."
9952 (interactive "P")
9953 (unless action
9954 (setq action 'move))
9955 ;; Check whether the source group supports the required functions.
9956 (cond ((and (eq action 'move)
9957 (not (gnus-check-backend-function
9958 'request-move-article gnus-newsgroup-name)))
9959 (error "The current group does not support article moving"))
9960 ((and (eq action 'crosspost)
9961 (not (gnus-check-backend-function
9962 'request-replace-article gnus-newsgroup-name)))
9963 (error "The current group does not support article editing")))
9964 (let ((articles (gnus-summary-work-articles n))
9965 (prefix (if (gnus-check-backend-function
9966 'request-move-article gnus-newsgroup-name)
9967 (funcall gnus-move-group-prefix-function
9968 gnus-newsgroup-name)
9969 ""))
9970 (names '((move "Move" "Moving")
9971 (copy "Copy" "Copying")
9972 (crosspost "Crosspost" "Crossposting")))
9973 (copy-buf (save-excursion
9974 (nnheader-set-temp-buffer " *copy article*")))
9975 art-group to-method new-xref article to-groups
9976 articles-to-update-marks encoded)
9977 (unless (assq action names)
9978 (error "Unknown action %s" action))
9979 ;; Read the newsgroup name.
9980 (when (and (not to-newsgroup)
9981 (not select-method))
9982 (if (and gnus-move-split-methods
9983 (not
9984 (and (memq gnus-current-article articles)
9985 (gnus-buffer-live-p gnus-original-article-buffer))))
9986 ;; When `gnus-move-split-methods' is non-nil, we have to
9987 ;; select an article to give `gnus-read-move-group-name' an
9988 ;; opportunity to suggest an appropriate default. However,
9989 ;; we needn't render or mark the article.
9990 (let ((gnus-display-mime-function nil)
9991 (gnus-article-prepare-hook nil)
9992 (gnus-mark-article-hook nil))
9993 (gnus-summary-select-article nil nil nil (car articles))))
9994 (setq to-newsgroup (gnus-read-move-group-name
9995 (cadr (assq action names))
9996 (symbol-value
9997 (intern (format "gnus-current-%s-group" action)))
9998 articles prefix)
9999 encoded to-newsgroup
10000 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
10001 (set (intern (format "gnus-current-%s-group" action))
10002 (mm-decode-coding-string
10003 to-newsgroup
10004 (gnus-group-name-charset to-method to-newsgroup))))
10005 (unless to-method
10006 (setq to-method (or select-method
10007 (gnus-server-to-method
10008 (gnus-group-method to-newsgroup)))))
10009 (setq to-newsgroup
10010 (or encoded
10011 (and to-newsgroup
10012 (mm-encode-coding-string
10013 to-newsgroup
10014 (gnus-group-name-charset to-method to-newsgroup)))))
10015 ;; Check the method we are to move this article to...
10016 (unless (gnus-check-backend-function
10017 'request-accept-article (car to-method))
10018 (error "%s does not support article copying" (car to-method)))
10019 (unless (gnus-check-server to-method)
10020 (error "Can't open server %s" (car to-method)))
10021 (gnus-message 6 "%s to %s: %s..."
10022 (caddr (assq action names))
10023 (or (car select-method)
10024 (gnus-group-decoded-name to-newsgroup))
10025 articles)
10026 (while articles
10027 (setq article (pop articles))
10028 ;; Set any marks that may have changed in the summary buffer.
10029 (when gnus-preserve-marks
10030 (gnus-summary-push-marks-to-backend article))
10031 (setq
10032 art-group
10033 (cond
10034 ;; Move the article.
10035 ((eq action 'move)
10036 ;; Remove this article from future suppression.
10037 (gnus-dup-unsuppress-article article)
10038 (let* ((from-method (gnus-find-method-for-group
10039 gnus-newsgroup-name))
10040 (to-method (or select-method
10041 (gnus-find-method-for-group to-newsgroup)))
10042 (move-is-internal (gnus-server-equal from-method to-method)))
10043 (gnus-request-move-article
10044 article ; Article to move
10045 gnus-newsgroup-name ; From newsgroup
10046 (nth 1 (gnus-find-method-for-group
10047 gnus-newsgroup-name)) ; Server
10048 (list 'gnus-request-accept-article
10049 to-newsgroup (list 'quote select-method)
10050 (not articles) t) ; Accept form
10051 (not articles) ; Only save nov last time
10052 (and move-is-internal
10053 to-newsgroup ; Not respooling
10054 ; Is this move internal?
10055 (gnus-group-real-name to-newsgroup)))))
10056 ;; Copy the article.
10057 ((eq action 'copy)
10058 (with-current-buffer copy-buf
10059 (when (gnus-request-article-this-buffer article
10060 gnus-newsgroup-name)
10061 (save-restriction
10062 (nnheader-narrow-to-headers)
10063 (dolist (hdr gnus-copy-article-ignored-headers)
10064 (message-remove-header hdr t)))
10065 (gnus-request-accept-article
10066 to-newsgroup select-method (not articles) t))))
10067 ;; Crosspost the article.
10068 ((eq action 'crosspost)
10069 (let ((xref (message-tokenize-header
10070 (mail-header-xref (gnus-summary-article-header
10071 article))
10072 " ")))
10073 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10074 ":" (number-to-string article)))
10075 (unless xref
10076 (setq xref (list (system-name))))
10077 (setq new-xref
10078 (concat
10079 (mapconcat 'identity
10080 (delete "Xref:" (delete new-xref xref))
10081 " ")
10082 " " new-xref))
10083 (with-current-buffer copy-buf
10084 ;; First put the article in the destination group.
10085 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10086 (when (consp (setq art-group
10087 (gnus-request-accept-article
10088 to-newsgroup select-method (not articles)
10089 t)))
10090 (setq new-xref (concat new-xref " " (car art-group)
10091 ":"
10092 (number-to-string (cdr art-group))))
10093 ;; Now we have the new Xrefs header, so we insert
10094 ;; it and replace the new article.
10095 (nnheader-replace-header "Xref" new-xref)
10096 (gnus-request-replace-article
10097 (cdr art-group) to-newsgroup (current-buffer) t)
10098 art-group))))))
10099 (cond
10100 ((not art-group)
10101 (gnus-message 1 "Couldn't %s article %s: %s"
10102 (cadr (assq action names)) article
10103 (nnheader-get-report (car to-method))))
10104 ((eq art-group 'junk)
10105 (when (eq action 'move)
10106 (gnus-summary-mark-article article gnus-canceled-mark)
10107 (gnus-message 4 "Deleted article %s" article)
10108 ;; run the delete hook
10109 (run-hook-with-args 'gnus-summary-article-delete-hook
10110 action
10111 (gnus-data-header
10112 (assoc article (gnus-data-list nil)))
10113 gnus-newsgroup-name nil
10114 select-method)))
10115 (t
10116 (let* ((pto-group (gnus-group-prefixed-name
10117 (car art-group) to-method))
10118 (info (gnus-get-info pto-group))
10119 (to-group (gnus-info-group info))
10120 to-marks)
10121 ;; Update the group that has been moved to.
10122 (when (and info
10123 (memq action '(move copy)))
10124 (unless (member to-group to-groups)
10125 (push to-group to-groups))
10126
10127 (when (and (not (memq article gnus-newsgroup-unreads))
10128 (cdr art-group))
10129 (push 'read to-marks)
10130 (gnus-info-set-read
10131 info (gnus-add-to-range (gnus-info-read info)
10132 (list (cdr art-group)))))
10133
10134 ;; See whether the article is to be put in the cache.
10135 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10136 (marks (if expirable
10137 gnus-article-mark-lists
10138 (delete '(expirable . expire)
10139 (copy-sequence
10140 gnus-article-mark-lists))))
10141 (to-article (cdr art-group)))
10142
10143 ;; Enter the article into the cache in the new group,
10144 ;; if that is required.
10145 (when (and to-article
10146 gnus-use-cache)
10147 (gnus-cache-possibly-enter-article
10148 to-group to-article
10149 (memq article gnus-newsgroup-marked)
10150 (memq article gnus-newsgroup-dormant)
10151 (memq article gnus-newsgroup-unreads)))
10152
10153 (when (and gnus-preserve-marks
10154 to-article)
10155 ;; Copy any marks over to the new group.
10156 (when (and (equal to-group gnus-newsgroup-name)
10157 (not (memq article gnus-newsgroup-unreads)))
10158 ;; Mark this article as read in this group.
10159 (push (cons to-article gnus-read-mark)
10160 gnus-newsgroup-reads)
10161 ;; Increase the active status of this group.
10162 (setcdr (gnus-active to-group) to-article)
10163 (setcdr gnus-newsgroup-active to-article))
10164
10165 (while marks
10166 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10167 (when (memq article (symbol-value
10168 (intern (format "gnus-newsgroup-%s"
10169 (caar marks)))))
10170 (push (cdar marks) to-marks)
10171 ;; If the other group is the same as this group,
10172 ;; then we have to add the mark to the list.
10173 (when (equal to-group gnus-newsgroup-name)
10174 (set (intern (format "gnus-newsgroup-%s"
10175 (caar marks)))
10176 (cons to-article
10177 (symbol-value
10178 (intern (format "gnus-newsgroup-%s"
10179 (caar marks)))))))
10180 ;; Copy the marks to other group.
10181 (gnus-add-marked-articles
10182 to-group (cdar marks) (list to-article) info)))
10183 (setq marks (cdr marks)))
10184
10185 (when (and expirable
10186 gnus-mark-copied-or-moved-articles-as-expirable
10187 (not (memq 'expire to-marks)))
10188 ;; Mark this article as expirable.
10189 (push 'expire to-marks)
10190 (when (equal to-group gnus-newsgroup-name)
10191 (push to-article gnus-newsgroup-expirable))
10192 ;; Copy the expirable mark to other group.
10193 (gnus-add-marked-articles
10194 to-group 'expire (list to-article) info))
10195
10196 (when (and to-marks
10197 (gnus-method-option-p
10198 (gnus-find-method-for-group to-group)
10199 'server-marks))
10200 (gnus-request-set-mark
10201 to-group (list (list (list to-article) 'add to-marks)))))
10202
10203 (gnus-dribble-enter
10204 (concat "(gnus-group-set-info '"
10205 (gnus-prin1-to-string (gnus-get-info to-group))
10206 ")")
10207 (concat "^(gnus-group-set-info '(\""
10208 (regexp-quote to-group) "\""))))
10209
10210 ;; Update the Xref header in this article to point to
10211 ;; the new crossposted article we have just created.
10212 (when (eq action 'crosspost)
10213 (with-current-buffer copy-buf
10214 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10215 (nnheader-replace-header "Xref" new-xref)
10216 (gnus-request-replace-article
10217 article gnus-newsgroup-name (current-buffer) t)))
10218
10219 ;; run the move/copy/crosspost/respool hook
10220 (run-hook-with-args 'gnus-summary-article-move-hook
10221 action
10222 (gnus-data-header
10223 (assoc article (gnus-data-list nil)))
10224 gnus-newsgroup-name
10225 to-newsgroup
10226 select-method))
10227
10228 ;;;!!!Why is this necessary?
10229 (set-buffer gnus-summary-buffer)
10230
10231 (when (eq action 'move)
10232 (save-excursion
10233 (gnus-summary-goto-subject article)
10234 (gnus-summary-mark-article article gnus-canceled-mark)))))
10235 (push article articles-to-update-marks))
10236
10237 (save-excursion
10238 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10239 ;; Re-activate all groups that have been moved to.
10240 (with-current-buffer gnus-group-buffer
10241 (let ((gnus-group-marked to-groups))
10242 (gnus-group-get-new-news-this-group nil t)))
10243
10244 (gnus-kill-buffer copy-buf)
10245 (gnus-summary-position-point)
10246 (gnus-set-mode-line 'summary)))
10247
10248 (defun gnus-summary-push-marks-to-backend (article)
10249 (let ((set nil)
10250 (del nil)
10251 (marks gnus-article-mark-lists))
10252 (unless (memq article gnus-newsgroup-unreads)
10253 (push 'read set))
10254 (while marks
10255 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10256 (memq article (symbol-value
10257 (intern (format "gnus-newsgroup-%s"
10258 (caar marks))))))
10259 (push (cdar marks) set)
10260 (push (cdar marks) del))
10261 (pop marks))
10262 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10263 ((,article) del ,del)))))
10264
10265 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10266 "Copy the current article to some other group.
10267 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10268 When called interactively, if TO-NEWSGROUP is nil, use the value of
10269 the variable `gnus-move-split-methods' for finding a default target
10270 newsgroup.
10271 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10272 re-spool using this method."
10273 (interactive "P")
10274 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10275
10276 (defun gnus-summary-crosspost-article (&optional n)
10277 "Crosspost the current article to some other group."
10278 (interactive "P")
10279 (gnus-summary-move-article n nil nil 'crosspost))
10280
10281 (defcustom gnus-summary-respool-default-method nil
10282 "Default method type for respooling an article.
10283 If nil, use to the current newsgroup method."
10284 :type 'symbol
10285 :group 'gnus-summary-mail)
10286
10287 (defun gnus-summary-respool-article (&optional n method)
10288 "Respool the current article.
10289 The article will be squeezed through the mail spooling process again,
10290 which means that it will be put in some mail newsgroup or other
10291 depending on `nnmail-split-methods'.
10292 If N is a positive number, respool the N next articles.
10293 If N is a negative number, respool the N previous articles.
10294 If N is nil and any articles have been marked with the process mark,
10295 respool those articles instead.
10296
10297 Respooling can be done both from mail groups and \"real\" newsgroups.
10298 In the former case, the articles in question will be moved from the
10299 current group into whatever groups they are destined to. In the
10300 latter case, they will be copied into the relevant groups."
10301 (interactive
10302 (list current-prefix-arg
10303 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10304 (methname
10305 (symbol-name (or gnus-summary-respool-default-method
10306 (car (gnus-find-method-for-group
10307 gnus-newsgroup-name)))))
10308 (method
10309 (gnus-completing-read
10310 "Backend to use when respooling"
10311 methods t nil 'gnus-mail-method-history methname))
10312 ms)
10313 (cond
10314 ((zerop (length (setq ms (gnus-servers-using-backend
10315 (intern method)))))
10316 (list (intern method) ""))
10317 ((= 1 (length ms))
10318 (car ms))
10319 (t
10320 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10321 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10322 ms-alist))))))))
10323 (unless method
10324 (error "No method given for respooling"))
10325 (if (assoc (symbol-name
10326 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10327 (gnus-methods-using 'respool))
10328 (gnus-summary-move-article n nil method)
10329 (gnus-summary-copy-article n nil method)))
10330
10331 (defun gnus-summary-import-article (file &optional edit)
10332 "Import an arbitrary file into a mail newsgroup."
10333 (interactive "fImport file: \nP")
10334 (let ((group gnus-newsgroup-name)
10335 (now (current-time))
10336 atts lines group-art)
10337 (unless (gnus-check-backend-function 'request-accept-article group)
10338 (error "%s does not support article importing" group))
10339 (or (file-readable-p file)
10340 (not (file-regular-p file))
10341 (error "Can't read %s" file))
10342 (with-current-buffer (gnus-get-buffer-create " *import file*")
10343 (erase-buffer)
10344 (nnheader-insert-file-contents file)
10345 (goto-char (point-min))
10346 (if (nnheader-article-p)
10347 (save-restriction
10348 (goto-char (point-min))
10349 (search-forward "\n\n" nil t)
10350 (narrow-to-region (point-min) (1- (point)))
10351 (goto-char (point-min))
10352 (unless (re-search-forward "^date:" nil t)
10353 (goto-char (point-max))
10354 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10355 ;; This doesn't look like an article, so we fudge some headers.
10356 (setq atts (file-attributes file)
10357 lines (count-lines (point-min) (point-max)))
10358 (insert "From: " (read-string "From: ") "\n"
10359 "Subject: " (read-string "Subject: ") "\n"
10360 "Date: " (message-make-date (nth 5 atts)) "\n"
10361 "Message-ID: " (message-make-message-id) "\n"
10362 "Lines: " (int-to-string lines) "\n"
10363 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10364 (setq group-art (gnus-request-accept-article group nil t))
10365 (kill-buffer (current-buffer)))
10366 (setq gnus-newsgroup-active (gnus-activate-group group))
10367 (forward-line 1)
10368 (gnus-summary-goto-article (cdr group-art) nil t)
10369 (when edit
10370 (gnus-summary-edit-article))))
10371
10372 (defun gnus-summary-create-article ()
10373 "Create an article in a mail newsgroup."
10374 (interactive)
10375 (let ((group gnus-newsgroup-name)
10376 (now (current-time))
10377 group-art)
10378 (unless (gnus-check-backend-function 'request-accept-article group)
10379 (error "%s does not support article importing" group))
10380 (with-current-buffer (gnus-get-buffer-create " *import file*")
10381 (erase-buffer)
10382 (goto-char (point-min))
10383 ;; This doesn't look like an article, so we fudge some headers.
10384 (insert "From: " (read-string "From: ") "\n"
10385 "Subject: " (read-string "Subject: ") "\n"
10386 "Date: " (message-make-date now) "\n"
10387 "Message-ID: " (message-make-message-id) "\n")
10388 (setq group-art (gnus-request-accept-article group nil t))
10389 (kill-buffer (current-buffer)))
10390 (setq gnus-newsgroup-active (gnus-activate-group group))
10391 (forward-line 1)
10392 (gnus-summary-goto-article (cdr group-art) nil t)
10393 (gnus-summary-edit-article)))
10394
10395 (defun gnus-summary-article-posted-p ()
10396 "Say whether the current (mail) article is available from news as well.
10397 This will be the case if the article has both been mailed and posted."
10398 (interactive)
10399 (let ((id (mail-header-references (gnus-summary-article-header)))
10400 (gnus-override-method (car (gnus-refer-article-methods))))
10401 (if (gnus-request-head id "")
10402 (gnus-message 2 "The current message was found on %s"
10403 gnus-override-method)
10404 (gnus-message 2 "The current message couldn't be found on %s"
10405 gnus-override-method)
10406 nil)))
10407
10408 (defun gnus-summary-expire-articles (&optional now)
10409 "Expire all articles that are marked as expirable in the current group."
10410 (interactive)
10411 (when (and (not gnus-group-is-exiting-without-update-p)
10412 (gnus-check-backend-function
10413 'request-expire-articles gnus-newsgroup-name))
10414 ;; This backend supports expiry.
10415 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10416 (expirable
10417 (gnus-list-range-difference
10418 (if total
10419 (progn
10420 ;; We need to update the info for
10421 ;; this group for `gnus-list-of-read-articles'
10422 ;; to give us the right answer.
10423 (gnus-run-hooks 'gnus-exit-group-hook)
10424 (gnus-summary-update-info)
10425 (gnus-list-of-read-articles gnus-newsgroup-name))
10426 (setq gnus-newsgroup-expirable
10427 (sort gnus-newsgroup-expirable '<)))
10428 gnus-newsgroup-unexist))
10429 (expiry-wait (if now 'immediate
10430 (gnus-group-find-parameter
10431 gnus-newsgroup-name 'expiry-wait)))
10432 (nnmail-expiry-target
10433 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10434 nnmail-expiry-target))
10435 es)
10436 (when expirable
10437 ;; There are expirable articles in this group, so we run them
10438 ;; through the expiry process.
10439 (gnus-message 6 "Expiring articles...")
10440 (when (gnus-check-group gnus-newsgroup-name)
10441 ;; The list of articles that weren't expired is returned.
10442 (save-excursion
10443 (if expiry-wait
10444 (let ((nnmail-expiry-wait-function nil)
10445 (nnmail-expiry-wait expiry-wait))
10446 (setq es (gnus-request-expire-articles
10447 expirable gnus-newsgroup-name)))
10448 (setq es (gnus-request-expire-articles
10449 expirable gnus-newsgroup-name)))
10450 (unless total
10451 (setq gnus-newsgroup-expirable es))
10452 ;; We go through the old list of expirable, and mark all
10453 ;; really expired articles as nonexistent.
10454 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10455 (let ((gnus-use-cache nil))
10456 (dolist (article expirable)
10457 (when (and (not (memq article es))
10458 (gnus-data-find article))
10459 (gnus-summary-mark-article article gnus-canceled-mark)
10460 (run-hook-with-args
10461 'gnus-summary-article-expire-hook
10462 'delete
10463 (gnus-data-header (assoc article (gnus-data-list nil)))
10464 gnus-newsgroup-name
10465 (cond
10466 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10467 ((eq nnmail-expiry-target 'delete) nil)
10468 (t
10469 (let ((rescall (funcall nnmail-expiry-target
10470 gnus-newsgroup-name)))
10471 (if (stringp rescall) rescall nil))))
10472 nil)))))))
10473 (gnus-message 6 "Expiring articles...done")))))
10474
10475 (defun gnus-summary-expire-articles-now ()
10476 "Expunge all expirable articles in the current group.
10477 This means that *all* articles that are marked as expirable will be
10478 deleted forever, right now."
10479 (interactive)
10480 (or gnus-expert-user
10481 (gnus-yes-or-no-p
10482 "Are you really, really sure you want to delete all expirable messages? ")
10483 (error "Phew!"))
10484 (gnus-summary-expire-articles t))
10485
10486 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10487 (defun gnus-summary-delete-article (&optional n)
10488 "Delete the N next (mail) articles.
10489 This command actually deletes articles. This is not a marking
10490 command. The article will disappear forever from your life, never to
10491 return.
10492
10493 If N is negative, delete backwards.
10494 If N is nil and articles have been marked with the process mark,
10495 delete these instead.
10496
10497 If `gnus-novice-user' is non-nil you will be asked for
10498 confirmation before the articles are deleted."
10499 (interactive "P")
10500 (unless (gnus-check-backend-function 'request-expire-articles
10501 gnus-newsgroup-name)
10502 (error "The current newsgroup does not support article deletion"))
10503 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10504 (error "Couldn't open server"))
10505 ;; Compute the list of articles to delete.
10506 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10507 (nnmail-expiry-target 'delete)
10508 not-deleted)
10509 (if (and gnus-novice-user
10510 (not (gnus-yes-or-no-p
10511 (format "Do you really want to delete %s forever? "
10512 (if (> (length articles) 1)
10513 (format "these %s articles" (length articles))
10514 "this article")))))
10515 ()
10516 ;; Delete the articles.
10517 (setq not-deleted (gnus-request-expire-articles
10518 articles gnus-newsgroup-name 'force))
10519 (save-excursion
10520 (while articles
10521 (gnus-summary-remove-process-mark (car articles))
10522 ;; The backend might not have been able to delete the article
10523 ;; after all.
10524 (unless (memq (car articles) not-deleted)
10525 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10526 (let* ((article (car articles))
10527 (ghead (gnus-data-header
10528 (assoc article (gnus-data-list nil)))))
10529 (run-hook-with-args 'gnus-summary-article-delete-hook
10530 'delete ghead gnus-newsgroup-name nil
10531 nil)))
10532 (setq articles (cdr articles))))
10533 (when not-deleted
10534 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10535 (gnus-summary-position-point)
10536 (gnus-set-mode-line 'summary)
10537 not-deleted))
10538
10539 (defun gnus-summary-edit-article (&optional arg)
10540 "Edit the current article.
10541 This will have permanent effect only in mail groups.
10542 If ARG is nil, edit the decoded articles.
10543 If ARG is 1, edit the raw articles.
10544 If ARG is 2, edit the raw articles even in read-only groups.
10545 If ARG is 3, edit the articles with the current handles.
10546 Otherwise, allow editing of articles even in read-only
10547 groups."
10548 (interactive "P")
10549 (let (force raw current-handles)
10550 (cond
10551 ((null arg))
10552 ((eq arg 1)
10553 (setq raw t))
10554 ((eq arg 2)
10555 (setq raw t
10556 force t))
10557 ((eq arg 3)
10558 (setq current-handles
10559 (and (gnus-buffer-live-p gnus-article-buffer)
10560 (with-current-buffer gnus-article-buffer
10561 (prog1
10562 gnus-article-mime-handles
10563 (setq gnus-article-mime-handles nil))))))
10564 (t
10565 (setq force t)))
10566 (when (and raw (not force)
10567 (member gnus-newsgroup-name '("nndraft:delayed"
10568 "nndraft:drafts"
10569 "nndraft:queue")))
10570 (error "Can't edit the raw article in group %s"
10571 gnus-newsgroup-name))
10572 (with-current-buffer gnus-summary-buffer
10573 (let ((mail-parse-charset gnus-newsgroup-charset)
10574 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10575 (gnus-set-global-variables)
10576 (when (and (not force)
10577 (gnus-group-read-only-p))
10578 (error "The current newsgroup does not support article editing"))
10579 (gnus-summary-show-article t)
10580 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10581 (with-current-buffer gnus-article-buffer
10582 (mm-enable-multibyte)))
10583 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10584 (setq raw t))
10585 (gnus-article-edit-article
10586 (if raw 'ignore
10587 `(lambda ()
10588 (let ((mbl mml-buffer-list))
10589 (setq mml-buffer-list nil)
10590 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10591 (mime-to-mml ,'current-handles))
10592 (let ((mbl1 mml-buffer-list))
10593 (setq mml-buffer-list mbl)
10594 (set (make-local-variable 'mml-buffer-list) mbl1))
10595 (gnus-make-local-hook 'kill-buffer-hook)
10596 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10597 `(lambda (no-highlight)
10598 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10599 (message-options message-options)
10600 (message-options-set-recipient)
10601 (mail-parse-ignored-charsets
10602 ',gnus-newsgroup-ignored-charsets)
10603 (rfc2047-header-encoding-alist
10604 ',(let ((charset (gnus-group-name-charset
10605 (gnus-find-method-for-group
10606 gnus-newsgroup-name)
10607 gnus-newsgroup-name)))
10608 (append (list (cons "Newsgroups" charset)
10609 (cons "Followup-To" charset)
10610 (cons "Xref" charset))
10611 rfc2047-header-encoding-alist))))
10612 ,(if (not raw) '(progn
10613 (mml-to-mime)
10614 (mml-destroy-buffers)
10615 (remove-hook 'kill-buffer-hook
10616 'mml-destroy-buffers t)
10617 (kill-local-variable 'mml-buffer-list)))
10618 (gnus-summary-edit-article-done
10619 ,(or (mail-header-references gnus-current-headers) "")
10620 ,(gnus-group-read-only-p)
10621 ,gnus-summary-buffer no-highlight))))))))
10622
10623 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10624
10625 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10626 no-highlight)
10627 "Make edits to the current article permanent."
10628 (interactive)
10629 (save-excursion
10630 ;; The buffer restriction contains the entire article if it exists.
10631 (when (article-goto-body)
10632 (let ((lines (count-lines (point) (point-max)))
10633 (length (- (point-max) (point)))
10634 (case-fold-search t)
10635 (body (point-marker)))
10636 (goto-char (point-min))
10637 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10638 (delete-region (match-beginning 1) (match-end 1))
10639 (insert (number-to-string length)))
10640 (goto-char (point-min))
10641 (when (re-search-forward
10642 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10643 (delete-region (match-beginning 1) (match-end 1))
10644 (insert (number-to-string length)))
10645 (goto-char (point-min))
10646 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10647 (delete-region (match-beginning 1) (match-end 1))
10648 (insert (number-to-string lines))))))
10649 ;; Replace the article.
10650 (let ((buf (current-buffer))
10651 (article (cdr gnus-article-current))
10652 replace-result)
10653 (with-temp-buffer
10654 (insert-buffer-substring buf)
10655 (if (and (not read-only)
10656 (not (setq replace-result
10657 (gnus-request-replace-article
10658 article (car gnus-article-current)
10659 (current-buffer) t))))
10660 (error "Couldn't replace article")
10661 ;; If we got a number back, then that's the new article number
10662 ;; for this article. Otherwise, the article number didn't change.
10663 (when (numberp replace-result)
10664 (with-current-buffer gnus-summary-buffer
10665 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10666 (gnus-summary-limit gnus-newsgroup-limit)
10667 (setq article replace-result)
10668 (gnus-summary-goto-subject article t)))
10669 ;; Update the summary buffer.
10670 (if (and references
10671 (equal (message-tokenize-header references " ")
10672 (message-tokenize-header
10673 (or (message-fetch-field "references") "") " ")))
10674 ;; We only have to update this line.
10675 (save-excursion
10676 (save-restriction
10677 (message-narrow-to-head)
10678 (let ((head (buffer-substring-no-properties
10679 (point-min) (point-max)))
10680 header)
10681 (with-temp-buffer
10682 (insert (format "211 %d Article retrieved.\n" article))
10683 (insert head)
10684 (insert ".\n")
10685 (let ((nntp-server-buffer (current-buffer)))
10686 (setq header (car (gnus-get-newsgroup-headers nil t))))
10687 (with-current-buffer gnus-summary-buffer
10688 (gnus-data-set-header (gnus-data-find article) header)
10689 (gnus-summary-update-article-line article header)
10690 (if (gnus-summary-goto-subject article nil t)
10691 (gnus-summary-update-secondary-mark article)))))))
10692 ;; Update threads.
10693 (set-buffer (or buffer gnus-summary-buffer))
10694 (gnus-summary-update-article article)
10695 (if (gnus-summary-goto-subject article nil t)
10696 (gnus-summary-update-secondary-mark article)))
10697 ;; Prettify the article buffer again.
10698 (unless no-highlight
10699 (with-current-buffer gnus-article-buffer
10700 ;;!!! Fix this -- article should be rehighlighted.
10701 ;;(gnus-run-hooks 'gnus-article-display-hook)
10702 (set-buffer gnus-original-article-buffer)
10703 (gnus-request-article
10704 article (car gnus-article-current) (current-buffer))))
10705 ;; Prettify the summary buffer line.
10706 (when (gnus-visual-p 'summary-highlight 'highlight)
10707 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10708
10709 (defun gnus-summary-edit-wash (key)
10710 "Perform editing command KEY in the article buffer."
10711 (interactive
10712 (list
10713 (progn
10714 (message "%s" (concat (this-command-keys) "- "))
10715 (read-char))))
10716 (message "")
10717 (gnus-summary-edit-article)
10718 (execute-kbd-macro (concat (this-command-keys) key))
10719 (gnus-article-edit-done))
10720
10721 ;;; Respooling
10722
10723 (defvar nnimap-split-fancy)
10724 (defvar nnimap-split-methods)
10725
10726 (defun gnus-summary-respool-query (&optional silent trace)
10727 "Query where the respool algorithm would put this article."
10728 (interactive)
10729 (let (gnus-mark-article-hook)
10730 (gnus-summary-select-article)
10731 (with-current-buffer gnus-original-article-buffer
10732 (let ((groups
10733 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10734 'nnimap)
10735 ;; nnimap has its own splitting variables.
10736 (let ((nnmail-split-methods
10737 (cond
10738 ((eq nnimap-split-methods 'default)
10739 nnmail-split-methods)
10740 (nnimap-split-methods
10741 nnimap-split-methods)
10742 (nnimap-split-fancy
10743 'nnmail-split-fancy)))
10744 (nnmail-split-fancy (or nnimap-split-fancy
10745 nnmail-split-fancy)))
10746 (nnmail-article-group 'identity trace))
10747 (nnmail-article-group 'identity trace))))
10748 (unless silent
10749 (if groups
10750 (message "This message would go to %s"
10751 (mapconcat 'car groups ", "))
10752 (message "This message would go to no groups"))
10753 groups)))))
10754
10755 (defun gnus-summary-respool-trace ()
10756 "Trace where the respool algorithm would put this article.
10757 Display a buffer showing all fancy splitting patterns which matched."
10758 (interactive)
10759 (gnus-summary-respool-query nil t))
10760
10761 ;; Summary marking commands.
10762
10763 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10764 "Mark articles which has the same subject as read, and then select the next.
10765 If UNMARK is positive, remove any kind of mark.
10766 If UNMARK is negative, tick articles."
10767 (interactive "P")
10768 (when unmark
10769 (setq unmark (prefix-numeric-value unmark)))
10770 (let ((count
10771 (gnus-summary-mark-same-subject
10772 (gnus-summary-article-subject) unmark)))
10773 ;; Select next unread article. If auto-select-same mode, should
10774 ;; select the first unread article.
10775 (gnus-summary-next-article t (and gnus-auto-select-same
10776 (gnus-summary-article-subject)))
10777 (gnus-message 7 "%d article%s marked as %s"
10778 count (if (= count 1) " is" "s are")
10779 (if unmark "unread" "read"))))
10780
10781 (defun gnus-summary-kill-same-subject (&optional unmark)
10782 "Mark articles which has the same subject as read.
10783 If UNMARK is positive, remove any kind of mark.
10784 If UNMARK is negative, tick articles."
10785 (interactive "P")
10786 (when unmark
10787 (setq unmark (prefix-numeric-value unmark)))
10788 (let ((count
10789 (gnus-summary-mark-same-subject
10790 (gnus-summary-article-subject) unmark)))
10791 ;; If marked as read, go to next unread subject.
10792 (when (null unmark)
10793 ;; Go to next unread subject.
10794 (gnus-summary-next-subject 1 t))
10795 (gnus-message 7 "%d articles are marked as %s"
10796 count (if unmark "unread" "read"))))
10797
10798 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10799 "Mark articles with same SUBJECT as read, and return marked number.
10800 If optional argument UNMARK is positive, remove any kinds of marks.
10801 If optional argument UNMARK is negative, mark articles as unread instead."
10802 (let ((count 1))
10803 (save-excursion
10804 (cond
10805 ((null unmark) ; Mark as read.
10806 (while (and
10807 (progn
10808 (gnus-summary-mark-article-as-read gnus-killed-mark)
10809 (gnus-summary-show-thread) t)
10810 (gnus-summary-find-subject subject))
10811 (setq count (1+ count))))
10812 ((> unmark 0) ; Tick.
10813 (while (and
10814 (progn
10815 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10816 (gnus-summary-show-thread) t)
10817 (gnus-summary-find-subject subject))
10818 (setq count (1+ count))))
10819 (t ; Mark as unread.
10820 (while (and
10821 (progn
10822 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10823 (gnus-summary-show-thread) t)
10824 (gnus-summary-find-subject subject))
10825 (setq count (1+ count)))))
10826 (gnus-set-mode-line 'summary)
10827 ;; Return the number of marked articles.
10828 count)))
10829
10830 (defun gnus-summary-mark-as-processable (n &optional unmark)
10831 "Set the process mark on the next N articles.
10832 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10833 the process mark instead. The difference between N and the actual
10834 number of articles marked is returned."
10835 (interactive "P")
10836 (if (and (null n) (and transient-mark-mode mark-active))
10837 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10838 (setq n (prefix-numeric-value n))
10839 (let ((backward (< n 0))
10840 (n (abs n)))
10841 (while (and
10842 (> n 0)
10843 (if unmark
10844 (gnus-summary-remove-process-mark
10845 (gnus-summary-article-number))
10846 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10847 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10848 (setq n (1- n)))
10849 (when (/= 0 n)
10850 (gnus-message 7 "No more articles"))
10851 (gnus-summary-recenter)
10852 (gnus-summary-position-point)
10853 n)))
10854
10855 (defun gnus-summary-unmark-as-processable (n)
10856 "Remove the process mark from the next N articles.
10857 If N is negative, unmark backward instead. The difference between N and
10858 the actual number of articles unmarked is returned."
10859 (interactive "P")
10860 (gnus-summary-mark-as-processable n t))
10861
10862 (defun gnus-summary-unmark-all-processable ()
10863 "Remove the process mark from all articles."
10864 (interactive)
10865 (save-excursion
10866 (while gnus-newsgroup-processable
10867 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10868 (gnus-summary-position-point))
10869
10870 (defun gnus-summary-add-mark (article type)
10871 "Mark ARTICLE with a mark of TYPE."
10872 (let ((vtype (car (assq type gnus-article-mark-lists)))
10873 var)
10874 (if (not vtype)
10875 (error "No such mark type: %s" type)
10876 (setq var (intern (format "gnus-newsgroup-%s" type)))
10877 (set var (cons article (symbol-value var)))
10878 (if (memq type '(processable cached replied forwarded recent saved))
10879 (gnus-summary-update-secondary-mark article)
10880 ;;; !!! This is bogus. We should find out what primary
10881 ;;; !!! mark we want to set.
10882 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10883
10884 (defun gnus-summary-mark-as-expirable (n)
10885 "Mark N articles forward as expirable.
10886 If N is negative, mark backward instead. The difference between N and
10887 the actual number of articles marked is returned."
10888 (interactive "p")
10889 (gnus-summary-mark-forward n gnus-expirable-mark))
10890
10891 (defun gnus-summary-mark-as-spam (n)
10892 "Mark N articles forward as spam.
10893 If N is negative, mark backward instead. The difference between N and
10894 the actual number of articles marked is returned."
10895 (interactive "p")
10896 (gnus-summary-mark-forward n gnus-spam-mark))
10897
10898 (defun gnus-summary-mark-article-as-replied (article)
10899 "Mark ARTICLE as replied to and update the summary line.
10900 ARTICLE can also be a list of articles."
10901 (interactive (list (gnus-summary-article-number)))
10902 (let ((articles (if (listp article) article (list article))))
10903 (dolist (article articles)
10904 (unless (numberp article)
10905 (error "%s is not a number" article))
10906 (push article gnus-newsgroup-replied)
10907 (let ((inhibit-read-only t))
10908 (when (gnus-summary-goto-subject article nil t)
10909 (gnus-summary-update-secondary-mark article))))))
10910
10911 (defun gnus-summary-mark-article-as-forwarded (article)
10912 "Mark ARTICLE as forwarded and update the summary line.
10913 ARTICLE can also be a list of articles."
10914 (let ((articles (if (listp article) article (list article))))
10915 (dolist (article articles)
10916 (push article gnus-newsgroup-forwarded)
10917 (let ((inhibit-read-only t))
10918 (when (gnus-summary-goto-subject article nil t)
10919 (gnus-summary-update-secondary-mark article))))))
10920
10921 (defun gnus-summary-set-bookmark (article)
10922 "Set a bookmark in current article."
10923 (interactive (list (gnus-summary-article-number)))
10924 (when (or (not (get-buffer gnus-article-buffer))
10925 (not gnus-current-article)
10926 (not gnus-article-current)
10927 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10928 (error "No current article selected"))
10929 ;; Remove old bookmark, if one exists.
10930 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10931 ;; Set the new bookmark, which is on the form
10932 ;; (article-number . line-number-in-body).
10933 (push
10934 (cons article
10935 (with-current-buffer gnus-article-buffer
10936 (count-lines
10937 (min (point)
10938 (save-excursion
10939 (article-goto-body)
10940 (point)))
10941 (point))))
10942 gnus-newsgroup-bookmarks)
10943 (gnus-message 6 "A bookmark has been added to the current article."))
10944
10945 (defun gnus-summary-remove-bookmark (article)
10946 "Remove the bookmark from the current article."
10947 (interactive (list (gnus-summary-article-number)))
10948 ;; Remove old bookmark, if one exists.
10949 (if (not (assq article gnus-newsgroup-bookmarks))
10950 (gnus-message 6 "No bookmark in current article.")
10951 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10952 (gnus-message 6 "Removed bookmark.")))
10953
10954 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10955 (defun gnus-summary-mark-as-dormant (n)
10956 "Mark N articles forward as dormant.
10957 If N is negative, mark backward instead. The difference between N and
10958 the actual number of articles marked is returned."
10959 (interactive "p")
10960 (gnus-summary-mark-forward n gnus-dormant-mark))
10961
10962 (defun gnus-summary-set-process-mark (article)
10963 "Set the process mark on ARTICLE and update the summary line."
10964 (setq gnus-newsgroup-processable
10965 (cons article
10966 (delq article gnus-newsgroup-processable)))
10967 (when (gnus-summary-goto-subject article)
10968 (gnus-summary-show-thread)
10969 (gnus-summary-goto-subject article)
10970 (gnus-summary-update-secondary-mark article)))
10971
10972 (defun gnus-summary-remove-process-mark (&rest articles)
10973 "Remove the process mark from ARTICLES and update the summary line."
10974 (dolist (article articles)
10975 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10976 (when (gnus-summary-goto-subject article)
10977 (gnus-summary-show-thread)
10978 (gnus-summary-goto-subject article)
10979 (gnus-summary-update-secondary-mark article)))
10980 t)
10981
10982 (defun gnus-summary-set-saved-mark (article)
10983 "Set the process mark on ARTICLE and update the summary line."
10984 (push article gnus-newsgroup-saved)
10985 (when (gnus-summary-goto-subject article)
10986 (gnus-summary-update-secondary-mark article)))
10987
10988 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10989 "Mark N articles as read forwards.
10990 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10991 The difference between N and the actual number of articles marked is
10992 returned.
10993 If NO-EXPIRE, auto-expiry will be inhibited."
10994 (interactive "p")
10995 (gnus-summary-show-thread)
10996 (let ((backward (< n 0))
10997 (gnus-summary-goto-unread
10998 (and gnus-summary-goto-unread
10999 (not (eq gnus-summary-goto-unread 'never))
11000 (not (memq mark (list gnus-unread-mark gnus-spam-mark
11001 gnus-ticked-mark gnus-dormant-mark)))))
11002 (n (abs n))
11003 (mark (or mark gnus-del-mark)))
11004 (while (and (> n 0)
11005 (gnus-summary-mark-article nil mark no-expire)
11006 (zerop (gnus-summary-next-subject
11007 (if backward -1 1)
11008 (and gnus-summary-goto-unread
11009 (not (eq gnus-summary-goto-unread 'never)))
11010 t)))
11011 (setq n (1- n)))
11012 (when (/= 0 n)
11013 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11014 (gnus-summary-recenter)
11015 (gnus-summary-position-point)
11016 (gnus-set-mode-line 'summary)
11017 n))
11018
11019 (defun gnus-summary-mark-article-as-read (mark)
11020 "Mark the current article quickly as read with MARK."
11021 (let ((article (gnus-summary-article-number)))
11022 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11023 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11024 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11025 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11026 (push (cons article mark) gnus-newsgroup-reads)
11027 ;; Possibly remove from cache, if that is used.
11028 (when gnus-use-cache
11029 (gnus-cache-enter-remove-article article))
11030 ;; Allow the backend to change the mark.
11031 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11032 ;; Check for auto-expiry.
11033 (when (and gnus-newsgroup-auto-expire
11034 (memq mark gnus-auto-expirable-marks))
11035 (setq mark gnus-expirable-mark)
11036 ;; Let the backend know about the mark change.
11037 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11038 (push article gnus-newsgroup-expirable))
11039 ;; Set the mark in the buffer.
11040 (gnus-summary-update-mark mark 'unread)
11041 t))
11042
11043 (defun gnus-summary-mark-article-as-unread (mark)
11044 "Mark the current article quickly as unread with MARK."
11045 (let* ((article (gnus-summary-article-number))
11046 (old-mark (gnus-summary-article-mark article)))
11047 ;; Allow the backend to change the mark.
11048 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11049 (if (eq mark old-mark)
11050 t
11051 (if (<= article 0)
11052 (progn
11053 (gnus-error 1 "Can't mark negative article numbers")
11054 nil)
11055 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11056 (setq gnus-newsgroup-spam-marked
11057 (delq article gnus-newsgroup-spam-marked))
11058 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11059 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11060 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11061 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11062 (cond ((= mark gnus-ticked-mark)
11063 (setq gnus-newsgroup-marked
11064 (gnus-add-to-sorted-list gnus-newsgroup-marked
11065 article)))
11066 ((= mark gnus-spam-mark)
11067 (setq gnus-newsgroup-spam-marked
11068 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11069 article)))
11070 ((= mark gnus-dormant-mark)
11071 (setq gnus-newsgroup-dormant
11072 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11073 article)))
11074 (t
11075 (setq gnus-newsgroup-unreads
11076 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11077 article))))
11078 (gnus-alist-pull article gnus-newsgroup-reads)
11079
11080 ;; See whether the article is to be put in the cache.
11081 (and gnus-use-cache
11082 (vectorp (gnus-summary-article-header article))
11083 (save-excursion
11084 (gnus-cache-possibly-enter-article
11085 gnus-newsgroup-name article
11086 (= mark gnus-ticked-mark)
11087 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11088
11089 ;; Fix the mark.
11090 (gnus-summary-update-mark mark 'unread)
11091 t))))
11092
11093 (defun gnus-summary-mark-article (&optional article mark no-expire)
11094 "Mark ARTICLE with MARK. MARK can be any character.
11095 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11096 `??' (dormant) and `?E' (expirable).
11097 If MARK is nil, then the default character `?r' is used.
11098 If ARTICLE is nil, then the article on the current line will be
11099 marked.
11100 If NO-EXPIRE, auto-expiry will be inhibited."
11101 ;; The mark might be a string.
11102 (when (stringp mark)
11103 (setq mark (aref mark 0)))
11104 ;; If no mark is given, then we check auto-expiring.
11105 (when (null mark)
11106 (setq mark gnus-del-mark))
11107 (when (and (not no-expire)
11108 gnus-newsgroup-auto-expire
11109 (memq mark gnus-auto-expirable-marks))
11110 (setq mark gnus-expirable-mark))
11111 (let ((article (or article (gnus-summary-article-number)))
11112 (old-mark (gnus-summary-article-mark article)))
11113 ;; Allow the backend to change the mark.
11114 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11115 (if (eq mark old-mark)
11116 t
11117 (unless article
11118 (error "No article on current line"))
11119 (if (not (if (or (= mark gnus-unread-mark)
11120 (= mark gnus-ticked-mark)
11121 (= mark gnus-spam-mark)
11122 (= mark gnus-dormant-mark))
11123 (gnus-mark-article-as-unread article mark)
11124 (gnus-mark-article-as-read article mark)))
11125 t
11126 ;; See whether the article is to be put in the cache.
11127 (and gnus-use-cache
11128 (not (= mark gnus-canceled-mark))
11129 (vectorp (gnus-summary-article-header article))
11130 (save-excursion
11131 (gnus-cache-possibly-enter-article
11132 gnus-newsgroup-name article
11133 (= mark gnus-ticked-mark)
11134 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11135
11136 (when (gnus-summary-goto-subject article nil t)
11137 (let ((inhibit-read-only t))
11138 (gnus-summary-show-thread)
11139 ;; Fix the mark.
11140 (gnus-summary-update-mark mark 'unread)
11141 t))))))
11142
11143 (defun gnus-summary-update-secondary-mark (article)
11144 "Update the secondary (read, process, cache) mark."
11145 (gnus-summary-update-mark
11146 (cond ((memq article gnus-newsgroup-processable)
11147 gnus-process-mark)
11148 ((memq article gnus-newsgroup-cached)
11149 gnus-cached-mark)
11150 ((memq article gnus-newsgroup-replied)
11151 gnus-replied-mark)
11152 ((memq article gnus-newsgroup-forwarded)
11153 gnus-forwarded-mark)
11154 ((memq article gnus-newsgroup-saved)
11155 gnus-saved-mark)
11156 ((memq article gnus-newsgroup-unseen)
11157 gnus-unseen-mark)
11158 (t gnus-no-mark))
11159 'replied)
11160 (when (gnus-visual-p 'summary-highlight 'highlight)
11161 (gnus-summary-highlight-line)
11162 (gnus-run-hooks 'gnus-summary-update-hook))
11163 t)
11164
11165 (defun gnus-summary-update-download-mark (article)
11166 "Update the download mark."
11167 (gnus-summary-update-mark
11168 (cond ((memq article gnus-newsgroup-undownloaded)
11169 gnus-undownloaded-mark)
11170 (gnus-newsgroup-agentized
11171 gnus-downloaded-mark)
11172 (t
11173 gnus-no-mark))
11174 'download)
11175 (gnus-summary-update-line t)
11176 t)
11177
11178 (defun gnus-summary-update-mark (mark type)
11179 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11180 (inhibit-read-only t))
11181 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11182 (when forward
11183 (when (looking-at "\r")
11184 (incf forward))
11185 (when (<= (+ forward (point)) (point-max))
11186 ;; Go to the right position on the line.
11187 (goto-char (+ forward (point)))
11188 ;; Replace the old mark with the new mark.
11189 (let ((to-insert
11190 (mm-subst-char-in-string
11191 (char-after) mark
11192 (buffer-substring (point) (1+ (point))))))
11193 (delete-region (point) (1+ (point)))
11194 (insert to-insert))
11195 ;; Optionally update the marks by some user rule.
11196 (when (eq type 'unread)
11197 (gnus-data-set-mark
11198 (gnus-data-find (gnus-summary-article-number)) mark)
11199 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11200
11201 (defun gnus-mark-article-as-read (article &optional mark)
11202 "Enter ARTICLE in the pertinent lists and remove it from others."
11203 ;; Make the article expirable.
11204 (let ((mark (or mark gnus-del-mark)))
11205 (setq gnus-newsgroup-expirable
11206 (if (= mark gnus-expirable-mark)
11207 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11208 (delq article gnus-newsgroup-expirable)))
11209 ;; Remove from unread and marked lists.
11210 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11211 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11212 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11213 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11214 (push (cons article mark) gnus-newsgroup-reads)
11215 ;; Possibly remove from cache, if that is used.
11216 (when gnus-use-cache
11217 (gnus-cache-enter-remove-article article))
11218 t))
11219
11220 (defun gnus-mark-article-as-unread (article &optional mark)
11221 "Enter ARTICLE in the pertinent lists and remove it from others."
11222 (let ((mark (or mark gnus-ticked-mark)))
11223 (if (<= article 0)
11224 (progn
11225 (gnus-error 1 "Can't mark negative article numbers")
11226 nil)
11227 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11228 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11229 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11230 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11231 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11232
11233 ;; Unsuppress duplicates?
11234 (when gnus-suppress-duplicates
11235 (gnus-dup-unsuppress-article article))
11236
11237 (cond ((= mark gnus-ticked-mark)
11238 (setq gnus-newsgroup-marked
11239 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11240 ((= mark gnus-spam-mark)
11241 (setq gnus-newsgroup-spam-marked
11242 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11243 article)))
11244 ((= mark gnus-dormant-mark)
11245 (setq gnus-newsgroup-dormant
11246 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11247 (t
11248 (setq gnus-newsgroup-unreads
11249 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11250 (gnus-alist-pull article gnus-newsgroup-reads)
11251 t)))
11252
11253 (defun gnus-summary-tick-article-forward (n)
11254 "Tick N articles forwards.
11255 If N is negative, tick backwards instead.
11256 The difference between N and the number of articles ticked is returned."
11257 (interactive "p")
11258 (gnus-summary-mark-forward n gnus-ticked-mark))
11259
11260 (defun gnus-summary-tick-article-backward (n)
11261 "Tick N articles backwards.
11262 The difference between N and the number of articles ticked is returned."
11263 (interactive "p")
11264 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11265
11266 (defun gnus-summary-tick-article (&optional article clear-mark)
11267 "Mark current article as unread.
11268 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11269 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11270 (interactive)
11271 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11272 gnus-ticked-mark)))
11273
11274 (defun gnus-summary-mark-as-read-forward (n)
11275 "Mark N articles as read forwards.
11276 If N is negative, mark backwards instead.
11277 The difference between N and the actual number of articles marked is
11278 returned."
11279 (interactive "p")
11280 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11281
11282 (defun gnus-summary-mark-as-read-backward (n)
11283 "Mark the N articles as read backwards.
11284 The difference between N and the actual number of articles marked is
11285 returned."
11286 (interactive "p")
11287 (gnus-summary-mark-forward
11288 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11289
11290 (defun gnus-summary-mark-as-read (&optional article mark)
11291 "Mark current article as read.
11292 ARTICLE specifies the article to be marked as read.
11293 MARK specifies a string to be inserted at the beginning of the line."
11294 (gnus-summary-mark-article article mark))
11295
11296 (defun gnus-summary-clear-mark-forward (n)
11297 "Clear marks from N articles forward.
11298 If N is negative, clear backward instead.
11299 The difference between N and the number of marks cleared is returned."
11300 (interactive "p")
11301 (gnus-summary-mark-forward n gnus-unread-mark))
11302
11303 (defun gnus-summary-clear-mark-backward (n)
11304 "Clear marks from N articles backward.
11305 The difference between N and the number of marks cleared is returned."
11306 (interactive "p")
11307 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11308
11309 (defun gnus-summary-mark-unread-as-read ()
11310 "Intended to be used by `gnus-mark-article-hook'."
11311 (when (memq gnus-current-article gnus-newsgroup-unreads)
11312 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11313
11314 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11315 "Intended to be used by `gnus-mark-article-hook'."
11316 (let ((mark (gnus-summary-article-mark)))
11317 (when (or (gnus-unread-mark-p mark)
11318 (gnus-read-mark-p mark))
11319 (gnus-summary-mark-article gnus-current-article
11320 (or new-mark gnus-read-mark)))))
11321
11322 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11323 "Intended to be used by `gnus-mark-article-hook'."
11324 (let ((mark (gnus-summary-article-mark)))
11325 (when (or (gnus-unread-mark-p mark)
11326 (gnus-read-mark-p mark))
11327 (gnus-summary-mark-article (gnus-summary-article-number)
11328 (or new-mark gnus-read-mark)))))
11329
11330 (defun gnus-summary-mark-unread-as-ticked ()
11331 "Intended to be used by `gnus-mark-article-hook'."
11332 (when (memq gnus-current-article gnus-newsgroup-unreads)
11333 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11334
11335 (defun gnus-summary-mark-region-as-read (point mark all)
11336 "Mark all unread articles between point and mark as read.
11337 If given a prefix, mark all articles between point and mark as read,
11338 even ticked and dormant ones."
11339 (interactive "r\nP")
11340 (save-excursion
11341 (let (article)
11342 (goto-char point)
11343 (beginning-of-line)
11344 (while (and
11345 (< (point) mark)
11346 (progn
11347 (when (or all
11348 (memq (setq article (gnus-summary-article-number))
11349 gnus-newsgroup-unreads))
11350 (gnus-summary-mark-article article gnus-del-mark))
11351 t)
11352 (gnus-summary-find-next))))))
11353
11354 (defun gnus-summary-mark-below (score mark)
11355 "Mark articles with score less than SCORE with MARK."
11356 (interactive "P\ncMark: ")
11357 (setq score (if score
11358 (prefix-numeric-value score)
11359 (or gnus-summary-default-score 0)))
11360 (with-current-buffer gnus-summary-buffer
11361 (goto-char (point-min))
11362 (while
11363 (progn
11364 (and (< (gnus-summary-article-score) score)
11365 (gnus-summary-mark-article nil mark))
11366 (gnus-summary-find-next)))))
11367
11368 (defun gnus-summary-kill-below (&optional score)
11369 "Mark articles with score below SCORE as read."
11370 (interactive "P")
11371 (gnus-summary-mark-below score gnus-killed-mark))
11372
11373 (defun gnus-summary-clear-above (&optional score)
11374 "Clear all marks from articles with score above SCORE."
11375 (interactive "P")
11376 (gnus-summary-mark-above score gnus-unread-mark))
11377
11378 (defun gnus-summary-tick-above (&optional score)
11379 "Tick all articles with score above SCORE."
11380 (interactive "P")
11381 (gnus-summary-mark-above score gnus-ticked-mark))
11382
11383 (defun gnus-summary-mark-above (score mark)
11384 "Mark articles with score over SCORE with MARK."
11385 (interactive "P\ncMark: ")
11386 (setq score (if score
11387 (prefix-numeric-value score)
11388 (or gnus-summary-default-score 0)))
11389 (with-current-buffer gnus-summary-buffer
11390 (goto-char (point-min))
11391 (while (and (progn
11392 (when (> (gnus-summary-article-score) score)
11393 (gnus-summary-mark-article nil mark))
11394 t)
11395 (gnus-summary-find-next)))))
11396
11397 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11398 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11399 (defun gnus-summary-limit-include-expunged (&optional no-error)
11400 "Display all the hidden articles that were expunged for low scores."
11401 (interactive)
11402 (let ((inhibit-read-only t))
11403 (let ((scored gnus-newsgroup-scored)
11404 headers h)
11405 (while scored
11406 (unless (gnus-summary-article-header (caar scored))
11407 (and (setq h (gnus-number-to-header (caar scored)))
11408 (< (cdar scored) gnus-summary-expunge-below)
11409 (push h headers)))
11410 (setq scored (cdr scored)))
11411 (if (not headers)
11412 (when (not no-error)
11413 (error "No expunged articles hidden"))
11414 (goto-char (point-min))
11415 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11416 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11417 (dolist (x headers)
11418 (push (mail-header-number x) gnus-newsgroup-limit))
11419 (gnus-summary-prepare-unthreaded (nreverse headers))
11420 (goto-char (point-min))
11421 (gnus-summary-position-point)
11422 t))))
11423
11424 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11425 "Mark all unread articles in this newsgroup as read.
11426 If prefix argument ALL is non-nil, ticked and dormant articles will
11427 also be marked as read.
11428 If QUIETLY is non-nil, no questions will be asked.
11429
11430 If TO-HERE is non-nil, it should be a point in the buffer. All
11431 articles before (after, if REVERSE is set) this point will be marked
11432 as read.
11433
11434 Note that this function will only catch up the unread article
11435 in the current summary buffer limitation.
11436
11437 The number of articles marked as read is returned."
11438 (interactive "P")
11439 (prog1
11440 (save-excursion
11441 (when (or quietly
11442 (not gnus-interactive-catchup) ;Without confirmation?
11443 gnus-expert-user
11444 (gnus-y-or-n-p
11445 (if all
11446 "Mark absolutely all articles as read? "
11447 "Mark all unread articles as read? ")))
11448 (if (and not-mark
11449 (not gnus-newsgroup-adaptive)
11450 (not gnus-newsgroup-auto-expire)
11451 (not gnus-suppress-duplicates)
11452 (or (not gnus-use-cache)
11453 (eq gnus-use-cache 'passive)))
11454 (progn
11455 (when all
11456 (setq gnus-newsgroup-marked nil
11457 gnus-newsgroup-spam-marked nil
11458 gnus-newsgroup-dormant nil))
11459 (setq gnus-newsgroup-unreads
11460 (gnus-sorted-nunion
11461 (gnus-sorted-intersection gnus-newsgroup-unreads
11462 gnus-newsgroup-downloadable)
11463 (gnus-sorted-difference gnus-newsgroup-unfetched
11464 gnus-newsgroup-cached))))
11465 ;; We actually mark all articles as canceled, which we
11466 ;; have to do when using auto-expiry or adaptive scoring.
11467 (gnus-summary-show-all-threads)
11468 (if (and to-here reverse)
11469 (progn
11470 (goto-char to-here)
11471 (gnus-summary-mark-current-read-and-unread-as-read
11472 gnus-catchup-mark)
11473 (while (gnus-summary-find-next (not all))
11474 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11475 (when (gnus-summary-first-subject (not all))
11476 (while (and
11477 (if to-here (< (point) to-here) t)
11478 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11479 (gnus-summary-find-next (not all))))))
11480 (gnus-set-mode-line 'summary))
11481 t))
11482 (gnus-summary-position-point)))
11483
11484 (defun gnus-summary-catchup-to-here (&optional all)
11485 "Mark all unticked articles before the current one as read.
11486 If ALL is non-nil, also mark ticked and dormant articles as read."
11487 (interactive "P")
11488 (save-excursion
11489 (gnus-save-hidden-threads
11490 (let ((beg (point)))
11491 ;; We check that there are unread articles.
11492 (when (or all (gnus-summary-find-prev))
11493 (gnus-summary-catchup all t beg)))))
11494 (gnus-summary-position-point))
11495
11496 (defun gnus-summary-catchup-from-here (&optional all)
11497 "Mark all unticked articles after (and including) the current one as read.
11498 If ALL is non-nil, also mark ticked and dormant articles as read."
11499 (interactive "P")
11500 (save-excursion
11501 (gnus-save-hidden-threads
11502 (let ((beg (point)))
11503 ;; We check that there are unread articles.
11504 (when (or all (gnus-summary-find-next))
11505 (gnus-summary-catchup all t beg nil t)))))
11506 (gnus-summary-position-point))
11507
11508 (defun gnus-summary-catchup-all (&optional quietly)
11509 "Mark all articles in this newsgroup as read.
11510 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11511 instead, which marks only unread articles as read."
11512 (interactive "P")
11513 (gnus-summary-catchup t quietly))
11514
11515 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11516 "Mark all unread articles in this group as read, then exit.
11517 If prefix argument ALL is non-nil, all articles are marked as read.
11518 If QUIETLY is non-nil, no questions will be asked."
11519 (interactive "P")
11520 (when (gnus-summary-catchup all quietly nil 'fast)
11521 ;; Select next newsgroup or exit.
11522 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11523 (eq gnus-auto-select-next 'quietly))
11524 (gnus-summary-next-group nil)
11525 (gnus-summary-exit))))
11526
11527 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11528 "Mark all articles in this newsgroup as read, and then exit.
11529 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11530 instead, which marks only unread articles as read."
11531 (interactive "P")
11532 (gnus-summary-catchup-and-exit t quietly))
11533
11534 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11535 "Mark all articles in this group as read and select the next group.
11536 If given a prefix, mark all articles, unread as well as ticked, as
11537 read."
11538 (interactive "P")
11539 (save-excursion
11540 (gnus-summary-catchup all))
11541 (gnus-summary-next-group))
11542
11543 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11544 "Mark all articles in this group as read and select the previous group.
11545 If given a prefix, mark all articles, unread as well as ticked, as
11546 read."
11547 (interactive "P")
11548 (save-excursion
11549 (gnus-summary-catchup all))
11550 (gnus-summary-next-group nil nil t))
11551
11552 ;;;
11553 ;;; with article
11554 ;;;
11555
11556 (defmacro gnus-with-article (article &rest forms)
11557 "Select ARTICLE and perform FORMS in the original article buffer.
11558 Then replace the article with the result."
11559 `(progn
11560 ;; We don't want the article to be marked as read.
11561 (let (gnus-mark-article-hook)
11562 (gnus-summary-select-article t t nil ,article))
11563 (set-buffer gnus-original-article-buffer)
11564 ,@forms
11565 (if (not (gnus-check-backend-function
11566 'request-replace-article (car gnus-article-current)))
11567 (gnus-message 5 "Read-only group; not replacing")
11568 (unless (gnus-request-replace-article
11569 ,article (car gnus-article-current)
11570 (current-buffer) t)
11571 (error "Couldn't replace article")))
11572 ;; The cache and backlog have to be flushed somewhat.
11573 (when gnus-keep-backlog
11574 (gnus-backlog-remove-article
11575 (car gnus-article-current) (cdr gnus-article-current)))
11576 (when gnus-use-cache
11577 (gnus-cache-update-article
11578 (car gnus-article-current) (cdr gnus-article-current)))))
11579
11580 (put 'gnus-with-article 'lisp-indent-function 1)
11581 (put 'gnus-with-article 'edebug-form-spec '(form body))
11582
11583 ;; Thread-based commands.
11584
11585 (defun gnus-summary-articles-in-thread (&optional article)
11586 "Return a list of all articles in the current thread.
11587 If ARTICLE is non-nil, return all articles in the thread that starts
11588 with that article."
11589 (let* ((article (or article (gnus-summary-article-number)))
11590 (data (gnus-data-find-list article))
11591 (top-level (gnus-data-level (car data)))
11592 (top-subject
11593 (cond ((null gnus-thread-operation-ignore-subject)
11594 (gnus-simplify-subject-re
11595 (mail-header-subject (gnus-data-header (car data)))))
11596 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11597 (gnus-simplify-subject-fuzzy
11598 (mail-header-subject (gnus-data-header (car data)))))
11599 (t nil)))
11600 (end-point (save-excursion
11601 (goto-char (gnus-data-pos (car data)))
11602 (if (gnus-summary-go-to-next-thread)
11603 (point) (point-max))))
11604 articles)
11605 (while (and data
11606 (< (gnus-data-pos (car data)) end-point))
11607 (when (or (not top-subject)
11608 (string= top-subject
11609 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11610 (gnus-simplify-subject-fuzzy
11611 (mail-header-subject
11612 (gnus-data-header (car data))))
11613 (gnus-simplify-subject-re
11614 (mail-header-subject
11615 (gnus-data-header (car data)))))))
11616 (push (gnus-data-number (car data)) articles))
11617 (unless (and (setq data (cdr data))
11618 (> (gnus-data-level (car data)) top-level))
11619 (setq data nil)))
11620 ;; Return the list of articles.
11621 (nreverse articles)))
11622
11623 (defun gnus-summary-rethread-current ()
11624 "Rethread the thread the current article is part of."
11625 (interactive)
11626 (let* ((gnus-show-threads t)
11627 (article (gnus-summary-article-number))
11628 (id (mail-header-id (gnus-summary-article-header)))
11629 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11630 (unless id
11631 (error "No article on the current line"))
11632 (gnus-rebuild-thread id)
11633 (gnus-summary-goto-subject article)))
11634
11635 (defun gnus-summary-reparent-thread ()
11636 "Make the current article child of the marked (or previous) article.
11637
11638 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11639 is non-nil or the Subject: of both articles are the same."
11640 (interactive)
11641 (unless (not (gnus-group-read-only-p))
11642 (error "The current newsgroup does not support article editing"))
11643 (unless (<= (length gnus-newsgroup-processable) 1)
11644 (error "No more than one article may be marked"))
11645 (let ((child (gnus-summary-article-number))
11646 ;; First grab the marked article, otherwise one line up.
11647 (parent (if (not (null gnus-newsgroup-processable))
11648 (car gnus-newsgroup-processable)
11649 (save-excursion
11650 (if (eq (forward-line -1) 0)
11651 (gnus-summary-article-number)
11652 (error "Beginning of summary buffer"))))))
11653 (gnus-summary-reparent-children parent (list child))))
11654
11655 (defun gnus-summary-reparent-children (parent children)
11656 "Make PARENT the parent of CHILDREN.
11657 When called interactively, PARENT is the current article and CHILDREN
11658 are the process-marked articles."
11659 (interactive
11660 (list (gnus-summary-article-number)
11661 (gnus-summary-work-articles nil)))
11662 (dolist (child children)
11663 (save-window-excursion
11664 (let ((gnus-article-buffer " *reparent*"))
11665 (unless (not (eq parent child))
11666 (error "An article may not be self-referential"))
11667 (let ((message-id (mail-header-id
11668 (gnus-summary-article-header parent))))
11669 (unless (and message-id (not (equal message-id "")))
11670 (error "No message-id in desired parent"))
11671 (gnus-with-article child
11672 (save-restriction
11673 (goto-char (point-min))
11674 (message-narrow-to-head)
11675 (if (re-search-forward "^References: " nil t)
11676 (progn
11677 (re-search-forward "^[^ \t]" nil t)
11678 (forward-line -1)
11679 (end-of-line)
11680 (insert " " message-id))
11681 (insert "References: " message-id "\n"))))
11682 (set-buffer gnus-summary-buffer)
11683 (gnus-summary-unmark-all-processable)
11684 (gnus-summary-update-article child)
11685 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11686 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11687 (gnus-summary-rethread-current)
11688 (gnus-message 3 "Article %d is now the child of article %d"
11689 child parent))))))
11690
11691 (defun gnus-summary-toggle-threads (&optional arg)
11692 "Toggle showing conversation threads.
11693 If ARG is positive number, turn showing conversation threads on."
11694 (interactive "P")
11695 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11696 (setq gnus-show-threads
11697 (if (null arg) (not gnus-show-threads)
11698 (> (prefix-numeric-value arg) 0)))
11699 (gnus-summary-prepare)
11700 (gnus-summary-goto-subject current)
11701 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11702 (gnus-summary-position-point)))
11703
11704 (defun gnus-summary-show-all-threads ()
11705 "Show all threads."
11706 (interactive)
11707 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11708 (gnus-summary-position-point))
11709
11710 (defsubst gnus-summary--inv (p)
11711 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11712
11713 (defun gnus-summary-show-thread ()
11714 "Show thread subtrees.
11715 Returns nil if no thread was there to be shown."
11716 (interactive)
11717 (let* ((orig (point))
11718 (end (point-at-eol))
11719 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11720 ;; Leave point at bol
11721 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11722 (eoi (when end
11723 (if (fboundp 'next-single-char-property-change)
11724 ;; Note: XEmacs version of n-s-c-p-c may return nil
11725 (or (next-single-char-property-change end 'invisible)
11726 (point-max))
11727 (while (progn
11728 (end-of-line 2)
11729 (and (not (eobp))
11730 (eq (get-char-property (point) 'invisible)
11731 'gnus-sum))))
11732 (point)))))
11733 (when eoi
11734 (remove-overlays beg eoi 'invisible 'gnus-sum)
11735 (goto-char orig)
11736 (gnus-summary-position-point)
11737 eoi)))
11738
11739 (defun gnus-summary-maybe-hide-threads ()
11740 "If requested, hide the threads that should be hidden."
11741 (when (and gnus-show-threads
11742 gnus-thread-hide-subtree)
11743 (gnus-summary-hide-all-threads
11744 (if (or (consp gnus-thread-hide-subtree)
11745 (functionp gnus-thread-hide-subtree))
11746 (gnus-make-predicate gnus-thread-hide-subtree)
11747 nil))))
11748
11749 ;;; Hiding predicates.
11750
11751 (defun gnus-article-unread-p (header)
11752 (memq (mail-header-number header) gnus-newsgroup-unreads))
11753
11754 (defun gnus-article-unseen-p (header)
11755 (memq (mail-header-number header) gnus-newsgroup-unseen))
11756
11757 (defun gnus-map-articles (predicate articles)
11758 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11759 (apply 'gnus-or (mapcar predicate
11760 (mapcar (lambda (number)
11761 (gnus-summary-article-header number))
11762 articles))))
11763
11764 (defun gnus-summary-hide-all-threads (&optional predicate)
11765 "Hide all thread subtrees.
11766 If PREDICATE is supplied, threads that satisfy this predicate
11767 will not be hidden."
11768 (interactive)
11769 (save-excursion
11770 (goto-char (point-min))
11771 (let ((end nil)
11772 (count 0))
11773 (while (not end)
11774 (incf count)
11775 (when (zerop (mod count 1000))
11776 (message "Hiding all threads... %d" count))
11777 (when (or (not predicate)
11778 (gnus-map-articles
11779 predicate (gnus-summary-article-children)))
11780 (gnus-summary-hide-thread))
11781 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11782 (gnus-summary-position-point))
11783
11784 (defun gnus-summary-hide-thread ()
11785 "Hide thread subtrees.
11786 If PREDICATE is supplied, threads that satisfy this predicate
11787 will not be hidden.
11788 Returns nil if no threads were there to be hidden."
11789 (interactive)
11790 (beginning-of-line)
11791 (let ((start (point))
11792 (starteol (line-end-position))
11793 (article (gnus-summary-article-number)))
11794 ;; Go forward until either the buffer ends or the subthread ends.
11795 (when (and (not (eobp))
11796 (or (zerop (gnus-summary-next-thread 1 t))
11797 (goto-char (point-max))))
11798 (if (and (> (point) start)
11799 ;; FIXME: this should actually search for a non-invisible \n.
11800 (search-backward "\n" start t))
11801 (progn
11802 (when (> (point) starteol)
11803 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11804 (let ((ol (make-overlay starteol (point) nil t nil)))
11805 (overlay-put ol 'invisible 'gnus-sum)
11806 (overlay-put ol 'evaporate t)))
11807 (gnus-summary-goto-subject article)
11808 (when (> start (point))
11809 (message "Hiding the thread moved us backwards, aborting!")
11810 (goto-char (point-max))))
11811 (goto-char start)
11812 nil))))
11813
11814 (defun gnus-summary-go-to-next-thread (&optional previous)
11815 "Go to the same level (or less) next thread.
11816 If PREVIOUS is non-nil, go to previous thread instead.
11817 Return the article number moved to, or nil if moving was impossible."
11818 (let ((level (gnus-summary-thread-level))
11819 (way (if previous -1 1))
11820 (beg (point)))
11821 (forward-line way)
11822 (while (and (not (eobp))
11823 (< level (gnus-summary-thread-level)))
11824 (forward-line way))
11825 (if (eobp)
11826 (progn
11827 (goto-char beg)
11828 nil)
11829 (setq beg (point))
11830 (prog1
11831 (gnus-summary-article-number)
11832 (goto-char beg)))))
11833
11834 (defun gnus-summary-next-thread (n &optional silent)
11835 "Go to the same level next N'th thread.
11836 If N is negative, search backward instead.
11837 Returns the difference between N and the number of skips actually
11838 done.
11839
11840 If SILENT, don't output messages."
11841 (interactive "p")
11842 (let ((backward (< n 0))
11843 (n (abs n)))
11844 (while (and (> n 0)
11845 (gnus-summary-go-to-next-thread backward))
11846 (decf n))
11847 (unless silent
11848 (gnus-summary-position-point))
11849 (when (and (not silent) (/= 0 n))
11850 (gnus-message 7 "No more threads"))
11851 n))
11852
11853 (defun gnus-summary-prev-thread (n)
11854 "Go to the same level previous N'th thread.
11855 Returns the difference between N and the number of skips actually
11856 done."
11857 (interactive "p")
11858 (gnus-summary-next-thread (- n)))
11859
11860 (defun gnus-summary-go-down-thread ()
11861 "Go down one level in the current thread."
11862 (let ((children (gnus-summary-article-children)))
11863 (when children
11864 (gnus-summary-goto-subject (car children)))))
11865
11866 (defun gnus-summary-go-up-thread ()
11867 "Go up one level in the current thread."
11868 (let ((parent (gnus-summary-article-parent)))
11869 (when parent
11870 (gnus-summary-goto-subject parent))))
11871
11872 (defun gnus-summary-down-thread (n)
11873 "Go down thread N steps.
11874 If N is negative, go up instead.
11875 Returns the difference between N and how many steps down that were
11876 taken."
11877 (interactive "p")
11878 (let ((up (< n 0))
11879 (n (abs n)))
11880 (while (and (> n 0)
11881 (if up (gnus-summary-go-up-thread)
11882 (gnus-summary-go-down-thread)))
11883 (setq n (1- n)))
11884 (gnus-summary-position-point)
11885 (when (/= 0 n)
11886 (gnus-message 7 "Can't go further"))
11887 n))
11888
11889 (defun gnus-summary-up-thread (n)
11890 "Go up thread N steps.
11891 If N is negative, go down instead.
11892 Returns the difference between N and how many steps down that were
11893 taken."
11894 (interactive "p")
11895 (gnus-summary-down-thread (- n)))
11896
11897 (defun gnus-summary-top-thread ()
11898 "Go to the top of the thread."
11899 (interactive)
11900 (while (gnus-summary-go-up-thread))
11901 (gnus-summary-article-number))
11902
11903 (defun gnus-summary-expire-thread ()
11904 "Mark articles under current thread as expired."
11905 (interactive)
11906 (gnus-summary-kill-thread 0))
11907
11908 (defun gnus-summary-kill-thread (&optional unmark)
11909 "Mark articles under current thread as read.
11910 If the prefix argument is positive, remove any kinds of marks.
11911 If the prefix argument is zero, mark thread as expired.
11912 If the prefix argument is negative, tick articles instead."
11913 (interactive "P")
11914 (when unmark
11915 (setq unmark (prefix-numeric-value unmark)))
11916 (let ((articles (gnus-summary-articles-in-thread))
11917 (hide (or (null unmark) (= unmark 0))))
11918 (save-excursion
11919 ;; Expand the thread.
11920 (gnus-summary-show-thread)
11921 ;; Mark all the articles.
11922 (while articles
11923 (gnus-summary-goto-subject (car articles))
11924 (cond ((null unmark)
11925 (gnus-summary-mark-article-as-read gnus-killed-mark))
11926 ((> unmark 0)
11927 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11928 ((= unmark 0)
11929 (gnus-summary-mark-article nil gnus-expirable-mark))
11930 (t
11931 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11932 (setq articles (cdr articles))))
11933 ;; Hide killed subtrees when hide is true.
11934 (and hide
11935 gnus-thread-hide-killed
11936 (gnus-summary-hide-thread))
11937 ;; If hide is t, go to next unread subject.
11938 (when hide
11939 ;; Go to next unread subject.
11940 (gnus-summary-next-subject 1 t)))
11941 (gnus-set-mode-line 'summary))
11942
11943 ;; Summary sorting commands
11944
11945 (defun gnus-summary-sort-by-number (&optional reverse)
11946 "Sort the summary buffer by article number.
11947 Argument REVERSE means reverse order."
11948 (interactive "P")
11949 (gnus-summary-sort 'number reverse))
11950
11951 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11952 "Sort the summary buffer by most recent article number.
11953 Argument REVERSE means reverse order."
11954 (interactive "P")
11955 (gnus-summary-sort 'most-recent-number reverse))
11956
11957 (defun gnus-summary-sort-by-random (&optional reverse)
11958 "Randomize the order in the summary buffer.
11959 Argument REVERSE means to randomize in reverse order."
11960 (interactive "P")
11961 (gnus-summary-sort 'random reverse))
11962
11963 (defun gnus-summary-sort-by-author (&optional reverse)
11964 "Sort the summary buffer by author name alphabetically.
11965 If `case-fold-search' is non-nil, case of letters is ignored.
11966 Argument REVERSE means reverse order."
11967 (interactive "P")
11968 (gnus-summary-sort 'author reverse))
11969
11970 (defun gnus-summary-sort-by-recipient (&optional reverse)
11971 "Sort the summary buffer by recipient name alphabetically.
11972 If `case-fold-search' is non-nil, case of letters is ignored.
11973 Argument REVERSE means reverse order."
11974 (interactive "P")
11975 (gnus-summary-sort 'recipient reverse))
11976
11977 (defun gnus-summary-sort-by-subject (&optional reverse)
11978 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11979 If `case-fold-search' is non-nil, case of letters is ignored.
11980 Argument REVERSE means reverse order."
11981 (interactive "P")
11982 (gnus-summary-sort 'subject reverse))
11983
11984 (defun gnus-summary-sort-by-date (&optional reverse)
11985 "Sort the summary buffer by date.
11986 Argument REVERSE means reverse order."
11987 (interactive "P")
11988 (gnus-summary-sort 'date reverse))
11989
11990 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11991 "Sort the summary buffer by most recent date.
11992 Argument REVERSE means reverse order."
11993 (interactive "P")
11994 (gnus-summary-sort 'most-recent-date reverse))
11995
11996 (defun gnus-summary-sort-by-score (&optional reverse)
11997 "Sort the summary buffer by score.
11998 Argument REVERSE means reverse order."
11999 (interactive "P")
12000 (gnus-summary-sort 'score reverse))
12001
12002 (defun gnus-summary-sort-by-lines (&optional reverse)
12003 "Sort the summary buffer by the number of lines.
12004 Argument REVERSE means reverse order."
12005 (interactive "P")
12006 (gnus-summary-sort 'lines reverse))
12007
12008 (defun gnus-summary-sort-by-chars (&optional reverse)
12009 "Sort the summary buffer by article length.
12010 Argument REVERSE means reverse order."
12011 (interactive "P")
12012 (gnus-summary-sort 'chars reverse))
12013
12014 (defun gnus-summary-sort-by-original (&optional reverse)
12015 "Sort the summary buffer using the default sorting method.
12016 Argument REVERSE means reverse order."
12017 (interactive "P")
12018 (let* ((inhibit-read-only t)
12019 (gnus-summary-prepare-hook nil))
12020 ;; We do the sorting by regenerating the threads.
12021 (gnus-summary-prepare)
12022 ;; Hide subthreads if needed.
12023 (gnus-summary-maybe-hide-threads)))
12024
12025 (defun gnus-summary-sort (predicate reverse)
12026 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12027 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12028 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12029 (gnus-thread-sort-functions
12030 (if (not reverse)
12031 thread
12032 `(lambda (t1 t2)
12033 (,thread t2 t1))))
12034 (gnus-sort-gathered-threads-function
12035 gnus-thread-sort-functions)
12036 (gnus-article-sort-functions
12037 (if (not reverse)
12038 article
12039 `(lambda (t1 t2)
12040 (,article t2 t1))))
12041 (inhibit-read-only t)
12042 (gnus-summary-prepare-hook nil))
12043 ;; We do the sorting by regenerating the threads.
12044 (gnus-summary-prepare)
12045 ;; Hide subthreads if needed.
12046 (gnus-summary-maybe-hide-threads)))
12047
12048 ;; Summary saving commands.
12049
12050 (defun gnus-summary-save-article (&optional n not-saved)
12051 "Save the current article using the default saver function.
12052 If N is a positive number, save the N next articles.
12053 If N is a negative number, save the N previous articles.
12054 If N is nil and any articles have been marked with the process mark,
12055 save those articles instead.
12056 The variable `gnus-default-article-saver' specifies the saver function.
12057
12058 If the optional second argument NOT-SAVED is non-nil, articles saved
12059 will not be marked as saved."
12060 (interactive "P")
12061 (require 'gnus-art)
12062 (let* ((articles (gnus-summary-work-articles n))
12063 (save-buffer (save-excursion
12064 (nnheader-set-temp-buffer " *Gnus Save*")))
12065 (num (length articles))
12066 ;; Whether to save decoded articles or raw articles.
12067 (decode (when gnus-article-save-coding-system
12068 (get gnus-default-article-saver :decode)))
12069 ;; When saving many articles in a single file, use the other
12070 ;; function to save articles other than the first one.
12071 (saver2 (get gnus-default-article-saver :function))
12072 (gnus-prompt-before-saving (if saver2
12073 t
12074 gnus-prompt-before-saving))
12075 (gnus-default-article-saver gnus-default-article-saver)
12076 header file)
12077 (dolist (article articles)
12078 (setq header (gnus-summary-article-header article))
12079 (if (not (vectorp header))
12080 ;; This is a pseudo-article.
12081 (if (assq 'name header)
12082 (gnus-copy-file (cdr (assq 'name header)))
12083 (gnus-message 1 "Article %d is unsavable" article))
12084 ;; This is a real article.
12085 (save-window-excursion
12086 (gnus-summary-select-article decode decode nil article)
12087 (gnus-summary-goto-subject article))
12088 (with-current-buffer save-buffer
12089 (erase-buffer)
12090 (insert-buffer-substring (if decode
12091 gnus-article-buffer
12092 gnus-original-article-buffer)))
12093 (setq file (gnus-article-save save-buffer file num))
12094 (gnus-summary-remove-process-mark article)
12095 (unless not-saved
12096 (gnus-summary-set-saved-mark article)))
12097 (when saver2
12098 (setq gnus-default-article-saver saver2
12099 saver2 nil)))
12100 (gnus-kill-buffer save-buffer)
12101 (gnus-summary-position-point)
12102 (gnus-set-mode-line 'summary)
12103 n))
12104
12105 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12106
12107 (defun gnus-summary-pipe-output (&optional n sym)
12108 "Pipe the current article to a subprocess.
12109 If N is a positive number, pipe the N next articles.
12110 If N is a negative number, pipe the N previous articles.
12111 If N is nil and any articles have been marked with the process mark,
12112 pipe those articles instead.
12113 The default command to which articles are piped is specified by the
12114 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12115 will be prompted for the command.
12116
12117 The properties `:decode' and `:headers' that are put to the function
12118 symbol `gnus-summary-save-in-pipe' control whether this function
12119 decodes articles and what headers to keep (see the doc string for the
12120 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12121 is neither omitted nor the symbol `r', force including all headers
12122 regardless of the `:headers' property. If it is the symbol `r',
12123 articles that are not decoded and include all headers will be piped
12124 no matter what the properties `:decode' and `:headers' are."
12125 (interactive (gnus-interactive "P\ny"))
12126 (require 'gnus-art)
12127 (let* ((articles (gnus-summary-work-articles n))
12128 (result-buffer "*Shell Command Output*")
12129 (all-headers (not (memq sym '(nil r))))
12130 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12131 (raw (eq sym 'r))
12132 (headers (get 'gnus-summary-save-in-pipe :headers))
12133 command result)
12134 (unless (numberp (car articles))
12135 (error "No article to pipe"))
12136 (setq command (gnus-read-shell-command
12137 (concat "Shell command on "
12138 (if (cdr articles)
12139 (format "these %d articles" (length articles))
12140 "this article")
12141 ": ")
12142 gnus-summary-pipe-output-default-command))
12143 (when (string-equal command "")
12144 (error "A command is required"))
12145 (when all-headers
12146 (put 'gnus-summary-save-in-pipe :headers nil))
12147 (unwind-protect
12148 (while articles
12149 (gnus-summary-goto-subject (pop articles))
12150 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12151 (when (and (get-buffer result-buffer)
12152 (not (zerop (buffer-size (get-buffer result-buffer)))))
12153 (setq result (concat result (with-current-buffer result-buffer
12154 (buffer-string))))))
12155 (put 'gnus-summary-save-in-pipe :headers headers))
12156 (unless (zerop (length result))
12157 (if (with-current-buffer (get-buffer-create result-buffer)
12158 (erase-buffer)
12159 (insert result)
12160 (prog1
12161 (and (= (count-lines (point-min) (point)) 1)
12162 (progn
12163 (end-of-line 0)
12164 (<= (current-column)
12165 (window-width (minibuffer-window)))))
12166 (goto-char (point-min))))
12167 (message "%s" (substring result 0 -1))
12168 (message nil)
12169 (gnus-configure-windows 'pipe)))))
12170
12171 (defun gnus-summary-save-article-mail (&optional arg)
12172 "Append the current article to a Unix mail box file.
12173 If N is a positive number, save the N next articles.
12174 If N is a negative number, save the N previous articles.
12175 If N is nil and any articles have been marked with the process mark,
12176 save those articles instead."
12177 (interactive "P")
12178 (require 'gnus-art)
12179 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12180 (gnus-summary-save-article arg)))
12181
12182 (defun gnus-summary-save-article-rmail (&optional arg)
12183 "Append the current article to an rmail file.
12184 If N is a positive number, save the N next articles.
12185 If N is a negative number, save the N previous articles.
12186 If N is nil and any articles have been marked with the process mark,
12187 save those articles instead."
12188 (interactive "P")
12189 (require 'gnus-art)
12190 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12191 (gnus-summary-save-article arg)))
12192
12193 (defun gnus-summary-save-article-file (&optional arg)
12194 "Append the current article to a file.
12195 If N is a positive number, save the N next articles.
12196 If N is a negative number, save the N previous articles.
12197 If N is nil and any articles have been marked with the process mark,
12198 save those articles instead."
12199 (interactive "P")
12200 (require 'gnus-art)
12201 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12202 (gnus-summary-save-article arg)))
12203
12204 (defun gnus-summary-write-article-file (&optional arg)
12205 "Write the current article to a file, deleting the previous file.
12206 If N is a positive number, save the N next articles.
12207 If N is a negative number, save the N previous articles.
12208 If N is nil and any articles have been marked with the process mark,
12209 save those articles instead."
12210 (interactive "P")
12211 (require 'gnus-art)
12212 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12213 (gnus-summary-save-article arg)))
12214
12215 (defun gnus-summary-save-article-body-file (&optional arg)
12216 "Append the current article body to a file.
12217 If N is a positive number, save the N next articles.
12218 If N is a negative number, save the N previous articles.
12219 If N is nil and any articles have been marked with the process mark,
12220 save those articles instead."
12221 (interactive "P")
12222 (require 'gnus-art)
12223 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12224 (gnus-summary-save-article arg)))
12225
12226 (defun gnus-summary-write-article-body-file (&optional arg)
12227 "Write the current article body to a file, deleting the previous file.
12228 If N is a positive number, save the N next articles.
12229 If N is a negative number, save the N previous articles.
12230 If N is nil and any articles have been marked with the process mark,
12231 save those articles instead."
12232 (interactive "P")
12233 (require 'gnus-art)
12234 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12235 (gnus-summary-save-article arg)))
12236
12237 (defun gnus-summary-muttprint (&optional arg)
12238 "Print the current article using Muttprint.
12239 If N is a positive number, save the N next articles.
12240 If N is a negative number, save the N previous articles.
12241 If N is nil and any articles have been marked with the process mark,
12242 save those articles instead."
12243 (interactive "P")
12244 (require 'gnus-art)
12245 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12246 (gnus-summary-save-article arg t)))
12247
12248 (defun gnus-summary-pipe-message (program)
12249 "Pipe the current article through PROGRAM."
12250 (interactive "sProgram: ")
12251 (gnus-summary-select-article)
12252 (let ((mail-header-separator ""))
12253 (gnus-eval-in-buffer-window gnus-article-buffer
12254 (save-restriction
12255 (widen)
12256 (let ((start (window-start))
12257 (inhibit-read-only t))
12258 (message-pipe-buffer-body program)
12259 (set-window-start (get-buffer-window (current-buffer)) start))))))
12260
12261 (defun gnus-get-split-value (methods)
12262 "Return a value based on the split METHODS."
12263 (let (split-name method result match)
12264 (when methods
12265 (with-current-buffer gnus-original-article-buffer
12266 (save-restriction
12267 (nnheader-narrow-to-headers)
12268 (while (and methods (not split-name))
12269 (goto-char (point-min))
12270 (setq method (pop methods))
12271 (setq match (car method))
12272 (when (cond
12273 ((stringp match)
12274 ;; Regular expression.
12275 (ignore-errors
12276 (re-search-forward match nil t)))
12277 ((functionp match)
12278 ;; Function.
12279 (save-restriction
12280 (widen)
12281 (setq result (funcall match gnus-newsgroup-name))))
12282 ((consp match)
12283 ;; Form.
12284 (save-restriction
12285 (widen)
12286 (setq result (eval match)))))
12287 (setq split-name (cdr method))
12288 (cond ((stringp result)
12289 (push (expand-file-name
12290 result gnus-article-save-directory)
12291 split-name))
12292 ((consp result)
12293 (setq split-name (append result split-name)))))))))
12294 (nreverse split-name)))
12295
12296 (defun gnus-valid-move-group-p (group)
12297 (and (symbolp group)
12298 (boundp group)
12299 (symbol-name group)
12300 (symbol-value group)
12301 (gnus-get-function (gnus-find-method-for-group
12302 (symbol-name group)) 'request-accept-article t)))
12303
12304 (defun gnus-read-move-group-name (prompt default articles prefix)
12305 "Read a group name."
12306 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12307 (minibuffer-confirm-incomplete nil) ; XEmacs
12308 (prom
12309 (format "%s %s to"
12310 prompt
12311 (if (> (length articles) 1)
12312 (format "these %d articles" (length articles))
12313 "this article")))
12314 (to-newsgroup
12315 (cond
12316 ((null split-name)
12317 (gnus-group-completing-read
12318 prom
12319 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12320 nil prefix nil default))
12321 ((= 1 (length split-name))
12322 (gnus-group-completing-read
12323 prom
12324 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12325 nil prefix 'gnus-group-history (car split-name)))
12326 (t
12327 (gnus-completing-read
12328 prom (nreverse split-name) nil nil 'gnus-group-history))))
12329 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12330 encoded)
12331 (when to-newsgroup
12332 (if (or (string= to-newsgroup "")
12333 (string= to-newsgroup prefix))
12334 (setq to-newsgroup default))
12335 (unless to-newsgroup
12336 (error "No group name entered"))
12337 (setq encoded (mm-encode-coding-string
12338 to-newsgroup
12339 (gnus-group-name-charset to-method to-newsgroup)))
12340 (or (gnus-active encoded)
12341 (gnus-activate-group encoded nil nil to-method)
12342 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12343 to-newsgroup))
12344 (or (and (gnus-request-create-group encoded to-method)
12345 (gnus-activate-group encoded nil nil to-method)
12346 (gnus-subscribe-group encoded))
12347 (error "Couldn't create group %s" to-newsgroup)))
12348 (error "No such group: %s" to-newsgroup))
12349 encoded)))
12350
12351 (defvar gnus-summary-save-parts-counter)
12352 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12353
12354 (defun gnus-summary-save-parts (type dir n &optional reverse)
12355 "Save parts matching TYPE to DIR.
12356 If REVERSE, save parts that do not match TYPE."
12357 (interactive
12358 (list (read-string "Save parts of type: "
12359 (or (car gnus-summary-save-parts-type-history)
12360 gnus-summary-save-parts-default-mime)
12361 'gnus-summary-save-parts-type-history)
12362 (setq gnus-summary-save-parts-last-directory
12363 (read-directory-name "Save to directory: "
12364 gnus-summary-save-parts-last-directory
12365 nil t))
12366 current-prefix-arg))
12367 (gnus-summary-iterate n
12368 (let ((gnus-display-mime-function nil)
12369 gnus-article-prepare-hook
12370 gnus-article-decode-hook
12371 gnus-display-mime-function
12372 gnus-break-pages
12373 (gnus-inhibit-treatment t))
12374 (gnus-summary-select-article))
12375 (with-current-buffer gnus-article-buffer
12376 (let ((handles (or gnus-article-mime-handles
12377 (mm-dissect-buffer nil gnus-article-loose-mime)
12378 (and gnus-article-emulate-mime
12379 (mm-uu-dissect))))
12380 (gnus-summary-save-parts-counter 1))
12381 (when handles
12382 (gnus-summary-save-parts-1 type dir handles reverse)
12383 (unless gnus-article-mime-handles ;; Don't destroy this case.
12384 (mm-destroy-parts handles)))))))
12385
12386 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12387 (if (stringp (car handle))
12388 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12389 (cdr handle))
12390 (when (if reverse
12391 (not (string-match type (mm-handle-media-type handle)))
12392 (string-match type (mm-handle-media-type handle)))
12393 (let ((file (expand-file-name
12394 (gnus-map-function
12395 mm-file-name-rewrite-functions
12396 (file-name-nondirectory
12397 (or
12398 (mm-handle-filename handle)
12399 (format "%s.%d.%d" gnus-newsgroup-name
12400 (cdr gnus-article-current)
12401 gnus-summary-save-parts-counter))))
12402 dir)))
12403 (incf gnus-summary-save-parts-counter)
12404 (unless (file-exists-p file)
12405 (mm-save-part-to-file handle file))))))
12406
12407 ;; Summary extract commands
12408
12409 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12410 (let ((inhibit-read-only t)
12411 (article (gnus-summary-article-number))
12412 after-article b e)
12413 (unless (gnus-summary-goto-subject article)
12414 (error "No such article: %d" article))
12415 (gnus-summary-position-point)
12416 ;; If all commands are to be bunched up on one line, we collect
12417 ;; them here.
12418 (unless gnus-view-pseudos-separately
12419 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12420 files action)
12421 (while ps
12422 (setq action (cdr (assq 'action (car ps))))
12423 (setq files (list (cdr (assq 'name (car ps)))))
12424 (while (and ps (cdr ps)
12425 (string= (or action "1")
12426 (or (cdr (assq 'action (cadr ps))) "2")))
12427 (push (cdr (assq 'name (cadr ps))) files)
12428 (setcdr ps (cddr ps)))
12429 (when files
12430 (when (not (string-match "%s" action))
12431 (push " " files))
12432 (push " " files)
12433 (when (assq 'execute (car ps))
12434 (setcdr (assq 'execute (car ps))
12435 (funcall (if (string-match "%s" action)
12436 'format 'concat)
12437 action
12438 (mapconcat
12439 (lambda (f)
12440 (if (equal f " ")
12441 f
12442 (shell-quote-argument f)))
12443 files " ")))))
12444 (setq ps (cdr ps)))))
12445 (if (and gnus-view-pseudos (not not-view))
12446 (while pslist
12447 (when (assq 'execute (car pslist))
12448 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12449 (eq gnus-view-pseudos 'not-confirm)))
12450 (setq pslist (cdr pslist)))
12451 (save-excursion
12452 (while pslist
12453 (setq after-article (or (cdr (assq 'article (car pslist)))
12454 (gnus-summary-article-number)))
12455 (gnus-summary-goto-subject after-article)
12456 (forward-line 1)
12457 (setq b (point))
12458 (insert " " (file-name-nondirectory
12459 (cdr (assq 'name (car pslist))))
12460 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12461 (setq e (point))
12462 (forward-line -1) ; back to `b'
12463 (gnus-add-text-properties
12464 b (1- e) (list 'gnus-number gnus-reffed-article-number
12465 'mouse-face gnus-mouse-face))
12466 (gnus-data-enter
12467 after-article gnus-reffed-article-number
12468 gnus-unread-mark b (car pslist) 0 (- e b))
12469 (setq gnus-newsgroup-unreads
12470 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12471 gnus-reffed-article-number))
12472 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12473 (setq pslist (cdr pslist)))))))
12474
12475 (defun gnus-pseudos< (p1 p2)
12476 (let ((c1 (cdr (assq 'action p1)))
12477 (c2 (cdr (assq 'action p2))))
12478 (and c1 c2 (string< c1 c2))))
12479
12480 (defun gnus-request-pseudo-article (props)
12481 (cond ((assq 'execute props)
12482 (gnus-execute-command (cdr (assq 'execute props)))))
12483 (let ((gnus-current-article (gnus-summary-article-number)))
12484 (gnus-run-hooks 'gnus-mark-article-hook)))
12485
12486 (defun gnus-execute-command (command &optional automatic)
12487 (save-excursion
12488 (gnus-article-setup-buffer)
12489 (set-buffer gnus-article-buffer)
12490 (setq buffer-read-only nil)
12491 (let ((command (if automatic command
12492 (read-string "Command: " (cons command 0)))))
12493 (erase-buffer)
12494 (insert "$ " command "\n\n")
12495 (if gnus-view-pseudo-asynchronously
12496 (start-process "gnus-execute" (current-buffer) shell-file-name
12497 shell-command-switch command)
12498 (call-process shell-file-name nil t nil
12499 shell-command-switch command)))))
12500
12501 ;; Summary kill commands.
12502
12503 (defun gnus-summary-edit-global-kill (article)
12504 "Edit the \"global\" kill file."
12505 (interactive (list (gnus-summary-article-number)))
12506 (gnus-group-edit-global-kill article))
12507
12508 (defun gnus-summary-edit-local-kill ()
12509 "Edit a local kill file applied to the current newsgroup."
12510 (interactive)
12511 (setq gnus-current-headers (gnus-summary-article-header))
12512 (gnus-group-edit-local-kill
12513 (gnus-summary-article-number) gnus-newsgroup-name))
12514
12515 ;;; Header reading.
12516
12517 (defun gnus-read-header (id &optional header)
12518 "Read the headers of article ID and enter them into the Gnus system."
12519 (let ((group gnus-newsgroup-name)
12520 (gnus-override-method
12521 (or
12522 gnus-override-method
12523 (and (gnus-news-group-p gnus-newsgroup-name)
12524 (car (gnus-refer-article-methods)))))
12525 where)
12526 ;; First we check to see whether the header in question is already
12527 ;; fetched.
12528 (if (stringp id)
12529 ;; This is a Message-ID.
12530 (setq header (or header (gnus-id-to-header id)))
12531 ;; This is an article number.
12532 (setq header (or header (gnus-summary-article-header id))))
12533 (if (and header
12534 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12535 ;; We have found the header.
12536 header
12537 ;; We have to really fetch the header to this article.
12538 (with-current-buffer nntp-server-buffer
12539 (when (setq where (gnus-request-head id group))
12540 (nnheader-fold-continuation-lines)
12541 (goto-char (point-max))
12542 (insert ".\n")
12543 (goto-char (point-min))
12544 (insert "211 ")
12545 (princ (cond
12546 ((numberp id) id)
12547 ((cdr where) (cdr where))
12548 (header (mail-header-number header))
12549 (t gnus-reffed-article-number))
12550 (current-buffer))
12551 (insert " Article retrieved.\n"))
12552 (if (or (not where)
12553 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12554 () ; Malformed head.
12555 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12556 (when (and (bound-and-true-p gnus-registry-enabled)
12557 (not (gnus-ephemeral-group-p (car where))))
12558 (gnus-registry-handle-action
12559 (mail-header-id header) nil
12560 (gnus-group-prefixed-name
12561 (car where)
12562 (or gnus-override-method (gnus-find-method-for-group group)))
12563 (mail-header-subject header)
12564 (mail-header-from header)))
12565 (when (and (stringp id)
12566 (or
12567 (not (string= (gnus-group-real-name group)
12568 (car where)))
12569 (not (gnus-server-equal gnus-override-method
12570 (gnus-group-method group)))))
12571 ;; If we fetched by Message-ID and the article came from
12572 ;; a different group (or server), we fudge some bogus
12573 ;; article numbers for this article.
12574 (mail-header-set-number header gnus-reffed-article-number))
12575 (with-current-buffer gnus-summary-buffer
12576 (decf gnus-reffed-article-number)
12577 (gnus-remove-header (mail-header-number header))
12578 (push header gnus-newsgroup-headers)
12579 (setq gnus-current-headers header)
12580 (push (mail-header-number header) gnus-newsgroup-limit)))
12581 header)))))
12582
12583 (defun gnus-remove-header (number)
12584 "Remove header NUMBER from `gnus-newsgroup-headers'."
12585 (if (and gnus-newsgroup-headers
12586 (= number (mail-header-number (car gnus-newsgroup-headers))))
12587 (pop gnus-newsgroup-headers)
12588 (let ((headers gnus-newsgroup-headers))
12589 (while (and (cdr headers)
12590 (not (= number (mail-header-number (cadr headers)))))
12591 (pop headers))
12592 (when (cdr headers)
12593 (setcdr headers (cddr headers))))))
12594
12595 ;;;
12596 ;;; summary highlights
12597 ;;;
12598
12599 (defun gnus-highlight-selected-summary ()
12600 "Highlight selected article in summary buffer."
12601 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12602 (when gnus-summary-selected-face
12603 (save-excursion
12604 (let* ((beg (point-at-bol))
12605 (end (point-at-eol))
12606 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12607 (from (if (get-text-property beg 'mouse-face)
12608 beg
12609 (or (next-single-property-change
12610 beg 'mouse-face nil end)
12611 beg)))
12612 (to
12613 (if (= from end)
12614 (- from 2)
12615 (or (next-single-property-change
12616 from 'mouse-face nil end)
12617 end))))
12618 ;; If no mouse-face prop on line we will have to = from = end,
12619 ;; so we highlight the entire line instead.
12620 (when (= (+ to 2) from)
12621 (setq from beg)
12622 (setq to end))
12623 (if gnus-newsgroup-selected-overlay
12624 ;; Move old overlay.
12625 (move-overlay
12626 gnus-newsgroup-selected-overlay from to (current-buffer))
12627 ;; Create new overlay.
12628 (overlay-put
12629 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12630 'face gnus-summary-selected-face))))))
12631
12632 (defvar gnus-summary-highlight-line-cached nil)
12633 (defvar gnus-summary-highlight-line-trigger nil)
12634
12635 (defun gnus-summary-highlight-line-0 ()
12636 (if (and (eq gnus-summary-highlight-line-trigger
12637 gnus-summary-highlight)
12638 gnus-summary-highlight-line-cached)
12639 gnus-summary-highlight-line-cached
12640 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12641 gnus-summary-highlight-line-cached
12642 (let* ((cond (list 'cond))
12643 (c cond)
12644 (list gnus-summary-highlight))
12645 (while list
12646 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12647 nil))
12648 (setq c (cdr c)
12649 list (cdr list)))
12650 (gnus-byte-compile (list 'lambda nil cond))))))
12651
12652 (defun gnus-summary-highlight-line ()
12653 "Highlight current line according to `gnus-summary-highlight'."
12654 (let* ((beg (point-at-bol))
12655 (article (or (gnus-summary-article-number) gnus-current-article))
12656 (score (or (cdr (assq article
12657 gnus-newsgroup-scored))
12658 gnus-summary-default-score 0))
12659 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12660 (inhibit-read-only t)
12661 (default gnus-summary-default-score)
12662 (default-high gnus-summary-default-high-score)
12663 (default-low gnus-summary-default-low-score)
12664 (uncached (and gnus-summary-use-undownloaded-faces
12665 (memq article gnus-newsgroup-undownloaded)
12666 (not (memq article gnus-newsgroup-cached)))))
12667 (let ((face (funcall (gnus-summary-highlight-line-0))))
12668 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12669 (gnus-put-text-property-excluding-characters-with-faces
12670 beg (point-at-eol) 'face
12671 (setq face (if (boundp face) (symbol-value face) face)))
12672 (when gnus-summary-highlight-line-function
12673 (funcall gnus-summary-highlight-line-function article face))))))
12674
12675 (defun gnus-update-read-articles (group unread &optional compute)
12676 "Update the list of read articles in GROUP.
12677 UNREAD is a sorted list."
12678 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12679 (info (gnus-get-info group))
12680 (prev 1)
12681 read)
12682 (if (or (not info) (not active))
12683 ;; There is no info on this group if it was, in fact,
12684 ;; killed. Gnus stores no information on killed groups, so
12685 ;; there's nothing to be done.
12686 ;; One could store the information somewhere temporarily,
12687 ;; perhaps... Hmmm...
12688 ()
12689 ;; Remove any negative articles numbers.
12690 (while (and unread (< (car unread) 0))
12691 (setq unread (cdr unread)))
12692 ;; Remove any expired article numbers
12693 (while (and unread (< (car unread) (car active)))
12694 (setq unread (cdr unread)))
12695 ;; Compute the ranges of read articles by looking at the list of
12696 ;; unread articles.
12697 (while unread
12698 (when (/= (car unread) prev)
12699 (push (if (= prev (1- (car unread))) prev
12700 (cons prev (1- (car unread))))
12701 read))
12702 (setq prev (1+ (car unread)))
12703 (setq unread (cdr unread)))
12704 (when (<= prev (cdr active))
12705 (push (cons prev (cdr active)) read))
12706 (setq read (if (> (length read) 1) (nreverse read) read))
12707 (if compute
12708 read
12709 (save-excursion
12710 (let (setmarkundo)
12711 ;; Propagate the read marks to the backend.
12712 (when (and (gnus-method-option-p
12713 (gnus-find-method-for-group group)
12714 'server-marks)
12715 (gnus-check-backend-function 'request-set-mark group))
12716 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12717 (add (gnus-remove-from-range read (gnus-info-read info))))
12718 (when (or add del)
12719 (unless (gnus-check-group group)
12720 (error "Can't open server for %s" group))
12721 (gnus-request-set-mark
12722 group (delq nil (list (if add (list add 'add '(read)))
12723 (if del (list del 'del '(read))))))
12724 (setq setmarkundo
12725 `(gnus-request-set-mark
12726 ,group
12727 ',(delq nil (list
12728 (if del (list del 'add '(read)))
12729 (if add (list add 'del '(read))))))))))
12730 (set-buffer gnus-group-buffer)
12731 (gnus-undo-register
12732 `(progn
12733 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12734 (gnus-info-set-read ',info ',(gnus-info-read info))
12735 (gnus-get-unread-articles-in-group ',info
12736 (gnus-active ,group))
12737 (gnus-group-update-group ,group t)
12738 ,setmarkundo))))
12739 ;; Enter this list into the group info.
12740 (gnus-info-set-read info read)
12741 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12742 (gnus-get-unread-articles-in-group info (gnus-active group))
12743 t))))
12744
12745 (defun gnus-offer-save-summaries ()
12746 "Offer to save all active summary buffers."
12747 (let (buffers)
12748 ;; Go through all buffers and find all summaries.
12749 (dolist (buffer (buffer-list))
12750 (when (and (setq buffer (buffer-name buffer))
12751 (string-match "Summary" buffer)
12752 (with-current-buffer buffer
12753 ;; We check that this is, indeed, a summary buffer.
12754 (and (derived-mode-p 'gnus-summary-mode)
12755 ;; Also make sure this isn't bogus.
12756 gnus-newsgroup-prepared
12757 ;; Also make sure that this isn't a
12758 ;; dead summary buffer.
12759 (not gnus-dead-summary-mode))))
12760 (push buffer buffers)))
12761 ;; Go through all these summary buffers and offer to save them.
12762 (when buffers
12763 (save-excursion
12764 (if (eq gnus-interactive-exit 'quiet)
12765 (dolist (buffer buffers)
12766 (switch-to-buffer buffer)
12767 (gnus-summary-exit))
12768 (map-y-or-n-p
12769 "Update summary buffer %s? "
12770 (lambda (buf)
12771 (switch-to-buffer buf)
12772 (gnus-summary-exit))
12773 buffers))))))
12774
12775 (defun gnus-summary-setup-default-charset ()
12776 "Setup newsgroup default charset."
12777 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12778 (setq gnus-newsgroup-charset nil)
12779 (let* ((ignored-charsets
12780 (or gnus-newsgroup-ephemeral-ignored-charsets
12781 (append
12782 (and gnus-newsgroup-name
12783 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12784 gnus-newsgroup-ignored-charsets))))
12785 (setq gnus-newsgroup-charset
12786 (or gnus-newsgroup-ephemeral-charset
12787 (and gnus-newsgroup-name
12788 (gnus-parameter-charset gnus-newsgroup-name))
12789 gnus-default-charset))
12790 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12791 ignored-charsets))))
12792
12793 ;;;
12794 ;;; Mime Commands
12795 ;;;
12796
12797 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12798 "Display the current article buffer fully MIME-buttonized.
12799 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12800 treated as multipart/mixed."
12801 (interactive "P")
12802 (require 'gnus-art)
12803 (let ((gnus-unbuttonized-mime-types nil)
12804 (gnus-mime-display-multipart-as-mixed show-all-parts))
12805 (gnus-summary-show-article)))
12806
12807 (defun gnus-summary-repair-multipart (article)
12808 "Add a Content-Type header to a multipart article without one."
12809 (interactive (list (gnus-summary-article-number)))
12810 (gnus-with-article article
12811 (message-narrow-to-head)
12812 (message-remove-header "Mime-Version")
12813 (goto-char (point-max))
12814 (insert "Mime-Version: 1.0\n")
12815 (widen)
12816 (when (search-forward "\n--" nil t)
12817 (let ((separator (buffer-substring (point) (point-at-eol))))
12818 (message-narrow-to-head)
12819 (message-remove-header "Content-Type")
12820 (goto-char (point-max))
12821 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12822 separator))
12823 (widen))))
12824 (let (gnus-mark-article-hook)
12825 (gnus-summary-select-article t t nil article)))
12826
12827 (defun gnus-summary-toggle-display-buttonized ()
12828 "Toggle the buttonizing of the article buffer."
12829 (interactive)
12830 (require 'gnus-art)
12831 (if (setq gnus-inhibit-mime-unbuttonizing
12832 (not gnus-inhibit-mime-unbuttonizing))
12833 (let ((gnus-unbuttonized-mime-types nil))
12834 (gnus-summary-show-article))
12835 (gnus-summary-show-article)))
12836
12837 ;;;
12838 ;;; Generic summary marking commands
12839 ;;;
12840
12841 (defvar gnus-summary-marking-alist
12842 '((read gnus-del-mark "d")
12843 (unread gnus-unread-mark "u")
12844 (ticked gnus-ticked-mark "!")
12845 (dormant gnus-dormant-mark "?")
12846 (expirable gnus-expirable-mark "e"))
12847 "An alist of names/marks/keystrokes.")
12848
12849 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12850 (defvar gnus-summary-mark-map)
12851
12852 (defun gnus-summary-make-all-marking-commands ()
12853 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12854 (dolist (elem gnus-summary-marking-alist)
12855 (apply 'gnus-summary-make-marking-command elem)))
12856
12857 (defun gnus-summary-make-marking-command (name mark keystroke)
12858 (let ((map (make-sparse-keymap)))
12859 (define-key gnus-summary-generic-mark-map keystroke map)
12860 (dolist (lway `((next "next" next nil "n")
12861 (next-unread "next unread" next t "N")
12862 (prev "previous" prev nil "p")
12863 (prev-unread "previous unread" prev t "P")
12864 (nomove "" nil nil ,keystroke)))
12865 (let ((func (gnus-summary-make-marking-command-1
12866 mark (car lway) lway name)))
12867 (setq func (eval func))
12868 (define-key map (nth 4 lway) func)))))
12869
12870 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12871 `(defun ,(intern
12872 (format "gnus-summary-put-mark-as-%s%s"
12873 name (if (eq way 'nomove)
12874 ""
12875 (concat "-" (symbol-name way)))))
12876 (n)
12877 ,(format
12878 "Mark the current article as %s%s.
12879 If N, the prefix, then repeat N times.
12880 If N is negative, move in reverse order.
12881 The difference between N and the actual number of articles marked is
12882 returned."
12883 name (cadr lway))
12884 (interactive "p")
12885 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12886
12887 (defun gnus-summary-generic-mark (n mark move unread)
12888 "Mark N articles with MARK."
12889 (unless (derived-mode-p 'gnus-summary-mode)
12890 (error "This command can only be used in the summary buffer"))
12891 (gnus-summary-show-thread)
12892 (let ((nummove
12893 (cond
12894 ((eq move 'next) 1)
12895 ((eq move 'prev) -1)
12896 (t 0))))
12897 (if (zerop nummove)
12898 (setq n 1)
12899 (when (< n 0)
12900 (setq n (abs n)
12901 nummove (* -1 nummove))))
12902 (while (and (> n 0)
12903 (gnus-summary-mark-article nil mark)
12904 (zerop (gnus-summary-next-subject nummove unread t)))
12905 (setq n (1- n)))
12906 (when (/= 0 n)
12907 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12908 (gnus-summary-recenter)
12909 (gnus-summary-position-point)
12910 (gnus-set-mode-line 'summary)
12911 n))
12912
12913 (defun gnus-summary-insert-articles (articles)
12914 (when (setq articles
12915 (gnus-sorted-difference articles
12916 (mapcar (lambda (h)
12917 (mail-header-number h))
12918 gnus-newsgroup-headers)))
12919 (setq gnus-newsgroup-headers
12920 (gnus-merge 'list
12921 gnus-newsgroup-headers
12922 (gnus-fetch-headers articles nil t)
12923 'gnus-article-sort-by-number))
12924 (setq gnus-newsgroup-articles
12925 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12926 ;; Suppress duplicates?
12927 (when gnus-suppress-duplicates
12928 (gnus-dup-suppress-articles))
12929
12930 (if (and gnus-fetch-old-headers
12931 (eq gnus-headers-retrieved-by 'nov))
12932 ;; We might want to build some more threads first.
12933 (if (eq gnus-fetch-old-headers 'invisible)
12934 (gnus-build-all-threads)
12935 (gnus-build-old-threads))
12936 ;; Mark the inserted articles that are unread as unread.
12937 (setq gnus-newsgroup-unreads
12938 (gnus-sorted-nunion
12939 gnus-newsgroup-unreads
12940 (gnus-sorted-nintersection
12941 (gnus-list-of-unread-articles gnus-newsgroup-name)
12942 articles)))
12943 ;; Mark the inserted articles as selected so that the information
12944 ;; of the marks having been changed by a user may be updated when
12945 ;; exiting this group. See `gnus-summary-update-info'.
12946 (dolist (art articles)
12947 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12948 ;; Let the Gnus agent mark articles as read.
12949 (when gnus-agent
12950 (gnus-agent-get-undownloaded-list))
12951 ;; Remove list identifiers from subject
12952 (gnus-summary-remove-list-identifiers)
12953 ;; First and last article in this newsgroup.
12954 (when gnus-newsgroup-headers
12955 (setq gnus-newsgroup-begin
12956 (mail-header-number (car gnus-newsgroup-headers))
12957 gnus-newsgroup-end
12958 (mail-header-number
12959 (gnus-last-element gnus-newsgroup-headers))))
12960 (when gnus-use-scoring
12961 (gnus-possibly-score-headers))))
12962
12963 (defun gnus-summary-insert-old-articles (&optional all)
12964 "Insert all old articles in this group.
12965 If ALL is non-nil, already read articles become readable.
12966 If ALL is a number, fetch this number of articles."
12967 (interactive "P")
12968 (prog1
12969 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12970 older len)
12971 (setq older
12972 ;; Some nntp servers lie about their active range. When
12973 ;; this happens, the active range can be in the millions.
12974 ;; Use a compressed range to avoid creating a huge list.
12975 (gnus-range-difference
12976 (gnus-range-difference (list gnus-newsgroup-active) old)
12977 gnus-newsgroup-unexist))
12978 (setq len (gnus-range-length older))
12979 (cond
12980 ((null older) nil)
12981 ((numberp all)
12982 (if (< all len)
12983 (let ((older-range (nreverse older)))
12984 (setq older nil)
12985
12986 (while (> all 0)
12987 (let* ((r (pop older-range))
12988 (min (if (numberp r) r (car r)))
12989 (max (if (numberp r) r (cdr r))))
12990 (while (and (<= min max)
12991 (> all 0))
12992 (push max older)
12993 (setq all (1- all)
12994 max (1- max))))))
12995 (setq older (gnus-uncompress-range older))))
12996 (all
12997 (setq older (gnus-uncompress-range older)))
12998 (t
12999 (when (and (numberp gnus-large-newsgroup)
13000 (> len gnus-large-newsgroup))
13001 (let* ((cursor-in-echo-area nil)
13002 (initial (gnus-parameter-large-newsgroup-initial
13003 gnus-newsgroup-name))
13004 (input
13005 (read-string
13006 (format
13007 "How many articles from %s (%s %d): "
13008 (gnus-group-decoded-name gnus-newsgroup-name)
13009 (if initial "max" "default")
13010 len)
13011 nil nil
13012 (and initial
13013 (number-to-string initial)))))
13014 (unless (string-match "^[ \t]*$" input)
13015 (setq all (string-to-number input))
13016 (if (< all len)
13017 (let ((older-range (nreverse older)))
13018 (setq older nil)
13019
13020 (while (> all 0)
13021 (let* ((r (pop older-range))
13022 (min (if (numberp r) r (car r)))
13023 (max (if (numberp r) r (cdr r))))
13024 (while (and (<= min max)
13025 (> all 0))
13026 (push max older)
13027 (setq all (1- all)
13028 max (1- max))))))))))
13029 (setq older (gnus-uncompress-range older))))
13030 (if (not older)
13031 (message "No old news.")
13032 (gnus-summary-insert-articles older)
13033 (gnus-summary-limit (gnus-sorted-nunion old older))))
13034 (gnus-summary-position-point)))
13035
13036 (defun gnus-summary-insert-new-articles ()
13037 "Insert all new articles in this group."
13038 (interactive)
13039 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13040 (old-high gnus-newsgroup-highest)
13041 (nnmail-fetched-sources (list t))
13042 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13043 i new)
13044 (unless new-active
13045 (error "Couldn't fetch new data"))
13046 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
13047 (setq i (cdr gnus-newsgroup-active)
13048 gnus-newsgroup-highest i)
13049 (while (> i old-high)
13050 (push i new)
13051 (decf i))
13052 (if (not new)
13053 (message "No gnus is bad news")
13054 (gnus-summary-insert-articles new)
13055 (setq gnus-newsgroup-unreads
13056 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13057 (gnus-summary-limit (gnus-sorted-nunion old new))))
13058 (gnus-summary-position-point))
13059
13060 ;;; Bookmark support for Gnus.
13061 (declare-function gnus-article-show-summary "gnus-art" ())
13062 (declare-function bookmark-make-record-default
13063 "bookmark" (&optional no-file no-context posn))
13064 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13065 (declare-function bookmark-default-handler "bookmark" (bmk))
13066 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13067 (defvar bookmark-yank-point)
13068 (defvar bookmark-current-buffer)
13069
13070 (defun gnus-summary-bookmark-make-record ()
13071 "Make a bookmark entry for a Gnus summary buffer."
13072 (let (pos buf)
13073 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13074 (save-restriction ; FIXME is it necessary to widen?
13075 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13076 (setq buf "art") ; We are recording bookmark from article buffer.
13077 (setq bookmark-yank-point (point))
13078 (setq bookmark-current-buffer (current-buffer))
13079 (gnus-article-show-summary)) ; Go back in summary buffer.
13080 ;; We are now recording bookmark from summary buffer.
13081 (unless buf (setq buf "sum"))
13082 (let* ((subject (elt (gnus-summary-article-header) 1))
13083 (grp (car gnus-article-current))
13084 (art (cdr gnus-article-current))
13085 (head (gnus-summary-article-header art))
13086 (id (mail-header-id head)))
13087 `(,subject
13088 ,@(condition-case nil
13089 (bookmark-make-record-default 'no-file 'no-context pos)
13090 (wrong-number-of-arguments
13091 (bookmark-make-record-default 'point-only)))
13092 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13093 (group . ,grp) (article . ,art)
13094 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13095
13096 ;;;###autoload
13097 (defun gnus-summary-bookmark-jump (bookmark)
13098 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13099 BOOKMARK is a bookmark name or a bookmark record."
13100 (let ((group (bookmark-prop-get bookmark 'group))
13101 (article (bookmark-prop-get bookmark 'article))
13102 (id (bookmark-prop-get bookmark 'message-id))
13103 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13104 (gnus-fetch-group group (list article))
13105 (gnus-summary-insert-cached-articles)
13106 (gnus-summary-goto-article id nil 'force)
13107 ;; FIXME we have to wait article buffer is ready (only large buffer)
13108 ;; Is there a better solution to know that?
13109 ;; If we don't wait `bookmark-default-handler' will have no chance
13110 ;; to set position. However there is no error, just wrong pos.
13111 (sit-for 1)
13112 (when (string= buf "Gnus-art")
13113 (other-window 1))
13114 (bookmark-default-handler
13115 `(""
13116 (buffer . ,(current-buffer))
13117 . ,(bookmark-get-bookmark-record bookmark)))))
13118
13119 (gnus-summary-make-all-marking-commands)
13120
13121 (provide 'gnus-sum)
13122
13123 (run-hooks 'gnus-sum-load-hook)
13124
13125 ;; Local Variables:
13126 ;; coding: utf-8
13127 ;; End:
13128
13129 ;;; gnus-sum.el ends here