]> code.delx.au - gnu-emacs/blob - lisp/gnus/gnus-sum.el
; Merge from origin/emacs-25
[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 ;; Don't share the 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 (image-load-path-for-library "gnus" "mail/save.xpm" nil t))
2942 (image-load-path (cons (car load-path) image-load-path))
2943 (map (gmm-tool-bar-from-list gnus-summary-tool-bar
2944 gnus-summary-tool-bar-zap-list
2945 'gnus-summary-mode-map)))
2946 (when map
2947 ;; Need to set `gnus-summary-tool-bar-map' because `gnus-article-mode'
2948 ;; uses its value.
2949 (setq gnus-summary-tool-bar-map map))))
2950 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))
2951
2952 (defun gnus-make-score-map (type)
2953 "Make a summary score map of type TYPE."
2954 (if t
2955 nil
2956 (let ((headers '(("author" "from" string)
2957 ("subject" "subject" string)
2958 ("article body" "body" string)
2959 ("article head" "head" string)
2960 ("xref" "xref" string)
2961 ("extra header" "extra" string)
2962 ("lines" "lines" number)
2963 ("followups to author" "followup" string)))
2964 (types '((number ("less than" <)
2965 ("greater than" >)
2966 ("equal" =))
2967 (string ("substring" s)
2968 ("exact string" e)
2969 ("fuzzy string" f)
2970 ("regexp" r))))
2971 (perms '(("temporary" (current-time-string))
2972 ("permanent" nil)
2973 ("immediate" now)))
2974 header)
2975 (list
2976 (apply
2977 'nconc
2978 (list
2979 (if (eq type 'lower)
2980 "Lower score"
2981 "Increase score"))
2982 (let (outh)
2983 (while headers
2984 (setq header (car headers))
2985 (setq outh
2986 (cons
2987 (apply
2988 'nconc
2989 (list (car header))
2990 (let ((ts (cdr (assoc (nth 2 header) types)))
2991 outt)
2992 (while ts
2993 (setq outt
2994 (cons
2995 (apply
2996 'nconc
2997 (list (caar ts))
2998 (let ((ps perms)
2999 outp)
3000 (while ps
3001 (setq outp
3002 (cons
3003 (vector
3004 (caar ps)
3005 (list
3006 'gnus-summary-score-entry
3007 (nth 1 header)
3008 (if (or (string= (nth 1 header)
3009 "head")
3010 (string= (nth 1 header)
3011 "body"))
3012 ""
3013 (list 'gnus-summary-header
3014 (nth 1 header)))
3015 (list 'quote (nth 1 (car ts)))
3016 (list 'gnus-score-delta-default
3017 nil)
3018 (nth 1 (car ps))
3019 t)
3020 t)
3021 outp))
3022 (setq ps (cdr ps)))
3023 (list (nreverse outp))))
3024 outt))
3025 (setq ts (cdr ts)))
3026 (list (nreverse outt))))
3027 outh))
3028 (setq headers (cdr headers)))
3029 (list (nreverse outh))))))))
3030
3031
3032 (declare-function turn-on-gnus-mailing-list-mode "gnus-ml" ())
3033 (defvar bookmark-make-record-function)
3034 \f
3035 (defvar bidi-paragraph-direction)
3036
3037 (defun gnus-summary-mode (&optional group)
3038 "Major mode for reading articles.
3039
3040 All normal editing commands are switched off.
3041 \\<gnus-summary-mode-map>
3042 Each line in this buffer represents one article. To read an
3043 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
3044 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
3045 respectively.
3046
3047 You can also post articles and send mail from this buffer. To
3048 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
3049 of an article, type `\\[gnus-summary-reply]'.
3050
3051 There are approx. one gazillion commands you can execute in this
3052 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
3053
3054 The following commands are available:
3055
3056 \\{gnus-summary-mode-map}"
3057 ;; FIXME: Use define-derived-mode.
3058 (interactive)
3059 (kill-all-local-variables)
3060 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
3061 (gnus-summary-make-local-variables))
3062 (gnus-summary-make-local-variables)
3063 (setq gnus-newsgroup-name group)
3064 (when (gnus-visual-p 'summary-menu 'menu)
3065 (gnus-summary-make-menu-bar)
3066 (gnus-summary-make-tool-bar))
3067 (gnus-make-thread-indent-array)
3068 (gnus-simplify-mode-line)
3069 (setq major-mode 'gnus-summary-mode)
3070 (setq mode-name "Summary")
3071 (use-local-map gnus-summary-mode-map)
3072 (buffer-disable-undo)
3073 (setq buffer-read-only t
3074 show-trailing-whitespace nil
3075 truncate-lines t
3076 bidi-paragraph-direction 'left-to-right)
3077 (add-to-invisibility-spec '(gnus-sum . t))
3078 (gnus-summary-set-display-table)
3079 (gnus-set-default-directory)
3080 (make-local-variable 'gnus-summary-line-format)
3081 (make-local-variable 'gnus-summary-line-format-spec)
3082 (make-local-variable 'gnus-summary-dummy-line-format)
3083 (make-local-variable 'gnus-summary-dummy-line-format-spec)
3084 (make-local-variable 'gnus-summary-mark-positions)
3085 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
3086 (gnus-run-mode-hooks 'gnus-summary-mode-hook)
3087 (turn-on-gnus-mailing-list-mode)
3088 (mm-enable-multibyte)
3089 (set (make-local-variable 'bookmark-make-record-function)
3090 'gnus-summary-bookmark-make-record)
3091 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
3092 (gnus-update-summary-mark-positions))
3093
3094 (defun gnus-summary-make-local-variables ()
3095 "Make all the local summary buffer variables."
3096 (let (global)
3097 (dolist (local gnus-summary-local-variables)
3098 (if (consp local)
3099 (progn
3100 (if (eq (cdr local) 'global)
3101 ;; Copy the global value of the variable.
3102 (setq global (symbol-value (car local)))
3103 ;; Use the value from the list.
3104 (setq global (eval (cdr local))))
3105 (set (make-local-variable (car local)) global))
3106 ;; Simple nil-valued local variable.
3107 (set (make-local-variable local) nil)))))
3108
3109 ;; Summary data functions.
3110
3111 (defmacro gnus-data-number (data)
3112 `(car ,data))
3113
3114 (defmacro gnus-data-set-number (data number)
3115 `(setcar ,data ,number))
3116
3117 (defmacro gnus-data-mark (data)
3118 `(nth 1 ,data))
3119
3120 (defmacro gnus-data-set-mark (data mark)
3121 `(setcar (nthcdr 1 ,data) ,mark))
3122
3123 (defmacro gnus-data-pos (data)
3124 `(nth 2 ,data))
3125
3126 (defmacro gnus-data-set-pos (data pos)
3127 `(setcar (nthcdr 2 ,data) ,pos))
3128
3129 (defmacro gnus-data-header (data)
3130 `(nth 3 ,data))
3131
3132 (defmacro gnus-data-set-header (data header)
3133 `(setf (nth 3 ,data) ,header))
3134
3135 (defmacro gnus-data-level (data)
3136 `(nth 4 ,data))
3137
3138 (defmacro gnus-data-unread-p (data)
3139 `(= (nth 1 ,data) gnus-unread-mark))
3140
3141 (defmacro gnus-data-read-p (data)
3142 `(/= (nth 1 ,data) gnus-unread-mark))
3143
3144 (defmacro gnus-data-pseudo-p (data)
3145 `(consp (nth 3 ,data)))
3146
3147 (defmacro gnus-data-find (number)
3148 `(assq ,number gnus-newsgroup-data))
3149
3150 (defmacro gnus-data-find-list (number &optional data)
3151 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
3152 (memq (assq ,number bdata)
3153 bdata)))
3154
3155 (defmacro gnus-data-make (number mark pos header level)
3156 `(list ,number ,mark ,pos ,header ,level))
3157
3158 (defun gnus-data-enter (after-article number mark pos header level offset)
3159 (let ((data (gnus-data-find-list after-article)))
3160 (unless data
3161 (error "No such article: %d" after-article))
3162 (setcdr data (cons (gnus-data-make number mark pos header level)
3163 (cdr data)))
3164 (setq gnus-newsgroup-data-reverse nil)
3165 (gnus-data-update-list (cddr data) offset)))
3166
3167 (defun gnus-data-enter-list (after-article list &optional offset)
3168 (when list
3169 (let ((data (and after-article (gnus-data-find-list after-article)))
3170 (ilist list))
3171 (if (not (or data
3172 after-article))
3173 (let ((odata gnus-newsgroup-data))
3174 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
3175 (when offset
3176 (gnus-data-update-list odata offset)))
3177 ;; Find the last element in the list to be spliced into the main
3178 ;; list.
3179 (setq list (last list))
3180 (if (not data)
3181 (progn
3182 (setcdr list gnus-newsgroup-data)
3183 (setq gnus-newsgroup-data ilist)
3184 (when offset
3185 (gnus-data-update-list (cdr list) offset)))
3186 (setcdr list (cdr data))
3187 (setcdr data ilist)
3188 (when offset
3189 (gnus-data-update-list (cdr list) offset))))
3190 (setq gnus-newsgroup-data-reverse nil))))
3191
3192 (defun gnus-data-remove (article &optional offset)
3193 (let ((data gnus-newsgroup-data))
3194 (if (= (gnus-data-number (car data)) article)
3195 (progn
3196 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
3197 gnus-newsgroup-data-reverse nil)
3198 (when offset
3199 (gnus-data-update-list gnus-newsgroup-data offset)))
3200 (while (cdr data)
3201 (when (= (gnus-data-number (cadr data)) article)
3202 (setcdr data (cddr data))
3203 (when offset
3204 (gnus-data-update-list (cdr data) offset))
3205 (setq data nil
3206 gnus-newsgroup-data-reverse nil))
3207 (setq data (cdr data))))))
3208
3209 (defmacro gnus-data-list (backward)
3210 `(if ,backward
3211 (or gnus-newsgroup-data-reverse
3212 (setq gnus-newsgroup-data-reverse
3213 (reverse gnus-newsgroup-data)))
3214 gnus-newsgroup-data))
3215
3216 (defun gnus-data-update-list (data offset)
3217 "Add OFFSET to the POS of all data entries in DATA."
3218 (setq gnus-newsgroup-data-reverse nil)
3219 (while data
3220 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
3221 (setq data (cdr data))))
3222
3223 (defun gnus-summary-article-pseudo-p (article)
3224 "Say whether this article is a pseudo article or not."
3225 (not (vectorp (gnus-data-header (gnus-data-find article)))))
3226
3227 (defmacro gnus-summary-article-sparse-p (article)
3228 "Say whether this article is a sparse article or not."
3229 `(memq ,article gnus-newsgroup-sparse))
3230
3231 (defmacro gnus-summary-article-ancient-p (article)
3232 "Say whether this article is a sparse article or not."
3233 `(memq ,article gnus-newsgroup-ancient))
3234
3235 (defun gnus-article-children (number)
3236 "Return a list of all children to NUMBER."
3237 (let* ((data (gnus-data-find-list number))
3238 (level (gnus-data-level (car data)))
3239 children)
3240 (setq data (cdr data))
3241 (while (and data
3242 (= (gnus-data-level (car data)) (1+ level)))
3243 (push (gnus-data-number (car data)) children)
3244 (setq data (cdr data)))
3245 children))
3246
3247 (defmacro gnus-summary-skip-intangible ()
3248 "If the current article is intangible, then jump to a different article."
3249 '(let ((to (get-text-property (point) 'gnus-intangible)))
3250 (and to (gnus-summary-goto-subject to))))
3251
3252 (defmacro gnus-summary-article-intangible-p ()
3253 "Say whether this article is intangible or not."
3254 '(get-text-property (point) 'gnus-intangible))
3255
3256 ;; Some summary mode macros.
3257
3258 (defmacro gnus-summary-article-number ()
3259 "The article number of the article on the current line.
3260 If there isn't an article number here, then we return the current
3261 article number."
3262 '(progn
3263 (gnus-summary-skip-intangible)
3264 (or (get-text-property (point) 'gnus-number)
3265 (gnus-summary-last-subject))))
3266
3267 (defmacro gnus-summary-article-header (&optional number)
3268 "Return the header of article NUMBER."
3269 `(gnus-data-header (gnus-data-find
3270 ,(or number '(gnus-summary-article-number)))))
3271
3272 (defmacro gnus-summary-thread-level (&optional number)
3273 "Return the level of thread that starts with article NUMBER."
3274 `(if (and (eq gnus-summary-make-false-root 'dummy)
3275 (get-text-property (point) 'gnus-intangible))
3276 0
3277 (gnus-data-level (gnus-data-find
3278 ,(or number '(gnus-summary-article-number))))))
3279
3280 (defmacro gnus-summary-article-mark (&optional number)
3281 "Return the mark of article NUMBER."
3282 `(gnus-data-mark (gnus-data-find
3283 ,(or number '(gnus-summary-article-number)))))
3284
3285 (defmacro gnus-summary-article-pos (&optional number)
3286 "Return the position of the line of article NUMBER."
3287 `(gnus-data-pos (gnus-data-find
3288 ,(or number '(gnus-summary-article-number)))))
3289
3290 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
3291 (defmacro gnus-summary-article-subject (&optional number)
3292 "Return current subject string or nil if nothing."
3293 `(let ((headers
3294 ,(if number
3295 `(gnus-data-header (assq ,number gnus-newsgroup-data))
3296 '(gnus-data-header (assq (gnus-summary-article-number)
3297 gnus-newsgroup-data)))))
3298 (and headers
3299 (vectorp headers)
3300 (mail-header-subject headers))))
3301
3302 (defmacro gnus-summary-article-score (&optional number)
3303 "Return current article score."
3304 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
3305 gnus-newsgroup-scored))
3306 gnus-summary-default-score 0))
3307
3308 (defun gnus-summary-article-children (&optional number)
3309 "Return a list of article numbers that are children of article NUMBER."
3310 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
3311 (level (gnus-data-level (car data)))
3312 l children)
3313 (while (and (setq data (cdr data))
3314 (> (setq l (gnus-data-level (car data))) level))
3315 (and (= (1+ level) l)
3316 (push (gnus-data-number (car data))
3317 children)))
3318 (nreverse children)))
3319
3320 (defun gnus-summary-article-parent (&optional number)
3321 "Return the article number of the parent of article NUMBER."
3322 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
3323 (gnus-data-list t)))
3324 (level (gnus-data-level (car data))))
3325 (if (zerop level)
3326 () ; This is a root.
3327 ;; We search until we find an article with a level less than
3328 ;; this one. That function has to be the parent.
3329 (while (and (setq data (cdr data))
3330 (not (< (gnus-data-level (car data)) level))))
3331 (and data (gnus-data-number (car data))))))
3332
3333 (defun gnus-unread-mark-p (mark)
3334 "Say whether MARK is the unread mark."
3335 (= mark gnus-unread-mark))
3336
3337 (defun gnus-read-mark-p (mark)
3338 "Say whether MARK is one of the marks that mark as read.
3339 This is all marks except unread, ticked, dormant, and expirable."
3340 (not (or (= mark gnus-unread-mark)
3341 (= mark gnus-ticked-mark)
3342 (= mark gnus-spam-mark)
3343 (= mark gnus-dormant-mark)
3344 (= mark gnus-expirable-mark))))
3345
3346 (defmacro gnus-article-mark (number)
3347 "Return the MARK of article NUMBER.
3348 This macro should only be used when computing the mark the \"first\"
3349 time; i.e., when generating the summary lines. After that,
3350 `gnus-summary-article-mark' should be used to examine the
3351 marks of articles."
3352 `(cond
3353 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3354 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3355 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3356 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3357 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3358 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3359 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3360 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3361 gnus-ancient-mark))))
3362
3363 ;; Saving hidden threads.
3364
3365 (defmacro gnus-save-hidden-threads (&rest forms)
3366 "Save hidden threads, eval FORMS, and restore the hidden threads."
3367 (let ((config (make-symbol "config")))
3368 `(let ((,config (gnus-hidden-threads-configuration)))
3369 (unwind-protect
3370 (save-excursion
3371 ,@forms)
3372 (gnus-restore-hidden-threads-configuration ,config)))))
3373 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3374 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3375
3376 (defun gnus-data-compute-positions ()
3377 "Compute the positions of all articles."
3378 (setq gnus-newsgroup-data-reverse nil)
3379 (let ((data gnus-newsgroup-data))
3380 (save-excursion
3381 (gnus-save-hidden-threads
3382 (gnus-summary-show-all-threads)
3383 (goto-char (point-min))
3384 (while data
3385 (while (get-text-property (point) 'gnus-intangible)
3386 (forward-line 1))
3387 (gnus-data-set-pos (car data) (+ (point) 3))
3388 (setq data (cdr data))
3389 (forward-line 1))))))
3390
3391 (defun gnus-hidden-threads-configuration ()
3392 "Return the current hidden threads configuration."
3393 (save-excursion
3394 (let (config)
3395 (goto-char (point-min))
3396 (while (not (eobp))
3397 (when (eq (get-char-property (point-at-eol) 'invisible) 'gnus-sum)
3398 (push (save-excursion (forward-line 0) (point)) config))
3399 (forward-line 1))
3400 config)))
3401
3402 (defun gnus-restore-hidden-threads-configuration (config)
3403 "Restore hidden threads configuration from CONFIG."
3404 (save-excursion
3405 (let (point (inhibit-read-only t))
3406 (while (setq point (pop config))
3407 (goto-char point)
3408 (gnus-summary-hide-thread)))))
3409
3410 ;; Various summary mode internalish functions.
3411
3412 (defun gnus-mouse-pick-article (e)
3413 (interactive "e")
3414 (mouse-set-point e)
3415 (gnus-summary-next-page nil t))
3416
3417 (defun gnus-summary-set-display-table ()
3418 "Change the display table.
3419 Odd characters have a tendency to mess
3420 up nicely formatted displays - we make all possible glyphs
3421 display only a single character."
3422
3423 ;; We start from the standard display table, if any.
3424 (let ((table (or (copy-sequence standard-display-table)
3425 (make-display-table)))
3426 (i 32))
3427 ;; Nix out all the control chars...
3428 (while (>= (setq i (1- i)) 0)
3429 (aset table i [??]))
3430 ;; ... but not newline and cr, of course. (cr is necessary for the
3431 ;; selective display).
3432 (aset table ?\n nil)
3433 (aset table ?\r nil)
3434 ;; We keep TAB as well.
3435 (aset table ?\t nil)
3436 ;; We nix out any glyphs 127 through 255, or 127 through 159 in
3437 ;; Emacs 23 (unicode), that are not set already.
3438 (let ((i (if (ignore-errors (= (make-char 'latin-iso8859-1 160) 160))
3439 160
3440 256)))
3441 (while (>= (setq i (1- i)) 127)
3442 ;; Only modify if the entry is nil.
3443 (unless (aref table i)
3444 (aset table i [??]))))
3445 (setq buffer-display-table table)))
3446
3447 (defun gnus-summary-set-article-display-arrow (pos)
3448 "Update the overlay arrow to point to line at position POS."
3449 (when gnus-summary-display-arrow
3450 (make-local-variable 'overlay-arrow-position)
3451 (make-local-variable 'overlay-arrow-string)
3452 (save-excursion
3453 (goto-char pos)
3454 (beginning-of-line)
3455 (unless overlay-arrow-position
3456 (setq overlay-arrow-position (make-marker)))
3457 (setq overlay-arrow-string "=>"
3458 overlay-arrow-position (set-marker overlay-arrow-position
3459 (point)
3460 (current-buffer))))))
3461
3462 (defun gnus-summary-setup-buffer (group)
3463 "Initialize summary buffer.
3464 If the setup was successful, non-nil is returned."
3465 (let ((buffer (gnus-summary-buffer-name group))
3466 (dead-name (concat "*Dead Summary "
3467 (gnus-group-decoded-name group) "*")))
3468 ;; If a dead summary buffer exists, we kill it.
3469 (when (gnus-buffer-live-p dead-name)
3470 (gnus-kill-buffer dead-name))
3471 (if (get-buffer buffer)
3472 (progn
3473 (set-buffer buffer)
3474 (setq gnus-summary-buffer (current-buffer))
3475 (not gnus-newsgroup-prepared))
3476 (set-buffer (gnus-get-buffer-create buffer))
3477 (setq gnus-summary-buffer (current-buffer))
3478 (gnus-summary-mode group)
3479 (when (gnus-group-quit-config group)
3480 (set (make-local-variable 'gnus-single-article-buffer) nil))
3481 (make-local-variable 'gnus-article-buffer)
3482 (make-local-variable 'gnus-article-current)
3483 (make-local-variable 'gnus-original-article-buffer)
3484 (setq gnus-newsgroup-name group)
3485 ;; Set any local variables in the group parameters.
3486 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3487 t)))
3488
3489 (defun gnus-set-global-variables ()
3490 "Set the global equivalents of the buffer-local variables.
3491 They are set to the latest values they had. These reflect the summary
3492 buffer that was in action when the last article was fetched."
3493 (when (derived-mode-p 'gnus-summary-mode)
3494 (setq gnus-summary-buffer (current-buffer))
3495 (let ((name gnus-newsgroup-name)
3496 (marked gnus-newsgroup-marked)
3497 (spam gnus-newsgroup-spam-marked)
3498 (unread gnus-newsgroup-unreads)
3499 (headers gnus-current-headers)
3500 (data gnus-newsgroup-data)
3501 (summary gnus-summary-buffer)
3502 (article-buffer gnus-article-buffer)
3503 (original gnus-original-article-buffer)
3504 (gac gnus-article-current)
3505 (reffed gnus-reffed-article-number)
3506 (score-file gnus-current-score-file)
3507 (default-charset gnus-newsgroup-charset)
3508 vlist)
3509 (let ((locals gnus-newsgroup-variables))
3510 (while locals
3511 (if (consp (car locals))
3512 (push (eval (caar locals)) vlist)
3513 (push (eval (car locals)) vlist))
3514 (setq locals (cdr locals)))
3515 (setq vlist (nreverse vlist)))
3516 (with-temp-buffer
3517 (setq gnus-newsgroup-name name
3518 gnus-newsgroup-marked marked
3519 gnus-newsgroup-spam-marked spam
3520 gnus-newsgroup-unreads unread
3521 gnus-current-headers headers
3522 gnus-newsgroup-data data
3523 gnus-article-current gac
3524 gnus-summary-buffer summary
3525 gnus-article-buffer article-buffer
3526 gnus-original-article-buffer original
3527 gnus-reffed-article-number reffed
3528 gnus-current-score-file score-file
3529 gnus-newsgroup-charset default-charset)
3530 (let ((locals gnus-newsgroup-variables))
3531 (while locals
3532 (if (consp (car locals))
3533 (set (caar locals) (pop vlist))
3534 (set (car locals) (pop vlist)))
3535 (setq locals (cdr locals))))))))
3536
3537 (defun gnus-summary-article-unread-p (article)
3538 "Say whether ARTICLE is unread or not."
3539 (memq article gnus-newsgroup-unreads))
3540
3541 (defun gnus-summary-first-article-p (&optional article)
3542 "Return whether ARTICLE is the first article in the buffer."
3543 (if (not (setq article (or article (gnus-summary-article-number))))
3544 nil
3545 (eq article (caar gnus-newsgroup-data))))
3546
3547 (defun gnus-summary-last-article-p (&optional article)
3548 "Return whether ARTICLE is the last article in the buffer."
3549 (if (not (setq article (or article (gnus-summary-article-number))))
3550 ;; All non-existent numbers are the last article. :-)
3551 t
3552 (not (cdr (gnus-data-find-list article)))))
3553
3554 (defun gnus-make-thread-indent-array (&optional n)
3555 (when (or n
3556 (progn (setq n 200) nil)
3557 (null gnus-thread-indent-array)
3558 (/= gnus-thread-indent-level gnus-thread-indent-array-level))
3559 (setq gnus-thread-indent-array (make-vector (1+ n) "")
3560 gnus-thread-indent-array-level gnus-thread-indent-level)
3561 (while (>= n 0)
3562 (aset gnus-thread-indent-array n
3563 (make-string (* n gnus-thread-indent-level) ? ))
3564 (setq n (1- n)))))
3565
3566 (defun gnus-update-summary-mark-positions ()
3567 "Compute where the summary marks are to go."
3568 (save-excursion
3569 (when (gnus-buffer-exists-p gnus-summary-buffer)
3570 (set-buffer gnus-summary-buffer))
3571 (let ((spec gnus-summary-line-format-spec)
3572 pos)
3573 (save-excursion
3574 (gnus-set-work-buffer)
3575 (let ((gnus-tmp-unread ?Z)
3576 (gnus-replied-mark ?Z)
3577 (gnus-score-below-mark ?Z)
3578 (gnus-score-over-mark ?Z)
3579 (gnus-undownloaded-mark ?Z)
3580 (gnus-summary-line-format-spec spec)
3581 (gnus-newsgroup-downloadable '(0))
3582 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3583 case-fold-search ignores)
3584 ;; Here, all marks are bound to Z.
3585 (gnus-summary-insert-line header
3586 0 nil t gnus-tmp-unread t nil "" nil 1)
3587 (goto-char (point-min))
3588 ;; Memorize the positions of the same characters as dummy marks.
3589 (while (re-search-forward "[A-D]" nil t)
3590 (push (point) ignores))
3591 (erase-buffer)
3592 ;; We use A-D as dummy marks in order to know column positions
3593 ;; where marks should be inserted.
3594 (setq gnus-tmp-unread ?A
3595 gnus-replied-mark ?B
3596 gnus-score-below-mark ?C
3597 gnus-score-over-mark ?C
3598 gnus-undownloaded-mark ?D)
3599 (gnus-summary-insert-line header
3600 0 nil t gnus-tmp-unread t nil "" nil 1)
3601 ;; Ignore characters which aren't dummy marks.
3602 (dolist (p ignores)
3603 (delete-region (goto-char (1- p)) p)
3604 (insert ?Z))
3605 (goto-char (point-min))
3606 (setq pos (list (cons 'unread
3607 (and (search-forward "A" nil t)
3608 (- (point) (point-min) 1)))))
3609 (goto-char (point-min))
3610 (push (cons 'replied (and (search-forward "B" nil t)
3611 (- (point) (point-min) 1)))
3612 pos)
3613 (goto-char (point-min))
3614 (push (cons 'score (and (search-forward "C" nil t)
3615 (- (point) (point-min) 1)))
3616 pos)
3617 (goto-char (point-min))
3618 (push (cons 'download (and (search-forward "D" nil t)
3619 (- (point) (point-min) 1)))
3620 pos)))
3621 (setq gnus-summary-mark-positions pos))))
3622
3623 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3624 "Insert a dummy root in the summary buffer."
3625 (beginning-of-line)
3626 (add-text-properties
3627 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3628 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3629
3630 (defun gnus-summary-extract-address-component (from)
3631 (or (car (funcall gnus-extract-address-components from))
3632 from))
3633
3634 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3635 (let ((mail-parse-charset gnus-newsgroup-charset)
3636 ;; Is it really necessary to do this next part for each summary line?
3637 ;; Luckily, doesn't seem to slow things down much.
3638 (mail-parse-ignored-charsets
3639 (with-current-buffer gnus-summary-buffer
3640 gnus-newsgroup-ignored-charsets)))
3641 (or
3642 (and gnus-ignored-from-addresses
3643 (cond ((functionp gnus-ignored-from-addresses)
3644 (funcall gnus-ignored-from-addresses
3645 (mail-strip-quoted-names gnus-tmp-from)))
3646 (t (string-match (gnus-ignored-from-addresses) gnus-tmp-from)))
3647 (let ((extra-headers (mail-header-extra header))
3648 to
3649 newsgroups)
3650 (cond
3651 ((setq to (cdr (assq 'To extra-headers)))
3652 (concat gnus-summary-to-prefix
3653 (inline
3654 (gnus-summary-extract-address-component
3655 (funcall gnus-decode-encoded-address-function to)))))
3656 ((setq newsgroups
3657 (or
3658 (cdr (assq 'Newsgroups extra-headers))
3659 (and
3660 (memq 'Newsgroups gnus-extra-headers)
3661 (eq (car (gnus-find-method-for-group
3662 gnus-newsgroup-name)) 'nntp)
3663 (gnus-group-real-name gnus-newsgroup-name))))
3664 (concat gnus-summary-newsgroup-prefix newsgroups)))))
3665 (bidi-string-mark-left-to-right
3666 (inline
3667 (gnus-summary-extract-address-component gnus-tmp-from))))))
3668
3669 (defun gnus-summary-insert-line (gnus-tmp-header
3670 gnus-tmp-level gnus-tmp-current
3671 undownloaded gnus-tmp-unread gnus-tmp-replied
3672 gnus-tmp-expirable gnus-tmp-subject-or-nil
3673 &optional gnus-tmp-dummy gnus-tmp-score
3674 gnus-tmp-process)
3675 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
3676 (gnus-make-thread-indent-array (max (* 2 (length gnus-thread-indent-array))
3677 gnus-tmp-level)))
3678 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3679 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3680 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3681 (gnus-tmp-score-char
3682 (if (or (null gnus-summary-default-score)
3683 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3684 gnus-summary-zcore-fuzz))
3685 ? ;Whitespace
3686 (if (< gnus-tmp-score gnus-summary-default-score)
3687 gnus-score-below-mark gnus-score-over-mark)))
3688 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3689 (gnus-tmp-replied
3690 (cond (gnus-tmp-process gnus-process-mark)
3691 ((memq gnus-tmp-current gnus-newsgroup-cached)
3692 gnus-cached-mark)
3693 (gnus-tmp-replied gnus-replied-mark)
3694 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3695 gnus-forwarded-mark)
3696 ((memq gnus-tmp-current gnus-newsgroup-saved)
3697 gnus-saved-mark)
3698 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3699 gnus-unseen-mark)
3700 (t gnus-no-mark)))
3701 (gnus-tmp-downloaded
3702 (cond (undownloaded
3703 gnus-undownloaded-mark)
3704 (gnus-newsgroup-agentized
3705 gnus-downloaded-mark)
3706 (t
3707 gnus-no-mark)))
3708 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3709 (gnus-tmp-name
3710 (cond
3711 ((string-match "<[^>]+> *$" gnus-tmp-from)
3712 (let ((beg (match-beginning 0)))
3713 (or (and (string-match "^\".+\"" gnus-tmp-from)
3714 (substring gnus-tmp-from 1 (1- (match-end 0))))
3715 (substring gnus-tmp-from 0 beg))))
3716 ((string-match "(.+)" gnus-tmp-from)
3717 (substring gnus-tmp-from
3718 (1+ (match-beginning 0)) (1- (match-end 0))))
3719 (t gnus-tmp-from)))
3720 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3721 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3722 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3723 (inhibit-read-only t))
3724 (when (string= gnus-tmp-name "")
3725 (setq gnus-tmp-name gnus-tmp-from))
3726 (unless (numberp gnus-tmp-lines)
3727 (setq gnus-tmp-lines -1))
3728 (if (= gnus-tmp-lines -1)
3729 (setq gnus-tmp-lines "?")
3730 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3731 (condition-case ()
3732 (put-text-property
3733 (point)
3734 (progn (eval gnus-summary-line-format-spec) (point))
3735 'gnus-number gnus-tmp-number)
3736 (error (gnus-message 5 "Error updating the summary line")))
3737 (when (gnus-visual-p 'summary-highlight 'highlight)
3738 (forward-line -1)
3739 (gnus-summary-highlight-line)
3740 (gnus-run-hooks 'gnus-summary-update-hook)
3741 (forward-line 1))))
3742
3743 (defun gnus-summary-update-line (&optional dont-update)
3744 "Update summary line after change."
3745 (when (and gnus-summary-default-score
3746 (not gnus-summary-inhibit-highlight))
3747 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3748 (article (gnus-summary-article-number))
3749 (score (gnus-summary-article-score article)))
3750 (unless dont-update
3751 (if (and gnus-summary-mark-below
3752 (< (gnus-summary-article-score)
3753 gnus-summary-mark-below))
3754 ;; This article has a low score, so we mark it as read.
3755 (when (memq article gnus-newsgroup-unreads)
3756 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3757 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3758 ;; This article was previously marked as read on account
3759 ;; of a low score, but now it has risen, so we mark it as
3760 ;; unread.
3761 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3762 (gnus-summary-update-mark
3763 (if (or (null gnus-summary-default-score)
3764 (<= (abs (- score gnus-summary-default-score))
3765 gnus-summary-zcore-fuzz))
3766 ? ;Whitespace
3767 (if (< score gnus-summary-default-score)
3768 gnus-score-below-mark gnus-score-over-mark))
3769 'score))
3770 ;; Do visual highlighting.
3771 (when (gnus-visual-p 'summary-highlight 'highlight)
3772 (gnus-summary-highlight-line)
3773 (gnus-run-hooks 'gnus-summary-update-hook)))))
3774
3775 (defvar gnus-tmp-new-adopts nil)
3776
3777 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3778 "Return the number of articles in THREAD.
3779 This may be 0 in some cases -- if none of the articles in
3780 the thread are to be displayed."
3781 (let* ((number
3782 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3783 (cond
3784 ((not (listp thread))
3785 1)
3786 ((and (consp thread) (cdr thread))
3787 (apply
3788 '+ 1 (mapcar
3789 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3790 ((null thread)
3791 1)
3792 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3793 1)
3794 (t 0))))
3795 (when (and level (zerop level) gnus-tmp-new-adopts)
3796 (incf number
3797 (apply '+ (mapcar
3798 'gnus-summary-number-of-articles-in-thread
3799 gnus-tmp-new-adopts))))
3800 (if char
3801 (if (> number 1) gnus-not-empty-thread-mark
3802 gnus-empty-thread-mark)
3803 number)))
3804
3805 (defsubst gnus-summary-line-message-size (head)
3806 "Return pretty-printed version of message size.
3807 This function is intended to be used in
3808 `gnus-summary-line-format-alist'."
3809 (let ((c (or (mail-header-chars head) -1)))
3810 (cond ((< c 0) "n/a") ; chars not available
3811 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3812 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3813 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3814 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3815
3816 (defcustom gnus-user-date-format-alist
3817 '(((gnus-seconds-today) . "Today, %H:%M")
3818 ((+ 86400 (gnus-seconds-today)) . "Yesterday, %H:%M")
3819 (604800 . "%A %H:%M") ; That's one week
3820 ((gnus-seconds-month) . "%A %d")
3821 ((gnus-seconds-year) . "%B %d")
3822 (t . "%b %d %Y")) ; This one is used when no other
3823 ; does match
3824 "Specifies date format depending on age of article.
3825 This is an alist of items (AGE . FORMAT). AGE can be a number (of
3826 seconds) or a Lisp expression evaluating to a number. When the age of
3827 the article is less than this number, then use `format-time-string'
3828 with the corresponding FORMAT for displaying the date of the article.
3829 If AGE is not a number or a Lisp expression evaluating to a
3830 non-number, then the corresponding FORMAT is used as a default value.
3831
3832 Note that the list is processed from the beginning, so it should be
3833 sorted by ascending AGE. Also note that items following the first
3834 non-number AGE will be ignored.
3835
3836 You can use the functions `gnus-seconds-today', `gnus-seconds-month'
3837 and `gnus-seconds-year' in the AGE spec. They return the number of
3838 seconds passed since the start of today, of this month, of this year,
3839 respectively."
3840 :version "24.1"
3841 :group 'gnus-summary-format
3842 :type '(alist :key-type sexp :value-type string))
3843
3844 (defun gnus-user-date (messy-date)
3845 "Format the messy-date according to `gnus-user-date-format-alist'.
3846 Returns \" ? \" if there's bad input or if another error occurs.
3847 Input should look like this: \"Sun, 14 Oct 2001 13:34:39 +0200\"."
3848 (condition-case ()
3849 (let* ((messy-date (float-time (gnus-date-get-time messy-date)))
3850 (now (float-time))
3851 ;;If we don't find something suitable we'll use this one
3852 (my-format "%b %d '%y"))
3853 (let* ((difference (- now messy-date))
3854 (templist gnus-user-date-format-alist)
3855 (top (eval (caar templist))))
3856 (while (if (numberp top) (< top difference) (not top))
3857 (progn
3858 (setq templist (cdr templist))
3859 (setq top (eval (caar templist)))))
3860 (if (stringp (cdr (car templist)))
3861 (setq my-format (cdr (car templist)))))
3862 (format-time-string (eval my-format) (seconds-to-time messy-date)))
3863 (error " ? ")))
3864
3865 (defun gnus-summary-set-local-parameters (group)
3866 "Go through the local params of GROUP and set all variable specs in that list."
3867 (let ((vars '(quit-config active))) ; Ignore things that aren't
3868 ; really variables.
3869 (dolist (elem (gnus-group-find-parameter group))
3870 (and (consp elem) ; Has to be a cons.
3871 (consp (cdr elem)) ; The cdr has to be a list.
3872 (symbolp (car elem)) ; Has to be a symbol in there.
3873 (not (memq (car elem) vars))
3874 (ignore-errors
3875 (push (car elem) vars)
3876 ;; Variables like `gnus-show-threads' that are globally
3877 ;; bound, if used as group parameters, need to get to be
3878 ;; buffer-local, whereas just parameters like `gcc-self',
3879 ;; `timestamp', etc. should not be bound as variables.
3880 (if (boundp (car elem))
3881 (set (make-local-variable (car elem)) (eval (nth 1 elem)))
3882 (eval (nth 1 elem))))))))
3883
3884 (defun gnus-summary-read-group (group &optional show-all no-article
3885 kill-buffer no-display backward
3886 select-articles)
3887 "Start reading news in newsgroup GROUP.
3888 If SHOW-ALL is non-nil, already read articles are also listed.
3889 If NO-ARTICLE is non-nil, no article is selected initially.
3890 If NO-DISPLAY, don't generate the summary buffer contents.
3891 If KILL-BUFFER, it should be a buffer that's killed once the new
3892 summary buffer has been generated.
3893 If BACKWARD, move point to the previous group in the group buffer
3894 If SELECT-ARTICLES, only select those articles from GROUP."
3895 (let (result)
3896 (while (and group
3897 (null (setq result
3898 (let ((gnus-auto-select-next nil))
3899 (or (gnus-summary-read-group-1
3900 group show-all no-article
3901 kill-buffer no-display
3902 select-articles)
3903 (setq show-all nil
3904 select-articles nil)))))
3905 (eq gnus-auto-select-next 'quietly))
3906 (set-buffer gnus-group-buffer)
3907 ;; The entry function called above goes to the next
3908 ;; group automatically, so we go two groups back
3909 ;; if we are searching for the previous group.
3910 (when backward
3911 (gnus-group-prev-unread-group 2))
3912 (if (not (equal group (gnus-group-group-name)))
3913 (setq group (gnus-group-group-name))
3914 (setq group nil)))
3915 result))
3916
3917 (defun gnus-summary-read-group-1 (group show-all no-article
3918 kill-buffer no-display
3919 &optional select-articles)
3920 ;; Killed foreign groups can't be entered.
3921 ;; (when (and (not (gnus-group-native-p group))
3922 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3923 ;; (error "Dead non-native groups can't be entered"))
3924 (gnus-message 7 "Retrieving newsgroup: %s..."
3925 (gnus-group-decoded-name group))
3926 (let* ((new-group (gnus-summary-setup-buffer group))
3927 (quit-config (gnus-group-quit-config group))
3928 (did-select (and new-group (gnus-select-newsgroup
3929 group show-all select-articles))))
3930 (cond
3931 ;; This summary buffer exists already, so we just select it.
3932 ((not new-group)
3933 (gnus-set-global-variables)
3934 (when kill-buffer
3935 (gnus-kill-or-deaden-summary kill-buffer))
3936 (gnus-configure-windows 'summary 'force)
3937 (gnus-set-mode-line 'summary)
3938 (gnus-summary-position-point)
3939 (message "")
3940 t)
3941 ;; We couldn't select this group.
3942 ((null did-select)
3943 (when (and (derived-mode-p 'gnus-summary-mode)
3944 (not (equal (current-buffer) kill-buffer)))
3945 (kill-buffer (current-buffer))
3946 (if (not quit-config)
3947 (progn
3948 ;; Update the info -- marks might need to be removed,
3949 ;; for instance.
3950 (gnus-summary-update-info)
3951 (set-buffer gnus-group-buffer)
3952 (gnus-group-jump-to-group group)
3953 (gnus-group-next-unread-group 1))
3954 (gnus-handle-ephemeral-exit quit-config)))
3955 (if (null (gnus-list-of-unread-articles group))
3956 (gnus-message 3 "Group %s contains no messages"
3957 (gnus-group-decoded-name group))
3958 (gnus-message 3 "Can't select group"))
3959 nil)
3960 ;; The user did a `C-g' while prompting for number of articles,
3961 ;; so we exit this group.
3962 ((eq did-select 'quit)
3963 (and (derived-mode-p 'gnus-summary-mode)
3964 (not (equal (current-buffer) kill-buffer))
3965 (kill-buffer (current-buffer)))
3966 (when kill-buffer
3967 (gnus-kill-or-deaden-summary kill-buffer))
3968 (if (not quit-config)
3969 (progn
3970 (set-buffer gnus-group-buffer)
3971 (gnus-group-jump-to-group group)
3972 (gnus-configure-windows 'group 'force))
3973 (gnus-handle-ephemeral-exit quit-config))
3974 ;; Finally signal the quit.
3975 (signal 'quit nil))
3976 ;; The group was successfully selected.
3977 (t
3978 (gnus-set-global-variables)
3979 (when (boundp 'spam-install-hooks)
3980 (spam-initialize))
3981 ;; Save the active value in effect when the group was entered.
3982 (setq gnus-newsgroup-active
3983 (gnus-copy-sequence
3984 (gnus-active gnus-newsgroup-name)))
3985 (setq gnus-newsgroup-highest (cdr gnus-newsgroup-active))
3986 ;; You can change the summary buffer in some way with this hook.
3987 (gnus-run-hooks 'gnus-select-group-hook)
3988 (when (memq 'summary (gnus-update-format-specifications
3989 nil 'summary 'summary-mode 'summary-dummy))
3990 ;; The format specification for the summary line was updated,
3991 ;; so we need to update the mark positions as well.
3992 (gnus-update-summary-mark-positions))
3993 ;; Do score processing.
3994 (when gnus-use-scoring
3995 (gnus-possibly-score-headers))
3996 ;; Check whether to fill in the gaps in the threads.
3997 (when gnus-build-sparse-threads
3998 (gnus-build-sparse-threads))
3999 ;; Find the initial limit.
4000 (if show-all
4001 (let ((gnus-newsgroup-dormant nil))
4002 (gnus-summary-initial-limit show-all))
4003 (gnus-summary-initial-limit show-all))
4004 ;; Generate the summary buffer.
4005 (unless no-display
4006 (gnus-summary-prepare))
4007 (when gnus-use-trees
4008 (gnus-tree-open)
4009 (setq gnus-summary-highlight-line-function
4010 'gnus-tree-highlight-article))
4011 ;; If the summary buffer is empty, but there are some low-scored
4012 ;; articles or some excluded dormants, we include these in the
4013 ;; buffer.
4014 (when (and (zerop (buffer-size))
4015 (not no-display))
4016 (cond (gnus-newsgroup-dormant
4017 (gnus-summary-limit-include-dormant))
4018 ((and gnus-newsgroup-scored show-all)
4019 (gnus-summary-limit-include-expunged t))))
4020 ;; Function `gnus-apply-kill-file' must be called in this hook.
4021 (gnus-run-hooks 'gnus-apply-kill-hook)
4022 (if (and (zerop (buffer-size))
4023 (not no-display))
4024 (progn
4025 ;; This newsgroup is empty.
4026 (gnus-summary-catchup-and-exit nil t)
4027 (gnus-message 6 "No unread news")
4028 (when kill-buffer
4029 (gnus-kill-or-deaden-summary kill-buffer))
4030 ;; Return nil from this function.
4031 nil)
4032 ;; Hide conversation thread subtrees. We cannot do this in
4033 ;; gnus-summary-prepare-hook since kill processing may not
4034 ;; work with hidden articles.
4035 (gnus-summary-maybe-hide-threads)
4036 (gnus-configure-windows 'summary)
4037 (when kill-buffer
4038 (gnus-kill-or-deaden-summary kill-buffer))
4039 (gnus-summary-auto-select-subject)
4040 ;; Show first unread article if requested.
4041 (if (and (not no-article)
4042 (not no-display)
4043 gnus-newsgroup-unreads
4044 gnus-auto-select-first)
4045 (progn
4046 (let ((art (gnus-summary-article-number)))
4047 (when (and art
4048 gnus-plugged
4049 (not (memq art gnus-newsgroup-undownloaded))
4050 (not (memq art gnus-newsgroup-downloadable)))
4051 (gnus-summary-goto-article art))))
4052 ;; Don't select any articles.
4053 (gnus-summary-position-point)
4054 (gnus-configure-windows 'summary 'force)
4055 (gnus-set-mode-line 'summary))
4056 (when (and gnus-auto-center-group
4057 (get-buffer-window gnus-group-buffer t))
4058 ;; Gotta use windows, because recenter does weird stuff if
4059 ;; the current buffer ain't the displayed window.
4060 (let ((owin (selected-window)))
4061 (select-window (get-buffer-window gnus-group-buffer t))
4062 (when (gnus-group-goto-group group)
4063 (recenter))
4064 (select-window owin)))
4065 ;; Mark this buffer as "prepared".
4066 (setq gnus-newsgroup-prepared t)
4067 (gnus-run-hooks 'gnus-summary-prepared-hook)
4068 (unless (gnus-ephemeral-group-p group)
4069 (gnus-group-update-group group nil t))
4070 t)))))
4071
4072 (defun gnus-summary-auto-select-subject ()
4073 "Select the subject line on initial group entry."
4074 (goto-char (point-min))
4075 (cond
4076 ((eq gnus-auto-select-subject 'best)
4077 (gnus-summary-best-unread-subject))
4078 ((eq gnus-auto-select-subject 'unread)
4079 (gnus-summary-first-unread-subject))
4080 ((eq gnus-auto-select-subject 'unseen)
4081 (gnus-summary-first-unseen-subject))
4082 ((eq gnus-auto-select-subject 'unseen-or-unread)
4083 (gnus-summary-first-unseen-or-unread-subject))
4084 ((eq gnus-auto-select-subject 'first)
4085 ;; Do nothing.
4086 )
4087 ((functionp gnus-auto-select-subject)
4088 (funcall gnus-auto-select-subject))))
4089
4090 (defun gnus-summary-prepare ()
4091 "Generate the summary buffer."
4092 (interactive)
4093 (let ((inhibit-read-only t))
4094 (erase-buffer)
4095 (setq gnus-newsgroup-data nil
4096 gnus-newsgroup-data-reverse nil)
4097 (gnus-run-hooks 'gnus-summary-generate-hook)
4098 ;; Generate the buffer, either with threads or without.
4099 (when gnus-newsgroup-headers
4100 (gnus-summary-prepare-threads
4101 (if gnus-show-threads
4102 (gnus-sort-gathered-threads
4103 (funcall gnus-summary-thread-gathering-function
4104 (gnus-sort-threads
4105 (gnus-cut-threads (gnus-make-threads)))))
4106 ;; Unthreaded display.
4107 (gnus-sort-articles gnus-newsgroup-headers))))
4108 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
4109 ;; Call hooks for modifying summary buffer.
4110 (goto-char (point-min))
4111 (gnus-run-hooks 'gnus-summary-prepare-hook)))
4112
4113 (defsubst gnus-general-simplify-subject (subject)
4114 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
4115 (setq subject
4116 (cond
4117 ;; Truncate the subject.
4118 (gnus-simplify-subject-functions
4119 (gnus-map-function gnus-simplify-subject-functions subject))
4120 ((numberp gnus-summary-gather-subject-limit)
4121 (setq subject (gnus-simplify-subject-re subject))
4122 (if (> (length subject) gnus-summary-gather-subject-limit)
4123 (substring subject 0 gnus-summary-gather-subject-limit)
4124 subject))
4125 ;; Fuzzily simplify it.
4126 ((eq 'fuzzy gnus-summary-gather-subject-limit)
4127 (gnus-simplify-subject-fuzzy subject))
4128 ;; Just remove the leading "Re:".
4129 (t
4130 (gnus-simplify-subject-re subject))))
4131
4132 (if (and gnus-summary-gather-exclude-subject
4133 (string-match gnus-summary-gather-exclude-subject subject))
4134 nil ; This article shouldn't be gathered
4135 subject))
4136
4137 (defun gnus-summary-simplify-subject-query ()
4138 "Query where the respool algorithm would put this article."
4139 (interactive)
4140 (gnus-summary-select-article)
4141 (message "%s" (gnus-general-simplify-subject (gnus-summary-article-subject))))
4142
4143 (defun gnus-gather-threads-by-subject (threads)
4144 "Gather threads by looking at Subject headers."
4145 (if (not gnus-summary-make-false-root)
4146 threads
4147 (let ((hashtb (gnus-make-hashtable 1024))
4148 (prev threads)
4149 (result threads)
4150 subject hthread whole-subject)
4151 (while threads
4152 (setq subject (gnus-general-simplify-subject
4153 (setq whole-subject (mail-header-subject
4154 (caar threads)))))
4155 (when subject
4156 (if (setq hthread (gnus-gethash subject hashtb))
4157 (progn
4158 ;; We enter a dummy root into the thread, if we
4159 ;; haven't done that already.
4160 (unless (stringp (caar hthread))
4161 (setcar hthread (list whole-subject (car hthread))))
4162 ;; We add this new gathered thread to this gathered
4163 ;; thread.
4164 (setcdr (car hthread)
4165 (nconc (cdar hthread) (list (car threads))))
4166 ;; Remove it from the list of threads.
4167 (setcdr prev (cdr threads))
4168 (setq threads prev))
4169 ;; Enter this thread into the hash table.
4170 (gnus-sethash subject
4171 (if gnus-summary-make-false-root-always
4172 (progn
4173 ;; If you want a dummy root above all
4174 ;; threads...
4175 (setcar threads (list whole-subject
4176 (car threads)))
4177 threads)
4178 threads)
4179 hashtb)))
4180 (setq prev threads)
4181 (setq threads (cdr threads)))
4182 result)))
4183
4184 (defun gnus-gather-threads-by-references (threads)
4185 "Gather threads by looking at References headers."
4186 (let ((idhashtb (gnus-make-hashtable 1024))
4187 (thhashtb (gnus-make-hashtable 1024))
4188 (prev threads)
4189 (result threads)
4190 ids references id gthread gid entered ref)
4191 (while threads
4192 (when (setq references (mail-header-references (caar threads)))
4193 (setq id (mail-header-id (caar threads))
4194 ids (inline (gnus-split-references references))
4195 entered nil)
4196 (while (setq ref (pop ids))
4197 (setq ids (delete ref ids))
4198 (if (not (setq gid (gnus-gethash ref idhashtb)))
4199 (progn
4200 (gnus-sethash ref id idhashtb)
4201 (gnus-sethash id threads thhashtb))
4202 (setq gthread (gnus-gethash gid thhashtb))
4203 (unless entered
4204 ;; We enter a dummy root into the thread, if we
4205 ;; haven't done that already.
4206 (unless (stringp (caar gthread))
4207 (setcar gthread (list (mail-header-subject (caar gthread))
4208 (car gthread))))
4209 ;; We add this new gathered thread to this gathered
4210 ;; thread.
4211 (setcdr (car gthread)
4212 (nconc (cdar gthread) (list (car threads)))))
4213 ;; Add it into the thread hash table.
4214 (gnus-sethash id gthread thhashtb)
4215 (setq entered t)
4216 ;; Remove it from the list of threads.
4217 (setcdr prev (cdr threads))
4218 (setq threads prev))))
4219 (setq prev threads)
4220 (setq threads (cdr threads)))
4221 result))
4222
4223 (defun gnus-sort-gathered-threads (threads)
4224 "Sort subthreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
4225 (let ((result threads))
4226 (while threads
4227 (when (stringp (caar threads))
4228 (setcdr (car threads)
4229 (sort (cdar threads) gnus-sort-gathered-threads-function)))
4230 (setq threads (cdr threads)))
4231 result))
4232
4233 (defun gnus-thread-loop-p (root thread)
4234 "Say whether ROOT is in THREAD."
4235 (let ((stack (list thread))
4236 (infloop 0)
4237 th)
4238 (while (setq thread (pop stack))
4239 (setq th (cdr thread))
4240 (while (and th
4241 (not (eq (caar th) root)))
4242 (pop th))
4243 (if th
4244 ;; We have found a loop.
4245 (let (ref-dep)
4246 (setcdr thread (delq (car th) (cdr thread)))
4247 (if (boundp (setq ref-dep (intern "none"
4248 gnus-newsgroup-dependencies)))
4249 (setcdr (symbol-value ref-dep)
4250 (nconc (cdr (symbol-value ref-dep))
4251 (list (car th))))
4252 (set ref-dep (list nil (car th))))
4253 (setq infloop 1
4254 stack nil))
4255 ;; Push all the subthreads onto the stack.
4256 (push (cdr thread) stack)))
4257 infloop))
4258
4259 (defun gnus-make-threads ()
4260 "Go through the dependency hashtb and find the roots. Return all threads."
4261 (let (threads)
4262 (while (catch 'infloop
4263 (mapatoms
4264 (lambda (refs)
4265 ;; Deal with self-referencing References loops.
4266 (when (and (car (symbol-value refs))
4267 (not (zerop
4268 (apply
4269 '+
4270 (mapcar
4271 (lambda (thread)
4272 (gnus-thread-loop-p
4273 (car (symbol-value refs)) thread))
4274 (cdr (symbol-value refs)))))))
4275 (setq threads nil)
4276 (throw 'infloop t))
4277 (unless (car (symbol-value refs))
4278 ;; These threads do not refer back to any other
4279 ;; articles, so they're roots.
4280 (setq threads (append (cdr (symbol-value refs)) threads))))
4281 gnus-newsgroup-dependencies)))
4282 threads))
4283
4284 ;; Build the thread tree.
4285 (defsubst gnus-dependencies-add-header (header dependencies force-new)
4286 "Enter HEADER into the DEPENDENCIES table if it is not already there.
4287
4288 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
4289 if it was already present.
4290
4291 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
4292 will not be entered in the DEPENDENCIES table. Otherwise duplicate
4293 Message-IDs will be renamed to a unique Message-ID before being
4294 entered.
4295
4296 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
4297 (let* ((id (mail-header-id header))
4298 (id-dep (and id (intern id dependencies)))
4299 parent-id ref ref-dep ref-header replaced)
4300 ;; Enter this `header' in the `dependencies' table.
4301 (cond
4302 ((not id-dep)
4303 (setq header nil))
4304 ;; The first two cases do the normal part: enter a new `header'
4305 ;; in the `dependencies' table.
4306 ((not (boundp id-dep))
4307 (set id-dep (list header)))
4308 ((null (car (symbol-value id-dep)))
4309 (setcar (symbol-value id-dep) header))
4310
4311 ;; From here the `header' was already present in the
4312 ;; `dependencies' table.
4313 (force-new
4314 ;; Overrides an existing entry;
4315 ;; just set the header part of the entry.
4316 (setcar (symbol-value id-dep) header)
4317 (setq replaced t))
4318
4319 ;; Renames the existing `header' to a unique Message-ID.
4320 ((not gnus-summary-ignore-duplicates)
4321 ;; An article with this Message-ID has already been seen.
4322 ;; We rename the Message-ID.
4323 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
4324 (list header))
4325 (mail-header-set-id header id))
4326
4327 ;; The last case ignores an existing entry, except it adds any
4328 ;; additional Xrefs (in case the two articles came from different
4329 ;; servers.
4330 ;; Also sets `header' to nil meaning that the `dependencies'
4331 ;; table was *not* modified.
4332 (t
4333 (mail-header-set-xref
4334 (car (symbol-value id-dep))
4335 (concat (or (mail-header-xref (car (symbol-value id-dep)))
4336 "")
4337 (or (mail-header-xref header) "")))
4338 (setq header nil)))
4339
4340 (when (and header (not replaced))
4341 ;; First check that we are not creating a References loop.
4342 (setq parent-id (gnus-parent-id (mail-header-references header)))
4343 (setq ref parent-id)
4344 (while (and ref
4345 (setq ref-dep (intern-soft ref dependencies))
4346 (boundp ref-dep)
4347 (setq ref-header (car (symbol-value ref-dep))))
4348 (if (string= id ref)
4349 ;; Yuk! This is a reference loop. Make the article be a
4350 ;; root article.
4351 (progn
4352 (mail-header-set-references (car (symbol-value id-dep)) "none")
4353 (setq ref nil)
4354 (setq parent-id nil))
4355 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
4356 (setq ref-dep (intern (or parent-id "none") dependencies))
4357 (if (boundp ref-dep)
4358 (setcdr (symbol-value ref-dep)
4359 (nconc (cdr (symbol-value ref-dep))
4360 (list (symbol-value id-dep))))
4361 (set ref-dep (list nil (symbol-value id-dep)))))
4362 header))
4363
4364 (defun gnus-extract-message-id-from-in-reply-to (string)
4365 (if (string-match "<[^>]+>" string)
4366 (substring string (match-beginning 0) (match-end 0))
4367 nil))
4368
4369 (defun gnus-build-sparse-threads ()
4370 (let ((headers gnus-newsgroup-headers)
4371 (mail-parse-charset gnus-newsgroup-charset)
4372 (gnus-summary-ignore-duplicates t)
4373 header references generation relations
4374 subject child end new-child date)
4375 ;; First we create an alist of generations/relations, where
4376 ;; generations is how much we trust the relation, and the relation
4377 ;; is parent/child.
4378 (gnus-message 7 "Making sparse threads...")
4379 (save-excursion
4380 (nnheader-set-temp-buffer " *gnus sparse threads*")
4381 (while (setq header (pop headers))
4382 (when (and (setq references (mail-header-references header))
4383 (not (string= references "")))
4384 (insert references)
4385 (setq child (mail-header-id header)
4386 subject (mail-header-subject header)
4387 date (mail-header-date header)
4388 generation 0)
4389 (while (search-backward ">" nil t)
4390 (setq end (1+ (point)))
4391 (when (search-backward "<" nil t)
4392 (setq new-child (buffer-substring (point) end))
4393 (push (list (incf generation)
4394 child (setq child new-child)
4395 subject date)
4396 relations)))
4397 (when child
4398 (push (list (1+ generation) child nil subject) relations))
4399 (erase-buffer)))
4400 (kill-buffer (current-buffer)))
4401 ;; Sort over trustworthiness.
4402 (dolist (relation (sort relations 'car-less-than-car))
4403 (when (gnus-dependencies-add-header
4404 (make-full-mail-header
4405 gnus-reffed-article-number
4406 (nth 3 relation) "" (or (nth 4 relation) "")
4407 (nth 1 relation)
4408 (or (nth 2 relation) "") 0 0 "")
4409 gnus-newsgroup-dependencies nil)
4410 (push gnus-reffed-article-number gnus-newsgroup-limit)
4411 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4412 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4413 gnus-newsgroup-reads)
4414 (decf gnus-reffed-article-number)))
4415 (gnus-message 7 "Making sparse threads...done")))
4416
4417 (defun gnus-build-old-threads ()
4418 ;; Look at all the articles that refer back to old articles, and
4419 ;; fetch the headers for the articles that aren't there. This will
4420 ;; build complete threads - if the roots haven't been expired by the
4421 ;; server, that is.
4422 (let ((mail-parse-charset gnus-newsgroup-charset)
4423 id heads)
4424 (mapatoms
4425 (lambda (refs)
4426 (when (not (car (symbol-value refs)))
4427 (setq heads (cdr (symbol-value refs)))
4428 (while heads
4429 (if (memq (mail-header-number (caar heads))
4430 gnus-newsgroup-dormant)
4431 (setq heads (cdr heads))
4432 (setq id (symbol-name refs))
4433 (while (and (setq id (gnus-build-get-header id))
4434 (not (car (gnus-id-to-thread id)))))
4435 (setq heads nil)))))
4436 gnus-newsgroup-dependencies)))
4437
4438 (defsubst gnus-remove-odd-characters (string)
4439 "Translate STRING into something that doesn't contain weird characters."
4440 (subst-char-in-string
4441 ?\r ?\-
4442 (subst-char-in-string ?\n ?\- string t) t))
4443
4444 ;; This function has to be called with point after the article number
4445 ;; on the beginning of the line.
4446 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4447 (let ((eol (point-at-eol))
4448 (buffer (current-buffer))
4449 header references in-reply-to)
4450
4451 ;; overview: [num subject from date id refs chars lines misc]
4452 (unwind-protect
4453 (let (x)
4454 (narrow-to-region (point) eol)
4455 (unless (eobp)
4456 (forward-char))
4457
4458 (setq header
4459 (make-full-mail-header
4460 number ; number
4461 (condition-case () ; subject
4462 (gnus-remove-odd-characters
4463 (funcall gnus-decode-encoded-word-function
4464 (setq x (nnheader-nov-field))))
4465 (error x))
4466 (condition-case () ; from
4467 (gnus-remove-odd-characters
4468 (funcall gnus-decode-encoded-address-function
4469 (setq x (nnheader-nov-field))))
4470 (error x))
4471 (nnheader-nov-field) ; date
4472 (nnheader-nov-read-message-id number) ; id
4473 (setq references (nnheader-nov-field)) ; refs
4474 (nnheader-nov-read-integer) ; chars
4475 (nnheader-nov-read-integer) ; lines
4476 (unless (eobp)
4477 (if (looking-at "Xref: ")
4478 (goto-char (match-end 0)))
4479 (nnheader-nov-field)) ; Xref
4480 (nnheader-nov-parse-extra)))) ; extra
4481
4482 (widen))
4483
4484 (when (and (string= references "")
4485 (setq in-reply-to (mail-header-extra header))
4486 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4487 (mail-header-set-references
4488 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4489
4490 (when gnus-alter-header-function
4491 (funcall gnus-alter-header-function header))
4492 (gnus-dependencies-add-header header dependencies force-new)))
4493
4494 (defun gnus-build-get-header (id)
4495 "Look through the buffer of NOV lines and find the header to ID.
4496 Enter this line into the dependencies hash table, and return
4497 the id of the parent article (if any)."
4498 (let ((deps gnus-newsgroup-dependencies)
4499 found header)
4500 (prog1
4501 (with-current-buffer nntp-server-buffer
4502 (let ((case-fold-search nil))
4503 (goto-char (point-min))
4504 (while (and (not found)
4505 (search-forward id nil t))
4506 (beginning-of-line)
4507 (setq found (looking-at
4508 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4509 (regexp-quote id))))
4510 (or found (beginning-of-line 2)))
4511 (when found
4512 (beginning-of-line)
4513 (and
4514 (setq header (gnus-nov-parse-line
4515 (read (current-buffer)) deps))
4516 (gnus-parent-id (mail-header-references header))))))
4517 (when header
4518 (let ((number (mail-header-number header)))
4519 (push number gnus-newsgroup-limit)
4520 (push header gnus-newsgroup-headers)
4521 (if (memq number gnus-newsgroup-unselected)
4522 (progn
4523 (setq gnus-newsgroup-unreads
4524 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4525 number))
4526 (setq gnus-newsgroup-unselected
4527 (delq number gnus-newsgroup-unselected)))
4528 (push number gnus-newsgroup-ancient)))))))
4529
4530 (defun gnus-build-all-threads ()
4531 "Read all the headers."
4532 (let ((gnus-summary-ignore-duplicates t)
4533 (mail-parse-charset gnus-newsgroup-charset)
4534 (dependencies gnus-newsgroup-dependencies)
4535 header article)
4536 (with-current-buffer nntp-server-buffer
4537 (let ((case-fold-search nil))
4538 (goto-char (point-min))
4539 (while (not (eobp))
4540 (ignore-errors
4541 (setq article (read (current-buffer))
4542 header (gnus-nov-parse-line article dependencies t)))
4543 (when header
4544 (with-current-buffer gnus-summary-buffer
4545 (push header gnus-newsgroup-headers)
4546 (if (memq (setq article (mail-header-number header))
4547 gnus-newsgroup-unselected)
4548 (progn
4549 (setq gnus-newsgroup-unreads
4550 (gnus-add-to-sorted-list
4551 gnus-newsgroup-unreads article))
4552 (setq gnus-newsgroup-unselected
4553 (delq article gnus-newsgroup-unselected)))
4554 (push article gnus-newsgroup-ancient)))
4555 (forward-line 1)))))))
4556
4557 (defun gnus-summary-update-article-line (article header)
4558 "Update the line for ARTICLE using HEADER."
4559 (let* ((id (mail-header-id header))
4560 (thread (gnus-id-to-thread id)))
4561 (unless thread
4562 (error "Article in no thread"))
4563 ;; Update the thread.
4564 (setcar thread header)
4565 (gnus-summary-goto-subject article)
4566 (let* ((datal (gnus-data-find-list article))
4567 (data (car datal))
4568 (inhibit-read-only t)
4569 (level (gnus-summary-thread-level)))
4570 (gnus-delete-line)
4571 (let ((inserted (- (point)
4572 (progn
4573 (gnus-summary-insert-line
4574 header level nil
4575 (memq article gnus-newsgroup-undownloaded)
4576 (gnus-article-mark article)
4577 (memq article gnus-newsgroup-replied)
4578 (memq article gnus-newsgroup-expirable)
4579 ;; Only insert the Subject string when it's different
4580 ;; from the previous Subject string.
4581 (if (and
4582 gnus-show-threads
4583 (gnus-subject-equal
4584 (condition-case ()
4585 (mail-header-subject
4586 (gnus-data-header
4587 (cadr
4588 (gnus-data-find-list
4589 article
4590 (gnus-data-list t)))))
4591 ;; Error on the side of excessive subjects.
4592 (error ""))
4593 (mail-header-subject header)))
4594 ""
4595 (mail-header-subject header))
4596 nil (cdr (assq article gnus-newsgroup-scored))
4597 (memq article gnus-newsgroup-processable))
4598 (point)))))
4599 (when (cdr datal)
4600 (gnus-data-update-list
4601 (cdr datal)
4602 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4603
4604 (defun gnus-summary-update-article (article &optional iheader)
4605 "Update ARTICLE in the summary buffer."
4606 (set-buffer gnus-summary-buffer)
4607 (let* ((header (gnus-summary-article-header article))
4608 (id (mail-header-id header))
4609 (data (gnus-data-find article))
4610 (thread (gnus-id-to-thread id))
4611 (references (mail-header-references header))
4612 (parent
4613 (gnus-id-to-thread
4614 (or (gnus-parent-id
4615 (when (and references
4616 (not (equal "" references)))
4617 references))
4618 "none")))
4619 (inhibit-read-only t)
4620 (old (car thread)))
4621 (when thread
4622 (unless iheader
4623 (setcar thread nil)
4624 (when parent
4625 (delq thread parent)))
4626 (if (gnus-summary-insert-subject id header)
4627 ;; Set the (possibly) new article number in the data structure.
4628 (gnus-data-set-number data (gnus-id-to-article id))
4629 (setcar thread old)
4630 nil))))
4631
4632 (defun gnus-rebuild-thread (id &optional line)
4633 "Rebuild the thread containing ID.
4634 If LINE, insert the rebuilt thread starting on line LINE."
4635 (let ((inhibit-read-only t)
4636 old-pos current thread data)
4637 (if (not gnus-show-threads)
4638 (setq thread (list (car (gnus-id-to-thread id))))
4639 ;; Get the thread this article is part of.
4640 (setq thread (gnus-remove-thread id)))
4641 (setq old-pos (point-at-bol))
4642 (setq current (save-excursion
4643 (and (re-search-backward "[\r\n]" nil t)
4644 (gnus-summary-article-number))))
4645 ;; If this is a gathered thread, we have to go some re-gathering.
4646 (when (stringp (car thread))
4647 (let ((subject (car thread))
4648 roots thr)
4649 (setq thread (cdr thread))
4650 (while thread
4651 (unless (memq (setq thr (gnus-id-to-thread
4652 (gnus-root-id
4653 (mail-header-id (caar thread)))))
4654 roots)
4655 (push thr roots))
4656 (setq thread (cdr thread)))
4657 ;; We now have all (unique) roots.
4658 (if (= (length roots) 1)
4659 ;; All the loose roots are now one solid root.
4660 (setq thread (car roots))
4661 (setq thread (cons subject (gnus-sort-threads roots))))))
4662 (let (threads)
4663 ;; We then insert this thread into the summary buffer.
4664 (when line
4665 (goto-char (point-min))
4666 (forward-line (1- line)))
4667 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4668 (if gnus-show-threads
4669 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4670 (gnus-summary-prepare-unthreaded thread))
4671 (setq data (nreverse gnus-newsgroup-data))
4672 (setq threads gnus-newsgroup-threads))
4673 ;; We splice the new data into the data structure.
4674 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4675 ;;!!! then we want to insert at the beginning of the buffer.
4676 ;;!!! That happens to be true with Gnus now, but that may
4677 ;;!!! change in the future. Perhaps.
4678 (gnus-data-enter-list
4679 (if line nil current) data (- (point) old-pos))
4680 (setq gnus-newsgroup-threads
4681 (nconc threads gnus-newsgroup-threads))
4682 (gnus-data-compute-positions))))
4683
4684 (defun gnus-number-to-header (number)
4685 "Return the header for article NUMBER."
4686 (let ((headers gnus-newsgroup-headers))
4687 (while (and headers
4688 (not (= number (mail-header-number (car headers)))))
4689 (pop headers))
4690 (when headers
4691 (car headers))))
4692
4693 (defun gnus-parent-headers (in-headers &optional generation)
4694 "Return the headers of the GENERATIONth parent of HEADERS."
4695 (unless generation
4696 (setq generation 1))
4697 (let ((parent t)
4698 (headers in-headers)
4699 references)
4700 (while (and parent
4701 (not (zerop generation))
4702 (setq references (mail-header-references headers)))
4703 (setq headers (if (and references
4704 (setq parent (gnus-parent-id references)))
4705 (car (gnus-id-to-thread parent))
4706 nil))
4707 (decf generation))
4708 (and (not (eq headers in-headers))
4709 headers)))
4710
4711 (defun gnus-id-to-thread (id)
4712 "Return the (sub-)thread where ID appears."
4713 (gnus-gethash id gnus-newsgroup-dependencies))
4714
4715 (defun gnus-id-to-article (id)
4716 "Return the article number of ID."
4717 (let ((thread (gnus-id-to-thread id)))
4718 (when (and thread
4719 (car thread))
4720 (mail-header-number (car thread)))))
4721
4722 (defun gnus-id-to-header (id)
4723 "Return the article headers of ID."
4724 (car (gnus-id-to-thread id)))
4725
4726 (defun gnus-article-displayed-root-p (article)
4727 "Say whether ARTICLE is a root(ish) article."
4728 (let ((level (gnus-summary-thread-level article))
4729 (refs (mail-header-references (gnus-summary-article-header article)))
4730 particle)
4731 (cond
4732 ((null level) nil)
4733 ((zerop level) t)
4734 ((null refs) t)
4735 ((null (gnus-parent-id refs)) t)
4736 ((and (= 1 level)
4737 (null (setq particle (gnus-id-to-article
4738 (gnus-parent-id refs))))
4739 (null (gnus-summary-thread-level particle)))))))
4740
4741 (defun gnus-root-id (id)
4742 "Return the id of the root of the thread where ID appears."
4743 (let (last-id prev)
4744 (while (and id (setq prev (car (gnus-id-to-thread id))))
4745 (setq last-id id
4746 id (gnus-parent-id (mail-header-references prev))))
4747 last-id))
4748
4749 (defun gnus-articles-in-thread (thread)
4750 "Return the list of articles in THREAD."
4751 (cons (mail-header-number (car thread))
4752 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4753
4754 (defun gnus-remove-thread (id &optional dont-remove)
4755 "Remove the thread that has ID in it."
4756 (let (headers thread last-id)
4757 ;; First go up in this thread until we find the root.
4758 (setq last-id (gnus-root-id id)
4759 headers (message-flatten-list (gnus-id-to-thread last-id)))
4760 ;; We have now found the real root of this thread. It might have
4761 ;; been gathered into some loose thread, so we have to search
4762 ;; through the threads to find the thread we wanted.
4763 (let ((threads gnus-newsgroup-threads)
4764 sub)
4765 (while threads
4766 (setq sub (car threads))
4767 (if (stringp (car sub))
4768 ;; This is a gathered thread, so we look at the roots
4769 ;; below it to find whether this article is in this
4770 ;; gathered root.
4771 (progn
4772 (setq sub (cdr sub))
4773 (while sub
4774 (when (member (caar sub) headers)
4775 (setq thread (car threads)
4776 threads nil
4777 sub nil))
4778 (setq sub (cdr sub))))
4779 ;; It's an ordinary thread, so we check it.
4780 (when (eq (car sub) (car headers))
4781 (setq thread sub
4782 threads nil)))
4783 (setq threads (cdr threads)))
4784 ;; If this article is in no thread, then it's a root.
4785 (if thread
4786 (unless dont-remove
4787 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4788 (setq thread (gnus-id-to-thread last-id)))
4789 (when thread
4790 (prog1
4791 thread ; We return this thread.
4792 (unless dont-remove
4793 (if (stringp (car thread))
4794 (progn
4795 ;; If we use dummy roots, then we have to remove the
4796 ;; dummy root as well.
4797 (when (eq gnus-summary-make-false-root 'dummy)
4798 ;; We go to the dummy root by going to
4799 ;; the first sub-"thread", and then one line up.
4800 (gnus-summary-goto-article
4801 (mail-header-number (caadr thread)))
4802 (forward-line -1)
4803 (gnus-delete-line)
4804 (gnus-data-compute-positions))
4805 (setq thread (cdr thread))
4806 (while thread
4807 (gnus-remove-thread-1 (car thread))
4808 (setq thread (cdr thread))))
4809 (gnus-remove-thread-1 thread))))))))
4810
4811 (defun gnus-remove-thread-1 (thread)
4812 "Remove the thread THREAD recursively."
4813 (let ((number (mail-header-number (pop thread)))
4814 d)
4815 (setq thread (reverse thread))
4816 (while thread
4817 (gnus-remove-thread-1 (pop thread)))
4818 (when (setq d (gnus-data-find number))
4819 (goto-char (gnus-data-pos d))
4820 (gnus-summary-show-thread)
4821 (gnus-data-remove
4822 number
4823 (- (point-at-bol)
4824 (prog1
4825 (1+ (point-at-eol))
4826 (gnus-delete-line)))))))
4827
4828 (defun gnus-sort-threads-recursive (threads func)
4829 ;; Responsible for sorting the root articles of threads.
4830 (let ((subthread-sort-func (if (eq gnus-subthread-sort-functions
4831 'gnus-thread-sort-functions)
4832 func
4833 (gnus-make-sort-function
4834 gnus-subthread-sort-functions))))
4835 (sort (mapcar (lambda (thread)
4836 (cons (car thread)
4837 (and (cdr thread)
4838 (gnus-sort-subthreads-recursive
4839 (cdr thread) subthread-sort-func))))
4840 threads) func)))
4841
4842 (defun gnus-sort-subthreads-recursive (threads func)
4843 ;; Responsible for sorting subthreads.
4844 (sort (mapcar (lambda (thread)
4845 (cons (car thread)
4846 (and (cdr thread)
4847 (gnus-sort-subthreads-recursive (cdr thread) func))))
4848 threads) func))
4849
4850 (defun gnus-sort-threads-loop (threads func)
4851 (let* ((superthread (cons nil threads))
4852 (stack (list (cons superthread threads)))
4853 remaining-threads thread)
4854 (while stack
4855 (setq remaining-threads (cdr (car stack)))
4856 (if remaining-threads
4857 (progn (setq thread (car remaining-threads))
4858 (setcdr (car stack) (cdr remaining-threads))
4859 (if (cdr thread)
4860 (push (cons thread (cdr thread)) stack)))
4861 (setq thread (caar stack))
4862 (setcdr thread (sort (cdr thread) func))
4863 (pop stack)))
4864 (cdr superthread)))
4865
4866 (defun gnus-sort-threads (threads)
4867 "Sort THREADS."
4868 (if (not gnus-thread-sort-functions)
4869 threads
4870 (gnus-message 8 "Sorting threads...")
4871 (prog1
4872 (condition-case nil
4873 (let ((max-lisp-eval-depth (max max-lisp-eval-depth 5000))
4874 (sort-func (gnus-make-sort-function gnus-thread-sort-functions)))
4875 (gnus-sort-threads-recursive threads sort-func))
4876 ;; Even after binding max-lisp-eval-depth, the recursive
4877 ;; sorter might fail for very long threads. In that case,
4878 ;; try using a (less well-tested) non-recursive sorter.
4879 (error (gnus-message 9 "Sorting threads with loop...")
4880 (gnus-sort-threads-loop
4881 threads (gnus-make-sort-function
4882 gnus-thread-sort-functions))))
4883 (gnus-message 8 "Sorting threads...done"))))
4884
4885 (defun gnus-sort-articles (articles)
4886 "Sort ARTICLES."
4887 (when gnus-article-sort-functions
4888 (gnus-message 7 "Sorting articles...")
4889 (prog1
4890 (setq gnus-newsgroup-headers
4891 (sort articles (gnus-make-sort-function
4892 gnus-article-sort-functions)))
4893 (gnus-message 7 "Sorting articles...done"))))
4894
4895 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4896 (defmacro gnus-thread-header (thread)
4897 "Return header of first article in THREAD.
4898 Note that THREAD must never, ever be anything else than a variable -
4899 using some other form will lead to serious barfage."
4900 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4901 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4902 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4903 (vector thread) 2))
4904
4905 (defsubst gnus-article-sort-by-number (h1 h2)
4906 "Sort articles by article number."
4907 (< (mail-header-number h1)
4908 (mail-header-number h2)))
4909
4910 (defun gnus-thread-sort-by-number (h1 h2)
4911 "Sort threads by root article number."
4912 (gnus-article-sort-by-number
4913 (gnus-thread-header h1) (gnus-thread-header h2)))
4914
4915 (defsubst gnus-article-sort-by-random (h1 h2)
4916 "Sort articles randomly."
4917 (zerop (random 2)))
4918
4919 (defun gnus-thread-sort-by-random (h1 h2)
4920 "Sort threads randomly."
4921 (gnus-article-sort-by-random
4922 (gnus-thread-header h1) (gnus-thread-header h2)))
4923
4924 (defsubst gnus-article-sort-by-lines (h1 h2)
4925 "Sort articles by article Lines header."
4926 (< (mail-header-lines h1)
4927 (mail-header-lines h2)))
4928
4929 (defun gnus-thread-sort-by-lines (h1 h2)
4930 "Sort threads by root article Lines header."
4931 (gnus-article-sort-by-lines
4932 (gnus-thread-header h1) (gnus-thread-header h2)))
4933
4934 (defsubst gnus-article-sort-by-chars (h1 h2)
4935 "Sort articles by octet length."
4936 (< (mail-header-chars h1)
4937 (mail-header-chars h2)))
4938
4939 (defun gnus-thread-sort-by-chars (h1 h2)
4940 "Sort threads by root article octet length."
4941 (gnus-article-sort-by-chars
4942 (gnus-thread-header h1) (gnus-thread-header h2)))
4943
4944 (defsubst gnus-article-sort-by-author (h1 h2)
4945 "Sort articles by root author."
4946 (gnus-string<
4947 (let ((extract (funcall
4948 gnus-extract-address-components
4949 (mail-header-from h1))))
4950 (or (car extract) (cadr extract) ""))
4951 (let ((extract (funcall
4952 gnus-extract-address-components
4953 (mail-header-from h2))))
4954 (or (car extract) (cadr extract) ""))))
4955
4956 (defun gnus-thread-sort-by-author (h1 h2)
4957 "Sort threads by root author."
4958 (gnus-article-sort-by-author
4959 (gnus-thread-header h1) (gnus-thread-header h2)))
4960
4961 (defsubst gnus-article-sort-by-recipient (h1 h2)
4962 "Sort articles by recipient."
4963 (gnus-string<
4964 (let ((extract (funcall
4965 gnus-extract-address-components
4966 (or (cdr (assq 'To (mail-header-extra h1))) ""))))
4967 (or (car extract) (cadr extract)))
4968 (let ((extract (funcall
4969 gnus-extract-address-components
4970 (or (cdr (assq 'To (mail-header-extra h2))) ""))))
4971 (or (car extract) (cadr extract)))))
4972
4973 (defun gnus-thread-sort-by-recipient (h1 h2)
4974 "Sort threads by root recipient."
4975 (gnus-article-sort-by-recipient
4976 (gnus-thread-header h1) (gnus-thread-header h2)))
4977
4978 (defsubst gnus-article-sort-by-subject (h1 h2)
4979 "Sort articles by root subject."
4980 (gnus-string<
4981 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4982 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4983
4984 (defun gnus-thread-sort-by-subject (h1 h2)
4985 "Sort threads by root subject."
4986 (gnus-article-sort-by-subject
4987 (gnus-thread-header h1) (gnus-thread-header h2)))
4988
4989 (defsubst gnus-article-sort-by-date (h1 h2)
4990 "Sort articles by root article date."
4991 (time-less-p
4992 (gnus-date-get-time (mail-header-date h1))
4993 (gnus-date-get-time (mail-header-date h2))))
4994
4995 (defun gnus-thread-sort-by-date (h1 h2)
4996 "Sort threads by root article date."
4997 (gnus-article-sort-by-date
4998 (gnus-thread-header h1) (gnus-thread-header h2)))
4999
5000 (defsubst gnus-article-sort-by-score (h1 h2)
5001 "Sort articles by root article score.
5002 Unscored articles will be counted as having a score of zero."
5003 (> (or (cdr (assq (mail-header-number h1)
5004 gnus-newsgroup-scored))
5005 gnus-summary-default-score 0)
5006 (or (cdr (assq (mail-header-number h2)
5007 gnus-newsgroup-scored))
5008 gnus-summary-default-score 0)))
5009
5010 (defun gnus-thread-sort-by-score (h1 h2)
5011 "Sort threads by root article score."
5012 (gnus-article-sort-by-score
5013 (gnus-thread-header h1) (gnus-thread-header h2)))
5014
5015 (defun gnus-thread-sort-by-total-score (h1 h2)
5016 "Sort threads by the sum of all scores in the thread.
5017 Unscored articles will be counted as having a score of zero."
5018 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
5019
5020 (defun gnus-thread-total-score (thread)
5021 ;; This function find the total score of THREAD.
5022 (cond
5023 ((null thread)
5024 0)
5025 ((consp thread)
5026 (if (stringp (car thread))
5027 (apply gnus-thread-score-function 0
5028 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
5029 (gnus-thread-total-score-1 thread)))
5030 (t
5031 (gnus-thread-total-score-1 (list thread)))))
5032
5033 (defun gnus-article-sort-by-most-recent-number (h1 h2)
5034 "Sort articles by number."
5035 (gnus-article-sort-by-number h1 h2))
5036
5037 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
5038 "Sort threads such that the thread with the most recently arrived article comes first."
5039 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
5040
5041 (defun gnus-thread-highest-number (thread)
5042 "Return the highest article number in THREAD."
5043 (apply 'max (mapcar (lambda (header)
5044 (mail-header-number header))
5045 (message-flatten-list thread))))
5046
5047 (defun gnus-article-sort-by-most-recent-date (h1 h2)
5048 "Sort articles by number."
5049 (gnus-article-sort-by-date h1 h2))
5050
5051 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
5052 "Sort threads such that the thread with the most recently dated article comes first."
5053 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
5054
5055 ; Since this is called not only to sort the top-level threads, but
5056 ; also in recursive sorts to order the articles within a thread, each
5057 ; article will be processed many times. Thus it speeds things up
5058 ; quite a bit to use gnus-date-get-time, which caches the time value.
5059 (defun gnus-thread-latest-date (thread)
5060 "Return the highest article date in THREAD."
5061 (apply 'max
5062 (mapcar (lambda (header) (float-time
5063 (gnus-date-get-time
5064 (mail-header-date header))))
5065 (message-flatten-list thread))))
5066
5067 (defun gnus-thread-total-score-1 (root)
5068 ;; This function find the total score of the thread below ROOT.
5069 (setq root (car root))
5070 (apply gnus-thread-score-function
5071 (or (append
5072 (mapcar 'gnus-thread-total-score
5073 (cdr (gnus-id-to-thread (mail-header-id root))))
5074 (when (> (mail-header-number root) 0)
5075 (list (or (cdr (assq (mail-header-number root)
5076 gnus-newsgroup-scored))
5077 gnus-summary-default-score 0))))
5078 (list gnus-summary-default-score)
5079 '(0))))
5080
5081 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
5082 (defvar gnus-tmp-prev-subject nil)
5083 (defvar gnus-tmp-false-parent nil)
5084 (defvar gnus-tmp-root-expunged nil)
5085 (defvar gnus-tmp-dummy-line nil)
5086
5087 (defun gnus-extra-header (type &optional header)
5088 "Return the extra header of TYPE."
5089 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
5090 ""))
5091
5092 (defvar gnus-tmp-thread-tree-header-string "")
5093
5094 (defcustom gnus-sum-thread-tree-root "> "
5095 "With %B spec, used for the root of a thread.
5096 If nil, use subject instead."
5097 :version "22.1"
5098 :type '(radio (const :format "%v " nil) string)
5099 :group 'gnus-thread)
5100
5101 (defcustom gnus-sum-thread-tree-false-root "> "
5102 "With %B spec, used for a false root of a thread.
5103 If nil, use subject instead."
5104 :version "22.1"
5105 :type '(radio (const :format "%v " nil) string)
5106 :group 'gnus-thread)
5107
5108 (defcustom gnus-sum-thread-tree-single-indent ""
5109 "With %B spec, used for a thread with just one message.
5110 If nil, use subject instead."
5111 :version "22.1"
5112 :type '(radio (const :format "%v " nil) string)
5113 :group 'gnus-thread)
5114
5115 (defcustom gnus-sum-thread-tree-vertical "| "
5116 "With %B spec, used for drawing a vertical line."
5117 :version "22.1"
5118 :type 'string
5119 :group 'gnus-thread)
5120
5121 (defcustom gnus-sum-thread-tree-indent " "
5122 "With %B spec, used for indenting."
5123 :version "22.1"
5124 :type 'string
5125 :group 'gnus-thread)
5126
5127 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
5128 "With %B spec, used for a leaf with brothers."
5129 :version "22.1"
5130 :type 'string
5131 :group 'gnus-thread)
5132
5133 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
5134 "With %B spec, used for a leaf without brothers."
5135 :version "22.1"
5136 :type 'string
5137 :group 'gnus-thread)
5138
5139 (defcustom gnus-summary-display-while-building nil
5140 "If non-nil, show and update the summary buffer as it's being built.
5141 If the value is t, update the buffer after every line is inserted. If
5142 the value is an integer (N), update the display every N lines."
5143 :version "22.1"
5144 :group 'gnus-thread
5145 :type '(choice (const :tag "off" nil)
5146 number
5147 (const :tag "frequently" t)))
5148
5149 (defun gnus-summary-prepare-threads (threads)
5150 "Prepare summary buffer from THREADS and indentation LEVEL.
5151 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
5152 or a straight list of headers."
5153 (gnus-message 7 "Generating summary...")
5154
5155 (setq gnus-newsgroup-threads threads)
5156 (beginning-of-line)
5157
5158 (let ((gnus-tmp-level 0)
5159 (default-score (or gnus-summary-default-score 0))
5160 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
5161 (building-line-count gnus-summary-display-while-building)
5162 (building-count (integerp gnus-summary-display-while-building))
5163 thread number subject stack state gnus-tmp-gathered beg-match
5164 new-roots gnus-tmp-new-adopts thread-end simp-subject
5165 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
5166 gnus-tmp-replied gnus-tmp-subject-or-nil
5167 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
5168 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
5169 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
5170 tree-stack)
5171
5172 (setq gnus-tmp-prev-subject nil
5173 gnus-tmp-thread-tree-header-string "")
5174
5175 (if (vectorp (car threads))
5176 ;; If this is a straight (sic) list of headers, then a
5177 ;; threaded summary display isn't required, so we just create
5178 ;; an unthreaded one.
5179 (gnus-summary-prepare-unthreaded threads)
5180
5181 ;; Do the threaded display.
5182
5183 (if gnus-summary-display-while-building
5184 (switch-to-buffer (buffer-name)))
5185 (while (or threads stack gnus-tmp-new-adopts new-roots)
5186
5187 (if (and (= gnus-tmp-level 0)
5188 (or (not stack)
5189 (= (caar stack) 0))
5190 (not gnus-tmp-false-parent)
5191 (or gnus-tmp-new-adopts new-roots))
5192 (if gnus-tmp-new-adopts
5193 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
5194 thread (list (car gnus-tmp-new-adopts))
5195 gnus-tmp-header (caar thread)
5196 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
5197 (when new-roots
5198 (setq thread (list (car new-roots))
5199 gnus-tmp-header (caar thread)
5200 new-roots (cdr new-roots))))
5201
5202 (if threads
5203 ;; If there are some threads, we do them before the
5204 ;; threads on the stack.
5205 (setq thread threads
5206 gnus-tmp-header (caar thread))
5207 ;; There were no current threads, so we pop something off
5208 ;; the stack.
5209 (setq state (car stack)
5210 gnus-tmp-level (car state)
5211 tree-stack (cadr state)
5212 thread (caddr state)
5213 stack (cdr stack)
5214 gnus-tmp-header (caar thread))))
5215
5216 (setq gnus-tmp-false-parent nil)
5217 (setq gnus-tmp-root-expunged nil)
5218 (setq thread-end nil)
5219
5220 (if (stringp gnus-tmp-header)
5221 ;; The header is a dummy root.
5222 (cond
5223 ((eq gnus-summary-make-false-root 'adopt)
5224 ;; We let the first article adopt the rest.
5225 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
5226 (cddar thread)))
5227 (setq gnus-tmp-gathered
5228 (nconc (mapcar
5229 (lambda (h) (mail-header-number (car h)))
5230 (cddar thread))
5231 gnus-tmp-gathered))
5232 (setq thread (cons (list (caar thread)
5233 (cadar thread))
5234 (cdr thread)))
5235 (setq gnus-tmp-level -1
5236 gnus-tmp-false-parent t))
5237 ((eq gnus-summary-make-false-root 'empty)
5238 ;; We print adopted articles with empty subject fields.
5239 (setq gnus-tmp-gathered
5240 (nconc (mapcar
5241 (lambda (h) (mail-header-number (car h)))
5242 (cddar thread))
5243 gnus-tmp-gathered))
5244 (setq gnus-tmp-level -1))
5245 ((eq gnus-summary-make-false-root 'dummy)
5246 ;; We remember that we probably want to output a dummy
5247 ;; root.
5248 (setq gnus-tmp-dummy-line gnus-tmp-header)
5249 (setq gnus-tmp-prev-subject gnus-tmp-header))
5250 (t
5251 ;; We do not make a root for the gathered
5252 ;; sub-threads at all.
5253 (setq gnus-tmp-level -1)))
5254
5255 (setq number (mail-header-number gnus-tmp-header)
5256 subject (mail-header-subject gnus-tmp-header)
5257 simp-subject (gnus-simplify-subject-fully subject))
5258
5259 (cond
5260 ;; If the thread has changed subject, we might want to make
5261 ;; this subthread into a root.
5262 ((and (null gnus-thread-ignore-subject)
5263 (not (zerop gnus-tmp-level))
5264 gnus-tmp-prev-subject
5265 (not (string= gnus-tmp-prev-subject simp-subject)))
5266 (setq new-roots (nconc new-roots (list (car thread)))
5267 thread-end t
5268 gnus-tmp-header nil))
5269 ;; If the article lies outside the current limit,
5270 ;; then we do not display it.
5271 ((not (memq number gnus-newsgroup-limit))
5272 (setq gnus-tmp-gathered
5273 (nconc (mapcar
5274 (lambda (h) (mail-header-number (car h)))
5275 (cdar thread))
5276 gnus-tmp-gathered))
5277 (setq gnus-tmp-new-adopts (if (cdar thread)
5278 (append gnus-tmp-new-adopts
5279 (cdar thread))
5280 gnus-tmp-new-adopts)
5281 thread-end t
5282 gnus-tmp-header nil)
5283 (when (zerop gnus-tmp-level)
5284 (setq gnus-tmp-root-expunged t)))
5285 ;; Perhaps this article is to be marked as read?
5286 ((and gnus-summary-mark-below
5287 (< (or (cdr (assq number gnus-newsgroup-scored))
5288 default-score)
5289 gnus-summary-mark-below)
5290 ;; Don't touch sparse articles.
5291 (not (gnus-summary-article-sparse-p number))
5292 (not (gnus-summary-article-ancient-p number)))
5293 (setq gnus-newsgroup-unreads
5294 (delq number gnus-newsgroup-unreads))
5295 (if gnus-newsgroup-auto-expire
5296 (setq gnus-newsgroup-expirable
5297 (gnus-add-to-sorted-list
5298 gnus-newsgroup-expirable number))
5299 (push (cons number gnus-low-score-mark)
5300 gnus-newsgroup-reads))))
5301
5302 (when gnus-tmp-header
5303 ;; We may have an old dummy line to output before this
5304 ;; article.
5305 (when (and gnus-tmp-dummy-line
5306 (gnus-subject-equal
5307 gnus-tmp-dummy-line
5308 (mail-header-subject gnus-tmp-header)))
5309 (gnus-summary-insert-dummy-line
5310 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
5311 (setq gnus-tmp-dummy-line nil))
5312
5313 ;; Compute the mark.
5314 (setq gnus-tmp-unread (gnus-article-mark number))
5315
5316 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
5317 gnus-tmp-header gnus-tmp-level)
5318 gnus-newsgroup-data)
5319
5320 ;; Actually insert the line.
5321 (setq
5322 gnus-tmp-subject-or-nil
5323 (cond
5324 ((and gnus-thread-ignore-subject
5325 gnus-tmp-prev-subject
5326 (not (string= gnus-tmp-prev-subject simp-subject)))
5327 subject)
5328 ((zerop gnus-tmp-level)
5329 (if (and (eq gnus-summary-make-false-root 'empty)
5330 (memq number gnus-tmp-gathered)
5331 gnus-tmp-prev-subject
5332 (string= gnus-tmp-prev-subject simp-subject))
5333 gnus-summary-same-subject
5334 subject))
5335 (t gnus-summary-same-subject)))
5336 (if (and (eq gnus-summary-make-false-root 'adopt)
5337 (= gnus-tmp-level 1)
5338 (memq number gnus-tmp-gathered))
5339 (setq gnus-tmp-opening-bracket ?\<
5340 gnus-tmp-closing-bracket ?\>)
5341 (setq gnus-tmp-opening-bracket ?\[
5342 gnus-tmp-closing-bracket ?\]))
5343 (if (>= gnus-tmp-level (length gnus-thread-indent-array))
5344 (gnus-make-thread-indent-array
5345 (max (* 2 (length gnus-thread-indent-array))
5346 gnus-tmp-level)))
5347 (setq
5348 gnus-tmp-indentation
5349 (aref gnus-thread-indent-array gnus-tmp-level)
5350 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
5351 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
5352 gnus-summary-default-score 0)
5353 gnus-tmp-score-char
5354 (if (or (null gnus-summary-default-score)
5355 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
5356 gnus-summary-zcore-fuzz))
5357 ? ;Whitespace
5358 (if (< gnus-tmp-score gnus-summary-default-score)
5359 gnus-score-below-mark gnus-score-over-mark))
5360 gnus-tmp-replied
5361 (cond ((memq number gnus-newsgroup-processable)
5362 gnus-process-mark)
5363 ((memq number gnus-newsgroup-cached)
5364 gnus-cached-mark)
5365 ((memq number gnus-newsgroup-replied)
5366 gnus-replied-mark)
5367 ((memq number gnus-newsgroup-forwarded)
5368 gnus-forwarded-mark)
5369 ((memq number gnus-newsgroup-saved)
5370 gnus-saved-mark)
5371 ((memq number gnus-newsgroup-unseen)
5372 gnus-unseen-mark)
5373 (t gnus-no-mark))
5374 gnus-tmp-downloaded
5375 (cond ((memq number gnus-newsgroup-undownloaded)
5376 gnus-undownloaded-mark)
5377 (gnus-newsgroup-agentized
5378 gnus-downloaded-mark)
5379 (t
5380 gnus-no-mark))
5381 gnus-tmp-from (mail-header-from gnus-tmp-header)
5382 gnus-tmp-name
5383 (cond
5384 ((string-match "<[^>]+> *$" gnus-tmp-from)
5385 (setq beg-match (match-beginning 0))
5386 (or (and (string-match "^\".+\"" gnus-tmp-from)
5387 (substring gnus-tmp-from 1 (1- (match-end 0))))
5388 (substring gnus-tmp-from 0 beg-match)))
5389 ((string-match "(.+)" gnus-tmp-from)
5390 (substring gnus-tmp-from
5391 (1+ (match-beginning 0)) (1- (match-end 0))))
5392 (t gnus-tmp-from))
5393
5394 ;; Do the %B string
5395 gnus-tmp-thread-tree-header-string
5396 (cond
5397 ((not gnus-show-threads) "")
5398 ((zerop gnus-tmp-level)
5399 (cond ((cdar thread)
5400 (or gnus-sum-thread-tree-root subject))
5401 (gnus-tmp-new-adopts
5402 (or gnus-sum-thread-tree-false-root subject))
5403 (t
5404 (or gnus-sum-thread-tree-single-indent subject))))
5405 (t
5406 (concat (apply 'concat
5407 (mapcar (lambda (item)
5408 (if (= item 1)
5409 gnus-sum-thread-tree-vertical
5410 gnus-sum-thread-tree-indent))
5411 (cdr (reverse tree-stack))))
5412 (if (nth 1 thread)
5413 gnus-sum-thread-tree-leaf-with-other
5414 gnus-sum-thread-tree-single-leaf)))))
5415 (when (string= gnus-tmp-name "")
5416 (setq gnus-tmp-name gnus-tmp-from))
5417 (unless (numberp gnus-tmp-lines)
5418 (setq gnus-tmp-lines -1))
5419 (if (= gnus-tmp-lines -1)
5420 (setq gnus-tmp-lines "?")
5421 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
5422 (put-text-property
5423 (point)
5424 (progn (eval gnus-summary-line-format-spec) (point))
5425 'gnus-number number)
5426 (when gnus-visual-p
5427 (forward-line -1)
5428 (gnus-summary-highlight-line)
5429 (when gnus-summary-update-hook
5430 (gnus-run-hooks 'gnus-summary-update-hook))
5431 (forward-line 1))
5432
5433 (setq gnus-tmp-prev-subject simp-subject)))
5434
5435 (when (nth 1 thread)
5436 (push (list (max 0 gnus-tmp-level)
5437 (copy-sequence tree-stack)
5438 (nthcdr 1 thread))
5439 stack))
5440 (push (if (nth 1 thread) 1 0) tree-stack)
5441 (incf gnus-tmp-level)
5442 (setq threads (if thread-end nil (cdar thread)))
5443 (if gnus-summary-display-while-building
5444 (if building-count
5445 (progn
5446 ;; use a set frequency
5447 (setq building-line-count (1- building-line-count))
5448 (when (= building-line-count 0)
5449 (sit-for 0)
5450 (setq building-line-count
5451 gnus-summary-display-while-building)))
5452 ;; always
5453 (sit-for 0)))
5454 (unless threads
5455 (setq gnus-tmp-level 0)))))
5456 (gnus-message 7 "Generating summary...done"))
5457
5458 (defun gnus-summary-prepare-unthreaded (headers)
5459 "Generate an unthreaded summary buffer based on HEADERS."
5460 (let (header number mark)
5461
5462 (beginning-of-line)
5463
5464 (while headers
5465 ;; We may have to root out some bad articles...
5466 (when (memq (setq number (mail-header-number
5467 (setq header (pop headers))))
5468 gnus-newsgroup-limit)
5469 ;; Mark article as read when it has a low score.
5470 (when (and gnus-summary-mark-below
5471 (< (or (cdr (assq number gnus-newsgroup-scored))
5472 gnus-summary-default-score 0)
5473 gnus-summary-mark-below)
5474 (not (gnus-summary-article-ancient-p number)))
5475 (setq gnus-newsgroup-unreads
5476 (delq number gnus-newsgroup-unreads))
5477 (if gnus-newsgroup-auto-expire
5478 (push number gnus-newsgroup-expirable)
5479 (push (cons number gnus-low-score-mark)
5480 gnus-newsgroup-reads)))
5481
5482 (setq mark (gnus-article-mark number))
5483 (push (gnus-data-make number mark (1+ (point)) header 0)
5484 gnus-newsgroup-data)
5485 (gnus-summary-insert-line
5486 header 0 number
5487 (memq number gnus-newsgroup-undownloaded)
5488 mark (memq number gnus-newsgroup-replied)
5489 (memq number gnus-newsgroup-expirable)
5490 (mail-header-subject header) nil
5491 (cdr (assq number gnus-newsgroup-scored))
5492 (memq number gnus-newsgroup-processable))))))
5493
5494 (declare-function gnus-parameter-list-identifier "gnus-art" (name) t)
5495
5496 (defun gnus-group-get-list-identifiers (group)
5497 "Get list identifier regexp for GROUP."
5498 (or (gnus-parameter-list-identifier group)
5499 (if (consp gnus-list-identifiers)
5500 (mapconcat 'identity gnus-list-identifiers " *\\|")
5501 gnus-list-identifiers)))
5502
5503 (defun gnus-summary-remove-list-identifiers ()
5504 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5505 (let ((regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
5506 changed subject)
5507 (when regexp
5508 (setq regexp (concat "^\\(?:R[Ee]: +\\)*\\(" regexp " *\\)"))
5509 (dolist (header gnus-newsgroup-headers)
5510 (setq subject (mail-header-subject header)
5511 changed nil)
5512 (while (string-match regexp subject)
5513 (setq subject
5514 (concat (substring subject 0 (match-beginning 1))
5515 (substring subject (match-end 0)))
5516 changed t))
5517 (when changed
5518 (when (string-match "^\\(\\(?:R[Ee]: +\\)+\\)R[Ee]: +" subject)
5519 (setq subject
5520 (concat (substring subject 0 (match-beginning 1))
5521 (substring subject (match-end 1)))))
5522 (mail-header-set-subject header subject))))))
5523
5524 (defun gnus-fetch-headers (articles &optional limit force-new dependencies)
5525 "Fetch headers of ARTICLES."
5526 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5527 (gnus-message 7 "Fetching headers for %s..." name)
5528 (prog1
5529 (if (eq 'nov
5530 (setq gnus-headers-retrieved-by
5531 (gnus-retrieve-headers
5532 articles gnus-newsgroup-name
5533 (or limit
5534 ;; We might want to fetch old headers, but
5535 ;; not if there is only 1 article.
5536 (and (or (and
5537 (not (eq gnus-fetch-old-headers 'some))
5538 (not (numberp gnus-fetch-old-headers)))
5539 (> (length articles) 1))
5540 gnus-fetch-old-headers)))))
5541 (gnus-get-newsgroup-headers-xover
5542 articles force-new dependencies gnus-newsgroup-name t)
5543 (gnus-get-newsgroup-headers dependencies force-new))
5544 (gnus-message 7 "Fetching headers for %s...done" name))))
5545
5546 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5547 "Select newsgroup GROUP.
5548 If READ-ALL is non-nil, all articles in the group are selected.
5549 If SELECT-ARTICLES, only select those articles from GROUP."
5550 (let* ((entry (gnus-group-entry group))
5551 ;;!!! Dirty hack; should be removed.
5552 (gnus-summary-ignore-duplicates
5553 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5554 t
5555 gnus-summary-ignore-duplicates))
5556 (info (nth 2 entry))
5557 charset articles fetched-articles cached)
5558
5559 (unless (gnus-check-server
5560 (set (make-local-variable 'gnus-current-select-method)
5561 (gnus-find-method-for-group group)))
5562 (error "Couldn't open server"))
5563 (setq charset (gnus-group-name-charset gnus-current-select-method group))
5564
5565 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5566 (gnus-activate-group group) ; Or we can activate it...
5567 (progn ; Or we bug out.
5568 (when (derived-mode-p 'gnus-summary-mode)
5569 (gnus-kill-buffer (current-buffer)))
5570 (error
5571 "Couldn't activate group %s: %s"
5572 (decode-coding-string group charset)
5573 (decode-coding-string (gnus-status-message group) charset))))
5574
5575 (unless (gnus-request-group group t nil (gnus-get-info group))
5576 (when (derived-mode-p 'gnus-summary-mode)
5577 (gnus-kill-buffer (current-buffer)))
5578 (error "Couldn't request group %s: %s"
5579 (decode-coding-string group charset)
5580 (decode-coding-string (gnus-status-message group) charset)))
5581
5582 (when (and gnus-agent
5583 (gnus-active group))
5584 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5585
5586 (setq gnus-summary-use-undownloaded-faces
5587 (gnus-agent-find-parameter
5588 group
5589 'agent-enable-undownloaded-faces)))
5590
5591 (setq gnus-newsgroup-name group
5592 gnus-newsgroup-unselected nil
5593 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5594
5595 (let ((display (gnus-group-find-parameter group 'display)))
5596 (setq gnus-newsgroup-display
5597 (cond
5598 ((not (zerop (or (car-safe read-all) 0)))
5599 ;; The user entered the group with C-u SPC/RET, let's show
5600 ;; all articles.
5601 'gnus-not-ignore)
5602 ((eq display 'all)
5603 'gnus-not-ignore)
5604 ((arrayp display)
5605 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5606 ((numberp display)
5607 ;; The following is probably the "correct" solution, but
5608 ;; it makes Gnus fetch all headers and then limit the
5609 ;; articles (which is slow), so instead we hack the
5610 ;; select-articles parameter instead. -- Simon Josefsson
5611 ;; <jas@kth.se>
5612 ;;
5613 ;; (gnus-byte-compile
5614 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5615 ;; display)))))
5616 (setq select-articles
5617 (gnus-uncompress-range
5618 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5619 (if (> tmp 0)
5620 tmp
5621 1))
5622 (cdr (gnus-active group)))))
5623 nil)
5624 (t
5625 nil))))
5626
5627 (gnus-summary-setup-default-charset)
5628
5629 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5630 (when (gnus-virtual-group-p group)
5631 (setq cached gnus-newsgroup-cached))
5632
5633 (setq gnus-newsgroup-unreads
5634 (gnus-sorted-ndifference
5635 (gnus-sorted-ndifference gnus-newsgroup-unreads
5636 gnus-newsgroup-marked)
5637 gnus-newsgroup-dormant))
5638
5639 (setq gnus-newsgroup-processable nil)
5640
5641 (gnus-update-read-articles group gnus-newsgroup-unreads t)
5642
5643 ;; Adjust and set lists of article marks.
5644 (when info
5645 (gnus-adjust-marked-articles info))
5646 (if (setq articles select-articles)
5647 (setq gnus-newsgroup-unselected
5648 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5649 (setq articles (gnus-articles-to-read group read-all)))
5650
5651 (cond
5652 ((null articles)
5653 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5654 'quit)
5655 ((eq articles 0) nil)
5656 (t
5657 ;; Init the dependencies hash table.
5658 (setq gnus-newsgroup-dependencies
5659 (gnus-make-hashtable (length articles)))
5660 (if (gnus-buffer-live-p gnus-group-buffer)
5661 (gnus-set-global-variables)
5662 (set-default 'gnus-newsgroup-name gnus-newsgroup-name))
5663 ;; Retrieve the headers and read them in.
5664
5665 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5666
5667 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5668 (when cached
5669 (setq gnus-newsgroup-cached cached))
5670
5671 ;; Suppress duplicates?
5672 (when gnus-suppress-duplicates
5673 (gnus-dup-suppress-articles))
5674
5675 ;; Set the initial limit.
5676 (setq gnus-newsgroup-limit (copy-sequence articles))
5677 ;; Remove canceled articles from the list of unread articles.
5678 (setq fetched-articles
5679 (mapcar (lambda (headers) (mail-header-number headers))
5680 gnus-newsgroup-headers))
5681 (setq gnus-newsgroup-articles fetched-articles)
5682 (setq gnus-newsgroup-unreads
5683 (gnus-sorted-nintersection
5684 gnus-newsgroup-unreads fetched-articles))
5685 (gnus-compute-unseen-list)
5686
5687 ;; Removed marked articles that do not exist.
5688 (gnus-update-missing-marks
5689 (gnus-sorted-difference articles fetched-articles))
5690 ;; We might want to build some more threads first.
5691 (when (and gnus-fetch-old-headers
5692 (eq gnus-headers-retrieved-by 'nov))
5693 (if (eq gnus-fetch-old-headers 'invisible)
5694 (gnus-build-all-threads)
5695 (gnus-build-old-threads)))
5696 ;; Let the Gnus agent mark articles as read.
5697 (when gnus-agent
5698 (gnus-agent-get-undownloaded-list))
5699 ;; Remove list identifiers from subject
5700 (gnus-summary-remove-list-identifiers)
5701 ;; Check whether auto-expire is to be done in this group.
5702 (setq gnus-newsgroup-auto-expire
5703 (and (gnus-group-auto-expirable-p group)
5704 (not (gnus-group-read-only-p group))))
5705 ;; Set up the article buffer now, if necessary.
5706 (unless (and gnus-single-article-buffer
5707 (equal gnus-article-buffer "*Article*"))
5708 (gnus-article-setup-buffer))
5709 ;; First and last article in this newsgroup.
5710 (when gnus-newsgroup-headers
5711 (setq gnus-newsgroup-begin
5712 (mail-header-number (car gnus-newsgroup-headers))
5713 gnus-newsgroup-end
5714 (mail-header-number
5715 (gnus-last-element gnus-newsgroup-headers))))
5716 ;; GROUP is successfully selected.
5717 (or gnus-newsgroup-headers t)))))
5718
5719 (defun gnus-compute-unseen-list ()
5720 ;; The `seen' marks are treated specially.
5721 (if (not gnus-newsgroup-seen)
5722 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5723 (setq gnus-newsgroup-unseen
5724 (gnus-inverse-list-range-intersection
5725 gnus-newsgroup-articles gnus-newsgroup-seen))))
5726
5727 (declare-function gnus-get-predicate "gnus-agent" (predicate))
5728
5729 (defun gnus-summary-display-make-predicate (display)
5730 (require 'gnus-agent)
5731 (when (= (length display) 1)
5732 (setq display (car display)))
5733 (unless gnus-summary-display-cache
5734 (dolist (elem (append '((unread . unread)
5735 (read . read)
5736 (unseen . unseen))
5737 gnus-article-mark-lists))
5738 (push (cons (cdr elem)
5739 (gnus-byte-compile ;Why bother?
5740 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5741 gnus-summary-display-cache)))
5742 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5743 (gnus-category-predicate-cache gnus-summary-display-cache))
5744 (gnus-get-predicate display)))
5745
5746 ;; Uses the dynamically bound `gnus-number' variable.
5747 (defvar gnus-number)
5748 (defun gnus-article-marked-p (type &optional article)
5749 (let ((article (or article gnus-number)))
5750 (cond
5751 ((eq type 'tick)
5752 (memq article gnus-newsgroup-marked))
5753 ((eq type 'spam)
5754 (memq article gnus-newsgroup-spam-marked))
5755 ((eq type 'unsend)
5756 (memq article gnus-newsgroup-unsendable))
5757 ((eq type 'undownload)
5758 (memq article gnus-newsgroup-undownloaded))
5759 ((eq type 'download)
5760 (memq article gnus-newsgroup-downloadable))
5761 ((eq type 'unread)
5762 (memq article gnus-newsgroup-unreads))
5763 ((eq type 'read)
5764 (memq article gnus-newsgroup-reads))
5765 ((eq type 'dormant)
5766 (memq article gnus-newsgroup-dormant) )
5767 ((eq type 'expire)
5768 (memq article gnus-newsgroup-expirable))
5769 ((eq type 'reply)
5770 (memq article gnus-newsgroup-replied))
5771 ((eq type 'killed)
5772 (memq article gnus-newsgroup-killed))
5773 ((eq type 'bookmark)
5774 (assq article gnus-newsgroup-bookmarks))
5775 ((eq type 'score)
5776 (assq article gnus-newsgroup-scored))
5777 ((eq type 'save)
5778 (memq article gnus-newsgroup-saved))
5779 ((eq type 'cache)
5780 (memq article gnus-newsgroup-cached))
5781 ((eq type 'forward)
5782 (memq article gnus-newsgroup-forwarded))
5783 ((eq type 'seen)
5784 (not (memq article gnus-newsgroup-unseen)))
5785 (t t))))
5786
5787 (defun gnus-articles-to-read (group &optional read-all)
5788 "Find out what articles the user wants to read."
5789 (let* ((only-read-p t)
5790 (articles
5791 (gnus-list-range-difference
5792 ;; Select all articles if `read-all' is non-nil, or if there
5793 ;; are no unread articles.
5794 (if (or read-all
5795 (and (zerop (length gnus-newsgroup-marked))
5796 (zerop (length gnus-newsgroup-unreads)))
5797 ;; Fetch all if the predicate is non-nil.
5798 gnus-newsgroup-display)
5799 ;; We want to select the headers for all the articles in
5800 ;; the group, so we select either all the active
5801 ;; articles in the group, or (if that's nil), the
5802 ;; articles in the cache.
5803 (or
5804 (if gnus-newsgroup-maximum-articles
5805 (let ((active (gnus-active group)))
5806 (gnus-uncompress-range
5807 (cons (max (car active)
5808 (- (cdr active)
5809 gnus-newsgroup-maximum-articles
5810 -1))
5811 (cdr active))))
5812 (gnus-uncompress-range (gnus-active group)))
5813 (gnus-cache-articles-in-group group))
5814 ;; Select only the "normal" subset of articles.
5815 (setq only-read-p nil)
5816 (gnus-sorted-nunion
5817 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5818 gnus-newsgroup-unreads))
5819 (cdr (assq 'unexist (gnus-info-marks (gnus-get-info group))))))
5820 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5821 (scored (length scored-list))
5822 (number (length articles))
5823 (marked (+ (length gnus-newsgroup-marked)
5824 (length gnus-newsgroup-dormant)))
5825 (select
5826 (cond
5827 ((numberp read-all)
5828 read-all)
5829 ((numberp gnus-newsgroup-display)
5830 gnus-newsgroup-display)
5831 (t
5832 (condition-case ()
5833 (cond
5834 ((and (or (<= scored marked) (= scored number))
5835 (numberp gnus-large-newsgroup)
5836 (> number gnus-large-newsgroup))
5837 (let* ((cursor-in-echo-area nil)
5838 (initial (gnus-parameter-large-newsgroup-initial
5839 gnus-newsgroup-name))
5840 (default (if only-read-p
5841 (or initial gnus-large-newsgroup)
5842 number))
5843 (input
5844 (read-string
5845 (if only-read-p
5846 (format
5847 "How many articles from %s (available %d, default %d): "
5848 (gnus-group-real-name
5849 (gnus-group-decoded-name gnus-newsgroup-name))
5850 number default)
5851 (format
5852 "How many articles from %s (%d default): "
5853 (gnus-group-real-name
5854 (gnus-group-decoded-name gnus-newsgroup-name))
5855 default))
5856 nil
5857 nil
5858 (number-to-string default))))
5859 (if (string-match "^[ \t]*$" input) number input)))
5860 ((and (> scored marked) (< scored number)
5861 (> (- scored number) 20))
5862 (let ((input
5863 (read-string
5864 (format "%s %s (%d scored, %d total): "
5865 "How many articles from"
5866 (gnus-group-decoded-name
5867 (gnus-group-real-name gnus-newsgroup-name))
5868 scored number))))
5869 (if (string-match "^[ \t]*$" input)
5870 number input)))
5871 (t number))
5872 (quit
5873 (message "Quit getting the articles to read")
5874 nil))))))
5875 (setq select (if (stringp select) (string-to-number select) select))
5876 (if (or (null select) (zerop select))
5877 select
5878 (if (and (not (zerop scored)) (<= (abs select) scored))
5879 (progn
5880 (setq articles (sort scored-list '<))
5881 (setq number (length articles)))
5882 (setq articles (copy-sequence articles)))
5883
5884 (when (< (abs select) number)
5885 (if (< select 0)
5886 ;; Select the N oldest articles.
5887 (setcdr (nthcdr (1- (abs select)) articles) nil)
5888 ;; Select the N most recent articles.
5889 (setq articles (nthcdr (- number select) articles))))
5890 (setq gnus-newsgroup-unselected
5891 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5892 (when gnus-alter-articles-to-read-function
5893 (setq articles
5894 (sort
5895 (funcall gnus-alter-articles-to-read-function
5896 gnus-newsgroup-name articles)
5897 '<)))
5898 articles)))
5899
5900 (defun gnus-killed-articles (killed articles)
5901 (let (out)
5902 (while articles
5903 (when (inline (gnus-member-of-range (car articles) killed))
5904 (push (car articles) out))
5905 (setq articles (cdr articles)))
5906 out))
5907
5908 (defun gnus-article-mark-to-type (mark)
5909 "Return the type of MARK."
5910 (or (cadr (assq mark gnus-article-special-mark-lists))
5911 'list))
5912
5913 (defun gnus-article-unpropagatable-p (mark)
5914 "Return whether MARK should be propagated to back end."
5915 (memq mark gnus-article-unpropagated-mark-lists))
5916
5917 (defun gnus-adjust-marked-articles (info)
5918 "Set all article lists and remove all marks that are no longer valid."
5919 (let* ((marked-lists (gnus-info-marks info))
5920 (active (gnus-active (gnus-info-group info)))
5921 (min (car active))
5922 (max (cdr active))
5923 (types gnus-article-mark-lists)
5924 marks var articles article mark mark-type
5925 bgn end)
5926 ;; Hack to avoid adjusting marks for imap.
5927 (when (eq (car (gnus-find-method-for-group (gnus-info-group info)))
5928 'nnimap)
5929 (setq min 1))
5930
5931 (dolist (marks marked-lists)
5932 (setq mark (car marks)
5933 mark-type (gnus-article-mark-to-type mark)
5934 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5935 ;; We set the variable according to the type of the marks list,
5936 ;; and then adjust the marks to a subset of the active articles.
5937 (cond
5938 ;; Adjust "simple" lists - compressed yet unsorted
5939 ((eq mark-type 'list)
5940 ;; Simultaneously uncompress and clip to active range
5941 ;; See gnus-uncompress-range for a description of possible marks
5942 (let (l lh)
5943 (if (not (cadr marks))
5944 (set var nil)
5945 (setq articles (if (numberp (cddr marks))
5946 (list (cdr marks))
5947 (cdr marks))
5948 lh (cons nil nil)
5949 l lh)
5950
5951 (while (setq article (pop articles))
5952 (cond ((consp article)
5953 (setq bgn (max (car article) min)
5954 end (min (cdr article) max))
5955 (while (<= bgn end)
5956 (setq l (setcdr l (cons bgn nil))
5957 bgn (1+ bgn))))
5958 ((and (<= min article)
5959 (>= max article))
5960 (setq l (setcdr l (cons article nil))))))
5961 (set var (cdr lh)))))
5962 ;; Adjust assocs.
5963 ((eq mark-type 'tuple)
5964 (set var (setq articles (cdr marks)))
5965 (when (not (listp (cdr (symbol-value var))))
5966 (set var (list (symbol-value var))))
5967 (when (not (listp (cdr articles)))
5968 (setq articles (list articles)))
5969 (while articles
5970 (when (or (not (consp (setq article (pop articles))))
5971 (< (car article) min)
5972 (> (car article) max))
5973 (set var (delq article (symbol-value var))))))
5974 ;; Adjust ranges (sloppily).
5975 ((eq mark-type 'range)
5976 (cond
5977 ((eq mark 'seen)
5978 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5979 ;; It should be (seen (NUM1 . NUM2)).
5980 (when (numberp (cddr marks))
5981 (setcdr marks (list (cdr marks))))
5982 (setq articles (cdr marks))
5983 (while (and articles
5984 (or (and (consp (car articles))
5985 (> min (cdar articles)))
5986 (and (numberp (car articles))
5987 (> min (car articles)))))
5988 (pop articles))
5989 (set var articles))
5990 ((eq mark 'unexist)
5991 (set var (cdr marks)))))))))
5992
5993 (defun gnus-update-missing-marks (missing)
5994 "Go through the list of MISSING articles and remove them from the mark lists."
5995 (when missing
5996 (let (var m)
5997 ;; Go through all types.
5998 (dolist (elem gnus-article-mark-lists)
5999 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
6000 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
6001 (when (symbol-value var)
6002 ;; This list has articles. So we delete all missing
6003 ;; articles from it.
6004 (setq m missing)
6005 (while m
6006 (set var (delq (pop m) (symbol-value var))))))))))
6007
6008 (defun gnus-update-marks ()
6009 "Enter the various lists of marked articles into the newsgroup info list."
6010 (let ((types gnus-article-mark-lists)
6011 (info (gnus-get-info gnus-newsgroup-name))
6012 type list newmarked symbol delta-marks)
6013 (when info
6014 ;; Add all marks lists to the list of marks lists.
6015 (while (setq type (pop types))
6016 (setq list (symbol-value
6017 (setq symbol
6018 (intern (format "gnus-newsgroup-%s" (car type))))))
6019
6020 (when list
6021 ;; Get rid of the entries of the articles that have the
6022 ;; default score.
6023 (when (and (eq (cdr type) 'score)
6024 gnus-save-score
6025 list)
6026 (let* ((arts list)
6027 (prev (cons nil list))
6028 (all prev))
6029 (while arts
6030 (if (or (not (consp (car arts)))
6031 (= (cdar arts) gnus-summary-default-score))
6032 (setcdr prev (cdr arts))
6033 (setq prev arts))
6034 (setq arts (cdr arts)))
6035 (setq list (cdr all)))))
6036
6037 ;; When exiting the group, everything that's previously been
6038 ;; unseen is now seen.
6039 (when (eq (cdr type) 'seen)
6040 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
6041
6042 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
6043 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
6044
6045 (when (and (gnus-check-backend-function
6046 'request-set-mark gnus-newsgroup-name)
6047 (not (gnus-article-unpropagatable-p (cdr type))))
6048 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
6049 ;; Don't do anything about marks for articles we
6050 ;; didn't actually get any headers for.
6051 (del
6052 (gnus-list-range-intersection
6053 gnus-newsgroup-articles
6054 (gnus-remove-from-range (gnus-copy-sequence old) list)))
6055 (add
6056 (gnus-list-range-intersection
6057 gnus-newsgroup-articles
6058 (gnus-remove-from-range
6059 (gnus-copy-sequence list) old))))
6060 (when add
6061 (push (list add 'add (list (cdr type))) delta-marks))
6062 (when del
6063 ;; Don't delete marks from outside the active range.
6064 ;; This shouldn't happen, but is a sanity check.
6065 (setq del (gnus-sorted-range-intersection
6066 (gnus-active gnus-newsgroup-name) del))
6067 (push (list del 'del (list (cdr type))) delta-marks))))
6068
6069 (when (or list
6070 (eq (cdr type) 'unexist))
6071 (push (cons (cdr type) list) newmarked)))
6072
6073 (when delta-marks
6074 (unless (gnus-check-group gnus-newsgroup-name)
6075 (error "Can't open server for %s" gnus-newsgroup-name))
6076 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
6077
6078 ;; Enter these new marks into the info of the group.
6079 (if (nthcdr 3 info)
6080 (setcar (nthcdr 3 info) newmarked)
6081 ;; Add the marks lists to the end of the info.
6082 (when newmarked
6083 (setcdr (nthcdr 2 info) (list newmarked))))
6084
6085 ;; Cut off the end of the info if there's nothing else there.
6086 (let ((i 5))
6087 (while (and (> i 2)
6088 (not (nth i info)))
6089 (when (nthcdr (decf i) info)
6090 (setcdr (nthcdr i info) nil)))))))
6091
6092 (defun gnus-set-mode-line (where)
6093 "Set the mode line of the article or summary buffers.
6094 If WHERE is `summary', the summary mode line format will be used."
6095 ;; Is this mode line one we keep updated?
6096 (when (and (memq where gnus-updated-mode-lines)
6097 (symbol-value
6098 (intern (format "gnus-%s-mode-line-format-spec" where))))
6099 (let (mode-string)
6100 ;; We evaluate this in the summary buffer since these
6101 ;; variables are buffer-local to that buffer.
6102 (with-current-buffer gnus-summary-buffer
6103 ;; We bind all these variables that are used in the `eval' form
6104 ;; below.
6105 (let* ((mformat (symbol-value
6106 (intern
6107 (format "gnus-%s-mode-line-format-spec" where))))
6108 (gnus-tmp-group-name (gnus-mode-string-quote
6109 (gnus-group-decoded-name
6110 gnus-newsgroup-name)))
6111 (gnus-tmp-article-number (or gnus-current-article 0))
6112 (gnus-tmp-unread gnus-newsgroup-unreads)
6113 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
6114 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
6115 (gnus-tmp-unread-and-unselected
6116 (cond ((and (zerop gnus-tmp-unread-and-unticked)
6117 (zerop gnus-tmp-unselected))
6118 "")
6119 ((zerop gnus-tmp-unselected)
6120 (format "{%d more}" gnus-tmp-unread-and-unticked))
6121 (t (format "{%d(+%d) more}"
6122 gnus-tmp-unread-and-unticked
6123 gnus-tmp-unselected))))
6124 (gnus-tmp-subject
6125 (if (and gnus-current-headers
6126 (vectorp gnus-current-headers))
6127 (gnus-mode-string-quote
6128 (mail-header-subject gnus-current-headers))
6129 ""))
6130 bufname-length max-len
6131 gnus-tmp-header) ;; passed as argument to any user-format-funcs
6132 (setq mode-string (eval mformat))
6133 (setq bufname-length (if (string-match "%b" mode-string)
6134 (- (length
6135 (buffer-name
6136 (if (eq where 'summary)
6137 nil
6138 (get-buffer gnus-article-buffer))))
6139 2)
6140 0))
6141 (setq max-len (max 4 (if gnus-mode-non-string-length
6142 (- (window-width)
6143 gnus-mode-non-string-length
6144 bufname-length)
6145 (length mode-string))))
6146 ;; We might have to chop a bit of the string off...
6147 (when (> (length mode-string) max-len)
6148 (setq mode-string
6149 (concat (truncate-string-to-width mode-string (- max-len 3))
6150 "...")))))
6151 ;; Update the mode line.
6152 (setq mode-line-buffer-identification
6153 (gnus-mode-line-buffer-identification (list mode-string)))
6154 (set-buffer-modified-p t))))
6155
6156 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
6157 "Go through the HEADERS list and add all Xrefs to a hash table.
6158 The resulting hash table is returned, or nil if no Xrefs were found."
6159 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
6160 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
6161 (xref-hashtb (gnus-make-hashtable))
6162 start group entry number xrefs header)
6163 (while headers
6164 (setq header (pop headers))
6165 (when (and (setq xrefs (mail-header-xref header))
6166 (not (memq (setq number (mail-header-number header))
6167 unreads)))
6168 (setq start 0)
6169 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
6170 (setq start (match-end 0))
6171 (setq group (if prefix
6172 (concat prefix (substring xrefs (match-beginning 1)
6173 (match-end 1)))
6174 (substring xrefs (match-beginning 1) (match-end 1))))
6175 (setq number
6176 (string-to-number (substring xrefs (match-beginning 2)
6177 (match-end 2))))
6178 (if (setq entry (gnus-gethash group xref-hashtb))
6179 (setcdr entry (cons number (cdr entry)))
6180 (gnus-sethash group (cons number nil) xref-hashtb)))))
6181 (and start xref-hashtb)))
6182
6183 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
6184 "Look through all the headers and mark the Xrefs as read."
6185 (let ((virtual (gnus-virtual-group-p from-newsgroup))
6186 name info xref-hashtb idlist method nth4)
6187 (with-current-buffer gnus-group-buffer
6188 (when (setq xref-hashtb
6189 (gnus-create-xref-hashtb from-newsgroup headers unreads))
6190 (mapatoms
6191 (lambda (group)
6192 (unless (string= from-newsgroup (setq name (symbol-name group)))
6193 (setq idlist (symbol-value group))
6194 ;; Dead groups are not updated.
6195 (and (prog1
6196 (setq info (gnus-get-info name))
6197 (when (stringp (setq nth4 (gnus-info-method info)))
6198 (setq nth4 (gnus-server-to-method nth4))))
6199 ;; Only do the xrefs if the group has the same
6200 ;; select method as the group we have just read.
6201 (or (gnus-methods-equal-p
6202 nth4 (gnus-find-method-for-group from-newsgroup))
6203 virtual
6204 (equal nth4 (setq method (gnus-find-method-for-group
6205 from-newsgroup)))
6206 (and (equal (car nth4) (car method))
6207 (equal (nth 1 nth4) (nth 1 method))))
6208 gnus-use-cross-reference
6209 (or (not (eq gnus-use-cross-reference t))
6210 virtual
6211 ;; Only do cross-references on subscribed
6212 ;; groups, if that is what is wanted.
6213 (<= (gnus-info-level info) gnus-level-subscribed))
6214 (gnus-group-make-articles-read name idlist))))
6215 xref-hashtb)))))
6216
6217 (defun gnus-compute-read-articles (group articles)
6218 (let* ((entry (gnus-group-entry group))
6219 (info (nth 2 entry))
6220 (active (gnus-active group))
6221 ninfo)
6222 (when entry
6223 ;; First peel off all invalid article numbers.
6224 (when active
6225 (let ((ids articles)
6226 id first)
6227 (while (setq id (pop ids))
6228 (when (and first (> id (cdr active)))
6229 ;; We'll end up in this situation in one particular
6230 ;; obscure situation. If you re-scan a group and get
6231 ;; a new article that is cross-posted to a different
6232 ;; group that has not been re-scanned, you might get
6233 ;; crossposted article that has a higher number than
6234 ;; Gnus believes possible. So we re-activate this
6235 ;; group as well. This might mean doing the
6236 ;; crossposting thingy will *increase* the number
6237 ;; of articles in some groups. Tsk, tsk.
6238 (setq active (or (gnus-activate-group group) active)))
6239 (when (or (> id (cdr active))
6240 (< id (car active)))
6241 (setq articles (delq id articles))))))
6242 ;; If the read list is nil, we init it.
6243 (if (and active
6244 (null (gnus-info-read info))
6245 (> (car active) 1))
6246 (setq ninfo (cons 1 (1- (car active))))
6247 (setq ninfo (gnus-info-read info)))
6248 ;; Then we add the read articles to the range.
6249 (gnus-add-to-range
6250 ninfo (setq articles (sort articles '<))))))
6251
6252 (defun gnus-group-make-articles-read (group articles)
6253 "Update the info of GROUP to say that ARTICLES are read."
6254 (let* ((num 0)
6255 (entry (gnus-group-entry group))
6256 (info (nth 2 entry))
6257 (active (gnus-active group))
6258 (set-marks
6259 (gnus-method-option-p
6260 (gnus-find-method-for-group group)
6261 'server-marks))
6262 range)
6263 (if (not entry)
6264 ;; Group that Gnus doesn't know exists, but still allow the
6265 ;; backend to set marks.
6266 (when set-marks
6267 (gnus-request-set-mark
6268 group (list (list (gnus-compress-sequence (sort articles #'<))
6269 'add '(read)))))
6270 ;; Normal, subscribed groups.
6271 (setq range (gnus-compute-read-articles group articles))
6272 (with-current-buffer gnus-group-buffer
6273 (gnus-undo-register
6274 `(progn
6275 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
6276 (gnus-info-set-read ',info ',(gnus-info-read info))
6277 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
6278 (when ,set-marks
6279 (gnus-request-set-mark
6280 ,group (list (list ',range 'del '(read)))))
6281 (gnus-group-update-group ,group t))))
6282 ;; Add the read articles to the range.
6283 (gnus-info-set-read info range)
6284 (when set-marks
6285 (gnus-request-set-mark group (list (list range 'add '(read)))))
6286 ;; Then we have to re-compute how many unread
6287 ;; articles there are in this group.
6288 (when active
6289 (cond
6290 ((not range)
6291 (setq num (- (1+ (cdr active)) (car active))))
6292 ((not (listp (cdr range)))
6293 (setq num (- (cdr active) (- (1+ (cdr range))
6294 (car range)))))
6295 (t
6296 (while range
6297 (if (numberp (car range))
6298 (setq num (1+ num))
6299 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
6300 (setq range (cdr range)))
6301 (setq num (- (cdr active) num))))
6302 ;; Update the number of unread articles.
6303 (setcar entry num)
6304 ;; Update the group buffer.
6305 (unless (gnus-ephemeral-group-p group)
6306 (gnus-group-update-group group t))))))
6307
6308 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
6309 (let ((cur nntp-server-buffer)
6310 (dependencies
6311 (or dependencies
6312 (with-current-buffer gnus-summary-buffer
6313 gnus-newsgroup-dependencies)))
6314 headers id end ref number
6315 (mail-parse-charset gnus-newsgroup-charset)
6316 (mail-parse-ignored-charsets
6317 (save-current-buffer (condition-case nil
6318 (set-buffer gnus-summary-buffer)
6319 (error))
6320 gnus-newsgroup-ignored-charsets)))
6321 (with-current-buffer nntp-server-buffer
6322 ;; Translate all TAB characters into SPACE characters.
6323 (subst-char-in-region (point-min) (point-max) ?\t ? t)
6324 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6325 (ietf-drums-unfold-fws)
6326 (gnus-run-hooks 'gnus-parse-headers-hook)
6327 (let ((case-fold-search t)
6328 in-reply-to header p lines chars)
6329 (goto-char (point-min))
6330 ;; Search to the beginning of the next header. Error messages
6331 ;; do not begin with 2 or 3.
6332 (while (re-search-forward "^[23][0-9]+ " nil t)
6333 (setq id nil
6334 ref nil)
6335 ;; This implementation of this function, with nine
6336 ;; search-forwards instead of the one re-search-forward and
6337 ;; a case (which basically was the old function) is actually
6338 ;; about twice as fast, even though it looks messier. You
6339 ;; can't have everything, I guess. Speed and elegance
6340 ;; doesn't always go hand in hand.
6341 (setq
6342 header
6343 (vector
6344 ;; Number.
6345 (prog1
6346 (setq number (read cur))
6347 (end-of-line)
6348 (setq p (point))
6349 (narrow-to-region (point)
6350 (or (and (search-forward "\n.\n" nil t)
6351 (- (point) 2))
6352 (point))))
6353 ;; Subject.
6354 (progn
6355 (goto-char p)
6356 (if (search-forward "\nsubject:" nil t)
6357 (funcall gnus-decode-encoded-word-function
6358 (nnheader-header-value))
6359 "(none)"))
6360 ;; From.
6361 (progn
6362 (goto-char p)
6363 (if (search-forward "\nfrom:" nil t)
6364 (funcall gnus-decode-encoded-address-function
6365 (nnheader-header-value))
6366 "(nobody)"))
6367 ;; Date.
6368 (progn
6369 (goto-char p)
6370 (if (search-forward "\ndate:" nil t)
6371 (nnheader-header-value) ""))
6372 ;; Message-ID.
6373 (progn
6374 (goto-char p)
6375 (setq id (if (re-search-forward
6376 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
6377 ;; We do it this way to make sure the Message-ID
6378 ;; is (somewhat) syntactically valid.
6379 (buffer-substring (match-beginning 1)
6380 (match-end 1))
6381 ;; If there was no message-id, we just fake one
6382 ;; to make subsequent routines simpler.
6383 (nnheader-generate-fake-message-id number))))
6384 ;; References.
6385 (progn
6386 (goto-char p)
6387 (if (search-forward "\nreferences:" nil t)
6388 (progn
6389 (setq end (point))
6390 (prog1
6391 (nnheader-header-value)
6392 (setq ref
6393 (buffer-substring
6394 (progn
6395 (end-of-line)
6396 (search-backward ">" end t)
6397 (1+ (point)))
6398 (progn
6399 (search-backward "<" end t)
6400 (point))))))
6401 ;; Get the references from the in-reply-to header if there
6402 ;; were no references and the in-reply-to header looks
6403 ;; promising.
6404 (if (and (search-forward "\nin-reply-to:" nil t)
6405 (setq in-reply-to (nnheader-header-value))
6406 (string-match "<[^>]+>" in-reply-to))
6407 (let (ref2)
6408 (setq ref (substring in-reply-to (match-beginning 0)
6409 (match-end 0)))
6410 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
6411 (setq ref2 (substring in-reply-to (match-beginning 0)
6412 (match-end 0)))
6413 (when (> (length ref2) (length ref))
6414 (setq ref ref2)))
6415 ref)
6416 (setq ref nil))))
6417 ;; Chars.
6418 (progn
6419 (goto-char p)
6420 (if (search-forward "\nchars: " nil t)
6421 (if (numberp (setq chars (ignore-errors (read cur))))
6422 chars -1)
6423 -1))
6424 ;; Lines.
6425 (progn
6426 (goto-char p)
6427 (if (search-forward "\nlines: " nil t)
6428 (if (numberp (setq lines (ignore-errors (read cur))))
6429 lines -1)
6430 -1))
6431 ;; Xref.
6432 (progn
6433 (goto-char p)
6434 (and (search-forward "\nxref:" nil t)
6435 (nnheader-header-value)))
6436 ;; Extra.
6437 (when gnus-extra-headers
6438 (let ((extra gnus-extra-headers)
6439 out)
6440 (while extra
6441 (goto-char p)
6442 (when (search-forward
6443 (concat "\n" (symbol-name (car extra)) ":") nil t)
6444 (push (cons (car extra) (nnheader-header-value))
6445 out))
6446 (pop extra))
6447 out))))
6448 (when (equal id ref)
6449 (setq ref nil))
6450
6451 (when gnus-alter-header-function
6452 (funcall gnus-alter-header-function header)
6453 (setq id (mail-header-id header)
6454 ref (gnus-parent-id (mail-header-references header))))
6455
6456 (when (setq header
6457 (gnus-dependencies-add-header
6458 header dependencies force-new))
6459 (push header headers))
6460 (goto-char (point-max))
6461 (widen))
6462 (nreverse headers)))))
6463
6464 ;; Goes through the xover lines and returns a list of vectors
6465 (defun gnus-get-newsgroup-headers-xover (sequence &optional
6466 force-new dependencies
6467 group also-fetch-heads)
6468 "Parse the news overview data in the server buffer.
6469 Return a list of headers that match SEQUENCE (see
6470 `nntp-retrieve-headers')."
6471 ;; Get the Xref when the users reads the articles since most/some
6472 ;; NNTP servers do not include Xrefs when using XOVER.
6473 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
6474 (let ((mail-parse-charset gnus-newsgroup-charset)
6475 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6476 (cur nntp-server-buffer)
6477 (dependencies (or dependencies gnus-newsgroup-dependencies))
6478 (allp (cond
6479 ((eq gnus-read-all-available-headers t)
6480 t)
6481 ((and (stringp gnus-read-all-available-headers)
6482 group)
6483 (string-match gnus-read-all-available-headers group))
6484 (t
6485 nil)))
6486 number headers header)
6487 (with-current-buffer nntp-server-buffer
6488 (subst-char-in-region (point-min) (point-max) ?\r ? t)
6489 ;; Allow the user to mangle the headers before parsing them.
6490 (gnus-run-hooks 'gnus-parse-headers-hook)
6491 (goto-char (point-min))
6492 (gnus-parse-without-error
6493 (while (and (or sequence allp)
6494 (not (eobp)))
6495 (setq number (read cur))
6496 (when (not allp)
6497 (while (and sequence
6498 (< (car sequence) number))
6499 (setq sequence (cdr sequence))))
6500 (when (and (or allp
6501 (and sequence
6502 (eq number (car sequence))))
6503 (progn
6504 (setq sequence (cdr sequence))
6505 (setq header (inline
6506 (gnus-nov-parse-line
6507 number dependencies force-new)))))
6508 (push header headers))
6509 (forward-line 1)))
6510 ;; A common bug in inn is that if you have posted an article and
6511 ;; then retrieves the active file, it will answer correctly --
6512 ;; the new article is included. However, a NOV entry for the
6513 ;; article may not have been generated yet, so this may fail.
6514 ;; We work around this problem by retrieving the last few
6515 ;; headers using HEAD.
6516 (if (or (not also-fetch-heads)
6517 (not sequence))
6518 ;; We (probably) got all the headers.
6519 (nreverse headers)
6520 (let ((gnus-nov-is-evil t))
6521 (nconc
6522 (nreverse headers)
6523 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6524 (gnus-get-newsgroup-headers))))))))
6525
6526 (defun gnus-article-get-xrefs ()
6527 "Fill in the Xref value in `gnus-current-headers', if necessary.
6528 This is meant to be called in `gnus-article-internal-prepare-hook'."
6529 (let ((headers (with-current-buffer gnus-summary-buffer
6530 gnus-current-headers)))
6531 (or (not gnus-use-cross-reference)
6532 (not headers)
6533 (and (mail-header-xref headers)
6534 (not (string= (mail-header-xref headers) "")))
6535 (let ((case-fold-search t)
6536 xref)
6537 (save-restriction
6538 (nnheader-narrow-to-headers)
6539 (goto-char (point-min))
6540 (when (or (and (not (eobp))
6541 (eq (downcase (char-after)) ?x)
6542 (looking-at "Xref:"))
6543 (search-forward "\nXref:" nil t))
6544 (goto-char (1+ (match-end 0)))
6545 (setq xref (buffer-substring (point) (point-at-eol)))
6546 (mail-header-set-xref headers xref)))))))
6547
6548 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6549 "Find article ID and insert the summary line for that article.
6550 OLD-HEADER can either be a header or a line number to insert
6551 the subject line on.
6552 If USE-OLD-HEADER is non-nil, then OLD-HEADER should be a header,
6553 and OLD-HEADER will be used when the summary line is inserted,
6554 too, instead of trying to fetch new headers."
6555 (let* ((line (and (numberp old-header) old-header))
6556 (old-header (and (vectorp old-header) old-header))
6557 (header (cond ((and old-header use-old-header)
6558 old-header)
6559 ((and (numberp id)
6560 (gnus-number-to-header id))
6561 (gnus-number-to-header id))
6562 (t
6563 (gnus-read-header id))))
6564 (number (and (numberp id) id))
6565 d)
6566 (when header
6567 ;; Rebuild the thread that this article is part of and go to the
6568 ;; article we have fetched.
6569 (when (and (not gnus-show-threads)
6570 old-header)
6571 (when (and number
6572 (setq d (gnus-data-find (mail-header-number old-header))))
6573 (goto-char (gnus-data-pos d))
6574 (gnus-data-remove
6575 number
6576 (- (point-at-bol)
6577 (prog1
6578 (1+ (point-at-eol))
6579 (gnus-delete-line))))))
6580 ;; Remove list identifiers from subject.
6581 (let ((gnus-newsgroup-headers (list header)))
6582 (gnus-summary-remove-list-identifiers))
6583 (when old-header
6584 (mail-header-set-number header (mail-header-number old-header)))
6585 (setq gnus-newsgroup-sparse
6586 (delq (setq number (mail-header-number header))
6587 gnus-newsgroup-sparse))
6588 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6589 (push number gnus-newsgroup-limit)
6590 (gnus-rebuild-thread (mail-header-id header) line)
6591 (gnus-summary-goto-subject number nil t))
6592 (when (and (numberp number)
6593 (> number 0))
6594 ;; We have to update the boundaries even if we can't fetch the
6595 ;; article if ID is a number -- so that the next `P' or `N'
6596 ;; command will fetch the previous (or next) article even
6597 ;; if the one we tried to fetch this time has been canceled.
6598 (unless (and gnus-newsgroup-end (< number gnus-newsgroup-end))
6599 (setq gnus-newsgroup-end number))
6600 (unless (and gnus-newsgroup-begin (> number gnus-newsgroup-begin))
6601 (setq gnus-newsgroup-begin number))
6602 (setq gnus-newsgroup-unselected
6603 (delq number gnus-newsgroup-unselected)))
6604 ;; Report back a success?
6605 (and header (mail-header-number header))))
6606
6607 ;;; Process/prefix in the summary buffer
6608
6609 (defun gnus-summary-work-articles (n)
6610 "Return a list of articles to be worked upon.
6611 The prefix argument, the list of process marked articles, and the
6612 current article will be taken into consideration."
6613 (with-current-buffer gnus-summary-buffer
6614 (cond
6615 (n
6616 ;; A numerical prefix has been given.
6617 (setq n (prefix-numeric-value n))
6618 (let ((backward (< n 0))
6619 (n (abs (prefix-numeric-value n)))
6620 articles article)
6621 (save-excursion
6622 (while
6623 (and (> n 0)
6624 (push (setq article (gnus-summary-article-number))
6625 articles)
6626 (if backward
6627 (gnus-summary-find-prev nil article)
6628 (gnus-summary-find-next nil article)))
6629 (decf n)))
6630 (nreverse articles)))
6631 ((and (and transient-mark-mode mark-active) (mark))
6632 (message "region active")
6633 ;; Work on the region between point and mark.
6634 (let ((max (max (point) (mark)))
6635 articles article)
6636 (save-excursion
6637 (goto-char (min (point) (mark)))
6638 (while
6639 (and
6640 (push (setq article (gnus-summary-article-number)) articles)
6641 (gnus-summary-find-next nil article)
6642 (< (point) max)))
6643 (nreverse articles))))
6644 (gnus-newsgroup-processable
6645 ;; There are process-marked articles present.
6646 ;; Save current state.
6647 (gnus-summary-save-process-mark)
6648 ;; Return the list.
6649 (reverse gnus-newsgroup-processable))
6650 (t
6651 ;; Just return the current article.
6652 (list (gnus-summary-article-number))))))
6653
6654 (defmacro gnus-summary-iterate (arg &rest forms)
6655 "Iterate over the process/prefixed articles and do FORMS.
6656 ARG is the interactive prefix given to the command. FORMS will be
6657 executed with point over the summary line of the articles."
6658 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6659 `(let ((,articles (gnus-summary-work-articles ,arg)))
6660 (while ,articles
6661 (gnus-summary-goto-subject (car ,articles))
6662 ,@forms
6663 (pop ,articles)))))
6664
6665 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6666 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6667
6668 (defun gnus-summary-save-process-mark ()
6669 "Push the current set of process marked articles on the stack."
6670 (interactive)
6671 (push (copy-sequence gnus-newsgroup-processable)
6672 gnus-newsgroup-process-stack))
6673
6674 (defun gnus-summary-kill-process-mark ()
6675 "Push the current set of process marked articles on the stack and unmark."
6676 (interactive)
6677 (gnus-summary-save-process-mark)
6678 (gnus-summary-unmark-all-processable))
6679
6680 (defun gnus-summary-yank-process-mark ()
6681 "Pop the last process mark state off the stack and restore it."
6682 (interactive)
6683 (unless gnus-newsgroup-process-stack
6684 (error "Empty mark stack"))
6685 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6686
6687 (defun gnus-summary-process-mark-set (set)
6688 "Make SET into the current process marked articles."
6689 (gnus-summary-unmark-all-processable)
6690 (mapc 'gnus-summary-set-process-mark set))
6691
6692 ;;; Searching and stuff
6693
6694 (defun gnus-summary-search-group (&optional backward use-level)
6695 "Search for next unread newsgroup.
6696 If optional argument BACKWARD is non-nil, search backward instead."
6697 (with-current-buffer gnus-group-buffer
6698 (when (gnus-group-search-forward
6699 backward nil (if use-level (gnus-group-group-level) nil))
6700 (gnus-group-group-name))))
6701
6702 (defun gnus-summary-best-group (&optional exclude-group)
6703 "Find the name of the best unread group.
6704 If EXCLUDE-GROUP, do not go to this group."
6705 (with-current-buffer gnus-group-buffer
6706 (save-excursion
6707 (gnus-group-best-unread-group exclude-group))))
6708
6709 (defun gnus-summary-find-next (&optional unread article backward)
6710 (if backward
6711 (gnus-summary-find-prev unread article)
6712 (let* ((dummy (gnus-summary-article-intangible-p))
6713 (article (or article (gnus-summary-article-number)))
6714 (data (gnus-data-find-list article))
6715 result)
6716 (when (and (not dummy)
6717 (or (not gnus-summary-check-current)
6718 (not unread)
6719 (not (gnus-data-unread-p (car data)))))
6720 (setq data (cdr data)))
6721 (when (setq result
6722 (if unread
6723 (progn
6724 (while data
6725 (unless (memq (gnus-data-number (car data))
6726 (cond
6727 ((eq gnus-auto-goto-ignores
6728 'always-undownloaded)
6729 gnus-newsgroup-undownloaded)
6730 (gnus-plugged
6731 nil)
6732 ((eq gnus-auto-goto-ignores
6733 'unfetched)
6734 gnus-newsgroup-unfetched)
6735 ((eq gnus-auto-goto-ignores
6736 'undownloaded)
6737 gnus-newsgroup-undownloaded)))
6738 (when (gnus-data-unread-p (car data))
6739 (setq result (car data)
6740 data nil)))
6741 (setq data (cdr data)))
6742 result)
6743 (car data)))
6744 (goto-char (gnus-data-pos result))
6745 (gnus-data-number result)))))
6746
6747 (defun gnus-summary-find-prev (&optional unread article)
6748 (let* ((eobp (eobp))
6749 (article (or article (gnus-summary-article-number)))
6750 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6751 result)
6752 (when (and (not eobp)
6753 (or (not gnus-summary-check-current)
6754 (not unread)
6755 (not (gnus-data-unread-p (car data)))))
6756 (setq data (cdr data)))
6757 (when (setq result
6758 (if unread
6759 (progn
6760 (while data
6761 (unless (memq (gnus-data-number (car data))
6762 (cond
6763 ((eq gnus-auto-goto-ignores
6764 'always-undownloaded)
6765 gnus-newsgroup-undownloaded)
6766 (gnus-plugged
6767 nil)
6768 ((eq gnus-auto-goto-ignores
6769 'unfetched)
6770 gnus-newsgroup-unfetched)
6771 ((eq gnus-auto-goto-ignores
6772 'undownloaded)
6773 gnus-newsgroup-undownloaded)))
6774 (when (gnus-data-unread-p (car data))
6775 (setq result (car data)
6776 data nil)))
6777 (setq data (cdr data)))
6778 result)
6779 (car data)))
6780 (goto-char (gnus-data-pos result))
6781 (gnus-data-number result))))
6782
6783 (defun gnus-summary-find-subject (subject &optional unread backward article)
6784 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6785 (article (or article (gnus-summary-article-number)))
6786 (articles (gnus-data-list backward))
6787 (arts (gnus-data-find-list article articles))
6788 result)
6789 (when (or (not gnus-summary-check-current)
6790 (not unread)
6791 (not (gnus-data-unread-p (car arts))))
6792 (setq arts (cdr arts)))
6793 (while arts
6794 (and (or (not unread)
6795 (gnus-data-unread-p (car arts)))
6796 (vectorp (gnus-data-header (car arts)))
6797 (gnus-subject-equal
6798 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6799 (setq result (car arts)
6800 arts nil))
6801 (setq arts (cdr arts)))
6802 (and result
6803 (goto-char (gnus-data-pos result))
6804 (gnus-data-number result))))
6805
6806 (defun gnus-summary-search-forward (&optional unread subject backward)
6807 "Search forward for an article.
6808 If UNREAD, look for unread articles. If SUBJECT, look for
6809 articles with that subject. If BACKWARD, search backward instead."
6810 (cond (subject (gnus-summary-find-subject subject unread backward))
6811 (backward (gnus-summary-find-prev unread))
6812 (t (gnus-summary-find-next unread))))
6813
6814 (defun gnus-recenter (&optional n)
6815 "Center point in window and redisplay frame.
6816 Also do horizontal recentering."
6817 (interactive "P")
6818 (when (and gnus-auto-center-summary
6819 (not (eq gnus-auto-center-summary 'vertical)))
6820 (gnus-horizontal-recenter))
6821 (recenter-top-bottom n))
6822
6823 (put 'gnus-recenter 'isearch-scroll t)
6824
6825 (defun gnus-forward-line-ignore-invisible (n)
6826 "Move N lines forward (backward if N is negative).
6827 Like forward-line, but skip over (and don't count) invisible lines."
6828 (let (done)
6829 (while (and (> n 0) (not done))
6830 ;; If the following character is currently invisible,
6831 ;; skip all characters with that same `invisible' property value.
6832 (while (invisible-p (point))
6833 (goto-char (next-char-property-change (point))))
6834 (forward-line 1)
6835 (if (eobp)
6836 (setq done t)
6837 (setq n (1- n))))
6838 (while (and (< n 0) (not done))
6839 (forward-line -1)
6840 (if (bobp) (setq done t)
6841 (setq n (1+ n))
6842 (while (and (not (bobp)) (invisible-p (1- (point))))
6843 (goto-char (previous-char-property-change (point))))))))
6844
6845 (defun gnus-summary-recenter ()
6846 "Center point in the summary window.
6847 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6848 displayed, no centering will be performed."
6849 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6850 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6851 (interactive)
6852 ;; The user has to want it.
6853 (when gnus-auto-center-summary
6854 (let* ((top (cond ((< (window-height) 4) 0)
6855 ((< (window-height) 7) 1)
6856 (t (if (numberp gnus-auto-center-summary)
6857 gnus-auto-center-summary
6858 (/ (1- (window-height)) 2)))))
6859 (height (1- (window-height)))
6860 (bottom (save-excursion
6861 (goto-char (point-max))
6862 (gnus-forward-line-ignore-invisible (- height))
6863 (point)))
6864 (window (get-buffer-window (current-buffer))))
6865 (when (get-buffer-window gnus-article-buffer)
6866 ;; Only do recentering when the article buffer is displayed,
6867 ;; Set the window start to either `bottom', which is the biggest
6868 ;; possible valid number, or the second line from the top,
6869 ;; whichever is the least.
6870 (let ((top-pos (save-excursion
6871 (gnus-forward-line-ignore-invisible (- top))
6872 (point))))
6873 (if (> bottom top-pos)
6874 ;; Keep the second line from the top visible
6875 (set-window-start window top-pos)
6876 ;; Try to keep the bottom line visible; if it's partially
6877 ;; obscured, either scroll one more line to make it fully
6878 ;; visible, or revert to using TOP-POS.
6879 (save-excursion
6880 (goto-char (point-max))
6881 (gnus-forward-line-ignore-invisible -1)
6882 (let ((last-line-start (point)))
6883 (goto-char bottom)
6884 (set-window-start window (point) t)
6885 (when (not (pos-visible-in-window-p last-line-start window))
6886 (gnus-forward-line-ignore-invisible 1)
6887 (set-window-start window (min (point) top-pos) t)))))))
6888 ;; Do horizontal recentering while we're at it.
6889 (when (and (get-buffer-window (current-buffer) t)
6890 (not (eq gnus-auto-center-summary 'vertical)))
6891 (let ((selected (selected-window)))
6892 (select-window (get-buffer-window (current-buffer) t))
6893 (gnus-summary-position-point)
6894 (gnus-horizontal-recenter)
6895 (select-window selected))))))
6896
6897 (defun gnus-summary-jump-to-group (newsgroup)
6898 "Move point to NEWSGROUP in group mode buffer."
6899 ;; Keep update point of group mode buffer if visible.
6900 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6901 (save-window-excursion
6902 ;; Take care of tree window mode.
6903 (when (get-buffer-window gnus-group-buffer)
6904 (pop-to-buffer gnus-group-buffer))
6905 (gnus-group-jump-to-group newsgroup))
6906 (save-excursion
6907 ;; Take care of tree window mode.
6908 (if (get-buffer-window gnus-group-buffer 0)
6909 (pop-to-buffer gnus-group-buffer)
6910 (set-buffer gnus-group-buffer))
6911 (gnus-group-jump-to-group newsgroup))))
6912
6913 ;; This function returns a list of article numbers based on the
6914 ;; difference between the ranges of read articles in this group and
6915 ;; the range of active articles.
6916 (defun gnus-list-of-unread-articles (group)
6917 (let* ((read (gnus-info-read (gnus-get-info group)))
6918 (active (or (gnus-active group) (gnus-activate-group group)))
6919 (last (or (cdr active)
6920 (error "Group %s couldn't be activated " group)))
6921 (bottom (if gnus-newsgroup-maximum-articles
6922 (max (car active)
6923 (- last gnus-newsgroup-maximum-articles -1))
6924 (car active)))
6925 first nlast unread)
6926 ;; If none are read, then all are unread.
6927 (if (not read)
6928 (setq first bottom)
6929 ;; If the range of read articles is a single range, then the
6930 ;; first unread article is the article after the last read
6931 ;; article. Sounds logical, doesn't it?
6932 (if (and (not (listp (cdr read)))
6933 (or (< (car read) bottom)
6934 (progn (setq read (list read))
6935 nil)))
6936 (setq first (max bottom (1+ (cdr read))))
6937 ;; `read' is a list of ranges.
6938 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6939 (caar read)))
6940 1)
6941 (setq first bottom))
6942 (while read
6943 (when first
6944 (while (< first nlast)
6945 (setq unread (cons first unread)
6946 first (1+ first))))
6947 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6948 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6949 (setq read (cdr read)))))
6950 ;; And add the last unread articles.
6951 (while (<= first last)
6952 (setq unread (cons first unread)
6953 first (1+ first)))
6954 ;; Return the list of unread articles.
6955 (delq 0 (nreverse unread))))
6956
6957 (defun gnus-list-of-read-articles (group)
6958 "Return a list of unread, unticked and non-dormant articles."
6959 (let* ((info (gnus-get-info group))
6960 (marked (gnus-info-marks info))
6961 (active (gnus-active group)))
6962 (and info active
6963 (gnus-list-range-difference
6964 (gnus-list-range-difference
6965 (gnus-sorted-complement
6966 (gnus-uncompress-range
6967 (if gnus-newsgroup-maximum-articles
6968 (cons (max (car active)
6969 (- (cdr active)
6970 gnus-newsgroup-maximum-articles
6971 -1))
6972 (cdr active))
6973 active))
6974 (gnus-list-of-unread-articles group))
6975 (cdr (assq 'dormant marked)))
6976 (cdr (assq 'tick marked))))))
6977
6978 ;; This function returns a sequence of article numbers based on the
6979 ;; difference between the ranges of read articles in this group and
6980 ;; the range of active articles.
6981 (defun gnus-sequence-of-unread-articles (group)
6982 (let* ((read (gnus-info-read (gnus-get-info group)))
6983 (active (or (gnus-active group) (gnus-activate-group group)))
6984 (last (cdr active))
6985 (bottom (if gnus-newsgroup-maximum-articles
6986 (max (car active)
6987 (- last gnus-newsgroup-maximum-articles -1))
6988 (car active)))
6989 first nlast unread)
6990 ;; If none are read, then all are unread.
6991 (if (not read)
6992 (setq first bottom)
6993 ;; If the range of read articles is a single range, then the
6994 ;; first unread article is the article after the last read
6995 ;; article. Sounds logical, doesn't it?
6996 (if (and (not (listp (cdr read)))
6997 (or (< (car read) bottom)
6998 (progn (setq read (list read))
6999 nil)))
7000 (setq first (max bottom (1+ (cdr read))))
7001 ;; `read' is a list of ranges.
7002 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
7003 (caar read)))
7004 1)
7005 (setq first bottom))
7006 (while read
7007 (when first
7008 (push (cons first nlast) unread))
7009 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
7010 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
7011 (setq read (cdr read)))))
7012 ;; And add the last unread articles.
7013 (cond ((not (and first last))
7014 nil)
7015 ((< first last)
7016 (push (cons first last) unread))
7017 ((= first last)
7018 (push first unread)))
7019 ;; Return the sequence of unread articles.
7020 (delq 0 (nreverse unread))))
7021
7022 ;; Various summary commands
7023
7024 (defun gnus-summary-select-article-buffer ()
7025 "Reconfigure windows to show the article buffer.
7026 If `gnus-widen-article-window' is set, show only the article
7027 buffer."
7028 (interactive)
7029 (if (not (gnus-buffer-live-p gnus-article-buffer))
7030 (error "There is no article buffer for this summary buffer")
7031 (unless (get-buffer-window gnus-article-buffer)
7032 (gnus-summary-show-article))
7033 (gnus-configure-windows
7034 (if gnus-widen-article-window
7035 'only-article
7036 'article)
7037 t)
7038 (select-window (get-buffer-window gnus-article-buffer))))
7039
7040 (defun gnus-summary-universal-argument (arg)
7041 "Perform any operation on all articles that are process/prefixed."
7042 (interactive "P")
7043 (let ((articles (gnus-summary-work-articles arg))
7044 func article)
7045 (if (eq
7046 (setq
7047 func
7048 (key-binding
7049 (read-key-sequence
7050 (substitute-command-keys
7051 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
7052 'undefined)
7053 (gnus-error 1 "Undefined key")
7054 (save-excursion
7055 (while articles
7056 (gnus-summary-goto-subject (setq article (pop articles)))
7057 (let (gnus-newsgroup-processable)
7058 (command-execute func))
7059 (gnus-summary-remove-process-mark article)))))
7060 (gnus-summary-position-point))
7061
7062 (defun gnus-summary-toggle-truncation (&optional arg)
7063 "Toggle truncation of summary lines.
7064 With ARG, turn line truncation on if ARG is positive."
7065 (interactive "P")
7066 (setq truncate-lines
7067 (if (null arg) (not truncate-lines)
7068 (> (prefix-numeric-value arg) 0)))
7069 (redraw-display))
7070
7071 (defun gnus-summary-find-for-reselect ()
7072 "Return the number of an article to stay on across a reselect.
7073 The current article is considered, then following articles, then previous
7074 articles. An article is sought which is not canceled and isn't a temporary
7075 insertion from another group. If there's no such then return a dummy 0."
7076 (let (found)
7077 (dolist (rev '(nil t))
7078 (unless found ; don't demand the reverse list if we don't need it
7079 (let ((data (gnus-data-find-list
7080 (gnus-summary-article-number) (gnus-data-list rev))))
7081 (while (and data (not found))
7082 (if (and (< 0 (gnus-data-number (car data)))
7083 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
7084 (setq found (gnus-data-number (car data))))
7085 (setq data (cdr data))))))
7086 (or found 0)))
7087
7088 (defun gnus-summary-reselect-current-group (&optional all rescan)
7089 "Exit and then reselect the current newsgroup.
7090 The prefix argument ALL means to select all articles."
7091 (interactive "P")
7092 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
7093 (error "Ephemeral groups can't be reselected"))
7094 (let ((current-subject (gnus-summary-find-for-reselect))
7095 (group gnus-newsgroup-name))
7096 (setq gnus-newsgroup-begin nil)
7097 (gnus-summary-exit nil 'leave-hidden)
7098 ;; We have to adjust the point of group mode buffer because
7099 ;; point was moved to the next unread newsgroup by exiting.
7100 (gnus-summary-jump-to-group group)
7101 (when rescan
7102 (save-excursion
7103 (gnus-group-get-new-news-this-group 1)))
7104 (gnus-group-read-group all t)
7105 (gnus-summary-goto-subject current-subject nil t)))
7106
7107 (defun gnus-summary-rescan-group (&optional all)
7108 "Exit the newsgroup, ask for new articles, and select the newsgroup."
7109 (interactive "P")
7110 (let ((config gnus-current-window-configuration))
7111 (gnus-summary-reselect-current-group all t)
7112 (gnus-configure-windows config)
7113 (when (eq config 'article)
7114 (gnus-summary-select-article))))
7115
7116 (defun gnus-summary-update-info (&optional non-destructive)
7117 (save-excursion
7118 (let ((group gnus-newsgroup-name))
7119 (when group
7120 (when gnus-newsgroup-kill-headers
7121 (setq gnus-newsgroup-killed
7122 (gnus-compress-sequence
7123 (gnus-sorted-union
7124 (gnus-list-range-intersection
7125 gnus-newsgroup-unselected gnus-newsgroup-killed)
7126 gnus-newsgroup-unreads)
7127 t)))
7128 (unless (listp (cdr gnus-newsgroup-killed))
7129 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
7130 (let ((headers gnus-newsgroup-headers)
7131 (ephemeral-p (gnus-ephemeral-group-p group))
7132 info)
7133 (unless ephemeral-p
7134 (setq info (copy-sequence (gnus-get-info group))
7135 info (delq (gnus-info-params info) info)))
7136 ;; Set the new ranges of read articles.
7137 (with-current-buffer gnus-group-buffer
7138 (gnus-undo-force-boundary))
7139 (gnus-update-read-articles
7140 group (gnus-sorted-union
7141 gnus-newsgroup-unreads gnus-newsgroup-unselected))
7142 ;; Set the current article marks.
7143 (let ((gnus-newsgroup-scored
7144 (if (and (not gnus-save-score)
7145 (not non-destructive))
7146 nil
7147 gnus-newsgroup-scored)))
7148 (save-excursion
7149 (gnus-update-marks)))
7150 ;; Do the cross-ref thing.
7151 (when gnus-use-cross-reference
7152 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
7153 ;; Do not switch windows but change the buffer to work.
7154 (set-buffer gnus-group-buffer)
7155 (unless ephemeral-p
7156 (gnus-group-update-group
7157 group nil
7158 (equal info
7159 (setq info (copy-sequence (gnus-get-info group))
7160 info (delq (gnus-info-params info) info))))))))))
7161
7162 (defun gnus-summary-save-newsrc (&optional force)
7163 "Save the current number of read/marked articles in the dribble buffer.
7164 The dribble buffer will then be saved.
7165 If FORCE (the prefix), also save the .newsrc file(s)."
7166 (interactive "P")
7167 (gnus-summary-update-info t)
7168 (if force
7169 (gnus-save-newsrc-file)
7170 (gnus-dribble-save)))
7171
7172 (declare-function gnus-cache-write-active "gnus-cache" (&optional force))
7173 (declare-function gnus-article-stop-animations "gnus-art" ())
7174
7175 (defun gnus-summary-exit (&optional temporary leave-hidden)
7176 "Exit reading current newsgroup, and then return to group selection mode.
7177 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
7178 (interactive)
7179 (gnus-set-global-variables)
7180 (when (gnus-buffer-live-p gnus-article-buffer)
7181 (with-current-buffer gnus-article-buffer
7182 (mm-destroy-parts gnus-article-mime-handles)
7183 ;; Set it to nil for safety reason.
7184 (setq gnus-article-mime-handle-alist nil)
7185 (setq gnus-article-mime-handles nil)))
7186 (gnus-kill-save-kill-buffer)
7187 (gnus-async-halt-prefetch)
7188 (let* ((group gnus-newsgroup-name)
7189 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
7190 (gnus-group-is-exiting-p t)
7191 (article-buffer gnus-article-buffer)
7192 (original-article-buffer gnus-original-article-buffer)
7193 (mode major-mode)
7194 (group-point nil)
7195 (buf (current-buffer))
7196 ;; `gnus-single-article-buffer' is nil buffer-locally in
7197 ;; ephemeral group of which summary buffer will be killed,
7198 ;; but the global value may be non-nil.
7199 (single-article-buffer gnus-single-article-buffer))
7200 (unless quit-config
7201 ;; Do adaptive scoring, and possibly save score files.
7202 (when gnus-newsgroup-adaptive
7203 (gnus-score-adaptive))
7204 (when gnus-use-scoring
7205 (gnus-score-save)))
7206 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
7207 (when gnus-use-cache
7208 (gnus-cache-possibly-remove-articles)
7209 (gnus-cache-save-buffers))
7210 (gnus-async-prefetch-remove-group group)
7211 (when gnus-suppress-duplicates
7212 (gnus-dup-enter-articles))
7213 (when gnus-use-trees
7214 (gnus-tree-close))
7215 (when gnus-use-cache
7216 (gnus-cache-write-active))
7217 ;; Remove entries for this group.
7218 (nnmail-purge-split-history (gnus-group-real-name group))
7219 ;; Make all changes in this group permanent.
7220 (unless quit-config
7221 (gnus-run-hooks 'gnus-exit-group-hook)
7222 (gnus-summary-update-info))
7223 (gnus-close-group group)
7224 ;; Make sure where we were, and go to next newsgroup.
7225 (when (buffer-live-p (get-buffer gnus-group-buffer))
7226 (set-buffer gnus-group-buffer))
7227 (unless quit-config
7228 (gnus-group-jump-to-group group))
7229 (gnus-run-hooks 'gnus-summary-exit-hook)
7230 (unless (or quit-config
7231 (not gnus-summary-next-group-on-exit)
7232 ;; If this group has disappeared from the summary
7233 ;; buffer, don't skip forwards.
7234 (not (string= group (gnus-group-group-name))))
7235 (gnus-group-next-unread-group 1))
7236 (setq group-point (point))
7237 (gnus-article-stop-animations)
7238 (if temporary
7239 nil ;Nothing to do.
7240 (set-buffer buf)
7241 (if (not gnus-kill-summary-on-exit)
7242 (progn
7243 (gnus-deaden-summary)
7244 (setq mode nil))
7245 (when (get-buffer gnus-article-buffer)
7246 (bury-buffer gnus-article-buffer))
7247 ;; Return to group mode buffer.
7248 (when (eq mode 'gnus-summary-mode)
7249 (gnus-kill-buffer buf)))
7250
7251 (setq gnus-current-select-method gnus-select-method)
7252 (when (gnus-buffer-live-p gnus-group-buffer)
7253 (set-buffer gnus-group-buffer))
7254 (if quit-config
7255 (gnus-handle-ephemeral-exit quit-config)
7256 (goto-char group-point)
7257 ;; If gnus-group-buffer is already displayed, make sure we also move
7258 ;; the cursor in the window that displays it.
7259 (let ((win (get-buffer-window (current-buffer) 0)))
7260 (if win (set-window-point win (point))))
7261 (unless leave-hidden
7262 (gnus-configure-windows 'group 'force)))
7263
7264 ;; If we have several article buffers, we kill them at exit.
7265 (unless single-article-buffer
7266 (when (gnus-buffer-live-p article-buffer)
7267 (with-current-buffer article-buffer
7268 ;; Don't kill sticky article buffers
7269 (unless (eq major-mode 'gnus-sticky-article-mode)
7270 (gnus-kill-buffer article-buffer)
7271 (setq gnus-article-current nil))))
7272 (gnus-kill-buffer original-article-buffer))
7273
7274 ;; Clear the current group name.
7275 (unless quit-config
7276 (setq gnus-newsgroup-name nil)))))
7277
7278 (declare-function gnus-stop-downloads "gnus-art" ())
7279
7280 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
7281 (defun gnus-summary-exit-no-update (&optional no-questions)
7282 "Quit reading current newsgroup without updating read article info."
7283 (interactive)
7284 (let* ((group gnus-newsgroup-name)
7285 (gnus-group-is-exiting-p t)
7286 (gnus-group-is-exiting-without-update-p t)
7287 (quit-config (gnus-group-quit-config group)))
7288 (when (or no-questions
7289 (gnus-ephemeral-group-p group)
7290 gnus-expert-user
7291 (gnus-y-or-n-p "Discard changes to this group and exit? "))
7292 (gnus-async-halt-prefetch)
7293 (run-hooks 'gnus-summary-prepare-exit-hook)
7294 (when (gnus-buffer-live-p gnus-article-buffer)
7295 (with-current-buffer gnus-article-buffer
7296 (gnus-article-stop-animations)
7297 (gnus-stop-downloads)
7298 (mm-destroy-parts gnus-article-mime-handles)
7299 ;; Set it to nil for safety reason.
7300 (setq gnus-article-mime-handle-alist nil)
7301 (setq gnus-article-mime-handles nil)))
7302 ;; If we have several article buffers, we kill them at exit.
7303 (unless gnus-single-article-buffer
7304 (gnus-kill-buffer gnus-article-buffer)
7305 (gnus-kill-buffer gnus-original-article-buffer)
7306 (setq gnus-article-current nil))
7307 ;; Return to the group buffer.
7308 (if (not gnus-kill-summary-on-exit)
7309 (progn
7310 (gnus-deaden-summary)
7311 (gnus-configure-windows 'group 'force))
7312 (gnus-configure-windows 'group 'force)
7313 (gnus-close-group group)
7314 (gnus-kill-buffer gnus-summary-buffer))
7315 (unless gnus-single-article-buffer
7316 (setq gnus-article-current nil))
7317 (when gnus-use-trees
7318 (gnus-tree-close))
7319 (gnus-async-prefetch-remove-group group)
7320 (when (get-buffer gnus-article-buffer)
7321 (bury-buffer gnus-article-buffer))
7322 ;; Clear the current group name.
7323 (setq gnus-newsgroup-name nil)
7324 (unless (gnus-ephemeral-group-p group)
7325 (gnus-group-update-group group nil t))
7326 (when (equal (gnus-group-group-name) group)
7327 (gnus-group-next-unread-group 1))
7328 (gnus-article-stop-animations)
7329 (when quit-config
7330 (gnus-handle-ephemeral-exit quit-config)))))
7331
7332 (defun gnus-handle-ephemeral-exit (quit-config)
7333 "Handle movement when leaving an ephemeral group.
7334 The state which existed when entering the ephemeral is reset."
7335 (if (not (buffer-live-p (car quit-config)))
7336 (when (gnus-buffer-live-p gnus-group-buffer)
7337 (gnus-configure-windows 'group 'force))
7338 (set-buffer (car quit-config))
7339 (unless (eq (cdr quit-config) 'group)
7340 (setq gnus-current-select-method
7341 (gnus-find-method-for-group gnus-newsgroup-name)))
7342 (cond ((derived-mode-p 'gnus-summary-mode)
7343 (gnus-set-global-variables))
7344 ((derived-mode-p 'gnus-article-mode)
7345 (save-current-buffer
7346 ;; The `gnus-summary-buffer' variable may point
7347 ;; to the old summary buffer when using a single
7348 ;; article buffer.
7349 (unless (gnus-buffer-live-p gnus-summary-buffer)
7350 (set-buffer gnus-group-buffer))
7351 (set-buffer gnus-summary-buffer)
7352 (gnus-set-global-variables))))
7353 (if (or (eq (cdr quit-config) 'article)
7354 (eq (cdr quit-config) 'pick))
7355 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
7356 (gnus-configure-windows 'pick 'force)
7357 (gnus-configure-windows (cdr quit-config) 'force))
7358 (gnus-configure-windows (cdr quit-config) 'force))
7359 (when (derived-mode-p 'gnus-summary-mode)
7360 (if (memq gnus-auto-select-on-ephemeral-exit '(next-noselect
7361 next-unread-noselect))
7362 (when (zerop (cond ((eq gnus-auto-select-on-ephemeral-exit
7363 'next-noselect)
7364 (gnus-summary-next-subject 1 nil t))
7365 ((eq gnus-auto-select-on-ephemeral-exit
7366 'next-unread-noselect)
7367 (gnus-summary-next-subject 1 t t))))
7368 ;; Hide the article buffer which displays the article different
7369 ;; from the one that the cursor points to in the summary buffer.
7370 (gnus-configure-windows 'summary 'force))
7371 (cond ((eq gnus-auto-select-on-ephemeral-exit 'next)
7372 (gnus-summary-next-subject 1))
7373 ((eq gnus-auto-select-on-ephemeral-exit 'next-unread)
7374 (gnus-summary-next-subject 1 t))))
7375 (gnus-summary-recenter)
7376 (gnus-summary-position-point))))
7377
7378 ;;; Dead summaries.
7379
7380 (defvar gnus-dead-summary-mode-map
7381 (let ((map (make-keymap)))
7382 (suppress-keymap map)
7383 (substitute-key-definition 'undefined 'gnus-summary-wake-up-the-dead map)
7384 (dolist (key '("\C-d" "\r" "\177" [delete]))
7385 (define-key map key 'gnus-summary-wake-up-the-dead))
7386 (dolist (key '("q" "Q"))
7387 (define-key map key 'bury-buffer))
7388 map))
7389
7390 (define-minor-mode gnus-dead-summary-mode
7391 "Minor mode for Gnus summary buffers."
7392 :lighter " Dead" :keymap gnus-dead-summary-mode-map
7393 (unless (derived-mode-p 'gnus-summary-mode)
7394 (setq gnus-dead-summary-mode nil)))
7395
7396 (defun gnus-deaden-summary ()
7397 "Make the current summary buffer into a dead summary buffer."
7398 ;; Kill any previous dead summary buffer.
7399 (when (and gnus-dead-summary
7400 (buffer-name gnus-dead-summary))
7401 (with-current-buffer gnus-dead-summary
7402 (when gnus-dead-summary-mode
7403 (kill-buffer (current-buffer)))))
7404 ;; Make this the current dead summary.
7405 (setq gnus-dead-summary (current-buffer))
7406 (gnus-dead-summary-mode 1)
7407 (let ((name (buffer-name)))
7408 (when (string-match "Summary" name)
7409 (rename-buffer
7410 (concat (substring name 0 (match-beginning 0)) "Dead "
7411 (substring name (match-beginning 0)))
7412 t)
7413 (bury-buffer))))
7414
7415 (defun gnus-kill-or-deaden-summary (buffer)
7416 "Kill or deaden the summary BUFFER."
7417 (save-excursion
7418 (when (and (buffer-name buffer)
7419 (not gnus-single-article-buffer))
7420 (with-current-buffer buffer
7421 (gnus-kill-buffer gnus-article-buffer)
7422 (gnus-kill-buffer gnus-original-article-buffer)))
7423 (cond
7424 ;; Kill the buffer.
7425 (gnus-kill-summary-on-exit
7426 (when (and gnus-use-trees
7427 (gnus-buffer-exists-p buffer))
7428 (with-current-buffer buffer
7429 (gnus-tree-close)))
7430 (gnus-kill-buffer buffer))
7431 ;; Deaden the buffer.
7432 ((gnus-buffer-exists-p buffer)
7433 (with-current-buffer buffer
7434 (gnus-deaden-summary))))))
7435
7436 (defun gnus-summary-wake-up-the-dead (&rest args)
7437 "Wake up the dead summary buffer."
7438 (interactive)
7439 (gnus-dead-summary-mode -1)
7440 (let ((name (buffer-name)))
7441 (when (string-match "Dead " name)
7442 (rename-buffer
7443 (concat (substring name 0 (match-beginning 0))
7444 (substring name (match-end 0)))
7445 t)))
7446 (gnus-message 3 "This dead summary is now alive again"))
7447
7448 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
7449 (defun gnus-summary-describe-group (&optional force)
7450 "Describe the current newsgroup."
7451 (interactive "P")
7452 (gnus-group-describe-group force gnus-newsgroup-name))
7453
7454 (defun gnus-summary-describe-briefly ()
7455 "Describe summary mode commands briefly."
7456 (interactive)
7457 (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")))
7458
7459 ;; Walking around group mode buffer from summary mode.
7460
7461 (defun gnus-summary-next-group (&optional no-article target-group backward)
7462 "Exit current newsgroup and then select next unread newsgroup.
7463 If prefix argument NO-ARTICLE is non-nil, no article is selected
7464 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
7465 previous group instead."
7466 (interactive "P")
7467 ;; Stop pre-fetching.
7468 (gnus-async-halt-prefetch)
7469 (let ((current-group gnus-newsgroup-name)
7470 (current-buffer (current-buffer))
7471 entered)
7472 ;; First we semi-exit this group to update Xrefs and all variables.
7473 ;; We can't do a real exit, because the window conf must remain
7474 ;; the same in case the user is prompted for info, and we don't
7475 ;; want the window conf to change before that...
7476 (gnus-summary-exit t)
7477 (while (not entered)
7478 ;; Then we find what group we are supposed to enter.
7479 (set-buffer gnus-group-buffer)
7480 (gnus-group-jump-to-group current-group)
7481 (setq target-group
7482 (or target-group
7483 (if (eq gnus-keep-same-level 'best)
7484 (gnus-summary-best-group gnus-newsgroup-name)
7485 (gnus-summary-search-group backward gnus-keep-same-level))))
7486 (if (not target-group)
7487 ;; There are no further groups, so we return to the group
7488 ;; buffer.
7489 (progn
7490 (gnus-message 5 "Returning to the group buffer")
7491 (setq entered t)
7492 (when (gnus-buffer-live-p current-buffer)
7493 (set-buffer current-buffer)
7494 (gnus-summary-exit))
7495 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
7496 ;; We try to enter the target group.
7497 (gnus-group-jump-to-group target-group)
7498 (let ((unreads (gnus-group-group-unread)))
7499 (if (and (or (eq t unreads)
7500 (and unreads (not (zerop unreads))))
7501 (gnus-summary-read-group
7502 target-group nil no-article
7503 (and (buffer-name current-buffer) current-buffer)
7504 nil backward))
7505 (setq entered t)
7506 (setq current-group target-group
7507 target-group nil)))))))
7508
7509 (defun gnus-summary-prev-group (&optional no-article)
7510 "Exit current newsgroup and then select previous unread newsgroup.
7511 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
7512 (interactive "P")
7513 (gnus-summary-next-group no-article nil t))
7514
7515 ;; Walking around summary lines.
7516
7517 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
7518 "Go to the first subject satisfying any non-nil constraint.
7519 If UNREAD is non-nil, the article should be unread.
7520 If UNDOWNLOADED is non-nil, the article should be undownloaded.
7521 If UNSEEN is non-nil, the article should be unseen as well as unread.
7522 Returns the article selected or nil if there are no matching articles."
7523 (interactive "P")
7524 (cond
7525 ;; Empty summary.
7526 ((null gnus-newsgroup-data)
7527 (gnus-message 3 "No articles in the group")
7528 nil)
7529 ;; Pick the first article.
7530 ((not (or unread undownloaded unseen))
7531 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
7532 (gnus-data-number (car gnus-newsgroup-data)))
7533 ;; Find the first unread article.
7534 (t
7535 (let ((data gnus-newsgroup-data))
7536 (while (and data
7537 (let ((num (gnus-data-number (car data))))
7538 (or (memq num gnus-newsgroup-unfetched)
7539 (not (or (and unread
7540 (memq num gnus-newsgroup-unreads))
7541 (and undownloaded
7542 (memq num gnus-newsgroup-undownloaded))
7543 (and unseen
7544 (memq num gnus-newsgroup-unseen)
7545 (memq num gnus-newsgroup-unreads)))))))
7546 (setq data (cdr data)))
7547 (prog1
7548 (if data
7549 (progn
7550 (goto-char (gnus-data-pos (car data)))
7551 (gnus-data-number (car data)))
7552 (gnus-message 3 "No more%s articles"
7553 (let* ((r (when unread " unread"))
7554 (d (when undownloaded " undownloaded"))
7555 (s (when unseen " unseen"))
7556 (l (delq nil (list r d s))))
7557 (cond ((= 3 (length l))
7558 (concat r "," d ", or" s))
7559 ((= 2 (length l))
7560 (concat (car l) ", or" (cadr l)))
7561 ((= 1 (length l))
7562 (car l))
7563 (t
7564 ""))))
7565 nil
7566 )
7567 (gnus-summary-position-point))))))
7568
7569 (defun gnus-summary-next-subject (n &optional unread dont-display)
7570 "Go to next N'th summary line.
7571 If N is negative, go to the previous N'th subject line.
7572 If UNREAD is non-nil, only unread articles are selected.
7573 The difference between N and the actual number of steps taken is
7574 returned."
7575 (interactive "p")
7576 (let ((backward (< n 0))
7577 (n (abs n)))
7578 (while (and (> n 0)
7579 (if backward
7580 (gnus-summary-find-prev unread)
7581 (gnus-summary-find-next unread)))
7582 (unless (zerop (setq n (1- n)))
7583 (gnus-summary-show-thread)))
7584 (when (/= 0 n)
7585 (gnus-message 7 "No more%s articles"
7586 (if unread " unread" "")))
7587 (unless dont-display
7588 (gnus-summary-recenter)
7589 (gnus-summary-position-point))
7590 n))
7591
7592 (defun gnus-summary-next-unread-subject (n)
7593 "Go to next N'th unread summary line."
7594 (interactive "p")
7595 (gnus-summary-next-subject n t))
7596
7597 (defun gnus-summary-prev-subject (n &optional unread)
7598 "Go to previous N'th summary line.
7599 If optional argument UNREAD is non-nil, only unread article is selected."
7600 (interactive "p")
7601 (gnus-summary-next-subject (- n) unread))
7602
7603 (defun gnus-summary-prev-unread-subject (n)
7604 "Go to previous N'th unread summary line."
7605 (interactive "p")
7606 (gnus-summary-next-subject (- n) t))
7607
7608 (defun gnus-summary-goto-subjects (articles)
7609 "Insert the subject header for ARTICLES in the current buffer."
7610 (save-excursion
7611 (dolist (article articles)
7612 (gnus-summary-goto-subject article t)))
7613 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7614 (gnus-summary-position-point))
7615
7616 (defun gnus-summary-goto-subject (article &optional force silent)
7617 "Go to the subject line of ARTICLE.
7618 If FORCE, also allow jumping to articles not currently shown."
7619 (interactive "nArticle number: ")
7620 (unless (numberp article)
7621 (error "Article %s is not a number" article))
7622 (let ((b (point))
7623 (data (gnus-data-find article)))
7624 ;; We read in the article if we have to.
7625 (and (not data)
7626 force
7627 (gnus-summary-insert-subject
7628 article
7629 (if (or (numberp force) (vectorp force)) force)
7630 t)
7631 (setq data (gnus-data-find article)))
7632 (goto-char b)
7633 (if (not data)
7634 (progn
7635 (unless silent
7636 (gnus-message 3 "Can't find article %d" article))
7637 nil)
7638 (let ((pt (gnus-data-pos data)))
7639 (goto-char pt)
7640 (gnus-summary-set-article-display-arrow pt))
7641 (gnus-summary-position-point)
7642 article)))
7643
7644 ;; Walking around summary lines with displaying articles.
7645
7646 (defun gnus-summary-expand-window (&optional arg)
7647 "Make the summary buffer take up the entire Emacs frame.
7648 Given a prefix, will force an `article' buffer configuration."
7649 (interactive "P")
7650 (if arg
7651 (gnus-configure-windows 'article 'force)
7652 (gnus-configure-windows 'summary 'force)))
7653
7654 (defun gnus-summary-display-article (article &optional all-header)
7655 "Display ARTICLE in article buffer."
7656 (unless (and (gnus-buffer-live-p gnus-article-buffer)
7657 (with-current-buffer gnus-article-buffer
7658 (derived-mode-p 'gnus-article-mode)))
7659 (gnus-article-setup-buffer))
7660 (gnus-set-global-variables)
7661 (with-current-buffer gnus-article-buffer
7662 (setq gnus-article-charset gnus-newsgroup-charset)
7663 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7664 (mm-enable-multibyte))
7665 (if (null article)
7666 nil
7667 (prog1
7668 (if gnus-summary-display-article-function
7669 (funcall gnus-summary-display-article-function article all-header)
7670 (gnus-article-prepare article all-header))
7671 (gnus-run-hooks 'gnus-select-article-hook)
7672 (when (and gnus-current-article
7673 (not (zerop gnus-current-article)))
7674 (gnus-summary-goto-subject gnus-current-article))
7675 (gnus-summary-recenter)
7676 (when (and gnus-use-trees gnus-show-threads)
7677 (gnus-possibly-generate-tree article)
7678 (gnus-highlight-selected-tree article))
7679 ;; Successfully display article.
7680 (gnus-article-set-window-start
7681 (cdr (assq article gnus-newsgroup-bookmarks))))))
7682
7683 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7684 "Select the current article.
7685 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7686 non-nil, the article will be re-fetched even if it already present in
7687 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7688 be displayed."
7689 ;; Make sure we are in the summary buffer to work around bbdb bug.
7690 (unless (derived-mode-p 'gnus-summary-mode)
7691 (set-buffer gnus-summary-buffer))
7692 (let ((article (or article (gnus-summary-article-number)))
7693 (all-headers (not (not all-headers))) ;Must be t or nil.
7694 gnus-summary-display-article-function)
7695 (and (not pseudo)
7696 (gnus-summary-article-pseudo-p article)
7697 (error "This is a pseudo-article"))
7698 (with-current-buffer gnus-summary-buffer
7699 (if (or (and gnus-single-article-buffer
7700 (or (null gnus-current-article)
7701 (null gnus-article-current)
7702 (null (get-buffer gnus-article-buffer))
7703 (not (eq article (cdr gnus-article-current)))
7704 (not (equal (car gnus-article-current)
7705 gnus-newsgroup-name))
7706 (not (get-buffer gnus-original-article-buffer))))
7707 (and (not gnus-single-article-buffer)
7708 (or (null gnus-current-article)
7709 (not (get-buffer gnus-original-article-buffer))
7710 (not (eq gnus-current-article article))))
7711 force)
7712 ;; The requested article is different from the current article.
7713 (progn
7714 (gnus-summary-display-article article all-headers)
7715 (when (gnus-buffer-live-p gnus-article-buffer)
7716 (with-current-buffer gnus-article-buffer
7717 (if (not gnus-article-decoded-p) ;; a local variable
7718 (mm-disable-multibyte))))
7719 (gnus-article-set-window-start
7720 (cdr (assq article gnus-newsgroup-bookmarks)))
7721 article)
7722 'old))))
7723
7724 (defun gnus-summary-force-verify-and-decrypt ()
7725 "Display buttons for signed/encrypted parts and verify/decrypt them."
7726 (interactive)
7727 (let ((mm-verify-option 'known)
7728 (mm-decrypt-option 'known)
7729 (gnus-article-emulate-mime t)
7730 (gnus-buttonized-mime-types (append (list "multipart/signed"
7731 "multipart/encrypted")
7732 gnus-buttonized-mime-types)))
7733 (gnus-summary-select-article nil 'force)))
7734
7735 (defun gnus-summary-next-article (&optional unread subject backward push)
7736 "Select the next article.
7737 If UNREAD, only unread articles are selected.
7738 If SUBJECT, only articles with SUBJECT are selected.
7739 If BACKWARD, the previous article is selected instead of the next."
7740 (interactive "P")
7741 ;; Make sure we are in the summary buffer.
7742 (unless (derived-mode-p 'gnus-summary-mode)
7743 (set-buffer gnus-summary-buffer))
7744 (cond
7745 ;; Is there such an article?
7746 ((and (gnus-summary-search-forward unread subject backward)
7747 (or (gnus-summary-display-article (gnus-summary-article-number))
7748 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7749 (gnus-summary-position-point))
7750 ;; If not, we try the first unread, if that is wanted.
7751 ((and subject
7752 gnus-auto-select-same
7753 (gnus-summary-first-unread-article))
7754 (gnus-summary-position-point)
7755 (gnus-message 6 "Wrapped"))
7756 ;; Try to get next/previous article not displayed in this group.
7757 ((and gnus-auto-extend-newsgroup
7758 (not unread) (not subject))
7759 (gnus-summary-goto-article
7760 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7761 nil (count-lines (point-min) (point))))
7762 ;; Go to next/previous group.
7763 (t
7764 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7765 (gnus-summary-jump-to-group gnus-newsgroup-name))
7766 (let ((cmd last-command-event)
7767 (point
7768 (with-current-buffer gnus-group-buffer
7769 (point)))
7770 (current-summary (current-buffer))
7771 (group
7772 (if (eq gnus-keep-same-level 'best)
7773 (gnus-summary-best-group gnus-newsgroup-name)
7774 (gnus-summary-search-group backward gnus-keep-same-level))))
7775 ;; Select next unread newsgroup automagically.
7776 (cond
7777 ((or (not gnus-auto-select-next)
7778 (not cmd))
7779 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7780 ((or (eq gnus-auto-select-next 'quietly)
7781 (and (eq gnus-auto-select-next 'slightly-quietly)
7782 push)
7783 (and (eq gnus-auto-select-next 'almost-quietly)
7784 (gnus-summary-last-article-p)))
7785 ;; Select quietly.
7786 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7787 (gnus-summary-exit)
7788 (gnus-message 7 "No more%s articles (%s)..."
7789 (if unread " unread" "")
7790 (if group (concat "selecting " group)
7791 "exiting"))
7792 (gnus-summary-next-group nil group backward)))
7793 (t
7794 (when (numberp last-input-event)
7795 ;; Somehow or other, we may now have selected a different
7796 ;; window. Make point go back to the summary buffer.
7797 (when (eq current-summary (current-buffer))
7798 ;; FIXME: This burps when get-buffer-window returns nil.
7799 (select-window (get-buffer-window current-summary 0)))
7800 (gnus-summary-walk-group-buffer
7801 gnus-newsgroup-name cmd unread backward point))))))))
7802
7803 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7804 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7805 (?\C-p (gnus-group-prev-unread-group 1))))
7806 (cursor-in-echo-area t)
7807 keve key group ended prompt)
7808 (with-current-buffer gnus-group-buffer
7809 (goto-char start)
7810 (setq group
7811 (if (eq gnus-keep-same-level 'best)
7812 (gnus-summary-best-group gnus-newsgroup-name)
7813 (gnus-summary-search-group backward gnus-keep-same-level))))
7814 (while (not ended)
7815 (setq prompt
7816 (format
7817 "No more%s articles%s " (if unread " unread" "")
7818 (if (and group
7819 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7820 (format " (Type %s for %s [%s])"
7821 (single-key-description cmd)
7822 (gnus-group-decoded-name group)
7823 (gnus-group-unread group))
7824 (format " (Type %s to exit %s)"
7825 (single-key-description cmd)
7826 (gnus-group-decoded-name gnus-newsgroup-name)))))
7827 ;; Confirm auto selection.
7828 (setq key (car (setq keve (gnus-read-event-char prompt)))
7829 ended t)
7830 (cond
7831 ((assq key keystrokes)
7832 (let ((obuf (current-buffer)))
7833 (switch-to-buffer gnus-group-buffer)
7834 (when group
7835 (gnus-group-jump-to-group group))
7836 (eval (cadr (assq key keystrokes)))
7837 (setq group (gnus-group-group-name))
7838 (switch-to-buffer obuf))
7839 (setq ended nil))
7840 ((equal key cmd)
7841 (if (or (not group)
7842 (gnus-ephemeral-group-p gnus-newsgroup-name))
7843 (gnus-summary-exit)
7844 (gnus-summary-next-group nil group backward)))
7845 (t
7846 (push (cdr keve) unread-command-events))))))
7847
7848 (defun gnus-summary-next-unread-article ()
7849 "Select unread article after current one."
7850 (interactive)
7851 (gnus-summary-next-article
7852 (or (not (eq gnus-summary-goto-unread 'never))
7853 (gnus-summary-last-article-p (gnus-summary-article-number)))
7854 (and gnus-auto-select-same
7855 (gnus-summary-article-subject))))
7856
7857 (defun gnus-summary-prev-article (&optional unread subject)
7858 "Select the article before the current one.
7859 If UNREAD is non-nil, only unread articles are selected."
7860 (interactive "P")
7861 (gnus-summary-next-article unread subject t))
7862
7863 (defun gnus-summary-prev-unread-article ()
7864 "Select unread article before current one."
7865 (interactive)
7866 (gnus-summary-prev-article
7867 (or (not (eq gnus-summary-goto-unread 'never))
7868 (gnus-summary-first-article-p (gnus-summary-article-number)))
7869 (and gnus-auto-select-same
7870 (gnus-summary-article-subject))))
7871
7872 (declare-function gnus-article-only-boring-p "gnus-art" ())
7873
7874 (defun gnus-summary-next-page (&optional lines circular stop)
7875 "Show next page of the selected article.
7876 If at the end of the current article, select the next article.
7877 LINES says how many lines should be scrolled up.
7878
7879 If CIRCULAR is non-nil, go to the start of the article instead of
7880 selecting the next article when reaching the end of the current
7881 article.
7882
7883 If STOP is non-nil, just stop when reaching the end of the message.
7884
7885 Also see the variable `gnus-article-skip-boring'."
7886 (interactive "P")
7887 (gnus-set-global-variables)
7888 (let ((article (gnus-summary-article-number))
7889 (article-window (get-buffer-window gnus-article-buffer t))
7890 endp)
7891 ;; If the buffer is empty, we have no article.
7892 (unless article
7893 (error "No article to select"))
7894 (gnus-configure-windows 'article)
7895 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7896 (if (and (eq gnus-summary-goto-unread 'never)
7897 (not (gnus-summary-last-article-p article)))
7898 (gnus-summary-next-article)
7899 (gnus-summary-next-unread-article))
7900 (if (or (null gnus-current-article)
7901 (null gnus-article-current)
7902 (/= article (cdr gnus-article-current))
7903 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7904 ;; Selected subject is different from current article's.
7905 (gnus-summary-display-article article)
7906 (when article-window
7907 (gnus-eval-in-buffer-window gnus-article-buffer
7908 (setq endp (or (gnus-article-next-page lines)
7909 (gnus-article-only-boring-p))))
7910 (when endp
7911 (cond ((or stop gnus-summary-stop-at-end-of-message)
7912 (gnus-message 3 "End of message"))
7913 (circular
7914 (gnus-summary-beginning-of-article))
7915 (lines
7916 (gnus-message 3 "End of message"))
7917 ((null lines)
7918 (if (and (eq gnus-summary-goto-unread 'never)
7919 (not (gnus-summary-last-article-p article)))
7920 (gnus-summary-next-article)
7921 (gnus-summary-next-unread-article))))))))
7922 (gnus-summary-recenter)
7923 (gnus-summary-position-point)))
7924
7925 (defun gnus-summary-prev-page (&optional lines move)
7926 "Show previous page of selected article.
7927 Argument LINES specifies lines to be scrolled down.
7928 If MOVE, move to the previous unread article if point is at
7929 the beginning of the buffer."
7930 (interactive "P")
7931 (let ((article (gnus-summary-article-number))
7932 (article-window (get-buffer-window gnus-article-buffer t))
7933 endp)
7934 (gnus-configure-windows 'article)
7935 (if (or (null gnus-current-article)
7936 (null gnus-article-current)
7937 (/= article (cdr gnus-article-current))
7938 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7939 ;; Selected subject is different from current article's.
7940 (gnus-summary-display-article article)
7941 (gnus-summary-recenter)
7942 (when article-window
7943 (gnus-eval-in-buffer-window gnus-article-buffer
7944 (setq endp (gnus-article-prev-page lines)))
7945 (when (and move endp)
7946 (cond (lines
7947 (gnus-message 3 "Beginning of message"))
7948 ((null lines)
7949 (if (and (eq gnus-summary-goto-unread 'never)
7950 (not (gnus-summary-first-article-p article)))
7951 (gnus-summary-prev-article)
7952 (gnus-summary-prev-unread-article))))))))
7953 (gnus-summary-position-point))
7954
7955 (defun gnus-summary-prev-page-or-article (&optional lines)
7956 "Show previous page of selected article.
7957 Argument LINES specifies lines to be scrolled down.
7958 If at the beginning of the article, go to the next article."
7959 (interactive "P")
7960 (gnus-summary-prev-page lines t))
7961
7962 (defun gnus-summary-scroll-up (lines)
7963 "Scroll up (or down) one line current article.
7964 Argument LINES specifies lines to be scrolled up (or down if negative).
7965 If no article is selected, then the current article will be selected first."
7966 (interactive "p")
7967 (gnus-configure-windows 'article)
7968 (gnus-summary-show-thread)
7969 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7970 (gnus-eval-in-buffer-window gnus-article-buffer
7971 (cond ((> lines 0)
7972 (when (gnus-article-next-page lines)
7973 (gnus-message 3 "End of message")))
7974 ((< lines 0)
7975 (gnus-article-prev-page (- lines))))))
7976 (gnus-summary-recenter)
7977 (gnus-summary-position-point))
7978
7979 (defun gnus-summary-scroll-down (lines)
7980 "Scroll down (or up) one line current article.
7981 Argument LINES specifies lines to be scrolled down (or up if negative).
7982 If no article is selected, then the current article will be selected first."
7983 (interactive "p")
7984 (gnus-summary-scroll-up (- lines)))
7985
7986 (defun gnus-summary-next-same-subject ()
7987 "Select next article which has the same subject as current one."
7988 (interactive)
7989 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7990
7991 (defun gnus-summary-prev-same-subject ()
7992 "Select previous article which has the same subject as current one."
7993 (interactive)
7994 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7995
7996 (defun gnus-summary-next-unread-same-subject ()
7997 "Select next unread article which has the same subject as current one."
7998 (interactive)
7999 (gnus-summary-next-article t (gnus-summary-article-subject)))
8000
8001 (defun gnus-summary-prev-unread-same-subject ()
8002 "Select previous unread article which has the same subject as current one."
8003 (interactive)
8004 (gnus-summary-prev-article t (gnus-summary-article-subject)))
8005
8006 (defun gnus-summary-first-unread-article ()
8007 "Select the first unread article.
8008 Return nil if there are no unread articles."
8009 (interactive)
8010 (prog1
8011 (when (gnus-summary-first-subject t)
8012 (gnus-summary-show-thread)
8013 (gnus-summary-first-subject t)
8014 (gnus-summary-display-article (gnus-summary-article-number)))
8015 (gnus-summary-position-point)))
8016
8017 (defun gnus-summary-first-unread-subject ()
8018 "Place the point on the subject line of the first unread article.
8019 Return nil if there are no unread articles."
8020 (interactive)
8021 (prog1
8022 (when (gnus-summary-first-subject t)
8023 (gnus-summary-show-thread)
8024 (gnus-summary-first-subject t))
8025 (gnus-summary-position-point)))
8026
8027 (defun gnus-summary-first-unseen-subject ()
8028 "Place the point on the subject line of the first unseen article.
8029 Return nil if there are no unseen articles."
8030 (interactive)
8031 (prog1
8032 (when (gnus-summary-first-subject nil nil t)
8033 (gnus-summary-show-thread)
8034 (gnus-summary-first-subject nil nil t))
8035 (gnus-summary-position-point)))
8036
8037 (defun gnus-summary-first-unseen-or-unread-subject ()
8038 "Place the point on the subject line of the first unseen and unread article.
8039 If all article have been seen, on the subject line of the first unread
8040 article."
8041 (interactive)
8042 (prog1
8043 (unless (when (gnus-summary-first-subject nil nil t)
8044 (gnus-summary-show-thread)
8045 (gnus-summary-first-subject nil nil t))
8046 (when (gnus-summary-first-subject t)
8047 (gnus-summary-show-thread)
8048 (gnus-summary-first-subject t)))
8049 (gnus-summary-position-point)))
8050
8051 (defun gnus-summary-first-article ()
8052 "Select the first article.
8053 Return nil if there are no articles."
8054 (interactive)
8055 (prog1
8056 (when (gnus-summary-first-subject)
8057 (gnus-summary-show-thread)
8058 (gnus-summary-first-subject)
8059 (gnus-summary-display-article (gnus-summary-article-number)))
8060 (gnus-summary-position-point)))
8061
8062 (defun gnus-summary-best-unread-article (&optional arg)
8063 "Select the unread article with the highest score.
8064 If given a prefix argument, select the next unread article that has a
8065 score higher than the default score."
8066 (interactive "P")
8067 (let ((article (if arg
8068 (gnus-summary-better-unread-subject)
8069 (gnus-summary-best-unread-subject))))
8070 (if article
8071 (gnus-summary-goto-article article)
8072 (error "No unread articles"))))
8073
8074 (defun gnus-summary-best-unread-subject ()
8075 "Select the unread subject with the highest score."
8076 (interactive)
8077 (let ((best -1000000)
8078 (data gnus-newsgroup-data)
8079 article score)
8080 (while data
8081 (and (gnus-data-unread-p (car data))
8082 (> (setq score
8083 (gnus-summary-article-score (gnus-data-number (car data))))
8084 best)
8085 (setq best score
8086 article (gnus-data-number (car data))))
8087 (setq data (cdr data)))
8088 (when article
8089 (gnus-summary-goto-subject article))
8090 (gnus-summary-position-point)
8091 article))
8092
8093 (defun gnus-summary-better-unread-subject ()
8094 "Select the first unread subject that has a score over the default score."
8095 (interactive)
8096 (let ((data gnus-newsgroup-data)
8097 article score)
8098 (while (and (setq article (gnus-data-number (car data)))
8099 (or (gnus-data-read-p (car data))
8100 (not (> (gnus-summary-article-score article)
8101 gnus-summary-default-score))))
8102 (setq data (cdr data)))
8103 (when article
8104 (gnus-summary-goto-subject article))
8105 (gnus-summary-position-point)
8106 article))
8107
8108 (defun gnus-summary-last-subject ()
8109 "Go to the last displayed subject line in the group."
8110 (let ((article (gnus-data-number (car (gnus-data-list t)))))
8111 (when article
8112 (gnus-summary-goto-subject article))))
8113
8114 (defun gnus-summary-goto-article (article &optional all-headers force)
8115 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
8116 If ALL-HEADERS is non-nil, no header lines are hidden.
8117 If FORCE, go to the article even if it isn't displayed. If FORCE
8118 is a number, it is the line the article is to be displayed on."
8119 (interactive
8120 (list
8121 (gnus-completing-read
8122 "Article number or Message-ID"
8123 (mapcar 'int-to-string gnus-newsgroup-limit))
8124 current-prefix-arg
8125 t))
8126 (prog1
8127 (if (and (stringp article)
8128 (string-match "@\\|%40" article))
8129 (gnus-summary-refer-article article)
8130 (when (stringp article)
8131 (setq article (string-to-number article)))
8132 (if (gnus-summary-goto-subject article force)
8133 (gnus-summary-display-article article all-headers)
8134 (gnus-message 4 "Couldn't go to article %s" article) nil))
8135 (gnus-summary-position-point)))
8136
8137 (defun gnus-summary-goto-last-article ()
8138 "Go to the previously read article."
8139 (interactive)
8140 (prog1
8141 (when gnus-last-article
8142 (gnus-summary-goto-article gnus-last-article nil t))
8143 (gnus-summary-position-point)))
8144
8145 (defun gnus-summary-pop-article (number)
8146 "Pop one article off the history and go to the previous.
8147 NUMBER articles will be popped off."
8148 (interactive "p")
8149 (let (to)
8150 (setq gnus-newsgroup-history
8151 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
8152 (if to
8153 (gnus-summary-goto-article (car to) nil t)
8154 (error "Article history empty")))
8155 (gnus-summary-position-point))
8156
8157 ;; Summary commands and functions for limiting the summary buffer.
8158
8159 (defun gnus-summary-limit-to-articles (n)
8160 "Limit the summary buffer to the next N articles.
8161 If not given a prefix, use the process marked articles instead."
8162 (interactive "P")
8163 (prog1
8164 (let ((articles (gnus-summary-work-articles n)))
8165 (setq gnus-newsgroup-processable nil)
8166 (gnus-summary-limit articles))
8167 (gnus-summary-position-point)))
8168
8169 (defun gnus-summary-pop-limit (&optional total)
8170 "Restore the previous limit.
8171 If given a prefix, remove all limits."
8172 (interactive "P")
8173 (when total
8174 (setq gnus-newsgroup-limits
8175 (list (mapcar (lambda (h) (mail-header-number h))
8176 gnus-newsgroup-headers))))
8177 (unless gnus-newsgroup-limits
8178 (error "No limit to pop"))
8179 (prog1
8180 (gnus-summary-limit nil 'pop)
8181 (gnus-summary-position-point)))
8182
8183 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
8184 "Limit the summary buffer to articles that have subjects that match a regexp.
8185 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
8186 (interactive
8187 (list (read-string (if current-prefix-arg
8188 "Exclude subject (regexp): "
8189 "Limit to subject (regexp): "))
8190 nil current-prefix-arg))
8191 (unless header
8192 (setq header "subject"))
8193 (when (not (equal "" subject))
8194 (prog1
8195 (let ((articles (gnus-summary-find-matching
8196 (or header "subject") subject 'all nil nil
8197 not-matching)))
8198 (unless articles
8199 (error "Found no matches for \"%s\"" subject))
8200 (gnus-summary-limit articles))
8201 (gnus-summary-position-point))))
8202
8203 (defun gnus-summary-limit-to-author (from &optional not-matching)
8204 "Limit the summary buffer to articles that have authors that match a regexp.
8205 If NOT-MATCHING, excluding articles that have authors that match a regexp."
8206 (interactive
8207 (list (let* ((header (gnus-summary-article-header))
8208 (default (and header (car (mail-header-parse-address
8209 (mail-header-from header))))))
8210 (read-string (concat (if current-prefix-arg
8211 "Exclude author (regexp"
8212 "Limit to author (regexp")
8213 (if default
8214 (concat ", default \"" default "\"): ")
8215 "): "))
8216 nil nil
8217 default))
8218 current-prefix-arg))
8219 (gnus-summary-limit-to-subject from "from" not-matching))
8220
8221 (defun gnus-summary-limit-to-recipient (recipient &optional not-matching)
8222 "Limit the summary buffer to articles with the given RECIPIENT.
8223
8224 If NOT-MATCHING, exclude RECIPIENT.
8225
8226 To and Cc headers are checked. You need to include them in
8227 `nnmail-extra-headers'."
8228 ;; Unlike `rmail-summary-by-recipients', doesn't include From.
8229 (interactive
8230 (list (read-string (format "%s recipient (regexp): "
8231 (if current-prefix-arg "Exclude" "Limit to")))
8232 current-prefix-arg))
8233 (when (not (equal "" recipient))
8234 (prog1 (let* ((to
8235 (if (memq 'To nnmail-extra-headers)
8236 (gnus-summary-find-matching
8237 (cons 'extra 'To) recipient 'all nil nil
8238 not-matching)
8239 (gnus-message
8240 1 "`To' isn't present in `nnmail-extra-headers'")
8241 (sit-for 1)
8242 nil))
8243 (cc
8244 (if (memq 'Cc nnmail-extra-headers)
8245 (gnus-summary-find-matching
8246 (cons 'extra 'Cc) recipient 'all nil nil
8247 not-matching)
8248 (gnus-message
8249 1 "`Cc' isn't present in `nnmail-extra-headers'")
8250 (sit-for 1)
8251 nil))
8252 (articles
8253 (if not-matching
8254 ;; We need the numbers that are in both lists:
8255 (mapcar (lambda (a)
8256 (and (memq a to) a))
8257 cc)
8258 (nconc to cc))))
8259 (unless articles
8260 (error "Found no matches for \"%s\"" recipient))
8261 (gnus-summary-limit articles))
8262 (gnus-summary-position-point))))
8263
8264 (defun gnus-summary-limit-to-address (address &optional not-matching)
8265 "Limit the summary buffer to articles with the given ADDRESS.
8266
8267 If NOT-MATCHING, exclude ADDRESS.
8268
8269 To, Cc and From headers are checked. You need to include `To' and `Cc'
8270 in `nnmail-extra-headers'."
8271 (interactive
8272 (list (read-string (format "%s address (regexp): "
8273 (if current-prefix-arg "Exclude" "Limit to")))
8274 current-prefix-arg))
8275 (when (not (equal "" address))
8276 (prog1 (let* ((to
8277 (if (memq 'To nnmail-extra-headers)
8278 (gnus-summary-find-matching
8279 (cons 'extra 'To) address 'all nil nil
8280 not-matching)
8281 (gnus-message
8282 1 "`To' isn't present in `nnmail-extra-headers'")
8283 (sit-for 1)
8284 t))
8285 (cc
8286 (if (memq 'Cc nnmail-extra-headers)
8287 (gnus-summary-find-matching
8288 (cons 'extra 'Cc) address 'all nil nil
8289 not-matching)
8290 (gnus-message
8291 1 "`Cc' isn't present in `nnmail-extra-headers'")
8292 (sit-for 1)
8293 t))
8294 (from
8295 (gnus-summary-find-matching "from" address
8296 'all nil nil not-matching))
8297 (articles
8298 (if not-matching
8299 ;; We need the numbers that are in all lists:
8300 (if (eq cc t)
8301 (if (eq to t)
8302 from
8303 (mapcar (lambda (a) (car (memq a from))) to))
8304 (if (eq to t)
8305 (mapcar (lambda (a) (car (memq a from))) cc)
8306 (mapcar (lambda (a) (car (memq a from)))
8307 (mapcar (lambda (a) (car (memq a to)))
8308 cc))))
8309 (nconc (if (eq to t) nil to)
8310 (if (eq cc t) nil cc)
8311 from))))
8312 (unless articles
8313 (error "Found no matches for \"%s\"" address))
8314 (gnus-summary-limit articles))
8315 (gnus-summary-position-point))))
8316
8317 (defun gnus-summary-limit-strange-charsets-predicate (header)
8318 (let ((string (concat (mail-header-subject header)
8319 (mail-header-from header)))
8320 charset found)
8321 (dotimes (i (1- (length string)))
8322 (setq charset (format "%s" (char-charset (aref string (1+ i)))))
8323 (when (string-match "unicode\\|big\\|japanese" charset)
8324 (setq found t)))
8325 found))
8326
8327 (defun gnus-summary-limit-to-predicate (predicate)
8328 "Limit to articles where PREDICATE returns non-nil.
8329 PREDICATE will be called with the header structures of the
8330 articles."
8331 (let ((articles nil)
8332 (case-fold-search t))
8333 (dolist (header gnus-newsgroup-headers)
8334 (when (funcall predicate header)
8335 (push (mail-header-number header) articles)))
8336 (gnus-summary-limit (nreverse articles))))
8337
8338 (defun gnus-summary-limit-to-age (age &optional younger-p)
8339 "Limit the summary buffer to articles that are older than (or equal) AGE days.
8340 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
8341 articles that are younger than AGE days."
8342 (interactive
8343 (let ((younger current-prefix-arg)
8344 (days-got nil)
8345 days)
8346 (while (not days-got)
8347 (setq days (if younger
8348 (read-string "Limit to articles younger than (in days, older when negative): ")
8349 (read-string
8350 "Limit to articles older than (in days, younger when negative): ")))
8351 (when (> (length days) 0)
8352 (setq days (read days)))
8353 (if (numberp days)
8354 (progn
8355 (setq days-got t)
8356 (when (< days 0)
8357 (setq younger (not younger))
8358 (setq days (* days -1))))
8359 (message "Please enter a number.")
8360 (sleep-for 1)))
8361 (list days younger)))
8362 (prog1
8363 (let ((data gnus-newsgroup-data)
8364 (cutoff (days-to-time age))
8365 articles d date is-younger)
8366 (while (setq d (pop data))
8367 (when (and (vectorp (gnus-data-header d))
8368 (setq date (mail-header-date (gnus-data-header d))))
8369 (setq is-younger (time-less-p
8370 (time-since (gnus-date-get-time date))
8371 cutoff))
8372 (when (if younger-p
8373 is-younger
8374 (not is-younger))
8375 (push (gnus-data-number d) articles))))
8376 (gnus-summary-limit (nreverse articles)))
8377 (gnus-summary-position-point)))
8378
8379 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
8380 "Limit the summary buffer to articles that match an `extra' header."
8381 (interactive
8382 (let ((header
8383 (intern
8384 (gnus-completing-read
8385 (if current-prefix-arg
8386 "Exclude extra header"
8387 "Limit extra header")
8388 (mapcar 'symbol-name gnus-extra-headers)
8389 t nil nil
8390 (symbol-name (car gnus-extra-headers))))))
8391 (list header
8392 (read-string (format "%s header %s (regexp): "
8393 (if current-prefix-arg "Exclude" "Limit to")
8394 header))
8395 current-prefix-arg)))
8396 (when (not (equal "" regexp))
8397 (prog1
8398 (let ((articles (gnus-summary-find-matching
8399 (cons 'extra header) regexp 'all nil nil
8400 not-matching)))
8401 (unless articles
8402 (error "Found no matches for \"%s\"" regexp))
8403 (gnus-summary-limit articles))
8404 (gnus-summary-position-point))))
8405
8406 (defun gnus-summary-limit-to-display-predicate ()
8407 "Limit the summary buffer to the predicated in the `display' group parameter."
8408 (interactive)
8409 (unless gnus-newsgroup-display
8410 (error "There is no `display' group parameter"))
8411 (let (articles)
8412 (dolist (gnus-number gnus-newsgroup-articles)
8413 (when (funcall gnus-newsgroup-display)
8414 (push gnus-number articles)))
8415 (gnus-summary-limit articles))
8416 (gnus-summary-position-point))
8417
8418 (defun gnus-summary-limit-to-unread (&optional all)
8419 "Limit the summary buffer to articles that are not marked as read.
8420 If ALL is non-nil, limit strictly to unread articles."
8421 (interactive "P")
8422 (if all
8423 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
8424 (gnus-summary-limit-to-marks
8425 ;; Concat all the marks that say that an article is read and have
8426 ;; those removed.
8427 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
8428 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
8429 gnus-low-score-mark gnus-expirable-mark
8430 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
8431 gnus-duplicate-mark)
8432 'reverse)))
8433
8434 (defun gnus-summary-limit-to-headers (match &optional reverse)
8435 "Limit the summary buffer to articles that have headers that match MATCH.
8436 If REVERSE (the prefix), limit to articles that don't match."
8437 (interactive "sMatch headers (regexp): \nP")
8438 (gnus-summary-limit-to-bodies match reverse t))
8439
8440 (declare-function article-goto-body "gnus-art" ())
8441
8442 (defun gnus-summary-limit-to-bodies (match &optional reverse headersp)
8443 "Limit the summary buffer to articles that have bodies that match MATCH.
8444 If REVERSE (the prefix), limit to articles that don't match."
8445 (interactive "sMatch body (regexp): \nP")
8446 (let ((articles nil)
8447 (gnus-select-article-hook nil) ;Disable hook.
8448 (gnus-article-prepare-hook nil)
8449 (gnus-use-article-prefetch nil)
8450 (gnus-keep-backlog nil)
8451 (gnus-break-pages nil)
8452 (gnus-summary-display-arrow nil)
8453 (gnus-updated-mode-lines nil)
8454 (gnus-auto-center-summary nil)
8455 (gnus-display-mime-function nil))
8456 (dolist (data gnus-newsgroup-data)
8457 (let (gnus-mark-article-hook)
8458 (gnus-summary-select-article t t nil (gnus-data-number data)))
8459 (with-current-buffer gnus-article-buffer
8460 (article-goto-body)
8461 (let* ((case-fold-search t)
8462 (found (if headersp
8463 (re-search-backward match nil t)
8464 (re-search-forward match nil t))))
8465 (when (or (and found
8466 (not reverse))
8467 (and (not found)
8468 reverse))
8469 (push (gnus-data-number data) articles)))))
8470 (if (not articles)
8471 (message "No messages matched")
8472 (gnus-summary-limit articles)))
8473 (gnus-summary-position-point))
8474
8475 (defun gnus-summary-limit-to-singletons (&optional threadsp)
8476 "Limit the summary buffer to articles that aren't part on any thread.
8477 If THREADSP (the prefix), limit to articles that are in threads."
8478 (interactive "P")
8479 (let ((articles nil)
8480 thread-articles
8481 threads)
8482 (dolist (thread gnus-newsgroup-threads)
8483 (if (stringp (car thread))
8484 (dolist (thread (cdr thread))
8485 (push thread threads))
8486 (push thread threads)))
8487 (dolist (thread threads)
8488 (setq thread-articles (gnus-articles-in-thread thread))
8489 (when (or (and threadsp
8490 (> (length thread-articles) 1))
8491 (and (not threadsp)
8492 (= (length thread-articles) 1)))
8493 (setq articles (nconc thread-articles articles))))
8494 (if (not articles)
8495 (message "No messages matched")
8496 (gnus-summary-limit articles))
8497 (gnus-summary-position-point)))
8498
8499 (defun gnus-summary-limit-to-replied (&optional unreplied)
8500 "Limit the summary buffer to replied articles.
8501 If UNREPLIED (the prefix), limit to unreplied articles."
8502 (interactive "P")
8503 (if unreplied
8504 (gnus-summary-limit
8505 (gnus-set-difference gnus-newsgroup-articles
8506 gnus-newsgroup-replied))
8507 (gnus-summary-limit gnus-newsgroup-replied))
8508 (gnus-summary-position-point))
8509
8510 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
8511 "Exclude articles that are marked with MARKS (e.g. \"DK\").
8512 If REVERSE, limit the summary buffer to articles that are marked
8513 with MARKS. MARKS can either be a string of marks or a list of marks.
8514 Returns how many articles were removed."
8515 (interactive "sMarks: ")
8516 (gnus-summary-limit-to-marks marks t))
8517
8518 (defun gnus-summary-limit-to-marks (marks &optional reverse)
8519 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
8520 If REVERSE (the prefix), limit the summary buffer to articles that are
8521 not marked with MARKS. MARKS can either be a string of marks or a
8522 list of marks.
8523 Returns how many articles were removed."
8524 (interactive "sMarks: \nP")
8525 (prog1
8526 (let ((data gnus-newsgroup-data)
8527 (marks (if (listp marks) marks
8528 (append marks nil))) ; Transform to list.
8529 articles)
8530 (while data
8531 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
8532 (memq (gnus-data-mark (car data)) marks))
8533 (push (gnus-data-number (car data)) articles))
8534 (setq data (cdr data)))
8535 (gnus-summary-limit articles))
8536 (gnus-summary-position-point)))
8537
8538 (defun gnus-summary-limit-to-score (score)
8539 "Limit to articles with score at or above SCORE."
8540 (interactive "NLimit to articles with score of at least: ")
8541 (let ((data gnus-newsgroup-data)
8542 articles)
8543 (while data
8544 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
8545 score)
8546 (push (gnus-data-number (car data)) articles))
8547 (setq data (cdr data)))
8548 (prog1
8549 (gnus-summary-limit articles)
8550 (gnus-summary-position-point))))
8551
8552 (defun gnus-summary-limit-to-unseen ()
8553 "Limit to unseen articles."
8554 (interactive)
8555 (prog1
8556 (gnus-summary-limit gnus-newsgroup-unseen)
8557 (gnus-summary-position-point)))
8558
8559 (defun gnus-summary-limit-include-thread (id)
8560 "Display all the hidden articles that is in the thread with ID in it.
8561 When called interactively, ID is the Message-ID of the current
8562 article."
8563 (interactive (list (mail-header-id (gnus-summary-article-header))))
8564 (let ((articles (gnus-articles-in-thread
8565 (gnus-id-to-thread (gnus-root-id id))))
8566 ;;we REALLY want the whole thread---this prevents cut-threads
8567 ;;from removing the thread we want to include.
8568 (gnus-fetch-old-headers nil)
8569 (gnus-build-sparse-threads nil))
8570 (prog1
8571 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8572 (gnus-summary-limit-include-matching-articles
8573 "subject"
8574 (regexp-quote (gnus-simplify-subject-re
8575 (mail-header-subject (gnus-id-to-header id)))))
8576 (gnus-summary-position-point))))
8577
8578 (defun gnus-summary-limit-include-matching-articles (header regexp)
8579 "Display all the hidden articles that have HEADERs that match REGEXP."
8580 (interactive (list (read-string "Match on header: ")
8581 (read-string "Regexp: ")))
8582 (let ((articles (gnus-find-matching-articles header regexp)))
8583 (prog1
8584 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
8585 (gnus-summary-position-point))))
8586
8587 (defun gnus-summary-insert-dormant-articles ()
8588 "Insert all the dormant articles for this group into the current buffer."
8589 (interactive)
8590 (let ((gnus-verbose (max 6 gnus-verbose)))
8591 (if (not gnus-newsgroup-dormant)
8592 (gnus-message 3 "No dormant articles for this group")
8593 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
8594
8595 (defun gnus-summary-insert-ticked-articles ()
8596 "Insert ticked articles for this group into the current buffer."
8597 (interactive)
8598 (let ((gnus-verbose (max 6 gnus-verbose)))
8599 (if (not gnus-newsgroup-marked)
8600 (gnus-message 3 "No ticked articles for this group")
8601 (gnus-summary-goto-subjects gnus-newsgroup-marked))))
8602
8603 (defun gnus-summary-limit-include-dormant ()
8604 "Display all the hidden articles that are marked as dormant.
8605 Note that this command only works on a subset of the articles currently
8606 fetched for this group."
8607 (interactive)
8608 (unless gnus-newsgroup-dormant
8609 (error "There are no dormant articles in this group"))
8610 (prog1
8611 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
8612 (gnus-summary-position-point)))
8613
8614 (defun gnus-summary-include-articles (articles)
8615 "Fetch the headers for ARTICLES and then display the summary lines."
8616 (let ((gnus-inhibit-demon t)
8617 (gnus-agent nil)
8618 (gnus-read-all-available-headers t))
8619 (setq gnus-newsgroup-headers
8620 (cl-merge
8621 'list gnus-newsgroup-headers
8622 (gnus-fetch-headers articles nil t)
8623 'gnus-article-sort-by-number))
8624 (setq gnus-newsgroup-articles
8625 (gnus-sorted-nunion gnus-newsgroup-articles articles))
8626 (gnus-summary-limit (append articles gnus-newsgroup-limit))))
8627
8628 (defun gnus-summary-limit-exclude-dormant ()
8629 "Hide all dormant articles."
8630 (interactive)
8631 (prog1
8632 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
8633 (gnus-summary-position-point)))
8634
8635 (defun gnus-summary-limit-exclude-childless-dormant ()
8636 "Hide all dormant articles that have no children."
8637 (interactive)
8638 (let ((data (gnus-data-list t))
8639 articles d children)
8640 ;; Find all articles that are either not dormant or have
8641 ;; children.
8642 (while (setq d (pop data))
8643 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
8644 (and (setq children
8645 (gnus-article-children (gnus-data-number d)))
8646 (let (found)
8647 (while children
8648 (when (memq (car children) articles)
8649 (setq children nil
8650 found t))
8651 (pop children))
8652 found)))
8653 (push (gnus-data-number d) articles)))
8654 ;; Do the limiting.
8655 (prog1
8656 (gnus-summary-limit articles)
8657 (gnus-summary-position-point))))
8658
8659 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
8660 "Mark all unread excluded articles as read.
8661 If ALL, mark even excluded ticked and dormants as read."
8662 (interactive "P")
8663 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
8664 (let ((articles (gnus-sorted-ndifference
8665 (sort
8666 (mapcar (lambda (h) (mail-header-number h))
8667 gnus-newsgroup-headers)
8668 '<)
8669 gnus-newsgroup-limit))
8670 article)
8671 (setq gnus-newsgroup-unreads
8672 (gnus-sorted-intersection gnus-newsgroup-unreads
8673 gnus-newsgroup-limit))
8674 (if all
8675 (setq gnus-newsgroup-dormant nil
8676 gnus-newsgroup-marked nil
8677 gnus-newsgroup-reads
8678 (nconc
8679 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
8680 gnus-newsgroup-reads))
8681 (while (setq article (pop articles))
8682 (unless (or (memq article gnus-newsgroup-dormant)
8683 (memq article gnus-newsgroup-marked))
8684 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
8685
8686 (defun gnus-summary-limit (articles &optional pop)
8687 (if pop
8688 ;; We pop the previous limit off the stack and use that.
8689 (setq articles (car gnus-newsgroup-limits)
8690 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
8691 ;; We use the new limit, so we push the old limit on the stack.
8692 (push gnus-newsgroup-limit gnus-newsgroup-limits))
8693 ;; Set the limit.
8694 (setq gnus-newsgroup-limit articles)
8695 (let ((total (length gnus-newsgroup-data))
8696 (data (gnus-data-find-list (gnus-summary-article-number)))
8697 (gnus-summary-mark-below nil) ; Inhibit this.
8698 found)
8699 ;; This will do all the work of generating the new summary buffer
8700 ;; according to the new limit.
8701 (gnus-summary-prepare)
8702 ;; Hide any threads, possibly.
8703 (gnus-summary-maybe-hide-threads)
8704 ;; Try to return to the article you were at, or one in the
8705 ;; neighborhood.
8706 (when data
8707 ;; We try to find some article after the current one.
8708 (while data
8709 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
8710 (setq data nil
8711 found t))
8712 (setq data (cdr data))))
8713 (unless found
8714 ;; If there is no data, that means that we were after the last
8715 ;; article. The same goes when we can't find any articles
8716 ;; after the current one.
8717 (goto-char (point-max))
8718 (gnus-summary-find-prev))
8719 (gnus-set-mode-line 'summary)
8720 ;; We return how many articles were removed from the summary
8721 ;; buffer as a result of the new limit.
8722 (- total (length gnus-newsgroup-data))))
8723
8724 (defsubst gnus-invisible-cut-children (threads)
8725 (let ((num 0))
8726 (while threads
8727 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
8728 (incf num))
8729 (pop threads))
8730 (< num 2)))
8731
8732 (defsubst gnus-cut-thread (thread)
8733 "Go forwards in the thread until we find an article that we want to display."
8734 (when (or (eq gnus-fetch-old-headers 'some)
8735 (eq gnus-fetch-old-headers 'invisible)
8736 (numberp gnus-fetch-old-headers)
8737 (eq gnus-build-sparse-threads 'some)
8738 (eq gnus-build-sparse-threads 'more))
8739 ;; Deal with old-fetched headers and sparse threads.
8740 (while (and
8741 thread
8742 (or
8743 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
8744 (gnus-summary-article-ancient-p
8745 (mail-header-number (car thread))))
8746 (if (or (<= (length (cdr thread)) 1)
8747 (eq gnus-fetch-old-headers 'invisible))
8748 (setq gnus-newsgroup-limit
8749 (delq (mail-header-number (car thread))
8750 gnus-newsgroup-limit)
8751 thread (cadr thread))
8752 (when (gnus-invisible-cut-children (cdr thread))
8753 (let ((th (cdr thread)))
8754 (while th
8755 (if (memq (mail-header-number (caar th))
8756 gnus-newsgroup-limit)
8757 (setq thread (car th)
8758 th nil)
8759 (setq th (cdr th))))))))))
8760 thread)
8761
8762 (defun gnus-cut-threads (threads)
8763 "Cut off all uninteresting articles from the beginning of THREADS."
8764 (when (or (eq gnus-fetch-old-headers 'some)
8765 (eq gnus-fetch-old-headers 'invisible)
8766 (numberp gnus-fetch-old-headers)
8767 (eq gnus-build-sparse-threads 'some)
8768 (eq gnus-build-sparse-threads 'more))
8769 (let ((th threads))
8770 (while th
8771 (setcar th (gnus-cut-thread (car th)))
8772 (setq th (cdr th)))))
8773 ;; Remove nixed out threads.
8774 (delq nil threads))
8775
8776 (defun gnus-summary-initial-limit (&optional show-if-empty)
8777 "Figure out what the initial limit is supposed to be on group entry.
8778 This entails weeding out unwanted dormants, low-scored articles,
8779 fetch-old-headers verbiage, and so on."
8780 ;; Most groups have nothing to remove.
8781 (unless (or gnus-inhibit-limiting
8782 (and (null gnus-newsgroup-dormant)
8783 (eq gnus-newsgroup-display 'gnus-not-ignore)
8784 (not (eq gnus-fetch-old-headers 'some))
8785 (not (numberp gnus-fetch-old-headers))
8786 (not (eq gnus-fetch-old-headers 'invisible))
8787 (null gnus-summary-expunge-below)
8788 (not (eq gnus-build-sparse-threads 'some))
8789 (not (eq gnus-build-sparse-threads 'more))
8790 (null gnus-thread-expunge-below)))
8791 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8792 (setq gnus-newsgroup-limit nil)
8793 (mapatoms
8794 (lambda (node)
8795 (unless (car (symbol-value node))
8796 ;; These threads have no parents -- they are roots.
8797 (let ((nodes (cdr (symbol-value node)))
8798 thread)
8799 (while nodes
8800 (if (and gnus-thread-expunge-below
8801 (< (gnus-thread-total-score (car nodes))
8802 gnus-thread-expunge-below))
8803 (gnus-expunge-thread (pop nodes))
8804 (setq thread (pop nodes))
8805 (gnus-summary-limit-children thread))))))
8806 gnus-newsgroup-dependencies)
8807 ;; If this limitation resulted in an empty group, we might
8808 ;; pop the previous limit and use it instead.
8809 (when (and (not gnus-newsgroup-limit)
8810 show-if-empty)
8811 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8812 gnus-newsgroup-limit))
8813
8814 (defun gnus-summary-limit-children (thread)
8815 "Return 1 if this subthread is visible and 0 if it is not."
8816 ;; First we get the number of visible children to this thread. This
8817 ;; is done by recursing down the thread using this function, so this
8818 ;; will really go down to a leaf article first, before slowly
8819 ;; working its way up towards the root.
8820 (when thread
8821 (let* ((max-lisp-eval-depth (max 5000 max-lisp-eval-depth))
8822 (children
8823 (if (cdr thread)
8824 (apply '+ (mapcar 'gnus-summary-limit-children
8825 (cdr thread)))
8826 0))
8827 (number (mail-header-number (car thread)))
8828 score)
8829 (if (and
8830 (not (memq number gnus-newsgroup-marked))
8831 (or
8832 ;; If this article is dormant and has absolutely no visible
8833 ;; children, then this article isn't visible.
8834 (and (memq number gnus-newsgroup-dormant)
8835 (zerop children))
8836 ;; If this is "fetch-old-headered" and there is no
8837 ;; visible children, then we don't want this article.
8838 (and (or (eq gnus-fetch-old-headers 'some)
8839 (numberp gnus-fetch-old-headers))
8840 (gnus-summary-article-ancient-p number)
8841 (zerop children))
8842 ;; If this is "fetch-old-headered" and `invisible', then
8843 ;; we don't want this article.
8844 (and (eq gnus-fetch-old-headers 'invisible)
8845 (gnus-summary-article-ancient-p number))
8846 ;; If this is a sparsely inserted article with no children,
8847 ;; we don't want it.
8848 (and (eq gnus-build-sparse-threads 'some)
8849 (gnus-summary-article-sparse-p number)
8850 (zerop children))
8851 ;; If we use expunging, and this article is really
8852 ;; low-scored, then we don't want this article.
8853 (when (and gnus-summary-expunge-below
8854 (< (setq score
8855 (or (cdr (assq number gnus-newsgroup-scored))
8856 gnus-summary-default-score))
8857 gnus-summary-expunge-below))
8858 ;; We increase the expunge-tally here, but that has
8859 ;; nothing to do with the limits, really.
8860 (incf gnus-newsgroup-expunged-tally)
8861 ;; We also mark as read here, if that's wanted.
8862 (when (and gnus-summary-mark-below
8863 (< score gnus-summary-mark-below))
8864 (setq gnus-newsgroup-unreads
8865 (delq number gnus-newsgroup-unreads))
8866 (if gnus-newsgroup-auto-expire
8867 (push number gnus-newsgroup-expirable)
8868 (push (cons number gnus-low-score-mark)
8869 gnus-newsgroup-reads)))
8870 t)
8871 ;; Do the `display' group parameter.
8872 (and gnus-newsgroup-display
8873 (let ((gnus-number number))
8874 (not (funcall gnus-newsgroup-display))))))
8875 ;; Nope, invisible article.
8876 0
8877 ;; Ok, this article is to be visible, so we add it to the limit
8878 ;; and return 1.
8879 (push number gnus-newsgroup-limit)
8880 1))))
8881
8882 (defun gnus-expunge-thread (thread)
8883 "Mark all articles in THREAD as read."
8884 (let* ((number (mail-header-number (car thread))))
8885 (incf gnus-newsgroup-expunged-tally)
8886 ;; We also mark as read here, if that's wanted.
8887 (setq gnus-newsgroup-unreads
8888 (delq number gnus-newsgroup-unreads))
8889 (if gnus-newsgroup-auto-expire
8890 (push number gnus-newsgroup-expirable)
8891 (push (cons number gnus-low-score-mark)
8892 gnus-newsgroup-reads)))
8893 ;; Go recursively through all subthreads.
8894 (mapcar 'gnus-expunge-thread (cdr thread)))
8895
8896 ;; Summary article oriented commands
8897
8898 (defun gnus-summary-refer-parent-article (n)
8899 "Refer parent article N times.
8900 If N is negative, go to ancestor -N instead.
8901 The difference between N and the number of articles fetched is returned."
8902 (interactive "p")
8903 (let ((skip 1)
8904 error header ref)
8905 (when (not (natnump n))
8906 (setq skip (abs n)
8907 n 1))
8908 (while (and (> n 0)
8909 (not error))
8910 (setq header (gnus-summary-article-header))
8911 (if (and (eq (mail-header-number header)
8912 (cdr gnus-article-current))
8913 (equal gnus-newsgroup-name
8914 (car gnus-article-current)))
8915 ;; If we try to find the parent of the currently
8916 ;; displayed article, then we take a look at the actual
8917 ;; References header, since this is slightly more
8918 ;; reliable than the References field we got from the
8919 ;; server.
8920 (with-current-buffer gnus-original-article-buffer
8921 (nnheader-narrow-to-headers)
8922 (unless (setq ref (message-fetch-field "references"))
8923 (when (setq ref (message-fetch-field "in-reply-to"))
8924 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8925 (widen))
8926 (setq ref
8927 ;; It's not the current article, so we take a bet on
8928 ;; the value we got from the server.
8929 (mail-header-references header)))
8930 (if (and ref
8931 (not (equal ref "")))
8932 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8933 (gnus-message 1 "Couldn't find parent"))
8934 (gnus-message 1 "No references in article %d"
8935 (gnus-summary-article-number))
8936 (setq error t))
8937 (decf n))
8938 (gnus-summary-position-point)
8939 n))
8940
8941 (defun gnus-summary-refer-references ()
8942 "Fetch all articles mentioned in the References header.
8943 Return the number of articles fetched."
8944 (interactive)
8945 (let ((ref (mail-header-references (gnus-summary-article-header)))
8946 (current (gnus-summary-article-number))
8947 (n 0))
8948 (if (or (not ref)
8949 (equal ref ""))
8950 (error "No References in the current article")
8951 ;; For each Message-ID in the References header...
8952 (while (string-match "<[^>]*>" ref)
8953 (incf n)
8954 ;; ... fetch that article.
8955 (gnus-summary-refer-article
8956 (prog1 (match-string 0 ref)
8957 (setq ref (substring ref (match-end 0))))))
8958 (gnus-summary-goto-subject current)
8959 (gnus-summary-position-point)
8960 n)))
8961
8962 (defun gnus-delete-duplicate-headers (headers)
8963 ;; First remove leading duplicates.
8964 (while (and (> (length headers) 1)
8965 (= (mail-header-number (car headers))
8966 (mail-header-number (cadr headers))))
8967 (pop headers))
8968 ;; Then the rest.
8969 (let ((result headers))
8970 (while (> (length headers) 1)
8971 (if (= (mail-header-number (car headers))
8972 (mail-header-number (cadr headers)))
8973 (setcdr headers (cddr headers))
8974 (pop headers)))
8975 result))
8976
8977 (defun gnus-summary-refer-thread (&optional limit)
8978 "Fetch all articles in the current thread. For backends that
8979 know how to search for threads (currently only 'nnimap) a
8980 non-numeric prefix arg will use nnir to search the entire
8981 server; without a prefix arg only the current group is
8982 searched. If the variable `gnus-refer-thread-use-nnir' is
8983 non-nil the prefix arg has the reverse meaning. If no
8984 backend-specific 'request-thread function is available fetch
8985 LIMIT (the numerical prefix) old headers. If LIMIT is
8986 non-numeric or nil fetch the number specified by the
8987 `gnus-refer-thread-limit' variable."
8988 (interactive "P")
8989 (gnus-warp-to-article)
8990 (let* ((header (gnus-summary-article-header))
8991 (id (mail-header-id header))
8992 (gnus-inhibit-demon t)
8993 (gnus-summary-ignore-duplicates t)
8994 (gnus-read-all-available-headers t)
8995 (gnus-refer-thread-use-nnir
8996 (if (and (not (null limit)) (listp limit))
8997 (not gnus-refer-thread-use-nnir) gnus-refer-thread-use-nnir))
8998 (new-headers
8999 (if (gnus-check-backend-function
9000 'request-thread gnus-newsgroup-name)
9001 (gnus-request-thread header gnus-newsgroup-name)
9002 (let* ((limit (if (numberp limit) (prefix-numeric-value limit)
9003 gnus-refer-thread-limit))
9004 (last (if (numberp limit)
9005 (min (+ (mail-header-number header)
9006 limit)
9007 gnus-newsgroup-highest)
9008 gnus-newsgroup-highest))
9009 (subject (gnus-simplify-subject
9010 (mail-header-subject header)))
9011 (refs (split-string (or (mail-header-references header)
9012 "")))
9013 (gnus-parse-headers-hook
9014 `(lambda () (goto-char (point-min))
9015 (keep-lines
9016 (regexp-opt ',(append refs (list id subject)))))))
9017 (gnus-fetch-headers (list last) (if (numberp limit)
9018 (* 2 limit) limit) t))))
9019 article-ids new-unreads)
9020 (when (listp new-headers)
9021 (dolist (header new-headers)
9022 (push (mail-header-number header) article-ids))
9023 (setq article-ids (nreverse article-ids))
9024 (setq new-unreads
9025 (gnus-sorted-intersection gnus-newsgroup-unselected article-ids))
9026 (setq gnus-newsgroup-unselected
9027 (gnus-sorted-ndifference gnus-newsgroup-unselected new-unreads))
9028 (setq gnus-newsgroup-unreads
9029 (gnus-sorted-nunion gnus-newsgroup-unreads new-unreads))
9030 (setq gnus-newsgroup-headers
9031 (gnus-delete-duplicate-headers
9032 (cl-merge
9033 'list gnus-newsgroup-headers new-headers
9034 'gnus-article-sort-by-number)))
9035 (setq gnus-newsgroup-articles
9036 (gnus-sorted-nunion gnus-newsgroup-articles article-ids))
9037 (gnus-summary-limit-include-thread id)))
9038 (gnus-summary-show-thread))
9039
9040 (defun gnus-summary-open-group-with-article (message-id)
9041 "Open a group containing the article with the given MESSAGE-ID."
9042 (interactive "sMessage-ID: ")
9043 (require 'nndoc)
9044 (with-temp-buffer
9045 ;; Prepare a dummy article
9046 (erase-buffer)
9047 (insert "From nobody Tue Sep 13 22:05:34 2011\n\n")
9048
9049 ;; Prepare pretty modelines for summary and article buffers
9050 (let ((gnus-summary-mode-line-format "Found %G")
9051 (gnus-article-mode-line-format
9052 ;; Group names just get in the way here, especially the
9053 ;; abbreviated ones
9054 (if (string-match "%[gG]" gnus-article-mode-line-format)
9055 (concat (substring gnus-article-mode-line-format
9056 0 (match-beginning 0))
9057 (substring gnus-article-mode-line-format (match-end 0)))
9058 gnus-article-mode-line-format)))
9059
9060 ;; Build an ephemeral group containing the dummy article (hidden)
9061 (gnus-group-read-ephemeral-group
9062 message-id
9063 `(nndoc ,message-id
9064 (nndoc-address ,(current-buffer))
9065 (nndoc-article-type mbox))
9066 :activate
9067 (cons (current-buffer) gnus-current-window-configuration)
9068 (not :request-only)
9069 '(-1) ; :select-articles
9070 (not :parameters)
9071 0)) ; :number
9072 ;; Fetch the desired article
9073 (gnus-summary-refer-article message-id)))
9074
9075 (defun gnus-summary-refer-article (message-id)
9076 "Fetch an article specified by MESSAGE-ID."
9077 (interactive "sMessage-ID: ")
9078 (gnus-warp-to-article)
9079 (when (and (stringp message-id)
9080 (not (zerop (length message-id))))
9081 (setq message-id (replace-regexp-in-string " " "" message-id))
9082 ;; Construct the correct Message-ID if necessary.
9083 ;; Suggested by tale@pawl.rpi.edu.
9084 (unless (string-match "^<" message-id)
9085 (setq message-id (concat "<" message-id)))
9086 (unless (string-match ">$" message-id)
9087 (setq message-id (concat message-id ">")))
9088 ;; People often post MIDs from URLs, so unhex it:
9089 (unless (string-match "@" message-id)
9090 (setq message-id (gnus-url-unhex-string message-id)))
9091 (let* ((header (gnus-id-to-header message-id))
9092 (sparse (and header
9093 (gnus-summary-article-sparse-p
9094 (mail-header-number header))
9095 (memq (mail-header-number header)
9096 gnus-newsgroup-limit)))
9097 number)
9098 (cond
9099 ;; If the article is present in the buffer we just go to it.
9100 ((and header
9101 (or (not (gnus-summary-article-sparse-p
9102 (mail-header-number header)))
9103 sparse))
9104 (prog1
9105 (gnus-summary-goto-article
9106 (mail-header-number header) nil t)
9107 (when sparse
9108 (gnus-summary-update-article (mail-header-number header)))))
9109 (t
9110 ;; We fetch the article.
9111 (catch 'found
9112 (dolist (gnus-override-method (gnus-refer-article-methods))
9113 (when (and (gnus-check-server gnus-override-method)
9114 ;; Fetch the header,
9115 (setq number (gnus-summary-insert-subject message-id)))
9116 ;; and display the article.
9117 (gnus-summary-select-article nil nil nil number)
9118 (throw 'found t)))
9119 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
9120
9121 (defun gnus-refer-article-methods ()
9122 "Return a list of referable methods."
9123 (cond
9124 ;; No method, so we default to current and native.
9125 ((null gnus-refer-article-method)
9126 (list gnus-current-select-method gnus-select-method))
9127 ;; Current.
9128 ((eq 'current gnus-refer-article-method)
9129 (list gnus-current-select-method))
9130 ;; List of select methods.
9131 ((not (and (symbolp (car gnus-refer-article-method))
9132 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
9133 (let (out)
9134 (dolist (method gnus-refer-article-method)
9135 (push (if (eq 'current method)
9136 gnus-current-select-method
9137 (if (eq 'nnir (car method))
9138 (list
9139 'nnir
9140 (or (cadr method)
9141 (gnus-method-to-server gnus-current-select-method)))
9142 method))
9143 out))
9144 (nreverse out)))
9145 ;; One single select method.
9146 (t
9147 (list gnus-refer-article-method))))
9148
9149 (defun gnus-summary-edit-parameters ()
9150 "Edit the group parameters of the current group."
9151 (interactive)
9152 (gnus-group-edit-group gnus-newsgroup-name 'params))
9153
9154 (defun gnus-summary-customize-parameters ()
9155 "Customize the group parameters of the current group."
9156 (interactive)
9157 (gnus-group-customize gnus-newsgroup-name))
9158
9159 (defun gnus-summary-enter-digest-group (&optional force)
9160 "Enter an nndoc group based on the current article.
9161 If FORCE, force a digest interpretation. If not, try to guess
9162 what the document format is.
9163
9164 To control what happens when you exit the group, see the
9165 `gnus-auto-select-on-ephemeral-exit' variable."
9166 (interactive "P")
9167 (let ((conf gnus-current-window-configuration))
9168 (save-window-excursion
9169 (save-excursion
9170 (let (gnus-article-prepare-hook
9171 gnus-display-mime-function
9172 gnus-break-pages)
9173 (gnus-summary-select-article))))
9174 (setq gnus-current-window-configuration conf)
9175 (let* ((name (format "%s-%d"
9176 (gnus-group-prefixed-name
9177 gnus-newsgroup-name (list 'nndoc ""))
9178 (with-current-buffer gnus-summary-buffer
9179 gnus-current-article)))
9180 (ogroup gnus-newsgroup-name)
9181 (params (append (gnus-info-params (gnus-get-info ogroup))
9182 (list (cons 'to-group ogroup))
9183 (list (cons 'parent-group ogroup))
9184 (list (cons 'save-article-group ogroup))))
9185 (case-fold-search t)
9186 (buf (current-buffer))
9187 dig to-address charset)
9188 (with-current-buffer gnus-original-article-buffer
9189 ;; Have the digest group inherit the main mail address of
9190 ;; the parent article.
9191 (when (setq to-address (or (gnus-fetch-field "reply-to")
9192 (gnus-fetch-field "from")))
9193 (setq params
9194 (append
9195 params
9196 (list (cons 'to-address
9197 (funcall gnus-decode-encoded-address-function
9198 to-address))))))
9199 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
9200 (insert-buffer-substring gnus-original-article-buffer)
9201 (narrow-to-region
9202 (goto-char (point-min))
9203 (or (search-forward "\n\n" nil t) (point)))
9204 ;; Remove lines that may lead nndoc to misinterpret the
9205 ;; document type.
9206 (goto-char (point-min))
9207 (delete-matching-lines "^Path:\\|^From ")
9208 ;; Parse charset, and decode content transfer encoding.
9209 (setq charset (mail-content-type-get
9210 (mail-header-parse-content-type
9211 (or (gnus-fetch-field "content-type") ""))
9212 'charset))
9213 (let ((encoding (gnus-fetch-field "content-transfer-encoding")))
9214 (when encoding
9215 (message-remove-header "content-transfer-encoding")
9216 (goto-char (point-max))
9217 (widen)
9218 (narrow-to-region (point) (point-max))
9219 (mm-decode-content-transfer-encoding
9220 (intern (downcase (mail-header-strip encoding))))))
9221 (widen))
9222 (unwind-protect
9223 (if (let ((gnus-newsgroup-ephemeral-charset
9224 (if charset
9225 (intern (downcase (gnus-strip-whitespace charset)))
9226 gnus-newsgroup-charset))
9227 (gnus-newsgroup-ephemeral-ignored-charsets
9228 gnus-newsgroup-ignored-charsets))
9229 (gnus-group-read-ephemeral-group
9230 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
9231 (nndoc-article-type
9232 ,(if force 'mbox 'guess)))
9233 t nil nil nil
9234 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
9235 "ADAPT")))))
9236 ;; Make all postings to this group go to the parent group.
9237 (nconc (gnus-info-params (gnus-get-info name))
9238 params)
9239 ;; Couldn't select this doc group.
9240 (switch-to-buffer buf)
9241 (gnus-set-global-variables)
9242 (gnus-configure-windows 'summary)
9243 (gnus-message 3 "Article couldn't be entered?"))
9244 (kill-buffer dig)))))
9245
9246 (defun gnus-summary-read-document (n)
9247 "Open a new group based on the current article(s).
9248 This will allow you to read digests and other similar
9249 documents as newsgroups.
9250 Obeys the standard process/prefix convention."
9251 (interactive "P")
9252 (let* ((ogroup gnus-newsgroup-name)
9253 (params (append (gnus-info-params (gnus-get-info ogroup))
9254 (list (cons 'to-group ogroup))))
9255 group egroup groups vgroup)
9256 (dolist (article (gnus-summary-work-articles n))
9257 (setq group (format "%s-%d" gnus-newsgroup-name article))
9258 (gnus-summary-remove-process-mark article)
9259 (when (gnus-summary-display-article article)
9260 (save-excursion ;;What for?
9261 (with-temp-buffer
9262 (insert-buffer-substring gnus-original-article-buffer)
9263 ;; Remove some headers that may lead nndoc to make
9264 ;; the wrong guess.
9265 (message-narrow-to-head)
9266 (goto-char (point-min))
9267 (delete-matching-lines "^Path:\\|^From ")
9268 (widen)
9269 (if (setq egroup
9270 (gnus-group-read-ephemeral-group
9271 group `(nndoc ,group (nndoc-address ,(current-buffer))
9272 (nndoc-article-type guess))
9273 t nil t))
9274 (progn
9275 ;; Make all postings to this group go to the parent group.
9276 (nconc (gnus-info-params (gnus-get-info egroup))
9277 params)
9278 (push egroup groups))
9279 ;; Couldn't select this doc group.
9280 (gnus-error 3 "Article couldn't be entered"))))))
9281 ;; Now we have selected all the documents.
9282 (cond
9283 ((not groups)
9284 (error "None of the articles could be interpreted as documents"))
9285 ((gnus-group-read-ephemeral-group
9286 (setq vgroup (format
9287 "nnvirtual:%s-%s" gnus-newsgroup-name
9288 (format-time-string "%Y%m%dT%H%M%S")))
9289 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
9290 t
9291 (cons (current-buffer) 'summary)))
9292 (t
9293 (error "Couldn't select virtual nndoc group")))))
9294
9295 (defun gnus-summary-widget-forward (arg)
9296 "Move point to the next field or button in the article.
9297 With optional ARG, move across that many fields."
9298 (interactive "p")
9299 (gnus-summary-select-article)
9300 (gnus-configure-windows 'article)
9301 (select-window (gnus-get-buffer-window gnus-article-buffer))
9302 (widget-forward arg))
9303
9304 (defun gnus-summary-widget-backward (arg)
9305 "Move point to the previous field or button in the article.
9306 With optional ARG, move across that many fields."
9307 (interactive "p")
9308 (gnus-summary-select-article)
9309 (gnus-configure-windows 'article)
9310 (select-window (gnus-get-buffer-window gnus-article-buffer))
9311 (unless (widget-at (point))
9312 (goto-char (point-max)))
9313 (widget-backward arg))
9314
9315 (defun gnus-summary-isearch-article (&optional regexp-p)
9316 "Do incremental search forward on the current article.
9317 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
9318 (interactive "P")
9319 (gnus-summary-select-article)
9320 (gnus-configure-windows 'article)
9321 (gnus-eval-in-buffer-window gnus-article-buffer
9322 (save-restriction
9323 (widen)
9324 (isearch-forward regexp-p))))
9325
9326 (defun gnus-summary-repeat-search-article-forward ()
9327 "Repeat the previous search forwards."
9328 (interactive)
9329 (unless gnus-last-search-regexp
9330 (error "No previous search"))
9331 (gnus-summary-search-article-forward gnus-last-search-regexp))
9332
9333 (defun gnus-summary-repeat-search-article-backward ()
9334 "Repeat the previous search backwards."
9335 (interactive)
9336 (unless gnus-last-search-regexp
9337 (error "No previous search"))
9338 (gnus-summary-search-article-forward gnus-last-search-regexp t))
9339
9340 (defun gnus-summary-search-article-forward (regexp &optional backward)
9341 "Search for an article containing REGEXP forward.
9342 If BACKWARD, search backward instead."
9343 (interactive
9344 (list (read-string
9345 (format "Search article %s (regexp%s): "
9346 (if current-prefix-arg "backward" "forward")
9347 (if gnus-last-search-regexp
9348 (concat ", default " gnus-last-search-regexp)
9349 "")))
9350 current-prefix-arg))
9351 (if (string-equal regexp "")
9352 (setq regexp (or gnus-last-search-regexp ""))
9353 (setq gnus-last-search-regexp regexp)
9354 (setq gnus-article-before-search gnus-current-article))
9355 ;; Intentionally set gnus-last-article.
9356 (setq gnus-last-article gnus-article-before-search)
9357 (let ((gnus-last-article gnus-last-article))
9358 (if (gnus-summary-search-article regexp backward)
9359 (gnus-summary-show-thread)
9360 (signal 'search-failed (list regexp)))))
9361
9362 (defun gnus-summary-search-article-backward (regexp)
9363 "Search for an article containing REGEXP backward."
9364 (interactive
9365 (list (read-string
9366 (format "Search article backward (regexp%s): "
9367 (if gnus-last-search-regexp
9368 (concat ", default " gnus-last-search-regexp)
9369 "")))))
9370 (gnus-summary-search-article-forward regexp 'backward))
9371
9372 (defun gnus-summary-search-article (regexp &optional backward)
9373 "Search for an article containing REGEXP.
9374 Optional argument BACKWARD means do search for backward.
9375 `gnus-select-article-hook' is not called during the search."
9376 ;; We have to require this here to make sure that the following
9377 ;; dynamic binding isn't shadowed by autoloading.
9378 (require 'gnus-async)
9379 (require 'gnus-art)
9380 (let ((gnus-select-article-hook nil) ;Disable hook.
9381 (gnus-article-prepare-hook nil)
9382 (gnus-mark-article-hook nil) ;Inhibit marking as read.
9383 (gnus-use-article-prefetch nil)
9384 (gnus-use-trees nil) ;Inhibit updating tree buffer.
9385 (gnus-visual nil)
9386 (gnus-keep-backlog nil)
9387 (gnus-break-pages nil)
9388 (gnus-summary-display-arrow nil)
9389 (gnus-updated-mode-lines nil)
9390 (gnus-auto-center-summary nil)
9391 (sum (current-buffer))
9392 (gnus-display-mime-function nil)
9393 (found nil)
9394 point)
9395 (gnus-save-hidden-threads
9396 (gnus-summary-select-article)
9397 (set-buffer gnus-article-buffer)
9398 (goto-char (window-point (get-buffer-window (current-buffer))))
9399 (when backward
9400 (forward-line -1))
9401 (while (not found)
9402 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
9403 (if (if backward
9404 (re-search-backward regexp nil t)
9405 (re-search-forward regexp nil t))
9406 ;; We found the regexp.
9407 (progn
9408 (setq found 'found)
9409 (beginning-of-line)
9410 (set-window-start
9411 (get-buffer-window (current-buffer))
9412 (point))
9413 (forward-line 1)
9414 (set-window-point
9415 (get-buffer-window (current-buffer))
9416 (point))
9417 (set-buffer sum)
9418 (setq point (point)))
9419 ;; We didn't find it, so we go to the next article.
9420 (set-buffer sum)
9421 (setq found 'not)
9422 (while (eq found 'not)
9423 (if (not (if backward (gnus-summary-find-prev)
9424 (gnus-summary-find-next)))
9425 ;; No more articles.
9426 (setq found t)
9427 ;; Select the next article and adjust point.
9428 (unless (gnus-summary-article-sparse-p
9429 (gnus-summary-article-number))
9430 (setq found nil)
9431 (gnus-summary-select-article)
9432 (set-buffer gnus-article-buffer)
9433 (widen)
9434 (goto-char (if backward (point-max) (point-min))))))))
9435 (gnus-message 7 ""))
9436 ;; Return whether we found the regexp.
9437 (when (eq found 'found)
9438 (goto-char point)
9439 (sit-for 0) ;; Ensure that the point is visible in the summary window.
9440 (gnus-summary-show-thread)
9441 (gnus-summary-goto-subject gnus-current-article)
9442 (gnus-summary-position-point)
9443 t)))
9444
9445 (defun gnus-find-matching-articles (header regexp)
9446 "Return a list of all articles that match REGEXP on HEADER.
9447 This search includes all articles in the current group that Gnus has
9448 fetched headers for, whether they are displayed or not."
9449 (let ((articles nil)
9450 ;; Can't eta-reduce because it's a macro.
9451 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
9452 (case-fold-search t))
9453 (dolist (header gnus-newsgroup-headers)
9454 (when (string-match regexp (funcall func header))
9455 (push (mail-header-number header) articles)))
9456 (nreverse articles)))
9457
9458 (defun gnus-summary-find-matching (header regexp &optional backward unread
9459 not-case-fold not-matching)
9460 "Return a list of all articles that match REGEXP on HEADER.
9461 The search stars on the current article and goes forwards unless
9462 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
9463 If UNREAD is non-nil, only unread articles will
9464 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
9465 in the comparisons. If NOT-MATCHING, return a list of all articles that
9466 not match REGEXP on HEADER."
9467 (let ((case-fold-search (not not-case-fold))
9468 articles d func)
9469 (if (consp header)
9470 (if (eq (car header) 'extra)
9471 (setq func
9472 `(lambda (h)
9473 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
9474 "")))
9475 (error "%s is an invalid header" header))
9476 (unless (fboundp (intern (concat "mail-header-" header)))
9477 (error "%s is not a valid header" header))
9478 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
9479 (dolist (d (if (eq backward 'all)
9480 gnus-newsgroup-data
9481 (gnus-data-find-list
9482 (gnus-summary-article-number)
9483 (gnus-data-list backward))))
9484 (when (and (or (not unread) ; We want all articles...
9485 (gnus-data-unread-p d)) ; Or just unreads.
9486 (vectorp (gnus-data-header d)) ; It's not a pseudo.
9487 (if not-matching
9488 (not (string-match
9489 regexp
9490 (funcall func (gnus-data-header d))))
9491 (string-match regexp
9492 (funcall func (gnus-data-header d)))))
9493 (push (gnus-data-number d) articles))) ; Success!
9494 (nreverse articles)))
9495
9496 (defun gnus-summary-execute-command (header regexp command &optional backward)
9497 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
9498 If HEADER is an empty string (or nil), the match is done on the entire
9499 article. If BACKWARD (the prefix) is non-nil, search backward instead."
9500 (interactive
9501 (list (let ((completion-ignore-case t))
9502 (gnus-completing-read
9503 "Header name"
9504 (mapcar 'symbol-name
9505 (append
9506 '(Number Subject From Lines Date
9507 Message-ID Xref References Body)
9508 gnus-extra-headers))
9509 'require-match))
9510 (read-string "Regexp: ")
9511 (read-key-sequence "Command: ")
9512 current-prefix-arg))
9513 (when (equal header "Body")
9514 (setq header ""))
9515 ;; Hidden thread subtrees must be searched as well.
9516 (gnus-summary-show-all-threads)
9517 ;; We don't want to change current point nor window configuration.
9518 (save-excursion
9519 (save-window-excursion
9520 (let (gnus-visual
9521 gnus-treat-strip-trailing-blank-lines
9522 gnus-treat-strip-leading-blank-lines
9523 gnus-treat-strip-multiple-blank-lines
9524 gnus-treat-hide-boring-headers
9525 gnus-treat-fold-newsgroups
9526 gnus-article-prepare-hook)
9527 (gnus-message 6 "Executing %s..." (key-description command))
9528 ;; We'd like to execute COMMAND interactively so as to give arguments.
9529 (gnus-execute header regexp
9530 `(call-interactively ',(key-binding command))
9531 backward)
9532 (gnus-message 6 "Executing %s...done" (key-description command))))))
9533
9534 (defun gnus-summary-beginning-of-article ()
9535 "Scroll the article back to the beginning."
9536 (interactive)
9537 (gnus-summary-select-article)
9538 (gnus-configure-windows 'article)
9539 (gnus-eval-in-buffer-window gnus-article-buffer
9540 (widen)
9541 (goto-char (point-min))
9542 (when gnus-break-pages
9543 (gnus-narrow-to-page))))
9544
9545 (defun gnus-summary-end-of-article ()
9546 "Scroll to the end of the article."
9547 (interactive)
9548 (gnus-summary-select-article)
9549 (gnus-configure-windows 'article)
9550 (gnus-eval-in-buffer-window gnus-article-buffer
9551 (widen)
9552 (goto-char (point-max))
9553 (recenter -3)
9554 (when gnus-break-pages
9555 (gnus-narrow-to-page))))
9556
9557 (defun gnus-summary-print-truncate-and-quote (string &optional len)
9558 "Truncate to LEN and quote all \"(\"'s in STRING."
9559 (replace-regexp-in-string "[()]" "\\\\\\&"
9560 (if (and len (> (length string) len))
9561 (substring string 0 len)
9562 string)))
9563
9564 (defun gnus-summary-print-article (&optional filename n)
9565 "Generate and print a PostScript image of the process-marked (mail) articles.
9566
9567 If used interactively, print the current article if none are
9568 process-marked. With prefix arg, prompt the user for the name of the
9569 file to save in.
9570
9571 When used from Lisp, accept two optional args FILENAME and N. N means
9572 to print the next N articles. If N is negative, print the N previous
9573 articles. If N is nil and articles have been marked with the process
9574 mark, print these instead.
9575
9576 If the optional first argument FILENAME is nil, send the image to the
9577 printer. If FILENAME is a string, save the PostScript image in a file with
9578 that name. If FILENAME is a number, prompt the user for the name of the file
9579 to save in."
9580 (interactive (list (ps-print-preprint current-prefix-arg)))
9581 (dolist (article (gnus-summary-work-articles n))
9582 (gnus-summary-select-article nil nil 'pseudo article)
9583 (gnus-eval-in-buffer-window gnus-article-buffer
9584 (gnus-print-buffer))
9585 (gnus-summary-remove-process-mark article))
9586 (ps-despool filename))
9587
9588 (defun gnus-print-buffer ()
9589 (let ((ps-left-header
9590 (list
9591 (concat "("
9592 (gnus-summary-print-truncate-and-quote
9593 (mail-header-subject gnus-current-headers)
9594 66) ")")
9595 (concat "("
9596 (gnus-summary-print-truncate-and-quote
9597 (mail-header-from gnus-current-headers)
9598 45) ")")))
9599 (ps-right-header
9600 (list
9601 "/pagenumberstring load"
9602 (concat "("
9603 (mail-header-date gnus-current-headers) ")"))))
9604 (gnus-run-hooks 'gnus-ps-print-hook)
9605 (save-excursion
9606 (if ps-print-color-p
9607 (ps-spool-buffer-with-faces)
9608 (ps-spool-buffer)))))
9609
9610 (declare-function gnus-flush-original-article-buffer "gnus-art" ())
9611
9612 (defun gnus-summary-show-complete-article ()
9613 "Show a complete version of the current article.
9614 This is only useful if you're looking at a partial version of the
9615 article currently."
9616 (interactive)
9617 (let ((gnus-keep-backlog nil)
9618 (gnus-use-cache nil)
9619 (gnus-agent nil)
9620 (variable (intern
9621 (format "%s-fetch-partial-articles"
9622 (car (gnus-find-method-for-group
9623 gnus-newsgroup-name)))
9624 obarray))
9625 old-val)
9626 (unwind-protect
9627 (progn
9628 (setq old-val (symbol-value variable))
9629 (set variable nil)
9630 (gnus-flush-original-article-buffer)
9631 (gnus-summary-show-article))
9632 (set variable old-val))))
9633
9634 (defun gnus-summary-show-article (&optional arg)
9635 "Force redisplaying of the current article.
9636 If ARG (the prefix) is a number, show the article with the charset
9637 defined in `gnus-summary-show-article-charset-alist', or the charset
9638 input.
9639 If ARG (the prefix) is non-nil and not a number, show the article,
9640 but without running any of the article treatment functions
9641 article. Normally, the keystroke is `C-u g'. When using `C-u
9642 C-u g', show the raw article."
9643 (interactive "P")
9644 (cond
9645 ((numberp arg)
9646 (gnus-summary-show-article t)
9647 (let ((gnus-newsgroup-charset
9648 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
9649 (read-coding-system
9650 "View as charset: " ;; actually it is coding system.
9651 (with-current-buffer gnus-article-buffer
9652 (mm-detect-coding-region (point) (point-max))))))
9653 (gnus-newsgroup-ignored-charsets 'gnus-all))
9654 (gnus-summary-select-article nil 'force)
9655 (let ((deps gnus-newsgroup-dependencies)
9656 head header lines)
9657 (with-current-buffer gnus-original-article-buffer
9658 (save-restriction
9659 (message-narrow-to-head)
9660 (setq head (buffer-string))
9661 (goto-char (point-min))
9662 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
9663 (goto-char (point-max))
9664 (widen)
9665 (setq lines (1- (count-lines (point) (point-max))))))
9666 (with-temp-buffer
9667 (insert (format "211 %d Article retrieved.\n"
9668 (cdr gnus-article-current)))
9669 (insert head)
9670 (if lines (insert (format "Lines: %d\n" lines)))
9671 (insert ".\n")
9672 (let ((nntp-server-buffer (current-buffer)))
9673 (setq header (car (gnus-get-newsgroup-headers deps t))))))
9674 (gnus-data-set-header
9675 (gnus-data-find (cdr gnus-article-current))
9676 header)
9677 (gnus-summary-update-article-line
9678 (cdr gnus-article-current) header)
9679 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9680 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
9681 ((not arg)
9682 ;; Select the article the normal way.
9683 (if (eq mm-text-html-renderer 'shr)
9684 (progn
9685 (require 'shr)
9686 (let ((shr-ignore-cache t))
9687 (gnus-summary-select-article nil 'force)))
9688 (gnus-summary-select-article nil 'force)))
9689 ((equal arg '(16))
9690 ;; C-u C-u g
9691 (let ((gnus-inhibit-article-treatments t))
9692 (gnus-summary-select-article nil 'force)))
9693 (t
9694 ;; We have to require this here to make sure that the following
9695 ;; dynamic binding isn't shadowed by autoloading.
9696 (require 'gnus-async)
9697 (require 'gnus-art)
9698 ;; Bind the article treatment functions to nil.
9699 (let ((gnus-have-all-headers t)
9700 gnus-article-prepare-hook
9701 gnus-article-decode-hook
9702 gnus-display-mime-function
9703 gnus-break-pages)
9704 ;; Destroy any MIME parts.
9705 (when (gnus-buffer-live-p gnus-article-buffer)
9706 (with-current-buffer gnus-article-buffer
9707 (gnus-article-stop-animations)
9708 (gnus-stop-downloads)
9709 (mm-destroy-parts gnus-article-mime-handles)
9710 ;; Set it to nil for safety reason.
9711 (setq gnus-article-mime-handle-alist nil)
9712 (setq gnus-article-mime-handles nil)))
9713 (gnus-summary-select-article nil 'force))))
9714 (gnus-summary-goto-subject gnus-current-article)
9715 (gnus-summary-position-point))
9716
9717 (defun gnus-summary-show-raw-article ()
9718 "Show the raw article without any article massaging functions being run."
9719 (interactive)
9720 (gnus-summary-show-article t))
9721
9722 (defun gnus-summary-verbose-headers (&optional arg)
9723 "Toggle permanent full header display.
9724 If ARG is a positive number, turn header display on.
9725 If ARG is a negative number, turn header display off."
9726 (interactive "P")
9727 (setq gnus-show-all-headers
9728 (cond ((or (not (numberp arg))
9729 (zerop arg))
9730 (not gnus-show-all-headers))
9731 ((natnump arg)
9732 t)))
9733 (gnus-summary-show-article))
9734
9735 (declare-function article-narrow-to-head "gnus-art" ())
9736 (declare-function gnus-article-hidden-text-p "gnus-art" (type))
9737 (declare-function gnus-delete-wash-type "gnus-art" (type))
9738 (declare-function gnus-mime-buttonize-attachments-in-header
9739 "gnus-art" (&optional interactive))
9740
9741 (defun gnus-summary-toggle-header (&optional arg)
9742 "Show the headers if they are hidden, or hide them if they are shown.
9743 If ARG is a positive number, show the entire header.
9744 If ARG is a negative number, hide the unwanted header lines."
9745 (interactive "P")
9746 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
9747 (get-buffer-window gnus-article-buffer t))))
9748 (with-current-buffer gnus-article-buffer
9749 (widen)
9750 (article-narrow-to-head)
9751 (let* ((inhibit-read-only t)
9752 (inhibit-point-motion-hooks t)
9753 (hidden (if (numberp arg)
9754 (>= arg 0)
9755 (or (not (looking-at "[^ \t\n]+:"))
9756 (gnus-article-hidden-text-p 'headers))))
9757 s e)
9758 (delete-region (point-min) (point-max))
9759 (with-current-buffer gnus-original-article-buffer
9760 (goto-char (setq s (point-min)))
9761 (setq e (if (search-forward "\n\n" nil t)
9762 (1- (point))
9763 (point-max))))
9764 (insert-buffer-substring gnus-original-article-buffer s e)
9765 (run-hooks 'gnus-article-decode-hook)
9766 (if hidden
9767 (let ((gnus-treat-hide-headers nil)
9768 (gnus-treat-hide-boring-headers nil))
9769 (gnus-delete-wash-type 'headers)
9770 (gnus-treat-article 'head))
9771 (gnus-treat-article 'head)
9772 ;; Add attachment buttons to the header.
9773 (when gnus-mime-display-attachment-buttons-in-header
9774 (gnus-mime-buttonize-attachments-in-header)))
9775 (widen)
9776 (if window
9777 (set-window-start window (goto-char (point-min))))
9778 (if gnus-break-pages
9779 (gnus-narrow-to-page)
9780 (when (gnus-visual-p 'page-marker)
9781 (let ((inhibit-read-only t))
9782 (gnus-remove-text-with-property 'gnus-prev)
9783 (gnus-remove-text-with-property 'gnus-next))))
9784 (gnus-set-mode-line 'article)))))
9785
9786 (defun gnus-summary-show-all-headers ()
9787 "Make all header lines visible."
9788 (interactive)
9789 (gnus-summary-toggle-header 1))
9790
9791 (defun gnus-summary-caesar-message (&optional arg)
9792 "Caesar rotate the current article by 13.
9793 With a non-numerical prefix, also rotate headers. A numerical
9794 prefix specifies how many places to rotate each letter forward."
9795 (interactive "P")
9796 (gnus-summary-select-article)
9797 (let ((mail-header-separator ""))
9798 (gnus-eval-in-buffer-window gnus-article-buffer
9799 (save-restriction
9800 (widen)
9801 (let ((start (window-start))
9802 (inhibit-read-only t))
9803 (if (equal arg '(4))
9804 (message-caesar-buffer-body nil t)
9805 (message-caesar-buffer-body arg))
9806 (set-window-start (get-buffer-window (current-buffer)) start)))))
9807 ;; Create buttons and stuff...
9808 (gnus-treat-article nil))
9809
9810 (defun gnus-summary-idna-message (&optional arg)
9811 "Decode IDNA encoded domain names in the current articles.
9812 IDNA encoded domain names looks like `xn--bar'. If a string
9813 remain unencoded after running this function, it is likely an
9814 invalid IDNA string (`xn--bar' is invalid).
9815
9816 You must have GNU Libidn (URL `http://www.gnu.org/software/libidn/')
9817 installed for this command to work."
9818 (interactive "P")
9819 (gnus-summary-select-article)
9820 (let ((mail-header-separator ""))
9821 (gnus-eval-in-buffer-window gnus-article-buffer
9822 (save-restriction
9823 (widen)
9824 (let ((start (window-start))
9825 buffer-read-only)
9826 (while (re-search-forward "\\(xn--[-0-9a-z]+\\)" nil t)
9827 (replace-match (puny-decode-domain (match-string 1))))
9828 (set-window-start (get-buffer-window (current-buffer)) start))))))
9829
9830 (defun gnus-summary-morse-message (&optional arg)
9831 "Morse decode the current article."
9832 (interactive "P")
9833 (gnus-summary-select-article)
9834 (let ((mail-header-separator ""))
9835 (gnus-eval-in-buffer-window gnus-article-buffer
9836 (save-excursion
9837 (save-restriction
9838 (widen)
9839 (let ((pos (window-start))
9840 (inhibit-read-only t))
9841 (goto-char (point-min))
9842 (when (message-goto-body)
9843 (gnus-narrow-to-body))
9844 (goto-char (point-min))
9845 (while (search-forward "·" (point-max) t)
9846 (replace-match "."))
9847 (unmorse-region (point-min) (point-max))
9848 (widen)
9849 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
9850
9851 (defun gnus-summary-stop-page-breaking ()
9852 "Stop page breaking in the current article."
9853 (interactive)
9854 (gnus-summary-select-article)
9855 (gnus-eval-in-buffer-window gnus-article-buffer
9856 (widen)
9857 (when (gnus-visual-p 'page-marker)
9858 (let ((inhibit-read-only t))
9859 (gnus-remove-text-with-property 'gnus-prev)
9860 (gnus-remove-text-with-property 'gnus-next))
9861 (setq gnus-page-broken nil))))
9862
9863 (defun gnus-summary-move-article (&optional n to-newsgroup
9864 select-method action)
9865 "Move the current article to a different newsgroup.
9866 If N is a positive number, move the N next articles.
9867 If N is a negative number, move the N previous articles.
9868 If N is nil and any articles have been marked with the process mark,
9869 move those articles instead.
9870 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
9871 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9872 re-spool using this method.
9873
9874 When called interactively with TO-NEWSGROUP being nil, the value of
9875 the variable `gnus-move-split-methods' is used for finding a default
9876 for the target newsgroup.
9877
9878 For this function to work, both the current newsgroup and the
9879 newsgroup that you want to move to have to support the `request-move'
9880 and `request-accept' functions.
9881
9882 ACTION can be either `move' (the default), `crosspost' or `copy'."
9883 (interactive "P")
9884 (unless action
9885 (setq action 'move))
9886 ;; Check whether the source group supports the required functions.
9887 (cond ((and (eq action 'move)
9888 (not (gnus-check-backend-function
9889 'request-move-article gnus-newsgroup-name)))
9890 (error "The current group does not support article moving"))
9891 ((and (eq action 'crosspost)
9892 (not (gnus-check-backend-function
9893 'request-replace-article gnus-newsgroup-name)))
9894 (error "The current group does not support article editing")))
9895 (let ((articles (gnus-summary-work-articles n))
9896 (prefix (if (gnus-check-backend-function
9897 'request-move-article gnus-newsgroup-name)
9898 (funcall gnus-move-group-prefix-function
9899 gnus-newsgroup-name)
9900 ""))
9901 (names '((move "Move" "Moving")
9902 (copy "Copy" "Copying")
9903 (crosspost "Crosspost" "Crossposting")))
9904 (copy-buf (save-excursion
9905 (nnheader-set-temp-buffer " *copy article*")))
9906 art-group to-method new-xref article to-groups
9907 articles-to-update-marks encoded)
9908 (unless (assq action names)
9909 (error "Unknown action %s" action))
9910 ;; Read the newsgroup name.
9911 (when (and (not to-newsgroup)
9912 (not select-method))
9913 (if (and gnus-move-split-methods
9914 (not
9915 (and (memq gnus-current-article articles)
9916 (gnus-buffer-live-p gnus-original-article-buffer))))
9917 ;; When `gnus-move-split-methods' is non-nil, we have to
9918 ;; select an article to give `gnus-read-move-group-name' an
9919 ;; opportunity to suggest an appropriate default. However,
9920 ;; we needn't render or mark the article.
9921 (let ((gnus-display-mime-function nil)
9922 (gnus-article-prepare-hook nil)
9923 (gnus-mark-article-hook nil))
9924 (gnus-summary-select-article nil nil nil (car articles))))
9925 (setq to-newsgroup (gnus-read-move-group-name
9926 (cadr (assq action names))
9927 (symbol-value
9928 (intern (format "gnus-current-%s-group" action)))
9929 articles prefix)
9930 encoded to-newsgroup
9931 to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
9932 (set (intern (format "gnus-current-%s-group" action))
9933 (decode-coding-string
9934 to-newsgroup
9935 (gnus-group-name-charset to-method to-newsgroup))))
9936 (unless to-method
9937 (setq to-method (or select-method
9938 (gnus-server-to-method
9939 (gnus-group-method to-newsgroup)))))
9940 (setq to-newsgroup
9941 (or encoded
9942 (and to-newsgroup
9943 (encode-coding-string
9944 to-newsgroup
9945 (gnus-group-name-charset to-method to-newsgroup)))))
9946 ;; Check the method we are to move this article to...
9947 (unless (gnus-check-backend-function
9948 'request-accept-article (car to-method))
9949 (error "%s does not support article copying" (car to-method)))
9950 (unless (gnus-check-server to-method)
9951 (error "Can't open server %s" (car to-method)))
9952 (gnus-message 6 "%s to %s: %s..."
9953 (caddr (assq action names))
9954 (or (car select-method)
9955 (gnus-group-decoded-name to-newsgroup))
9956 articles)
9957 (while articles
9958 (setq article (pop articles))
9959 ;; Set any marks that may have changed in the summary buffer.
9960 (when gnus-preserve-marks
9961 (gnus-summary-push-marks-to-backend article))
9962 (setq
9963 art-group
9964 (cond
9965 ;; Move the article.
9966 ((eq action 'move)
9967 ;; Remove this article from future suppression.
9968 (gnus-dup-unsuppress-article article)
9969 (let* ((from-method (gnus-find-method-for-group
9970 gnus-newsgroup-name))
9971 (to-method (or select-method
9972 (gnus-find-method-for-group to-newsgroup)))
9973 (move-is-internal (gnus-server-equal from-method to-method)))
9974 (gnus-request-move-article
9975 article ; Article to move
9976 gnus-newsgroup-name ; From newsgroup
9977 (nth 1 (gnus-find-method-for-group
9978 gnus-newsgroup-name)) ; Server
9979 (list 'gnus-request-accept-article
9980 to-newsgroup (list 'quote select-method)
9981 (not articles) t) ; Accept form
9982 (not articles) ; Only save nov last time
9983 (and move-is-internal
9984 to-newsgroup ; Not respooling
9985 ; Is this move internal?
9986 (gnus-group-real-name to-newsgroup)))))
9987 ;; Copy the article.
9988 ((eq action 'copy)
9989 (with-current-buffer copy-buf
9990 (when (gnus-request-article-this-buffer article
9991 gnus-newsgroup-name)
9992 (save-restriction
9993 (nnheader-narrow-to-headers)
9994 (dolist (hdr gnus-copy-article-ignored-headers)
9995 (message-remove-header hdr t)))
9996 (gnus-request-accept-article
9997 to-newsgroup select-method (not articles) t))))
9998 ;; Crosspost the article.
9999 ((eq action 'crosspost)
10000 (let ((xref (message-tokenize-header
10001 (mail-header-xref (gnus-summary-article-header
10002 article))
10003 " ")))
10004 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
10005 ":" (number-to-string article)))
10006 (unless xref
10007 (setq xref (list (system-name))))
10008 (setq new-xref
10009 (concat
10010 (mapconcat 'identity
10011 (delete "Xref:" (delete new-xref xref))
10012 " ")
10013 " " new-xref))
10014 (with-current-buffer copy-buf
10015 ;; First put the article in the destination group.
10016 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10017 (when (consp (setq art-group
10018 (gnus-request-accept-article
10019 to-newsgroup select-method (not articles)
10020 t)))
10021 (setq new-xref (concat new-xref " " (car art-group)
10022 ":"
10023 (number-to-string (cdr art-group))))
10024 ;; Now we have the new Xrefs header, so we insert
10025 ;; it and replace the new article.
10026 (nnheader-replace-header "Xref" new-xref)
10027 (gnus-request-replace-article
10028 (cdr art-group) to-newsgroup (current-buffer) t)
10029 art-group))))))
10030 (cond
10031 ((not art-group)
10032 (gnus-message 1 "Couldn't %s article %s: %s"
10033 (cadr (assq action names)) article
10034 (nnheader-get-report (car to-method))))
10035 ((eq art-group 'junk)
10036 (when (eq action 'move)
10037 (gnus-summary-mark-article article gnus-canceled-mark)
10038 (gnus-message 4 "Deleted article %s" article)
10039 ;; run the delete hook
10040 (run-hook-with-args 'gnus-summary-article-delete-hook
10041 action
10042 (gnus-data-header
10043 (assoc article (gnus-data-list nil)))
10044 gnus-newsgroup-name nil
10045 select-method)))
10046 (t
10047 (let* ((pto-group (gnus-group-prefixed-name
10048 (car art-group) to-method))
10049 (info (gnus-get-info pto-group))
10050 (to-group (gnus-info-group info))
10051 to-marks)
10052 ;; Update the group that has been moved to.
10053 (when (and info
10054 (memq action '(move copy)))
10055 (unless (member to-group to-groups)
10056 (push to-group to-groups))
10057
10058 (when (and (not (memq article gnus-newsgroup-unreads))
10059 (cdr art-group))
10060 (push 'read to-marks)
10061 (gnus-info-set-read
10062 info (gnus-add-to-range (gnus-info-read info)
10063 (list (cdr art-group)))))
10064
10065 ;; See whether the article is to be put in the cache.
10066 (let* ((expirable (gnus-group-auto-expirable-p to-group))
10067 (marks (if expirable
10068 gnus-article-mark-lists
10069 (delete '(expirable . expire)
10070 (copy-sequence
10071 gnus-article-mark-lists))))
10072 (to-article (cdr art-group)))
10073
10074 ;; Enter the article into the cache in the new group,
10075 ;; if that is required.
10076 (when (and to-article
10077 gnus-use-cache)
10078 (gnus-cache-possibly-enter-article
10079 to-group to-article
10080 (memq article gnus-newsgroup-marked)
10081 (memq article gnus-newsgroup-dormant)
10082 (memq article gnus-newsgroup-unreads)))
10083
10084 (when (and gnus-preserve-marks
10085 to-article)
10086 ;; Copy any marks over to the new group.
10087 (when (and (equal to-group gnus-newsgroup-name)
10088 (not (memq article gnus-newsgroup-unreads)))
10089 ;; Mark this article as read in this group.
10090 (push (cons to-article gnus-read-mark)
10091 gnus-newsgroup-reads)
10092 ;; Increase the active status of this group.
10093 (setcdr (gnus-active to-group) to-article)
10094 (setcdr gnus-newsgroup-active to-article))
10095
10096 (while marks
10097 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10098 (when (memq article (symbol-value
10099 (intern (format "gnus-newsgroup-%s"
10100 (caar marks)))))
10101 (push (cdar marks) to-marks)
10102 ;; If the other group is the same as this group,
10103 ;; then we have to add the mark to the list.
10104 (when (equal to-group gnus-newsgroup-name)
10105 (set (intern (format "gnus-newsgroup-%s"
10106 (caar marks)))
10107 (cons to-article
10108 (symbol-value
10109 (intern (format "gnus-newsgroup-%s"
10110 (caar marks)))))))
10111 ;; Copy the marks to other group.
10112 (gnus-add-marked-articles
10113 to-group (cdar marks) (list to-article) info)))
10114 (setq marks (cdr marks)))
10115
10116 (when (and expirable
10117 gnus-mark-copied-or-moved-articles-as-expirable
10118 (not (memq 'expire to-marks)))
10119 ;; Mark this article as expirable.
10120 (push 'expire to-marks)
10121 (when (equal to-group gnus-newsgroup-name)
10122 (push to-article gnus-newsgroup-expirable))
10123 ;; Copy the expirable mark to other group.
10124 (gnus-add-marked-articles
10125 to-group 'expire (list to-article) info))
10126
10127 (when (and to-marks
10128 (gnus-method-option-p
10129 (gnus-find-method-for-group to-group)
10130 'server-marks))
10131 (gnus-request-set-mark
10132 to-group (list (list (list to-article) 'add to-marks)))))
10133
10134 (gnus-dribble-enter
10135 (concat "(gnus-group-set-info '"
10136 (gnus-prin1-to-string (gnus-get-info to-group))
10137 ")")
10138 (concat "^(gnus-group-set-info '(\""
10139 (regexp-quote to-group) "\""))))
10140
10141 ;; Update the Xref header in this article to point to
10142 ;; the new crossposted article we have just created.
10143 (when (eq action 'crosspost)
10144 (with-current-buffer copy-buf
10145 (gnus-request-article-this-buffer article gnus-newsgroup-name)
10146 (nnheader-replace-header "Xref" new-xref)
10147 (gnus-request-replace-article
10148 article gnus-newsgroup-name (current-buffer) t)))
10149
10150 ;; run the move/copy/crosspost/respool hook
10151 (run-hook-with-args 'gnus-summary-article-move-hook
10152 action
10153 (gnus-data-header
10154 (assoc article (gnus-data-list nil)))
10155 gnus-newsgroup-name
10156 to-newsgroup
10157 select-method))
10158
10159 ;;;!!!Why is this necessary?
10160 (set-buffer gnus-summary-buffer)
10161
10162 (when (eq action 'move)
10163 (save-excursion
10164 (gnus-summary-goto-subject article)
10165 (gnus-summary-mark-article article gnus-canceled-mark)))))
10166 (push article articles-to-update-marks))
10167
10168 (save-excursion
10169 (apply 'gnus-summary-remove-process-mark articles-to-update-marks))
10170 ;; Re-activate all groups that have been moved to.
10171 (with-current-buffer gnus-group-buffer
10172 (let ((gnus-group-marked to-groups))
10173 (gnus-group-get-new-news-this-group nil t)))
10174
10175 (gnus-kill-buffer copy-buf)
10176 (gnus-summary-position-point)
10177 (gnus-set-mode-line 'summary)))
10178
10179 (defun gnus-summary-push-marks-to-backend (article)
10180 (let ((set nil)
10181 (del nil)
10182 (marks gnus-article-mark-lists))
10183 (unless (memq article gnus-newsgroup-unreads)
10184 (push 'read set))
10185 (while marks
10186 (if (and (eq (gnus-article-mark-to-type (cdar marks)) 'list)
10187 (memq article (symbol-value
10188 (intern (format "gnus-newsgroup-%s"
10189 (caar marks))))))
10190 (push (cdar marks) set)
10191 (push (cdar marks) del))
10192 (pop marks))
10193 (gnus-request-set-mark gnus-newsgroup-name `(((,article) set ,set)
10194 ((,article) del ,del)))))
10195
10196 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
10197 "Copy the current article to some other group.
10198 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
10199 When called interactively, if TO-NEWSGROUP is nil, use the value of
10200 the variable `gnus-move-split-methods' for finding a default target
10201 newsgroup.
10202 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
10203 re-spool using this method."
10204 (interactive "P")
10205 (gnus-summary-move-article n to-newsgroup select-method 'copy))
10206
10207 (defun gnus-summary-crosspost-article (&optional n)
10208 "Crosspost the current article to some other group."
10209 (interactive "P")
10210 (gnus-summary-move-article n nil nil 'crosspost))
10211
10212 (defcustom gnus-summary-respool-default-method nil
10213 "Default method type for respooling an article.
10214 If nil, use to the current newsgroup method."
10215 :type 'symbol
10216 :group 'gnus-summary-mail)
10217
10218 (defun gnus-summary-respool-article (&optional n method)
10219 "Respool the current article.
10220 The article will be squeezed through the mail spooling process again,
10221 which means that it will be put in some mail newsgroup or other
10222 depending on `nnmail-split-methods'.
10223 If N is a positive number, respool the N next articles.
10224 If N is a negative number, respool the N previous articles.
10225 If N is nil and any articles have been marked with the process mark,
10226 respool those articles instead.
10227
10228 Respooling can be done both from mail groups and \"real\" newsgroups.
10229 In the former case, the articles in question will be moved from the
10230 current group into whatever groups they are destined to. In the
10231 latter case, they will be copied into the relevant groups."
10232 (interactive
10233 (list current-prefix-arg
10234 (let* ((methods (mapcar #'car (gnus-methods-using 'respool)))
10235 (methname
10236 (symbol-name (or gnus-summary-respool-default-method
10237 (car (gnus-find-method-for-group
10238 gnus-newsgroup-name)))))
10239 (method
10240 (gnus-completing-read
10241 "Backend to use when respooling"
10242 methods t nil 'gnus-mail-method-history methname))
10243 ms)
10244 (cond
10245 ((zerop (length (setq ms (gnus-servers-using-backend
10246 (intern method)))))
10247 (list (intern method) ""))
10248 ((= 1 (length ms))
10249 (car ms))
10250 (t
10251 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
10252 (cdr (assoc (gnus-completing-read "Server name" ms-alist t)
10253 ms-alist))))))))
10254 (unless method
10255 (error "No method given for respooling"))
10256 (if (assoc (symbol-name
10257 (car (gnus-find-method-for-group gnus-newsgroup-name)))
10258 (gnus-methods-using 'respool))
10259 (gnus-summary-move-article n nil method)
10260 (gnus-summary-copy-article n nil method)))
10261
10262 (defun gnus-summary-import-article (file &optional edit)
10263 "Import an arbitrary file into a mail newsgroup."
10264 (interactive "fImport file: \nP")
10265 (let ((group gnus-newsgroup-name)
10266 (now (current-time))
10267 atts lines group-art)
10268 (unless (gnus-check-backend-function 'request-accept-article group)
10269 (error "%s does not support article importing" group))
10270 (or (file-readable-p file)
10271 (not (file-regular-p file))
10272 (error "Can't read %s" file))
10273 (with-current-buffer (gnus-get-buffer-create " *import file*")
10274 (erase-buffer)
10275 (nnheader-insert-file-contents file)
10276 (goto-char (point-min))
10277 (if (nnheader-article-p)
10278 (save-restriction
10279 (goto-char (point-min))
10280 (search-forward "\n\n" nil t)
10281 (narrow-to-region (point-min) (1- (point)))
10282 (goto-char (point-min))
10283 (unless (re-search-forward "^date:" nil t)
10284 (goto-char (point-max))
10285 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
10286 ;; This doesn't look like an article, so we fudge some headers.
10287 (setq atts (file-attributes file)
10288 lines (count-lines (point-min) (point-max)))
10289 (insert "From: " (read-string "From: ") "\n"
10290 "Subject: " (read-string "Subject: ") "\n"
10291 "Date: " (message-make-date (nth 5 atts)) "\n"
10292 "Message-ID: " (message-make-message-id) "\n"
10293 "Lines: " (int-to-string lines) "\n"
10294 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
10295 (setq group-art (gnus-request-accept-article group nil t))
10296 (kill-buffer (current-buffer)))
10297 (setq gnus-newsgroup-active (gnus-activate-group group))
10298 (forward-line 1)
10299 (gnus-summary-goto-article (cdr group-art) nil t)
10300 (when edit
10301 (gnus-summary-edit-article))))
10302
10303 (defun gnus-summary-create-article ()
10304 "Create an article in a mail newsgroup."
10305 (interactive)
10306 (let ((group gnus-newsgroup-name)
10307 (now (current-time))
10308 group-art)
10309 (unless (gnus-check-backend-function 'request-accept-article group)
10310 (error "%s does not support article importing" group))
10311 (with-current-buffer (gnus-get-buffer-create " *import file*")
10312 (erase-buffer)
10313 (goto-char (point-min))
10314 ;; This doesn't look like an article, so we fudge some headers.
10315 (insert "From: " (read-string "From: ") "\n"
10316 "Subject: " (read-string "Subject: ") "\n"
10317 "Date: " (message-make-date now) "\n"
10318 "Message-ID: " (message-make-message-id) "\n")
10319 (setq group-art (gnus-request-accept-article group nil t))
10320 (kill-buffer (current-buffer)))
10321 (setq gnus-newsgroup-active (gnus-activate-group group))
10322 (forward-line 1)
10323 (gnus-summary-goto-article (cdr group-art) nil t)
10324 (gnus-summary-edit-article)))
10325
10326 (defun gnus-summary-article-posted-p ()
10327 "Say whether the current (mail) article is available from news as well.
10328 This will be the case if the article has both been mailed and posted."
10329 (interactive)
10330 (let ((id (mail-header-references (gnus-summary-article-header)))
10331 (gnus-override-method (car (gnus-refer-article-methods))))
10332 (if (gnus-request-head id "")
10333 (gnus-message 2 "The current message was found on %s"
10334 gnus-override-method)
10335 (gnus-message 2 "The current message couldn't be found on %s"
10336 gnus-override-method)
10337 nil)))
10338
10339 (defun gnus-summary-expire-articles (&optional now)
10340 "Expire all articles that are marked as expirable in the current group."
10341 (interactive)
10342 (when (and (not gnus-group-is-exiting-without-update-p)
10343 (gnus-check-backend-function
10344 'request-expire-articles gnus-newsgroup-name))
10345 ;; This backend supports expiry.
10346 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
10347 (expirable
10348 (gnus-list-range-difference
10349 (if total
10350 (progn
10351 ;; We need to update the info for
10352 ;; this group for `gnus-list-of-read-articles'
10353 ;; to give us the right answer.
10354 (gnus-run-hooks 'gnus-exit-group-hook)
10355 (gnus-summary-update-info)
10356 (gnus-list-of-read-articles gnus-newsgroup-name))
10357 (setq gnus-newsgroup-expirable
10358 (sort gnus-newsgroup-expirable '<)))
10359 gnus-newsgroup-unexist))
10360 (expiry-wait (if now 'immediate
10361 (gnus-group-find-parameter
10362 gnus-newsgroup-name 'expiry-wait)))
10363 (nnmail-expiry-target
10364 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
10365 nnmail-expiry-target))
10366 es)
10367 (when expirable
10368 ;; There are expirable articles in this group, so we run them
10369 ;; through the expiry process.
10370 (gnus-message 6 "Expiring articles...")
10371 (when (gnus-check-group gnus-newsgroup-name)
10372 ;; The list of articles that weren't expired is returned.
10373 (save-excursion
10374 (if expiry-wait
10375 (let ((nnmail-expiry-wait-function nil)
10376 (nnmail-expiry-wait expiry-wait))
10377 (setq es (gnus-request-expire-articles
10378 expirable gnus-newsgroup-name)))
10379 (setq es (gnus-request-expire-articles
10380 expirable gnus-newsgroup-name)))
10381 (unless total
10382 (setq gnus-newsgroup-expirable es))
10383 ;; We go through the old list of expirable, and mark all
10384 ;; really expired articles as nonexistent.
10385 (unless (eq es expirable) ;If nothing was expired, we don't mark.
10386 (let ((gnus-use-cache nil))
10387 (dolist (article expirable)
10388 (when (and (not (memq article es))
10389 (gnus-data-find article))
10390 (gnus-summary-mark-article article gnus-canceled-mark)
10391 (run-hook-with-args
10392 'gnus-summary-article-expire-hook
10393 'delete
10394 (gnus-data-header (assoc article (gnus-data-list nil)))
10395 gnus-newsgroup-name
10396 (cond
10397 ((stringp nnmail-expiry-target) nnmail-expiry-target)
10398 ((eq nnmail-expiry-target 'delete) nil)
10399 (t
10400 (let ((rescall (funcall nnmail-expiry-target
10401 gnus-newsgroup-name)))
10402 (if (stringp rescall) rescall nil))))
10403 nil)))))))
10404 (gnus-message 6 "Expiring articles...done")))))
10405
10406 (defun gnus-summary-expire-articles-now ()
10407 "Expunge all expirable articles in the current group.
10408 This means that *all* articles that are marked as expirable will be
10409 deleted forever, right now."
10410 (interactive)
10411 (or gnus-expert-user
10412 (gnus-yes-or-no-p
10413 "Are you really, really sure you want to delete all expirable messages? ")
10414 (error "Phew!"))
10415 (gnus-summary-expire-articles t))
10416
10417 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
10418 (defun gnus-summary-delete-article (&optional n)
10419 "Delete the N next (mail) articles.
10420 This command actually deletes articles. This is not a marking
10421 command. The article will disappear forever from your life, never to
10422 return.
10423
10424 If N is negative, delete backwards.
10425 If N is nil and articles have been marked with the process mark,
10426 delete these instead.
10427
10428 If `gnus-novice-user' is non-nil you will be asked for
10429 confirmation before the articles are deleted."
10430 (interactive "P")
10431 (unless (gnus-check-backend-function 'request-expire-articles
10432 gnus-newsgroup-name)
10433 (error "The current newsgroup does not support article deletion"))
10434 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
10435 (error "Couldn't open server"))
10436 ;; Compute the list of articles to delete.
10437 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
10438 (nnmail-expiry-target 'delete)
10439 not-deleted)
10440 (if (and gnus-novice-user
10441 (not (gnus-yes-or-no-p
10442 (format "Do you really want to delete %s forever? "
10443 (if (> (length articles) 1)
10444 (format "these %s articles" (length articles))
10445 "this article")))))
10446 ()
10447 ;; Delete the articles.
10448 (setq not-deleted (gnus-request-expire-articles
10449 articles gnus-newsgroup-name 'force))
10450 (save-excursion
10451 (while articles
10452 (gnus-summary-remove-process-mark (car articles))
10453 ;; The backend might not have been able to delete the article
10454 ;; after all.
10455 (unless (memq (car articles) not-deleted)
10456 (gnus-summary-mark-article (car articles) gnus-canceled-mark)
10457 (let* ((article (car articles))
10458 (ghead (gnus-data-header
10459 (assoc article (gnus-data-list nil)))))
10460 (run-hook-with-args 'gnus-summary-article-delete-hook
10461 'delete ghead gnus-newsgroup-name nil
10462 nil)))
10463 (setq articles (cdr articles))))
10464 (when not-deleted
10465 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
10466 (gnus-summary-position-point)
10467 (gnus-set-mode-line 'summary)
10468 not-deleted))
10469
10470 (defun gnus-summary-edit-article (&optional arg)
10471 "Edit the current article.
10472 This will have permanent effect only in mail groups.
10473 If ARG is nil, edit the decoded articles.
10474 If ARG is 1, edit the raw articles.
10475 If ARG is 2, edit the raw articles even in read-only groups.
10476 If ARG is 3, edit the articles with the current handles.
10477 Otherwise, allow editing of articles even in read-only
10478 groups."
10479 (interactive "P")
10480 (let (force raw current-handles)
10481 (cond
10482 ((null arg))
10483 ((eq arg 1)
10484 (setq raw t))
10485 ((eq arg 2)
10486 (setq raw t
10487 force t))
10488 ((eq arg 3)
10489 (setq current-handles
10490 (and (gnus-buffer-live-p gnus-article-buffer)
10491 (with-current-buffer gnus-article-buffer
10492 (prog1
10493 gnus-article-mime-handles
10494 (setq gnus-article-mime-handles nil))))))
10495 (t
10496 (setq force t)))
10497 (when (and raw (not force)
10498 (member gnus-newsgroup-name '("nndraft:delayed"
10499 "nndraft:drafts"
10500 "nndraft:queue")))
10501 (error "Can't edit the raw article in group %s"
10502 gnus-newsgroup-name))
10503 (with-current-buffer gnus-summary-buffer
10504 (let ((mail-parse-charset gnus-newsgroup-charset)
10505 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
10506 (gnus-set-global-variables)
10507 (when (and (not force)
10508 (gnus-group-read-only-p))
10509 (error "The current newsgroup does not support article editing"))
10510 (gnus-summary-show-article t)
10511 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
10512 (with-current-buffer gnus-article-buffer
10513 (mm-enable-multibyte)))
10514 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
10515 (setq raw t))
10516 (gnus-article-edit-article
10517 (if raw 'ignore
10518 `(lambda ()
10519 (let ((mbl mml-buffer-list))
10520 (setq mml-buffer-list nil)
10521 (let ((rfc2047-quote-decoded-words-containing-tspecials t))
10522 (mime-to-mml ,'current-handles))
10523 (let ((mbl1 mml-buffer-list))
10524 (setq mml-buffer-list mbl)
10525 (set (make-local-variable 'mml-buffer-list) mbl1))
10526 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
10527 `(lambda (no-highlight)
10528 (let ((mail-parse-charset ',gnus-newsgroup-charset)
10529 (message-options message-options)
10530 (message-options-set-recipient)
10531 (mail-parse-ignored-charsets
10532 ',gnus-newsgroup-ignored-charsets)
10533 (rfc2047-header-encoding-alist
10534 ',(let ((charset (gnus-group-name-charset
10535 (gnus-find-method-for-group
10536 gnus-newsgroup-name)
10537 gnus-newsgroup-name)))
10538 (append (list (cons "Newsgroups" charset)
10539 (cons "Followup-To" charset)
10540 (cons "Xref" charset))
10541 rfc2047-header-encoding-alist))))
10542 ,(if (not raw) '(progn
10543 (mml-to-mime)
10544 (mml-destroy-buffers)
10545 (remove-hook 'kill-buffer-hook
10546 'mml-destroy-buffers t)
10547 (kill-local-variable 'mml-buffer-list)))
10548 (gnus-summary-edit-article-done
10549 ,(or (mail-header-references gnus-current-headers) "")
10550 ,(gnus-group-read-only-p)
10551 ,gnus-summary-buffer no-highlight))))))))
10552
10553 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
10554
10555 (defun gnus-summary-edit-article-done (&optional references read-only buffer
10556 no-highlight)
10557 "Make edits to the current article permanent."
10558 (interactive)
10559 (save-excursion
10560 ;; The buffer restriction contains the entire article if it exists.
10561 (when (article-goto-body)
10562 (let ((lines (count-lines (point) (point-max)))
10563 (length (- (point-max) (point)))
10564 (case-fold-search t)
10565 (body (point-marker)))
10566 (goto-char (point-min))
10567 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
10568 (delete-region (match-beginning 1) (match-end 1))
10569 (insert (number-to-string length)))
10570 (goto-char (point-min))
10571 (when (re-search-forward
10572 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
10573 (delete-region (match-beginning 1) (match-end 1))
10574 (insert (number-to-string length)))
10575 (goto-char (point-min))
10576 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
10577 (delete-region (match-beginning 1) (match-end 1))
10578 (insert (number-to-string lines))))))
10579 ;; Replace the article.
10580 (let ((buf (current-buffer))
10581 (article (cdr gnus-article-current))
10582 replace-result)
10583 (with-temp-buffer
10584 (insert-buffer-substring buf)
10585 (if (and (not read-only)
10586 (not (setq replace-result
10587 (gnus-request-replace-article
10588 article (car gnus-article-current)
10589 (current-buffer) t))))
10590 (error "Couldn't replace article")
10591 ;; If we got a number back, then that's the new article number
10592 ;; for this article. Otherwise, the article number didn't change.
10593 (when (numberp replace-result)
10594 (with-current-buffer gnus-summary-buffer
10595 (setq gnus-newsgroup-limit (delq article gnus-newsgroup-limit))
10596 (gnus-summary-limit gnus-newsgroup-limit)
10597 (setq article replace-result)
10598 (gnus-summary-goto-subject article t)))
10599 ;; Update the summary buffer.
10600 (if (and references
10601 (equal (message-tokenize-header references " ")
10602 (message-tokenize-header
10603 (or (message-fetch-field "references") "") " ")))
10604 ;; We only have to update this line.
10605 (save-excursion
10606 (save-restriction
10607 (message-narrow-to-head)
10608 (let ((head (buffer-substring-no-properties
10609 (point-min) (point-max)))
10610 header)
10611 (with-temp-buffer
10612 (insert (format "211 %d Article retrieved.\n" article))
10613 (insert head)
10614 (insert ".\n")
10615 (let ((nntp-server-buffer (current-buffer)))
10616 (setq header (car (gnus-get-newsgroup-headers nil t))))
10617 (with-current-buffer gnus-summary-buffer
10618 (gnus-data-set-header (gnus-data-find article) header)
10619 (gnus-summary-update-article-line article header)
10620 (if (gnus-summary-goto-subject article nil t)
10621 (gnus-summary-update-secondary-mark article)))))))
10622 ;; Update threads.
10623 (set-buffer (or buffer gnus-summary-buffer))
10624 (gnus-summary-update-article article)
10625 (if (gnus-summary-goto-subject article nil t)
10626 (gnus-summary-update-secondary-mark article)))
10627 ;; Prettify the article buffer again.
10628 (unless no-highlight
10629 (with-current-buffer gnus-article-buffer
10630 ;;!!! Fix this -- article should be rehighlighted.
10631 ;;(gnus-run-hooks 'gnus-article-display-hook)
10632 (set-buffer gnus-original-article-buffer)
10633 (gnus-request-article
10634 article (car gnus-article-current) (current-buffer))))
10635 ;; Prettify the summary buffer line.
10636 (when (gnus-visual-p 'summary-highlight 'highlight)
10637 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
10638
10639 (defun gnus-summary-edit-wash (key)
10640 "Perform editing command KEY in the article buffer."
10641 (interactive
10642 (list
10643 (progn
10644 (message "%s" (concat (this-command-keys) "- "))
10645 (read-char))))
10646 (message "")
10647 (gnus-summary-edit-article)
10648 (execute-kbd-macro (concat (this-command-keys) key))
10649 (gnus-article-edit-done))
10650
10651 ;;; Respooling
10652
10653 (defvar nnimap-split-fancy)
10654 (defvar nnimap-split-methods)
10655
10656 (defun gnus-summary-respool-query (&optional silent trace)
10657 "Query where the respool algorithm would put this article."
10658 (interactive)
10659 (let (gnus-mark-article-hook)
10660 (gnus-summary-select-article)
10661 (with-current-buffer gnus-original-article-buffer
10662 (let ((groups
10663 (if (eq (car (gnus-find-method-for-group gnus-newsgroup-name))
10664 'nnimap)
10665 ;; nnimap has its own splitting variables.
10666 (let ((nnmail-split-methods
10667 (cond
10668 ((eq nnimap-split-methods 'default)
10669 nnmail-split-methods)
10670 (nnimap-split-methods
10671 nnimap-split-methods)
10672 (nnimap-split-fancy
10673 'nnmail-split-fancy)))
10674 (nnmail-split-fancy (or nnimap-split-fancy
10675 nnmail-split-fancy)))
10676 (nnmail-article-group 'identity trace))
10677 (nnmail-article-group 'identity trace))))
10678 (unless silent
10679 (if groups
10680 (message "This message would go to %s"
10681 (mapconcat 'car groups ", "))
10682 (message "This message would go to no groups"))
10683 groups)))))
10684
10685 (defun gnus-summary-respool-trace ()
10686 "Trace where the respool algorithm would put this article.
10687 Display a buffer showing all fancy splitting patterns which matched."
10688 (interactive)
10689 (gnus-summary-respool-query nil t))
10690
10691 ;; Summary marking commands.
10692
10693 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
10694 "Mark articles which has the same subject as read, and then select the next.
10695 If UNMARK is positive, remove any kind of mark.
10696 If UNMARK is negative, tick articles."
10697 (interactive "P")
10698 (when unmark
10699 (setq unmark (prefix-numeric-value unmark)))
10700 (let ((count
10701 (gnus-summary-mark-same-subject
10702 (gnus-summary-article-subject) unmark)))
10703 ;; Select next unread article. If auto-select-same mode, should
10704 ;; select the first unread article.
10705 (gnus-summary-next-article t (and gnus-auto-select-same
10706 (gnus-summary-article-subject)))
10707 (gnus-message 7 "%d article%s marked as %s"
10708 count (if (= count 1) " is" "s are")
10709 (if unmark "unread" "read"))))
10710
10711 (defun gnus-summary-kill-same-subject (&optional unmark)
10712 "Mark articles which has the same subject as read.
10713 If UNMARK is positive, remove any kind of mark.
10714 If UNMARK is negative, tick articles."
10715 (interactive "P")
10716 (when unmark
10717 (setq unmark (prefix-numeric-value unmark)))
10718 (let ((count
10719 (gnus-summary-mark-same-subject
10720 (gnus-summary-article-subject) unmark)))
10721 ;; If marked as read, go to next unread subject.
10722 (when (null unmark)
10723 ;; Go to next unread subject.
10724 (gnus-summary-next-subject 1 t))
10725 (gnus-message 7 "%d articles are marked as %s"
10726 count (if unmark "unread" "read"))))
10727
10728 (defun gnus-summary-mark-same-subject (subject &optional unmark)
10729 "Mark articles with same SUBJECT as read, and return marked number.
10730 If optional argument UNMARK is positive, remove any kinds of marks.
10731 If optional argument UNMARK is negative, mark articles as unread instead."
10732 (let ((count 1))
10733 (save-excursion
10734 (cond
10735 ((null unmark) ; Mark as read.
10736 (while (and
10737 (progn
10738 (gnus-summary-mark-article-as-read gnus-killed-mark)
10739 (gnus-summary-show-thread) t)
10740 (gnus-summary-find-subject subject))
10741 (setq count (1+ count))))
10742 ((> unmark 0) ; Tick.
10743 (while (and
10744 (progn
10745 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
10746 (gnus-summary-show-thread) t)
10747 (gnus-summary-find-subject subject))
10748 (setq count (1+ count))))
10749 (t ; Mark as unread.
10750 (while (and
10751 (progn
10752 (gnus-summary-mark-article-as-unread gnus-unread-mark)
10753 (gnus-summary-show-thread) t)
10754 (gnus-summary-find-subject subject))
10755 (setq count (1+ count)))))
10756 (gnus-set-mode-line 'summary)
10757 ;; Return the number of marked articles.
10758 count)))
10759
10760 (defun gnus-summary-mark-as-processable (n &optional unmark)
10761 "Set the process mark on the next N articles.
10762 If N is negative, mark backward instead. If UNMARK is non-nil, remove
10763 the process mark instead. The difference between N and the actual
10764 number of articles marked is returned."
10765 (interactive "P")
10766 (if (and (null n) (and transient-mark-mode mark-active))
10767 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
10768 (setq n (prefix-numeric-value n))
10769 (let ((backward (< n 0))
10770 (n (abs n)))
10771 (while (and
10772 (> n 0)
10773 (if unmark
10774 (gnus-summary-remove-process-mark
10775 (gnus-summary-article-number))
10776 (gnus-summary-set-process-mark (gnus-summary-article-number)))
10777 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
10778 (setq n (1- n)))
10779 (when (/= 0 n)
10780 (gnus-message 7 "No more articles"))
10781 (gnus-summary-recenter)
10782 (gnus-summary-position-point)
10783 n)))
10784
10785 (defun gnus-summary-unmark-as-processable (n)
10786 "Remove the process mark from the next N articles.
10787 If N is negative, unmark backward instead. The difference between N and
10788 the actual number of articles unmarked is returned."
10789 (interactive "P")
10790 (gnus-summary-mark-as-processable n t))
10791
10792 (defun gnus-summary-unmark-all-processable ()
10793 "Remove the process mark from all articles."
10794 (interactive)
10795 (save-excursion
10796 (while gnus-newsgroup-processable
10797 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
10798 (gnus-summary-position-point))
10799
10800 (defun gnus-summary-add-mark (article type)
10801 "Mark ARTICLE with a mark of TYPE."
10802 (let ((vtype (car (assq type gnus-article-mark-lists)))
10803 var)
10804 (if (not vtype)
10805 (error "No such mark type: %s" type)
10806 (setq var (intern (format "gnus-newsgroup-%s" type)))
10807 (set var (cons article (symbol-value var)))
10808 (if (memq type '(processable cached replied forwarded recent saved))
10809 (gnus-summary-update-secondary-mark article)
10810 ;;; !!! This is bogus. We should find out what primary
10811 ;;; !!! mark we want to set.
10812 (gnus-summary-update-mark gnus-del-mark 'unread)))))
10813
10814 (defun gnus-summary-mark-as-expirable (n)
10815 "Mark N articles forward as expirable.
10816 If N is negative, mark backward instead. The difference between N and
10817 the actual number of articles marked is returned."
10818 (interactive "p")
10819 (gnus-summary-mark-forward n gnus-expirable-mark))
10820
10821 (defun gnus-summary-mark-as-spam (n)
10822 "Mark N articles forward as spam.
10823 If N is negative, mark backward instead. The difference between N and
10824 the actual number of articles marked is returned."
10825 (interactive "p")
10826 (gnus-summary-mark-forward n gnus-spam-mark))
10827
10828 (defun gnus-summary-mark-article-as-replied (article)
10829 "Mark ARTICLE as replied to and update the summary line.
10830 ARTICLE can also be a list of articles."
10831 (interactive (list (gnus-summary-article-number)))
10832 (let ((articles (if (listp article) article (list article))))
10833 (dolist (article articles)
10834 (unless (numberp article)
10835 (error "%s is not a number" article))
10836 (push article gnus-newsgroup-replied)
10837 (let ((inhibit-read-only t))
10838 (when (gnus-summary-goto-subject article nil t)
10839 (gnus-summary-update-secondary-mark article))))))
10840
10841 (defun gnus-summary-mark-article-as-forwarded (article)
10842 "Mark ARTICLE as forwarded and update the summary line.
10843 ARTICLE can also be a list of articles."
10844 (let ((articles (if (listp article) article (list article))))
10845 (dolist (article articles)
10846 (push article gnus-newsgroup-forwarded)
10847 (let ((inhibit-read-only t))
10848 (when (gnus-summary-goto-subject article nil t)
10849 (gnus-summary-update-secondary-mark article))))))
10850
10851 (defun gnus-summary-set-bookmark (article)
10852 "Set a bookmark in current article."
10853 (interactive (list (gnus-summary-article-number)))
10854 (when (or (not (get-buffer gnus-article-buffer))
10855 (not gnus-current-article)
10856 (not gnus-article-current)
10857 (not (equal gnus-newsgroup-name (car gnus-article-current))))
10858 (error "No current article selected"))
10859 ;; Remove old bookmark, if one exists.
10860 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10861 ;; Set the new bookmark, which is on the form
10862 ;; (article-number . line-number-in-body).
10863 (push
10864 (cons article
10865 (with-current-buffer gnus-article-buffer
10866 (count-lines
10867 (min (point)
10868 (save-excursion
10869 (article-goto-body)
10870 (point)))
10871 (point))))
10872 gnus-newsgroup-bookmarks)
10873 (gnus-message 6 "A bookmark has been added to the current article."))
10874
10875 (defun gnus-summary-remove-bookmark (article)
10876 "Remove the bookmark from the current article."
10877 (interactive (list (gnus-summary-article-number)))
10878 ;; Remove old bookmark, if one exists.
10879 (if (not (assq article gnus-newsgroup-bookmarks))
10880 (gnus-message 6 "No bookmark in current article.")
10881 (gnus-alist-pull article gnus-newsgroup-bookmarks)
10882 (gnus-message 6 "Removed bookmark.")))
10883
10884 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10885 (defun gnus-summary-mark-as-dormant (n)
10886 "Mark N articles forward as dormant.
10887 If N is negative, mark backward instead. The difference between N and
10888 the actual number of articles marked is returned."
10889 (interactive "p")
10890 (gnus-summary-mark-forward n gnus-dormant-mark))
10891
10892 (defun gnus-summary-set-process-mark (article)
10893 "Set the process mark on ARTICLE and update the summary line."
10894 (setq gnus-newsgroup-processable
10895 (cons article
10896 (delq article gnus-newsgroup-processable)))
10897 (when (gnus-summary-goto-subject article)
10898 (gnus-summary-show-thread)
10899 (gnus-summary-goto-subject article)
10900 (gnus-summary-update-secondary-mark article)))
10901
10902 (defun gnus-summary-remove-process-mark (&rest articles)
10903 "Remove the process mark from ARTICLES and update the summary line."
10904 (dolist (article articles)
10905 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
10906 (when (gnus-summary-goto-subject article)
10907 (gnus-summary-show-thread)
10908 (gnus-summary-goto-subject article)
10909 (gnus-summary-update-secondary-mark article)))
10910 t)
10911
10912 (defun gnus-summary-set-saved-mark (article)
10913 "Set the process mark on ARTICLE and update the summary line."
10914 (push article gnus-newsgroup-saved)
10915 (when (gnus-summary-goto-subject article)
10916 (gnus-summary-update-secondary-mark article)))
10917
10918 (defun gnus-summary-mark-forward (n &optional mark no-expire)
10919 "Mark N articles as read forwards.
10920 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
10921 The difference between N and the actual number of articles marked is
10922 returned.
10923 If NO-EXPIRE, auto-expiry will be inhibited."
10924 (interactive "p")
10925 (gnus-summary-show-thread)
10926 (let ((backward (< n 0))
10927 (gnus-summary-goto-unread
10928 (and gnus-summary-goto-unread
10929 (not (eq gnus-summary-goto-unread 'never))
10930 (not (memq mark (list gnus-unread-mark gnus-spam-mark
10931 gnus-ticked-mark gnus-dormant-mark)))))
10932 (n (abs n))
10933 (mark (or mark gnus-del-mark)))
10934 (while (and (> n 0)
10935 (gnus-summary-mark-article nil mark no-expire)
10936 (zerop (gnus-summary-next-subject
10937 (if backward -1 1)
10938 (and gnus-summary-goto-unread
10939 (not (eq gnus-summary-goto-unread 'never)))
10940 t)))
10941 (setq n (1- n)))
10942 (when (/= 0 n)
10943 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
10944 (gnus-summary-recenter)
10945 (gnus-summary-position-point)
10946 (gnus-set-mode-line 'summary)
10947 n))
10948
10949 (defun gnus-summary-mark-article-as-read (mark)
10950 "Mark the current article quickly as read with MARK."
10951 (let ((article (gnus-summary-article-number)))
10952 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10953 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10954 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10955 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10956 (push (cons article mark) gnus-newsgroup-reads)
10957 ;; Possibly remove from cache, if that is used.
10958 (when gnus-use-cache
10959 (gnus-cache-enter-remove-article article))
10960 ;; Allow the backend to change the mark.
10961 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10962 ;; Check for auto-expiry.
10963 (when (and gnus-newsgroup-auto-expire
10964 (memq mark gnus-auto-expirable-marks))
10965 (setq mark gnus-expirable-mark)
10966 ;; Let the backend know about the mark change.
10967 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10968 (push article gnus-newsgroup-expirable))
10969 ;; Set the mark in the buffer.
10970 (gnus-summary-update-mark mark 'unread)
10971 t))
10972
10973 (defun gnus-summary-mark-article-as-unread (mark)
10974 "Mark the current article quickly as unread with MARK."
10975 (let* ((article (gnus-summary-article-number))
10976 (old-mark (gnus-summary-article-mark article)))
10977 ;; Allow the backend to change the mark.
10978 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
10979 (if (eq mark old-mark)
10980 t
10981 (if (<= article 0)
10982 (progn
10983 (gnus-error 1 "Can't mark negative article numbers")
10984 nil)
10985 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10986 (setq gnus-newsgroup-spam-marked
10987 (delq article gnus-newsgroup-spam-marked))
10988 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10989 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
10990 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
10991 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10992 (cond ((= mark gnus-ticked-mark)
10993 (setq gnus-newsgroup-marked
10994 (gnus-add-to-sorted-list gnus-newsgroup-marked
10995 article)))
10996 ((= mark gnus-spam-mark)
10997 (setq gnus-newsgroup-spam-marked
10998 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10999 article)))
11000 ((= mark gnus-dormant-mark)
11001 (setq gnus-newsgroup-dormant
11002 (gnus-add-to-sorted-list gnus-newsgroup-dormant
11003 article)))
11004 (t
11005 (setq gnus-newsgroup-unreads
11006 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11007 article))))
11008 (gnus-alist-pull article gnus-newsgroup-reads)
11009
11010 ;; See whether the article is to be put in the cache.
11011 (and gnus-use-cache
11012 (vectorp (gnus-summary-article-header article))
11013 (save-excursion
11014 (gnus-cache-possibly-enter-article
11015 gnus-newsgroup-name article
11016 (= mark gnus-ticked-mark)
11017 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11018
11019 ;; Fix the mark.
11020 (gnus-summary-update-mark mark 'unread)
11021 t))))
11022
11023 (defun gnus-summary-mark-article (&optional article mark no-expire)
11024 "Mark ARTICLE with MARK. MARK can be any character.
11025 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
11026 `??' (dormant) and `?E' (expirable).
11027 If MARK is nil, then the default character `?r' is used.
11028 If ARTICLE is nil, then the article on the current line will be
11029 marked.
11030 If NO-EXPIRE, auto-expiry will be inhibited."
11031 ;; The mark might be a string.
11032 (when (stringp mark)
11033 (setq mark (aref mark 0)))
11034 ;; If no mark is given, then we check auto-expiring.
11035 (when (null mark)
11036 (setq mark gnus-del-mark))
11037 (when (and (not no-expire)
11038 gnus-newsgroup-auto-expire
11039 (memq mark gnus-auto-expirable-marks))
11040 (setq mark gnus-expirable-mark))
11041 (let ((article (or article (gnus-summary-article-number)))
11042 (old-mark (gnus-summary-article-mark article)))
11043 ;; Allow the backend to change the mark.
11044 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
11045 (if (eq mark old-mark)
11046 t
11047 (unless article
11048 (error "No article on current line"))
11049 (if (not (if (or (= mark gnus-unread-mark)
11050 (= mark gnus-ticked-mark)
11051 (= mark gnus-spam-mark)
11052 (= mark gnus-dormant-mark))
11053 (gnus-mark-article-as-unread article mark)
11054 (gnus-mark-article-as-read article mark)))
11055 t
11056 ;; See whether the article is to be put in the cache.
11057 (and gnus-use-cache
11058 (not (= mark gnus-canceled-mark))
11059 (vectorp (gnus-summary-article-header article))
11060 (save-excursion
11061 (gnus-cache-possibly-enter-article
11062 gnus-newsgroup-name article
11063 (= mark gnus-ticked-mark)
11064 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
11065
11066 (when (gnus-summary-goto-subject article nil t)
11067 (let ((inhibit-read-only t))
11068 (gnus-summary-show-thread)
11069 ;; Fix the mark.
11070 (gnus-summary-update-mark mark 'unread)
11071 t))))))
11072
11073 (defun gnus-summary-update-secondary-mark (article)
11074 "Update the secondary (read, process, cache) mark."
11075 (gnus-summary-update-mark
11076 (cond ((memq article gnus-newsgroup-processable)
11077 gnus-process-mark)
11078 ((memq article gnus-newsgroup-cached)
11079 gnus-cached-mark)
11080 ((memq article gnus-newsgroup-replied)
11081 gnus-replied-mark)
11082 ((memq article gnus-newsgroup-forwarded)
11083 gnus-forwarded-mark)
11084 ((memq article gnus-newsgroup-saved)
11085 gnus-saved-mark)
11086 ((memq article gnus-newsgroup-unseen)
11087 gnus-unseen-mark)
11088 (t gnus-no-mark))
11089 'replied)
11090 (when (gnus-visual-p 'summary-highlight 'highlight)
11091 (gnus-summary-highlight-line)
11092 (gnus-run-hooks 'gnus-summary-update-hook))
11093 t)
11094
11095 (defun gnus-summary-update-download-mark (article)
11096 "Update the download mark."
11097 (gnus-summary-update-mark
11098 (cond ((memq article gnus-newsgroup-undownloaded)
11099 gnus-undownloaded-mark)
11100 (gnus-newsgroup-agentized
11101 gnus-downloaded-mark)
11102 (t
11103 gnus-no-mark))
11104 'download)
11105 (gnus-summary-update-line t)
11106 t)
11107
11108 (defun gnus-summary-update-mark (mark type)
11109 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
11110 (inhibit-read-only t))
11111 (re-search-backward "[\n\r]" (point-at-bol) 'move-to-limit)
11112 (when forward
11113 (when (looking-at "\r")
11114 (incf forward))
11115 (when (<= (+ forward (point)) (point-max))
11116 ;; Go to the right position on the line.
11117 (goto-char (+ forward (point)))
11118 ;; Replace the old mark with the new mark.
11119 (let ((to-insert
11120 (subst-char-in-string
11121 (char-after) mark
11122 (buffer-substring (point) (1+ (point))))))
11123 (delete-region (point) (1+ (point)))
11124 (insert to-insert))
11125 ;; Optionally update the marks by some user rule.
11126 (when (eq type 'unread)
11127 (gnus-data-set-mark
11128 (gnus-data-find (gnus-summary-article-number)) mark)
11129 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
11130
11131 (defun gnus-mark-article-as-read (article &optional mark)
11132 "Enter ARTICLE in the pertinent lists and remove it from others."
11133 ;; Make the article expirable.
11134 (let ((mark (or mark gnus-del-mark)))
11135 (setq gnus-newsgroup-expirable
11136 (if (= mark gnus-expirable-mark)
11137 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
11138 (delq article gnus-newsgroup-expirable)))
11139 ;; Remove from unread and marked lists.
11140 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11141 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
11142 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
11143 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
11144 (push (cons article mark) gnus-newsgroup-reads)
11145 ;; Possibly remove from cache, if that is used.
11146 (when gnus-use-cache
11147 (gnus-cache-enter-remove-article article))
11148 t))
11149
11150 (defun gnus-mark-article-as-unread (article &optional mark)
11151 "Enter ARTICLE in the pertinent lists and remove it from others."
11152 (let ((mark (or mark gnus-ticked-mark)))
11153 (if (<= article 0)
11154 (progn
11155 (gnus-error 1 "Can't mark negative article numbers")
11156 nil)
11157 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
11158 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
11159 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
11160 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
11161 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
11162
11163 ;; Unsuppress duplicates?
11164 (when gnus-suppress-duplicates
11165 (gnus-dup-unsuppress-article article))
11166
11167 (cond ((= mark gnus-ticked-mark)
11168 (setq gnus-newsgroup-marked
11169 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
11170 ((= mark gnus-spam-mark)
11171 (setq gnus-newsgroup-spam-marked
11172 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
11173 article)))
11174 ((= mark gnus-dormant-mark)
11175 (setq gnus-newsgroup-dormant
11176 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
11177 (t
11178 (setq gnus-newsgroup-unreads
11179 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
11180 (gnus-alist-pull article gnus-newsgroup-reads)
11181 t)))
11182
11183 (defun gnus-summary-tick-article-forward (n)
11184 "Tick N articles forwards.
11185 If N is negative, tick backwards instead.
11186 The difference between N and the number of articles ticked is returned."
11187 (interactive "p")
11188 (gnus-summary-mark-forward n gnus-ticked-mark))
11189
11190 (defun gnus-summary-tick-article-backward (n)
11191 "Tick N articles backwards.
11192 The difference between N and the number of articles ticked is returned."
11193 (interactive "p")
11194 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
11195
11196 (defun gnus-summary-tick-article (&optional article clear-mark)
11197 "Mark current article as unread.
11198 Optional 1st argument ARTICLE specifies article number to be marked as unread.
11199 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
11200 (interactive)
11201 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
11202 gnus-ticked-mark)))
11203
11204 (defun gnus-summary-mark-as-read-forward (n)
11205 "Mark N articles as read forwards.
11206 If N is negative, mark backwards instead.
11207 The difference between N and the actual number of articles marked is
11208 returned."
11209 (interactive "p")
11210 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
11211
11212 (defun gnus-summary-mark-as-read-backward (n)
11213 "Mark the N articles as read backwards.
11214 The difference between N and the actual number of articles marked is
11215 returned."
11216 (interactive "p")
11217 (gnus-summary-mark-forward
11218 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
11219
11220 (defun gnus-summary-mark-as-read (&optional article mark)
11221 "Mark current article as read.
11222 ARTICLE specifies the article to be marked as read.
11223 MARK specifies a string to be inserted at the beginning of the line."
11224 (gnus-summary-mark-article article mark))
11225
11226 (defun gnus-summary-clear-mark-forward (n)
11227 "Clear marks from N articles forward.
11228 If N is negative, clear backward instead.
11229 The difference between N and the number of marks cleared is returned."
11230 (interactive "p")
11231 (gnus-summary-mark-forward n gnus-unread-mark))
11232
11233 (defun gnus-summary-clear-mark-backward (n)
11234 "Clear marks from N articles backward.
11235 The difference between N and the number of marks cleared is returned."
11236 (interactive "p")
11237 (gnus-summary-mark-forward (- n) gnus-unread-mark))
11238
11239 (defun gnus-summary-mark-unread-as-read ()
11240 "Intended to be used by `gnus-mark-article-hook'."
11241 (when (memq gnus-current-article gnus-newsgroup-unreads)
11242 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
11243
11244 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
11245 "Intended to be used by `gnus-mark-article-hook'."
11246 (let ((mark (gnus-summary-article-mark)))
11247 (when (or (gnus-unread-mark-p mark)
11248 (gnus-read-mark-p mark))
11249 (gnus-summary-mark-article gnus-current-article
11250 (or new-mark gnus-read-mark)))))
11251
11252 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
11253 "Intended to be used by `gnus-mark-article-hook'."
11254 (let ((mark (gnus-summary-article-mark)))
11255 (when (or (gnus-unread-mark-p mark)
11256 (gnus-read-mark-p mark))
11257 (gnus-summary-mark-article (gnus-summary-article-number)
11258 (or new-mark gnus-read-mark)))))
11259
11260 (defun gnus-summary-mark-unread-as-ticked ()
11261 "Intended to be used by `gnus-mark-article-hook'."
11262 (when (memq gnus-current-article gnus-newsgroup-unreads)
11263 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
11264
11265 (defun gnus-summary-mark-region-as-read (point mark all)
11266 "Mark all unread articles between point and mark as read.
11267 If given a prefix, mark all articles between point and mark as read,
11268 even ticked and dormant ones."
11269 (interactive "r\nP")
11270 (save-excursion
11271 (let (article)
11272 (goto-char point)
11273 (beginning-of-line)
11274 (while (and
11275 (< (point) mark)
11276 (progn
11277 (when (or all
11278 (memq (setq article (gnus-summary-article-number))
11279 gnus-newsgroup-unreads))
11280 (gnus-summary-mark-article article gnus-del-mark))
11281 t)
11282 (gnus-summary-find-next))))))
11283
11284 (defun gnus-summary-mark-below (score mark)
11285 "Mark articles with score less than SCORE with MARK."
11286 (interactive "P\ncMark: ")
11287 (setq score (if score
11288 (prefix-numeric-value score)
11289 (or gnus-summary-default-score 0)))
11290 (with-current-buffer gnus-summary-buffer
11291 (goto-char (point-min))
11292 (while
11293 (progn
11294 (and (< (gnus-summary-article-score) score)
11295 (gnus-summary-mark-article nil mark))
11296 (gnus-summary-find-next)))))
11297
11298 (defun gnus-summary-kill-below (&optional score)
11299 "Mark articles with score below SCORE as read."
11300 (interactive "P")
11301 (gnus-summary-mark-below score gnus-killed-mark))
11302
11303 (defun gnus-summary-clear-above (&optional score)
11304 "Clear all marks from articles with score above SCORE."
11305 (interactive "P")
11306 (gnus-summary-mark-above score gnus-unread-mark))
11307
11308 (defun gnus-summary-tick-above (&optional score)
11309 "Tick all articles with score above SCORE."
11310 (interactive "P")
11311 (gnus-summary-mark-above score gnus-ticked-mark))
11312
11313 (defun gnus-summary-mark-above (score mark)
11314 "Mark articles with score over SCORE with MARK."
11315 (interactive "P\ncMark: ")
11316 (setq score (if score
11317 (prefix-numeric-value score)
11318 (or gnus-summary-default-score 0)))
11319 (with-current-buffer gnus-summary-buffer
11320 (goto-char (point-min))
11321 (while (and (progn
11322 (when (> (gnus-summary-article-score) score)
11323 (gnus-summary-mark-article nil mark))
11324 t)
11325 (gnus-summary-find-next)))))
11326
11327 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
11328 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
11329 (defun gnus-summary-limit-include-expunged (&optional no-error)
11330 "Display all the hidden articles that were expunged for low scores."
11331 (interactive)
11332 (let ((inhibit-read-only t))
11333 (let ((scored gnus-newsgroup-scored)
11334 headers h)
11335 (while scored
11336 (unless (gnus-summary-article-header (caar scored))
11337 (and (setq h (gnus-number-to-header (caar scored)))
11338 (< (cdar scored) gnus-summary-expunge-below)
11339 (push h headers)))
11340 (setq scored (cdr scored)))
11341 (if (not headers)
11342 (when (not no-error)
11343 (error "No expunged articles hidden"))
11344 (goto-char (point-min))
11345 (push gnus-newsgroup-limit gnus-newsgroup-limits)
11346 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
11347 (dolist (x headers)
11348 (push (mail-header-number x) gnus-newsgroup-limit))
11349 (gnus-summary-prepare-unthreaded (nreverse headers))
11350 (goto-char (point-min))
11351 (gnus-summary-position-point)
11352 t))))
11353
11354 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
11355 "Mark all unread articles in this newsgroup as read.
11356 If prefix argument ALL is non-nil, ticked and dormant articles will
11357 also be marked as read.
11358 If QUIETLY is non-nil, no questions will be asked.
11359
11360 If TO-HERE is non-nil, it should be a point in the buffer. All
11361 articles before (after, if REVERSE is set) this point will be marked
11362 as read.
11363
11364 Note that this function will only catch up the unread article
11365 in the current summary buffer limitation.
11366
11367 The number of articles marked as read is returned."
11368 (interactive "P")
11369 (prog1
11370 (save-excursion
11371 (when (or quietly
11372 (not gnus-interactive-catchup) ;Without confirmation?
11373 gnus-expert-user
11374 (gnus-y-or-n-p
11375 (if all
11376 "Mark absolutely all articles as read? "
11377 "Mark all unread articles as read? ")))
11378 (if (and not-mark
11379 (not gnus-newsgroup-adaptive)
11380 (not gnus-newsgroup-auto-expire)
11381 (not gnus-suppress-duplicates)
11382 (or (not gnus-use-cache)
11383 (eq gnus-use-cache 'passive)))
11384 (progn
11385 (when all
11386 (setq gnus-newsgroup-marked nil
11387 gnus-newsgroup-spam-marked nil
11388 gnus-newsgroup-dormant nil))
11389 (setq gnus-newsgroup-unreads
11390 (gnus-sorted-nunion
11391 (gnus-sorted-intersection gnus-newsgroup-unreads
11392 gnus-newsgroup-downloadable)
11393 (gnus-sorted-difference gnus-newsgroup-unfetched
11394 gnus-newsgroup-cached))))
11395 ;; We actually mark all articles as canceled, which we
11396 ;; have to do when using auto-expiry or adaptive scoring.
11397 (gnus-summary-show-all-threads)
11398 (if (and to-here reverse)
11399 (progn
11400 (goto-char to-here)
11401 (gnus-summary-mark-current-read-and-unread-as-read
11402 gnus-catchup-mark)
11403 (while (gnus-summary-find-next (not all))
11404 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
11405 (when (gnus-summary-first-subject (not all))
11406 (while (and
11407 (if to-here (< (point) to-here) t)
11408 (gnus-summary-mark-article-as-read gnus-catchup-mark)
11409 (gnus-summary-find-next (not all))))))
11410 (gnus-set-mode-line 'summary))
11411 t))
11412 (gnus-summary-position-point)))
11413
11414 (defun gnus-summary-catchup-to-here (&optional all)
11415 "Mark all unticked articles before the current one as read.
11416 If ALL is non-nil, also mark ticked and dormant articles as read."
11417 (interactive "P")
11418 (save-excursion
11419 (gnus-save-hidden-threads
11420 (let ((beg (point)))
11421 ;; We check that there are unread articles.
11422 (when (or all (gnus-summary-find-prev))
11423 (gnus-summary-catchup all t beg)))))
11424 (gnus-summary-position-point))
11425
11426 (defun gnus-summary-catchup-from-here (&optional all)
11427 "Mark all unticked articles after (and including) the current one as read.
11428 If ALL is non-nil, also mark ticked and dormant articles as read."
11429 (interactive "P")
11430 (save-excursion
11431 (gnus-save-hidden-threads
11432 (let ((beg (point)))
11433 ;; We check that there are unread articles.
11434 (when (or all (gnus-summary-find-next))
11435 (gnus-summary-catchup all t beg nil t)))))
11436 (gnus-summary-position-point))
11437
11438 (defun gnus-summary-catchup-all (&optional quietly)
11439 "Mark all articles in this newsgroup as read.
11440 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
11441 instead, which marks only unread articles as read."
11442 (interactive "P")
11443 (gnus-summary-catchup t quietly))
11444
11445 (defun gnus-summary-catchup-and-exit (&optional all quietly)
11446 "Mark all unread articles in this group as read, then exit.
11447 If prefix argument ALL is non-nil, all articles are marked as read.
11448 If QUIETLY is non-nil, no questions will be asked."
11449 (interactive "P")
11450 (when (gnus-summary-catchup all quietly nil 'fast)
11451 ;; Select next newsgroup or exit.
11452 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
11453 (eq gnus-auto-select-next 'quietly))
11454 (gnus-summary-next-group nil)
11455 (gnus-summary-exit))))
11456
11457 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
11458 "Mark all articles in this newsgroup as read, and then exit.
11459 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
11460 instead, which marks only unread articles as read."
11461 (interactive "P")
11462 (gnus-summary-catchup-and-exit t quietly))
11463
11464 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
11465 "Mark all articles in this group as read and select the next group.
11466 If given a prefix, mark all articles, unread as well as ticked, as
11467 read."
11468 (interactive "P")
11469 (save-excursion
11470 (gnus-summary-catchup all))
11471 (gnus-summary-next-group))
11472
11473 (defun gnus-summary-catchup-and-goto-prev-group (&optional all)
11474 "Mark all articles in this group as read and select the previous group.
11475 If given a prefix, mark all articles, unread as well as ticked, as
11476 read."
11477 (interactive "P")
11478 (save-excursion
11479 (gnus-summary-catchup all))
11480 (gnus-summary-next-group nil nil t))
11481
11482 ;;;
11483 ;;; with article
11484 ;;;
11485
11486 (defmacro gnus-with-article (article &rest forms)
11487 "Select ARTICLE and perform FORMS in the original article buffer.
11488 Then replace the article with the result."
11489 `(progn
11490 ;; We don't want the article to be marked as read.
11491 (let (gnus-mark-article-hook)
11492 (gnus-summary-select-article t t nil ,article))
11493 (set-buffer gnus-original-article-buffer)
11494 ,@forms
11495 (if (not (gnus-check-backend-function
11496 'request-replace-article (car gnus-article-current)))
11497 (gnus-message 5 "Read-only group; not replacing")
11498 (unless (gnus-request-replace-article
11499 ,article (car gnus-article-current)
11500 (current-buffer) t)
11501 (error "Couldn't replace article")))
11502 ;; The cache and backlog have to be flushed somewhat.
11503 (when gnus-keep-backlog
11504 (gnus-backlog-remove-article
11505 (car gnus-article-current) (cdr gnus-article-current)))
11506 (when gnus-use-cache
11507 (gnus-cache-update-article
11508 (car gnus-article-current) (cdr gnus-article-current)))))
11509
11510 (put 'gnus-with-article 'lisp-indent-function 1)
11511 (put 'gnus-with-article 'edebug-form-spec '(form body))
11512
11513 ;; Thread-based commands.
11514
11515 (defun gnus-summary-articles-in-thread (&optional article)
11516 "Return a list of all articles in the current thread.
11517 If ARTICLE is non-nil, return all articles in the thread that starts
11518 with that article."
11519 (let* ((article (or article (gnus-summary-article-number)))
11520 (data (gnus-data-find-list article))
11521 (top-level (gnus-data-level (car data)))
11522 (top-subject
11523 (cond ((null gnus-thread-operation-ignore-subject)
11524 (gnus-simplify-subject-re
11525 (mail-header-subject (gnus-data-header (car data)))))
11526 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
11527 (gnus-simplify-subject-fuzzy
11528 (mail-header-subject (gnus-data-header (car data)))))
11529 (t nil)))
11530 (end-point (save-excursion
11531 (goto-char (gnus-data-pos (car data)))
11532 (if (gnus-summary-go-to-next-thread)
11533 (point) (point-max))))
11534 articles)
11535 (while (and data
11536 (< (gnus-data-pos (car data)) end-point))
11537 (when (or (not top-subject)
11538 (string= top-subject
11539 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
11540 (gnus-simplify-subject-fuzzy
11541 (mail-header-subject
11542 (gnus-data-header (car data))))
11543 (gnus-simplify-subject-re
11544 (mail-header-subject
11545 (gnus-data-header (car data)))))))
11546 (push (gnus-data-number (car data)) articles))
11547 (unless (and (setq data (cdr data))
11548 (> (gnus-data-level (car data)) top-level))
11549 (setq data nil)))
11550 ;; Return the list of articles.
11551 (nreverse articles)))
11552
11553 (defun gnus-summary-rethread-current ()
11554 "Rethread the thread the current article is part of."
11555 (interactive)
11556 (let* ((gnus-show-threads t)
11557 (article (gnus-summary-article-number))
11558 (id (mail-header-id (gnus-summary-article-header)))
11559 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
11560 (unless id
11561 (error "No article on the current line"))
11562 (gnus-rebuild-thread id)
11563 (gnus-summary-goto-subject article)))
11564
11565 (defun gnus-summary-reparent-thread ()
11566 "Make the current article child of the marked (or previous) article.
11567
11568 Note that the re-threading will only work if `gnus-thread-ignore-subject'
11569 is non-nil or the Subject: of both articles are the same."
11570 (interactive)
11571 (unless (not (gnus-group-read-only-p))
11572 (error "The current newsgroup does not support article editing"))
11573 (unless (<= (length gnus-newsgroup-processable) 1)
11574 (error "No more than one article may be marked"))
11575 (let ((child (gnus-summary-article-number))
11576 ;; First grab the marked article, otherwise one line up.
11577 (parent (if (not (null gnus-newsgroup-processable))
11578 (car gnus-newsgroup-processable)
11579 (save-excursion
11580 (if (eq (forward-line -1) 0)
11581 (gnus-summary-article-number)
11582 (error "Beginning of summary buffer"))))))
11583 (gnus-summary-reparent-children parent (list child))))
11584
11585 (defun gnus-summary-reparent-children (parent children)
11586 "Make PARENT the parent of CHILDREN.
11587 When called interactively, PARENT is the current article and CHILDREN
11588 are the process-marked articles."
11589 (interactive
11590 (list (gnus-summary-article-number)
11591 (gnus-summary-work-articles nil)))
11592 (dolist (child children)
11593 (save-window-excursion
11594 (let ((gnus-article-buffer " *reparent*"))
11595 (unless (not (eq parent child))
11596 (error "An article may not be self-referential"))
11597 (let ((message-id (mail-header-id
11598 (gnus-summary-article-header parent))))
11599 (unless (and message-id (not (equal message-id "")))
11600 (error "No message-id in desired parent"))
11601 (gnus-with-article child
11602 (save-restriction
11603 (goto-char (point-min))
11604 (message-narrow-to-head)
11605 (if (re-search-forward "^References: " nil t)
11606 (progn
11607 (re-search-forward "^[^ \t]" nil t)
11608 (forward-line -1)
11609 (end-of-line)
11610 (insert " " message-id))
11611 (insert "References: " message-id "\n"))))
11612 (set-buffer gnus-summary-buffer)
11613 (gnus-summary-unmark-all-processable)
11614 (gnus-summary-update-article child)
11615 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
11616 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
11617 (gnus-summary-rethread-current)
11618 (gnus-message 3 "Article %d is now the child of article %d"
11619 child parent))))))
11620
11621 (defun gnus-summary-toggle-threads (&optional arg)
11622 "Toggle showing conversation threads.
11623 If ARG is positive number, turn showing conversation threads on."
11624 (interactive "P")
11625 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
11626 (setq gnus-show-threads
11627 (if (null arg) (not gnus-show-threads)
11628 (> (prefix-numeric-value arg) 0)))
11629 (gnus-summary-prepare)
11630 (gnus-summary-goto-subject current)
11631 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
11632 (gnus-summary-position-point)))
11633
11634 (defun gnus-summary-show-all-threads ()
11635 "Show all threads."
11636 (interactive)
11637 (remove-overlays (point-min) (point-max) 'invisible 'gnus-sum)
11638 (gnus-summary-position-point))
11639
11640 (defsubst gnus-summary--inv (p)
11641 (and (eq (get-char-property p 'invisible) 'gnus-sum) p))
11642
11643 (defun gnus-summary-show-thread ()
11644 "Show thread subtrees.
11645 Returns nil if no thread was there to be shown."
11646 (interactive)
11647 (let* ((orig (point))
11648 (end (point-at-eol))
11649 (end (or (gnus-summary--inv end) (gnus-summary--inv (1- end))))
11650 ;; Leave point at bol
11651 (beg (progn (beginning-of-line) (if (bobp) (point) (1- (point)))))
11652 (eoi (and end (next-single-char-property-change end 'invisible))))
11653 (when eoi
11654 (remove-overlays beg eoi 'invisible 'gnus-sum)
11655 (goto-char orig)
11656 (gnus-summary-position-point)
11657 eoi)))
11658
11659 (defun gnus-summary-maybe-hide-threads ()
11660 "If requested, hide the threads that should be hidden."
11661 (when (and gnus-show-threads
11662 gnus-thread-hide-subtree)
11663 (gnus-summary-hide-all-threads
11664 (if (or (consp gnus-thread-hide-subtree)
11665 (functionp gnus-thread-hide-subtree))
11666 (gnus-make-predicate gnus-thread-hide-subtree)
11667 nil))))
11668
11669 ;;; Hiding predicates.
11670
11671 (defun gnus-article-unread-p (header)
11672 (memq (mail-header-number header) gnus-newsgroup-unreads))
11673
11674 (defun gnus-article-unseen-p (header)
11675 (memq (mail-header-number header) gnus-newsgroup-unseen))
11676
11677 (defun gnus-map-articles (predicate articles)
11678 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
11679 (apply 'gnus-or (mapcar predicate
11680 (mapcar (lambda (number)
11681 (gnus-summary-article-header number))
11682 articles))))
11683
11684 (defun gnus-summary-hide-all-threads (&optional predicate)
11685 "Hide all thread subtrees.
11686 If PREDICATE is supplied, threads that satisfy this predicate
11687 will not be hidden."
11688 (interactive)
11689 (save-excursion
11690 (goto-char (point-min))
11691 (let ((end nil)
11692 (count 0))
11693 (while (not end)
11694 (incf count)
11695 (when (zerop (mod count 1000))
11696 (message "Hiding all threads... %d" count))
11697 (when (or (not predicate)
11698 (gnus-map-articles
11699 predicate (gnus-summary-article-children)))
11700 (gnus-summary-hide-thread))
11701 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
11702 (gnus-summary-position-point))
11703
11704 (defun gnus-summary-hide-thread ()
11705 "Hide thread subtrees.
11706 If PREDICATE is supplied, threads that satisfy this predicate
11707 will not be hidden.
11708 Returns nil if no threads were there to be hidden."
11709 (interactive)
11710 (beginning-of-line)
11711 (let ((start (point))
11712 (starteol (line-end-position))
11713 (article (gnus-summary-article-number)))
11714 ;; Go forward until either the buffer ends or the subthread ends.
11715 (when (and (not (eobp))
11716 (or (zerop (gnus-summary-next-thread 1 t))
11717 (goto-char (point-max))))
11718 (if (and (> (point) start)
11719 ;; FIXME: this should actually search for a non-invisible \n.
11720 (search-backward "\n" start t))
11721 (progn
11722 (when (> (point) starteol)
11723 (remove-overlays starteol (point) 'invisible 'gnus-sum)
11724 (let ((ol (make-overlay starteol (point) nil t nil)))
11725 (overlay-put ol 'invisible 'gnus-sum)
11726 (overlay-put ol 'evaporate t)))
11727 (gnus-summary-goto-subject article)
11728 (when (> start (point))
11729 (message "Hiding the thread moved us backwards, aborting!")
11730 (goto-char (point-max))))
11731 (goto-char start)
11732 nil))))
11733
11734 (defun gnus-summary-go-to-next-thread (&optional previous)
11735 "Go to the same level (or less) next thread.
11736 If PREVIOUS is non-nil, go to previous thread instead.
11737 Return the article number moved to, or nil if moving was impossible."
11738 (let ((level (gnus-summary-thread-level))
11739 (way (if previous -1 1))
11740 (beg (point)))
11741 (forward-line way)
11742 (while (and (not (eobp))
11743 (< level (gnus-summary-thread-level)))
11744 (forward-line way))
11745 (if (eobp)
11746 (progn
11747 (goto-char beg)
11748 nil)
11749 (setq beg (point))
11750 (prog1
11751 (gnus-summary-article-number)
11752 (goto-char beg)))))
11753
11754 (defun gnus-summary-next-thread (n &optional silent)
11755 "Go to the same level next N'th thread.
11756 If N is negative, search backward instead.
11757 Returns the difference between N and the number of skips actually
11758 done.
11759
11760 If SILENT, don't output messages."
11761 (interactive "p")
11762 (let ((backward (< n 0))
11763 (n (abs n)))
11764 (while (and (> n 0)
11765 (gnus-summary-go-to-next-thread backward))
11766 (decf n))
11767 (unless silent
11768 (gnus-summary-position-point))
11769 (when (and (not silent) (/= 0 n))
11770 (gnus-message 7 "No more threads"))
11771 n))
11772
11773 (defun gnus-summary-prev-thread (n)
11774 "Go to the same level previous N'th thread.
11775 Returns the difference between N and the number of skips actually
11776 done."
11777 (interactive "p")
11778 (gnus-summary-next-thread (- n)))
11779
11780 (defun gnus-summary-go-down-thread ()
11781 "Go down one level in the current thread."
11782 (let ((children (gnus-summary-article-children)))
11783 (when children
11784 (gnus-summary-goto-subject (car children)))))
11785
11786 (defun gnus-summary-go-up-thread ()
11787 "Go up one level in the current thread."
11788 (let ((parent (gnus-summary-article-parent)))
11789 (when parent
11790 (gnus-summary-goto-subject parent))))
11791
11792 (defun gnus-summary-down-thread (n)
11793 "Go down thread N steps.
11794 If N is negative, go up instead.
11795 Returns the difference between N and how many steps down that were
11796 taken."
11797 (interactive "p")
11798 (let ((up (< n 0))
11799 (n (abs n)))
11800 (while (and (> n 0)
11801 (if up (gnus-summary-go-up-thread)
11802 (gnus-summary-go-down-thread)))
11803 (setq n (1- n)))
11804 (gnus-summary-position-point)
11805 (when (/= 0 n)
11806 (gnus-message 7 "Can't go further"))
11807 n))
11808
11809 (defun gnus-summary-up-thread (n)
11810 "Go up thread N steps.
11811 If N is negative, go down instead.
11812 Returns the difference between N and how many steps down that were
11813 taken."
11814 (interactive "p")
11815 (gnus-summary-down-thread (- n)))
11816
11817 (defun gnus-summary-top-thread ()
11818 "Go to the top of the thread."
11819 (interactive)
11820 (while (gnus-summary-go-up-thread))
11821 (gnus-summary-article-number))
11822
11823 (defun gnus-summary-expire-thread ()
11824 "Mark articles under current thread as expired."
11825 (interactive)
11826 (gnus-summary-kill-thread 0))
11827
11828 (defun gnus-summary-kill-thread (&optional unmark)
11829 "Mark articles under current thread as read.
11830 If the prefix argument is positive, remove any kinds of marks.
11831 If the prefix argument is zero, mark thread as expired.
11832 If the prefix argument is negative, tick articles instead."
11833 (interactive "P")
11834 (when unmark
11835 (setq unmark (prefix-numeric-value unmark)))
11836 (let ((articles (gnus-summary-articles-in-thread))
11837 (hide (or (null unmark) (= unmark 0))))
11838 (save-excursion
11839 ;; Expand the thread.
11840 (gnus-summary-show-thread)
11841 ;; Mark all the articles.
11842 (while articles
11843 (gnus-summary-goto-subject (car articles))
11844 (cond ((null unmark)
11845 (gnus-summary-mark-article-as-read gnus-killed-mark))
11846 ((> unmark 0)
11847 (gnus-summary-mark-article-as-unread gnus-unread-mark))
11848 ((= unmark 0)
11849 (gnus-summary-mark-article nil gnus-expirable-mark))
11850 (t
11851 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
11852 (setq articles (cdr articles))))
11853 ;; Hide killed subtrees when hide is true.
11854 (and hide
11855 gnus-thread-hide-killed
11856 (gnus-summary-hide-thread))
11857 ;; If hide is t, go to next unread subject.
11858 (when hide
11859 ;; Go to next unread subject.
11860 (gnus-summary-next-subject 1 t)))
11861 (gnus-set-mode-line 'summary))
11862
11863 ;; Summary sorting commands
11864
11865 (defun gnus-summary-sort-by-number (&optional reverse)
11866 "Sort the summary buffer by article number.
11867 Argument REVERSE means reverse order."
11868 (interactive "P")
11869 (gnus-summary-sort 'number reverse))
11870
11871 (defun gnus-summary-sort-by-most-recent-number (&optional reverse)
11872 "Sort the summary buffer by most recent article number.
11873 Argument REVERSE means reverse order."
11874 (interactive "P")
11875 (gnus-summary-sort 'most-recent-number reverse))
11876
11877 (defun gnus-summary-sort-by-random (&optional reverse)
11878 "Randomize the order in the summary buffer.
11879 Argument REVERSE means to randomize in reverse order."
11880 (interactive "P")
11881 (gnus-summary-sort 'random reverse))
11882
11883 (defun gnus-summary-sort-by-author (&optional reverse)
11884 "Sort the summary buffer by author name alphabetically.
11885 If `case-fold-search' is non-nil, case of letters is ignored.
11886 Argument REVERSE means reverse order."
11887 (interactive "P")
11888 (gnus-summary-sort 'author reverse))
11889
11890 (defun gnus-summary-sort-by-recipient (&optional reverse)
11891 "Sort the summary buffer by recipient name alphabetically.
11892 If `case-fold-search' is non-nil, case of letters is ignored.
11893 Argument REVERSE means reverse order."
11894 (interactive "P")
11895 (gnus-summary-sort 'recipient reverse))
11896
11897 (defun gnus-summary-sort-by-subject (&optional reverse)
11898 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
11899 If `case-fold-search' is non-nil, case of letters is ignored.
11900 Argument REVERSE means reverse order."
11901 (interactive "P")
11902 (gnus-summary-sort 'subject reverse))
11903
11904 (defun gnus-summary-sort-by-date (&optional reverse)
11905 "Sort the summary buffer by date.
11906 Argument REVERSE means reverse order."
11907 (interactive "P")
11908 (gnus-summary-sort 'date reverse))
11909
11910 (defun gnus-summary-sort-by-most-recent-date (&optional reverse)
11911 "Sort the summary buffer by most recent date.
11912 Argument REVERSE means reverse order."
11913 (interactive "P")
11914 (gnus-summary-sort 'most-recent-date reverse))
11915
11916 (defun gnus-summary-sort-by-score (&optional reverse)
11917 "Sort the summary buffer by score.
11918 Argument REVERSE means reverse order."
11919 (interactive "P")
11920 (gnus-summary-sort 'score reverse))
11921
11922 (defun gnus-summary-sort-by-lines (&optional reverse)
11923 "Sort the summary buffer by the number of lines.
11924 Argument REVERSE means reverse order."
11925 (interactive "P")
11926 (gnus-summary-sort 'lines reverse))
11927
11928 (defun gnus-summary-sort-by-chars (&optional reverse)
11929 "Sort the summary buffer by article length.
11930 Argument REVERSE means reverse order."
11931 (interactive "P")
11932 (gnus-summary-sort 'chars reverse))
11933
11934 (defun gnus-summary-sort-by-original (&optional reverse)
11935 "Sort the summary buffer using the default sorting method.
11936 Argument REVERSE means reverse order."
11937 (interactive "P")
11938 (let* ((inhibit-read-only t)
11939 (gnus-summary-prepare-hook nil))
11940 ;; We do the sorting by regenerating the threads.
11941 (gnus-summary-prepare)
11942 ;; Hide subthreads if needed.
11943 (gnus-summary-maybe-hide-threads)))
11944
11945 (defun gnus-summary-sort (predicate reverse)
11946 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
11947 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
11948 (article (intern (format "gnus-article-sort-by-%s" predicate)))
11949 (gnus-thread-sort-functions
11950 (if (not reverse)
11951 thread
11952 `(lambda (t1 t2)
11953 (,thread t2 t1))))
11954 (gnus-sort-gathered-threads-function
11955 gnus-thread-sort-functions)
11956 (gnus-article-sort-functions
11957 (if (not reverse)
11958 article
11959 `(lambda (t1 t2)
11960 (,article t2 t1))))
11961 (inhibit-read-only t)
11962 (gnus-summary-prepare-hook nil))
11963 ;; We do the sorting by regenerating the threads.
11964 (gnus-summary-prepare)
11965 ;; Hide subthreads if needed.
11966 (gnus-summary-maybe-hide-threads)))
11967
11968 ;; Summary saving commands.
11969
11970 (defun gnus-summary-save-article (&optional n not-saved)
11971 "Save the current article using the default saver function.
11972 If N is a positive number, save the N next articles.
11973 If N is a negative number, save the N previous articles.
11974 If N is nil and any articles have been marked with the process mark,
11975 save those articles instead.
11976 The variable `gnus-default-article-saver' specifies the saver function.
11977
11978 If the optional second argument NOT-SAVED is non-nil, articles saved
11979 will not be marked as saved."
11980 (interactive "P")
11981 (require 'gnus-art)
11982 (let* ((articles (gnus-summary-work-articles n))
11983 (save-buffer (save-excursion
11984 (nnheader-set-temp-buffer " *Gnus Save*")))
11985 (num (length articles))
11986 ;; Whether to save decoded articles or raw articles.
11987 (decode (when gnus-article-save-coding-system
11988 (get gnus-default-article-saver :decode)))
11989 ;; When saving many articles in a single file, use the other
11990 ;; function to save articles other than the first one.
11991 (saver2 (get gnus-default-article-saver :function))
11992 (gnus-prompt-before-saving (if saver2
11993 t
11994 gnus-prompt-before-saving))
11995 (gnus-default-article-saver gnus-default-article-saver)
11996 header file)
11997 (dolist (article articles)
11998 (setq header (gnus-summary-article-header article))
11999 (if (not (vectorp header))
12000 ;; This is a pseudo-article.
12001 (if (assq 'name header)
12002 (gnus-copy-file (cdr (assq 'name header)))
12003 (gnus-message 1 "Article %d is unsavable" article))
12004 ;; This is a real article.
12005 (save-window-excursion
12006 (gnus-summary-select-article decode decode nil article)
12007 (gnus-summary-goto-subject article))
12008 (with-current-buffer save-buffer
12009 (erase-buffer)
12010 (insert-buffer-substring (if decode
12011 gnus-article-buffer
12012 gnus-original-article-buffer)))
12013 (setq file (gnus-article-save save-buffer file num))
12014 (gnus-summary-remove-process-mark article)
12015 (unless not-saved
12016 (gnus-summary-set-saved-mark article)))
12017 (when saver2
12018 (setq gnus-default-article-saver saver2
12019 saver2 nil)))
12020 (gnus-kill-buffer save-buffer)
12021 (gnus-summary-position-point)
12022 (gnus-set-mode-line 'summary)
12023 n))
12024
12025 (declare-function gnus-summary-save-in-pipe "gnus-art" (&optional command raw))
12026
12027 (defun gnus-summary-pipe-output (&optional n sym)
12028 "Pipe the current article to a subprocess.
12029 If N is a positive number, pipe the N next articles.
12030 If N is a negative number, pipe the N previous articles.
12031 If N is nil and any articles have been marked with the process mark,
12032 pipe those articles instead.
12033 The default command to which articles are piped is specified by the
12034 variable `gnus-summary-pipe-output-default-command'; if it is nil, you
12035 will be prompted for the command.
12036
12037 The properties `:decode' and `:headers' that are put to the function
12038 symbol `gnus-summary-save-in-pipe' control whether this function
12039 decodes articles and what headers to keep (see the doc string for the
12040 `gnus-default-article-saver' variable). If SYM (the symbolic prefix)
12041 is neither omitted nor the symbol `r', force including all headers
12042 regardless of the `:headers' property. If it is the symbol `r',
12043 articles that are not decoded and include all headers will be piped
12044 no matter what the properties `:decode' and `:headers' are."
12045 (interactive (gnus-interactive "P\ny"))
12046 (require 'gnus-art)
12047 (let* ((articles (gnus-summary-work-articles n))
12048 (result-buffer "*Shell Command Output*")
12049 (all-headers (not (memq sym '(nil r))))
12050 (gnus-save-all-headers (or all-headers gnus-save-all-headers))
12051 (raw (eq sym 'r))
12052 (headers (get 'gnus-summary-save-in-pipe :headers))
12053 command result)
12054 (unless (numberp (car articles))
12055 (error "No article to pipe"))
12056 (setq command (read-shell-command
12057 (concat "Shell command on "
12058 (if (cdr articles)
12059 (format "these %d articles" (length articles))
12060 "this article")
12061 ": ")
12062 gnus-summary-pipe-output-default-command))
12063 (when (string-equal command "")
12064 (error "A command is required"))
12065 (when all-headers
12066 (put 'gnus-summary-save-in-pipe :headers nil))
12067 (unwind-protect
12068 (while articles
12069 (gnus-summary-goto-subject (pop articles))
12070 (save-window-excursion (gnus-summary-save-in-pipe command raw))
12071 (when (and (get-buffer result-buffer)
12072 (not (zerop (buffer-size (get-buffer result-buffer)))))
12073 (setq result (concat result (with-current-buffer result-buffer
12074 (buffer-string))))))
12075 (put 'gnus-summary-save-in-pipe :headers headers))
12076 (unless (zerop (length result))
12077 (if (with-current-buffer (get-buffer-create result-buffer)
12078 (erase-buffer)
12079 (insert result)
12080 (prog1
12081 (and (= (count-lines (point-min) (point)) 1)
12082 (progn
12083 (end-of-line 0)
12084 (<= (current-column)
12085 (window-width (minibuffer-window)))))
12086 (goto-char (point-min))))
12087 (message "%s" (substring result 0 -1))
12088 (message nil)
12089 (gnus-configure-windows 'pipe)))))
12090
12091 (defun gnus-summary-save-article-mail (&optional arg)
12092 "Append the current article to a Unix mail box file.
12093 If N is a positive number, save the N next articles.
12094 If N is a negative number, save the N previous articles.
12095 If N is nil and any articles have been marked with the process mark,
12096 save those articles instead."
12097 (interactive "P")
12098 (require 'gnus-art)
12099 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
12100 (gnus-summary-save-article arg)))
12101
12102 (defun gnus-summary-save-article-rmail (&optional arg)
12103 "Append the current article to an rmail file.
12104 If N is a positive number, save the N next articles.
12105 If N is a negative number, save the N previous articles.
12106 If N is nil and any articles have been marked with the process mark,
12107 save those articles instead."
12108 (interactive "P")
12109 (require 'gnus-art)
12110 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
12111 (gnus-summary-save-article arg)))
12112
12113 (defun gnus-summary-save-article-file (&optional arg)
12114 "Append the current article to a file.
12115 If N is a positive number, save the N next articles.
12116 If N is a negative number, save the N previous articles.
12117 If N is nil and any articles have been marked with the process mark,
12118 save those articles instead."
12119 (interactive "P")
12120 (require 'gnus-art)
12121 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
12122 (gnus-summary-save-article arg)))
12123
12124 (defun gnus-summary-write-article-file (&optional arg)
12125 "Write the current article to a file, deleting the previous file.
12126 If N is a positive number, save the N next articles.
12127 If N is a negative number, save the N previous articles.
12128 If N is nil and any articles have been marked with the process mark,
12129 save those articles instead."
12130 (interactive "P")
12131 (require 'gnus-art)
12132 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
12133 (gnus-summary-save-article arg)))
12134
12135 (defun gnus-summary-save-article-body-file (&optional arg)
12136 "Append the current article body to a file.
12137 If N is a positive number, save the N next articles.
12138 If N is a negative number, save the N previous articles.
12139 If N is nil and any articles have been marked with the process mark,
12140 save those articles instead."
12141 (interactive "P")
12142 (require 'gnus-art)
12143 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
12144 (gnus-summary-save-article arg)))
12145
12146 (defun gnus-summary-write-article-body-file (&optional arg)
12147 "Write the current article body to a file, deleting the previous file.
12148 If N is a positive number, save the N next articles.
12149 If N is a negative number, save the N previous articles.
12150 If N is nil and any articles have been marked with the process mark,
12151 save those articles instead."
12152 (interactive "P")
12153 (require 'gnus-art)
12154 (let ((gnus-default-article-saver 'gnus-summary-write-body-to-file))
12155 (gnus-summary-save-article arg)))
12156
12157 (defun gnus-summary-muttprint (&optional arg)
12158 "Print the current article using Muttprint.
12159 If N is a positive number, save the N next articles.
12160 If N is a negative number, save the N previous articles.
12161 If N is nil and any articles have been marked with the process mark,
12162 save those articles instead."
12163 (interactive "P")
12164 (require 'gnus-art)
12165 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
12166 (gnus-summary-save-article arg t)))
12167
12168 (defun gnus-summary-pipe-message (program)
12169 "Pipe the current article through PROGRAM."
12170 (interactive "sProgram: ")
12171 (gnus-summary-select-article)
12172 (let ((mail-header-separator ""))
12173 (gnus-eval-in-buffer-window gnus-article-buffer
12174 (save-restriction
12175 (widen)
12176 (let ((start (window-start))
12177 (inhibit-read-only t))
12178 (message-pipe-buffer-body program)
12179 (set-window-start (get-buffer-window (current-buffer)) start))))))
12180
12181 (defun gnus-get-split-value (methods)
12182 "Return a value based on the split METHODS."
12183 (let (split-name method result match)
12184 (when methods
12185 (with-current-buffer gnus-original-article-buffer
12186 (save-restriction
12187 (nnheader-narrow-to-headers)
12188 (while (and methods (not split-name))
12189 (goto-char (point-min))
12190 (setq method (pop methods))
12191 (setq match (car method))
12192 (when (cond
12193 ((stringp match)
12194 ;; Regular expression.
12195 (ignore-errors
12196 (re-search-forward match nil t)))
12197 ((functionp match)
12198 ;; Function.
12199 (save-restriction
12200 (widen)
12201 (setq result (funcall match gnus-newsgroup-name))))
12202 ((consp match)
12203 ;; Form.
12204 (save-restriction
12205 (widen)
12206 (setq result (eval match)))))
12207 (setq split-name (cdr method))
12208 (cond ((stringp result)
12209 (push (expand-file-name
12210 result gnus-article-save-directory)
12211 split-name))
12212 ((consp result)
12213 (setq split-name (append result split-name)))))))))
12214 (nreverse split-name)))
12215
12216 (defun gnus-valid-move-group-p (group)
12217 (and (symbolp group)
12218 (boundp group)
12219 (symbol-name group)
12220 (symbol-value group)
12221 (gnus-get-function (gnus-find-method-for-group
12222 (symbol-name group)) 'request-accept-article t)))
12223
12224 (defun gnus-read-move-group-name (prompt default articles prefix)
12225 "Read a group name."
12226 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
12227 (prom
12228 (format "%s %s to"
12229 prompt
12230 (if (> (length articles) 1)
12231 (format "these %d articles" (length articles))
12232 "this article")))
12233 (to-newsgroup
12234 (cond
12235 ((null split-name)
12236 (gnus-group-completing-read
12237 prom
12238 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12239 nil prefix nil default))
12240 ((= 1 (length split-name))
12241 (gnus-group-completing-read
12242 prom
12243 (gnus-remove-if-not 'gnus-valid-move-group-p gnus-active-hashtb t)
12244 nil prefix 'gnus-group-history (car split-name)))
12245 (t
12246 (gnus-completing-read
12247 prom (nreverse split-name) nil nil 'gnus-group-history))))
12248 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup)))
12249 encoded)
12250 (when to-newsgroup
12251 (if (or (string= to-newsgroup "")
12252 (string= to-newsgroup prefix))
12253 (setq to-newsgroup default))
12254 (unless to-newsgroup
12255 (error "No group name entered"))
12256 (setq encoded (encode-coding-string
12257 to-newsgroup
12258 (gnus-group-name-charset to-method to-newsgroup)))
12259 (or (gnus-active encoded)
12260 (gnus-activate-group encoded nil nil to-method)
12261 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
12262 to-newsgroup))
12263 (or (and (gnus-request-create-group encoded to-method)
12264 (gnus-activate-group encoded nil nil to-method)
12265 (gnus-subscribe-group encoded))
12266 (error "Couldn't create group %s" to-newsgroup)))
12267 (error "No such group: %s" to-newsgroup))
12268 encoded)))
12269
12270 (defvar gnus-summary-save-parts-counter)
12271 (declare-function mm-uu-dissect "mm-uu" (&optional noheader mime-type))
12272
12273 (defun gnus-summary-save-parts (type dir n &optional reverse)
12274 "Save parts matching TYPE to DIR.
12275 If REVERSE, save parts that do not match TYPE."
12276 (interactive
12277 (list (read-string "Save parts of type: "
12278 (or (car gnus-summary-save-parts-type-history)
12279 gnus-summary-save-parts-default-mime)
12280 'gnus-summary-save-parts-type-history)
12281 (setq gnus-summary-save-parts-last-directory
12282 (read-directory-name "Save to directory: "
12283 gnus-summary-save-parts-last-directory
12284 nil t))
12285 current-prefix-arg))
12286 (gnus-summary-iterate n
12287 (let ((gnus-display-mime-function nil)
12288 gnus-article-prepare-hook
12289 gnus-article-decode-hook
12290 gnus-display-mime-function
12291 gnus-break-pages
12292 (gnus-inhibit-treatment t))
12293 (gnus-summary-select-article))
12294 (with-current-buffer gnus-article-buffer
12295 (let ((handles (or gnus-article-mime-handles
12296 (mm-dissect-buffer nil gnus-article-loose-mime)
12297 (and gnus-article-emulate-mime
12298 (mm-uu-dissect))))
12299 (gnus-summary-save-parts-counter 1))
12300 (when handles
12301 (gnus-summary-save-parts-1 type dir handles reverse)
12302 (unless gnus-article-mime-handles ;; Don't destroy this case.
12303 (mm-destroy-parts handles)))))))
12304
12305 (defun gnus-summary-save-parts-1 (type dir handle reverse)
12306 (if (stringp (car handle))
12307 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
12308 (cdr handle))
12309 (when (if reverse
12310 (not (string-match type (mm-handle-media-type handle)))
12311 (string-match type (mm-handle-media-type handle)))
12312 (let ((file (expand-file-name
12313 (gnus-map-function
12314 mm-file-name-rewrite-functions
12315 (file-name-nondirectory
12316 (or
12317 (mm-handle-filename handle)
12318 (format "%s.%d.%d" gnus-newsgroup-name
12319 (cdr gnus-article-current)
12320 gnus-summary-save-parts-counter))))
12321 dir)))
12322 (incf gnus-summary-save-parts-counter)
12323 (unless (file-exists-p file)
12324 (mm-save-part-to-file handle file))))))
12325
12326 ;; Summary extract commands
12327
12328 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
12329 (let ((inhibit-read-only t)
12330 (article (gnus-summary-article-number))
12331 after-article b e)
12332 (unless (gnus-summary-goto-subject article)
12333 (error "No such article: %d" article))
12334 (gnus-summary-position-point)
12335 ;; If all commands are to be bunched up on one line, we collect
12336 ;; them here.
12337 (unless gnus-view-pseudos-separately
12338 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
12339 files action)
12340 (while ps
12341 (setq action (cdr (assq 'action (car ps))))
12342 (setq files (list (cdr (assq 'name (car ps)))))
12343 (while (and ps (cdr ps)
12344 (string= (or action "1")
12345 (or (cdr (assq 'action (cadr ps))) "2")))
12346 (push (cdr (assq 'name (cadr ps))) files)
12347 (setcdr ps (cddr ps)))
12348 (when files
12349 (when (not (string-match "%s" action))
12350 (push " " files))
12351 (push " " files)
12352 (when (assq 'execute (car ps))
12353 (setcdr (assq 'execute (car ps))
12354 (funcall (if (string-match "%s" action)
12355 'format 'concat)
12356 action
12357 (mapconcat
12358 (lambda (f)
12359 (if (equal f " ")
12360 f
12361 (shell-quote-argument f)))
12362 files " ")))))
12363 (setq ps (cdr ps)))))
12364 (if (and gnus-view-pseudos (not not-view))
12365 (while pslist
12366 (when (assq 'execute (car pslist))
12367 (gnus-execute-command (cdr (assq 'execute (car pslist)))
12368 (eq gnus-view-pseudos 'not-confirm)))
12369 (setq pslist (cdr pslist)))
12370 (save-excursion
12371 (while pslist
12372 (setq after-article (or (cdr (assq 'article (car pslist)))
12373 (gnus-summary-article-number)))
12374 (gnus-summary-goto-subject after-article)
12375 (forward-line 1)
12376 (setq b (point))
12377 (insert " " (file-name-nondirectory
12378 (cdr (assq 'name (car pslist))))
12379 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
12380 (setq e (point))
12381 (forward-line -1) ; back to `b'
12382 (add-text-properties
12383 b (1- e) (list 'gnus-number gnus-reffed-article-number
12384 'mouse-face gnus-mouse-face))
12385 (gnus-data-enter
12386 after-article gnus-reffed-article-number
12387 gnus-unread-mark b (car pslist) 0 (- e b))
12388 (setq gnus-newsgroup-unreads
12389 (gnus-add-to-sorted-list gnus-newsgroup-unreads
12390 gnus-reffed-article-number))
12391 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
12392 (setq pslist (cdr pslist)))))))
12393
12394 (defun gnus-pseudos< (p1 p2)
12395 (let ((c1 (cdr (assq 'action p1)))
12396 (c2 (cdr (assq 'action p2))))
12397 (and c1 c2 (string< c1 c2))))
12398
12399 (defun gnus-request-pseudo-article (props)
12400 (cond ((assq 'execute props)
12401 (gnus-execute-command (cdr (assq 'execute props)))))
12402 (let ((gnus-current-article (gnus-summary-article-number)))
12403 (gnus-run-hooks 'gnus-mark-article-hook)))
12404
12405 (defun gnus-execute-command (command &optional automatic)
12406 (save-excursion
12407 (gnus-article-setup-buffer)
12408 (set-buffer gnus-article-buffer)
12409 (setq buffer-read-only nil)
12410 (let ((command (if automatic command
12411 (read-string "Command: " (cons command 0)))))
12412 (erase-buffer)
12413 (insert "$ " command "\n\n")
12414 (if gnus-view-pseudo-asynchronously
12415 (start-process "gnus-execute" (current-buffer) shell-file-name
12416 shell-command-switch command)
12417 (call-process shell-file-name nil t nil
12418 shell-command-switch command)))))
12419
12420 ;; Summary kill commands.
12421
12422 (defun gnus-summary-edit-global-kill (article)
12423 "Edit the \"global\" kill file."
12424 (interactive (list (gnus-summary-article-number)))
12425 (gnus-group-edit-global-kill article))
12426
12427 (defun gnus-summary-edit-local-kill ()
12428 "Edit a local kill file applied to the current newsgroup."
12429 (interactive)
12430 (setq gnus-current-headers (gnus-summary-article-header))
12431 (gnus-group-edit-local-kill
12432 (gnus-summary-article-number) gnus-newsgroup-name))
12433
12434 ;;; Header reading.
12435
12436 (defun gnus-read-header (id &optional header)
12437 "Read the headers of article ID and enter them into the Gnus system."
12438 (let ((group gnus-newsgroup-name)
12439 (gnus-override-method
12440 (or
12441 gnus-override-method
12442 (and (gnus-news-group-p gnus-newsgroup-name)
12443 (car (gnus-refer-article-methods)))))
12444 where)
12445 ;; First we check to see whether the header in question is already
12446 ;; fetched.
12447 (if (stringp id)
12448 ;; This is a Message-ID.
12449 (setq header (or header (gnus-id-to-header id)))
12450 ;; This is an article number.
12451 (setq header (or header (gnus-summary-article-header id))))
12452 (if (and header
12453 (not (gnus-summary-article-sparse-p (mail-header-number header))))
12454 ;; We have found the header.
12455 header
12456 ;; We have to really fetch the header to this article.
12457 (with-current-buffer nntp-server-buffer
12458 (when (setq where (gnus-request-head id group))
12459 (nnheader-fold-continuation-lines)
12460 (goto-char (point-max))
12461 (insert ".\n")
12462 (goto-char (point-min))
12463 (insert "211 ")
12464 (princ (cond
12465 ((numberp id) id)
12466 ((cdr where) (cdr where))
12467 (header (mail-header-number header))
12468 (t gnus-reffed-article-number))
12469 (current-buffer))
12470 (insert " Article retrieved.\n"))
12471 (if (or (not where)
12472 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
12473 () ; Malformed head.
12474 (unless (gnus-summary-article-sparse-p (mail-header-number header))
12475 (when (and (bound-and-true-p gnus-registry-enabled)
12476 (not (gnus-ephemeral-group-p (car where))))
12477 (gnus-registry-handle-action
12478 (mail-header-id header) nil
12479 (gnus-group-prefixed-name
12480 (car where)
12481 (or gnus-override-method (gnus-find-method-for-group group)))
12482 (mail-header-subject header)
12483 (mail-header-from header)))
12484 (when (and (stringp id)
12485 (or
12486 (not (string= (gnus-group-real-name group)
12487 (car where)))
12488 (not (gnus-server-equal gnus-override-method
12489 (gnus-group-method group)))))
12490 ;; If we fetched by Message-ID and the article came from
12491 ;; a different group (or server), we fudge some bogus
12492 ;; article numbers for this article.
12493 (mail-header-set-number header gnus-reffed-article-number))
12494 (with-current-buffer gnus-summary-buffer
12495 (decf gnus-reffed-article-number)
12496 (gnus-remove-header (mail-header-number header))
12497 (push header gnus-newsgroup-headers)
12498 (setq gnus-current-headers header)
12499 (push (mail-header-number header) gnus-newsgroup-limit)))
12500 header)))))
12501
12502 (defun gnus-remove-header (number)
12503 "Remove header NUMBER from `gnus-newsgroup-headers'."
12504 (if (and gnus-newsgroup-headers
12505 (= number (mail-header-number (car gnus-newsgroup-headers))))
12506 (pop gnus-newsgroup-headers)
12507 (let ((headers gnus-newsgroup-headers))
12508 (while (and (cdr headers)
12509 (not (= number (mail-header-number (cadr headers)))))
12510 (pop headers))
12511 (when (cdr headers)
12512 (setcdr headers (cddr headers))))))
12513
12514 ;;;
12515 ;;; summary highlights
12516 ;;;
12517
12518 (defun gnus-highlight-selected-summary ()
12519 "Highlight selected article in summary buffer."
12520 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
12521 (when gnus-summary-selected-face
12522 (save-excursion
12523 (let* ((beg (point-at-bol))
12524 (end (point-at-eol))
12525 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
12526 (from (if (get-text-property beg 'mouse-face)
12527 beg
12528 (or (next-single-property-change
12529 beg 'mouse-face nil end)
12530 beg)))
12531 (to
12532 (if (= from end)
12533 (- from 2)
12534 (or (next-single-property-change
12535 from 'mouse-face nil end)
12536 end))))
12537 ;; If no mouse-face prop on line we will have to = from = end,
12538 ;; so we highlight the entire line instead.
12539 (when (= (+ to 2) from)
12540 (setq from beg)
12541 (setq to end))
12542 (if gnus-newsgroup-selected-overlay
12543 ;; Move old overlay.
12544 (move-overlay
12545 gnus-newsgroup-selected-overlay from to (current-buffer))
12546 ;; Create new overlay.
12547 (overlay-put
12548 (setq gnus-newsgroup-selected-overlay (make-overlay from to))
12549 'face gnus-summary-selected-face))))))
12550
12551 (defvar gnus-summary-highlight-line-cached nil)
12552 (defvar gnus-summary-highlight-line-trigger nil)
12553
12554 (defun gnus-summary-highlight-line-0 ()
12555 (if (and (eq gnus-summary-highlight-line-trigger
12556 gnus-summary-highlight)
12557 gnus-summary-highlight-line-cached)
12558 gnus-summary-highlight-line-cached
12559 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
12560 gnus-summary-highlight-line-cached
12561 (let* ((cond (list 'cond))
12562 (c cond)
12563 (list gnus-summary-highlight))
12564 (while list
12565 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
12566 nil))
12567 (setq c (cdr c)
12568 list (cdr list)))
12569 (gnus-byte-compile (list 'lambda nil cond))))))
12570
12571 (defun gnus-summary-highlight-line ()
12572 "Highlight current line according to `gnus-summary-highlight'."
12573 (let* ((beg (point-at-bol))
12574 (article (or (gnus-summary-article-number) gnus-current-article))
12575 (score (or (cdr (assq article
12576 gnus-newsgroup-scored))
12577 gnus-summary-default-score 0))
12578 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
12579 (inhibit-read-only t)
12580 (default gnus-summary-default-score)
12581 (default-high gnus-summary-default-high-score)
12582 (default-low gnus-summary-default-low-score)
12583 (uncached (and gnus-summary-use-undownloaded-faces
12584 (memq article gnus-newsgroup-undownloaded)
12585 (not (memq article gnus-newsgroup-cached)))))
12586 (let ((face (funcall (gnus-summary-highlight-line-0))))
12587 (unless (eq face (gnus-get-text-property-excluding-characters-with-faces beg 'face))
12588 (gnus-put-text-property-excluding-characters-with-faces
12589 beg (point-at-eol) 'face
12590 (setq face (if (boundp face) (symbol-value face) face)))
12591 (when gnus-summary-highlight-line-function
12592 (funcall gnus-summary-highlight-line-function article face))))))
12593
12594 (defun gnus-update-read-articles (group unread &optional compute)
12595 "Update the list of read articles in GROUP.
12596 UNREAD is a sorted list."
12597 (let ((active (or gnus-newsgroup-active (gnus-active group)))
12598 (info (gnus-get-info group))
12599 (prev 1)
12600 read)
12601 (if (or (not info) (not active))
12602 ;; There is no info on this group if it was, in fact,
12603 ;; killed. Gnus stores no information on killed groups, so
12604 ;; there's nothing to be done.
12605 ;; One could store the information somewhere temporarily,
12606 ;; perhaps... Hmmm...
12607 ()
12608 ;; Remove any negative articles numbers.
12609 (while (and unread (< (car unread) 0))
12610 (setq unread (cdr unread)))
12611 ;; Remove any expired article numbers
12612 (while (and unread (< (car unread) (car active)))
12613 (setq unread (cdr unread)))
12614 ;; Compute the ranges of read articles by looking at the list of
12615 ;; unread articles.
12616 (while unread
12617 (when (/= (car unread) prev)
12618 (push (if (= prev (1- (car unread))) prev
12619 (cons prev (1- (car unread))))
12620 read))
12621 (setq prev (1+ (car unread)))
12622 (setq unread (cdr unread)))
12623 (when (<= prev (cdr active))
12624 (push (cons prev (cdr active)) read))
12625 (setq read (if (> (length read) 1) (nreverse read) read))
12626 (if compute
12627 read
12628 (save-excursion
12629 (let (setmarkundo)
12630 ;; Propagate the read marks to the backend.
12631 (when (and (gnus-method-option-p
12632 (gnus-find-method-for-group group)
12633 'server-marks)
12634 (gnus-check-backend-function 'request-set-mark group))
12635 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
12636 (add (gnus-remove-from-range read (gnus-info-read info))))
12637 (when (or add del)
12638 (unless (gnus-check-group group)
12639 (error "Can't open server for %s" group))
12640 (gnus-request-set-mark
12641 group (delq nil (list (if add (list add 'add '(read)))
12642 (if del (list del 'del '(read))))))
12643 (setq setmarkundo
12644 `(gnus-request-set-mark
12645 ,group
12646 ',(delq nil (list
12647 (if del (list del 'add '(read)))
12648 (if add (list add 'del '(read))))))))))
12649 (set-buffer gnus-group-buffer)
12650 (gnus-undo-register
12651 `(progn
12652 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
12653 (gnus-info-set-read ',info ',(gnus-info-read info))
12654 (gnus-get-unread-articles-in-group ',info
12655 (gnus-active ,group))
12656 (gnus-group-update-group ,group t)
12657 ,setmarkundo))))
12658 ;; Enter this list into the group info.
12659 (gnus-info-set-read info read)
12660 ;; Set the number of unread articles in gnus-newsrc-hashtb.
12661 (gnus-get-unread-articles-in-group info (gnus-active group))
12662 t))))
12663
12664 (defun gnus-offer-save-summaries ()
12665 "Offer to save all active summary buffers."
12666 (let (buffers)
12667 ;; Go through all buffers and find all summaries.
12668 (dolist (buffer (buffer-list))
12669 (when (and (setq buffer (buffer-name buffer))
12670 (string-match "Summary" buffer)
12671 (with-current-buffer buffer
12672 ;; We check that this is, indeed, a summary buffer.
12673 (and (derived-mode-p 'gnus-summary-mode)
12674 ;; Also make sure this isn't bogus.
12675 gnus-newsgroup-prepared
12676 ;; Also make sure that this isn't a
12677 ;; dead summary buffer.
12678 (not gnus-dead-summary-mode))))
12679 (push buffer buffers)))
12680 ;; Go through all these summary buffers and offer to save them.
12681 (when buffers
12682 (save-excursion
12683 (if (eq gnus-interactive-exit 'quiet)
12684 (dolist (buffer buffers)
12685 (switch-to-buffer buffer)
12686 (gnus-summary-exit))
12687 (map-y-or-n-p
12688 "Update summary buffer %s? "
12689 (lambda (buf)
12690 (switch-to-buffer buf)
12691 (gnus-summary-exit))
12692 buffers))))))
12693
12694 (defun gnus-summary-setup-default-charset ()
12695 "Setup newsgroup default charset."
12696 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
12697 (setq gnus-newsgroup-charset nil)
12698 (let* ((ignored-charsets
12699 (or gnus-newsgroup-ephemeral-ignored-charsets
12700 (append
12701 (and gnus-newsgroup-name
12702 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
12703 gnus-newsgroup-ignored-charsets))))
12704 (setq gnus-newsgroup-charset
12705 (or gnus-newsgroup-ephemeral-charset
12706 (and gnus-newsgroup-name
12707 (gnus-parameter-charset gnus-newsgroup-name))
12708 gnus-default-charset))
12709 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
12710 ignored-charsets))))
12711
12712 ;;;
12713 ;;; Mime Commands
12714 ;;;
12715
12716 (defun gnus-summary-display-buttonized (&optional show-all-parts)
12717 "Display the current article buffer fully MIME-buttonized.
12718 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
12719 treated as multipart/mixed."
12720 (interactive "P")
12721 (require 'gnus-art)
12722 (let ((gnus-unbuttonized-mime-types nil)
12723 (gnus-mime-display-multipart-as-mixed show-all-parts))
12724 (gnus-summary-show-article)))
12725
12726 (defun gnus-summary-repair-multipart (article)
12727 "Add a Content-Type header to a multipart article without one."
12728 (interactive (list (gnus-summary-article-number)))
12729 (gnus-with-article article
12730 (message-narrow-to-head)
12731 (message-remove-header "Mime-Version")
12732 (goto-char (point-max))
12733 (insert "Mime-Version: 1.0\n")
12734 (widen)
12735 (when (search-forward "\n--" nil t)
12736 (let ((separator (buffer-substring (point) (point-at-eol))))
12737 (message-narrow-to-head)
12738 (message-remove-header "Content-Type")
12739 (goto-char (point-max))
12740 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
12741 separator))
12742 (widen))))
12743 (let (gnus-mark-article-hook)
12744 (gnus-summary-select-article t t nil article)))
12745
12746 (defun gnus-summary-toggle-display-buttonized ()
12747 "Toggle the buttonizing of the article buffer."
12748 (interactive)
12749 (require 'gnus-art)
12750 (if (setq gnus-inhibit-mime-unbuttonizing
12751 (not gnus-inhibit-mime-unbuttonizing))
12752 (let ((gnus-unbuttonized-mime-types nil))
12753 (gnus-summary-show-article))
12754 (gnus-summary-show-article)))
12755
12756 ;;;
12757 ;;; Generic summary marking commands
12758 ;;;
12759
12760 (defvar gnus-summary-marking-alist
12761 '((read gnus-del-mark "d")
12762 (unread gnus-unread-mark "u")
12763 (ticked gnus-ticked-mark "!")
12764 (dormant gnus-dormant-mark "?")
12765 (expirable gnus-expirable-mark "e"))
12766 "An alist of names/marks/keystrokes.")
12767
12768 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
12769 (defvar gnus-summary-mark-map)
12770
12771 (defun gnus-summary-make-all-marking-commands ()
12772 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
12773 (dolist (elem gnus-summary-marking-alist)
12774 (apply 'gnus-summary-make-marking-command elem)))
12775
12776 (defun gnus-summary-make-marking-command (name mark keystroke)
12777 (let ((map (make-sparse-keymap)))
12778 (define-key gnus-summary-generic-mark-map keystroke map)
12779 (dolist (lway `((next "next" next nil "n")
12780 (next-unread "next unread" next t "N")
12781 (prev "previous" prev nil "p")
12782 (prev-unread "previous unread" prev t "P")
12783 (nomove "" nil nil ,keystroke)))
12784 (let ((func (gnus-summary-make-marking-command-1
12785 mark (car lway) lway name)))
12786 (setq func (eval func))
12787 (define-key map (nth 4 lway) func)))))
12788
12789 (defun gnus-summary-make-marking-command-1 (mark way lway name)
12790 `(defun ,(intern
12791 (format "gnus-summary-put-mark-as-%s%s"
12792 name (if (eq way 'nomove)
12793 ""
12794 (concat "-" (symbol-name way)))))
12795 (n)
12796 ,(format
12797 "Mark the current article as %s%s.
12798 If N, the prefix, then repeat N times.
12799 If N is negative, move in reverse order.
12800 The difference between N and the actual number of articles marked is
12801 returned."
12802 name (cadr lway))
12803 (interactive "p")
12804 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
12805
12806 (defun gnus-summary-generic-mark (n mark move unread)
12807 "Mark N articles with MARK."
12808 (unless (derived-mode-p 'gnus-summary-mode)
12809 (error "This command can only be used in the summary buffer"))
12810 (gnus-summary-show-thread)
12811 (let ((nummove
12812 (cond
12813 ((eq move 'next) 1)
12814 ((eq move 'prev) -1)
12815 (t 0))))
12816 (if (zerop nummove)
12817 (setq n 1)
12818 (when (< n 0)
12819 (setq n (abs n)
12820 nummove (* -1 nummove))))
12821 (while (and (> n 0)
12822 (gnus-summary-mark-article nil mark)
12823 (zerop (gnus-summary-next-subject nummove unread t)))
12824 (setq n (1- n)))
12825 (when (/= 0 n)
12826 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
12827 (gnus-summary-recenter)
12828 (gnus-summary-position-point)
12829 (gnus-set-mode-line 'summary)
12830 n))
12831
12832 (defun gnus-summary-insert-articles (articles)
12833 (when (setq articles
12834 (gnus-sorted-difference articles
12835 (mapcar (lambda (h)
12836 (mail-header-number h))
12837 gnus-newsgroup-headers)))
12838 (setq gnus-newsgroup-headers
12839 (cl-merge 'list
12840 gnus-newsgroup-headers
12841 (gnus-fetch-headers articles nil t)
12842 'gnus-article-sort-by-number))
12843 (setq gnus-newsgroup-articles
12844 (gnus-sorted-nunion gnus-newsgroup-articles articles))
12845 ;; Suppress duplicates?
12846 (when gnus-suppress-duplicates
12847 (gnus-dup-suppress-articles))
12848
12849 (if (and gnus-fetch-old-headers
12850 (eq gnus-headers-retrieved-by 'nov))
12851 ;; We might want to build some more threads first.
12852 (if (eq gnus-fetch-old-headers 'invisible)
12853 (gnus-build-all-threads)
12854 (gnus-build-old-threads))
12855 ;; Mark the inserted articles that are unread as unread.
12856 (setq gnus-newsgroup-unreads
12857 (gnus-sorted-nunion
12858 gnus-newsgroup-unreads
12859 (gnus-sorted-nintersection
12860 (gnus-list-of-unread-articles gnus-newsgroup-name)
12861 articles)))
12862 ;; Mark the inserted articles as selected so that the information
12863 ;; of the marks having been changed by a user may be updated when
12864 ;; exiting this group. See `gnus-summary-update-info'.
12865 (dolist (art articles)
12866 (setq gnus-newsgroup-unselected (delq art gnus-newsgroup-unselected))))
12867 ;; Let the Gnus agent mark articles as read.
12868 (when gnus-agent
12869 (gnus-agent-get-undownloaded-list))
12870 ;; Remove list identifiers from subject
12871 (gnus-summary-remove-list-identifiers)
12872 ;; First and last article in this newsgroup.
12873 (when gnus-newsgroup-headers
12874 (setq gnus-newsgroup-begin
12875 (mail-header-number (car gnus-newsgroup-headers))
12876 gnus-newsgroup-end
12877 (mail-header-number
12878 (gnus-last-element gnus-newsgroup-headers))))
12879 (when gnus-use-scoring
12880 (gnus-possibly-score-headers))))
12881
12882 (defun gnus-summary-insert-old-articles (&optional all)
12883 "Insert all old articles in this group.
12884 If ALL is non-nil, already read articles become readable.
12885 If ALL is a number, fetch this number of articles."
12886 (interactive "P")
12887 (prog1
12888 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12889 older len)
12890 (setq older
12891 ;; Some nntp servers lie about their active range. When
12892 ;; this happens, the active range can be in the millions.
12893 ;; Use a compressed range to avoid creating a huge list.
12894 (gnus-range-difference
12895 (gnus-range-difference (list gnus-newsgroup-active) old)
12896 gnus-newsgroup-unexist))
12897 (setq len (gnus-range-length older))
12898 (cond
12899 ((null older) nil)
12900 ((numberp all)
12901 (if (< all len)
12902 (let ((older-range (nreverse older)))
12903 (setq older nil)
12904
12905 (while (> all 0)
12906 (let* ((r (pop older-range))
12907 (min (if (numberp r) r (car r)))
12908 (max (if (numberp r) r (cdr r))))
12909 (while (and (<= min max)
12910 (> all 0))
12911 (push max older)
12912 (setq all (1- all)
12913 max (1- max))))))
12914 (setq older (gnus-uncompress-range older))))
12915 (all
12916 (setq older (gnus-uncompress-range older)))
12917 (t
12918 (when (and (numberp gnus-large-newsgroup)
12919 (> len gnus-large-newsgroup))
12920 (let* ((cursor-in-echo-area nil)
12921 (initial (gnus-parameter-large-newsgroup-initial
12922 gnus-newsgroup-name))
12923 (input
12924 (read-string
12925 (format
12926 "How many articles from %s (%s %d): "
12927 (gnus-group-decoded-name gnus-newsgroup-name)
12928 (if initial "max" "default")
12929 len)
12930 nil nil
12931 (and initial
12932 (number-to-string initial)))))
12933 (unless (string-match "^[ \t]*$" input)
12934 (setq all (string-to-number input))
12935 (if (< all len)
12936 (let ((older-range (nreverse older)))
12937 (setq older nil)
12938
12939 (while (> all 0)
12940 (let* ((r (pop older-range))
12941 (min (if (numberp r) r (car r)))
12942 (max (if (numberp r) r (cdr r))))
12943 (while (and (<= min max)
12944 (> all 0))
12945 (push max older)
12946 (setq all (1- all)
12947 max (1- max))))))))))
12948 (setq older (gnus-uncompress-range older))))
12949 (if (not older)
12950 (message "No old news.")
12951 (gnus-summary-insert-articles older)
12952 (gnus-summary-limit (gnus-sorted-nunion old older))))
12953 (gnus-summary-position-point)))
12954
12955 (defun gnus-summary-insert-new-articles ()
12956 "Insert all new articles in this group."
12957 (interactive)
12958 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
12959 (old-high gnus-newsgroup-highest)
12960 (nnmail-fetched-sources (list t))
12961 (new-active (gnus-activate-group gnus-newsgroup-name 'scan))
12962 i new)
12963 (unless new-active
12964 (error "Couldn't fetch new data"))
12965 (setq gnus-newsgroup-active (gnus-copy-sequence new-active))
12966 (setq i (cdr gnus-newsgroup-active)
12967 gnus-newsgroup-highest i)
12968 (while (> i old-high)
12969 (push i new)
12970 (decf i))
12971 (if (not new)
12972 (message "No gnus is bad news")
12973 (gnus-summary-insert-articles new)
12974 (setq gnus-newsgroup-unreads
12975 (gnus-sorted-nunion gnus-newsgroup-unreads new))
12976 (gnus-summary-limit (gnus-sorted-nunion old new))))
12977 (gnus-summary-position-point))
12978
12979 ;;; Bookmark support for Gnus.
12980 (declare-function gnus-article-show-summary "gnus-art" ())
12981 (declare-function bookmark-make-record-default
12982 "bookmark" (&optional no-file no-context posn))
12983 (declare-function bookmark-prop-get "bookmark" (bookmark prop))
12984 (declare-function bookmark-default-handler "bookmark" (bmk))
12985 (declare-function bookmark-get-bookmark-record "bookmark" (bmk))
12986 (defvar bookmark-yank-point)
12987 (defvar bookmark-current-buffer)
12988
12989 (defun gnus-summary-bookmark-make-record ()
12990 "Make a bookmark entry for a Gnus summary buffer."
12991 (let (pos buf)
12992 (unless (and (derived-mode-p 'gnus-summary-mode) gnus-article-current)
12993 (save-restriction ; FIXME is it necessary to widen?
12994 (widen) (setq pos (point))) ; Set position in gnus-article buffer.
12995 (setq buf "art") ; We are recording bookmark from article buffer.
12996 (setq bookmark-yank-point (point))
12997 (setq bookmark-current-buffer (current-buffer))
12998 (gnus-article-show-summary)) ; Go back in summary buffer.
12999 ;; We are now recording bookmark from summary buffer.
13000 (unless buf (setq buf "sum"))
13001 (let* ((subject (elt (gnus-summary-article-header) 1))
13002 (grp (car gnus-article-current))
13003 (art (cdr gnus-article-current))
13004 (head (gnus-summary-article-header art))
13005 (id (mail-header-id head)))
13006 `(,subject
13007 ,@(condition-case nil
13008 (bookmark-make-record-default 'no-file 'no-context pos)
13009 (wrong-number-of-arguments
13010 (bookmark-make-record-default 'point-only)))
13011 (location . ,(format "Gnus-%s %s:%d:%s" buf grp art id))
13012 (group . ,grp) (article . ,art)
13013 (message-id . ,id) (handler . gnus-summary-bookmark-jump)))))
13014
13015 ;;;###autoload
13016 (defun gnus-summary-bookmark-jump (bookmark)
13017 "Handler function for record returned by `gnus-summary-bookmark-make-record'.
13018 BOOKMARK is a bookmark name or a bookmark record."
13019 (let ((group (bookmark-prop-get bookmark 'group))
13020 (article (bookmark-prop-get bookmark 'article))
13021 (id (bookmark-prop-get bookmark 'message-id))
13022 (buf (car (split-string (bookmark-prop-get bookmark 'location)))))
13023 (gnus-fetch-group group (list article))
13024 (gnus-summary-insert-cached-articles)
13025 (gnus-summary-goto-article id nil 'force)
13026 ;; FIXME we have to wait article buffer is ready (only large buffer)
13027 ;; Is there a better solution to know that?
13028 ;; If we don't wait `bookmark-default-handler' will have no chance
13029 ;; to set position. However there is no error, just wrong pos.
13030 (sit-for 1)
13031 (when (string= buf "Gnus-art")
13032 (other-window 1))
13033 (bookmark-default-handler
13034 `(""
13035 (buffer . ,(current-buffer))
13036 . ,(bookmark-get-bookmark-record bookmark)))))
13037
13038 (gnus-summary-make-all-marking-commands)
13039
13040 (provide 'gnus-sum)
13041
13042 (run-hooks 'gnus-sum-load-hook)
13043
13044 ;; Local Variables:
13045 ;; coding: utf-8
13046 ;; End:
13047
13048 ;;; gnus-sum.el ends here