1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-make-false-root-always t
124 "Always make a false dummy root."
128 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
129 "*A regexp to match subjects to be excluded from loose thread gathering.
130 As loose thread gathering is done on subjects only, that means that
131 there can be many false gatherings performed. By rooting out certain
132 common subjects, gathering might become saner."
136 (defcustom gnus-summary-gather-subject-limit nil
137 "*Maximum length of subject comparisons when gathering loose threads.
138 Use nil to compare full subjects. Setting this variable to a low
139 number will help gather threads that have been corrupted by
140 newsreaders chopping off subject lines, but it might also mean that
141 unrelated articles that have subject that happen to begin with the
142 same few characters will be incorrectly gathered.
144 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
147 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "on" t)))
151 (defcustom gnus-simplify-subject-functions nil
152 "List of functions taking a string argument that simplify subjects.
153 The functions are applied recursively.
155 Useful functions to put in this list include:
156 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
157 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
159 :type '(repeat function))
161 (defcustom gnus-simplify-ignored-prefixes nil
162 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
164 :type '(choice (const :tag "off" nil)
167 (defcustom gnus-build-sparse-threads nil
168 "*If non-nil, fill in the gaps in threads.
169 If `some', only fill in the gaps that are needed to tie loose threads
170 together. If `more', fill in all leaf nodes that Gnus can find. If
171 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
173 :type '(choice (const :tag "off" nil)
176 (sexp :menu-tag "all" t)))
178 (defcustom gnus-summary-thread-gathering-function
179 'gnus-gather-threads-by-subject
180 "*Function used for gathering loose threads.
181 There are two pre-defined functions: `gnus-gather-threads-by-subject',
182 which only takes Subjects into consideration; and
183 `gnus-gather-threads-by-references', which compared the References
184 headers of the articles to find matches."
186 :type '(radio (function-item gnus-gather-threads-by-subject)
187 (function-item gnus-gather-threads-by-references)
188 (function :tag "other")))
190 (defcustom gnus-summary-same-subject ""
191 "*String indicating that the current article has the same subject as the previous.
192 This variable will only be used if the value of
193 `gnus-summary-make-false-root' is `empty'."
194 :group 'gnus-summary-format
197 (defcustom gnus-summary-goto-unread t
198 "*If t, many commands will go to the next unread article.
199 This applies to marking commands as well as other commands that
200 \"naturally\" select the next article, like, for instance, `SPC' at
201 the end of an article.
203 If nil, the marking commands do NOT go to the next unread article
204 \(they go to the next article instead). If `never', commands that
205 usually go to the next unread article, will go to the next article,
206 whether it is read or not."
207 :group 'gnus-summary-marks
208 :link '(custom-manual "(gnus)Setting Marks")
209 :type '(choice (const :tag "off" nil)
211 (sexp :menu-tag "on" t)))
213 (defcustom gnus-summary-default-score 0
214 "*Default article score level.
215 All scores generated by the score files will be added to this score.
216 If this variable is nil, scoring will be disabled."
217 :group 'gnus-score-default
218 :type '(choice (const :tag "disable")
221 (defcustom gnus-summary-default-high-score 0
222 "*Default threshold for a high scored article.
223 An article will be highlighted as high scored if its score is greater
225 :group 'gnus-score-default
228 (defcustom gnus-summary-default-low-score 0
229 "*Default threshold for a low scored article.
230 An article will be highlighted as low scored if its score is smaller
232 :group 'gnus-score-default
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'
239 :group 'gnus-summary-format
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."
248 :type '(repeat regexp))
250 (defcustom gnus-show-threads t
251 "*If non-nil, display threads in summary mode."
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."
264 (defcustom gnus-thread-hide-killed t
265 "*If non-nil, hide killed threads automatically."
269 (defcustom gnus-thread-ignore-subject t
270 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
271 If nil, articles that have different subjects from their parents will
272 start separate threads."
276 (defcustom gnus-thread-operation-ignore-subject t
277 "*If non-nil, subjects will be ignored when doing thread commands.
278 This affects commands like `gnus-summary-kill-thread' and
279 `gnus-summary-lower-thread'.
281 If this variable is nil, articles in the same thread with different
282 subjects will not be included in the operation in question. If this
283 variable is `fuzzy', only articles that have subjects that are fuzzily
284 equal will be included."
286 :type '(choice (const :tag "off" nil)
290 (defcustom gnus-thread-indent-level 4
291 "*Number that says how much each sub-thread should be indented."
295 (defcustom gnus-auto-extend-newsgroup t
296 "*If non-nil, extend newsgroup forward and backward when requested."
297 :group 'gnus-summary-choose
300 (defcustom gnus-auto-select-first t
301 "*If non-nil, select the article under point.
302 Which article this is is controlled by the `gnus-auto-select-subject'
305 If you want to prevent automatic selection of articles in some
306 newsgroups, set the variable to nil in `gnus-select-group-hook'."
307 :group 'gnus-group-select
308 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "first" t)))
311 (defcustom gnus-auto-select-subject 'unread
312 "*Says what subject to place under point when entering a group.
314 This variable can either be the symbols `first' (place point on the
315 first subject), `unread' (place point on the subject line of the first
316 unread article), `best' (place point on the subject line of the
317 higest-scored article), `unseen' (place point on the subject line of
318 the first unseen article), 'unseen-or-unread' (place point on the subject
319 line of the first unseen article or, if all article have been seen, on the
320 subject line of the first unread article), or a function to be called to
321 place point on some subject line."
322 :group 'gnus-group-select
323 :type '(choice (const best)
327 (const unseen-or-unread)))
329 (defcustom gnus-dont-select-after-jump-to-other-group nil
330 "If non-nil, don't select the first unread article after entering the
331 other group by the command `gnus-summary-jump-to-other-group'. If nil,
332 it is depend on the value of `gnus-auto-select-first' whether to select
334 :group 'gnus-group-select
337 (defcustom gnus-auto-select-next t
338 "*If non-nil, offer to go to the next group from the end of the previous.
339 If the value is t and the next newsgroup is empty, Gnus will exit
340 summary mode and go back to group mode. If the value is neither nil
341 nor t, Gnus will select the following unread newsgroup. In
342 particular, if the value is the symbol `quietly', the next unread
343 newsgroup will be selected without any confirmation, and if it is
344 `almost-quietly', the next group will be selected without any
345 confirmation if you are located on the last article in the group.
346 Finally, if this variable is `slightly-quietly', the `Z n' command
347 will go to the next group without confirmation."
348 :group 'gnus-summary-maneuvering
349 :type '(choice (const :tag "off" nil)
351 (const almost-quietly)
352 (const slightly-quietly)
353 (sexp :menu-tag "on" t)))
355 (defcustom gnus-auto-select-same nil
356 "*If non-nil, select the next article with the same subject.
357 If there are no more articles with the same subject, go to
358 the first unread article."
359 :group 'gnus-summary-maneuvering
362 (defcustom gnus-summary-check-current nil
363 "*If non-nil, consider the current article when moving.
364 The \"unread\" movement commands will stay on the same line if the
365 current article is unread."
366 :group 'gnus-summary-maneuvering
369 (defcustom gnus-auto-center-summary t
370 "*If non-nil, always center the current summary buffer.
371 In particular, if `vertical' do only vertical recentering. If non-nil
372 and non-`vertical', do both horizontal and vertical recentering."
373 :group 'gnus-summary-maneuvering
374 :type '(choice (const :tag "none" nil)
376 (integer :tag "height")
377 (sexp :menu-tag "both" t)))
379 (defcustom gnus-show-all-headers nil
380 "*If non-nil, don't hide any headers."
381 :group 'gnus-article-hiding
382 :group 'gnus-article-headers
385 (defcustom gnus-summary-ignore-duplicates nil
386 "*If non-nil, ignore articles with identical Message-ID headers."
390 (defcustom gnus-single-article-buffer t
391 "*If non-nil, display all articles in the same buffer.
392 If nil, each group will get its own article buffer."
393 :group 'gnus-article-various
396 (defcustom gnus-break-pages t
397 "*If non-nil, do page breaking on articles.
398 The page delimiter is specified by the `gnus-page-delimiter'
400 :group 'gnus-article-various
403 (defcustom gnus-show-mime t
404 "*If non-nil, do mime processing of articles.
405 The articles will simply be fed to the function given by
406 `gnus-article-display-method-for-mime'."
407 :group 'gnus-article-mime
410 (defcustom gnus-move-split-methods nil
411 "*Variable used to suggest where articles are to be moved to.
412 It uses the same syntax as the `gnus-split-methods' variable.
413 However, whereas `gnus-split-methods' specifies file names as targets,
414 this variable specifies group names."
415 :group 'gnus-summary-mail
416 :type '(repeat (choice (list :value (fun) function)
417 (cons :value ("" "") regexp (repeat string))
420 (defcustom gnus-unread-mark ?\ ;;;Whitespace
421 "*Mark used for unread articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-ticked-mark ?!
426 "*Mark used for ticked articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-dormant-mark ??
431 "*Mark used for dormant articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-del-mark ?r
436 "*Mark used for del'd articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-read-mark ?R
441 "*Mark used for read articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-expirable-mark ?E
446 "*Mark used for expirable articles."
447 :group 'gnus-summary-marks
450 (defcustom gnus-killed-mark ?K
451 "*Mark used for killed articles."
452 :group 'gnus-summary-marks
455 (defcustom gnus-spam-mark ?H
456 "*Mark used for spam articles."
457 :group 'gnus-summary-marks
460 (defcustom gnus-souped-mark ?F
461 "*Mark used for souped articles."
462 :group 'gnus-summary-marks
465 (defcustom gnus-kill-file-mark ?X
466 "*Mark used for articles killed by kill files."
467 :group 'gnus-summary-marks
470 (defcustom gnus-low-score-mark ?Y
471 "*Mark used for articles with a low score."
472 :group 'gnus-summary-marks
475 (defcustom gnus-catchup-mark ?C
476 "*Mark used for articles that are caught up."
477 :group 'gnus-summary-marks
480 (defcustom gnus-replied-mark ?A
481 "*Mark used for articles that have been replied to."
482 :group 'gnus-summary-marks
485 (defcustom gnus-forwarded-mark ?F
486 "*Mark used for articles that have been forwarded."
487 :group 'gnus-summary-marks
490 (defcustom gnus-recent-mark ?N
491 "*Mark used for articles that are recent."
492 :group 'gnus-summary-marks
495 (defcustom gnus-cached-mark ?*
496 "*Mark used for articles that are in the cache."
497 :group 'gnus-summary-marks
500 (defcustom gnus-saved-mark ?S
501 "*Mark used for articles that have been saved."
502 :group 'gnus-summary-marks
505 (defcustom gnus-unseen-mark ?.
506 "*Mark used for articles that haven't been seen."
507 :group 'gnus-summary-marks
510 (defcustom gnus-no-mark ?\ ;;;Whitespace
511 "*Mark used for articles that have no other secondary mark."
512 :group 'gnus-summary-marks
515 (defcustom gnus-ancient-mark ?O
516 "*Mark used for ancient articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-sparse-mark ?Q
521 "*Mark used for sparsely reffed articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-canceled-mark ?G
526 "*Mark used for canceled articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-duplicate-mark ?M
531 "*Mark used for duplicate articles."
532 :group 'gnus-summary-marks
535 (defcustom gnus-undownloaded-mark ?-
536 "*Mark used for articles that weren't downloaded."
537 :group 'gnus-summary-marks
540 (defcustom gnus-downloaded-mark ?+
541 "*Mark used for articles that were downloaded."
542 :group 'gnus-summary-marks
545 (defcustom gnus-downloadable-mark ?%
546 "*Mark used for articles that are to be downloaded."
547 :group 'gnus-summary-marks
550 (defcustom gnus-unsendable-mark ?=
551 "*Mark used for articles that won't be sent."
552 :group 'gnus-summary-marks
555 (defcustom gnus-score-over-mark ?+
556 "*Score mark used for articles with high scores."
557 :group 'gnus-summary-marks
560 (defcustom gnus-score-below-mark ?-
561 "*Score mark used for articles with low scores."
562 :group 'gnus-summary-marks
565 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
566 "*There is no thread under the article."
567 :group 'gnus-summary-marks
570 (defcustom gnus-not-empty-thread-mark ?=
571 "*There is a thread under the article."
572 :group 'gnus-summary-marks
575 (defcustom gnus-view-pseudo-asynchronously nil
576 "*If non-nil, Gnus will view pseudo-articles asynchronously."
577 :group 'gnus-extract-view
580 (defcustom gnus-auto-expirable-marks
581 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
582 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
583 gnus-souped-mark gnus-duplicate-mark)
584 "*The list of marks converted into expiration if a group is auto-expirable."
587 :type '(repeat character))
589 (defcustom gnus-inhibit-user-auto-expire t
590 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
595 (defcustom gnus-view-pseudos nil
596 "*If `automatic', pseudo-articles will be viewed automatically.
597 If `not-confirm', pseudos will be viewed automatically, and the user
598 will not be asked to confirm the command."
599 :group 'gnus-extract-view
600 :type '(choice (const :tag "off" nil)
602 (const not-confirm)))
604 (defcustom gnus-view-pseudos-separately t
605 "*If non-nil, one pseudo-article will be created for each file to be viewed.
606 If nil, all files that use the same viewing command will be given as a
607 list of parameters to that command."
608 :group 'gnus-extract-view
611 (defcustom gnus-insert-pseudo-articles t
612 "*If non-nil, insert pseudo-articles when decoding articles."
613 :group 'gnus-extract-view
616 (defcustom gnus-summary-dummy-line-format
618 "*The format specification for the dummy roots in the summary buffer.
619 It works along the same lines as a normal formatting string,
620 with some simple extensions.
624 General format specifiers can also be used.
625 See `(gnus)Formatting Variables'."
626 :link '(custom-manual "(gnus)Formatting Variables")
627 :group 'gnus-threading
630 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
631 "*The format specification for the summary mode line.
632 It works along the same lines as a normal formatting string,
633 with some simple extensions:
636 %p Unprefixed group name
637 %A Current article number
638 %z Current article score
640 %U Number of unread articles in the group
641 %e Number of unselected articles in the group
642 %Z A string with unread/unselected article counts
643 %g Shortish group name
644 %S Subject of the current article
646 %s Current score file name
647 %d Number of dormant articles
648 %r Number of articles that have been marked as read in this session
649 %E Number of articles expunged by the score files"
650 :group 'gnus-summary-format
653 (defcustom gnus-list-identifiers nil
654 "Regexp that matches list identifiers to be removed from subject.
655 This can also be a list of regexps."
657 :group 'gnus-summary-format
658 :group 'gnus-article-hiding
659 :type '(choice (const :tag "none" nil)
661 (repeat :value (".*") regexp)))
663 (defcustom gnus-summary-mark-below 0
664 "*Mark all articles with a score below this variable as read.
665 This variable is local to each summary buffer and usually set by the
667 :group 'gnus-score-default
670 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
671 "*List of functions used for sorting articles in the summary buffer.
673 Each function takes two articles and returns non-nil if the first
674 article should be sorted before the other. If you use more than one
675 function, the primary sort function should be the last. You should
676 probably always include `gnus-article-sort-by-number' in the list of
677 sorting functions -- preferably first. Also note that sorting by date
678 is often much slower than sorting by number, and the sorting order is
679 very similar. (Sorting by date means sorting by the time the message
680 was sent, sorting by number means sorting by arrival time.)
682 Ready-made functions include `gnus-article-sort-by-number',
683 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
684 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
685 and `gnus-article-sort-by-score'.
687 When threading is turned on, the variable `gnus-thread-sort-functions'
688 controls how articles are sorted."
689 :group 'gnus-summary-sort
690 :type '(repeat (choice (function-item gnus-article-sort-by-number)
691 (function-item gnus-article-sort-by-author)
692 (function-item gnus-article-sort-by-subject)
693 (function-item gnus-article-sort-by-date)
694 (function-item gnus-article-sort-by-score)
695 (function-item gnus-article-sort-by-random)
696 (function :tag "other"))))
698 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
699 "*List of functions used for sorting threads in the summary buffer.
700 By default, threads are sorted by article number.
702 Each function takes two threads and returns non-nil if the first
703 thread should be sorted before the other. If you use more than one
704 function, the primary sort function should be the last. You should
705 probably always include `gnus-thread-sort-by-number' in the list of
706 sorting functions -- preferably first. Also note that sorting by date
707 is often much slower than sorting by number, and the sorting order is
708 very similar. (Sorting by date means sorting by the time the message
709 was sent, sorting by number means sorting by arrival time.)
711 Ready-made functions include `gnus-thread-sort-by-number',
712 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
713 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
714 `gnus-thread-sort-by-most-recent-number',
715 `gnus-thread-sort-by-most-recent-date',
716 `gnus-thread-sort-by-random', and
717 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
719 When threading is turned off, the variable
720 `gnus-article-sort-functions' controls how articles are sorted."
721 :group 'gnus-summary-sort
722 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
723 (function-item gnus-thread-sort-by-author)
724 (function-item gnus-thread-sort-by-subject)
725 (function-item gnus-thread-sort-by-date)
726 (function-item gnus-thread-sort-by-score)
727 (function-item gnus-thread-sort-by-total-score)
728 (function-item gnus-thread-sort-by-random)
729 (function :tag "other"))))
731 (defcustom gnus-thread-score-function '+
732 "*Function used for calculating the total score of a thread.
734 The function is called with the scores of the article and each
735 subthread and should then return the score of the thread.
737 Some functions you can use are `+', `max', or `min'."
738 :group 'gnus-summary-sort
741 (defcustom gnus-summary-expunge-below nil
742 "All articles that have a score less than this variable will be expunged.
743 This variable is local to the summary buffers."
744 :group 'gnus-score-default
745 :type '(choice (const :tag "off" nil)
748 (defcustom gnus-thread-expunge-below nil
749 "All threads that have a total score less than this variable will be expunged.
750 See `gnus-thread-score-function' for en explanation of what a
753 This variable is local to the summary buffers."
754 :group 'gnus-threading
755 :group 'gnus-score-default
756 :type '(choice (const :tag "off" nil)
759 (defcustom gnus-summary-mode-hook nil
760 "*A hook for Gnus summary mode.
761 This hook is run before any variables are set in the summary buffer."
762 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
763 :group 'gnus-summary-various
766 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
767 (when (featurep 'xemacs)
768 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
769 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
770 (add-hook 'gnus-summary-mode-hook
771 'gnus-xmas-switch-horizontal-scrollbar-off))
773 (defcustom gnus-summary-menu-hook nil
774 "*Hook run after the creation of the summary mode menu."
775 :group 'gnus-summary-visual
778 (defcustom gnus-summary-exit-hook nil
779 "*A hook called on exit from the summary buffer.
780 It will be called with point in the group buffer."
781 :group 'gnus-summary-exit
784 (defcustom gnus-summary-prepare-hook nil
785 "*A hook called after the summary buffer has been generated.
786 If you want to modify the summary buffer, you can use this hook."
787 :group 'gnus-summary-various
790 (defcustom gnus-summary-prepared-hook nil
791 "*A hook called as the last thing after the summary buffer has been generated."
792 :group 'gnus-summary-various
795 (defcustom gnus-summary-generate-hook nil
796 "*A hook run just before generating the summary buffer.
797 This hook is commonly used to customize threading variables and the
799 :group 'gnus-summary-various
802 (defcustom gnus-select-group-hook nil
803 "*A hook called when a newsgroup is selected.
805 If you'd like to simplify subjects like the
806 `gnus-summary-next-same-subject' command does, you can use the
809 (add-hook gnus-select-group-hook
811 (mapcar (lambda (header)
812 (mail-header-set-subject
814 (gnus-simplify-subject
815 (mail-header-subject header) 're-only)))
816 gnus-newsgroup-headers)))"
817 :group 'gnus-group-select
820 (defcustom gnus-select-article-hook nil
821 "*A hook called when an article is selected."
822 :group 'gnus-summary-choose
825 (defcustom gnus-visual-mark-article-hook
826 (list 'gnus-highlight-selected-summary)
827 "*Hook run after selecting an article in the summary buffer.
828 It is meant to be used for highlighting the article in some way. It
829 is not run if `gnus-visual' is nil."
830 :group 'gnus-summary-visual
833 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
834 "*A hook called before parsing the headers."
838 (defcustom gnus-exit-group-hook nil
839 "*A hook called when exiting summary mode.
840 This hook is not called from the non-updating exit commands like `Q'."
844 (defcustom gnus-summary-update-hook
845 (list 'gnus-summary-highlight-line)
846 "*A hook called when a summary line is changed.
847 The hook will not be called if `gnus-visual' is nil.
849 The default function `gnus-summary-highlight-line' will
850 highlight the line according to the `gnus-summary-highlight'
852 :group 'gnus-summary-visual
855 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
856 "*A hook called when an article is selected for the first time.
857 The hook is intended to mark an article as read (or unread)
858 automatically when it is selected."
859 :group 'gnus-summary-choose
862 (defcustom gnus-group-no-more-groups-hook nil
863 "*A hook run when returning to group mode having no more (unread) groups."
864 :group 'gnus-group-select
867 (defcustom gnus-ps-print-hook nil
868 "*A hook run before ps-printing something from Gnus."
872 (defcustom gnus-summary-display-arrow
873 (and (fboundp 'display-graphic-p)
875 "*If non-nil, display an arrow highlighting the current article."
880 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
881 "Face used for highlighting the current article in the summary buffer."
882 :group 'gnus-summary-visual
885 (defvar gnus-tmp-downloaded nil)
887 (defcustom gnus-summary-highlight
888 '(((eq mark gnus-canceled-mark)
889 . gnus-summary-cancelled-face)
890 ((and uncached (> score default-high))
891 . gnus-summary-high-uncached-face)
892 ((and uncached (< score default-low))
893 . gnus-summary-low-uncached-face)
895 . gnus-summary-normal-uncached-face)
896 ((and (> score default-high)
897 (or (eq mark gnus-dormant-mark)
898 (eq mark gnus-ticked-mark)))
899 . gnus-summary-high-ticked-face)
900 ((and (< score default-low)
901 (or (eq mark gnus-dormant-mark)
902 (eq mark gnus-ticked-mark)))
903 . gnus-summary-low-ticked-face)
904 ((or (eq mark gnus-dormant-mark)
905 (eq mark gnus-ticked-mark))
906 . gnus-summary-normal-ticked-face)
907 ((and (> score default-high) (eq mark gnus-ancient-mark))
908 . gnus-summary-high-ancient-face)
909 ((and (< score default-low) (eq mark gnus-ancient-mark))
910 . gnus-summary-low-ancient-face)
911 ((eq mark gnus-ancient-mark)
912 . gnus-summary-normal-ancient-face)
913 ((and (> score default-high) (eq mark gnus-unread-mark))
914 . gnus-summary-high-unread-face)
915 ((and (< score default-low) (eq mark gnus-unread-mark))
916 . gnus-summary-low-unread-face)
917 ((eq mark gnus-unread-mark)
918 . gnus-summary-normal-unread-face)
919 ((> score default-high)
920 . gnus-summary-high-read-face)
921 ((< score default-low)
922 . gnus-summary-low-read-face)
924 . gnus-summary-normal-read-face))
925 "*Controls the highlighting of summary buffer lines.
927 A list of (FORM . FACE) pairs. When deciding how a a particular
928 summary line should be displayed, each form is evaluated. The content
929 of the face field after the first true form is used. You can change
930 how those summary lines are displayed, by editing the face field.
932 You can use the following variables in the FORM field.
934 score: The article's score
935 default: The default article score.
936 default-high: The default score for high scored articles.
937 default-low: The default score for low scored articles.
938 below: The score below which articles are automatically marked as read.
939 mark: The articles mark."
940 :group 'gnus-summary-visual
941 :type '(repeat (cons (sexp :tag "Form" nil)
944 (defcustom gnus-alter-header-function nil
945 "Function called to allow alteration of article header structures.
946 The function is called with one parameter, the article header vector,
947 which it may alter in any way.")
949 (defvar gnus-decode-encoded-word-function
950 (mime-find-field-decoder 'From 'nov)
951 "Variable that says which function should be used to decode a string with encoded words.")
953 (defcustom gnus-extra-headers '(To Newsgroups)
954 "*Extra headers to parse."
957 :type '(repeat symbol))
959 (defcustom gnus-ignored-from-addresses
960 (and user-mail-address (regexp-quote user-mail-address))
961 "*Regexp of From headers that may be suppressed in favor of To headers."
966 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
967 "List of charsets that should be ignored.
968 When these charsets are used in the \"charset\" parameter, the
969 default charset will be used instead."
971 :type '(repeat symbol)
972 :group 'gnus-charset)
974 (gnus-define-group-parameter
978 "Return the ignored charsets of GROUP."
979 :variable gnus-group-ignored-charsets-alist
981 '(("alt\\.chinese\\.text" iso-8859-1))
983 "Alist of regexps (to match group names) and charsets that should be ignored.
984 When these charsets are used in the \"charset\" parameter, the
985 default charset will be used instead."
986 :variable-group gnus-charset
987 :variable-type '(repeat (cons (regexp :tag "Group")
989 :parameter-type '(choice :tag "Ignored charsets"
992 :parameter-document "\
993 List of charsets that should be ignored.
995 When these charsets are used in the \"charset\" parameter, the
996 default charset will be used instead.")
998 (defcustom gnus-group-highlight-words-alist nil
999 "Alist of group regexps and highlight regexps.
1000 This variable uses the same syntax as `gnus-emphasis-alist'."
1002 :type '(repeat (cons (regexp :tag "Group")
1003 (repeat (list (regexp :tag "Highlight regexp")
1004 (number :tag "Group for entire word" 0)
1005 (number :tag "Group for displayed part" 0)
1007 gnus-emphasis-highlight-words)))))
1008 :group 'gnus-summary-visual)
1010 (defcustom gnus-use-wheel nil
1011 "Use Intelli-mouse on summary movement"
1013 :group 'gnus-summary-maneuvering)
1015 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1016 "Amount to scroll messages by spinning the mouse wheel.
1017 This is actually a cons cell, where the first item is the amount to scroll
1018 on a normal wheel event, and the second is the amount to scroll when the
1019 wheel is moved with the shift key depressed."
1020 :type '(cons (integer :tag "Shift") integer)
1021 :group 'gnus-summary-maneuvering)
1023 (defcustom gnus-wheel-edge-resistance 2
1024 "How hard it should be to change the current article
1025 by moving the mouse over the edge of the article window."
1027 :group 'gnus-summary-maneuvering)
1029 (defcustom gnus-summary-show-article-charset-alist
1031 "Alist of number and charset.
1032 The article will be shown with the charset corresponding to the
1034 For example: ((1 . cn-gb-2312) (2 . big5))."
1036 :type '(repeat (cons (number :tag "Argument" 1)
1037 (symbol :tag "Charset")))
1038 :group 'gnus-charset)
1040 (defcustom gnus-preserve-marks t
1041 "Whether marks are preserved when moving, copying and respooling messages."
1044 :group 'gnus-summary-marks)
1046 (defcustom gnus-alter-articles-to-read-function nil
1047 "Function to be called to alter the list of articles to be selected."
1048 :type '(choice (const nil) function)
1049 :group 'gnus-summary)
1051 (defcustom gnus-orphan-score nil
1052 "*All orphans get this score added. Set in the score file."
1053 :group 'gnus-score-default
1054 :type '(choice (const nil)
1057 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1058 "*A regexp to match MIME parts when saving multiple parts of a message
1059 with gnus-summary-save-parts (X m). This regexp will be used by default
1060 when prompting the user for which type of files to save."
1061 :group 'gnus-summary
1064 (defcustom gnus-read-all-available-headers nil
1065 "Whether Gnus should parse all headers made available to it.
1066 This is mostly relevant for slow backends where the user may
1067 wish to widen the summary buffer to include all headers
1068 that were fetched. Say, for nnultimate groups."
1069 :group 'gnus-summary
1070 :type '(choice boolean regexp))
1072 (defcustom gnus-summary-muttprint-program "muttprint"
1073 "Command (and optional arguments) used to run Muttprint."
1075 :group 'gnus-summary
1078 (defcustom gnus-article-loose-mime nil
1079 "If non-nil, don't require MIME-Version header.
1080 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1081 supply the MIME-Version header or deliberately strip it From the mail.
1082 Set it to non-nil, Gnus will treat some articles as MIME even if
1083 the MIME-Version header is missed."
1086 :group 'gnus-article)
1088 ;;; Internal variables
1090 (defvar gnus-summary-display-cache nil)
1091 (defvar gnus-article-mime-handles nil)
1092 (defvar gnus-article-decoded-p nil)
1093 (defvar gnus-article-charset nil)
1094 (defvar gnus-article-ignored-charsets nil)
1095 (defvar gnus-scores-exclude-files nil)
1096 (defvar gnus-page-broken nil)
1098 (defvar gnus-original-article nil)
1099 (defvar gnus-article-internal-prepare-hook nil)
1100 (defvar gnus-newsgroup-process-stack nil)
1102 (defvar gnus-thread-indent-array nil)
1103 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1104 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1105 "Function called to sort the articles within a thread after it has been gathered together.")
1107 (defvar gnus-summary-save-parts-type-history nil)
1108 (defvar gnus-summary-save-parts-last-directory nil)
1110 ;; Avoid highlighting in kill files.
1111 (defvar gnus-summary-inhibit-highlight nil)
1112 (defvar gnus-newsgroup-selected-overlay nil)
1113 (defvar gnus-inhibit-limiting nil)
1114 (defvar gnus-newsgroup-adaptive-score-file nil)
1115 (defvar gnus-current-score-file nil)
1116 (defvar gnus-current-move-group nil)
1117 (defvar gnus-current-copy-group nil)
1118 (defvar gnus-current-crosspost-group nil)
1119 (defvar gnus-newsgroup-display nil)
1121 (defvar gnus-newsgroup-dependencies nil)
1122 (defvar gnus-newsgroup-adaptive nil)
1123 (defvar gnus-summary-display-article-function nil)
1124 (defvar gnus-summary-highlight-line-function nil
1125 "Function called after highlighting a summary line.")
1127 (defvar gnus-summary-line-format-alist
1128 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1129 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1130 (?s gnus-tmp-subject-or-nil ?s)
1131 (?n gnus-tmp-name ?s)
1132 (?A (std11-address-string
1133 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1134 (?a (or (std11-full-name-string
1135 (car (mime-entity-read-field gnus-tmp-header 'From)))
1137 (?F gnus-tmp-from ?s)
1138 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1139 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1140 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1141 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1142 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1143 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1144 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1145 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1146 (?L gnus-tmp-lines ?s)
1147 (?O gnus-tmp-downloaded ?c)
1148 (?I gnus-tmp-indentation ?s)
1149 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1150 (?R gnus-tmp-replied ?c)
1151 (?\[ gnus-tmp-opening-bracket ?c)
1152 (?\] gnus-tmp-closing-bracket ?c)
1153 (?\> (make-string gnus-tmp-level ? ) ?s)
1154 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1155 (?i gnus-tmp-score ?d)
1156 (?z gnus-tmp-score-char ?c)
1157 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1158 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1159 (?U gnus-tmp-unread ?c)
1160 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1162 (?t (gnus-summary-number-of-articles-in-thread
1163 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1165 (?e (gnus-summary-number-of-articles-in-thread
1166 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1168 (?u gnus-tmp-user-defined ?s)
1169 (?P (gnus-pick-line-number) ?d)
1170 (?B gnus-tmp-thread-tree-header-string ?s)
1171 (user-date (gnus-user-date
1172 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1173 "An alist of format specifications that can appear in summary lines.
1174 These are paired with what variables they correspond with, along with
1175 the type of the variable (string, integer, character, etc).")
1177 (defvar gnus-summary-dummy-line-format-alist
1178 `((?S gnus-tmp-subject ?s)
1179 (?N gnus-tmp-number ?d)
1180 (?u gnus-tmp-user-defined ?s)))
1182 (defvar gnus-summary-mode-line-format-alist
1183 `((?G gnus-tmp-group-name ?s)
1184 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1185 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1186 (?A gnus-tmp-article-number ?d)
1187 (?Z gnus-tmp-unread-and-unselected ?s)
1188 (?V gnus-version ?s)
1189 (?U gnus-tmp-unread-and-unticked ?d)
1190 (?S gnus-tmp-subject ?s)
1191 (?e gnus-tmp-unselected ?d)
1192 (?u gnus-tmp-user-defined ?s)
1193 (?d (length gnus-newsgroup-dormant) ?d)
1194 (?t (length gnus-newsgroup-marked) ?d)
1195 (?h (length gnus-newsgroup-spam-marked) ?d)
1196 (?r (length gnus-newsgroup-reads) ?d)
1197 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1198 (?E gnus-newsgroup-expunged-tally ?d)
1199 (?s (gnus-current-score-file-nondirectory) ?s)))
1201 (defvar gnus-last-search-regexp nil
1202 "Default regexp for article search command.")
1204 (defvar gnus-summary-search-article-matched-data nil
1205 "Last matched data of article search command. It is the local variable
1206 in `gnus-article-buffer' which consists of the list of start position,
1207 end position and text.")
1209 (defvar gnus-last-shell-command nil
1210 "Default shell command on article.")
1212 (defvar gnus-newsgroup-agentized nil
1213 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1214 (defvar gnus-newsgroup-begin nil)
1215 (defvar gnus-newsgroup-end nil)
1216 (defvar gnus-newsgroup-last-rmail nil)
1217 (defvar gnus-newsgroup-last-mail nil)
1218 (defvar gnus-newsgroup-last-folder nil)
1219 (defvar gnus-newsgroup-last-file nil)
1220 (defvar gnus-newsgroup-auto-expire nil)
1221 (defvar gnus-newsgroup-active nil)
1223 (defvar gnus-newsgroup-data nil)
1224 (defvar gnus-newsgroup-data-reverse nil)
1225 (defvar gnus-newsgroup-limit nil)
1226 (defvar gnus-newsgroup-limits nil)
1228 (defvar gnus-newsgroup-unreads nil
1229 "Sorted list of unread articles in the current newsgroup.")
1231 (defvar gnus-newsgroup-unselected nil
1232 "Sorted list of unselected unread articles in the current newsgroup.")
1234 (defvar gnus-newsgroup-reads nil
1235 "Alist of read articles and article marks in the current newsgroup.")
1237 (defvar gnus-newsgroup-expunged-tally nil)
1239 (defvar gnus-newsgroup-marked nil
1240 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1242 (defvar gnus-newsgroup-spam-marked nil
1243 "List of ranges of articles that have been marked as spam.")
1245 (defvar gnus-newsgroup-killed nil
1246 "List of ranges of articles that have been through the scoring process.")
1248 (defvar gnus-newsgroup-cached nil
1249 "Sorted list of articles that come from the article cache.")
1251 (defvar gnus-newsgroup-saved nil
1252 "List of articles that have been saved.")
1254 (defvar gnus-newsgroup-kill-headers nil)
1256 (defvar gnus-newsgroup-replied nil
1257 "List of articles that have been replied to in the current newsgroup.")
1259 (defvar gnus-newsgroup-forwarded nil
1260 "List of articles that have been forwarded in the current newsgroup.")
1262 (defvar gnus-newsgroup-recent nil
1263 "List of articles that have are recent in the current newsgroup.")
1265 (defvar gnus-newsgroup-expirable nil
1266 "Sorted list of articles in the current newsgroup that can be expired.")
1268 (defvar gnus-newsgroup-processable nil
1269 "List of articles in the current newsgroup that can be processed.")
1271 (defvar gnus-newsgroup-downloadable nil
1272 "Sorted list of articles in the current newsgroup that can be processed.")
1274 (defvar gnus-newsgroup-undownloaded nil
1275 "List of articles in the current newsgroup that haven't been downloaded..")
1277 (defvar gnus-newsgroup-unsendable nil
1278 "List of articles in the current newsgroup that won't be sent.")
1280 (defvar gnus-newsgroup-bookmarks nil
1281 "List of articles in the current newsgroup that have bookmarks.")
1283 (defvar gnus-newsgroup-dormant nil
1284 "Sorted list of dormant articles in the current newsgroup.")
1286 (defvar gnus-newsgroup-unseen nil
1287 "List of unseen articles in the current newsgroup.")
1289 (defvar gnus-newsgroup-seen nil
1290 "Range of seen articles in the current newsgroup.")
1292 (defvar gnus-newsgroup-articles nil
1293 "List of articles in the current newsgroup.")
1295 (defvar gnus-newsgroup-scored nil
1296 "List of scored articles in the current newsgroup.")
1298 (defvar gnus-newsgroup-incorporated nil
1299 "List of incorporated articles in the current newsgroup.")
1301 (defvar gnus-newsgroup-headers nil
1302 "List of article headers in the current newsgroup.")
1304 (defvar gnus-newsgroup-threads nil)
1306 (defvar gnus-newsgroup-prepared nil
1307 "Whether the current group has been prepared properly.")
1309 (defvar gnus-newsgroup-ancient nil
1310 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1312 (defvar gnus-newsgroup-sparse nil)
1314 (defvar gnus-current-article nil)
1315 (defvar gnus-article-current nil)
1316 (defvar gnus-current-headers nil)
1317 (defvar gnus-have-all-headers nil)
1318 (defvar gnus-last-article nil)
1319 (defvar gnus-newsgroup-history nil)
1320 (defvar gnus-newsgroup-charset nil)
1321 (defvar gnus-newsgroup-ephemeral-charset nil)
1322 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1324 (defvar gnus-article-before-search nil)
1326 (defconst gnus-summary-local-variables
1327 '(gnus-newsgroup-name
1328 gnus-newsgroup-begin gnus-newsgroup-end
1329 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1330 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1331 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1332 gnus-newsgroup-unselected gnus-newsgroup-marked
1333 gnus-newsgroup-spam-marked
1334 gnus-newsgroup-reads gnus-newsgroup-saved
1335 gnus-newsgroup-replied gnus-newsgroup-forwarded
1336 gnus-newsgroup-recent
1337 gnus-newsgroup-expirable
1338 gnus-newsgroup-processable gnus-newsgroup-killed
1339 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1340 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1341 gnus-newsgroup-seen gnus-newsgroup-articles
1342 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1343 gnus-newsgroup-headers gnus-newsgroup-threads
1344 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1345 gnus-current-article gnus-current-headers gnus-have-all-headers
1346 gnus-last-article gnus-article-internal-prepare-hook
1347 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1348 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1349 gnus-thread-expunge-below
1350 gnus-score-alist gnus-current-score-file
1351 (gnus-summary-expunge-below . global)
1352 (gnus-summary-mark-below . global)
1353 (gnus-orphan-score . global)
1354 gnus-newsgroup-active gnus-scores-exclude-files
1355 gnus-newsgroup-history gnus-newsgroup-ancient
1356 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1357 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1358 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1359 (gnus-newsgroup-expunged-tally . 0)
1360 gnus-cache-removable-articles gnus-newsgroup-cached
1361 gnus-newsgroup-data gnus-newsgroup-data-reverse
1362 gnus-newsgroup-limit gnus-newsgroup-limits
1363 gnus-newsgroup-charset gnus-newsgroup-display
1364 gnus-newsgroup-incorporated)
1365 "Variables that are buffer-local to the summary buffers.")
1367 (defvar gnus-newsgroup-variables nil
1368 "A list of variables that have separate values in different newsgroups.
1369 A list of newsgroup (summary buffer) local variables, or cons of
1370 variables and their default values (when the default values are not
1371 nil), that should be made global while the summary buffer is active.
1372 These variables can be used to set variables in the group parameters
1373 while still allowing them to affect operations done in other
1374 buffers. For example:
1376 \(setq gnus-newsgroup-variables
1377 '(message-use-followup-to
1378 (gnus-visible-headers .
1379 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1382 ;; Byte-compiler warning.
1383 (eval-when-compile (defvar gnus-article-mode-map))
1385 ;; Subject simplification.
1387 (defun gnus-simplify-whitespace (str)
1388 "Remove excessive whitespace from STR."
1391 (while (string-match "[ \t][ \t]+" mystr)
1392 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1394 (substring mystr (match-end 0)))))
1396 (when (string-match "^[ \t]+" mystr)
1397 (setq mystr (substring mystr (match-end 0))))
1399 (when (string-match "[ \t]+$" mystr)
1400 (setq mystr (substring mystr 0 (match-beginning 0))))
1403 (defun gnus-simplify-all-whitespace (str)
1404 "Remove all whitespace from STR."
1406 (while (string-match "[ \t\n]+" mystr)
1407 (setq mystr (replace-match "" nil nil mystr)))
1410 (defsubst gnus-simplify-subject-re (subject)
1411 "Remove \"Re:\" from subject lines."
1412 (if (string-match message-subject-re-regexp subject)
1413 (substring subject (match-end 0))
1416 (defun gnus-simplify-subject (subject &optional re-only)
1417 "Remove `Re:' and words in parentheses.
1418 If RE-ONLY is non-nil, strip leading `Re:'s only."
1419 (let ((case-fold-search t)) ;Ignore case.
1420 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1421 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1422 (setq subject (substring subject (match-end 0))))
1423 ;; Remove uninteresting prefixes.
1424 (when (and (not re-only)
1425 gnus-simplify-ignored-prefixes
1426 (string-match gnus-simplify-ignored-prefixes subject))
1427 (setq subject (substring subject (match-end 0))))
1428 ;; Remove words in parentheses from end.
1430 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1431 (setq subject (substring subject 0 (match-beginning 0)))))
1432 ;; Return subject string.
1435 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1437 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1438 (goto-char (point-min))
1439 (while (re-search-forward regexp nil t)
1440 (replace-match (or newtext ""))))
1442 (defun gnus-simplify-buffer-fuzzy ()
1443 "Simplify string in the buffer fuzzily.
1444 The string in the accessible portion of the current buffer is simplified.
1445 It is assumed to be a single-line subject.
1446 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1447 matter is removed. Additional things can be deleted by setting
1448 `gnus-simplify-subject-fuzzy-regexp'."
1449 (let ((case-fold-search t)
1451 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1453 (while (not (eq modified-tick (buffer-modified-tick)))
1454 (setq modified-tick (buffer-modified-tick))
1456 ((listp gnus-simplify-subject-fuzzy-regexp)
1457 (mapcar 'gnus-simplify-buffer-fuzzy-step
1458 gnus-simplify-subject-fuzzy-regexp))
1459 (gnus-simplify-subject-fuzzy-regexp
1460 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1461 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1462 (gnus-simplify-buffer-fuzzy-step
1463 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1464 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1466 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1467 (gnus-simplify-buffer-fuzzy-step " +" " ")
1468 (gnus-simplify-buffer-fuzzy-step " $")
1469 (gnus-simplify-buffer-fuzzy-step "^ +")))
1471 (defun gnus-simplify-subject-fuzzy (subject)
1472 "Simplify a subject string fuzzily.
1473 See `gnus-simplify-buffer-fuzzy' for details."
1475 (gnus-set-work-buffer)
1476 (let ((case-fold-search t))
1477 ;; Remove uninteresting prefixes.
1478 (when (and gnus-simplify-ignored-prefixes
1479 (string-match gnus-simplify-ignored-prefixes subject))
1480 (setq subject (substring subject (match-end 0))))
1482 (inline (gnus-simplify-buffer-fuzzy))
1485 (defsubst gnus-simplify-subject-fully (subject)
1486 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1488 (gnus-simplify-subject-functions
1489 (gnus-map-function gnus-simplify-subject-functions subject))
1490 ((null gnus-summary-gather-subject-limit)
1491 (gnus-simplify-subject-re subject))
1492 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1493 (gnus-simplify-subject-fuzzy subject))
1494 ((numberp gnus-summary-gather-subject-limit)
1495 (gnus-limit-string (gnus-simplify-subject-re subject)
1496 gnus-summary-gather-subject-limit))
1500 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1501 "Check whether two subjects are equal.
1502 If optional argument simple-first is t, first argument is already
1505 ((null simple-first)
1506 (equal (gnus-simplify-subject-fully s1)
1507 (gnus-simplify-subject-fully s2)))
1510 (gnus-simplify-subject-fully s2)))))
1512 (defun gnus-summary-bubble-group ()
1513 "Increase the score of the current group.
1514 This is a handy function to add to `gnus-summary-exit-hook' to
1515 increase the score of each group you read."
1516 (gnus-group-add-score gnus-newsgroup-name))
1520 ;;; Gnus summary mode
1523 (put 'gnus-summary-mode 'mode-class 'special)
1525 (defvar gnus-article-commands-menu)
1528 ;; Non-orthogonal keys
1530 (gnus-define-keys gnus-summary-mode-map
1531 " " gnus-summary-next-page
1532 "\177" gnus-summary-prev-page
1533 [delete] gnus-summary-prev-page
1534 [backspace] gnus-summary-prev-page
1535 "\r" gnus-summary-scroll-up
1536 "\M-\r" gnus-summary-scroll-down
1537 "n" gnus-summary-next-unread-article
1538 "p" gnus-summary-prev-unread-article
1539 "N" gnus-summary-next-article
1540 "P" gnus-summary-prev-article
1541 "\M-\C-n" gnus-summary-next-same-subject
1542 "\M-\C-p" gnus-summary-prev-same-subject
1543 "\M-n" gnus-summary-next-unread-subject
1544 "\M-p" gnus-summary-prev-unread-subject
1545 "." gnus-summary-first-unread-article
1546 "," gnus-summary-best-unread-article
1547 "\M-s" gnus-summary-search-article-forward
1548 "\M-r" gnus-summary-search-article-backward
1549 "<" gnus-summary-beginning-of-article
1550 ">" gnus-summary-end-of-article
1551 "j" gnus-summary-goto-article
1552 "^" gnus-summary-refer-parent-article
1553 "\M-^" gnus-summary-refer-article
1554 "u" gnus-summary-tick-article-forward
1555 "!" gnus-summary-tick-article-forward
1556 "U" gnus-summary-tick-article-backward
1557 "d" gnus-summary-mark-as-read-forward
1558 "D" gnus-summary-mark-as-read-backward
1559 "E" gnus-summary-mark-as-expirable
1560 "\M-u" gnus-summary-clear-mark-forward
1561 "\M-U" gnus-summary-clear-mark-backward
1562 "k" gnus-summary-kill-same-subject-and-select
1563 "\C-k" gnus-summary-kill-same-subject
1564 "\M-\C-k" gnus-summary-kill-thread
1565 "\M-\C-l" gnus-summary-lower-thread
1566 "e" gnus-summary-edit-article
1567 "#" gnus-summary-mark-as-processable
1568 "\M-#" gnus-summary-unmark-as-processable
1569 "\M-\C-t" gnus-summary-toggle-threads
1570 "\M-\C-s" gnus-summary-show-thread
1571 "\M-\C-h" gnus-summary-hide-thread
1572 "\M-\C-f" gnus-summary-next-thread
1573 "\M-\C-b" gnus-summary-prev-thread
1574 [(meta down)] gnus-summary-next-thread
1575 [(meta up)] gnus-summary-prev-thread
1576 "\M-\C-u" gnus-summary-up-thread
1577 "\M-\C-d" gnus-summary-down-thread
1578 "&" gnus-summary-execute-command
1579 "c" gnus-summary-catchup-and-exit
1580 "\C-w" gnus-summary-mark-region-as-read
1581 "\C-t" gnus-summary-toggle-truncation
1582 "?" gnus-summary-mark-as-dormant
1583 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1584 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1585 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1586 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1587 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1588 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1589 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1590 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1591 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1592 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1593 "=" gnus-summary-expand-window
1594 "\C-x\C-s" gnus-summary-reselect-current-group
1595 "\M-g" gnus-summary-rescan-group
1596 "w" gnus-summary-stop-page-breaking
1597 "\C-c\C-r" gnus-summary-caesar-message
1598 "\M-t" gnus-summary-toggle-mime
1599 "f" gnus-summary-followup
1600 "F" gnus-summary-followup-with-original
1601 "C" gnus-summary-cancel-article
1602 "r" gnus-summary-reply
1603 "R" gnus-summary-reply-with-original
1604 "\C-c\C-f" gnus-summary-mail-forward
1605 "o" gnus-summary-save-article
1606 "\C-o" gnus-summary-save-article-mail
1607 "|" gnus-summary-pipe-output
1608 "\M-k" gnus-summary-edit-local-kill
1609 "\M-K" gnus-summary-edit-global-kill
1611 "\C-c\C-d" gnus-summary-describe-group
1612 "q" gnus-summary-exit
1613 "Q" gnus-summary-exit-no-update
1614 "\C-c\C-i" gnus-info-find-node
1615 gnus-mouse-2 gnus-mouse-pick-article
1616 "m" gnus-summary-mail-other-window
1617 "a" gnus-summary-post-news
1618 "i" gnus-summary-news-other-window
1619 "x" gnus-summary-limit-to-unread
1620 "s" gnus-summary-isearch-article
1621 "t" gnus-summary-toggle-header
1622 "g" gnus-summary-show-article
1623 "l" gnus-summary-goto-last-article
1624 "v" gnus-summary-preview-mime-message
1625 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1626 "\C-d" gnus-summary-enter-digest-group
1627 "\M-\C-d" gnus-summary-read-document
1628 "\M-\C-e" gnus-summary-edit-parameters
1629 "\M-\C-a" gnus-summary-customize-parameters
1631 "\C-c\C-n" gnus-namazu-search
1632 "*" gnus-cache-enter-article
1633 "\M-*" gnus-cache-remove-article
1634 "\M-&" gnus-summary-universal-argument
1635 "\C-l" gnus-recenter
1636 "I" gnus-summary-increase-score
1637 "L" gnus-summary-lower-score
1638 "\M-i" gnus-symbolic-argument
1639 "h" gnus-summary-select-article-buffer
1641 "V" gnus-summary-score-map
1642 "X" gnus-uu-extract-map
1643 "S" gnus-summary-send-map)
1645 ;; Sort of orthogonal keymap
1646 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1647 "t" gnus-summary-tick-article-forward
1648 "!" gnus-summary-tick-article-forward
1649 "d" gnus-summary-mark-as-read-forward
1650 "r" gnus-summary-mark-as-read-forward
1651 "c" gnus-summary-clear-mark-forward
1652 " " gnus-summary-clear-mark-forward
1653 "e" gnus-summary-mark-as-expirable
1654 "x" gnus-summary-mark-as-expirable
1655 "?" gnus-summary-mark-as-dormant
1656 "b" gnus-summary-set-bookmark
1657 "B" gnus-summary-remove-bookmark
1658 "#" gnus-summary-mark-as-processable
1659 "\M-#" gnus-summary-unmark-as-processable
1660 "S" gnus-summary-limit-include-expunged
1661 "C" gnus-summary-catchup
1662 "H" gnus-summary-catchup-to-here
1663 "h" gnus-summary-catchup-from-here
1664 "\C-c" gnus-summary-catchup-all
1665 "k" gnus-summary-kill-same-subject-and-select
1666 "K" gnus-summary-kill-same-subject
1667 "P" gnus-uu-mark-map)
1669 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1670 "c" gnus-summary-clear-above
1671 "u" gnus-summary-tick-above
1672 "m" gnus-summary-mark-above
1673 "k" gnus-summary-kill-below)
1675 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1676 "/" gnus-summary-limit-to-subject
1677 "n" gnus-summary-limit-to-articles
1678 "w" gnus-summary-pop-limit
1679 "s" gnus-summary-limit-to-subject
1680 "a" gnus-summary-limit-to-author
1681 "u" gnus-summary-limit-to-unread
1682 "m" gnus-summary-limit-to-marks
1683 "M" gnus-summary-limit-exclude-marks
1684 "v" gnus-summary-limit-to-score
1685 "*" gnus-summary-limit-include-cached
1686 "D" gnus-summary-limit-include-dormant
1687 "T" gnus-summary-limit-include-thread
1688 "d" gnus-summary-limit-exclude-dormant
1689 "t" gnus-summary-limit-to-age
1690 "." gnus-summary-limit-to-unseen
1691 "x" gnus-summary-limit-to-extra
1692 "p" gnus-summary-limit-to-display-predicate
1693 "E" gnus-summary-limit-include-expunged
1694 "c" gnus-summary-limit-exclude-childless-dormant
1695 "C" gnus-summary-limit-mark-excluded-as-read
1696 "o" gnus-summary-insert-old-articles
1697 "N" gnus-summary-insert-new-articles)
1699 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1700 "n" gnus-summary-next-unread-article
1701 "p" gnus-summary-prev-unread-article
1702 "N" gnus-summary-next-article
1703 "P" gnus-summary-prev-article
1704 "\C-n" gnus-summary-next-same-subject
1705 "\C-p" gnus-summary-prev-same-subject
1706 "\M-n" gnus-summary-next-unread-subject
1707 "\M-p" gnus-summary-prev-unread-subject
1708 "f" gnus-summary-first-unread-article
1709 "b" gnus-summary-best-unread-article
1710 "j" gnus-summary-goto-article
1711 "g" gnus-summary-goto-subject
1712 "l" gnus-summary-goto-last-article
1713 "o" gnus-summary-pop-article)
1715 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1716 "k" gnus-summary-kill-thread
1717 "l" gnus-summary-lower-thread
1718 "i" gnus-summary-raise-thread
1719 "T" gnus-summary-toggle-threads
1720 "t" gnus-summary-rethread-current
1721 "^" gnus-summary-reparent-thread
1722 "s" gnus-summary-show-thread
1723 "S" gnus-summary-show-all-threads
1724 "h" gnus-summary-hide-thread
1725 "H" gnus-summary-hide-all-threads
1726 "n" gnus-summary-next-thread
1727 "p" gnus-summary-prev-thread
1728 "u" gnus-summary-up-thread
1729 "o" gnus-summary-top-thread
1730 "d" gnus-summary-down-thread
1731 "#" gnus-uu-mark-thread
1732 "\M-#" gnus-uu-unmark-thread)
1734 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1735 "g" gnus-summary-prepare
1736 "c" gnus-summary-insert-cached-articles)
1738 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1739 "c" gnus-summary-catchup-and-exit
1740 "C" gnus-summary-catchup-all-and-exit
1741 "E" gnus-summary-exit-no-update
1742 "J" gnus-summary-jump-to-other-group
1743 "Q" gnus-summary-exit
1744 "Z" gnus-summary-exit
1745 "n" gnus-summary-catchup-and-goto-next-group
1746 "R" gnus-summary-reselect-current-group
1747 "G" gnus-summary-rescan-group
1748 "N" gnus-summary-next-group
1749 "s" gnus-summary-save-newsrc
1750 "P" gnus-summary-prev-group)
1752 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1753 " " gnus-summary-next-page
1754 "n" gnus-summary-next-page
1755 "\177" gnus-summary-prev-page
1756 [delete] gnus-summary-prev-page
1757 "p" gnus-summary-prev-page
1758 "\r" gnus-summary-scroll-up
1759 "\M-\r" gnus-summary-scroll-down
1760 "<" gnus-summary-beginning-of-article
1761 ">" gnus-summary-end-of-article
1762 "b" gnus-summary-beginning-of-article
1763 "e" gnus-summary-end-of-article
1764 "^" gnus-summary-refer-parent-article
1765 "r" gnus-summary-refer-parent-article
1766 "D" gnus-summary-enter-digest-group
1767 "R" gnus-summary-refer-references
1768 "T" gnus-summary-refer-thread
1769 "g" gnus-summary-show-article
1770 "s" gnus-summary-isearch-article
1771 "P" gnus-summary-print-article
1772 "M" gnus-mailing-list-insinuate
1773 "t" gnus-article-babel)
1775 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1776 "b" gnus-article-add-buttons
1777 "B" gnus-article-add-buttons-to-head
1778 "o" gnus-article-treat-overstrike
1779 "e" gnus-article-emphasize
1780 "w" gnus-article-fill-cited-article
1781 "Q" gnus-article-fill-long-lines
1782 "C" gnus-article-capitalize-sentences
1783 "c" gnus-article-remove-cr
1784 "Z" gnus-article-decode-HZ
1785 "h" gnus-article-wash-html
1786 "u" gnus-article-unsplit-urls
1787 "f" gnus-article-display-x-face
1788 "l" gnus-summary-stop-page-breaking
1789 "r" gnus-summary-caesar-message
1790 "m" gnus-summary-morse-message
1791 "t" gnus-summary-toggle-header
1792 "g" gnus-treat-smiley
1793 "v" gnus-summary-verbose-headers
1794 "m" gnus-summary-toggle-mime
1795 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1796 "p" gnus-article-verify-x-pgp-sig
1797 "d" gnus-article-treat-dumbquotes
1798 "k" gnus-article-outlook-deuglify-article)
1800 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1801 "a" gnus-article-hide
1802 "h" gnus-article-hide-headers
1803 "b" gnus-article-hide-boring-headers
1804 "s" gnus-article-hide-signature
1805 "c" gnus-article-hide-citation
1806 "C" gnus-article-hide-citation-in-followups
1807 "l" gnus-article-hide-list-identifiers
1808 "p" gnus-article-hide-pgp
1809 "B" gnus-article-strip-banner
1810 "P" gnus-article-hide-pem
1811 "\C-c" gnus-article-hide-citation-maybe)
1813 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1814 "a" gnus-article-highlight
1815 "h" gnus-article-highlight-headers
1816 "c" gnus-article-highlight-citation
1817 "s" gnus-article-highlight-signature)
1819 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1820 "f" gnus-article-treat-fold-headers
1821 "u" gnus-article-treat-unfold-headers
1822 "n" gnus-article-treat-fold-newsgroups)
1824 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1825 "x" gnus-article-display-x-face
1826 "s" gnus-treat-smiley
1827 "D" gnus-article-remove-images
1828 "f" gnus-treat-from-picon
1829 "m" gnus-treat-mail-picon
1830 "n" gnus-treat-newsgroups-picon)
1832 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1833 "z" gnus-article-date-ut
1834 "u" gnus-article-date-ut
1835 "l" gnus-article-date-local
1836 "p" gnus-article-date-english
1837 "e" gnus-article-date-lapsed
1838 "o" gnus-article-date-original
1839 "i" gnus-article-date-iso8601
1840 "s" gnus-article-date-user)
1842 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1843 "t" gnus-article-remove-trailing-blank-lines
1844 "l" gnus-article-strip-leading-blank-lines
1845 "m" gnus-article-strip-multiple-blank-lines
1846 "a" gnus-article-strip-blank-lines
1847 "A" gnus-article-strip-all-blank-lines
1848 "s" gnus-article-strip-leading-space
1849 "e" gnus-article-strip-trailing-space
1850 "w" gnus-article-remove-leading-whitespace)
1852 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1854 "f" gnus-summary-fetch-faq
1855 "d" gnus-summary-describe-group
1856 "h" gnus-summary-describe-briefly
1857 "i" gnus-info-find-node
1858 "c" gnus-group-fetch-charter
1859 "C" gnus-group-fetch-control)
1861 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1862 "e" gnus-summary-expire-articles
1863 "\M-\C-e" gnus-summary-expire-articles-now
1864 "\177" gnus-summary-delete-article
1865 [delete] gnus-summary-delete-article
1866 [backspace] gnus-summary-delete-article
1867 "m" gnus-summary-move-article
1868 "r" gnus-summary-respool-article
1869 "w" gnus-summary-edit-article
1870 "c" gnus-summary-copy-article
1871 "B" gnus-summary-crosspost-article
1872 "q" gnus-summary-respool-query
1873 "t" gnus-summary-respool-trace
1874 "i" gnus-summary-import-article
1875 "I" gnus-summary-create-article
1876 "p" gnus-summary-article-posted-p)
1878 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1879 "o" gnus-summary-save-article
1880 "m" gnus-summary-save-article-mail
1881 "F" gnus-summary-write-article-file
1882 "r" gnus-summary-save-article-rmail
1883 "f" gnus-summary-save-article-file
1884 "b" gnus-summary-save-article-body-file
1885 "h" gnus-summary-save-article-folder
1886 "v" gnus-summary-save-article-vm
1887 "p" gnus-summary-pipe-output
1888 "P" gnus-summary-muttprint
1889 "s" gnus-soup-add-article)
1891 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1892 "b" gnus-summary-display-buttonized
1893 "m" gnus-summary-repair-multipart
1894 "v" gnus-article-view-part
1895 "o" gnus-article-save-part
1896 "c" gnus-article-copy-part
1897 "C" gnus-article-view-part-as-charset
1898 "e" gnus-article-view-part-externally
1899 "E" gnus-article-encrypt-body
1900 "i" gnus-article-inline-part
1901 "|" gnus-article-pipe-part)
1903 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1904 "p" gnus-summary-mark-as-processable
1905 "u" gnus-summary-unmark-as-processable
1906 "U" gnus-summary-unmark-all-processable
1907 "v" gnus-uu-mark-over
1908 "s" gnus-uu-mark-series
1909 "r" gnus-uu-mark-region
1910 "g" gnus-uu-unmark-region
1911 "R" gnus-uu-mark-by-regexp
1912 "G" gnus-uu-unmark-by-regexp
1913 "t" gnus-uu-mark-thread
1914 "T" gnus-uu-unmark-thread
1915 "a" gnus-uu-mark-all
1916 "b" gnus-uu-mark-buffer
1917 "S" gnus-uu-mark-sparse
1918 "k" gnus-summary-kill-process-mark
1919 "y" gnus-summary-yank-process-mark
1920 "w" gnus-summary-save-process-mark
1921 "i" gnus-uu-invert-processable)
1923 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1924 ;;"x" gnus-uu-extract-any
1925 "m" gnus-summary-save-parts
1926 "u" gnus-uu-decode-uu
1927 "U" gnus-uu-decode-uu-and-save
1928 "s" gnus-uu-decode-unshar
1929 "S" gnus-uu-decode-unshar-and-save
1930 "o" gnus-uu-decode-save
1931 "O" gnus-uu-decode-save
1932 "b" gnus-uu-decode-binhex
1933 "B" gnus-uu-decode-binhex
1934 "p" gnus-uu-decode-postscript
1935 "P" gnus-uu-decode-postscript-and-save)
1938 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1939 "u" gnus-uu-decode-uu-view
1940 "U" gnus-uu-decode-uu-and-save-view
1941 "s" gnus-uu-decode-unshar-view
1942 "S" gnus-uu-decode-unshar-and-save-view
1943 "o" gnus-uu-decode-save-view
1944 "O" gnus-uu-decode-save-view
1945 "b" gnus-uu-decode-binhex-view
1946 "B" gnus-uu-decode-binhex-view
1947 "p" gnus-uu-decode-postscript-view
1948 "P" gnus-uu-decode-postscript-and-save-view))
1950 (defvar gnus-article-post-menu nil)
1952 (defconst gnus-summary-menu-maxlen 20)
1954 (defun gnus-summary-menu-split (menu)
1955 ;; If we have lots of elements, divide them into groups of 20
1956 ;; and make a pane (or submenu) for each one.
1957 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1958 (let ((menu menu) sublists next
1961 ;; Pull off the next gnus-summary-menu-maxlen elements
1962 ;; and make them the next element of sublist.
1963 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1965 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1967 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1968 (aref (car (last menu)) 0)) menu)
1972 (nreverse sublists))
1973 ;; Few elements--put them all in one pane.
1976 (defun gnus-summary-make-menu-bar ()
1977 (gnus-turn-off-edit-menu 'summary)
1979 (unless (boundp 'gnus-summary-misc-menu)
1982 gnus-summary-kill-menu gnus-summary-mode-map ""
1987 ["Customize" gnus-score-customize t])
1988 (gnus-make-score-map 'increase)
1989 (gnus-make-score-map 'lower)
1991 ["Kill below" gnus-summary-kill-below t]
1992 ["Mark above" gnus-summary-mark-above t]
1993 ["Tick above" gnus-summary-tick-above t]
1994 ["Clear above" gnus-summary-clear-above t])
1995 ["Current score" gnus-summary-current-score t]
1996 ["Set score" gnus-summary-set-score t]
1997 ["Switch current score file..." gnus-score-change-score-file t]
1998 ["Set mark below..." gnus-score-set-mark-below t]
1999 ["Set expunge below..." gnus-score-set-expunge-below t]
2000 ["Edit current score file" gnus-score-edit-current-scores t]
2001 ["Edit score file" gnus-score-edit-file t]
2002 ["Trace score" gnus-score-find-trace t]
2003 ["Find words" gnus-score-find-favourite-words t]
2004 ["Rescore buffer" gnus-summary-rescore t]
2005 ["Increase score..." gnus-summary-increase-score t]
2006 ["Lower score..." gnus-summary-lower-score t]))))
2008 ;; Define both the Article menu in the summary buffer and the
2009 ;; equivalent Commands menu in the article buffer here for
2013 ["All" gnus-article-hide t]
2014 ["Headers" gnus-article-hide-headers t]
2015 ["Signature" gnus-article-hide-signature t]
2016 ["Citation" gnus-article-hide-citation t]
2017 ["List identifiers" gnus-article-hide-list-identifiers t]
2018 ["PGP" gnus-article-hide-pgp t]
2019 ["Banner" gnus-article-strip-banner t]
2020 ["Boring headers" gnus-article-hide-boring-headers t])
2022 ["All" gnus-article-highlight t]
2023 ["Headers" gnus-article-highlight-headers t]
2024 ["Signature" gnus-article-highlight-signature t]
2025 ["Citation" gnus-article-highlight-citation t])
2027 ["Local" gnus-article-date-local t]
2028 ["ISO8601" gnus-article-date-iso8601 t]
2029 ["UT" gnus-article-date-ut t]
2030 ["Original" gnus-article-date-original t]
2031 ["Lapsed" gnus-article-date-lapsed t]
2032 ["User-defined" gnus-article-date-user t])
2034 ["Remove images" gnus-article-remove-images t]
2035 ["Toggle smiley" gnus-treat-smiley t]
2036 ["Show X-Face" gnus-article-display-x-face t]
2037 ["Show picons in From" gnus-treat-from-picon t]
2038 ["Show picons in mail headers" gnus-treat-mail-picon t]
2039 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2040 ("View as different encoding"
2041 ,@(gnus-summary-menu-split
2044 ;; Since easymenu under FSF Emacs doesn't allow lambda
2045 ;; forms for menu commands, we should provide intern'ed
2046 ;; function symbols.
2047 (let ((command (intern (format "\
2048 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2052 (let ((gnus-summary-show-article-charset-alist
2054 (gnus-summary-show-article 1))))
2055 `[,(symbol-name cs) ,command t]))
2056 (sort (if (fboundp 'coding-system-list)
2057 (coding-system-list)
2058 ;;(mapcar 'car mm-mime-mule-charset-alist)
2063 ["Leading" gnus-article-strip-leading-blank-lines t]
2064 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2065 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2066 ["All of the above" gnus-article-strip-blank-lines t]
2067 ["All" gnus-article-strip-all-blank-lines t]
2068 ["Leading space" gnus-article-strip-leading-space t]
2069 ["Trailing space" gnus-article-strip-trailing-space t]
2070 ["Leading space in headers"
2071 gnus-article-remove-leading-whitespace t])
2072 ["Overstrike" gnus-article-treat-overstrike t]
2073 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2074 ["Emphasis" gnus-article-emphasize t]
2075 ["Word wrap" gnus-article-fill-cited-article t]
2076 ["Fill long lines" gnus-article-fill-long-lines t]
2077 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2078 ["CR" gnus-article-remove-cr t]
2079 ["Rot 13" gnus-summary-caesar-message
2080 ,@(if (featurep 'xemacs) '(t)
2081 '(:help "\"Caesar rotate\" article by 13"))]
2082 ["Morse decode" gnus-summary-morse-message t]
2083 ["Unix pipe..." gnus-summary-pipe-message t]
2084 ["Add buttons" gnus-article-add-buttons t]
2085 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2086 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2087 ["Toggle MIME" gnus-summary-toggle-mime t]
2088 ["Verbose header" gnus-summary-verbose-headers t]
2089 ["Toggle header" gnus-summary-toggle-header t]
2090 ["Unfold headers" gnus-article-treat-unfold-headers t]
2091 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2092 ["Html" gnus-article-wash-html t]
2093 ["URLs" gnus-article-unsplit-urls t]
2094 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2095 ["HZ" gnus-article-decode-HZ t]
2096 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2099 ["Save in default format" gnus-summary-save-article
2100 ,@(if (featurep 'xemacs) '(t)
2101 '(:help "Save article using default method"))]
2102 ["Save in file" gnus-summary-save-article-file
2103 ,@(if (featurep 'xemacs) '(t)
2104 '(:help "Save article in file"))]
2105 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2106 ["Save in MH folder" gnus-summary-save-article-folder t]
2107 ["Save in VM folder" gnus-summary-save-article-vm t]
2108 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2109 ["Save body in file" gnus-summary-save-article-body-file t]
2110 ["Pipe through a filter" gnus-summary-pipe-output t]
2111 ["Add to SOUP packet" gnus-soup-add-article t]
2112 ["Print with Muttprint" gnus-summary-muttprint t]
2113 ["Print" gnus-summary-print-article t])
2115 ["Respool article..." gnus-summary-respool-article t]
2116 ["Move article..." gnus-summary-move-article
2117 (gnus-check-backend-function
2118 'request-move-article gnus-newsgroup-name)]
2119 ["Copy article..." gnus-summary-copy-article t]
2120 ["Crosspost article..." gnus-summary-crosspost-article
2121 (gnus-check-backend-function
2122 'request-replace-article gnus-newsgroup-name)]
2123 ["Import file..." gnus-summary-import-article t]
2124 ["Create article..." gnus-summary-create-article t]
2125 ["Check if posted" gnus-summary-article-posted-p t]
2126 ["Edit article" gnus-summary-edit-article
2127 (not (gnus-group-read-only-p))]
2128 ["Delete article" gnus-summary-delete-article
2129 (gnus-check-backend-function
2130 'request-expire-articles gnus-newsgroup-name)]
2131 ["Query respool" gnus-summary-respool-query t]
2132 ["Trace respool" gnus-summary-respool-trace t]
2133 ["Delete expirable articles" gnus-summary-expire-articles-now
2134 (gnus-check-backend-function
2135 'request-expire-articles gnus-newsgroup-name)])
2137 ["Uudecode" gnus-uu-decode-uu
2138 ,@(if (featurep 'xemacs) '(t)
2139 '(:help "Decode uuencoded article(s)"))]
2140 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2141 ["Unshar" gnus-uu-decode-unshar t]
2142 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2143 ["Save" gnus-uu-decode-save t]
2144 ["Binhex" gnus-uu-decode-binhex t]
2145 ["Postscript" gnus-uu-decode-postscript t])
2147 ["Enter article" gnus-cache-enter-article t]
2148 ["Remove article" gnus-cache-remove-article t])
2149 ["Translate" gnus-article-babel t]
2150 ["Select article buffer" gnus-summary-select-article-buffer t]
2151 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2152 ["Isearch article..." gnus-summary-isearch-article t]
2153 ["Beginning of the article" gnus-summary-beginning-of-article t]
2154 ["End of the article" gnus-summary-end-of-article t]
2155 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2156 ["Fetch referenced articles" gnus-summary-refer-references t]
2157 ["Fetch current thread" gnus-summary-refer-thread t]
2158 ["Fetch article with id..." gnus-summary-refer-article t]
2159 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2160 ["Redisplay" gnus-summary-show-article t]
2161 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2163 gnus-summary-article-menu gnus-summary-mode-map ""
2164 (cons "Article" innards))
2166 (if (not (keymapp gnus-summary-article-menu))
2168 gnus-article-commands-menu gnus-article-mode-map ""
2169 (cons "Commands" innards))
2170 ;; in Emacs, don't share menu.
2171 (setq gnus-article-commands-menu
2172 (copy-keymap gnus-summary-article-menu))
2173 (define-key gnus-article-mode-map [menu-bar commands]
2174 (cons "Commands" gnus-article-commands-menu))))
2177 gnus-summary-thread-menu gnus-summary-mode-map ""
2179 ["Toggle threading" gnus-summary-toggle-threads t]
2180 ["Hide threads" gnus-summary-hide-all-threads t]
2181 ["Show threads" gnus-summary-show-all-threads t]
2182 ["Hide thread" gnus-summary-hide-thread t]
2183 ["Show thread" gnus-summary-show-thread t]
2184 ["Go to next thread" gnus-summary-next-thread t]
2185 ["Go to previous thread" gnus-summary-prev-thread t]
2186 ["Go down thread" gnus-summary-down-thread t]
2187 ["Go up thread" gnus-summary-up-thread t]
2188 ["Top of thread" gnus-summary-top-thread t]
2189 ["Mark thread as read" gnus-summary-kill-thread t]
2190 ["Lower thread score" gnus-summary-lower-thread t]
2191 ["Raise thread score" gnus-summary-raise-thread t]
2192 ["Rethread current" gnus-summary-rethread-current t]))
2195 gnus-summary-post-menu gnus-summary-mode-map ""
2197 ["Send a message (mail or news)" gnus-summary-post-news
2198 ,@(if (featurep 'xemacs) '(t)
2199 '(:help "Post an article"))]
2200 ["Followup" gnus-summary-followup
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Post followup to this article"))]
2203 ["Followup and yank" gnus-summary-followup-with-original
2204 ,@(if (featurep 'xemacs) '(t)
2205 '(:help "Post followup to this article, quoting its contents"))]
2206 ["Supersede article" gnus-summary-supersede-article t]
2207 ["Cancel article" gnus-summary-cancel-article
2208 ,@(if (featurep 'xemacs) '(t)
2209 '(:help "Cancel an article you posted"))]
2210 ["Reply" gnus-summary-reply t]
2211 ["Reply and yank" gnus-summary-reply-with-original t]
2212 ["Wide reply" gnus-summary-wide-reply t]
2213 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2214 ,@(if (featurep 'xemacs) '(t)
2215 '(:help "Mail a reply, quoting this article"))]
2216 ["Very wide reply" gnus-summary-very-wide-reply t]
2217 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2218 ,@(if (featurep 'xemacs) '(t)
2219 '(:help "Mail a very wide reply, quoting this article"))]
2220 ["Mail forward" gnus-summary-mail-forward t]
2221 ["Post forward" gnus-summary-post-forward t]
2222 ["Digest and mail" gnus-summary-digest-mail-forward t]
2223 ["Digest and post" gnus-summary-digest-post-forward t]
2224 ["Resend message" gnus-summary-resend-message t]
2225 ["Resend message edit" gnus-summary-resend-message-edit t]
2226 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2227 ["Send a mail" gnus-summary-mail-other-window t]
2228 ["Create a local message" gnus-summary-news-other-window t]
2229 ["Uuencode and post" gnus-uu-post-news
2230 ,@(if (featurep 'xemacs) '(t)
2231 '(:help "Post a uuencoded article"))]
2232 ["Followup via news" gnus-summary-followup-to-mail t]
2233 ["Followup via news and yank"
2234 gnus-summary-followup-to-mail-with-original t]
2236 ;;["Send" gnus-summary-send-draft t]
2237 ;;["Send bounced" gnus-resend-bounced-mail t])
2241 ((not (keymapp gnus-summary-post-menu))
2242 (setq gnus-article-post-menu gnus-summary-post-menu))
2243 ((not gnus-article-post-menu)
2244 ;; Don't share post menu.
2245 (setq gnus-article-post-menu
2246 (copy-keymap gnus-summary-post-menu))))
2247 (define-key gnus-article-mode-map [menu-bar post]
2248 (cons "Post" gnus-article-post-menu))
2251 gnus-summary-misc-menu gnus-summary-mode-map ""
2254 ["Mark as read" gnus-summary-mark-as-read-forward t]
2255 ["Mark same subject and select"
2256 gnus-summary-kill-same-subject-and-select t]
2257 ["Mark same subject" gnus-summary-kill-same-subject t]
2258 ["Catchup" gnus-summary-catchup
2259 ,@(if (featurep 'xemacs) '(t)
2260 '(:help "Mark unread articles in this group as read"))]
2261 ["Catchup all" gnus-summary-catchup-all t]
2262 ["Catchup to here" gnus-summary-catchup-to-here t]
2263 ["Catchup from here" gnus-summary-catchup-from-here t]
2264 ["Catchup region" gnus-summary-mark-region-as-read t]
2265 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2267 ["Tick" gnus-summary-tick-article-forward t]
2268 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2269 ["Remove marks" gnus-summary-clear-mark-forward t]
2270 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2271 ["Set bookmark" gnus-summary-set-bookmark t]
2272 ["Remove bookmark" gnus-summary-remove-bookmark t])
2274 ["Marks..." gnus-summary-limit-to-marks t]
2275 ["Subject..." gnus-summary-limit-to-subject t]
2276 ["Author..." gnus-summary-limit-to-author t]
2277 ["Age..." gnus-summary-limit-to-age t]
2278 ["Extra..." gnus-summary-limit-to-extra t]
2279 ["Score..." gnus-summary-limit-to-score t]
2280 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2281 ["Unread" gnus-summary-limit-to-unread t]
2282 ["Unseen" gnus-summary-limit-to-unseen t]
2283 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2284 ["Next articles" gnus-summary-limit-to-articles t]
2285 ["Pop limit" gnus-summary-pop-limit t]
2286 ["Show dormant" gnus-summary-limit-include-dormant t]
2287 ["Hide childless dormant"
2288 gnus-summary-limit-exclude-childless-dormant t]
2289 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2290 ["Hide marked" gnus-summary-limit-exclude-marks t]
2291 ["Show expunged" gnus-summary-limit-include-expunged t])
2293 ["Set mark" gnus-summary-mark-as-processable t]
2294 ["Remove mark" gnus-summary-unmark-as-processable t]
2295 ["Remove all marks" gnus-summary-unmark-all-processable t]
2296 ["Mark above" gnus-uu-mark-over t]
2297 ["Mark series" gnus-uu-mark-series t]
2298 ["Mark region" gnus-uu-mark-region t]
2299 ["Unmark region" gnus-uu-unmark-region t]
2300 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2301 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2302 ["Mark all" gnus-uu-mark-all t]
2303 ["Mark buffer" gnus-uu-mark-buffer t]
2304 ["Mark sparse" gnus-uu-mark-sparse t]
2305 ["Mark thread" gnus-uu-mark-thread t]
2306 ["Unmark thread" gnus-uu-unmark-thread t]
2307 ("Process Mark Sets"
2308 ["Kill" gnus-summary-kill-process-mark t]
2309 ["Yank" gnus-summary-yank-process-mark
2310 gnus-newsgroup-process-stack]
2311 ["Save" gnus-summary-save-process-mark t]))
2313 ["Page forward" gnus-summary-next-page
2314 ,@(if (featurep 'xemacs) '(t)
2315 '(:help "Show next page of article"))]
2316 ["Page backward" gnus-summary-prev-page
2317 ,@(if (featurep 'xemacs) '(t)
2318 '(:help "Show previous page of article"))]
2319 ["Line forward" gnus-summary-scroll-up t])
2321 ["Next unread article" gnus-summary-next-unread-article t]
2322 ["Previous unread article" gnus-summary-prev-unread-article t]
2323 ["Next article" gnus-summary-next-article t]
2324 ["Previous article" gnus-summary-prev-article t]
2325 ["Next unread subject" gnus-summary-next-unread-subject t]
2326 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2327 ["Next article same subject" gnus-summary-next-same-subject t]
2328 ["Previous article same subject" gnus-summary-prev-same-subject t]
2329 ["First unread article" gnus-summary-first-unread-article t]
2330 ["Best unread article" gnus-summary-best-unread-article t]
2331 ["Go to subject number..." gnus-summary-goto-subject t]
2332 ["Go to article number..." gnus-summary-goto-article t]
2333 ["Go to the last article" gnus-summary-goto-last-article t]
2334 ["Pop article off history" gnus-summary-pop-article t])
2336 ["Sort by number" gnus-summary-sort-by-number t]
2337 ["Sort by author" gnus-summary-sort-by-author t]
2338 ["Sort by subject" gnus-summary-sort-by-subject t]
2339 ["Sort by date" gnus-summary-sort-by-date t]
2340 ["Sort by score" gnus-summary-sort-by-score t]
2341 ["Sort by lines" gnus-summary-sort-by-lines t]
2342 ["Sort by characters" gnus-summary-sort-by-chars t]
2343 ["Randomize" gnus-summary-sort-by-random t]
2344 ["Original sort" gnus-summary-sort-by-original t])
2346 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2347 ["Describe group" gnus-summary-describe-group t]
2348 ["Fetch charter" gnus-group-fetch-charter
2349 ,@(if (featurep 'xemacs) nil
2350 '(:help "Display the charter of the current group"))]
2351 ["Fetch control message" gnus-group-fetch-control
2352 ,@(if (featurep 'xemacs) nil
2353 '(:help "Display the archived control message for the current group"))]
2354 ["Read manual" gnus-info-find-node t])
2356 ["Pick and read" gnus-pick-mode t]
2357 ["Binary" gnus-binary-mode t])
2359 ["Regenerate" gnus-summary-prepare t]
2360 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2361 ["Toggle threading" gnus-summary-toggle-threads t])
2362 ["See old articles" gnus-summary-insert-old-articles t]
2363 ["See new articles" gnus-summary-insert-new-articles t]
2364 ["Filter articles..." gnus-summary-execute-command t]
2365 ["Run command on subjects..." gnus-summary-universal-argument t]
2366 ["Search articles forward..." gnus-summary-search-article-forward t]
2367 ["Search articles backward..." gnus-summary-search-article-backward t]
2368 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2369 ["Expand window" gnus-summary-expand-window t]
2370 ["Expire expirable articles" gnus-summary-expire-articles
2371 (gnus-check-backend-function
2372 'request-expire-articles gnus-newsgroup-name)]
2373 ["Edit local kill file" gnus-summary-edit-local-kill t]
2374 ["Edit main kill file" gnus-summary-edit-global-kill t]
2375 ["Edit group parameters" gnus-summary-edit-parameters t]
2376 ["Customize group parameters" gnus-summary-customize-parameters t]
2377 ["Send a bug report" gnus-bug t]
2379 ["Catchup and exit" gnus-summary-catchup-and-exit
2380 ,@(if (featurep 'xemacs) '(t)
2381 '(:help "Mark unread articles in this group as read, then exit"))]
2382 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2383 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2384 ["Exit group" gnus-summary-exit
2385 ,@(if (featurep 'xemacs) '(t)
2386 '(:help "Exit current group, return to group selection mode"))]
2387 ["Exit group without updating" gnus-summary-exit-no-update t]
2388 ["Exit and goto next group" gnus-summary-next-group t]
2389 ["Exit and goto prev group" gnus-summary-prev-group t]
2390 ["Reselect group" gnus-summary-reselect-current-group t]
2391 ["Rescan group" gnus-summary-rescan-group t]
2392 ["Update dribble" gnus-summary-save-newsrc t])))
2394 (gnus-run-hooks 'gnus-summary-menu-hook)))
2396 (defvar gnus-summary-tool-bar-map nil)
2398 ;; Emacs 21 tool bar. Should be no-op otherwise.
2399 (defun gnus-summary-make-tool-bar ()
2400 (if (and (fboundp 'tool-bar-add-item-from-menu)
2401 (default-value 'tool-bar-mode)
2402 (not gnus-summary-tool-bar-map))
2403 (setq gnus-summary-tool-bar-map
2404 (let ((tool-bar-map (make-sparse-keymap))
2405 (load-path (mm-image-load-path)))
2406 (tool-bar-add-item-from-menu
2407 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2408 (tool-bar-add-item-from-menu
2409 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2410 (tool-bar-add-item-from-menu
2411 'gnus-summary-post-news "post" gnus-summary-mode-map)
2412 (tool-bar-add-item-from-menu
2413 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2414 (tool-bar-add-item-from-menu
2415 'gnus-summary-followup "followup" gnus-summary-mode-map)
2416 (tool-bar-add-item-from-menu
2417 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2418 (tool-bar-add-item-from-menu
2419 'gnus-summary-reply "reply" gnus-summary-mode-map)
2420 (tool-bar-add-item-from-menu
2421 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2422 (tool-bar-add-item-from-menu
2423 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2424 (tool-bar-add-item-from-menu
2425 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2426 (tool-bar-add-item-from-menu
2427 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2428 (tool-bar-add-item-from-menu
2429 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2430 (tool-bar-add-item-from-menu
2431 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2432 (tool-bar-add-item-from-menu
2433 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2434 (tool-bar-add-item-from-menu
2435 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2437 (if gnus-summary-tool-bar-map
2438 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2440 (defun gnus-score-set-default (var value)
2441 "A version of set that updates the GNU Emacs menu-bar."
2443 ;; It is the message that forces the active status to be updated.
2446 (defun gnus-make-score-map (type)
2447 "Make a summary score map of type TYPE."
2450 (let ((headers '(("author" "from" string)
2451 ("subject" "subject" string)
2452 ("article body" "body" string)
2453 ("article head" "head" string)
2454 ("xref" "xref" string)
2455 ("extra header" "extra" string)
2456 ("lines" "lines" number)
2457 ("followups to author" "followup" string)))
2458 (types '((number ("less than" <)
2461 (string ("substring" s)
2465 (perms '(("temporary" (current-time-string))
2473 (if (eq type 'lower)
2478 (setq header (car headers))
2484 (let ((ts (cdr (assoc (nth 2 header) types)))
2500 'gnus-summary-score-entry
2502 (if (or (string= (nth 1 header)
2504 (string= (nth 1 header)
2507 (list 'gnus-summary-header
2509 (list 'quote (nth 1 (car ts)))
2510 (list 'gnus-score-delta-default
2517 (list (nreverse outp))))
2520 (list (nreverse outt))))
2522 (setq headers (cdr headers)))
2523 (list (nreverse outh))))))))
2527 (defun gnus-summary-mode (&optional group)
2528 "Major mode for reading articles.
2530 All normal editing commands are switched off.
2531 \\<gnus-summary-mode-map>
2532 Each line in this buffer represents one article. To read an
2533 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2534 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2537 You can also post articles and send mail from this buffer. To
2538 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2539 of an article, type `\\[gnus-summary-reply]'.
2541 There are approx. one gazillion commands you can execute in this
2542 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2544 The following commands are available:
2546 \\{gnus-summary-mode-map}"
2548 (kill-all-local-variables)
2549 (when (gnus-visual-p 'summary-menu 'menu)
2550 (gnus-summary-make-menu-bar)
2551 (gnus-summary-make-tool-bar))
2552 (gnus-summary-make-local-variables)
2553 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2554 (gnus-summary-make-local-variables))
2555 (gnus-make-thread-indent-array)
2556 (gnus-simplify-mode-line)
2557 (setq major-mode 'gnus-summary-mode)
2558 (setq mode-name "Summary")
2559 (make-local-variable 'minor-mode-alist)
2560 (use-local-map gnus-summary-mode-map)
2561 (buffer-disable-undo)
2562 (setq buffer-read-only t) ;Disable modification
2563 (setq truncate-lines t)
2564 (setq selective-display t)
2565 (setq selective-display-ellipses t) ;Display `...'
2566 (gnus-summary-set-display-table)
2567 (gnus-set-default-directory)
2568 (setq gnus-newsgroup-name group)
2569 (unless (gnus-news-group-p group)
2570 (setq gnus-newsgroup-incorporated
2571 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2572 (make-local-variable 'gnus-summary-line-format)
2573 (make-local-variable 'gnus-summary-line-format-spec)
2574 (make-local-variable 'gnus-summary-dummy-line-format)
2575 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2576 (make-local-variable 'gnus-summary-mark-positions)
2577 (make-local-hook 'pre-command-hook)
2578 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2579 (gnus-run-hooks 'gnus-summary-mode-hook)
2580 (turn-on-gnus-mailing-list-mode)
2581 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2582 (gnus-update-summary-mark-positions))
2584 (defun gnus-summary-make-local-variables ()
2585 "Make all the local summary buffer variables."
2587 (dolist (local gnus-summary-local-variables)
2590 (if (eq (cdr local) 'global)
2591 ;; Copy the global value of the variable.
2592 (setq global (symbol-value (car local)))
2593 ;; Use the value from the list.
2594 (setq global (eval (cdr local))))
2595 (set (make-local-variable (car local)) global))
2596 ;; Simple nil-valued local variable.
2597 (set (make-local-variable local) nil)))))
2599 (defun gnus-summary-clear-local-variables ()
2600 (let ((locals gnus-summary-local-variables))
2602 (if (consp (car locals))
2603 (and (vectorp (caar locals))
2604 (set (caar locals) nil))
2605 (and (vectorp (car locals))
2606 (set (car locals) nil)))
2607 (setq locals (cdr locals)))))
2609 ;; Summary data functions.
2611 (defmacro gnus-data-number (data)
2614 (defmacro gnus-data-set-number (data number)
2615 `(setcar ,data ,number))
2617 (defmacro gnus-data-mark (data)
2620 (defmacro gnus-data-set-mark (data mark)
2621 `(setcar (nthcdr 1 ,data) ,mark))
2623 (defmacro gnus-data-pos (data)
2626 (defmacro gnus-data-set-pos (data pos)
2627 `(setcar (nthcdr 2 ,data) ,pos))
2629 (defmacro gnus-data-header (data)
2632 (defmacro gnus-data-set-header (data header)
2633 `(setcar (nthcdr 3 ,data) ,header))
2635 (defmacro gnus-data-level (data)
2638 (defmacro gnus-data-unread-p (data)
2639 `(= (nth 1 ,data) gnus-unread-mark))
2641 (defmacro gnus-data-read-p (data)
2642 `(/= (nth 1 ,data) gnus-unread-mark))
2644 (defmacro gnus-data-pseudo-p (data)
2645 `(consp (nth 3 ,data)))
2647 (defmacro gnus-data-find (number)
2648 `(assq ,number gnus-newsgroup-data))
2650 (defmacro gnus-data-find-list (number &optional data)
2651 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2652 (memq (assq ,number bdata)
2655 (defmacro gnus-data-make (number mark pos header level)
2656 `(list ,number ,mark ,pos ,header ,level))
2658 (defun gnus-data-enter (after-article number mark pos header level offset)
2659 (let ((data (gnus-data-find-list after-article)))
2661 (error "No such article: %d" after-article))
2662 (setcdr data (cons (gnus-data-make number mark pos header level)
2664 (setq gnus-newsgroup-data-reverse nil)
2665 (gnus-data-update-list (cddr data) offset)))
2667 (defun gnus-data-enter-list (after-article list &optional offset)
2669 (let ((data (and after-article (gnus-data-find-list after-article)))
2673 (let ((odata gnus-newsgroup-data))
2674 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2676 (gnus-data-update-list odata offset)))
2677 ;; Find the last element in the list to be spliced into the main
2680 (setq list (cdr list)))
2683 (setcdr list gnus-newsgroup-data)
2684 (setq gnus-newsgroup-data ilist)
2686 (gnus-data-update-list (cdr list) offset)))
2687 (setcdr list (cdr data))
2690 (gnus-data-update-list (cdr list) offset))))
2691 (setq gnus-newsgroup-data-reverse nil))))
2693 (defun gnus-data-remove (article &optional offset)
2694 (let ((data gnus-newsgroup-data))
2695 (if (= (gnus-data-number (car data)) article)
2697 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2698 gnus-newsgroup-data-reverse nil)
2700 (gnus-data-update-list gnus-newsgroup-data offset)))
2702 (when (= (gnus-data-number (cadr data)) article)
2703 (setcdr data (cddr data))
2705 (gnus-data-update-list (cdr data) offset))
2707 gnus-newsgroup-data-reverse nil))
2708 (setq data (cdr data))))))
2710 (defmacro gnus-data-list (backward)
2712 (or gnus-newsgroup-data-reverse
2713 (setq gnus-newsgroup-data-reverse
2714 (reverse gnus-newsgroup-data)))
2715 gnus-newsgroup-data))
2717 (defun gnus-data-update-list (data offset)
2718 "Add OFFSET to the POS of all data entries in DATA."
2719 (setq gnus-newsgroup-data-reverse nil)
2721 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2722 (setq data (cdr data))))
2724 (defun gnus-summary-article-pseudo-p (article)
2725 "Say whether this article is a pseudo article or not."
2726 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2728 (defmacro gnus-summary-article-sparse-p (article)
2729 "Say whether this article is a sparse article or not."
2730 `(memq ,article gnus-newsgroup-sparse))
2732 (defmacro gnus-summary-article-ancient-p (article)
2733 "Say whether this article is a sparse article or not."
2734 `(memq ,article gnus-newsgroup-ancient))
2736 (defun gnus-article-parent-p (number)
2737 "Say whether this article is a parent or not."
2738 (let ((data (gnus-data-find-list number)))
2739 (and (cdr data) ; There has to be an article after...
2740 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2741 (gnus-data-level (nth 1 data))))))
2743 (defun gnus-article-children (number)
2744 "Return a list of all children to NUMBER."
2745 (let* ((data (gnus-data-find-list number))
2746 (level (gnus-data-level (car data)))
2748 (setq data (cdr data))
2750 (= (gnus-data-level (car data)) (1+ level)))
2751 (push (gnus-data-number (car data)) children)
2752 (setq data (cdr data)))
2755 (defmacro gnus-summary-skip-intangible ()
2756 "If the current article is intangible, then jump to a different article."
2757 '(let ((to (get-text-property (point) 'gnus-intangible)))
2758 (and to (gnus-summary-goto-subject to))))
2760 (defmacro gnus-summary-article-intangible-p ()
2761 "Say whether this article is intangible or not."
2762 '(get-text-property (point) 'gnus-intangible))
2764 (defun gnus-article-read-p (article)
2765 "Say whether ARTICLE is read or not."
2766 (not (or (memq article gnus-newsgroup-marked)
2767 (memq article gnus-newsgroup-spam-marked)
2768 (memq article gnus-newsgroup-unreads)
2769 (memq article gnus-newsgroup-unselected)
2770 (memq article gnus-newsgroup-dormant))))
2772 ;; Some summary mode macros.
2774 (defmacro gnus-summary-article-number ()
2775 "The article number of the article on the current line.
2776 If there isn't an article number here, then we return the current
2779 (gnus-summary-skip-intangible)
2780 (or (get-text-property (point) 'gnus-number)
2781 (gnus-summary-last-subject))))
2783 (defmacro gnus-summary-article-header (&optional number)
2784 "Return the header of article NUMBER."
2785 `(gnus-data-header (gnus-data-find
2786 ,(or number '(gnus-summary-article-number)))))
2788 (defmacro gnus-summary-thread-level (&optional number)
2789 "Return the level of thread that starts with article NUMBER."
2790 `(if (and (eq gnus-summary-make-false-root 'dummy)
2791 (get-text-property (point) 'gnus-intangible))
2793 (gnus-data-level (gnus-data-find
2794 ,(or number '(gnus-summary-article-number))))))
2796 (defmacro gnus-summary-article-mark (&optional number)
2797 "Return the mark of article NUMBER."
2798 `(gnus-data-mark (gnus-data-find
2799 ,(or number '(gnus-summary-article-number)))))
2801 (defmacro gnus-summary-article-pos (&optional number)
2802 "Return the position of the line of article NUMBER."
2803 `(gnus-data-pos (gnus-data-find
2804 ,(or number '(gnus-summary-article-number)))))
2806 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2807 (defmacro gnus-summary-article-subject (&optional number)
2808 "Return current subject string or nil if nothing."
2811 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2812 '(gnus-data-header (assq (gnus-summary-article-number)
2813 gnus-newsgroup-data)))))
2816 (mail-header-subject headers))))
2818 (defmacro gnus-summary-article-score (&optional number)
2819 "Return current article score."
2820 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2821 gnus-newsgroup-scored))
2822 gnus-summary-default-score 0))
2824 (defun gnus-summary-article-children (&optional number)
2825 "Return a list of article numbers that are children of article NUMBER."
2826 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2827 (level (gnus-data-level (car data)))
2829 (while (and (setq data (cdr data))
2830 (> (setq l (gnus-data-level (car data))) level))
2831 (and (= (1+ level) l)
2832 (push (gnus-data-number (car data))
2834 (nreverse children)))
2836 (defun gnus-summary-article-parent (&optional number)
2837 "Return the article number of the parent of article NUMBER."
2838 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2839 (gnus-data-list t)))
2840 (level (gnus-data-level (car data))))
2842 () ; This is a root.
2843 ;; We search until we find an article with a level less than
2844 ;; this one. That function has to be the parent.
2845 (while (and (setq data (cdr data))
2846 (not (< (gnus-data-level (car data)) level))))
2847 (and data (gnus-data-number (car data))))))
2849 (defun gnus-unread-mark-p (mark)
2850 "Say whether MARK is the unread mark."
2851 (= mark gnus-unread-mark))
2853 (defun gnus-read-mark-p (mark)
2854 "Say whether MARK is one of the marks that mark as read.
2855 This is all marks except unread, ticked, dormant, and expirable."
2856 (not (or (= mark gnus-unread-mark)
2857 (= mark gnus-ticked-mark)
2858 (= mark gnus-dormant-mark)
2859 (= mark gnus-expirable-mark))))
2861 (defmacro gnus-article-mark (number)
2862 "Return the MARK of article NUMBER.
2863 This macro should only be used when computing the mark the \"first\"
2864 time; i.e., when generating the summary lines. After that,
2865 `gnus-summary-article-mark' should be used to examine the
2868 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2869 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2870 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2871 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2872 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2873 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2874 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2875 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2876 gnus-ancient-mark))))
2878 ;; Saving hidden threads.
2880 (defmacro gnus-save-hidden-threads (&rest forms)
2881 "Save hidden threads, eval FORMS, and restore the hidden threads."
2882 (let ((config (make-symbol "config")))
2883 `(let ((,config (gnus-hidden-threads-configuration)))
2887 (gnus-restore-hidden-threads-configuration ,config)))))
2888 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2889 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2891 (defun gnus-data-compute-positions ()
2892 "Compute the positions of all articles."
2893 (setq gnus-newsgroup-data-reverse nil)
2894 (let ((data gnus-newsgroup-data))
2896 (gnus-save-hidden-threads
2897 (gnus-summary-show-all-threads)
2898 (goto-char (point-min))
2900 (while (get-text-property (point) 'gnus-intangible)
2902 (gnus-data-set-pos (car data) (+ (point) 3))
2903 (setq data (cdr data))
2904 (forward-line 1))))))
2906 (defun gnus-hidden-threads-configuration ()
2907 "Return the current hidden threads configuration."
2910 (goto-char (point-min))
2911 (while (search-forward "\r" nil t)
2912 (push (1- (point)) config))
2915 (defun gnus-restore-hidden-threads-configuration (config)
2916 "Restore hidden threads configuration from CONFIG."
2918 (let (point buffer-read-only)
2919 (while (setq point (pop config))
2920 (when (and (< point (point-max))
2922 (eq (char-after) ?\n))
2923 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2925 ;; Various summary mode internalish functions.
2927 (defun gnus-mouse-pick-article (e)
2930 (gnus-summary-next-page nil t))
2932 (defun gnus-summary-set-display-table ()
2933 "Change the display table.
2934 Odd characters have a tendency to mess
2935 up nicely formatted displays - we make all possible glyphs
2936 display only a single character."
2938 ;; We start from the standard display table, if any.
2939 (let ((table (or (copy-sequence standard-display-table)
2940 (make-display-table)))
2942 ;; Nix out all the control chars...
2943 (while (>= (setq i (1- i)) 0)
2944 (aset table i [??]))
2945 ;; ... but not newline and cr, of course. (cr is necessary for the
2946 ;; selective display).
2947 (aset table ?\n nil)
2948 (aset table ?\r nil)
2949 ;; We keep TAB as well.
2950 (aset table ?\t nil)
2951 ;; We nix out any glyphs over 126 that are not set already.
2953 (while (>= (setq i (1- i)) 127)
2954 ;; Only modify if the entry is nil.
2955 (unless (aref table i)
2956 (aset table i [??]))))
2957 (setq buffer-display-table table)))
2959 (defun gnus-summary-set-article-display-arrow (pos)
2960 "Update the overlay arrow to point to line at position POS."
2961 (when (and gnus-summary-display-arrow
2962 (boundp 'overlay-arrow-position)
2963 (boundp 'overlay-arrow-string))
2967 (unless overlay-arrow-position
2968 (setq overlay-arrow-position (make-marker)))
2969 (setq overlay-arrow-string "=>"
2970 overlay-arrow-position (set-marker overlay-arrow-position
2972 (current-buffer))))))
2974 (defun gnus-summary-buffer-name (group)
2975 "Return the summary buffer name of GROUP."
2976 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2978 (defun gnus-summary-setup-buffer (group)
2979 "Initialize summary buffer."
2980 (let ((buffer (gnus-summary-buffer-name group))
2981 (dead-name (concat "*Dead Summary "
2982 (gnus-group-decoded-name group) "*")))
2983 ;; If a dead summary buffer exists, we kill it.
2984 (when (gnus-buffer-live-p dead-name)
2985 (gnus-kill-buffer dead-name))
2986 (if (get-buffer buffer)
2989 (setq gnus-summary-buffer (current-buffer))
2990 (not gnus-newsgroup-prepared))
2991 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2992 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2993 (gnus-summary-mode group)
2995 (gnus-carpal-setup-buffer 'summary))
2996 (unless gnus-single-article-buffer
2997 (make-local-variable 'gnus-article-buffer)
2998 (make-local-variable 'gnus-article-current)
2999 (make-local-variable 'gnus-original-article-buffer))
3000 (setq gnus-newsgroup-name group)
3001 ;; Set any local variables in the group parameters.
3002 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3005 (defun gnus-set-global-variables ()
3006 "Set the global equivalents of the buffer-local variables.
3007 They are set to the latest values they had. These reflect the summary
3008 buffer that was in action when the last article was fetched."
3009 (when (eq major-mode 'gnus-summary-mode)
3010 (setq gnus-summary-buffer (current-buffer))
3011 (let ((name gnus-newsgroup-name)
3012 (marked gnus-newsgroup-marked)
3013 (spam gnus-newsgroup-spam-marked)
3014 (unread gnus-newsgroup-unreads)
3015 (headers gnus-current-headers)
3016 (data gnus-newsgroup-data)
3017 (summary gnus-summary-buffer)
3018 (article-buffer gnus-article-buffer)
3019 (original gnus-original-article-buffer)
3020 (gac gnus-article-current)
3021 (reffed gnus-reffed-article-number)
3022 (score-file gnus-current-score-file)
3023 (default-charset gnus-newsgroup-charset)
3025 (let ((locals gnus-newsgroup-variables))
3027 (if (consp (car locals))
3028 (push (eval (caar locals)) vlist)
3029 (push (eval (car locals)) vlist))
3030 (setq locals (cdr locals)))
3031 (setq vlist (nreverse vlist)))
3033 (set-buffer gnus-group-buffer)
3034 (setq gnus-newsgroup-name name
3035 gnus-newsgroup-marked marked
3036 gnus-newsgroup-spam-marked spam
3037 gnus-newsgroup-unreads unread
3038 gnus-current-headers headers
3039 gnus-newsgroup-data data
3040 gnus-article-current gac
3041 gnus-summary-buffer summary
3042 gnus-article-buffer article-buffer
3043 gnus-original-article-buffer original
3044 gnus-reffed-article-number reffed
3045 gnus-current-score-file score-file
3046 gnus-newsgroup-charset default-charset)
3047 (let ((locals gnus-newsgroup-variables))
3049 (if (consp (car locals))
3050 (set (caar locals) (pop vlist))
3051 (set (car locals) (pop vlist)))
3052 (setq locals (cdr locals))))
3053 ;; The article buffer also has local variables.
3054 (when (gnus-buffer-live-p gnus-article-buffer)
3055 (set-buffer gnus-article-buffer)
3056 (setq gnus-summary-buffer summary))))))
3058 (defun gnus-summary-article-unread-p (article)
3059 "Say whether ARTICLE is unread or not."
3060 (memq article gnus-newsgroup-unreads))
3062 (defun gnus-summary-first-article-p (&optional article)
3063 "Return whether ARTICLE is the first article in the buffer."
3064 (if (not (setq article (or article (gnus-summary-article-number))))
3066 (eq article (caar gnus-newsgroup-data))))
3068 (defun gnus-summary-last-article-p (&optional article)
3069 "Return whether ARTICLE is the last article in the buffer."
3070 (if (not (setq article (or article (gnus-summary-article-number))))
3071 ;; All non-existent numbers are the last article. :-)
3073 (not (cdr (gnus-data-find-list article)))))
3075 (defun gnus-make-thread-indent-array ()
3077 (unless (and gnus-thread-indent-array
3078 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3079 (setq gnus-thread-indent-array (make-vector 201 "")
3080 gnus-thread-indent-array-level gnus-thread-indent-level)
3082 (aset gnus-thread-indent-array n
3083 (make-string (* n gnus-thread-indent-level) ? ))
3086 (defun gnus-update-summary-mark-positions ()
3087 "Compute where the summary marks are to go."
3089 (when (gnus-buffer-exists-p gnus-summary-buffer)
3090 (set-buffer gnus-summary-buffer))
3091 (let ((gnus-replied-mark 129)
3092 (gnus-score-below-mark 130)
3093 (gnus-score-over-mark 130)
3094 (gnus-downloaded-mark 131)
3095 (spec gnus-summary-line-format-spec)
3098 (gnus-set-work-buffer)
3099 (let ((gnus-summary-line-format-spec spec)
3100 (gnus-newsgroup-downloadable '(0)))
3101 (gnus-summary-insert-line
3102 (make-full-mail-header 0 "" "nobody"
3103 "05 Apr 2001 23:33:09 +0400"
3105 0 nil nil 128 t nil "" nil 1)
3106 (goto-char (point-min))
3107 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3108 (- (point) (point-min) 1)))))
3109 (goto-char (point-min))
3110 (push (cons 'replied (and (search-forward "\201" nil t)
3111 (- (point) (point-min) 1)))
3113 (goto-char (point-min))
3114 (push (cons 'score (and (search-forward "\202" nil t)
3115 (- (point) (point-min) 1)))
3117 (goto-char (point-min))
3118 (push (cons 'download
3119 (and (search-forward "\203" nil t)
3120 (- (point) (point-min) 1)))
3122 (setq gnus-summary-mark-positions pos))))
3124 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3125 "Insert a dummy root in the summary buffer."
3127 (gnus-add-text-properties
3128 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3129 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3131 (defun gnus-summary-extract-address-component (from)
3132 (or (car (funcall gnus-extract-address-components from))
3135 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3136 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3137 default-mime-charset)))
3138 ;; Is it really necessary to do this next part for each summary line?
3139 ;; Luckily, doesn't seem to slow things down much.
3141 (and gnus-ignored-from-addresses
3142 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3143 (let ((extra-headers (mail-header-extra header))
3147 ((setq to (cdr (assq 'To extra-headers)))
3150 (gnus-summary-extract-address-component
3151 (funcall gnus-decode-encoded-word-function to)))))
3152 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3153 (concat "=> " newsgroups)))))
3154 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3156 (defun gnus-summary-insert-line (gnus-tmp-header
3157 gnus-tmp-level gnus-tmp-current
3158 undownloaded gnus-tmp-unread gnus-tmp-replied
3159 gnus-tmp-expirable gnus-tmp-subject-or-nil
3160 &optional gnus-tmp-dummy gnus-tmp-score
3162 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3163 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3164 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3165 (gnus-tmp-score-char
3166 (if (or (null gnus-summary-default-score)
3167 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3168 gnus-summary-zcore-fuzz))
3170 (if (< gnus-tmp-score gnus-summary-default-score)
3171 gnus-score-below-mark gnus-score-over-mark)))
3172 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3174 (cond (gnus-tmp-process gnus-process-mark)
3175 ((memq gnus-tmp-current gnus-newsgroup-cached)
3177 (gnus-tmp-replied gnus-replied-mark)
3178 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3179 gnus-forwarded-mark)
3180 ((memq gnus-tmp-current gnus-newsgroup-saved)
3182 ((memq gnus-tmp-number gnus-newsgroup-recent)
3184 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3187 (gnus-tmp-downloaded
3189 gnus-undownloaded-mark)
3190 (gnus-newsgroup-agentized
3191 gnus-downloaded-mark)
3194 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3197 ((string-match "<[^>]+> *$" gnus-tmp-from)
3198 (let ((beg (match-beginning 0)))
3199 (or (and (string-match "^\".+\"" gnus-tmp-from)
3200 (substring gnus-tmp-from 1 (1- (match-end 0))))
3201 (substring gnus-tmp-from 0 beg))))
3202 ((string-match "(.+)" gnus-tmp-from)
3203 (substring gnus-tmp-from
3204 (1+ (match-beginning 0)) (1- (match-end 0))))
3206 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3207 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3208 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3209 (buffer-read-only nil))
3210 (when (string= gnus-tmp-name "")
3211 (setq gnus-tmp-name gnus-tmp-from))
3212 (unless (numberp gnus-tmp-lines)
3213 (setq gnus-tmp-lines -1))
3214 (if (= gnus-tmp-lines -1)
3215 (setq gnus-tmp-lines "?")
3216 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3217 (gnus-put-text-property-excluding-characters-with-faces
3219 (progn (eval gnus-summary-line-format-spec) (point))
3220 'gnus-number gnus-tmp-number)
3221 (when (gnus-visual-p 'summary-highlight 'highlight)
3223 (gnus-run-hooks 'gnus-summary-update-hook)
3226 (defun gnus-summary-update-line (&optional dont-update)
3227 "Update summary line after change."
3228 (when (and gnus-summary-default-score
3229 (not gnus-summary-inhibit-highlight))
3230 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3231 (article (gnus-summary-article-number))
3232 (score (gnus-summary-article-score article)))
3234 (if (and gnus-summary-mark-below
3235 (< (gnus-summary-article-score)
3236 gnus-summary-mark-below))
3237 ;; This article has a low score, so we mark it as read.
3238 (when (memq article gnus-newsgroup-unreads)
3239 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3240 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3241 ;; This article was previously marked as read on account
3242 ;; of a low score, but now it has risen, so we mark it as
3244 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3245 (gnus-summary-update-mark
3246 (if (or (null gnus-summary-default-score)
3247 (<= (abs (- score gnus-summary-default-score))
3248 gnus-summary-zcore-fuzz))
3250 (if (< score gnus-summary-default-score)
3251 gnus-score-below-mark gnus-score-over-mark))
3253 ;; Do visual highlighting.
3254 (when (gnus-visual-p 'summary-highlight 'highlight)
3255 (gnus-run-hooks 'gnus-summary-update-hook)))))
3257 (defvar gnus-tmp-new-adopts nil)
3259 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3260 "Return the number of articles in THREAD.
3261 This may be 0 in some cases -- if none of the articles in
3262 the thread are to be displayed."
3264 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3266 ((not (listp thread))
3268 ((and (consp thread) (cdr thread))
3271 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3274 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3277 (when (and level (zerop level) gnus-tmp-new-adopts)
3280 'gnus-summary-number-of-articles-in-thread
3281 gnus-tmp-new-adopts))))
3283 (if (> number 1) gnus-not-empty-thread-mark
3284 gnus-empty-thread-mark)
3287 (defsubst gnus-summary-line-message-size (head)
3288 "Return pretty-printed version of message size.
3289 This function is intended to be used in
3290 `gnus-summary-line-format-alist', which see."
3291 (let ((c (or (mail-header-chars head) -1)))
3292 (cond ((< c 0) "n/a") ; chars not available
3293 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3294 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3295 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3296 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3299 (defun gnus-summary-set-local-parameters (group)
3300 "Go through the local params of GROUP and set all variable specs in that list."
3301 (let ((params (gnus-group-find-parameter group))
3302 (vars '(quit-config)) ; Ignore quit-config.
3305 (setq elem (car params)
3306 params (cdr params))
3307 (and (consp elem) ; Has to be a cons.
3308 (consp (cdr elem)) ; The cdr has to be a list.
3309 (symbolp (car elem)) ; Has to be a symbol in there.
3310 (not (memq (car elem) vars))
3311 (ignore-errors ; So we set it.
3312 (push (car elem) vars)
3313 (make-local-variable (car elem))
3314 (set (car elem) (eval (nth 1 elem))))))))
3316 (defun gnus-summary-read-group (group &optional show-all no-article
3317 kill-buffer no-display backward
3319 "Start reading news in newsgroup GROUP.
3320 If SHOW-ALL is non-nil, already read articles are also listed.
3321 If NO-ARTICLE is non-nil, no article is selected initially.
3322 If NO-DISPLAY, don't generate a summary buffer."
3326 (let ((gnus-auto-select-next nil))
3327 (or (gnus-summary-read-group-1
3328 group show-all no-article
3329 kill-buffer no-display
3332 select-articles nil)))))
3333 (eq gnus-auto-select-next 'quietly))
3334 (set-buffer gnus-group-buffer)
3335 ;; The entry function called above goes to the next
3336 ;; group automatically, so we go two groups back
3337 ;; if we are searching for the previous group.
3339 (gnus-group-prev-unread-group 2))
3340 (if (not (equal group (gnus-group-group-name)))
3341 (setq group (gnus-group-group-name))
3345 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3346 "Directly jump to the other GROUP from summary buffer.
3347 If SHOW-ALL is non-nil, already read articles are also listed."
3349 (if (eq gnus-summary-buffer (current-buffer))
3350 (list (completing-read
3351 "Group: " gnus-active-hashtb nil t
3352 (when (and gnus-newsgroup-name
3353 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3354 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3355 'gnus-group-history)
3357 (error "%s must be invoked from a gnus summary buffer." this-command)))
3358 (unless (or (zerop (length group))
3359 (and gnus-newsgroup-name
3360 (string-equal gnus-newsgroup-name group)))
3362 (gnus-summary-read-group group show-all
3363 gnus-dont-select-after-jump-to-other-group)))
3365 (defun gnus-summary-read-group-1 (group show-all no-article
3366 kill-buffer no-display
3367 &optional select-articles)
3368 ;; Killed foreign groups can't be entered.
3369 ;; (when (and (not (gnus-group-native-p group))
3370 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3371 ;; (error "Dead non-native groups can't be entered"))
3372 (gnus-message 5 "Retrieving newsgroup: %s..."
3373 (gnus-group-decoded-name group))
3374 (let* ((new-group (gnus-summary-setup-buffer group))
3375 (quit-config (gnus-group-quit-config group))
3376 (did-select (and new-group (gnus-select-newsgroup
3377 group show-all select-articles))))
3379 ;; This summary buffer exists already, so we just select it.
3381 (gnus-set-global-variables)
3383 (gnus-kill-or-deaden-summary kill-buffer))
3384 (gnus-configure-windows 'summary 'force)
3385 (gnus-set-mode-line 'summary)
3386 (gnus-summary-position-point)
3389 ;; We couldn't select this group.
3391 (when (and (eq major-mode 'gnus-summary-mode)
3392 (not (equal (current-buffer) kill-buffer)))
3393 (kill-buffer (current-buffer))
3394 (if (not quit-config)
3396 ;; Update the info -- marks might need to be removed,
3398 (gnus-summary-update-info)
3399 (set-buffer gnus-group-buffer)
3400 (gnus-group-jump-to-group group)
3401 (gnus-group-next-unread-group 1))
3402 (gnus-handle-ephemeral-exit quit-config)))
3403 (let ((grpinfo (gnus-get-info group)))
3404 (if (null (gnus-info-read grpinfo))
3405 (gnus-message 3 "Group %s contains no messages"
3406 (gnus-group-decoded-name group))
3407 (gnus-message 3 "Can't select group")))
3409 ;; The user did a `C-g' while prompting for number of articles,
3410 ;; so we exit this group.
3411 ((eq did-select 'quit)
3412 (and (eq major-mode 'gnus-summary-mode)
3413 (not (equal (current-buffer) kill-buffer))
3414 (kill-buffer (current-buffer)))
3416 (gnus-kill-or-deaden-summary kill-buffer))
3417 (if (not quit-config)
3419 (set-buffer gnus-group-buffer)
3420 (gnus-group-jump-to-group group)
3421 (gnus-group-next-unread-group 1)
3422 (gnus-configure-windows 'group 'force))
3423 (gnus-handle-ephemeral-exit quit-config))
3424 ;; Finally signal the quit.
3426 ;; The group was successfully selected.
3428 (gnus-set-global-variables)
3429 ;; Save the active value in effect when the group was entered.
3430 (setq gnus-newsgroup-active
3432 (gnus-active gnus-newsgroup-name)))
3433 ;; You can change the summary buffer in some way with this hook.
3434 (gnus-run-hooks 'gnus-select-group-hook)
3435 (gnus-update-format-specifications
3436 nil 'summary 'summary-mode 'summary-dummy)
3437 (gnus-update-summary-mark-positions)
3438 ;; Do score processing.
3439 (when gnus-use-scoring
3440 (gnus-possibly-score-headers))
3441 ;; Check whether to fill in the gaps in the threads.
3442 (when gnus-build-sparse-threads
3443 (gnus-build-sparse-threads))
3444 ;; Find the initial limit.
3445 (if gnus-show-threads
3447 (let ((gnus-newsgroup-dormant nil))
3448 (gnus-summary-initial-limit show-all))
3449 (gnus-summary-initial-limit show-all))
3450 ;; When unthreaded, all articles are always shown.
3451 (setq gnus-newsgroup-limit
3453 (lambda (header) (mail-header-number header))
3454 gnus-newsgroup-headers)))
3455 ;; Generate the summary buffer.
3457 (gnus-summary-prepare))
3458 (when gnus-use-trees
3459 (gnus-tree-open group)
3460 (setq gnus-summary-highlight-line-function
3461 'gnus-tree-highlight-article))
3462 ;; If the summary buffer is empty, but there are some low-scored
3463 ;; articles or some excluded dormants, we include these in the
3465 (when (and (zerop (buffer-size))
3467 (cond (gnus-newsgroup-dormant
3468 (gnus-summary-limit-include-dormant))
3469 ((and gnus-newsgroup-scored show-all)
3470 (gnus-summary-limit-include-expunged t))))
3471 ;; Function `gnus-apply-kill-file' must be called in this hook.
3472 (gnus-run-hooks 'gnus-apply-kill-hook)
3473 (if (and (zerop (buffer-size))
3476 ;; This newsgroup is empty.
3477 (gnus-summary-catchup-and-exit nil t)
3478 (gnus-message 6 "No unread news")
3480 (gnus-kill-or-deaden-summary kill-buffer))
3481 ;; Return nil from this function.
3483 ;; Hide conversation thread subtrees. We cannot do this in
3484 ;; gnus-summary-prepare-hook since kill processing may not
3485 ;; work with hidden articles.
3486 (gnus-summary-maybe-hide-threads)
3488 (gnus-kill-or-deaden-summary kill-buffer))
3489 (gnus-summary-auto-select-subject)
3490 ;; Show first unread article if requested.
3491 (if (and (not no-article)
3493 gnus-newsgroup-unreads
3494 gnus-auto-select-first)
3496 (gnus-configure-windows 'summary)
3497 (let ((art (gnus-summary-article-number)))
3498 (unless (or (memq art gnus-newsgroup-undownloaded)
3499 (memq art gnus-newsgroup-downloadable))
3500 (gnus-summary-goto-article art))))
3501 ;; Don't select any articles.
3502 (gnus-summary-position-point)
3503 (gnus-configure-windows 'summary 'force)
3504 (gnus-set-mode-line 'summary))
3505 (when (get-buffer-window gnus-group-buffer t)
3506 ;; Gotta use windows, because recenter does weird stuff if
3507 ;; the current buffer ain't the displayed window.
3508 (let ((owin (selected-window)))
3509 (select-window (get-buffer-window gnus-group-buffer t))
3510 (when (gnus-group-goto-group group)
3512 (select-window owin)))
3513 ;; Mark this buffer as "prepared".
3514 (setq gnus-newsgroup-prepared t)
3515 (gnus-run-hooks 'gnus-summary-prepared-hook)
3518 (defun gnus-summary-auto-select-subject ()
3519 "Select the subject line on initial group entry."
3520 (goto-char (point-min))
3522 ((eq gnus-auto-select-subject 'best)
3523 (gnus-summary-best-unread-subject))
3524 ((eq gnus-auto-select-subject 'unread)
3525 (gnus-summary-first-unread-subject))
3526 ((eq gnus-auto-select-subject 'unseen)
3527 (gnus-summary-first-unseen-subject))
3528 ((eq gnus-auto-select-subject 'unseen-or-unread)
3529 (gnus-summary-first-unseen-or-unread-subject))
3530 ((eq gnus-auto-select-subject 'first)
3533 ((gnus-functionp gnus-auto-select-subject)
3534 (funcall gnus-auto-select-subject))))
3536 (defun gnus-summary-prepare ()
3537 "Generate the summary buffer."
3539 (let ((buffer-read-only nil))
3541 (setq gnus-newsgroup-data nil
3542 gnus-newsgroup-data-reverse nil)
3543 (gnus-run-hooks 'gnus-summary-generate-hook)
3544 ;; Generate the buffer, either with threads or without.
3545 (when gnus-newsgroup-headers
3546 (gnus-summary-prepare-threads
3547 (if gnus-show-threads
3548 (gnus-sort-gathered-threads
3549 (funcall gnus-summary-thread-gathering-function
3551 (gnus-cut-threads (gnus-make-threads)))))
3552 ;; Unthreaded display.
3553 (gnus-sort-articles gnus-newsgroup-headers))))
3554 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3555 ;; Call hooks for modifying summary buffer.
3556 (goto-char (point-min))
3557 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3559 (defsubst gnus-general-simplify-subject (subject)
3560 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3563 ;; Truncate the subject.
3564 (gnus-simplify-subject-functions
3565 (gnus-map-function gnus-simplify-subject-functions subject))
3566 ((numberp gnus-summary-gather-subject-limit)
3567 (setq subject (gnus-simplify-subject-re subject))
3568 (if (> (length subject) gnus-summary-gather-subject-limit)
3569 (substring subject 0 gnus-summary-gather-subject-limit)
3571 ;; Fuzzily simplify it.
3572 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3573 (gnus-simplify-subject-fuzzy subject))
3574 ;; Just remove the leading "Re:".
3576 (gnus-simplify-subject-re subject))))
3578 (if (and gnus-summary-gather-exclude-subject
3579 (string-match gnus-summary-gather-exclude-subject subject))
3580 nil ; This article shouldn't be gathered
3583 (defun gnus-summary-simplify-subject-query ()
3584 "Query where the respool algorithm would put this article."
3586 (gnus-summary-select-article)
3588 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3590 (defun gnus-gather-threads-by-subject (threads)
3591 "Gather threads by looking at Subject headers."
3592 (if (not gnus-summary-make-false-root)
3594 (let ((hashtb (gnus-make-hashtable 1024))
3597 subject hthread whole-subject)
3599 (setq subject (gnus-general-simplify-subject
3600 (setq whole-subject (mail-header-subject
3603 (if (setq hthread (gnus-gethash subject hashtb))
3605 ;; We enter a dummy root into the thread, if we
3606 ;; haven't done that already.
3607 (unless (stringp (caar hthread))
3608 (setcar hthread (list whole-subject (car hthread))))
3609 ;; We add this new gathered thread to this gathered
3611 (setcdr (car hthread)
3612 (nconc (cdar hthread) (list (car threads))))
3613 ;; Remove it from the list of threads.
3614 (setcdr prev (cdr threads))
3615 (setq threads prev))
3616 ;; Enter this thread into the hash table.
3617 (gnus-sethash subject
3618 (if gnus-summary-make-false-root-always
3620 ;; If you want a dummy root above all
3622 (setcar threads (list whole-subject
3628 (setq threads (cdr threads)))
3631 (defun gnus-gather-threads-by-references (threads)
3632 "Gather threads by looking at References headers."
3633 (let ((idhashtb (gnus-make-hashtable 1024))
3634 (thhashtb (gnus-make-hashtable 1024))
3637 ids references id gthread gid entered ref)
3639 (when (setq references (mail-header-references (caar threads)))
3640 (setq id (mail-header-id (caar threads))
3641 ids (inline (gnus-split-references references))
3643 (while (setq ref (pop ids))
3644 (setq ids (delete ref ids))
3645 (if (not (setq gid (gnus-gethash ref idhashtb)))
3647 (gnus-sethash ref id idhashtb)
3648 (gnus-sethash id threads thhashtb))
3649 (setq gthread (gnus-gethash gid thhashtb))
3651 ;; We enter a dummy root into the thread, if we
3652 ;; haven't done that already.
3653 (unless (stringp (caar gthread))
3654 (setcar gthread (list (mail-header-subject (caar gthread))
3656 ;; We add this new gathered thread to this gathered
3658 (setcdr (car gthread)
3659 (nconc (cdar gthread) (list (car threads)))))
3660 ;; Add it into the thread hash table.
3661 (gnus-sethash id gthread thhashtb)
3663 ;; Remove it from the list of threads.
3664 (setcdr prev (cdr threads))
3665 (setq threads prev))))
3667 (setq threads (cdr threads)))
3670 (defun gnus-sort-gathered-threads (threads)
3671 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3672 (let ((result threads))
3674 (when (stringp (caar threads))
3675 (setcdr (car threads)
3676 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3677 (setq threads (cdr threads)))
3680 (defun gnus-thread-loop-p (root thread)
3681 "Say whether ROOT is in THREAD."
3682 (let ((stack (list thread))
3685 (while (setq thread (pop stack))
3686 (setq th (cdr thread))
3688 (not (eq (caar th) root)))
3691 ;; We have found a loop.
3693 (setcdr thread (delq (car th) (cdr thread)))
3694 (if (boundp (setq ref-dep (intern "none"
3695 gnus-newsgroup-dependencies)))
3696 (setcdr (symbol-value ref-dep)
3697 (nconc (cdr (symbol-value ref-dep))
3699 (set ref-dep (list nil (car th))))
3702 ;; Push all the subthreads onto the stack.
3703 (push (cdr thread) stack)))
3706 (defun gnus-make-threads ()
3707 "Go through the dependency hashtb and find the roots. Return all threads."
3709 (while (catch 'infloop
3712 ;; Deal with self-referencing References loops.
3713 (when (and (car (symbol-value refs))
3720 (car (symbol-value refs)) thread))
3721 (cdr (symbol-value refs)))))))
3724 (unless (car (symbol-value refs))
3725 ;; These threads do not refer back to any other articles,
3726 ;; so they're roots.
3727 (setq threads (append (cdr (symbol-value refs)) threads))))
3728 gnus-newsgroup-dependencies)))
3731 ;; Build the thread tree.
3732 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3733 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3735 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3736 if it was already present.
3738 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3739 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3740 Message-IDs will be renamed to a unique Message-ID before being
3743 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3744 (let* ((id (mail-header-id header))
3745 (id-dep (and id (intern id dependencies)))
3746 parent-id ref ref-dep ref-header replaced)
3747 ;; Enter this `header' in the `dependencies' table.
3751 ;; The first two cases do the normal part: enter a new `header'
3752 ;; in the `dependencies' table.
3753 ((not (boundp id-dep))
3754 (set id-dep (list header)))
3755 ((null (car (symbol-value id-dep)))
3756 (setcar (symbol-value id-dep) header))
3758 ;; From here the `header' was already present in the
3759 ;; `dependencies' table.
3761 ;; Overrides an existing entry;
3762 ;; just set the header part of the entry.
3763 (setcar (symbol-value id-dep) header)
3766 ;; Renames the existing `header' to a unique Message-ID.
3767 ((not gnus-summary-ignore-duplicates)
3768 ;; An article with this Message-ID has already been seen.
3769 ;; We rename the Message-ID.
3770 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3772 (mail-header-set-id header id))
3774 ;; The last case ignores an existing entry, except it adds any
3775 ;; additional Xrefs (in case the two articles came from different
3777 ;; Also sets `header' to `nil' meaning that the `dependencies'
3778 ;; table was *not* modified.
3780 (mail-header-set-xref
3781 (car (symbol-value id-dep))
3782 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3784 (or (mail-header-xref header) "")))
3787 (when (and header (not replaced))
3788 ;; First check that we are not creating a References loop.
3789 (setq parent-id (gnus-parent-id (mail-header-references header)))
3790 (setq ref parent-id)
3792 (setq ref-dep (intern-soft ref dependencies))
3794 (setq ref-header (car (symbol-value ref-dep))))
3795 (if (string= id ref)
3796 ;; Yuk! This is a reference loop. Make the article be a
3799 (mail-header-set-references (car (symbol-value id-dep)) "none")
3801 (setq parent-id nil))
3802 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3803 (setq ref-dep (intern (or parent-id "none") dependencies))
3804 (if (boundp ref-dep)
3805 (setcdr (symbol-value ref-dep)
3806 (nconc (cdr (symbol-value ref-dep))
3807 (list (symbol-value id-dep))))
3808 (set ref-dep (list nil (symbol-value id-dep)))))
3811 (defun gnus-extract-message-id-from-in-reply-to (string)
3812 (if (string-match "<[^>]+>" string)
3813 (substring string (match-beginning 0) (match-end 0))
3816 (defun gnus-build-sparse-threads ()
3817 (let ((headers gnus-newsgroup-headers)
3818 (mail-parse-charset gnus-newsgroup-charset)
3819 (gnus-summary-ignore-duplicates t)
3820 header references generation relations
3821 subject child end new-child date)
3822 ;; First we create an alist of generations/relations, where
3823 ;; generations is how much we trust the relation, and the relation
3825 (gnus-message 7 "Making sparse threads...")
3827 (nnheader-set-temp-buffer " *gnus sparse threads*")
3828 (while (setq header (pop headers))
3829 (when (and (setq references (mail-header-references header))
3830 (not (string= references "")))
3832 (setq child (mail-header-id header)
3833 subject (mail-header-subject header)
3834 date (mail-header-date header)
3836 (while (search-backward ">" nil t)
3837 (setq end (1+ (point)))
3838 (when (search-backward "<" nil t)
3839 (setq new-child (buffer-substring (point) end))
3840 (push (list (incf generation)
3841 child (setq child new-child)
3845 (push (list (1+ generation) child nil subject) relations))
3847 (kill-buffer (current-buffer)))
3848 ;; Sort over trustworthiness.
3851 (when (gnus-dependencies-add-header
3852 (make-full-mail-header-from-decoded-header
3853 gnus-reffed-article-number
3854 (nth 3 relation) "" (or (nth 4 relation) "")
3856 (or (nth 2 relation) "") 0 0 "")
3857 gnus-newsgroup-dependencies nil)
3858 (push gnus-reffed-article-number gnus-newsgroup-limit)
3859 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3860 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3861 gnus-newsgroup-reads)
3862 (decf gnus-reffed-article-number)))
3863 (sort relations 'car-less-than-car))
3864 (gnus-message 7 "Making sparse threads...done")))
3866 (defun gnus-build-old-threads ()
3867 ;; Look at all the articles that refer back to old articles, and
3868 ;; fetch the headers for the articles that aren't there. This will
3869 ;; build complete threads - if the roots haven't been expired by the
3871 (let ((mail-parse-charset gnus-newsgroup-charset)
3875 (when (not (car (symbol-value refs)))
3876 (setq heads (cdr (symbol-value refs)))
3878 (if (memq (mail-header-number (caar heads))
3879 gnus-newsgroup-dormant)
3880 (setq heads (cdr heads))
3881 (setq id (symbol-name refs))
3882 (while (and (setq id (gnus-build-get-header id))
3883 (not (car (gnus-id-to-thread id)))))
3884 (setq heads nil)))))
3885 gnus-newsgroup-dependencies)))
3887 ;; This function has to be called with point after the article number
3888 ;; on the beginning of the line.
3889 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3890 (let ((eol (gnus-point-at-eol))
3891 (buffer (current-buffer))
3892 header references in-reply-to)
3894 ;; overview: [num subject from date id refs chars lines misc]
3897 (narrow-to-region (point) eol)
3902 (make-full-mail-header
3904 (nnheader-nov-field) ; subject
3905 (nnheader-nov-field) ; from
3906 (nnheader-nov-field) ; date
3907 (nnheader-nov-read-message-id) ; id
3908 (nnheader-nov-field) ; refs
3909 (nnheader-nov-read-integer) ; chars
3910 (nnheader-nov-read-integer) ; lines
3912 (if (looking-at "Xref: ")
3913 (goto-char (match-end 0)))
3914 (nnheader-nov-field)) ; Xref
3915 (nnheader-nov-parse-extra)))) ; extra
3919 (when (and (string= references "")
3920 (setq in-reply-to (mail-header-extra header))
3921 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3922 (mail-header-set-references
3923 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3925 (when gnus-alter-header-function
3926 (funcall gnus-alter-header-function header))
3927 (gnus-dependencies-add-header header dependencies force-new)))
3929 (defun gnus-build-get-header (id)
3930 "Look through the buffer of NOV lines and find the header to ID.
3931 Enter this line into the dependencies hash table, and return
3932 the id of the parent article (if any)."
3933 (let ((deps gnus-newsgroup-dependencies)
3937 (set-buffer nntp-server-buffer)
3938 (let ((case-fold-search nil))
3939 (goto-char (point-min))
3940 (while (and (not found)
3941 (search-forward id nil t))
3943 (setq found (looking-at
3944 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3945 (regexp-quote id))))
3946 (or found (beginning-of-line 2)))
3950 (setq header (gnus-nov-parse-line
3951 (read (current-buffer)) deps))
3952 (gnus-parent-id (mail-header-references header))))))
3954 (let ((number (mail-header-number header)))
3955 (push number gnus-newsgroup-limit)
3956 (push header gnus-newsgroup-headers)
3957 (if (memq number gnus-newsgroup-unselected)
3959 (setq gnus-newsgroup-unreads
3960 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3962 (setq gnus-newsgroup-unselected
3963 (delq number gnus-newsgroup-unselected)))
3964 (push number gnus-newsgroup-ancient)))))))
3966 (defun gnus-build-all-threads ()
3967 "Read all the headers."
3968 (let ((gnus-summary-ignore-duplicates t)
3969 (mail-parse-charset gnus-newsgroup-charset)
3970 (dependencies gnus-newsgroup-dependencies)
3973 (set-buffer nntp-server-buffer)
3974 (let ((case-fold-search nil))
3975 (goto-char (point-min))
3978 (setq article (read (current-buffer))
3979 header (gnus-nov-parse-line article dependencies)))
3982 (set-buffer gnus-summary-buffer)
3983 (push header gnus-newsgroup-headers)
3984 (if (memq (setq article (mail-header-number header))
3985 gnus-newsgroup-unselected)
3987 (setq gnus-newsgroup-unreads
3988 (gnus-add-to-sorted-list
3989 gnus-newsgroup-unreads article))
3990 (setq gnus-newsgroup-unselected
3991 (delq article gnus-newsgroup-unselected)))
3992 (push article gnus-newsgroup-ancient)))
3993 (forward-line 1)))))))
3995 (defun gnus-summary-update-article-line (article header)
3996 "Update the line for ARTICLE using HEADERS."
3997 (let* ((id (mail-header-id header))
3998 (thread (gnus-id-to-thread id)))
4000 (error "Article in no thread"))
4001 ;; Update the thread.
4002 (setcar thread header)
4003 (gnus-summary-goto-subject article)
4004 (let* ((datal (gnus-data-find-list article))
4006 (length (when (cdr datal)
4007 (- (gnus-data-pos data)
4008 (gnus-data-pos (cadr datal)))))
4009 (buffer-read-only nil)
4010 (level (gnus-summary-thread-level)))
4012 (gnus-summary-insert-line
4014 (memq article gnus-newsgroup-undownloaded)
4015 (gnus-article-mark article)
4016 (memq article gnus-newsgroup-replied)
4017 (memq article gnus-newsgroup-expirable)
4018 ;; Only insert the Subject string when it's different
4019 ;; from the previous Subject string.
4024 (mail-header-subject
4027 (gnus-data-find-list
4029 (gnus-data-list t)))))
4030 ;; Error on the side of excessive subjects.
4032 (mail-header-subject header)))
4034 (mail-header-subject header))
4035 nil (cdr (assq article gnus-newsgroup-scored))
4036 (memq article gnus-newsgroup-processable))
4038 (gnus-data-update-list
4039 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4041 (defun gnus-summary-update-article (article &optional iheader)
4042 "Update ARTICLE in the summary buffer."
4043 (set-buffer gnus-summary-buffer)
4044 (let* ((header (gnus-summary-article-header article))
4045 (id (mail-header-id header))
4046 (data (gnus-data-find article))
4047 (thread (gnus-id-to-thread id))
4048 (references (mail-header-references header))
4052 (when (and references
4053 (not (equal "" references)))
4056 (buffer-read-only nil)
4062 (delq thread parent)))
4063 (if (gnus-summary-insert-subject id header)
4064 ;; Set the (possibly) new article number in the data structure.
4065 (gnus-data-set-number data (gnus-id-to-article id))
4069 (defun gnus-rebuild-thread (id &optional line)
4070 "Rebuild the thread containing ID.
4071 If LINE, insert the rebuilt thread starting on line LINE."
4072 (let ((buffer-read-only nil)
4073 old-pos current thread data)
4074 (if (not gnus-show-threads)
4075 (setq thread (list (car (gnus-id-to-thread id))))
4076 ;; Get the thread this article is part of.
4077 (setq thread (gnus-remove-thread id)))
4078 (setq old-pos (gnus-point-at-bol))
4079 (setq current (save-excursion
4080 (and (re-search-backward "[\r\n]" nil t)
4081 (gnus-summary-article-number))))
4082 ;; If this is a gathered thread, we have to go some re-gathering.
4083 (when (stringp (car thread))
4084 (let ((subject (car thread))
4086 (setq thread (cdr thread))
4088 (unless (memq (setq thr (gnus-id-to-thread
4090 (mail-header-id (caar thread)))))
4093 (setq thread (cdr thread)))
4094 ;; We now have all (unique) roots.
4095 (if (= (length roots) 1)
4096 ;; All the loose roots are now one solid root.
4097 (setq thread (car roots))
4098 (setq thread (cons subject (gnus-sort-threads roots))))))
4100 ;; We then insert this thread into the summary buffer.
4102 (goto-char (point-min))
4103 (forward-line (1- line)))
4104 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4105 (if gnus-show-threads
4106 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4107 (gnus-summary-prepare-unthreaded thread))
4108 (setq data (nreverse gnus-newsgroup-data))
4109 (setq threads gnus-newsgroup-threads))
4110 ;; We splice the new data into the data structure.
4111 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4112 ;;!!! then we want to insert at the beginning of the buffer.
4113 ;;!!! That happens to be true with Gnus now, but that may
4114 ;;!!! change in the future. Perhaps.
4115 (gnus-data-enter-list
4116 (if line nil current) data (- (point) old-pos))
4117 (setq gnus-newsgroup-threads
4118 (nconc threads gnus-newsgroup-threads))
4119 (gnus-data-compute-positions))))
4121 (defun gnus-number-to-header (number)
4122 "Return the header for article NUMBER."
4123 (let ((headers gnus-newsgroup-headers))
4125 (not (= number (mail-header-number (car headers)))))
4130 (defun gnus-parent-headers (in-headers &optional generation)
4131 "Return the headers of the GENERATIONeth parent of HEADERS."
4133 (setq generation 1))
4135 (headers in-headers)
4138 (not (zerop generation))
4139 (setq references (mail-header-references headers)))
4140 (setq headers (if (and references
4141 (setq parent (gnus-parent-id references)))
4142 (car (gnus-id-to-thread parent))
4145 (and (not (eq headers in-headers))
4148 (defun gnus-id-to-thread (id)
4149 "Return the (sub-)thread where ID appears."
4150 (gnus-gethash id gnus-newsgroup-dependencies))
4152 (defun gnus-id-to-article (id)
4153 "Return the article number of ID."
4154 (let ((thread (gnus-id-to-thread id)))
4157 (mail-header-number (car thread)))))
4159 (defun gnus-id-to-header (id)
4160 "Return the article headers of ID."
4161 (car (gnus-id-to-thread id)))
4163 (defun gnus-article-displayed-root-p (article)
4164 "Say whether ARTICLE is a root(ish) article."
4165 (let ((level (gnus-summary-thread-level article))
4166 (refs (mail-header-references (gnus-summary-article-header article)))
4172 ((null (gnus-parent-id refs)) t)
4174 (null (setq particle (gnus-id-to-article
4175 (gnus-parent-id refs))))
4176 (null (gnus-summary-thread-level particle)))))))
4178 (defun gnus-root-id (id)
4179 "Return the id of the root of the thread where ID appears."
4181 (while (and id (setq prev (car (gnus-id-to-thread id))))
4183 id (gnus-parent-id (mail-header-references prev))))
4186 (defun gnus-articles-in-thread (thread)
4187 "Return the list of articles in THREAD."
4188 (cons (mail-header-number (car thread))
4189 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4191 (defun gnus-remove-thread (id &optional dont-remove)
4192 "Remove the thread that has ID in it."
4193 (let (headers thread last-id)
4194 ;; First go up in this thread until we find the root.
4195 (setq last-id (gnus-root-id id)
4196 headers (message-flatten-list (gnus-id-to-thread last-id)))
4197 ;; We have now found the real root of this thread. It might have
4198 ;; been gathered into some loose thread, so we have to search
4199 ;; through the threads to find the thread we wanted.
4200 (let ((threads gnus-newsgroup-threads)
4203 (setq sub (car threads))
4204 (if (stringp (car sub))
4205 ;; This is a gathered thread, so we look at the roots
4206 ;; below it to find whether this article is in this
4209 (setq sub (cdr sub))
4211 (when (member (caar sub) headers)
4212 (setq thread (car threads)
4215 (setq sub (cdr sub))))
4216 ;; It's an ordinary thread, so we check it.
4217 (when (eq (car sub) (car headers))
4220 (setq threads (cdr threads)))
4221 ;; If this article is in no thread, then it's a root.
4224 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4225 (setq thread (gnus-id-to-thread last-id)))
4228 thread ; We return this thread.
4230 (if (stringp (car thread))
4232 ;; If we use dummy roots, then we have to remove the
4233 ;; dummy root as well.
4234 (when (eq gnus-summary-make-false-root 'dummy)
4235 ;; We go to the dummy root by going to
4236 ;; the first sub-"thread", and then one line up.
4237 (gnus-summary-goto-article
4238 (mail-header-number (caadr thread)))
4241 (gnus-data-compute-positions))
4242 (setq thread (cdr thread))
4244 (gnus-remove-thread-1 (car thread))
4245 (setq thread (cdr thread))))
4246 (gnus-remove-thread-1 thread))))))))
4248 (defun gnus-remove-thread-1 (thread)
4249 "Remove the thread THREAD recursively."
4250 (let ((number (mail-header-number (pop thread)))
4252 (setq thread (reverse thread))
4254 (gnus-remove-thread-1 (pop thread)))
4255 (when (setq d (gnus-data-find number))
4256 (goto-char (gnus-data-pos d))
4257 (gnus-summary-show-thread)
4260 (- (gnus-point-at-bol)
4262 (1+ (gnus-point-at-eol))
4263 (gnus-delete-line)))))))
4265 (defun gnus-sort-threads-1 (threads func)
4266 (sort (mapcar (lambda (thread)
4269 (gnus-sort-threads-1 (cdr thread) func))))
4272 (defun gnus-sort-threads (threads)
4274 (if (not gnus-thread-sort-functions)
4276 (gnus-message 8 "Sorting threads...")
4277 (let ((max-lisp-eval-depth 5000))
4278 (prog1 (gnus-sort-threads-1
4280 (gnus-make-sort-function gnus-thread-sort-functions))
4281 (gnus-message 8 "Sorting threads...done")))))
4283 (defun gnus-sort-articles (articles)
4285 (when gnus-article-sort-functions
4286 (gnus-message 7 "Sorting articles...")
4288 (setq gnus-newsgroup-headers
4289 (sort articles (gnus-make-sort-function
4290 gnus-article-sort-functions)))
4291 (gnus-message 7 "Sorting articles...done"))))
4293 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4294 (defmacro gnus-thread-header (thread)
4295 "Return header of first article in THREAD.
4296 Note that THREAD must never, ever be anything else than a variable -
4297 using some other form will lead to serious barfage."
4298 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4299 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4300 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4303 (defsubst gnus-article-sort-by-number (h1 h2)
4304 "Sort articles by article number."
4305 (< (mail-header-number h1)
4306 (mail-header-number h2)))
4308 (defun gnus-thread-sort-by-number (h1 h2)
4309 "Sort threads by root article number."
4310 (gnus-article-sort-by-number
4311 (gnus-thread-header h1) (gnus-thread-header h2)))
4313 (defsubst gnus-article-sort-by-random (h1 h2)
4314 "Sort articles by article number."
4317 (defun gnus-thread-sort-by-random (h1 h2)
4318 "Sort threads by root article number."
4319 (gnus-article-sort-by-random
4320 (gnus-thread-header h1) (gnus-thread-header h2)))
4322 (defsubst gnus-article-sort-by-lines (h1 h2)
4323 "Sort articles by article Lines header."
4324 (< (mail-header-lines h1)
4325 (mail-header-lines h2)))
4327 (defun gnus-thread-sort-by-lines (h1 h2)
4328 "Sort threads by root article Lines header."
4329 (gnus-article-sort-by-lines
4330 (gnus-thread-header h1) (gnus-thread-header h2)))
4332 (defsubst gnus-article-sort-by-chars (h1 h2)
4333 "Sort articles by octet length."
4334 (< (mail-header-chars h1)
4335 (mail-header-chars h2)))
4337 (defun gnus-thread-sort-by-chars (h1 h2)
4338 "Sort threads by root article octet length."
4339 (gnus-article-sort-by-chars
4340 (gnus-thread-header h1) (gnus-thread-header h2)))
4342 (defsubst gnus-article-sort-by-author (h1 h2)
4343 "Sort articles by root author."
4345 (let ((addr (car (mime-entity-read-field h1 'From))))
4346 (or (std11-full-name-string addr)
4347 (std11-address-string addr)
4349 (let ((addr (car (mime-entity-read-field h2 'From))))
4350 (or (std11-full-name-string addr)
4351 (std11-address-string addr)
4355 (defun gnus-thread-sort-by-author (h1 h2)
4356 "Sort threads by root author."
4357 (gnus-article-sort-by-author
4358 (gnus-thread-header h1) (gnus-thread-header h2)))
4360 (defsubst gnus-article-sort-by-subject (h1 h2)
4361 "Sort articles by root subject."
4363 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4364 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4366 (defun gnus-thread-sort-by-subject (h1 h2)
4367 "Sort threads by root subject."
4368 (gnus-article-sort-by-subject
4369 (gnus-thread-header h1) (gnus-thread-header h2)))
4371 (defsubst gnus-article-sort-by-date (h1 h2)
4372 "Sort articles by root article date."
4374 (gnus-date-get-time (mail-header-date h1))
4375 (gnus-date-get-time (mail-header-date h2))))
4377 (defun gnus-thread-sort-by-date (h1 h2)
4378 "Sort threads by root article date."
4379 (gnus-article-sort-by-date
4380 (gnus-thread-header h1) (gnus-thread-header h2)))
4382 (defsubst gnus-article-sort-by-score (h1 h2)
4383 "Sort articles by root article score.
4384 Unscored articles will be counted as having a score of zero."
4385 (> (or (cdr (assq (mail-header-number h1)
4386 gnus-newsgroup-scored))
4387 gnus-summary-default-score 0)
4388 (or (cdr (assq (mail-header-number h2)
4389 gnus-newsgroup-scored))
4390 gnus-summary-default-score 0)))
4392 (defun gnus-thread-sort-by-score (h1 h2)
4393 "Sort threads by root article score."
4394 (gnus-article-sort-by-score
4395 (gnus-thread-header h1) (gnus-thread-header h2)))
4397 (defun gnus-thread-sort-by-total-score (h1 h2)
4398 "Sort threads by the sum of all scores in the thread.
4399 Unscored articles will be counted as having a score of zero."
4400 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4402 (defun gnus-thread-total-score (thread)
4403 ;; This function find the total score of THREAD.
4408 (if (stringp (car thread))
4409 (apply gnus-thread-score-function 0
4410 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4411 (gnus-thread-total-score-1 thread)))
4413 (gnus-thread-total-score-1 (list thread)))))
4415 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4416 "Sort threads such that the thread with the most recently arrived article comes first."
4417 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4419 (defun gnus-thread-highest-number (thread)
4420 "Return the highest article number in THREAD."
4421 (apply 'max (mapcar (lambda (header)
4422 (mail-header-number header))
4423 (message-flatten-list thread))))
4425 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4426 "Sort threads such that the thread with the most recently dated article comes first."
4427 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4429 (defun gnus-thread-latest-date (thread)
4430 "Return the highest article date in THREAD."
4431 (let ((previous-time 0))
4438 (mail-header-parse-date (mail-header-date header))
4439 (error previous-time)))))
4441 (message-flatten-list thread)
4443 (< (mail-header-number h1)
4444 (mail-header-number h2))))))))
4446 (defun gnus-thread-total-score-1 (root)
4447 ;; This function find the total score of the thread below ROOT.
4448 (setq root (car root))
4449 (apply gnus-thread-score-function
4451 (mapcar 'gnus-thread-total-score
4452 (cdr (gnus-id-to-thread (mail-header-id root))))
4453 (when (> (mail-header-number root) 0)
4454 (list (or (cdr (assq (mail-header-number root)
4455 gnus-newsgroup-scored))
4456 gnus-summary-default-score 0))))
4457 (list gnus-summary-default-score)
4460 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4461 (defvar gnus-tmp-prev-subject nil)
4462 (defvar gnus-tmp-false-parent nil)
4463 (defvar gnus-tmp-root-expunged nil)
4464 (defvar gnus-tmp-dummy-line nil)
4466 (eval-when-compile (defvar gnus-tmp-header))
4467 (defun gnus-extra-header (type &optional header)
4468 "Return the extra header of TYPE."
4469 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4472 (defvar gnus-tmp-thread-tree-header-string "")
4474 (defcustom gnus-sum-thread-tree-root "> "
4475 "With %B spec, used for the root of a thread.
4476 If nil, use subject instead."
4478 :group 'gnus-thread)
4479 (defcustom gnus-sum-thread-tree-single-indent ""
4480 "With %B spec, used for a thread with just one message.
4481 If nil, use subject instead."
4483 :group 'gnus-thread)
4484 (defcustom gnus-sum-thread-tree-vertical "| "
4485 "With %B spec, used for drawing a vertical line."
4487 :group 'gnus-thread)
4488 (defcustom gnus-sum-thread-tree-indent " "
4489 "With %B spec, used for indenting."
4491 :group 'gnus-thread)
4492 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4493 "With %B spec, used for a leaf with brothers."
4495 :group 'gnus-thread)
4496 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4497 "With %B spec, used for a leaf without brothers."
4499 :group 'gnus-thread)
4501 (defun gnus-summary-prepare-threads (threads)
4502 "Prepare summary buffer from THREADS and indentation LEVEL.
4503 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4504 or a straight list of headers."
4505 (gnus-message 7 "Generating summary...")
4507 (setq gnus-newsgroup-threads threads)
4510 (let ((gnus-tmp-level 0)
4511 (default-score (or gnus-summary-default-score 0))
4512 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4513 thread number subject stack state gnus-tmp-gathered beg-match
4514 new-roots gnus-tmp-new-adopts thread-end simp-subject
4515 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4516 gnus-tmp-replied gnus-tmp-subject-or-nil
4517 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4518 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4519 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4522 (setq gnus-tmp-prev-subject nil)
4524 (if (vectorp (car threads))
4525 ;; If this is a straight (sic) list of headers, then a
4526 ;; threaded summary display isn't required, so we just create
4527 ;; an unthreaded one.
4528 (gnus-summary-prepare-unthreaded threads)
4530 ;; Do the threaded display.
4532 (while (or threads stack gnus-tmp-new-adopts new-roots)
4534 (if (and (= gnus-tmp-level 0)
4537 (not gnus-tmp-false-parent)
4538 (or gnus-tmp-new-adopts new-roots))
4539 (if gnus-tmp-new-adopts
4540 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4541 thread (list (car gnus-tmp-new-adopts))
4542 gnus-tmp-header (caar thread)
4543 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4545 (setq thread (list (car new-roots))
4546 gnus-tmp-header (caar thread)
4547 new-roots (cdr new-roots))))
4550 ;; If there are some threads, we do them before the
4551 ;; threads on the stack.
4552 (setq thread threads
4553 gnus-tmp-header (caar thread))
4554 ;; There were no current threads, so we pop something off
4556 (setq state (car stack)
4557 gnus-tmp-level (car state)
4558 tree-stack (cadr state)
4559 thread (caddr state)
4561 gnus-tmp-header (caar thread))))
4563 (setq gnus-tmp-false-parent nil)
4564 (setq gnus-tmp-root-expunged nil)
4565 (setq thread-end nil)
4567 (if (stringp gnus-tmp-header)
4568 ;; The header is a dummy root.
4570 ((eq gnus-summary-make-false-root 'adopt)
4571 ;; We let the first article adopt the rest.
4572 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4574 (setq gnus-tmp-gathered
4576 (lambda (h) (mail-header-number (car h)))
4579 (setq thread (cons (list (caar thread)
4582 (setq gnus-tmp-level -1
4583 gnus-tmp-false-parent t))
4584 ((eq gnus-summary-make-false-root 'empty)
4585 ;; We print adopted articles with empty subject fields.
4586 (setq gnus-tmp-gathered
4588 (lambda (h) (mail-header-number (car h)))
4591 (setq gnus-tmp-level -1))
4592 ((eq gnus-summary-make-false-root 'dummy)
4593 ;; We remember that we probably want to output a dummy
4595 (setq gnus-tmp-dummy-line gnus-tmp-header)
4596 (setq gnus-tmp-prev-subject gnus-tmp-header))
4598 ;; We do not make a root for the gathered
4599 ;; sub-threads at all.
4600 (setq gnus-tmp-level -1)))
4602 (setq number (mail-header-number gnus-tmp-header)
4603 subject (mail-header-subject gnus-tmp-header)
4604 simp-subject (gnus-simplify-subject-fully subject))
4607 ;; If the thread has changed subject, we might want to make
4608 ;; this subthread into a root.
4609 ((and (null gnus-thread-ignore-subject)
4610 (not (zerop gnus-tmp-level))
4611 gnus-tmp-prev-subject
4612 (not (string= gnus-tmp-prev-subject simp-subject)))
4613 (setq new-roots (nconc new-roots (list (car thread)))
4615 gnus-tmp-header nil))
4616 ;; If the article lies outside the current limit,
4617 ;; then we do not display it.
4618 ((not (memq number gnus-newsgroup-limit))
4619 (setq gnus-tmp-gathered
4621 (lambda (h) (mail-header-number (car h)))
4624 (setq gnus-tmp-new-adopts (if (cdar thread)
4625 (append gnus-tmp-new-adopts
4627 gnus-tmp-new-adopts)
4629 gnus-tmp-header nil)
4630 (when (zerop gnus-tmp-level)
4631 (setq gnus-tmp-root-expunged t)))
4632 ;; Perhaps this article is to be marked as read?
4633 ((and gnus-summary-mark-below
4634 (< (or (cdr (assq number gnus-newsgroup-scored))
4636 gnus-summary-mark-below)
4637 ;; Don't touch sparse articles.
4638 (not (gnus-summary-article-sparse-p number))
4639 (not (gnus-summary-article-ancient-p number)))
4640 (setq gnus-newsgroup-unreads
4641 (delq number gnus-newsgroup-unreads))
4642 (if gnus-newsgroup-auto-expire
4643 (setq gnus-newsgroup-expirable
4644 (gnus-add-to-sorted-list
4645 gnus-newsgroup-expirable number))
4646 (push (cons number gnus-low-score-mark)
4647 gnus-newsgroup-reads))))
4649 (when gnus-tmp-header
4650 ;; We may have an old dummy line to output before this
4652 (when (and gnus-tmp-dummy-line
4655 (mail-header-subject gnus-tmp-header)))
4656 (gnus-summary-insert-dummy-line
4657 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4658 (setq gnus-tmp-dummy-line nil))
4660 ;; Compute the mark.
4661 (setq gnus-tmp-unread (gnus-article-mark number))
4663 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4664 gnus-tmp-header gnus-tmp-level)
4665 gnus-newsgroup-data)
4667 ;; Actually insert the line.
4669 gnus-tmp-subject-or-nil
4671 ((and gnus-thread-ignore-subject
4672 gnus-tmp-prev-subject
4673 (not (string= gnus-tmp-prev-subject simp-subject)))
4675 ((zerop gnus-tmp-level)
4676 (if (and (eq gnus-summary-make-false-root 'empty)
4677 (memq number gnus-tmp-gathered)
4678 gnus-tmp-prev-subject
4679 (string= gnus-tmp-prev-subject simp-subject))
4680 gnus-summary-same-subject
4682 (t gnus-summary-same-subject)))
4683 (if (and (eq gnus-summary-make-false-root 'adopt)
4684 (= gnus-tmp-level 1)
4685 (memq number gnus-tmp-gathered))
4686 (setq gnus-tmp-opening-bracket ?\<
4687 gnus-tmp-closing-bracket ?\>)
4688 (setq gnus-tmp-opening-bracket ?\[
4689 gnus-tmp-closing-bracket ?\]))
4691 gnus-tmp-indentation
4692 (aref gnus-thread-indent-array gnus-tmp-level)
4693 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4694 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4695 gnus-summary-default-score 0)
4697 (if (or (null gnus-summary-default-score)
4698 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4699 gnus-summary-zcore-fuzz))
4701 (if (< gnus-tmp-score gnus-summary-default-score)
4702 gnus-score-below-mark gnus-score-over-mark))
4704 (cond ((memq number gnus-newsgroup-processable)
4706 ((memq number gnus-newsgroup-cached)
4708 ((memq number gnus-newsgroup-replied)
4710 ((memq number gnus-newsgroup-forwarded)
4711 gnus-forwarded-mark)
4712 ((memq number gnus-newsgroup-saved)
4714 ((memq number gnus-newsgroup-recent)
4716 ((memq number gnus-newsgroup-unseen)
4720 (cond ((memq number gnus-newsgroup-undownloaded)
4721 gnus-undownloaded-mark)
4722 (gnus-newsgroup-agentized
4723 gnus-downloaded-mark)
4726 gnus-tmp-from (mail-header-from gnus-tmp-header)
4729 ((string-match "<[^>]+> *$" gnus-tmp-from)
4730 (setq beg-match (match-beginning 0))
4731 (or (and (string-match "^\".+\"" gnus-tmp-from)
4732 (substring gnus-tmp-from 1 (1- (match-end 0))))
4733 (substring gnus-tmp-from 0 beg-match)))
4734 ((string-match "(.+)" gnus-tmp-from)
4735 (substring gnus-tmp-from
4736 (1+ (match-beginning 0)) (1- (match-end 0))))
4738 gnus-tmp-thread-tree-header-string
4740 ((not gnus-show-threads) "")
4741 ((zerop gnus-tmp-level)
4743 (or gnus-sum-thread-tree-root subject)
4744 (or gnus-sum-thread-tree-single-indent subject)))
4746 (concat (apply 'concat
4747 (mapcar (lambda (item)
4749 gnus-sum-thread-tree-vertical
4750 gnus-sum-thread-tree-indent))
4751 (cdr (reverse tree-stack))))
4753 gnus-sum-thread-tree-leaf-with-other
4754 gnus-sum-thread-tree-single-leaf)))))
4755 (when (string= gnus-tmp-name "")
4756 (setq gnus-tmp-name gnus-tmp-from))
4757 (unless (numberp gnus-tmp-lines)
4758 (setq gnus-tmp-lines -1))
4759 (if (= gnus-tmp-lines -1)
4760 (setq gnus-tmp-lines "?")
4761 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4762 (gnus-put-text-property
4764 (progn (eval gnus-summary-line-format-spec) (point))
4765 'gnus-number number)
4768 (gnus-run-hooks 'gnus-summary-update-hook)
4771 (setq gnus-tmp-prev-subject simp-subject)))
4773 (when (nth 1 thread)
4774 (push (list (max 0 gnus-tmp-level)
4775 (copy-list tree-stack)
4778 (push (if (nth 1 thread) 1 0) tree-stack)
4779 (incf gnus-tmp-level)
4780 (setq threads (if thread-end nil (cdar thread)))
4782 (setq gnus-tmp-level 0)))))
4783 (gnus-message 7 "Generating summary...done"))
4785 (defun gnus-summary-prepare-unthreaded (headers)
4786 "Generate an unthreaded summary buffer based on HEADERS."
4787 (let (header number mark)
4792 ;; We may have to root out some bad articles...
4793 (when (memq (setq number (mail-header-number
4794 (setq header (pop headers))))
4795 gnus-newsgroup-limit)
4796 ;; Mark article as read when it has a low score.
4797 (when (and gnus-summary-mark-below
4798 (< (or (cdr (assq number gnus-newsgroup-scored))
4799 gnus-summary-default-score 0)
4800 gnus-summary-mark-below)
4801 (not (gnus-summary-article-ancient-p number)))
4802 (setq gnus-newsgroup-unreads
4803 (delq number gnus-newsgroup-unreads))
4804 (if gnus-newsgroup-auto-expire
4805 (push number gnus-newsgroup-expirable)
4806 (push (cons number gnus-low-score-mark)
4807 gnus-newsgroup-reads)))
4809 (setq mark (gnus-article-mark number))
4810 (push (gnus-data-make number mark (1+ (point)) header 0)
4811 gnus-newsgroup-data)
4812 (gnus-summary-insert-line
4814 (memq number gnus-newsgroup-undownloaded)
4815 mark (memq number gnus-newsgroup-replied)
4816 (memq number gnus-newsgroup-expirable)
4817 (mail-header-subject header) nil
4818 (cdr (assq number gnus-newsgroup-scored))
4819 (memq number gnus-newsgroup-processable))))))
4821 (defun gnus-summary-remove-list-identifiers ()
4822 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4823 (let ((regexp (if (consp gnus-list-identifiers)
4824 (mapconcat 'identity gnus-list-identifiers " *\\|")
4825 gnus-list-identifiers))
4828 (dolist (header gnus-newsgroup-headers)
4829 (setq subject (mail-header-subject header)
4831 (while (string-match
4832 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4835 (concat (substring subject 0 (match-beginning 2))
4836 (substring subject (match-end 0)))
4840 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4842 (concat (substring subject 0 (match-beginning 1))
4843 (substring subject (match-end 1)))))
4845 (mail-header-set-subject header subject))))))
4847 (defun gnus-fetch-headers (articles)
4848 "Fetch headers of ARTICLES."
4849 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4850 (gnus-message 5 "Fetching headers for %s..." name)
4853 (setq gnus-headers-retrieved-by
4854 (gnus-retrieve-headers
4855 articles gnus-newsgroup-name
4856 ;; We might want to fetch old headers, but
4857 ;; not if there is only 1 article.
4859 (not (eq gnus-fetch-old-headers 'some))
4860 (not (numberp gnus-fetch-old-headers)))
4861 (> (length articles) 1))
4862 gnus-fetch-old-headers))))
4863 (gnus-get-newsgroup-headers-xover
4864 articles nil nil gnus-newsgroup-name t)
4865 (gnus-get-newsgroup-headers))
4866 (gnus-message 5 "Fetching headers for %s...done" name))))
4868 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4869 "Select newsgroup GROUP.
4870 If READ-ALL is non-nil, all articles in the group are selected.
4871 If SELECT-ARTICLES, only select those articles from GROUP."
4872 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4873 ;;!!! Dirty hack; should be removed.
4874 (gnus-summary-ignore-duplicates
4875 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4877 gnus-summary-ignore-duplicates))
4878 (info (nth 2 entry))
4879 articles fetched-articles cached)
4881 (unless (gnus-check-server
4882 (set (make-local-variable 'gnus-current-select-method)
4883 (gnus-find-method-for-group group)))
4884 (error "Couldn't open server"))
4886 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4887 (gnus-activate-group group) ; Or we can activate it...
4888 (progn ; Or we bug out.
4889 (when (equal major-mode 'gnus-summary-mode)
4890 (kill-buffer (current-buffer)))
4891 (error "Couldn't activate group %s: %s"
4892 group (gnus-status-message group))))
4894 (unless (gnus-request-group group t)
4895 (when (equal major-mode 'gnus-summary-mode)
4896 (kill-buffer (current-buffer)))
4897 (error "Couldn't request group %s: %s"
4898 group (gnus-status-message group)))
4900 (setq gnus-newsgroup-name group
4901 gnus-newsgroup-unselected nil
4902 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4904 (let ((display (gnus-group-find-parameter group 'display)))
4905 (setq gnus-newsgroup-display
4907 ((not (zerop (or (car-safe read-all) 0)))
4908 ;; The user entered the group with C-u SPC/RET, let's show
4914 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4916 ;; The following is probably the "correct" solution, but
4917 ;; it makes Gnus fetch all headers and then limit the
4918 ;; articles (which is slow), so instead we hack the
4919 ;; select-articles parameter instead. -- Simon Josefsson
4922 ;; (gnus-byte-compile
4923 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4925 (setq select-articles
4926 (gnus-uncompress-range
4927 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4931 (cdr (gnus-active group)))))
4936 (gnus-summary-setup-default-charset)
4938 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4939 (when (gnus-virtual-group-p group)
4940 (setq cached gnus-newsgroup-cached))
4942 (setq gnus-newsgroup-unreads
4943 (gnus-sorted-ndifference
4944 (gnus-sorted-ndifference gnus-newsgroup-unreads
4945 gnus-newsgroup-marked)
4946 gnus-newsgroup-dormant))
4948 (setq gnus-newsgroup-processable nil)
4950 (gnus-update-read-articles group gnus-newsgroup-unreads)
4952 ;; Adjust and set lists of article marks.
4954 (gnus-adjust-marked-articles info))
4955 (if (setq articles select-articles)
4956 (setq gnus-newsgroup-unselected
4957 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4958 (setq articles (gnus-articles-to-read group read-all)))
4962 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4964 ((eq articles 0) nil)
4966 ;; Init the dependencies hash table.
4967 (setq gnus-newsgroup-dependencies
4968 (gnus-make-hashtable (length articles)))
4969 (gnus-set-global-variables)
4970 ;; Retrieve the headers and read them in.
4972 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4974 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4976 (setq gnus-newsgroup-cached cached))
4978 ;; Suppress duplicates?
4979 (when gnus-suppress-duplicates
4980 (gnus-dup-suppress-articles))
4982 ;; Set the initial limit.
4983 (setq gnus-newsgroup-limit (copy-sequence articles))
4984 ;; Remove canceled articles from the list of unread articles.
4985 (setq fetched-articles
4986 (mapcar (lambda (headers) (mail-header-number headers))
4987 gnus-newsgroup-headers))
4988 (setq gnus-newsgroup-articles fetched-articles)
4989 (setq gnus-newsgroup-unreads
4990 (gnus-sorted-nintersection
4991 gnus-newsgroup-unreads fetched-articles))
4992 (gnus-compute-unseen-list)
4994 ;; Removed marked articles that do not exist.
4995 (gnus-update-missing-marks
4996 (gnus-sorted-difference articles fetched-articles))
4997 ;; We might want to build some more threads first.
4998 (when (and gnus-fetch-old-headers
4999 (eq gnus-headers-retrieved-by 'nov))
5000 (if (eq gnus-fetch-old-headers 'invisible)
5001 (gnus-build-all-threads)
5002 (gnus-build-old-threads)))
5003 ;; Let the Gnus agent mark articles as read.
5005 (gnus-agent-get-undownloaded-list))
5006 ;; Remove list identifiers from subject
5007 (when gnus-list-identifiers
5008 (gnus-summary-remove-list-identifiers))
5009 ;; Check whether auto-expire is to be done in this group.
5010 (setq gnus-newsgroup-auto-expire
5011 (gnus-group-auto-expirable-p group))
5012 ;; Set up the article buffer now, if necessary.
5013 (unless gnus-single-article-buffer
5014 (gnus-article-setup-buffer))
5015 ;; First and last article in this newsgroup.
5016 (when gnus-newsgroup-headers
5017 (setq gnus-newsgroup-begin
5018 (mail-header-number (car gnus-newsgroup-headers))
5021 (gnus-last-element gnus-newsgroup-headers))))
5022 ;; GROUP is successfully selected.
5023 (or gnus-newsgroup-headers t)))))
5025 (defun gnus-compute-unseen-list ()
5026 ;; The `seen' marks are treated specially.
5027 (if (not gnus-newsgroup-seen)
5028 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5029 (setq gnus-newsgroup-unseen
5030 (gnus-inverse-list-range-intersection
5031 gnus-newsgroup-articles gnus-newsgroup-seen))))
5033 (defun gnus-summary-display-make-predicate (display)
5034 (require 'gnus-agent)
5035 (when (= (length display) 1)
5036 (setq display (car display)))
5037 (unless gnus-summary-display-cache
5038 (dolist (elem (append '((unread . unread)
5041 gnus-article-mark-lists))
5042 (push (cons (cdr elem)
5044 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5045 gnus-summary-display-cache)))
5046 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5047 (gnus-category-predicate-cache gnus-summary-display-cache))
5048 (gnus-get-predicate display)))
5050 ;; Uses the dynamically bound `number' variable.
5053 (defun gnus-article-marked-p (type &optional article)
5054 (let ((article (or article number)))
5057 (memq article gnus-newsgroup-marked))
5059 (memq article gnus-newsgroup-spam-marked))
5061 (memq article gnus-newsgroup-unsendable))
5062 ((eq type 'undownload)
5063 (memq article gnus-newsgroup-undownloaded))
5064 ((eq type 'download)
5065 (memq article gnus-newsgroup-downloadable))
5067 (memq article gnus-newsgroup-unreads))
5069 (memq article gnus-newsgroup-reads))
5071 (memq article gnus-newsgroup-dormant) )
5073 (memq article gnus-newsgroup-expirable))
5075 (memq article gnus-newsgroup-replied))
5077 (memq article gnus-newsgroup-killed))
5078 ((eq type 'bookmark)
5079 (assq article gnus-newsgroup-bookmarks))
5081 (assq article gnus-newsgroup-scored))
5083 (memq article gnus-newsgroup-saved))
5085 (memq article gnus-newsgroup-cached))
5087 (memq article gnus-newsgroup-forwarded))
5089 (not (memq article gnus-newsgroup-unseen)))
5091 (memq article gnus-newsgroup-recent))
5094 (defun gnus-articles-to-read (group &optional read-all)
5095 "Find out what articles the user wants to read."
5097 ;; Select all articles if `read-all' is non-nil, or if there
5098 ;; are no unread articles.
5100 (and (zerop (length gnus-newsgroup-marked))
5101 (zerop (length gnus-newsgroup-unreads)))
5102 ;; Fetch all if the predicate is non-nil.
5103 gnus-newsgroup-display)
5104 ;; We want to select the headers for all the articles in
5105 ;; the group, so we select either all the active
5106 ;; articles in the group, or (if that's nil), the
5107 ;; articles in the cache.
5109 (gnus-uncompress-range (gnus-active group))
5110 (gnus-cache-articles-in-group group))
5111 ;; Select only the "normal" subset of articles.
5113 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5114 gnus-newsgroup-unreads)))
5115 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5116 (scored (length scored-list))
5117 (number (length articles))
5118 (marked (+ (length gnus-newsgroup-marked)
5119 (length gnus-newsgroup-dormant)))
5124 ((numberp gnus-newsgroup-display)
5125 gnus-newsgroup-display)
5129 ((and (or (<= scored marked) (= scored number))
5130 (numberp gnus-large-newsgroup)
5131 (> number gnus-large-newsgroup))
5132 (let* ((cursor-in-echo-area nil)
5133 (initial (gnus-parameter-large-newsgroup-initial
5134 gnus-newsgroup-name))
5138 "How many articles from %s (%s %d): "
5140 (gnus-group-decoded-name gnus-newsgroup-name)
5142 (if initial "max" "default")
5145 (cons (number-to-string initial)
5147 (if (string-match "^[ \t]*$" input) number input)))
5148 ((and (> scored marked) (< scored number)
5149 (> (- scored number) 20))
5152 (format "%s %s (%d scored, %d total): "
5153 "How many articles from"
5154 (gnus-group-decoded-name group)
5156 (if (string-match "^[ \t]*$" input)
5160 (message "Quit getting the articles to read")
5162 (setq select (if (stringp select) (string-to-number select) select))
5163 (if (or (null select) (zerop select))
5165 (if (and (not (zerop scored)) (<= (abs select) scored))
5167 (setq articles (sort scored-list '<))
5168 (setq number (length articles)))
5169 (setq articles (copy-sequence articles)))
5171 (when (< (abs select) number)
5173 ;; Select the N oldest articles.
5174 (setcdr (nthcdr (1- (abs select)) articles) nil)
5175 ;; Select the N most recent articles.
5176 (setq articles (nthcdr (- number select) articles))))
5177 (setq gnus-newsgroup-unselected
5178 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5179 (when gnus-alter-articles-to-read-function
5180 (setq gnus-newsgroup-unreads
5182 (funcall gnus-alter-articles-to-read-function
5183 gnus-newsgroup-name gnus-newsgroup-unreads)
5187 (defun gnus-killed-articles (killed articles)
5190 (when (inline (gnus-member-of-range (car articles) killed))
5191 (push (car articles) out))
5192 (setq articles (cdr articles)))
5195 (defun gnus-uncompress-marks (marks)
5196 "Uncompress the mark ranges in MARKS."
5197 (let ((uncompressed '(score bookmark))
5200 (if (memq (caar marks) uncompressed)
5201 (push (car marks) out)
5202 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5203 (setq marks (cdr marks)))
5206 (defun gnus-article-mark-to-type (mark)
5207 "Return the type of MARK."
5208 (or (cadr (assq mark gnus-article-special-mark-lists))
5211 (defun gnus-article-unpropagatable-p (mark)
5212 "Return whether MARK should be propagated to backend."
5213 (memq mark gnus-article-unpropagated-mark-lists))
5215 (defun gnus-adjust-marked-articles (info)
5216 "Set all article lists and remove all marks that are no longer valid."
5217 (let* ((marked-lists (gnus-info-marks info))
5218 (active (gnus-active (gnus-info-group info)))
5221 (types gnus-article-mark-lists)
5222 marks var articles article mark mark-type)
5224 (dolist (marks marked-lists)
5225 (setq mark (car marks)
5226 mark-type (gnus-article-mark-to-type mark)
5227 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5229 ;; We set the variable according to the type of the marks list,
5230 ;; and then adjust the marks to a subset of the active articles.
5232 ;; Adjust "simple" lists.
5233 ((eq mark-type 'list)
5234 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5235 (when (memq mark '(tick dormant expire reply save))
5237 (when (or (< (setq article (pop articles)) min) (> article max))
5238 (set var (delq article (symbol-value var)))))))
5240 ((eq mark-type 'tuple)
5241 (set var (setq articles (cdr marks)))
5242 (when (not (listp (cdr (symbol-value var))))
5243 (set var (list (symbol-value var))))
5244 (when (not (listp (cdr articles)))
5245 (setq articles (list articles)))
5247 (when (or (not (consp (setq article (pop articles))))
5248 (< (car article) min)
5249 (> (car article) max))
5250 (set var (delq article (symbol-value var))))))
5251 ;; Adjust ranges (sloppily).
5252 ((eq mark-type 'range)
5255 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5256 ;; It should be (seen (NUM1 . NUM2)).
5257 (when (numberp (cddr marks))
5258 (setcdr marks (list (cdr marks))))
5259 (setq articles (cdr marks))
5260 (while (and articles
5261 (or (and (consp (car articles))
5262 (> min (cdar articles)))
5263 (and (numberp (car articles))
5264 (> min (car articles)))))
5266 (set var articles))))))))
5268 (defun gnus-update-missing-marks (missing)
5269 "Go through the list of MISSING articles and remove them from the mark lists."
5272 ;; Go through all types.
5273 (dolist (elem gnus-article-mark-lists)
5274 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5275 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5276 (when (symbol-value var)
5277 ;; This list has articles. So we delete all missing
5278 ;; articles from it.
5281 (set var (delq (pop m) (symbol-value var))))))))))
5283 (defun gnus-update-marks ()
5284 "Enter the various lists of marked articles into the newsgroup info list."
5285 (let ((types gnus-article-mark-lists)
5286 (info (gnus-get-info gnus-newsgroup-name))
5287 type list newmarked symbol delta-marks)
5289 ;; Add all marks lists to the list of marks lists.
5290 (while (setq type (pop types))
5291 (setq list (symbol-value
5293 (intern (format "gnus-newsgroup-%s" (car type))))))
5296 ;; Get rid of the entries of the articles that have the
5298 (when (and (eq (cdr type) 'score)
5302 (prev (cons nil list))
5305 (if (or (not (consp (car arts)))
5306 (= (cdar arts) gnus-summary-default-score))
5307 (setcdr prev (cdr arts))
5309 (setq arts (cdr arts)))
5310 (setq list (cdr all)))))
5312 (when (eq (cdr type) 'seen)
5313 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5315 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5316 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5318 (when (and (gnus-check-backend-function
5319 'request-set-mark gnus-newsgroup-name)
5320 (not (gnus-article-unpropagatable-p (cdr type))))
5321 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5322 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5323 (add (gnus-remove-from-range
5324 (gnus-copy-sequence list) old)))
5326 (push (list add 'add (list (cdr type))) delta-marks))
5328 (push (list del 'del (list (cdr type))) delta-marks))))
5331 (push (cons (cdr type) list) newmarked)))
5334 (unless (gnus-check-group gnus-newsgroup-name)
5335 (error "Can't open server for %s" gnus-newsgroup-name))
5336 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5338 ;; Enter these new marks into the info of the group.
5340 (setcar (nthcdr 3 info) newmarked)
5341 ;; Add the marks lists to the end of the info.
5343 (setcdr (nthcdr 2 info) (list newmarked))))
5345 ;; Cut off the end of the info if there's nothing else there.
5349 (when (nthcdr (decf i) info)
5350 (setcdr (nthcdr i info) nil)))))))
5352 (defun gnus-set-mode-line (where)
5353 "Set the mode line of the article or summary buffers.
5354 If WHERE is `summary', the summary mode line format will be used."
5355 ;; Is this mode line one we keep updated?
5356 (when (and (memq where gnus-updated-mode-lines)
5358 (intern (format "gnus-%s-mode-line-format-spec" where))))
5361 ;; We evaluate this in the summary buffer since these
5362 ;; variables are buffer-local to that buffer.
5363 (set-buffer gnus-summary-buffer)
5364 ;; We bind all these variables that are used in the `eval' form
5366 (let* ((mformat (symbol-value
5368 (format "gnus-%s-mode-line-format-spec" where))))
5369 (gnus-tmp-group-name (gnus-group-decoded-name
5370 gnus-newsgroup-name))
5371 (gnus-tmp-article-number (or gnus-current-article 0))
5372 (gnus-tmp-unread gnus-newsgroup-unreads)
5373 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5374 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5375 (gnus-tmp-unread-and-unselected
5376 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5377 (zerop gnus-tmp-unselected))
5379 ((zerop gnus-tmp-unselected)
5380 (format "{%d more}" gnus-tmp-unread-and-unticked))
5381 (t (format "{%d(+%d) more}"
5382 gnus-tmp-unread-and-unticked
5383 gnus-tmp-unselected))))
5385 (if (and gnus-current-headers
5386 (vectorp gnus-current-headers))
5387 (gnus-mode-string-quote
5388 (mail-header-subject gnus-current-headers))
5390 bufname-length max-len
5391 gnus-tmp-header);; passed as argument to any user-format-funcs
5392 (setq mode-string (eval mformat))
5393 (setq bufname-length (if (string-match "%b" mode-string)
5396 (if (eq where 'summary)
5398 (get-buffer gnus-article-buffer))))
5401 (setq max-len (max 4 (if gnus-mode-non-string-length
5403 gnus-mode-non-string-length
5405 (length mode-string))))
5406 ;; We might have to chop a bit of the string off...
5407 (when (> (length mode-string) max-len)
5409 (concat (gnus-truncate-string mode-string (- max-len 3))
5411 ;; Pad the mode string a bit.
5412 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5413 ;; Update the mode line.
5414 (setq mode-line-buffer-identification
5415 (gnus-mode-line-buffer-identification (list mode-string)))
5416 (set-buffer-modified-p t))))
5418 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5419 "Go through the HEADERS list and add all Xrefs to a hash table.
5420 The resulting hash table is returned, or nil if no Xrefs were found."
5421 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5422 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5423 (xref-hashtb (gnus-make-hashtable))
5424 start group entry number xrefs header)
5426 (setq header (pop headers))
5427 (when (and (setq xrefs (mail-header-xref header))
5428 (not (memq (setq number (mail-header-number header))
5431 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5432 (setq start (match-end 0))
5433 (setq group (if prefix
5434 (concat prefix (substring xrefs (match-beginning 1)
5436 (substring xrefs (match-beginning 1) (match-end 1))))
5438 (string-to-int (substring xrefs (match-beginning 2)
5440 (if (setq entry (gnus-gethash group xref-hashtb))
5441 (setcdr entry (cons number (cdr entry)))
5442 (gnus-sethash group (cons number nil) xref-hashtb)))))
5443 (and start xref-hashtb)))
5445 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5446 "Look through all the headers and mark the Xrefs as read."
5447 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5448 name entry info xref-hashtb idlist method nth4)
5450 (set-buffer gnus-group-buffer)
5451 (when (setq xref-hashtb
5452 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5455 (unless (string= from-newsgroup (setq name (symbol-name group)))
5456 (setq idlist (symbol-value group))
5457 ;; Dead groups are not updated.
5459 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5461 (when (stringp (setq nth4 (gnus-info-method info)))
5462 (setq nth4 (gnus-server-to-method nth4))))
5463 ;; Only do the xrefs if the group has the same
5464 ;; select method as the group we have just read.
5465 (or (gnus-methods-equal-p
5466 nth4 (gnus-find-method-for-group from-newsgroup))
5468 (equal nth4 (setq method (gnus-find-method-for-group
5470 (and (equal (car nth4) (car method))
5471 (equal (nth 1 nth4) (nth 1 method))))
5472 gnus-use-cross-reference
5473 (or (not (eq gnus-use-cross-reference t))
5475 ;; Only do cross-references on subscribed
5476 ;; groups, if that is what is wanted.
5477 (<= (gnus-info-level info) gnus-level-subscribed))
5478 (gnus-group-make-articles-read name idlist))))
5481 (defun gnus-compute-read-articles (group articles)
5482 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5483 (info (nth 2 entry))
5484 (active (gnus-active group))
5487 ;; First peel off all invalid article numbers.
5489 (let ((ids articles)
5491 (while (setq id (pop ids))
5492 (when (and first (> id (cdr active)))
5493 ;; We'll end up in this situation in one particular
5494 ;; obscure situation. If you re-scan a group and get
5495 ;; a new article that is cross-posted to a different
5496 ;; group that has not been re-scanned, you might get
5497 ;; crossposted article that has a higher number than
5498 ;; Gnus believes possible. So we re-activate this
5499 ;; group as well. This might mean doing the
5500 ;; crossposting thingy will *increase* the number
5501 ;; of articles in some groups. Tsk, tsk.
5502 (setq active (or (gnus-activate-group group) active)))
5503 (when (or (> id (cdr active))
5504 (< id (car active)))
5505 (setq articles (delq id articles))))))
5506 ;; If the read list is nil, we init it.
5508 (null (gnus-info-read info))
5510 (setq ninfo (cons 1 (1- (car active))))
5511 (setq ninfo (gnus-info-read info)))
5512 ;; Then we add the read articles to the range.
5514 ninfo (setq articles (sort articles '<))))))
5516 (defun gnus-group-make-articles-read (group articles)
5517 "Update the info of GROUP to say that ARTICLES are read."
5519 (entry (gnus-gethash group gnus-newsrc-hashtb))
5520 (info (nth 2 entry))
5521 (active (gnus-active group))
5524 (setq range (gnus-compute-read-articles group articles))
5526 (set-buffer gnus-group-buffer)
5529 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5530 (gnus-info-set-read ',info ',(gnus-info-read info))
5531 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5532 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5533 (gnus-group-update-group ,group t))))
5534 ;; Add the read articles to the range.
5535 (gnus-info-set-read info range)
5536 (gnus-request-set-mark group (list (list range 'add '(read))))
5537 ;; Then we have to re-compute how many unread
5538 ;; articles there are in this group.
5542 (setq num (- (1+ (cdr active)) (car active))))
5543 ((not (listp (cdr range)))
5544 (setq num (- (cdr active) (- (1+ (cdr range))
5548 (if (numberp (car range))
5550 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5551 (setq range (cdr range)))
5552 (setq num (- (cdr active) num))))
5553 ;; Update the number of unread articles.
5555 ;; Update the group buffer.
5556 (gnus-group-update-group group t)))))
5558 (defvar gnus-newsgroup-none-id 0)
5560 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5561 (let ((cur nntp-server-buffer)
5564 (save-excursion (set-buffer gnus-summary-buffer)
5565 gnus-newsgroup-dependencies)))
5567 (mail-parse-charset gnus-newsgroup-charset)
5568 (mail-parse-ignored-charsets
5569 (save-excursion (condition-case nil
5570 (set-buffer gnus-summary-buffer)
5572 gnus-newsgroup-ignored-charsets)))
5574 (set-buffer nntp-server-buffer)
5575 ;; Translate all TAB characters into SPACE characters.
5576 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5577 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5578 (gnus-run-hooks 'gnus-parse-headers-hook)
5579 (let ((case-fold-search t)
5580 in-reply-to header p lines chars ctype)
5581 (goto-char (point-min))
5582 ;; Search to the beginning of the next header. Error messages
5583 ;; do not begin with 2 or 3.
5584 (while (re-search-forward "^[23][0-9]+ " nil t)
5587 ;; This implementation of this function, with nine
5588 ;; search-forwards instead of the one re-search-forward and
5589 ;; a case (which basically was the old function) is actually
5590 ;; about twice as fast, even though it looks messier. You
5591 ;; can't have everything, I guess. Speed and elegance
5592 ;; doesn't always go hand in hand.
5595 (make-full-mail-header
5601 (narrow-to-region (point)
5602 (or (and (search-forward "\n.\n" nil t)
5608 (if (search-forward "\nsubject:" nil t)
5609 (nnheader-header-value)
5614 (if (search-forward "\nfrom:" nil t)
5615 (nnheader-header-value)
5620 (if (search-forward "\ndate:" nil t)
5621 (nnheader-header-value) ""))
5625 (setq id (if (re-search-forward
5626 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5627 ;; We do it this way to make sure the Message-ID
5628 ;; is (somewhat) syntactically valid.
5629 (buffer-substring (match-beginning 1)
5631 ;; If there was no message-id, we just fake one
5632 ;; to make subsequent routines simpler.
5633 (nnheader-generate-fake-message-id))))
5637 (if (search-forward "\nreferences:" nil t)
5641 (nnheader-header-value)
5646 (search-backward ">" end t)
5649 (search-backward "<" end t)
5651 ;; Get the references from the in-reply-to header if there
5652 ;; were no references and the in-reply-to header looks
5654 (if (and (search-forward "\nin-reply-to:" nil t)
5655 (setq in-reply-to (nnheader-header-value))
5656 (string-match "<[^>]+>" in-reply-to))
5658 (setq ref (substring in-reply-to (match-beginning 0)
5660 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5661 (setq ref2 (substring in-reply-to (match-beginning 0)
5663 (when (> (length ref2) (length ref))
5670 (if (search-forward "\nchars: " nil t)
5671 (if (numberp (setq chars (ignore-errors (read cur))))
5677 (if (search-forward "\nlines: " nil t)
5678 (if (numberp (setq lines (ignore-errors (read cur))))
5684 (and (search-forward "\nxref:" nil t)
5685 (nnheader-header-value)))
5687 (when gnus-extra-headers
5688 (let ((extra gnus-extra-headers)
5692 (when (search-forward
5693 (concat "\n" (symbol-name (car extra)) ":") nil t)
5694 (push (cons (car extra) (nnheader-header-value)) out))
5698 (if (and (search-forward "\ncontent-type: " nil t)
5699 (setq ctype (nnheader-header-value)))
5700 (mime-entity-set-content-type-internal
5701 header (mime-parse-Content-Type ctype)))
5702 (when (equal id ref)
5705 (when gnus-alter-header-function
5706 (funcall gnus-alter-header-function header)
5707 (setq id (mail-header-id header)
5708 ref (gnus-parent-id (mail-header-references header))))
5711 (gnus-dependencies-add-header
5712 header dependencies force-new))
5713 (push header headers))
5714 (goto-char (point-max))
5716 (nreverse headers)))))
5718 ;; Goes through the xover lines and returns a list of vectors
5719 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5720 force-new dependencies
5721 group also-fetch-heads)
5722 "Parse the news overview data in the server buffer.
5723 Return a list of headers that match SEQUENCE (see
5724 `nntp-retrieve-headers')."
5725 ;; Get the Xref when the users reads the articles since most/some
5726 ;; NNTP servers do not include Xrefs when using XOVER.
5727 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5728 (let ((mail-parse-charset gnus-newsgroup-charset)
5729 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5730 (cur nntp-server-buffer)
5731 (dependencies (or dependencies gnus-newsgroup-dependencies))
5733 ((eq gnus-read-all-available-headers t)
5735 ((stringp gnus-read-all-available-headers)
5736 (string-match gnus-read-all-available-headers group))
5739 number headers header)
5741 (set-buffer nntp-server-buffer)
5742 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5743 ;; Allow the user to mangle the headers before parsing them.
5744 (gnus-run-hooks 'gnus-parse-headers-hook)
5745 (goto-char (point-min))
5746 (gnus-parse-without-error
5747 (while (and (or sequence allp)
5749 (setq number (read cur))
5751 (while (and sequence
5752 (< (car sequence) number))
5753 (setq sequence (cdr sequence))))
5756 (eq number (car sequence))))
5758 (setq sequence (cdr sequence))
5759 (setq header (inline
5760 (gnus-nov-parse-line
5761 number dependencies force-new)))))
5762 (push header headers))
5764 ;; A common bug in inn is that if you have posted an article and
5765 ;; then retrieves the active file, it will answer correctly --
5766 ;; the new article is included. However, a NOV entry for the
5767 ;; article may not have been generated yet, so this may fail.
5768 ;; We work around this problem by retrieving the last few
5769 ;; headers using HEAD.
5770 (if (or (not also-fetch-heads)
5772 ;; We (probably) got all the headers.
5774 (let ((gnus-nov-is-evil t))
5777 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5778 (gnus-get-newsgroup-headers))))))))
5780 (defun gnus-article-get-xrefs ()
5781 "Fill in the Xref value in `gnus-current-headers', if necessary.
5782 This is meant to be called in `gnus-article-internal-prepare-hook'."
5783 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5784 gnus-current-headers)))
5785 (or (not gnus-use-cross-reference)
5787 (and (mail-header-xref headers)
5788 (not (string= (mail-header-xref headers) "")))
5789 (let ((case-fold-search t)
5792 (nnheader-narrow-to-headers)
5793 (goto-char (point-min))
5794 (when (or (and (not (eobp))
5795 (eq (downcase (char-after)) ?x)
5796 (looking-at "Xref:"))
5797 (search-forward "\nXref:" nil t))
5798 (goto-char (1+ (match-end 0)))
5799 (setq xref (buffer-substring (point)
5800 (progn (end-of-line) (point))))
5801 (mail-header-set-xref headers xref)))))))
5803 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5804 "Find article ID and insert the summary line for that article.
5805 OLD-HEADER can either be a header or a line number to insert
5806 the subject line on."
5807 (let* ((line (and (numberp old-header) old-header))
5808 (old-header (and (vectorp old-header) old-header))
5809 (header (cond ((and old-header use-old-header)
5812 (gnus-number-to-header id))
5813 (gnus-number-to-header id))
5815 (gnus-read-header id))))
5816 (number (and (numberp id) id))
5819 ;; Rebuild the thread that this article is part of and go to the
5820 ;; article we have fetched.
5821 (when (and (not gnus-show-threads)
5824 (setq d (gnus-data-find (mail-header-number old-header))))
5825 (goto-char (gnus-data-pos d))
5828 (- (gnus-point-at-bol)
5830 (1+ (gnus-point-at-eol))
5831 (gnus-delete-line))))))
5833 (mail-header-set-number header (mail-header-number old-header)))
5834 (setq gnus-newsgroup-sparse
5835 (delq (setq number (mail-header-number header))
5836 gnus-newsgroup-sparse))
5837 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5838 (push number gnus-newsgroup-limit)
5839 (gnus-rebuild-thread (mail-header-id header) line)
5840 (gnus-summary-goto-subject number nil t))
5841 (when (and (numberp number)
5843 ;; We have to update the boundaries even if we can't fetch the
5844 ;; article if ID is a number -- so that the next `P' or `N'
5845 ;; command will fetch the previous (or next) article even
5846 ;; if the one we tried to fetch this time has been canceled.
5847 (when (> number gnus-newsgroup-end)
5848 (setq gnus-newsgroup-end number))
5849 (when (< number gnus-newsgroup-begin)
5850 (setq gnus-newsgroup-begin number))
5851 (setq gnus-newsgroup-unselected
5852 (delq number gnus-newsgroup-unselected)))
5853 ;; Report back a success?
5854 (and header (mail-header-number header))))
5856 ;;; Process/prefix in the summary buffer
5858 (defun gnus-summary-work-articles (n)
5859 "Return a list of articles to be worked upon.
5860 The prefix argument, the list of process marked articles, and the
5861 current article will be taken into consideration."
5863 (set-buffer gnus-summary-buffer)
5866 ;; A numerical prefix has been given.
5867 (setq n (prefix-numeric-value n))
5868 (let ((backward (< n 0))
5869 (n (abs (prefix-numeric-value n)))
5874 (push (setq article (gnus-summary-article-number))
5877 (gnus-summary-find-prev nil article)
5878 (gnus-summary-find-next nil article)))
5880 (nreverse articles)))
5881 ((and (gnus-region-active-p) (mark))
5882 (message "region active")
5883 ;; Work on the region between point and mark.
5884 (let ((max (max (point) (mark)))
5887 (goto-char (min (point) (mark)))
5890 (push (setq article (gnus-summary-article-number)) articles)
5891 (gnus-summary-find-next nil article)
5893 (nreverse articles))))
5894 (gnus-newsgroup-processable
5895 ;; There are process-marked articles present.
5896 ;; Save current state.
5897 (gnus-summary-save-process-mark)
5899 (reverse gnus-newsgroup-processable))
5901 ;; Just return the current article.
5902 (list (gnus-summary-article-number))))))
5904 (defmacro gnus-summary-iterate (arg &rest forms)
5905 "Iterate over the process/prefixed articles and do FORMS.
5906 ARG is the interactive prefix given to the command. FORMS will be
5907 executed with point over the summary line of the articles."
5908 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5909 `(let ((,articles (gnus-summary-work-articles ,arg)))
5911 (gnus-summary-goto-subject (car ,articles))
5915 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5916 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5918 (defun gnus-summary-save-process-mark ()
5919 "Push the current set of process marked articles on the stack."
5921 (push (copy-sequence gnus-newsgroup-processable)
5922 gnus-newsgroup-process-stack))
5924 (defun gnus-summary-kill-process-mark ()
5925 "Push the current set of process marked articles on the stack and unmark."
5927 (gnus-summary-save-process-mark)
5928 (gnus-summary-unmark-all-processable))
5930 (defun gnus-summary-yank-process-mark ()
5931 "Pop the last process mark state off the stack and restore it."
5933 (unless gnus-newsgroup-process-stack
5934 (error "Empty mark stack"))
5935 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5937 (defun gnus-summary-process-mark-set (set)
5938 "Make SET into the current process marked articles."
5939 (gnus-summary-unmark-all-processable)
5941 (gnus-summary-set-process-mark (pop set))))
5943 ;;; Searching and stuff
5945 (defun gnus-summary-search-group (&optional backward use-level)
5946 "Search for next unread newsgroup.
5947 If optional argument BACKWARD is non-nil, search backward instead."
5949 (set-buffer gnus-group-buffer)
5950 (when (gnus-group-search-forward
5951 backward nil (if use-level (gnus-group-group-level) nil))
5952 (gnus-group-group-name))))
5954 (defun gnus-summary-best-group (&optional exclude-group)
5955 "Find the name of the best unread group.
5956 If EXCLUDE-GROUP, do not go to this group."
5958 (set-buffer gnus-group-buffer)
5960 (gnus-group-best-unread-group exclude-group))))
5962 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5963 (if backward (gnus-summary-find-prev)
5964 (let* ((dummy (gnus-summary-article-intangible-p))
5965 (article (or article (gnus-summary-article-number)))
5966 (arts (gnus-data-find-list article))
5968 (when (and (not dummy)
5969 (or (not gnus-summary-check-current)
5971 (not (gnus-data-unread-p (car arts)))))
5972 (setq arts (cdr arts)))
5977 (when (or (and undownloaded
5978 (memq (car arts) gnus-newsgroup-undownloaded))
5979 (gnus-data-unread-p (car arts)))
5980 (setq result (car arts)
5982 (setq arts (cdr arts)))
5985 (goto-char (gnus-data-pos result))
5986 (gnus-data-number result)))))
5988 (defun gnus-summary-find-prev (&optional unread article)
5989 (let* ((eobp (eobp))
5990 (article (or article (gnus-summary-article-number)))
5991 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5993 (when (and (not eobp)
5994 (or (not gnus-summary-check-current)
5996 (not (gnus-data-unread-p (car arts)))))
5997 (setq arts (cdr arts)))
6002 (when (gnus-data-unread-p (car arts))
6003 (setq result (car arts)
6005 (setq arts (cdr arts)))
6008 (goto-char (gnus-data-pos result))
6009 (gnus-data-number result))))
6011 (defun gnus-summary-find-subject (subject &optional unread backward article)
6012 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6013 (article (or article (gnus-summary-article-number)))
6014 (articles (gnus-data-list backward))
6015 (arts (gnus-data-find-list article articles))
6017 (when (or (not gnus-summary-check-current)
6019 (not (gnus-data-unread-p (car arts))))
6020 (setq arts (cdr arts)))
6022 (and (or (not unread)
6023 (gnus-data-unread-p (car arts)))
6024 (vectorp (gnus-data-header (car arts)))
6026 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6027 (setq result (car arts)
6029 (setq arts (cdr arts)))
6031 (goto-char (gnus-data-pos result))
6032 (gnus-data-number result))))
6034 (defun gnus-summary-search-forward (&optional unread subject backward)
6035 "Search forward for an article.
6036 If UNREAD, look for unread articles. If SUBJECT, look for
6037 articles with that subject. If BACKWARD, search backward instead."
6038 (cond (subject (gnus-summary-find-subject subject unread backward))
6039 (backward (gnus-summary-find-prev unread))
6040 (t (gnus-summary-find-next unread))))
6042 (defun gnus-recenter (&optional n)
6043 "Center point in window and redisplay frame.
6044 Also do horizontal recentering."
6046 (when (and gnus-auto-center-summary
6047 (not (eq gnus-auto-center-summary 'vertical)))
6048 (gnus-horizontal-recenter))
6051 (defun gnus-summary-recenter ()
6052 "Center point in the summary window.
6053 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6054 displayed, no centering will be performed."
6055 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6056 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6058 (let* ((top (cond ((< (window-height) 4) 0)
6059 ((< (window-height) 7) 1)
6060 (t (if (numberp gnus-auto-center-summary)
6061 gnus-auto-center-summary
6063 (height (1- (window-height)))
6064 (bottom (save-excursion (goto-char (point-max))
6065 (forward-line (- height))
6067 (window (get-buffer-window (current-buffer))))
6068 ;; The user has to want it.
6069 (when gnus-auto-center-summary
6070 (when (get-buffer-window gnus-article-buffer)
6071 ;; Only do recentering when the article buffer is displayed,
6072 ;; Set the window start to either `bottom', which is the biggest
6073 ;; possible valid number, or the second line from the top,
6074 ;; whichever is the least.
6075 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6076 (if (> bottom top-pos)
6077 ;; Keep the second line from the top visible
6078 (set-window-start window top-pos t)
6079 ;; Try to keep the bottom line visible; if it's partially
6080 ;; obscured, either scroll one more line to make it fully
6081 ;; visible, or revert to using TOP-POS.
6083 (goto-char (point-max))
6085 (let ((last-line-start (point)))
6087 (set-window-start window (point) t)
6088 (when (not (pos-visible-in-window-p last-line-start window))
6090 (set-window-start window (min (point) top-pos) t)))))))
6091 ;; Do horizontal recentering while we're at it.
6092 (when (and (get-buffer-window (current-buffer) t)
6093 (not (eq gnus-auto-center-summary 'vertical)))
6094 (let ((selected (selected-window)))
6095 (select-window (get-buffer-window (current-buffer) t))
6096 (gnus-summary-position-point)
6097 (gnus-horizontal-recenter)
6098 (select-window selected))))))
6100 (defun gnus-summary-jump-to-group (newsgroup)
6101 "Move point to NEWSGROUP in group mode buffer."
6102 ;; Keep update point of group mode buffer if visible.
6103 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6104 (save-window-excursion
6105 ;; Take care of tree window mode.
6106 (when (get-buffer-window gnus-group-buffer)
6107 (pop-to-buffer gnus-group-buffer))
6108 (gnus-group-jump-to-group newsgroup))
6110 ;; Take care of tree window mode.
6111 (if (get-buffer-window gnus-group-buffer)
6112 (pop-to-buffer gnus-group-buffer)
6113 (set-buffer gnus-group-buffer))
6114 (gnus-group-jump-to-group newsgroup))))
6116 ;; This function returns a list of article numbers based on the
6117 ;; difference between the ranges of read articles in this group and
6118 ;; the range of active articles.
6119 (defun gnus-list-of-unread-articles (group)
6120 (let* ((read (gnus-info-read (gnus-get-info group)))
6121 (active (or (gnus-active group) (gnus-activate-group group)))
6124 ;; If none are read, then all are unread.
6126 (setq first (car active))
6127 ;; If the range of read articles is a single range, then the
6128 ;; first unread article is the article after the last read
6129 ;; article. Sounds logical, doesn't it?
6130 (if (and (not (listp (cdr read)))
6131 (or (< (car read) (car active))
6132 (progn (setq read (list read))
6134 (setq first (max (car active) (1+ (cdr read))))
6135 ;; `read' is a list of ranges.
6136 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6139 (setq first (car active)))
6142 (while (< first nlast)
6144 (setq first (1+ first))))
6145 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6146 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6147 (setq read (cdr read)))))
6148 ;; And add the last unread articles.
6149 (while (<= first last)
6151 (setq first (1+ first)))
6152 ;; Return the list of unread articles.
6153 (delq 0 (nreverse unread))))
6155 (defun gnus-list-of-read-articles (group)
6156 "Return a list of unread, unticked and non-dormant articles."
6157 (let* ((info (gnus-get-info group))
6158 (marked (gnus-info-marks info))
6159 (active (gnus-active group)))
6161 (gnus-list-range-difference
6162 (gnus-list-range-difference
6163 (gnus-sorted-complement
6164 (gnus-uncompress-range active)
6165 (gnus-list-of-unread-articles group))
6166 (cdr (assq 'dormant marked)))
6167 (cdr (assq 'tick marked))))))
6169 ;; Various summary commands
6171 (defun gnus-summary-select-article-buffer ()
6172 "Reconfigure windows to show article buffer."
6174 (if (not (gnus-buffer-live-p gnus-article-buffer))
6175 (error "There is no article buffer for this summary buffer")
6176 (gnus-configure-windows 'article)
6177 (select-window (get-buffer-window gnus-article-buffer))))
6179 (defun gnus-summary-universal-argument (arg)
6180 "Perform any operation on all articles that are process/prefixed."
6182 (let ((articles (gnus-summary-work-articles arg))
6189 (substitute-command-keys
6190 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6192 (gnus-error 1 "Undefined key")
6195 (gnus-summary-goto-subject (setq article (pop articles)))
6196 (let (gnus-newsgroup-processable)
6197 (command-execute func))
6198 (gnus-summary-remove-process-mark article)))))
6199 (gnus-summary-position-point))
6201 (defun gnus-summary-toggle-truncation (&optional arg)
6202 "Toggle truncation of summary lines.
6203 With arg, turn line truncation on if arg is positive."
6205 (setq truncate-lines
6206 (if (null arg) (not truncate-lines)
6207 (> (prefix-numeric-value arg) 0)))
6210 (defun gnus-summary-find-uncancelled ()
6211 "Return the number of an uncancelled article.
6212 The current article is considered, then following articles, then previous
6213 articles. If all articles are cancelled then return a dummy 0."
6215 (dolist (rev '(nil t))
6216 (unless found ; don't demand the reverse list if we don't need it
6217 (let ((data (gnus-data-find-list
6218 (gnus-summary-article-number) (gnus-data-list rev))))
6219 (while (and data (not found))
6220 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6221 (setq found (gnus-data-number (car data))))
6222 (setq data (cdr data))))))
6225 (defun gnus-summary-reselect-current-group (&optional all rescan)
6226 "Exit and then reselect the current newsgroup.
6227 The prefix argument ALL means to select all articles."
6229 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6230 (error "Ephemeral groups can't be reselected"))
6231 (let ((current-subject (gnus-summary-find-uncancelled))
6232 (group gnus-newsgroup-name))
6233 (setq gnus-newsgroup-begin nil)
6235 ;; We have to adjust the point of group mode buffer because
6236 ;; point was moved to the next unread newsgroup by exiting.
6237 (gnus-summary-jump-to-group group)
6240 (save-window-excursion
6241 ;; Don't show group contents.
6242 (set-window-start (selected-window) (point-max))
6243 (gnus-group-get-new-news-this-group 1))))
6244 (gnus-group-read-group all t)
6245 (gnus-summary-goto-subject current-subject nil t)))
6247 (defun gnus-summary-rescan-group (&optional all)
6248 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6250 (gnus-summary-reselect-current-group all t))
6252 (defun gnus-summary-update-info (&optional non-destructive)
6254 (let ((group gnus-newsgroup-name))
6256 (when gnus-newsgroup-kill-headers
6257 (setq gnus-newsgroup-killed
6258 (gnus-compress-sequence
6260 (gnus-list-range-intersection
6261 gnus-newsgroup-unselected gnus-newsgroup-killed)
6262 gnus-newsgroup-unreads)
6264 (unless (listp (cdr gnus-newsgroup-killed))
6265 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6266 (let ((headers gnus-newsgroup-headers))
6267 ;; Set the new ranges of read articles.
6269 (set-buffer gnus-group-buffer)
6270 (gnus-undo-force-boundary))
6271 (gnus-update-read-articles
6272 group (gnus-sorted-union
6273 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6274 ;; Set the current article marks.
6275 (let ((gnus-newsgroup-scored
6276 (if (and (not gnus-save-score)
6277 (not non-destructive))
6279 gnus-newsgroup-scored)))
6281 (gnus-update-marks)))
6282 ;; Do the cross-ref thing.
6283 (when gnus-use-cross-reference
6284 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6285 ;; Do not switch windows but change the buffer to work.
6286 (set-buffer gnus-group-buffer)
6287 (unless (gnus-ephemeral-group-p group)
6288 (gnus-group-update-group group)))))))
6290 (defun gnus-summary-save-newsrc (&optional force)
6291 "Save the current number of read/marked articles in the dribble buffer.
6292 The dribble buffer will then be saved.
6293 If FORCE (the prefix), also save the .newsrc file(s)."
6295 (gnus-summary-update-info t)
6297 (gnus-save-newsrc-file)
6298 (gnus-dribble-save)))
6300 (defun gnus-summary-exit (&optional temporary)
6301 "Exit reading current newsgroup, and then return to group selection mode.
6302 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6304 (gnus-set-global-variables)
6305 (gnus-kill-save-kill-buffer)
6306 (gnus-async-halt-prefetch)
6307 (let* ((group gnus-newsgroup-name)
6308 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6311 (buf (current-buffer)))
6313 ;; Do adaptive scoring, and possibly save score files.
6314 (when gnus-newsgroup-adaptive
6315 (gnus-score-adaptive))
6316 (when gnus-use-scoring
6318 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6319 ;; If we have several article buffers, we kill them at exit.
6320 (unless gnus-single-article-buffer
6321 (gnus-kill-buffer gnus-original-article-buffer)
6322 (setq gnus-article-current nil))
6323 (when gnus-use-cache
6324 (gnus-cache-possibly-remove-articles)
6325 (gnus-cache-save-buffers))
6326 (gnus-async-prefetch-remove-group group)
6327 (when gnus-suppress-duplicates
6328 (gnus-dup-enter-articles))
6329 (when gnus-use-trees
6330 (gnus-tree-close group))
6331 (when gnus-use-cache
6332 (gnus-cache-write-active))
6333 ;; Remove entries for this group.
6334 (nnmail-purge-split-history (gnus-group-real-name group))
6335 ;; Make all changes in this group permanent.
6337 (gnus-run-hooks 'gnus-exit-group-hook)
6338 (gnus-summary-update-info))
6339 (gnus-close-group group)
6340 ;; Make sure where we were, and go to next newsgroup.
6341 (set-buffer gnus-group-buffer)
6343 (gnus-group-jump-to-group group))
6344 (gnus-run-hooks 'gnus-summary-exit-hook)
6345 (unless (or quit-config
6346 ;; If this group has disappeared from the summary
6347 ;; buffer, don't skip forwards.
6348 (not (string= group (gnus-group-group-name))))
6349 (gnus-group-next-unread-group 1))
6350 (setq group-point (point))
6353 ;; If we have several article buffers, we kill them at exit.
6354 (unless gnus-single-article-buffer
6355 (gnus-kill-buffer gnus-article-buffer)
6356 (gnus-kill-buffer gnus-original-article-buffer)
6357 (setq gnus-article-current nil))
6359 (if (not gnus-kill-summary-on-exit)
6361 (gnus-deaden-summary)
6363 ;; We set all buffer-local variables to nil. It is unclear why
6364 ;; this is needed, but if we don't, buffer-local variables are
6365 ;; not garbage-collected, it seems. This would the lead to en
6366 ;; ever-growing Emacs.
6367 (gnus-summary-clear-local-variables)
6368 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6369 (gnus-summary-clear-local-variables))
6370 (when (get-buffer gnus-article-buffer)
6371 (bury-buffer gnus-article-buffer))
6372 ;; We clear the global counterparts of the buffer-local
6373 ;; variables as well, just to be on the safe side.
6374 (set-buffer gnus-group-buffer)
6375 (gnus-summary-clear-local-variables)
6376 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6377 (gnus-summary-clear-local-variables)))
6378 (setq gnus-current-select-method gnus-select-method)
6379 (pop-to-buffer gnus-group-buffer)
6380 (if (not quit-config)
6382 (goto-char group-point)
6383 (gnus-configure-windows 'group 'force)
6384 (unless (pos-visible-in-window-p)
6385 (forward-line (/ (static-if (featurep 'xemacs)
6386 (window-displayed-height)
6387 (1- (window-height)))
6389 (set-window-start (selected-window) (point))
6390 (goto-char group-point)))
6391 (gnus-handle-ephemeral-exit quit-config))
6392 ;; Return to group mode buffer.
6393 (when (eq mode 'gnus-summary-mode)
6394 (gnus-kill-buffer buf))
6395 ;; Clear the current group name.
6397 (setq gnus-newsgroup-name nil)))))
6399 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6400 (defun gnus-summary-exit-no-update (&optional no-questions)
6401 "Quit reading current newsgroup without updating read article info."
6403 (let* ((group gnus-newsgroup-name)
6404 (quit-config (gnus-group-quit-config group)))
6405 (when (or no-questions
6407 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6408 (gnus-async-halt-prefetch)
6410 (delq 'gnus-summary-expire-articles
6411 (copy-sequence gnus-summary-prepare-exit-hook)))
6412 ;; If we have several article buffers, we kill them at exit.
6413 (unless gnus-single-article-buffer
6414 (gnus-kill-buffer gnus-article-buffer)
6415 (gnus-kill-buffer gnus-original-article-buffer)
6416 (setq gnus-article-current nil))
6417 (if (not gnus-kill-summary-on-exit)
6418 (gnus-deaden-summary)
6419 (gnus-close-group group)
6420 (gnus-summary-clear-local-variables)
6421 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6422 (gnus-summary-clear-local-variables))
6423 (set-buffer gnus-group-buffer)
6424 (gnus-summary-clear-local-variables)
6425 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6426 (gnus-summary-clear-local-variables))
6427 (when (get-buffer gnus-summary-buffer)
6428 (kill-buffer gnus-summary-buffer)))
6429 (unless gnus-single-article-buffer
6430 (setq gnus-article-current nil))
6431 (when gnus-use-trees
6432 (gnus-tree-close group))
6433 (gnus-async-prefetch-remove-group group)
6434 (when (get-buffer gnus-article-buffer)
6435 (bury-buffer gnus-article-buffer))
6436 ;; Return to the group buffer.
6437 (gnus-configure-windows 'group 'force)
6438 ;; Clear the current group name.
6439 (setq gnus-newsgroup-name nil)
6440 (when (equal (gnus-group-group-name) group)
6441 (gnus-group-next-unread-group 1))
6443 (gnus-handle-ephemeral-exit quit-config)))))
6445 (defun gnus-handle-ephemeral-exit (quit-config)
6446 "Handle movement when leaving an ephemeral group.
6447 The state which existed when entering the ephemeral is reset."
6448 (if (not (buffer-name (car quit-config)))
6449 (gnus-configure-windows 'group 'force)
6450 (set-buffer (car quit-config))
6451 (cond ((eq major-mode 'gnus-summary-mode)
6452 (gnus-set-global-variables))
6453 ((eq major-mode 'gnus-article-mode)
6455 ;; The `gnus-summary-buffer' variable may point
6456 ;; to the old summary buffer when using a single
6458 (unless (gnus-buffer-live-p gnus-summary-buffer)
6459 (set-buffer gnus-group-buffer))
6460 (set-buffer gnus-summary-buffer)
6461 (gnus-set-global-variables))))
6462 (if (or (eq (cdr quit-config) 'article)
6463 (eq (cdr quit-config) 'pick))
6465 ;; The current article may be from the ephemeral group
6466 ;; thus it is best that we reload this article
6467 (gnus-summary-show-article)
6468 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6469 (gnus-configure-windows 'pick 'force)
6470 (gnus-configure-windows (cdr quit-config) 'force)))
6471 (gnus-configure-windows (cdr quit-config) 'force))
6472 (when (eq major-mode 'gnus-summary-mode)
6473 (gnus-summary-next-subject 1 nil t)
6474 (gnus-summary-recenter)
6475 (gnus-summary-position-point))))
6477 (defun gnus-summary-preview-mime-message ()
6478 "MIME decode and play this message."
6480 (let ((gnus-break-pages nil)
6482 (gnus-summary-select-article gnus-show-all-headers t))
6483 (let ((w (get-buffer-window gnus-article-buffer)))
6485 (select-window (get-buffer-window gnus-article-buffer)))))
6489 (defvar gnus-dead-summary-mode-map nil)
6491 (unless gnus-dead-summary-mode-map
6492 (setq gnus-dead-summary-mode-map (make-keymap))
6493 (suppress-keymap gnus-dead-summary-mode-map)
6494 (substitute-key-definition
6495 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6496 (dolist (key '("\C-d" "\r" "\177" [delete]))
6497 (define-key gnus-dead-summary-mode-map
6498 key 'gnus-summary-wake-up-the-dead))
6499 (dolist (key '("q" "Q"))
6500 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6502 (defvar gnus-dead-summary-mode nil
6503 "Minor mode for Gnus summary buffers.")
6505 (defun gnus-dead-summary-mode (&optional arg)
6506 "Minor mode for Gnus summary buffers."
6508 (when (eq major-mode 'gnus-summary-mode)
6509 (make-local-variable 'gnus-dead-summary-mode)
6510 (setq gnus-dead-summary-mode
6511 (if (null arg) (not gnus-dead-summary-mode)
6512 (> (prefix-numeric-value arg) 0)))
6513 (when gnus-dead-summary-mode
6514 (gnus-add-minor-mode
6515 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6517 (defun gnus-deaden-summary ()
6518 "Make the current summary buffer into a dead summary buffer."
6519 ;; Kill any previous dead summary buffer.
6520 (when (and gnus-dead-summary
6521 (buffer-name gnus-dead-summary))
6523 (set-buffer gnus-dead-summary)
6524 (when gnus-dead-summary-mode
6525 (kill-buffer (current-buffer)))))
6526 ;; Make this the current dead summary.
6527 (setq gnus-dead-summary (current-buffer))
6528 (gnus-dead-summary-mode 1)
6529 (let ((name (buffer-name)))
6530 (when (string-match "Summary" name)
6532 (concat (substring name 0 (match-beginning 0)) "Dead "
6533 (substring name (match-beginning 0)))
6537 (defun gnus-kill-or-deaden-summary (buffer)
6538 "Kill or deaden the summary BUFFER."
6540 (when (and (buffer-name buffer)
6541 (not gnus-single-article-buffer))
6544 (gnus-kill-buffer gnus-article-buffer)
6545 (gnus-kill-buffer gnus-original-article-buffer)))
6548 (gnus-kill-summary-on-exit
6549 (when (and gnus-use-trees
6550 (gnus-buffer-exists-p buffer))
6553 (gnus-tree-close gnus-newsgroup-name)))
6554 (gnus-kill-buffer buffer))
6555 ;; Deaden the buffer.
6556 ((gnus-buffer-exists-p buffer)
6559 (gnus-deaden-summary))))))
6561 (defun gnus-summary-wake-up-the-dead (&rest args)
6562 "Wake up the dead summary buffer."
6564 (gnus-dead-summary-mode -1)
6565 (let ((name (buffer-name)))
6566 (when (string-match "Dead " name)
6568 (concat (substring name 0 (match-beginning 0))
6569 (substring name (match-end 0)))
6571 (gnus-message 3 "This dead summary is now alive again"))
6573 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6574 (defun gnus-summary-fetch-faq (&optional faq-dir)
6575 "Fetch the FAQ for the current group.
6576 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6580 (when current-prefix-arg
6582 "FAQ dir: " (and (listp gnus-group-faq-directory)
6583 (mapcar (lambda (file) (list file))
6584 gnus-group-faq-directory))))))
6585 (let (gnus-faq-buffer)
6586 (when (setq gnus-faq-buffer
6587 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6588 (gnus-configure-windows 'summary-faq))))
6590 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6591 (defun gnus-summary-describe-group (&optional force)
6592 "Describe the current newsgroup."
6594 (gnus-group-describe-group force gnus-newsgroup-name))
6596 (defun gnus-summary-describe-briefly ()
6597 "Describe summary mode commands briefly."
6599 (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")))
6601 ;; Walking around group mode buffer from summary mode.
6603 (defun gnus-summary-next-group (&optional no-article target-group backward)
6604 "Exit current newsgroup and then select next unread newsgroup.
6605 If prefix argument NO-ARTICLE is non-nil, no article is selected
6606 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6607 previous group instead."
6609 ;; Stop pre-fetching.
6610 (gnus-async-halt-prefetch)
6611 (let ((current-group gnus-newsgroup-name)
6612 (current-buffer (current-buffer))
6614 (gnus-summary-exit t)
6615 (while (not entered)
6616 ;; Then we find what group we are supposed to enter.
6617 (set-buffer gnus-group-buffer)
6618 (gnus-group-jump-to-group current-group)
6621 (if (eq gnus-keep-same-level 'best)
6622 (gnus-summary-best-group gnus-newsgroup-name)
6623 (gnus-summary-search-group backward gnus-keep-same-level))))
6624 (if (not target-group)
6625 ;; There are no further groups, so we return to the group
6628 (gnus-message 5 "Returning to the group buffer")
6630 (when (gnus-buffer-live-p current-buffer)
6631 (set-buffer current-buffer)
6632 (gnus-summary-exit))
6633 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6634 ;; We try to enter the target group.
6635 (gnus-group-jump-to-group target-group)
6636 (let ((unreads (gnus-group-group-unread)))
6637 (if (and (or (eq t unreads)
6638 (and unreads (not (zerop unreads))))
6640 ;; Now we semi-exit this group to update Xrefs
6641 ;; and all variables. We can't do a real exit,
6642 ;; because the window conf must remain the same
6643 ;; in case the user is prompted for info, and we
6644 ;; don't want the window conf to change before
6646 (when (gnus-buffer-live-p current-buffer)
6647 (set-buffer current-buffer)
6648 (gnus-summary-exit t))
6649 (gnus-summary-read-group
6650 target-group nil no-article
6651 (and (buffer-name current-buffer) current-buffer)
6654 (setq current-group target-group
6655 target-group nil)))))))
6657 (defun gnus-summary-prev-group (&optional no-article)
6658 "Exit current newsgroup and then select previous unread newsgroup.
6659 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6661 (gnus-summary-next-group no-article nil t))
6663 ;; Walking around summary lines.
6665 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6666 "Go to the first unread subject.
6667 If UNREAD is non-nil, go to the first unread article.
6668 Returns the article selected or nil if there are no unread articles."
6673 ((null gnus-newsgroup-data)
6674 (gnus-message 3 "No articles in the group")
6676 ;; Pick the first article.
6678 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6679 (gnus-data-number (car gnus-newsgroup-data)))
6680 ;; No unread articles.
6681 ((null gnus-newsgroup-unreads)
6682 (gnus-message 3 "No more unread articles")
6684 ;; Find the first unread article.
6686 (let ((data gnus-newsgroup-data))
6688 (and (not (and undownloaded
6689 (memq (car data) gnus-newsgroup-undownloaded)))
6692 (gnus-data-number (car data))
6693 gnus-newsgroup-unseen))
6694 (not (gnus-data-unread-p (car data))))
6695 (not (gnus-data-unread-p (car data))))))
6696 (setq data (cdr data)))
6698 (goto-char (gnus-data-pos (car data)))
6699 (gnus-data-number (car data))))))
6700 (gnus-summary-position-point)))
6702 (defun gnus-summary-next-subject (n &optional unread dont-display)
6703 "Go to next N'th summary line.
6704 If N is negative, go to the previous N'th subject line.
6705 If UNREAD is non-nil, only unread articles are selected.
6706 The difference between N and the actual number of steps taken is
6709 (let ((backward (< n 0))
6713 (gnus-summary-find-prev unread)
6714 (gnus-summary-find-next unread)))
6715 (unless (zerop (setq n (1- n)))
6716 (gnus-summary-show-thread)))
6718 (gnus-message 7 "No more%s articles"
6719 (if unread " unread" "")))
6720 (unless dont-display
6721 (gnus-summary-recenter)
6722 (gnus-summary-position-point))
6725 (defun gnus-summary-next-unread-subject (n)
6726 "Go to next N'th unread summary line."
6728 (gnus-summary-next-subject n t))
6730 (defun gnus-summary-prev-subject (n &optional unread)
6731 "Go to previous N'th summary line.
6732 If optional argument UNREAD is non-nil, only unread article is selected."
6734 (gnus-summary-next-subject (- n) unread))
6736 (defun gnus-summary-prev-unread-subject (n)
6737 "Go to previous N'th unread summary line."
6739 (gnus-summary-next-subject (- n) t))
6741 (defun gnus-summary-goto-subject (article &optional force silent)
6742 "Go the subject line of ARTICLE.
6743 If FORCE, also allow jumping to articles not currently shown."
6744 (interactive "nArticle number: ")
6745 (unless (numberp article)
6746 (error "Article %s is not a number" article))
6748 (data (gnus-data-find article)))
6749 ;; We read in the article if we have to.
6752 (gnus-summary-insert-subject
6754 (if (or (numberp force) (vectorp force)) force)
6756 (setq data (gnus-data-find article)))
6761 (gnus-message 3 "Can't find article %d" article))
6763 (let ((pt (gnus-data-pos data)))
6765 (gnus-summary-set-article-display-arrow pt))
6766 (gnus-summary-position-point)
6769 ;; Walking around summary lines with displaying articles.
6771 (defun gnus-summary-expand-window (&optional arg)
6772 "Make the summary buffer take up the entire Emacs frame.
6773 Given a prefix, will force an `article' buffer configuration."
6776 (gnus-configure-windows 'article 'force)
6777 (gnus-configure-windows 'summary 'force)))
6779 (defun gnus-summary-display-article (article &optional all-header)
6780 "Display ARTICLE in article buffer."
6781 (when (gnus-buffer-live-p gnus-article-buffer)
6782 (with-current-buffer gnus-article-buffer
6783 (set-buffer-multibyte t)))
6784 (gnus-set-global-variables)
6785 (when (gnus-buffer-live-p gnus-article-buffer)
6786 (with-current-buffer gnus-article-buffer
6787 (setq gnus-article-charset gnus-newsgroup-charset)
6788 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6789 (set-buffer-multibyte t)))
6793 (if gnus-summary-display-article-function
6794 (funcall gnus-summary-display-article-function article all-header)
6795 (gnus-article-prepare article all-header))
6796 (with-current-buffer gnus-article-buffer
6797 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6799 (gnus-run-hooks 'gnus-select-article-hook)
6800 (when (and gnus-current-article
6801 (not (zerop gnus-current-article)))
6802 (gnus-summary-goto-subject gnus-current-article))
6803 (gnus-summary-recenter)
6804 (when (and gnus-use-trees gnus-show-threads)
6805 (gnus-possibly-generate-tree article)
6806 (gnus-highlight-selected-tree article))
6807 ;; Successfully display article.
6808 (gnus-article-set-window-start
6809 (cdr (assq article gnus-newsgroup-bookmarks))))))
6811 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6812 "Select the current article.
6813 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6814 non-nil, the article will be re-fetched even if it already present in
6815 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6817 ;; Make sure we are in the summary buffer to work around bbdb bug.
6818 (unless (eq major-mode 'gnus-summary-mode)
6819 (set-buffer gnus-summary-buffer))
6820 (let ((article (or article (gnus-summary-article-number)))
6821 (all-headers (not (not all-headers))) ;Must be T or NIL.
6822 gnus-summary-display-article-function)
6824 (gnus-summary-article-pseudo-p article)
6825 (error "This is a pseudo-article"))
6827 (set-buffer gnus-summary-buffer)
6828 (if (or (and gnus-single-article-buffer
6829 (or (null gnus-current-article)
6830 (null gnus-article-current)
6831 (null (get-buffer gnus-article-buffer))
6832 (not (eq article (cdr gnus-article-current)))
6833 (not (equal (car gnus-article-current)
6834 gnus-newsgroup-name))))
6835 (and (not gnus-single-article-buffer)
6836 (or (null gnus-current-article)
6837 (not (eq gnus-current-article article))))
6839 ;; The requested article is different from the current article.
6841 (gnus-summary-display-article article all-headers)
6842 (gnus-article-set-window-start
6843 (cdr (assq article gnus-newsgroup-bookmarks)))
6847 (defun gnus-summary-force-verify-and-decrypt ()
6849 (let ((mm-verify-option 'known)
6850 (mm-decrypt-option 'known)
6851 (gnus-buttonized-mime-types (append (list "multipart/signed"
6852 "multipart/encrypted")
6853 gnus-buttonized-mime-types)))
6854 (gnus-summary-select-article nil 'force)))
6856 (defun gnus-summary-set-current-mark (&optional current-mark)
6857 "Obsolete function."
6860 (defun gnus-summary-next-article (&optional unread subject backward push)
6861 "Select the next article.
6862 If UNREAD, only unread articles are selected.
6863 If SUBJECT, only articles with SUBJECT are selected.
6864 If BACKWARD, the previous article is selected instead of the next."
6867 ;; Is there such an article?
6868 ((and (gnus-summary-search-forward unread subject backward)
6869 (or (gnus-summary-display-article (gnus-summary-article-number))
6870 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6871 (gnus-summary-position-point))
6872 ;; If not, we try the first unread, if that is wanted.
6874 gnus-auto-select-same
6875 (gnus-summary-first-unread-article))
6876 (gnus-summary-position-point)
6877 (gnus-message 6 "Wrapped"))
6878 ;; Try to get next/previous article not displayed in this group.
6879 ((and gnus-auto-extend-newsgroup
6880 (not unread) (not subject))
6881 (gnus-summary-goto-article
6882 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6883 nil (count-lines (point-min) (point))))
6884 ;; Go to next/previous group.
6886 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6887 (gnus-summary-jump-to-group gnus-newsgroup-name))
6888 (let ((cmd last-command-char)
6891 (set-buffer gnus-group-buffer)
6894 (if (eq gnus-keep-same-level 'best)
6895 (gnus-summary-best-group gnus-newsgroup-name)
6896 (gnus-summary-search-group backward gnus-keep-same-level))))
6897 ;; For some reason, the group window gets selected. We change
6899 (select-window (get-buffer-window (current-buffer)))
6900 ;; Select next unread newsgroup automagically.
6902 ((or (not gnus-auto-select-next)
6904 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6905 ((or (eq gnus-auto-select-next 'quietly)
6906 (and (eq gnus-auto-select-next 'slightly-quietly)
6908 (and (eq gnus-auto-select-next 'almost-quietly)
6909 (gnus-summary-last-article-p)))
6911 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6913 (gnus-message 7 "No more%s articles (%s)..."
6914 (if unread " unread" "")
6915 (if group (concat "selecting " group)
6917 (gnus-summary-next-group nil group backward)))
6919 (when (gnus-key-press-event-p last-input-event)
6920 (gnus-summary-walk-group-buffer
6921 gnus-newsgroup-name cmd unread backward point))))))))
6923 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6924 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6925 (?\C-p (gnus-group-prev-unread-group 1))))
6926 (cursor-in-echo-area t)
6927 keve key group ended)
6929 (set-buffer gnus-group-buffer)
6932 (if (eq gnus-keep-same-level 'best)
6933 (gnus-summary-best-group gnus-newsgroup-name)
6934 (gnus-summary-search-group backward gnus-keep-same-level))))
6937 5 "No more%s articles%s" (if unread " unread" "")
6939 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6940 (format " (Type %s for %s [%s])"
6941 (single-key-description cmd) group
6942 (car (gnus-gethash group gnus-newsrc-hashtb)))
6943 (format " (Type %s to exit %s)"
6944 (single-key-description cmd)
6945 gnus-newsgroup-name)))
6946 ;; Confirm auto selection.
6947 (setq key (car (setq keve (gnus-read-event-char))))
6950 ((assq key keystrokes)
6951 (let ((obuf (current-buffer)))
6952 (switch-to-buffer gnus-group-buffer)
6954 (gnus-group-jump-to-group group))
6955 (eval (cadr (assq key keystrokes)))
6956 (setq group (gnus-group-group-name))
6957 (switch-to-buffer obuf))
6961 (gnus-ephemeral-group-p gnus-newsgroup-name))
6963 (gnus-summary-next-group nil group backward)))
6965 (push (cdr keve) unread-command-events))))))
6967 (defun gnus-summary-next-unread-article ()
6968 "Select unread article after current one."
6970 (gnus-summary-next-article
6971 (or (not (eq gnus-summary-goto-unread 'never))
6972 (gnus-summary-last-article-p (gnus-summary-article-number)))
6973 (and gnus-auto-select-same
6974 (gnus-summary-article-subject))))
6976 (defun gnus-summary-prev-article (&optional unread subject)
6977 "Select the article after the current one.
6978 If UNREAD is non-nil, only unread articles are selected."
6980 (gnus-summary-next-article unread subject t))
6982 (defun gnus-summary-prev-unread-article ()
6983 "Select unread article before current one."
6985 (gnus-summary-prev-article
6986 (or (not (eq gnus-summary-goto-unread 'never))
6987 (gnus-summary-first-article-p (gnus-summary-article-number)))
6988 (and gnus-auto-select-same
6989 (gnus-summary-article-subject))))
6991 (defun gnus-summary-next-page (&optional lines circular stop)
6992 "Show next page of the selected article.
6993 If at the end of the current article, select the next article.
6994 LINES says how many lines should be scrolled up.
6996 If CIRCULAR is non-nil, go to the start of the article instead of
6997 selecting the next article when reaching the end of the current
7000 If STOP is non-nil, just stop when reaching the end of the message."
7002 (setq gnus-summary-buffer (current-buffer))
7003 (gnus-set-global-variables)
7004 (let ((article (gnus-summary-article-number))
7005 (article-window (get-buffer-window gnus-article-buffer t))
7007 ;; If the buffer is empty, we have no article.
7009 (error "No article to select"))
7010 (gnus-configure-windows 'article)
7011 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7012 (if (and (eq gnus-summary-goto-unread 'never)
7013 (not (gnus-summary-last-article-p article)))
7014 (gnus-summary-next-article)
7015 (gnus-summary-next-unread-article))
7016 (if (or (null gnus-current-article)
7017 (null gnus-article-current)
7018 (/= article (cdr gnus-article-current))
7019 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7020 ;; Selected subject is different from current article's.
7021 (gnus-summary-display-article article)
7022 (when article-window
7023 (gnus-eval-in-buffer-window gnus-article-buffer
7024 (setq endp (gnus-article-next-page lines)))
7027 (gnus-message 3 "End of message"))
7029 (gnus-summary-beginning-of-article))
7031 (gnus-message 3 "End of message"))
7033 (if (and (eq gnus-summary-goto-unread 'never)
7034 (not (gnus-summary-last-article-p article)))
7035 (gnus-summary-next-article)
7036 (gnus-summary-next-unread-article))))))))
7037 (gnus-summary-recenter)
7038 (gnus-summary-position-point)))
7040 (defun gnus-summary-prev-page (&optional lines move)
7041 "Show previous page of selected article.
7042 Argument LINES specifies lines to be scrolled down.
7043 If MOVE, move to the previous unread article if point is at
7044 the beginning of the buffer."
7046 (let ((article (gnus-summary-article-number))
7047 (article-window (get-buffer-window gnus-article-buffer t))
7049 (gnus-configure-windows 'article)
7050 (if (or (null gnus-current-article)
7051 (null gnus-article-current)
7052 (/= article (cdr gnus-article-current))
7053 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7054 ;; Selected subject is different from current article's.
7055 (gnus-summary-display-article article)
7056 (gnus-summary-recenter)
7057 (when article-window
7058 (gnus-eval-in-buffer-window gnus-article-buffer
7059 (setq endp (gnus-article-prev-page lines)))
7060 (when (and move endp)
7062 (gnus-message 3 "Beginning of message"))
7064 (if (and (eq gnus-summary-goto-unread 'never)
7065 (not (gnus-summary-first-article-p article)))
7066 (gnus-summary-prev-article)
7067 (gnus-summary-prev-unread-article))))))))
7068 (gnus-summary-position-point))
7070 (defun gnus-summary-prev-page-or-article (&optional lines)
7071 "Show previous page of selected article.
7072 Argument LINES specifies lines to be scrolled down.
7073 If at the beginning of the article, go to the next article."
7075 (gnus-summary-prev-page lines t))
7077 (defun gnus-summary-scroll-up (lines)
7078 "Scroll up (or down) one line current article.
7079 Argument LINES specifies lines to be scrolled up (or down if negative)."
7081 (gnus-configure-windows 'article)
7082 (gnus-summary-show-thread)
7083 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7084 (gnus-eval-in-buffer-window gnus-article-buffer
7086 (when (gnus-article-next-page lines)
7087 (gnus-message 3 "End of message")))
7089 (gnus-article-prev-page (- lines))))))
7090 (gnus-summary-recenter)
7091 (gnus-summary-position-point))
7093 (defun gnus-summary-scroll-down (lines)
7094 "Scroll down (or up) one line current article.
7095 Argument LINES specifies lines to be scrolled down (or up if negative)."
7097 (gnus-summary-scroll-up (- lines)))
7099 (defun gnus-summary-next-same-subject ()
7100 "Select next article which has the same subject as current one."
7102 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7104 (defun gnus-summary-prev-same-subject ()
7105 "Select previous article which has the same subject as current one."
7107 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7109 (defun gnus-summary-next-unread-same-subject ()
7110 "Select next unread article which has the same subject as current one."
7112 (gnus-summary-next-article t (gnus-summary-article-subject)))
7114 (defun gnus-summary-prev-unread-same-subject ()
7115 "Select previous unread article which has the same subject as current one."
7117 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7119 (defun gnus-summary-first-unread-article ()
7120 "Select the first unread article.
7121 Return nil if there are no unread articles."
7124 (when (gnus-summary-first-subject t)
7125 (gnus-summary-show-thread)
7126 (gnus-summary-first-subject t)
7127 (gnus-summary-display-article (gnus-summary-article-number)))
7128 (gnus-summary-position-point)))
7130 (defun gnus-summary-first-unread-subject ()
7131 "Place the point on the subject line of the first unread article.
7132 Return nil if there are no unread articles."
7135 (when (gnus-summary-first-subject t)
7136 (gnus-summary-show-thread)
7137 (gnus-summary-first-subject t))
7138 (gnus-summary-position-point)))
7140 (defun gnus-summary-first-unseen-subject ()
7141 "Place the point on the subject line of the first unseen article.
7142 Return nil if there are no unseen articles."
7145 (when (gnus-summary-first-subject t t t)
7146 (gnus-summary-show-thread)
7147 (gnus-summary-first-subject t t t))
7148 (gnus-summary-position-point)))
7150 (defun gnus-summary-first-unseen-or-unread-subject ()
7151 "Place the point on the subject line of the first unseen article.
7152 Return nil if there are no unseen articles."
7155 (unless (when (gnus-summary-first-subject t t t)
7156 (gnus-summary-show-thread)
7157 (gnus-summary-first-subject t t t))
7158 (when (gnus-summary-first-subject t)
7159 (gnus-summary-show-thread)
7160 (gnus-summary-first-subject t)))
7161 (gnus-summary-position-point)))
7163 (defun gnus-summary-first-article ()
7164 "Select the first article.
7165 Return nil if there are no articles."
7168 (when (gnus-summary-first-subject)
7169 (gnus-summary-show-thread)
7170 (gnus-summary-first-subject)
7171 (gnus-summary-display-article (gnus-summary-article-number)))
7172 (gnus-summary-position-point)))
7174 (defun gnus-summary-best-unread-article (&optional arg)
7175 "Select the unread article with the highest score.
7176 If given a prefix argument, select the next unread article that has a
7177 score higher than the default score."
7179 (let ((article (if arg
7180 (gnus-summary-better-unread-subject)
7181 (gnus-summary-best-unread-subject))))
7183 (gnus-summary-goto-article article)
7184 (error "No unread articles"))))
7186 (defun gnus-summary-best-unread-subject ()
7187 "Select the unread subject with the highest score."
7189 (let ((best -1000000)
7190 (data gnus-newsgroup-data)
7193 (and (gnus-data-unread-p (car data))
7195 (gnus-summary-article-score (gnus-data-number (car data))))
7198 article (gnus-data-number (car data))))
7199 (setq data (cdr data)))
7201 (gnus-summary-goto-subject article))
7202 (gnus-summary-position-point)
7205 (defun gnus-summary-better-unread-subject ()
7206 "Select the first unread subject that has a score over the default score."
7208 (let ((data gnus-newsgroup-data)
7210 (while (and (setq article (gnus-data-number (car data)))
7211 (or (gnus-data-read-p (car data))
7212 (not (> (gnus-summary-article-score article)
7213 gnus-summary-default-score))))
7214 (setq data (cdr data)))
7216 (gnus-summary-goto-subject article))
7217 (gnus-summary-position-point)
7220 (defun gnus-summary-last-subject ()
7221 "Go to the last displayed subject line in the group."
7222 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7224 (gnus-summary-goto-subject article))))
7226 (defun gnus-summary-goto-article (article &optional all-headers force)
7227 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7228 If ALL-HEADERS is non-nil, no header lines are hidden.
7229 If FORCE, go to the article even if it isn't displayed. If FORCE
7230 is a number, it is the line the article is to be displayed on."
7234 "Article number or Message-ID: "
7235 (mapcar (lambda (number) (list (int-to-string number)))
7236 gnus-newsgroup-limit))
7240 (if (and (stringp article)
7241 (string-match "@" article))
7242 (gnus-summary-refer-article article)
7243 (when (stringp article)
7244 (setq article (string-to-number article)))
7245 (if (gnus-summary-goto-subject article force)
7246 (gnus-summary-display-article article all-headers)
7247 (gnus-message 4 "Couldn't go to article %s" article) nil))
7248 (gnus-summary-position-point)))
7250 (defun gnus-summary-goto-last-article ()
7251 "Go to the previously read article."
7254 (when gnus-last-article
7255 (gnus-summary-goto-article gnus-last-article nil t))
7256 (gnus-summary-position-point)))
7258 (defun gnus-summary-pop-article (number)
7259 "Pop one article off the history and go to the previous.
7260 NUMBER articles will be popped off."
7263 (setq gnus-newsgroup-history
7264 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7266 (gnus-summary-goto-article (car to) nil t)
7267 (error "Article history empty")))
7268 (gnus-summary-position-point))
7270 ;; Summary commands and functions for limiting the summary buffer.
7272 (defun gnus-summary-limit-to-articles (n)
7273 "Limit the summary buffer to the next N articles.
7274 If not given a prefix, use the process marked articles instead."
7277 (let ((articles (gnus-summary-work-articles n)))
7278 (setq gnus-newsgroup-processable nil)
7279 (gnus-summary-limit articles))
7280 (gnus-summary-position-point)))
7282 (defun gnus-summary-pop-limit (&optional total)
7283 "Restore the previous limit.
7284 If given a prefix, remove all limits."
7287 (setq gnus-newsgroup-limits
7288 (list (mapcar (lambda (h) (mail-header-number h))
7289 gnus-newsgroup-headers))))
7290 (unless gnus-newsgroup-limits
7291 (error "No limit to pop"))
7293 (gnus-summary-limit nil 'pop)
7294 (gnus-summary-position-point)))
7296 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7297 "Limit the summary buffer to articles that have subjects that match a regexp.
7298 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7300 (list (read-string (if current-prefix-arg
7301 "Exclude subject (regexp): "
7302 "Limit to subject (regexp): "))
7303 nil current-prefix-arg))
7305 (setq header "subject"))
7306 (when (not (equal "" subject))
7308 (let ((articles (gnus-summary-find-matching
7309 (or header "subject") subject 'all nil nil
7312 (error "Found no matches for \"%s\"" subject))
7313 (gnus-summary-limit articles))
7314 (gnus-summary-position-point))))
7316 (defun gnus-summary-limit-to-author (from &optional not-matching)
7317 "Limit the summary buffer to articles that have authors that match a regexp.
7318 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7320 (list (read-string (if current-prefix-arg
7321 "Exclude author (regexp): "
7322 "Limit to author (regexp): "))
7323 current-prefix-arg))
7324 (gnus-summary-limit-to-subject from "from" not-matching))
7326 (defun gnus-summary-limit-to-age (age &optional younger-p)
7327 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7328 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7329 articles that are younger than AGE days."
7331 (let ((younger current-prefix-arg)
7334 (while (not days-got)
7335 (setq days (if younger
7336 (read-string "Limit to articles younger than (in days, older when negative): ")
7338 "Limit to articles older than (in days, younger when negative): ")))
7339 (when (> (length days) 0)
7340 (setq days (read days)))
7346 (setq younger (not younger))
7347 (setq days (* days -1)))))
7348 (message "Please enter a number.")
7350 (list days younger)))
7352 (let ((data gnus-newsgroup-data)
7353 (cutoff (days-to-time age))
7354 articles d date is-younger)
7355 (while (setq d (pop data))
7356 (when (and (vectorp (gnus-data-header d))
7357 (setq date (mail-header-date (gnus-data-header d))))
7358 (setq is-younger (time-less-p
7359 (time-since (condition-case ()
7366 (push (gnus-data-number d) articles))))
7367 (gnus-summary-limit (nreverse articles)))
7368 (gnus-summary-position-point)))
7370 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7371 "Limit the summary buffer to articles that match an 'extra' header."
7375 (gnus-completing-read-with-default
7376 (symbol-name (car gnus-extra-headers))
7377 (if current-prefix-arg
7378 "Exclude extra header:"
7379 "Limit extra header:")
7381 (cons (symbol-name x) x))
7386 (read-string (format "%s header %s (regexp): "
7387 (if current-prefix-arg "Exclude" "Limit to")
7389 current-prefix-arg)))
7390 (when (not (equal "" regexp))
7392 (let ((articles (gnus-summary-find-matching
7393 (cons 'extra header) regexp 'all nil nil
7396 (error "Found no matches for \"%s\"" regexp))
7397 (gnus-summary-limit articles))
7398 (gnus-summary-position-point))))
7400 (defun gnus-summary-limit-to-display-predicate ()
7401 "Limit the summary buffer to the predicated in the `display' group parameter."
7403 (unless gnus-newsgroup-display
7404 (error "There is no `display' group parameter"))
7406 (dolist (number gnus-newsgroup-articles)
7407 (when (funcall gnus-newsgroup-display)
7408 (push number articles)))
7409 (gnus-summary-limit articles))
7410 (gnus-summary-position-point))
7412 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7414 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7416 (defun gnus-summary-limit-to-unread (&optional all)
7417 "Limit the summary buffer to articles that are not marked as read.
7418 If ALL is non-nil, limit strictly to unread articles."
7421 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7422 (gnus-summary-limit-to-marks
7423 ;; Concat all the marks that say that an article is read and have
7425 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7426 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7427 gnus-low-score-mark gnus-expirable-mark
7428 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7429 gnus-duplicate-mark gnus-souped-mark)
7432 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7433 (make-obsolete 'gnus-summary-delete-marked-with
7434 'gnus-summary-limit-exclude-marks)
7436 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7437 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7438 If REVERSE, limit the summary buffer to articles that are marked
7439 with MARKS. MARKS can either be a string of marks or a list of marks.
7440 Returns how many articles were removed."
7441 (interactive "sMarks: ")
7442 (gnus-summary-limit-to-marks marks t))
7444 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7445 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7446 If REVERSE (the prefix), limit the summary buffer to articles that are
7447 not marked with MARKS. MARKS can either be a string of marks or a
7449 Returns how many articles were removed."
7450 (interactive "sMarks: \nP")
7452 (let ((data gnus-newsgroup-data)
7453 (marks (if (listp marks) marks
7454 (append marks nil))) ; Transform to list.
7457 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7458 (memq (gnus-data-mark (car data)) marks))
7459 (push (gnus-data-number (car data)) articles))
7460 (setq data (cdr data)))
7461 (gnus-summary-limit articles))
7462 (gnus-summary-position-point)))
7464 (defun gnus-summary-limit-to-score (score)
7465 "Limit to articles with score at or above SCORE."
7466 (interactive "NLimit to articles with score of at least: ")
7467 (let ((data gnus-newsgroup-data)
7470 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7472 (push (gnus-data-number (car data)) articles))
7473 (setq data (cdr data)))
7475 (gnus-summary-limit articles)
7476 (gnus-summary-position-point))))
7478 (defun gnus-summary-limit-to-unseen ()
7479 "Limit to unseen articles."
7482 (gnus-summary-limit gnus-newsgroup-unseen)
7483 (gnus-summary-position-point)))
7485 (defun gnus-summary-limit-include-thread (id)
7486 "Display all the hidden articles that is in the thread with ID in it.
7487 When called interactively, ID is the Message-ID of the current
7489 (interactive (list (mail-header-id (gnus-summary-article-header))))
7490 (let ((articles (gnus-articles-in-thread
7491 (gnus-id-to-thread (gnus-root-id id)))))
7493 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7494 (gnus-summary-limit-include-matching-articles
7496 (regexp-quote (gnus-simplify-subject-re
7497 (mail-header-subject (gnus-id-to-header id)))))
7498 (gnus-summary-position-point))))
7500 (defun gnus-summary-limit-include-matching-articles (header regexp)
7501 "Display all the hidden articles that have HEADERs that match REGEXP."
7502 (interactive (list (read-string "Match on header: ")
7503 (read-string "Regexp: ")))
7504 (let ((articles (gnus-find-matching-articles header regexp)))
7506 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7507 (gnus-summary-position-point))))
7509 (defun gnus-summary-limit-include-dormant ()
7510 "Display all the hidden articles that are marked as dormant.
7511 Note that this command only works on a subset of the articles currently
7512 fetched for this group."
7514 (unless gnus-newsgroup-dormant
7515 (error "There are no dormant articles in this group"))
7517 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7518 (gnus-summary-position-point)))
7520 (defun gnus-summary-limit-exclude-dormant ()
7521 "Hide all dormant articles."
7524 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7525 (gnus-summary-position-point)))
7527 (defun gnus-summary-limit-exclude-childless-dormant ()
7528 "Hide all dormant articles that have no children."
7530 (let ((data (gnus-data-list t))
7531 articles d children)
7532 ;; Find all articles that are either not dormant or have
7534 (while (setq d (pop data))
7535 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7537 (gnus-article-children (gnus-data-number d)))
7540 (when (memq (car children) articles)
7545 (push (gnus-data-number d) articles)))
7548 (gnus-summary-limit articles)
7549 (gnus-summary-position-point))))
7551 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7552 "Mark all unread excluded articles as read.
7553 If ALL, mark even excluded ticked and dormants as read."
7555 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7556 (let ((articles (gnus-sorted-ndifference
7558 (mapcar (lambda (h) (mail-header-number h))
7559 gnus-newsgroup-headers)
7561 gnus-newsgroup-limit))
7563 (setq gnus-newsgroup-unreads
7564 (gnus-sorted-intersection gnus-newsgroup-unreads
7565 gnus-newsgroup-limit))
7567 (setq gnus-newsgroup-dormant nil
7568 gnus-newsgroup-marked nil
7569 gnus-newsgroup-reads
7571 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7572 gnus-newsgroup-reads))
7573 (while (setq article (pop articles))
7574 (unless (or (memq article gnus-newsgroup-dormant)
7575 (memq article gnus-newsgroup-marked))
7576 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7578 (defun gnus-summary-limit (articles &optional pop)
7580 ;; We pop the previous limit off the stack and use that.
7581 (setq articles (car gnus-newsgroup-limits)
7582 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7583 ;; We use the new limit, so we push the old limit on the stack.
7584 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7586 (setq gnus-newsgroup-limit articles)
7587 (let ((total (length gnus-newsgroup-data))
7588 (data (gnus-data-find-list (gnus-summary-article-number)))
7589 (gnus-summary-mark-below nil) ; Inhibit this.
7591 ;; This will do all the work of generating the new summary buffer
7592 ;; according to the new limit.
7593 (gnus-summary-prepare)
7594 ;; Hide any threads, possibly.
7595 (gnus-summary-maybe-hide-threads)
7596 ;; Try to return to the article you were at, or one in the
7599 ;; We try to find some article after the current one.
7601 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7604 (setq data (cdr data))))
7606 ;; If there is no data, that means that we were after the last
7607 ;; article. The same goes when we can't find any articles
7608 ;; after the current one.
7609 (goto-char (point-max))
7610 (gnus-summary-find-prev))
7611 (gnus-set-mode-line 'summary)
7612 ;; We return how many articles were removed from the summary
7613 ;; buffer as a result of the new limit.
7614 (- total (length gnus-newsgroup-data))))
7616 (defsubst gnus-invisible-cut-children (threads)
7619 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7624 (defsubst gnus-cut-thread (thread)
7625 "Go forwards in the thread until we find an article that we want to display."
7626 (when (or (eq gnus-fetch-old-headers 'some)
7627 (eq gnus-fetch-old-headers 'invisible)
7628 (numberp gnus-fetch-old-headers)
7629 (eq gnus-build-sparse-threads 'some)
7630 (eq gnus-build-sparse-threads 'more))
7631 ;; Deal with old-fetched headers and sparse threads.
7635 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7636 (gnus-summary-article-ancient-p
7637 (mail-header-number (car thread))))
7638 (if (or (<= (length (cdr thread)) 1)
7639 (eq gnus-fetch-old-headers 'invisible))
7640 (setq gnus-newsgroup-limit
7641 (delq (mail-header-number (car thread))
7642 gnus-newsgroup-limit)
7643 thread (cadr thread))
7644 (when (gnus-invisible-cut-children (cdr thread))
7645 (let ((th (cdr thread)))
7647 (if (memq (mail-header-number (caar th))
7648 gnus-newsgroup-limit)
7649 (setq thread (car th)
7651 (setq th (cdr th))))))))))
7654 (defun gnus-cut-threads (threads)
7655 "Cut off all uninteresting articles from the beginning of threads."
7656 (when (or (eq gnus-fetch-old-headers 'some)
7657 (eq gnus-fetch-old-headers 'invisible)
7658 (numberp gnus-fetch-old-headers)
7659 (eq gnus-build-sparse-threads 'some)
7660 (eq gnus-build-sparse-threads 'more))
7663 (setcar th (gnus-cut-thread (car th)))
7664 (setq th (cdr th)))))
7665 ;; Remove nixed out threads.
7668 (defun gnus-summary-initial-limit (&optional show-if-empty)
7669 "Figure out what the initial limit is supposed to be on group entry.
7670 This entails weeding out unwanted dormants, low-scored articles,
7671 fetch-old-headers verbiage, and so on."
7672 ;; Most groups have nothing to remove.
7673 (if (or gnus-inhibit-limiting
7674 (and (null gnus-newsgroup-dormant)
7675 (eq gnus-newsgroup-display 'gnus-not-ignore)
7676 (not (eq gnus-fetch-old-headers 'some))
7677 (not (numberp gnus-fetch-old-headers))
7678 (not (eq gnus-fetch-old-headers 'invisible))
7679 (null gnus-summary-expunge-below)
7680 (not (eq gnus-build-sparse-threads 'some))
7681 (not (eq gnus-build-sparse-threads 'more))
7682 (null gnus-thread-expunge-below)
7683 (not gnus-use-nocem)))
7685 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7686 (setq gnus-newsgroup-limit nil)
7689 (unless (car (symbol-value node))
7690 ;; These threads have no parents -- they are roots.
7691 (let ((nodes (cdr (symbol-value node)))
7694 (if (and gnus-thread-expunge-below
7695 (< (gnus-thread-total-score (car nodes))
7696 gnus-thread-expunge-below))
7697 (gnus-expunge-thread (pop nodes))
7698 (setq thread (pop nodes))
7699 (gnus-summary-limit-children thread))))))
7700 gnus-newsgroup-dependencies)
7701 ;; If this limitation resulted in an empty group, we might
7702 ;; pop the previous limit and use it instead.
7703 (when (and (not gnus-newsgroup-limit)
7705 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7706 gnus-newsgroup-limit))
7708 (defun gnus-summary-limit-children (thread)
7709 "Return 1 if this subthread is visible and 0 if it is not."
7710 ;; First we get the number of visible children to this thread. This
7711 ;; is done by recursing down the thread using this function, so this
7712 ;; will really go down to a leaf article first, before slowly
7713 ;; working its way up towards the root.
7715 (let* ((max-lisp-eval-depth 5000)
7718 (apply '+ (mapcar 'gnus-summary-limit-children
7721 (number (mail-header-number (car thread)))
7724 (not (memq number gnus-newsgroup-marked))
7726 ;; If this article is dormant and has absolutely no visible
7727 ;; children, then this article isn't visible.
7728 (and (memq number gnus-newsgroup-dormant)
7730 ;; If this is "fetch-old-headered" and there is no
7731 ;; visible children, then we don't want this article.
7732 (and (or (eq gnus-fetch-old-headers 'some)
7733 (numberp gnus-fetch-old-headers))
7734 (gnus-summary-article-ancient-p number)
7736 ;; If this is "fetch-old-headered" and `invisible', then
7737 ;; we don't want this article.
7738 (and (eq gnus-fetch-old-headers 'invisible)
7739 (gnus-summary-article-ancient-p number))
7740 ;; If this is a sparsely inserted article with no children,
7741 ;; we don't want it.
7742 (and (eq gnus-build-sparse-threads 'some)
7743 (gnus-summary-article-sparse-p number)
7745 ;; If we use expunging, and this article is really
7746 ;; low-scored, then we don't want this article.
7747 (when (and gnus-summary-expunge-below
7749 (or (cdr (assq number gnus-newsgroup-scored))
7750 gnus-summary-default-score))
7751 gnus-summary-expunge-below))
7752 ;; We increase the expunge-tally here, but that has
7753 ;; nothing to do with the limits, really.
7754 (incf gnus-newsgroup-expunged-tally)
7755 ;; We also mark as read here, if that's wanted.
7756 (when (and gnus-summary-mark-below
7757 (< score gnus-summary-mark-below))
7758 (setq gnus-newsgroup-unreads
7759 (delq number gnus-newsgroup-unreads))
7760 (if gnus-newsgroup-auto-expire
7761 (push number gnus-newsgroup-expirable)
7762 (push (cons number gnus-low-score-mark)
7763 gnus-newsgroup-reads)))
7765 ;; Do the `display' group parameter.
7766 (and gnus-newsgroup-display
7767 (not (funcall gnus-newsgroup-display)))
7768 ;; Check NoCeM things.
7769 (if (and gnus-use-nocem
7770 (gnus-nocem-unwanted-article-p
7771 (mail-header-id (car thread))))
7773 (setq gnus-newsgroup-unreads
7774 (delq number gnus-newsgroup-unreads))
7776 ;; Nope, invisible article.
7778 ;; Ok, this article is to be visible, so we add it to the limit
7780 (push number gnus-newsgroup-limit)
7783 (defun gnus-expunge-thread (thread)
7784 "Mark all articles in THREAD as read."
7785 (let* ((number (mail-header-number (car thread))))
7786 (incf gnus-newsgroup-expunged-tally)
7787 ;; We also mark as read here, if that's wanted.
7788 (setq gnus-newsgroup-unreads
7789 (delq number gnus-newsgroup-unreads))
7790 (if gnus-newsgroup-auto-expire
7791 (push number gnus-newsgroup-expirable)
7792 (push (cons number gnus-low-score-mark)
7793 gnus-newsgroup-reads)))
7794 ;; Go recursively through all subthreads.
7795 (mapcar 'gnus-expunge-thread (cdr thread)))
7797 ;; Summary article oriented commands
7799 (defun gnus-summary-refer-parent-article (n)
7800 "Refer parent article N times.
7801 If N is negative, go to ancestor -N instead.
7802 The difference between N and the number of articles fetched is returned."
7806 (when (not (natnump n))
7811 (setq header (gnus-summary-article-header))
7812 (if (and (eq (mail-header-number header)
7813 (cdr gnus-article-current))
7814 (equal gnus-newsgroup-name
7815 (car gnus-article-current)))
7816 ;; If we try to find the parent of the currently
7817 ;; displayed article, then we take a look at the actual
7818 ;; References header, since this is slightly more
7819 ;; reliable than the References field we got from the
7822 (set-buffer gnus-original-article-buffer)
7823 (nnheader-narrow-to-headers)
7824 (unless (setq ref (message-fetch-field "references"))
7825 (setq ref (message-fetch-field "in-reply-to")))
7828 ;; It's not the current article, so we take a bet on
7829 ;; the value we got from the server.
7830 (mail-header-references header)))
7832 (not (equal ref "")))
7833 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7834 (gnus-message 1 "Couldn't find parent"))
7835 (gnus-message 1 "No references in article %d"
7836 (gnus-summary-article-number))
7839 (gnus-summary-position-point)
7842 (defun gnus-summary-refer-references ()
7843 "Fetch all articles mentioned in the References header.
7844 Return the number of articles fetched."
7846 (let ((ref (mail-header-references (gnus-summary-article-header)))
7847 (current (gnus-summary-article-number))
7851 (error "No References in the current article")
7852 ;; For each Message-ID in the References header...
7853 (while (string-match "<[^>]*>" ref)
7855 ;; ... fetch that article.
7856 (gnus-summary-refer-article
7857 (prog1 (match-string 0 ref)
7858 (setq ref (substring ref (match-end 0))))))
7859 (gnus-summary-goto-subject current)
7860 (gnus-summary-position-point)
7863 (defun gnus-summary-refer-thread (&optional limit)
7864 "Fetch all articles in the current thread.
7865 If LIMIT (the numerical prefix), fetch that many old headers instead
7866 of what's specified by the `gnus-refer-thread-limit' variable."
7868 (let ((id (mail-header-id (gnus-summary-article-header)))
7869 (limit (if limit (prefix-numeric-value limit)
7870 gnus-refer-thread-limit)))
7871 ;; We want to fetch LIMIT *old* headers, but we also have to
7872 ;; re-fetch all the headers in the current buffer, because many of
7873 ;; them may be undisplayed. So we adjust LIMIT.
7874 (when (numberp limit)
7875 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7876 (unless (eq gnus-fetch-old-headers 'invisible)
7877 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7878 ;; Retrieve the headers and read them in.
7879 (if (eq (gnus-retrieve-headers
7880 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7882 (gnus-build-all-threads)
7883 (error "Can't fetch thread from backends that don't support NOV"))
7884 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7885 (gnus-summary-limit-include-thread id)))
7887 (defun gnus-summary-refer-article (message-id)
7888 "Fetch an article specified by MESSAGE-ID."
7889 (interactive "sMessage-ID: ")
7890 (when (and (stringp message-id)
7891 (not (zerop (length message-id))))
7892 ;; Construct the correct Message-ID if necessary.
7893 ;; Suggested by tale@pawl.rpi.edu.
7894 (unless (string-match "^<" message-id)
7895 (setq message-id (concat "<" message-id)))
7896 (unless (string-match ">$" message-id)
7897 (setq message-id (concat message-id ">")))
7898 (let* ((header (gnus-id-to-header message-id))
7900 (gnus-summary-article-sparse-p
7901 (mail-header-number header))
7902 (memq (mail-header-number header)
7903 gnus-newsgroup-limit)))
7906 ;; If the article is present in the buffer we just go to it.
7908 (or (not (gnus-summary-article-sparse-p
7909 (mail-header-number header)))
7912 (gnus-summary-goto-article
7913 (mail-header-number header) nil t)
7915 (gnus-summary-update-article (mail-header-number header)))))
7917 ;; We fetch the article.
7919 (dolist (gnus-override-method (gnus-refer-article-methods))
7920 (gnus-check-server gnus-override-method)
7921 ;; Fetch the header, and display the article.
7922 (when (setq number (gnus-summary-insert-subject message-id))
7923 (gnus-summary-select-article nil nil nil number)
7925 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7927 (defun gnus-refer-article-methods ()
7928 "Return a list of referable methods."
7930 ;; No method, so we default to current and native.
7931 ((null gnus-refer-article-method)
7932 (list gnus-current-select-method gnus-select-method))
7934 ((eq 'current gnus-refer-article-method)
7935 (list gnus-current-select-method))
7936 ;; List of select methods.
7937 ((not (and (symbolp (car gnus-refer-article-method))
7938 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7940 (dolist (method gnus-refer-article-method)
7941 (push (if (eq 'current method)
7942 gnus-current-select-method
7946 ;; One single select method.
7948 (list gnus-refer-article-method))))
7950 (defun gnus-summary-edit-parameters ()
7951 "Edit the group parameters of the current group."
7953 (gnus-group-edit-group gnus-newsgroup-name 'params))
7955 (defun gnus-summary-customize-parameters ()
7956 "Customize the group parameters of the current group."
7958 (gnus-group-customize gnus-newsgroup-name))
7960 (defun gnus-summary-enter-digest-group (&optional force)
7961 "Enter an nndoc group based on the current article.
7962 If FORCE, force a digest interpretation. If not, try
7963 to guess what the document format is."
7965 (let ((conf gnus-current-window-configuration))
7967 (gnus-summary-select-article))
7968 (setq gnus-current-window-configuration conf)
7969 (let* ((name (format "%s-%d"
7970 (gnus-group-prefixed-name
7971 gnus-newsgroup-name (list 'nndoc ""))
7973 (set-buffer gnus-summary-buffer)
7974 gnus-current-article)))
7975 (ogroup gnus-newsgroup-name)
7976 (params (append (gnus-info-params (gnus-get-info ogroup))
7977 (list (cons 'to-group ogroup))
7978 (list (cons 'save-article-group ogroup))))
7979 (case-fold-search t)
7980 (buf (current-buffer))
7983 (set-buffer gnus-original-article-buffer)
7984 ;; Have the digest group inherit the main mail address of
7985 ;; the parent article.
7986 (when (setq to-address (or (gnus-fetch-field "reply-to")
7987 (gnus-fetch-field "from")))
7988 (setq params (append
7989 (list (cons 'to-address
7990 (funcall gnus-decode-encoded-word-function
7992 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7993 (insert-buffer-substring gnus-original-article-buffer)
7994 ;; Remove lines that may lead nndoc to misinterpret the
7997 (goto-char (point-min))
7998 (or (search-forward "\n\n" nil t) (point)))
7999 (goto-char (point-min))
8000 (delete-matching-lines "^Path:\\|^From ")
8003 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
8004 (gnus-newsgroup-ephemeral-ignored-charsets
8005 gnus-newsgroup-ignored-charsets))
8006 (gnus-group-read-ephemeral-group
8007 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8009 ,(if force 'mbox 'guess)))
8011 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8013 ;; Make all postings to this group go to the parent group.
8014 (nconc (gnus-info-params (gnus-get-info name))
8016 ;; Couldn't select this doc group.
8017 (switch-to-buffer buf)
8018 (gnus-set-global-variables)
8019 (gnus-configure-windows 'summary)
8020 (gnus-message 3 "Article couldn't be entered?"))
8021 (kill-buffer dig)))))
8023 (defun gnus-summary-read-document (n)
8024 "Open a new group based on the current article(s).
8025 This will allow you to read digests and other similar
8026 documents as newsgroups.
8027 Obeys the standard process/prefix convention."
8029 (let* ((articles (gnus-summary-work-articles n))
8030 (ogroup gnus-newsgroup-name)
8031 (params (append (gnus-info-params (gnus-get-info ogroup))
8032 (list (cons 'to-group ogroup))))
8033 article group egroup groups vgroup)
8034 (while (setq article (pop articles))
8035 (setq group (format "%s-%d" gnus-newsgroup-name article))
8036 (gnus-summary-remove-process-mark article)
8037 (when (gnus-summary-display-article article)
8040 (insert-buffer-substring gnus-original-article-buffer)
8041 ;; Remove some headers that may lead nndoc to make
8043 (message-narrow-to-head)
8044 (goto-char (point-min))
8045 (delete-matching-lines "^\\(Path\\):\\|^From ")
8048 (gnus-group-read-ephemeral-group
8049 group `(nndoc ,group (nndoc-address ,(current-buffer))
8050 (nndoc-article-type guess))
8053 ;; Make all postings to this group go to the parent group.
8054 (nconc (gnus-info-params (gnus-get-info egroup))
8056 (push egroup groups))
8057 ;; Couldn't select this doc group.
8058 (gnus-error 3 "Article couldn't be entered"))))))
8059 ;; Now we have selected all the documents.
8062 (error "None of the articles could be interpreted as documents"))
8063 ((gnus-group-read-ephemeral-group
8064 (setq vgroup (format
8065 "nnvirtual:%s-%s" gnus-newsgroup-name
8066 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8067 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8069 (cons (current-buffer) 'summary)))
8071 (error "Couldn't select virtual nndoc group")))))
8073 (defun gnus-summary-isearch-article (&optional regexp-p)
8074 "Do incremental search forward on the current article.
8075 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8077 (let* ((gnus-inhibit-treatment t)
8078 (old (gnus-summary-select-article)))
8079 (gnus-configure-windows 'article)
8080 (gnus-eval-in-buffer-window gnus-article-buffer
8084 (gnus-article-show-all-headers))
8085 (goto-char (point-min))
8086 (isearch-forward regexp-p)))))
8088 (defun gnus-summary-search-article-forward (regexp &optional backward)
8089 "Search for an article containing REGEXP forward.
8090 If BACKWARD, search backward instead."
8093 (format "Search article %s (regexp%s): "
8094 (if current-prefix-arg "backward" "forward")
8095 (if gnus-last-search-regexp
8096 (concat ", default " gnus-last-search-regexp)
8098 current-prefix-arg))
8099 (if (string-equal regexp "")
8100 (setq regexp (or gnus-last-search-regexp ""))
8101 (setq gnus-last-search-regexp regexp)
8102 (setq gnus-article-before-search gnus-current-article))
8103 ;; Intentionally set gnus-last-article.
8104 (setq gnus-last-article gnus-article-before-search)
8105 (let ((gnus-last-article gnus-last-article))
8106 (if (gnus-summary-search-article regexp backward)
8107 (gnus-summary-show-thread)
8108 (error "Search failed: \"%s\"" regexp))))
8110 (defun gnus-summary-search-article-backward (regexp)
8111 "Search for an article containing REGEXP backward."
8114 (format "Search article backward (regexp%s): "
8115 (if gnus-last-search-regexp
8116 (concat ", default " gnus-last-search-regexp)
8118 (gnus-summary-search-article-forward regexp 'backward))
8121 (defmacro gnus-summary-search-article-position-point (regexp backward)
8122 "Dehighlight the last matched text and goto the beginning position."
8123 (` (if (and gnus-summary-search-article-matched-data
8124 (let ((text (caddr gnus-summary-search-article-matched-data))
8125 (inhibit-read-only t)
8128 (goto-char (car gnus-summary-search-article-matched-data))
8129 (cadr gnus-summary-search-article-matched-data))
8131 (string-match (, regexp) text)))
8132 (if (, backward) (beginning-of-line) (end-of-line))
8133 (goto-char (if (, backward) (point-max) (point-min))))))
8135 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8136 "Place point where X-Face image is displayed."
8137 (if (featurep 'xemacs)
8138 (` (let ((end (if (search-forward "\n\n" nil t)
8139 (goto-char (1- (point)))
8142 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8143 (unless (and (re-search-forward "^From:" end t)
8144 (setq extent (extent-at (point)))
8145 (extent-begin-glyph extent))
8146 (goto-char (, opoint)))))
8147 (` (let ((end (if (search-forward "\n\n" nil t)
8148 (goto-char (1- (point)))
8150 (start (or (search-backward "\n\n" nil t) (point-min))))
8152 (or (text-property-any start end 'x-face-image t);; x-face-e21
8153 (text-property-any start end 'x-face-mule-bitmap-image t)
8156 (defmacro gnus-summary-search-article-highlight-matched-text
8157 (backward treated x-face)
8158 "Highlight matched text in the function `gnus-summary-search-article'."
8159 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8160 (end (set-marker (make-marker) (match-end 0)))
8161 (inhibit-read-only t)
8165 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8167 (lambda (item) (setq items (delq item items)))
8168 '(gnus-treat-buttonize
8169 gnus-treat-fill-article
8170 gnus-treat-fill-long-lines
8171 gnus-treat-emphasize
8172 gnus-treat-highlight-headers
8173 gnus-treat-highlight-citation
8174 gnus-treat-highlight-signature
8175 gnus-treat-overstrike
8176 gnus-treat-display-xface
8177 gnus-treat-buttonize-head
8178 gnus-treat-decode-article-as-default-mime-charset))
8179 (static-if (featurep 'xemacs)
8181 (cons '(x-face-mule-delete-x-face-field
8184 (gnus-treat-display-xface
8185 (when (, x-face) gnus-treat-display-xface)))
8186 (gnus-article-prepare-mime-display)))
8187 (goto-char (if (, backward) start end))
8189 (gnus-summary-search-article-highlight-goto-x-face (point)))
8190 (setq gnus-summary-search-article-matched-data
8191 (list start end (buffer-substring start end)))
8192 (unless (eq start end);; matched text has been deleted. :-<
8193 (put-text-property start end 'face
8194 (or (find-face 'isearch)
8195 'secondary-selection))))))
8198 (defun gnus-summary-search-article (regexp &optional backward)
8199 "Search for an article containing REGEXP.
8200 Optional argument BACKWARD means do search for backward.
8201 `gnus-select-article-hook' is not called during the search."
8202 ;; We have to require this here to make sure that the following
8203 ;; dynamic binding isn't shadowed by autoloading.
8204 (require 'gnus-async)
8206 (let ((gnus-select-article-hook nil) ;Disable hook.
8207 (gnus-article-prepare-hook nil)
8208 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8209 (gnus-use-article-prefetch nil)
8210 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8211 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8212 (sum (current-buffer))
8215 (gnus-save-hidden-threads
8216 (static-if (featurep 'xemacs)
8217 (let ((gnus-inhibit-treatment t))
8218 (setq treated (eq 'old (gnus-summary-select-article)))
8220 (not (and (gnus-buffer-live-p gnus-article-buffer)
8221 (window-live-p (get-buffer-window
8222 gnus-article-buffer t)))))
8223 (gnus-summary-select-article nil t)
8224 (setq treated nil)))
8225 (let ((gnus-inhibit-treatment t)
8226 (x-face-mule-delete-x-face-field 'never))
8227 (setq treated (eq 'old (gnus-summary-select-article)))
8230 (and (gnus-buffer-live-p gnus-article-buffer)
8231 (window-live-p (get-buffer-window
8232 gnus-article-buffer t))
8233 (or (not (string-match "^\\^X-Face:" regexp))
8234 (with-current-buffer gnus-article-buffer
8235 gnus-summary-search-article-matched-data)))))
8236 (gnus-summary-select-article nil t)
8237 (setq treated nil))))
8238 (set-buffer gnus-article-buffer)
8242 (gnus-article-show-all-headers)
8243 (gnus-summary-search-article-position-point regexp backward))
8244 (goto-char (if backward (point-max) (point-min))))
8246 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8248 (re-search-backward regexp nil t)
8249 (re-search-forward regexp nil t))
8250 ;; We found the regexp.
8252 (gnus-summary-search-article-highlight-matched-text
8253 backward treated (string-match "^\\^X-Face:" regexp))
8256 (/ (- 2 (window-height
8257 (get-buffer-window gnus-article-buffer t)))
8260 (get-buffer-window (current-buffer))
8263 (setq point (point)))
8264 ;; We didn't find it, so we go to the next article.
8267 (while (eq found 'not)
8268 (if (not (if backward (gnus-summary-find-prev)
8269 (gnus-summary-find-next)))
8270 ;; No more articles.
8272 ;; Select the next article and adjust point.
8273 (unless (gnus-summary-article-sparse-p
8274 (gnus-summary-article-number))
8276 (let ((gnus-inhibit-treatment t))
8277 (gnus-summary-select-article))
8279 (set-buffer gnus-article-buffer)
8281 (goto-char (if backward (point-max) (point-min))))))))
8282 (gnus-message 7 ""))
8283 ;; Return whether we found the regexp.
8284 (when (eq found 'found)
8286 (gnus-summary-show-thread)
8287 (gnus-summary-goto-subject gnus-current-article)
8288 (gnus-summary-position-point)
8291 (defun gnus-find-matching-articles (header regexp)
8292 "Return a list of all articles that match REGEXP on HEADER.
8293 This search includes all articles in the current group that Gnus has
8294 fetched headers for, whether they are displayed or not."
8295 (let ((articles nil)
8296 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8297 (case-fold-search t))
8298 (dolist (header gnus-newsgroup-headers)
8299 (when (string-match regexp (funcall func header))
8300 (push (mail-header-number header) articles)))
8301 (nreverse articles)))
8303 (defun gnus-summary-find-matching (header regexp &optional backward unread
8304 not-case-fold not-matching)
8305 "Return a list of all articles that match REGEXP on HEADER.
8306 The search stars on the current article and goes forwards unless
8307 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8308 If UNREAD is non-nil, only unread articles will
8309 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8310 in the comparisons. If NOT-MATCHING, return a list of all articles that
8311 not match REGEXP on HEADER."
8312 (let ((case-fold-search (not not-case-fold))
8315 (if (eq (car header) 'extra)
8318 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8320 (error "%s is an invalid header" header))
8321 (unless (fboundp (intern (concat "mail-header-" header)))
8322 (error "%s is not a valid header" header))
8323 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8324 (dolist (d (if (eq backward 'all)
8326 (gnus-data-find-list
8327 (gnus-summary-article-number)
8328 (gnus-data-list backward))))
8329 (when (and (or (not unread) ; We want all articles...
8330 (gnus-data-unread-p d)) ; Or just unreads.
8331 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8335 (funcall func (gnus-data-header d))))
8336 (string-match regexp
8337 (funcall func (gnus-data-header d)))))
8338 (push (gnus-data-number d) articles))) ; Success!
8339 (nreverse articles)))
8341 (defun gnus-summary-execute-command (header regexp command &optional backward)
8342 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8343 If HEADER is an empty string (or nil), the match is done on the entire
8344 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8346 (list (let ((completion-ignore-case t))
8349 (mapcar (lambda (header) (list (format "%s" header)))
8351 '("Number" "Subject" "From" "Lines" "Date"
8352 "Message-ID" "Xref" "References" "Body")
8353 gnus-extra-headers))
8354 nil 'require-match))
8355 (read-string "Regexp: ")
8356 (read-key-sequence "Command: ")
8357 current-prefix-arg))
8358 (when (equal header "Body")
8360 ;; Hidden thread subtrees must be searched as well.
8361 (gnus-summary-show-all-threads)
8362 ;; We don't want to change current point nor window configuration.
8364 (save-window-excursion
8366 gnus-treat-strip-trailing-blank-lines
8367 gnus-treat-strip-leading-blank-lines
8368 gnus-treat-strip-multiple-blank-lines
8369 gnus-treat-hide-boring-headers
8370 gnus-treat-fold-newsgroups
8371 gnus-article-prepare-hook)
8372 (gnus-message 6 "Executing %s..." (key-description command))
8373 ;; We'd like to execute COMMAND interactively so as to give arguments.
8374 (gnus-execute header regexp
8375 `(call-interactively ',(key-binding command))
8377 (gnus-message 6 "Executing %s...done" (key-description command))))))
8379 (defun gnus-summary-beginning-of-article ()
8380 "Scroll the article back to the beginning."
8382 (gnus-summary-select-article)
8383 (gnus-configure-windows 'article)
8384 (gnus-eval-in-buffer-window gnus-article-buffer
8386 (goto-char (point-min))
8387 (when gnus-page-broken
8388 (gnus-narrow-to-page))))
8390 (defun gnus-summary-end-of-article ()
8391 "Scroll to the end of the article."
8393 (gnus-summary-select-article)
8394 (gnus-configure-windows 'article)
8395 (gnus-eval-in-buffer-window gnus-article-buffer
8397 (goto-char (point-max))
8399 (when gnus-page-broken
8400 (gnus-narrow-to-page))))
8402 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8403 "Truncate to LEN and quote all \"(\"'s in STRING."
8404 (gnus-replace-in-string (if (and len (> (length string) len))
8405 (substring string 0 len)
8409 (defun gnus-summary-print-article (&optional filename n)
8410 "Generate and print a PostScript image of the N next (mail) articles.
8412 If N is negative, print the N previous articles. If N is nil and articles
8413 have been marked with the process mark, print these instead.
8415 If the optional first argument FILENAME is nil, send the image to the
8416 printer. If FILENAME is a string, save the PostScript image in a file with
8417 that name. If FILENAME is a number, prompt the user for the name of the file
8419 (interactive (list (ps-print-preprint current-prefix-arg)))
8420 (dolist (article (gnus-summary-work-articles n))
8421 (gnus-summary-select-article nil nil 'pseudo article)
8422 (gnus-eval-in-buffer-window gnus-article-buffer
8423 (gnus-print-buffer))
8424 (gnus-summary-remove-process-mark article))
8425 (ps-despool filename))
8427 (defun gnus-print-buffer ()
8428 (let ((buffer (generate-new-buffer " *print*")))
8431 (copy-to-buffer buffer (point-min) (point-max))
8433 (gnus-article-delete-invisible-text)
8434 (gnus-remove-text-with-property 'gnus-decoration)
8435 (when (gnus-visual-p 'article-highlight 'highlight)
8436 ;; Copy-to-buffer doesn't copy overlay. So redo
8438 (let ((gnus-article-buffer buffer))
8439 (gnus-article-highlight-citation t)
8440 (gnus-article-highlight-signature)))
8441 (let ((ps-left-header
8444 (gnus-summary-print-truncate-and-quote
8445 (mail-header-subject gnus-current-headers)
8448 (gnus-summary-print-truncate-and-quote
8449 (mail-header-from gnus-current-headers)
8453 "/pagenumberstring load"
8455 (mail-header-date gnus-current-headers) ")"))))
8456 (gnus-run-hooks 'gnus-ps-print-hook)
8459 (ps-spool-buffer-with-faces)
8460 (ps-spool-buffer)))))
8461 (kill-buffer buffer))))
8463 (defun gnus-summary-show-article (&optional arg)
8464 "Force redisplaying of the current article.
8465 If ARG (the prefix) is a number, show the article with the charset
8466 defined in `gnus-summary-show-article-charset-alist', or the charset
8468 If ARG (the prefix) is non-nil and not a number, show the raw article
8469 without any article massaging functions being run. Normally, the key strokes
8474 (gnus-summary-show-article t)
8475 (let* ((gnus-newsgroup-charset
8476 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8477 (mm-read-coding-system
8478 "View as charset: " ;; actually it is coding system.
8480 (set-buffer gnus-article-buffer)
8481 (mm-detect-coding-region (point) (point-max))))))
8482 (default-mime-charset gnus-newsgroup-charset)
8483 (gnus-newsgroup-ignored-charsets 'gnus-all))
8484 (gnus-summary-select-article nil 'force)
8485 (let ((deps gnus-newsgroup-dependencies)
8488 (set-buffer gnus-original-article-buffer)
8490 (message-narrow-to-head)
8491 (setq head (buffer-string))
8492 (goto-char (point-min))
8493 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8494 (goto-char (point-max))
8496 (setq lines (1- (count-lines (point) (point-max))))))
8498 (insert (format "211 %d Article retrieved.\n"
8499 (cdr gnus-article-current)))
8501 (if lines (insert (format "Lines: %d\n" lines)))
8503 (let ((nntp-server-buffer (current-buffer)))
8504 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8505 (gnus-data-set-header
8506 (gnus-data-find (cdr gnus-article-current))
8508 (gnus-summary-update-article-line
8509 (cdr gnus-article-current) header)
8510 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8511 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8513 ;; Select the article the normal way.
8514 (gnus-summary-select-article nil 'force))
8516 ;; We have to require this here to make sure that the following
8517 ;; dynamic binding isn't shadowed by autoloading.
8518 (require 'gnus-async)
8520 ;; Bind the article treatment functions to nil.
8521 (let ((gnus-have-all-headers t)
8522 gnus-article-prepare-hook
8523 gnus-article-decode-hook
8526 (gnus-inhibit-treatment t))
8527 (gnus-summary-select-article nil 'force))))
8528 (gnus-summary-goto-subject gnus-current-article)
8529 (gnus-summary-position-point))
8531 (defun gnus-summary-show-raw-article ()
8532 "Show the raw article without any article massaging functions being run."
8534 (gnus-summary-show-article t))
8536 (defun gnus-summary-verbose-headers (&optional arg)
8537 "Toggle permanent full header display.
8538 If ARG is a positive number, turn header display on.
8539 If ARG is a negative number, turn header display off."
8541 (setq gnus-show-all-headers
8542 (cond ((or (not (numberp arg))
8544 (not gnus-show-all-headers))
8547 (gnus-summary-show-article))
8549 (defun gnus-summary-toggle-header (&optional arg)
8550 "Show the headers if they are hidden, or hide them if they are shown.
8551 If ARG is a positive number, show the entire header.
8552 If ARG is a negative number, hide the unwanted header lines."
8554 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8555 (get-buffer-window gnus-article-buffer t))))
8556 (with-current-buffer gnus-article-buffer
8558 (article-narrow-to-head)
8559 (let* ((buffer-read-only nil)
8560 (inhibit-point-motion-hooks t)
8561 (hidden (if (numberp arg)
8563 (gnus-article-hidden-text-p 'headers)))
8565 (delete-region (point-min) (point-max))
8566 (with-current-buffer gnus-original-article-buffer
8567 (goto-char (setq s (point-min)))
8568 (setq e (if (search-forward "\n\n" nil t)
8571 (insert-buffer-substring gnus-original-article-buffer s e)
8572 (article-decode-encoded-words)
8574 (let ((gnus-treat-hide-headers nil)
8575 (gnus-treat-hide-boring-headers nil))
8576 (gnus-delete-wash-type 'headers)
8577 (gnus-treat-article 'head))
8578 (gnus-treat-article 'head))
8581 (set-window-start window (goto-char (point-min))))
8582 (setq gnus-page-broken
8583 (when gnus-break-pages
8584 (gnus-narrow-to-page)
8586 (gnus-set-mode-line 'article)))))
8588 (defun gnus-summary-show-all-headers ()
8589 "Make all header lines visible."
8591 (gnus-summary-toggle-header 1))
8593 (defun gnus-summary-toggle-mime (&optional arg)
8594 "Toggle MIME processing.
8595 If ARG is a positive number, turn MIME processing on."
8597 (setq gnus-show-mime
8599 (not gnus-show-mime)
8600 (> (prefix-numeric-value arg) 0)))
8601 (gnus-summary-select-article t 'force))
8603 (defun gnus-summary-caesar-message (&optional arg)
8604 "Caesar rotate the current article by 13.
8605 The numerical prefix specifies how many places to rotate each letter
8608 (gnus-summary-select-article)
8609 (let ((mail-header-separator ""))
8610 (gnus-eval-in-buffer-window gnus-article-buffer
8613 (let ((start (window-start))
8615 (message-caesar-buffer-body arg)
8616 (set-window-start (get-buffer-window (current-buffer)) start))))))
8618 (autoload 'unmorse-region "morse"
8619 "Convert morse coded text in region to ordinary ASCII text."
8622 (defun gnus-summary-morse-message (&optional arg)
8623 "Morse decode the current article."
8625 (gnus-summary-select-article)
8626 (let ((mail-header-separator ""))
8627 (gnus-eval-in-buffer-window gnus-article-buffer
8631 (let ((pos (window-start))
8633 (goto-char (point-min))
8634 (when (message-goto-body)
8635 (gnus-narrow-to-body))
8636 (goto-char (point-min))
8637 (while (re-search-forward "·" (point-max) t)
8638 (replace-match "."))
8639 (unmorse-region (point-min) (point-max))
8641 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8643 (defun gnus-summary-stop-page-breaking ()
8644 "Stop page breaking in the current article."
8646 (gnus-summary-select-article)
8647 (gnus-eval-in-buffer-window gnus-article-buffer
8649 (when (gnus-visual-p 'page-marker)
8650 (let ((buffer-read-only nil))
8651 (gnus-remove-text-with-property 'gnus-prev)
8652 (gnus-remove-text-with-property 'gnus-next))
8653 (setq gnus-page-broken nil))))
8655 (defun gnus-summary-move-article (&optional n to-newsgroup
8656 select-method action)
8657 "Move the current article to a different newsgroup.
8658 If N is a positive number, move the N next articles.
8659 If N is a negative number, move the N previous articles.
8660 If N is nil and any articles have been marked with the process mark,
8661 move those articles instead.
8662 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8663 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8664 re-spool using this method.
8666 When called interactively with TO-NEWSGROUP being nil, the value of
8667 the variable `gnus-move-split-methods' is used for finding a default
8668 for the target newsgroup.
8670 For this function to work, both the current newsgroup and the
8671 newsgroup that you want to move to have to support the `request-move'
8672 and `request-accept' functions.
8674 ACTION can be either `move' (the default), `crosspost' or `copy'."
8677 (setq action 'move))
8678 ;; Check whether the source group supports the required functions.
8679 (cond ((and (eq action 'move)
8680 (not (gnus-check-backend-function
8681 'request-move-article gnus-newsgroup-name)))
8682 (error "The current group does not support article moving"))
8683 ((and (eq action 'crosspost)
8684 (not (gnus-check-backend-function
8685 'request-replace-article gnus-newsgroup-name)))
8686 (error "The current group does not support article editing")))
8687 (let ((articles (gnus-summary-work-articles n))
8688 (prefix (if (gnus-check-backend-function
8689 'request-move-article gnus-newsgroup-name)
8690 (gnus-group-real-prefix gnus-newsgroup-name)
8692 (names '((move "Move" "Moving")
8693 (copy "Copy" "Copying")
8694 (crosspost "Crosspost" "Crossposting")))
8695 (copy-buf (save-excursion
8696 (nnheader-set-temp-buffer " *copy article*")))
8697 (default-marks gnus-article-mark-lists)
8698 (no-expire-marks (delete '(expirable . expire)
8699 (copy-sequence gnus-article-mark-lists)))
8700 art-group to-method new-xref article to-groups)
8701 (unless (assq action names)
8702 (error "Unknown action %s" action))
8703 ;; Read the newsgroup name.
8704 (when (and (not to-newsgroup)
8705 (not select-method))
8706 (if (and gnus-move-split-methods
8708 (and (memq gnus-current-article articles)
8709 (gnus-buffer-live-p gnus-original-article-buffer))))
8710 ;; When `gnus-move-split-methods' is non-nil, we have to
8711 ;; select an article to give `gnus-read-move-group-name' an
8712 ;; opportunity to suggest an appropriate default. However,
8713 ;; we needn't render or mark the article.
8714 (let ((gnus-display-mime-function nil)
8715 (gnus-article-prepare-hook nil)
8716 (gnus-mark-article-hook nil))
8717 (gnus-summary-select-article nil nil nil (car articles))))
8719 (gnus-read-move-group-name
8720 (cadr (assq action names))
8721 (symbol-value (intern (format "gnus-current-%s-group" action)))
8723 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8724 (setq to-method (or select-method
8725 (gnus-server-to-method
8726 (gnus-group-method to-newsgroup))))
8727 ;; Check the method we are to move this article to...
8728 (unless (gnus-check-backend-function
8729 'request-accept-article (car to-method))
8730 (error "%s does not support article copying" (car to-method)))
8731 (unless (gnus-check-server to-method)
8732 (error "Can't open server %s" (car to-method)))
8733 (gnus-message 6 "%s to %s: %s..."
8734 (caddr (assq action names))
8735 (or (car select-method) to-newsgroup) articles)
8737 (setq article (pop articles))
8741 ;; Move the article.
8743 ;; Remove this article from future suppression.
8744 (gnus-dup-unsuppress-article article)
8745 (gnus-request-move-article
8746 article ; Article to move
8747 gnus-newsgroup-name ; From newsgroup
8748 (nth 1 (gnus-find-method-for-group
8749 gnus-newsgroup-name)) ; Server
8750 (list 'gnus-request-accept-article
8751 to-newsgroup (list 'quote select-method)
8752 (not articles) t) ; Accept form
8753 (not articles))) ; Only save nov last time
8754 ;; Copy the article.
8757 (set-buffer copy-buf)
8758 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8759 (gnus-request-accept-article
8760 to-newsgroup select-method (not articles) t))))
8761 ;; Crosspost the article.
8762 ((eq action 'crosspost)
8763 (let ((xref (message-tokenize-header
8764 (mail-header-xref (gnus-summary-article-header article))
8766 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8767 ":" (number-to-string article)))
8769 (setq xref (list (system-name))))
8772 (mapconcat 'identity
8773 (delete "Xref:" (delete new-xref xref))
8777 (set-buffer copy-buf)
8778 ;; First put the article in the destination group.
8779 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8780 (when (consp (setq art-group
8781 (gnus-request-accept-article
8782 to-newsgroup select-method (not articles))))
8783 (setq new-xref (concat new-xref " " (car art-group)
8785 (number-to-string (cdr art-group))))
8786 ;; Now we have the new Xrefs header, so we insert
8787 ;; it and replace the new article.
8788 (nnheader-replace-header "Xref" new-xref)
8789 (gnus-request-replace-article
8790 (cdr art-group) to-newsgroup (current-buffer))
8794 (gnus-message 1 "Couldn't %s article %s: %s"
8795 (cadr (assq action names)) article
8796 (nnheader-get-report (car to-method))))
8797 ((eq art-group 'junk)
8798 (when (eq action 'move)
8799 (gnus-summary-mark-article article gnus-canceled-mark)
8800 (gnus-message 4 "Deleted article %s" article)))
8802 (let* ((pto-group (gnus-group-prefixed-name
8803 (car art-group) to-method))
8805 (gnus-gethash pto-group gnus-newsrc-hashtb))
8806 (info (nth 2 entry))
8807 (to-group (gnus-info-group info))
8809 ;; Update the group that has been moved to.
8811 (memq action '(move copy)))
8812 (unless (member to-group to-groups)
8813 (push to-group to-groups))
8815 (unless (memq article gnus-newsgroup-unreads)
8816 (push 'read to-marks)
8818 info (gnus-add-to-range (gnus-info-read info)
8819 (list (cdr art-group)))))
8821 ;; See whether the article is to be put in the cache.
8822 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8825 (to-article (cdr art-group)))
8827 ;; Enter the article into the cache in the new group,
8828 ;; if that is required.
8829 (when gnus-use-cache
8830 (gnus-cache-possibly-enter-article
8832 (let ((header (copy-sequence
8833 (gnus-summary-article-header article))))
8834 (mail-header-set-number header to-article)
8836 (memq article gnus-newsgroup-marked)
8837 (memq article gnus-newsgroup-dormant)
8838 (memq article gnus-newsgroup-unreads)))
8840 (when gnus-preserve-marks
8841 ;; Copy any marks over to the new group.
8842 (when (and (equal to-group gnus-newsgroup-name)
8843 (not (memq article gnus-newsgroup-unreads)))
8844 ;; Mark this article as read in this group.
8845 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8846 (setcdr (gnus-active to-group) to-article)
8847 (setcdr gnus-newsgroup-active to-article))
8850 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8851 (when (memq article (symbol-value
8852 (intern (format "gnus-newsgroup-%s"
8854 (push (cdar marks) to-marks)
8855 ;; If the other group is the same as this group,
8856 ;; then we have to add the mark to the list.
8857 (when (equal to-group gnus-newsgroup-name)
8858 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8861 (intern (format "gnus-newsgroup-%s"
8863 ;; Copy the marks to other group.
8864 (gnus-add-marked-articles
8865 to-group (cdar marks) (list to-article) info)))
8866 (setq marks (cdr marks)))
8868 (gnus-request-set-mark
8869 to-group (list (list (list to-article) 'add to-marks))))
8872 (concat "(gnus-group-set-info '"
8873 (gnus-prin1-to-string (gnus-get-info to-group))
8876 ;; Update the Xref header in this article to point to
8877 ;; the new crossposted article we have just created.
8878 (when (eq action 'crosspost)
8880 (set-buffer copy-buf)
8881 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8882 (nnheader-replace-header "Xref" new-xref)
8883 (gnus-request-replace-article
8884 article gnus-newsgroup-name (current-buffer)))))
8886 ;;;!!!Why is this necessary?
8887 (set-buffer gnus-summary-buffer)
8889 (gnus-summary-goto-subject article)
8890 (when (eq action 'move)
8891 (gnus-summary-mark-article article gnus-canceled-mark))))
8892 (gnus-summary-remove-process-mark article))
8893 ;; Re-activate all groups that have been moved to.
8895 (set-buffer gnus-group-buffer)
8896 (let ((gnus-group-marked to-groups))
8897 (gnus-group-get-new-news-this-group nil t)))
8899 (gnus-kill-buffer copy-buf)
8900 (gnus-summary-position-point)
8901 (gnus-set-mode-line 'summary)))
8903 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8904 "Move the current article to a different newsgroup.
8905 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8906 When called interactively, if TO-NEWSGROUP is nil, use the value of
8907 the variable `gnus-move-split-methods' for finding a default target
8909 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8910 re-spool using this method."
8912 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8914 (defun gnus-summary-crosspost-article (&optional n)
8915 "Crosspost the current article to some other group."
8917 (gnus-summary-move-article n nil nil 'crosspost))
8919 (defcustom gnus-summary-respool-default-method nil
8920 "Default method type for respooling an article.
8921 If nil, use to the current newsgroup method."
8923 :group 'gnus-summary-mail)
8925 (defun gnus-summary-respool-article (&optional n method)
8926 "Respool the current article.
8927 The article will be squeezed through the mail spooling process again,
8928 which means that it will be put in some mail newsgroup or other
8929 depending on `nnmail-split-methods'.
8930 If N is a positive number, respool the N next articles.
8931 If N is a negative number, respool the N previous articles.
8932 If N is nil and any articles have been marked with the process mark,
8933 respool those articles instead.
8935 Respooling can be done both from mail groups and \"real\" newsgroups.
8936 In the former case, the articles in question will be moved from the
8937 current group into whatever groups they are destined to. In the
8938 latter case, they will be copied into the relevant groups."
8940 (list current-prefix-arg
8941 (let* ((methods (gnus-methods-using 'respool))
8943 (symbol-name (or gnus-summary-respool-default-method
8944 (car (gnus-find-method-for-group
8945 gnus-newsgroup-name)))))
8947 (gnus-completing-read-with-default
8948 methname "What backend do you want to use when respooling?"
8949 methods nil t nil 'gnus-mail-method-history))
8952 ((zerop (length (setq ms (gnus-servers-using-backend
8954 (list (intern method) ""))
8958 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8959 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8962 (error "No method given for respooling"))
8963 (if (assoc (symbol-name
8964 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8965 (gnus-methods-using 'respool))
8966 (gnus-summary-move-article n nil method)
8967 (gnus-summary-copy-article n nil method)))
8969 (defun gnus-summary-import-article (file &optional edit)
8970 "Import an arbitrary file into a mail newsgroup."
8971 (interactive "fImport file: \nP")
8972 (let ((group gnus-newsgroup-name)
8973 (now (current-time))
8974 atts lines group-art)
8975 (unless (gnus-check-backend-function 'request-accept-article group)
8976 (error "%s does not support article importing" group))
8977 (or (file-readable-p file)
8978 (not (file-regular-p file))
8979 (error "Can't read %s" file))
8981 (set-buffer (gnus-get-buffer-create " *import file*"))
8983 (nnheader-insert-file-contents file)
8984 (goto-char (point-min))
8985 (if (nnheader-article-p)
8987 (goto-char (point-min))
8988 (search-forward "\n\n" nil t)
8989 (narrow-to-region (point-min) (1- (point)))
8990 (goto-char (point-min))
8991 (unless (re-search-forward "^date:" nil t)
8992 (goto-char (point-max))
8993 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8994 ;; This doesn't look like an article, so we fudge some headers.
8995 (setq atts (file-attributes file)
8996 lines (count-lines (point-min) (point-max)))
8997 (insert "From: " (read-string "From: ") "\n"
8998 "Subject: " (read-string "Subject: ") "\n"
8999 "Date: " (message-make-date (nth 5 atts)) "\n"
9000 "Message-ID: " (message-make-message-id) "\n"
9001 "Lines: " (int-to-string lines) "\n"
9002 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
9003 (setq group-art (gnus-request-accept-article group nil t))
9004 (kill-buffer (current-buffer)))
9005 (setq gnus-newsgroup-active (gnus-activate-group group))
9007 (gnus-summary-goto-article (cdr group-art) nil t)
9009 (gnus-summary-edit-article))))
9011 (defun gnus-summary-create-article ()
9012 "Create an article in a mail newsgroup."
9014 (let ((group gnus-newsgroup-name)
9015 (now (current-time))
9017 (unless (gnus-check-backend-function 'request-accept-article group)
9018 (error "%s does not support article importing" group))
9020 (set-buffer (gnus-get-buffer-create " *import file*"))
9022 (goto-char (point-min))
9023 ;; This doesn't look like an article, so we fudge some headers.
9024 (insert "From: " (read-string "From: ") "\n"
9025 "Subject: " (read-string "Subject: ") "\n"
9026 "Date: " (message-make-date now) "\n"
9027 "Message-ID: " (message-make-message-id) "\n")
9028 (setq group-art (gnus-request-accept-article group nil t))
9029 (kill-buffer (current-buffer)))
9030 (setq gnus-newsgroup-active (gnus-activate-group group))
9032 (gnus-summary-goto-article (cdr group-art) nil t)
9033 (gnus-summary-edit-article)))
9035 (defun gnus-summary-article-posted-p ()
9036 "Say whether the current (mail) article is available from news as well.
9037 This will be the case if the article has both been mailed and posted."
9039 (let ((id (mail-header-references (gnus-summary-article-header)))
9040 (gnus-override-method (car (gnus-refer-article-methods))))
9041 (if (gnus-request-head id "")
9042 (gnus-message 2 "The current message was found on %s"
9043 gnus-override-method)
9044 (gnus-message 2 "The current message couldn't be found on %s"
9045 gnus-override-method)
9048 (defun gnus-summary-expire-articles (&optional now)
9049 "Expire all articles that are marked as expirable in the current group."
9051 (when (gnus-check-backend-function
9052 'request-expire-articles gnus-newsgroup-name)
9053 ;; This backend supports expiry.
9054 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9055 (expirable (if total
9057 ;; We need to update the info for
9058 ;; this group for `gnus-list-of-read-articles'
9059 ;; to give us the right answer.
9060 (gnus-run-hooks 'gnus-exit-group-hook)
9061 (gnus-summary-update-info)
9062 (gnus-list-of-read-articles gnus-newsgroup-name))
9063 (setq gnus-newsgroup-expirable
9064 (sort gnus-newsgroup-expirable '<))))
9065 (expiry-wait (if now 'immediate
9066 (gnus-group-find-parameter
9067 gnus-newsgroup-name 'expiry-wait)))
9068 (nnmail-expiry-target
9069 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9070 nnmail-expiry-target))
9073 ;; There are expirable articles in this group, so we run them
9074 ;; through the expiry process.
9075 (gnus-message 6 "Expiring articles...")
9076 (unless (gnus-check-group gnus-newsgroup-name)
9077 (error "Can't open server for %s" gnus-newsgroup-name))
9078 ;; The list of articles that weren't expired is returned.
9081 (let ((nnmail-expiry-wait-function nil)
9082 (nnmail-expiry-wait expiry-wait))
9083 (setq es (gnus-request-expire-articles
9084 expirable gnus-newsgroup-name)))
9085 (setq es (gnus-request-expire-articles
9086 expirable gnus-newsgroup-name)))
9088 (setq gnus-newsgroup-expirable es))
9089 ;; We go through the old list of expirable, and mark all
9090 ;; really expired articles as nonexistent.
9091 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9092 (let ((gnus-use-cache nil))
9093 (dolist (article expirable)
9094 (when (and (not (memq article es))
9095 (gnus-data-find article))
9096 (gnus-summary-mark-article article gnus-canceled-mark))))))
9097 (gnus-message 6 "Expiring articles...done")))))
9099 (defun gnus-summary-expire-articles-now ()
9100 "Expunge all expirable articles in the current group.
9101 This means that *all* articles that are marked as expirable will be
9102 deleted forever, right now."
9104 (or gnus-expert-user
9106 "Are you really, really, really sure you want to delete all these messages? ")
9108 (gnus-summary-expire-articles t))
9110 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9111 (defun gnus-summary-delete-article (&optional n)
9112 "Delete the N next (mail) articles.
9113 This command actually deletes articles. This is not a marking
9114 command. The article will disappear forever from your life, never to
9116 If N is negative, delete backwards.
9117 If N is nil and articles have been marked with the process mark,
9118 delete these instead."
9120 (unless (gnus-check-backend-function 'request-expire-articles
9121 gnus-newsgroup-name)
9122 (error "The current newsgroup does not support article deletion"))
9123 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9124 (error "Couldn't open server"))
9125 ;; Compute the list of articles to delete.
9126 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9127 (nnmail-expiry-target 'delete)
9129 (if (and gnus-novice-user
9130 (not (gnus-yes-or-no-p
9131 (format "Do you really want to delete %s forever? "
9132 (if (> (length articles) 1)
9133 (format "these %s articles" (length articles))
9136 ;; Delete the articles.
9137 (setq not-deleted (gnus-request-expire-articles
9138 articles gnus-newsgroup-name 'force))
9140 (gnus-summary-remove-process-mark (car articles))
9141 ;; The backend might not have been able to delete the article
9143 (unless (memq (car articles) not-deleted)
9144 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9145 (setq articles (cdr articles)))
9147 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9148 (gnus-summary-position-point)
9149 (gnus-set-mode-line 'summary)
9152 (defun gnus-summary-edit-article (&optional force)
9153 "Edit the current article.
9154 This will have permanent effect only in mail groups.
9155 If FORCE is non-nil, allow editing of articles even in read-only
9159 (set-buffer gnus-summary-buffer)
9160 (let ((mail-parse-charset gnus-newsgroup-charset)
9161 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9162 (gnus-set-global-variables)
9163 (when (and (not force)
9164 (gnus-group-read-only-p))
9165 (error "The current newsgroup does not support article editing"))
9166 (gnus-summary-show-article t)
9167 (gnus-article-edit-article
9169 `(lambda (no-highlight)
9170 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9171 (message-options message-options)
9172 (message-options-set-recipient)
9173 (mail-parse-ignored-charsets
9174 ',gnus-newsgroup-ignored-charsets))
9175 (gnus-summary-edit-article-done
9176 ,(or (mail-header-references gnus-current-headers) "")
9177 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9179 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9181 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9183 "Make edits to the current article permanent."
9186 ;; The buffer restriction contains the entire article if it exists.
9187 (when (article-goto-body)
9188 (let ((lines (count-lines (point) (point-max)))
9189 (length (- (point-max) (point)))
9190 (case-fold-search t)
9191 (body (copy-marker (point))))
9192 (goto-char (point-min))
9193 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9194 (delete-region (match-beginning 1) (match-end 1))
9195 (insert (number-to-string length)))
9196 (goto-char (point-min))
9197 (when (re-search-forward
9198 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9199 (delete-region (match-beginning 1) (match-end 1))
9200 (insert (number-to-string length)))
9201 (goto-char (point-min))
9202 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9203 (delete-region (match-beginning 1) (match-end 1))
9204 (insert (number-to-string lines))))))
9205 ;; Replace the article.
9206 (let ((buf (current-buffer)))
9208 (insert-buffer-substring buf)
9210 (if (and (not read-only)
9211 (not (gnus-request-replace-article
9212 (cdr gnus-article-current) (car gnus-article-current)
9213 (current-buffer) t)))
9214 (error "Couldn't replace article")
9215 ;; Update the summary buffer.
9217 (equal (message-tokenize-header references " ")
9218 (message-tokenize-header
9219 (or (message-fetch-field "references") "") " ")))
9220 ;; We only have to update this line.
9223 (message-narrow-to-head)
9224 (let ((head (buffer-string))
9227 (insert (format "211 %d Article retrieved.\n"
9228 (cdr gnus-article-current)))
9231 (let ((nntp-server-buffer (current-buffer)))
9232 (setq header (car (gnus-get-newsgroup-headers
9235 (set-buffer gnus-summary-buffer)
9236 (gnus-data-set-header
9237 (gnus-data-find (cdr gnus-article-current))
9239 (gnus-summary-update-article-line
9240 (cdr gnus-article-current) header)
9241 (if (gnus-summary-goto-subject
9242 (cdr gnus-article-current) nil t)
9243 (gnus-summary-update-secondary-mark
9244 (cdr gnus-article-current))))))))
9246 (set-buffer (or buffer gnus-summary-buffer))
9247 (gnus-summary-update-article (cdr gnus-article-current))
9248 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9249 (gnus-summary-update-secondary-mark
9250 (cdr gnus-article-current))))
9251 ;; Prettify the article buffer again.
9252 (unless no-highlight
9254 (set-buffer gnus-article-buffer)
9255 ;;;!!! Fix this -- article should be rehighlighted.
9256 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9257 (set-buffer gnus-original-article-buffer)
9258 (gnus-request-article
9259 (cdr gnus-article-current)
9260 (car gnus-article-current) (current-buffer))))
9261 ;; Prettify the summary buffer line.
9262 (when (gnus-visual-p 'summary-highlight 'highlight)
9263 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9265 (defun gnus-summary-edit-wash (key)
9266 "Perform editing command KEY in the article buffer."
9270 (message "%s" (concat (this-command-keys) "- "))
9273 (gnus-summary-edit-article)
9274 (execute-kbd-macro (concat (this-command-keys) key))
9275 (gnus-article-edit-done))
9279 (defun gnus-summary-respool-query (&optional silent trace)
9280 "Query where the respool algorithm would put this article."
9282 (let (gnus-mark-article-hook)
9283 (gnus-summary-select-article)
9285 (set-buffer gnus-original-article-buffer)
9287 (message-narrow-to-head)
9288 (let ((groups (nnmail-article-group 'identity trace)))
9291 (message "This message would go to %s"
9292 (mapconcat 'car groups ", "))
9293 (message "This message would go to no groups"))
9296 (defun gnus-summary-respool-trace ()
9297 "Trace where the respool algorithm would put this article.
9298 Display a buffer showing all fancy splitting patterns which matched."
9300 (gnus-summary-respool-query nil t))
9302 ;; Summary marking commands.
9304 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9305 "Mark articles which has the same subject as read, and then select the next.
9306 If UNMARK is positive, remove any kind of mark.
9307 If UNMARK is negative, tick articles."
9310 (setq unmark (prefix-numeric-value unmark)))
9312 (gnus-summary-mark-same-subject
9313 (gnus-summary-article-subject) unmark)))
9314 ;; Select next unread article. If auto-select-same mode, should
9315 ;; select the first unread article.
9316 (gnus-summary-next-article t (and gnus-auto-select-same
9317 (gnus-summary-article-subject)))
9318 (gnus-message 7 "%d article%s marked as %s"
9319 count (if (= count 1) " is" "s are")
9320 (if unmark "unread" "read"))))
9322 (defun gnus-summary-kill-same-subject (&optional unmark)
9323 "Mark articles which has the same subject as read.
9324 If UNMARK is positive, remove any kind of mark.
9325 If UNMARK is negative, tick articles."
9328 (setq unmark (prefix-numeric-value unmark)))
9330 (gnus-summary-mark-same-subject
9331 (gnus-summary-article-subject) unmark)))
9332 ;; If marked as read, go to next unread subject.
9334 ;; Go to next unread subject.
9335 (gnus-summary-next-subject 1 t))
9336 (gnus-message 7 "%d articles are marked as %s"
9337 count (if unmark "unread" "read"))))
9339 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9340 "Mark articles with same SUBJECT as read, and return marked number.
9341 If optional argument UNMARK is positive, remove any kinds of marks.
9342 If optional argument UNMARK is negative, mark articles as unread instead."
9346 ((null unmark) ; Mark as read.
9349 (gnus-summary-mark-article-as-read gnus-killed-mark)
9350 (gnus-summary-show-thread) t)
9351 (gnus-summary-find-subject subject))
9352 (setq count (1+ count))))
9353 ((> unmark 0) ; Tick.
9356 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9357 (gnus-summary-show-thread) t)
9358 (gnus-summary-find-subject subject))
9359 (setq count (1+ count))))
9360 (t ; Mark as unread.
9363 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9364 (gnus-summary-show-thread) t)
9365 (gnus-summary-find-subject subject))
9366 (setq count (1+ count)))))
9367 (gnus-set-mode-line 'summary)
9368 ;; Return the number of marked articles.
9371 (defun gnus-summary-mark-as-processable (n &optional unmark)
9372 "Set the process mark on the next N articles.
9373 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9374 the process mark instead. The difference between N and the actual
9375 number of articles marked is returned."
9377 (if (and (null n) (gnus-region-active-p))
9378 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9379 (setq n (prefix-numeric-value n))
9380 (let ((backward (< n 0))
9385 (gnus-summary-remove-process-mark
9386 (gnus-summary-article-number))
9387 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9388 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9391 (gnus-message 7 "No more articles"))
9392 (gnus-summary-recenter)
9393 (gnus-summary-position-point)
9396 (defun gnus-summary-unmark-as-processable (n)
9397 "Remove the process mark from the next N articles.
9398 If N is negative, unmark backward instead. The difference between N and
9399 the actual number of articles unmarked is returned."
9401 (gnus-summary-mark-as-processable n t))
9403 (defun gnus-summary-unmark-all-processable ()
9404 "Remove the process mark from all articles."
9407 (while gnus-newsgroup-processable
9408 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9409 (gnus-summary-position-point))
9411 (defun gnus-summary-add-mark (article type)
9412 "Mark ARTICLE with a mark of TYPE."
9413 (let ((vtype (car (assq type gnus-article-mark-lists)))
9416 (error "No such mark type: %s" type)
9417 (setq var (intern (format "gnus-newsgroup-%s" type)))
9418 (set var (cons article (symbol-value var)))
9419 (if (memq type '(processable cached replied forwarded recent saved))
9420 (gnus-summary-update-secondary-mark article)
9421 ;;; !!! This is bogus. We should find out what primary
9422 ;;; !!! mark we want to set.
9423 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9425 (defun gnus-summary-mark-as-expirable (n)
9426 "Mark N articles forward as expirable.
9427 If N is negative, mark backward instead. The difference between N and
9428 the actual number of articles marked is returned."
9430 (gnus-summary-mark-forward n gnus-expirable-mark))
9432 (defun gnus-summary-mark-as-spam (n)
9433 "Mark N articles forward as spam.
9434 If N is negative, mark backward instead. The difference between N and
9435 the actual number of articles marked is returned."
9437 (gnus-summary-mark-forward n gnus-spam-mark))
9439 (defun gnus-summary-mark-article-as-replied (article)
9440 "Mark ARTICLE as replied to and update the summary line.
9441 ARTICLE can also be a list of articles."
9442 (interactive (list (gnus-summary-article-number)))
9443 (let ((articles (if (listp article) article (list article))))
9444 (dolist (article articles)
9445 (push article gnus-newsgroup-replied)
9446 (let ((buffer-read-only nil))
9447 (when (gnus-summary-goto-subject article nil t)
9448 (gnus-summary-update-secondary-mark article))))))
9450 (defun gnus-summary-mark-article-as-forwarded (article)
9451 "Mark ARTICLE as forwarded and update the summary line.
9452 ARTICLE can also be a list of articles."
9453 (let ((articles (if (listp article) article (list article))))
9454 (dolist (article articles)
9455 (push article gnus-newsgroup-forwarded)
9456 (let ((buffer-read-only nil))
9457 (when (gnus-summary-goto-subject article nil t)
9458 (gnus-summary-update-secondary-mark article))))))
9460 (defun gnus-summary-set-bookmark (article)
9461 "Set a bookmark in current article."
9462 (interactive (list (gnus-summary-article-number)))
9463 (when (or (not (get-buffer gnus-article-buffer))
9464 (not gnus-current-article)
9465 (not gnus-article-current)
9466 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9467 (error "No current article selected"))
9468 ;; Remove old bookmark, if one exists.
9469 (let ((old (assq article gnus-newsgroup-bookmarks)))
9471 (setq gnus-newsgroup-bookmarks
9472 (delq old gnus-newsgroup-bookmarks))))
9473 ;; Set the new bookmark, which is on the form
9474 ;; (article-number . line-number-in-body).
9478 (set-buffer gnus-article-buffer)
9482 (goto-char (point-min))
9483 (search-forward "\n\n" nil t)
9486 gnus-newsgroup-bookmarks)
9487 (gnus-message 6 "A bookmark has been added to the current article."))
9489 (defun gnus-summary-remove-bookmark (article)
9490 "Remove the bookmark from the current article."
9491 (interactive (list (gnus-summary-article-number)))
9492 ;; Remove old bookmark, if one exists.
9493 (let ((old (assq article gnus-newsgroup-bookmarks)))
9496 (setq gnus-newsgroup-bookmarks
9497 (delq old gnus-newsgroup-bookmarks))
9498 (gnus-message 6 "Removed bookmark."))
9499 (gnus-message 6 "No bookmark in current article."))))
9501 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9502 (defun gnus-summary-mark-as-dormant (n)
9503 "Mark N articles forward as dormant.
9504 If N is negative, mark backward instead. The difference between N and
9505 the actual number of articles marked is returned."
9507 (gnus-summary-mark-forward n gnus-dormant-mark))
9509 (defun gnus-summary-set-process-mark (article)
9510 "Set the process mark on ARTICLE and update the summary line."
9511 (setq gnus-newsgroup-processable
9513 (delq article gnus-newsgroup-processable)))
9514 (when (gnus-summary-goto-subject article)
9515 (gnus-summary-show-thread)
9516 (gnus-summary-goto-subject article)
9517 (gnus-summary-update-secondary-mark article)))
9519 (defun gnus-summary-remove-process-mark (article)
9520 "Remove the process mark from ARTICLE and update the summary line."
9521 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9522 (when (gnus-summary-goto-subject article)
9523 (gnus-summary-show-thread)
9524 (gnus-summary-goto-subject article)
9525 (gnus-summary-update-secondary-mark article)))
9527 (defun gnus-summary-set-saved-mark (article)
9528 "Set the process mark on ARTICLE and update the summary line."
9529 (push article gnus-newsgroup-saved)
9530 (when (gnus-summary-goto-subject article)
9531 (gnus-summary-update-secondary-mark article)))
9533 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9534 "Mark N articles as read forwards.
9535 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9536 The difference between N and the actual number of articles marked is
9538 If NO-EXPIRE, auto-expiry will be inhibited."
9540 (gnus-summary-show-thread)
9541 (let ((backward (< n 0))
9542 (gnus-summary-goto-unread
9543 (and gnus-summary-goto-unread
9544 (not (eq gnus-summary-goto-unread 'never))
9545 (not (memq mark (list gnus-unread-mark
9546 gnus-ticked-mark gnus-dormant-mark)))))
9548 (mark (or mark gnus-del-mark)))
9550 (gnus-summary-mark-article nil mark no-expire)
9551 (zerop (gnus-summary-next-subject
9553 (and gnus-summary-goto-unread
9554 (not (eq gnus-summary-goto-unread 'never)))
9558 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9559 (gnus-summary-recenter)
9560 (gnus-summary-position-point)
9561 (gnus-set-mode-line 'summary)
9564 (defun gnus-summary-mark-article-as-read (mark)
9565 "Mark the current article quickly as read with MARK."
9566 (let ((article (gnus-summary-article-number)))
9567 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9568 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9569 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9570 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9571 (push (cons article mark) gnus-newsgroup-reads)
9572 ;; Possibly remove from cache, if that is used.
9573 (when gnus-use-cache
9574 (gnus-cache-enter-remove-article article))
9575 ;; Allow the backend to change the mark.
9576 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9577 ;; Check for auto-expiry.
9578 (when (and gnus-newsgroup-auto-expire
9579 (memq mark gnus-auto-expirable-marks))
9580 (setq mark gnus-expirable-mark)
9581 ;; Let the backend know about the mark change.
9582 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9583 (push article gnus-newsgroup-expirable))
9584 ;; Set the mark in the buffer.
9585 (gnus-summary-update-mark mark 'unread)
9588 (defun gnus-summary-mark-article-as-unread (mark)
9589 "Mark the current article quickly as unread with MARK."
9590 (let* ((article (gnus-summary-article-number))
9591 (old-mark (gnus-summary-article-mark article)))
9592 ;; Allow the backend to change the mark.
9593 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9594 (if (eq mark old-mark)
9598 (gnus-error 1 "Can't mark negative article numbers")
9600 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9601 (setq gnus-newsgroup-spam-marked
9602 (delq article gnus-newsgroup-spam-marked))
9603 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9604 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9605 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9606 (cond ((= mark gnus-ticked-mark)
9607 (setq gnus-newsgroup-marked
9608 (gnus-add-to-sorted-list gnus-newsgroup-marked
9610 ((= mark gnus-spam-mark)
9611 (setq gnus-newsgroup-spam-marked
9612 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9614 ((= mark gnus-dormant-mark)
9615 (setq gnus-newsgroup-dormant
9616 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9619 (setq gnus-newsgroup-unreads
9620 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9622 (gnus-pull article gnus-newsgroup-reads)
9624 ;; See whether the article is to be put in the cache.
9626 (vectorp (gnus-summary-article-header article))
9628 (gnus-cache-possibly-enter-article
9629 gnus-newsgroup-name article
9630 (gnus-summary-article-header article)
9631 (= mark gnus-ticked-mark)
9632 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9635 (gnus-summary-update-mark mark 'unread)
9638 (defun gnus-summary-mark-article (&optional article mark no-expire)
9639 "Mark ARTICLE with MARK. MARK can be any character.
9640 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9641 `??' (dormant) and `?E' (expirable).
9642 If MARK is nil, then the default character `?r' is used.
9643 If ARTICLE is nil, then the article on the current line will be
9645 If NO-EXPIRE, auto-expiry will be inhibited."
9646 ;; The mark might be a string.
9647 (when (stringp mark)
9648 (setq mark (aref mark 0)))
9649 ;; If no mark is given, then we check auto-expiring.
9651 (setq mark gnus-del-mark))
9652 (when (and (not no-expire)
9653 gnus-newsgroup-auto-expire
9654 (memq mark gnus-auto-expirable-marks))
9655 (setq mark gnus-expirable-mark))
9656 (let ((article (or article (gnus-summary-article-number)))
9657 (old-mark (gnus-summary-article-mark article)))
9658 ;; Allow the backend to change the mark.
9659 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9660 (if (eq mark old-mark)
9663 (error "No article on current line"))
9664 (if (not (if (or (= mark gnus-unread-mark)
9665 (= mark gnus-ticked-mark)
9666 (= mark gnus-spam-mark)
9667 (= mark gnus-dormant-mark))
9668 (gnus-mark-article-as-unread article mark)
9669 (gnus-mark-article-as-read article mark)))
9671 ;; See whether the article is to be put in the cache.
9673 (not (= mark gnus-canceled-mark))
9674 (vectorp (gnus-summary-article-header article))
9676 (gnus-cache-possibly-enter-article
9677 gnus-newsgroup-name article
9678 (gnus-summary-article-header article)
9679 (= mark gnus-ticked-mark)
9680 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9682 (when (gnus-summary-goto-subject article nil t)
9683 (let ((buffer-read-only nil))
9684 (gnus-summary-show-thread)
9686 (gnus-summary-update-mark mark 'unread)
9689 (defun gnus-summary-update-secondary-mark (article)
9690 "Update the secondary (read, process, cache) mark."
9691 (gnus-summary-update-mark
9692 (cond ((memq article gnus-newsgroup-processable)
9694 ((memq article gnus-newsgroup-cached)
9696 ((memq article gnus-newsgroup-replied)
9698 ((memq article gnus-newsgroup-forwarded)
9699 gnus-forwarded-mark)
9700 ((memq article gnus-newsgroup-saved)
9702 ((memq article gnus-newsgroup-recent)
9704 ((memq article gnus-newsgroup-unseen)
9708 (when (gnus-visual-p 'summary-highlight 'highlight)
9709 (gnus-run-hooks 'gnus-summary-update-hook))
9712 (defun gnus-summary-update-download-mark (article)
9713 "Update the secondary (read, process, cache) mark."
9714 (gnus-summary-update-mark
9715 (cond ((memq article gnus-newsgroup-undownloaded)
9716 gnus-undownloaded-mark)
9717 (gnus-newsgroup-agentized
9718 gnus-downloaded-mark)
9722 (gnus-summary-update-line t)
9725 (defun gnus-summary-update-mark (mark type)
9726 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9727 (buffer-read-only nil))
9728 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9730 (when (looking-at "\r")
9732 (when (<= (+ forward (point)) (point-max))
9733 ;; Go to the right position on the line.
9734 (goto-char (+ forward (point)))
9735 ;; Replace the old mark with the new mark.
9736 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9737 ;; Optionally update the marks by some user rule.
9738 (when (eq type 'unread)
9740 (gnus-data-find (gnus-summary-article-number)) mark)
9741 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9743 (defun gnus-mark-article-as-read (article &optional mark)
9744 "Enter ARTICLE in the pertinent lists and remove it from others."
9745 ;; Make the article expirable.
9746 (let ((mark (or mark gnus-del-mark)))
9747 (setq gnus-newsgroup-expirable
9748 (if (= mark gnus-expirable-mark)
9749 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9750 (delq article gnus-newsgroup-expirable)))
9751 ;; Remove from unread and marked lists.
9752 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9753 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9754 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9755 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9756 (push (cons article mark) gnus-newsgroup-reads)
9757 ;; Possibly remove from cache, if that is used.
9758 (when gnus-use-cache
9759 (gnus-cache-enter-remove-article article))
9762 (defun gnus-mark-article-as-unread (article &optional mark)
9763 "Enter ARTICLE in the pertinent lists and remove it from others."
9764 (let ((mark (or mark gnus-ticked-mark)))
9767 (gnus-error 1 "Can't mark negative article numbers")
9769 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9770 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9771 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9772 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9773 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9775 ;; Unsuppress duplicates?
9776 (when gnus-suppress-duplicates
9777 (gnus-dup-unsuppress-article article))
9779 (cond ((= mark gnus-ticked-mark)
9780 (setq gnus-newsgroup-marked
9781 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9782 ((= mark gnus-spam-mark)
9783 (setq gnus-newsgroup-spam-marked
9784 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9786 ((= mark gnus-dormant-mark)
9787 (setq gnus-newsgroup-dormant
9788 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9790 (setq gnus-newsgroup-unreads
9791 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9792 (gnus-pull article gnus-newsgroup-reads)
9795 (defalias 'gnus-summary-mark-as-unread-forward
9796 'gnus-summary-tick-article-forward)
9797 (make-obsolete 'gnus-summary-mark-as-unread-forward
9798 'gnus-summary-tick-article-forward)
9799 (defun gnus-summary-tick-article-forward (n)
9800 "Tick N articles forwards.
9801 If N is negative, tick backwards instead.
9802 The difference between N and the number of articles ticked is returned."
9804 (gnus-summary-mark-forward n gnus-ticked-mark))
9806 (defalias 'gnus-summary-mark-as-unread-backward
9807 'gnus-summary-tick-article-backward)
9808 (make-obsolete 'gnus-summary-mark-as-unread-backward
9809 'gnus-summary-tick-article-backward)
9810 (defun gnus-summary-tick-article-backward (n)
9811 "Tick N articles backwards.
9812 The difference between N and the number of articles ticked is returned."
9814 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9816 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9817 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9818 (defun gnus-summary-tick-article (&optional article clear-mark)
9819 "Mark current article as unread.
9820 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9821 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9823 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9826 (defun gnus-summary-mark-as-read-forward (n)
9827 "Mark N articles as read forwards.
9828 If N is negative, mark backwards instead.
9829 The difference between N and the actual number of articles marked is
9832 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9834 (defun gnus-summary-mark-as-read-backward (n)
9835 "Mark the N articles as read backwards.
9836 The difference between N and the actual number of articles marked is
9839 (gnus-summary-mark-forward
9840 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9842 (defun gnus-summary-mark-as-read (&optional article mark)
9843 "Mark current article as read.
9844 ARTICLE specifies the article to be marked as read.
9845 MARK specifies a string to be inserted at the beginning of the line."
9846 (gnus-summary-mark-article article mark))
9848 (defun gnus-summary-clear-mark-forward (n)
9849 "Clear marks from N articles forward.
9850 If N is negative, clear backward instead.
9851 The difference between N and the number of marks cleared is returned."
9853 (gnus-summary-mark-forward n gnus-unread-mark))
9855 (defun gnus-summary-clear-mark-backward (n)
9856 "Clear marks from N articles backward.
9857 The difference between N and the number of marks cleared is returned."
9859 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9861 (defun gnus-summary-mark-unread-as-read ()
9862 "Intended to be used by `gnus-summary-mark-article-hook'."
9863 (when (memq gnus-current-article gnus-newsgroup-unreads)
9864 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9866 (defun gnus-summary-mark-read-and-unread-as-read ()
9867 "Intended to be used by `gnus-summary-mark-article-hook'."
9868 (let ((mark (gnus-summary-article-mark)))
9869 (when (or (gnus-unread-mark-p mark)
9870 (gnus-read-mark-p mark))
9871 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9873 (defun gnus-summary-mark-unread-as-ticked ()
9874 "Intended to be used by `gnus-summary-mark-article-hook'."
9875 (when (memq gnus-current-article gnus-newsgroup-unreads)
9876 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9878 (defun gnus-summary-mark-region-as-read (point mark all)
9879 "Mark all unread articles between point and mark as read.
9880 If given a prefix, mark all articles between point and mark as read,
9881 even ticked and dormant ones."
9882 (interactive "r\nP")
9891 (memq (setq article (gnus-summary-article-number))
9892 gnus-newsgroup-unreads))
9893 (gnus-summary-mark-article article gnus-del-mark))
9895 (gnus-summary-find-next))))))
9897 (defun gnus-summary-mark-below (score mark)
9898 "Mark articles with score less than SCORE with MARK."
9899 (interactive "P\ncMark: ")
9900 (setq score (if score
9901 (prefix-numeric-value score)
9902 (or gnus-summary-default-score 0)))
9904 (set-buffer gnus-summary-buffer)
9905 (goto-char (point-min))
9908 (and (< (gnus-summary-article-score) score)
9909 (gnus-summary-mark-article nil mark))
9910 (gnus-summary-find-next)))))
9912 (defun gnus-summary-kill-below (&optional score)
9913 "Mark articles with score below SCORE as read."
9915 (gnus-summary-mark-below score gnus-killed-mark))
9917 (defun gnus-summary-clear-above (&optional score)
9918 "Clear all marks from articles with score above SCORE."
9920 (gnus-summary-mark-above score gnus-unread-mark))
9922 (defun gnus-summary-tick-above (&optional score)
9923 "Tick all articles with score above SCORE."
9925 (gnus-summary-mark-above score gnus-ticked-mark))
9927 (defun gnus-summary-mark-above (score mark)
9928 "Mark articles with score over SCORE with MARK."
9929 (interactive "P\ncMark: ")
9930 (setq score (if score
9931 (prefix-numeric-value score)
9932 (or gnus-summary-default-score 0)))
9934 (set-buffer gnus-summary-buffer)
9935 (goto-char (point-min))
9937 (when (> (gnus-summary-article-score) score)
9938 (gnus-summary-mark-article nil mark))
9940 (gnus-summary-find-next)))))
9942 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9943 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9944 (defun gnus-summary-limit-include-expunged (&optional no-error)
9945 "Display all the hidden articles that were expunged for low scores."
9947 (let ((buffer-read-only nil))
9948 (let ((scored gnus-newsgroup-scored)
9951 (unless (gnus-summary-article-header (caar scored))
9952 (and (setq h (gnus-number-to-header (caar scored)))
9953 (< (cdar scored) gnus-summary-expunge-below)
9955 (setq scored (cdr scored)))
9957 (when (not no-error)
9958 (error "No expunged articles hidden"))
9959 (goto-char (point-min))
9960 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9961 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9962 (mapcar (lambda (x) (push (mail-header-number x)
9963 gnus-newsgroup-limit))
9965 (gnus-summary-prepare-unthreaded (nreverse headers))
9966 (goto-char (point-min))
9967 (gnus-summary-position-point)
9970 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9971 "Mark all unread articles in this newsgroup as read.
9972 If prefix argument ALL is non-nil, ticked and dormant articles will
9973 also be marked as read.
9974 If QUIETLY is non-nil, no questions will be asked.
9975 If TO-HERE is non-nil, it should be a point in the buffer. All
9976 articles before (after, if REVERSE is set) this point will be marked as read.
9977 Note that this function will only catch up the unread article
9978 in the current summary buffer limitation.
9979 The number of articles marked as read is returned."
9984 (not gnus-interactive-catchup) ;Without confirmation?
9988 "Mark absolutely all articles as read? "
9989 "Mark all unread articles as read? ")))
9991 (not gnus-newsgroup-adaptive)
9992 (not gnus-newsgroup-auto-expire)
9993 (not gnus-suppress-duplicates)
9994 (or (not gnus-use-cache)
9995 (eq gnus-use-cache 'passive)))
9998 (setq gnus-newsgroup-marked nil
9999 gnus-newsgroup-spam-marked nil
10000 gnus-newsgroup-dormant nil))
10001 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
10002 ;; We actually mark all articles as canceled, which we
10003 ;; have to do when using auto-expiry or adaptive scoring.
10004 (gnus-summary-show-all-threads)
10005 (if (and to-here reverse)
10007 (goto-char to-here)
10009 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10010 (gnus-summary-find-next (not all) nil nil t))))
10011 (when (gnus-summary-first-subject (not all) t)
10013 (if to-here (< (point) to-here) t)
10014 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10015 (gnus-summary-find-next (not all) nil nil t)))))
10016 (gnus-set-mode-line 'summary))
10018 (gnus-summary-position-point)))
10020 (defun gnus-summary-catchup-to-here (&optional all)
10021 "Mark all unticked articles before the current one as read.
10022 If ALL is non-nil, also mark ticked and dormant articles as read."
10025 (gnus-save-hidden-threads
10026 (let ((beg (point)))
10027 ;; We check that there are unread articles.
10028 (when (or all (gnus-summary-find-prev))
10029 (gnus-summary-catchup all t beg)))))
10030 (gnus-summary-position-point))
10032 (defun gnus-summary-catchup-from-here (&optional all)
10033 "Mark all unticked articles after the current one as read.
10034 If ALL is non-nil, also mark ticked and dormant articles as read."
10037 (gnus-save-hidden-threads
10038 (let ((beg (point)))
10039 ;; We check that there are unread articles.
10040 (when (or all (gnus-summary-find-next))
10041 (gnus-summary-catchup all t beg nil t)))))
10042 (gnus-summary-position-point))
10044 (defun gnus-summary-catchup-all (&optional quietly)
10045 "Mark all articles in this newsgroup as read.
10046 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10047 instead, which marks only unread articles as read."
10049 (gnus-summary-catchup t quietly))
10051 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10052 "Mark all unread articles in this group as read, then exit.
10053 If prefix argument ALL is non-nil, all articles are marked as read.
10054 If QUIETLY is non-nil, no questions will be asked."
10056 (when (gnus-summary-catchup all quietly nil 'fast)
10057 ;; Select next newsgroup or exit.
10058 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10059 (eq gnus-auto-select-next 'quietly))
10060 (gnus-summary-next-group nil)
10061 (gnus-summary-exit))))
10063 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10064 "Mark all articles in this newsgroup as read, and then exit.
10065 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10066 instead, which marks only unread articles as read."
10068 (gnus-summary-catchup-and-exit t quietly))
10070 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10071 "Mark all articles in this group as read and select the next group.
10072 If given a prefix, mark all articles, unread as well as ticked, as
10076 (gnus-summary-catchup all))
10077 (gnus-summary-next-group))
10083 (defmacro gnus-with-article (article &rest forms)
10084 "Select ARTICLE and perform FORMS in the original article buffer.
10085 Then replace the article with the result."
10087 ;; We don't want the article to be marked as read.
10088 (let (gnus-mark-article-hook)
10089 (gnus-summary-select-article t t nil ,article))
10090 (set-buffer gnus-original-article-buffer)
10092 (if (not (gnus-check-backend-function
10093 'request-replace-article (car gnus-article-current)))
10094 (gnus-message 5 "Read-only group; not replacing")
10095 (unless (gnus-request-replace-article
10096 ,article (car gnus-article-current)
10097 (current-buffer) t)
10098 (error "Couldn't replace article")))
10099 ;; The cache and backlog have to be flushed somewhat.
10100 (when gnus-keep-backlog
10101 (gnus-backlog-remove-article
10102 (car gnus-article-current) (cdr gnus-article-current)))
10103 (when gnus-use-cache
10104 (gnus-cache-update-article
10105 (car gnus-article-current) (cdr gnus-article-current)))))
10107 (put 'gnus-with-article 'lisp-indent-function 1)
10108 (put 'gnus-with-article 'edebug-form-spec '(form body))
10110 ;; Thread-based commands.
10112 (defun gnus-summary-articles-in-thread (&optional article)
10113 "Return a list of all articles in the current thread.
10114 If ARTICLE is non-nil, return all articles in the thread that starts
10115 with that article."
10116 (let* ((article (or article (gnus-summary-article-number)))
10117 (data (gnus-data-find-list article))
10118 (top-level (gnus-data-level (car data)))
10120 (cond ((null gnus-thread-operation-ignore-subject)
10121 (gnus-simplify-subject-re
10122 (mail-header-subject (gnus-data-header (car data)))))
10123 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10124 (gnus-simplify-subject-fuzzy
10125 (mail-header-subject (gnus-data-header (car data)))))
10127 (end-point (save-excursion
10128 (if (gnus-summary-go-to-next-thread)
10129 (point) (point-max))))
10132 (< (gnus-data-pos (car data)) end-point))
10133 (when (or (not top-subject)
10134 (string= top-subject
10135 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10136 (gnus-simplify-subject-fuzzy
10137 (mail-header-subject
10138 (gnus-data-header (car data))))
10139 (gnus-simplify-subject-re
10140 (mail-header-subject
10141 (gnus-data-header (car data)))))))
10142 (push (gnus-data-number (car data)) articles))
10143 (unless (and (setq data (cdr data))
10144 (> (gnus-data-level (car data)) top-level))
10146 ;; Return the list of articles.
10147 (nreverse articles)))
10149 (defun gnus-summary-rethread-current ()
10150 "Rethread the thread the current article is part of."
10152 (let* ((gnus-show-threads t)
10153 (article (gnus-summary-article-number))
10154 (id (mail-header-id (gnus-summary-article-header)))
10155 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10157 (error "No article on the current line"))
10158 (gnus-rebuild-thread id)
10159 (gnus-summary-goto-subject article)))
10161 (defun gnus-summary-reparent-thread ()
10162 "Make the current article child of the marked (or previous) article.
10164 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10165 is non-nil or the Subject: of both articles are the same."
10167 (unless (not (gnus-group-read-only-p))
10168 (error "The current newsgroup does not support article editing"))
10169 (unless (<= (length gnus-newsgroup-processable) 1)
10170 (error "No more than one article may be marked"))
10171 (save-window-excursion
10172 (let ((gnus-article-buffer " *reparent*")
10173 (current-article (gnus-summary-article-number))
10174 ;; First grab the marked article, otherwise one line up.
10175 (parent-article (if (not (null gnus-newsgroup-processable))
10176 (car gnus-newsgroup-processable)
10178 (if (eq (forward-line -1) 0)
10179 (gnus-summary-article-number)
10180 (error "Beginning of summary buffer"))))))
10181 (unless (not (eq current-article parent-article))
10182 (error "An article may not be self-referential"))
10183 (let ((message-id (mail-header-id
10184 (gnus-summary-article-header parent-article))))
10185 (unless (and message-id (not (equal message-id "")))
10186 (error "No message-id in desired parent"))
10187 (gnus-with-article current-article
10189 (goto-char (point-min))
10190 (message-narrow-to-head)
10191 (if (re-search-forward "^References: " nil t)
10193 (re-search-forward "^[^ \t]" nil t)
10196 (insert " " message-id))
10197 (insert "References: " message-id "\n"))))
10198 (set-buffer gnus-summary-buffer)
10199 (gnus-summary-unmark-all-processable)
10200 (gnus-summary-update-article current-article)
10201 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10202 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10203 (gnus-summary-rethread-current)
10204 (gnus-message 3 "Article %d is now the child of article %d"
10205 current-article parent-article)))))
10207 (defun gnus-summary-toggle-threads (&optional arg)
10208 "Toggle showing conversation threads.
10209 If ARG is positive number, turn showing conversation threads on."
10211 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10212 (setq gnus-show-threads
10213 (if (null arg) (not gnus-show-threads)
10214 (> (prefix-numeric-value arg) 0)))
10215 (gnus-summary-prepare)
10216 (gnus-summary-goto-subject current)
10217 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10218 (gnus-summary-position-point)))
10220 (defun gnus-summary-show-all-threads ()
10221 "Show all threads."
10224 (let ((buffer-read-only nil))
10225 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10226 (gnus-summary-position-point))
10228 (defun gnus-summary-show-thread ()
10229 "Show thread subtrees.
10230 Returns nil if no thread was there to be shown."
10232 (let ((buffer-read-only nil)
10234 ;; first goto end then to beg, to have point at beg after let
10235 (end (progn (end-of-line) (point)))
10236 (beg (progn (beginning-of-line) (point))))
10238 ;; Any hidden lines here?
10239 (search-forward "\r" end t)
10240 (subst-char-in-region beg end ?\^M ?\n t)
10242 (gnus-summary-position-point))))
10244 (defun gnus-summary-maybe-hide-threads ()
10245 "If requested, hide the threads that should be hidden."
10246 (when (and gnus-show-threads
10247 gnus-thread-hide-subtree)
10248 (gnus-summary-hide-all-threads
10249 (if (or (consp gnus-thread-hide-subtree)
10250 (gnus-functionp gnus-thread-hide-subtree))
10251 (gnus-make-predicate gnus-thread-hide-subtree)
10254 ;;; Hiding predicates.
10256 (defun gnus-article-unread-p (header)
10257 (memq (mail-header-number header) gnus-newsgroup-unreads))
10259 (defun gnus-article-unseen-p (header)
10260 (memq (mail-header-number header) gnus-newsgroup-unseen))
10262 (defun gnus-map-articles (predicate articles)
10263 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10264 (apply 'gnus-or (mapcar predicate
10265 (mapcar 'gnus-summary-article-header articles))))
10267 (defun gnus-summary-hide-all-threads (&optional predicate)
10268 "Hide all thread subtrees.
10269 If PREDICATE is supplied, threads that satisfy this predicate
10270 will not be hidden."
10273 (goto-char (point-min))
10276 (when (or (not predicate)
10278 predicate (gnus-summary-article-children)))
10279 (gnus-summary-hide-thread))
10280 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10281 (gnus-summary-position-point))
10283 (defun gnus-summary-hide-thread ()
10284 "Hide thread subtrees.
10285 If PREDICATE is supplied, threads that satisfy this predicate
10286 will not be hidden.
10287 Returns nil if no threads were there to be hidden."
10289 (let ((buffer-read-only nil)
10291 (article (gnus-summary-article-number)))
10293 ;; Go forward until either the buffer ends or the subthread
10295 (when (and (not (eobp))
10296 (or (zerop (gnus-summary-next-thread 1 t))
10297 (goto-char (point-max))))
10299 (if (and (> (point) start)
10300 (search-backward "\n" start t))
10302 (subst-char-in-region start (point) ?\n ?\^M)
10303 (gnus-summary-goto-subject article))
10307 (defun gnus-summary-go-to-next-thread (&optional previous)
10308 "Go to the same level (or less) next thread.
10309 If PREVIOUS is non-nil, go to previous thread instead.
10310 Return the article number moved to, or nil if moving was impossible."
10311 (let ((level (gnus-summary-thread-level))
10312 (way (if previous -1 1))
10315 (while (and (not (eobp))
10316 (< level (gnus-summary-thread-level)))
10317 (forward-line way))
10324 (gnus-summary-article-number)
10325 (goto-char beg)))))
10327 (defun gnus-summary-next-thread (n &optional silent)
10328 "Go to the same level next N'th thread.
10329 If N is negative, search backward instead.
10330 Returns the difference between N and the number of skips actually
10333 If SILENT, don't output messages."
10335 (let ((backward (< n 0))
10337 (while (and (> n 0)
10338 (gnus-summary-go-to-next-thread backward))
10341 (gnus-summary-position-point))
10342 (when (and (not silent) (/= 0 n))
10343 (gnus-message 7 "No more threads"))
10346 (defun gnus-summary-prev-thread (n)
10347 "Go to the same level previous N'th thread.
10348 Returns the difference between N and the number of skips actually
10351 (gnus-summary-next-thread (- n)))
10353 (defun gnus-summary-go-down-thread ()
10354 "Go down one level in the current thread."
10355 (let ((children (gnus-summary-article-children)))
10357 (gnus-summary-goto-subject (car children)))))
10359 (defun gnus-summary-go-up-thread ()
10360 "Go up one level in the current thread."
10361 (let ((parent (gnus-summary-article-parent)))
10363 (gnus-summary-goto-subject parent))))
10365 (defun gnus-summary-down-thread (n)
10366 "Go down thread N steps.
10367 If N is negative, go up instead.
10368 Returns the difference between N and how many steps down that were
10373 (while (and (> n 0)
10374 (if up (gnus-summary-go-up-thread)
10375 (gnus-summary-go-down-thread)))
10377 (gnus-summary-position-point)
10379 (gnus-message 7 "Can't go further"))
10382 (defun gnus-summary-up-thread (n)
10383 "Go up thread N steps.
10384 If N is negative, go down instead.
10385 Returns the difference between N and how many steps down that were
10388 (gnus-summary-down-thread (- n)))
10390 (defun gnus-summary-top-thread ()
10391 "Go to the top of the thread."
10393 (while (gnus-summary-go-up-thread))
10394 (gnus-summary-article-number))
10396 (defun gnus-summary-kill-thread (&optional unmark)
10397 "Mark articles under current thread as read.
10398 If the prefix argument is positive, remove any kinds of marks.
10399 If the prefix argument is negative, tick articles instead."
10402 (setq unmark (prefix-numeric-value unmark)))
10403 (let ((articles (gnus-summary-articles-in-thread)))
10405 ;; Expand the thread.
10406 (gnus-summary-show-thread)
10407 ;; Mark all the articles.
10409 (gnus-summary-goto-subject (car articles))
10410 (cond ((null unmark)
10411 (gnus-summary-mark-article-as-read gnus-killed-mark))
10413 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10415 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10416 (setq articles (cdr articles))))
10417 ;; Hide killed subtrees.
10419 gnus-thread-hide-killed
10420 (gnus-summary-hide-thread))
10421 ;; If marked as read, go to next unread subject.
10422 (when (null unmark)
10423 ;; Go to next unread subject.
10424 (gnus-summary-next-subject 1 t)))
10425 (gnus-set-mode-line 'summary))
10427 ;; Summary sorting commands
10429 (defun gnus-summary-sort-by-number (&optional reverse)
10430 "Sort the summary buffer by article number.
10431 Argument REVERSE means reverse order."
10433 (gnus-summary-sort 'number reverse))
10435 (defun gnus-summary-sort-by-random (&optional reverse)
10436 "Randomize the order in the summary buffer.
10437 Argument REVERSE means to randomize in reverse order."
10439 (gnus-summary-sort 'random reverse))
10441 (defun gnus-summary-sort-by-author (&optional reverse)
10442 "Sort the summary buffer by author name alphabetically.
10443 If `case-fold-search' is non-nil, case of letters is ignored.
10444 Argument REVERSE means reverse order."
10446 (gnus-summary-sort 'author reverse))
10448 (defun gnus-summary-sort-by-subject (&optional reverse)
10449 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10450 If `case-fold-search' is non-nil, case of letters is ignored.
10451 Argument REVERSE means reverse order."
10453 (gnus-summary-sort 'subject reverse))
10455 (defun gnus-summary-sort-by-date (&optional reverse)
10456 "Sort the summary buffer by date.
10457 Argument REVERSE means reverse order."
10459 (gnus-summary-sort 'date reverse))
10461 (defun gnus-summary-sort-by-score (&optional reverse)
10462 "Sort the summary buffer by score.
10463 Argument REVERSE means reverse order."
10465 (gnus-summary-sort 'score reverse))
10467 (defun gnus-summary-sort-by-lines (&optional reverse)
10468 "Sort the summary buffer by the number of lines.
10469 Argument REVERSE means reverse order."
10471 (gnus-summary-sort 'lines reverse))
10473 (defun gnus-summary-sort-by-chars (&optional reverse)
10474 "Sort the summary buffer by article length.
10475 Argument REVERSE means reverse order."
10477 (gnus-summary-sort 'chars reverse))
10479 (defun gnus-summary-sort-by-original (&optional reverse)
10480 "Sort the summary buffer using the default sorting method.
10481 Argument REVERSE means reverse order."
10483 (let* ((buffer-read-only)
10484 (gnus-summary-prepare-hook nil))
10485 ;; We do the sorting by regenerating the threads.
10486 (gnus-summary-prepare)
10487 ;; Hide subthreads if needed.
10488 (gnus-summary-maybe-hide-threads)))
10490 (defun gnus-summary-sort (predicate reverse)
10491 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10492 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10493 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10494 (gnus-thread-sort-functions
10499 (gnus-sort-gathered-threads-function
10500 gnus-thread-sort-functions)
10501 (gnus-article-sort-functions
10505 (,article t2 t1))))
10507 (gnus-summary-prepare-hook nil))
10508 ;; We do the sorting by regenerating the threads.
10509 (gnus-summary-prepare)
10510 ;; Hide subthreads if needed.
10511 (gnus-summary-maybe-hide-threads)))
10513 ;; Summary saving commands.
10515 (defun gnus-summary-save-article (&optional n not-saved)
10516 "Save the current article using the default saver function.
10517 If N is a positive number, save the N next articles.
10518 If N is a negative number, save the N previous articles.
10519 If N is nil and any articles have been marked with the process mark,
10520 save those articles instead.
10521 The variable `gnus-default-article-saver' specifies the saver function."
10523 (let* ((articles (gnus-summary-work-articles n))
10524 (save-buffer (save-excursion
10525 (nnheader-set-temp-buffer " *Gnus Save*")))
10526 (num (length articles))
10528 (dolist (article articles)
10529 (setq header (gnus-summary-article-header article))
10530 (if (not (vectorp header))
10531 ;; This is a pseudo-article.
10532 (if (assq 'name header)
10533 (gnus-copy-file (cdr (assq 'name header)))
10534 (gnus-message 1 "Article %d is unsaveable" article))
10535 ;; This is a real article.
10536 (save-window-excursion
10537 (let ((gnus-display-mime-function nil)
10538 (gnus-article-prepare-hook nil))
10539 (gnus-summary-select-article t nil nil article)))
10541 (set-buffer save-buffer)
10543 (insert-buffer-substring gnus-original-article-buffer))
10544 (setq file (gnus-article-save save-buffer file num))
10545 (gnus-summary-remove-process-mark article)
10547 (gnus-summary-set-saved-mark article))))
10548 (gnus-kill-buffer save-buffer)
10549 (gnus-summary-position-point)
10550 (gnus-set-mode-line 'summary)
10553 (defun gnus-summary-pipe-output (&optional arg headers)
10554 "Pipe the current article to a subprocess.
10555 If N is a positive number, pipe the N next articles.
10556 If N is a negative number, pipe the N previous articles.
10557 If N is nil and any articles have been marked with the process mark,
10558 pipe those articles instead.
10559 If HEADERS (the symbolic prefix), include the headers, too."
10560 (interactive (gnus-interactive "P\ny"))
10561 (require 'gnus-art)
10562 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe)
10563 (gnus-save-all-headers (or headers gnus-save-all-headers)))
10564 (gnus-summary-save-article arg t))
10565 (let ((buffer (get-buffer "*Shell Command Output*")))
10567 (not (zerop (buffer-size buffer))))
10568 (gnus-configure-windows 'pipe))))
10570 (defun gnus-summary-save-article-mail (&optional arg)
10571 "Append the current article to an mail file.
10572 If N is a positive number, save the N next articles.
10573 If N is a negative number, save the N previous articles.
10574 If N is nil and any articles have been marked with the process mark,
10575 save those articles instead."
10577 (require 'gnus-art)
10578 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10579 (gnus-summary-save-article arg)))
10581 (defun gnus-summary-save-article-rmail (&optional arg)
10582 "Append the current article to an rmail file.
10583 If N is a positive number, save the N next articles.
10584 If N is a negative number, save the N previous articles.
10585 If N is nil and any articles have been marked with the process mark,
10586 save those articles instead."
10588 (require 'gnus-art)
10589 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10590 (gnus-summary-save-article arg)))
10592 (defun gnus-summary-save-article-file (&optional arg)
10593 "Append the current article to a file.
10594 If N is a positive number, save the N next articles.
10595 If N is a negative number, save the N previous articles.
10596 If N is nil and any articles have been marked with the process mark,
10597 save those articles instead."
10599 (require 'gnus-art)
10600 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10601 (gnus-summary-save-article arg)))
10603 (defun gnus-summary-write-article-file (&optional arg)
10604 "Write the current article to a file, deleting the previous file.
10605 If N is a positive number, save the N next articles.
10606 If N is a negative number, save the N previous articles.
10607 If N is nil and any articles have been marked with the process mark,
10608 save those articles instead."
10610 (require 'gnus-art)
10611 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10612 (gnus-summary-save-article arg)))
10614 (defun gnus-summary-save-article-body-file (&optional arg)
10615 "Append the current article body to a file.
10616 If N is a positive number, save the N next articles.
10617 If N is a negative number, save the N previous articles.
10618 If N is nil and any articles have been marked with the process mark,
10619 save those articles instead."
10621 (require 'gnus-art)
10622 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10623 (gnus-summary-save-article arg)))
10625 (defun gnus-summary-muttprint (&optional arg)
10626 "Print the current article using Muttprint.
10627 If N is a positive number, save the N next articles.
10628 If N is a negative number, save the N previous articles.
10629 If N is nil and any articles have been marked with the process mark,
10630 save those articles instead."
10632 (require 'gnus-art)
10633 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10634 (gnus-summary-save-article arg t)))
10636 (defun gnus-summary-pipe-message (program)
10637 "Pipe the current article through PROGRAM."
10638 (interactive "sProgram: ")
10639 (gnus-summary-select-article)
10640 (let ((mail-header-separator ""))
10641 (gnus-eval-in-buffer-window gnus-article-buffer
10644 (let ((start (window-start))
10646 (message-pipe-buffer-body program)
10647 (set-window-start (get-buffer-window (current-buffer)) start))))))
10649 (defun gnus-get-split-value (methods)
10650 "Return a value based on the split METHODS."
10651 (let (split-name method result match)
10654 (set-buffer gnus-original-article-buffer)
10656 (nnheader-narrow-to-headers)
10657 (while (and methods (not split-name))
10658 (goto-char (point-min))
10659 (setq method (pop methods))
10660 (setq match (car method))
10663 ;; Regular expression.
10665 (re-search-forward match nil t)))
10666 ((gnus-functionp match)
10670 (setq result (funcall match gnus-newsgroup-name))))
10675 (setq result (eval match)))))
10676 (setq split-name (cdr method))
10677 (cond ((stringp result)
10678 (push (expand-file-name
10679 result gnus-article-save-directory)
10682 (setq split-name (append result split-name)))))))))
10683 (nreverse split-name)))
10685 (defun gnus-valid-move-group-p (group)
10686 (and (boundp group)
10687 (symbol-name group)
10688 (symbol-value group)
10689 (gnus-get-function (gnus-find-method-for-group
10690 (symbol-name group)) 'request-accept-article t)))
10692 (defun gnus-read-move-group-name (prompt default articles prefix)
10693 "Read a group name."
10694 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10695 (minibuffer-confirm-incomplete nil) ; XEmacs
10697 (format "%s %s to:"
10699 (if (> (length articles) 1)
10700 (format "these %d articles" (length articles))
10705 (gnus-completing-read-with-default
10708 'gnus-valid-move-group-p
10710 'gnus-group-history))
10711 ((= 1 (length split-name))
10712 (gnus-completing-read-with-default
10713 (car split-name) prom
10715 'gnus-valid-move-group-p
10717 'gnus-group-history))
10719 (gnus-completing-read-with-default
10721 (mapcar (lambda (el) (list el))
10722 (nreverse split-name))
10724 'gnus-group-history))))
10725 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10727 (if (or (string= to-newsgroup "")
10728 (string= to-newsgroup prefix))
10729 (setq to-newsgroup default))
10730 (unless to-newsgroup
10731 (error "No group name entered"))
10732 (or (gnus-active to-newsgroup)
10733 (gnus-activate-group to-newsgroup nil nil to-method)
10734 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10736 (or (and (gnus-request-create-group to-newsgroup to-method)
10737 (gnus-activate-group
10738 to-newsgroup nil nil to-method)
10739 (gnus-subscribe-group to-newsgroup))
10740 (error "Couldn't create group %s" to-newsgroup)))
10741 (error "No such group: %s" to-newsgroup)))
10744 (defun gnus-summary-save-parts (type dir n &optional reverse)
10745 "Save parts matching TYPE to DIR.
10746 If REVERSE, save parts that do not match TYPE."
10748 (list (read-string "Save parts of type: "
10749 (or (car gnus-summary-save-parts-type-history)
10750 gnus-summary-save-parts-default-mime)
10751 'gnus-summary-save-parts-type-history)
10752 (setq gnus-summary-save-parts-last-directory
10753 (read-file-name "Save to directory: "
10754 gnus-summary-save-parts-last-directory
10756 current-prefix-arg))
10757 (gnus-summary-iterate n
10758 (let ((gnus-display-mime-function nil)
10759 (gnus-inhibit-treatment t))
10760 (gnus-summary-select-article))
10762 (set-buffer gnus-article-buffer)
10763 (let ((handles (or gnus-article-mime-handles
10764 (mm-dissect-buffer nil gnus-article-loose-mime)
10767 (gnus-summary-save-parts-1 type dir handles reverse)
10768 (unless gnus-article-mime-handles ;; Don't destroy this case.
10769 (mm-destroy-parts handles)))))))
10771 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10772 (if (stringp (car handle))
10773 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10776 (not (string-match type (mm-handle-media-type handle)))
10777 (string-match type (mm-handle-media-type handle)))
10778 (let ((file (expand-file-name
10779 (file-name-nondirectory
10781 (mail-content-type-get
10782 (mm-handle-disposition handle) 'filename)
10783 (concat gnus-newsgroup-name
10784 "." (number-to-string
10785 (cdr gnus-article-current)))))
10787 (unless (file-exists-p file)
10788 (mm-save-part-to-file handle file))))))
10790 ;; Summary extract commands
10792 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10793 (let ((buffer-read-only nil)
10794 (article (gnus-summary-article-number))
10796 (unless (gnus-summary-goto-subject article)
10797 (error "No such article: %d" article))
10798 (gnus-summary-position-point)
10799 ;; If all commands are to be bunched up on one line, we collect
10801 (unless gnus-view-pseudos-separately
10802 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10805 (setq action (cdr (assq 'action (car ps))))
10806 (setq files (list (cdr (assq 'name (car ps)))))
10807 (while (and ps (cdr ps)
10808 (string= (or action "1")
10809 (or (cdr (assq 'action (cadr ps))) "2")))
10810 (push (cdr (assq 'name (cadr ps))) files)
10811 (setcdr ps (cddr ps)))
10813 (when (not (string-match "%s" action))
10816 (when (assq 'execute (car ps))
10817 (setcdr (assq 'execute (car ps))
10818 (funcall (if (string-match "%s" action)
10825 (gnus-quote-arg-for-sh-or-csh f)))
10827 (setq ps (cdr ps)))))
10828 (if (and gnus-view-pseudos (not not-view))
10830 (when (assq 'execute (car pslist))
10831 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10832 (eq gnus-view-pseudos 'not-confirm)))
10833 (setq pslist (cdr pslist)))
10836 (setq after-article (or (cdr (assq 'article (car pslist)))
10837 (gnus-summary-article-number)))
10838 (gnus-summary-goto-subject after-article)
10841 (insert " " (file-name-nondirectory
10842 (cdr (assq 'name (car pslist))))
10843 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10845 (forward-line -1) ; back to `b'
10846 (gnus-add-text-properties
10847 b (1- e) (list 'gnus-number gnus-reffed-article-number
10848 gnus-mouse-face-prop gnus-mouse-face))
10850 after-article gnus-reffed-article-number
10851 gnus-unread-mark b (car pslist) 0 (- e b))
10852 (setq gnus-newsgroup-unreads
10853 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10854 gnus-reffed-article-number))
10855 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10856 (setq pslist (cdr pslist)))))))
10858 (defun gnus-pseudos< (p1 p2)
10859 (let ((c1 (cdr (assq 'action p1)))
10860 (c2 (cdr (assq 'action p2))))
10861 (and c1 c2 (string< c1 c2))))
10863 (defun gnus-request-pseudo-article (props)
10864 (cond ((assq 'execute props)
10865 (gnus-execute-command (cdr (assq 'execute props)))))
10866 (let ((gnus-current-article (gnus-summary-article-number)))
10867 (gnus-run-hooks 'gnus-mark-article-hook)))
10869 (defun gnus-execute-command (command &optional automatic)
10871 (gnus-article-setup-buffer)
10872 (set-buffer gnus-article-buffer)
10873 (setq buffer-read-only nil)
10874 (let ((command (if automatic command
10875 (read-string "Command: " (cons command 0)))))
10877 (insert "$ " command "\n\n")
10878 (if gnus-view-pseudo-asynchronously
10879 (start-process "gnus-execute" (current-buffer) shell-file-name
10880 shell-command-switch command)
10881 (call-process shell-file-name nil t nil
10882 shell-command-switch command)))))
10884 ;; Summary kill commands.
10886 (defun gnus-summary-edit-global-kill (article)
10887 "Edit the \"global\" kill file."
10888 (interactive (list (gnus-summary-article-number)))
10889 (gnus-group-edit-global-kill article))
10891 (defun gnus-summary-edit-local-kill ()
10892 "Edit a local kill file applied to the current newsgroup."
10894 (setq gnus-current-headers (gnus-summary-article-header))
10895 (gnus-group-edit-local-kill
10896 (gnus-summary-article-number) gnus-newsgroup-name))
10898 ;;; Header reading.
10900 (defun gnus-read-header (id &optional header)
10901 "Read the headers of article ID and enter them into the Gnus system."
10902 (let ((group gnus-newsgroup-name)
10903 (gnus-override-method
10905 gnus-override-method
10906 (and (gnus-news-group-p gnus-newsgroup-name)
10907 (car (gnus-refer-article-methods)))))
10909 ;; First we check to see whether the header in question is already
10912 ;; This is a Message-ID.
10913 (setq header (or header (gnus-id-to-header id)))
10914 ;; This is an article number.
10915 (setq header (or header (gnus-summary-article-header id))))
10917 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10918 ;; We have found the header.
10920 ;; If this is a sparse article, we have to nix out its
10921 ;; previous entry in the thread hashtb.
10923 (gnus-summary-article-sparse-p (mail-header-number header)))
10924 (let* ((parent (gnus-parent-id (mail-header-references header)))
10925 (thread (and parent (gnus-id-to-thread parent))))
10927 (delq (assq header thread) thread))))
10928 ;; We have to really fetch the header to this article.
10930 (set-buffer nntp-server-buffer)
10931 (when (setq where (gnus-request-head id group))
10932 (nnheader-fold-continuation-lines)
10933 (goto-char (point-max))
10935 (goto-char (point-min))
10939 ((cdr where) (cdr where))
10940 (header (mail-header-number header))
10941 (t gnus-reffed-article-number))
10943 (insert " Article retrieved.\n"))
10944 (if (or (not where)
10945 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10946 () ; Malformed head.
10947 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10948 (when (and (stringp id)
10949 (not (string= (gnus-group-real-name group)
10951 ;; If we fetched by Message-ID and the article came
10952 ;; from a different group, we fudge some bogus article
10953 ;; numbers for this article.
10954 (mail-header-set-number header gnus-reffed-article-number))
10956 (set-buffer gnus-summary-buffer)
10957 (decf gnus-reffed-article-number)
10958 (gnus-remove-header (mail-header-number header))
10959 (push header gnus-newsgroup-headers)
10960 (setq gnus-current-headers header)
10961 (push (mail-header-number header) gnus-newsgroup-limit)))
10964 (defun gnus-remove-header (number)
10965 "Remove header NUMBER from `gnus-newsgroup-headers'."
10966 (if (and gnus-newsgroup-headers
10967 (= number (mail-header-number (car gnus-newsgroup-headers))))
10968 (pop gnus-newsgroup-headers)
10969 (let ((headers gnus-newsgroup-headers))
10970 (while (and (cdr headers)
10971 (not (= number (mail-header-number (cadr headers)))))
10973 (when (cdr headers)
10974 (setcdr headers (cddr headers))))))
10977 ;;; summary highlights
10980 (defun gnus-highlight-selected-summary ()
10981 "Highlight selected article in summary buffer."
10982 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10983 (when gnus-summary-selected-face
10985 (let* ((beg (progn (beginning-of-line) (point)))
10986 (end (progn (end-of-line) (point)))
10987 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10988 (from (if (get-text-property beg gnus-mouse-face-prop)
10990 (or (next-single-property-change
10991 beg gnus-mouse-face-prop nil end)
10996 (or (next-single-property-change
10997 from gnus-mouse-face-prop nil end)
10999 ;; If no mouse-face prop on line we will have to = from = end,
11000 ;; so we highlight the entire line instead.
11001 (when (= (+ to 2) from)
11004 (if gnus-newsgroup-selected-overlay
11005 ;; Move old overlay.
11007 gnus-newsgroup-selected-overlay from to (current-buffer))
11008 ;; Create new overlay.
11010 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11011 'face gnus-summary-selected-face))))))
11013 (defvar gnus-summary-highlight-line-cached nil)
11014 (defvar gnus-summary-highlight-line-trigger nil)
11016 (defun gnus-summary-highlight-line-0 ()
11017 (if (and (eq gnus-summary-highlight-line-trigger
11018 gnus-summary-highlight)
11019 gnus-summary-highlight-line-cached)
11020 gnus-summary-highlight-line-cached
11021 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11022 gnus-summary-highlight-line-cached
11023 (let* ((cond (list 'cond))
11025 (list gnus-summary-highlight))
11027 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11030 (gnus-byte-compile (list 'lambda nil cond))))))
11032 (defun gnus-summary-highlight-line ()
11033 "Highlight current line according to `gnus-summary-highlight'."
11034 (let* ((beg (gnus-point-at-bol))
11035 (article (or (gnus-summary-article-number) gnus-current-article))
11036 (score (or (cdr (assq article
11037 gnus-newsgroup-scored))
11038 gnus-summary-default-score 0))
11039 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11040 (inhibit-read-only t)
11041 (default gnus-summary-default-score)
11042 (default-high gnus-summary-default-high-score)
11043 (default-low gnus-summary-default-low-score)
11044 (uncached (memq article gnus-newsgroup-undownloaded))
11045 (downloaded (not uncached)))
11046 (let ((face (funcall (gnus-summary-highlight-line-0))))
11047 (unless (eq face (get-text-property beg 'face))
11048 (gnus-put-text-property-excluding-characters-with-faces
11049 beg (gnus-point-at-eol) 'face
11050 (setq face (if (boundp face) (symbol-value face) face)))
11051 (when gnus-summary-highlight-line-function
11052 (funcall gnus-summary-highlight-line-function article face))))))
11054 (defun gnus-update-read-articles (group unread &optional compute)
11055 "Update the list of read articles in GROUP.
11056 UNREAD is a sorted list."
11057 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11058 (entry (gnus-gethash group gnus-newsrc-hashtb))
11059 (info (nth 2 entry))
11062 (if (or (not info) (not active))
11063 ;; There is no info on this group if it was, in fact,
11064 ;; killed. Gnus stores no information on killed groups, so
11065 ;; there's nothing to be done.
11066 ;; One could store the information somewhere temporarily,
11067 ;; perhaps... Hmmm...
11069 ;; Remove any negative articles numbers.
11070 (while (and unread (< (car unread) 0))
11071 (setq unread (cdr unread)))
11072 ;; Remove any expired article numbers
11073 (while (and unread (< (car unread) (car active)))
11074 (setq unread (cdr unread)))
11075 ;; Compute the ranges of read articles by looking at the list of
11076 ;; unread articles.
11078 (when (/= (car unread) prev)
11079 (push (if (= prev (1- (car unread))) prev
11080 (cons prev (1- (car unread))))
11082 (setq prev (1+ (car unread)))
11083 (setq unread (cdr unread)))
11084 (when (<= prev (cdr active))
11085 (push (cons prev (cdr active)) read))
11086 (setq read (if (> (length read) 1) (nreverse read) read))
11091 ;; Propagate the read marks to the backend.
11092 (when (gnus-check-backend-function 'request-set-mark group)
11093 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11094 (add (gnus-remove-from-range read (gnus-info-read info))))
11096 (unless (gnus-check-group group)
11097 (error "Can't open server for %s" group))
11098 (gnus-request-set-mark
11099 group (delq nil (list (if add (list add 'add '(read)))
11100 (if del (list del 'del '(read))))))
11102 `(gnus-request-set-mark
11105 (if del (list del 'add '(read)))
11106 (if add (list add 'del '(read))))))))))
11107 (set-buffer gnus-group-buffer)
11108 (gnus-undo-register
11110 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11111 (gnus-info-set-read ',info ',(gnus-info-read info))
11112 (gnus-get-unread-articles-in-group ',info
11113 (gnus-active ,group))
11114 (gnus-group-update-group ,group t)
11116 ;; Enter this list into the group info.
11117 (gnus-info-set-read info read)
11118 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11119 (gnus-get-unread-articles-in-group info (gnus-active group))
11122 (defun gnus-offer-save-summaries ()
11123 "Offer to save all active summary buffers."
11125 ;; Go through all buffers and find all summaries.
11126 (dolist (buffer (buffer-list))
11127 (when (and (setq buffer (buffer-name buffer))
11128 (string-match "Summary" buffer)
11130 (set-buffer buffer)
11131 ;; We check that this is, indeed, a summary buffer.
11132 (and (eq major-mode 'gnus-summary-mode)
11133 ;; Also make sure this isn't bogus.
11134 gnus-newsgroup-prepared
11135 ;; Also make sure that this isn't a
11136 ;; dead summary buffer.
11137 (not gnus-dead-summary-mode))))
11138 (push buffer buffers)))
11139 ;; Go through all these summary buffers and offer to save them.
11143 "Update summary buffer %s? "
11145 (switch-to-buffer buf)
11146 (gnus-summary-exit))
11150 ;;; @ for mime-partial
11153 (defun gnus-request-partial-message ()
11155 (let ((number (gnus-summary-article-number))
11156 (group gnus-newsgroup-name)
11157 (mother gnus-article-buffer))
11158 (set-buffer (get-buffer-create " *Partial Article*"))
11160 (setq mime-preview-buffer mother)
11161 (gnus-request-article-this-buffer number group)
11162 (mime-parse-buffer)
11165 (autoload 'mime-combine-message/partial-pieces-automatically
11167 "Internal method to combine message/partial messages automatically.")
11169 (mime-add-condition
11170 'action '((type . message)(subtype . partial)
11171 (major-mode . gnus-original-article-mode)
11172 (method . mime-combine-message/partial-pieces-automatically)
11173 (summary-buffer-exp . gnus-summary-buffer)
11174 (request-partial-message-method . gnus-request-partial-message)
11178 ;;; @ for message/rfc822
11181 (defun gnus-mime-extract-message/rfc822 (entity situation)
11182 "Burst a forwarded article."
11184 (set-buffer gnus-summary-buffer)
11185 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11186 gnus-newsgroup-name 'gnus-group-history))
11187 (gnus-group-marked (list group))
11190 (mime-insert-entity-content entity)
11191 (setq article (gnus-request-accept-article group)))
11192 (when (and (consp article)
11193 (numberp (setq article (cdr article))))
11194 (setq info (gnus-get-info group))
11195 (gnus-info-set-read info
11196 (gnus-remove-from-range (gnus-info-read info)
11198 (when (string-equal group gnus-newsgroup-name)
11200 (let (gnus-show-threads)
11201 (gnus-summary-goto-subject article t))
11202 (gnus-summary-clear-mark-forward 1))
11203 (set-buffer gnus-group-buffer)
11204 (gnus-group-get-new-news-this-group nil t)))))
11206 (mime-add-condition
11207 'action '((type . message)(subtype . rfc822)
11208 (major-mode . gnus-original-article-mode)
11209 (method . gnus-mime-extract-message/rfc822)
11213 (mime-add-condition
11214 'action '((type . message)(subtype . news)
11215 (major-mode . gnus-original-article-mode)
11216 (method . gnus-mime-extract-message/rfc822)
11220 (defun gnus-mime-extract-multipart (entity situation)
11221 (let ((children (mime-entity-children entity))
11222 mime-acting-situation-to-override
11225 (mime-play-entity (car children)
11226 (cons (assq 'mode situation)
11227 mime-acting-situation-to-override))
11228 (setq children (cdr children)))
11229 (if (setq f (cdr (assq 'after-method
11230 mime-acting-situation-to-override)))
11234 (mime-add-condition
11235 'action '((type . multipart)
11236 (method . gnus-mime-extract-multipart)
11245 (defun gnus-summary-inherit-default-charset ()
11246 "Import `default-mime-charset' from summary buffer.
11247 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11249 (if (buffer-live-p gnus-summary-buffer)
11250 (let (d-m-c d-m-c-u)
11251 (with-current-buffer gnus-summary-buffer
11252 (setq d-m-c (if (local-variable-p 'default-mime-charset
11253 gnus-summary-buffer)
11254 default-mime-charset
11257 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11258 gnus-summary-buffer)
11259 (symbol-value 'default-mime-charset-unlimited)
11262 (kill-local-variable 'default-mime-charset)
11263 (set (make-local-variable 'default-mime-charset) d-m-c))
11265 (kill-local-variable 'default-mime-charset-unlimited)
11266 (set (make-local-variable 'default-mime-charset-unlimited)
11269 (defun gnus-summary-setup-default-charset ()
11270 "Setup newsgroup default charset."
11271 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11273 (setq gnus-newsgroup-charset nil)
11274 (set (make-local-variable 'default-mime-charset) nil)
11275 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11276 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11277 (let ((ignored-charsets
11278 (or gnus-newsgroup-ephemeral-ignored-charsets
11280 (and gnus-newsgroup-name
11281 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11282 gnus-newsgroup-ignored-charsets)))
11284 (setq gnus-newsgroup-charset
11285 (or gnus-newsgroup-ephemeral-charset
11286 (when (and gnus-newsgroup-name
11287 (setq charset (gnus-parameter-charset
11288 gnus-newsgroup-name)))
11289 (make-local-variable 'default-mime-charset)
11290 (setq default-mime-charset charset))
11291 gnus-default-charset))
11292 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11293 ignored-charsets))))
11299 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11300 "Display the current article buffer fully MIME-buttonized.
11301 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11302 treated as multipart/mixed."
11304 (require 'gnus-art)
11305 (let ((gnus-unbuttonized-mime-types nil)
11306 (gnus-mime-display-multipart-as-mixed show-all-parts))
11307 (gnus-summary-show-article)))
11309 (defun gnus-summary-repair-multipart (article)
11310 "Add a Content-Type header to a multipart article without one."
11311 (interactive (list (gnus-summary-article-number)))
11312 (gnus-with-article article
11313 (message-narrow-to-head)
11314 (message-remove-header "Mime-Version")
11315 (goto-char (point-max))
11316 (insert "Mime-Version: 1.0\n")
11318 (when (search-forward "\n--" nil t)
11319 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11320 (message-narrow-to-head)
11321 (message-remove-header "Content-Type")
11322 (goto-char (point-max))
11323 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11326 (let (gnus-mark-article-hook)
11327 (gnus-summary-select-article t t nil article)))
11329 (defun gnus-summary-toggle-display-buttonized ()
11330 "Toggle the buttonizing of the article buffer."
11332 (require 'gnus-art)
11333 (if (setq gnus-inhibit-mime-unbuttonizing
11334 (not gnus-inhibit-mime-unbuttonizing))
11335 (let ((gnus-unbuttonized-mime-types nil))
11336 (gnus-summary-show-article))
11337 (gnus-summary-show-article)))
11340 ;;; Intelli-mouse commmands
11343 (defun gnus-wheel-summary-scroll (event)
11345 (let ((amount (if (memq 'shift (event-modifiers event))
11346 (car gnus-wheel-scroll-amount)
11347 (cdr gnus-wheel-scroll-amount)))
11348 (direction (- (* (static-if (featurep 'xemacs)
11349 (event-button event)
11350 (cond ((eq 'mouse-4 (event-basic-type event))
11352 ((eq 'mouse-5 (event-basic-type event))
11356 (gnus-summary-scroll-up (* amount direction))
11357 (when (gnus-eval-in-buffer-window gnus-article-buffer
11360 (and (if (< 0 direction)
11361 (gnus-article-next-page 0)
11362 (gnus-article-prev-page 0)
11364 (if (setq edge (get-text-property
11365 (point-min) 'gnus-wheel-edge))
11366 (setq edge (* edge direction))
11369 (let ((buffer-read-only nil)
11370 (inhibit-read-only t))
11371 (put-text-property (point-min) (point-max)
11372 'gnus-wheel-edge direction)
11374 (or (> edge gnus-wheel-edge-resistance)
11375 (let ((buffer-read-only nil)
11376 (inhibit-read-only t))
11377 (put-text-property (point-min) (point-max)
11379 (* (1+ edge) direction))
11381 (eq last-command 'gnus-wheel-summary-scroll))))
11382 (gnus-summary-next-article nil nil (minusp direction)))))
11384 (defun gnus-wheel-install ()
11385 "Enable mouse wheel support on summary window."
11386 (when gnus-use-wheel
11388 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11390 (define-key gnus-summary-mode-map key
11391 'gnus-wheel-summary-scroll)))))
11393 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11396 ;;; Traditional PGP commmands
11399 (defun gnus-summary-decrypt-article (&optional force)
11400 "Decrypt the current article in traditional PGP way.
11401 This will have permanent effect only in mail groups.
11402 If FORCE is non-nil, allow editing of articles even in read-only
11405 (gnus-summary-select-article t)
11406 (gnus-eval-in-buffer-window gnus-article-buffer
11410 (goto-char (point-min))
11411 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11412 (error "Not a traditional PGP message!"))
11413 (let ((armor-start (match-beginning 0)))
11414 (if (and (pgg-decrypt-region armor-start (point-max))
11415 (or force (not (gnus-group-read-only-p))))
11416 (let ((inhibit-read-only t)
11418 (delete-region armor-start
11420 (re-search-forward "^-+END PGP" nil t)
11421 (beginning-of-line 2)
11423 (insert-buffer-substring pgg-output-buffer))))))))
11425 (defun gnus-summary-verify-article ()
11426 "Verify the current article in traditional PGP way."
11429 (set-buffer gnus-original-article-buffer)
11430 (goto-char (point-min))
11431 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11432 (error "Not a traditional PGP message!"))
11433 (re-search-forward "^-+END PGP" nil t)
11434 (beginning-of-line 2)
11435 (call-interactively (function pgg-verify-region))))
11438 ;;; Generic summary marking commands
11441 (defvar gnus-summary-marking-alist
11442 '((read gnus-del-mark "d")
11443 (unread gnus-unread-mark "u")
11444 (ticked gnus-ticked-mark "!")
11445 (dormant gnus-dormant-mark "?")
11446 (expirable gnus-expirable-mark "e"))
11447 "An alist of names/marks/keystrokes.")
11449 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11450 (defvar gnus-summary-mark-map)
11452 (defun gnus-summary-make-all-marking-commands ()
11453 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11454 (dolist (elem gnus-summary-marking-alist)
11455 (apply 'gnus-summary-make-marking-command elem)))
11457 (defun gnus-summary-make-marking-command (name mark keystroke)
11458 (let ((map (make-sparse-keymap)))
11459 (define-key gnus-summary-generic-mark-map keystroke map)
11460 (dolist (lway `((next "next" next nil "n")
11461 (next-unread "next unread" next t "N")
11462 (prev "previous" prev nil "p")
11463 (prev-unread "previous unread" prev t "P")
11464 (nomove "" nil nil ,keystroke)))
11465 (let ((func (gnus-summary-make-marking-command-1
11466 mark (car lway) lway name)))
11467 (setq func (eval func))
11468 (define-key map (nth 4 lway) func)))))
11470 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11472 (format "gnus-summary-put-mark-as-%s%s"
11473 name (if (eq way 'nomove)
11475 (concat "-" (symbol-name way)))))
11478 "Mark the current article as %s%s.
11479 If N, the prefix, then repeat N times.
11480 If N is negative, move in reverse order.
11481 The difference between N and the actual number of articles marked is
11483 name (car (cdr lway)))
11485 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11487 (defun gnus-summary-generic-mark (n mark move unread)
11488 "Mark N articles with MARK."
11489 (unless (eq major-mode 'gnus-summary-mode)
11490 (error "This command can only be used in the summary buffer"))
11491 (gnus-summary-show-thread)
11494 ((eq move 'next) 1)
11495 ((eq move 'prev) -1)
11497 (if (zerop nummove)
11501 nummove (* -1 nummove))))
11502 (while (and (> n 0)
11503 (gnus-summary-mark-article nil mark)
11504 (zerop (gnus-summary-next-subject nummove unread t)))
11507 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11508 (gnus-summary-recenter)
11509 (gnus-summary-position-point)
11510 (gnus-set-mode-line 'summary)
11513 (defun gnus-summary-insert-articles (articles)
11514 (when (setq articles
11515 (gnus-sorted-difference articles
11516 (mapcar (lambda (h)
11517 (mail-header-number h))
11518 gnus-newsgroup-headers)))
11519 (setq gnus-newsgroup-headers
11521 gnus-newsgroup-headers
11522 (gnus-fetch-headers articles)
11523 'gnus-article-sort-by-number))
11524 ;; Suppress duplicates?
11525 (when gnus-suppress-duplicates
11526 (gnus-dup-suppress-articles))
11528 ;; We might want to build some more threads first.
11529 (when (and gnus-fetch-old-headers
11530 (eq gnus-headers-retrieved-by 'nov))
11531 (if (eq gnus-fetch-old-headers 'invisible)
11532 (gnus-build-all-threads)
11533 (gnus-build-old-threads)))
11534 ;; Let the Gnus agent mark articles as read.
11536 (gnus-agent-get-undownloaded-list))
11537 ;; Remove list identifiers from subject
11538 (when gnus-list-identifiers
11539 (gnus-summary-remove-list-identifiers))
11540 ;; First and last article in this newsgroup.
11541 (when gnus-newsgroup-headers
11542 (setq gnus-newsgroup-begin
11543 (mail-header-number (car gnus-newsgroup-headers))
11545 (mail-header-number
11546 (gnus-last-element gnus-newsgroup-headers))))
11547 (when gnus-use-scoring
11548 (gnus-possibly-score-headers))))
11550 (defun gnus-summary-insert-old-articles (&optional all)
11551 "Insert all old articles in this group.
11552 If ALL is non-nil, already read articles become readable.
11553 If ALL is a number, fetch this number of articles."
11556 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11559 ;; Some nntp servers lie about their active range. When
11560 ;; this happens, the active range can be in the millions.
11561 ;; Use a compressed range to avoid creating a huge list.
11562 (gnus-range-difference (list gnus-newsgroup-active) old))
11563 (setq len (gnus-range-length older))
11568 (let ((older-range (nreverse older)))
11572 (let* ((r (pop older-range))
11573 (min (if (numberp r) r (car r)))
11574 (max (if (numberp r) r (cdr r))))
11575 (while (and (<= min max)
11580 (setq older (gnus-uncompress-range older))))
11582 (setq older (gnus-uncompress-range older)))
11584 (when (and (numberp gnus-large-newsgroup)
11585 (> len gnus-large-newsgroup))
11586 (let* ((cursor-in-echo-area nil)
11587 (initial (gnus-parameter-large-newsgroup-initial
11588 gnus-newsgroup-name))
11592 "How many articles from %s (%s %d): "
11594 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11595 (if initial "max" "default")
11598 (cons (number-to-string initial)
11600 (unless (string-match "^[ \t]*$" input)
11601 (setq all (string-to-number input))
11603 (let ((older-range (nreverse older)))
11607 (let* ((r (pop older-range))
11608 (min (if (numberp r) r (car r)))
11609 (max (if (numberp r) r (cdr r))))
11610 (while (and (<= min max)
11614 max (1- max))))))))))
11615 (setq older (gnus-uncompress-range older))))
11617 (message "No old news.")
11618 (gnus-summary-insert-articles older)
11619 (gnus-summary-limit (gnus-sorted-nunion old older))))
11620 (gnus-summary-position-point)))
11622 (defun gnus-summary-insert-new-articles ()
11623 "Insert all new articles in this group."
11626 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11627 (old-active gnus-newsgroup-active)
11628 (nnmail-fetched-sources (list t))
11630 (setq gnus-newsgroup-active
11631 (gnus-activate-group gnus-newsgroup-name 'scan))
11632 (setq i (cdr gnus-newsgroup-active))
11633 (while (> i (cdr old-active))
11637 (message "No gnus is bad news.")
11638 (gnus-summary-insert-articles new)
11639 (setq gnus-newsgroup-unreads
11640 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11641 (gnus-summary-limit (gnus-sorted-nunion old new))))
11642 (gnus-summary-position-point)))
11644 (gnus-summary-make-all-marking-commands)
11646 (gnus-ems-redefine)
11648 (provide 'gnus-sum)
11650 (run-hooks 'gnus-sum-load-hook)
11652 ;;; gnus-sum.el ends here