]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
Make "unseen" tracking work again in Gnus
[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 (require 'cl))
28
29 (defvar tool-bar-mode)
30 (defvar gnus-tmp-header)
31
32 (require 'gnus)
33 (require 'gnus-group)
34 (require 'gnus-spec)
35 (require 'gnus-range)
36 (require 'gnus-int)
37 (require 'gnus-undo)
38 (require 'gnus-util)
39 (require 'gmm-utils)
40 (require 'mm-decode)
41 (require 'nnoo)
42
43 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
44 (autoload 'gnus-cache-write-active "gnus-cache")
45 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
46 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
47 (autoload 'gnus-pick-line-number "gnus-salt" nil t)
48 (autoload 'mm-uu-dissect "mm-uu")
49 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
50 "Deuglify broken Outlook (Express) articles and redisplay."
51 t)
52 (autoload 'gnus-article-outlook-unwrap-lines "deuglify" nil t)
53 (autoload 'gnus-article-outlook-repair-attribution "deuglify" nil t)
54 (autoload 'gnus-article-outlook-rearrange-citation "deuglify" nil t)
55 (autoload 'nnir-article-rsv "nnir" nil nil 'macro)
56 (autoload 'nnir-article-group "nnir" nil nil 'macro)
57
58 (defcustom gnus-kill-summary-on-exit t
59 "*If non-nil, kill the summary buffer when you exit from it.
60 If nil, the summary will become a \"*Dead Summary*\" buffer, and
61 it will be killed sometime later."
62 :group 'gnus-summary-exit
63 :type 'boolean)
64
65 (defcustom gnus-summary-next-group-on-exit t
66 "If non-nil, go to the next unread newsgroup on summary exit.
67 See `gnus-group-goto-unread'."
68 :link '(custom-manual "(gnus)Group Maneuvering")
69 :group 'gnus-summary-exit
70 :version "23.1" ;; No Gnus
71 :type 'boolean)
72
73 (defcustom gnus-summary-stop-at-end-of-message nil
74 "If non-nil, don't select the next message when using `SPC'."
75 :link '(custom-manual "(gnus)Group Maneuvering")
76 :group 'gnus-summary-maneuvering
77 :version "24.1"
78 :type 'boolean)
79
80 (defcustom gnus-fetch-old-headers nil
81 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
82 If an unread article in the group refers to an older, already
83 read (or just marked as read) article, the old article will not
84 normally be displayed in the Summary buffer. If this variable is
85 t, Gnus will attempt to grab the headers to the old articles, and
86 thereby build complete threads. If it has the value `some', all
87 old headers will be fetched but only enough headers to connect
88 otherwise loose threads will be displayed. This variable can
89 also be a number. In that case, no more than that number of old
90 headers will be fetched. If it has the value `invisible', all
91 old headers will be fetched, but none will be displayed.
92
93 The server has to support NOV for any of this to work.
94
95 This feature can seriously impact performance it ignores all
96 locally cached header entries. Setting it to t for groups for a
97 server that doesn't expire articles (such as news.gmane.org),
98 leads to very slow summary generation."
99 :group 'gnus-thread
100 :type '(choice (const :tag "off" nil)
101 (const :tag "on" t)
102 (const some)
103 (const invisible)
104 number
105 (sexp :menu-tag "other" t)))
106
107 (defcustom gnus-refer-thread-limit 500
108 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
109 If t, fetch all the available old headers."
110 :group 'gnus-thread
111 :type '(choice number
112 (sexp :menu-tag "other" t)))
113
114 (defcustom gnus-refer-thread-use-nnir nil
115 "*Use nnir to search an entire server when referring threads. A
116 nil value will only search for thread-related articles in the
117 current group."
118 :version "24.1"
119 :group 'gnus-thread
120 :type 'boolean)
121
122 (defcustom gnus-summary-make-false-root 'adopt
123 "*nil means that Gnus won't gather loose threads.
124 If the root of a thread has expired or been read in a previous
125 session, the information necessary to build a complete thread has been
126 lost. Instead of having many small sub-threads from this original thread
127 scattered all over the summary buffer, Gnus can gather them.
128
129 If non-nil, Gnus will try to gather all loose sub-threads from an
130 original thread into one large thread.
131
132 If this variable is non-nil, it should be one of `none', `adopt',
133 `dummy' or `empty'.
134
135 If this variable is `none', Gnus will not make a false root, but just
136 present the sub-threads after another.
137 If this variable is `dummy', Gnus will create a dummy root that will
138 have all the sub-threads as children.
139 If this variable is `adopt', Gnus will make one of the \"children\"
140 the parent and mark all the step-children as such.
141 If this variable is `empty', the \"children\" are printed with empty
142 subject fields. (Or rather, they will be printed with a string
143 given by the `gnus-summary-same-subject' variable.)"
144 :group 'gnus-thread
145 :type '(choice (const :tag "off" nil)
146 (const none)
147 (const dummy)
148 (const adopt)
149 (const empty)))
150
151 (defcustom gnus-summary-make-false-root-always nil
152 "Always make a false dummy root."
153 :version "22.1"
154 :group 'gnus-thread
155 :type 'boolean)
156
157 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
158 "*A regexp to match subjects to be excluded from loose thread gathering.
159 As loose thread gathering is done on subjects only, that means that
160 there can be many false gatherings performed. By rooting out certain
161 common subjects, gathering might become saner."
162 :group 'gnus-thread
163 :type 'regexp)
164
165 (defcustom gnus-summary-gather-subject-limit nil
166 "*Maximum length of subject comparisons when gathering loose threads.
167 Use nil to compare full subjects. Setting this variable to a low
168 number will help gather threads that have been corrupted by
169 newsreaders chopping off subject lines, but it might also mean that
170 unrelated articles that have subject that happen to begin with the
171 same few characters will be incorrectly gathered.
172
173 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
174 comparing subjects."
175 :group 'gnus-thread
176 :type '(choice (const :tag "off" nil)
177 (const fuzzy)
178 (sexp :menu-tag "on" t)))
179
180 (defcustom gnus-simplify-subject-functions nil
181 "List of functions taking a string argument that simplify subjects.
182 The functions are applied recursively.
183
184 Useful functions to put in this list include:
185 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
186 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
187 :group 'gnus-thread
188 :type '(repeat function))
189
190 (defcustom gnus-simplify-ignored-prefixes nil
191 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
192 :group 'gnus-thread
193 :type '(choice (const :tag "off" nil)
194 regexp))
195
196 (defcustom gnus-build-sparse-threads nil
197 "*If non-nil, fill in the gaps in threads.
198 If `some', only fill in the gaps that are needed to tie loose threads
199 together. If `more', fill in all leaf nodes that Gnus can find. If
200 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
201 :group 'gnus-thread
202 :type '(choice (const :tag "off" nil)
203 (const some)
204 (const more)
205 (sexp :menu-tag "all" t)))
206
207 (defcustom gnus-summary-thread-gathering-function
208 'gnus-gather-threads-by-subject
209 "*Function used for gathering loose threads.
210 There are two pre-defined functions: `gnus-gather-threads-by-subject',
211 which only takes Subjects into consideration; and
212 `gnus-gather-threads-by-references', which compared the References
213 headers of the articles to find matches."
214 :group 'gnus-thread
215 :type '(radio (function-item gnus-gather-threads-by-subject)
216 (function-item gnus-gather-threads-by-references)
217 (function :tag "other")))
218
219 (defcustom gnus-summary-same-subject ""
220 "*String indicating that the current article has the same subject as the previous.
221 This variable will only be used if the value of
222 `gnus-summary-make-false-root' is `empty'."
223 :group 'gnus-summary-format
224 :type 'string)
225
226 (defcustom gnus-summary-goto-unread nil
227 "*If t, many commands will go to the next unread article.
228 This applies to marking commands as well as other commands that
229 \"naturally\" select the next article, like, for instance, `SPC' at
230 the end of an article.
231
232 If nil, the marking commands do NOT go to the next unread article
233 \(they go to the next article instead). If `never', commands that
234 usually go to the next unread article, will go to the next article,
235 whether it is read or not."
236 :version "24.1"
237 :group 'gnus-summary-marks
238 :link '(custom-manual "(gnus)Setting Marks")
239 :type '(choice (const :tag "off" nil)
240 (const never)
241 (sexp :menu-tag "on" t)))
242
243 (defcustom gnus-summary-default-score 0
244 "*Default article score level.
245 All scores generated by the score files will be added to this score.
246 If this variable is nil, scoring will be disabled."
247 :group 'gnus-score-default
248 :type '(choice (const :tag "disable")
249 integer))
250
251 (defcustom gnus-summary-default-high-score 0
252 "*Default threshold for a high scored article.
253 An article will be highlighted as high scored if its score is greater
254 than this score."
255 :version "22.1"
256 :group 'gnus-score-default
257 :type 'integer)
258
259 (defcustom gnus-summary-default-low-score 0
260 "*Default threshold for a low scored article.
261 An article will be highlighted as low scored if its score is smaller
262 than this score."
263 :version "22.1"
264 :group 'gnus-score-default
265 :type 'integer)
266
267 (defcustom gnus-summary-zcore-fuzz 0
268 "*Fuzziness factor for the zcore in the summary buffer.
269 Articles with scores closer than this to `gnus-summary-default-score'
270 will not be marked."
271 :group 'gnus-summary-format
272 :type 'integer)
273
274 (defcustom gnus-simplify-subject-fuzzy-regexp nil
275 "*Strings to be removed when doing fuzzy matches.
276 This can either be a regular expression or list of regular expressions
277 that will be removed from subject strings if fuzzy subject
278 simplification is selected."
279 :group 'gnus-thread
280 :type '(repeat regexp))
281
282 (defcustom gnus-show-threads t
283 "*If non-nil, display threads in summary mode."
284 :group 'gnus-thread
285 :type 'boolean)
286
287 (defcustom gnus-thread-hide-subtree nil
288 "*If non-nil, hide all threads initially.
289 This can be a predicate specifier which says which threads to hide.
290 If threads are hidden, you have to run the command
291 `gnus-summary-show-thread' by hand or select an article."
292 :group 'gnus-thread
293 :type '(radio (sexp :format "Non-nil\n"
294 :match (lambda (widget value)
295 (not (or (consp value) (functionp value))))
296 :value t)
297 (const nil)
298 (sexp :tag "Predicate specifier")))
299
300 (defcustom gnus-thread-hide-killed t
301 "*If non-nil, hide killed threads automatically."
302 :group 'gnus-thread
303 :type 'boolean)
304
305 (defcustom gnus-thread-ignore-subject t
306 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
307 If nil, articles that have different subjects from their parents will
308 start separate threads."
309 :group 'gnus-thread
310 :type 'boolean)
311
312 (defcustom gnus-thread-operation-ignore-subject t
313 "*If non-nil, subjects will be ignored when doing thread commands.
314 This affects commands like `gnus-summary-kill-thread' and
315 `gnus-summary-lower-thread'.
316
317 If this variable is nil, articles in the same thread with different
318 subjects will not be included in the operation in question. If this
319 variable is `fuzzy', only articles that have subjects that are fuzzily
320 equal will be included."
321 :group 'gnus-thread
322 :type '(choice (const :tag "off" nil)
323 (const fuzzy)
324 (sexp :tag "on" t)))
325
326 (defcustom gnus-thread-indent-level 4
327 "*Number that says how much each sub-thread should be indented."
328 :group 'gnus-thread
329 :type 'integer)
330
331 (defcustom gnus-auto-extend-newsgroup t
332 "*If non-nil, extend newsgroup forward and backward when requested."
333 :group 'gnus-summary-choose
334 :type 'boolean)
335
336 (defcustom gnus-auto-select-first t
337 "If non-nil, select an article on group entry.
338 An article is selected automatically when entering a group
339 e.g. with \\<gnus-group-mode-map>\\[gnus-group-read-group], or via `gnus-summary-next-page' or
340 `gnus-summary-catchup-and-goto-next-group'.
341
342 Which article is selected is controlled by the variable
343 `gnus-auto-select-subject'.
344
345 If you want to prevent automatic selection of articles in some
346 newsgroups, set the variable to nil in `gnus-select-group-hook'."
347 ;; Commands include...
348 ;; \\<gnus-group-mode-map>\\[gnus-group-read-group]
349 ;; \\<gnus-summary-mode-map>\\[gnus-summary-next-page]
350 ;; \\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]
351 :group 'gnus-group-select
352 :type '(choice (const :tag "none" nil)
353 (sexp :menu-tag "first" t)))
354
355 (defcustom gnus-auto-select-subject 'unseen-or-unread
356 "*Says what subject to place under point when entering a group.
357
358 This variable can either be the symbols `first' (place point on the
359 first subject), `unread' (place point on the subject line of the first
360 unread article), `best' (place point on the subject line of the
361 highest-scored article), `unseen' (place point on the subject line of
362 the first unseen article), `unseen-or-unread' (place point on the subject
363 line of the first unseen article or, if all articles have been seen, on the
364 subject line of the first unread article), or a function to be called to
365 place point on some subject line."
366 :version "24.1"
367 :group 'gnus-group-select
368 :type '(choice (const best)
369 (const unread)
370 (const first)
371 (const unseen)
372 (const unseen-or-unread)
373 (function :tag "Function to call")))
374
375 (defcustom gnus-auto-select-next t
376 "*If non-nil, offer to go to the next group from the end of the previous.
377 If the value is t and the next newsgroup is empty, Gnus will exit
378 summary mode and go back to group mode. If the value is neither nil
379 nor t, Gnus will select the following unread newsgroup. In
380 particular, if the value is the symbol `quietly', the next unread
381 newsgroup will be selected without any confirmation, and if it is
382 `almost-quietly', the next group will be selected without any
383 confirmation if you are located on the last article in the group.
384 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
385 will go to the next group without confirmation."
386 :group 'gnus-summary-maneuvering
387 :type '(choice (const :tag "off" nil)
388 (const quietly)
389 (const almost-quietly)
390 (const slightly-quietly)
391 (sexp :menu-tag "on" t)))
392
393 (defcustom gnus-auto-select-same nil
394 "*If non-nil, select the next article with the same subject.
395 If there are no more articles with the same subject, go to
396 the first unread article."
397 :group 'gnus-summary-maneuvering
398 :type 'boolean)
399
400 (defcustom gnus-auto-select-on-ephemeral-exit 'next-noselect
401 "What article should be selected after exiting an ephemeral group.
402 Valid values include:
403
404 `next'
405 Select the next article.
406 `next-unread'
407 Select the next unread article.
408 `next-noselect'
409 Move the cursor to the next article. This is the default.
410 `next-unread-noselect'
411 Move the cursor to the next unread article.
412
413 If it has any other value or there is no next (unread) article, the
414 article selected before entering to the ephemeral group will appear."
415 :version "23.1" ;; No Gnus
416 :group 'gnus-summary-maneuvering
417 :type '(choice :format "%{%t%}:\n %[Value Menu%] %v"
418 (const next) (const next-unread)
419 (const next-noselect) (const next-unread-noselect)
420 (sexp :tag "other" :value nil)))
421
422 (defcustom gnus-auto-goto-ignores 'unfetched
423 "*Says how to handle unfetched articles when maneuvering.
424
425 This variable can either be the symbols nil (maneuver to any
426 article), `undownloaded' (maneuvering while unplugged ignores articles
427 that have not been fetched), `always-undownloaded' (maneuvering always
428 ignores articles that have not been fetched), `unfetched' (maneuvering
429 ignores articles whose headers have not been fetched).
430
431 NOTE: The list of unfetched articles will always be nil when plugged
432 and, when unplugged, a subset of the undownloaded article list."
433 :version "22.1"
434 :group 'gnus-summary-maneuvering
435 :type '(choice (const :tag "None" nil)
436 (const :tag "Undownloaded when unplugged" undownloaded)
437 (const :tag "Undownloaded" always-undownloaded)
438 (const :tag "Unfetched" unfetched)))
439
440 (defcustom gnus-summary-check-current nil
441 "*If non-nil, consider the current article when moving.
442 The \"unread\" movement commands will stay on the same line if the
443 current article is unread."
444 :group 'gnus-summary-maneuvering
445 :type 'boolean)
446
447 (defcustom gnus-auto-center-summary
448 (max (or (bound-and-true-p scroll-margin) 0) 2)
449 "*If non-nil, always center the current summary buffer.
450 In particular, if `vertical' do only vertical recentering. If non-nil
451 and non-`vertical', do both horizontal and vertical recentering."
452 :group 'gnus-summary-maneuvering
453 :type '(choice (const :tag "none" nil)
454 (const vertical)
455 (integer :tag "height")
456 (sexp :menu-tag "both" t)))
457
458 (defcustom gnus-auto-center-group t
459 "If non-nil, always center the group buffer."
460 :group 'gnus-summary-maneuvering
461 :type 'boolean)
462
463 (defcustom gnus-show-all-headers nil
464 "*If non-nil, don't hide any headers."
465 :group 'gnus-article-hiding
466 :group 'gnus-article-headers
467 :type 'boolean)
468
469 (defcustom gnus-summary-ignore-duplicates nil
470 "*If non-nil, ignore articles with identical Message-ID headers."
471 :group 'gnus-summary
472 :type 'boolean)
473
474 (defcustom gnus-single-article-buffer nil
475 "*If non-nil, display all articles in the same buffer.
476 If nil, each group will get its own article buffer."
477 :version "24.1"
478 :group 'gnus-article-various
479 :type 'boolean)
480
481 (defcustom gnus-widen-article-window nil
482 "If non-nil, selecting the article buffer will display only the article buffer."
483 :version "24.1"
484 :group 'gnus-article-various
485 :type 'boolean)
486
487 (defcustom gnus-break-pages t
488 "*If non-nil, do page breaking on articles.
489 The page delimiter is specified by the `gnus-page-delimiter'
490 variable."
491 :group 'gnus-article-various
492 :type 'boolean)
493
494 (defcustom gnus-move-split-methods nil
495 "*Variable used to suggest where articles are to be moved to.
496 It uses the same syntax as the `gnus-split-methods' variable.
497 However, whereas `gnus-split-methods' specifies file names as targets,
498 this variable specifies group names."
499 :group 'gnus-summary-mail
500 :type '(repeat (choice (list :value (fun) function)
501 (cons :value ("" "") regexp (repeat string))
502 (sexp :value nil))))
503
504 (defcustom gnus-move-group-prefix-function 'gnus-group-real-prefix
505 "Function used to compute default prefix for article move/copy/etc prompts.
506 The function should take one argument, a group name, and return a
507 string with the suggested prefix."
508 :group 'gnus-summary-mail
509 :type 'function)
510
511 ;; FIXME: Although the custom type is `character' for the following variables,
512 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
513
514 (defcustom gnus-unread-mark ? ;Whitespace
515 "*Mark used for unread articles."
516 :group 'gnus-summary-marks
517 :type 'character)
518
519 (defcustom gnus-ticked-mark ?!
520 "*Mark used for ticked articles."
521 :group 'gnus-summary-marks
522 :type 'character)
523
524 (defcustom gnus-dormant-mark ??
525 "*Mark used for dormant articles."
526 :group 'gnus-summary-marks
527 :type 'character)
528
529 (defcustom gnus-del-mark ?r
530 "*Mark used for del'd articles."
531 :group 'gnus-summary-marks
532 :type 'character)
533
534 (defcustom gnus-read-mark ?R
535 "*Mark used for read articles."
536 :group 'gnus-summary-marks
537 :type 'character)
538
539 (defcustom gnus-expirable-mark ?E
540 "*Mark used for expirable articles."
541 :group 'gnus-summary-marks
542 :type 'character)
543
544 (defcustom gnus-killed-mark ?K
545 "*Mark used for killed articles."
546 :group 'gnus-summary-marks
547 :type 'character)
548
549 (defcustom gnus-spam-mark ?$
550 "*Mark used for spam articles."
551 :version "22.1"
552 :group 'gnus-summary-marks
553 :type 'character)
554
555 (defcustom gnus-kill-file-mark ?X
556 "*Mark used for articles killed by kill files."
557 :group 'gnus-summary-marks
558 :type 'character)
559
560 (defcustom gnus-low-score-mark ?Y
561 "*Mark used for articles with a low score."
562 :group 'gnus-summary-marks
563 :type 'character)
564
565 (defcustom gnus-catchup-mark ?C
566 "*Mark used for articles that are caught up."
567 :group 'gnus-summary-marks
568 :type 'character)
569
570 (defcustom gnus-replied-mark ?A
571 "*Mark used for articles that have been replied to."
572 :group 'gnus-summary-marks
573 :type 'character)
574
575 (defcustom gnus-forwarded-mark ?F
576 "*Mark used for articles that have been forwarded."
577 :version "22.1"
578 :group 'gnus-summary-marks
579 :type 'character)
580
581 (defcustom gnus-recent-mark ?N
582 "*Mark used for articles that are recent."
583 :version "22.1"
584 :group 'gnus-summary-marks
585 :type 'character)
586
587 (defcustom gnus-cached-mark ?*
588 "*Mark used for articles that are in the cache."
589 :group 'gnus-summary-marks
590 :type 'character)
591
592 (defcustom gnus-saved-mark ?S
593 "*Mark used for articles that have been saved."
594 :group 'gnus-summary-marks
595 :type 'character)
596
597 (defcustom gnus-unseen-mark ?.
598 "*Mark used for articles that haven't been seen."
599 :version "22.1"
600 :group 'gnus-summary-marks
601 :type 'character)
602
603 (defcustom gnus-no-mark ? ;Whitespace
604 "*Mark used for articles that have no other secondary mark."
605 :version "22.1"
606 :group 'gnus-summary-marks
607 :type 'character)
608
609 (defcustom gnus-ancient-mark ?O
610 "*Mark used for ancient articles."
611 :group 'gnus-summary-marks
612 :type 'character)
613
614 (defcustom gnus-sparse-mark ?Q
615 "*Mark used for sparsely reffed articles."
616 :group 'gnus-summary-marks
617 :type 'character)
618
619 (defcustom gnus-canceled-mark ?G
620 "*Mark used for canceled articles."
621 :group 'gnus-summary-marks
622 :type 'character)
623
624 (defcustom gnus-duplicate-mark ?M
625 "*Mark used for duplicate articles."
626 :group 'gnus-summary-marks
627 :type 'character)
628
629 (defcustom gnus-undownloaded-mark ?-
630 "*Mark used for articles that weren't downloaded."
631 :version "22.1"
632 :group 'gnus-summary-marks
633 :type 'character)
634
635 (defcustom gnus-downloaded-mark ?+
636 "*Mark used for articles that were downloaded."
637 :group 'gnus-summary-marks
638 :type 'character)
639
640 (defcustom gnus-downloadable-mark ?%
641 "*Mark used for articles that are to be downloaded."
642 :group 'gnus-summary-marks
643 :type 'character)
644
645 (defcustom gnus-unsendable-mark ?=
646 "*Mark used for articles that won't be sent."
647 :group 'gnus-summary-marks
648 :type 'character)
649
650 (defcustom gnus-score-over-mark ?+
651 "*Score mark used for articles with high scores."
652 :group 'gnus-summary-marks
653 :type 'character)
654
655 (defcustom gnus-score-below-mark ?-
656 "*Score mark used for articles with low scores."
657 :group 'gnus-summary-marks
658 :type 'character)
659
660 (defcustom gnus-empty-thread-mark ? ;Whitespace
661 "*There is no thread under the article."
662 :group 'gnus-summary-marks
663 :type 'character)
664
665 (defcustom gnus-not-empty-thread-mark ?=
666 "*There is a thread under the article."
667 :group 'gnus-summary-marks
668 :type 'character)
669
670 (defcustom gnus-view-pseudo-asynchronously nil
671 "*If non-nil, Gnus will view pseudo-articles asynchronously."
672 :group 'gnus-extract-view
673 :type 'boolean)
674
675 (defcustom gnus-auto-expirable-marks
676 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
677 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
678 gnus-duplicate-mark)
679 "*The list of marks converted into expiration if a group is auto-expirable."
680 :version "24.1"
681 :group 'gnus-summary
682 :type '(repeat character))
683
684 (defcustom gnus-inhibit-user-auto-expire t
685 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
686 :version "21.1"
687 :group 'gnus-summary
688 :type 'boolean)
689
690 (defcustom gnus-mark-copied-or-moved-articles-as-expirable nil
691 "If non-nil, mark articles copied or moved to auto-expire group as expirable.
692 If nil, the expirable marks will be unchanged except that the marks
693 will be removed when copying or moving articles to a group that has
694 not turned auto-expire on. If non-nil, articles that have been read
695 will be marked as expirable when being copied or moved to a group in
696 which auto-expire is turned on."
697 :version "23.2"
698 :type 'boolean
699 :group 'gnus-summary-marks)
700
701 (defcustom gnus-view-pseudos nil
702 "*If `automatic', pseudo-articles will be viewed automatically.
703 If `not-confirm', pseudos will be viewed automatically, and the user
704 will not be asked to confirm the command."
705 :group 'gnus-extract-view
706 :type '(choice (const :tag "off" nil)
707 (const automatic)
708 (const not-confirm)))
709
710 (defcustom gnus-view-pseudos-separately t
711 "*If non-nil, one pseudo-article will be created for each file to be viewed.
712 If nil, all files that use the same viewing command will be given as a
713 list of parameters to that command."
714 :group 'gnus-extract-view
715 :type 'boolean)
716
717 (defcustom gnus-insert-pseudo-articles t
718 "*If non-nil, insert pseudo-articles when decoding articles."
719 :group 'gnus-extract-view
720 :type 'boolean)
721
722 (defcustom gnus-summary-dummy-line-format
723 " %(: :%) %S\n"
724 "*The format specification for the dummy roots in the summary buffer.
725 It works along the same lines as a normal formatting string,
726 with some simple extensions.
727
728 %S The subject
729
730 General format specifiers can also be used.
731 See `(gnus)Formatting Variables'."
732 :link '(custom-manual "(gnus)Formatting Variables")
733 :group 'gnus-threading
734 :type 'string)
735
736 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
737 "*The format specification for the summary mode line.
738 It works along the same lines as a normal formatting string,
739 with some simple extensions:
740
741 %G Group name
742 %p Unprefixed group name
743 %A Current article number
744 %z Current article score
745 %V Gnus version
746 %U Number of unread articles in the group
747 %e Number of unselected articles in the group
748 %Z A string with unread/unselected article counts
749 %g Shortish group name
750 %S Subject of the current article
751 %u User-defined spec
752 %s Current score file name
753 %d Number of dormant articles
754 %r Number of articles that have been marked as read in this session
755 %E Number of articles expunged by the score files"
756 :group 'gnus-summary-format
757 :type 'string)
758
759 (defcustom gnus-list-identifiers nil
760 "Regexp that matches list identifiers to be removed from subject.
761 This can also be a list of regexps."
762 :version "21.1"
763 :group 'gnus-summary-format
764 :group 'gnus-article-hiding
765 :type '(choice (const :tag "none" nil)
766 (regexp :value ".*")
767 (repeat :value (".*") regexp)))
768
769 (defcustom gnus-summary-mark-below 0
770 "*Mark all articles with a score below this variable as read.
771 This variable is local to each summary buffer and usually set by the
772 score file."
773 :group 'gnus-score-default
774 :type 'integer)
775
776 (defun gnus-widget-reversible-match (widget value)
777 "Ignoring WIDGET, convert VALUE to internal form.
778 VALUE should have the form `FOO' or `(not FOO)', where FOO is an symbol."
779 ;; (debug value)
780 (or (symbolp value)
781 (and (listp value)
782 (eq (length value) 2)
783 (eq (nth 0 value) 'not)
784 (symbolp (nth 1 value)))))
785
786 (defun gnus-widget-reversible-to-internal (widget value)
787 "Ignoring WIDGET, convert VALUE to internal form.
788 VALUE should have the form `FOO' or `(not FOO)', where FOO is an atom.
789 FOO is converted to (FOO nil) and (not FOO) is converted to (FOO t)."
790 ;; (debug value)
791 (if (atom value)
792 (list value nil)
793 (list (nth 1 value) t)))
794
795 (defun gnus-widget-reversible-to-external (widget value)
796 "Ignoring WIDGET, convert VALUE to external form.
797 VALUE should have the form `(FOO nil)' or `(FOO t)', where FOO is an atom.
798 \(FOO nil) is converted to FOO and (FOO t) is converted to (not FOO)."
799 ;; (debug value)
800 (if (nth 1 value)
801 (list 'not (nth 0 value))
802 (nth 0 value)))
803
804 (define-widget 'gnus-widget-reversible 'group
805 "A `group' that convert values."
806 :match 'gnus-widget-reversible-match
807 :value-to-internal 'gnus-widget-reversible-to-internal
808 :value-to-external 'gnus-widget-reversible-to-external)
809
810 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
811 "*List of functions used for sorting articles in the summary buffer.
812
813 Each function takes two articles and returns non-nil if the first
814 article should be sorted before the other. If you use more than one
815 function, the primary sort function should be the last. You should
816 probably always include `gnus-article-sort-by-number' in the list of
817 sorting functions -- preferably first. Also note that sorting by date
818 is often much slower than sorting by number, and the sorting order is
819 very similar. (Sorting by date means sorting by the time the message
820 was sent, sorting by number means sorting by arrival time.)
821
822 Each item can also be a list `(not F)' where F is a function;
823 this reverses the sort order.
824
825 Ready-made functions include `gnus-article-sort-by-number',
826 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
827 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
828 and `gnus-article-sort-by-score'.
829
830 When threading is turned on, the variable `gnus-thread-sort-functions'
831 controls how articles are sorted."
832 :group 'gnus-summary-sort
833 :type '(repeat (gnus-widget-reversible
834 (choice (function-item gnus-article-sort-by-number)
835 (function-item gnus-article-sort-by-author)
836 (function-item gnus-article-sort-by-subject)
837 (function-item gnus-article-sort-by-date)
838 (function-item gnus-article-sort-by-score)
839 (function-item gnus-article-sort-by-random)
840 (function :tag "other"))
841 (boolean :tag "Reverse order"))))
842
843 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
844 "*List of functions used for sorting threads in the summary buffer.
845 By default, threads are sorted by article number.
846
847 Each function takes two threads and returns non-nil if the first
848 thread should be sorted before the other. If you use more than one
849 function, the primary sort function should be the last. You should
850 probably always include `gnus-thread-sort-by-number' in the list of
851 sorting functions -- preferably first. Also note that sorting by date
852 is often much slower than sorting by number, and the sorting order is
853 very similar. (Sorting by date means sorting by the time the message
854 was sent, sorting by number means sorting by arrival time.)
855
856 Each list item can also be a list `(not F)' where F is a
857 function; this specifies reversed sort order.
858
859 Ready-made functions include `gnus-thread-sort-by-number',
860 `gnus-thread-sort-by-author', `gnus-thread-sort-by-recipient'
861 `gnus-thread-sort-by-subject', `gnus-thread-sort-by-date',
862 `gnus-thread-sort-by-score', `gnus-thread-sort-by-most-recent-number',
863 `gnus-thread-sort-by-most-recent-date', `gnus-thread-sort-by-random',
864 and `gnus-thread-sort-by-total-score' (see
865 `gnus-thread-score-function').
866
867 When threading is turned off, the variable
868 `gnus-article-sort-functions' controls how articles are sorted.
869
870 By default, threads and their subthreads are sorted according to
871 the value of this variable. To use a different sorting order for
872 subthreads, customize `gnus-subthread-sort-functions'."
873 :group 'gnus-summary-sort
874 :type '(repeat
875 (gnus-widget-reversible
876 (choice (function-item gnus-thread-sort-by-number)
877 (function-item gnus-thread-sort-by-author)
878 (function-item gnus-thread-sort-by-recipient)
879 (function-item gnus-thread-sort-by-subject)
880 (function-item gnus-thread-sort-by-date)
881 (function-item gnus-thread-sort-by-score)
882 (function-item gnus-thread-sort-by-most-recent-number)
883 (function-item gnus-thread-sort-by-most-recent-date)
884 (function-item gnus-thread-sort-by-random)
885 (function-item gnus-thread-sort-by-total-score)
886 (function :tag "other"))
887 (boolean :tag "Reverse order"))))
888
889 (defcustom gnus-subthread-sort-functions 'gnus-thread-sort-functions
890 "*List of functions used for sorting subthreads in the summary buffer.
891 By default, subthreads are sorted the same as threads, i.e.,
892 according to the value of `gnus-thread-sort-functions'."
893 :version "24.4"
894 :group 'gnus-summary-sort
895 :type '(choice
896 (const :tag "Sort subthreads like threads" gnus-thread-sort-functions)
897 (repeat
898 (gnus-widget-reversible
899 (choice (function-item gnus-thread-sort-by-number)
900 (function-item gnus-thread-sort-by-author)
901 (function-item gnus-thread-sort-by-recipient)
902 (function-item gnus-thread-sort-by-subject)
903 (function-item gnus-thread-sort-by-date)
904 (function-item gnus-thread-sort-by-score)
905 (function-item gnus-thread-sort-by-most-recent-number)
906 (function-item gnus-thread-sort-by-most-recent-date)
907 (function-item gnus-thread-sort-by-random)
908 (function-item gnus-thread-sort-by-total-score)
909 (function :tag "other"))
910 (boolean :tag "Reverse order")))))
911
912 (defcustom gnus-thread-score-function '+
913 "*Function used for calculating the total score of a thread.
914
915 The function is called with the scores of the article and each
916 subthread and should then return the score of the thread.
917
918 Some functions you can use are `+', `max', or `min'."
919 :group 'gnus-summary-sort
920 :type 'function)
921
922 (defcustom gnus-summary-expunge-below nil
923 "All articles that have a score less than this variable will be expunged.
924 This variable is local to the summary buffers."
925 :group 'gnus-score-default
926 :type '(choice (const :tag "off" nil)
927 integer))
928
929 (defcustom gnus-thread-expunge-below nil
930 "All threads that have a total score less than this variable will be expunged.
931 See `gnus-thread-score-function' for en explanation of what a
932 \"thread score\" is.
933
934 This variable is local to the summary buffers."
935 :group 'gnus-threading
936 :group 'gnus-score-default
937 :type '(choice (const :tag "off" nil)
938 integer))
939
940 (defcustom gnus-summary-mode-hook nil
941 "*A hook for Gnus summary mode.
942 This hook is run before any variables are set in the summary buffer."
943 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
944 :group 'gnus-summary-various
945 :type 'hook)
946
947 (defcustom gnus-summary-menu-hook nil
948 "*Hook run after the creation of the summary mode menu."
949 :group 'gnus-summary-visual
950 :type 'hook)
951
952 (defcustom gnus-summary-exit-hook nil
953 "*A hook called on exit from the summary buffer.
954 It will be called with point in the group buffer."
955 :group 'gnus-summary-exit
956 :type 'hook)
957
958 (defcustom gnus-summary-prepare-hook nil
959 "*A hook called after the summary buffer has been generated.
960 If you want to modify the summary buffer, you can use this hook."
961 :group 'gnus-summary-various
962 :type 'hook)
963
964 (defcustom gnus-summary-prepared-hook nil
965 "*A hook called as the last thing after the summary buffer has been generated."
966 :group 'gnus-summary-various
967 :type 'hook)
968
969 (defcustom gnus-summary-generate-hook nil
970 "*A hook run just before generating the summary buffer.
971 This hook is commonly used to customize threading variables and the
972 like."
973 :group 'gnus-summary-various
974 :type 'hook)
975
976 (defcustom gnus-select-group-hook nil
977 "*A hook called when a newsgroup is selected.
978
979 If you'd like to simplify subjects like the
980 `gnus-summary-next-same-subject' command does, you can use the
981 following hook:
982
983 (add-hook gnus-select-group-hook
984 (lambda ()
985 (mapcar (lambda (header)
986 (mail-header-set-subject
987 header
988 (gnus-simplify-subject
989 (mail-header-subject header) \\='re-only)))
990 gnus-newsgroup-headers)))"
991 :group 'gnus-group-select
992 :type 'hook)
993
994 (defcustom gnus-select-article-hook nil
995 "*A hook called when an article is selected."
996 :group 'gnus-summary-choose
997 :options '(gnus-agent-fetch-selected-article)
998 :type 'hook)
999
1000 (defcustom gnus-visual-mark-article-hook
1001 (list 'gnus-highlight-selected-summary)
1002 "*Hook run after selecting an article in the summary buffer.
1003 It is meant to be used for highlighting the article in some way. It
1004 is not run if `gnus-visual' is nil."
1005 :group 'gnus-summary-visual
1006 :type 'hook)
1007
1008 (defcustom gnus-parse-headers-hook nil
1009 "*A hook called before parsing the headers."
1010 :group 'gnus-various
1011 :type 'hook)
1012
1013 (defcustom gnus-exit-group-hook nil
1014 "*A hook called when exiting summary mode.
1015 This hook is not called from the non-updating exit commands like `Q'."
1016 :group 'gnus-various
1017 :type 'hook)
1018
1019 (defcustom gnus-summary-update-hook nil
1020 "*A hook called when a summary line is changed.
1021 The hook will not be called if `gnus-visual' is nil.
1022
1023 The default function `gnus-summary-highlight-line' will
1024 highlight the line according to the `gnus-summary-highlight'
1025 variable."
1026 :group 'gnus-summary-visual
1027 :type 'hook)
1028
1029 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
1030 "*A hook called when an article is selected for the first time.
1031 The hook is intended to mark an article as read (or unread)
1032 automatically when it is selected."
1033 :group 'gnus-summary-choose
1034 :type 'hook)
1035
1036 (defcustom gnus-group-no-more-groups-hook nil
1037 "*A hook run when returning to group mode having no more (unread) groups."
1038 :group 'gnus-group-select
1039 :type 'hook)
1040
1041 (defcustom gnus-ps-print-hook nil
1042 "*A hook run before ps-printing something from Gnus."
1043 :group 'gnus-summary
1044 :type 'hook)
1045
1046 (defcustom gnus-summary-article-move-hook nil
1047 "*A hook called after an article is moved, copied, respooled, or crossposted."
1048 :version "22.1"
1049 :group 'gnus-summary
1050 :type 'hook)
1051
1052 (defcustom gnus-summary-article-delete-hook nil
1053 "*A hook called after an article is deleted."
1054 :version "22.1"
1055 :group 'gnus-summary
1056 :type 'hook)
1057
1058 (defcustom gnus-summary-article-expire-hook nil
1059 "*A hook called after an article is expired."
1060 :version "22.1"
1061 :group 'gnus-summary
1062 :type 'hook)
1063
1064 (defcustom gnus-summary-display-arrow (display-graphic-p)
1065 "*If non-nil, display an arrow highlighting the current article."
1066 :version "22.1"
1067 :group 'gnus-summary
1068 :type 'boolean)
1069
1070 (defcustom gnus-summary-selected-face 'gnus-summary-selected
1071 "Face used for highlighting the current article in the summary buffer."
1072 :group 'gnus-summary-visual
1073 :type 'face)
1074
1075 (defvar gnus-tmp-downloaded nil)
1076
1077 (defcustom gnus-summary-highlight
1078 '(((eq mark gnus-canceled-mark)
1079 . gnus-summary-cancelled)
1080 ((and uncached (> score default-high))
1081 . gnus-summary-high-undownloaded)
1082 ((and uncached (< score default-low))
1083 . gnus-summary-low-undownloaded)
1084 (uncached
1085 . gnus-summary-normal-undownloaded)
1086 ((and (> score default-high)
1087 (or (eq mark gnus-dormant-mark)
1088 (eq mark gnus-ticked-mark)))
1089 . gnus-summary-high-ticked)
1090 ((and (< score default-low)
1091 (or (eq mark gnus-dormant-mark)
1092 (eq mark gnus-ticked-mark)))
1093 . gnus-summary-low-ticked)
1094 ((or (eq mark gnus-dormant-mark)
1095 (eq mark gnus-ticked-mark))
1096 . gnus-summary-normal-ticked)
1097 ((and (> score default-high) (eq mark gnus-ancient-mark))
1098 . gnus-summary-high-ancient)
1099 ((and (< score default-low) (eq mark gnus-ancient-mark))
1100 . gnus-summary-low-ancient)
1101 ((eq mark gnus-ancient-mark)
1102 . gnus-summary-normal-ancient)
1103 ((and (> score default-high) (eq mark gnus-unread-mark))
1104 . gnus-summary-high-unread)
1105 ((and (< score default-low) (eq mark gnus-unread-mark))
1106 . gnus-summary-low-unread)
1107 ((eq mark gnus-unread-mark)
1108 . gnus-summary-normal-unread)
1109 ((> score default-high)
1110 . gnus-summary-high-read)
1111 ((< score default-low)
1112 . gnus-summary-low-read)
1113 (t
1114 . gnus-summary-normal-read))
1115 "*Controls the highlighting of summary buffer lines.
1116
1117 A list of (FORM . FACE) pairs. When deciding how a particular
1118 summary line should be displayed, each form is evaluated. The content
1119 of the face field after the first true form is used. You can change
1120 how those summary lines are displayed, by editing the face field.
1121
1122 You can use the following variables in the FORM field.
1123
1124 score: The article's score.
1125 default: The default article score.
1126 default-high: The default score for high scored articles.
1127 default-low: The default score for low scored articles.
1128 mark: The article's mark.
1129 uncached: Non-nil if the article is uncached."
1130 :group 'gnus-summary-visual
1131 :type '(repeat (cons (sexp :tag "Form" nil)
1132 face)))
1133 (put 'gnus-summary-highlight 'risky-local-variable t)
1134
1135 (defcustom gnus-alter-header-function nil
1136 "Function called to allow alteration of article header structures.
1137 The function is called with one parameter, the article header vector,
1138 which it may alter in any way."
1139 :type '(choice (const :tag "None" nil)
1140 function)
1141 :group 'gnus-summary)
1142
1143 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
1144 "Function used to decode a string with encoded words.")
1145
1146 (defvar gnus-decode-encoded-address-function
1147 'mail-decode-encoded-address-string
1148 "Function used to decode addresses with encoded words.")
1149
1150 (defcustom gnus-extra-headers '(To Cc Keywords Gcc Newsgroups X-GM-LABELS)
1151 "*Extra headers to parse."
1152 :version "25.1"
1153 :group 'gnus-summary
1154 :type '(repeat symbol))
1155
1156 (defcustom gnus-ignored-from-addresses
1157 (and user-mail-address
1158 (not (string= user-mail-address ""))
1159 (regexp-quote user-mail-address))
1160 "*From headers that may be suppressed in favor of To headers.
1161 This can be a regexp, a list of regexps or a function.
1162
1163 If a function, an email string is passed as the argument."
1164 :version "21.1"
1165 :group 'gnus-summary
1166 :type '(choice regexp
1167 (repeat :tag "Regexp List" regexp)
1168 function))
1169
1170 (defsubst gnus-ignored-from-addresses ()
1171 (cond ((functionp gnus-ignored-from-addresses)
1172 gnus-ignored-from-addresses)
1173 (t (gmm-regexp-concat gnus-ignored-from-addresses))))
1174
1175 (defcustom gnus-summary-to-prefix "-> "
1176 "*String prefixed to the To field in the summary line when
1177 using `gnus-ignored-from-addresses'."
1178 :version "22.1"
1179 :group 'gnus-summary
1180 :type 'string)
1181
1182 (defcustom gnus-summary-newsgroup-prefix "=> "
1183 "*String prefixed to the Newsgroup field in the summary
1184 line when using the option `gnus-ignored-from-addresses'."
1185 :version "22.1"
1186 :group 'gnus-summary
1187 :type 'string)
1188
1189 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1190 "List of charsets that should be ignored.
1191 When these charsets are used in the \"charset\" parameter, the
1192 default charset will be used instead."
1193 :version "21.1"
1194 :type '(repeat symbol)
1195 :group 'gnus-charset)
1196
1197 (defcustom gnus-newsgroup-maximum-articles nil
1198 "The maximum number of articles a newsgroup.
1199 If this is a number, old articles in a newsgroup exceeding this number
1200 are silently ignored. If it is nil, no article is ignored. Note that
1201 setting this variable to a number might prevent you from reading very
1202 old articles."
1203 :group 'gnus-group-select
1204 :version "22.2"
1205 :type '(choice (const :tag "No limit" nil)
1206 integer))
1207
1208 (gnus-define-group-parameter
1209 ignored-charsets
1210 :type list
1211 :function-document
1212 "Return the ignored charsets of GROUP."
1213 :variable gnus-group-ignored-charsets-alist
1214 :variable-default
1215 '(("alt\\.chinese\\.text" iso-8859-1))
1216 :variable-document
1217 "Alist of regexps (to match group names) and charsets that should be ignored.
1218 When these charsets are used in the \"charset\" parameter, the
1219 default charset will be used instead."
1220 :variable-group gnus-charset
1221 :variable-type '(repeat (cons (regexp :tag "Group")
1222 (repeat symbol)))
1223 :parameter-type '(choice :tag "Ignored charsets"
1224 :value nil
1225 (repeat (symbol)))
1226 :parameter-document "\
1227 List of charsets that should be ignored.
1228
1229 When these charsets are used in the \"charset\" parameter, the
1230 default charset will be used instead.")
1231
1232 (defcustom gnus-group-highlight-words-alist nil
1233 "Alist of group regexps and highlight regexps.
1234 This variable uses the same syntax as `gnus-emphasis-alist'."
1235 :version "21.1"
1236 :type '(repeat (cons (regexp :tag "Group")
1237 (repeat (list (regexp :tag "Highlight regexp")
1238 (number :tag "Group for entire word" 0)
1239 (number :tag "Group for displayed part" 0)
1240 (symbol :tag "Face"
1241 gnus-emphasis-highlight-words)))))
1242 :group 'gnus-summary-visual)
1243
1244 (defcustom gnus-summary-show-article-charset-alist
1245 nil
1246 "Alist of number and charset.
1247 The article will be shown with the charset corresponding to the
1248 numbered argument.
1249 For example: ((1 . cn-gb-2312) (2 . big5))."
1250 :version "21.1"
1251 :type '(repeat (cons (number :tag "Argument" 1)
1252 (symbol :tag "Charset")))
1253 :group 'gnus-charset)
1254
1255 (defcustom gnus-preserve-marks t
1256 "Whether marks are preserved when moving, copying and respooling messages."
1257 :version "21.1"
1258 :type 'boolean
1259 :group 'gnus-summary-marks)
1260
1261 (defcustom gnus-alter-articles-to-read-function nil
1262 "Function to be called to alter the list of articles to be selected."
1263 :type '(choice (const nil) function)
1264 :group 'gnus-summary)
1265
1266 (defcustom gnus-orphan-score nil
1267 "*All orphans get this score added. Set in the score file."
1268 :group 'gnus-score-default
1269 :type '(choice (const nil)
1270 integer))
1271
1272 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1273 "*A regexp to match MIME parts when saving multiple parts of a
1274 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1275 This regexp will be used by default when prompting the user for which
1276 type of files to save."
1277 :group 'gnus-summary
1278 :type 'regexp)
1279
1280 (defcustom gnus-read-all-available-headers nil
1281 "Whether Gnus should parse all headers made available to it.
1282 This is mostly relevant for slow back ends where the user may
1283 wish to widen the summary buffer to include all headers
1284 that were fetched."
1285 :version "22.1"
1286 :group 'gnus-summary
1287 :type '(choice boolean regexp))
1288
1289 (defcustom gnus-summary-pipe-output-default-command nil
1290 "Command (and optional arguments) used to pipe article to subprocess.
1291 This will be used as the default command if it is non-nil. The value
1292 will be updated if you modify it when executing the command
1293 `gnus-summary-pipe-output' or the function `gnus-summary-save-in-pipe'."
1294 :version "23.1" ;; No Gnus
1295 :group 'gnus-summary
1296 :type '(radio (const :tag "None" nil) (string :tag "Command")))
1297
1298 (defcustom gnus-summary-muttprint-program "muttprint"
1299 "Command (and optional arguments) used to run Muttprint.
1300 The value will be updated if you modify it when executing the command
1301 `gnus-summary-muttprint'."
1302 :version "22.1"
1303 :group 'gnus-summary
1304 :type 'string)
1305
1306 (defcustom gnus-article-loose-mime t
1307 "If non-nil, don't require MIME-Version header.
1308 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1309 supply the MIME-Version header or deliberately strip it from the mail.
1310 If non-nil (the default), Gnus will treat some articles as MIME
1311 even if the MIME-Version header is missing."
1312 :version "22.1"
1313 :type 'boolean
1314 :group 'gnus-article-mime)
1315
1316 (defcustom gnus-article-emulate-mime t
1317 "If non-nil, use MIME emulation for uuencode and the like.
1318 This means that Gnus will search message bodies for text that look
1319 like uuencoded bits, yEncoded bits, and so on, and present that using
1320 the normal Gnus MIME machinery."
1321 :version "22.1"
1322 :type 'boolean
1323 :group 'gnus-article-mime)
1324
1325 ;;; Internal variables
1326
1327 (defvar gnus-summary-display-cache nil)
1328 (defvar gnus-article-mime-handles nil)
1329 (defvar gnus-article-decoded-p nil)
1330 (defvar gnus-article-charset nil)
1331 (defvar gnus-article-ignored-charsets nil)
1332 (defvar gnus-scores-exclude-files nil)
1333 (defvar gnus-page-broken nil)
1334
1335 (defvar gnus-original-article nil)
1336 (defvar gnus-article-internal-prepare-hook nil)
1337 (defvar gnus-newsgroup-process-stack nil)
1338
1339 (defvar gnus-thread-indent-array nil)
1340 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1341 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1342 "Function called to sort the articles within a thread after it has been gathered together.")
1343
1344 (defvar gnus-summary-save-parts-type-history nil)
1345 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1346
1347 ;; Avoid highlighting in kill files.
1348 (defvar gnus-summary-inhibit-highlight nil)
1349 (defvar gnus-newsgroup-selected-overlay nil)
1350 (defvar gnus-inhibit-limiting nil)
1351 (defvar gnus-newsgroup-adaptive-score-file nil)
1352 (defvar gnus-current-score-file nil)
1353 (defvar gnus-current-move-group nil)
1354 (defvar gnus-current-copy-group nil)
1355 (defvar gnus-current-crosspost-group nil)
1356 (defvar gnus-newsgroup-display nil)
1357
1358 (defvar gnus-newsgroup-dependencies nil)
1359 (defvar gnus-newsgroup-adaptive nil)
1360 (defvar gnus-summary-display-article-function nil)
1361 (defvar gnus-summary-highlight-line-function nil
1362 "Function called after highlighting a summary line.")
1363
1364 (defvar gnus-summary-line-format-alist
1365 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1366 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1367 (?s gnus-tmp-subject-or-nil ?s)
1368 (?n gnus-tmp-name ?s)
1369 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1370 ?s)
1371 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1372 gnus-tmp-from) ?s)
1373 (?F gnus-tmp-from ?s)
1374 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1375 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1376 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1377 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1378 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1379 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1380 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1381 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1382 (?L gnus-tmp-lines ?s)
1383 (?Z (or (nnir-article-rsv (mail-header-number gnus-tmp-header))
1384 0) ?d)
1385 (?G (or (nnir-article-group (mail-header-number gnus-tmp-header))
1386 "") ?s)
1387 (?g (or (gnus-group-short-name
1388 (nnir-article-group (mail-header-number gnus-tmp-header)))
1389 "") ?s)
1390 (?O gnus-tmp-downloaded ?c)
1391 (?I gnus-tmp-indentation ?s)
1392 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1393 (?R gnus-tmp-replied ?c)
1394 (?\[ gnus-tmp-opening-bracket ?c)
1395 (?\] gnus-tmp-closing-bracket ?c)
1396 (?\> (make-string gnus-tmp-level ? ) ?s)
1397 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1398 (?i gnus-tmp-score ?d)
1399 (?z gnus-tmp-score-char ?c)
1400 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1401 (?U gnus-tmp-unread ?c)
1402 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1403 ?s)
1404 (?t (gnus-summary-number-of-articles-in-thread
1405 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1406 ?d)
1407 (?e (gnus-summary-number-of-articles-in-thread
1408 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1409 ?c)
1410 (?u gnus-tmp-user-defined ?s)
1411 (?P (gnus-pick-line-number) ?d)
1412 (?B gnus-tmp-thread-tree-header-string ?s)
1413 (user-date (gnus-user-date
1414 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1415 "An alist of format specifications that can appear in summary lines.
1416 These are paired with what variables they correspond with, along with
1417 the type of the variable (string, integer, character, etc).")
1418
1419 (defvar gnus-summary-dummy-line-format-alist
1420 `((?S gnus-tmp-subject ?s)
1421 (?N gnus-tmp-number ?d)
1422 (?u gnus-tmp-user-defined ?s)))
1423
1424 (defvar gnus-summary-mode-line-format-alist
1425 `((?G gnus-tmp-group-name ?s)
1426 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1427 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1428 (?A gnus-tmp-article-number ?d)
1429 (?Z gnus-tmp-unread-and-unselected ?s)
1430 (?V gnus-version ?s)
1431 (?U gnus-tmp-unread-and-unticked ?d)
1432 (?S gnus-tmp-subject ?s)
1433 (?e gnus-tmp-unselected ?d)
1434 (?u gnus-tmp-user-defined ?s)
1435 (?d (length gnus-newsgroup-dormant) ?d)
1436 (?t (length gnus-newsgroup-marked) ?d)
1437 (?h (length gnus-newsgroup-spam-marked) ?d)
1438 (?r (length gnus-newsgroup-reads) ?d)
1439 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1440 (?E gnus-newsgroup-expunged-tally ?d)
1441 (?s (gnus-current-score-file-nondirectory) ?s)))
1442
1443 ;; This is here rather than in gnus-art for compilation reasons.
1444 (defvar gnus-article-mode-line-format-alist
1445 (nconc '((?w (gnus-article-wash-status) ?s)
1446 (?m (gnus-article-mime-part-status) ?s))
1447 gnus-summary-mode-line-format-alist))
1448
1449 (defvar gnus-last-search-regexp nil
1450 "Default regexp for article search command.")
1451
1452 (defvar gnus-last-shell-command nil
1453 "Default shell command on article.")
1454
1455 (defvar gnus-newsgroup-agentized nil
1456 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1457 (defvar gnus-newsgroup-begin nil)
1458 (defvar gnus-newsgroup-end nil)
1459 (defvar gnus-newsgroup-last-rmail nil)
1460 (defvar gnus-newsgroup-last-mail nil)
1461 (defvar gnus-newsgroup-last-folder nil)
1462 (defvar gnus-newsgroup-last-file nil)
1463 (defvar gnus-newsgroup-last-directory nil)
1464 (defvar gnus-newsgroup-auto-expire nil)
1465 (defvar gnus-newsgroup-active nil)
1466 (defvar gnus-newsgroup-highest nil)
1467
1468 (defvar gnus-newsgroup-data nil)
1469 (defvar gnus-newsgroup-data-reverse nil)
1470 (defvar gnus-newsgroup-limit nil)
1471 (defvar gnus-newsgroup-limits nil)
1472 (defvar gnus-summary-use-undownloaded-faces nil)
1473
1474 (defvar gnus-newsgroup-unreads nil
1475 "Sorted list of unread articles in the current newsgroup.")
1476
1477 (defvar gnus-newsgroup-unselected nil
1478 "Sorted list of unselected unread articles in the current newsgroup.")
1479
1480 (defvar gnus-newsgroup-reads nil
1481 "Alist of read articles and article marks in the current newsgroup.")
1482
1483 (defvar gnus-newsgroup-expunged-tally nil)
1484
1485 (defvar gnus-newsgroup-marked nil
1486 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1487
1488 (defvar gnus-newsgroup-spam-marked nil
1489 "List of ranges of articles that have been marked as spam.")
1490
1491 (defvar gnus-newsgroup-killed nil
1492 "List of ranges of articles that have been through the scoring process.")
1493
1494 (defvar gnus-newsgroup-cached nil
1495 "Sorted list of articles that come from the article cache.")
1496
1497 (defvar gnus-newsgroup-saved nil
1498 "List of articles that have been saved.")
1499
1500 (defvar gnus-newsgroup-kill-headers nil)
1501
1502 (defvar gnus-newsgroup-replied nil
1503 "List of articles that have been replied to in the current newsgroup.")
1504
1505 (defvar gnus-newsgroup-forwarded nil
1506 "List of articles that have been forwarded in the current newsgroup.")
1507
1508 (defvar gnus-newsgroup-expirable nil
1509 "Sorted list of articles in the current newsgroup that can be expired.")
1510
1511 (defvar gnus-newsgroup-processable nil
1512 "List of articles in the current newsgroup that can be processed.")
1513
1514 (defvar gnus-newsgroup-downloadable nil
1515 "Sorted list of articles in the current newsgroup that can be processed.")
1516
1517 (defvar gnus-newsgroup-unfetched nil
1518 "Sorted list of articles in the current newsgroup whose headers have
1519 not been fetched into the agent.
1520
1521 This list will always be a subset of gnus-newsgroup-undownloaded.")
1522
1523 (defvar gnus-newsgroup-undownloaded nil
1524 "List of articles in the current newsgroup that haven't been downloaded.")
1525
1526 (defvar gnus-newsgroup-unsendable nil
1527 "List of articles in the current newsgroup that won't be sent.")
1528
1529 (defvar gnus-newsgroup-bookmarks nil
1530 "List of articles in the current newsgroup that have bookmarks.")
1531
1532 (defvar gnus-newsgroup-dormant nil
1533 "Sorted list of dormant articles in the current newsgroup.")
1534
1535 (defvar gnus-newsgroup-unseen nil
1536 "List of unseen articles in the current newsgroup.")
1537
1538 (defvar gnus-newsgroup-seen nil
1539 "Range of seen articles in the current newsgroup.")
1540
1541 (defvar gnus-newsgroup-unexist nil
1542 "Range of unexisting articles in the current newsgroup.")
1543
1544 (defvar gnus-newsgroup-articles nil
1545 "List of articles in the current newsgroup.")
1546
1547 (defvar gnus-newsgroup-scored nil
1548 "List of scored articles in the current newsgroup.")
1549
1550 (defvar gnus-newsgroup-headers nil
1551 "List of article headers in the current newsgroup.")
1552
1553 (defvar gnus-newsgroup-threads nil)
1554
1555 (defvar gnus-newsgroup-prepared nil
1556 "Whether the current group has been prepared properly.")
1557
1558 (defvar gnus-newsgroup-ancient nil
1559 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1560
1561 (defvar gnus-newsgroup-sparse nil)
1562
1563 (defvar gnus-current-article nil)
1564 (defvar gnus-article-current nil)
1565 (defvar gnus-current-headers nil)
1566 (defvar gnus-have-all-headers nil)
1567 (defvar gnus-last-article nil)
1568 (defvar gnus-newsgroup-history nil)
1569 (defvar gnus-newsgroup-charset nil)
1570 (defvar gnus-newsgroup-ephemeral-charset nil)
1571 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1572
1573 (defvar gnus-article-before-search nil)
1574
1575 (defvar gnus-summary-local-variables
1576 '(gnus-newsgroup-name
1577
1578 ;; Marks lists
1579 gnus-newsgroup-unreads
1580 gnus-newsgroup-unselected
1581 gnus-newsgroup-marked
1582 gnus-newsgroup-spam-marked
1583 gnus-newsgroup-reads
1584 gnus-newsgroup-saved
1585 gnus-newsgroup-replied
1586 gnus-newsgroup-forwarded
1587 gnus-newsgroup-expirable
1588 gnus-newsgroup-killed
1589 gnus-newsgroup-unseen
1590 gnus-newsgroup-seen
1591 gnus-newsgroup-unexist
1592 gnus-newsgroup-cached
1593 gnus-newsgroup-downloadable
1594 gnus-newsgroup-undownloaded
1595 gnus-newsgroup-unsendable
1596
1597 gnus-newsgroup-begin gnus-newsgroup-end
1598 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1599 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1600 gnus-newsgroup-last-directory
1601 gnus-newsgroup-auto-expire
1602 gnus-newsgroup-processable
1603 gnus-newsgroup-unfetched
1604 gnus-newsgroup-articles
1605 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1606 gnus-newsgroup-headers gnus-newsgroup-threads
1607 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1608 gnus-current-article gnus-current-headers gnus-have-all-headers
1609 gnus-last-article gnus-article-internal-prepare-hook
1610 (gnus-summary-article-delete-hook . global)
1611 (gnus-summary-article-move-hook . global)
1612 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1613 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1614 gnus-thread-expunge-below
1615 gnus-score-alist gnus-current-score-file
1616 (gnus-summary-expunge-below . global)
1617 (gnus-summary-mark-below . global)
1618 (gnus-orphan-score . global)
1619 gnus-newsgroup-active gnus-scores-exclude-files
1620 gnus-newsgroup-highest
1621 gnus-newsgroup-history gnus-newsgroup-ancient
1622 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1623 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1624 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1625 (gnus-newsgroup-expunged-tally . 0)
1626 gnus-cache-removable-articles
1627 gnus-newsgroup-data gnus-newsgroup-data-reverse
1628 gnus-newsgroup-limit gnus-newsgroup-limits
1629 gnus-newsgroup-charset gnus-newsgroup-display
1630 gnus-summary-use-undownloaded-faces)
1631 "Variables that are buffer-local to the summary buffers.")
1632
1633 (defvar gnus-newsgroup-variables nil
1634 "A list of variables that have separate values in different newsgroups.
1635 A list of newsgroup (summary buffer) local variables, or cons of
1636 variables and their default expressions to be evalled (when the default
1637 values are not nil), that should be made global while the summary buffer
1638 is active.
1639
1640 Note: The default expressions will be evaluated (using function `eval')
1641 before assignment to the local variable rather than just assigned to it.
1642 If the default expression is the symbol `global', that symbol will not
1643 be evaluated but the global value of the local variable will be used
1644 instead.
1645
1646 These variables can be used to set variables in the group parameters
1647 while still allowing them to affect operations done in other buffers.
1648 For example:
1649
1650 \(setq gnus-newsgroup-variables
1651 \\='(message-use-followup-to
1652 (gnus-visible-headers .
1653 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1654 ")
1655
1656 (eval-when-compile
1657 ;; Bind features so that require will believe that gnus-sum has
1658 ;; already been loaded (avoids infinite recursion)
1659 (let ((features (cons 'gnus-sum features)))
1660 (require 'gnus-art)))
1661
1662 ;; MIME stuff.
1663
1664 (defvar gnus-decode-encoded-word-methods
1665 '(mail-decode-encoded-word-string)
1666 "List of methods used to decode encoded words.
1667
1668 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1669 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1670 \(REGEXP . FUNCTION), FUNCTION will be applied only to the newsgroups
1671 whose names match REGEXP.
1672
1673 For example:
1674 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1675 mail-decode-encoded-word-string
1676 (\"chinese\" . rfc1843-decode-string))")
1677
1678 (defvar gnus-decode-encoded-word-methods-cache nil)
1679
1680 (defun gnus-multi-decode-encoded-word-string (string)
1681 "Apply the functions from `gnus-encoded-word-methods' that match."
1682 (unless (and gnus-decode-encoded-word-methods-cache
1683 (eq gnus-newsgroup-name
1684 (car gnus-decode-encoded-word-methods-cache)))
1685 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1686 (dolist (method gnus-decode-encoded-word-methods)
1687 (if (symbolp method)
1688 (nconc gnus-decode-encoded-word-methods-cache (list method))
1689 (if (and gnus-newsgroup-name
1690 (string-match (car method) gnus-newsgroup-name))
1691 (nconc gnus-decode-encoded-word-methods-cache
1692 (list (cdr method)))))))
1693 (dolist (method (cdr gnus-decode-encoded-word-methods-cache) string)
1694 (setq string (funcall method string))))
1695
1696 ;; Subject simplification.
1697
1698 (defun gnus-simplify-whitespace (str)
1699 "Remove excessive whitespace from STR."
1700 ;; Multiple spaces.
1701 (while (string-match "[ \t][ \t]+" str)
1702 (setq str (concat (substring str 0 (match-beginning 0))
1703 " "
1704 (substring str (match-end 0)))))
1705 ;; Leading spaces.
1706 (when (string-match "^[ \t]+" str)
1707 (setq str (substring str (match-end 0))))
1708 ;; Trailing spaces.
1709 (when (string-match "[ \t]+$" str)
1710 (setq str (substring str 0 (match-beginning 0))))
1711 str)
1712
1713 (defun gnus-simplify-all-whitespace (str)
1714 "Remove all whitespace from STR."
1715 (while (string-match "[ \t\n]+" str)
1716 (setq str (replace-match "" nil nil str)))
1717 str)
1718
1719 (defsubst gnus-simplify-subject-re (subject)
1720 "Remove \"Re:\" from subject lines."
1721 (if (string-match message-subject-re-regexp subject)
1722 (substring subject (match-end 0))
1723 subject))
1724
1725 (defun gnus-simplify-subject (subject &optional re-only)
1726 "Remove `Re:' and words in parentheses.
1727 If RE-ONLY is non-nil, strip leading `Re:'s only."
1728 (let ((case-fold-search t)) ;Ignore case.
1729 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1730 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1731 (setq subject (substring subject (match-end 0))))
1732 ;; Remove uninteresting prefixes.
1733 (when (and (not re-only)
1734 gnus-simplify-ignored-prefixes
1735 (string-match gnus-simplify-ignored-prefixes subject))
1736 (setq subject (substring subject (match-end 0))))
1737 ;; Remove words in parentheses from end.
1738 (unless re-only
1739 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1740 (setq subject (substring subject 0 (match-beginning 0)))))
1741 ;; Return subject string.
1742 subject))
1743
1744 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1745 ;; all whitespace.
1746 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1747 (goto-char (point-min))
1748 (while (re-search-forward regexp nil t)
1749 (replace-match (or newtext ""))))
1750
1751 (defun gnus-simplify-buffer-fuzzy (regexp)
1752 "Simplify string in the buffer fuzzily.
1753 The string in the accessible portion of the current buffer is simplified.
1754 It is assumed to be a single-line subject.
1755 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1756 matter is removed. Additional things can be deleted by setting
1757 `gnus-simplify-subject-fuzzy-regexp'."
1758 (let ((case-fold-search t)
1759 (modified-tick))
1760 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1761
1762 (while (not (eq modified-tick (buffer-modified-tick)))
1763 (setq modified-tick (buffer-modified-tick))
1764 (cond
1765 ((listp regexp)
1766 (mapc 'gnus-simplify-buffer-fuzzy-step regexp))
1767 (regexp
1768 (gnus-simplify-buffer-fuzzy-step regexp)))
1769 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1770 (gnus-simplify-buffer-fuzzy-step
1771 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1772 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1773
1774 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1775 (gnus-simplify-buffer-fuzzy-step " +" " ")
1776 (gnus-simplify-buffer-fuzzy-step " $")
1777 (gnus-simplify-buffer-fuzzy-step "^ +")))
1778
1779 (defun gnus-simplify-subject-fuzzy (subject)
1780 "Simplify a subject string fuzzily.
1781 See `gnus-simplify-buffer-fuzzy' for details."
1782 (save-excursion
1783 (let ((regexp gnus-simplify-subject-fuzzy-regexp))
1784 (gnus-set-work-buffer)
1785 (let ((case-fold-search t))
1786 ;; Remove uninteresting prefixes.
1787 (when (and gnus-simplify-ignored-prefixes
1788 (string-match gnus-simplify-ignored-prefixes subject))
1789 (setq subject (substring subject (match-end 0))))
1790 (insert subject)
1791 (inline (gnus-simplify-buffer-fuzzy regexp))
1792 (buffer-string)))))
1793
1794 (defsubst gnus-simplify-subject-fully (subject)
1795 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1796 (cond
1797 (gnus-simplify-subject-functions
1798 (gnus-map-function gnus-simplify-subject-functions subject))
1799 ((null gnus-summary-gather-subject-limit)
1800 (gnus-simplify-subject-re subject))
1801 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1802 (gnus-simplify-subject-fuzzy subject))
1803 ((numberp gnus-summary-gather-subject-limit)
1804 (truncate-string-to-width (gnus-simplify-subject-re subject)
1805 gnus-summary-gather-subject-limit))
1806 (t
1807 subject)))
1808
1809 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1810 "Check whether two subjects are equal.
1811 If optional argument SIMPLE-FIRST is t, first argument is already
1812 simplified."
1813 (cond
1814 ((null simple-first)
1815 (equal (gnus-simplify-subject-fully s1)
1816 (gnus-simplify-subject-fully s2)))
1817 (t
1818 (equal s1
1819 (gnus-simplify-subject-fully s2)))))
1820
1821 (defun gnus-summary-bubble-group ()
1822 "Increase the score of the current group.
1823 This is a handy function to add to `gnus-summary-exit-hook' to
1824 increase the score of each group you read."
1825 (gnus-group-add-score gnus-newsgroup-name))
1826
1827 \f
1828 ;;;
1829 ;;; Gnus summary mode
1830 ;;;
1831
1832 (put 'gnus-summary-mode 'mode-class 'special)
1833
1834 (defvar gnus-article-commands-menu)
1835
1836 ;; Non-orthogonal keys
1837
1838 (gnus-define-keys gnus-summary-mode-map
1839 " " gnus-summary-next-page
1840 [?\S-\ ] gnus-summary-prev-page
1841 "\177" gnus-summary-prev-page
1842 [delete] gnus-summary-prev-page
1843 "\r" gnus-summary-scroll-up
1844 "\M-\r" gnus-summary-scroll-down
1845 "n" gnus-summary-next-unread-article
1846 "p" gnus-summary-prev-unread-article
1847 "N" gnus-summary-next-article
1848 "P" gnus-summary-prev-article
1849 "\M-\C-n" gnus-summary-next-same-subject
1850 "\M-\C-p" gnus-summary-prev-same-subject
1851 "\M-n" gnus-summary-next-unread-subject
1852 "\M-p" gnus-summary-prev-unread-subject
1853 "." gnus-summary-first-unread-article
1854 "," gnus-summary-best-unread-article
1855 "\M-s" gnus-summary-search-article-forward
1856 "\M-r" gnus-summary-search-article-backward
1857 "\M-S" gnus-summary-repeat-search-article-forward
1858 "\M-R" gnus-summary-repeat-search-article-backward
1859 "<" gnus-summary-beginning-of-article
1860 ">" gnus-summary-end-of-article
1861 "j" gnus-summary-goto-article
1862 "^" gnus-summary-refer-parent-article
1863 "\M-^" gnus-summary-refer-article
1864 "u" gnus-summary-tick-article-forward
1865 "!" gnus-summary-tick-article-forward
1866 "U" gnus-summary-tick-article-backward
1867 "d" gnus-summary-mark-as-read-forward
1868 "D" gnus-summary-mark-as-read-backward
1869 "E" gnus-summary-mark-as-expirable
1870 "\M-u" gnus-summary-clear-mark-forward
1871 "\M-U" gnus-summary-clear-mark-backward
1872 "k" gnus-summary-kill-same-subject-and-select
1873 "\C-k" gnus-summary-kill-same-subject
1874 "\M-\C-k" gnus-summary-kill-thread
1875 "\M-\C-l" gnus-summary-lower-thread
1876 "e" gnus-summary-edit-article
1877 "#" gnus-summary-mark-as-processable
1878 "\M-#" gnus-summary-unmark-as-processable
1879 "\M-\C-t" gnus-summary-toggle-threads
1880 "\M-\C-s" gnus-summary-show-thread
1881 "\M-\C-h" gnus-summary-hide-thread
1882 "\M-\C-f" gnus-summary-next-thread
1883 "\M-\C-b" gnus-summary-prev-thread
1884 [(meta down)] gnus-summary-next-thread
1885 [(meta up)] gnus-summary-prev-thread
1886 "\M-\C-u" gnus-summary-up-thread
1887 "\M-\C-d" gnus-summary-down-thread
1888 "&" gnus-summary-execute-command
1889 "c" gnus-summary-catchup-and-exit
1890 "\C-w" gnus-summary-mark-region-as-read
1891 "\C-t" gnus-summary-toggle-truncation
1892 "?" gnus-summary-mark-as-dormant
1893 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1894 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1895 "\C-c\C-s\C-m\C-n" gnus-summary-sort-by-most-recent-number
1896 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1897 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1898 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1899 "\C-c\C-s\C-t" gnus-summary-sort-by-recipient
1900 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1901 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1902 "\C-c\C-s\C-m\C-d" gnus-summary-sort-by-most-recent-date
1903 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1904 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1905 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1906 "=" gnus-summary-expand-window
1907 "\C-x\C-s" gnus-summary-reselect-current-group
1908 "\M-g" gnus-summary-rescan-group
1909 "\C-c\C-r" gnus-summary-caesar-message
1910 "f" gnus-summary-followup
1911 "F" gnus-summary-followup-with-original
1912 "C" gnus-summary-cancel-article
1913 "r" gnus-summary-reply
1914 "R" gnus-summary-reply-with-original
1915 "\C-c\C-f" gnus-summary-mail-forward
1916 "o" gnus-summary-save-article
1917 "\C-o" gnus-summary-save-article-mail
1918 "|" gnus-summary-pipe-output
1919 "\M-k" gnus-summary-edit-local-kill
1920 "\M-K" gnus-summary-edit-global-kill
1921 ;; "V" gnus-version
1922 "\C-c\C-d" gnus-summary-describe-group
1923 "q" gnus-summary-exit
1924 "Q" gnus-summary-exit-no-update
1925 "\C-c\C-i" gnus-info-find-node
1926 [mouse-2] gnus-mouse-pick-article
1927 [follow-link] mouse-face
1928 "m" gnus-summary-mail-other-window
1929 "a" gnus-summary-post-news
1930 "x" gnus-summary-limit-to-unread
1931 "s" gnus-summary-isearch-article
1932 "\t" gnus-summary-widget-forward
1933 [backtab] gnus-summary-widget-backward
1934 "t" gnus-summary-toggle-header
1935 "g" gnus-summary-show-article
1936 "l" gnus-summary-goto-last-article
1937 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1938 "\C-d" gnus-summary-enter-digest-group
1939 "\M-\C-d" gnus-summary-read-document
1940 "\M-\C-e" gnus-summary-edit-parameters
1941 "\M-\C-a" gnus-summary-customize-parameters
1942 "\C-c\C-b" gnus-bug
1943 "*" gnus-cache-enter-article
1944 "\M-*" gnus-cache-remove-article
1945 "\M-&" gnus-summary-universal-argument
1946 "\C-l" gnus-recenter
1947 "I" gnus-summary-increase-score
1948 "L" gnus-summary-lower-score
1949 "\M-i" gnus-symbolic-argument
1950 "h" gnus-summary-select-article-buffer
1951
1952 "b" gnus-article-view-part
1953 "\M-t" gnus-summary-toggle-display-buttonized
1954
1955 "V" gnus-summary-score-map
1956 "X" gnus-uu-extract-map
1957 "S" gnus-summary-send-map)
1958
1959 ;; Sort of orthogonal keymap
1960 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1961 "t" gnus-summary-tick-article-forward
1962 "!" gnus-summary-tick-article-forward
1963 "d" gnus-summary-mark-as-read-forward
1964 "r" gnus-summary-mark-as-read-forward
1965 "c" gnus-summary-clear-mark-forward
1966 " " gnus-summary-clear-mark-forward
1967 "e" gnus-summary-mark-as-expirable
1968 "x" gnus-summary-mark-as-expirable
1969 "?" gnus-summary-mark-as-dormant
1970 "b" gnus-summary-set-bookmark
1971 "B" gnus-summary-remove-bookmark
1972 "#" gnus-summary-mark-as-processable
1973 "\M-#" gnus-summary-unmark-as-processable
1974 "S" gnus-summary-limit-include-expunged
1975 "C" gnus-summary-catchup
1976 "H" gnus-summary-catchup-to-here
1977 "h" gnus-summary-catchup-from-here
1978 "\C-c" gnus-summary-catchup-all
1979 "k" gnus-summary-kill-same-subject-and-select
1980 "K" gnus-summary-kill-same-subject
1981 "P" gnus-uu-mark-map)
1982
1983 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1984 "c" gnus-summary-clear-above
1985 "u" gnus-summary-tick-above
1986 "m" gnus-summary-mark-above
1987 "k" gnus-summary-kill-below)
1988
1989 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1990 "/" gnus-summary-limit-to-subject
1991 "n" gnus-summary-limit-to-articles
1992 "b" gnus-summary-limit-to-bodies
1993 "h" gnus-summary-limit-to-headers
1994 "w" gnus-summary-pop-limit
1995 "s" gnus-summary-limit-to-subject
1996 "a" gnus-summary-limit-to-author
1997 "u" gnus-summary-limit-to-unread
1998 "m" gnus-summary-limit-to-marks
1999 "M" gnus-summary-limit-exclude-marks
2000 "v" gnus-summary-limit-to-score
2001 "*" gnus-summary-limit-include-cached
2002 "D" gnus-summary-limit-include-dormant
2003 "T" gnus-summary-limit-include-thread
2004 "d" gnus-summary-limit-exclude-dormant
2005 "t" gnus-summary-limit-to-age
2006 "." gnus-summary-limit-to-unseen
2007 "x" gnus-summary-limit-to-extra
2008 "p" gnus-summary-limit-to-display-predicate
2009 "E" gnus-summary-limit-include-expunged
2010 "c" gnus-summary-limit-exclude-childless-dormant
2011 "C" gnus-summary-limit-mark-excluded-as-read
2012 "o" gnus-summary-insert-old-articles
2013 "N" gnus-summary-insert-new-articles
2014 "S" gnus-summary-limit-to-singletons
2015 "r" gnus-summary-limit-to-replied
2016 "R" gnus-summary-limit-to-recipient
2017 "A" gnus-summary-limit-to-address)
2018
2019 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
2020 "n" gnus-summary-next-unread-article
2021 "p" gnus-summary-prev-unread-article
2022 "N" gnus-summary-next-article
2023 "P" gnus-summary-prev-article
2024 "\C-n" gnus-summary-next-same-subject
2025 "\C-p" gnus-summary-prev-same-subject
2026 "\M-n" gnus-summary-next-unread-subject
2027 "\M-p" gnus-summary-prev-unread-subject
2028 "f" gnus-summary-first-unread-article
2029 "b" gnus-summary-best-unread-article
2030 "j" gnus-summary-goto-article
2031 "g" gnus-summary-goto-subject
2032 "l" gnus-summary-goto-last-article
2033 "o" gnus-summary-pop-article)
2034
2035 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
2036 "k" gnus-summary-kill-thread
2037 "E" gnus-summary-expire-thread
2038 "l" gnus-summary-lower-thread
2039 "i" gnus-summary-raise-thread
2040 "T" gnus-summary-toggle-threads
2041 "t" gnus-summary-rethread-current
2042 "^" gnus-summary-reparent-thread
2043 "\M-^" gnus-summary-reparent-children
2044 "s" gnus-summary-show-thread
2045 "S" gnus-summary-show-all-threads
2046 "h" gnus-summary-hide-thread
2047 "H" gnus-summary-hide-all-threads
2048 "n" gnus-summary-next-thread
2049 "p" gnus-summary-prev-thread
2050 "u" gnus-summary-up-thread
2051 "o" gnus-summary-top-thread
2052 "d" gnus-summary-down-thread
2053 "#" gnus-uu-mark-thread
2054 "\M-#" gnus-uu-unmark-thread)
2055
2056 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
2057 "g" gnus-summary-prepare
2058 "c" gnus-summary-insert-cached-articles
2059 "d" gnus-summary-insert-dormant-articles
2060 "t" gnus-summary-insert-ticked-articles)
2061
2062 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
2063 "c" gnus-summary-catchup-and-exit
2064 "C" gnus-summary-catchup-all-and-exit
2065 "E" gnus-summary-exit-no-update
2066 "Q" gnus-summary-exit
2067 "Z" gnus-summary-exit
2068 "n" gnus-summary-catchup-and-goto-next-group
2069 "p" gnus-summary-catchup-and-goto-prev-group
2070 "R" gnus-summary-reselect-current-group
2071 "G" gnus-summary-rescan-group
2072 "N" gnus-summary-next-group
2073 "s" gnus-summary-save-newsrc
2074 "P" gnus-summary-prev-group)
2075
2076 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
2077 " " gnus-summary-next-page
2078 "n" gnus-summary-next-page
2079 [?\S-\ ] gnus-summary-prev-page
2080 "\177" gnus-summary-prev-page
2081 [delete] gnus-summary-prev-page
2082 "p" gnus-summary-prev-page
2083 "\r" gnus-summary-scroll-up
2084 "\M-\r" gnus-summary-scroll-down
2085 "<" gnus-summary-beginning-of-article
2086 ">" gnus-summary-end-of-article
2087 "b" gnus-summary-beginning-of-article
2088 "e" gnus-summary-end-of-article
2089 "^" gnus-summary-refer-parent-article
2090 "r" gnus-summary-refer-parent-article
2091 "C" gnus-summary-show-complete-article
2092 "D" gnus-summary-enter-digest-group
2093 "R" gnus-summary-refer-references
2094 "T" gnus-summary-refer-thread
2095 "W" gnus-warp-to-article
2096 "g" gnus-summary-show-article
2097 "s" gnus-summary-isearch-article
2098 "\t" gnus-summary-widget-forward
2099 [backtab] gnus-summary-widget-backward
2100 "P" gnus-summary-print-article
2101 "S" gnus-sticky-article
2102 "M" gnus-mailing-list-insinuate
2103 "t" gnus-article-babel)
2104
2105 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
2106 "b" gnus-article-add-buttons
2107 "B" gnus-article-add-buttons-to-head
2108 "o" gnus-article-treat-overstrike
2109 "e" gnus-article-emphasize
2110 "w" gnus-article-fill-cited-article
2111 "Q" gnus-article-fill-long-lines
2112 "L" gnus-article-toggle-truncate-lines
2113 "C" gnus-article-capitalize-sentences
2114 "c" gnus-article-remove-cr
2115 "q" gnus-article-de-quoted-unreadable
2116 "6" gnus-article-de-base64-unreadable
2117 "Z" gnus-article-decode-HZ
2118 "A" gnus-article-treat-ansi-sequences
2119 "h" gnus-article-wash-html
2120 "u" gnus-article-unsplit-urls
2121 "s" gnus-summary-force-verify-and-decrypt
2122 "f" gnus-article-display-x-face
2123 "l" gnus-summary-stop-page-breaking
2124 "r" gnus-summary-caesar-message
2125 "m" gnus-summary-morse-message
2126 "t" gnus-summary-toggle-header
2127 "g" gnus-treat-smiley
2128 "v" gnus-summary-verbose-headers
2129 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
2130 "p" gnus-article-verify-x-pgp-sig
2131 "d" gnus-article-treat-dumbquotes
2132 "U" gnus-article-treat-non-ascii
2133 "i" gnus-summary-idna-message)
2134
2135 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
2136 ;; mnemonic: deuglif*Y*
2137 "u" gnus-article-outlook-unwrap-lines
2138 "a" gnus-article-outlook-repair-attribution
2139 "c" gnus-article-outlook-rearrange-citation
2140 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
2141
2142 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
2143 "a" gnus-article-hide
2144 "h" gnus-article-hide-headers
2145 "b" gnus-article-hide-boring-headers
2146 "s" gnus-article-hide-signature
2147 "c" gnus-article-hide-citation
2148 "C" gnus-article-hide-citation-in-followups
2149 "l" gnus-article-hide-list-identifiers
2150 "B" gnus-article-strip-banner
2151 "P" gnus-article-hide-pem
2152 "\C-c" gnus-article-hide-citation-maybe)
2153
2154 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
2155 "a" gnus-article-highlight
2156 "h" gnus-article-highlight-headers
2157 "c" gnus-article-highlight-citation
2158 "s" gnus-article-highlight-signature)
2159
2160 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
2161 "f" gnus-article-treat-fold-headers
2162 "u" gnus-article-treat-unfold-headers
2163 "n" gnus-article-treat-fold-newsgroups)
2164
2165 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
2166 "x" gnus-article-display-x-face
2167 "d" gnus-article-display-face
2168 "s" gnus-treat-smiley
2169 "D" gnus-article-remove-images
2170 "W" gnus-article-show-images
2171 "f" gnus-treat-from-picon
2172 "m" gnus-treat-mail-picon
2173 "n" gnus-treat-newsgroups-picon
2174 "g" gnus-treat-from-gravatar
2175 "h" gnus-treat-mail-gravatar)
2176
2177 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
2178 "w" gnus-article-decode-mime-words
2179 "c" gnus-article-decode-charset
2180 "h" gnus-mime-buttonize-attachments-in-header
2181 "v" gnus-mime-view-all-parts
2182 "b" gnus-article-view-part)
2183
2184 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
2185 "z" gnus-article-date-ut
2186 "u" gnus-article-date-ut
2187 "l" gnus-article-date-local
2188 "p" gnus-article-date-english
2189 "e" gnus-article-date-lapsed
2190 "o" gnus-article-date-original
2191 "i" gnus-article-date-iso8601
2192 "s" gnus-article-date-user)
2193
2194 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
2195 "t" gnus-article-remove-trailing-blank-lines
2196 "l" gnus-article-strip-leading-blank-lines
2197 "m" gnus-article-strip-multiple-blank-lines
2198 "a" gnus-article-strip-blank-lines
2199 "A" gnus-article-strip-all-blank-lines
2200 "s" gnus-article-strip-leading-space
2201 "e" gnus-article-strip-trailing-space
2202 "w" gnus-article-remove-leading-whitespace)
2203
2204 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
2205 "v" gnus-version
2206 "d" gnus-summary-describe-group
2207 "h" gnus-summary-describe-briefly
2208 "i" gnus-info-find-node)
2209
2210 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
2211 "e" gnus-summary-expire-articles
2212 "\M-\C-e" gnus-summary-expire-articles-now
2213 "\177" gnus-summary-delete-article
2214 [delete] gnus-summary-delete-article
2215 [backspace] gnus-summary-delete-article
2216 "m" gnus-summary-move-article
2217 "r" gnus-summary-respool-article
2218 "w" gnus-summary-edit-article
2219 "c" gnus-summary-copy-article
2220 "B" gnus-summary-crosspost-article
2221 "q" gnus-summary-respool-query
2222 "t" gnus-summary-respool-trace
2223 "i" gnus-summary-import-article
2224 "I" gnus-summary-create-article
2225 "p" gnus-summary-article-posted-p)
2226
2227 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
2228 "o" gnus-summary-save-article
2229 "m" gnus-summary-save-article-mail
2230 "F" gnus-summary-write-article-file
2231 "r" gnus-summary-save-article-rmail
2232 "f" gnus-summary-save-article-file
2233 "b" gnus-summary-save-article-body-file
2234 "B" gnus-summary-write-article-body-file
2235 "h" gnus-summary-save-article-folder
2236 "v" gnus-summary-save-article-vm
2237 "p" gnus-summary-pipe-output
2238 "P" gnus-summary-muttprint)
2239
2240 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
2241 "b" gnus-summary-display-buttonized
2242 "m" gnus-summary-repair-multipart
2243 "v" gnus-article-view-part
2244 "o" gnus-article-save-part
2245 "O" gnus-article-save-part-and-strip
2246 "r" gnus-article-replace-part
2247 "d" gnus-article-delete-part
2248 "t" gnus-article-view-part-as-type
2249 "j" gnus-article-jump-to-part
2250 "c" gnus-article-copy-part
2251 "C" gnus-article-view-part-as-charset
2252 "e" gnus-article-view-part-externally
2253 "H" gnus-article-browse-html-article
2254 "E" gnus-article-encrypt-body
2255 "i" gnus-article-inline-part
2256 "|" gnus-article-pipe-part)
2257
2258 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2259 "p" gnus-summary-mark-as-processable
2260 "u" gnus-summary-unmark-as-processable
2261 "U" gnus-summary-unmark-all-processable
2262 "v" gnus-uu-mark-over
2263 "s" gnus-uu-mark-series
2264 "r" gnus-uu-mark-region
2265 "g" gnus-uu-unmark-region
2266 "R" gnus-uu-mark-by-regexp
2267 "G" gnus-uu-unmark-by-regexp
2268 "t" gnus-uu-mark-thread
2269 "T" gnus-uu-unmark-thread
2270 "a" gnus-uu-mark-all
2271 "b" gnus-uu-mark-buffer
2272 "S" gnus-uu-mark-sparse
2273 "k" gnus-summary-kill-process-mark
2274 "y" gnus-summary-yank-process-mark
2275 "w" gnus-summary-save-process-mark
2276 "i" gnus-uu-invert-processable)
2277
2278 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2279 ;;"x" gnus-uu-extract-any
2280 "m" gnus-summary-save-parts
2281 "u" gnus-uu-decode-uu
2282 "U" gnus-uu-decode-uu-and-save
2283 "s" gnus-uu-decode-unshar
2284 "S" gnus-uu-decode-unshar-and-save
2285 "o" gnus-uu-decode-save
2286 "O" gnus-uu-decode-save
2287 "b" gnus-uu-decode-binhex
2288 "B" gnus-uu-decode-binhex
2289 "Y" gnus-uu-decode-yenc
2290 "p" gnus-uu-decode-postscript
2291 "P" gnus-uu-decode-postscript-and-save)
2292
2293 (gnus-define-keys
2294 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2295 "u" gnus-uu-decode-uu-view
2296 "U" gnus-uu-decode-uu-and-save-view
2297 "s" gnus-uu-decode-unshar-view
2298 "S" gnus-uu-decode-unshar-and-save-view
2299 "o" gnus-uu-decode-save-view
2300 "O" gnus-uu-decode-save-view
2301 "b" gnus-uu-decode-binhex-view
2302 "B" gnus-uu-decode-binhex-view
2303 "p" gnus-uu-decode-postscript-view
2304 "P" gnus-uu-decode-postscript-and-save-view)
2305
2306 (defvar gnus-article-post-menu nil)
2307
2308 (defconst gnus-summary-menu-maxlen 20)
2309
2310 (defun gnus-summary-menu-split (menu)
2311 ;; If we have lots of elements, divide them into groups of 20
2312 ;; and make a pane (or submenu) for each one.
2313 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2314 (let ((menu menu) sublists next
2315 (i 1))
2316 (while menu
2317 ;; Pull off the next gnus-summary-menu-maxlen elements
2318 ;; and make them the next element of sublist.
2319 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2320 (if next
2321 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2322 nil))
2323 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2324 (aref (car (last menu)) 0)) menu)
2325 sublists))
2326 (setq i (1+ i))
2327 (setq menu next))
2328 (nreverse sublists))
2329 ;; Few elements--put them all in one pane.
2330 menu))
2331
2332 (defun gnus-summary-make-menu-bar ()
2333 (gnus-turn-off-edit-menu 'summary)
2334
2335 (unless (boundp 'gnus-summary-misc-menu)
2336
2337 (easy-menu-define
2338 gnus-summary-kill-menu gnus-summary-mode-map ""
2339 (cons
2340 "Score"
2341 (nconc
2342 (list
2343 ["Customize" gnus-score-customize t])
2344 (gnus-make-score-map 'increase)
2345 (gnus-make-score-map 'lower)
2346 '(("Mark"
2347 ["Kill below" gnus-summary-kill-below t]
2348 ["Mark above" gnus-summary-mark-above t]
2349 ["Tick above" gnus-summary-tick-above t]
2350 ["Clear above" gnus-summary-clear-above t])
2351 ["Current article score" gnus-summary-current-score t]
2352 ["Current thread score" (gnus-summary-current-score 'total) t]
2353 ["Set score" gnus-summary-set-score t]
2354 ["Switch current score file..." gnus-score-change-score-file t]
2355 ["Set mark below..." gnus-score-set-mark-below t]
2356 ["Set expunge below..." gnus-score-set-expunge-below t]
2357 ["Edit current score file" gnus-score-edit-current-scores t]
2358 ["Edit score file..." gnus-score-edit-file t]
2359 ["Trace score" gnus-score-find-trace t]
2360 ["Find words" gnus-score-find-favourite-words t]
2361 ["Rescore buffer" gnus-summary-rescore t]
2362 ["Increase score..." gnus-summary-increase-score t]
2363 ["Lower score..." gnus-summary-lower-score t]))))
2364
2365 ;; Define both the Article menu in the summary buffer and the
2366 ;; equivalent Commands menu in the article buffer here for
2367 ;; consistency.
2368 (let ((innards
2369 `(("Hide"
2370 ["All" gnus-article-hide t]
2371 ["Headers" gnus-article-hide-headers t]
2372 ["Signature" gnus-article-hide-signature t]
2373 ["Citation" gnus-article-hide-citation t]
2374 ["List identifiers" gnus-article-hide-list-identifiers t]
2375 ["Banner" gnus-article-strip-banner t]
2376 ["Boring headers" gnus-article-hide-boring-headers t])
2377 ("Highlight"
2378 ["All" gnus-article-highlight t]
2379 ["Headers" gnus-article-highlight-headers t]
2380 ["Signature" gnus-article-highlight-signature t]
2381 ["Citation" gnus-article-highlight-citation t])
2382 ("MIME"
2383 ["Words" gnus-article-decode-mime-words t]
2384 ["Charset" gnus-article-decode-charset t]
2385 ["QP" gnus-article-de-quoted-unreadable t]
2386 ["Base64" gnus-article-de-base64-unreadable t]
2387 ["View MIME buttons" gnus-summary-display-buttonized t]
2388 ["View MIME buttons in header"
2389 gnus-mime-buttonize-attachments-in-header t]
2390 ["View all" gnus-mime-view-all-parts t]
2391 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2392 ["Encrypt body" gnus-article-encrypt-body
2393 :active (not (gnus-group-read-only-p))
2394 :help "Encrypt the message body on disk"]
2395 ["Extract all parts..." gnus-summary-save-parts t]
2396 ("Multipart"
2397 ["Repair multipart" gnus-summary-repair-multipart t]
2398 ["Pipe part..." gnus-article-pipe-part t]
2399 ["Inline part" gnus-article-inline-part t]
2400 ["View part as type..." gnus-article-view-part-as-type t]
2401 ["Encrypt body" gnus-article-encrypt-body
2402 :active (not (gnus-group-read-only-p))
2403 :help "Encrypt the message body on disk"]
2404 ["View part externally" gnus-article-view-part-externally t]
2405 ["View HTML parts in browser" gnus-article-browse-html-article t]
2406 ["View part with charset..." gnus-article-view-part-as-charset t]
2407 ["Copy part" gnus-article-copy-part t]
2408 ["Save part..." gnus-article-save-part t]
2409 ["View part" gnus-article-view-part t]))
2410 ("Date"
2411 ["Local" gnus-article-date-local t]
2412 ["ISO8601" gnus-article-date-iso8601 t]
2413 ["UT" gnus-article-date-ut t]
2414 ["Original" gnus-article-date-original t]
2415 ["Lapsed" gnus-article-date-lapsed t]
2416 ["User-defined" gnus-article-date-user t])
2417 ("Display"
2418 ["Display HTML images" gnus-article-show-images t]
2419 ["Remove images" gnus-article-remove-images t]
2420 ["Toggle smiley" gnus-treat-smiley t]
2421 ["Show X-Face" gnus-article-display-x-face t]
2422 ["Show picons in From" gnus-treat-from-picon t]
2423 ["Show picons in mail headers" gnus-treat-mail-picon t]
2424 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2425 ["Show Gravatars in From" gnus-treat-from-gravatar t]
2426 ["Show Gravatars in mail headers" gnus-treat-mail-gravatar t]
2427 ("View as different encoding"
2428 ,@(gnus-summary-menu-split
2429 (mapcar
2430 (lambda (cs)
2431 ;; Since easymenu under Emacs doesn't allow
2432 ;; lambda forms for menu commands, we should
2433 ;; provide intern'ed function symbols.
2434 (let ((command (intern (format "\
2435 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2436 (fset command
2437 `(lambda ()
2438 (interactive)
2439 (let ((gnus-summary-show-article-charset-alist
2440 '((1 . ,cs))))
2441 (gnus-summary-show-article 1))))
2442 `[,(symbol-name cs) ,command t]))
2443 (sort (coding-system-list) 'string<)))))
2444 ("Washing"
2445 ("Remove Blanks"
2446 ["Leading" gnus-article-strip-leading-blank-lines t]
2447 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2448 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2449 ["All of the above" gnus-article-strip-blank-lines t]
2450 ["All" gnus-article-strip-all-blank-lines t]
2451 ["Leading space" gnus-article-strip-leading-space t]
2452 ["Trailing space" gnus-article-strip-trailing-space t]
2453 ["Leading space in headers"
2454 gnus-article-remove-leading-whitespace t])
2455 ["Overstrike" gnus-article-treat-overstrike t]
2456 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2457 ["Non-ASCII" gnus-article-treat-non-ascii t]
2458 ["Emphasis" gnus-article-emphasize t]
2459 ["Word wrap" gnus-article-fill-cited-article t]
2460 ["Fill long lines" gnus-article-fill-long-lines t]
2461 ["Toggle truncate long lines" gnus-article-toggle-truncate-lines t]
2462 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2463 ["Remove CR" gnus-article-remove-cr t]
2464 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2465 ["Base64" gnus-article-de-base64-unreadable t]
2466 ["Rot 13" gnus-summary-caesar-message
2467 :help "\"Caesar rotate\" article by 13"]
2468 ["De-IDNA" gnus-summary-idna-message t]
2469 ["Morse decode" gnus-summary-morse-message t]
2470 ["Unix pipe..." gnus-summary-pipe-message t]
2471 ["Add buttons" gnus-article-add-buttons t]
2472 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2473 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2474 ["Verbose header" gnus-summary-verbose-headers t]
2475 ["Toggle header" gnus-summary-toggle-header t]
2476 ["Unfold headers" gnus-article-treat-unfold-headers t]
2477 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2478 ["Html" gnus-article-wash-html t]
2479 ["Unsplit URLs" gnus-article-unsplit-urls t]
2480 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2481 ["Decode HZ" gnus-article-decode-HZ t]
2482 ["ANSI sequences" gnus-article-treat-ansi-sequences t]
2483 ("(Outlook) Deuglify"
2484 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2485 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2486 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2487 ["Full (Outlook) deuglify"
2488 gnus-article-outlook-deuglify-article t])
2489 )
2490 ("Output"
2491 ["Save in default format..." gnus-summary-save-article
2492 :help "Save article using default method"]
2493 ["Save in file..." gnus-summary-save-article-file
2494 :help "Save article in file"]
2495 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2496 ["Save in MH folder..." gnus-summary-save-article-folder t]
2497 ["Save in VM folder..." gnus-summary-save-article-vm t]
2498 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2499 ["Save body in file..." gnus-summary-save-article-body-file t]
2500 ["Pipe through a filter..." gnus-summary-pipe-output t]
2501 ["Print with Muttprint..." gnus-summary-muttprint t]
2502 ["Print" gnus-summary-print-article
2503 :help "Generate and print a PostScript image"])
2504 ("Copy, move,... (Backend)"
2505 :help "Copying, moving, expiring articles..."
2506 ["Respool article..." gnus-summary-respool-article t]
2507 ["Move article..." gnus-summary-move-article
2508 (gnus-check-backend-function
2509 'request-move-article gnus-newsgroup-name)]
2510 ["Copy article..." gnus-summary-copy-article t]
2511 ["Crosspost article..." gnus-summary-crosspost-article
2512 (gnus-check-backend-function
2513 'request-replace-article gnus-newsgroup-name)]
2514 ["Import file..." gnus-summary-import-article
2515 (gnus-check-backend-function
2516 'request-accept-article gnus-newsgroup-name)]
2517 ["Create article..." gnus-summary-create-article
2518 (gnus-check-backend-function
2519 'request-accept-article gnus-newsgroup-name)]
2520 ["Check if posted" gnus-summary-article-posted-p t]
2521 ["Edit article" gnus-summary-edit-article
2522 (not (gnus-group-read-only-p))]
2523 ["Delete article" gnus-summary-delete-article
2524 (gnus-check-backend-function
2525 'request-expire-articles gnus-newsgroup-name)]
2526 ["Query respool" gnus-summary-respool-query t]
2527 ["Trace respool" gnus-summary-respool-trace t]
2528 ["Delete expirable articles" gnus-summary-expire-articles-now
2529 (gnus-check-backend-function
2530 'request-expire-articles gnus-newsgroup-name)])
2531 ("Extract"
2532 ["Uudecode" gnus-uu-decode-uu :help "Decode uuencoded article(s)"]
2533 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2534 ["Unshar" gnus-uu-decode-unshar t]
2535 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2536 ["Save" gnus-uu-decode-save t]
2537 ["Binhex" gnus-uu-decode-binhex t]
2538 ["PostScript" gnus-uu-decode-postscript t]
2539 ["All MIME parts" gnus-summary-save-parts t])
2540 ("Cache"
2541 ["Enter article" gnus-cache-enter-article t]
2542 ["Remove article" gnus-cache-remove-article t])
2543 ["Translate" gnus-article-babel t]
2544 ["Select article buffer" gnus-summary-select-article-buffer t]
2545 ["Make article buffer sticky" gnus-sticky-article t]
2546 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2547 ["Isearch article..." gnus-summary-isearch-article t]
2548 ["Beginning of the article" gnus-summary-beginning-of-article t]
2549 ["End of the article" gnus-summary-end-of-article t]
2550 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2551 ["Fetch referenced articles" gnus-summary-refer-references t]
2552 ["Fetch current thread" gnus-summary-refer-thread t]
2553 ["Fetch article with id..." gnus-summary-refer-article t]
2554 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2555 ["Redisplay" gnus-summary-show-article t]
2556 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2557 (easy-menu-define
2558 gnus-summary-article-menu gnus-summary-mode-map ""
2559 (cons "Article" innards))
2560
2561 (if (not (keymapp gnus-summary-article-menu))
2562 (easy-menu-define
2563 gnus-article-commands-menu gnus-article-mode-map ""
2564 (cons "Commands" innards))
2565 ;; in Emacs, don't share menu.
2566 (setq gnus-article-commands-menu
2567 (copy-keymap gnus-summary-article-menu))
2568 (define-key gnus-article-mode-map [menu-bar commands]
2569 (cons "Commands" gnus-article-commands-menu))))
2570
2571 (easy-menu-define
2572 gnus-summary-thread-menu gnus-summary-mode-map ""
2573 '("Threads"
2574 ["Find all messages in thread" gnus-summary-refer-thread t]
2575 ["Toggle threading" gnus-summary-toggle-threads t]
2576 ["Hide threads" gnus-summary-hide-all-threads t]
2577 ["Show threads" gnus-summary-show-all-threads t]
2578 ["Hide thread" gnus-summary-hide-thread t]
2579 ["Show thread" gnus-summary-show-thread t]
2580 ["Go to next thread" gnus-summary-next-thread t]
2581 ["Go to previous thread" gnus-summary-prev-thread t]
2582 ["Go down thread" gnus-summary-down-thread t]
2583 ["Go up thread" gnus-summary-up-thread t]
2584 ["Top of thread" gnus-summary-top-thread t]
2585 ["Mark thread as read" gnus-summary-kill-thread t]
2586 ["Mark thread as expired" gnus-summary-expire-thread t]
2587 ["Lower thread score" gnus-summary-lower-thread t]
2588 ["Raise thread score" gnus-summary-raise-thread t]
2589 ["Rethread current" gnus-summary-rethread-current t]))
2590
2591 (easy-menu-define
2592 gnus-summary-post-menu gnus-summary-mode-map ""
2593 `("Post"
2594 ["Send a message (mail or news)" gnus-summary-post-news
2595 :help "Compose a new message (mail or news)"]
2596 ["Followup" gnus-summary-followup
2597 :help "Post followup to this article"]
2598 ["Followup and yank" gnus-summary-followup-with-original
2599 :help "Post followup to this article, quoting its contents"]
2600 ["Supersede article" gnus-summary-supersede-article t]
2601 ["Cancel article" gnus-summary-cancel-article
2602 :help "Cancel an article you posted"]
2603 ["Reply" gnus-summary-reply t]
2604 ["Reply and yank" gnus-summary-reply-with-original t]
2605 ["Wide reply" gnus-summary-wide-reply t]
2606 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2607 :help "Mail a reply, quoting this article"]
2608 ["Very wide reply" gnus-summary-very-wide-reply t]
2609 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2610 :help "Mail a very wide reply, quoting this article"]
2611 ["Mail forward" gnus-summary-mail-forward t]
2612 ["Post forward" gnus-summary-post-forward t]
2613 ["Digest and mail" gnus-uu-digest-mail-forward t]
2614 ["Digest and post" gnus-uu-digest-post-forward t]
2615 ["Resend message" gnus-summary-resend-message t]
2616 ["Resend message edit" gnus-summary-resend-message-edit t]
2617 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2618 ["Send a mail" gnus-summary-mail-other-window t]
2619 ["Create a local message" gnus-summary-news-other-window t]
2620 ["Uuencode and post" gnus-uu-post-news
2621 :help "Post a uuencoded article"]
2622 ["Followup via news" gnus-summary-followup-to-mail t]
2623 ["Followup via news and yank"
2624 gnus-summary-followup-to-mail-with-original t]
2625 ["Strip signature on reply"
2626 (lambda ()
2627 (interactive)
2628 (setq message-cite-function
2629 (if (eq message-cite-function
2630 'message-cite-original-without-signature)
2631 'message-cite-original
2632 'message-cite-original-without-signature)))
2633 :visible (memq message-cite-function
2634 '(message-cite-original-without-signature
2635 message-cite-original))
2636 :style toggle
2637 :selected (eq message-cite-function
2638 'message-cite-original-without-signature)
2639 :help "Strip signature from cited article when replying."]))
2640
2641 (cond
2642 ((not (keymapp gnus-summary-post-menu))
2643 (setq gnus-article-post-menu gnus-summary-post-menu))
2644 ((not gnus-article-post-menu)
2645 ;; Don't share post menu.
2646 (setq gnus-article-post-menu
2647 (copy-keymap gnus-summary-post-menu))))
2648 (define-key gnus-article-mode-map [menu-bar post]
2649 (cons "Post" gnus-article-post-menu))
2650
2651 (easy-menu-define
2652 gnus-summary-misc-menu gnus-summary-mode-map ""
2653 `("Gnus"
2654 ("Mark Read"
2655 ["Mark as read" gnus-summary-mark-as-read-forward t]
2656 ["Mark same subject and select"
2657 gnus-summary-kill-same-subject-and-select t]
2658 ["Mark same subject" gnus-summary-kill-same-subject t]
2659 ["Catchup" gnus-summary-catchup
2660 :help "Mark unread articles in this group as read"]
2661 ["Catchup all" gnus-summary-catchup-all t]
2662 ["Catchup to here" gnus-summary-catchup-to-here t]
2663 ["Catchup from here" gnus-summary-catchup-from-here t]
2664 ["Catchup region" gnus-summary-mark-region-as-read mark-active]
2665 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2666 ("Mark Various"
2667 ["Tick" gnus-summary-tick-article-forward t]
2668 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2669 ["Remove marks" gnus-summary-clear-mark-forward t]
2670 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2671 ["Set bookmark" gnus-summary-set-bookmark t]
2672 ["Remove bookmark" gnus-summary-remove-bookmark t])
2673 ("Limit to"
2674 ["Marks..." gnus-summary-limit-to-marks t]
2675 ["Subject..." gnus-summary-limit-to-subject t]
2676 ["Author..." gnus-summary-limit-to-author t]
2677 ["Recipient..." gnus-summary-limit-to-recipient t]
2678 ["Address..." gnus-summary-limit-to-address t]
2679 ["Age..." gnus-summary-limit-to-age t]
2680 ["Extra..." gnus-summary-limit-to-extra t]
2681 ["Score..." gnus-summary-limit-to-score t]
2682 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2683 ["Unread" gnus-summary-limit-to-unread t]
2684 ["Unseen" gnus-summary-limit-to-unseen t]
2685 ["Singletons" gnus-summary-limit-to-singletons t]
2686 ["Replied" gnus-summary-limit-to-replied t]
2687 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2688 ["Next or process marked articles" gnus-summary-limit-to-articles t]
2689 ["Pop limit" gnus-summary-pop-limit t]
2690 ["Show dormant" gnus-summary-limit-include-dormant t]
2691 ["Hide childless dormant"
2692 gnus-summary-limit-exclude-childless-dormant t]
2693 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2694 ["Hide marked" gnus-summary-limit-exclude-marks t]
2695 ["Show expunged" gnus-summary-limit-include-expunged t])
2696 ("Process Mark"
2697 ["Set mark" gnus-summary-mark-as-processable t]
2698 ["Remove mark" gnus-summary-unmark-as-processable t]
2699 ["Remove all marks" gnus-summary-unmark-all-processable t]
2700 ["Invert marks" gnus-uu-invert-processable t]
2701 ["Mark above" gnus-uu-mark-over t]
2702 ["Mark series" gnus-uu-mark-series t]
2703 ["Mark region" gnus-uu-mark-region mark-active]
2704 ["Unmark region" gnus-uu-unmark-region mark-active]
2705 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2706 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2707 ["Mark all" gnus-uu-mark-all t]
2708 ["Mark buffer" gnus-uu-mark-buffer t]
2709 ["Mark sparse" gnus-uu-mark-sparse t]
2710 ["Mark thread" gnus-uu-mark-thread t]
2711 ["Unmark thread" gnus-uu-unmark-thread t]
2712 ("Process Mark Sets"
2713 ["Kill" gnus-summary-kill-process-mark t]
2714 ["Yank" gnus-summary-yank-process-mark
2715 gnus-newsgroup-process-stack]
2716 ["Save" gnus-summary-save-process-mark t]
2717 ["Run command on marked..." gnus-summary-universal-argument t]))
2718 ("Registry Marks")
2719 ("Scroll article"
2720 ["Page forward" gnus-summary-next-page
2721 :help "Show next page of article"]
2722 ["Page backward" gnus-summary-prev-page
2723 :help "Show previous page of article"]
2724 ["Line forward" gnus-summary-scroll-up t])
2725 ("Move"
2726 ["Next unread article" gnus-summary-next-unread-article t]
2727 ["Previous unread article" gnus-summary-prev-unread-article t]
2728 ["Next article" gnus-summary-next-article t]
2729 ["Previous article" gnus-summary-prev-article t]
2730 ["Next unread subject" gnus-summary-next-unread-subject t]
2731 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2732 ["Next article same subject" gnus-summary-next-same-subject t]
2733 ["Previous article same subject" gnus-summary-prev-same-subject t]
2734 ["First unread article" gnus-summary-first-unread-article t]
2735 ["Best unread article" gnus-summary-best-unread-article t]
2736 ["Go to subject number..." gnus-summary-goto-subject t]
2737 ["Go to article number..." gnus-summary-goto-article t]
2738 ["Go to the last article" gnus-summary-goto-last-article t]
2739 ["Pop article off history" gnus-summary-pop-article t])
2740 ("Sort"
2741 ["Sort by number" gnus-summary-sort-by-number t]
2742 ["Sort by most recent number" gnus-summary-sort-by-most-recent-number t]
2743 ["Sort by author" gnus-summary-sort-by-author t]
2744 ["Sort by recipient" gnus-summary-sort-by-recipient t]
2745 ["Sort by subject" gnus-summary-sort-by-subject t]
2746 ["Sort by date" gnus-summary-sort-by-date t]
2747 ["Sort by most recent date" gnus-summary-sort-by-most-recent-date t]
2748 ["Sort by score" gnus-summary-sort-by-score t]
2749 ["Sort by lines" gnus-summary-sort-by-lines t]
2750 ["Sort by characters" gnus-summary-sort-by-chars t]
2751 ["Randomize" gnus-summary-sort-by-random t]
2752 ["Original sort" gnus-summary-sort-by-original t])
2753 ("Help"
2754 ["Describe group" gnus-summary-describe-group t]
2755 ["Read manual" gnus-info-find-node t])
2756 ("Modes"
2757 ["Pick and read" gnus-pick-mode t]
2758 ["Binary" gnus-binary-mode t])
2759 ("Regeneration"
2760 ["Regenerate" gnus-summary-prepare t]
2761 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2762 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2763 ["Insert ticked articles" gnus-summary-insert-ticked-articles t]
2764 ["Toggle threading" gnus-summary-toggle-threads t])
2765 ["See old articles" gnus-summary-insert-old-articles t]
2766 ["See new articles" gnus-summary-insert-new-articles t]
2767 ["Filter articles..." gnus-summary-execute-command t]
2768 ["Run command on articles..." gnus-summary-universal-argument t]
2769 ["Search articles forward..." gnus-summary-search-article-forward t]
2770 ["Search articles backward..." gnus-summary-search-article-backward t]
2771 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2772 ["Expand window" gnus-summary-expand-window t]
2773 ["Expire expirable articles" gnus-summary-expire-articles
2774 (gnus-check-backend-function
2775 'request-expire-articles gnus-newsgroup-name)]
2776 ["Edit local kill file" gnus-summary-edit-local-kill t]
2777 ["Edit main kill file" gnus-summary-edit-global-kill t]
2778 ["Edit group parameters" gnus-summary-edit-parameters t]
2779 ["Customize group parameters" gnus-summary-customize-parameters t]
2780 ["Send a bug report" gnus-bug t]
2781 ("Exit"
2782 ["Catchup and exit" gnus-summary-catchup-and-exit
2783 :help "Mark unread articles in this group as read, then exit"]
2784 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2785 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2786 ["Catchup and goto prev" gnus-summary-catchup-and-goto-prev-group t]
2787 ["Exit group" gnus-summary-exit
2788 :help "Exit current group, return to group selection mode"]
2789 ["Exit group without updating" gnus-summary-exit-no-update t]
2790 ["Exit and goto next group" gnus-summary-next-group t]
2791 ["Exit and goto prev group" gnus-summary-prev-group t]
2792 ["Reselect group" gnus-summary-reselect-current-group t]
2793 ["Rescan group" gnus-summary-rescan-group t]
2794 ["Update dribble" gnus-summary-save-newsrc t])))
2795
2796 (gnus-run-hooks 'gnus-summary-menu-hook)))
2797
2798 (defvar gnus-summary-tool-bar-map nil)
2799
2800 ;; Note: The :set function in the `gnus-summary-tool-bar*' variables will only
2801 ;; affect _new_ message buffers. We might add a function that walks thru all
2802 ;; summary-mode buffers and force the update.
2803 (defun gnus-summary-tool-bar-update (&optional symbol value)
2804 "Update summary mode toolbar.
2805 Setter function for custom variables."
2806 (setq-default gnus-summary-tool-bar-map nil)
2807 (when symbol
2808 ;; When used as ":set" function:
2809 (set-default symbol value))
2810 (when (gnus-buffer-live-p gnus-summary-buffer)
2811 (with-current-buffer gnus-summary-buffer
2812 (gnus-summary-make-tool-bar))))
2813
2814 (defcustom gnus-summary-tool-bar (if (eq gmm-tool-bar-style 'gnome)
2815 'gnus-summary-tool-bar-gnome
2816 'gnus-summary-tool-bar-retro)
2817 "Specifies the Gnus summary tool bar.
2818
2819 It can be either a list or a symbol referring to a list. See
2820 `gmm-tool-bar-from-list' for the format of the list. The
2821 default key map is `gnus-summary-mode-map'.
2822
2823 Pre-defined symbols include `gnus-summary-tool-bar-gnome' and
2824 `gnus-summary-tool-bar-retro'."
2825 :type '(choice (const :tag "GNOME style" gnus-summary-tool-bar-gnome)
2826 (const :tag "Retro look" gnus-summary-tool-bar-retro)
2827 (repeat :tag "User defined list" gmm-tool-bar-item)
2828 (symbol))
2829 :version "23.1" ;; No Gnus
2830 :initialize 'custom-initialize-default
2831 :set 'gnus-summary-tool-bar-update
2832 :group 'gnus-summary)
2833
2834 (defcustom gnus-summary-tool-bar-gnome
2835 '((gnus-summary-post-news "mail/compose" nil)
2836 (gnus-summary-insert-new-articles "mail/inbox" nil
2837 :visible (or (not gnus-agent)
2838 gnus-plugged))
2839 (gnus-summary-reply-with-original "mail/reply")
2840 (gnus-summary-reply "mail/reply" nil :visible nil)
2841 (gnus-summary-followup-with-original "mail/reply-all")
2842 (gnus-summary-followup "mail/reply-all" nil :visible nil)
2843 (gnus-summary-mail-forward "mail/forward")
2844 (gnus-summary-save-article "mail/save")
2845 (gnus-summary-search-article-forward "search" nil :visible nil)
2846 (gnus-summary-print-article "print")
2847 (gnus-summary-tick-article-forward "flag-followup" nil :visible nil)
2848 ;; Some new commands that may need more suitable icons:
2849 (gnus-summary-save-newsrc "save" nil :visible nil)
2850 ;; (gnus-summary-show-article "stock_message-display" nil :visible nil)
2851 (gnus-summary-prev-article "left-arrow")
2852 (gnus-summary-next-article "right-arrow")
2853 (gnus-summary-next-page "next-page")
2854 ;; (gnus-summary-enter-digest-group "right_arrow" nil :visible nil)
2855 ;;
2856 ;; Maybe some sort-by-... could be added:
2857 ;; (gnus-summary-sort-by-author "sort-a-z" nil :visible nil)
2858 ;; (gnus-summary-sort-by-date "sort-1-9" nil :visible nil)
2859 (gnus-summary-mark-as-expirable
2860 "delete" nil
2861 :visible (gnus-check-backend-function 'request-expire-articles
2862 gnus-newsgroup-name))
2863 (gnus-summary-mark-as-spam
2864 "mail/spam" t
2865 :visible (and (fboundp 'spam-group-ham-contents-p)
2866 (spam-group-ham-contents-p gnus-newsgroup-name))
2867 :help "Mark as spam")
2868 (gnus-summary-mark-as-read-forward
2869 "mail/not-spam" nil
2870 :visible (and (fboundp 'spam-group-spam-contents-p)
2871 (spam-group-spam-contents-p gnus-newsgroup-name)))
2872 ;;
2873 (gnus-summary-exit "exit")
2874 (gmm-customize-mode "preferences" t :help "Edit mode preferences")
2875 (gnus-info-find-node "help"))
2876 "List of functions for the summary tool bar (GNOME style).
2877
2878 See `gmm-tool-bar-from-list' for the format of the list."
2879 :type '(repeat gmm-tool-bar-item)
2880 :version "23.1" ;; No Gnus
2881 :initialize 'custom-initialize-default
2882 :set 'gnus-summary-tool-bar-update
2883 :group 'gnus-summary)
2884
2885 (defcustom gnus-summary-tool-bar-retro
2886 '((gnus-summary-prev-unread-article "gnus/prev-ur")
2887 (gnus-summary-next-unread-article "gnus/next-ur")
2888 (gnus-summary-post-news "gnus/post")
2889 (gnus-summary-followup-with-original "gnus/fuwo")
2890 (gnus-summary-followup "gnus/followup")
2891 (gnus-summary-reply-with-original "gnus/reply-wo")
2892 (gnus-summary-reply "gnus/reply")
2893 (gnus-summary-caesar-message "gnus/rot13")
2894 (gnus-uu-decode-uu "gnus/uu-decode")
2895 (gnus-summary-save-article-file "gnus/save-aif")
2896 (gnus-summary-save-article "gnus/save-art")
2897 (gnus-uu-post-news "gnus/uu-post")
2898 (gnus-summary-catchup "gnus/catchup")
2899 (gnus-summary-catchup-and-exit "gnus/cu-exit")
2900 (gnus-summary-exit "gnus/exit-summ")
2901 ;; Some new command that may need more suitable icons:
2902 (gnus-summary-print-article "gnus/print" nil :visible nil)
2903 (gnus-summary-mark-as-expirable "gnus/close" nil :visible nil)
2904 (gnus-summary-save-newsrc "gnus/save" nil :visible nil)
2905 ;; (gnus-summary-enter-digest-group "gnus/right_arrow" nil :visible nil)
2906 (gnus-summary-search-article-forward "gnus/search" nil :visible nil)
2907 ;; (gnus-summary-insert-new-articles "gnus/paste" nil :visible nil)
2908 ;; (gnus-summary-toggle-threads "gnus/open" nil :visible nil)
2909 ;;
2910 (gnus-info-find-node "gnus/help" nil :visible nil))
2911 "List of functions for the summary tool bar (retro look).
2912
2913 See `gmm-tool-bar-from-list' for the format of the list."
2914 :type '(repeat gmm-tool-bar-item)
2915 :version "23.1" ;; No Gnus
2916 :initialize 'custom-initialize-default
2917 :set 'gnus-summary-tool-bar-update
2918 :group 'gnus-summary)
2919
2920 (defcustom gnus-summary-tool-bar-zap-list t
2921 "List of icon items from the global tool bar.
2922 These items are not displayed in the Gnus summary mode tool bar.
2923
2924 See `gmm-tool-bar-from-list' for the format of the list."
2925 :type 'gmm-tool-bar-zap-list
2926 :version "23.1" ;; No Gnus
2927 :initialize 'custom-initialize-default
2928 :set 'gnus-summary-tool-bar-update
2929 :group 'gnus-summary)
2930
2931 (defvar image-load-path)
2932 (defvar tool-bar-map)
2933
2934 (defun gnus-summary-make-tool-bar (&optional force)
2935 "Make a summary mode tool bar from `gnus-summary-tool-bar'.
2936 When FORCE, rebuild the tool bar."
2937 (when (and (boundp 'tool-bar-mode)
2938 tool-bar-mode
2939 (or (not gnus-summary-tool-bar-map) force))
2940 (let* ((load-path
2941 (gmm-image-load-path-for-library "gnus"
2942 "mail/save.xpm"
2943 nil t))
2944 (image-load-path (cons (car load-path) image-load-path))
2945 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2946 gnus-summary-tool-bar-zap-list
2947 'gnus-summary-mode-map)))
2948 (when map
2949 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2950 ;; uses its value.
2951 (setq gnus-summary-tool-bar-map map))))
2952 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2953
2954 (defun gnus-make-score-map (type)
2955 "Make a summary score map of type TYPE."
2956 (if t
2957 nil
2958 (let ((headers '(("author" "from" string)
2959 ("subject" "subject" string)
2960 ("article body" "body" string)
2961 ("article head" "head" string)
2962 ("xref" "xref" string)
2963 ("extra header" "extra" string)
2964 ("lines" "lines" number)
2965 ("followups to author" "followup" string)))
2966 (types '((number ("less than" <)
2967 ("greater than" >)
2968 ("equal" =))
2969 (string ("substring" s)
2970 ("exact string" e)
2971 ("fuzzy string" f)
2972 ("regexp" r))))
2973 (perms '(("temporary" (current-time-string))
2974 ("permanent" nil)
2975 ("immediate" now)))
2976 header)
2977 (list
2978 (apply
2979 'nconc
2980 (list
2981 (if (eq type 'lower)
2982 "Lower score"
2983 "Increase score"))
2984 (let (outh)
2985 (while headers
2986 (setq header (car headers))
2987 (setq outh
2988 (cons
2989 (apply
2990 'nconc
2991 (list (car header))
2992 (let ((ts (cdr (assoc (nth 2 header) types)))
2993 outt)
2994 (while ts
2995 (setq outt
2996 (cons
2997 (apply
2998 'nconc
2999 (list (caar ts))
3000 (let ((ps perms)
3001 outp)
3002 (while ps
3003 (setq outp
3004 (cons
3005 (vector
3006 (caar ps)
3007 (list
3008 'gnus-summary-score-entry
3009 (nth 1 header)
3010 (if (or (string= (nth 1 header)
3011 "head")
3012 (string= (nth 1 header)
3013 "body"))
3014 ""
3015 (list 'gnus-summary-header
3016 (nth 1 header)))
3017 (list 'quote (nth 1 (car ts)))
3018 (list 'gnus-score-delta-default
3019 nil)
3020 (nth 1 (car ps))
3021 t)
3022 t)
3023 outp))
3024 (setq ps (cdr ps)))
3025 (list (nreverse outp))))
3026 outt))
3027 (setq ts (cdr ts)))
3028 (list (nreverse outt))))
3029 outh))
3030 (setq headers (cdr headers)))
3031 (list (nreverse outh))))))))
3032
3033
3034 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3035 (defvar bookmark-make-record-function)
3036 \f
3037 (defvar bidi-paragraph-direction)
3038
3039 (defun gnus-summary-mode (&optional group)
3040 "Major mode for reading articles.
3041
3042 All normal editing commands are switched off.
3043 \\<gnus-summary-mode-map>
3044 Each line in this buffer represents one article. To read an
3045 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3046 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3047 respectively.
3048
3049 You can also post articles and send mail from this buffer. To
3050 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3051 of an article, type `\\[gnus-summary-reply]'.
3052
3053 There are approx. one gazillion commands you can execute in this
3054 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3055
3056 The following commands are available:
3057
3058 \\{gnus-summary-mode-map}"
3059 ;; FIXME: Use define-derived-mode.
3060 (interactive)
3061 (kill-all-local-variables)
3062 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3063 (gnus-summary-make-local-variables))
3064 (gnus-summary-make-local-variables)
3065 (setq gnus-newsgroup-name group)
3066 (when (gnus-visual-p 'summary-menu 'menu)
3067 (gnus-summary-make-menu-bar)
3068 (gnus-summary-make-tool-bar))
3069 (gnus-make-thread-indent-array)
3070 (gnus-simplify-mode-line)
3071 (setq major-mode 'gnus-summary-mode)
3072 (setq mode-name "Summary")
3073 (use-local-map gnus-summary-mode-map)
3074 (buffer-disable-undo)
3075 (setq buffer-read-only t
3076 show-trailing-whitespace nil
3077 truncate-lines t
3078 bidi-paragraph-direction 'left-to-right)
3079 (add-to-invisibility-spec '(gnus-sum . t))
3080 (gnus-summary-set-display-table)
3081 (gnus-set-default-directory)
3082 (make-local-variable 'gnus-summary-line-format)
3083 (make-local-variable 'gnus-summary-line-format-spec)
3084 (make-local-variable 'gnus-summary-dummy-line-format)
3085 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3086 (make-local-variable 'gnus-summary-mark-positions)
3087 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3088 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3089 (turn-on-gnus-mailing-list-mode)
3090 (mm-enable-multibyte)
3091 (set (make-local-variable 'bookmark-make-record-function)
3092 'gnus-summary-bookmark-make-record)
3093 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3094 (gnus-update-summary-mark-positions))
3095
3096 (defun gnus-summary-make-local-variables ()
3097 "Make all the local summary buffer variables."
3098 (let (global)
3099 (dolist (local gnus-summary-local-variables)
3100 (if (consp local)
3101 (progn
3102 (if (eq (cdr local) 'global)
3103 ;; Copy the global value of the variable.
3104 (setq global (symbol-value (car local)))
3105 ;; Use the value from the list.
3106 (setq global (eval (cdr local))))
3107 (set (make-local-variable (car local)) global))
3108 ;; Simple nil-valued local variable.
3109 (set (make-local-variable local) nil)))))
3110
3111 ;; Summary data functions.
3112
3113 (defmacro gnus-data-number (data)
3114 `(car ,data))
3115
3116 (defmacro gnus-data-set-number (data number)
3117 `(setcar ,data ,number))
3118
3119 (defmacro gnus-data-mark (data)
3120 `(nth 1 ,data))
3121
3122 (defmacro gnus-data-set-mark (data mark)
3123 `(setcar (nthcdr 1 ,data) ,mark))
3124
3125 (defmacro gnus-data-pos (data)
3126 `(nth 2 ,data))
3127
3128 (defmacro gnus-data-set-pos (data pos)
3129 `(setcar (nthcdr 2 ,data) ,pos))
3130
3131 (defmacro gnus-data-header (data)
3132 `(nth 3 ,data))
3133
3134 (defmacro gnus-data-set-header (data header)
3135 `(setf (nth 3 ,data) ,header))
3136
3137 (defmacro gnus-data-level (data)
3138 `(nth 4 ,data))
3139
3140 (defmacro gnus-data-unread-p (data)
3141 `(= (nth 1 ,data) gnus-unread-mark))
3142
3143 (defmacro gnus-data-read-p (data)
3144 `(/= (nth 1 ,data) gnus-unread-mark))
3145
3146 (defmacro gnus-data-pseudo-p (data)
3147 `(consp (nth 3 ,data)))
3148
3149 (defmacro gnus-data-find (number)
3150 `(assq ,number gnus-newsgroup-data))
3151
3152 (defmacro gnus-data-find-list (number &optional data)
3153 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3154 (memq (assq ,number bdata)
3155 bdata)))
3156
3157 (defmacro gnus-data-make (number mark pos header level)
3158 `(list ,number ,mark ,pos ,header ,level))
3159
3160 (defun gnus-data-enter (after-article number mark pos header level offset)
3161 (let ((data (gnus-data-find-list after-article)))
3162 (unless data
3163 (error "No such article: %d" after-article))
3164 (setcdr data (cons (gnus-data-make number mark pos header level)
3165 (cdr data)))
3166 (setq gnus-newsgroup-data-reverse nil)
3167 (gnus-data-update-list (cddr data) offset)))
3168
3169 (defun gnus-data-enter-list (after-article list &optional offset)
3170 (when list
3171 (let ((data (and after-article (gnus-data-find-list after-article)))
3172 (ilist list))
3173 (if (not (or data
3174 after-article))
3175 (let ((odata gnus-newsgroup-data))
3176 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3177 (when offset
3178 (gnus-data-update-list odata offset)))
3179 ;; Find the last element in the list to be spliced into the main
3180 ;; list.
3181 (setq list (last list))
3182 (if (not data)
3183 (progn
3184 (setcdr list gnus-newsgroup-data)
3185 (setq gnus-newsgroup-data ilist)
3186 (when offset
3187 (gnus-data-update-list (cdr list) offset)))
3188 (setcdr list (cdr data))
3189 (setcdr data ilist)
3190 (when offset
3191 (gnus-data-update-list (cdr list) offset))))
3192 (setq gnus-newsgroup-data-reverse nil))))
3193
3194 (defun gnus-data-remove (article &optional offset)
3195 (let ((data gnus-newsgroup-data))
3196 (if (= (gnus-data-number (car data)) article)
3197 (progn
3198 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3199 gnus-newsgroup-data-reverse nil)
3200 (when offset
3201 (gnus-data-update-list gnus-newsgroup-data offset)))
3202 (while (cdr data)
3203 (when (= (gnus-data-number (cadr data)) article)
3204 (setcdr data (cddr data))
3205 (when offset
3206 (gnus-data-update-list (cdr data) offset))
3207 (setq data nil
3208 gnus-newsgroup-data-reverse nil))
3209 (setq data (cdr data))))))
3210
3211 (defmacro gnus-data-list (backward)
3212 `(if ,backward
3213 (or gnus-newsgroup-data-reverse
3214 (setq gnus-newsgroup-data-reverse
3215 (reverse gnus-newsgroup-data)))
3216 gnus-newsgroup-data))
3217
3218 (defun gnus-data-update-list (data offset)
3219 "Add OFFSET to the POS of all data entries in DATA."
3220 (setq gnus-newsgroup-data-reverse nil)
3221 (while data
3222 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3223 (setq data (cdr data))))
3224
3225 (defun gnus-summary-article-pseudo-p (article)
3226 "Say whether this article is a pseudo article or not."
3227 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3228
3229 (defmacro gnus-summary-article-sparse-p (article)
3230 "Say whether this article is a sparse article or not."
3231 `(memq ,article gnus-newsgroup-sparse))
3232
3233 (defmacro gnus-summary-article-ancient-p (article)
3234 "Say whether this article is a sparse article or not."
3235 `(memq ,article gnus-newsgroup-ancient))
3236
3237 (defun gnus-article-children (number)
3238 "Return a list of all children to NUMBER."
3239 (let* ((data (gnus-data-find-list number))
3240 (level (gnus-data-level (car data)))
3241 children)
3242 (setq data (cdr data))
3243 (while (and data
3244 (= (gnus-data-level (car data)) (1+ level)))
3245 (push (gnus-data-number (car data)) children)
3246 (setq data (cdr data)))
3247 children))
3248
3249 (defmacro gnus-summary-skip-intangible ()
3250 "If the current article is intangible, then jump to a different article."
3251 '(let ((to (get-text-property (point) 'gnus-intangible)))
3252 (and to (gnus-summary-goto-subject to))))
3253
3254 (defmacro gnus-summary-article-intangible-p ()
3255 "Say whether this article is intangible or not."
3256 '(get-text-property (point) 'gnus-intangible))
3257
3258 ;; Some summary mode macros.
3259
3260 (defmacro gnus-summary-article-number ()
3261 "The article number of the article on the current line.
3262 If there isn't an article number here, then we return the current
3263 article number."
3264 '(progn
3265 (gnus-summary-skip-intangible)
3266 (or (get-text-property (point) 'gnus-number)
3267 (gnus-summary-last-subject))))
3268
3269 (defmacro gnus-summary-article-header (&optional number)
3270 "Return the header of article NUMBER."
3271 `(gnus-data-header (gnus-data-find
3272 ,(or number '(gnus-summary-article-number)))))
3273
3274 (defmacro gnus-summary-thread-level (&optional number)
3275 "Return the level of thread that starts with article NUMBER."
3276 `(if (and (eq gnus-summary-make-false-root 'dummy)
3277 (get-text-property (point) 'gnus-intangible))
3278 0
3279 (gnus-data-level (gnus-data-find
3280 ,(or number '(gnus-summary-article-number))))))
3281
3282 (defmacro gnus-summary-article-mark (&optional number)
3283 "Return the mark of article NUMBER."
3284 `(gnus-data-mark (gnus-data-find
3285 ,(or number '(gnus-summary-article-number)))))
3286
3287 (defmacro gnus-summary-article-pos (&optional number)
3288 "Return the position of the line of article NUMBER."
3289 `(gnus-data-pos (gnus-data-find
3290 ,(or number '(gnus-summary-article-number)))))
3291
3292 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3293 (defmacro gnus-summary-article-subject (&optional number)
3294 "Return current subject string or nil if nothing."
3295 `(let ((headers
3296 ,(if number
3297 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3298 '(gnus-data-header (assq (gnus-summary-article-number)
3299 gnus-newsgroup-data)))))
3300 (and headers
3301 (vectorp headers)
3302 (mail-header-subject headers))))
3303
3304 (defmacro gnus-summary-article-score (&optional number)
3305 "Return current article score."
3306 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3307 gnus-newsgroup-scored))
3308 gnus-summary-default-score 0))
3309
3310 (defun gnus-summary-article-children (&optional number)
3311 "Return a list of article numbers that are children of article NUMBER."
3312 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3313 (level (gnus-data-level (car data)))
3314 l children)
3315 (while (and (setq data (cdr data))
3316 (> (setq l (gnus-data-level (car data))) level))
3317 (and (= (1+ level) l)
3318 (push (gnus-data-number (car data))
3319 children)))
3320 (nreverse children)))
3321
3322 (defun gnus-summary-article-parent (&optional number)
3323 "Return the article number of the parent of article NUMBER."
3324 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3325 (gnus-data-list t)))
3326 (level (gnus-data-level (car data))))
3327 (if (zerop level)
3328 () ; This is a root.
3329 ;; We search until we find an article with a level less than
3330 ;; this one. That function has to be the parent.
3331 (while (and (setq data (cdr data))
3332 (not (< (gnus-data-level (car data)) level))))
3333 (and data (gnus-data-number (car data))))))
3334
3335 (defun gnus-unread-mark-p (mark)
3336 "Say whether MARK is the unread mark."
3337 (= mark gnus-unread-mark))
3338
3339 (defun gnus-read-mark-p (mark)
3340 "Say whether MARK is one of the marks that mark as read.
3341 This is all marks except unread, ticked, dormant, and expirable."
3342 (not (or (= mark gnus-unread-mark)
3343 (= mark gnus-ticked-mark)
3344 (= mark gnus-spam-mark)
3345 (= mark gnus-dormant-mark)
3346 (= mark gnus-expirable-mark))))
3347
3348 (defmacro gnus-article-mark (number)
3349 "Return the MARK of article NUMBER.
3350 This macro should only be used when computing the mark the \"first\"
3351 time; i.e., when generating the summary lines. After that,
3352 `gnus-summary-article-mark' should be used to examine the
3353 marks of articles."
3354 `(cond
3355 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3356 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3357 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3358 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3359 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3360 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3361 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3362 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3363 gnus-ancient-mark))))
3364
3365 ;; Saving hidden threads.
3366
3367 (defmacro gnus-save-hidden-threads (&rest forms)
3368 "Save hidden threads, eval FORMS, and restore the hidden threads."
3369 (let ((config (make-symbol "config")))
3370 `(let ((,config (gnus-hidden-threads-configuration)))
3371 (unwind-protect
3372 (save-excursion
3373 ,@forms)
3374 (gnus-restore-hidden-threads-configuration ,config)))))
3375 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3376 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3377
3378 (defun gnus-data-compute-positions ()
3379 "Compute the positions of all articles."
3380 (setq gnus-newsgroup-data-reverse nil)
3381 (let ((data gnus-newsgroup-data))
3382 (save-excursion
3383 (gnus-save-hidden-threads
3384 (gnus-summary-show-all-threads)
3385 (goto-char (point-min))
3386 (while data
3387 (while (get-text-property (point) 'gnus-intangible)
3388 (forward-line 1))
3389 (gnus-data-set-pos (car data) (+ (point) 3))
3390 (setq data (cdr data))
3391 (forward-line 1))))))
3392
3393 (defun gnus-hidden-threads-configuration ()
3394 "Return the current hidden threads configuration."
3395 (save-excursion
3396 (let (config)
3397 (goto-char (point-min))
3398 (while (not (eobp))
3399 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3400 (push (save-excursion (forward-line 0) (point)) config))
3401 (forward-line 1))
3402 config)))
3403
3404 (defun gnus-restore-hidden-threads-configuration (config)
3405 "Restore hidden threads configuration from CONFIG."
3406 (save-excursion
3407 (let (point (inhibit-read-only t))
3408 (while (setq point (pop config))
3409 (goto-char point)
3410 (gnus-summary-hide-thread)))))
3411
3412 ;; Various summary mode internalish functions.
3413
3414 (defun gnus-mouse-pick-article (e)
3415 (interactive "e")
3416 (mouse-set-point e)
3417 (gnus-summary-next-page nil t))
3418
3419 (defun gnus-summary-set-display-table ()
3420 "Change the display table.
3421 Odd characters have a tendency to mess
3422 up nicely formatted displays - we make all possible glyphs
3423 display only a single character."
3424
3425 ;; We start from the standard display table, if any.
3426 (let ((table (or (copy-sequence standard-display-table)
3427 (make-display-table)))
3428 (i 32))
3429 ;; Nix out all the control chars...
3430 (while (>= (setq i (1- i)) 0)
3431 (aset table i [??]))
3432 ;; ... but not newline and cr, of course. (cr is necessary for the
3433 ;; selective display).
3434 (aset table ?\n nil)
3435 (aset table ?\r nil)
3436 ;; We keep TAB as well.
3437 (aset table ?\t nil)
3438 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3439 ;; Emacs 23 (unicode), that are not set already.
3440 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3441 160
3442 256)))
3443 (while (>= (setq i (1- i)) 127)
3444 ;; Only modify if the entry is nil.
3445 (unless (aref table i)
3446 (aset table i [??]))))
3447 (setq buffer-display-table table)))
3448
3449 (defun gnus-summary-set-article-display-arrow (pos)
3450 "Update the overlay arrow to point to line at position POS."
3451 (when gnus-summary-display-arrow
3452 (make-local-variable 'overlay-arrow-position)
3453 (make-local-variable 'overlay-arrow-string)
3454 (save-excursion
3455 (goto-char pos)
3456 (beginning-of-line)
3457 (unless overlay-arrow-position
3458 (setq overlay-arrow-position (make-marker)))
3459 (setq overlay-arrow-string "=>"
3460 overlay-arrow-position (set-marker overlay-arrow-position
3461 (point)
3462 (current-buffer))))))
3463
3464 (defun gnus-summary-setup-buffer (group)
3465 "Initialize summary buffer.
3466 If the setup was successful, non-nil is returned."
3467 (let ((buffer (gnus-summary-buffer-name group))
3468 (dead-name (concat "*Dead Summary "
3469 (gnus-group-decoded-name group) "*")))
3470 ;; If a dead summary buffer exists, we kill it.
3471 (when (gnus-buffer-live-p dead-name)
3472 (gnus-kill-buffer dead-name))
3473 (if (get-buffer buffer)
3474 (progn
3475 (set-buffer buffer)
3476 (setq gnus-summary-buffer (current-buffer))
3477 (not gnus-newsgroup-prepared))
3478 (set-buffer (gnus-get-buffer-create buffer))
3479 (setq gnus-summary-buffer (current-buffer))
3480 (gnus-summary-mode group)
3481 (when (gnus-group-quit-config group)
3482 (set (make-local-variable 'gnus-single-article-buffer) nil))
3483 (make-local-variable 'gnus-article-buffer)
3484 (make-local-variable 'gnus-article-current)
3485 (make-local-variable 'gnus-original-article-buffer)
3486 (setq gnus-newsgroup-name group)
3487 ;; Set any local variables in the group parameters.
3488 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3489 t)))
3490
3491 (defun gnus-set-global-variables ()
3492 "Set the global equivalents of the buffer-local variables.
3493 They are set to the latest values they had. These reflect the summary
3494 buffer that was in action when the last article was fetched."
3495 (when (derived-mode-p 'gnus-summary-mode)
3496 (setq gnus-summary-buffer (current-buffer))
3497 (let ((name gnus-newsgroup-name)
3498 (marked gnus-newsgroup-marked)
3499 (spam gnus-newsgroup-spam-marked)
3500 (unread gnus-newsgroup-unreads)
3501 (headers gnus-current-headers)
3502 (data gnus-newsgroup-data)
3503 (summary gnus-summary-buffer)
3504 (article-buffer gnus-article-buffer)
3505 (original gnus-original-article-buffer)
3506 (gac gnus-article-current)
3507 (reffed gnus-reffed-article-number)
3508 (score-file gnus-current-score-file)
3509 (default-charset gnus-newsgroup-charset)
3510 vlist)
3511 (let ((locals gnus-newsgroup-variables))
3512 (while locals
3513 (if (consp (car locals))
3514 (push (eval (caar locals)) vlist)
3515 (push (eval (car locals)) vlist))
3516 (setq locals (cdr locals)))
3517 (setq vlist (nreverse vlist)))
3518 (with-temp-buffer
3519 (setq gnus-newsgroup-name name
3520 gnus-newsgroup-marked marked
3521 gnus-newsgroup-spam-marked spam
3522 gnus-newsgroup-unreads unread
3523 gnus-current-headers headers
3524 gnus-newsgroup-data data
3525 gnus-article-current gac
3526 gnus-summary-buffer summary
3527 gnus-article-buffer article-buffer
3528 gnus-original-article-buffer original
3529 gnus-reffed-article-number reffed
3530 gnus-current-score-file score-file
3531 gnus-newsgroup-charset default-charset)
3532 (let ((locals gnus-newsgroup-variables))
3533 (while locals
3534 (if (consp (car locals))
3535 (set (caar locals) (pop vlist))
3536 (set (car locals) (pop vlist)))
3537 (setq locals (cdr locals))))))))
3538
3539 (defun gnus-summary-article-unread-p (article)
3540 "Say whether ARTICLE is unread or not."
3541 (memq article gnus-newsgroup-unreads))
3542
3543 (defun gnus-summary-first-article-p (&optional article)
3544 "Return whether ARTICLE is the first article in the buffer."
3545 (if (not (setq article (or article (gnus-summary-article-number))))
3546 nil
3547 (eq article (caar gnus-newsgroup-data))))
3548
3549 (defun gnus-summary-last-article-p (&optional article)
3550 "Return whether ARTICLE is the last article in the buffer."
3551 (if (not (setq article (or article (gnus-summary-article-number))))
3552 ;; All non-existent numbers are the last article. :-)
3553 t
3554 (not (cdr (gnus-data-find-list article)))))
3555
3556 (defun gnus-make-thread-indent-array (&optional n)
3557 (when (or n
3558 (progn (setq n 200) nil)
3559 (null gnus-thread-indent-array)
3560 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3561 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3562 gnus-thread-indent-array-level gnus-thread-indent-level)
3563 (while (>= n 0)
3564 (aset gnus-thread-indent-array n
3565 (make-string (* n gnus-thread-indent-level) ? ))
3566 (setq n (1- n)))))
3567
3568 (defun gnus-update-summary-mark-positions ()
3569 "Compute where the summary marks are to go."
3570 (save-excursion
3571 (when (gnus-buffer-exists-p gnus-summary-buffer)
3572 (set-buffer gnus-summary-buffer))
3573 (let ((spec gnus-summary-line-format-spec)
3574 pos)
3575 (save-excursion
3576 (gnus-set-work-buffer)
3577 (let ((gnus-tmp-unread ?Z)
3578 (gnus-replied-mark ?Z)
3579 (gnus-score-below-mark ?Z)
3580 (gnus-score-over-mark ?Z)
3581 (gnus-undownloaded-mark ?Z)
3582 (gnus-summary-line-format-spec spec)
3583 (gnus-newsgroup-downloadable '(0))
3584 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3585 case-fold-search ignores)
3586 ;; Here, all marks are bound to Z.
3587 (gnus-summary-insert-line header
3588 0 nil t gnus-tmp-unread t nil "" nil 1)
3589 (goto-char (point-min))
3590 ;; Memorize the positions of the same characters as dummy marks.
3591 (while (re-search-forward "[A-D]" nil t)
3592 (push (point) ignores))
3593 (erase-buffer)
3594 ;; We use A-D as dummy marks in order to know column positions
3595 ;; where marks should be inserted.
3596 (setq gnus-tmp-unread ?A
3597 gnus-replied-mark ?B
3598 gnus-score-below-mark ?C
3599 gnus-score-over-mark ?C
3600 gnus-undownloaded-mark ?D)
3601 (gnus-summary-insert-line header
3602 0 nil t gnus-tmp-unread t nil "" nil 1)
3603 ;; Ignore characters which aren't dummy marks.
3604 (dolist (p ignores)
3605 (delete-region (goto-char (1- p)) p)
3606 (insert ?Z))
3607 (goto-char (point-min))
3608 (setq pos (list (cons 'unread
3609 (and (search-forward "A" nil t)
3610 (- (point) (point-min) 1)))))
3611 (goto-char (point-min))
3612 (push (cons 'replied (and (search-forward "B" nil t)
3613 (- (point) (point-min) 1)))
3614 pos)
3615 (goto-char (point-min))
3616 (push (cons 'score (and (search-forward "C" nil t)
3617 (- (point) (point-min) 1)))
3618 pos)
3619 (goto-char (point-min))
3620 (push (cons 'download (and (search-forward "D" nil t)
3621 (- (point) (point-min) 1)))
3622 pos)))
3623 (setq gnus-summary-mark-positions pos))))
3624
3625 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3626 "Insert a dummy root in the summary buffer."
3627 (beginning-of-line)
3628 (add-text-properties
3629 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3630 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3631
3632 (defun gnus-summary-extract-address-component (from)
3633 (or (car (funcall gnus-extract-address-components from))
3634 from))
3635
3636 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3637 (let ((mail-parse-charset gnus-newsgroup-charset)
3638 ;; Is it really necessary to do this next part for each summary line?
3639 ;; Luckily, doesn't seem to slow things down much.
3640 (mail-parse-ignored-charsets
3641 (with-current-buffer gnus-summary-buffer
3642 gnus-newsgroup-ignored-charsets)))
3643 (or
3644 (and gnus-ignored-from-addresses
3645 (cond ((functionp gnus-ignored-from-addresses)
3646 (funcall gnus-ignored-from-addresses
3647 (mail-strip-quoted-names gnus-tmp-from)))
3648 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3649 (let ((extra-headers (mail-header-extra header))
3650 to
3651 newsgroups)
3652 (cond
3653 ((setq to (cdr (assq 'To extra-headers)))
3654 (concat gnus-summary-to-prefix
3655 (inline
3656 (gnus-summary-extract-address-component
3657 (funcall gnus-decode-encoded-address-function to)))))
3658 ((setq newsgroups
3659 (or
3660 (cdr (assq 'Newsgroups extra-headers))
3661 (and
3662 (memq 'Newsgroups gnus-extra-headers)
3663 (eq (car (gnus-find-method-for-group
3664 gnus-newsgroup-name)) 'nntp)
3665 (gnus-group-real-name gnus-newsgroup-name))))
3666 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3667 (bidi-string-mark-left-to-right
3668 (inline
3669 (gnus-summary-extract-address-component gnus-tmp-from))))))
3670
3671 (defun gnus-summary-insert-line (gnus-tmp-header
3672 gnus-tmp-level gnus-tmp-current
3673 undownloaded gnus-tmp-unread gnus-tmp-replied
3674 gnus-tmp-expirable gnus-tmp-subject-or-nil
3675 &optional gnus-tmp-dummy gnus-tmp-score
3676 gnus-tmp-process)
3677 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3678 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3679 gnus-tmp-level)))
3680 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3681 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3682 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3683 (gnus-tmp-score-char
3684 (if (or (null gnus-summary-default-score)
3685 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3686 gnus-summary-zcore-fuzz))
3687 ? ;Whitespace
3688 (if (< gnus-tmp-score gnus-summary-default-score)
3689 gnus-score-below-mark gnus-score-over-mark)))
3690 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3691 (gnus-tmp-replied
3692 (cond (gnus-tmp-process gnus-process-mark)
3693 ((memq gnus-tmp-current gnus-newsgroup-cached)
3694 gnus-cached-mark)
3695 (gnus-tmp-replied gnus-replied-mark)
3696 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3697 gnus-forwarded-mark)
3698 ((memq gnus-tmp-current gnus-newsgroup-saved)
3699 gnus-saved-mark)
3700 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3701 gnus-unseen-mark)
3702 (t gnus-no-mark)))
3703 (gnus-tmp-downloaded
3704 (cond (undownloaded
3705 gnus-undownloaded-mark)
3706 (gnus-newsgroup-agentized
3707 gnus-downloaded-mark)
3708 (t
3709 gnus-no-mark)))
3710 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3711 (gnus-tmp-name
3712 (cond
3713 ((string-match "<[^>]+> *$" gnus-tmp-from)
3714 (let ((beg (match-beginning 0)))
3715 (or (and (string-match "^\".+\"" gnus-tmp-from)
3716 (substring gnus-tmp-from 1 (1- (match-end 0))))
3717 (substring gnus-tmp-from 0 beg))))
3718 ((string-match "(.+)" gnus-tmp-from)
3719 (substring gnus-tmp-from
3720 (1+ (match-beginning 0)) (1- (match-end 0))))
3721 (t gnus-tmp-from)))
3722 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3723 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3724 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3725 (inhibit-read-only t))
3726 (when (string= gnus-tmp-name "")
3727 (setq gnus-tmp-name gnus-tmp-from))
3728 (unless (numberp gnus-tmp-lines)
3729 (setq gnus-tmp-lines -1))
3730 (if (= gnus-tmp-lines -1)
3731 (setq gnus-tmp-lines "?")
3732 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3733 (condition-case ()
3734 (put-text-property
3735 (point)
3736 (progn (eval gnus-summary-line-format-spec) (point))
3737 'gnus-number gnus-tmp-number)
3738 (error (gnus-message 5 "Error updating the summary line")))
3739 (when (gnus-visual-p 'summary-highlight 'highlight)
3740 (forward-line -1)
3741 (gnus-summary-highlight-line)
3742 (gnus-run-hooks 'gnus-summary-update-hook)
3743 (forward-line 1))))
3744
3745 (defun gnus-summary-update-line (&optional dont-update)
3746 "Update summary line after change."
3747 (when (and gnus-summary-default-score
3748 (not gnus-summary-inhibit-highlight))
3749 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3750 (article (gnus-summary-article-number))
3751 (score (gnus-summary-article-score article)))
3752 (unless dont-update
3753 (if (and gnus-summary-mark-below
3754 (< (gnus-summary-article-score)
3755 gnus-summary-mark-below))
3756 ;; This article has a low score, so we mark it as read.
3757 (when (memq article gnus-newsgroup-unreads)
3758 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3759 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3760 ;; This article was previously marked as read on account
3761 ;; of a low score, but now it has risen, so we mark it as
3762 ;; unread.
3763 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3764 (gnus-summary-update-mark
3765 (if (or (null gnus-summary-default-score)
3766 (<= (abs (- score gnus-summary-default-score))
3767 gnus-summary-zcore-fuzz))
3768 ? ;Whitespace
3769 (if (< score gnus-summary-default-score)
3770 gnus-score-below-mark gnus-score-over-mark))
3771 'score))
3772 ;; Do visual highlighting.
3773 (when (gnus-visual-p 'summary-highlight 'highlight)
3774 (gnus-summary-highlight-line)
3775 (gnus-run-hooks 'gnus-summary-update-hook)))))
3776
3777 (defvar gnus-tmp-new-adopts nil)
3778
3779 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3780 "Return the number of articles in THREAD.
3781 This may be 0 in some cases -- if none of the articles in
3782 the thread are to be displayed."
3783 (let* ((number
3784 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3785 (cond
3786 ((not (listp thread))
3787 1)
3788 ((and (consp thread) (cdr thread))
3789 (apply
3790 '+ 1 (mapcar
3791 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3792 ((null thread)
3793 1)
3794 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3795 1)
3796 (t 0))))
3797 (when (and level (zerop level) gnus-tmp-new-adopts)
3798 (incf number
3799 (apply '+ (mapcar
3800 'gnus-summary-number-of-articles-in-thread
3801 gnus-tmp-new-adopts))))
3802 (if char
3803 (if (> number 1) gnus-not-empty-thread-mark
3804 gnus-empty-thread-mark)
3805 number)))
3806
3807 (defsubst gnus-summary-line-message-size (head)
3808 "Return pretty-printed version of message size.
3809 This function is intended to be used in
3810 `gnus-summary-line-format-alist'."
3811 (let ((c (or (mail-header-chars head) -1)))
3812 (cond ((< c 0) "n/a") ; chars not available
3813 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3814 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3815 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3816 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3817
3818 (defcustom gnus-user-date-format-alist
3819 '(((gnus-seconds-today) . "Today, %H:%M")
3820 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3821 (604800 . "%A %H:%M") ; That's one week
3822 ((gnus-seconds-month) . "%A %d")
3823 ((gnus-seconds-year) . "%B %d")
3824 (t . "%b %d %Y")) ; This one is used when no other
3825 ; does match
3826 "Specifies date format depending on age of article.
3827 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3828 seconds) or a Lisp expression evaluating to a number. When the age of
3829 the article is less than this number, then use `format-time-string'
3830 with the corresponding FORMAT for displaying the date of the article.
3831 If AGE is not a number or a Lisp expression evaluating to a
3832 non-number, then the corresponding FORMAT is used as a default value.
3833
3834 Note that the list is processed from the beginning, so it should be
3835 sorted by ascending AGE. Also note that items following the first
3836 non-number AGE will be ignored.
3837
3838 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3839 and `gnus-seconds-year' in the AGE spec. They return the number of
3840 seconds passed since the start of today, of this month, of this year,
3841 respectively."
3842 :version "24.1"
3843 :group 'gnus-summary-format
3844 :type '(alist :key-type sexp :value-type string))
3845
3846 (defun gnus-user-date (messy-date)
3847 "Format the messy-date according to `gnus-user-date-format-alist'.
3848 Returns \" ? \" if there's bad input or if another error occurs.
3849 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3850 (condition-case ()
3851 (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
3852 (now (float-time))
3853 ;;If we don't find something suitable we'll use this one
3854 (my-format "%b %d '%y"))
3855 (let* ((difference (- now messy-date))
3856 (templist gnus-user-date-format-alist)
3857 (top (eval (caar templist))))
3858 (while (if (numberp top) (< top difference) (not top))
3859 (progn
3860 (setq templist (cdr templist))
3861 (setq top (eval (caar templist)))))
3862 (if (stringp (cdr (car templist)))
3863 (setq my-format (cdr (car templist)))))
3864 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3865 (error " ? ")))
3866
3867 (defun gnus-summary-set-local-parameters (group)
3868 "Go through the local params of GROUP and set all variable specs in that list."
3869 (let ((vars '(quit-config active))) ; Ignore things that aren't
3870 ; really variables.
3871 (dolist (elem (gnus-group-find-parameter group))
3872 (and (consp elem) ; Has to be a cons.
3873 (consp (cdr elem)) ; The cdr has to be a list.
3874 (symbolp (car elem)) ; Has to be a symbol in there.
3875 (not (memq (car elem) vars))
3876 (ignore-errors
3877 (push (car elem) vars)
3878 ;; Variables like `gnus-show-threads' that are globally
3879 ;; bound, if used as group parameters, need to get to be
3880 ;; buffer-local, whereas just parameters like `gcc-self',
3881 ;; `timestamp', etc. should not be bound as variables.
3882 (if (boundp (car elem))
3883 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3884 (eval (nth 1 elem))))))))
3885
3886 (defun gnus-summary-read-group (group &optional show-all no-article
3887 kill-buffer no-display backward
3888 select-articles)
3889 "Start reading news in newsgroup GROUP.
3890 If SHOW-ALL is non-nil, already read articles are also listed.
3891 If NO-ARTICLE is non-nil, no article is selected initially.
3892 If NO-DISPLAY, don't generate the summary buffer contents.
3893 If KILL-BUFFER, it should be a buffer that's killed once the new
3894 summary buffer has been generated.
3895 If BACKWARD, move point to the previous group in the group buffer
3896 If SELECT-ARTICLES, only select those articles from GROUP."
3897 (let (result)
3898 (while (and group
3899 (null (setq result
3900 (let ((gnus-auto-select-next nil))
3901 (or (gnus-summary-read-group-1
3902 group show-all no-article
3903 kill-buffer no-display
3904 select-articles)
3905 (setq show-all nil
3906 select-articles nil)))))
3907 (eq gnus-auto-select-next 'quietly))
3908 (set-buffer gnus-group-buffer)
3909 ;; The entry function called above goes to the next
3910 ;; group automatically, so we go two groups back
3911 ;; if we are searching for the previous group.
3912 (when backward
3913 (gnus-group-prev-unread-group 2))
3914 (if (not (equal group (gnus-group-group-name)))
3915 (setq group (gnus-group-group-name))
3916 (setq group nil)))
3917 result))
3918
3919 (defun gnus-summary-read-group-1 (group show-all no-article
3920 kill-buffer no-display
3921 &optional select-articles)
3922 ;; Killed foreign groups can't be entered.
3923 ;; (when (and (not (gnus-group-native-p group))
3924 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3925 ;; (error "Dead non-native groups can't be entered"))
3926 (gnus-message 7 "Retrieving newsgroup: %s..."
3927 (gnus-group-decoded-name group))
3928 (let* ((new-group (gnus-summary-setup-buffer group))
3929 (quit-config (gnus-group-quit-config group))
3930 (did-select (and new-group (gnus-select-newsgroup
3931 group show-all select-articles))))
3932 (cond
3933 ;; This summary buffer exists already, so we just select it.
3934 ((not new-group)
3935 (gnus-set-global-variables)
3936 (when kill-buffer
3937 (gnus-kill-or-deaden-summary kill-buffer))
3938 (gnus-configure-windows 'summary 'force)
3939 (gnus-set-mode-line 'summary)
3940 (gnus-summary-position-point)
3941 (message "")
3942 t)
3943 ;; We couldn't select this group.
3944 ((null did-select)
3945 (when (and (derived-mode-p 'gnus-summary-mode)
3946 (not (equal (current-buffer) kill-buffer)))
3947 (kill-buffer (current-buffer))
3948 (if (not quit-config)
3949 (progn
3950 ;; Update the info -- marks might need to be removed,
3951 ;; for instance.
3952 (gnus-summary-update-info)
3953 (set-buffer gnus-group-buffer)
3954 (gnus-group-jump-to-group group)
3955 (gnus-group-next-unread-group 1))
3956 (gnus-handle-ephemeral-exit quit-config)))
3957 (if (null (gnus-list-of-unread-articles group))
3958 (gnus-message 3 "Group %s contains no messages"
3959 (gnus-group-decoded-name group))
3960 (gnus-message 3 "Can't select group"))
3961 nil)
3962 ;; The user did a `C-g' while prompting for number of articles,
3963 ;; so we exit this group.
3964 ((eq did-select 'quit)
3965 (and (derived-mode-p 'gnus-summary-mode)
3966 (not (equal (current-buffer) kill-buffer))
3967 (kill-buffer (current-buffer)))
3968 (when kill-buffer
3969 (gnus-kill-or-deaden-summary kill-buffer))
3970 (if (not quit-config)
3971 (progn
3972 (set-buffer gnus-group-buffer)
3973 (gnus-group-jump-to-group group)
3974 (gnus-configure-windows 'group 'force))
3975 (gnus-handle-ephemeral-exit quit-config))
3976 ;; Finally signal the quit.
3977 (signal 'quit nil))
3978 ;; The group was successfully selected.
3979 (t
3980 (gnus-set-global-variables)
3981 (when (boundp 'spam-install-hooks)
3982 (spam-initialize))
3983 ;; Save the active value in effect when the group was entered.
3984 (setq gnus-newsgroup-active
3985 (gnus-copy-sequence
3986 (gnus-active gnus-newsgroup-name)))
3987 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
3988 ;; You can change the summary buffer in some way with this hook.
3989 (gnus-run-hooks 'gnus-select-group-hook)
3990 (when (memq 'summary (gnus-update-format-specifications
3991 nil 'summary 'summary-mode 'summary-dummy))
3992 ;; The format specification for the summary line was updated,
3993 ;; so we need to update the mark positions as well.
3994 (gnus-update-summary-mark-positions))
3995 ;; Do score processing.
3996 (when gnus-use-scoring
3997 (gnus-possibly-score-headers))
3998 ;; Check whether to fill in the gaps in the threads.
3999 (when gnus-build-sparse-threads
4000 (gnus-build-sparse-threads))
4001 ;; Find the initial limit.
4002 (if show-all
4003 (let ((gnus-newsgroup-dormant nil))
4004 (gnus-summary-initial-limit show-all))
4005 (gnus-summary-initial-limit show-all))
4006 ;; Generate the summary buffer.
4007 (unless no-display
4008 (gnus-summary-prepare))
4009 (when gnus-use-trees
4010 (gnus-tree-open)
4011 (setq gnus-summary-highlight-line-function
4012 'gnus-tree-highlight-article))
4013 ;; If the summary buffer is empty, but there are some low-scored
4014 ;; articles or some excluded dormants, we include these in the
4015 ;; buffer.
4016 (when (and (zerop (buffer-size))
4017 (not no-display))
4018 (cond (gnus-newsgroup-dormant
4019 (gnus-summary-limit-include-dormant))
4020 ((and gnus-newsgroup-scored show-all)
4021 (gnus-summary-limit-include-expunged t))))
4022 ;; Function `gnus-apply-kill-file' must be called in this hook.
4023 (gnus-run-hooks 'gnus-apply-kill-hook)
4024 (if (and (zerop (buffer-size))
4025 (not no-display))
4026 (progn
4027 ;; This newsgroup is empty.
4028 (gnus-summary-catchup-and-exit nil t)
4029 (gnus-message 6 "No unread news")
4030 (when kill-buffer
4031 (gnus-kill-or-deaden-summary kill-buffer))
4032 ;; Return nil from this function.
4033 nil)
4034 ;; Hide conversation thread subtrees. We cannot do this in
4035 ;; gnus-summary-prepare-hook since kill processing may not
4036 ;; work with hidden articles.
4037 (gnus-summary-maybe-hide-threads)
4038 (gnus-configure-windows 'summary)
4039 (when kill-buffer
4040 (gnus-kill-or-deaden-summary kill-buffer))
4041 (gnus-summary-auto-select-subject)
4042 ;; Show first unread article if requested.
4043 (if (and (not no-article)
4044 (not no-display)
4045 gnus-newsgroup-unreads
4046 gnus-auto-select-first)
4047 (progn
4048 (let ((art (gnus-summary-article-number)))
4049 (when (and art
4050 gnus-plugged
4051 (not (memq art gnus-newsgroup-undownloaded))
4052 (not (memq art gnus-newsgroup-downloadable)))
4053 (gnus-summary-goto-article art))))
4054 ;; Don't select any articles.
4055 (gnus-summary-position-point)
4056 (gnus-configure-windows 'summary 'force)
4057 (gnus-set-mode-line 'summary))
4058 (when (and gnus-auto-center-group
4059 (get-buffer-window gnus-group-buffer t))
4060 ;; Gotta use windows, because recenter does weird stuff if
4061 ;; the current buffer ain't the displayed window.
4062 (let ((owin (selected-window)))
4063 (select-window (get-buffer-window gnus-group-buffer t))
4064 (when (gnus-group-goto-group group)
4065 (recenter))
4066 (select-window owin)))
4067 ;; Mark this buffer as "prepared".
4068 (setq gnus-newsgroup-prepared t)
4069 (gnus-run-hooks 'gnus-summary-prepared-hook)
4070 (unless (gnus-ephemeral-group-p group)
4071 (gnus-group-update-group group nil t))
4072 t)))))
4073
4074 (defun gnus-summary-auto-select-subject ()
4075 "Select the subject line on initial group entry."
4076 (goto-char (point-min))
4077 (cond
4078 ((eq gnus-auto-select-subject 'best)
4079 (gnus-summary-best-unread-subject))
4080 ((eq gnus-auto-select-subject 'unread)
4081 (gnus-summary-first-unread-subject))
4082 ((eq gnus-auto-select-subject 'unseen)
4083 (gnus-summary-first-unseen-subject))
4084 ((eq gnus-auto-select-subject 'unseen-or-unread)
4085 (gnus-summary-first-unseen-or-unread-subject))
4086 ((eq gnus-auto-select-subject 'first)
4087 ;; Do nothing.
4088 )
4089 ((functionp gnus-auto-select-subject)
4090 (funcall gnus-auto-select-subject))))
4091
4092 (defun gnus-summary-prepare ()
4093 "Generate the summary buffer."
4094 (interactive)
4095 (let ((inhibit-read-only t))
4096 (erase-buffer)
4097 (setq gnus-newsgroup-data nil
4098 gnus-newsgroup-data-reverse nil)
4099 (gnus-run-hooks 'gnus-summary-generate-hook)
4100 ;; Generate the buffer, either with threads or without.
4101 (when gnus-newsgroup-headers
4102 (gnus-summary-prepare-threads
4103 (if gnus-show-threads
4104 (gnus-sort-gathered-threads
4105 (funcall gnus-summary-thread-gathering-function
4106 (gnus-sort-threads
4107 (gnus-cut-threads (gnus-make-threads)))))
4108 ;; Unthreaded display.
4109 (gnus-sort-articles gnus-newsgroup-headers))))
4110 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4111 ;; Call hooks for modifying summary buffer.
4112 (goto-char (point-min))
4113 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4114
4115 (defsubst gnus-general-simplify-subject (subject)
4116 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4117 (setq subject
4118 (cond
4119 ;; Truncate the subject.
4120 (gnus-simplify-subject-functions
4121 (gnus-map-function gnus-simplify-subject-functions subject))
4122 ((numberp gnus-summary-gather-subject-limit)
4123 (setq subject (gnus-simplify-subject-re subject))
4124 (if (> (length subject) gnus-summary-gather-subject-limit)
4125 (substring subject 0 gnus-summary-gather-subject-limit)
4126 subject))
4127 ;; Fuzzily simplify it.
4128 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4129 (gnus-simplify-subject-fuzzy subject))
4130 ;; Just remove the leading "Re:".
4131 (t
4132 (gnus-simplify-subject-re subject))))
4133
4134 (if (and gnus-summary-gather-exclude-subject
4135 (string-match gnus-summary-gather-exclude-subject subject))
4136 nil ; This article shouldn't be gathered
4137 subject))
4138
4139 (defun gnus-summary-simplify-subject-query ()
4140 "Query where the respool algorithm would put this article."
4141 (interactive)
4142 (gnus-summary-select-article)
4143 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4144
4145 (defun gnus-gather-threads-by-subject (threads)
4146 "Gather threads by looking at Subject headers."
4147 (if (not gnus-summary-make-false-root)
4148 threads
4149 (let ((hashtb (gnus-make-hashtable 1024))
4150 (prev threads)
4151 (result threads)
4152 subject hthread whole-subject)
4153 (while threads
4154 (setq subject (gnus-general-simplify-subject
4155 (setq whole-subject (mail-header-subject
4156 (caar threads)))))
4157 (when subject
4158 (if (setq hthread (gnus-gethash subject hashtb))
4159 (progn
4160 ;; We enter a dummy root into the thread, if we
4161 ;; haven't done that already.
4162 (unless (stringp (caar hthread))
4163 (setcar hthread (list whole-subject (car hthread))))
4164 ;; We add this new gathered thread to this gathered
4165 ;; thread.
4166 (setcdr (car hthread)
4167 (nconc (cdar hthread) (list (car threads))))
4168 ;; Remove it from the list of threads.
4169 (setcdr prev (cdr threads))
4170 (setq threads prev))
4171 ;; Enter this thread into the hash table.
4172 (gnus-sethash subject
4173 (if gnus-summary-make-false-root-always
4174 (progn
4175 ;; If you want a dummy root above all
4176 ;; threads...
4177 (setcar threads (list whole-subject
4178 (car threads)))
4179 threads)
4180 threads)
4181 hashtb)))
4182 (setq prev threads)
4183 (setq threads (cdr threads)))
4184 result)))
4185
4186 (defun gnus-gather-threads-by-references (threads)
4187 "Gather threads by looking at References headers."
4188 (let ((idhashtb (gnus-make-hashtable 1024))
4189 (thhashtb (gnus-make-hashtable 1024))
4190 (prev threads)
4191 (result threads)
4192 ids references id gthread gid entered ref)
4193 (while threads
4194 (when (setq references (mail-header-references (caar threads)))
4195 (setq id (mail-header-id (caar threads))
4196 ids (inline (gnus-split-references references))
4197 entered nil)
4198 (while (setq ref (pop ids))
4199 (setq ids (delete ref ids))
4200 (if (not (setq gid (gnus-gethash ref idhashtb)))
4201 (progn
4202 (gnus-sethash ref id idhashtb)
4203 (gnus-sethash id threads thhashtb))
4204 (setq gthread (gnus-gethash gid thhashtb))
4205 (unless entered
4206 ;; We enter a dummy root into the thread, if we
4207 ;; haven't done that already.
4208 (unless (stringp (caar gthread))
4209 (setcar gthread (list (mail-header-subject (caar gthread))
4210 (car gthread))))
4211 ;; We add this new gathered thread to this gathered
4212 ;; thread.
4213 (setcdr (car gthread)
4214 (nconc (cdar gthread) (list (car threads)))))
4215 ;; Add it into the thread hash table.
4216 (gnus-sethash id gthread thhashtb)
4217 (setq entered t)
4218 ;; Remove it from the list of threads.
4219 (setcdr prev (cdr threads))
4220 (setq threads prev))))
4221 (setq prev threads)
4222 (setq threads (cdr threads)))
4223 result))
4224
4225 (defun gnus-sort-gathered-threads (threads)
4226 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4227 (let ((result threads))
4228 (while threads
4229 (when (stringp (caar threads))
4230 (setcdr (car threads)
4231 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4232 (setq threads (cdr threads)))
4233 result))
4234
4235 (defun gnus-thread-loop-p (root thread)
4236 "Say whether ROOT is in THREAD."
4237 (let ((stack (list thread))
4238 (infloop 0)
4239 th)
4240 (while (setq thread (pop stack))
4241 (setq th (cdr thread))
4242 (while (and th
4243 (not (eq (caar th) root)))
4244 (pop th))
4245 (if th
4246 ;; We have found a loop.
4247 (let (ref-dep)
4248 (setcdr thread (delq (car th) (cdr thread)))
4249 (if (boundp (setq ref-dep (intern "none"
4250 gnus-newsgroup-dependencies)))
4251 (setcdr (symbol-value ref-dep)
4252 (nconc (cdr (symbol-value ref-dep))
4253 (list (car th))))
4254 (set ref-dep (list nil (car th))))
4255 (setq infloop 1
4256 stack nil))
4257 ;; Push all the subthreads onto the stack.
4258 (push (cdr thread) stack)))
4259 infloop))
4260
4261 (defun gnus-make-threads ()
4262 "Go through the dependency hashtb and find the roots. Return all threads."
4263 (let (threads)
4264 (while (catch 'infloop
4265 (mapatoms
4266 (lambda (refs)
4267 ;; Deal with self-referencing References loops.
4268 (when (and (car (symbol-value refs))
4269 (not (zerop
4270 (apply
4271 '+
4272 (mapcar
4273 (lambda (thread)
4274 (gnus-thread-loop-p
4275 (car (symbol-value refs)) thread))
4276 (cdr (symbol-value refs)))))))
4277 (setq threads nil)
4278 (throw 'infloop t))
4279 (unless (car (symbol-value refs))
4280 ;; These threads do not refer back to any other
4281 ;; articles, so they're roots.
4282 (setq threads (append (cdr (symbol-value refs)) threads))))
4283 gnus-newsgroup-dependencies)))
4284 threads))
4285
4286 ;; Build the thread tree.
4287 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4288 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4289
4290 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4291 if it was already present.
4292
4293 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4294 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4295 Message-IDs will be renamed to a unique Message-ID before being
4296 entered.
4297
4298 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4299 (let* ((id (mail-header-id header))
4300 (id-dep (and id (intern id dependencies)))
4301 parent-id ref ref-dep ref-header replaced)
4302 ;; Enter this `header' in the `dependencies' table.
4303 (cond
4304 ((not id-dep)
4305 (setq header nil))
4306 ;; The first two cases do the normal part: enter a new `header'
4307 ;; in the `dependencies' table.
4308 ((not (boundp id-dep))
4309 (set id-dep (list header)))
4310 ((null (car (symbol-value id-dep)))
4311 (setcar (symbol-value id-dep) header))
4312
4313 ;; From here the `header' was already present in the
4314 ;; `dependencies' table.
4315 (force-new
4316 ;; Overrides an existing entry;
4317 ;; just set the header part of the entry.
4318 (setcar (symbol-value id-dep) header)
4319 (setq replaced t))
4320
4321 ;; Renames the existing `header' to a unique Message-ID.
4322 ((not gnus-summary-ignore-duplicates)
4323 ;; An article with this Message-ID has already been seen.
4324 ;; We rename the Message-ID.
4325 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4326 (list header))
4327 (mail-header-set-id header id))
4328
4329 ;; The last case ignores an existing entry, except it adds any
4330 ;; additional Xrefs (in case the two articles came from different
4331 ;; servers.
4332 ;; Also sets `header' to nil meaning that the `dependencies'
4333 ;; table was *not* modified.
4334 (t
4335 (mail-header-set-xref
4336 (car (symbol-value id-dep))
4337 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4338 "")
4339 (or (mail-header-xref header) "")))
4340 (setq header nil)))
4341
4342 (when (and header (not replaced))
4343 ;; First check that we are not creating a References loop.
4344 (setq parent-id (gnus-parent-id (mail-header-references header)))
4345 (setq ref parent-id)
4346 (while (and ref
4347 (setq ref-dep (intern-soft ref dependencies))
4348 (boundp ref-dep)
4349 (setq ref-header (car (symbol-value ref-dep))))
4350 (if (string= id ref)
4351 ;; Yuk! This is a reference loop. Make the article be a
4352 ;; root article.
4353 (progn
4354 (mail-header-set-references (car (symbol-value id-dep)) "none")
4355 (setq ref nil)
4356 (setq parent-id nil))
4357 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4358 (setq ref-dep (intern (or parent-id "none") dependencies))
4359 (if (boundp ref-dep)
4360 (setcdr (symbol-value ref-dep)
4361 (nconc (cdr (symbol-value ref-dep))
4362 (list (symbol-value id-dep))))
4363 (set ref-dep (list nil (symbol-value id-dep)))))
4364 header))
4365
4366 (defun gnus-extract-message-id-from-in-reply-to (string)
4367 (if (string-match "<[^>]+>" string)
4368 (substring string (match-beginning 0) (match-end 0))
4369 nil))
4370
4371 (defun gnus-build-sparse-threads ()
4372 (let ((headers gnus-newsgroup-headers)
4373 (mail-parse-charset gnus-newsgroup-charset)
4374 (gnus-summary-ignore-duplicates t)
4375 header references generation relations
4376 subject child end new-child date)
4377 ;; First we create an alist of generations/relations, where
4378 ;; generations is how much we trust the relation, and the relation
4379 ;; is parent/child.
4380 (gnus-message 7 "Making sparse threads...")
4381 (save-excursion
4382 (nnheader-set-temp-buffer " *gnus sparse threads*")
4383 (while (setq header (pop headers))
4384 (when (and (setq references (mail-header-references header))
4385 (not (string= references "")))
4386 (insert references)
4387 (setq child (mail-header-id header)
4388 subject (mail-header-subject header)
4389 date (mail-header-date header)
4390 generation 0)
4391 (while (search-backward ">" nil t)
4392 (setq end (1+ (point)))
4393 (when (search-backward "<" nil t)
4394 (setq new-child (buffer-substring (point) end))
4395 (push (list (incf generation)
4396 child (setq child new-child)
4397 subject date)
4398 relations)))
4399 (when child
4400 (push (list (1+ generation) child nil subject) relations))
4401 (erase-buffer)))
4402 (kill-buffer (current-buffer)))
4403 ;; Sort over trustworthiness.
4404 (dolist (relation (sort relations 'car-less-than-car))
4405 (when (gnus-dependencies-add-header
4406 (make-full-mail-header
4407 gnus-reffed-article-number
4408 (nth 3 relation) "" (or (nth 4 relation) "")
4409 (nth 1 relation)
4410 (or (nth 2 relation) "") 0 0 "")
4411 gnus-newsgroup-dependencies nil)
4412 (push gnus-reffed-article-number gnus-newsgroup-limit)
4413 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4414 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4415 gnus-newsgroup-reads)
4416 (decf gnus-reffed-article-number)))
4417 (gnus-message 7 "Making sparse threads...done")))
4418
4419 (defun gnus-build-old-threads ()
4420 ;; Look at all the articles that refer back to old articles, and
4421 ;; fetch the headers for the articles that aren't there. This will
4422 ;; build complete threads - if the roots haven't been expired by the
4423 ;; server, that is.
4424 (let ((mail-parse-charset gnus-newsgroup-charset)
4425 id heads)
4426 (mapatoms
4427 (lambda (refs)
4428 (when (not (car (symbol-value refs)))
4429 (setq heads (cdr (symbol-value refs)))
4430 (while heads
4431 (if (memq (mail-header-number (caar heads))
4432 gnus-newsgroup-dormant)
4433 (setq heads (cdr heads))
4434 (setq id (symbol-name refs))
4435 (while (and (setq id (gnus-build-get-header id))
4436 (not (car (gnus-id-to-thread id)))))
4437 (setq heads nil)))))
4438 gnus-newsgroup-dependencies)))
4439
4440 (defsubst gnus-remove-odd-characters (string)
4441 "Translate STRING into something that doesn't contain weird characters."
4442 (subst-char-in-string
4443 ?\r ?\-
4444 (subst-char-in-string ?\n ?\- string t) t))
4445
4446 ;; This function has to be called with point after the article number
4447 ;; on the beginning of the line.
4448 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4449 (let ((eol (point-at-eol))
4450 (buffer (current-buffer))
4451 header references in-reply-to)
4452
4453 ;; overview: [num subject from date id refs chars lines misc]
4454 (unwind-protect
4455 (let (x)
4456 (narrow-to-region (point) eol)
4457 (unless (eobp)
4458 (forward-char))
4459
4460 (setq header
4461 (make-full-mail-header
4462 number ; number
4463 (condition-case () ; subject
4464 (gnus-remove-odd-characters
4465 (funcall gnus-decode-encoded-word-function
4466 (setq x (nnheader-nov-field))))
4467 (error x))
4468 (condition-case () ; from
4469 (gnus-remove-odd-characters
4470 (funcall gnus-decode-encoded-address-function
4471 (setq x (nnheader-nov-field))))
4472 (error x))
4473 (nnheader-nov-field) ; date
4474 (nnheader-nov-read-message-id number) ; id
4475 (setq references (nnheader-nov-field)) ; refs
4476 (nnheader-nov-read-integer) ; chars
4477 (nnheader-nov-read-integer) ; lines
4478 (unless (eobp)
4479 (if (looking-at "Xref: ")
4480 (goto-char (match-end 0)))
4481 (nnheader-nov-field)) ; Xref
4482 (nnheader-nov-parse-extra)))) ; extra
4483
4484 (widen))
4485
4486 (when (and (string= references "")
4487 (setq in-reply-to (mail-header-extra header))
4488 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4489 (mail-header-set-references
4490 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4491
4492 (when gnus-alter-header-function
4493 (funcall gnus-alter-header-function header))
4494 (gnus-dependencies-add-header header dependencies force-new)))
4495
4496 (defun gnus-build-get-header (id)
4497 "Look through the buffer of NOV lines and find the header to ID.
4498 Enter this line into the dependencies hash table, and return
4499 the id of the parent article (if any)."
4500 (let ((deps gnus-newsgroup-dependencies)
4501 found header)
4502 (prog1
4503 (with-current-buffer nntp-server-buffer
4504 (let ((case-fold-search nil))
4505 (goto-char (point-min))
4506 (while (and (not found)
4507 (search-forward id nil t))
4508 (beginning-of-line)
4509 (setq found (looking-at
4510 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4511 (regexp-quote id))))
4512 (or found (beginning-of-line 2)))
4513 (when found
4514 (beginning-of-line)
4515 (and
4516 (setq header (gnus-nov-parse-line
4517 (read (current-buffer)) deps))
4518 (gnus-parent-id (mail-header-references header))))))
4519 (when header
4520 (let ((number (mail-header-number header)))
4521 (push number gnus-newsgroup-limit)
4522 (push header gnus-newsgroup-headers)
4523 (if (memq number gnus-newsgroup-unselected)
4524 (progn
4525 (setq gnus-newsgroup-unreads
4526 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4527 number))
4528 (setq gnus-newsgroup-unselected
4529 (delq number gnus-newsgroup-unselected)))
4530 (push number gnus-newsgroup-ancient)))))))
4531
4532 (defun gnus-build-all-threads ()
4533 "Read all the headers."
4534 (let ((gnus-summary-ignore-duplicates t)
4535 (mail-parse-charset gnus-newsgroup-charset)
4536 (dependencies gnus-newsgroup-dependencies)
4537 header article)
4538 (with-current-buffer nntp-server-buffer
4539 (let ((case-fold-search nil))
4540 (goto-char (point-min))
4541 (while (not (eobp))
4542 (ignore-errors
4543 (setq article (read (current-buffer))
4544 header (gnus-nov-parse-line article dependencies t)))
4545 (when header
4546 (with-current-buffer gnus-summary-buffer
4547 (push header gnus-newsgroup-headers)
4548 (if (memq (setq article (mail-header-number header))
4549 gnus-newsgroup-unselected)
4550 (progn
4551 (setq gnus-newsgroup-unreads
4552 (gnus-add-to-sorted-list
4553 gnus-newsgroup-unreads article))
4554 (setq gnus-newsgroup-unselected
4555 (delq article gnus-newsgroup-unselected)))
4556 (push article gnus-newsgroup-ancient)))
4557 (forward-line 1)))))))
4558
4559 (defun gnus-summary-update-article-line (article header)
4560 "Update the line for ARTICLE using HEADER."
4561 (let* ((id (mail-header-id header))
4562 (thread (gnus-id-to-thread id)))
4563 (unless thread
4564 (error "Article in no thread"))
4565 ;; Update the thread.
4566 (setcar thread header)
4567 (gnus-summary-goto-subject article)
4568 (let* ((datal (gnus-data-find-list article))
4569 (data (car datal))
4570 (inhibit-read-only t)
4571 (level (gnus-summary-thread-level)))
4572 (gnus-delete-line)
4573 (let ((inserted (- (point)
4574 (progn
4575 (gnus-summary-insert-line
4576 header level nil
4577 (memq article gnus-newsgroup-undownloaded)
4578 (gnus-article-mark article)
4579 (memq article gnus-newsgroup-replied)
4580 (memq article gnus-newsgroup-expirable)
4581 ;; Only insert the Subject string when it's different
4582 ;; from the previous Subject string.
4583 (if (and
4584 gnus-show-threads
4585 (gnus-subject-equal
4586 (condition-case ()
4587 (mail-header-subject
4588 (gnus-data-header
4589 (cadr
4590 (gnus-data-find-list
4591 article
4592 (gnus-data-list t)))))
4593 ;; Error on the side of excessive subjects.
4594 (error ""))
4595 (mail-header-subject header)))
4596 ""
4597 (mail-header-subject header))
4598 nil (cdr (assq article gnus-newsgroup-scored))
4599 (memq article gnus-newsgroup-processable))
4600 (point)))))
4601 (when (cdr datal)
4602 (gnus-data-update-list
4603 (cdr datal)
4604 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4605
4606 (defun gnus-summary-update-article (article &optional iheader)
4607 "Update ARTICLE in the summary buffer."
4608 (set-buffer gnus-summary-buffer)
4609 (let* ((header (gnus-summary-article-header article))
4610 (id (mail-header-id header))
4611 (data (gnus-data-find article))
4612 (thread (gnus-id-to-thread id))
4613 (references (mail-header-references header))
4614 (parent
4615 (gnus-id-to-thread
4616 (or (gnus-parent-id
4617 (when (and references
4618 (not (equal "" references)))
4619 references))
4620 "none")))
4621 (inhibit-read-only t)
4622 (old (car thread)))
4623 (when thread
4624 (unless iheader
4625 (setcar thread nil)
4626 (when parent
4627 (delq thread parent)))
4628 (if (gnus-summary-insert-subject id header)
4629 ;; Set the (possibly) new article number in the data structure.
4630 (gnus-data-set-number data (gnus-id-to-article id))
4631 (setcar thread old)
4632 nil))))
4633
4634 (defun gnus-rebuild-thread (id &optional line)
4635 "Rebuild the thread containing ID.
4636 If LINE, insert the rebuilt thread starting on line LINE."
4637 (let ((inhibit-read-only t)
4638 old-pos current thread data)
4639 (if (not gnus-show-threads)
4640 (setq thread (list (car (gnus-id-to-thread id))))
4641 ;; Get the thread this article is part of.
4642 (setq thread (gnus-remove-thread id)))
4643 (setq old-pos (point-at-bol))
4644 (setq current (save-excursion
4645 (and (re-search-backward "[\r\n]" nil t)
4646 (gnus-summary-article-number))))
4647 ;; If this is a gathered thread, we have to go some re-gathering.
4648 (when (stringp (car thread))
4649 (let ((subject (car thread))
4650 roots thr)
4651 (setq thread (cdr thread))
4652 (while thread
4653 (unless (memq (setq thr (gnus-id-to-thread
4654 (gnus-root-id
4655 (mail-header-id (caar thread)))))
4656 roots)
4657 (push thr roots))
4658 (setq thread (cdr thread)))
4659 ;; We now have all (unique) roots.
4660 (if (= (length roots) 1)
4661 ;; All the loose roots are now one solid root.
4662 (setq thread (car roots))
4663 (setq thread (cons subject (gnus-sort-threads roots))))))
4664 (let (threads)
4665 ;; We then insert this thread into the summary buffer.
4666 (when line
4667 (goto-char (point-min))
4668 (forward-line (1- line)))
4669 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4670 (if gnus-show-threads
4671 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4672 (gnus-summary-prepare-unthreaded thread))
4673 (setq data (nreverse gnus-newsgroup-data))
4674 (setq threads gnus-newsgroup-threads))
4675 ;; We splice the new data into the data structure.
4676 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4677 ;;!!! then we want to insert at the beginning of the buffer.
4678 ;;!!! That happens to be true with Gnus now, but that may
4679 ;;!!! change in the future. Perhaps.
4680 (gnus-data-enter-list
4681 (if line nil current) data (- (point) old-pos))
4682 (setq gnus-newsgroup-threads
4683 (nconc threads gnus-newsgroup-threads))
4684 (gnus-data-compute-positions))))
4685
4686 (defun gnus-number-to-header (number)
4687 "Return the header for article NUMBER."
4688 (let ((headers gnus-newsgroup-headers))
4689 (while (and headers
4690 (not (= number (mail-header-number (car headers)))))
4691 (pop headers))
4692 (when headers
4693 (car headers))))
4694
4695 (defun gnus-parent-headers (in-headers &optional generation)
4696 "Return the headers of the GENERATIONth parent of HEADERS."
4697 (unless generation
4698 (setq generation 1))
4699 (let ((parent t)
4700 (headers in-headers)
4701 references)
4702 (while (and parent
4703 (not (zerop generation))
4704 (setq references (mail-header-references headers)))
4705 (setq headers (if (and references
4706 (setq parent (gnus-parent-id references)))
4707 (car (gnus-id-to-thread parent))
4708 nil))
4709 (decf generation))
4710 (and (not (eq headers in-headers))
4711 headers)))
4712
4713 (defun gnus-id-to-thread (id)
4714 "Return the (sub-)thread where ID appears."
4715 (gnus-gethash id gnus-newsgroup-dependencies))
4716
4717 (defun gnus-id-to-article (id)
4718 "Return the article number of ID."
4719 (let ((thread (gnus-id-to-thread id)))
4720 (when (and thread
4721 (car thread))
4722 (mail-header-number (car thread)))))
4723
4724 (defun gnus-id-to-header (id)
4725 "Return the article headers of ID."
4726 (car (gnus-id-to-thread id)))
4727
4728 (defun gnus-article-displayed-root-p (article)
4729 "Say whether ARTICLE is a root(ish) article."
4730 (let ((level (gnus-summary-thread-level article))
4731 (refs (mail-header-references (gnus-summary-article-header article)))
4732 particle)
4733 (cond
4734 ((null level) nil)
4735 ((zerop level) t)
4736 ((null refs) t)
4737 ((null (gnus-parent-id refs)) t)
4738 ((and (= 1 level)
4739 (null (setq particle (gnus-id-to-article
4740 (gnus-parent-id refs))))
4741 (null (gnus-summary-thread-level particle)))))))
4742
4743 (defun gnus-root-id (id)
4744 "Return the id of the root of the thread where ID appears."
4745 (let (last-id prev)
4746 (while (and id (setq prev (car (gnus-id-to-thread id))))
4747 (setq last-id id
4748 id (gnus-parent-id (mail-header-references prev))))
4749 last-id))
4750
4751 (defun gnus-articles-in-thread (thread)
4752 "Return the list of articles in THREAD."
4753 (cons (mail-header-number (car thread))
4754 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4755
4756 (defun gnus-remove-thread (id &optional dont-remove)
4757 "Remove the thread that has ID in it."
4758 (let (headers thread last-id)
4759 ;; First go up in this thread until we find the root.
4760 (setq last-id (gnus-root-id id)
4761 headers (message-flatten-list (gnus-id-to-thread last-id)))
4762 ;; We have now found the real root of this thread. It might have
4763 ;; been gathered into some loose thread, so we have to search
4764 ;; through the threads to find the thread we wanted.
4765 (let ((threads gnus-newsgroup-threads)
4766 sub)
4767 (while threads
4768 (setq sub (car threads))
4769 (if (stringp (car sub))
4770 ;; This is a gathered thread, so we look at the roots
4771 ;; below it to find whether this article is in this
4772 ;; gathered root.
4773 (progn
4774 (setq sub (cdr sub))
4775 (while sub
4776 (when (member (caar sub) headers)
4777 (setq thread (car threads)
4778 threads nil
4779 sub nil))
4780 (setq sub (cdr sub))))
4781 ;; It's an ordinary thread, so we check it.
4782 (when (eq (car sub) (car headers))
4783 (setq thread sub
4784 threads nil)))
4785 (setq threads (cdr threads)))
4786 ;; If this article is in no thread, then it's a root.
4787 (if thread
4788 (unless dont-remove
4789 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4790 (setq thread (gnus-id-to-thread last-id)))
4791 (when thread
4792 (prog1
4793 thread ; We return this thread.
4794 (unless dont-remove
4795 (if (stringp (car thread))
4796 (progn
4797 ;; If we use dummy roots, then we have to remove the
4798 ;; dummy root as well.
4799 (when (eq gnus-summary-make-false-root 'dummy)
4800 ;; We go to the dummy root by going to
4801 ;; the first sub-"thread", and then one line up.
4802 (gnus-summary-goto-article
4803 (mail-header-number (caadr thread)))
4804 (forward-line -1)
4805 (gnus-delete-line)
4806 (gnus-data-compute-positions))
4807 (setq thread (cdr thread))
4808 (while thread
4809 (gnus-remove-thread-1 (car thread))
4810 (setq thread (cdr thread))))
4811 (gnus-remove-thread-1 thread))))))))
4812
4813 (defun gnus-remove-thread-1 (thread)
4814 "Remove the thread THREAD recursively."
4815 (let ((number (mail-header-number (pop thread)))
4816 d)
4817 (setq thread (reverse thread))
4818 (while thread
4819 (gnus-remove-thread-1 (pop thread)))
4820 (when (setq d (gnus-data-find number))
4821 (goto-char (gnus-data-pos d))
4822 (gnus-summary-show-thread)
4823 (gnus-data-remove
4824 number
4825 (- (point-at-bol)
4826 (prog1
4827 (1+ (point-at-eol))
4828 (gnus-delete-line)))))))
4829
4830 (defun gnus-sort-threads-recursive (threads func)
4831 ;; Responsible for sorting the root articles of threads.
4832 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4833 'gnus-thread-sort-functions)
4834 func
4835 (gnus-make-sort-function
4836 gnus-subthread-sort-functions))))
4837 (sort (mapcar (lambda (thread)
4838 (cons (car thread)
4839 (and (cdr thread)
4840 (gnus-sort-subthreads-recursive
4841 (cdr thread) subthread-sort-func))))
4842 threads) func)))
4843
4844 (defun gnus-sort-subthreads-recursive (threads func)
4845 ;; Responsible for sorting subthreads.
4846 (sort (mapcar (lambda (thread)
4847 (cons (car thread)
4848 (and (cdr thread)
4849 (gnus-sort-subthreads-recursive (cdr thread) func))))
4850 threads) func))
4851
4852 (defun gnus-sort-threads-loop (threads func)
4853 (let* ((superthread (cons nil threads))
4854 (stack (list (cons superthread threads)))
4855 remaining-threads thread)
4856 (while stack
4857 (setq remaining-threads (cdr (car stack)))
4858 (if remaining-threads
4859 (progn (setq thread (car remaining-threads))
4860 (setcdr (car stack) (cdr remaining-threads))
4861 (if (cdr thread)
4862 (push (cons thread (cdr thread)) stack)))
4863 (setq thread (caar stack))
4864 (setcdr thread (sort (cdr thread) func))
4865 (pop stack)))
4866 (cdr superthread)))
4867
4868 (defun gnus-sort-threads (threads)
4869 "Sort THREADS."
4870 (if (not gnus-thread-sort-functions)
4871 threads
4872 (gnus-message 8 "Sorting threads...")
4873 (prog1
4874 (condition-case nil
4875 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4876 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4877 (gnus-sort-threads-recursive threads sort-func))
4878 ;; Even after binding max-lisp-eval-depth, the recursive
4879 ;; sorter might fail for very long threads. In that case,
4880 ;; try using a (less well-tested) non-recursive sorter.
4881 (error (gnus-message 9 "Sorting threads with loop...")
4882 (gnus-sort-threads-loop
4883 threads (gnus-make-sort-function
4884 gnus-thread-sort-functions))))
4885 (gnus-message 8 "Sorting threads...done"))))
4886
4887 (defun gnus-sort-articles (articles)
4888 "Sort ARTICLES."
4889 (when gnus-article-sort-functions
4890 (gnus-message 7 "Sorting articles...")
4891 (prog1
4892 (setq gnus-newsgroup-headers
4893 (sort articles (gnus-make-sort-function
4894 gnus-article-sort-functions)))
4895 (gnus-message 7 "Sorting articles...done"))))
4896
4897 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4898 (defmacro gnus-thread-header (thread)
4899 "Return header of first article in THREAD.
4900 Note that THREAD must never, ever be anything else than a variable -
4901 using some other form will lead to serious barfage."
4902 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4903 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4904 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4905 (vector thread) 2))
4906
4907 (defsubst gnus-article-sort-by-number (h1 h2)
4908 "Sort articles by article number."
4909 (< (mail-header-number h1)
4910 (mail-header-number h2)))
4911
4912 (defun gnus-thread-sort-by-number (h1 h2)
4913 "Sort threads by root article number."
4914 (gnus-article-sort-by-number
4915 (gnus-thread-header h1) (gnus-thread-header h2)))
4916
4917 (defsubst gnus-article-sort-by-random (h1 h2)
4918 "Sort articles randomly."
4919 (zerop (random 2)))
4920
4921 (defun gnus-thread-sort-by-random (h1 h2)
4922 "Sort threads randomly."
4923 (gnus-article-sort-by-random
4924 (gnus-thread-header h1) (gnus-thread-header h2)))
4925
4926 (defsubst gnus-article-sort-by-lines (h1 h2)
4927 "Sort articles by article Lines header."
4928 (< (mail-header-lines h1)
4929 (mail-header-lines h2)))
4930
4931 (defun gnus-thread-sort-by-lines (h1 h2)
4932 "Sort threads by root article Lines header."
4933 (gnus-article-sort-by-lines
4934 (gnus-thread-header h1) (gnus-thread-header h2)))
4935
4936 (defsubst gnus-article-sort-by-chars (h1 h2)
4937 "Sort articles by octet length."
4938 (< (mail-header-chars h1)
4939 (mail-header-chars h2)))
4940
4941 (defun gnus-thread-sort-by-chars (h1 h2)
4942 "Sort threads by root article octet length."
4943 (gnus-article-sort-by-chars
4944 (gnus-thread-header h1) (gnus-thread-header h2)))
4945
4946 (defsubst gnus-article-sort-by-author (h1 h2)
4947 "Sort articles by root author."
4948 (gnus-string<
4949 (let ((extract (funcall
4950 gnus-extract-address-components
4951 (mail-header-from h1))))
4952 (or (car extract) (cadr extract) ""))
4953 (let ((extract (funcall
4954 gnus-extract-address-components
4955 (mail-header-from h2))))
4956 (or (car extract) (cadr extract) ""))))
4957
4958 (defun gnus-thread-sort-by-author (h1 h2)
4959 "Sort threads by root author."
4960 (gnus-article-sort-by-author
4961 (gnus-thread-header h1) (gnus-thread-header h2)))
4962
4963 (defsubst gnus-article-sort-by-recipient (h1 h2)
4964 "Sort articles by recipient."
4965 (gnus-string<
4966 (let ((extract (funcall
4967 gnus-extract-address-components
4968 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4969 (or (car extract) (cadr extract)))
4970 (let ((extract (funcall
4971 gnus-extract-address-components
4972 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4973 (or (car extract) (cadr extract)))))
4974
4975 (defun gnus-thread-sort-by-recipient (h1 h2)
4976 "Sort threads by root recipient."
4977 (gnus-article-sort-by-recipient
4978 (gnus-thread-header h1) (gnus-thread-header h2)))
4979
4980 (defsubst gnus-article-sort-by-subject (h1 h2)
4981 "Sort articles by root subject."
4982 (gnus-string<
4983 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4984 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4985
4986 (defun gnus-thread-sort-by-subject (h1 h2)
4987 "Sort threads by root subject."
4988 (gnus-article-sort-by-subject
4989 (gnus-thread-header h1) (gnus-thread-header h2)))
4990
4991 (defsubst gnus-article-sort-by-date (h1 h2)
4992 "Sort articles by root article date."
4993 (time-less-p
4994 (gnus-date-get-time (mail-header-date h1))
4995 (gnus-date-get-time (mail-header-date h2))))
4996
4997 (defun gnus-thread-sort-by-date (h1 h2)
4998 "Sort threads by root article date."
4999 (gnus-article-sort-by-date
5000 (gnus-thread-header h1) (gnus-thread-header h2)))
5001
5002 (defsubst gnus-article-sort-by-score (h1 h2)
5003 "Sort articles by root article score.
5004 Unscored articles will be counted as having a score of zero."
5005 (> (or (cdr (assq (mail-header-number h1)
5006 gnus-newsgroup-scored))
5007 gnus-summary-default-score 0)
5008 (or (cdr (assq (mail-header-number h2)
5009 gnus-newsgroup-scored))
5010 gnus-summary-default-score 0)))
5011
5012 (defun gnus-thread-sort-by-score (h1 h2)
5013 "Sort threads by root article score."
5014 (gnus-article-sort-by-score
5015 (gnus-thread-header h1) (gnus-thread-header h2)))
5016
5017 (defun gnus-thread-sort-by-total-score (h1 h2)
5018 "Sort threads by the sum of all scores in the thread.
5019 Unscored articles will be counted as having a score of zero."
5020 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5021
5022 (defun gnus-thread-total-score (thread)
5023 ;; This function find the total score of THREAD.
5024 (cond
5025 ((null thread)
5026 0)
5027 ((consp thread)
5028 (if (stringp (car thread))
5029 (apply gnus-thread-score-function 0
5030 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5031 (gnus-thread-total-score-1 thread)))
5032 (t
5033 (gnus-thread-total-score-1 (list thread)))))
5034
5035 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5036 "Sort articles by number."
5037 (gnus-article-sort-by-number h1 h2))
5038
5039 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5040 "Sort threads such that the thread with the most recently arrived article comes first."
5041 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5042
5043 (defun gnus-thread-highest-number (thread)
5044 "Return the highest article number in THREAD."
5045 (apply 'max (mapcar (lambda (header)
5046 (mail-header-number header))
5047 (message-flatten-list thread))))
5048
5049 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5050 "Sort articles by number."
5051 (gnus-article-sort-by-date h1 h2))
5052
5053 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5054 "Sort threads such that the thread with the most recently dated article comes first."
5055 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5056
5057 ; Since this is called not only to sort the top-level threads, but
5058 ; also in recursive sorts to order the articles within a thread, each
5059 ; article will be processed many times. Thus it speeds things up
5060 ; quite a bit to use gnus-date-get-time, which caches the time value.
5061 (defun gnus-thread-latest-date (thread)
5062 "Return the highest article date in THREAD."
5063 (apply 'max
5064 (mapcar (lambda (header) (float-time
5065 (gnus-date-get-time
5066 (mail-header-date header))))
5067 (message-flatten-list thread))))
5068
5069 (defun gnus-thread-total-score-1 (root)
5070 ;; This function find the total score of the thread below ROOT.
5071 (setq root (car root))
5072 (apply gnus-thread-score-function
5073 (or (append
5074 (mapcar 'gnus-thread-total-score
5075 (cdr (gnus-id-to-thread (mail-header-id root))))
5076 (when (> (mail-header-number root) 0)
5077 (list (or (cdr (assq (mail-header-number root)
5078 gnus-newsgroup-scored))
5079 gnus-summary-default-score 0))))
5080 (list gnus-summary-default-score)
5081 '(0))))
5082
5083 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5084 (defvar gnus-tmp-prev-subject nil)
5085 (defvar gnus-tmp-false-parent nil)
5086 (defvar gnus-tmp-root-expunged nil)
5087 (defvar gnus-tmp-dummy-line nil)
5088
5089 (defun gnus-extra-header (type &optional header)
5090 "Return the extra header of TYPE."
5091 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5092 ""))
5093
5094 (defvar gnus-tmp-thread-tree-header-string "")
5095
5096 (defcustom gnus-sum-thread-tree-root "> "
5097 "With %B spec, used for the root of a thread.
5098 If nil, use subject instead."
5099 :version "22.1"
5100 :type '(radio (const :format "%v " nil) string)
5101 :group 'gnus-thread)
5102
5103 (defcustom gnus-sum-thread-tree-false-root "> "
5104 "With %B spec, used for a false root of a thread.
5105 If nil, use subject instead."
5106 :version "22.1"
5107 :type '(radio (const :format "%v " nil) string)
5108 :group 'gnus-thread)
5109
5110 (defcustom gnus-sum-thread-tree-single-indent ""
5111 "With %B spec, used for a thread with just one message.
5112 If nil, use subject instead."
5113 :version "22.1"
5114 :type '(radio (const :format "%v " nil) string)
5115 :group 'gnus-thread)
5116
5117 (defcustom gnus-sum-thread-tree-vertical "| "
5118 "With %B spec, used for drawing a vertical line."
5119 :version "22.1"
5120 :type 'string
5121 :group 'gnus-thread)
5122
5123 (defcustom gnus-sum-thread-tree-indent " "
5124 "With %B spec, used for indenting."
5125 :version "22.1"
5126 :type 'string
5127 :group 'gnus-thread)
5128
5129 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5130 "With %B spec, used for a leaf with brothers."
5131 :version "22.1"
5132 :type 'string
5133 :group 'gnus-thread)
5134
5135 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5136 "With %B spec, used for a leaf without brothers."
5137 :version "22.1"
5138 :type 'string
5139 :group 'gnus-thread)
5140
5141 (defcustom gnus-summary-display-while-building nil
5142 "If non-nil, show and update the summary buffer as it's being built.
5143 If the value is t, update the buffer after every line is inserted. If
5144 the value is an integer (N), update the display every N lines."
5145 :version "22.1"
5146 :group 'gnus-thread
5147 :type '(choice (const :tag "off" nil)
5148 number
5149 (const :tag "frequently" t)))
5150
5151 (defun gnus-summary-prepare-threads (threads)
5152 "Prepare summary buffer from THREADS and indentation LEVEL.
5153 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5154 or a straight list of headers."
5155 (gnus-message 7 "Generating summary...")
5156
5157 (setq gnus-newsgroup-threads threads)
5158 (beginning-of-line)
5159
5160 (let ((gnus-tmp-level 0)
5161 (default-score (or gnus-summary-default-score 0))
5162 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5163 (building-line-count gnus-summary-display-while-building)
5164 (building-count (integerp gnus-summary-display-while-building))
5165 thread number subject stack state gnus-tmp-gathered beg-match
5166 new-roots gnus-tmp-new-adopts thread-end simp-subject
5167 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5168 gnus-tmp-replied gnus-tmp-subject-or-nil
5169 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5170 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5171 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5172 tree-stack)
5173
5174 (setq gnus-tmp-prev-subject nil
5175 gnus-tmp-thread-tree-header-string "")
5176
5177 (if (vectorp (car threads))
5178 ;; If this is a straight (sic) list of headers, then a
5179 ;; threaded summary display isn't required, so we just create
5180 ;; an unthreaded one.
5181 (gnus-summary-prepare-unthreaded threads)
5182
5183 ;; Do the threaded display.
5184
5185 (if gnus-summary-display-while-building
5186 (switch-to-buffer (buffer-name)))
5187 (while (or threads stack gnus-tmp-new-adopts new-roots)
5188
5189 (if (and (= gnus-tmp-level 0)
5190 (or (not stack)
5191 (= (caar stack) 0))
5192 (not gnus-tmp-false-parent)
5193 (or gnus-tmp-new-adopts new-roots))
5194 (if gnus-tmp-new-adopts
5195 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5196 thread (list (car gnus-tmp-new-adopts))
5197 gnus-tmp-header (caar thread)
5198 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5199 (when new-roots
5200 (setq thread (list (car new-roots))
5201 gnus-tmp-header (caar thread)
5202 new-roots (cdr new-roots))))
5203
5204 (if threads
5205 ;; If there are some threads, we do them before the
5206 ;; threads on the stack.
5207 (setq thread threads
5208 gnus-tmp-header (caar thread))
5209 ;; There were no current threads, so we pop something off
5210 ;; the stack.
5211 (setq state (car stack)
5212 gnus-tmp-level (car state)
5213 tree-stack (cadr state)
5214 thread (caddr state)
5215 stack (cdr stack)
5216 gnus-tmp-header (caar thread))))
5217
5218 (setq gnus-tmp-false-parent nil)
5219 (setq gnus-tmp-root-expunged nil)
5220 (setq thread-end nil)
5221
5222 (if (stringp gnus-tmp-header)
5223 ;; The header is a dummy root.
5224 (cond
5225 ((eq gnus-summary-make-false-root 'adopt)
5226 ;; We let the first article adopt the rest.
5227 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5228 (cddar thread)))
5229 (setq gnus-tmp-gathered
5230 (nconc (mapcar
5231 (lambda (h) (mail-header-number (car h)))
5232 (cddar thread))
5233 gnus-tmp-gathered))
5234 (setq thread (cons (list (caar thread)
5235 (cadar thread))
5236 (cdr thread)))
5237 (setq gnus-tmp-level -1
5238 gnus-tmp-false-parent t))
5239 ((eq gnus-summary-make-false-root 'empty)
5240 ;; We print adopted articles with empty subject fields.
5241 (setq gnus-tmp-gathered
5242 (nconc (mapcar
5243 (lambda (h) (mail-header-number (car h)))
5244 (cddar thread))
5245 gnus-tmp-gathered))
5246 (setq gnus-tmp-level -1))
5247 ((eq gnus-summary-make-false-root 'dummy)
5248 ;; We remember that we probably want to output a dummy
5249 ;; root.
5250 (setq gnus-tmp-dummy-line gnus-tmp-header)
5251 (setq gnus-tmp-prev-subject gnus-tmp-header))
5252 (t
5253 ;; We do not make a root for the gathered
5254 ;; sub-threads at all.
5255 (setq gnus-tmp-level -1)))
5256
5257 (setq number (mail-header-number gnus-tmp-header)
5258 subject (mail-header-subject gnus-tmp-header)
5259 simp-subject (gnus-simplify-subject-fully subject))
5260
5261 (cond
5262 ;; If the thread has changed subject, we might want to make
5263 ;; this subthread into a root.
5264 ((and (null gnus-thread-ignore-subject)
5265 (not (zerop gnus-tmp-level))
5266 gnus-tmp-prev-subject
5267 (not (string= gnus-tmp-prev-subject simp-subject)))
5268 (setq new-roots (nconc new-roots (list (car thread)))
5269 thread-end t
5270 gnus-tmp-header nil))
5271 ;; If the article lies outside the current limit,
5272 ;; then we do not display it.
5273 ((not (memq number gnus-newsgroup-limit))
5274 (setq gnus-tmp-gathered
5275 (nconc (mapcar
5276 (lambda (h) (mail-header-number (car h)))
5277 (cdar thread))
5278 gnus-tmp-gathered))
5279 (setq gnus-tmp-new-adopts (if (cdar thread)
5280 (append gnus-tmp-new-adopts
5281 (cdar thread))
5282 gnus-tmp-new-adopts)
5283 thread-end t
5284 gnus-tmp-header nil)
5285 (when (zerop gnus-tmp-level)
5286 (setq gnus-tmp-root-expunged t)))
5287 ;; Perhaps this article is to be marked as read?
5288 ((and gnus-summary-mark-below
5289 (< (or (cdr (assq number gnus-newsgroup-scored))
5290 default-score)
5291 gnus-summary-mark-below)
5292 ;; Don't touch sparse articles.
5293 (not (gnus-summary-article-sparse-p number))
5294 (not (gnus-summary-article-ancient-p number)))
5295 (setq gnus-newsgroup-unreads
5296 (delq number gnus-newsgroup-unreads))
5297 (if gnus-newsgroup-auto-expire
5298 (setq gnus-newsgroup-expirable
5299 (gnus-add-to-sorted-list
5300 gnus-newsgroup-expirable number))
5301 (push (cons number gnus-low-score-mark)
5302 gnus-newsgroup-reads))))
5303
5304 (when gnus-tmp-header
5305 ;; We may have an old dummy line to output before this
5306 ;; article.
5307 (when (and gnus-tmp-dummy-line
5308 (gnus-subject-equal
5309 gnus-tmp-dummy-line
5310 (mail-header-subject gnus-tmp-header)))
5311 (gnus-summary-insert-dummy-line
5312 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5313 (setq gnus-tmp-dummy-line nil))
5314
5315 ;; Compute the mark.
5316 (setq gnus-tmp-unread (gnus-article-mark number))
5317
5318 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5319 gnus-tmp-header gnus-tmp-level)
5320 gnus-newsgroup-data)
5321
5322 ;; Actually insert the line.
5323 (setq
5324 gnus-tmp-subject-or-nil
5325 (cond
5326 ((and gnus-thread-ignore-subject
5327 gnus-tmp-prev-subject
5328 (not (string= gnus-tmp-prev-subject simp-subject)))
5329 subject)
5330 ((zerop gnus-tmp-level)
5331 (if (and (eq gnus-summary-make-false-root 'empty)
5332 (memq number gnus-tmp-gathered)
5333 gnus-tmp-prev-subject
5334 (string= gnus-tmp-prev-subject simp-subject))
5335 gnus-summary-same-subject
5336 subject))
5337 (t gnus-summary-same-subject)))
5338 (if (and (eq gnus-summary-make-false-root 'adopt)
5339 (= gnus-tmp-level 1)
5340 (memq number gnus-tmp-gathered))
5341 (setq gnus-tmp-opening-bracket ?\<
5342 gnus-tmp-closing-bracket ?\>)
5343 (setq gnus-tmp-opening-bracket ?\[
5344 gnus-tmp-closing-bracket ?\]))
5345 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5346 (gnus-make-thread-indent-array
5347 (max (* 2 (length gnus-thread-indent-array))
5348 gnus-tmp-level)))
5349 (setq
5350 gnus-tmp-indentation
5351 (aref gnus-thread-indent-array gnus-tmp-level)
5352 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5353 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5354 gnus-summary-default-score 0)
5355 gnus-tmp-score-char
5356 (if (or (null gnus-summary-default-score)
5357 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5358 gnus-summary-zcore-fuzz))
5359 ? ;Whitespace
5360 (if (< gnus-tmp-score gnus-summary-default-score)
5361 gnus-score-below-mark gnus-score-over-mark))
5362 gnus-tmp-replied
5363 (cond ((memq number gnus-newsgroup-processable)
5364 gnus-process-mark)
5365 ((memq number gnus-newsgroup-cached)
5366 gnus-cached-mark)
5367 ((memq number gnus-newsgroup-replied)
5368 gnus-replied-mark)
5369 ((memq number gnus-newsgroup-forwarded)
5370 gnus-forwarded-mark)
5371 ((memq number gnus-newsgroup-saved)
5372 gnus-saved-mark)
5373 ((memq number gnus-newsgroup-unseen)
5374 gnus-unseen-mark)
5375 (t gnus-no-mark))
5376 gnus-tmp-downloaded
5377 (cond ((memq number gnus-newsgroup-undownloaded)
5378 gnus-undownloaded-mark)
5379 (gnus-newsgroup-agentized
5380 gnus-downloaded-mark)
5381 (t
5382 gnus-no-mark))
5383 gnus-tmp-from (mail-header-from gnus-tmp-header)
5384 gnus-tmp-name
5385 (cond
5386 ((string-match "<[^>]+> *$" gnus-tmp-from)
5387 (setq beg-match (match-beginning 0))
5388 (or (and (string-match "^\".+\"" gnus-tmp-from)
5389 (substring gnus-tmp-from 1 (1- (match-end 0))))
5390 (substring gnus-tmp-from 0 beg-match)))
5391 ((string-match "(.+)" gnus-tmp-from)
5392 (substring gnus-tmp-from
5393 (1+ (match-beginning 0)) (1- (match-end 0))))
5394 (t gnus-tmp-from))
5395
5396 ;; Do the %B string
5397 gnus-tmp-thread-tree-header-string
5398 (cond
5399 ((not gnus-show-threads) "")
5400 ((zerop gnus-tmp-level)
5401 (cond ((cdar thread)
5402 (or gnus-sum-thread-tree-root subject))
5403 (gnus-tmp-new-adopts
5404 (or gnus-sum-thread-tree-false-root subject))
5405 (t
5406 (or gnus-sum-thread-tree-single-indent subject))))
5407 (t
5408 (concat (apply 'concat
5409 (mapcar (lambda (item)
5410 (if (= item 1)
5411 gnus-sum-thread-tree-vertical
5412 gnus-sum-thread-tree-indent))
5413 (cdr (reverse tree-stack))))
5414 (if (nth 1 thread)
5415 gnus-sum-thread-tree-leaf-with-other
5416 gnus-sum-thread-tree-single-leaf)))))
5417 (when (string= gnus-tmp-name "")
5418 (setq gnus-tmp-name gnus-tmp-from))
5419 (unless (numberp gnus-tmp-lines)
5420 (setq gnus-tmp-lines -1))
5421 (if (= gnus-tmp-lines -1)
5422 (setq gnus-tmp-lines "?")
5423 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5424 (put-text-property
5425 (point)
5426 (progn (eval gnus-summary-line-format-spec) (point))
5427 'gnus-number number)
5428 (when gnus-visual-p
5429 (forward-line -1)
5430 (gnus-summary-highlight-line)
5431 (when gnus-summary-update-hook
5432 (gnus-run-hooks 'gnus-summary-update-hook))
5433 (forward-line 1))
5434
5435 (setq gnus-tmp-prev-subject simp-subject)))
5436
5437 (when (nth 1 thread)
5438 (push (list (max 0 gnus-tmp-level)
5439 (copy-sequence tree-stack)
5440 (nthcdr 1 thread))
5441 stack))
5442 (push (if (nth 1 thread) 1 0) tree-stack)
5443 (incf gnus-tmp-level)
5444 (setq threads (if thread-end nil (cdar thread)))
5445 (if gnus-summary-display-while-building
5446 (if building-count
5447 (progn
5448 ;; use a set frequency
5449 (setq building-line-count (1- building-line-count))
5450 (when (= building-line-count 0)
5451 (sit-for 0)
5452 (setq building-line-count
5453 gnus-summary-display-while-building)))
5454 ;; always
5455 (sit-for 0)))
5456 (unless threads
5457 (setq gnus-tmp-level 0)))))
5458 (gnus-message 7 "Generating summary...done"))
5459
5460 (defun gnus-summary-prepare-unthreaded (headers)
5461 "Generate an unthreaded summary buffer based on HEADERS."
5462 (let (header number mark)
5463
5464 (beginning-of-line)
5465
5466 (while headers
5467 ;; We may have to root out some bad articles...
5468 (when (memq (setq number (mail-header-number
5469 (setq header (pop headers))))
5470 gnus-newsgroup-limit)
5471 ;; Mark article as read when it has a low score.
5472 (when (and gnus-summary-mark-below
5473 (< (or (cdr (assq number gnus-newsgroup-scored))
5474 gnus-summary-default-score 0)
5475 gnus-summary-mark-below)
5476 (not (gnus-summary-article-ancient-p number)))
5477 (setq gnus-newsgroup-unreads
5478 (delq number gnus-newsgroup-unreads))
5479 (if gnus-newsgroup-auto-expire
5480 (push number gnus-newsgroup-expirable)
5481 (push (cons number gnus-low-score-mark)
5482 gnus-newsgroup-reads)))
5483
5484 (setq mark (gnus-article-mark number))
5485 (push (gnus-data-make number mark (1+ (point)) header 0)
5486 gnus-newsgroup-data)
5487 (gnus-summary-insert-line
5488 header 0 number
5489 (memq number gnus-newsgroup-undownloaded)
5490 mark (memq number gnus-newsgroup-replied)
5491 (memq number gnus-newsgroup-expirable)
5492 (mail-header-subject header) nil
5493 (cdr (assq number gnus-newsgroup-scored))
5494 (memq number gnus-newsgroup-processable))))))
5495
5496 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5497
5498 (defun gnus-group-get-list-identifiers (group)
5499 "Get list identifier regexp for GROUP."
5500 (or (gnus-parameter-list-identifier group)
5501 (if (consp gnus-list-identifiers)
5502 (mapconcat 'identity gnus-list-identifiers " *\\|")
5503 gnus-list-identifiers)))
5504
5505 (defun gnus-summary-remove-list-identifiers ()
5506 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5507 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5508 changed subject)
5509 (when regexp
5510 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5511 (dolist (header gnus-newsgroup-headers)
5512 (setq subject (mail-header-subject header)
5513 changed nil)
5514 (while (string-match regexp subject)
5515 (setq subject
5516 (concat (substring subject 0 (match-beginning 1))
5517 (substring subject (match-end 0)))
5518 changed t))
5519 (when changed
5520 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5521 (setq subject
5522 (concat (substring subject 0 (match-beginning 1))
5523 (substring subject (match-end 1)))))
5524 (mail-header-set-subject header subject))))))
5525
5526 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5527 "Fetch headers of ARTICLES."
5528 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5529 (gnus-message 7 "Fetching headers for %s..." name)
5530 (prog1
5531 (if (eq 'nov
5532 (setq gnus-headers-retrieved-by
5533 (gnus-retrieve-headers
5534 articles gnus-newsgroup-name
5535 (or limit
5536 ;; We might want to fetch old headers, but
5537 ;; not if there is only 1 article.
5538 (and (or (and
5539 (not (eq gnus-fetch-old-headers 'some))
5540 (not (numberp gnus-fetch-old-headers)))
5541 (> (length articles) 1))
5542 gnus-fetch-old-headers)))))
5543 (gnus-get-newsgroup-headers-xover
5544 articles force-new dependencies gnus-newsgroup-name t)
5545 (gnus-get-newsgroup-headers dependencies force-new))
5546 (gnus-message 7 "Fetching headers for %s...done" name))))
5547
5548 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5549 "Select newsgroup GROUP.
5550 If READ-ALL is non-nil, all articles in the group are selected.
5551 If SELECT-ARTICLES, only select those articles from GROUP."
5552 (let* ((entry (gnus-group-entry group))
5553 ;;!!! Dirty hack; should be removed.
5554 (gnus-summary-ignore-duplicates
5555 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5556 t
5557 gnus-summary-ignore-duplicates))
5558 (info (nth 2 entry))
5559 charset articles fetched-articles cached)
5560
5561 (unless (gnus-check-server
5562 (set (make-local-variable 'gnus-current-select-method)
5563 (gnus-find-method-for-group group)))
5564 (error "Couldn't open server"))
5565 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5566
5567 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5568 (gnus-activate-group group) ; Or we can activate it...
5569 (progn ; Or we bug out.
5570 (when (derived-mode-p 'gnus-summary-mode)
5571 (gnus-kill-buffer (current-buffer)))
5572 (error
5573 "Couldn't activate group %s: %s"
5574 (decode-coding-string group charset)
5575 (decode-coding-string (gnus-status-message group) charset))))
5576
5577 (unless (gnus-request-group group t nil (gnus-get-info group))
5578 (when (derived-mode-p 'gnus-summary-mode)
5579 (gnus-kill-buffer (current-buffer)))
5580 (error "Couldn't request group %s: %s"
5581 (decode-coding-string group charset)
5582 (decode-coding-string (gnus-status-message group) charset)))
5583
5584 (when (and gnus-agent
5585 (gnus-active group))
5586 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5587
5588 (setq gnus-summary-use-undownloaded-faces
5589 (gnus-agent-find-parameter
5590 group
5591 'agent-enable-undownloaded-faces)))
5592
5593 (setq gnus-newsgroup-name group
5594 gnus-newsgroup-unselected nil
5595 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5596
5597 (let ((display (gnus-group-find-parameter group 'display)))
5598 (setq gnus-newsgroup-display
5599 (cond
5600 ((not (zerop (or (car-safe read-all) 0)))
5601 ;; The user entered the group with C-u SPC/RET, let's show
5602 ;; all articles.
5603 'gnus-not-ignore)
5604 ((eq display 'all)
5605 'gnus-not-ignore)
5606 ((arrayp display)
5607 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5608 ((numberp display)
5609 ;; The following is probably the "correct" solution, but
5610 ;; it makes Gnus fetch all headers and then limit the
5611 ;; articles (which is slow), so instead we hack the
5612 ;; select-articles parameter instead. -- Simon Josefsson
5613 ;; <jas@kth.se>
5614 ;;
5615 ;; (gnus-byte-compile
5616 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5617 ;; display)))))
5618 (setq select-articles
5619 (gnus-uncompress-range
5620 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5621 (if (> tmp 0)
5622 tmp
5623 1))
5624 (cdr (gnus-active group)))))
5625 nil)
5626 (t
5627 nil))))
5628
5629 (gnus-summary-setup-default-charset)
5630
5631 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5632 (when (gnus-virtual-group-p group)
5633 (setq cached gnus-newsgroup-cached))
5634
5635 (setq gnus-newsgroup-unreads
5636 (gnus-sorted-ndifference
5637 (gnus-sorted-ndifference gnus-newsgroup-unreads
5638 gnus-newsgroup-marked)
5639 gnus-newsgroup-dormant))
5640
5641 (setq gnus-newsgroup-processable nil)
5642
5643 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5644
5645 ;; Adjust and set lists of article marks.
5646 (when info
5647 (gnus-adjust-marked-articles info))
5648 (if (setq articles select-articles)
5649 (setq gnus-newsgroup-unselected
5650 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5651 (setq articles (gnus-articles-to-read group read-all)))
5652
5653 (cond
5654 ((null articles)
5655 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5656 'quit)
5657 ((eq articles 0) nil)
5658 (t
5659 ;; Init the dependencies hash table.
5660 (setq gnus-newsgroup-dependencies
5661 (gnus-make-hashtable (length articles)))
5662 (if (gnus-buffer-live-p gnus-group-buffer)
5663 (gnus-set-global-variables)
5664 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5665 ;; Retrieve the headers and read them in.
5666
5667 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5668
5669 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5670 (when cached
5671 (setq gnus-newsgroup-cached cached))
5672
5673 ;; Suppress duplicates?
5674 (when gnus-suppress-duplicates
5675 (gnus-dup-suppress-articles))
5676
5677 ;; Set the initial limit.
5678 (setq gnus-newsgroup-limit (copy-sequence articles))
5679 ;; Remove canceled articles from the list of unread articles.
5680 (setq fetched-articles
5681 (mapcar (lambda (headers) (mail-header-number headers))
5682 gnus-newsgroup-headers))
5683 (setq gnus-newsgroup-articles fetched-articles)
5684 (setq gnus-newsgroup-unreads
5685 (gnus-sorted-nintersection
5686 gnus-newsgroup-unreads fetched-articles))
5687 (gnus-compute-unseen-list)
5688
5689 ;; Removed marked articles that do not exist.
5690 (gnus-update-missing-marks
5691 (gnus-sorted-difference articles fetched-articles))
5692 ;; We might want to build some more threads first.
5693 (when (and gnus-fetch-old-headers
5694 (eq gnus-headers-retrieved-by 'nov))
5695 (if (eq gnus-fetch-old-headers 'invisible)
5696 (gnus-build-all-threads)
5697 (gnus-build-old-threads)))
5698 ;; Let the Gnus agent mark articles as read.
5699 (when gnus-agent
5700 (gnus-agent-get-undownloaded-list))
5701 ;; Remove list identifiers from subject
5702 (gnus-summary-remove-list-identifiers)
5703 ;; Check whether auto-expire is to be done in this group.
5704 (setq gnus-newsgroup-auto-expire
5705 (and (gnus-group-auto-expirable-p group)
5706 (not (gnus-group-read-only-p group))))
5707 ;; Set up the article buffer now, if necessary.
5708 (unless (and gnus-single-article-buffer
5709 (equal gnus-article-buffer "*Article*"))
5710 (gnus-article-setup-buffer))
5711 ;; First and last article in this newsgroup.
5712 (when gnus-newsgroup-headers
5713 (setq gnus-newsgroup-begin
5714 (mail-header-number (car gnus-newsgroup-headers))
5715 gnus-newsgroup-end
5716 (mail-header-number
5717 (gnus-last-element gnus-newsgroup-headers))))
5718 ;; GROUP is successfully selected.
5719 (or gnus-newsgroup-headers t)))))
5720
5721 (defun gnus-compute-unseen-list ()
5722 ;; The `seen' marks are treated specially.
5723 (if (not gnus-newsgroup-seen)
5724 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5725 (setq gnus-newsgroup-unseen
5726 (gnus-inverse-list-range-intersection
5727 gnus-newsgroup-articles gnus-newsgroup-seen))))
5728
5729 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5730
5731 (defun gnus-summary-display-make-predicate (display)
5732 (require 'gnus-agent)
5733 (when (= (length display) 1)
5734 (setq display (car display)))
5735 (unless gnus-summary-display-cache
5736 (dolist (elem (append '((unread . unread)
5737 (read . read)
5738 (unseen . unseen))
5739 gnus-article-mark-lists))
5740 (push (cons (cdr elem)
5741 (gnus-byte-compile ;Why bother?
5742 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5743 gnus-summary-display-cache)))
5744 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5745 (gnus-category-predicate-cache gnus-summary-display-cache))
5746 (gnus-get-predicate display)))
5747
5748 ;; Uses the dynamically bound `gnus-number' variable.
5749 (defvar gnus-number)
5750 (defun gnus-article-marked-p (type &optional article)
5751 (let ((article (or article gnus-number)))
5752 (cond
5753 ((eq type 'tick)
5754 (memq article gnus-newsgroup-marked))
5755 ((eq type 'spam)
5756 (memq article gnus-newsgroup-spam-marked))
5757 ((eq type 'unsend)
5758 (memq article gnus-newsgroup-unsendable))
5759 ((eq type 'undownload)
5760 (memq article gnus-newsgroup-undownloaded))
5761 ((eq type 'download)
5762 (memq article gnus-newsgroup-downloadable))
5763 ((eq type 'unread)
5764 (memq article gnus-newsgroup-unreads))
5765 ((eq type 'read)
5766 (memq article gnus-newsgroup-reads))
5767 ((eq type 'dormant)
5768 (memq article gnus-newsgroup-dormant) )
5769 ((eq type 'expire)
5770 (memq article gnus-newsgroup-expirable))
5771 ((eq type 'reply)
5772 (memq article gnus-newsgroup-replied))
5773 ((eq type 'killed)
5774 (memq article gnus-newsgroup-killed))
5775 ((eq type 'bookmark)
5776 (assq article gnus-newsgroup-bookmarks))
5777 ((eq type 'score)
5778 (assq article gnus-newsgroup-scored))
5779 ((eq type 'save)
5780 (memq article gnus-newsgroup-saved))
5781 ((eq type 'cache)
5782 (memq article gnus-newsgroup-cached))
5783 ((eq type 'forward)
5784 (memq article gnus-newsgroup-forwarded))
5785 ((eq type 'seen)
5786 (not (memq article gnus-newsgroup-unseen)))
5787 (t t))))
5788
5789 (defun gnus-articles-to-read (group &optional read-all)
5790 "Find out what articles the user wants to read."
5791 (let* ((only-read-p t)
5792 (articles
5793 (gnus-list-range-difference
5794 ;; Select all articles if `read-all' is non-nil, or if there
5795 ;; are no unread articles.
5796 (if (or read-all
5797 (and (zerop (length gnus-newsgroup-marked))
5798 (zerop (length gnus-newsgroup-unreads)))
5799 ;; Fetch all if the predicate is non-nil.
5800 gnus-newsgroup-display)
5801 ;; We want to select the headers for all the articles in
5802 ;; the group, so we select either all the active
5803 ;; articles in the group, or (if that's nil), the
5804 ;; articles in the cache.
5805 (or
5806 (if gnus-newsgroup-maximum-articles
5807 (let ((active (gnus-active group)))
5808 (gnus-uncompress-range
5809 (cons (max (car active)
5810 (- (cdr active)
5811 gnus-newsgroup-maximum-articles
5812 -1))
5813 (cdr active))))
5814 (gnus-uncompress-range (gnus-active group)))
5815 (gnus-cache-articles-in-group group))
5816 ;; Select only the "normal" subset of articles.
5817 (setq only-read-p nil)
5818 (gnus-sorted-nunion
5819 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5820 gnus-newsgroup-unreads))
5821 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5822 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5823 (scored (length scored-list))
5824 (number (length articles))
5825 (marked (+ (length gnus-newsgroup-marked)
5826 (length gnus-newsgroup-dormant)))
5827 (select
5828 (cond
5829 ((numberp read-all)
5830 read-all)
5831 ((numberp gnus-newsgroup-display)
5832 gnus-newsgroup-display)
5833 (t
5834 (condition-case ()
5835 (cond
5836 ((and (or (<= scored marked) (= scored number))
5837 (numberp gnus-large-newsgroup)
5838 (> number gnus-large-newsgroup))
5839 (let* ((cursor-in-echo-area nil)
5840 (initial (gnus-parameter-large-newsgroup-initial
5841 gnus-newsgroup-name))
5842 (default (if only-read-p
5843 (or initial gnus-large-newsgroup)
5844 number))
5845 (input
5846 (read-string
5847 (if only-read-p
5848 (format
5849 "How many articles from %s (available %d, default %d): "
5850 (gnus-group-real-name
5851 (gnus-group-decoded-name gnus-newsgroup-name))
5852 number default)
5853 (format
5854 "How many articles from %s (%d default): "
5855 (gnus-group-real-name
5856 (gnus-group-decoded-name gnus-newsgroup-name))
5857 default))
5858 nil
5859 nil
5860 (number-to-string default))))
5861 (if (string-match "^[ \t]*$" input) number input)))
5862 ((and (> scored marked) (< scored number)
5863 (> (- scored number) 20))
5864 (let ((input
5865 (read-string
5866 (format "%s %s (%d scored, %d total): "
5867 "How many articles from"
5868 (gnus-group-decoded-name
5869 (gnus-group-real-name gnus-newsgroup-name))
5870 scored number))))
5871 (if (string-match "^[ \t]*$" input)
5872 number input)))
5873 (t number))
5874 (quit
5875 (message "Quit getting the articles to read")
5876 nil))))))
5877 (setq select (if (stringp select) (string-to-number select) select))
5878 (if (or (null select) (zerop select))
5879 select
5880 (if (and (not (zerop scored)) (<= (abs select) scored))
5881 (progn
5882 (setq articles (sort scored-list '<))
5883 (setq number (length articles)))
5884 (setq articles (copy-sequence articles)))
5885
5886 (when (< (abs select) number)
5887 (if (< select 0)
5888 ;; Select the N oldest articles.
5889 (setcdr (nthcdr (1- (abs select)) articles) nil)
5890 ;; Select the N most recent articles.
5891 (setq articles (nthcdr (- number select) articles))))
5892 (setq gnus-newsgroup-unselected
5893 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5894 (when gnus-alter-articles-to-read-function
5895 (setq articles
5896 (sort
5897 (funcall gnus-alter-articles-to-read-function
5898 gnus-newsgroup-name articles)
5899 '<)))
5900 articles)))
5901
5902 (defun gnus-killed-articles (killed articles)
5903 (let (out)
5904 (while articles
5905 (when (inline (gnus-member-of-range (car articles) killed))
5906 (push (car articles) out))
5907 (setq articles (cdr articles)))
5908 out))
5909
5910 (defun gnus-article-mark-to-type (mark)
5911 "Return the type of MARK."
5912 (or (cadr (assq mark gnus-article-special-mark-lists))
5913 'list))
5914
5915 (defun gnus-article-unpropagatable-p (mark)
5916 "Return whether MARK should be propagated to back end."
5917 (memq mark gnus-article-unpropagated-mark-lists))
5918
5919 (defun gnus-adjust-marked-articles (info)
5920 "Set all article lists and remove all marks that are no longer valid."
5921 (let* ((marked-lists (gnus-info-marks info))
5922 (active (gnus-active (gnus-info-group info)))
5923 (min (car active))
5924 (max (cdr active))
5925 (types gnus-article-mark-lists)
5926 marks var articles article mark mark-type
5927 bgn end)
5928 ;; Hack to avoid adjusting marks for imap.
5929 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5930 'nnimap)
5931 (setq min 1))
5932
5933 (dolist (marks marked-lists)
5934 (setq mark (car marks)
5935 mark-type (gnus-article-mark-to-type mark)
5936 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5937 ;; We set the variable according to the type of the marks list,
5938 ;; and then adjust the marks to a subset of the active articles.
5939 (cond
5940 ;; Adjust "simple" lists - compressed yet unsorted
5941 ((eq mark-type 'list)
5942 ;; Simultaneously uncompress and clip to active range
5943 ;; See gnus-uncompress-range for a description of possible marks
5944 (let (l lh)
5945 (if (not (cadr marks))
5946 (set var nil)
5947 (setq articles (if (numberp (cddr marks))
5948 (list (cdr marks))
5949 (cdr marks))
5950 lh (cons nil nil)
5951 l lh)
5952
5953 (while (setq article (pop articles))
5954 (cond ((consp article)
5955 (setq bgn (max (car article) min)
5956 end (min (cdr article) max))
5957 (while (<= bgn end)
5958 (setq l (setcdr l (cons bgn nil))
5959 bgn (1+ bgn))))
5960 ((and (<= min article)
5961 (>= max article))
5962 (setq l (setcdr l (cons article nil))))))
5963 (set var (cdr lh)))))
5964 ;; Adjust assocs.
5965 ((eq mark-type 'tuple)
5966 (set var (setq articles (cdr marks)))
5967 (when (not (listp (cdr (symbol-value var))))
5968 (set var (list (symbol-value var))))
5969 (when (not (listp (cdr articles)))
5970 (setq articles (list articles)))
5971 (while articles
5972 (when (or (not (consp (setq article (pop articles))))
5973 (< (car article) min)
5974 (> (car article) max))
5975 (set var (delq article (symbol-value var))))))
5976 ;; Adjust ranges (sloppily).
5977 ((eq mark-type 'range)
5978 (cond
5979 ((eq mark 'seen)
5980 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5981 ;; It should be (seen (NUM1 . NUM2)).
5982 (when (numberp (cddr marks))
5983 (setcdr marks (list (cdr marks))))
5984 (setq articles (cdr marks))
5985 (while (and articles
5986 (or (and (consp (car articles))
5987 (> min (cdar articles)))
5988 (and (numberp (car articles))
5989 (> min (car articles)))))
5990 (pop articles))
5991 (set var articles))
5992 ((eq mark 'unexist)
5993 (set var (cdr marks)))))))))
5994
5995 (defun gnus-update-missing-marks (missing)
5996 "Go through the list of MISSING articles and remove them from the mark lists."
5997 (when missing
5998 (let (var m)
5999 ;; Go through all types.
6000 (dolist (elem gnus-article-mark-lists)
6001 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6002 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6003 (when (symbol-value var)
6004 ;; This list has articles. So we delete all missing
6005 ;; articles from it.
6006 (setq m missing)
6007 (while m
6008 (set var (delq (pop m) (symbol-value var))))))))))
6009
6010 (defun gnus-update-marks ()
6011 "Enter the various lists of marked articles into the newsgroup info list."
6012 (let ((types gnus-article-mark-lists)
6013 (info (gnus-get-info gnus-newsgroup-name))
6014 type list newmarked symbol delta-marks)
6015 (when info
6016 ;; Add all marks lists to the list of marks lists.
6017 (while (setq type (pop types))
6018 (setq list (symbol-value
6019 (setq symbol
6020 (intern (format "gnus-newsgroup-%s" (car type))))))
6021
6022 (when list
6023 ;; Get rid of the entries of the articles that have the
6024 ;; default score.
6025 (when (and (eq (cdr type) 'score)
6026 gnus-save-score
6027 list)
6028 (let* ((arts list)
6029 (prev (cons nil list))
6030 (all prev))
6031 (while arts
6032 (if (or (not (consp (car arts)))
6033 (= (cdar arts) gnus-summary-default-score))
6034 (setcdr prev (cdr arts))
6035 (setq prev arts))
6036 (setq arts (cdr arts)))
6037 (setq list (cdr all)))))
6038
6039 ;; When exiting the group, everything that's previously been
6040 ;; unseen is now seen.
6041 (when (eq (cdr type) 'seen)
6042 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6043
6044 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6045 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6046
6047 (when (and (gnus-check-backend-function
6048 'request-set-mark gnus-newsgroup-name)
6049 (not (gnus-article-unpropagatable-p (cdr type))))
6050 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6051 ;; Don't do anything about marks for articles we
6052 ;; didn't actually get any headers for.
6053 (del
6054 (gnus-list-range-intersection
6055 gnus-newsgroup-articles
6056 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6057 (add
6058 (gnus-list-range-intersection
6059 gnus-newsgroup-articles
6060 (gnus-remove-from-range
6061 (gnus-copy-sequence list) old))))
6062 (when add
6063 (push (list add 'add (list (cdr type))) delta-marks))
6064 (when del
6065 ;; Don't delete marks from outside the active range.
6066 ;; This shouldn't happen, but is a sanity check.
6067 (setq del (gnus-sorted-range-intersection
6068 (gnus-active gnus-newsgroup-name) del))
6069 (push (list del 'del (list (cdr type))) delta-marks))))
6070
6071 (when (or list
6072 (eq (cdr type) 'unexist))
6073 (push (cons (cdr type) list) newmarked)))
6074
6075 (when delta-marks
6076 (unless (gnus-check-group gnus-newsgroup-name)
6077 (error "Can't open server for %s" gnus-newsgroup-name))
6078 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6079
6080 ;; Enter these new marks into the info of the group.
6081 (if (nthcdr 3 info)
6082 (setcar (nthcdr 3 info) newmarked)
6083 ;; Add the marks lists to the end of the info.
6084 (when newmarked
6085 (setcdr (nthcdr 2 info) (list newmarked))))
6086
6087 ;; Cut off the end of the info if there's nothing else there.
6088 (let ((i 5))
6089 (while (and (> i 2)
6090 (not (nth i info)))
6091 (when (nthcdr (decf i) info)
6092 (setcdr (nthcdr i info) nil)))))))
6093
6094 (defun gnus-set-mode-line (where)
6095 "Set the mode line of the article or summary buffers.
6096 If WHERE is `summary', the summary mode line format will be used."
6097 ;; Is this mode line one we keep updated?
6098 (when (and (memq where gnus-updated-mode-lines)
6099 (symbol-value
6100 (intern (format "gnus-%s-mode-line-format-spec" where))))
6101 (let (mode-string)
6102 ;; We evaluate this in the summary buffer since these
6103 ;; variables are buffer-local to that buffer.
6104 (with-current-buffer gnus-summary-buffer
6105 ;; We bind all these variables that are used in the `eval' form
6106 ;; below.
6107 (let* ((mformat (symbol-value
6108 (intern
6109 (format "gnus-%s-mode-line-format-spec" where))))
6110 (gnus-tmp-group-name (gnus-mode-string-quote
6111 (gnus-group-decoded-name
6112 gnus-newsgroup-name)))
6113 (gnus-tmp-article-number (or gnus-current-article 0))
6114 (gnus-tmp-unread gnus-newsgroup-unreads)
6115 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6116 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6117 (gnus-tmp-unread-and-unselected
6118 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6119 (zerop gnus-tmp-unselected))
6120 "")
6121 ((zerop gnus-tmp-unselected)
6122 (format "{%d more}" gnus-tmp-unread-and-unticked))
6123 (t (format "{%d(+%d) more}"
6124 gnus-tmp-unread-and-unticked
6125 gnus-tmp-unselected))))
6126 (gnus-tmp-subject
6127 (if (and gnus-current-headers
6128 (vectorp gnus-current-headers))
6129 (gnus-mode-string-quote
6130 (mail-header-subject gnus-current-headers))
6131 ""))
6132 bufname-length max-len
6133 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6134 (setq mode-string (eval mformat))
6135 (setq bufname-length (if (string-match "%b" mode-string)
6136 (- (length
6137 (buffer-name
6138 (if (eq where 'summary)
6139 nil
6140 (get-buffer gnus-article-buffer))))
6141 2)
6142 0))
6143 (setq max-len (max 4 (if gnus-mode-non-string-length
6144 (- (window-width)
6145 gnus-mode-non-string-length
6146 bufname-length)
6147 (length mode-string))))
6148 ;; We might have to chop a bit of the string off...
6149 (when (> (length mode-string) max-len)
6150 (setq mode-string
6151 (concat (truncate-string-to-width mode-string (- max-len 3))
6152 "...")))))
6153 ;; Update the mode line.
6154 (setq mode-line-buffer-identification
6155 (gnus-mode-line-buffer-identification (list mode-string)))
6156 (set-buffer-modified-p t))))
6157
6158 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6159 "Go through the HEADERS list and add all Xrefs to a hash table.
6160 The resulting hash table is returned, or nil if no Xrefs were found."
6161 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6162 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6163 (xref-hashtb (gnus-make-hashtable))
6164 start group entry number xrefs header)
6165 (while headers
6166 (setq header (pop headers))
6167 (when (and (setq xrefs (mail-header-xref header))
6168 (not (memq (setq number (mail-header-number header))
6169 unreads)))
6170 (setq start 0)
6171 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6172 (setq start (match-end 0))
6173 (setq group (if prefix
6174 (concat prefix (substring xrefs (match-beginning 1)
6175 (match-end 1)))
6176 (substring xrefs (match-beginning 1) (match-end 1))))
6177 (setq number
6178 (string-to-number (substring xrefs (match-beginning 2)
6179 (match-end 2))))
6180 (if (setq entry (gnus-gethash group xref-hashtb))
6181 (setcdr entry (cons number (cdr entry)))
6182 (gnus-sethash group (cons number nil) xref-hashtb)))))
6183 (and start xref-hashtb)))
6184
6185 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6186 "Look through all the headers and mark the Xrefs as read."
6187 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6188 name info xref-hashtb idlist method nth4)
6189 (with-current-buffer gnus-group-buffer
6190 (when (setq xref-hashtb
6191 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6192 (mapatoms
6193 (lambda (group)
6194 (unless (string= from-newsgroup (setq name (symbol-name group)))
6195 (setq idlist (symbol-value group))
6196 ;; Dead groups are not updated.
6197 (and (prog1
6198 (setq info (gnus-get-info name))
6199 (when (stringp (setq nth4 (gnus-info-method info)))
6200 (setq nth4 (gnus-server-to-method nth4))))
6201 ;; Only do the xrefs if the group has the same
6202 ;; select method as the group we have just read.
6203 (or (gnus-methods-equal-p
6204 nth4 (gnus-find-method-for-group from-newsgroup))
6205 virtual
6206 (equal nth4 (setq method (gnus-find-method-for-group
6207 from-newsgroup)))
6208 (and (equal (car nth4) (car method))
6209 (equal (nth 1 nth4) (nth 1 method))))
6210 gnus-use-cross-reference
6211 (or (not (eq gnus-use-cross-reference t))
6212 virtual
6213 ;; Only do cross-references on subscribed
6214 ;; groups, if that is what is wanted.
6215 (<= (gnus-info-level info) gnus-level-subscribed))
6216 (gnus-group-make-articles-read name idlist))))
6217 xref-hashtb)))))
6218
6219 (defun gnus-compute-read-articles (group articles)
6220 (let* ((entry (gnus-group-entry group))
6221 (info (nth 2 entry))
6222 (active (gnus-active group))
6223 ninfo)
6224 (when entry
6225 ;; First peel off all invalid article numbers.
6226 (when active
6227 (let ((ids articles)
6228 id first)
6229 (while (setq id (pop ids))
6230 (when (and first (> id (cdr active)))
6231 ;; We'll end up in this situation in one particular
6232 ;; obscure situation. If you re-scan a group and get
6233 ;; a new article that is cross-posted to a different
6234 ;; group that has not been re-scanned, you might get
6235 ;; crossposted article that has a higher number than
6236 ;; Gnus believes possible. So we re-activate this
6237 ;; group as well. This might mean doing the
6238 ;; crossposting thingy will *increase* the number
6239 ;; of articles in some groups. Tsk, tsk.
6240 (setq active (or (gnus-activate-group group) active)))
6241 (when (or (> id (cdr active))
6242 (< id (car active)))
6243 (setq articles (delq id articles))))))
6244 ;; If the read list is nil, we init it.
6245 (if (and active
6246 (null (gnus-info-read info))
6247 (> (car active) 1))
6248 (setq ninfo (cons 1 (1- (car active))))
6249 (setq ninfo (gnus-info-read info)))
6250 ;; Then we add the read articles to the range.
6251 (gnus-add-to-range
6252 ninfo (setq articles (sort articles '<))))))
6253
6254 (defun gnus-group-make-articles-read (group articles)
6255 "Update the info of GROUP to say that ARTICLES are read."
6256 (let* ((num 0)
6257 (entry (gnus-group-entry group))
6258 (info (nth 2 entry))
6259 (active (gnus-active group))
6260 (set-marks
6261 (gnus-method-option-p
6262 (gnus-find-method-for-group group)
6263 'server-marks))
6264 range)
6265 (if (not entry)
6266 ;; Group that Gnus doesn't know exists, but still allow the
6267 ;; backend to set marks.
6268 (when set-marks
6269 (gnus-request-set-mark
6270 group (list (list (gnus-compress-sequence (sort articles #'<))
6271 'add '(read)))))
6272 ;; Normal, subscribed groups.
6273 (setq range (gnus-compute-read-articles group articles))
6274 (with-current-buffer gnus-group-buffer
6275 (gnus-undo-register
6276 `(progn
6277 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6278 (gnus-info-set-read ',info ',(gnus-info-read info))
6279 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6280 (when ,set-marks
6281 (gnus-request-set-mark
6282 ,group (list (list ',range 'del '(read)))))
6283 (gnus-group-update-group ,group t))))
6284 ;; Add the read articles to the range.
6285 (gnus-info-set-read info range)
6286 (when set-marks
6287 (gnus-request-set-mark group (list (list range 'add '(read)))))
6288 ;; Then we have to re-compute how many unread
6289 ;; articles there are in this group.
6290 (when active
6291 (cond
6292 ((not range)
6293 (setq num (- (1+ (cdr active)) (car active))))
6294 ((not (listp (cdr range)))
6295 (setq num (- (cdr active) (- (1+ (cdr range))
6296 (car range)))))
6297 (t
6298 (while range
6299 (if (numberp (car range))
6300 (setq num (1+ num))
6301 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6302 (setq range (cdr range)))
6303 (setq num (- (cdr active) num))))
6304 ;; Update the number of unread articles.
6305 (setcar entry num)
6306 ;; Update the group buffer.
6307 (unless (gnus-ephemeral-group-p group)
6308 (gnus-group-update-group group t))))))
6309
6310 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6311 (let ((cur nntp-server-buffer)
6312 (dependencies
6313 (or dependencies
6314 (with-current-buffer gnus-summary-buffer
6315 gnus-newsgroup-dependencies)))
6316 headers id end ref number
6317 (mail-parse-charset gnus-newsgroup-charset)
6318 (mail-parse-ignored-charsets
6319 (save-current-buffer (condition-case nil
6320 (set-buffer gnus-summary-buffer)
6321 (error))
6322 gnus-newsgroup-ignored-charsets)))
6323 (with-current-buffer nntp-server-buffer
6324 ;; Translate all TAB characters into SPACE characters.
6325 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6326 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6327 (ietf-drums-unfold-fws)
6328 (gnus-run-hooks 'gnus-parse-headers-hook)
6329 (let ((case-fold-search t)
6330 in-reply-to header p lines chars)
6331 (goto-char (point-min))
6332 ;; Search to the beginning of the next header. Error messages
6333 ;; do not begin with 2 or 3.
6334 (while (re-search-forward "^[23][0-9]+ " nil t)
6335 (setq id nil
6336 ref nil)
6337 ;; This implementation of this function, with nine
6338 ;; search-forwards instead of the one re-search-forward and
6339 ;; a case (which basically was the old function) is actually
6340 ;; about twice as fast, even though it looks messier. You
6341 ;; can't have everything, I guess. Speed and elegance
6342 ;; doesn't always go hand in hand.
6343 (setq
6344 header
6345 (vector
6346 ;; Number.
6347 (prog1
6348 (setq number (read cur))
6349 (end-of-line)
6350 (setq p (point))
6351 (narrow-to-region (point)
6352 (or (and (search-forward "\n.\n" nil t)
6353 (- (point) 2))
6354 (point))))
6355 ;; Subject.
6356 (progn
6357 (goto-char p)
6358 (if (search-forward "\nsubject:" nil t)
6359 (funcall gnus-decode-encoded-word-function
6360 (nnheader-header-value))
6361 "(none)"))
6362 ;; From.
6363 (progn
6364 (goto-char p)
6365 (if (search-forward "\nfrom:" nil t)
6366 (funcall gnus-decode-encoded-address-function
6367 (nnheader-header-value))
6368 "(nobody)"))
6369 ;; Date.
6370 (progn
6371 (goto-char p)
6372 (if (search-forward "\ndate:" nil t)
6373 (nnheader-header-value) ""))
6374 ;; Message-ID.
6375 (progn
6376 (goto-char p)
6377 (setq id (if (re-search-forward
6378 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6379 ;; We do it this way to make sure the Message-ID
6380 ;; is (somewhat) syntactically valid.
6381 (buffer-substring (match-beginning 1)
6382 (match-end 1))
6383 ;; If there was no message-id, we just fake one
6384 ;; to make subsequent routines simpler.
6385 (nnheader-generate-fake-message-id number))))
6386 ;; References.
6387 (progn
6388 (goto-char p)
6389 (if (search-forward "\nreferences:" nil t)
6390 (progn
6391 (setq end (point))
6392 (prog1
6393 (nnheader-header-value)
6394 (setq ref
6395 (buffer-substring
6396 (progn
6397 (end-of-line)
6398 (search-backward ">" end t)
6399 (1+ (point)))
6400 (progn
6401 (search-backward "<" end t)
6402 (point))))))
6403 ;; Get the references from the in-reply-to header if there
6404 ;; were no references and the in-reply-to header looks
6405 ;; promising.
6406 (if (and (search-forward "\nin-reply-to:" nil t)
6407 (setq in-reply-to (nnheader-header-value))
6408 (string-match "<[^>]+>" in-reply-to))
6409 (let (ref2)
6410 (setq ref (substring in-reply-to (match-beginning 0)
6411 (match-end 0)))
6412 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6413 (setq ref2 (substring in-reply-to (match-beginning 0)
6414 (match-end 0)))
6415 (when (> (length ref2) (length ref))
6416 (setq ref ref2)))
6417 ref)
6418 (setq ref nil))))
6419 ;; Chars.
6420 (progn
6421 (goto-char p)
6422 (if (search-forward "\nchars: " nil t)
6423 (if (numberp (setq chars (ignore-errors (read cur))))
6424 chars -1)
6425 -1))
6426 ;; Lines.
6427 (progn
6428 (goto-char p)
6429 (if (search-forward "\nlines: " nil t)
6430 (if (numberp (setq lines (ignore-errors (read cur))))
6431 lines -1)
6432 -1))
6433 ;; Xref.
6434 (progn
6435 (goto-char p)
6436 (and (search-forward "\nxref:" nil t)
6437 (nnheader-header-value)))
6438 ;; Extra.
6439 (when gnus-extra-headers
6440 (let ((extra gnus-extra-headers)
6441 out)
6442 (while extra
6443 (goto-char p)
6444 (when (search-forward
6445 (concat "\n" (symbol-name (car extra)) ":") nil t)
6446 (push (cons (car extra) (nnheader-header-value))
6447 out))
6448 (pop extra))
6449 out))))
6450 (when (equal id ref)
6451 (setq ref nil))
6452
6453 (when gnus-alter-header-function
6454 (funcall gnus-alter-header-function header)
6455 (setq id (mail-header-id header)
6456 ref (gnus-parent-id (mail-header-references header))))
6457
6458 (when (setq header
6459 (gnus-dependencies-add-header
6460 header dependencies force-new))
6461 (push header headers))
6462 (goto-char (point-max))
6463 (widen))
6464 (nreverse headers)))))
6465
6466 ;; Goes through the xover lines and returns a list of vectors
6467 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6468 force-new dependencies
6469 group also-fetch-heads)
6470 "Parse the news overview data in the server buffer.
6471 Return a list of headers that match SEQUENCE (see
6472 `nntp-retrieve-headers')."
6473 ;; Get the Xref when the users reads the articles since most/some
6474 ;; NNTP servers do not include Xrefs when using XOVER.
6475 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6476 (let ((mail-parse-charset gnus-newsgroup-charset)
6477 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6478 (cur nntp-server-buffer)
6479 (dependencies (or dependencies gnus-newsgroup-dependencies))
6480 (allp (cond
6481 ((eq gnus-read-all-available-headers t)
6482 t)
6483 ((and (stringp gnus-read-all-available-headers)
6484 group)
6485 (string-match gnus-read-all-available-headers group))
6486 (t
6487 nil)))
6488 number headers header)
6489 (with-current-buffer nntp-server-buffer
6490 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6491 ;; Allow the user to mangle the headers before parsing them.
6492 (gnus-run-hooks 'gnus-parse-headers-hook)
6493 (goto-char (point-min))
6494 (gnus-parse-without-error
6495 (while (and (or sequence allp)
6496 (not (eobp)))
6497 (setq number (read cur))
6498 (when (not allp)
6499 (while (and sequence
6500 (< (car sequence) number))
6501 (setq sequence (cdr sequence))))
6502 (when (and (or allp
6503 (and sequence
6504 (eq number (car sequence))))
6505 (progn
6506 (setq sequence (cdr sequence))
6507 (setq header (inline
6508 (gnus-nov-parse-line
6509 number dependencies force-new)))))
6510 (push header headers))
6511 (forward-line 1)))
6512 ;; A common bug in inn is that if you have posted an article and
6513 ;; then retrieves the active file, it will answer correctly --
6514 ;; the new article is included. However, a NOV entry for the
6515 ;; article may not have been generated yet, so this may fail.
6516 ;; We work around this problem by retrieving the last few
6517 ;; headers using HEAD.
6518 (if (or (not also-fetch-heads)
6519 (not sequence))
6520 ;; We (probably) got all the headers.
6521 (nreverse headers)
6522 (let ((gnus-nov-is-evil t))
6523 (nconc
6524 (nreverse headers)
6525 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6526 (gnus-get-newsgroup-headers))))))))
6527
6528 (defun gnus-article-get-xrefs ()
6529 "Fill in the Xref value in `gnus-current-headers', if necessary.
6530 This is meant to be called in `gnus-article-internal-prepare-hook'."
6531 (let ((headers (with-current-buffer gnus-summary-buffer
6532 gnus-current-headers)))
6533 (or (not gnus-use-cross-reference)
6534 (not headers)
6535 (and (mail-header-xref headers)
6536 (not (string= (mail-header-xref headers) "")))
6537 (let ((case-fold-search t)
6538 xref)
6539 (save-restriction
6540 (nnheader-narrow-to-headers)
6541 (goto-char (point-min))
6542 (when (or (and (not (eobp))
6543 (eq (downcase (char-after)) ?x)
6544 (looking-at "Xref:"))
6545 (search-forward "\nXref:" nil t))
6546 (goto-char (1+ (match-end 0)))
6547 (setq xref (buffer-substring (point) (point-at-eol)))
6548 (mail-header-set-xref headers xref)))))))
6549
6550 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6551 "Find article ID and insert the summary line for that article.
6552 OLD-HEADER can either be a header or a line number to insert
6553 the subject line on.
6554 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6555 and OLD-HEADER will be used when the summary line is inserted,
6556 too, instead of trying to fetch new headers."
6557 (let* ((line (and (numberp old-header) old-header))
6558 (old-header (and (vectorp old-header) old-header))
6559 (header (cond ((and old-header use-old-header)
6560 old-header)
6561 ((and (numberp id)
6562 (gnus-number-to-header id))
6563 (gnus-number-to-header id))
6564 (t
6565 (gnus-read-header id))))
6566 (number (and (numberp id) id))
6567 d)
6568 (when header
6569 ;; Rebuild the thread that this article is part of and go to the
6570 ;; article we have fetched.
6571 (when (and (not gnus-show-threads)
6572 old-header)
6573 (when (and number
6574 (setq d (gnus-data-find (mail-header-number old-header))))
6575 (goto-char (gnus-data-pos d))
6576 (gnus-data-remove
6577 number
6578 (- (point-at-bol)
6579 (prog1
6580 (1+ (point-at-eol))
6581 (gnus-delete-line))))))
6582 ;; Remove list identifiers from subject.
6583 (let ((gnus-newsgroup-headers (list header)))
6584 (gnus-summary-remove-list-identifiers))
6585 (when old-header
6586 (mail-header-set-number header (mail-header-number old-header)))
6587 (setq gnus-newsgroup-sparse
6588 (delq (setq number (mail-header-number header))
6589 gnus-newsgroup-sparse))
6590 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6591 (push number gnus-newsgroup-limit)
6592 (gnus-rebuild-thread (mail-header-id header) line)
6593 (gnus-summary-goto-subject number nil t))
6594 (when (and (numberp number)
6595 (> number 0))
6596 ;; We have to update the boundaries even if we can't fetch the
6597 ;; article if ID is a number -- so that the next `P' or `N'
6598 ;; command will fetch the previous (or next) article even
6599 ;; if the one we tried to fetch this time has been canceled.
6600 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6601 (setq gnus-newsgroup-end number))
6602 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6603 (setq gnus-newsgroup-begin number))
6604 (setq gnus-newsgroup-unselected
6605 (delq number gnus-newsgroup-unselected)))
6606 ;; Report back a success?
6607 (and header (mail-header-number header))))
6608
6609 ;;; Process/prefix in the summary buffer
6610
6611 (defun gnus-summary-work-articles (n)
6612 "Return a list of articles to be worked upon.
6613 The prefix argument, the list of process marked articles, and the
6614 current article will be taken into consideration."
6615 (with-current-buffer gnus-summary-buffer
6616 (cond
6617 (n
6618 ;; A numerical prefix has been given.
6619 (setq n (prefix-numeric-value n))
6620 (let ((backward (< n 0))
6621 (n (abs (prefix-numeric-value n)))
6622 articles article)
6623 (save-excursion
6624 (while
6625 (and (> n 0)
6626 (push (setq article (gnus-summary-article-number))
6627 articles)
6628 (if backward
6629 (gnus-summary-find-prev nil article)
6630 (gnus-summary-find-next nil article)))
6631 (decf n)))
6632 (nreverse articles)))
6633 ((and (and transient-mark-mode mark-active) (mark))
6634 (message "region active")
6635 ;; Work on the region between point and mark.
6636 (let ((max (max (point) (mark)))
6637 articles article)
6638 (save-excursion
6639 (goto-char (min (point) (mark)))
6640 (while
6641 (and
6642 (push (setq article (gnus-summary-article-number)) articles)
6643 (gnus-summary-find-next nil article)
6644 (< (point) max)))
6645 (nreverse articles))))
6646 (gnus-newsgroup-processable
6647 ;; There are process-marked articles present.
6648 ;; Save current state.
6649 (gnus-summary-save-process-mark)
6650 ;; Return the list.
6651 (reverse gnus-newsgroup-processable))
6652 (t
6653 ;; Just return the current article.
6654 (list (gnus-summary-article-number))))))
6655
6656 (defmacro gnus-summary-iterate (arg &rest forms)
6657 "Iterate over the process/prefixed articles and do FORMS.
6658 ARG is the interactive prefix given to the command. FORMS will be
6659 executed with point over the summary line of the articles."
6660 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6661 `(let ((,articles (gnus-summary-work-articles ,arg)))
6662 (while ,articles
6663 (gnus-summary-goto-subject (car ,articles))
6664 ,@forms
6665 (pop ,articles)))))
6666
6667 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6668 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6669
6670 (defun gnus-summary-save-process-mark ()
6671 "Push the current set of process marked articles on the stack."
6672 (interactive)
6673 (push (copy-sequence gnus-newsgroup-processable)
6674 gnus-newsgroup-process-stack))
6675
6676 (defun gnus-summary-kill-process-mark ()
6677 "Push the current set of process marked articles on the stack and unmark."
6678 (interactive)
6679 (gnus-summary-save-process-mark)
6680 (gnus-summary-unmark-all-processable))
6681
6682 (defun gnus-summary-yank-process-mark ()
6683 "Pop the last process mark state off the stack and restore it."
6684 (interactive)
6685 (unless gnus-newsgroup-process-stack
6686 (error "Empty mark stack"))
6687 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6688
6689 (defun gnus-summary-process-mark-set (set)
6690 "Make SET into the current process marked articles."
6691 (gnus-summary-unmark-all-processable)
6692 (mapc 'gnus-summary-set-process-mark set))
6693
6694 ;;; Searching and stuff
6695
6696 (defun gnus-summary-search-group (&optional backward use-level)
6697 "Search for next unread newsgroup.
6698 If optional argument BACKWARD is non-nil, search backward instead."
6699 (with-current-buffer gnus-group-buffer
6700 (when (gnus-group-search-forward
6701 backward nil (if use-level (gnus-group-group-level) nil))
6702 (gnus-group-group-name))))
6703
6704 (defun gnus-summary-best-group (&optional exclude-group)
6705 "Find the name of the best unread group.
6706 If EXCLUDE-GROUP, do not go to this group."
6707 (with-current-buffer gnus-group-buffer
6708 (save-excursion
6709 (gnus-group-best-unread-group exclude-group))))
6710
6711 (defun gnus-summary-find-next (&optional unread article backward)
6712 (if backward
6713 (gnus-summary-find-prev unread article)
6714 (let* ((dummy (gnus-summary-article-intangible-p))
6715 (article (or article (gnus-summary-article-number)))
6716 (data (gnus-data-find-list article))
6717 result)
6718 (when (and (not dummy)
6719 (or (not gnus-summary-check-current)
6720 (not unread)
6721 (not (gnus-data-unread-p (car data)))))
6722 (setq data (cdr data)))
6723 (when (setq result
6724 (if unread
6725 (progn
6726 (while data
6727 (unless (memq (gnus-data-number (car data))
6728 (cond
6729 ((eq gnus-auto-goto-ignores
6730 'always-undownloaded)
6731 gnus-newsgroup-undownloaded)
6732 (gnus-plugged
6733 nil)
6734 ((eq gnus-auto-goto-ignores
6735 'unfetched)
6736 gnus-newsgroup-unfetched)
6737 ((eq gnus-auto-goto-ignores
6738 'undownloaded)
6739 gnus-newsgroup-undownloaded)))
6740 (when (gnus-data-unread-p (car data))
6741 (setq result (car data)
6742 data nil)))
6743 (setq data (cdr data)))
6744 result)
6745 (car data)))
6746 (goto-char (gnus-data-pos result))
6747 (gnus-data-number result)))))
6748
6749 (defun gnus-summary-find-prev (&optional unread article)
6750 (let* ((eobp (eobp))
6751 (article (or article (gnus-summary-article-number)))
6752 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6753 result)
6754 (when (and (not eobp)
6755 (or (not gnus-summary-check-current)
6756 (not unread)
6757 (not (gnus-data-unread-p (car data)))))
6758 (setq data (cdr data)))
6759 (when (setq result
6760 (if unread
6761 (progn
6762 (while data
6763 (unless (memq (gnus-data-number (car data))
6764 (cond
6765 ((eq gnus-auto-goto-ignores
6766 'always-undownloaded)
6767 gnus-newsgroup-undownloaded)
6768 (gnus-plugged
6769 nil)
6770 ((eq gnus-auto-goto-ignores
6771 'unfetched)
6772 gnus-newsgroup-unfetched)
6773 ((eq gnus-auto-goto-ignores
6774 'undownloaded)
6775 gnus-newsgroup-undownloaded)))
6776 (when (gnus-data-unread-p (car data))
6777 (setq result (car data)
6778 data nil)))
6779 (setq data (cdr data)))
6780 result)
6781 (car data)))
6782 (goto-char (gnus-data-pos result))
6783 (gnus-data-number result))))
6784
6785 (defun gnus-summary-find-subject (subject &optional unread backward article)
6786 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6787 (article (or article (gnus-summary-article-number)))
6788 (articles (gnus-data-list backward))
6789 (arts (gnus-data-find-list article articles))
6790 result)
6791 (when (or (not gnus-summary-check-current)
6792 (not unread)
6793 (not (gnus-data-unread-p (car arts))))
6794 (setq arts (cdr arts)))
6795 (while arts
6796 (and (or (not unread)
6797 (gnus-data-unread-p (car arts)))
6798 (vectorp (gnus-data-header (car arts)))
6799 (gnus-subject-equal
6800 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6801 (setq result (car arts)
6802 arts nil))
6803 (setq arts (cdr arts)))
6804 (and result
6805 (goto-char (gnus-data-pos result))
6806 (gnus-data-number result))))
6807
6808 (defun gnus-summary-search-forward (&optional unread subject backward)
6809 "Search forward for an article.
6810 If UNREAD, look for unread articles. If SUBJECT, look for
6811 articles with that subject. If BACKWARD, search backward instead."
6812 (cond (subject (gnus-summary-find-subject subject unread backward))
6813 (backward (gnus-summary-find-prev unread))
6814 (t (gnus-summary-find-next unread))))
6815
6816 (defun gnus-recenter (&optional n)
6817 "Center point in window and redisplay frame.
6818 Also do horizontal recentering."
6819 (interactive "P")
6820 (when (and gnus-auto-center-summary
6821 (not (eq gnus-auto-center-summary 'vertical)))
6822 (gnus-horizontal-recenter))
6823 (recenter-top-bottom n))
6824
6825 (put 'gnus-recenter 'isearch-scroll t)
6826
6827 (defun gnus-forward-line-ignore-invisible (n)
6828 "Move N lines forward (backward if N is negative).
6829 Like forward-line, but skip over (and don't count) invisible lines."
6830 (let (done)
6831 (while (and (> n 0) (not done))
6832 ;; If the following character is currently invisible,
6833 ;; skip all characters with that same `invisible' property value.
6834 (while (invisible-p (point))
6835 (goto-char (next-char-property-change (point))))
6836 (forward-line 1)
6837 (if (eobp)
6838 (setq done t)
6839 (setq n (1- n))))
6840 (while (and (< n 0) (not done))
6841 (forward-line -1)
6842 (if (bobp) (setq done t)
6843 (setq n (1+ n))
6844 (while (and (not (bobp)) (invisible-p (1- (point))))
6845 (goto-char (previous-char-property-change (point))))))))
6846
6847 (defun gnus-summary-recenter ()
6848 "Center point in the summary window.
6849 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6850 displayed, no centering will be performed."
6851 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6852 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6853 (interactive)
6854 ;; The user has to want it.
6855 (when gnus-auto-center-summary
6856 (let* ((top (cond ((< (window-height) 4) 0)
6857 ((< (window-height) 7) 1)
6858 (t (if (numberp gnus-auto-center-summary)
6859 gnus-auto-center-summary
6860 (/ (1- (window-height)) 2)))))
6861 (height (1- (window-height)))
6862 (bottom (save-excursion
6863 (goto-char (point-max))
6864 (gnus-forward-line-ignore-invisible (- height))
6865 (point)))
6866 (window (get-buffer-window (current-buffer))))
6867 (when (get-buffer-window gnus-article-buffer)
6868 ;; Only do recentering when the article buffer is displayed,
6869 ;; Set the window start to either `bottom', which is the biggest
6870 ;; possible valid number, or the second line from the top,
6871 ;; whichever is the least.
6872 (let ((top-pos (save-excursion
6873 (gnus-forward-line-ignore-invisible (- top))
6874 (point))))
6875 (if (> bottom top-pos)
6876 ;; Keep the second line from the top visible
6877 (set-window-start window top-pos)
6878 ;; Try to keep the bottom line visible; if it's partially
6879 ;; obscured, either scroll one more line to make it fully
6880 ;; visible, or revert to using TOP-POS.
6881 (save-excursion
6882 (goto-char (point-max))
6883 (gnus-forward-line-ignore-invisible -1)
6884 (let ((last-line-start (point)))
6885 (goto-char bottom)
6886 (set-window-start window (point) t)
6887 (when (not (pos-visible-in-window-p last-line-start window))
6888 (gnus-forward-line-ignore-invisible 1)
6889 (set-window-start window (min (point) top-pos) t)))))))
6890 ;; Do horizontal recentering while we're at it.
6891 (when (and (get-buffer-window (current-buffer) t)
6892 (not (eq gnus-auto-center-summary 'vertical)))
6893 (let ((selected (selected-window)))
6894 (select-window (get-buffer-window (current-buffer) t))
6895 (gnus-summary-position-point)
6896 (gnus-horizontal-recenter)
6897 (select-window selected))))))
6898
6899 (defun gnus-summary-jump-to-group (newsgroup)
6900 "Move point to NEWSGROUP in group mode buffer."
6901 ;; Keep update point of group mode buffer if visible.
6902 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6903 (save-window-excursion
6904 ;; Take care of tree window mode.
6905 (when (get-buffer-window gnus-group-buffer)
6906 (pop-to-buffer gnus-group-buffer))
6907 (gnus-group-jump-to-group newsgroup))
6908 (save-excursion
6909 ;; Take care of tree window mode.
6910 (if (get-buffer-window gnus-group-buffer 0)
6911 (pop-to-buffer gnus-group-buffer)
6912 (set-buffer gnus-group-buffer))
6913 (gnus-group-jump-to-group newsgroup))))
6914
6915 ;; This function returns a list of article numbers based on the
6916 ;; difference between the ranges of read articles in this group and
6917 ;; the range of active articles.
6918 (defun gnus-list-of-unread-articles (group)
6919 (let* ((read (gnus-info-read (gnus-get-info group)))
6920 (active (or (gnus-active group) (gnus-activate-group group)))
6921 (last (or (cdr active)
6922 (error "Group %s couldn't be activated " group)))
6923 (bottom (if gnus-newsgroup-maximum-articles
6924 (max (car active)
6925 (- last gnus-newsgroup-maximum-articles -1))
6926 (car active)))
6927 first nlast unread)
6928 ;; If none are read, then all are unread.
6929 (if (not read)
6930 (setq first bottom)
6931 ;; If the range of read articles is a single range, then the
6932 ;; first unread article is the article after the last read
6933 ;; article. Sounds logical, doesn't it?
6934 (if (and (not (listp (cdr read)))
6935 (or (< (car read) bottom)
6936 (progn (setq read (list read))
6937 nil)))
6938 (setq first (max bottom (1+ (cdr read))))
6939 ;; `read' is a list of ranges.
6940 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6941 (caar read)))
6942 1)
6943 (setq first bottom))
6944 (while read
6945 (when first
6946 (while (< first nlast)
6947 (setq unread (cons first unread)
6948 first (1+ first))))
6949 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6950 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6951 (setq read (cdr read)))))
6952 ;; And add the last unread articles.
6953 (while (<= first last)
6954 (setq unread (cons first unread)
6955 first (1+ first)))
6956 ;; Return the list of unread articles.
6957 (delq 0 (nreverse unread))))
6958
6959 (defun gnus-list-of-read-articles (group)
6960 "Return a list of unread, unticked and non-dormant articles."
6961 (let* ((info (gnus-get-info group))
6962 (marked (gnus-info-marks info))
6963 (active (gnus-active group)))
6964 (and info active
6965 (gnus-list-range-difference
6966 (gnus-list-range-difference
6967 (gnus-sorted-complement
6968 (gnus-uncompress-range
6969 (if gnus-newsgroup-maximum-articles
6970 (cons (max (car active)
6971 (- (cdr active)
6972 gnus-newsgroup-maximum-articles
6973 -1))
6974 (cdr active))
6975 active))
6976 (gnus-list-of-unread-articles group))
6977 (cdr (assq 'dormant marked)))
6978 (cdr (assq 'tick marked))))))
6979
6980 ;; This function returns a sequence of article numbers based on the
6981 ;; difference between the ranges of read articles in this group and
6982 ;; the range of active articles.
6983 (defun gnus-sequence-of-unread-articles (group)
6984 (let* ((read (gnus-info-read (gnus-get-info group)))
6985 (active (or (gnus-active group) (gnus-activate-group group)))
6986 (last (cdr active))
6987 (bottom (if gnus-newsgroup-maximum-articles
6988 (max (car active)
6989 (- last gnus-newsgroup-maximum-articles -1))
6990 (car active)))
6991 first nlast unread)
6992 ;; If none are read, then all are unread.
6993 (if (not read)
6994 (setq first bottom)
6995 ;; If the range of read articles is a single range, then the
6996 ;; first unread article is the article after the last read
6997 ;; article. Sounds logical, doesn't it?
6998 (if (and (not (listp (cdr read)))
6999 (or (< (car read) bottom)
7000 (progn (setq read (list read))
7001 nil)))
7002 (setq first (max bottom (1+ (cdr read))))
7003 ;; `read' is a list of ranges.
7004 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7005 (caar read)))
7006 1)
7007 (setq first bottom))
7008 (while read
7009 (when first
7010 (push (cons first nlast) unread))
7011 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7012 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7013 (setq read (cdr read)))))
7014 ;; And add the last unread articles.
7015 (cond ((not (and first last))
7016 nil)
7017 ((< first last)
7018 (push (cons first last) unread))
7019 ((= first last)
7020 (push first unread)))
7021 ;; Return the sequence of unread articles.
7022 (delq 0 (nreverse unread))))
7023
7024 ;; Various summary commands
7025
7026 (defun gnus-summary-select-article-buffer ()
7027 "Reconfigure windows to show the article buffer.
7028 If `gnus-widen-article-window' is set, show only the article
7029 buffer."
7030 (interactive)
7031 (if (not (gnus-buffer-live-p gnus-article-buffer))
7032 (error "There is no article buffer for this summary buffer")
7033 (unless (get-buffer-window gnus-article-buffer)
7034 (gnus-summary-show-article))
7035 (gnus-configure-windows
7036 (if gnus-widen-article-window
7037 'only-article
7038 'article)
7039 t)
7040 (select-window (get-buffer-window gnus-article-buffer))))
7041
7042 (defun gnus-summary-universal-argument (arg)
7043 "Perform any operation on all articles that are process/prefixed."
7044 (interactive "P")
7045 (let ((articles (gnus-summary-work-articles arg))
7046 func article)
7047 (if (eq
7048 (setq
7049 func
7050 (key-binding
7051 (read-key-sequence
7052 (substitute-command-keys
7053 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7054 'undefined)
7055 (gnus-error 1 "Undefined key")
7056 (save-excursion
7057 (while articles
7058 (gnus-summary-goto-subject (setq article (pop articles)))
7059 (let (gnus-newsgroup-processable)
7060 (command-execute func))
7061 (gnus-summary-remove-process-mark article)))))
7062 (gnus-summary-position-point))
7063
7064 (defun gnus-summary-toggle-truncation (&optional arg)
7065 "Toggle truncation of summary lines.
7066 With ARG, turn line truncation on if ARG is positive."
7067 (interactive "P")
7068 (setq truncate-lines
7069 (if (null arg) (not truncate-lines)
7070 (> (prefix-numeric-value arg) 0)))
7071 (redraw-display))
7072
7073 (defun gnus-summary-find-for-reselect ()
7074 "Return the number of an article to stay on across a reselect.
7075 The current article is considered, then following articles, then previous
7076 articles. An article is sought which is not canceled and isn't a temporary
7077 insertion from another group. If there's no such then return a dummy 0."
7078 (let (found)
7079 (dolist (rev '(nil t))
7080 (unless found ; don't demand the reverse list if we don't need it
7081 (let ((data (gnus-data-find-list
7082 (gnus-summary-article-number) (gnus-data-list rev))))
7083 (while (and data (not found))
7084 (if (and (< 0 (gnus-data-number (car data)))
7085 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7086 (setq found (gnus-data-number (car data))))
7087 (setq data (cdr data))))))
7088 (or found 0)))
7089
7090 (defun gnus-summary-reselect-current-group (&optional all rescan)
7091 "Exit and then reselect the current newsgroup.
7092 The prefix argument ALL means to select all articles."
7093 (interactive "P")
7094 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7095 (error "Ephemeral groups can't be reselected"))
7096 (let ((current-subject (gnus-summary-find-for-reselect))
7097 (group gnus-newsgroup-name))
7098 (setq gnus-newsgroup-begin nil)
7099 (gnus-summary-exit nil 'leave-hidden)
7100 ;; We have to adjust the point of group mode buffer because
7101 ;; point was moved to the next unread newsgroup by exiting.
7102 (gnus-summary-jump-to-group group)
7103 (when rescan
7104 (save-excursion
7105 (gnus-group-get-new-news-this-group 1)))
7106 (gnus-group-read-group all t)
7107 (gnus-summary-goto-subject current-subject nil t)))
7108
7109 (defun gnus-summary-rescan-group (&optional all)
7110 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7111 (interactive "P")
7112 (let ((config gnus-current-window-configuration))
7113 (gnus-summary-reselect-current-group all t)
7114 (gnus-configure-windows config)
7115 (when (eq config 'article)
7116 (gnus-summary-select-article))))
7117
7118 (defun gnus-summary-update-info (&optional non-destructive)
7119 (save-excursion
7120 (let ((group gnus-newsgroup-name))
7121 (when group
7122 (when gnus-newsgroup-kill-headers
7123 (setq gnus-newsgroup-killed
7124 (gnus-compress-sequence
7125 (gnus-sorted-union
7126 (gnus-list-range-intersection
7127 gnus-newsgroup-unselected gnus-newsgroup-killed)
7128 gnus-newsgroup-unreads)
7129 t)))
7130 (unless (listp (cdr gnus-newsgroup-killed))
7131 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7132 (let ((headers gnus-newsgroup-headers)
7133 (ephemeral-p (gnus-ephemeral-group-p group))
7134 info)
7135 (unless ephemeral-p
7136 (setq info (copy-sequence (gnus-get-info group))
7137 info (delq (gnus-info-params info) info)))
7138 ;; Set the new ranges of read articles.
7139 (with-current-buffer gnus-group-buffer
7140 (gnus-undo-force-boundary))
7141 (gnus-update-read-articles
7142 group (gnus-sorted-union
7143 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7144 ;; Set the current article marks.
7145 (let ((gnus-newsgroup-scored
7146 (if (and (not gnus-save-score)
7147 (not non-destructive))
7148 nil
7149 gnus-newsgroup-scored)))
7150 (save-excursion
7151 (gnus-update-marks)))
7152 ;; Do the cross-ref thing.
7153 (when gnus-use-cross-reference
7154 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7155 ;; Do not switch windows but change the buffer to work.
7156 (set-buffer gnus-group-buffer)
7157 (unless ephemeral-p
7158 (gnus-group-update-group
7159 group nil
7160 (equal info
7161 (setq info (copy-sequence (gnus-get-info group))
7162 info (delq (gnus-info-params info) info))))))))))
7163
7164 (defun gnus-summary-save-newsrc (&optional force)
7165 "Save the current number of read/marked articles in the dribble buffer.
7166 The dribble buffer will then be saved.
7167 If FORCE (the prefix), also save the .newsrc file(s)."
7168 (interactive "P")
7169 (gnus-summary-update-info t)
7170 (if force
7171 (gnus-save-newsrc-file)
7172 (gnus-dribble-save)))
7173
7174 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7175 (declare-function gnus-article-stop-animations "gnus-art" ())
7176
7177 (defun gnus-summary-exit (&optional temporary leave-hidden)
7178 "Exit reading current newsgroup, and then return to group selection mode.
7179 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7180 (interactive)
7181 (gnus-set-global-variables)
7182 (when (gnus-buffer-live-p gnus-article-buffer)
7183 (with-current-buffer gnus-article-buffer
7184 (mm-destroy-parts gnus-article-mime-handles)
7185 ;; Set it to nil for safety reason.
7186 (setq gnus-article-mime-handle-alist nil)
7187 (setq gnus-article-mime-handles nil)))
7188 (gnus-kill-save-kill-buffer)
7189 (gnus-async-halt-prefetch)
7190 (let* ((group gnus-newsgroup-name)
7191 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7192 (gnus-group-is-exiting-p t)
7193 (article-buffer gnus-article-buffer)
7194 (original-article-buffer gnus-original-article-buffer)
7195 (mode major-mode)
7196 (group-point nil)
7197 (buf (current-buffer))
7198 ;; `gnus-single-article-buffer' is nil buffer-locally in
7199 ;; ephemeral group of which summary buffer will be killed,
7200 ;; but the global value may be non-nil.
7201 (single-article-buffer gnus-single-article-buffer))
7202 (unless quit-config
7203 ;; Do adaptive scoring, and possibly save score files.
7204 (when gnus-newsgroup-adaptive
7205 (gnus-score-adaptive))
7206 (when gnus-use-scoring
7207 (gnus-score-save)))
7208 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7209 (when gnus-use-cache
7210 (gnus-cache-possibly-remove-articles)
7211 (gnus-cache-save-buffers))
7212 (gnus-async-prefetch-remove-group group)
7213 (when gnus-suppress-duplicates
7214 (gnus-dup-enter-articles))
7215 (when gnus-use-trees
7216 (gnus-tree-close))
7217 (when gnus-use-cache
7218 (gnus-cache-write-active))
7219 ;; Remove entries for this group.
7220 (nnmail-purge-split-history (gnus-group-real-name group))
7221 ;; Make all changes in this group permanent.
7222 (unless quit-config
7223 (gnus-run-hooks 'gnus-exit-group-hook)
7224 (gnus-summary-update-info))
7225 (gnus-close-group group)
7226 ;; Make sure where we were, and go to next newsgroup.
7227 (when (buffer-live-p (get-buffer gnus-group-buffer))
7228 (set-buffer gnus-group-buffer))
7229 (unless quit-config
7230 (gnus-group-jump-to-group group))
7231 (gnus-run-hooks 'gnus-summary-exit-hook)
7232 (unless (or quit-config
7233 (not gnus-summary-next-group-on-exit)
7234 ;; If this group has disappeared from the summary
7235 ;; buffer, don't skip forwards.
7236 (not (string= group (gnus-group-group-name))))
7237 (gnus-group-next-unread-group 1))
7238 (setq group-point (point))
7239 (gnus-article-stop-animations)
7240 (if temporary
7241 nil ;Nothing to do.
7242 (set-buffer buf)
7243 (if (not gnus-kill-summary-on-exit)
7244 (progn
7245 (gnus-deaden-summary)
7246 (setq mode nil))
7247 (when (get-buffer gnus-article-buffer)
7248 (bury-buffer gnus-article-buffer))
7249 ;; Return to group mode buffer.
7250 (when (eq mode 'gnus-summary-mode)
7251 (gnus-kill-buffer buf)))
7252
7253 (setq gnus-current-select-method gnus-select-method)
7254 (when (gnus-buffer-live-p gnus-group-buffer)
7255 (set-buffer gnus-group-buffer))
7256 (if quit-config
7257 (gnus-handle-ephemeral-exit quit-config)
7258 (goto-char group-point)
7259 ;; If gnus-group-buffer is already displayed, make sure we also move
7260 ;; the cursor in the window that displays it.
7261 (let ((win (get-buffer-window (current-buffer) 0)))
7262 (if win (set-window-point win (point))))
7263 (unless leave-hidden
7264 (gnus-configure-windows 'group 'force)))
7265
7266 ;; If we have several article buffers, we kill them at exit.
7267 (unless single-article-buffer
7268 (when (gnus-buffer-live-p article-buffer)
7269 (with-current-buffer article-buffer
7270 ;; Don't kill sticky article buffers
7271 (unless (eq major-mode 'gnus-sticky-article-mode)
7272 (gnus-kill-buffer article-buffer)
7273 (setq gnus-article-current nil))))
7274 (gnus-kill-buffer original-article-buffer))
7275
7276 ;; Clear the current group name.
7277 (unless quit-config
7278 (setq gnus-newsgroup-name nil)))))
7279
7280 (declare-function gnus-stop-downloads "gnus-art" ())
7281
7282 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7283 (defun gnus-summary-exit-no-update (&optional no-questions)
7284 "Quit reading current newsgroup without updating read article info."
7285 (interactive)
7286 (let* ((group gnus-newsgroup-name)
7287 (gnus-group-is-exiting-p t)
7288 (gnus-group-is-exiting-without-update-p t)
7289 (quit-config (gnus-group-quit-config group)))
7290 (when (or no-questions
7291 (gnus-ephemeral-group-p group)
7292 gnus-expert-user
7293 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7294 (gnus-async-halt-prefetch)
7295 (run-hooks 'gnus-summary-prepare-exit-hook)
7296 (when (gnus-buffer-live-p gnus-article-buffer)
7297 (with-current-buffer gnus-article-buffer
7298 (gnus-article-stop-animations)
7299 (gnus-stop-downloads)
7300 (mm-destroy-parts gnus-article-mime-handles)
7301 ;; Set it to nil for safety reason.
7302 (setq gnus-article-mime-handle-alist nil)
7303 (setq gnus-article-mime-handles nil)))
7304 ;; If we have several article buffers, we kill them at exit.
7305 (unless gnus-single-article-buffer
7306 (gnus-kill-buffer gnus-article-buffer)
7307 (gnus-kill-buffer gnus-original-article-buffer)
7308 (setq gnus-article-current nil))
7309 ;; Return to the group buffer.
7310 (if (not gnus-kill-summary-on-exit)
7311 (progn
7312 (gnus-deaden-summary)
7313 (gnus-configure-windows 'group 'force))
7314 (gnus-configure-windows 'group 'force)
7315 (gnus-close-group group)
7316 (gnus-kill-buffer gnus-summary-buffer))
7317 (unless gnus-single-article-buffer
7318 (setq gnus-article-current nil))
7319 (when gnus-use-trees
7320 (gnus-tree-close))
7321 (gnus-async-prefetch-remove-group group)
7322 (when (get-buffer gnus-article-buffer)
7323 (bury-buffer gnus-article-buffer))
7324 ;; Clear the current group name.
7325 (setq gnus-newsgroup-name nil)
7326 (unless (gnus-ephemeral-group-p group)
7327 (gnus-group-update-group group nil t))
7328 (when (equal (gnus-group-group-name) group)
7329 (gnus-group-next-unread-group 1))
7330 (gnus-article-stop-animations)
7331 (when quit-config
7332 (gnus-handle-ephemeral-exit quit-config)))))
7333
7334 (defun gnus-handle-ephemeral-exit (quit-config)
7335 "Handle movement when leaving an ephemeral group.
7336 The state which existed when entering the ephemeral is reset."
7337 (if (not (buffer-live-p (car quit-config)))
7338 (when (gnus-buffer-live-p gnus-group-buffer)
7339 (gnus-configure-windows 'group 'force))
7340 (set-buffer (car quit-config))
7341 (unless (eq (cdr quit-config) 'group)
7342 (setq gnus-current-select-method
7343 (gnus-find-method-for-group gnus-newsgroup-name)))
7344 (cond ((derived-mode-p 'gnus-summary-mode)
7345 (gnus-set-global-variables))
7346 ((derived-mode-p 'gnus-article-mode)
7347 (save-current-buffer
7348 ;; The `gnus-summary-buffer' variable may point
7349 ;; to the old summary buffer when using a single
7350 ;; article buffer.
7351 (unless (gnus-buffer-live-p gnus-summary-buffer)
7352 (set-buffer gnus-group-buffer))
7353 (set-buffer gnus-summary-buffer)
7354 (gnus-set-global-variables))))
7355 (if (or (eq (cdr quit-config) 'article)
7356 (eq (cdr quit-config) 'pick))
7357 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7358 (gnus-configure-windows 'pick 'force)
7359 (gnus-configure-windows (cdr quit-config) 'force))
7360 (gnus-configure-windows (cdr quit-config) 'force))
7361 (when (derived-mode-p 'gnus-summary-mode)
7362 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7363 next-unread-noselect))
7364 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7365 'next-noselect)
7366 (gnus-summary-next-subject 1 nil t))
7367 ((eq gnus-auto-select-on-ephemeral-exit
7368 'next-unread-noselect)
7369 (gnus-summary-next-subject 1 t t))))
7370 ;; Hide the article buffer which displays the article different
7371 ;; from the one that the cursor points to in the summary buffer.
7372 (gnus-configure-windows 'summary 'force))
7373 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7374 (gnus-summary-next-subject 1))
7375 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7376 (gnus-summary-next-subject 1 t))))
7377 (gnus-summary-recenter)
7378 (gnus-summary-position-point))))
7379
7380 ;;; Dead summaries.
7381
7382 (defvar gnus-dead-summary-mode-map
7383 (let ((map (make-keymap)))
7384 (suppress-keymap map)
7385 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7386 (dolist (key '("\C-d" "\r" "\177" [delete]))
7387 (define-key map key 'gnus-summary-wake-up-the-dead))
7388 (dolist (key '("q" "Q"))
7389 (define-key map key 'bury-buffer))
7390 map))
7391
7392 (define-minor-mode gnus-dead-summary-mode
7393 "Minor mode for Gnus summary buffers."
7394 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7395 (unless (derived-mode-p 'gnus-summary-mode)
7396 (setq gnus-dead-summary-mode nil)))
7397
7398 (defun gnus-deaden-summary ()
7399 "Make the current summary buffer into a dead summary buffer."
7400 ;; Kill any previous dead summary buffer.
7401 (when (and gnus-dead-summary
7402 (buffer-name gnus-dead-summary))
7403 (with-current-buffer gnus-dead-summary
7404 (when gnus-dead-summary-mode
7405 (kill-buffer (current-buffer)))))
7406 ;; Make this the current dead summary.
7407 (setq gnus-dead-summary (current-buffer))
7408 (gnus-dead-summary-mode 1)
7409 (let ((name (buffer-name)))
7410 (when (string-match "Summary" name)
7411 (rename-buffer
7412 (concat (substring name 0 (match-beginning 0)) "Dead "
7413 (substring name (match-beginning 0)))
7414 t)
7415 (bury-buffer))))
7416
7417 (defun gnus-kill-or-deaden-summary (buffer)
7418 "Kill or deaden the summary BUFFER."
7419 (save-excursion
7420 (when (and (buffer-name buffer)
7421 (not gnus-single-article-buffer))
7422 (with-current-buffer buffer
7423 (gnus-kill-buffer gnus-article-buffer)
7424 (gnus-kill-buffer gnus-original-article-buffer)))
7425 (cond
7426 ;; Kill the buffer.
7427 (gnus-kill-summary-on-exit
7428 (when (and gnus-use-trees
7429 (gnus-buffer-exists-p buffer))
7430 (with-current-buffer buffer
7431 (gnus-tree-close)))
7432 (gnus-kill-buffer buffer))
7433 ;; Deaden the buffer.
7434 ((gnus-buffer-exists-p buffer)
7435 (with-current-buffer buffer
7436 (gnus-deaden-summary))))))
7437
7438 (defun gnus-summary-wake-up-the-dead (&rest args)
7439 "Wake up the dead summary buffer."
7440 (interactive)
7441 (gnus-dead-summary-mode -1)
7442 (let ((name (buffer-name)))
7443 (when (string-match "Dead " name)
7444 (rename-buffer
7445 (concat (substring name 0 (match-beginning 0))
7446 (substring name (match-end 0)))
7447 t)))
7448 (gnus-message 3 "This dead summary is now alive again"))
7449
7450 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7451 (defun gnus-summary-describe-group (&optional force)
7452 "Describe the current newsgroup."
7453 (interactive "P")
7454 (gnus-group-describe-group force gnus-newsgroup-name))
7455
7456 (defun gnus-summary-describe-briefly ()
7457 "Describe summary mode commands briefly."
7458 (interactive)
7459 (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")))
7460
7461 ;; Walking around group mode buffer from summary mode.
7462
7463 (defun gnus-summary-next-group (&optional no-article target-group backward)
7464 "Exit current newsgroup and then select next unread newsgroup.
7465 If prefix argument NO-ARTICLE is non-nil, no article is selected
7466 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7467 previous group instead."
7468 (interactive "P")
7469 ;; Stop pre-fetching.
7470 (gnus-async-halt-prefetch)
7471 (let ((current-group gnus-newsgroup-name)
7472 (current-buffer (current-buffer))
7473 entered)
7474 ;; First we semi-exit this group to update Xrefs and all variables.
7475 ;; We can't do a real exit, because the window conf must remain
7476 ;; the same in case the user is prompted for info, and we don't
7477 ;; want the window conf to change before that...
7478 (gnus-summary-exit t)
7479 (while (not entered)
7480 ;; Then we find what group we are supposed to enter.
7481 (set-buffer gnus-group-buffer)
7482 (gnus-group-jump-to-group current-group)
7483 (setq target-group
7484 (or target-group
7485 (if (eq gnus-keep-same-level 'best)
7486 (gnus-summary-best-group gnus-newsgroup-name)
7487 (gnus-summary-search-group backward gnus-keep-same-level))))
7488 (if (not target-group)
7489 ;; There are no further groups, so we return to the group
7490 ;; buffer.
7491 (progn
7492 (gnus-message 5 "Returning to the group buffer")
7493 (setq entered t)
7494 (when (gnus-buffer-live-p current-buffer)
7495 (set-buffer current-buffer)
7496 (gnus-summary-exit))
7497 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7498 ;; We try to enter the target group.
7499 (gnus-group-jump-to-group target-group)
7500 (let ((unreads (gnus-group-group-unread)))
7501 (if (and (or (eq t unreads)
7502 (and unreads (not (zerop unreads))))
7503 (gnus-summary-read-group
7504 target-group nil no-article
7505 (and (buffer-name current-buffer) current-buffer)
7506 nil backward))
7507 (setq entered t)
7508 (setq current-group target-group
7509 target-group nil)))))))
7510
7511 (defun gnus-summary-prev-group (&optional no-article)
7512 "Exit current newsgroup and then select previous unread newsgroup.
7513 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7514 (interactive "P")
7515 (gnus-summary-next-group no-article nil t))
7516
7517 ;; Walking around summary lines.
7518
7519 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7520 "Go to the first subject satisfying any non-nil constraint.
7521 If UNREAD is non-nil, the article should be unread.
7522 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7523 If UNSEEN is non-nil, the article should be unseen as well as unread.
7524 Returns the article selected or nil if there are no matching articles."
7525 (interactive "P")
7526 (cond
7527 ;; Empty summary.
7528 ((null gnus-newsgroup-data)
7529 (gnus-message 3 "No articles in the group")
7530 nil)
7531 ;; Pick the first article.
7532 ((not (or unread undownloaded unseen))
7533 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7534 (gnus-data-number (car gnus-newsgroup-data)))
7535 ;; Find the first unread article.
7536 (t
7537 (let ((data gnus-newsgroup-data))
7538 (while (and data
7539 (let ((num (gnus-data-number (car data))))
7540 (or (memq num gnus-newsgroup-unfetched)
7541 (not (or (and unread
7542 (memq num gnus-newsgroup-unreads))
7543 (and undownloaded
7544 (memq num gnus-newsgroup-undownloaded))
7545 (and unseen
7546 (memq num gnus-newsgroup-unseen)
7547 (memq num gnus-newsgroup-unreads)))))))
7548 (setq data (cdr data)))
7549 (prog1
7550 (if data
7551 (progn
7552 (goto-char (gnus-data-pos (car data)))
7553 (gnus-data-number (car data)))
7554 (gnus-message 3 "No more%s articles"
7555 (let* ((r (when unread " unread"))
7556 (d (when undownloaded " undownloaded"))
7557 (s (when unseen " unseen"))
7558 (l (delq nil (list r d s))))
7559 (cond ((= 3 (length l))
7560 (concat r "," d ", or" s))
7561 ((= 2 (length l))
7562 (concat (car l) ", or" (cadr l)))
7563 ((= 1 (length l))
7564 (car l))
7565 (t
7566 ""))))
7567 nil
7568 )
7569 (gnus-summary-position-point))))))
7570
7571 (defun gnus-summary-next-subject (n &optional unread dont-display)
7572 "Go to next N'th summary line.
7573 If N is negative, go to the previous N'th subject line.
7574 If UNREAD is non-nil, only unread articles are selected.
7575 The difference between N and the actual number of steps taken is
7576 returned."
7577 (interactive "p")
7578 (let ((backward (< n 0))
7579 (n (abs n)))
7580 (while (and (> n 0)
7581 (if backward
7582 (gnus-summary-find-prev unread)
7583 (gnus-summary-find-next unread)))
7584 (unless (zerop (setq n (1- n)))
7585 (gnus-summary-show-thread)))
7586 (when (/= 0 n)
7587 (gnus-message 7 "No more%s articles"
7588 (if unread " unread" "")))
7589 (unless dont-display
7590 (gnus-summary-recenter)
7591 (gnus-summary-position-point))
7592 n))
7593
7594 (defun gnus-summary-next-unread-subject (n)
7595 "Go to next N'th unread summary line."
7596 (interactive "p")
7597 (gnus-summary-next-subject n t))
7598
7599 (defun gnus-summary-prev-subject (n &optional unread)
7600 "Go to previous N'th summary line.
7601 If optional argument UNREAD is non-nil, only unread article is selected."
7602 (interactive "p")
7603 (gnus-summary-next-subject (- n) unread))
7604
7605 (defun gnus-summary-prev-unread-subject (n)
7606 "Go to previous N'th unread summary line."
7607 (interactive "p")
7608 (gnus-summary-next-subject (- n) t))
7609
7610 (defun gnus-summary-goto-subjects (articles)
7611 "Insert the subject header for ARTICLES in the current buffer."
7612 (save-excursion
7613 (dolist (article articles)
7614 (gnus-summary-goto-subject article t)))
7615 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7616 (gnus-summary-position-point))
7617
7618 (defun gnus-summary-goto-subject (article &optional force silent)
7619 "Go to the subject line of ARTICLE.
7620 If FORCE, also allow jumping to articles not currently shown."
7621 (interactive "nArticle number: ")
7622 (unless (numberp article)
7623 (error "Article %s is not a number" article))
7624 (let ((b (point))
7625 (data (gnus-data-find article)))
7626 ;; We read in the article if we have to.
7627 (and (not data)
7628 force
7629 (gnus-summary-insert-subject
7630 article
7631 (if (or (numberp force) (vectorp force)) force)
7632 t)
7633 (setq data (gnus-data-find article)))
7634 (goto-char b)
7635 (if (not data)
7636 (progn
7637 (unless silent
7638 (gnus-message 3 "Can't find article %d" article))
7639 nil)
7640 (let ((pt (gnus-data-pos data)))
7641 (goto-char pt)
7642 (gnus-summary-set-article-display-arrow pt))
7643 (gnus-summary-position-point)
7644 article)))
7645
7646 ;; Walking around summary lines with displaying articles.
7647
7648 (defun gnus-summary-expand-window (&optional arg)
7649 "Make the summary buffer take up the entire Emacs frame.
7650 Given a prefix, will force an `article' buffer configuration."
7651 (interactive "P")
7652 (if arg
7653 (gnus-configure-windows 'article 'force)
7654 (gnus-configure-windows 'summary 'force)))
7655
7656 (defun gnus-summary-display-article (article &optional all-header)
7657 "Display ARTICLE in article buffer."
7658 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7659 (with-current-buffer gnus-article-buffer
7660 (derived-mode-p 'gnus-article-mode)))
7661 (gnus-article-setup-buffer))
7662 (gnus-set-global-variables)
7663 (with-current-buffer gnus-article-buffer
7664 (setq gnus-article-charset gnus-newsgroup-charset)
7665 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7666 (mm-enable-multibyte))
7667 (if (null article)
7668 nil
7669 (prog1
7670 (if gnus-summary-display-article-function
7671 (funcall gnus-summary-display-article-function article all-header)
7672 (gnus-article-prepare article all-header))
7673 (gnus-run-hooks 'gnus-select-article-hook)
7674 (when (and gnus-current-article
7675 (not (zerop gnus-current-article)))
7676 (gnus-summary-goto-subject gnus-current-article))
7677 (gnus-summary-recenter)
7678 (when (and gnus-use-trees gnus-show-threads)
7679 (gnus-possibly-generate-tree article)
7680 (gnus-highlight-selected-tree article))
7681 ;; Successfully display article.
7682 (gnus-article-set-window-start
7683 (cdr (assq article gnus-newsgroup-bookmarks))))))
7684
7685 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7686 "Select the current article.
7687 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7688 non-nil, the article will be re-fetched even if it already present in
7689 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7690 be displayed."
7691 ;; Make sure we are in the summary buffer to work around bbdb bug.
7692 (unless (derived-mode-p 'gnus-summary-mode)
7693 (set-buffer gnus-summary-buffer))
7694 (let ((article (or article (gnus-summary-article-number)))
7695 (all-headers (not (not all-headers))) ;Must be t or nil.
7696 gnus-summary-display-article-function)
7697 (and (not pseudo)
7698 (gnus-summary-article-pseudo-p article)
7699 (error "This is a pseudo-article"))
7700 (with-current-buffer gnus-summary-buffer
7701 (if (or (and gnus-single-article-buffer
7702 (or (null gnus-current-article)
7703 (null gnus-article-current)
7704 (null (get-buffer gnus-article-buffer))
7705 (not (eq article (cdr gnus-article-current)))
7706 (not (equal (car gnus-article-current)
7707 gnus-newsgroup-name))
7708 (not (get-buffer gnus-original-article-buffer))))
7709 (and (not gnus-single-article-buffer)
7710 (or (null gnus-current-article)
7711 (not (get-buffer gnus-original-article-buffer))
7712 (not (eq gnus-current-article article))))
7713 force)
7714 ;; The requested article is different from the current article.
7715 (progn
7716 (gnus-summary-display-article article all-headers)
7717 (when (gnus-buffer-live-p gnus-article-buffer)
7718 (with-current-buffer gnus-article-buffer
7719 (if (not gnus-article-decoded-p) ;; a local variable
7720 (mm-disable-multibyte))))
7721 (gnus-article-set-window-start
7722 (cdr (assq article gnus-newsgroup-bookmarks)))
7723 article)
7724 'old))))
7725
7726 (defun gnus-summary-force-verify-and-decrypt ()
7727 "Display buttons for signed/encrypted parts and verify/decrypt them."
7728 (interactive)
7729 (let ((mm-verify-option 'known)
7730 (mm-decrypt-option 'known)
7731 (gnus-article-emulate-mime t)
7732 (gnus-buttonized-mime-types (append (list "multipart/signed"
7733 "multipart/encrypted")
7734 gnus-buttonized-mime-types)))
7735 (gnus-summary-select-article nil 'force)))
7736
7737 (defun gnus-summary-next-article (&optional unread subject backward push)
7738 "Select the next article.
7739 If UNREAD, only unread articles are selected.
7740 If SUBJECT, only articles with SUBJECT are selected.
7741 If BACKWARD, the previous article is selected instead of the next."
7742 (interactive "P")
7743 ;; Make sure we are in the summary buffer.
7744 (unless (derived-mode-p 'gnus-summary-mode)
7745 (set-buffer gnus-summary-buffer))
7746 (cond
7747 ;; Is there such an article?
7748 ((and (gnus-summary-search-forward unread subject backward)
7749 (or (gnus-summary-display-article (gnus-summary-article-number))
7750 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7751 (gnus-summary-position-point))
7752 ;; If not, we try the first unread, if that is wanted.
7753 ((and subject
7754 gnus-auto-select-same
7755 (gnus-summary-first-unread-article))
7756 (gnus-summary-position-point)
7757 (gnus-message 6 "Wrapped"))
7758 ;; Try to get next/previous article not displayed in this group.
7759 ((and gnus-auto-extend-newsgroup
7760 (not unread) (not subject))
7761 (gnus-summary-goto-article
7762 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7763 nil (count-lines (point-min) (point))))
7764 ;; Go to next/previous group.
7765 (t
7766 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7767 (gnus-summary-jump-to-group gnus-newsgroup-name))
7768 (let ((cmd last-command-event)
7769 (point
7770 (with-current-buffer gnus-group-buffer
7771 (point)))
7772 (current-summary (current-buffer))
7773 (group
7774 (if (eq gnus-keep-same-level 'best)
7775 (gnus-summary-best-group gnus-newsgroup-name)
7776 (gnus-summary-search-group backward gnus-keep-same-level))))
7777 ;; Select next unread newsgroup automagically.
7778 (cond
7779 ((or (not gnus-auto-select-next)
7780 (not cmd))
7781 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7782 ((or (eq gnus-auto-select-next 'quietly)
7783 (and (eq gnus-auto-select-next 'slightly-quietly)
7784 push)
7785 (and (eq gnus-auto-select-next 'almost-quietly)
7786 (gnus-summary-last-article-p)))
7787 ;; Select quietly.
7788 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7789 (gnus-summary-exit)
7790 (gnus-message 7 "No more%s articles (%s)..."
7791 (if unread " unread" "")
7792 (if group (concat "selecting " group)
7793 "exiting"))
7794 (gnus-summary-next-group nil group backward)))
7795 (t
7796 (when (numberp last-input-event)
7797 ;; Somehow or other, we may now have selected a different
7798 ;; window. Make point go back to the summary buffer.
7799 (when (eq current-summary (current-buffer))
7800 ;; FIXME: This burps when get-buffer-window returns nil.
7801 (select-window (get-buffer-window current-summary 0)))
7802 (gnus-summary-walk-group-buffer
7803 gnus-newsgroup-name cmd unread backward point))))))))
7804
7805 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7806 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7807 (?\C-p (gnus-group-prev-unread-group 1))))
7808 (cursor-in-echo-area t)
7809 keve key group ended prompt)
7810 (with-current-buffer gnus-group-buffer
7811 (goto-char start)
7812 (setq group
7813 (if (eq gnus-keep-same-level 'best)
7814 (gnus-summary-best-group gnus-newsgroup-name)
7815 (gnus-summary-search-group backward gnus-keep-same-level))))
7816 (while (not ended)
7817 (setq prompt
7818 (format
7819 "No more%s articles%s " (if unread " unread" "")
7820 (if (and group
7821 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7822 (format " (Type %s for %s [%s])"
7823 (single-key-description cmd)
7824 (gnus-group-decoded-name group)
7825 (gnus-group-unread group))
7826 (format " (Type %s to exit %s)"
7827 (single-key-description cmd)
7828 (gnus-group-decoded-name gnus-newsgroup-name)))))
7829 ;; Confirm auto selection.
7830 (setq key (car (setq keve (gnus-read-event-char prompt)))
7831 ended t)
7832 (cond
7833 ((assq key keystrokes)
7834 (let ((obuf (current-buffer)))
7835 (switch-to-buffer gnus-group-buffer)
7836 (when group
7837 (gnus-group-jump-to-group group))
7838 (eval (cadr (assq key keystrokes)))
7839 (setq group (gnus-group-group-name))
7840 (switch-to-buffer obuf))
7841 (setq ended nil))
7842 ((equal key cmd)
7843 (if (or (not group)
7844 (gnus-ephemeral-group-p gnus-newsgroup-name))
7845 (gnus-summary-exit)
7846 (gnus-summary-next-group nil group backward)))
7847 (t
7848 (push (cdr keve) unread-command-events))))))
7849
7850 (defun gnus-summary-next-unread-article ()
7851 "Select unread article after current one."
7852 (interactive)
7853 (gnus-summary-next-article
7854 (or (not (eq gnus-summary-goto-unread 'never))
7855 (gnus-summary-last-article-p (gnus-summary-article-number)))
7856 (and gnus-auto-select-same
7857 (gnus-summary-article-subject))))
7858
7859 (defun gnus-summary-prev-article (&optional unread subject)
7860 "Select the article before the current one.
7861 If UNREAD is non-nil, only unread articles are selected."
7862 (interactive "P")
7863 (gnus-summary-next-article unread subject t))
7864
7865 (defun gnus-summary-prev-unread-article ()
7866 "Select unread article before current one."
7867 (interactive)
7868 (gnus-summary-prev-article
7869 (or (not (eq gnus-summary-goto-unread 'never))
7870 (gnus-summary-first-article-p (gnus-summary-article-number)))
7871 (and gnus-auto-select-same
7872 (gnus-summary-article-subject))))
7873
7874 (declare-function gnus-article-only-boring-p "gnus-art" ())
7875
7876 (defun gnus-summary-next-page (&optional lines circular stop)
7877 "Show next page of the selected article.
7878 If at the end of the current article, select the next article.
7879 LINES says how many lines should be scrolled up.
7880
7881 If CIRCULAR is non-nil, go to the start of the article instead of
7882 selecting the next article when reaching the end of the current
7883 article.
7884
7885 If STOP is non-nil, just stop when reaching the end of the message.
7886
7887 Also see the variable `gnus-article-skip-boring'."
7888 (interactive "P")
7889 (gnus-set-global-variables)
7890 (let ((article (gnus-summary-article-number))
7891 (article-window (get-buffer-window gnus-article-buffer t))
7892 endp)
7893 ;; If the buffer is empty, we have no article.
7894 (unless article
7895 (error "No article to select"))
7896 (gnus-configure-windows 'article)
7897 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7898 (if (and (eq gnus-summary-goto-unread 'never)
7899 (not (gnus-summary-last-article-p article)))
7900 (gnus-summary-next-article)
7901 (gnus-summary-next-unread-article))
7902 (if (or (null gnus-current-article)
7903 (null gnus-article-current)
7904 (/= article (cdr gnus-article-current))
7905 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7906 ;; Selected subject is different from current article's.
7907 (gnus-summary-display-article article)
7908 (when article-window
7909 (gnus-eval-in-buffer-window gnus-article-buffer
7910 (setq endp (or (gnus-article-next-page lines)
7911 (gnus-article-only-boring-p))))
7912 (when endp
7913 (cond ((or stop gnus-summary-stop-at-end-of-message)
7914 (gnus-message 3 "End of message"))
7915 (circular
7916 (gnus-summary-beginning-of-article))
7917 (lines
7918 (gnus-message 3 "End of message"))
7919 ((null lines)
7920 (if (and (eq gnus-summary-goto-unread 'never)
7921 (not (gnus-summary-last-article-p article)))
7922 (gnus-summary-next-article)
7923 (gnus-summary-next-unread-article))))))))
7924 (gnus-summary-recenter)
7925 (gnus-summary-position-point)))
7926
7927 (defun gnus-summary-prev-page (&optional lines move)
7928 "Show previous page of selected article.
7929 Argument LINES specifies lines to be scrolled down.
7930 If MOVE, move to the previous unread article if point is at
7931 the beginning of the buffer."
7932 (interactive "P")
7933 (let ((article (gnus-summary-article-number))
7934 (article-window (get-buffer-window gnus-article-buffer t))
7935 endp)
7936 (gnus-configure-windows 'article)
7937 (if (or (null gnus-current-article)
7938 (null gnus-article-current)
7939 (/= article (cdr gnus-article-current))
7940 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7941 ;; Selected subject is different from current article's.
7942 (gnus-summary-display-article article)
7943 (gnus-summary-recenter)
7944 (when article-window
7945 (gnus-eval-in-buffer-window gnus-article-buffer
7946 (setq endp (gnus-article-prev-page lines)))
7947 (when (and move endp)
7948 (cond (lines
7949 (gnus-message 3 "Beginning of message"))
7950 ((null lines)
7951 (if (and (eq gnus-summary-goto-unread 'never)
7952 (not (gnus-summary-first-article-p article)))
7953 (gnus-summary-prev-article)
7954 (gnus-summary-prev-unread-article))))))))
7955 (gnus-summary-position-point))
7956
7957 (defun gnus-summary-prev-page-or-article (&optional lines)
7958 "Show previous page of selected article.
7959 Argument LINES specifies lines to be scrolled down.
7960 If at the beginning of the article, go to the next article."
7961 (interactive "P")
7962 (gnus-summary-prev-page lines t))
7963
7964 (defun gnus-summary-scroll-up (lines)
7965 "Scroll up (or down) one line current article.
7966 Argument LINES specifies lines to be scrolled up (or down if negative).
7967 If no article is selected, then the current article will be selected first."
7968 (interactive "p")
7969 (gnus-configure-windows 'article)
7970 (gnus-summary-show-thread)
7971 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7972 (gnus-eval-in-buffer-window gnus-article-buffer
7973 (cond ((> lines 0)
7974 (when (gnus-article-next-page lines)
7975 (gnus-message 3 "End of message")))
7976 ((< lines 0)
7977 (gnus-article-prev-page (- lines))))))
7978 (gnus-summary-recenter)
7979 (gnus-summary-position-point))
7980
7981 (defun gnus-summary-scroll-down (lines)
7982 "Scroll down (or up) one line current article.
7983 Argument LINES specifies lines to be scrolled down (or up if negative).
7984 If no article is selected, then the current article will be selected first."
7985 (interactive "p")
7986 (gnus-summary-scroll-up (- lines)))
7987
7988 (defun gnus-summary-next-same-subject ()
7989 "Select next article which has the same subject as current one."
7990 (interactive)
7991 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7992
7993 (defun gnus-summary-prev-same-subject ()
7994 "Select previous article which has the same subject as current one."
7995 (interactive)
7996 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7997
7998 (defun gnus-summary-next-unread-same-subject ()
7999 "Select next unread article which has the same subject as current one."
8000 (interactive)
8001 (gnus-summary-next-article t (gnus-summary-article-subject)))
8002
8003 (defun gnus-summary-prev-unread-same-subject ()
8004 "Select previous unread article which has the same subject as current one."
8005 (interactive)
8006 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8007
8008 (defun gnus-summary-first-unread-article ()
8009 "Select the first unread article.
8010 Return nil if there are no unread articles."
8011 (interactive)
8012 (prog1
8013 (when (gnus-summary-first-subject t)
8014 (gnus-summary-show-thread)
8015 (gnus-summary-first-subject t)
8016 (gnus-summary-display-article (gnus-summary-article-number)))
8017 (gnus-summary-position-point)))
8018
8019 (defun gnus-summary-first-unread-subject ()
8020 "Place the point on the subject line of the first unread article.
8021 Return nil if there are no unread articles."
8022 (interactive)
8023 (prog1
8024 (when (gnus-summary-first-subject t)
8025 (gnus-summary-show-thread)
8026 (gnus-summary-first-subject t))
8027 (gnus-summary-position-point)))
8028
8029 (defun gnus-summary-first-unseen-subject ()
8030 "Place the point on the subject line of the first unseen article.
8031 Return nil if there are no unseen articles."
8032 (interactive)
8033 (prog1
8034 (when (gnus-summary-first-subject nil nil t)
8035 (gnus-summary-show-thread)
8036 (gnus-summary-first-subject nil nil t))
8037 (gnus-summary-position-point)))
8038
8039 (defun gnus-summary-first-unseen-or-unread-subject ()
8040 "Place the point on the subject line of the first unseen and unread article.
8041 If all article have been seen, on the subject line of the first unread
8042 article."
8043 (interactive)
8044 (prog1
8045 (unless (when (gnus-summary-first-subject nil nil t)
8046 (gnus-summary-show-thread)
8047 (gnus-summary-first-subject nil nil t))
8048 (when (gnus-summary-first-subject t)
8049 (gnus-summary-show-thread)
8050 (gnus-summary-first-subject t)))
8051 (gnus-summary-position-point)))
8052
8053 (defun gnus-summary-first-article ()
8054 "Select the first article.
8055 Return nil if there are no articles."
8056 (interactive)
8057 (prog1
8058 (when (gnus-summary-first-subject)
8059 (gnus-summary-show-thread)
8060 (gnus-summary-first-subject)
8061 (gnus-summary-display-article (gnus-summary-article-number)))
8062 (gnus-summary-position-point)))
8063
8064 (defun gnus-summary-best-unread-article (&optional arg)
8065 "Select the unread article with the highest score.
8066 If given a prefix argument, select the next unread article that has a
8067 score higher than the default score."
8068 (interactive "P")
8069 (let ((article (if arg
8070 (gnus-summary-better-unread-subject)
8071 (gnus-summary-best-unread-subject))))
8072 (if article
8073 (gnus-summary-goto-article article)
8074 (error "No unread articles"))))
8075
8076 (defun gnus-summary-best-unread-subject ()
8077 "Select the unread subject with the highest score."
8078 (interactive)
8079 (let ((best -1000000)
8080 (data gnus-newsgroup-data)
8081 article score)
8082 (while data
8083 (and (gnus-data-unread-p (car data))
8084 (> (setq score
8085 (gnus-summary-article-score (gnus-data-number (car data))))
8086 best)
8087 (setq best score
8088 article (gnus-data-number (car data))))
8089 (setq data (cdr data)))
8090 (when article
8091 (gnus-summary-goto-subject article))
8092 (gnus-summary-position-point)
8093 article))
8094
8095 (defun gnus-summary-better-unread-subject ()
8096 "Select the first unread subject that has a score over the default score."
8097 (interactive)
8098 (let ((data gnus-newsgroup-data)
8099 article score)
8100 (while (and (setq article (gnus-data-number (car data)))
8101 (or (gnus-data-read-p (car data))
8102 (not (> (gnus-summary-article-score article)
8103 gnus-summary-default-score))))
8104 (setq data (cdr data)))
8105 (when article
8106 (gnus-summary-goto-subject article))
8107 (gnus-summary-position-point)
8108 article))
8109
8110 (defun gnus-summary-last-subject ()
8111 "Go to the last displayed subject line in the group."
8112 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8113 (when article
8114 (gnus-summary-goto-subject article))))
8115
8116 (defun gnus-summary-goto-article (article &optional all-headers force)
8117 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8118 If ALL-HEADERS is non-nil, no header lines are hidden.
8119 If FORCE, go to the article even if it isn't displayed. If FORCE
8120 is a number, it is the line the article is to be displayed on."
8121 (interactive
8122 (list
8123 (gnus-completing-read
8124 "Article number or Message-ID"
8125 (mapcar 'int-to-string gnus-newsgroup-limit))
8126 current-prefix-arg
8127 t))
8128 (prog1
8129 (if (and (stringp article)
8130 (string-match "@\\|%40" article))
8131 (gnus-summary-refer-article article)
8132 (when (stringp article)
8133 (setq article (string-to-number article)))
8134 (if (gnus-summary-goto-subject article force)
8135 (gnus-summary-display-article article all-headers)
8136 (gnus-message 4 "Couldn't go to article %s" article) nil))
8137 (gnus-summary-position-point)))
8138
8139 (defun gnus-summary-goto-last-article ()
8140 "Go to the previously read article."
8141 (interactive)
8142 (prog1
8143 (when gnus-last-article
8144 (gnus-summary-goto-article gnus-last-article nil t))
8145 (gnus-summary-position-point)))
8146
8147 (defun gnus-summary-pop-article (number)
8148 "Pop one article off the history and go to the previous.
8149 NUMBER articles will be popped off."
8150 (interactive "p")
8151 (let (to)
8152 (setq gnus-newsgroup-history
8153 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8154 (if to
8155 (gnus-summary-goto-article (car to) nil t)
8156 (error "Article history empty")))
8157 (gnus-summary-position-point))
8158
8159 ;; Summary commands and functions for limiting the summary buffer.
8160
8161 (defun gnus-summary-limit-to-articles (n)
8162 "Limit the summary buffer to the next N articles.
8163 If not given a prefix, use the process marked articles instead."
8164 (interactive "P")
8165 (prog1
8166 (let ((articles (gnus-summary-work-articles n)))
8167 (setq gnus-newsgroup-processable nil)
8168 (gnus-summary-limit articles))
8169 (gnus-summary-position-point)))
8170
8171 (defun gnus-summary-pop-limit (&optional total)
8172 "Restore the previous limit.
8173 If given a prefix, remove all limits."
8174 (interactive "P")
8175 (when total
8176 (setq gnus-newsgroup-limits
8177 (list (mapcar (lambda (h) (mail-header-number h))
8178 gnus-newsgroup-headers))))
8179 (unless gnus-newsgroup-limits
8180 (error "No limit to pop"))
8181 (prog1
8182 (gnus-summary-limit nil 'pop)
8183 (gnus-summary-position-point)))
8184
8185 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8186 "Limit the summary buffer to articles that have subjects that match a regexp.
8187 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8188 (interactive
8189 (list (read-string (if current-prefix-arg
8190 "Exclude subject (regexp): "
8191 "Limit to subject (regexp): "))
8192 nil current-prefix-arg))
8193 (unless header
8194 (setq header "subject"))
8195 (when (not (equal "" subject))
8196 (prog1
8197 (let ((articles (gnus-summary-find-matching
8198 (or header "subject") subject 'all nil nil
8199 not-matching)))
8200 (unless articles
8201 (error "Found no matches for \"%s\"" subject))
8202 (gnus-summary-limit articles))
8203 (gnus-summary-position-point))))
8204
8205 (defun gnus-summary-limit-to-author (from &optional not-matching)
8206 "Limit the summary buffer to articles that have authors that match a regexp.
8207 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8208 (interactive
8209 (list (let* ((header (gnus-summary-article-header))
8210 (default (and header (car (mail-header-parse-address
8211 (mail-header-from header))))))
8212 (read-string (concat (if current-prefix-arg
8213 "Exclude author (regexp"
8214 "Limit to author (regexp")
8215 (if default
8216 (concat ", default \"" default "\"): ")
8217 "): "))
8218 nil nil
8219 default))
8220 current-prefix-arg))
8221 (gnus-summary-limit-to-subject from "from" not-matching))
8222
8223 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8224 "Limit the summary buffer to articles with the given RECIPIENT.
8225
8226 If NOT-MATCHING, exclude RECIPIENT.
8227
8228 To and Cc headers are checked. You need to include them in
8229 `nnmail-extra-headers'."
8230 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8231 (interactive
8232 (list (read-string (format "%s recipient (regexp): "
8233 (if current-prefix-arg "Exclude" "Limit to")))
8234 current-prefix-arg))
8235 (when (not (equal "" recipient))
8236 (prog1 (let* ((to
8237 (if (memq 'To nnmail-extra-headers)
8238 (gnus-summary-find-matching
8239 (cons 'extra 'To) recipient 'all nil nil
8240 not-matching)
8241 (gnus-message
8242 1 "`To' isn't present in `nnmail-extra-headers'")
8243 (sit-for 1)
8244 nil))
8245 (cc
8246 (if (memq 'Cc nnmail-extra-headers)
8247 (gnus-summary-find-matching
8248 (cons 'extra 'Cc) recipient 'all nil nil
8249 not-matching)
8250 (gnus-message
8251 1 "`Cc' isn't present in `nnmail-extra-headers'")
8252 (sit-for 1)
8253 nil))
8254 (articles
8255 (if not-matching
8256 ;; We need the numbers that are in both lists:
8257 (mapcar (lambda (a)
8258 (and (memq a to) a))
8259 cc)
8260 (nconc to cc))))
8261 (unless articles
8262 (error "Found no matches for \"%s\"" recipient))
8263 (gnus-summary-limit articles))
8264 (gnus-summary-position-point))))
8265
8266 (defun gnus-summary-limit-to-address (address &optional not-matching)
8267 "Limit the summary buffer to articles with the given ADDRESS.
8268
8269 If NOT-MATCHING, exclude ADDRESS.
8270
8271 To, Cc and From headers are checked. You need to include `To' and `Cc'
8272 in `nnmail-extra-headers'."
8273 (interactive
8274 (list (read-string (format "%s address (regexp): "
8275 (if current-prefix-arg "Exclude" "Limit to")))
8276 current-prefix-arg))
8277 (when (not (equal "" address))
8278 (prog1 (let* ((to
8279 (if (memq 'To nnmail-extra-headers)
8280 (gnus-summary-find-matching
8281 (cons 'extra 'To) address 'all nil nil
8282 not-matching)
8283 (gnus-message
8284 1 "`To' isn't present in `nnmail-extra-headers'")
8285 (sit-for 1)
8286 t))
8287 (cc
8288 (if (memq 'Cc nnmail-extra-headers)
8289 (gnus-summary-find-matching
8290 (cons 'extra 'Cc) address 'all nil nil
8291 not-matching)
8292 (gnus-message
8293 1 "`Cc' isn't present in `nnmail-extra-headers'")
8294 (sit-for 1)
8295 t))
8296 (from
8297 (gnus-summary-find-matching "from" address
8298 'all nil nil not-matching))
8299 (articles
8300 (if not-matching
8301 ;; We need the numbers that are in all lists:
8302 (if (eq cc t)
8303 (if (eq to t)
8304 from
8305 (mapcar (lambda (a) (car (memq a from))) to))
8306 (if (eq to t)
8307 (mapcar (lambda (a) (car (memq a from))) cc)
8308 (mapcar (lambda (a) (car (memq a from)))
8309 (mapcar (lambda (a) (car (memq a to)))
8310 cc))))
8311 (nconc (if (eq to t) nil to)
8312 (if (eq cc t) nil cc)
8313 from))))
8314 (unless articles
8315 (error "Found no matches for \"%s\"" address))
8316 (gnus-summary-limit articles))
8317 (gnus-summary-position-point))))
8318
8319 (defun gnus-summary-limit-strange-charsets-predicate (header)
8320 (let ((string (concat (mail-header-subject header)
8321 (mail-header-from header)))
8322 charset found)
8323 (dotimes (i (1- (length string)))
8324 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8325 (when (string-match "unicode\\|big\\|japanese" charset)
8326 (setq found t)))
8327 found))
8328
8329 (defun gnus-summary-limit-to-predicate (predicate)
8330 "Limit to articles where PREDICATE returns non-nil.
8331 PREDICATE will be called with the header structures of the
8332 articles."
8333 (let ((articles nil)
8334 (case-fold-search t))
8335 (dolist (header gnus-newsgroup-headers)
8336 (when (funcall predicate header)
8337 (push (mail-header-number header) articles)))
8338 (gnus-summary-limit (nreverse articles))))
8339
8340 (defun gnus-summary-limit-to-age (age &optional younger-p)
8341 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8342 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8343 articles that are younger than AGE days."
8344 (interactive
8345 (let ((younger current-prefix-arg)
8346 (days-got nil)
8347 days)
8348 (while (not days-got)
8349 (setq days (if younger
8350 (read-string "Limit to articles younger than (in days, older when negative): ")
8351 (read-string
8352 "Limit to articles older than (in days, younger when negative): ")))
8353 (when (> (length days) 0)
8354 (setq days (read days)))
8355 (if (numberp days)
8356 (progn
8357 (setq days-got t)
8358 (when (< days 0)
8359 (setq younger (not younger))
8360 (setq days (* days -1))))
8361 (message "Please enter a number.")
8362 (sleep-for 1)))
8363 (list days younger)))
8364 (prog1
8365 (let ((data gnus-newsgroup-data)
8366 (cutoff (days-to-time age))
8367 articles d date is-younger)
8368 (while (setq d (pop data))
8369 (when (and (vectorp (gnus-data-header d))
8370 (setq date (mail-header-date (gnus-data-header d))))
8371 (setq is-younger (time-less-p
8372 (time-since (gnus-date-get-time date))
8373 cutoff))
8374 (when (if younger-p
8375 is-younger
8376 (not is-younger))
8377 (push (gnus-data-number d) articles))))
8378 (gnus-summary-limit (nreverse articles)))
8379 (gnus-summary-position-point)))
8380
8381 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8382 "Limit the summary buffer to articles that match an `extra' header."
8383 (interactive
8384 (let ((header
8385 (intern
8386 (gnus-completing-read
8387 (if current-prefix-arg
8388 "Exclude extra header"
8389 "Limit extra header")
8390 (mapcar 'symbol-name gnus-extra-headers)
8391 t nil nil
8392 (symbol-name (car gnus-extra-headers))))))
8393 (list header
8394 (read-string (format "%s header %s (regexp): "
8395 (if current-prefix-arg "Exclude" "Limit to")
8396 header))
8397 current-prefix-arg)))
8398 (when (not (equal "" regexp))
8399 (prog1
8400 (let ((articles (gnus-summary-find-matching
8401 (cons 'extra header) regexp 'all nil nil
8402 not-matching)))
8403 (unless articles
8404 (error "Found no matches for \"%s\"" regexp))
8405 (gnus-summary-limit articles))
8406 (gnus-summary-position-point))))
8407
8408 (defun gnus-summary-limit-to-display-predicate ()
8409 "Limit the summary buffer to the predicated in the `display' group parameter."
8410 (interactive)
8411 (unless gnus-newsgroup-display
8412 (error "There is no `display' group parameter"))
8413 (let (articles)
8414 (dolist (gnus-number gnus-newsgroup-articles)
8415 (when (funcall gnus-newsgroup-display)
8416 (push gnus-number articles)))
8417 (gnus-summary-limit articles))
8418 (gnus-summary-position-point))
8419
8420 (defun gnus-summary-limit-to-unread (&optional all)
8421 "Limit the summary buffer to articles that are not marked as read.
8422 If ALL is non-nil, limit strictly to unread articles."
8423 (interactive "P")
8424 (if all
8425 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8426 (gnus-summary-limit-to-marks
8427 ;; Concat all the marks that say that an article is read and have
8428 ;; those removed.
8429 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8430 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8431 gnus-low-score-mark gnus-expirable-mark
8432 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8433 gnus-duplicate-mark)
8434 'reverse)))
8435
8436 (defun gnus-summary-limit-to-headers (match &optional reverse)
8437 "Limit the summary buffer to articles that have headers that match MATCH.
8438 If REVERSE (the prefix), limit to articles that don't match."
8439 (interactive "sMatch headers (regexp): \nP")
8440 (gnus-summary-limit-to-bodies match reverse t))
8441
8442 (declare-function article-goto-body "gnus-art" ())
8443
8444 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8445 "Limit the summary buffer to articles that have bodies that match MATCH.
8446 If REVERSE (the prefix), limit to articles that don't match."
8447 (interactive "sMatch body (regexp): \nP")
8448 (let ((articles nil)
8449 (gnus-select-article-hook nil) ;Disable hook.
8450 (gnus-article-prepare-hook nil)
8451 (gnus-use-article-prefetch nil)
8452 (gnus-keep-backlog nil)
8453 (gnus-break-pages nil)
8454 (gnus-summary-display-arrow nil)
8455 (gnus-updated-mode-lines nil)
8456 (gnus-auto-center-summary nil)
8457 (gnus-display-mime-function nil))
8458 (dolist (data gnus-newsgroup-data)
8459 (let (gnus-mark-article-hook)
8460 (gnus-summary-select-article t t nil (gnus-data-number data)))
8461 (with-current-buffer gnus-article-buffer
8462 (article-goto-body)
8463 (let* ((case-fold-search t)
8464 (found (if headersp
8465 (re-search-backward match nil t)
8466 (re-search-forward match nil t))))
8467 (when (or (and found
8468 (not reverse))
8469 (and (not found)
8470 reverse))
8471 (push (gnus-data-number data) articles)))))
8472 (if (not articles)
8473 (message "No messages matched")
8474 (gnus-summary-limit articles)))
8475 (gnus-summary-position-point))
8476
8477 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8478 "Limit the summary buffer to articles that aren't part on any thread.
8479 If THREADSP (the prefix), limit to articles that are in threads."
8480 (interactive "P")
8481 (let ((articles nil)
8482 thread-articles
8483 threads)
8484 (dolist (thread gnus-newsgroup-threads)
8485 (if (stringp (car thread))
8486 (dolist (thread (cdr thread))
8487 (push thread threads))
8488 (push thread threads)))
8489 (dolist (thread threads)
8490 (setq thread-articles (gnus-articles-in-thread thread))
8491 (when (or (and threadsp
8492 (> (length thread-articles) 1))
8493 (and (not threadsp)
8494 (= (length thread-articles) 1)))
8495 (setq articles (nconc thread-articles articles))))
8496 (if (not articles)
8497 (message "No messages matched")
8498 (gnus-summary-limit articles))
8499 (gnus-summary-position-point)))
8500
8501 (defun gnus-summary-limit-to-replied (&optional unreplied)
8502 "Limit the summary buffer to replied articles.
8503 If UNREPLIED (the prefix), limit to unreplied articles."
8504 (interactive "P")
8505 (if unreplied
8506 (gnus-summary-limit
8507 (gnus-set-difference gnus-newsgroup-articles
8508 gnus-newsgroup-replied))
8509 (gnus-summary-limit gnus-newsgroup-replied))
8510 (gnus-summary-position-point))
8511
8512 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8513 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8514 If REVERSE, limit the summary buffer to articles that are marked
8515 with MARKS. MARKS can either be a string of marks or a list of marks.
8516 Returns how many articles were removed."
8517 (interactive "sMarks: ")
8518 (gnus-summary-limit-to-marks marks t))
8519
8520 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8521 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8522 If REVERSE (the prefix), limit the summary buffer to articles that are
8523 not marked with MARKS. MARKS can either be a string of marks or a
8524 list of marks.
8525 Returns how many articles were removed."
8526 (interactive "sMarks: \nP")
8527 (prog1
8528 (let ((data gnus-newsgroup-data)
8529 (marks (if (listp marks) marks
8530 (append marks nil))) ; Transform to list.
8531 articles)
8532 (while data
8533 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8534 (memq (gnus-data-mark (car data)) marks))
8535 (push (gnus-data-number (car data)) articles))
8536 (setq data (cdr data)))
8537 (gnus-summary-limit articles))
8538 (gnus-summary-position-point)))
8539
8540 (defun gnus-summary-limit-to-score (score)
8541 "Limit to articles with score at or above SCORE."
8542 (interactive "NLimit to articles with score of at least: ")
8543 (let ((data gnus-newsgroup-data)
8544 articles)
8545 (while data
8546 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8547 score)
8548 (push (gnus-data-number (car data)) articles))
8549 (setq data (cdr data)))
8550 (prog1
8551 (gnus-summary-limit articles)
8552 (gnus-summary-position-point))))
8553
8554 (defun gnus-summary-limit-to-unseen ()
8555 "Limit to unseen articles."
8556 (interactive)
8557 (prog1
8558 (gnus-summary-limit gnus-newsgroup-unseen)
8559 (gnus-summary-position-point)))
8560
8561 (defun gnus-summary-limit-include-thread (id)
8562 "Display all the hidden articles that is in the thread with ID in it.
8563 When called interactively, ID is the Message-ID of the current
8564 article."
8565 (interactive (list (mail-header-id (gnus-summary-article-header))))
8566 (let ((articles (gnus-articles-in-thread
8567 (gnus-id-to-thread (gnus-root-id id))))
8568 ;;we REALLY want the whole thread---this prevents cut-threads
8569 ;;from removing the thread we want to include.
8570 (gnus-fetch-old-headers nil)
8571 (gnus-build-sparse-threads nil))
8572 (prog1
8573 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8574 (gnus-summary-limit-include-matching-articles
8575 "subject"
8576 (regexp-quote (gnus-simplify-subject-re
8577 (mail-header-subject (gnus-id-to-header id)))))
8578 (gnus-summary-position-point))))
8579
8580 (defun gnus-summary-limit-include-matching-articles (header regexp)
8581 "Display all the hidden articles that have HEADERs that match REGEXP."
8582 (interactive (list (read-string "Match on header: ")
8583 (read-string "Regexp: ")))
8584 (let ((articles (gnus-find-matching-articles header regexp)))
8585 (prog1
8586 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8587 (gnus-summary-position-point))))
8588
8589 (defun gnus-summary-insert-dormant-articles ()
8590 "Insert all the dormant articles for this group into the current buffer."
8591 (interactive)
8592 (let ((gnus-verbose (max 6 gnus-verbose)))
8593 (if (not gnus-newsgroup-dormant)
8594 (gnus-message 3 "No dormant articles for this group")
8595 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8596
8597 (defun gnus-summary-insert-ticked-articles ()
8598 "Insert ticked articles for this group into the current buffer."
8599 (interactive)
8600 (let ((gnus-verbose (max 6 gnus-verbose)))
8601 (if (not gnus-newsgroup-marked)
8602 (gnus-message 3 "No ticked articles for this group")
8603 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8604
8605 (defun gnus-summary-limit-include-dormant ()
8606 "Display all the hidden articles that are marked as dormant.
8607 Note that this command only works on a subset of the articles currently
8608 fetched for this group."
8609 (interactive)
8610 (unless gnus-newsgroup-dormant
8611 (error "There are no dormant articles in this group"))
8612 (prog1
8613 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8614 (gnus-summary-position-point)))
8615
8616 (defun gnus-summary-include-articles (articles)
8617 "Fetch the headers for ARTICLES and then display the summary lines."
8618 (let ((gnus-inhibit-demon t)
8619 (gnus-agent nil)
8620 (gnus-read-all-available-headers t))
8621 (setq gnus-newsgroup-headers
8622 (cl-merge
8623 'list gnus-newsgroup-headers
8624 (gnus-fetch-headers articles nil t)
8625 'gnus-article-sort-by-number))
8626 (setq gnus-newsgroup-articles
8627 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8628 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8629
8630 (defun gnus-summary-limit-exclude-dormant ()
8631 "Hide all dormant articles."
8632 (interactive)
8633 (prog1
8634 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8635 (gnus-summary-position-point)))
8636
8637 (defun gnus-summary-limit-exclude-childless-dormant ()
8638 "Hide all dormant articles that have no children."
8639 (interactive)
8640 (let ((data (gnus-data-list t))
8641 articles d children)
8642 ;; Find all articles that are either not dormant or have
8643 ;; children.
8644 (while (setq d (pop data))
8645 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8646 (and (setq children
8647 (gnus-article-children (gnus-data-number d)))
8648 (let (found)
8649 (while children
8650 (when (memq (car children) articles)
8651 (setq children nil
8652 found t))
8653 (pop children))
8654 found)))
8655 (push (gnus-data-number d) articles)))
8656 ;; Do the limiting.
8657 (prog1
8658 (gnus-summary-limit articles)
8659 (gnus-summary-position-point))))
8660
8661 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8662 "Mark all unread excluded articles as read.
8663 If ALL, mark even excluded ticked and dormants as read."
8664 (interactive "P")
8665 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8666 (let ((articles (gnus-sorted-ndifference
8667 (sort
8668 (mapcar (lambda (h) (mail-header-number h))
8669 gnus-newsgroup-headers)
8670 '<)
8671 gnus-newsgroup-limit))
8672 article)
8673 (setq gnus-newsgroup-unreads
8674 (gnus-sorted-intersection gnus-newsgroup-unreads
8675 gnus-newsgroup-limit))
8676 (if all
8677 (setq gnus-newsgroup-dormant nil
8678 gnus-newsgroup-marked nil
8679 gnus-newsgroup-reads
8680 (nconc
8681 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8682 gnus-newsgroup-reads))
8683 (while (setq article (pop articles))
8684 (unless (or (memq article gnus-newsgroup-dormant)
8685 (memq article gnus-newsgroup-marked))
8686 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8687
8688 (defun gnus-summary-limit (articles &optional pop)
8689 (if pop
8690 ;; We pop the previous limit off the stack and use that.
8691 (setq articles (car gnus-newsgroup-limits)
8692 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8693 ;; We use the new limit, so we push the old limit on the stack.
8694 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8695 ;; Set the limit.
8696 (setq gnus-newsgroup-limit articles)
8697 (let ((total (length gnus-newsgroup-data))
8698 (data (gnus-data-find-list (gnus-summary-article-number)))
8699 (gnus-summary-mark-below nil) ; Inhibit this.
8700 found)
8701 ;; This will do all the work of generating the new summary buffer
8702 ;; according to the new limit.
8703 (gnus-summary-prepare)
8704 ;; Hide any threads, possibly.
8705 (gnus-summary-maybe-hide-threads)
8706 ;; Try to return to the article you were at, or one in the
8707 ;; neighborhood.
8708 (when data
8709 ;; We try to find some article after the current one.
8710 (while data
8711 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8712 (setq data nil
8713 found t))
8714 (setq data (cdr data))))
8715 (unless found
8716 ;; If there is no data, that means that we were after the last
8717 ;; article. The same goes when we can't find any articles
8718 ;; after the current one.
8719 (goto-char (point-max))
8720 (gnus-summary-find-prev))
8721 (gnus-set-mode-line 'summary)
8722 ;; We return how many articles were removed from the summary
8723 ;; buffer as a result of the new limit.
8724 (- total (length gnus-newsgroup-data))))
8725
8726 (defsubst gnus-invisible-cut-children (threads)
8727 (let ((num 0))
8728 (while threads
8729 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8730 (incf num))
8731 (pop threads))
8732 (< num 2)))
8733
8734 (defsubst gnus-cut-thread (thread)
8735 "Go forwards in the thread until we find an article that we want to display."
8736 (when (or (eq gnus-fetch-old-headers 'some)
8737 (eq gnus-fetch-old-headers 'invisible)
8738 (numberp gnus-fetch-old-headers)
8739 (eq gnus-build-sparse-threads 'some)
8740 (eq gnus-build-sparse-threads 'more))
8741 ;; Deal with old-fetched headers and sparse threads.
8742 (while (and
8743 thread
8744 (or
8745 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8746 (gnus-summary-article-ancient-p
8747 (mail-header-number (car thread))))
8748 (if (or (<= (length (cdr thread)) 1)
8749 (eq gnus-fetch-old-headers 'invisible))
8750 (setq gnus-newsgroup-limit
8751 (delq (mail-header-number (car thread))
8752 gnus-newsgroup-limit)
8753 thread (cadr thread))
8754 (when (gnus-invisible-cut-children (cdr thread))
8755 (let ((th (cdr thread)))
8756 (while th
8757 (if (memq (mail-header-number (caar th))
8758 gnus-newsgroup-limit)
8759 (setq thread (car th)
8760 th nil)
8761 (setq th (cdr th))))))))))
8762 thread)
8763
8764 (defun gnus-cut-threads (threads)
8765 "Cut off all uninteresting articles from the beginning of THREADS."
8766 (when (or (eq gnus-fetch-old-headers 'some)
8767 (eq gnus-fetch-old-headers 'invisible)
8768 (numberp gnus-fetch-old-headers)
8769 (eq gnus-build-sparse-threads 'some)
8770 (eq gnus-build-sparse-threads 'more))
8771 (let ((th threads))
8772 (while th
8773 (setcar th (gnus-cut-thread (car th)))
8774 (setq th (cdr th)))))
8775 ;; Remove nixed out threads.
8776 (delq nil threads))
8777
8778 (defun gnus-summary-initial-limit (&optional show-if-empty)
8779 "Figure out what the initial limit is supposed to be on group entry.
8780 This entails weeding out unwanted dormants, low-scored articles,
8781 fetch-old-headers verbiage, and so on."
8782 ;; Most groups have nothing to remove.
8783 (unless (or gnus-inhibit-limiting
8784 (and (null gnus-newsgroup-dormant)
8785 (eq gnus-newsgroup-display 'gnus-not-ignore)
8786 (not (eq gnus-fetch-old-headers 'some))
8787 (not (numberp gnus-fetch-old-headers))
8788 (not (eq gnus-fetch-old-headers 'invisible))
8789 (null gnus-summary-expunge-below)
8790 (not (eq gnus-build-sparse-threads 'some))
8791 (not (eq gnus-build-sparse-threads 'more))
8792 (null gnus-thread-expunge-below)))
8793 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8794 (setq gnus-newsgroup-limit nil)
8795 (mapatoms
8796 (lambda (node)
8797 (unless (car (symbol-value node))
8798 ;; These threads have no parents -- they are roots.
8799 (let ((nodes (cdr (symbol-value node)))
8800 thread)
8801 (while nodes
8802 (if (and gnus-thread-expunge-below
8803 (< (gnus-thread-total-score (car nodes))
8804 gnus-thread-expunge-below))
8805 (gnus-expunge-thread (pop nodes))
8806 (setq thread (pop nodes))
8807 (gnus-summary-limit-children thread))))))
8808 gnus-newsgroup-dependencies)
8809 ;; If this limitation resulted in an empty group, we might
8810 ;; pop the previous limit and use it instead.
8811 (when (and (not gnus-newsgroup-limit)
8812 show-if-empty)
8813 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8814 gnus-newsgroup-limit))
8815
8816 (defun gnus-summary-limit-children (thread)
8817 "Return 1 if this subthread is visible and 0 if it is not."
8818 ;; First we get the number of visible children to this thread. This
8819 ;; is done by recursing down the thread using this function, so this
8820 ;; will really go down to a leaf article first, before slowly
8821 ;; working its way up towards the root.
8822 (when thread
8823 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8824 (children
8825 (if (cdr thread)
8826 (apply '+ (mapcar 'gnus-summary-limit-children
8827 (cdr thread)))
8828 0))
8829 (number (mail-header-number (car thread)))
8830 score)
8831 (if (and
8832 (not (memq number gnus-newsgroup-marked))
8833 (or
8834 ;; If this article is dormant and has absolutely no visible
8835 ;; children, then this article isn't visible.
8836 (and (memq number gnus-newsgroup-dormant)
8837 (zerop children))
8838 ;; If this is "fetch-old-headered" and there is no
8839 ;; visible children, then we don't want this article.
8840 (and (or (eq gnus-fetch-old-headers 'some)
8841 (numberp gnus-fetch-old-headers))
8842 (gnus-summary-article-ancient-p number)
8843 (zerop children))
8844 ;; If this is "fetch-old-headered" and `invisible', then
8845 ;; we don't want this article.
8846 (and (eq gnus-fetch-old-headers 'invisible)
8847 (gnus-summary-article-ancient-p number))
8848 ;; If this is a sparsely inserted article with no children,
8849 ;; we don't want it.
8850 (and (eq gnus-build-sparse-threads 'some)
8851 (gnus-summary-article-sparse-p number)
8852 (zerop children))
8853 ;; If we use expunging, and this article is really
8854 ;; low-scored, then we don't want this article.
8855 (when (and gnus-summary-expunge-below
8856 (< (setq score
8857 (or (cdr (assq number gnus-newsgroup-scored))
8858 gnus-summary-default-score))
8859 gnus-summary-expunge-below))
8860 ;; We increase the expunge-tally here, but that has
8861 ;; nothing to do with the limits, really.
8862 (incf gnus-newsgroup-expunged-tally)
8863 ;; We also mark as read here, if that's wanted.
8864 (when (and gnus-summary-mark-below
8865 (< score gnus-summary-mark-below))
8866 (setq gnus-newsgroup-unreads
8867 (delq number gnus-newsgroup-unreads))
8868 (if gnus-newsgroup-auto-expire
8869 (push number gnus-newsgroup-expirable)
8870 (push (cons number gnus-low-score-mark)
8871 gnus-newsgroup-reads)))
8872 t)
8873 ;; Do the `display' group parameter.
8874 (and gnus-newsgroup-display
8875 (let ((gnus-number number))
8876 (not (funcall gnus-newsgroup-display))))))
8877 ;; Nope, invisible article.
8878 0
8879 ;; Ok, this article is to be visible, so we add it to the limit
8880 ;; and return 1.
8881 (push number gnus-newsgroup-limit)
8882 1))))
8883
8884 (defun gnus-expunge-thread (thread)
8885 "Mark all articles in THREAD as read."
8886 (let* ((number (mail-header-number (car thread))))
8887 (incf gnus-newsgroup-expunged-tally)
8888 ;; We also mark as read here, if that's wanted.
8889 (setq gnus-newsgroup-unreads
8890 (delq number gnus-newsgroup-unreads))
8891 (if gnus-newsgroup-auto-expire
8892 (push number gnus-newsgroup-expirable)
8893 (push (cons number gnus-low-score-mark)
8894 gnus-newsgroup-reads)))
8895 ;; Go recursively through all subthreads.
8896 (mapcar 'gnus-expunge-thread (cdr thread)))
8897
8898 ;; Summary article oriented commands
8899
8900 (defun gnus-summary-refer-parent-article (n)
8901 "Refer parent article N times.
8902 If N is negative, go to ancestor -N instead.
8903 The difference between N and the number of articles fetched is returned."
8904 (interactive "p")
8905 (let ((skip 1)
8906 error header ref)
8907 (when (not (natnump n))
8908 (setq skip (abs n)
8909 n 1))
8910 (while (and (> n 0)
8911 (not error))
8912 (setq header (gnus-summary-article-header))
8913 (if (and (eq (mail-header-number header)
8914 (cdr gnus-article-current))
8915 (equal gnus-newsgroup-name
8916 (car gnus-article-current)))
8917 ;; If we try to find the parent of the currently
8918 ;; displayed article, then we take a look at the actual
8919 ;; References header, since this is slightly more
8920 ;; reliable than the References field we got from the
8921 ;; server.
8922 (with-current-buffer gnus-original-article-buffer
8923 (nnheader-narrow-to-headers)
8924 (unless (setq ref (message-fetch-field "references"))
8925 (when (setq ref (message-fetch-field "in-reply-to"))
8926 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8927 (widen))
8928 (setq ref
8929 ;; It's not the current article, so we take a bet on
8930 ;; the value we got from the server.
8931 (mail-header-references header)))
8932 (if (and ref
8933 (not (equal ref "")))
8934 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8935 (gnus-message 1 "Couldn't find parent"))
8936 (gnus-message 1 "No references in article %d"
8937 (gnus-summary-article-number))
8938 (setq error t))
8939 (decf n))
8940 (gnus-summary-position-point)
8941 n))
8942
8943 (defun gnus-summary-refer-references ()
8944 "Fetch all articles mentioned in the References header.
8945 Return the number of articles fetched."
8946 (interactive)
8947 (let ((ref (mail-header-references (gnus-summary-article-header)))
8948 (current (gnus-summary-article-number))
8949 (n 0))
8950 (if (or (not ref)
8951 (equal ref ""))
8952 (error "No References in the current article")
8953 ;; For each Message-ID in the References header...
8954 (while (string-match "<[^>]*>" ref)
8955 (incf n)
8956 ;; ... fetch that article.
8957 (gnus-summary-refer-article
8958 (prog1 (match-string 0 ref)
8959 (setq ref (substring ref (match-end 0))))))
8960 (gnus-summary-goto-subject current)
8961 (gnus-summary-position-point)
8962 n)))
8963
8964 (defun gnus-delete-duplicate-headers (headers)
8965 ;; First remove leading duplicates.
8966 (while (and (> (length headers) 1)
8967 (= (mail-header-number (car headers))
8968 (mail-header-number (cadr headers))))
8969 (pop headers))
8970 ;; Then the rest.
8971 (let ((result headers))
8972 (while (> (length headers) 1)
8973 (if (= (mail-header-number (car headers))
8974 (mail-header-number (cadr headers)))
8975 (setcdr headers (cddr headers))
8976 (pop headers)))
8977 result))
8978
8979 (defun gnus-summary-refer-thread (&optional limit)
8980 "Fetch all articles in the current thread. For backends that
8981 know how to search for threads (currently only 'nnimap) a
8982 non-numeric prefix arg will use nnir to search the entire
8983 server; without a prefix arg only the current group is
8984 searched. If the variable `gnus-refer-thread-use-nnir' is
8985 non-nil the prefix arg has the reverse meaning. If no
8986 backend-specific 'request-thread function is available fetch
8987 LIMIT (the numerical prefix) old headers. If LIMIT is
8988 non-numeric or nil fetch the number specified by the
8989 `gnus-refer-thread-limit' variable."
8990 (interactive "P")
8991 (gnus-warp-to-article)
8992 (let* ((header (gnus-summary-article-header))
8993 (id (mail-header-id header))
8994 (gnus-inhibit-demon t)
8995 (gnus-summary-ignore-duplicates t)
8996 (gnus-read-all-available-headers t)
8997 (gnus-refer-thread-use-nnir
8998 (if (and (not (null limit)) (listp limit))
8999 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
9000 (new-headers
9001 (if (gnus-check-backend-function
9002 'request-thread gnus-newsgroup-name)
9003 (gnus-request-thread header gnus-newsgroup-name)
9004 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9005 gnus-refer-thread-limit))
9006 (last (if (numberp limit)
9007 (min (+ (mail-header-number header)
9008 limit)
9009 gnus-newsgroup-highest)
9010 gnus-newsgroup-highest))
9011 (subject (gnus-simplify-subject
9012 (mail-header-subject header)))
9013 (refs (split-string (or (mail-header-references header)
9014 "")))
9015 (gnus-parse-headers-hook
9016 `(lambda () (goto-char (point-min))
9017 (keep-lines
9018 (regexp-opt ',(append refs (list id subject)))))))
9019 (gnus-fetch-headers (list last) (if (numberp limit)
9020 (* 2 limit) limit) t))))
9021 article-ids new-unreads)
9022 (when (listp new-headers)
9023 (dolist (header new-headers)
9024 (push (mail-header-number header) article-ids))
9025 (setq article-ids (nreverse article-ids))
9026 (setq new-unreads
9027 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9028 (setq gnus-newsgroup-unselected
9029 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9030 (setq gnus-newsgroup-unreads
9031 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9032 (setq gnus-newsgroup-headers
9033 (gnus-delete-duplicate-headers
9034 (cl-merge
9035 'list gnus-newsgroup-headers new-headers
9036 'gnus-article-sort-by-number)))
9037 (setq gnus-newsgroup-articles
9038 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9039 (gnus-summary-limit-include-thread id)))
9040 (gnus-summary-show-thread))
9041
9042 (defun gnus-summary-open-group-with-article (message-id)
9043 "Open a group containing the article with the given MESSAGE-ID."
9044 (interactive "sMessage-ID: ")
9045 (require 'nndoc)
9046 (with-temp-buffer
9047 ;; Prepare a dummy article
9048 (erase-buffer)
9049 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9050
9051 ;; Prepare pretty modelines for summary and article buffers
9052 (let ((gnus-summary-mode-line-format "Found %G")
9053 (gnus-article-mode-line-format
9054 ;; Group names just get in the way here, especially the
9055 ;; abbreviated ones
9056 (if (string-match "%[gG]" gnus-article-mode-line-format)
9057 (concat (substring gnus-article-mode-line-format
9058 0 (match-beginning 0))
9059 (substring gnus-article-mode-line-format (match-end 0)))
9060 gnus-article-mode-line-format)))
9061
9062 ;; Build an ephemeral group containing the dummy article (hidden)
9063 (gnus-group-read-ephemeral-group
9064 message-id
9065 `(nndoc ,message-id
9066 (nndoc-address ,(current-buffer))
9067 (nndoc-article-type mbox))
9068 :activate
9069 (cons (current-buffer) gnus-current-window-configuration)
9070 (not :request-only)
9071 '(-1) ; :select-articles
9072 (not :parameters)
9073 0)) ; :number
9074 ;; Fetch the desired article
9075 (gnus-summary-refer-article message-id)))
9076
9077 (defun gnus-summary-refer-article (message-id)
9078 "Fetch an article specified by MESSAGE-ID."
9079 (interactive "sMessage-ID: ")
9080 (gnus-warp-to-article)
9081 (when (and (stringp message-id)
9082 (not (zerop (length message-id))))
9083 (setq message-id (replace-regexp-in-string " " "" message-id))
9084 ;; Construct the correct Message-ID if necessary.
9085 ;; Suggested by tale@pawl.rpi.edu.
9086 (unless (string-match "^<" message-id)
9087 (setq message-id (concat "<" message-id)))
9088 (unless (string-match ">$" message-id)
9089 (setq message-id (concat message-id ">")))
9090 ;; People often post MIDs from URLs, so unhex it:
9091 (unless (string-match "@" message-id)
9092 (setq message-id (gnus-url-unhex-string message-id)))
9093 (let* ((header (gnus-id-to-header message-id))
9094 (sparse (and header
9095 (gnus-summary-article-sparse-p
9096 (mail-header-number header))
9097 (memq (mail-header-number header)
9098 gnus-newsgroup-limit)))
9099 number)
9100 (cond
9101 ;; If the article is present in the buffer we just go to it.
9102 ((and header
9103 (or (not (gnus-summary-article-sparse-p
9104 (mail-header-number header)))
9105 sparse))
9106 (prog1
9107 (gnus-summary-goto-article
9108 (mail-header-number header) nil t)
9109 (when sparse
9110 (gnus-summary-update-article (mail-header-number header)))))
9111 (t
9112 ;; We fetch the article.
9113 (catch 'found
9114 (dolist (gnus-override-method (gnus-refer-article-methods))
9115 (when (and (gnus-check-server gnus-override-method)
9116 ;; Fetch the header,
9117 (setq number (gnus-summary-insert-subject message-id)))
9118 ;; and display the article.
9119 (gnus-summary-select-article nil nil nil number)
9120 (throw 'found t)))
9121 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9122
9123 (defun gnus-refer-article-methods ()
9124 "Return a list of referable methods."
9125 (cond
9126 ;; No method, so we default to current and native.
9127 ((null gnus-refer-article-method)
9128 (list gnus-current-select-method gnus-select-method))
9129 ;; Current.
9130 ((eq 'current gnus-refer-article-method)
9131 (list gnus-current-select-method))
9132 ;; List of select methods.
9133 ((not (and (symbolp (car gnus-refer-article-method))
9134 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9135 (let (out)
9136 (dolist (method gnus-refer-article-method)
9137 (push (if (eq 'current method)
9138 gnus-current-select-method
9139 (if (eq 'nnir (car method))
9140 (list
9141 'nnir
9142 (or (cadr method)
9143 (gnus-method-to-server gnus-current-select-method)))
9144 method))
9145 out))
9146 (nreverse out)))
9147 ;; One single select method.
9148 (t
9149 (list gnus-refer-article-method))))
9150
9151 (defun gnus-summary-edit-parameters ()
9152 "Edit the group parameters of the current group."
9153 (interactive)
9154 (gnus-group-edit-group gnus-newsgroup-name 'params))
9155
9156 (defun gnus-summary-customize-parameters ()
9157 "Customize the group parameters of the current group."
9158 (interactive)
9159 (gnus-group-customize gnus-newsgroup-name))
9160
9161 (defun gnus-summary-enter-digest-group (&optional force)
9162 "Enter an nndoc group based on the current article.
9163 If FORCE, force a digest interpretation. If not, try to guess
9164 what the document format is.
9165
9166 To control what happens when you exit the group, see the
9167 `gnus-auto-select-on-ephemeral-exit' variable."
9168 (interactive "P")
9169 (let ((conf gnus-current-window-configuration))
9170 (save-window-excursion
9171 (save-excursion
9172 (let (gnus-article-prepare-hook
9173 gnus-display-mime-function
9174 gnus-break-pages)
9175 (gnus-summary-select-article))))
9176 (setq gnus-current-window-configuration conf)
9177 (let* ((name (format "%s-%d"
9178 (gnus-group-prefixed-name
9179 gnus-newsgroup-name (list 'nndoc ""))
9180 (with-current-buffer gnus-summary-buffer
9181 gnus-current-article)))
9182 (ogroup gnus-newsgroup-name)
9183 (params (append (gnus-info-params (gnus-get-info ogroup))
9184 (list (cons 'to-group ogroup))
9185 (list (cons 'parent-group ogroup))
9186 (list (cons 'save-article-group ogroup))))
9187 (case-fold-search t)
9188 (buf (current-buffer))
9189 dig to-address charset)
9190 (with-current-buffer gnus-original-article-buffer
9191 ;; Have the digest group inherit the main mail address of
9192 ;; the parent article.
9193 (when (setq to-address (or (gnus-fetch-field "reply-to")
9194 (gnus-fetch-field "from")))
9195 (setq params
9196 (append
9197 params
9198 (list (cons 'to-address
9199 (funcall gnus-decode-encoded-address-function
9200 to-address))))))
9201 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9202 (insert-buffer-substring gnus-original-article-buffer)
9203 (narrow-to-region
9204 (goto-char (point-min))
9205 (or (search-forward "\n\n" nil t) (point)))
9206 ;; Remove lines that may lead nndoc to misinterpret the
9207 ;; document type.
9208 (goto-char (point-min))
9209 (delete-matching-lines "^Path:\\|^From ")
9210 ;; Parse charset, and decode content transfer encoding.
9211 (setq charset (mail-content-type-get
9212 (mail-header-parse-content-type
9213 (or (gnus-fetch-field "content-type") ""))
9214 'charset))
9215 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9216 (when encoding
9217 (message-remove-header "content-transfer-encoding")
9218 (goto-char (point-max))
9219 (widen)
9220 (narrow-to-region (point) (point-max))
9221 (mm-decode-content-transfer-encoding
9222 (intern (downcase (mail-header-strip encoding))))))
9223 (widen))
9224 (unwind-protect
9225 (if (let ((gnus-newsgroup-ephemeral-charset
9226 (if charset
9227 (intern (downcase (gnus-strip-whitespace charset)))
9228 gnus-newsgroup-charset))
9229 (gnus-newsgroup-ephemeral-ignored-charsets
9230 gnus-newsgroup-ignored-charsets))
9231 (gnus-group-read-ephemeral-group
9232 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9233 (nndoc-article-type
9234 ,(if force 'mbox 'guess)))
9235 t nil nil nil
9236 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9237 "ADAPT")))))
9238 ;; Make all postings to this group go to the parent group.
9239 (nconc (gnus-info-params (gnus-get-info name))
9240 params)
9241 ;; Couldn't select this doc group.
9242 (switch-to-buffer buf)
9243 (gnus-set-global-variables)
9244 (gnus-configure-windows 'summary)
9245 (gnus-message 3 "Article couldn't be entered?"))
9246 (kill-buffer dig)))))
9247
9248 (defun gnus-summary-read-document (n)
9249 "Open a new group based on the current article(s).
9250 This will allow you to read digests and other similar
9251 documents as newsgroups.
9252 Obeys the standard process/prefix convention."
9253 (interactive "P")
9254 (let* ((ogroup gnus-newsgroup-name)
9255 (params (append (gnus-info-params (gnus-get-info ogroup))
9256 (list (cons 'to-group ogroup))))
9257 group egroup groups vgroup)
9258 (dolist (article (gnus-summary-work-articles n))
9259 (setq group (format "%s-%d" gnus-newsgroup-name article))
9260 (gnus-summary-remove-process-mark article)
9261 (when (gnus-summary-display-article article)
9262 (save-excursion ;;What for?
9263 (with-temp-buffer
9264 (insert-buffer-substring gnus-original-article-buffer)
9265 ;; Remove some headers that may lead nndoc to make
9266 ;; the wrong guess.
9267 (message-narrow-to-head)
9268 (goto-char (point-min))
9269 (delete-matching-lines "^Path:\\|^From ")
9270 (widen)
9271 (if (setq egroup
9272 (gnus-group-read-ephemeral-group
9273 group `(nndoc ,group (nndoc-address ,(current-buffer))
9274 (nndoc-article-type guess))
9275 t nil t))
9276 (progn
9277 ;; Make all postings to this group go to the parent group.
9278 (nconc (gnus-info-params (gnus-get-info egroup))
9279 params)
9280 (push egroup groups))
9281 ;; Couldn't select this doc group.
9282 (gnus-error 3 "Article couldn't be entered"))))))
9283 ;; Now we have selected all the documents.
9284 (cond
9285 ((not groups)
9286 (error "None of the articles could be interpreted as documents"))
9287 ((gnus-group-read-ephemeral-group
9288 (setq vgroup (format
9289 "nnvirtual:%s-%s" gnus-newsgroup-name
9290 (format-time-string "%Y%m%dT%H%M%S")))
9291 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9292 t
9293 (cons (current-buffer) 'summary)))
9294 (t
9295 (error "Couldn't select virtual nndoc group")))))
9296
9297 (defun gnus-summary-widget-forward (arg)
9298 "Move point to the next field or button in the article.
9299 With optional ARG, move across that many fields."
9300 (interactive "p")
9301 (gnus-summary-select-article)
9302 (gnus-configure-windows 'article)
9303 (select-window (gnus-get-buffer-window gnus-article-buffer))
9304 (widget-forward arg))
9305
9306 (defun gnus-summary-widget-backward (arg)
9307 "Move point to the previous field or button in the article.
9308 With optional ARG, move across that many fields."
9309 (interactive "p")
9310 (gnus-summary-select-article)
9311 (gnus-configure-windows 'article)
9312 (select-window (gnus-get-buffer-window gnus-article-buffer))
9313 (unless (widget-at (point))
9314 (goto-char (point-max)))
9315 (widget-backward arg))
9316
9317 (defun gnus-summary-isearch-article (&optional regexp-p)
9318 "Do incremental search forward on the current article.
9319 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9320 (interactive "P")
9321 (gnus-summary-select-article)
9322 (gnus-configure-windows 'article)
9323 (gnus-eval-in-buffer-window gnus-article-buffer
9324 (save-restriction
9325 (widen)
9326 (isearch-forward regexp-p))))
9327
9328 (defun gnus-summary-repeat-search-article-forward ()
9329 "Repeat the previous search forwards."
9330 (interactive)
9331 (unless gnus-last-search-regexp
9332 (error "No previous search"))
9333 (gnus-summary-search-article-forward gnus-last-search-regexp))
9334
9335 (defun gnus-summary-repeat-search-article-backward ()
9336 "Repeat the previous search backwards."
9337 (interactive)
9338 (unless gnus-last-search-regexp
9339 (error "No previous search"))
9340 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9341
9342 (defun gnus-summary-search-article-forward (regexp &optional backward)
9343 "Search for an article containing REGEXP forward.
9344 If BACKWARD, search backward instead."
9345 (interactive
9346 (list (read-string
9347 (format "Search article %s (regexp%s): "
9348 (if current-prefix-arg "backward" "forward")
9349 (if gnus-last-search-regexp
9350 (concat ", default " gnus-last-search-regexp)
9351 "")))
9352 current-prefix-arg))
9353 (if (string-equal regexp "")
9354 (setq regexp (or gnus-last-search-regexp ""))
9355 (setq gnus-last-search-regexp regexp)
9356 (setq gnus-article-before-search gnus-current-article))
9357 ;; Intentionally set gnus-last-article.
9358 (setq gnus-last-article gnus-article-before-search)
9359 (let ((gnus-last-article gnus-last-article))
9360 (if (gnus-summary-search-article regexp backward)
9361 (gnus-summary-show-thread)
9362 (signal 'search-failed (list regexp)))))
9363
9364 (defun gnus-summary-search-article-backward (regexp)
9365 "Search for an article containing REGEXP backward."
9366 (interactive
9367 (list (read-string
9368 (format "Search article backward (regexp%s): "
9369 (if gnus-last-search-regexp
9370 (concat ", default " gnus-last-search-regexp)
9371 "")))))
9372 (gnus-summary-search-article-forward regexp 'backward))
9373
9374 (defun gnus-summary-search-article (regexp &optional backward)
9375 "Search for an article containing REGEXP.
9376 Optional argument BACKWARD means do search for backward.
9377 `gnus-select-article-hook' is not called during the search."
9378 ;; We have to require this here to make sure that the following
9379 ;; dynamic binding isn't shadowed by autoloading.
9380 (require 'gnus-async)
9381 (require 'gnus-art)
9382 (let ((gnus-select-article-hook nil) ;Disable hook.
9383 (gnus-article-prepare-hook nil)
9384 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9385 (gnus-use-article-prefetch nil)
9386 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9387 (gnus-visual nil)
9388 (gnus-keep-backlog nil)
9389 (gnus-break-pages nil)
9390 (gnus-summary-display-arrow nil)
9391 (gnus-updated-mode-lines nil)
9392 (gnus-auto-center-summary nil)
9393 (sum (current-buffer))
9394 (gnus-display-mime-function nil)
9395 (found nil)
9396 point)
9397 (gnus-save-hidden-threads
9398 (gnus-summary-select-article)
9399 (set-buffer gnus-article-buffer)
9400 (goto-char (window-point (get-buffer-window (current-buffer))))
9401 (when backward
9402 (forward-line -1))
9403 (while (not found)
9404 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9405 (if (if backward
9406 (re-search-backward regexp nil t)
9407 (re-search-forward regexp nil t))
9408 ;; We found the regexp.
9409 (progn
9410 (setq found 'found)
9411 (beginning-of-line)
9412 (set-window-start
9413 (get-buffer-window (current-buffer))
9414 (point))
9415 (forward-line 1)
9416 (set-window-point
9417 (get-buffer-window (current-buffer))
9418 (point))
9419 (set-buffer sum)
9420 (setq point (point)))
9421 ;; We didn't find it, so we go to the next article.
9422 (set-buffer sum)
9423 (setq found 'not)
9424 (while (eq found 'not)
9425 (if (not (if backward (gnus-summary-find-prev)
9426 (gnus-summary-find-next)))
9427 ;; No more articles.
9428 (setq found t)
9429 ;; Select the next article and adjust point.
9430 (unless (gnus-summary-article-sparse-p
9431 (gnus-summary-article-number))
9432 (setq found nil)
9433 (gnus-summary-select-article)
9434 (set-buffer gnus-article-buffer)
9435 (widen)
9436 (goto-char (if backward (point-max) (point-min))))))))
9437 (gnus-message 7 ""))
9438 ;; Return whether we found the regexp.
9439 (when (eq found 'found)
9440 (goto-char point)
9441 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9442 (gnus-summary-show-thread)
9443 (gnus-summary-goto-subject gnus-current-article)
9444 (gnus-summary-position-point)
9445 t)))
9446
9447 (defun gnus-find-matching-articles (header regexp)
9448 "Return a list of all articles that match REGEXP on HEADER.
9449 This search includes all articles in the current group that Gnus has
9450 fetched headers for, whether they are displayed or not."
9451 (let ((articles nil)
9452 ;; Can't eta-reduce because it's a macro.
9453 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9454 (case-fold-search t))
9455 (dolist (header gnus-newsgroup-headers)
9456 (when (string-match regexp (funcall func header))
9457 (push (mail-header-number header) articles)))
9458 (nreverse articles)))
9459
9460 (defun gnus-summary-find-matching (header regexp &optional backward unread
9461 not-case-fold not-matching)
9462 "Return a list of all articles that match REGEXP on HEADER.
9463 The search stars on the current article and goes forwards unless
9464 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9465 If UNREAD is non-nil, only unread articles will
9466 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9467 in the comparisons. If NOT-MATCHING, return a list of all articles that
9468 not match REGEXP on HEADER."
9469 (let ((case-fold-search (not not-case-fold))
9470 articles d func)
9471 (if (consp header)
9472 (if (eq (car header) 'extra)
9473 (setq func
9474 `(lambda (h)
9475 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9476 "")))
9477 (error "%s is an invalid header" header))
9478 (unless (fboundp (intern (concat "mail-header-" header)))
9479 (error "%s is not a valid header" header))
9480 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9481 (dolist (d (if (eq backward 'all)
9482 gnus-newsgroup-data
9483 (gnus-data-find-list
9484 (gnus-summary-article-number)
9485 (gnus-data-list backward))))
9486 (when (and (or (not unread) ; We want all articles...
9487 (gnus-data-unread-p d)) ; Or just unreads.
9488 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9489 (if not-matching
9490 (not (string-match
9491 regexp
9492 (funcall func (gnus-data-header d))))
9493 (string-match regexp
9494 (funcall func (gnus-data-header d)))))
9495 (push (gnus-data-number d) articles))) ; Success!
9496 (nreverse articles)))
9497
9498 (defun gnus-summary-execute-command (header regexp command &optional backward)
9499 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9500 If HEADER is an empty string (or nil), the match is done on the entire
9501 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9502 (interactive
9503 (list (let ((completion-ignore-case t))
9504 (gnus-completing-read
9505 "Header name"
9506 (mapcar 'symbol-name
9507 (append
9508 '(Number Subject From Lines Date
9509 Message-ID Xref References Body)
9510 gnus-extra-headers))
9511 'require-match))
9512 (read-string "Regexp: ")
9513 (read-key-sequence "Command: ")
9514 current-prefix-arg))
9515 (when (equal header "Body")
9516 (setq header ""))
9517 ;; Hidden thread subtrees must be searched as well.
9518 (gnus-summary-show-all-threads)
9519 ;; We don't want to change current point nor window configuration.
9520 (save-excursion
9521 (save-window-excursion
9522 (let (gnus-visual
9523 gnus-treat-strip-trailing-blank-lines
9524 gnus-treat-strip-leading-blank-lines
9525 gnus-treat-strip-multiple-blank-lines
9526 gnus-treat-hide-boring-headers
9527 gnus-treat-fold-newsgroups
9528 gnus-article-prepare-hook)
9529 (gnus-message 6 "Executing %s..." (key-description command))
9530 ;; We'd like to execute COMMAND interactively so as to give arguments.
9531 (gnus-execute header regexp
9532 `(call-interactively ',(key-binding command))
9533 backward)
9534 (gnus-message 6 "Executing %s...done" (key-description command))))))
9535
9536 (defun gnus-summary-beginning-of-article ()
9537 "Scroll the article back to the beginning."
9538 (interactive)
9539 (gnus-summary-select-article)
9540 (gnus-configure-windows 'article)
9541 (gnus-eval-in-buffer-window gnus-article-buffer
9542 (widen)
9543 (goto-char (point-min))
9544 (when gnus-break-pages
9545 (gnus-narrow-to-page))))
9546
9547 (defun gnus-summary-end-of-article ()
9548 "Scroll to the end of the article."
9549 (interactive)
9550 (gnus-summary-select-article)
9551 (gnus-configure-windows 'article)
9552 (gnus-eval-in-buffer-window gnus-article-buffer
9553 (widen)
9554 (goto-char (point-max))
9555 (recenter -3)
9556 (when gnus-break-pages
9557 (gnus-narrow-to-page))))
9558
9559 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9560 "Truncate to LEN and quote all \"(\"'s in STRING."
9561 (replace-regexp-in-string "[()]" "\\\\\\&"
9562 (if (and len (> (length string) len))
9563 (substring string 0 len)
9564 string)))
9565
9566 (defun gnus-summary-print-article (&optional filename n)
9567 "Generate and print a PostScript image of the process-marked (mail) articles.
9568
9569 If used interactively, print the current article if none are
9570 process-marked. With prefix arg, prompt the user for the name of the
9571 file to save in.
9572
9573 When used from Lisp, accept two optional args FILENAME and N. N means
9574 to print the next N articles. If N is negative, print the N previous
9575 articles. If N is nil and articles have been marked with the process
9576 mark, print these instead.
9577
9578 If the optional first argument FILENAME is nil, send the image to the
9579 printer. If FILENAME is a string, save the PostScript image in a file with
9580 that name. If FILENAME is a number, prompt the user for the name of the file
9581 to save in."
9582 (interactive (list (ps-print-preprint current-prefix-arg)))
9583 (dolist (article (gnus-summary-work-articles n))
9584 (gnus-summary-select-article nil nil 'pseudo article)
9585 (gnus-eval-in-buffer-window gnus-article-buffer
9586 (gnus-print-buffer))
9587 (gnus-summary-remove-process-mark article))
9588 (ps-despool filename))
9589
9590 (defun gnus-print-buffer ()
9591 (let ((ps-left-header
9592 (list
9593 (concat "("
9594 (gnus-summary-print-truncate-and-quote
9595 (mail-header-subject gnus-current-headers)
9596 66) ")")
9597 (concat "("
9598 (gnus-summary-print-truncate-and-quote
9599 (mail-header-from gnus-current-headers)
9600 45) ")")))
9601 (ps-right-header
9602 (list
9603 "/pagenumberstring load"
9604 (concat "("
9605 (mail-header-date gnus-current-headers) ")"))))
9606 (gnus-run-hooks 'gnus-ps-print-hook)
9607 (save-excursion
9608 (if ps-print-color-p
9609 (ps-spool-buffer-with-faces)
9610 (ps-spool-buffer)))))
9611
9612 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9613
9614 (defun gnus-summary-show-complete-article ()
9615 "Show a complete version of the current article.
9616 This is only useful if you're looking at a partial version of the
9617 article currently."
9618 (interactive)
9619 (let ((gnus-keep-backlog nil)
9620 (gnus-use-cache nil)
9621 (gnus-agent nil)
9622 (variable (intern
9623 (format "%s-fetch-partial-articles"
9624 (car (gnus-find-method-for-group
9625 gnus-newsgroup-name)))
9626 obarray))
9627 old-val)
9628 (unwind-protect
9629 (progn
9630 (setq old-val (symbol-value variable))
9631 (set variable nil)
9632 (gnus-flush-original-article-buffer)
9633 (gnus-summary-show-article))
9634 (set variable old-val))))
9635
9636 (defun gnus-summary-show-article (&optional arg)
9637 "Force redisplaying of the current article.
9638 If ARG (the prefix) is a number, show the article with the charset
9639 defined in `gnus-summary-show-article-charset-alist', or the charset
9640 input.
9641 If ARG (the prefix) is non-nil and not a number, show the article,
9642 but without running any of the article treatment functions
9643 article. Normally, the keystroke is `C-u g'. When using `C-u
9644 C-u g', show the raw article."
9645 (interactive "P")
9646 (cond
9647 ((numberp arg)
9648 (gnus-summary-show-article t)
9649 (let ((gnus-newsgroup-charset
9650 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9651 (read-coding-system
9652 "View as charset: " ;; actually it is coding system.
9653 (with-current-buffer gnus-article-buffer
9654 (mm-detect-coding-region (point) (point-max))))))
9655 (gnus-newsgroup-ignored-charsets 'gnus-all))
9656 (gnus-summary-select-article nil 'force)
9657 (let ((deps gnus-newsgroup-dependencies)
9658 head header lines)
9659 (with-current-buffer gnus-original-article-buffer
9660 (save-restriction
9661 (message-narrow-to-head)
9662 (setq head (buffer-string))
9663 (goto-char (point-min))
9664 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9665 (goto-char (point-max))
9666 (widen)
9667 (setq lines (1- (count-lines (point) (point-max))))))
9668 (with-temp-buffer
9669 (insert (format "211 %d Article retrieved.\n"
9670 (cdr gnus-article-current)))
9671 (insert head)
9672 (if lines (insert (format "Lines: %d\n" lines)))
9673 (insert ".\n")
9674 (let ((nntp-server-buffer (current-buffer)))
9675 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9676 (gnus-data-set-header
9677 (gnus-data-find (cdr gnus-article-current))
9678 header)
9679 (gnus-summary-update-article-line
9680 (cdr gnus-article-current) header)
9681 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9682 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9683 ((not arg)
9684 ;; Select the article the normal way.
9685 (if (eq mm-text-html-renderer 'shr)
9686 (progn
9687 (require 'shr)
9688 (let ((shr-ignore-cache t))
9689 (gnus-summary-select-article nil 'force)))
9690 (gnus-summary-select-article nil 'force)))
9691 ((equal arg '(16))
9692 ;; C-u C-u g
9693 (let ((gnus-inhibit-article-treatments t))
9694 (gnus-summary-select-article nil 'force)))
9695 (t
9696 ;; We have to require this here to make sure that the following
9697 ;; dynamic binding isn't shadowed by autoloading.
9698 (require 'gnus-async)
9699 (require 'gnus-art)
9700 ;; Bind the article treatment functions to nil.
9701 (let ((gnus-have-all-headers t)
9702 gnus-article-prepare-hook
9703 gnus-article-decode-hook
9704 gnus-display-mime-function
9705 gnus-break-pages)
9706 ;; Destroy any MIME parts.
9707 (when (gnus-buffer-live-p gnus-article-buffer)
9708 (with-current-buffer gnus-article-buffer
9709 (gnus-article-stop-animations)
9710 (gnus-stop-downloads)
9711 (mm-destroy-parts gnus-article-mime-handles)
9712 ;; Set it to nil for safety reason.
9713 (setq gnus-article-mime-handle-alist nil)
9714 (setq gnus-article-mime-handles nil)))
9715 (gnus-summary-select-article nil 'force))))
9716 (gnus-summary-goto-subject gnus-current-article)
9717 (gnus-summary-position-point))
9718
9719 (defun gnus-summary-show-raw-article ()
9720 "Show the raw article without any article massaging functions being run."
9721 (interactive)
9722 (gnus-summary-show-article t))
9723
9724 (defun gnus-summary-verbose-headers (&optional arg)
9725 "Toggle permanent full header display.
9726 If ARG is a positive number, turn header display on.
9727 If ARG is a negative number, turn header display off."
9728 (interactive "P")
9729 (setq gnus-show-all-headers
9730 (cond ((or (not (numberp arg))
9731 (zerop arg))
9732 (not gnus-show-all-headers))
9733 ((natnump arg)
9734 t)))
9735 (gnus-summary-show-article))
9736
9737 (declare-function article-narrow-to-head "gnus-art" ())
9738 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9739 (declare-function gnus-delete-wash-type "gnus-art" (type))
9740 (declare-function gnus-mime-buttonize-attachments-in-header
9741 "gnus-art" (&optional interactive))
9742
9743 (defun gnus-summary-toggle-header (&optional arg)
9744 "Show the headers if they are hidden, or hide them if they are shown.
9745 If ARG is a positive number, show the entire header.
9746 If ARG is a negative number, hide the unwanted header lines."
9747 (interactive "P")
9748 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9749 (get-buffer-window gnus-article-buffer t))))
9750 (with-current-buffer gnus-article-buffer
9751 (widen)
9752 (article-narrow-to-head)
9753 (let* ((inhibit-read-only t)
9754 (inhibit-point-motion-hooks t)
9755 (hidden (if (numberp arg)
9756 (>= arg 0)
9757 (or (not (looking-at "[^ \t\n]+:"))
9758 (gnus-article-hidden-text-p 'headers))))
9759 s e)
9760 (delete-region (point-min) (point-max))
9761 (with-current-buffer gnus-original-article-buffer
9762 (goto-char (setq s (point-min)))
9763 (setq e (if (search-forward "\n\n" nil t)
9764 (1- (point))
9765 (point-max))))
9766 (insert-buffer-substring gnus-original-article-buffer s e)
9767 (run-hooks 'gnus-article-decode-hook)
9768 (if hidden
9769 (let ((gnus-treat-hide-headers nil)
9770 (gnus-treat-hide-boring-headers nil))
9771 (gnus-delete-wash-type 'headers)
9772 (gnus-treat-article 'head))
9773 (gnus-treat-article 'head)
9774 ;; Add attachment buttons to the header.
9775 (when gnus-mime-display-attachment-buttons-in-header
9776 (gnus-mime-buttonize-attachments-in-header)))
9777 (widen)
9778 (if window
9779 (set-window-start window (goto-char (point-min))))
9780 (if gnus-break-pages
9781 (gnus-narrow-to-page)
9782 (when (gnus-visual-p 'page-marker)
9783 (let ((inhibit-read-only t))
9784 (gnus-remove-text-with-property 'gnus-prev)
9785 (gnus-remove-text-with-property 'gnus-next))))
9786 (gnus-set-mode-line 'article)))))
9787
9788 (defun gnus-summary-show-all-headers ()
9789 "Make all header lines visible."
9790 (interactive)
9791 (gnus-summary-toggle-header 1))
9792
9793 (defun gnus-summary-caesar-message (&optional arg)
9794 "Caesar rotate the current article by 13.
9795 With a non-numerical prefix, also rotate headers. A numerical
9796 prefix specifies how many places to rotate each letter forward."
9797 (interactive "P")
9798 (gnus-summary-select-article)
9799 (let ((mail-header-separator ""))
9800 (gnus-eval-in-buffer-window gnus-article-buffer
9801 (save-restriction
9802 (widen)
9803 (let ((start (window-start))
9804 (inhibit-read-only t))
9805 (if (equal arg '(4))
9806 (message-caesar-buffer-body nil t)
9807 (message-caesar-buffer-body arg))
9808 (set-window-start (get-buffer-window (current-buffer)) start)))))
9809 ;; Create buttons and stuff...
9810 (gnus-treat-article nil))
9811
9812 (declare-function idna-to-unicode "ext:idna" (str))
9813
9814 (defun gnus-summary-idna-message (&optional arg)
9815 "Decode IDNA encoded domain names in the current articles.
9816 IDNA encoded domain names looks like `xn--bar'. If a string
9817 remain unencoded after running this function, it is likely an
9818 invalid IDNA string (`xn--bar' is invalid).
9819
9820 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9821 installed for this command to work."
9822 (interactive "P")
9823 (if (not (and (mm-coding-system-p 'utf-8)
9824 (condition-case nil
9825 (require 'idna)
9826 (file-error)
9827 (invalid-operation))
9828 (symbol-value 'idna-program)
9829 (executable-find (symbol-value 'idna-program))))
9830 (gnus-message
9831 5 "GNU Libidn not installed properly (`idn' or `idna.el' missing)")
9832 (gnus-summary-select-article)
9833 (let ((mail-header-separator ""))
9834 (gnus-eval-in-buffer-window gnus-article-buffer
9835 (save-restriction
9836 (widen)
9837 (let ((start (window-start))
9838 buffer-read-only)
9839 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9840 (replace-match (idna-to-unicode (match-string 1))))
9841 (set-window-start (get-buffer-window (current-buffer)) start)))))))
9842
9843 (defun gnus-summary-morse-message (&optional arg)
9844 "Morse decode the current article."
9845 (interactive "P")
9846 (gnus-summary-select-article)
9847 (let ((mail-header-separator ""))
9848 (gnus-eval-in-buffer-window gnus-article-buffer
9849 (save-excursion
9850 (save-restriction
9851 (widen)
9852 (let ((pos (window-start))
9853 (inhibit-read-only t))
9854 (goto-char (point-min))
9855 (when (message-goto-body)
9856 (gnus-narrow-to-body))
9857 (goto-char (point-min))
9858 (while (search-forward "·" (point-max) t)
9859 (replace-match "."))
9860 (unmorse-region (point-min) (point-max))
9861 (widen)
9862 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9863
9864 (defun gnus-summary-stop-page-breaking ()
9865 "Stop page breaking in the current article."
9866 (interactive)
9867 (gnus-summary-select-article)
9868 (gnus-eval-in-buffer-window gnus-article-buffer
9869 (widen)
9870 (when (gnus-visual-p 'page-marker)
9871 (let ((inhibit-read-only t))
9872 (gnus-remove-text-with-property 'gnus-prev)
9873 (gnus-remove-text-with-property 'gnus-next))
9874 (setq gnus-page-broken nil))))
9875
9876 (defun gnus-summary-move-article (&optional n to-newsgroup
9877 select-method action)
9878 "Move the current article to a different newsgroup.
9879 If N is a positive number, move the N next articles.
9880 If N is a negative number, move the N previous articles.
9881 If N is nil and any articles have been marked with the process mark,
9882 move those articles instead.
9883 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9884 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9885 re-spool using this method.
9886
9887 When called interactively with TO-NEWSGROUP being nil, the value of
9888 the variable `gnus-move-split-methods' is used for finding a default
9889 for the target newsgroup.
9890
9891 For this function to work, both the current newsgroup and the
9892 newsgroup that you want to move to have to support the `request-move'
9893 and `request-accept' functions.
9894
9895 ACTION can be either `move' (the default), `crosspost' or `copy'."
9896 (interactive "P")
9897 (unless action
9898 (setq action 'move))
9899 ;; Check whether the source group supports the required functions.
9900 (cond ((and (eq action 'move)
9901 (not (gnus-check-backend-function
9902 'request-move-article gnus-newsgroup-name)))
9903 (error "The current group does not support article moving"))
9904 ((and (eq action 'crosspost)
9905 (not (gnus-check-backend-function
9906 'request-replace-article gnus-newsgroup-name)))
9907 (error "The current group does not support article editing")))
9908 (let ((articles (gnus-summary-work-articles n))
9909 (prefix (if (gnus-check-backend-function
9910 'request-move-article gnus-newsgroup-name)
9911 (funcall gnus-move-group-prefix-function
9912 gnus-newsgroup-name)
9913 ""))
9914 (names '((move "Move" "Moving")
9915 (copy "Copy" "Copying")
9916 (crosspost "Crosspost" "Crossposting")))
9917 (copy-buf (save-excursion
9918 (nnheader-set-temp-buffer " *copy article*")))
9919 art-group to-method new-xref article to-groups
9920 articles-to-update-marks encoded)
9921 (unless (assq action names)
9922 (error "Unknown action %s" action))
9923 ;; Read the newsgroup name.
9924 (when (and (not to-newsgroup)
9925 (not select-method))
9926 (if (and gnus-move-split-methods
9927 (not
9928 (and (memq gnus-current-article articles)
9929 (gnus-buffer-live-p gnus-original-article-buffer))))
9930 ;; When `gnus-move-split-methods' is non-nil, we have to
9931 ;; select an article to give `gnus-read-move-group-name' an
9932 ;; opportunity to suggest an appropriate default. However,
9933 ;; we needn't render or mark the article.
9934 (let ((gnus-display-mime-function nil)
9935 (gnus-article-prepare-hook nil)
9936 (gnus-mark-article-hook nil))
9937 (gnus-summary-select-article nil nil nil (car articles))))
9938 (setq to-newsgroup (gnus-read-move-group-name
9939 (cadr (assq action names))
9940 (symbol-value
9941 (intern (format "gnus-current-%s-group" action)))
9942 articles prefix)
9943 encoded to-newsgroup
9944 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9945 (set (intern (format "gnus-current-%s-group" action))
9946 (decode-coding-string
9947 to-newsgroup
9948 (gnus-group-name-charset to-method to-newsgroup))))
9949 (unless to-method
9950 (setq to-method (or select-method
9951 (gnus-server-to-method
9952 (gnus-group-method to-newsgroup)))))
9953 (setq to-newsgroup
9954 (or encoded
9955 (and to-newsgroup
9956 (encode-coding-string
9957 to-newsgroup
9958 (gnus-group-name-charset to-method to-newsgroup)))))
9959 ;; Check the method we are to move this article to...
9960 (unless (gnus-check-backend-function
9961 'request-accept-article (car to-method))
9962 (error "%s does not support article copying" (car to-method)))
9963 (unless (gnus-check-server to-method)
9964 (error "Can't open server %s" (car to-method)))
9965 (gnus-message 6 "%s to %s: %s..."
9966 (caddr (assq action names))
9967 (or (car select-method)
9968 (gnus-group-decoded-name to-newsgroup))
9969 articles)
9970 (while articles
9971 (setq article (pop articles))
9972 ;; Set any marks that may have changed in the summary buffer.
9973 (when gnus-preserve-marks
9974 (gnus-summary-push-marks-to-backend article))
9975 (setq
9976 art-group
9977 (cond
9978 ;; Move the article.
9979 ((eq action 'move)
9980 ;; Remove this article from future suppression.
9981 (gnus-dup-unsuppress-article article)
9982 (let* ((from-method (gnus-find-method-for-group
9983 gnus-newsgroup-name))
9984 (to-method (or select-method
9985 (gnus-find-method-for-group to-newsgroup)))
9986 (move-is-internal (gnus-server-equal from-method to-method)))
9987 (gnus-request-move-article
9988 article ; Article to move
9989 gnus-newsgroup-name ; From newsgroup
9990 (nth 1 (gnus-find-method-for-group
9991 gnus-newsgroup-name)) ; Server
9992 (list 'gnus-request-accept-article
9993 to-newsgroup (list 'quote select-method)
9994 (not articles) t) ; Accept form
9995 (not articles) ; Only save nov last time
9996 (and move-is-internal
9997 to-newsgroup ; Not respooling
9998 ; Is this move internal?
9999 (gnus-group-real-name to-newsgroup)))))
10000 ;; Copy the article.
10001 ((eq action 'copy)
10002 (with-current-buffer copy-buf
10003 (when (gnus-request-article-this-buffer article
10004 gnus-newsgroup-name)
10005 (save-restriction
10006 (nnheader-narrow-to-headers)
10007 (dolist (hdr gnus-copy-article-ignored-headers)
10008 (message-remove-header hdr t)))
10009 (gnus-request-accept-article
10010 to-newsgroup select-method (not articles) t))))
10011 ;; Crosspost the article.
10012 ((eq action 'crosspost)
10013 (let ((xref (message-tokenize-header
10014 (mail-header-xref (gnus-summary-article-header
10015 article))
10016 " ")))
10017 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10018 ":" (number-to-string article)))
10019 (unless xref
10020 (setq xref (list (system-name))))
10021 (setq new-xref
10022 (concat
10023 (mapconcat 'identity
10024 (delete "Xref:" (delete new-xref xref))
10025 " ")
10026 " " new-xref))
10027 (with-current-buffer copy-buf
10028 ;; First put the article in the destination group.
10029 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10030 (when (consp (setq art-group
10031 (gnus-request-accept-article
10032 to-newsgroup select-method (not articles)
10033 t)))
10034 (setq new-xref (concat new-xref " " (car art-group)
10035 ":"
10036 (number-to-string (cdr art-group))))
10037 ;; Now we have the new Xrefs header, so we insert
10038 ;; it and replace the new article.
10039 (nnheader-replace-header "Xref" new-xref)
10040 (gnus-request-replace-article
10041 (cdr art-group) to-newsgroup (current-buffer) t)
10042 art-group))))))
10043 (cond
10044 ((not art-group)
10045 (gnus-message 1 "Couldn't %s article %s: %s"
10046 (cadr (assq action names)) article
10047 (nnheader-get-report (car to-method))))
10048 ((eq art-group 'junk)
10049 (when (eq action 'move)
10050 (gnus-summary-mark-article article gnus-canceled-mark)
10051 (gnus-message 4 "Deleted article %s" article)
10052 ;; run the delete hook
10053 (run-hook-with-args 'gnus-summary-article-delete-hook
10054 action
10055 (gnus-data-header
10056 (assoc article (gnus-data-list nil)))
10057 gnus-newsgroup-name nil
10058 select-method)))
10059 (t
10060 (let* ((pto-group (gnus-group-prefixed-name
10061 (car art-group) to-method))
10062 (info (gnus-get-info pto-group))
10063 (to-group (gnus-info-group info))
10064 to-marks)
10065 ;; Update the group that has been moved to.
10066 (when (and info
10067 (memq action '(move copy)))
10068 (unless (member to-group to-groups)
10069 (push to-group to-groups))
10070
10071 (when (and (not (memq article gnus-newsgroup-unreads))
10072 (cdr art-group))
10073 (push 'read to-marks)
10074 (gnus-info-set-read
10075 info (gnus-add-to-range (gnus-info-read info)
10076 (list (cdr art-group)))))
10077
10078 ;; See whether the article is to be put in the cache.
10079 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10080 (marks (if expirable
10081 gnus-article-mark-lists
10082 (delete '(expirable . expire)
10083 (copy-sequence
10084 gnus-article-mark-lists))))
10085 (to-article (cdr art-group)))
10086
10087 ;; Enter the article into the cache in the new group,
10088 ;; if that is required.
10089 (when (and to-article
10090 gnus-use-cache)
10091 (gnus-cache-possibly-enter-article
10092 to-group to-article
10093 (memq article gnus-newsgroup-marked)
10094 (memq article gnus-newsgroup-dormant)
10095 (memq article gnus-newsgroup-unreads)))
10096
10097 (when (and gnus-preserve-marks
10098 to-article)
10099 ;; Copy any marks over to the new group.
10100 (when (and (equal to-group gnus-newsgroup-name)
10101 (not (memq article gnus-newsgroup-unreads)))
10102 ;; Mark this article as read in this group.
10103 (push (cons to-article gnus-read-mark)
10104 gnus-newsgroup-reads)
10105 ;; Increase the active status of this group.
10106 (setcdr (gnus-active to-group) to-article)
10107 (setcdr gnus-newsgroup-active to-article))
10108
10109 (while marks
10110 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10111 (when (memq article (symbol-value
10112 (intern (format "gnus-newsgroup-%s"
10113 (caar marks)))))
10114 (push (cdar marks) to-marks)
10115 ;; If the other group is the same as this group,
10116 ;; then we have to add the mark to the list.
10117 (when (equal to-group gnus-newsgroup-name)
10118 (set (intern (format "gnus-newsgroup-%s"
10119 (caar marks)))
10120 (cons to-article
10121 (symbol-value
10122 (intern (format "gnus-newsgroup-%s"
10123 (caar marks)))))))
10124 ;; Copy the marks to other group.
10125 (gnus-add-marked-articles
10126 to-group (cdar marks) (list to-article) info)))
10127 (setq marks (cdr marks)))
10128
10129 (when (and expirable
10130 gnus-mark-copied-or-moved-articles-as-expirable
10131 (not (memq 'expire to-marks)))
10132 ;; Mark this article as expirable.
10133 (push 'expire to-marks)
10134 (when (equal to-group gnus-newsgroup-name)
10135 (push to-article gnus-newsgroup-expirable))
10136 ;; Copy the expirable mark to other group.
10137 (gnus-add-marked-articles
10138 to-group 'expire (list to-article) info))
10139
10140 (when (and to-marks
10141 (gnus-method-option-p
10142 (gnus-find-method-for-group to-group)
10143 'server-marks))
10144 (gnus-request-set-mark
10145 to-group (list (list (list to-article) 'add to-marks)))))
10146
10147 (gnus-dribble-enter
10148 (concat "(gnus-group-set-info '"
10149 (gnus-prin1-to-string (gnus-get-info to-group))
10150 ")")
10151 (concat "^(gnus-group-set-info '(\""
10152 (regexp-quote to-group) "\""))))
10153
10154 ;; Update the Xref header in this article to point to
10155 ;; the new crossposted article we have just created.
10156 (when (eq action 'crosspost)
10157 (with-current-buffer copy-buf
10158 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10159 (nnheader-replace-header "Xref" new-xref)
10160 (gnus-request-replace-article
10161 article gnus-newsgroup-name (current-buffer) t)))
10162
10163 ;; run the move/copy/crosspost/respool hook
10164 (run-hook-with-args 'gnus-summary-article-move-hook
10165 action
10166 (gnus-data-header
10167 (assoc article (gnus-data-list nil)))
10168 gnus-newsgroup-name
10169 to-newsgroup
10170 select-method))
10171
10172 ;;;!!!Why is this necessary?
10173 (set-buffer gnus-summary-buffer)
10174
10175 (when (eq action 'move)
10176 (save-excursion
10177 (gnus-summary-goto-subject article)
10178 (gnus-summary-mark-article article gnus-canceled-mark)))))
10179 (push article articles-to-update-marks))
10180
10181 (save-excursion
10182 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10183 ;; Re-activate all groups that have been moved to.
10184 (with-current-buffer gnus-group-buffer
10185 (let ((gnus-group-marked to-groups))
10186 (gnus-group-get-new-news-this-group nil t)))
10187
10188 (gnus-kill-buffer copy-buf)
10189 (gnus-summary-position-point)
10190 (gnus-set-mode-line 'summary)))
10191
10192 (defun gnus-summary-push-marks-to-backend (article)
10193 (let ((set nil)
10194 (del nil)
10195 (marks gnus-article-mark-lists))
10196 (unless (memq article gnus-newsgroup-unreads)
10197 (push 'read set))
10198 (while marks
10199 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10200 (memq article (symbol-value
10201 (intern (format "gnus-newsgroup-%s"
10202 (caar marks))))))
10203 (push (cdar marks) set)
10204 (push (cdar marks) del))
10205 (pop marks))
10206 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10207 ((,article) del ,del)))))
10208
10209 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10210 "Copy the current article to some other group.
10211 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10212 When called interactively, if TO-NEWSGROUP is nil, use the value of
10213 the variable `gnus-move-split-methods' for finding a default target
10214 newsgroup.
10215 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10216 re-spool using this method."
10217 (interactive "P")
10218 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10219
10220 (defun gnus-summary-crosspost-article (&optional n)
10221 "Crosspost the current article to some other group."
10222 (interactive "P")
10223 (gnus-summary-move-article n nil nil 'crosspost))
10224
10225 (defcustom gnus-summary-respool-default-method nil
10226 "Default method type for respooling an article.
10227 If nil, use to the current newsgroup method."
10228 :type 'symbol
10229 :group 'gnus-summary-mail)
10230
10231 (defun gnus-summary-respool-article (&optional n method)
10232 "Respool the current article.
10233 The article will be squeezed through the mail spooling process again,
10234 which means that it will be put in some mail newsgroup or other
10235 depending on `nnmail-split-methods'.
10236 If N is a positive number, respool the N next articles.
10237 If N is a negative number, respool the N previous articles.
10238 If N is nil and any articles have been marked with the process mark,
10239 respool those articles instead.
10240
10241 Respooling can be done both from mail groups and \"real\" newsgroups.
10242 In the former case, the articles in question will be moved from the
10243 current group into whatever groups they are destined to. In the
10244 latter case, they will be copied into the relevant groups."
10245 (interactive
10246 (list current-prefix-arg
10247 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10248 (methname
10249 (symbol-name (or gnus-summary-respool-default-method
10250 (car (gnus-find-method-for-group
10251 gnus-newsgroup-name)))))
10252 (method
10253 (gnus-completing-read
10254 "Backend to use when respooling"
10255 methods t nil 'gnus-mail-method-history methname))
10256 ms)
10257 (cond
10258 ((zerop (length (setq ms (gnus-servers-using-backend
10259 (intern method)))))
10260 (list (intern method) ""))
10261 ((= 1 (length ms))
10262 (car ms))
10263 (t
10264 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10265 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10266 ms-alist))))))))
10267 (unless method
10268 (error "No method given for respooling"))
10269 (if (assoc (symbol-name
10270 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10271 (gnus-methods-using 'respool))
10272 (gnus-summary-move-article n nil method)
10273 (gnus-summary-copy-article n nil method)))
10274
10275 (defun gnus-summary-import-article (file &optional edit)
10276 "Import an arbitrary file into a mail newsgroup."
10277 (interactive "fImport file: \nP")
10278 (let ((group gnus-newsgroup-name)
10279 (now (current-time))
10280 atts lines group-art)
10281 (unless (gnus-check-backend-function 'request-accept-article group)
10282 (error "%s does not support article importing" group))
10283 (or (file-readable-p file)
10284 (not (file-regular-p file))
10285 (error "Can't read %s" file))
10286 (with-current-buffer (gnus-get-buffer-create " *import file*")
10287 (erase-buffer)
10288 (nnheader-insert-file-contents file)
10289 (goto-char (point-min))
10290 (if (nnheader-article-p)
10291 (save-restriction
10292 (goto-char (point-min))
10293 (search-forward "\n\n" nil t)
10294 (narrow-to-region (point-min) (1- (point)))
10295 (goto-char (point-min))
10296 (unless (re-search-forward "^date:" nil t)
10297 (goto-char (point-max))
10298 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10299 ;; This doesn't look like an article, so we fudge some headers.
10300 (setq atts (file-attributes file)
10301 lines (count-lines (point-min) (point-max)))
10302 (insert "From: " (read-string "From: ") "\n"
10303 "Subject: " (read-string "Subject: ") "\n"
10304 "Date: " (message-make-date (nth 5 atts)) "\n"
10305 "Message-ID: " (message-make-message-id) "\n"
10306 "Lines: " (int-to-string lines) "\n"
10307 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10308 (setq group-art (gnus-request-accept-article group nil t))
10309 (kill-buffer (current-buffer)))
10310 (setq gnus-newsgroup-active (gnus-activate-group group))
10311 (forward-line 1)
10312 (gnus-summary-goto-article (cdr group-art) nil t)
10313 (when edit
10314 (gnus-summary-edit-article))))
10315
10316 (defun gnus-summary-create-article ()
10317 "Create an article in a mail newsgroup."
10318 (interactive)
10319 (let ((group gnus-newsgroup-name)
10320 (now (current-time))
10321 group-art)
10322 (unless (gnus-check-backend-function 'request-accept-article group)
10323 (error "%s does not support article importing" group))
10324 (with-current-buffer (gnus-get-buffer-create " *import file*")
10325 (erase-buffer)
10326 (goto-char (point-min))
10327 ;; This doesn't look like an article, so we fudge some headers.
10328 (insert "From: " (read-string "From: ") "\n"
10329 "Subject: " (read-string "Subject: ") "\n"
10330 "Date: " (message-make-date now) "\n"
10331 "Message-ID: " (message-make-message-id) "\n")
10332 (setq group-art (gnus-request-accept-article group nil t))
10333 (kill-buffer (current-buffer)))
10334 (setq gnus-newsgroup-active (gnus-activate-group group))
10335 (forward-line 1)
10336 (gnus-summary-goto-article (cdr group-art) nil t)
10337 (gnus-summary-edit-article)))
10338
10339 (defun gnus-summary-article-posted-p ()
10340 "Say whether the current (mail) article is available from news as well.
10341 This will be the case if the article has both been mailed and posted."
10342 (interactive)
10343 (let ((id (mail-header-references (gnus-summary-article-header)))
10344 (gnus-override-method (car (gnus-refer-article-methods))))
10345 (if (gnus-request-head id "")
10346 (gnus-message 2 "The current message was found on %s"
10347 gnus-override-method)
10348 (gnus-message 2 "The current message couldn't be found on %s"
10349 gnus-override-method)
10350 nil)))
10351
10352 (defun gnus-summary-expire-articles (&optional now)
10353 "Expire all articles that are marked as expirable in the current group."
10354 (interactive)
10355 (when (and (not gnus-group-is-exiting-without-update-p)
10356 (gnus-check-backend-function
10357 'request-expire-articles gnus-newsgroup-name))
10358 ;; This backend supports expiry.
10359 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10360 (expirable
10361 (gnus-list-range-difference
10362 (if total
10363 (progn
10364 ;; We need to update the info for
10365 ;; this group for `gnus-list-of-read-articles'
10366 ;; to give us the right answer.
10367 (gnus-run-hooks 'gnus-exit-group-hook)
10368 (gnus-summary-update-info)
10369 (gnus-list-of-read-articles gnus-newsgroup-name))
10370 (setq gnus-newsgroup-expirable
10371 (sort gnus-newsgroup-expirable '<)))
10372 gnus-newsgroup-unexist))
10373 (expiry-wait (if now 'immediate
10374 (gnus-group-find-parameter
10375 gnus-newsgroup-name 'expiry-wait)))
10376 (nnmail-expiry-target
10377 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10378 nnmail-expiry-target))
10379 es)
10380 (when expirable
10381 ;; There are expirable articles in this group, so we run them
10382 ;; through the expiry process.
10383 (gnus-message 6 "Expiring articles...")
10384 (when (gnus-check-group gnus-newsgroup-name)
10385 ;; The list of articles that weren't expired is returned.
10386 (save-excursion
10387 (if expiry-wait
10388 (let ((nnmail-expiry-wait-function nil)
10389 (nnmail-expiry-wait expiry-wait))
10390 (setq es (gnus-request-expire-articles
10391 expirable gnus-newsgroup-name)))
10392 (setq es (gnus-request-expire-articles
10393 expirable gnus-newsgroup-name)))
10394 (unless total
10395 (setq gnus-newsgroup-expirable es))
10396 ;; We go through the old list of expirable, and mark all
10397 ;; really expired articles as nonexistent.
10398 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10399 (let ((gnus-use-cache nil))
10400 (dolist (article expirable)
10401 (when (and (not (memq article es))
10402 (gnus-data-find article))
10403 (gnus-summary-mark-article article gnus-canceled-mark)
10404 (run-hook-with-args
10405 'gnus-summary-article-expire-hook
10406 'delete
10407 (gnus-data-header (assoc article (gnus-data-list nil)))
10408 gnus-newsgroup-name
10409 (cond
10410 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10411 ((eq nnmail-expiry-target 'delete) nil)
10412 (t
10413 (let ((rescall (funcall nnmail-expiry-target
10414 gnus-newsgroup-name)))
10415 (if (stringp rescall) rescall nil))))
10416 nil)))))))
10417 (gnus-message 6 "Expiring articles...done")))))
10418
10419 (defun gnus-summary-expire-articles-now ()
10420 "Expunge all expirable articles in the current group.
10421 This means that *all* articles that are marked as expirable will be
10422 deleted forever, right now."
10423 (interactive)
10424 (or gnus-expert-user
10425 (gnus-yes-or-no-p
10426 "Are you really, really sure you want to delete all expirable messages? ")
10427 (error "Phew!"))
10428 (gnus-summary-expire-articles t))
10429
10430 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10431 (defun gnus-summary-delete-article (&optional n)
10432 "Delete the N next (mail) articles.
10433 This command actually deletes articles. This is not a marking
10434 command. The article will disappear forever from your life, never to
10435 return.
10436
10437 If N is negative, delete backwards.
10438 If N is nil and articles have been marked with the process mark,
10439 delete these instead.
10440
10441 If `gnus-novice-user' is non-nil you will be asked for
10442 confirmation before the articles are deleted."
10443 (interactive "P")
10444 (unless (gnus-check-backend-function 'request-expire-articles
10445 gnus-newsgroup-name)
10446 (error "The current newsgroup does not support article deletion"))
10447 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10448 (error "Couldn't open server"))
10449 ;; Compute the list of articles to delete.
10450 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10451 (nnmail-expiry-target 'delete)
10452 not-deleted)
10453 (if (and gnus-novice-user
10454 (not (gnus-yes-or-no-p
10455 (format "Do you really want to delete %s forever? "
10456 (if (> (length articles) 1)
10457 (format "these %s articles" (length articles))
10458 "this article")))))
10459 ()
10460 ;; Delete the articles.
10461 (setq not-deleted (gnus-request-expire-articles
10462 articles gnus-newsgroup-name 'force))
10463 (save-excursion
10464 (while articles
10465 (gnus-summary-remove-process-mark (car articles))
10466 ;; The backend might not have been able to delete the article
10467 ;; after all.
10468 (unless (memq (car articles) not-deleted)
10469 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10470 (let* ((article (car articles))
10471 (ghead (gnus-data-header
10472 (assoc article (gnus-data-list nil)))))
10473 (run-hook-with-args 'gnus-summary-article-delete-hook
10474 'delete ghead gnus-newsgroup-name nil
10475 nil)))
10476 (setq articles (cdr articles))))
10477 (when not-deleted
10478 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10479 (gnus-summary-position-point)
10480 (gnus-set-mode-line 'summary)
10481 not-deleted))
10482
10483 (defun gnus-summary-edit-article (&optional arg)
10484 "Edit the current article.
10485 This will have permanent effect only in mail groups.
10486 If ARG is nil, edit the decoded articles.
10487 If ARG is 1, edit the raw articles.
10488 If ARG is 2, edit the raw articles even in read-only groups.
10489 If ARG is 3, edit the articles with the current handles.
10490 Otherwise, allow editing of articles even in read-only
10491 groups."
10492 (interactive "P")
10493 (let (force raw current-handles)
10494 (cond
10495 ((null arg))
10496 ((eq arg 1)
10497 (setq raw t))
10498 ((eq arg 2)
10499 (setq raw t
10500 force t))
10501 ((eq arg 3)
10502 (setq current-handles
10503 (and (gnus-buffer-live-p gnus-article-buffer)
10504 (with-current-buffer gnus-article-buffer
10505 (prog1
10506 gnus-article-mime-handles
10507 (setq gnus-article-mime-handles nil))))))
10508 (t
10509 (setq force t)))
10510 (when (and raw (not force)
10511 (member gnus-newsgroup-name '("nndraft:delayed"
10512 "nndraft:drafts"
10513 "nndraft:queue")))
10514 (error "Can't edit the raw article in group %s"
10515 gnus-newsgroup-name))
10516 (with-current-buffer gnus-summary-buffer
10517 (let ((mail-parse-charset gnus-newsgroup-charset)
10518 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10519 (gnus-set-global-variables)
10520 (when (and (not force)
10521 (gnus-group-read-only-p))
10522 (error "The current newsgroup does not support article editing"))
10523 (gnus-summary-show-article t)
10524 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10525 (with-current-buffer gnus-article-buffer
10526 (mm-enable-multibyte)))
10527 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10528 (setq raw t))
10529 (gnus-article-edit-article
10530 (if raw 'ignore
10531 `(lambda ()
10532 (let ((mbl mml-buffer-list))
10533 (setq mml-buffer-list nil)
10534 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10535 (mime-to-mml ,'current-handles))
10536 (let ((mbl1 mml-buffer-list))
10537 (setq mml-buffer-list mbl)
10538 (set (make-local-variable 'mml-buffer-list) mbl1))
10539 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10540 `(lambda (no-highlight)
10541 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10542 (message-options message-options)
10543 (message-options-set-recipient)
10544 (mail-parse-ignored-charsets
10545 ',gnus-newsgroup-ignored-charsets)
10546 (rfc2047-header-encoding-alist
10547 ',(let ((charset (gnus-group-name-charset
10548 (gnus-find-method-for-group
10549 gnus-newsgroup-name)
10550 gnus-newsgroup-name)))
10551 (append (list (cons "Newsgroups" charset)
10552 (cons "Followup-To" charset)
10553 (cons "Xref" charset))
10554 rfc2047-header-encoding-alist))))
10555 ,(if (not raw) '(progn
10556 (mml-to-mime)
10557 (mml-destroy-buffers)
10558 (remove-hook 'kill-buffer-hook
10559 'mml-destroy-buffers t)
10560 (kill-local-variable 'mml-buffer-list)))
10561 (gnus-summary-edit-article-done
10562 ,(or (mail-header-references gnus-current-headers) "")
10563 ,(gnus-group-read-only-p)
10564 ,gnus-summary-buffer no-highlight))))))))
10565
10566 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10567
10568 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10569 no-highlight)
10570 "Make edits to the current article permanent."
10571 (interactive)
10572 (save-excursion
10573 ;; The buffer restriction contains the entire article if it exists.
10574 (when (article-goto-body)
10575 (let ((lines (count-lines (point) (point-max)))
10576 (length (- (point-max) (point)))
10577 (case-fold-search t)
10578 (body (point-marker)))
10579 (goto-char (point-min))
10580 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10581 (delete-region (match-beginning 1) (match-end 1))
10582 (insert (number-to-string length)))
10583 (goto-char (point-min))
10584 (when (re-search-forward
10585 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10586 (delete-region (match-beginning 1) (match-end 1))
10587 (insert (number-to-string length)))
10588 (goto-char (point-min))
10589 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10590 (delete-region (match-beginning 1) (match-end 1))
10591 (insert (number-to-string lines))))))
10592 ;; Replace the article.
10593 (let ((buf (current-buffer))
10594 (article (cdr gnus-article-current))
10595 replace-result)
10596 (with-temp-buffer
10597 (insert-buffer-substring buf)
10598 (if (and (not read-only)
10599 (not (setq replace-result
10600 (gnus-request-replace-article
10601 article (car gnus-article-current)
10602 (current-buffer) t))))
10603 (error "Couldn't replace article")
10604 ;; If we got a number back, then that's the new article number
10605 ;; for this article. Otherwise, the article number didn't change.
10606 (when (numberp replace-result)
10607 (with-current-buffer gnus-summary-buffer
10608 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10609 (gnus-summary-limit gnus-newsgroup-limit)
10610 (setq article replace-result)
10611 (gnus-summary-goto-subject article t)))
10612 ;; Update the summary buffer.
10613 (if (and references
10614 (equal (message-tokenize-header references " ")
10615 (message-tokenize-header
10616 (or (message-fetch-field "references") "") " ")))
10617 ;; We only have to update this line.
10618 (save-excursion
10619 (save-restriction
10620 (message-narrow-to-head)
10621 (let ((head (buffer-substring-no-properties
10622 (point-min) (point-max)))
10623 header)
10624 (with-temp-buffer
10625 (insert (format "211 %d Article retrieved.\n" article))
10626 (insert head)
10627 (insert ".\n")
10628 (let ((nntp-server-buffer (current-buffer)))
10629 (setq header (car (gnus-get-newsgroup-headers nil t))))
10630 (with-current-buffer gnus-summary-buffer
10631 (gnus-data-set-header (gnus-data-find article) header)
10632 (gnus-summary-update-article-line article header)
10633 (if (gnus-summary-goto-subject article nil t)
10634 (gnus-summary-update-secondary-mark article)))))))
10635 ;; Update threads.
10636 (set-buffer (or buffer gnus-summary-buffer))
10637 (gnus-summary-update-article article)
10638 (if (gnus-summary-goto-subject article nil t)
10639 (gnus-summary-update-secondary-mark article)))
10640 ;; Prettify the article buffer again.
10641 (unless no-highlight
10642 (with-current-buffer gnus-article-buffer
10643 ;;!!! Fix this -- article should be rehighlighted.
10644 ;;(gnus-run-hooks 'gnus-article-display-hook)
10645 (set-buffer gnus-original-article-buffer)
10646 (gnus-request-article
10647 article (car gnus-article-current) (current-buffer))))
10648 ;; Prettify the summary buffer line.
10649 (when (gnus-visual-p 'summary-highlight 'highlight)
10650 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10651
10652 (defun gnus-summary-edit-wash (key)
10653 "Perform editing command KEY in the article buffer."
10654 (interactive
10655 (list
10656 (progn
10657 (message "%s" (concat (this-command-keys) "- "))
10658 (read-char))))
10659 (message "")
10660 (gnus-summary-edit-article)
10661 (execute-kbd-macro (concat (this-command-keys) key))
10662 (gnus-article-edit-done))
10663
10664 ;;; Respooling
10665
10666 (defvar nnimap-split-fancy)
10667 (defvar nnimap-split-methods)
10668
10669 (defun gnus-summary-respool-query (&optional silent trace)
10670 "Query where the respool algorithm would put this article."
10671 (interactive)
10672 (let (gnus-mark-article-hook)
10673 (gnus-summary-select-article)
10674 (with-current-buffer gnus-original-article-buffer
10675 (let ((groups
10676 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10677 'nnimap)
10678 ;; nnimap has its own splitting variables.
10679 (let ((nnmail-split-methods
10680 (cond
10681 ((eq nnimap-split-methods 'default)
10682 nnmail-split-methods)
10683 (nnimap-split-methods
10684 nnimap-split-methods)
10685 (nnimap-split-fancy
10686 'nnmail-split-fancy)))
10687 (nnmail-split-fancy (or nnimap-split-fancy
10688 nnmail-split-fancy)))
10689 (nnmail-article-group 'identity trace))
10690 (nnmail-article-group 'identity trace))))
10691 (unless silent
10692 (if groups
10693 (message "This message would go to %s"
10694 (mapconcat 'car groups ", "))
10695 (message "This message would go to no groups"))
10696 groups)))))
10697
10698 (defun gnus-summary-respool-trace ()
10699 "Trace where the respool algorithm would put this article.
10700 Display a buffer showing all fancy splitting patterns which matched."
10701 (interactive)
10702 (gnus-summary-respool-query nil t))
10703
10704 ;; Summary marking commands.
10705
10706 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10707 "Mark articles which has the same subject as read, and then select the next.
10708 If UNMARK is positive, remove any kind of mark.
10709 If UNMARK is negative, tick articles."
10710 (interactive "P")
10711 (when unmark
10712 (setq unmark (prefix-numeric-value unmark)))
10713 (let ((count
10714 (gnus-summary-mark-same-subject
10715 (gnus-summary-article-subject) unmark)))
10716 ;; Select next unread article. If auto-select-same mode, should
10717 ;; select the first unread article.
10718 (gnus-summary-next-article t (and gnus-auto-select-same
10719 (gnus-summary-article-subject)))
10720 (gnus-message 7 "%d article%s marked as %s"
10721 count (if (= count 1) " is" "s are")
10722 (if unmark "unread" "read"))))
10723
10724 (defun gnus-summary-kill-same-subject (&optional unmark)
10725 "Mark articles which has the same subject as read.
10726 If UNMARK is positive, remove any kind of mark.
10727 If UNMARK is negative, tick articles."
10728 (interactive "P")
10729 (when unmark
10730 (setq unmark (prefix-numeric-value unmark)))
10731 (let ((count
10732 (gnus-summary-mark-same-subject
10733 (gnus-summary-article-subject) unmark)))
10734 ;; If marked as read, go to next unread subject.
10735 (when (null unmark)
10736 ;; Go to next unread subject.
10737 (gnus-summary-next-subject 1 t))
10738 (gnus-message 7 "%d articles are marked as %s"
10739 count (if unmark "unread" "read"))))
10740
10741 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10742 "Mark articles with same SUBJECT as read, and return marked number.
10743 If optional argument UNMARK is positive, remove any kinds of marks.
10744 If optional argument UNMARK is negative, mark articles as unread instead."
10745 (let ((count 1))
10746 (save-excursion
10747 (cond
10748 ((null unmark) ; Mark as read.
10749 (while (and
10750 (progn
10751 (gnus-summary-mark-article-as-read gnus-killed-mark)
10752 (gnus-summary-show-thread) t)
10753 (gnus-summary-find-subject subject))
10754 (setq count (1+ count))))
10755 ((> unmark 0) ; Tick.
10756 (while (and
10757 (progn
10758 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10759 (gnus-summary-show-thread) t)
10760 (gnus-summary-find-subject subject))
10761 (setq count (1+ count))))
10762 (t ; Mark as unread.
10763 (while (and
10764 (progn
10765 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10766 (gnus-summary-show-thread) t)
10767 (gnus-summary-find-subject subject))
10768 (setq count (1+ count)))))
10769 (gnus-set-mode-line 'summary)
10770 ;; Return the number of marked articles.
10771 count)))
10772
10773 (defun gnus-summary-mark-as-processable (n &optional unmark)
10774 "Set the process mark on the next N articles.
10775 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10776 the process mark instead. The difference between N and the actual
10777 number of articles marked is returned."
10778 (interactive "P")
10779 (if (and (null n) (and transient-mark-mode mark-active))
10780 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10781 (setq n (prefix-numeric-value n))
10782 (let ((backward (< n 0))
10783 (n (abs n)))
10784 (while (and
10785 (> n 0)
10786 (if unmark
10787 (gnus-summary-remove-process-mark
10788 (gnus-summary-article-number))
10789 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10790 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10791 (setq n (1- n)))
10792 (when (/= 0 n)
10793 (gnus-message 7 "No more articles"))
10794 (gnus-summary-recenter)
10795 (gnus-summary-position-point)
10796 n)))
10797
10798 (defun gnus-summary-unmark-as-processable (n)
10799 "Remove the process mark from the next N articles.
10800 If N is negative, unmark backward instead. The difference between N and
10801 the actual number of articles unmarked is returned."
10802 (interactive "P")
10803 (gnus-summary-mark-as-processable n t))
10804
10805 (defun gnus-summary-unmark-all-processable ()
10806 "Remove the process mark from all articles."
10807 (interactive)
10808 (save-excursion
10809 (while gnus-newsgroup-processable
10810 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10811 (gnus-summary-position-point))
10812
10813 (defun gnus-summary-add-mark (article type)
10814 "Mark ARTICLE with a mark of TYPE."
10815 (let ((vtype (car (assq type gnus-article-mark-lists)))
10816 var)
10817 (if (not vtype)
10818 (error "No such mark type: %s" type)
10819 (setq var (intern (format "gnus-newsgroup-%s" type)))
10820 (set var (cons article (symbol-value var)))
10821 (if (memq type '(processable cached replied forwarded recent saved))
10822 (gnus-summary-update-secondary-mark article)
10823 ;;; !!! This is bogus. We should find out what primary
10824 ;;; !!! mark we want to set.
10825 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10826
10827 (defun gnus-summary-mark-as-expirable (n)
10828 "Mark N articles forward as expirable.
10829 If N is negative, mark backward instead. The difference between N and
10830 the actual number of articles marked is returned."
10831 (interactive "p")
10832 (gnus-summary-mark-forward n gnus-expirable-mark))
10833
10834 (defun gnus-summary-mark-as-spam (n)
10835 "Mark N articles forward as spam.
10836 If N is negative, mark backward instead. The difference between N and
10837 the actual number of articles marked is returned."
10838 (interactive "p")
10839 (gnus-summary-mark-forward n gnus-spam-mark))
10840
10841 (defun gnus-summary-mark-article-as-replied (article)
10842 "Mark ARTICLE as replied to and update the summary line.
10843 ARTICLE can also be a list of articles."
10844 (interactive (list (gnus-summary-article-number)))
10845 (let ((articles (if (listp article) article (list article))))
10846 (dolist (article articles)
10847 (unless (numberp article)
10848 (error "%s is not a number" article))
10849 (push article gnus-newsgroup-replied)
10850 (let ((inhibit-read-only t))
10851 (when (gnus-summary-goto-subject article nil t)
10852 (gnus-summary-update-secondary-mark article))))))
10853
10854 (defun gnus-summary-mark-article-as-forwarded (article)
10855 "Mark ARTICLE as forwarded and update the summary line.
10856 ARTICLE can also be a list of articles."
10857 (let ((articles (if (listp article) article (list article))))
10858 (dolist (article articles)
10859 (push article gnus-newsgroup-forwarded)
10860 (let ((inhibit-read-only t))
10861 (when (gnus-summary-goto-subject article nil t)
10862 (gnus-summary-update-secondary-mark article))))))
10863
10864 (defun gnus-summary-set-bookmark (article)
10865 "Set a bookmark in current article."
10866 (interactive (list (gnus-summary-article-number)))
10867 (when (or (not (get-buffer gnus-article-buffer))
10868 (not gnus-current-article)
10869 (not gnus-article-current)
10870 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10871 (error "No current article selected"))
10872 ;; Remove old bookmark, if one exists.
10873 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10874 ;; Set the new bookmark, which is on the form
10875 ;; (article-number . line-number-in-body).
10876 (push
10877 (cons article
10878 (with-current-buffer gnus-article-buffer
10879 (count-lines
10880 (min (point)
10881 (save-excursion
10882 (article-goto-body)
10883 (point)))
10884 (point))))
10885 gnus-newsgroup-bookmarks)
10886 (gnus-message 6 "A bookmark has been added to the current article."))
10887
10888 (defun gnus-summary-remove-bookmark (article)
10889 "Remove the bookmark from the current article."
10890 (interactive (list (gnus-summary-article-number)))
10891 ;; Remove old bookmark, if one exists.
10892 (if (not (assq article gnus-newsgroup-bookmarks))
10893 (gnus-message 6 "No bookmark in current article.")
10894 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10895 (gnus-message 6 "Removed bookmark.")))
10896
10897 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10898 (defun gnus-summary-mark-as-dormant (n)
10899 "Mark N articles forward as dormant.
10900 If N is negative, mark backward instead. The difference between N and
10901 the actual number of articles marked is returned."
10902 (interactive "p")
10903 (gnus-summary-mark-forward n gnus-dormant-mark))
10904
10905 (defun gnus-summary-set-process-mark (article)
10906 "Set the process mark on ARTICLE and update the summary line."
10907 (setq gnus-newsgroup-processable
10908 (cons article
10909 (delq article gnus-newsgroup-processable)))
10910 (when (gnus-summary-goto-subject article)
10911 (gnus-summary-show-thread)
10912 (gnus-summary-goto-subject article)
10913 (gnus-summary-update-secondary-mark article)))
10914
10915 (defun gnus-summary-remove-process-mark (&rest articles)
10916 "Remove the process mark from ARTICLES and update the summary line."
10917 (dolist (article articles)
10918 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10919 (when (gnus-summary-goto-subject article)
10920 (gnus-summary-show-thread)
10921 (gnus-summary-goto-subject article)
10922 (gnus-summary-update-secondary-mark article)))
10923 t)
10924
10925 (defun gnus-summary-set-saved-mark (article)
10926 "Set the process mark on ARTICLE and update the summary line."
10927 (push article gnus-newsgroup-saved)
10928 (when (gnus-summary-goto-subject article)
10929 (gnus-summary-update-secondary-mark article)))
10930
10931 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10932 "Mark N articles as read forwards.
10933 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10934 The difference between N and the actual number of articles marked is
10935 returned.
10936 If NO-EXPIRE, auto-expiry will be inhibited."
10937 (interactive "p")
10938 (gnus-summary-show-thread)
10939 (let ((backward (< n 0))
10940 (gnus-summary-goto-unread
10941 (and gnus-summary-goto-unread
10942 (not (eq gnus-summary-goto-unread 'never))
10943 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10944 gnus-ticked-mark gnus-dormant-mark)))))
10945 (n (abs n))
10946 (mark (or mark gnus-del-mark)))
10947 (while (and (> n 0)
10948 (gnus-summary-mark-article nil mark no-expire)
10949 (zerop (gnus-summary-next-subject
10950 (if backward -1 1)
10951 (and gnus-summary-goto-unread
10952 (not (eq gnus-summary-goto-unread 'never)))
10953 t)))
10954 (setq n (1- n)))
10955 (when (/= 0 n)
10956 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10957 (gnus-summary-recenter)
10958 (gnus-summary-position-point)
10959 (gnus-set-mode-line 'summary)
10960 n))
10961
10962 (defun gnus-summary-mark-article-as-read (mark)
10963 "Mark the current article quickly as read with MARK."
10964 (let ((article (gnus-summary-article-number)))
10965 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10966 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10967 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10968 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10969 (push (cons article mark) gnus-newsgroup-reads)
10970 ;; Possibly remove from cache, if that is used.
10971 (when gnus-use-cache
10972 (gnus-cache-enter-remove-article article))
10973 ;; Allow the backend to change the mark.
10974 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10975 ;; Check for auto-expiry.
10976 (when (and gnus-newsgroup-auto-expire
10977 (memq mark gnus-auto-expirable-marks))
10978 (setq mark gnus-expirable-mark)
10979 ;; Let the backend know about the mark change.
10980 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10981 (push article gnus-newsgroup-expirable))
10982 ;; Set the mark in the buffer.
10983 (gnus-summary-update-mark mark 'unread)
10984 t))
10985
10986 (defun gnus-summary-mark-article-as-unread (mark)
10987 "Mark the current article quickly as unread with MARK."
10988 (let* ((article (gnus-summary-article-number))
10989 (old-mark (gnus-summary-article-mark article)))
10990 ;; Allow the backend to change the mark.
10991 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10992 (if (eq mark old-mark)
10993 t
10994 (if (<= article 0)
10995 (progn
10996 (gnus-error 1 "Can't mark negative article numbers")
10997 nil)
10998 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10999 (setq gnus-newsgroup-spam-marked
11000 (delq article gnus-newsgroup-spam-marked))
11001 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11002 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
11003 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
11004 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11005 (cond ((= mark gnus-ticked-mark)
11006 (setq gnus-newsgroup-marked
11007 (gnus-add-to-sorted-list gnus-newsgroup-marked
11008 article)))
11009 ((= mark gnus-spam-mark)
11010 (setq gnus-newsgroup-spam-marked
11011 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11012 article)))
11013 ((= mark gnus-dormant-mark)
11014 (setq gnus-newsgroup-dormant
11015 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11016 article)))
11017 (t
11018 (setq gnus-newsgroup-unreads
11019 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11020 article))))
11021 (gnus-alist-pull article gnus-newsgroup-reads)
11022
11023 ;; See whether the article is to be put in the cache.
11024 (and gnus-use-cache
11025 (vectorp (gnus-summary-article-header article))
11026 (save-excursion
11027 (gnus-cache-possibly-enter-article
11028 gnus-newsgroup-name article
11029 (= mark gnus-ticked-mark)
11030 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11031
11032 ;; Fix the mark.
11033 (gnus-summary-update-mark mark 'unread)
11034 t))))
11035
11036 (defun gnus-summary-mark-article (&optional article mark no-expire)
11037 "Mark ARTICLE with MARK. MARK can be any character.
11038 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11039 `??' (dormant) and `?E' (expirable).
11040 If MARK is nil, then the default character `?r' is used.
11041 If ARTICLE is nil, then the article on the current line will be
11042 marked.
11043 If NO-EXPIRE, auto-expiry will be inhibited."
11044 ;; The mark might be a string.
11045 (when (stringp mark)
11046 (setq mark (aref mark 0)))
11047 ;; If no mark is given, then we check auto-expiring.
11048 (when (null mark)
11049 (setq mark gnus-del-mark))
11050 (when (and (not no-expire)
11051 gnus-newsgroup-auto-expire
11052 (memq mark gnus-auto-expirable-marks))
11053 (setq mark gnus-expirable-mark))
11054 (let ((article (or article (gnus-summary-article-number)))
11055 (old-mark (gnus-summary-article-mark article)))
11056 ;; Allow the backend to change the mark.
11057 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11058 (if (eq mark old-mark)
11059 t
11060 (unless article
11061 (error "No article on current line"))
11062 (if (not (if (or (= mark gnus-unread-mark)
11063 (= mark gnus-ticked-mark)
11064 (= mark gnus-spam-mark)
11065 (= mark gnus-dormant-mark))
11066 (gnus-mark-article-as-unread article mark)
11067 (gnus-mark-article-as-read article mark)))
11068 t
11069 ;; See whether the article is to be put in the cache.
11070 (and gnus-use-cache
11071 (not (= mark gnus-canceled-mark))
11072 (vectorp (gnus-summary-article-header article))
11073 (save-excursion
11074 (gnus-cache-possibly-enter-article
11075 gnus-newsgroup-name article
11076 (= mark gnus-ticked-mark)
11077 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11078
11079 (when (gnus-summary-goto-subject article nil t)
11080 (let ((inhibit-read-only t))
11081 (gnus-summary-show-thread)
11082 ;; Fix the mark.
11083 (gnus-summary-update-mark mark 'unread)
11084 t))))))
11085
11086 (defun gnus-summary-update-secondary-mark (article)
11087 "Update the secondary (read, process, cache) mark."
11088 (gnus-summary-update-mark
11089 (cond ((memq article gnus-newsgroup-processable)
11090 gnus-process-mark)
11091 ((memq article gnus-newsgroup-cached)
11092 gnus-cached-mark)
11093 ((memq article gnus-newsgroup-replied)
11094 gnus-replied-mark)
11095 ((memq article gnus-newsgroup-forwarded)
11096 gnus-forwarded-mark)
11097 ((memq article gnus-newsgroup-saved)
11098 gnus-saved-mark)
11099 ((memq article gnus-newsgroup-unseen)
11100 gnus-unseen-mark)
11101 (t gnus-no-mark))
11102 'replied)
11103 (when (gnus-visual-p 'summary-highlight 'highlight)
11104 (gnus-summary-highlight-line)
11105 (gnus-run-hooks 'gnus-summary-update-hook))
11106 t)
11107
11108 (defun gnus-summary-update-download-mark (article)
11109 "Update the download mark."
11110 (gnus-summary-update-mark
11111 (cond ((memq article gnus-newsgroup-undownloaded)
11112 gnus-undownloaded-mark)
11113 (gnus-newsgroup-agentized
11114 gnus-downloaded-mark)
11115 (t
11116 gnus-no-mark))
11117 'download)
11118 (gnus-summary-update-line t)
11119 t)
11120
11121 (defun gnus-summary-update-mark (mark type)
11122 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11123 (inhibit-read-only t))
11124 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11125 (when forward
11126 (when (looking-at "\r")
11127 (incf forward))
11128 (when (<= (+ forward (point)) (point-max))
11129 ;; Go to the right position on the line.
11130 (goto-char (+ forward (point)))
11131 ;; Replace the old mark with the new mark.
11132 (let ((to-insert
11133 (subst-char-in-string
11134 (char-after) mark
11135 (buffer-substring (point) (1+ (point))))))
11136 (delete-region (point) (1+ (point)))
11137 (insert to-insert))
11138 ;; Optionally update the marks by some user rule.
11139 (when (eq type 'unread)
11140 (gnus-data-set-mark
11141 (gnus-data-find (gnus-summary-article-number)) mark)
11142 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11143
11144 (defun gnus-mark-article-as-read (article &optional mark)
11145 "Enter ARTICLE in the pertinent lists and remove it from others."
11146 ;; Make the article expirable.
11147 (let ((mark (or mark gnus-del-mark)))
11148 (setq gnus-newsgroup-expirable
11149 (if (= mark gnus-expirable-mark)
11150 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11151 (delq article gnus-newsgroup-expirable)))
11152 ;; Remove from unread and marked lists.
11153 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11154 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11155 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11156 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11157 (push (cons article mark) gnus-newsgroup-reads)
11158 ;; Possibly remove from cache, if that is used.
11159 (when gnus-use-cache
11160 (gnus-cache-enter-remove-article article))
11161 t))
11162
11163 (defun gnus-mark-article-as-unread (article &optional mark)
11164 "Enter ARTICLE in the pertinent lists and remove it from others."
11165 (let ((mark (or mark gnus-ticked-mark)))
11166 (if (<= article 0)
11167 (progn
11168 (gnus-error 1 "Can't mark negative article numbers")
11169 nil)
11170 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11171 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11172 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11173 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11174 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11175
11176 ;; Unsuppress duplicates?
11177 (when gnus-suppress-duplicates
11178 (gnus-dup-unsuppress-article article))
11179
11180 (cond ((= mark gnus-ticked-mark)
11181 (setq gnus-newsgroup-marked
11182 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11183 ((= mark gnus-spam-mark)
11184 (setq gnus-newsgroup-spam-marked
11185 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11186 article)))
11187 ((= mark gnus-dormant-mark)
11188 (setq gnus-newsgroup-dormant
11189 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11190 (t
11191 (setq gnus-newsgroup-unreads
11192 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11193 (gnus-alist-pull article gnus-newsgroup-reads)
11194 t)))
11195
11196 (defun gnus-summary-tick-article-forward (n)
11197 "Tick N articles forwards.
11198 If N is negative, tick backwards instead.
11199 The difference between N and the number of articles ticked is returned."
11200 (interactive "p")
11201 (gnus-summary-mark-forward n gnus-ticked-mark))
11202
11203 (defun gnus-summary-tick-article-backward (n)
11204 "Tick N articles backwards.
11205 The difference between N and the number of articles ticked is returned."
11206 (interactive "p")
11207 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11208
11209 (defun gnus-summary-tick-article (&optional article clear-mark)
11210 "Mark current article as unread.
11211 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11212 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11213 (interactive)
11214 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11215 gnus-ticked-mark)))
11216
11217 (defun gnus-summary-mark-as-read-forward (n)
11218 "Mark N articles as read forwards.
11219 If N is negative, mark backwards instead.
11220 The difference between N and the actual number of articles marked is
11221 returned."
11222 (interactive "p")
11223 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11224
11225 (defun gnus-summary-mark-as-read-backward (n)
11226 "Mark the N articles as read backwards.
11227 The difference between N and the actual number of articles marked is
11228 returned."
11229 (interactive "p")
11230 (gnus-summary-mark-forward
11231 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11232
11233 (defun gnus-summary-mark-as-read (&optional article mark)
11234 "Mark current article as read.
11235 ARTICLE specifies the article to be marked as read.
11236 MARK specifies a string to be inserted at the beginning of the line."
11237 (gnus-summary-mark-article article mark))
11238
11239 (defun gnus-summary-clear-mark-forward (n)
11240 "Clear marks from N articles forward.
11241 If N is negative, clear backward instead.
11242 The difference between N and the number of marks cleared is returned."
11243 (interactive "p")
11244 (gnus-summary-mark-forward n gnus-unread-mark))
11245
11246 (defun gnus-summary-clear-mark-backward (n)
11247 "Clear marks from N articles backward.
11248 The difference between N and the number of marks cleared is returned."
11249 (interactive "p")
11250 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11251
11252 (defun gnus-summary-mark-unread-as-read ()
11253 "Intended to be used by `gnus-mark-article-hook'."
11254 (when (memq gnus-current-article gnus-newsgroup-unreads)
11255 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11256
11257 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11258 "Intended to be used by `gnus-mark-article-hook'."
11259 (let ((mark (gnus-summary-article-mark)))
11260 (when (or (gnus-unread-mark-p mark)
11261 (gnus-read-mark-p mark))
11262 (gnus-summary-mark-article gnus-current-article
11263 (or new-mark gnus-read-mark)))))
11264
11265 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11266 "Intended to be used by `gnus-mark-article-hook'."
11267 (let ((mark (gnus-summary-article-mark)))
11268 (when (or (gnus-unread-mark-p mark)
11269 (gnus-read-mark-p mark))
11270 (gnus-summary-mark-article (gnus-summary-article-number)
11271 (or new-mark gnus-read-mark)))))
11272
11273 (defun gnus-summary-mark-unread-as-ticked ()
11274 "Intended to be used by `gnus-mark-article-hook'."
11275 (when (memq gnus-current-article gnus-newsgroup-unreads)
11276 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11277
11278 (defun gnus-summary-mark-region-as-read (point mark all)
11279 "Mark all unread articles between point and mark as read.
11280 If given a prefix, mark all articles between point and mark as read,
11281 even ticked and dormant ones."
11282 (interactive "r\nP")
11283 (save-excursion
11284 (let (article)
11285 (goto-char point)
11286 (beginning-of-line)
11287 (while (and
11288 (< (point) mark)
11289 (progn
11290 (when (or all
11291 (memq (setq article (gnus-summary-article-number))
11292 gnus-newsgroup-unreads))
11293 (gnus-summary-mark-article article gnus-del-mark))
11294 t)
11295 (gnus-summary-find-next))))))
11296
11297 (defun gnus-summary-mark-below (score mark)
11298 "Mark articles with score less than SCORE with MARK."
11299 (interactive "P\ncMark: ")
11300 (setq score (if score
11301 (prefix-numeric-value score)
11302 (or gnus-summary-default-score 0)))
11303 (with-current-buffer gnus-summary-buffer
11304 (goto-char (point-min))
11305 (while
11306 (progn
11307 (and (< (gnus-summary-article-score) score)
11308 (gnus-summary-mark-article nil mark))
11309 (gnus-summary-find-next)))))
11310
11311 (defun gnus-summary-kill-below (&optional score)
11312 "Mark articles with score below SCORE as read."
11313 (interactive "P")
11314 (gnus-summary-mark-below score gnus-killed-mark))
11315
11316 (defun gnus-summary-clear-above (&optional score)
11317 "Clear all marks from articles with score above SCORE."
11318 (interactive "P")
11319 (gnus-summary-mark-above score gnus-unread-mark))
11320
11321 (defun gnus-summary-tick-above (&optional score)
11322 "Tick all articles with score above SCORE."
11323 (interactive "P")
11324 (gnus-summary-mark-above score gnus-ticked-mark))
11325
11326 (defun gnus-summary-mark-above (score mark)
11327 "Mark articles with score over SCORE with MARK."
11328 (interactive "P\ncMark: ")
11329 (setq score (if score
11330 (prefix-numeric-value score)
11331 (or gnus-summary-default-score 0)))
11332 (with-current-buffer gnus-summary-buffer
11333 (goto-char (point-min))
11334 (while (and (progn
11335 (when (> (gnus-summary-article-score) score)
11336 (gnus-summary-mark-article nil mark))
11337 t)
11338 (gnus-summary-find-next)))))
11339
11340 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11341 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11342 (defun gnus-summary-limit-include-expunged (&optional no-error)
11343 "Display all the hidden articles that were expunged for low scores."
11344 (interactive)
11345 (let ((inhibit-read-only t))
11346 (let ((scored gnus-newsgroup-scored)
11347 headers h)
11348 (while scored
11349 (unless (gnus-summary-article-header (caar scored))
11350 (and (setq h (gnus-number-to-header (caar scored)))
11351 (< (cdar scored) gnus-summary-expunge-below)
11352 (push h headers)))
11353 (setq scored (cdr scored)))
11354 (if (not headers)
11355 (when (not no-error)
11356 (error "No expunged articles hidden"))
11357 (goto-char (point-min))
11358 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11359 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11360 (dolist (x headers)
11361 (push (mail-header-number x) gnus-newsgroup-limit))
11362 (gnus-summary-prepare-unthreaded (nreverse headers))
11363 (goto-char (point-min))
11364 (gnus-summary-position-point)
11365 t))))
11366
11367 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11368 "Mark all unread articles in this newsgroup as read.
11369 If prefix argument ALL is non-nil, ticked and dormant articles will
11370 also be marked as read.
11371 If QUIETLY is non-nil, no questions will be asked.
11372
11373 If TO-HERE is non-nil, it should be a point in the buffer. All
11374 articles before (after, if REVERSE is set) this point will be marked
11375 as read.
11376
11377 Note that this function will only catch up the unread article
11378 in the current summary buffer limitation.
11379
11380 The number of articles marked as read is returned."
11381 (interactive "P")
11382 (prog1
11383 (save-excursion
11384 (when (or quietly
11385 (not gnus-interactive-catchup) ;Without confirmation?
11386 gnus-expert-user
11387 (gnus-y-or-n-p
11388 (if all
11389 "Mark absolutely all articles as read? "
11390 "Mark all unread articles as read? ")))
11391 (if (and not-mark
11392 (not gnus-newsgroup-adaptive)
11393 (not gnus-newsgroup-auto-expire)
11394 (not gnus-suppress-duplicates)
11395 (or (not gnus-use-cache)
11396 (eq gnus-use-cache 'passive)))
11397 (progn
11398 (when all
11399 (setq gnus-newsgroup-marked nil
11400 gnus-newsgroup-spam-marked nil
11401 gnus-newsgroup-dormant nil))
11402 (setq gnus-newsgroup-unreads
11403 (gnus-sorted-nunion
11404 (gnus-sorted-intersection gnus-newsgroup-unreads
11405 gnus-newsgroup-downloadable)
11406 (gnus-sorted-difference gnus-newsgroup-unfetched
11407 gnus-newsgroup-cached))))
11408 ;; We actually mark all articles as canceled, which we
11409 ;; have to do when using auto-expiry or adaptive scoring.
11410 (gnus-summary-show-all-threads)
11411 (if (and to-here reverse)
11412 (progn
11413 (goto-char to-here)
11414 (gnus-summary-mark-current-read-and-unread-as-read
11415 gnus-catchup-mark)
11416 (while (gnus-summary-find-next (not all))
11417 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11418 (when (gnus-summary-first-subject (not all))
11419 (while (and
11420 (if to-here (< (point) to-here) t)
11421 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11422 (gnus-summary-find-next (not all))))))
11423 (gnus-set-mode-line 'summary))
11424 t))
11425 (gnus-summary-position-point)))
11426
11427 (defun gnus-summary-catchup-to-here (&optional all)
11428 "Mark all unticked articles before the current one as read.
11429 If ALL is non-nil, also mark ticked and dormant articles as read."
11430 (interactive "P")
11431 (save-excursion
11432 (gnus-save-hidden-threads
11433 (let ((beg (point)))
11434 ;; We check that there are unread articles.
11435 (when (or all (gnus-summary-find-prev))
11436 (gnus-summary-catchup all t beg)))))
11437 (gnus-summary-position-point))
11438
11439 (defun gnus-summary-catchup-from-here (&optional all)
11440 "Mark all unticked articles after (and including) the current one as read.
11441 If ALL is non-nil, also mark ticked and dormant articles as read."
11442 (interactive "P")
11443 (save-excursion
11444 (gnus-save-hidden-threads
11445 (let ((beg (point)))
11446 ;; We check that there are unread articles.
11447 (when (or all (gnus-summary-find-next))
11448 (gnus-summary-catchup all t beg nil t)))))
11449 (gnus-summary-position-point))
11450
11451 (defun gnus-summary-catchup-all (&optional quietly)
11452 "Mark all articles in this newsgroup as read.
11453 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11454 instead, which marks only unread articles as read."
11455 (interactive "P")
11456 (gnus-summary-catchup t quietly))
11457
11458 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11459 "Mark all unread articles in this group as read, then exit.
11460 If prefix argument ALL is non-nil, all articles are marked as read.
11461 If QUIETLY is non-nil, no questions will be asked."
11462 (interactive "P")
11463 (when (gnus-summary-catchup all quietly nil 'fast)
11464 ;; Select next newsgroup or exit.
11465 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11466 (eq gnus-auto-select-next 'quietly))
11467 (gnus-summary-next-group nil)
11468 (gnus-summary-exit))))
11469
11470 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11471 "Mark all articles in this newsgroup as read, and then exit.
11472 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11473 instead, which marks only unread articles as read."
11474 (interactive "P")
11475 (gnus-summary-catchup-and-exit t quietly))
11476
11477 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11478 "Mark all articles in this group as read and select the next group.
11479 If given a prefix, mark all articles, unread as well as ticked, as
11480 read."
11481 (interactive "P")
11482 (save-excursion
11483 (gnus-summary-catchup all))
11484 (gnus-summary-next-group))
11485
11486 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11487 "Mark all articles in this group as read and select the previous group.
11488 If given a prefix, mark all articles, unread as well as ticked, as
11489 read."
11490 (interactive "P")
11491 (save-excursion
11492 (gnus-summary-catchup all))
11493 (gnus-summary-next-group nil nil t))
11494
11495 ;;;
11496 ;;; with article
11497 ;;;
11498
11499 (defmacro gnus-with-article (article &rest forms)
11500 "Select ARTICLE and perform FORMS in the original article buffer.
11501 Then replace the article with the result."
11502 `(progn
11503 ;; We don't want the article to be marked as read.
11504 (let (gnus-mark-article-hook)
11505 (gnus-summary-select-article t t nil ,article))
11506 (set-buffer gnus-original-article-buffer)
11507 ,@forms
11508 (if (not (gnus-check-backend-function
11509 'request-replace-article (car gnus-article-current)))
11510 (gnus-message 5 "Read-only group; not replacing")
11511 (unless (gnus-request-replace-article
11512 ,article (car gnus-article-current)
11513 (current-buffer) t)
11514 (error "Couldn't replace article")))
11515 ;; The cache and backlog have to be flushed somewhat.
11516 (when gnus-keep-backlog
11517 (gnus-backlog-remove-article
11518 (car gnus-article-current) (cdr gnus-article-current)))
11519 (when gnus-use-cache
11520 (gnus-cache-update-article
11521 (car gnus-article-current) (cdr gnus-article-current)))))
11522
11523 (put 'gnus-with-article 'lisp-indent-function 1)
11524 (put 'gnus-with-article 'edebug-form-spec '(form body))
11525
11526 ;; Thread-based commands.
11527
11528 (defun gnus-summary-articles-in-thread (&optional article)
11529 "Return a list of all articles in the current thread.
11530 If ARTICLE is non-nil, return all articles in the thread that starts
11531 with that article."
11532 (let* ((article (or article (gnus-summary-article-number)))
11533 (data (gnus-data-find-list article))
11534 (top-level (gnus-data-level (car data)))
11535 (top-subject
11536 (cond ((null gnus-thread-operation-ignore-subject)
11537 (gnus-simplify-subject-re
11538 (mail-header-subject (gnus-data-header (car data)))))
11539 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11540 (gnus-simplify-subject-fuzzy
11541 (mail-header-subject (gnus-data-header (car data)))))
11542 (t nil)))
11543 (end-point (save-excursion
11544 (goto-char (gnus-data-pos (car data)))
11545 (if (gnus-summary-go-to-next-thread)
11546 (point) (point-max))))
11547 articles)
11548 (while (and data
11549 (< (gnus-data-pos (car data)) end-point))
11550 (when (or (not top-subject)
11551 (string= top-subject
11552 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11553 (gnus-simplify-subject-fuzzy
11554 (mail-header-subject
11555 (gnus-data-header (car data))))
11556 (gnus-simplify-subject-re
11557 (mail-header-subject
11558 (gnus-data-header (car data)))))))
11559 (push (gnus-data-number (car data)) articles))
11560 (unless (and (setq data (cdr data))
11561 (> (gnus-data-level (car data)) top-level))
11562 (setq data nil)))
11563 ;; Return the list of articles.
11564 (nreverse articles)))
11565
11566 (defun gnus-summary-rethread-current ()
11567 "Rethread the thread the current article is part of."
11568 (interactive)
11569 (let* ((gnus-show-threads t)
11570 (article (gnus-summary-article-number))
11571 (id (mail-header-id (gnus-summary-article-header)))
11572 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11573 (unless id
11574 (error "No article on the current line"))
11575 (gnus-rebuild-thread id)
11576 (gnus-summary-goto-subject article)))
11577
11578 (defun gnus-summary-reparent-thread ()
11579 "Make the current article child of the marked (or previous) article.
11580
11581 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11582 is non-nil or the Subject: of both articles are the same."
11583 (interactive)
11584 (unless (not (gnus-group-read-only-p))
11585 (error "The current newsgroup does not support article editing"))
11586 (unless (<= (length gnus-newsgroup-processable) 1)
11587 (error "No more than one article may be marked"))
11588 (let ((child (gnus-summary-article-number))
11589 ;; First grab the marked article, otherwise one line up.
11590 (parent (if (not (null gnus-newsgroup-processable))
11591 (car gnus-newsgroup-processable)
11592 (save-excursion
11593 (if (eq (forward-line -1) 0)
11594 (gnus-summary-article-number)
11595 (error "Beginning of summary buffer"))))))
11596 (gnus-summary-reparent-children parent (list child))))
11597
11598 (defun gnus-summary-reparent-children (parent children)
11599 "Make PARENT the parent of CHILDREN.
11600 When called interactively, PARENT is the current article and CHILDREN
11601 are the process-marked articles."
11602 (interactive
11603 (list (gnus-summary-article-number)
11604 (gnus-summary-work-articles nil)))
11605 (dolist (child children)
11606 (save-window-excursion
11607 (let ((gnus-article-buffer " *reparent*"))
11608 (unless (not (eq parent child))
11609 (error "An article may not be self-referential"))
11610 (let ((message-id (mail-header-id
11611 (gnus-summary-article-header parent))))
11612 (unless (and message-id (not (equal message-id "")))
11613 (error "No message-id in desired parent"))
11614 (gnus-with-article child
11615 (save-restriction
11616 (goto-char (point-min))
11617 (message-narrow-to-head)
11618 (if (re-search-forward "^References: " nil t)
11619 (progn
11620 (re-search-forward "^[^ \t]" nil t)
11621 (forward-line -1)
11622 (end-of-line)
11623 (insert " " message-id))
11624 (insert "References: " message-id "\n"))))
11625 (set-buffer gnus-summary-buffer)
11626 (gnus-summary-unmark-all-processable)
11627 (gnus-summary-update-article child)
11628 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11629 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11630 (gnus-summary-rethread-current)
11631 (gnus-message 3 "Article %d is now the child of article %d"
11632 child parent))))))
11633
11634 (defun gnus-summary-toggle-threads (&optional arg)
11635 "Toggle showing conversation threads.
11636 If ARG is positive number, turn showing conversation threads on."
11637 (interactive "P")
11638 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11639 (setq gnus-show-threads
11640 (if (null arg) (not gnus-show-threads)
11641 (> (prefix-numeric-value arg) 0)))
11642 (gnus-summary-prepare)
11643 (gnus-summary-goto-subject current)
11644 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11645 (gnus-summary-position-point)))
11646
11647 (defun gnus-summary-show-all-threads ()
11648 "Show all threads."
11649 (interactive)
11650 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11651 (gnus-summary-position-point))
11652
11653 (defsubst gnus-summary--inv (p)
11654 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11655
11656 (defun gnus-summary-show-thread ()
11657 "Show thread subtrees.
11658 Returns nil if no thread was there to be shown."
11659 (interactive)
11660 (let* ((orig (point))
11661 (end (point-at-eol))
11662 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11663 ;; Leave point at bol
11664 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11665 (eoi (and end (next-single-char-property-change end 'invisible))))
11666 (when eoi
11667 (remove-overlays beg eoi 'invisible 'gnus-sum)
11668 (goto-char orig)
11669 (gnus-summary-position-point)
11670 eoi)))
11671
11672 (defun gnus-summary-maybe-hide-threads ()
11673 "If requested, hide the threads that should be hidden."
11674 (when (and gnus-show-threads
11675 gnus-thread-hide-subtree)
11676 (gnus-summary-hide-all-threads
11677 (if (or (consp gnus-thread-hide-subtree)
11678 (functionp gnus-thread-hide-subtree))
11679 (gnus-make-predicate gnus-thread-hide-subtree)
11680 nil))))
11681
11682 ;;; Hiding predicates.
11683
11684 (defun gnus-article-unread-p (header)
11685 (memq (mail-header-number header) gnus-newsgroup-unreads))
11686
11687 (defun gnus-article-unseen-p (header)
11688 (memq (mail-header-number header) gnus-newsgroup-unseen))
11689
11690 (defun gnus-map-articles (predicate articles)
11691 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11692 (apply 'gnus-or (mapcar predicate
11693 (mapcar (lambda (number)
11694 (gnus-summary-article-header number))
11695 articles))))
11696
11697 (defun gnus-summary-hide-all-threads (&optional predicate)
11698 "Hide all thread subtrees.
11699 If PREDICATE is supplied, threads that satisfy this predicate
11700 will not be hidden."
11701 (interactive)
11702 (save-excursion
11703 (goto-char (point-min))
11704 (let ((end nil)
11705 (count 0))
11706 (while (not end)
11707 (incf count)
11708 (when (zerop (mod count 1000))
11709 (message "Hiding all threads... %d" count))
11710 (when (or (not predicate)
11711 (gnus-map-articles
11712 predicate (gnus-summary-article-children)))
11713 (gnus-summary-hide-thread))
11714 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11715 (gnus-summary-position-point))
11716
11717 (defun gnus-summary-hide-thread ()
11718 "Hide thread subtrees.
11719 If PREDICATE is supplied, threads that satisfy this predicate
11720 will not be hidden.
11721 Returns nil if no threads were there to be hidden."
11722 (interactive)
11723 (beginning-of-line)
11724 (let ((start (point))
11725 (starteol (line-end-position))
11726 (article (gnus-summary-article-number)))
11727 ;; Go forward until either the buffer ends or the subthread ends.
11728 (when (and (not (eobp))
11729 (or (zerop (gnus-summary-next-thread 1 t))
11730 (goto-char (point-max))))
11731 (if (and (> (point) start)
11732 ;; FIXME: this should actually search for a non-invisible \n.
11733 (search-backward "\n" start t))
11734 (progn
11735 (when (> (point) starteol)
11736 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11737 (let ((ol (make-overlay starteol (point) nil t nil)))
11738 (overlay-put ol 'invisible 'gnus-sum)
11739 (overlay-put ol 'evaporate t)))
11740 (gnus-summary-goto-subject article)
11741 (when (> start (point))
11742 (message "Hiding the thread moved us backwards, aborting!")
11743 (goto-char (point-max))))
11744 (goto-char start)
11745 nil))))
11746
11747 (defun gnus-summary-go-to-next-thread (&optional previous)
11748 "Go to the same level (or less) next thread.
11749 If PREVIOUS is non-nil, go to previous thread instead.
11750 Return the article number moved to, or nil if moving was impossible."
11751 (let ((level (gnus-summary-thread-level))
11752 (way (if previous -1 1))
11753 (beg (point)))
11754 (forward-line way)
11755 (while (and (not (eobp))
11756 (< level (gnus-summary-thread-level)))
11757 (forward-line way))
11758 (if (eobp)
11759 (progn
11760 (goto-char beg)
11761 nil)
11762 (setq beg (point))
11763 (prog1
11764 (gnus-summary-article-number)
11765 (goto-char beg)))))
11766
11767 (defun gnus-summary-next-thread (n &optional silent)
11768 "Go to the same level next N'th thread.
11769 If N is negative, search backward instead.
11770 Returns the difference between N and the number of skips actually
11771 done.
11772
11773 If SILENT, don't output messages."
11774 (interactive "p")
11775 (let ((backward (< n 0))
11776 (n (abs n)))
11777 (while (and (> n 0)
11778 (gnus-summary-go-to-next-thread backward))
11779 (decf n))
11780 (unless silent
11781 (gnus-summary-position-point))
11782 (when (and (not silent) (/= 0 n))
11783 (gnus-message 7 "No more threads"))
11784 n))
11785
11786 (defun gnus-summary-prev-thread (n)
11787 "Go to the same level previous N'th thread.
11788 Returns the difference between N and the number of skips actually
11789 done."
11790 (interactive "p")
11791 (gnus-summary-next-thread (- n)))
11792
11793 (defun gnus-summary-go-down-thread ()
11794 "Go down one level in the current thread."
11795 (let ((children (gnus-summary-article-children)))
11796 (when children
11797 (gnus-summary-goto-subject (car children)))))
11798
11799 (defun gnus-summary-go-up-thread ()
11800 "Go up one level in the current thread."
11801 (let ((parent (gnus-summary-article-parent)))
11802 (when parent
11803 (gnus-summary-goto-subject parent))))
11804
11805 (defun gnus-summary-down-thread (n)
11806 "Go down thread N steps.
11807 If N is negative, go up instead.
11808 Returns the difference between N and how many steps down that were
11809 taken."
11810 (interactive "p")
11811 (let ((up (< n 0))
11812 (n (abs n)))
11813 (while (and (> n 0)
11814 (if up (gnus-summary-go-up-thread)
11815 (gnus-summary-go-down-thread)))
11816 (setq n (1- n)))
11817 (gnus-summary-position-point)
11818 (when (/= 0 n)
11819 (gnus-message 7 "Can't go further"))
11820 n))
11821
11822 (defun gnus-summary-up-thread (n)
11823 "Go up thread N steps.
11824 If N is negative, go down instead.
11825 Returns the difference between N and how many steps down that were
11826 taken."
11827 (interactive "p")
11828 (gnus-summary-down-thread (- n)))
11829
11830 (defun gnus-summary-top-thread ()
11831 "Go to the top of the thread."
11832 (interactive)
11833 (while (gnus-summary-go-up-thread))
11834 (gnus-summary-article-number))
11835
11836 (defun gnus-summary-expire-thread ()
11837 "Mark articles under current thread as expired."
11838 (interactive)
11839 (gnus-summary-kill-thread 0))
11840
11841 (defun gnus-summary-kill-thread (&optional unmark)
11842 "Mark articles under current thread as read.
11843 If the prefix argument is positive, remove any kinds of marks.
11844 If the prefix argument is zero, mark thread as expired.
11845 If the prefix argument is negative, tick articles instead."
11846 (interactive "P")
11847 (when unmark
11848 (setq unmark (prefix-numeric-value unmark)))
11849 (let ((articles (gnus-summary-articles-in-thread))
11850 (hide (or (null unmark) (= unmark 0))))
11851 (save-excursion
11852 ;; Expand the thread.
11853 (gnus-summary-show-thread)
11854 ;; Mark all the articles.
11855 (while articles
11856 (gnus-summary-goto-subject (car articles))
11857 (cond ((null unmark)
11858 (gnus-summary-mark-article-as-read gnus-killed-mark))
11859 ((> unmark 0)
11860 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11861 ((= unmark 0)
11862 (gnus-summary-mark-article nil gnus-expirable-mark))
11863 (t
11864 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11865 (setq articles (cdr articles))))
11866 ;; Hide killed subtrees when hide is true.
11867 (and hide
11868 gnus-thread-hide-killed
11869 (gnus-summary-hide-thread))
11870 ;; If hide is t, go to next unread subject.
11871 (when hide
11872 ;; Go to next unread subject.
11873 (gnus-summary-next-subject 1 t)))
11874 (gnus-set-mode-line 'summary))
11875
11876 ;; Summary sorting commands
11877
11878 (defun gnus-summary-sort-by-number (&optional reverse)
11879 "Sort the summary buffer by article number.
11880 Argument REVERSE means reverse order."
11881 (interactive "P")
11882 (gnus-summary-sort 'number reverse))
11883
11884 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11885 "Sort the summary buffer by most recent article number.
11886 Argument REVERSE means reverse order."
11887 (interactive "P")
11888 (gnus-summary-sort 'most-recent-number reverse))
11889
11890 (defun gnus-summary-sort-by-random (&optional reverse)
11891 "Randomize the order in the summary buffer.
11892 Argument REVERSE means to randomize in reverse order."
11893 (interactive "P")
11894 (gnus-summary-sort 'random reverse))
11895
11896 (defun gnus-summary-sort-by-author (&optional reverse)
11897 "Sort the summary buffer by author name alphabetically.
11898 If `case-fold-search' is non-nil, case of letters is ignored.
11899 Argument REVERSE means reverse order."
11900 (interactive "P")
11901 (gnus-summary-sort 'author reverse))
11902
11903 (defun gnus-summary-sort-by-recipient (&optional reverse)
11904 "Sort the summary buffer by recipient name alphabetically.
11905 If `case-fold-search' is non-nil, case of letters is ignored.
11906 Argument REVERSE means reverse order."
11907 (interactive "P")
11908 (gnus-summary-sort 'recipient reverse))
11909
11910 (defun gnus-summary-sort-by-subject (&optional reverse)
11911 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11912 If `case-fold-search' is non-nil, case of letters is ignored.
11913 Argument REVERSE means reverse order."
11914 (interactive "P")
11915 (gnus-summary-sort 'subject reverse))
11916
11917 (defun gnus-summary-sort-by-date (&optional reverse)
11918 "Sort the summary buffer by date.
11919 Argument REVERSE means reverse order."
11920 (interactive "P")
11921 (gnus-summary-sort 'date reverse))
11922
11923 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11924 "Sort the summary buffer by most recent date.
11925 Argument REVERSE means reverse order."
11926 (interactive "P")
11927 (gnus-summary-sort 'most-recent-date reverse))
11928
11929 (defun gnus-summary-sort-by-score (&optional reverse)
11930 "Sort the summary buffer by score.
11931 Argument REVERSE means reverse order."
11932 (interactive "P")
11933 (gnus-summary-sort 'score reverse))
11934
11935 (defun gnus-summary-sort-by-lines (&optional reverse)
11936 "Sort the summary buffer by the number of lines.
11937 Argument REVERSE means reverse order."
11938 (interactive "P")
11939 (gnus-summary-sort 'lines reverse))
11940
11941 (defun gnus-summary-sort-by-chars (&optional reverse)
11942 "Sort the summary buffer by article length.
11943 Argument REVERSE means reverse order."
11944 (interactive "P")
11945 (gnus-summary-sort 'chars reverse))
11946
11947 (defun gnus-summary-sort-by-original (&optional reverse)
11948 "Sort the summary buffer using the default sorting method.
11949 Argument REVERSE means reverse order."
11950 (interactive "P")
11951 (let* ((inhibit-read-only t)
11952 (gnus-summary-prepare-hook nil))
11953 ;; We do the sorting by regenerating the threads.
11954 (gnus-summary-prepare)
11955 ;; Hide subthreads if needed.
11956 (gnus-summary-maybe-hide-threads)))
11957
11958 (defun gnus-summary-sort (predicate reverse)
11959 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11960 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11961 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11962 (gnus-thread-sort-functions
11963 (if (not reverse)
11964 thread
11965 `(lambda (t1 t2)
11966 (,thread t2 t1))))
11967 (gnus-sort-gathered-threads-function
11968 gnus-thread-sort-functions)
11969 (gnus-article-sort-functions
11970 (if (not reverse)
11971 article
11972 `(lambda (t1 t2)
11973 (,article t2 t1))))
11974 (inhibit-read-only t)
11975 (gnus-summary-prepare-hook nil))
11976 ;; We do the sorting by regenerating the threads.
11977 (gnus-summary-prepare)
11978 ;; Hide subthreads if needed.
11979 (gnus-summary-maybe-hide-threads)))
11980
11981 ;; Summary saving commands.
11982
11983 (defun gnus-summary-save-article (&optional n not-saved)
11984 "Save the current article using the default saver function.
11985 If N is a positive number, save the N next articles.
11986 If N is a negative number, save the N previous articles.
11987 If N is nil and any articles have been marked with the process mark,
11988 save those articles instead.
11989 The variable `gnus-default-article-saver' specifies the saver function.
11990
11991 If the optional second argument NOT-SAVED is non-nil, articles saved
11992 will not be marked as saved."
11993 (interactive "P")
11994 (require 'gnus-art)
11995 (let* ((articles (gnus-summary-work-articles n))
11996 (save-buffer (save-excursion
11997 (nnheader-set-temp-buffer " *Gnus Save*")))
11998 (num (length articles))
11999 ;; Whether to save decoded articles or raw articles.
12000 (decode (when gnus-article-save-coding-system
12001 (get gnus-default-article-saver :decode)))
12002 ;; When saving many articles in a single file, use the other
12003 ;; function to save articles other than the first one.
12004 (saver2 (get gnus-default-article-saver :function))
12005 (gnus-prompt-before-saving (if saver2
12006 t
12007 gnus-prompt-before-saving))
12008 (gnus-default-article-saver gnus-default-article-saver)
12009 header file)
12010 (dolist (article articles)
12011 (setq header (gnus-summary-article-header article))
12012 (if (not (vectorp header))
12013 ;; This is a pseudo-article.
12014 (if (assq 'name header)
12015 (gnus-copy-file (cdr (assq 'name header)))
12016 (gnus-message 1 "Article %d is unsavable" article))
12017 ;; This is a real article.
12018 (save-window-excursion
12019 (gnus-summary-select-article decode decode nil article)
12020 (gnus-summary-goto-subject article))
12021 (with-current-buffer save-buffer
12022 (erase-buffer)
12023 (insert-buffer-substring (if decode
12024 gnus-article-buffer
12025 gnus-original-article-buffer)))
12026 (setq file (gnus-article-save save-buffer file num))
12027 (gnus-summary-remove-process-mark article)
12028 (unless not-saved
12029 (gnus-summary-set-saved-mark article)))
12030 (when saver2
12031 (setq gnus-default-article-saver saver2
12032 saver2 nil)))
12033 (gnus-kill-buffer save-buffer)
12034 (gnus-summary-position-point)
12035 (gnus-set-mode-line 'summary)
12036 n))
12037
12038 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12039
12040 (defun gnus-summary-pipe-output (&optional n sym)
12041 "Pipe the current article to a subprocess.
12042 If N is a positive number, pipe the N next articles.
12043 If N is a negative number, pipe the N previous articles.
12044 If N is nil and any articles have been marked with the process mark,
12045 pipe those articles instead.
12046 The default command to which articles are piped is specified by the
12047 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12048 will be prompted for the command.
12049
12050 The properties `:decode' and `:headers' that are put to the function
12051 symbol `gnus-summary-save-in-pipe' control whether this function
12052 decodes articles and what headers to keep (see the doc string for the
12053 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12054 is neither omitted nor the symbol `r', force including all headers
12055 regardless of the `:headers' property. If it is the symbol `r',
12056 articles that are not decoded and include all headers will be piped
12057 no matter what the properties `:decode' and `:headers' are."
12058 (interactive (gnus-interactive "P\ny"))
12059 (require 'gnus-art)
12060 (let* ((articles (gnus-summary-work-articles n))
12061 (result-buffer "*Shell Command Output*")
12062 (all-headers (not (memq sym '(nil r))))
12063 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12064 (raw (eq sym 'r))
12065 (headers (get 'gnus-summary-save-in-pipe :headers))
12066 command result)
12067 (unless (numberp (car articles))
12068 (error "No article to pipe"))
12069 (setq command (read-shell-command
12070 (concat "Shell command on "
12071 (if (cdr articles)
12072 (format "these %d articles" (length articles))
12073 "this article")
12074 ": ")
12075 gnus-summary-pipe-output-default-command))
12076 (when (string-equal command "")
12077 (error "A command is required"))
12078 (when all-headers
12079 (put 'gnus-summary-save-in-pipe :headers nil))
12080 (unwind-protect
12081 (while articles
12082 (gnus-summary-goto-subject (pop articles))
12083 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12084 (when (and (get-buffer result-buffer)
12085 (not (zerop (buffer-size (get-buffer result-buffer)))))
12086 (setq result (concat result (with-current-buffer result-buffer
12087 (buffer-string))))))
12088 (put 'gnus-summary-save-in-pipe :headers headers))
12089 (unless (zerop (length result))
12090 (if (with-current-buffer (get-buffer-create result-buffer)
12091 (erase-buffer)
12092 (insert result)
12093 (prog1
12094 (and (= (count-lines (point-min) (point)) 1)
12095 (progn
12096 (end-of-line 0)
12097 (<= (current-column)
12098 (window-width (minibuffer-window)))))
12099 (goto-char (point-min))))
12100 (message "%s" (substring result 0 -1))
12101 (message nil)
12102 (gnus-configure-windows 'pipe)))))
12103
12104 (defun gnus-summary-save-article-mail (&optional arg)
12105 "Append the current article to a Unix mail box file.
12106 If N is a positive number, save the N next articles.
12107 If N is a negative number, save the N previous articles.
12108 If N is nil and any articles have been marked with the process mark,
12109 save those articles instead."
12110 (interactive "P")
12111 (require 'gnus-art)
12112 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12113 (gnus-summary-save-article arg)))
12114
12115 (defun gnus-summary-save-article-rmail (&optional arg)
12116 "Append the current article to an rmail file.
12117 If N is a positive number, save the N next articles.
12118 If N is a negative number, save the N previous articles.
12119 If N is nil and any articles have been marked with the process mark,
12120 save those articles instead."
12121 (interactive "P")
12122 (require 'gnus-art)
12123 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12124 (gnus-summary-save-article arg)))
12125
12126 (defun gnus-summary-save-article-file (&optional arg)
12127 "Append the current article to a file.
12128 If N is a positive number, save the N next articles.
12129 If N is a negative number, save the N previous articles.
12130 If N is nil and any articles have been marked with the process mark,
12131 save those articles instead."
12132 (interactive "P")
12133 (require 'gnus-art)
12134 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12135 (gnus-summary-save-article arg)))
12136
12137 (defun gnus-summary-write-article-file (&optional arg)
12138 "Write the current article to a file, deleting the previous file.
12139 If N is a positive number, save the N next articles.
12140 If N is a negative number, save the N previous articles.
12141 If N is nil and any articles have been marked with the process mark,
12142 save those articles instead."
12143 (interactive "P")
12144 (require 'gnus-art)
12145 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12146 (gnus-summary-save-article arg)))
12147
12148 (defun gnus-summary-save-article-body-file (&optional arg)
12149 "Append the current article body to a file.
12150 If N is a positive number, save the N next articles.
12151 If N is a negative number, save the N previous articles.
12152 If N is nil and any articles have been marked with the process mark,
12153 save those articles instead."
12154 (interactive "P")
12155 (require 'gnus-art)
12156 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12157 (gnus-summary-save-article arg)))
12158
12159 (defun gnus-summary-write-article-body-file (&optional arg)
12160 "Write the current article body to a file, deleting the previous file.
12161 If N is a positive number, save the N next articles.
12162 If N is a negative number, save the N previous articles.
12163 If N is nil and any articles have been marked with the process mark,
12164 save those articles instead."
12165 (interactive "P")
12166 (require 'gnus-art)
12167 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12168 (gnus-summary-save-article arg)))
12169
12170 (defun gnus-summary-muttprint (&optional arg)
12171 "Print the current article using Muttprint.
12172 If N is a positive number, save the N next articles.
12173 If N is a negative number, save the N previous articles.
12174 If N is nil and any articles have been marked with the process mark,
12175 save those articles instead."
12176 (interactive "P")
12177 (require 'gnus-art)
12178 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12179 (gnus-summary-save-article arg t)))
12180
12181 (defun gnus-summary-pipe-message (program)
12182 "Pipe the current article through PROGRAM."
12183 (interactive "sProgram: ")
12184 (gnus-summary-select-article)
12185 (let ((mail-header-separator ""))
12186 (gnus-eval-in-buffer-window gnus-article-buffer
12187 (save-restriction
12188 (widen)
12189 (let ((start (window-start))
12190 (inhibit-read-only t))
12191 (message-pipe-buffer-body program)
12192 (set-window-start (get-buffer-window (current-buffer)) start))))))
12193
12194 (defun gnus-get-split-value (methods)
12195 "Return a value based on the split METHODS."
12196 (let (split-name method result match)
12197 (when methods
12198 (with-current-buffer gnus-original-article-buffer
12199 (save-restriction
12200 (nnheader-narrow-to-headers)
12201 (while (and methods (not split-name))
12202 (goto-char (point-min))
12203 (setq method (pop methods))
12204 (setq match (car method))
12205 (when (cond
12206 ((stringp match)
12207 ;; Regular expression.
12208 (ignore-errors
12209 (re-search-forward match nil t)))
12210 ((functionp match)
12211 ;; Function.
12212 (save-restriction
12213 (widen)
12214 (setq result (funcall match gnus-newsgroup-name))))
12215 ((consp match)
12216 ;; Form.
12217 (save-restriction
12218 (widen)
12219 (setq result (eval match)))))
12220 (setq split-name (cdr method))
12221 (cond ((stringp result)
12222 (push (expand-file-name
12223 result gnus-article-save-directory)
12224 split-name))
12225 ((consp result)
12226 (setq split-name (append result split-name)))))))))
12227 (nreverse split-name)))
12228
12229 (defun gnus-valid-move-group-p (group)
12230 (and (symbolp group)
12231 (boundp group)
12232 (symbol-name group)
12233 (symbol-value group)
12234 (gnus-get-function (gnus-find-method-for-group
12235 (symbol-name group)) 'request-accept-article t)))
12236
12237 (defun gnus-read-move-group-name (prompt default articles prefix)
12238 "Read a group name."
12239 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12240 (prom
12241 (format "%s %s to"
12242 prompt
12243 (if (> (length articles) 1)
12244 (format "these %d articles" (length articles))
12245 "this article")))
12246 (to-newsgroup
12247 (cond
12248 ((null split-name)
12249 (gnus-group-completing-read
12250 prom
12251 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12252 nil prefix nil default))
12253 ((= 1 (length split-name))
12254 (gnus-group-completing-read
12255 prom
12256 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12257 nil prefix 'gnus-group-history (car split-name)))
12258 (t
12259 (gnus-completing-read
12260 prom (nreverse split-name) nil nil 'gnus-group-history))))
12261 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12262 encoded)
12263 (when to-newsgroup
12264 (if (or (string= to-newsgroup "")
12265 (string= to-newsgroup prefix))
12266 (setq to-newsgroup default))
12267 (unless to-newsgroup
12268 (error "No group name entered"))
12269 (setq encoded (encode-coding-string
12270 to-newsgroup
12271 (gnus-group-name-charset to-method to-newsgroup)))
12272 (or (gnus-active encoded)
12273 (gnus-activate-group encoded nil nil to-method)
12274 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12275 to-newsgroup))
12276 (or (and (gnus-request-create-group encoded to-method)
12277 (gnus-activate-group encoded nil nil to-method)
12278 (gnus-subscribe-group encoded))
12279 (error "Couldn't create group %s" to-newsgroup)))
12280 (error "No such group: %s" to-newsgroup))
12281 encoded)))
12282
12283 (defvar gnus-summary-save-parts-counter)
12284 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12285
12286 (defun gnus-summary-save-parts (type dir n &optional reverse)
12287 "Save parts matching TYPE to DIR.
12288 If REVERSE, save parts that do not match TYPE."
12289 (interactive
12290 (list (read-string "Save parts of type: "
12291 (or (car gnus-summary-save-parts-type-history)
12292 gnus-summary-save-parts-default-mime)
12293 'gnus-summary-save-parts-type-history)
12294 (setq gnus-summary-save-parts-last-directory
12295 (read-directory-name "Save to directory: "
12296 gnus-summary-save-parts-last-directory
12297 nil t))
12298 current-prefix-arg))
12299 (gnus-summary-iterate n
12300 (let ((gnus-display-mime-function nil)
12301 gnus-article-prepare-hook
12302 gnus-article-decode-hook
12303 gnus-display-mime-function
12304 gnus-break-pages
12305 (gnus-inhibit-treatment t))
12306 (gnus-summary-select-article))
12307 (with-current-buffer gnus-article-buffer
12308 (let ((handles (or gnus-article-mime-handles
12309 (mm-dissect-buffer nil gnus-article-loose-mime)
12310 (and gnus-article-emulate-mime
12311 (mm-uu-dissect))))
12312 (gnus-summary-save-parts-counter 1))
12313 (when handles
12314 (gnus-summary-save-parts-1 type dir handles reverse)
12315 (unless gnus-article-mime-handles ;; Don't destroy this case.
12316 (mm-destroy-parts handles)))))))
12317
12318 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12319 (if (stringp (car handle))
12320 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12321 (cdr handle))
12322 (when (if reverse
12323 (not (string-match type (mm-handle-media-type handle)))
12324 (string-match type (mm-handle-media-type handle)))
12325 (let ((file (expand-file-name
12326 (gnus-map-function
12327 mm-file-name-rewrite-functions
12328 (file-name-nondirectory
12329 (or
12330 (mm-handle-filename handle)
12331 (format "%s.%d.%d" gnus-newsgroup-name
12332 (cdr gnus-article-current)
12333 gnus-summary-save-parts-counter))))
12334 dir)))
12335 (incf gnus-summary-save-parts-counter)
12336 (unless (file-exists-p file)
12337 (mm-save-part-to-file handle file))))))
12338
12339 ;; Summary extract commands
12340
12341 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12342 (let ((inhibit-read-only t)
12343 (article (gnus-summary-article-number))
12344 after-article b e)
12345 (unless (gnus-summary-goto-subject article)
12346 (error "No such article: %d" article))
12347 (gnus-summary-position-point)
12348 ;; If all commands are to be bunched up on one line, we collect
12349 ;; them here.
12350 (unless gnus-view-pseudos-separately
12351 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12352 files action)
12353 (while ps
12354 (setq action (cdr (assq 'action (car ps))))
12355 (setq files (list (cdr (assq 'name (car ps)))))
12356 (while (and ps (cdr ps)
12357 (string= (or action "1")
12358 (or (cdr (assq 'action (cadr ps))) "2")))
12359 (push (cdr (assq 'name (cadr ps))) files)
12360 (setcdr ps (cddr ps)))
12361 (when files
12362 (when (not (string-match "%s" action))
12363 (push " " files))
12364 (push " " files)
12365 (when (assq 'execute (car ps))
12366 (setcdr (assq 'execute (car ps))
12367 (funcall (if (string-match "%s" action)
12368 'format 'concat)
12369 action
12370 (mapconcat
12371 (lambda (f)
12372 (if (equal f " ")
12373 f
12374 (shell-quote-argument f)))
12375 files " ")))))
12376 (setq ps (cdr ps)))))
12377 (if (and gnus-view-pseudos (not not-view))
12378 (while pslist
12379 (when (assq 'execute (car pslist))
12380 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12381 (eq gnus-view-pseudos 'not-confirm)))
12382 (setq pslist (cdr pslist)))
12383 (save-excursion
12384 (while pslist
12385 (setq after-article (or (cdr (assq 'article (car pslist)))
12386 (gnus-summary-article-number)))
12387 (gnus-summary-goto-subject after-article)
12388 (forward-line 1)
12389 (setq b (point))
12390 (insert " " (file-name-nondirectory
12391 (cdr (assq 'name (car pslist))))
12392 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12393 (setq e (point))
12394 (forward-line -1) ; back to `b'
12395 (add-text-properties
12396 b (1- e) (list 'gnus-number gnus-reffed-article-number
12397 'mouse-face gnus-mouse-face))
12398 (gnus-data-enter
12399 after-article gnus-reffed-article-number
12400 gnus-unread-mark b (car pslist) 0 (- e b))
12401 (setq gnus-newsgroup-unreads
12402 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12403 gnus-reffed-article-number))
12404 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12405 (setq pslist (cdr pslist)))))))
12406
12407 (defun gnus-pseudos< (p1 p2)
12408 (let ((c1 (cdr (assq 'action p1)))
12409 (c2 (cdr (assq 'action p2))))
12410 (and c1 c2 (string< c1 c2))))
12411
12412 (defun gnus-request-pseudo-article (props)
12413 (cond ((assq 'execute props)
12414 (gnus-execute-command (cdr (assq 'execute props)))))
12415 (let ((gnus-current-article (gnus-summary-article-number)))
12416 (gnus-run-hooks 'gnus-mark-article-hook)))
12417
12418 (defun gnus-execute-command (command &optional automatic)
12419 (save-excursion
12420 (gnus-article-setup-buffer)
12421 (set-buffer gnus-article-buffer)
12422 (setq buffer-read-only nil)
12423 (let ((command (if automatic command
12424 (read-string "Command: " (cons command 0)))))
12425 (erase-buffer)
12426 (insert "$ " command "\n\n")
12427 (if gnus-view-pseudo-asynchronously
12428 (start-process "gnus-execute" (current-buffer) shell-file-name
12429 shell-command-switch command)
12430 (call-process shell-file-name nil t nil
12431 shell-command-switch command)))))
12432
12433 ;; Summary kill commands.
12434
12435 (defun gnus-summary-edit-global-kill (article)
12436 "Edit the \"global\" kill file."
12437 (interactive (list (gnus-summary-article-number)))
12438 (gnus-group-edit-global-kill article))
12439
12440 (defun gnus-summary-edit-local-kill ()
12441 "Edit a local kill file applied to the current newsgroup."
12442 (interactive)
12443 (setq gnus-current-headers (gnus-summary-article-header))
12444 (gnus-group-edit-local-kill
12445 (gnus-summary-article-number) gnus-newsgroup-name))
12446
12447 ;;; Header reading.
12448
12449 (defun gnus-read-header (id &optional header)
12450 "Read the headers of article ID and enter them into the Gnus system."
12451 (let ((group gnus-newsgroup-name)
12452 (gnus-override-method
12453 (or
12454 gnus-override-method
12455 (and (gnus-news-group-p gnus-newsgroup-name)
12456 (car (gnus-refer-article-methods)))))
12457 where)
12458 ;; First we check to see whether the header in question is already
12459 ;; fetched.
12460 (if (stringp id)
12461 ;; This is a Message-ID.
12462 (setq header (or header (gnus-id-to-header id)))
12463 ;; This is an article number.
12464 (setq header (or header (gnus-summary-article-header id))))
12465 (if (and header
12466 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12467 ;; We have found the header.
12468 header
12469 ;; We have to really fetch the header to this article.
12470 (with-current-buffer nntp-server-buffer
12471 (when (setq where (gnus-request-head id group))
12472 (nnheader-fold-continuation-lines)
12473 (goto-char (point-max))
12474 (insert ".\n")
12475 (goto-char (point-min))
12476 (insert "211 ")
12477 (princ (cond
12478 ((numberp id) id)
12479 ((cdr where) (cdr where))
12480 (header (mail-header-number header))
12481 (t gnus-reffed-article-number))
12482 (current-buffer))
12483 (insert " Article retrieved.\n"))
12484 (if (or (not where)
12485 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12486 () ; Malformed head.
12487 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12488 (when (and (bound-and-true-p gnus-registry-enabled)
12489 (not (gnus-ephemeral-group-p (car where))))
12490 (gnus-registry-handle-action
12491 (mail-header-id header) nil
12492 (gnus-group-prefixed-name
12493 (car where)
12494 (or gnus-override-method (gnus-find-method-for-group group)))
12495 (mail-header-subject header)
12496 (mail-header-from header)))
12497 (when (and (stringp id)
12498 (or
12499 (not (string= (gnus-group-real-name group)
12500 (car where)))
12501 (not (gnus-server-equal gnus-override-method
12502 (gnus-group-method group)))))
12503 ;; If we fetched by Message-ID and the article came from
12504 ;; a different group (or server), we fudge some bogus
12505 ;; article numbers for this article.
12506 (mail-header-set-number header gnus-reffed-article-number))
12507 (with-current-buffer gnus-summary-buffer
12508 (decf gnus-reffed-article-number)
12509 (gnus-remove-header (mail-header-number header))
12510 (push header gnus-newsgroup-headers)
12511 (setq gnus-current-headers header)
12512 (push (mail-header-number header) gnus-newsgroup-limit)))
12513 header)))))
12514
12515 (defun gnus-remove-header (number)
12516 "Remove header NUMBER from `gnus-newsgroup-headers'."
12517 (if (and gnus-newsgroup-headers
12518 (= number (mail-header-number (car gnus-newsgroup-headers))))
12519 (pop gnus-newsgroup-headers)
12520 (let ((headers gnus-newsgroup-headers))
12521 (while (and (cdr headers)
12522 (not (= number (mail-header-number (cadr headers)))))
12523 (pop headers))
12524 (when (cdr headers)
12525 (setcdr headers (cddr headers))))))
12526
12527 ;;;
12528 ;;; summary highlights
12529 ;;;
12530
12531 (defun gnus-highlight-selected-summary ()
12532 "Highlight selected article in summary buffer."
12533 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12534 (when gnus-summary-selected-face
12535 (save-excursion
12536 (let* ((beg (point-at-bol))
12537 (end (point-at-eol))
12538 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12539 (from (if (get-text-property beg 'mouse-face)
12540 beg
12541 (or (next-single-property-change
12542 beg 'mouse-face nil end)
12543 beg)))
12544 (to
12545 (if (= from end)
12546 (- from 2)
12547 (or (next-single-property-change
12548 from 'mouse-face nil end)
12549 end))))
12550 ;; If no mouse-face prop on line we will have to = from = end,
12551 ;; so we highlight the entire line instead.
12552 (when (= (+ to 2) from)
12553 (setq from beg)
12554 (setq to end))
12555 (if gnus-newsgroup-selected-overlay
12556 ;; Move old overlay.
12557 (move-overlay
12558 gnus-newsgroup-selected-overlay from to (current-buffer))
12559 ;; Create new overlay.
12560 (overlay-put
12561 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12562 'face gnus-summary-selected-face))))))
12563
12564 (defvar gnus-summary-highlight-line-cached nil)
12565 (defvar gnus-summary-highlight-line-trigger nil)
12566
12567 (defun gnus-summary-highlight-line-0 ()
12568 (if (and (eq gnus-summary-highlight-line-trigger
12569 gnus-summary-highlight)
12570 gnus-summary-highlight-line-cached)
12571 gnus-summary-highlight-line-cached
12572 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12573 gnus-summary-highlight-line-cached
12574 (let* ((cond (list 'cond))
12575 (c cond)
12576 (list gnus-summary-highlight))
12577 (while list
12578 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12579 nil))
12580 (setq c (cdr c)
12581 list (cdr list)))
12582 (gnus-byte-compile (list 'lambda nil cond))))))
12583
12584 (defun gnus-summary-highlight-line ()
12585 "Highlight current line according to `gnus-summary-highlight'."
12586 (let* ((beg (point-at-bol))
12587 (article (or (gnus-summary-article-number) gnus-current-article))
12588 (score (or (cdr (assq article
12589 gnus-newsgroup-scored))
12590 gnus-summary-default-score 0))
12591 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12592 (inhibit-read-only t)
12593 (default gnus-summary-default-score)
12594 (default-high gnus-summary-default-high-score)
12595 (default-low gnus-summary-default-low-score)
12596 (uncached (and gnus-summary-use-undownloaded-faces
12597 (memq article gnus-newsgroup-undownloaded)
12598 (not (memq article gnus-newsgroup-cached)))))
12599 (let ((face (funcall (gnus-summary-highlight-line-0))))
12600 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12601 (gnus-put-text-property-excluding-characters-with-faces
12602 beg (point-at-eol) 'face
12603 (setq face (if (boundp face) (symbol-value face) face)))
12604 (when gnus-summary-highlight-line-function
12605 (funcall gnus-summary-highlight-line-function article face))))))
12606
12607 (defun gnus-update-read-articles (group unread &optional compute)
12608 "Update the list of read articles in GROUP.
12609 UNREAD is a sorted list."
12610 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12611 (info (gnus-get-info group))
12612 (prev 1)
12613 read)
12614 (if (or (not info) (not active))
12615 ;; There is no info on this group if it was, in fact,
12616 ;; killed. Gnus stores no information on killed groups, so
12617 ;; there's nothing to be done.
12618 ;; One could store the information somewhere temporarily,
12619 ;; perhaps... Hmmm...
12620 ()
12621 ;; Remove any negative articles numbers.
12622 (while (and unread (< (car unread) 0))
12623 (setq unread (cdr unread)))
12624 ;; Remove any expired article numbers
12625 (while (and unread (< (car unread) (car active)))
12626 (setq unread (cdr unread)))
12627 ;; Compute the ranges of read articles by looking at the list of
12628 ;; unread articles.
12629 (while unread
12630 (when (/= (car unread) prev)
12631 (push (if (= prev (1- (car unread))) prev
12632 (cons prev (1- (car unread))))
12633 read))
12634 (setq prev (1+ (car unread)))
12635 (setq unread (cdr unread)))
12636 (when (<= prev (cdr active))
12637 (push (cons prev (cdr active)) read))
12638 (setq read (if (> (length read) 1) (nreverse read) read))
12639 (if compute
12640 read
12641 (save-excursion
12642 (let (setmarkundo)
12643 ;; Propagate the read marks to the backend.
12644 (when (and (gnus-method-option-p
12645 (gnus-find-method-for-group group)
12646 'server-marks)
12647 (gnus-check-backend-function 'request-set-mark group))
12648 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12649 (add (gnus-remove-from-range read (gnus-info-read info))))
12650 (when (or add del)
12651 (unless (gnus-check-group group)
12652 (error "Can't open server for %s" group))
12653 (gnus-request-set-mark
12654 group (delq nil (list (if add (list add 'add '(read)))
12655 (if del (list del 'del '(read))))))
12656 (setq setmarkundo
12657 `(gnus-request-set-mark
12658 ,group
12659 ',(delq nil (list
12660 (if del (list del 'add '(read)))
12661 (if add (list add 'del '(read))))))))))
12662 (set-buffer gnus-group-buffer)
12663 (gnus-undo-register
12664 `(progn
12665 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12666 (gnus-info-set-read ',info ',(gnus-info-read info))
12667 (gnus-get-unread-articles-in-group ',info
12668 (gnus-active ,group))
12669 (gnus-group-update-group ,group t)
12670 ,setmarkundo))))
12671 ;; Enter this list into the group info.
12672 (gnus-info-set-read info read)
12673 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12674 (gnus-get-unread-articles-in-group info (gnus-active group))
12675 t))))
12676
12677 (defun gnus-offer-save-summaries ()
12678 "Offer to save all active summary buffers."
12679 (let (buffers)
12680 ;; Go through all buffers and find all summaries.
12681 (dolist (buffer (buffer-list))
12682 (when (and (setq buffer (buffer-name buffer))
12683 (string-match "Summary" buffer)
12684 (with-current-buffer buffer
12685 ;; We check that this is, indeed, a summary buffer.
12686 (and (derived-mode-p 'gnus-summary-mode)
12687 ;; Also make sure this isn't bogus.
12688 gnus-newsgroup-prepared
12689 ;; Also make sure that this isn't a
12690 ;; dead summary buffer.
12691 (not gnus-dead-summary-mode))))
12692 (push buffer buffers)))
12693 ;; Go through all these summary buffers and offer to save them.
12694 (when buffers
12695 (save-excursion
12696 (if (eq gnus-interactive-exit 'quiet)
12697 (dolist (buffer buffers)
12698 (switch-to-buffer buffer)
12699 (gnus-summary-exit))
12700 (map-y-or-n-p
12701 "Update summary buffer %s? "
12702 (lambda (buf)
12703 (switch-to-buffer buf)
12704 (gnus-summary-exit))
12705 buffers))))))
12706
12707 (defun gnus-summary-setup-default-charset ()
12708 "Setup newsgroup default charset."
12709 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12710 (setq gnus-newsgroup-charset nil)
12711 (let* ((ignored-charsets
12712 (or gnus-newsgroup-ephemeral-ignored-charsets
12713 (append
12714 (and gnus-newsgroup-name
12715 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12716 gnus-newsgroup-ignored-charsets))))
12717 (setq gnus-newsgroup-charset
12718 (or gnus-newsgroup-ephemeral-charset
12719 (and gnus-newsgroup-name
12720 (gnus-parameter-charset gnus-newsgroup-name))
12721 gnus-default-charset))
12722 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12723 ignored-charsets))))
12724
12725 ;;;
12726 ;;; Mime Commands
12727 ;;;
12728
12729 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12730 "Display the current article buffer fully MIME-buttonized.
12731 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12732 treated as multipart/mixed."
12733 (interactive "P")
12734 (require 'gnus-art)
12735 (let ((gnus-unbuttonized-mime-types nil)
12736 (gnus-mime-display-multipart-as-mixed show-all-parts))
12737 (gnus-summary-show-article)))
12738
12739 (defun gnus-summary-repair-multipart (article)
12740 "Add a Content-Type header to a multipart article without one."
12741 (interactive (list (gnus-summary-article-number)))
12742 (gnus-with-article article
12743 (message-narrow-to-head)
12744 (message-remove-header "Mime-Version")
12745 (goto-char (point-max))
12746 (insert "Mime-Version: 1.0\n")
12747 (widen)
12748 (when (search-forward "\n--" nil t)
12749 (let ((separator (buffer-substring (point) (point-at-eol))))
12750 (message-narrow-to-head)
12751 (message-remove-header "Content-Type")
12752 (goto-char (point-max))
12753 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12754 separator))
12755 (widen))))
12756 (let (gnus-mark-article-hook)
12757 (gnus-summary-select-article t t nil article)))
12758
12759 (defun gnus-summary-toggle-display-buttonized ()
12760 "Toggle the buttonizing of the article buffer."
12761 (interactive)
12762 (require 'gnus-art)
12763 (if (setq gnus-inhibit-mime-unbuttonizing
12764 (not gnus-inhibit-mime-unbuttonizing))
12765 (let ((gnus-unbuttonized-mime-types nil))
12766 (gnus-summary-show-article))
12767 (gnus-summary-show-article)))
12768
12769 ;;;
12770 ;;; Generic summary marking commands
12771 ;;;
12772
12773 (defvar gnus-summary-marking-alist
12774 '((read gnus-del-mark "d")
12775 (unread gnus-unread-mark "u")
12776 (ticked gnus-ticked-mark "!")
12777 (dormant gnus-dormant-mark "?")
12778 (expirable gnus-expirable-mark "e"))
12779 "An alist of names/marks/keystrokes.")
12780
12781 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12782 (defvar gnus-summary-mark-map)
12783
12784 (defun gnus-summary-make-all-marking-commands ()
12785 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12786 (dolist (elem gnus-summary-marking-alist)
12787 (apply 'gnus-summary-make-marking-command elem)))
12788
12789 (defun gnus-summary-make-marking-command (name mark keystroke)
12790 (let ((map (make-sparse-keymap)))
12791 (define-key gnus-summary-generic-mark-map keystroke map)
12792 (dolist (lway `((next "next" next nil "n")
12793 (next-unread "next unread" next t "N")
12794 (prev "previous" prev nil "p")
12795 (prev-unread "previous unread" prev t "P")
12796 (nomove "" nil nil ,keystroke)))
12797 (let ((func (gnus-summary-make-marking-command-1
12798 mark (car lway) lway name)))
12799 (setq func (eval func))
12800 (define-key map (nth 4 lway) func)))))
12801
12802 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12803 `(defun ,(intern
12804 (format "gnus-summary-put-mark-as-%s%s"
12805 name (if (eq way 'nomove)
12806 ""
12807 (concat "-" (symbol-name way)))))
12808 (n)
12809 ,(format
12810 "Mark the current article as %s%s.
12811 If N, the prefix, then repeat N times.
12812 If N is negative, move in reverse order.
12813 The difference between N and the actual number of articles marked is
12814 returned."
12815 name (cadr lway))
12816 (interactive "p")
12817 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12818
12819 (defun gnus-summary-generic-mark (n mark move unread)
12820 "Mark N articles with MARK."
12821 (unless (derived-mode-p 'gnus-summary-mode)
12822 (error "This command can only be used in the summary buffer"))
12823 (gnus-summary-show-thread)
12824 (let ((nummove
12825 (cond
12826 ((eq move 'next) 1)
12827 ((eq move 'prev) -1)
12828 (t 0))))
12829 (if (zerop nummove)
12830 (setq n 1)
12831 (when (< n 0)
12832 (setq n (abs n)
12833 nummove (* -1 nummove))))
12834 (while (and (> n 0)
12835 (gnus-summary-mark-article nil mark)
12836 (zerop (gnus-summary-next-subject nummove unread t)))
12837 (setq n (1- n)))
12838 (when (/= 0 n)
12839 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12840 (gnus-summary-recenter)
12841 (gnus-summary-position-point)
12842 (gnus-set-mode-line 'summary)
12843 n))
12844
12845 (defun gnus-summary-insert-articles (articles)
12846 (when (setq articles
12847 (gnus-sorted-difference articles
12848 (mapcar (lambda (h)
12849 (mail-header-number h))
12850 gnus-newsgroup-headers)))
12851 (setq gnus-newsgroup-headers
12852 (cl-merge 'list
12853 gnus-newsgroup-headers
12854 (gnus-fetch-headers articles nil t)
12855 'gnus-article-sort-by-number))
12856 (setq gnus-newsgroup-articles
12857 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12858 ;; Suppress duplicates?
12859 (when gnus-suppress-duplicates
12860 (gnus-dup-suppress-articles))
12861
12862 (if (and gnus-fetch-old-headers
12863 (eq gnus-headers-retrieved-by 'nov))
12864 ;; We might want to build some more threads first.
12865 (if (eq gnus-fetch-old-headers 'invisible)
12866 (gnus-build-all-threads)
12867 (gnus-build-old-threads))
12868 ;; Mark the inserted articles that are unread as unread.
12869 (setq gnus-newsgroup-unreads
12870 (gnus-sorted-nunion
12871 gnus-newsgroup-unreads
12872 (gnus-sorted-nintersection
12873 (gnus-list-of-unread-articles gnus-newsgroup-name)
12874 articles)))
12875 ;; Mark the inserted articles as selected so that the information
12876 ;; of the marks having been changed by a user may be updated when
12877 ;; exiting this group. See `gnus-summary-update-info'.
12878 (dolist (art articles)
12879 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12880 ;; Let the Gnus agent mark articles as read.
12881 (when gnus-agent
12882 (gnus-agent-get-undownloaded-list))
12883 ;; Remove list identifiers from subject
12884 (gnus-summary-remove-list-identifiers)
12885 ;; First and last article in this newsgroup.
12886 (when gnus-newsgroup-headers
12887 (setq gnus-newsgroup-begin
12888 (mail-header-number (car gnus-newsgroup-headers))
12889 gnus-newsgroup-end
12890 (mail-header-number
12891 (gnus-last-element gnus-newsgroup-headers))))
12892 (when gnus-use-scoring
12893 (gnus-possibly-score-headers))))
12894
12895 (defun gnus-summary-insert-old-articles (&optional all)
12896 "Insert all old articles in this group.
12897 If ALL is non-nil, already read articles become readable.
12898 If ALL is a number, fetch this number of articles."
12899 (interactive "P")
12900 (prog1
12901 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12902 older len)
12903 (setq older
12904 ;; Some nntp servers lie about their active range. When
12905 ;; this happens, the active range can be in the millions.
12906 ;; Use a compressed range to avoid creating a huge list.
12907 (gnus-range-difference
12908 (gnus-range-difference (list gnus-newsgroup-active) old)
12909 gnus-newsgroup-unexist))
12910 (setq len (gnus-range-length older))
12911 (cond
12912 ((null older) nil)
12913 ((numberp all)
12914 (if (< all len)
12915 (let ((older-range (nreverse older)))
12916 (setq older nil)
12917
12918 (while (> all 0)
12919 (let* ((r (pop older-range))
12920 (min (if (numberp r) r (car r)))
12921 (max (if (numberp r) r (cdr r))))
12922 (while (and (<= min max)
12923 (> all 0))
12924 (push max older)
12925 (setq all (1- all)
12926 max (1- max))))))
12927 (setq older (gnus-uncompress-range older))))
12928 (all
12929 (setq older (gnus-uncompress-range older)))
12930 (t
12931 (when (and (numberp gnus-large-newsgroup)
12932 (> len gnus-large-newsgroup))
12933 (let* ((cursor-in-echo-area nil)
12934 (initial (gnus-parameter-large-newsgroup-initial
12935 gnus-newsgroup-name))
12936 (input
12937 (read-string
12938 (format
12939 "How many articles from %s (%s %d): "
12940 (gnus-group-decoded-name gnus-newsgroup-name)
12941 (if initial "max" "default")
12942 len)
12943 nil nil
12944 (and initial
12945 (number-to-string initial)))))
12946 (unless (string-match "^[ \t]*$" input)
12947 (setq all (string-to-number input))
12948 (if (< all len)
12949 (let ((older-range (nreverse older)))
12950 (setq older nil)
12951
12952 (while (> all 0)
12953 (let* ((r (pop older-range))
12954 (min (if (numberp r) r (car r)))
12955 (max (if (numberp r) r (cdr r))))
12956 (while (and (<= min max)
12957 (> all 0))
12958 (push max older)
12959 (setq all (1- all)
12960 max (1- max))))))))))
12961 (setq older (gnus-uncompress-range older))))
12962 (if (not older)
12963 (message "No old news.")
12964 (gnus-summary-insert-articles older)
12965 (gnus-summary-limit (gnus-sorted-nunion old older))))
12966 (gnus-summary-position-point)))
12967
12968 (defun gnus-summary-insert-new-articles ()
12969 "Insert all new articles in this group."
12970 (interactive)
12971 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12972 (old-high gnus-newsgroup-highest)
12973 (nnmail-fetched-sources (list t))
12974 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12975 i new)
12976 (unless new-active
12977 (error "Couldn't fetch new data"))
12978 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12979 (setq i (cdr gnus-newsgroup-active)
12980 gnus-newsgroup-highest i)
12981 (while (> i old-high)
12982 (push i new)
12983 (decf i))
12984 (if (not new)
12985 (message "No gnus is bad news")
12986 (gnus-summary-insert-articles new)
12987 (setq gnus-newsgroup-unreads
12988 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12989 (gnus-summary-limit (gnus-sorted-nunion old new))))
12990 (gnus-summary-position-point))
12991
12992 ;;; Bookmark support for Gnus.
12993 (declare-function gnus-article-show-summary "gnus-art" ())
12994 (declare-function bookmark-make-record-default
12995 "bookmark" (&optional no-file no-context posn))
12996 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12997 (declare-function bookmark-default-handler "bookmark" (bmk))
12998 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12999 (defvar bookmark-yank-point)
13000 (defvar bookmark-current-buffer)
13001
13002 (defun gnus-summary-bookmark-make-record ()
13003 "Make a bookmark entry for a Gnus summary buffer."
13004 (let (pos buf)
13005 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
13006 (save-restriction ; FIXME is it necessary to widen?
13007 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
13008 (setq buf "art") ; We are recording bookmark from article buffer.
13009 (setq bookmark-yank-point (point))
13010 (setq bookmark-current-buffer (current-buffer))
13011 (gnus-article-show-summary)) ; Go back in summary buffer.
13012 ;; We are now recording bookmark from summary buffer.
13013 (unless buf (setq buf "sum"))
13014 (let* ((subject (elt (gnus-summary-article-header) 1))
13015 (grp (car gnus-article-current))
13016 (art (cdr gnus-article-current))
13017 (head (gnus-summary-article-header art))
13018 (id (mail-header-id head)))
13019 `(,subject
13020 ,@(condition-case nil
13021 (bookmark-make-record-default 'no-file 'no-context pos)
13022 (wrong-number-of-arguments
13023 (bookmark-make-record-default 'point-only)))
13024 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13025 (group . ,grp) (article . ,art)
13026 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13027
13028 ;;;###autoload
13029 (defun gnus-summary-bookmark-jump (bookmark)
13030 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13031 BOOKMARK is a bookmark name or a bookmark record."
13032 (let ((group (bookmark-prop-get bookmark 'group))
13033 (article (bookmark-prop-get bookmark 'article))
13034 (id (bookmark-prop-get bookmark 'message-id))
13035 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13036 (gnus-fetch-group group (list article))
13037 (gnus-summary-insert-cached-articles)
13038 (gnus-summary-goto-article id nil 'force)
13039 ;; FIXME we have to wait article buffer is ready (only large buffer)
13040 ;; Is there a better solution to know that?
13041 ;; If we don't wait `bookmark-default-handler' will have no chance
13042 ;; to set position. However there is no error, just wrong pos.
13043 (sit-for 1)
13044 (when (string= buf "Gnus-art")
13045 (other-window 1))
13046 (bookmark-default-handler
13047 `(""
13048 (buffer . ,(current-buffer))
13049 . ,(bookmark-get-bookmark-record bookmark)))))
13050
13051 (gnus-summary-make-all-marking-commands)
13052
13053 (provide 'gnus-sum)
13054
13055 (run-hooks 'gnus-sum-load-hook)
13056
13057 ;; Local Variables:
13058 ;; coding: utf-8
13059 ;; End:
13060
13061 ;;; gnus-sum.el ends here