]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Doc fixes for fclist and grep
[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 or a list of regexps."
1175 :version "21.1"
1176 :group 'gnus-summary
1177 :type '(choice regexp
1178 (repeat :tag "Regexp List" regexp)))
1179
1180 (defsubst gnus-ignored-from-addresses ()
1181 (gmm-regexp-concat gnus-ignored-from-addresses))
1182
1183 (defcustom gnus-summary-to-prefix "-> "
1184 "*String prefixed to the To field in the summary line when
1185 using `gnus-ignored-from-addresses'."
1186 :version "22.1"
1187 :group 'gnus-summary
1188 :type 'string)
1189
1190 (defcustom gnus-summary-newsgroup-prefix "=> "
1191 "*String prefixed to the Newsgroup field in the summary
1192 line when using the option `gnus-ignored-from-addresses'."
1193 :version "22.1"
1194 :group 'gnus-summary
1195 :type 'string)
1196
1197 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1198 "List of charsets that should be ignored.
1199 When these charsets are used in the \"charset\" parameter, the
1200 default charset will be used instead."
1201 :version "21.1"
1202 :type '(repeat symbol)
1203 :group 'gnus-charset)
1204
1205 (defcustom gnus-newsgroup-maximum-articles nil
1206 "The maximum number of articles a newsgroup.
1207 If this is a number, old articles in a newsgroup exceeding this number
1208 are silently ignored. If it is nil, no article is ignored. Note that
1209 setting this variable to a number might prevent you from reading very
1210 old articles."
1211 :group 'gnus-group-select
1212 :version "22.2"
1213 :type '(choice (const :tag "No limit" nil)
1214 integer))
1215
1216 (gnus-define-group-parameter
1217 ignored-charsets
1218 :type list
1219 :function-document
1220 "Return the ignored charsets of GROUP."
1221 :variable gnus-group-ignored-charsets-alist
1222 :variable-default
1223 '(("alt\\.chinese\\.text" iso-8859-1))
1224 :variable-document
1225 "Alist of regexps (to match group names) and charsets that should be ignored.
1226 When these charsets are used in the \"charset\" parameter, the
1227 default charset will be used instead."
1228 :variable-group gnus-charset
1229 :variable-type '(repeat (cons (regexp :tag "Group")
1230 (repeat symbol)))
1231 :parameter-type '(choice :tag "Ignored charsets"
1232 :value nil
1233 (repeat (symbol)))
1234 :parameter-document "\
1235 List of charsets that should be ignored.
1236
1237 When these charsets are used in the \"charset\" parameter, the
1238 default charset will be used instead.")
1239
1240 (defcustom gnus-group-highlight-words-alist nil
1241 "Alist of group regexps and highlight regexps.
1242 This variable uses the same syntax as `gnus-emphasis-alist'."
1243 :version "21.1"
1244 :type '(repeat (cons (regexp :tag "Group")
1245 (repeat (list (regexp :tag "Highlight regexp")
1246 (number :tag "Group for entire word" 0)
1247 (number :tag "Group for displayed part" 0)
1248 (symbol :tag "Face"
1249 gnus-emphasis-highlight-words)))))
1250 :group 'gnus-summary-visual)
1251
1252 (defcustom gnus-summary-show-article-charset-alist
1253 nil
1254 "Alist of number and charset.
1255 The article will be shown with the charset corresponding to the
1256 numbered argument.
1257 For example: ((1 . cn-gb-2312) (2 . big5))."
1258 :version "21.1"
1259 :type '(repeat (cons (number :tag "Argument" 1)
1260 (symbol :tag "Charset")))
1261 :group 'gnus-charset)
1262
1263 (defcustom gnus-preserve-marks t
1264 "Whether marks are preserved when moving, copying and respooling messages."
1265 :version "21.1"
1266 :type 'boolean
1267 :group 'gnus-summary-marks)
1268
1269 (defcustom gnus-alter-articles-to-read-function nil
1270 "Function to be called to alter the list of articles to be selected."
1271 :type '(choice (const nil) function)
1272 :group 'gnus-summary)
1273
1274 (defcustom gnus-orphan-score nil
1275 "*All orphans get this score added. Set in the score file."
1276 :group 'gnus-score-default
1277 :type '(choice (const nil)
1278 integer))
1279
1280 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1281 "*A regexp to match MIME parts when saving multiple parts of a
1282 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1283 This regexp will be used by default when prompting the user for which
1284 type of files to save."
1285 :group 'gnus-summary
1286 :type 'regexp)
1287
1288 (defcustom gnus-read-all-available-headers nil
1289 "Whether Gnus should parse all headers made available to it.
1290 This is mostly relevant for slow back ends where the user may
1291 wish to widen the summary buffer to include all headers
1292 that were fetched."
1293 :version "22.1"
1294 :group 'gnus-summary
1295 :type '(choice boolean regexp))
1296
1297 (defcustom gnus-summary-pipe-output-default-command nil
1298 "Command (and optional arguments) used to pipe article to subprocess.
1299 This will be used as the default command if it is non-nil. The value
1300 will be updated if you modify it when executing the command
1301 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1302 :version "23.1" ;; No Gnus
1303 :group 'gnus-summary
1304 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1305
1306 (defcustom gnus-summary-muttprint-program "muttprint"
1307 "Command (and optional arguments) used to run Muttprint.
1308 The value will be updated if you modify it when executing the command
1309 `gnus-summary-muttprint'."
1310 :version "22.1"
1311 :group 'gnus-summary
1312 :type 'string)
1313
1314 (defcustom gnus-article-loose-mime t
1315 "If non-nil, don't require MIME-Version header.
1316 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1317 supply the MIME-Version header or deliberately strip it from the mail.
1318 If non-nil (the default), Gnus will treat some articles as MIME
1319 even if the MIME-Version header is missing."
1320 :version "22.1"
1321 :type 'boolean
1322 :group 'gnus-article-mime)
1323
1324 (defcustom gnus-article-emulate-mime t
1325 "If non-nil, use MIME emulation for uuencode and the like.
1326 This means that Gnus will search message bodies for text that look
1327 like uuencoded bits, yEncoded bits, and so on, and present that using
1328 the normal Gnus MIME machinery."
1329 :version "22.1"
1330 :type 'boolean
1331 :group 'gnus-article-mime)
1332
1333 ;;; Internal variables
1334
1335 (defvar gnus-summary-display-cache nil)
1336 (defvar gnus-article-mime-handles nil)
1337 (defvar gnus-article-decoded-p nil)
1338 (defvar gnus-article-charset nil)
1339 (defvar gnus-article-ignored-charsets nil)
1340 (defvar gnus-scores-exclude-files nil)
1341 (defvar gnus-page-broken nil)
1342
1343 (defvar gnus-original-article nil)
1344 (defvar gnus-article-internal-prepare-hook nil)
1345 (defvar gnus-newsgroup-process-stack nil)
1346
1347 (defvar gnus-thread-indent-array nil)
1348 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1349 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1350 "Function called to sort the articles within a thread after it has been gathered together.")
1351
1352 (defvar gnus-summary-save-parts-type-history nil)
1353 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1354
1355 ;; Avoid highlighting in kill files.
1356 (defvar gnus-summary-inhibit-highlight nil)
1357 (defvar gnus-newsgroup-selected-overlay nil)
1358 (defvar gnus-inhibit-limiting nil)
1359 (defvar gnus-newsgroup-adaptive-score-file nil)
1360 (defvar gnus-current-score-file nil)
1361 (defvar gnus-current-move-group nil)
1362 (defvar gnus-current-copy-group nil)
1363 (defvar gnus-current-crosspost-group nil)
1364 (defvar gnus-newsgroup-display nil)
1365
1366 (defvar gnus-newsgroup-dependencies nil)
1367 (defvar gnus-newsgroup-adaptive nil)
1368 (defvar gnus-summary-display-article-function nil)
1369 (defvar gnus-summary-highlight-line-function nil
1370 "Function called after highlighting a summary line.")
1371
1372 (defvar gnus-summary-line-format-alist
1373 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1374 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1375 (?s gnus-tmp-subject-or-nil ?s)
1376 (?n gnus-tmp-name ?s)
1377 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1378 ?s)
1379 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1380 gnus-tmp-from) ?s)
1381 (?F gnus-tmp-from ?s)
1382 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1383 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1384 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1385 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1386 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1387 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1388 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1389 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1390 (?L gnus-tmp-lines ?s)
1391 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1392 0) ?d)
1393 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1394 "") ?s)
1395 (?g (or (gnus-group-short-name
1396 (nnir-article-group (mail-header-number gnus-tmp-header)))
1397 "") ?s)
1398 (?O gnus-tmp-downloaded ?c)
1399 (?I gnus-tmp-indentation ?s)
1400 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1401 (?R gnus-tmp-replied ?c)
1402 (?\[ gnus-tmp-opening-bracket ?c)
1403 (?\] gnus-tmp-closing-bracket ?c)
1404 (?\> (make-string gnus-tmp-level ? ) ?s)
1405 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1406 (?i gnus-tmp-score ?d)
1407 (?z gnus-tmp-score-char ?c)
1408 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1409 (?U gnus-tmp-unread ?c)
1410 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1411 ?s)
1412 (?t (gnus-summary-number-of-articles-in-thread
1413 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1414 ?d)
1415 (?e (gnus-summary-number-of-articles-in-thread
1416 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1417 ?c)
1418 (?u gnus-tmp-user-defined ?s)
1419 (?P (gnus-pick-line-number) ?d)
1420 (?B gnus-tmp-thread-tree-header-string ?s)
1421 (user-date (gnus-user-date
1422 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1423 "An alist of format specifications that can appear in summary lines.
1424 These are paired with what variables they correspond with, along with
1425 the type of the variable (string, integer, character, etc).")
1426
1427 (defvar gnus-summary-dummy-line-format-alist
1428 `((?S gnus-tmp-subject ?s)
1429 (?N gnus-tmp-number ?d)
1430 (?u gnus-tmp-user-defined ?s)))
1431
1432 (defvar gnus-summary-mode-line-format-alist
1433 `((?G gnus-tmp-group-name ?s)
1434 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1435 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1436 (?A gnus-tmp-article-number ?d)
1437 (?Z gnus-tmp-unread-and-unselected ?s)
1438 (?V gnus-version ?s)
1439 (?U gnus-tmp-unread-and-unticked ?d)
1440 (?S gnus-tmp-subject ?s)
1441 (?e gnus-tmp-unselected ?d)
1442 (?u gnus-tmp-user-defined ?s)
1443 (?d (length gnus-newsgroup-dormant) ?d)
1444 (?t (length gnus-newsgroup-marked) ?d)
1445 (?h (length gnus-newsgroup-spam-marked) ?d)
1446 (?r (length gnus-newsgroup-reads) ?d)
1447 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1448 (?E gnus-newsgroup-expunged-tally ?d)
1449 (?s (gnus-current-score-file-nondirectory) ?s)))
1450
1451 ;; This is here rather than in gnus-art for compilation reasons.
1452 (defvar gnus-article-mode-line-format-alist
1453 (nconc '((?w (gnus-article-wash-status) ?s)
1454 (?m (gnus-article-mime-part-status) ?s))
1455 gnus-summary-mode-line-format-alist))
1456
1457 (defvar gnus-last-search-regexp nil
1458 "Default regexp for article search command.")
1459
1460 (defvar gnus-last-shell-command nil
1461 "Default shell command on article.")
1462
1463 (defvar gnus-newsgroup-agentized nil
1464 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1465 (defvar gnus-newsgroup-begin nil)
1466 (defvar gnus-newsgroup-end nil)
1467 (defvar gnus-newsgroup-last-rmail nil)
1468 (defvar gnus-newsgroup-last-mail nil)
1469 (defvar gnus-newsgroup-last-folder nil)
1470 (defvar gnus-newsgroup-last-file nil)
1471 (defvar gnus-newsgroup-last-directory nil)
1472 (defvar gnus-newsgroup-auto-expire nil)
1473 (defvar gnus-newsgroup-active nil)
1474 (defvar gnus-newsgroup-highest nil)
1475
1476 (defvar gnus-newsgroup-data nil)
1477 (defvar gnus-newsgroup-data-reverse nil)
1478 (defvar gnus-newsgroup-limit nil)
1479 (defvar gnus-newsgroup-limits nil)
1480 (defvar gnus-summary-use-undownloaded-faces nil)
1481
1482 (defvar gnus-newsgroup-unreads nil
1483 "Sorted list of unread articles in the current newsgroup.")
1484
1485 (defvar gnus-newsgroup-unselected nil
1486 "Sorted list of unselected unread articles in the current newsgroup.")
1487
1488 (defvar gnus-newsgroup-reads nil
1489 "Alist of read articles and article marks in the current newsgroup.")
1490
1491 (defvar gnus-newsgroup-expunged-tally nil)
1492
1493 (defvar gnus-newsgroup-marked nil
1494 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1495
1496 (defvar gnus-newsgroup-spam-marked nil
1497 "List of ranges of articles that have been marked as spam.")
1498
1499 (defvar gnus-newsgroup-killed nil
1500 "List of ranges of articles that have been through the scoring process.")
1501
1502 (defvar gnus-newsgroup-cached nil
1503 "Sorted list of articles that come from the article cache.")
1504
1505 (defvar gnus-newsgroup-saved nil
1506 "List of articles that have been saved.")
1507
1508 (defvar gnus-newsgroup-kill-headers nil)
1509
1510 (defvar gnus-newsgroup-replied nil
1511 "List of articles that have been replied to in the current newsgroup.")
1512
1513 (defvar gnus-newsgroup-forwarded nil
1514 "List of articles that have been forwarded in the current newsgroup.")
1515
1516 (defvar gnus-newsgroup-expirable nil
1517 "Sorted list of articles in the current newsgroup that can be expired.")
1518
1519 (defvar gnus-newsgroup-processable nil
1520 "List of articles in the current newsgroup that can be processed.")
1521
1522 (defvar gnus-newsgroup-downloadable nil
1523 "Sorted list of articles in the current newsgroup that can be processed.")
1524
1525 (defvar gnus-newsgroup-unfetched nil
1526 "Sorted list of articles in the current newsgroup whose headers have
1527 not been fetched into the agent.
1528
1529 This list will always be a subset of gnus-newsgroup-undownloaded.")
1530
1531 (defvar gnus-newsgroup-undownloaded nil
1532 "List of articles in the current newsgroup that haven't been downloaded.")
1533
1534 (defvar gnus-newsgroup-unsendable nil
1535 "List of articles in the current newsgroup that won't be sent.")
1536
1537 (defvar gnus-newsgroup-bookmarks nil
1538 "List of articles in the current newsgroup that have bookmarks.")
1539
1540 (defvar gnus-newsgroup-dormant nil
1541 "Sorted list of dormant articles in the current newsgroup.")
1542
1543 (defvar gnus-newsgroup-unseen nil
1544 "List of unseen articles in the current newsgroup.")
1545
1546 (defvar gnus-newsgroup-seen nil
1547 "Range of seen articles in the current newsgroup.")
1548
1549 (defvar gnus-newsgroup-unexist nil
1550 "Range of unexisting articles in the current newsgroup.")
1551
1552 (defvar gnus-newsgroup-articles nil
1553 "List of articles in the current newsgroup.")
1554
1555 (defvar gnus-newsgroup-scored nil
1556 "List of scored articles in the current newsgroup.")
1557
1558 (defvar gnus-newsgroup-headers nil
1559 "List of article headers in the current newsgroup.")
1560
1561 (defvar gnus-newsgroup-threads nil)
1562
1563 (defvar gnus-newsgroup-prepared nil
1564 "Whether the current group has been prepared properly.")
1565
1566 (defvar gnus-newsgroup-ancient nil
1567 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1568
1569 (defvar gnus-newsgroup-sparse nil)
1570
1571 (defvar gnus-current-article nil)
1572 (defvar gnus-article-current nil)
1573 (defvar gnus-current-headers nil)
1574 (defvar gnus-have-all-headers nil)
1575 (defvar gnus-last-article nil)
1576 (defvar gnus-newsgroup-history nil)
1577 (defvar gnus-newsgroup-charset nil)
1578 (defvar gnus-newsgroup-ephemeral-charset nil)
1579 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1580
1581 (defvar gnus-article-before-search nil)
1582
1583 (defvar gnus-summary-local-variables
1584 '(gnus-newsgroup-name
1585
1586 ;; Marks lists
1587 gnus-newsgroup-unreads
1588 gnus-newsgroup-unselected
1589 gnus-newsgroup-marked
1590 gnus-newsgroup-spam-marked
1591 gnus-newsgroup-reads
1592 gnus-newsgroup-saved
1593 gnus-newsgroup-replied
1594 gnus-newsgroup-forwarded
1595 gnus-newsgroup-expirable
1596 gnus-newsgroup-killed
1597 gnus-newsgroup-unseen
1598 gnus-newsgroup-seen
1599 gnus-newsgroup-unexist
1600 gnus-newsgroup-cached
1601 gnus-newsgroup-downloadable
1602 gnus-newsgroup-undownloaded
1603 gnus-newsgroup-unsendable
1604
1605 gnus-newsgroup-begin gnus-newsgroup-end
1606 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1607 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1608 gnus-newsgroup-last-directory
1609 gnus-newsgroup-auto-expire
1610 gnus-newsgroup-processable
1611 gnus-newsgroup-unfetched
1612 gnus-newsgroup-articles
1613 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1614 gnus-newsgroup-headers gnus-newsgroup-threads
1615 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1616 gnus-current-article gnus-current-headers gnus-have-all-headers
1617 gnus-last-article gnus-article-internal-prepare-hook
1618 (gnus-summary-article-delete-hook . global)
1619 (gnus-summary-article-move-hook . global)
1620 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1621 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1622 gnus-thread-expunge-below
1623 gnus-score-alist gnus-current-score-file
1624 (gnus-summary-expunge-below . global)
1625 (gnus-summary-mark-below . global)
1626 (gnus-orphan-score . global)
1627 gnus-newsgroup-active gnus-scores-exclude-files
1628 gnus-newsgroup-highest
1629 gnus-newsgroup-history gnus-newsgroup-ancient
1630 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1631 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1632 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1633 (gnus-newsgroup-expunged-tally . 0)
1634 gnus-cache-removable-articles
1635 gnus-newsgroup-data gnus-newsgroup-data-reverse
1636 gnus-newsgroup-limit gnus-newsgroup-limits
1637 gnus-newsgroup-charset gnus-newsgroup-display
1638 gnus-summary-use-undownloaded-faces)
1639 "Variables that are buffer-local to the summary buffers.")
1640
1641 (defvar gnus-newsgroup-variables nil
1642 "A list of variables that have separate values in different newsgroups.
1643 A list of newsgroup (summary buffer) local variables, or cons of
1644 variables and their default expressions to be evalled (when the default
1645 values are not nil), that should be made global while the summary buffer
1646 is active.
1647
1648 Note: The default expressions will be evaluated (using function `eval')
1649 before assignment to the local variable rather than just assigned to it.
1650 If the default expression is the symbol `global', that symbol will not
1651 be evaluated but the global value of the local variable will be used
1652 instead.
1653
1654 These variables can be used to set variables in the group parameters
1655 while still allowing them to affect operations done in other buffers.
1656 For example:
1657
1658 \(setq gnus-newsgroup-variables
1659 \\='(message-use-followup-to
1660 (gnus-visible-headers .
1661 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1662 ")
1663
1664 (eval-when-compile
1665 ;; Bind features so that require will believe that gnus-sum has
1666 ;; already been loaded (avoids infinite recursion)
1667 (let ((features (cons 'gnus-sum features)))
1668 (require 'gnus-art)))
1669
1670 ;; MIME stuff.
1671
1672 (defvar gnus-decode-encoded-word-methods
1673 '(mail-decode-encoded-word-string)
1674 "List of methods used to decode encoded words.
1675
1676 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1677 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1678 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1679 whose names match REGEXP.
1680
1681 For example:
1682 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1683 mail-decode-encoded-word-string
1684 (\"chinese\" . rfc1843-decode-string))")
1685
1686 (defvar gnus-decode-encoded-word-methods-cache nil)
1687
1688 (defun gnus-multi-decode-encoded-word-string (string)
1689 "Apply the functions from `gnus-encoded-word-methods' that match."
1690 (unless (and gnus-decode-encoded-word-methods-cache
1691 (eq gnus-newsgroup-name
1692 (car gnus-decode-encoded-word-methods-cache)))
1693 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1694 (dolist (method gnus-decode-encoded-word-methods)
1695 (if (symbolp method)
1696 (nconc gnus-decode-encoded-word-methods-cache (list method))
1697 (if (and gnus-newsgroup-name
1698 (string-match (car method) gnus-newsgroup-name))
1699 (nconc gnus-decode-encoded-word-methods-cache
1700 (list (cdr method)))))))
1701 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1702 (setq string (funcall method string))))
1703
1704 ;; Subject simplification.
1705
1706 (defun gnus-simplify-whitespace (str)
1707 "Remove excessive whitespace from STR."
1708 ;; Multiple spaces.
1709 (while (string-match "[ \t][ \t]+" str)
1710 (setq str (concat (substring str 0 (match-beginning 0))
1711 " "
1712 (substring str (match-end 0)))))
1713 ;; Leading spaces.
1714 (when (string-match "^[ \t]+" str)
1715 (setq str (substring str (match-end 0))))
1716 ;; Trailing spaces.
1717 (when (string-match "[ \t]+$" str)
1718 (setq str (substring str 0 (match-beginning 0))))
1719 str)
1720
1721 (defun gnus-simplify-all-whitespace (str)
1722 "Remove all whitespace from STR."
1723 (while (string-match "[ \t\n]+" str)
1724 (setq str (replace-match "" nil nil str)))
1725 str)
1726
1727 (defsubst gnus-simplify-subject-re (subject)
1728 "Remove \"Re:\" from subject lines."
1729 (if (string-match message-subject-re-regexp subject)
1730 (substring subject (match-end 0))
1731 subject))
1732
1733 (defun gnus-simplify-subject (subject &optional re-only)
1734 "Remove `Re:' and words in parentheses.
1735 If RE-ONLY is non-nil, strip leading `Re:'s only."
1736 (let ((case-fold-search t)) ;Ignore case.
1737 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1738 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1739 (setq subject (substring subject (match-end 0))))
1740 ;; Remove uninteresting prefixes.
1741 (when (and (not re-only)
1742 gnus-simplify-ignored-prefixes
1743 (string-match gnus-simplify-ignored-prefixes subject))
1744 (setq subject (substring subject (match-end 0))))
1745 ;; Remove words in parentheses from end.
1746 (unless re-only
1747 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1748 (setq subject (substring subject 0 (match-beginning 0)))))
1749 ;; Return subject string.
1750 subject))
1751
1752 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1753 ;; all whitespace.
1754 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1755 (goto-char (point-min))
1756 (while (re-search-forward regexp nil t)
1757 (replace-match (or newtext ""))))
1758
1759 (defun gnus-simplify-buffer-fuzzy (regexp)
1760 "Simplify string in the buffer fuzzily.
1761 The string in the accessible portion of the current buffer is simplified.
1762 It is assumed to be a single-line subject.
1763 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1764 matter is removed. Additional things can be deleted by setting
1765 `gnus-simplify-subject-fuzzy-regexp'."
1766 (let ((case-fold-search t)
1767 (modified-tick))
1768 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1769
1770 (while (not (eq modified-tick (buffer-modified-tick)))
1771 (setq modified-tick (buffer-modified-tick))
1772 (cond
1773 ((listp regexp)
1774 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1775 (regexp
1776 (gnus-simplify-buffer-fuzzy-step regexp)))
1777 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1778 (gnus-simplify-buffer-fuzzy-step
1779 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1780 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1781
1782 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1783 (gnus-simplify-buffer-fuzzy-step " +" " ")
1784 (gnus-simplify-buffer-fuzzy-step " $")
1785 (gnus-simplify-buffer-fuzzy-step "^ +")))
1786
1787 (defun gnus-simplify-subject-fuzzy (subject)
1788 "Simplify a subject string fuzzily.
1789 See `gnus-simplify-buffer-fuzzy' for details."
1790 (save-excursion
1791 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1792 (gnus-set-work-buffer)
1793 (let ((case-fold-search t))
1794 ;; Remove uninteresting prefixes.
1795 (when (and gnus-simplify-ignored-prefixes
1796 (string-match gnus-simplify-ignored-prefixes subject))
1797 (setq subject (substring subject (match-end 0))))
1798 (insert subject)
1799 (inline (gnus-simplify-buffer-fuzzy regexp))
1800 (buffer-string)))))
1801
1802 (defsubst gnus-simplify-subject-fully (subject)
1803 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1804 (cond
1805 (gnus-simplify-subject-functions
1806 (gnus-map-function gnus-simplify-subject-functions subject))
1807 ((null gnus-summary-gather-subject-limit)
1808 (gnus-simplify-subject-re subject))
1809 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1810 (gnus-simplify-subject-fuzzy subject))
1811 ((numberp gnus-summary-gather-subject-limit)
1812 (truncate-string-to-width (gnus-simplify-subject-re subject)
1813 gnus-summary-gather-subject-limit))
1814 (t
1815 subject)))
1816
1817 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1818 "Check whether two subjects are equal.
1819 If optional argument SIMPLE-FIRST is t, first argument is already
1820 simplified."
1821 (cond
1822 ((null simple-first)
1823 (equal (gnus-simplify-subject-fully s1)
1824 (gnus-simplify-subject-fully s2)))
1825 (t
1826 (equal s1
1827 (gnus-simplify-subject-fully s2)))))
1828
1829 (defun gnus-summary-bubble-group ()
1830 "Increase the score of the current group.
1831 This is a handy function to add to `gnus-summary-exit-hook' to
1832 increase the score of each group you read."
1833 (gnus-group-add-score gnus-newsgroup-name))
1834
1835 \f
1836 ;;;
1837 ;;; Gnus summary mode
1838 ;;;
1839
1840 (put 'gnus-summary-mode 'mode-class 'special)
1841
1842 (defvar gnus-article-commands-menu)
1843
1844 ;; Non-orthogonal keys
1845
1846 (gnus-define-keys gnus-summary-mode-map
1847 " " gnus-summary-next-page
1848 [?\S-\ ] gnus-summary-prev-page
1849 "\177" gnus-summary-prev-page
1850 [delete] gnus-summary-prev-page
1851 "\r" gnus-summary-scroll-up
1852 "\M-\r" gnus-summary-scroll-down
1853 "n" gnus-summary-next-unread-article
1854 "p" gnus-summary-prev-unread-article
1855 "N" gnus-summary-next-article
1856 "P" gnus-summary-prev-article
1857 "\M-\C-n" gnus-summary-next-same-subject
1858 "\M-\C-p" gnus-summary-prev-same-subject
1859 "\M-n" gnus-summary-next-unread-subject
1860 "\M-p" gnus-summary-prev-unread-subject
1861 "." gnus-summary-first-unread-article
1862 "," gnus-summary-best-unread-article
1863 "\M-s" gnus-summary-search-article-forward
1864 "\M-r" gnus-summary-search-article-backward
1865 "\M-S" gnus-summary-repeat-search-article-forward
1866 "\M-R" gnus-summary-repeat-search-article-backward
1867 "<" gnus-summary-beginning-of-article
1868 ">" gnus-summary-end-of-article
1869 "j" gnus-summary-goto-article
1870 "^" gnus-summary-refer-parent-article
1871 "\M-^" gnus-summary-refer-article
1872 "u" gnus-summary-tick-article-forward
1873 "!" gnus-summary-tick-article-forward
1874 "U" gnus-summary-tick-article-backward
1875 "d" gnus-summary-mark-as-read-forward
1876 "D" gnus-summary-mark-as-read-backward
1877 "E" gnus-summary-mark-as-expirable
1878 "\M-u" gnus-summary-clear-mark-forward
1879 "\M-U" gnus-summary-clear-mark-backward
1880 "k" gnus-summary-kill-same-subject-and-select
1881 "\C-k" gnus-summary-kill-same-subject
1882 "\M-\C-k" gnus-summary-kill-thread
1883 "\M-\C-l" gnus-summary-lower-thread
1884 "e" gnus-summary-edit-article
1885 "#" gnus-summary-mark-as-processable
1886 "\M-#" gnus-summary-unmark-as-processable
1887 "\M-\C-t" gnus-summary-toggle-threads
1888 "\M-\C-s" gnus-summary-show-thread
1889 "\M-\C-h" gnus-summary-hide-thread
1890 "\M-\C-f" gnus-summary-next-thread
1891 "\M-\C-b" gnus-summary-prev-thread
1892 [(meta down)] gnus-summary-next-thread
1893 [(meta up)] gnus-summary-prev-thread
1894 "\M-\C-u" gnus-summary-up-thread
1895 "\M-\C-d" gnus-summary-down-thread
1896 "&" gnus-summary-execute-command
1897 "c" gnus-summary-catchup-and-exit
1898 "\C-w" gnus-summary-mark-region-as-read
1899 "\C-t" gnus-summary-toggle-truncation
1900 "?" gnus-summary-mark-as-dormant
1901 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1902 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1903 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1904 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1905 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1906 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1907 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1908 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1909 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1910 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1911 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1912 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1913 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1914 "=" gnus-summary-expand-window
1915 "\C-x\C-s" gnus-summary-reselect-current-group
1916 "\M-g" gnus-summary-rescan-group
1917 "\C-c\C-r" gnus-summary-caesar-message
1918 "f" gnus-summary-followup
1919 "F" gnus-summary-followup-with-original
1920 "C" gnus-summary-cancel-article
1921 "r" gnus-summary-reply
1922 "R" gnus-summary-reply-with-original
1923 "\C-c\C-f" gnus-summary-mail-forward
1924 "o" gnus-summary-save-article
1925 "\C-o" gnus-summary-save-article-mail
1926 "|" gnus-summary-pipe-output
1927 "\M-k" gnus-summary-edit-local-kill
1928 "\M-K" gnus-summary-edit-global-kill
1929 ;; "V" gnus-version
1930 "\C-c\C-d" gnus-summary-describe-group
1931 "q" gnus-summary-exit
1932 "Q" gnus-summary-exit-no-update
1933 "\C-c\C-i" gnus-info-find-node
1934 gnus-mouse-2 gnus-mouse-pick-article
1935 [follow-link] mouse-face
1936 "m" gnus-summary-mail-other-window
1937 "a" gnus-summary-post-news
1938 "x" gnus-summary-limit-to-unread
1939 "s" gnus-summary-isearch-article
1940 "\t" gnus-summary-widget-forward
1941 [backtab] gnus-summary-widget-backward
1942 "t" gnus-summary-toggle-header
1943 "g" gnus-summary-show-article
1944 "l" gnus-summary-goto-last-article
1945 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1946 "\C-d" gnus-summary-enter-digest-group
1947 "\M-\C-d" gnus-summary-read-document
1948 "\M-\C-e" gnus-summary-edit-parameters
1949 "\M-\C-a" gnus-summary-customize-parameters
1950 "\C-c\C-b" gnus-bug
1951 "*" gnus-cache-enter-article
1952 "\M-*" gnus-cache-remove-article
1953 "\M-&" gnus-summary-universal-argument
1954 "\C-l" gnus-recenter
1955 "I" gnus-summary-increase-score
1956 "L" gnus-summary-lower-score
1957 "\M-i" gnus-symbolic-argument
1958 "h" gnus-summary-select-article-buffer
1959
1960 "b" gnus-article-view-part
1961 "\M-t" gnus-summary-toggle-display-buttonized
1962
1963 "V" gnus-summary-score-map
1964 "X" gnus-uu-extract-map
1965 "S" gnus-summary-send-map)
1966
1967 ;; Sort of orthogonal keymap
1968 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1969 "t" gnus-summary-tick-article-forward
1970 "!" gnus-summary-tick-article-forward
1971 "d" gnus-summary-mark-as-read-forward
1972 "r" gnus-summary-mark-as-read-forward
1973 "c" gnus-summary-clear-mark-forward
1974 " " gnus-summary-clear-mark-forward
1975 "e" gnus-summary-mark-as-expirable
1976 "x" gnus-summary-mark-as-expirable
1977 "?" gnus-summary-mark-as-dormant
1978 "b" gnus-summary-set-bookmark
1979 "B" gnus-summary-remove-bookmark
1980 "#" gnus-summary-mark-as-processable
1981 "\M-#" gnus-summary-unmark-as-processable
1982 "S" gnus-summary-limit-include-expunged
1983 "C" gnus-summary-catchup
1984 "H" gnus-summary-catchup-to-here
1985 "h" gnus-summary-catchup-from-here
1986 "\C-c" gnus-summary-catchup-all
1987 "k" gnus-summary-kill-same-subject-and-select
1988 "K" gnus-summary-kill-same-subject
1989 "P" gnus-uu-mark-map)
1990
1991 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1992 "c" gnus-summary-clear-above
1993 "u" gnus-summary-tick-above
1994 "m" gnus-summary-mark-above
1995 "k" gnus-summary-kill-below)
1996
1997 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1998 "/" gnus-summary-limit-to-subject
1999 "n" gnus-summary-limit-to-articles
2000 "b" gnus-summary-limit-to-bodies
2001 "h" gnus-summary-limit-to-headers
2002 "w" gnus-summary-pop-limit
2003 "s" gnus-summary-limit-to-subject
2004 "a" gnus-summary-limit-to-author
2005 "u" gnus-summary-limit-to-unread
2006 "m" gnus-summary-limit-to-marks
2007 "M" gnus-summary-limit-exclude-marks
2008 "v" gnus-summary-limit-to-score
2009 "*" gnus-summary-limit-include-cached
2010 "D" gnus-summary-limit-include-dormant
2011 "T" gnus-summary-limit-include-thread
2012 "d" gnus-summary-limit-exclude-dormant
2013 "t" gnus-summary-limit-to-age
2014 "." gnus-summary-limit-to-unseen
2015 "x" gnus-summary-limit-to-extra
2016 "p" gnus-summary-limit-to-display-predicate
2017 "E" gnus-summary-limit-include-expunged
2018 "c" gnus-summary-limit-exclude-childless-dormant
2019 "C" gnus-summary-limit-mark-excluded-as-read
2020 "o" gnus-summary-insert-old-articles
2021 "N" gnus-summary-insert-new-articles
2022 "S" gnus-summary-limit-to-singletons
2023 "r" gnus-summary-limit-to-replied
2024 "R" gnus-summary-limit-to-recipient
2025 "A" gnus-summary-limit-to-address)
2026
2027 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2028 "n" gnus-summary-next-unread-article
2029 "p" gnus-summary-prev-unread-article
2030 "N" gnus-summary-next-article
2031 "P" gnus-summary-prev-article
2032 "\C-n" gnus-summary-next-same-subject
2033 "\C-p" gnus-summary-prev-same-subject
2034 "\M-n" gnus-summary-next-unread-subject
2035 "\M-p" gnus-summary-prev-unread-subject
2036 "f" gnus-summary-first-unread-article
2037 "b" gnus-summary-best-unread-article
2038 "j" gnus-summary-goto-article
2039 "g" gnus-summary-goto-subject
2040 "l" gnus-summary-goto-last-article
2041 "o" gnus-summary-pop-article)
2042
2043 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2044 "k" gnus-summary-kill-thread
2045 "E" gnus-summary-expire-thread
2046 "l" gnus-summary-lower-thread
2047 "i" gnus-summary-raise-thread
2048 "T" gnus-summary-toggle-threads
2049 "t" gnus-summary-rethread-current
2050 "^" gnus-summary-reparent-thread
2051 "\M-^" gnus-summary-reparent-children
2052 "s" gnus-summary-show-thread
2053 "S" gnus-summary-show-all-threads
2054 "h" gnus-summary-hide-thread
2055 "H" gnus-summary-hide-all-threads
2056 "n" gnus-summary-next-thread
2057 "p" gnus-summary-prev-thread
2058 "u" gnus-summary-up-thread
2059 "o" gnus-summary-top-thread
2060 "d" gnus-summary-down-thread
2061 "#" gnus-uu-mark-thread
2062 "\M-#" gnus-uu-unmark-thread)
2063
2064 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2065 "g" gnus-summary-prepare
2066 "c" gnus-summary-insert-cached-articles
2067 "d" gnus-summary-insert-dormant-articles
2068 "t" gnus-summary-insert-ticked-articles)
2069
2070 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2071 "c" gnus-summary-catchup-and-exit
2072 "C" gnus-summary-catchup-all-and-exit
2073 "E" gnus-summary-exit-no-update
2074 "Q" gnus-summary-exit
2075 "Z" gnus-summary-exit
2076 "n" gnus-summary-catchup-and-goto-next-group
2077 "p" gnus-summary-catchup-and-goto-prev-group
2078 "R" gnus-summary-reselect-current-group
2079 "G" gnus-summary-rescan-group
2080 "N" gnus-summary-next-group
2081 "s" gnus-summary-save-newsrc
2082 "P" gnus-summary-prev-group)
2083
2084 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2085 " " gnus-summary-next-page
2086 "n" gnus-summary-next-page
2087 [?\S-\ ] gnus-summary-prev-page
2088 "\177" gnus-summary-prev-page
2089 [delete] gnus-summary-prev-page
2090 "p" gnus-summary-prev-page
2091 "\r" gnus-summary-scroll-up
2092 "\M-\r" gnus-summary-scroll-down
2093 "<" gnus-summary-beginning-of-article
2094 ">" gnus-summary-end-of-article
2095 "b" gnus-summary-beginning-of-article
2096 "e" gnus-summary-end-of-article
2097 "^" gnus-summary-refer-parent-article
2098 "r" gnus-summary-refer-parent-article
2099 "C" gnus-summary-show-complete-article
2100 "D" gnus-summary-enter-digest-group
2101 "R" gnus-summary-refer-references
2102 "T" gnus-summary-refer-thread
2103 "W" gnus-warp-to-article
2104 "g" gnus-summary-show-article
2105 "s" gnus-summary-isearch-article
2106 "\t" gnus-summary-widget-forward
2107 [backtab] gnus-summary-widget-backward
2108 "P" gnus-summary-print-article
2109 "S" gnus-sticky-article
2110 "M" gnus-mailing-list-insinuate
2111 "t" gnus-article-babel)
2112
2113 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2114 "b" gnus-article-add-buttons
2115 "B" gnus-article-add-buttons-to-head
2116 "o" gnus-article-treat-overstrike
2117 "e" gnus-article-emphasize
2118 "w" gnus-article-fill-cited-article
2119 "Q" gnus-article-fill-long-lines
2120 "L" gnus-article-toggle-truncate-lines
2121 "C" gnus-article-capitalize-sentences
2122 "c" gnus-article-remove-cr
2123 "q" gnus-article-de-quoted-unreadable
2124 "6" gnus-article-de-base64-unreadable
2125 "Z" gnus-article-decode-HZ
2126 "A" gnus-article-treat-ansi-sequences
2127 "h" gnus-article-wash-html
2128 "u" gnus-article-unsplit-urls
2129 "s" gnus-summary-force-verify-and-decrypt
2130 "f" gnus-article-display-x-face
2131 "l" gnus-summary-stop-page-breaking
2132 "r" gnus-summary-caesar-message
2133 "m" gnus-summary-morse-message
2134 "t" gnus-summary-toggle-header
2135 "g" gnus-treat-smiley
2136 "v" gnus-summary-verbose-headers
2137 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2138 "p" gnus-article-verify-x-pgp-sig
2139 "d" gnus-article-treat-dumbquotes
2140 "U" gnus-article-treat-non-ascii
2141 "i" gnus-summary-idna-message)
2142
2143 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2144 ;; mnemonic: deuglif*Y*
2145 "u" gnus-article-outlook-unwrap-lines
2146 "a" gnus-article-outlook-repair-attribution
2147 "c" gnus-article-outlook-rearrange-citation
2148 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2149
2150 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2151 "a" gnus-article-hide
2152 "h" gnus-article-hide-headers
2153 "b" gnus-article-hide-boring-headers
2154 "s" gnus-article-hide-signature
2155 "c" gnus-article-hide-citation
2156 "C" gnus-article-hide-citation-in-followups
2157 "l" gnus-article-hide-list-identifiers
2158 "B" gnus-article-strip-banner
2159 "P" gnus-article-hide-pem
2160 "\C-c" gnus-article-hide-citation-maybe)
2161
2162 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2163 "a" gnus-article-highlight
2164 "h" gnus-article-highlight-headers
2165 "c" gnus-article-highlight-citation
2166 "s" gnus-article-highlight-signature)
2167
2168 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2169 "f" gnus-article-treat-fold-headers
2170 "u" gnus-article-treat-unfold-headers
2171 "n" gnus-article-treat-fold-newsgroups)
2172
2173 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2174 "x" gnus-article-display-x-face
2175 "d" gnus-article-display-face
2176 "s" gnus-treat-smiley
2177 "D" gnus-article-remove-images
2178 "W" gnus-article-show-images
2179 "f" gnus-treat-from-picon
2180 "m" gnus-treat-mail-picon
2181 "n" gnus-treat-newsgroups-picon
2182 "g" gnus-treat-from-gravatar
2183 "h" gnus-treat-mail-gravatar)
2184
2185 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2186 "w" gnus-article-decode-mime-words
2187 "c" gnus-article-decode-charset
2188 "h" gnus-mime-buttonize-attachments-in-header
2189 "v" gnus-mime-view-all-parts
2190 "b" gnus-article-view-part)
2191
2192 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2193 "z" gnus-article-date-ut
2194 "u" gnus-article-date-ut
2195 "l" gnus-article-date-local
2196 "p" gnus-article-date-english
2197 "e" gnus-article-date-lapsed
2198 "o" gnus-article-date-original
2199 "i" gnus-article-date-iso8601
2200 "s" gnus-article-date-user)
2201
2202 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2203 "t" gnus-article-remove-trailing-blank-lines
2204 "l" gnus-article-strip-leading-blank-lines
2205 "m" gnus-article-strip-multiple-blank-lines
2206 "a" gnus-article-strip-blank-lines
2207 "A" gnus-article-strip-all-blank-lines
2208 "s" gnus-article-strip-leading-space
2209 "e" gnus-article-strip-trailing-space
2210 "w" gnus-article-remove-leading-whitespace)
2211
2212 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2213 "v" gnus-version
2214 "d" gnus-summary-describe-group
2215 "h" gnus-summary-describe-briefly
2216 "i" gnus-info-find-node)
2217
2218 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2219 "e" gnus-summary-expire-articles
2220 "\M-\C-e" gnus-summary-expire-articles-now
2221 "\177" gnus-summary-delete-article
2222 [delete] gnus-summary-delete-article
2223 [backspace] gnus-summary-delete-article
2224 "m" gnus-summary-move-article
2225 "r" gnus-summary-respool-article
2226 "w" gnus-summary-edit-article
2227 "c" gnus-summary-copy-article
2228 "B" gnus-summary-crosspost-article
2229 "q" gnus-summary-respool-query
2230 "t" gnus-summary-respool-trace
2231 "i" gnus-summary-import-article
2232 "I" gnus-summary-create-article
2233 "p" gnus-summary-article-posted-p)
2234
2235 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2236 "o" gnus-summary-save-article
2237 "m" gnus-summary-save-article-mail
2238 "F" gnus-summary-write-article-file
2239 "r" gnus-summary-save-article-rmail
2240 "f" gnus-summary-save-article-file
2241 "b" gnus-summary-save-article-body-file
2242 "B" gnus-summary-write-article-body-file
2243 "h" gnus-summary-save-article-folder
2244 "v" gnus-summary-save-article-vm
2245 "p" gnus-summary-pipe-output
2246 "P" gnus-summary-muttprint)
2247
2248 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2249 "b" gnus-summary-display-buttonized
2250 "m" gnus-summary-repair-multipart
2251 "v" gnus-article-view-part
2252 "o" gnus-article-save-part
2253 "O" gnus-article-save-part-and-strip
2254 "r" gnus-article-replace-part
2255 "d" gnus-article-delete-part
2256 "t" gnus-article-view-part-as-type
2257 "j" gnus-article-jump-to-part
2258 "c" gnus-article-copy-part
2259 "C" gnus-article-view-part-as-charset
2260 "e" gnus-article-view-part-externally
2261 "H" gnus-article-browse-html-article
2262 "E" gnus-article-encrypt-body
2263 "i" gnus-article-inline-part
2264 "|" gnus-article-pipe-part)
2265
2266 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2267 "p" gnus-summary-mark-as-processable
2268 "u" gnus-summary-unmark-as-processable
2269 "U" gnus-summary-unmark-all-processable
2270 "v" gnus-uu-mark-over
2271 "s" gnus-uu-mark-series
2272 "r" gnus-uu-mark-region
2273 "g" gnus-uu-unmark-region
2274 "R" gnus-uu-mark-by-regexp
2275 "G" gnus-uu-unmark-by-regexp
2276 "t" gnus-uu-mark-thread
2277 "T" gnus-uu-unmark-thread
2278 "a" gnus-uu-mark-all
2279 "b" gnus-uu-mark-buffer
2280 "S" gnus-uu-mark-sparse
2281 "k" gnus-summary-kill-process-mark
2282 "y" gnus-summary-yank-process-mark
2283 "w" gnus-summary-save-process-mark
2284 "i" gnus-uu-invert-processable)
2285
2286 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2287 ;;"x" gnus-uu-extract-any
2288 "m" gnus-summary-save-parts
2289 "u" gnus-uu-decode-uu
2290 "U" gnus-uu-decode-uu-and-save
2291 "s" gnus-uu-decode-unshar
2292 "S" gnus-uu-decode-unshar-and-save
2293 "o" gnus-uu-decode-save
2294 "O" gnus-uu-decode-save
2295 "b" gnus-uu-decode-binhex
2296 "B" gnus-uu-decode-binhex
2297 "Y" gnus-uu-decode-yenc
2298 "p" gnus-uu-decode-postscript
2299 "P" gnus-uu-decode-postscript-and-save)
2300
2301 (gnus-define-keys
2302 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2303 "u" gnus-uu-decode-uu-view
2304 "U" gnus-uu-decode-uu-and-save-view
2305 "s" gnus-uu-decode-unshar-view
2306 "S" gnus-uu-decode-unshar-and-save-view
2307 "o" gnus-uu-decode-save-view
2308 "O" gnus-uu-decode-save-view
2309 "b" gnus-uu-decode-binhex-view
2310 "B" gnus-uu-decode-binhex-view
2311 "p" gnus-uu-decode-postscript-view
2312 "P" gnus-uu-decode-postscript-and-save-view)
2313
2314 (defvar gnus-article-post-menu nil)
2315
2316 (defconst gnus-summary-menu-maxlen 20)
2317
2318 (defun gnus-summary-menu-split (menu)
2319 ;; If we have lots of elements, divide them into groups of 20
2320 ;; and make a pane (or submenu) for each one.
2321 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2322 (let ((menu menu) sublists next
2323 (i 1))
2324 (while menu
2325 ;; Pull off the next gnus-summary-menu-maxlen elements
2326 ;; and make them the next element of sublist.
2327 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2328 (if next
2329 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2330 nil))
2331 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2332 (aref (car (last menu)) 0)) menu)
2333 sublists))
2334 (setq i (1+ i))
2335 (setq menu next))
2336 (nreverse sublists))
2337 ;; Few elements--put them all in one pane.
2338 menu))
2339
2340 (defun gnus-summary-make-menu-bar ()
2341 (gnus-turn-off-edit-menu 'summary)
2342
2343 (unless (boundp 'gnus-summary-misc-menu)
2344
2345 (easy-menu-define
2346 gnus-summary-kill-menu gnus-summary-mode-map ""
2347 (cons
2348 "Score"
2349 (nconc
2350 (list
2351 ["Customize" gnus-score-customize t])
2352 (gnus-make-score-map 'increase)
2353 (gnus-make-score-map 'lower)
2354 '(("Mark"
2355 ["Kill below" gnus-summary-kill-below t]
2356 ["Mark above" gnus-summary-mark-above t]
2357 ["Tick above" gnus-summary-tick-above t]
2358 ["Clear above" gnus-summary-clear-above t])
2359 ["Current article score" gnus-summary-current-score t]
2360 ["Current thread score" (gnus-summary-current-score 'total) t]
2361 ["Set score" gnus-summary-set-score t]
2362 ["Switch current score file..." gnus-score-change-score-file t]
2363 ["Set mark below..." gnus-score-set-mark-below t]
2364 ["Set expunge below..." gnus-score-set-expunge-below t]
2365 ["Edit current score file" gnus-score-edit-current-scores t]
2366 ["Edit score file..." gnus-score-edit-file t]
2367 ["Trace score" gnus-score-find-trace t]
2368 ["Find words" gnus-score-find-favourite-words t]
2369 ["Rescore buffer" gnus-summary-rescore t]
2370 ["Increase score..." gnus-summary-increase-score t]
2371 ["Lower score..." gnus-summary-lower-score t]))))
2372
2373 ;; Define both the Article menu in the summary buffer and the
2374 ;; equivalent Commands menu in the article buffer here for
2375 ;; consistency.
2376 (let ((innards
2377 `(("Hide"
2378 ["All" gnus-article-hide t]
2379 ["Headers" gnus-article-hide-headers t]
2380 ["Signature" gnus-article-hide-signature t]
2381 ["Citation" gnus-article-hide-citation t]
2382 ["List identifiers" gnus-article-hide-list-identifiers t]
2383 ["Banner" gnus-article-strip-banner t]
2384 ["Boring headers" gnus-article-hide-boring-headers t])
2385 ("Highlight"
2386 ["All" gnus-article-highlight t]
2387 ["Headers" gnus-article-highlight-headers t]
2388 ["Signature" gnus-article-highlight-signature t]
2389 ["Citation" gnus-article-highlight-citation t])
2390 ("MIME"
2391 ["Words" gnus-article-decode-mime-words t]
2392 ["Charset" gnus-article-decode-charset t]
2393 ["QP" gnus-article-de-quoted-unreadable t]
2394 ["Base64" gnus-article-de-base64-unreadable t]
2395 ["View MIME buttons" gnus-summary-display-buttonized t]
2396 ["View MIME buttons in header"
2397 gnus-mime-buttonize-attachments-in-header t]
2398 ["View all" gnus-mime-view-all-parts t]
2399 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2400 ["Encrypt body" gnus-article-encrypt-body
2401 :active (not (gnus-group-read-only-p))
2402 ,@(if (featurep 'xemacs) nil
2403 '(:help "Encrypt the message body on disk"))]
2404 ["Extract all parts..." gnus-summary-save-parts t]
2405 ("Multipart"
2406 ["Repair multipart" gnus-summary-repair-multipart t]
2407 ["Pipe part..." gnus-article-pipe-part t]
2408 ["Inline part" gnus-article-inline-part t]
2409 ["View part as type..." gnus-article-view-part-as-type t]
2410 ["Encrypt body" gnus-article-encrypt-body
2411 :active (not (gnus-group-read-only-p))
2412 ,@(if (featurep 'xemacs) nil
2413 '(:help "Encrypt the message body on disk"))]
2414 ["View part externally" gnus-article-view-part-externally t]
2415 ["View HTML parts in browser" gnus-article-browse-html-article t]
2416 ["View part with charset..." gnus-article-view-part-as-charset t]
2417 ["Copy part" gnus-article-copy-part t]
2418 ["Save part..." gnus-article-save-part t]
2419 ["View part" gnus-article-view-part t]))
2420 ("Date"
2421 ["Local" gnus-article-date-local t]
2422 ["ISO8601" gnus-article-date-iso8601 t]
2423 ["UT" gnus-article-date-ut t]
2424 ["Original" gnus-article-date-original t]
2425 ["Lapsed" gnus-article-date-lapsed t]
2426 ["User-defined" gnus-article-date-user t])
2427 ("Display"
2428 ["Display HTML images" gnus-article-show-images t]
2429 ["Remove images" gnus-article-remove-images t]
2430 ["Toggle smiley" gnus-treat-smiley t]
2431 ["Show X-Face" gnus-article-display-x-face t]
2432 ["Show picons in From" gnus-treat-from-picon t]
2433 ["Show picons in mail headers" gnus-treat-mail-picon t]
2434 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2435 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2436 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2437 ("View as different encoding"
2438 ,@(gnus-summary-menu-split
2439 (mapcar
2440 (lambda (cs)
2441 ;; Since easymenu under Emacs doesn't allow
2442 ;; lambda forms for menu commands, we should
2443 ;; provide intern'ed function symbols.
2444 (let ((command (intern (format "\
2445 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2446 (fset command
2447 `(lambda ()
2448 (interactive)
2449 (let ((gnus-summary-show-article-charset-alist
2450 '((1 . ,cs))))
2451 (gnus-summary-show-article 1))))
2452 `[,(symbol-name cs) ,command t]))
2453 (sort (if (fboundp 'coding-system-list)
2454 (coding-system-list)
2455 (mapcar 'car mm-mime-mule-charset-alist))
2456 'string<)))))
2457 ("Washing"
2458 ("Remove Blanks"
2459 ["Leading" gnus-article-strip-leading-blank-lines t]
2460 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2461 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2462 ["All of the above" gnus-article-strip-blank-lines t]
2463 ["All" gnus-article-strip-all-blank-lines t]
2464 ["Leading space" gnus-article-strip-leading-space t]
2465 ["Trailing space" gnus-article-strip-trailing-space t]
2466 ["Leading space in headers"
2467 gnus-article-remove-leading-whitespace t])
2468 ["Overstrike" gnus-article-treat-overstrike t]
2469 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2470 ["Non-ASCII" gnus-article-treat-non-ascii t]
2471 ["Emphasis" gnus-article-emphasize t]
2472 ["Word wrap" gnus-article-fill-cited-article t]
2473 ["Fill long lines" gnus-article-fill-long-lines t]
2474 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2475 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2476 ["Remove CR" gnus-article-remove-cr t]
2477 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2478 ["Base64" gnus-article-de-base64-unreadable t]
2479 ["Rot 13" gnus-summary-caesar-message
2480 ,@(if (featurep 'xemacs) '(t)
2481 '(:help "\"Caesar rotate\" article by 13"))]
2482 ["De-IDNA" gnus-summary-idna-message t]
2483 ["Morse decode" gnus-summary-morse-message t]
2484 ["Unix pipe..." gnus-summary-pipe-message t]
2485 ["Add buttons" gnus-article-add-buttons t]
2486 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2487 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2488 ["Verbose header" gnus-summary-verbose-headers t]
2489 ["Toggle header" gnus-summary-toggle-header t]
2490 ["Unfold headers" gnus-article-treat-unfold-headers t]
2491 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2492 ["Html" gnus-article-wash-html t]
2493 ["Unsplit URLs" gnus-article-unsplit-urls t]
2494 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2495 ["Decode HZ" gnus-article-decode-HZ t]
2496 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2497 ("(Outlook) Deuglify"
2498 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2499 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2500 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2501 ["Full (Outlook) deuglify"
2502 gnus-article-outlook-deuglify-article t])
2503 )
2504 ("Output"
2505 ["Save in default format..." gnus-summary-save-article
2506 ,@(if (featurep 'xemacs) '(t)
2507 '(:help "Save article using default method"))]
2508 ["Save in file..." gnus-summary-save-article-file
2509 ,@(if (featurep 'xemacs) '(t)
2510 '(:help "Save article in file"))]
2511 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2512 ["Save in MH folder..." gnus-summary-save-article-folder t]
2513 ["Save in VM folder..." gnus-summary-save-article-vm t]
2514 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2515 ["Save body in file..." gnus-summary-save-article-body-file t]
2516 ["Pipe through a filter..." gnus-summary-pipe-output t]
2517 ["Print with Muttprint..." gnus-summary-muttprint t]
2518 ["Print" gnus-summary-print-article
2519 ,@(if (featurep 'xemacs) '(t)
2520 '(:help "Generate and print a PostScript image"))])
2521 ("Copy, move,... (Backend)"
2522 ,@(if (featurep 'xemacs) nil
2523 '(:help "Copying, moving, expiring articles..."))
2524 ["Respool article..." gnus-summary-respool-article t]
2525 ["Move article..." gnus-summary-move-article
2526 (gnus-check-backend-function
2527 'request-move-article gnus-newsgroup-name)]
2528 ["Copy article..." gnus-summary-copy-article t]
2529 ["Crosspost article..." gnus-summary-crosspost-article
2530 (gnus-check-backend-function
2531 'request-replace-article gnus-newsgroup-name)]
2532 ["Import file..." gnus-summary-import-article
2533 (gnus-check-backend-function
2534 'request-accept-article gnus-newsgroup-name)]
2535 ["Create article..." gnus-summary-create-article
2536 (gnus-check-backend-function
2537 'request-accept-article gnus-newsgroup-name)]
2538 ["Check if posted" gnus-summary-article-posted-p t]
2539 ["Edit article" gnus-summary-edit-article
2540 (not (gnus-group-read-only-p))]
2541 ["Delete article" gnus-summary-delete-article
2542 (gnus-check-backend-function
2543 'request-expire-articles gnus-newsgroup-name)]
2544 ["Query respool" gnus-summary-respool-query t]
2545 ["Trace respool" gnus-summary-respool-trace t]
2546 ["Delete expirable articles" gnus-summary-expire-articles-now
2547 (gnus-check-backend-function
2548 'request-expire-articles gnus-newsgroup-name)])
2549 ("Extract"
2550 ["Uudecode" gnus-uu-decode-uu
2551 ,@(if (featurep 'xemacs) '(t)
2552 '(:help "Decode uuencoded article(s)"))]
2553 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2554 ["Unshar" gnus-uu-decode-unshar t]
2555 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2556 ["Save" gnus-uu-decode-save t]
2557 ["Binhex" gnus-uu-decode-binhex t]
2558 ["PostScript" gnus-uu-decode-postscript t]
2559 ["All MIME parts" gnus-summary-save-parts t])
2560 ("Cache"
2561 ["Enter article" gnus-cache-enter-article t]
2562 ["Remove article" gnus-cache-remove-article t])
2563 ["Translate" gnus-article-babel t]
2564 ["Select article buffer" gnus-summary-select-article-buffer t]
2565 ["Make article buffer sticky" gnus-sticky-article t]
2566 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2567 ["Isearch article..." gnus-summary-isearch-article t]
2568 ["Beginning of the article" gnus-summary-beginning-of-article t]
2569 ["End of the article" gnus-summary-end-of-article t]
2570 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2571 ["Fetch referenced articles" gnus-summary-refer-references t]
2572 ["Fetch current thread" gnus-summary-refer-thread t]
2573 ["Fetch article with id..." gnus-summary-refer-article t]
2574 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2575 ["Redisplay" gnus-summary-show-article t]
2576 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2577 (easy-menu-define
2578 gnus-summary-article-menu gnus-summary-mode-map ""
2579 (cons "Article" innards))
2580
2581 (if (not (keymapp gnus-summary-article-menu))
2582 (easy-menu-define
2583 gnus-article-commands-menu gnus-article-mode-map ""
2584 (cons "Commands" innards))
2585 ;; in Emacs, don't share menu.
2586 (setq gnus-article-commands-menu
2587 (copy-keymap gnus-summary-article-menu))
2588 (define-key gnus-article-mode-map [menu-bar commands]
2589 (cons "Commands" gnus-article-commands-menu))))
2590
2591 (easy-menu-define
2592 gnus-summary-thread-menu gnus-summary-mode-map ""
2593 '("Threads"
2594 ["Find all messages in thread" gnus-summary-refer-thread t]
2595 ["Toggle threading" gnus-summary-toggle-threads t]
2596 ["Hide threads" gnus-summary-hide-all-threads t]
2597 ["Show threads" gnus-summary-show-all-threads t]
2598 ["Hide thread" gnus-summary-hide-thread t]
2599 ["Show thread" gnus-summary-show-thread t]
2600 ["Go to next thread" gnus-summary-next-thread t]
2601 ["Go to previous thread" gnus-summary-prev-thread t]
2602 ["Go down thread" gnus-summary-down-thread t]
2603 ["Go up thread" gnus-summary-up-thread t]
2604 ["Top of thread" gnus-summary-top-thread t]
2605 ["Mark thread as read" gnus-summary-kill-thread t]
2606 ["Mark thread as expired" gnus-summary-expire-thread t]
2607 ["Lower thread score" gnus-summary-lower-thread t]
2608 ["Raise thread score" gnus-summary-raise-thread t]
2609 ["Rethread current" gnus-summary-rethread-current t]))
2610
2611 (easy-menu-define
2612 gnus-summary-post-menu gnus-summary-mode-map ""
2613 `("Post"
2614 ["Send a message (mail or news)" gnus-summary-post-news
2615 ,@(if (featurep 'xemacs) '(t)
2616 '(:help "Compose a new message (mail or news)"))]
2617 ["Followup" gnus-summary-followup
2618 ,@(if (featurep 'xemacs) '(t)
2619 '(:help "Post followup to this article"))]
2620 ["Followup and yank" gnus-summary-followup-with-original
2621 ,@(if (featurep 'xemacs) '(t)
2622 '(:help "Post followup to this article, quoting its contents"))]
2623 ["Supersede article" gnus-summary-supersede-article t]
2624 ["Cancel article" gnus-summary-cancel-article
2625 ,@(if (featurep 'xemacs) '(t)
2626 '(:help "Cancel an article you posted"))]
2627 ["Reply" gnus-summary-reply t]
2628 ["Reply and yank" gnus-summary-reply-with-original t]
2629 ["Wide reply" gnus-summary-wide-reply t]
2630 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2631 ,@(if (featurep 'xemacs) '(t)
2632 '(:help "Mail a reply, quoting this article"))]
2633 ["Very wide reply" gnus-summary-very-wide-reply t]
2634 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2635 ,@(if (featurep 'xemacs) '(t)
2636 '(:help "Mail a very wide reply, quoting this article"))]
2637 ["Mail forward" gnus-summary-mail-forward t]
2638 ["Post forward" gnus-summary-post-forward t]
2639 ["Digest and mail" gnus-uu-digest-mail-forward t]
2640 ["Digest and post" gnus-uu-digest-post-forward t]
2641 ["Resend message" gnus-summary-resend-message t]
2642 ["Resend message edit" gnus-summary-resend-message-edit t]
2643 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2644 ["Send a mail" gnus-summary-mail-other-window t]
2645 ["Create a local message" gnus-summary-news-other-window t]
2646 ["Uuencode and post" gnus-uu-post-news
2647 ,@(if (featurep 'xemacs) '(t)
2648 '(:help "Post a uuencoded article"))]
2649 ["Followup via news" gnus-summary-followup-to-mail t]
2650 ["Followup via news and yank"
2651 gnus-summary-followup-to-mail-with-original t]
2652 ["Strip signature on reply"
2653 (lambda ()
2654 (interactive)
2655 (if (not (memq message-cite-function
2656 '(message-cite-original-without-signature
2657 message-cite-original)))
2658 ;; Stupid workaround for XEmacs not honoring :visible.
2659 (message "Can't toggle this value of `message-cite-function'")
2660 (setq message-cite-function
2661 (if (eq message-cite-function
2662 'message-cite-original-without-signature)
2663 'message-cite-original
2664 'message-cite-original-without-signature))))
2665 ;; XEmacs barfs on :visible.
2666 ,@(if (featurep 'xemacs) nil
2667 '(:visible (memq message-cite-function
2668 '(message-cite-original-without-signature
2669 message-cite-original))))
2670 :style toggle
2671 :selected (eq message-cite-function
2672 'message-cite-original-without-signature)
2673 ,@(if (featurep 'xemacs) nil
2674 '(:help "Strip signature from cited article when replying."))]
2675 ;;("Draft"
2676 ;;["Send" gnus-summary-send-draft t]
2677 ;;["Send bounced" gnus-resend-bounced-mail t])
2678 ))
2679
2680 (cond
2681 ((not (keymapp gnus-summary-post-menu))
2682 (setq gnus-article-post-menu gnus-summary-post-menu))
2683 ((not gnus-article-post-menu)
2684 ;; Don't share post menu.
2685 (setq gnus-article-post-menu
2686 (copy-keymap gnus-summary-post-menu))))
2687 (define-key gnus-article-mode-map [menu-bar post]
2688 (cons "Post" gnus-article-post-menu))
2689
2690 (easy-menu-define
2691 gnus-summary-misc-menu gnus-summary-mode-map ""
2692 `("Gnus"
2693 ("Mark Read"
2694 ["Mark as read" gnus-summary-mark-as-read-forward t]
2695 ["Mark same subject and select"
2696 gnus-summary-kill-same-subject-and-select t]
2697 ["Mark same subject" gnus-summary-kill-same-subject t]
2698 ["Catchup" gnus-summary-catchup
2699 ,@(if (featurep 'xemacs) '(t)
2700 '(:help "Mark unread articles in this group as read"))]
2701 ["Catchup all" gnus-summary-catchup-all t]
2702 ["Catchup to here" gnus-summary-catchup-to-here t]
2703 ["Catchup from here" gnus-summary-catchup-from-here t]
2704 ["Catchup region" gnus-summary-mark-region-as-read
2705 (gnus-mark-active-p)]
2706 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2707 ("Mark Various"
2708 ["Tick" gnus-summary-tick-article-forward t]
2709 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2710 ["Remove marks" gnus-summary-clear-mark-forward t]
2711 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2712 ["Set bookmark" gnus-summary-set-bookmark t]
2713 ["Remove bookmark" gnus-summary-remove-bookmark t])
2714 ("Limit to"
2715 ["Marks..." gnus-summary-limit-to-marks t]
2716 ["Subject..." gnus-summary-limit-to-subject t]
2717 ["Author..." gnus-summary-limit-to-author t]
2718 ["Recipient..." gnus-summary-limit-to-recipient t]
2719 ["Address..." gnus-summary-limit-to-address t]
2720 ["Age..." gnus-summary-limit-to-age t]
2721 ["Extra..." gnus-summary-limit-to-extra t]
2722 ["Score..." gnus-summary-limit-to-score t]
2723 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2724 ["Unread" gnus-summary-limit-to-unread t]
2725 ["Unseen" gnus-summary-limit-to-unseen t]
2726 ["Singletons" gnus-summary-limit-to-singletons t]
2727 ["Replied" gnus-summary-limit-to-replied t]
2728 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2729 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2730 ["Pop limit" gnus-summary-pop-limit t]
2731 ["Show dormant" gnus-summary-limit-include-dormant t]
2732 ["Hide childless dormant"
2733 gnus-summary-limit-exclude-childless-dormant t]
2734 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2735 ["Hide marked" gnus-summary-limit-exclude-marks t]
2736 ["Show expunged" gnus-summary-limit-include-expunged t])
2737 ("Process Mark"
2738 ["Set mark" gnus-summary-mark-as-processable t]
2739 ["Remove mark" gnus-summary-unmark-as-processable t]
2740 ["Remove all marks" gnus-summary-unmark-all-processable t]
2741 ["Invert marks" gnus-uu-invert-processable t]
2742 ["Mark above" gnus-uu-mark-over t]
2743 ["Mark series" gnus-uu-mark-series t]
2744 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2745 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2746 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2747 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2748 ["Mark all" gnus-uu-mark-all t]
2749 ["Mark buffer" gnus-uu-mark-buffer t]
2750 ["Mark sparse" gnus-uu-mark-sparse t]
2751 ["Mark thread" gnus-uu-mark-thread t]
2752 ["Unmark thread" gnus-uu-unmark-thread t]
2753 ("Process Mark Sets"
2754 ["Kill" gnus-summary-kill-process-mark t]
2755 ["Yank" gnus-summary-yank-process-mark
2756 gnus-newsgroup-process-stack]
2757 ["Save" gnus-summary-save-process-mark t]
2758 ["Run command on marked..." gnus-summary-universal-argument t]))
2759 ("Registry Marks")
2760 ("Scroll article"
2761 ["Page forward" gnus-summary-next-page
2762 ,@(if (featurep 'xemacs) '(t)
2763 '(:help "Show next page of article"))]
2764 ["Page backward" gnus-summary-prev-page
2765 ,@(if (featurep 'xemacs) '(t)
2766 '(:help "Show previous page of article"))]
2767 ["Line forward" gnus-summary-scroll-up t])
2768 ("Move"
2769 ["Next unread article" gnus-summary-next-unread-article t]
2770 ["Previous unread article" gnus-summary-prev-unread-article t]
2771 ["Next article" gnus-summary-next-article t]
2772 ["Previous article" gnus-summary-prev-article t]
2773 ["Next unread subject" gnus-summary-next-unread-subject t]
2774 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2775 ["Next article same subject" gnus-summary-next-same-subject t]
2776 ["Previous article same subject" gnus-summary-prev-same-subject t]
2777 ["First unread article" gnus-summary-first-unread-article t]
2778 ["Best unread article" gnus-summary-best-unread-article t]
2779 ["Go to subject number..." gnus-summary-goto-subject t]
2780 ["Go to article number..." gnus-summary-goto-article t]
2781 ["Go to the last article" gnus-summary-goto-last-article t]
2782 ["Pop article off history" gnus-summary-pop-article t])
2783 ("Sort"
2784 ["Sort by number" gnus-summary-sort-by-number t]
2785 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2786 ["Sort by author" gnus-summary-sort-by-author t]
2787 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2788 ["Sort by subject" gnus-summary-sort-by-subject t]
2789 ["Sort by date" gnus-summary-sort-by-date t]
2790 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2791 ["Sort by score" gnus-summary-sort-by-score t]
2792 ["Sort by lines" gnus-summary-sort-by-lines t]
2793 ["Sort by characters" gnus-summary-sort-by-chars t]
2794 ["Randomize" gnus-summary-sort-by-random t]
2795 ["Original sort" gnus-summary-sort-by-original t])
2796 ("Help"
2797 ["Describe group" gnus-summary-describe-group t]
2798 ["Read manual" gnus-info-find-node t])
2799 ("Modes"
2800 ["Pick and read" gnus-pick-mode t]
2801 ["Binary" gnus-binary-mode t])
2802 ("Regeneration"
2803 ["Regenerate" gnus-summary-prepare t]
2804 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2805 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2806 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2807 ["Toggle threading" gnus-summary-toggle-threads t])
2808 ["See old articles" gnus-summary-insert-old-articles t]
2809 ["See new articles" gnus-summary-insert-new-articles t]
2810 ["Filter articles..." gnus-summary-execute-command t]
2811 ["Run command on articles..." gnus-summary-universal-argument t]
2812 ["Search articles forward..." gnus-summary-search-article-forward t]
2813 ["Search articles backward..." gnus-summary-search-article-backward t]
2814 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2815 ["Expand window" gnus-summary-expand-window t]
2816 ["Expire expirable articles" gnus-summary-expire-articles
2817 (gnus-check-backend-function
2818 'request-expire-articles gnus-newsgroup-name)]
2819 ["Edit local kill file" gnus-summary-edit-local-kill t]
2820 ["Edit main kill file" gnus-summary-edit-global-kill t]
2821 ["Edit group parameters" gnus-summary-edit-parameters t]
2822 ["Customize group parameters" gnus-summary-customize-parameters t]
2823 ["Send a bug report" gnus-bug t]
2824 ("Exit"
2825 ["Catchup and exit" gnus-summary-catchup-and-exit
2826 ,@(if (featurep 'xemacs) '(t)
2827 '(:help "Mark unread articles in this group as read, then exit"))]
2828 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2829 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2830 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2831 ["Exit group" gnus-summary-exit
2832 ,@(if (featurep 'xemacs) '(t)
2833 '(:help "Exit current group, return to group selection mode"))]
2834 ["Exit group without updating" gnus-summary-exit-no-update t]
2835 ["Exit and goto next group" gnus-summary-next-group t]
2836 ["Exit and goto prev group" gnus-summary-prev-group t]
2837 ["Reselect group" gnus-summary-reselect-current-group t]
2838 ["Rescan group" gnus-summary-rescan-group t]
2839 ["Update dribble" gnus-summary-save-newsrc t])))
2840
2841 (gnus-run-hooks 'gnus-summary-menu-hook)))
2842
2843 (defvar gnus-summary-tool-bar-map nil)
2844
2845 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2846 ;; affect _new_ message buffers. We might add a function that walks thru all
2847 ;; summary-mode buffers and force the update.
2848 (defun gnus-summary-tool-bar-update (&optional symbol value)
2849 "Update summary mode toolbar.
2850 Setter function for custom variables."
2851 (setq-default gnus-summary-tool-bar-map nil)
2852 (when symbol
2853 ;; When used as ":set" function:
2854 (set-default symbol value))
2855 (when (gnus-buffer-live-p gnus-summary-buffer)
2856 (with-current-buffer gnus-summary-buffer
2857 (gnus-summary-make-tool-bar))))
2858
2859 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2860 'gnus-summary-tool-bar-gnome
2861 'gnus-summary-tool-bar-retro)
2862 "Specifies the Gnus summary tool bar.
2863
2864 It can be either a list or a symbol referring to a list. See
2865 `gmm-tool-bar-from-list' for the format of the list. The
2866 default key map is `gnus-summary-mode-map'.
2867
2868 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2869 `gnus-summary-tool-bar-retro'."
2870 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2871 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2872 (repeat :tag "User defined list" gmm-tool-bar-item)
2873 (symbol))
2874 :version "23.1" ;; No Gnus
2875 :initialize 'custom-initialize-default
2876 :set 'gnus-summary-tool-bar-update
2877 :group 'gnus-summary)
2878
2879 (defcustom gnus-summary-tool-bar-gnome
2880 '((gnus-summary-post-news "mail/compose" nil)
2881 (gnus-summary-insert-new-articles "mail/inbox" nil
2882 :visible (or (not gnus-agent)
2883 gnus-plugged))
2884 (gnus-summary-reply-with-original "mail/reply")
2885 (gnus-summary-reply "mail/reply" nil :visible nil)
2886 (gnus-summary-followup-with-original "mail/reply-all")
2887 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2888 (gnus-summary-mail-forward "mail/forward")
2889 (gnus-summary-save-article "mail/save")
2890 (gnus-summary-search-article-forward "search" nil :visible nil)
2891 (gnus-summary-print-article "print")
2892 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2893 ;; Some new commands that may need more suitable icons:
2894 (gnus-summary-save-newsrc "save" nil :visible nil)
2895 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2896 (gnus-summary-prev-article "left-arrow")
2897 (gnus-summary-next-article "right-arrow")
2898 (gnus-summary-next-page "next-page")
2899 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2900 ;;
2901 ;; Maybe some sort-by-... could be added:
2902 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2903 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2904 (gnus-summary-mark-as-expirable
2905 "delete" nil
2906 :visible (gnus-check-backend-function 'request-expire-articles
2907 gnus-newsgroup-name))
2908 (gnus-summary-mark-as-spam
2909 "mail/spam" t
2910 :visible (and (fboundp 'spam-group-ham-contents-p)
2911 (spam-group-ham-contents-p gnus-newsgroup-name))
2912 :help "Mark as spam")
2913 (gnus-summary-mark-as-read-forward
2914 "mail/not-spam" nil
2915 :visible (and (fboundp 'spam-group-spam-contents-p)
2916 (spam-group-spam-contents-p gnus-newsgroup-name)))
2917 ;;
2918 (gnus-summary-exit "exit")
2919 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2920 (gnus-info-find-node "help"))
2921 "List of functions for the summary tool bar (GNOME style).
2922
2923 See `gmm-tool-bar-from-list' for the format of the list."
2924 :type '(repeat gmm-tool-bar-item)
2925 :version "23.1" ;; No Gnus
2926 :initialize 'custom-initialize-default
2927 :set 'gnus-summary-tool-bar-update
2928 :group 'gnus-summary)
2929
2930 (defcustom gnus-summary-tool-bar-retro
2931 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2932 (gnus-summary-next-unread-article "gnus/next-ur")
2933 (gnus-summary-post-news "gnus/post")
2934 (gnus-summary-followup-with-original "gnus/fuwo")
2935 (gnus-summary-followup "gnus/followup")
2936 (gnus-summary-reply-with-original "gnus/reply-wo")
2937 (gnus-summary-reply "gnus/reply")
2938 (gnus-summary-caesar-message "gnus/rot13")
2939 (gnus-uu-decode-uu "gnus/uu-decode")
2940 (gnus-summary-save-article-file "gnus/save-aif")
2941 (gnus-summary-save-article "gnus/save-art")
2942 (gnus-uu-post-news "gnus/uu-post")
2943 (gnus-summary-catchup "gnus/catchup")
2944 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2945 (gnus-summary-exit "gnus/exit-summ")
2946 ;; Some new command that may need more suitable icons:
2947 (gnus-summary-print-article "gnus/print" nil :visible nil)
2948 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2949 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2950 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2951 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2952 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2953 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2954 ;;
2955 (gnus-info-find-node "gnus/help" nil :visible nil))
2956 "List of functions for the summary tool bar (retro look).
2957
2958 See `gmm-tool-bar-from-list' for the format of the list."
2959 :type '(repeat gmm-tool-bar-item)
2960 :version "23.1" ;; No Gnus
2961 :initialize 'custom-initialize-default
2962 :set 'gnus-summary-tool-bar-update
2963 :group 'gnus-summary)
2964
2965 (defcustom gnus-summary-tool-bar-zap-list t
2966 "List of icon items from the global tool bar.
2967 These items are not displayed in the Gnus summary mode tool bar.
2968
2969 See `gmm-tool-bar-from-list' for the format of the list."
2970 :type 'gmm-tool-bar-zap-list
2971 :version "23.1" ;; No Gnus
2972 :initialize 'custom-initialize-default
2973 :set 'gnus-summary-tool-bar-update
2974 :group 'gnus-summary)
2975
2976 (defvar image-load-path)
2977 (defvar tool-bar-map)
2978
2979 (defun gnus-summary-make-tool-bar (&optional force)
2980 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2981 When FORCE, rebuild the tool bar."
2982 (when (and (not (featurep 'xemacs))
2983 (boundp 'tool-bar-mode)
2984 tool-bar-mode
2985 (or (not gnus-summary-tool-bar-map) force))
2986 (let* ((load-path
2987 (gmm-image-load-path-for-library "gnus"
2988 "mail/save.xpm"
2989 nil t))
2990 (image-load-path (cons (car load-path)
2991 (when (boundp 'image-load-path)
2992 image-load-path)))
2993 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2994 gnus-summary-tool-bar-zap-list
2995 'gnus-summary-mode-map)))
2996 (when map
2997 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2998 ;; uses its value.
2999 (setq gnus-summary-tool-bar-map map))))
3000 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
3001
3002 (defun gnus-make-score-map (type)
3003 "Make a summary score map of type TYPE."
3004 (if t
3005 nil
3006 (let ((headers '(("author" "from" string)
3007 ("subject" "subject" string)
3008 ("article body" "body" string)
3009 ("article head" "head" string)
3010 ("xref" "xref" string)
3011 ("extra header" "extra" string)
3012 ("lines" "lines" number)
3013 ("followups to author" "followup" string)))
3014 (types '((number ("less than" <)
3015 ("greater than" >)
3016 ("equal" =))
3017 (string ("substring" s)
3018 ("exact string" e)
3019 ("fuzzy string" f)
3020 ("regexp" r))))
3021 (perms '(("temporary" (current-time-string))
3022 ("permanent" nil)
3023 ("immediate" now)))
3024 header)
3025 (list
3026 (apply
3027 'nconc
3028 (list
3029 (if (eq type 'lower)
3030 "Lower score"
3031 "Increase score"))
3032 (let (outh)
3033 (while headers
3034 (setq header (car headers))
3035 (setq outh
3036 (cons
3037 (apply
3038 'nconc
3039 (list (car header))
3040 (let ((ts (cdr (assoc (nth 2 header) types)))
3041 outt)
3042 (while ts
3043 (setq outt
3044 (cons
3045 (apply
3046 'nconc
3047 (list (caar ts))
3048 (let ((ps perms)
3049 outp)
3050 (while ps
3051 (setq outp
3052 (cons
3053 (vector
3054 (caar ps)
3055 (list
3056 'gnus-summary-score-entry
3057 (nth 1 header)
3058 (if (or (string= (nth 1 header)
3059 "head")
3060 (string= (nth 1 header)
3061 "body"))
3062 ""
3063 (list 'gnus-summary-header
3064 (nth 1 header)))
3065 (list 'quote (nth 1 (car ts)))
3066 (list 'gnus-score-delta-default
3067 nil)
3068 (nth 1 (car ps))
3069 t)
3070 t)
3071 outp))
3072 (setq ps (cdr ps)))
3073 (list (nreverse outp))))
3074 outt))
3075 (setq ts (cdr ts)))
3076 (list (nreverse outt))))
3077 outh))
3078 (setq headers (cdr headers)))
3079 (list (nreverse outh))))))))
3080
3081
3082 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3083 (defvar bookmark-make-record-function)
3084 \f
3085 (defvar bidi-paragraph-direction)
3086
3087 (defun gnus-summary-mode (&optional group)
3088 "Major mode for reading articles.
3089
3090 All normal editing commands are switched off.
3091 \\<gnus-summary-mode-map>
3092 Each line in this buffer represents one article. To read an
3093 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3094 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3095 respectively.
3096
3097 You can also post articles and send mail from this buffer. To
3098 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3099 of an article, type `\\[gnus-summary-reply]'.
3100
3101 There are approx. one gazillion commands you can execute in this
3102 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3103
3104 The following commands are available:
3105
3106 \\{gnus-summary-mode-map}"
3107 ;; FIXME: Use define-derived-mode.
3108 (interactive)
3109 (kill-all-local-variables)
3110 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3111 (gnus-summary-make-local-variables))
3112 (gnus-summary-make-local-variables)
3113 (setq gnus-newsgroup-name group)
3114 (when (gnus-visual-p 'summary-menu 'menu)
3115 (gnus-summary-make-menu-bar)
3116 (gnus-summary-make-tool-bar))
3117 (gnus-make-thread-indent-array)
3118 (gnus-simplify-mode-line)
3119 (setq major-mode 'gnus-summary-mode)
3120 (setq mode-name "Summary")
3121 (use-local-map gnus-summary-mode-map)
3122 (buffer-disable-undo)
3123 (setq buffer-read-only t ;Disable modification
3124 show-trailing-whitespace nil)
3125 (setq truncate-lines t)
3126 ;; Force paragraph direction to be left-to-right. Don't make it
3127 ;; bound globally in old Emacsen and XEmacsen.
3128 (set (make-local-variable 'bidi-paragraph-direction) 'left-to-right)
3129 (add-to-invisibility-spec '(gnus-sum . t))
3130 (gnus-summary-set-display-table)
3131 (gnus-set-default-directory)
3132 (make-local-variable 'gnus-summary-line-format)
3133 (make-local-variable 'gnus-summary-line-format-spec)
3134 (make-local-variable 'gnus-summary-dummy-line-format)
3135 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3136 (make-local-variable 'gnus-summary-mark-positions)
3137 (gnus-make-local-hook 'pre-command-hook)
3138 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3139 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3140 (turn-on-gnus-mailing-list-mode)
3141 (mm-enable-multibyte)
3142 (set (make-local-variable 'bookmark-make-record-function)
3143 'gnus-summary-bookmark-make-record)
3144 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3145 (gnus-update-summary-mark-positions))
3146
3147 (defun gnus-summary-make-local-variables ()
3148 "Make all the local summary buffer variables."
3149 (let (global)
3150 (dolist (local gnus-summary-local-variables)
3151 (if (consp local)
3152 (progn
3153 (if (eq (cdr local) 'global)
3154 ;; Copy the global value of the variable.
3155 (setq global (symbol-value (car local)))
3156 ;; Use the value from the list.
3157 (setq global (eval (cdr local))))
3158 (set (make-local-variable (car local)) global))
3159 ;; Simple nil-valued local variable.
3160 (set (make-local-variable local) nil)))))
3161
3162 ;; Summary data functions.
3163
3164 (defmacro gnus-data-number (data)
3165 `(car ,data))
3166
3167 (defmacro gnus-data-set-number (data number)
3168 `(setcar ,data ,number))
3169
3170 (defmacro gnus-data-mark (data)
3171 `(nth 1 ,data))
3172
3173 (defmacro gnus-data-set-mark (data mark)
3174 `(setcar (nthcdr 1 ,data) ,mark))
3175
3176 (defmacro gnus-data-pos (data)
3177 `(nth 2 ,data))
3178
3179 (defmacro gnus-data-set-pos (data pos)
3180 `(setcar (nthcdr 2 ,data) ,pos))
3181
3182 (defmacro gnus-data-header (data)
3183 `(nth 3 ,data))
3184
3185 (defmacro gnus-data-set-header (data header)
3186 `(setf (nth 3 ,data) ,header))
3187
3188 (defmacro gnus-data-level (data)
3189 `(nth 4 ,data))
3190
3191 (defmacro gnus-data-unread-p (data)
3192 `(= (nth 1 ,data) gnus-unread-mark))
3193
3194 (defmacro gnus-data-read-p (data)
3195 `(/= (nth 1 ,data) gnus-unread-mark))
3196
3197 (defmacro gnus-data-pseudo-p (data)
3198 `(consp (nth 3 ,data)))
3199
3200 (defmacro gnus-data-find (number)
3201 `(assq ,number gnus-newsgroup-data))
3202
3203 (defmacro gnus-data-find-list (number &optional data)
3204 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3205 (memq (assq ,number bdata)
3206 bdata)))
3207
3208 (defmacro gnus-data-make (number mark pos header level)
3209 `(list ,number ,mark ,pos ,header ,level))
3210
3211 (defun gnus-data-enter (after-article number mark pos header level offset)
3212 (let ((data (gnus-data-find-list after-article)))
3213 (unless data
3214 (error "No such article: %d" after-article))
3215 (setcdr data (cons (gnus-data-make number mark pos header level)
3216 (cdr data)))
3217 (setq gnus-newsgroup-data-reverse nil)
3218 (gnus-data-update-list (cddr data) offset)))
3219
3220 (defun gnus-data-enter-list (after-article list &optional offset)
3221 (when list
3222 (let ((data (and after-article (gnus-data-find-list after-article)))
3223 (ilist list))
3224 (if (not (or data
3225 after-article))
3226 (let ((odata gnus-newsgroup-data))
3227 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3228 (when offset
3229 (gnus-data-update-list odata offset)))
3230 ;; Find the last element in the list to be spliced into the main
3231 ;; list.
3232 (setq list (last list))
3233 (if (not data)
3234 (progn
3235 (setcdr list gnus-newsgroup-data)
3236 (setq gnus-newsgroup-data ilist)
3237 (when offset
3238 (gnus-data-update-list (cdr list) offset)))
3239 (setcdr list (cdr data))
3240 (setcdr data ilist)
3241 (when offset
3242 (gnus-data-update-list (cdr list) offset))))
3243 (setq gnus-newsgroup-data-reverse nil))))
3244
3245 (defun gnus-data-remove (article &optional offset)
3246 (let ((data gnus-newsgroup-data))
3247 (if (= (gnus-data-number (car data)) article)
3248 (progn
3249 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3250 gnus-newsgroup-data-reverse nil)
3251 (when offset
3252 (gnus-data-update-list gnus-newsgroup-data offset)))
3253 (while (cdr data)
3254 (when (= (gnus-data-number (cadr data)) article)
3255 (setcdr data (cddr data))
3256 (when offset
3257 (gnus-data-update-list (cdr data) offset))
3258 (setq data nil
3259 gnus-newsgroup-data-reverse nil))
3260 (setq data (cdr data))))))
3261
3262 (defmacro gnus-data-list (backward)
3263 `(if ,backward
3264 (or gnus-newsgroup-data-reverse
3265 (setq gnus-newsgroup-data-reverse
3266 (reverse gnus-newsgroup-data)))
3267 gnus-newsgroup-data))
3268
3269 (defun gnus-data-update-list (data offset)
3270 "Add OFFSET to the POS of all data entries in DATA."
3271 (setq gnus-newsgroup-data-reverse nil)
3272 (while data
3273 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3274 (setq data (cdr data))))
3275
3276 (defun gnus-summary-article-pseudo-p (article)
3277 "Say whether this article is a pseudo article or not."
3278 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3279
3280 (defmacro gnus-summary-article-sparse-p (article)
3281 "Say whether this article is a sparse article or not."
3282 `(memq ,article gnus-newsgroup-sparse))
3283
3284 (defmacro gnus-summary-article-ancient-p (article)
3285 "Say whether this article is a sparse article or not."
3286 `(memq ,article gnus-newsgroup-ancient))
3287
3288 (defun gnus-article-children (number)
3289 "Return a list of all children to NUMBER."
3290 (let* ((data (gnus-data-find-list number))
3291 (level (gnus-data-level (car data)))
3292 children)
3293 (setq data (cdr data))
3294 (while (and data
3295 (= (gnus-data-level (car data)) (1+ level)))
3296 (push (gnus-data-number (car data)) children)
3297 (setq data (cdr data)))
3298 children))
3299
3300 (defmacro gnus-summary-skip-intangible ()
3301 "If the current article is intangible, then jump to a different article."
3302 '(let ((to (get-text-property (point) 'gnus-intangible)))
3303 (and to (gnus-summary-goto-subject to))))
3304
3305 (defmacro gnus-summary-article-intangible-p ()
3306 "Say whether this article is intangible or not."
3307 '(get-text-property (point) 'gnus-intangible))
3308
3309 ;; Some summary mode macros.
3310
3311 (defmacro gnus-summary-article-number ()
3312 "The article number of the article on the current line.
3313 If there isn't an article number here, then we return the current
3314 article number."
3315 '(progn
3316 (gnus-summary-skip-intangible)
3317 (or (get-text-property (point) 'gnus-number)
3318 (gnus-summary-last-subject))))
3319
3320 (defmacro gnus-summary-article-header (&optional number)
3321 "Return the header of article NUMBER."
3322 `(gnus-data-header (gnus-data-find
3323 ,(or number '(gnus-summary-article-number)))))
3324
3325 (defmacro gnus-summary-thread-level (&optional number)
3326 "Return the level of thread that starts with article NUMBER."
3327 `(if (and (eq gnus-summary-make-false-root 'dummy)
3328 (get-text-property (point) 'gnus-intangible))
3329 0
3330 (gnus-data-level (gnus-data-find
3331 ,(or number '(gnus-summary-article-number))))))
3332
3333 (defmacro gnus-summary-article-mark (&optional number)
3334 "Return the mark of article NUMBER."
3335 `(gnus-data-mark (gnus-data-find
3336 ,(or number '(gnus-summary-article-number)))))
3337
3338 (defmacro gnus-summary-article-pos (&optional number)
3339 "Return the position of the line of article NUMBER."
3340 `(gnus-data-pos (gnus-data-find
3341 ,(or number '(gnus-summary-article-number)))))
3342
3343 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3344 (defmacro gnus-summary-article-subject (&optional number)
3345 "Return current subject string or nil if nothing."
3346 `(let ((headers
3347 ,(if number
3348 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3349 '(gnus-data-header (assq (gnus-summary-article-number)
3350 gnus-newsgroup-data)))))
3351 (and headers
3352 (vectorp headers)
3353 (mail-header-subject headers))))
3354
3355 (defmacro gnus-summary-article-score (&optional number)
3356 "Return current article score."
3357 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3358 gnus-newsgroup-scored))
3359 gnus-summary-default-score 0))
3360
3361 (defun gnus-summary-article-children (&optional number)
3362 "Return a list of article numbers that are children of article NUMBER."
3363 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3364 (level (gnus-data-level (car data)))
3365 l children)
3366 (while (and (setq data (cdr data))
3367 (> (setq l (gnus-data-level (car data))) level))
3368 (and (= (1+ level) l)
3369 (push (gnus-data-number (car data))
3370 children)))
3371 (nreverse children)))
3372
3373 (defun gnus-summary-article-parent (&optional number)
3374 "Return the article number of the parent of article NUMBER."
3375 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3376 (gnus-data-list t)))
3377 (level (gnus-data-level (car data))))
3378 (if (zerop level)
3379 () ; This is a root.
3380 ;; We search until we find an article with a level less than
3381 ;; this one. That function has to be the parent.
3382 (while (and (setq data (cdr data))
3383 (not (< (gnus-data-level (car data)) level))))
3384 (and data (gnus-data-number (car data))))))
3385
3386 (defun gnus-unread-mark-p (mark)
3387 "Say whether MARK is the unread mark."
3388 (= mark gnus-unread-mark))
3389
3390 (defun gnus-read-mark-p (mark)
3391 "Say whether MARK is one of the marks that mark as read.
3392 This is all marks except unread, ticked, dormant, and expirable."
3393 (not (or (= mark gnus-unread-mark)
3394 (= mark gnus-ticked-mark)
3395 (= mark gnus-spam-mark)
3396 (= mark gnus-dormant-mark)
3397 (= mark gnus-expirable-mark))))
3398
3399 (defmacro gnus-article-mark (number)
3400 "Return the MARK of article NUMBER.
3401 This macro should only be used when computing the mark the \"first\"
3402 time; i.e., when generating the summary lines. After that,
3403 `gnus-summary-article-mark' should be used to examine the
3404 marks of articles."
3405 `(cond
3406 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3407 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3408 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3409 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3410 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3411 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3412 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3413 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3414 gnus-ancient-mark))))
3415
3416 ;; Saving hidden threads.
3417
3418 (defmacro gnus-save-hidden-threads (&rest forms)
3419 "Save hidden threads, eval FORMS, and restore the hidden threads."
3420 (let ((config (make-symbol "config")))
3421 `(let ((,config (gnus-hidden-threads-configuration)))
3422 (unwind-protect
3423 (save-excursion
3424 ,@forms)
3425 (gnus-restore-hidden-threads-configuration ,config)))))
3426 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3427 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3428
3429 (defun gnus-data-compute-positions ()
3430 "Compute the positions of all articles."
3431 (setq gnus-newsgroup-data-reverse nil)
3432 (let ((data gnus-newsgroup-data))
3433 (save-excursion
3434 (gnus-save-hidden-threads
3435 (gnus-summary-show-all-threads)
3436 (goto-char (point-min))
3437 (while data
3438 (while (get-text-property (point) 'gnus-intangible)
3439 (forward-line 1))
3440 (gnus-data-set-pos (car data) (+ (point) 3))
3441 (setq data (cdr data))
3442 (forward-line 1))))))
3443
3444 (defun gnus-hidden-threads-configuration ()
3445 "Return the current hidden threads configuration."
3446 (save-excursion
3447 (let (config)
3448 (goto-char (point-min))
3449 (while (not (eobp))
3450 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3451 (push (save-excursion (forward-line 0) (point)) config))
3452 (forward-line 1))
3453 config)))
3454
3455 (defun gnus-restore-hidden-threads-configuration (config)
3456 "Restore hidden threads configuration from CONFIG."
3457 (save-excursion
3458 (let (point (inhibit-read-only t))
3459 (while (setq point (pop config))
3460 (goto-char point)
3461 (gnus-summary-hide-thread)))))
3462
3463 ;; Various summary mode internalish functions.
3464
3465 (defun gnus-mouse-pick-article (e)
3466 (interactive "e")
3467 (mouse-set-point e)
3468 (gnus-summary-next-page nil t))
3469
3470 (defun gnus-summary-set-display-table ()
3471 "Change the display table.
3472 Odd characters have a tendency to mess
3473 up nicely formatted displays - we make all possible glyphs
3474 display only a single character."
3475
3476 ;; We start from the standard display table, if any.
3477 (let ((table (or (copy-sequence standard-display-table)
3478 (make-display-table)))
3479 (i 32))
3480 ;; Nix out all the control chars...
3481 (while (>= (setq i (1- i)) 0)
3482 (gnus-put-display-table i [??] table))
3483 ;; ... but not newline and cr, of course. (cr is necessary for the
3484 ;; selective display).
3485 (gnus-put-display-table ?\n nil table)
3486 (gnus-put-display-table ?\r nil table)
3487 ;; We keep TAB as well.
3488 (gnus-put-display-table ?\t nil table)
3489 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3490 ;; Emacs 23 (unicode), that are not set already.
3491 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3492 160
3493 256)))
3494 (while (>= (setq i (1- i)) 127)
3495 ;; Only modify if the entry is nil.
3496 (unless (gnus-get-display-table i table)
3497 (gnus-put-display-table i [??] table))))
3498 (setq buffer-display-table table)))
3499
3500 (defun gnus-summary-set-article-display-arrow (pos)
3501 "Update the overlay arrow to point to line at position POS."
3502 (when gnus-summary-display-arrow
3503 (make-local-variable 'overlay-arrow-position)
3504 (make-local-variable 'overlay-arrow-string)
3505 (save-excursion
3506 (goto-char pos)
3507 (beginning-of-line)
3508 (unless overlay-arrow-position
3509 (setq overlay-arrow-position (make-marker)))
3510 (setq overlay-arrow-string "=>"
3511 overlay-arrow-position (set-marker overlay-arrow-position
3512 (point)
3513 (current-buffer))))))
3514
3515 (defun gnus-summary-setup-buffer (group)
3516 "Initialize summary buffer.
3517 If the setup was successful, non-nil is returned."
3518 (let ((buffer (gnus-summary-buffer-name group))
3519 (dead-name (concat "*Dead Summary "
3520 (gnus-group-decoded-name group) "*")))
3521 ;; If a dead summary buffer exists, we kill it.
3522 (when (gnus-buffer-live-p dead-name)
3523 (gnus-kill-buffer dead-name))
3524 (if (get-buffer buffer)
3525 (progn
3526 (set-buffer buffer)
3527 (setq gnus-summary-buffer (current-buffer))
3528 (not gnus-newsgroup-prepared))
3529 (set-buffer (gnus-get-buffer-create buffer))
3530 (setq gnus-summary-buffer (current-buffer))
3531 (gnus-summary-mode group)
3532 (when (gnus-group-quit-config group)
3533 (set (make-local-variable 'gnus-single-article-buffer) nil))
3534 (make-local-variable 'gnus-article-buffer)
3535 (make-local-variable 'gnus-article-current)
3536 (make-local-variable 'gnus-original-article-buffer)
3537 (setq gnus-newsgroup-name group)
3538 ;; Set any local variables in the group parameters.
3539 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3540 t)))
3541
3542 (defun gnus-set-global-variables ()
3543 "Set the global equivalents of the buffer-local variables.
3544 They are set to the latest values they had. These reflect the summary
3545 buffer that was in action when the last article was fetched."
3546 (when (derived-mode-p 'gnus-summary-mode)
3547 (setq gnus-summary-buffer (current-buffer))
3548 (let ((name gnus-newsgroup-name)
3549 (marked gnus-newsgroup-marked)
3550 (spam gnus-newsgroup-spam-marked)
3551 (unread gnus-newsgroup-unreads)
3552 (headers gnus-current-headers)
3553 (data gnus-newsgroup-data)
3554 (summary gnus-summary-buffer)
3555 (article-buffer gnus-article-buffer)
3556 (original gnus-original-article-buffer)
3557 (gac gnus-article-current)
3558 (reffed gnus-reffed-article-number)
3559 (score-file gnus-current-score-file)
3560 (default-charset gnus-newsgroup-charset)
3561 vlist)
3562 (let ((locals gnus-newsgroup-variables))
3563 (while locals
3564 (if (consp (car locals))
3565 (push (eval (caar locals)) vlist)
3566 (push (eval (car locals)) vlist))
3567 (setq locals (cdr locals)))
3568 (setq vlist (nreverse vlist)))
3569 (with-temp-buffer
3570 (setq gnus-newsgroup-name name
3571 gnus-newsgroup-marked marked
3572 gnus-newsgroup-spam-marked spam
3573 gnus-newsgroup-unreads unread
3574 gnus-current-headers headers
3575 gnus-newsgroup-data data
3576 gnus-article-current gac
3577 gnus-summary-buffer summary
3578 gnus-article-buffer article-buffer
3579 gnus-original-article-buffer original
3580 gnus-reffed-article-number reffed
3581 gnus-current-score-file score-file
3582 gnus-newsgroup-charset default-charset)
3583 (let ((locals gnus-newsgroup-variables))
3584 (while locals
3585 (if (consp (car locals))
3586 (set (caar locals) (pop vlist))
3587 (set (car locals) (pop vlist)))
3588 (setq locals (cdr locals))))))))
3589
3590 (defun gnus-summary-article-unread-p (article)
3591 "Say whether ARTICLE is unread or not."
3592 (memq article gnus-newsgroup-unreads))
3593
3594 (defun gnus-summary-first-article-p (&optional article)
3595 "Return whether ARTICLE is the first article in the buffer."
3596 (if (not (setq article (or article (gnus-summary-article-number))))
3597 nil
3598 (eq article (caar gnus-newsgroup-data))))
3599
3600 (defun gnus-summary-last-article-p (&optional article)
3601 "Return whether ARTICLE is the last article in the buffer."
3602 (if (not (setq article (or article (gnus-summary-article-number))))
3603 ;; All non-existent numbers are the last article. :-)
3604 t
3605 (not (cdr (gnus-data-find-list article)))))
3606
3607 (defun gnus-make-thread-indent-array (&optional n)
3608 (when (or n
3609 (progn (setq n 200) nil)
3610 (null gnus-thread-indent-array)
3611 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3612 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3613 gnus-thread-indent-array-level gnus-thread-indent-level)
3614 (while (>= n 0)
3615 (aset gnus-thread-indent-array n
3616 (make-string (* n gnus-thread-indent-level) ? ))
3617 (setq n (1- n)))))
3618
3619 (defun gnus-update-summary-mark-positions ()
3620 "Compute where the summary marks are to go."
3621 (save-excursion
3622 (when (gnus-buffer-exists-p gnus-summary-buffer)
3623 (set-buffer gnus-summary-buffer))
3624 (let ((spec gnus-summary-line-format-spec)
3625 pos)
3626 (save-excursion
3627 (gnus-set-work-buffer)
3628 (let ((gnus-tmp-unread ?Z)
3629 (gnus-replied-mark ?Z)
3630 (gnus-score-below-mark ?Z)
3631 (gnus-score-over-mark ?Z)
3632 (gnus-undownloaded-mark ?Z)
3633 (gnus-summary-line-format-spec spec)
3634 (gnus-newsgroup-downloadable '(0))
3635 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3636 case-fold-search ignores)
3637 ;; Here, all marks are bound to Z.
3638 (gnus-summary-insert-line header
3639 0 nil t gnus-tmp-unread t nil "" nil 1)
3640 (goto-char (point-min))
3641 ;; Memorize the positions of the same characters as dummy marks.
3642 (while (re-search-forward "[A-D]" nil t)
3643 (push (point) ignores))
3644 (erase-buffer)
3645 ;; We use A-D as dummy marks in order to know column positions
3646 ;; where marks should be inserted.
3647 (setq gnus-tmp-unread ?A
3648 gnus-replied-mark ?B
3649 gnus-score-below-mark ?C
3650 gnus-score-over-mark ?C
3651 gnus-undownloaded-mark ?D)
3652 (gnus-summary-insert-line header
3653 0 nil t gnus-tmp-unread t nil "" nil 1)
3654 ;; Ignore characters which aren't dummy marks.
3655 (dolist (p ignores)
3656 (delete-region (goto-char (1- p)) p)
3657 (insert ?Z))
3658 (goto-char (point-min))
3659 (setq pos (list (cons 'unread
3660 (and (search-forward "A" nil t)
3661 (- (point) (point-min) 1)))))
3662 (goto-char (point-min))
3663 (push (cons 'replied (and (search-forward "B" nil t)
3664 (- (point) (point-min) 1)))
3665 pos)
3666 (goto-char (point-min))
3667 (push (cons 'score (and (search-forward "C" nil t)
3668 (- (point) (point-min) 1)))
3669 pos)
3670 (goto-char (point-min))
3671 (push (cons 'download (and (search-forward "D" nil t)
3672 (- (point) (point-min) 1)))
3673 pos)))
3674 (setq gnus-summary-mark-positions pos))))
3675
3676 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3677 "Insert a dummy root in the summary buffer."
3678 (beginning-of-line)
3679 (gnus-add-text-properties
3680 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3681 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3682
3683 (defun gnus-summary-extract-address-component (from)
3684 (or (car (funcall gnus-extract-address-components from))
3685 from))
3686
3687 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3688 (let ((mail-parse-charset gnus-newsgroup-charset)
3689 (ignored-from-addresses (gnus-ignored-from-addresses))
3690 ;; Is it really necessary to do this next part for each summary line?
3691 ;; Luckily, doesn't seem to slow things down much.
3692 (mail-parse-ignored-charsets
3693 (with-current-buffer gnus-summary-buffer
3694 gnus-newsgroup-ignored-charsets)))
3695 (or
3696 (and ignored-from-addresses
3697 (string-match ignored-from-addresses gnus-tmp-from)
3698 (let ((extra-headers (mail-header-extra header))
3699 to
3700 newsgroups)
3701 (cond
3702 ((setq to (cdr (assq 'To extra-headers)))
3703 (concat gnus-summary-to-prefix
3704 (inline
3705 (gnus-summary-extract-address-component
3706 (funcall gnus-decode-encoded-address-function to)))))
3707 ((setq newsgroups
3708 (or
3709 (cdr (assq 'Newsgroups extra-headers))
3710 (and
3711 (memq 'Newsgroups gnus-extra-headers)
3712 (eq (car (gnus-find-method-for-group
3713 gnus-newsgroup-name)) 'nntp)
3714 (gnus-group-real-name gnus-newsgroup-name))))
3715 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3716 (gnus-string-mark-left-to-right
3717 (inline
3718 (gnus-summary-extract-address-component gnus-tmp-from))))))
3719
3720 (defun gnus-summary-insert-line (gnus-tmp-header
3721 gnus-tmp-level gnus-tmp-current
3722 undownloaded gnus-tmp-unread gnus-tmp-replied
3723 gnus-tmp-expirable gnus-tmp-subject-or-nil
3724 &optional gnus-tmp-dummy gnus-tmp-score
3725 gnus-tmp-process)
3726 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3727 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3728 gnus-tmp-level)))
3729 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3730 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3731 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3732 (gnus-tmp-score-char
3733 (if (or (null gnus-summary-default-score)
3734 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3735 gnus-summary-zcore-fuzz))
3736 ? ;Whitespace
3737 (if (< gnus-tmp-score gnus-summary-default-score)
3738 gnus-score-below-mark gnus-score-over-mark)))
3739 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3740 (gnus-tmp-replied
3741 (cond (gnus-tmp-process gnus-process-mark)
3742 ((memq gnus-tmp-current gnus-newsgroup-cached)
3743 gnus-cached-mark)
3744 (gnus-tmp-replied gnus-replied-mark)
3745 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3746 gnus-forwarded-mark)
3747 ((memq gnus-tmp-current gnus-newsgroup-saved)
3748 gnus-saved-mark)
3749 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3750 gnus-unseen-mark)
3751 (t gnus-no-mark)))
3752 (gnus-tmp-downloaded
3753 (cond (undownloaded
3754 gnus-undownloaded-mark)
3755 (gnus-newsgroup-agentized
3756 gnus-downloaded-mark)
3757 (t
3758 gnus-no-mark)))
3759 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3760 (gnus-tmp-name
3761 (cond
3762 ((string-match "<[^>]+> *$" gnus-tmp-from)
3763 (let ((beg (match-beginning 0)))
3764 (or (and (string-match "^\".+\"" gnus-tmp-from)
3765 (substring gnus-tmp-from 1 (1- (match-end 0))))
3766 (substring gnus-tmp-from 0 beg))))
3767 ((string-match "(.+)" gnus-tmp-from)
3768 (substring gnus-tmp-from
3769 (1+ (match-beginning 0)) (1- (match-end 0))))
3770 (t gnus-tmp-from)))
3771 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3772 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3773 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3774 (inhibit-read-only t))
3775 (when (string= gnus-tmp-name "")
3776 (setq gnus-tmp-name gnus-tmp-from))
3777 (unless (numberp gnus-tmp-lines)
3778 (setq gnus-tmp-lines -1))
3779 (if (= gnus-tmp-lines -1)
3780 (setq gnus-tmp-lines "?")
3781 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3782 (condition-case ()
3783 (gnus-put-text-property
3784 (point)
3785 (progn (eval gnus-summary-line-format-spec) (point))
3786 'gnus-number gnus-tmp-number)
3787 (error (gnus-message 5 "Error updating the summary line")))
3788 (when (gnus-visual-p 'summary-highlight 'highlight)
3789 (forward-line -1)
3790 (gnus-summary-highlight-line)
3791 (gnus-run-hooks 'gnus-summary-update-hook)
3792 (forward-line 1))))
3793
3794 (defun gnus-summary-update-line (&optional dont-update)
3795 "Update summary line after change."
3796 (when (and gnus-summary-default-score
3797 (not gnus-summary-inhibit-highlight))
3798 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3799 (article (gnus-summary-article-number))
3800 (score (gnus-summary-article-score article)))
3801 (unless dont-update
3802 (if (and gnus-summary-mark-below
3803 (< (gnus-summary-article-score)
3804 gnus-summary-mark-below))
3805 ;; This article has a low score, so we mark it as read.
3806 (when (memq article gnus-newsgroup-unreads)
3807 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3808 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3809 ;; This article was previously marked as read on account
3810 ;; of a low score, but now it has risen, so we mark it as
3811 ;; unread.
3812 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3813 (gnus-summary-update-mark
3814 (if (or (null gnus-summary-default-score)
3815 (<= (abs (- score gnus-summary-default-score))
3816 gnus-summary-zcore-fuzz))
3817 ? ;Whitespace
3818 (if (< score gnus-summary-default-score)
3819 gnus-score-below-mark gnus-score-over-mark))
3820 'score))
3821 ;; Do visual highlighting.
3822 (when (gnus-visual-p 'summary-highlight 'highlight)
3823 (gnus-summary-highlight-line)
3824 (gnus-run-hooks 'gnus-summary-update-hook)))))
3825
3826 (defvar gnus-tmp-new-adopts nil)
3827
3828 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3829 "Return the number of articles in THREAD.
3830 This may be 0 in some cases -- if none of the articles in
3831 the thread are to be displayed."
3832 (let* ((number
3833 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3834 (cond
3835 ((not (listp thread))
3836 1)
3837 ((and (consp thread) (cdr thread))
3838 (apply
3839 '+ 1 (mapcar
3840 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3841 ((null thread)
3842 1)
3843 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3844 1)
3845 (t 0))))
3846 (when (and level (zerop level) gnus-tmp-new-adopts)
3847 (incf number
3848 (apply '+ (mapcar
3849 'gnus-summary-number-of-articles-in-thread
3850 gnus-tmp-new-adopts))))
3851 (if char
3852 (if (> number 1) gnus-not-empty-thread-mark
3853 gnus-empty-thread-mark)
3854 number)))
3855
3856 (defsubst gnus-summary-line-message-size (head)
3857 "Return pretty-printed version of message size.
3858 This function is intended to be used in
3859 `gnus-summary-line-format-alist'."
3860 (let ((c (or (mail-header-chars head) -1)))
3861 (cond ((< c 0) "n/a") ; chars not available
3862 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3863 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3864 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3865 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3866
3867 (defcustom gnus-user-date-format-alist
3868 '(((gnus-seconds-today) . "Today, %H:%M")
3869 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3870 (604800 . "%A %H:%M") ; That's one week
3871 ((gnus-seconds-month) . "%A %d")
3872 ((gnus-seconds-year) . "%B %d")
3873 (t . "%b %d %Y")) ; This one is used when no other
3874 ; does match
3875 "Specifies date format depending on age of article.
3876 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3877 seconds) or a Lisp expression evaluating to a number. When the age of
3878 the article is less than this number, then use `format-time-string'
3879 with the corresponding FORMAT for displaying the date of the article.
3880 If AGE is not a number or a Lisp expression evaluating to a
3881 non-number, then the corresponding FORMAT is used as a default value.
3882
3883 Note that the list is processed from the beginning, so it should be
3884 sorted by ascending AGE. Also note that items following the first
3885 non-number AGE will be ignored.
3886
3887 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3888 and `gnus-seconds-year' in the AGE spec. They return the number of
3889 seconds passed since the start of today, of this month, of this year,
3890 respectively."
3891 :version "24.1"
3892 :group 'gnus-summary-format
3893 :type '(alist :key-type sexp :value-type string))
3894
3895 (defun gnus-user-date (messy-date)
3896 "Format the messy-date according to `gnus-user-date-format-alist'.
3897 Returns \" ? \" if there's bad input or if another error occurs.
3898 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3899 (condition-case ()
3900 (let* ((messy-date (gnus-float-time (gnus-date-get-time messy-date)))
3901 (now (gnus-float-time))
3902 ;;If we don't find something suitable we'll use this one
3903 (my-format "%b %d '%y"))
3904 (let* ((difference (- now messy-date))
3905 (templist gnus-user-date-format-alist)
3906 (top (eval (caar templist))))
3907 (while (if (numberp top) (< top difference) (not top))
3908 (progn
3909 (setq templist (cdr templist))
3910 (setq top (eval (caar templist)))))
3911 (if (stringp (cdr (car templist)))
3912 (setq my-format (cdr (car templist)))))
3913 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3914 (error " ? ")))
3915
3916 (defun gnus-summary-set-local-parameters (group)
3917 "Go through the local params of GROUP and set all variable specs in that list."
3918 (let ((vars '(quit-config active))) ; Ignore things that aren't
3919 ; really variables.
3920 (dolist (elem (gnus-group-find-parameter group))
3921 (and (consp elem) ; Has to be a cons.
3922 (consp (cdr elem)) ; The cdr has to be a list.
3923 (symbolp (car elem)) ; Has to be a symbol in there.
3924 (not (memq (car elem) vars))
3925 (ignore-errors
3926 (push (car elem) vars)
3927 ;; Variables like `gnus-show-threads' that are globally
3928 ;; bound, if used as group parameters, need to get to be
3929 ;; buffer-local, whereas just parameters like `gcc-self',
3930 ;; `timestamp', etc. should not be bound as variables.
3931 (if (boundp (car elem))
3932 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3933 (eval (nth 1 elem))))))))
3934
3935 (defun gnus-summary-read-group (group &optional show-all no-article
3936 kill-buffer no-display backward
3937 select-articles)
3938 "Start reading news in newsgroup GROUP.
3939 If SHOW-ALL is non-nil, already read articles are also listed.
3940 If NO-ARTICLE is non-nil, no article is selected initially.
3941 If NO-DISPLAY, don't generate the summary buffer contents.
3942 If KILL-BUFFER, it should be a buffer that's killed once the new
3943 summary buffer has been generated.
3944 If BACKWARD, move point to the previous group in the group buffer
3945 If SELECT-ARTICLES, only select those articles from GROUP."
3946 (let (result)
3947 (while (and group
3948 (null (setq result
3949 (let ((gnus-auto-select-next nil))
3950 (or (gnus-summary-read-group-1
3951 group show-all no-article
3952 kill-buffer no-display
3953 select-articles)
3954 (setq show-all nil
3955 select-articles nil)))))
3956 (eq gnus-auto-select-next 'quietly))
3957 (set-buffer gnus-group-buffer)
3958 ;; The entry function called above goes to the next
3959 ;; group automatically, so we go two groups back
3960 ;; if we are searching for the previous group.
3961 (when backward
3962 (gnus-group-prev-unread-group 2))
3963 (if (not (equal group (gnus-group-group-name)))
3964 (setq group (gnus-group-group-name))
3965 (setq group nil)))
3966 result))
3967
3968 (defun gnus-summary-read-group-1 (group show-all no-article
3969 kill-buffer no-display
3970 &optional select-articles)
3971 ;; Killed foreign groups can't be entered.
3972 ;; (when (and (not (gnus-group-native-p group))
3973 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3974 ;; (error "Dead non-native groups can't be entered"))
3975 (gnus-message 7 "Retrieving newsgroup: %s..."
3976 (gnus-group-decoded-name group))
3977 (let* ((new-group (gnus-summary-setup-buffer group))
3978 (quit-config (gnus-group-quit-config group))
3979 (did-select (and new-group (gnus-select-newsgroup
3980 group show-all select-articles))))
3981 (cond
3982 ;; This summary buffer exists already, so we just select it.
3983 ((not new-group)
3984 (gnus-set-global-variables)
3985 (when kill-buffer
3986 (gnus-kill-or-deaden-summary kill-buffer))
3987 (gnus-configure-windows 'summary 'force)
3988 (gnus-set-mode-line 'summary)
3989 (gnus-summary-position-point)
3990 (message "")
3991 t)
3992 ;; We couldn't select this group.
3993 ((null did-select)
3994 (when (and (derived-mode-p 'gnus-summary-mode)
3995 (not (equal (current-buffer) kill-buffer)))
3996 (kill-buffer (current-buffer))
3997 (if (not quit-config)
3998 (progn
3999 ;; Update the info -- marks might need to be removed,
4000 ;; for instance.
4001 (gnus-summary-update-info)
4002 (set-buffer gnus-group-buffer)
4003 (gnus-group-jump-to-group group)
4004 (gnus-group-next-unread-group 1))
4005 (gnus-handle-ephemeral-exit quit-config)))
4006 (if (null (gnus-list-of-unread-articles group))
4007 (gnus-message 3 "Group %s contains no messages"
4008 (gnus-group-decoded-name group))
4009 (gnus-message 3 "Can't select group"))
4010 nil)
4011 ;; The user did a `C-g' while prompting for number of articles,
4012 ;; so we exit this group.
4013 ((eq did-select 'quit)
4014 (and (derived-mode-p 'gnus-summary-mode)
4015 (not (equal (current-buffer) kill-buffer))
4016 (kill-buffer (current-buffer)))
4017 (when kill-buffer
4018 (gnus-kill-or-deaden-summary kill-buffer))
4019 (if (not quit-config)
4020 (progn
4021 (set-buffer gnus-group-buffer)
4022 (gnus-group-jump-to-group group)
4023 (gnus-configure-windows 'group 'force))
4024 (gnus-handle-ephemeral-exit quit-config))
4025 ;; Finally signal the quit.
4026 (signal 'quit nil))
4027 ;; The group was successfully selected.
4028 (t
4029 (gnus-set-global-variables)
4030 (when (boundp 'spam-install-hooks)
4031 (spam-initialize))
4032 ;; Save the active value in effect when the group was entered.
4033 (setq gnus-newsgroup-active
4034 (gnus-copy-sequence
4035 (gnus-active gnus-newsgroup-name)))
4036 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
4037 ;; You can change the summary buffer in some way with this hook.
4038 (gnus-run-hooks 'gnus-select-group-hook)
4039 (when (memq 'summary (gnus-update-format-specifications
4040 nil 'summary 'summary-mode 'summary-dummy))
4041 ;; The format specification for the summary line was updated,
4042 ;; so we need to update the mark positions as well.
4043 (gnus-update-summary-mark-positions))
4044 ;; Do score processing.
4045 (when gnus-use-scoring
4046 (gnus-possibly-score-headers))
4047 ;; Check whether to fill in the gaps in the threads.
4048 (when gnus-build-sparse-threads
4049 (gnus-build-sparse-threads))
4050 ;; Find the initial limit.
4051 (if show-all
4052 (let ((gnus-newsgroup-dormant nil))
4053 (gnus-summary-initial-limit show-all))
4054 (gnus-summary-initial-limit show-all))
4055 ;; Generate the summary buffer.
4056 (unless no-display
4057 (gnus-summary-prepare))
4058 (when gnus-use-trees
4059 (gnus-tree-open)
4060 (setq gnus-summary-highlight-line-function
4061 'gnus-tree-highlight-article))
4062 ;; If the summary buffer is empty, but there are some low-scored
4063 ;; articles or some excluded dormants, we include these in the
4064 ;; buffer.
4065 (when (and (zerop (buffer-size))
4066 (not no-display))
4067 (cond (gnus-newsgroup-dormant
4068 (gnus-summary-limit-include-dormant))
4069 ((and gnus-newsgroup-scored show-all)
4070 (gnus-summary-limit-include-expunged t))))
4071 ;; Function `gnus-apply-kill-file' must be called in this hook.
4072 (gnus-run-hooks 'gnus-apply-kill-hook)
4073 (if (and (zerop (buffer-size))
4074 (not no-display))
4075 (progn
4076 ;; This newsgroup is empty.
4077 (gnus-summary-catchup-and-exit nil t)
4078 (gnus-message 6 "No unread news")
4079 (when kill-buffer
4080 (gnus-kill-or-deaden-summary kill-buffer))
4081 ;; Return nil from this function.
4082 nil)
4083 ;; Hide conversation thread subtrees. We cannot do this in
4084 ;; gnus-summary-prepare-hook since kill processing may not
4085 ;; work with hidden articles.
4086 (gnus-summary-maybe-hide-threads)
4087 (gnus-configure-windows 'summary)
4088 (when kill-buffer
4089 (gnus-kill-or-deaden-summary kill-buffer))
4090 (gnus-summary-auto-select-subject)
4091 ;; Show first unread article if requested.
4092 (if (and (not no-article)
4093 (not no-display)
4094 gnus-newsgroup-unreads
4095 gnus-auto-select-first)
4096 (progn
4097 (let ((art (gnus-summary-article-number)))
4098 (when (and art
4099 gnus-plugged
4100 (not (memq art gnus-newsgroup-undownloaded))
4101 (not (memq art gnus-newsgroup-downloadable)))
4102 (gnus-summary-goto-article art))))
4103 ;; Don't select any articles.
4104 (gnus-summary-position-point)
4105 (gnus-configure-windows 'summary 'force)
4106 (gnus-set-mode-line 'summary))
4107 (when (and gnus-auto-center-group
4108 (get-buffer-window gnus-group-buffer t))
4109 ;; Gotta use windows, because recenter does weird stuff if
4110 ;; the current buffer ain't the displayed window.
4111 (let ((owin (selected-window)))
4112 (select-window (get-buffer-window gnus-group-buffer t))
4113 (when (gnus-group-goto-group group)
4114 (recenter))
4115 (select-window owin)))
4116 ;; Mark this buffer as "prepared".
4117 (setq gnus-newsgroup-prepared t)
4118 (gnus-run-hooks 'gnus-summary-prepared-hook)
4119 (unless (gnus-ephemeral-group-p group)
4120 (gnus-group-update-group group nil t))
4121 t)))))
4122
4123 (defun gnus-summary-auto-select-subject ()
4124 "Select the subject line on initial group entry."
4125 (goto-char (point-min))
4126 (cond
4127 ((eq gnus-auto-select-subject 'best)
4128 (gnus-summary-best-unread-subject))
4129 ((eq gnus-auto-select-subject 'unread)
4130 (gnus-summary-first-unread-subject))
4131 ((eq gnus-auto-select-subject 'unseen)
4132 (gnus-summary-first-unseen-subject))
4133 ((eq gnus-auto-select-subject 'unseen-or-unread)
4134 (gnus-summary-first-unseen-or-unread-subject))
4135 ((eq gnus-auto-select-subject 'first)
4136 ;; Do nothing.
4137 )
4138 ((functionp gnus-auto-select-subject)
4139 (funcall gnus-auto-select-subject))))
4140
4141 (defun gnus-summary-prepare ()
4142 "Generate the summary buffer."
4143 (interactive)
4144 (let ((inhibit-read-only t))
4145 (erase-buffer)
4146 (setq gnus-newsgroup-data nil
4147 gnus-newsgroup-data-reverse nil)
4148 (gnus-run-hooks 'gnus-summary-generate-hook)
4149 ;; Generate the buffer, either with threads or without.
4150 (when gnus-newsgroup-headers
4151 (gnus-summary-prepare-threads
4152 (if gnus-show-threads
4153 (gnus-sort-gathered-threads
4154 (funcall gnus-summary-thread-gathering-function
4155 (gnus-sort-threads
4156 (gnus-cut-threads (gnus-make-threads)))))
4157 ;; Unthreaded display.
4158 (gnus-sort-articles gnus-newsgroup-headers))))
4159 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4160 ;; Call hooks for modifying summary buffer.
4161 (goto-char (point-min))
4162 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4163
4164 (defsubst gnus-general-simplify-subject (subject)
4165 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4166 (setq subject
4167 (cond
4168 ;; Truncate the subject.
4169 (gnus-simplify-subject-functions
4170 (gnus-map-function gnus-simplify-subject-functions subject))
4171 ((numberp gnus-summary-gather-subject-limit)
4172 (setq subject (gnus-simplify-subject-re subject))
4173 (if (> (length subject) gnus-summary-gather-subject-limit)
4174 (substring subject 0 gnus-summary-gather-subject-limit)
4175 subject))
4176 ;; Fuzzily simplify it.
4177 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4178 (gnus-simplify-subject-fuzzy subject))
4179 ;; Just remove the leading "Re:".
4180 (t
4181 (gnus-simplify-subject-re subject))))
4182
4183 (if (and gnus-summary-gather-exclude-subject
4184 (string-match gnus-summary-gather-exclude-subject subject))
4185 nil ; This article shouldn't be gathered
4186 subject))
4187
4188 (defun gnus-summary-simplify-subject-query ()
4189 "Query where the respool algorithm would put this article."
4190 (interactive)
4191 (gnus-summary-select-article)
4192 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4193
4194 (defun gnus-gather-threads-by-subject (threads)
4195 "Gather threads by looking at Subject headers."
4196 (if (not gnus-summary-make-false-root)
4197 threads
4198 (let ((hashtb (gnus-make-hashtable 1024))
4199 (prev threads)
4200 (result threads)
4201 subject hthread whole-subject)
4202 (while threads
4203 (setq subject (gnus-general-simplify-subject
4204 (setq whole-subject (mail-header-subject
4205 (caar threads)))))
4206 (when subject
4207 (if (setq hthread (gnus-gethash subject hashtb))
4208 (progn
4209 ;; We enter a dummy root into the thread, if we
4210 ;; haven't done that already.
4211 (unless (stringp (caar hthread))
4212 (setcar hthread (list whole-subject (car hthread))))
4213 ;; We add this new gathered thread to this gathered
4214 ;; thread.
4215 (setcdr (car hthread)
4216 (nconc (cdar hthread) (list (car threads))))
4217 ;; Remove it from the list of threads.
4218 (setcdr prev (cdr threads))
4219 (setq threads prev))
4220 ;; Enter this thread into the hash table.
4221 (gnus-sethash subject
4222 (if gnus-summary-make-false-root-always
4223 (progn
4224 ;; If you want a dummy root above all
4225 ;; threads...
4226 (setcar threads (list whole-subject
4227 (car threads)))
4228 threads)
4229 threads)
4230 hashtb)))
4231 (setq prev threads)
4232 (setq threads (cdr threads)))
4233 result)))
4234
4235 (defun gnus-gather-threads-by-references (threads)
4236 "Gather threads by looking at References headers."
4237 (let ((idhashtb (gnus-make-hashtable 1024))
4238 (thhashtb (gnus-make-hashtable 1024))
4239 (prev threads)
4240 (result threads)
4241 ids references id gthread gid entered ref)
4242 (while threads
4243 (when (setq references (mail-header-references (caar threads)))
4244 (setq id (mail-header-id (caar threads))
4245 ids (inline (gnus-split-references references))
4246 entered nil)
4247 (while (setq ref (pop ids))
4248 (setq ids (delete ref ids))
4249 (if (not (setq gid (gnus-gethash ref idhashtb)))
4250 (progn
4251 (gnus-sethash ref id idhashtb)
4252 (gnus-sethash id threads thhashtb))
4253 (setq gthread (gnus-gethash gid thhashtb))
4254 (unless entered
4255 ;; We enter a dummy root into the thread, if we
4256 ;; haven't done that already.
4257 (unless (stringp (caar gthread))
4258 (setcar gthread (list (mail-header-subject (caar gthread))
4259 (car gthread))))
4260 ;; We add this new gathered thread to this gathered
4261 ;; thread.
4262 (setcdr (car gthread)
4263 (nconc (cdar gthread) (list (car threads)))))
4264 ;; Add it into the thread hash table.
4265 (gnus-sethash id gthread thhashtb)
4266 (setq entered t)
4267 ;; Remove it from the list of threads.
4268 (setcdr prev (cdr threads))
4269 (setq threads prev))))
4270 (setq prev threads)
4271 (setq threads (cdr threads)))
4272 result))
4273
4274 (defun gnus-sort-gathered-threads (threads)
4275 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4276 (let ((result threads))
4277 (while threads
4278 (when (stringp (caar threads))
4279 (setcdr (car threads)
4280 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4281 (setq threads (cdr threads)))
4282 result))
4283
4284 (defun gnus-thread-loop-p (root thread)
4285 "Say whether ROOT is in THREAD."
4286 (let ((stack (list thread))
4287 (infloop 0)
4288 th)
4289 (while (setq thread (pop stack))
4290 (setq th (cdr thread))
4291 (while (and th
4292 (not (eq (caar th) root)))
4293 (pop th))
4294 (if th
4295 ;; We have found a loop.
4296 (let (ref-dep)
4297 (setcdr thread (delq (car th) (cdr thread)))
4298 (if (boundp (setq ref-dep (intern "none"
4299 gnus-newsgroup-dependencies)))
4300 (setcdr (symbol-value ref-dep)
4301 (nconc (cdr (symbol-value ref-dep))
4302 (list (car th))))
4303 (set ref-dep (list nil (car th))))
4304 (setq infloop 1
4305 stack nil))
4306 ;; Push all the subthreads onto the stack.
4307 (push (cdr thread) stack)))
4308 infloop))
4309
4310 (defun gnus-make-threads ()
4311 "Go through the dependency hashtb and find the roots. Return all threads."
4312 (let (threads)
4313 (while (catch 'infloop
4314 (mapatoms
4315 (lambda (refs)
4316 ;; Deal with self-referencing References loops.
4317 (when (and (car (symbol-value refs))
4318 (not (zerop
4319 (apply
4320 '+
4321 (mapcar
4322 (lambda (thread)
4323 (gnus-thread-loop-p
4324 (car (symbol-value refs)) thread))
4325 (cdr (symbol-value refs)))))))
4326 (setq threads nil)
4327 (throw 'infloop t))
4328 (unless (car (symbol-value refs))
4329 ;; These threads do not refer back to any other
4330 ;; articles, so they're roots.
4331 (setq threads (append (cdr (symbol-value refs)) threads))))
4332 gnus-newsgroup-dependencies)))
4333 threads))
4334
4335 ;; Build the thread tree.
4336 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4337 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4338
4339 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4340 if it was already present.
4341
4342 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4343 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4344 Message-IDs will be renamed to a unique Message-ID before being
4345 entered.
4346
4347 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4348 (let* ((id (mail-header-id header))
4349 (id-dep (and id (intern id dependencies)))
4350 parent-id ref ref-dep ref-header replaced)
4351 ;; Enter this `header' in the `dependencies' table.
4352 (cond
4353 ((not id-dep)
4354 (setq header nil))
4355 ;; The first two cases do the normal part: enter a new `header'
4356 ;; in the `dependencies' table.
4357 ((not (boundp id-dep))
4358 (set id-dep (list header)))
4359 ((null (car (symbol-value id-dep)))
4360 (setcar (symbol-value id-dep) header))
4361
4362 ;; From here the `header' was already present in the
4363 ;; `dependencies' table.
4364 (force-new
4365 ;; Overrides an existing entry;
4366 ;; just set the header part of the entry.
4367 (setcar (symbol-value id-dep) header)
4368 (setq replaced t))
4369
4370 ;; Renames the existing `header' to a unique Message-ID.
4371 ((not gnus-summary-ignore-duplicates)
4372 ;; An article with this Message-ID has already been seen.
4373 ;; We rename the Message-ID.
4374 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4375 (list header))
4376 (mail-header-set-id header id))
4377
4378 ;; The last case ignores an existing entry, except it adds any
4379 ;; additional Xrefs (in case the two articles came from different
4380 ;; servers.
4381 ;; Also sets `header' to nil meaning that the `dependencies'
4382 ;; table was *not* modified.
4383 (t
4384 (mail-header-set-xref
4385 (car (symbol-value id-dep))
4386 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4387 "")
4388 (or (mail-header-xref header) "")))
4389 (setq header nil)))
4390
4391 (when (and header (not replaced))
4392 ;; First check that we are not creating a References loop.
4393 (setq parent-id (gnus-parent-id (mail-header-references header)))
4394 (setq ref parent-id)
4395 (while (and ref
4396 (setq ref-dep (intern-soft ref dependencies))
4397 (boundp ref-dep)
4398 (setq ref-header (car (symbol-value ref-dep))))
4399 (if (string= id ref)
4400 ;; Yuk! This is a reference loop. Make the article be a
4401 ;; root article.
4402 (progn
4403 (mail-header-set-references (car (symbol-value id-dep)) "none")
4404 (setq ref nil)
4405 (setq parent-id nil))
4406 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4407 (setq ref-dep (intern (or parent-id "none") dependencies))
4408 (if (boundp ref-dep)
4409 (setcdr (symbol-value ref-dep)
4410 (nconc (cdr (symbol-value ref-dep))
4411 (list (symbol-value id-dep))))
4412 (set ref-dep (list nil (symbol-value id-dep)))))
4413 header))
4414
4415 (defun gnus-extract-message-id-from-in-reply-to (string)
4416 (if (string-match "<[^>]+>" string)
4417 (substring string (match-beginning 0) (match-end 0))
4418 nil))
4419
4420 (defun gnus-build-sparse-threads ()
4421 (let ((headers gnus-newsgroup-headers)
4422 (mail-parse-charset gnus-newsgroup-charset)
4423 (gnus-summary-ignore-duplicates t)
4424 header references generation relations
4425 subject child end new-child date)
4426 ;; First we create an alist of generations/relations, where
4427 ;; generations is how much we trust the relation, and the relation
4428 ;; is parent/child.
4429 (gnus-message 7 "Making sparse threads...")
4430 (save-excursion
4431 (nnheader-set-temp-buffer " *gnus sparse threads*")
4432 (while (setq header (pop headers))
4433 (when (and (setq references (mail-header-references header))
4434 (not (string= references "")))
4435 (insert references)
4436 (setq child (mail-header-id header)
4437 subject (mail-header-subject header)
4438 date (mail-header-date header)
4439 generation 0)
4440 (while (search-backward ">" nil t)
4441 (setq end (1+ (point)))
4442 (when (search-backward "<" nil t)
4443 (setq new-child (buffer-substring (point) end))
4444 (push (list (incf generation)
4445 child (setq child new-child)
4446 subject date)
4447 relations)))
4448 (when child
4449 (push (list (1+ generation) child nil subject) relations))
4450 (erase-buffer)))
4451 (kill-buffer (current-buffer)))
4452 ;; Sort over trustworthiness.
4453 (dolist (relation (sort relations 'car-less-than-car))
4454 (when (gnus-dependencies-add-header
4455 (make-full-mail-header
4456 gnus-reffed-article-number
4457 (nth 3 relation) "" (or (nth 4 relation) "")
4458 (nth 1 relation)
4459 (or (nth 2 relation) "") 0 0 "")
4460 gnus-newsgroup-dependencies nil)
4461 (push gnus-reffed-article-number gnus-newsgroup-limit)
4462 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4463 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4464 gnus-newsgroup-reads)
4465 (decf gnus-reffed-article-number)))
4466 (gnus-message 7 "Making sparse threads...done")))
4467
4468 (defun gnus-build-old-threads ()
4469 ;; Look at all the articles that refer back to old articles, and
4470 ;; fetch the headers for the articles that aren't there. This will
4471 ;; build complete threads - if the roots haven't been expired by the
4472 ;; server, that is.
4473 (let ((mail-parse-charset gnus-newsgroup-charset)
4474 id heads)
4475 (mapatoms
4476 (lambda (refs)
4477 (when (not (car (symbol-value refs)))
4478 (setq heads (cdr (symbol-value refs)))
4479 (while heads
4480 (if (memq (mail-header-number (caar heads))
4481 gnus-newsgroup-dormant)
4482 (setq heads (cdr heads))
4483 (setq id (symbol-name refs))
4484 (while (and (setq id (gnus-build-get-header id))
4485 (not (car (gnus-id-to-thread id)))))
4486 (setq heads nil)))))
4487 gnus-newsgroup-dependencies)))
4488
4489 (defsubst gnus-remove-odd-characters (string)
4490 "Translate STRING into something that doesn't contain weird characters."
4491 (mm-subst-char-in-string
4492 ?\r ?\-
4493 (mm-subst-char-in-string ?\n ?\- string t) t))
4494
4495 ;; This function has to be called with point after the article number
4496 ;; on the beginning of the line.
4497 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4498 (let ((eol (point-at-eol))
4499 (buffer (current-buffer))
4500 header references in-reply-to)
4501
4502 ;; overview: [num subject from date id refs chars lines misc]
4503 (unwind-protect
4504 (let (x)
4505 (narrow-to-region (point) eol)
4506 (unless (eobp)
4507 (forward-char))
4508
4509 (setq header
4510 (make-full-mail-header
4511 number ; number
4512 (condition-case () ; subject
4513 (gnus-remove-odd-characters
4514 (funcall gnus-decode-encoded-word-function
4515 (setq x (nnheader-nov-field))))
4516 (error x))
4517 (condition-case () ; from
4518 (gnus-remove-odd-characters
4519 (funcall gnus-decode-encoded-address-function
4520 (setq x (nnheader-nov-field))))
4521 (error x))
4522 (nnheader-nov-field) ; date
4523 (nnheader-nov-read-message-id number) ; id
4524 (setq references (nnheader-nov-field)) ; refs
4525 (nnheader-nov-read-integer) ; chars
4526 (nnheader-nov-read-integer) ; lines
4527 (unless (eobp)
4528 (if (looking-at "Xref: ")
4529 (goto-char (match-end 0)))
4530 (nnheader-nov-field)) ; Xref
4531 (nnheader-nov-parse-extra)))) ; extra
4532
4533 (widen))
4534
4535 (when (and (string= references "")
4536 (setq in-reply-to (mail-header-extra header))
4537 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4538 (mail-header-set-references
4539 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4540
4541 (when gnus-alter-header-function
4542 (funcall gnus-alter-header-function header))
4543 (gnus-dependencies-add-header header dependencies force-new)))
4544
4545 (defun gnus-build-get-header (id)
4546 "Look through the buffer of NOV lines and find the header to ID.
4547 Enter this line into the dependencies hash table, and return
4548 the id of the parent article (if any)."
4549 (let ((deps gnus-newsgroup-dependencies)
4550 found header)
4551 (prog1
4552 (with-current-buffer nntp-server-buffer
4553 (let ((case-fold-search nil))
4554 (goto-char (point-min))
4555 (while (and (not found)
4556 (search-forward id nil t))
4557 (beginning-of-line)
4558 (setq found (looking-at
4559 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4560 (regexp-quote id))))
4561 (or found (beginning-of-line 2)))
4562 (when found
4563 (beginning-of-line)
4564 (and
4565 (setq header (gnus-nov-parse-line
4566 (read (current-buffer)) deps))
4567 (gnus-parent-id (mail-header-references header))))))
4568 (when header
4569 (let ((number (mail-header-number header)))
4570 (push number gnus-newsgroup-limit)
4571 (push header gnus-newsgroup-headers)
4572 (if (memq number gnus-newsgroup-unselected)
4573 (progn
4574 (setq gnus-newsgroup-unreads
4575 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4576 number))
4577 (setq gnus-newsgroup-unselected
4578 (delq number gnus-newsgroup-unselected)))
4579 (push number gnus-newsgroup-ancient)))))))
4580
4581 (defun gnus-build-all-threads ()
4582 "Read all the headers."
4583 (let ((gnus-summary-ignore-duplicates t)
4584 (mail-parse-charset gnus-newsgroup-charset)
4585 (dependencies gnus-newsgroup-dependencies)
4586 header article)
4587 (with-current-buffer nntp-server-buffer
4588 (let ((case-fold-search nil))
4589 (goto-char (point-min))
4590 (while (not (eobp))
4591 (ignore-errors
4592 (setq article (read (current-buffer))
4593 header (gnus-nov-parse-line article dependencies t)))
4594 (when header
4595 (with-current-buffer gnus-summary-buffer
4596 (push header gnus-newsgroup-headers)
4597 (if (memq (setq article (mail-header-number header))
4598 gnus-newsgroup-unselected)
4599 (progn
4600 (setq gnus-newsgroup-unreads
4601 (gnus-add-to-sorted-list
4602 gnus-newsgroup-unreads article))
4603 (setq gnus-newsgroup-unselected
4604 (delq article gnus-newsgroup-unselected)))
4605 (push article gnus-newsgroup-ancient)))
4606 (forward-line 1)))))))
4607
4608 (defun gnus-summary-update-article-line (article header)
4609 "Update the line for ARTICLE using HEADER."
4610 (let* ((id (mail-header-id header))
4611 (thread (gnus-id-to-thread id)))
4612 (unless thread
4613 (error "Article in no thread"))
4614 ;; Update the thread.
4615 (setcar thread header)
4616 (gnus-summary-goto-subject article)
4617 (let* ((datal (gnus-data-find-list article))
4618 (data (car datal))
4619 (inhibit-read-only t)
4620 (level (gnus-summary-thread-level)))
4621 (gnus-delete-line)
4622 (let ((inserted (- (point)
4623 (progn
4624 (gnus-summary-insert-line
4625 header level nil
4626 (memq article gnus-newsgroup-undownloaded)
4627 (gnus-article-mark article)
4628 (memq article gnus-newsgroup-replied)
4629 (memq article gnus-newsgroup-expirable)
4630 ;; Only insert the Subject string when it's different
4631 ;; from the previous Subject string.
4632 (if (and
4633 gnus-show-threads
4634 (gnus-subject-equal
4635 (condition-case ()
4636 (mail-header-subject
4637 (gnus-data-header
4638 (cadr
4639 (gnus-data-find-list
4640 article
4641 (gnus-data-list t)))))
4642 ;; Error on the side of excessive subjects.
4643 (error ""))
4644 (mail-header-subject header)))
4645 ""
4646 (mail-header-subject header))
4647 nil (cdr (assq article gnus-newsgroup-scored))
4648 (memq article gnus-newsgroup-processable))
4649 (point)))))
4650 (when (cdr datal)
4651 (gnus-data-update-list
4652 (cdr datal)
4653 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4654
4655 (defun gnus-summary-update-article (article &optional iheader)
4656 "Update ARTICLE in the summary buffer."
4657 (set-buffer gnus-summary-buffer)
4658 (let* ((header (gnus-summary-article-header article))
4659 (id (mail-header-id header))
4660 (data (gnus-data-find article))
4661 (thread (gnus-id-to-thread id))
4662 (references (mail-header-references header))
4663 (parent
4664 (gnus-id-to-thread
4665 (or (gnus-parent-id
4666 (when (and references
4667 (not (equal "" references)))
4668 references))
4669 "none")))
4670 (inhibit-read-only t)
4671 (old (car thread)))
4672 (when thread
4673 (unless iheader
4674 (setcar thread nil)
4675 (when parent
4676 (delq thread parent)))
4677 (if (gnus-summary-insert-subject id header)
4678 ;; Set the (possibly) new article number in the data structure.
4679 (gnus-data-set-number data (gnus-id-to-article id))
4680 (setcar thread old)
4681 nil))))
4682
4683 (defun gnus-rebuild-thread (id &optional line)
4684 "Rebuild the thread containing ID.
4685 If LINE, insert the rebuilt thread starting on line LINE."
4686 (let ((inhibit-read-only t)
4687 old-pos current thread data)
4688 (if (not gnus-show-threads)
4689 (setq thread (list (car (gnus-id-to-thread id))))
4690 ;; Get the thread this article is part of.
4691 (setq thread (gnus-remove-thread id)))
4692 (setq old-pos (point-at-bol))
4693 (setq current (save-excursion
4694 (and (re-search-backward "[\r\n]" nil t)
4695 (gnus-summary-article-number))))
4696 ;; If this is a gathered thread, we have to go some re-gathering.
4697 (when (stringp (car thread))
4698 (let ((subject (car thread))
4699 roots thr)
4700 (setq thread (cdr thread))
4701 (while thread
4702 (unless (memq (setq thr (gnus-id-to-thread
4703 (gnus-root-id
4704 (mail-header-id (caar thread)))))
4705 roots)
4706 (push thr roots))
4707 (setq thread (cdr thread)))
4708 ;; We now have all (unique) roots.
4709 (if (= (length roots) 1)
4710 ;; All the loose roots are now one solid root.
4711 (setq thread (car roots))
4712 (setq thread (cons subject (gnus-sort-threads roots))))))
4713 (let (threads)
4714 ;; We then insert this thread into the summary buffer.
4715 (when line
4716 (goto-char (point-min))
4717 (forward-line (1- line)))
4718 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4719 (if gnus-show-threads
4720 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4721 (gnus-summary-prepare-unthreaded thread))
4722 (setq data (nreverse gnus-newsgroup-data))
4723 (setq threads gnus-newsgroup-threads))
4724 ;; We splice the new data into the data structure.
4725 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4726 ;;!!! then we want to insert at the beginning of the buffer.
4727 ;;!!! That happens to be true with Gnus now, but that may
4728 ;;!!! change in the future. Perhaps.
4729 (gnus-data-enter-list
4730 (if line nil current) data (- (point) old-pos))
4731 (setq gnus-newsgroup-threads
4732 (nconc threads gnus-newsgroup-threads))
4733 (gnus-data-compute-positions))))
4734
4735 (defun gnus-number-to-header (number)
4736 "Return the header for article NUMBER."
4737 (let ((headers gnus-newsgroup-headers))
4738 (while (and headers
4739 (not (= number (mail-header-number (car headers)))))
4740 (pop headers))
4741 (when headers
4742 (car headers))))
4743
4744 (defun gnus-parent-headers (in-headers &optional generation)
4745 "Return the headers of the GENERATIONth parent of HEADERS."
4746 (unless generation
4747 (setq generation 1))
4748 (let ((parent t)
4749 (headers in-headers)
4750 references)
4751 (while (and parent
4752 (not (zerop generation))
4753 (setq references (mail-header-references headers)))
4754 (setq headers (if (and references
4755 (setq parent (gnus-parent-id references)))
4756 (car (gnus-id-to-thread parent))
4757 nil))
4758 (decf generation))
4759 (and (not (eq headers in-headers))
4760 headers)))
4761
4762 (defun gnus-id-to-thread (id)
4763 "Return the (sub-)thread where ID appears."
4764 (gnus-gethash id gnus-newsgroup-dependencies))
4765
4766 (defun gnus-id-to-article (id)
4767 "Return the article number of ID."
4768 (let ((thread (gnus-id-to-thread id)))
4769 (when (and thread
4770 (car thread))
4771 (mail-header-number (car thread)))))
4772
4773 (defun gnus-id-to-header (id)
4774 "Return the article headers of ID."
4775 (car (gnus-id-to-thread id)))
4776
4777 (defun gnus-article-displayed-root-p (article)
4778 "Say whether ARTICLE is a root(ish) article."
4779 (let ((level (gnus-summary-thread-level article))
4780 (refs (mail-header-references (gnus-summary-article-header article)))
4781 particle)
4782 (cond
4783 ((null level) nil)
4784 ((zerop level) t)
4785 ((null refs) t)
4786 ((null (gnus-parent-id refs)) t)
4787 ((and (= 1 level)
4788 (null (setq particle (gnus-id-to-article
4789 (gnus-parent-id refs))))
4790 (null (gnus-summary-thread-level particle)))))))
4791
4792 (defun gnus-root-id (id)
4793 "Return the id of the root of the thread where ID appears."
4794 (let (last-id prev)
4795 (while (and id (setq prev (car (gnus-id-to-thread id))))
4796 (setq last-id id
4797 id (gnus-parent-id (mail-header-references prev))))
4798 last-id))
4799
4800 (defun gnus-articles-in-thread (thread)
4801 "Return the list of articles in THREAD."
4802 (cons (mail-header-number (car thread))
4803 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4804
4805 (defun gnus-remove-thread (id &optional dont-remove)
4806 "Remove the thread that has ID in it."
4807 (let (headers thread last-id)
4808 ;; First go up in this thread until we find the root.
4809 (setq last-id (gnus-root-id id)
4810 headers (message-flatten-list (gnus-id-to-thread last-id)))
4811 ;; We have now found the real root of this thread. It might have
4812 ;; been gathered into some loose thread, so we have to search
4813 ;; through the threads to find the thread we wanted.
4814 (let ((threads gnus-newsgroup-threads)
4815 sub)
4816 (while threads
4817 (setq sub (car threads))
4818 (if (stringp (car sub))
4819 ;; This is a gathered thread, so we look at the roots
4820 ;; below it to find whether this article is in this
4821 ;; gathered root.
4822 (progn
4823 (setq sub (cdr sub))
4824 (while sub
4825 (when (member (caar sub) headers)
4826 (setq thread (car threads)
4827 threads nil
4828 sub nil))
4829 (setq sub (cdr sub))))
4830 ;; It's an ordinary thread, so we check it.
4831 (when (eq (car sub) (car headers))
4832 (setq thread sub
4833 threads nil)))
4834 (setq threads (cdr threads)))
4835 ;; If this article is in no thread, then it's a root.
4836 (if thread
4837 (unless dont-remove
4838 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4839 (setq thread (gnus-id-to-thread last-id)))
4840 (when thread
4841 (prog1
4842 thread ; We return this thread.
4843 (unless dont-remove
4844 (if (stringp (car thread))
4845 (progn
4846 ;; If we use dummy roots, then we have to remove the
4847 ;; dummy root as well.
4848 (when (eq gnus-summary-make-false-root 'dummy)
4849 ;; We go to the dummy root by going to
4850 ;; the first sub-"thread", and then one line up.
4851 (gnus-summary-goto-article
4852 (mail-header-number (caadr thread)))
4853 (forward-line -1)
4854 (gnus-delete-line)
4855 (gnus-data-compute-positions))
4856 (setq thread (cdr thread))
4857 (while thread
4858 (gnus-remove-thread-1 (car thread))
4859 (setq thread (cdr thread))))
4860 (gnus-remove-thread-1 thread))))))))
4861
4862 (defun gnus-remove-thread-1 (thread)
4863 "Remove the thread THREAD recursively."
4864 (let ((number (mail-header-number (pop thread)))
4865 d)
4866 (setq thread (reverse thread))
4867 (while thread
4868 (gnus-remove-thread-1 (pop thread)))
4869 (when (setq d (gnus-data-find number))
4870 (goto-char (gnus-data-pos d))
4871 (gnus-summary-show-thread)
4872 (gnus-data-remove
4873 number
4874 (- (point-at-bol)
4875 (prog1
4876 (1+ (point-at-eol))
4877 (gnus-delete-line)))))))
4878
4879 (defun gnus-sort-threads-recursive (threads func)
4880 ;; Responsible for sorting the root articles of threads.
4881 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4882 'gnus-thread-sort-functions)
4883 func
4884 (gnus-make-sort-function
4885 gnus-subthread-sort-functions))))
4886 (sort (mapcar (lambda (thread)
4887 (cons (car thread)
4888 (and (cdr thread)
4889 (gnus-sort-subthreads-recursive
4890 (cdr thread) subthread-sort-func))))
4891 threads) func)))
4892
4893 (defun gnus-sort-subthreads-recursive (threads func)
4894 ;; Responsible for sorting subthreads.
4895 (sort (mapcar (lambda (thread)
4896 (cons (car thread)
4897 (and (cdr thread)
4898 (gnus-sort-subthreads-recursive (cdr thread) func))))
4899 threads) func))
4900
4901 (defun gnus-sort-threads-loop (threads func)
4902 (let* ((superthread (cons nil threads))
4903 (stack (list (cons superthread threads)))
4904 remaining-threads thread)
4905 (while stack
4906 (setq remaining-threads (cdr (car stack)))
4907 (if remaining-threads
4908 (progn (setq thread (car remaining-threads))
4909 (setcdr (car stack) (cdr remaining-threads))
4910 (if (cdr thread)
4911 (push (cons thread (cdr thread)) stack)))
4912 (setq thread (caar stack))
4913 (setcdr thread (sort (cdr thread) func))
4914 (pop stack)))
4915 (cdr superthread)))
4916
4917 (defun gnus-sort-threads (threads)
4918 "Sort THREADS."
4919 (if (not gnus-thread-sort-functions)
4920 threads
4921 (gnus-message 8 "Sorting threads...")
4922 (prog1
4923 (condition-case nil
4924 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4925 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4926 (gnus-sort-threads-recursive threads sort-func))
4927 ;; Even after binding max-lisp-eval-depth, the recursive
4928 ;; sorter might fail for very long threads. In that case,
4929 ;; try using a (less well-tested) non-recursive sorter.
4930 (error (gnus-message 9 "Sorting threads with loop...")
4931 (gnus-sort-threads-loop
4932 threads (gnus-make-sort-function
4933 gnus-thread-sort-functions))))
4934 (gnus-message 8 "Sorting threads...done"))))
4935
4936 (defun gnus-sort-articles (articles)
4937 "Sort ARTICLES."
4938 (when gnus-article-sort-functions
4939 (gnus-message 7 "Sorting articles...")
4940 (prog1
4941 (setq gnus-newsgroup-headers
4942 (sort articles (gnus-make-sort-function
4943 gnus-article-sort-functions)))
4944 (gnus-message 7 "Sorting articles...done"))))
4945
4946 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4947 (defmacro gnus-thread-header (thread)
4948 "Return header of first article in THREAD.
4949 Note that THREAD must never, ever be anything else than a variable -
4950 using some other form will lead to serious barfage."
4951 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4952 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4953 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4954 (vector thread) 2))
4955
4956 (defsubst gnus-article-sort-by-number (h1 h2)
4957 "Sort articles by article number."
4958 (< (mail-header-number h1)
4959 (mail-header-number h2)))
4960
4961 (defun gnus-thread-sort-by-number (h1 h2)
4962 "Sort threads by root article number."
4963 (gnus-article-sort-by-number
4964 (gnus-thread-header h1) (gnus-thread-header h2)))
4965
4966 (defsubst gnus-article-sort-by-random (h1 h2)
4967 "Sort articles randomly."
4968 (zerop (random 2)))
4969
4970 (defun gnus-thread-sort-by-random (h1 h2)
4971 "Sort threads randomly."
4972 (gnus-article-sort-by-random
4973 (gnus-thread-header h1) (gnus-thread-header h2)))
4974
4975 (defsubst gnus-article-sort-by-lines (h1 h2)
4976 "Sort articles by article Lines header."
4977 (< (mail-header-lines h1)
4978 (mail-header-lines h2)))
4979
4980 (defun gnus-thread-sort-by-lines (h1 h2)
4981 "Sort threads by root article Lines header."
4982 (gnus-article-sort-by-lines
4983 (gnus-thread-header h1) (gnus-thread-header h2)))
4984
4985 (defsubst gnus-article-sort-by-chars (h1 h2)
4986 "Sort articles by octet length."
4987 (< (mail-header-chars h1)
4988 (mail-header-chars h2)))
4989
4990 (defun gnus-thread-sort-by-chars (h1 h2)
4991 "Sort threads by root article octet length."
4992 (gnus-article-sort-by-chars
4993 (gnus-thread-header h1) (gnus-thread-header h2)))
4994
4995 (defsubst gnus-article-sort-by-author (h1 h2)
4996 "Sort articles by root author."
4997 (gnus-string<
4998 (let ((extract (funcall
4999 gnus-extract-address-components
5000 (mail-header-from h1))))
5001 (or (car extract) (cadr extract) ""))
5002 (let ((extract (funcall
5003 gnus-extract-address-components
5004 (mail-header-from h2))))
5005 (or (car extract) (cadr extract) ""))))
5006
5007 (defun gnus-thread-sort-by-author (h1 h2)
5008 "Sort threads by root author."
5009 (gnus-article-sort-by-author
5010 (gnus-thread-header h1) (gnus-thread-header h2)))
5011
5012 (defsubst gnus-article-sort-by-recipient (h1 h2)
5013 "Sort articles by recipient."
5014 (gnus-string<
5015 (let ((extract (funcall
5016 gnus-extract-address-components
5017 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
5018 (or (car extract) (cadr extract)))
5019 (let ((extract (funcall
5020 gnus-extract-address-components
5021 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
5022 (or (car extract) (cadr extract)))))
5023
5024 (defun gnus-thread-sort-by-recipient (h1 h2)
5025 "Sort threads by root recipient."
5026 (gnus-article-sort-by-recipient
5027 (gnus-thread-header h1) (gnus-thread-header h2)))
5028
5029 (defsubst gnus-article-sort-by-subject (h1 h2)
5030 "Sort articles by root subject."
5031 (gnus-string<
5032 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
5033 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
5034
5035 (defun gnus-thread-sort-by-subject (h1 h2)
5036 "Sort threads by root subject."
5037 (gnus-article-sort-by-subject
5038 (gnus-thread-header h1) (gnus-thread-header h2)))
5039
5040 (defsubst gnus-article-sort-by-date (h1 h2)
5041 "Sort articles by root article date."
5042 (time-less-p
5043 (gnus-date-get-time (mail-header-date h1))
5044 (gnus-date-get-time (mail-header-date h2))))
5045
5046 (defun gnus-thread-sort-by-date (h1 h2)
5047 "Sort threads by root article date."
5048 (gnus-article-sort-by-date
5049 (gnus-thread-header h1) (gnus-thread-header h2)))
5050
5051 (defsubst gnus-article-sort-by-score (h1 h2)
5052 "Sort articles by root article score.
5053 Unscored articles will be counted as having a score of zero."
5054 (> (or (cdr (assq (mail-header-number h1)
5055 gnus-newsgroup-scored))
5056 gnus-summary-default-score 0)
5057 (or (cdr (assq (mail-header-number h2)
5058 gnus-newsgroup-scored))
5059 gnus-summary-default-score 0)))
5060
5061 (defun gnus-thread-sort-by-score (h1 h2)
5062 "Sort threads by root article score."
5063 (gnus-article-sort-by-score
5064 (gnus-thread-header h1) (gnus-thread-header h2)))
5065
5066 (defun gnus-thread-sort-by-total-score (h1 h2)
5067 "Sort threads by the sum of all scores in the thread.
5068 Unscored articles will be counted as having a score of zero."
5069 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5070
5071 (defun gnus-thread-total-score (thread)
5072 ;; This function find the total score of THREAD.
5073 (cond
5074 ((null thread)
5075 0)
5076 ((consp thread)
5077 (if (stringp (car thread))
5078 (apply gnus-thread-score-function 0
5079 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5080 (gnus-thread-total-score-1 thread)))
5081 (t
5082 (gnus-thread-total-score-1 (list thread)))))
5083
5084 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5085 "Sort articles by number."
5086 (gnus-article-sort-by-number h1 h2))
5087
5088 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5089 "Sort threads such that the thread with the most recently arrived article comes first."
5090 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5091
5092 (defun gnus-thread-highest-number (thread)
5093 "Return the highest article number in THREAD."
5094 (apply 'max (mapcar (lambda (header)
5095 (mail-header-number header))
5096 (message-flatten-list thread))))
5097
5098 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5099 "Sort articles by number."
5100 (gnus-article-sort-by-date h1 h2))
5101
5102 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5103 "Sort threads such that the thread with the most recently dated article comes first."
5104 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5105
5106 ; Since this is called not only to sort the top-level threads, but
5107 ; also in recursive sorts to order the articles within a thread, each
5108 ; article will be processed many times. Thus it speeds things up
5109 ; quite a bit to use gnus-date-get-time, which caches the time value.
5110 (defun gnus-thread-latest-date (thread)
5111 "Return the highest article date in THREAD."
5112 (apply 'max
5113 (mapcar (lambda (header) (gnus-float-time
5114 (gnus-date-get-time
5115 (mail-header-date header))))
5116 (message-flatten-list thread))))
5117
5118 (defun gnus-thread-total-score-1 (root)
5119 ;; This function find the total score of the thread below ROOT.
5120 (setq root (car root))
5121 (apply gnus-thread-score-function
5122 (or (append
5123 (mapcar 'gnus-thread-total-score
5124 (cdr (gnus-id-to-thread (mail-header-id root))))
5125 (when (> (mail-header-number root) 0)
5126 (list (or (cdr (assq (mail-header-number root)
5127 gnus-newsgroup-scored))
5128 gnus-summary-default-score 0))))
5129 (list gnus-summary-default-score)
5130 '(0))))
5131
5132 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5133 (defvar gnus-tmp-prev-subject nil)
5134 (defvar gnus-tmp-false-parent nil)
5135 (defvar gnus-tmp-root-expunged nil)
5136 (defvar gnus-tmp-dummy-line nil)
5137
5138 (defun gnus-extra-header (type &optional header)
5139 "Return the extra header of TYPE."
5140 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5141 ""))
5142
5143 (defvar gnus-tmp-thread-tree-header-string "")
5144
5145 (defcustom gnus-sum-thread-tree-root "> "
5146 "With %B spec, used for the root of a thread.
5147 If nil, use subject instead."
5148 :version "22.1"
5149 :type '(radio (const :format "%v " nil) string)
5150 :group 'gnus-thread)
5151
5152 (defcustom gnus-sum-thread-tree-false-root "> "
5153 "With %B spec, used for a false root of a thread.
5154 If nil, use subject instead."
5155 :version "22.1"
5156 :type '(radio (const :format "%v " nil) string)
5157 :group 'gnus-thread)
5158
5159 (defcustom gnus-sum-thread-tree-single-indent ""
5160 "With %B spec, used for a thread with just one message.
5161 If nil, use subject instead."
5162 :version "22.1"
5163 :type '(radio (const :format "%v " nil) string)
5164 :group 'gnus-thread)
5165
5166 (defcustom gnus-sum-thread-tree-vertical "| "
5167 "With %B spec, used for drawing a vertical line."
5168 :version "22.1"
5169 :type 'string
5170 :group 'gnus-thread)
5171
5172 (defcustom gnus-sum-thread-tree-indent " "
5173 "With %B spec, used for indenting."
5174 :version "22.1"
5175 :type 'string
5176 :group 'gnus-thread)
5177
5178 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5179 "With %B spec, used for a leaf with brothers."
5180 :version "22.1"
5181 :type 'string
5182 :group 'gnus-thread)
5183
5184 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5185 "With %B spec, used for a leaf without brothers."
5186 :version "22.1"
5187 :type 'string
5188 :group 'gnus-thread)
5189
5190 (defcustom gnus-summary-display-while-building nil
5191 "If non-nil, show and update the summary buffer as it's being built.
5192 If the value is t, update the buffer after every line is inserted. If
5193 the value is an integer (N), update the display every N lines."
5194 :version "22.1"
5195 :group 'gnus-thread
5196 :type '(choice (const :tag "off" nil)
5197 number
5198 (const :tag "frequently" t)))
5199
5200 (defun gnus-summary-prepare-threads (threads)
5201 "Prepare summary buffer from THREADS and indentation LEVEL.
5202 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5203 or a straight list of headers."
5204 (gnus-message 7 "Generating summary...")
5205
5206 (setq gnus-newsgroup-threads threads)
5207 (beginning-of-line)
5208
5209 (let ((gnus-tmp-level 0)
5210 (default-score (or gnus-summary-default-score 0))
5211 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5212 (building-line-count gnus-summary-display-while-building)
5213 (building-count (integerp gnus-summary-display-while-building))
5214 thread number subject stack state gnus-tmp-gathered beg-match
5215 new-roots gnus-tmp-new-adopts thread-end simp-subject
5216 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5217 gnus-tmp-replied gnus-tmp-subject-or-nil
5218 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5219 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5220 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5221 tree-stack)
5222
5223 (setq gnus-tmp-prev-subject nil
5224 gnus-tmp-thread-tree-header-string "")
5225
5226 (if (vectorp (car threads))
5227 ;; If this is a straight (sic) list of headers, then a
5228 ;; threaded summary display isn't required, so we just create
5229 ;; an unthreaded one.
5230 (gnus-summary-prepare-unthreaded threads)
5231
5232 ;; Do the threaded display.
5233
5234 (if gnus-summary-display-while-building
5235 (switch-to-buffer (buffer-name)))
5236 (while (or threads stack gnus-tmp-new-adopts new-roots)
5237
5238 (if (and (= gnus-tmp-level 0)
5239 (or (not stack)
5240 (= (caar stack) 0))
5241 (not gnus-tmp-false-parent)
5242 (or gnus-tmp-new-adopts new-roots))
5243 (if gnus-tmp-new-adopts
5244 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5245 thread (list (car gnus-tmp-new-adopts))
5246 gnus-tmp-header (caar thread)
5247 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5248 (when new-roots
5249 (setq thread (list (car new-roots))
5250 gnus-tmp-header (caar thread)
5251 new-roots (cdr new-roots))))
5252
5253 (if threads
5254 ;; If there are some threads, we do them before the
5255 ;; threads on the stack.
5256 (setq thread threads
5257 gnus-tmp-header (caar thread))
5258 ;; There were no current threads, so we pop something off
5259 ;; the stack.
5260 (setq state (car stack)
5261 gnus-tmp-level (car state)
5262 tree-stack (cadr state)
5263 thread (caddr state)
5264 stack (cdr stack)
5265 gnus-tmp-header (caar thread))))
5266
5267 (setq gnus-tmp-false-parent nil)
5268 (setq gnus-tmp-root-expunged nil)
5269 (setq thread-end nil)
5270
5271 (if (stringp gnus-tmp-header)
5272 ;; The header is a dummy root.
5273 (cond
5274 ((eq gnus-summary-make-false-root 'adopt)
5275 ;; We let the first article adopt the rest.
5276 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5277 (cddar thread)))
5278 (setq gnus-tmp-gathered
5279 (nconc (mapcar
5280 (lambda (h) (mail-header-number (car h)))
5281 (cddar thread))
5282 gnus-tmp-gathered))
5283 (setq thread (cons (list (caar thread)
5284 (cadar thread))
5285 (cdr thread)))
5286 (setq gnus-tmp-level -1
5287 gnus-tmp-false-parent t))
5288 ((eq gnus-summary-make-false-root 'empty)
5289 ;; We print adopted articles with empty subject fields.
5290 (setq gnus-tmp-gathered
5291 (nconc (mapcar
5292 (lambda (h) (mail-header-number (car h)))
5293 (cddar thread))
5294 gnus-tmp-gathered))
5295 (setq gnus-tmp-level -1))
5296 ((eq gnus-summary-make-false-root 'dummy)
5297 ;; We remember that we probably want to output a dummy
5298 ;; root.
5299 (setq gnus-tmp-dummy-line gnus-tmp-header)
5300 (setq gnus-tmp-prev-subject gnus-tmp-header))
5301 (t
5302 ;; We do not make a root for the gathered
5303 ;; sub-threads at all.
5304 (setq gnus-tmp-level -1)))
5305
5306 (setq number (mail-header-number gnus-tmp-header)
5307 subject (mail-header-subject gnus-tmp-header)
5308 simp-subject (gnus-simplify-subject-fully subject))
5309
5310 (cond
5311 ;; If the thread has changed subject, we might want to make
5312 ;; this subthread into a root.
5313 ((and (null gnus-thread-ignore-subject)
5314 (not (zerop gnus-tmp-level))
5315 gnus-tmp-prev-subject
5316 (not (string= gnus-tmp-prev-subject simp-subject)))
5317 (setq new-roots (nconc new-roots (list (car thread)))
5318 thread-end t
5319 gnus-tmp-header nil))
5320 ;; If the article lies outside the current limit,
5321 ;; then we do not display it.
5322 ((not (memq number gnus-newsgroup-limit))
5323 (setq gnus-tmp-gathered
5324 (nconc (mapcar
5325 (lambda (h) (mail-header-number (car h)))
5326 (cdar thread))
5327 gnus-tmp-gathered))
5328 (setq gnus-tmp-new-adopts (if (cdar thread)
5329 (append gnus-tmp-new-adopts
5330 (cdar thread))
5331 gnus-tmp-new-adopts)
5332 thread-end t
5333 gnus-tmp-header nil)
5334 (when (zerop gnus-tmp-level)
5335 (setq gnus-tmp-root-expunged t)))
5336 ;; Perhaps this article is to be marked as read?
5337 ((and gnus-summary-mark-below
5338 (< (or (cdr (assq number gnus-newsgroup-scored))
5339 default-score)
5340 gnus-summary-mark-below)
5341 ;; Don't touch sparse articles.
5342 (not (gnus-summary-article-sparse-p number))
5343 (not (gnus-summary-article-ancient-p number)))
5344 (setq gnus-newsgroup-unreads
5345 (delq number gnus-newsgroup-unreads))
5346 (if gnus-newsgroup-auto-expire
5347 (setq gnus-newsgroup-expirable
5348 (gnus-add-to-sorted-list
5349 gnus-newsgroup-expirable number))
5350 (push (cons number gnus-low-score-mark)
5351 gnus-newsgroup-reads))))
5352
5353 (when gnus-tmp-header
5354 ;; We may have an old dummy line to output before this
5355 ;; article.
5356 (when (and gnus-tmp-dummy-line
5357 (gnus-subject-equal
5358 gnus-tmp-dummy-line
5359 (mail-header-subject gnus-tmp-header)))
5360 (gnus-summary-insert-dummy-line
5361 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5362 (setq gnus-tmp-dummy-line nil))
5363
5364 ;; Compute the mark.
5365 (setq gnus-tmp-unread (gnus-article-mark number))
5366
5367 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5368 gnus-tmp-header gnus-tmp-level)
5369 gnus-newsgroup-data)
5370
5371 ;; Actually insert the line.
5372 (setq
5373 gnus-tmp-subject-or-nil
5374 (cond
5375 ((and gnus-thread-ignore-subject
5376 gnus-tmp-prev-subject
5377 (not (string= gnus-tmp-prev-subject simp-subject)))
5378 subject)
5379 ((zerop gnus-tmp-level)
5380 (if (and (eq gnus-summary-make-false-root 'empty)
5381 (memq number gnus-tmp-gathered)
5382 gnus-tmp-prev-subject
5383 (string= gnus-tmp-prev-subject simp-subject))
5384 gnus-summary-same-subject
5385 subject))
5386 (t gnus-summary-same-subject)))
5387 (if (and (eq gnus-summary-make-false-root 'adopt)
5388 (= gnus-tmp-level 1)
5389 (memq number gnus-tmp-gathered))
5390 (setq gnus-tmp-opening-bracket ?\<
5391 gnus-tmp-closing-bracket ?\>)
5392 (setq gnus-tmp-opening-bracket ?\[
5393 gnus-tmp-closing-bracket ?\]))
5394 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5395 (gnus-make-thread-indent-array
5396 (max (* 2 (length gnus-thread-indent-array))
5397 gnus-tmp-level)))
5398 (setq
5399 gnus-tmp-indentation
5400 (aref gnus-thread-indent-array gnus-tmp-level)
5401 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5402 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5403 gnus-summary-default-score 0)
5404 gnus-tmp-score-char
5405 (if (or (null gnus-summary-default-score)
5406 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5407 gnus-summary-zcore-fuzz))
5408 ? ;Whitespace
5409 (if (< gnus-tmp-score gnus-summary-default-score)
5410 gnus-score-below-mark gnus-score-over-mark))
5411 gnus-tmp-replied
5412 (cond ((memq number gnus-newsgroup-processable)
5413 gnus-process-mark)
5414 ((memq number gnus-newsgroup-cached)
5415 gnus-cached-mark)
5416 ((memq number gnus-newsgroup-replied)
5417 gnus-replied-mark)
5418 ((memq number gnus-newsgroup-forwarded)
5419 gnus-forwarded-mark)
5420 ((memq number gnus-newsgroup-saved)
5421 gnus-saved-mark)
5422 ((memq number gnus-newsgroup-unseen)
5423 gnus-unseen-mark)
5424 (t gnus-no-mark))
5425 gnus-tmp-downloaded
5426 (cond ((memq number gnus-newsgroup-undownloaded)
5427 gnus-undownloaded-mark)
5428 (gnus-newsgroup-agentized
5429 gnus-downloaded-mark)
5430 (t
5431 gnus-no-mark))
5432 gnus-tmp-from (mail-header-from gnus-tmp-header)
5433 gnus-tmp-name
5434 (cond
5435 ((string-match "<[^>]+> *$" gnus-tmp-from)
5436 (setq beg-match (match-beginning 0))
5437 (or (and (string-match "^\".+\"" gnus-tmp-from)
5438 (substring gnus-tmp-from 1 (1- (match-end 0))))
5439 (substring gnus-tmp-from 0 beg-match)))
5440 ((string-match "(.+)" gnus-tmp-from)
5441 (substring gnus-tmp-from
5442 (1+ (match-beginning 0)) (1- (match-end 0))))
5443 (t gnus-tmp-from))
5444
5445 ;; Do the %B string
5446 gnus-tmp-thread-tree-header-string
5447 (cond
5448 ((not gnus-show-threads) "")
5449 ((zerop gnus-tmp-level)
5450 (cond ((cdar thread)
5451 (or gnus-sum-thread-tree-root subject))
5452 (gnus-tmp-new-adopts
5453 (or gnus-sum-thread-tree-false-root subject))
5454 (t
5455 (or gnus-sum-thread-tree-single-indent subject))))
5456 (t
5457 (concat (apply 'concat
5458 (mapcar (lambda (item)
5459 (if (= item 1)
5460 gnus-sum-thread-tree-vertical
5461 gnus-sum-thread-tree-indent))
5462 (cdr (reverse tree-stack))))
5463 (if (nth 1 thread)
5464 gnus-sum-thread-tree-leaf-with-other
5465 gnus-sum-thread-tree-single-leaf)))))
5466 (when (string= gnus-tmp-name "")
5467 (setq gnus-tmp-name gnus-tmp-from))
5468 (unless (numberp gnus-tmp-lines)
5469 (setq gnus-tmp-lines -1))
5470 (if (= gnus-tmp-lines -1)
5471 (setq gnus-tmp-lines "?")
5472 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5473 (gnus-put-text-property
5474 (point)
5475 (progn (eval gnus-summary-line-format-spec) (point))
5476 'gnus-number number)
5477 (when gnus-visual-p
5478 (forward-line -1)
5479 (gnus-summary-highlight-line)
5480 (when gnus-summary-update-hook
5481 (gnus-run-hooks 'gnus-summary-update-hook))
5482 (forward-line 1))
5483
5484 (setq gnus-tmp-prev-subject simp-subject)))
5485
5486 (when (nth 1 thread)
5487 (push (list (max 0 gnus-tmp-level)
5488 (copy-sequence tree-stack)
5489 (nthcdr 1 thread))
5490 stack))
5491 (push (if (nth 1 thread) 1 0) tree-stack)
5492 (incf gnus-tmp-level)
5493 (setq threads (if thread-end nil (cdar thread)))
5494 (if gnus-summary-display-while-building
5495 (if building-count
5496 (progn
5497 ;; use a set frequency
5498 (setq building-line-count (1- building-line-count))
5499 (when (= building-line-count 0)
5500 (sit-for 0)
5501 (setq building-line-count
5502 gnus-summary-display-while-building)))
5503 ;; always
5504 (sit-for 0)))
5505 (unless threads
5506 (setq gnus-tmp-level 0)))))
5507 (gnus-message 7 "Generating summary...done"))
5508
5509 (defun gnus-summary-prepare-unthreaded (headers)
5510 "Generate an unthreaded summary buffer based on HEADERS."
5511 (let (header number mark)
5512
5513 (beginning-of-line)
5514
5515 (while headers
5516 ;; We may have to root out some bad articles...
5517 (when (memq (setq number (mail-header-number
5518 (setq header (pop headers))))
5519 gnus-newsgroup-limit)
5520 ;; Mark article as read when it has a low score.
5521 (when (and gnus-summary-mark-below
5522 (< (or (cdr (assq number gnus-newsgroup-scored))
5523 gnus-summary-default-score 0)
5524 gnus-summary-mark-below)
5525 (not (gnus-summary-article-ancient-p number)))
5526 (setq gnus-newsgroup-unreads
5527 (delq number gnus-newsgroup-unreads))
5528 (if gnus-newsgroup-auto-expire
5529 (push number gnus-newsgroup-expirable)
5530 (push (cons number gnus-low-score-mark)
5531 gnus-newsgroup-reads)))
5532
5533 (setq mark (gnus-article-mark number))
5534 (push (gnus-data-make number mark (1+ (point)) header 0)
5535 gnus-newsgroup-data)
5536 (gnus-summary-insert-line
5537 header 0 number
5538 (memq number gnus-newsgroup-undownloaded)
5539 mark (memq number gnus-newsgroup-replied)
5540 (memq number gnus-newsgroup-expirable)
5541 (mail-header-subject header) nil
5542 (cdr (assq number gnus-newsgroup-scored))
5543 (memq number gnus-newsgroup-processable))))))
5544
5545 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5546
5547 (defun gnus-group-get-list-identifiers (group)
5548 "Get list identifier regexp for GROUP."
5549 (or (gnus-parameter-list-identifier group)
5550 (if (consp gnus-list-identifiers)
5551 (mapconcat 'identity gnus-list-identifiers " *\\|")
5552 gnus-list-identifiers)))
5553
5554 (defun gnus-summary-remove-list-identifiers ()
5555 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5556 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5557 changed subject)
5558 (when regexp
5559 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5560 (dolist (header gnus-newsgroup-headers)
5561 (setq subject (mail-header-subject header)
5562 changed nil)
5563 (while (string-match regexp subject)
5564 (setq subject
5565 (concat (substring subject 0 (match-beginning 1))
5566 (substring subject (match-end 0)))
5567 changed t))
5568 (when changed
5569 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5570 (setq subject
5571 (concat (substring subject 0 (match-beginning 1))
5572 (substring subject (match-end 1)))))
5573 (mail-header-set-subject header subject))))))
5574
5575 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5576 "Fetch headers of ARTICLES."
5577 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5578 (gnus-message 7 "Fetching headers for %s..." name)
5579 (prog1
5580 (if (eq 'nov
5581 (setq gnus-headers-retrieved-by
5582 (gnus-retrieve-headers
5583 articles gnus-newsgroup-name
5584 (or limit
5585 ;; We might want to fetch old headers, but
5586 ;; not if there is only 1 article.
5587 (and (or (and
5588 (not (eq gnus-fetch-old-headers 'some))
5589 (not (numberp gnus-fetch-old-headers)))
5590 (> (length articles) 1))
5591 gnus-fetch-old-headers)))))
5592 (gnus-get-newsgroup-headers-xover
5593 articles force-new dependencies gnus-newsgroup-name t)
5594 (gnus-get-newsgroup-headers dependencies force-new))
5595 (gnus-message 7 "Fetching headers for %s...done" name))))
5596
5597 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5598 "Select newsgroup GROUP.
5599 If READ-ALL is non-nil, all articles in the group are selected.
5600 If SELECT-ARTICLES, only select those articles from GROUP."
5601 (let* ((entry (gnus-group-entry group))
5602 ;;!!! Dirty hack; should be removed.
5603 (gnus-summary-ignore-duplicates
5604 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5605 t
5606 gnus-summary-ignore-duplicates))
5607 (info (nth 2 entry))
5608 charset articles fetched-articles cached)
5609
5610 (unless (gnus-check-server
5611 (set (make-local-variable 'gnus-current-select-method)
5612 (gnus-find-method-for-group group)))
5613 (error "Couldn't open server"))
5614 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5615
5616 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5617 (gnus-activate-group group) ; Or we can activate it...
5618 (progn ; Or we bug out.
5619 (when (derived-mode-p 'gnus-summary-mode)
5620 (gnus-kill-buffer (current-buffer)))
5621 (error
5622 "Couldn't activate group %s: %s"
5623 (mm-decode-coding-string group charset)
5624 (mm-decode-coding-string (gnus-status-message group) charset))))
5625
5626 (unless (gnus-request-group group t nil (gnus-get-info group))
5627 (when (derived-mode-p 'gnus-summary-mode)
5628 (gnus-kill-buffer (current-buffer)))
5629 (error "Couldn't request group %s: %s"
5630 (mm-decode-coding-string group charset)
5631 (mm-decode-coding-string (gnus-status-message group) charset)))
5632
5633 (when (and gnus-agent
5634 (gnus-active group))
5635 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5636
5637 (setq gnus-summary-use-undownloaded-faces
5638 (gnus-agent-find-parameter
5639 group
5640 'agent-enable-undownloaded-faces)))
5641
5642 (setq gnus-newsgroup-name group
5643 gnus-newsgroup-unselected nil
5644 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5645
5646 (let ((display (gnus-group-find-parameter group 'display)))
5647 (setq gnus-newsgroup-display
5648 (cond
5649 ((not (zerop (or (car-safe read-all) 0)))
5650 ;; The user entered the group with C-u SPC/RET, let's show
5651 ;; all articles.
5652 'gnus-not-ignore)
5653 ((eq display 'all)
5654 'gnus-not-ignore)
5655 ((arrayp display)
5656 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5657 ((numberp display)
5658 ;; The following is probably the "correct" solution, but
5659 ;; it makes Gnus fetch all headers and then limit the
5660 ;; articles (which is slow), so instead we hack the
5661 ;; select-articles parameter instead. -- Simon Josefsson
5662 ;; <jas@kth.se>
5663 ;;
5664 ;; (gnus-byte-compile
5665 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5666 ;; display)))))
5667 (setq select-articles
5668 (gnus-uncompress-range
5669 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5670 (if (> tmp 0)
5671 tmp
5672 1))
5673 (cdr (gnus-active group)))))
5674 nil)
5675 (t
5676 nil))))
5677
5678 (gnus-summary-setup-default-charset)
5679
5680 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5681 (when (gnus-virtual-group-p group)
5682 (setq cached gnus-newsgroup-cached))
5683
5684 (setq gnus-newsgroup-unreads
5685 (gnus-sorted-ndifference
5686 (gnus-sorted-ndifference gnus-newsgroup-unreads
5687 gnus-newsgroup-marked)
5688 gnus-newsgroup-dormant))
5689
5690 (setq gnus-newsgroup-processable nil)
5691
5692 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5693
5694 ;; Adjust and set lists of article marks.
5695 (when info
5696 (gnus-adjust-marked-articles info))
5697 (if (setq articles select-articles)
5698 (setq gnus-newsgroup-unselected
5699 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5700 (setq articles (gnus-articles-to-read group read-all)))
5701
5702 (cond
5703 ((null articles)
5704 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5705 'quit)
5706 ((eq articles 0) nil)
5707 (t
5708 ;; Init the dependencies hash table.
5709 (setq gnus-newsgroup-dependencies
5710 (gnus-make-hashtable (length articles)))
5711 (if (gnus-buffer-live-p gnus-group-buffer)
5712 (gnus-set-global-variables)
5713 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5714 ;; Retrieve the headers and read them in.
5715
5716 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5717
5718 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5719 (when cached
5720 (setq gnus-newsgroup-cached cached))
5721
5722 ;; Suppress duplicates?
5723 (when gnus-suppress-duplicates
5724 (gnus-dup-suppress-articles))
5725
5726 ;; Set the initial limit.
5727 (setq gnus-newsgroup-limit (copy-sequence articles))
5728 ;; Remove canceled articles from the list of unread articles.
5729 (setq fetched-articles
5730 (mapcar (lambda (headers) (mail-header-number headers))
5731 gnus-newsgroup-headers))
5732 (setq gnus-newsgroup-articles fetched-articles)
5733 (setq gnus-newsgroup-unreads
5734 (gnus-sorted-nintersection
5735 gnus-newsgroup-unreads fetched-articles))
5736 (gnus-compute-unseen-list)
5737
5738 ;; Removed marked articles that do not exist.
5739 (gnus-update-missing-marks
5740 (gnus-sorted-difference articles fetched-articles))
5741 ;; We might want to build some more threads first.
5742 (when (and gnus-fetch-old-headers
5743 (eq gnus-headers-retrieved-by 'nov))
5744 (if (eq gnus-fetch-old-headers 'invisible)
5745 (gnus-build-all-threads)
5746 (gnus-build-old-threads)))
5747 ;; Let the Gnus agent mark articles as read.
5748 (when gnus-agent
5749 (gnus-agent-get-undownloaded-list))
5750 ;; Remove list identifiers from subject
5751 (gnus-summary-remove-list-identifiers)
5752 ;; Check whether auto-expire is to be done in this group.
5753 (setq gnus-newsgroup-auto-expire
5754 (and (gnus-group-auto-expirable-p group)
5755 (not (gnus-group-read-only-p group))))
5756 ;; Set up the article buffer now, if necessary.
5757 (unless (and gnus-single-article-buffer
5758 (equal gnus-article-buffer "*Article*"))
5759 (gnus-article-setup-buffer))
5760 ;; First and last article in this newsgroup.
5761 (when gnus-newsgroup-headers
5762 (setq gnus-newsgroup-begin
5763 (mail-header-number (car gnus-newsgroup-headers))
5764 gnus-newsgroup-end
5765 (mail-header-number
5766 (gnus-last-element gnus-newsgroup-headers))))
5767 ;; GROUP is successfully selected.
5768 (or gnus-newsgroup-headers t)))))
5769
5770 (defun gnus-compute-unseen-list ()
5771 ;; The `seen' marks are treated specially.
5772 (if (not gnus-newsgroup-seen)
5773 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5774 (setq gnus-newsgroup-unseen
5775 (gnus-inverse-list-range-intersection
5776 gnus-newsgroup-articles gnus-newsgroup-seen))))
5777
5778 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5779
5780 (defun gnus-summary-display-make-predicate (display)
5781 (require 'gnus-agent)
5782 (when (= (length display) 1)
5783 (setq display (car display)))
5784 (unless gnus-summary-display-cache
5785 (dolist (elem (append '((unread . unread)
5786 (read . read)
5787 (unseen . unseen))
5788 gnus-article-mark-lists))
5789 (push (cons (cdr elem)
5790 (gnus-byte-compile ;Why bother?
5791 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5792 gnus-summary-display-cache)))
5793 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5794 (gnus-category-predicate-cache gnus-summary-display-cache))
5795 (gnus-get-predicate display)))
5796
5797 ;; Uses the dynamically bound `gnus-number' variable.
5798 (defvar gnus-number)
5799 (defun gnus-article-marked-p (type &optional article)
5800 (let ((article (or article gnus-number)))
5801 (cond
5802 ((eq type 'tick)
5803 (memq article gnus-newsgroup-marked))
5804 ((eq type 'spam)
5805 (memq article gnus-newsgroup-spam-marked))
5806 ((eq type 'unsend)
5807 (memq article gnus-newsgroup-unsendable))
5808 ((eq type 'undownload)
5809 (memq article gnus-newsgroup-undownloaded))
5810 ((eq type 'download)
5811 (memq article gnus-newsgroup-downloadable))
5812 ((eq type 'unread)
5813 (memq article gnus-newsgroup-unreads))
5814 ((eq type 'read)
5815 (memq article gnus-newsgroup-reads))
5816 ((eq type 'dormant)
5817 (memq article gnus-newsgroup-dormant) )
5818 ((eq type 'expire)
5819 (memq article gnus-newsgroup-expirable))
5820 ((eq type 'reply)
5821 (memq article gnus-newsgroup-replied))
5822 ((eq type 'killed)
5823 (memq article gnus-newsgroup-killed))
5824 ((eq type 'bookmark)
5825 (assq article gnus-newsgroup-bookmarks))
5826 ((eq type 'score)
5827 (assq article gnus-newsgroup-scored))
5828 ((eq type 'save)
5829 (memq article gnus-newsgroup-saved))
5830 ((eq type 'cache)
5831 (memq article gnus-newsgroup-cached))
5832 ((eq type 'forward)
5833 (memq article gnus-newsgroup-forwarded))
5834 ((eq type 'seen)
5835 (not (memq article gnus-newsgroup-unseen)))
5836 (t t))))
5837
5838 (defun gnus-articles-to-read (group &optional read-all)
5839 "Find out what articles the user wants to read."
5840 (let* ((only-read-p t)
5841 (articles
5842 (gnus-list-range-difference
5843 ;; Select all articles if `read-all' is non-nil, or if there
5844 ;; are no unread articles.
5845 (if (or read-all
5846 (and (zerop (length gnus-newsgroup-marked))
5847 (zerop (length gnus-newsgroup-unreads)))
5848 ;; Fetch all if the predicate is non-nil.
5849 gnus-newsgroup-display)
5850 ;; We want to select the headers for all the articles in
5851 ;; the group, so we select either all the active
5852 ;; articles in the group, or (if that's nil), the
5853 ;; articles in the cache.
5854 (or
5855 (if gnus-newsgroup-maximum-articles
5856 (let ((active (gnus-active group)))
5857 (gnus-uncompress-range
5858 (cons (max (car active)
5859 (- (cdr active)
5860 gnus-newsgroup-maximum-articles
5861 -1))
5862 (cdr active))))
5863 (gnus-uncompress-range (gnus-active group)))
5864 (gnus-cache-articles-in-group group))
5865 ;; Select only the "normal" subset of articles.
5866 (setq only-read-p nil)
5867 (gnus-sorted-nunion
5868 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5869 gnus-newsgroup-unreads))
5870 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5871 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5872 (scored (length scored-list))
5873 (number (length articles))
5874 (marked (+ (length gnus-newsgroup-marked)
5875 (length gnus-newsgroup-dormant)))
5876 (select
5877 (cond
5878 ((numberp read-all)
5879 read-all)
5880 ((numberp gnus-newsgroup-display)
5881 gnus-newsgroup-display)
5882 (t
5883 (condition-case ()
5884 (cond
5885 ((and (or (<= scored marked) (= scored number))
5886 (numberp gnus-large-newsgroup)
5887 (> number gnus-large-newsgroup))
5888 (let* ((cursor-in-echo-area nil)
5889 (initial (gnus-parameter-large-newsgroup-initial
5890 gnus-newsgroup-name))
5891 (default (if only-read-p
5892 (or initial gnus-large-newsgroup)
5893 number))
5894 (input
5895 (read-string
5896 (if only-read-p
5897 (format
5898 "How many articles from %s (available %d, default %d): "
5899 (gnus-group-real-name
5900 (gnus-group-decoded-name gnus-newsgroup-name))
5901 number default)
5902 (format
5903 "How many articles from %s (%d default): "
5904 (gnus-group-real-name
5905 (gnus-group-decoded-name gnus-newsgroup-name))
5906 default))
5907 nil
5908 nil
5909 (number-to-string default))))
5910 (if (string-match "^[ \t]*$" input) number input)))
5911 ((and (> scored marked) (< scored number)
5912 (> (- scored number) 20))
5913 (let ((input
5914 (read-string
5915 (format "%s %s (%d scored, %d total): "
5916 "How many articles from"
5917 (gnus-group-decoded-name
5918 (gnus-group-real-name gnus-newsgroup-name))
5919 scored number))))
5920 (if (string-match "^[ \t]*$" input)
5921 number input)))
5922 (t number))
5923 (quit
5924 (message "Quit getting the articles to read")
5925 nil))))))
5926 (setq select (if (stringp select) (string-to-number select) select))
5927 (if (or (null select) (zerop select))
5928 select
5929 (if (and (not (zerop scored)) (<= (abs select) scored))
5930 (progn
5931 (setq articles (sort scored-list '<))
5932 (setq number (length articles)))
5933 (setq articles (copy-sequence articles)))
5934
5935 (when (< (abs select) number)
5936 (if (< select 0)
5937 ;; Select the N oldest articles.
5938 (setcdr (nthcdr (1- (abs select)) articles) nil)
5939 ;; Select the N most recent articles.
5940 (setq articles (nthcdr (- number select) articles))))
5941 (setq gnus-newsgroup-unselected
5942 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5943 (when gnus-alter-articles-to-read-function
5944 (setq articles
5945 (sort
5946 (funcall gnus-alter-articles-to-read-function
5947 gnus-newsgroup-name articles)
5948 '<)))
5949 articles)))
5950
5951 (defun gnus-killed-articles (killed articles)
5952 (let (out)
5953 (while articles
5954 (when (inline (gnus-member-of-range (car articles) killed))
5955 (push (car articles) out))
5956 (setq articles (cdr articles)))
5957 out))
5958
5959 (defun gnus-article-mark-to-type (mark)
5960 "Return the type of MARK."
5961 (or (cadr (assq mark gnus-article-special-mark-lists))
5962 'list))
5963
5964 (defun gnus-article-unpropagatable-p (mark)
5965 "Return whether MARK should be propagated to back end."
5966 (memq mark gnus-article-unpropagated-mark-lists))
5967
5968 (defun gnus-adjust-marked-articles (info)
5969 "Set all article lists and remove all marks that are no longer valid."
5970 (let* ((marked-lists (gnus-info-marks info))
5971 (active (gnus-active (gnus-info-group info)))
5972 (min (car active))
5973 (max (cdr active))
5974 (types gnus-article-mark-lists)
5975 marks var articles article mark mark-type
5976 bgn end)
5977 ;; Hack to avoid adjusting marks for imap.
5978 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5979 'nnimap)
5980 (setq min 1))
5981
5982 (dolist (marks marked-lists)
5983 (setq mark (car marks)
5984 mark-type (gnus-article-mark-to-type mark)
5985 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5986 ;; We set the variable according to the type of the marks list,
5987 ;; and then adjust the marks to a subset of the active articles.
5988 (cond
5989 ;; Adjust "simple" lists - compressed yet unsorted
5990 ((eq mark-type 'list)
5991 ;; Simultaneously uncompress and clip to active range
5992 ;; See gnus-uncompress-range for a description of possible marks
5993 (let (l lh)
5994 (if (not (cadr marks))
5995 (set var nil)
5996 (setq articles (if (numberp (cddr marks))
5997 (list (cdr marks))
5998 (cdr marks))
5999 lh (cons nil nil)
6000 l lh)
6001
6002 (while (setq article (pop articles))
6003 (cond ((consp article)
6004 (setq bgn (max (car article) min)
6005 end (min (cdr article) max))
6006 (while (<= bgn end)
6007 (setq l (setcdr l (cons bgn nil))
6008 bgn (1+ bgn))))
6009 ((and (<= min article)
6010 (>= max article))
6011 (setq l (setcdr l (cons article nil))))))
6012 (set var (cdr lh)))))
6013 ;; Adjust assocs.
6014 ((eq mark-type 'tuple)
6015 (set var (setq articles (cdr marks)))
6016 (when (not (listp (cdr (symbol-value var))))
6017 (set var (list (symbol-value var))))
6018 (when (not (listp (cdr articles)))
6019 (setq articles (list articles)))
6020 (while articles
6021 (when (or (not (consp (setq article (pop articles))))
6022 (< (car article) min)
6023 (> (car article) max))
6024 (set var (delq article (symbol-value var))))))
6025 ;; Adjust ranges (sloppily).
6026 ((eq mark-type 'range)
6027 (cond
6028 ((eq mark 'seen)
6029 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
6030 ;; It should be (seen (NUM1 . NUM2)).
6031 (when (numberp (cddr marks))
6032 (setcdr marks (list (cdr marks))))
6033 (setq articles (cdr marks))
6034 (while (and articles
6035 (or (and (consp (car articles))
6036 (> min (cdar articles)))
6037 (and (numberp (car articles))
6038 (> min (car articles)))))
6039 (pop articles))
6040 (set var articles))
6041 ((eq mark 'unexist)
6042 (set var (cdr marks)))))))))
6043
6044 (defun gnus-update-missing-marks (missing)
6045 "Go through the list of MISSING articles and remove them from the mark lists."
6046 (when missing
6047 (let (var m)
6048 ;; Go through all types.
6049 (dolist (elem gnus-article-mark-lists)
6050 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6051 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6052 (when (symbol-value var)
6053 ;; This list has articles. So we delete all missing
6054 ;; articles from it.
6055 (setq m missing)
6056 (while m
6057 (set var (delq (pop m) (symbol-value var))))))))))
6058
6059 (defun gnus-update-marks ()
6060 "Enter the various lists of marked articles into the newsgroup info list."
6061 (let ((types gnus-article-mark-lists)
6062 (info (gnus-get-info gnus-newsgroup-name))
6063 type list newmarked symbol delta-marks)
6064 (when info
6065 ;; Add all marks lists to the list of marks lists.
6066 (while (setq type (pop types))
6067 (setq list (symbol-value
6068 (setq symbol
6069 (intern (format "gnus-newsgroup-%s" (car type))))))
6070
6071 (when list
6072 ;; Get rid of the entries of the articles that have the
6073 ;; default score.
6074 (when (and (eq (cdr type) 'score)
6075 gnus-save-score
6076 list)
6077 (let* ((arts list)
6078 (prev (cons nil list))
6079 (all prev))
6080 (while arts
6081 (if (or (not (consp (car arts)))
6082 (= (cdar arts) gnus-summary-default-score))
6083 (setcdr prev (cdr arts))
6084 (setq prev arts))
6085 (setq arts (cdr arts)))
6086 (setq list (cdr all)))))
6087
6088 (when (eq (cdr type) 'seen)
6089 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6090
6091 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6092 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6093
6094 (when (and (gnus-check-backend-function
6095 'request-set-mark gnus-newsgroup-name)
6096 (not (gnus-article-unpropagatable-p (cdr type))))
6097 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6098 ;; Don't do anything about marks for articles we
6099 ;; didn't actually get any headers for.
6100 (del
6101 (gnus-list-range-intersection
6102 gnus-newsgroup-articles
6103 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6104 (add
6105 (gnus-list-range-intersection
6106 gnus-newsgroup-articles
6107 (gnus-remove-from-range
6108 (gnus-copy-sequence list) old))))
6109 (when add
6110 (push (list add 'add (list (cdr type))) delta-marks))
6111 (when del
6112 ;; Don't delete marks from outside the active range.
6113 ;; This shouldn't happen, but is a sanity check.
6114 (setq del (gnus-sorted-range-intersection
6115 (gnus-active gnus-newsgroup-name) del))
6116 (push (list del 'del (list (cdr type))) delta-marks))))
6117
6118 (when (or list
6119 (eq (cdr type) 'unexist))
6120 (push (cons (cdr type) list) newmarked)))
6121
6122 (when delta-marks
6123 (unless (gnus-check-group gnus-newsgroup-name)
6124 (error "Can't open server for %s" gnus-newsgroup-name))
6125 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6126
6127 ;; Enter these new marks into the info of the group.
6128 (if (nthcdr 3 info)
6129 (setcar (nthcdr 3 info) newmarked)
6130 ;; Add the marks lists to the end of the info.
6131 (when newmarked
6132 (setcdr (nthcdr 2 info) (list newmarked))))
6133
6134 ;; Cut off the end of the info if there's nothing else there.
6135 (let ((i 5))
6136 (while (and (> i 2)
6137 (not (nth i info)))
6138 (when (nthcdr (decf i) info)
6139 (setcdr (nthcdr i info) nil)))))))
6140
6141 (defun gnus-set-mode-line (where)
6142 "Set the mode line of the article or summary buffers.
6143 If WHERE is `summary', the summary mode line format will be used."
6144 ;; Is this mode line one we keep updated?
6145 (when (and (memq where gnus-updated-mode-lines)
6146 (symbol-value
6147 (intern (format "gnus-%s-mode-line-format-spec" where))))
6148 (let (mode-string)
6149 ;; We evaluate this in the summary buffer since these
6150 ;; variables are buffer-local to that buffer.
6151 (with-current-buffer gnus-summary-buffer
6152 ;; We bind all these variables that are used in the `eval' form
6153 ;; below.
6154 (let* ((mformat (symbol-value
6155 (intern
6156 (format "gnus-%s-mode-line-format-spec" where))))
6157 (gnus-tmp-group-name (gnus-mode-string-quote
6158 (gnus-group-decoded-name
6159 gnus-newsgroup-name)))
6160 (gnus-tmp-article-number (or gnus-current-article 0))
6161 (gnus-tmp-unread gnus-newsgroup-unreads)
6162 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6163 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6164 (gnus-tmp-unread-and-unselected
6165 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6166 (zerop gnus-tmp-unselected))
6167 "")
6168 ((zerop gnus-tmp-unselected)
6169 (format "{%d more}" gnus-tmp-unread-and-unticked))
6170 (t (format "{%d(+%d) more}"
6171 gnus-tmp-unread-and-unticked
6172 gnus-tmp-unselected))))
6173 (gnus-tmp-subject
6174 (if (and gnus-current-headers
6175 (vectorp gnus-current-headers))
6176 (gnus-mode-string-quote
6177 (mail-header-subject gnus-current-headers))
6178 ""))
6179 bufname-length max-len
6180 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6181 (setq mode-string (eval mformat))
6182 (setq bufname-length (if (string-match "%b" mode-string)
6183 (- (length
6184 (buffer-name
6185 (if (eq where 'summary)
6186 nil
6187 (get-buffer gnus-article-buffer))))
6188 2)
6189 0))
6190 (setq max-len (max 4 (if gnus-mode-non-string-length
6191 (- (window-width)
6192 gnus-mode-non-string-length
6193 bufname-length)
6194 (length mode-string))))
6195 ;; We might have to chop a bit of the string off...
6196 (when (> (length mode-string) max-len)
6197 (setq mode-string
6198 (concat (truncate-string-to-width mode-string (- max-len 3))
6199 "...")))))
6200 ;; Update the mode line.
6201 (setq mode-line-buffer-identification
6202 (gnus-mode-line-buffer-identification (list mode-string)))
6203 (set-buffer-modified-p t))))
6204
6205 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6206 "Go through the HEADERS list and add all Xrefs to a hash table.
6207 The resulting hash table is returned, or nil if no Xrefs were found."
6208 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6209 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6210 (xref-hashtb (gnus-make-hashtable))
6211 start group entry number xrefs header)
6212 (while headers
6213 (setq header (pop headers))
6214 (when (and (setq xrefs (mail-header-xref header))
6215 (not (memq (setq number (mail-header-number header))
6216 unreads)))
6217 (setq start 0)
6218 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6219 (setq start (match-end 0))
6220 (setq group (if prefix
6221 (concat prefix (substring xrefs (match-beginning 1)
6222 (match-end 1)))
6223 (substring xrefs (match-beginning 1) (match-end 1))))
6224 (setq number
6225 (string-to-number (substring xrefs (match-beginning 2)
6226 (match-end 2))))
6227 (if (setq entry (gnus-gethash group xref-hashtb))
6228 (setcdr entry (cons number (cdr entry)))
6229 (gnus-sethash group (cons number nil) xref-hashtb)))))
6230 (and start xref-hashtb)))
6231
6232 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6233 "Look through all the headers and mark the Xrefs as read."
6234 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6235 name info xref-hashtb idlist method nth4)
6236 (with-current-buffer gnus-group-buffer
6237 (when (setq xref-hashtb
6238 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6239 (mapatoms
6240 (lambda (group)
6241 (unless (string= from-newsgroup (setq name (symbol-name group)))
6242 (setq idlist (symbol-value group))
6243 ;; Dead groups are not updated.
6244 (and (prog1
6245 (setq info (gnus-get-info name))
6246 (when (stringp (setq nth4 (gnus-info-method info)))
6247 (setq nth4 (gnus-server-to-method nth4))))
6248 ;; Only do the xrefs if the group has the same
6249 ;; select method as the group we have just read.
6250 (or (gnus-methods-equal-p
6251 nth4 (gnus-find-method-for-group from-newsgroup))
6252 virtual
6253 (equal nth4 (setq method (gnus-find-method-for-group
6254 from-newsgroup)))
6255 (and (equal (car nth4) (car method))
6256 (equal (nth 1 nth4) (nth 1 method))))
6257 gnus-use-cross-reference
6258 (or (not (eq gnus-use-cross-reference t))
6259 virtual
6260 ;; Only do cross-references on subscribed
6261 ;; groups, if that is what is wanted.
6262 (<= (gnus-info-level info) gnus-level-subscribed))
6263 (gnus-group-make-articles-read name idlist))))
6264 xref-hashtb)))))
6265
6266 (defun gnus-compute-read-articles (group articles)
6267 (let* ((entry (gnus-group-entry group))
6268 (info (nth 2 entry))
6269 (active (gnus-active group))
6270 ninfo)
6271 (when entry
6272 ;; First peel off all invalid article numbers.
6273 (when active
6274 (let ((ids articles)
6275 id first)
6276 (while (setq id (pop ids))
6277 (when (and first (> id (cdr active)))
6278 ;; We'll end up in this situation in one particular
6279 ;; obscure situation. If you re-scan a group and get
6280 ;; a new article that is cross-posted to a different
6281 ;; group that has not been re-scanned, you might get
6282 ;; crossposted article that has a higher number than
6283 ;; Gnus believes possible. So we re-activate this
6284 ;; group as well. This might mean doing the
6285 ;; crossposting thingy will *increase* the number
6286 ;; of articles in some groups. Tsk, tsk.
6287 (setq active (or (gnus-activate-group group) active)))
6288 (when (or (> id (cdr active))
6289 (< id (car active)))
6290 (setq articles (delq id articles))))))
6291 ;; If the read list is nil, we init it.
6292 (if (and active
6293 (null (gnus-info-read info))
6294 (> (car active) 1))
6295 (setq ninfo (cons 1 (1- (car active))))
6296 (setq ninfo (gnus-info-read info)))
6297 ;; Then we add the read articles to the range.
6298 (gnus-add-to-range
6299 ninfo (setq articles (sort articles '<))))))
6300
6301 (defun gnus-group-make-articles-read (group articles)
6302 "Update the info of GROUP to say that ARTICLES are read."
6303 (let* ((num 0)
6304 (entry (gnus-group-entry group))
6305 (info (nth 2 entry))
6306 (active (gnus-active group))
6307 (set-marks
6308 (gnus-method-option-p
6309 (gnus-find-method-for-group group)
6310 'server-marks))
6311 range)
6312 (if (not entry)
6313 ;; Group that Gnus doesn't know exists, but still allow the
6314 ;; backend to set marks.
6315 (when set-marks
6316 (gnus-request-set-mark
6317 group (list (list (gnus-compress-sequence (sort articles #'<))
6318 'add '(read)))))
6319 ;; Normal, subscribed groups.
6320 (setq range (gnus-compute-read-articles group articles))
6321 (with-current-buffer gnus-group-buffer
6322 (gnus-undo-register
6323 `(progn
6324 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6325 (gnus-info-set-read ',info ',(gnus-info-read info))
6326 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6327 (when ,set-marks
6328 (gnus-request-set-mark
6329 ,group (list (list ',range 'del '(read)))))
6330 (gnus-group-update-group ,group t))))
6331 ;; Add the read articles to the range.
6332 (gnus-info-set-read info range)
6333 (when set-marks
6334 (gnus-request-set-mark group (list (list range 'add '(read)))))
6335 ;; Then we have to re-compute how many unread
6336 ;; articles there are in this group.
6337 (when active
6338 (cond
6339 ((not range)
6340 (setq num (- (1+ (cdr active)) (car active))))
6341 ((not (listp (cdr range)))
6342 (setq num (- (cdr active) (- (1+ (cdr range))
6343 (car range)))))
6344 (t
6345 (while range
6346 (if (numberp (car range))
6347 (setq num (1+ num))
6348 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6349 (setq range (cdr range)))
6350 (setq num (- (cdr active) num))))
6351 ;; Update the number of unread articles.
6352 (setcar entry num)
6353 ;; Update the group buffer.
6354 (unless (gnus-ephemeral-group-p group)
6355 (gnus-group-update-group group t))))))
6356
6357 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6358 (let ((cur nntp-server-buffer)
6359 (dependencies
6360 (or dependencies
6361 (with-current-buffer gnus-summary-buffer
6362 gnus-newsgroup-dependencies)))
6363 headers id end ref number
6364 (mail-parse-charset gnus-newsgroup-charset)
6365 (mail-parse-ignored-charsets
6366 (save-current-buffer (condition-case nil
6367 (set-buffer gnus-summary-buffer)
6368 (error))
6369 gnus-newsgroup-ignored-charsets)))
6370 (with-current-buffer nntp-server-buffer
6371 ;; Translate all TAB characters into SPACE characters.
6372 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6373 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6374 (ietf-drums-unfold-fws)
6375 (gnus-run-hooks 'gnus-parse-headers-hook)
6376 (let ((case-fold-search t)
6377 in-reply-to header p lines chars)
6378 (goto-char (point-min))
6379 ;; Search to the beginning of the next header. Error messages
6380 ;; do not begin with 2 or 3.
6381 (while (re-search-forward "^[23][0-9]+ " nil t)
6382 (setq id nil
6383 ref nil)
6384 ;; This implementation of this function, with nine
6385 ;; search-forwards instead of the one re-search-forward and
6386 ;; a case (which basically was the old function) is actually
6387 ;; about twice as fast, even though it looks messier. You
6388 ;; can't have everything, I guess. Speed and elegance
6389 ;; doesn't always go hand in hand.
6390 (setq
6391 header
6392 (vector
6393 ;; Number.
6394 (prog1
6395 (setq number (read cur))
6396 (end-of-line)
6397 (setq p (point))
6398 (narrow-to-region (point)
6399 (or (and (search-forward "\n.\n" nil t)
6400 (- (point) 2))
6401 (point))))
6402 ;; Subject.
6403 (progn
6404 (goto-char p)
6405 (if (search-forward "\nsubject:" nil t)
6406 (funcall gnus-decode-encoded-word-function
6407 (nnheader-header-value))
6408 "(none)"))
6409 ;; From.
6410 (progn
6411 (goto-char p)
6412 (if (search-forward "\nfrom:" nil t)
6413 (funcall gnus-decode-encoded-address-function
6414 (nnheader-header-value))
6415 "(nobody)"))
6416 ;; Date.
6417 (progn
6418 (goto-char p)
6419 (if (search-forward "\ndate:" nil t)
6420 (nnheader-header-value) ""))
6421 ;; Message-ID.
6422 (progn
6423 (goto-char p)
6424 (setq id (if (re-search-forward
6425 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6426 ;; We do it this way to make sure the Message-ID
6427 ;; is (somewhat) syntactically valid.
6428 (buffer-substring (match-beginning 1)
6429 (match-end 1))
6430 ;; If there was no message-id, we just fake one
6431 ;; to make subsequent routines simpler.
6432 (nnheader-generate-fake-message-id number))))
6433 ;; References.
6434 (progn
6435 (goto-char p)
6436 (if (search-forward "\nreferences:" nil t)
6437 (progn
6438 (setq end (point))
6439 (prog1
6440 (nnheader-header-value)
6441 (setq ref
6442 (buffer-substring
6443 (progn
6444 (end-of-line)
6445 (search-backward ">" end t)
6446 (1+ (point)))
6447 (progn
6448 (search-backward "<" end t)
6449 (point))))))
6450 ;; Get the references from the in-reply-to header if there
6451 ;; were no references and the in-reply-to header looks
6452 ;; promising.
6453 (if (and (search-forward "\nin-reply-to:" nil t)
6454 (setq in-reply-to (nnheader-header-value))
6455 (string-match "<[^>]+>" in-reply-to))
6456 (let (ref2)
6457 (setq ref (substring in-reply-to (match-beginning 0)
6458 (match-end 0)))
6459 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6460 (setq ref2 (substring in-reply-to (match-beginning 0)
6461 (match-end 0)))
6462 (when (> (length ref2) (length ref))
6463 (setq ref ref2)))
6464 ref)
6465 (setq ref nil))))
6466 ;; Chars.
6467 (progn
6468 (goto-char p)
6469 (if (search-forward "\nchars: " nil t)
6470 (if (numberp (setq chars (ignore-errors (read cur))))
6471 chars -1)
6472 -1))
6473 ;; Lines.
6474 (progn
6475 (goto-char p)
6476 (if (search-forward "\nlines: " nil t)
6477 (if (numberp (setq lines (ignore-errors (read cur))))
6478 lines -1)
6479 -1))
6480 ;; Xref.
6481 (progn
6482 (goto-char p)
6483 (and (search-forward "\nxref:" nil t)
6484 (nnheader-header-value)))
6485 ;; Extra.
6486 (when gnus-extra-headers
6487 (let ((extra gnus-extra-headers)
6488 out)
6489 (while extra
6490 (goto-char p)
6491 (when (search-forward
6492 (concat "\n" (symbol-name (car extra)) ":") nil t)
6493 (push (cons (car extra) (nnheader-header-value))
6494 out))
6495 (pop extra))
6496 out))))
6497 (when (equal id ref)
6498 (setq ref nil))
6499
6500 (when gnus-alter-header-function
6501 (funcall gnus-alter-header-function header)
6502 (setq id (mail-header-id header)
6503 ref (gnus-parent-id (mail-header-references header))))
6504
6505 (when (setq header
6506 (gnus-dependencies-add-header
6507 header dependencies force-new))
6508 (push header headers))
6509 (goto-char (point-max))
6510 (widen))
6511 (nreverse headers)))))
6512
6513 ;; Goes through the xover lines and returns a list of vectors
6514 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6515 force-new dependencies
6516 group also-fetch-heads)
6517 "Parse the news overview data in the server buffer.
6518 Return a list of headers that match SEQUENCE (see
6519 `nntp-retrieve-headers')."
6520 ;; Get the Xref when the users reads the articles since most/some
6521 ;; NNTP servers do not include Xrefs when using XOVER.
6522 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6523 (let ((mail-parse-charset gnus-newsgroup-charset)
6524 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6525 (cur nntp-server-buffer)
6526 (dependencies (or dependencies gnus-newsgroup-dependencies))
6527 (allp (cond
6528 ((eq gnus-read-all-available-headers t)
6529 t)
6530 ((and (stringp gnus-read-all-available-headers)
6531 group)
6532 (string-match gnus-read-all-available-headers group))
6533 (t
6534 nil)))
6535 number headers header)
6536 (with-current-buffer nntp-server-buffer
6537 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6538 ;; Allow the user to mangle the headers before parsing them.
6539 (gnus-run-hooks 'gnus-parse-headers-hook)
6540 (goto-char (point-min))
6541 (gnus-parse-without-error
6542 (while (and (or sequence allp)
6543 (not (eobp)))
6544 (setq number (read cur))
6545 (when (not allp)
6546 (while (and sequence
6547 (< (car sequence) number))
6548 (setq sequence (cdr sequence))))
6549 (when (and (or allp
6550 (and sequence
6551 (eq number (car sequence))))
6552 (progn
6553 (setq sequence (cdr sequence))
6554 (setq header (inline
6555 (gnus-nov-parse-line
6556 number dependencies force-new)))))
6557 (push header headers))
6558 (forward-line 1)))
6559 ;; A common bug in inn is that if you have posted an article and
6560 ;; then retrieves the active file, it will answer correctly --
6561 ;; the new article is included. However, a NOV entry for the
6562 ;; article may not have been generated yet, so this may fail.
6563 ;; We work around this problem by retrieving the last few
6564 ;; headers using HEAD.
6565 (if (or (not also-fetch-heads)
6566 (not sequence))
6567 ;; We (probably) got all the headers.
6568 (nreverse headers)
6569 (let ((gnus-nov-is-evil t))
6570 (nconc
6571 (nreverse headers)
6572 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6573 (gnus-get-newsgroup-headers))))))))
6574
6575 (defun gnus-article-get-xrefs ()
6576 "Fill in the Xref value in `gnus-current-headers', if necessary.
6577 This is meant to be called in `gnus-article-internal-prepare-hook'."
6578 (let ((headers (with-current-buffer gnus-summary-buffer
6579 gnus-current-headers)))
6580 (or (not gnus-use-cross-reference)
6581 (not headers)
6582 (and (mail-header-xref headers)
6583 (not (string= (mail-header-xref headers) "")))
6584 (let ((case-fold-search t)
6585 xref)
6586 (save-restriction
6587 (nnheader-narrow-to-headers)
6588 (goto-char (point-min))
6589 (when (or (and (not (eobp))
6590 (eq (downcase (char-after)) ?x)
6591 (looking-at "Xref:"))
6592 (search-forward "\nXref:" nil t))
6593 (goto-char (1+ (match-end 0)))
6594 (setq xref (buffer-substring (point) (point-at-eol)))
6595 (mail-header-set-xref headers xref)))))))
6596
6597 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6598 "Find article ID and insert the summary line for that article.
6599 OLD-HEADER can either be a header or a line number to insert
6600 the subject line on.
6601 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6602 and OLD-HEADER will be used when the summary line is inserted,
6603 too, instead of trying to fetch new headers."
6604 (let* ((line (and (numberp old-header) old-header))
6605 (old-header (and (vectorp old-header) old-header))
6606 (header (cond ((and old-header use-old-header)
6607 old-header)
6608 ((and (numberp id)
6609 (gnus-number-to-header id))
6610 (gnus-number-to-header id))
6611 (t
6612 (gnus-read-header id))))
6613 (number (and (numberp id) id))
6614 d)
6615 (when header
6616 ;; Rebuild the thread that this article is part of and go to the
6617 ;; article we have fetched.
6618 (when (and (not gnus-show-threads)
6619 old-header)
6620 (when (and number
6621 (setq d (gnus-data-find (mail-header-number old-header))))
6622 (goto-char (gnus-data-pos d))
6623 (gnus-data-remove
6624 number
6625 (- (point-at-bol)
6626 (prog1
6627 (1+ (point-at-eol))
6628 (gnus-delete-line))))))
6629 ;; Remove list identifiers from subject.
6630 (let ((gnus-newsgroup-headers (list header)))
6631 (gnus-summary-remove-list-identifiers))
6632 (when old-header
6633 (mail-header-set-number header (mail-header-number old-header)))
6634 (setq gnus-newsgroup-sparse
6635 (delq (setq number (mail-header-number header))
6636 gnus-newsgroup-sparse))
6637 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6638 (push number gnus-newsgroup-limit)
6639 (gnus-rebuild-thread (mail-header-id header) line)
6640 (gnus-summary-goto-subject number nil t))
6641 (when (and (numberp number)
6642 (> number 0))
6643 ;; We have to update the boundaries even if we can't fetch the
6644 ;; article if ID is a number -- so that the next `P' or `N'
6645 ;; command will fetch the previous (or next) article even
6646 ;; if the one we tried to fetch this time has been canceled.
6647 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6648 (setq gnus-newsgroup-end number))
6649 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6650 (setq gnus-newsgroup-begin number))
6651 (setq gnus-newsgroup-unselected
6652 (delq number gnus-newsgroup-unselected)))
6653 ;; Report back a success?
6654 (and header (mail-header-number header))))
6655
6656 ;;; Process/prefix in the summary buffer
6657
6658 (defun gnus-summary-work-articles (n)
6659 "Return a list of articles to be worked upon.
6660 The prefix argument, the list of process marked articles, and the
6661 current article will be taken into consideration."
6662 (with-current-buffer gnus-summary-buffer
6663 (cond
6664 (n
6665 ;; A numerical prefix has been given.
6666 (setq n (prefix-numeric-value n))
6667 (let ((backward (< n 0))
6668 (n (abs (prefix-numeric-value n)))
6669 articles article)
6670 (save-excursion
6671 (while
6672 (and (> n 0)
6673 (push (setq article (gnus-summary-article-number))
6674 articles)
6675 (if backward
6676 (gnus-summary-find-prev nil article)
6677 (gnus-summary-find-next nil article)))
6678 (decf n)))
6679 (nreverse articles)))
6680 ((and (gnus-region-active-p) (mark))
6681 (message "region active")
6682 ;; Work on the region between point and mark.
6683 (let ((max (max (point) (mark)))
6684 articles article)
6685 (save-excursion
6686 (goto-char (min (point) (mark)))
6687 (while
6688 (and
6689 (push (setq article (gnus-summary-article-number)) articles)
6690 (gnus-summary-find-next nil article)
6691 (< (point) max)))
6692 (nreverse articles))))
6693 (gnus-newsgroup-processable
6694 ;; There are process-marked articles present.
6695 ;; Save current state.
6696 (gnus-summary-save-process-mark)
6697 ;; Return the list.
6698 (reverse gnus-newsgroup-processable))
6699 (t
6700 ;; Just return the current article.
6701 (list (gnus-summary-article-number))))))
6702
6703 (defmacro gnus-summary-iterate (arg &rest forms)
6704 "Iterate over the process/prefixed articles and do FORMS.
6705 ARG is the interactive prefix given to the command. FORMS will be
6706 executed with point over the summary line of the articles."
6707 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6708 `(let ((,articles (gnus-summary-work-articles ,arg)))
6709 (while ,articles
6710 (gnus-summary-goto-subject (car ,articles))
6711 ,@forms
6712 (pop ,articles)))))
6713
6714 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6715 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6716
6717 (defun gnus-summary-save-process-mark ()
6718 "Push the current set of process marked articles on the stack."
6719 (interactive)
6720 (push (copy-sequence gnus-newsgroup-processable)
6721 gnus-newsgroup-process-stack))
6722
6723 (defun gnus-summary-kill-process-mark ()
6724 "Push the current set of process marked articles on the stack and unmark."
6725 (interactive)
6726 (gnus-summary-save-process-mark)
6727 (gnus-summary-unmark-all-processable))
6728
6729 (defun gnus-summary-yank-process-mark ()
6730 "Pop the last process mark state off the stack and restore it."
6731 (interactive)
6732 (unless gnus-newsgroup-process-stack
6733 (error "Empty mark stack"))
6734 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6735
6736 (defun gnus-summary-process-mark-set (set)
6737 "Make SET into the current process marked articles."
6738 (gnus-summary-unmark-all-processable)
6739 (mapc 'gnus-summary-set-process-mark set))
6740
6741 ;;; Searching and stuff
6742
6743 (defun gnus-summary-search-group (&optional backward use-level)
6744 "Search for next unread newsgroup.
6745 If optional argument BACKWARD is non-nil, search backward instead."
6746 (with-current-buffer gnus-group-buffer
6747 (when (gnus-group-search-forward
6748 backward nil (if use-level (gnus-group-group-level) nil))
6749 (gnus-group-group-name))))
6750
6751 (defun gnus-summary-best-group (&optional exclude-group)
6752 "Find the name of the best unread group.
6753 If EXCLUDE-GROUP, do not go to this group."
6754 (with-current-buffer gnus-group-buffer
6755 (save-excursion
6756 (gnus-group-best-unread-group exclude-group))))
6757
6758 (defun gnus-summary-find-next (&optional unread article backward)
6759 (if backward
6760 (gnus-summary-find-prev unread article)
6761 (let* ((dummy (gnus-summary-article-intangible-p))
6762 (article (or article (gnus-summary-article-number)))
6763 (data (gnus-data-find-list article))
6764 result)
6765 (when (and (not dummy)
6766 (or (not gnus-summary-check-current)
6767 (not unread)
6768 (not (gnus-data-unread-p (car data)))))
6769 (setq data (cdr data)))
6770 (when (setq result
6771 (if unread
6772 (progn
6773 (while data
6774 (unless (memq (gnus-data-number (car data))
6775 (cond
6776 ((eq gnus-auto-goto-ignores
6777 'always-undownloaded)
6778 gnus-newsgroup-undownloaded)
6779 (gnus-plugged
6780 nil)
6781 ((eq gnus-auto-goto-ignores
6782 'unfetched)
6783 gnus-newsgroup-unfetched)
6784 ((eq gnus-auto-goto-ignores
6785 'undownloaded)
6786 gnus-newsgroup-undownloaded)))
6787 (when (gnus-data-unread-p (car data))
6788 (setq result (car data)
6789 data nil)))
6790 (setq data (cdr data)))
6791 result)
6792 (car data)))
6793 (goto-char (gnus-data-pos result))
6794 (gnus-data-number result)))))
6795
6796 (defun gnus-summary-find-prev (&optional unread article)
6797 (let* ((eobp (eobp))
6798 (article (or article (gnus-summary-article-number)))
6799 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6800 result)
6801 (when (and (not eobp)
6802 (or (not gnus-summary-check-current)
6803 (not unread)
6804 (not (gnus-data-unread-p (car data)))))
6805 (setq data (cdr data)))
6806 (when (setq result
6807 (if unread
6808 (progn
6809 (while data
6810 (unless (memq (gnus-data-number (car data))
6811 (cond
6812 ((eq gnus-auto-goto-ignores
6813 'always-undownloaded)
6814 gnus-newsgroup-undownloaded)
6815 (gnus-plugged
6816 nil)
6817 ((eq gnus-auto-goto-ignores
6818 'unfetched)
6819 gnus-newsgroup-unfetched)
6820 ((eq gnus-auto-goto-ignores
6821 'undownloaded)
6822 gnus-newsgroup-undownloaded)))
6823 (when (gnus-data-unread-p (car data))
6824 (setq result (car data)
6825 data nil)))
6826 (setq data (cdr data)))
6827 result)
6828 (car data)))
6829 (goto-char (gnus-data-pos result))
6830 (gnus-data-number result))))
6831
6832 (defun gnus-summary-find-subject (subject &optional unread backward article)
6833 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6834 (article (or article (gnus-summary-article-number)))
6835 (articles (gnus-data-list backward))
6836 (arts (gnus-data-find-list article articles))
6837 result)
6838 (when (or (not gnus-summary-check-current)
6839 (not unread)
6840 (not (gnus-data-unread-p (car arts))))
6841 (setq arts (cdr arts)))
6842 (while arts
6843 (and (or (not unread)
6844 (gnus-data-unread-p (car arts)))
6845 (vectorp (gnus-data-header (car arts)))
6846 (gnus-subject-equal
6847 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6848 (setq result (car arts)
6849 arts nil))
6850 (setq arts (cdr arts)))
6851 (and result
6852 (goto-char (gnus-data-pos result))
6853 (gnus-data-number result))))
6854
6855 (defun gnus-summary-search-forward (&optional unread subject backward)
6856 "Search forward for an article.
6857 If UNREAD, look for unread articles. If SUBJECT, look for
6858 articles with that subject. If BACKWARD, search backward instead."
6859 (cond (subject (gnus-summary-find-subject subject unread backward))
6860 (backward (gnus-summary-find-prev unread))
6861 (t (gnus-summary-find-next unread))))
6862
6863 (defun gnus-recenter (&optional n)
6864 "Center point in window and redisplay frame.
6865 Also do horizontal recentering."
6866 (interactive "P")
6867 (when (and gnus-auto-center-summary
6868 (not (eq gnus-auto-center-summary 'vertical)))
6869 (gnus-horizontal-recenter))
6870 (if (fboundp 'recenter-top-bottom)
6871 (recenter-top-bottom n)
6872 (recenter n)))
6873
6874 (put 'gnus-recenter 'isearch-scroll t)
6875
6876 (defun gnus-forward-line-ignore-invisible (n)
6877 "Move N lines forward (backward if N is negative).
6878 Like forward-line, but skip over (and don't count) invisible lines."
6879 (let (done)
6880 (while (and (> n 0) (not done))
6881 ;; If the following character is currently invisible,
6882 ;; skip all characters with that same `invisible' property value.
6883 (while (gnus-invisible-p (point))
6884 (goto-char (gnus-next-char-property-change (point))))
6885 (forward-line 1)
6886 (if (eobp)
6887 (setq done t)
6888 (setq n (1- n))))
6889 (while (and (< n 0) (not done))
6890 (forward-line -1)
6891 (if (bobp) (setq done t)
6892 (setq n (1+ n))
6893 (while (and (not (bobp)) (gnus-invisible-p (1- (point))))
6894 (goto-char (gnus-previous-char-property-change (point))))))))
6895
6896 (defun gnus-summary-recenter ()
6897 "Center point in the summary window.
6898 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6899 displayed, no centering will be performed."
6900 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6901 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6902 (interactive)
6903 ;; The user has to want it.
6904 (when gnus-auto-center-summary
6905 (let* ((top (cond ((< (window-height) 4) 0)
6906 ((< (window-height) 7) 1)
6907 (t (if (numberp gnus-auto-center-summary)
6908 gnus-auto-center-summary
6909 (/ (1- (window-height)) 2)))))
6910 (height (1- (window-height)))
6911 (bottom (save-excursion
6912 (goto-char (point-max))
6913 (gnus-forward-line-ignore-invisible (- height))
6914 (point)))
6915 (window (get-buffer-window (current-buffer))))
6916 (when (get-buffer-window gnus-article-buffer)
6917 ;; Only do recentering when the article buffer is displayed,
6918 ;; Set the window start to either `bottom', which is the biggest
6919 ;; possible valid number, or the second line from the top,
6920 ;; whichever is the least.
6921 (let ((top-pos (save-excursion
6922 (gnus-forward-line-ignore-invisible (- top))
6923 (point))))
6924 (if (> bottom top-pos)
6925 ;; Keep the second line from the top visible
6926 (set-window-start window top-pos)
6927 ;; Try to keep the bottom line visible; if it's partially
6928 ;; obscured, either scroll one more line to make it fully
6929 ;; visible, or revert to using TOP-POS.
6930 (save-excursion
6931 (goto-char (point-max))
6932 (gnus-forward-line-ignore-invisible -1)
6933 (let ((last-line-start (point)))
6934 (goto-char bottom)
6935 (set-window-start window (point) t)
6936 (when (not (pos-visible-in-window-p last-line-start window))
6937 (gnus-forward-line-ignore-invisible 1)
6938 (set-window-start window (min (point) top-pos) t)))))))
6939 ;; Do horizontal recentering while we're at it.
6940 (when (and (get-buffer-window (current-buffer) t)
6941 (not (eq gnus-auto-center-summary 'vertical)))
6942 (let ((selected (selected-window)))
6943 (select-window (get-buffer-window (current-buffer) t))
6944 (gnus-summary-position-point)
6945 (gnus-horizontal-recenter)
6946 (select-window selected))))))
6947
6948 (defun gnus-summary-jump-to-group (newsgroup)
6949 "Move point to NEWSGROUP in group mode buffer."
6950 ;; Keep update point of group mode buffer if visible.
6951 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6952 (save-window-excursion
6953 ;; Take care of tree window mode.
6954 (when (get-buffer-window gnus-group-buffer)
6955 (pop-to-buffer gnus-group-buffer))
6956 (gnus-group-jump-to-group newsgroup))
6957 (save-excursion
6958 ;; Take care of tree window mode.
6959 (if (get-buffer-window gnus-group-buffer 0)
6960 (pop-to-buffer gnus-group-buffer)
6961 (set-buffer gnus-group-buffer))
6962 (gnus-group-jump-to-group newsgroup))))
6963
6964 ;; This function returns a list of article numbers based on the
6965 ;; difference between the ranges of read articles in this group and
6966 ;; the range of active articles.
6967 (defun gnus-list-of-unread-articles (group)
6968 (let* ((read (gnus-info-read (gnus-get-info group)))
6969 (active (or (gnus-active group) (gnus-activate-group group)))
6970 (last (or (cdr active)
6971 (error "Group %s couldn't be activated " group)))
6972 (bottom (if gnus-newsgroup-maximum-articles
6973 (max (car active)
6974 (- last gnus-newsgroup-maximum-articles -1))
6975 (car active)))
6976 first nlast unread)
6977 ;; If none are read, then all are unread.
6978 (if (not read)
6979 (setq first bottom)
6980 ;; If the range of read articles is a single range, then the
6981 ;; first unread article is the article after the last read
6982 ;; article. Sounds logical, doesn't it?
6983 (if (and (not (listp (cdr read)))
6984 (or (< (car read) bottom)
6985 (progn (setq read (list read))
6986 nil)))
6987 (setq first (max bottom (1+ (cdr read))))
6988 ;; `read' is a list of ranges.
6989 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6990 (caar read)))
6991 1)
6992 (setq first bottom))
6993 (while read
6994 (when first
6995 (while (< first nlast)
6996 (setq unread (cons first unread)
6997 first (1+ first))))
6998 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6999 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7000 (setq read (cdr read)))))
7001 ;; And add the last unread articles.
7002 (while (<= first last)
7003 (setq unread (cons first unread)
7004 first (1+ first)))
7005 ;; Return the list of unread articles.
7006 (delq 0 (nreverse unread))))
7007
7008 (defun gnus-list-of-read-articles (group)
7009 "Return a list of unread, unticked and non-dormant articles."
7010 (let* ((info (gnus-get-info group))
7011 (marked (gnus-info-marks info))
7012 (active (gnus-active group)))
7013 (and info active
7014 (gnus-list-range-difference
7015 (gnus-list-range-difference
7016 (gnus-sorted-complement
7017 (gnus-uncompress-range
7018 (if gnus-newsgroup-maximum-articles
7019 (cons (max (car active)
7020 (- (cdr active)
7021 gnus-newsgroup-maximum-articles
7022 -1))
7023 (cdr active))
7024 active))
7025 (gnus-list-of-unread-articles group))
7026 (cdr (assq 'dormant marked)))
7027 (cdr (assq 'tick marked))))))
7028
7029 ;; This function returns a sequence of article numbers based on the
7030 ;; difference between the ranges of read articles in this group and
7031 ;; the range of active articles.
7032 (defun gnus-sequence-of-unread-articles (group)
7033 (let* ((read (gnus-info-read (gnus-get-info group)))
7034 (active (or (gnus-active group) (gnus-activate-group group)))
7035 (last (cdr active))
7036 (bottom (if gnus-newsgroup-maximum-articles
7037 (max (car active)
7038 (- last gnus-newsgroup-maximum-articles -1))
7039 (car active)))
7040 first nlast unread)
7041 ;; If none are read, then all are unread.
7042 (if (not read)
7043 (setq first bottom)
7044 ;; If the range of read articles is a single range, then the
7045 ;; first unread article is the article after the last read
7046 ;; article. Sounds logical, doesn't it?
7047 (if (and (not (listp (cdr read)))
7048 (or (< (car read) bottom)
7049 (progn (setq read (list read))
7050 nil)))
7051 (setq first (max bottom (1+ (cdr read))))
7052 ;; `read' is a list of ranges.
7053 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7054 (caar read)))
7055 1)
7056 (setq first bottom))
7057 (while read
7058 (when first
7059 (push (cons first nlast) unread))
7060 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7061 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7062 (setq read (cdr read)))))
7063 ;; And add the last unread articles.
7064 (cond ((not (and first last))
7065 nil)
7066 ((< first last)
7067 (push (cons first last) unread))
7068 ((= first last)
7069 (push first unread)))
7070 ;; Return the sequence of unread articles.
7071 (delq 0 (nreverse unread))))
7072
7073 ;; Various summary commands
7074
7075 (defun gnus-summary-select-article-buffer ()
7076 "Reconfigure windows to show the article buffer.
7077 If `gnus-widen-article-window' is set, show only the article
7078 buffer."
7079 (interactive)
7080 (if (not (gnus-buffer-live-p gnus-article-buffer))
7081 (error "There is no article buffer for this summary buffer")
7082 (unless (get-buffer-window gnus-article-buffer)
7083 (gnus-summary-show-article))
7084 (gnus-configure-windows
7085 (if gnus-widen-article-window
7086 'only-article
7087 'article)
7088 t)
7089 (select-window (get-buffer-window gnus-article-buffer))))
7090
7091 (defun gnus-summary-universal-argument (arg)
7092 "Perform any operation on all articles that are process/prefixed."
7093 (interactive "P")
7094 (let ((articles (gnus-summary-work-articles arg))
7095 func article)
7096 (if (eq
7097 (setq
7098 func
7099 (key-binding
7100 (read-key-sequence
7101 (substitute-command-keys
7102 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7103 'undefined)
7104 (gnus-error 1 "Undefined key")
7105 (save-excursion
7106 (while articles
7107 (gnus-summary-goto-subject (setq article (pop articles)))
7108 (let (gnus-newsgroup-processable)
7109 (command-execute func))
7110 (gnus-summary-remove-process-mark article)))))
7111 (gnus-summary-position-point))
7112
7113 (defun gnus-summary-toggle-truncation (&optional arg)
7114 "Toggle truncation of summary lines.
7115 With ARG, turn line truncation on if ARG is positive."
7116 (interactive "P")
7117 (setq truncate-lines
7118 (if (null arg) (not truncate-lines)
7119 (> (prefix-numeric-value arg) 0)))
7120 (redraw-display))
7121
7122 (defun gnus-summary-find-for-reselect ()
7123 "Return the number of an article to stay on across a reselect.
7124 The current article is considered, then following articles, then previous
7125 articles. An article is sought which is not canceled and isn't a temporary
7126 insertion from another group. If there's no such then return a dummy 0."
7127 (let (found)
7128 (dolist (rev '(nil t))
7129 (unless found ; don't demand the reverse list if we don't need it
7130 (let ((data (gnus-data-find-list
7131 (gnus-summary-article-number) (gnus-data-list rev))))
7132 (while (and data (not found))
7133 (if (and (< 0 (gnus-data-number (car data)))
7134 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7135 (setq found (gnus-data-number (car data))))
7136 (setq data (cdr data))))))
7137 (or found 0)))
7138
7139 (defun gnus-summary-reselect-current-group (&optional all rescan)
7140 "Exit and then reselect the current newsgroup.
7141 The prefix argument ALL means to select all articles."
7142 (interactive "P")
7143 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7144 (error "Ephemeral groups can't be reselected"))
7145 (let ((current-subject (gnus-summary-find-for-reselect))
7146 (group gnus-newsgroup-name))
7147 (setq gnus-newsgroup-begin nil)
7148 (gnus-summary-exit nil 'leave-hidden)
7149 ;; We have to adjust the point of group mode buffer because
7150 ;; point was moved to the next unread newsgroup by exiting.
7151 (gnus-summary-jump-to-group group)
7152 (when rescan
7153 (save-excursion
7154 (gnus-group-get-new-news-this-group 1)))
7155 (gnus-group-read-group all t)
7156 (gnus-summary-goto-subject current-subject nil t)))
7157
7158 (defun gnus-summary-rescan-group (&optional all)
7159 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7160 (interactive "P")
7161 (let ((config gnus-current-window-configuration))
7162 (gnus-summary-reselect-current-group all t)
7163 (gnus-configure-windows config)
7164 (when (eq config 'article)
7165 (gnus-summary-select-article))))
7166
7167 (defun gnus-summary-update-info (&optional non-destructive)
7168 (save-excursion
7169 (let ((group gnus-newsgroup-name))
7170 (when group
7171 (when gnus-newsgroup-kill-headers
7172 (setq gnus-newsgroup-killed
7173 (gnus-compress-sequence
7174 (gnus-sorted-union
7175 (gnus-list-range-intersection
7176 gnus-newsgroup-unselected gnus-newsgroup-killed)
7177 gnus-newsgroup-unreads)
7178 t)))
7179 (unless (listp (cdr gnus-newsgroup-killed))
7180 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7181 (let ((headers gnus-newsgroup-headers)
7182 (ephemeral-p (gnus-ephemeral-group-p group))
7183 info)
7184 (unless ephemeral-p
7185 (setq info (copy-sequence (gnus-get-info group))
7186 info (delq (gnus-info-params info) info)))
7187 ;; Set the new ranges of read articles.
7188 (with-current-buffer gnus-group-buffer
7189 (gnus-undo-force-boundary))
7190 (gnus-update-read-articles
7191 group (gnus-sorted-union
7192 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7193 ;; Set the current article marks.
7194 (let ((gnus-newsgroup-scored
7195 (if (and (not gnus-save-score)
7196 (not non-destructive))
7197 nil
7198 gnus-newsgroup-scored)))
7199 (save-excursion
7200 (gnus-update-marks)))
7201 ;; Do the cross-ref thing.
7202 (when gnus-use-cross-reference
7203 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7204 ;; Do not switch windows but change the buffer to work.
7205 (set-buffer gnus-group-buffer)
7206 (unless ephemeral-p
7207 (gnus-group-update-group
7208 group nil
7209 (equal info
7210 (setq info (copy-sequence (gnus-get-info group))
7211 info (delq (gnus-info-params info) info))))))))))
7212
7213 (defun gnus-summary-save-newsrc (&optional force)
7214 "Save the current number of read/marked articles in the dribble buffer.
7215 The dribble buffer will then be saved.
7216 If FORCE (the prefix), also save the .newsrc file(s)."
7217 (interactive "P")
7218 (gnus-summary-update-info t)
7219 (if force
7220 (gnus-save-newsrc-file)
7221 (gnus-dribble-save)))
7222
7223 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7224 (declare-function gnus-article-stop-animations "gnus-art" ())
7225
7226 (defun gnus-summary-exit (&optional temporary leave-hidden)
7227 "Exit reading current newsgroup, and then return to group selection mode.
7228 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7229 (interactive)
7230 (gnus-set-global-variables)
7231 (when (gnus-buffer-live-p gnus-article-buffer)
7232 (with-current-buffer gnus-article-buffer
7233 (mm-destroy-parts gnus-article-mime-handles)
7234 ;; Set it to nil for safety reason.
7235 (setq gnus-article-mime-handle-alist nil)
7236 (setq gnus-article-mime-handles nil)))
7237 (gnus-kill-save-kill-buffer)
7238 (gnus-async-halt-prefetch)
7239 (let* ((group gnus-newsgroup-name)
7240 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7241 (gnus-group-is-exiting-p t)
7242 (article-buffer gnus-article-buffer)
7243 (original-article-buffer gnus-original-article-buffer)
7244 (mode major-mode)
7245 (group-point nil)
7246 (buf (current-buffer))
7247 ;; `gnus-single-article-buffer' is nil buffer-locally in
7248 ;; ephemeral group of which summary buffer will be killed,
7249 ;; but the global value may be non-nil.
7250 (single-article-buffer gnus-single-article-buffer))
7251 (unless quit-config
7252 ;; Do adaptive scoring, and possibly save score files.
7253 (when gnus-newsgroup-adaptive
7254 (gnus-score-adaptive))
7255 (when gnus-use-scoring
7256 (gnus-score-save)))
7257 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7258 (when gnus-use-cache
7259 (gnus-cache-possibly-remove-articles)
7260 (gnus-cache-save-buffers))
7261 (gnus-async-prefetch-remove-group group)
7262 (when gnus-suppress-duplicates
7263 (gnus-dup-enter-articles))
7264 (when gnus-use-trees
7265 (gnus-tree-close))
7266 (when gnus-use-cache
7267 (gnus-cache-write-active))
7268 ;; Remove entries for this group.
7269 (nnmail-purge-split-history (gnus-group-real-name group))
7270 ;; Make all changes in this group permanent.
7271 (unless quit-config
7272 (gnus-run-hooks 'gnus-exit-group-hook)
7273 (gnus-summary-update-info))
7274 (gnus-close-group group)
7275 ;; Make sure where we were, and go to next newsgroup.
7276 (when (buffer-live-p (get-buffer gnus-group-buffer))
7277 (set-buffer gnus-group-buffer))
7278 (unless quit-config
7279 (gnus-group-jump-to-group group))
7280 (gnus-run-hooks 'gnus-summary-exit-hook)
7281 (unless (or quit-config
7282 (not gnus-summary-next-group-on-exit)
7283 ;; If this group has disappeared from the summary
7284 ;; buffer, don't skip forwards.
7285 (not (string= group (gnus-group-group-name))))
7286 (gnus-group-next-unread-group 1))
7287 (setq group-point (point))
7288 (gnus-article-stop-animations)
7289 (if temporary
7290 nil ;Nothing to do.
7291 (set-buffer buf)
7292 (if (not gnus-kill-summary-on-exit)
7293 (progn
7294 (gnus-deaden-summary)
7295 (setq mode nil))
7296 (when (get-buffer gnus-article-buffer)
7297 (bury-buffer gnus-article-buffer))
7298 ;; Return to group mode buffer.
7299 (when (eq mode 'gnus-summary-mode)
7300 (gnus-kill-buffer buf)))
7301
7302 (setq gnus-current-select-method gnus-select-method)
7303 (when (gnus-buffer-live-p gnus-group-buffer)
7304 (set-buffer gnus-group-buffer))
7305 (if quit-config
7306 (gnus-handle-ephemeral-exit quit-config)
7307 (goto-char group-point)
7308 ;; If gnus-group-buffer is already displayed, make sure we also move
7309 ;; the cursor in the window that displays it.
7310 (let ((win (get-buffer-window (current-buffer) 0)))
7311 (if win (set-window-point win (point))))
7312 (unless leave-hidden
7313 (gnus-configure-windows 'group 'force)))
7314
7315 ;; If we have several article buffers, we kill them at exit.
7316 (unless single-article-buffer
7317 (when (gnus-buffer-live-p article-buffer)
7318 (with-current-buffer article-buffer
7319 ;; Don't kill sticky article buffers
7320 (unless (eq major-mode 'gnus-sticky-article-mode)
7321 (gnus-kill-buffer article-buffer)
7322 (setq gnus-article-current nil))))
7323 (gnus-kill-buffer original-article-buffer))
7324
7325 ;; Clear the current group name.
7326 (unless quit-config
7327 (setq gnus-newsgroup-name nil)))))
7328
7329 (declare-function gnus-stop-downloads "gnus-art" ())
7330
7331 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7332 (defun gnus-summary-exit-no-update (&optional no-questions)
7333 "Quit reading current newsgroup without updating read article info."
7334 (interactive)
7335 (let* ((group gnus-newsgroup-name)
7336 (gnus-group-is-exiting-p t)
7337 (gnus-group-is-exiting-without-update-p t)
7338 (quit-config (gnus-group-quit-config group)))
7339 (when (or no-questions
7340 (gnus-ephemeral-group-p group)
7341 gnus-expert-user
7342 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7343 (gnus-async-halt-prefetch)
7344 (run-hooks 'gnus-summary-prepare-exit-hook)
7345 (when (gnus-buffer-live-p gnus-article-buffer)
7346 (with-current-buffer gnus-article-buffer
7347 (gnus-article-stop-animations)
7348 (gnus-stop-downloads)
7349 (mm-destroy-parts gnus-article-mime-handles)
7350 ;; Set it to nil for safety reason.
7351 (setq gnus-article-mime-handle-alist nil)
7352 (setq gnus-article-mime-handles nil)))
7353 ;; If we have several article buffers, we kill them at exit.
7354 (unless gnus-single-article-buffer
7355 (gnus-kill-buffer gnus-article-buffer)
7356 (gnus-kill-buffer gnus-original-article-buffer)
7357 (setq gnus-article-current nil))
7358 ;; Return to the group buffer.
7359 (if (not gnus-kill-summary-on-exit)
7360 (progn
7361 (gnus-deaden-summary)
7362 (gnus-configure-windows 'group 'force))
7363 (gnus-configure-windows 'group 'force)
7364 (gnus-close-group group)
7365 (gnus-kill-buffer gnus-summary-buffer))
7366 (unless gnus-single-article-buffer
7367 (setq gnus-article-current nil))
7368 (when gnus-use-trees
7369 (gnus-tree-close))
7370 (gnus-async-prefetch-remove-group group)
7371 (when (get-buffer gnus-article-buffer)
7372 (bury-buffer gnus-article-buffer))
7373 ;; Clear the current group name.
7374 (setq gnus-newsgroup-name nil)
7375 (unless (gnus-ephemeral-group-p group)
7376 (gnus-group-update-group group nil t))
7377 (when (equal (gnus-group-group-name) group)
7378 (gnus-group-next-unread-group 1))
7379 (gnus-article-stop-animations)
7380 (when quit-config
7381 (gnus-handle-ephemeral-exit quit-config)))))
7382
7383 (defun gnus-handle-ephemeral-exit (quit-config)
7384 "Handle movement when leaving an ephemeral group.
7385 The state which existed when entering the ephemeral is reset."
7386 (if (not (buffer-live-p (car quit-config)))
7387 (when (gnus-buffer-live-p gnus-group-buffer)
7388 (gnus-configure-windows 'group 'force))
7389 (set-buffer (car quit-config))
7390 (unless (eq (cdr quit-config) 'group)
7391 (setq gnus-current-select-method
7392 (gnus-find-method-for-group gnus-newsgroup-name)))
7393 (cond ((derived-mode-p 'gnus-summary-mode)
7394 (gnus-set-global-variables))
7395 ((derived-mode-p 'gnus-article-mode)
7396 (save-current-buffer
7397 ;; The `gnus-summary-buffer' variable may point
7398 ;; to the old summary buffer when using a single
7399 ;; article buffer.
7400 (unless (gnus-buffer-live-p gnus-summary-buffer)
7401 (set-buffer gnus-group-buffer))
7402 (set-buffer gnus-summary-buffer)
7403 (gnus-set-global-variables))))
7404 (if (or (eq (cdr quit-config) 'article)
7405 (eq (cdr quit-config) 'pick))
7406 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7407 (gnus-configure-windows 'pick 'force)
7408 (gnus-configure-windows (cdr quit-config) 'force))
7409 (gnus-configure-windows (cdr quit-config) 'force))
7410 (when (derived-mode-p 'gnus-summary-mode)
7411 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7412 next-unread-noselect))
7413 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7414 'next-noselect)
7415 (gnus-summary-next-subject 1 nil t))
7416 ((eq gnus-auto-select-on-ephemeral-exit
7417 'next-unread-noselect)
7418 (gnus-summary-next-subject 1 t t))))
7419 ;; Hide the article buffer which displays the article different
7420 ;; from the one that the cursor points to in the summary buffer.
7421 (gnus-configure-windows 'summary 'force))
7422 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7423 (gnus-summary-next-subject 1))
7424 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7425 (gnus-summary-next-subject 1 t))))
7426 (gnus-summary-recenter)
7427 (gnus-summary-position-point))))
7428
7429 ;;; Dead summaries.
7430
7431 (defvar gnus-dead-summary-mode-map
7432 (let ((map (make-keymap)))
7433 (suppress-keymap map)
7434 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7435 (dolist (key '("\C-d" "\r" "\177" [delete]))
7436 (define-key map key 'gnus-summary-wake-up-the-dead))
7437 (dolist (key '("q" "Q"))
7438 (define-key map key 'bury-buffer))
7439 map))
7440
7441 (define-minor-mode gnus-dead-summary-mode
7442 "Minor mode for Gnus summary buffers."
7443 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7444 (unless (derived-mode-p 'gnus-summary-mode)
7445 (setq gnus-dead-summary-mode nil)))
7446
7447 (defun gnus-deaden-summary ()
7448 "Make the current summary buffer into a dead summary buffer."
7449 ;; Kill any previous dead summary buffer.
7450 (when (and gnus-dead-summary
7451 (buffer-name gnus-dead-summary))
7452 (with-current-buffer gnus-dead-summary
7453 (when gnus-dead-summary-mode
7454 (kill-buffer (current-buffer)))))
7455 ;; Make this the current dead summary.
7456 (setq gnus-dead-summary (current-buffer))
7457 (gnus-dead-summary-mode 1)
7458 (let ((name (buffer-name)))
7459 (when (string-match "Summary" name)
7460 (rename-buffer
7461 (concat (substring name 0 (match-beginning 0)) "Dead "
7462 (substring name (match-beginning 0)))
7463 t)
7464 (bury-buffer))))
7465
7466 (defun gnus-kill-or-deaden-summary (buffer)
7467 "Kill or deaden the summary BUFFER."
7468 (save-excursion
7469 (when (and (buffer-name buffer)
7470 (not gnus-single-article-buffer))
7471 (with-current-buffer buffer
7472 (gnus-kill-buffer gnus-article-buffer)
7473 (gnus-kill-buffer gnus-original-article-buffer)))
7474 (cond
7475 ;; Kill the buffer.
7476 (gnus-kill-summary-on-exit
7477 (when (and gnus-use-trees
7478 (gnus-buffer-exists-p buffer))
7479 (with-current-buffer buffer
7480 (gnus-tree-close)))
7481 (gnus-kill-buffer buffer))
7482 ;; Deaden the buffer.
7483 ((gnus-buffer-exists-p buffer)
7484 (with-current-buffer buffer
7485 (gnus-deaden-summary))))))
7486
7487 (defun gnus-summary-wake-up-the-dead (&rest args)
7488 "Wake up the dead summary buffer."
7489 (interactive)
7490 (gnus-dead-summary-mode -1)
7491 (let ((name (buffer-name)))
7492 (when (string-match "Dead " name)
7493 (rename-buffer
7494 (concat (substring name 0 (match-beginning 0))
7495 (substring name (match-end 0)))
7496 t)))
7497 (gnus-message 3 "This dead summary is now alive again"))
7498
7499 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7500 (defun gnus-summary-describe-group (&optional force)
7501 "Describe the current newsgroup."
7502 (interactive "P")
7503 (gnus-group-describe-group force gnus-newsgroup-name))
7504
7505 (defun gnus-summary-describe-briefly ()
7506 "Describe summary mode commands briefly."
7507 (interactive)
7508 (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")))
7509
7510 ;; Walking around group mode buffer from summary mode.
7511
7512 (defun gnus-summary-next-group (&optional no-article target-group backward)
7513 "Exit current newsgroup and then select next unread newsgroup.
7514 If prefix argument NO-ARTICLE is non-nil, no article is selected
7515 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7516 previous group instead."
7517 (interactive "P")
7518 ;; Stop pre-fetching.
7519 (gnus-async-halt-prefetch)
7520 (let ((current-group gnus-newsgroup-name)
7521 (current-buffer (current-buffer))
7522 entered)
7523 ;; First we semi-exit this group to update Xrefs and all variables.
7524 ;; We can't do a real exit, because the window conf must remain
7525 ;; the same in case the user is prompted for info, and we don't
7526 ;; want the window conf to change before that...
7527 (gnus-summary-exit t)
7528 (while (not entered)
7529 ;; Then we find what group we are supposed to enter.
7530 (set-buffer gnus-group-buffer)
7531 (gnus-group-jump-to-group current-group)
7532 (setq target-group
7533 (or target-group
7534 (if (eq gnus-keep-same-level 'best)
7535 (gnus-summary-best-group gnus-newsgroup-name)
7536 (gnus-summary-search-group backward gnus-keep-same-level))))
7537 (if (not target-group)
7538 ;; There are no further groups, so we return to the group
7539 ;; buffer.
7540 (progn
7541 (gnus-message 5 "Returning to the group buffer")
7542 (setq entered t)
7543 (when (gnus-buffer-live-p current-buffer)
7544 (set-buffer current-buffer)
7545 (gnus-summary-exit))
7546 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7547 ;; We try to enter the target group.
7548 (gnus-group-jump-to-group target-group)
7549 (let ((unreads (gnus-group-group-unread)))
7550 (if (and (or (eq t unreads)
7551 (and unreads (not (zerop unreads))))
7552 (gnus-summary-read-group
7553 target-group nil no-article
7554 (and (buffer-name current-buffer) current-buffer)
7555 nil backward))
7556 (setq entered t)
7557 (setq current-group target-group
7558 target-group nil)))))))
7559
7560 (defun gnus-summary-prev-group (&optional no-article)
7561 "Exit current newsgroup and then select previous unread newsgroup.
7562 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7563 (interactive "P")
7564 (gnus-summary-next-group no-article nil t))
7565
7566 ;; Walking around summary lines.
7567
7568 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7569 "Go to the first subject satisfying any non-nil constraint.
7570 If UNREAD is non-nil, the article should be unread.
7571 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7572 If UNSEEN is non-nil, the article should be unseen as well as unread.
7573 Returns the article selected or nil if there are no matching articles."
7574 (interactive "P")
7575 (cond
7576 ;; Empty summary.
7577 ((null gnus-newsgroup-data)
7578 (gnus-message 3 "No articles in the group")
7579 nil)
7580 ;; Pick the first article.
7581 ((not (or unread undownloaded unseen))
7582 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7583 (gnus-data-number (car gnus-newsgroup-data)))
7584 ;; Find the first unread article.
7585 (t
7586 (let ((data gnus-newsgroup-data))
7587 (while (and data
7588 (let ((num (gnus-data-number (car data))))
7589 (or (memq num gnus-newsgroup-unfetched)
7590 (not (or (and unread
7591 (memq num gnus-newsgroup-unreads))
7592 (and undownloaded
7593 (memq num gnus-newsgroup-undownloaded))
7594 (and unseen
7595 (memq num gnus-newsgroup-unseen)
7596 (memq num gnus-newsgroup-unreads)))))))
7597 (setq data (cdr data)))
7598 (prog1
7599 (if data
7600 (progn
7601 (goto-char (gnus-data-pos (car data)))
7602 (gnus-data-number (car data)))
7603 (gnus-message 3 "No more%s articles"
7604 (let* ((r (when unread " unread"))
7605 (d (when undownloaded " undownloaded"))
7606 (s (when unseen " unseen"))
7607 (l (delq nil (list r d s))))
7608 (cond ((= 3 (length l))
7609 (concat r "," d ", or" s))
7610 ((= 2 (length l))
7611 (concat (car l) ", or" (cadr l)))
7612 ((= 1 (length l))
7613 (car l))
7614 (t
7615 ""))))
7616 nil
7617 )
7618 (gnus-summary-position-point))))))
7619
7620 (defun gnus-summary-next-subject (n &optional unread dont-display)
7621 "Go to next N'th summary line.
7622 If N is negative, go to the previous N'th subject line.
7623 If UNREAD is non-nil, only unread articles are selected.
7624 The difference between N and the actual number of steps taken is
7625 returned."
7626 (interactive "p")
7627 (let ((backward (< n 0))
7628 (n (abs n)))
7629 (while (and (> n 0)
7630 (if backward
7631 (gnus-summary-find-prev unread)
7632 (gnus-summary-find-next unread)))
7633 (unless (zerop (setq n (1- n)))
7634 (gnus-summary-show-thread)))
7635 (when (/= 0 n)
7636 (gnus-message 7 "No more%s articles"
7637 (if unread " unread" "")))
7638 (unless dont-display
7639 (gnus-summary-recenter)
7640 (gnus-summary-position-point))
7641 n))
7642
7643 (defun gnus-summary-next-unread-subject (n)
7644 "Go to next N'th unread summary line."
7645 (interactive "p")
7646 (gnus-summary-next-subject n t))
7647
7648 (defun gnus-summary-prev-subject (n &optional unread)
7649 "Go to previous N'th summary line.
7650 If optional argument UNREAD is non-nil, only unread article is selected."
7651 (interactive "p")
7652 (gnus-summary-next-subject (- n) unread))
7653
7654 (defun gnus-summary-prev-unread-subject (n)
7655 "Go to previous N'th unread summary line."
7656 (interactive "p")
7657 (gnus-summary-next-subject (- n) t))
7658
7659 (defun gnus-summary-goto-subjects (articles)
7660 "Insert the subject header for ARTICLES in the current buffer."
7661 (save-excursion
7662 (dolist (article articles)
7663 (gnus-summary-goto-subject article t)))
7664 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7665 (gnus-summary-position-point))
7666
7667 (defun gnus-summary-goto-subject (article &optional force silent)
7668 "Go to the subject line of ARTICLE.
7669 If FORCE, also allow jumping to articles not currently shown."
7670 (interactive "nArticle number: ")
7671 (unless (numberp article)
7672 (error "Article %s is not a number" article))
7673 (let ((b (point))
7674 (data (gnus-data-find article)))
7675 ;; We read in the article if we have to.
7676 (and (not data)
7677 force
7678 (gnus-summary-insert-subject
7679 article
7680 (if (or (numberp force) (vectorp force)) force)
7681 t)
7682 (setq data (gnus-data-find article)))
7683 (goto-char b)
7684 (if (not data)
7685 (progn
7686 (unless silent
7687 (gnus-message 3 "Can't find article %d" article))
7688 nil)
7689 (let ((pt (gnus-data-pos data)))
7690 (goto-char pt)
7691 (gnus-summary-set-article-display-arrow pt))
7692 (gnus-summary-position-point)
7693 article)))
7694
7695 ;; Walking around summary lines with displaying articles.
7696
7697 (defun gnus-summary-expand-window (&optional arg)
7698 "Make the summary buffer take up the entire Emacs frame.
7699 Given a prefix, will force an `article' buffer configuration."
7700 (interactive "P")
7701 (if arg
7702 (gnus-configure-windows 'article 'force)
7703 (gnus-configure-windows 'summary 'force)))
7704
7705 (defun gnus-summary-display-article (article &optional all-header)
7706 "Display ARTICLE in article buffer."
7707 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7708 (with-current-buffer gnus-article-buffer
7709 (derived-mode-p 'gnus-article-mode)))
7710 (gnus-article-setup-buffer))
7711 (gnus-set-global-variables)
7712 (with-current-buffer gnus-article-buffer
7713 (setq gnus-article-charset gnus-newsgroup-charset)
7714 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7715 (mm-enable-multibyte))
7716 (if (null article)
7717 nil
7718 (prog1
7719 (if gnus-summary-display-article-function
7720 (funcall gnus-summary-display-article-function article all-header)
7721 (gnus-article-prepare article all-header))
7722 (gnus-run-hooks 'gnus-select-article-hook)
7723 (when (and gnus-current-article
7724 (not (zerop gnus-current-article)))
7725 (gnus-summary-goto-subject gnus-current-article))
7726 (gnus-summary-recenter)
7727 (when (and gnus-use-trees gnus-show-threads)
7728 (gnus-possibly-generate-tree article)
7729 (gnus-highlight-selected-tree article))
7730 ;; Successfully display article.
7731 (gnus-article-set-window-start
7732 (cdr (assq article gnus-newsgroup-bookmarks))))))
7733
7734 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7735 "Select the current article.
7736 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7737 non-nil, the article will be re-fetched even if it already present in
7738 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7739 be displayed."
7740 ;; Make sure we are in the summary buffer to work around bbdb bug.
7741 (unless (derived-mode-p 'gnus-summary-mode)
7742 (set-buffer gnus-summary-buffer))
7743 (let ((article (or article (gnus-summary-article-number)))
7744 (all-headers (not (not all-headers))) ;Must be t or nil.
7745 gnus-summary-display-article-function)
7746 (and (not pseudo)
7747 (gnus-summary-article-pseudo-p article)
7748 (error "This is a pseudo-article"))
7749 (with-current-buffer gnus-summary-buffer
7750 (if (or (and gnus-single-article-buffer
7751 (or (null gnus-current-article)
7752 (null gnus-article-current)
7753 (null (get-buffer gnus-article-buffer))
7754 (not (eq article (cdr gnus-article-current)))
7755 (not (equal (car gnus-article-current)
7756 gnus-newsgroup-name))
7757 (not (get-buffer gnus-original-article-buffer))))
7758 (and (not gnus-single-article-buffer)
7759 (or (null gnus-current-article)
7760 (not (get-buffer gnus-original-article-buffer))
7761 (not (eq gnus-current-article article))))
7762 force)
7763 ;; The requested article is different from the current article.
7764 (progn
7765 (gnus-summary-display-article article all-headers)
7766 (when (gnus-buffer-live-p gnus-article-buffer)
7767 (with-current-buffer gnus-article-buffer
7768 (if (not gnus-article-decoded-p) ;; a local variable
7769 (mm-disable-multibyte))))
7770 (gnus-article-set-window-start
7771 (cdr (assq article gnus-newsgroup-bookmarks)))
7772 article)
7773 'old))))
7774
7775 (defun gnus-summary-force-verify-and-decrypt ()
7776 "Display buttons for signed/encrypted parts and verify/decrypt them."
7777 (interactive)
7778 (let ((mm-verify-option 'known)
7779 (mm-decrypt-option 'known)
7780 (gnus-article-emulate-mime t)
7781 (gnus-buttonized-mime-types (append (list "multipart/signed"
7782 "multipart/encrypted")
7783 gnus-buttonized-mime-types)))
7784 (gnus-summary-select-article nil 'force)))
7785
7786 (defun gnus-summary-next-article (&optional unread subject backward push)
7787 "Select the next article.
7788 If UNREAD, only unread articles are selected.
7789 If SUBJECT, only articles with SUBJECT are selected.
7790 If BACKWARD, the previous article is selected instead of the next."
7791 (interactive "P")
7792 ;; Make sure we are in the summary buffer.
7793 (unless (derived-mode-p 'gnus-summary-mode)
7794 (set-buffer gnus-summary-buffer))
7795 (cond
7796 ;; Is there such an article?
7797 ((and (gnus-summary-search-forward unread subject backward)
7798 (or (gnus-summary-display-article (gnus-summary-article-number))
7799 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7800 (gnus-summary-position-point))
7801 ;; If not, we try the first unread, if that is wanted.
7802 ((and subject
7803 gnus-auto-select-same
7804 (gnus-summary-first-unread-article))
7805 (gnus-summary-position-point)
7806 (gnus-message 6 "Wrapped"))
7807 ;; Try to get next/previous article not displayed in this group.
7808 ((and gnus-auto-extend-newsgroup
7809 (not unread) (not subject))
7810 (gnus-summary-goto-article
7811 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7812 nil (count-lines (point-min) (point))))
7813 ;; Go to next/previous group.
7814 (t
7815 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7816 (gnus-summary-jump-to-group gnus-newsgroup-name))
7817 (let ((cmd (if (featurep 'xemacs)
7818 last-command-char
7819 last-command-event))
7820 (point
7821 (with-current-buffer gnus-group-buffer
7822 (point)))
7823 (current-summary (current-buffer))
7824 (group
7825 (if (eq gnus-keep-same-level 'best)
7826 (gnus-summary-best-group gnus-newsgroup-name)
7827 (gnus-summary-search-group backward gnus-keep-same-level))))
7828 ;; Select next unread newsgroup automagically.
7829 (cond
7830 ((or (not gnus-auto-select-next)
7831 (not cmd))
7832 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7833 ((or (eq gnus-auto-select-next 'quietly)
7834 (and (eq gnus-auto-select-next 'slightly-quietly)
7835 push)
7836 (and (eq gnus-auto-select-next 'almost-quietly)
7837 (gnus-summary-last-article-p)))
7838 ;; Select quietly.
7839 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7840 (gnus-summary-exit)
7841 (gnus-message 7 "No more%s articles (%s)..."
7842 (if unread " unread" "")
7843 (if group (concat "selecting " group)
7844 "exiting"))
7845 (gnus-summary-next-group nil group backward)))
7846 (t
7847 (when (gnus-key-press-event-p last-input-event)
7848 ;; Somehow or other, we may now have selected a different
7849 ;; window. Make point go back to the summary buffer.
7850 (when (eq current-summary (current-buffer))
7851 ;; FIXME: This burps when get-buffer-window returns nil.
7852 (select-window (get-buffer-window current-summary 0)))
7853 (gnus-summary-walk-group-buffer
7854 gnus-newsgroup-name cmd unread backward point))))))))
7855
7856 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7857 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7858 (?\C-p (gnus-group-prev-unread-group 1))))
7859 (cursor-in-echo-area t)
7860 keve key group ended prompt)
7861 (with-current-buffer gnus-group-buffer
7862 (goto-char start)
7863 (setq group
7864 (if (eq gnus-keep-same-level 'best)
7865 (gnus-summary-best-group gnus-newsgroup-name)
7866 (gnus-summary-search-group backward gnus-keep-same-level))))
7867 (while (not ended)
7868 (setq prompt
7869 (format
7870 "No more%s articles%s " (if unread " unread" "")
7871 (if (and group
7872 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7873 (format " (Type %s for %s [%s])"
7874 (single-key-description cmd)
7875 (gnus-group-decoded-name group)
7876 (gnus-group-unread group))
7877 (format " (Type %s to exit %s)"
7878 (single-key-description cmd)
7879 (gnus-group-decoded-name gnus-newsgroup-name)))))
7880 ;; Confirm auto selection.
7881 (setq key (car (setq keve (gnus-read-event-char prompt)))
7882 ended t)
7883 (cond
7884 ((assq key keystrokes)
7885 (let ((obuf (current-buffer)))
7886 (switch-to-buffer gnus-group-buffer)
7887 (when group
7888 (gnus-group-jump-to-group group))
7889 (eval (cadr (assq key keystrokes)))
7890 (setq group (gnus-group-group-name))
7891 (switch-to-buffer obuf))
7892 (setq ended nil))
7893 ((equal key cmd)
7894 (if (or (not group)
7895 (gnus-ephemeral-group-p gnus-newsgroup-name))
7896 (gnus-summary-exit)
7897 (gnus-summary-next-group nil group backward)))
7898 (t
7899 (push (cdr keve) unread-command-events))))))
7900
7901 (defun gnus-summary-next-unread-article ()
7902 "Select unread article after current one."
7903 (interactive)
7904 (gnus-summary-next-article
7905 (or (not (eq gnus-summary-goto-unread 'never))
7906 (gnus-summary-last-article-p (gnus-summary-article-number)))
7907 (and gnus-auto-select-same
7908 (gnus-summary-article-subject))))
7909
7910 (defun gnus-summary-prev-article (&optional unread subject)
7911 "Select the article before the current one.
7912 If UNREAD is non-nil, only unread articles are selected."
7913 (interactive "P")
7914 (gnus-summary-next-article unread subject t))
7915
7916 (defun gnus-summary-prev-unread-article ()
7917 "Select unread article before current one."
7918 (interactive)
7919 (gnus-summary-prev-article
7920 (or (not (eq gnus-summary-goto-unread 'never))
7921 (gnus-summary-first-article-p (gnus-summary-article-number)))
7922 (and gnus-auto-select-same
7923 (gnus-summary-article-subject))))
7924
7925 (declare-function gnus-article-only-boring-p "gnus-art" ())
7926
7927 (defun gnus-summary-next-page (&optional lines circular stop)
7928 "Show next page of the selected article.
7929 If at the end of the current article, select the next article.
7930 LINES says how many lines should be scrolled up.
7931
7932 If CIRCULAR is non-nil, go to the start of the article instead of
7933 selecting the next article when reaching the end of the current
7934 article.
7935
7936 If STOP is non-nil, just stop when reaching the end of the message.
7937
7938 Also see the variable `gnus-article-skip-boring'."
7939 (interactive "P")
7940 (gnus-set-global-variables)
7941 (let ((article (gnus-summary-article-number))
7942 (article-window (get-buffer-window gnus-article-buffer t))
7943 endp)
7944 ;; If the buffer is empty, we have no article.
7945 (unless article
7946 (error "No article to select"))
7947 (gnus-configure-windows 'article)
7948 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7949 (if (and (eq gnus-summary-goto-unread 'never)
7950 (not (gnus-summary-last-article-p article)))
7951 (gnus-summary-next-article)
7952 (gnus-summary-next-unread-article))
7953 (if (or (null gnus-current-article)
7954 (null gnus-article-current)
7955 (/= article (cdr gnus-article-current))
7956 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7957 ;; Selected subject is different from current article's.
7958 (gnus-summary-display-article article)
7959 (when article-window
7960 (gnus-eval-in-buffer-window gnus-article-buffer
7961 (setq endp (or (gnus-article-next-page lines)
7962 (gnus-article-only-boring-p))))
7963 (when endp
7964 (cond ((or stop gnus-summary-stop-at-end-of-message)
7965 (gnus-message 3 "End of message"))
7966 (circular
7967 (gnus-summary-beginning-of-article))
7968 (lines
7969 (gnus-message 3 "End of message"))
7970 ((null lines)
7971 (if (and (eq gnus-summary-goto-unread 'never)
7972 (not (gnus-summary-last-article-p article)))
7973 (gnus-summary-next-article)
7974 (gnus-summary-next-unread-article))))))))
7975 (gnus-summary-recenter)
7976 (gnus-summary-position-point)))
7977
7978 (defun gnus-summary-prev-page (&optional lines move)
7979 "Show previous page of selected article.
7980 Argument LINES specifies lines to be scrolled down.
7981 If MOVE, move to the previous unread article if point is at
7982 the beginning of the buffer."
7983 (interactive "P")
7984 (let ((article (gnus-summary-article-number))
7985 (article-window (get-buffer-window gnus-article-buffer t))
7986 endp)
7987 (gnus-configure-windows 'article)
7988 (if (or (null gnus-current-article)
7989 (null gnus-article-current)
7990 (/= article (cdr gnus-article-current))
7991 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7992 ;; Selected subject is different from current article's.
7993 (gnus-summary-display-article article)
7994 (gnus-summary-recenter)
7995 (when article-window
7996 (gnus-eval-in-buffer-window gnus-article-buffer
7997 (setq endp (gnus-article-prev-page lines)))
7998 (when (and move endp)
7999 (cond (lines
8000 (gnus-message 3 "Beginning of message"))
8001 ((null lines)
8002 (if (and (eq gnus-summary-goto-unread 'never)
8003 (not (gnus-summary-first-article-p article)))
8004 (gnus-summary-prev-article)
8005 (gnus-summary-prev-unread-article))))))))
8006 (gnus-summary-position-point))
8007
8008 (defun gnus-summary-prev-page-or-article (&optional lines)
8009 "Show previous page of selected article.
8010 Argument LINES specifies lines to be scrolled down.
8011 If at the beginning of the article, go to the next article."
8012 (interactive "P")
8013 (gnus-summary-prev-page lines t))
8014
8015 (defun gnus-summary-scroll-up (lines)
8016 "Scroll up (or down) one line current article.
8017 Argument LINES specifies lines to be scrolled up (or down if negative).
8018 If no article is selected, then the current article will be selected first."
8019 (interactive "p")
8020 (gnus-configure-windows 'article)
8021 (gnus-summary-show-thread)
8022 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
8023 (gnus-eval-in-buffer-window gnus-article-buffer
8024 (cond ((> lines 0)
8025 (when (gnus-article-next-page lines)
8026 (gnus-message 3 "End of message")))
8027 ((< lines 0)
8028 (gnus-article-prev-page (- lines))))))
8029 (gnus-summary-recenter)
8030 (gnus-summary-position-point))
8031
8032 (defun gnus-summary-scroll-down (lines)
8033 "Scroll down (or up) one line current article.
8034 Argument LINES specifies lines to be scrolled down (or up if negative).
8035 If no article is selected, then the current article will be selected first."
8036 (interactive "p")
8037 (gnus-summary-scroll-up (- lines)))
8038
8039 (defun gnus-summary-next-same-subject ()
8040 "Select next article which has the same subject as current one."
8041 (interactive)
8042 (gnus-summary-next-article nil (gnus-summary-article-subject)))
8043
8044 (defun gnus-summary-prev-same-subject ()
8045 "Select previous article which has the same subject as current one."
8046 (interactive)
8047 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
8048
8049 (defun gnus-summary-next-unread-same-subject ()
8050 "Select next unread article which has the same subject as current one."
8051 (interactive)
8052 (gnus-summary-next-article t (gnus-summary-article-subject)))
8053
8054 (defun gnus-summary-prev-unread-same-subject ()
8055 "Select previous unread article which has the same subject as current one."
8056 (interactive)
8057 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8058
8059 (defun gnus-summary-first-unread-article ()
8060 "Select the first unread article.
8061 Return nil if there are no unread articles."
8062 (interactive)
8063 (prog1
8064 (when (gnus-summary-first-subject t)
8065 (gnus-summary-show-thread)
8066 (gnus-summary-first-subject t)
8067 (gnus-summary-display-article (gnus-summary-article-number)))
8068 (gnus-summary-position-point)))
8069
8070 (defun gnus-summary-first-unread-subject ()
8071 "Place the point on the subject line of the first unread article.
8072 Return nil if there are no unread articles."
8073 (interactive)
8074 (prog1
8075 (when (gnus-summary-first-subject t)
8076 (gnus-summary-show-thread)
8077 (gnus-summary-first-subject t))
8078 (gnus-summary-position-point)))
8079
8080 (defun gnus-summary-first-unseen-subject ()
8081 "Place the point on the subject line of the first unseen article.
8082 Return nil if there are no unseen articles."
8083 (interactive)
8084 (prog1
8085 (when (gnus-summary-first-subject nil nil t)
8086 (gnus-summary-show-thread)
8087 (gnus-summary-first-subject nil nil t))
8088 (gnus-summary-position-point)))
8089
8090 (defun gnus-summary-first-unseen-or-unread-subject ()
8091 "Place the point on the subject line of the first unseen and unread article.
8092 If all article have been seen, on the subject line of the first unread
8093 article."
8094 (interactive)
8095 (prog1
8096 (unless (when (gnus-summary-first-subject nil nil t)
8097 (gnus-summary-show-thread)
8098 (gnus-summary-first-subject nil nil t))
8099 (when (gnus-summary-first-subject t)
8100 (gnus-summary-show-thread)
8101 (gnus-summary-first-subject t)))
8102 (gnus-summary-position-point)))
8103
8104 (defun gnus-summary-first-article ()
8105 "Select the first article.
8106 Return nil if there are no articles."
8107 (interactive)
8108 (prog1
8109 (when (gnus-summary-first-subject)
8110 (gnus-summary-show-thread)
8111 (gnus-summary-first-subject)
8112 (gnus-summary-display-article (gnus-summary-article-number)))
8113 (gnus-summary-position-point)))
8114
8115 (defun gnus-summary-best-unread-article (&optional arg)
8116 "Select the unread article with the highest score.
8117 If given a prefix argument, select the next unread article that has a
8118 score higher than the default score."
8119 (interactive "P")
8120 (let ((article (if arg
8121 (gnus-summary-better-unread-subject)
8122 (gnus-summary-best-unread-subject))))
8123 (if article
8124 (gnus-summary-goto-article article)
8125 (error "No unread articles"))))
8126
8127 (defun gnus-summary-best-unread-subject ()
8128 "Select the unread subject with the highest score."
8129 (interactive)
8130 (let ((best -1000000)
8131 (data gnus-newsgroup-data)
8132 article score)
8133 (while data
8134 (and (gnus-data-unread-p (car data))
8135 (> (setq score
8136 (gnus-summary-article-score (gnus-data-number (car data))))
8137 best)
8138 (setq best score
8139 article (gnus-data-number (car data))))
8140 (setq data (cdr data)))
8141 (when article
8142 (gnus-summary-goto-subject article))
8143 (gnus-summary-position-point)
8144 article))
8145
8146 (defun gnus-summary-better-unread-subject ()
8147 "Select the first unread subject that has a score over the default score."
8148 (interactive)
8149 (let ((data gnus-newsgroup-data)
8150 article score)
8151 (while (and (setq article (gnus-data-number (car data)))
8152 (or (gnus-data-read-p (car data))
8153 (not (> (gnus-summary-article-score article)
8154 gnus-summary-default-score))))
8155 (setq data (cdr data)))
8156 (when article
8157 (gnus-summary-goto-subject article))
8158 (gnus-summary-position-point)
8159 article))
8160
8161 (defun gnus-summary-last-subject ()
8162 "Go to the last displayed subject line in the group."
8163 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8164 (when article
8165 (gnus-summary-goto-subject article))))
8166
8167 (defun gnus-summary-goto-article (article &optional all-headers force)
8168 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8169 If ALL-HEADERS is non-nil, no header lines are hidden.
8170 If FORCE, go to the article even if it isn't displayed. If FORCE
8171 is a number, it is the line the article is to be displayed on."
8172 (interactive
8173 (list
8174 (gnus-completing-read
8175 "Article number or Message-ID"
8176 (mapcar 'int-to-string gnus-newsgroup-limit))
8177 current-prefix-arg
8178 t))
8179 (prog1
8180 (if (and (stringp article)
8181 (string-match "@\\|%40" article))
8182 (gnus-summary-refer-article article)
8183 (when (stringp article)
8184 (setq article (string-to-number article)))
8185 (if (gnus-summary-goto-subject article force)
8186 (gnus-summary-display-article article all-headers)
8187 (gnus-message 4 "Couldn't go to article %s" article) nil))
8188 (gnus-summary-position-point)))
8189
8190 (defun gnus-summary-goto-last-article ()
8191 "Go to the previously read article."
8192 (interactive)
8193 (prog1
8194 (when gnus-last-article
8195 (gnus-summary-goto-article gnus-last-article nil t))
8196 (gnus-summary-position-point)))
8197
8198 (defun gnus-summary-pop-article (number)
8199 "Pop one article off the history and go to the previous.
8200 NUMBER articles will be popped off."
8201 (interactive "p")
8202 (let (to)
8203 (setq gnus-newsgroup-history
8204 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8205 (if to
8206 (gnus-summary-goto-article (car to) nil t)
8207 (error "Article history empty")))
8208 (gnus-summary-position-point))
8209
8210 ;; Summary commands and functions for limiting the summary buffer.
8211
8212 (defun gnus-summary-limit-to-articles (n)
8213 "Limit the summary buffer to the next N articles.
8214 If not given a prefix, use the process marked articles instead."
8215 (interactive "P")
8216 (prog1
8217 (let ((articles (gnus-summary-work-articles n)))
8218 (setq gnus-newsgroup-processable nil)
8219 (gnus-summary-limit articles))
8220 (gnus-summary-position-point)))
8221
8222 (defun gnus-summary-pop-limit (&optional total)
8223 "Restore the previous limit.
8224 If given a prefix, remove all limits."
8225 (interactive "P")
8226 (when total
8227 (setq gnus-newsgroup-limits
8228 (list (mapcar (lambda (h) (mail-header-number h))
8229 gnus-newsgroup-headers))))
8230 (unless gnus-newsgroup-limits
8231 (error "No limit to pop"))
8232 (prog1
8233 (gnus-summary-limit nil 'pop)
8234 (gnus-summary-position-point)))
8235
8236 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8237 "Limit the summary buffer to articles that have subjects that match a regexp.
8238 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8239 (interactive
8240 (list (read-string (if current-prefix-arg
8241 "Exclude subject (regexp): "
8242 "Limit to subject (regexp): "))
8243 nil current-prefix-arg))
8244 (unless header
8245 (setq header "subject"))
8246 (when (not (equal "" subject))
8247 (prog1
8248 (let ((articles (gnus-summary-find-matching
8249 (or header "subject") subject 'all nil nil
8250 not-matching)))
8251 (unless articles
8252 (error "Found no matches for \"%s\"" subject))
8253 (gnus-summary-limit articles))
8254 (gnus-summary-position-point))))
8255
8256 (defun gnus-summary-limit-to-author (from &optional not-matching)
8257 "Limit the summary buffer to articles that have authors that match a regexp.
8258 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8259 (interactive
8260 (list (let* ((header (gnus-summary-article-header))
8261 (default (and header (car (mail-header-parse-address
8262 (mail-header-from header))))))
8263 (read-string (concat (if current-prefix-arg
8264 "Exclude author (regexp"
8265 "Limit to author (regexp")
8266 (if default
8267 (concat ", default \"" default "\"): ")
8268 "): "))
8269 nil nil
8270 default))
8271 current-prefix-arg))
8272 (gnus-summary-limit-to-subject from "from" not-matching))
8273
8274 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8275 "Limit the summary buffer to articles with the given RECIPIENT.
8276
8277 If NOT-MATCHING, exclude RECIPIENT.
8278
8279 To and Cc headers are checked. You need to include them in
8280 `nnmail-extra-headers'."
8281 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8282 (interactive
8283 (list (read-string (format "%s recipient (regexp): "
8284 (if current-prefix-arg "Exclude" "Limit to")))
8285 current-prefix-arg))
8286 (when (not (equal "" recipient))
8287 (prog1 (let* ((to
8288 (if (memq 'To nnmail-extra-headers)
8289 (gnus-summary-find-matching
8290 (cons 'extra 'To) recipient 'all nil nil
8291 not-matching)
8292 (gnus-message
8293 1 "`To' isn't present in `nnmail-extra-headers'")
8294 (sit-for 1)
8295 nil))
8296 (cc
8297 (if (memq 'Cc nnmail-extra-headers)
8298 (gnus-summary-find-matching
8299 (cons 'extra 'Cc) recipient 'all nil nil
8300 not-matching)
8301 (gnus-message
8302 1 "`Cc' isn't present in `nnmail-extra-headers'")
8303 (sit-for 1)
8304 nil))
8305 (articles
8306 (if not-matching
8307 ;; We need the numbers that are in both lists:
8308 (mapcar (lambda (a)
8309 (and (memq a to) a))
8310 cc)
8311 (nconc to cc))))
8312 (unless articles
8313 (error "Found no matches for \"%s\"" recipient))
8314 (gnus-summary-limit articles))
8315 (gnus-summary-position-point))))
8316
8317 (defun gnus-summary-limit-to-address (address &optional not-matching)
8318 "Limit the summary buffer to articles with the given ADDRESS.
8319
8320 If NOT-MATCHING, exclude ADDRESS.
8321
8322 To, Cc and From headers are checked. You need to include `To' and `Cc'
8323 in `nnmail-extra-headers'."
8324 (interactive
8325 (list (read-string (format "%s address (regexp): "
8326 (if current-prefix-arg "Exclude" "Limit to")))
8327 current-prefix-arg))
8328 (when (not (equal "" address))
8329 (prog1 (let* ((to
8330 (if (memq 'To nnmail-extra-headers)
8331 (gnus-summary-find-matching
8332 (cons 'extra 'To) address 'all nil nil
8333 not-matching)
8334 (gnus-message
8335 1 "`To' isn't present in `nnmail-extra-headers'")
8336 (sit-for 1)
8337 t))
8338 (cc
8339 (if (memq 'Cc nnmail-extra-headers)
8340 (gnus-summary-find-matching
8341 (cons 'extra 'Cc) address 'all nil nil
8342 not-matching)
8343 (gnus-message
8344 1 "`Cc' isn't present in `nnmail-extra-headers'")
8345 (sit-for 1)
8346 t))
8347 (from
8348 (gnus-summary-find-matching "from" address
8349 'all nil nil not-matching))
8350 (articles
8351 (if not-matching
8352 ;; We need the numbers that are in all lists:
8353 (if (eq cc t)
8354 (if (eq to t)
8355 from
8356 (mapcar (lambda (a) (car (memq a from))) to))
8357 (if (eq to t)
8358 (mapcar (lambda (a) (car (memq a from))) cc)
8359 (mapcar (lambda (a) (car (memq a from)))
8360 (mapcar (lambda (a) (car (memq a to)))
8361 cc))))
8362 (nconc (if (eq to t) nil to)
8363 (if (eq cc t) nil cc)
8364 from))))
8365 (unless articles
8366 (error "Found no matches for \"%s\"" address))
8367 (gnus-summary-limit articles))
8368 (gnus-summary-position-point))))
8369
8370 (defun gnus-summary-limit-strange-charsets-predicate (header)
8371 (when (fboundp 'char-charset)
8372 (let ((string (concat (mail-header-subject header)
8373 (mail-header-from header)))
8374 charset found)
8375 (dotimes (i (1- (length string)))
8376 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8377 (when (string-match "unicode\\|big\\|japanese" charset)
8378 (setq found t)))
8379 found)))
8380
8381 (defun gnus-summary-limit-to-predicate (predicate)
8382 "Limit to articles where PREDICATE returns non-nil.
8383 PREDICATE will be called with the header structures of the
8384 articles."
8385 (let ((articles nil)
8386 (case-fold-search t))
8387 (dolist (header gnus-newsgroup-headers)
8388 (when (funcall predicate header)
8389 (push (mail-header-number header) articles)))
8390 (gnus-summary-limit (nreverse articles))))
8391
8392 (defun gnus-summary-limit-to-age (age &optional younger-p)
8393 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8394 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8395 articles that are younger than AGE days."
8396 (interactive
8397 (let ((younger current-prefix-arg)
8398 (days-got nil)
8399 days)
8400 (while (not days-got)
8401 (setq days (if younger
8402 (read-string "Limit to articles younger than (in days, older when negative): ")
8403 (read-string
8404 "Limit to articles older than (in days, younger when negative): ")))
8405 (when (> (length days) 0)
8406 (setq days (read days)))
8407 (if (numberp days)
8408 (progn
8409 (setq days-got t)
8410 (when (< days 0)
8411 (setq younger (not younger))
8412 (setq days (* days -1))))
8413 (message "Please enter a number.")
8414 (sleep-for 1)))
8415 (list days younger)))
8416 (prog1
8417 (let ((data gnus-newsgroup-data)
8418 (cutoff (days-to-time age))
8419 articles d date is-younger)
8420 (while (setq d (pop data))
8421 (when (and (vectorp (gnus-data-header d))
8422 (setq date (mail-header-date (gnus-data-header d))))
8423 (setq is-younger (time-less-p
8424 (time-since (gnus-date-get-time date))
8425 cutoff))
8426 (when (if younger-p
8427 is-younger
8428 (not is-younger))
8429 (push (gnus-data-number d) articles))))
8430 (gnus-summary-limit (nreverse articles)))
8431 (gnus-summary-position-point)))
8432
8433 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8434 "Limit the summary buffer to articles that match an `extra' header."
8435 (interactive
8436 (let ((header
8437 (intern
8438 (gnus-completing-read
8439 (if current-prefix-arg
8440 "Exclude extra header"
8441 "Limit extra header")
8442 (mapcar 'symbol-name gnus-extra-headers)
8443 t nil nil
8444 (symbol-name (car gnus-extra-headers))))))
8445 (list header
8446 (read-string (format "%s header %s (regexp): "
8447 (if current-prefix-arg "Exclude" "Limit to")
8448 header))
8449 current-prefix-arg)))
8450 (when (not (equal "" regexp))
8451 (prog1
8452 (let ((articles (gnus-summary-find-matching
8453 (cons 'extra header) regexp 'all nil nil
8454 not-matching)))
8455 (unless articles
8456 (error "Found no matches for \"%s\"" regexp))
8457 (gnus-summary-limit articles))
8458 (gnus-summary-position-point))))
8459
8460 (defun gnus-summary-limit-to-display-predicate ()
8461 "Limit the summary buffer to the predicated in the `display' group parameter."
8462 (interactive)
8463 (unless gnus-newsgroup-display
8464 (error "There is no `display' group parameter"))
8465 (let (articles)
8466 (dolist (gnus-number gnus-newsgroup-articles)
8467 (when (funcall gnus-newsgroup-display)
8468 (push gnus-number articles)))
8469 (gnus-summary-limit articles))
8470 (gnus-summary-position-point))
8471
8472 (defun gnus-summary-limit-to-unread (&optional all)
8473 "Limit the summary buffer to articles that are not marked as read.
8474 If ALL is non-nil, limit strictly to unread articles."
8475 (interactive "P")
8476 (if all
8477 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8478 (gnus-summary-limit-to-marks
8479 ;; Concat all the marks that say that an article is read and have
8480 ;; those removed.
8481 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8482 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8483 gnus-low-score-mark gnus-expirable-mark
8484 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8485 gnus-duplicate-mark)
8486 'reverse)))
8487
8488 (defun gnus-summary-limit-to-headers (match &optional reverse)
8489 "Limit the summary buffer to articles that have headers that match MATCH.
8490 If REVERSE (the prefix), limit to articles that don't match."
8491 (interactive "sMatch headers (regexp): \nP")
8492 (gnus-summary-limit-to-bodies match reverse t))
8493
8494 (declare-function article-goto-body "gnus-art" ())
8495
8496 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8497 "Limit the summary buffer to articles that have bodies that match MATCH.
8498 If REVERSE (the prefix), limit to articles that don't match."
8499 (interactive "sMatch body (regexp): \nP")
8500 (let ((articles nil)
8501 (gnus-select-article-hook nil) ;Disable hook.
8502 (gnus-article-prepare-hook nil)
8503 (gnus-use-article-prefetch nil)
8504 (gnus-keep-backlog nil)
8505 (gnus-break-pages nil)
8506 (gnus-summary-display-arrow nil)
8507 (gnus-updated-mode-lines nil)
8508 (gnus-auto-center-summary nil)
8509 (gnus-display-mime-function nil))
8510 (dolist (data gnus-newsgroup-data)
8511 (let (gnus-mark-article-hook)
8512 (gnus-summary-select-article t t nil (gnus-data-number data)))
8513 (with-current-buffer gnus-article-buffer
8514 (article-goto-body)
8515 (let* ((case-fold-search t)
8516 (found (if headersp
8517 (re-search-backward match nil t)
8518 (re-search-forward match nil t))))
8519 (when (or (and found
8520 (not reverse))
8521 (and (not found)
8522 reverse))
8523 (push (gnus-data-number data) articles)))))
8524 (if (not articles)
8525 (message "No messages matched")
8526 (gnus-summary-limit articles)))
8527 (gnus-summary-position-point))
8528
8529 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8530 "Limit the summary buffer to articles that aren't part on any thread.
8531 If THREADSP (the prefix), limit to articles that are in threads."
8532 (interactive "P")
8533 (let ((articles nil)
8534 thread-articles
8535 threads)
8536 (dolist (thread gnus-newsgroup-threads)
8537 (if (stringp (car thread))
8538 (dolist (thread (cdr thread))
8539 (push thread threads))
8540 (push thread threads)))
8541 (dolist (thread threads)
8542 (setq thread-articles (gnus-articles-in-thread thread))
8543 (when (or (and threadsp
8544 (> (length thread-articles) 1))
8545 (and (not threadsp)
8546 (= (length thread-articles) 1)))
8547 (setq articles (nconc thread-articles articles))))
8548 (if (not articles)
8549 (message "No messages matched")
8550 (gnus-summary-limit articles))
8551 (gnus-summary-position-point)))
8552
8553 (defun gnus-summary-limit-to-replied (&optional unreplied)
8554 "Limit the summary buffer to replied articles.
8555 If UNREPLIED (the prefix), limit to unreplied articles."
8556 (interactive "P")
8557 (if unreplied
8558 (gnus-summary-limit
8559 (gnus-set-difference gnus-newsgroup-articles
8560 gnus-newsgroup-replied))
8561 (gnus-summary-limit gnus-newsgroup-replied))
8562 (gnus-summary-position-point))
8563
8564 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8565 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8566 If REVERSE, limit the summary buffer to articles that are marked
8567 with MARKS. MARKS can either be a string of marks or a list of marks.
8568 Returns how many articles were removed."
8569 (interactive "sMarks: ")
8570 (gnus-summary-limit-to-marks marks t))
8571
8572 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8573 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8574 If REVERSE (the prefix), limit the summary buffer to articles that are
8575 not marked with MARKS. MARKS can either be a string of marks or a
8576 list of marks.
8577 Returns how many articles were removed."
8578 (interactive "sMarks: \nP")
8579 (prog1
8580 (let ((data gnus-newsgroup-data)
8581 (marks (if (listp marks) marks
8582 (append marks nil))) ; Transform to list.
8583 articles)
8584 (while data
8585 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8586 (memq (gnus-data-mark (car data)) marks))
8587 (push (gnus-data-number (car data)) articles))
8588 (setq data (cdr data)))
8589 (gnus-summary-limit articles))
8590 (gnus-summary-position-point)))
8591
8592 (defun gnus-summary-limit-to-score (score)
8593 "Limit to articles with score at or above SCORE."
8594 (interactive "NLimit to articles with score of at least: ")
8595 (let ((data gnus-newsgroup-data)
8596 articles)
8597 (while data
8598 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8599 score)
8600 (push (gnus-data-number (car data)) articles))
8601 (setq data (cdr data)))
8602 (prog1
8603 (gnus-summary-limit articles)
8604 (gnus-summary-position-point))))
8605
8606 (defun gnus-summary-limit-to-unseen ()
8607 "Limit to unseen articles."
8608 (interactive)
8609 (prog1
8610 (gnus-summary-limit gnus-newsgroup-unseen)
8611 (gnus-summary-position-point)))
8612
8613 (defun gnus-summary-limit-include-thread (id)
8614 "Display all the hidden articles that is in the thread with ID in it.
8615 When called interactively, ID is the Message-ID of the current
8616 article."
8617 (interactive (list (mail-header-id (gnus-summary-article-header))))
8618 (let ((articles (gnus-articles-in-thread
8619 (gnus-id-to-thread (gnus-root-id id))))
8620 ;;we REALLY want the whole thread---this prevents cut-threads
8621 ;;from removing the thread we want to include.
8622 (gnus-fetch-old-headers nil)
8623 (gnus-build-sparse-threads nil))
8624 (prog1
8625 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8626 (gnus-summary-limit-include-matching-articles
8627 "subject"
8628 (regexp-quote (gnus-simplify-subject-re
8629 (mail-header-subject (gnus-id-to-header id)))))
8630 (gnus-summary-position-point))))
8631
8632 (defun gnus-summary-limit-include-matching-articles (header regexp)
8633 "Display all the hidden articles that have HEADERs that match REGEXP."
8634 (interactive (list (read-string "Match on header: ")
8635 (read-string "Regexp: ")))
8636 (let ((articles (gnus-find-matching-articles header regexp)))
8637 (prog1
8638 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8639 (gnus-summary-position-point))))
8640
8641 (defun gnus-summary-insert-dormant-articles ()
8642 "Insert all the dormant articles for this group into the current buffer."
8643 (interactive)
8644 (let ((gnus-verbose (max 6 gnus-verbose)))
8645 (if (not gnus-newsgroup-dormant)
8646 (gnus-message 3 "No dormant articles for this group")
8647 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8648
8649 (defun gnus-summary-insert-ticked-articles ()
8650 "Insert ticked articles for this group into the current buffer."
8651 (interactive)
8652 (let ((gnus-verbose (max 6 gnus-verbose)))
8653 (if (not gnus-newsgroup-marked)
8654 (gnus-message 3 "No ticked articles for this group")
8655 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8656
8657 (defun gnus-summary-limit-include-dormant ()
8658 "Display all the hidden articles that are marked as dormant.
8659 Note that this command only works on a subset of the articles currently
8660 fetched for this group."
8661 (interactive)
8662 (unless gnus-newsgroup-dormant
8663 (error "There are no dormant articles in this group"))
8664 (prog1
8665 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8666 (gnus-summary-position-point)))
8667
8668 (defun gnus-summary-include-articles (articles)
8669 "Fetch the headers for ARTICLES and then display the summary lines."
8670 (let ((gnus-inhibit-demon t)
8671 (gnus-agent nil)
8672 (gnus-read-all-available-headers t))
8673 (setq gnus-newsgroup-headers
8674 (gnus-merge
8675 'list gnus-newsgroup-headers
8676 (gnus-fetch-headers articles nil t)
8677 'gnus-article-sort-by-number))
8678 (setq gnus-newsgroup-articles
8679 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8680 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8681
8682 (defun gnus-summary-limit-exclude-dormant ()
8683 "Hide all dormant articles."
8684 (interactive)
8685 (prog1
8686 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8687 (gnus-summary-position-point)))
8688
8689 (defun gnus-summary-limit-exclude-childless-dormant ()
8690 "Hide all dormant articles that have no children."
8691 (interactive)
8692 (let ((data (gnus-data-list t))
8693 articles d children)
8694 ;; Find all articles that are either not dormant or have
8695 ;; children.
8696 (while (setq d (pop data))
8697 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8698 (and (setq children
8699 (gnus-article-children (gnus-data-number d)))
8700 (let (found)
8701 (while children
8702 (when (memq (car children) articles)
8703 (setq children nil
8704 found t))
8705 (pop children))
8706 found)))
8707 (push (gnus-data-number d) articles)))
8708 ;; Do the limiting.
8709 (prog1
8710 (gnus-summary-limit articles)
8711 (gnus-summary-position-point))))
8712
8713 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8714 "Mark all unread excluded articles as read.
8715 If ALL, mark even excluded ticked and dormants as read."
8716 (interactive "P")
8717 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8718 (let ((articles (gnus-sorted-ndifference
8719 (sort
8720 (mapcar (lambda (h) (mail-header-number h))
8721 gnus-newsgroup-headers)
8722 '<)
8723 gnus-newsgroup-limit))
8724 article)
8725 (setq gnus-newsgroup-unreads
8726 (gnus-sorted-intersection gnus-newsgroup-unreads
8727 gnus-newsgroup-limit))
8728 (if all
8729 (setq gnus-newsgroup-dormant nil
8730 gnus-newsgroup-marked nil
8731 gnus-newsgroup-reads
8732 (nconc
8733 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8734 gnus-newsgroup-reads))
8735 (while (setq article (pop articles))
8736 (unless (or (memq article gnus-newsgroup-dormant)
8737 (memq article gnus-newsgroup-marked))
8738 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8739
8740 (defun gnus-summary-limit (articles &optional pop)
8741 (if pop
8742 ;; We pop the previous limit off the stack and use that.
8743 (setq articles (car gnus-newsgroup-limits)
8744 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8745 ;; We use the new limit, so we push the old limit on the stack.
8746 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8747 ;; Set the limit.
8748 (setq gnus-newsgroup-limit articles)
8749 (let ((total (length gnus-newsgroup-data))
8750 (data (gnus-data-find-list (gnus-summary-article-number)))
8751 (gnus-summary-mark-below nil) ; Inhibit this.
8752 found)
8753 ;; This will do all the work of generating the new summary buffer
8754 ;; according to the new limit.
8755 (gnus-summary-prepare)
8756 ;; Hide any threads, possibly.
8757 (gnus-summary-maybe-hide-threads)
8758 ;; Try to return to the article you were at, or one in the
8759 ;; neighborhood.
8760 (when data
8761 ;; We try to find some article after the current one.
8762 (while data
8763 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8764 (setq data nil
8765 found t))
8766 (setq data (cdr data))))
8767 (unless found
8768 ;; If there is no data, that means that we were after the last
8769 ;; article. The same goes when we can't find any articles
8770 ;; after the current one.
8771 (goto-char (point-max))
8772 (gnus-summary-find-prev))
8773 (gnus-set-mode-line 'summary)
8774 ;; We return how many articles were removed from the summary
8775 ;; buffer as a result of the new limit.
8776 (- total (length gnus-newsgroup-data))))
8777
8778 (defsubst gnus-invisible-cut-children (threads)
8779 (let ((num 0))
8780 (while threads
8781 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8782 (incf num))
8783 (pop threads))
8784 (< num 2)))
8785
8786 (defsubst gnus-cut-thread (thread)
8787 "Go forwards in the thread until we find an article that we want to display."
8788 (when (or (eq gnus-fetch-old-headers 'some)
8789 (eq gnus-fetch-old-headers 'invisible)
8790 (numberp gnus-fetch-old-headers)
8791 (eq gnus-build-sparse-threads 'some)
8792 (eq gnus-build-sparse-threads 'more))
8793 ;; Deal with old-fetched headers and sparse threads.
8794 (while (and
8795 thread
8796 (or
8797 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8798 (gnus-summary-article-ancient-p
8799 (mail-header-number (car thread))))
8800 (if (or (<= (length (cdr thread)) 1)
8801 (eq gnus-fetch-old-headers 'invisible))
8802 (setq gnus-newsgroup-limit
8803 (delq (mail-header-number (car thread))
8804 gnus-newsgroup-limit)
8805 thread (cadr thread))
8806 (when (gnus-invisible-cut-children (cdr thread))
8807 (let ((th (cdr thread)))
8808 (while th
8809 (if (memq (mail-header-number (caar th))
8810 gnus-newsgroup-limit)
8811 (setq thread (car th)
8812 th nil)
8813 (setq th (cdr th))))))))))
8814 thread)
8815
8816 (defun gnus-cut-threads (threads)
8817 "Cut off all uninteresting articles from the beginning of THREADS."
8818 (when (or (eq gnus-fetch-old-headers 'some)
8819 (eq gnus-fetch-old-headers 'invisible)
8820 (numberp gnus-fetch-old-headers)
8821 (eq gnus-build-sparse-threads 'some)
8822 (eq gnus-build-sparse-threads 'more))
8823 (let ((th threads))
8824 (while th
8825 (setcar th (gnus-cut-thread (car th)))
8826 (setq th (cdr th)))))
8827 ;; Remove nixed out threads.
8828 (delq nil threads))
8829
8830 (defun gnus-summary-initial-limit (&optional show-if-empty)
8831 "Figure out what the initial limit is supposed to be on group entry.
8832 This entails weeding out unwanted dormants, low-scored articles,
8833 fetch-old-headers verbiage, and so on."
8834 ;; Most groups have nothing to remove.
8835 (unless (or gnus-inhibit-limiting
8836 (and (null gnus-newsgroup-dormant)
8837 (eq gnus-newsgroup-display 'gnus-not-ignore)
8838 (not (eq gnus-fetch-old-headers 'some))
8839 (not (numberp gnus-fetch-old-headers))
8840 (not (eq gnus-fetch-old-headers 'invisible))
8841 (null gnus-summary-expunge-below)
8842 (not (eq gnus-build-sparse-threads 'some))
8843 (not (eq gnus-build-sparse-threads 'more))
8844 (null gnus-thread-expunge-below)))
8845 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8846 (setq gnus-newsgroup-limit nil)
8847 (mapatoms
8848 (lambda (node)
8849 (unless (car (symbol-value node))
8850 ;; These threads have no parents -- they are roots.
8851 (let ((nodes (cdr (symbol-value node)))
8852 thread)
8853 (while nodes
8854 (if (and gnus-thread-expunge-below
8855 (< (gnus-thread-total-score (car nodes))
8856 gnus-thread-expunge-below))
8857 (gnus-expunge-thread (pop nodes))
8858 (setq thread (pop nodes))
8859 (gnus-summary-limit-children thread))))))
8860 gnus-newsgroup-dependencies)
8861 ;; If this limitation resulted in an empty group, we might
8862 ;; pop the previous limit and use it instead.
8863 (when (and (not gnus-newsgroup-limit)
8864 show-if-empty)
8865 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8866 gnus-newsgroup-limit))
8867
8868 (defun gnus-summary-limit-children (thread)
8869 "Return 1 if this subthread is visible and 0 if it is not."
8870 ;; First we get the number of visible children to this thread. This
8871 ;; is done by recursing down the thread using this function, so this
8872 ;; will really go down to a leaf article first, before slowly
8873 ;; working its way up towards the root.
8874 (when thread
8875 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8876 (children
8877 (if (cdr thread)
8878 (apply '+ (mapcar 'gnus-summary-limit-children
8879 (cdr thread)))
8880 0))
8881 (number (mail-header-number (car thread)))
8882 score)
8883 (if (and
8884 (not (memq number gnus-newsgroup-marked))
8885 (or
8886 ;; If this article is dormant and has absolutely no visible
8887 ;; children, then this article isn't visible.
8888 (and (memq number gnus-newsgroup-dormant)
8889 (zerop children))
8890 ;; If this is "fetch-old-headered" and there is no
8891 ;; visible children, then we don't want this article.
8892 (and (or (eq gnus-fetch-old-headers 'some)
8893 (numberp gnus-fetch-old-headers))
8894 (gnus-summary-article-ancient-p number)
8895 (zerop children))
8896 ;; If this is "fetch-old-headered" and `invisible', then
8897 ;; we don't want this article.
8898 (and (eq gnus-fetch-old-headers 'invisible)
8899 (gnus-summary-article-ancient-p number))
8900 ;; If this is a sparsely inserted article with no children,
8901 ;; we don't want it.
8902 (and (eq gnus-build-sparse-threads 'some)
8903 (gnus-summary-article-sparse-p number)
8904 (zerop children))
8905 ;; If we use expunging, and this article is really
8906 ;; low-scored, then we don't want this article.
8907 (when (and gnus-summary-expunge-below
8908 (< (setq score
8909 (or (cdr (assq number gnus-newsgroup-scored))
8910 gnus-summary-default-score))
8911 gnus-summary-expunge-below))
8912 ;; We increase the expunge-tally here, but that has
8913 ;; nothing to do with the limits, really.
8914 (incf gnus-newsgroup-expunged-tally)
8915 ;; We also mark as read here, if that's wanted.
8916 (when (and gnus-summary-mark-below
8917 (< score gnus-summary-mark-below))
8918 (setq gnus-newsgroup-unreads
8919 (delq number gnus-newsgroup-unreads))
8920 (if gnus-newsgroup-auto-expire
8921 (push number gnus-newsgroup-expirable)
8922 (push (cons number gnus-low-score-mark)
8923 gnus-newsgroup-reads)))
8924 t)
8925 ;; Do the `display' group parameter.
8926 (and gnus-newsgroup-display
8927 (let ((gnus-number number))
8928 (not (funcall gnus-newsgroup-display))))))
8929 ;; Nope, invisible article.
8930 0
8931 ;; Ok, this article is to be visible, so we add it to the limit
8932 ;; and return 1.
8933 (push number gnus-newsgroup-limit)
8934 1))))
8935
8936 (defun gnus-expunge-thread (thread)
8937 "Mark all articles in THREAD as read."
8938 (let* ((number (mail-header-number (car thread))))
8939 (incf gnus-newsgroup-expunged-tally)
8940 ;; We also mark as read here, if that's wanted.
8941 (setq gnus-newsgroup-unreads
8942 (delq number gnus-newsgroup-unreads))
8943 (if gnus-newsgroup-auto-expire
8944 (push number gnus-newsgroup-expirable)
8945 (push (cons number gnus-low-score-mark)
8946 gnus-newsgroup-reads)))
8947 ;; Go recursively through all subthreads.
8948 (mapcar 'gnus-expunge-thread (cdr thread)))
8949
8950 ;; Summary article oriented commands
8951
8952 (defun gnus-summary-refer-parent-article (n)
8953 "Refer parent article N times.
8954 If N is negative, go to ancestor -N instead.
8955 The difference between N and the number of articles fetched is returned."
8956 (interactive "p")
8957 (let ((skip 1)
8958 error header ref)
8959 (when (not (natnump n))
8960 (setq skip (abs n)
8961 n 1))
8962 (while (and (> n 0)
8963 (not error))
8964 (setq header (gnus-summary-article-header))
8965 (if (and (eq (mail-header-number header)
8966 (cdr gnus-article-current))
8967 (equal gnus-newsgroup-name
8968 (car gnus-article-current)))
8969 ;; If we try to find the parent of the currently
8970 ;; displayed article, then we take a look at the actual
8971 ;; References header, since this is slightly more
8972 ;; reliable than the References field we got from the
8973 ;; server.
8974 (with-current-buffer gnus-original-article-buffer
8975 (nnheader-narrow-to-headers)
8976 (unless (setq ref (message-fetch-field "references"))
8977 (when (setq ref (message-fetch-field "in-reply-to"))
8978 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8979 (widen))
8980 (setq ref
8981 ;; It's not the current article, so we take a bet on
8982 ;; the value we got from the server.
8983 (mail-header-references header)))
8984 (if (and ref
8985 (not (equal ref "")))
8986 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8987 (gnus-message 1 "Couldn't find parent"))
8988 (gnus-message 1 "No references in article %d"
8989 (gnus-summary-article-number))
8990 (setq error t))
8991 (decf n))
8992 (gnus-summary-position-point)
8993 n))
8994
8995 (defun gnus-summary-refer-references ()
8996 "Fetch all articles mentioned in the References header.
8997 Return the number of articles fetched."
8998 (interactive)
8999 (let ((ref (mail-header-references (gnus-summary-article-header)))
9000 (current (gnus-summary-article-number))
9001 (n 0))
9002 (if (or (not ref)
9003 (equal ref ""))
9004 (error "No References in the current article")
9005 ;; For each Message-ID in the References header...
9006 (while (string-match "<[^>]*>" ref)
9007 (incf n)
9008 ;; ... fetch that article.
9009 (gnus-summary-refer-article
9010 (prog1 (match-string 0 ref)
9011 (setq ref (substring ref (match-end 0))))))
9012 (gnus-summary-goto-subject current)
9013 (gnus-summary-position-point)
9014 n)))
9015
9016 (defun gnus-delete-duplicate-headers (headers)
9017 ;; First remove leading duplicates.
9018 (while (and (> (length headers) 1)
9019 (= (mail-header-number (car headers))
9020 (mail-header-number (cadr headers))))
9021 (pop headers))
9022 ;; Then the rest.
9023 (let ((result headers))
9024 (while (> (length headers) 1)
9025 (if (= (mail-header-number (car headers))
9026 (mail-header-number (cadr headers)))
9027 (setcdr headers (cddr headers))
9028 (pop headers)))
9029 result))
9030
9031 (defun gnus-summary-refer-thread (&optional limit)
9032 "Fetch all articles in the current thread. For backends that
9033 know how to search for threads (currently only 'nnimap) a
9034 non-numeric prefix arg will use nnir to search the entire
9035 server; without a prefix arg only the current group is
9036 searched. If the variable `gnus-refer-thread-use-nnir' is
9037 non-nil the prefix arg has the reverse meaning. If no
9038 backend-specific 'request-thread function is available fetch
9039 LIMIT (the numerical prefix) old headers. If LIMIT is
9040 non-numeric or nil fetch the number specified by the
9041 `gnus-refer-thread-limit' variable."
9042 (interactive "P")
9043 (gnus-warp-to-article)
9044 (let* ((header (gnus-summary-article-header))
9045 (id (mail-header-id header))
9046 (gnus-inhibit-demon t)
9047 (gnus-summary-ignore-duplicates t)
9048 (gnus-read-all-available-headers t)
9049 (gnus-refer-thread-use-nnir
9050 (if (and (not (null limit)) (listp limit))
9051 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9052 (new-headers
9053 (if (gnus-check-backend-function
9054 'request-thread gnus-newsgroup-name)
9055 (gnus-request-thread header gnus-newsgroup-name)
9056 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9057 gnus-refer-thread-limit))
9058 (last (if (numberp limit)
9059 (min (+ (mail-header-number header)
9060 limit)
9061 gnus-newsgroup-highest)
9062 gnus-newsgroup-highest))
9063 (subject (gnus-simplify-subject
9064 (mail-header-subject header)))
9065 (refs (split-string (or (mail-header-references header)
9066 "")))
9067 (gnus-parse-headers-hook
9068 `(lambda () (goto-char (point-min))
9069 (keep-lines
9070 (regexp-opt ',(append refs (list id subject)))))))
9071 (gnus-fetch-headers (list last) (if (numberp limit)
9072 (* 2 limit) limit) t))))
9073 article-ids new-unreads)
9074 (when (listp new-headers)
9075 (dolist (header new-headers)
9076 (push (mail-header-number header) article-ids))
9077 (setq article-ids (nreverse article-ids))
9078 (setq new-unreads
9079 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9080 (setq gnus-newsgroup-unselected
9081 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9082 (setq gnus-newsgroup-unreads
9083 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9084 (setq gnus-newsgroup-headers
9085 (gnus-delete-duplicate-headers
9086 (gnus-merge
9087 'list gnus-newsgroup-headers new-headers
9088 'gnus-article-sort-by-number)))
9089 (setq gnus-newsgroup-articles
9090 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9091 (gnus-summary-limit-include-thread id)))
9092 (gnus-summary-show-thread))
9093
9094 (defun gnus-summary-open-group-with-article (message-id)
9095 "Open a group containing the article with the given MESSAGE-ID."
9096 (interactive "sMessage-ID: ")
9097 (require 'nndoc)
9098 (with-temp-buffer
9099 ;; Prepare a dummy article
9100 (erase-buffer)
9101 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9102
9103 ;; Prepare pretty modelines for summary and article buffers
9104 (let ((gnus-summary-mode-line-format "Found %G")
9105 (gnus-article-mode-line-format
9106 ;; Group names just get in the way here, especially the
9107 ;; abbreviated ones
9108 (if (string-match "%[gG]" gnus-article-mode-line-format)
9109 (concat (substring gnus-article-mode-line-format
9110 0 (match-beginning 0))
9111 (substring gnus-article-mode-line-format (match-end 0)))
9112 gnus-article-mode-line-format)))
9113
9114 ;; Build an ephemeral group containing the dummy article (hidden)
9115 (gnus-group-read-ephemeral-group
9116 message-id
9117 `(nndoc ,message-id
9118 (nndoc-address ,(current-buffer))
9119 (nndoc-article-type mbox))
9120 :activate
9121 (cons (current-buffer) gnus-current-window-configuration)
9122 (not :request-only)
9123 '(-1) ; :select-articles
9124 (not :parameters)
9125 0)) ; :number
9126 ;; Fetch the desired article
9127 (gnus-summary-refer-article message-id)))
9128
9129 (defun gnus-summary-refer-article (message-id)
9130 "Fetch an article specified by MESSAGE-ID."
9131 (interactive "sMessage-ID: ")
9132 (gnus-warp-to-article)
9133 (when (and (stringp message-id)
9134 (not (zerop (length message-id))))
9135 (setq message-id (gnus-replace-in-string message-id " " ""))
9136 ;; Construct the correct Message-ID if necessary.
9137 ;; Suggested by tale@pawl.rpi.edu.
9138 (unless (string-match "^<" message-id)
9139 (setq message-id (concat "<" message-id)))
9140 (unless (string-match ">$" message-id)
9141 (setq message-id (concat message-id ">")))
9142 ;; People often post MIDs from URLs, so unhex it:
9143 (unless (string-match "@" message-id)
9144 (setq message-id (gnus-url-unhex-string message-id)))
9145 (let* ((header (gnus-id-to-header message-id))
9146 (sparse (and header
9147 (gnus-summary-article-sparse-p
9148 (mail-header-number header))
9149 (memq (mail-header-number header)
9150 gnus-newsgroup-limit)))
9151 number)
9152 (cond
9153 ;; If the article is present in the buffer we just go to it.
9154 ((and header
9155 (or (not (gnus-summary-article-sparse-p
9156 (mail-header-number header)))
9157 sparse))
9158 (prog1
9159 (gnus-summary-goto-article
9160 (mail-header-number header) nil t)
9161 (when sparse
9162 (gnus-summary-update-article (mail-header-number header)))))
9163 (t
9164 ;; We fetch the article.
9165 (catch 'found
9166 (dolist (gnus-override-method (gnus-refer-article-methods))
9167 (when (and (gnus-check-server gnus-override-method)
9168 ;; Fetch the header,
9169 (setq number (gnus-summary-insert-subject message-id)))
9170 ;; and display the article.
9171 (gnus-summary-select-article nil nil nil number)
9172 (throw 'found t)))
9173 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9174
9175 (defun gnus-refer-article-methods ()
9176 "Return a list of referable methods."
9177 (cond
9178 ;; No method, so we default to current and native.
9179 ((null gnus-refer-article-method)
9180 (list gnus-current-select-method gnus-select-method))
9181 ;; Current.
9182 ((eq 'current gnus-refer-article-method)
9183 (list gnus-current-select-method))
9184 ;; List of select methods.
9185 ((not (and (symbolp (car gnus-refer-article-method))
9186 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9187 (let (out)
9188 (dolist (method gnus-refer-article-method)
9189 (push (if (eq 'current method)
9190 gnus-current-select-method
9191 (if (eq 'nnir (car method))
9192 (list
9193 'nnir
9194 (or (cadr method)
9195 (gnus-method-to-server gnus-current-select-method)))
9196 method))
9197 out))
9198 (nreverse out)))
9199 ;; One single select method.
9200 (t
9201 (list gnus-refer-article-method))))
9202
9203 (defun gnus-summary-edit-parameters ()
9204 "Edit the group parameters of the current group."
9205 (interactive)
9206 (gnus-group-edit-group gnus-newsgroup-name 'params))
9207
9208 (defun gnus-summary-customize-parameters ()
9209 "Customize the group parameters of the current group."
9210 (interactive)
9211 (gnus-group-customize gnus-newsgroup-name))
9212
9213 (defun gnus-summary-enter-digest-group (&optional force)
9214 "Enter an nndoc group based on the current article.
9215 If FORCE, force a digest interpretation. If not, try to guess
9216 what the document format is.
9217
9218 To control what happens when you exit the group, see the
9219 `gnus-auto-select-on-ephemeral-exit' variable."
9220 (interactive "P")
9221 (let ((conf gnus-current-window-configuration))
9222 (save-window-excursion
9223 (save-excursion
9224 (let (gnus-article-prepare-hook
9225 gnus-display-mime-function
9226 gnus-break-pages)
9227 (gnus-summary-select-article))))
9228 (setq gnus-current-window-configuration conf)
9229 (let* ((name (format "%s-%d"
9230 (gnus-group-prefixed-name
9231 gnus-newsgroup-name (list 'nndoc ""))
9232 (with-current-buffer gnus-summary-buffer
9233 gnus-current-article)))
9234 (ogroup gnus-newsgroup-name)
9235 (params (append (gnus-info-params (gnus-get-info ogroup))
9236 (list (cons 'to-group ogroup))
9237 (list (cons 'parent-group ogroup))
9238 (list (cons 'save-article-group ogroup))))
9239 (case-fold-search t)
9240 (buf (current-buffer))
9241 dig to-address charset)
9242 (with-current-buffer gnus-original-article-buffer
9243 ;; Have the digest group inherit the main mail address of
9244 ;; the parent article.
9245 (when (setq to-address (or (gnus-fetch-field "reply-to")
9246 (gnus-fetch-field "from")))
9247 (setq params
9248 (append
9249 params
9250 (list (cons 'to-address
9251 (funcall gnus-decode-encoded-address-function
9252 to-address))))))
9253 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9254 (insert-buffer-substring gnus-original-article-buffer)
9255 (narrow-to-region
9256 (goto-char (point-min))
9257 (or (search-forward "\n\n" nil t) (point)))
9258 ;; Remove lines that may lead nndoc to misinterpret the
9259 ;; document type.
9260 (goto-char (point-min))
9261 (delete-matching-lines "^Path:\\|^From ")
9262 ;; Parse charset, and decode content transfer encoding.
9263 (setq charset (mail-content-type-get
9264 (mail-header-parse-content-type
9265 (or (gnus-fetch-field "content-type") ""))
9266 'charset))
9267 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9268 (when encoding
9269 (message-remove-header "content-transfer-encoding")
9270 (goto-char (point-max))
9271 (widen)
9272 (narrow-to-region (point) (point-max))
9273 (mm-decode-content-transfer-encoding
9274 (intern (downcase (mail-header-strip encoding))))))
9275 (widen))
9276 (unwind-protect
9277 (if (let ((gnus-newsgroup-ephemeral-charset
9278 (if charset
9279 (intern (downcase (gnus-strip-whitespace charset)))
9280 gnus-newsgroup-charset))
9281 (gnus-newsgroup-ephemeral-ignored-charsets
9282 gnus-newsgroup-ignored-charsets))
9283 (gnus-group-read-ephemeral-group
9284 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9285 (nndoc-article-type
9286 ,(if force 'mbox 'guess)))
9287 t nil nil nil
9288 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9289 "ADAPT")))))
9290 ;; Make all postings to this group go to the parent group.
9291 (nconc (gnus-info-params (gnus-get-info name))
9292 params)
9293 ;; Couldn't select this doc group.
9294 (switch-to-buffer buf)
9295 (gnus-set-global-variables)
9296 (gnus-configure-windows 'summary)
9297 (gnus-message 3 "Article couldn't be entered?"))
9298 (kill-buffer dig)))))
9299
9300 (defun gnus-summary-read-document (n)
9301 "Open a new group based on the current article(s).
9302 This will allow you to read digests and other similar
9303 documents as newsgroups.
9304 Obeys the standard process/prefix convention."
9305 (interactive "P")
9306 (let* ((ogroup gnus-newsgroup-name)
9307 (params (append (gnus-info-params (gnus-get-info ogroup))
9308 (list (cons 'to-group ogroup))))
9309 group egroup groups vgroup)
9310 (dolist (article (gnus-summary-work-articles n))
9311 (setq group (format "%s-%d" gnus-newsgroup-name article))
9312 (gnus-summary-remove-process-mark article)
9313 (when (gnus-summary-display-article article)
9314 (save-excursion ;;What for?
9315 (with-temp-buffer
9316 (insert-buffer-substring gnus-original-article-buffer)
9317 ;; Remove some headers that may lead nndoc to make
9318 ;; the wrong guess.
9319 (message-narrow-to-head)
9320 (goto-char (point-min))
9321 (delete-matching-lines "^Path:\\|^From ")
9322 (widen)
9323 (if (setq egroup
9324 (gnus-group-read-ephemeral-group
9325 group `(nndoc ,group (nndoc-address ,(current-buffer))
9326 (nndoc-article-type guess))
9327 t nil t))
9328 (progn
9329 ;; Make all postings to this group go to the parent group.
9330 (nconc (gnus-info-params (gnus-get-info egroup))
9331 params)
9332 (push egroup groups))
9333 ;; Couldn't select this doc group.
9334 (gnus-error 3 "Article couldn't be entered"))))))
9335 ;; Now we have selected all the documents.
9336 (cond
9337 ((not groups)
9338 (error "None of the articles could be interpreted as documents"))
9339 ((gnus-group-read-ephemeral-group
9340 (setq vgroup (format
9341 "nnvirtual:%s-%s" gnus-newsgroup-name
9342 (format-time-string "%Y%m%dT%H%M%S")))
9343 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9344 t
9345 (cons (current-buffer) 'summary)))
9346 (t
9347 (error "Couldn't select virtual nndoc group")))))
9348
9349 (defun gnus-summary-widget-forward (arg)
9350 "Move point to the next field or button in the article.
9351 With optional ARG, move across that many fields."
9352 (interactive "p")
9353 (gnus-summary-select-article)
9354 (gnus-configure-windows 'article)
9355 (select-window (gnus-get-buffer-window gnus-article-buffer))
9356 (widget-forward arg))
9357
9358 (defun gnus-summary-widget-backward (arg)
9359 "Move point to the previous field or button in the article.
9360 With optional ARG, move across that many fields."
9361 (interactive "p")
9362 (gnus-summary-select-article)
9363 (gnus-configure-windows 'article)
9364 (select-window (gnus-get-buffer-window gnus-article-buffer))
9365 (unless (widget-at (point))
9366 (goto-char (point-max)))
9367 (widget-backward arg))
9368
9369 (defun gnus-summary-isearch-article (&optional regexp-p)
9370 "Do incremental search forward on the current article.
9371 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9372 (interactive "P")
9373 (gnus-summary-select-article)
9374 (gnus-configure-windows 'article)
9375 (gnus-eval-in-buffer-window gnus-article-buffer
9376 (save-restriction
9377 (widen)
9378 (isearch-forward regexp-p))))
9379
9380 (defun gnus-summary-repeat-search-article-forward ()
9381 "Repeat the previous search forwards."
9382 (interactive)
9383 (unless gnus-last-search-regexp
9384 (error "No previous search"))
9385 (gnus-summary-search-article-forward gnus-last-search-regexp))
9386
9387 (defun gnus-summary-repeat-search-article-backward ()
9388 "Repeat the previous search backwards."
9389 (interactive)
9390 (unless gnus-last-search-regexp
9391 (error "No previous search"))
9392 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9393
9394 (defun gnus-summary-search-article-forward (regexp &optional backward)
9395 "Search for an article containing REGEXP forward.
9396 If BACKWARD, search backward instead."
9397 (interactive
9398 (list (read-string
9399 (format "Search article %s (regexp%s): "
9400 (if current-prefix-arg "backward" "forward")
9401 (if gnus-last-search-regexp
9402 (concat ", default " gnus-last-search-regexp)
9403 "")))
9404 current-prefix-arg))
9405 (if (string-equal regexp "")
9406 (setq regexp (or gnus-last-search-regexp ""))
9407 (setq gnus-last-search-regexp regexp)
9408 (setq gnus-article-before-search gnus-current-article))
9409 ;; Intentionally set gnus-last-article.
9410 (setq gnus-last-article gnus-article-before-search)
9411 (let ((gnus-last-article gnus-last-article))
9412 (if (gnus-summary-search-article regexp backward)
9413 (gnus-summary-show-thread)
9414 (signal 'search-failed (list regexp)))))
9415
9416 (defun gnus-summary-search-article-backward (regexp)
9417 "Search for an article containing REGEXP backward."
9418 (interactive
9419 (list (read-string
9420 (format "Search article backward (regexp%s): "
9421 (if gnus-last-search-regexp
9422 (concat ", default " gnus-last-search-regexp)
9423 "")))))
9424 (gnus-summary-search-article-forward regexp 'backward))
9425
9426 (defun gnus-summary-search-article (regexp &optional backward)
9427 "Search for an article containing REGEXP.
9428 Optional argument BACKWARD means do search for backward.
9429 `gnus-select-article-hook' is not called during the search."
9430 ;; We have to require this here to make sure that the following
9431 ;; dynamic binding isn't shadowed by autoloading.
9432 (require 'gnus-async)
9433 (require 'gnus-art)
9434 (let ((gnus-select-article-hook nil) ;Disable hook.
9435 (gnus-article-prepare-hook nil)
9436 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9437 (gnus-use-article-prefetch nil)
9438 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
9439 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9440 (gnus-visual nil)
9441 (gnus-keep-backlog nil)
9442 (gnus-break-pages nil)
9443 (gnus-summary-display-arrow nil)
9444 (gnus-updated-mode-lines nil)
9445 (gnus-auto-center-summary nil)
9446 (sum (current-buffer))
9447 (gnus-display-mime-function nil)
9448 (found nil)
9449 point)
9450 (gnus-save-hidden-threads
9451 (gnus-summary-select-article)
9452 (set-buffer gnus-article-buffer)
9453 (goto-char (window-point (get-buffer-window (current-buffer))))
9454 (when backward
9455 (forward-line -1))
9456 (while (not found)
9457 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9458 (if (if backward
9459 (re-search-backward regexp nil t)
9460 (re-search-forward regexp nil t))
9461 ;; We found the regexp.
9462 (progn
9463 (setq found 'found)
9464 (beginning-of-line)
9465 (set-window-start
9466 (get-buffer-window (current-buffer))
9467 (point))
9468 (forward-line 1)
9469 (set-window-point
9470 (get-buffer-window (current-buffer))
9471 (point))
9472 (set-buffer sum)
9473 (setq point (point)))
9474 ;; We didn't find it, so we go to the next article.
9475 (set-buffer sum)
9476 (setq found 'not)
9477 (while (eq found 'not)
9478 (if (not (if backward (gnus-summary-find-prev)
9479 (gnus-summary-find-next)))
9480 ;; No more articles.
9481 (setq found t)
9482 ;; Select the next article and adjust point.
9483 (unless (gnus-summary-article-sparse-p
9484 (gnus-summary-article-number))
9485 (setq found nil)
9486 (gnus-summary-select-article)
9487 (set-buffer gnus-article-buffer)
9488 (widen)
9489 (goto-char (if backward (point-max) (point-min))))))))
9490 (gnus-message 7 ""))
9491 ;; Return whether we found the regexp.
9492 (when (eq found 'found)
9493 (goto-char point)
9494 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9495 (gnus-summary-show-thread)
9496 (gnus-summary-goto-subject gnus-current-article)
9497 (gnus-summary-position-point)
9498 t)))
9499
9500 (defun gnus-find-matching-articles (header regexp)
9501 "Return a list of all articles that match REGEXP on HEADER.
9502 This search includes all articles in the current group that Gnus has
9503 fetched headers for, whether they are displayed or not."
9504 (let ((articles nil)
9505 ;; Can't eta-reduce because it's a macro.
9506 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9507 (case-fold-search t))
9508 (dolist (header gnus-newsgroup-headers)
9509 (when (string-match regexp (funcall func header))
9510 (push (mail-header-number header) articles)))
9511 (nreverse articles)))
9512
9513 (defun gnus-summary-find-matching (header regexp &optional backward unread
9514 not-case-fold not-matching)
9515 "Return a list of all articles that match REGEXP on HEADER.
9516 The search stars on the current article and goes forwards unless
9517 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9518 If UNREAD is non-nil, only unread articles will
9519 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9520 in the comparisons. If NOT-MATCHING, return a list of all articles that
9521 not match REGEXP on HEADER."
9522 (let ((case-fold-search (not not-case-fold))
9523 articles d func)
9524 (if (consp header)
9525 (if (eq (car header) 'extra)
9526 (setq func
9527 `(lambda (h)
9528 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9529 "")))
9530 (error "%s is an invalid header" header))
9531 (unless (fboundp (intern (concat "mail-header-" header)))
9532 (error "%s is not a valid header" header))
9533 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9534 (dolist (d (if (eq backward 'all)
9535 gnus-newsgroup-data
9536 (gnus-data-find-list
9537 (gnus-summary-article-number)
9538 (gnus-data-list backward))))
9539 (when (and (or (not unread) ; We want all articles...
9540 (gnus-data-unread-p d)) ; Or just unreads.
9541 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9542 (if not-matching
9543 (not (string-match
9544 regexp
9545 (funcall func (gnus-data-header d))))
9546 (string-match regexp
9547 (funcall func (gnus-data-header d)))))
9548 (push (gnus-data-number d) articles))) ; Success!
9549 (nreverse articles)))
9550
9551 (defun gnus-summary-execute-command (header regexp command &optional backward)
9552 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9553 If HEADER is an empty string (or nil), the match is done on the entire
9554 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9555 (interactive
9556 (list (let ((completion-ignore-case t))
9557 (gnus-completing-read
9558 "Header name"
9559 (mapcar 'symbol-name
9560 (append
9561 '(Number Subject From Lines Date
9562 Message-ID Xref References Body)
9563 gnus-extra-headers))
9564 'require-match))
9565 (read-string "Regexp: ")
9566 (read-key-sequence "Command: ")
9567 current-prefix-arg))
9568 (when (equal header "Body")
9569 (setq header ""))
9570 ;; Hidden thread subtrees must be searched as well.
9571 (gnus-summary-show-all-threads)
9572 ;; We don't want to change current point nor window configuration.
9573 (save-excursion
9574 (save-window-excursion
9575 (let (gnus-visual
9576 gnus-treat-strip-trailing-blank-lines
9577 gnus-treat-strip-leading-blank-lines
9578 gnus-treat-strip-multiple-blank-lines
9579 gnus-treat-hide-boring-headers
9580 gnus-treat-fold-newsgroups
9581 gnus-article-prepare-hook)
9582 (gnus-message 6 "Executing %s..." (key-description command))
9583 ;; We'd like to execute COMMAND interactively so as to give arguments.
9584 (gnus-execute header regexp
9585 `(call-interactively ',(key-binding command))
9586 backward)
9587 (gnus-message 6 "Executing %s...done" (key-description command))))))
9588
9589 (defun gnus-summary-beginning-of-article ()
9590 "Scroll the article back to the beginning."
9591 (interactive)
9592 (gnus-summary-select-article)
9593 (gnus-configure-windows 'article)
9594 (gnus-eval-in-buffer-window gnus-article-buffer
9595 (widen)
9596 (goto-char (point-min))
9597 (when gnus-break-pages
9598 (gnus-narrow-to-page))))
9599
9600 (defun gnus-summary-end-of-article ()
9601 "Scroll to the end of the article."
9602 (interactive)
9603 (gnus-summary-select-article)
9604 (gnus-configure-windows 'article)
9605 (gnus-eval-in-buffer-window gnus-article-buffer
9606 (widen)
9607 (goto-char (point-max))
9608 (recenter -3)
9609 (when gnus-break-pages
9610 (gnus-narrow-to-page))))
9611
9612 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9613 "Truncate to LEN and quote all \"(\"'s in STRING."
9614 (gnus-replace-in-string (if (and len (> (length string) len))
9615 (substring string 0 len)
9616 string)
9617 "[()]" "\\\\\\&"))
9618
9619 (defun gnus-summary-print-article (&optional filename n)
9620 "Generate and print a PostScript image of the process-marked (mail) articles.
9621
9622 If used interactively, print the current article if none are
9623 process-marked. With prefix arg, prompt the user for the name of the
9624 file to save in.
9625
9626 When used from Lisp, accept two optional args FILENAME and N. N means
9627 to print the next N articles. If N is negative, print the N previous
9628 articles. If N is nil and articles have been marked with the process
9629 mark, print these instead.
9630
9631 If the optional first argument FILENAME is nil, send the image to the
9632 printer. If FILENAME is a string, save the PostScript image in a file with
9633 that name. If FILENAME is a number, prompt the user for the name of the file
9634 to save in."
9635 (interactive (list (ps-print-preprint current-prefix-arg)))
9636 (dolist (article (gnus-summary-work-articles n))
9637 (gnus-summary-select-article nil nil 'pseudo article)
9638 (gnus-eval-in-buffer-window gnus-article-buffer
9639 (gnus-print-buffer))
9640 (gnus-summary-remove-process-mark article))
9641 (ps-despool filename))
9642
9643 (defun gnus-print-buffer ()
9644 (let ((ps-left-header
9645 (list
9646 (concat "("
9647 (gnus-summary-print-truncate-and-quote
9648 (mail-header-subject gnus-current-headers)
9649 66) ")")
9650 (concat "("
9651 (gnus-summary-print-truncate-and-quote
9652 (mail-header-from gnus-current-headers)
9653 45) ")")))
9654 (ps-right-header
9655 (list
9656 "/pagenumberstring load"
9657 (concat "("
9658 (mail-header-date gnus-current-headers) ")"))))
9659 (gnus-run-hooks 'gnus-ps-print-hook)
9660 (save-excursion
9661 (if ps-print-color-p
9662 (ps-spool-buffer-with-faces)
9663 (ps-spool-buffer)))))
9664
9665 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9666
9667 (defun gnus-summary-show-complete-article ()
9668 "Show a complete version of the current article.
9669 This is only useful if you're looking at a partial version of the
9670 article currently."
9671 (interactive)
9672 (let ((gnus-keep-backlog nil)
9673 (gnus-use-cache nil)
9674 (gnus-agent nil)
9675 (variable (intern
9676 (format "%s-fetch-partial-articles"
9677 (car (gnus-find-method-for-group
9678 gnus-newsgroup-name)))
9679 obarray))
9680 old-val)
9681 (unwind-protect
9682 (progn
9683 (setq old-val (symbol-value variable))
9684 (set variable nil)
9685 (gnus-flush-original-article-buffer)
9686 (gnus-summary-show-article))
9687 (set variable old-val))))
9688
9689 (defun gnus-summary-show-article (&optional arg)
9690 "Force redisplaying of the current article.
9691 If ARG (the prefix) is a number, show the article with the charset
9692 defined in `gnus-summary-show-article-charset-alist', or the charset
9693 input.
9694 If ARG (the prefix) is non-nil and not a number, show the article,
9695 but without running any of the article treatment functions
9696 article. Normally, the keystroke is `C-u g'. When using `C-u
9697 C-u g', show the raw article."
9698 (interactive "P")
9699 (cond
9700 ((numberp arg)
9701 (gnus-summary-show-article t)
9702 (let ((gnus-newsgroup-charset
9703 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9704 (mm-read-coding-system
9705 "View as charset: " ;; actually it is coding system.
9706 (with-current-buffer gnus-article-buffer
9707 (mm-detect-coding-region (point) (point-max))))))
9708 (gnus-newsgroup-ignored-charsets 'gnus-all))
9709 (gnus-summary-select-article nil 'force)
9710 (let ((deps gnus-newsgroup-dependencies)
9711 head header lines)
9712 (with-current-buffer gnus-original-article-buffer
9713 (save-restriction
9714 (message-narrow-to-head)
9715 (setq head (buffer-string))
9716 (goto-char (point-min))
9717 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9718 (goto-char (point-max))
9719 (widen)
9720 (setq lines (1- (count-lines (point) (point-max))))))
9721 (with-temp-buffer
9722 (insert (format "211 %d Article retrieved.\n"
9723 (cdr gnus-article-current)))
9724 (insert head)
9725 (if lines (insert (format "Lines: %d\n" lines)))
9726 (insert ".\n")
9727 (let ((nntp-server-buffer (current-buffer)))
9728 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9729 (gnus-data-set-header
9730 (gnus-data-find (cdr gnus-article-current))
9731 header)
9732 (gnus-summary-update-article-line
9733 (cdr gnus-article-current) header)
9734 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9735 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9736 ((not arg)
9737 ;; Select the article the normal way.
9738 (if (eq mm-text-html-renderer 'shr)
9739 (progn
9740 (require 'shr)
9741 (let ((shr-ignore-cache t))
9742 (gnus-summary-select-article nil 'force)))
9743 (gnus-summary-select-article nil 'force)))
9744 ((equal arg '(16))
9745 ;; C-u C-u g
9746 (let ((gnus-inhibit-article-treatments t))
9747 (gnus-summary-select-article nil 'force)))
9748 (t
9749 ;; We have to require this here to make sure that the following
9750 ;; dynamic binding isn't shadowed by autoloading.
9751 (require 'gnus-async)
9752 (require 'gnus-art)
9753 ;; Bind the article treatment functions to nil.
9754 (let ((gnus-have-all-headers t)
9755 gnus-article-prepare-hook
9756 gnus-article-decode-hook
9757 gnus-display-mime-function
9758 gnus-break-pages)
9759 ;; Destroy any MIME parts.
9760 (when (gnus-buffer-live-p gnus-article-buffer)
9761 (with-current-buffer gnus-article-buffer
9762 (gnus-article-stop-animations)
9763 (gnus-stop-downloads)
9764 (mm-destroy-parts gnus-article-mime-handles)
9765 ;; Set it to nil for safety reason.
9766 (setq gnus-article-mime-handle-alist nil)
9767 (setq gnus-article-mime-handles nil)))
9768 (gnus-summary-select-article nil 'force))))
9769 (gnus-summary-goto-subject gnus-current-article)
9770 (gnus-summary-position-point))
9771
9772 (defun gnus-summary-show-raw-article ()
9773 "Show the raw article without any article massaging functions being run."
9774 (interactive)
9775 (gnus-summary-show-article t))
9776
9777 (defun gnus-summary-verbose-headers (&optional arg)
9778 "Toggle permanent full header display.
9779 If ARG is a positive number, turn header display on.
9780 If ARG is a negative number, turn header display off."
9781 (interactive "P")
9782 (setq gnus-show-all-headers
9783 (cond ((or (not (numberp arg))
9784 (zerop arg))
9785 (not gnus-show-all-headers))
9786 ((natnump arg)
9787 t)))
9788 (gnus-summary-show-article))
9789
9790 (declare-function article-narrow-to-head "gnus-art" ())
9791 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9792 (declare-function gnus-delete-wash-type "gnus-art" (type))
9793 (declare-function gnus-mime-buttonize-attachments-in-header
9794 "gnus-art" (&optional interactive))
9795
9796 (defun gnus-summary-toggle-header (&optional arg)
9797 "Show the headers if they are hidden, or hide them if they are shown.
9798 If ARG is a positive number, show the entire header.
9799 If ARG is a negative number, hide the unwanted header lines."
9800 (interactive "P")
9801 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9802 (get-buffer-window gnus-article-buffer t))))
9803 (with-current-buffer gnus-article-buffer
9804 (widen)
9805 (article-narrow-to-head)
9806 (let* ((inhibit-read-only t)
9807 (inhibit-point-motion-hooks t)
9808 (hidden (if (numberp arg)
9809 (>= arg 0)
9810 (or (not (looking-at "[^ \t\n]+:"))
9811 (gnus-article-hidden-text-p 'headers))))
9812 s e)
9813 (delete-region (point-min) (point-max))
9814 (with-current-buffer gnus-original-article-buffer
9815 (goto-char (setq s (point-min)))
9816 (setq e (if (search-forward "\n\n" nil t)
9817 (1- (point))
9818 (point-max))))
9819 (insert-buffer-substring gnus-original-article-buffer s e)
9820 (run-hooks 'gnus-article-decode-hook)
9821 (if hidden
9822 (let ((gnus-treat-hide-headers nil)
9823 (gnus-treat-hide-boring-headers nil))
9824 (gnus-delete-wash-type 'headers)
9825 (gnus-treat-article 'head))
9826 (gnus-treat-article 'head)
9827 ;; Add attachment buttons to the header.
9828 (when gnus-mime-display-attachment-buttons-in-header
9829 (gnus-mime-buttonize-attachments-in-header)))
9830 (widen)
9831 (if window
9832 (set-window-start window (goto-char (point-min))))
9833 (if gnus-break-pages
9834 (gnus-narrow-to-page)
9835 (when (gnus-visual-p 'page-marker)
9836 (let ((inhibit-read-only t))
9837 (gnus-remove-text-with-property 'gnus-prev)
9838 (gnus-remove-text-with-property 'gnus-next))))
9839 (gnus-set-mode-line 'article)))))
9840
9841 (defun gnus-summary-show-all-headers ()
9842 "Make all header lines visible."
9843 (interactive)
9844 (gnus-summary-toggle-header 1))
9845
9846 (defun gnus-summary-caesar-message (&optional arg)
9847 "Caesar rotate the current article by 13.
9848 With a non-numerical prefix, also rotate headers. A numerical
9849 prefix specifies how many places to rotate each letter forward."
9850 (interactive "P")
9851 (gnus-summary-select-article)
9852 (let ((mail-header-separator ""))
9853 (gnus-eval-in-buffer-window gnus-article-buffer
9854 (save-restriction
9855 (widen)
9856 (let ((start (window-start))
9857 (inhibit-read-only t))
9858 (if (equal arg '(4))
9859 (message-caesar-buffer-body nil t)
9860 (message-caesar-buffer-body arg))
9861 (set-window-start (get-buffer-window (current-buffer)) start)))))
9862 ;; Create buttons and stuff...
9863 (gnus-treat-article nil))
9864
9865 (declare-function idna-to-unicode "ext:idna" (str))
9866
9867 (defun gnus-summary-idna-message (&optional arg)
9868 "Decode IDNA encoded domain names in the current articles.
9869 IDNA encoded domain names looks like `xn--bar'. If a string
9870 remain unencoded after running this function, it is likely an
9871 invalid IDNA string (`xn--bar' is invalid).
9872
9873 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9874 installed for this command to work."
9875 (interactive "P")
9876 (if (not (and (mm-coding-system-p 'utf-8)
9877 (condition-case nil
9878 (require 'idna)
9879 (file-error)
9880 (invalid-operation))
9881 (symbol-value 'idna-program)
9882 (executable-find (symbol-value 'idna-program))))
9883 (gnus-message
9884 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9885 (gnus-summary-select-article)
9886 (let ((mail-header-separator ""))
9887 (gnus-eval-in-buffer-window gnus-article-buffer
9888 (save-restriction
9889 (widen)
9890 (let ((start (window-start))
9891 buffer-read-only)
9892 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9893 (replace-match (idna-to-unicode (match-string 1))))
9894 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9895
9896 (defun gnus-summary-morse-message (&optional arg)
9897 "Morse decode the current article."
9898 (interactive "P")
9899 (gnus-summary-select-article)
9900 (let ((mail-header-separator ""))
9901 (gnus-eval-in-buffer-window gnus-article-buffer
9902 (save-excursion
9903 (save-restriction
9904 (widen)
9905 (let ((pos (window-start))
9906 (inhibit-read-only t))
9907 (goto-char (point-min))
9908 (when (message-goto-body)
9909 (gnus-narrow-to-body))
9910 (goto-char (point-min))
9911 (while (search-forward "·" (point-max) t)
9912 (replace-match "."))
9913 (unmorse-region (point-min) (point-max))
9914 (widen)
9915 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9916
9917 (defun gnus-summary-stop-page-breaking ()
9918 "Stop page breaking in the current article."
9919 (interactive)
9920 (gnus-summary-select-article)
9921 (gnus-eval-in-buffer-window gnus-article-buffer
9922 (widen)
9923 (when (gnus-visual-p 'page-marker)
9924 (let ((inhibit-read-only t))
9925 (gnus-remove-text-with-property 'gnus-prev)
9926 (gnus-remove-text-with-property 'gnus-next))
9927 (setq gnus-page-broken nil))))
9928
9929 (defun gnus-summary-move-article (&optional n to-newsgroup
9930 select-method action)
9931 "Move the current article to a different newsgroup.
9932 If N is a positive number, move the N next articles.
9933 If N is a negative number, move the N previous articles.
9934 If N is nil and any articles have been marked with the process mark,
9935 move those articles instead.
9936 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9937 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9938 re-spool using this method.
9939
9940 When called interactively with TO-NEWSGROUP being nil, the value of
9941 the variable `gnus-move-split-methods' is used for finding a default
9942 for the target newsgroup.
9943
9944 For this function to work, both the current newsgroup and the
9945 newsgroup that you want to move to have to support the `request-move'
9946 and `request-accept' functions.
9947
9948 ACTION can be either `move' (the default), `crosspost' or `copy'."
9949 (interactive "P")
9950 (unless action
9951 (setq action 'move))
9952 ;; Check whether the source group supports the required functions.
9953 (cond ((and (eq action 'move)
9954 (not (gnus-check-backend-function
9955 'request-move-article gnus-newsgroup-name)))
9956 (error "The current group does not support article moving"))
9957 ((and (eq action 'crosspost)
9958 (not (gnus-check-backend-function
9959 'request-replace-article gnus-newsgroup-name)))
9960 (error "The current group does not support article editing")))
9961 (let ((articles (gnus-summary-work-articles n))
9962 (prefix (if (gnus-check-backend-function
9963 'request-move-article gnus-newsgroup-name)
9964 (funcall gnus-move-group-prefix-function
9965 gnus-newsgroup-name)
9966 ""))
9967 (names '((move "Move" "Moving")
9968 (copy "Copy" "Copying")
9969 (crosspost "Crosspost" "Crossposting")))
9970 (copy-buf (save-excursion
9971 (nnheader-set-temp-buffer " *copy article*")))
9972 art-group to-method new-xref article to-groups
9973 articles-to-update-marks encoded)
9974 (unless (assq action names)
9975 (error "Unknown action %s" action))
9976 ;; Read the newsgroup name.
9977 (when (and (not to-newsgroup)
9978 (not select-method))
9979 (if (and gnus-move-split-methods
9980 (not
9981 (and (memq gnus-current-article articles)
9982 (gnus-buffer-live-p gnus-original-article-buffer))))
9983 ;; When `gnus-move-split-methods' is non-nil, we have to
9984 ;; select an article to give `gnus-read-move-group-name' an
9985 ;; opportunity to suggest an appropriate default. However,
9986 ;; we needn't render or mark the article.
9987 (let ((gnus-display-mime-function nil)
9988 (gnus-article-prepare-hook nil)
9989 (gnus-mark-article-hook nil))
9990 (gnus-summary-select-article nil nil nil (car articles))))
9991 (setq to-newsgroup (gnus-read-move-group-name
9992 (cadr (assq action names))
9993 (symbol-value
9994 (intern (format "gnus-current-%s-group" action)))
9995 articles prefix)
9996 encoded to-newsgroup
9997 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9998 (set (intern (format "gnus-current-%s-group" action))
9999 (mm-decode-coding-string
10000 to-newsgroup
10001 (gnus-group-name-charset to-method to-newsgroup))))
10002 (unless to-method
10003 (setq to-method (or select-method
10004 (gnus-server-to-method
10005 (gnus-group-method to-newsgroup)))))
10006 (setq to-newsgroup
10007 (or encoded
10008 (and to-newsgroup
10009 (mm-encode-coding-string
10010 to-newsgroup
10011 (gnus-group-name-charset to-method to-newsgroup)))))
10012 ;; Check the method we are to move this article to...
10013 (unless (gnus-check-backend-function
10014 'request-accept-article (car to-method))
10015 (error "%s does not support article copying" (car to-method)))
10016 (unless (gnus-check-server to-method)
10017 (error "Can't open server %s" (car to-method)))
10018 (gnus-message 6 "%s to %s: %s..."
10019 (caddr (assq action names))
10020 (or (car select-method)
10021 (gnus-group-decoded-name to-newsgroup))
10022 articles)
10023 (while articles
10024 (setq article (pop articles))
10025 ;; Set any marks that may have changed in the summary buffer.
10026 (when gnus-preserve-marks
10027 (gnus-summary-push-marks-to-backend article))
10028 (setq
10029 art-group
10030 (cond
10031 ;; Move the article.
10032 ((eq action 'move)
10033 ;; Remove this article from future suppression.
10034 (gnus-dup-unsuppress-article article)
10035 (let* ((from-method (gnus-find-method-for-group
10036 gnus-newsgroup-name))
10037 (to-method (or select-method
10038 (gnus-find-method-for-group to-newsgroup)))
10039 (move-is-internal (gnus-server-equal from-method to-method)))
10040 (gnus-request-move-article
10041 article ; Article to move
10042 gnus-newsgroup-name ; From newsgroup
10043 (nth 1 (gnus-find-method-for-group
10044 gnus-newsgroup-name)) ; Server
10045 (list 'gnus-request-accept-article
10046 to-newsgroup (list 'quote select-method)
10047 (not articles) t) ; Accept form
10048 (not articles) ; Only save nov last time
10049 (and move-is-internal
10050 to-newsgroup ; Not respooling
10051 ; Is this move internal?
10052 (gnus-group-real-name to-newsgroup)))))
10053 ;; Copy the article.
10054 ((eq action 'copy)
10055 (with-current-buffer copy-buf
10056 (when (gnus-request-article-this-buffer article
10057 gnus-newsgroup-name)
10058 (save-restriction
10059 (nnheader-narrow-to-headers)
10060 (dolist (hdr gnus-copy-article-ignored-headers)
10061 (message-remove-header hdr t)))
10062 (gnus-request-accept-article
10063 to-newsgroup select-method (not articles) t))))
10064 ;; Crosspost the article.
10065 ((eq action 'crosspost)
10066 (let ((xref (message-tokenize-header
10067 (mail-header-xref (gnus-summary-article-header
10068 article))
10069 " ")))
10070 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10071 ":" (number-to-string article)))
10072 (unless xref
10073 (setq xref (list (system-name))))
10074 (setq new-xref
10075 (concat
10076 (mapconcat 'identity
10077 (delete "Xref:" (delete new-xref xref))
10078 " ")
10079 " " new-xref))
10080 (with-current-buffer copy-buf
10081 ;; First put the article in the destination group.
10082 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10083 (when (consp (setq art-group
10084 (gnus-request-accept-article
10085 to-newsgroup select-method (not articles)
10086 t)))
10087 (setq new-xref (concat new-xref " " (car art-group)
10088 ":"
10089 (number-to-string (cdr art-group))))
10090 ;; Now we have the new Xrefs header, so we insert
10091 ;; it and replace the new article.
10092 (nnheader-replace-header "Xref" new-xref)
10093 (gnus-request-replace-article
10094 (cdr art-group) to-newsgroup (current-buffer) t)
10095 art-group))))))
10096 (cond
10097 ((not art-group)
10098 (gnus-message 1 "Couldn't %s article %s: %s"
10099 (cadr (assq action names)) article
10100 (nnheader-get-report (car to-method))))
10101 ((eq art-group 'junk)
10102 (when (eq action 'move)
10103 (gnus-summary-mark-article article gnus-canceled-mark)
10104 (gnus-message 4 "Deleted article %s" article)
10105 ;; run the delete hook
10106 (run-hook-with-args 'gnus-summary-article-delete-hook
10107 action
10108 (gnus-data-header
10109 (assoc article (gnus-data-list nil)))
10110 gnus-newsgroup-name nil
10111 select-method)))
10112 (t
10113 (let* ((pto-group (gnus-group-prefixed-name
10114 (car art-group) to-method))
10115 (info (gnus-get-info pto-group))
10116 (to-group (gnus-info-group info))
10117 to-marks)
10118 ;; Update the group that has been moved to.
10119 (when (and info
10120 (memq action '(move copy)))
10121 (unless (member to-group to-groups)
10122 (push to-group to-groups))
10123
10124 (when (and (not (memq article gnus-newsgroup-unreads))
10125 (cdr art-group))
10126 (push 'read to-marks)
10127 (gnus-info-set-read
10128 info (gnus-add-to-range (gnus-info-read info)
10129 (list (cdr art-group)))))
10130
10131 ;; See whether the article is to be put in the cache.
10132 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10133 (marks (if expirable
10134 gnus-article-mark-lists
10135 (delete '(expirable . expire)
10136 (copy-sequence
10137 gnus-article-mark-lists))))
10138 (to-article (cdr art-group)))
10139
10140 ;; Enter the article into the cache in the new group,
10141 ;; if that is required.
10142 (when (and to-article
10143 gnus-use-cache)
10144 (gnus-cache-possibly-enter-article
10145 to-group to-article
10146 (memq article gnus-newsgroup-marked)
10147 (memq article gnus-newsgroup-dormant)
10148 (memq article gnus-newsgroup-unreads)))
10149
10150 (when (and gnus-preserve-marks
10151 to-article)
10152 ;; Copy any marks over to the new group.
10153 (when (and (equal to-group gnus-newsgroup-name)
10154 (not (memq article gnus-newsgroup-unreads)))
10155 ;; Mark this article as read in this group.
10156 (push (cons to-article gnus-read-mark)
10157 gnus-newsgroup-reads)
10158 ;; Increase the active status of this group.
10159 (setcdr (gnus-active to-group) to-article)
10160 (setcdr gnus-newsgroup-active to-article))
10161
10162 (while marks
10163 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10164 (when (memq article (symbol-value
10165 (intern (format "gnus-newsgroup-%s"
10166 (caar marks)))))
10167 (push (cdar marks) to-marks)
10168 ;; If the other group is the same as this group,
10169 ;; then we have to add the mark to the list.
10170 (when (equal to-group gnus-newsgroup-name)
10171 (set (intern (format "gnus-newsgroup-%s"
10172 (caar marks)))
10173 (cons to-article
10174 (symbol-value
10175 (intern (format "gnus-newsgroup-%s"
10176 (caar marks)))))))
10177 ;; Copy the marks to other group.
10178 (gnus-add-marked-articles
10179 to-group (cdar marks) (list to-article) info)))
10180 (setq marks (cdr marks)))
10181
10182 (when (and expirable
10183 gnus-mark-copied-or-moved-articles-as-expirable
10184 (not (memq 'expire to-marks)))
10185 ;; Mark this article as expirable.
10186 (push 'expire to-marks)
10187 (when (equal to-group gnus-newsgroup-name)
10188 (push to-article gnus-newsgroup-expirable))
10189 ;; Copy the expirable mark to other group.
10190 (gnus-add-marked-articles
10191 to-group 'expire (list to-article) info))
10192
10193 (when (and to-marks
10194 (gnus-method-option-p
10195 (gnus-find-method-for-group to-group)
10196 'server-marks))
10197 (gnus-request-set-mark
10198 to-group (list (list (list to-article) 'add to-marks)))))
10199
10200 (gnus-dribble-enter
10201 (concat "(gnus-group-set-info '"
10202 (gnus-prin1-to-string (gnus-get-info to-group))
10203 ")")
10204 (concat "^(gnus-group-set-info '(\""
10205 (regexp-quote to-group) "\""))))
10206
10207 ;; Update the Xref header in this article to point to
10208 ;; the new crossposted article we have just created.
10209 (when (eq action 'crosspost)
10210 (with-current-buffer copy-buf
10211 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10212 (nnheader-replace-header "Xref" new-xref)
10213 (gnus-request-replace-article
10214 article gnus-newsgroup-name (current-buffer) t)))
10215
10216 ;; run the move/copy/crosspost/respool hook
10217 (run-hook-with-args 'gnus-summary-article-move-hook
10218 action
10219 (gnus-data-header
10220 (assoc article (gnus-data-list nil)))
10221 gnus-newsgroup-name
10222 to-newsgroup
10223 select-method))
10224
10225 ;;;!!!Why is this necessary?
10226 (set-buffer gnus-summary-buffer)
10227
10228 (when (eq action 'move)
10229 (save-excursion
10230 (gnus-summary-goto-subject article)
10231 (gnus-summary-mark-article article gnus-canceled-mark)))))
10232 (push article articles-to-update-marks))
10233
10234 (save-excursion
10235 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10236 ;; Re-activate all groups that have been moved to.
10237 (with-current-buffer gnus-group-buffer
10238 (let ((gnus-group-marked to-groups))
10239 (gnus-group-get-new-news-this-group nil t)))
10240
10241 (gnus-kill-buffer copy-buf)
10242 (gnus-summary-position-point)
10243 (gnus-set-mode-line 'summary)))
10244
10245 (defun gnus-summary-push-marks-to-backend (article)
10246 (let ((set nil)
10247 (del nil)
10248 (marks gnus-article-mark-lists))
10249 (unless (memq article gnus-newsgroup-unreads)
10250 (push 'read set))
10251 (while marks
10252 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10253 (memq article (symbol-value
10254 (intern (format "gnus-newsgroup-%s"
10255 (caar marks))))))
10256 (push (cdar marks) set)
10257 (push (cdar marks) del))
10258 (pop marks))
10259 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10260 ((,article) del ,del)))))
10261
10262 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10263 "Copy the current article to some other group.
10264 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10265 When called interactively, if TO-NEWSGROUP is nil, use the value of
10266 the variable `gnus-move-split-methods' for finding a default target
10267 newsgroup.
10268 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10269 re-spool using this method."
10270 (interactive "P")
10271 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10272
10273 (defun gnus-summary-crosspost-article (&optional n)
10274 "Crosspost the current article to some other group."
10275 (interactive "P")
10276 (gnus-summary-move-article n nil nil 'crosspost))
10277
10278 (defcustom gnus-summary-respool-default-method nil
10279 "Default method type for respooling an article.
10280 If nil, use to the current newsgroup method."
10281 :type 'symbol
10282 :group 'gnus-summary-mail)
10283
10284 (defun gnus-summary-respool-article (&optional n method)
10285 "Respool the current article.
10286 The article will be squeezed through the mail spooling process again,
10287 which means that it will be put in some mail newsgroup or other
10288 depending on `nnmail-split-methods'.
10289 If N is a positive number, respool the N next articles.
10290 If N is a negative number, respool the N previous articles.
10291 If N is nil and any articles have been marked with the process mark,
10292 respool those articles instead.
10293
10294 Respooling can be done both from mail groups and \"real\" newsgroups.
10295 In the former case, the articles in question will be moved from the
10296 current group into whatever groups they are destined to. In the
10297 latter case, they will be copied into the relevant groups."
10298 (interactive
10299 (list current-prefix-arg
10300 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10301 (methname
10302 (symbol-name (or gnus-summary-respool-default-method
10303 (car (gnus-find-method-for-group
10304 gnus-newsgroup-name)))))
10305 (method
10306 (gnus-completing-read
10307 "Backend to use when respooling"
10308 methods t nil 'gnus-mail-method-history methname))
10309 ms)
10310 (cond
10311 ((zerop (length (setq ms (gnus-servers-using-backend
10312 (intern method)))))
10313 (list (intern method) ""))
10314 ((= 1 (length ms))
10315 (car ms))
10316 (t
10317 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10318 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10319 ms-alist))))))))
10320 (unless method
10321 (error "No method given for respooling"))
10322 (if (assoc (symbol-name
10323 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10324 (gnus-methods-using 'respool))
10325 (gnus-summary-move-article n nil method)
10326 (gnus-summary-copy-article n nil method)))
10327
10328 (defun gnus-summary-import-article (file &optional edit)
10329 "Import an arbitrary file into a mail newsgroup."
10330 (interactive "fImport file: \nP")
10331 (let ((group gnus-newsgroup-name)
10332 (now (current-time))
10333 atts lines group-art)
10334 (unless (gnus-check-backend-function 'request-accept-article group)
10335 (error "%s does not support article importing" group))
10336 (or (file-readable-p file)
10337 (not (file-regular-p file))
10338 (error "Can't read %s" file))
10339 (with-current-buffer (gnus-get-buffer-create " *import file*")
10340 (erase-buffer)
10341 (nnheader-insert-file-contents file)
10342 (goto-char (point-min))
10343 (if (nnheader-article-p)
10344 (save-restriction
10345 (goto-char (point-min))
10346 (search-forward "\n\n" nil t)
10347 (narrow-to-region (point-min) (1- (point)))
10348 (goto-char (point-min))
10349 (unless (re-search-forward "^date:" nil t)
10350 (goto-char (point-max))
10351 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10352 ;; This doesn't look like an article, so we fudge some headers.
10353 (setq atts (file-attributes file)
10354 lines (count-lines (point-min) (point-max)))
10355 (insert "From: " (read-string "From: ") "\n"
10356 "Subject: " (read-string "Subject: ") "\n"
10357 "Date: " (message-make-date (nth 5 atts)) "\n"
10358 "Message-ID: " (message-make-message-id) "\n"
10359 "Lines: " (int-to-string lines) "\n"
10360 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10361 (setq group-art (gnus-request-accept-article group nil t))
10362 (kill-buffer (current-buffer)))
10363 (setq gnus-newsgroup-active (gnus-activate-group group))
10364 (forward-line 1)
10365 (gnus-summary-goto-article (cdr group-art) nil t)
10366 (when edit
10367 (gnus-summary-edit-article))))
10368
10369 (defun gnus-summary-create-article ()
10370 "Create an article in a mail newsgroup."
10371 (interactive)
10372 (let ((group gnus-newsgroup-name)
10373 (now (current-time))
10374 group-art)
10375 (unless (gnus-check-backend-function 'request-accept-article group)
10376 (error "%s does not support article importing" group))
10377 (with-current-buffer (gnus-get-buffer-create " *import file*")
10378 (erase-buffer)
10379 (goto-char (point-min))
10380 ;; This doesn't look like an article, so we fudge some headers.
10381 (insert "From: " (read-string "From: ") "\n"
10382 "Subject: " (read-string "Subject: ") "\n"
10383 "Date: " (message-make-date now) "\n"
10384 "Message-ID: " (message-make-message-id) "\n")
10385 (setq group-art (gnus-request-accept-article group nil t))
10386 (kill-buffer (current-buffer)))
10387 (setq gnus-newsgroup-active (gnus-activate-group group))
10388 (forward-line 1)
10389 (gnus-summary-goto-article (cdr group-art) nil t)
10390 (gnus-summary-edit-article)))
10391
10392 (defun gnus-summary-article-posted-p ()
10393 "Say whether the current (mail) article is available from news as well.
10394 This will be the case if the article has both been mailed and posted."
10395 (interactive)
10396 (let ((id (mail-header-references (gnus-summary-article-header)))
10397 (gnus-override-method (car (gnus-refer-article-methods))))
10398 (if (gnus-request-head id "")
10399 (gnus-message 2 "The current message was found on %s"
10400 gnus-override-method)
10401 (gnus-message 2 "The current message couldn't be found on %s"
10402 gnus-override-method)
10403 nil)))
10404
10405 (defun gnus-summary-expire-articles (&optional now)
10406 "Expire all articles that are marked as expirable in the current group."
10407 (interactive)
10408 (when (and (not gnus-group-is-exiting-without-update-p)
10409 (gnus-check-backend-function
10410 'request-expire-articles gnus-newsgroup-name))
10411 ;; This backend supports expiry.
10412 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10413 (expirable
10414 (gnus-list-range-difference
10415 (if total
10416 (progn
10417 ;; We need to update the info for
10418 ;; this group for `gnus-list-of-read-articles'
10419 ;; to give us the right answer.
10420 (gnus-run-hooks 'gnus-exit-group-hook)
10421 (gnus-summary-update-info)
10422 (gnus-list-of-read-articles gnus-newsgroup-name))
10423 (setq gnus-newsgroup-expirable
10424 (sort gnus-newsgroup-expirable '<)))
10425 gnus-newsgroup-unexist))
10426 (expiry-wait (if now 'immediate
10427 (gnus-group-find-parameter
10428 gnus-newsgroup-name 'expiry-wait)))
10429 (nnmail-expiry-target
10430 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10431 nnmail-expiry-target))
10432 es)
10433 (when expirable
10434 ;; There are expirable articles in this group, so we run them
10435 ;; through the expiry process.
10436 (gnus-message 6 "Expiring articles...")
10437 (when (gnus-check-group gnus-newsgroup-name)
10438 ;; The list of articles that weren't expired is returned.
10439 (save-excursion
10440 (if expiry-wait
10441 (let ((nnmail-expiry-wait-function nil)
10442 (nnmail-expiry-wait expiry-wait))
10443 (setq es (gnus-request-expire-articles
10444 expirable gnus-newsgroup-name)))
10445 (setq es (gnus-request-expire-articles
10446 expirable gnus-newsgroup-name)))
10447 (unless total
10448 (setq gnus-newsgroup-expirable es))
10449 ;; We go through the old list of expirable, and mark all
10450 ;; really expired articles as nonexistent.
10451 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10452 (let ((gnus-use-cache nil))
10453 (dolist (article expirable)
10454 (when (and (not (memq article es))
10455 (gnus-data-find article))
10456 (gnus-summary-mark-article article gnus-canceled-mark)
10457 (run-hook-with-args
10458 'gnus-summary-article-expire-hook
10459 'delete
10460 (gnus-data-header (assoc article (gnus-data-list nil)))
10461 gnus-newsgroup-name
10462 (cond
10463 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10464 ((eq nnmail-expiry-target 'delete) nil)
10465 (t
10466 (let ((rescall (funcall nnmail-expiry-target
10467 gnus-newsgroup-name)))
10468 (if (stringp rescall) rescall nil))))
10469 nil)))))))
10470 (gnus-message 6 "Expiring articles...done")))))
10471
10472 (defun gnus-summary-expire-articles-now ()
10473 "Expunge all expirable articles in the current group.
10474 This means that *all* articles that are marked as expirable will be
10475 deleted forever, right now."
10476 (interactive)
10477 (or gnus-expert-user
10478 (gnus-yes-or-no-p
10479 "Are you really, really sure you want to delete all expirable messages? ")
10480 (error "Phew!"))
10481 (gnus-summary-expire-articles t))
10482
10483 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10484 (defun gnus-summary-delete-article (&optional n)
10485 "Delete the N next (mail) articles.
10486 This command actually deletes articles. This is not a marking
10487 command. The article will disappear forever from your life, never to
10488 return.
10489
10490 If N is negative, delete backwards.
10491 If N is nil and articles have been marked with the process mark,
10492 delete these instead.
10493
10494 If `gnus-novice-user' is non-nil you will be asked for
10495 confirmation before the articles are deleted."
10496 (interactive "P")
10497 (unless (gnus-check-backend-function 'request-expire-articles
10498 gnus-newsgroup-name)
10499 (error "The current newsgroup does not support article deletion"))
10500 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10501 (error "Couldn't open server"))
10502 ;; Compute the list of articles to delete.
10503 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10504 (nnmail-expiry-target 'delete)
10505 not-deleted)
10506 (if (and gnus-novice-user
10507 (not (gnus-yes-or-no-p
10508 (format "Do you really want to delete %s forever? "
10509 (if (> (length articles) 1)
10510 (format "these %s articles" (length articles))
10511 "this article")))))
10512 ()
10513 ;; Delete the articles.
10514 (setq not-deleted (gnus-request-expire-articles
10515 articles gnus-newsgroup-name 'force))
10516 (save-excursion
10517 (while articles
10518 (gnus-summary-remove-process-mark (car articles))
10519 ;; The backend might not have been able to delete the article
10520 ;; after all.
10521 (unless (memq (car articles) not-deleted)
10522 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10523 (let* ((article (car articles))
10524 (ghead (gnus-data-header
10525 (assoc article (gnus-data-list nil)))))
10526 (run-hook-with-args 'gnus-summary-article-delete-hook
10527 'delete ghead gnus-newsgroup-name nil
10528 nil)))
10529 (setq articles (cdr articles))))
10530 (when not-deleted
10531 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10532 (gnus-summary-position-point)
10533 (gnus-set-mode-line 'summary)
10534 not-deleted))
10535
10536 (defun gnus-summary-edit-article (&optional arg)
10537 "Edit the current article.
10538 This will have permanent effect only in mail groups.
10539 If ARG is nil, edit the decoded articles.
10540 If ARG is 1, edit the raw articles.
10541 If ARG is 2, edit the raw articles even in read-only groups.
10542 If ARG is 3, edit the articles with the current handles.
10543 Otherwise, allow editing of articles even in read-only
10544 groups."
10545 (interactive "P")
10546 (let (force raw current-handles)
10547 (cond
10548 ((null arg))
10549 ((eq arg 1)
10550 (setq raw t))
10551 ((eq arg 2)
10552 (setq raw t
10553 force t))
10554 ((eq arg 3)
10555 (setq current-handles
10556 (and (gnus-buffer-live-p gnus-article-buffer)
10557 (with-current-buffer gnus-article-buffer
10558 (prog1
10559 gnus-article-mime-handles
10560 (setq gnus-article-mime-handles nil))))))
10561 (t
10562 (setq force t)))
10563 (when (and raw (not force)
10564 (member gnus-newsgroup-name '("nndraft:delayed"
10565 "nndraft:drafts"
10566 "nndraft:queue")))
10567 (error "Can't edit the raw article in group %s"
10568 gnus-newsgroup-name))
10569 (with-current-buffer gnus-summary-buffer
10570 (let ((mail-parse-charset gnus-newsgroup-charset)
10571 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10572 (gnus-set-global-variables)
10573 (when (and (not force)
10574 (gnus-group-read-only-p))
10575 (error "The current newsgroup does not support article editing"))
10576 (gnus-summary-show-article t)
10577 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10578 (with-current-buffer gnus-article-buffer
10579 (mm-enable-multibyte)))
10580 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10581 (setq raw t))
10582 (gnus-article-edit-article
10583 (if raw 'ignore
10584 `(lambda ()
10585 (let ((mbl mml-buffer-list))
10586 (setq mml-buffer-list nil)
10587 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10588 (mime-to-mml ,'current-handles))
10589 (let ((mbl1 mml-buffer-list))
10590 (setq mml-buffer-list mbl)
10591 (set (make-local-variable 'mml-buffer-list) mbl1))
10592 (gnus-make-local-hook 'kill-buffer-hook)
10593 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10594 `(lambda (no-highlight)
10595 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10596 (message-options message-options)
10597 (message-options-set-recipient)
10598 (mail-parse-ignored-charsets
10599 ',gnus-newsgroup-ignored-charsets)
10600 (rfc2047-header-encoding-alist
10601 ',(let ((charset (gnus-group-name-charset
10602 (gnus-find-method-for-group
10603 gnus-newsgroup-name)
10604 gnus-newsgroup-name)))
10605 (append (list (cons "Newsgroups" charset)
10606 (cons "Followup-To" charset)
10607 (cons "Xref" charset))
10608 rfc2047-header-encoding-alist))))
10609 ,(if (not raw) '(progn
10610 (mml-to-mime)
10611 (mml-destroy-buffers)
10612 (remove-hook 'kill-buffer-hook
10613 'mml-destroy-buffers t)
10614 (kill-local-variable 'mml-buffer-list)))
10615 (gnus-summary-edit-article-done
10616 ,(or (mail-header-references gnus-current-headers) "")
10617 ,(gnus-group-read-only-p)
10618 ,gnus-summary-buffer no-highlight))))))))
10619
10620 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10621
10622 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10623 no-highlight)
10624 "Make edits to the current article permanent."
10625 (interactive)
10626 (save-excursion
10627 ;; The buffer restriction contains the entire article if it exists.
10628 (when (article-goto-body)
10629 (let ((lines (count-lines (point) (point-max)))
10630 (length (- (point-max) (point)))
10631 (case-fold-search t)
10632 (body (point-marker)))
10633 (goto-char (point-min))
10634 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10635 (delete-region (match-beginning 1) (match-end 1))
10636 (insert (number-to-string length)))
10637 (goto-char (point-min))
10638 (when (re-search-forward
10639 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10640 (delete-region (match-beginning 1) (match-end 1))
10641 (insert (number-to-string length)))
10642 (goto-char (point-min))
10643 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10644 (delete-region (match-beginning 1) (match-end 1))
10645 (insert (number-to-string lines))))))
10646 ;; Replace the article.
10647 (let ((buf (current-buffer))
10648 (article (cdr gnus-article-current))
10649 replace-result)
10650 (with-temp-buffer
10651 (insert-buffer-substring buf)
10652 (if (and (not read-only)
10653 (not (setq replace-result
10654 (gnus-request-replace-article
10655 article (car gnus-article-current)
10656 (current-buffer) t))))
10657 (error "Couldn't replace article")
10658 ;; If we got a number back, then that's the new article number
10659 ;; for this article. Otherwise, the article number didn't change.
10660 (when (numberp replace-result)
10661 (with-current-buffer gnus-summary-buffer
10662 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10663 (gnus-summary-limit gnus-newsgroup-limit)
10664 (setq article replace-result)
10665 (gnus-summary-goto-subject article t)))
10666 ;; Update the summary buffer.
10667 (if (and references
10668 (equal (message-tokenize-header references " ")
10669 (message-tokenize-header
10670 (or (message-fetch-field "references") "") " ")))
10671 ;; We only have to update this line.
10672 (save-excursion
10673 (save-restriction
10674 (message-narrow-to-head)
10675 (let ((head (buffer-substring-no-properties
10676 (point-min) (point-max)))
10677 header)
10678 (with-temp-buffer
10679 (insert (format "211 %d Article retrieved.\n" article))
10680 (insert head)
10681 (insert ".\n")
10682 (let ((nntp-server-buffer (current-buffer)))
10683 (setq header (car (gnus-get-newsgroup-headers nil t))))
10684 (with-current-buffer gnus-summary-buffer
10685 (gnus-data-set-header (gnus-data-find article) header)
10686 (gnus-summary-update-article-line article header)
10687 (if (gnus-summary-goto-subject article nil t)
10688 (gnus-summary-update-secondary-mark article)))))))
10689 ;; Update threads.
10690 (set-buffer (or buffer gnus-summary-buffer))
10691 (gnus-summary-update-article article)
10692 (if (gnus-summary-goto-subject article nil t)
10693 (gnus-summary-update-secondary-mark article)))
10694 ;; Prettify the article buffer again.
10695 (unless no-highlight
10696 (with-current-buffer gnus-article-buffer
10697 ;;!!! Fix this -- article should be rehighlighted.
10698 ;;(gnus-run-hooks 'gnus-article-display-hook)
10699 (set-buffer gnus-original-article-buffer)
10700 (gnus-request-article
10701 article (car gnus-article-current) (current-buffer))))
10702 ;; Prettify the summary buffer line.
10703 (when (gnus-visual-p 'summary-highlight 'highlight)
10704 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10705
10706 (defun gnus-summary-edit-wash (key)
10707 "Perform editing command KEY in the article buffer."
10708 (interactive
10709 (list
10710 (progn
10711 (message "%s" (concat (this-command-keys) "- "))
10712 (read-char))))
10713 (message "")
10714 (gnus-summary-edit-article)
10715 (execute-kbd-macro (concat (this-command-keys) key))
10716 (gnus-article-edit-done))
10717
10718 ;;; Respooling
10719
10720 (defvar nnimap-split-fancy)
10721 (defvar nnimap-split-methods)
10722
10723 (defun gnus-summary-respool-query (&optional silent trace)
10724 "Query where the respool algorithm would put this article."
10725 (interactive)
10726 (let (gnus-mark-article-hook)
10727 (gnus-summary-select-article)
10728 (with-current-buffer gnus-original-article-buffer
10729 (let ((groups
10730 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10731 'nnimap)
10732 ;; nnimap has its own splitting variables.
10733 (let ((nnmail-split-methods
10734 (cond
10735 ((eq nnimap-split-methods 'default)
10736 nnmail-split-methods)
10737 (nnimap-split-methods
10738 nnimap-split-methods)
10739 (nnimap-split-fancy
10740 'nnmail-split-fancy)))
10741 (nnmail-split-fancy (or nnimap-split-fancy
10742 nnmail-split-fancy)))
10743 (nnmail-article-group 'identity trace))
10744 (nnmail-article-group 'identity trace))))
10745 (unless silent
10746 (if groups
10747 (message "This message would go to %s"
10748 (mapconcat 'car groups ", "))
10749 (message "This message would go to no groups"))
10750 groups)))))
10751
10752 (defun gnus-summary-respool-trace ()
10753 "Trace where the respool algorithm would put this article.
10754 Display a buffer showing all fancy splitting patterns which matched."
10755 (interactive)
10756 (gnus-summary-respool-query nil t))
10757
10758 ;; Summary marking commands.
10759
10760 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10761 "Mark articles which has the same subject as read, and then select the next.
10762 If UNMARK is positive, remove any kind of mark.
10763 If UNMARK is negative, tick articles."
10764 (interactive "P")
10765 (when unmark
10766 (setq unmark (prefix-numeric-value unmark)))
10767 (let ((count
10768 (gnus-summary-mark-same-subject
10769 (gnus-summary-article-subject) unmark)))
10770 ;; Select next unread article. If auto-select-same mode, should
10771 ;; select the first unread article.
10772 (gnus-summary-next-article t (and gnus-auto-select-same
10773 (gnus-summary-article-subject)))
10774 (gnus-message 7 "%d article%s marked as %s"
10775 count (if (= count 1) " is" "s are")
10776 (if unmark "unread" "read"))))
10777
10778 (defun gnus-summary-kill-same-subject (&optional unmark)
10779 "Mark articles which has the same subject as read.
10780 If UNMARK is positive, remove any kind of mark.
10781 If UNMARK is negative, tick articles."
10782 (interactive "P")
10783 (when unmark
10784 (setq unmark (prefix-numeric-value unmark)))
10785 (let ((count
10786 (gnus-summary-mark-same-subject
10787 (gnus-summary-article-subject) unmark)))
10788 ;; If marked as read, go to next unread subject.
10789 (when (null unmark)
10790 ;; Go to next unread subject.
10791 (gnus-summary-next-subject 1 t))
10792 (gnus-message 7 "%d articles are marked as %s"
10793 count (if unmark "unread" "read"))))
10794
10795 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10796 "Mark articles with same SUBJECT as read, and return marked number.
10797 If optional argument UNMARK is positive, remove any kinds of marks.
10798 If optional argument UNMARK is negative, mark articles as unread instead."
10799 (let ((count 1))
10800 (save-excursion
10801 (cond
10802 ((null unmark) ; Mark as read.
10803 (while (and
10804 (progn
10805 (gnus-summary-mark-article-as-read gnus-killed-mark)
10806 (gnus-summary-show-thread) t)
10807 (gnus-summary-find-subject subject))
10808 (setq count (1+ count))))
10809 ((> unmark 0) ; Tick.
10810 (while (and
10811 (progn
10812 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10813 (gnus-summary-show-thread) t)
10814 (gnus-summary-find-subject subject))
10815 (setq count (1+ count))))
10816 (t ; Mark as unread.
10817 (while (and
10818 (progn
10819 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10820 (gnus-summary-show-thread) t)
10821 (gnus-summary-find-subject subject))
10822 (setq count (1+ count)))))
10823 (gnus-set-mode-line 'summary)
10824 ;; Return the number of marked articles.
10825 count)))
10826
10827 (defun gnus-summary-mark-as-processable (n &optional unmark)
10828 "Set the process mark on the next N articles.
10829 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10830 the process mark instead. The difference between N and the actual
10831 number of articles marked is returned."
10832 (interactive "P")
10833 (if (and (null n) (gnus-region-active-p))
10834 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10835 (setq n (prefix-numeric-value n))
10836 (let ((backward (< n 0))
10837 (n (abs n)))
10838 (while (and
10839 (> n 0)
10840 (if unmark
10841 (gnus-summary-remove-process-mark
10842 (gnus-summary-article-number))
10843 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10844 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10845 (setq n (1- n)))
10846 (when (/= 0 n)
10847 (gnus-message 7 "No more articles"))
10848 (gnus-summary-recenter)
10849 (gnus-summary-position-point)
10850 n)))
10851
10852 (defun gnus-summary-unmark-as-processable (n)
10853 "Remove the process mark from the next N articles.
10854 If N is negative, unmark backward instead. The difference between N and
10855 the actual number of articles unmarked is returned."
10856 (interactive "P")
10857 (gnus-summary-mark-as-processable n t))
10858
10859 (defun gnus-summary-unmark-all-processable ()
10860 "Remove the process mark from all articles."
10861 (interactive)
10862 (save-excursion
10863 (while gnus-newsgroup-processable
10864 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10865 (gnus-summary-position-point))
10866
10867 (defun gnus-summary-add-mark (article type)
10868 "Mark ARTICLE with a mark of TYPE."
10869 (let ((vtype (car (assq type gnus-article-mark-lists)))
10870 var)
10871 (if (not vtype)
10872 (error "No such mark type: %s" type)
10873 (setq var (intern (format "gnus-newsgroup-%s" type)))
10874 (set var (cons article (symbol-value var)))
10875 (if (memq type '(processable cached replied forwarded recent saved))
10876 (gnus-summary-update-secondary-mark article)
10877 ;;; !!! This is bogus. We should find out what primary
10878 ;;; !!! mark we want to set.
10879 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10880
10881 (defun gnus-summary-mark-as-expirable (n)
10882 "Mark N articles forward as expirable.
10883 If N is negative, mark backward instead. The difference between N and
10884 the actual number of articles marked is returned."
10885 (interactive "p")
10886 (gnus-summary-mark-forward n gnus-expirable-mark))
10887
10888 (defun gnus-summary-mark-as-spam (n)
10889 "Mark N articles forward as spam.
10890 If N is negative, mark backward instead. The difference between N and
10891 the actual number of articles marked is returned."
10892 (interactive "p")
10893 (gnus-summary-mark-forward n gnus-spam-mark))
10894
10895 (defun gnus-summary-mark-article-as-replied (article)
10896 "Mark ARTICLE as replied to and update the summary line.
10897 ARTICLE can also be a list of articles."
10898 (interactive (list (gnus-summary-article-number)))
10899 (let ((articles (if (listp article) article (list article))))
10900 (dolist (article articles)
10901 (unless (numberp article)
10902 (error "%s is not a number" article))
10903 (push article gnus-newsgroup-replied)
10904 (let ((inhibit-read-only t))
10905 (when (gnus-summary-goto-subject article nil t)
10906 (gnus-summary-update-secondary-mark article))))))
10907
10908 (defun gnus-summary-mark-article-as-forwarded (article)
10909 "Mark ARTICLE as forwarded and update the summary line.
10910 ARTICLE can also be a list of articles."
10911 (let ((articles (if (listp article) article (list article))))
10912 (dolist (article articles)
10913 (push article gnus-newsgroup-forwarded)
10914 (let ((inhibit-read-only t))
10915 (when (gnus-summary-goto-subject article nil t)
10916 (gnus-summary-update-secondary-mark article))))))
10917
10918 (defun gnus-summary-set-bookmark (article)
10919 "Set a bookmark in current article."
10920 (interactive (list (gnus-summary-article-number)))
10921 (when (or (not (get-buffer gnus-article-buffer))
10922 (not gnus-current-article)
10923 (not gnus-article-current)
10924 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10925 (error "No current article selected"))
10926 ;; Remove old bookmark, if one exists.
10927 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10928 ;; Set the new bookmark, which is on the form
10929 ;; (article-number . line-number-in-body).
10930 (push
10931 (cons article
10932 (with-current-buffer gnus-article-buffer
10933 (count-lines
10934 (min (point)
10935 (save-excursion
10936 (article-goto-body)
10937 (point)))
10938 (point))))
10939 gnus-newsgroup-bookmarks)
10940 (gnus-message 6 "A bookmark has been added to the current article."))
10941
10942 (defun gnus-summary-remove-bookmark (article)
10943 "Remove the bookmark from the current article."
10944 (interactive (list (gnus-summary-article-number)))
10945 ;; Remove old bookmark, if one exists.
10946 (if (not (assq article gnus-newsgroup-bookmarks))
10947 (gnus-message 6 "No bookmark in current article.")
10948 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10949 (gnus-message 6 "Removed bookmark.")))
10950
10951 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10952 (defun gnus-summary-mark-as-dormant (n)
10953 "Mark N articles forward as dormant.
10954 If N is negative, mark backward instead. The difference between N and
10955 the actual number of articles marked is returned."
10956 (interactive "p")
10957 (gnus-summary-mark-forward n gnus-dormant-mark))
10958
10959 (defun gnus-summary-set-process-mark (article)
10960 "Set the process mark on ARTICLE and update the summary line."
10961 (setq gnus-newsgroup-processable
10962 (cons article
10963 (delq article gnus-newsgroup-processable)))
10964 (when (gnus-summary-goto-subject article)
10965 (gnus-summary-show-thread)
10966 (gnus-summary-goto-subject article)
10967 (gnus-summary-update-secondary-mark article)))
10968
10969 (defun gnus-summary-remove-process-mark (&rest articles)
10970 "Remove the process mark from ARTICLES and update the summary line."
10971 (dolist (article articles)
10972 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10973 (when (gnus-summary-goto-subject article)
10974 (gnus-summary-show-thread)
10975 (gnus-summary-goto-subject article)
10976 (gnus-summary-update-secondary-mark article)))
10977 t)
10978
10979 (defun gnus-summary-set-saved-mark (article)
10980 "Set the process mark on ARTICLE and update the summary line."
10981 (push article gnus-newsgroup-saved)
10982 (when (gnus-summary-goto-subject article)
10983 (gnus-summary-update-secondary-mark article)))
10984
10985 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10986 "Mark N articles as read forwards.
10987 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10988 The difference between N and the actual number of articles marked is
10989 returned.
10990 If NO-EXPIRE, auto-expiry will be inhibited."
10991 (interactive "p")
10992 (gnus-summary-show-thread)
10993 (let ((backward (< n 0))
10994 (gnus-summary-goto-unread
10995 (and gnus-summary-goto-unread
10996 (not (eq gnus-summary-goto-unread 'never))
10997 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10998 gnus-ticked-mark gnus-dormant-mark)))))
10999 (n (abs n))
11000 (mark (or mark gnus-del-mark)))
11001 (while (and (> n 0)
11002 (gnus-summary-mark-article nil mark no-expire)
11003 (zerop (gnus-summary-next-subject
11004 (if backward -1 1)
11005 (and gnus-summary-goto-unread
11006 (not (eq gnus-summary-goto-unread 'never)))
11007 t)))
11008 (setq n (1- n)))
11009 (when (/= 0 n)
11010 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11011 (gnus-summary-recenter)
11012 (gnus-summary-position-point)
11013 (gnus-set-mode-line 'summary)
11014 n))
11015
11016 (defun gnus-summary-mark-article-as-read (mark)
11017 "Mark the current article quickly as read with MARK."
11018 (let ((article (gnus-summary-article-number)))
11019 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11020 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11021 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11022 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11023 (push (cons article mark) gnus-newsgroup-reads)
11024 ;; Possibly remove from cache, if that is used.
11025 (when gnus-use-cache
11026 (gnus-cache-enter-remove-article article))
11027 ;; Allow the backend to change the mark.
11028 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11029 ;; Check for auto-expiry.
11030 (when (and gnus-newsgroup-auto-expire
11031 (memq mark gnus-auto-expirable-marks))
11032 (setq mark gnus-expirable-mark)
11033 ;; Let the backend know about the mark change.
11034 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11035 (push article gnus-newsgroup-expirable))
11036 ;; Set the mark in the buffer.
11037 (gnus-summary-update-mark mark 'unread)
11038 t))
11039
11040 (defun gnus-summary-mark-article-as-unread (mark)
11041 "Mark the current article quickly as unread with MARK."
11042 (let* ((article (gnus-summary-article-number))
11043 (old-mark (gnus-summary-article-mark article)))
11044 ;; Allow the backend to change the mark.
11045 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11046 (if (eq mark old-mark)
11047 t
11048 (if (<= article 0)
11049 (progn
11050 (gnus-error 1 "Can't mark negative article numbers")
11051 nil)
11052 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11053 (setq gnus-newsgroup-spam-marked
11054 (delq article gnus-newsgroup-spam-marked))
11055 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11056 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11057 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11058 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11059 (cond ((= mark gnus-ticked-mark)
11060 (setq gnus-newsgroup-marked
11061 (gnus-add-to-sorted-list gnus-newsgroup-marked
11062 article)))
11063 ((= mark gnus-spam-mark)
11064 (setq gnus-newsgroup-spam-marked
11065 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11066 article)))
11067 ((= mark gnus-dormant-mark)
11068 (setq gnus-newsgroup-dormant
11069 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11070 article)))
11071 (t
11072 (setq gnus-newsgroup-unreads
11073 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11074 article))))
11075 (gnus-alist-pull article gnus-newsgroup-reads)
11076
11077 ;; See whether the article is to be put in the cache.
11078 (and gnus-use-cache
11079 (vectorp (gnus-summary-article-header article))
11080 (save-excursion
11081 (gnus-cache-possibly-enter-article
11082 gnus-newsgroup-name article
11083 (= mark gnus-ticked-mark)
11084 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11085
11086 ;; Fix the mark.
11087 (gnus-summary-update-mark mark 'unread)
11088 t))))
11089
11090 (defun gnus-summary-mark-article (&optional article mark no-expire)
11091 "Mark ARTICLE with MARK. MARK can be any character.
11092 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11093 `??' (dormant) and `?E' (expirable).
11094 If MARK is nil, then the default character `?r' is used.
11095 If ARTICLE is nil, then the article on the current line will be
11096 marked.
11097 If NO-EXPIRE, auto-expiry will be inhibited."
11098 ;; The mark might be a string.
11099 (when (stringp mark)
11100 (setq mark (aref mark 0)))
11101 ;; If no mark is given, then we check auto-expiring.
11102 (when (null mark)
11103 (setq mark gnus-del-mark))
11104 (when (and (not no-expire)
11105 gnus-newsgroup-auto-expire
11106 (memq mark gnus-auto-expirable-marks))
11107 (setq mark gnus-expirable-mark))
11108 (let ((article (or article (gnus-summary-article-number)))
11109 (old-mark (gnus-summary-article-mark article)))
11110 ;; Allow the backend to change the mark.
11111 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11112 (if (eq mark old-mark)
11113 t
11114 (unless article
11115 (error "No article on current line"))
11116 (if (not (if (or (= mark gnus-unread-mark)
11117 (= mark gnus-ticked-mark)
11118 (= mark gnus-spam-mark)
11119 (= mark gnus-dormant-mark))
11120 (gnus-mark-article-as-unread article mark)
11121 (gnus-mark-article-as-read article mark)))
11122 t
11123 ;; See whether the article is to be put in the cache.
11124 (and gnus-use-cache
11125 (not (= mark gnus-canceled-mark))
11126 (vectorp (gnus-summary-article-header article))
11127 (save-excursion
11128 (gnus-cache-possibly-enter-article
11129 gnus-newsgroup-name article
11130 (= mark gnus-ticked-mark)
11131 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11132
11133 (when (gnus-summary-goto-subject article nil t)
11134 (let ((inhibit-read-only t))
11135 (gnus-summary-show-thread)
11136 ;; Fix the mark.
11137 (gnus-summary-update-mark mark 'unread)
11138 t))))))
11139
11140 (defun gnus-summary-update-secondary-mark (article)
11141 "Update the secondary (read, process, cache) mark."
11142 (gnus-summary-update-mark
11143 (cond ((memq article gnus-newsgroup-processable)
11144 gnus-process-mark)
11145 ((memq article gnus-newsgroup-cached)
11146 gnus-cached-mark)
11147 ((memq article gnus-newsgroup-replied)
11148 gnus-replied-mark)
11149 ((memq article gnus-newsgroup-forwarded)
11150 gnus-forwarded-mark)
11151 ((memq article gnus-newsgroup-saved)
11152 gnus-saved-mark)
11153 ((memq article gnus-newsgroup-unseen)
11154 gnus-unseen-mark)
11155 (t gnus-no-mark))
11156 'replied)
11157 (when (gnus-visual-p 'summary-highlight 'highlight)
11158 (gnus-summary-highlight-line)
11159 (gnus-run-hooks 'gnus-summary-update-hook))
11160 t)
11161
11162 (defun gnus-summary-update-download-mark (article)
11163 "Update the download mark."
11164 (gnus-summary-update-mark
11165 (cond ((memq article gnus-newsgroup-undownloaded)
11166 gnus-undownloaded-mark)
11167 (gnus-newsgroup-agentized
11168 gnus-downloaded-mark)
11169 (t
11170 gnus-no-mark))
11171 'download)
11172 (gnus-summary-update-line t)
11173 t)
11174
11175 (defun gnus-summary-update-mark (mark type)
11176 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11177 (inhibit-read-only t))
11178 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11179 (when forward
11180 (when (looking-at "\r")
11181 (incf forward))
11182 (when (<= (+ forward (point)) (point-max))
11183 ;; Go to the right position on the line.
11184 (goto-char (+ forward (point)))
11185 ;; Replace the old mark with the new mark.
11186 (let ((to-insert
11187 (mm-subst-char-in-string
11188 (char-after) mark
11189 (buffer-substring (point) (1+ (point))))))
11190 (delete-region (point) (1+ (point)))
11191 (insert to-insert))
11192 ;; Optionally update the marks by some user rule.
11193 (when (eq type 'unread)
11194 (gnus-data-set-mark
11195 (gnus-data-find (gnus-summary-article-number)) mark)
11196 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11197
11198 (defun gnus-mark-article-as-read (article &optional mark)
11199 "Enter ARTICLE in the pertinent lists and remove it from others."
11200 ;; Make the article expirable.
11201 (let ((mark (or mark gnus-del-mark)))
11202 (setq gnus-newsgroup-expirable
11203 (if (= mark gnus-expirable-mark)
11204 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11205 (delq article gnus-newsgroup-expirable)))
11206 ;; Remove from unread and marked lists.
11207 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11208 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11209 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11210 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11211 (push (cons article mark) gnus-newsgroup-reads)
11212 ;; Possibly remove from cache, if that is used.
11213 (when gnus-use-cache
11214 (gnus-cache-enter-remove-article article))
11215 t))
11216
11217 (defun gnus-mark-article-as-unread (article &optional mark)
11218 "Enter ARTICLE in the pertinent lists and remove it from others."
11219 (let ((mark (or mark gnus-ticked-mark)))
11220 (if (<= article 0)
11221 (progn
11222 (gnus-error 1 "Can't mark negative article numbers")
11223 nil)
11224 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11225 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11226 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11227 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11228 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11229
11230 ;; Unsuppress duplicates?
11231 (when gnus-suppress-duplicates
11232 (gnus-dup-unsuppress-article article))
11233
11234 (cond ((= mark gnus-ticked-mark)
11235 (setq gnus-newsgroup-marked
11236 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11237 ((= mark gnus-spam-mark)
11238 (setq gnus-newsgroup-spam-marked
11239 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11240 article)))
11241 ((= mark gnus-dormant-mark)
11242 (setq gnus-newsgroup-dormant
11243 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11244 (t
11245 (setq gnus-newsgroup-unreads
11246 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11247 (gnus-alist-pull article gnus-newsgroup-reads)
11248 t)))
11249
11250 (defun gnus-summary-tick-article-forward (n)
11251 "Tick N articles forwards.
11252 If N is negative, tick backwards instead.
11253 The difference between N and the number of articles ticked is returned."
11254 (interactive "p")
11255 (gnus-summary-mark-forward n gnus-ticked-mark))
11256
11257 (defun gnus-summary-tick-article-backward (n)
11258 "Tick N articles backwards.
11259 The difference between N and the number of articles ticked is returned."
11260 (interactive "p")
11261 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11262
11263 (defun gnus-summary-tick-article (&optional article clear-mark)
11264 "Mark current article as unread.
11265 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11266 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11267 (interactive)
11268 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11269 gnus-ticked-mark)))
11270
11271 (defun gnus-summary-mark-as-read-forward (n)
11272 "Mark N articles as read forwards.
11273 If N is negative, mark backwards instead.
11274 The difference between N and the actual number of articles marked is
11275 returned."
11276 (interactive "p")
11277 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11278
11279 (defun gnus-summary-mark-as-read-backward (n)
11280 "Mark the N articles as read backwards.
11281 The difference between N and the actual number of articles marked is
11282 returned."
11283 (interactive "p")
11284 (gnus-summary-mark-forward
11285 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11286
11287 (defun gnus-summary-mark-as-read (&optional article mark)
11288 "Mark current article as read.
11289 ARTICLE specifies the article to be marked as read.
11290 MARK specifies a string to be inserted at the beginning of the line."
11291 (gnus-summary-mark-article article mark))
11292
11293 (defun gnus-summary-clear-mark-forward (n)
11294 "Clear marks from N articles forward.
11295 If N is negative, clear backward instead.
11296 The difference between N and the number of marks cleared is returned."
11297 (interactive "p")
11298 (gnus-summary-mark-forward n gnus-unread-mark))
11299
11300 (defun gnus-summary-clear-mark-backward (n)
11301 "Clear marks from N articles backward.
11302 The difference between N and the number of marks cleared is returned."
11303 (interactive "p")
11304 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11305
11306 (defun gnus-summary-mark-unread-as-read ()
11307 "Intended to be used by `gnus-mark-article-hook'."
11308 (when (memq gnus-current-article gnus-newsgroup-unreads)
11309 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11310
11311 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11312 "Intended to be used by `gnus-mark-article-hook'."
11313 (let ((mark (gnus-summary-article-mark)))
11314 (when (or (gnus-unread-mark-p mark)
11315 (gnus-read-mark-p mark))
11316 (gnus-summary-mark-article gnus-current-article
11317 (or new-mark gnus-read-mark)))))
11318
11319 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11320 "Intended to be used by `gnus-mark-article-hook'."
11321 (let ((mark (gnus-summary-article-mark)))
11322 (when (or (gnus-unread-mark-p mark)
11323 (gnus-read-mark-p mark))
11324 (gnus-summary-mark-article (gnus-summary-article-number)
11325 (or new-mark gnus-read-mark)))))
11326
11327 (defun gnus-summary-mark-unread-as-ticked ()
11328 "Intended to be used by `gnus-mark-article-hook'."
11329 (when (memq gnus-current-article gnus-newsgroup-unreads)
11330 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11331
11332 (defun gnus-summary-mark-region-as-read (point mark all)
11333 "Mark all unread articles between point and mark as read.
11334 If given a prefix, mark all articles between point and mark as read,
11335 even ticked and dormant ones."
11336 (interactive "r\nP")
11337 (save-excursion
11338 (let (article)
11339 (goto-char point)
11340 (beginning-of-line)
11341 (while (and
11342 (< (point) mark)
11343 (progn
11344 (when (or all
11345 (memq (setq article (gnus-summary-article-number))
11346 gnus-newsgroup-unreads))
11347 (gnus-summary-mark-article article gnus-del-mark))
11348 t)
11349 (gnus-summary-find-next))))))
11350
11351 (defun gnus-summary-mark-below (score mark)
11352 "Mark articles with score less than SCORE with MARK."
11353 (interactive "P\ncMark: ")
11354 (setq score (if score
11355 (prefix-numeric-value score)
11356 (or gnus-summary-default-score 0)))
11357 (with-current-buffer gnus-summary-buffer
11358 (goto-char (point-min))
11359 (while
11360 (progn
11361 (and (< (gnus-summary-article-score) score)
11362 (gnus-summary-mark-article nil mark))
11363 (gnus-summary-find-next)))))
11364
11365 (defun gnus-summary-kill-below (&optional score)
11366 "Mark articles with score below SCORE as read."
11367 (interactive "P")
11368 (gnus-summary-mark-below score gnus-killed-mark))
11369
11370 (defun gnus-summary-clear-above (&optional score)
11371 "Clear all marks from articles with score above SCORE."
11372 (interactive "P")
11373 (gnus-summary-mark-above score gnus-unread-mark))
11374
11375 (defun gnus-summary-tick-above (&optional score)
11376 "Tick all articles with score above SCORE."
11377 (interactive "P")
11378 (gnus-summary-mark-above score gnus-ticked-mark))
11379
11380 (defun gnus-summary-mark-above (score mark)
11381 "Mark articles with score over SCORE with MARK."
11382 (interactive "P\ncMark: ")
11383 (setq score (if score
11384 (prefix-numeric-value score)
11385 (or gnus-summary-default-score 0)))
11386 (with-current-buffer gnus-summary-buffer
11387 (goto-char (point-min))
11388 (while (and (progn
11389 (when (> (gnus-summary-article-score) score)
11390 (gnus-summary-mark-article nil mark))
11391 t)
11392 (gnus-summary-find-next)))))
11393
11394 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11395 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11396 (defun gnus-summary-limit-include-expunged (&optional no-error)
11397 "Display all the hidden articles that were expunged for low scores."
11398 (interactive)
11399 (let ((inhibit-read-only t))
11400 (let ((scored gnus-newsgroup-scored)
11401 headers h)
11402 (while scored
11403 (unless (gnus-summary-article-header (caar scored))
11404 (and (setq h (gnus-number-to-header (caar scored)))
11405 (< (cdar scored) gnus-summary-expunge-below)
11406 (push h headers)))
11407 (setq scored (cdr scored)))
11408 (if (not headers)
11409 (when (not no-error)
11410 (error "No expunged articles hidden"))
11411 (goto-char (point-min))
11412 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11413 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11414 (dolist (x headers)
11415 (push (mail-header-number x) gnus-newsgroup-limit))
11416 (gnus-summary-prepare-unthreaded (nreverse headers))
11417 (goto-char (point-min))
11418 (gnus-summary-position-point)
11419 t))))
11420
11421 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11422 "Mark all unread articles in this newsgroup as read.
11423 If prefix argument ALL is non-nil, ticked and dormant articles will
11424 also be marked as read.
11425 If QUIETLY is non-nil, no questions will be asked.
11426
11427 If TO-HERE is non-nil, it should be a point in the buffer. All
11428 articles before (after, if REVERSE is set) this point will be marked
11429 as read.
11430
11431 Note that this function will only catch up the unread article
11432 in the current summary buffer limitation.
11433
11434 The number of articles marked as read is returned."
11435 (interactive "P")
11436 (prog1
11437 (save-excursion
11438 (when (or quietly
11439 (not gnus-interactive-catchup) ;Without confirmation?
11440 gnus-expert-user
11441 (gnus-y-or-n-p
11442 (if all
11443 "Mark absolutely all articles as read? "
11444 "Mark all unread articles as read? ")))
11445 (if (and not-mark
11446 (not gnus-newsgroup-adaptive)
11447 (not gnus-newsgroup-auto-expire)
11448 (not gnus-suppress-duplicates)
11449 (or (not gnus-use-cache)
11450 (eq gnus-use-cache 'passive)))
11451 (progn
11452 (when all
11453 (setq gnus-newsgroup-marked nil
11454 gnus-newsgroup-spam-marked nil
11455 gnus-newsgroup-dormant nil))
11456 (setq gnus-newsgroup-unreads
11457 (gnus-sorted-nunion
11458 (gnus-sorted-intersection gnus-newsgroup-unreads
11459 gnus-newsgroup-downloadable)
11460 (gnus-sorted-difference gnus-newsgroup-unfetched
11461 gnus-newsgroup-cached))))
11462 ;; We actually mark all articles as canceled, which we
11463 ;; have to do when using auto-expiry or adaptive scoring.
11464 (gnus-summary-show-all-threads)
11465 (if (and to-here reverse)
11466 (progn
11467 (goto-char to-here)
11468 (gnus-summary-mark-current-read-and-unread-as-read
11469 gnus-catchup-mark)
11470 (while (gnus-summary-find-next (not all))
11471 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11472 (when (gnus-summary-first-subject (not all))
11473 (while (and
11474 (if to-here (< (point) to-here) t)
11475 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11476 (gnus-summary-find-next (not all))))))
11477 (gnus-set-mode-line 'summary))
11478 t))
11479 (gnus-summary-position-point)))
11480
11481 (defun gnus-summary-catchup-to-here (&optional all)
11482 "Mark all unticked articles before the current one as read.
11483 If ALL is non-nil, also mark ticked and dormant articles as read."
11484 (interactive "P")
11485 (save-excursion
11486 (gnus-save-hidden-threads
11487 (let ((beg (point)))
11488 ;; We check that there are unread articles.
11489 (when (or all (gnus-summary-find-prev))
11490 (gnus-summary-catchup all t beg)))))
11491 (gnus-summary-position-point))
11492
11493 (defun gnus-summary-catchup-from-here (&optional all)
11494 "Mark all unticked articles after (and including) the current one as read.
11495 If ALL is non-nil, also mark ticked and dormant articles as read."
11496 (interactive "P")
11497 (save-excursion
11498 (gnus-save-hidden-threads
11499 (let ((beg (point)))
11500 ;; We check that there are unread articles.
11501 (when (or all (gnus-summary-find-next))
11502 (gnus-summary-catchup all t beg nil t)))))
11503 (gnus-summary-position-point))
11504
11505 (defun gnus-summary-catchup-all (&optional quietly)
11506 "Mark all articles in this newsgroup as read.
11507 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11508 instead, which marks only unread articles as read."
11509 (interactive "P")
11510 (gnus-summary-catchup t quietly))
11511
11512 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11513 "Mark all unread articles in this group as read, then exit.
11514 If prefix argument ALL is non-nil, all articles are marked as read.
11515 If QUIETLY is non-nil, no questions will be asked."
11516 (interactive "P")
11517 (when (gnus-summary-catchup all quietly nil 'fast)
11518 ;; Select next newsgroup or exit.
11519 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11520 (eq gnus-auto-select-next 'quietly))
11521 (gnus-summary-next-group nil)
11522 (gnus-summary-exit))))
11523
11524 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11525 "Mark all articles in this newsgroup as read, and then exit.
11526 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11527 instead, which marks only unread articles as read."
11528 (interactive "P")
11529 (gnus-summary-catchup-and-exit t quietly))
11530
11531 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11532 "Mark all articles in this group as read and select the next group.
11533 If given a prefix, mark all articles, unread as well as ticked, as
11534 read."
11535 (interactive "P")
11536 (save-excursion
11537 (gnus-summary-catchup all))
11538 (gnus-summary-next-group))
11539
11540 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11541 "Mark all articles in this group as read and select the previous group.
11542 If given a prefix, mark all articles, unread as well as ticked, as
11543 read."
11544 (interactive "P")
11545 (save-excursion
11546 (gnus-summary-catchup all))
11547 (gnus-summary-next-group nil nil t))
11548
11549 ;;;
11550 ;;; with article
11551 ;;;
11552
11553 (defmacro gnus-with-article (article &rest forms)
11554 "Select ARTICLE and perform FORMS in the original article buffer.
11555 Then replace the article with the result."
11556 `(progn
11557 ;; We don't want the article to be marked as read.
11558 (let (gnus-mark-article-hook)
11559 (gnus-summary-select-article t t nil ,article))
11560 (set-buffer gnus-original-article-buffer)
11561 ,@forms
11562 (if (not (gnus-check-backend-function
11563 'request-replace-article (car gnus-article-current)))
11564 (gnus-message 5 "Read-only group; not replacing")
11565 (unless (gnus-request-replace-article
11566 ,article (car gnus-article-current)
11567 (current-buffer) t)
11568 (error "Couldn't replace article")))
11569 ;; The cache and backlog have to be flushed somewhat.
11570 (when gnus-keep-backlog
11571 (gnus-backlog-remove-article
11572 (car gnus-article-current) (cdr gnus-article-current)))
11573 (when gnus-use-cache
11574 (gnus-cache-update-article
11575 (car gnus-article-current) (cdr gnus-article-current)))))
11576
11577 (put 'gnus-with-article 'lisp-indent-function 1)
11578 (put 'gnus-with-article 'edebug-form-spec '(form body))
11579
11580 ;; Thread-based commands.
11581
11582 (defun gnus-summary-articles-in-thread (&optional article)
11583 "Return a list of all articles in the current thread.
11584 If ARTICLE is non-nil, return all articles in the thread that starts
11585 with that article."
11586 (let* ((article (or article (gnus-summary-article-number)))
11587 (data (gnus-data-find-list article))
11588 (top-level (gnus-data-level (car data)))
11589 (top-subject
11590 (cond ((null gnus-thread-operation-ignore-subject)
11591 (gnus-simplify-subject-re
11592 (mail-header-subject (gnus-data-header (car data)))))
11593 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11594 (gnus-simplify-subject-fuzzy
11595 (mail-header-subject (gnus-data-header (car data)))))
11596 (t nil)))
11597 (end-point (save-excursion
11598 (goto-char (gnus-data-pos (car data)))
11599 (if (gnus-summary-go-to-next-thread)
11600 (point) (point-max))))
11601 articles)
11602 (while (and data
11603 (< (gnus-data-pos (car data)) end-point))
11604 (when (or (not top-subject)
11605 (string= top-subject
11606 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11607 (gnus-simplify-subject-fuzzy
11608 (mail-header-subject
11609 (gnus-data-header (car data))))
11610 (gnus-simplify-subject-re
11611 (mail-header-subject
11612 (gnus-data-header (car data)))))))
11613 (push (gnus-data-number (car data)) articles))
11614 (unless (and (setq data (cdr data))
11615 (> (gnus-data-level (car data)) top-level))
11616 (setq data nil)))
11617 ;; Return the list of articles.
11618 (nreverse articles)))
11619
11620 (defun gnus-summary-rethread-current ()
11621 "Rethread the thread the current article is part of."
11622 (interactive)
11623 (let* ((gnus-show-threads t)
11624 (article (gnus-summary-article-number))
11625 (id (mail-header-id (gnus-summary-article-header)))
11626 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11627 (unless id
11628 (error "No article on the current line"))
11629 (gnus-rebuild-thread id)
11630 (gnus-summary-goto-subject article)))
11631
11632 (defun gnus-summary-reparent-thread ()
11633 "Make the current article child of the marked (or previous) article.
11634
11635 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11636 is non-nil or the Subject: of both articles are the same."
11637 (interactive)
11638 (unless (not (gnus-group-read-only-p))
11639 (error "The current newsgroup does not support article editing"))
11640 (unless (<= (length gnus-newsgroup-processable) 1)
11641 (error "No more than one article may be marked"))
11642 (let ((child (gnus-summary-article-number))
11643 ;; First grab the marked article, otherwise one line up.
11644 (parent (if (not (null gnus-newsgroup-processable))
11645 (car gnus-newsgroup-processable)
11646 (save-excursion
11647 (if (eq (forward-line -1) 0)
11648 (gnus-summary-article-number)
11649 (error "Beginning of summary buffer"))))))
11650 (gnus-summary-reparent-children parent (list child))))
11651
11652 (defun gnus-summary-reparent-children (parent children)
11653 "Make PARENT the parent of CHILDREN.
11654 When called interactively, PARENT is the current article and CHILDREN
11655 are the process-marked articles."
11656 (interactive
11657 (list (gnus-summary-article-number)
11658 (gnus-summary-work-articles nil)))
11659 (dolist (child children)
11660 (save-window-excursion
11661 (let ((gnus-article-buffer " *reparent*"))
11662 (unless (not (eq parent child))
11663 (error "An article may not be self-referential"))
11664 (let ((message-id (mail-header-id
11665 (gnus-summary-article-header parent))))
11666 (unless (and message-id (not (equal message-id "")))
11667 (error "No message-id in desired parent"))
11668 (gnus-with-article child
11669 (save-restriction
11670 (goto-char (point-min))
11671 (message-narrow-to-head)
11672 (if (re-search-forward "^References: " nil t)
11673 (progn
11674 (re-search-forward "^[^ \t]" nil t)
11675 (forward-line -1)
11676 (end-of-line)
11677 (insert " " message-id))
11678 (insert "References: " message-id "\n"))))
11679 (set-buffer gnus-summary-buffer)
11680 (gnus-summary-unmark-all-processable)
11681 (gnus-summary-update-article child)
11682 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11683 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11684 (gnus-summary-rethread-current)
11685 (gnus-message 3 "Article %d is now the child of article %d"
11686 child parent))))))
11687
11688 (defun gnus-summary-toggle-threads (&optional arg)
11689 "Toggle showing conversation threads.
11690 If ARG is positive number, turn showing conversation threads on."
11691 (interactive "P")
11692 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11693 (setq gnus-show-threads
11694 (if (null arg) (not gnus-show-threads)
11695 (> (prefix-numeric-value arg) 0)))
11696 (gnus-summary-prepare)
11697 (gnus-summary-goto-subject current)
11698 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11699 (gnus-summary-position-point)))
11700
11701 (defun gnus-summary-show-all-threads ()
11702 "Show all threads."
11703 (interactive)
11704 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11705 (gnus-summary-position-point))
11706
11707 (defsubst gnus-summary--inv (p)
11708 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11709
11710 (defun gnus-summary-show-thread ()
11711 "Show thread subtrees.
11712 Returns nil if no thread was there to be shown."
11713 (interactive)
11714 (let* ((orig (point))
11715 (end (point-at-eol))
11716 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11717 ;; Leave point at bol
11718 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11719 (eoi (when end
11720 (if (fboundp 'next-single-char-property-change)
11721 ;; Note: XEmacs version of n-s-c-p-c may return nil
11722 (or (next-single-char-property-change end 'invisible)
11723 (point-max))
11724 (while (progn
11725 (end-of-line 2)
11726 (and (not (eobp))
11727 (eq (get-char-property (point) 'invisible)
11728 'gnus-sum))))
11729 (point)))))
11730 (when eoi
11731 (remove-overlays beg eoi 'invisible 'gnus-sum)
11732 (goto-char orig)
11733 (gnus-summary-position-point)
11734 eoi)))
11735
11736 (defun gnus-summary-maybe-hide-threads ()
11737 "If requested, hide the threads that should be hidden."
11738 (when (and gnus-show-threads
11739 gnus-thread-hide-subtree)
11740 (gnus-summary-hide-all-threads
11741 (if (or (consp gnus-thread-hide-subtree)
11742 (functionp gnus-thread-hide-subtree))
11743 (gnus-make-predicate gnus-thread-hide-subtree)
11744 nil))))
11745
11746 ;;; Hiding predicates.
11747
11748 (defun gnus-article-unread-p (header)
11749 (memq (mail-header-number header) gnus-newsgroup-unreads))
11750
11751 (defun gnus-article-unseen-p (header)
11752 (memq (mail-header-number header) gnus-newsgroup-unseen))
11753
11754 (defun gnus-map-articles (predicate articles)
11755 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11756 (apply 'gnus-or (mapcar predicate
11757 (mapcar (lambda (number)
11758 (gnus-summary-article-header number))
11759 articles))))
11760
11761 (defun gnus-summary-hide-all-threads (&optional predicate)
11762 "Hide all thread subtrees.
11763 If PREDICATE is supplied, threads that satisfy this predicate
11764 will not be hidden."
11765 (interactive)
11766 (save-excursion
11767 (goto-char (point-min))
11768 (let ((end nil)
11769 (count 0))
11770 (while (not end)
11771 (incf count)
11772 (when (zerop (mod count 1000))
11773 (message "Hiding all threads... %d" count))
11774 (when (or (not predicate)
11775 (gnus-map-articles
11776 predicate (gnus-summary-article-children)))
11777 (gnus-summary-hide-thread))
11778 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11779 (gnus-summary-position-point))
11780
11781 (defun gnus-summary-hide-thread ()
11782 "Hide thread subtrees.
11783 If PREDICATE is supplied, threads that satisfy this predicate
11784 will not be hidden.
11785 Returns nil if no threads were there to be hidden."
11786 (interactive)
11787 (beginning-of-line)
11788 (let ((start (point))
11789 (starteol (line-end-position))
11790 (article (gnus-summary-article-number)))
11791 ;; Go forward until either the buffer ends or the subthread ends.
11792 (when (and (not (eobp))
11793 (or (zerop (gnus-summary-next-thread 1 t))
11794 (goto-char (point-max))))
11795 (if (and (> (point) start)
11796 ;; FIXME: this should actually search for a non-invisible \n.
11797 (search-backward "\n" start t))
11798 (progn
11799 (when (> (point) starteol)
11800 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11801 (let ((ol (make-overlay starteol (point) nil t nil)))
11802 (overlay-put ol 'invisible 'gnus-sum)
11803 (overlay-put ol 'evaporate t)))
11804 (gnus-summary-goto-subject article)
11805 (when (> start (point))
11806 (message "Hiding the thread moved us backwards, aborting!")
11807 (goto-char (point-max))))
11808 (goto-char start)
11809 nil))))
11810
11811 (defun gnus-summary-go-to-next-thread (&optional previous)
11812 "Go to the same level (or less) next thread.
11813 If PREVIOUS is non-nil, go to previous thread instead.
11814 Return the article number moved to, or nil if moving was impossible."
11815 (let ((level (gnus-summary-thread-level))
11816 (way (if previous -1 1))
11817 (beg (point)))
11818 (forward-line way)
11819 (while (and (not (eobp))
11820 (< level (gnus-summary-thread-level)))
11821 (forward-line way))
11822 (if (eobp)
11823 (progn
11824 (goto-char beg)
11825 nil)
11826 (setq beg (point))
11827 (prog1
11828 (gnus-summary-article-number)
11829 (goto-char beg)))))
11830
11831 (defun gnus-summary-next-thread (n &optional silent)
11832 "Go to the same level next N'th thread.
11833 If N is negative, search backward instead.
11834 Returns the difference between N and the number of skips actually
11835 done.
11836
11837 If SILENT, don't output messages."
11838 (interactive "p")
11839 (let ((backward (< n 0))
11840 (n (abs n)))
11841 (while (and (> n 0)
11842 (gnus-summary-go-to-next-thread backward))
11843 (decf n))
11844 (unless silent
11845 (gnus-summary-position-point))
11846 (when (and (not silent) (/= 0 n))
11847 (gnus-message 7 "No more threads"))
11848 n))
11849
11850 (defun gnus-summary-prev-thread (n)
11851 "Go to the same level previous N'th thread.
11852 Returns the difference between N and the number of skips actually
11853 done."
11854 (interactive "p")
11855 (gnus-summary-next-thread (- n)))
11856
11857 (defun gnus-summary-go-down-thread ()
11858 "Go down one level in the current thread."
11859 (let ((children (gnus-summary-article-children)))
11860 (when children
11861 (gnus-summary-goto-subject (car children)))))
11862
11863 (defun gnus-summary-go-up-thread ()
11864 "Go up one level in the current thread."
11865 (let ((parent (gnus-summary-article-parent)))
11866 (when parent
11867 (gnus-summary-goto-subject parent))))
11868
11869 (defun gnus-summary-down-thread (n)
11870 "Go down thread N steps.
11871 If N is negative, go up instead.
11872 Returns the difference between N and how many steps down that were
11873 taken."
11874 (interactive "p")
11875 (let ((up (< n 0))
11876 (n (abs n)))
11877 (while (and (> n 0)
11878 (if up (gnus-summary-go-up-thread)
11879 (gnus-summary-go-down-thread)))
11880 (setq n (1- n)))
11881 (gnus-summary-position-point)
11882 (when (/= 0 n)
11883 (gnus-message 7 "Can't go further"))
11884 n))
11885
11886 (defun gnus-summary-up-thread (n)
11887 "Go up thread N steps.
11888 If N is negative, go down instead.
11889 Returns the difference between N and how many steps down that were
11890 taken."
11891 (interactive "p")
11892 (gnus-summary-down-thread (- n)))
11893
11894 (defun gnus-summary-top-thread ()
11895 "Go to the top of the thread."
11896 (interactive)
11897 (while (gnus-summary-go-up-thread))
11898 (gnus-summary-article-number))
11899
11900 (defun gnus-summary-expire-thread ()
11901 "Mark articles under current thread as expired."
11902 (interactive)
11903 (gnus-summary-kill-thread 0))
11904
11905 (defun gnus-summary-kill-thread (&optional unmark)
11906 "Mark articles under current thread as read.
11907 If the prefix argument is positive, remove any kinds of marks.
11908 If the prefix argument is zero, mark thread as expired.
11909 If the prefix argument is negative, tick articles instead."
11910 (interactive "P")
11911 (when unmark
11912 (setq unmark (prefix-numeric-value unmark)))
11913 (let ((articles (gnus-summary-articles-in-thread))
11914 (hide (or (null unmark) (= unmark 0))))
11915 (save-excursion
11916 ;; Expand the thread.
11917 (gnus-summary-show-thread)
11918 ;; Mark all the articles.
11919 (while articles
11920 (gnus-summary-goto-subject (car articles))
11921 (cond ((null unmark)
11922 (gnus-summary-mark-article-as-read gnus-killed-mark))
11923 ((> unmark 0)
11924 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11925 ((= unmark 0)
11926 (gnus-summary-mark-article nil gnus-expirable-mark))
11927 (t
11928 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11929 (setq articles (cdr articles))))
11930 ;; Hide killed subtrees when hide is true.
11931 (and hide
11932 gnus-thread-hide-killed
11933 (gnus-summary-hide-thread))
11934 ;; If hide is t, go to next unread subject.
11935 (when hide
11936 ;; Go to next unread subject.
11937 (gnus-summary-next-subject 1 t)))
11938 (gnus-set-mode-line 'summary))
11939
11940 ;; Summary sorting commands
11941
11942 (defun gnus-summary-sort-by-number (&optional reverse)
11943 "Sort the summary buffer by article number.
11944 Argument REVERSE means reverse order."
11945 (interactive "P")
11946 (gnus-summary-sort 'number reverse))
11947
11948 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11949 "Sort the summary buffer by most recent article number.
11950 Argument REVERSE means reverse order."
11951 (interactive "P")
11952 (gnus-summary-sort 'most-recent-number reverse))
11953
11954 (defun gnus-summary-sort-by-random (&optional reverse)
11955 "Randomize the order in the summary buffer.
11956 Argument REVERSE means to randomize in reverse order."
11957 (interactive "P")
11958 (gnus-summary-sort 'random reverse))
11959
11960 (defun gnus-summary-sort-by-author (&optional reverse)
11961 "Sort the summary buffer by author name alphabetically.
11962 If `case-fold-search' is non-nil, case of letters is ignored.
11963 Argument REVERSE means reverse order."
11964 (interactive "P")
11965 (gnus-summary-sort 'author reverse))
11966
11967 (defun gnus-summary-sort-by-recipient (&optional reverse)
11968 "Sort the summary buffer by recipient name alphabetically.
11969 If `case-fold-search' is non-nil, case of letters is ignored.
11970 Argument REVERSE means reverse order."
11971 (interactive "P")
11972 (gnus-summary-sort 'recipient reverse))
11973
11974 (defun gnus-summary-sort-by-subject (&optional reverse)
11975 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11976 If `case-fold-search' is non-nil, case of letters is ignored.
11977 Argument REVERSE means reverse order."
11978 (interactive "P")
11979 (gnus-summary-sort 'subject reverse))
11980
11981 (defun gnus-summary-sort-by-date (&optional reverse)
11982 "Sort the summary buffer by date.
11983 Argument REVERSE means reverse order."
11984 (interactive "P")
11985 (gnus-summary-sort 'date reverse))
11986
11987 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11988 "Sort the summary buffer by most recent date.
11989 Argument REVERSE means reverse order."
11990 (interactive "P")
11991 (gnus-summary-sort 'most-recent-date reverse))
11992
11993 (defun gnus-summary-sort-by-score (&optional reverse)
11994 "Sort the summary buffer by score.
11995 Argument REVERSE means reverse order."
11996 (interactive "P")
11997 (gnus-summary-sort 'score reverse))
11998
11999 (defun gnus-summary-sort-by-lines (&optional reverse)
12000 "Sort the summary buffer by the number of lines.
12001 Argument REVERSE means reverse order."
12002 (interactive "P")
12003 (gnus-summary-sort 'lines reverse))
12004
12005 (defun gnus-summary-sort-by-chars (&optional reverse)
12006 "Sort the summary buffer by article length.
12007 Argument REVERSE means reverse order."
12008 (interactive "P")
12009 (gnus-summary-sort 'chars reverse))
12010
12011 (defun gnus-summary-sort-by-original (&optional reverse)
12012 "Sort the summary buffer using the default sorting method.
12013 Argument REVERSE means reverse order."
12014 (interactive "P")
12015 (let* ((inhibit-read-only t)
12016 (gnus-summary-prepare-hook nil))
12017 ;; We do the sorting by regenerating the threads.
12018 (gnus-summary-prepare)
12019 ;; Hide subthreads if needed.
12020 (gnus-summary-maybe-hide-threads)))
12021
12022 (defun gnus-summary-sort (predicate reverse)
12023 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
12024 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
12025 (article (intern (format "gnus-article-sort-by-%s" predicate)))
12026 (gnus-thread-sort-functions
12027 (if (not reverse)
12028 thread
12029 `(lambda (t1 t2)
12030 (,thread t2 t1))))
12031 (gnus-sort-gathered-threads-function
12032 gnus-thread-sort-functions)
12033 (gnus-article-sort-functions
12034 (if (not reverse)
12035 article
12036 `(lambda (t1 t2)
12037 (,article t2 t1))))
12038 (inhibit-read-only t)
12039 (gnus-summary-prepare-hook nil))
12040 ;; We do the sorting by regenerating the threads.
12041 (gnus-summary-prepare)
12042 ;; Hide subthreads if needed.
12043 (gnus-summary-maybe-hide-threads)))
12044
12045 ;; Summary saving commands.
12046
12047 (defun gnus-summary-save-article (&optional n not-saved)
12048 "Save the current article using the default saver function.
12049 If N is a positive number, save the N next articles.
12050 If N is a negative number, save the N previous articles.
12051 If N is nil and any articles have been marked with the process mark,
12052 save those articles instead.
12053 The variable `gnus-default-article-saver' specifies the saver function.
12054
12055 If the optional second argument NOT-SAVED is non-nil, articles saved
12056 will not be marked as saved."
12057 (interactive "P")
12058 (require 'gnus-art)
12059 (let* ((articles (gnus-summary-work-articles n))
12060 (save-buffer (save-excursion
12061 (nnheader-set-temp-buffer " *Gnus Save*")))
12062 (num (length articles))
12063 ;; Whether to save decoded articles or raw articles.
12064 (decode (when gnus-article-save-coding-system
12065 (get gnus-default-article-saver :decode)))
12066 ;; When saving many articles in a single file, use the other
12067 ;; function to save articles other than the first one.
12068 (saver2 (get gnus-default-article-saver :function))
12069 (gnus-prompt-before-saving (if saver2
12070 t
12071 gnus-prompt-before-saving))
12072 (gnus-default-article-saver gnus-default-article-saver)
12073 header file)
12074 (dolist (article articles)
12075 (setq header (gnus-summary-article-header article))
12076 (if (not (vectorp header))
12077 ;; This is a pseudo-article.
12078 (if (assq 'name header)
12079 (gnus-copy-file (cdr (assq 'name header)))
12080 (gnus-message 1 "Article %d is unsavable" article))
12081 ;; This is a real article.
12082 (save-window-excursion
12083 (gnus-summary-select-article decode decode nil article)
12084 (gnus-summary-goto-subject article))
12085 (with-current-buffer save-buffer
12086 (erase-buffer)
12087 (insert-buffer-substring (if decode
12088 gnus-article-buffer
12089 gnus-original-article-buffer)))
12090 (setq file (gnus-article-save save-buffer file num))
12091 (gnus-summary-remove-process-mark article)
12092 (unless not-saved
12093 (gnus-summary-set-saved-mark article)))
12094 (when saver2
12095 (setq gnus-default-article-saver saver2
12096 saver2 nil)))
12097 (gnus-kill-buffer save-buffer)
12098 (gnus-summary-position-point)
12099 (gnus-set-mode-line 'summary)
12100 n))
12101
12102 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12103
12104 (defun gnus-summary-pipe-output (&optional n sym)
12105 "Pipe the current article to a subprocess.
12106 If N is a positive number, pipe the N next articles.
12107 If N is a negative number, pipe the N previous articles.
12108 If N is nil and any articles have been marked with the process mark,
12109 pipe those articles instead.
12110 The default command to which articles are piped is specified by the
12111 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12112 will be prompted for the command.
12113
12114 The properties `:decode' and `:headers' that are put to the function
12115 symbol `gnus-summary-save-in-pipe' control whether this function
12116 decodes articles and what headers to keep (see the doc string for the
12117 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12118 is neither omitted nor the symbol `r', force including all headers
12119 regardless of the `:headers' property. If it is the symbol `r',
12120 articles that are not decoded and include all headers will be piped
12121 no matter what the properties `:decode' and `:headers' are."
12122 (interactive (gnus-interactive "P\ny"))
12123 (require 'gnus-art)
12124 (let* ((articles (gnus-summary-work-articles n))
12125 (result-buffer "*Shell Command Output*")
12126 (all-headers (not (memq sym '(nil r))))
12127 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12128 (raw (eq sym 'r))
12129 (headers (get 'gnus-summary-save-in-pipe :headers))
12130 command result)
12131 (unless (numberp (car articles))
12132 (error "No article to pipe"))
12133 (setq command (gnus-read-shell-command
12134 (concat "Shell command on "
12135 (if (cdr articles)
12136 (format "these %d articles" (length articles))
12137 "this article")
12138 ": ")
12139 gnus-summary-pipe-output-default-command))
12140 (when (string-equal command "")
12141 (error "A command is required"))
12142 (when all-headers
12143 (put 'gnus-summary-save-in-pipe :headers nil))
12144 (unwind-protect
12145 (while articles
12146 (gnus-summary-goto-subject (pop articles))
12147 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12148 (when (and (get-buffer result-buffer)
12149 (not (zerop (buffer-size (get-buffer result-buffer)))))
12150 (setq result (concat result (with-current-buffer result-buffer
12151 (buffer-string))))))
12152 (put 'gnus-summary-save-in-pipe :headers headers))
12153 (unless (zerop (length result))
12154 (if (with-current-buffer (get-buffer-create result-buffer)
12155 (erase-buffer)
12156 (insert result)
12157 (prog1
12158 (and (= (count-lines (point-min) (point)) 1)
12159 (progn
12160 (end-of-line 0)
12161 (<= (current-column)
12162 (window-width (minibuffer-window)))))
12163 (goto-char (point-min))))
12164 (message "%s" (substring result 0 -1))
12165 (message nil)
12166 (gnus-configure-windows 'pipe)))))
12167
12168 (defun gnus-summary-save-article-mail (&optional arg)
12169 "Append the current article to a Unix mail box file.
12170 If N is a positive number, save the N next articles.
12171 If N is a negative number, save the N previous articles.
12172 If N is nil and any articles have been marked with the process mark,
12173 save those articles instead."
12174 (interactive "P")
12175 (require 'gnus-art)
12176 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12177 (gnus-summary-save-article arg)))
12178
12179 (defun gnus-summary-save-article-rmail (&optional arg)
12180 "Append the current article to an rmail file.
12181 If N is a positive number, save the N next articles.
12182 If N is a negative number, save the N previous articles.
12183 If N is nil and any articles have been marked with the process mark,
12184 save those articles instead."
12185 (interactive "P")
12186 (require 'gnus-art)
12187 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12188 (gnus-summary-save-article arg)))
12189
12190 (defun gnus-summary-save-article-file (&optional arg)
12191 "Append the current article to a file.
12192 If N is a positive number, save the N next articles.
12193 If N is a negative number, save the N previous articles.
12194 If N is nil and any articles have been marked with the process mark,
12195 save those articles instead."
12196 (interactive "P")
12197 (require 'gnus-art)
12198 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12199 (gnus-summary-save-article arg)))
12200
12201 (defun gnus-summary-write-article-file (&optional arg)
12202 "Write the current article to a file, deleting the previous file.
12203 If N is a positive number, save the N next articles.
12204 If N is a negative number, save the N previous articles.
12205 If N is nil and any articles have been marked with the process mark,
12206 save those articles instead."
12207 (interactive "P")
12208 (require 'gnus-art)
12209 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12210 (gnus-summary-save-article arg)))
12211
12212 (defun gnus-summary-save-article-body-file (&optional arg)
12213 "Append the current article body to a file.
12214 If N is a positive number, save the N next articles.
12215 If N is a negative number, save the N previous articles.
12216 If N is nil and any articles have been marked with the process mark,
12217 save those articles instead."
12218 (interactive "P")
12219 (require 'gnus-art)
12220 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12221 (gnus-summary-save-article arg)))
12222
12223 (defun gnus-summary-write-article-body-file (&optional arg)
12224 "Write the current article body to a file, deleting the previous file.
12225 If N is a positive number, save the N next articles.
12226 If N is a negative number, save the N previous articles.
12227 If N is nil and any articles have been marked with the process mark,
12228 save those articles instead."
12229 (interactive "P")
12230 (require 'gnus-art)
12231 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12232 (gnus-summary-save-article arg)))
12233
12234 (defun gnus-summary-muttprint (&optional arg)
12235 "Print the current article using Muttprint.
12236 If N is a positive number, save the N next articles.
12237 If N is a negative number, save the N previous articles.
12238 If N is nil and any articles have been marked with the process mark,
12239 save those articles instead."
12240 (interactive "P")
12241 (require 'gnus-art)
12242 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12243 (gnus-summary-save-article arg t)))
12244
12245 (defun gnus-summary-pipe-message (program)
12246 "Pipe the current article through PROGRAM."
12247 (interactive "sProgram: ")
12248 (gnus-summary-select-article)
12249 (let ((mail-header-separator ""))
12250 (gnus-eval-in-buffer-window gnus-article-buffer
12251 (save-restriction
12252 (widen)
12253 (let ((start (window-start))
12254 (inhibit-read-only t))
12255 (message-pipe-buffer-body program)
12256 (set-window-start (get-buffer-window (current-buffer)) start))))))
12257
12258 (defun gnus-get-split-value (methods)
12259 "Return a value based on the split METHODS."
12260 (let (split-name method result match)
12261 (when methods
12262 (with-current-buffer gnus-original-article-buffer
12263 (save-restriction
12264 (nnheader-narrow-to-headers)
12265 (while (and methods (not split-name))
12266 (goto-char (point-min))
12267 (setq method (pop methods))
12268 (setq match (car method))
12269 (when (cond
12270 ((stringp match)
12271 ;; Regular expression.
12272 (ignore-errors
12273 (re-search-forward match nil t)))
12274 ((functionp match)
12275 ;; Function.
12276 (save-restriction
12277 (widen)
12278 (setq result (funcall match gnus-newsgroup-name))))
12279 ((consp match)
12280 ;; Form.
12281 (save-restriction
12282 (widen)
12283 (setq result (eval match)))))
12284 (setq split-name (cdr method))
12285 (cond ((stringp result)
12286 (push (expand-file-name
12287 result gnus-article-save-directory)
12288 split-name))
12289 ((consp result)
12290 (setq split-name (append result split-name)))))))))
12291 (nreverse split-name)))
12292
12293 (defun gnus-valid-move-group-p (group)
12294 (and (symbolp group)
12295 (boundp group)
12296 (symbol-name group)
12297 (symbol-value group)
12298 (gnus-get-function (gnus-find-method-for-group
12299 (symbol-name group)) 'request-accept-article t)))
12300
12301 (defun gnus-read-move-group-name (prompt default articles prefix)
12302 "Read a group name."
12303 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12304 (minibuffer-confirm-incomplete nil) ; XEmacs
12305 (prom
12306 (format "%s %s to"
12307 prompt
12308 (if (> (length articles) 1)
12309 (format "these %d articles" (length articles))
12310 "this article")))
12311 (to-newsgroup
12312 (cond
12313 ((null split-name)
12314 (gnus-group-completing-read
12315 prom
12316 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12317 nil prefix nil default))
12318 ((= 1 (length split-name))
12319 (gnus-group-completing-read
12320 prom
12321 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12322 nil prefix 'gnus-group-history (car split-name)))
12323 (t
12324 (gnus-completing-read
12325 prom (nreverse split-name) nil nil 'gnus-group-history))))
12326 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12327 encoded)
12328 (when to-newsgroup
12329 (if (or (string= to-newsgroup "")
12330 (string= to-newsgroup prefix))
12331 (setq to-newsgroup default))
12332 (unless to-newsgroup
12333 (error "No group name entered"))
12334 (setq encoded (mm-encode-coding-string
12335 to-newsgroup
12336 (gnus-group-name-charset to-method to-newsgroup)))
12337 (or (gnus-active encoded)
12338 (gnus-activate-group encoded nil nil to-method)
12339 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12340 to-newsgroup))
12341 (or (and (gnus-request-create-group encoded to-method)
12342 (gnus-activate-group encoded nil nil to-method)
12343 (gnus-subscribe-group encoded))
12344 (error "Couldn't create group %s" to-newsgroup)))
12345 (error "No such group: %s" to-newsgroup))
12346 encoded)))
12347
12348 (defvar gnus-summary-save-parts-counter)
12349 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12350
12351 (defun gnus-summary-save-parts (type dir n &optional reverse)
12352 "Save parts matching TYPE to DIR.
12353 If REVERSE, save parts that do not match TYPE."
12354 (interactive
12355 (list (read-string "Save parts of type: "
12356 (or (car gnus-summary-save-parts-type-history)
12357 gnus-summary-save-parts-default-mime)
12358 'gnus-summary-save-parts-type-history)
12359 (setq gnus-summary-save-parts-last-directory
12360 (read-directory-name "Save to directory: "
12361 gnus-summary-save-parts-last-directory
12362 nil t))
12363 current-prefix-arg))
12364 (gnus-summary-iterate n
12365 (let ((gnus-display-mime-function nil)
12366 gnus-article-prepare-hook
12367 gnus-article-decode-hook
12368 gnus-display-mime-function
12369 gnus-break-pages
12370 (gnus-inhibit-treatment t))
12371 (gnus-summary-select-article))
12372 (with-current-buffer gnus-article-buffer
12373 (let ((handles (or gnus-article-mime-handles
12374 (mm-dissect-buffer nil gnus-article-loose-mime)
12375 (and gnus-article-emulate-mime
12376 (mm-uu-dissect))))
12377 (gnus-summary-save-parts-counter 1))
12378 (when handles
12379 (gnus-summary-save-parts-1 type dir handles reverse)
12380 (unless gnus-article-mime-handles ;; Don't destroy this case.
12381 (mm-destroy-parts handles)))))))
12382
12383 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12384 (if (stringp (car handle))
12385 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12386 (cdr handle))
12387 (when (if reverse
12388 (not (string-match type (mm-handle-media-type handle)))
12389 (string-match type (mm-handle-media-type handle)))
12390 (let ((file (expand-file-name
12391 (gnus-map-function
12392 mm-file-name-rewrite-functions
12393 (file-name-nondirectory
12394 (or
12395 (mm-handle-filename handle)
12396 (format "%s.%d.%d" gnus-newsgroup-name
12397 (cdr gnus-article-current)
12398 gnus-summary-save-parts-counter))))
12399 dir)))
12400 (incf gnus-summary-save-parts-counter)
12401 (unless (file-exists-p file)
12402 (mm-save-part-to-file handle file))))))
12403
12404 ;; Summary extract commands
12405
12406 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12407 (let ((inhibit-read-only t)
12408 (article (gnus-summary-article-number))
12409 after-article b e)
12410 (unless (gnus-summary-goto-subject article)
12411 (error "No such article: %d" article))
12412 (gnus-summary-position-point)
12413 ;; If all commands are to be bunched up on one line, we collect
12414 ;; them here.
12415 (unless gnus-view-pseudos-separately
12416 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12417 files action)
12418 (while ps
12419 (setq action (cdr (assq 'action (car ps))))
12420 (setq files (list (cdr (assq 'name (car ps)))))
12421 (while (and ps (cdr ps)
12422 (string= (or action "1")
12423 (or (cdr (assq 'action (cadr ps))) "2")))
12424 (push (cdr (assq 'name (cadr ps))) files)
12425 (setcdr ps (cddr ps)))
12426 (when files
12427 (when (not (string-match "%s" action))
12428 (push " " files))
12429 (push " " files)
12430 (when (assq 'execute (car ps))
12431 (setcdr (assq 'execute (car ps))
12432 (funcall (if (string-match "%s" action)
12433 'format 'concat)
12434 action
12435 (mapconcat
12436 (lambda (f)
12437 (if (equal f " ")
12438 f
12439 (shell-quote-argument f)))
12440 files " ")))))
12441 (setq ps (cdr ps)))))
12442 (if (and gnus-view-pseudos (not not-view))
12443 (while pslist
12444 (when (assq 'execute (car pslist))
12445 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12446 (eq gnus-view-pseudos 'not-confirm)))
12447 (setq pslist (cdr pslist)))
12448 (save-excursion
12449 (while pslist
12450 (setq after-article (or (cdr (assq 'article (car pslist)))
12451 (gnus-summary-article-number)))
12452 (gnus-summary-goto-subject after-article)
12453 (forward-line 1)
12454 (setq b (point))
12455 (insert " " (file-name-nondirectory
12456 (cdr (assq 'name (car pslist))))
12457 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12458 (setq e (point))
12459 (forward-line -1) ; back to `b'
12460 (gnus-add-text-properties
12461 b (1- e) (list 'gnus-number gnus-reffed-article-number
12462 gnus-mouse-face-prop gnus-mouse-face))
12463 (gnus-data-enter
12464 after-article gnus-reffed-article-number
12465 gnus-unread-mark b (car pslist) 0 (- e b))
12466 (setq gnus-newsgroup-unreads
12467 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12468 gnus-reffed-article-number))
12469 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12470 (setq pslist (cdr pslist)))))))
12471
12472 (defun gnus-pseudos< (p1 p2)
12473 (let ((c1 (cdr (assq 'action p1)))
12474 (c2 (cdr (assq 'action p2))))
12475 (and c1 c2 (string< c1 c2))))
12476
12477 (defun gnus-request-pseudo-article (props)
12478 (cond ((assq 'execute props)
12479 (gnus-execute-command (cdr (assq 'execute props)))))
12480 (let ((gnus-current-article (gnus-summary-article-number)))
12481 (gnus-run-hooks 'gnus-mark-article-hook)))
12482
12483 (defun gnus-execute-command (command &optional automatic)
12484 (save-excursion
12485 (gnus-article-setup-buffer)
12486 (set-buffer gnus-article-buffer)
12487 (setq buffer-read-only nil)
12488 (let ((command (if automatic command
12489 (read-string "Command: " (cons command 0)))))
12490 (erase-buffer)
12491 (insert "$ " command "\n\n")
12492 (if gnus-view-pseudo-asynchronously
12493 (start-process "gnus-execute" (current-buffer) shell-file-name
12494 shell-command-switch command)
12495 (call-process shell-file-name nil t nil
12496 shell-command-switch command)))))
12497
12498 ;; Summary kill commands.
12499
12500 (defun gnus-summary-edit-global-kill (article)
12501 "Edit the \"global\" kill file."
12502 (interactive (list (gnus-summary-article-number)))
12503 (gnus-group-edit-global-kill article))
12504
12505 (defun gnus-summary-edit-local-kill ()
12506 "Edit a local kill file applied to the current newsgroup."
12507 (interactive)
12508 (setq gnus-current-headers (gnus-summary-article-header))
12509 (gnus-group-edit-local-kill
12510 (gnus-summary-article-number) gnus-newsgroup-name))
12511
12512 ;;; Header reading.
12513
12514 (defun gnus-read-header (id &optional header)
12515 "Read the headers of article ID and enter them into the Gnus system."
12516 (let ((group gnus-newsgroup-name)
12517 (gnus-override-method
12518 (or
12519 gnus-override-method
12520 (and (gnus-news-group-p gnus-newsgroup-name)
12521 (car (gnus-refer-article-methods)))))
12522 where)
12523 ;; First we check to see whether the header in question is already
12524 ;; fetched.
12525 (if (stringp id)
12526 ;; This is a Message-ID.
12527 (setq header (or header (gnus-id-to-header id)))
12528 ;; This is an article number.
12529 (setq header (or header (gnus-summary-article-header id))))
12530 (if (and header
12531 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12532 ;; We have found the header.
12533 header
12534 ;; We have to really fetch the header to this article.
12535 (with-current-buffer nntp-server-buffer
12536 (when (setq where (gnus-request-head id group))
12537 (nnheader-fold-continuation-lines)
12538 (goto-char (point-max))
12539 (insert ".\n")
12540 (goto-char (point-min))
12541 (insert "211 ")
12542 (princ (cond
12543 ((numberp id) id)
12544 ((cdr where) (cdr where))
12545 (header (mail-header-number header))
12546 (t gnus-reffed-article-number))
12547 (current-buffer))
12548 (insert " Article retrieved.\n"))
12549 (if (or (not where)
12550 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12551 () ; Malformed head.
12552 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12553 (when (and (bound-and-true-p gnus-registry-enabled)
12554 (not (gnus-ephemeral-group-p (car where))))
12555 (gnus-registry-handle-action
12556 (mail-header-id header) nil
12557 (gnus-group-prefixed-name
12558 (car where)
12559 (or gnus-override-method (gnus-find-method-for-group group)))
12560 (mail-header-subject header)
12561 (mail-header-from header)))
12562 (when (and (stringp id)
12563 (or
12564 (not (string= (gnus-group-real-name group)
12565 (car where)))
12566 (not (gnus-server-equal gnus-override-method
12567 (gnus-group-method group)))))
12568 ;; If we fetched by Message-ID and the article came from
12569 ;; a different group (or server), we fudge some bogus
12570 ;; article numbers for this article.
12571 (mail-header-set-number header gnus-reffed-article-number))
12572 (with-current-buffer gnus-summary-buffer
12573 (decf gnus-reffed-article-number)
12574 (gnus-remove-header (mail-header-number header))
12575 (push header gnus-newsgroup-headers)
12576 (setq gnus-current-headers header)
12577 (push (mail-header-number header) gnus-newsgroup-limit)))
12578 header)))))
12579
12580 (defun gnus-remove-header (number)
12581 "Remove header NUMBER from `gnus-newsgroup-headers'."
12582 (if (and gnus-newsgroup-headers
12583 (= number (mail-header-number (car gnus-newsgroup-headers))))
12584 (pop gnus-newsgroup-headers)
12585 (let ((headers gnus-newsgroup-headers))
12586 (while (and (cdr headers)
12587 (not (= number (mail-header-number (cadr headers)))))
12588 (pop headers))
12589 (when (cdr headers)
12590 (setcdr headers (cddr headers))))))
12591
12592 ;;;
12593 ;;; summary highlights
12594 ;;;
12595
12596 (defun gnus-highlight-selected-summary ()
12597 "Highlight selected article in summary buffer."
12598 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12599 (when gnus-summary-selected-face
12600 (save-excursion
12601 (let* ((beg (point-at-bol))
12602 (end (point-at-eol))
12603 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12604 (from (if (get-text-property beg gnus-mouse-face-prop)
12605 beg
12606 (or (next-single-property-change
12607 beg gnus-mouse-face-prop nil end)
12608 beg)))
12609 (to
12610 (if (= from end)
12611 (- from 2)
12612 (or (next-single-property-change
12613 from gnus-mouse-face-prop nil end)
12614 end))))
12615 ;; If no mouse-face prop on line we will have to = from = end,
12616 ;; so we highlight the entire line instead.
12617 (when (= (+ to 2) from)
12618 (setq from beg)
12619 (setq to end))
12620 (if gnus-newsgroup-selected-overlay
12621 ;; Move old overlay.
12622 (move-overlay
12623 gnus-newsgroup-selected-overlay from to (current-buffer))
12624 ;; Create new overlay.
12625 (overlay-put
12626 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12627 'face gnus-summary-selected-face))))))
12628
12629 (defvar gnus-summary-highlight-line-cached nil)
12630 (defvar gnus-summary-highlight-line-trigger nil)
12631
12632 (defun gnus-summary-highlight-line-0 ()
12633 (if (and (eq gnus-summary-highlight-line-trigger
12634 gnus-summary-highlight)
12635 gnus-summary-highlight-line-cached)
12636 gnus-summary-highlight-line-cached
12637 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12638 gnus-summary-highlight-line-cached
12639 (let* ((cond (list 'cond))
12640 (c cond)
12641 (list gnus-summary-highlight))
12642 (while list
12643 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12644 nil))
12645 (setq c (cdr c)
12646 list (cdr list)))
12647 (gnus-byte-compile (list 'lambda nil cond))))))
12648
12649 (defun gnus-summary-highlight-line ()
12650 "Highlight current line according to `gnus-summary-highlight'."
12651 (let* ((beg (point-at-bol))
12652 (article (or (gnus-summary-article-number) gnus-current-article))
12653 (score (or (cdr (assq article
12654 gnus-newsgroup-scored))
12655 gnus-summary-default-score 0))
12656 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12657 (inhibit-read-only t)
12658 (default gnus-summary-default-score)
12659 (default-high gnus-summary-default-high-score)
12660 (default-low gnus-summary-default-low-score)
12661 (uncached (and gnus-summary-use-undownloaded-faces
12662 (memq article gnus-newsgroup-undownloaded)
12663 (not (memq article gnus-newsgroup-cached)))))
12664 (let ((face (funcall (gnus-summary-highlight-line-0))))
12665 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12666 (gnus-put-text-property-excluding-characters-with-faces
12667 beg (point-at-eol) 'face
12668 (setq face (if (boundp face) (symbol-value face) face)))
12669 (when gnus-summary-highlight-line-function
12670 (funcall gnus-summary-highlight-line-function article face))))))
12671
12672 (defun gnus-update-read-articles (group unread &optional compute)
12673 "Update the list of read articles in GROUP.
12674 UNREAD is a sorted list."
12675 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12676 (info (gnus-get-info group))
12677 (prev 1)
12678 read)
12679 (if (or (not info) (not active))
12680 ;; There is no info on this group if it was, in fact,
12681 ;; killed. Gnus stores no information on killed groups, so
12682 ;; there's nothing to be done.
12683 ;; One could store the information somewhere temporarily,
12684 ;; perhaps... Hmmm...
12685 ()
12686 ;; Remove any negative articles numbers.
12687 (while (and unread (< (car unread) 0))
12688 (setq unread (cdr unread)))
12689 ;; Remove any expired article numbers
12690 (while (and unread (< (car unread) (car active)))
12691 (setq unread (cdr unread)))
12692 ;; Compute the ranges of read articles by looking at the list of
12693 ;; unread articles.
12694 (while unread
12695 (when (/= (car unread) prev)
12696 (push (if (= prev (1- (car unread))) prev
12697 (cons prev (1- (car unread))))
12698 read))
12699 (setq prev (1+ (car unread)))
12700 (setq unread (cdr unread)))
12701 (when (<= prev (cdr active))
12702 (push (cons prev (cdr active)) read))
12703 (setq read (if (> (length read) 1) (nreverse read) read))
12704 (if compute
12705 read
12706 (save-excursion
12707 (let (setmarkundo)
12708 ;; Propagate the read marks to the backend.
12709 (when (and (gnus-method-option-p
12710 (gnus-find-method-for-group group)
12711 'server-marks)
12712 (gnus-check-backend-function 'request-set-mark group))
12713 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12714 (add (gnus-remove-from-range read (gnus-info-read info))))
12715 (when (or add del)
12716 (unless (gnus-check-group group)
12717 (error "Can't open server for %s" group))
12718 (gnus-request-set-mark
12719 group (delq nil (list (if add (list add 'add '(read)))
12720 (if del (list del 'del '(read))))))
12721 (setq setmarkundo
12722 `(gnus-request-set-mark
12723 ,group
12724 ',(delq nil (list
12725 (if del (list del 'add '(read)))
12726 (if add (list add 'del '(read))))))))))
12727 (set-buffer gnus-group-buffer)
12728 (gnus-undo-register
12729 `(progn
12730 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12731 (gnus-info-set-read ',info ',(gnus-info-read info))
12732 (gnus-get-unread-articles-in-group ',info
12733 (gnus-active ,group))
12734 (gnus-group-update-group ,group t)
12735 ,setmarkundo))))
12736 ;; Enter this list into the group info.
12737 (gnus-info-set-read info read)
12738 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12739 (gnus-get-unread-articles-in-group info (gnus-active group))
12740 t))))
12741
12742 (defun gnus-offer-save-summaries ()
12743 "Offer to save all active summary buffers."
12744 (let (buffers)
12745 ;; Go through all buffers and find all summaries.
12746 (dolist (buffer (buffer-list))
12747 (when (and (setq buffer (buffer-name buffer))
12748 (string-match "Summary" buffer)
12749 (with-current-buffer buffer
12750 ;; We check that this is, indeed, a summary buffer.
12751 (and (derived-mode-p 'gnus-summary-mode)
12752 ;; Also make sure this isn't bogus.
12753 gnus-newsgroup-prepared
12754 ;; Also make sure that this isn't a
12755 ;; dead summary buffer.
12756 (not gnus-dead-summary-mode))))
12757 (push buffer buffers)))
12758 ;; Go through all these summary buffers and offer to save them.
12759 (when buffers
12760 (save-excursion
12761 (if (eq gnus-interactive-exit 'quiet)
12762 (dolist (buffer buffers)
12763 (switch-to-buffer buffer)
12764 (gnus-summary-exit))
12765 (map-y-or-n-p
12766 "Update summary buffer %s? "
12767 (lambda (buf)
12768 (switch-to-buffer buf)
12769 (gnus-summary-exit))
12770 buffers))))))
12771
12772 (defun gnus-summary-setup-default-charset ()
12773 "Setup newsgroup default charset."
12774 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12775 (setq gnus-newsgroup-charset nil)
12776 (let* ((ignored-charsets
12777 (or gnus-newsgroup-ephemeral-ignored-charsets
12778 (append
12779 (and gnus-newsgroup-name
12780 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12781 gnus-newsgroup-ignored-charsets))))
12782 (setq gnus-newsgroup-charset
12783 (or gnus-newsgroup-ephemeral-charset
12784 (and gnus-newsgroup-name
12785 (gnus-parameter-charset gnus-newsgroup-name))
12786 gnus-default-charset))
12787 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12788 ignored-charsets))))
12789
12790 ;;;
12791 ;;; Mime Commands
12792 ;;;
12793
12794 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12795 "Display the current article buffer fully MIME-buttonized.
12796 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12797 treated as multipart/mixed."
12798 (interactive "P")
12799 (require 'gnus-art)
12800 (let ((gnus-unbuttonized-mime-types nil)
12801 (gnus-mime-display-multipart-as-mixed show-all-parts))
12802 (gnus-summary-show-article)))
12803
12804 (defun gnus-summary-repair-multipart (article)
12805 "Add a Content-Type header to a multipart article without one."
12806 (interactive (list (gnus-summary-article-number)))
12807 (gnus-with-article article
12808 (message-narrow-to-head)
12809 (message-remove-header "Mime-Version")
12810 (goto-char (point-max))
12811 (insert "Mime-Version: 1.0\n")
12812 (widen)
12813 (when (search-forward "\n--" nil t)
12814 (let ((separator (buffer-substring (point) (point-at-eol))))
12815 (message-narrow-to-head)
12816 (message-remove-header "Content-Type")
12817 (goto-char (point-max))
12818 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12819 separator))
12820 (widen))))
12821 (let (gnus-mark-article-hook)
12822 (gnus-summary-select-article t t nil article)))
12823
12824 (defun gnus-summary-toggle-display-buttonized ()
12825 "Toggle the buttonizing of the article buffer."
12826 (interactive)
12827 (require 'gnus-art)
12828 (if (setq gnus-inhibit-mime-unbuttonizing
12829 (not gnus-inhibit-mime-unbuttonizing))
12830 (let ((gnus-unbuttonized-mime-types nil))
12831 (gnus-summary-show-article))
12832 (gnus-summary-show-article)))
12833
12834 ;;;
12835 ;;; Generic summary marking commands
12836 ;;;
12837
12838 (defvar gnus-summary-marking-alist
12839 '((read gnus-del-mark "d")
12840 (unread gnus-unread-mark "u")
12841 (ticked gnus-ticked-mark "!")
12842 (dormant gnus-dormant-mark "?")
12843 (expirable gnus-expirable-mark "e"))
12844 "An alist of names/marks/keystrokes.")
12845
12846 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12847 (defvar gnus-summary-mark-map)
12848
12849 (defun gnus-summary-make-all-marking-commands ()
12850 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12851 (dolist (elem gnus-summary-marking-alist)
12852 (apply 'gnus-summary-make-marking-command elem)))
12853
12854 (defun gnus-summary-make-marking-command (name mark keystroke)
12855 (let ((map (make-sparse-keymap)))
12856 (define-key gnus-summary-generic-mark-map keystroke map)
12857 (dolist (lway `((next "next" next nil "n")
12858 (next-unread "next unread" next t "N")
12859 (prev "previous" prev nil "p")
12860 (prev-unread "previous unread" prev t "P")
12861 (nomove "" nil nil ,keystroke)))
12862 (let ((func (gnus-summary-make-marking-command-1
12863 mark (car lway) lway name)))
12864 (setq func (eval func))
12865 (define-key map (nth 4 lway) func)))))
12866
12867 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12868 `(defun ,(intern
12869 (format "gnus-summary-put-mark-as-%s%s"
12870 name (if (eq way 'nomove)
12871 ""
12872 (concat "-" (symbol-name way)))))
12873 (n)
12874 ,(format
12875 "Mark the current article as %s%s.
12876 If N, the prefix, then repeat N times.
12877 If N is negative, move in reverse order.
12878 The difference between N and the actual number of articles marked is
12879 returned."
12880 name (cadr lway))
12881 (interactive "p")
12882 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12883
12884 (defun gnus-summary-generic-mark (n mark move unread)
12885 "Mark N articles with MARK."
12886 (unless (derived-mode-p 'gnus-summary-mode)
12887 (error "This command can only be used in the summary buffer"))
12888 (gnus-summary-show-thread)
12889 (let ((nummove
12890 (cond
12891 ((eq move 'next) 1)
12892 ((eq move 'prev) -1)
12893 (t 0))))
12894 (if (zerop nummove)
12895 (setq n 1)
12896 (when (< n 0)
12897 (setq n (abs n)
12898 nummove (* -1 nummove))))
12899 (while (and (> n 0)
12900 (gnus-summary-mark-article nil mark)
12901 (zerop (gnus-summary-next-subject nummove unread t)))
12902 (setq n (1- n)))
12903 (when (/= 0 n)
12904 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12905 (gnus-summary-recenter)
12906 (gnus-summary-position-point)
12907 (gnus-set-mode-line 'summary)
12908 n))
12909
12910 (defun gnus-summary-insert-articles (articles)
12911 (when (setq articles
12912 (gnus-sorted-difference articles
12913 (mapcar (lambda (h)
12914 (mail-header-number h))
12915 gnus-newsgroup-headers)))
12916 (setq gnus-newsgroup-headers
12917 (gnus-merge 'list
12918 gnus-newsgroup-headers
12919 (gnus-fetch-headers articles nil t)
12920 'gnus-article-sort-by-number))
12921 (setq gnus-newsgroup-articles
12922 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12923 ;; Suppress duplicates?
12924 (when gnus-suppress-duplicates
12925 (gnus-dup-suppress-articles))
12926
12927 (if (and gnus-fetch-old-headers
12928 (eq gnus-headers-retrieved-by 'nov))
12929 ;; We might want to build some more threads first.
12930 (if (eq gnus-fetch-old-headers 'invisible)
12931 (gnus-build-all-threads)
12932 (gnus-build-old-threads))
12933 ;; Mark the inserted articles that are unread as unread.
12934 (setq gnus-newsgroup-unreads
12935 (gnus-sorted-nunion
12936 gnus-newsgroup-unreads
12937 (gnus-sorted-nintersection
12938 (gnus-list-of-unread-articles gnus-newsgroup-name)
12939 articles)))
12940 ;; Mark the inserted articles as selected so that the information
12941 ;; of the marks having been changed by a user may be updated when
12942 ;; exiting this group. See `gnus-summary-update-info'.
12943 (dolist (art articles)
12944 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12945 ;; Let the Gnus agent mark articles as read.
12946 (when gnus-agent
12947 (gnus-agent-get-undownloaded-list))
12948 ;; Remove list identifiers from subject
12949 (gnus-summary-remove-list-identifiers)
12950 ;; First and last article in this newsgroup.
12951 (when gnus-newsgroup-headers
12952 (setq gnus-newsgroup-begin
12953 (mail-header-number (car gnus-newsgroup-headers))
12954 gnus-newsgroup-end
12955 (mail-header-number
12956 (gnus-last-element gnus-newsgroup-headers))))
12957 (when gnus-use-scoring
12958 (gnus-possibly-score-headers))))
12959
12960 (defun gnus-summary-insert-old-articles (&optional all)
12961 "Insert all old articles in this group.
12962 If ALL is non-nil, already read articles become readable.
12963 If ALL is a number, fetch this number of articles."
12964 (interactive "P")
12965 (prog1
12966 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12967 older len)
12968 (setq older
12969 ;; Some nntp servers lie about their active range. When
12970 ;; this happens, the active range can be in the millions.
12971 ;; Use a compressed range to avoid creating a huge list.
12972 (gnus-range-difference
12973 (gnus-range-difference (list gnus-newsgroup-active) old)
12974 gnus-newsgroup-unexist))
12975 (setq len (gnus-range-length older))
12976 (cond
12977 ((null older) nil)
12978 ((numberp all)
12979 (if (< all len)
12980 (let ((older-range (nreverse older)))
12981 (setq older nil)
12982
12983 (while (> all 0)
12984 (let* ((r (pop older-range))
12985 (min (if (numberp r) r (car r)))
12986 (max (if (numberp r) r (cdr r))))
12987 (while (and (<= min max)
12988 (> all 0))
12989 (push max older)
12990 (setq all (1- all)
12991 max (1- max))))))
12992 (setq older (gnus-uncompress-range older))))
12993 (all
12994 (setq older (gnus-uncompress-range older)))
12995 (t
12996 (when (and (numberp gnus-large-newsgroup)
12997 (> len gnus-large-newsgroup))
12998 (let* ((cursor-in-echo-area nil)
12999 (initial (gnus-parameter-large-newsgroup-initial
13000 gnus-newsgroup-name))
13001 (input
13002 (read-string
13003 (format
13004 "How many articles from %s (%s %d): "
13005 (gnus-group-decoded-name gnus-newsgroup-name)
13006 (if initial "max" "default")
13007 len)
13008 nil nil
13009 (and initial
13010 (number-to-string initial)))))
13011 (unless (string-match "^[ \t]*$" input)
13012 (setq all (string-to-number input))
13013 (if (< all len)
13014 (let ((older-range (nreverse older)))
13015 (setq older nil)
13016
13017 (while (> all 0)
13018 (let* ((r (pop older-range))
13019 (min (if (numberp r) r (car r)))
13020 (max (if (numberp r) r (cdr r))))
13021 (while (and (<= min max)
13022 (> all 0))
13023 (push max older)
13024 (setq all (1- all)
13025 max (1- max))))))))))
13026 (setq older (gnus-uncompress-range older))))
13027 (if (not older)
13028 (message "No old news.")
13029 (gnus-summary-insert-articles older)
13030 (gnus-summary-limit (gnus-sorted-nunion old older))))
13031 (gnus-summary-position-point)))
13032
13033 (defun gnus-summary-insert-new-articles ()
13034 "Insert all new articles in this group."
13035 (interactive)
13036 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
13037 (old-high gnus-newsgroup-highest)
13038 (nnmail-fetched-sources (list t))
13039 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
13040 i new)
13041 (unless new-active
13042 (error "Couldn't fetch new data"))
13043 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
13044 (setq i (cdr gnus-newsgroup-active)
13045 gnus-newsgroup-highest i)
13046 (while (> i old-high)
13047 (push i new)
13048 (decf i))
13049 (if (not new)
13050 (message "No gnus is bad news")
13051 (gnus-summary-insert-articles new)
13052 (setq gnus-newsgroup-unreads
13053 (gnus-sorted-nunion gnus-newsgroup-unreads new))
13054 (gnus-summary-limit (gnus-sorted-nunion old new))))
13055 (gnus-summary-position-point))
13056
13057 ;;; Bookmark support for Gnus.
13058 (declare-function gnus-article-show-summary "gnus-art" ())
13059 (declare-function bookmark-make-record-default
13060 "bookmark" (&optional no-file no-context posn))
13061 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
13062 (declare-function bookmark-default-handler "bookmark" (bmk))
13063 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
13064 (defvar bookmark-yank-point)
13065 (defvar bookmark-current-buffer)
13066
13067 (defun gnus-summary-bookmark-make-record ()
13068 "Make a bookmark entry for a Gnus summary buffer."
13069 (let (pos buf)
13070 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13071 (save-restriction ; FIXME is it necessary to widen?
13072 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13073 (setq buf "art") ; We are recording bookmark from article buffer.
13074 (setq bookmark-yank-point (point))
13075 (setq bookmark-current-buffer (current-buffer))
13076 (gnus-article-show-summary)) ; Go back in summary buffer.
13077 ;; We are now recording bookmark from summary buffer.
13078 (unless buf (setq buf "sum"))
13079 (let* ((subject (elt (gnus-summary-article-header) 1))
13080 (grp (car gnus-article-current))
13081 (art (cdr gnus-article-current))
13082 (head (gnus-summary-article-header art))
13083 (id (mail-header-id head)))
13084 `(,subject
13085 ,@(condition-case nil
13086 (bookmark-make-record-default 'no-file 'no-context pos)
13087 (wrong-number-of-arguments
13088 (bookmark-make-record-default 'point-only)))
13089 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13090 (group . ,grp) (article . ,art)
13091 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13092
13093 ;;;###autoload
13094 (defun gnus-summary-bookmark-jump (bookmark)
13095 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13096 BOOKMARK is a bookmark name or a bookmark record."
13097 (let ((group (bookmark-prop-get bookmark 'group))
13098 (article (bookmark-prop-get bookmark 'article))
13099 (id (bookmark-prop-get bookmark 'message-id))
13100 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13101 (gnus-fetch-group group (list article))
13102 (gnus-summary-insert-cached-articles)
13103 (gnus-summary-goto-article id nil 'force)
13104 ;; FIXME we have to wait article buffer is ready (only large buffer)
13105 ;; Is there a better solution to know that?
13106 ;; If we don't wait `bookmark-default-handler' will have no chance
13107 ;; to set position. However there is no error, just wrong pos.
13108 (sit-for 1)
13109 (when (string= buf "Gnus-art")
13110 (other-window 1))
13111 (bookmark-default-handler
13112 `(""
13113 (buffer . ,(current-buffer))
13114 . ,(bookmark-get-bookmark-record bookmark)))))
13115
13116 (gnus-summary-make-all-marking-commands)
13117
13118 (gnus-ems-redefine)
13119
13120 (provide 'gnus-sum)
13121
13122 (run-hooks 'gnus-sum-load-hook)
13123
13124 ;; Local Variables:
13125 ;; coding: utf-8
13126 ;; End:
13127
13128 ;;; gnus-sum.el ends here