(Vsearch_spaces_regexp):
[emacs.git] / lisp / gnus / gnus-sum.el
blob5f2c2d7aeb1a9dbd9c4992172b6eee42e81576d7
1 ;;; gnus-sum.el --- summary mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
8 ;; This file is part of GNU Emacs.
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 2, or (at your option)
13 ;; any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;;; Code:
29 (eval-when-compile
30 (require 'cl)
31 (defvar tool-bar-map))
33 (require 'gnus)
34 (require 'gnus-group)
35 (require 'gnus-spec)
36 (require 'gnus-range)
37 (require 'gnus-int)
38 (require 'gnus-undo)
39 (require 'gnus-util)
40 (require 'mm-decode)
41 (require 'nnoo)
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."
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)
56 (defcustom gnus-kill-summary-on-exit t
57 "*If non-nil, kill the summary buffer when you exit from it.
58 If nil, the summary will become a \"*Dead Summary*\" buffer, and
59 it will be killed sometime later."
60 :group 'gnus-summary-exit
61 :type 'boolean)
63 (defcustom gnus-fetch-old-headers nil
64 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
65 If an unread article in the group refers to an older, already read (or
66 just marked as read) article, the old article will not normally be
67 displayed in the Summary buffer. If this variable is t, Gnus
68 will attempt to grab the headers to the old articles, and thereby
69 build complete threads. If it has the value `some', only enough
70 headers to connect otherwise loose threads will be displayed. This
71 variable can also be a number. In that case, no more than that number
72 of old headers will be fetched. If it has the value `invisible', all
73 old headers will be fetched, but none will be displayed.
75 The server has to support NOV for any of this to work."
76 :group 'gnus-thread
77 :type '(choice (const :tag "off" nil)
78 (const :tag "on" t)
79 (const some)
80 (const invisible)
81 number
82 (sexp :menu-tag "other" t)))
84 (defcustom gnus-refer-thread-limit 200
85 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
86 If t, fetch all the available old headers."
87 :group 'gnus-thread
88 :type '(choice number
89 (sexp :menu-tag "other" t)))
91 (defcustom gnus-summary-make-false-root 'adopt
92 "*nil means that Gnus won't gather loose threads.
93 If the root of a thread has expired or been read in a previous
94 session, the information necessary to build a complete thread has been
95 lost. Instead of having many small sub-threads from this original thread
96 scattered all over the summary buffer, Gnus can gather them.
98 If non-nil, Gnus will try to gather all loose sub-threads from an
99 original thread into one large thread.
101 If this variable is non-nil, it should be one of `none', `adopt',
102 `dummy' or `empty'.
104 If this variable is `none', Gnus will not make a false root, but just
105 present the sub-threads after another.
106 If this variable is `dummy', Gnus will create a dummy root that will
107 have all the sub-threads as children.
108 If this variable is `adopt', Gnus will make one of the \"children\"
109 the parent and mark all the step-children as such.
110 If this variable is `empty', the \"children\" are printed with empty
111 subject fields. (Or rather, they will be printed with a string
112 given by the `gnus-summary-same-subject' variable.)"
113 :group 'gnus-thread
114 :type '(choice (const :tag "off" nil)
115 (const none)
116 (const dummy)
117 (const adopt)
118 (const empty)))
120 (defcustom gnus-summary-make-false-root-always nil
121 "Always make a false dummy root."
122 :version "21.4"
123 :group 'gnus-thread
124 :type 'boolean)
126 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
127 "*A regexp to match subjects to be excluded from loose thread gathering.
128 As loose thread gathering is done on subjects only, that means that
129 there can be many false gatherings performed. By rooting out certain
130 common subjects, gathering might become saner."
131 :group 'gnus-thread
132 :type 'regexp)
134 (defcustom gnus-summary-gather-subject-limit nil
135 "*Maximum length of subject comparisons when gathering loose threads.
136 Use nil to compare full subjects. Setting this variable to a low
137 number will help gather threads that have been corrupted by
138 newsreaders chopping off subject lines, but it might also mean that
139 unrelated articles that have subject that happen to begin with the
140 same few characters will be incorrectly gathered.
142 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
143 comparing subjects."
144 :group 'gnus-thread
145 :type '(choice (const :tag "off" nil)
146 (const fuzzy)
147 (sexp :menu-tag "on" t)))
149 (defcustom gnus-simplify-subject-functions nil
150 "List of functions taking a string argument that simplify subjects.
151 The functions are applied recursively.
153 Useful functions to put in this list include:
154 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
155 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
156 :group 'gnus-thread
157 :type '(repeat function))
159 (defcustom gnus-simplify-ignored-prefixes nil
160 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
161 :group 'gnus-thread
162 :type '(choice (const :tag "off" nil)
163 regexp))
165 (defcustom gnus-build-sparse-threads nil
166 "*If non-nil, fill in the gaps in threads.
167 If `some', only fill in the gaps that are needed to tie loose threads
168 together. If `more', fill in all leaf nodes that Gnus can find. If
169 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
170 :group 'gnus-thread
171 :type '(choice (const :tag "off" nil)
172 (const some)
173 (const more)
174 (sexp :menu-tag "all" t)))
176 (defcustom gnus-summary-thread-gathering-function
177 'gnus-gather-threads-by-subject
178 "*Function used for gathering loose threads.
179 There are two pre-defined functions: `gnus-gather-threads-by-subject',
180 which only takes Subjects into consideration; and
181 `gnus-gather-threads-by-references', which compared the References
182 headers of the articles to find matches."
183 :group 'gnus-thread
184 :type '(radio (function-item gnus-gather-threads-by-subject)
185 (function-item gnus-gather-threads-by-references)
186 (function :tag "other")))
188 (defcustom gnus-summary-same-subject ""
189 "*String indicating that the current article has the same subject as the previous.
190 This variable will only be used if the value of
191 `gnus-summary-make-false-root' is `empty'."
192 :group 'gnus-summary-format
193 :type 'string)
195 (defcustom gnus-summary-goto-unread t
196 "*If t, many commands will go to the next unread article.
197 This applies to marking commands as well as other commands that
198 \"naturally\" select the next article, like, for instance, `SPC' at
199 the end of an article.
201 If nil, the marking commands do NOT go to the next unread article
202 \(they go to the next article instead). If `never', commands that
203 usually go to the next unread article, will go to the next article,
204 whether it is read or not."
205 :group 'gnus-summary-marks
206 :link '(custom-manual "(gnus)Setting Marks")
207 :type '(choice (const :tag "off" nil)
208 (const never)
209 (sexp :menu-tag "on" t)))
211 (defcustom gnus-summary-default-score 0
212 "*Default article score level.
213 All scores generated by the score files will be added to this score.
214 If this variable is nil, scoring will be disabled."
215 :group 'gnus-score-default
216 :type '(choice (const :tag "disable")
217 integer))
219 (defcustom gnus-summary-default-high-score 0
220 "*Default threshold for a high scored article.
221 An article will be highlighted as high scored if its score is greater
222 than this score."
223 :version "21.4"
224 :group 'gnus-score-default
225 :type 'integer)
227 (defcustom gnus-summary-default-low-score 0
228 "*Default threshold for a low scored article.
229 An article will be highlighted as low scored if its score is smaller
230 than this score."
231 :version "21.4"
232 :group 'gnus-score-default
233 :type 'integer)
235 (defcustom gnus-summary-zcore-fuzz 0
236 "*Fuzziness factor for the zcore in the summary buffer.
237 Articles with scores closer than this to `gnus-summary-default-score'
238 will not be marked."
239 :group 'gnus-summary-format
240 :type 'integer)
242 (defcustom gnus-simplify-subject-fuzzy-regexp nil
243 "*Strings to be removed when doing fuzzy matches.
244 This can either be a regular expression or list of regular expressions
245 that will be removed from subject strings if fuzzy subject
246 simplification is selected."
247 :group 'gnus-thread
248 :type '(repeat regexp))
250 (defcustom gnus-show-threads t
251 "*If non-nil, display threads in summary mode."
252 :group 'gnus-thread
253 :type 'boolean)
255 (defcustom gnus-thread-hide-subtree nil
256 "*If non-nil, hide all threads initially.
257 This can be a predicate specifier which says which threads to hide.
258 If threads are hidden, you have to run the command
259 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
260 to expose hidden threads."
261 :group 'gnus-thread
262 :type '(radio (sexp :format "Non-nil\n"
263 :match (lambda (widget value)
264 (not (or (consp value) (functionp value))))
265 :value t)
266 (const nil)
267 (sexp :tag "Predicate specifier" :size 0)))
269 (defcustom gnus-thread-hide-killed t
270 "*If non-nil, hide killed threads automatically."
271 :group 'gnus-thread
272 :type 'boolean)
274 (defcustom gnus-thread-ignore-subject t
275 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
276 If nil, articles that have different subjects from their parents will
277 start separate threads."
278 :group 'gnus-thread
279 :type 'boolean)
281 (defcustom gnus-thread-operation-ignore-subject t
282 "*If non-nil, subjects will be ignored when doing thread commands.
283 This affects commands like `gnus-summary-kill-thread' and
284 `gnus-summary-lower-thread'.
286 If this variable is nil, articles in the same thread with different
287 subjects will not be included in the operation in question. If this
288 variable is `fuzzy', only articles that have subjects that are fuzzily
289 equal will be included."
290 :group 'gnus-thread
291 :type '(choice (const :tag "off" nil)
292 (const fuzzy)
293 (sexp :tag "on" t)))
295 (defcustom gnus-thread-indent-level 4
296 "*Number that says how much each sub-thread should be indented."
297 :group 'gnus-thread
298 :type 'integer)
300 (defcustom gnus-auto-extend-newsgroup t
301 "*If non-nil, extend newsgroup forward and backward when requested."
302 :group 'gnus-summary-choose
303 :type 'boolean)
305 (defcustom gnus-auto-select-first t
306 "*If non-nil, select the article under point.
307 Which article this is is controlled by the `gnus-auto-select-subject'
308 variable.
310 If you want to prevent automatic selection of articles in some
311 newsgroups, set the variable to nil in `gnus-select-group-hook'."
312 :group 'gnus-group-select
313 :type '(choice (const :tag "none" nil)
314 (sexp :menu-tag "first" t)))
316 (defcustom gnus-auto-select-subject 'unread
317 "*Says what subject to place under point when entering a group.
319 This variable can either be the symbols `first' (place point on the
320 first subject), `unread' (place point on the subject line of the first
321 unread article), `best' (place point on the subject line of the
322 higest-scored article), `unseen' (place point on the subject line of
323 the first unseen article), 'unseen-or-unread' (place point on the subject
324 line of the first unseen article or, if all article have been seen, on the
325 subject line of the first unread article), or a function to be called to
326 place point on some subject line."
327 :version "21.4"
328 :group 'gnus-group-select
329 :type '(choice (const best)
330 (const unread)
331 (const first)
332 (const unseen)
333 (const unseen-or-unread)))
335 (defcustom gnus-auto-select-next t
336 "*If non-nil, offer to go to the next group from the end of the previous.
337 If the value is t and the next newsgroup is empty, Gnus will exit
338 summary mode and go back to group mode. If the value is neither nil
339 nor t, Gnus will select the following unread newsgroup. In
340 particular, if the value is the symbol `quietly', the next unread
341 newsgroup will be selected without any confirmation, and if it is
342 `almost-quietly', the next group will be selected without any
343 confirmation if you are located on the last article in the group.
344 Finally, if this variable is `slightly-quietly', the `\\<gnus-summary-mode-map>\\[gnus-summary-catchup-and-goto-next-group]' command
345 will go to the next group without confirmation."
346 :group 'gnus-summary-maneuvering
347 :type '(choice (const :tag "off" nil)
348 (const quietly)
349 (const almost-quietly)
350 (const slightly-quietly)
351 (sexp :menu-tag "on" t)))
353 (defcustom gnus-auto-select-same nil
354 "*If non-nil, select the next article with the same subject.
355 If there are no more articles with the same subject, go to
356 the first unread article."
357 :group 'gnus-summary-maneuvering
358 :type 'boolean)
360 (defcustom gnus-auto-goto-ignores 'unfetched
361 "*Says how to handle unfetched articles when maneuvering.
363 This variable can either be the symbols nil (maneuver to any
364 article), `undownloaded' (maneuvering while unplugged ignores articles
365 that have not been fetched), `always-undownloaded' (maneuvering always
366 ignores articles that have not been fetched), `unfetched' (maneuvering
367 ignores articles whose headers have not been fetched).
369 NOTE: The list of unfetched articles will always be nil when plugged
370 and, when unplugged, a subset of the undownloaded article list."
371 :version "21.4"
372 :group 'gnus-summary-maneuvering
373 :type '(choice (const :tag "None" nil)
374 (const :tag "Undownloaded when unplugged" undownloaded)
375 (const :tag "Undownloaded" always-undownloaded)
376 (const :tag "Unfetched" unfetched)))
378 (defcustom gnus-summary-check-current nil
379 "*If non-nil, consider the current article when moving.
380 The \"unread\" movement commands will stay on the same line if the
381 current article is unread."
382 :group 'gnus-summary-maneuvering
383 :type 'boolean)
385 (defcustom gnus-auto-center-summary t
386 "*If non-nil, always center the current summary buffer.
387 In particular, if `vertical' do only vertical recentering. If non-nil
388 and non-`vertical', do both horizontal and vertical recentering."
389 :group 'gnus-summary-maneuvering
390 :type '(choice (const :tag "none" nil)
391 (const vertical)
392 (integer :tag "height")
393 (sexp :menu-tag "both" t)))
395 (defvar gnus-auto-center-group t
396 "*If non-nil, always center the group buffer.")
398 (defcustom gnus-show-all-headers nil
399 "*If non-nil, don't hide any headers."
400 :group 'gnus-article-hiding
401 :group 'gnus-article-headers
402 :type 'boolean)
404 (defcustom gnus-summary-ignore-duplicates nil
405 "*If non-nil, ignore articles with identical Message-ID headers."
406 :group 'gnus-summary
407 :type 'boolean)
409 (defcustom gnus-single-article-buffer t
410 "*If non-nil, display all articles in the same buffer.
411 If nil, each group will get its own article buffer."
412 :group 'gnus-article-various
413 :type 'boolean)
415 (defcustom gnus-break-pages t
416 "*If non-nil, do page breaking on articles.
417 The page delimiter is specified by the `gnus-page-delimiter'
418 variable."
419 :group 'gnus-article-various
420 :type 'boolean)
422 (defcustom gnus-move-split-methods nil
423 "*Variable used to suggest where articles are to be moved to.
424 It uses the same syntax as the `gnus-split-methods' variable.
425 However, whereas `gnus-split-methods' specifies file names as targets,
426 this variable specifies group names."
427 :group 'gnus-summary-mail
428 :type '(repeat (choice (list :value (fun) function)
429 (cons :value ("" "") regexp (repeat string))
430 (sexp :value nil))))
432 ;; FIXME: Although the custom type is `character' for the following variables,
433 ;; using multibyte characters (Latin-1, UTF-8) doesn't work. -- rs
435 (defcustom gnus-unread-mark ? ;Whitespace
436 "*Mark used for unread articles."
437 :group 'gnus-summary-marks
438 :type 'character)
440 (defcustom gnus-ticked-mark ?!
441 "*Mark used for ticked articles."
442 :group 'gnus-summary-marks
443 :type 'character)
445 (defcustom gnus-dormant-mark ??
446 "*Mark used for dormant articles."
447 :group 'gnus-summary-marks
448 :type 'character)
450 (defcustom gnus-del-mark ?r
451 "*Mark used for del'd articles."
452 :group 'gnus-summary-marks
453 :type 'character)
455 (defcustom gnus-read-mark ?R
456 "*Mark used for read articles."
457 :group 'gnus-summary-marks
458 :type 'character)
460 (defcustom gnus-expirable-mark ?E
461 "*Mark used for expirable articles."
462 :group 'gnus-summary-marks
463 :type 'character)
465 (defcustom gnus-killed-mark ?K
466 "*Mark used for killed articles."
467 :group 'gnus-summary-marks
468 :type 'character)
470 (defcustom gnus-spam-mark ?$
471 "*Mark used for spam articles."
472 :version "21.4"
473 :group 'gnus-summary-marks
474 :type 'character)
476 (defcustom gnus-souped-mark ?F
477 "*Mark used for souped articles."
478 :group 'gnus-summary-marks
479 :type 'character)
481 (defcustom gnus-kill-file-mark ?X
482 "*Mark used for articles killed by kill files."
483 :group 'gnus-summary-marks
484 :type 'character)
486 (defcustom gnus-low-score-mark ?Y
487 "*Mark used for articles with a low score."
488 :group 'gnus-summary-marks
489 :type 'character)
491 (defcustom gnus-catchup-mark ?C
492 "*Mark used for articles that are caught up."
493 :group 'gnus-summary-marks
494 :type 'character)
496 (defcustom gnus-replied-mark ?A
497 "*Mark used for articles that have been replied to."
498 :group 'gnus-summary-marks
499 :type 'character)
501 (defcustom gnus-forwarded-mark ?F
502 "*Mark used for articles that have been forwarded."
503 :version "21.4"
504 :group 'gnus-summary-marks
505 :type 'character)
507 (defcustom gnus-recent-mark ?N
508 "*Mark used for articles that are recent."
509 :version "21.4"
510 :group 'gnus-summary-marks
511 :type 'character)
513 (defcustom gnus-cached-mark ?*
514 "*Mark used for articles that are in the cache."
515 :group 'gnus-summary-marks
516 :type 'character)
518 (defcustom gnus-saved-mark ?S
519 "*Mark used for articles that have been saved."
520 :group 'gnus-summary-marks
521 :type 'character)
523 (defcustom gnus-unseen-mark ?.
524 "*Mark used for articles that haven't been seen."
525 :version "21.4"
526 :group 'gnus-summary-marks
527 :type 'character)
529 (defcustom gnus-no-mark ? ;Whitespace
530 "*Mark used for articles that have no other secondary mark."
531 :version "21.4"
532 :group 'gnus-summary-marks
533 :type 'character)
535 (defcustom gnus-ancient-mark ?O
536 "*Mark used for ancient articles."
537 :group 'gnus-summary-marks
538 :type 'character)
540 (defcustom gnus-sparse-mark ?Q
541 "*Mark used for sparsely reffed articles."
542 :group 'gnus-summary-marks
543 :type 'character)
545 (defcustom gnus-canceled-mark ?G
546 "*Mark used for canceled articles."
547 :group 'gnus-summary-marks
548 :type 'character)
550 (defcustom gnus-duplicate-mark ?M
551 "*Mark used for duplicate articles."
552 :group 'gnus-summary-marks
553 :type 'character)
555 (defcustom gnus-undownloaded-mark ?-
556 "*Mark used for articles that weren't downloaded."
557 :version "21.4"
558 :group 'gnus-summary-marks
559 :type 'character)
561 (defcustom gnus-downloaded-mark ?+
562 "*Mark used for articles that were downloaded."
563 :group 'gnus-summary-marks
564 :type 'character)
566 (defcustom gnus-downloadable-mark ?%
567 "*Mark used for articles that are to be downloaded."
568 :group 'gnus-summary-marks
569 :type 'character)
571 (defcustom gnus-unsendable-mark ?=
572 "*Mark used for articles that won't be sent."
573 :group 'gnus-summary-marks
574 :type 'character)
576 (defcustom gnus-score-over-mark ?+
577 "*Score mark used for articles with high scores."
578 :group 'gnus-summary-marks
579 :type 'character)
581 (defcustom gnus-score-below-mark ?-
582 "*Score mark used for articles with low scores."
583 :group 'gnus-summary-marks
584 :type 'character)
586 (defcustom gnus-empty-thread-mark ? ;Whitespace
587 "*There is no thread under the article."
588 :group 'gnus-summary-marks
589 :type 'character)
591 (defcustom gnus-not-empty-thread-mark ?=
592 "*There is a thread under the article."
593 :group 'gnus-summary-marks
594 :type 'character)
596 (defcustom gnus-view-pseudo-asynchronously nil
597 "*If non-nil, Gnus will view pseudo-articles asynchronously."
598 :group 'gnus-extract-view
599 :type 'boolean)
601 (defcustom gnus-auto-expirable-marks
602 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
603 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
604 gnus-souped-mark gnus-duplicate-mark)
605 "*The list of marks converted into expiration if a group is auto-expirable."
606 :version "21.1"
607 :group 'gnus-summary
608 :type '(repeat character))
610 (defcustom gnus-inhibit-user-auto-expire t
611 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
612 :version "21.1"
613 :group 'gnus-summary
614 :type 'boolean)
616 (defcustom gnus-view-pseudos nil
617 "*If `automatic', pseudo-articles will be viewed automatically.
618 If `not-confirm', pseudos will be viewed automatically, and the user
619 will not be asked to confirm the command."
620 :group 'gnus-extract-view
621 :type '(choice (const :tag "off" nil)
622 (const automatic)
623 (const not-confirm)))
625 (defcustom gnus-view-pseudos-separately t
626 "*If non-nil, one pseudo-article will be created for each file to be viewed.
627 If nil, all files that use the same viewing command will be given as a
628 list of parameters to that command."
629 :group 'gnus-extract-view
630 :type 'boolean)
632 (defcustom gnus-insert-pseudo-articles t
633 "*If non-nil, insert pseudo-articles when decoding articles."
634 :group 'gnus-extract-view
635 :type 'boolean)
637 (defcustom gnus-summary-dummy-line-format
638 " %(: :%) %S\n"
639 "*The format specification for the dummy roots in the summary buffer.
640 It works along the same lines as a normal formatting string,
641 with some simple extensions.
643 %S The subject
645 General format specifiers can also be used.
646 See `(gnus)Formatting Variables'."
647 :link '(custom-manual "(gnus)Formatting Variables")
648 :group 'gnus-threading
649 :type 'string)
651 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
652 "*The format specification for the summary mode line.
653 It works along the same lines as a normal formatting string,
654 with some simple extensions:
656 %G Group name
657 %p Unprefixed group name
658 %A Current article number
659 %z Current article score
660 %V Gnus version
661 %U Number of unread articles in the group
662 %e Number of unselected articles in the group
663 %Z A string with unread/unselected article counts
664 %g Shortish group name
665 %S Subject of the current article
666 %u User-defined spec
667 %s Current score file name
668 %d Number of dormant articles
669 %r Number of articles that have been marked as read in this session
670 %E Number of articles expunged by the score files"
671 :group 'gnus-summary-format
672 :type 'string)
674 (defcustom gnus-list-identifiers nil
675 "Regexp that matches list identifiers to be removed from subject.
676 This can also be a list of regexps."
677 :version "21.1"
678 :group 'gnus-summary-format
679 :group 'gnus-article-hiding
680 :type '(choice (const :tag "none" nil)
681 (regexp :value ".*")
682 (repeat :value (".*") regexp)))
684 (defcustom gnus-summary-mark-below 0
685 "*Mark all articles with a score below this variable as read.
686 This variable is local to each summary buffer and usually set by the
687 score file."
688 :group 'gnus-score-default
689 :type 'integer)
691 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
692 "*List of functions used for sorting articles in the summary buffer.
694 Each function takes two articles and returns non-nil if the first
695 article should be sorted before the other. If you use more than one
696 function, the primary sort function should be the last. You should
697 probably always include `gnus-article-sort-by-number' in the list of
698 sorting functions -- preferably first. Also note that sorting by date
699 is often much slower than sorting by number, and the sorting order is
700 very similar. (Sorting by date means sorting by the time the message
701 was sent, sorting by number means sorting by arrival time.)
703 Ready-made functions include `gnus-article-sort-by-number',
704 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
705 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
706 and `gnus-article-sort-by-score'.
708 When threading is turned on, the variable `gnus-thread-sort-functions'
709 controls how articles are sorted."
710 :group 'gnus-summary-sort
711 :type '(repeat (choice (function-item gnus-article-sort-by-number)
712 (function-item gnus-article-sort-by-author)
713 (function-item gnus-article-sort-by-subject)
714 (function-item gnus-article-sort-by-date)
715 (function-item gnus-article-sort-by-score)
716 (function-item gnus-article-sort-by-random)
717 (function :tag "other"))))
719 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
720 "*List of functions used for sorting threads in the summary buffer.
721 By default, threads are sorted by article number.
723 Each function takes two threads and returns non-nil if the first
724 thread should be sorted before the other. If you use more than one
725 function, the primary sort function should be the last. You should
726 probably always include `gnus-thread-sort-by-number' in the list of
727 sorting functions -- preferably first. Also note that sorting by date
728 is often much slower than sorting by number, and the sorting order is
729 very similar. (Sorting by date means sorting by the time the message
730 was sent, sorting by number means sorting by arrival time.)
732 Ready-made functions include `gnus-thread-sort-by-number',
733 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
734 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
735 `gnus-thread-sort-by-most-recent-number',
736 `gnus-thread-sort-by-most-recent-date',
737 `gnus-thread-sort-by-random', and
738 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
740 When threading is turned off, the variable
741 `gnus-article-sort-functions' controls how articles are sorted."
742 :group 'gnus-summary-sort
743 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
744 (function-item gnus-thread-sort-by-author)
745 (function-item gnus-thread-sort-by-subject)
746 (function-item gnus-thread-sort-by-date)
747 (function-item gnus-thread-sort-by-score)
748 (function-item gnus-thread-sort-by-total-score)
749 (function-item gnus-thread-sort-by-random)
750 (function :tag "other"))))
752 (defcustom gnus-thread-score-function '+
753 "*Function used for calculating the total score of a thread.
755 The function is called with the scores of the article and each
756 subthread and should then return the score of the thread.
758 Some functions you can use are `+', `max', or `min'."
759 :group 'gnus-summary-sort
760 :type 'function)
762 (defcustom gnus-summary-expunge-below nil
763 "All articles that have a score less than this variable will be expunged.
764 This variable is local to the summary buffers."
765 :group 'gnus-score-default
766 :type '(choice (const :tag "off" nil)
767 integer))
769 (defcustom gnus-thread-expunge-below nil
770 "All threads that have a total score less than this variable will be expunged.
771 See `gnus-thread-score-function' for en explanation of what a
772 \"thread score\" is.
774 This variable is local to the summary buffers."
775 :group 'gnus-threading
776 :group 'gnus-score-default
777 :type '(choice (const :tag "off" nil)
778 integer))
780 (defcustom gnus-summary-mode-hook nil
781 "*A hook for Gnus summary mode.
782 This hook is run before any variables are set in the summary buffer."
783 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
784 :group 'gnus-summary-various
785 :type 'hook)
787 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
788 (when (featurep 'xemacs)
789 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
790 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
791 (add-hook 'gnus-summary-mode-hook
792 'gnus-xmas-switch-horizontal-scrollbar-off))
794 (defcustom gnus-summary-menu-hook nil
795 "*Hook run after the creation of the summary mode menu."
796 :group 'gnus-summary-visual
797 :type 'hook)
799 (defcustom gnus-summary-exit-hook nil
800 "*A hook called on exit from the summary buffer.
801 It will be called with point in the group buffer."
802 :group 'gnus-summary-exit
803 :type 'hook)
805 (defcustom gnus-summary-prepare-hook nil
806 "*A hook called after the summary buffer has been generated.
807 If you want to modify the summary buffer, you can use this hook."
808 :group 'gnus-summary-various
809 :type 'hook)
811 (defcustom gnus-summary-prepared-hook nil
812 "*A hook called as the last thing after the summary buffer has been generated."
813 :group 'gnus-summary-various
814 :type 'hook)
816 (defcustom gnus-summary-generate-hook nil
817 "*A hook run just before generating the summary buffer.
818 This hook is commonly used to customize threading variables and the
819 like."
820 :group 'gnus-summary-various
821 :type 'hook)
823 (defcustom gnus-select-group-hook nil
824 "*A hook called when a newsgroup is selected.
826 If you'd like to simplify subjects like the
827 `gnus-summary-next-same-subject' command does, you can use the
828 following hook:
830 (add-hook gnus-select-group-hook
831 (lambda ()
832 (mapcar (lambda (header)
833 (mail-header-set-subject
834 header
835 (gnus-simplify-subject
836 (mail-header-subject header) 're-only)))
837 gnus-newsgroup-headers)))"
838 :group 'gnus-group-select
839 :type 'hook)
841 (defcustom gnus-select-article-hook nil
842 "*A hook called when an article is selected."
843 :group 'gnus-summary-choose
844 :options '(gnus-agent-fetch-selected-article)
845 :type 'hook)
847 (defcustom gnus-visual-mark-article-hook
848 (list 'gnus-highlight-selected-summary)
849 "*Hook run after selecting an article in the summary buffer.
850 It is meant to be used for highlighting the article in some way. It
851 is not run if `gnus-visual' is nil."
852 :group 'gnus-summary-visual
853 :type 'hook)
855 (defcustom gnus-parse-headers-hook nil
856 "*A hook called before parsing the headers."
857 :group 'gnus-various
858 :type 'hook)
860 (defcustom gnus-exit-group-hook nil
861 "*A hook called when exiting summary mode.
862 This hook is not called from the non-updating exit commands like `Q'."
863 :group 'gnus-various
864 :type 'hook)
866 (defcustom gnus-summary-update-hook
867 (list 'gnus-summary-highlight-line)
868 "*A hook called when a summary line is changed.
869 The hook will not be called if `gnus-visual' is nil.
871 The default function `gnus-summary-highlight-line' will
872 highlight the line according to the `gnus-summary-highlight'
873 variable."
874 :group 'gnus-summary-visual
875 :type 'hook)
877 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
878 "*A hook called when an article is selected for the first time.
879 The hook is intended to mark an article as read (or unread)
880 automatically when it is selected."
881 :group 'gnus-summary-choose
882 :type 'hook)
884 (defcustom gnus-group-no-more-groups-hook nil
885 "*A hook run when returning to group mode having no more (unread) groups."
886 :group 'gnus-group-select
887 :type 'hook)
889 (defcustom gnus-ps-print-hook nil
890 "*A hook run before ps-printing something from Gnus."
891 :group 'gnus-summary
892 :type 'hook)
894 (defcustom gnus-summary-article-move-hook nil
895 "*A hook called after an article is moved, copied, respooled, or crossposted."
896 :version "21.4"
897 :group 'gnus-summary
898 :type 'hook)
900 (defcustom gnus-summary-article-delete-hook nil
901 "*A hook called after an article is deleted."
902 :version "21.4"
903 :group 'gnus-summary
904 :type 'hook)
906 (defcustom gnus-summary-article-expire-hook nil
907 "*A hook called after an article is expired."
908 :version "21.4"
909 :group 'gnus-summary
910 :type 'hook)
912 (defcustom gnus-summary-display-arrow
913 (and (fboundp 'display-graphic-p)
914 (display-graphic-p))
915 "*If non-nil, display an arrow highlighting the current article."
916 :version "21.4"
917 :group 'gnus-summary
918 :type 'boolean)
920 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
921 "Face used for highlighting the current article in the summary buffer."
922 :group 'gnus-summary-visual
923 :type 'face)
925 (defvar gnus-tmp-downloaded nil)
927 (defcustom gnus-summary-highlight
928 '(((eq mark gnus-canceled-mark)
929 . gnus-summary-cancelled-face)
930 ((and uncached (> score default-high))
931 . gnus-summary-high-undownloaded-face)
932 ((and uncached (< score default-low))
933 . gnus-summary-low-undownloaded-face)
934 (uncached
935 . gnus-summary-normal-undownloaded-face)
936 ((and (> score default-high)
937 (or (eq mark gnus-dormant-mark)
938 (eq mark gnus-ticked-mark)))
939 . gnus-summary-high-ticked-face)
940 ((and (< score default-low)
941 (or (eq mark gnus-dormant-mark)
942 (eq mark gnus-ticked-mark)))
943 . gnus-summary-low-ticked-face)
944 ((or (eq mark gnus-dormant-mark)
945 (eq mark gnus-ticked-mark))
946 . gnus-summary-normal-ticked-face)
947 ((and (> score default-high) (eq mark gnus-ancient-mark))
948 . gnus-summary-high-ancient-face)
949 ((and (< score default-low) (eq mark gnus-ancient-mark))
950 . gnus-summary-low-ancient-face)
951 ((eq mark gnus-ancient-mark)
952 . gnus-summary-normal-ancient-face)
953 ((and (> score default-high) (eq mark gnus-unread-mark))
954 . gnus-summary-high-unread-face)
955 ((and (< score default-low) (eq mark gnus-unread-mark))
956 . gnus-summary-low-unread-face)
957 ((eq mark gnus-unread-mark)
958 . gnus-summary-normal-unread-face)
959 ((> score default-high)
960 . gnus-summary-high-read-face)
961 ((< score default-low)
962 . gnus-summary-low-read-face)
964 . gnus-summary-normal-read-face))
965 "*Controls the highlighting of summary buffer lines.
967 A list of (FORM . FACE) pairs. When deciding how a a particular
968 summary line should be displayed, each form is evaluated. The content
969 of the face field after the first true form is used. You can change
970 how those summary lines are displayed, by editing the face field.
972 You can use the following variables in the FORM field.
974 score: The article's score
975 default: The default article score.
976 default-high: The default score for high scored articles.
977 default-low: The default score for low scored articles.
978 below: The score below which articles are automatically marked as read.
979 mark: The article's mark.
980 uncached: Non-nil if the article is uncached."
981 :group 'gnus-summary-visual
982 :type '(repeat (cons (sexp :tag "Form" nil)
983 face)))
985 (defcustom gnus-alter-header-function nil
986 "Function called to allow alteration of article header structures.
987 The function is called with one parameter, the article header vector,
988 which it may alter in any way."
989 :type '(choice (const :tag "None" nil)
990 function)
991 :group 'gnus-summary)
993 (defvar gnus-decode-encoded-word-function 'mail-decode-encoded-word-string
994 "Variable that says which function should be used to decode a string with encoded words.")
996 (defcustom gnus-extra-headers '(To Newsgroups)
997 "*Extra headers to parse."
998 :version "21.1"
999 :group 'gnus-summary
1000 :type '(repeat symbol))
1002 (defcustom gnus-ignored-from-addresses
1003 (and user-mail-address (regexp-quote user-mail-address))
1004 "*Regexp of From headers that may be suppressed in favor of To headers."
1005 :version "21.1"
1006 :group 'gnus-summary
1007 :type 'regexp)
1009 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
1010 "List of charsets that should be ignored.
1011 When these charsets are used in the \"charset\" parameter, the
1012 default charset will be used instead."
1013 :version "21.1"
1014 :type '(repeat symbol)
1015 :group 'gnus-charset)
1017 (gnus-define-group-parameter
1018 ignored-charsets
1019 :type list
1020 :function-document
1021 "Return the ignored charsets of GROUP."
1022 :variable gnus-group-ignored-charsets-alist
1023 :variable-default
1024 '(("alt\\.chinese\\.text" iso-8859-1))
1025 :variable-document
1026 "Alist of regexps (to match group names) and charsets that should be ignored.
1027 When these charsets are used in the \"charset\" parameter, the
1028 default charset will be used instead."
1029 :variable-group gnus-charset
1030 :variable-type '(repeat (cons (regexp :tag "Group")
1031 (repeat symbol)))
1032 :parameter-type '(choice :tag "Ignored charsets"
1033 :value nil
1034 (repeat (symbol)))
1035 :parameter-document "\
1036 List of charsets that should be ignored.
1038 When these charsets are used in the \"charset\" parameter, the
1039 default charset will be used instead.")
1041 (defcustom gnus-group-highlight-words-alist nil
1042 "Alist of group regexps and highlight regexps.
1043 This variable uses the same syntax as `gnus-emphasis-alist'."
1044 :version "21.1"
1045 :type '(repeat (cons (regexp :tag "Group")
1046 (repeat (list (regexp :tag "Highlight regexp")
1047 (number :tag "Group for entire word" 0)
1048 (number :tag "Group for displayed part" 0)
1049 (symbol :tag "Face"
1050 gnus-emphasis-highlight-words)))))
1051 :group 'gnus-summary-visual)
1053 (defcustom gnus-summary-show-article-charset-alist
1055 "Alist of number and charset.
1056 The article will be shown with the charset corresponding to the
1057 numbered argument.
1058 For example: ((1 . cn-gb-2312) (2 . big5))."
1059 :version "21.1"
1060 :type '(repeat (cons (number :tag "Argument" 1)
1061 (symbol :tag "Charset")))
1062 :group 'gnus-charset)
1064 (defcustom gnus-preserve-marks t
1065 "Whether marks are preserved when moving, copying and respooling messages."
1066 :version "21.1"
1067 :type 'boolean
1068 :group 'gnus-summary-marks)
1070 (defcustom gnus-alter-articles-to-read-function nil
1071 "Function to be called to alter the list of articles to be selected."
1072 :type '(choice (const nil) function)
1073 :group 'gnus-summary)
1075 (defcustom gnus-orphan-score nil
1076 "*All orphans get this score added. Set in the score file."
1077 :group 'gnus-score-default
1078 :type '(choice (const nil)
1079 integer))
1081 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1082 "*A regexp to match MIME parts when saving multiple parts of a
1083 message with `gnus-summary-save-parts' (\\<gnus-summary-mode-map>\\[gnus-summary-save-parts]).
1084 This regexp will be used by default when prompting the user for which
1085 type of files to save."
1086 :group 'gnus-summary
1087 :type 'regexp)
1089 (defcustom gnus-read-all-available-headers nil
1090 "Whether Gnus should parse all headers made available to it.
1091 This is mostly relevant for slow back ends where the user may
1092 wish to widen the summary buffer to include all headers
1093 that were fetched. Say, for nnultimate groups."
1094 :version "21.4"
1095 :group 'gnus-summary
1096 :type '(choice boolean regexp))
1098 (defcustom gnus-summary-muttprint-program "muttprint"
1099 "Command (and optional arguments) used to run Muttprint."
1100 :version "21.4"
1101 :group 'gnus-summary
1102 :type 'string)
1104 (defcustom gnus-article-loose-mime nil
1105 "If non-nil, don't require MIME-Version header.
1106 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1107 supply the MIME-Version header or deliberately strip it from the mail.
1108 Set it to non-nil, Gnus will treat some articles as MIME even if
1109 the MIME-Version header is missed."
1110 :version "21.4"
1111 :type 'boolean
1112 :group 'gnus-article-mime)
1114 (defcustom gnus-article-emulate-mime t
1115 "If non-nil, use MIME emulation for uuencode and the like.
1116 This means that Gnus will search message bodies for text that look
1117 like uuencoded bits, yEncoded bits, and so on, and present that using
1118 the normal Gnus MIME machinery."
1119 :version "21.4"
1120 :type 'boolean
1121 :group 'gnus-article-mime)
1123 ;;; Internal variables
1125 (defvar gnus-summary-display-cache nil)
1126 (defvar gnus-article-mime-handles nil)
1127 (defvar gnus-article-decoded-p nil)
1128 (defvar gnus-article-charset nil)
1129 (defvar gnus-article-ignored-charsets nil)
1130 (defvar gnus-scores-exclude-files nil)
1131 (defvar gnus-page-broken nil)
1133 (defvar gnus-original-article nil)
1134 (defvar gnus-article-internal-prepare-hook nil)
1135 (defvar gnus-newsgroup-process-stack nil)
1137 (defvar gnus-thread-indent-array nil)
1138 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1139 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1140 "Function called to sort the articles within a thread after it has been gathered together.")
1142 (defvar gnus-summary-save-parts-type-history nil)
1143 (defvar gnus-summary-save-parts-last-directory mm-default-directory)
1145 ;; Avoid highlighting in kill files.
1146 (defvar gnus-summary-inhibit-highlight nil)
1147 (defvar gnus-newsgroup-selected-overlay nil)
1148 (defvar gnus-inhibit-limiting nil)
1149 (defvar gnus-newsgroup-adaptive-score-file nil)
1150 (defvar gnus-current-score-file nil)
1151 (defvar gnus-current-move-group nil)
1152 (defvar gnus-current-copy-group nil)
1153 (defvar gnus-current-crosspost-group nil)
1154 (defvar gnus-newsgroup-display nil)
1156 (defvar gnus-newsgroup-dependencies nil)
1157 (defvar gnus-newsgroup-adaptive nil)
1158 (defvar gnus-summary-display-article-function nil)
1159 (defvar gnus-summary-highlight-line-function nil
1160 "Function called after highlighting a summary line.")
1162 (defvar gnus-summary-line-format-alist
1163 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1164 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1165 (?s gnus-tmp-subject-or-nil ?s)
1166 (?n gnus-tmp-name ?s)
1167 (?A (car (cdr (funcall gnus-extract-address-components gnus-tmp-from)))
1169 (?a (or (car (funcall gnus-extract-address-components gnus-tmp-from))
1170 gnus-tmp-from) ?s)
1171 (?F gnus-tmp-from ?s)
1172 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1173 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1174 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1175 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1176 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1177 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1178 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1179 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1180 (?L gnus-tmp-lines ?s)
1181 (?O gnus-tmp-downloaded ?c)
1182 (?I gnus-tmp-indentation ?s)
1183 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1184 (?R gnus-tmp-replied ?c)
1185 (?\[ gnus-tmp-opening-bracket ?c)
1186 (?\] gnus-tmp-closing-bracket ?c)
1187 (?\> (make-string gnus-tmp-level ? ) ?s)
1188 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1189 (?i gnus-tmp-score ?d)
1190 (?z gnus-tmp-score-char ?c)
1191 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1192 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1193 (?U gnus-tmp-unread ?c)
1194 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1196 (?t (gnus-summary-number-of-articles-in-thread
1197 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1199 (?e (gnus-summary-number-of-articles-in-thread
1200 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1202 (?u gnus-tmp-user-defined ?s)
1203 (?P (gnus-pick-line-number) ?d)
1204 (?B gnus-tmp-thread-tree-header-string ?s)
1205 (user-date (gnus-user-date
1206 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1207 "An alist of format specifications that can appear in summary lines.
1208 These are paired with what variables they correspond with, along with
1209 the type of the variable (string, integer, character, etc).")
1211 (defvar gnus-summary-dummy-line-format-alist
1212 `((?S gnus-tmp-subject ?s)
1213 (?N gnus-tmp-number ?d)
1214 (?u gnus-tmp-user-defined ?s)))
1216 (defvar gnus-summary-mode-line-format-alist
1217 `((?G gnus-tmp-group-name ?s)
1218 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1219 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1220 (?A gnus-tmp-article-number ?d)
1221 (?Z gnus-tmp-unread-and-unselected ?s)
1222 (?V gnus-version ?s)
1223 (?U gnus-tmp-unread-and-unticked ?d)
1224 (?S gnus-tmp-subject ?s)
1225 (?e gnus-tmp-unselected ?d)
1226 (?u gnus-tmp-user-defined ?s)
1227 (?d (length gnus-newsgroup-dormant) ?d)
1228 (?t (length gnus-newsgroup-marked) ?d)
1229 (?h (length gnus-newsgroup-spam-marked) ?d)
1230 (?r (length gnus-newsgroup-reads) ?d)
1231 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1232 (?E gnus-newsgroup-expunged-tally ?d)
1233 (?s (gnus-current-score-file-nondirectory) ?s)))
1235 (defvar gnus-last-search-regexp nil
1236 "Default regexp for article search command.")
1238 (defvar gnus-last-shell-command nil
1239 "Default shell command on article.")
1241 (defvar gnus-newsgroup-agentized nil
1242 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1243 (defvar gnus-newsgroup-begin nil)
1244 (defvar gnus-newsgroup-end nil)
1245 (defvar gnus-newsgroup-last-rmail nil)
1246 (defvar gnus-newsgroup-last-mail nil)
1247 (defvar gnus-newsgroup-last-folder nil)
1248 (defvar gnus-newsgroup-last-file nil)
1249 (defvar gnus-newsgroup-auto-expire nil)
1250 (defvar gnus-newsgroup-active nil)
1252 (defvar gnus-newsgroup-data nil)
1253 (defvar gnus-newsgroup-data-reverse nil)
1254 (defvar gnus-newsgroup-limit nil)
1255 (defvar gnus-newsgroup-limits nil)
1256 (defvar gnus-summary-use-undownloaded-faces nil)
1258 (defvar gnus-newsgroup-unreads nil
1259 "Sorted list of unread articles in the current newsgroup.")
1261 (defvar gnus-newsgroup-unselected nil
1262 "Sorted list of unselected unread articles in the current newsgroup.")
1264 (defvar gnus-newsgroup-reads nil
1265 "Alist of read articles and article marks in the current newsgroup.")
1267 (defvar gnus-newsgroup-expunged-tally nil)
1269 (defvar gnus-newsgroup-marked nil
1270 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1272 (defvar gnus-newsgroup-spam-marked nil
1273 "List of ranges of articles that have been marked as spam.")
1275 (defvar gnus-newsgroup-killed nil
1276 "List of ranges of articles that have been through the scoring process.")
1278 (defvar gnus-newsgroup-cached nil
1279 "Sorted list of articles that come from the article cache.")
1281 (defvar gnus-newsgroup-saved nil
1282 "List of articles that have been saved.")
1284 (defvar gnus-newsgroup-kill-headers nil)
1286 (defvar gnus-newsgroup-replied nil
1287 "List of articles that have been replied to in the current newsgroup.")
1289 (defvar gnus-newsgroup-forwarded nil
1290 "List of articles that have been forwarded in the current newsgroup.")
1292 (defvar gnus-newsgroup-recent nil
1293 "List of articles that have are recent in the current newsgroup.")
1295 (defvar gnus-newsgroup-expirable nil
1296 "Sorted list of articles in the current newsgroup that can be expired.")
1298 (defvar gnus-newsgroup-processable nil
1299 "List of articles in the current newsgroup that can be processed.")
1301 (defvar gnus-newsgroup-downloadable nil
1302 "Sorted list of articles in the current newsgroup that can be processed.")
1304 (defvar gnus-newsgroup-unfetched nil
1305 "Sorted list of articles in the current newsgroup whose headers have
1306 not been fetched into the agent.
1308 This list will always be a subset of gnus-newsgroup-undownloaded.")
1310 (defvar gnus-newsgroup-undownloaded nil
1311 "List of articles in the current newsgroup that haven't been downloaded.")
1313 (defvar gnus-newsgroup-unsendable nil
1314 "List of articles in the current newsgroup that won't be sent.")
1316 (defvar gnus-newsgroup-bookmarks nil
1317 "List of articles in the current newsgroup that have bookmarks.")
1319 (defvar gnus-newsgroup-dormant nil
1320 "Sorted list of dormant articles in the current newsgroup.")
1322 (defvar gnus-newsgroup-unseen nil
1323 "List of unseen articles in the current newsgroup.")
1325 (defvar gnus-newsgroup-seen nil
1326 "Range of seen articles in the current newsgroup.")
1328 (defvar gnus-newsgroup-articles nil
1329 "List of articles in the current newsgroup.")
1331 (defvar gnus-newsgroup-scored nil
1332 "List of scored articles in the current newsgroup.")
1334 (defvar gnus-newsgroup-headers nil
1335 "List of article headers in the current newsgroup.")
1337 (defvar gnus-newsgroup-threads nil)
1339 (defvar gnus-newsgroup-prepared nil
1340 "Whether the current group has been prepared properly.")
1342 (defvar gnus-newsgroup-ancient nil
1343 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1345 (defvar gnus-newsgroup-sparse nil)
1347 (defvar gnus-current-article nil)
1348 (defvar gnus-article-current nil)
1349 (defvar gnus-current-headers nil)
1350 (defvar gnus-have-all-headers nil)
1351 (defvar gnus-last-article nil)
1352 (defvar gnus-newsgroup-history nil)
1353 (defvar gnus-newsgroup-charset nil)
1354 (defvar gnus-newsgroup-ephemeral-charset nil)
1355 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1357 (defvar gnus-article-before-search nil)
1359 (defvar gnus-summary-local-variables
1360 '(gnus-newsgroup-name
1361 gnus-newsgroup-begin gnus-newsgroup-end
1362 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1363 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1364 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1365 gnus-newsgroup-unselected gnus-newsgroup-marked
1366 gnus-newsgroup-spam-marked
1367 gnus-newsgroup-reads gnus-newsgroup-saved
1368 gnus-newsgroup-replied gnus-newsgroup-forwarded
1369 gnus-newsgroup-recent
1370 gnus-newsgroup-expirable
1371 gnus-newsgroup-processable gnus-newsgroup-killed
1372 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1373 gnus-newsgroup-unfetched
1374 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1375 gnus-newsgroup-seen gnus-newsgroup-articles
1376 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1377 gnus-newsgroup-headers gnus-newsgroup-threads
1378 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1379 gnus-current-article gnus-current-headers gnus-have-all-headers
1380 gnus-last-article gnus-article-internal-prepare-hook
1381 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1382 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1383 gnus-thread-expunge-below
1384 gnus-score-alist gnus-current-score-file
1385 (gnus-summary-expunge-below . global)
1386 (gnus-summary-mark-below . global)
1387 (gnus-orphan-score . global)
1388 gnus-newsgroup-active gnus-scores-exclude-files
1389 gnus-newsgroup-history gnus-newsgroup-ancient
1390 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1391 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1392 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1393 (gnus-newsgroup-expunged-tally . 0)
1394 gnus-cache-removable-articles gnus-newsgroup-cached
1395 gnus-newsgroup-data gnus-newsgroup-data-reverse
1396 gnus-newsgroup-limit gnus-newsgroup-limits
1397 gnus-newsgroup-charset gnus-newsgroup-display
1398 gnus-summary-use-undownloaded-faces)
1399 "Variables that are buffer-local to the summary buffers.")
1401 (defvar gnus-newsgroup-variables nil
1402 "A list of variables that have separate values in different newsgroups.
1403 A list of newsgroup (summary buffer) local variables, or cons of
1404 variables and their default expressions to be evalled (when the default
1405 values are not nil), that should be made global while the summary buffer
1406 is active.
1408 Note: The default expressions will be evaluated (using function `eval')
1409 before assignment to the local variable rather than just assigned to it.
1410 If the default expression is the symbol `global', that symbol will not
1411 be evaluated but the global value of the local variable will be used
1412 instead.
1414 These variables can be used to set variables in the group parameters
1415 while still allowing them to affect operations done in other buffers.
1416 For example:
1418 \(setq gnus-newsgroup-variables
1419 '(message-use-followup-to
1420 (gnus-visible-headers .
1421 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1424 ;; Byte-compiler warning.
1425 (eval-when-compile
1426 ;; Bind features so that require will believe that gnus-sum has
1427 ;; already been loaded (avoids infinite recursion)
1428 (let ((features (cons 'gnus-sum features)))
1429 ;; Several of the declarations in gnus-sum are needed to load the
1430 ;; following files. Right now, these definitions have been
1431 ;; compiled but not defined (evaluated). We could either do a
1432 ;; eval-and-compile about all of the declarations or evaluate the
1433 ;; source file.
1434 (if (boundp 'gnus-newsgroup-variables)
1436 (load "gnus-sum.el" t t t))
1437 (require 'gnus)
1438 (require 'gnus-agent)
1439 (require 'gnus-art)))
1441 ;; MIME stuff.
1443 (defvar gnus-decode-encoded-word-methods
1444 '(mail-decode-encoded-word-string)
1445 "List of methods used to decode encoded words.
1447 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
1448 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
1449 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
1450 whose names match REGEXP.
1452 For example:
1453 \((\"chinese\" . gnus-decode-encoded-word-string-by-guess)
1454 mail-decode-encoded-word-string
1455 (\"chinese\" . rfc1843-decode-string))")
1457 (defvar gnus-decode-encoded-word-methods-cache nil)
1459 (defun gnus-multi-decode-encoded-word-string (string)
1460 "Apply the functions from `gnus-encoded-word-methods' that match."
1461 (unless (and gnus-decode-encoded-word-methods-cache
1462 (eq gnus-newsgroup-name
1463 (car gnus-decode-encoded-word-methods-cache)))
1464 (setq gnus-decode-encoded-word-methods-cache (list gnus-newsgroup-name))
1465 (mapcar (lambda (x)
1466 (if (symbolp x)
1467 (nconc gnus-decode-encoded-word-methods-cache (list x))
1468 (if (and gnus-newsgroup-name
1469 (string-match (car x) gnus-newsgroup-name))
1470 (nconc gnus-decode-encoded-word-methods-cache
1471 (list (cdr x))))))
1472 gnus-decode-encoded-word-methods))
1473 (let ((xlist gnus-decode-encoded-word-methods-cache))
1474 (pop xlist)
1475 (while xlist
1476 (setq string (funcall (pop xlist) string))))
1477 string)
1479 ;; Subject simplification.
1481 (defun gnus-simplify-whitespace (str)
1482 "Remove excessive whitespace from STR."
1483 ;; Multiple spaces.
1484 (while (string-match "[ \t][ \t]+" str)
1485 (setq str (concat (substring str 0 (match-beginning 0))
1487 (substring str (match-end 0)))))
1488 ;; Leading spaces.
1489 (when (string-match "^[ \t]+" str)
1490 (setq str (substring str (match-end 0))))
1491 ;; Trailing spaces.
1492 (when (string-match "[ \t]+$" str)
1493 (setq str (substring str 0 (match-beginning 0))))
1494 str)
1496 (defun gnus-simplify-all-whitespace (str)
1497 "Remove all whitespace from STR."
1498 (while (string-match "[ \t\n]+" str)
1499 (setq str (replace-match "" nil nil str)))
1500 str)
1502 (defsubst gnus-simplify-subject-re (subject)
1503 "Remove \"Re:\" from subject lines."
1504 (if (string-match message-subject-re-regexp subject)
1505 (substring subject (match-end 0))
1506 subject))
1508 (defun gnus-simplify-subject (subject &optional re-only)
1509 "Remove `Re:' and words in parentheses.
1510 If RE-ONLY is non-nil, strip leading `Re:'s only."
1511 (let ((case-fold-search t)) ;Ignore case.
1512 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1513 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1514 (setq subject (substring subject (match-end 0))))
1515 ;; Remove uninteresting prefixes.
1516 (when (and (not re-only)
1517 gnus-simplify-ignored-prefixes
1518 (string-match gnus-simplify-ignored-prefixes subject))
1519 (setq subject (substring subject (match-end 0))))
1520 ;; Remove words in parentheses from end.
1521 (unless re-only
1522 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1523 (setq subject (substring subject 0 (match-beginning 0)))))
1524 ;; Return subject string.
1525 subject))
1527 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1528 ;; all whitespace.
1529 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1530 (goto-char (point-min))
1531 (while (re-search-forward regexp nil t)
1532 (replace-match (or newtext ""))))
1534 (defun gnus-simplify-buffer-fuzzy ()
1535 "Simplify string in the buffer fuzzily.
1536 The string in the accessible portion of the current buffer is simplified.
1537 It is assumed to be a single-line subject.
1538 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1539 matter is removed. Additional things can be deleted by setting
1540 `gnus-simplify-subject-fuzzy-regexp'."
1541 (let ((case-fold-search t)
1542 (modified-tick))
1543 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1545 (while (not (eq modified-tick (buffer-modified-tick)))
1546 (setq modified-tick (buffer-modified-tick))
1547 (cond
1548 ((listp gnus-simplify-subject-fuzzy-regexp)
1549 (mapcar 'gnus-simplify-buffer-fuzzy-step
1550 gnus-simplify-subject-fuzzy-regexp))
1551 (gnus-simplify-subject-fuzzy-regexp
1552 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1553 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1554 (gnus-simplify-buffer-fuzzy-step
1555 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1556 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1558 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1559 (gnus-simplify-buffer-fuzzy-step " +" " ")
1560 (gnus-simplify-buffer-fuzzy-step " $")
1561 (gnus-simplify-buffer-fuzzy-step "^ +")))
1563 (defun gnus-simplify-subject-fuzzy (subject)
1564 "Simplify a subject string fuzzily.
1565 See `gnus-simplify-buffer-fuzzy' for details."
1566 (save-excursion
1567 (gnus-set-work-buffer)
1568 (let ((case-fold-search t))
1569 ;; Remove uninteresting prefixes.
1570 (when (and gnus-simplify-ignored-prefixes
1571 (string-match gnus-simplify-ignored-prefixes subject))
1572 (setq subject (substring subject (match-end 0))))
1573 (insert subject)
1574 (inline (gnus-simplify-buffer-fuzzy))
1575 (buffer-string))))
1577 (defsubst gnus-simplify-subject-fully (subject)
1578 "Simplify a subject string according to `gnus-summary-gather-subject-limit'."
1579 (cond
1580 (gnus-simplify-subject-functions
1581 (gnus-map-function gnus-simplify-subject-functions subject))
1582 ((null gnus-summary-gather-subject-limit)
1583 (gnus-simplify-subject-re subject))
1584 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1585 (gnus-simplify-subject-fuzzy subject))
1586 ((numberp gnus-summary-gather-subject-limit)
1587 (gnus-limit-string (gnus-simplify-subject-re subject)
1588 gnus-summary-gather-subject-limit))
1590 subject)))
1592 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1593 "Check whether two subjects are equal.
1594 If optional argument SIMPLE-FIRST is t, first argument is already
1595 simplified."
1596 (cond
1597 ((null simple-first)
1598 (equal (gnus-simplify-subject-fully s1)
1599 (gnus-simplify-subject-fully s2)))
1601 (equal s1
1602 (gnus-simplify-subject-fully s2)))))
1604 (defun gnus-summary-bubble-group ()
1605 "Increase the score of the current group.
1606 This is a handy function to add to `gnus-summary-exit-hook' to
1607 increase the score of each group you read."
1608 (gnus-group-add-score gnus-newsgroup-name))
1612 ;;; Gnus summary mode
1615 (put 'gnus-summary-mode 'mode-class 'special)
1617 (defvar gnus-article-commands-menu)
1619 ;; Non-orthogonal keys
1621 (gnus-define-keys gnus-summary-mode-map
1622 " " gnus-summary-next-page
1623 "\177" gnus-summary-prev-page
1624 [delete] gnus-summary-prev-page
1625 [backspace] gnus-summary-prev-page
1626 "\r" gnus-summary-scroll-up
1627 "\M-\r" gnus-summary-scroll-down
1628 "n" gnus-summary-next-unread-article
1629 "p" gnus-summary-prev-unread-article
1630 "N" gnus-summary-next-article
1631 "P" gnus-summary-prev-article
1632 "\M-\C-n" gnus-summary-next-same-subject
1633 "\M-\C-p" gnus-summary-prev-same-subject
1634 "\M-n" gnus-summary-next-unread-subject
1635 "\M-p" gnus-summary-prev-unread-subject
1636 "." gnus-summary-first-unread-article
1637 "," gnus-summary-best-unread-article
1638 "\M-s" gnus-summary-search-article-forward
1639 "\M-r" gnus-summary-search-article-backward
1640 "<" gnus-summary-beginning-of-article
1641 ">" gnus-summary-end-of-article
1642 "j" gnus-summary-goto-article
1643 "^" gnus-summary-refer-parent-article
1644 "\M-^" gnus-summary-refer-article
1645 "u" gnus-summary-tick-article-forward
1646 "!" gnus-summary-tick-article-forward
1647 "U" gnus-summary-tick-article-backward
1648 "d" gnus-summary-mark-as-read-forward
1649 "D" gnus-summary-mark-as-read-backward
1650 "E" gnus-summary-mark-as-expirable
1651 "\M-u" gnus-summary-clear-mark-forward
1652 "\M-U" gnus-summary-clear-mark-backward
1653 "k" gnus-summary-kill-same-subject-and-select
1654 "\C-k" gnus-summary-kill-same-subject
1655 "\M-\C-k" gnus-summary-kill-thread
1656 "\M-\C-l" gnus-summary-lower-thread
1657 "e" gnus-summary-edit-article
1658 "#" gnus-summary-mark-as-processable
1659 "\M-#" gnus-summary-unmark-as-processable
1660 "\M-\C-t" gnus-summary-toggle-threads
1661 "\M-\C-s" gnus-summary-show-thread
1662 "\M-\C-h" gnus-summary-hide-thread
1663 "\M-\C-f" gnus-summary-next-thread
1664 "\M-\C-b" gnus-summary-prev-thread
1665 [(meta down)] gnus-summary-next-thread
1666 [(meta up)] gnus-summary-prev-thread
1667 "\M-\C-u" gnus-summary-up-thread
1668 "\M-\C-d" gnus-summary-down-thread
1669 "&" gnus-summary-execute-command
1670 "c" gnus-summary-catchup-and-exit
1671 "\C-w" gnus-summary-mark-region-as-read
1672 "\C-t" gnus-summary-toggle-truncation
1673 "?" gnus-summary-mark-as-dormant
1674 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1675 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1676 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1677 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1678 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1679 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1680 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1681 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1682 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1683 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1684 "=" gnus-summary-expand-window
1685 "\C-x\C-s" gnus-summary-reselect-current-group
1686 "\M-g" gnus-summary-rescan-group
1687 "w" gnus-summary-stop-page-breaking
1688 "\C-c\C-r" gnus-summary-caesar-message
1689 "f" gnus-summary-followup
1690 "F" gnus-summary-followup-with-original
1691 "C" gnus-summary-cancel-article
1692 "r" gnus-summary-reply
1693 "R" gnus-summary-reply-with-original
1694 "\C-c\C-f" gnus-summary-mail-forward
1695 "o" gnus-summary-save-article
1696 "\C-o" gnus-summary-save-article-mail
1697 "|" gnus-summary-pipe-output
1698 "\M-k" gnus-summary-edit-local-kill
1699 "\M-K" gnus-summary-edit-global-kill
1700 ;; "V" gnus-version
1701 "\C-c\C-d" gnus-summary-describe-group
1702 "q" gnus-summary-exit
1703 "Q" gnus-summary-exit-no-update
1704 "\C-c\C-i" gnus-info-find-node
1705 gnus-mouse-2 gnus-mouse-pick-article
1706 "m" gnus-summary-mail-other-window
1707 "a" gnus-summary-post-news
1708 "i" gnus-summary-news-other-window
1709 "x" gnus-summary-limit-to-unread
1710 "s" gnus-summary-isearch-article
1711 "t" gnus-summary-toggle-header
1712 "g" gnus-summary-show-article
1713 "l" gnus-summary-goto-last-article
1714 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1715 "\C-d" gnus-summary-enter-digest-group
1716 "\M-\C-d" gnus-summary-read-document
1717 "\M-\C-e" gnus-summary-edit-parameters
1718 "\M-\C-a" gnus-summary-customize-parameters
1719 "\C-c\C-b" gnus-bug
1720 "*" gnus-cache-enter-article
1721 "\M-*" gnus-cache-remove-article
1722 "\M-&" gnus-summary-universal-argument
1723 "\C-l" gnus-recenter
1724 "I" gnus-summary-increase-score
1725 "L" gnus-summary-lower-score
1726 "\M-i" gnus-symbolic-argument
1727 "h" gnus-summary-select-article-buffer
1729 "b" gnus-article-view-part
1730 "\M-t" gnus-summary-toggle-display-buttonized
1732 "V" gnus-summary-score-map
1733 "X" gnus-uu-extract-map
1734 "S" gnus-summary-send-map)
1736 ;; Sort of orthogonal keymap
1737 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1738 "t" gnus-summary-tick-article-forward
1739 "!" gnus-summary-tick-article-forward
1740 "d" gnus-summary-mark-as-read-forward
1741 "r" gnus-summary-mark-as-read-forward
1742 "c" gnus-summary-clear-mark-forward
1743 " " gnus-summary-clear-mark-forward
1744 "e" gnus-summary-mark-as-expirable
1745 "x" gnus-summary-mark-as-expirable
1746 "?" gnus-summary-mark-as-dormant
1747 "b" gnus-summary-set-bookmark
1748 "B" gnus-summary-remove-bookmark
1749 "#" gnus-summary-mark-as-processable
1750 "\M-#" gnus-summary-unmark-as-processable
1751 "S" gnus-summary-limit-include-expunged
1752 "C" gnus-summary-catchup
1753 "H" gnus-summary-catchup-to-here
1754 "h" gnus-summary-catchup-from-here
1755 "\C-c" gnus-summary-catchup-all
1756 "k" gnus-summary-kill-same-subject-and-select
1757 "K" gnus-summary-kill-same-subject
1758 "P" gnus-uu-mark-map)
1760 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1761 "c" gnus-summary-clear-above
1762 "u" gnus-summary-tick-above
1763 "m" gnus-summary-mark-above
1764 "k" gnus-summary-kill-below)
1766 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1767 "/" gnus-summary-limit-to-subject
1768 "n" gnus-summary-limit-to-articles
1769 "w" gnus-summary-pop-limit
1770 "s" gnus-summary-limit-to-subject
1771 "a" gnus-summary-limit-to-author
1772 "u" gnus-summary-limit-to-unread
1773 "m" gnus-summary-limit-to-marks
1774 "M" gnus-summary-limit-exclude-marks
1775 "v" gnus-summary-limit-to-score
1776 "*" gnus-summary-limit-include-cached
1777 "D" gnus-summary-limit-include-dormant
1778 "T" gnus-summary-limit-include-thread
1779 "d" gnus-summary-limit-exclude-dormant
1780 "t" gnus-summary-limit-to-age
1781 "." gnus-summary-limit-to-unseen
1782 "x" gnus-summary-limit-to-extra
1783 "p" gnus-summary-limit-to-display-predicate
1784 "E" gnus-summary-limit-include-expunged
1785 "c" gnus-summary-limit-exclude-childless-dormant
1786 "C" gnus-summary-limit-mark-excluded-as-read
1787 "o" gnus-summary-insert-old-articles
1788 "N" gnus-summary-insert-new-articles)
1790 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1791 "n" gnus-summary-next-unread-article
1792 "p" gnus-summary-prev-unread-article
1793 "N" gnus-summary-next-article
1794 "P" gnus-summary-prev-article
1795 "\C-n" gnus-summary-next-same-subject
1796 "\C-p" gnus-summary-prev-same-subject
1797 "\M-n" gnus-summary-next-unread-subject
1798 "\M-p" gnus-summary-prev-unread-subject
1799 "f" gnus-summary-first-unread-article
1800 "b" gnus-summary-best-unread-article
1801 "j" gnus-summary-goto-article
1802 "g" gnus-summary-goto-subject
1803 "l" gnus-summary-goto-last-article
1804 "o" gnus-summary-pop-article)
1806 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1807 "k" gnus-summary-kill-thread
1808 "l" gnus-summary-lower-thread
1809 "i" gnus-summary-raise-thread
1810 "T" gnus-summary-toggle-threads
1811 "t" gnus-summary-rethread-current
1812 "^" gnus-summary-reparent-thread
1813 "s" gnus-summary-show-thread
1814 "S" gnus-summary-show-all-threads
1815 "h" gnus-summary-hide-thread
1816 "H" gnus-summary-hide-all-threads
1817 "n" gnus-summary-next-thread
1818 "p" gnus-summary-prev-thread
1819 "u" gnus-summary-up-thread
1820 "o" gnus-summary-top-thread
1821 "d" gnus-summary-down-thread
1822 "#" gnus-uu-mark-thread
1823 "\M-#" gnus-uu-unmark-thread)
1825 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1826 "g" gnus-summary-prepare
1827 "c" gnus-summary-insert-cached-articles
1828 "d" gnus-summary-insert-dormant-articles)
1830 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1831 "c" gnus-summary-catchup-and-exit
1832 "C" gnus-summary-catchup-all-and-exit
1833 "E" gnus-summary-exit-no-update
1834 "Q" gnus-summary-exit
1835 "Z" gnus-summary-exit
1836 "n" gnus-summary-catchup-and-goto-next-group
1837 "R" gnus-summary-reselect-current-group
1838 "G" gnus-summary-rescan-group
1839 "N" gnus-summary-next-group
1840 "s" gnus-summary-save-newsrc
1841 "P" gnus-summary-prev-group)
1843 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1844 " " gnus-summary-next-page
1845 "n" gnus-summary-next-page
1846 "\177" gnus-summary-prev-page
1847 [delete] gnus-summary-prev-page
1848 "p" gnus-summary-prev-page
1849 "\r" gnus-summary-scroll-up
1850 "\M-\r" gnus-summary-scroll-down
1851 "<" gnus-summary-beginning-of-article
1852 ">" gnus-summary-end-of-article
1853 "b" gnus-summary-beginning-of-article
1854 "e" gnus-summary-end-of-article
1855 "^" gnus-summary-refer-parent-article
1856 "r" gnus-summary-refer-parent-article
1857 "D" gnus-summary-enter-digest-group
1858 "R" gnus-summary-refer-references
1859 "T" gnus-summary-refer-thread
1860 "g" gnus-summary-show-article
1861 "s" gnus-summary-isearch-article
1862 "P" gnus-summary-print-article
1863 "M" gnus-mailing-list-insinuate
1864 "t" gnus-article-babel)
1866 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1867 "b" gnus-article-add-buttons
1868 "B" gnus-article-add-buttons-to-head
1869 "o" gnus-article-treat-overstrike
1870 "e" gnus-article-emphasize
1871 "w" gnus-article-fill-cited-article
1872 "Q" gnus-article-fill-long-lines
1873 "C" gnus-article-capitalize-sentences
1874 "c" gnus-article-remove-cr
1875 "q" gnus-article-de-quoted-unreadable
1876 "6" gnus-article-de-base64-unreadable
1877 "Z" gnus-article-decode-HZ
1878 "h" gnus-article-wash-html
1879 "u" gnus-article-unsplit-urls
1880 "s" gnus-summary-force-verify-and-decrypt
1881 "f" gnus-article-display-x-face
1882 "l" gnus-summary-stop-page-breaking
1883 "r" gnus-summary-caesar-message
1884 "m" gnus-summary-morse-message
1885 "t" gnus-summary-toggle-header
1886 "g" gnus-treat-smiley
1887 "v" gnus-summary-verbose-headers
1888 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1889 "p" gnus-article-verify-x-pgp-sig
1890 "d" gnus-article-treat-dumbquotes)
1892 (gnus-define-keys (gnus-summary-wash-deuglify-map "Y" gnus-summary-wash-map)
1893 ;; mnemonic: deuglif*Y*
1894 "u" gnus-article-outlook-unwrap-lines
1895 "a" gnus-article-outlook-repair-attribution
1896 "c" gnus-article-outlook-rearrange-citation
1897 "f" gnus-article-outlook-deuglify-article) ;; mnemonic: full deuglify
1899 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1900 "a" gnus-article-hide
1901 "h" gnus-article-hide-headers
1902 "b" gnus-article-hide-boring-headers
1903 "s" gnus-article-hide-signature
1904 "c" gnus-article-hide-citation
1905 "C" gnus-article-hide-citation-in-followups
1906 "l" gnus-article-hide-list-identifiers
1907 "B" gnus-article-strip-banner
1908 "P" gnus-article-hide-pem
1909 "\C-c" gnus-article-hide-citation-maybe)
1911 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1912 "a" gnus-article-highlight
1913 "h" gnus-article-highlight-headers
1914 "c" gnus-article-highlight-citation
1915 "s" gnus-article-highlight-signature)
1917 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1918 "f" gnus-article-treat-fold-headers
1919 "u" gnus-article-treat-unfold-headers
1920 "n" gnus-article-treat-fold-newsgroups)
1922 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1923 "x" gnus-article-display-x-face
1924 "d" gnus-article-display-face
1925 "s" gnus-treat-smiley
1926 "D" gnus-article-remove-images
1927 "f" gnus-treat-from-picon
1928 "m" gnus-treat-mail-picon
1929 "n" gnus-treat-newsgroups-picon)
1931 (gnus-define-keys (gnus-summary-wash-mime-map "M" gnus-summary-wash-map)
1932 "w" gnus-article-decode-mime-words
1933 "c" gnus-article-decode-charset
1934 "v" gnus-mime-view-all-parts
1935 "b" gnus-article-view-part)
1937 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1938 "z" gnus-article-date-ut
1939 "u" gnus-article-date-ut
1940 "l" gnus-article-date-local
1941 "p" gnus-article-date-english
1942 "e" gnus-article-date-lapsed
1943 "o" gnus-article-date-original
1944 "i" gnus-article-date-iso8601
1945 "s" gnus-article-date-user)
1947 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1948 "t" gnus-article-remove-trailing-blank-lines
1949 "l" gnus-article-strip-leading-blank-lines
1950 "m" gnus-article-strip-multiple-blank-lines
1951 "a" gnus-article-strip-blank-lines
1952 "A" gnus-article-strip-all-blank-lines
1953 "s" gnus-article-strip-leading-space
1954 "e" gnus-article-strip-trailing-space
1955 "w" gnus-article-remove-leading-whitespace)
1957 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1958 "v" gnus-version
1959 "f" gnus-summary-fetch-faq
1960 "d" gnus-summary-describe-group
1961 "h" gnus-summary-describe-briefly
1962 "i" gnus-info-find-node
1963 "c" gnus-group-fetch-charter
1964 "C" gnus-group-fetch-control)
1966 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1967 "e" gnus-summary-expire-articles
1968 "\M-\C-e" gnus-summary-expire-articles-now
1969 "\177" gnus-summary-delete-article
1970 [delete] gnus-summary-delete-article
1971 [backspace] gnus-summary-delete-article
1972 "m" gnus-summary-move-article
1973 "r" gnus-summary-respool-article
1974 "w" gnus-summary-edit-article
1975 "c" gnus-summary-copy-article
1976 "B" gnus-summary-crosspost-article
1977 "q" gnus-summary-respool-query
1978 "t" gnus-summary-respool-trace
1979 "i" gnus-summary-import-article
1980 "I" gnus-summary-create-article
1981 "p" gnus-summary-article-posted-p)
1983 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1984 "o" gnus-summary-save-article
1985 "m" gnus-summary-save-article-mail
1986 "F" gnus-summary-write-article-file
1987 "r" gnus-summary-save-article-rmail
1988 "f" gnus-summary-save-article-file
1989 "b" gnus-summary-save-article-body-file
1990 "h" gnus-summary-save-article-folder
1991 "v" gnus-summary-save-article-vm
1992 "p" gnus-summary-pipe-output
1993 "P" gnus-summary-muttprint
1994 "s" gnus-soup-add-article)
1996 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1997 "b" gnus-summary-display-buttonized
1998 "m" gnus-summary-repair-multipart
1999 "v" gnus-article-view-part
2000 "o" gnus-article-save-part
2001 "c" gnus-article-copy-part
2002 "C" gnus-article-view-part-as-charset
2003 "e" gnus-article-view-part-externally
2004 "E" gnus-article-encrypt-body
2005 "i" gnus-article-inline-part
2006 "|" gnus-article-pipe-part)
2008 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
2009 "p" gnus-summary-mark-as-processable
2010 "u" gnus-summary-unmark-as-processable
2011 "U" gnus-summary-unmark-all-processable
2012 "v" gnus-uu-mark-over
2013 "s" gnus-uu-mark-series
2014 "r" gnus-uu-mark-region
2015 "g" gnus-uu-unmark-region
2016 "R" gnus-uu-mark-by-regexp
2017 "G" gnus-uu-unmark-by-regexp
2018 "t" gnus-uu-mark-thread
2019 "T" gnus-uu-unmark-thread
2020 "a" gnus-uu-mark-all
2021 "b" gnus-uu-mark-buffer
2022 "S" gnus-uu-mark-sparse
2023 "k" gnus-summary-kill-process-mark
2024 "y" gnus-summary-yank-process-mark
2025 "w" gnus-summary-save-process-mark
2026 "i" gnus-uu-invert-processable)
2028 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
2029 ;;"x" gnus-uu-extract-any
2030 "m" gnus-summary-save-parts
2031 "u" gnus-uu-decode-uu
2032 "U" gnus-uu-decode-uu-and-save
2033 "s" gnus-uu-decode-unshar
2034 "S" gnus-uu-decode-unshar-and-save
2035 "o" gnus-uu-decode-save
2036 "O" gnus-uu-decode-save
2037 "b" gnus-uu-decode-binhex
2038 "B" gnus-uu-decode-binhex
2039 "p" gnus-uu-decode-postscript
2040 "P" gnus-uu-decode-postscript-and-save)
2042 (gnus-define-keys
2043 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
2044 "u" gnus-uu-decode-uu-view
2045 "U" gnus-uu-decode-uu-and-save-view
2046 "s" gnus-uu-decode-unshar-view
2047 "S" gnus-uu-decode-unshar-and-save-view
2048 "o" gnus-uu-decode-save-view
2049 "O" gnus-uu-decode-save-view
2050 "b" gnus-uu-decode-binhex-view
2051 "B" gnus-uu-decode-binhex-view
2052 "p" gnus-uu-decode-postscript-view
2053 "P" gnus-uu-decode-postscript-and-save-view)
2055 (defvar gnus-article-post-menu nil)
2057 (defconst gnus-summary-menu-maxlen 20)
2059 (defun gnus-summary-menu-split (menu)
2060 ;; If we have lots of elements, divide them into groups of 20
2061 ;; and make a pane (or submenu) for each one.
2062 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
2063 (let ((menu menu) sublists next
2064 (i 1))
2065 (while menu
2066 ;; Pull off the next gnus-summary-menu-maxlen elements
2067 ;; and make them the next element of sublist.
2068 (setq next (nthcdr gnus-summary-menu-maxlen menu))
2069 (if next
2070 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
2071 nil))
2072 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
2073 (aref (car (last menu)) 0)) menu)
2074 sublists))
2075 (setq i (1+ i))
2076 (setq menu next))
2077 (nreverse sublists))
2078 ;; Few elements--put them all in one pane.
2079 menu))
2081 (defun gnus-summary-make-menu-bar ()
2082 (gnus-turn-off-edit-menu 'summary)
2084 (unless (boundp 'gnus-summary-misc-menu)
2086 (easy-menu-define
2087 gnus-summary-kill-menu gnus-summary-mode-map ""
2088 (cons
2089 "Score"
2090 (nconc
2091 (list
2092 ["Customize" gnus-score-customize t])
2093 (gnus-make-score-map 'increase)
2094 (gnus-make-score-map 'lower)
2095 '(("Mark"
2096 ["Kill below" gnus-summary-kill-below t]
2097 ["Mark above" gnus-summary-mark-above t]
2098 ["Tick above" gnus-summary-tick-above t]
2099 ["Clear above" gnus-summary-clear-above t])
2100 ["Current score" gnus-summary-current-score t]
2101 ["Set score" gnus-summary-set-score t]
2102 ["Switch current score file..." gnus-score-change-score-file t]
2103 ["Set mark below..." gnus-score-set-mark-below t]
2104 ["Set expunge below..." gnus-score-set-expunge-below t]
2105 ["Edit current score file" gnus-score-edit-current-scores t]
2106 ["Edit score file" gnus-score-edit-file t]
2107 ["Trace score" gnus-score-find-trace t]
2108 ["Find words" gnus-score-find-favourite-words t]
2109 ["Rescore buffer" gnus-summary-rescore t]
2110 ["Increase score..." gnus-summary-increase-score t]
2111 ["Lower score..." gnus-summary-lower-score t]))))
2113 ;; Define both the Article menu in the summary buffer and the
2114 ;; equivalent Commands menu in the article buffer here for
2115 ;; consistency.
2116 (let ((innards
2117 `(("Hide"
2118 ["All" gnus-article-hide t]
2119 ["Headers" gnus-article-hide-headers t]
2120 ["Signature" gnus-article-hide-signature t]
2121 ["Citation" gnus-article-hide-citation t]
2122 ["List identifiers" gnus-article-hide-list-identifiers t]
2123 ["Banner" gnus-article-strip-banner t]
2124 ["Boring headers" gnus-article-hide-boring-headers t])
2125 ("Highlight"
2126 ["All" gnus-article-highlight t]
2127 ["Headers" gnus-article-highlight-headers t]
2128 ["Signature" gnus-article-highlight-signature t]
2129 ["Citation" gnus-article-highlight-citation t])
2130 ("MIME"
2131 ["Words" gnus-article-decode-mime-words t]
2132 ["Charset" gnus-article-decode-charset t]
2133 ["QP" gnus-article-de-quoted-unreadable t]
2134 ["Base64" gnus-article-de-base64-unreadable t]
2135 ["View MIME buttons" gnus-summary-display-buttonized t]
2136 ["View all" gnus-mime-view-all-parts t]
2137 ["Verify and Decrypt" gnus-summary-force-verify-and-decrypt t]
2138 ["Encrypt body" gnus-article-encrypt-body
2139 :active (not (gnus-group-read-only-p))
2140 ,@(if (featurep 'xemacs) nil
2141 '(:help "Encrypt the message body on disk"))]
2142 ["Extract all parts..." gnus-summary-save-parts t]
2143 ("Multipart"
2144 ["Repair multipart" gnus-summary-repair-multipart t]
2145 ["Pipe part..." gnus-article-pipe-part t]
2146 ["Inline part" gnus-article-inline-part t]
2147 ["Encrypt body" gnus-article-encrypt-body
2148 :active (not (gnus-group-read-only-p))
2149 ,@(if (featurep 'xemacs) nil
2150 '(:help "Encrypt the message body on disk"))]
2151 ["View part externally" gnus-article-view-part-externally t]
2152 ["View part with charset..." gnus-article-view-part-as-charset t]
2153 ["Copy part" gnus-article-copy-part t]
2154 ["Save part..." gnus-article-save-part t]
2155 ["View part" gnus-article-view-part t]))
2156 ("Date"
2157 ["Local" gnus-article-date-local t]
2158 ["ISO8601" gnus-article-date-iso8601 t]
2159 ["UT" gnus-article-date-ut t]
2160 ["Original" gnus-article-date-original t]
2161 ["Lapsed" gnus-article-date-lapsed t]
2162 ["User-defined" gnus-article-date-user t])
2163 ("Display"
2164 ["Remove images" gnus-article-remove-images t]
2165 ["Toggle smiley" gnus-treat-smiley t]
2166 ["Show X-Face" gnus-article-display-x-face t]
2167 ["Show picons in From" gnus-treat-from-picon t]
2168 ["Show picons in mail headers" gnus-treat-mail-picon t]
2169 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2170 ("View as different encoding"
2171 ,@(gnus-summary-menu-split
2172 (mapcar
2173 (lambda (cs)
2174 ;; Since easymenu under Emacs doesn't allow
2175 ;; lambda forms for menu commands, we should
2176 ;; provide intern'ed function symbols.
2177 (let ((command (intern (format "\
2178 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2179 (fset command
2180 `(lambda ()
2181 (interactive)
2182 (let ((gnus-summary-show-article-charset-alist
2183 '((1 . ,cs))))
2184 (gnus-summary-show-article 1))))
2185 `[,(symbol-name cs) ,command t]))
2186 (sort (if (fboundp 'coding-system-list)
2187 (coding-system-list)
2188 (mapcar 'car mm-mime-mule-charset-alist))
2189 'string<)))))
2190 ("Washing"
2191 ("Remove Blanks"
2192 ["Leading" gnus-article-strip-leading-blank-lines t]
2193 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2194 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2195 ["All of the above" gnus-article-strip-blank-lines t]
2196 ["All" gnus-article-strip-all-blank-lines t]
2197 ["Leading space" gnus-article-strip-leading-space t]
2198 ["Trailing space" gnus-article-strip-trailing-space t]
2199 ["Leading space in headers"
2200 gnus-article-remove-leading-whitespace t])
2201 ["Overstrike" gnus-article-treat-overstrike t]
2202 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2203 ["Emphasis" gnus-article-emphasize t]
2204 ["Word wrap" gnus-article-fill-cited-article t]
2205 ["Fill long lines" gnus-article-fill-long-lines t]
2206 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2207 ["Remove CR" gnus-article-remove-cr t]
2208 ["Quoted-Printable" gnus-article-de-quoted-unreadable t]
2209 ["Base64" gnus-article-de-base64-unreadable t]
2210 ["Rot 13" gnus-summary-caesar-message
2211 ,@(if (featurep 'xemacs) '(t)
2212 '(:help "\"Caesar rotate\" article by 13"))]
2213 ["Morse decode" gnus-summary-morse-message t]
2214 ["Unix pipe..." gnus-summary-pipe-message t]
2215 ["Add buttons" gnus-article-add-buttons t]
2216 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2217 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2218 ["Verbose header" gnus-summary-verbose-headers t]
2219 ["Toggle header" gnus-summary-toggle-header t]
2220 ["Unfold headers" gnus-article-treat-unfold-headers t]
2221 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2222 ["Html" gnus-article-wash-html t]
2223 ["Unsplit URLs" gnus-article-unsplit-urls t]
2224 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2225 ["Decode HZ" gnus-article-decode-HZ t]
2226 ("(Outlook) Deuglify"
2227 ["Unwrap lines" gnus-article-outlook-unwrap-lines t]
2228 ["Repair attribution" gnus-article-outlook-repair-attribution t]
2229 ["Rearrange citation" gnus-article-outlook-rearrange-citation t]
2230 ["Full (Outlook) deuglify"
2231 gnus-article-outlook-deuglify-article t])
2233 ("Output"
2234 ["Save in default format..." gnus-summary-save-article
2235 ,@(if (featurep 'xemacs) '(t)
2236 '(:help "Save article using default method"))]
2237 ["Save in file..." gnus-summary-save-article-file
2238 ,@(if (featurep 'xemacs) '(t)
2239 '(:help "Save article in file"))]
2240 ["Save in Unix mail format..." gnus-summary-save-article-mail t]
2241 ["Save in MH folder..." gnus-summary-save-article-folder t]
2242 ["Save in VM folder..." gnus-summary-save-article-vm t]
2243 ["Save in RMAIL mbox..." gnus-summary-save-article-rmail t]
2244 ["Save body in file..." gnus-summary-save-article-body-file t]
2245 ["Pipe through a filter..." gnus-summary-pipe-output t]
2246 ["Add to SOUP packet" gnus-soup-add-article t]
2247 ["Print with Muttprint..." gnus-summary-muttprint t]
2248 ["Print" gnus-summary-print-article
2249 ,@(if (featurep 'xemacs) '(t)
2250 '(:help "Generate and print a PostScript image"))])
2251 ("Copy, move,... (Backend)"
2252 ,@(if (featurep 'xemacs) '(t)
2253 '(:help "Copying, moving, expiring articles..."))
2254 ["Respool article..." gnus-summary-respool-article t]
2255 ["Move article..." gnus-summary-move-article
2256 (gnus-check-backend-function
2257 'request-move-article gnus-newsgroup-name)]
2258 ["Copy article..." gnus-summary-copy-article t]
2259 ["Crosspost article..." gnus-summary-crosspost-article
2260 (gnus-check-backend-function
2261 'request-replace-article gnus-newsgroup-name)]
2262 ["Import file..." gnus-summary-import-article
2263 (gnus-check-backend-function
2264 'request-accept-article gnus-newsgroup-name)]
2265 ["Create article..." gnus-summary-create-article
2266 (gnus-check-backend-function
2267 'request-accept-article gnus-newsgroup-name)]
2268 ["Check if posted" gnus-summary-article-posted-p t]
2269 ["Edit article" gnus-summary-edit-article
2270 (not (gnus-group-read-only-p))]
2271 ["Delete article" gnus-summary-delete-article
2272 (gnus-check-backend-function
2273 'request-expire-articles gnus-newsgroup-name)]
2274 ["Query respool" gnus-summary-respool-query t]
2275 ["Trace respool" gnus-summary-respool-trace t]
2276 ["Delete expirable articles" gnus-summary-expire-articles-now
2277 (gnus-check-backend-function
2278 'request-expire-articles gnus-newsgroup-name)])
2279 ("Extract"
2280 ["Uudecode" gnus-uu-decode-uu
2281 ,@(if (featurep 'xemacs) '(t)
2282 '(:help "Decode uuencoded article(s)"))]
2283 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2284 ["Unshar" gnus-uu-decode-unshar t]
2285 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2286 ["Save" gnus-uu-decode-save t]
2287 ["Binhex" gnus-uu-decode-binhex t]
2288 ["Postscript" gnus-uu-decode-postscript t]
2289 ["All MIME parts" gnus-summary-save-parts t])
2290 ("Cache"
2291 ["Enter article" gnus-cache-enter-article t]
2292 ["Remove article" gnus-cache-remove-article t])
2293 ["Translate" gnus-article-babel t]
2294 ["Select article buffer" gnus-summary-select-article-buffer t]
2295 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2296 ["Isearch article..." gnus-summary-isearch-article t]
2297 ["Beginning of the article" gnus-summary-beginning-of-article t]
2298 ["End of the article" gnus-summary-end-of-article t]
2299 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2300 ["Fetch referenced articles" gnus-summary-refer-references t]
2301 ["Fetch current thread" gnus-summary-refer-thread t]
2302 ["Fetch article with id..." gnus-summary-refer-article t]
2303 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2304 ["Redisplay" gnus-summary-show-article t]
2305 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2306 (easy-menu-define
2307 gnus-summary-article-menu gnus-summary-mode-map ""
2308 (cons "Article" innards))
2310 (if (not (keymapp gnus-summary-article-menu))
2311 (easy-menu-define
2312 gnus-article-commands-menu gnus-article-mode-map ""
2313 (cons "Commands" innards))
2314 ;; in Emacs, don't share menu.
2315 (setq gnus-article-commands-menu
2316 (copy-keymap gnus-summary-article-menu))
2317 (define-key gnus-article-mode-map [menu-bar commands]
2318 (cons "Commands" gnus-article-commands-menu))))
2320 (easy-menu-define
2321 gnus-summary-thread-menu gnus-summary-mode-map ""
2322 '("Threads"
2323 ["Find all messages in thread" gnus-summary-refer-thread t]
2324 ["Toggle threading" gnus-summary-toggle-threads t]
2325 ["Hide threads" gnus-summary-hide-all-threads t]
2326 ["Show threads" gnus-summary-show-all-threads t]
2327 ["Hide thread" gnus-summary-hide-thread t]
2328 ["Show thread" gnus-summary-show-thread t]
2329 ["Go to next thread" gnus-summary-next-thread t]
2330 ["Go to previous thread" gnus-summary-prev-thread t]
2331 ["Go down thread" gnus-summary-down-thread t]
2332 ["Go up thread" gnus-summary-up-thread t]
2333 ["Top of thread" gnus-summary-top-thread t]
2334 ["Mark thread as read" gnus-summary-kill-thread t]
2335 ["Lower thread score" gnus-summary-lower-thread t]
2336 ["Raise thread score" gnus-summary-raise-thread t]
2337 ["Rethread current" gnus-summary-rethread-current t]))
2339 (easy-menu-define
2340 gnus-summary-post-menu gnus-summary-mode-map ""
2341 `("Post"
2342 ["Send a message (mail or news)" gnus-summary-post-news
2343 ,@(if (featurep 'xemacs) '(t)
2344 '(:help "Compose a new message (mail or news)"))]
2345 ["Followup" gnus-summary-followup
2346 ,@(if (featurep 'xemacs) '(t)
2347 '(:help "Post followup to this article"))]
2348 ["Followup and yank" gnus-summary-followup-with-original
2349 ,@(if (featurep 'xemacs) '(t)
2350 '(:help "Post followup to this article, quoting its contents"))]
2351 ["Supersede article" gnus-summary-supersede-article t]
2352 ["Cancel article" gnus-summary-cancel-article
2353 ,@(if (featurep 'xemacs) '(t)
2354 '(:help "Cancel an article you posted"))]
2355 ["Reply" gnus-summary-reply t]
2356 ["Reply and yank" gnus-summary-reply-with-original t]
2357 ["Wide reply" gnus-summary-wide-reply t]
2358 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2359 ,@(if (featurep 'xemacs) '(t)
2360 '(:help "Mail a reply, quoting this article"))]
2361 ["Very wide reply" gnus-summary-very-wide-reply t]
2362 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2363 ,@(if (featurep 'xemacs) '(t)
2364 '(:help "Mail a very wide reply, quoting this article"))]
2365 ["Mail forward" gnus-summary-mail-forward t]
2366 ["Post forward" gnus-summary-post-forward t]
2367 ["Digest and mail" gnus-uu-digest-mail-forward t]
2368 ["Digest and post" gnus-uu-digest-post-forward t]
2369 ["Resend message" gnus-summary-resend-message t]
2370 ["Resend message edit" gnus-summary-resend-message-edit t]
2371 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2372 ["Send a mail" gnus-summary-mail-other-window t]
2373 ["Create a local message" gnus-summary-news-other-window t]
2374 ["Uuencode and post" gnus-uu-post-news
2375 ,@(if (featurep 'xemacs) '(t)
2376 '(:help "Post a uuencoded article"))]
2377 ["Followup via news" gnus-summary-followup-to-mail t]
2378 ["Followup via news and yank"
2379 gnus-summary-followup-to-mail-with-original t]
2380 ;;("Draft"
2381 ;;["Send" gnus-summary-send-draft t]
2382 ;;["Send bounced" gnus-resend-bounced-mail t])
2385 (cond
2386 ((not (keymapp gnus-summary-post-menu))
2387 (setq gnus-article-post-menu gnus-summary-post-menu))
2388 ((not gnus-article-post-menu)
2389 ;; Don't share post menu.
2390 (setq gnus-article-post-menu
2391 (copy-keymap gnus-summary-post-menu))))
2392 (define-key gnus-article-mode-map [menu-bar post]
2393 (cons "Post" gnus-article-post-menu))
2395 (easy-menu-define
2396 gnus-summary-misc-menu gnus-summary-mode-map ""
2397 `("Gnus"
2398 ("Mark Read"
2399 ["Mark as read" gnus-summary-mark-as-read-forward t]
2400 ["Mark same subject and select"
2401 gnus-summary-kill-same-subject-and-select t]
2402 ["Mark same subject" gnus-summary-kill-same-subject t]
2403 ["Catchup" gnus-summary-catchup
2404 ,@(if (featurep 'xemacs) '(t)
2405 '(:help "Mark unread articles in this group as read"))]
2406 ["Catchup all" gnus-summary-catchup-all t]
2407 ["Catchup to here" gnus-summary-catchup-to-here t]
2408 ["Catchup from here" gnus-summary-catchup-from-here t]
2409 ["Catchup region" gnus-summary-mark-region-as-read
2410 (gnus-mark-active-p)]
2411 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2412 ("Mark Various"
2413 ["Tick" gnus-summary-tick-article-forward t]
2414 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2415 ["Remove marks" gnus-summary-clear-mark-forward t]
2416 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2417 ["Set bookmark" gnus-summary-set-bookmark t]
2418 ["Remove bookmark" gnus-summary-remove-bookmark t])
2419 ("Limit to"
2420 ["Marks..." gnus-summary-limit-to-marks t]
2421 ["Subject..." gnus-summary-limit-to-subject t]
2422 ["Author..." gnus-summary-limit-to-author t]
2423 ["Age..." gnus-summary-limit-to-age t]
2424 ["Extra..." gnus-summary-limit-to-extra t]
2425 ["Score..." gnus-summary-limit-to-score t]
2426 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2427 ["Unread" gnus-summary-limit-to-unread t]
2428 ["Unseen" gnus-summary-limit-to-unseen t]
2429 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2430 ["Next articles" gnus-summary-limit-to-articles t]
2431 ["Pop limit" gnus-summary-pop-limit t]
2432 ["Show dormant" gnus-summary-limit-include-dormant t]
2433 ["Hide childless dormant"
2434 gnus-summary-limit-exclude-childless-dormant t]
2435 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2436 ["Hide marked" gnus-summary-limit-exclude-marks t]
2437 ["Show expunged" gnus-summary-limit-include-expunged t])
2438 ("Process Mark"
2439 ["Set mark" gnus-summary-mark-as-processable t]
2440 ["Remove mark" gnus-summary-unmark-as-processable t]
2441 ["Remove all marks" gnus-summary-unmark-all-processable t]
2442 ["Mark above" gnus-uu-mark-over t]
2443 ["Mark series" gnus-uu-mark-series t]
2444 ["Mark region" gnus-uu-mark-region (gnus-mark-active-p)]
2445 ["Unmark region" gnus-uu-unmark-region (gnus-mark-active-p)]
2446 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2447 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2448 ["Mark all" gnus-uu-mark-all t]
2449 ["Mark buffer" gnus-uu-mark-buffer t]
2450 ["Mark sparse" gnus-uu-mark-sparse t]
2451 ["Mark thread" gnus-uu-mark-thread t]
2452 ["Unmark thread" gnus-uu-unmark-thread t]
2453 ("Process Mark Sets"
2454 ["Kill" gnus-summary-kill-process-mark t]
2455 ["Yank" gnus-summary-yank-process-mark
2456 gnus-newsgroup-process-stack]
2457 ["Save" gnus-summary-save-process-mark t]
2458 ["Run command on marked..." gnus-summary-universal-argument t]))
2459 ("Scroll article"
2460 ["Page forward" gnus-summary-next-page
2461 ,@(if (featurep 'xemacs) '(t)
2462 '(:help "Show next page of article"))]
2463 ["Page backward" gnus-summary-prev-page
2464 ,@(if (featurep 'xemacs) '(t)
2465 '(:help "Show previous page of article"))]
2466 ["Line forward" gnus-summary-scroll-up t])
2467 ("Move"
2468 ["Next unread article" gnus-summary-next-unread-article t]
2469 ["Previous unread article" gnus-summary-prev-unread-article t]
2470 ["Next article" gnus-summary-next-article t]
2471 ["Previous article" gnus-summary-prev-article t]
2472 ["Next unread subject" gnus-summary-next-unread-subject t]
2473 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2474 ["Next article same subject" gnus-summary-next-same-subject t]
2475 ["Previous article same subject" gnus-summary-prev-same-subject t]
2476 ["First unread article" gnus-summary-first-unread-article t]
2477 ["Best unread article" gnus-summary-best-unread-article t]
2478 ["Go to subject number..." gnus-summary-goto-subject t]
2479 ["Go to article number..." gnus-summary-goto-article t]
2480 ["Go to the last article" gnus-summary-goto-last-article t]
2481 ["Pop article off history" gnus-summary-pop-article t])
2482 ("Sort"
2483 ["Sort by number" gnus-summary-sort-by-number t]
2484 ["Sort by author" gnus-summary-sort-by-author t]
2485 ["Sort by subject" gnus-summary-sort-by-subject t]
2486 ["Sort by date" gnus-summary-sort-by-date t]
2487 ["Sort by score" gnus-summary-sort-by-score t]
2488 ["Sort by lines" gnus-summary-sort-by-lines t]
2489 ["Sort by characters" gnus-summary-sort-by-chars t]
2490 ["Randomize" gnus-summary-sort-by-random t]
2491 ["Original sort" gnus-summary-sort-by-original t])
2492 ("Help"
2493 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2494 ["Describe group" gnus-summary-describe-group t]
2495 ["Fetch charter" gnus-group-fetch-charter
2496 ,@(if (featurep 'xemacs) nil
2497 '(:help "Display the charter of the current group"))]
2498 ["Fetch control message" gnus-group-fetch-control
2499 ,@(if (featurep 'xemacs) nil
2500 '(:help "Display the archived control message for the current group"))]
2501 ["Read manual" gnus-info-find-node t])
2502 ("Modes"
2503 ["Pick and read" gnus-pick-mode t]
2504 ["Binary" gnus-binary-mode t])
2505 ("Regeneration"
2506 ["Regenerate" gnus-summary-prepare t]
2507 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2508 ["Insert dormant articles" gnus-summary-insert-dormant-articles t]
2509 ["Toggle threading" gnus-summary-toggle-threads t])
2510 ["See old articles" gnus-summary-insert-old-articles t]
2511 ["See new articles" gnus-summary-insert-new-articles t]
2512 ["Filter articles..." gnus-summary-execute-command t]
2513 ["Run command on articles..." gnus-summary-universal-argument t]
2514 ["Search articles forward..." gnus-summary-search-article-forward t]
2515 ["Search articles backward..." gnus-summary-search-article-backward t]
2516 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2517 ["Expand window" gnus-summary-expand-window t]
2518 ["Expire expirable articles" gnus-summary-expire-articles
2519 (gnus-check-backend-function
2520 'request-expire-articles gnus-newsgroup-name)]
2521 ["Edit local kill file" gnus-summary-edit-local-kill t]
2522 ["Edit main kill file" gnus-summary-edit-global-kill t]
2523 ["Edit group parameters" gnus-summary-edit-parameters t]
2524 ["Customize group parameters" gnus-summary-customize-parameters t]
2525 ["Send a bug report" gnus-bug t]
2526 ("Exit"
2527 ["Catchup and exit" gnus-summary-catchup-and-exit
2528 ,@(if (featurep 'xemacs) '(t)
2529 '(:help "Mark unread articles in this group as read, then exit"))]
2530 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2531 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2532 ["Exit group" gnus-summary-exit
2533 ,@(if (featurep 'xemacs) '(t)
2534 '(:help "Exit current group, return to group selection mode"))]
2535 ["Exit group without updating" gnus-summary-exit-no-update t]
2536 ["Exit and goto next group" gnus-summary-next-group t]
2537 ["Exit and goto prev group" gnus-summary-prev-group t]
2538 ["Reselect group" gnus-summary-reselect-current-group t]
2539 ["Rescan group" gnus-summary-rescan-group t]
2540 ["Update dribble" gnus-summary-save-newsrc t])))
2542 (gnus-run-hooks 'gnus-summary-menu-hook)))
2544 (defvar gnus-summary-tool-bar-map nil)
2546 ;; Emacs 21 tool bar. Should be no-op otherwise.
2547 (defun gnus-summary-make-tool-bar ()
2548 (if (and (fboundp 'tool-bar-add-item-from-menu)
2549 (default-value 'tool-bar-mode)
2550 (not gnus-summary-tool-bar-map))
2551 (setq gnus-summary-tool-bar-map
2552 (let ((tool-bar-map (make-sparse-keymap))
2553 (load-path (mm-image-load-path)))
2554 (tool-bar-add-item-from-menu
2555 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2556 (tool-bar-add-item-from-menu
2557 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2558 (tool-bar-add-item-from-menu
2559 'gnus-summary-post-news "post" gnus-summary-mode-map)
2560 (tool-bar-add-item-from-menu
2561 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2562 (tool-bar-add-item-from-menu
2563 'gnus-summary-followup "followup" gnus-summary-mode-map)
2564 (tool-bar-add-item-from-menu
2565 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2566 (tool-bar-add-item-from-menu
2567 'gnus-summary-reply "reply" gnus-summary-mode-map)
2568 (tool-bar-add-item-from-menu
2569 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2570 (tool-bar-add-item-from-menu
2571 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2572 (tool-bar-add-item-from-menu
2573 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2574 (tool-bar-add-item-from-menu
2575 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2576 (tool-bar-add-item-from-menu
2577 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2578 (tool-bar-add-item-from-menu
2579 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2580 (tool-bar-add-item-from-menu
2581 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2582 (tool-bar-add-item-from-menu
2583 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2584 tool-bar-map)))
2585 (if gnus-summary-tool-bar-map
2586 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2588 (defun gnus-score-set-default (var value)
2589 "A version of set that updates the GNU Emacs menu-bar."
2590 (set var value)
2591 ;; It is the message that forces the active status to be updated.
2592 (message ""))
2594 (defun gnus-make-score-map (type)
2595 "Make a summary score map of type TYPE."
2596 (if t
2598 (let ((headers '(("author" "from" string)
2599 ("subject" "subject" string)
2600 ("article body" "body" string)
2601 ("article head" "head" string)
2602 ("xref" "xref" string)
2603 ("extra header" "extra" string)
2604 ("lines" "lines" number)
2605 ("followups to author" "followup" string)))
2606 (types '((number ("less than" <)
2607 ("greater than" >)
2608 ("equal" =))
2609 (string ("substring" s)
2610 ("exact string" e)
2611 ("fuzzy string" f)
2612 ("regexp" r))))
2613 (perms '(("temporary" (current-time-string))
2614 ("permanent" nil)
2615 ("immediate" now)))
2616 header)
2617 (list
2618 (apply
2619 'nconc
2620 (list
2621 (if (eq type 'lower)
2622 "Lower score"
2623 "Increase score"))
2624 (let (outh)
2625 (while headers
2626 (setq header (car headers))
2627 (setq outh
2628 (cons
2629 (apply
2630 'nconc
2631 (list (car header))
2632 (let ((ts (cdr (assoc (nth 2 header) types)))
2633 outt)
2634 (while ts
2635 (setq outt
2636 (cons
2637 (apply
2638 'nconc
2639 (list (caar ts))
2640 (let ((ps perms)
2641 outp)
2642 (while ps
2643 (setq outp
2644 (cons
2645 (vector
2646 (caar ps)
2647 (list
2648 'gnus-summary-score-entry
2649 (nth 1 header)
2650 (if (or (string= (nth 1 header)
2651 "head")
2652 (string= (nth 1 header)
2653 "body"))
2655 (list 'gnus-summary-header
2656 (nth 1 header)))
2657 (list 'quote (nth 1 (car ts)))
2658 (list 'gnus-score-delta-default
2659 nil)
2660 (nth 1 (car ps))
2663 outp))
2664 (setq ps (cdr ps)))
2665 (list (nreverse outp))))
2666 outt))
2667 (setq ts (cdr ts)))
2668 (list (nreverse outt))))
2669 outh))
2670 (setq headers (cdr headers)))
2671 (list (nreverse outh))))))))
2675 (defun gnus-summary-mode (&optional group)
2676 "Major mode for reading articles.
2678 All normal editing commands are switched off.
2679 \\<gnus-summary-mode-map>
2680 Each line in this buffer represents one article. To read an
2681 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2682 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2683 respectively.
2685 You can also post articles and send mail from this buffer. To
2686 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2687 of an article, type `\\[gnus-summary-reply]'.
2689 There are approx. one gazillion commands you can execute in this
2690 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2692 The following commands are available:
2694 \\{gnus-summary-mode-map}"
2695 (interactive)
2696 (kill-all-local-variables)
2697 (when (gnus-visual-p 'summary-menu 'menu)
2698 (gnus-summary-make-menu-bar)
2699 (gnus-summary-make-tool-bar))
2700 (gnus-summary-make-local-variables)
2701 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2702 (gnus-summary-make-local-variables))
2703 (gnus-make-thread-indent-array)
2704 (gnus-simplify-mode-line)
2705 (setq major-mode 'gnus-summary-mode)
2706 (setq mode-name "Summary")
2707 (make-local-variable 'minor-mode-alist)
2708 (use-local-map gnus-summary-mode-map)
2709 (buffer-disable-undo)
2710 (setq buffer-read-only t) ;Disable modification
2711 (setq truncate-lines t)
2712 (setq selective-display t)
2713 (setq selective-display-ellipses t) ;Display `...'
2714 (gnus-summary-set-display-table)
2715 (gnus-set-default-directory)
2716 (setq gnus-newsgroup-name group)
2717 (make-local-variable 'gnus-summary-line-format)
2718 (make-local-variable 'gnus-summary-line-format-spec)
2719 (make-local-variable 'gnus-summary-dummy-line-format)
2720 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2721 (make-local-variable 'gnus-summary-mark-positions)
2722 (gnus-make-local-hook 'pre-command-hook)
2723 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2724 (gnus-run-hooks 'gnus-summary-mode-hook)
2725 (turn-on-gnus-mailing-list-mode)
2726 (mm-enable-multibyte)
2727 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2728 (gnus-update-summary-mark-positions))
2730 (defun gnus-summary-make-local-variables ()
2731 "Make all the local summary buffer variables."
2732 (let (global)
2733 (dolist (local gnus-summary-local-variables)
2734 (if (consp local)
2735 (progn
2736 (if (eq (cdr local) 'global)
2737 ;; Copy the global value of the variable.
2738 (setq global (symbol-value (car local)))
2739 ;; Use the value from the list.
2740 (setq global (eval (cdr local))))
2741 (set (make-local-variable (car local)) global))
2742 ;; Simple nil-valued local variable.
2743 (set (make-local-variable local) nil)))))
2745 (defun gnus-summary-clear-local-variables ()
2746 (let ((locals gnus-summary-local-variables))
2747 (while locals
2748 (if (consp (car locals))
2749 (and (vectorp (caar locals))
2750 (set (caar locals) nil))
2751 (and (vectorp (car locals))
2752 (set (car locals) nil)))
2753 (setq locals (cdr locals)))))
2755 ;; Summary data functions.
2757 (defmacro gnus-data-number (data)
2758 `(car ,data))
2760 (defmacro gnus-data-set-number (data number)
2761 `(setcar ,data ,number))
2763 (defmacro gnus-data-mark (data)
2764 `(nth 1 ,data))
2766 (defmacro gnus-data-set-mark (data mark)
2767 `(setcar (nthcdr 1 ,data) ,mark))
2769 (defmacro gnus-data-pos (data)
2770 `(nth 2 ,data))
2772 (defmacro gnus-data-set-pos (data pos)
2773 `(setcar (nthcdr 2 ,data) ,pos))
2775 (defmacro gnus-data-header (data)
2776 `(nth 3 ,data))
2778 (defmacro gnus-data-set-header (data header)
2779 `(setf (nth 3 ,data) ,header))
2781 (defmacro gnus-data-level (data)
2782 `(nth 4 ,data))
2784 (defmacro gnus-data-unread-p (data)
2785 `(= (nth 1 ,data) gnus-unread-mark))
2787 (defmacro gnus-data-read-p (data)
2788 `(/= (nth 1 ,data) gnus-unread-mark))
2790 (defmacro gnus-data-pseudo-p (data)
2791 `(consp (nth 3 ,data)))
2793 (defmacro gnus-data-find (number)
2794 `(assq ,number gnus-newsgroup-data))
2796 (defmacro gnus-data-find-list (number &optional data)
2797 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2798 (memq (assq ,number bdata)
2799 bdata)))
2801 (defmacro gnus-data-make (number mark pos header level)
2802 `(list ,number ,mark ,pos ,header ,level))
2804 (defun gnus-data-enter (after-article number mark pos header level offset)
2805 (let ((data (gnus-data-find-list after-article)))
2806 (unless data
2807 (error "No such article: %d" after-article))
2808 (setcdr data (cons (gnus-data-make number mark pos header level)
2809 (cdr data)))
2810 (setq gnus-newsgroup-data-reverse nil)
2811 (gnus-data-update-list (cddr data) offset)))
2813 (defun gnus-data-enter-list (after-article list &optional offset)
2814 (when list
2815 (let ((data (and after-article (gnus-data-find-list after-article)))
2816 (ilist list))
2817 (if (not (or data
2818 after-article))
2819 (let ((odata gnus-newsgroup-data))
2820 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2821 (when offset
2822 (gnus-data-update-list odata offset)))
2823 ;; Find the last element in the list to be spliced into the main
2824 ;; list.
2825 (while (cdr list)
2826 (setq list (cdr list)))
2827 (if (not data)
2828 (progn
2829 (setcdr list gnus-newsgroup-data)
2830 (setq gnus-newsgroup-data ilist)
2831 (when offset
2832 (gnus-data-update-list (cdr list) offset)))
2833 (setcdr list (cdr data))
2834 (setcdr data ilist)
2835 (when offset
2836 (gnus-data-update-list (cdr list) offset))))
2837 (setq gnus-newsgroup-data-reverse nil))))
2839 (defun gnus-data-remove (article &optional offset)
2840 (let ((data gnus-newsgroup-data))
2841 (if (= (gnus-data-number (car data)) article)
2842 (progn
2843 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2844 gnus-newsgroup-data-reverse nil)
2845 (when offset
2846 (gnus-data-update-list gnus-newsgroup-data offset)))
2847 (while (cdr data)
2848 (when (= (gnus-data-number (cadr data)) article)
2849 (setcdr data (cddr data))
2850 (when offset
2851 (gnus-data-update-list (cdr data) offset))
2852 (setq data nil
2853 gnus-newsgroup-data-reverse nil))
2854 (setq data (cdr data))))))
2856 (defmacro gnus-data-list (backward)
2857 `(if ,backward
2858 (or gnus-newsgroup-data-reverse
2859 (setq gnus-newsgroup-data-reverse
2860 (reverse gnus-newsgroup-data)))
2861 gnus-newsgroup-data))
2863 (defun gnus-data-update-list (data offset)
2864 "Add OFFSET to the POS of all data entries in DATA."
2865 (setq gnus-newsgroup-data-reverse nil)
2866 (while data
2867 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2868 (setq data (cdr data))))
2870 (defun gnus-summary-article-pseudo-p (article)
2871 "Say whether this article is a pseudo article or not."
2872 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2874 (defmacro gnus-summary-article-sparse-p (article)
2875 "Say whether this article is a sparse article or not."
2876 `(memq ,article gnus-newsgroup-sparse))
2878 (defmacro gnus-summary-article-ancient-p (article)
2879 "Say whether this article is a sparse article or not."
2880 `(memq ,article gnus-newsgroup-ancient))
2882 (defun gnus-article-parent-p (number)
2883 "Say whether this article is a parent or not."
2884 (let ((data (gnus-data-find-list number)))
2885 (and (cdr data) ; There has to be an article after...
2886 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2887 (gnus-data-level (nth 1 data))))))
2889 (defun gnus-article-children (number)
2890 "Return a list of all children to NUMBER."
2891 (let* ((data (gnus-data-find-list number))
2892 (level (gnus-data-level (car data)))
2893 children)
2894 (setq data (cdr data))
2895 (while (and data
2896 (= (gnus-data-level (car data)) (1+ level)))
2897 (push (gnus-data-number (car data)) children)
2898 (setq data (cdr data)))
2899 children))
2901 (defmacro gnus-summary-skip-intangible ()
2902 "If the current article is intangible, then jump to a different article."
2903 '(let ((to (get-text-property (point) 'gnus-intangible)))
2904 (and to (gnus-summary-goto-subject to))))
2906 (defmacro gnus-summary-article-intangible-p ()
2907 "Say whether this article is intangible or not."
2908 '(get-text-property (point) 'gnus-intangible))
2910 (defun gnus-article-read-p (article)
2911 "Say whether ARTICLE is read or not."
2912 (not (or (memq article gnus-newsgroup-marked)
2913 (memq article gnus-newsgroup-spam-marked)
2914 (memq article gnus-newsgroup-unreads)
2915 (memq article gnus-newsgroup-unselected)
2916 (memq article gnus-newsgroup-dormant))))
2918 ;; Some summary mode macros.
2920 (defmacro gnus-summary-article-number ()
2921 "The article number of the article on the current line.
2922 If there isn't an article number here, then we return the current
2923 article number."
2924 '(progn
2925 (gnus-summary-skip-intangible)
2926 (or (get-text-property (point) 'gnus-number)
2927 (gnus-summary-last-subject))))
2929 (defmacro gnus-summary-article-header (&optional number)
2930 "Return the header of article NUMBER."
2931 `(gnus-data-header (gnus-data-find
2932 ,(or number '(gnus-summary-article-number)))))
2934 (defmacro gnus-summary-thread-level (&optional number)
2935 "Return the level of thread that starts with article NUMBER."
2936 `(if (and (eq gnus-summary-make-false-root 'dummy)
2937 (get-text-property (point) 'gnus-intangible))
2939 (gnus-data-level (gnus-data-find
2940 ,(or number '(gnus-summary-article-number))))))
2942 (defmacro gnus-summary-article-mark (&optional number)
2943 "Return the mark of article NUMBER."
2944 `(gnus-data-mark (gnus-data-find
2945 ,(or number '(gnus-summary-article-number)))))
2947 (defmacro gnus-summary-article-pos (&optional number)
2948 "Return the position of the line of article NUMBER."
2949 `(gnus-data-pos (gnus-data-find
2950 ,(or number '(gnus-summary-article-number)))))
2952 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2953 (defmacro gnus-summary-article-subject (&optional number)
2954 "Return current subject string or nil if nothing."
2955 `(let ((headers
2956 ,(if number
2957 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2958 '(gnus-data-header (assq (gnus-summary-article-number)
2959 gnus-newsgroup-data)))))
2960 (and headers
2961 (vectorp headers)
2962 (mail-header-subject headers))))
2964 (defmacro gnus-summary-article-score (&optional number)
2965 "Return current article score."
2966 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2967 gnus-newsgroup-scored))
2968 gnus-summary-default-score 0))
2970 (defun gnus-summary-article-children (&optional number)
2971 "Return a list of article numbers that are children of article NUMBER."
2972 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2973 (level (gnus-data-level (car data)))
2974 l children)
2975 (while (and (setq data (cdr data))
2976 (> (setq l (gnus-data-level (car data))) level))
2977 (and (= (1+ level) l)
2978 (push (gnus-data-number (car data))
2979 children)))
2980 (nreverse children)))
2982 (defun gnus-summary-article-parent (&optional number)
2983 "Return the article number of the parent of article NUMBER."
2984 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2985 (gnus-data-list t)))
2986 (level (gnus-data-level (car data))))
2987 (if (zerop level)
2988 () ; This is a root.
2989 ;; We search until we find an article with a level less than
2990 ;; this one. That function has to be the parent.
2991 (while (and (setq data (cdr data))
2992 (not (< (gnus-data-level (car data)) level))))
2993 (and data (gnus-data-number (car data))))))
2995 (defun gnus-unread-mark-p (mark)
2996 "Say whether MARK is the unread mark."
2997 (= mark gnus-unread-mark))
2999 (defun gnus-read-mark-p (mark)
3000 "Say whether MARK is one of the marks that mark as read.
3001 This is all marks except unread, ticked, dormant, and expirable."
3002 (not (or (= mark gnus-unread-mark)
3003 (= mark gnus-ticked-mark)
3004 (= mark gnus-spam-mark)
3005 (= mark gnus-dormant-mark)
3006 (= mark gnus-expirable-mark))))
3008 (defmacro gnus-article-mark (number)
3009 "Return the MARK of article NUMBER.
3010 This macro should only be used when computing the mark the \"first\"
3011 time; i.e., when generating the summary lines. After that,
3012 `gnus-summary-article-mark' should be used to examine the
3013 marks of articles."
3014 `(cond
3015 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
3016 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
3017 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
3018 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
3019 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
3020 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
3021 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
3022 (t (or (cdr (assq ,number gnus-newsgroup-reads))
3023 gnus-ancient-mark))))
3025 ;; Saving hidden threads.
3027 (defmacro gnus-save-hidden-threads (&rest forms)
3028 "Save hidden threads, eval FORMS, and restore the hidden threads."
3029 (let ((config (make-symbol "config")))
3030 `(let ((,config (gnus-hidden-threads-configuration)))
3031 (unwind-protect
3032 (save-excursion
3033 ,@forms)
3034 (gnus-restore-hidden-threads-configuration ,config)))))
3035 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
3036 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
3038 (defun gnus-data-compute-positions ()
3039 "Compute the positions of all articles."
3040 (setq gnus-newsgroup-data-reverse nil)
3041 (let ((data gnus-newsgroup-data))
3042 (save-excursion
3043 (gnus-save-hidden-threads
3044 (gnus-summary-show-all-threads)
3045 (goto-char (point-min))
3046 (while data
3047 (while (get-text-property (point) 'gnus-intangible)
3048 (forward-line 1))
3049 (gnus-data-set-pos (car data) (+ (point) 3))
3050 (setq data (cdr data))
3051 (forward-line 1))))))
3053 (defun gnus-hidden-threads-configuration ()
3054 "Return the current hidden threads configuration."
3055 (save-excursion
3056 (let (config)
3057 (goto-char (point-min))
3058 (while (search-forward "\r" nil t)
3059 (push (1- (point)) config))
3060 config)))
3062 (defun gnus-restore-hidden-threads-configuration (config)
3063 "Restore hidden threads configuration from CONFIG."
3064 (save-excursion
3065 (let (point buffer-read-only)
3066 (while (setq point (pop config))
3067 (when (and (< point (point-max))
3068 (goto-char point)
3069 (eq (char-after) ?\n))
3070 (subst-char-in-region point (1+ point) ?\n ?\r))))))
3072 ;; Various summary mode internalish functions.
3074 (defun gnus-mouse-pick-article (e)
3075 (interactive "e")
3076 (mouse-set-point e)
3077 (gnus-summary-next-page nil t))
3079 (defun gnus-summary-set-display-table ()
3080 "Change the display table.
3081 Odd characters have a tendency to mess
3082 up nicely formatted displays - we make all possible glyphs
3083 display only a single character."
3085 ;; We start from the standard display table, if any.
3086 (let ((table (or (copy-sequence standard-display-table)
3087 (make-display-table)))
3088 (i 32))
3089 ;; Nix out all the control chars...
3090 (while (>= (setq i (1- i)) 0)
3091 (aset table i [??]))
3092 ;; ... but not newline and cr, of course. (cr is necessary for the
3093 ;; selective display).
3094 (aset table ?\n nil)
3095 (aset table ?\r nil)
3096 ;; We keep TAB as well.
3097 (aset table ?\t nil)
3098 ;; We nix out any glyphs over 126 that are not set already.
3099 (let ((i 256))
3100 (while (>= (setq i (1- i)) 127)
3101 ;; Only modify if the entry is nil.
3102 (unless (aref table i)
3103 (aset table i [??]))))
3104 (setq buffer-display-table table)))
3106 (defun gnus-summary-set-article-display-arrow (pos)
3107 "Update the overlay arrow to point to line at position POS."
3108 (when (and gnus-summary-display-arrow
3109 (boundp 'overlay-arrow-position)
3110 (boundp 'overlay-arrow-string))
3111 (save-excursion
3112 (goto-char pos)
3113 (beginning-of-line)
3114 (unless overlay-arrow-position
3115 (setq overlay-arrow-position (make-marker)))
3116 (setq overlay-arrow-string "=>"
3117 overlay-arrow-position (set-marker overlay-arrow-position
3118 (point)
3119 (current-buffer))))))
3121 (defun gnus-summary-setup-buffer (group)
3122 "Initialize summary buffer."
3123 (let ((buffer (gnus-summary-buffer-name group))
3124 (dead-name (concat "*Dead Summary "
3125 (gnus-group-decoded-name group) "*")))
3126 ;; If a dead summary buffer exists, we kill it.
3127 (when (gnus-buffer-live-p dead-name)
3128 (gnus-kill-buffer dead-name))
3129 (if (get-buffer buffer)
3130 (progn
3131 (set-buffer buffer)
3132 (setq gnus-summary-buffer (current-buffer))
3133 (not gnus-newsgroup-prepared))
3134 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
3135 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
3136 (gnus-summary-mode group)
3137 (when gnus-carpal
3138 (gnus-carpal-setup-buffer 'summary))
3139 (unless gnus-single-article-buffer
3140 (make-local-variable 'gnus-article-buffer)
3141 (make-local-variable 'gnus-article-current)
3142 (make-local-variable 'gnus-original-article-buffer))
3143 (setq gnus-newsgroup-name group)
3144 ;; Set any local variables in the group parameters.
3145 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3146 t)))
3148 (defun gnus-set-global-variables ()
3149 "Set the global equivalents of the buffer-local variables.
3150 They are set to the latest values they had. These reflect the summary
3151 buffer that was in action when the last article was fetched."
3152 (when (eq major-mode 'gnus-summary-mode)
3153 (setq gnus-summary-buffer (current-buffer))
3154 (let ((name gnus-newsgroup-name)
3155 (marked gnus-newsgroup-marked)
3156 (spam gnus-newsgroup-spam-marked)
3157 (unread gnus-newsgroup-unreads)
3158 (headers gnus-current-headers)
3159 (data gnus-newsgroup-data)
3160 (summary gnus-summary-buffer)
3161 (article-buffer gnus-article-buffer)
3162 (original gnus-original-article-buffer)
3163 (gac gnus-article-current)
3164 (reffed gnus-reffed-article-number)
3165 (score-file gnus-current-score-file)
3166 (default-charset gnus-newsgroup-charset)
3167 vlist)
3168 (let ((locals gnus-newsgroup-variables))
3169 (while locals
3170 (if (consp (car locals))
3171 (push (eval (caar locals)) vlist)
3172 (push (eval (car locals)) vlist))
3173 (setq locals (cdr locals)))
3174 (setq vlist (nreverse vlist)))
3175 (save-excursion
3176 (set-buffer gnus-group-buffer)
3177 (setq gnus-newsgroup-name name
3178 gnus-newsgroup-marked marked
3179 gnus-newsgroup-spam-marked spam
3180 gnus-newsgroup-unreads unread
3181 gnus-current-headers headers
3182 gnus-newsgroup-data data
3183 gnus-article-current gac
3184 gnus-summary-buffer summary
3185 gnus-article-buffer article-buffer
3186 gnus-original-article-buffer original
3187 gnus-reffed-article-number reffed
3188 gnus-current-score-file score-file
3189 gnus-newsgroup-charset default-charset)
3190 (let ((locals gnus-newsgroup-variables))
3191 (while locals
3192 (if (consp (car locals))
3193 (set (caar locals) (pop vlist))
3194 (set (car locals) (pop vlist)))
3195 (setq locals (cdr locals))))
3196 ;; The article buffer also has local variables.
3197 (when (gnus-buffer-live-p gnus-article-buffer)
3198 (set-buffer gnus-article-buffer)
3199 (setq gnus-summary-buffer summary))))))
3201 (defun gnus-summary-article-unread-p (article)
3202 "Say whether ARTICLE is unread or not."
3203 (memq article gnus-newsgroup-unreads))
3205 (defun gnus-summary-first-article-p (&optional article)
3206 "Return whether ARTICLE is the first article in the buffer."
3207 (if (not (setq article (or article (gnus-summary-article-number))))
3209 (eq article (caar gnus-newsgroup-data))))
3211 (defun gnus-summary-last-article-p (&optional article)
3212 "Return whether ARTICLE is the last article in the buffer."
3213 (if (not (setq article (or article (gnus-summary-article-number))))
3214 ;; All non-existent numbers are the last article. :-)
3216 (not (cdr (gnus-data-find-list article)))))
3218 (defun gnus-make-thread-indent-array ()
3219 (let ((n 200))
3220 (unless (and gnus-thread-indent-array
3221 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3222 (setq gnus-thread-indent-array (make-vector 201 "")
3223 gnus-thread-indent-array-level gnus-thread-indent-level)
3224 (while (>= n 0)
3225 (aset gnus-thread-indent-array n
3226 (make-string (* n gnus-thread-indent-level) ? ))
3227 (setq n (1- n))))))
3229 (defun gnus-update-summary-mark-positions ()
3230 "Compute where the summary marks are to go."
3231 (save-excursion
3232 (when (gnus-buffer-exists-p gnus-summary-buffer)
3233 (set-buffer gnus-summary-buffer))
3234 (let ((spec gnus-summary-line-format-spec)
3235 pos)
3236 (save-excursion
3237 (gnus-set-work-buffer)
3238 (let ((gnus-tmp-unread ?Z)
3239 (gnus-replied-mark ?Z)
3240 (gnus-score-below-mark ?Z)
3241 (gnus-score-over-mark ?Z)
3242 (gnus-undownloaded-mark ?Z)
3243 (gnus-summary-line-format-spec spec)
3244 (gnus-newsgroup-downloadable '(0))
3245 (header [0 "" "" "05 Apr 2001 23:33:09 +0400" "" "" 0 0 "" nil])
3246 case-fold-search ignores)
3247 ;; Here, all marks are bound to Z.
3248 (gnus-summary-insert-line header
3249 0 nil t gnus-tmp-unread t nil "" nil 1)
3250 (goto-char (point-min))
3251 ;; Memorize the positions of the same characters as dummy marks.
3252 (while (re-search-forward "[A-D]" nil t)
3253 (push (point) ignores))
3254 (erase-buffer)
3255 ;; We use A-D as dummy marks in order to know column positions
3256 ;; where marks should be inserted.
3257 (setq gnus-tmp-unread ?A
3258 gnus-replied-mark ?B
3259 gnus-score-below-mark ?C
3260 gnus-score-over-mark ?C
3261 gnus-undownloaded-mark ?D)
3262 (gnus-summary-insert-line header
3263 0 nil t gnus-tmp-unread t nil "" nil 1)
3264 ;; Ignore characters which aren't dummy marks.
3265 (dolist (p ignores)
3266 (delete-region (goto-char (1- p)) p)
3267 (insert ?Z))
3268 (goto-char (point-min))
3269 (setq pos (list (cons 'unread
3270 (and (search-forward "A" nil t)
3271 (- (point) (point-min) 1)))))
3272 (goto-char (point-min))
3273 (push (cons 'replied (and (search-forward "B" nil t)
3274 (- (point) (point-min) 1)))
3275 pos)
3276 (goto-char (point-min))
3277 (push (cons 'score (and (search-forward "C" nil t)
3278 (- (point) (point-min) 1)))
3279 pos)
3280 (goto-char (point-min))
3281 (push (cons 'download (and (search-forward "D" nil t)
3282 (- (point) (point-min) 1)))
3283 pos)))
3284 (setq gnus-summary-mark-positions pos))))
3286 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3287 "Insert a dummy root in the summary buffer."
3288 (beginning-of-line)
3289 (gnus-add-text-properties
3290 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3291 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3293 (defun gnus-summary-extract-address-component (from)
3294 (or (car (funcall gnus-extract-address-components from))
3295 from))
3297 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3298 (let ((mail-parse-charset gnus-newsgroup-charset)
3299 ; Is it really necessary to do this next part for each summary line?
3300 ; Luckily, doesn't seem to slow things down much.
3301 (mail-parse-ignored-charsets
3302 (save-excursion (set-buffer gnus-summary-buffer)
3303 gnus-newsgroup-ignored-charsets)))
3305 (and gnus-ignored-from-addresses
3306 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3307 (let ((extra-headers (mail-header-extra header))
3309 newsgroups)
3310 (cond
3311 ((setq to (cdr (assq 'To extra-headers)))
3312 (concat "-> "
3313 (inline
3314 (gnus-summary-extract-address-component
3315 (funcall gnus-decode-encoded-word-function to)))))
3316 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3317 (concat "=> " newsgroups)))))
3318 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3320 (defun gnus-summary-insert-line (gnus-tmp-header
3321 gnus-tmp-level gnus-tmp-current
3322 undownloaded gnus-tmp-unread gnus-tmp-replied
3323 gnus-tmp-expirable gnus-tmp-subject-or-nil
3324 &optional gnus-tmp-dummy gnus-tmp-score
3325 gnus-tmp-process)
3326 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3327 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3328 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3329 (gnus-tmp-score-char
3330 (if (or (null gnus-summary-default-score)
3331 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3332 gnus-summary-zcore-fuzz))
3333 ? ;Whitespace
3334 (if (< gnus-tmp-score gnus-summary-default-score)
3335 gnus-score-below-mark gnus-score-over-mark)))
3336 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3337 (gnus-tmp-replied
3338 (cond (gnus-tmp-process gnus-process-mark)
3339 ((memq gnus-tmp-current gnus-newsgroup-cached)
3340 gnus-cached-mark)
3341 (gnus-tmp-replied gnus-replied-mark)
3342 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3343 gnus-forwarded-mark)
3344 ((memq gnus-tmp-current gnus-newsgroup-saved)
3345 gnus-saved-mark)
3346 ((memq gnus-tmp-number gnus-newsgroup-recent)
3347 gnus-recent-mark)
3348 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3349 gnus-unseen-mark)
3350 (t gnus-no-mark)))
3351 (gnus-tmp-downloaded
3352 (cond (undownloaded
3353 gnus-undownloaded-mark)
3354 (gnus-newsgroup-agentized
3355 gnus-downloaded-mark)
3357 gnus-no-mark)))
3358 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3359 (gnus-tmp-name
3360 (cond
3361 ((string-match "<[^>]+> *$" gnus-tmp-from)
3362 (let ((beg (match-beginning 0)))
3363 (or (and (string-match "^\".+\"" gnus-tmp-from)
3364 (substring gnus-tmp-from 1 (1- (match-end 0))))
3365 (substring gnus-tmp-from 0 beg))))
3366 ((string-match "(.+)" gnus-tmp-from)
3367 (substring gnus-tmp-from
3368 (1+ (match-beginning 0)) (1- (match-end 0))))
3369 (t gnus-tmp-from)))
3370 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3371 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3372 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3373 (buffer-read-only nil))
3374 (when (string= gnus-tmp-name "")
3375 (setq gnus-tmp-name gnus-tmp-from))
3376 (unless (numberp gnus-tmp-lines)
3377 (setq gnus-tmp-lines -1))
3378 (if (= gnus-tmp-lines -1)
3379 (setq gnus-tmp-lines "?")
3380 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3381 (gnus-put-text-property
3382 (point)
3383 (progn (eval gnus-summary-line-format-spec) (point))
3384 'gnus-number gnus-tmp-number)
3385 (when (gnus-visual-p 'summary-highlight 'highlight)
3386 (forward-line -1)
3387 (gnus-run-hooks 'gnus-summary-update-hook)
3388 (forward-line 1))))
3390 (defun gnus-summary-update-line (&optional dont-update)
3391 "Update summary line after change."
3392 (when (and gnus-summary-default-score
3393 (not gnus-summary-inhibit-highlight))
3394 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3395 (article (gnus-summary-article-number))
3396 (score (gnus-summary-article-score article)))
3397 (unless dont-update
3398 (if (and gnus-summary-mark-below
3399 (< (gnus-summary-article-score)
3400 gnus-summary-mark-below))
3401 ;; This article has a low score, so we mark it as read.
3402 (when (memq article gnus-newsgroup-unreads)
3403 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3404 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3405 ;; This article was previously marked as read on account
3406 ;; of a low score, but now it has risen, so we mark it as
3407 ;; unread.
3408 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3409 (gnus-summary-update-mark
3410 (if (or (null gnus-summary-default-score)
3411 (<= (abs (- score gnus-summary-default-score))
3412 gnus-summary-zcore-fuzz))
3413 ? ;Whitespace
3414 (if (< score gnus-summary-default-score)
3415 gnus-score-below-mark gnus-score-over-mark))
3416 'score))
3417 ;; Do visual highlighting.
3418 (when (gnus-visual-p 'summary-highlight 'highlight)
3419 (gnus-run-hooks 'gnus-summary-update-hook)))))
3421 (defvar gnus-tmp-new-adopts nil)
3423 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3424 "Return the number of articles in THREAD.
3425 This may be 0 in some cases -- if none of the articles in
3426 the thread are to be displayed."
3427 (let* ((number
3428 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3429 (cond
3430 ((not (listp thread))
3432 ((and (consp thread) (cdr thread))
3433 (apply
3434 '+ 1 (mapcar
3435 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3436 ((null thread)
3438 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3440 (t 0))))
3441 (when (and level (zerop level) gnus-tmp-new-adopts)
3442 (incf number
3443 (apply '+ (mapcar
3444 'gnus-summary-number-of-articles-in-thread
3445 gnus-tmp-new-adopts))))
3446 (if char
3447 (if (> number 1) gnus-not-empty-thread-mark
3448 gnus-empty-thread-mark)
3449 number)))
3451 (defsubst gnus-summary-line-message-size (head)
3452 "Return pretty-printed version of message size.
3453 This function is intended to be used in
3454 `gnus-summary-line-format-alist'."
3455 (let ((c (or (mail-header-chars head) -1)))
3456 (cond ((< c 0) "n/a") ; chars not available
3457 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3458 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3459 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3460 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3463 (defun gnus-summary-set-local-parameters (group)
3464 "Go through the local params of GROUP and set all variable specs in that list."
3465 (let ((params (gnus-group-find-parameter group))
3466 (vars '(quit-config)) ; Ignore quit-config.
3467 elem)
3468 (while params
3469 (setq elem (car params)
3470 params (cdr params))
3471 (and (consp elem) ; Has to be a cons.
3472 (consp (cdr elem)) ; The cdr has to be a list.
3473 (symbolp (car elem)) ; Has to be a symbol in there.
3474 (not (memq (car elem) vars))
3475 (ignore-errors ; So we set it.
3476 (push (car elem) vars)
3477 (make-local-variable (car elem))
3478 (set (car elem) (eval (nth 1 elem))))))))
3480 (defun gnus-summary-read-group (group &optional show-all no-article
3481 kill-buffer no-display backward
3482 select-articles)
3483 "Start reading news in newsgroup GROUP.
3484 If SHOW-ALL is non-nil, already read articles are also listed.
3485 If NO-ARTICLE is non-nil, no article is selected initially.
3486 If NO-DISPLAY, don't generate a summary buffer."
3487 (let (result)
3488 (while (and group
3489 (null (setq result
3490 (let ((gnus-auto-select-next nil))
3491 (or (gnus-summary-read-group-1
3492 group show-all no-article
3493 kill-buffer no-display
3494 select-articles)
3495 (setq show-all nil
3496 select-articles nil)))))
3497 (eq gnus-auto-select-next 'quietly))
3498 (set-buffer gnus-group-buffer)
3499 ;; The entry function called above goes to the next
3500 ;; group automatically, so we go two groups back
3501 ;; if we are searching for the previous group.
3502 (when backward
3503 (gnus-group-prev-unread-group 2))
3504 (if (not (equal group (gnus-group-group-name)))
3505 (setq group (gnus-group-group-name))
3506 (setq group nil)))
3507 result))
3509 (defun gnus-summary-read-group-1 (group show-all no-article
3510 kill-buffer no-display
3511 &optional select-articles)
3512 ;; Killed foreign groups can't be entered.
3513 ;; (when (and (not (gnus-group-native-p group))
3514 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3515 ;; (error "Dead non-native groups can't be entered"))
3516 (gnus-message 5 "Retrieving newsgroup: %s..."
3517 (gnus-group-decoded-name group))
3518 (let* ((new-group (gnus-summary-setup-buffer group))
3519 (quit-config (gnus-group-quit-config group))
3520 (did-select (and new-group (gnus-select-newsgroup
3521 group show-all select-articles))))
3522 (cond
3523 ;; This summary buffer exists already, so we just select it.
3524 ((not new-group)
3525 (gnus-set-global-variables)
3526 (when kill-buffer
3527 (gnus-kill-or-deaden-summary kill-buffer))
3528 (gnus-configure-windows 'summary 'force)
3529 (gnus-set-mode-line 'summary)
3530 (gnus-summary-position-point)
3531 (message "")
3533 ;; We couldn't select this group.
3534 ((null did-select)
3535 (when (and (eq major-mode 'gnus-summary-mode)
3536 (not (equal (current-buffer) kill-buffer)))
3537 (kill-buffer (current-buffer))
3538 (if (not quit-config)
3539 (progn
3540 ;; Update the info -- marks might need to be removed,
3541 ;; for instance.
3542 (gnus-summary-update-info)
3543 (set-buffer gnus-group-buffer)
3544 (gnus-group-jump-to-group group)
3545 (gnus-group-next-unread-group 1))
3546 (gnus-handle-ephemeral-exit quit-config)))
3547 (let ((grpinfo (gnus-get-info group)))
3548 (if (null (gnus-info-read grpinfo))
3549 (gnus-message 3 "Group %s contains no messages"
3550 (gnus-group-decoded-name group))
3551 (gnus-message 3 "Can't select group")))
3552 nil)
3553 ;; The user did a `C-g' while prompting for number of articles,
3554 ;; so we exit this group.
3555 ((eq did-select 'quit)
3556 (and (eq major-mode 'gnus-summary-mode)
3557 (not (equal (current-buffer) kill-buffer))
3558 (kill-buffer (current-buffer)))
3559 (when kill-buffer
3560 (gnus-kill-or-deaden-summary kill-buffer))
3561 (if (not quit-config)
3562 (progn
3563 (set-buffer gnus-group-buffer)
3564 (gnus-group-jump-to-group group)
3565 (gnus-group-next-unread-group 1)
3566 (gnus-configure-windows 'group 'force))
3567 (gnus-handle-ephemeral-exit quit-config))
3568 ;; Finally signal the quit.
3569 (signal 'quit nil))
3570 ;; The group was successfully selected.
3572 (gnus-set-global-variables)
3573 ;; Save the active value in effect when the group was entered.
3574 (setq gnus-newsgroup-active
3575 (gnus-copy-sequence
3576 (gnus-active gnus-newsgroup-name)))
3577 ;; You can change the summary buffer in some way with this hook.
3578 (gnus-run-hooks 'gnus-select-group-hook)
3579 (when (memq 'summary (gnus-update-format-specifications
3580 nil 'summary 'summary-mode 'summary-dummy))
3581 ;; The format specification for the summary line was updated,
3582 ;; so we need to update the mark positions as well.
3583 (gnus-update-summary-mark-positions))
3584 ;; Do score processing.
3585 (when gnus-use-scoring
3586 (gnus-possibly-score-headers))
3587 ;; Check whether to fill in the gaps in the threads.
3588 (when gnus-build-sparse-threads
3589 (gnus-build-sparse-threads))
3590 ;; Find the initial limit.
3591 (if gnus-show-threads
3592 (if show-all
3593 (let ((gnus-newsgroup-dormant nil))
3594 (gnus-summary-initial-limit show-all))
3595 (gnus-summary-initial-limit show-all))
3596 ;; When unthreaded, all articles are always shown.
3597 (setq gnus-newsgroup-limit
3598 (mapcar
3599 (lambda (header) (mail-header-number header))
3600 gnus-newsgroup-headers)))
3601 ;; Generate the summary buffer.
3602 (unless no-display
3603 (gnus-summary-prepare))
3604 (when gnus-use-trees
3605 (gnus-tree-open group)
3606 (setq gnus-summary-highlight-line-function
3607 'gnus-tree-highlight-article))
3608 ;; If the summary buffer is empty, but there are some low-scored
3609 ;; articles or some excluded dormants, we include these in the
3610 ;; buffer.
3611 (when (and (zerop (buffer-size))
3612 (not no-display))
3613 (cond (gnus-newsgroup-dormant
3614 (gnus-summary-limit-include-dormant))
3615 ((and gnus-newsgroup-scored show-all)
3616 (gnus-summary-limit-include-expunged t))))
3617 ;; Function `gnus-apply-kill-file' must be called in this hook.
3618 (gnus-run-hooks 'gnus-apply-kill-hook)
3619 (if (and (zerop (buffer-size))
3620 (not no-display))
3621 (progn
3622 ;; This newsgroup is empty.
3623 (gnus-summary-catchup-and-exit nil t)
3624 (gnus-message 6 "No unread news")
3625 (when kill-buffer
3626 (gnus-kill-or-deaden-summary kill-buffer))
3627 ;; Return nil from this function.
3628 nil)
3629 ;; Hide conversation thread subtrees. We cannot do this in
3630 ;; gnus-summary-prepare-hook since kill processing may not
3631 ;; work with hidden articles.
3632 (gnus-summary-maybe-hide-threads)
3633 (when kill-buffer
3634 (gnus-kill-or-deaden-summary kill-buffer))
3635 (gnus-summary-auto-select-subject)
3636 ;; Show first unread article if requested.
3637 (if (and (not no-article)
3638 (not no-display)
3639 gnus-newsgroup-unreads
3640 gnus-auto-select-first)
3641 (progn
3642 (gnus-configure-windows 'summary)
3643 (let ((art (gnus-summary-article-number)))
3644 (unless (and (not gnus-plugged)
3645 (or (memq art gnus-newsgroup-undownloaded)
3646 (memq art gnus-newsgroup-downloadable)))
3647 (gnus-summary-goto-article art))))
3648 ;; Don't select any articles.
3649 (gnus-summary-position-point)
3650 (gnus-configure-windows 'summary 'force)
3651 (gnus-set-mode-line 'summary))
3652 (when (and gnus-auto-center-group
3653 (get-buffer-window gnus-group-buffer t))
3654 ;; Gotta use windows, because recenter does weird stuff if
3655 ;; the current buffer ain't the displayed window.
3656 (let ((owin (selected-window)))
3657 (select-window (get-buffer-window gnus-group-buffer t))
3658 (when (gnus-group-goto-group group)
3659 (recenter))
3660 (select-window owin)))
3661 ;; Mark this buffer as "prepared".
3662 (setq gnus-newsgroup-prepared t)
3663 (gnus-run-hooks 'gnus-summary-prepared-hook)
3664 (unless (gnus-ephemeral-group-p group)
3665 (gnus-group-update-group group))
3666 t)))))
3668 (defun gnus-summary-auto-select-subject ()
3669 "Select the subject line on initial group entry."
3670 (goto-char (point-min))
3671 (cond
3672 ((eq gnus-auto-select-subject 'best)
3673 (gnus-summary-best-unread-subject))
3674 ((eq gnus-auto-select-subject 'unread)
3675 (gnus-summary-first-unread-subject))
3676 ((eq gnus-auto-select-subject 'unseen)
3677 (gnus-summary-first-unseen-subject))
3678 ((eq gnus-auto-select-subject 'unseen-or-unread)
3679 (gnus-summary-first-unseen-or-unread-subject))
3680 ((eq gnus-auto-select-subject 'first)
3681 ;; Do nothing.
3683 ((functionp gnus-auto-select-subject)
3684 (funcall gnus-auto-select-subject))))
3686 (defun gnus-summary-prepare ()
3687 "Generate the summary buffer."
3688 (interactive)
3689 (let ((buffer-read-only nil))
3690 (erase-buffer)
3691 (setq gnus-newsgroup-data nil
3692 gnus-newsgroup-data-reverse nil)
3693 (gnus-run-hooks 'gnus-summary-generate-hook)
3694 ;; Generate the buffer, either with threads or without.
3695 (when gnus-newsgroup-headers
3696 (gnus-summary-prepare-threads
3697 (if gnus-show-threads
3698 (gnus-sort-gathered-threads
3699 (funcall gnus-summary-thread-gathering-function
3700 (gnus-sort-threads
3701 (gnus-cut-threads (gnus-make-threads)))))
3702 ;; Unthreaded display.
3703 (gnus-sort-articles gnus-newsgroup-headers))))
3704 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3705 ;; Call hooks for modifying summary buffer.
3706 (goto-char (point-min))
3707 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3709 (defsubst gnus-general-simplify-subject (subject)
3710 "Simplify subject by the same rules as `gnus-gather-threads-by-subject'."
3711 (setq subject
3712 (cond
3713 ;; Truncate the subject.
3714 (gnus-simplify-subject-functions
3715 (gnus-map-function gnus-simplify-subject-functions subject))
3716 ((numberp gnus-summary-gather-subject-limit)
3717 (setq subject (gnus-simplify-subject-re subject))
3718 (if (> (length subject) gnus-summary-gather-subject-limit)
3719 (substring subject 0 gnus-summary-gather-subject-limit)
3720 subject))
3721 ;; Fuzzily simplify it.
3722 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3723 (gnus-simplify-subject-fuzzy subject))
3724 ;; Just remove the leading "Re:".
3726 (gnus-simplify-subject-re subject))))
3728 (if (and gnus-summary-gather-exclude-subject
3729 (string-match gnus-summary-gather-exclude-subject subject))
3730 nil ; This article shouldn't be gathered
3731 subject))
3733 (defun gnus-summary-simplify-subject-query ()
3734 "Query where the respool algorithm would put this article."
3735 (interactive)
3736 (gnus-summary-select-article)
3737 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
3739 (defun gnus-gather-threads-by-subject (threads)
3740 "Gather threads by looking at Subject headers."
3741 (if (not gnus-summary-make-false-root)
3742 threads
3743 (let ((hashtb (gnus-make-hashtable 1024))
3744 (prev threads)
3745 (result threads)
3746 subject hthread whole-subject)
3747 (while threads
3748 (setq subject (gnus-general-simplify-subject
3749 (setq whole-subject (mail-header-subject
3750 (caar threads)))))
3751 (when subject
3752 (if (setq hthread (gnus-gethash subject hashtb))
3753 (progn
3754 ;; We enter a dummy root into the thread, if we
3755 ;; haven't done that already.
3756 (unless (stringp (caar hthread))
3757 (setcar hthread (list whole-subject (car hthread))))
3758 ;; We add this new gathered thread to this gathered
3759 ;; thread.
3760 (setcdr (car hthread)
3761 (nconc (cdar hthread) (list (car threads))))
3762 ;; Remove it from the list of threads.
3763 (setcdr prev (cdr threads))
3764 (setq threads prev))
3765 ;; Enter this thread into the hash table.
3766 (gnus-sethash subject
3767 (if gnus-summary-make-false-root-always
3768 (progn
3769 ;; If you want a dummy root above all
3770 ;; threads...
3771 (setcar threads (list whole-subject
3772 (car threads)))
3773 threads)
3774 threads)
3775 hashtb)))
3776 (setq prev threads)
3777 (setq threads (cdr threads)))
3778 result)))
3780 (defun gnus-gather-threads-by-references (threads)
3781 "Gather threads by looking at References headers."
3782 (let ((idhashtb (gnus-make-hashtable 1024))
3783 (thhashtb (gnus-make-hashtable 1024))
3784 (prev threads)
3785 (result threads)
3786 ids references id gthread gid entered ref)
3787 (while threads
3788 (when (setq references (mail-header-references (caar threads)))
3789 (setq id (mail-header-id (caar threads))
3790 ids (inline (gnus-split-references references))
3791 entered nil)
3792 (while (setq ref (pop ids))
3793 (setq ids (delete ref ids))
3794 (if (not (setq gid (gnus-gethash ref idhashtb)))
3795 (progn
3796 (gnus-sethash ref id idhashtb)
3797 (gnus-sethash id threads thhashtb))
3798 (setq gthread (gnus-gethash gid thhashtb))
3799 (unless entered
3800 ;; We enter a dummy root into the thread, if we
3801 ;; haven't done that already.
3802 (unless (stringp (caar gthread))
3803 (setcar gthread (list (mail-header-subject (caar gthread))
3804 (car gthread))))
3805 ;; We add this new gathered thread to this gathered
3806 ;; thread.
3807 (setcdr (car gthread)
3808 (nconc (cdar gthread) (list (car threads)))))
3809 ;; Add it into the thread hash table.
3810 (gnus-sethash id gthread thhashtb)
3811 (setq entered t)
3812 ;; Remove it from the list of threads.
3813 (setcdr prev (cdr threads))
3814 (setq threads prev))))
3815 (setq prev threads)
3816 (setq threads (cdr threads)))
3817 result))
3819 (defun gnus-sort-gathered-threads (threads)
3820 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3821 (let ((result threads))
3822 (while threads
3823 (when (stringp (caar threads))
3824 (setcdr (car threads)
3825 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3826 (setq threads (cdr threads)))
3827 result))
3829 (defun gnus-thread-loop-p (root thread)
3830 "Say whether ROOT is in THREAD."
3831 (let ((stack (list thread))
3832 (infloop 0)
3834 (while (setq thread (pop stack))
3835 (setq th (cdr thread))
3836 (while (and th
3837 (not (eq (caar th) root)))
3838 (pop th))
3839 (if th
3840 ;; We have found a loop.
3841 (let (ref-dep)
3842 (setcdr thread (delq (car th) (cdr thread)))
3843 (if (boundp (setq ref-dep (intern "none"
3844 gnus-newsgroup-dependencies)))
3845 (setcdr (symbol-value ref-dep)
3846 (nconc (cdr (symbol-value ref-dep))
3847 (list (car th))))
3848 (set ref-dep (list nil (car th))))
3849 (setq infloop 1
3850 stack nil))
3851 ;; Push all the subthreads onto the stack.
3852 (push (cdr thread) stack)))
3853 infloop))
3855 (defun gnus-make-threads ()
3856 "Go through the dependency hashtb and find the roots. Return all threads."
3857 (let (threads)
3858 (while (catch 'infloop
3859 (mapatoms
3860 (lambda (refs)
3861 ;; Deal with self-referencing References loops.
3862 (when (and (car (symbol-value refs))
3863 (not (zerop
3864 (apply
3866 (mapcar
3867 (lambda (thread)
3868 (gnus-thread-loop-p
3869 (car (symbol-value refs)) thread))
3870 (cdr (symbol-value refs)))))))
3871 (setq threads nil)
3872 (throw 'infloop t))
3873 (unless (car (symbol-value refs))
3874 ;; These threads do not refer back to any other
3875 ;; articles, so they're roots.
3876 (setq threads (append (cdr (symbol-value refs)) threads))))
3877 gnus-newsgroup-dependencies)))
3878 threads))
3880 ;; Build the thread tree.
3881 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3882 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3884 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3885 if it was already present.
3887 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3888 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3889 Message-IDs will be renamed to a unique Message-ID before being
3890 entered.
3892 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3893 (let* ((id (mail-header-id header))
3894 (id-dep (and id (intern id dependencies)))
3895 parent-id ref ref-dep ref-header replaced)
3896 ;; Enter this `header' in the `dependencies' table.
3897 (cond
3898 ((not id-dep)
3899 (setq header nil))
3900 ;; The first two cases do the normal part: enter a new `header'
3901 ;; in the `dependencies' table.
3902 ((not (boundp id-dep))
3903 (set id-dep (list header)))
3904 ((null (car (symbol-value id-dep)))
3905 (setcar (symbol-value id-dep) header))
3907 ;; From here the `header' was already present in the
3908 ;; `dependencies' table.
3909 (force-new
3910 ;; Overrides an existing entry;
3911 ;; just set the header part of the entry.
3912 (setcar (symbol-value id-dep) header)
3913 (setq replaced t))
3915 ;; Renames the existing `header' to a unique Message-ID.
3916 ((not gnus-summary-ignore-duplicates)
3917 ;; An article with this Message-ID has already been seen.
3918 ;; We rename the Message-ID.
3919 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3920 (list header))
3921 (mail-header-set-id header id))
3923 ;; The last case ignores an existing entry, except it adds any
3924 ;; additional Xrefs (in case the two articles came from different
3925 ;; servers.
3926 ;; Also sets `header' to `nil' meaning that the `dependencies'
3927 ;; table was *not* modified.
3929 (mail-header-set-xref
3930 (car (symbol-value id-dep))
3931 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3933 (or (mail-header-xref header) "")))
3934 (setq header nil)))
3936 (when (and header (not replaced))
3937 ;; First check that we are not creating a References loop.
3938 (setq parent-id (gnus-parent-id (mail-header-references header)))
3939 (setq ref parent-id)
3940 (while (and ref
3941 (setq ref-dep (intern-soft ref dependencies))
3942 (boundp ref-dep)
3943 (setq ref-header (car (symbol-value ref-dep))))
3944 (if (string= id ref)
3945 ;; Yuk! This is a reference loop. Make the article be a
3946 ;; root article.
3947 (progn
3948 (mail-header-set-references (car (symbol-value id-dep)) "none")
3949 (setq ref nil)
3950 (setq parent-id nil))
3951 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3952 (setq ref-dep (intern (or parent-id "none") dependencies))
3953 (if (boundp ref-dep)
3954 (setcdr (symbol-value ref-dep)
3955 (nconc (cdr (symbol-value ref-dep))
3956 (list (symbol-value id-dep))))
3957 (set ref-dep (list nil (symbol-value id-dep)))))
3958 header))
3960 (defun gnus-extract-message-id-from-in-reply-to (string)
3961 (if (string-match "<[^>]+>" string)
3962 (substring string (match-beginning 0) (match-end 0))
3963 nil))
3965 (defun gnus-build-sparse-threads ()
3966 (let ((headers gnus-newsgroup-headers)
3967 (mail-parse-charset gnus-newsgroup-charset)
3968 (gnus-summary-ignore-duplicates t)
3969 header references generation relations
3970 subject child end new-child date)
3971 ;; First we create an alist of generations/relations, where
3972 ;; generations is how much we trust the relation, and the relation
3973 ;; is parent/child.
3974 (gnus-message 7 "Making sparse threads...")
3975 (save-excursion
3976 (nnheader-set-temp-buffer " *gnus sparse threads*")
3977 (while (setq header (pop headers))
3978 (when (and (setq references (mail-header-references header))
3979 (not (string= references "")))
3980 (insert references)
3981 (setq child (mail-header-id header)
3982 subject (mail-header-subject header)
3983 date (mail-header-date header)
3984 generation 0)
3985 (while (search-backward ">" nil t)
3986 (setq end (1+ (point)))
3987 (when (search-backward "<" nil t)
3988 (setq new-child (buffer-substring (point) end))
3989 (push (list (incf generation)
3990 child (setq child new-child)
3991 subject date)
3992 relations)))
3993 (when child
3994 (push (list (1+ generation) child nil subject) relations))
3995 (erase-buffer)))
3996 (kill-buffer (current-buffer)))
3997 ;; Sort over trustworthiness.
3998 (mapcar
3999 (lambda (relation)
4000 (when (gnus-dependencies-add-header
4001 (make-full-mail-header
4002 gnus-reffed-article-number
4003 (nth 3 relation) "" (or (nth 4 relation) "")
4004 (nth 1 relation)
4005 (or (nth 2 relation) "") 0 0 "")
4006 gnus-newsgroup-dependencies nil)
4007 (push gnus-reffed-article-number gnus-newsgroup-limit)
4008 (push gnus-reffed-article-number gnus-newsgroup-sparse)
4009 (push (cons gnus-reffed-article-number gnus-sparse-mark)
4010 gnus-newsgroup-reads)
4011 (decf gnus-reffed-article-number)))
4012 (sort relations 'car-less-than-car))
4013 (gnus-message 7 "Making sparse threads...done")))
4015 (defun gnus-build-old-threads ()
4016 ;; Look at all the articles that refer back to old articles, and
4017 ;; fetch the headers for the articles that aren't there. This will
4018 ;; build complete threads - if the roots haven't been expired by the
4019 ;; server, that is.
4020 (let ((mail-parse-charset gnus-newsgroup-charset)
4021 id heads)
4022 (mapatoms
4023 (lambda (refs)
4024 (when (not (car (symbol-value refs)))
4025 (setq heads (cdr (symbol-value refs)))
4026 (while heads
4027 (if (memq (mail-header-number (caar heads))
4028 gnus-newsgroup-dormant)
4029 (setq heads (cdr heads))
4030 (setq id (symbol-name refs))
4031 (while (and (setq id (gnus-build-get-header id))
4032 (not (car (gnus-id-to-thread id)))))
4033 (setq heads nil)))))
4034 gnus-newsgroup-dependencies)))
4036 (defsubst gnus-remove-odd-characters (string)
4037 "Translate STRING into something that doesn't contain weird characters."
4038 (mm-subst-char-in-string
4039 ?\r ?\-
4040 (mm-subst-char-in-string
4041 ?\n ?\- string)))
4043 ;; This function has to be called with point after the article number
4044 ;; on the beginning of the line.
4045 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
4046 (let ((eol (gnus-point-at-eol))
4047 (buffer (current-buffer))
4048 header references in-reply-to)
4050 ;; overview: [num subject from date id refs chars lines misc]
4051 (unwind-protect
4052 (let (x)
4053 (narrow-to-region (point) eol)
4054 (unless (eobp)
4055 (forward-char))
4057 (setq header
4058 (make-full-mail-header
4059 number ; number
4060 (condition-case () ; subject
4061 (gnus-remove-odd-characters
4062 (funcall gnus-decode-encoded-word-function
4063 (setq x (nnheader-nov-field))))
4064 (error x))
4065 (condition-case () ; from
4066 (gnus-remove-odd-characters
4067 (funcall gnus-decode-encoded-word-function
4068 (setq x (nnheader-nov-field))))
4069 (error x))
4070 (nnheader-nov-field) ; date
4071 (nnheader-nov-read-message-id) ; id
4072 (setq references (nnheader-nov-field)) ; refs
4073 (nnheader-nov-read-integer) ; chars
4074 (nnheader-nov-read-integer) ; lines
4075 (unless (eobp)
4076 (if (looking-at "Xref: ")
4077 (goto-char (match-end 0)))
4078 (nnheader-nov-field)) ; Xref
4079 (nnheader-nov-parse-extra)))) ; extra
4081 (widen))
4083 (when (and (string= references "")
4084 (setq in-reply-to (mail-header-extra header))
4085 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
4086 (mail-header-set-references
4087 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
4089 (when gnus-alter-header-function
4090 (funcall gnus-alter-header-function header))
4091 (gnus-dependencies-add-header header dependencies force-new)))
4093 (defun gnus-build-get-header (id)
4094 "Look through the buffer of NOV lines and find the header to ID.
4095 Enter this line into the dependencies hash table, and return
4096 the id of the parent article (if any)."
4097 (let ((deps gnus-newsgroup-dependencies)
4098 found header)
4099 (prog1
4100 (save-excursion
4101 (set-buffer nntp-server-buffer)
4102 (let ((case-fold-search nil))
4103 (goto-char (point-min))
4104 (while (and (not found)
4105 (search-forward id nil t))
4106 (beginning-of-line)
4107 (setq found (looking-at
4108 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
4109 (regexp-quote id))))
4110 (or found (beginning-of-line 2)))
4111 (when found
4112 (beginning-of-line)
4113 (and
4114 (setq header (gnus-nov-parse-line
4115 (read (current-buffer)) deps))
4116 (gnus-parent-id (mail-header-references header))))))
4117 (when header
4118 (let ((number (mail-header-number header)))
4119 (push number gnus-newsgroup-limit)
4120 (push header gnus-newsgroup-headers)
4121 (if (memq number gnus-newsgroup-unselected)
4122 (progn
4123 (setq gnus-newsgroup-unreads
4124 (gnus-add-to-sorted-list gnus-newsgroup-unreads
4125 number))
4126 (setq gnus-newsgroup-unselected
4127 (delq number gnus-newsgroup-unselected)))
4128 (push number gnus-newsgroup-ancient)))))))
4130 (defun gnus-build-all-threads ()
4131 "Read all the headers."
4132 (let ((gnus-summary-ignore-duplicates t)
4133 (mail-parse-charset gnus-newsgroup-charset)
4134 (dependencies gnus-newsgroup-dependencies)
4135 header article)
4136 (save-excursion
4137 (set-buffer nntp-server-buffer)
4138 (let ((case-fold-search nil))
4139 (goto-char (point-min))
4140 (while (not (eobp))
4141 (ignore-errors
4142 (setq article (read (current-buffer))
4143 header (gnus-nov-parse-line article dependencies)))
4144 (when header
4145 (save-excursion
4146 (set-buffer gnus-summary-buffer)
4147 (push header gnus-newsgroup-headers)
4148 (if (memq (setq article (mail-header-number header))
4149 gnus-newsgroup-unselected)
4150 (progn
4151 (setq gnus-newsgroup-unreads
4152 (gnus-add-to-sorted-list
4153 gnus-newsgroup-unreads article))
4154 (setq gnus-newsgroup-unselected
4155 (delq article gnus-newsgroup-unselected)))
4156 (push article gnus-newsgroup-ancient)))
4157 (forward-line 1)))))))
4159 (defun gnus-summary-update-article-line (article header)
4160 "Update the line for ARTICLE using HEADER."
4161 (let* ((id (mail-header-id header))
4162 (thread (gnus-id-to-thread id)))
4163 (unless thread
4164 (error "Article in no thread"))
4165 ;; Update the thread.
4166 (setcar thread header)
4167 (gnus-summary-goto-subject article)
4168 (let* ((datal (gnus-data-find-list article))
4169 (data (car datal))
4170 (buffer-read-only nil)
4171 (level (gnus-summary-thread-level)))
4172 (gnus-delete-line)
4173 (let ((inserted (- (point)
4174 (progn
4175 (gnus-summary-insert-line
4176 header level nil
4177 (memq article gnus-newsgroup-undownloaded)
4178 (gnus-article-mark article)
4179 (memq article gnus-newsgroup-replied)
4180 (memq article gnus-newsgroup-expirable)
4181 ;; Only insert the Subject string when it's different
4182 ;; from the previous Subject string.
4183 (if (and
4184 gnus-show-threads
4185 (gnus-subject-equal
4186 (condition-case ()
4187 (mail-header-subject
4188 (gnus-data-header
4189 (cadr
4190 (gnus-data-find-list
4191 article
4192 (gnus-data-list t)))))
4193 ;; Error on the side of excessive subjects.
4194 (error ""))
4195 (mail-header-subject header)))
4197 (mail-header-subject header))
4198 nil (cdr (assq article gnus-newsgroup-scored))
4199 (memq article gnus-newsgroup-processable))
4200 (point)))))
4201 (when (cdr datal)
4202 (gnus-data-update-list
4203 (cdr datal)
4204 (- (gnus-data-pos data) (gnus-data-pos (cadr datal)) inserted)))))))
4206 (defun gnus-summary-update-article (article &optional iheader)
4207 "Update ARTICLE in the summary buffer."
4208 (set-buffer gnus-summary-buffer)
4209 (let* ((header (gnus-summary-article-header article))
4210 (id (mail-header-id header))
4211 (data (gnus-data-find article))
4212 (thread (gnus-id-to-thread id))
4213 (references (mail-header-references header))
4214 (parent
4215 (gnus-id-to-thread
4216 (or (gnus-parent-id
4217 (when (and references
4218 (not (equal "" references)))
4219 references))
4220 "none")))
4221 (buffer-read-only nil)
4222 (old (car thread)))
4223 (when thread
4224 (unless iheader
4225 (setcar thread nil)
4226 (when parent
4227 (delq thread parent)))
4228 (if (gnus-summary-insert-subject id header)
4229 ;; Set the (possibly) new article number in the data structure.
4230 (gnus-data-set-number data (gnus-id-to-article id))
4231 (setcar thread old)
4232 nil))))
4234 (defun gnus-rebuild-thread (id &optional line)
4235 "Rebuild the thread containing ID.
4236 If LINE, insert the rebuilt thread starting on line LINE."
4237 (let ((buffer-read-only nil)
4238 old-pos current thread data)
4239 (if (not gnus-show-threads)
4240 (setq thread (list (car (gnus-id-to-thread id))))
4241 ;; Get the thread this article is part of.
4242 (setq thread (gnus-remove-thread id)))
4243 (setq old-pos (gnus-point-at-bol))
4244 (setq current (save-excursion
4245 (and (re-search-backward "[\r\n]" nil t)
4246 (gnus-summary-article-number))))
4247 ;; If this is a gathered thread, we have to go some re-gathering.
4248 (when (stringp (car thread))
4249 (let ((subject (car thread))
4250 roots thr)
4251 (setq thread (cdr thread))
4252 (while thread
4253 (unless (memq (setq thr (gnus-id-to-thread
4254 (gnus-root-id
4255 (mail-header-id (caar thread)))))
4256 roots)
4257 (push thr roots))
4258 (setq thread (cdr thread)))
4259 ;; We now have all (unique) roots.
4260 (if (= (length roots) 1)
4261 ;; All the loose roots are now one solid root.
4262 (setq thread (car roots))
4263 (setq thread (cons subject (gnus-sort-threads roots))))))
4264 (let (threads)
4265 ;; We then insert this thread into the summary buffer.
4266 (when line
4267 (goto-char (point-min))
4268 (forward-line (1- line)))
4269 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4270 (if gnus-show-threads
4271 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4272 (gnus-summary-prepare-unthreaded thread))
4273 (setq data (nreverse gnus-newsgroup-data))
4274 (setq threads gnus-newsgroup-threads))
4275 ;; We splice the new data into the data structure.
4276 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4277 ;;!!! then we want to insert at the beginning of the buffer.
4278 ;;!!! That happens to be true with Gnus now, but that may
4279 ;;!!! change in the future. Perhaps.
4280 (gnus-data-enter-list
4281 (if line nil current) data (- (point) old-pos))
4282 (setq gnus-newsgroup-threads
4283 (nconc threads gnus-newsgroup-threads))
4284 (gnus-data-compute-positions))))
4286 (defun gnus-number-to-header (number)
4287 "Return the header for article NUMBER."
4288 (let ((headers gnus-newsgroup-headers))
4289 (while (and headers
4290 (not (= number (mail-header-number (car headers)))))
4291 (pop headers))
4292 (when headers
4293 (car headers))))
4295 (defun gnus-parent-headers (in-headers &optional generation)
4296 "Return the headers of the GENERATIONeth parent of HEADERS."
4297 (unless generation
4298 (setq generation 1))
4299 (let ((parent t)
4300 (headers in-headers)
4301 references)
4302 (while (and parent
4303 (not (zerop generation))
4304 (setq references (mail-header-references headers)))
4305 (setq headers (if (and references
4306 (setq parent (gnus-parent-id references)))
4307 (car (gnus-id-to-thread parent))
4308 nil))
4309 (decf generation))
4310 (and (not (eq headers in-headers))
4311 headers)))
4313 (defun gnus-id-to-thread (id)
4314 "Return the (sub-)thread where ID appears."
4315 (gnus-gethash id gnus-newsgroup-dependencies))
4317 (defun gnus-id-to-article (id)
4318 "Return the article number of ID."
4319 (let ((thread (gnus-id-to-thread id)))
4320 (when (and thread
4321 (car thread))
4322 (mail-header-number (car thread)))))
4324 (defun gnus-id-to-header (id)
4325 "Return the article headers of ID."
4326 (car (gnus-id-to-thread id)))
4328 (defun gnus-article-displayed-root-p (article)
4329 "Say whether ARTICLE is a root(ish) article."
4330 (let ((level (gnus-summary-thread-level article))
4331 (refs (mail-header-references (gnus-summary-article-header article)))
4332 particle)
4333 (cond
4334 ((null level) nil)
4335 ((zerop level) t)
4336 ((null refs) t)
4337 ((null (gnus-parent-id refs)) t)
4338 ((and (= 1 level)
4339 (null (setq particle (gnus-id-to-article
4340 (gnus-parent-id refs))))
4341 (null (gnus-summary-thread-level particle)))))))
4343 (defun gnus-root-id (id)
4344 "Return the id of the root of the thread where ID appears."
4345 (let (last-id prev)
4346 (while (and id (setq prev (car (gnus-id-to-thread id))))
4347 (setq last-id id
4348 id (gnus-parent-id (mail-header-references prev))))
4349 last-id))
4351 (defun gnus-articles-in-thread (thread)
4352 "Return the list of articles in THREAD."
4353 (cons (mail-header-number (car thread))
4354 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4356 (defun gnus-remove-thread (id &optional dont-remove)
4357 "Remove the thread that has ID in it."
4358 (let (headers thread last-id)
4359 ;; First go up in this thread until we find the root.
4360 (setq last-id (gnus-root-id id)
4361 headers (message-flatten-list (gnus-id-to-thread last-id)))
4362 ;; We have now found the real root of this thread. It might have
4363 ;; been gathered into some loose thread, so we have to search
4364 ;; through the threads to find the thread we wanted.
4365 (let ((threads gnus-newsgroup-threads)
4366 sub)
4367 (while threads
4368 (setq sub (car threads))
4369 (if (stringp (car sub))
4370 ;; This is a gathered thread, so we look at the roots
4371 ;; below it to find whether this article is in this
4372 ;; gathered root.
4373 (progn
4374 (setq sub (cdr sub))
4375 (while sub
4376 (when (member (caar sub) headers)
4377 (setq thread (car threads)
4378 threads nil
4379 sub nil))
4380 (setq sub (cdr sub))))
4381 ;; It's an ordinary thread, so we check it.
4382 (when (eq (car sub) (car headers))
4383 (setq thread sub
4384 threads nil)))
4385 (setq threads (cdr threads)))
4386 ;; If this article is in no thread, then it's a root.
4387 (if thread
4388 (unless dont-remove
4389 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4390 (setq thread (gnus-id-to-thread last-id)))
4391 (when thread
4392 (prog1
4393 thread ; We return this thread.
4394 (unless dont-remove
4395 (if (stringp (car thread))
4396 (progn
4397 ;; If we use dummy roots, then we have to remove the
4398 ;; dummy root as well.
4399 (when (eq gnus-summary-make-false-root 'dummy)
4400 ;; We go to the dummy root by going to
4401 ;; the first sub-"thread", and then one line up.
4402 (gnus-summary-goto-article
4403 (mail-header-number (caadr thread)))
4404 (forward-line -1)
4405 (gnus-delete-line)
4406 (gnus-data-compute-positions))
4407 (setq thread (cdr thread))
4408 (while thread
4409 (gnus-remove-thread-1 (car thread))
4410 (setq thread (cdr thread))))
4411 (gnus-remove-thread-1 thread))))))))
4413 (defun gnus-remove-thread-1 (thread)
4414 "Remove the thread THREAD recursively."
4415 (let ((number (mail-header-number (pop thread)))
4417 (setq thread (reverse thread))
4418 (while thread
4419 (gnus-remove-thread-1 (pop thread)))
4420 (when (setq d (gnus-data-find number))
4421 (goto-char (gnus-data-pos d))
4422 (gnus-summary-show-thread)
4423 (gnus-data-remove
4424 number
4425 (- (gnus-point-at-bol)
4426 (prog1
4427 (1+ (gnus-point-at-eol))
4428 (gnus-delete-line)))))))
4430 (defun gnus-sort-threads-1 (threads func)
4431 (sort (mapcar (lambda (thread)
4432 (cons (car thread)
4433 (and (cdr thread)
4434 (gnus-sort-threads-1 (cdr thread) func))))
4435 threads) func))
4437 (defun gnus-sort-threads (threads)
4438 "Sort THREADS."
4439 (if (not gnus-thread-sort-functions)
4440 threads
4441 (gnus-message 8 "Sorting threads...")
4442 (let ((max-lisp-eval-depth 5000))
4443 (prog1 (gnus-sort-threads-1
4444 threads
4445 (gnus-make-sort-function gnus-thread-sort-functions))
4446 (gnus-message 8 "Sorting threads...done")))))
4448 (defun gnus-sort-articles (articles)
4449 "Sort ARTICLES."
4450 (when gnus-article-sort-functions
4451 (gnus-message 7 "Sorting articles...")
4452 (prog1
4453 (setq gnus-newsgroup-headers
4454 (sort articles (gnus-make-sort-function
4455 gnus-article-sort-functions)))
4456 (gnus-message 7 "Sorting articles...done"))))
4458 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4459 (defmacro gnus-thread-header (thread)
4460 "Return header of first article in THREAD.
4461 Note that THREAD must never, ever be anything else than a variable -
4462 using some other form will lead to serious barfage."
4463 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4464 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4465 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4466 (vector thread) 2))
4468 (defsubst gnus-article-sort-by-number (h1 h2)
4469 "Sort articles by article number."
4470 (< (mail-header-number h1)
4471 (mail-header-number h2)))
4473 (defun gnus-thread-sort-by-number (h1 h2)
4474 "Sort threads by root article number."
4475 (gnus-article-sort-by-number
4476 (gnus-thread-header h1) (gnus-thread-header h2)))
4478 (defsubst gnus-article-sort-by-random (h1 h2)
4479 "Sort articles by article number."
4480 (zerop (random 2)))
4482 (defun gnus-thread-sort-by-random (h1 h2)
4483 "Sort threads by root article number."
4484 (gnus-article-sort-by-random
4485 (gnus-thread-header h1) (gnus-thread-header h2)))
4487 (defsubst gnus-article-sort-by-lines (h1 h2)
4488 "Sort articles by article Lines header."
4489 (< (mail-header-lines h1)
4490 (mail-header-lines h2)))
4492 (defun gnus-thread-sort-by-lines (h1 h2)
4493 "Sort threads by root article Lines header."
4494 (gnus-article-sort-by-lines
4495 (gnus-thread-header h1) (gnus-thread-header h2)))
4497 (defsubst gnus-article-sort-by-chars (h1 h2)
4498 "Sort articles by octet length."
4499 (< (mail-header-chars h1)
4500 (mail-header-chars h2)))
4502 (defun gnus-thread-sort-by-chars (h1 h2)
4503 "Sort threads by root article octet length."
4504 (gnus-article-sort-by-chars
4505 (gnus-thread-header h1) (gnus-thread-header h2)))
4507 (defsubst gnus-article-sort-by-author (h1 h2)
4508 "Sort articles by root author."
4509 (string-lessp
4510 (let ((extract (funcall
4511 gnus-extract-address-components
4512 (mail-header-from h1))))
4513 (or (car extract) (cadr extract) ""))
4514 (let ((extract (funcall
4515 gnus-extract-address-components
4516 (mail-header-from h2))))
4517 (or (car extract) (cadr extract) ""))))
4519 (defun gnus-thread-sort-by-author (h1 h2)
4520 "Sort threads by root author."
4521 (gnus-article-sort-by-author
4522 (gnus-thread-header h1) (gnus-thread-header h2)))
4524 (defsubst gnus-article-sort-by-subject (h1 h2)
4525 "Sort articles by root subject."
4526 (string-lessp
4527 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4528 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4530 (defun gnus-thread-sort-by-subject (h1 h2)
4531 "Sort threads by root subject."
4532 (gnus-article-sort-by-subject
4533 (gnus-thread-header h1) (gnus-thread-header h2)))
4535 (defsubst gnus-article-sort-by-date (h1 h2)
4536 "Sort articles by root article date."
4537 (time-less-p
4538 (gnus-date-get-time (mail-header-date h1))
4539 (gnus-date-get-time (mail-header-date h2))))
4541 (defun gnus-thread-sort-by-date (h1 h2)
4542 "Sort threads by root article date."
4543 (gnus-article-sort-by-date
4544 (gnus-thread-header h1) (gnus-thread-header h2)))
4546 (defsubst gnus-article-sort-by-score (h1 h2)
4547 "Sort articles by root article score.
4548 Unscored articles will be counted as having a score of zero."
4549 (> (or (cdr (assq (mail-header-number h1)
4550 gnus-newsgroup-scored))
4551 gnus-summary-default-score 0)
4552 (or (cdr (assq (mail-header-number h2)
4553 gnus-newsgroup-scored))
4554 gnus-summary-default-score 0)))
4556 (defun gnus-thread-sort-by-score (h1 h2)
4557 "Sort threads by root article score."
4558 (gnus-article-sort-by-score
4559 (gnus-thread-header h1) (gnus-thread-header h2)))
4561 (defun gnus-thread-sort-by-total-score (h1 h2)
4562 "Sort threads by the sum of all scores in the thread.
4563 Unscored articles will be counted as having a score of zero."
4564 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4566 (defun gnus-thread-total-score (thread)
4567 ;; This function find the total score of THREAD.
4568 (cond
4569 ((null thread)
4571 ((consp thread)
4572 (if (stringp (car thread))
4573 (apply gnus-thread-score-function 0
4574 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4575 (gnus-thread-total-score-1 thread)))
4577 (gnus-thread-total-score-1 (list thread)))))
4579 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4580 "Sort threads such that the thread with the most recently arrived article comes first."
4581 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4583 (defun gnus-thread-highest-number (thread)
4584 "Return the highest article number in THREAD."
4585 (apply 'max (mapcar (lambda (header)
4586 (mail-header-number header))
4587 (message-flatten-list thread))))
4589 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4590 "Sort threads such that the thread with the most recently dated article comes first."
4591 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4593 (defun gnus-thread-latest-date (thread)
4594 "Return the highest article date in THREAD."
4595 (let ((previous-time 0))
4596 (apply 'max
4597 (mapcar
4598 (lambda (header)
4599 (setq previous-time
4600 (condition-case ()
4601 (time-to-seconds (mail-header-parse-date
4602 (mail-header-date header)))
4603 (error previous-time))))
4604 (sort
4605 (message-flatten-list thread)
4606 (lambda (h1 h2)
4607 (< (mail-header-number h1)
4608 (mail-header-number h2))))))))
4610 (defun gnus-thread-total-score-1 (root)
4611 ;; This function find the total score of the thread below ROOT.
4612 (setq root (car root))
4613 (apply gnus-thread-score-function
4614 (or (append
4615 (mapcar 'gnus-thread-total-score
4616 (cdr (gnus-id-to-thread (mail-header-id root))))
4617 (when (> (mail-header-number root) 0)
4618 (list (or (cdr (assq (mail-header-number root)
4619 gnus-newsgroup-scored))
4620 gnus-summary-default-score 0))))
4621 (list gnus-summary-default-score)
4622 '(0))))
4624 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4625 (defvar gnus-tmp-prev-subject nil)
4626 (defvar gnus-tmp-false-parent nil)
4627 (defvar gnus-tmp-root-expunged nil)
4628 (defvar gnus-tmp-dummy-line nil)
4630 (eval-when-compile (defvar gnus-tmp-header))
4631 (defun gnus-extra-header (type &optional header)
4632 "Return the extra header of TYPE."
4633 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4634 ""))
4636 (defvar gnus-tmp-thread-tree-header-string "")
4638 (defcustom gnus-sum-thread-tree-root "> "
4639 "With %B spec, used for the root of a thread.
4640 If nil, use subject instead."
4641 :version "21.4"
4642 :type '(radio (const :format "%v " nil) (string :size 0))
4643 :group 'gnus-thread)
4644 (defcustom gnus-sum-thread-tree-false-root "> "
4645 "With %B spec, used for a false root of a thread.
4646 If nil, use subject instead."
4647 :version "21.4"
4648 :type '(radio (const :format "%v " nil) (string :size 0))
4649 :group 'gnus-thread)
4650 (defcustom gnus-sum-thread-tree-single-indent ""
4651 "With %B spec, used for a thread with just one message.
4652 If nil, use subject instead."
4653 :version "21.4"
4654 :type '(radio (const :format "%v " nil) (string :size 0))
4655 :group 'gnus-thread)
4656 (defcustom gnus-sum-thread-tree-vertical "| "
4657 "With %B spec, used for drawing a vertical line."
4658 :version "21.4"
4659 :type 'string
4660 :group 'gnus-thread)
4661 (defcustom gnus-sum-thread-tree-indent " "
4662 "With %B spec, used for indenting."
4663 :version "21.4"
4664 :type 'string
4665 :group 'gnus-thread)
4666 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4667 "With %B spec, used for a leaf with brothers."
4668 :version "21.4"
4669 :type 'string
4670 :group 'gnus-thread)
4671 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4672 "With %B spec, used for a leaf without brothers."
4673 :version "21.4"
4674 :type 'string
4675 :group 'gnus-thread)
4677 (defun gnus-summary-prepare-threads (threads)
4678 "Prepare summary buffer from THREADS and indentation LEVEL.
4679 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4680 or a straight list of headers."
4681 (gnus-message 7 "Generating summary...")
4683 (setq gnus-newsgroup-threads threads)
4684 (beginning-of-line)
4686 (let ((gnus-tmp-level 0)
4687 (default-score (or gnus-summary-default-score 0))
4688 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4689 (building-line-count gnus-summary-display-while-building)
4690 (building-count (integerp gnus-summary-display-while-building))
4691 thread number subject stack state gnus-tmp-gathered beg-match
4692 new-roots gnus-tmp-new-adopts thread-end simp-subject
4693 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4694 gnus-tmp-replied gnus-tmp-subject-or-nil
4695 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4696 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4697 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4698 tree-stack)
4700 (setq gnus-tmp-prev-subject nil
4701 gnus-tmp-thread-tree-header-string "")
4703 (if (vectorp (car threads))
4704 ;; If this is a straight (sic) list of headers, then a
4705 ;; threaded summary display isn't required, so we just create
4706 ;; an unthreaded one.
4707 (gnus-summary-prepare-unthreaded threads)
4709 ;; Do the threaded display.
4711 (if gnus-summary-display-while-building
4712 (switch-to-buffer (buffer-name)))
4713 (while (or threads stack gnus-tmp-new-adopts new-roots)
4715 (if (and (= gnus-tmp-level 0)
4716 (or (not stack)
4717 (= (caar stack) 0))
4718 (not gnus-tmp-false-parent)
4719 (or gnus-tmp-new-adopts new-roots))
4720 (if gnus-tmp-new-adopts
4721 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4722 thread (list (car gnus-tmp-new-adopts))
4723 gnus-tmp-header (caar thread)
4724 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4725 (when new-roots
4726 (setq thread (list (car new-roots))
4727 gnus-tmp-header (caar thread)
4728 new-roots (cdr new-roots))))
4730 (if threads
4731 ;; If there are some threads, we do them before the
4732 ;; threads on the stack.
4733 (setq thread threads
4734 gnus-tmp-header (caar thread))
4735 ;; There were no current threads, so we pop something off
4736 ;; the stack.
4737 (setq state (car stack)
4738 gnus-tmp-level (car state)
4739 tree-stack (cadr state)
4740 thread (caddr state)
4741 stack (cdr stack)
4742 gnus-tmp-header (caar thread))))
4744 (setq gnus-tmp-false-parent nil)
4745 (setq gnus-tmp-root-expunged nil)
4746 (setq thread-end nil)
4748 (if (stringp gnus-tmp-header)
4749 ;; The header is a dummy root.
4750 (cond
4751 ((eq gnus-summary-make-false-root 'adopt)
4752 ;; We let the first article adopt the rest.
4753 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4754 (cddar thread)))
4755 (setq gnus-tmp-gathered
4756 (nconc (mapcar
4757 (lambda (h) (mail-header-number (car h)))
4758 (cddar thread))
4759 gnus-tmp-gathered))
4760 (setq thread (cons (list (caar thread)
4761 (cadar thread))
4762 (cdr thread)))
4763 (setq gnus-tmp-level -1
4764 gnus-tmp-false-parent t))
4765 ((eq gnus-summary-make-false-root 'empty)
4766 ;; We print adopted articles with empty subject fields.
4767 (setq gnus-tmp-gathered
4768 (nconc (mapcar
4769 (lambda (h) (mail-header-number (car h)))
4770 (cddar thread))
4771 gnus-tmp-gathered))
4772 (setq gnus-tmp-level -1))
4773 ((eq gnus-summary-make-false-root 'dummy)
4774 ;; We remember that we probably want to output a dummy
4775 ;; root.
4776 (setq gnus-tmp-dummy-line gnus-tmp-header)
4777 (setq gnus-tmp-prev-subject gnus-tmp-header))
4779 ;; We do not make a root for the gathered
4780 ;; sub-threads at all.
4781 (setq gnus-tmp-level -1)))
4783 (setq number (mail-header-number gnus-tmp-header)
4784 subject (mail-header-subject gnus-tmp-header)
4785 simp-subject (gnus-simplify-subject-fully subject))
4787 (cond
4788 ;; If the thread has changed subject, we might want to make
4789 ;; this subthread into a root.
4790 ((and (null gnus-thread-ignore-subject)
4791 (not (zerop gnus-tmp-level))
4792 gnus-tmp-prev-subject
4793 (not (string= gnus-tmp-prev-subject simp-subject)))
4794 (setq new-roots (nconc new-roots (list (car thread)))
4795 thread-end t
4796 gnus-tmp-header nil))
4797 ;; If the article lies outside the current limit,
4798 ;; then we do not display it.
4799 ((not (memq number gnus-newsgroup-limit))
4800 (setq gnus-tmp-gathered
4801 (nconc (mapcar
4802 (lambda (h) (mail-header-number (car h)))
4803 (cdar thread))
4804 gnus-tmp-gathered))
4805 (setq gnus-tmp-new-adopts (if (cdar thread)
4806 (append gnus-tmp-new-adopts
4807 (cdar thread))
4808 gnus-tmp-new-adopts)
4809 thread-end t
4810 gnus-tmp-header nil)
4811 (when (zerop gnus-tmp-level)
4812 (setq gnus-tmp-root-expunged t)))
4813 ;; Perhaps this article is to be marked as read?
4814 ((and gnus-summary-mark-below
4815 (< (or (cdr (assq number gnus-newsgroup-scored))
4816 default-score)
4817 gnus-summary-mark-below)
4818 ;; Don't touch sparse articles.
4819 (not (gnus-summary-article-sparse-p number))
4820 (not (gnus-summary-article-ancient-p number)))
4821 (setq gnus-newsgroup-unreads
4822 (delq number gnus-newsgroup-unreads))
4823 (if gnus-newsgroup-auto-expire
4824 (setq gnus-newsgroup-expirable
4825 (gnus-add-to-sorted-list
4826 gnus-newsgroup-expirable number))
4827 (push (cons number gnus-low-score-mark)
4828 gnus-newsgroup-reads))))
4830 (when gnus-tmp-header
4831 ;; We may have an old dummy line to output before this
4832 ;; article.
4833 (when (and gnus-tmp-dummy-line
4834 (gnus-subject-equal
4835 gnus-tmp-dummy-line
4836 (mail-header-subject gnus-tmp-header)))
4837 (gnus-summary-insert-dummy-line
4838 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4839 (setq gnus-tmp-dummy-line nil))
4841 ;; Compute the mark.
4842 (setq gnus-tmp-unread (gnus-article-mark number))
4844 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4845 gnus-tmp-header gnus-tmp-level)
4846 gnus-newsgroup-data)
4848 ;; Actually insert the line.
4849 (setq
4850 gnus-tmp-subject-or-nil
4851 (cond
4852 ((and gnus-thread-ignore-subject
4853 gnus-tmp-prev-subject
4854 (not (string= gnus-tmp-prev-subject simp-subject)))
4855 subject)
4856 ((zerop gnus-tmp-level)
4857 (if (and (eq gnus-summary-make-false-root 'empty)
4858 (memq number gnus-tmp-gathered)
4859 gnus-tmp-prev-subject
4860 (string= gnus-tmp-prev-subject simp-subject))
4861 gnus-summary-same-subject
4862 subject))
4863 (t gnus-summary-same-subject)))
4864 (if (and (eq gnus-summary-make-false-root 'adopt)
4865 (= gnus-tmp-level 1)
4866 (memq number gnus-tmp-gathered))
4867 (setq gnus-tmp-opening-bracket ?\<
4868 gnus-tmp-closing-bracket ?\>)
4869 (setq gnus-tmp-opening-bracket ?\[
4870 gnus-tmp-closing-bracket ?\]))
4871 (setq
4872 gnus-tmp-indentation
4873 (aref gnus-thread-indent-array gnus-tmp-level)
4874 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4875 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4876 gnus-summary-default-score 0)
4877 gnus-tmp-score-char
4878 (if (or (null gnus-summary-default-score)
4879 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4880 gnus-summary-zcore-fuzz))
4881 ? ;Whitespace
4882 (if (< gnus-tmp-score gnus-summary-default-score)
4883 gnus-score-below-mark gnus-score-over-mark))
4884 gnus-tmp-replied
4885 (cond ((memq number gnus-newsgroup-processable)
4886 gnus-process-mark)
4887 ((memq number gnus-newsgroup-cached)
4888 gnus-cached-mark)
4889 ((memq number gnus-newsgroup-replied)
4890 gnus-replied-mark)
4891 ((memq number gnus-newsgroup-forwarded)
4892 gnus-forwarded-mark)
4893 ((memq number gnus-newsgroup-saved)
4894 gnus-saved-mark)
4895 ((memq number gnus-newsgroup-recent)
4896 gnus-recent-mark)
4897 ((memq number gnus-newsgroup-unseen)
4898 gnus-unseen-mark)
4899 (t gnus-no-mark))
4900 gnus-tmp-downloaded
4901 (cond ((memq number gnus-newsgroup-undownloaded)
4902 gnus-undownloaded-mark)
4903 (gnus-newsgroup-agentized
4904 gnus-downloaded-mark)
4906 gnus-no-mark))
4907 gnus-tmp-from (mail-header-from gnus-tmp-header)
4908 gnus-tmp-name
4909 (cond
4910 ((string-match "<[^>]+> *$" gnus-tmp-from)
4911 (setq beg-match (match-beginning 0))
4912 (or (and (string-match "^\".+\"" gnus-tmp-from)
4913 (substring gnus-tmp-from 1 (1- (match-end 0))))
4914 (substring gnus-tmp-from 0 beg-match)))
4915 ((string-match "(.+)" gnus-tmp-from)
4916 (substring gnus-tmp-from
4917 (1+ (match-beginning 0)) (1- (match-end 0))))
4918 (t gnus-tmp-from))
4920 ;; Do the %B string
4921 gnus-tmp-thread-tree-header-string
4922 (cond
4923 ((not gnus-show-threads) "")
4924 ((zerop gnus-tmp-level)
4925 (cond ((cdar thread)
4926 (or gnus-sum-thread-tree-root subject))
4927 (gnus-tmp-new-adopts
4928 (or gnus-sum-thread-tree-false-root subject))
4930 (or gnus-sum-thread-tree-single-indent subject))))
4932 (concat (apply 'concat
4933 (mapcar (lambda (item)
4934 (if (= item 1)
4935 gnus-sum-thread-tree-vertical
4936 gnus-sum-thread-tree-indent))
4937 (cdr (reverse tree-stack))))
4938 (if (nth 1 thread)
4939 gnus-sum-thread-tree-leaf-with-other
4940 gnus-sum-thread-tree-single-leaf)))))
4941 (when (string= gnus-tmp-name "")
4942 (setq gnus-tmp-name gnus-tmp-from))
4943 (unless (numberp gnus-tmp-lines)
4944 (setq gnus-tmp-lines -1))
4945 (if (= gnus-tmp-lines -1)
4946 (setq gnus-tmp-lines "?")
4947 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4948 (gnus-put-text-property
4949 (point)
4950 (progn (eval gnus-summary-line-format-spec) (point))
4951 'gnus-number number)
4952 (when gnus-visual-p
4953 (forward-line -1)
4954 (gnus-run-hooks 'gnus-summary-update-hook)
4955 (forward-line 1))
4957 (setq gnus-tmp-prev-subject simp-subject)))
4959 (when (nth 1 thread)
4960 (push (list (max 0 gnus-tmp-level)
4961 (copy-sequence tree-stack)
4962 (nthcdr 1 thread))
4963 stack))
4964 (push (if (nth 1 thread) 1 0) tree-stack)
4965 (incf gnus-tmp-level)
4966 (setq threads (if thread-end nil (cdar thread)))
4967 (if gnus-summary-display-while-building
4968 (if building-count
4969 (progn
4970 ;; use a set frequency
4971 (setq building-line-count (1- building-line-count))
4972 (when (= building-line-count 0)
4973 (sit-for 0)
4974 (setq building-line-count
4975 gnus-summary-display-while-building)))
4976 ;; always
4977 (sit-for 0)))
4978 (unless threads
4979 (setq gnus-tmp-level 0)))))
4980 (gnus-message 7 "Generating summary...done"))
4982 (defun gnus-summary-prepare-unthreaded (headers)
4983 "Generate an unthreaded summary buffer based on HEADERS."
4984 (let (header number mark)
4986 (beginning-of-line)
4988 (while headers
4989 ;; We may have to root out some bad articles...
4990 (when (memq (setq number (mail-header-number
4991 (setq header (pop headers))))
4992 gnus-newsgroup-limit)
4993 ;; Mark article as read when it has a low score.
4994 (when (and gnus-summary-mark-below
4995 (< (or (cdr (assq number gnus-newsgroup-scored))
4996 gnus-summary-default-score 0)
4997 gnus-summary-mark-below)
4998 (not (gnus-summary-article-ancient-p number)))
4999 (setq gnus-newsgroup-unreads
5000 (delq number gnus-newsgroup-unreads))
5001 (if gnus-newsgroup-auto-expire
5002 (push number gnus-newsgroup-expirable)
5003 (push (cons number gnus-low-score-mark)
5004 gnus-newsgroup-reads)))
5006 (setq mark (gnus-article-mark number))
5007 (push (gnus-data-make number mark (1+ (point)) header 0)
5008 gnus-newsgroup-data)
5009 (gnus-summary-insert-line
5010 header 0 number
5011 (memq number gnus-newsgroup-undownloaded)
5012 mark (memq number gnus-newsgroup-replied)
5013 (memq number gnus-newsgroup-expirable)
5014 (mail-header-subject header) nil
5015 (cdr (assq number gnus-newsgroup-scored))
5016 (memq number gnus-newsgroup-processable))))))
5018 (defun gnus-summary-remove-list-identifiers ()
5019 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
5020 (let ((regexp (if (consp gnus-list-identifiers)
5021 (mapconcat 'identity gnus-list-identifiers " *\\|")
5022 gnus-list-identifiers))
5023 changed subject)
5024 (when regexp
5025 (dolist (header gnus-newsgroup-headers)
5026 (setq subject (mail-header-subject header)
5027 changed nil)
5028 (while (string-match
5029 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
5030 subject)
5031 (setq subject
5032 (concat (substring subject 0 (match-beginning 2))
5033 (substring subject (match-end 0)))
5034 changed t))
5035 (when (and changed
5036 (string-match
5037 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
5038 (setq subject
5039 (concat (substring subject 0 (match-beginning 1))
5040 (substring subject (match-end 1)))))
5041 (when changed
5042 (mail-header-set-subject header subject))))))
5044 (defun gnus-fetch-headers (articles)
5045 "Fetch headers of ARTICLES."
5046 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
5047 (gnus-message 5 "Fetching headers for %s..." name)
5048 (prog1
5049 (if (eq 'nov
5050 (setq gnus-headers-retrieved-by
5051 (gnus-retrieve-headers
5052 articles gnus-newsgroup-name
5053 ;; We might want to fetch old headers, but
5054 ;; not if there is only 1 article.
5055 (and (or (and
5056 (not (eq gnus-fetch-old-headers 'some))
5057 (not (numberp gnus-fetch-old-headers)))
5058 (> (length articles) 1))
5059 gnus-fetch-old-headers))))
5060 (gnus-get-newsgroup-headers-xover
5061 articles nil nil gnus-newsgroup-name t)
5062 (gnus-get-newsgroup-headers))
5063 (gnus-message 5 "Fetching headers for %s...done" name))))
5065 (defun gnus-select-newsgroup (group &optional read-all select-articles)
5066 "Select newsgroup GROUP.
5067 If READ-ALL is non-nil, all articles in the group are selected.
5068 If SELECT-ARTICLES, only select those articles from GROUP."
5069 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5070 ;;!!! Dirty hack; should be removed.
5071 (gnus-summary-ignore-duplicates
5072 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
5074 gnus-summary-ignore-duplicates))
5075 (info (nth 2 entry))
5076 articles fetched-articles cached)
5078 (unless (gnus-check-server
5079 (set (make-local-variable 'gnus-current-select-method)
5080 (gnus-find-method-for-group group)))
5081 (error "Couldn't open server"))
5083 (or (and entry (not (eq (car entry) t))) ; Either it's active...
5084 (gnus-activate-group group) ; Or we can activate it...
5085 (progn ; Or we bug out.
5086 (when (equal major-mode 'gnus-summary-mode)
5087 (gnus-kill-buffer (current-buffer)))
5088 (error "Couldn't activate group %s: %s"
5089 group (gnus-status-message group))))
5091 (unless (gnus-request-group group t)
5092 (when (equal major-mode 'gnus-summary-mode)
5093 (gnus-kill-buffer (current-buffer)))
5094 (error "Couldn't request group %s: %s"
5095 group (gnus-status-message group)))
5097 (when gnus-agent
5098 (gnus-agent-possibly-alter-active group (gnus-active group) info)
5100 (setq gnus-summary-use-undownloaded-faces
5101 (gnus-agent-find-parameter
5102 group
5103 'agent-enable-undownloaded-faces)))
5105 (setq gnus-newsgroup-name group
5106 gnus-newsgroup-unselected nil
5107 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
5109 (let ((display (gnus-group-find-parameter group 'display)))
5110 (setq gnus-newsgroup-display
5111 (cond
5112 ((not (zerop (or (car-safe read-all) 0)))
5113 ;; The user entered the group with C-u SPC/RET, let's show
5114 ;; all articles.
5115 'gnus-not-ignore)
5116 ((eq display 'all)
5117 'gnus-not-ignore)
5118 ((arrayp display)
5119 (gnus-summary-display-make-predicate (mapcar 'identity display)))
5120 ((numberp display)
5121 ;; The following is probably the "correct" solution, but
5122 ;; it makes Gnus fetch all headers and then limit the
5123 ;; articles (which is slow), so instead we hack the
5124 ;; select-articles parameter instead. -- Simon Josefsson
5125 ;; <jas@kth.se>
5127 ;; (gnus-byte-compile
5128 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
5129 ;; display)))))
5130 (setq select-articles
5131 (gnus-uncompress-range
5132 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
5133 (if (> tmp 0)
5136 (cdr (gnus-active group)))))
5137 nil)
5139 nil))))
5141 (gnus-summary-setup-default-charset)
5143 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5144 (when (gnus-virtual-group-p group)
5145 (setq cached gnus-newsgroup-cached))
5147 (setq gnus-newsgroup-unreads
5148 (gnus-sorted-ndifference
5149 (gnus-sorted-ndifference gnus-newsgroup-unreads
5150 gnus-newsgroup-marked)
5151 gnus-newsgroup-dormant))
5153 (setq gnus-newsgroup-processable nil)
5155 (gnus-update-read-articles group gnus-newsgroup-unreads)
5157 ;; Adjust and set lists of article marks.
5158 (when info
5159 (gnus-adjust-marked-articles info))
5160 (if (setq articles select-articles)
5161 (setq gnus-newsgroup-unselected
5162 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5163 (setq articles (gnus-articles-to-read group read-all)))
5165 (cond
5166 ((null articles)
5167 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
5168 'quit)
5169 ((eq articles 0) nil)
5171 ;; Init the dependencies hash table.
5172 (setq gnus-newsgroup-dependencies
5173 (gnus-make-hashtable (length articles)))
5174 (gnus-set-global-variables)
5175 ;; Retrieve the headers and read them in.
5177 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
5179 ;; Kludge to avoid having cached articles nixed out in virtual groups.
5180 (when cached
5181 (setq gnus-newsgroup-cached cached))
5183 ;; Suppress duplicates?
5184 (when gnus-suppress-duplicates
5185 (gnus-dup-suppress-articles))
5187 ;; Set the initial limit.
5188 (setq gnus-newsgroup-limit (copy-sequence articles))
5189 ;; Remove canceled articles from the list of unread articles.
5190 (setq fetched-articles
5191 (mapcar (lambda (headers) (mail-header-number headers))
5192 gnus-newsgroup-headers))
5193 (setq gnus-newsgroup-articles fetched-articles)
5194 (setq gnus-newsgroup-unreads
5195 (gnus-sorted-nintersection
5196 gnus-newsgroup-unreads fetched-articles))
5197 (gnus-compute-unseen-list)
5199 ;; Removed marked articles that do not exist.
5200 (gnus-update-missing-marks
5201 (gnus-sorted-difference articles fetched-articles))
5202 ;; We might want to build some more threads first.
5203 (when (and gnus-fetch-old-headers
5204 (eq gnus-headers-retrieved-by 'nov))
5205 (if (eq gnus-fetch-old-headers 'invisible)
5206 (gnus-build-all-threads)
5207 (gnus-build-old-threads)))
5208 ;; Let the Gnus agent mark articles as read.
5209 (when gnus-agent
5210 (gnus-agent-get-undownloaded-list))
5211 ;; Remove list identifiers from subject
5212 (when gnus-list-identifiers
5213 (gnus-summary-remove-list-identifiers))
5214 ;; Check whether auto-expire is to be done in this group.
5215 (setq gnus-newsgroup-auto-expire
5216 (gnus-group-auto-expirable-p group))
5217 ;; Set up the article buffer now, if necessary.
5218 (unless gnus-single-article-buffer
5219 (gnus-article-setup-buffer))
5220 ;; First and last article in this newsgroup.
5221 (when gnus-newsgroup-headers
5222 (setq gnus-newsgroup-begin
5223 (mail-header-number (car gnus-newsgroup-headers))
5224 gnus-newsgroup-end
5225 (mail-header-number
5226 (gnus-last-element gnus-newsgroup-headers))))
5227 ;; GROUP is successfully selected.
5228 (or gnus-newsgroup-headers t)))))
5230 (defun gnus-compute-unseen-list ()
5231 ;; The `seen' marks are treated specially.
5232 (if (not gnus-newsgroup-seen)
5233 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5234 (setq gnus-newsgroup-unseen
5235 (gnus-inverse-list-range-intersection
5236 gnus-newsgroup-articles gnus-newsgroup-seen))))
5238 (defun gnus-summary-display-make-predicate (display)
5239 (require 'gnus-agent)
5240 (when (= (length display) 1)
5241 (setq display (car display)))
5242 (unless gnus-summary-display-cache
5243 (dolist (elem (append '((unread . unread)
5244 (read . read)
5245 (unseen . unseen))
5246 gnus-article-mark-lists))
5247 (push (cons (cdr elem)
5248 (gnus-byte-compile
5249 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5250 gnus-summary-display-cache)))
5251 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5252 (gnus-category-predicate-cache gnus-summary-display-cache))
5253 (gnus-get-predicate display)))
5255 ;; Uses the dynamically bound `number' variable.
5256 (eval-when-compile
5257 (defvar number))
5258 (defun gnus-article-marked-p (type &optional article)
5259 (let ((article (or article number)))
5260 (cond
5261 ((eq type 'tick)
5262 (memq article gnus-newsgroup-marked))
5263 ((eq type 'spam)
5264 (memq article gnus-newsgroup-spam-marked))
5265 ((eq type 'unsend)
5266 (memq article gnus-newsgroup-unsendable))
5267 ((eq type 'undownload)
5268 (memq article gnus-newsgroup-undownloaded))
5269 ((eq type 'download)
5270 (memq article gnus-newsgroup-downloadable))
5271 ((eq type 'unread)
5272 (memq article gnus-newsgroup-unreads))
5273 ((eq type 'read)
5274 (memq article gnus-newsgroup-reads))
5275 ((eq type 'dormant)
5276 (memq article gnus-newsgroup-dormant) )
5277 ((eq type 'expire)
5278 (memq article gnus-newsgroup-expirable))
5279 ((eq type 'reply)
5280 (memq article gnus-newsgroup-replied))
5281 ((eq type 'killed)
5282 (memq article gnus-newsgroup-killed))
5283 ((eq type 'bookmark)
5284 (assq article gnus-newsgroup-bookmarks))
5285 ((eq type 'score)
5286 (assq article gnus-newsgroup-scored))
5287 ((eq type 'save)
5288 (memq article gnus-newsgroup-saved))
5289 ((eq type 'cache)
5290 (memq article gnus-newsgroup-cached))
5291 ((eq type 'forward)
5292 (memq article gnus-newsgroup-forwarded))
5293 ((eq type 'seen)
5294 (not (memq article gnus-newsgroup-unseen)))
5295 ((eq type 'recent)
5296 (memq article gnus-newsgroup-recent))
5297 (t t))))
5299 (defun gnus-articles-to-read (group &optional read-all)
5300 "Find out what articles the user wants to read."
5301 (let* ((display (gnus-group-find-parameter group 'display))
5302 (articles
5303 ;; Select all articles if `read-all' is non-nil, or if there
5304 ;; are no unread articles.
5305 (if (or read-all
5306 (and (zerop (length gnus-newsgroup-marked))
5307 (zerop (length gnus-newsgroup-unreads)))
5308 ;; Fetch all if the predicate is non-nil.
5309 gnus-newsgroup-display)
5310 ;; We want to select the headers for all the articles in
5311 ;; the group, so we select either all the active
5312 ;; articles in the group, or (if that's nil), the
5313 ;; articles in the cache.
5315 (gnus-uncompress-range (gnus-active group))
5316 (gnus-cache-articles-in-group group))
5317 ;; Select only the "normal" subset of articles.
5318 (gnus-sorted-nunion
5319 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5320 gnus-newsgroup-unreads)))
5321 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5322 (scored (length scored-list))
5323 (number (length articles))
5324 (marked (+ (length gnus-newsgroup-marked)
5325 (length gnus-newsgroup-dormant)))
5326 (select
5327 (cond
5328 ((numberp read-all)
5329 read-all)
5330 ((numberp gnus-newsgroup-display)
5331 gnus-newsgroup-display)
5333 (condition-case ()
5334 (cond
5335 ((and (or (<= scored marked) (= scored number))
5336 (numberp gnus-large-newsgroup)
5337 (> number gnus-large-newsgroup))
5338 (let* ((cursor-in-echo-area nil)
5339 (initial (gnus-parameter-large-newsgroup-initial
5340 gnus-newsgroup-name))
5341 (input
5342 (read-string
5343 (format
5344 "How many articles from %s (%s %d): "
5345 (gnus-limit-string
5346 (gnus-group-decoded-name gnus-newsgroup-name)
5348 (if initial "max" "default")
5349 number)
5350 (if initial
5351 (cons (number-to-string initial)
5352 0)))))
5353 (if (string-match "^[ \t]*$" input) number input)))
5354 ((and (> scored marked) (< scored number)
5355 (> (- scored number) 20))
5356 (let ((input
5357 (read-string
5358 (format "%s %s (%d scored, %d total): "
5359 "How many articles from"
5360 (gnus-group-decoded-name group)
5361 scored number))))
5362 (if (string-match "^[ \t]*$" input)
5363 number input)))
5364 (t number))
5365 (quit
5366 (message "Quit getting the articles to read")
5367 nil))))))
5368 (setq select (if (stringp select) (string-to-number select) select))
5369 (if (or (null select) (zerop select))
5370 select
5371 (if (and (not (zerop scored)) (<= (abs select) scored))
5372 (progn
5373 (setq articles (sort scored-list '<))
5374 (setq number (length articles)))
5375 (setq articles (copy-sequence articles)))
5377 (when (< (abs select) number)
5378 (if (< select 0)
5379 ;; Select the N oldest articles.
5380 (setcdr (nthcdr (1- (abs select)) articles) nil)
5381 ;; Select the N most recent articles.
5382 (setq articles (nthcdr (- number select) articles))))
5383 (setq gnus-newsgroup-unselected
5384 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5385 (when gnus-alter-articles-to-read-function
5386 (setq articles
5387 (sort
5388 (funcall gnus-alter-articles-to-read-function
5389 gnus-newsgroup-name articles)
5390 '<)))
5391 articles)))
5393 (defun gnus-killed-articles (killed articles)
5394 (let (out)
5395 (while articles
5396 (when (inline (gnus-member-of-range (car articles) killed))
5397 (push (car articles) out))
5398 (setq articles (cdr articles)))
5399 out))
5401 (defun gnus-uncompress-marks (marks)
5402 "Uncompress the mark ranges in MARKS."
5403 (let ((uncompressed '(score bookmark))
5404 out)
5405 (while marks
5406 (if (memq (caar marks) uncompressed)
5407 (push (car marks) out)
5408 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5409 (setq marks (cdr marks)))
5410 out))
5412 (defun gnus-article-mark-to-type (mark)
5413 "Return the type of MARK."
5414 (or (cadr (assq mark gnus-article-special-mark-lists))
5415 'list))
5417 (defun gnus-article-unpropagatable-p (mark)
5418 "Return whether MARK should be propagated to back end."
5419 (memq mark gnus-article-unpropagated-mark-lists))
5421 (defun gnus-adjust-marked-articles (info)
5422 "Set all article lists and remove all marks that are no longer valid."
5423 (let* ((marked-lists (gnus-info-marks info))
5424 (active (gnus-active (gnus-info-group info)))
5425 (min (car active))
5426 (max (cdr active))
5427 (types gnus-article-mark-lists)
5428 marks var articles article mark mark-type
5429 bgn end)
5431 (dolist (marks marked-lists)
5432 (setq mark (car marks)
5433 mark-type (gnus-article-mark-to-type mark)
5434 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5436 ;; We set the variable according to the type of the marks list,
5437 ;; and then adjust the marks to a subset of the active articles.
5438 (cond
5439 ;; Adjust "simple" lists - compressed yet unsorted
5440 ((eq mark-type 'list)
5441 ;; Simultaneously uncompress and clip to active range
5442 ;; See gnus-uncompress-range for a description of possible marks
5443 (let (l lh)
5444 (if (not (cadr marks))
5445 (set var nil)
5446 (setq articles (if (numberp (cddr marks))
5447 (list (cdr marks))
5448 (cdr marks))
5449 lh (cons nil nil)
5450 l lh)
5452 (while (setq article (pop articles))
5453 (cond ((consp article)
5454 (setq bgn (max (car article) min)
5455 end (min (cdr article) max))
5456 (while (<= bgn end)
5457 (setq l (setcdr l (cons bgn nil))
5458 bgn (1+ bgn))))
5459 ((and (<= min article)
5460 (>= max article))
5461 (setq l (setcdr l (cons article nil))))))
5462 (set var (cdr lh)))))
5463 ;; Adjust assocs.
5464 ((eq mark-type 'tuple)
5465 (set var (setq articles (cdr marks)))
5466 (when (not (listp (cdr (symbol-value var))))
5467 (set var (list (symbol-value var))))
5468 (when (not (listp (cdr articles)))
5469 (setq articles (list articles)))
5470 (while articles
5471 (when (or (not (consp (setq article (pop articles))))
5472 (< (car article) min)
5473 (> (car article) max))
5474 (set var (delq article (symbol-value var))))))
5475 ;; Adjust ranges (sloppily).
5476 ((eq mark-type 'range)
5477 (cond
5478 ((eq mark 'seen)
5479 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5480 ;; It should be (seen (NUM1 . NUM2)).
5481 (when (numberp (cddr marks))
5482 (setcdr marks (list (cdr marks))))
5483 (setq articles (cdr marks))
5484 (while (and articles
5485 (or (and (consp (car articles))
5486 (> min (cdar articles)))
5487 (and (numberp (car articles))
5488 (> min (car articles)))))
5489 (pop articles))
5490 (set var articles))))))))
5492 (defun gnus-update-missing-marks (missing)
5493 "Go through the list of MISSING articles and remove them from the mark lists."
5494 (when missing
5495 (let (var m)
5496 ;; Go through all types.
5497 (dolist (elem gnus-article-mark-lists)
5498 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5499 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5500 (when (symbol-value var)
5501 ;; This list has articles. So we delete all missing
5502 ;; articles from it.
5503 (setq m missing)
5504 (while m
5505 (set var (delq (pop m) (symbol-value var))))))))))
5507 (defun gnus-update-marks ()
5508 "Enter the various lists of marked articles into the newsgroup info list."
5509 (let ((types gnus-article-mark-lists)
5510 (info (gnus-get-info gnus-newsgroup-name))
5511 type list newmarked symbol delta-marks)
5512 (when info
5513 ;; Add all marks lists to the list of marks lists.
5514 (while (setq type (pop types))
5515 (setq list (symbol-value
5516 (setq symbol
5517 (intern (format "gnus-newsgroup-%s" (car type))))))
5519 (when list
5520 ;; Get rid of the entries of the articles that have the
5521 ;; default score.
5522 (when (and (eq (cdr type) 'score)
5523 gnus-save-score
5524 list)
5525 (let* ((arts list)
5526 (prev (cons nil list))
5527 (all prev))
5528 (while arts
5529 (if (or (not (consp (car arts)))
5530 (= (cdar arts) gnus-summary-default-score))
5531 (setcdr prev (cdr arts))
5532 (setq prev arts))
5533 (setq arts (cdr arts)))
5534 (setq list (cdr all)))))
5536 (when (eq (cdr type) 'seen)
5537 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5539 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5540 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5542 (when (and (gnus-check-backend-function
5543 'request-set-mark gnus-newsgroup-name)
5544 (not (gnus-article-unpropagatable-p (cdr type))))
5545 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5546 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5547 (add (gnus-remove-from-range
5548 (gnus-copy-sequence list) old)))
5549 (when add
5550 (push (list add 'add (list (cdr type))) delta-marks))
5551 (when del
5552 (push (list del 'del (list (cdr type))) delta-marks))))
5554 (when list
5555 (push (cons (cdr type) list) newmarked)))
5557 (when delta-marks
5558 (unless (gnus-check-group gnus-newsgroup-name)
5559 (error "Can't open server for %s" gnus-newsgroup-name))
5560 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5562 ;; Enter these new marks into the info of the group.
5563 (if (nthcdr 3 info)
5564 (setcar (nthcdr 3 info) newmarked)
5565 ;; Add the marks lists to the end of the info.
5566 (when newmarked
5567 (setcdr (nthcdr 2 info) (list newmarked))))
5569 ;; Cut off the end of the info if there's nothing else there.
5570 (let ((i 5))
5571 (while (and (> i 2)
5572 (not (nth i info)))
5573 (when (nthcdr (decf i) info)
5574 (setcdr (nthcdr i info) nil)))))))
5576 (defun gnus-set-mode-line (where)
5577 "Set the mode line of the article or summary buffers.
5578 If WHERE is `summary', the summary mode line format will be used."
5579 ;; Is this mode line one we keep updated?
5580 (when (and (memq where gnus-updated-mode-lines)
5581 (symbol-value
5582 (intern (format "gnus-%s-mode-line-format-spec" where))))
5583 (let (mode-string)
5584 (save-excursion
5585 ;; We evaluate this in the summary buffer since these
5586 ;; variables are buffer-local to that buffer.
5587 (set-buffer gnus-summary-buffer)
5588 ;; We bind all these variables that are used in the `eval' form
5589 ;; below.
5590 (let* ((mformat (symbol-value
5591 (intern
5592 (format "gnus-%s-mode-line-format-spec" where))))
5593 (gnus-tmp-group-name (gnus-group-decoded-name
5594 gnus-newsgroup-name))
5595 (gnus-tmp-article-number (or gnus-current-article 0))
5596 (gnus-tmp-unread gnus-newsgroup-unreads)
5597 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5598 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5599 (gnus-tmp-unread-and-unselected
5600 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5601 (zerop gnus-tmp-unselected))
5603 ((zerop gnus-tmp-unselected)
5604 (format "{%d more}" gnus-tmp-unread-and-unticked))
5605 (t (format "{%d(+%d) more}"
5606 gnus-tmp-unread-and-unticked
5607 gnus-tmp-unselected))))
5608 (gnus-tmp-subject
5609 (if (and gnus-current-headers
5610 (vectorp gnus-current-headers))
5611 (gnus-mode-string-quote
5612 (mail-header-subject gnus-current-headers))
5613 ""))
5614 bufname-length max-len
5615 gnus-tmp-header) ;; passed as argument to any user-format-funcs
5616 (setq mode-string (eval mformat))
5617 (setq bufname-length (if (string-match "%b" mode-string)
5618 (- (length
5619 (buffer-name
5620 (if (eq where 'summary)
5622 (get-buffer gnus-article-buffer))))
5625 (setq max-len (max 4 (if gnus-mode-non-string-length
5626 (- (window-width)
5627 gnus-mode-non-string-length
5628 bufname-length)
5629 (length mode-string))))
5630 ;; We might have to chop a bit of the string off...
5631 (when (> (length mode-string) max-len)
5632 (setq mode-string
5633 (concat (truncate-string-to-width mode-string (- max-len 3))
5634 "...")))
5635 ;; Pad the mode string a bit.
5636 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5637 ;; Update the mode line.
5638 (setq mode-line-buffer-identification
5639 (gnus-mode-line-buffer-identification (list mode-string)))
5640 (set-buffer-modified-p t))))
5642 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5643 "Go through the HEADERS list and add all Xrefs to a hash table.
5644 The resulting hash table is returned, or nil if no Xrefs were found."
5645 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5646 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5647 (xref-hashtb (gnus-make-hashtable))
5648 start group entry number xrefs header)
5649 (while headers
5650 (setq header (pop headers))
5651 (when (and (setq xrefs (mail-header-xref header))
5652 (not (memq (setq number (mail-header-number header))
5653 unreads)))
5654 (setq start 0)
5655 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5656 (setq start (match-end 0))
5657 (setq group (if prefix
5658 (concat prefix (substring xrefs (match-beginning 1)
5659 (match-end 1)))
5660 (substring xrefs (match-beginning 1) (match-end 1))))
5661 (setq number
5662 (string-to-int (substring xrefs (match-beginning 2)
5663 (match-end 2))))
5664 (if (setq entry (gnus-gethash group xref-hashtb))
5665 (setcdr entry (cons number (cdr entry)))
5666 (gnus-sethash group (cons number nil) xref-hashtb)))))
5667 (and start xref-hashtb)))
5669 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5670 "Look through all the headers and mark the Xrefs as read."
5671 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5672 name entry info xref-hashtb idlist method nth4)
5673 (save-excursion
5674 (set-buffer gnus-group-buffer)
5675 (when (setq xref-hashtb
5676 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5677 (mapatoms
5678 (lambda (group)
5679 (unless (string= from-newsgroup (setq name (symbol-name group)))
5680 (setq idlist (symbol-value group))
5681 ;; Dead groups are not updated.
5682 (and (prog1
5683 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5684 info (nth 2 entry))
5685 (when (stringp (setq nth4 (gnus-info-method info)))
5686 (setq nth4 (gnus-server-to-method nth4))))
5687 ;; Only do the xrefs if the group has the same
5688 ;; select method as the group we have just read.
5689 (or (gnus-methods-equal-p
5690 nth4 (gnus-find-method-for-group from-newsgroup))
5691 virtual
5692 (equal nth4 (setq method (gnus-find-method-for-group
5693 from-newsgroup)))
5694 (and (equal (car nth4) (car method))
5695 (equal (nth 1 nth4) (nth 1 method))))
5696 gnus-use-cross-reference
5697 (or (not (eq gnus-use-cross-reference t))
5698 virtual
5699 ;; Only do cross-references on subscribed
5700 ;; groups, if that is what is wanted.
5701 (<= (gnus-info-level info) gnus-level-subscribed))
5702 (gnus-group-make-articles-read name idlist))))
5703 xref-hashtb)))))
5705 (defun gnus-compute-read-articles (group articles)
5706 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5707 (info (nth 2 entry))
5708 (active (gnus-active group))
5709 ninfo)
5710 (when entry
5711 ;; First peel off all invalid article numbers.
5712 (when active
5713 (let ((ids articles)
5714 id first)
5715 (while (setq id (pop ids))
5716 (when (and first (> id (cdr active)))
5717 ;; We'll end up in this situation in one particular
5718 ;; obscure situation. If you re-scan a group and get
5719 ;; a new article that is cross-posted to a different
5720 ;; group that has not been re-scanned, you might get
5721 ;; crossposted article that has a higher number than
5722 ;; Gnus believes possible. So we re-activate this
5723 ;; group as well. This might mean doing the
5724 ;; crossposting thingy will *increase* the number
5725 ;; of articles in some groups. Tsk, tsk.
5726 (setq active (or (gnus-activate-group group) active)))
5727 (when (or (> id (cdr active))
5728 (< id (car active)))
5729 (setq articles (delq id articles))))))
5730 ;; If the read list is nil, we init it.
5731 (if (and active
5732 (null (gnus-info-read info))
5733 (> (car active) 1))
5734 (setq ninfo (cons 1 (1- (car active))))
5735 (setq ninfo (gnus-info-read info)))
5736 ;; Then we add the read articles to the range.
5737 (gnus-add-to-range
5738 ninfo (setq articles (sort articles '<))))))
5740 (defun gnus-group-make-articles-read (group articles)
5741 "Update the info of GROUP to say that ARTICLES are read."
5742 (let* ((num 0)
5743 (entry (gnus-gethash group gnus-newsrc-hashtb))
5744 (info (nth 2 entry))
5745 (active (gnus-active group))
5746 range)
5747 (when entry
5748 (setq range (gnus-compute-read-articles group articles))
5749 (save-excursion
5750 (set-buffer gnus-group-buffer)
5751 (gnus-undo-register
5752 `(progn
5753 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5754 (gnus-info-set-read ',info ',(gnus-info-read info))
5755 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5756 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5757 (gnus-group-update-group ,group t))))
5758 ;; Add the read articles to the range.
5759 (gnus-info-set-read info range)
5760 (gnus-request-set-mark group (list (list range 'add '(read))))
5761 ;; Then we have to re-compute how many unread
5762 ;; articles there are in this group.
5763 (when active
5764 (cond
5765 ((not range)
5766 (setq num (- (1+ (cdr active)) (car active))))
5767 ((not (listp (cdr range)))
5768 (setq num (- (cdr active) (- (1+ (cdr range))
5769 (car range)))))
5771 (while range
5772 (if (numberp (car range))
5773 (setq num (1+ num))
5774 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5775 (setq range (cdr range)))
5776 (setq num (- (cdr active) num))))
5777 ;; Update the number of unread articles.
5778 (setcar entry num)
5779 ;; Update the group buffer.
5780 (unless (gnus-ephemeral-group-p group)
5781 (gnus-group-update-group group t))))))
5783 (defvar gnus-newsgroup-none-id 0)
5785 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5786 (let ((cur nntp-server-buffer)
5787 (dependencies
5788 (or dependencies
5789 (save-excursion (set-buffer gnus-summary-buffer)
5790 gnus-newsgroup-dependencies)))
5791 headers id end ref
5792 (mail-parse-charset gnus-newsgroup-charset)
5793 (mail-parse-ignored-charsets
5794 (save-excursion (condition-case nil
5795 (set-buffer gnus-summary-buffer)
5796 (error))
5797 gnus-newsgroup-ignored-charsets)))
5798 (save-excursion
5799 (set-buffer nntp-server-buffer)
5800 ;; Translate all TAB characters into SPACE characters.
5801 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5802 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5803 (ietf-drums-unfold-fws)
5804 (gnus-run-hooks 'gnus-parse-headers-hook)
5805 (let ((case-fold-search t)
5806 in-reply-to header p lines chars)
5807 (goto-char (point-min))
5808 ;; Search to the beginning of the next header. Error messages
5809 ;; do not begin with 2 or 3.
5810 (while (re-search-forward "^[23][0-9]+ " nil t)
5811 (setq id nil
5812 ref nil)
5813 ;; This implementation of this function, with nine
5814 ;; search-forwards instead of the one re-search-forward and
5815 ;; a case (which basically was the old function) is actually
5816 ;; about twice as fast, even though it looks messier. You
5817 ;; can't have everything, I guess. Speed and elegance
5818 ;; doesn't always go hand in hand.
5819 (setq
5820 header
5821 (vector
5822 ;; Number.
5823 (prog1
5824 (read cur)
5825 (end-of-line)
5826 (setq p (point))
5827 (narrow-to-region (point)
5828 (or (and (search-forward "\n.\n" nil t)
5829 (- (point) 2))
5830 (point))))
5831 ;; Subject.
5832 (progn
5833 (goto-char p)
5834 (if (search-forward "\nsubject:" nil t)
5835 (funcall gnus-decode-encoded-word-function
5836 (nnheader-header-value))
5837 "(none)"))
5838 ;; From.
5839 (progn
5840 (goto-char p)
5841 (if (search-forward "\nfrom:" nil t)
5842 (funcall gnus-decode-encoded-word-function
5843 (nnheader-header-value))
5844 "(nobody)"))
5845 ;; Date.
5846 (progn
5847 (goto-char p)
5848 (if (search-forward "\ndate:" nil t)
5849 (nnheader-header-value) ""))
5850 ;; Message-ID.
5851 (progn
5852 (goto-char p)
5853 (setq id (if (re-search-forward
5854 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5855 ;; We do it this way to make sure the Message-ID
5856 ;; is (somewhat) syntactically valid.
5857 (buffer-substring (match-beginning 1)
5858 (match-end 1))
5859 ;; If there was no message-id, we just fake one
5860 ;; to make subsequent routines simpler.
5861 (nnheader-generate-fake-message-id))))
5862 ;; References.
5863 (progn
5864 (goto-char p)
5865 (if (search-forward "\nreferences:" nil t)
5866 (progn
5867 (setq end (point))
5868 (prog1
5869 (nnheader-header-value)
5870 (setq ref
5871 (buffer-substring
5872 (progn
5873 (end-of-line)
5874 (search-backward ">" end t)
5875 (1+ (point)))
5876 (progn
5877 (search-backward "<" end t)
5878 (point))))))
5879 ;; Get the references from the in-reply-to header if there
5880 ;; were no references and the in-reply-to header looks
5881 ;; promising.
5882 (if (and (search-forward "\nin-reply-to:" nil t)
5883 (setq in-reply-to (nnheader-header-value))
5884 (string-match "<[^>]+>" in-reply-to))
5885 (let (ref2)
5886 (setq ref (substring in-reply-to (match-beginning 0)
5887 (match-end 0)))
5888 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5889 (setq ref2 (substring in-reply-to (match-beginning 0)
5890 (match-end 0)))
5891 (when (> (length ref2) (length ref))
5892 (setq ref ref2)))
5893 ref)
5894 (setq ref nil))))
5895 ;; Chars.
5896 (progn
5897 (goto-char p)
5898 (if (search-forward "\nchars: " nil t)
5899 (if (numberp (setq chars (ignore-errors (read cur))))
5900 chars -1)
5901 -1))
5902 ;; Lines.
5903 (progn
5904 (goto-char p)
5905 (if (search-forward "\nlines: " nil t)
5906 (if (numberp (setq lines (ignore-errors (read cur))))
5907 lines -1)
5908 -1))
5909 ;; Xref.
5910 (progn
5911 (goto-char p)
5912 (and (search-forward "\nxref:" nil t)
5913 (nnheader-header-value)))
5914 ;; Extra.
5915 (when gnus-extra-headers
5916 (let ((extra gnus-extra-headers)
5917 out)
5918 (while extra
5919 (goto-char p)
5920 (when (search-forward
5921 (concat "\n" (symbol-name (car extra)) ":") nil t)
5922 (push (cons (car extra) (nnheader-header-value))
5923 out))
5924 (pop extra))
5925 out))))
5926 (when (equal id ref)
5927 (setq ref nil))
5929 (when gnus-alter-header-function
5930 (funcall gnus-alter-header-function header)
5931 (setq id (mail-header-id header)
5932 ref (gnus-parent-id (mail-header-references header))))
5934 (when (setq header
5935 (gnus-dependencies-add-header
5936 header dependencies force-new))
5937 (push header headers))
5938 (goto-char (point-max))
5939 (widen))
5940 (nreverse headers)))))
5942 ;; Goes through the xover lines and returns a list of vectors
5943 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5944 force-new dependencies
5945 group also-fetch-heads)
5946 "Parse the news overview data in the server buffer.
5947 Return a list of headers that match SEQUENCE (see
5948 `nntp-retrieve-headers')."
5949 ;; Get the Xref when the users reads the articles since most/some
5950 ;; NNTP servers do not include Xrefs when using XOVER.
5951 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5952 (let ((mail-parse-charset gnus-newsgroup-charset)
5953 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5954 (cur nntp-server-buffer)
5955 (dependencies (or dependencies gnus-newsgroup-dependencies))
5956 (allp (cond
5957 ((eq gnus-read-all-available-headers t)
5959 ((stringp gnus-read-all-available-headers)
5960 (string-match gnus-read-all-available-headers group))
5962 nil)))
5963 number headers header)
5964 (save-excursion
5965 (set-buffer nntp-server-buffer)
5966 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5967 ;; Allow the user to mangle the headers before parsing them.
5968 (gnus-run-hooks 'gnus-parse-headers-hook)
5969 (goto-char (point-min))
5970 (gnus-parse-without-error
5971 (while (and (or sequence allp)
5972 (not (eobp)))
5973 (setq number (read cur))
5974 (when (not allp)
5975 (while (and sequence
5976 (< (car sequence) number))
5977 (setq sequence (cdr sequence))))
5978 (when (and (or allp
5979 (and sequence
5980 (eq number (car sequence))))
5981 (progn
5982 (setq sequence (cdr sequence))
5983 (setq header (inline
5984 (gnus-nov-parse-line
5985 number dependencies force-new)))))
5986 (push header headers))
5987 (forward-line 1)))
5988 ;; A common bug in inn is that if you have posted an article and
5989 ;; then retrieves the active file, it will answer correctly --
5990 ;; the new article is included. However, a NOV entry for the
5991 ;; article may not have been generated yet, so this may fail.
5992 ;; We work around this problem by retrieving the last few
5993 ;; headers using HEAD.
5994 (if (or (not also-fetch-heads)
5995 (not sequence))
5996 ;; We (probably) got all the headers.
5997 (nreverse headers)
5998 (let ((gnus-nov-is-evil t))
5999 (nconc
6000 (nreverse headers)
6001 (when (eq (gnus-retrieve-headers sequence group) 'headers)
6002 (gnus-get-newsgroup-headers))))))))
6004 (defun gnus-article-get-xrefs ()
6005 "Fill in the Xref value in `gnus-current-headers', if necessary.
6006 This is meant to be called in `gnus-article-internal-prepare-hook'."
6007 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
6008 gnus-current-headers)))
6009 (or (not gnus-use-cross-reference)
6010 (not headers)
6011 (and (mail-header-xref headers)
6012 (not (string= (mail-header-xref headers) "")))
6013 (let ((case-fold-search t)
6014 xref)
6015 (save-restriction
6016 (nnheader-narrow-to-headers)
6017 (goto-char (point-min))
6018 (when (or (and (not (eobp))
6019 (eq (downcase (char-after)) ?x)
6020 (looking-at "Xref:"))
6021 (search-forward "\nXref:" nil t))
6022 (goto-char (1+ (match-end 0)))
6023 (setq xref (buffer-substring (point) (gnus-point-at-eol)))
6024 (mail-header-set-xref headers xref)))))))
6026 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
6027 "Find article ID and insert the summary line for that article.
6028 OLD-HEADER can either be a header or a line number to insert
6029 the subject line on."
6030 (let* ((line (and (numberp old-header) old-header))
6031 (old-header (and (vectorp old-header) old-header))
6032 (header (cond ((and old-header use-old-header)
6033 old-header)
6034 ((and (numberp id)
6035 (gnus-number-to-header id))
6036 (gnus-number-to-header id))
6038 (gnus-read-header id))))
6039 (number (and (numberp id) id))
6041 (when header
6042 ;; Rebuild the thread that this article is part of and go to the
6043 ;; article we have fetched.
6044 (when (and (not gnus-show-threads)
6045 old-header)
6046 (when (and number
6047 (setq d (gnus-data-find (mail-header-number old-header))))
6048 (goto-char (gnus-data-pos d))
6049 (gnus-data-remove
6050 number
6051 (- (gnus-point-at-bol)
6052 (prog1
6053 (1+ (gnus-point-at-eol))
6054 (gnus-delete-line))))))
6055 ;; Remove list identifiers from subject.
6056 (when gnus-list-identifiers
6057 (let ((gnus-newsgroup-headers (list header)))
6058 (gnus-summary-remove-list-identifiers)))
6059 (when old-header
6060 (mail-header-set-number header (mail-header-number old-header)))
6061 (setq gnus-newsgroup-sparse
6062 (delq (setq number (mail-header-number header))
6063 gnus-newsgroup-sparse))
6064 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
6065 (push number gnus-newsgroup-limit)
6066 (gnus-rebuild-thread (mail-header-id header) line)
6067 (gnus-summary-goto-subject number nil t))
6068 (when (and (numberp number)
6069 (> number 0))
6070 ;; We have to update the boundaries even if we can't fetch the
6071 ;; article if ID is a number -- so that the next `P' or `N'
6072 ;; command will fetch the previous (or next) article even
6073 ;; if the one we tried to fetch this time has been canceled.
6074 (when (> number gnus-newsgroup-end)
6075 (setq gnus-newsgroup-end number))
6076 (when (< number gnus-newsgroup-begin)
6077 (setq gnus-newsgroup-begin number))
6078 (setq gnus-newsgroup-unselected
6079 (delq number gnus-newsgroup-unselected)))
6080 ;; Report back a success?
6081 (and header (mail-header-number header))))
6083 ;;; Process/prefix in the summary buffer
6085 (defun gnus-summary-work-articles (n)
6086 "Return a list of articles to be worked upon.
6087 The prefix argument, the list of process marked articles, and the
6088 current article will be taken into consideration."
6089 (save-excursion
6090 (set-buffer gnus-summary-buffer)
6091 (cond
6093 ;; A numerical prefix has been given.
6094 (setq n (prefix-numeric-value n))
6095 (let ((backward (< n 0))
6096 (n (abs (prefix-numeric-value n)))
6097 articles article)
6098 (save-excursion
6099 (while
6100 (and (> n 0)
6101 (push (setq article (gnus-summary-article-number))
6102 articles)
6103 (if backward
6104 (gnus-summary-find-prev nil article)
6105 (gnus-summary-find-next nil article)))
6106 (decf n)))
6107 (nreverse articles)))
6108 ((and (gnus-region-active-p) (mark))
6109 (message "region active")
6110 ;; Work on the region between point and mark.
6111 (let ((max (max (point) (mark)))
6112 articles article)
6113 (save-excursion
6114 (goto-char (min (min (point) (mark))))
6115 (while
6116 (and
6117 (push (setq article (gnus-summary-article-number)) articles)
6118 (gnus-summary-find-next nil article)
6119 (< (point) max)))
6120 (nreverse articles))))
6121 (gnus-newsgroup-processable
6122 ;; There are process-marked articles present.
6123 ;; Save current state.
6124 (gnus-summary-save-process-mark)
6125 ;; Return the list.
6126 (reverse gnus-newsgroup-processable))
6128 ;; Just return the current article.
6129 (list (gnus-summary-article-number))))))
6131 (defmacro gnus-summary-iterate (arg &rest forms)
6132 "Iterate over the process/prefixed articles and do FORMS.
6133 ARG is the interactive prefix given to the command. FORMS will be
6134 executed with point over the summary line of the articles."
6135 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
6136 `(let ((,articles (gnus-summary-work-articles ,arg)))
6137 (while ,articles
6138 (gnus-summary-goto-subject (car ,articles))
6139 ,@forms
6140 (pop ,articles)))))
6142 (put 'gnus-summary-iterate 'lisp-indent-function 1)
6143 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
6145 (defun gnus-summary-save-process-mark ()
6146 "Push the current set of process marked articles on the stack."
6147 (interactive)
6148 (push (copy-sequence gnus-newsgroup-processable)
6149 gnus-newsgroup-process-stack))
6151 (defun gnus-summary-kill-process-mark ()
6152 "Push the current set of process marked articles on the stack and unmark."
6153 (interactive)
6154 (gnus-summary-save-process-mark)
6155 (gnus-summary-unmark-all-processable))
6157 (defun gnus-summary-yank-process-mark ()
6158 "Pop the last process mark state off the stack and restore it."
6159 (interactive)
6160 (unless gnus-newsgroup-process-stack
6161 (error "Empty mark stack"))
6162 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
6164 (defun gnus-summary-process-mark-set (set)
6165 "Make SET into the current process marked articles."
6166 (gnus-summary-unmark-all-processable)
6167 (while set
6168 (gnus-summary-set-process-mark (pop set))))
6170 ;;; Searching and stuff
6172 (defun gnus-summary-search-group (&optional backward use-level)
6173 "Search for next unread newsgroup.
6174 If optional argument BACKWARD is non-nil, search backward instead."
6175 (save-excursion
6176 (set-buffer gnus-group-buffer)
6177 (when (gnus-group-search-forward
6178 backward nil (if use-level (gnus-group-group-level) nil))
6179 (gnus-group-group-name))))
6181 (defun gnus-summary-best-group (&optional exclude-group)
6182 "Find the name of the best unread group.
6183 If EXCLUDE-GROUP, do not go to this group."
6184 (save-excursion
6185 (set-buffer gnus-group-buffer)
6186 (save-excursion
6187 (gnus-group-best-unread-group exclude-group))))
6189 (defun gnus-summary-find-next (&optional unread article backward)
6190 (if backward
6191 (gnus-summary-find-prev unread article)
6192 (let* ((dummy (gnus-summary-article-intangible-p))
6193 (article (or article (gnus-summary-article-number)))
6194 (data (gnus-data-find-list article))
6195 result)
6196 (when (and (not dummy)
6197 (or (not gnus-summary-check-current)
6198 (not unread)
6199 (not (gnus-data-unread-p (car data)))))
6200 (setq data (cdr data)))
6201 (when (setq result
6202 (if unread
6203 (progn
6204 (while data
6205 (unless (memq (gnus-data-number (car data))
6206 (cond
6207 ((eq gnus-auto-goto-ignores
6208 'always-undownloaded)
6209 gnus-newsgroup-undownloaded)
6210 (gnus-plugged
6211 nil)
6212 ((eq gnus-auto-goto-ignores
6213 'unfetched)
6214 gnus-newsgroup-unfetched)
6215 ((eq gnus-auto-goto-ignores
6216 'undownloaded)
6217 gnus-newsgroup-undownloaded)))
6218 (when (gnus-data-unread-p (car data))
6219 (setq result (car data)
6220 data nil)))
6221 (setq data (cdr data)))
6222 result)
6223 (car data)))
6224 (goto-char (gnus-data-pos result))
6225 (gnus-data-number result)))))
6227 (defun gnus-summary-find-prev (&optional unread article)
6228 (let* ((eobp (eobp))
6229 (article (or article (gnus-summary-article-number)))
6230 (data (gnus-data-find-list article (gnus-data-list 'rev)))
6231 result)
6232 (when (and (not eobp)
6233 (or (not gnus-summary-check-current)
6234 (not unread)
6235 (not (gnus-data-unread-p (car data)))))
6236 (setq data (cdr data)))
6237 (when (setq result
6238 (if unread
6239 (progn
6240 (while data
6241 (unless (memq (gnus-data-number (car data))
6242 (cond
6243 ((eq gnus-auto-goto-ignores
6244 'always-undownloaded)
6245 gnus-newsgroup-undownloaded)
6246 (gnus-plugged
6247 nil)
6248 ((eq gnus-auto-goto-ignores
6249 'unfetched)
6250 gnus-newsgroup-unfetched)
6251 ((eq gnus-auto-goto-ignores
6252 'undownloaded)
6253 gnus-newsgroup-undownloaded)))
6254 (when (gnus-data-unread-p (car data))
6255 (setq result (car data)
6256 data nil)))
6257 (setq data (cdr data)))
6258 result)
6259 (car data)))
6260 (goto-char (gnus-data-pos result))
6261 (gnus-data-number result))))
6263 (defun gnus-summary-find-subject (subject &optional unread backward article)
6264 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6265 (article (or article (gnus-summary-article-number)))
6266 (articles (gnus-data-list backward))
6267 (arts (gnus-data-find-list article articles))
6268 result)
6269 (when (or (not gnus-summary-check-current)
6270 (not unread)
6271 (not (gnus-data-unread-p (car arts))))
6272 (setq arts (cdr arts)))
6273 (while arts
6274 (and (or (not unread)
6275 (gnus-data-unread-p (car arts)))
6276 (vectorp (gnus-data-header (car arts)))
6277 (gnus-subject-equal
6278 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6279 (setq result (car arts)
6280 arts nil))
6281 (setq arts (cdr arts)))
6282 (and result
6283 (goto-char (gnus-data-pos result))
6284 (gnus-data-number result))))
6286 (defun gnus-summary-search-forward (&optional unread subject backward)
6287 "Search forward for an article.
6288 If UNREAD, look for unread articles. If SUBJECT, look for
6289 articles with that subject. If BACKWARD, search backward instead."
6290 (cond (subject (gnus-summary-find-subject subject unread backward))
6291 (backward (gnus-summary-find-prev unread))
6292 (t (gnus-summary-find-next unread))))
6294 (defun gnus-recenter (&optional n)
6295 "Center point in window and redisplay frame.
6296 Also do horizontal recentering."
6297 (interactive "P")
6298 (when (and gnus-auto-center-summary
6299 (not (eq gnus-auto-center-summary 'vertical)))
6300 (gnus-horizontal-recenter))
6301 (recenter n))
6303 (defun gnus-summary-recenter ()
6304 "Center point in the summary window.
6305 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6306 displayed, no centering will be performed."
6307 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6308 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6309 (interactive)
6310 ;; The user has to want it.
6311 (when gnus-auto-center-summary
6312 (let* ((top (cond ((< (window-height) 4) 0)
6313 ((< (window-height) 7) 1)
6314 (t (if (numberp gnus-auto-center-summary)
6315 gnus-auto-center-summary
6316 2))))
6317 (height (1- (window-height)))
6318 (bottom (save-excursion (goto-char (point-max))
6319 (forward-line (- height))
6320 (point)))
6321 (window (get-buffer-window (current-buffer))))
6322 (when (get-buffer-window gnus-article-buffer)
6323 ;; Only do recentering when the article buffer is displayed,
6324 ;; Set the window start to either `bottom', which is the biggest
6325 ;; possible valid number, or the second line from the top,
6326 ;; whichever is the least.
6327 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6328 (if (> bottom top-pos)
6329 ;; Keep the second line from the top visible
6330 (set-window-start window top-pos t)
6331 ;; Try to keep the bottom line visible; if it's partially
6332 ;; obscured, either scroll one more line to make it fully
6333 ;; visible, or revert to using TOP-POS.
6334 (save-excursion
6335 (goto-char (point-max))
6336 (forward-line -1)
6337 (let ((last-line-start (point)))
6338 (goto-char bottom)
6339 (set-window-start window (point) t)
6340 (when (not (pos-visible-in-window-p last-line-start window))
6341 (forward-line 1)
6342 (set-window-start window (min (point) top-pos) t)))))))
6343 ;; Do horizontal recentering while we're at it.
6344 (when (and (get-buffer-window (current-buffer) t)
6345 (not (eq gnus-auto-center-summary 'vertical)))
6346 (let ((selected (selected-window)))
6347 (select-window (get-buffer-window (current-buffer) t))
6348 (gnus-summary-position-point)
6349 (gnus-horizontal-recenter)
6350 (select-window selected))))))
6352 (defun gnus-summary-jump-to-group (newsgroup)
6353 "Move point to NEWSGROUP in group mode buffer."
6354 ;; Keep update point of group mode buffer if visible.
6355 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6356 (save-window-excursion
6357 ;; Take care of tree window mode.
6358 (when (get-buffer-window gnus-group-buffer)
6359 (pop-to-buffer gnus-group-buffer))
6360 (gnus-group-jump-to-group newsgroup))
6361 (save-excursion
6362 ;; Take care of tree window mode.
6363 (if (get-buffer-window gnus-group-buffer)
6364 (pop-to-buffer gnus-group-buffer)
6365 (set-buffer gnus-group-buffer))
6366 (gnus-group-jump-to-group newsgroup))))
6368 ;; This function returns a list of article numbers based on the
6369 ;; difference between the ranges of read articles in this group and
6370 ;; the range of active articles.
6371 (defun gnus-list-of-unread-articles (group)
6372 (let* ((read (gnus-info-read (gnus-get-info group)))
6373 (active (or (gnus-active group) (gnus-activate-group group)))
6374 (last (cdr active))
6375 first nlast unread)
6376 ;; If none are read, then all are unread.
6377 (if (not read)
6378 (setq first (car active))
6379 ;; If the range of read articles is a single range, then the
6380 ;; first unread article is the article after the last read
6381 ;; article. Sounds logical, doesn't it?
6382 (if (and (not (listp (cdr read)))
6383 (or (< (car read) (car active))
6384 (progn (setq read (list read))
6385 nil)))
6386 (setq first (max (car active) (1+ (cdr read))))
6387 ;; `read' is a list of ranges.
6388 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6389 (caar read)))
6391 (setq first (car active)))
6392 (while read
6393 (when first
6394 (while (< first nlast)
6395 (setq unread (cons first unread)
6396 first (1+ first))))
6397 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6398 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6399 (setq read (cdr read)))))
6400 ;; And add the last unread articles.
6401 (while (<= first last)
6402 (setq unread (cons first unread)
6403 first (1+ first)))
6404 ;; Return the list of unread articles.
6405 (delq 0 (nreverse unread))))
6407 (defun gnus-list-of-read-articles (group)
6408 "Return a list of unread, unticked and non-dormant articles."
6409 (let* ((info (gnus-get-info group))
6410 (marked (gnus-info-marks info))
6411 (active (gnus-active group)))
6412 (and info active
6413 (gnus-list-range-difference
6414 (gnus-list-range-difference
6415 (gnus-sorted-complement
6416 (gnus-uncompress-range active)
6417 (gnus-list-of-unread-articles group))
6418 (cdr (assq 'dormant marked)))
6419 (cdr (assq 'tick marked))))))
6421 ;; This function returns a sequence of article numbers based on the
6422 ;; difference between the ranges of read articles in this group and
6423 ;; the range of active articles.
6424 (defun gnus-sequence-of-unread-articles (group)
6425 (let* ((read (gnus-info-read (gnus-get-info group)))
6426 (active (or (gnus-active group) (gnus-activate-group group)))
6427 (last (cdr active))
6428 first nlast unread)
6429 ;; If none are read, then all are unread.
6430 (if (not read)
6431 (setq first (car active))
6432 ;; If the range of read articles is a single range, then the
6433 ;; first unread article is the article after the last read
6434 ;; article. Sounds logical, doesn't it?
6435 (if (and (not (listp (cdr read)))
6436 (or (< (car read) (car active))
6437 (progn (setq read (list read))
6438 nil)))
6439 (setq first (max (car active) (1+ (cdr read))))
6440 ;; `read' is a list of ranges.
6441 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6442 (caar read)))
6444 (setq first (car active)))
6445 (while read
6446 (when first
6447 (push (cons first nlast) unread))
6448 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6449 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6450 (setq read (cdr read)))))
6451 ;; And add the last unread articles.
6452 (cond ((< first last)
6453 (push (cons first last) unread))
6454 ((= first last)
6455 (push first unread)))
6456 ;; Return the sequence of unread articles.
6457 (delq 0 (nreverse unread))))
6459 ;; Various summary commands
6461 (defun gnus-summary-select-article-buffer ()
6462 "Reconfigure windows to show article buffer."
6463 (interactive)
6464 (if (not (gnus-buffer-live-p gnus-article-buffer))
6465 (error "There is no article buffer for this summary buffer")
6466 (gnus-configure-windows 'article)
6467 (select-window (get-buffer-window gnus-article-buffer))))
6469 (defun gnus-summary-universal-argument (arg)
6470 "Perform any operation on all articles that are process/prefixed."
6471 (interactive "P")
6472 (let ((articles (gnus-summary-work-articles arg))
6473 func article)
6474 (if (eq
6475 (setq
6476 func
6477 (key-binding
6478 (read-key-sequence
6479 (substitute-command-keys
6480 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6481 'undefined)
6482 (gnus-error 1 "Undefined key")
6483 (save-excursion
6484 (while articles
6485 (gnus-summary-goto-subject (setq article (pop articles)))
6486 (let (gnus-newsgroup-processable)
6487 (command-execute func))
6488 (gnus-summary-remove-process-mark article)))))
6489 (gnus-summary-position-point))
6491 (defun gnus-summary-toggle-truncation (&optional arg)
6492 "Toggle truncation of summary lines.
6493 With ARG, turn line truncation on if ARG is positive."
6494 (interactive "P")
6495 (setq truncate-lines
6496 (if (null arg) (not truncate-lines)
6497 (> (prefix-numeric-value arg) 0)))
6498 (redraw-display))
6500 (defun gnus-summary-find-for-reselect ()
6501 "Return the number of an article to stay on across a reselect.
6502 The current article is considered, then following articles, then previous
6503 articles. An article is sought which is not cancelled and isn't a temporary
6504 insertion from another group. If there's no such then return a dummy 0."
6505 (let (found)
6506 (dolist (rev '(nil t))
6507 (unless found ; don't demand the reverse list if we don't need it
6508 (let ((data (gnus-data-find-list
6509 (gnus-summary-article-number) (gnus-data-list rev))))
6510 (while (and data (not found))
6511 (if (and (< 0 (gnus-data-number (car data)))
6512 (not (eq gnus-canceled-mark (gnus-data-mark (car data)))))
6513 (setq found (gnus-data-number (car data))))
6514 (setq data (cdr data))))))
6515 (or found 0)))
6517 (defun gnus-summary-reselect-current-group (&optional all rescan)
6518 "Exit and then reselect the current newsgroup.
6519 The prefix argument ALL means to select all articles."
6520 (interactive "P")
6521 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6522 (error "Ephemeral groups can't be reselected"))
6523 (let ((current-subject (gnus-summary-find-for-reselect))
6524 (group gnus-newsgroup-name))
6525 (setq gnus-newsgroup-begin nil)
6526 (gnus-summary-exit nil 'leave-hidden)
6527 ;; We have to adjust the point of group mode buffer because
6528 ;; point was moved to the next unread newsgroup by exiting.
6529 (gnus-summary-jump-to-group group)
6530 (when rescan
6531 (save-excursion
6532 (gnus-group-get-new-news-this-group 1)))
6533 (gnus-group-read-group all t)
6534 (gnus-summary-goto-subject current-subject nil t)))
6536 (defun gnus-summary-rescan-group (&optional all)
6537 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6538 (interactive "P")
6539 (gnus-summary-reselect-current-group all t))
6541 (defun gnus-summary-update-info (&optional non-destructive)
6542 (save-excursion
6543 (let ((group gnus-newsgroup-name))
6544 (when group
6545 (when gnus-newsgroup-kill-headers
6546 (setq gnus-newsgroup-killed
6547 (gnus-compress-sequence
6548 (gnus-sorted-union
6549 (gnus-list-range-intersection
6550 gnus-newsgroup-unselected gnus-newsgroup-killed)
6551 gnus-newsgroup-unreads)
6552 t)))
6553 (unless (listp (cdr gnus-newsgroup-killed))
6554 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6555 (let ((headers gnus-newsgroup-headers))
6556 ;; Set the new ranges of read articles.
6557 (save-excursion
6558 (set-buffer gnus-group-buffer)
6559 (gnus-undo-force-boundary))
6560 (gnus-update-read-articles
6561 group (gnus-sorted-union
6562 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6563 ;; Set the current article marks.
6564 (let ((gnus-newsgroup-scored
6565 (if (and (not gnus-save-score)
6566 (not non-destructive))
6568 gnus-newsgroup-scored)))
6569 (save-excursion
6570 (gnus-update-marks)))
6571 ;; Do the cross-ref thing.
6572 (when gnus-use-cross-reference
6573 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6574 ;; Do not switch windows but change the buffer to work.
6575 (set-buffer gnus-group-buffer)
6576 (unless (gnus-ephemeral-group-p group)
6577 (gnus-group-update-group group)))))))
6579 (defun gnus-summary-save-newsrc (&optional force)
6580 "Save the current number of read/marked articles in the dribble buffer.
6581 The dribble buffer will then be saved.
6582 If FORCE (the prefix), also save the .newsrc file(s)."
6583 (interactive "P")
6584 (gnus-summary-update-info t)
6585 (if force
6586 (gnus-save-newsrc-file)
6587 (gnus-dribble-save)))
6589 (defun gnus-summary-exit (&optional temporary leave-hidden)
6590 "Exit reading current newsgroup, and then return to group selection mode.
6591 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6592 (interactive)
6593 (gnus-set-global-variables)
6594 (when (gnus-buffer-live-p gnus-article-buffer)
6595 (save-excursion
6596 (set-buffer gnus-article-buffer)
6597 (mm-destroy-parts gnus-article-mime-handles)
6598 ;; Set it to nil for safety reason.
6599 (setq gnus-article-mime-handle-alist nil)
6600 (setq gnus-article-mime-handles nil)))
6601 (gnus-kill-save-kill-buffer)
6602 (gnus-async-halt-prefetch)
6603 (let* ((group gnus-newsgroup-name)
6604 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6605 (gnus-group-is-exiting-p t)
6606 (mode major-mode)
6607 (group-point nil)
6608 (buf (current-buffer)))
6609 (unless quit-config
6610 ;; Do adaptive scoring, and possibly save score files.
6611 (when gnus-newsgroup-adaptive
6612 (gnus-score-adaptive))
6613 (when gnus-use-scoring
6614 (gnus-score-save)))
6615 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6616 ;; If we have several article buffers, we kill them at exit.
6617 (unless gnus-single-article-buffer
6618 (gnus-kill-buffer gnus-original-article-buffer)
6619 (setq gnus-article-current nil))
6620 (when gnus-use-cache
6621 (gnus-cache-possibly-remove-articles)
6622 (gnus-cache-save-buffers))
6623 (gnus-async-prefetch-remove-group group)
6624 (when gnus-suppress-duplicates
6625 (gnus-dup-enter-articles))
6626 (when gnus-use-trees
6627 (gnus-tree-close group))
6628 (when gnus-use-cache
6629 (gnus-cache-write-active))
6630 ;; Remove entries for this group.
6631 (nnmail-purge-split-history (gnus-group-real-name group))
6632 ;; Make all changes in this group permanent.
6633 (unless quit-config
6634 (gnus-run-hooks 'gnus-exit-group-hook)
6635 (gnus-summary-update-info))
6636 (gnus-close-group group)
6637 ;; Make sure where we were, and go to next newsgroup.
6638 (set-buffer gnus-group-buffer)
6639 (unless quit-config
6640 (gnus-group-jump-to-group group))
6641 (gnus-run-hooks 'gnus-summary-exit-hook)
6642 (unless (or quit-config
6643 ;; If this group has disappeared from the summary
6644 ;; buffer, don't skip forwards.
6645 (not (string= group (gnus-group-group-name))))
6646 (gnus-group-next-unread-group 1))
6647 (setq group-point (point))
6648 (if temporary
6649 nil ;Nothing to do.
6650 ;; If we have several article buffers, we kill them at exit.
6651 (unless gnus-single-article-buffer
6652 (gnus-kill-buffer gnus-article-buffer)
6653 (gnus-kill-buffer gnus-original-article-buffer)
6654 (setq gnus-article-current nil))
6655 (set-buffer buf)
6656 (if (not gnus-kill-summary-on-exit)
6657 (progn
6658 (gnus-deaden-summary)
6659 (setq mode nil))
6660 ;; We set all buffer-local variables to nil. It is unclear why
6661 ;; this is needed, but if we don't, buffer-local variables are
6662 ;; not garbage-collected, it seems. This would the lead to en
6663 ;; ever-growing Emacs.
6664 (gnus-summary-clear-local-variables)
6665 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6666 (gnus-summary-clear-local-variables))
6667 (when (get-buffer gnus-article-buffer)
6668 (bury-buffer gnus-article-buffer))
6669 ;; We clear the global counterparts of the buffer-local
6670 ;; variables as well, just to be on the safe side.
6671 (set-buffer gnus-group-buffer)
6672 (gnus-summary-clear-local-variables)
6673 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6674 (gnus-summary-clear-local-variables))
6675 ;; Return to group mode buffer.
6676 (when (eq mode 'gnus-summary-mode)
6677 (gnus-kill-buffer buf)))
6678 (setq gnus-current-select-method gnus-select-method)
6679 (if leave-hidden
6680 (set-buffer gnus-group-buffer)
6681 (pop-to-buffer gnus-group-buffer))
6682 (if (not quit-config)
6683 (progn
6684 (goto-char group-point)
6685 (unless leave-hidden
6686 (gnus-configure-windows 'group 'force)))
6687 (gnus-handle-ephemeral-exit quit-config))
6688 ;; Clear the current group name.
6689 (unless quit-config
6690 (setq gnus-newsgroup-name nil)))))
6692 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6693 (defun gnus-summary-exit-no-update (&optional no-questions)
6694 "Quit reading current newsgroup without updating read article info."
6695 (interactive)
6696 (let* ((group gnus-newsgroup-name)
6697 (gnus-group-is-exiting-p t)
6698 (gnus-group-is-exiting-without-update-p t)
6699 (quit-config (gnus-group-quit-config group)))
6700 (when (or no-questions
6701 gnus-expert-user
6702 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6703 (gnus-async-halt-prefetch)
6704 (run-hooks 'gnus-summary-prepare-exit-hook)
6705 (when (gnus-buffer-live-p gnus-article-buffer)
6706 (save-excursion
6707 (set-buffer gnus-article-buffer)
6708 (mm-destroy-parts gnus-article-mime-handles)
6709 ;; Set it to nil for safety reason.
6710 (setq gnus-article-mime-handle-alist nil)
6711 (setq gnus-article-mime-handles nil)))
6712 ;; If we have several article buffers, we kill them at exit.
6713 (unless gnus-single-article-buffer
6714 (gnus-kill-buffer gnus-article-buffer)
6715 (gnus-kill-buffer gnus-original-article-buffer)
6716 (setq gnus-article-current nil))
6717 (if (not gnus-kill-summary-on-exit)
6718 (gnus-deaden-summary)
6719 (gnus-close-group group)
6720 (gnus-summary-clear-local-variables)
6721 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6722 (gnus-summary-clear-local-variables))
6723 (set-buffer gnus-group-buffer)
6724 (gnus-summary-clear-local-variables)
6725 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6726 (gnus-summary-clear-local-variables))
6727 (gnus-kill-buffer gnus-summary-buffer))
6728 (unless gnus-single-article-buffer
6729 (setq gnus-article-current nil))
6730 (when gnus-use-trees
6731 (gnus-tree-close group))
6732 (gnus-async-prefetch-remove-group group)
6733 (when (get-buffer gnus-article-buffer)
6734 (bury-buffer gnus-article-buffer))
6735 ;; Return to the group buffer.
6736 (gnus-configure-windows 'group 'force)
6737 ;; Clear the current group name.
6738 (setq gnus-newsgroup-name nil)
6739 (unless (gnus-ephemeral-group-p group)
6740 (gnus-group-update-group group))
6741 (when (equal (gnus-group-group-name) group)
6742 (gnus-group-next-unread-group 1))
6743 (when quit-config
6744 (gnus-handle-ephemeral-exit quit-config)))))
6746 (defun gnus-handle-ephemeral-exit (quit-config)
6747 "Handle movement when leaving an ephemeral group.
6748 The state which existed when entering the ephemeral is reset."
6749 (if (not (buffer-name (car quit-config)))
6750 (gnus-configure-windows 'group 'force)
6751 (set-buffer (car quit-config))
6752 (cond ((eq major-mode 'gnus-summary-mode)
6753 (gnus-set-global-variables))
6754 ((eq major-mode 'gnus-article-mode)
6755 (save-excursion
6756 ;; The `gnus-summary-buffer' variable may point
6757 ;; to the old summary buffer when using a single
6758 ;; article buffer.
6759 (unless (gnus-buffer-live-p gnus-summary-buffer)
6760 (set-buffer gnus-group-buffer))
6761 (set-buffer gnus-summary-buffer)
6762 (gnus-set-global-variables))))
6763 (if (or (eq (cdr quit-config) 'article)
6764 (eq (cdr quit-config) 'pick))
6765 (progn
6766 ;; The current article may be from the ephemeral group
6767 ;; thus it is best that we reload this article
6769 ;; If we're exiting from a large digest, this can be
6770 ;; extremely slow. So, it's better not to reload it. -- jh.
6771 ;;(gnus-summary-show-article)
6772 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6773 (gnus-configure-windows 'pick 'force)
6774 (gnus-configure-windows (cdr quit-config) 'force)))
6775 (gnus-configure-windows (cdr quit-config) 'force))
6776 (when (eq major-mode 'gnus-summary-mode)
6777 (gnus-summary-next-subject 1 nil t)
6778 (gnus-summary-recenter)
6779 (gnus-summary-position-point))))
6781 ;;; Dead summaries.
6783 (defvar gnus-dead-summary-mode-map nil)
6785 (unless gnus-dead-summary-mode-map
6786 (setq gnus-dead-summary-mode-map (make-keymap))
6787 (suppress-keymap gnus-dead-summary-mode-map)
6788 (substitute-key-definition
6789 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6790 (dolist (key '("\C-d" "\r" "\177" [delete]))
6791 (define-key gnus-dead-summary-mode-map
6792 key 'gnus-summary-wake-up-the-dead))
6793 (dolist (key '("q" "Q"))
6794 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6796 (defvar gnus-dead-summary-mode nil
6797 "Minor mode for Gnus summary buffers.")
6799 (defun gnus-dead-summary-mode (&optional arg)
6800 "Minor mode for Gnus summary buffers."
6801 (interactive "P")
6802 (when (eq major-mode 'gnus-summary-mode)
6803 (make-local-variable 'gnus-dead-summary-mode)
6804 (setq gnus-dead-summary-mode
6805 (if (null arg) (not gnus-dead-summary-mode)
6806 (> (prefix-numeric-value arg) 0)))
6807 (when gnus-dead-summary-mode
6808 (gnus-add-minor-mode
6809 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6811 (defun gnus-deaden-summary ()
6812 "Make the current summary buffer into a dead summary buffer."
6813 ;; Kill any previous dead summary buffer.
6814 (when (and gnus-dead-summary
6815 (buffer-name gnus-dead-summary))
6816 (save-excursion
6817 (set-buffer gnus-dead-summary)
6818 (when gnus-dead-summary-mode
6819 (kill-buffer (current-buffer)))))
6820 ;; Make this the current dead summary.
6821 (setq gnus-dead-summary (current-buffer))
6822 (gnus-dead-summary-mode 1)
6823 (let ((name (buffer-name)))
6824 (when (string-match "Summary" name)
6825 (rename-buffer
6826 (concat (substring name 0 (match-beginning 0)) "Dead "
6827 (substring name (match-beginning 0)))
6829 (bury-buffer))))
6831 (defun gnus-kill-or-deaden-summary (buffer)
6832 "Kill or deaden the summary BUFFER."
6833 (save-excursion
6834 (when (and (buffer-name buffer)
6835 (not gnus-single-article-buffer))
6836 (save-excursion
6837 (set-buffer buffer)
6838 (gnus-kill-buffer gnus-article-buffer)
6839 (gnus-kill-buffer gnus-original-article-buffer)))
6840 (cond
6841 ;; Kill the buffer.
6842 (gnus-kill-summary-on-exit
6843 (when (and gnus-use-trees
6844 (gnus-buffer-exists-p buffer))
6845 (save-excursion
6846 (set-buffer buffer)
6847 (gnus-tree-close gnus-newsgroup-name)))
6848 (gnus-kill-buffer buffer))
6849 ;; Deaden the buffer.
6850 ((gnus-buffer-exists-p buffer)
6851 (save-excursion
6852 (set-buffer buffer)
6853 (gnus-deaden-summary))))))
6855 (defun gnus-summary-wake-up-the-dead (&rest args)
6856 "Wake up the dead summary buffer."
6857 (interactive)
6858 (gnus-dead-summary-mode -1)
6859 (let ((name (buffer-name)))
6860 (when (string-match "Dead " name)
6861 (rename-buffer
6862 (concat (substring name 0 (match-beginning 0))
6863 (substring name (match-end 0)))
6864 t)))
6865 (gnus-message 3 "This dead summary is now alive again"))
6867 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6868 (defun gnus-summary-fetch-faq (&optional faq-dir)
6869 "Fetch the FAQ for the current group.
6870 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6871 in."
6872 (interactive
6873 (list
6874 (when current-prefix-arg
6875 (completing-read
6876 "FAQ dir: " (and (listp gnus-group-faq-directory)
6877 (mapcar (lambda (file) (list file))
6878 gnus-group-faq-directory))))))
6879 (let (gnus-faq-buffer)
6880 (when (setq gnus-faq-buffer
6881 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6882 (gnus-configure-windows 'summary-faq))))
6884 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6885 (defun gnus-summary-describe-group (&optional force)
6886 "Describe the current newsgroup."
6887 (interactive "P")
6888 (gnus-group-describe-group force gnus-newsgroup-name))
6890 (defun gnus-summary-describe-briefly ()
6891 "Describe summary mode commands briefly."
6892 (interactive)
6893 (gnus-message 6 (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")))
6895 ;; Walking around group mode buffer from summary mode.
6897 (defun gnus-summary-next-group (&optional no-article target-group backward)
6898 "Exit current newsgroup and then select next unread newsgroup.
6899 If prefix argument NO-ARTICLE is non-nil, no article is selected
6900 initially. If TARGET-GROUP, go to this group. If BACKWARD, go to
6901 previous group instead."
6902 (interactive "P")
6903 ;; Stop pre-fetching.
6904 (gnus-async-halt-prefetch)
6905 (let ((current-group gnus-newsgroup-name)
6906 (current-buffer (current-buffer))
6907 entered)
6908 ;; First we semi-exit this group to update Xrefs and all variables.
6909 ;; We can't do a real exit, because the window conf must remain
6910 ;; the same in case the user is prompted for info, and we don't
6911 ;; want the window conf to change before that...
6912 (gnus-summary-exit t)
6913 (while (not entered)
6914 ;; Then we find what group we are supposed to enter.
6915 (set-buffer gnus-group-buffer)
6916 (gnus-group-jump-to-group current-group)
6917 (setq target-group
6918 (or target-group
6919 (if (eq gnus-keep-same-level 'best)
6920 (gnus-summary-best-group gnus-newsgroup-name)
6921 (gnus-summary-search-group backward gnus-keep-same-level))))
6922 (if (not target-group)
6923 ;; There are no further groups, so we return to the group
6924 ;; buffer.
6925 (progn
6926 (gnus-message 5 "Returning to the group buffer")
6927 (setq entered t)
6928 (when (gnus-buffer-live-p current-buffer)
6929 (set-buffer current-buffer)
6930 (gnus-summary-exit))
6931 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6932 ;; We try to enter the target group.
6933 (gnus-group-jump-to-group target-group)
6934 (let ((unreads (gnus-group-group-unread)))
6935 (if (and (or (eq t unreads)
6936 (and unreads (not (zerop unreads))))
6937 (gnus-summary-read-group
6938 target-group nil no-article
6939 (and (buffer-name current-buffer) current-buffer)
6940 nil backward))
6941 (setq entered t)
6942 (setq current-group target-group
6943 target-group nil)))))))
6945 (defun gnus-summary-prev-group (&optional no-article)
6946 "Exit current newsgroup and then select previous unread newsgroup.
6947 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6948 (interactive "P")
6949 (gnus-summary-next-group no-article nil t))
6951 ;; Walking around summary lines.
6953 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6954 "Go to the first subject satisfying any non-nil constraint.
6955 If UNREAD is non-nil, the article should be unread.
6956 If UNDOWNLOADED is non-nil, the article should be undownloaded.
6957 If UNSEEN is non-nil, the article should be unseen.
6958 Returns the article selected or nil if there are no matching articles."
6959 (interactive "P")
6960 (cond
6961 ;; Empty summary.
6962 ((null gnus-newsgroup-data)
6963 (gnus-message 3 "No articles in the group")
6964 nil)
6965 ;; Pick the first article.
6966 ((not (or unread undownloaded unseen))
6967 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6968 (gnus-data-number (car gnus-newsgroup-data)))
6969 ;; Find the first unread article.
6971 (let ((data gnus-newsgroup-data))
6972 (while (and data
6973 (let ((num (gnus-data-number (car data))))
6974 (or (memq num gnus-newsgroup-unfetched)
6975 (not (or (and unread
6976 (memq num gnus-newsgroup-unreads))
6977 (and undownloaded
6978 (memq num gnus-newsgroup-undownloaded))
6979 (and unseen
6980 (memq num gnus-newsgroup-unseen)))))))
6981 (setq data (cdr data)))
6982 (prog1
6983 (if data
6984 (progn
6985 (goto-char (gnus-data-pos (car data)))
6986 (gnus-data-number (car data)))
6987 (gnus-message 3 "No more%s articles"
6988 (let* ((r (when unread " unread"))
6989 (d (when undownloaded " undownloaded"))
6990 (s (when unseen " unseen"))
6991 (l (delq nil (list r d s))))
6992 (cond ((= 3 (length l))
6993 (concat r "," d ", or" s))
6994 ((= 2 (length l))
6995 (concat (car l) ", or" (cadr l)))
6996 ((= 1 (length l))
6997 (car l))
6999 ""))))
7002 (gnus-summary-position-point))))))
7004 (defun gnus-summary-next-subject (n &optional unread dont-display)
7005 "Go to next N'th summary line.
7006 If N is negative, go to the previous N'th subject line.
7007 If UNREAD is non-nil, only unread articles are selected.
7008 The difference between N and the actual number of steps taken is
7009 returned."
7010 (interactive "p")
7011 (let ((backward (< n 0))
7012 (n (abs n)))
7013 (while (and (> n 0)
7014 (if backward
7015 (gnus-summary-find-prev unread)
7016 (gnus-summary-find-next unread)))
7017 (unless (zerop (setq n (1- n)))
7018 (gnus-summary-show-thread)))
7019 (when (/= 0 n)
7020 (gnus-message 7 "No more%s articles"
7021 (if unread " unread" "")))
7022 (unless dont-display
7023 (gnus-summary-recenter)
7024 (gnus-summary-position-point))
7027 (defun gnus-summary-next-unread-subject (n)
7028 "Go to next N'th unread summary line."
7029 (interactive "p")
7030 (gnus-summary-next-subject n t))
7032 (defun gnus-summary-prev-subject (n &optional unread)
7033 "Go to previous N'th summary line.
7034 If optional argument UNREAD is non-nil, only unread article is selected."
7035 (interactive "p")
7036 (gnus-summary-next-subject (- n) unread))
7038 (defun gnus-summary-prev-unread-subject (n)
7039 "Go to previous N'th unread summary line."
7040 (interactive "p")
7041 (gnus-summary-next-subject (- n) t))
7043 (defun gnus-summary-goto-subjects (articles)
7044 "Insert the subject header for ARTICLES in the current buffer."
7045 (save-excursion
7046 (dolist (article articles)
7047 (gnus-summary-goto-subject article t)))
7048 (gnus-summary-limit (append articles gnus-newsgroup-limit))
7049 (gnus-summary-position-point))
7051 (defun gnus-summary-goto-subject (article &optional force silent)
7052 "Go the subject line of ARTICLE.
7053 If FORCE, also allow jumping to articles not currently shown."
7054 (interactive "nArticle number: ")
7055 (unless (numberp article)
7056 (error "Article %s is not a number" article))
7057 (let ((b (point))
7058 (data (gnus-data-find article)))
7059 ;; We read in the article if we have to.
7060 (and (not data)
7061 force
7062 (gnus-summary-insert-subject
7063 article
7064 (if (or (numberp force) (vectorp force)) force)
7066 (setq data (gnus-data-find article)))
7067 (goto-char b)
7068 (if (not data)
7069 (progn
7070 (unless silent
7071 (gnus-message 3 "Can't find article %d" article))
7072 nil)
7073 (let ((pt (gnus-data-pos data)))
7074 (goto-char pt)
7075 (gnus-summary-set-article-display-arrow pt))
7076 (gnus-summary-position-point)
7077 article)))
7079 ;; Walking around summary lines with displaying articles.
7081 (defun gnus-summary-expand-window (&optional arg)
7082 "Make the summary buffer take up the entire Emacs frame.
7083 Given a prefix, will force an `article' buffer configuration."
7084 (interactive "P")
7085 (if arg
7086 (gnus-configure-windows 'article 'force)
7087 (gnus-configure-windows 'summary 'force)))
7089 (defun gnus-summary-display-article (article &optional all-header)
7090 "Display ARTICLE in article buffer."
7091 (when (gnus-buffer-live-p gnus-article-buffer)
7092 (with-current-buffer gnus-article-buffer
7093 (mm-enable-multibyte)))
7094 (gnus-set-global-variables)
7095 (when (gnus-buffer-live-p gnus-article-buffer)
7096 (with-current-buffer gnus-article-buffer
7097 (setq gnus-article-charset gnus-newsgroup-charset)
7098 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
7099 (mm-enable-multibyte)))
7100 (if (null article)
7102 (prog1
7103 (if gnus-summary-display-article-function
7104 (funcall gnus-summary-display-article-function article all-header)
7105 (gnus-article-prepare article all-header))
7106 (gnus-run-hooks 'gnus-select-article-hook)
7107 (when (and gnus-current-article
7108 (not (zerop gnus-current-article)))
7109 (gnus-summary-goto-subject gnus-current-article))
7110 (gnus-summary-recenter)
7111 (when (and gnus-use-trees gnus-show-threads)
7112 (gnus-possibly-generate-tree article)
7113 (gnus-highlight-selected-tree article))
7114 ;; Successfully display article.
7115 (gnus-article-set-window-start
7116 (cdr (assq article gnus-newsgroup-bookmarks))))))
7118 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
7119 "Select the current article.
7120 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
7121 non-nil, the article will be re-fetched even if it already present in
7122 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
7123 be displayed."
7124 ;; Make sure we are in the summary buffer to work around bbdb bug.
7125 (unless (eq major-mode 'gnus-summary-mode)
7126 (set-buffer gnus-summary-buffer))
7127 (let ((article (or article (gnus-summary-article-number)))
7128 (all-headers (not (not all-headers))) ;Must be t or nil.
7129 gnus-summary-display-article-function)
7130 (and (not pseudo)
7131 (gnus-summary-article-pseudo-p article)
7132 (error "This is a pseudo-article"))
7133 (save-excursion
7134 (set-buffer gnus-summary-buffer)
7135 (if (or (and gnus-single-article-buffer
7136 (or (null gnus-current-article)
7137 (null gnus-article-current)
7138 (null (get-buffer gnus-article-buffer))
7139 (not (eq article (cdr gnus-article-current)))
7140 (not (equal (car gnus-article-current)
7141 gnus-newsgroup-name))))
7142 (and (not gnus-single-article-buffer)
7143 (or (null gnus-current-article)
7144 (not (eq gnus-current-article article))))
7145 force)
7146 ;; The requested article is different from the current article.
7147 (progn
7148 (gnus-summary-display-article article all-headers)
7149 (when (gnus-buffer-live-p gnus-article-buffer)
7150 (with-current-buffer gnus-article-buffer
7151 (if (not gnus-article-decoded-p) ;; a local variable
7152 (mm-disable-multibyte))))
7153 (gnus-article-set-window-start
7154 (cdr (assq article gnus-newsgroup-bookmarks)))
7155 article)
7156 'old))))
7158 (defun gnus-summary-force-verify-and-decrypt ()
7159 "Display buttons for signed/encrypted parts and verify/decrypt them."
7160 (interactive)
7161 (let ((mm-verify-option 'known)
7162 (mm-decrypt-option 'known)
7163 (gnus-article-emulate-mime t)
7164 (gnus-buttonized-mime-types (append (list "multipart/signed"
7165 "multipart/encrypted")
7166 gnus-buttonized-mime-types)))
7167 (gnus-summary-select-article nil 'force)))
7169 (defun gnus-summary-set-current-mark (&optional current-mark)
7170 "Obsolete function."
7171 nil)
7173 (defun gnus-summary-next-article (&optional unread subject backward push)
7174 "Select the next article.
7175 If UNREAD, only unread articles are selected.
7176 If SUBJECT, only articles with SUBJECT are selected.
7177 If BACKWARD, the previous article is selected instead of the next."
7178 (interactive "P")
7179 (cond
7180 ;; Is there such an article?
7181 ((and (gnus-summary-search-forward unread subject backward)
7182 (or (gnus-summary-display-article (gnus-summary-article-number))
7183 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
7184 (gnus-summary-position-point))
7185 ;; If not, we try the first unread, if that is wanted.
7186 ((and subject
7187 gnus-auto-select-same
7188 (gnus-summary-first-unread-article))
7189 (gnus-summary-position-point)
7190 (gnus-message 6 "Wrapped"))
7191 ;; Try to get next/previous article not displayed in this group.
7192 ((and gnus-auto-extend-newsgroup
7193 (not unread) (not subject))
7194 (gnus-summary-goto-article
7195 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
7196 nil (count-lines (point-min) (point))))
7197 ;; Go to next/previous group.
7199 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
7200 (gnus-summary-jump-to-group gnus-newsgroup-name))
7201 (let ((cmd last-command-char)
7202 (point
7203 (save-excursion
7204 (set-buffer gnus-group-buffer)
7205 (point)))
7206 (group
7207 (if (eq gnus-keep-same-level 'best)
7208 (gnus-summary-best-group gnus-newsgroup-name)
7209 (gnus-summary-search-group backward gnus-keep-same-level))))
7210 ;; For some reason, the group window gets selected. We change
7211 ;; it back.
7212 (select-window (get-buffer-window (current-buffer)))
7213 ;; Select next unread newsgroup automagically.
7214 (cond
7215 ((or (not gnus-auto-select-next)
7216 (not cmd))
7217 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
7218 ((or (eq gnus-auto-select-next 'quietly)
7219 (and (eq gnus-auto-select-next 'slightly-quietly)
7220 push)
7221 (and (eq gnus-auto-select-next 'almost-quietly)
7222 (gnus-summary-last-article-p)))
7223 ;; Select quietly.
7224 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
7225 (gnus-summary-exit)
7226 (gnus-message 7 "No more%s articles (%s)..."
7227 (if unread " unread" "")
7228 (if group (concat "selecting " group)
7229 "exiting"))
7230 (gnus-summary-next-group nil group backward)))
7232 (when (gnus-key-press-event-p last-input-event)
7233 (gnus-summary-walk-group-buffer
7234 gnus-newsgroup-name cmd unread backward point))))))))
7236 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
7237 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
7238 (?\C-p (gnus-group-prev-unread-group 1))))
7239 (cursor-in-echo-area t)
7240 keve key group ended prompt)
7241 (save-excursion
7242 (set-buffer gnus-group-buffer)
7243 (goto-char start)
7244 (setq group
7245 (if (eq gnus-keep-same-level 'best)
7246 (gnus-summary-best-group gnus-newsgroup-name)
7247 (gnus-summary-search-group backward gnus-keep-same-level))))
7248 (while (not ended)
7249 (setq prompt
7250 (format
7251 "No more%s articles%s " (if unread " unread" "")
7252 (if (and group
7253 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
7254 (format " (Type %s for %s [%s])"
7255 (single-key-description cmd) group
7256 (car (gnus-gethash group gnus-newsrc-hashtb)))
7257 (format " (Type %s to exit %s)"
7258 (single-key-description cmd)
7259 gnus-newsgroup-name))))
7260 ;; Confirm auto selection.
7261 (setq key (car (setq keve (gnus-read-event-char prompt)))
7262 ended t)
7263 (cond
7264 ((assq key keystrokes)
7265 (let ((obuf (current-buffer)))
7266 (switch-to-buffer gnus-group-buffer)
7267 (when group
7268 (gnus-group-jump-to-group group))
7269 (eval (cadr (assq key keystrokes)))
7270 (setq group (gnus-group-group-name))
7271 (switch-to-buffer obuf))
7272 (setq ended nil))
7273 ((equal key cmd)
7274 (if (or (not group)
7275 (gnus-ephemeral-group-p gnus-newsgroup-name))
7276 (gnus-summary-exit)
7277 (gnus-summary-next-group nil group backward)))
7279 (push (cdr keve) unread-command-events))))))
7281 (defun gnus-summary-next-unread-article ()
7282 "Select unread article after current one."
7283 (interactive)
7284 (gnus-summary-next-article
7285 (or (not (eq gnus-summary-goto-unread 'never))
7286 (gnus-summary-last-article-p (gnus-summary-article-number)))
7287 (and gnus-auto-select-same
7288 (gnus-summary-article-subject))))
7290 (defun gnus-summary-prev-article (&optional unread subject)
7291 "Select the article after the current one.
7292 If UNREAD is non-nil, only unread articles are selected."
7293 (interactive "P")
7294 (gnus-summary-next-article unread subject t))
7296 (defun gnus-summary-prev-unread-article ()
7297 "Select unread article before current one."
7298 (interactive)
7299 (gnus-summary-prev-article
7300 (or (not (eq gnus-summary-goto-unread 'never))
7301 (gnus-summary-first-article-p (gnus-summary-article-number)))
7302 (and gnus-auto-select-same
7303 (gnus-summary-article-subject))))
7305 (defun gnus-summary-next-page (&optional lines circular stop)
7306 "Show next page of the selected article.
7307 If at the end of the current article, select the next article.
7308 LINES says how many lines should be scrolled up.
7310 If CIRCULAR is non-nil, go to the start of the article instead of
7311 selecting the next article when reaching the end of the current
7312 article.
7314 If STOP is non-nil, just stop when reaching the end of the message.
7316 Also see the variable `gnus-article-skip-boring'."
7317 (interactive "P")
7318 (setq gnus-summary-buffer (current-buffer))
7319 (gnus-set-global-variables)
7320 (let ((article (gnus-summary-article-number))
7321 (article-window (get-buffer-window gnus-article-buffer t))
7322 endp)
7323 ;; If the buffer is empty, we have no article.
7324 (unless article
7325 (error "No article to select"))
7326 (gnus-configure-windows 'article)
7327 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7328 (if (and (eq gnus-summary-goto-unread 'never)
7329 (not (gnus-summary-last-article-p article)))
7330 (gnus-summary-next-article)
7331 (gnus-summary-next-unread-article))
7332 (if (or (null gnus-current-article)
7333 (null gnus-article-current)
7334 (/= article (cdr gnus-article-current))
7335 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7336 ;; Selected subject is different from current article's.
7337 (gnus-summary-display-article article)
7338 (when article-window
7339 (gnus-eval-in-buffer-window gnus-article-buffer
7340 (setq endp (or (gnus-article-next-page lines)
7341 (gnus-article-only-boring-p))))
7342 (when endp
7343 (cond (stop
7344 (gnus-message 3 "End of message"))
7345 (circular
7346 (gnus-summary-beginning-of-article))
7347 (lines
7348 (gnus-message 3 "End of message"))
7349 ((null lines)
7350 (if (and (eq gnus-summary-goto-unread 'never)
7351 (not (gnus-summary-last-article-p article)))
7352 (gnus-summary-next-article)
7353 (gnus-summary-next-unread-article))))))))
7354 (gnus-summary-recenter)
7355 (gnus-summary-position-point)))
7357 (defun gnus-summary-prev-page (&optional lines move)
7358 "Show previous page of selected article.
7359 Argument LINES specifies lines to be scrolled down.
7360 If MOVE, move to the previous unread article if point is at
7361 the beginning of the buffer."
7362 (interactive "P")
7363 (let ((article (gnus-summary-article-number))
7364 (article-window (get-buffer-window gnus-article-buffer t))
7365 endp)
7366 (gnus-configure-windows 'article)
7367 (if (or (null gnus-current-article)
7368 (null gnus-article-current)
7369 (/= article (cdr gnus-article-current))
7370 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7371 ;; Selected subject is different from current article's.
7372 (gnus-summary-display-article article)
7373 (gnus-summary-recenter)
7374 (when article-window
7375 (gnus-eval-in-buffer-window gnus-article-buffer
7376 (setq endp (gnus-article-prev-page lines)))
7377 (when (and move endp)
7378 (cond (lines
7379 (gnus-message 3 "Beginning of message"))
7380 ((null lines)
7381 (if (and (eq gnus-summary-goto-unread 'never)
7382 (not (gnus-summary-first-article-p article)))
7383 (gnus-summary-prev-article)
7384 (gnus-summary-prev-unread-article))))))))
7385 (gnus-summary-position-point))
7387 (defun gnus-summary-prev-page-or-article (&optional lines)
7388 "Show previous page of selected article.
7389 Argument LINES specifies lines to be scrolled down.
7390 If at the beginning of the article, go to the next article."
7391 (interactive "P")
7392 (gnus-summary-prev-page lines t))
7394 (defun gnus-summary-scroll-up (lines)
7395 "Scroll up (or down) one line current article.
7396 Argument LINES specifies lines to be scrolled up (or down if negative)."
7397 (interactive "p")
7398 (gnus-configure-windows 'article)
7399 (gnus-summary-show-thread)
7400 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7401 (gnus-eval-in-buffer-window gnus-article-buffer
7402 (cond ((> lines 0)
7403 (when (gnus-article-next-page lines)
7404 (gnus-message 3 "End of message")))
7405 ((< lines 0)
7406 (gnus-article-prev-page (- lines))))))
7407 (gnus-summary-recenter)
7408 (gnus-summary-position-point))
7410 (defun gnus-summary-scroll-down (lines)
7411 "Scroll down (or up) one line current article.
7412 Argument LINES specifies lines to be scrolled down (or up if negative)."
7413 (interactive "p")
7414 (gnus-summary-scroll-up (- lines)))
7416 (defun gnus-summary-next-same-subject ()
7417 "Select next article which has the same subject as current one."
7418 (interactive)
7419 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7421 (defun gnus-summary-prev-same-subject ()
7422 "Select previous article which has the same subject as current one."
7423 (interactive)
7424 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7426 (defun gnus-summary-next-unread-same-subject ()
7427 "Select next unread article which has the same subject as current one."
7428 (interactive)
7429 (gnus-summary-next-article t (gnus-summary-article-subject)))
7431 (defun gnus-summary-prev-unread-same-subject ()
7432 "Select previous unread article which has the same subject as current one."
7433 (interactive)
7434 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7436 (defun gnus-summary-first-unread-article ()
7437 "Select the first unread article.
7438 Return nil if there are no unread articles."
7439 (interactive)
7440 (prog1
7441 (when (gnus-summary-first-subject t)
7442 (gnus-summary-show-thread)
7443 (gnus-summary-first-subject t)
7444 (gnus-summary-display-article (gnus-summary-article-number)))
7445 (gnus-summary-position-point)))
7447 (defun gnus-summary-first-unread-subject ()
7448 "Place the point on the subject line of the first unread article.
7449 Return nil if there are no unread articles."
7450 (interactive)
7451 (prog1
7452 (when (gnus-summary-first-subject t)
7453 (gnus-summary-show-thread)
7454 (gnus-summary-first-subject t))
7455 (gnus-summary-position-point)))
7457 (defun gnus-summary-first-unseen-subject ()
7458 "Place the point on the subject line of the first unseen article.
7459 Return nil if there are no unseen articles."
7460 (interactive)
7461 (prog1
7462 (when (gnus-summary-first-subject nil nil t)
7463 (gnus-summary-show-thread)
7464 (gnus-summary-first-subject nil nil t))
7465 (gnus-summary-position-point)))
7467 (defun gnus-summary-first-unseen-or-unread-subject ()
7468 "Place the point on the subject line of the first unseen article or,
7469 if all article have been seen, on the subject line of the first unread
7470 article."
7471 (interactive)
7472 (prog1
7473 (unless (when (gnus-summary-first-subject nil nil t)
7474 (gnus-summary-show-thread)
7475 (gnus-summary-first-subject nil nil t))
7476 (when (gnus-summary-first-subject t)
7477 (gnus-summary-show-thread)
7478 (gnus-summary-first-subject t)))
7479 (gnus-summary-position-point)))
7481 (defun gnus-summary-first-article ()
7482 "Select the first article.
7483 Return nil if there are no articles."
7484 (interactive)
7485 (prog1
7486 (when (gnus-summary-first-subject)
7487 (gnus-summary-show-thread)
7488 (gnus-summary-first-subject)
7489 (gnus-summary-display-article (gnus-summary-article-number)))
7490 (gnus-summary-position-point)))
7492 (defun gnus-summary-best-unread-article (&optional arg)
7493 "Select the unread article with the highest score.
7494 If given a prefix argument, select the next unread article that has a
7495 score higher than the default score."
7496 (interactive "P")
7497 (let ((article (if arg
7498 (gnus-summary-better-unread-subject)
7499 (gnus-summary-best-unread-subject))))
7500 (if article
7501 (gnus-summary-goto-article article)
7502 (error "No unread articles"))))
7504 (defun gnus-summary-best-unread-subject ()
7505 "Select the unread subject with the highest score."
7506 (interactive)
7507 (let ((best -1000000)
7508 (data gnus-newsgroup-data)
7509 article score)
7510 (while data
7511 (and (gnus-data-unread-p (car data))
7512 (> (setq score
7513 (gnus-summary-article-score (gnus-data-number (car data))))
7514 best)
7515 (setq best score
7516 article (gnus-data-number (car data))))
7517 (setq data (cdr data)))
7518 (when article
7519 (gnus-summary-goto-subject article))
7520 (gnus-summary-position-point)
7521 article))
7523 (defun gnus-summary-better-unread-subject ()
7524 "Select the first unread subject that has a score over the default score."
7525 (interactive)
7526 (let ((data gnus-newsgroup-data)
7527 article score)
7528 (while (and (setq article (gnus-data-number (car data)))
7529 (or (gnus-data-read-p (car data))
7530 (not (> (gnus-summary-article-score article)
7531 gnus-summary-default-score))))
7532 (setq data (cdr data)))
7533 (when article
7534 (gnus-summary-goto-subject article))
7535 (gnus-summary-position-point)
7536 article))
7538 (defun gnus-summary-last-subject ()
7539 "Go to the last displayed subject line in the group."
7540 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7541 (when article
7542 (gnus-summary-goto-subject article))))
7544 (defun gnus-summary-goto-article (article &optional all-headers force)
7545 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7546 If ALL-HEADERS is non-nil, no header lines are hidden.
7547 If FORCE, go to the article even if it isn't displayed. If FORCE
7548 is a number, it is the line the article is to be displayed on."
7549 (interactive
7550 (list
7551 (completing-read
7552 "Article number or Message-ID: "
7553 (mapcar (lambda (number) (list (int-to-string number)))
7554 gnus-newsgroup-limit))
7555 current-prefix-arg
7557 (prog1
7558 (if (and (stringp article)
7559 (string-match "@\\|%40" article))
7560 (gnus-summary-refer-article article)
7561 (when (stringp article)
7562 (setq article (string-to-number article)))
7563 (if (gnus-summary-goto-subject article force)
7564 (gnus-summary-display-article article all-headers)
7565 (gnus-message 4 "Couldn't go to article %s" article) nil))
7566 (gnus-summary-position-point)))
7568 (defun gnus-summary-goto-last-article ()
7569 "Go to the previously read article."
7570 (interactive)
7571 (prog1
7572 (when gnus-last-article
7573 (gnus-summary-goto-article gnus-last-article nil t))
7574 (gnus-summary-position-point)))
7576 (defun gnus-summary-pop-article (number)
7577 "Pop one article off the history and go to the previous.
7578 NUMBER articles will be popped off."
7579 (interactive "p")
7580 (let (to)
7581 (setq gnus-newsgroup-history
7582 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7583 (if to
7584 (gnus-summary-goto-article (car to) nil t)
7585 (error "Article history empty")))
7586 (gnus-summary-position-point))
7588 ;; Summary commands and functions for limiting the summary buffer.
7590 (defun gnus-summary-limit-to-articles (n)
7591 "Limit the summary buffer to the next N articles.
7592 If not given a prefix, use the process marked articles instead."
7593 (interactive "P")
7594 (prog1
7595 (let ((articles (gnus-summary-work-articles n)))
7596 (setq gnus-newsgroup-processable nil)
7597 (gnus-summary-limit articles))
7598 (gnus-summary-position-point)))
7600 (defun gnus-summary-pop-limit (&optional total)
7601 "Restore the previous limit.
7602 If given a prefix, remove all limits."
7603 (interactive "P")
7604 (when total
7605 (setq gnus-newsgroup-limits
7606 (list (mapcar (lambda (h) (mail-header-number h))
7607 gnus-newsgroup-headers))))
7608 (unless gnus-newsgroup-limits
7609 (error "No limit to pop"))
7610 (prog1
7611 (gnus-summary-limit nil 'pop)
7612 (gnus-summary-position-point)))
7614 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7615 "Limit the summary buffer to articles that have subjects that match a regexp.
7616 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7617 (interactive
7618 (list (read-string (if current-prefix-arg
7619 "Exclude subject (regexp): "
7620 "Limit to subject (regexp): "))
7621 nil current-prefix-arg))
7622 (unless header
7623 (setq header "subject"))
7624 (when (not (equal "" subject))
7625 (prog1
7626 (let ((articles (gnus-summary-find-matching
7627 (or header "subject") subject 'all nil nil
7628 not-matching)))
7629 (unless articles
7630 (error "Found no matches for \"%s\"" subject))
7631 (gnus-summary-limit articles))
7632 (gnus-summary-position-point))))
7634 (defun gnus-summary-limit-to-author (from &optional not-matching)
7635 "Limit the summary buffer to articles that have authors that match a regexp.
7636 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7637 (interactive
7638 (list (read-string (if current-prefix-arg
7639 "Exclude author (regexp): "
7640 "Limit to author (regexp): "))
7641 current-prefix-arg))
7642 (gnus-summary-limit-to-subject from "from" not-matching))
7644 (defun gnus-summary-limit-to-age (age &optional younger-p)
7645 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7646 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7647 articles that are younger than AGE days."
7648 (interactive
7649 (let ((younger current-prefix-arg)
7650 (days-got nil)
7651 days)
7652 (while (not days-got)
7653 (setq days (if younger
7654 (read-string "Limit to articles younger than (in days, older when negative): ")
7655 (read-string
7656 "Limit to articles older than (in days, younger when negative): ")))
7657 (when (> (length days) 0)
7658 (setq days (read days)))
7659 (if (numberp days)
7660 (progn
7661 (setq days-got t)
7662 (if (< days 0)
7663 (progn
7664 (setq younger (not younger))
7665 (setq days (* days -1)))))
7666 (message "Please enter a number.")
7667 (sleep-for 1)))
7668 (list days younger)))
7669 (prog1
7670 (let ((data gnus-newsgroup-data)
7671 (cutoff (days-to-time age))
7672 articles d date is-younger)
7673 (while (setq d (pop data))
7674 (when (and (vectorp (gnus-data-header d))
7675 (setq date (mail-header-date (gnus-data-header d))))
7676 (setq is-younger (time-less-p
7677 (time-since (condition-case ()
7678 (date-to-time date)
7679 (error '(0 0))))
7680 cutoff))
7681 (when (if younger-p
7682 is-younger
7683 (not is-younger))
7684 (push (gnus-data-number d) articles))))
7685 (gnus-summary-limit (nreverse articles)))
7686 (gnus-summary-position-point)))
7688 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7689 "Limit the summary buffer to articles that match an 'extra' header."
7690 (interactive
7691 (let ((header
7692 (intern
7693 (gnus-completing-read-with-default
7694 (symbol-name (car gnus-extra-headers))
7695 (if current-prefix-arg
7696 "Exclude extra header:"
7697 "Limit extra header:")
7698 (mapcar (lambda (x)
7699 (cons (symbol-name x) x))
7700 gnus-extra-headers)
7702 t))))
7703 (list header
7704 (read-string (format "%s header %s (regexp): "
7705 (if current-prefix-arg "Exclude" "Limit to")
7706 header))
7707 current-prefix-arg)))
7708 (when (not (equal "" regexp))
7709 (prog1
7710 (let ((articles (gnus-summary-find-matching
7711 (cons 'extra header) regexp 'all nil nil
7712 not-matching)))
7713 (unless articles
7714 (error "Found no matches for \"%s\"" regexp))
7715 (gnus-summary-limit articles))
7716 (gnus-summary-position-point))))
7718 (defun gnus-summary-limit-to-display-predicate ()
7719 "Limit the summary buffer to the predicated in the `display' group parameter."
7720 (interactive)
7721 (unless gnus-newsgroup-display
7722 (error "There is no `display' group parameter"))
7723 (let (articles)
7724 (dolist (number gnus-newsgroup-articles)
7725 (when (funcall gnus-newsgroup-display)
7726 (push number articles)))
7727 (gnus-summary-limit articles))
7728 (gnus-summary-position-point))
7730 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7731 (make-obsolete
7732 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7734 (defun gnus-summary-limit-to-unread (&optional all)
7735 "Limit the summary buffer to articles that are not marked as read.
7736 If ALL is non-nil, limit strictly to unread articles."
7737 (interactive "P")
7738 (if all
7739 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7740 (gnus-summary-limit-to-marks
7741 ;; Concat all the marks that say that an article is read and have
7742 ;; those removed.
7743 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7744 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7745 gnus-low-score-mark gnus-expirable-mark
7746 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7747 gnus-duplicate-mark gnus-souped-mark)
7748 'reverse)))
7750 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7751 (make-obsolete 'gnus-summary-delete-marked-with
7752 'gnus-summary-limit-exclude-marks)
7754 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7755 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7756 If REVERSE, limit the summary buffer to articles that are marked
7757 with MARKS. MARKS can either be a string of marks or a list of marks.
7758 Returns how many articles were removed."
7759 (interactive "sMarks: ")
7760 (gnus-summary-limit-to-marks marks t))
7762 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7763 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7764 If REVERSE (the prefix), limit the summary buffer to articles that are
7765 not marked with MARKS. MARKS can either be a string of marks or a
7766 list of marks.
7767 Returns how many articles were removed."
7768 (interactive "sMarks: \nP")
7769 (prog1
7770 (let ((data gnus-newsgroup-data)
7771 (marks (if (listp marks) marks
7772 (append marks nil))) ; Transform to list.
7773 articles)
7774 (while data
7775 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7776 (memq (gnus-data-mark (car data)) marks))
7777 (push (gnus-data-number (car data)) articles))
7778 (setq data (cdr data)))
7779 (gnus-summary-limit articles))
7780 (gnus-summary-position-point)))
7782 (defun gnus-summary-limit-to-score (score)
7783 "Limit to articles with score at or above SCORE."
7784 (interactive "NLimit to articles with score of at least: ")
7785 (let ((data gnus-newsgroup-data)
7786 articles)
7787 (while data
7788 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7789 score)
7790 (push (gnus-data-number (car data)) articles))
7791 (setq data (cdr data)))
7792 (prog1
7793 (gnus-summary-limit articles)
7794 (gnus-summary-position-point))))
7796 (defun gnus-summary-limit-to-unseen ()
7797 "Limit to unseen articles."
7798 (interactive)
7799 (prog1
7800 (gnus-summary-limit gnus-newsgroup-unseen)
7801 (gnus-summary-position-point)))
7803 (defun gnus-summary-limit-include-thread (id)
7804 "Display all the hidden articles that is in the thread with ID in it.
7805 When called interactively, ID is the Message-ID of the current
7806 article."
7807 (interactive (list (mail-header-id (gnus-summary-article-header))))
7808 (let ((articles (gnus-articles-in-thread
7809 (gnus-id-to-thread (gnus-root-id id)))))
7810 (prog1
7811 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7812 (gnus-summary-limit-include-matching-articles
7813 "subject"
7814 (regexp-quote (gnus-simplify-subject-re
7815 (mail-header-subject (gnus-id-to-header id)))))
7816 (gnus-summary-position-point))))
7818 (defun gnus-summary-limit-include-matching-articles (header regexp)
7819 "Display all the hidden articles that have HEADERs that match REGEXP."
7820 (interactive (list (read-string "Match on header: ")
7821 (read-string "Regexp: ")))
7822 (let ((articles (gnus-find-matching-articles header regexp)))
7823 (prog1
7824 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7825 (gnus-summary-position-point))))
7827 (defun gnus-summary-insert-dormant-articles ()
7828 "Insert all the dormant articles for this group into the current buffer."
7829 (interactive)
7830 (let ((gnus-verbose (max 6 gnus-verbose)))
7831 (if (not gnus-newsgroup-dormant)
7832 (gnus-message 3 "No cached articles for this group")
7833 (gnus-summary-goto-subjects gnus-newsgroup-dormant))))
7835 (defun gnus-summary-limit-include-dormant ()
7836 "Display all the hidden articles that are marked as dormant.
7837 Note that this command only works on a subset of the articles currently
7838 fetched for this group."
7839 (interactive)
7840 (unless gnus-newsgroup-dormant
7841 (error "There are no dormant articles in this group"))
7842 (prog1
7843 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7844 (gnus-summary-position-point)))
7846 (defun gnus-summary-limit-exclude-dormant ()
7847 "Hide all dormant articles."
7848 (interactive)
7849 (prog1
7850 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7851 (gnus-summary-position-point)))
7853 (defun gnus-summary-limit-exclude-childless-dormant ()
7854 "Hide all dormant articles that have no children."
7855 (interactive)
7856 (let ((data (gnus-data-list t))
7857 articles d children)
7858 ;; Find all articles that are either not dormant or have
7859 ;; children.
7860 (while (setq d (pop data))
7861 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7862 (and (setq children
7863 (gnus-article-children (gnus-data-number d)))
7864 (let (found)
7865 (while children
7866 (when (memq (car children) articles)
7867 (setq children nil
7868 found t))
7869 (pop children))
7870 found)))
7871 (push (gnus-data-number d) articles)))
7872 ;; Do the limiting.
7873 (prog1
7874 (gnus-summary-limit articles)
7875 (gnus-summary-position-point))))
7877 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7878 "Mark all unread excluded articles as read.
7879 If ALL, mark even excluded ticked and dormants as read."
7880 (interactive "P")
7881 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7882 (let ((articles (gnus-sorted-ndifference
7883 (sort
7884 (mapcar (lambda (h) (mail-header-number h))
7885 gnus-newsgroup-headers)
7887 gnus-newsgroup-limit))
7888 article)
7889 (setq gnus-newsgroup-unreads
7890 (gnus-sorted-intersection gnus-newsgroup-unreads
7891 gnus-newsgroup-limit))
7892 (if all
7893 (setq gnus-newsgroup-dormant nil
7894 gnus-newsgroup-marked nil
7895 gnus-newsgroup-reads
7896 (nconc
7897 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7898 gnus-newsgroup-reads))
7899 (while (setq article (pop articles))
7900 (unless (or (memq article gnus-newsgroup-dormant)
7901 (memq article gnus-newsgroup-marked))
7902 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7904 (defun gnus-summary-limit (articles &optional pop)
7905 (if pop
7906 ;; We pop the previous limit off the stack and use that.
7907 (setq articles (car gnus-newsgroup-limits)
7908 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7909 ;; We use the new limit, so we push the old limit on the stack.
7910 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7911 ;; Set the limit.
7912 (setq gnus-newsgroup-limit articles)
7913 (let ((total (length gnus-newsgroup-data))
7914 (data (gnus-data-find-list (gnus-summary-article-number)))
7915 (gnus-summary-mark-below nil) ; Inhibit this.
7916 found)
7917 ;; This will do all the work of generating the new summary buffer
7918 ;; according to the new limit.
7919 (gnus-summary-prepare)
7920 ;; Hide any threads, possibly.
7921 (gnus-summary-maybe-hide-threads)
7922 ;; Try to return to the article you were at, or one in the
7923 ;; neighborhood.
7924 (when data
7925 ;; We try to find some article after the current one.
7926 (while data
7927 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7928 (setq data nil
7929 found t))
7930 (setq data (cdr data))))
7931 (unless found
7932 ;; If there is no data, that means that we were after the last
7933 ;; article. The same goes when we can't find any articles
7934 ;; after the current one.
7935 (goto-char (point-max))
7936 (gnus-summary-find-prev))
7937 (gnus-set-mode-line 'summary)
7938 ;; We return how many articles were removed from the summary
7939 ;; buffer as a result of the new limit.
7940 (- total (length gnus-newsgroup-data))))
7942 (defsubst gnus-invisible-cut-children (threads)
7943 (let ((num 0))
7944 (while threads
7945 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7946 (incf num))
7947 (pop threads))
7948 (< num 2)))
7950 (defsubst gnus-cut-thread (thread)
7951 "Go forwards in the thread until we find an article that we want to display."
7952 (when (or (eq gnus-fetch-old-headers 'some)
7953 (eq gnus-fetch-old-headers 'invisible)
7954 (numberp gnus-fetch-old-headers)
7955 (eq gnus-build-sparse-threads 'some)
7956 (eq gnus-build-sparse-threads 'more))
7957 ;; Deal with old-fetched headers and sparse threads.
7958 (while (and
7959 thread
7961 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7962 (gnus-summary-article-ancient-p
7963 (mail-header-number (car thread))))
7964 (if (or (<= (length (cdr thread)) 1)
7965 (eq gnus-fetch-old-headers 'invisible))
7966 (setq gnus-newsgroup-limit
7967 (delq (mail-header-number (car thread))
7968 gnus-newsgroup-limit)
7969 thread (cadr thread))
7970 (when (gnus-invisible-cut-children (cdr thread))
7971 (let ((th (cdr thread)))
7972 (while th
7973 (if (memq (mail-header-number (caar th))
7974 gnus-newsgroup-limit)
7975 (setq thread (car th)
7976 th nil)
7977 (setq th (cdr th))))))))))
7978 thread)
7980 (defun gnus-cut-threads (threads)
7981 "Cut off all uninteresting articles from the beginning of THREADS."
7982 (when (or (eq gnus-fetch-old-headers 'some)
7983 (eq gnus-fetch-old-headers 'invisible)
7984 (numberp gnus-fetch-old-headers)
7985 (eq gnus-build-sparse-threads 'some)
7986 (eq gnus-build-sparse-threads 'more))
7987 (let ((th threads))
7988 (while th
7989 (setcar th (gnus-cut-thread (car th)))
7990 (setq th (cdr th)))))
7991 ;; Remove nixed out threads.
7992 (delq nil threads))
7994 (defun gnus-summary-initial-limit (&optional show-if-empty)
7995 "Figure out what the initial limit is supposed to be on group entry.
7996 This entails weeding out unwanted dormants, low-scored articles,
7997 fetch-old-headers verbiage, and so on."
7998 ;; Most groups have nothing to remove.
7999 (if (or gnus-inhibit-limiting
8000 (and (null gnus-newsgroup-dormant)
8001 (eq gnus-newsgroup-display 'gnus-not-ignore)
8002 (not (eq gnus-fetch-old-headers 'some))
8003 (not (numberp gnus-fetch-old-headers))
8004 (not (eq gnus-fetch-old-headers 'invisible))
8005 (null gnus-summary-expunge-below)
8006 (not (eq gnus-build-sparse-threads 'some))
8007 (not (eq gnus-build-sparse-threads 'more))
8008 (null gnus-thread-expunge-below)
8009 (not gnus-use-nocem)))
8010 () ; Do nothing.
8011 (push gnus-newsgroup-limit gnus-newsgroup-limits)
8012 (setq gnus-newsgroup-limit nil)
8013 (mapatoms
8014 (lambda (node)
8015 (unless (car (symbol-value node))
8016 ;; These threads have no parents -- they are roots.
8017 (let ((nodes (cdr (symbol-value node)))
8018 thread)
8019 (while nodes
8020 (if (and gnus-thread-expunge-below
8021 (< (gnus-thread-total-score (car nodes))
8022 gnus-thread-expunge-below))
8023 (gnus-expunge-thread (pop nodes))
8024 (setq thread (pop nodes))
8025 (gnus-summary-limit-children thread))))))
8026 gnus-newsgroup-dependencies)
8027 ;; If this limitation resulted in an empty group, we might
8028 ;; pop the previous limit and use it instead.
8029 (when (and (not gnus-newsgroup-limit)
8030 show-if-empty)
8031 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
8032 gnus-newsgroup-limit))
8034 (defun gnus-summary-limit-children (thread)
8035 "Return 1 if this subthread is visible and 0 if it is not."
8036 ;; First we get the number of visible children to this thread. This
8037 ;; is done by recursing down the thread using this function, so this
8038 ;; will really go down to a leaf article first, before slowly
8039 ;; working its way up towards the root.
8040 (when thread
8041 (let* ((max-lisp-eval-depth 5000)
8042 (children
8043 (if (cdr thread)
8044 (apply '+ (mapcar 'gnus-summary-limit-children
8045 (cdr thread)))
8047 (number (mail-header-number (car thread)))
8048 score)
8049 (if (and
8050 (not (memq number gnus-newsgroup-marked))
8052 ;; If this article is dormant and has absolutely no visible
8053 ;; children, then this article isn't visible.
8054 (and (memq number gnus-newsgroup-dormant)
8055 (zerop children))
8056 ;; If this is "fetch-old-headered" and there is no
8057 ;; visible children, then we don't want this article.
8058 (and (or (eq gnus-fetch-old-headers 'some)
8059 (numberp gnus-fetch-old-headers))
8060 (gnus-summary-article-ancient-p number)
8061 (zerop children))
8062 ;; If this is "fetch-old-headered" and `invisible', then
8063 ;; we don't want this article.
8064 (and (eq gnus-fetch-old-headers 'invisible)
8065 (gnus-summary-article-ancient-p number))
8066 ;; If this is a sparsely inserted article with no children,
8067 ;; we don't want it.
8068 (and (eq gnus-build-sparse-threads 'some)
8069 (gnus-summary-article-sparse-p number)
8070 (zerop children))
8071 ;; If we use expunging, and this article is really
8072 ;; low-scored, then we don't want this article.
8073 (when (and gnus-summary-expunge-below
8074 (< (setq score
8075 (or (cdr (assq number gnus-newsgroup-scored))
8076 gnus-summary-default-score))
8077 gnus-summary-expunge-below))
8078 ;; We increase the expunge-tally here, but that has
8079 ;; nothing to do with the limits, really.
8080 (incf gnus-newsgroup-expunged-tally)
8081 ;; We also mark as read here, if that's wanted.
8082 (when (and gnus-summary-mark-below
8083 (< score gnus-summary-mark-below))
8084 (setq gnus-newsgroup-unreads
8085 (delq number gnus-newsgroup-unreads))
8086 (if gnus-newsgroup-auto-expire
8087 (push number gnus-newsgroup-expirable)
8088 (push (cons number gnus-low-score-mark)
8089 gnus-newsgroup-reads)))
8091 ;; Do the `display' group parameter.
8092 (and gnus-newsgroup-display
8093 (not (funcall gnus-newsgroup-display)))
8094 ;; Check NoCeM things.
8095 (if (and gnus-use-nocem
8096 (gnus-nocem-unwanted-article-p
8097 (mail-header-id (car thread))))
8098 (progn
8099 (setq gnus-newsgroup-unreads
8100 (delq number gnus-newsgroup-unreads))
8101 t))))
8102 ;; Nope, invisible article.
8104 ;; Ok, this article is to be visible, so we add it to the limit
8105 ;; and return 1.
8106 (push number gnus-newsgroup-limit)
8107 1))))
8109 (defun gnus-expunge-thread (thread)
8110 "Mark all articles in THREAD as read."
8111 (let* ((number (mail-header-number (car thread))))
8112 (incf gnus-newsgroup-expunged-tally)
8113 ;; We also mark as read here, if that's wanted.
8114 (setq gnus-newsgroup-unreads
8115 (delq number gnus-newsgroup-unreads))
8116 (if gnus-newsgroup-auto-expire
8117 (push number gnus-newsgroup-expirable)
8118 (push (cons number gnus-low-score-mark)
8119 gnus-newsgroup-reads)))
8120 ;; Go recursively through all subthreads.
8121 (mapcar 'gnus-expunge-thread (cdr thread)))
8123 ;; Summary article oriented commands
8125 (defun gnus-summary-refer-parent-article (n)
8126 "Refer parent article N times.
8127 If N is negative, go to ancestor -N instead.
8128 The difference between N and the number of articles fetched is returned."
8129 (interactive "p")
8130 (let ((skip 1)
8131 error header ref)
8132 (when (not (natnump n))
8133 (setq skip (abs n)
8134 n 1))
8135 (while (and (> n 0)
8136 (not error))
8137 (setq header (gnus-summary-article-header))
8138 (if (and (eq (mail-header-number header)
8139 (cdr gnus-article-current))
8140 (equal gnus-newsgroup-name
8141 (car gnus-article-current)))
8142 ;; If we try to find the parent of the currently
8143 ;; displayed article, then we take a look at the actual
8144 ;; References header, since this is slightly more
8145 ;; reliable than the References field we got from the
8146 ;; server.
8147 (save-excursion
8148 (set-buffer gnus-original-article-buffer)
8149 (nnheader-narrow-to-headers)
8150 (unless (setq ref (message-fetch-field "references"))
8151 (when (setq ref (message-fetch-field "in-reply-to"))
8152 (setq ref (gnus-extract-message-id-from-in-reply-to ref))))
8153 (widen))
8154 (setq ref
8155 ;; It's not the current article, so we take a bet on
8156 ;; the value we got from the server.
8157 (mail-header-references header)))
8158 (if (and ref
8159 (not (equal ref "")))
8160 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
8161 (gnus-message 1 "Couldn't find parent"))
8162 (gnus-message 1 "No references in article %d"
8163 (gnus-summary-article-number))
8164 (setq error t))
8165 (decf n))
8166 (gnus-summary-position-point)
8169 (defun gnus-summary-refer-references ()
8170 "Fetch all articles mentioned in the References header.
8171 Return the number of articles fetched."
8172 (interactive)
8173 (let ((ref (mail-header-references (gnus-summary-article-header)))
8174 (current (gnus-summary-article-number))
8175 (n 0))
8176 (if (or (not ref)
8177 (equal ref ""))
8178 (error "No References in the current article")
8179 ;; For each Message-ID in the References header...
8180 (while (string-match "<[^>]*>" ref)
8181 (incf n)
8182 ;; ... fetch that article.
8183 (gnus-summary-refer-article
8184 (prog1 (match-string 0 ref)
8185 (setq ref (substring ref (match-end 0))))))
8186 (gnus-summary-goto-subject current)
8187 (gnus-summary-position-point)
8188 n)))
8190 (defun gnus-summary-refer-thread (&optional limit)
8191 "Fetch all articles in the current thread.
8192 If LIMIT (the numerical prefix), fetch that many old headers instead
8193 of what's specified by the `gnus-refer-thread-limit' variable."
8194 (interactive "P")
8195 (let ((id (mail-header-id (gnus-summary-article-header)))
8196 (limit (if limit (prefix-numeric-value limit)
8197 gnus-refer-thread-limit)))
8198 (unless (eq gnus-fetch-old-headers 'invisible)
8199 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
8200 ;; Retrieve the headers and read them in.
8201 (if (eq (if (numberp limit)
8202 (gnus-retrieve-headers
8203 (list (min
8204 (+ (mail-header-number
8205 (gnus-summary-article-header))
8206 limit)
8207 gnus-newsgroup-end))
8208 gnus-newsgroup-name (* limit 2))
8209 ;; gnus-refer-thread-limit is t, i.e. fetch _all_
8210 ;; headers.
8211 (gnus-retrieve-headers (list gnus-newsgroup-end)
8212 gnus-newsgroup-name limit))
8213 'nov)
8214 (gnus-build-all-threads)
8215 (error "Can't fetch thread from back ends that don't support NOV"))
8216 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
8217 (gnus-summary-limit-include-thread id)))
8219 (defun gnus-summary-refer-article (message-id)
8220 "Fetch an article specified by MESSAGE-ID."
8221 (interactive "sMessage-ID: ")
8222 (when (and (stringp message-id)
8223 (not (zerop (length message-id))))
8224 (setq message-id (gnus-replace-in-string message-id " " ""))
8225 ;; Construct the correct Message-ID if necessary.
8226 ;; Suggested by tale@pawl.rpi.edu.
8227 (unless (string-match "^<" message-id)
8228 (setq message-id (concat "<" message-id)))
8229 (unless (string-match ">$" message-id)
8230 (setq message-id (concat message-id ">")))
8231 ;; People often post MIDs from URLs, so unhex it:
8232 (unless (string-match "@" message-id)
8233 (setq message-id (gnus-url-unhex-string message-id)))
8234 (let* ((header (gnus-id-to-header message-id))
8235 (sparse (and header
8236 (gnus-summary-article-sparse-p
8237 (mail-header-number header))
8238 (memq (mail-header-number header)
8239 gnus-newsgroup-limit)))
8240 number)
8241 (cond
8242 ;; If the article is present in the buffer we just go to it.
8243 ((and header
8244 (or (not (gnus-summary-article-sparse-p
8245 (mail-header-number header)))
8246 sparse))
8247 (prog1
8248 (gnus-summary-goto-article
8249 (mail-header-number header) nil t)
8250 (when sparse
8251 (gnus-summary-update-article (mail-header-number header)))))
8253 ;; We fetch the article.
8254 (catch 'found
8255 (dolist (gnus-override-method (gnus-refer-article-methods))
8256 (when (and (gnus-check-server gnus-override-method)
8257 ;; Fetch the header,
8258 (setq number (gnus-summary-insert-subject message-id)))
8259 ;; and display the article.
8260 (gnus-summary-select-article nil nil nil number)
8261 (throw 'found t)))
8262 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
8264 (defun gnus-refer-article-methods ()
8265 "Return a list of referable methods."
8266 (cond
8267 ;; No method, so we default to current and native.
8268 ((null gnus-refer-article-method)
8269 (list gnus-current-select-method gnus-select-method))
8270 ;; Current.
8271 ((eq 'current gnus-refer-article-method)
8272 (list gnus-current-select-method))
8273 ;; List of select methods.
8274 ((not (and (symbolp (car gnus-refer-article-method))
8275 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
8276 (let (out)
8277 (dolist (method gnus-refer-article-method)
8278 (push (if (eq 'current method)
8279 gnus-current-select-method
8280 method)
8281 out))
8282 (nreverse out)))
8283 ;; One single select method.
8285 (list gnus-refer-article-method))))
8287 (defun gnus-summary-edit-parameters ()
8288 "Edit the group parameters of the current group."
8289 (interactive)
8290 (gnus-group-edit-group gnus-newsgroup-name 'params))
8292 (defun gnus-summary-customize-parameters ()
8293 "Customize the group parameters of the current group."
8294 (interactive)
8295 (gnus-group-customize gnus-newsgroup-name))
8297 (defun gnus-summary-enter-digest-group (&optional force)
8298 "Enter an nndoc group based on the current article.
8299 If FORCE, force a digest interpretation. If not, try
8300 to guess what the document format is."
8301 (interactive "P")
8302 (let ((conf gnus-current-window-configuration))
8303 (save-window-excursion
8304 (save-excursion
8305 (let (gnus-article-prepare-hook
8306 gnus-display-mime-function
8307 gnus-break-pages)
8308 (gnus-summary-select-article))))
8309 (setq gnus-current-window-configuration conf)
8310 (let* ((name (format "%s-%d"
8311 (gnus-group-prefixed-name
8312 gnus-newsgroup-name (list 'nndoc ""))
8313 (save-excursion
8314 (set-buffer gnus-summary-buffer)
8315 gnus-current-article)))
8316 (ogroup gnus-newsgroup-name)
8317 (params (append (gnus-info-params (gnus-get-info ogroup))
8318 (list (cons 'to-group ogroup))
8319 (list (cons 'parent-group ogroup))
8320 (list (cons 'save-article-group ogroup))))
8321 (case-fold-search t)
8322 (buf (current-buffer))
8323 dig to-address)
8324 (save-excursion
8325 (set-buffer gnus-original-article-buffer)
8326 ;; Have the digest group inherit the main mail address of
8327 ;; the parent article.
8328 (when (setq to-address (or (gnus-fetch-field "reply-to")
8329 (gnus-fetch-field "from")))
8330 (setq params (append
8331 (list (cons 'to-address
8332 (funcall gnus-decode-encoded-word-function
8333 to-address))))))
8334 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
8335 (insert-buffer-substring gnus-original-article-buffer)
8336 ;; Remove lines that may lead nndoc to misinterpret the
8337 ;; document type.
8338 (narrow-to-region
8339 (goto-char (point-min))
8340 (or (search-forward "\n\n" nil t) (point)))
8341 (goto-char (point-min))
8342 (delete-matching-lines "^Path:\\|^From ")
8343 (widen))
8344 (unwind-protect
8345 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8346 (gnus-newsgroup-ephemeral-ignored-charsets
8347 gnus-newsgroup-ignored-charsets))
8348 (gnus-group-read-ephemeral-group
8349 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8350 (nndoc-article-type
8351 ,(if force 'mbox 'guess)))
8352 t nil nil nil
8353 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8354 "ADAPT")))))
8355 ;; Make all postings to this group go to the parent group.
8356 (nconc (gnus-info-params (gnus-get-info name))
8357 params)
8358 ;; Couldn't select this doc group.
8359 (switch-to-buffer buf)
8360 (gnus-set-global-variables)
8361 (gnus-configure-windows 'summary)
8362 (gnus-message 3 "Article couldn't be entered?"))
8363 (kill-buffer dig)))))
8365 (defun gnus-summary-read-document (n)
8366 "Open a new group based on the current article(s).
8367 This will allow you to read digests and other similar
8368 documents as newsgroups.
8369 Obeys the standard process/prefix convention."
8370 (interactive "P")
8371 (let* ((articles (gnus-summary-work-articles n))
8372 (ogroup gnus-newsgroup-name)
8373 (params (append (gnus-info-params (gnus-get-info ogroup))
8374 (list (cons 'to-group ogroup))))
8375 article group egroup groups vgroup)
8376 (while (setq article (pop articles))
8377 (setq group (format "%s-%d" gnus-newsgroup-name article))
8378 (gnus-summary-remove-process-mark article)
8379 (when (gnus-summary-display-article article)
8380 (save-excursion
8381 (with-temp-buffer
8382 (insert-buffer-substring gnus-original-article-buffer)
8383 ;; Remove some headers that may lead nndoc to make
8384 ;; the wrong guess.
8385 (message-narrow-to-head)
8386 (goto-char (point-min))
8387 (delete-matching-lines "^\\(Path\\):\\|^From ")
8388 (widen)
8389 (if (setq egroup
8390 (gnus-group-read-ephemeral-group
8391 group `(nndoc ,group (nndoc-address ,(current-buffer))
8392 (nndoc-article-type guess))
8393 t nil t))
8394 (progn
8395 ;; Make all postings to this group go to the parent group.
8396 (nconc (gnus-info-params (gnus-get-info egroup))
8397 params)
8398 (push egroup groups))
8399 ;; Couldn't select this doc group.
8400 (gnus-error 3 "Article couldn't be entered"))))))
8401 ;; Now we have selected all the documents.
8402 (cond
8403 ((not groups)
8404 (error "None of the articles could be interpreted as documents"))
8405 ((gnus-group-read-ephemeral-group
8406 (setq vgroup (format
8407 "nnvirtual:%s-%s" gnus-newsgroup-name
8408 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8409 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8411 (cons (current-buffer) 'summary)))
8413 (error "Couldn't select virtual nndoc group")))))
8415 (defun gnus-summary-isearch-article (&optional regexp-p)
8416 "Do incremental search forward on the current article.
8417 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8418 (interactive "P")
8419 (gnus-summary-select-article)
8420 (gnus-configure-windows 'article)
8421 (gnus-eval-in-buffer-window gnus-article-buffer
8422 (save-restriction
8423 (widen)
8424 (isearch-forward regexp-p))))
8426 (defun gnus-summary-search-article-forward (regexp &optional backward)
8427 "Search for an article containing REGEXP forward.
8428 If BACKWARD, search backward instead."
8429 (interactive
8430 (list (read-string
8431 (format "Search article %s (regexp%s): "
8432 (if current-prefix-arg "backward" "forward")
8433 (if gnus-last-search-regexp
8434 (concat ", default " gnus-last-search-regexp)
8435 "")))
8436 current-prefix-arg))
8437 (if (string-equal regexp "")
8438 (setq regexp (or gnus-last-search-regexp ""))
8439 (setq gnus-last-search-regexp regexp)
8440 (setq gnus-article-before-search gnus-current-article))
8441 ;; Intentionally set gnus-last-article.
8442 (setq gnus-last-article gnus-article-before-search)
8443 (let ((gnus-last-article gnus-last-article))
8444 (if (gnus-summary-search-article regexp backward)
8445 (gnus-summary-show-thread)
8446 (signal 'search-failed (list regexp)))))
8448 (defun gnus-summary-search-article-backward (regexp)
8449 "Search for an article containing REGEXP backward."
8450 (interactive
8451 (list (read-string
8452 (format "Search article backward (regexp%s): "
8453 (if gnus-last-search-regexp
8454 (concat ", default " gnus-last-search-regexp)
8455 "")))))
8456 (gnus-summary-search-article-forward regexp 'backward))
8458 (defun gnus-summary-search-article (regexp &optional backward)
8459 "Search for an article containing REGEXP.
8460 Optional argument BACKWARD means do search for backward.
8461 `gnus-select-article-hook' is not called during the search."
8462 ;; We have to require this here to make sure that the following
8463 ;; dynamic binding isn't shadowed by autoloading.
8464 (require 'gnus-async)
8465 (require 'gnus-art)
8466 (let ((gnus-select-article-hook nil) ;Disable hook.
8467 (gnus-article-prepare-hook nil)
8468 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8469 (gnus-use-article-prefetch nil)
8470 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8471 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8472 (gnus-visual nil)
8473 (gnus-keep-backlog nil)
8474 (gnus-break-pages nil)
8475 (gnus-summary-display-arrow nil)
8476 (gnus-updated-mode-lines nil)
8477 (gnus-auto-center-summary nil)
8478 (sum (current-buffer))
8479 (gnus-display-mime-function nil)
8480 (found nil)
8481 point)
8482 (gnus-save-hidden-threads
8483 (gnus-summary-select-article)
8484 (set-buffer gnus-article-buffer)
8485 (goto-char (window-point (get-buffer-window (current-buffer))))
8486 (when backward
8487 (forward-line -1))
8488 (while (not found)
8489 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8490 (if (if backward
8491 (re-search-backward regexp nil t)
8492 (re-search-forward regexp nil t))
8493 ;; We found the regexp.
8494 (progn
8495 (setq found 'found)
8496 (beginning-of-line)
8497 (set-window-start
8498 (get-buffer-window (current-buffer))
8499 (point))
8500 (forward-line 1)
8501 (set-window-point
8502 (get-buffer-window (current-buffer))
8503 (point))
8504 (set-buffer sum)
8505 (setq point (point)))
8506 ;; We didn't find it, so we go to the next article.
8507 (set-buffer sum)
8508 (setq found 'not)
8509 (while (eq found 'not)
8510 (if (not (if backward (gnus-summary-find-prev)
8511 (gnus-summary-find-next)))
8512 ;; No more articles.
8513 (setq found t)
8514 ;; Select the next article and adjust point.
8515 (unless (gnus-summary-article-sparse-p
8516 (gnus-summary-article-number))
8517 (setq found nil)
8518 (gnus-summary-select-article)
8519 (set-buffer gnus-article-buffer)
8520 (widen)
8521 (goto-char (if backward (point-max) (point-min))))))))
8522 (gnus-message 7 ""))
8523 ;; Return whether we found the regexp.
8524 (when (eq found 'found)
8525 (goto-char point)
8526 (gnus-summary-show-thread)
8527 (gnus-summary-goto-subject gnus-current-article)
8528 (gnus-summary-position-point)
8529 t)))
8531 (defun gnus-find-matching-articles (header regexp)
8532 "Return a list of all articles that match REGEXP on HEADER.
8533 This search includes all articles in the current group that Gnus has
8534 fetched headers for, whether they are displayed or not."
8535 (let ((articles nil)
8536 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8537 (case-fold-search t))
8538 (dolist (header gnus-newsgroup-headers)
8539 (when (string-match regexp (funcall func header))
8540 (push (mail-header-number header) articles)))
8541 (nreverse articles)))
8543 (defun gnus-summary-find-matching (header regexp &optional backward unread
8544 not-case-fold not-matching)
8545 "Return a list of all articles that match REGEXP on HEADER.
8546 The search stars on the current article and goes forwards unless
8547 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8548 If UNREAD is non-nil, only unread articles will
8549 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8550 in the comparisons. If NOT-MATCHING, return a list of all articles that
8551 not match REGEXP on HEADER."
8552 (let ((case-fold-search (not not-case-fold))
8553 articles d func)
8554 (if (consp header)
8555 (if (eq (car header) 'extra)
8556 (setq func
8557 `(lambda (h)
8558 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8559 "")))
8560 (error "%s is an invalid header" header))
8561 (unless (fboundp (intern (concat "mail-header-" header)))
8562 (error "%s is not a valid header" header))
8563 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8564 (dolist (d (if (eq backward 'all)
8565 gnus-newsgroup-data
8566 (gnus-data-find-list
8567 (gnus-summary-article-number)
8568 (gnus-data-list backward))))
8569 (when (and (or (not unread) ; We want all articles...
8570 (gnus-data-unread-p d)) ; Or just unreads.
8571 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8572 (if not-matching
8573 (not (string-match
8574 regexp
8575 (funcall func (gnus-data-header d))))
8576 (string-match regexp
8577 (funcall func (gnus-data-header d)))))
8578 (push (gnus-data-number d) articles))) ; Success!
8579 (nreverse articles)))
8581 (defun gnus-summary-execute-command (header regexp command &optional backward)
8582 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8583 If HEADER is an empty string (or nil), the match is done on the entire
8584 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8585 (interactive
8586 (list (let ((completion-ignore-case t))
8587 (completing-read
8588 "Header name: "
8589 (mapcar (lambda (header) (list (format "%s" header)))
8590 (append
8591 '("Number" "Subject" "From" "Lines" "Date"
8592 "Message-ID" "Xref" "References" "Body")
8593 gnus-extra-headers))
8594 nil 'require-match))
8595 (read-string "Regexp: ")
8596 (read-key-sequence "Command: ")
8597 current-prefix-arg))
8598 (when (equal header "Body")
8599 (setq header ""))
8600 ;; Hidden thread subtrees must be searched as well.
8601 (gnus-summary-show-all-threads)
8602 ;; We don't want to change current point nor window configuration.
8603 (save-excursion
8604 (save-window-excursion
8605 (let (gnus-visual
8606 gnus-treat-strip-trailing-blank-lines
8607 gnus-treat-strip-leading-blank-lines
8608 gnus-treat-strip-multiple-blank-lines
8609 gnus-treat-hide-boring-headers
8610 gnus-treat-fold-newsgroups
8611 gnus-article-prepare-hook)
8612 (gnus-message 6 "Executing %s..." (key-description command))
8613 ;; We'd like to execute COMMAND interactively so as to give arguments.
8614 (gnus-execute header regexp
8615 `(call-interactively ',(key-binding command))
8616 backward)
8617 (gnus-message 6 "Executing %s...done" (key-description command))))))
8619 (defun gnus-summary-beginning-of-article ()
8620 "Scroll the article back to the beginning."
8621 (interactive)
8622 (gnus-summary-select-article)
8623 (gnus-configure-windows 'article)
8624 (gnus-eval-in-buffer-window gnus-article-buffer
8625 (widen)
8626 (goto-char (point-min))
8627 (when gnus-break-pages
8628 (gnus-narrow-to-page))))
8630 (defun gnus-summary-end-of-article ()
8631 "Scroll to the end of the article."
8632 (interactive)
8633 (gnus-summary-select-article)
8634 (gnus-configure-windows 'article)
8635 (gnus-eval-in-buffer-window gnus-article-buffer
8636 (widen)
8637 (goto-char (point-max))
8638 (recenter -3)
8639 (when gnus-break-pages
8640 (when (re-search-backward page-delimiter nil t)
8641 (narrow-to-region (match-end 0) (point-max)))
8642 (gnus-narrow-to-page))))
8644 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8645 "Truncate to LEN and quote all \"(\"'s in STRING."
8646 (gnus-replace-in-string (if (and len (> (length string) len))
8647 (substring string 0 len)
8648 string)
8649 "[()]" "\\\\\\&"))
8651 (defun gnus-summary-print-article (&optional filename n)
8652 "Generate and print a PostScript image of the process-marked (mail) articles.
8654 If used interactively, print the current article if none are
8655 process-marked. With prefix arg, prompt the user for the name of the
8656 file to save in.
8658 When used from Lisp, accept two optional args FILENAME and N. N means
8659 to print the next N articles. If N is negative, print the N previous
8660 articles. If N is nil and articles have been marked with the process
8661 mark, print these instead.
8663 If the optional first argument FILENAME is nil, send the image to the
8664 printer. If FILENAME is a string, save the PostScript image in a file with
8665 that name. If FILENAME is a number, prompt the user for the name of the file
8666 to save in."
8667 (interactive (list (ps-print-preprint current-prefix-arg)))
8668 (dolist (article (gnus-summary-work-articles n))
8669 (gnus-summary-select-article nil nil 'pseudo article)
8670 (gnus-eval-in-buffer-window gnus-article-buffer
8671 (gnus-print-buffer))
8672 (gnus-summary-remove-process-mark article))
8673 (ps-despool filename))
8675 (defun gnus-print-buffer ()
8676 (let ((buffer (generate-new-buffer " *print*")))
8677 (unwind-protect
8678 (progn
8679 (copy-to-buffer buffer (point-min) (point-max))
8680 (set-buffer buffer)
8681 (gnus-remove-text-with-property 'gnus-decoration)
8682 (when (gnus-visual-p 'article-highlight 'highlight)
8683 ;; Copy-to-buffer doesn't copy overlay. So redo
8684 ;; highlight.
8685 (let ((gnus-article-buffer buffer))
8686 (gnus-article-highlight-citation t)
8687 (gnus-article-highlight-signature)
8688 (gnus-article-emphasize)
8689 (gnus-article-delete-invisible-text)))
8690 (let ((ps-left-header
8691 (list
8692 (concat "("
8693 (gnus-summary-print-truncate-and-quote
8694 (mail-header-subject gnus-current-headers)
8695 66) ")")
8696 (concat "("
8697 (gnus-summary-print-truncate-and-quote
8698 (mail-header-from gnus-current-headers)
8699 45) ")")))
8700 (ps-right-header
8701 (list
8702 "/pagenumberstring load"
8703 (concat "("
8704 (mail-header-date gnus-current-headers) ")"))))
8705 (gnus-run-hooks 'gnus-ps-print-hook)
8706 (save-excursion
8707 (if window-system
8708 (ps-spool-buffer-with-faces)
8709 (ps-spool-buffer)))))
8710 (kill-buffer buffer))))
8712 (defun gnus-summary-show-article (&optional arg)
8713 "Force redisplaying of the current article.
8714 If ARG (the prefix) is a number, show the article with the charset
8715 defined in `gnus-summary-show-article-charset-alist', or the charset
8716 input.
8717 If ARG (the prefix) is non-nil and not a number, show the raw article
8718 without any article massaging functions being run. Normally, the key
8719 strokes are `C-u g'."
8720 (interactive "P")
8721 (cond
8722 ((numberp arg)
8723 (gnus-summary-show-article t)
8724 (let ((gnus-newsgroup-charset
8725 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8726 (mm-read-coding-system
8727 "View as charset: " ;; actually it is coding system.
8728 (save-excursion
8729 (set-buffer gnus-article-buffer)
8730 (mm-detect-coding-region (point) (point-max))))))
8731 (gnus-newsgroup-ignored-charsets 'gnus-all))
8732 (gnus-summary-select-article nil 'force)
8733 (let ((deps gnus-newsgroup-dependencies)
8734 head header lines)
8735 (save-excursion
8736 (set-buffer gnus-original-article-buffer)
8737 (save-restriction
8738 (message-narrow-to-head)
8739 (setq head (buffer-string))
8740 (goto-char (point-min))
8741 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8742 (goto-char (point-max))
8743 (widen)
8744 (setq lines (1- (count-lines (point) (point-max))))))
8745 (with-temp-buffer
8746 (insert (format "211 %d Article retrieved.\n"
8747 (cdr gnus-article-current)))
8748 (insert head)
8749 (if lines (insert (format "Lines: %d\n" lines)))
8750 (insert ".\n")
8751 (let ((nntp-server-buffer (current-buffer)))
8752 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8753 (gnus-data-set-header
8754 (gnus-data-find (cdr gnus-article-current))
8755 header)
8756 (gnus-summary-update-article-line
8757 (cdr gnus-article-current) header)
8758 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8759 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8760 ((not arg)
8761 ;; Select the article the normal way.
8762 (gnus-summary-select-article nil 'force))
8764 ;; We have to require this here to make sure that the following
8765 ;; dynamic binding isn't shadowed by autoloading.
8766 (require 'gnus-async)
8767 (require 'gnus-art)
8768 ;; Bind the article treatment functions to nil.
8769 (let ((gnus-have-all-headers t)
8770 gnus-article-prepare-hook
8771 gnus-article-decode-hook
8772 gnus-display-mime-function
8773 gnus-break-pages)
8774 ;; Destroy any MIME parts.
8775 (when (gnus-buffer-live-p gnus-article-buffer)
8776 (save-excursion
8777 (set-buffer gnus-article-buffer)
8778 (mm-destroy-parts gnus-article-mime-handles)
8779 ;; Set it to nil for safety reason.
8780 (setq gnus-article-mime-handle-alist nil)
8781 (setq gnus-article-mime-handles nil)))
8782 (gnus-summary-select-article nil 'force))))
8783 (gnus-summary-goto-subject gnus-current-article)
8784 (gnus-summary-position-point))
8786 (defun gnus-summary-show-raw-article ()
8787 "Show the raw article without any article massaging functions being run."
8788 (interactive)
8789 (gnus-summary-show-article t))
8791 (defun gnus-summary-verbose-headers (&optional arg)
8792 "Toggle permanent full header display.
8793 If ARG is a positive number, turn header display on.
8794 If ARG is a negative number, turn header display off."
8795 (interactive "P")
8796 (setq gnus-show-all-headers
8797 (cond ((or (not (numberp arg))
8798 (zerop arg))
8799 (not gnus-show-all-headers))
8800 ((natnump arg)
8801 t)))
8802 (gnus-summary-show-article))
8804 (defun gnus-summary-toggle-header (&optional arg)
8805 "Show the headers if they are hidden, or hide them if they are shown.
8806 If ARG is a positive number, show the entire header.
8807 If ARG is a negative number, hide the unwanted header lines."
8808 (interactive "P")
8809 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8810 (get-buffer-window gnus-article-buffer t))))
8811 (with-current-buffer gnus-article-buffer
8812 (widen)
8813 (article-narrow-to-head)
8814 (let* ((buffer-read-only nil)
8815 (inhibit-point-motion-hooks t)
8816 (hidden (if (numberp arg)
8817 (>= arg 0)
8818 (or (not (looking-at "[^ \t\n]+:"))
8819 (gnus-article-hidden-text-p 'headers))))
8820 s e)
8821 (delete-region (point-min) (point-max))
8822 (with-current-buffer gnus-original-article-buffer
8823 (goto-char (setq s (point-min)))
8824 (setq e (if (search-forward "\n\n" nil t)
8825 (1- (point))
8826 (point-max))))
8827 (insert-buffer-substring gnus-original-article-buffer s e)
8828 (run-hooks 'gnus-article-decode-hook)
8829 (if hidden
8830 (let ((gnus-treat-hide-headers nil)
8831 (gnus-treat-hide-boring-headers nil))
8832 (gnus-delete-wash-type 'headers)
8833 (gnus-treat-article 'head))
8834 (gnus-treat-article 'head))
8835 (widen)
8836 (if window
8837 (set-window-start window (goto-char (point-min))))
8838 (if gnus-break-pages
8839 (gnus-narrow-to-page)
8840 (when (gnus-visual-p 'page-marker)
8841 (let ((buffer-read-only nil))
8842 (gnus-remove-text-with-property 'gnus-prev)
8843 (gnus-remove-text-with-property 'gnus-next))))
8844 (gnus-set-mode-line 'article)))))
8846 (defun gnus-summary-show-all-headers ()
8847 "Make all header lines visible."
8848 (interactive)
8849 (gnus-summary-toggle-header 1))
8851 (defun gnus-summary-caesar-message (&optional arg)
8852 "Caesar rotate the current article by 13.
8853 The numerical prefix specifies how many places to rotate each letter
8854 forward."
8855 (interactive "P")
8856 (gnus-summary-select-article)
8857 (let ((mail-header-separator ""))
8858 (gnus-eval-in-buffer-window gnus-article-buffer
8859 (save-restriction
8860 (widen)
8861 (let ((start (window-start))
8862 buffer-read-only)
8863 (message-caesar-buffer-body arg)
8864 (set-window-start (get-buffer-window (current-buffer)) start))))))
8866 (autoload 'unmorse-region "morse"
8867 "Convert morse coded text in region to ordinary ASCII text."
8870 (defun gnus-summary-morse-message (&optional arg)
8871 "Morse decode the current article."
8872 (interactive "P")
8873 (gnus-summary-select-article)
8874 (let ((mail-header-separator ""))
8875 (gnus-eval-in-buffer-window gnus-article-buffer
8876 (save-excursion
8877 (save-restriction
8878 (widen)
8879 (let ((pos (window-start))
8880 buffer-read-only)
8881 (goto-char (point-min))
8882 (when (message-goto-body)
8883 (gnus-narrow-to-body))
8884 (goto-char (point-min))
8885 (while (re-search-forward "·" (point-max) t)
8886 (replace-match "."))
8887 (unmorse-region (point-min) (point-max))
8888 (widen)
8889 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8891 (defun gnus-summary-stop-page-breaking ()
8892 "Stop page breaking in the current article."
8893 (interactive)
8894 (gnus-summary-select-article)
8895 (gnus-eval-in-buffer-window gnus-article-buffer
8896 (widen)
8897 (when (gnus-visual-p 'page-marker)
8898 (let ((buffer-read-only nil))
8899 (gnus-remove-text-with-property 'gnus-prev)
8900 (gnus-remove-text-with-property 'gnus-next))
8901 (setq gnus-page-broken nil))))
8903 (defun gnus-summary-move-article (&optional n to-newsgroup
8904 select-method action)
8905 "Move the current article to a different newsgroup.
8906 If N is a positive number, move the N next articles.
8907 If N is a negative number, move the N previous articles.
8908 If N is nil and any articles have been marked with the process mark,
8909 move those articles instead.
8910 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8911 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8912 re-spool using this method.
8914 When called interactively with TO-NEWSGROUP being nil, the value of
8915 the variable `gnus-move-split-methods' is used for finding a default
8916 for the target newsgroup.
8918 For this function to work, both the current newsgroup and the
8919 newsgroup that you want to move to have to support the `request-move'
8920 and `request-accept' functions.
8922 ACTION can be either `move' (the default), `crosspost' or `copy'."
8923 (interactive "P")
8924 (unless action
8925 (setq action 'move))
8926 ;; Check whether the source group supports the required functions.
8927 (cond ((and (eq action 'move)
8928 (not (gnus-check-backend-function
8929 'request-move-article gnus-newsgroup-name)))
8930 (error "The current group does not support article moving"))
8931 ((and (eq action 'crosspost)
8932 (not (gnus-check-backend-function
8933 'request-replace-article gnus-newsgroup-name)))
8934 (error "The current group does not support article editing")))
8935 (let ((articles (gnus-summary-work-articles n))
8936 (prefix (if (gnus-check-backend-function
8937 'request-move-article gnus-newsgroup-name)
8938 (gnus-group-real-prefix gnus-newsgroup-name)
8939 ""))
8940 (names '((move "Move" "Moving")
8941 (copy "Copy" "Copying")
8942 (crosspost "Crosspost" "Crossposting")))
8943 (copy-buf (save-excursion
8944 (nnheader-set-temp-buffer " *copy article*")))
8945 art-group to-method new-xref article to-groups)
8946 (unless (assq action names)
8947 (error "Unknown action %s" action))
8948 ;; Read the newsgroup name.
8949 (when (and (not to-newsgroup)
8950 (not select-method))
8951 (if (and gnus-move-split-methods
8952 (not
8953 (and (memq gnus-current-article articles)
8954 (gnus-buffer-live-p gnus-original-article-buffer))))
8955 ;; When `gnus-move-split-methods' is non-nil, we have to
8956 ;; select an article to give `gnus-read-move-group-name' an
8957 ;; opportunity to suggest an appropriate default. However,
8958 ;; we needn't render or mark the article.
8959 (let ((gnus-display-mime-function nil)
8960 (gnus-article-prepare-hook nil)
8961 (gnus-mark-article-hook nil))
8962 (gnus-summary-select-article nil nil nil (car articles))))
8963 (setq to-newsgroup
8964 (gnus-read-move-group-name
8965 (cadr (assq action names))
8966 (symbol-value (intern (format "gnus-current-%s-group" action)))
8967 articles prefix))
8968 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8969 (setq to-method (or select-method
8970 (gnus-server-to-method
8971 (gnus-group-method to-newsgroup))))
8972 ;; Check the method we are to move this article to...
8973 (unless (gnus-check-backend-function
8974 'request-accept-article (car to-method))
8975 (error "%s does not support article copying" (car to-method)))
8976 (unless (gnus-check-server to-method)
8977 (error "Can't open server %s" (car to-method)))
8978 (gnus-message 6 "%s to %s: %s..."
8979 (caddr (assq action names))
8980 (or (car select-method) to-newsgroup) articles)
8981 (while articles
8982 (setq article (pop articles))
8983 (setq
8984 art-group
8985 (cond
8986 ;; Move the article.
8987 ((eq action 'move)
8988 ;; Remove this article from future suppression.
8989 (gnus-dup-unsuppress-article article)
8990 (gnus-request-move-article
8991 article ; Article to move
8992 gnus-newsgroup-name ; From newsgroup
8993 (nth 1 (gnus-find-method-for-group
8994 gnus-newsgroup-name)) ; Server
8995 (list 'gnus-request-accept-article
8996 to-newsgroup (list 'quote select-method)
8997 (not articles) t) ; Accept form
8998 (not articles))) ; Only save nov last time
8999 ;; Copy the article.
9000 ((eq action 'copy)
9001 (save-excursion
9002 (set-buffer copy-buf)
9003 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
9004 (gnus-request-accept-article
9005 to-newsgroup select-method (not articles) t))))
9006 ;; Crosspost the article.
9007 ((eq action 'crosspost)
9008 (let ((xref (message-tokenize-header
9009 (mail-header-xref (gnus-summary-article-header article))
9010 " ")))
9011 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
9012 ":" (number-to-string article)))
9013 (unless xref
9014 (setq xref (list (system-name))))
9015 (setq new-xref
9016 (concat
9017 (mapconcat 'identity
9018 (delete "Xref:" (delete new-xref xref))
9019 " ")
9020 " " new-xref))
9021 (save-excursion
9022 (set-buffer copy-buf)
9023 ;; First put the article in the destination group.
9024 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9025 (when (consp (setq art-group
9026 (gnus-request-accept-article
9027 to-newsgroup select-method (not articles))))
9028 (setq new-xref (concat new-xref " " (car art-group)
9030 (number-to-string (cdr art-group))))
9031 ;; Now we have the new Xrefs header, so we insert
9032 ;; it and replace the new article.
9033 (nnheader-replace-header "Xref" new-xref)
9034 (gnus-request-replace-article
9035 (cdr art-group) to-newsgroup (current-buffer))
9036 art-group))))))
9037 (cond
9038 ((not art-group)
9039 (gnus-message 1 "Couldn't %s article %s: %s"
9040 (cadr (assq action names)) article
9041 (nnheader-get-report (car to-method))))
9042 ((eq art-group 'junk)
9043 (when (eq action 'move)
9044 (gnus-summary-mark-article article gnus-canceled-mark)
9045 (gnus-message 4 "Deleted article %s" article)
9046 ;; run the delete hook
9047 (run-hook-with-args 'gnus-summary-article-delete-hook
9048 action
9049 (gnus-data-header
9050 (assoc article (gnus-data-list nil)))
9051 gnus-newsgroup-name nil
9052 select-method)))
9054 (let* ((pto-group (gnus-group-prefixed-name
9055 (car art-group) to-method))
9056 (entry
9057 (gnus-gethash pto-group gnus-newsrc-hashtb))
9058 (info (nth 2 entry))
9059 (to-group (gnus-info-group info))
9060 to-marks)
9061 ;; Update the group that has been moved to.
9062 (when (and info
9063 (memq action '(move copy)))
9064 (unless (member to-group to-groups)
9065 (push to-group to-groups))
9067 (unless (memq article gnus-newsgroup-unreads)
9068 (push 'read to-marks)
9069 (gnus-info-set-read
9070 info (gnus-add-to-range (gnus-info-read info)
9071 (list (cdr art-group)))))
9073 ;; See whether the article is to be put in the cache.
9074 (let ((marks (if (gnus-group-auto-expirable-p to-group)
9075 gnus-article-mark-lists
9076 (delete '(expirable . expire)
9077 (copy-sequence gnus-article-mark-lists))))
9078 (to-article (cdr art-group)))
9080 ;; Enter the article into the cache in the new group,
9081 ;; if that is required.
9082 (when gnus-use-cache
9083 (gnus-cache-possibly-enter-article
9084 to-group to-article
9085 (memq article gnus-newsgroup-marked)
9086 (memq article gnus-newsgroup-dormant)
9087 (memq article gnus-newsgroup-unreads)))
9089 (when gnus-preserve-marks
9090 ;; Copy any marks over to the new group.
9091 (when (and (equal to-group gnus-newsgroup-name)
9092 (not (memq article gnus-newsgroup-unreads)))
9093 ;; Mark this article as read in this group.
9094 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
9095 (setcdr (gnus-active to-group) to-article)
9096 (setcdr gnus-newsgroup-active to-article))
9098 (while marks
9099 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
9100 (when (memq article (symbol-value
9101 (intern (format "gnus-newsgroup-%s"
9102 (caar marks)))))
9103 (push (cdar marks) to-marks)
9104 ;; If the other group is the same as this group,
9105 ;; then we have to add the mark to the list.
9106 (when (equal to-group gnus-newsgroup-name)
9107 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
9108 (cons to-article
9109 (symbol-value
9110 (intern (format "gnus-newsgroup-%s"
9111 (caar marks)))))))
9112 ;; Copy the marks to other group.
9113 (gnus-add-marked-articles
9114 to-group (cdar marks) (list to-article) info)))
9115 (setq marks (cdr marks)))
9117 (gnus-request-set-mark
9118 to-group (list (list (list to-article) 'add to-marks))))
9120 (gnus-dribble-enter
9121 (concat "(gnus-group-set-info '"
9122 (gnus-prin1-to-string (gnus-get-info to-group))
9123 ")"))))
9125 ;; Update the Xref header in this article to point to
9126 ;; the new crossposted article we have just created.
9127 (when (eq action 'crosspost)
9128 (save-excursion
9129 (set-buffer copy-buf)
9130 (gnus-request-article-this-buffer article gnus-newsgroup-name)
9131 (nnheader-replace-header "Xref" new-xref)
9132 (gnus-request-replace-article
9133 article gnus-newsgroup-name (current-buffer))))
9135 ;; run the move/copy/crosspost/respool hook
9136 (run-hook-with-args 'gnus-summary-article-move-hook
9137 action
9138 (gnus-data-header
9139 (assoc article (gnus-data-list nil)))
9140 gnus-newsgroup-name
9141 to-newsgroup
9142 select-method))
9144 ;;;!!!Why is this necessary?
9145 (set-buffer gnus-summary-buffer)
9147 (gnus-summary-goto-subject article)
9148 (when (eq action 'move)
9149 (gnus-summary-mark-article article gnus-canceled-mark))))
9150 (gnus-summary-remove-process-mark article))
9151 ;; Re-activate all groups that have been moved to.
9152 (save-excursion
9153 (set-buffer gnus-group-buffer)
9154 (let ((gnus-group-marked to-groups))
9155 (gnus-group-get-new-news-this-group nil t)))
9157 (gnus-kill-buffer copy-buf)
9158 (gnus-summary-position-point)
9159 (gnus-set-mode-line 'summary)))
9161 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
9162 "Copy the current article to some other group.
9163 If TO-NEWSGROUP is string, do not prompt for a newsgroup to copy to.
9164 When called interactively, if TO-NEWSGROUP is nil, use the value of
9165 the variable `gnus-move-split-methods' for finding a default target
9166 newsgroup.
9167 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
9168 re-spool using this method."
9169 (interactive "P")
9170 (gnus-summary-move-article n to-newsgroup select-method 'copy))
9172 (defun gnus-summary-crosspost-article (&optional n)
9173 "Crosspost the current article to some other group."
9174 (interactive "P")
9175 (gnus-summary-move-article n nil nil 'crosspost))
9177 (defcustom gnus-summary-respool-default-method nil
9178 "Default method type for respooling an article.
9179 If nil, use to the current newsgroup method."
9180 :type 'symbol
9181 :group 'gnus-summary-mail)
9183 (defcustom gnus-summary-display-while-building nil
9184 "If non-nil, show and update the summary buffer as it's being built.
9185 If the value is t, update the buffer after every line is inserted. If
9186 the value is an integer (N), update the display every N lines."
9187 :version "21.4"
9188 :group 'gnus-thread
9189 :type '(choice (const :tag "off" nil)
9190 number
9191 (const :tag "frequently" t)))
9193 (defun gnus-summary-respool-article (&optional n method)
9194 "Respool the current article.
9195 The article will be squeezed through the mail spooling process again,
9196 which means that it will be put in some mail newsgroup or other
9197 depending on `nnmail-split-methods'.
9198 If N is a positive number, respool the N next articles.
9199 If N is a negative number, respool the N previous articles.
9200 If N is nil and any articles have been marked with the process mark,
9201 respool those articles instead.
9203 Respooling can be done both from mail groups and \"real\" newsgroups.
9204 In the former case, the articles in question will be moved from the
9205 current group into whatever groups they are destined to. In the
9206 latter case, they will be copied into the relevant groups."
9207 (interactive
9208 (list current-prefix-arg
9209 (let* ((methods (gnus-methods-using 'respool))
9210 (methname
9211 (symbol-name (or gnus-summary-respool-default-method
9212 (car (gnus-find-method-for-group
9213 gnus-newsgroup-name)))))
9214 (method
9215 (gnus-completing-read-with-default
9216 methname "What backend do you want to use when respooling?"
9217 methods nil t nil 'gnus-mail-method-history))
9219 (cond
9220 ((zerop (length (setq ms (gnus-servers-using-backend
9221 (intern method)))))
9222 (list (intern method) ""))
9223 ((= 1 (length ms))
9224 (car ms))
9226 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
9227 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
9228 ms-alist))))))))
9229 (unless method
9230 (error "No method given for respooling"))
9231 (if (assoc (symbol-name
9232 (car (gnus-find-method-for-group gnus-newsgroup-name)))
9233 (gnus-methods-using 'respool))
9234 (gnus-summary-move-article n nil method)
9235 (gnus-summary-copy-article n nil method)))
9237 (defun gnus-summary-import-article (file &optional edit)
9238 "Import an arbitrary file into a mail newsgroup."
9239 (interactive "fImport file: \nP")
9240 (let ((group gnus-newsgroup-name)
9241 (now (current-time))
9242 atts lines group-art)
9243 (unless (gnus-check-backend-function 'request-accept-article group)
9244 (error "%s does not support article importing" group))
9245 (or (file-readable-p file)
9246 (not (file-regular-p file))
9247 (error "Can't read %s" file))
9248 (save-excursion
9249 (set-buffer (gnus-get-buffer-create " *import file*"))
9250 (erase-buffer)
9251 (nnheader-insert-file-contents file)
9252 (goto-char (point-min))
9253 (if (nnheader-article-p)
9254 (save-restriction
9255 (goto-char (point-min))
9256 (search-forward "\n\n" nil t)
9257 (narrow-to-region (point-min) (1- (point)))
9258 (goto-char (point-min))
9259 (unless (re-search-forward "^date:" nil t)
9260 (goto-char (point-max))
9261 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
9262 ;; This doesn't look like an article, so we fudge some headers.
9263 (setq atts (file-attributes file)
9264 lines (count-lines (point-min) (point-max)))
9265 (insert "From: " (read-string "From: ") "\n"
9266 "Subject: " (read-string "Subject: ") "\n"
9267 "Date: " (message-make-date (nth 5 atts)) "\n"
9268 "Message-ID: " (message-make-message-id) "\n"
9269 "Lines: " (int-to-string lines) "\n"
9270 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9271 (setq group-art (gnus-request-accept-article group nil t))
9272 (kill-buffer (current-buffer)))
9273 (setq gnus-newsgroup-active (gnus-activate-group group))
9274 (forward-line 1)
9275 (gnus-summary-goto-article (cdr group-art) nil t)
9276 (when edit
9277 (gnus-summary-edit-article))))
9279 (defun gnus-summary-create-article ()
9280 "Create an article in a mail newsgroup."
9281 (interactive)
9282 (let ((group gnus-newsgroup-name)
9283 (now (current-time))
9284 group-art)
9285 (unless (gnus-check-backend-function 'request-accept-article group)
9286 (error "%s does not support article importing" group))
9287 (save-excursion
9288 (set-buffer (gnus-get-buffer-create " *import file*"))
9289 (erase-buffer)
9290 (goto-char (point-min))
9291 ;; This doesn't look like an article, so we fudge some headers.
9292 (insert "From: " (read-string "From: ") "\n"
9293 "Subject: " (read-string "Subject: ") "\n"
9294 "Date: " (message-make-date now) "\n"
9295 "Message-ID: " (message-make-message-id) "\n")
9296 (setq group-art (gnus-request-accept-article group nil t))
9297 (kill-buffer (current-buffer)))
9298 (setq gnus-newsgroup-active (gnus-activate-group group))
9299 (forward-line 1)
9300 (gnus-summary-goto-article (cdr group-art) nil t)
9301 (gnus-summary-edit-article)))
9303 (defun gnus-summary-article-posted-p ()
9304 "Say whether the current (mail) article is available from news as well.
9305 This will be the case if the article has both been mailed and posted."
9306 (interactive)
9307 (let ((id (mail-header-references (gnus-summary-article-header)))
9308 (gnus-override-method (car (gnus-refer-article-methods))))
9309 (if (gnus-request-head id "")
9310 (gnus-message 2 "The current message was found on %s"
9311 gnus-override-method)
9312 (gnus-message 2 "The current message couldn't be found on %s"
9313 gnus-override-method)
9314 nil)))
9316 (defun gnus-summary-expire-articles (&optional now)
9317 "Expire all articles that are marked as expirable in the current group."
9318 (interactive)
9319 (when (and (not gnus-group-is-exiting-without-update-p)
9320 (gnus-check-backend-function
9321 'request-expire-articles gnus-newsgroup-name))
9322 ;; This backend supports expiry.
9323 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9324 (expirable (if total
9325 (progn
9326 ;; We need to update the info for
9327 ;; this group for `gnus-list-of-read-articles'
9328 ;; to give us the right answer.
9329 (gnus-run-hooks 'gnus-exit-group-hook)
9330 (gnus-summary-update-info)
9331 (gnus-list-of-read-articles gnus-newsgroup-name))
9332 (setq gnus-newsgroup-expirable
9333 (sort gnus-newsgroup-expirable '<))))
9334 (expiry-wait (if now 'immediate
9335 (gnus-group-find-parameter
9336 gnus-newsgroup-name 'expiry-wait)))
9337 (nnmail-expiry-target
9338 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9339 nnmail-expiry-target))
9341 (when expirable
9342 ;; There are expirable articles in this group, so we run them
9343 ;; through the expiry process.
9344 (gnus-message 6 "Expiring articles...")
9345 (unless (gnus-check-group gnus-newsgroup-name)
9346 (error "Can't open server for %s" gnus-newsgroup-name))
9347 ;; The list of articles that weren't expired is returned.
9348 (save-excursion
9349 (if expiry-wait
9350 (let ((nnmail-expiry-wait-function nil)
9351 (nnmail-expiry-wait expiry-wait))
9352 (setq es (gnus-request-expire-articles
9353 expirable gnus-newsgroup-name)))
9354 (setq es (gnus-request-expire-articles
9355 expirable gnus-newsgroup-name)))
9356 (unless total
9357 (setq gnus-newsgroup-expirable es))
9358 ;; We go through the old list of expirable, and mark all
9359 ;; really expired articles as nonexistent.
9360 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9361 (let ((gnus-use-cache nil))
9362 (dolist (article expirable)
9363 (when (and (not (memq article es))
9364 (gnus-data-find article))
9365 (gnus-summary-mark-article article gnus-canceled-mark)
9366 (run-hook-with-args 'gnus-summary-article-expire-hook
9367 'delete
9368 (gnus-data-header
9369 (assoc article (gnus-data-list nil)))
9370 gnus-newsgroup-name
9372 nil))))))
9373 (gnus-message 6 "Expiring articles...done")))))
9375 (defun gnus-summary-expire-articles-now ()
9376 "Expunge all expirable articles in the current group.
9377 This means that *all* articles that are marked as expirable will be
9378 deleted forever, right now."
9379 (interactive)
9380 (or gnus-expert-user
9381 (gnus-yes-or-no-p
9382 "Are you really, really, really sure you want to delete all these messages? ")
9383 (error "Phew!"))
9384 (gnus-summary-expire-articles t))
9386 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9387 (defun gnus-summary-delete-article (&optional n)
9388 "Delete the N next (mail) articles.
9389 This command actually deletes articles. This is not a marking
9390 command. The article will disappear forever from your life, never to
9391 return.
9393 If N is negative, delete backwards.
9394 If N is nil and articles have been marked with the process mark,
9395 delete these instead.
9397 If `gnus-novice-user' is non-nil you will be asked for
9398 confirmation before the articles are deleted."
9399 (interactive "P")
9400 (unless (gnus-check-backend-function 'request-expire-articles
9401 gnus-newsgroup-name)
9402 (error "The current newsgroup does not support article deletion"))
9403 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9404 (error "Couldn't open server"))
9405 ;; Compute the list of articles to delete.
9406 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9407 (nnmail-expiry-target 'delete)
9408 not-deleted)
9409 (if (and gnus-novice-user
9410 (not (gnus-yes-or-no-p
9411 (format "Do you really want to delete %s forever? "
9412 (if (> (length articles) 1)
9413 (format "these %s articles" (length articles))
9414 "this article")))))
9416 ;; Delete the articles.
9417 (setq not-deleted (gnus-request-expire-articles
9418 articles gnus-newsgroup-name 'force))
9419 (while articles
9420 (gnus-summary-remove-process-mark (car articles))
9421 ;; The backend might not have been able to delete the article
9422 ;; after all.
9423 (unless (memq (car articles) not-deleted)
9424 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9425 (let* ((article (car articles))
9426 (id (mail-header-id (gnus-data-header
9427 (assoc article (gnus-data-list nil))))))
9428 (run-hook-with-args 'gnus-summary-article-delete-hook
9429 'delete id gnus-newsgroup-name nil
9430 nil))
9431 (setq articles (cdr articles)))
9432 (when not-deleted
9433 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9434 (gnus-summary-position-point)
9435 (gnus-set-mode-line 'summary)
9436 not-deleted))
9438 (defun gnus-summary-edit-article (&optional arg)
9439 "Edit the current article.
9440 This will have permanent effect only in mail groups.
9441 If ARG is nil, edit the decoded articles.
9442 If ARG is 1, edit the raw articles.
9443 If ARG is 2, edit the raw articles even in read-only groups.
9444 If ARG is 3, edit the articles with the current handles.
9445 Otherwise, allow editing of articles even in read-only
9446 groups."
9447 (interactive "P")
9448 (let (force raw current-handles)
9449 (cond
9450 ((null arg))
9451 ((eq arg 1)
9452 (setq raw t))
9453 ((eq arg 2)
9454 (setq raw t
9455 force t))
9456 ((eq arg 3)
9457 (setq current-handles
9458 (and (gnus-buffer-live-p gnus-article-buffer)
9459 (with-current-buffer gnus-article-buffer
9460 (prog1
9461 gnus-article-mime-handles
9462 (setq gnus-article-mime-handles nil))))))
9464 (setq force t)))
9465 (when (and raw (not force)
9466 (member gnus-newsgroup-name '("nndraft:delayed"
9467 "nndraft:drafts"
9468 "nndraft:queue")))
9469 (error "Can't edit the raw article in group %s"
9470 gnus-newsgroup-name))
9471 (save-excursion
9472 (set-buffer gnus-summary-buffer)
9473 (let ((mail-parse-charset gnus-newsgroup-charset)
9474 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9475 (gnus-set-global-variables)
9476 (when (and (not force)
9477 (gnus-group-read-only-p))
9478 (error "The current newsgroup does not support article editing"))
9479 (gnus-summary-show-article t)
9480 (when (and (not raw) (gnus-buffer-live-p gnus-article-buffer))
9481 (with-current-buffer gnus-article-buffer
9482 (mm-enable-multibyte)))
9483 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
9484 (setq raw t))
9485 (gnus-article-edit-article
9486 (if raw 'ignore
9487 `(lambda ()
9488 (let ((mbl mml-buffer-list))
9489 (setq mml-buffer-list nil)
9490 (mime-to-mml ,'current-handles)
9491 (let ((mbl1 mml-buffer-list))
9492 (setq mml-buffer-list mbl)
9493 (set (make-local-variable 'mml-buffer-list) mbl1))
9494 (gnus-make-local-hook 'kill-buffer-hook)
9495 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))))
9496 `(lambda (no-highlight)
9497 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9498 (message-options message-options)
9499 (message-options-set-recipient)
9500 (mail-parse-ignored-charsets
9501 ',gnus-newsgroup-ignored-charsets))
9502 ,(if (not raw) '(progn
9503 (mml-to-mime)
9504 (mml-destroy-buffers)
9505 (remove-hook 'kill-buffer-hook
9506 'mml-destroy-buffers t)
9507 (kill-local-variable 'mml-buffer-list)))
9508 (gnus-summary-edit-article-done
9509 ,(or (mail-header-references gnus-current-headers) "")
9510 ,(gnus-group-read-only-p)
9511 ,gnus-summary-buffer no-highlight))))))))
9513 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9515 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9516 no-highlight)
9517 "Make edits to the current article permanent."
9518 (interactive)
9519 (save-excursion
9520 ;; The buffer restriction contains the entire article if it exists.
9521 (when (article-goto-body)
9522 (let ((lines (count-lines (point) (point-max)))
9523 (length (- (point-max) (point)))
9524 (case-fold-search t)
9525 (body (copy-marker (point))))
9526 (goto-char (point-min))
9527 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9528 (delete-region (match-beginning 1) (match-end 1))
9529 (insert (number-to-string length)))
9530 (goto-char (point-min))
9531 (when (re-search-forward
9532 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9533 (delete-region (match-beginning 1) (match-end 1))
9534 (insert (number-to-string length)))
9535 (goto-char (point-min))
9536 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9537 (delete-region (match-beginning 1) (match-end 1))
9538 (insert (number-to-string lines))))))
9539 ;; Replace the article.
9540 (let ((buf (current-buffer)))
9541 (with-temp-buffer
9542 (insert-buffer-substring buf)
9544 (if (and (not read-only)
9545 (not (gnus-request-replace-article
9546 (cdr gnus-article-current) (car gnus-article-current)
9547 (current-buffer) t)))
9548 (error "Couldn't replace article")
9549 ;; Update the summary buffer.
9550 (if (and references
9551 (equal (message-tokenize-header references " ")
9552 (message-tokenize-header
9553 (or (message-fetch-field "references") "") " ")))
9554 ;; We only have to update this line.
9555 (save-excursion
9556 (save-restriction
9557 (message-narrow-to-head)
9558 (let ((head (buffer-string))
9559 header)
9560 (with-temp-buffer
9561 (insert (format "211 %d Article retrieved.\n"
9562 (cdr gnus-article-current)))
9563 (insert head)
9564 (insert ".\n")
9565 (let ((nntp-server-buffer (current-buffer)))
9566 (setq header (car (gnus-get-newsgroup-headers
9567 nil t))))
9568 (save-excursion
9569 (set-buffer gnus-summary-buffer)
9570 (gnus-data-set-header
9571 (gnus-data-find (cdr gnus-article-current))
9572 header)
9573 (gnus-summary-update-article-line
9574 (cdr gnus-article-current) header)
9575 (if (gnus-summary-goto-subject
9576 (cdr gnus-article-current) nil t)
9577 (gnus-summary-update-secondary-mark
9578 (cdr gnus-article-current))))))))
9579 ;; Update threads.
9580 (set-buffer (or buffer gnus-summary-buffer))
9581 (gnus-summary-update-article (cdr gnus-article-current))
9582 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9583 (gnus-summary-update-secondary-mark
9584 (cdr gnus-article-current))))
9585 ;; Prettify the article buffer again.
9586 (unless no-highlight
9587 (save-excursion
9588 (set-buffer gnus-article-buffer)
9589 ;;;!!! Fix this -- article should be rehighlighted.
9590 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9591 (set-buffer gnus-original-article-buffer)
9592 (gnus-request-article
9593 (cdr gnus-article-current)
9594 (car gnus-article-current) (current-buffer))))
9595 ;; Prettify the summary buffer line.
9596 (when (gnus-visual-p 'summary-highlight 'highlight)
9597 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9599 (defun gnus-summary-edit-wash (key)
9600 "Perform editing command KEY in the article buffer."
9601 (interactive
9602 (list
9603 (progn
9604 (message "%s" (concat (this-command-keys) "- "))
9605 (read-char))))
9606 (message "")
9607 (gnus-summary-edit-article)
9608 (execute-kbd-macro (concat (this-command-keys) key))
9609 (gnus-article-edit-done))
9611 ;;; Respooling
9613 (defun gnus-summary-respool-query (&optional silent trace)
9614 "Query where the respool algorithm would put this article."
9615 (interactive)
9616 (let (gnus-mark-article-hook)
9617 (gnus-summary-select-article)
9618 (save-excursion
9619 (set-buffer gnus-original-article-buffer)
9620 (let ((groups (nnmail-article-group 'identity trace)))
9621 (unless silent
9622 (if groups
9623 (message "This message would go to %s"
9624 (mapconcat 'car groups ", "))
9625 (message "This message would go to no groups"))
9626 groups)))))
9628 (defun gnus-summary-respool-trace ()
9629 "Trace where the respool algorithm would put this article.
9630 Display a buffer showing all fancy splitting patterns which matched."
9631 (interactive)
9632 (gnus-summary-respool-query nil t))
9634 ;; Summary marking commands.
9636 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9637 "Mark articles which has the same subject as read, and then select the next.
9638 If UNMARK is positive, remove any kind of mark.
9639 If UNMARK is negative, tick articles."
9640 (interactive "P")
9641 (when unmark
9642 (setq unmark (prefix-numeric-value unmark)))
9643 (let ((count
9644 (gnus-summary-mark-same-subject
9645 (gnus-summary-article-subject) unmark)))
9646 ;; Select next unread article. If auto-select-same mode, should
9647 ;; select the first unread article.
9648 (gnus-summary-next-article t (and gnus-auto-select-same
9649 (gnus-summary-article-subject)))
9650 (gnus-message 7 "%d article%s marked as %s"
9651 count (if (= count 1) " is" "s are")
9652 (if unmark "unread" "read"))))
9654 (defun gnus-summary-kill-same-subject (&optional unmark)
9655 "Mark articles which has the same subject as read.
9656 If UNMARK is positive, remove any kind of mark.
9657 If UNMARK is negative, tick articles."
9658 (interactive "P")
9659 (when unmark
9660 (setq unmark (prefix-numeric-value unmark)))
9661 (let ((count
9662 (gnus-summary-mark-same-subject
9663 (gnus-summary-article-subject) unmark)))
9664 ;; If marked as read, go to next unread subject.
9665 (when (null unmark)
9666 ;; Go to next unread subject.
9667 (gnus-summary-next-subject 1 t))
9668 (gnus-message 7 "%d articles are marked as %s"
9669 count (if unmark "unread" "read"))))
9671 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9672 "Mark articles with same SUBJECT as read, and return marked number.
9673 If optional argument UNMARK is positive, remove any kinds of marks.
9674 If optional argument UNMARK is negative, mark articles as unread instead."
9675 (let ((count 1))
9676 (save-excursion
9677 (cond
9678 ((null unmark) ; Mark as read.
9679 (while (and
9680 (progn
9681 (gnus-summary-mark-article-as-read gnus-killed-mark)
9682 (gnus-summary-show-thread) t)
9683 (gnus-summary-find-subject subject))
9684 (setq count (1+ count))))
9685 ((> unmark 0) ; Tick.
9686 (while (and
9687 (progn
9688 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9689 (gnus-summary-show-thread) t)
9690 (gnus-summary-find-subject subject))
9691 (setq count (1+ count))))
9692 (t ; Mark as unread.
9693 (while (and
9694 (progn
9695 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9696 (gnus-summary-show-thread) t)
9697 (gnus-summary-find-subject subject))
9698 (setq count (1+ count)))))
9699 (gnus-set-mode-line 'summary)
9700 ;; Return the number of marked articles.
9701 count)))
9703 (defun gnus-summary-mark-as-processable (n &optional unmark)
9704 "Set the process mark on the next N articles.
9705 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9706 the process mark instead. The difference between N and the actual
9707 number of articles marked is returned."
9708 (interactive "P")
9709 (if (and (null n) (gnus-region-active-p))
9710 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9711 (setq n (prefix-numeric-value n))
9712 (let ((backward (< n 0))
9713 (n (abs n)))
9714 (while (and
9715 (> n 0)
9716 (if unmark
9717 (gnus-summary-remove-process-mark
9718 (gnus-summary-article-number))
9719 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9720 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9721 (setq n (1- n)))
9722 (when (/= 0 n)
9723 (gnus-message 7 "No more articles"))
9724 (gnus-summary-recenter)
9725 (gnus-summary-position-point)
9726 n)))
9728 (defun gnus-summary-unmark-as-processable (n)
9729 "Remove the process mark from the next N articles.
9730 If N is negative, unmark backward instead. The difference between N and
9731 the actual number of articles unmarked is returned."
9732 (interactive "P")
9733 (gnus-summary-mark-as-processable n t))
9735 (defun gnus-summary-unmark-all-processable ()
9736 "Remove the process mark from all articles."
9737 (interactive)
9738 (save-excursion
9739 (while gnus-newsgroup-processable
9740 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9741 (gnus-summary-position-point))
9743 (defun gnus-summary-add-mark (article type)
9744 "Mark ARTICLE with a mark of TYPE."
9745 (let ((vtype (car (assq type gnus-article-mark-lists)))
9746 var)
9747 (if (not vtype)
9748 (error "No such mark type: %s" type)
9749 (setq var (intern (format "gnus-newsgroup-%s" type)))
9750 (set var (cons article (symbol-value var)))
9751 (if (memq type '(processable cached replied forwarded recent saved))
9752 (gnus-summary-update-secondary-mark article)
9753 ;;; !!! This is bogus. We should find out what primary
9754 ;;; !!! mark we want to set.
9755 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9757 (defun gnus-summary-mark-as-expirable (n)
9758 "Mark N articles forward as expirable.
9759 If N is negative, mark backward instead. The difference between N and
9760 the actual number of articles marked is returned."
9761 (interactive "p")
9762 (gnus-summary-mark-forward n gnus-expirable-mark))
9764 (defun gnus-summary-mark-as-spam (n)
9765 "Mark N articles forward as spam.
9766 If N is negative, mark backward instead. The difference between N and
9767 the actual number of articles marked is returned."
9768 (interactive "p")
9769 (gnus-summary-mark-forward n gnus-spam-mark))
9771 (defun gnus-summary-mark-article-as-replied (article)
9772 "Mark ARTICLE as replied to and update the summary line.
9773 ARTICLE can also be a list of articles."
9774 (interactive (list (gnus-summary-article-number)))
9775 (let ((articles (if (listp article) article (list article))))
9776 (dolist (article articles)
9777 (unless (numberp article)
9778 (error "%s is not a number" article))
9779 (push article gnus-newsgroup-replied)
9780 (let ((buffer-read-only nil))
9781 (when (gnus-summary-goto-subject article nil t)
9782 (gnus-summary-update-secondary-mark article))))))
9784 (defun gnus-summary-mark-article-as-forwarded (article)
9785 "Mark ARTICLE as forwarded and update the summary line.
9786 ARTICLE can also be a list of articles."
9787 (let ((articles (if (listp article) article (list article))))
9788 (dolist (article articles)
9789 (push article gnus-newsgroup-forwarded)
9790 (let ((buffer-read-only nil))
9791 (when (gnus-summary-goto-subject article nil t)
9792 (gnus-summary-update-secondary-mark article))))))
9794 (defun gnus-summary-set-bookmark (article)
9795 "Set a bookmark in current article."
9796 (interactive (list (gnus-summary-article-number)))
9797 (when (or (not (get-buffer gnus-article-buffer))
9798 (not gnus-current-article)
9799 (not gnus-article-current)
9800 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9801 (error "No current article selected"))
9802 ;; Remove old bookmark, if one exists.
9803 (gnus-pull article gnus-newsgroup-bookmarks)
9804 ;; Set the new bookmark, which is on the form
9805 ;; (article-number . line-number-in-body).
9806 (push
9807 (cons article
9808 (save-excursion
9809 (set-buffer gnus-article-buffer)
9810 (count-lines
9811 (min (point)
9812 (save-excursion
9813 (article-goto-body)
9814 (point)))
9815 (point))))
9816 gnus-newsgroup-bookmarks)
9817 (gnus-message 6 "A bookmark has been added to the current article."))
9819 (defun gnus-summary-remove-bookmark (article)
9820 "Remove the bookmark from the current article."
9821 (interactive (list (gnus-summary-article-number)))
9822 ;; Remove old bookmark, if one exists.
9823 (if (not (assq article gnus-newsgroup-bookmarks))
9824 (gnus-message 6 "No bookmark in current article.")
9825 (gnus-pull article gnus-newsgroup-bookmarks)
9826 (gnus-message 6 "Removed bookmark.")))
9828 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9829 (defun gnus-summary-mark-as-dormant (n)
9830 "Mark N articles forward as dormant.
9831 If N is negative, mark backward instead. The difference between N and
9832 the actual number of articles marked is returned."
9833 (interactive "p")
9834 (gnus-summary-mark-forward n gnus-dormant-mark))
9836 (defun gnus-summary-set-process-mark (article)
9837 "Set the process mark on ARTICLE and update the summary line."
9838 (setq gnus-newsgroup-processable
9839 (cons article
9840 (delq article gnus-newsgroup-processable)))
9841 (when (gnus-summary-goto-subject article)
9842 (gnus-summary-show-thread)
9843 (gnus-summary-goto-subject article)
9844 (gnus-summary-update-secondary-mark article)))
9846 (defun gnus-summary-remove-process-mark (article)
9847 "Remove the process mark from ARTICLE and update the summary line."
9848 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9849 (when (gnus-summary-goto-subject article)
9850 (gnus-summary-show-thread)
9851 (gnus-summary-goto-subject article)
9852 (gnus-summary-update-secondary-mark article)))
9854 (defun gnus-summary-set-saved-mark (article)
9855 "Set the process mark on ARTICLE and update the summary line."
9856 (push article gnus-newsgroup-saved)
9857 (when (gnus-summary-goto-subject article)
9858 (gnus-summary-update-secondary-mark article)))
9860 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9861 "Mark N articles as read forwards.
9862 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9863 The difference between N and the actual number of articles marked is
9864 returned.
9865 If NO-EXPIRE, auto-expiry will be inhibited."
9866 (interactive "p")
9867 (gnus-summary-show-thread)
9868 (let ((backward (< n 0))
9869 (gnus-summary-goto-unread
9870 (and gnus-summary-goto-unread
9871 (not (eq gnus-summary-goto-unread 'never))
9872 (not (memq mark (list gnus-unread-mark gnus-spam-mark
9873 gnus-ticked-mark gnus-dormant-mark)))))
9874 (n (abs n))
9875 (mark (or mark gnus-del-mark)))
9876 (while (and (> n 0)
9877 (gnus-summary-mark-article nil mark no-expire)
9878 (zerop (gnus-summary-next-subject
9879 (if backward -1 1)
9880 (and gnus-summary-goto-unread
9881 (not (eq gnus-summary-goto-unread 'never)))
9882 t)))
9883 (setq n (1- n)))
9884 (when (/= 0 n)
9885 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9886 (gnus-summary-recenter)
9887 (gnus-summary-position-point)
9888 (gnus-set-mode-line 'summary)
9891 (defun gnus-summary-mark-article-as-read (mark)
9892 "Mark the current article quickly as read with MARK."
9893 (let ((article (gnus-summary-article-number)))
9894 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9895 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9896 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9897 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9898 (push (cons article mark) gnus-newsgroup-reads)
9899 ;; Possibly remove from cache, if that is used.
9900 (when gnus-use-cache
9901 (gnus-cache-enter-remove-article article))
9902 ;; Allow the backend to change the mark.
9903 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9904 ;; Check for auto-expiry.
9905 (when (and gnus-newsgroup-auto-expire
9906 (memq mark gnus-auto-expirable-marks))
9907 (setq mark gnus-expirable-mark)
9908 ;; Let the backend know about the mark change.
9909 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9910 (push article gnus-newsgroup-expirable))
9911 ;; Set the mark in the buffer.
9912 (gnus-summary-update-mark mark 'unread)
9915 (defun gnus-summary-mark-article-as-unread (mark)
9916 "Mark the current article quickly as unread with MARK."
9917 (let* ((article (gnus-summary-article-number))
9918 (old-mark (gnus-summary-article-mark article)))
9919 ;; Allow the backend to change the mark.
9920 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9921 (if (eq mark old-mark)
9923 (if (<= article 0)
9924 (progn
9925 (gnus-error 1 "Can't mark negative article numbers")
9926 nil)
9927 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9928 (setq gnus-newsgroup-spam-marked
9929 (delq article gnus-newsgroup-spam-marked))
9930 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9931 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9932 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9933 (cond ((= mark gnus-ticked-mark)
9934 (setq gnus-newsgroup-marked
9935 (gnus-add-to-sorted-list gnus-newsgroup-marked
9936 article)))
9937 ((= mark gnus-spam-mark)
9938 (setq gnus-newsgroup-spam-marked
9939 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9940 article)))
9941 ((= mark gnus-dormant-mark)
9942 (setq gnus-newsgroup-dormant
9943 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9944 article)))
9946 (setq gnus-newsgroup-unreads
9947 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9948 article))))
9949 (gnus-pull article gnus-newsgroup-reads)
9951 ;; See whether the article is to be put in the cache.
9952 (and gnus-use-cache
9953 (vectorp (gnus-summary-article-header article))
9954 (save-excursion
9955 (gnus-cache-possibly-enter-article
9956 gnus-newsgroup-name article
9957 (= mark gnus-ticked-mark)
9958 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9960 ;; Fix the mark.
9961 (gnus-summary-update-mark mark 'unread)
9962 t))))
9964 (defun gnus-summary-mark-article (&optional article mark no-expire)
9965 "Mark ARTICLE with MARK. MARK can be any character.
9966 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9967 `??' (dormant) and `?E' (expirable).
9968 If MARK is nil, then the default character `?r' is used.
9969 If ARTICLE is nil, then the article on the current line will be
9970 marked.
9971 If NO-EXPIRE, auto-expiry will be inhibited."
9972 ;; The mark might be a string.
9973 (when (stringp mark)
9974 (setq mark (aref mark 0)))
9975 ;; If no mark is given, then we check auto-expiring.
9976 (when (null mark)
9977 (setq mark gnus-del-mark))
9978 (when (and (not no-expire)
9979 gnus-newsgroup-auto-expire
9980 (memq mark gnus-auto-expirable-marks))
9981 (setq mark gnus-expirable-mark))
9982 (let ((article (or article (gnus-summary-article-number)))
9983 (old-mark (gnus-summary-article-mark article)))
9984 ;; Allow the backend to change the mark.
9985 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9986 (if (eq mark old-mark)
9988 (unless article
9989 (error "No article on current line"))
9990 (if (not (if (or (= mark gnus-unread-mark)
9991 (= mark gnus-ticked-mark)
9992 (= mark gnus-spam-mark)
9993 (= mark gnus-dormant-mark))
9994 (gnus-mark-article-as-unread article mark)
9995 (gnus-mark-article-as-read article mark)))
9997 ;; See whether the article is to be put in the cache.
9998 (and gnus-use-cache
9999 (not (= mark gnus-canceled-mark))
10000 (vectorp (gnus-summary-article-header article))
10001 (save-excursion
10002 (gnus-cache-possibly-enter-article
10003 gnus-newsgroup-name article
10004 (= mark gnus-ticked-mark)
10005 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
10007 (when (gnus-summary-goto-subject article nil t)
10008 (let ((buffer-read-only nil))
10009 (gnus-summary-show-thread)
10010 ;; Fix the mark.
10011 (gnus-summary-update-mark mark 'unread)
10012 t))))))
10014 (defun gnus-summary-update-secondary-mark (article)
10015 "Update the secondary (read, process, cache) mark."
10016 (gnus-summary-update-mark
10017 (cond ((memq article gnus-newsgroup-processable)
10018 gnus-process-mark)
10019 ((memq article gnus-newsgroup-cached)
10020 gnus-cached-mark)
10021 ((memq article gnus-newsgroup-replied)
10022 gnus-replied-mark)
10023 ((memq article gnus-newsgroup-forwarded)
10024 gnus-forwarded-mark)
10025 ((memq article gnus-newsgroup-saved)
10026 gnus-saved-mark)
10027 ((memq article gnus-newsgroup-recent)
10028 gnus-recent-mark)
10029 ((memq article gnus-newsgroup-unseen)
10030 gnus-unseen-mark)
10031 (t gnus-no-mark))
10032 'replied)
10033 (when (gnus-visual-p 'summary-highlight 'highlight)
10034 (gnus-run-hooks 'gnus-summary-update-hook))
10037 (defun gnus-summary-update-download-mark (article)
10038 "Update the download mark."
10039 (gnus-summary-update-mark
10040 (cond ((memq article gnus-newsgroup-undownloaded)
10041 gnus-undownloaded-mark)
10042 (gnus-newsgroup-agentized
10043 gnus-downloaded-mark)
10045 gnus-no-mark))
10046 'download)
10047 (gnus-summary-update-line t)
10050 (defun gnus-summary-update-mark (mark type)
10051 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
10052 (buffer-read-only nil))
10053 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
10054 (when forward
10055 (when (looking-at "\r")
10056 (incf forward))
10057 (when (<= (+ forward (point)) (point-max))
10058 ;; Go to the right position on the line.
10059 (goto-char (+ forward (point)))
10060 ;; Replace the old mark with the new mark.
10061 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
10062 ;; Optionally update the marks by some user rule.
10063 (when (eq type 'unread)
10064 (gnus-data-set-mark
10065 (gnus-data-find (gnus-summary-article-number)) mark)
10066 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
10068 (defun gnus-mark-article-as-read (article &optional mark)
10069 "Enter ARTICLE in the pertinent lists and remove it from others."
10070 ;; Make the article expirable.
10071 (let ((mark (or mark gnus-del-mark)))
10072 (setq gnus-newsgroup-expirable
10073 (if (= mark gnus-expirable-mark)
10074 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
10075 (delq article gnus-newsgroup-expirable)))
10076 ;; Remove from unread and marked lists.
10077 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10078 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
10079 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
10080 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
10081 (push (cons article mark) gnus-newsgroup-reads)
10082 ;; Possibly remove from cache, if that is used.
10083 (when gnus-use-cache
10084 (gnus-cache-enter-remove-article article))
10087 (defun gnus-mark-article-as-unread (article &optional mark)
10088 "Enter ARTICLE in the pertinent lists and remove it from others."
10089 (let ((mark (or mark gnus-ticked-mark)))
10090 (if (<= article 0)
10091 (progn
10092 (gnus-error 1 "Can't mark negative article numbers")
10093 nil)
10094 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
10095 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
10096 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
10097 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
10098 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
10100 ;; Unsuppress duplicates?
10101 (when gnus-suppress-duplicates
10102 (gnus-dup-unsuppress-article article))
10104 (cond ((= mark gnus-ticked-mark)
10105 (setq gnus-newsgroup-marked
10106 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
10107 ((= mark gnus-spam-mark)
10108 (setq gnus-newsgroup-spam-marked
10109 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
10110 article)))
10111 ((= mark gnus-dormant-mark)
10112 (setq gnus-newsgroup-dormant
10113 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
10115 (setq gnus-newsgroup-unreads
10116 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
10117 (gnus-pull article gnus-newsgroup-reads)
10118 t)))
10120 (defalias 'gnus-summary-mark-as-unread-forward
10121 'gnus-summary-tick-article-forward)
10122 (make-obsolete 'gnus-summary-mark-as-unread-forward
10123 'gnus-summary-tick-article-forward)
10124 (defun gnus-summary-tick-article-forward (n)
10125 "Tick N articles forwards.
10126 If N is negative, tick backwards instead.
10127 The difference between N and the number of articles ticked is returned."
10128 (interactive "p")
10129 (gnus-summary-mark-forward n gnus-ticked-mark))
10131 (defalias 'gnus-summary-mark-as-unread-backward
10132 'gnus-summary-tick-article-backward)
10133 (make-obsolete 'gnus-summary-mark-as-unread-backward
10134 'gnus-summary-tick-article-backward)
10135 (defun gnus-summary-tick-article-backward (n)
10136 "Tick N articles backwards.
10137 The difference between N and the number of articles ticked is returned."
10138 (interactive "p")
10139 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
10141 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10142 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
10143 (defun gnus-summary-tick-article (&optional article clear-mark)
10144 "Mark current article as unread.
10145 Optional 1st argument ARTICLE specifies article number to be marked as unread.
10146 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
10147 (interactive)
10148 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
10149 gnus-ticked-mark)))
10151 (defun gnus-summary-mark-as-read-forward (n)
10152 "Mark N articles as read forwards.
10153 If N is negative, mark backwards instead.
10154 The difference between N and the actual number of articles marked is
10155 returned."
10156 (interactive "p")
10157 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
10159 (defun gnus-summary-mark-as-read-backward (n)
10160 "Mark the N articles as read backwards.
10161 The difference between N and the actual number of articles marked is
10162 returned."
10163 (interactive "p")
10164 (gnus-summary-mark-forward
10165 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
10167 (defun gnus-summary-mark-as-read (&optional article mark)
10168 "Mark current article as read.
10169 ARTICLE specifies the article to be marked as read.
10170 MARK specifies a string to be inserted at the beginning of the line."
10171 (gnus-summary-mark-article article mark))
10173 (defun gnus-summary-clear-mark-forward (n)
10174 "Clear marks from N articles forward.
10175 If N is negative, clear backward instead.
10176 The difference between N and the number of marks cleared is returned."
10177 (interactive "p")
10178 (gnus-summary-mark-forward n gnus-unread-mark))
10180 (defun gnus-summary-clear-mark-backward (n)
10181 "Clear marks from N articles backward.
10182 The difference between N and the number of marks cleared is returned."
10183 (interactive "p")
10184 (gnus-summary-mark-forward (- n) gnus-unread-mark))
10186 (defun gnus-summary-mark-unread-as-read ()
10187 "Intended to be used by `gnus-summary-mark-article-hook'."
10188 (when (memq gnus-current-article gnus-newsgroup-unreads)
10189 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
10191 (defun gnus-summary-mark-read-and-unread-as-read (&optional new-mark)
10192 "Intended to be used by `gnus-summary-mark-article-hook'."
10193 (let ((mark (gnus-summary-article-mark)))
10194 (when (or (gnus-unread-mark-p mark)
10195 (gnus-read-mark-p mark))
10196 (gnus-summary-mark-article gnus-current-article
10197 (or new-mark gnus-read-mark)))))
10199 (defun gnus-summary-mark-current-read-and-unread-as-read (&optional new-mark)
10200 "Intended to be used by `gnus-summary-mark-article-hook'."
10201 (let ((mark (gnus-summary-article-mark)))
10202 (when (or (gnus-unread-mark-p mark)
10203 (gnus-read-mark-p mark))
10204 (gnus-summary-mark-article (gnus-summary-article-number)
10205 (or new-mark gnus-read-mark)))))
10207 (defun gnus-summary-mark-unread-as-ticked ()
10208 "Intended to be used by `gnus-summary-mark-article-hook'."
10209 (when (memq gnus-current-article gnus-newsgroup-unreads)
10210 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
10212 (defun gnus-summary-mark-region-as-read (point mark all)
10213 "Mark all unread articles between point and mark as read.
10214 If given a prefix, mark all articles between point and mark as read,
10215 even ticked and dormant ones."
10216 (interactive "r\nP")
10217 (save-excursion
10218 (let (article)
10219 (goto-char point)
10220 (beginning-of-line)
10221 (while (and
10222 (< (point) mark)
10223 (progn
10224 (when (or all
10225 (memq (setq article (gnus-summary-article-number))
10226 gnus-newsgroup-unreads))
10227 (gnus-summary-mark-article article gnus-del-mark))
10229 (gnus-summary-find-next))))))
10231 (defun gnus-summary-mark-below (score mark)
10232 "Mark articles with score less than SCORE with MARK."
10233 (interactive "P\ncMark: ")
10234 (setq score (if score
10235 (prefix-numeric-value score)
10236 (or gnus-summary-default-score 0)))
10237 (save-excursion
10238 (set-buffer gnus-summary-buffer)
10239 (goto-char (point-min))
10240 (while
10241 (progn
10242 (and (< (gnus-summary-article-score) score)
10243 (gnus-summary-mark-article nil mark))
10244 (gnus-summary-find-next)))))
10246 (defun gnus-summary-kill-below (&optional score)
10247 "Mark articles with score below SCORE as read."
10248 (interactive "P")
10249 (gnus-summary-mark-below score gnus-killed-mark))
10251 (defun gnus-summary-clear-above (&optional score)
10252 "Clear all marks from articles with score above SCORE."
10253 (interactive "P")
10254 (gnus-summary-mark-above score gnus-unread-mark))
10256 (defun gnus-summary-tick-above (&optional score)
10257 "Tick all articles with score above SCORE."
10258 (interactive "P")
10259 (gnus-summary-mark-above score gnus-ticked-mark))
10261 (defun gnus-summary-mark-above (score mark)
10262 "Mark articles with score over SCORE with MARK."
10263 (interactive "P\ncMark: ")
10264 (setq score (if score
10265 (prefix-numeric-value score)
10266 (or gnus-summary-default-score 0)))
10267 (save-excursion
10268 (set-buffer gnus-summary-buffer)
10269 (goto-char (point-min))
10270 (while (and (progn
10271 (when (> (gnus-summary-article-score) score)
10272 (gnus-summary-mark-article nil mark))
10274 (gnus-summary-find-next)))))
10276 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
10277 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
10278 (defun gnus-summary-limit-include-expunged (&optional no-error)
10279 "Display all the hidden articles that were expunged for low scores."
10280 (interactive)
10281 (let ((buffer-read-only nil))
10282 (let ((scored gnus-newsgroup-scored)
10283 headers h)
10284 (while scored
10285 (unless (gnus-summary-article-header (caar scored))
10286 (and (setq h (gnus-number-to-header (caar scored)))
10287 (< (cdar scored) gnus-summary-expunge-below)
10288 (push h headers)))
10289 (setq scored (cdr scored)))
10290 (if (not headers)
10291 (when (not no-error)
10292 (error "No expunged articles hidden"))
10293 (goto-char (point-min))
10294 (push gnus-newsgroup-limit gnus-newsgroup-limits)
10295 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
10296 (mapcar (lambda (x) (push (mail-header-number x)
10297 gnus-newsgroup-limit))
10298 headers)
10299 (gnus-summary-prepare-unthreaded (nreverse headers))
10300 (goto-char (point-min))
10301 (gnus-summary-position-point)
10302 t))))
10304 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
10305 "Mark all unread articles in this newsgroup as read.
10306 If prefix argument ALL is non-nil, ticked and dormant articles will
10307 also be marked as read.
10308 If QUIETLY is non-nil, no questions will be asked.
10310 If TO-HERE is non-nil, it should be a point in the buffer. All
10311 articles before (after, if REVERSE is set) this point will be marked
10312 as read.
10314 Note that this function will only catch up the unread article
10315 in the current summary buffer limitation.
10317 The number of articles marked as read is returned."
10318 (interactive "P")
10319 (prog1
10320 (save-excursion
10321 (when (or quietly
10322 (not gnus-interactive-catchup) ;Without confirmation?
10323 gnus-expert-user
10324 (gnus-y-or-n-p
10325 (if all
10326 "Mark absolutely all articles as read? "
10327 "Mark all unread articles as read? ")))
10328 (if (and not-mark
10329 (not gnus-newsgroup-adaptive)
10330 (not gnus-newsgroup-auto-expire)
10331 (not gnus-suppress-duplicates)
10332 (or (not gnus-use-cache)
10333 (eq gnus-use-cache 'passive)))
10334 (progn
10335 (when all
10336 (setq gnus-newsgroup-marked nil
10337 gnus-newsgroup-spam-marked nil
10338 gnus-newsgroup-dormant nil))
10339 (setq gnus-newsgroup-unreads
10340 (gnus-sorted-nunion
10341 (gnus-intersection gnus-newsgroup-unreads
10342 gnus-newsgroup-downloadable)
10343 gnus-newsgroup-unfetched)))
10344 ;; We actually mark all articles as canceled, which we
10345 ;; have to do when using auto-expiry or adaptive scoring.
10346 (gnus-summary-show-all-threads)
10347 (if (and to-here reverse)
10348 (progn
10349 (goto-char to-here)
10350 (gnus-summary-mark-current-read-and-unread-as-read
10351 gnus-catchup-mark)
10352 (while (gnus-summary-find-next (not all))
10353 (gnus-summary-mark-article-as-read gnus-catchup-mark)))
10354 (when (gnus-summary-first-subject (not all))
10355 (while (and
10356 (if to-here (< (point) to-here) t)
10357 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10358 (gnus-summary-find-next (not all))))))
10359 (gnus-set-mode-line 'summary))
10361 (gnus-summary-position-point)))
10363 (defun gnus-summary-catchup-to-here (&optional all)
10364 "Mark all unticked articles before the current one as read.
10365 If ALL is non-nil, also mark ticked and dormant articles as read."
10366 (interactive "P")
10367 (save-excursion
10368 (gnus-save-hidden-threads
10369 (let ((beg (point)))
10370 ;; We check that there are unread articles.
10371 (when (or all (gnus-summary-find-prev))
10372 (gnus-summary-catchup all t beg)))))
10373 (gnus-summary-position-point))
10375 (defun gnus-summary-catchup-from-here (&optional all)
10376 "Mark all unticked articles after (and including) the current one as read.
10377 If ALL is non-nil, also mark ticked and dormant articles as read."
10378 (interactive "P")
10379 (save-excursion
10380 (gnus-save-hidden-threads
10381 (let ((beg (point)))
10382 ;; We check that there are unread articles.
10383 (when (or all (gnus-summary-find-next))
10384 (gnus-summary-catchup all t beg nil t)))))
10385 (gnus-summary-position-point))
10387 (defun gnus-summary-catchup-all (&optional quietly)
10388 "Mark all articles in this newsgroup as read.
10389 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10390 instead, which marks only unread articles as read."
10391 (interactive "P")
10392 (gnus-summary-catchup t quietly))
10394 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10395 "Mark all unread articles in this group as read, then exit.
10396 If prefix argument ALL is non-nil, all articles are marked as read.
10397 If QUIETLY is non-nil, no questions will be asked."
10398 (interactive "P")
10399 (when (gnus-summary-catchup all quietly nil 'fast)
10400 ;; Select next newsgroup or exit.
10401 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10402 (eq gnus-auto-select-next 'quietly))
10403 (gnus-summary-next-group nil)
10404 (gnus-summary-exit))))
10406 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10407 "Mark all articles in this newsgroup as read, and then exit.
10408 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10409 instead, which marks only unread articles as read."
10410 (interactive "P")
10411 (gnus-summary-catchup-and-exit t quietly))
10413 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10414 "Mark all articles in this group as read and select the next group.
10415 If given a prefix, mark all articles, unread as well as ticked, as
10416 read."
10417 (interactive "P")
10418 (save-excursion
10419 (gnus-summary-catchup all))
10420 (gnus-summary-next-group))
10423 ;;; with article
10426 (defmacro gnus-with-article (article &rest forms)
10427 "Select ARTICLE and perform FORMS in the original article buffer.
10428 Then replace the article with the result."
10429 `(progn
10430 ;; We don't want the article to be marked as read.
10431 (let (gnus-mark-article-hook)
10432 (gnus-summary-select-article t t nil ,article))
10433 (set-buffer gnus-original-article-buffer)
10434 ,@forms
10435 (if (not (gnus-check-backend-function
10436 'request-replace-article (car gnus-article-current)))
10437 (gnus-message 5 "Read-only group; not replacing")
10438 (unless (gnus-request-replace-article
10439 ,article (car gnus-article-current)
10440 (current-buffer) t)
10441 (error "Couldn't replace article")))
10442 ;; The cache and backlog have to be flushed somewhat.
10443 (when gnus-keep-backlog
10444 (gnus-backlog-remove-article
10445 (car gnus-article-current) (cdr gnus-article-current)))
10446 (when gnus-use-cache
10447 (gnus-cache-update-article
10448 (car gnus-article-current) (cdr gnus-article-current)))))
10450 (put 'gnus-with-article 'lisp-indent-function 1)
10451 (put 'gnus-with-article 'edebug-form-spec '(form body))
10453 ;; Thread-based commands.
10455 (defun gnus-summary-articles-in-thread (&optional article)
10456 "Return a list of all articles in the current thread.
10457 If ARTICLE is non-nil, return all articles in the thread that starts
10458 with that article."
10459 (let* ((article (or article (gnus-summary-article-number)))
10460 (data (gnus-data-find-list article))
10461 (top-level (gnus-data-level (car data)))
10462 (top-subject
10463 (cond ((null gnus-thread-operation-ignore-subject)
10464 (gnus-simplify-subject-re
10465 (mail-header-subject (gnus-data-header (car data)))))
10466 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10467 (gnus-simplify-subject-fuzzy
10468 (mail-header-subject (gnus-data-header (car data)))))
10469 (t nil)))
10470 (end-point (save-excursion
10471 (if (gnus-summary-go-to-next-thread)
10472 (point) (point-max))))
10473 articles)
10474 (while (and data
10475 (< (gnus-data-pos (car data)) end-point))
10476 (when (or (not top-subject)
10477 (string= top-subject
10478 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10479 (gnus-simplify-subject-fuzzy
10480 (mail-header-subject
10481 (gnus-data-header (car data))))
10482 (gnus-simplify-subject-re
10483 (mail-header-subject
10484 (gnus-data-header (car data)))))))
10485 (push (gnus-data-number (car data)) articles))
10486 (unless (and (setq data (cdr data))
10487 (> (gnus-data-level (car data)) top-level))
10488 (setq data nil)))
10489 ;; Return the list of articles.
10490 (nreverse articles)))
10492 (defun gnus-summary-rethread-current ()
10493 "Rethread the thread the current article is part of."
10494 (interactive)
10495 (let* ((gnus-show-threads t)
10496 (article (gnus-summary-article-number))
10497 (id (mail-header-id (gnus-summary-article-header)))
10498 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10499 (unless id
10500 (error "No article on the current line"))
10501 (gnus-rebuild-thread id)
10502 (gnus-summary-goto-subject article)))
10504 (defun gnus-summary-reparent-thread ()
10505 "Make the current article child of the marked (or previous) article.
10507 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10508 is non-nil or the Subject: of both articles are the same."
10509 (interactive)
10510 (unless (not (gnus-group-read-only-p))
10511 (error "The current newsgroup does not support article editing"))
10512 (unless (<= (length gnus-newsgroup-processable) 1)
10513 (error "No more than one article may be marked"))
10514 (save-window-excursion
10515 (let ((gnus-article-buffer " *reparent*")
10516 (current-article (gnus-summary-article-number))
10517 ;; First grab the marked article, otherwise one line up.
10518 (parent-article (if (not (null gnus-newsgroup-processable))
10519 (car gnus-newsgroup-processable)
10520 (save-excursion
10521 (if (eq (forward-line -1) 0)
10522 (gnus-summary-article-number)
10523 (error "Beginning of summary buffer"))))))
10524 (unless (not (eq current-article parent-article))
10525 (error "An article may not be self-referential"))
10526 (let ((message-id (mail-header-id
10527 (gnus-summary-article-header parent-article))))
10528 (unless (and message-id (not (equal message-id "")))
10529 (error "No message-id in desired parent"))
10530 (gnus-with-article current-article
10531 (save-restriction
10532 (goto-char (point-min))
10533 (message-narrow-to-head)
10534 (if (re-search-forward "^References: " nil t)
10535 (progn
10536 (re-search-forward "^[^ \t]" nil t)
10537 (forward-line -1)
10538 (end-of-line)
10539 (insert " " message-id))
10540 (insert "References: " message-id "\n"))))
10541 (set-buffer gnus-summary-buffer)
10542 (gnus-summary-unmark-all-processable)
10543 (gnus-summary-update-article current-article)
10544 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10545 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10546 (gnus-summary-rethread-current)
10547 (gnus-message 3 "Article %d is now the child of article %d"
10548 current-article parent-article)))))
10550 (defun gnus-summary-toggle-threads (&optional arg)
10551 "Toggle showing conversation threads.
10552 If ARG is positive number, turn showing conversation threads on."
10553 (interactive "P")
10554 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10555 (setq gnus-show-threads
10556 (if (null arg) (not gnus-show-threads)
10557 (> (prefix-numeric-value arg) 0)))
10558 (gnus-summary-prepare)
10559 (gnus-summary-goto-subject current)
10560 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10561 (gnus-summary-position-point)))
10563 (defun gnus-summary-show-all-threads ()
10564 "Show all threads."
10565 (interactive)
10566 (save-excursion
10567 (let ((buffer-read-only nil))
10568 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10569 (gnus-summary-position-point))
10571 (defun gnus-summary-show-thread ()
10572 "Show thread subtrees.
10573 Returns nil if no thread was there to be shown."
10574 (interactive)
10575 (let ((buffer-read-only nil)
10576 (orig (point))
10577 (end (gnus-point-at-eol))
10578 ;; Leave point at bol
10579 (beg (progn (beginning-of-line) (point))))
10580 (prog1
10581 ;; Any hidden lines here?
10582 (search-forward "\r" end t)
10583 (subst-char-in-region beg end ?\^M ?\n t)
10584 (goto-char orig)
10585 (gnus-summary-position-point))))
10587 (defun gnus-summary-maybe-hide-threads ()
10588 "If requested, hide the threads that should be hidden."
10589 (when (and gnus-show-threads
10590 gnus-thread-hide-subtree)
10591 (gnus-summary-hide-all-threads
10592 (if (or (consp gnus-thread-hide-subtree)
10593 (functionp gnus-thread-hide-subtree))
10594 (gnus-make-predicate gnus-thread-hide-subtree)
10595 nil))))
10597 ;;; Hiding predicates.
10599 (defun gnus-article-unread-p (header)
10600 (memq (mail-header-number header) gnus-newsgroup-unreads))
10602 (defun gnus-article-unseen-p (header)
10603 (memq (mail-header-number header) gnus-newsgroup-unseen))
10605 (defun gnus-map-articles (predicate articles)
10606 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10607 (apply 'gnus-or (mapcar predicate
10608 (mapcar 'gnus-summary-article-header articles))))
10610 (defun gnus-summary-hide-all-threads (&optional predicate)
10611 "Hide all thread subtrees.
10612 If PREDICATE is supplied, threads that satisfy this predicate
10613 will not be hidden."
10614 (interactive)
10615 (save-excursion
10616 (goto-char (point-min))
10617 (let ((end nil))
10618 (while (not end)
10619 (when (or (not predicate)
10620 (gnus-map-articles
10621 predicate (gnus-summary-article-children)))
10622 (gnus-summary-hide-thread))
10623 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10624 (gnus-summary-position-point))
10626 (defun gnus-summary-hide-thread ()
10627 "Hide thread subtrees.
10628 If PREDICATE is supplied, threads that satisfy this predicate
10629 will not be hidden.
10630 Returns nil if no threads were there to be hidden."
10631 (interactive)
10632 (let ((buffer-read-only nil)
10633 (start (point))
10634 (article (gnus-summary-article-number)))
10635 (goto-char start)
10636 ;; Go forward until either the buffer ends or the subthread
10637 ;; ends.
10638 (when (and (not (eobp))
10639 (or (zerop (gnus-summary-next-thread 1 t))
10640 (goto-char (point-max))))
10641 (prog1
10642 (if (and (> (point) start)
10643 (search-backward "\n" start t))
10644 (progn
10645 (subst-char-in-region start (point) ?\n ?\^M)
10646 (gnus-summary-goto-subject article))
10647 (goto-char start)
10648 nil)))))
10650 (defun gnus-summary-go-to-next-thread (&optional previous)
10651 "Go to the same level (or less) next thread.
10652 If PREVIOUS is non-nil, go to previous thread instead.
10653 Return the article number moved to, or nil if moving was impossible."
10654 (let ((level (gnus-summary-thread-level))
10655 (way (if previous -1 1))
10656 (beg (point)))
10657 (forward-line way)
10658 (while (and (not (eobp))
10659 (< level (gnus-summary-thread-level)))
10660 (forward-line way))
10661 (if (eobp)
10662 (progn
10663 (goto-char beg)
10664 nil)
10665 (setq beg (point))
10666 (prog1
10667 (gnus-summary-article-number)
10668 (goto-char beg)))))
10670 (defun gnus-summary-next-thread (n &optional silent)
10671 "Go to the same level next N'th thread.
10672 If N is negative, search backward instead.
10673 Returns the difference between N and the number of skips actually
10674 done.
10676 If SILENT, don't output messages."
10677 (interactive "p")
10678 (let ((backward (< n 0))
10679 (n (abs n)))
10680 (while (and (> n 0)
10681 (gnus-summary-go-to-next-thread backward))
10682 (decf n))
10683 (unless silent
10684 (gnus-summary-position-point))
10685 (when (and (not silent) (/= 0 n))
10686 (gnus-message 7 "No more threads"))
10689 (defun gnus-summary-prev-thread (n)
10690 "Go to the same level previous N'th thread.
10691 Returns the difference between N and the number of skips actually
10692 done."
10693 (interactive "p")
10694 (gnus-summary-next-thread (- n)))
10696 (defun gnus-summary-go-down-thread ()
10697 "Go down one level in the current thread."
10698 (let ((children (gnus-summary-article-children)))
10699 (when children
10700 (gnus-summary-goto-subject (car children)))))
10702 (defun gnus-summary-go-up-thread ()
10703 "Go up one level in the current thread."
10704 (let ((parent (gnus-summary-article-parent)))
10705 (when parent
10706 (gnus-summary-goto-subject parent))))
10708 (defun gnus-summary-down-thread (n)
10709 "Go down thread N steps.
10710 If N is negative, go up instead.
10711 Returns the difference between N and how many steps down that were
10712 taken."
10713 (interactive "p")
10714 (let ((up (< n 0))
10715 (n (abs n)))
10716 (while (and (> n 0)
10717 (if up (gnus-summary-go-up-thread)
10718 (gnus-summary-go-down-thread)))
10719 (setq n (1- n)))
10720 (gnus-summary-position-point)
10721 (when (/= 0 n)
10722 (gnus-message 7 "Can't go further"))
10725 (defun gnus-summary-up-thread (n)
10726 "Go up thread N steps.
10727 If N is negative, go down instead.
10728 Returns the difference between N and how many steps down that were
10729 taken."
10730 (interactive "p")
10731 (gnus-summary-down-thread (- n)))
10733 (defun gnus-summary-top-thread ()
10734 "Go to the top of the thread."
10735 (interactive)
10736 (while (gnus-summary-go-up-thread))
10737 (gnus-summary-article-number))
10739 (defun gnus-summary-kill-thread (&optional unmark)
10740 "Mark articles under current thread as read.
10741 If the prefix argument is positive, remove any kinds of marks.
10742 If the prefix argument is negative, tick articles instead."
10743 (interactive "P")
10744 (when unmark
10745 (setq unmark (prefix-numeric-value unmark)))
10746 (let ((articles (gnus-summary-articles-in-thread)))
10747 (save-excursion
10748 ;; Expand the thread.
10749 (gnus-summary-show-thread)
10750 ;; Mark all the articles.
10751 (while articles
10752 (gnus-summary-goto-subject (car articles))
10753 (cond ((null unmark)
10754 (gnus-summary-mark-article-as-read gnus-killed-mark))
10755 ((> unmark 0)
10756 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10758 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10759 (setq articles (cdr articles))))
10760 ;; Hide killed subtrees.
10761 (and (null unmark)
10762 gnus-thread-hide-killed
10763 (gnus-summary-hide-thread))
10764 ;; If marked as read, go to next unread subject.
10765 (when (null unmark)
10766 ;; Go to next unread subject.
10767 (gnus-summary-next-subject 1 t)))
10768 (gnus-set-mode-line 'summary))
10770 ;; Summary sorting commands
10772 (defun gnus-summary-sort-by-number (&optional reverse)
10773 "Sort the summary buffer by article number.
10774 Argument REVERSE means reverse order."
10775 (interactive "P")
10776 (gnus-summary-sort 'number reverse))
10778 (defun gnus-summary-sort-by-random (&optional reverse)
10779 "Randomize the order in the summary buffer.
10780 Argument REVERSE means to randomize in reverse order."
10781 (interactive "P")
10782 (gnus-summary-sort 'random reverse))
10784 (defun gnus-summary-sort-by-author (&optional reverse)
10785 "Sort the summary buffer by author name alphabetically.
10786 If `case-fold-search' is non-nil, case of letters is ignored.
10787 Argument REVERSE means reverse order."
10788 (interactive "P")
10789 (gnus-summary-sort 'author reverse))
10791 (defun gnus-summary-sort-by-subject (&optional reverse)
10792 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10793 If `case-fold-search' is non-nil, case of letters is ignored.
10794 Argument REVERSE means reverse order."
10795 (interactive "P")
10796 (gnus-summary-sort 'subject reverse))
10798 (defun gnus-summary-sort-by-date (&optional reverse)
10799 "Sort the summary buffer by date.
10800 Argument REVERSE means reverse order."
10801 (interactive "P")
10802 (gnus-summary-sort 'date reverse))
10804 (defun gnus-summary-sort-by-score (&optional reverse)
10805 "Sort the summary buffer by score.
10806 Argument REVERSE means reverse order."
10807 (interactive "P")
10808 (gnus-summary-sort 'score reverse))
10810 (defun gnus-summary-sort-by-lines (&optional reverse)
10811 "Sort the summary buffer by the number of lines.
10812 Argument REVERSE means reverse order."
10813 (interactive "P")
10814 (gnus-summary-sort 'lines reverse))
10816 (defun gnus-summary-sort-by-chars (&optional reverse)
10817 "Sort the summary buffer by article length.
10818 Argument REVERSE means reverse order."
10819 (interactive "P")
10820 (gnus-summary-sort 'chars reverse))
10822 (defun gnus-summary-sort-by-original (&optional reverse)
10823 "Sort the summary buffer using the default sorting method.
10824 Argument REVERSE means reverse order."
10825 (interactive "P")
10826 (let* ((buffer-read-only)
10827 (gnus-summary-prepare-hook nil))
10828 ;; We do the sorting by regenerating the threads.
10829 (gnus-summary-prepare)
10830 ;; Hide subthreads if needed.
10831 (gnus-summary-maybe-hide-threads)))
10833 (defun gnus-summary-sort (predicate reverse)
10834 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10835 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10836 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10837 (gnus-thread-sort-functions
10838 (if (not reverse)
10839 thread
10840 `(lambda (t1 t2)
10841 (,thread t2 t1))))
10842 (gnus-sort-gathered-threads-function
10843 gnus-thread-sort-functions)
10844 (gnus-article-sort-functions
10845 (if (not reverse)
10846 article
10847 `(lambda (t1 t2)
10848 (,article t2 t1))))
10849 (buffer-read-only)
10850 (gnus-summary-prepare-hook nil))
10851 ;; We do the sorting by regenerating the threads.
10852 (gnus-summary-prepare)
10853 ;; Hide subthreads if needed.
10854 (gnus-summary-maybe-hide-threads)))
10856 ;; Summary saving commands.
10858 (defun gnus-summary-save-article (&optional n not-saved)
10859 "Save the current article using the default saver function.
10860 If N is a positive number, save the N next articles.
10861 If N is a negative number, save the N previous articles.
10862 If N is nil and any articles have been marked with the process mark,
10863 save those articles instead.
10864 The variable `gnus-default-article-saver' specifies the saver function."
10865 (interactive "P")
10866 (let* ((articles (gnus-summary-work-articles n))
10867 (save-buffer (save-excursion
10868 (nnheader-set-temp-buffer " *Gnus Save*")))
10869 (num (length articles))
10870 header file)
10871 (dolist (article articles)
10872 (setq header (gnus-summary-article-header article))
10873 (if (not (vectorp header))
10874 ;; This is a pseudo-article.
10875 (if (assq 'name header)
10876 (gnus-copy-file (cdr (assq 'name header)))
10877 (gnus-message 1 "Article %d is unsaveable" article))
10878 ;; This is a real article.
10879 (save-window-excursion
10880 (let ((gnus-display-mime-function nil)
10881 (gnus-article-prepare-hook nil))
10882 (gnus-summary-select-article t nil nil article)))
10883 (save-excursion
10884 (set-buffer save-buffer)
10885 (erase-buffer)
10886 (insert-buffer-substring gnus-original-article-buffer))
10887 (setq file (gnus-article-save save-buffer file num))
10888 (gnus-summary-remove-process-mark article)
10889 (unless not-saved
10890 (gnus-summary-set-saved-mark article))))
10891 (gnus-kill-buffer save-buffer)
10892 (gnus-summary-position-point)
10893 (gnus-set-mode-line 'summary)
10896 (defun gnus-summary-pipe-output (&optional arg headers)
10897 "Pipe the current article to a subprocess.
10898 If N is a positive number, pipe the N next articles.
10899 If N is a negative number, pipe the N previous articles.
10900 If N is nil and any articles have been marked with the process mark,
10901 pipe those articles instead.
10902 If HEADERS (the symbolic prefix), include the headers, too."
10903 (interactive (gnus-interactive "P\ny"))
10904 (require 'gnus-art)
10905 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10906 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10907 (gnus-summary-save-article arg t))
10908 (let ((buffer (get-buffer "*Shell Command Output*")))
10909 (when (and buffer
10910 (not (zerop (buffer-size buffer))))
10911 (gnus-configure-windows 'pipe))))
10913 (defun gnus-summary-save-article-mail (&optional arg)
10914 "Append the current article to an mail file.
10915 If N is a positive number, save the N next articles.
10916 If N is a negative number, save the N previous articles.
10917 If N is nil and any articles have been marked with the process mark,
10918 save those articles instead."
10919 (interactive "P")
10920 (require 'gnus-art)
10921 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10922 (gnus-summary-save-article arg)))
10924 (defun gnus-summary-save-article-rmail (&optional arg)
10925 "Append the current article to an rmail file.
10926 If N is a positive number, save the N next articles.
10927 If N is a negative number, save the N previous articles.
10928 If N is nil and any articles have been marked with the process mark,
10929 save those articles instead."
10930 (interactive "P")
10931 (require 'gnus-art)
10932 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10933 (gnus-summary-save-article arg)))
10935 (defun gnus-summary-save-article-file (&optional arg)
10936 "Append the current article to a file.
10937 If N is a positive number, save the N next articles.
10938 If N is a negative number, save the N previous articles.
10939 If N is nil and any articles have been marked with the process mark,
10940 save those articles instead."
10941 (interactive "P")
10942 (require 'gnus-art)
10943 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10944 (gnus-summary-save-article arg)))
10946 (defun gnus-summary-write-article-file (&optional arg)
10947 "Write the current article to a file, deleting the previous file.
10948 If N is a positive number, save the N next articles.
10949 If N is a negative number, save the N previous articles.
10950 If N is nil and any articles have been marked with the process mark,
10951 save those articles instead."
10952 (interactive "P")
10953 (require 'gnus-art)
10954 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10955 (gnus-summary-save-article arg)))
10957 (defun gnus-summary-save-article-body-file (&optional arg)
10958 "Append the current article body to a file.
10959 If N is a positive number, save the N next articles.
10960 If N is a negative number, save the N previous articles.
10961 If N is nil and any articles have been marked with the process mark,
10962 save those articles instead."
10963 (interactive "P")
10964 (require 'gnus-art)
10965 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10966 (gnus-summary-save-article arg)))
10968 (defun gnus-summary-muttprint (&optional arg)
10969 "Print the current article using Muttprint.
10970 If N is a positive number, save the N next articles.
10971 If N is a negative number, save the N previous articles.
10972 If N is nil and any articles have been marked with the process mark,
10973 save those articles instead."
10974 (interactive "P")
10975 (require 'gnus-art)
10976 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10977 (gnus-summary-save-article arg t)))
10979 (defun gnus-summary-pipe-message (program)
10980 "Pipe the current article through PROGRAM."
10981 (interactive "sProgram: ")
10982 (gnus-summary-select-article)
10983 (let ((mail-header-separator ""))
10984 (gnus-eval-in-buffer-window gnus-article-buffer
10985 (save-restriction
10986 (widen)
10987 (let ((start (window-start))
10988 buffer-read-only)
10989 (message-pipe-buffer-body program)
10990 (set-window-start (get-buffer-window (current-buffer)) start))))))
10992 (defun gnus-get-split-value (methods)
10993 "Return a value based on the split METHODS."
10994 (let (split-name method result match)
10995 (when methods
10996 (save-excursion
10997 (set-buffer gnus-original-article-buffer)
10998 (save-restriction
10999 (nnheader-narrow-to-headers)
11000 (while (and methods (not split-name))
11001 (goto-char (point-min))
11002 (setq method (pop methods))
11003 (setq match (car method))
11004 (when (cond
11005 ((stringp match)
11006 ;; Regular expression.
11007 (ignore-errors
11008 (re-search-forward match nil t)))
11009 ((functionp match)
11010 ;; Function.
11011 (save-restriction
11012 (widen)
11013 (setq result (funcall match gnus-newsgroup-name))))
11014 ((consp match)
11015 ;; Form.
11016 (save-restriction
11017 (widen)
11018 (setq result (eval match)))))
11019 (setq split-name (cdr method))
11020 (cond ((stringp result)
11021 (push (expand-file-name
11022 result gnus-article-save-directory)
11023 split-name))
11024 ((consp result)
11025 (setq split-name (append result split-name)))))))))
11026 (nreverse split-name)))
11028 (defun gnus-valid-move-group-p (group)
11029 (and (boundp group)
11030 (symbol-name group)
11031 (symbol-value group)
11032 (gnus-get-function (gnus-find-method-for-group
11033 (symbol-name group)) 'request-accept-article t)))
11035 (defun gnus-read-move-group-name (prompt default articles prefix)
11036 "Read a group name."
11037 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
11038 (minibuffer-confirm-incomplete nil) ; XEmacs
11039 (prom
11040 (format "%s %s to:"
11041 prompt
11042 (if (> (length articles) 1)
11043 (format "these %d articles" (length articles))
11044 "this article")))
11045 (to-newsgroup
11046 (cond
11047 ((null split-name)
11048 (gnus-completing-read-with-default
11049 default prom
11050 gnus-active-hashtb
11051 'gnus-valid-move-group-p
11052 nil prefix
11053 'gnus-group-history))
11054 ((= 1 (length split-name))
11055 (gnus-completing-read-with-default
11056 (car split-name) prom
11057 gnus-active-hashtb
11058 'gnus-valid-move-group-p
11059 nil nil
11060 'gnus-group-history))
11062 (gnus-completing-read-with-default
11063 nil prom
11064 (mapcar (lambda (el) (list el))
11065 (nreverse split-name))
11066 nil nil nil
11067 'gnus-group-history))))
11068 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
11069 (when to-newsgroup
11070 (if (or (string= to-newsgroup "")
11071 (string= to-newsgroup prefix))
11072 (setq to-newsgroup default))
11073 (unless to-newsgroup
11074 (error "No group name entered"))
11075 (or (gnus-active to-newsgroup)
11076 (gnus-activate-group to-newsgroup nil nil to-method)
11077 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
11078 to-newsgroup))
11079 (or (and (gnus-request-create-group to-newsgroup to-method)
11080 (gnus-activate-group
11081 to-newsgroup nil nil to-method)
11082 (gnus-subscribe-group to-newsgroup))
11083 (error "Couldn't create group %s" to-newsgroup)))
11084 (error "No such group: %s" to-newsgroup)))
11085 to-newsgroup))
11087 (defun gnus-summary-save-parts (type dir n &optional reverse)
11088 "Save parts matching TYPE to DIR.
11089 If REVERSE, save parts that do not match TYPE."
11090 (interactive
11091 (list (read-string "Save parts of type: "
11092 (or (car gnus-summary-save-parts-type-history)
11093 gnus-summary-save-parts-default-mime)
11094 'gnus-summary-save-parts-type-history)
11095 (setq gnus-summary-save-parts-last-directory
11096 (read-file-name "Save to directory: "
11097 gnus-summary-save-parts-last-directory
11098 nil t))
11099 current-prefix-arg))
11100 (gnus-summary-iterate n
11101 (let ((gnus-display-mime-function nil)
11102 (gnus-inhibit-treatment t))
11103 (gnus-summary-select-article))
11104 (save-excursion
11105 (set-buffer gnus-article-buffer)
11106 (let ((handles (or gnus-article-mime-handles
11107 (mm-dissect-buffer nil gnus-article-loose-mime)
11108 (and gnus-article-emulate-mime
11109 (mm-uu-dissect)))))
11110 (when handles
11111 (gnus-summary-save-parts-1 type dir handles reverse)
11112 (unless gnus-article-mime-handles ;; Don't destroy this case.
11113 (mm-destroy-parts handles)))))))
11115 (defun gnus-summary-save-parts-1 (type dir handle reverse)
11116 (if (stringp (car handle))
11117 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
11118 (cdr handle))
11119 (when (if reverse
11120 (not (string-match type (mm-handle-media-type handle)))
11121 (string-match type (mm-handle-media-type handle)))
11122 (let ((file (expand-file-name
11123 (gnus-map-function
11124 mm-file-name-rewrite-functions
11125 (file-name-nondirectory
11127 (mail-content-type-get
11128 (mm-handle-disposition handle) 'filename)
11129 (mail-content-type-get
11130 (mm-handle-type handle) 'name)
11131 (concat gnus-newsgroup-name
11132 "." (number-to-string
11133 (cdr gnus-article-current))))))
11134 dir)))
11135 (unless (file-exists-p file)
11136 (mm-save-part-to-file handle file))))))
11138 ;; Summary extract commands
11140 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
11141 (let ((buffer-read-only nil)
11142 (article (gnus-summary-article-number))
11143 after-article b e)
11144 (unless (gnus-summary-goto-subject article)
11145 (error "No such article: %d" article))
11146 (gnus-summary-position-point)
11147 ;; If all commands are to be bunched up on one line, we collect
11148 ;; them here.
11149 (unless gnus-view-pseudos-separately
11150 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
11151 files action)
11152 (while ps
11153 (setq action (cdr (assq 'action (car ps))))
11154 (setq files (list (cdr (assq 'name (car ps)))))
11155 (while (and ps (cdr ps)
11156 (string= (or action "1")
11157 (or (cdr (assq 'action (cadr ps))) "2")))
11158 (push (cdr (assq 'name (cadr ps))) files)
11159 (setcdr ps (cddr ps)))
11160 (when files
11161 (when (not (string-match "%s" action))
11162 (push " " files))
11163 (push " " files)
11164 (when (assq 'execute (car ps))
11165 (setcdr (assq 'execute (car ps))
11166 (funcall (if (string-match "%s" action)
11167 'format 'concat)
11168 action
11169 (mapconcat
11170 (lambda (f)
11171 (if (equal f " ")
11173 (mm-quote-arg f)))
11174 files " ")))))
11175 (setq ps (cdr ps)))))
11176 (if (and gnus-view-pseudos (not not-view))
11177 (while pslist
11178 (when (assq 'execute (car pslist))
11179 (gnus-execute-command (cdr (assq 'execute (car pslist)))
11180 (eq gnus-view-pseudos 'not-confirm)))
11181 (setq pslist (cdr pslist)))
11182 (save-excursion
11183 (while pslist
11184 (setq after-article (or (cdr (assq 'article (car pslist)))
11185 (gnus-summary-article-number)))
11186 (gnus-summary-goto-subject after-article)
11187 (forward-line 1)
11188 (setq b (point))
11189 (insert " " (file-name-nondirectory
11190 (cdr (assq 'name (car pslist))))
11191 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
11192 (setq e (point))
11193 (forward-line -1) ; back to `b'
11194 (gnus-add-text-properties
11195 b (1- e) (list 'gnus-number gnus-reffed-article-number
11196 gnus-mouse-face-prop gnus-mouse-face))
11197 (gnus-data-enter
11198 after-article gnus-reffed-article-number
11199 gnus-unread-mark b (car pslist) 0 (- e b))
11200 (setq gnus-newsgroup-unreads
11201 (gnus-add-to-sorted-list gnus-newsgroup-unreads
11202 gnus-reffed-article-number))
11203 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
11204 (setq pslist (cdr pslist)))))))
11206 (defun gnus-pseudos< (p1 p2)
11207 (let ((c1 (cdr (assq 'action p1)))
11208 (c2 (cdr (assq 'action p2))))
11209 (and c1 c2 (string< c1 c2))))
11211 (defun gnus-request-pseudo-article (props)
11212 (cond ((assq 'execute props)
11213 (gnus-execute-command (cdr (assq 'execute props)))))
11214 (let ((gnus-current-article (gnus-summary-article-number)))
11215 (gnus-run-hooks 'gnus-mark-article-hook)))
11217 (defun gnus-execute-command (command &optional automatic)
11218 (save-excursion
11219 (gnus-article-setup-buffer)
11220 (set-buffer gnus-article-buffer)
11221 (setq buffer-read-only nil)
11222 (let ((command (if automatic command
11223 (read-string "Command: " (cons command 0)))))
11224 (erase-buffer)
11225 (insert "$ " command "\n\n")
11226 (if gnus-view-pseudo-asynchronously
11227 (start-process "gnus-execute" (current-buffer) shell-file-name
11228 shell-command-switch command)
11229 (call-process shell-file-name nil t nil
11230 shell-command-switch command)))))
11232 ;; Summary kill commands.
11234 (defun gnus-summary-edit-global-kill (article)
11235 "Edit the \"global\" kill file."
11236 (interactive (list (gnus-summary-article-number)))
11237 (gnus-group-edit-global-kill article))
11239 (defun gnus-summary-edit-local-kill ()
11240 "Edit a local kill file applied to the current newsgroup."
11241 (interactive)
11242 (setq gnus-current-headers (gnus-summary-article-header))
11243 (gnus-group-edit-local-kill
11244 (gnus-summary-article-number) gnus-newsgroup-name))
11246 ;;; Header reading.
11248 (defun gnus-read-header (id &optional header)
11249 "Read the headers of article ID and enter them into the Gnus system."
11250 (let ((group gnus-newsgroup-name)
11251 (gnus-override-method
11253 gnus-override-method
11254 (and (gnus-news-group-p gnus-newsgroup-name)
11255 (car (gnus-refer-article-methods)))))
11256 where)
11257 ;; First we check to see whether the header in question is already
11258 ;; fetched.
11259 (if (stringp id)
11260 ;; This is a Message-ID.
11261 (setq header (or header (gnus-id-to-header id)))
11262 ;; This is an article number.
11263 (setq header (or header (gnus-summary-article-header id))))
11264 (if (and header
11265 (not (gnus-summary-article-sparse-p (mail-header-number header))))
11266 ;; We have found the header.
11267 header
11268 ;; We have to really fetch the header to this article.
11269 (save-excursion
11270 (set-buffer nntp-server-buffer)
11271 (when (setq where (gnus-request-head id group))
11272 (nnheader-fold-continuation-lines)
11273 (goto-char (point-max))
11274 (insert ".\n")
11275 (goto-char (point-min))
11276 (insert "211 ")
11277 (princ (cond
11278 ((numberp id) id)
11279 ((cdr where) (cdr where))
11280 (header (mail-header-number header))
11281 (t gnus-reffed-article-number))
11282 (current-buffer))
11283 (insert " Article retrieved.\n"))
11284 (if (or (not where)
11285 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
11286 () ; Malformed head.
11287 (unless (gnus-summary-article-sparse-p (mail-header-number header))
11288 (when (and (stringp id)
11289 (not (string= (gnus-group-real-name group)
11290 (car where))))
11291 ;; If we fetched by Message-ID and the article came
11292 ;; from a different group, we fudge some bogus article
11293 ;; numbers for this article.
11294 (mail-header-set-number header gnus-reffed-article-number))
11295 (save-excursion
11296 (set-buffer gnus-summary-buffer)
11297 (decf gnus-reffed-article-number)
11298 (gnus-remove-header (mail-header-number header))
11299 (push header gnus-newsgroup-headers)
11300 (setq gnus-current-headers header)
11301 (push (mail-header-number header) gnus-newsgroup-limit)))
11302 header)))))
11304 (defun gnus-remove-header (number)
11305 "Remove header NUMBER from `gnus-newsgroup-headers'."
11306 (if (and gnus-newsgroup-headers
11307 (= number (mail-header-number (car gnus-newsgroup-headers))))
11308 (pop gnus-newsgroup-headers)
11309 (let ((headers gnus-newsgroup-headers))
11310 (while (and (cdr headers)
11311 (not (= number (mail-header-number (cadr headers)))))
11312 (pop headers))
11313 (when (cdr headers)
11314 (setcdr headers (cddr headers))))))
11317 ;;; summary highlights
11320 (defun gnus-highlight-selected-summary ()
11321 "Highlight selected article in summary buffer."
11322 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
11323 (when gnus-summary-selected-face
11324 (save-excursion
11325 (let* ((beg (gnus-point-at-bol))
11326 (end (gnus-point-at-eol))
11327 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
11328 (from (if (get-text-property beg gnus-mouse-face-prop)
11330 (or (next-single-property-change
11331 beg gnus-mouse-face-prop nil end)
11332 beg)))
11334 (if (= from end)
11335 (- from 2)
11336 (or (next-single-property-change
11337 from gnus-mouse-face-prop nil end)
11338 end))))
11339 ;; If no mouse-face prop on line we will have to = from = end,
11340 ;; so we highlight the entire line instead.
11341 (when (= (+ to 2) from)
11342 (setq from beg)
11343 (setq to end))
11344 (if gnus-newsgroup-selected-overlay
11345 ;; Move old overlay.
11346 (gnus-move-overlay
11347 gnus-newsgroup-selected-overlay from to (current-buffer))
11348 ;; Create new overlay.
11349 (gnus-overlay-put
11350 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11351 'face gnus-summary-selected-face))))))
11353 (defvar gnus-summary-highlight-line-cached nil)
11354 (defvar gnus-summary-highlight-line-trigger nil)
11356 (defun gnus-summary-highlight-line-0 ()
11357 (if (and (eq gnus-summary-highlight-line-trigger
11358 gnus-summary-highlight)
11359 gnus-summary-highlight-line-cached)
11360 gnus-summary-highlight-line-cached
11361 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11362 gnus-summary-highlight-line-cached
11363 (let* ((cond (list 'cond))
11364 (c cond)
11365 (list gnus-summary-highlight))
11366 (while list
11367 (setcdr c (cons (list (caar list) (list 'quote (cdar list)))
11368 nil))
11369 (setq c (cdr c)
11370 list (cdr list)))
11371 (gnus-byte-compile (list 'lambda nil cond))))))
11373 (defun gnus-summary-highlight-line ()
11374 "Highlight current line according to `gnus-summary-highlight'."
11375 (let* ((beg (gnus-point-at-bol))
11376 (article (or (gnus-summary-article-number) gnus-current-article))
11377 (score (or (cdr (assq article
11378 gnus-newsgroup-scored))
11379 gnus-summary-default-score 0))
11380 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11381 (inhibit-read-only t)
11382 (default gnus-summary-default-score)
11383 (default-high gnus-summary-default-high-score)
11384 (default-low gnus-summary-default-low-score)
11385 (uncached (and gnus-summary-use-undownloaded-faces
11386 (memq article gnus-newsgroup-undownloaded)
11387 (not (memq article gnus-newsgroup-cached)))))
11388 (let ((face (funcall (gnus-summary-highlight-line-0))))
11389 (unless (eq face (get-text-property beg 'face))
11390 (gnus-put-text-property-excluding-characters-with-faces
11391 beg (gnus-point-at-eol) 'face
11392 (setq face (if (boundp face) (symbol-value face) face)))
11393 (when gnus-summary-highlight-line-function
11394 (funcall gnus-summary-highlight-line-function article face))))))
11396 (defun gnus-update-read-articles (group unread &optional compute)
11397 "Update the list of read articles in GROUP.
11398 UNREAD is a sorted list."
11399 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11400 (entry (gnus-gethash group gnus-newsrc-hashtb))
11401 (info (nth 2 entry))
11402 (prev 1)
11403 read)
11404 (if (or (not info) (not active))
11405 ;; There is no info on this group if it was, in fact,
11406 ;; killed. Gnus stores no information on killed groups, so
11407 ;; there's nothing to be done.
11408 ;; One could store the information somewhere temporarily,
11409 ;; perhaps... Hmmm...
11411 ;; Remove any negative articles numbers.
11412 (while (and unread (< (car unread) 0))
11413 (setq unread (cdr unread)))
11414 ;; Remove any expired article numbers
11415 (while (and unread (< (car unread) (car active)))
11416 (setq unread (cdr unread)))
11417 ;; Compute the ranges of read articles by looking at the list of
11418 ;; unread articles.
11419 (while unread
11420 (when (/= (car unread) prev)
11421 (push (if (= prev (1- (car unread))) prev
11422 (cons prev (1- (car unread))))
11423 read))
11424 (setq prev (1+ (car unread)))
11425 (setq unread (cdr unread)))
11426 (when (<= prev (cdr active))
11427 (push (cons prev (cdr active)) read))
11428 (setq read (if (> (length read) 1) (nreverse read) read))
11429 (if compute
11430 read
11431 (save-excursion
11432 (let (setmarkundo)
11433 ;; Propagate the read marks to the backend.
11434 (when (gnus-check-backend-function 'request-set-mark group)
11435 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11436 (add (gnus-remove-from-range read (gnus-info-read info))))
11437 (when (or add del)
11438 (unless (gnus-check-group group)
11439 (error "Can't open server for %s" group))
11440 (gnus-request-set-mark
11441 group (delq nil (list (if add (list add 'add '(read)))
11442 (if del (list del 'del '(read))))))
11443 (setq setmarkundo
11444 `(gnus-request-set-mark
11445 ,group
11446 ',(delq nil (list
11447 (if del (list del 'add '(read)))
11448 (if add (list add 'del '(read))))))))))
11449 (set-buffer gnus-group-buffer)
11450 (gnus-undo-register
11451 `(progn
11452 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11453 (gnus-info-set-read ',info ',(gnus-info-read info))
11454 (gnus-get-unread-articles-in-group ',info
11455 (gnus-active ,group))
11456 (gnus-group-update-group ,group t)
11457 ,setmarkundo))))
11458 ;; Enter this list into the group info.
11459 (gnus-info-set-read info read)
11460 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11461 (gnus-get-unread-articles-in-group info (gnus-active group))
11462 t))))
11464 (defun gnus-offer-save-summaries ()
11465 "Offer to save all active summary buffers."
11466 (let (buffers)
11467 ;; Go through all buffers and find all summaries.
11468 (dolist (buffer (buffer-list))
11469 (when (and (setq buffer (buffer-name buffer))
11470 (string-match "Summary" buffer)
11471 (save-excursion
11472 (set-buffer buffer)
11473 ;; We check that this is, indeed, a summary buffer.
11474 (and (eq major-mode 'gnus-summary-mode)
11475 ;; Also make sure this isn't bogus.
11476 gnus-newsgroup-prepared
11477 ;; Also make sure that this isn't a
11478 ;; dead summary buffer.
11479 (not gnus-dead-summary-mode))))
11480 (push buffer buffers)))
11481 ;; Go through all these summary buffers and offer to save them.
11482 (when buffers
11483 (save-excursion
11484 (map-y-or-n-p
11485 "Update summary buffer %s? "
11486 (lambda (buf)
11487 (switch-to-buffer buf)
11488 (gnus-summary-exit))
11489 buffers)))))
11491 (defun gnus-summary-setup-default-charset ()
11492 "Setup newsgroup default charset."
11493 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11494 (setq gnus-newsgroup-charset nil)
11495 (let* ((ignored-charsets
11496 (or gnus-newsgroup-ephemeral-ignored-charsets
11497 (append
11498 (and gnus-newsgroup-name
11499 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11500 gnus-newsgroup-ignored-charsets))))
11501 (setq gnus-newsgroup-charset
11502 (or gnus-newsgroup-ephemeral-charset
11503 (and gnus-newsgroup-name
11504 (gnus-parameter-charset gnus-newsgroup-name))
11505 gnus-default-charset))
11506 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11507 ignored-charsets))))
11510 ;;; Mime Commands
11513 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11514 "Display the current article buffer fully MIME-buttonized.
11515 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11516 treated as multipart/mixed."
11517 (interactive "P")
11518 (require 'gnus-art)
11519 (let ((gnus-unbuttonized-mime-types nil)
11520 (gnus-mime-display-multipart-as-mixed show-all-parts))
11521 (gnus-summary-show-article)))
11523 (defun gnus-summary-repair-multipart (article)
11524 "Add a Content-Type header to a multipart article without one."
11525 (interactive (list (gnus-summary-article-number)))
11526 (gnus-with-article article
11527 (message-narrow-to-head)
11528 (message-remove-header "Mime-Version")
11529 (goto-char (point-max))
11530 (insert "Mime-Version: 1.0\n")
11531 (widen)
11532 (when (search-forward "\n--" nil t)
11533 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11534 (message-narrow-to-head)
11535 (message-remove-header "Content-Type")
11536 (goto-char (point-max))
11537 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11538 separator))
11539 (widen))))
11540 (let (gnus-mark-article-hook)
11541 (gnus-summary-select-article t t nil article)))
11543 (defun gnus-summary-toggle-display-buttonized ()
11544 "Toggle the buttonizing of the article buffer."
11545 (interactive)
11546 (require 'gnus-art)
11547 (if (setq gnus-inhibit-mime-unbuttonizing
11548 (not gnus-inhibit-mime-unbuttonizing))
11549 (let ((gnus-unbuttonized-mime-types nil))
11550 (gnus-summary-show-article))
11551 (gnus-summary-show-article)))
11554 ;;; Generic summary marking commands
11557 (defvar gnus-summary-marking-alist
11558 '((read gnus-del-mark "d")
11559 (unread gnus-unread-mark "u")
11560 (ticked gnus-ticked-mark "!")
11561 (dormant gnus-dormant-mark "?")
11562 (expirable gnus-expirable-mark "e"))
11563 "An alist of names/marks/keystrokes.")
11565 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11566 (defvar gnus-summary-mark-map)
11568 (defun gnus-summary-make-all-marking-commands ()
11569 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11570 (dolist (elem gnus-summary-marking-alist)
11571 (apply 'gnus-summary-make-marking-command elem)))
11573 (defun gnus-summary-make-marking-command (name mark keystroke)
11574 (let ((map (make-sparse-keymap)))
11575 (define-key gnus-summary-generic-mark-map keystroke map)
11576 (dolist (lway `((next "next" next nil "n")
11577 (next-unread "next unread" next t "N")
11578 (prev "previous" prev nil "p")
11579 (prev-unread "previous unread" prev t "P")
11580 (nomove "" nil nil ,keystroke)))
11581 (let ((func (gnus-summary-make-marking-command-1
11582 mark (car lway) lway name)))
11583 (setq func (eval func))
11584 (define-key map (nth 4 lway) func)))))
11586 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11587 `(defun ,(intern
11588 (format "gnus-summary-put-mark-as-%s%s"
11589 name (if (eq way 'nomove)
11591 (concat "-" (symbol-name way)))))
11593 ,(format
11594 "Mark the current article as %s%s.
11595 If N, the prefix, then repeat N times.
11596 If N is negative, move in reverse order.
11597 The difference between N and the actual number of articles marked is
11598 returned."
11599 name (cadr lway))
11600 (interactive "p")
11601 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11603 (defun gnus-summary-generic-mark (n mark move unread)
11604 "Mark N articles with MARK."
11605 (unless (eq major-mode 'gnus-summary-mode)
11606 (error "This command can only be used in the summary buffer"))
11607 (gnus-summary-show-thread)
11608 (let ((nummove
11609 (cond
11610 ((eq move 'next) 1)
11611 ((eq move 'prev) -1)
11612 (t 0))))
11613 (if (zerop nummove)
11614 (setq n 1)
11615 (when (< n 0)
11616 (setq n (abs n)
11617 nummove (* -1 nummove))))
11618 (while (and (> n 0)
11619 (gnus-summary-mark-article nil mark)
11620 (zerop (gnus-summary-next-subject nummove unread t)))
11621 (setq n (1- n)))
11622 (when (/= 0 n)
11623 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11624 (gnus-summary-recenter)
11625 (gnus-summary-position-point)
11626 (gnus-set-mode-line 'summary)
11629 (defun gnus-summary-insert-articles (articles)
11630 (when (setq articles
11631 (gnus-sorted-difference articles
11632 (mapcar (lambda (h)
11633 (mail-header-number h))
11634 gnus-newsgroup-headers)))
11635 (setq gnus-newsgroup-headers
11636 (gnus-merge 'list
11637 gnus-newsgroup-headers
11638 (gnus-fetch-headers articles)
11639 'gnus-article-sort-by-number))
11640 ;; Suppress duplicates?
11641 (when gnus-suppress-duplicates
11642 (gnus-dup-suppress-articles))
11644 ;; We might want to build some more threads first.
11645 (when (and gnus-fetch-old-headers
11646 (eq gnus-headers-retrieved-by 'nov))
11647 (if (eq gnus-fetch-old-headers 'invisible)
11648 (gnus-build-all-threads)
11649 (gnus-build-old-threads)))
11650 ;; Let the Gnus agent mark articles as read.
11651 (when gnus-agent
11652 (gnus-agent-get-undownloaded-list))
11653 ;; Remove list identifiers from subject
11654 (when gnus-list-identifiers
11655 (gnus-summary-remove-list-identifiers))
11656 ;; First and last article in this newsgroup.
11657 (when gnus-newsgroup-headers
11658 (setq gnus-newsgroup-begin
11659 (mail-header-number (car gnus-newsgroup-headers))
11660 gnus-newsgroup-end
11661 (mail-header-number
11662 (gnus-last-element gnus-newsgroup-headers))))
11663 (when gnus-use-scoring
11664 (gnus-possibly-score-headers))))
11666 (defun gnus-summary-insert-old-articles (&optional all)
11667 "Insert all old articles in this group.
11668 If ALL is non-nil, already read articles become readable.
11669 If ALL is a number, fetch this number of articles."
11670 (interactive "P")
11671 (prog1
11672 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11673 older len)
11674 (setq older
11675 ;; Some nntp servers lie about their active range. When
11676 ;; this happens, the active range can be in the millions.
11677 ;; Use a compressed range to avoid creating a huge list.
11678 (gnus-range-difference (list gnus-newsgroup-active) old))
11679 (setq len (gnus-range-length older))
11680 (cond
11681 ((null older) nil)
11682 ((numberp all)
11683 (if (< all len)
11684 (let ((older-range (nreverse older)))
11685 (setq older nil)
11687 (while (> all 0)
11688 (let* ((r (pop older-range))
11689 (min (if (numberp r) r (car r)))
11690 (max (if (numberp r) r (cdr r))))
11691 (while (and (<= min max)
11692 (> all 0))
11693 (push max older)
11694 (setq all (1- all)
11695 max (1- max))))))
11696 (setq older (gnus-uncompress-range older))))
11697 (all
11698 (setq older (gnus-uncompress-range older)))
11700 (when (and (numberp gnus-large-newsgroup)
11701 (> len gnus-large-newsgroup))
11702 (let* ((cursor-in-echo-area nil)
11703 (initial (gnus-parameter-large-newsgroup-initial
11704 gnus-newsgroup-name))
11705 (input
11706 (read-string
11707 (format
11708 "How many articles from %s (%s %d): "
11709 (gnus-limit-string
11710 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11711 (if initial "max" "default")
11712 len)
11713 (if initial
11714 (cons (number-to-string initial)
11715 0)))))
11716 (unless (string-match "^[ \t]*$" input)
11717 (setq all (string-to-number input))
11718 (if (< all len)
11719 (let ((older-range (nreverse older)))
11720 (setq older nil)
11722 (while (> all 0)
11723 (let* ((r (pop older-range))
11724 (min (if (numberp r) r (car r)))
11725 (max (if (numberp r) r (cdr r))))
11726 (while (and (<= min max)
11727 (> all 0))
11728 (push max older)
11729 (setq all (1- all)
11730 max (1- max))))))))))
11731 (setq older (gnus-uncompress-range older))))
11732 (if (not older)
11733 (message "No old news.")
11734 (gnus-summary-insert-articles older)
11735 (gnus-summary-limit (gnus-sorted-nunion old older))))
11736 (gnus-summary-position-point)))
11738 (defun gnus-summary-insert-new-articles ()
11739 "Insert all new articles in this group."
11740 (interactive)
11741 (prog1
11742 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11743 (old-active gnus-newsgroup-active)
11744 (nnmail-fetched-sources (list t))
11745 i new)
11746 (setq gnus-newsgroup-active
11747 (gnus-activate-group gnus-newsgroup-name 'scan))
11748 (setq i (cdr gnus-newsgroup-active))
11749 (while (> i (cdr old-active))
11750 (push i new)
11751 (decf i))
11752 (if (not new)
11753 (message "No gnus is bad news.")
11754 (gnus-summary-insert-articles new)
11755 (setq gnus-newsgroup-unreads
11756 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11757 (gnus-summary-limit (gnus-sorted-nunion old new))))
11758 (gnus-summary-position-point)))
11760 (gnus-summary-make-all-marking-commands)
11762 (gnus-ems-redefine)
11764 (provide 'gnus-sum)
11766 (run-hooks 'gnus-sum-load-hook)
11768 ;; Local Variables:
11769 ;; coding: iso-8859-1
11770 ;; End:
11772 ;;; arch-tag: 17c6748f-6d00-4d36-bf01-835c42f31235
11773 ;;; gnus-sum.el ends here