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-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include:
151 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
152 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 (they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-default-high-score 0
217 "*Default threshold for a high scored article.
218 An article will be highlighted as high scored if its score is greater
220 :group 'gnus-score-default
223 (defcustom gnus-summary-default-low-score 0
224 "*Default threshold for a low scored article.
225 An article will be highlighted as low scored if its score is smaller
227 :group 'gnus-score-default
230 (defcustom gnus-summary-zcore-fuzz 0
231 "*Fuzziness factor for the zcore in the summary buffer.
232 Articles with scores closer than this to `gnus-summary-default-score'
234 :group 'gnus-summary-format
237 (defcustom gnus-simplify-subject-fuzzy-regexp nil
238 "*Strings to be removed when doing fuzzy matches.
239 This can either be a regular expression or list of regular expressions
240 that will be removed from subject strings if fuzzy subject
241 simplification is selected."
243 :type '(repeat regexp))
245 (defcustom gnus-show-threads t
246 "*If non-nil, display threads in summary mode."
250 (defcustom gnus-thread-hide-subtree nil
251 "*If non-nil, hide all threads initially.
252 This can be a predicate specifier which says which threads to hide.
253 If threads are hidden, you have to run the command
254 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
255 to expose hidden threads."
259 (defcustom gnus-thread-hide-killed t
260 "*If non-nil, hide killed threads automatically."
264 (defcustom gnus-thread-ignore-subject t
265 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
266 If nil, articles that have different subjects from their parents will
267 start separate threads."
271 (defcustom gnus-thread-operation-ignore-subject t
272 "*If non-nil, subjects will be ignored when doing thread commands.
273 This affects commands like `gnus-summary-kill-thread' and
274 `gnus-summary-lower-thread'.
276 If this variable is nil, articles in the same thread with different
277 subjects will not be included in the operation in question. If this
278 variable is `fuzzy', only articles that have subjects that are fuzzily
279 equal will be included."
281 :type '(choice (const :tag "off" nil)
285 (defcustom gnus-thread-indent-level 4
286 "*Number that says how much each sub-thread should be indented."
290 (defcustom gnus-auto-extend-newsgroup t
291 "*If non-nil, extend newsgroup forward and backward when requested."
292 :group 'gnus-summary-choose
295 (defcustom gnus-auto-select-first t
296 "*If non-nil, select the article under point.
297 Which article this is is controlled by the `gnus-auto-select-subject'
300 If you want to prevent automatic selection of articles in some
301 newsgroups, set the variable to nil in `gnus-select-group-hook'."
302 :group 'gnus-group-select
303 :type '(choice (const :tag "none" nil)
304 (sexp :menu-tag "first" t)))
306 (defcustom gnus-auto-select-subject 'unread
307 "*Says what subject to place under point when entering a group.
309 This variable can either be the symbols `first' (place point on the
310 first subject), `unread' (place point on the subject line of the first
311 unread article), `best' (place point on the subject line of the
312 higest-scored article), `unseen' (place point on the subject line of
313 the first unseen article), 'unseen-or-unread' (place point on the subject
314 line of the first unseen article or, if all article have been seen, on the
315 subject line of the first unread article), or a function to be called to
316 place point on some subject line."
317 :group 'gnus-group-select
318 :type '(choice (const best)
322 (const unseen-or-unread)))
324 (defcustom gnus-dont-select-after-jump-to-other-group nil
325 "If non-nil, don't select the first unread article after entering the
326 other group by the command `gnus-summary-jump-to-other-group'. If nil,
327 it is depend on the value of `gnus-auto-select-first' whether to select
329 :group 'gnus-group-select
332 (defcustom gnus-auto-select-next t
333 "*If non-nil, offer to go to the next group from the end of the previous.
334 If the value is t and the next newsgroup is empty, Gnus will exit
335 summary mode and go back to group mode. If the value is neither nil
336 nor t, Gnus will select the following unread newsgroup. In
337 particular, if the value is the symbol `quietly', the next unread
338 newsgroup will be selected without any confirmation, and if it is
339 `almost-quietly', the next group will be selected without any
340 confirmation if you are located on the last article in the group.
341 Finally, if this variable is `slightly-quietly', the `Z n' command
342 will go to the next group without confirmation."
343 :group 'gnus-summary-maneuvering
344 :type '(choice (const :tag "off" nil)
346 (const almost-quietly)
347 (const slightly-quietly)
348 (sexp :menu-tag "on" t)))
350 (defcustom gnus-auto-select-same nil
351 "*If non-nil, select the next article with the same subject.
352 If there are no more articles with the same subject, go to
353 the first unread article."
354 :group 'gnus-summary-maneuvering
357 (defcustom gnus-summary-check-current nil
358 "*If non-nil, consider the current article when moving.
359 The \"unread\" movement commands will stay on the same line if the
360 current article is unread."
361 :group 'gnus-summary-maneuvering
364 (defcustom gnus-auto-center-summary t
365 "*If non-nil, always center the current summary buffer.
366 In particular, if `vertical' do only vertical recentering. If non-nil
367 and non-`vertical', do both horizontal and vertical recentering."
368 :group 'gnus-summary-maneuvering
369 :type '(choice (const :tag "none" nil)
371 (integer :tag "height")
372 (sexp :menu-tag "both" t)))
374 (defcustom gnus-show-all-headers nil
375 "*If non-nil, don't hide any headers."
376 :group 'gnus-article-hiding
377 :group 'gnus-article-headers
380 (defcustom gnus-summary-ignore-duplicates nil
381 "*If non-nil, ignore articles with identical Message-ID headers."
385 (defcustom gnus-single-article-buffer t
386 "*If non-nil, display all articles in the same buffer.
387 If nil, each group will get its own article buffer."
388 :group 'gnus-article-various
391 (defcustom gnus-break-pages t
392 "*If non-nil, do page breaking on articles.
393 The page delimiter is specified by the `gnus-page-delimiter'
395 :group 'gnus-article-various
398 (defcustom gnus-show-mime t
399 "*If non-nil, do mime processing of articles.
400 The articles will simply be fed to the function given by
401 `gnus-article-display-method-for-mime'."
402 :group 'gnus-article-mime
405 (defcustom gnus-move-split-methods nil
406 "*Variable used to suggest where articles are to be moved to.
407 It uses the same syntax as the `gnus-split-methods' variable.
408 However, whereas `gnus-split-methods' specifies file names as targets,
409 this variable specifies group names."
410 :group 'gnus-summary-mail
411 :type '(repeat (choice (list :value (fun) function)
412 (cons :value ("" "") regexp (repeat string))
415 (defcustom gnus-unread-mark ?\ ;;;Whitespace
416 "*Mark used for unread articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-ticked-mark ?!
421 "*Mark used for ticked articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-dormant-mark ??
426 "*Mark used for dormant articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-del-mark ?r
431 "*Mark used for del'd articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-read-mark ?R
436 "*Mark used for read articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-expirable-mark ?E
441 "*Mark used for expirable articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-killed-mark ?K
446 "*Mark used for killed articles."
447 :group 'gnus-summary-marks
450 (defcustom gnus-spam-mark ?H
451 "*Mark used for spam articles."
452 :group 'gnus-summary-marks
455 (defcustom gnus-souped-mark ?F
456 "*Mark used for souped articles."
457 :group 'gnus-summary-marks
460 (defcustom gnus-kill-file-mark ?X
461 "*Mark used for articles killed by kill files."
462 :group 'gnus-summary-marks
465 (defcustom gnus-low-score-mark ?Y
466 "*Mark used for articles with a low score."
467 :group 'gnus-summary-marks
470 (defcustom gnus-catchup-mark ?C
471 "*Mark used for articles that are caught up."
472 :group 'gnus-summary-marks
475 (defcustom gnus-replied-mark ?A
476 "*Mark used for articles that have been replied to."
477 :group 'gnus-summary-marks
480 (defcustom gnus-forwarded-mark ?F
481 "*Mark used for articles that have been forwarded."
482 :group 'gnus-summary-marks
485 (defcustom gnus-recent-mark ?N
486 "*Mark used for articles that are recent."
487 :group 'gnus-summary-marks
490 (defcustom gnus-cached-mark ?*
491 "*Mark used for articles that are in the cache."
492 :group 'gnus-summary-marks
495 (defcustom gnus-saved-mark ?S
496 "*Mark used for articles that have been saved."
497 :group 'gnus-summary-marks
500 (defcustom gnus-unseen-mark ?.
501 "*Mark used for articles that haven't been seen."
502 :group 'gnus-summary-marks
505 (defcustom gnus-no-mark ?\ ;;;Whitespace
506 "*Mark used for articles that have no other secondary mark."
507 :group 'gnus-summary-marks
510 (defcustom gnus-ancient-mark ?O
511 "*Mark used for ancient articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-sparse-mark ?Q
516 "*Mark used for sparsely reffed articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-canceled-mark ?G
521 "*Mark used for canceled articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-duplicate-mark ?M
526 "*Mark used for duplicate articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-undownloaded-mark ?@
531 "*Mark used for articles that weren't downloaded."
532 :group 'gnus-summary-marks
535 (defcustom gnus-downloadable-mark ?%
536 "*Mark used for articles that are to be downloaded."
537 :group 'gnus-summary-marks
540 (defcustom gnus-unsendable-mark ?=
541 "*Mark used for articles that won't be sent."
542 :group 'gnus-summary-marks
545 (defcustom gnus-score-over-mark ?+
546 "*Score mark used for articles with high scores."
547 :group 'gnus-summary-marks
550 (defcustom gnus-score-below-mark ?-
551 "*Score mark used for articles with low scores."
552 :group 'gnus-summary-marks
555 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
556 "*There is no thread under the article."
557 :group 'gnus-summary-marks
560 (defcustom gnus-not-empty-thread-mark ?=
561 "*There is a thread under the article."
562 :group 'gnus-summary-marks
565 (defcustom gnus-view-pseudo-asynchronously nil
566 "*If non-nil, Gnus will view pseudo-articles asynchronously."
567 :group 'gnus-extract-view
570 (defcustom gnus-auto-expirable-marks
571 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
572 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
573 gnus-souped-mark gnus-duplicate-mark)
574 "*The list of marks converted into expiration if a group is auto-expirable."
577 :type '(repeat character))
579 (defcustom gnus-inhibit-user-auto-expire t
580 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
585 (defcustom gnus-view-pseudos nil
586 "*If `automatic', pseudo-articles will be viewed automatically.
587 If `not-confirm', pseudos will be viewed automatically, and the user
588 will not be asked to confirm the command."
589 :group 'gnus-extract-view
590 :type '(choice (const :tag "off" nil)
592 (const not-confirm)))
594 (defcustom gnus-view-pseudos-separately t
595 "*If non-nil, one pseudo-article will be created for each file to be viewed.
596 If nil, all files that use the same viewing command will be given as a
597 list of parameters to that command."
598 :group 'gnus-extract-view
601 (defcustom gnus-insert-pseudo-articles t
602 "*If non-nil, insert pseudo-articles when decoding articles."
603 :group 'gnus-extract-view
606 (defcustom gnus-summary-dummy-line-format
608 "*The format specification for the dummy roots in the summary buffer.
609 It works along the same lines as a normal formatting string,
610 with some simple extensions.
614 General format specifiers can also be used.
615 See `(gnus)Formatting Variables'."
616 :link '(custom-manual "(gnus)Formatting Variables")
617 :group 'gnus-threading
620 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
621 "*The format specification for the summary mode line.
622 It works along the same lines as a normal formatting string,
623 with some simple extensions:
626 %p Unprefixed group name
627 %A Current article number
628 %z Current article score
630 %U Number of unread articles in the group
631 %e Number of unselected articles in the group
632 %Z A string with unread/unselected article counts
633 %g Shortish group name
634 %S Subject of the current article
636 %s Current score file name
637 %d Number of dormant articles
638 %r Number of articles that have been marked as read in this session
639 %E Number of articles expunged by the score files"
640 :group 'gnus-summary-format
643 (defcustom gnus-list-identifiers nil
644 "Regexp that matches list identifiers to be removed from subject.
645 This can also be a list of regexps."
647 :group 'gnus-summary-format
648 :group 'gnus-article-hiding
649 :type '(choice (const :tag "none" nil)
651 (repeat :value (".*") regexp)))
653 (defcustom gnus-summary-mark-below 0
654 "*Mark all articles with a score below this variable as read.
655 This variable is local to each summary buffer and usually set by the
657 :group 'gnus-score-default
660 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
661 "*List of functions used for sorting articles in the summary buffer.
663 Each function takes two articles and returns non-nil if the first
664 article should be sorted before the other. If you use more than one
665 function, the primary sort function should be the last. You should
666 probably always include `gnus-article-sort-by-number' in the list of
667 sorting functions -- preferably first. Also note that sorting by date
668 is often much slower than sorting by number, and the sorting order is
669 very similar. (Sorting by date means sorting by the time the message
670 was sent, sorting by number means sorting by arrival time.)
672 Ready-made functions include `gnus-article-sort-by-number',
673 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
674 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
675 and `gnus-article-sort-by-score'.
677 When threading is turned on, the variable `gnus-thread-sort-functions'
678 controls how articles are sorted."
679 :group 'gnus-summary-sort
680 :type '(repeat (choice (function-item gnus-article-sort-by-number)
681 (function-item gnus-article-sort-by-author)
682 (function-item gnus-article-sort-by-subject)
683 (function-item gnus-article-sort-by-date)
684 (function-item gnus-article-sort-by-score)
685 (function-item gnus-article-sort-by-random)
686 (function :tag "other"))))
688 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
689 "*List of functions used for sorting threads in the summary buffer.
690 By default, threads are sorted by article number.
692 Each function takes two threads and returns non-nil if the first
693 thread should be sorted before the other. If you use more than one
694 function, the primary sort function should be the last. You should
695 probably always include `gnus-thread-sort-by-number' in the list of
696 sorting functions -- preferably first. Also note that sorting by date
697 is often much slower than sorting by number, and the sorting order is
698 very similar. (Sorting by date means sorting by the time the message
699 was sent, sorting by number means sorting by arrival time.)
701 Ready-made functions include `gnus-thread-sort-by-number',
702 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
703 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
704 `gnus-thread-sort-by-most-recent-number',
705 `gnus-thread-sort-by-most-recent-date',
706 `gnus-thread-sort-by-random', and
707 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
709 When threading is turned off, the variable
710 `gnus-article-sort-functions' controls how articles are sorted."
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
713 (function-item gnus-thread-sort-by-author)
714 (function-item gnus-thread-sort-by-subject)
715 (function-item gnus-thread-sort-by-date)
716 (function-item gnus-thread-sort-by-score)
717 (function-item gnus-thread-sort-by-total-score)
718 (function-item gnus-thread-sort-by-random)
719 (function :tag "other"))))
721 (defcustom gnus-thread-score-function '+
722 "*Function used for calculating the total score of a thread.
724 The function is called with the scores of the article and each
725 subthread and should then return the score of the thread.
727 Some functions you can use are `+', `max', or `min'."
728 :group 'gnus-summary-sort
731 (defcustom gnus-summary-expunge-below nil
732 "All articles that have a score less than this variable will be expunged.
733 This variable is local to the summary buffers."
734 :group 'gnus-score-default
735 :type '(choice (const :tag "off" nil)
738 (defcustom gnus-thread-expunge-below nil
739 "All threads that have a total score less than this variable will be expunged.
740 See `gnus-thread-score-function' for en explanation of what a
743 This variable is local to the summary buffers."
744 :group 'gnus-threading
745 :group 'gnus-score-default
746 :type '(choice (const :tag "off" nil)
749 (defcustom gnus-summary-mode-hook nil
750 "*A hook for Gnus summary mode.
751 This hook is run before any variables are set in the summary buffer."
752 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
753 :group 'gnus-summary-various
756 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
757 (when (featurep 'xemacs)
758 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
759 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
760 (add-hook 'gnus-summary-mode-hook
761 'gnus-xmas-switch-horizontal-scrollbar-off))
763 (defcustom gnus-summary-menu-hook nil
764 "*Hook run after the creation of the summary mode menu."
765 :group 'gnus-summary-visual
768 (defcustom gnus-summary-exit-hook nil
769 "*A hook called on exit from the summary buffer.
770 It will be called with point in the group buffer."
771 :group 'gnus-summary-exit
774 (defcustom gnus-summary-prepare-hook nil
775 "*A hook called after the summary buffer has been generated.
776 If you want to modify the summary buffer, you can use this hook."
777 :group 'gnus-summary-various
780 (defcustom gnus-summary-prepared-hook nil
781 "*A hook called as the last thing after the summary buffer has been generated."
782 :group 'gnus-summary-various
785 (defcustom gnus-summary-generate-hook nil
786 "*A hook run just before generating the summary buffer.
787 This hook is commonly used to customize threading variables and the
789 :group 'gnus-summary-various
792 (defcustom gnus-select-group-hook nil
793 "*A hook called when a newsgroup is selected.
795 If you'd like to simplify subjects like the
796 `gnus-summary-next-same-subject' command does, you can use the
799 (add-hook gnus-select-group-hook
801 (mapcar (lambda (header)
802 (mail-header-set-subject
804 (gnus-simplify-subject
805 (mail-header-subject header) 're-only)))
806 gnus-newsgroup-headers)))"
807 :group 'gnus-group-select
810 (defcustom gnus-select-article-hook nil
811 "*A hook called when an article is selected."
812 :group 'gnus-summary-choose
815 (defcustom gnus-visual-mark-article-hook
816 (list 'gnus-highlight-selected-summary)
817 "*Hook run after selecting an article in the summary buffer.
818 It is meant to be used for highlighting the article in some way. It
819 is not run if `gnus-visual' is nil."
820 :group 'gnus-summary-visual
823 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
824 "*A hook called before parsing the headers."
828 (defcustom gnus-exit-group-hook nil
829 "*A hook called when exiting summary mode.
830 This hook is not called from the non-updating exit commands like `Q'."
834 (defcustom gnus-summary-update-hook
835 (list 'gnus-summary-highlight-line)
836 "*A hook called when a summary line is changed.
837 The hook will not be called if `gnus-visual' is nil.
839 The default function `gnus-summary-highlight-line' will
840 highlight the line according to the `gnus-summary-highlight'
842 :group 'gnus-summary-visual
845 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
846 "*A hook called when an article is selected for the first time.
847 The hook is intended to mark an article as read (or unread)
848 automatically when it is selected."
849 :group 'gnus-summary-choose
852 (defcustom gnus-group-no-more-groups-hook nil
853 "*A hook run when returning to group mode having no more (unread) groups."
854 :group 'gnus-group-select
857 (defcustom gnus-ps-print-hook nil
858 "*A hook run before ps-printing something from Gnus."
862 (defcustom gnus-summary-display-arrow
863 (and (fboundp 'display-graphic-p)
865 "*If non-nil, display an arrow highlighting the current article."
870 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
871 "Face used for highlighting the current article in the summary buffer."
872 :group 'gnus-summary-visual
875 (defcustom gnus-summary-highlight
876 '(((eq mark gnus-canceled-mark)
877 . gnus-summary-cancelled-face)
878 ((and (> score default-high)
879 (or (eq mark gnus-dormant-mark)
880 (eq mark gnus-ticked-mark)))
881 . gnus-summary-high-ticked-face)
882 ((and (< score default-low)
883 (or (eq mark gnus-dormant-mark)
884 (eq mark gnus-ticked-mark)))
885 . gnus-summary-low-ticked-face)
886 ((or (eq mark gnus-dormant-mark)
887 (eq mark gnus-ticked-mark))
888 . gnus-summary-normal-ticked-face)
889 ((and (> score default-high) (eq mark gnus-ancient-mark))
890 . gnus-summary-high-ancient-face)
891 ((and (< score default-low) (eq mark gnus-ancient-mark))
892 . gnus-summary-low-ancient-face)
893 ((eq mark gnus-ancient-mark)
894 . gnus-summary-normal-ancient-face)
895 ((and (> score default-high) (eq mark gnus-unread-mark))
896 . gnus-summary-high-unread-face)
897 ((and (< score default-low) (eq mark gnus-unread-mark))
898 . gnus-summary-low-unread-face)
899 ((eq mark gnus-unread-mark)
900 . gnus-summary-normal-unread-face)
901 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
902 gnus-undownloaded-mark)))
903 . gnus-summary-high-unread-face)
904 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
905 gnus-undownloaded-mark)))
906 . gnus-summary-low-unread-face)
907 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
908 (memq article gnus-newsgroup-unreads))
909 . gnus-summary-normal-unread-face)
910 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
911 . gnus-summary-normal-read-face)
912 ((> score default-high)
913 . gnus-summary-high-read-face)
914 ((< score default-low)
915 . gnus-summary-low-read-face)
917 . gnus-summary-normal-read-face))
918 "*Controls the highlighting of summary buffer lines.
920 A list of (FORM . FACE) pairs. When deciding how a a particular
921 summary line should be displayed, each form is evaluated. The content
922 of the face field after the first true form is used. You can change
923 how those summary lines are displayed, by editing the face field.
925 You can use the following variables in the FORM field.
927 score: The article's score
928 default: The default article score.
929 default-high: The default score for high scored articles.
930 default-low: The default score for low scored articles.
931 below: The score below which articles are automatically marked as read.
932 mark: The articles mark."
933 :group 'gnus-summary-visual
934 :type '(repeat (cons (sexp :tag "Form" nil)
937 (defcustom gnus-alter-header-function nil
938 "Function called to allow alteration of article header structures.
939 The function is called with one parameter, the article header vector,
940 which it may alter in any way.")
942 (defvar gnus-decode-encoded-word-function
943 (mime-find-field-decoder 'From 'nov)
944 "Variable that says which function should be used to decode a string with encoded words.")
946 (defcustom gnus-extra-headers '(To Newsgroups)
947 "*Extra headers to parse."
950 :type '(repeat symbol))
952 (defcustom gnus-ignored-from-addresses
953 (and user-mail-address (regexp-quote user-mail-address))
954 "*Regexp of From headers that may be suppressed in favor of To headers."
959 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
960 "List of charsets that should be ignored.
961 When these charsets are used in the \"charset\" parameter, the
962 default charset will be used instead."
964 :type '(repeat symbol)
965 :group 'gnus-charset)
967 (gnus-define-group-parameter
971 "Return the ignored charsets of GROUP."
972 :variable gnus-group-ignored-charsets-alist
974 '(("alt\\.chinese\\.text" iso-8859-1))
976 "Alist of regexps (to match group names) and charsets that should be ignored.
977 When these charsets are used in the \"charset\" parameter, the
978 default charset will be used instead."
979 :variable-group gnus-charset
980 :variable-type '(repeat (cons (regexp :tag "Group")
982 :parameter-type '(choice :tag "Ignored charsets"
985 :parameter-document "\
986 List of charsets that should be ignored.
988 When these charsets are used in the \"charset\" parameter, the
989 default charset will be used instead.")
991 (defcustom gnus-group-highlight-words-alist nil
992 "Alist of group regexps and highlight regexps.
993 This variable uses the same syntax as `gnus-emphasis-alist'."
995 :type '(repeat (cons (regexp :tag "Group")
996 (repeat (list (regexp :tag "Highlight regexp")
997 (number :tag "Group for entire word" 0)
998 (number :tag "Group for displayed part" 0)
1000 gnus-emphasis-highlight-words)))))
1001 :group 'gnus-summary-visual)
1003 (defcustom gnus-use-wheel nil
1004 "Use Intelli-mouse on summary movement"
1006 :group 'gnus-summary-maneuvering)
1008 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1009 "Amount to scroll messages by spinning the mouse wheel.
1010 This is actually a cons cell, where the first item is the amount to scroll
1011 on a normal wheel event, and the second is the amount to scroll when the
1012 wheel is moved with the shift key depressed."
1013 :type '(cons (integer :tag "Shift") integer)
1014 :group 'gnus-summary-maneuvering)
1016 (defcustom gnus-wheel-edge-resistance 2
1017 "How hard it should be to change the current article
1018 by moving the mouse over the edge of the article window."
1020 :group 'gnus-summary-maneuvering)
1022 (defcustom gnus-summary-show-article-charset-alist
1024 "Alist of number and charset.
1025 The article will be shown with the charset corresponding to the
1027 For example: ((1 . cn-gb-2312) (2 . big5))."
1029 :type '(repeat (cons (number :tag "Argument" 1)
1030 (symbol :tag "Charset")))
1031 :group 'gnus-charset)
1033 (defcustom gnus-preserve-marks t
1034 "Whether marks are preserved when moving, copying and respooling messages."
1037 :group 'gnus-summary-marks)
1039 (defcustom gnus-alter-articles-to-read-function nil
1040 "Function to be called to alter the list of articles to be selected."
1041 :type '(choice (const nil) function)
1042 :group 'gnus-summary)
1044 (defcustom gnus-orphan-score nil
1045 "*All orphans get this score added. Set in the score file."
1046 :group 'gnus-score-default
1047 :type '(choice (const nil)
1050 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1051 "*A regexp to match MIME parts when saving multiple parts of a message
1052 with gnus-summary-save-parts (X m). This regexp will be used by default
1053 when prompting the user for which type of files to save."
1054 :group 'gnus-summary
1057 (defcustom gnus-read-all-available-headers nil
1058 "Whether Gnus should parse all headers made available to it.
1059 This is mostly relevant for slow backends where the user may
1060 wish to widen the summary buffer to include all headers
1061 that were fetched. Say, for nnultimate groups."
1062 :group 'gnus-summary
1063 :type '(choice boolean regexp))
1065 (defcustom gnus-summary-muttprint-program "muttprint"
1066 "Command (and optional arguments) used to run Muttprint."
1068 :group 'gnus-summary
1071 (defcustom gnus-article-loose-mime nil
1072 "If non-nil, don't require MIME-Version header.
1073 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1074 supply the MIME-Version header or deliberately strip it From the mail.
1075 Set it to non-nil, Gnus will treat some articles as MIME even if
1076 the MIME-Version header is missed."
1079 :group 'gnus-article)
1081 ;;; Internal variables
1083 (defvar gnus-summary-display-cache nil)
1084 (defvar gnus-article-mime-handles nil)
1085 (defvar gnus-article-decoded-p nil)
1086 (defvar gnus-article-charset nil)
1087 (defvar gnus-article-ignored-charsets nil)
1088 (defvar gnus-scores-exclude-files nil)
1089 (defvar gnus-page-broken nil)
1090 (defvar gnus-inhibit-mime-unbuttonizing nil)
1092 (defvar gnus-original-article nil)
1093 (defvar gnus-article-internal-prepare-hook nil)
1094 (defvar gnus-newsgroup-process-stack nil)
1096 (defvar gnus-thread-indent-array nil)
1097 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1098 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1099 "Function called to sort the articles within a thread after it has been gathered together.")
1101 (defvar gnus-summary-save-parts-type-history nil)
1102 (defvar gnus-summary-save-parts-last-directory nil)
1104 ;; Avoid highlighting in kill files.
1105 (defvar gnus-summary-inhibit-highlight nil)
1106 (defvar gnus-newsgroup-selected-overlay nil)
1107 (defvar gnus-inhibit-limiting nil)
1108 (defvar gnus-newsgroup-adaptive-score-file nil)
1109 (defvar gnus-current-score-file nil)
1110 (defvar gnus-current-move-group nil)
1111 (defvar gnus-current-copy-group nil)
1112 (defvar gnus-current-crosspost-group nil)
1113 (defvar gnus-newsgroup-display nil)
1115 (defvar gnus-newsgroup-dependencies nil)
1116 (defvar gnus-newsgroup-adaptive nil)
1117 (defvar gnus-summary-display-article-function nil)
1118 (defvar gnus-summary-highlight-line-function nil
1119 "Function called after highlighting a summary line.")
1121 (defvar gnus-summary-line-format-alist
1122 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1123 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1124 (?s gnus-tmp-subject-or-nil ?s)
1125 (?n gnus-tmp-name ?s)
1126 (?A (std11-address-string
1127 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1128 (?a (or (std11-full-name-string
1129 (car (mime-entity-read-field gnus-tmp-header 'From)))
1131 (?F gnus-tmp-from ?s)
1132 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1133 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1134 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1135 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1136 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1137 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1138 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1139 (?L gnus-tmp-lines ?s)
1140 (?I gnus-tmp-indentation ?s)
1141 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1142 (?R gnus-tmp-replied ?c)
1143 (?\[ gnus-tmp-opening-bracket ?c)
1144 (?\] gnus-tmp-closing-bracket ?c)
1145 (?\> (make-string gnus-tmp-level ? ) ?s)
1146 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1147 (?i gnus-tmp-score ?d)
1148 (?z gnus-tmp-score-char ?c)
1149 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1150 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1151 (?U gnus-tmp-unread ?c)
1152 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1154 (?t (gnus-summary-number-of-articles-in-thread
1155 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1157 (?e (gnus-summary-number-of-articles-in-thread
1158 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1160 (?u gnus-tmp-user-defined ?s)
1161 (?P (gnus-pick-line-number) ?d)
1162 (?B gnus-tmp-thread-tree-header-string ?s)
1163 (user-date (gnus-user-date
1164 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1165 "An alist of format specifications that can appear in summary lines.
1166 These are paired with what variables they correspond with, along with
1167 the type of the variable (string, integer, character, etc).")
1169 (defvar gnus-summary-dummy-line-format-alist
1170 `((?S gnus-tmp-subject ?s)
1171 (?N gnus-tmp-number ?d)
1172 (?u gnus-tmp-user-defined ?s)))
1174 (defvar gnus-summary-mode-line-format-alist
1175 `((?G gnus-tmp-group-name ?s)
1176 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1177 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1178 (?A gnus-tmp-article-number ?d)
1179 (?Z gnus-tmp-unread-and-unselected ?s)
1180 (?V gnus-version ?s)
1181 (?U gnus-tmp-unread-and-unticked ?d)
1182 (?S gnus-tmp-subject ?s)
1183 (?e gnus-tmp-unselected ?d)
1184 (?u gnus-tmp-user-defined ?s)
1185 (?d (length gnus-newsgroup-dormant) ?d)
1186 (?t (length gnus-newsgroup-marked) ?d)
1187 (?h (length gnus-newsgroup-spam-marked) ?d)
1188 (?r (length gnus-newsgroup-reads) ?d)
1189 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1190 (?E gnus-newsgroup-expunged-tally ?d)
1191 (?s (gnus-current-score-file-nondirectory) ?s)))
1193 (defvar gnus-last-search-regexp nil
1194 "Default regexp for article search command.")
1196 (defvar gnus-summary-search-article-matched-data nil
1197 "Last matched data of article search command. It is the local variable
1198 in `gnus-article-buffer' which consists of the list of start position,
1199 end position and text.")
1201 (defvar gnus-last-shell-command nil
1202 "Default shell command on article.")
1204 (defvar gnus-newsgroup-begin nil)
1205 (defvar gnus-newsgroup-end nil)
1206 (defvar gnus-newsgroup-last-rmail nil)
1207 (defvar gnus-newsgroup-last-mail nil)
1208 (defvar gnus-newsgroup-last-folder nil)
1209 (defvar gnus-newsgroup-last-file nil)
1210 (defvar gnus-newsgroup-auto-expire nil)
1211 (defvar gnus-newsgroup-active nil)
1213 (defvar gnus-newsgroup-data nil)
1214 (defvar gnus-newsgroup-data-reverse nil)
1215 (defvar gnus-newsgroup-limit nil)
1216 (defvar gnus-newsgroup-limits nil)
1218 (defvar gnus-newsgroup-unreads nil
1219 "Sorted list of unread articles in the current newsgroup.")
1221 (defvar gnus-newsgroup-unselected nil
1222 "Sorted list of unselected unread articles in the current newsgroup.")
1224 (defvar gnus-newsgroup-reads nil
1225 "Alist of read articles and article marks in the current newsgroup.")
1227 (defvar gnus-newsgroup-expunged-tally nil)
1229 (defvar gnus-newsgroup-marked nil
1230 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1232 (defvar gnus-newsgroup-spam-marked nil
1233 "List of ranges of articles that have been marked as spam.")
1235 (defvar gnus-newsgroup-killed nil
1236 "List of ranges of articles that have been through the scoring process.")
1238 (defvar gnus-newsgroup-cached nil
1239 "Sorted list of articles that come from the article cache.")
1241 (defvar gnus-newsgroup-saved nil
1242 "List of articles that have been saved.")
1244 (defvar gnus-newsgroup-kill-headers nil)
1246 (defvar gnus-newsgroup-replied nil
1247 "List of articles that have been replied to in the current newsgroup.")
1249 (defvar gnus-newsgroup-forwarded nil
1250 "List of articles that have been forwarded in the current newsgroup.")
1252 (defvar gnus-newsgroup-recent nil
1253 "List of articles that have are recent in the current newsgroup.")
1255 (defvar gnus-newsgroup-expirable nil
1256 "Sorted list of articles in the current newsgroup that can be expired.")
1258 (defvar gnus-newsgroup-processable nil
1259 "List of articles in the current newsgroup that can be processed.")
1261 (defvar gnus-newsgroup-downloadable nil
1262 "Sorted list of articles in the current newsgroup that can be processed.")
1264 (defvar gnus-newsgroup-undownloaded nil
1265 "List of articles in the current newsgroup that haven't been downloaded..")
1267 (defvar gnus-newsgroup-unsendable nil
1268 "List of articles in the current newsgroup that won't be sent.")
1270 (defvar gnus-newsgroup-bookmarks nil
1271 "List of articles in the current newsgroup that have bookmarks.")
1273 (defvar gnus-newsgroup-dormant nil
1274 "Sorted list of dormant articles in the current newsgroup.")
1276 (defvar gnus-newsgroup-unseen nil
1277 "List of unseen articles in the current newsgroup.")
1279 (defvar gnus-newsgroup-seen nil
1280 "Range of seen articles in the current newsgroup.")
1282 (defvar gnus-newsgroup-articles nil
1283 "List of articles in the current newsgroup.")
1285 (defvar gnus-newsgroup-scored nil
1286 "List of scored articles in the current newsgroup.")
1288 (defvar gnus-newsgroup-incorporated nil
1289 "List of incorporated articles in the current newsgroup.")
1291 (defvar gnus-newsgroup-headers nil
1292 "List of article headers in the current newsgroup.")
1294 (defvar gnus-newsgroup-threads nil)
1296 (defvar gnus-newsgroup-prepared nil
1297 "Whether the current group has been prepared properly.")
1299 (defvar gnus-newsgroup-ancient nil
1300 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1302 (defvar gnus-newsgroup-sparse nil)
1304 (defvar gnus-current-article nil)
1305 (defvar gnus-article-current nil)
1306 (defvar gnus-current-headers nil)
1307 (defvar gnus-have-all-headers nil)
1308 (defvar gnus-last-article nil)
1309 (defvar gnus-newsgroup-history nil)
1310 (defvar gnus-newsgroup-charset nil)
1311 (defvar gnus-newsgroup-ephemeral-charset nil)
1312 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1314 (defvar gnus-article-before-search nil)
1316 (defconst gnus-summary-local-variables
1317 '(gnus-newsgroup-name
1318 gnus-newsgroup-begin gnus-newsgroup-end
1319 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1320 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1321 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1322 gnus-newsgroup-unselected gnus-newsgroup-marked
1323 gnus-newsgroup-spam-marked
1324 gnus-newsgroup-reads gnus-newsgroup-saved
1325 gnus-newsgroup-replied gnus-newsgroup-forwarded
1326 gnus-newsgroup-recent
1327 gnus-newsgroup-expirable
1328 gnus-newsgroup-processable gnus-newsgroup-killed
1329 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1330 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1331 gnus-newsgroup-seen gnus-newsgroup-articles
1332 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1333 gnus-newsgroup-headers gnus-newsgroup-threads
1334 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1335 gnus-current-article gnus-current-headers gnus-have-all-headers
1336 gnus-last-article gnus-article-internal-prepare-hook
1337 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1338 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1339 gnus-thread-expunge-below
1340 gnus-score-alist gnus-current-score-file
1341 (gnus-summary-expunge-below . global)
1342 (gnus-summary-mark-below . global)
1343 (gnus-orphan-score . global)
1344 gnus-newsgroup-active gnus-scores-exclude-files
1345 gnus-newsgroup-history gnus-newsgroup-ancient
1346 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1347 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1348 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1349 (gnus-newsgroup-expunged-tally . 0)
1350 gnus-cache-removable-articles gnus-newsgroup-cached
1351 gnus-newsgroup-data gnus-newsgroup-data-reverse
1352 gnus-newsgroup-limit gnus-newsgroup-limits
1353 gnus-newsgroup-charset gnus-newsgroup-display
1354 gnus-newsgroup-incorporated)
1355 "Variables that are buffer-local to the summary buffers.")
1357 (defvar gnus-newsgroup-variables nil
1358 "A list of variables that have separate values in different newsgroups.
1359 A list of newsgroup (summary buffer) local variables, or cons of
1360 variables and their default values (when the default values are not
1361 nil), that should be made global while the summary buffer is active.
1362 These variables can be used to set variables in the group parameters
1363 while still allowing them to affect operations done in other
1364 buffers. For example:
1366 \(setq gnus-newsgroup-variables
1367 '(message-use-followup-to
1368 (gnus-visible-headers .
1369 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1372 ;; Byte-compiler warning.
1373 (eval-when-compile (defvar gnus-article-mode-map))
1375 ;; Subject simplification.
1377 (defun gnus-simplify-whitespace (str)
1378 "Remove excessive whitespace from STR."
1381 (while (string-match "[ \t][ \t]+" mystr)
1382 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1384 (substring mystr (match-end 0)))))
1386 (when (string-match "^[ \t]+" mystr)
1387 (setq mystr (substring mystr (match-end 0))))
1389 (when (string-match "[ \t]+$" mystr)
1390 (setq mystr (substring mystr 0 (match-beginning 0))))
1393 (defun gnus-simplify-all-whitespace (str)
1394 "Remove all whitespace from STR."
1396 (while (string-match "[ \t\n]+" mystr)
1397 (setq mystr (replace-match "" nil nil mystr)))
1400 (defsubst gnus-simplify-subject-re (subject)
1401 "Remove \"Re:\" from subject lines."
1402 (if (string-match message-subject-re-regexp subject)
1403 (substring subject (match-end 0))
1406 (defun gnus-simplify-subject (subject &optional re-only)
1407 "Remove `Re:' and words in parentheses.
1408 If RE-ONLY is non-nil, strip leading `Re:'s only."
1409 (let ((case-fold-search t)) ;Ignore case.
1410 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1411 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1412 (setq subject (substring subject (match-end 0))))
1413 ;; Remove uninteresting prefixes.
1414 (when (and (not re-only)
1415 gnus-simplify-ignored-prefixes
1416 (string-match gnus-simplify-ignored-prefixes subject))
1417 (setq subject (substring subject (match-end 0))))
1418 ;; Remove words in parentheses from end.
1420 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1421 (setq subject (substring subject 0 (match-beginning 0)))))
1422 ;; Return subject string.
1425 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1427 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1428 (goto-char (point-min))
1429 (while (re-search-forward regexp nil t)
1430 (replace-match (or newtext ""))))
1432 (defun gnus-simplify-buffer-fuzzy ()
1433 "Simplify string in the buffer fuzzily.
1434 The string in the accessible portion of the current buffer is simplified.
1435 It is assumed to be a single-line subject.
1436 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1437 matter is removed. Additional things can be deleted by setting
1438 `gnus-simplify-subject-fuzzy-regexp'."
1439 (let ((case-fold-search t)
1441 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1443 (while (not (eq modified-tick (buffer-modified-tick)))
1444 (setq modified-tick (buffer-modified-tick))
1446 ((listp gnus-simplify-subject-fuzzy-regexp)
1447 (mapcar 'gnus-simplify-buffer-fuzzy-step
1448 gnus-simplify-subject-fuzzy-regexp))
1449 (gnus-simplify-subject-fuzzy-regexp
1450 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1451 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1452 (gnus-simplify-buffer-fuzzy-step
1453 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1454 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1456 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1457 (gnus-simplify-buffer-fuzzy-step " +" " ")
1458 (gnus-simplify-buffer-fuzzy-step " $")
1459 (gnus-simplify-buffer-fuzzy-step "^ +")))
1461 (defun gnus-simplify-subject-fuzzy (subject)
1462 "Simplify a subject string fuzzily.
1463 See `gnus-simplify-buffer-fuzzy' for details."
1465 (gnus-set-work-buffer)
1466 (let ((case-fold-search t))
1467 ;; Remove uninteresting prefixes.
1468 (when (and gnus-simplify-ignored-prefixes
1469 (string-match gnus-simplify-ignored-prefixes subject))
1470 (setq subject (substring subject (match-end 0))))
1472 (inline (gnus-simplify-buffer-fuzzy))
1475 (defsubst gnus-simplify-subject-fully (subject)
1476 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1478 (gnus-simplify-subject-functions
1479 (gnus-map-function gnus-simplify-subject-functions subject))
1480 ((null gnus-summary-gather-subject-limit)
1481 (gnus-simplify-subject-re subject))
1482 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1483 (gnus-simplify-subject-fuzzy subject))
1484 ((numberp gnus-summary-gather-subject-limit)
1485 (gnus-limit-string (gnus-simplify-subject-re subject)
1486 gnus-summary-gather-subject-limit))
1490 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1491 "Check whether two subjects are equal.
1492 If optional argument simple-first is t, first argument is already
1495 ((null simple-first)
1496 (equal (gnus-simplify-subject-fully s1)
1497 (gnus-simplify-subject-fully s2)))
1500 (gnus-simplify-subject-fully s2)))))
1502 (defun gnus-summary-bubble-group ()
1503 "Increase the score of the current group.
1504 This is a handy function to add to `gnus-summary-exit-hook' to
1505 increase the score of each group you read."
1506 (gnus-group-add-score gnus-newsgroup-name))
1510 ;;; Gnus summary mode
1513 (put 'gnus-summary-mode 'mode-class 'special)
1515 (defvar gnus-article-commands-menu)
1518 ;; Non-orthogonal keys
1520 (gnus-define-keys gnus-summary-mode-map
1521 " " gnus-summary-next-page
1522 "\177" gnus-summary-prev-page
1523 [delete] gnus-summary-prev-page
1524 [backspace] gnus-summary-prev-page
1525 "\r" gnus-summary-scroll-up
1526 "\M-\r" gnus-summary-scroll-down
1527 "n" gnus-summary-next-unread-article
1528 "p" gnus-summary-prev-unread-article
1529 "N" gnus-summary-next-article
1530 "P" gnus-summary-prev-article
1531 "\M-\C-n" gnus-summary-next-same-subject
1532 "\M-\C-p" gnus-summary-prev-same-subject
1533 "\M-n" gnus-summary-next-unread-subject
1534 "\M-p" gnus-summary-prev-unread-subject
1535 "." gnus-summary-first-unread-article
1536 "," gnus-summary-best-unread-article
1537 "\M-s" gnus-summary-search-article-forward
1538 "\M-r" gnus-summary-search-article-backward
1539 "<" gnus-summary-beginning-of-article
1540 ">" gnus-summary-end-of-article
1541 "j" gnus-summary-goto-article
1542 "^" gnus-summary-refer-parent-article
1543 "\M-^" gnus-summary-refer-article
1544 "u" gnus-summary-tick-article-forward
1545 "!" gnus-summary-tick-article-forward
1546 "U" gnus-summary-tick-article-backward
1547 "d" gnus-summary-mark-as-read-forward
1548 "D" gnus-summary-mark-as-read-backward
1549 "E" gnus-summary-mark-as-expirable
1550 "\M-u" gnus-summary-clear-mark-forward
1551 "\M-U" gnus-summary-clear-mark-backward
1552 "k" gnus-summary-kill-same-subject-and-select
1553 "\C-k" gnus-summary-kill-same-subject
1554 "\M-\C-k" gnus-summary-kill-thread
1555 "\M-\C-l" gnus-summary-lower-thread
1556 "e" gnus-summary-edit-article
1557 "#" gnus-summary-mark-as-processable
1558 "\M-#" gnus-summary-unmark-as-processable
1559 "\M-\C-t" gnus-summary-toggle-threads
1560 "\M-\C-s" gnus-summary-show-thread
1561 "\M-\C-h" gnus-summary-hide-thread
1562 "\M-\C-f" gnus-summary-next-thread
1563 "\M-\C-b" gnus-summary-prev-thread
1564 [(meta down)] gnus-summary-next-thread
1565 [(meta up)] gnus-summary-prev-thread
1566 "\M-\C-u" gnus-summary-up-thread
1567 "\M-\C-d" gnus-summary-down-thread
1568 "&" gnus-summary-execute-command
1569 "c" gnus-summary-catchup-and-exit
1570 "\C-w" gnus-summary-mark-region-as-read
1571 "\C-t" gnus-summary-toggle-truncation
1572 "?" gnus-summary-mark-as-dormant
1573 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1574 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1575 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1576 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1577 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1578 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1579 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1580 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1581 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1582 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1583 "=" gnus-summary-expand-window
1584 "\C-x\C-s" gnus-summary-reselect-current-group
1585 "\M-g" gnus-summary-rescan-group
1586 "w" gnus-summary-stop-page-breaking
1587 "\C-c\C-r" gnus-summary-caesar-message
1588 "\M-t" gnus-summary-toggle-mime
1589 "f" gnus-summary-followup
1590 "F" gnus-summary-followup-with-original
1591 "C" gnus-summary-cancel-article
1592 "r" gnus-summary-reply
1593 "R" gnus-summary-reply-with-original
1594 "\C-c\C-f" gnus-summary-mail-forward
1595 "o" gnus-summary-save-article
1596 "\C-o" gnus-summary-save-article-mail
1597 "|" gnus-summary-pipe-output
1598 "\M-k" gnus-summary-edit-local-kill
1599 "\M-K" gnus-summary-edit-global-kill
1601 "\C-c\C-d" gnus-summary-describe-group
1602 "q" gnus-summary-exit
1603 "Q" gnus-summary-exit-no-update
1604 "\C-c\C-i" gnus-info-find-node
1605 gnus-mouse-2 gnus-mouse-pick-article
1606 "m" gnus-summary-mail-other-window
1607 "a" gnus-summary-post-news
1608 "i" gnus-summary-news-other-window
1609 "x" gnus-summary-limit-to-unread
1610 "s" gnus-summary-isearch-article
1611 "t" gnus-summary-toggle-header
1612 "g" gnus-summary-show-article
1613 "l" gnus-summary-goto-last-article
1614 "v" gnus-summary-preview-mime-message
1615 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1616 "\C-d" gnus-summary-enter-digest-group
1617 "\M-\C-d" gnus-summary-read-document
1618 "\M-\C-e" gnus-summary-edit-parameters
1619 "\M-\C-a" gnus-summary-customize-parameters
1621 "\C-c\C-n" gnus-namazu-search
1622 "*" gnus-cache-enter-article
1623 "\M-*" gnus-cache-remove-article
1624 "\M-&" gnus-summary-universal-argument
1625 "\C-l" gnus-recenter
1626 "I" gnus-summary-increase-score
1627 "L" gnus-summary-lower-score
1628 "\M-i" gnus-symbolic-argument
1629 "h" gnus-summary-select-article-buffer
1631 "V" gnus-summary-score-map
1632 "X" gnus-uu-extract-map
1633 "S" gnus-summary-send-map)
1635 ;; Sort of orthogonal keymap
1636 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1637 "t" gnus-summary-tick-article-forward
1638 "!" gnus-summary-tick-article-forward
1639 "d" gnus-summary-mark-as-read-forward
1640 "r" gnus-summary-mark-as-read-forward
1641 "c" gnus-summary-clear-mark-forward
1642 " " gnus-summary-clear-mark-forward
1643 "e" gnus-summary-mark-as-expirable
1644 "x" gnus-summary-mark-as-expirable
1645 "?" gnus-summary-mark-as-dormant
1646 "b" gnus-summary-set-bookmark
1647 "B" gnus-summary-remove-bookmark
1648 "#" gnus-summary-mark-as-processable
1649 "\M-#" gnus-summary-unmark-as-processable
1650 "S" gnus-summary-limit-include-expunged
1651 "C" gnus-summary-catchup
1652 "H" gnus-summary-catchup-to-here
1653 "h" gnus-summary-catchup-from-here
1654 "\C-c" gnus-summary-catchup-all
1655 "k" gnus-summary-kill-same-subject-and-select
1656 "K" gnus-summary-kill-same-subject
1657 "P" gnus-uu-mark-map)
1659 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1660 "c" gnus-summary-clear-above
1661 "u" gnus-summary-tick-above
1662 "m" gnus-summary-mark-above
1663 "k" gnus-summary-kill-below)
1665 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1666 "/" gnus-summary-limit-to-subject
1667 "n" gnus-summary-limit-to-articles
1668 "w" gnus-summary-pop-limit
1669 "s" gnus-summary-limit-to-subject
1670 "a" gnus-summary-limit-to-author
1671 "u" gnus-summary-limit-to-unread
1672 "m" gnus-summary-limit-to-marks
1673 "M" gnus-summary-limit-exclude-marks
1674 "v" gnus-summary-limit-to-score
1675 "*" gnus-summary-limit-include-cached
1676 "D" gnus-summary-limit-include-dormant
1677 "T" gnus-summary-limit-include-thread
1678 "d" gnus-summary-limit-exclude-dormant
1679 "t" gnus-summary-limit-to-age
1680 "x" gnus-summary-limit-to-extra
1681 "p" gnus-summary-limit-to-display-predicate
1682 "E" gnus-summary-limit-include-expunged
1683 "c" gnus-summary-limit-exclude-childless-dormant
1684 "C" gnus-summary-limit-mark-excluded-as-read
1685 "o" gnus-summary-insert-old-articles
1686 "N" gnus-summary-insert-new-articles)
1688 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1689 "n" gnus-summary-next-unread-article
1690 "p" gnus-summary-prev-unread-article
1691 "N" gnus-summary-next-article
1692 "P" gnus-summary-prev-article
1693 "\C-n" gnus-summary-next-same-subject
1694 "\C-p" gnus-summary-prev-same-subject
1695 "\M-n" gnus-summary-next-unread-subject
1696 "\M-p" gnus-summary-prev-unread-subject
1697 "f" gnus-summary-first-unread-article
1698 "b" gnus-summary-best-unread-article
1699 "j" gnus-summary-goto-article
1700 "g" gnus-summary-goto-subject
1701 "l" gnus-summary-goto-last-article
1702 "o" gnus-summary-pop-article)
1704 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1705 "k" gnus-summary-kill-thread
1706 "l" gnus-summary-lower-thread
1707 "i" gnus-summary-raise-thread
1708 "T" gnus-summary-toggle-threads
1709 "t" gnus-summary-rethread-current
1710 "^" gnus-summary-reparent-thread
1711 "s" gnus-summary-show-thread
1712 "S" gnus-summary-show-all-threads
1713 "h" gnus-summary-hide-thread
1714 "H" gnus-summary-hide-all-threads
1715 "n" gnus-summary-next-thread
1716 "p" gnus-summary-prev-thread
1717 "u" gnus-summary-up-thread
1718 "o" gnus-summary-top-thread
1719 "d" gnus-summary-down-thread
1720 "#" gnus-uu-mark-thread
1721 "\M-#" gnus-uu-unmark-thread)
1723 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1724 "g" gnus-summary-prepare
1725 "c" gnus-summary-insert-cached-articles)
1727 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1728 "c" gnus-summary-catchup-and-exit
1729 "C" gnus-summary-catchup-all-and-exit
1730 "E" gnus-summary-exit-no-update
1731 "J" gnus-summary-jump-to-other-group
1732 "Q" gnus-summary-exit
1733 "Z" gnus-summary-exit
1734 "n" gnus-summary-catchup-and-goto-next-group
1735 "R" gnus-summary-reselect-current-group
1736 "G" gnus-summary-rescan-group
1737 "N" gnus-summary-next-group
1738 "s" gnus-summary-save-newsrc
1739 "P" gnus-summary-prev-group)
1741 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1742 " " gnus-summary-next-page
1743 "n" gnus-summary-next-page
1744 "\177" gnus-summary-prev-page
1745 [delete] gnus-summary-prev-page
1746 "p" gnus-summary-prev-page
1747 "\r" gnus-summary-scroll-up
1748 "\M-\r" gnus-summary-scroll-down
1749 "<" gnus-summary-beginning-of-article
1750 ">" gnus-summary-end-of-article
1751 "b" gnus-summary-beginning-of-article
1752 "e" gnus-summary-end-of-article
1753 "^" gnus-summary-refer-parent-article
1754 "r" gnus-summary-refer-parent-article
1755 "D" gnus-summary-enter-digest-group
1756 "R" gnus-summary-refer-references
1757 "T" gnus-summary-refer-thread
1758 "g" gnus-summary-show-article
1759 "s" gnus-summary-isearch-article
1760 "P" gnus-summary-print-article
1761 "M" gnus-mailing-list-insinuate
1762 "t" gnus-article-babel)
1764 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1765 "b" gnus-article-add-buttons
1766 "B" gnus-article-add-buttons-to-head
1767 "o" gnus-article-treat-overstrike
1768 "e" gnus-article-emphasize
1769 "w" gnus-article-fill-cited-article
1770 "Q" gnus-article-fill-long-lines
1771 "C" gnus-article-capitalize-sentences
1772 "c" gnus-article-remove-cr
1773 "Z" gnus-article-decode-HZ
1774 "h" gnus-article-wash-html
1775 "u" gnus-article-unsplit-urls
1776 "f" gnus-article-display-x-face
1777 "l" gnus-summary-stop-page-breaking
1778 "r" gnus-summary-caesar-message
1779 "t" gnus-summary-toggle-header
1780 "g" gnus-treat-smiley
1781 "v" gnus-summary-verbose-headers
1782 "m" gnus-summary-toggle-mime
1783 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1784 "p" gnus-article-verify-x-pgp-sig
1785 "d" gnus-article-treat-dumbquotes
1786 "k" gnus-article-outlook-deuglify-article)
1788 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1789 "a" gnus-article-hide
1790 "h" gnus-article-hide-headers
1791 "b" gnus-article-hide-boring-headers
1792 "s" gnus-article-hide-signature
1793 "c" gnus-article-hide-citation
1794 "C" gnus-article-hide-citation-in-followups
1795 "l" gnus-article-hide-list-identifiers
1796 "p" gnus-article-hide-pgp
1797 "B" gnus-article-strip-banner
1798 "P" gnus-article-hide-pem
1799 "\C-c" gnus-article-hide-citation-maybe)
1801 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1802 "a" gnus-article-highlight
1803 "h" gnus-article-highlight-headers
1804 "c" gnus-article-highlight-citation
1805 "s" gnus-article-highlight-signature)
1807 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1808 "f" gnus-article-treat-fold-headers
1809 "u" gnus-article-treat-unfold-headers
1810 "n" gnus-article-treat-fold-newsgroups)
1812 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1813 "x" gnus-article-display-x-face
1814 "s" gnus-treat-smiley
1815 "D" gnus-article-remove-images
1816 "f" gnus-treat-from-picon
1817 "m" gnus-treat-mail-picon
1818 "n" gnus-treat-newsgroups-picon)
1820 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1821 "z" gnus-article-date-ut
1822 "u" gnus-article-date-ut
1823 "l" gnus-article-date-local
1824 "p" gnus-article-date-english
1825 "e" gnus-article-date-lapsed
1826 "o" gnus-article-date-original
1827 "i" gnus-article-date-iso8601
1828 "s" gnus-article-date-user)
1830 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1831 "t" gnus-article-remove-trailing-blank-lines
1832 "l" gnus-article-strip-leading-blank-lines
1833 "m" gnus-article-strip-multiple-blank-lines
1834 "a" gnus-article-strip-blank-lines
1835 "A" gnus-article-strip-all-blank-lines
1836 "s" gnus-article-strip-leading-space
1837 "e" gnus-article-strip-trailing-space
1838 "w" gnus-article-remove-leading-whitespace)
1840 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1842 "f" gnus-summary-fetch-faq
1843 "d" gnus-summary-describe-group
1844 "h" gnus-summary-describe-briefly
1845 "i" gnus-info-find-node)
1847 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1848 "e" gnus-summary-expire-articles
1849 "\M-\C-e" gnus-summary-expire-articles-now
1850 "\177" gnus-summary-delete-article
1851 [delete] gnus-summary-delete-article
1852 [backspace] gnus-summary-delete-article
1853 "m" gnus-summary-move-article
1854 "r" gnus-summary-respool-article
1855 "w" gnus-summary-edit-article
1856 "c" gnus-summary-copy-article
1857 "B" gnus-summary-crosspost-article
1858 "q" gnus-summary-respool-query
1859 "t" gnus-summary-respool-trace
1860 "i" gnus-summary-import-article
1861 "I" gnus-summary-create-article
1862 "p" gnus-summary-article-posted-p)
1864 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1865 "o" gnus-summary-save-article
1866 "m" gnus-summary-save-article-mail
1867 "F" gnus-summary-write-article-file
1868 "r" gnus-summary-save-article-rmail
1869 "f" gnus-summary-save-article-file
1870 "b" gnus-summary-save-article-body-file
1871 "h" gnus-summary-save-article-folder
1872 "v" gnus-summary-save-article-vm
1873 "p" gnus-summary-pipe-output
1874 "P" gnus-summary-muttprint
1875 "s" gnus-soup-add-article)
1877 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1878 "b" gnus-summary-display-buttonized
1879 "m" gnus-summary-repair-multipart
1880 "v" gnus-article-view-part
1881 "o" gnus-article-save-part
1882 "c" gnus-article-copy-part
1883 "C" gnus-article-view-part-as-charset
1884 "e" gnus-article-view-part-externally
1885 "E" gnus-article-encrypt-body
1886 "i" gnus-article-inline-part
1887 "|" gnus-article-pipe-part)
1889 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1890 "p" gnus-summary-mark-as-processable
1891 "u" gnus-summary-unmark-as-processable
1892 "U" gnus-summary-unmark-all-processable
1893 "v" gnus-uu-mark-over
1894 "s" gnus-uu-mark-series
1895 "r" gnus-uu-mark-region
1896 "g" gnus-uu-unmark-region
1897 "R" gnus-uu-mark-by-regexp
1898 "G" gnus-uu-unmark-by-regexp
1899 "t" gnus-uu-mark-thread
1900 "T" gnus-uu-unmark-thread
1901 "a" gnus-uu-mark-all
1902 "b" gnus-uu-mark-buffer
1903 "S" gnus-uu-mark-sparse
1904 "k" gnus-summary-kill-process-mark
1905 "y" gnus-summary-yank-process-mark
1906 "w" gnus-summary-save-process-mark
1907 "i" gnus-uu-invert-processable)
1909 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1910 ;;"x" gnus-uu-extract-any
1911 "m" gnus-summary-save-parts
1912 "u" gnus-uu-decode-uu
1913 "U" gnus-uu-decode-uu-and-save
1914 "s" gnus-uu-decode-unshar
1915 "S" gnus-uu-decode-unshar-and-save
1916 "o" gnus-uu-decode-save
1917 "O" gnus-uu-decode-save
1918 "b" gnus-uu-decode-binhex
1919 "B" gnus-uu-decode-binhex
1920 "p" gnus-uu-decode-postscript
1921 "P" gnus-uu-decode-postscript-and-save)
1924 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1925 "u" gnus-uu-decode-uu-view
1926 "U" gnus-uu-decode-uu-and-save-view
1927 "s" gnus-uu-decode-unshar-view
1928 "S" gnus-uu-decode-unshar-and-save-view
1929 "o" gnus-uu-decode-save-view
1930 "O" gnus-uu-decode-save-view
1931 "b" gnus-uu-decode-binhex-view
1932 "B" gnus-uu-decode-binhex-view
1933 "p" gnus-uu-decode-postscript-view
1934 "P" gnus-uu-decode-postscript-and-save-view))
1936 (defvar gnus-article-post-menu nil)
1938 (defconst gnus-summary-menu-maxlen 20)
1940 (defun gnus-summary-menu-split (menu)
1941 ;; If we have lots of elements, divide them into groups of 20
1942 ;; and make a pane (or submenu) for each one.
1943 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1944 (let ((menu menu) sublists next
1947 ;; Pull off the next gnus-summary-menu-maxlen elements
1948 ;; and make them the next element of sublist.
1949 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1951 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1953 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1954 (aref (car (last menu)) 0)) menu)
1958 (nreverse sublists))
1959 ;; Few elements--put them all in one pane.
1962 (defun gnus-summary-make-menu-bar ()
1963 (gnus-turn-off-edit-menu 'summary)
1965 (unless (boundp 'gnus-summary-misc-menu)
1968 gnus-summary-kill-menu gnus-summary-mode-map ""
1973 ["Customize" gnus-score-customize t])
1974 (gnus-make-score-map 'increase)
1975 (gnus-make-score-map 'lower)
1977 ["Kill below" gnus-summary-kill-below t]
1978 ["Mark above" gnus-summary-mark-above t]
1979 ["Tick above" gnus-summary-tick-above t]
1980 ["Clear above" gnus-summary-clear-above t])
1981 ["Current score" gnus-summary-current-score t]
1982 ["Set score" gnus-summary-set-score t]
1983 ["Switch current score file..." gnus-score-change-score-file t]
1984 ["Set mark below..." gnus-score-set-mark-below t]
1985 ["Set expunge below..." gnus-score-set-expunge-below t]
1986 ["Edit current score file" gnus-score-edit-current-scores t]
1987 ["Edit score file" gnus-score-edit-file t]
1988 ["Trace score" gnus-score-find-trace t]
1989 ["Find words" gnus-score-find-favourite-words t]
1990 ["Rescore buffer" gnus-summary-rescore t]
1991 ["Increase score..." gnus-summary-increase-score t]
1992 ["Lower score..." gnus-summary-lower-score t]))))
1994 ;; Define both the Article menu in the summary buffer and the
1995 ;; equivalent Commands menu in the article buffer here for
1999 ["All" gnus-article-hide t]
2000 ["Headers" gnus-article-hide-headers t]
2001 ["Signature" gnus-article-hide-signature t]
2002 ["Citation" gnus-article-hide-citation t]
2003 ["List identifiers" gnus-article-hide-list-identifiers t]
2004 ["PGP" gnus-article-hide-pgp t]
2005 ["Banner" gnus-article-strip-banner t]
2006 ["Boring headers" gnus-article-hide-boring-headers t])
2008 ["All" gnus-article-highlight t]
2009 ["Headers" gnus-article-highlight-headers t]
2010 ["Signature" gnus-article-highlight-signature t]
2011 ["Citation" gnus-article-highlight-citation t])
2013 ["Local" gnus-article-date-local t]
2014 ["ISO8601" gnus-article-date-iso8601 t]
2015 ["UT" gnus-article-date-ut t]
2016 ["Original" gnus-article-date-original t]
2017 ["Lapsed" gnus-article-date-lapsed t]
2018 ["User-defined" gnus-article-date-user t])
2020 ["Remove images" gnus-article-remove-images t]
2021 ["Toggle smiley" gnus-treat-smiley t]
2022 ["Show X-Face" gnus-article-display-x-face t]
2023 ["Show picons in From" gnus-treat-from-picon t]
2024 ["Show picons in mail headers" gnus-treat-mail-picon t]
2025 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2026 ("View as different encoding"
2027 ,@(gnus-summary-menu-split
2030 ;; Since easymenu under FSF Emacs doesn't allow lambda
2031 ;; forms for menu commands, we should provide intern'ed
2032 ;; function symbols.
2033 (let ((command (intern (format "\
2034 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2038 (let ((gnus-summary-show-article-charset-alist
2040 (gnus-summary-show-article 1))))
2041 `[,(symbol-name cs) ,command t]))
2042 (sort (if (fboundp 'coding-system-list)
2043 (coding-system-list)
2044 ;;(mapcar 'car mm-mime-mule-charset-alist)
2047 (string< (symbol-name a)
2048 (symbol-name b))))))))
2051 ["Leading" gnus-article-strip-leading-blank-lines t]
2052 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2053 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2054 ["All of the above" gnus-article-strip-blank-lines t]
2055 ["All" gnus-article-strip-all-blank-lines t]
2056 ["Leading space" gnus-article-strip-leading-space t]
2057 ["Trailing space" gnus-article-strip-trailing-space t]
2058 ["Leading space in headers"
2059 gnus-article-remove-leading-whitespace t])
2060 ["Overstrike" gnus-article-treat-overstrike t]
2061 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2062 ["Emphasis" gnus-article-emphasize t]
2063 ["Word wrap" gnus-article-fill-cited-article t]
2064 ["Fill long lines" gnus-article-fill-long-lines t]
2065 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2066 ["CR" gnus-article-remove-cr t]
2067 ["Rot 13" gnus-summary-caesar-message
2068 ,@(if (featurep 'xemacs) '(t)
2069 '(:help "\"Caesar rotate\" article by 13"))]
2070 ["Unix pipe" gnus-summary-pipe-message t]
2071 ["Add buttons" gnus-article-add-buttons t]
2072 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2073 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2074 ["Toggle MIME" gnus-summary-toggle-mime t]
2075 ["Verbose header" gnus-summary-verbose-headers t]
2076 ["Toggle header" gnus-summary-toggle-header t]
2077 ["Unfold headers" gnus-article-treat-unfold-headers t]
2078 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2079 ["Html" gnus-article-wash-html t]
2080 ["URLs" gnus-article-unsplit-urls t]
2081 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2082 ["HZ" gnus-article-decode-HZ t]
2083 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2086 ["Save in default format" gnus-summary-save-article
2087 ,@(if (featurep 'xemacs) '(t)
2088 '(:help "Save article using default method"))]
2089 ["Save in file" gnus-summary-save-article-file
2090 ,@(if (featurep 'xemacs) '(t)
2091 '(:help "Save article in file"))]
2092 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2093 ["Save in MH folder" gnus-summary-save-article-folder t]
2094 ["Save in VM folder" gnus-summary-save-article-vm t]
2095 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2096 ["Save body in file" gnus-summary-save-article-body-file t]
2097 ["Pipe through a filter" gnus-summary-pipe-output t]
2098 ["Add to SOUP packet" gnus-soup-add-article t]
2099 ["Print with Muttprint" gnus-summary-muttprint t]
2100 ["Print" gnus-summary-print-article t])
2102 ["Respool article..." gnus-summary-respool-article t]
2103 ["Move article..." gnus-summary-move-article
2104 (gnus-check-backend-function
2105 'request-move-article gnus-newsgroup-name)]
2106 ["Copy article..." gnus-summary-copy-article t]
2107 ["Crosspost article..." gnus-summary-crosspost-article
2108 (gnus-check-backend-function
2109 'request-replace-article gnus-newsgroup-name)]
2110 ["Import file..." gnus-summary-import-article t]
2111 ["Create article..." gnus-summary-create-article t]
2112 ["Check if posted" gnus-summary-article-posted-p t]
2113 ["Edit article" gnus-summary-edit-article
2114 (not (gnus-group-read-only-p))]
2115 ["Delete article" gnus-summary-delete-article
2116 (gnus-check-backend-function
2117 'request-expire-articles gnus-newsgroup-name)]
2118 ["Query respool" gnus-summary-respool-query t]
2119 ["Trace respool" gnus-summary-respool-trace t]
2120 ["Delete expirable articles" gnus-summary-expire-articles-now
2121 (gnus-check-backend-function
2122 'request-expire-articles gnus-newsgroup-name)])
2124 ["Uudecode" gnus-uu-decode-uu
2125 ,@(if (featurep 'xemacs) '(t)
2126 '(:help "Decode uuencoded article(s)"))]
2127 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2128 ["Unshar" gnus-uu-decode-unshar t]
2129 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2130 ["Save" gnus-uu-decode-save t]
2131 ["Binhex" gnus-uu-decode-binhex t]
2132 ["Postscript" gnus-uu-decode-postscript t])
2134 ["Enter article" gnus-cache-enter-article t]
2135 ["Remove article" gnus-cache-remove-article t])
2136 ["Translate" gnus-article-babel t]
2137 ["Select article buffer" gnus-summary-select-article-buffer t]
2138 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2139 ["Isearch article..." gnus-summary-isearch-article t]
2140 ["Beginning of the article" gnus-summary-beginning-of-article t]
2141 ["End of the article" gnus-summary-end-of-article t]
2142 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2143 ["Fetch referenced articles" gnus-summary-refer-references t]
2144 ["Fetch current thread" gnus-summary-refer-thread t]
2145 ["Fetch article with id..." gnus-summary-refer-article t]
2146 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2147 ["Redisplay" gnus-summary-show-article t]
2148 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2150 gnus-summary-article-menu gnus-summary-mode-map ""
2151 (cons "Article" innards))
2153 (if (not (keymapp gnus-summary-article-menu))
2155 gnus-article-commands-menu gnus-article-mode-map ""
2156 (cons "Commands" innards))
2157 ;; in Emacs, don't share menu.
2158 (setq gnus-article-commands-menu
2159 (copy-keymap gnus-summary-article-menu))
2160 (define-key gnus-article-mode-map [menu-bar commands]
2161 (cons "Commands" gnus-article-commands-menu))))
2164 gnus-summary-thread-menu gnus-summary-mode-map ""
2166 ["Toggle threading" gnus-summary-toggle-threads t]
2167 ["Hide threads" gnus-summary-hide-all-threads t]
2168 ["Show threads" gnus-summary-show-all-threads t]
2169 ["Hide thread" gnus-summary-hide-thread t]
2170 ["Show thread" gnus-summary-show-thread t]
2171 ["Go to next thread" gnus-summary-next-thread t]
2172 ["Go to previous thread" gnus-summary-prev-thread t]
2173 ["Go down thread" gnus-summary-down-thread t]
2174 ["Go up thread" gnus-summary-up-thread t]
2175 ["Top of thread" gnus-summary-top-thread t]
2176 ["Mark thread as read" gnus-summary-kill-thread t]
2177 ["Lower thread score" gnus-summary-lower-thread t]
2178 ["Raise thread score" gnus-summary-raise-thread t]
2179 ["Rethread current" gnus-summary-rethread-current t]))
2182 gnus-summary-post-menu gnus-summary-mode-map ""
2184 ["Send a message (mail or news)" gnus-summary-post-news
2185 ,@(if (featurep 'xemacs) '(t)
2186 '(:help "Post an article"))]
2187 ["Followup" gnus-summary-followup
2188 ,@(if (featurep 'xemacs) '(t)
2189 '(:help "Post followup to this article"))]
2190 ["Followup and yank" gnus-summary-followup-with-original
2191 ,@(if (featurep 'xemacs) '(t)
2192 '(:help "Post followup to this article, quoting its contents"))]
2193 ["Supersede article" gnus-summary-supersede-article t]
2194 ["Cancel article" gnus-summary-cancel-article
2195 ,@(if (featurep 'xemacs) '(t)
2196 '(:help "Cancel an article you posted"))]
2197 ["Reply" gnus-summary-reply t]
2198 ["Reply and yank" gnus-summary-reply-with-original t]
2199 ["Wide reply" gnus-summary-wide-reply t]
2200 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Mail a reply, quoting this article"))]
2203 ["Very wide reply" gnus-summary-very-wide-reply t]
2204 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2205 ,@(if (featurep 'xemacs) '(t)
2206 '(:help "Mail a very wide reply, quoting this article"))]
2207 ["Mail forward" gnus-summary-mail-forward t]
2208 ["Post forward" gnus-summary-post-forward t]
2209 ["Digest and mail" gnus-summary-digest-mail-forward t]
2210 ["Digest and post" gnus-summary-digest-post-forward t]
2211 ["Resend message" gnus-summary-resend-message t]
2212 ["Resend message edit" gnus-summary-resend-message-edit t]
2213 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2214 ["Send a mail" gnus-summary-mail-other-window t]
2215 ["Create a local message" gnus-summary-news-other-window t]
2216 ["Uuencode and post" gnus-uu-post-news
2217 ,@(if (featurep 'xemacs) '(t)
2218 '(:help "Post a uuencoded article"))]
2219 ["Followup via news" gnus-summary-followup-to-mail t]
2220 ["Followup via news and yank"
2221 gnus-summary-followup-to-mail-with-original t]
2223 ;;["Send" gnus-summary-send-draft t]
2224 ;;["Send bounced" gnus-resend-bounced-mail t])
2228 ((not (keymapp gnus-summary-post-menu))
2229 (setq gnus-article-post-menu gnus-summary-post-menu))
2230 ((not gnus-article-post-menu)
2231 ;; Don't share post menu.
2232 (setq gnus-article-post-menu
2233 (copy-keymap gnus-summary-post-menu))))
2234 (define-key gnus-article-mode-map [menu-bar post]
2235 (cons "Post" gnus-article-post-menu))
2238 gnus-summary-misc-menu gnus-summary-mode-map ""
2241 ["Mark as read" gnus-summary-mark-as-read-forward t]
2242 ["Mark same subject and select"
2243 gnus-summary-kill-same-subject-and-select t]
2244 ["Mark same subject" gnus-summary-kill-same-subject t]
2245 ["Catchup" gnus-summary-catchup
2246 ,@(if (featurep 'xemacs) '(t)
2247 '(:help "Mark unread articles in this group as read"))]
2248 ["Catchup all" gnus-summary-catchup-all t]
2249 ["Catchup to here" gnus-summary-catchup-to-here t]
2250 ["Catchup from here" gnus-summary-catchup-from-here t]
2251 ["Catchup region" gnus-summary-mark-region-as-read t]
2252 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2254 ["Tick" gnus-summary-tick-article-forward t]
2255 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2256 ["Remove marks" gnus-summary-clear-mark-forward t]
2257 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2258 ["Set bookmark" gnus-summary-set-bookmark t]
2259 ["Remove bookmark" gnus-summary-remove-bookmark t])
2261 ["Marks..." gnus-summary-limit-to-marks t]
2262 ["Subject..." gnus-summary-limit-to-subject t]
2263 ["Author..." gnus-summary-limit-to-author t]
2264 ["Age..." gnus-summary-limit-to-age t]
2265 ["Extra..." gnus-summary-limit-to-extra t]
2266 ["Score" gnus-summary-limit-to-score t]
2267 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2268 ["Unread" gnus-summary-limit-to-unread t]
2269 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2270 ["Articles" gnus-summary-limit-to-articles t]
2271 ["Pop limit" gnus-summary-pop-limit t]
2272 ["Show dormant" gnus-summary-limit-include-dormant t]
2273 ["Hide childless dormant"
2274 gnus-summary-limit-exclude-childless-dormant t]
2275 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2276 ["Hide marked" gnus-summary-limit-exclude-marks t]
2277 ["Show expunged" gnus-summary-limit-include-expunged t])
2279 ["Set mark" gnus-summary-mark-as-processable t]
2280 ["Remove mark" gnus-summary-unmark-as-processable t]
2281 ["Remove all marks" gnus-summary-unmark-all-processable t]
2282 ["Mark above" gnus-uu-mark-over t]
2283 ["Mark series" gnus-uu-mark-series t]
2284 ["Mark region" gnus-uu-mark-region t]
2285 ["Unmark region" gnus-uu-unmark-region t]
2286 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2287 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2288 ["Mark all" gnus-uu-mark-all t]
2289 ["Mark buffer" gnus-uu-mark-buffer t]
2290 ["Mark sparse" gnus-uu-mark-sparse t]
2291 ["Mark thread" gnus-uu-mark-thread t]
2292 ["Unmark thread" gnus-uu-unmark-thread t]
2293 ("Process Mark Sets"
2294 ["Kill" gnus-summary-kill-process-mark t]
2295 ["Yank" gnus-summary-yank-process-mark
2296 gnus-newsgroup-process-stack]
2297 ["Save" gnus-summary-save-process-mark t]))
2299 ["Page forward" gnus-summary-next-page
2300 ,@(if (featurep 'xemacs) '(t)
2301 '(:help "Show next page of article"))]
2302 ["Page backward" gnus-summary-prev-page
2303 ,@(if (featurep 'xemacs) '(t)
2304 '(:help "Show previous page of article"))]
2305 ["Line forward" gnus-summary-scroll-up t])
2307 ["Next unread article" gnus-summary-next-unread-article t]
2308 ["Previous unread article" gnus-summary-prev-unread-article t]
2309 ["Next article" gnus-summary-next-article t]
2310 ["Previous article" gnus-summary-prev-article t]
2311 ["Next unread subject" gnus-summary-next-unread-subject t]
2312 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2313 ["Next article same subject" gnus-summary-next-same-subject t]
2314 ["Previous article same subject" gnus-summary-prev-same-subject t]
2315 ["First unread article" gnus-summary-first-unread-article t]
2316 ["Best unread article" gnus-summary-best-unread-article t]
2317 ["Go to subject number..." gnus-summary-goto-subject t]
2318 ["Go to article number..." gnus-summary-goto-article t]
2319 ["Go to the last article" gnus-summary-goto-last-article t]
2320 ["Pop article off history" gnus-summary-pop-article t])
2322 ["Sort by number" gnus-summary-sort-by-number t]
2323 ["Sort by author" gnus-summary-sort-by-author t]
2324 ["Sort by subject" gnus-summary-sort-by-subject t]
2325 ["Sort by date" gnus-summary-sort-by-date t]
2326 ["Sort by score" gnus-summary-sort-by-score t]
2327 ["Sort by lines" gnus-summary-sort-by-lines t]
2328 ["Sort by characters" gnus-summary-sort-by-chars t]
2329 ["Randomize" gnus-summary-sort-by-random t]
2330 ["Original sort" gnus-summary-sort-by-original t])
2332 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2333 ["Describe group" gnus-summary-describe-group t]
2334 ["Read manual" gnus-info-find-node t])
2336 ["Pick and read" gnus-pick-mode t]
2337 ["Binary" gnus-binary-mode t])
2339 ["Regenerate" gnus-summary-prepare t]
2340 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2341 ["Toggle threading" gnus-summary-toggle-threads t])
2342 ["See old articles" gnus-summary-insert-old-articles t]
2343 ["See new articles" gnus-summary-insert-new-articles t]
2344 ["Filter articles..." gnus-summary-execute-command t]
2345 ["Run command on subjects..." gnus-summary-universal-argument t]
2346 ["Search articles forward..." gnus-summary-search-article-forward t]
2347 ["Search articles backward..." gnus-summary-search-article-backward t]
2348 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2349 ["Expand window" gnus-summary-expand-window t]
2350 ["Expire expirable articles" gnus-summary-expire-articles
2351 (gnus-check-backend-function
2352 'request-expire-articles gnus-newsgroup-name)]
2353 ["Edit local kill file" gnus-summary-edit-local-kill t]
2354 ["Edit main kill file" gnus-summary-edit-global-kill t]
2355 ["Edit group parameters" gnus-summary-edit-parameters t]
2356 ["Customize group parameters" gnus-summary-customize-parameters t]
2357 ["Send a bug report" gnus-bug t]
2359 ["Catchup and exit" gnus-summary-catchup-and-exit
2360 ,@(if (featurep 'xemacs) '(t)
2361 '(:help "Mark unread articles in this group as read, then exit"))]
2362 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2363 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2364 ["Exit group" gnus-summary-exit
2365 ,@(if (featurep 'xemacs) '(t)
2366 '(:help "Exit current group, return to group selection mode"))]
2367 ["Exit group without updating" gnus-summary-exit-no-update t]
2368 ["Exit and goto next group" gnus-summary-next-group t]
2369 ["Exit and goto prev group" gnus-summary-prev-group t]
2370 ["Reselect group" gnus-summary-reselect-current-group t]
2371 ["Rescan group" gnus-summary-rescan-group t]
2372 ["Update dribble" gnus-summary-save-newsrc t])))
2374 (gnus-run-hooks 'gnus-summary-menu-hook)))
2376 (defvar gnus-summary-tool-bar-map nil)
2378 ;; Emacs 21 tool bar. Should be no-op otherwise.
2379 (defun gnus-summary-make-tool-bar ()
2380 (if (and (fboundp 'tool-bar-add-item-from-menu)
2381 (default-value 'tool-bar-mode)
2382 (not gnus-summary-tool-bar-map))
2383 (setq gnus-summary-tool-bar-map
2384 (let ((tool-bar-map (make-sparse-keymap))
2385 (load-path (mm-image-load-path)))
2386 (tool-bar-add-item-from-menu
2387 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2388 (tool-bar-add-item-from-menu
2389 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2390 (tool-bar-add-item-from-menu
2391 'gnus-summary-post-news "post" gnus-summary-mode-map)
2392 (tool-bar-add-item-from-menu
2393 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2394 (tool-bar-add-item-from-menu
2395 'gnus-summary-followup "followup" gnus-summary-mode-map)
2396 (tool-bar-add-item-from-menu
2397 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2398 (tool-bar-add-item-from-menu
2399 'gnus-summary-reply "reply" gnus-summary-mode-map)
2400 (tool-bar-add-item-from-menu
2401 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2402 (tool-bar-add-item-from-menu
2403 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2404 (tool-bar-add-item-from-menu
2405 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2406 (tool-bar-add-item-from-menu
2407 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2408 (tool-bar-add-item-from-menu
2409 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2410 (tool-bar-add-item-from-menu
2411 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2412 (tool-bar-add-item-from-menu
2413 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2414 (tool-bar-add-item-from-menu
2415 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2417 (if gnus-summary-tool-bar-map
2418 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2420 (defun gnus-score-set-default (var value)
2421 "A version of set that updates the GNU Emacs menu-bar."
2423 ;; It is the message that forces the active status to be updated.
2426 (defun gnus-make-score-map (type)
2427 "Make a summary score map of type TYPE."
2430 (let ((headers '(("author" "from" string)
2431 ("subject" "subject" string)
2432 ("article body" "body" string)
2433 ("article head" "head" string)
2434 ("xref" "xref" string)
2435 ("extra header" "extra" string)
2436 ("lines" "lines" number)
2437 ("followups to author" "followup" string)))
2438 (types '((number ("less than" <)
2441 (string ("substring" s)
2445 (perms '(("temporary" (current-time-string))
2453 (if (eq type 'lower)
2458 (setq header (car headers))
2464 (let ((ts (cdr (assoc (nth 2 header) types)))
2480 'gnus-summary-score-entry
2482 (if (or (string= (nth 1 header)
2484 (string= (nth 1 header)
2487 (list 'gnus-summary-header
2489 (list 'quote (nth 1 (car ts)))
2490 (list 'gnus-score-delta-default
2497 (list (nreverse outp))))
2500 (list (nreverse outt))))
2502 (setq headers (cdr headers)))
2503 (list (nreverse outh))))))))
2507 (defun gnus-summary-mode (&optional group)
2508 "Major mode for reading articles.
2510 All normal editing commands are switched off.
2511 \\<gnus-summary-mode-map>
2512 Each line in this buffer represents one article. To read an
2513 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2514 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2517 You can also post articles and send mail from this buffer. To
2518 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2519 of an article, type `\\[gnus-summary-reply]'.
2521 There are approx. one gazillion commands you can execute in this
2522 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2524 The following commands are available:
2526 \\{gnus-summary-mode-map}"
2528 (kill-all-local-variables)
2529 (when (gnus-visual-p 'summary-menu 'menu)
2530 (gnus-summary-make-menu-bar)
2531 (gnus-summary-make-tool-bar))
2532 (gnus-summary-make-local-variables)
2533 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2534 (gnus-summary-make-local-variables))
2535 (gnus-make-thread-indent-array)
2536 (gnus-simplify-mode-line)
2537 (setq major-mode 'gnus-summary-mode)
2538 (setq mode-name "Summary")
2539 (make-local-variable 'minor-mode-alist)
2540 (use-local-map gnus-summary-mode-map)
2541 (buffer-disable-undo)
2542 (setq buffer-read-only t) ;Disable modification
2543 (setq truncate-lines t)
2544 (setq selective-display t)
2545 (setq selective-display-ellipses t) ;Display `...'
2546 (gnus-summary-set-display-table)
2547 (gnus-set-default-directory)
2548 (setq gnus-newsgroup-name group)
2549 (unless (gnus-news-group-p group)
2550 (setq gnus-newsgroup-incorporated
2551 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2552 (make-local-variable 'gnus-summary-line-format)
2553 (make-local-variable 'gnus-summary-line-format-spec)
2554 (make-local-variable 'gnus-summary-dummy-line-format)
2555 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2556 (make-local-variable 'gnus-summary-mark-positions)
2557 (make-local-hook 'pre-command-hook)
2558 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2559 (gnus-run-hooks 'gnus-summary-mode-hook)
2560 (turn-on-gnus-mailing-list-mode)
2561 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2562 (gnus-update-summary-mark-positions))
2564 (defun gnus-summary-make-local-variables ()
2565 "Make all the local summary buffer variables."
2567 (dolist (local gnus-summary-local-variables)
2570 (if (eq (cdr local) 'global)
2571 ;; Copy the global value of the variable.
2572 (setq global (symbol-value (car local)))
2573 ;; Use the value from the list.
2574 (setq global (eval (cdr local))))
2575 (set (make-local-variable (car local)) global))
2576 ;; Simple nil-valued local variable.
2577 (set (make-local-variable local) nil)))))
2579 (defun gnus-summary-clear-local-variables ()
2580 (let ((locals gnus-summary-local-variables))
2582 (if (consp (car locals))
2583 (and (vectorp (caar locals))
2584 (set (caar locals) nil))
2585 (and (vectorp (car locals))
2586 (set (car locals) nil)))
2587 (setq locals (cdr locals)))))
2589 ;; Summary data functions.
2591 (defmacro gnus-data-number (data)
2594 (defmacro gnus-data-set-number (data number)
2595 `(setcar ,data ,number))
2597 (defmacro gnus-data-mark (data)
2600 (defmacro gnus-data-set-mark (data mark)
2601 `(setcar (nthcdr 1 ,data) ,mark))
2603 (defmacro gnus-data-pos (data)
2606 (defmacro gnus-data-set-pos (data pos)
2607 `(setcar (nthcdr 2 ,data) ,pos))
2609 (defmacro gnus-data-header (data)
2612 (defmacro gnus-data-set-header (data header)
2613 `(setcar (nthcdr 3 ,data) ,header))
2615 (defmacro gnus-data-level (data)
2618 (defmacro gnus-data-unread-p (data)
2619 `(= (nth 1 ,data) gnus-unread-mark))
2621 (defmacro gnus-data-read-p (data)
2622 `(/= (nth 1 ,data) gnus-unread-mark))
2624 (defmacro gnus-data-pseudo-p (data)
2625 `(consp (nth 3 ,data)))
2627 (defmacro gnus-data-find (number)
2628 `(assq ,number gnus-newsgroup-data))
2630 (defmacro gnus-data-find-list (number &optional data)
2631 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2632 (memq (assq ,number bdata)
2635 (defmacro gnus-data-make (number mark pos header level)
2636 `(list ,number ,mark ,pos ,header ,level))
2638 (defun gnus-data-enter (after-article number mark pos header level offset)
2639 (let ((data (gnus-data-find-list after-article)))
2641 (error "No such article: %d" after-article))
2642 (setcdr data (cons (gnus-data-make number mark pos header level)
2644 (setq gnus-newsgroup-data-reverse nil)
2645 (gnus-data-update-list (cddr data) offset)))
2647 (defun gnus-data-enter-list (after-article list &optional offset)
2649 (let ((data (and after-article (gnus-data-find-list after-article)))
2653 (let ((odata gnus-newsgroup-data))
2654 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2656 (gnus-data-update-list odata offset)))
2657 ;; Find the last element in the list to be spliced into the main
2660 (setq list (cdr list)))
2663 (setcdr list gnus-newsgroup-data)
2664 (setq gnus-newsgroup-data ilist)
2666 (gnus-data-update-list (cdr list) offset)))
2667 (setcdr list (cdr data))
2670 (gnus-data-update-list (cdr list) offset))))
2671 (setq gnus-newsgroup-data-reverse nil))))
2673 (defun gnus-data-remove (article &optional offset)
2674 (let ((data gnus-newsgroup-data))
2675 (if (= (gnus-data-number (car data)) article)
2677 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2678 gnus-newsgroup-data-reverse nil)
2680 (gnus-data-update-list gnus-newsgroup-data offset)))
2682 (when (= (gnus-data-number (cadr data)) article)
2683 (setcdr data (cddr data))
2685 (gnus-data-update-list (cdr data) offset))
2687 gnus-newsgroup-data-reverse nil))
2688 (setq data (cdr data))))))
2690 (defmacro gnus-data-list (backward)
2692 (or gnus-newsgroup-data-reverse
2693 (setq gnus-newsgroup-data-reverse
2694 (reverse gnus-newsgroup-data)))
2695 gnus-newsgroup-data))
2697 (defun gnus-data-update-list (data offset)
2698 "Add OFFSET to the POS of all data entries in DATA."
2699 (setq gnus-newsgroup-data-reverse nil)
2701 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2702 (setq data (cdr data))))
2704 (defun gnus-summary-article-pseudo-p (article)
2705 "Say whether this article is a pseudo article or not."
2706 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2708 (defmacro gnus-summary-article-sparse-p (article)
2709 "Say whether this article is a sparse article or not."
2710 `(memq ,article gnus-newsgroup-sparse))
2712 (defmacro gnus-summary-article-ancient-p (article)
2713 "Say whether this article is a sparse article or not."
2714 `(memq ,article gnus-newsgroup-ancient))
2716 (defun gnus-article-parent-p (number)
2717 "Say whether this article is a parent or not."
2718 (let ((data (gnus-data-find-list number)))
2719 (and (cdr data) ; There has to be an article after...
2720 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2721 (gnus-data-level (nth 1 data))))))
2723 (defun gnus-article-children (number)
2724 "Return a list of all children to NUMBER."
2725 (let* ((data (gnus-data-find-list number))
2726 (level (gnus-data-level (car data)))
2728 (setq data (cdr data))
2730 (= (gnus-data-level (car data)) (1+ level)))
2731 (push (gnus-data-number (car data)) children)
2732 (setq data (cdr data)))
2735 (defmacro gnus-summary-skip-intangible ()
2736 "If the current article is intangible, then jump to a different article."
2737 '(let ((to (get-text-property (point) 'gnus-intangible)))
2738 (and to (gnus-summary-goto-subject to))))
2740 (defmacro gnus-summary-article-intangible-p ()
2741 "Say whether this article is intangible or not."
2742 '(get-text-property (point) 'gnus-intangible))
2744 (defun gnus-article-read-p (article)
2745 "Say whether ARTICLE is read or not."
2746 (not (or (memq article gnus-newsgroup-marked)
2747 (memq article gnus-newsgroup-spam-marked)
2748 (memq article gnus-newsgroup-unreads)
2749 (memq article gnus-newsgroup-unselected)
2750 (memq article gnus-newsgroup-dormant))))
2752 ;; Some summary mode macros.
2754 (defmacro gnus-summary-article-number ()
2755 "The article number of the article on the current line.
2756 If there isn's an article number here, then we return the current
2759 (gnus-summary-skip-intangible)
2760 (or (get-text-property (point) 'gnus-number)
2761 (gnus-summary-last-subject))))
2763 (defmacro gnus-summary-article-header (&optional number)
2764 "Return the header of article NUMBER."
2765 `(gnus-data-header (gnus-data-find
2766 ,(or number '(gnus-summary-article-number)))))
2768 (defmacro gnus-summary-thread-level (&optional number)
2769 "Return the level of thread that starts with article NUMBER."
2770 `(if (and (eq gnus-summary-make-false-root 'dummy)
2771 (get-text-property (point) 'gnus-intangible))
2773 (gnus-data-level (gnus-data-find
2774 ,(or number '(gnus-summary-article-number))))))
2776 (defmacro gnus-summary-article-mark (&optional number)
2777 "Return the mark of article NUMBER."
2778 `(gnus-data-mark (gnus-data-find
2779 ,(or number '(gnus-summary-article-number)))))
2781 (defmacro gnus-summary-article-pos (&optional number)
2782 "Return the position of the line of article NUMBER."
2783 `(gnus-data-pos (gnus-data-find
2784 ,(or number '(gnus-summary-article-number)))))
2786 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2787 (defmacro gnus-summary-article-subject (&optional number)
2788 "Return current subject string or nil if nothing."
2791 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2792 '(gnus-data-header (assq (gnus-summary-article-number)
2793 gnus-newsgroup-data)))))
2796 (mail-header-subject headers))))
2798 (defmacro gnus-summary-article-score (&optional number)
2799 "Return current article score."
2800 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2801 gnus-newsgroup-scored))
2802 gnus-summary-default-score 0))
2804 (defun gnus-summary-article-children (&optional number)
2805 "Return a list of article numbers that are children of article NUMBER."
2806 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2807 (level (gnus-data-level (car data)))
2809 (while (and (setq data (cdr data))
2810 (> (setq l (gnus-data-level (car data))) level))
2811 (and (= (1+ level) l)
2812 (push (gnus-data-number (car data))
2814 (nreverse children)))
2816 (defun gnus-summary-article-parent (&optional number)
2817 "Return the article number of the parent of article NUMBER."
2818 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2819 (gnus-data-list t)))
2820 (level (gnus-data-level (car data))))
2822 () ; This is a root.
2823 ;; We search until we find an article with a level less than
2824 ;; this one. That function has to be the parent.
2825 (while (and (setq data (cdr data))
2826 (not (< (gnus-data-level (car data)) level))))
2827 (and data (gnus-data-number (car data))))))
2829 (defun gnus-unread-mark-p (mark)
2830 "Say whether MARK is the unread mark."
2831 (= mark gnus-unread-mark))
2833 (defun gnus-read-mark-p (mark)
2834 "Say whether MARK is one of the marks that mark as read.
2835 This is all marks except unread, ticked, dormant, and expirable."
2836 (not (or (= mark gnus-unread-mark)
2837 (= mark gnus-ticked-mark)
2838 (= mark gnus-dormant-mark)
2839 (= mark gnus-expirable-mark))))
2841 (defmacro gnus-article-mark (number)
2842 "Return the MARK of article NUMBER.
2843 This macro should only be used when computing the mark the \"first\"
2844 time; i.e., when generating the summary lines. After that,
2845 `gnus-summary-article-mark' should be used to examine the
2848 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2849 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2850 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2851 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2852 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2853 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2854 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2855 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2856 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2857 gnus-ancient-mark))))
2859 ;; Saving hidden threads.
2861 (defmacro gnus-save-hidden-threads (&rest forms)
2862 "Save hidden threads, eval FORMS, and restore the hidden threads."
2863 (let ((config (make-symbol "config")))
2864 `(let ((,config (gnus-hidden-threads-configuration)))
2868 (gnus-restore-hidden-threads-configuration ,config)))))
2869 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2870 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2872 (defun gnus-data-compute-positions ()
2873 "Compute the positions of all articles."
2874 (setq gnus-newsgroup-data-reverse nil)
2875 (let ((data gnus-newsgroup-data))
2877 (gnus-save-hidden-threads
2878 (gnus-summary-show-all-threads)
2879 (goto-char (point-min))
2881 (while (get-text-property (point) 'gnus-intangible)
2883 (gnus-data-set-pos (car data) (+ (point) 3))
2884 (setq data (cdr data))
2885 (forward-line 1))))))
2887 (defun gnus-hidden-threads-configuration ()
2888 "Return the current hidden threads configuration."
2891 (goto-char (point-min))
2892 (while (search-forward "\r" nil t)
2893 (push (1- (point)) config))
2896 (defun gnus-restore-hidden-threads-configuration (config)
2897 "Restore hidden threads configuration from CONFIG."
2899 (let (point buffer-read-only)
2900 (while (setq point (pop config))
2901 (when (and (< point (point-max))
2903 (eq (char-after) ?\n))
2904 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2906 ;; Various summary mode internalish functions.
2908 (defun gnus-mouse-pick-article (e)
2911 (gnus-summary-next-page nil t))
2913 (defun gnus-summary-set-display-table ()
2914 "Change the display table.
2915 Odd characters have a tendency to mess
2916 up nicely formatted displays - we make all possible glyphs
2917 display only a single character."
2919 ;; We start from the standard display table, if any.
2920 (let ((table (or (copy-sequence standard-display-table)
2921 (make-display-table)))
2923 ;; Nix out all the control chars...
2924 (while (>= (setq i (1- i)) 0)
2925 (aset table i [??]))
2926 ;; ... but not newline and cr, of course. (cr is necessary for the
2927 ;; selective display).
2928 (aset table ?\n nil)
2929 (aset table ?\r nil)
2930 ;; We keep TAB as well.
2931 (aset table ?\t nil)
2932 ;; We nix out any glyphs over 126 that are not set already.
2934 (while (>= (setq i (1- i)) 127)
2935 ;; Only modify if the entry is nil.
2936 (unless (aref table i)
2937 (aset table i [??]))))
2938 (setq buffer-display-table table)))
2940 (defun gnus-summary-set-article-display-arrow (pos)
2941 "Update the overlay arrow to point to line at position POS."
2942 (when (and gnus-summary-display-arrow
2943 (boundp 'overlay-arrow-position)
2944 (boundp 'overlay-arrow-string))
2948 (unless overlay-arrow-position
2949 (setq overlay-arrow-position (make-marker)))
2950 (setq overlay-arrow-string "=>"
2951 overlay-arrow-position (set-marker overlay-arrow-position
2953 (current-buffer))))))
2955 (defun gnus-summary-buffer-name (group)
2956 "Return the summary buffer name of GROUP."
2957 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2959 (defun gnus-summary-setup-buffer (group)
2960 "Initialize summary buffer."
2961 (let ((buffer (gnus-summary-buffer-name group))
2962 (dead-name (concat "*Dead Summary "
2963 (gnus-group-decoded-name group) "*")))
2964 ;; If a dead summary buffer exists, we kill it.
2965 (when (gnus-buffer-live-p dead-name)
2966 (gnus-kill-buffer dead-name))
2967 (if (get-buffer buffer)
2970 (setq gnus-summary-buffer (current-buffer))
2971 (not gnus-newsgroup-prepared))
2972 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2973 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2974 (gnus-summary-mode group)
2976 (gnus-carpal-setup-buffer 'summary))
2977 (unless gnus-single-article-buffer
2978 (make-local-variable 'gnus-article-buffer)
2979 (make-local-variable 'gnus-article-current)
2980 (make-local-variable 'gnus-original-article-buffer))
2981 (setq gnus-newsgroup-name group)
2982 ;; Set any local variables in the group parameters.
2983 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2986 (defun gnus-set-global-variables ()
2987 "Set the global equivalents of the buffer-local variables.
2988 They are set to the latest values they had. These reflect the summary
2989 buffer that was in action when the last article was fetched."
2990 (when (eq major-mode 'gnus-summary-mode)
2991 (setq gnus-summary-buffer (current-buffer))
2992 (let ((name gnus-newsgroup-name)
2993 (marked gnus-newsgroup-marked)
2994 (spam gnus-newsgroup-spam-marked)
2995 (unread gnus-newsgroup-unreads)
2996 (headers gnus-current-headers)
2997 (data gnus-newsgroup-data)
2998 (summary gnus-summary-buffer)
2999 (article-buffer gnus-article-buffer)
3000 (original gnus-original-article-buffer)
3001 (gac gnus-article-current)
3002 (reffed gnus-reffed-article-number)
3003 (score-file gnus-current-score-file)
3004 (default-charset gnus-newsgroup-charset)
3006 (let ((locals gnus-newsgroup-variables))
3008 (if (consp (car locals))
3009 (push (eval (caar locals)) vlist)
3010 (push (eval (car locals)) vlist))
3011 (setq locals (cdr locals)))
3012 (setq vlist (nreverse vlist)))
3014 (set-buffer gnus-group-buffer)
3015 (setq gnus-newsgroup-name name
3016 gnus-newsgroup-marked marked
3017 gnus-newsgroup-spam-marked spam
3018 gnus-newsgroup-unreads unread
3019 gnus-current-headers headers
3020 gnus-newsgroup-data data
3021 gnus-article-current gac
3022 gnus-summary-buffer summary
3023 gnus-article-buffer article-buffer
3024 gnus-original-article-buffer original
3025 gnus-reffed-article-number reffed
3026 gnus-current-score-file score-file
3027 gnus-newsgroup-charset default-charset)
3028 (let ((locals gnus-newsgroup-variables))
3030 (if (consp (car locals))
3031 (set (caar locals) (pop vlist))
3032 (set (car locals) (pop vlist)))
3033 (setq locals (cdr locals))))
3034 ;; The article buffer also has local variables.
3035 (when (gnus-buffer-live-p gnus-article-buffer)
3036 (set-buffer gnus-article-buffer)
3037 (setq gnus-summary-buffer summary))))))
3039 (defun gnus-summary-article-unread-p (article)
3040 "Say whether ARTICLE is unread or not."
3041 (memq article gnus-newsgroup-unreads))
3043 (defun gnus-summary-first-article-p (&optional article)
3044 "Return whether ARTICLE is the first article in the buffer."
3045 (if (not (setq article (or article (gnus-summary-article-number))))
3047 (eq article (caar gnus-newsgroup-data))))
3049 (defun gnus-summary-last-article-p (&optional article)
3050 "Return whether ARTICLE is the last article in the buffer."
3051 (if (not (setq article (or article (gnus-summary-article-number))))
3052 ;; All non-existent numbers are the last article. :-)
3054 (not (cdr (gnus-data-find-list article)))))
3056 (defun gnus-make-thread-indent-array ()
3058 (unless (and gnus-thread-indent-array
3059 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3060 (setq gnus-thread-indent-array (make-vector 201 "")
3061 gnus-thread-indent-array-level gnus-thread-indent-level)
3063 (aset gnus-thread-indent-array n
3064 (make-string (* n gnus-thread-indent-level) ? ))
3067 (defun gnus-update-summary-mark-positions ()
3068 "Compute where the summary marks are to go."
3070 (when (gnus-buffer-exists-p gnus-summary-buffer)
3071 (set-buffer gnus-summary-buffer))
3072 (let ((gnus-replied-mark 129)
3073 (gnus-score-below-mark 130)
3074 (gnus-score-over-mark 130)
3075 (gnus-download-mark 131)
3076 (spec gnus-summary-line-format-spec)
3079 (gnus-set-work-buffer)
3080 (let ((gnus-summary-line-format-spec spec)
3081 (gnus-newsgroup-downloadable '((0 . t))))
3082 (gnus-summary-insert-line
3083 (make-full-mail-header 0 "" "nobody"
3084 "05 Apr 2001 23:33:09 +0400"
3086 0 nil 128 t nil "" nil 1)
3087 (goto-char (point-min))
3088 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3089 (- (point) (point-min) 1)))))
3090 (goto-char (point-min))
3091 (push (cons 'replied (and (search-forward "\201" nil t)
3092 (- (point) (point-min) 1)))
3094 (goto-char (point-min))
3095 (push (cons 'score (and (search-forward "\202" nil t)
3096 (- (point) (point-min) 1)))
3098 (goto-char (point-min))
3099 (push (cons 'download
3100 (and (search-forward "\203" nil t)
3101 (- (point) (point-min) 1)))
3103 (setq gnus-summary-mark-positions pos))))
3105 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3106 "Insert a dummy root in the summary buffer."
3108 (gnus-add-text-properties
3109 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3110 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3112 (defun gnus-summary-extract-address-component (from)
3113 (or (car (funcall gnus-extract-address-components from))
3116 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3117 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3118 default-mime-charset)))
3119 ;; Is it really necessary to do this next part for each summary line?
3120 ;; Luckily, doesn't seem to slow things down much.
3122 (and gnus-ignored-from-addresses
3123 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3124 (let ((extra-headers (mail-header-extra header))
3128 ((setq to (cdr (assq 'To extra-headers)))
3131 (gnus-summary-extract-address-component
3132 (funcall gnus-decode-encoded-word-function to)))))
3133 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3134 (concat "=> " newsgroups)))))
3135 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3137 (defun gnus-summary-insert-line (gnus-tmp-header
3138 gnus-tmp-level gnus-tmp-current
3139 gnus-tmp-unread gnus-tmp-replied
3140 gnus-tmp-expirable gnus-tmp-subject-or-nil
3141 &optional gnus-tmp-dummy gnus-tmp-score
3143 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3144 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3145 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3146 (gnus-tmp-score-char
3147 (if (or (null gnus-summary-default-score)
3148 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3149 gnus-summary-zcore-fuzz))
3151 (if (< gnus-tmp-score gnus-summary-default-score)
3152 gnus-score-below-mark gnus-score-over-mark)))
3153 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3155 (cond (gnus-tmp-process gnus-process-mark)
3156 ((memq gnus-tmp-current gnus-newsgroup-cached)
3158 (gnus-tmp-replied gnus-replied-mark)
3159 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3160 gnus-forwarded-mark)
3161 ((memq gnus-tmp-current gnus-newsgroup-saved)
3163 ((memq gnus-tmp-number gnus-newsgroup-recent)
3165 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3168 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3171 ((string-match "<[^>]+> *$" gnus-tmp-from)
3172 (let ((beg (match-beginning 0)))
3173 (or (and (string-match "^\".+\"" gnus-tmp-from)
3174 (substring gnus-tmp-from 1 (1- (match-end 0))))
3175 (substring gnus-tmp-from 0 beg))))
3176 ((string-match "(.+)" gnus-tmp-from)
3177 (substring gnus-tmp-from
3178 (1+ (match-beginning 0)) (1- (match-end 0))))
3180 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3181 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3182 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3183 (buffer-read-only nil))
3184 (when (string= gnus-tmp-name "")
3185 (setq gnus-tmp-name gnus-tmp-from))
3186 (unless (numberp gnus-tmp-lines)
3187 (setq gnus-tmp-lines -1))
3188 (if (= gnus-tmp-lines -1)
3189 (setq gnus-tmp-lines "?")
3190 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3191 (gnus-put-text-property-excluding-characters-with-faces
3193 (progn (eval gnus-summary-line-format-spec) (point))
3194 'gnus-number gnus-tmp-number)
3195 (when (gnus-visual-p 'summary-highlight 'highlight)
3197 (gnus-run-hooks 'gnus-summary-update-hook)
3200 (defun gnus-summary-update-line (&optional dont-update)
3201 "Update summary line after change."
3202 (when (and gnus-summary-default-score
3203 (not gnus-summary-inhibit-highlight))
3204 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3205 (article (gnus-summary-article-number))
3206 (score (gnus-summary-article-score article)))
3208 (if (and gnus-summary-mark-below
3209 (< (gnus-summary-article-score)
3210 gnus-summary-mark-below))
3211 ;; This article has a low score, so we mark it as read.
3212 (when (memq article gnus-newsgroup-unreads)
3213 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3214 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3215 ;; This article was previously marked as read on account
3216 ;; of a low score, but now it has risen, so we mark it as
3218 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3219 (gnus-summary-update-mark
3220 (if (or (null gnus-summary-default-score)
3221 (<= (abs (- score gnus-summary-default-score))
3222 gnus-summary-zcore-fuzz))
3224 (if (< score gnus-summary-default-score)
3225 gnus-score-below-mark gnus-score-over-mark))
3227 ;; Do visual highlighting.
3228 (when (gnus-visual-p 'summary-highlight 'highlight)
3229 (gnus-run-hooks 'gnus-summary-update-hook)))))
3231 (defvar gnus-tmp-new-adopts nil)
3233 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3234 "Return the number of articles in THREAD.
3235 This may be 0 in some cases -- if none of the articles in
3236 the thread are to be displayed."
3238 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3240 ((not (listp thread))
3242 ((and (consp thread) (cdr thread))
3245 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3248 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3251 (when (and level (zerop level) gnus-tmp-new-adopts)
3254 'gnus-summary-number-of-articles-in-thread
3255 gnus-tmp-new-adopts))))
3257 (if (> number 1) gnus-not-empty-thread-mark
3258 gnus-empty-thread-mark)
3261 (defun gnus-summary-set-local-parameters (group)
3262 "Go through the local params of GROUP and set all variable specs in that list."
3263 (let ((params (gnus-group-find-parameter group))
3264 (vars '(quit-config)) ; Ignore quit-config.
3267 (setq elem (car params)
3268 params (cdr params))
3269 (and (consp elem) ; Has to be a cons.
3270 (consp (cdr elem)) ; The cdr has to be a list.
3271 (symbolp (car elem)) ; Has to be a symbol in there.
3272 (not (memq (car elem) vars))
3273 (ignore-errors ; So we set it.
3274 (push (car elem) vars)
3275 (make-local-variable (car elem))
3276 (set (car elem) (eval (nth 1 elem))))))))
3278 (defun gnus-summary-read-group (group &optional show-all no-article
3279 kill-buffer no-display backward
3281 "Start reading news in newsgroup GROUP.
3282 If SHOW-ALL is non-nil, already read articles are also listed.
3283 If NO-ARTICLE is non-nil, no article is selected initially.
3284 If NO-DISPLAY, don't generate a summary buffer."
3288 (let ((gnus-auto-select-next nil))
3289 (or (gnus-summary-read-group-1
3290 group show-all no-article
3291 kill-buffer no-display
3294 select-articles nil)))))
3295 (eq gnus-auto-select-next 'quietly))
3296 (set-buffer gnus-group-buffer)
3297 ;; The entry function called above goes to the next
3298 ;; group automatically, so we go two groups back
3299 ;; if we are searching for the previous group.
3301 (gnus-group-prev-unread-group 2))
3302 (if (not (equal group (gnus-group-group-name)))
3303 (setq group (gnus-group-group-name))
3307 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3308 "Directly jump to the other GROUP from summary buffer.
3309 If SHOW-ALL is non-nil, already read articles are also listed."
3311 (if (eq gnus-summary-buffer (current-buffer))
3312 (list (completing-read
3313 "Group: " gnus-active-hashtb nil t
3314 (when (and gnus-newsgroup-name
3315 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3316 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3317 'gnus-group-history)
3319 (error "%s must be invoked from a gnus summary buffer." this-command)))
3320 (unless (or (zerop (length group))
3321 (and gnus-newsgroup-name
3322 (string-equal gnus-newsgroup-name group)))
3324 (gnus-summary-read-group group show-all
3325 gnus-dont-select-after-jump-to-other-group)))
3327 (defun gnus-summary-read-group-1 (group show-all no-article
3328 kill-buffer no-display
3329 &optional select-articles)
3330 ;; Killed foreign groups can't be entered.
3331 ;; (when (and (not (gnus-group-native-p group))
3332 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3333 ;; (error "Dead non-native groups can't be entered"))
3334 (gnus-message 5 "Retrieving newsgroup: %s..."
3335 (gnus-group-decoded-name group))
3336 (let* ((new-group (gnus-summary-setup-buffer group))
3337 (quit-config (gnus-group-quit-config group))
3338 (did-select (and new-group (gnus-select-newsgroup
3339 group show-all select-articles))))
3341 ;; This summary buffer exists already, so we just select it.
3343 (gnus-set-global-variables)
3345 (gnus-kill-or-deaden-summary kill-buffer))
3346 (gnus-configure-windows 'summary 'force)
3347 (gnus-set-mode-line 'summary)
3348 (gnus-summary-position-point)
3351 ;; We couldn't select this group.
3353 (when (and (eq major-mode 'gnus-summary-mode)
3354 (not (equal (current-buffer) kill-buffer)))
3355 (kill-buffer (current-buffer))
3356 (if (not quit-config)
3358 ;; Update the info -- marks might need to be removed,
3360 (gnus-summary-update-info)
3361 (set-buffer gnus-group-buffer)
3362 (gnus-group-jump-to-group group)
3363 (gnus-group-next-unread-group 1))
3364 (gnus-handle-ephemeral-exit quit-config)))
3365 (let ((grpinfo (gnus-get-info group)))
3366 (if (null (gnus-info-read grpinfo))
3367 (gnus-message 3 "Group %s contains no messages"
3368 (gnus-group-decoded-name group))
3369 (gnus-message 3 "Can't select group")))
3371 ;; The user did a `C-g' while prompting for number of articles,
3372 ;; so we exit this group.
3373 ((eq did-select 'quit)
3374 (and (eq major-mode 'gnus-summary-mode)
3375 (not (equal (current-buffer) kill-buffer))
3376 (kill-buffer (current-buffer)))
3378 (gnus-kill-or-deaden-summary kill-buffer))
3379 (if (not quit-config)
3381 (set-buffer gnus-group-buffer)
3382 (gnus-group-jump-to-group group)
3383 (gnus-group-next-unread-group 1)
3384 (gnus-configure-windows 'group 'force))
3385 (gnus-handle-ephemeral-exit quit-config))
3386 ;; Finally signal the quit.
3388 ;; The group was successfully selected.
3390 (gnus-set-global-variables)
3391 ;; Save the active value in effect when the group was entered.
3392 (setq gnus-newsgroup-active
3394 (gnus-active gnus-newsgroup-name)))
3395 ;; You can change the summary buffer in some way with this hook.
3396 (gnus-run-hooks 'gnus-select-group-hook)
3397 (gnus-update-format-specifications
3398 nil 'summary 'summary-mode 'summary-dummy)
3399 (gnus-update-summary-mark-positions)
3400 ;; Do score processing.
3401 (when gnus-use-scoring
3402 (gnus-possibly-score-headers))
3403 ;; Check whether to fill in the gaps in the threads.
3404 (when gnus-build-sparse-threads
3405 (gnus-build-sparse-threads))
3406 ;; Find the initial limit.
3407 (if gnus-show-threads
3409 (let ((gnus-newsgroup-dormant nil))
3410 (gnus-summary-initial-limit show-all))
3411 (gnus-summary-initial-limit show-all))
3412 ;; When untreaded, all articles are always shown.
3413 (setq gnus-newsgroup-limit
3415 (lambda (header) (mail-header-number header))
3416 gnus-newsgroup-headers)))
3417 ;; Generate the summary buffer.
3419 (gnus-summary-prepare))
3420 (when gnus-use-trees
3421 (gnus-tree-open group)
3422 (setq gnus-summary-highlight-line-function
3423 'gnus-tree-highlight-article))
3424 ;; If the summary buffer is empty, but there are some low-scored
3425 ;; articles or some excluded dormants, we include these in the
3427 (when (and (zerop (buffer-size))
3429 (cond (gnus-newsgroup-dormant
3430 (gnus-summary-limit-include-dormant))
3431 ((and gnus-newsgroup-scored show-all)
3432 (gnus-summary-limit-include-expunged t))))
3433 ;; Function `gnus-apply-kill-file' must be called in this hook.
3434 (gnus-run-hooks 'gnus-apply-kill-hook)
3435 (if (and (zerop (buffer-size))
3438 ;; This newsgroup is empty.
3439 (gnus-summary-catchup-and-exit nil t)
3440 (gnus-message 6 "No unread news")
3442 (gnus-kill-or-deaden-summary kill-buffer))
3443 ;; Return nil from this function.
3445 ;; Hide conversation thread subtrees. We cannot do this in
3446 ;; gnus-summary-prepare-hook since kill processing may not
3447 ;; work with hidden articles.
3448 (gnus-summary-maybe-hide-threads)
3450 (gnus-kill-or-deaden-summary kill-buffer))
3451 (gnus-summary-auto-select-subject)
3452 ;; Show first unread article if requested.
3453 (if (and (not no-article)
3455 gnus-newsgroup-unreads
3456 gnus-auto-select-first)
3458 (gnus-configure-windows 'summary)
3459 (let ((art (gnus-summary-article-number)))
3460 (unless (or (memq art gnus-newsgroup-undownloaded)
3461 (memq art gnus-newsgroup-downloadable))
3462 (gnus-summary-goto-article art))))
3463 ;; Don't select any articles.
3464 (gnus-summary-position-point)
3465 (gnus-configure-windows 'summary 'force)
3466 (gnus-set-mode-line 'summary))
3467 (when (get-buffer-window gnus-group-buffer t)
3468 ;; Gotta use windows, because recenter does weird stuff if
3469 ;; the current buffer ain't the displayed window.
3470 (let ((owin (selected-window)))
3471 (select-window (get-buffer-window gnus-group-buffer t))
3472 (when (gnus-group-goto-group group)
3474 (select-window owin)))
3475 ;; Mark this buffer as "prepared".
3476 (setq gnus-newsgroup-prepared t)
3477 (gnus-run-hooks 'gnus-summary-prepared-hook)
3480 (defun gnus-summary-auto-select-subject ()
3481 "Select the subject line on initial group entry."
3482 (goto-char (point-min))
3484 ((eq gnus-auto-select-subject 'best)
3485 (gnus-summary-best-unread-subject))
3486 ((eq gnus-auto-select-subject 'unread)
3487 (gnus-summary-first-unread-subject))
3488 ((eq gnus-auto-select-subject 'unseen)
3489 (gnus-summary-first-unseen-subject))
3490 ((eq gnus-auto-select-subject 'unseen-or-unread)
3491 (gnus-summary-first-unseen-or-unread-subject))
3492 ((eq gnus-auto-select-subject 'first)
3495 ((gnus-functionp gnus-auto-select-subject)
3496 (funcall gnus-auto-select-subject))))
3498 (defun gnus-summary-prepare ()
3499 "Generate the summary buffer."
3501 (let ((buffer-read-only nil))
3503 (setq gnus-newsgroup-data nil
3504 gnus-newsgroup-data-reverse nil)
3505 (gnus-run-hooks 'gnus-summary-generate-hook)
3506 ;; Generate the buffer, either with threads or without.
3507 (when gnus-newsgroup-headers
3508 (gnus-summary-prepare-threads
3509 (if gnus-show-threads
3510 (gnus-sort-gathered-threads
3511 (funcall gnus-summary-thread-gathering-function
3513 (gnus-cut-threads (gnus-make-threads)))))
3514 ;; Unthreaded display.
3515 (gnus-sort-articles gnus-newsgroup-headers))))
3516 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3517 ;; Call hooks for modifying summary buffer.
3518 (goto-char (point-min))
3519 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3521 (defsubst gnus-general-simplify-subject (subject)
3522 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3525 ;; Truncate the subject.
3526 (gnus-simplify-subject-functions
3527 (gnus-map-function gnus-simplify-subject-functions subject))
3528 ((numberp gnus-summary-gather-subject-limit)
3529 (setq subject (gnus-simplify-subject-re subject))
3530 (if (> (length subject) gnus-summary-gather-subject-limit)
3531 (substring subject 0 gnus-summary-gather-subject-limit)
3533 ;; Fuzzily simplify it.
3534 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3535 (gnus-simplify-subject-fuzzy subject))
3536 ;; Just remove the leading "Re:".
3538 (gnus-simplify-subject-re subject))))
3540 (if (and gnus-summary-gather-exclude-subject
3541 (string-match gnus-summary-gather-exclude-subject subject))
3542 nil ; This article shouldn't be gathered
3545 (defun gnus-summary-simplify-subject-query ()
3546 "Query where the respool algorithm would put this article."
3548 (gnus-summary-select-article)
3550 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3552 (defun gnus-gather-threads-by-subject (threads)
3553 "Gather threads by looking at Subject headers."
3554 (if (not gnus-summary-make-false-root)
3556 (let ((hashtb (gnus-make-hashtable 1024))
3559 subject hthread whole-subject)
3561 (setq subject (gnus-general-simplify-subject
3562 (setq whole-subject (mail-header-subject
3565 (if (setq hthread (gnus-gethash subject hashtb))
3567 ;; We enter a dummy root into the thread, if we
3568 ;; haven't done that already.
3569 (unless (stringp (caar hthread))
3570 (setcar hthread (list whole-subject (car hthread))))
3571 ;; We add this new gathered thread to this gathered
3573 (setcdr (car hthread)
3574 (nconc (cdar hthread) (list (car threads))))
3575 ;; Remove it from the list of threads.
3576 (setcdr prev (cdr threads))
3577 (setq threads prev))
3578 ;; Enter this thread into the hash table.
3579 (gnus-sethash subject threads hashtb)))
3581 (setq threads (cdr threads)))
3584 (defun gnus-gather-threads-by-references (threads)
3585 "Gather threads by looking at References headers."
3586 (let ((idhashtb (gnus-make-hashtable 1024))
3587 (thhashtb (gnus-make-hashtable 1024))
3590 ids references id gthread gid entered ref)
3592 (when (setq references (mail-header-references (caar threads)))
3593 (setq id (mail-header-id (caar threads))
3594 ids (inline (gnus-split-references references))
3596 (while (setq ref (pop ids))
3597 (setq ids (delete ref ids))
3598 (if (not (setq gid (gnus-gethash ref idhashtb)))
3600 (gnus-sethash ref id idhashtb)
3601 (gnus-sethash id threads thhashtb))
3602 (setq gthread (gnus-gethash gid thhashtb))
3604 ;; We enter a dummy root into the thread, if we
3605 ;; haven't done that already.
3606 (unless (stringp (caar gthread))
3607 (setcar gthread (list (mail-header-subject (caar gthread))
3609 ;; We add this new gathered thread to this gathered
3611 (setcdr (car gthread)
3612 (nconc (cdar gthread) (list (car threads)))))
3613 ;; Add it into the thread hash table.
3614 (gnus-sethash id gthread thhashtb)
3616 ;; Remove it from the list of threads.
3617 (setcdr prev (cdr threads))
3618 (setq threads prev))))
3620 (setq threads (cdr threads)))
3623 (defun gnus-sort-gathered-threads (threads)
3624 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3625 (let ((result threads))
3627 (when (stringp (caar threads))
3628 (setcdr (car threads)
3629 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3630 (setq threads (cdr threads)))
3633 (defun gnus-thread-loop-p (root thread)
3634 "Say whether ROOT is in THREAD."
3635 (let ((stack (list thread))
3638 (while (setq thread (pop stack))
3639 (setq th (cdr thread))
3641 (not (eq (caar th) root)))
3644 ;; We have found a loop.
3646 (setcdr thread (delq (car th) (cdr thread)))
3647 (if (boundp (setq ref-dep (intern "none"
3648 gnus-newsgroup-dependencies)))
3649 (setcdr (symbol-value ref-dep)
3650 (nconc (cdr (symbol-value ref-dep))
3652 (set ref-dep (list nil (car th))))
3655 ;; Push all the subthreads onto the stack.
3656 (push (cdr thread) stack)))
3659 (defun gnus-make-threads ()
3660 "Go through the dependency hashtb and find the roots. Return all threads."
3662 (while (catch 'infloop
3665 ;; Deal with self-referencing References loops.
3666 (when (and (car (symbol-value refs))
3673 (car (symbol-value refs)) thread))
3674 (cdr (symbol-value refs)))))))
3677 (unless (car (symbol-value refs))
3678 ;; These threads do not refer back to any other articles,
3679 ;; so they're roots.
3680 (setq threads (append (cdr (symbol-value refs)) threads))))
3681 gnus-newsgroup-dependencies)))
3684 ;; Build the thread tree.
3685 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3686 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3688 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3689 if it was already present.
3691 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3692 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3693 Message-IDs will be renamed to a unique Message-ID before being
3696 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3697 (let* ((id (mail-header-id header))
3698 (id-dep (and id (intern id dependencies)))
3699 parent-id ref ref-dep ref-header replaced)
3700 ;; Enter this `header' in the `dependencies' table.
3704 ;; The first two cases do the normal part: enter a new `header'
3705 ;; in the `dependencies' table.
3706 ((not (boundp id-dep))
3707 (set id-dep (list header)))
3708 ((null (car (symbol-value id-dep)))
3709 (setcar (symbol-value id-dep) header))
3711 ;; From here the `header' was already present in the
3712 ;; `dependencies' table.
3714 ;; Overrides an existing entry;
3715 ;; just set the header part of the entry.
3716 (setcar (symbol-value id-dep) header)
3719 ;; Renames the existing `header' to a unique Message-ID.
3720 ((not gnus-summary-ignore-duplicates)
3721 ;; An article with this Message-ID has already been seen.
3722 ;; We rename the Message-ID.
3723 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3725 (mail-header-set-id header id))
3727 ;; The last case ignores an existing entry, except it adds any
3728 ;; additional Xrefs (in case the two articles came from different
3730 ;; Also sets `header' to `nil' meaning that the `dependencies'
3731 ;; table was *not* modified.
3733 (mail-header-set-xref
3734 (car (symbol-value id-dep))
3735 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3737 (or (mail-header-xref header) "")))
3740 (when (and header (not replaced))
3741 ;; First check that we are not creating a References loop.
3742 (setq parent-id (gnus-parent-id (mail-header-references header)))
3743 (setq ref parent-id)
3745 (setq ref-dep (intern-soft ref dependencies))
3747 (setq ref-header (car (symbol-value ref-dep))))
3748 (if (string= id ref)
3749 ;; Yuk! This is a reference loop. Make the article be a
3752 (mail-header-set-references (car (symbol-value id-dep)) "none")
3754 (setq parent-id nil))
3755 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3756 (setq ref-dep (intern (or parent-id "none") dependencies))
3757 (if (boundp ref-dep)
3758 (setcdr (symbol-value ref-dep)
3759 (nconc (cdr (symbol-value ref-dep))
3760 (list (symbol-value id-dep))))
3761 (set ref-dep (list nil (symbol-value id-dep)))))
3764 (defun gnus-extract-message-id-from-in-reply-to (string)
3765 (if (string-match "<[^>]+>" string)
3766 (substring string (match-beginning 0) (match-end 0))
3769 (defun gnus-build-sparse-threads ()
3770 (let ((headers gnus-newsgroup-headers)
3771 (mail-parse-charset gnus-newsgroup-charset)
3772 (gnus-summary-ignore-duplicates t)
3773 header references generation relations
3774 subject child end new-child date)
3775 ;; First we create an alist of generations/relations, where
3776 ;; generations is how much we trust the relation, and the relation
3778 (gnus-message 7 "Making sparse threads...")
3780 (nnheader-set-temp-buffer " *gnus sparse threads*")
3781 (while (setq header (pop headers))
3782 (when (and (setq references (mail-header-references header))
3783 (not (string= references "")))
3785 (setq child (mail-header-id header)
3786 subject (mail-header-subject header)
3787 date (mail-header-date header)
3789 (while (search-backward ">" nil t)
3790 (setq end (1+ (point)))
3791 (when (search-backward "<" nil t)
3792 (setq new-child (buffer-substring (point) end))
3793 (push (list (incf generation)
3794 child (setq child new-child)
3798 (push (list (1+ generation) child nil subject) relations))
3800 (kill-buffer (current-buffer)))
3801 ;; Sort over trustworthiness.
3804 (when (gnus-dependencies-add-header
3805 (make-full-mail-header-from-decoded-header
3806 gnus-reffed-article-number
3807 (nth 3 relation) "" (or (nth 4 relation) "")
3809 (or (nth 2 relation) "") 0 0 "")
3810 gnus-newsgroup-dependencies nil)
3811 (push gnus-reffed-article-number gnus-newsgroup-limit)
3812 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3813 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3814 gnus-newsgroup-reads)
3815 (decf gnus-reffed-article-number)))
3816 (sort relations 'car-less-than-car))
3817 (gnus-message 7 "Making sparse threads...done")))
3819 (defun gnus-build-old-threads ()
3820 ;; Look at all the articles that refer back to old articles, and
3821 ;; fetch the headers for the articles that aren't there. This will
3822 ;; build complete threads - if the roots haven't been expired by the
3824 (let ((mail-parse-charset gnus-newsgroup-charset)
3828 (when (not (car (symbol-value refs)))
3829 (setq heads (cdr (symbol-value refs)))
3831 (if (memq (mail-header-number (caar heads))
3832 gnus-newsgroup-dormant)
3833 (setq heads (cdr heads))
3834 (setq id (symbol-name refs))
3835 (while (and (setq id (gnus-build-get-header id))
3836 (not (car (gnus-id-to-thread id)))))
3837 (setq heads nil)))))
3838 gnus-newsgroup-dependencies)))
3840 ;; This function has to be called with point after the article number
3841 ;; on the beginning of the line.
3842 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3843 (let ((eol (gnus-point-at-eol))
3844 (buffer (current-buffer))
3845 header references in-reply-to)
3847 ;; overview: [num subject from date id refs chars lines misc]
3850 (narrow-to-region (point) eol)
3855 (make-full-mail-header
3857 (nnheader-nov-field) ; subject
3858 (nnheader-nov-field) ; from
3859 (nnheader-nov-field) ; date
3860 (nnheader-nov-read-message-id) ; id
3861 (nnheader-nov-field) ; refs
3862 (nnheader-nov-read-integer) ; chars
3863 (nnheader-nov-read-integer) ; lines
3865 (if (looking-at "Xref: ")
3866 (goto-char (match-end 0)))
3867 (nnheader-nov-field)) ; Xref
3868 (nnheader-nov-parse-extra)))) ; extra
3872 (when (and (string= references "")
3873 (setq in-reply-to (mail-header-extra header))
3874 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3875 (mail-header-set-references
3876 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3878 (when gnus-alter-header-function
3879 (funcall gnus-alter-header-function header))
3880 (gnus-dependencies-add-header header dependencies force-new)))
3882 (defun gnus-build-get-header (id)
3883 "Look through the buffer of NOV lines and find the header to ID.
3884 Enter this line into the dependencies hash table, and return
3885 the id of the parent article (if any)."
3886 (let ((deps gnus-newsgroup-dependencies)
3890 (set-buffer nntp-server-buffer)
3891 (let ((case-fold-search nil))
3892 (goto-char (point-min))
3893 (while (and (not found)
3894 (search-forward id nil t))
3896 (setq found (looking-at
3897 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3898 (regexp-quote id))))
3899 (or found (beginning-of-line 2)))
3903 (setq header (gnus-nov-parse-line
3904 (read (current-buffer)) deps))
3905 (gnus-parent-id (mail-header-references header))))))
3907 (let ((number (mail-header-number header)))
3908 (push number gnus-newsgroup-limit)
3909 (push header gnus-newsgroup-headers)
3910 (if (memq number gnus-newsgroup-unselected)
3912 (setq gnus-newsgroup-unreads
3913 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3915 (setq gnus-newsgroup-unselected
3916 (delq number gnus-newsgroup-unselected)))
3917 (push number gnus-newsgroup-ancient)))))))
3919 (defun gnus-build-all-threads ()
3920 "Read all the headers."
3921 (let ((gnus-summary-ignore-duplicates t)
3922 (mail-parse-charset gnus-newsgroup-charset)
3923 (dependencies gnus-newsgroup-dependencies)
3926 (set-buffer nntp-server-buffer)
3927 (let ((case-fold-search nil))
3928 (goto-char (point-min))
3931 (setq article (read (current-buffer))
3932 header (gnus-nov-parse-line article dependencies)))
3935 (set-buffer gnus-summary-buffer)
3936 (push header gnus-newsgroup-headers)
3937 (if (memq (setq article (mail-header-number header))
3938 gnus-newsgroup-unselected)
3940 (setq gnus-newsgroup-unreads
3941 (gnus-add-to-sorted-list
3942 gnus-newsgroup-unreads article))
3943 (setq gnus-newsgroup-unselected
3944 (delq article gnus-newsgroup-unselected)))
3945 (push article gnus-newsgroup-ancient)))
3946 (forward-line 1)))))))
3948 (defun gnus-summary-update-article-line (article header)
3949 "Update the line for ARTICLE using HEADERS."
3950 (let* ((id (mail-header-id header))
3951 (thread (gnus-id-to-thread id)))
3953 (error "Article in no thread"))
3954 ;; Update the thread.
3955 (setcar thread header)
3956 (gnus-summary-goto-subject article)
3957 (let* ((datal (gnus-data-find-list article))
3959 (length (when (cdr datal)
3960 (- (gnus-data-pos data)
3961 (gnus-data-pos (cadr datal)))))
3962 (buffer-read-only nil)
3963 (level (gnus-summary-thread-level)))
3965 (gnus-summary-insert-line
3966 header level nil (gnus-article-mark article)
3967 (memq article gnus-newsgroup-replied)
3968 (memq article gnus-newsgroup-expirable)
3969 ;; Only insert the Subject string when it's different
3970 ;; from the previous Subject string.
3975 (mail-header-subject
3978 (gnus-data-find-list
3980 (gnus-data-list t)))))
3981 ;; Error on the side of excessive subjects.
3983 (mail-header-subject header)))
3985 (mail-header-subject header))
3986 nil (cdr (assq article gnus-newsgroup-scored))
3987 (memq article gnus-newsgroup-processable))
3989 (gnus-data-update-list
3990 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3992 (defun gnus-summary-update-article (article &optional iheader)
3993 "Update ARTICLE in the summary buffer."
3994 (set-buffer gnus-summary-buffer)
3995 (let* ((header (gnus-summary-article-header article))
3996 (id (mail-header-id header))
3997 (data (gnus-data-find article))
3998 (thread (gnus-id-to-thread id))
3999 (references (mail-header-references header))
4003 (when (and references
4004 (not (equal "" references)))
4007 (buffer-read-only nil)
4013 (delq thread parent)))
4014 (if (gnus-summary-insert-subject id header)
4015 ;; Set the (possibly) new article number in the data structure.
4016 (gnus-data-set-number data (gnus-id-to-article id))
4020 (defun gnus-rebuild-thread (id &optional line)
4021 "Rebuild the thread containing ID.
4022 If LINE, insert the rebuilt thread starting on line LINE."
4023 (let ((buffer-read-only nil)
4024 old-pos current thread data)
4025 (if (not gnus-show-threads)
4026 (setq thread (list (car (gnus-id-to-thread id))))
4027 ;; Get the thread this article is part of.
4028 (setq thread (gnus-remove-thread id)))
4029 (setq old-pos (gnus-point-at-bol))
4030 (setq current (save-excursion
4031 (and (re-search-backward "[\r\n]" nil t)
4032 (gnus-summary-article-number))))
4033 ;; If this is a gathered thread, we have to go some re-gathering.
4034 (when (stringp (car thread))
4035 (let ((subject (car thread))
4037 (setq thread (cdr thread))
4039 (unless (memq (setq thr (gnus-id-to-thread
4041 (mail-header-id (caar thread)))))
4044 (setq thread (cdr thread)))
4045 ;; We now have all (unique) roots.
4046 (if (= (length roots) 1)
4047 ;; All the loose roots are now one solid root.
4048 (setq thread (car roots))
4049 (setq thread (cons subject (gnus-sort-threads roots))))))
4051 ;; We then insert this thread into the summary buffer.
4053 (goto-char (point-min))
4054 (forward-line (1- line)))
4055 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4056 (if gnus-show-threads
4057 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4058 (gnus-summary-prepare-unthreaded thread))
4059 (setq data (nreverse gnus-newsgroup-data))
4060 (setq threads gnus-newsgroup-threads))
4061 ;; We splice the new data into the data structure.
4062 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4063 ;;!!! then we want to insert at the beginning of the buffer.
4064 ;;!!! That happens to be true with Gnus now, but that may
4065 ;;!!! change in the future. Perhaps.
4066 (gnus-data-enter-list
4067 (if line nil current) data (- (point) old-pos))
4068 (setq gnus-newsgroup-threads
4069 (nconc threads gnus-newsgroup-threads))
4070 (gnus-data-compute-positions))))
4072 (defun gnus-number-to-header (number)
4073 "Return the header for article NUMBER."
4074 (let ((headers gnus-newsgroup-headers))
4076 (not (= number (mail-header-number (car headers)))))
4081 (defun gnus-parent-headers (in-headers &optional generation)
4082 "Return the headers of the GENERATIONeth parent of HEADERS."
4084 (setq generation 1))
4086 (headers in-headers)
4089 (not (zerop generation))
4090 (setq references (mail-header-references headers)))
4091 (setq headers (if (and references
4092 (setq parent (gnus-parent-id references)))
4093 (car (gnus-id-to-thread parent))
4096 (and (not (eq headers in-headers))
4099 (defun gnus-id-to-thread (id)
4100 "Return the (sub-)thread where ID appears."
4101 (gnus-gethash id gnus-newsgroup-dependencies))
4103 (defun gnus-id-to-article (id)
4104 "Return the article number of ID."
4105 (let ((thread (gnus-id-to-thread id)))
4108 (mail-header-number (car thread)))))
4110 (defun gnus-id-to-header (id)
4111 "Return the article headers of ID."
4112 (car (gnus-id-to-thread id)))
4114 (defun gnus-article-displayed-root-p (article)
4115 "Say whether ARTICLE is a root(ish) article."
4116 (let ((level (gnus-summary-thread-level article))
4117 (refs (mail-header-references (gnus-summary-article-header article)))
4123 ((null (gnus-parent-id refs)) t)
4125 (null (setq particle (gnus-id-to-article
4126 (gnus-parent-id refs))))
4127 (null (gnus-summary-thread-level particle)))))))
4129 (defun gnus-root-id (id)
4130 "Return the id of the root of the thread where ID appears."
4132 (while (and id (setq prev (car (gnus-id-to-thread id))))
4134 id (gnus-parent-id (mail-header-references prev))))
4137 (defun gnus-articles-in-thread (thread)
4138 "Return the list of articles in THREAD."
4139 (cons (mail-header-number (car thread))
4140 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4142 (defun gnus-remove-thread (id &optional dont-remove)
4143 "Remove the thread that has ID in it."
4144 (let (headers thread last-id)
4145 ;; First go up in this thread until we find the root.
4146 (setq last-id (gnus-root-id id)
4147 headers (message-flatten-list (gnus-id-to-thread last-id)))
4148 ;; We have now found the real root of this thread. It might have
4149 ;; been gathered into some loose thread, so we have to search
4150 ;; through the threads to find the thread we wanted.
4151 (let ((threads gnus-newsgroup-threads)
4154 (setq sub (car threads))
4155 (if (stringp (car sub))
4156 ;; This is a gathered thread, so we look at the roots
4157 ;; below it to find whether this article is in this
4160 (setq sub (cdr sub))
4162 (when (member (caar sub) headers)
4163 (setq thread (car threads)
4166 (setq sub (cdr sub))))
4167 ;; It's an ordinary thread, so we check it.
4168 (when (eq (car sub) (car headers))
4171 (setq threads (cdr threads)))
4172 ;; If this article is in no thread, then it's a root.
4175 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4176 (setq thread (gnus-id-to-thread last-id)))
4179 thread ; We return this thread.
4181 (if (stringp (car thread))
4183 ;; If we use dummy roots, then we have to remove the
4184 ;; dummy root as well.
4185 (when (eq gnus-summary-make-false-root 'dummy)
4186 ;; We go to the dummy root by going to
4187 ;; the first sub-"thread", and then one line up.
4188 (gnus-summary-goto-article
4189 (mail-header-number (caadr thread)))
4192 (gnus-data-compute-positions))
4193 (setq thread (cdr thread))
4195 (gnus-remove-thread-1 (car thread))
4196 (setq thread (cdr thread))))
4197 (gnus-remove-thread-1 thread))))))))
4199 (defun gnus-remove-thread-1 (thread)
4200 "Remove the thread THREAD recursively."
4201 (let ((number (mail-header-number (pop thread)))
4203 (setq thread (reverse thread))
4205 (gnus-remove-thread-1 (pop thread)))
4206 (when (setq d (gnus-data-find number))
4207 (goto-char (gnus-data-pos d))
4208 (gnus-summary-show-thread)
4211 (- (gnus-point-at-bol)
4213 (1+ (gnus-point-at-eol))
4214 (gnus-delete-line)))))))
4216 (defun gnus-sort-threads-1 (threads func)
4217 (sort (mapcar (lambda (thread)
4220 (gnus-sort-threads-1 (cdr thread) func))))
4223 (defun gnus-sort-threads (threads)
4225 (if (not gnus-thread-sort-functions)
4227 (gnus-message 8 "Sorting threads...")
4229 (gnus-sort-threads-1
4231 (gnus-make-sort-function gnus-thread-sort-functions))
4232 (gnus-message 8 "Sorting threads...done"))))
4234 (defun gnus-sort-articles (articles)
4236 (when gnus-article-sort-functions
4237 (gnus-message 7 "Sorting articles...")
4239 (setq gnus-newsgroup-headers
4240 (sort articles (gnus-make-sort-function
4241 gnus-article-sort-functions)))
4242 (gnus-message 7 "Sorting articles...done"))))
4244 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4245 (defmacro gnus-thread-header (thread)
4246 "Return header of first article in THREAD.
4247 Note that THREAD must never, ever be anything else than a variable -
4248 using some other form will lead to serious barfage."
4249 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4250 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4251 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4254 (defsubst gnus-article-sort-by-number (h1 h2)
4255 "Sort articles by article number."
4256 (< (mail-header-number h1)
4257 (mail-header-number h2)))
4259 (defun gnus-thread-sort-by-number (h1 h2)
4260 "Sort threads by root article number."
4261 (gnus-article-sort-by-number
4262 (gnus-thread-header h1) (gnus-thread-header h2)))
4264 (defsubst gnus-article-sort-by-random (h1 h2)
4265 "Sort articles by article number."
4268 (defun gnus-thread-sort-by-random (h1 h2)
4269 "Sort threads by root article number."
4270 (gnus-article-sort-by-random
4271 (gnus-thread-header h1) (gnus-thread-header h2)))
4273 (defsubst gnus-article-sort-by-lines (h1 h2)
4274 "Sort articles by article Lines header."
4275 (< (mail-header-lines h1)
4276 (mail-header-lines h2)))
4278 (defun gnus-thread-sort-by-lines (h1 h2)
4279 "Sort threads by root article Lines header."
4280 (gnus-article-sort-by-lines
4281 (gnus-thread-header h1) (gnus-thread-header h2)))
4283 (defsubst gnus-article-sort-by-chars (h1 h2)
4284 "Sort articles by octet length."
4285 (< (mail-header-chars h1)
4286 (mail-header-chars h2)))
4288 (defun gnus-thread-sort-by-chars (h1 h2)
4289 "Sort threads by root article octet length."
4290 (gnus-article-sort-by-chars
4291 (gnus-thread-header h1) (gnus-thread-header h2)))
4293 (defsubst gnus-article-sort-by-author (h1 h2)
4294 "Sort articles by root author."
4296 (let ((addr (car (mime-entity-read-field h1 'From))))
4297 (or (std11-full-name-string addr)
4298 (std11-address-string addr)
4300 (let ((addr (car (mime-entity-read-field h2 'From))))
4301 (or (std11-full-name-string addr)
4302 (std11-address-string addr)
4306 (defun gnus-thread-sort-by-author (h1 h2)
4307 "Sort threads by root author."
4308 (gnus-article-sort-by-author
4309 (gnus-thread-header h1) (gnus-thread-header h2)))
4311 (defsubst gnus-article-sort-by-subject (h1 h2)
4312 "Sort articles by root subject."
4314 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4315 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4317 (defun gnus-thread-sort-by-subject (h1 h2)
4318 "Sort threads by root subject."
4319 (gnus-article-sort-by-subject
4320 (gnus-thread-header h1) (gnus-thread-header h2)))
4322 (defsubst gnus-article-sort-by-date (h1 h2)
4323 "Sort articles by root article date."
4325 (gnus-date-get-time (mail-header-date h1))
4326 (gnus-date-get-time (mail-header-date h2))))
4328 (defun gnus-thread-sort-by-date (h1 h2)
4329 "Sort threads by root article date."
4330 (gnus-article-sort-by-date
4331 (gnus-thread-header h1) (gnus-thread-header h2)))
4333 (defsubst gnus-article-sort-by-score (h1 h2)
4334 "Sort articles by root article score.
4335 Unscored articles will be counted as having a score of zero."
4336 (> (or (cdr (assq (mail-header-number h1)
4337 gnus-newsgroup-scored))
4338 gnus-summary-default-score 0)
4339 (or (cdr (assq (mail-header-number h2)
4340 gnus-newsgroup-scored))
4341 gnus-summary-default-score 0)))
4343 (defun gnus-thread-sort-by-score (h1 h2)
4344 "Sort threads by root article score."
4345 (gnus-article-sort-by-score
4346 (gnus-thread-header h1) (gnus-thread-header h2)))
4348 (defun gnus-thread-sort-by-total-score (h1 h2)
4349 "Sort threads by the sum of all scores in the thread.
4350 Unscored articles will be counted as having a score of zero."
4351 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4353 (defun gnus-thread-total-score (thread)
4354 ;; This function find the total score of THREAD.
4359 (if (stringp (car thread))
4360 (apply gnus-thread-score-function 0
4361 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4362 (gnus-thread-total-score-1 thread)))
4364 (gnus-thread-total-score-1 (list thread)))))
4366 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4367 "Sort threads such that the thread with the most recently arrived article comes first."
4368 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4370 (defun gnus-thread-highest-number (thread)
4371 "Return the highest article number in THREAD."
4372 (apply 'max (mapcar (lambda (header)
4373 (mail-header-number header))
4374 (message-flatten-list thread))))
4376 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4377 "Sort threads such that the thread with the most recently dated article comes first."
4378 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4380 (defun gnus-thread-latest-date (thread)
4381 "Return the highest article date in THREAD."
4382 (let ((previous-time 0))
4387 (mail-header-parse-date
4389 (mail-header-date header)
4390 (error previous-time))))))
4392 (message-flatten-list thread)
4394 (< (mail-header-number h1)
4395 (mail-header-number h2))))))))
4397 (defun gnus-thread-total-score-1 (root)
4398 ;; This function find the total score of the thread below ROOT.
4399 (setq root (car root))
4400 (apply gnus-thread-score-function
4402 (mapcar 'gnus-thread-total-score
4403 (cdr (gnus-id-to-thread (mail-header-id root))))
4404 (when (> (mail-header-number root) 0)
4405 (list (or (cdr (assq (mail-header-number root)
4406 gnus-newsgroup-scored))
4407 gnus-summary-default-score 0))))
4408 (list gnus-summary-default-score)
4411 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4412 (defvar gnus-tmp-prev-subject nil)
4413 (defvar gnus-tmp-false-parent nil)
4414 (defvar gnus-tmp-root-expunged nil)
4415 (defvar gnus-tmp-dummy-line nil)
4417 (eval-when-compile (defvar gnus-tmp-header))
4418 (defun gnus-extra-header (type &optional header)
4419 "Return the extra header of TYPE."
4420 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4423 (defvar gnus-tmp-thread-tree-header-string "")
4425 (defcustom gnus-sum-thread-tree-root "> "
4426 "With %B spec, used for the root of a thread.
4427 If nil, use subject instead."
4429 :group 'gnus-thread)
4430 (defcustom gnus-sum-thread-tree-single-indent ""
4431 "With %B spec, used for a thread with just one message.
4432 If nil, use subject instead."
4434 :group 'gnus-thread)
4435 (defcustom gnus-sum-thread-tree-vertical "| "
4436 "With %B spec, used for drawing a vertical line."
4438 :group 'gnus-thread)
4439 (defcustom gnus-sum-thread-tree-indent " "
4440 "With %B spec, used for indenting."
4442 :group 'gnus-thread)
4443 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4444 "With %B spec, used for a leaf with brothers."
4446 :group 'gnus-thread)
4447 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4448 "With %B spec, used for a leaf without brothers."
4450 :group 'gnus-thread)
4452 (defun gnus-summary-prepare-threads (threads)
4453 "Prepare summary buffer from THREADS and indentation LEVEL.
4454 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4455 or a straight list of headers."
4456 (gnus-message 7 "Generating summary...")
4458 (setq gnus-newsgroup-threads threads)
4461 (let ((gnus-tmp-level 0)
4462 (default-score (or gnus-summary-default-score 0))
4463 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4464 thread number subject stack state gnus-tmp-gathered beg-match
4465 new-roots gnus-tmp-new-adopts thread-end simp-subject
4466 gnus-tmp-header gnus-tmp-unread
4467 gnus-tmp-replied gnus-tmp-subject-or-nil
4468 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4469 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4470 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4473 (setq gnus-tmp-prev-subject nil)
4475 (if (vectorp (car threads))
4476 ;; If this is a straight (sic) list of headers, then a
4477 ;; threaded summary display isn't required, so we just create
4478 ;; an unthreaded one.
4479 (gnus-summary-prepare-unthreaded threads)
4481 ;; Do the threaded display.
4483 (while (or threads stack gnus-tmp-new-adopts new-roots)
4485 (if (and (= gnus-tmp-level 0)
4488 (not gnus-tmp-false-parent)
4489 (or gnus-tmp-new-adopts new-roots))
4490 (if gnus-tmp-new-adopts
4491 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4492 thread (list (car gnus-tmp-new-adopts))
4493 gnus-tmp-header (caar thread)
4494 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4496 (setq thread (list (car new-roots))
4497 gnus-tmp-header (caar thread)
4498 new-roots (cdr new-roots))))
4501 ;; If there are some threads, we do them before the
4502 ;; threads on the stack.
4503 (setq thread threads
4504 gnus-tmp-header (caar thread))
4505 ;; There were no current threads, so we pop something off
4507 (setq state (car stack)
4508 gnus-tmp-level (car state)
4509 tree-stack (cadr state)
4510 thread (caddr state)
4512 gnus-tmp-header (caar thread))))
4514 (setq gnus-tmp-false-parent nil)
4515 (setq gnus-tmp-root-expunged nil)
4516 (setq thread-end nil)
4518 (if (stringp gnus-tmp-header)
4519 ;; The header is a dummy root.
4521 ((eq gnus-summary-make-false-root 'adopt)
4522 ;; We let the first article adopt the rest.
4523 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4525 (setq gnus-tmp-gathered
4527 (lambda (h) (mail-header-number (car h)))
4530 (setq thread (cons (list (caar thread)
4533 (setq gnus-tmp-level -1
4534 gnus-tmp-false-parent t))
4535 ((eq gnus-summary-make-false-root 'empty)
4536 ;; We print adopted articles with empty subject fields.
4537 (setq gnus-tmp-gathered
4539 (lambda (h) (mail-header-number (car h)))
4542 (setq gnus-tmp-level -1))
4543 ((eq gnus-summary-make-false-root 'dummy)
4544 ;; We remember that we probably want to output a dummy
4546 (setq gnus-tmp-dummy-line gnus-tmp-header)
4547 (setq gnus-tmp-prev-subject gnus-tmp-header))
4549 ;; We do not make a root for the gathered
4550 ;; sub-threads at all.
4551 (setq gnus-tmp-level -1)))
4553 (setq number (mail-header-number gnus-tmp-header)
4554 subject (mail-header-subject gnus-tmp-header)
4555 simp-subject (gnus-simplify-subject-fully subject))
4558 ;; If the thread has changed subject, we might want to make
4559 ;; this subthread into a root.
4560 ((and (null gnus-thread-ignore-subject)
4561 (not (zerop gnus-tmp-level))
4562 gnus-tmp-prev-subject
4563 (not (string= gnus-tmp-prev-subject simp-subject)))
4564 (setq new-roots (nconc new-roots (list (car thread)))
4566 gnus-tmp-header nil))
4567 ;; If the article lies outside the current limit,
4568 ;; then we do not display it.
4569 ((not (memq number gnus-newsgroup-limit))
4570 (setq gnus-tmp-gathered
4572 (lambda (h) (mail-header-number (car h)))
4575 (setq gnus-tmp-new-adopts (if (cdar thread)
4576 (append gnus-tmp-new-adopts
4578 gnus-tmp-new-adopts)
4580 gnus-tmp-header nil)
4581 (when (zerop gnus-tmp-level)
4582 (setq gnus-tmp-root-expunged t)))
4583 ;; Perhaps this article is to be marked as read?
4584 ((and gnus-summary-mark-below
4585 (< (or (cdr (assq number gnus-newsgroup-scored))
4587 gnus-summary-mark-below)
4588 ;; Don't touch sparse articles.
4589 (not (gnus-summary-article-sparse-p number))
4590 (not (gnus-summary-article-ancient-p number)))
4591 (setq gnus-newsgroup-unreads
4592 (delq number gnus-newsgroup-unreads))
4593 (if gnus-newsgroup-auto-expire
4594 (setq gnus-newsgroup-expirable
4595 (gnus-add-to-sorted-list
4596 gnus-newsgroup-expirable number))
4597 (push (cons number gnus-low-score-mark)
4598 gnus-newsgroup-reads))))
4600 (when gnus-tmp-header
4601 ;; We may have an old dummy line to output before this
4603 (when (and gnus-tmp-dummy-line
4606 (mail-header-subject gnus-tmp-header)))
4607 (gnus-summary-insert-dummy-line
4608 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4609 (setq gnus-tmp-dummy-line nil))
4611 ;; Compute the mark.
4612 (setq gnus-tmp-unread (gnus-article-mark number))
4614 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4615 gnus-tmp-header gnus-tmp-level)
4616 gnus-newsgroup-data)
4618 ;; Actually insert the line.
4620 gnus-tmp-subject-or-nil
4622 ((and gnus-thread-ignore-subject
4623 gnus-tmp-prev-subject
4624 (not (string= gnus-tmp-prev-subject simp-subject)))
4626 ((zerop gnus-tmp-level)
4627 (if (and (eq gnus-summary-make-false-root 'empty)
4628 (memq number gnus-tmp-gathered)
4629 gnus-tmp-prev-subject
4630 (string= gnus-tmp-prev-subject simp-subject))
4631 gnus-summary-same-subject
4633 (t gnus-summary-same-subject)))
4634 (if (and (eq gnus-summary-make-false-root 'adopt)
4635 (= gnus-tmp-level 1)
4636 (memq number gnus-tmp-gathered))
4637 (setq gnus-tmp-opening-bracket ?\<
4638 gnus-tmp-closing-bracket ?\>)
4639 (setq gnus-tmp-opening-bracket ?\[
4640 gnus-tmp-closing-bracket ?\]))
4642 gnus-tmp-indentation
4643 (aref gnus-thread-indent-array gnus-tmp-level)
4644 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4645 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4646 gnus-summary-default-score 0)
4648 (if (or (null gnus-summary-default-score)
4649 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4650 gnus-summary-zcore-fuzz))
4652 (if (< gnus-tmp-score gnus-summary-default-score)
4653 gnus-score-below-mark gnus-score-over-mark))
4655 (cond ((memq number gnus-newsgroup-processable)
4657 ((memq number gnus-newsgroup-cached)
4659 ((memq number gnus-newsgroup-replied)
4661 ((memq number gnus-newsgroup-forwarded)
4662 gnus-forwarded-mark)
4663 ((memq number gnus-newsgroup-saved)
4665 ((memq number gnus-newsgroup-recent)
4667 ((memq number gnus-newsgroup-unseen)
4670 gnus-tmp-from (mail-header-from gnus-tmp-header)
4673 ((string-match "<[^>]+> *$" gnus-tmp-from)
4674 (setq beg-match (match-beginning 0))
4675 (or (and (string-match "^\".+\"" gnus-tmp-from)
4676 (substring gnus-tmp-from 1 (1- (match-end 0))))
4677 (substring gnus-tmp-from 0 beg-match)))
4678 ((string-match "(.+)" gnus-tmp-from)
4679 (substring gnus-tmp-from
4680 (1+ (match-beginning 0)) (1- (match-end 0))))
4682 gnus-tmp-thread-tree-header-string
4684 ((not gnus-show-threads) "")
4685 ((zerop gnus-tmp-level)
4687 (or gnus-sum-thread-tree-root subject)
4688 (or gnus-sum-thread-tree-single-indent subject)))
4690 (concat (apply 'concat
4691 (mapcar (lambda (item)
4693 gnus-sum-thread-tree-vertical
4694 gnus-sum-thread-tree-indent))
4695 (cdr (reverse tree-stack))))
4697 gnus-sum-thread-tree-leaf-with-other
4698 gnus-sum-thread-tree-single-leaf)))))
4699 (when (string= gnus-tmp-name "")
4700 (setq gnus-tmp-name gnus-tmp-from))
4701 (unless (numberp gnus-tmp-lines)
4702 (setq gnus-tmp-lines -1))
4703 (if (= gnus-tmp-lines -1)
4704 (setq gnus-tmp-lines "?")
4705 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4706 (gnus-put-text-property
4708 (progn (eval gnus-summary-line-format-spec) (point))
4709 'gnus-number number)
4712 (gnus-run-hooks 'gnus-summary-update-hook)
4715 (setq gnus-tmp-prev-subject simp-subject)))
4717 (when (nth 1 thread)
4718 (push (list (max 0 gnus-tmp-level)
4719 (copy-list tree-stack)
4722 (push (if (nth 1 thread) 1 0) tree-stack)
4723 (incf gnus-tmp-level)
4724 (setq threads (if thread-end nil (cdar thread)))
4726 (setq gnus-tmp-level 0)))))
4727 (gnus-message 7 "Generating summary...done"))
4729 (defun gnus-summary-prepare-unthreaded (headers)
4730 "Generate an unthreaded summary buffer based on HEADERS."
4731 (let (header number mark)
4736 ;; We may have to root out some bad articles...
4737 (when (memq (setq number (mail-header-number
4738 (setq header (pop headers))))
4739 gnus-newsgroup-limit)
4740 ;; Mark article as read when it has a low score.
4741 (when (and gnus-summary-mark-below
4742 (< (or (cdr (assq number gnus-newsgroup-scored))
4743 gnus-summary-default-score 0)
4744 gnus-summary-mark-below)
4745 (not (gnus-summary-article-ancient-p number)))
4746 (setq gnus-newsgroup-unreads
4747 (delq number gnus-newsgroup-unreads))
4748 (if gnus-newsgroup-auto-expire
4749 (push number gnus-newsgroup-expirable)
4750 (push (cons number gnus-low-score-mark)
4751 gnus-newsgroup-reads)))
4753 (setq mark (gnus-article-mark number))
4754 (push (gnus-data-make number mark (1+ (point)) header 0)
4755 gnus-newsgroup-data)
4756 (gnus-summary-insert-line
4758 mark (memq number gnus-newsgroup-replied)
4759 (memq number gnus-newsgroup-expirable)
4760 (mail-header-subject header) nil
4761 (cdr (assq number gnus-newsgroup-scored))
4762 (memq number gnus-newsgroup-processable))))))
4764 (defun gnus-summary-remove-list-identifiers ()
4765 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4766 (let ((regexp (if (consp gnus-list-identifiers)
4767 (mapconcat 'identity gnus-list-identifiers " *\\|")
4768 gnus-list-identifiers))
4771 (dolist (header gnus-newsgroup-headers)
4772 (setq subject (mail-header-subject header)
4774 (while (string-match
4775 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4778 (concat (substring subject 0 (match-beginning 2))
4779 (substring subject (match-end 0)))
4783 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4785 (concat (substring subject 0 (match-beginning 1))
4786 (substring subject (match-end 1)))))
4788 (mail-header-set-subject header subject))))))
4790 (defun gnus-fetch-headers (articles)
4791 "Fetch headers of ARTICLES."
4792 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4793 (gnus-message 5 "Fetching headers for %s..." name)
4796 (setq gnus-headers-retrieved-by
4797 (gnus-retrieve-headers
4798 articles gnus-newsgroup-name
4799 ;; We might want to fetch old headers, but
4800 ;; not if there is only 1 article.
4802 (not (eq gnus-fetch-old-headers 'some))
4803 (not (numberp gnus-fetch-old-headers)))
4804 (> (length articles) 1))
4805 gnus-fetch-old-headers))))
4806 (gnus-get-newsgroup-headers-xover
4807 articles nil nil gnus-newsgroup-name t)
4808 (gnus-get-newsgroup-headers))
4809 (gnus-message 5 "Fetching headers for %s...done" name))))
4811 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4812 "Select newsgroup GROUP.
4813 If READ-ALL is non-nil, all articles in the group are selected.
4814 If SELECT-ARTICLES, only select those articles from GROUP."
4815 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4816 ;;!!! Dirty hack; should be removed.
4817 (gnus-summary-ignore-duplicates
4818 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4820 gnus-summary-ignore-duplicates))
4821 (info (nth 2 entry))
4822 articles fetched-articles cached)
4824 (unless (gnus-check-server
4825 (set (make-local-variable 'gnus-current-select-method)
4826 (gnus-find-method-for-group group)))
4827 (error "Couldn't open server"))
4829 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4830 (gnus-activate-group group) ; Or we can activate it...
4831 (progn ; Or we bug out.
4832 (when (equal major-mode 'gnus-summary-mode)
4833 (kill-buffer (current-buffer)))
4834 (error "Couldn't activate group %s: %s"
4835 group (gnus-status-message group))))
4837 (unless (gnus-request-group group t)
4838 (when (equal major-mode 'gnus-summary-mode)
4839 (kill-buffer (current-buffer)))
4840 (error "Couldn't request group %s: %s"
4841 group (gnus-status-message group)))
4843 (setq gnus-newsgroup-name group
4844 gnus-newsgroup-unselected nil
4845 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4847 (let ((display (gnus-group-find-parameter group 'display)))
4848 (setq gnus-newsgroup-display
4850 ((not (zerop (or (car-safe read-all) 0)))
4851 ;; The user entered the group with C-u SPC/RET, let's show
4857 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4859 ;; The following is probably the "correct" solution, but
4860 ;; it makes Gnus fetch all headers and then limit the
4861 ;; articles (which is slow), so instead we hack the
4862 ;; select-articles parameter instead. -- Simon Josefsson
4865 ;; (gnus-byte-compile
4866 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4868 (setq select-articles
4869 (gnus-uncompress-range
4870 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4874 (cdr (gnus-active group)))))
4879 (gnus-summary-setup-default-charset)
4881 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4882 (when (gnus-virtual-group-p group)
4883 (setq cached gnus-newsgroup-cached))
4885 (setq gnus-newsgroup-unreads
4886 (gnus-sorted-ndifference
4887 (gnus-sorted-ndifference gnus-newsgroup-unreads
4888 gnus-newsgroup-marked)
4889 gnus-newsgroup-dormant))
4891 (setq gnus-newsgroup-processable nil)
4893 (gnus-update-read-articles group gnus-newsgroup-unreads)
4895 ;; Adjust and set lists of article marks.
4897 (gnus-adjust-marked-articles info))
4899 (if (setq articles select-articles)
4900 (setq gnus-newsgroup-unselected
4901 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4902 (setq articles (gnus-articles-to-read group read-all)))
4906 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4908 ((eq articles 0) nil)
4910 ;; Init the dependencies hash table.
4911 (setq gnus-newsgroup-dependencies
4912 (gnus-make-hashtable (length articles)))
4913 (gnus-set-global-variables)
4914 ;; Retrieve the headers and read them in.
4915 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4917 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4919 (setq gnus-newsgroup-cached cached))
4921 ;; Suppress duplicates?
4922 (when gnus-suppress-duplicates
4923 (gnus-dup-suppress-articles))
4925 ;; Set the initial limit.
4926 (setq gnus-newsgroup-limit (copy-sequence articles))
4927 ;; Remove canceled articles from the list of unread articles.
4928 (setq fetched-articles
4929 (mapcar (lambda (headers) (mail-header-number headers))
4930 gnus-newsgroup-headers))
4931 (setq gnus-newsgroup-articles fetched-articles)
4932 (setq gnus-newsgroup-unreads
4933 (gnus-sorted-nintersection
4934 gnus-newsgroup-unreads fetched-articles))
4935 (gnus-compute-unseen-list)
4937 ;; Removed marked articles that do not exist.
4938 (gnus-update-missing-marks
4939 (gnus-sorted-difference articles fetched-articles))
4940 ;; We might want to build some more threads first.
4941 (when (and gnus-fetch-old-headers
4942 (eq gnus-headers-retrieved-by 'nov))
4943 (if (eq gnus-fetch-old-headers 'invisible)
4944 (gnus-build-all-threads)
4945 (gnus-build-old-threads)))
4946 ;; Let the Gnus agent mark articles as read.
4948 (gnus-agent-get-undownloaded-list))
4949 ;; Remove list identifiers from subject
4950 (when gnus-list-identifiers
4951 (gnus-summary-remove-list-identifiers))
4952 ;; Check whether auto-expire is to be done in this group.
4953 (setq gnus-newsgroup-auto-expire
4954 (gnus-group-auto-expirable-p group))
4955 ;; Set up the article buffer now, if necessary.
4956 (unless gnus-single-article-buffer
4957 (gnus-article-setup-buffer))
4958 ;; First and last article in this newsgroup.
4959 (when gnus-newsgroup-headers
4960 (setq gnus-newsgroup-begin
4961 (mail-header-number (car gnus-newsgroup-headers))
4964 (gnus-last-element gnus-newsgroup-headers))))
4965 ;; GROUP is successfully selected.
4966 (or gnus-newsgroup-headers t)))))
4968 (defun gnus-compute-unseen-list ()
4969 ;; The `seen' marks are treated specially.
4970 (if (not gnus-newsgroup-seen)
4971 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4972 (setq gnus-newsgroup-unseen
4973 (gnus-inverse-list-range-intersection
4974 gnus-newsgroup-articles gnus-newsgroup-seen))))
4976 (defun gnus-summary-display-make-predicate (display)
4977 (require 'gnus-agent)
4978 (when (= (length display) 1)
4979 (setq display (car display)))
4980 (unless gnus-summary-display-cache
4981 (dolist (elem (append '((unread . unread)
4984 gnus-article-mark-lists))
4985 (push (cons (cdr elem)
4987 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
4988 gnus-summary-display-cache)))
4989 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
4990 (gnus-category-predicate-cache gnus-summary-display-cache))
4991 (gnus-get-predicate display)))
4993 ;; Uses the dynamically bound `number' variable.
4995 (defun gnus-article-marked-p (type &optional article)
4996 (let ((article (or article number)))
4999 (memq article gnus-newsgroup-marked))
5001 (memq article gnus-newsgroup-spam-marked))
5003 (memq article gnus-newsgroup-unsendable))
5004 ((eq type 'undownload)
5005 (memq article gnus-newsgroup-undownloaded))
5006 ((eq type 'download)
5007 (memq article gnus-newsgroup-downloadable))
5009 (memq article gnus-newsgroup-unreads))
5011 (memq article gnus-newsgroup-reads))
5013 (memq article gnus-newsgroup-dormant) )
5015 (memq article gnus-newsgroup-expirable))
5017 (memq article gnus-newsgroup-replied))
5019 (memq article gnus-newsgroup-killed))
5020 ((eq type 'bookmark)
5021 (assq article gnus-newsgroup-bookmarks))
5023 (assq article gnus-newsgroup-scored))
5025 (memq article gnus-newsgroup-saved))
5027 (memq article gnus-newsgroup-cached))
5029 (memq article gnus-newsgroup-forwarded))
5031 (not (memq article gnus-newsgroup-unseen)))
5033 (memq article gnus-newsgroup-recent))
5036 (defun gnus-articles-to-read (group &optional read-all)
5037 "Find out what articles the user wants to read."
5039 ;; Select all articles if `read-all' is non-nil, or if there
5040 ;; are no unread articles.
5042 (and (zerop (length gnus-newsgroup-marked))
5043 (zerop (length gnus-newsgroup-unreads)))
5044 ;; Fetch all if the predicate is non-nil.
5045 gnus-newsgroup-display)
5046 ;; We want to select the headers for all the articles in
5047 ;; the group, so we select either all the active
5048 ;; articles in the group, or (if that's nil), the
5049 ;; articles in the cache.
5051 (gnus-uncompress-range (gnus-active group))
5052 (gnus-cache-articles-in-group group))
5053 ;; Select only the "normal" subset of articles.
5055 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5056 gnus-newsgroup-unreads)))
5057 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5058 (scored (length scored-list))
5059 (number (length articles))
5060 (marked (+ (length gnus-newsgroup-marked)
5061 (length gnus-newsgroup-dormant)))
5066 ((numberp gnus-newsgroup-display)
5067 gnus-newsgroup-display)
5071 ((and (or (<= scored marked) (= scored number))
5072 (numberp gnus-large-newsgroup)
5073 (> number gnus-large-newsgroup))
5074 (let* ((cursor-in-echo-area nil)
5075 (initial (gnus-parameter-large-newsgroup-initial
5076 gnus-newsgroup-name))
5080 "How many articles from %s (%s %d): "
5082 (gnus-group-decoded-name gnus-newsgroup-name)
5084 (if initial "max" "default")
5087 (cons (number-to-string initial)
5089 (if (string-match "^[ \t]*$" input) number input)))
5090 ((and (> scored marked) (< scored number)
5091 (> (- scored number) 20))
5094 (format "%s %s (%d scored, %d total): "
5095 "How many articles from"
5096 (gnus-group-decoded-name group)
5098 (if (string-match "^[ \t]*$" input)
5102 (message "Quit getting the articles to read")
5104 (setq select (if (stringp select) (string-to-number select) select))
5105 (if (or (null select) (zerop select))
5107 (if (and (not (zerop scored)) (<= (abs select) scored))
5109 (setq articles (sort scored-list '<))
5110 (setq number (length articles)))
5111 (setq articles (copy-sequence articles)))
5113 (when (< (abs select) number)
5115 ;; Select the N oldest articles.
5116 (setcdr (nthcdr (1- (abs select)) articles) nil)
5117 ;; Select the N most recent articles.
5118 (setq articles (nthcdr (- number select) articles))))
5119 (setq gnus-newsgroup-unselected
5120 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5121 (when gnus-alter-articles-to-read-function
5122 (setq gnus-newsgroup-unreads
5124 (funcall gnus-alter-articles-to-read-function
5125 gnus-newsgroup-name gnus-newsgroup-unreads)
5129 (defun gnus-killed-articles (killed articles)
5132 (when (inline (gnus-member-of-range (car articles) killed))
5133 (push (car articles) out))
5134 (setq articles (cdr articles)))
5137 (defun gnus-uncompress-marks (marks)
5138 "Uncompress the mark ranges in MARKS."
5139 (let ((uncompressed '(score bookmark))
5142 (if (memq (caar marks) uncompressed)
5143 (push (car marks) out)
5144 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5145 (setq marks (cdr marks)))
5148 (defun gnus-article-mark-to-type (mark)
5149 "Return the type of MARK."
5150 (or (cadr (assq mark gnus-article-special-mark-lists))
5153 (defun gnus-article-unpropagatable-p (mark)
5154 "Return whether MARK should be propagated to backend."
5155 (memq mark gnus-article-unpropagated-mark-lists))
5157 (defun gnus-adjust-marked-articles (info)
5158 "Set all article lists and remove all marks that are no longer valid."
5159 (let* ((marked-lists (gnus-info-marks info))
5160 (active (gnus-active (gnus-info-group info)))
5163 (types gnus-article-mark-lists)
5164 marks var articles article mark mark-type)
5166 (dolist (marks marked-lists)
5167 (setq mark (car marks)
5168 mark-type (gnus-article-mark-to-type mark)
5169 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5171 ;; We set the variable according to the type of the marks list,
5172 ;; and then adjust the marks to a subset of the active articles.
5174 ;; Adjust "simple" lists.
5175 ((eq mark-type 'list)
5176 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5177 (when (memq mark '(tick dormant expire reply save))
5179 (when (or (< (setq article (pop articles)) min) (> article max))
5180 (set var (delq article (symbol-value var)))))))
5182 ((eq mark-type 'tuple)
5183 (set var (setq articles (cdr marks)))
5184 (when (not (listp (cdr (symbol-value var))))
5185 (set var (list (symbol-value var))))
5186 (when (not (listp (cdr articles)))
5187 (setq articles (list articles)))
5189 (when (or (not (consp (setq article (pop articles))))
5190 (< (car article) min)
5191 (> (car article) max))
5192 (set var (delq article (symbol-value var))))))
5193 ;; Adjust ranges (sloppily).
5194 ((eq mark-type 'range)
5197 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5198 ;; It should be (seen (NUM1 . NUM2)).
5199 (when (numberp (cddr marks))
5200 (setcdr marks (list (cdr marks))))
5201 (setq articles (cdr marks))
5202 (while (and articles
5203 (or (and (consp (car articles))
5204 (> min (cdar articles)))
5205 (and (numberp (car articles))
5206 (> min (car articles)))))
5208 (set var articles))))))))
5210 (defun gnus-update-missing-marks (missing)
5211 "Go through the list of MISSING articles and remove them from the mark lists."
5214 ;; Go through all types.
5215 (dolist (elem gnus-article-mark-lists)
5216 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5217 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5218 (when (symbol-value var)
5219 ;; This list has articles. So we delete all missing
5220 ;; articles from it.
5223 (set var (delq (pop m) (symbol-value var))))))))))
5225 (defun gnus-update-marks ()
5226 "Enter the various lists of marked articles into the newsgroup info list."
5227 (let ((types gnus-article-mark-lists)
5228 (info (gnus-get-info gnus-newsgroup-name))
5229 type list newmarked symbol delta-marks)
5231 ;; Add all marks lists to the list of marks lists.
5232 (while (setq type (pop types))
5233 (setq list (symbol-value
5235 (intern (format "gnus-newsgroup-%s" (car type))))))
5238 ;; Get rid of the entries of the articles that have the
5240 (when (and (eq (cdr type) 'score)
5244 (prev (cons nil list))
5247 (if (or (not (consp (car arts)))
5248 (= (cdar arts) gnus-summary-default-score))
5249 (setcdr prev (cdr arts))
5251 (setq arts (cdr arts)))
5252 (setq list (cdr all)))))
5254 (when (eq (cdr type) 'seen)
5255 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5257 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5258 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5260 (when (and (gnus-check-backend-function
5261 'request-set-mark gnus-newsgroup-name)
5262 (not (gnus-article-unpropagatable-p (cdr type))))
5263 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5264 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5265 (add (gnus-remove-from-range
5266 (gnus-copy-sequence list) old)))
5268 (push (list add 'add (list (cdr type))) delta-marks))
5270 (push (list del 'del (list (cdr type))) delta-marks))))
5273 (push (cons (cdr type) list) newmarked)))
5276 (unless (gnus-check-group gnus-newsgroup-name)
5277 (error "Can't open server for %s" gnus-newsgroup-name))
5278 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5280 ;; Enter these new marks into the info of the group.
5282 (setcar (nthcdr 3 info) newmarked)
5283 ;; Add the marks lists to the end of the info.
5285 (setcdr (nthcdr 2 info) (list newmarked))))
5287 ;; Cut off the end of the info if there's nothing else there.
5291 (when (nthcdr (decf i) info)
5292 (setcdr (nthcdr i info) nil)))))))
5294 (defun gnus-set-mode-line (where)
5295 "Set the mode line of the article or summary buffers.
5296 If WHERE is `summary', the summary mode line format will be used."
5297 ;; Is this mode line one we keep updated?
5298 (when (and (memq where gnus-updated-mode-lines)
5300 (intern (format "gnus-%s-mode-line-format-spec" where))))
5303 ;; We evaluate this in the summary buffer since these
5304 ;; variables are buffer-local to that buffer.
5305 (set-buffer gnus-summary-buffer)
5306 ;; We bind all these variables that are used in the `eval' form
5308 (let* ((mformat (symbol-value
5310 (format "gnus-%s-mode-line-format-spec" where))))
5311 (gnus-tmp-group-name (gnus-group-decoded-name
5312 gnus-newsgroup-name))
5313 (gnus-tmp-article-number (or gnus-current-article 0))
5314 (gnus-tmp-unread gnus-newsgroup-unreads)
5315 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5316 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5317 (gnus-tmp-unread-and-unselected
5318 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5319 (zerop gnus-tmp-unselected))
5321 ((zerop gnus-tmp-unselected)
5322 (format "{%d more}" gnus-tmp-unread-and-unticked))
5323 (t (format "{%d(+%d) more}"
5324 gnus-tmp-unread-and-unticked
5325 gnus-tmp-unselected))))
5327 (if (and gnus-current-headers
5328 (vectorp gnus-current-headers))
5329 (gnus-mode-string-quote
5330 (mail-header-subject gnus-current-headers))
5332 bufname-length max-len
5333 gnus-tmp-header);; passed as argument to any user-format-funcs
5334 (setq mode-string (eval mformat))
5335 (setq bufname-length (if (string-match "%b" mode-string)
5338 (if (eq where 'summary)
5340 (get-buffer gnus-article-buffer))))
5343 (setq max-len (max 4 (if gnus-mode-non-string-length
5345 gnus-mode-non-string-length
5347 (length mode-string))))
5348 ;; We might have to chop a bit of the string off...
5349 (when (> (length mode-string) max-len)
5351 (concat (gnus-truncate-string mode-string (- max-len 3))
5353 ;; Pad the mode string a bit.
5354 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5355 ;; Update the mode line.
5356 (setq mode-line-buffer-identification
5357 (gnus-mode-line-buffer-identification (list mode-string)))
5358 (set-buffer-modified-p t))))
5360 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5361 "Go through the HEADERS list and add all Xrefs to a hash table.
5362 The resulting hash table is returned, or nil if no Xrefs were found."
5363 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5364 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5365 (xref-hashtb (gnus-make-hashtable))
5366 start group entry number xrefs header)
5368 (setq header (pop headers))
5369 (when (and (setq xrefs (mail-header-xref header))
5370 (not (memq (setq number (mail-header-number header))
5373 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5374 (setq start (match-end 0))
5375 (setq group (if prefix
5376 (concat prefix (substring xrefs (match-beginning 1)
5378 (substring xrefs (match-beginning 1) (match-end 1))))
5380 (string-to-int (substring xrefs (match-beginning 2)
5382 (if (setq entry (gnus-gethash group xref-hashtb))
5383 (setcdr entry (cons number (cdr entry)))
5384 (gnus-sethash group (cons number nil) xref-hashtb)))))
5385 (and start xref-hashtb)))
5387 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5388 "Look through all the headers and mark the Xrefs as read."
5389 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5390 name entry info xref-hashtb idlist method nth4)
5392 (set-buffer gnus-group-buffer)
5393 (when (setq xref-hashtb
5394 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5397 (unless (string= from-newsgroup (setq name (symbol-name group)))
5398 (setq idlist (symbol-value group))
5399 ;; Dead groups are not updated.
5401 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5403 (when (stringp (setq nth4 (gnus-info-method info)))
5404 (setq nth4 (gnus-server-to-method nth4))))
5405 ;; Only do the xrefs if the group has the same
5406 ;; select method as the group we have just read.
5407 (or (gnus-methods-equal-p
5408 nth4 (gnus-find-method-for-group from-newsgroup))
5410 (equal nth4 (setq method (gnus-find-method-for-group
5412 (and (equal (car nth4) (car method))
5413 (equal (nth 1 nth4) (nth 1 method))))
5414 gnus-use-cross-reference
5415 (or (not (eq gnus-use-cross-reference t))
5417 ;; Only do cross-references on subscribed
5418 ;; groups, if that is what is wanted.
5419 (<= (gnus-info-level info) gnus-level-subscribed))
5420 (gnus-group-make-articles-read name idlist))))
5423 (defun gnus-compute-read-articles (group articles)
5424 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5425 (info (nth 2 entry))
5426 (active (gnus-active group))
5429 ;; First peel off all invalid article numbers.
5431 (let ((ids articles)
5433 (while (setq id (pop ids))
5434 (when (and first (> id (cdr active)))
5435 ;; We'll end up in this situation in one particular
5436 ;; obscure situation. If you re-scan a group and get
5437 ;; a new article that is cross-posted to a different
5438 ;; group that has not been re-scanned, you might get
5439 ;; crossposted article that has a higher number than
5440 ;; Gnus believes possible. So we re-activate this
5441 ;; group as well. This might mean doing the
5442 ;; crossposting thingy will *increase* the number
5443 ;; of articles in some groups. Tsk, tsk.
5444 (setq active (or (gnus-activate-group group) active)))
5445 (when (or (> id (cdr active))
5446 (< id (car active)))
5447 (setq articles (delq id articles))))))
5448 ;; If the read list is nil, we init it.
5450 (null (gnus-info-read info))
5452 (setq ninfo (cons 1 (1- (car active))))
5453 (setq ninfo (gnus-info-read info)))
5454 ;; Then we add the read articles to the range.
5456 ninfo (setq articles (sort articles '<))))))
5458 (defun gnus-group-make-articles-read (group articles)
5459 "Update the info of GROUP to say that ARTICLES are read."
5461 (entry (gnus-gethash group gnus-newsrc-hashtb))
5462 (info (nth 2 entry))
5463 (active (gnus-active group))
5466 (setq range (gnus-compute-read-articles group articles))
5468 (set-buffer gnus-group-buffer)
5471 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5472 (gnus-info-set-read ',info ',(gnus-info-read info))
5473 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5474 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5475 (gnus-group-update-group ,group t))))
5476 ;; Add the read articles to the range.
5477 (gnus-info-set-read info range)
5478 (gnus-request-set-mark group (list (list range 'add '(read))))
5479 ;; Then we have to re-compute how many unread
5480 ;; articles there are in this group.
5484 (setq num (- (1+ (cdr active)) (car active))))
5485 ((not (listp (cdr range)))
5486 (setq num (- (cdr active) (- (1+ (cdr range))
5490 (if (numberp (car range))
5492 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5493 (setq range (cdr range)))
5494 (setq num (- (cdr active) num))))
5495 ;; Update the number of unread articles.
5497 ;; Update the group buffer.
5498 (gnus-group-update-group group t)))))
5500 (defvar gnus-newsgroup-none-id 0)
5502 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5503 (let ((cur nntp-server-buffer)
5506 (save-excursion (set-buffer gnus-summary-buffer)
5507 gnus-newsgroup-dependencies)))
5509 (mail-parse-charset gnus-newsgroup-charset)
5510 (mail-parse-ignored-charsets
5511 (save-excursion (condition-case nil
5512 (set-buffer gnus-summary-buffer)
5514 gnus-newsgroup-ignored-charsets)))
5516 (set-buffer nntp-server-buffer)
5517 ;; Translate all TAB characters into SPACE characters.
5518 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5519 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5520 (gnus-run-hooks 'gnus-parse-headers-hook)
5521 (let ((case-fold-search t)
5522 in-reply-to header p lines chars ctype)
5523 (goto-char (point-min))
5524 ;; Search to the beginning of the next header. Error messages
5525 ;; do not begin with 2 or 3.
5526 (while (re-search-forward "^[23][0-9]+ " nil t)
5529 ;; This implementation of this function, with nine
5530 ;; search-forwards instead of the one re-search-forward and
5531 ;; a case (which basically was the old function) is actually
5532 ;; about twice as fast, even though it looks messier. You
5533 ;; can't have everything, I guess. Speed and elegance
5534 ;; doesn't always go hand in hand.
5537 (make-full-mail-header
5543 (narrow-to-region (point)
5544 (or (and (search-forward "\n.\n" nil t)
5550 (if (search-forward "\nsubject:" nil t)
5551 (nnheader-header-value)
5556 (if (search-forward "\nfrom:" nil t)
5557 (nnheader-header-value)
5562 (if (search-forward "\ndate:" nil t)
5563 (nnheader-header-value) ""))
5567 (setq id (if (re-search-forward
5568 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5569 ;; We do it this way to make sure the Message-ID
5570 ;; is (somewhat) syntactically valid.
5571 (buffer-substring (match-beginning 1)
5573 ;; If there was no message-id, we just fake one
5574 ;; to make subsequent routines simpler.
5575 (nnheader-generate-fake-message-id))))
5579 (if (search-forward "\nreferences:" nil t)
5583 (nnheader-header-value)
5588 (search-backward ">" end t)
5591 (search-backward "<" end t)
5593 ;; Get the references from the in-reply-to header if there
5594 ;; were no references and the in-reply-to header looks
5596 (if (and (search-forward "\nin-reply-to:" nil t)
5597 (setq in-reply-to (nnheader-header-value))
5598 (string-match "<[^>]+>" in-reply-to))
5600 (setq ref (substring in-reply-to (match-beginning 0)
5602 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5603 (setq ref2 (substring in-reply-to (match-beginning 0)
5605 (when (> (length ref2) (length ref))
5612 (if (search-forward "\nchars: " nil t)
5613 (if (numberp (setq chars (ignore-errors (read cur))))
5619 (if (search-forward "\nlines: " nil t)
5620 (if (numberp (setq lines (ignore-errors (read cur))))
5626 (and (search-forward "\nxref:" nil t)
5627 (nnheader-header-value)))
5629 (when gnus-extra-headers
5630 (let ((extra gnus-extra-headers)
5634 (when (search-forward
5635 (concat "\n" (symbol-name (car extra)) ":") nil t)
5636 (push (cons (car extra) (nnheader-header-value)) out))
5640 (if (and (search-forward "\ncontent-type: " nil t)
5641 (setq ctype (nnheader-header-value)))
5642 (mime-entity-set-content-type-internal
5643 header (mime-parse-Content-Type ctype)))
5644 (when (equal id ref)
5647 (when gnus-alter-header-function
5648 (funcall gnus-alter-header-function header)
5649 (setq id (mail-header-id header)
5650 ref (gnus-parent-id (mail-header-references header))))
5653 (gnus-dependencies-add-header
5654 header dependencies force-new))
5655 (push header headers))
5656 (goto-char (point-max))
5658 (nreverse headers)))))
5660 ;; Goes through the xover lines and returns a list of vectors
5661 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5662 force-new dependencies
5663 group also-fetch-heads)
5664 "Parse the news overview data in the server buffer.
5665 Return a list of headers that match SEQUENCE (see
5666 `nntp-retrieve-headers')."
5667 ;; Get the Xref when the users reads the articles since most/some
5668 ;; NNTP servers do not include Xrefs when using XOVER.
5669 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5670 (let ((mail-parse-charset gnus-newsgroup-charset)
5671 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5672 (cur nntp-server-buffer)
5673 (dependencies (or dependencies gnus-newsgroup-dependencies))
5675 ((eq gnus-read-all-available-headers t)
5677 ((stringp gnus-read-all-available-headers)
5678 (string-match gnus-read-all-available-headers group))
5681 number headers header)
5683 (set-buffer nntp-server-buffer)
5684 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5685 ;; Allow the user to mangle the headers before parsing them.
5686 (gnus-run-hooks 'gnus-parse-headers-hook)
5687 (goto-char (point-min))
5688 (gnus-parse-without-error
5689 (while (and (or sequence allp)
5691 (setq number (read cur))
5693 (while (and sequence
5694 (< (car sequence) number))
5695 (setq sequence (cdr sequence))))
5698 (eq number (car sequence))))
5700 (setq sequence (cdr sequence))
5701 (setq header (inline
5702 (gnus-nov-parse-line
5703 number dependencies force-new)))))
5704 (push header headers))
5706 ;; A common bug in inn is that if you have posted an article and
5707 ;; then retrieves the active file, it will answer correctly --
5708 ;; the new article is included. However, a NOV entry for the
5709 ;; article may not have been generated yet, so this may fail.
5710 ;; We work around this problem by retrieving the last few
5711 ;; headers using HEAD.
5712 (if (or (not also-fetch-heads)
5714 ;; We (probably) got all the headers.
5716 (let ((gnus-nov-is-evil t))
5719 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5720 (gnus-get-newsgroup-headers))))))))
5722 (defun gnus-article-get-xrefs ()
5723 "Fill in the Xref value in `gnus-current-headers', if necessary.
5724 This is meant to be called in `gnus-article-internal-prepare-hook'."
5725 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5726 gnus-current-headers)))
5727 (or (not gnus-use-cross-reference)
5729 (and (mail-header-xref headers)
5730 (not (string= (mail-header-xref headers) "")))
5731 (let ((case-fold-search t)
5734 (nnheader-narrow-to-headers)
5735 (goto-char (point-min))
5736 (when (or (and (not (eobp))
5737 (eq (downcase (char-after)) ?x)
5738 (looking-at "Xref:"))
5739 (search-forward "\nXref:" nil t))
5740 (goto-char (1+ (match-end 0)))
5741 (setq xref (buffer-substring (point)
5742 (progn (end-of-line) (point))))
5743 (mail-header-set-xref headers xref)))))))
5745 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5746 "Find article ID and insert the summary line for that article.
5747 OLD-HEADER can either be a header or a line number to insert
5748 the subject line on."
5749 (let* ((line (and (numberp old-header) old-header))
5750 (old-header (and (vectorp old-header) old-header))
5751 (header (cond ((and old-header use-old-header)
5754 (gnus-number-to-header id))
5755 (gnus-number-to-header id))
5757 (gnus-read-header id))))
5758 (number (and (numberp id) id))
5761 ;; Rebuild the thread that this article is part of and go to the
5762 ;; article we have fetched.
5763 (when (and (not gnus-show-threads)
5766 (setq d (gnus-data-find (mail-header-number old-header))))
5767 (goto-char (gnus-data-pos d))
5770 (- (gnus-point-at-bol)
5772 (1+ (gnus-point-at-eol))
5773 (gnus-delete-line))))))
5775 (mail-header-set-number header (mail-header-number old-header)))
5776 (setq gnus-newsgroup-sparse
5777 (delq (setq number (mail-header-number header))
5778 gnus-newsgroup-sparse))
5779 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5780 (push number gnus-newsgroup-limit)
5781 (gnus-rebuild-thread (mail-header-id header) line)
5782 (gnus-summary-goto-subject number nil t))
5783 (when (and (numberp number)
5785 ;; We have to update the boundaries even if we can't fetch the
5786 ;; article if ID is a number -- so that the next `P' or `N'
5787 ;; command will fetch the previous (or next) article even
5788 ;; if the one we tried to fetch this time has been canceled.
5789 (when (> number gnus-newsgroup-end)
5790 (setq gnus-newsgroup-end number))
5791 (when (< number gnus-newsgroup-begin)
5792 (setq gnus-newsgroup-begin number))
5793 (setq gnus-newsgroup-unselected
5794 (delq number gnus-newsgroup-unselected)))
5795 ;; Report back a success?
5796 (and header (mail-header-number header))))
5798 ;;; Process/prefix in the summary buffer
5800 (defun gnus-summary-work-articles (n)
5801 "Return a list of articles to be worked upon.
5802 The prefix argument, the list of process marked articles, and the
5803 current article will be taken into consideration."
5805 (set-buffer gnus-summary-buffer)
5808 ;; A numerical prefix has been given.
5809 (setq n (prefix-numeric-value n))
5810 (let ((backward (< n 0))
5811 (n (abs (prefix-numeric-value n)))
5816 (push (setq article (gnus-summary-article-number))
5819 (gnus-summary-find-prev nil article)
5820 (gnus-summary-find-next nil article)))
5822 (nreverse articles)))
5823 ((and (gnus-region-active-p) (mark))
5824 (message "region active")
5825 ;; Work on the region between point and mark.
5826 (let ((max (max (point) (mark)))
5829 (goto-char (min (point) (mark)))
5832 (push (setq article (gnus-summary-article-number)) articles)
5833 (gnus-summary-find-next nil article)
5835 (nreverse articles))))
5836 (gnus-newsgroup-processable
5837 ;; There are process-marked articles present.
5838 ;; Save current state.
5839 (gnus-summary-save-process-mark)
5841 (reverse gnus-newsgroup-processable))
5843 ;; Just return the current article.
5844 (list (gnus-summary-article-number))))))
5846 (defmacro gnus-summary-iterate (arg &rest forms)
5847 "Iterate over the process/prefixed articles and do FORMS.
5848 ARG is the interactive prefix given to the command. FORMS will be
5849 executed with point over the summary line of the articles."
5850 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5851 `(let ((,articles (gnus-summary-work-articles ,arg)))
5853 (gnus-summary-goto-subject (car ,articles))
5857 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5858 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5860 (defun gnus-summary-save-process-mark ()
5861 "Push the current set of process marked articles on the stack."
5863 (push (copy-sequence gnus-newsgroup-processable)
5864 gnus-newsgroup-process-stack))
5866 (defun gnus-summary-kill-process-mark ()
5867 "Push the current set of process marked articles on the stack and unmark."
5869 (gnus-summary-save-process-mark)
5870 (gnus-summary-unmark-all-processable))
5872 (defun gnus-summary-yank-process-mark ()
5873 "Pop the last process mark state off the stack and restore it."
5875 (unless gnus-newsgroup-process-stack
5876 (error "Empty mark stack"))
5877 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5879 (defun gnus-summary-process-mark-set (set)
5880 "Make SET into the current process marked articles."
5881 (gnus-summary-unmark-all-processable)
5883 (gnus-summary-set-process-mark (pop set))))
5885 ;;; Searching and stuff
5887 (defun gnus-summary-search-group (&optional backward use-level)
5888 "Search for next unread newsgroup.
5889 If optional argument BACKWARD is non-nil, search backward instead."
5891 (set-buffer gnus-group-buffer)
5892 (when (gnus-group-search-forward
5893 backward nil (if use-level (gnus-group-group-level) nil))
5894 (gnus-group-group-name))))
5896 (defun gnus-summary-best-group (&optional exclude-group)
5897 "Find the name of the best unread group.
5898 If EXCLUDE-GROUP, do not go to this group."
5900 (set-buffer gnus-group-buffer)
5902 (gnus-group-best-unread-group exclude-group))))
5904 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5905 (if backward (gnus-summary-find-prev)
5906 (let* ((dummy (gnus-summary-article-intangible-p))
5907 (article (or article (gnus-summary-article-number)))
5908 (arts (gnus-data-find-list article))
5910 (when (and (not dummy)
5911 (or (not gnus-summary-check-current)
5913 (not (gnus-data-unread-p (car arts)))))
5914 (setq arts (cdr arts)))
5919 (when (or (and undownloaded
5920 (eq gnus-undownloaded-mark
5921 (gnus-data-mark (car arts))))
5922 (gnus-data-unread-p (car arts)))
5923 (setq result (car arts)
5925 (setq arts (cdr arts)))
5928 (goto-char (gnus-data-pos result))
5929 (gnus-data-number result)))))
5931 (defun gnus-summary-find-prev (&optional unread article)
5932 (let* ((eobp (eobp))
5933 (article (or article (gnus-summary-article-number)))
5934 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5936 (when (and (not eobp)
5937 (or (not gnus-summary-check-current)
5939 (not (gnus-data-unread-p (car arts)))))
5940 (setq arts (cdr arts)))
5945 (when (gnus-data-unread-p (car arts))
5946 (setq result (car arts)
5948 (setq arts (cdr arts)))
5951 (goto-char (gnus-data-pos result))
5952 (gnus-data-number result))))
5954 (defun gnus-summary-find-subject (subject &optional unread backward article)
5955 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5956 (article (or article (gnus-summary-article-number)))
5957 (articles (gnus-data-list backward))
5958 (arts (gnus-data-find-list article articles))
5960 (when (or (not gnus-summary-check-current)
5962 (not (gnus-data-unread-p (car arts))))
5963 (setq arts (cdr arts)))
5965 (and (or (not unread)
5966 (gnus-data-unread-p (car arts)))
5967 (vectorp (gnus-data-header (car arts)))
5969 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5970 (setq result (car arts)
5972 (setq arts (cdr arts)))
5974 (goto-char (gnus-data-pos result))
5975 (gnus-data-number result))))
5977 (defun gnus-summary-search-forward (&optional unread subject backward)
5978 "Search forward for an article.
5979 If UNREAD, look for unread articles. If SUBJECT, look for
5980 articles with that subject. If BACKWARD, search backward instead."
5981 (cond (subject (gnus-summary-find-subject subject unread backward))
5982 (backward (gnus-summary-find-prev unread))
5983 (t (gnus-summary-find-next unread))))
5985 (defun gnus-recenter (&optional n)
5986 "Center point in window and redisplay frame.
5987 Also do horizontal recentering."
5989 (when (and gnus-auto-center-summary
5990 (not (eq gnus-auto-center-summary 'vertical)))
5991 (gnus-horizontal-recenter))
5994 (defun gnus-summary-recenter ()
5995 "Center point in the summary window.
5996 If `gnus-auto-center-summary' is nil, or the article buffer isn't
5997 displayed, no centering will be performed."
5998 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
5999 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6001 (let* ((top (cond ((< (window-height) 4) 0)
6002 ((< (window-height) 7) 1)
6003 (t (if (numberp gnus-auto-center-summary)
6004 gnus-auto-center-summary
6006 (height (1- (window-height)))
6007 (bottom (save-excursion (goto-char (point-max))
6008 (forward-line (- height))
6010 (window (get-buffer-window (current-buffer))))
6011 ;; The user has to want it.
6012 (when gnus-auto-center-summary
6013 (when (get-buffer-window gnus-article-buffer)
6014 ;; Only do recentering when the article buffer is displayed,
6015 ;; Set the window start to either `bottom', which is the biggest
6016 ;; possible valid number, or the second line from the top,
6017 ;; whichever is the least.
6018 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6019 (if (> bottom top-pos)
6020 ;; Keep the second line from the top visible
6021 (set-window-start window top-pos t)
6022 ;; Try to keep the bottom line visible; if it's partially
6023 ;; obscured, either scroll one more line to make it fully
6024 ;; visible, or revert to using TOP-POS.
6026 (goto-char (point-max))
6028 (let ((last-line-start (point)))
6030 (set-window-start window (point) t)
6031 (when (not (pos-visible-in-window-p last-line-start window))
6033 (set-window-start window (min (point) top-pos) t)))))))
6034 ;; Do horizontal recentering while we're at it.
6035 (when (and (get-buffer-window (current-buffer) t)
6036 (not (eq gnus-auto-center-summary 'vertical)))
6037 (let ((selected (selected-window)))
6038 (select-window (get-buffer-window (current-buffer) t))
6039 (gnus-summary-position-point)
6040 (gnus-horizontal-recenter)
6041 (select-window selected))))))
6043 (defun gnus-summary-jump-to-group (newsgroup)
6044 "Move point to NEWSGROUP in group mode buffer."
6045 ;; Keep update point of group mode buffer if visible.
6046 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6047 (save-window-excursion
6048 ;; Take care of tree window mode.
6049 (when (get-buffer-window gnus-group-buffer)
6050 (pop-to-buffer gnus-group-buffer))
6051 (gnus-group-jump-to-group newsgroup))
6053 ;; Take care of tree window mode.
6054 (if (get-buffer-window gnus-group-buffer)
6055 (pop-to-buffer gnus-group-buffer)
6056 (set-buffer gnus-group-buffer))
6057 (gnus-group-jump-to-group newsgroup))))
6059 ;; This function returns a list of article numbers based on the
6060 ;; difference between the ranges of read articles in this group and
6061 ;; the range of active articles.
6062 (defun gnus-list-of-unread-articles (group)
6063 (let* ((read (gnus-info-read (gnus-get-info group)))
6064 (active (or (gnus-active group) (gnus-activate-group group)))
6067 ;; If none are read, then all are unread.
6069 (setq first (car active))
6070 ;; If the range of read articles is a single range, then the
6071 ;; first unread article is the article after the last read
6072 ;; article. Sounds logical, doesn't it?
6073 (if (and (not (listp (cdr read)))
6074 (or (< (car read) (car active))
6075 (progn (setq read (list read))
6077 (setq first (max (car active) (1+ (cdr read))))
6078 ;; `read' is a list of ranges.
6079 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6082 (setq first (car active)))
6085 (while (< first nlast)
6087 (setq first (1+ first))))
6088 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6089 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6090 (setq read (cdr read)))))
6091 ;; And add the last unread articles.
6092 (while (<= first last)
6094 (setq first (1+ first)))
6095 ;; Return the list of unread articles.
6096 (delq 0 (nreverse unread))))
6098 (defun gnus-list-of-read-articles (group)
6099 "Return a list of unread, unticked and non-dormant articles."
6100 (let* ((info (gnus-get-info group))
6101 (marked (gnus-info-marks info))
6102 (active (gnus-active group)))
6104 (gnus-list-range-difference
6105 (gnus-list-range-difference
6106 (gnus-sorted-complement
6107 (gnus-uncompress-range active)
6108 (gnus-list-of-unread-articles group))
6109 (cdr (assq 'dormant marked)))
6110 (cdr (assq 'tick marked))))))
6112 ;; Various summary commands
6114 (defun gnus-summary-select-article-buffer ()
6115 "Reconfigure windows to show article buffer."
6117 (if (not (gnus-buffer-live-p gnus-article-buffer))
6118 (error "There is no article buffer for this summary buffer")
6119 (gnus-configure-windows 'article)
6120 (select-window (get-buffer-window gnus-article-buffer))))
6122 (defun gnus-summary-universal-argument (arg)
6123 "Perform any operation on all articles that are process/prefixed."
6125 (let ((articles (gnus-summary-work-articles arg))
6132 (substitute-command-keys
6133 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6135 (gnus-error 1 "Undefined key")
6138 (gnus-summary-goto-subject (setq article (pop articles)))
6139 (let (gnus-newsgroup-processable)
6140 (command-execute func))
6141 (gnus-summary-remove-process-mark article)))))
6142 (gnus-summary-position-point))
6144 (defun gnus-summary-toggle-truncation (&optional arg)
6145 "Toggle truncation of summary lines.
6146 With arg, turn line truncation on iff arg is positive."
6148 (setq truncate-lines
6149 (if (null arg) (not truncate-lines)
6150 (> (prefix-numeric-value arg) 0)))
6153 (defun gnus-summary-reselect-current-group (&optional all rescan)
6154 "Exit and then reselect the current newsgroup.
6155 The prefix argument ALL means to select all articles."
6157 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6158 (error "Ephemeral groups can't be reselected"))
6159 (let ((current-subject (gnus-summary-article-number))
6160 (group gnus-newsgroup-name))
6161 (setq gnus-newsgroup-begin nil)
6163 ;; We have to adjust the point of group mode buffer because
6164 ;; point was moved to the next unread newsgroup by exiting.
6165 (gnus-summary-jump-to-group group)
6168 (save-window-excursion
6169 ;; Don't show group contents.
6170 (set-window-start (selected-window) (point-max))
6171 (gnus-group-get-new-news-this-group 1))))
6172 (gnus-group-read-group all t)
6173 (gnus-summary-goto-subject current-subject nil t)))
6175 (defun gnus-summary-rescan-group (&optional all)
6176 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6178 (gnus-summary-reselect-current-group all t))
6180 (defun gnus-summary-update-info (&optional non-destructive)
6182 (let ((group gnus-newsgroup-name))
6184 (when gnus-newsgroup-kill-headers
6185 (setq gnus-newsgroup-killed
6186 (gnus-compress-sequence
6188 (gnus-list-range-intersection
6189 gnus-newsgroup-unselected gnus-newsgroup-killed)
6190 gnus-newsgroup-unreads)
6192 (unless (listp (cdr gnus-newsgroup-killed))
6193 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6194 (let ((headers gnus-newsgroup-headers))
6195 ;; Set the new ranges of read articles.
6197 (set-buffer gnus-group-buffer)
6198 (gnus-undo-force-boundary))
6199 (gnus-update-read-articles
6200 group (gnus-sorted-union
6201 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6202 ;; Set the current article marks.
6203 (let ((gnus-newsgroup-scored
6204 (if (and (not gnus-save-score)
6205 (not non-destructive))
6207 gnus-newsgroup-scored)))
6209 (gnus-update-marks)))
6210 ;; Do the cross-ref thing.
6211 (when gnus-use-cross-reference
6212 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6213 ;; Do not switch windows but change the buffer to work.
6214 (set-buffer gnus-group-buffer)
6215 (unless (gnus-ephemeral-group-p group)
6216 (gnus-group-update-group group)))))))
6218 (defun gnus-summary-save-newsrc (&optional force)
6219 "Save the current number of read/marked articles in the dribble buffer.
6220 The dribble buffer will then be saved.
6221 If FORCE (the prefix), also save the .newsrc file(s)."
6223 (gnus-summary-update-info t)
6225 (gnus-save-newsrc-file)
6226 (gnus-dribble-save)))
6228 (defun gnus-summary-exit (&optional temporary)
6229 "Exit reading current newsgroup, and then return to group selection mode.
6230 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6232 (gnus-set-global-variables)
6233 (gnus-kill-save-kill-buffer)
6234 (gnus-async-halt-prefetch)
6235 (let* ((group gnus-newsgroup-name)
6236 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6239 (buf (current-buffer)))
6241 ;; Do adaptive scoring, and possibly save score files.
6242 (when gnus-newsgroup-adaptive
6243 (gnus-score-adaptive))
6244 (when gnus-use-scoring
6246 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6247 ;; If we have several article buffers, we kill them at exit.
6248 (unless gnus-single-article-buffer
6249 (gnus-kill-buffer gnus-original-article-buffer)
6250 (setq gnus-article-current nil))
6251 (when gnus-use-cache
6252 (gnus-cache-possibly-remove-articles)
6253 (gnus-cache-save-buffers))
6254 (gnus-async-prefetch-remove-group group)
6255 (when gnus-suppress-duplicates
6256 (gnus-dup-enter-articles))
6257 (when gnus-use-trees
6258 (gnus-tree-close group))
6259 (when gnus-use-cache
6260 (gnus-cache-write-active))
6261 ;; Remove entries for this group.
6262 (nnmail-purge-split-history (gnus-group-real-name group))
6263 ;; Make all changes in this group permanent.
6265 (gnus-run-hooks 'gnus-exit-group-hook)
6266 (gnus-summary-update-info))
6267 (gnus-close-group group)
6268 ;; Make sure where we were, and go to next newsgroup.
6269 (set-buffer gnus-group-buffer)
6271 (gnus-group-jump-to-group group))
6272 (gnus-run-hooks 'gnus-summary-exit-hook)
6273 (unless (or quit-config
6274 ;; If this group has disappeared from the summary
6275 ;; buffer, don't skip forwards.
6276 (not (string= group (gnus-group-group-name))))
6277 (gnus-group-next-unread-group 1))
6278 (setq group-point (point))
6281 ;; If we have several article buffers, we kill them at exit.
6282 (unless gnus-single-article-buffer
6283 (gnus-kill-buffer gnus-article-buffer)
6284 (gnus-kill-buffer gnus-original-article-buffer)
6285 (setq gnus-article-current nil))
6287 (if (not gnus-kill-summary-on-exit)
6289 (gnus-deaden-summary)
6291 ;; We set all buffer-local variables to nil. It is unclear why
6292 ;; this is needed, but if we don't, buffer-local variables are
6293 ;; not garbage-collected, it seems. This would the lead to en
6294 ;; ever-growing Emacs.
6295 (gnus-summary-clear-local-variables)
6296 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6297 (gnus-summary-clear-local-variables))
6298 (when (get-buffer gnus-article-buffer)
6299 (bury-buffer gnus-article-buffer))
6300 ;; We clear the global counterparts of the buffer-local
6301 ;; variables as well, just to be on the safe side.
6302 (set-buffer gnus-group-buffer)
6303 (gnus-summary-clear-local-variables)
6304 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6305 (gnus-summary-clear-local-variables)))
6306 (setq gnus-current-select-method gnus-select-method)
6307 (pop-to-buffer gnus-group-buffer)
6308 (if (not quit-config)
6310 (goto-char group-point)
6311 (gnus-configure-windows 'group 'force)
6312 (unless (pos-visible-in-window-p)
6313 (forward-line (/ (static-if (featurep 'xemacs)
6314 (window-displayed-height)
6315 (1- (window-height)))
6317 (set-window-start (selected-window) (point))
6318 (goto-char group-point)))
6319 (gnus-handle-ephemeral-exit quit-config))
6320 ;; Return to group mode buffer.
6321 (when (eq mode 'gnus-summary-mode)
6322 (gnus-kill-buffer buf))
6323 ;; Clear the current group name.
6325 (setq gnus-newsgroup-name nil)))))
6327 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6328 (defun gnus-summary-exit-no-update (&optional no-questions)
6329 "Quit reading current newsgroup without updating read article info."
6331 (let* ((group gnus-newsgroup-name)
6332 (quit-config (gnus-group-quit-config group)))
6333 (when (or no-questions
6335 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6336 (gnus-async-halt-prefetch)
6338 (delq 'gnus-summary-expire-articles
6339 (copy-sequence gnus-summary-prepare-exit-hook)))
6340 ;; If we have several article buffers, we kill them at exit.
6341 (unless gnus-single-article-buffer
6342 (gnus-kill-buffer gnus-article-buffer)
6343 (gnus-kill-buffer gnus-original-article-buffer)
6344 (setq gnus-article-current nil))
6345 (if (not gnus-kill-summary-on-exit)
6346 (gnus-deaden-summary)
6347 (gnus-close-group group)
6348 (gnus-summary-clear-local-variables)
6349 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6350 (gnus-summary-clear-local-variables))
6351 (set-buffer gnus-group-buffer)
6352 (gnus-summary-clear-local-variables)
6353 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6354 (gnus-summary-clear-local-variables))
6355 (when (get-buffer gnus-summary-buffer)
6356 (kill-buffer gnus-summary-buffer)))
6357 (unless gnus-single-article-buffer
6358 (setq gnus-article-current nil))
6359 (when gnus-use-trees
6360 (gnus-tree-close group))
6361 (gnus-async-prefetch-remove-group group)
6362 (when (get-buffer gnus-article-buffer)
6363 (bury-buffer gnus-article-buffer))
6364 ;; Return to the group buffer.
6365 (gnus-configure-windows 'group 'force)
6366 ;; Clear the current group name.
6367 (setq gnus-newsgroup-name nil)
6368 (when (equal (gnus-group-group-name) group)
6369 (gnus-group-next-unread-group 1))
6371 (gnus-handle-ephemeral-exit quit-config)))))
6373 (defun gnus-handle-ephemeral-exit (quit-config)
6374 "Handle movement when leaving an ephemeral group.
6375 The state which existed when entering the ephemeral is reset."
6376 (if (not (buffer-name (car quit-config)))
6377 (gnus-configure-windows 'group 'force)
6378 (set-buffer (car quit-config))
6379 (cond ((eq major-mode 'gnus-summary-mode)
6380 (gnus-set-global-variables))
6381 ((eq major-mode 'gnus-article-mode)
6383 ;; The `gnus-summary-buffer' variable may point
6384 ;; to the old summary buffer when using a single
6386 (unless (gnus-buffer-live-p gnus-summary-buffer)
6387 (set-buffer gnus-group-buffer))
6388 (set-buffer gnus-summary-buffer)
6389 (gnus-set-global-variables))))
6390 (if (or (eq (cdr quit-config) 'article)
6391 (eq (cdr quit-config) 'pick))
6393 ;; The current article may be from the ephemeral group
6394 ;; thus it is best that we reload this article
6395 (gnus-summary-show-article)
6396 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6397 (gnus-configure-windows 'pick 'force)
6398 (gnus-configure-windows (cdr quit-config) 'force)))
6399 (gnus-configure-windows (cdr quit-config) 'force))
6400 (when (eq major-mode 'gnus-summary-mode)
6401 (gnus-summary-next-subject 1 nil t)
6402 (gnus-summary-recenter)
6403 (gnus-summary-position-point))))
6405 (defun gnus-summary-preview-mime-message ()
6406 "MIME decode and play this message."
6408 (let ((gnus-break-pages nil)
6410 (gnus-summary-select-article gnus-show-all-headers t))
6411 (let ((w (get-buffer-window gnus-article-buffer)))
6413 (select-window (get-buffer-window gnus-article-buffer)))))
6417 (defvar gnus-dead-summary-mode-map nil)
6419 (unless gnus-dead-summary-mode-map
6420 (setq gnus-dead-summary-mode-map (make-keymap))
6421 (suppress-keymap gnus-dead-summary-mode-map)
6422 (substitute-key-definition
6423 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6424 (dolist (key '("\C-d" "\r" "\177" [delete]))
6425 (define-key gnus-dead-summary-mode-map
6426 key 'gnus-summary-wake-up-the-dead))
6427 (dolist (key '("q" "Q"))
6428 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6430 (defvar gnus-dead-summary-mode nil
6431 "Minor mode for Gnus summary buffers.")
6433 (defun gnus-dead-summary-mode (&optional arg)
6434 "Minor mode for Gnus summary buffers."
6436 (when (eq major-mode 'gnus-summary-mode)
6437 (make-local-variable 'gnus-dead-summary-mode)
6438 (setq gnus-dead-summary-mode
6439 (if (null arg) (not gnus-dead-summary-mode)
6440 (> (prefix-numeric-value arg) 0)))
6441 (when gnus-dead-summary-mode
6442 (gnus-add-minor-mode
6443 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6445 (defun gnus-deaden-summary ()
6446 "Make the current summary buffer into a dead summary buffer."
6447 ;; Kill any previous dead summary buffer.
6448 (when (and gnus-dead-summary
6449 (buffer-name gnus-dead-summary))
6451 (set-buffer gnus-dead-summary)
6452 (when gnus-dead-summary-mode
6453 (kill-buffer (current-buffer)))))
6454 ;; Make this the current dead summary.
6455 (setq gnus-dead-summary (current-buffer))
6456 (gnus-dead-summary-mode 1)
6457 (let ((name (buffer-name)))
6458 (when (string-match "Summary" name)
6460 (concat (substring name 0 (match-beginning 0)) "Dead "
6461 (substring name (match-beginning 0)))
6465 (defun gnus-kill-or-deaden-summary (buffer)
6466 "Kill or deaden the summary BUFFER."
6468 (when (and (buffer-name buffer)
6469 (not gnus-single-article-buffer))
6472 (gnus-kill-buffer gnus-article-buffer)
6473 (gnus-kill-buffer gnus-original-article-buffer)))
6476 (gnus-kill-summary-on-exit
6477 (when (and gnus-use-trees
6478 (gnus-buffer-exists-p buffer))
6481 (gnus-tree-close gnus-newsgroup-name)))
6482 (gnus-kill-buffer buffer))
6483 ;; Deaden the buffer.
6484 ((gnus-buffer-exists-p buffer)
6487 (gnus-deaden-summary))))))
6489 (defun gnus-summary-wake-up-the-dead (&rest args)
6490 "Wake up the dead summary buffer."
6492 (gnus-dead-summary-mode -1)
6493 (let ((name (buffer-name)))
6494 (when (string-match "Dead " name)
6496 (concat (substring name 0 (match-beginning 0))
6497 (substring name (match-end 0)))
6499 (gnus-message 3 "This dead summary is now alive again"))
6501 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6502 (defun gnus-summary-fetch-faq (&optional faq-dir)
6503 "Fetch the FAQ for the current group.
6504 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6508 (when current-prefix-arg
6510 "Faq dir: " (and (listp gnus-group-faq-directory)
6511 (mapcar (lambda (file) (list file))
6512 gnus-group-faq-directory))))))
6513 (let (gnus-faq-buffer)
6514 (when (setq gnus-faq-buffer
6515 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6516 (gnus-configure-windows 'summary-faq))))
6518 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6519 (defun gnus-summary-describe-group (&optional force)
6520 "Describe the current newsgroup."
6522 (gnus-group-describe-group force gnus-newsgroup-name))
6524 (defun gnus-summary-describe-briefly ()
6525 "Describe summary mode commands briefly."
6527 (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")))
6529 ;; Walking around group mode buffer from summary mode.
6531 (defun gnus-summary-next-group (&optional no-article target-group backward)
6532 "Exit current newsgroup and then select next unread newsgroup.
6533 If prefix argument NO-ARTICLE is non-nil, no article is selected
6534 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6535 previous group instead."
6537 ;; Stop pre-fetching.
6538 (gnus-async-halt-prefetch)
6539 (let ((current-group gnus-newsgroup-name)
6540 (current-buffer (current-buffer))
6542 ;; First we semi-exit this group to update Xrefs and all variables.
6543 ;; We can't do a real exit, because the window conf must remain
6544 ;; the same in case the user is prompted for info, and we don't
6545 ;; want the window conf to change before that...
6546 (gnus-summary-exit t)
6547 (while (not entered)
6548 ;; Then we find what group we are supposed to enter.
6549 (set-buffer gnus-group-buffer)
6550 (gnus-group-jump-to-group current-group)
6553 (if (eq gnus-keep-same-level 'best)
6554 (gnus-summary-best-group gnus-newsgroup-name)
6555 (gnus-summary-search-group backward gnus-keep-same-level))))
6556 (if (not target-group)
6557 ;; There are no further groups, so we return to the group
6560 (gnus-message 5 "Returning to the group buffer")
6562 (when (gnus-buffer-live-p current-buffer)
6563 (set-buffer current-buffer)
6564 (gnus-summary-exit))
6565 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6566 ;; We try to enter the target group.
6567 (gnus-group-jump-to-group target-group)
6568 (let ((unreads (gnus-group-group-unread)))
6569 (if (and (or (eq t unreads)
6570 (and unreads (not (zerop unreads))))
6571 (gnus-summary-read-group
6572 target-group nil no-article
6573 (and (buffer-name current-buffer) current-buffer)
6576 (setq current-group target-group
6577 target-group nil)))))))
6579 (defun gnus-summary-prev-group (&optional no-article)
6580 "Exit current newsgroup and then select previous unread newsgroup.
6581 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6583 (gnus-summary-next-group no-article nil t))
6585 ;; Walking around summary lines.
6587 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6588 "Go to the first unread subject.
6589 If UNREAD is non-nil, go to the first unread article.
6590 Returns the article selected or nil if there are no unread articles."
6595 ((null gnus-newsgroup-data)
6596 (gnus-message 3 "No articles in the group")
6598 ;; Pick the first article.
6600 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6601 (gnus-data-number (car gnus-newsgroup-data)))
6602 ;; No unread articles.
6603 ((null gnus-newsgroup-unreads)
6604 (gnus-message 3 "No more unread articles")
6606 ;; Find the first unread article.
6608 (let ((data gnus-newsgroup-data))
6610 (and (not (and undownloaded
6611 (eq gnus-undownloaded-mark
6612 (gnus-data-mark (car data)))))
6615 (gnus-data-number (car data))
6616 gnus-newsgroup-unseen))
6617 (not (gnus-data-unread-p (car data))))
6618 (not (gnus-data-unread-p (car data))))))
6619 (setq data (cdr data)))
6621 (goto-char (gnus-data-pos (car data)))
6622 (gnus-data-number (car data))))))
6623 (gnus-summary-position-point)))
6625 (defun gnus-summary-next-subject (n &optional unread dont-display)
6626 "Go to next N'th summary line.
6627 If N is negative, go to the previous N'th subject line.
6628 If UNREAD is non-nil, only unread articles are selected.
6629 The difference between N and the actual number of steps taken is
6632 (let ((backward (< n 0))
6636 (gnus-summary-find-prev unread)
6637 (gnus-summary-find-next unread)))
6638 (unless (zerop (setq n (1- n)))
6639 (gnus-summary-show-thread)))
6641 (gnus-message 7 "No more%s articles"
6642 (if unread " unread" "")))
6643 (unless dont-display
6644 (gnus-summary-recenter)
6645 (gnus-summary-position-point))
6648 (defun gnus-summary-next-unread-subject (n)
6649 "Go to next N'th unread summary line."
6651 (gnus-summary-next-subject n t))
6653 (defun gnus-summary-prev-subject (n &optional unread)
6654 "Go to previous N'th summary line.
6655 If optional argument UNREAD is non-nil, only unread article is selected."
6657 (gnus-summary-next-subject (- n) unread))
6659 (defun gnus-summary-prev-unread-subject (n)
6660 "Go to previous N'th unread summary line."
6662 (gnus-summary-next-subject (- n) t))
6664 (defun gnus-summary-goto-subject (article &optional force silent)
6665 "Go the subject line of ARTICLE.
6666 If FORCE, also allow jumping to articles not currently shown."
6667 (interactive "nArticle number: ")
6668 (unless (numberp article)
6669 (error "Article %s is not a number" article))
6671 (data (gnus-data-find article)))
6672 ;; We read in the article if we have to.
6675 (gnus-summary-insert-subject
6677 (if (or (numberp force) (vectorp force)) force)
6679 (setq data (gnus-data-find article)))
6684 (gnus-message 3 "Can't find article %d" article))
6686 (let ((pt (gnus-data-pos data)))
6688 (gnus-summary-set-article-display-arrow pt))
6689 (gnus-summary-position-point)
6692 ;; Walking around summary lines with displaying articles.
6694 (defun gnus-summary-expand-window (&optional arg)
6695 "Make the summary buffer take up the entire Emacs frame.
6696 Given a prefix, will force an `article' buffer configuration."
6699 (gnus-configure-windows 'article 'force)
6700 (gnus-configure-windows 'summary 'force)))
6702 (defun gnus-summary-display-article (article &optional all-header)
6703 "Display ARTICLE in article buffer."
6704 (when (gnus-buffer-live-p gnus-article-buffer)
6705 (with-current-buffer gnus-article-buffer
6706 (set-buffer-multibyte t)))
6707 (gnus-set-global-variables)
6708 (when (gnus-buffer-live-p gnus-article-buffer)
6709 (with-current-buffer gnus-article-buffer
6710 (setq gnus-article-charset gnus-newsgroup-charset)
6711 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6712 (set-buffer-multibyte t)))
6716 (if gnus-summary-display-article-function
6717 (funcall gnus-summary-display-article-function article all-header)
6718 (gnus-article-prepare article all-header))
6719 (with-current-buffer gnus-article-buffer
6720 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6722 (gnus-run-hooks 'gnus-select-article-hook)
6723 (when (and gnus-current-article
6724 (not (zerop gnus-current-article)))
6725 (gnus-summary-goto-subject gnus-current-article))
6726 (gnus-summary-recenter)
6727 (when (and gnus-use-trees gnus-show-threads)
6728 (gnus-possibly-generate-tree article)
6729 (gnus-highlight-selected-tree article))
6730 ;; Successfully display article.
6731 (gnus-article-set-window-start
6732 (cdr (assq article gnus-newsgroup-bookmarks))))))
6734 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6735 "Select the current article.
6736 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6737 non-nil, the article will be re-fetched even if it already present in
6738 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6740 ;; Make sure we are in the summary buffer to work around bbdb bug.
6741 (unless (eq major-mode 'gnus-summary-mode)
6742 (set-buffer gnus-summary-buffer))
6743 (let ((article (or article (gnus-summary-article-number)))
6744 (all-headers (not (not all-headers))) ;Must be T or NIL.
6745 gnus-summary-display-article-function)
6747 (gnus-summary-article-pseudo-p article)
6748 (error "This is a pseudo-article"))
6750 (set-buffer gnus-summary-buffer)
6751 (if (or (and gnus-single-article-buffer
6752 (or (null gnus-current-article)
6753 (null gnus-article-current)
6754 (null (get-buffer gnus-article-buffer))
6755 (not (eq article (cdr gnus-article-current)))
6756 (not (equal (car gnus-article-current)
6757 gnus-newsgroup-name))))
6758 (and (not gnus-single-article-buffer)
6759 (or (null gnus-current-article)
6760 (not (eq gnus-current-article article))))
6762 ;; The requested article is different from the current article.
6764 (gnus-summary-display-article article all-headers)
6765 (gnus-article-set-window-start
6766 (cdr (assq article gnus-newsgroup-bookmarks)))
6770 (defun gnus-summary-force-verify-and-decrypt ()
6772 (let ((mm-verify-option 'known)
6773 (mm-decrypt-option 'known)
6774 (gnus-buttonized-mime-types (append (list "multipart/signed"
6775 "multipart/encrypted")
6776 gnus-buttonized-mime-types)))
6777 (gnus-summary-select-article nil 'force)))
6779 (defun gnus-summary-set-current-mark (&optional current-mark)
6780 "Obsolete function."
6783 (defun gnus-summary-next-article (&optional unread subject backward push)
6784 "Select the next article.
6785 If UNREAD, only unread articles are selected.
6786 If SUBJECT, only articles with SUBJECT are selected.
6787 If BACKWARD, the previous article is selected instead of the next."
6790 ;; Is there such an article?
6791 ((and (gnus-summary-search-forward unread subject backward)
6792 (or (gnus-summary-display-article (gnus-summary-article-number))
6793 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6794 (gnus-summary-position-point))
6795 ;; If not, we try the first unread, if that is wanted.
6797 gnus-auto-select-same
6798 (gnus-summary-first-unread-article))
6799 (gnus-summary-position-point)
6800 (gnus-message 6 "Wrapped"))
6801 ;; Try to get next/previous article not displayed in this group.
6802 ((and gnus-auto-extend-newsgroup
6803 (not unread) (not subject))
6804 (gnus-summary-goto-article
6805 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6806 nil (count-lines (point-min) (point))))
6807 ;; Go to next/previous group.
6809 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6810 (gnus-summary-jump-to-group gnus-newsgroup-name))
6811 (let ((cmd last-command-char)
6814 (set-buffer gnus-group-buffer)
6817 (if (eq gnus-keep-same-level 'best)
6818 (gnus-summary-best-group gnus-newsgroup-name)
6819 (gnus-summary-search-group backward gnus-keep-same-level))))
6820 ;; For some reason, the group window gets selected. We change
6822 (select-window (get-buffer-window (current-buffer)))
6823 ;; Select next unread newsgroup automagically.
6825 ((or (not gnus-auto-select-next)
6827 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6828 ((or (eq gnus-auto-select-next 'quietly)
6829 (and (eq gnus-auto-select-next 'slightly-quietly)
6831 (and (eq gnus-auto-select-next 'almost-quietly)
6832 (gnus-summary-last-article-p)))
6834 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6836 (gnus-message 7 "No more%s articles (%s)..."
6837 (if unread " unread" "")
6838 (if group (concat "selecting " group)
6840 (gnus-summary-next-group nil group backward)))
6842 (when (gnus-key-press-event-p last-input-event)
6843 (gnus-summary-walk-group-buffer
6844 gnus-newsgroup-name cmd unread backward point))))))))
6846 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6847 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6848 (?\C-p (gnus-group-prev-unread-group 1))))
6849 (cursor-in-echo-area t)
6850 keve key group ended)
6852 (set-buffer gnus-group-buffer)
6855 (if (eq gnus-keep-same-level 'best)
6856 (gnus-summary-best-group gnus-newsgroup-name)
6857 (gnus-summary-search-group backward gnus-keep-same-level))))
6860 5 "No more%s articles%s" (if unread " unread" "")
6862 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6863 (format " (Type %s for %s [%s])"
6864 (single-key-description cmd) group
6865 (car (gnus-gethash group gnus-newsrc-hashtb)))
6866 (format " (Type %s to exit %s)"
6867 (single-key-description cmd)
6868 gnus-newsgroup-name)))
6869 ;; Confirm auto selection.
6870 (setq key (car (setq keve (gnus-read-event-char))))
6873 ((assq key keystrokes)
6874 (let ((obuf (current-buffer)))
6875 (switch-to-buffer gnus-group-buffer)
6877 (gnus-group-jump-to-group group))
6878 (eval (cadr (assq key keystrokes)))
6879 (setq group (gnus-group-group-name))
6880 (switch-to-buffer obuf))
6884 (gnus-ephemeral-group-p gnus-newsgroup-name))
6886 (gnus-summary-next-group nil group backward)))
6888 (push (cdr keve) unread-command-events))))))
6890 (defun gnus-summary-next-unread-article ()
6891 "Select unread article after current one."
6893 (gnus-summary-next-article
6894 (or (not (eq gnus-summary-goto-unread 'never))
6895 (gnus-summary-last-article-p (gnus-summary-article-number)))
6896 (and gnus-auto-select-same
6897 (gnus-summary-article-subject))))
6899 (defun gnus-summary-prev-article (&optional unread subject)
6900 "Select the article after the current one.
6901 If UNREAD is non-nil, only unread articles are selected."
6903 (gnus-summary-next-article unread subject t))
6905 (defun gnus-summary-prev-unread-article ()
6906 "Select unread article before current one."
6908 (gnus-summary-prev-article
6909 (or (not (eq gnus-summary-goto-unread 'never))
6910 (gnus-summary-first-article-p (gnus-summary-article-number)))
6911 (and gnus-auto-select-same
6912 (gnus-summary-article-subject))))
6914 (defun gnus-summary-next-page (&optional lines circular)
6915 "Show next page of the selected article.
6916 If at the end of the current article, select the next article.
6917 LINES says how many lines should be scrolled up.
6919 If CIRCULAR is non-nil, go to the start of the article instead of
6920 selecting the next article when reaching the end of the current
6923 (setq gnus-summary-buffer (current-buffer))
6924 (gnus-set-global-variables)
6925 (let ((article (gnus-summary-article-number))
6926 (article-window (get-buffer-window gnus-article-buffer t))
6928 ;; If the buffer is empty, we have no article.
6930 (error "No article to select"))
6931 (gnus-configure-windows 'article)
6932 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6933 (if (and (eq gnus-summary-goto-unread 'never)
6934 (not (gnus-summary-last-article-p article)))
6935 (gnus-summary-next-article)
6936 (gnus-summary-next-unread-article))
6937 (if (or (null gnus-current-article)
6938 (null gnus-article-current)
6939 (/= article (cdr gnus-article-current))
6940 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6941 ;; Selected subject is different from current article's.
6942 (gnus-summary-display-article article)
6943 (when article-window
6944 (gnus-eval-in-buffer-window gnus-article-buffer
6945 (setq endp (gnus-article-next-page lines)))
6948 (gnus-summary-beginning-of-article))
6950 (gnus-message 3 "End of message"))
6952 (if (and (eq gnus-summary-goto-unread 'never)
6953 (not (gnus-summary-last-article-p article)))
6954 (gnus-summary-next-article)
6955 (gnus-summary-next-unread-article))))))))
6956 (gnus-summary-recenter)
6957 (gnus-summary-position-point)))
6959 (defun gnus-summary-prev-page (&optional lines move)
6960 "Show previous page of selected article.
6961 Argument LINES specifies lines to be scrolled down.
6962 If MOVE, move to the previous unread article if point is at
6963 the beginning of the buffer."
6965 (let ((article (gnus-summary-article-number))
6966 (article-window (get-buffer-window gnus-article-buffer t))
6968 (gnus-configure-windows 'article)
6969 (if (or (null gnus-current-article)
6970 (null gnus-article-current)
6971 (/= article (cdr gnus-article-current))
6972 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6973 ;; Selected subject is different from current article's.
6974 (gnus-summary-display-article article)
6975 (gnus-summary-recenter)
6976 (when article-window
6977 (gnus-eval-in-buffer-window gnus-article-buffer
6978 (setq endp (gnus-article-prev-page lines)))
6979 (when (and move endp)
6981 (gnus-message 3 "Beginning of message"))
6983 (if (and (eq gnus-summary-goto-unread 'never)
6984 (not (gnus-summary-first-article-p article)))
6985 (gnus-summary-prev-article)
6986 (gnus-summary-prev-unread-article))))))))
6987 (gnus-summary-position-point))
6989 (defun gnus-summary-prev-page-or-article (&optional lines)
6990 "Show previous page of selected article.
6991 Argument LINES specifies lines to be scrolled down.
6992 If at the beginning of the article, go to the next article."
6994 (gnus-summary-prev-page lines t))
6996 (defun gnus-summary-scroll-up (lines)
6997 "Scroll up (or down) one line current article.
6998 Argument LINES specifies lines to be scrolled up (or down if negative)."
7000 (gnus-configure-windows 'article)
7001 (gnus-summary-show-thread)
7002 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7003 (gnus-eval-in-buffer-window gnus-article-buffer
7005 (when (gnus-article-next-page lines)
7006 (gnus-message 3 "End of message")))
7008 (gnus-article-prev-page (- lines))))))
7009 (gnus-summary-recenter)
7010 (gnus-summary-position-point))
7012 (defun gnus-summary-scroll-down (lines)
7013 "Scroll down (or up) one line current article.
7014 Argument LINES specifies lines to be scrolled down (or up if negative)."
7016 (gnus-summary-scroll-up (- lines)))
7018 (defun gnus-summary-next-same-subject ()
7019 "Select next article which has the same subject as current one."
7021 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7023 (defun gnus-summary-prev-same-subject ()
7024 "Select previous article which has the same subject as current one."
7026 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7028 (defun gnus-summary-next-unread-same-subject ()
7029 "Select next unread article which has the same subject as current one."
7031 (gnus-summary-next-article t (gnus-summary-article-subject)))
7033 (defun gnus-summary-prev-unread-same-subject ()
7034 "Select previous unread article which has the same subject as current one."
7036 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7038 (defun gnus-summary-first-unread-article ()
7039 "Select the first unread article.
7040 Return nil if there are no unread articles."
7043 (when (gnus-summary-first-subject t)
7044 (gnus-summary-show-thread)
7045 (gnus-summary-first-subject t)
7046 (gnus-summary-display-article (gnus-summary-article-number)))
7047 (gnus-summary-position-point)))
7049 (defun gnus-summary-first-unread-subject ()
7050 "Place the point on the subject line of the first unread article.
7051 Return nil if there are no unread articles."
7054 (when (gnus-summary-first-subject t)
7055 (gnus-summary-show-thread)
7056 (gnus-summary-first-subject t))
7057 (gnus-summary-position-point)))
7059 (defun gnus-summary-first-unseen-subject ()
7060 "Place the point on the subject line of the first unseen article.
7061 Return nil if there are no unseen articles."
7064 (when (gnus-summary-first-subject t t t)
7065 (gnus-summary-show-thread)
7066 (gnus-summary-first-subject t t t))
7067 (gnus-summary-position-point)))
7069 (defun gnus-summary-first-unseen-or-unread-subject ()
7070 "Place the point on the subject line of the first unseen article.
7071 Return nil if there are no unseen articles."
7074 (unless (when (gnus-summary-first-subject t t t)
7075 (gnus-summary-show-thread)
7076 (gnus-summary-first-subject t t t))
7077 (when (gnus-summary-first-subject t)
7078 (gnus-summary-show-thread)
7079 (gnus-summary-first-subject t)))
7080 (gnus-summary-position-point)))
7082 (defun gnus-summary-first-article ()
7083 "Select the first article.
7084 Return nil if there are no articles."
7087 (when (gnus-summary-first-subject)
7088 (gnus-summary-show-thread)
7089 (gnus-summary-first-subject)
7090 (gnus-summary-display-article (gnus-summary-article-number)))
7091 (gnus-summary-position-point)))
7093 (defun gnus-summary-best-unread-article (&optional arg)
7094 "Select the unread article with the highest score.
7095 If given a prefix argument, select the next unread article that has a
7096 score higher than the default score."
7098 (let ((article (if arg
7099 (gnus-summary-better-unread-subject)
7100 (gnus-summary-best-unread-subject))))
7102 (gnus-summary-goto-article article)
7103 (error "No unread articles"))))
7105 (defun gnus-summary-best-unread-subject ()
7106 "Select the unread subject with the highest score."
7108 (let ((best -1000000)
7109 (data gnus-newsgroup-data)
7112 (and (gnus-data-unread-p (car data))
7114 (gnus-summary-article-score (gnus-data-number (car data))))
7117 article (gnus-data-number (car data))))
7118 (setq data (cdr data)))
7120 (gnus-summary-goto-subject article))
7121 (gnus-summary-position-point)
7124 (defun gnus-summary-better-unread-subject ()
7125 "Select the first unread subject that has a score over the default score."
7127 (let ((data gnus-newsgroup-data)
7129 (while (and (setq article (gnus-data-number (car data)))
7130 (or (gnus-data-read-p (car data))
7131 (not (> (gnus-summary-article-score article)
7132 gnus-summary-default-score))))
7133 (setq data (cdr data)))
7135 (gnus-summary-goto-subject article))
7136 (gnus-summary-position-point)
7139 (defun gnus-summary-last-subject ()
7140 "Go to the last displayed subject line in the group."
7141 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7143 (gnus-summary-goto-subject article))))
7145 (defun gnus-summary-goto-article (article &optional all-headers force)
7146 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7147 If ALL-HEADERS is non-nil, no header lines are hidden.
7148 If FORCE, go to the article even if it isn't displayed. If FORCE
7149 is a number, it is the line the article is to be displayed on."
7153 "Article number or Message-ID: "
7154 (mapcar (lambda (number) (list (int-to-string number)))
7155 gnus-newsgroup-limit))
7159 (if (and (stringp article)
7160 (string-match "@" article))
7161 (gnus-summary-refer-article article)
7162 (when (stringp article)
7163 (setq article (string-to-number article)))
7164 (if (gnus-summary-goto-subject article force)
7165 (gnus-summary-display-article article all-headers)
7166 (gnus-message 4 "Couldn't go to article %s" article) nil))
7167 (gnus-summary-position-point)))
7169 (defun gnus-summary-goto-last-article ()
7170 "Go to the previously read article."
7173 (when gnus-last-article
7174 (gnus-summary-goto-article gnus-last-article nil t))
7175 (gnus-summary-position-point)))
7177 (defun gnus-summary-pop-article (number)
7178 "Pop one article off the history and go to the previous.
7179 NUMBER articles will be popped off."
7182 (setq gnus-newsgroup-history
7183 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7185 (gnus-summary-goto-article (car to) nil t)
7186 (error "Article history empty")))
7187 (gnus-summary-position-point))
7189 ;; Summary commands and functions for limiting the summary buffer.
7191 (defun gnus-summary-limit-to-articles (n)
7192 "Limit the summary buffer to the next N articles.
7193 If not given a prefix, use the process marked articles instead."
7196 (let ((articles (gnus-summary-work-articles n)))
7197 (setq gnus-newsgroup-processable nil)
7198 (gnus-summary-limit articles))
7199 (gnus-summary-position-point)))
7201 (defun gnus-summary-pop-limit (&optional total)
7202 "Restore the previous limit.
7203 If given a prefix, remove all limits."
7206 (setq gnus-newsgroup-limits
7207 (list (mapcar (lambda (h) (mail-header-number h))
7208 gnus-newsgroup-headers))))
7209 (unless gnus-newsgroup-limits
7210 (error "No limit to pop"))
7212 (gnus-summary-limit nil 'pop)
7213 (gnus-summary-position-point)))
7215 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7216 "Limit the summary buffer to articles that have subjects that match a regexp.
7217 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7219 (list (read-string (if current-prefix-arg
7220 "Exclude subject (regexp): "
7221 "Limit to subject (regexp): "))
7222 nil current-prefix-arg))
7224 (setq header "subject"))
7225 (when (not (equal "" subject))
7227 (let ((articles (gnus-summary-find-matching
7228 (or header "subject") subject 'all nil nil
7231 (error "Found no matches for \"%s\"" subject))
7232 (gnus-summary-limit articles))
7233 (gnus-summary-position-point))))
7235 (defun gnus-summary-limit-to-author (from &optional not-matching)
7236 "Limit the summary buffer to articles that have authors that match a regexp.
7237 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7239 (list (read-string (if current-prefix-arg
7240 "Exclude author (regexp): "
7241 "Limit to author (regexp): "))
7242 current-prefix-arg))
7243 (gnus-summary-limit-to-subject from "from" not-matching))
7245 (defun gnus-summary-limit-to-age (age &optional younger-p)
7246 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7247 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7248 articles that are younger than AGE days."
7250 (let ((younger current-prefix-arg)
7253 (while (not days-got)
7254 (setq days (if younger
7255 (read-string "Limit to articles within (in days): ")
7256 (read-string "Limit to articles older than (in days): ")))
7257 (when (> (length days) 0)
7258 (setq days (read days)))
7264 (setq younger (not younger))
7265 (setq days (* days -1)))))
7266 (message "Please enter a number.")
7268 (list days younger)))
7270 (let ((data gnus-newsgroup-data)
7271 (cutoff (days-to-time age))
7272 articles d date is-younger)
7273 (while (setq d (pop data))
7274 (when (and (vectorp (gnus-data-header d))
7275 (setq date (mail-header-date (gnus-data-header d))))
7276 (setq is-younger (time-less-p
7277 (time-since (condition-case ()
7284 (push (gnus-data-number d) articles))))
7285 (gnus-summary-limit (nreverse articles)))
7286 (gnus-summary-position-point)))
7288 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7289 "Limit the summary buffer to articles that match an 'extra' header."
7293 (gnus-completing-read-with-default
7294 (symbol-name (car gnus-extra-headers))
7295 (if current-prefix-arg
7296 "Exclude extra header:"
7297 "Limit extra header:")
7299 (cons (symbol-name x) x))
7304 (read-string (format "%s header %s (regexp): "
7305 (if current-prefix-arg "Exclude" "Limit to")
7307 current-prefix-arg)))
7308 (when (not (equal "" regexp))
7310 (let ((articles (gnus-summary-find-matching
7311 (cons 'extra header) regexp 'all nil nil
7314 (error "Found no matches for \"%s\"" regexp))
7315 (gnus-summary-limit articles))
7316 (gnus-summary-position-point))))
7318 (defun gnus-summary-limit-to-display-predicate ()
7319 "Limit the summary buffer to the predicated in the `display' group parameter."
7321 (unless gnus-newsgroup-display
7322 (error "There is no `display' group parameter"))
7324 (dolist (number gnus-newsgroup-articles)
7325 (when (funcall gnus-newsgroup-display)
7326 (push number articles)))
7327 (gnus-summary-limit articles))
7328 (gnus-summary-position-point))
7330 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7332 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7334 (defun gnus-summary-limit-to-unread (&optional all)
7335 "Limit the summary buffer to articles that are not marked as read.
7336 If ALL is non-nil, limit strictly to unread articles."
7339 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7340 (gnus-summary-limit-to-marks
7341 ;; Concat all the marks that say that an article is read and have
7343 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7344 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7345 gnus-low-score-mark gnus-expirable-mark
7346 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7347 gnus-duplicate-mark gnus-souped-mark)
7350 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7351 (make-obsolete 'gnus-summary-delete-marked-with
7352 'gnus-summary-limit-exclude-marks)
7354 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7355 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7356 If REVERSE, limit the summary buffer to articles that are marked
7357 with MARKS. MARKS can either be a string of marks or a list of marks.
7358 Returns how many articles were removed."
7359 (interactive "sMarks: ")
7360 (gnus-summary-limit-to-marks marks t))
7362 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7363 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7364 If REVERSE (the prefix), limit the summary buffer to articles that are
7365 not marked with MARKS. MARKS can either be a string of marks or a
7367 Returns how many articles were removed."
7368 (interactive "sMarks: \nP")
7370 (let ((data gnus-newsgroup-data)
7371 (marks (if (listp marks) marks
7372 (append marks nil))) ; Transform to list.
7375 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7376 (memq (gnus-data-mark (car data)) marks))
7377 (push (gnus-data-number (car data)) articles))
7378 (setq data (cdr data)))
7379 (gnus-summary-limit articles))
7380 (gnus-summary-position-point)))
7382 (defun gnus-summary-limit-to-score (score)
7383 "Limit to articles with score at or above SCORE."
7384 (interactive "NLimit to articles with score of at least: ")
7385 (let ((data gnus-newsgroup-data)
7388 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7390 (push (gnus-data-number (car data)) articles))
7391 (setq data (cdr data)))
7393 (gnus-summary-limit articles)
7394 (gnus-summary-position-point))))
7396 (defun gnus-summary-limit-include-thread (id)
7397 "Display all the hidden articles that is in the thread with ID in it.
7398 When called interactively, ID is the Message-ID of the current
7400 (interactive (list (mail-header-id (gnus-summary-article-header))))
7401 (let ((articles (gnus-articles-in-thread
7402 (gnus-id-to-thread (gnus-root-id id)))))
7404 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7405 (gnus-summary-limit-include-matching-articles
7407 (regexp-quote (gnus-simplify-subject-re
7408 (mail-header-subject (gnus-id-to-header id)))))
7409 (gnus-summary-position-point))))
7411 (defun gnus-summary-limit-include-matching-articles (header regexp)
7412 "Display all the hidden articles that have HEADERs that match REGEXP."
7413 (interactive (list (read-string "Match on header: ")
7414 (read-string "Regexp: ")))
7415 (let ((articles (gnus-find-matching-articles header regexp)))
7417 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7418 (gnus-summary-position-point))))
7420 (defun gnus-summary-limit-include-dormant ()
7421 "Display all the hidden articles that are marked as dormant.
7422 Note that this command only works on a subset of the articles currently
7423 fetched for this group."
7425 (unless gnus-newsgroup-dormant
7426 (error "There are no dormant articles in this group"))
7428 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7429 (gnus-summary-position-point)))
7431 (defun gnus-summary-limit-exclude-dormant ()
7432 "Hide all dormant articles."
7435 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7436 (gnus-summary-position-point)))
7438 (defun gnus-summary-limit-exclude-childless-dormant ()
7439 "Hide all dormant articles that have no children."
7441 (let ((data (gnus-data-list t))
7442 articles d children)
7443 ;; Find all articles that are either not dormant or have
7445 (while (setq d (pop data))
7446 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7448 (gnus-article-children (gnus-data-number d)))
7451 (when (memq (car children) articles)
7456 (push (gnus-data-number d) articles)))
7459 (gnus-summary-limit articles)
7460 (gnus-summary-position-point))))
7462 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7463 "Mark all unread excluded articles as read.
7464 If ALL, mark even excluded ticked and dormants as read."
7466 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7467 (let ((articles (gnus-sorted-ndifference
7469 (mapcar (lambda (h) (mail-header-number h))
7470 gnus-newsgroup-headers)
7472 gnus-newsgroup-limit))
7474 (setq gnus-newsgroup-unreads
7475 (gnus-sorted-intersection gnus-newsgroup-unreads
7476 gnus-newsgroup-limit))
7478 (setq gnus-newsgroup-dormant nil
7479 gnus-newsgroup-marked nil
7480 gnus-newsgroup-reads
7482 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7483 gnus-newsgroup-reads))
7484 (while (setq article (pop articles))
7485 (unless (or (memq article gnus-newsgroup-dormant)
7486 (memq article gnus-newsgroup-marked))
7487 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7489 (defun gnus-summary-limit (articles &optional pop)
7491 ;; We pop the previous limit off the stack and use that.
7492 (setq articles (car gnus-newsgroup-limits)
7493 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7494 ;; We use the new limit, so we push the old limit on the stack.
7495 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7497 (setq gnus-newsgroup-limit articles)
7498 (let ((total (length gnus-newsgroup-data))
7499 (data (gnus-data-find-list (gnus-summary-article-number)))
7500 (gnus-summary-mark-below nil) ; Inhibit this.
7502 ;; This will do all the work of generating the new summary buffer
7503 ;; according to the new limit.
7504 (gnus-summary-prepare)
7505 ;; Hide any threads, possibly.
7506 (gnus-summary-maybe-hide-threads)
7507 ;; Try to return to the article you were at, or one in the
7510 ;; We try to find some article after the current one.
7512 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7515 (setq data (cdr data))))
7517 ;; If there is no data, that means that we were after the last
7518 ;; article. The same goes when we can't find any articles
7519 ;; after the current one.
7520 (goto-char (point-max))
7521 (gnus-summary-find-prev))
7522 (gnus-set-mode-line 'summary)
7523 ;; We return how many articles were removed from the summary
7524 ;; buffer as a result of the new limit.
7525 (- total (length gnus-newsgroup-data))))
7527 (defsubst gnus-invisible-cut-children (threads)
7530 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7535 (defsubst gnus-cut-thread (thread)
7536 "Go forwards in the thread until we find an article that we want to display."
7537 (when (or (eq gnus-fetch-old-headers 'some)
7538 (eq gnus-fetch-old-headers 'invisible)
7539 (numberp gnus-fetch-old-headers)
7540 (eq gnus-build-sparse-threads 'some)
7541 (eq gnus-build-sparse-threads 'more))
7542 ;; Deal with old-fetched headers and sparse threads.
7546 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7547 (gnus-summary-article-ancient-p
7548 (mail-header-number (car thread))))
7549 (if (or (<= (length (cdr thread)) 1)
7550 (eq gnus-fetch-old-headers 'invisible))
7551 (setq gnus-newsgroup-limit
7552 (delq (mail-header-number (car thread))
7553 gnus-newsgroup-limit)
7554 thread (cadr thread))
7555 (when (gnus-invisible-cut-children (cdr thread))
7556 (let ((th (cdr thread)))
7558 (if (memq (mail-header-number (caar th))
7559 gnus-newsgroup-limit)
7560 (setq thread (car th)
7562 (setq th (cdr th))))))))))
7565 (defun gnus-cut-threads (threads)
7566 "Cut off all uninteresting articles from the beginning of threads."
7567 (when (or (eq gnus-fetch-old-headers 'some)
7568 (eq gnus-fetch-old-headers 'invisible)
7569 (numberp gnus-fetch-old-headers)
7570 (eq gnus-build-sparse-threads 'some)
7571 (eq gnus-build-sparse-threads 'more))
7574 (setcar th (gnus-cut-thread (car th)))
7575 (setq th (cdr th)))))
7576 ;; Remove nixed out threads.
7579 (defun gnus-summary-initial-limit (&optional show-if-empty)
7580 "Figure out what the initial limit is supposed to be on group entry.
7581 This entails weeding out unwanted dormants, low-scored articles,
7582 fetch-old-headers verbiage, and so on."
7583 ;; Most groups have nothing to remove.
7584 (if (or gnus-inhibit-limiting
7585 (and (null gnus-newsgroup-dormant)
7586 (eq gnus-newsgroup-display 'gnus-not-ignore)
7587 (not (eq gnus-fetch-old-headers 'some))
7588 (not (numberp gnus-fetch-old-headers))
7589 (not (eq gnus-fetch-old-headers 'invisible))
7590 (null gnus-summary-expunge-below)
7591 (not (eq gnus-build-sparse-threads 'some))
7592 (not (eq gnus-build-sparse-threads 'more))
7593 (null gnus-thread-expunge-below)
7594 (not gnus-use-nocem)))
7596 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7597 (setq gnus-newsgroup-limit nil)
7600 (unless (car (symbol-value node))
7601 ;; These threads have no parents -- they are roots.
7602 (let ((nodes (cdr (symbol-value node)))
7605 (if (and gnus-thread-expunge-below
7606 (< (gnus-thread-total-score (car nodes))
7607 gnus-thread-expunge-below))
7608 (gnus-expunge-thread (pop nodes))
7609 (setq thread (pop nodes))
7610 (gnus-summary-limit-children thread))))))
7611 gnus-newsgroup-dependencies)
7612 ;; If this limitation resulted in an empty group, we might
7613 ;; pop the previous limit and use it instead.
7614 (when (and (not gnus-newsgroup-limit)
7616 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7617 gnus-newsgroup-limit))
7619 (defun gnus-summary-limit-children (thread)
7620 "Return 1 if this subthread is visible and 0 if it is not."
7621 ;; First we get the number of visible children to this thread. This
7622 ;; is done by recursing down the thread using this function, so this
7623 ;; will really go down to a leaf article first, before slowly
7624 ;; working its way up towards the root.
7628 (apply '+ (mapcar 'gnus-summary-limit-children
7631 (number (mail-header-number (car thread)))
7634 (not (memq number gnus-newsgroup-marked))
7636 ;; If this article is dormant and has absolutely no visible
7637 ;; children, then this article isn't visible.
7638 (and (memq number gnus-newsgroup-dormant)
7640 ;; If this is "fetch-old-headered" and there is no
7641 ;; visible children, then we don't want this article.
7642 (and (or (eq gnus-fetch-old-headers 'some)
7643 (numberp gnus-fetch-old-headers))
7644 (gnus-summary-article-ancient-p number)
7646 ;; If this is "fetch-old-headered" and `invisible', then
7647 ;; we don't want this article.
7648 (and (eq gnus-fetch-old-headers 'invisible)
7649 (gnus-summary-article-ancient-p number))
7650 ;; If this is a sparsely inserted article with no children,
7651 ;; we don't want it.
7652 (and (eq gnus-build-sparse-threads 'some)
7653 (gnus-summary-article-sparse-p number)
7655 ;; If we use expunging, and this article is really
7656 ;; low-scored, then we don't want this article.
7657 (when (and gnus-summary-expunge-below
7659 (or (cdr (assq number gnus-newsgroup-scored))
7660 gnus-summary-default-score))
7661 gnus-summary-expunge-below))
7662 ;; We increase the expunge-tally here, but that has
7663 ;; nothing to do with the limits, really.
7664 (incf gnus-newsgroup-expunged-tally)
7665 ;; We also mark as read here, if that's wanted.
7666 (when (and gnus-summary-mark-below
7667 (< score gnus-summary-mark-below))
7668 (setq gnus-newsgroup-unreads
7669 (delq number gnus-newsgroup-unreads))
7670 (if gnus-newsgroup-auto-expire
7671 (push number gnus-newsgroup-expirable)
7672 (push (cons number gnus-low-score-mark)
7673 gnus-newsgroup-reads)))
7675 ;; Do the `display' group parameter.
7676 (and gnus-newsgroup-display
7677 (not (funcall gnus-newsgroup-display)))
7678 ;; Check NoCeM things.
7679 (if (and gnus-use-nocem
7680 (gnus-nocem-unwanted-article-p
7681 (mail-header-id (car thread))))
7683 (setq gnus-newsgroup-unreads
7684 (delq number gnus-newsgroup-unreads))
7686 ;; Nope, invisible article.
7688 ;; Ok, this article is to be visible, so we add it to the limit
7690 (push number gnus-newsgroup-limit)
7693 (defun gnus-expunge-thread (thread)
7694 "Mark all articles in THREAD as read."
7695 (let* ((number (mail-header-number (car thread))))
7696 (incf gnus-newsgroup-expunged-tally)
7697 ;; We also mark as read here, if that's wanted.
7698 (setq gnus-newsgroup-unreads
7699 (delq number gnus-newsgroup-unreads))
7700 (if gnus-newsgroup-auto-expire
7701 (push number gnus-newsgroup-expirable)
7702 (push (cons number gnus-low-score-mark)
7703 gnus-newsgroup-reads)))
7704 ;; Go recursively through all subthreads.
7705 (mapcar 'gnus-expunge-thread (cdr thread)))
7707 ;; Summary article oriented commands
7709 (defun gnus-summary-refer-parent-article (n)
7710 "Refer parent article N times.
7711 If N is negative, go to ancestor -N instead.
7712 The difference between N and the number of articles fetched is returned."
7716 (when (not (natnump n))
7721 (setq header (gnus-summary-article-header))
7722 (if (and (eq (mail-header-number header)
7723 (cdr gnus-article-current))
7724 (equal gnus-newsgroup-name
7725 (car gnus-article-current)))
7726 ;; If we try to find the parent of the currently
7727 ;; displayed article, then we take a look at the actual
7728 ;; References header, since this is slightly more
7729 ;; reliable than the References field we got from the
7732 (set-buffer gnus-original-article-buffer)
7733 (nnheader-narrow-to-headers)
7734 (unless (setq ref (message-fetch-field "references"))
7735 (setq ref (message-fetch-field "in-reply-to")))
7738 ;; It's not the current article, so we take a bet on
7739 ;; the value we got from the server.
7740 (mail-header-references header)))
7742 (not (equal ref "")))
7743 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7744 (gnus-message 1 "Couldn't find parent"))
7745 (gnus-message 1 "No references in article %d"
7746 (gnus-summary-article-number))
7749 (gnus-summary-position-point)
7752 (defun gnus-summary-refer-references ()
7753 "Fetch all articles mentioned in the References header.
7754 Return the number of articles fetched."
7756 (let ((ref (mail-header-references (gnus-summary-article-header)))
7757 (current (gnus-summary-article-number))
7761 (error "No References in the current article")
7762 ;; For each Message-ID in the References header...
7763 (while (string-match "<[^>]*>" ref)
7765 ;; ... fetch that article.
7766 (gnus-summary-refer-article
7767 (prog1 (match-string 0 ref)
7768 (setq ref (substring ref (match-end 0))))))
7769 (gnus-summary-goto-subject current)
7770 (gnus-summary-position-point)
7773 (defun gnus-summary-refer-thread (&optional limit)
7774 "Fetch all articles in the current thread.
7775 If LIMIT (the numerical prefix), fetch that many old headers instead
7776 of what's specified by the `gnus-refer-thread-limit' variable."
7778 (let ((id (mail-header-id (gnus-summary-article-header)))
7779 (limit (if limit (prefix-numeric-value limit)
7780 gnus-refer-thread-limit)))
7781 ;; We want to fetch LIMIT *old* headers, but we also have to
7782 ;; re-fetch all the headers in the current buffer, because many of
7783 ;; them may be undisplayed. So we adjust LIMIT.
7784 (when (numberp limit)
7785 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7786 (unless (eq gnus-fetch-old-headers 'invisible)
7787 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7788 ;; Retrieve the headers and read them in.
7789 (if (eq (gnus-retrieve-headers
7790 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7792 (gnus-build-all-threads)
7793 (error "Can't fetch thread from backends that don't support NOV"))
7794 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7795 (gnus-summary-limit-include-thread id)))
7797 (defun gnus-summary-refer-article (message-id)
7798 "Fetch an article specified by MESSAGE-ID."
7799 (interactive "sMessage-ID: ")
7800 (when (and (stringp message-id)
7801 (not (zerop (length message-id))))
7802 ;; Construct the correct Message-ID if necessary.
7803 ;; Suggested by tale@pawl.rpi.edu.
7804 (unless (string-match "^<" message-id)
7805 (setq message-id (concat "<" message-id)))
7806 (unless (string-match ">$" message-id)
7807 (setq message-id (concat message-id ">")))
7808 (let* ((header (gnus-id-to-header message-id))
7810 (gnus-summary-article-sparse-p
7811 (mail-header-number header))
7812 (memq (mail-header-number header)
7813 gnus-newsgroup-limit)))
7816 ;; If the article is present in the buffer we just go to it.
7818 (or (not (gnus-summary-article-sparse-p
7819 (mail-header-number header)))
7822 (gnus-summary-goto-article
7823 (mail-header-number header) nil t)
7825 (gnus-summary-update-article (mail-header-number header)))))
7827 ;; We fetch the article.
7829 (dolist (gnus-override-method (gnus-refer-article-methods))
7830 (gnus-check-server gnus-override-method)
7831 ;; Fetch the header, and display the article.
7832 (when (setq number (gnus-summary-insert-subject message-id))
7833 (gnus-summary-select-article nil nil nil number)
7835 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7837 (defun gnus-refer-article-methods ()
7838 "Return a list of referrable methods."
7840 ;; No method, so we default to current and native.
7841 ((null gnus-refer-article-method)
7842 (list gnus-current-select-method gnus-select-method))
7844 ((eq 'current gnus-refer-article-method)
7845 (list gnus-current-select-method))
7846 ;; List of select methods.
7847 ((not (and (symbolp (car gnus-refer-article-method))
7848 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7850 (dolist (method gnus-refer-article-method)
7851 (push (if (eq 'current method)
7852 gnus-current-select-method
7856 ;; One single select method.
7858 (list gnus-refer-article-method))))
7860 (defun gnus-summary-edit-parameters ()
7861 "Edit the group parameters of the current group."
7863 (gnus-group-edit-group gnus-newsgroup-name 'params))
7865 (defun gnus-summary-customize-parameters ()
7866 "Customize the group parameters of the current group."
7868 (gnus-group-customize gnus-newsgroup-name))
7870 (defun gnus-summary-enter-digest-group (&optional force)
7871 "Enter an nndoc group based on the current article.
7872 If FORCE, force a digest interpretation. If not, try
7873 to guess what the document format is."
7875 (let ((conf gnus-current-window-configuration))
7877 (gnus-summary-select-article))
7878 (setq gnus-current-window-configuration conf)
7879 (let* ((name (format "%s-%d"
7880 (gnus-group-prefixed-name
7881 gnus-newsgroup-name (list 'nndoc ""))
7883 (set-buffer gnus-summary-buffer)
7884 gnus-current-article)))
7885 (ogroup gnus-newsgroup-name)
7886 (params (append (gnus-info-params (gnus-get-info ogroup))
7887 (list (cons 'to-group ogroup))
7888 (list (cons 'save-article-group ogroup))))
7889 (case-fold-search t)
7890 (buf (current-buffer))
7893 (set-buffer gnus-original-article-buffer)
7894 ;; Have the digest group inherit the main mail address of
7895 ;; the parent article.
7896 (when (setq to-address (or (gnus-fetch-field "reply-to")
7897 (gnus-fetch-field "from")))
7898 (setq params (append
7899 (list (cons 'to-address
7900 (funcall gnus-decode-encoded-word-function
7902 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7903 (insert-buffer-substring gnus-original-article-buffer)
7904 ;; Remove lines that may lead nndoc to misinterpret the
7907 (goto-char (point-min))
7908 (or (search-forward "\n\n" nil t) (point)))
7909 (goto-char (point-min))
7910 (delete-matching-lines "^Path:\\|^From ")
7913 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7914 (gnus-newsgroup-ephemeral-ignored-charsets
7915 gnus-newsgroup-ignored-charsets))
7916 (gnus-group-read-ephemeral-group
7917 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7919 ,(if force 'mbox 'guess)))
7921 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7923 ;; Make all postings to this group go to the parent group.
7924 (nconc (gnus-info-params (gnus-get-info name))
7926 ;; Couldn't select this doc group.
7927 (switch-to-buffer buf)
7928 (gnus-set-global-variables)
7929 (gnus-configure-windows 'summary)
7930 (gnus-message 3 "Article couldn't be entered?"))
7931 (kill-buffer dig)))))
7933 (defun gnus-summary-read-document (n)
7934 "Open a new group based on the current article(s).
7935 This will allow you to read digests and other similar
7936 documents as newsgroups.
7937 Obeys the standard process/prefix convention."
7939 (let* ((articles (gnus-summary-work-articles n))
7940 (ogroup gnus-newsgroup-name)
7941 (params (append (gnus-info-params (gnus-get-info ogroup))
7942 (list (cons 'to-group ogroup))))
7943 article group egroup groups vgroup)
7944 (while (setq article (pop articles))
7945 (setq group (format "%s-%d" gnus-newsgroup-name article))
7946 (gnus-summary-remove-process-mark article)
7947 (when (gnus-summary-display-article article)
7950 (insert-buffer-substring gnus-original-article-buffer)
7951 ;; Remove some headers that may lead nndoc to make
7953 (message-narrow-to-head)
7954 (goto-char (point-min))
7955 (delete-matching-lines "^\\(Path\\):\\|^From ")
7958 (gnus-group-read-ephemeral-group
7959 group `(nndoc ,group (nndoc-address ,(current-buffer))
7960 (nndoc-article-type guess))
7963 ;; Make all postings to this group go to the parent group.
7964 (nconc (gnus-info-params (gnus-get-info egroup))
7966 (push egroup groups))
7967 ;; Couldn't select this doc group.
7968 (gnus-error 3 "Article couldn't be entered"))))))
7969 ;; Now we have selected all the documents.
7972 (error "None of the articles could be interpreted as documents"))
7973 ((gnus-group-read-ephemeral-group
7974 (setq vgroup (format
7975 "nnvirtual:%s-%s" gnus-newsgroup-name
7976 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
7977 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
7979 (cons (current-buffer) 'summary)))
7981 (error "Couldn't select virtual nndoc group")))))
7983 (defun gnus-summary-isearch-article (&optional regexp-p)
7984 "Do incremental search forward on the current article.
7985 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
7987 (let* ((gnus-inhibit-treatment t)
7988 (old (gnus-summary-select-article)))
7989 (gnus-configure-windows 'article)
7990 (gnus-eval-in-buffer-window gnus-article-buffer
7994 (gnus-article-show-all-headers))
7995 (goto-char (point-min))
7996 (isearch-forward regexp-p)))))
7998 (defun gnus-summary-search-article-forward (regexp &optional backward)
7999 "Search for an article containing REGEXP forward.
8000 If BACKWARD, search backward instead."
8003 (format "Search article %s (regexp%s): "
8004 (if current-prefix-arg "backward" "forward")
8005 (if gnus-last-search-regexp
8006 (concat ", default " gnus-last-search-regexp)
8008 current-prefix-arg))
8009 (if (string-equal regexp "")
8010 (setq regexp (or gnus-last-search-regexp ""))
8011 (setq gnus-last-search-regexp regexp)
8012 (setq gnus-article-before-search gnus-current-article))
8013 ;; Intentionally set gnus-last-article.
8014 (setq gnus-last-article gnus-article-before-search)
8015 (let ((gnus-last-article gnus-last-article))
8016 (if (gnus-summary-search-article regexp backward)
8017 (gnus-summary-show-thread)
8018 (error "Search failed: \"%s\"" regexp))))
8020 (defun gnus-summary-search-article-backward (regexp)
8021 "Search for an article containing REGEXP backward."
8024 (format "Search article backward (regexp%s): "
8025 (if gnus-last-search-regexp
8026 (concat ", default " gnus-last-search-regexp)
8028 (gnus-summary-search-article-forward regexp 'backward))
8031 (defmacro gnus-summary-search-article-position-point (regexp backward)
8032 "Dehighlight the last matched text and goto the beginning position."
8033 (` (if (and gnus-summary-search-article-matched-data
8034 (let ((text (caddr gnus-summary-search-article-matched-data))
8035 (inhibit-read-only t)
8038 (goto-char (car gnus-summary-search-article-matched-data))
8039 (cadr gnus-summary-search-article-matched-data))
8041 (string-match (, regexp) text)))
8042 (if (, backward) (beginning-of-line) (end-of-line))
8043 (goto-char (if (, backward) (point-max) (point-min))))))
8045 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8046 "Place point where X-Face image is displayed."
8047 (if (featurep 'xemacs)
8048 (` (let ((end (if (search-forward "\n\n" nil t)
8049 (goto-char (1- (point)))
8052 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8053 (unless (and (re-search-forward "^From:" end t)
8054 (setq extent (extent-at (point)))
8055 (extent-begin-glyph extent))
8056 (goto-char (, opoint)))))
8057 (` (let ((end (if (search-forward "\n\n" nil t)
8058 (goto-char (1- (point)))
8060 (start (or (search-backward "\n\n" nil t) (point-min))))
8062 (or (text-property-any start end 'x-face-image t);; x-face-e21
8063 (text-property-any start end 'x-face-mule-bitmap-image t)
8066 (defmacro gnus-summary-search-article-highlight-matched-text
8067 (backward treated x-face)
8068 "Highlight matched text in the function `gnus-summary-search-article'."
8069 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8070 (end (set-marker (make-marker) (match-end 0)))
8071 (inhibit-read-only t)
8075 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8077 (lambda (item) (setq items (delq item items)))
8078 '(gnus-treat-buttonize
8079 gnus-treat-fill-article
8080 gnus-treat-fill-long-lines
8081 gnus-treat-emphasize
8082 gnus-treat-highlight-headers
8083 gnus-treat-highlight-citation
8084 gnus-treat-highlight-signature
8085 gnus-treat-overstrike
8086 gnus-treat-display-xface
8087 gnus-treat-buttonize-head
8088 gnus-treat-decode-article-as-default-mime-charset))
8089 (static-if (featurep 'xemacs)
8091 (cons '(x-face-mule-delete-x-face-field
8094 (gnus-treat-display-xface
8095 (when (, x-face) gnus-treat-display-xface)))
8096 (gnus-article-prepare-mime-display)))
8097 (goto-char (if (, backward) start end))
8099 (gnus-summary-search-article-highlight-goto-x-face (point)))
8100 (setq gnus-summary-search-article-matched-data
8101 (list start end (buffer-substring start end)))
8102 (unless (eq start end);; matched text has been deleted. :-<
8103 (put-text-property start end 'face
8104 (or (find-face 'isearch)
8105 'secondary-selection))))))
8108 (defun gnus-summary-search-article (regexp &optional backward)
8109 "Search for an article containing REGEXP.
8110 Optional argument BACKWARD means do search for backward.
8111 `gnus-select-article-hook' is not called during the search."
8112 ;; We have to require this here to make sure that the following
8113 ;; dynamic binding isn't shadowed by autoloading.
8114 (require 'gnus-async)
8116 (let ((gnus-select-article-hook nil) ;Disable hook.
8117 (gnus-article-prepare-hook nil)
8118 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8119 (gnus-use-article-prefetch nil)
8120 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8121 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8122 (sum (current-buffer))
8125 (gnus-save-hidden-threads
8126 (static-if (featurep 'xemacs)
8127 (let ((gnus-inhibit-treatment t))
8128 (setq treated (eq 'old (gnus-summary-select-article)))
8130 (not (and (gnus-buffer-live-p gnus-article-buffer)
8131 (window-live-p (get-buffer-window
8132 gnus-article-buffer t)))))
8133 (gnus-summary-select-article nil t)
8134 (setq treated nil)))
8135 (let ((gnus-inhibit-treatment t)
8136 (x-face-mule-delete-x-face-field 'never))
8137 (setq treated (eq 'old (gnus-summary-select-article)))
8140 (and (gnus-buffer-live-p gnus-article-buffer)
8141 (window-live-p (get-buffer-window
8142 gnus-article-buffer t))
8143 (or (not (string-match "^\\^X-Face:" regexp))
8144 (with-current-buffer gnus-article-buffer
8145 gnus-summary-search-article-matched-data)))))
8146 (gnus-summary-select-article nil t)
8147 (setq treated nil))))
8148 (set-buffer gnus-article-buffer)
8152 (gnus-article-show-all-headers)
8153 (gnus-summary-search-article-position-point regexp backward))
8154 (goto-char (if backward (point-max) (point-min))))
8156 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8158 (re-search-backward regexp nil t)
8159 (re-search-forward regexp nil t))
8160 ;; We found the regexp.
8162 (gnus-summary-search-article-highlight-matched-text
8163 backward treated (string-match "^\\^X-Face:" regexp))
8166 (/ (- 2 (window-height
8167 (get-buffer-window gnus-article-buffer t)))
8170 (get-buffer-window (current-buffer))
8173 (setq point (point)))
8174 ;; We didn't find it, so we go to the next article.
8177 (while (eq found 'not)
8178 (if (not (if backward (gnus-summary-find-prev)
8179 (gnus-summary-find-next)))
8180 ;; No more articles.
8182 ;; Select the next article and adjust point.
8183 (unless (gnus-summary-article-sparse-p
8184 (gnus-summary-article-number))
8186 (let ((gnus-inhibit-treatment t))
8187 (gnus-summary-select-article))
8189 (set-buffer gnus-article-buffer)
8191 (goto-char (if backward (point-max) (point-min))))))))
8192 (gnus-message 7 ""))
8193 ;; Return whether we found the regexp.
8194 (when (eq found 'found)
8196 (gnus-summary-show-thread)
8197 (gnus-summary-goto-subject gnus-current-article)
8198 (gnus-summary-position-point)
8201 (defun gnus-find-matching-articles (header regexp)
8202 "Return a list of all articles that match REGEXP on HEADER.
8203 This search includes all articles in the current group that Gnus has
8204 fetched headers for, whether they are displayed or not."
8205 (let ((articles nil)
8206 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8207 (case-fold-search t))
8208 (dolist (header gnus-newsgroup-headers)
8209 (when (string-match regexp (funcall func header))
8210 (push (mail-header-number header) articles)))
8211 (nreverse articles)))
8213 (defun gnus-summary-find-matching (header regexp &optional backward unread
8214 not-case-fold not-matching)
8215 "Return a list of all articles that match REGEXP on HEADER.
8216 The search stars on the current article and goes forwards unless
8217 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8218 If UNREAD is non-nil, only unread articles will
8219 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8220 in the comparisons. If NOT-MATCHING, return a list of all articles that
8221 not match REGEXP on HEADER."
8222 (let ((case-fold-search (not not-case-fold))
8225 (if (eq (car header) 'extra)
8228 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8230 (error "%s is an invalid header" header))
8231 (unless (fboundp (intern (concat "mail-header-" header)))
8232 (error "%s is not a valid header" header))
8233 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8234 (dolist (d (if (eq backward 'all)
8236 (gnus-data-find-list
8237 (gnus-summary-article-number)
8238 (gnus-data-list backward))))
8239 (when (and (or (not unread) ; We want all articles...
8240 (gnus-data-unread-p d)) ; Or just unreads.
8241 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8245 (funcall func (gnus-data-header d))))
8246 (string-match regexp
8247 (funcall func (gnus-data-header d)))))
8248 (push (gnus-data-number d) articles))) ; Success!
8249 (nreverse articles)))
8251 (defun gnus-summary-execute-command (header regexp command &optional backward)
8252 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8253 If HEADER is an empty string (or nil), the match is done on the entire
8254 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8256 (list (let ((completion-ignore-case t))
8259 (mapcar (lambda (header) (list (format "%s" header)))
8261 '("Number" "Subject" "From" "Lines" "Date"
8262 "Message-ID" "Xref" "References" "Body")
8263 gnus-extra-headers))
8264 nil 'require-match))
8265 (read-string "Regexp: ")
8266 (read-key-sequence "Command: ")
8267 current-prefix-arg))
8268 (when (equal header "Body")
8270 ;; Hidden thread subtrees must be searched as well.
8271 (gnus-summary-show-all-threads)
8272 ;; We don't want to change current point nor window configuration.
8274 (save-window-excursion
8275 (gnus-message 6 "Executing %s..." (key-description command))
8276 ;; We'd like to execute COMMAND interactively so as to give arguments.
8277 (gnus-execute header regexp
8278 `(call-interactively ',(key-binding command))
8280 (gnus-message 6 "Executing %s...done" (key-description command)))))
8282 (defun gnus-summary-beginning-of-article ()
8283 "Scroll the article back to the beginning."
8285 (gnus-summary-select-article)
8286 (gnus-configure-windows 'article)
8287 (gnus-eval-in-buffer-window gnus-article-buffer
8289 (goto-char (point-min))
8290 (when gnus-page-broken
8291 (gnus-narrow-to-page))))
8293 (defun gnus-summary-end-of-article ()
8294 "Scroll to the end of the article."
8296 (gnus-summary-select-article)
8297 (gnus-configure-windows 'article)
8298 (gnus-eval-in-buffer-window gnus-article-buffer
8300 (goto-char (point-max))
8302 (when gnus-page-broken
8303 (gnus-narrow-to-page))))
8305 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8306 "Truncate to LEN and quote all \"(\"'s in STRING."
8307 (gnus-replace-in-string (if (and len (> (length string) len))
8308 (substring string 0 len)
8312 (defun gnus-summary-print-article (&optional filename n)
8313 "Generate and print a PostScript image of the N next (mail) articles.
8315 If N is negative, print the N previous articles. If N is nil and articles
8316 have been marked with the process mark, print these instead.
8318 If the optional first argument FILENAME is nil, send the image to the
8319 printer. If FILENAME is a string, save the PostScript image in a file with
8320 that name. If FILENAME is a number, prompt the user for the name of the file
8322 (interactive (list (ps-print-preprint current-prefix-arg)))
8323 (dolist (article (gnus-summary-work-articles n))
8324 (gnus-summary-select-article nil nil 'pseudo article)
8325 (gnus-eval-in-buffer-window gnus-article-buffer
8326 (gnus-print-buffer))
8327 (gnus-summary-remove-process-mark article))
8328 (ps-despool filename))
8330 (defun gnus-print-buffer ()
8331 (let ((buffer (generate-new-buffer " *print*")))
8334 (copy-to-buffer buffer (point-min) (point-max))
8336 (gnus-article-delete-invisible-text)
8337 (gnus-remove-text-with-property 'gnus-decoration)
8338 (when (gnus-visual-p 'article-highlight 'highlight)
8339 ;; Copy-to-buffer doesn't copy overlay. So redo
8341 (let ((gnus-article-buffer buffer))
8342 (gnus-article-highlight-citation t)
8343 (gnus-article-highlight-signature)))
8344 (let ((ps-left-header
8347 (gnus-summary-print-truncate-and-quote
8348 (mail-header-subject gnus-current-headers)
8351 (gnus-summary-print-truncate-and-quote
8352 (mail-header-from gnus-current-headers)
8356 "/pagenumberstring load"
8358 (mail-header-date gnus-current-headers) ")"))))
8359 (gnus-run-hooks 'gnus-ps-print-hook)
8362 (ps-spool-buffer-with-faces)
8363 (ps-spool-buffer)))))
8364 (kill-buffer buffer))))
8366 (defun gnus-summary-show-article (&optional arg)
8367 "Force redisplaying of the current article.
8368 If ARG (the prefix) is a number, show the article with the charset
8369 defined in `gnus-summary-show-article-charset-alist', or the charset
8371 If ARG (the prefix) is non-nil and not a number, show the raw article
8372 without any article massaging functions being run. Normally, the key strokes
8377 (gnus-summary-show-article t)
8378 (let* ((gnus-newsgroup-charset
8379 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8380 (mm-read-coding-system
8381 "View as charset: " ;; actually it is coding system.
8383 (set-buffer gnus-article-buffer)
8384 (mm-detect-coding-region (point) (point-max))))))
8385 (default-mime-charset gnus-newsgroup-charset)
8386 (gnus-newsgroup-ignored-charsets 'gnus-all))
8387 (gnus-summary-select-article nil 'force)
8388 (let ((deps gnus-newsgroup-dependencies)
8391 (set-buffer gnus-original-article-buffer)
8393 (message-narrow-to-head)
8394 (setq head (buffer-string))
8395 (goto-char (point-min))
8396 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8397 (goto-char (point-max))
8399 (setq lines (1- (count-lines (point) (point-max))))))
8401 (insert (format "211 %d Article retrieved.\n"
8402 (cdr gnus-article-current)))
8404 (if lines (insert (format "Lines: %d\n" lines)))
8406 (let ((nntp-server-buffer (current-buffer)))
8407 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8408 (gnus-data-set-header
8409 (gnus-data-find (cdr gnus-article-current))
8411 (gnus-summary-update-article-line
8412 (cdr gnus-article-current) header)
8413 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8414 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8416 ;; Select the article the normal way.
8417 (gnus-summary-select-article nil 'force))
8419 ;; We have to require this here to make sure that the following
8420 ;; dynamic binding isn't shadowed by autoloading.
8421 (require 'gnus-async)
8423 ;; Bind the article treatment functions to nil.
8424 (let ((gnus-have-all-headers t)
8425 gnus-article-prepare-hook
8426 gnus-article-decode-hook
8429 (gnus-inhibit-treatment t))
8430 (gnus-summary-select-article nil 'force))))
8431 (gnus-summary-goto-subject gnus-current-article)
8432 (gnus-summary-position-point))
8434 (defun gnus-summary-show-raw-article ()
8435 "Show the raw article without any article massaging functions being run."
8437 (gnus-summary-show-article t))
8439 (defun gnus-summary-verbose-headers (&optional arg)
8440 "Toggle permanent full header display.
8441 If ARG is a positive number, turn header display on.
8442 If ARG is a negative number, turn header display off."
8444 (setq gnus-show-all-headers
8445 (cond ((or (not (numberp arg))
8447 (not gnus-show-all-headers))
8450 (gnus-summary-show-article))
8452 (defun gnus-summary-toggle-header (&optional arg)
8453 "Show the headers if they are hidden, or hide them if they are shown.
8454 If ARG is a positive number, show the entire header.
8455 If ARG is a negative number, hide the unwanted header lines."
8457 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8458 (get-buffer-window gnus-article-buffer t))))
8460 (with-current-buffer gnus-article-buffer
8462 (article-narrow-to-head)
8463 (let* ((buffer-read-only nil)
8464 (inhibit-point-motion-hooks t)
8465 (hidden (if (numberp arg)
8467 (gnus-article-hidden-text-p 'headers)))
8469 (delete-region (point-min) (point-max))
8470 (with-current-buffer gnus-original-article-buffer
8471 (goto-char (setq s (point-min)))
8472 (setq e (if (search-forward "\n\n" nil t)
8475 (insert-buffer-substring gnus-original-article-buffer s e)
8476 (article-decode-encoded-words)
8478 (let ((gnus-treat-hide-headers nil)
8479 (gnus-treat-hide-boring-headers nil))
8480 (gnus-delete-wash-type 'headers)
8481 (gnus-treat-article 'head))
8482 (gnus-treat-article 'head))
8484 (set-window-start window (goto-char (point-min)))
8485 (setq gnus-page-broken
8486 (when gnus-break-pages
8487 (gnus-narrow-to-page)
8489 (gnus-set-mode-line 'article))))))
8491 (defun gnus-summary-show-all-headers ()
8492 "Make all header lines visible."
8494 (gnus-summary-toggle-header 1))
8496 (defun gnus-summary-toggle-mime (&optional arg)
8497 "Toggle MIME processing.
8498 If ARG is a positive number, turn MIME processing on."
8500 (setq gnus-show-mime
8502 (not gnus-show-mime)
8503 (> (prefix-numeric-value arg) 0)))
8504 (gnus-summary-select-article t 'force))
8506 (defun gnus-summary-caesar-message (&optional arg)
8507 "Caesar rotate the current article by 13.
8508 The numerical prefix specifies how many places to rotate each letter
8511 (gnus-summary-select-article)
8512 (let ((mail-header-separator ""))
8513 (gnus-eval-in-buffer-window gnus-article-buffer
8516 (let ((start (window-start))
8518 (message-caesar-buffer-body arg)
8519 (set-window-start (get-buffer-window (current-buffer)) start))))))
8521 (defun gnus-summary-stop-page-breaking ()
8522 "Stop page breaking in the current article."
8524 (gnus-summary-select-article)
8525 (gnus-eval-in-buffer-window gnus-article-buffer
8527 (when (gnus-visual-p 'page-marker)
8528 (let ((buffer-read-only nil))
8529 (gnus-remove-text-with-property 'gnus-prev)
8530 (gnus-remove-text-with-property 'gnus-next))
8531 (setq gnus-page-broken nil))))
8533 (defun gnus-summary-move-article (&optional n to-newsgroup
8534 select-method action)
8535 "Move the current article to a different newsgroup.
8536 If N is a positive number, move the N next articles.
8537 If N is a negative number, move the N previous articles.
8538 If N is nil and any articles have been marked with the process mark,
8539 move those articles instead.
8540 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8541 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8542 re-spool using this method.
8544 When called interactively with TO-NEWSGROUP being nil, the value of
8545 the variable `gnus-move-split-methods' is used for finding a default
8546 for the target newsgroup.
8548 For this function to work, both the current newsgroup and the
8549 newsgroup that you want to move to have to support the `request-move'
8550 and `request-accept' functions.
8552 ACTION can be either `move' (the default), `crosspost' or `copy'."
8555 (setq action 'move))
8556 ;; Check whether the source group supports the required functions.
8557 (cond ((and (eq action 'move)
8558 (not (gnus-check-backend-function
8559 'request-move-article gnus-newsgroup-name)))
8560 (error "The current group does not support article moving"))
8561 ((and (eq action 'crosspost)
8562 (not (gnus-check-backend-function
8563 'request-replace-article gnus-newsgroup-name)))
8564 (error "The current group does not support article editing")))
8565 (let ((articles (gnus-summary-work-articles n))
8566 (prefix (if (gnus-check-backend-function
8567 'request-move-article gnus-newsgroup-name)
8568 (gnus-group-real-prefix gnus-newsgroup-name)
8570 (names '((move "Move" "Moving")
8571 (copy "Copy" "Copying")
8572 (crosspost "Crosspost" "Crossposting")))
8573 (copy-buf (save-excursion
8574 (nnheader-set-temp-buffer " *copy article*")))
8575 (default-marks gnus-article-mark-lists)
8576 (no-expire-marks (delete '(expirable . expire)
8577 (copy-sequence gnus-article-mark-lists)))
8578 art-group to-method new-xref article to-groups)
8579 (unless (assq action names)
8580 (error "Unknown action %s" action))
8581 ;; Read the newsgroup name.
8582 (when (and (not to-newsgroup)
8583 (not select-method))
8584 (if (and gnus-move-split-methods
8586 (and (memq gnus-current-article articles)
8587 (gnus-buffer-live-p gnus-original-article-buffer))))
8588 ;; When `gnus-move-split-methods' is non-nil, we have to
8589 ;; select an article to give `gnus-read-move-group-name' an
8590 ;; opportunity to suggest an appropriate default. However,
8591 ;; we needn't render or mark the article.
8592 (let ((gnus-display-mime-function nil)
8593 (gnus-article-prepare-hook nil)
8594 (gnus-mark-article-hook nil))
8595 (gnus-summary-select-article nil nil nil (car articles))))
8597 (gnus-read-move-group-name
8598 (cadr (assq action names))
8599 (symbol-value (intern (format "gnus-current-%s-group" action)))
8601 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8602 (setq to-method (or select-method
8603 (gnus-server-to-method
8604 (gnus-group-method to-newsgroup))))
8605 ;; Check the method we are to move this article to...
8606 (unless (gnus-check-backend-function
8607 'request-accept-article (car to-method))
8608 (error "%s does not support article copying" (car to-method)))
8609 (unless (gnus-check-server to-method)
8610 (error "Can't open server %s" (car to-method)))
8611 (gnus-message 6 "%s to %s: %s..."
8612 (caddr (assq action names))
8613 (or (car select-method) to-newsgroup) articles)
8615 (setq article (pop articles))
8619 ;; Move the article.
8621 ;; Remove this article from future suppression.
8622 (gnus-dup-unsuppress-article article)
8623 (gnus-request-move-article
8624 article ; Article to move
8625 gnus-newsgroup-name ; From newsgroup
8626 (nth 1 (gnus-find-method-for-group
8627 gnus-newsgroup-name)) ; Server
8628 (list 'gnus-request-accept-article
8629 to-newsgroup (list 'quote select-method)
8630 (not articles) t) ; Accept form
8631 (not articles))) ; Only save nov last time
8632 ;; Copy the article.
8635 (set-buffer copy-buf)
8636 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8637 (gnus-request-accept-article
8638 to-newsgroup select-method (not articles) t))))
8639 ;; Crosspost the article.
8640 ((eq action 'crosspost)
8641 (let ((xref (message-tokenize-header
8642 (mail-header-xref (gnus-summary-article-header article))
8644 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8645 ":" (number-to-string article)))
8647 (setq xref (list (system-name))))
8650 (mapconcat 'identity
8651 (delete "Xref:" (delete new-xref xref))
8655 (set-buffer copy-buf)
8656 ;; First put the article in the destination group.
8657 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8658 (when (consp (setq art-group
8659 (gnus-request-accept-article
8660 to-newsgroup select-method (not articles))))
8661 (setq new-xref (concat new-xref " " (car art-group)
8663 (number-to-string (cdr art-group))))
8664 ;; Now we have the new Xrefs header, so we insert
8665 ;; it and replace the new article.
8666 (nnheader-replace-header "Xref" new-xref)
8667 (gnus-request-replace-article
8668 (cdr art-group) to-newsgroup (current-buffer))
8672 (gnus-message 1 "Couldn't %s article %s: %s"
8673 (cadr (assq action names)) article
8674 (nnheader-get-report (car to-method))))
8675 ((eq art-group 'junk)
8676 (when (eq action 'move)
8677 (gnus-summary-mark-article article gnus-canceled-mark)
8678 (gnus-message 4 "Deleted article %s" article)))
8680 (let* ((pto-group (gnus-group-prefixed-name
8681 (car art-group) to-method))
8683 (gnus-gethash pto-group gnus-newsrc-hashtb))
8684 (info (nth 2 entry))
8685 (to-group (gnus-info-group info))
8687 ;; Update the group that has been moved to.
8689 (memq action '(move copy)))
8690 (unless (member to-group to-groups)
8691 (push to-group to-groups))
8693 (unless (memq article gnus-newsgroup-unreads)
8694 (push 'read to-marks)
8696 info (gnus-add-to-range (gnus-info-read info)
8697 (list (cdr art-group)))))
8699 ;; See whether the article is to be put in the cache.
8700 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8703 (to-article (cdr art-group)))
8705 ;; Enter the article into the cache in the new group,
8706 ;; if that is required.
8707 (when gnus-use-cache
8708 (gnus-cache-possibly-enter-article
8710 (let ((header (copy-sequence
8711 (gnus-summary-article-header article))))
8712 (mail-header-set-number header to-article)
8714 (memq article gnus-newsgroup-marked)
8715 (memq article gnus-newsgroup-dormant)
8716 (memq article gnus-newsgroup-unreads)))
8718 (when gnus-preserve-marks
8719 ;; Copy any marks over to the new group.
8720 (when (and (equal to-group gnus-newsgroup-name)
8721 (not (memq article gnus-newsgroup-unreads)))
8722 ;; Mark this article as read in this group.
8723 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8724 (setcdr (gnus-active to-group) to-article)
8725 (setcdr gnus-newsgroup-active to-article))
8728 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8729 (when (memq article (symbol-value
8730 (intern (format "gnus-newsgroup-%s"
8732 (push (cdar marks) to-marks)
8733 ;; If the other group is the same as this group,
8734 ;; then we have to add the mark to the list.
8735 (when (equal to-group gnus-newsgroup-name)
8736 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8739 (intern (format "gnus-newsgroup-%s"
8741 ;; Copy the marks to other group.
8742 (gnus-add-marked-articles
8743 to-group (cdar marks) (list to-article) info)))
8744 (setq marks (cdr marks)))
8746 (gnus-request-set-mark to-group (list (list (list to-article)
8751 (concat "(gnus-group-set-info '"
8752 (gnus-prin1-to-string (gnus-get-info to-group))
8755 ;; Update the Xref header in this article to point to
8756 ;; the new crossposted article we have just created.
8757 (when (eq action 'crosspost)
8759 (set-buffer copy-buf)
8760 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8761 (nnheader-replace-header "Xref" new-xref)
8762 (gnus-request-replace-article
8763 article gnus-newsgroup-name (current-buffer)))))
8765 ;;;!!!Why is this necessary?
8766 (set-buffer gnus-summary-buffer)
8768 (gnus-summary-goto-subject article)
8769 (when (eq action 'move)
8770 (gnus-summary-mark-article article gnus-canceled-mark))))
8771 (gnus-summary-remove-process-mark article))
8772 ;; Re-activate all groups that have been moved to.
8774 (set-buffer gnus-group-buffer)
8775 (let ((gnus-group-marked to-groups))
8776 (gnus-group-get-new-news-this-group nil t)))
8778 (gnus-kill-buffer copy-buf)
8779 (gnus-summary-position-point)
8780 (gnus-set-mode-line 'summary)))
8782 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8783 "Move the current article to a different newsgroup.
8784 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8785 When called interactively, if TO-NEWSGROUP is nil, use the value of
8786 the variable `gnus-move-split-methods' for finding a default target
8788 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8789 re-spool using this method."
8791 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8793 (defun gnus-summary-crosspost-article (&optional n)
8794 "Crosspost the current article to some other group."
8796 (gnus-summary-move-article n nil nil 'crosspost))
8798 (defcustom gnus-summary-respool-default-method nil
8799 "Default method type for respooling an article.
8800 If nil, use to the current newsgroup method."
8802 :group 'gnus-summary-mail)
8804 (defun gnus-summary-respool-article (&optional n method)
8805 "Respool the current article.
8806 The article will be squeezed through the mail spooling process again,
8807 which means that it will be put in some mail newsgroup or other
8808 depending on `nnmail-split-methods'.
8809 If N is a positive number, respool the N next articles.
8810 If N is a negative number, respool the N previous articles.
8811 If N is nil and any articles have been marked with the process mark,
8812 respool those articles instead.
8814 Respooling can be done both from mail groups and \"real\" newsgroups.
8815 In the former case, the articles in question will be moved from the
8816 current group into whatever groups they are destined to. In the
8817 latter case, they will be copied into the relevant groups."
8819 (list current-prefix-arg
8820 (let* ((methods (gnus-methods-using 'respool))
8822 (symbol-name (or gnus-summary-respool-default-method
8823 (car (gnus-find-method-for-group
8824 gnus-newsgroup-name)))))
8826 (gnus-completing-read-with-default
8827 methname "What backend do you want to use when respooling?"
8828 methods nil t nil 'gnus-mail-method-history))
8831 ((zerop (length (setq ms (gnus-servers-using-backend
8833 (list (intern method) ""))
8837 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8838 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8841 (error "No method given for respooling"))
8842 (if (assoc (symbol-name
8843 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8844 (gnus-methods-using 'respool))
8845 (gnus-summary-move-article n nil method)
8846 (gnus-summary-copy-article n nil method)))
8848 (defun gnus-summary-import-article (file &optional edit)
8849 "Import an arbitrary file into a mail newsgroup."
8850 (interactive "fImport file: \nP")
8851 (let ((group gnus-newsgroup-name)
8852 (now (current-time))
8853 atts lines group-art)
8854 (unless (gnus-check-backend-function 'request-accept-article group)
8855 (error "%s does not support article importing" group))
8856 (or (file-readable-p file)
8857 (not (file-regular-p file))
8858 (error "Can't read %s" file))
8860 (set-buffer (gnus-get-buffer-create " *import file*"))
8862 (nnheader-insert-file-contents file)
8863 (goto-char (point-min))
8864 (if (nnheader-article-p)
8866 (goto-char (point-min))
8867 (search-forward "\n\n" nil t)
8868 (narrow-to-region (point-min) (1- (point)))
8869 (goto-char (point-min))
8870 (unless (re-search-forward "^date:" nil t)
8871 (goto-char (point-max))
8872 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8873 ;; This doesn't look like an article, so we fudge some headers.
8874 (setq atts (file-attributes file)
8875 lines (count-lines (point-min) (point-max)))
8876 (insert "From: " (read-string "From: ") "\n"
8877 "Subject: " (read-string "Subject: ") "\n"
8878 "Date: " (message-make-date (nth 5 atts)) "\n"
8879 "Message-ID: " (message-make-message-id) "\n"
8880 "Lines: " (int-to-string lines) "\n"
8881 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8882 (setq group-art (gnus-request-accept-article group nil t))
8883 (kill-buffer (current-buffer)))
8884 (setq gnus-newsgroup-active (gnus-activate-group group))
8886 (gnus-summary-goto-article (cdr group-art) nil t)
8888 (gnus-summary-edit-article))))
8890 (defun gnus-summary-create-article ()
8891 "Create an article in a mail newsgroup."
8893 (let ((group gnus-newsgroup-name)
8894 (now (current-time))
8896 (unless (gnus-check-backend-function 'request-accept-article group)
8897 (error "%s does not support article importing" group))
8899 (set-buffer (gnus-get-buffer-create " *import file*"))
8901 (goto-char (point-min))
8902 ;; This doesn't look like an article, so we fudge some headers.
8903 (insert "From: " (read-string "From: ") "\n"
8904 "Subject: " (read-string "Subject: ") "\n"
8905 "Date: " (message-make-date now) "\n"
8906 "Message-ID: " (message-make-message-id) "\n")
8907 (setq group-art (gnus-request-accept-article group nil t))
8908 (kill-buffer (current-buffer)))
8909 (setq gnus-newsgroup-active (gnus-activate-group group))
8911 (gnus-summary-goto-article (cdr group-art) nil t)
8912 (gnus-summary-edit-article)))
8914 (defun gnus-summary-article-posted-p ()
8915 "Say whether the current (mail) article is available from news as well.
8916 This will be the case if the article has both been mailed and posted."
8918 (let ((id (mail-header-references (gnus-summary-article-header)))
8919 (gnus-override-method (car (gnus-refer-article-methods))))
8920 (if (gnus-request-head id "")
8921 (gnus-message 2 "The current message was found on %s"
8922 gnus-override-method)
8923 (gnus-message 2 "The current message couldn't be found on %s"
8924 gnus-override-method)
8927 (defun gnus-summary-expire-articles (&optional now)
8928 "Expire all articles that are marked as expirable in the current group."
8930 (when (gnus-check-backend-function
8931 'request-expire-articles gnus-newsgroup-name)
8932 ;; This backend supports expiry.
8933 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8934 (expirable (if total
8936 ;; We need to update the info for
8937 ;; this group for `gnus-list-of-read-articles'
8938 ;; to give us the right answer.
8939 (gnus-run-hooks 'gnus-exit-group-hook)
8940 (gnus-summary-update-info)
8941 (gnus-list-of-read-articles gnus-newsgroup-name))
8942 (setq gnus-newsgroup-expirable
8943 (sort gnus-newsgroup-expirable '<))))
8944 (expiry-wait (if now 'immediate
8945 (gnus-group-find-parameter
8946 gnus-newsgroup-name 'expiry-wait)))
8947 (nnmail-expiry-target
8948 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8949 nnmail-expiry-target))
8952 ;; There are expirable articles in this group, so we run them
8953 ;; through the expiry process.
8954 (gnus-message 6 "Expiring articles...")
8955 (unless (gnus-check-group gnus-newsgroup-name)
8956 (error "Can't open server for %s" gnus-newsgroup-name))
8957 ;; The list of articles that weren't expired is returned.
8960 (let ((nnmail-expiry-wait-function nil)
8961 (nnmail-expiry-wait expiry-wait))
8962 (setq es (gnus-request-expire-articles
8963 expirable gnus-newsgroup-name)))
8964 (setq es (gnus-request-expire-articles
8965 expirable gnus-newsgroup-name)))
8967 (setq gnus-newsgroup-expirable es))
8968 ;; We go through the old list of expirable, and mark all
8969 ;; really expired articles as nonexistent.
8970 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8971 (let ((gnus-use-cache nil))
8972 (dolist (article expirable)
8973 (when (and (not (memq article es))
8974 (gnus-data-find article))
8975 (gnus-summary-mark-article article gnus-canceled-mark))))))
8976 (gnus-message 6 "Expiring articles...done")))))
8978 (defun gnus-summary-expire-articles-now ()
8979 "Expunge all expirable articles in the current group.
8980 This means that *all* articles that are marked as expirable will be
8981 deleted forever, right now."
8983 (or gnus-expert-user
8985 "Are you really, really, really sure you want to delete all these messages? ")
8987 (gnus-summary-expire-articles t))
8989 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
8990 (defun gnus-summary-delete-article (&optional n)
8991 "Delete the N next (mail) articles.
8992 This command actually deletes articles. This is not a marking
8993 command. The article will disappear forever from your life, never to
8995 If N is negative, delete backwards.
8996 If N is nil and articles have been marked with the process mark,
8997 delete these instead."
8999 (unless (gnus-check-backend-function 'request-expire-articles
9000 gnus-newsgroup-name)
9001 (error "The current newsgroup does not support article deletion"))
9002 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9003 (error "Couldn't open server"))
9004 ;; Compute the list of articles to delete.
9005 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9006 (nnmail-expiry-target 'delete)
9008 (if (and gnus-novice-user
9009 (not (gnus-yes-or-no-p
9010 (format "Do you really want to delete %s forever? "
9011 (if (> (length articles) 1)
9012 (format "these %s articles" (length articles))
9015 ;; Delete the articles.
9016 (setq not-deleted (gnus-request-expire-articles
9017 articles gnus-newsgroup-name 'force))
9019 (gnus-summary-remove-process-mark (car articles))
9020 ;; The backend might not have been able to delete the article
9022 (unless (memq (car articles) not-deleted)
9023 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9024 (setq articles (cdr articles)))
9026 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9027 (gnus-summary-position-point)
9028 (gnus-set-mode-line 'summary)
9031 (defun gnus-summary-edit-article (&optional force)
9032 "Edit the current article.
9033 This will have permanent effect only in mail groups.
9034 If FORCE is non-nil, allow editing of articles even in read-only
9038 (set-buffer gnus-summary-buffer)
9039 (let ((mail-parse-charset gnus-newsgroup-charset)
9040 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9041 (gnus-set-global-variables)
9042 (when (and (not force)
9043 (gnus-group-read-only-p))
9044 (error "The current newsgroup does not support article editing"))
9045 (gnus-summary-show-article t)
9046 (gnus-article-edit-article
9048 `(lambda (no-highlight)
9049 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9050 (message-options message-options)
9051 (message-options-set-recipient)
9052 (mail-parse-ignored-charsets
9053 ',gnus-newsgroup-ignored-charsets))
9054 (gnus-summary-edit-article-done
9055 ,(or (mail-header-references gnus-current-headers) "")
9056 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9058 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9060 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9062 "Make edits to the current article permanent."
9065 ;; The buffer restriction contains the entire article if it exists.
9066 (when (article-goto-body)
9067 (let ((lines (count-lines (point) (point-max)))
9068 (length (- (point-max) (point)))
9069 (case-fold-search t)
9070 (body (copy-marker (point))))
9071 (goto-char (point-min))
9072 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9073 (delete-region (match-beginning 1) (match-end 1))
9074 (insert (number-to-string length)))
9075 (goto-char (point-min))
9076 (when (re-search-forward
9077 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9078 (delete-region (match-beginning 1) (match-end 1))
9079 (insert (number-to-string length)))
9080 (goto-char (point-min))
9081 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9082 (delete-region (match-beginning 1) (match-end 1))
9083 (insert (number-to-string lines))))))
9084 ;; Replace the article.
9085 (let ((buf (current-buffer)))
9087 (insert-buffer-substring buf)
9089 (if (and (not read-only)
9090 (not (gnus-request-replace-article
9091 (cdr gnus-article-current) (car gnus-article-current)
9092 (current-buffer) t)))
9093 (error "Couldn't replace article")
9094 ;; Update the summary buffer.
9096 (equal (message-tokenize-header references " ")
9097 (message-tokenize-header
9098 (or (message-fetch-field "references") "") " ")))
9099 ;; We only have to update this line.
9102 (message-narrow-to-head)
9103 (let ((head (buffer-string))
9106 (insert (format "211 %d Article retrieved.\n"
9107 (cdr gnus-article-current)))
9110 (let ((nntp-server-buffer (current-buffer)))
9111 (setq header (car (gnus-get-newsgroup-headers
9114 (set-buffer gnus-summary-buffer)
9115 (gnus-data-set-header
9116 (gnus-data-find (cdr gnus-article-current))
9118 (gnus-summary-update-article-line
9119 (cdr gnus-article-current) header)
9120 (if (gnus-summary-goto-subject
9121 (cdr gnus-article-current) nil t)
9122 (gnus-summary-update-secondary-mark
9123 (cdr gnus-article-current))))))))
9125 (set-buffer (or buffer gnus-summary-buffer))
9126 (gnus-summary-update-article (cdr gnus-article-current))
9127 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9128 (gnus-summary-update-secondary-mark
9129 (cdr gnus-article-current))))
9130 ;; Prettify the article buffer again.
9131 (unless no-highlight
9133 (set-buffer gnus-article-buffer)
9134 ;;;!!! Fix this -- article should be rehighlighted.
9135 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9136 (set-buffer gnus-original-article-buffer)
9137 (gnus-request-article
9138 (cdr gnus-article-current)
9139 (car gnus-article-current) (current-buffer))))
9140 ;; Prettify the summary buffer line.
9141 (when (gnus-visual-p 'summary-highlight 'highlight)
9142 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9144 (defun gnus-summary-edit-wash (key)
9145 "Perform editing command KEY in the article buffer."
9149 (message "%s" (concat (this-command-keys) "- "))
9152 (gnus-summary-edit-article)
9153 (execute-kbd-macro (concat (this-command-keys) key))
9154 (gnus-article-edit-done))
9158 (defun gnus-summary-respool-query (&optional silent trace)
9159 "Query where the respool algorithm would put this article."
9161 (let (gnus-mark-article-hook)
9162 (gnus-summary-select-article)
9164 (set-buffer gnus-original-article-buffer)
9166 (message-narrow-to-head)
9167 (let ((groups (nnmail-article-group 'identity trace)))
9170 (message "This message would go to %s"
9171 (mapconcat 'car groups ", "))
9172 (message "This message would go to no groups"))
9175 (defun gnus-summary-respool-trace ()
9176 "Trace where the respool algorithm would put this article.
9177 Display a buffer showing all fancy splitting patterns which matched."
9179 (gnus-summary-respool-query nil t))
9181 ;; Summary marking commands.
9183 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9184 "Mark articles which has the same subject as read, and then select the next.
9185 If UNMARK is positive, remove any kind of mark.
9186 If UNMARK is negative, tick articles."
9189 (setq unmark (prefix-numeric-value unmark)))
9191 (gnus-summary-mark-same-subject
9192 (gnus-summary-article-subject) unmark)))
9193 ;; Select next unread article. If auto-select-same mode, should
9194 ;; select the first unread article.
9195 (gnus-summary-next-article t (and gnus-auto-select-same
9196 (gnus-summary-article-subject)))
9197 (gnus-message 7 "%d article%s marked as %s"
9198 count (if (= count 1) " is" "s are")
9199 (if unmark "unread" "read"))))
9201 (defun gnus-summary-kill-same-subject (&optional unmark)
9202 "Mark articles which has the same subject as read.
9203 If UNMARK is positive, remove any kind of mark.
9204 If UNMARK is negative, tick articles."
9207 (setq unmark (prefix-numeric-value unmark)))
9209 (gnus-summary-mark-same-subject
9210 (gnus-summary-article-subject) unmark)))
9211 ;; If marked as read, go to next unread subject.
9213 ;; Go to next unread subject.
9214 (gnus-summary-next-subject 1 t))
9215 (gnus-message 7 "%d articles are marked as %s"
9216 count (if unmark "unread" "read"))))
9218 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9219 "Mark articles with same SUBJECT as read, and return marked number.
9220 If optional argument UNMARK is positive, remove any kinds of marks.
9221 If optional argument UNMARK is negative, mark articles as unread instead."
9225 ((null unmark) ; Mark as read.
9228 (gnus-summary-mark-article-as-read gnus-killed-mark)
9229 (gnus-summary-show-thread) t)
9230 (gnus-summary-find-subject subject))
9231 (setq count (1+ count))))
9232 ((> unmark 0) ; Tick.
9235 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9236 (gnus-summary-show-thread) t)
9237 (gnus-summary-find-subject subject))
9238 (setq count (1+ count))))
9239 (t ; Mark as unread.
9242 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9243 (gnus-summary-show-thread) t)
9244 (gnus-summary-find-subject subject))
9245 (setq count (1+ count)))))
9246 (gnus-set-mode-line 'summary)
9247 ;; Return the number of marked articles.
9250 (defun gnus-summary-mark-as-processable (n &optional unmark)
9251 "Set the process mark on the next N articles.
9252 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9253 the process mark instead. The difference between N and the actual
9254 number of articles marked is returned."
9256 (if (and (null n) (gnus-region-active-p))
9257 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9258 (setq n (prefix-numeric-value n))
9259 (let ((backward (< n 0))
9264 (gnus-summary-remove-process-mark
9265 (gnus-summary-article-number))
9266 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9267 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9270 (gnus-message 7 "No more articles"))
9271 (gnus-summary-recenter)
9272 (gnus-summary-position-point)
9275 (defun gnus-summary-unmark-as-processable (n)
9276 "Remove the process mark from the next N articles.
9277 If N is negative, unmark backward instead. The difference between N and
9278 the actual number of articles unmarked is returned."
9280 (gnus-summary-mark-as-processable n t))
9282 (defun gnus-summary-unmark-all-processable ()
9283 "Remove the process mark from all articles."
9286 (while gnus-newsgroup-processable
9287 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9288 (gnus-summary-position-point))
9290 (defun gnus-summary-add-mark (article type)
9291 "Mark ARTICLE with a mark of TYPE."
9292 (let ((vtype (car (assq type gnus-article-mark-lists)))
9295 (error "No such mark type: %s" type)
9296 (setq var (intern (format "gnus-newsgroup-%s" type)))
9297 (set var (cons article (symbol-value var)))
9298 (if (memq type '(processable cached replied forwarded recent saved))
9299 (gnus-summary-update-secondary-mark article)
9300 ;;; !!! This is bogus. We should find out what primary
9301 ;;; !!! mark we want to set.
9302 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9304 (defun gnus-summary-mark-as-expirable (n)
9305 "Mark N articles forward as expirable.
9306 If N is negative, mark backward instead. The difference between N and
9307 the actual number of articles marked is returned."
9309 (gnus-summary-mark-forward n gnus-expirable-mark))
9311 (defun gnus-summary-mark-as-spam (n)
9312 "Mark N articles forward as spam.
9313 If N is negative, mark backward instead. The difference between N and
9314 the actual number of articles marked is returned."
9316 (gnus-summary-mark-forward n gnus-spam-mark))
9318 (defun gnus-summary-mark-article-as-replied (article)
9319 "Mark ARTICLE as replied to and update the summary line.
9320 ARTICLE can also be a list of articles."
9321 (interactive (list (gnus-summary-article-number)))
9322 (let ((articles (if (listp article) article (list article))))
9323 (dolist (article articles)
9324 (push article gnus-newsgroup-replied)
9325 (let ((buffer-read-only nil))
9326 (when (gnus-summary-goto-subject article nil t)
9327 (gnus-summary-update-secondary-mark article))))))
9329 (defun gnus-summary-mark-article-as-forwarded (article)
9330 "Mark ARTICLE as forwarded and update the summary line.
9331 ARTICLE can also be a list of articles."
9332 (let ((articles (if (listp article) article (list article))))
9333 (dolist (article articles)
9334 (push article gnus-newsgroup-forwarded)
9335 (let ((buffer-read-only nil))
9336 (when (gnus-summary-goto-subject article nil t)
9337 (gnus-summary-update-secondary-mark article))))))
9339 (defun gnus-summary-set-bookmark (article)
9340 "Set a bookmark in current article."
9341 (interactive (list (gnus-summary-article-number)))
9342 (when (or (not (get-buffer gnus-article-buffer))
9343 (not gnus-current-article)
9344 (not gnus-article-current)
9345 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9346 (error "No current article selected"))
9347 ;; Remove old bookmark, if one exists.
9348 (let ((old (assq article gnus-newsgroup-bookmarks)))
9350 (setq gnus-newsgroup-bookmarks
9351 (delq old gnus-newsgroup-bookmarks))))
9352 ;; Set the new bookmark, which is on the form
9353 ;; (article-number . line-number-in-body).
9357 (set-buffer gnus-article-buffer)
9361 (goto-char (point-min))
9362 (search-forward "\n\n" nil t)
9365 gnus-newsgroup-bookmarks)
9366 (gnus-message 6 "A bookmark has been added to the current article."))
9368 (defun gnus-summary-remove-bookmark (article)
9369 "Remove the bookmark from the current article."
9370 (interactive (list (gnus-summary-article-number)))
9371 ;; Remove old bookmark, if one exists.
9372 (let ((old (assq article gnus-newsgroup-bookmarks)))
9375 (setq gnus-newsgroup-bookmarks
9376 (delq old gnus-newsgroup-bookmarks))
9377 (gnus-message 6 "Removed bookmark."))
9378 (gnus-message 6 "No bookmark in current article."))))
9380 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9381 (defun gnus-summary-mark-as-dormant (n)
9382 "Mark N articles forward as dormant.
9383 If N is negative, mark backward instead. The difference between N and
9384 the actual number of articles marked is returned."
9386 (gnus-summary-mark-forward n gnus-dormant-mark))
9388 (defun gnus-summary-set-process-mark (article)
9389 "Set the process mark on ARTICLE and update the summary line."
9390 (setq gnus-newsgroup-processable
9392 (delq article gnus-newsgroup-processable)))
9393 (when (gnus-summary-goto-subject article)
9394 (gnus-summary-show-thread)
9395 (gnus-summary-goto-subject article)
9396 (gnus-summary-update-secondary-mark article)))
9398 (defun gnus-summary-remove-process-mark (article)
9399 "Remove the process mark from ARTICLE and update the summary line."
9400 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9401 (when (gnus-summary-goto-subject article)
9402 (gnus-summary-show-thread)
9403 (gnus-summary-goto-subject article)
9404 (gnus-summary-update-secondary-mark article)))
9406 (defun gnus-summary-set-saved-mark (article)
9407 "Set the process mark on ARTICLE and update the summary line."
9408 (push article gnus-newsgroup-saved)
9409 (when (gnus-summary-goto-subject article)
9410 (gnus-summary-update-secondary-mark article)))
9412 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9413 "Mark N articles as read forwards.
9414 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9415 The difference between N and the actual number of articles marked is
9417 Iff NO-EXPIRE, auto-expiry will be inhibited."
9419 (gnus-summary-show-thread)
9420 (let ((backward (< n 0))
9421 (gnus-summary-goto-unread
9422 (and gnus-summary-goto-unread
9423 (not (eq gnus-summary-goto-unread 'never))
9424 (not (memq mark (list gnus-unread-mark
9425 gnus-ticked-mark gnus-dormant-mark)))))
9427 (mark (or mark gnus-del-mark)))
9429 (gnus-summary-mark-article nil mark no-expire)
9430 (zerop (gnus-summary-next-subject
9432 (and gnus-summary-goto-unread
9433 (not (eq gnus-summary-goto-unread 'never)))
9437 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9438 (gnus-summary-recenter)
9439 (gnus-summary-position-point)
9440 (gnus-set-mode-line 'summary)
9443 (defun gnus-summary-mark-article-as-read (mark)
9444 "Mark the current article quickly as read with MARK."
9445 (let ((article (gnus-summary-article-number)))
9446 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9447 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9448 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9449 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9450 (push (cons article mark) gnus-newsgroup-reads)
9451 ;; Possibly remove from cache, if that is used.
9452 (when gnus-use-cache
9453 (gnus-cache-enter-remove-article article))
9454 ;; Allow the backend to change the mark.
9455 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9456 ;; Check for auto-expiry.
9457 (when (and gnus-newsgroup-auto-expire
9458 (memq mark gnus-auto-expirable-marks))
9459 (setq mark gnus-expirable-mark)
9460 ;; Let the backend know about the mark change.
9461 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9462 (push article gnus-newsgroup-expirable))
9463 ;; Set the mark in the buffer.
9464 (gnus-summary-update-mark mark 'unread)
9467 (defun gnus-summary-mark-article-as-unread (mark)
9468 "Mark the current article quickly as unread with MARK."
9469 (let* ((article (gnus-summary-article-number))
9470 (old-mark (gnus-summary-article-mark article)))
9471 ;; Allow the backend to change the mark.
9472 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9473 (if (eq mark old-mark)
9477 (gnus-error 1 "Can't mark negative article numbers")
9479 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9480 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9481 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9482 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9483 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9484 (cond ((= mark gnus-ticked-mark)
9485 (setq gnus-newsgroup-marked
9486 (gnus-add-to-sorted-list gnus-newsgroup-marked
9488 ((= mark gnus-spam-mark)
9489 (setq gnus-newsgroup-spam-marked
9490 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9492 ((= mark gnus-dormant-mark)
9493 (setq gnus-newsgroup-dormant
9494 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9497 (setq gnus-newsgroup-unreads
9498 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9500 (gnus-pull article gnus-newsgroup-reads)
9502 ;; See whether the article is to be put in the cache.
9504 (vectorp (gnus-summary-article-header article))
9506 (gnus-cache-possibly-enter-article
9507 gnus-newsgroup-name article
9508 (gnus-summary-article-header article)
9509 (= mark gnus-ticked-mark)
9510 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9513 (gnus-summary-update-mark mark 'unread)
9516 (defun gnus-summary-mark-article (&optional article mark no-expire)
9517 "Mark ARTICLE with MARK. MARK can be any character.
9518 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9519 `??' (dormant) and `?E' (expirable).
9520 If MARK is nil, then the default character `?r' is used.
9521 If ARTICLE is nil, then the article on the current line will be
9523 Iff NO-EXPIRE, auto-expiry will be inhibited."
9524 ;; The mark might be a string.
9525 (when (stringp mark)
9526 (setq mark (aref mark 0)))
9527 ;; If no mark is given, then we check auto-expiring.
9529 (setq mark gnus-del-mark))
9530 (when (and (not no-expire)
9531 gnus-newsgroup-auto-expire
9532 (memq mark gnus-auto-expirable-marks))
9533 (setq mark gnus-expirable-mark))
9534 (let ((article (or article (gnus-summary-article-number)))
9535 (old-mark (gnus-summary-article-mark article)))
9536 ;; Allow the backend to change the mark.
9537 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9538 (if (eq mark old-mark)
9541 (error "No article on current line"))
9542 (if (not (if (or (= mark gnus-unread-mark)
9543 (= mark gnus-ticked-mark)
9544 (= mark gnus-spam-mark)
9545 (= mark gnus-dormant-mark))
9546 (gnus-mark-article-as-unread article mark)
9547 (gnus-mark-article-as-read article mark)))
9549 ;; See whether the article is to be put in the cache.
9551 (not (= mark gnus-canceled-mark))
9552 (vectorp (gnus-summary-article-header article))
9554 (gnus-cache-possibly-enter-article
9555 gnus-newsgroup-name article
9556 (gnus-summary-article-header article)
9557 (= mark gnus-ticked-mark)
9558 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9560 (when (gnus-summary-goto-subject article nil t)
9561 (let ((buffer-read-only nil))
9562 (gnus-summary-show-thread)
9564 (gnus-summary-update-mark mark 'unread)
9567 (defun gnus-summary-update-secondary-mark (article)
9568 "Update the secondary (read, process, cache) mark."
9569 (gnus-summary-update-mark
9570 (cond ((memq article gnus-newsgroup-processable)
9572 ((memq article gnus-newsgroup-cached)
9574 ((memq article gnus-newsgroup-replied)
9576 ((memq article gnus-newsgroup-forwarded)
9577 gnus-forwarded-mark)
9578 ((memq article gnus-newsgroup-saved)
9580 ((memq article gnus-newsgroup-recent)
9582 ((memq article gnus-newsgroup-unseen)
9586 (when (gnus-visual-p 'summary-highlight 'highlight)
9587 (gnus-run-hooks 'gnus-summary-update-hook))
9590 (defun gnus-summary-update-mark (mark type)
9591 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9592 (buffer-read-only nil))
9593 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9595 (when (looking-at "\r")
9597 (when (<= (+ forward (point)) (point-max))
9598 ;; Go to the right position on the line.
9599 (goto-char (+ forward (point)))
9600 ;; Replace the old mark with the new mark.
9601 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9602 ;; Optionally update the marks by some user rule.
9603 (when (eq type 'unread)
9605 (gnus-data-find (gnus-summary-article-number)) mark)
9606 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9608 (defun gnus-mark-article-as-read (article &optional mark)
9609 "Enter ARTICLE in the pertinent lists and remove it from others."
9610 ;; Make the article expirable.
9611 (let ((mark (or mark gnus-del-mark)))
9612 (setq gnus-newsgroup-expirable
9613 (if (= mark gnus-expirable-mark)
9614 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9615 (delq article gnus-newsgroup-expirable)))
9616 ;; Remove from unread and marked lists.
9617 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9618 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9619 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9620 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9621 (push (cons article mark) gnus-newsgroup-reads)
9622 ;; Possibly remove from cache, if that is used.
9623 (when gnus-use-cache
9624 (gnus-cache-enter-remove-article article))
9627 (defun gnus-mark-article-as-unread (article &optional mark)
9628 "Enter ARTICLE in the pertinent lists and remove it from others."
9629 (let ((mark (or mark gnus-ticked-mark)))
9632 (gnus-error 1 "Can't mark negative article numbers")
9634 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9635 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9636 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9637 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9638 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9640 ;; Unsuppress duplicates?
9641 (when gnus-suppress-duplicates
9642 (gnus-dup-unsuppress-article article))
9644 (cond ((= mark gnus-ticked-mark)
9645 (setq gnus-newsgroup-marked
9646 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9647 ((= mark gnus-spam-mark)
9648 (setq gnus-newsgroup-spam-marked
9649 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked article)))
9650 ((= mark gnus-dormant-mark)
9651 (setq gnus-newsgroup-dormant
9652 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9654 (setq gnus-newsgroup-unreads
9655 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9656 (gnus-pull article gnus-newsgroup-reads)
9659 (defalias 'gnus-summary-mark-as-unread-forward
9660 'gnus-summary-tick-article-forward)
9661 (make-obsolete 'gnus-summary-mark-as-unread-forward
9662 'gnus-summary-tick-article-forward)
9663 (defun gnus-summary-tick-article-forward (n)
9664 "Tick N articles forwards.
9665 If N is negative, tick backwards instead.
9666 The difference between N and the number of articles ticked is returned."
9668 (gnus-summary-mark-forward n gnus-ticked-mark))
9670 (defalias 'gnus-summary-mark-as-unread-backward
9671 'gnus-summary-tick-article-backward)
9672 (make-obsolete 'gnus-summary-mark-as-unread-backward
9673 'gnus-summary-tick-article-backward)
9674 (defun gnus-summary-tick-article-backward (n)
9675 "Tick N articles backwards.
9676 The difference between N and the number of articles ticked is returned."
9678 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9680 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9681 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9682 (defun gnus-summary-tick-article (&optional article clear-mark)
9683 "Mark current article as unread.
9684 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9685 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9687 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9690 (defun gnus-summary-mark-as-read-forward (n)
9691 "Mark N articles as read forwards.
9692 If N is negative, mark backwards instead.
9693 The difference between N and the actual number of articles marked is
9696 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9698 (defun gnus-summary-mark-as-read-backward (n)
9699 "Mark the N articles as read backwards.
9700 The difference between N and the actual number of articles marked is
9703 (gnus-summary-mark-forward
9704 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9706 (defun gnus-summary-mark-as-read (&optional article mark)
9707 "Mark current article as read.
9708 ARTICLE specifies the article to be marked as read.
9709 MARK specifies a string to be inserted at the beginning of the line."
9710 (gnus-summary-mark-article article mark))
9712 (defun gnus-summary-clear-mark-forward (n)
9713 "Clear marks from N articles forward.
9714 If N is negative, clear backward instead.
9715 The difference between N and the number of marks cleared is returned."
9717 (gnus-summary-mark-forward n gnus-unread-mark))
9719 (defun gnus-summary-clear-mark-backward (n)
9720 "Clear marks from N articles backward.
9721 The difference between N and the number of marks cleared is returned."
9723 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9725 (defun gnus-summary-mark-unread-as-read ()
9726 "Intended to be used by `gnus-summary-mark-article-hook'."
9727 (when (memq gnus-current-article gnus-newsgroup-unreads)
9728 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9730 (defun gnus-summary-mark-read-and-unread-as-read ()
9731 "Intended to be used by `gnus-summary-mark-article-hook'."
9732 (let ((mark (gnus-summary-article-mark)))
9733 (when (or (gnus-unread-mark-p mark)
9734 (gnus-read-mark-p mark))
9735 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9737 (defun gnus-summary-mark-unread-as-ticked ()
9738 "Intended to be used by `gnus-summary-mark-article-hook'."
9739 (when (memq gnus-current-article gnus-newsgroup-unreads)
9740 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9742 (defun gnus-summary-mark-region-as-read (point mark all)
9743 "Mark all unread articles between point and mark as read.
9744 If given a prefix, mark all articles between point and mark as read,
9745 even ticked and dormant ones."
9746 (interactive "r\nP")
9755 (memq (setq article (gnus-summary-article-number))
9756 gnus-newsgroup-unreads))
9757 (gnus-summary-mark-article article gnus-del-mark))
9759 (gnus-summary-find-next))))))
9761 (defun gnus-summary-mark-below (score mark)
9762 "Mark articles with score less than SCORE with MARK."
9763 (interactive "P\ncMark: ")
9764 (setq score (if score
9765 (prefix-numeric-value score)
9766 (or gnus-summary-default-score 0)))
9768 (set-buffer gnus-summary-buffer)
9769 (goto-char (point-min))
9772 (and (< (gnus-summary-article-score) score)
9773 (gnus-summary-mark-article nil mark))
9774 (gnus-summary-find-next)))))
9776 (defun gnus-summary-kill-below (&optional score)
9777 "Mark articles with score below SCORE as read."
9779 (gnus-summary-mark-below score gnus-killed-mark))
9781 (defun gnus-summary-clear-above (&optional score)
9782 "Clear all marks from articles with score above SCORE."
9784 (gnus-summary-mark-above score gnus-unread-mark))
9786 (defun gnus-summary-tick-above (&optional score)
9787 "Tick all articles with score above SCORE."
9789 (gnus-summary-mark-above score gnus-ticked-mark))
9791 (defun gnus-summary-mark-above (score mark)
9792 "Mark articles with score over SCORE with MARK."
9793 (interactive "P\ncMark: ")
9794 (setq score (if score
9795 (prefix-numeric-value score)
9796 (or gnus-summary-default-score 0)))
9798 (set-buffer gnus-summary-buffer)
9799 (goto-char (point-min))
9801 (when (> (gnus-summary-article-score) score)
9802 (gnus-summary-mark-article nil mark))
9804 (gnus-summary-find-next)))))
9806 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9807 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9808 (defun gnus-summary-limit-include-expunged (&optional no-error)
9809 "Display all the hidden articles that were expunged for low scores."
9811 (let ((buffer-read-only nil))
9812 (let ((scored gnus-newsgroup-scored)
9815 (unless (gnus-summary-article-header (caar scored))
9816 (and (setq h (gnus-number-to-header (caar scored)))
9817 (< (cdar scored) gnus-summary-expunge-below)
9819 (setq scored (cdr scored)))
9821 (when (not no-error)
9822 (error "No expunged articles hidden"))
9823 (goto-char (point-min))
9824 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9825 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9826 (mapcar (lambda (x) (push (mail-header-number x)
9827 gnus-newsgroup-limit))
9829 (gnus-summary-prepare-unthreaded (nreverse headers))
9830 (goto-char (point-min))
9831 (gnus-summary-position-point)
9834 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9835 "Mark all unread articles in this newsgroup as read.
9836 If prefix argument ALL is non-nil, ticked and dormant articles will
9837 also be marked as read.
9838 If QUIETLY is non-nil, no questions will be asked.
9839 If TO-HERE is non-nil, it should be a point in the buffer. All
9840 articles before (after, if REVERSE is set) this point will be marked as read.
9841 Note that this function will only catch up the unread article
9842 in the current summary buffer limitation.
9843 The number of articles marked as read is returned."
9848 (not gnus-interactive-catchup) ;Without confirmation?
9852 "Mark absolutely all articles as read? "
9853 "Mark all unread articles as read? ")))
9855 (not gnus-newsgroup-adaptive)
9856 (not gnus-newsgroup-auto-expire)
9857 (not gnus-suppress-duplicates)
9858 (or (not gnus-use-cache)
9859 (eq gnus-use-cache 'passive)))
9862 (setq gnus-newsgroup-marked nil
9863 gnus-newsgroup-spam-marked nil
9864 gnus-newsgroup-dormant nil))
9865 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9866 ;; We actually mark all articles as canceled, which we
9867 ;; have to do when using auto-expiry or adaptive scoring.
9868 (gnus-summary-show-all-threads)
9869 (if (and to-here reverse)
9873 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9874 (gnus-summary-find-next (not all) nil nil t))))
9875 (when (gnus-summary-first-subject (not all) t)
9877 (if to-here (< (point) to-here) t)
9878 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9879 (gnus-summary-find-next (not all) nil nil t)))))
9880 (gnus-set-mode-line 'summary))
9882 (gnus-summary-position-point)))
9884 (defun gnus-summary-catchup-to-here (&optional all)
9885 "Mark all unticked articles before the current one as read.
9886 If ALL is non-nil, also mark ticked and dormant articles as read."
9889 (gnus-save-hidden-threads
9890 (let ((beg (point)))
9891 ;; We check that there are unread articles.
9892 (when (or all (gnus-summary-find-prev))
9893 (gnus-summary-catchup all t beg)))))
9894 (gnus-summary-position-point))
9896 (defun gnus-summary-catchup-from-here (&optional all)
9897 "Mark all unticked articles after the current one as read.
9898 If ALL is non-nil, also mark ticked and dormant articles as read."
9901 (gnus-save-hidden-threads
9902 (let ((beg (point)))
9903 ;; We check that there are unread articles.
9904 (when (or all (gnus-summary-find-next))
9905 (gnus-summary-catchup all t beg nil t)))))
9906 (gnus-summary-position-point))
9908 (defun gnus-summary-catchup-all (&optional quietly)
9909 "Mark all articles in this newsgroup as read."
9911 (gnus-summary-catchup t quietly))
9913 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9914 "Mark all unread articles in this group as read, then exit.
9915 If prefix argument ALL is non-nil, all articles are marked as read.
9916 If QUIETLY is non-nil, no questions will be asked."
9918 (when (gnus-summary-catchup all quietly nil 'fast)
9919 ;; Select next newsgroup or exit.
9920 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9921 (eq gnus-auto-select-next 'quietly))
9922 (gnus-summary-next-group nil)
9923 (gnus-summary-exit))))
9925 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9926 "Mark all articles in this newsgroup as read, and then exit."
9928 (gnus-summary-catchup-and-exit t quietly))
9930 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9931 "Mark all articles in this group as read and select the next group.
9932 If given a prefix, mark all articles, unread as well as ticked, as
9936 (gnus-summary-catchup all))
9937 (gnus-summary-next-group))
9943 (defmacro gnus-with-article (article &rest forms)
9944 "Select ARTICLE and perform FORMS in the original article buffer.
9945 Then replace the article with the result."
9947 ;; We don't want the article to be marked as read.
9948 (let (gnus-mark-article-hook)
9949 (gnus-summary-select-article t t nil ,article))
9950 (set-buffer gnus-original-article-buffer)
9952 (if (not (gnus-check-backend-function
9953 'request-replace-article (car gnus-article-current)))
9954 (gnus-message 5 "Read-only group; not replacing")
9955 (unless (gnus-request-replace-article
9956 ,article (car gnus-article-current)
9958 (error "Couldn't replace article")))
9959 ;; The cache and backlog have to be flushed somewhat.
9960 (when gnus-keep-backlog
9961 (gnus-backlog-remove-article
9962 (car gnus-article-current) (cdr gnus-article-current)))
9963 (when gnus-use-cache
9964 (gnus-cache-update-article
9965 (car gnus-article-current) (cdr gnus-article-current)))))
9967 (put 'gnus-with-article 'lisp-indent-function 1)
9968 (put 'gnus-with-article 'edebug-form-spec '(form body))
9970 ;; Thread-based commands.
9972 (defun gnus-summary-articles-in-thread (&optional article)
9973 "Return a list of all articles in the current thread.
9974 If ARTICLE is non-nil, return all articles in the thread that starts
9976 (let* ((article (or article (gnus-summary-article-number)))
9977 (data (gnus-data-find-list article))
9978 (top-level (gnus-data-level (car data)))
9980 (cond ((null gnus-thread-operation-ignore-subject)
9981 (gnus-simplify-subject-re
9982 (mail-header-subject (gnus-data-header (car data)))))
9983 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
9984 (gnus-simplify-subject-fuzzy
9985 (mail-header-subject (gnus-data-header (car data)))))
9987 (end-point (save-excursion
9988 (if (gnus-summary-go-to-next-thread)
9989 (point) (point-max))))
9992 (< (gnus-data-pos (car data)) end-point))
9993 (when (or (not top-subject)
9994 (string= top-subject
9995 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
9996 (gnus-simplify-subject-fuzzy
9997 (mail-header-subject
9998 (gnus-data-header (car data))))
9999 (gnus-simplify-subject-re
10000 (mail-header-subject
10001 (gnus-data-header (car data)))))))
10002 (push (gnus-data-number (car data)) articles))
10003 (unless (and (setq data (cdr data))
10004 (> (gnus-data-level (car data)) top-level))
10006 ;; Return the list of articles.
10007 (nreverse articles)))
10009 (defun gnus-summary-rethread-current ()
10010 "Rethread the thread the current article is part of."
10012 (let* ((gnus-show-threads t)
10013 (article (gnus-summary-article-number))
10014 (id (mail-header-id (gnus-summary-article-header)))
10015 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10017 (error "No article on the current line"))
10018 (gnus-rebuild-thread id)
10019 (gnus-summary-goto-subject article)))
10021 (defun gnus-summary-reparent-thread ()
10022 "Make the current article child of the marked (or previous) article.
10024 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10025 is non-nil or the Subject: of both articles are the same."
10027 (unless (not (gnus-group-read-only-p))
10028 (error "The current newsgroup does not support article editing"))
10029 (unless (<= (length gnus-newsgroup-processable) 1)
10030 (error "No more than one article may be marked"))
10031 (save-window-excursion
10032 (let ((gnus-article-buffer " *reparent*")
10033 (current-article (gnus-summary-article-number))
10034 ;; First grab the marked article, otherwise one line up.
10035 (parent-article (if (not (null gnus-newsgroup-processable))
10036 (car gnus-newsgroup-processable)
10038 (if (eq (forward-line -1) 0)
10039 (gnus-summary-article-number)
10040 (error "Beginning of summary buffer"))))))
10041 (unless (not (eq current-article parent-article))
10042 (error "An article may not be self-referential"))
10043 (let ((message-id (mail-header-id
10044 (gnus-summary-article-header parent-article))))
10045 (unless (and message-id (not (equal message-id "")))
10046 (error "No message-id in desired parent"))
10047 (gnus-with-article current-article
10049 (goto-char (point-min))
10050 (message-narrow-to-head)
10051 (if (re-search-forward "^References: " nil t)
10053 (re-search-forward "^[^ \t]" nil t)
10056 (insert " " message-id))
10057 (insert "References: " message-id "\n"))))
10058 (set-buffer gnus-summary-buffer)
10059 (gnus-summary-unmark-all-processable)
10060 (gnus-summary-update-article current-article)
10061 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10062 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10063 (gnus-summary-rethread-current)
10064 (gnus-message 3 "Article %d is now the child of article %d"
10065 current-article parent-article)))))
10067 (defun gnus-summary-toggle-threads (&optional arg)
10068 "Toggle showing conversation threads.
10069 If ARG is positive number, turn showing conversation threads on."
10071 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10072 (setq gnus-show-threads
10073 (if (null arg) (not gnus-show-threads)
10074 (> (prefix-numeric-value arg) 0)))
10075 (gnus-summary-prepare)
10076 (gnus-summary-goto-subject current)
10077 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10078 (gnus-summary-position-point)))
10080 (defun gnus-summary-show-all-threads ()
10081 "Show all threads."
10084 (let ((buffer-read-only nil))
10085 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10086 (gnus-summary-position-point))
10088 (defun gnus-summary-show-thread ()
10089 "Show thread subtrees.
10090 Returns nil if no thread was there to be shown."
10092 (let ((buffer-read-only nil)
10094 ;; first goto end then to beg, to have point at beg after let
10095 (end (progn (end-of-line) (point)))
10096 (beg (progn (beginning-of-line) (point))))
10098 ;; Any hidden lines here?
10099 (search-forward "\r" end t)
10100 (subst-char-in-region beg end ?\^M ?\n t)
10102 (gnus-summary-position-point))))
10104 (defun gnus-summary-maybe-hide-threads ()
10105 "If requested, hide the threads that should be hidden."
10106 (when (and gnus-show-threads
10107 gnus-thread-hide-subtree)
10108 (gnus-summary-hide-all-threads
10109 (if (or (consp gnus-thread-hide-subtree)
10110 (gnus-functionp gnus-thread-hide-subtree))
10111 (gnus-make-predicate gnus-thread-hide-subtree)
10114 ;;; Hiding predicates.
10116 (defun gnus-article-unread-p (header)
10117 (memq (mail-header-number header) gnus-newsgroup-unreads))
10119 (defun gnus-article-unseen-p (header)
10120 (memq (mail-header-number header) gnus-newsgroup-unseen))
10122 (defun gnus-map-articles (predicate articles)
10123 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10124 (apply 'gnus-or (mapcar predicate
10125 (mapcar 'gnus-summary-article-header articles))))
10127 (defun gnus-summary-hide-all-threads (&optional predicate)
10128 "Hide all thread subtrees.
10129 If PREDICATE is supplied, threads that satisfy this predicate
10130 will not be hidden."
10133 (goto-char (point-min))
10136 (when (or (not predicate)
10138 predicate (gnus-summary-article-children)))
10139 (gnus-summary-hide-thread))
10140 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10141 (gnus-summary-position-point))
10143 (defun gnus-summary-hide-thread ()
10144 "Hide thread subtrees.
10145 If PREDICATE is supplied, threads that satisfy this predicate
10146 will not be hidden.
10147 Returns nil if no threads were there to be hidden."
10149 (let ((buffer-read-only nil)
10151 (article (gnus-summary-article-number)))
10153 ;; Go forward until either the buffer ends or the subthread
10155 (when (and (not (eobp))
10156 (or (zerop (gnus-summary-next-thread 1 t))
10157 (goto-char (point-max))))
10159 (if (and (> (point) start)
10160 (search-backward "\n" start t))
10162 (subst-char-in-region start (point) ?\n ?\^M)
10163 (gnus-summary-goto-subject article))
10167 (defun gnus-summary-go-to-next-thread (&optional previous)
10168 "Go to the same level (or less) next thread.
10169 If PREVIOUS is non-nil, go to previous thread instead.
10170 Return the article number moved to, or nil if moving was impossible."
10171 (let ((level (gnus-summary-thread-level))
10172 (way (if previous -1 1))
10175 (while (and (not (eobp))
10176 (< level (gnus-summary-thread-level)))
10177 (forward-line way))
10184 (gnus-summary-article-number)
10185 (goto-char beg)))))
10187 (defun gnus-summary-next-thread (n &optional silent)
10188 "Go to the same level next N'th thread.
10189 If N is negative, search backward instead.
10190 Returns the difference between N and the number of skips actually
10193 If SILENT, don't output messages."
10195 (let ((backward (< n 0))
10197 (while (and (> n 0)
10198 (gnus-summary-go-to-next-thread backward))
10201 (gnus-summary-position-point))
10202 (when (and (not silent) (/= 0 n))
10203 (gnus-message 7 "No more threads"))
10206 (defun gnus-summary-prev-thread (n)
10207 "Go to the same level previous N'th thread.
10208 Returns the difference between N and the number of skips actually
10211 (gnus-summary-next-thread (- n)))
10213 (defun gnus-summary-go-down-thread ()
10214 "Go down one level in the current thread."
10215 (let ((children (gnus-summary-article-children)))
10217 (gnus-summary-goto-subject (car children)))))
10219 (defun gnus-summary-go-up-thread ()
10220 "Go up one level in the current thread."
10221 (let ((parent (gnus-summary-article-parent)))
10223 (gnus-summary-goto-subject parent))))
10225 (defun gnus-summary-down-thread (n)
10226 "Go down thread N steps.
10227 If N is negative, go up instead.
10228 Returns the difference between N and how many steps down that were
10233 (while (and (> n 0)
10234 (if up (gnus-summary-go-up-thread)
10235 (gnus-summary-go-down-thread)))
10237 (gnus-summary-position-point)
10239 (gnus-message 7 "Can't go further"))
10242 (defun gnus-summary-up-thread (n)
10243 "Go up thread N steps.
10244 If N is negative, go down instead.
10245 Returns the difference between N and how many steps down that were
10248 (gnus-summary-down-thread (- n)))
10250 (defun gnus-summary-top-thread ()
10251 "Go to the top of the thread."
10253 (while (gnus-summary-go-up-thread))
10254 (gnus-summary-article-number))
10256 (defun gnus-summary-kill-thread (&optional unmark)
10257 "Mark articles under current thread as read.
10258 If the prefix argument is positive, remove any kinds of marks.
10259 If the prefix argument is negative, tick articles instead."
10262 (setq unmark (prefix-numeric-value unmark)))
10263 (let ((articles (gnus-summary-articles-in-thread)))
10265 ;; Expand the thread.
10266 (gnus-summary-show-thread)
10267 ;; Mark all the articles.
10269 (gnus-summary-goto-subject (car articles))
10270 (cond ((null unmark)
10271 (gnus-summary-mark-article-as-read gnus-killed-mark))
10273 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10275 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10276 (setq articles (cdr articles))))
10277 ;; Hide killed subtrees.
10279 gnus-thread-hide-killed
10280 (gnus-summary-hide-thread))
10281 ;; If marked as read, go to next unread subject.
10282 (when (null unmark)
10283 ;; Go to next unread subject.
10284 (gnus-summary-next-subject 1 t)))
10285 (gnus-set-mode-line 'summary))
10287 ;; Summary sorting commands
10289 (defun gnus-summary-sort-by-number (&optional reverse)
10290 "Sort the summary buffer by article number.
10291 Argument REVERSE means reverse order."
10293 (gnus-summary-sort 'number reverse))
10295 (defun gnus-summary-sort-by-random (&optional reverse)
10296 "Randomize the order in the summary buffer.
10297 Argument REVERSE means to randomize in reverse order."
10299 (gnus-summary-sort 'random reverse))
10301 (defun gnus-summary-sort-by-author (&optional reverse)
10302 "Sort the summary buffer by author name alphabetically.
10303 If `case-fold-search' is non-nil, case of letters is ignored.
10304 Argument REVERSE means reverse order."
10306 (gnus-summary-sort 'author reverse))
10308 (defun gnus-summary-sort-by-subject (&optional reverse)
10309 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10310 If `case-fold-search' is non-nil, case of letters is ignored.
10311 Argument REVERSE means reverse order."
10313 (gnus-summary-sort 'subject reverse))
10315 (defun gnus-summary-sort-by-date (&optional reverse)
10316 "Sort the summary buffer by date.
10317 Argument REVERSE means reverse order."
10319 (gnus-summary-sort 'date reverse))
10321 (defun gnus-summary-sort-by-score (&optional reverse)
10322 "Sort the summary buffer by score.
10323 Argument REVERSE means reverse order."
10325 (gnus-summary-sort 'score reverse))
10327 (defun gnus-summary-sort-by-lines (&optional reverse)
10328 "Sort the summary buffer by the number of lines.
10329 Argument REVERSE means reverse order."
10331 (gnus-summary-sort 'lines reverse))
10333 (defun gnus-summary-sort-by-chars (&optional reverse)
10334 "Sort the summary buffer by article length.
10335 Argument REVERSE means reverse order."
10337 (gnus-summary-sort 'chars reverse))
10339 (defun gnus-summary-sort-by-original (&optional reverse)
10340 "Sort the summary buffer using the default sorting method.
10341 Argument REVERSE means reverse order."
10343 (let* ((buffer-read-only)
10344 (gnus-summary-prepare-hook nil))
10345 ;; We do the sorting by regenerating the threads.
10346 (gnus-summary-prepare)
10347 ;; Hide subthreads if needed.
10348 (gnus-summary-maybe-hide-threads)))
10350 (defun gnus-summary-sort (predicate reverse)
10351 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10352 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10353 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10354 (gnus-thread-sort-functions
10359 (gnus-sort-gathered-threads-function
10360 gnus-thread-sort-functions)
10361 (gnus-article-sort-functions
10365 (,article t2 t1))))
10367 (gnus-summary-prepare-hook nil))
10368 ;; We do the sorting by regenerating the threads.
10369 (gnus-summary-prepare)
10370 ;; Hide subthreads if needed.
10371 (gnus-summary-maybe-hide-threads)))
10373 ;; Summary saving commands.
10375 (defun gnus-summary-save-article (&optional n not-saved)
10376 "Save the current article using the default saver function.
10377 If N is a positive number, save the N next articles.
10378 If N is a negative number, save the N previous articles.
10379 If N is nil and any articles have been marked with the process mark,
10380 save those articles instead.
10381 The variable `gnus-default-article-saver' specifies the saver function."
10383 (let* ((articles (gnus-summary-work-articles n))
10384 (save-buffer (save-excursion
10385 (nnheader-set-temp-buffer " *Gnus Save*")))
10386 (num (length articles))
10388 (dolist (article articles)
10389 (setq header (gnus-summary-article-header article))
10390 (if (not (vectorp header))
10391 ;; This is a pseudo-article.
10392 (if (assq 'name header)
10393 (gnus-copy-file (cdr (assq 'name header)))
10394 (gnus-message 1 "Article %d is unsaveable" article))
10395 ;; This is a real article.
10396 (save-window-excursion
10397 (let ((gnus-display-mime-function nil)
10398 (gnus-article-prepare-hook nil))
10399 (gnus-summary-select-article t nil nil article)))
10401 (set-buffer save-buffer)
10403 (insert-buffer-substring gnus-original-article-buffer))
10404 (setq file (gnus-article-save save-buffer file num))
10405 (gnus-summary-remove-process-mark article)
10407 (gnus-summary-set-saved-mark article))))
10408 (gnus-kill-buffer save-buffer)
10409 (gnus-summary-position-point)
10410 (gnus-set-mode-line 'summary)
10413 (defun gnus-summary-pipe-output (&optional arg)
10414 "Pipe the current article to a subprocess.
10415 If N is a positive number, pipe the N next articles.
10416 If N is a negative number, pipe the N previous articles.
10417 If N is nil and any articles have been marked with the process mark,
10418 pipe those articles instead."
10420 (require 'gnus-art)
10421 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10422 (gnus-summary-save-article arg t))
10423 (let ((buffer (get-buffer "*Shell Command Output*")))
10425 (with-current-buffer buffer (> (point-max) (point-min))))
10426 (gnus-configure-windows 'pipe))))
10428 (defun gnus-summary-save-article-mail (&optional arg)
10429 "Append the current article to an mail file.
10430 If N is a positive number, save the N next articles.
10431 If N is a negative number, save the N previous articles.
10432 If N is nil and any articles have been marked with the process mark,
10433 save those articles instead."
10435 (require 'gnus-art)
10436 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10437 (gnus-summary-save-article arg)))
10439 (defun gnus-summary-save-article-rmail (&optional arg)
10440 "Append the current article to an rmail file.
10441 If N is a positive number, save the N next articles.
10442 If N is a negative number, save the N previous articles.
10443 If N is nil and any articles have been marked with the process mark,
10444 save those articles instead."
10446 (require 'gnus-art)
10447 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10448 (gnus-summary-save-article arg)))
10450 (defun gnus-summary-save-article-file (&optional arg)
10451 "Append the current article to a file.
10452 If N is a positive number, save the N next articles.
10453 If N is a negative number, save the N previous articles.
10454 If N is nil and any articles have been marked with the process mark,
10455 save those articles instead."
10457 (require 'gnus-art)
10458 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10459 (gnus-summary-save-article arg)))
10461 (defun gnus-summary-write-article-file (&optional arg)
10462 "Write the current article to a file, deleting the previous file.
10463 If N is a positive number, save the N next articles.
10464 If N is a negative number, save the N previous articles.
10465 If N is nil and any articles have been marked with the process mark,
10466 save those articles instead."
10468 (require 'gnus-art)
10469 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10470 (gnus-summary-save-article arg)))
10472 (defun gnus-summary-save-article-body-file (&optional arg)
10473 "Append the current article body to a file.
10474 If N is a positive number, save the N next articles.
10475 If N is a negative number, save the N previous articles.
10476 If N is nil and any articles have been marked with the process mark,
10477 save those articles instead."
10479 (require 'gnus-art)
10480 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10481 (gnus-summary-save-article arg)))
10483 (defun gnus-summary-muttprint (&optional arg)
10484 "Print the current article using Muttprint.
10485 If N is a positive number, save the N next articles.
10486 If N is a negative number, save the N previous articles.
10487 If N is nil and any articles have been marked with the process mark,
10488 save those articles instead."
10490 (require 'gnus-art)
10491 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10492 (gnus-summary-save-article arg t)))
10494 (defun gnus-summary-pipe-message (program)
10495 "Pipe the current article through PROGRAM."
10496 (interactive "sProgram: ")
10497 (gnus-summary-select-article)
10498 (let ((mail-header-separator ""))
10499 (gnus-eval-in-buffer-window gnus-article-buffer
10502 (let ((start (window-start))
10504 (message-pipe-buffer-body program)
10505 (set-window-start (get-buffer-window (current-buffer)) start))))))
10507 (defun gnus-get-split-value (methods)
10508 "Return a value based on the split METHODS."
10509 (let (split-name method result match)
10512 (set-buffer gnus-original-article-buffer)
10514 (nnheader-narrow-to-headers)
10515 (while (and methods (not split-name))
10516 (goto-char (point-min))
10517 (setq method (pop methods))
10518 (setq match (car method))
10521 ;; Regular expression.
10523 (re-search-forward match nil t)))
10524 ((gnus-functionp match)
10528 (setq result (funcall match gnus-newsgroup-name))))
10533 (setq result (eval match)))))
10534 (setq split-name (cdr method))
10535 (cond ((stringp result)
10536 (push (expand-file-name
10537 result gnus-article-save-directory)
10540 (setq split-name (append result split-name)))))))))
10541 (nreverse split-name)))
10543 (defun gnus-valid-move-group-p (group)
10544 (and (boundp group)
10545 (symbol-name group)
10546 (symbol-value group)
10547 (gnus-get-function (gnus-find-method-for-group
10548 (symbol-name group)) 'request-accept-article t)))
10550 (defun gnus-read-move-group-name (prompt default articles prefix)
10551 "Read a group name."
10552 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10553 (minibuffer-confirm-incomplete nil) ; XEmacs
10555 (format "%s %s to:"
10557 (if (> (length articles) 1)
10558 (format "these %d articles" (length articles))
10563 (gnus-completing-read-with-default
10566 'gnus-valid-move-group-p
10568 'gnus-group-history))
10569 ((= 1 (length split-name))
10570 (gnus-completing-read-with-default
10571 (car split-name) prom
10573 'gnus-valid-move-group-p
10575 'gnus-group-history))
10577 (gnus-completing-read-with-default
10579 (mapcar (lambda (el) (list el))
10580 (nreverse split-name))
10582 'gnus-group-history))))
10583 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10585 (if (or (string= to-newsgroup "")
10586 (string= to-newsgroup prefix))
10587 (setq to-newsgroup default))
10588 (unless to-newsgroup
10589 (error "No group name entered"))
10590 (or (gnus-active to-newsgroup)
10591 (gnus-activate-group to-newsgroup nil nil to-method)
10592 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10594 (or (and (gnus-request-create-group to-newsgroup to-method)
10595 (gnus-activate-group
10596 to-newsgroup nil nil to-method)
10597 (gnus-subscribe-group to-newsgroup))
10598 (error "Couldn't create group %s" to-newsgroup)))
10599 (error "No such group: %s" to-newsgroup)))
10602 (defun gnus-summary-save-parts (type dir n &optional reverse)
10603 "Save parts matching TYPE to DIR.
10604 If REVERSE, save parts that do not match TYPE."
10606 (list (read-string "Save parts of type: "
10607 (or (car gnus-summary-save-parts-type-history)
10608 gnus-summary-save-parts-default-mime)
10609 'gnus-summary-save-parts-type-history)
10610 (setq gnus-summary-save-parts-last-directory
10611 (read-file-name "Save to directory: "
10612 gnus-summary-save-parts-last-directory
10614 current-prefix-arg))
10615 (gnus-summary-iterate n
10616 (let ((gnus-display-mime-function nil)
10617 (gnus-inhibit-treatment t))
10618 (gnus-summary-select-article))
10620 (set-buffer gnus-article-buffer)
10621 (let ((handles (or gnus-article-mime-handles
10622 (mm-dissect-buffer nil gnus-article-loose-mime)
10625 (gnus-summary-save-parts-1 type dir handles reverse)
10626 (unless gnus-article-mime-handles ;; Don't destroy this case.
10627 (mm-destroy-parts handles)))))))
10629 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10630 (if (stringp (car handle))
10631 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10634 (not (string-match type (mm-handle-media-type handle)))
10635 (string-match type (mm-handle-media-type handle)))
10636 (let ((file (expand-file-name
10637 (file-name-nondirectory
10639 (mail-content-type-get
10640 (mm-handle-disposition handle) 'filename)
10641 (concat gnus-newsgroup-name
10642 "." (number-to-string
10643 (cdr gnus-article-current)))))
10645 (unless (file-exists-p file)
10646 (mm-save-part-to-file handle file))))))
10648 ;; Summary extract commands
10650 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10651 (let ((buffer-read-only nil)
10652 (article (gnus-summary-article-number))
10654 (unless (gnus-summary-goto-subject article)
10655 (error "No such article: %d" article))
10656 (gnus-summary-position-point)
10657 ;; If all commands are to be bunched up on one line, we collect
10659 (unless gnus-view-pseudos-separately
10660 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10663 (setq action (cdr (assq 'action (car ps))))
10664 (setq files (list (cdr (assq 'name (car ps)))))
10665 (while (and ps (cdr ps)
10666 (string= (or action "1")
10667 (or (cdr (assq 'action (cadr ps))) "2")))
10668 (push (cdr (assq 'name (cadr ps))) files)
10669 (setcdr ps (cddr ps)))
10671 (when (not (string-match "%s" action))
10674 (when (assq 'execute (car ps))
10675 (setcdr (assq 'execute (car ps))
10676 (funcall (if (string-match "%s" action)
10683 (gnus-quote-arg-for-sh-or-csh f)))
10685 (setq ps (cdr ps)))))
10686 (if (and gnus-view-pseudos (not not-view))
10688 (when (assq 'execute (car pslist))
10689 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10690 (eq gnus-view-pseudos 'not-confirm)))
10691 (setq pslist (cdr pslist)))
10694 (setq after-article (or (cdr (assq 'article (car pslist)))
10695 (gnus-summary-article-number)))
10696 (gnus-summary-goto-subject after-article)
10699 (insert " " (file-name-nondirectory
10700 (cdr (assq 'name (car pslist))))
10701 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10703 (forward-line -1) ; back to `b'
10704 (gnus-add-text-properties
10705 b (1- e) (list 'gnus-number gnus-reffed-article-number
10706 gnus-mouse-face-prop gnus-mouse-face))
10708 after-article gnus-reffed-article-number
10709 gnus-unread-mark b (car pslist) 0 (- e b))
10710 (setq gnus-newsgroup-unreads
10711 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10712 gnus-reffed-article-number))
10713 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10714 (setq pslist (cdr pslist)))))))
10716 (defun gnus-pseudos< (p1 p2)
10717 (let ((c1 (cdr (assq 'action p1)))
10718 (c2 (cdr (assq 'action p2))))
10719 (and c1 c2 (string< c1 c2))))
10721 (defun gnus-request-pseudo-article (props)
10722 (cond ((assq 'execute props)
10723 (gnus-execute-command (cdr (assq 'execute props)))))
10724 (let ((gnus-current-article (gnus-summary-article-number)))
10725 (gnus-run-hooks 'gnus-mark-article-hook)))
10727 (defun gnus-execute-command (command &optional automatic)
10729 (gnus-article-setup-buffer)
10730 (set-buffer gnus-article-buffer)
10731 (setq buffer-read-only nil)
10732 (let ((command (if automatic command
10733 (read-string "Command: " (cons command 0)))))
10735 (insert "$ " command "\n\n")
10736 (if gnus-view-pseudo-asynchronously
10737 (start-process "gnus-execute" (current-buffer) shell-file-name
10738 shell-command-switch command)
10739 (call-process shell-file-name nil t nil
10740 shell-command-switch command)))))
10742 ;; Summary kill commands.
10744 (defun gnus-summary-edit-global-kill (article)
10745 "Edit the \"global\" kill file."
10746 (interactive (list (gnus-summary-article-number)))
10747 (gnus-group-edit-global-kill article))
10749 (defun gnus-summary-edit-local-kill ()
10750 "Edit a local kill file applied to the current newsgroup."
10752 (setq gnus-current-headers (gnus-summary-article-header))
10753 (gnus-group-edit-local-kill
10754 (gnus-summary-article-number) gnus-newsgroup-name))
10756 ;;; Header reading.
10758 (defun gnus-read-header (id &optional header)
10759 "Read the headers of article ID and enter them into the Gnus system."
10760 (let ((group gnus-newsgroup-name)
10761 (gnus-override-method
10763 gnus-override-method
10764 (and (gnus-news-group-p gnus-newsgroup-name)
10765 (car (gnus-refer-article-methods)))))
10767 ;; First we check to see whether the header in question is already
10770 ;; This is a Message-ID.
10771 (setq header (or header (gnus-id-to-header id)))
10772 ;; This is an article number.
10773 (setq header (or header (gnus-summary-article-header id))))
10775 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10776 ;; We have found the header.
10778 ;; If this is a sparse article, we have to nix out its
10779 ;; previous entry in the thread hashtb.
10781 (gnus-summary-article-sparse-p (mail-header-number header)))
10782 (let* ((parent (gnus-parent-id (mail-header-references header)))
10783 (thread (and parent (gnus-id-to-thread parent))))
10785 (delq (assq header thread) thread))))
10786 ;; We have to really fetch the header to this article.
10788 (set-buffer nntp-server-buffer)
10789 (when (setq where (gnus-request-head id group))
10790 (nnheader-fold-continuation-lines)
10791 (goto-char (point-max))
10793 (goto-char (point-min))
10797 ((cdr where) (cdr where))
10798 (header (mail-header-number header))
10799 (t gnus-reffed-article-number))
10801 (insert " Article retrieved.\n"))
10802 (if (or (not where)
10803 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10804 () ; Malformed head.
10805 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10806 (when (and (stringp id)
10807 (not (string= (gnus-group-real-name group)
10809 ;; If we fetched by Message-ID and the article came
10810 ;; from a different group, we fudge some bogus article
10811 ;; numbers for this article.
10812 (mail-header-set-number header gnus-reffed-article-number))
10814 (set-buffer gnus-summary-buffer)
10815 (decf gnus-reffed-article-number)
10816 (gnus-remove-header (mail-header-number header))
10817 (push header gnus-newsgroup-headers)
10818 (setq gnus-current-headers header)
10819 (push (mail-header-number header) gnus-newsgroup-limit)))
10822 (defun gnus-remove-header (number)
10823 "Remove header NUMBER from `gnus-newsgroup-headers'."
10824 (if (and gnus-newsgroup-headers
10825 (= number (mail-header-number (car gnus-newsgroup-headers))))
10826 (pop gnus-newsgroup-headers)
10827 (let ((headers gnus-newsgroup-headers))
10828 (while (and (cdr headers)
10829 (not (= number (mail-header-number (cadr headers)))))
10831 (when (cdr headers)
10832 (setcdr headers (cddr headers))))))
10835 ;;; summary highlights
10838 (defun gnus-highlight-selected-summary ()
10839 "Highlight selected article in summary buffer."
10840 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10841 (when gnus-summary-selected-face
10843 (let* ((beg (progn (beginning-of-line) (point)))
10844 (end (progn (end-of-line) (point)))
10845 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10846 (from (if (get-text-property beg gnus-mouse-face-prop)
10848 (or (next-single-property-change
10849 beg gnus-mouse-face-prop nil end)
10854 (or (next-single-property-change
10855 from gnus-mouse-face-prop nil end)
10857 ;; If no mouse-face prop on line we will have to = from = end,
10858 ;; so we highlight the entire line instead.
10859 (when (= (+ to 2) from)
10862 (if gnus-newsgroup-selected-overlay
10863 ;; Move old overlay.
10865 gnus-newsgroup-selected-overlay from to (current-buffer))
10866 ;; Create new overlay.
10868 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10869 'face gnus-summary-selected-face))))))
10871 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10872 (defun gnus-summary-highlight-line ()
10873 "Highlight current line according to `gnus-summary-highlight'."
10874 (let* ((list gnus-summary-highlight)
10875 (beg (gnus-point-at-bol))
10876 (article (gnus-summary-article-number))
10877 (score (or (cdr (assq (or article gnus-current-article)
10878 gnus-newsgroup-scored))
10879 gnus-summary-default-score 0))
10880 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10881 (inhibit-read-only t)
10882 (default gnus-summary-default-score)
10883 (default-high gnus-summary-default-high-score)
10884 (default-low gnus-summary-default-low-score))
10885 ;; Eval the cars of the lists until we find a match.
10887 (not (eval (caar list))))
10888 (setq list (cdr list)))
10889 (let ((face (cdar list)))
10890 (unless (eq face (get-text-property beg 'face))
10891 (gnus-put-text-property-excluding-characters-with-faces
10892 beg (gnus-point-at-eol) 'face
10893 (setq face (if (boundp face) (symbol-value face) face)))
10894 (when gnus-summary-highlight-line-function
10895 (funcall gnus-summary-highlight-line-function article face))))))
10897 (defun gnus-update-read-articles (group unread &optional compute)
10898 "Update the list of read articles in GROUP.
10899 UNREAD is a sorted list."
10900 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10901 (entry (gnus-gethash group gnus-newsrc-hashtb))
10902 (info (nth 2 entry))
10905 (if (or (not info) (not active))
10906 ;; There is no info on this group if it was, in fact,
10907 ;; killed. Gnus stores no information on killed groups, so
10908 ;; there's nothing to be done.
10909 ;; One could store the information somewhere temporarily,
10910 ;; perhaps... Hmmm...
10912 ;; Remove any negative articles numbers.
10913 (while (and unread (< (car unread) 0))
10914 (setq unread (cdr unread)))
10915 ;; Remove any expired article numbers
10916 (while (and unread (< (car unread) (car active)))
10917 (setq unread (cdr unread)))
10918 ;; Compute the ranges of read articles by looking at the list of
10919 ;; unread articles.
10921 (when (/= (car unread) prev)
10922 (push (if (= prev (1- (car unread))) prev
10923 (cons prev (1- (car unread))))
10925 (setq prev (1+ (car unread)))
10926 (setq unread (cdr unread)))
10927 (when (<= prev (cdr active))
10928 (push (cons prev (cdr active)) read))
10929 (setq read (if (> (length read) 1) (nreverse read) read))
10934 ;; Propagate the read marks to the backend.
10935 (when (gnus-check-backend-function 'request-set-mark group)
10936 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10937 (add (gnus-remove-from-range read (gnus-info-read info))))
10939 (unless (gnus-check-group group)
10940 (error "Can't open server for %s" group))
10941 (gnus-request-set-mark
10942 group (delq nil (list (if add (list add 'add '(read)))
10943 (if del (list del 'del '(read))))))
10945 `(gnus-request-set-mark
10948 (if del (list del 'add '(read)))
10949 (if add (list add 'del '(read))))))))))
10950 (set-buffer gnus-group-buffer)
10951 (gnus-undo-register
10953 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10954 (gnus-info-set-read ',info ',(gnus-info-read info))
10955 (gnus-get-unread-articles-in-group ',info
10956 (gnus-active ,group))
10957 (gnus-group-update-group ,group t)
10959 ;; Enter this list into the group info.
10960 (gnus-info-set-read info read)
10961 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10962 (gnus-get-unread-articles-in-group info (gnus-active group))
10965 (defun gnus-offer-save-summaries ()
10966 "Offer to save all active summary buffers."
10968 ;; Go through all buffers and find all summaries.
10969 (dolist (buffer (buffer-list))
10970 (when (and (setq buffer (buffer-name buffer))
10971 (string-match "Summary" buffer)
10973 (set-buffer buffer)
10974 ;; We check that this is, indeed, a summary buffer.
10975 (and (eq major-mode 'gnus-summary-mode)
10976 ;; Also make sure this isn't bogus.
10977 gnus-newsgroup-prepared
10978 ;; Also make sure that this isn't a
10979 ;; dead summary buffer.
10980 (not gnus-dead-summary-mode))))
10981 (push buffer buffers)))
10982 ;; Go through all these summary buffers and offer to save them.
10986 "Update summary buffer %s? "
10988 (switch-to-buffer buf)
10989 (gnus-summary-exit))
10993 ;;; @ for mime-partial
10996 (defun gnus-request-partial-message ()
10998 (let ((number (gnus-summary-article-number))
10999 (group gnus-newsgroup-name)
11000 (mother gnus-article-buffer))
11001 (set-buffer (get-buffer-create " *Partial Article*"))
11003 (setq mime-preview-buffer mother)
11004 (gnus-request-article-this-buffer number group)
11005 (mime-parse-buffer)
11008 (autoload 'mime-combine-message/partial-pieces-automatically
11010 "Internal method to combine message/partial messages automatically.")
11012 (mime-add-condition
11013 'action '((type . message)(subtype . partial)
11014 (major-mode . gnus-original-article-mode)
11015 (method . mime-combine-message/partial-pieces-automatically)
11016 (summary-buffer-exp . gnus-summary-buffer)
11017 (request-partial-message-method . gnus-request-partial-message)
11021 ;;; @ for message/rfc822
11024 (defun gnus-mime-extract-message/rfc822 (entity situation)
11025 "Burst a forwarded article."
11027 (set-buffer gnus-summary-buffer)
11028 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11029 gnus-newsgroup-name 'gnus-group-history))
11030 (gnus-group-marked (list group))
11033 (mime-insert-entity-content entity)
11034 (setq article (gnus-request-accept-article group)))
11035 (when (and (consp article)
11036 (numberp (setq article (cdr article))))
11037 (setq info (gnus-get-info group))
11038 (gnus-info-set-read info
11039 (gnus-remove-from-range (gnus-info-read info)
11041 (when (string-equal group gnus-newsgroup-name)
11043 (let (gnus-show-threads)
11044 (gnus-summary-goto-subject article t))
11045 (gnus-summary-clear-mark-forward 1))
11046 (set-buffer gnus-group-buffer)
11047 (gnus-group-get-new-news-this-group nil t)))))
11049 (mime-add-condition
11050 'action '((type . message)(subtype . rfc822)
11051 (major-mode . gnus-original-article-mode)
11052 (method . gnus-mime-extract-message/rfc822)
11056 (mime-add-condition
11057 'action '((type . message)(subtype . news)
11058 (major-mode . gnus-original-article-mode)
11059 (method . gnus-mime-extract-message/rfc822)
11063 (defun gnus-mime-extract-multipart (entity situation)
11064 (let ((children (mime-entity-children entity))
11065 mime-acting-situation-to-override
11068 (mime-play-entity (car children)
11069 (cons (assq 'mode situation)
11070 mime-acting-situation-to-override))
11071 (setq children (cdr children)))
11072 (if (setq f (cdr (assq 'after-method
11073 mime-acting-situation-to-override)))
11077 (mime-add-condition
11078 'action '((type . multipart)
11079 (method . gnus-mime-extract-multipart)
11088 (defun gnus-summary-inherit-default-charset ()
11089 "Import `default-mime-charset' from summary buffer."
11090 (if (buffer-live-p gnus-summary-buffer)
11091 (if (local-variable-p 'default-mime-charset gnus-summary-buffer)
11093 (make-local-variable 'default-mime-charset)
11094 (setq default-mime-charset
11095 (with-current-buffer gnus-summary-buffer
11096 default-mime-charset)))
11097 (kill-local-variable 'default-mime-charset))))
11099 (defun gnus-summary-setup-default-charset ()
11100 "Setup newsgroup default charset."
11101 (if (equal gnus-newsgroup-name "nndraft:drafts")
11103 (setq gnus-newsgroup-charset nil)
11104 (make-local-variable 'default-mime-charset)
11105 (setq default-mime-charset nil))
11106 (let ((ignored-charsets
11107 (or gnus-newsgroup-ephemeral-ignored-charsets
11109 (and gnus-newsgroup-name
11110 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11111 gnus-newsgroup-ignored-charsets)))
11113 (setq gnus-newsgroup-charset
11114 (or gnus-newsgroup-ephemeral-charset
11115 (when (and gnus-newsgroup-name
11116 (setq charset (gnus-parameter-charset
11117 gnus-newsgroup-name)))
11118 (make-local-variable 'default-mime-charset)
11119 (setq default-mime-charset charset))
11120 gnus-default-charset))
11121 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11122 ignored-charsets))))
11128 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11129 "Display the current article buffer fully MIME-buttonized.
11130 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11131 treated as multipart/mixed."
11133 (require 'gnus-art)
11134 (let ((gnus-unbuttonized-mime-types nil)
11135 (gnus-mime-display-multipart-as-mixed show-all-parts))
11136 (gnus-summary-show-article)))
11138 (defun gnus-summary-repair-multipart (article)
11139 "Add a Content-Type header to a multipart article without one."
11140 (interactive (list (gnus-summary-article-number)))
11141 (gnus-with-article article
11142 (message-narrow-to-head)
11143 (message-remove-header "Mime-Version")
11144 (goto-char (point-max))
11145 (insert "Mime-Version: 1.0\n")
11147 (when (search-forward "\n--" nil t)
11148 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11149 (message-narrow-to-head)
11150 (message-remove-header "Content-Type")
11151 (goto-char (point-max))
11152 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11155 (let (gnus-mark-article-hook)
11156 (gnus-summary-select-article t t nil article)))
11158 (defun gnus-summary-toggle-display-buttonized ()
11159 "Toggle the buttonizing of the article buffer."
11161 (require 'gnus-art)
11162 (if (setq gnus-inhibit-mime-unbuttonizing
11163 (not gnus-inhibit-mime-unbuttonizing))
11164 (let ((gnus-unbuttonized-mime-types nil))
11165 (gnus-summary-show-article))
11166 (gnus-summary-show-article)))
11169 ;;; Intelli-mouse commmands
11172 (defun gnus-wheel-summary-scroll (event)
11174 (let ((amount (if (memq 'shift (event-modifiers event))
11175 (car gnus-wheel-scroll-amount)
11176 (cdr gnus-wheel-scroll-amount)))
11177 (direction (- (* (static-if (featurep 'xemacs)
11178 (event-button event)
11179 (cond ((eq 'mouse-4 (event-basic-type event))
11181 ((eq 'mouse-5 (event-basic-type event))
11185 (gnus-summary-scroll-up (* amount direction))
11186 (when (gnus-eval-in-buffer-window gnus-article-buffer
11189 (and (if (< 0 direction)
11190 (gnus-article-next-page 0)
11191 (gnus-article-prev-page 0)
11193 (if (setq edge (get-text-property
11194 (point-min) 'gnus-wheel-edge))
11195 (setq edge (* edge direction))
11198 (let ((buffer-read-only nil)
11199 (inhibit-read-only t))
11200 (put-text-property (point-min) (point-max)
11201 'gnus-wheel-edge direction)
11203 (or (> edge gnus-wheel-edge-resistance)
11204 (let ((buffer-read-only nil)
11205 (inhibit-read-only t))
11206 (put-text-property (point-min) (point-max)
11208 (* (1+ edge) direction))
11210 (eq last-command 'gnus-wheel-summary-scroll))))
11211 (gnus-summary-next-article nil nil (minusp direction)))))
11213 (defun gnus-wheel-install ()
11214 "Enable mouse wheel support on summary window."
11215 (when gnus-use-wheel
11217 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11219 (define-key gnus-summary-mode-map key
11220 'gnus-wheel-summary-scroll)))))
11222 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11225 ;;; Traditional PGP commmands
11228 (defun gnus-summary-decrypt-article (&optional force)
11229 "Decrypt the current article in traditional PGP way.
11230 This will have permanent effect only in mail groups.
11231 If FORCE is non-nil, allow editing of articles even in read-only
11234 (gnus-summary-select-article t)
11235 (gnus-eval-in-buffer-window gnus-article-buffer
11239 (goto-char (point-min))
11240 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11241 (error "Not a traditional PGP message!"))
11242 (let ((armor-start (match-beginning 0)))
11243 (if (and (pgg-decrypt-region armor-start (point-max))
11244 (or force (not (gnus-group-read-only-p))))
11245 (let ((inhibit-read-only t)
11247 (delete-region armor-start
11249 (re-search-forward "^-+END PGP" nil t)
11250 (beginning-of-line 2)
11252 (insert-buffer-substring pgg-output-buffer))))))))
11254 (defun gnus-summary-verify-article ()
11255 "Verify the current article in traditional PGP way."
11258 (set-buffer gnus-original-article-buffer)
11259 (goto-char (point-min))
11260 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11261 (error "Not a traditional PGP message!"))
11262 (re-search-forward "^-+END PGP" nil t)
11263 (beginning-of-line 2)
11264 (call-interactively (function pgg-verify-region))))
11267 ;;; Generic summary marking commands
11270 (defvar gnus-summary-marking-alist
11271 '((read gnus-del-mark "d")
11272 (unread gnus-unread-mark "u")
11273 (ticked gnus-ticked-mark "!")
11274 (dormant gnus-dormant-mark "?")
11275 (expirable gnus-expirable-mark "e"))
11276 "An alist of names/marks/keystrokes.")
11278 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11279 (defvar gnus-summary-mark-map)
11281 (defun gnus-summary-make-all-marking-commands ()
11282 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11283 (dolist (elem gnus-summary-marking-alist)
11284 (apply 'gnus-summary-make-marking-command elem)))
11286 (defun gnus-summary-make-marking-command (name mark keystroke)
11287 (let ((map (make-sparse-keymap)))
11288 (define-key gnus-summary-generic-mark-map keystroke map)
11289 (dolist (lway `((next "next" next nil "n")
11290 (next-unread "next unread" next t "N")
11291 (prev "previous" prev nil "p")
11292 (prev-unread "previous unread" prev t "P")
11293 (nomove "" nil nil ,keystroke)))
11294 (let ((func (gnus-summary-make-marking-command-1
11295 mark (car lway) lway name)))
11296 (setq func (eval func))
11297 (define-key map (nth 4 lway) func)))))
11299 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11301 (format "gnus-summary-put-mark-as-%s%s"
11302 name (if (eq way 'nomove)
11304 (concat "-" (symbol-name way)))))
11307 "Mark the current article as %s%s.
11308 If N, the prefix, then repeat N times.
11309 If N is negative, move in reverse order.
11310 The difference between N and the actual number of articles marked is
11312 name (car (cdr lway)))
11314 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11316 (defun gnus-summary-generic-mark (n mark move unread)
11317 "Mark N articles with MARK."
11318 (unless (eq major-mode 'gnus-summary-mode)
11319 (error "This command can only be used in the summary buffer"))
11320 (gnus-summary-show-thread)
11323 ((eq move 'next) 1)
11324 ((eq move 'prev) -1)
11326 (if (zerop nummove)
11330 nummove (* -1 nummove))))
11331 (while (and (> n 0)
11332 (gnus-summary-mark-article nil mark)
11333 (zerop (gnus-summary-next-subject nummove unread t)))
11336 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11337 (gnus-summary-recenter)
11338 (gnus-summary-position-point)
11339 (gnus-set-mode-line 'summary)
11342 (defun gnus-summary-insert-articles (articles)
11343 (when (setq articles
11344 (gnus-sorted-difference articles
11345 (mapcar (lambda (h)
11346 (mail-header-number h))
11347 gnus-newsgroup-headers)))
11348 (setq gnus-newsgroup-headers
11350 gnus-newsgroup-headers
11351 (gnus-fetch-headers articles)
11352 'gnus-article-sort-by-number))
11353 ;; Suppress duplicates?
11354 (when gnus-suppress-duplicates
11355 (gnus-dup-suppress-articles))
11357 ;; We might want to build some more threads first.
11358 (when (and gnus-fetch-old-headers
11359 (eq gnus-headers-retrieved-by 'nov))
11360 (if (eq gnus-fetch-old-headers 'invisible)
11361 (gnus-build-all-threads)
11362 (gnus-build-old-threads)))
11363 ;; Let the Gnus agent mark articles as read.
11365 (gnus-agent-get-undownloaded-list))
11366 ;; Remove list identifiers from subject
11367 (when gnus-list-identifiers
11368 (gnus-summary-remove-list-identifiers))
11369 ;; First and last article in this newsgroup.
11370 (when gnus-newsgroup-headers
11371 (setq gnus-newsgroup-begin
11372 (mail-header-number (car gnus-newsgroup-headers))
11374 (mail-header-number
11375 (gnus-last-element gnus-newsgroup-headers))))
11376 (when gnus-use-scoring
11377 (gnus-possibly-score-headers))))
11379 (defun gnus-summary-insert-old-articles (&optional all)
11380 "Insert all old articles in this group.
11381 If ALL is non-nil, already read articles become readable.
11382 If ALL is a number, fetch this number of articles."
11385 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11388 (gnus-sorted-difference
11389 (gnus-uncompress-range (list gnus-newsgroup-active))
11391 (setq len (length older))
11396 (setq older (last older all))))
11399 (if (and (numberp gnus-large-newsgroup)
11400 (> len gnus-large-newsgroup))
11401 (let* ((cursor-in-echo-area nil)
11402 (initial (gnus-parameter-large-newsgroup-initial
11403 gnus-newsgroup-name))
11407 "How many articles from %s (%s %d): "
11409 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11410 (if initial "max" "default")
11413 (cons (number-to-string initial)
11415 (unless (string-match "^[ \t]*$" input)
11416 (setq all (string-to-number input))
11418 (setq older (last older all))))))))
11420 (message "No old news.")
11421 (gnus-summary-insert-articles older)
11422 (gnus-summary-limit (gnus-sorted-nunion old older))))
11423 (gnus-summary-position-point)))
11425 (defun gnus-summary-insert-new-articles ()
11426 "Insert all new articles in this group."
11429 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11430 (old-active gnus-newsgroup-active)
11431 (nnmail-fetched-sources (list t))
11433 (setq gnus-newsgroup-active
11434 (gnus-activate-group gnus-newsgroup-name 'scan))
11435 (setq i (cdr gnus-newsgroup-active))
11436 (while (> i (cdr old-active))
11440 (message "No gnus is bad news.")
11441 (gnus-summary-insert-articles new)
11442 (setq gnus-newsgroup-unreads
11443 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11444 (gnus-summary-limit (gnus-sorted-nunion old new))))
11445 (gnus-summary-position-point)))
11447 (gnus-summary-make-all-marking-commands)
11449 (gnus-ems-redefine)
11451 (provide 'gnus-sum)
11453 (run-hooks 'gnus-sum-load-hook)
11455 ;;; gnus-sum.el ends here