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 "*Remove matches for this regexp 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)
896 . gnus-agent-downloaded-article-face)
897 ((and (> score default-high) (eq mark gnus-unread-mark))
898 . gnus-summary-high-unread-face)
899 ((and (< score default-low) (eq mark gnus-unread-mark))
900 . gnus-summary-low-unread-face)
901 ((eq mark gnus-unread-mark)
902 . gnus-summary-normal-unread-face)
903 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
904 gnus-undownloaded-mark)))
905 . gnus-summary-high-unread-face)
906 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
907 gnus-undownloaded-mark)))
908 . gnus-summary-low-unread-face)
909 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
910 (memq article gnus-newsgroup-unreads))
911 . gnus-summary-normal-unread-face)
912 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
913 . gnus-summary-normal-read-face)
914 ((> score default-high)
915 . gnus-summary-high-read-face)
916 ((< score default-low)
917 . gnus-summary-low-read-face)
919 . gnus-summary-normal-read-face))
920 "*Controls the highlighting of summary buffer lines.
922 A list of (FORM . FACE) pairs. When deciding how a a particular
923 summary line should be displayed, each form is evaluated. The content
924 of the face field after the first true form is used. You can change
925 how those summary lines are displayed, by editing the face field.
927 You can use the following variables in the FORM field.
929 score: The article's score
930 default: The default article score.
931 default-high: The default score for high scored articles.
932 default-low: The default score for low scored articles.
933 below: The score below which articles are automatically marked as read.
934 mark: The articles mark."
935 :group 'gnus-summary-visual
936 :type '(repeat (cons (sexp :tag "Form" nil)
939 (defcustom gnus-alter-header-function nil
940 "Function called to allow alteration of article header structures.
941 The function is called with one parameter, the article header vector,
942 which it may alter in any way.")
944 (defvar gnus-decode-encoded-word-function
945 (mime-find-field-decoder 'From 'nov)
946 "Variable that says which function should be used to decode a string with encoded words.")
948 (defcustom gnus-extra-headers '(To Newsgroups)
949 "*Extra headers to parse."
952 :type '(repeat symbol))
954 (defcustom gnus-ignored-from-addresses
955 (and user-mail-address (regexp-quote user-mail-address))
956 "*Regexp of From headers that may be suppressed in favor of To headers."
961 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
962 "List of charsets that should be ignored.
963 When these charsets are used in the \"charset\" parameter, the
964 default charset will be used instead."
966 :type '(repeat symbol)
967 :group 'gnus-charset)
969 (gnus-define-group-parameter
973 "Return the ignored charsets of GROUP."
974 :variable gnus-group-ignored-charsets-alist
976 '(("alt\\.chinese\\.text" iso-8859-1))
978 "Alist of regexps (to match group names) and charsets that should be ignored.
979 When these charsets are used in the \"charset\" parameter, the
980 default charset will be used instead."
981 :variable-group gnus-charset
982 :variable-type '(repeat (cons (regexp :tag "Group")
984 :parameter-type '(choice :tag "Ignored charsets"
987 :parameter-document "\
988 List of charsets that should be ignored.
990 When these charsets are used in the \"charset\" parameter, the
991 default charset will be used instead.")
993 (defcustom gnus-group-highlight-words-alist nil
994 "Alist of group regexps and highlight regexps.
995 This variable uses the same syntax as `gnus-emphasis-alist'."
997 :type '(repeat (cons (regexp :tag "Group")
998 (repeat (list (regexp :tag "Highlight regexp")
999 (number :tag "Group for entire word" 0)
1000 (number :tag "Group for displayed part" 0)
1002 gnus-emphasis-highlight-words)))))
1003 :group 'gnus-summary-visual)
1005 (defcustom gnus-use-wheel nil
1006 "Use Intelli-mouse on summary movement"
1008 :group 'gnus-summary-maneuvering)
1010 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1011 "Amount to scroll messages by spinning the mouse wheel.
1012 This is actually a cons cell, where the first item is the amount to scroll
1013 on a normal wheel event, and the second is the amount to scroll when the
1014 wheel is moved with the shift key depressed."
1015 :type '(cons (integer :tag "Shift") integer)
1016 :group 'gnus-summary-maneuvering)
1018 (defcustom gnus-wheel-edge-resistance 2
1019 "How hard it should be to change the current article
1020 by moving the mouse over the edge of the article window."
1022 :group 'gnus-summary-maneuvering)
1024 (defcustom gnus-summary-show-article-charset-alist
1026 "Alist of number and charset.
1027 The article will be shown with the charset corresponding to the
1029 For example: ((1 . cn-gb-2312) (2 . big5))."
1031 :type '(repeat (cons (number :tag "Argument" 1)
1032 (symbol :tag "Charset")))
1033 :group 'gnus-charset)
1035 (defcustom gnus-preserve-marks t
1036 "Whether marks are preserved when moving, copying and respooling messages."
1039 :group 'gnus-summary-marks)
1041 (defcustom gnus-alter-articles-to-read-function nil
1042 "Function to be called to alter the list of articles to be selected."
1043 :type '(choice (const nil) function)
1044 :group 'gnus-summary)
1046 (defcustom gnus-orphan-score nil
1047 "*All orphans get this score added. Set in the score file."
1048 :group 'gnus-score-default
1049 :type '(choice (const nil)
1052 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1053 "*A regexp to match MIME parts when saving multiple parts of a message
1054 with gnus-summary-save-parts (X m). This regexp will be used by default
1055 when prompting the user for which type of files to save."
1056 :group 'gnus-summary
1059 (defcustom gnus-read-all-available-headers nil
1060 "Whether Gnus should parse all headers made available to it.
1061 This is mostly relevant for slow backends where the user may
1062 wish to widen the summary buffer to include all headers
1063 that were fetched. Say, for nnultimate groups."
1064 :group 'gnus-summary
1065 :type '(choice boolean regexp))
1067 (defcustom gnus-summary-muttprint-program "muttprint"
1068 "Command (and optional arguments) used to run Muttprint."
1070 :group 'gnus-summary
1073 (defcustom gnus-article-loose-mime nil
1074 "If non-nil, don't require MIME-Version header.
1075 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1076 supply the MIME-Version header or deliberately strip it From the mail.
1077 Set it to non-nil, Gnus will treat some articles as MIME even if
1078 the MIME-Version header is missed."
1081 :group 'gnus-article)
1083 ;;; Internal variables
1085 (defvar gnus-summary-display-cache nil)
1086 (defvar gnus-article-mime-handles nil)
1087 (defvar gnus-article-decoded-p nil)
1088 (defvar gnus-article-charset nil)
1089 (defvar gnus-article-ignored-charsets nil)
1090 (defvar gnus-scores-exclude-files nil)
1091 (defvar gnus-page-broken nil)
1093 (defvar gnus-original-article nil)
1094 (defvar gnus-article-internal-prepare-hook nil)
1095 (defvar gnus-newsgroup-process-stack nil)
1097 (defvar gnus-thread-indent-array nil)
1098 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1099 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1100 "Function called to sort the articles within a thread after it has been gathered together.")
1102 (defvar gnus-summary-save-parts-type-history nil)
1103 (defvar gnus-summary-save-parts-last-directory nil)
1105 ;; Avoid highlighting in kill files.
1106 (defvar gnus-summary-inhibit-highlight nil)
1107 (defvar gnus-newsgroup-selected-overlay nil)
1108 (defvar gnus-inhibit-limiting nil)
1109 (defvar gnus-newsgroup-adaptive-score-file nil)
1110 (defvar gnus-current-score-file nil)
1111 (defvar gnus-current-move-group nil)
1112 (defvar gnus-current-copy-group nil)
1113 (defvar gnus-current-crosspost-group nil)
1114 (defvar gnus-newsgroup-display nil)
1116 (defvar gnus-newsgroup-dependencies nil)
1117 (defvar gnus-newsgroup-adaptive nil)
1118 (defvar gnus-summary-display-article-function nil)
1119 (defvar gnus-summary-highlight-line-function nil
1120 "Function called after highlighting a summary line.")
1122 (defvar gnus-summary-line-format-alist
1123 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1124 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1125 (?s gnus-tmp-subject-or-nil ?s)
1126 (?n gnus-tmp-name ?s)
1127 (?A (std11-address-string
1128 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1129 (?a (or (std11-full-name-string
1130 (car (mime-entity-read-field gnus-tmp-header 'From)))
1132 (?F gnus-tmp-from ?s)
1133 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1134 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1135 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1136 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1137 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1138 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1139 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1140 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1141 (?L gnus-tmp-lines ?s)
1142 (?I gnus-tmp-indentation ?s)
1143 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1144 (?R gnus-tmp-replied ?c)
1145 (?\[ gnus-tmp-opening-bracket ?c)
1146 (?\] gnus-tmp-closing-bracket ?c)
1147 (?\> (make-string gnus-tmp-level ? ) ?s)
1148 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1149 (?i gnus-tmp-score ?d)
1150 (?z gnus-tmp-score-char ?c)
1151 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1152 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1153 (?U gnus-tmp-unread ?c)
1154 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1156 (?t (gnus-summary-number-of-articles-in-thread
1157 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1159 (?e (gnus-summary-number-of-articles-in-thread
1160 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1162 (?u gnus-tmp-user-defined ?s)
1163 (?P (gnus-pick-line-number) ?d)
1164 (?B gnus-tmp-thread-tree-header-string ?s)
1165 (user-date (gnus-user-date
1166 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1167 "An alist of format specifications that can appear in summary lines.
1168 These are paired with what variables they correspond with, along with
1169 the type of the variable (string, integer, character, etc).")
1171 (defvar gnus-summary-dummy-line-format-alist
1172 `((?S gnus-tmp-subject ?s)
1173 (?N gnus-tmp-number ?d)
1174 (?u gnus-tmp-user-defined ?s)))
1176 (defvar gnus-summary-mode-line-format-alist
1177 `((?G gnus-tmp-group-name ?s)
1178 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1179 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1180 (?A gnus-tmp-article-number ?d)
1181 (?Z gnus-tmp-unread-and-unselected ?s)
1182 (?V gnus-version ?s)
1183 (?U gnus-tmp-unread-and-unticked ?d)
1184 (?S gnus-tmp-subject ?s)
1185 (?e gnus-tmp-unselected ?d)
1186 (?u gnus-tmp-user-defined ?s)
1187 (?d (length gnus-newsgroup-dormant) ?d)
1188 (?t (length gnus-newsgroup-marked) ?d)
1189 (?h (length gnus-newsgroup-spam-marked) ?d)
1190 (?r (length gnus-newsgroup-reads) ?d)
1191 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1192 (?E gnus-newsgroup-expunged-tally ?d)
1193 (?s (gnus-current-score-file-nondirectory) ?s)))
1195 (defvar gnus-last-search-regexp nil
1196 "Default regexp for article search command.")
1198 (defvar gnus-summary-search-article-matched-data nil
1199 "Last matched data of article search command. It is the local variable
1200 in `gnus-article-buffer' which consists of the list of start position,
1201 end position and text.")
1203 (defvar gnus-last-shell-command nil
1204 "Default shell command on article.")
1206 (defvar gnus-newsgroup-begin nil)
1207 (defvar gnus-newsgroup-end nil)
1208 (defvar gnus-newsgroup-last-rmail nil)
1209 (defvar gnus-newsgroup-last-mail nil)
1210 (defvar gnus-newsgroup-last-folder nil)
1211 (defvar gnus-newsgroup-last-file nil)
1212 (defvar gnus-newsgroup-auto-expire nil)
1213 (defvar gnus-newsgroup-active nil)
1215 (defvar gnus-newsgroup-data nil)
1216 (defvar gnus-newsgroup-data-reverse nil)
1217 (defvar gnus-newsgroup-limit nil)
1218 (defvar gnus-newsgroup-limits nil)
1220 (defvar gnus-newsgroup-unreads nil
1221 "Sorted list of unread articles in the current newsgroup.")
1223 (defvar gnus-newsgroup-unselected nil
1224 "Sorted list of unselected unread articles in the current newsgroup.")
1226 (defvar gnus-newsgroup-reads nil
1227 "Alist of read articles and article marks in the current newsgroup.")
1229 (defvar gnus-newsgroup-expunged-tally nil)
1231 (defvar gnus-newsgroup-marked nil
1232 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1234 (defvar gnus-newsgroup-spam-marked nil
1235 "List of ranges of articles that have been marked as spam.")
1237 (defvar gnus-newsgroup-killed nil
1238 "List of ranges of articles that have been through the scoring process.")
1240 (defvar gnus-newsgroup-cached nil
1241 "Sorted list of articles that come from the article cache.")
1243 (defvar gnus-newsgroup-saved nil
1244 "List of articles that have been saved.")
1246 (defvar gnus-newsgroup-kill-headers nil)
1248 (defvar gnus-newsgroup-replied nil
1249 "List of articles that have been replied to in the current newsgroup.")
1251 (defvar gnus-newsgroup-forwarded nil
1252 "List of articles that have been forwarded in the current newsgroup.")
1254 (defvar gnus-newsgroup-recent nil
1255 "List of articles that have are recent in the current newsgroup.")
1257 (defvar gnus-newsgroup-expirable nil
1258 "Sorted list of articles in the current newsgroup that can be expired.")
1260 (defvar gnus-newsgroup-processable nil
1261 "List of articles in the current newsgroup that can be processed.")
1263 (defvar gnus-newsgroup-downloadable nil
1264 "Sorted list of articles in the current newsgroup that can be processed.")
1266 (defvar gnus-newsgroup-undownloaded nil
1267 "List of articles in the current newsgroup that haven't been downloaded..")
1269 (defvar gnus-newsgroup-unsendable nil
1270 "List of articles in the current newsgroup that won't be sent.")
1272 (defvar gnus-newsgroup-bookmarks nil
1273 "List of articles in the current newsgroup that have bookmarks.")
1275 (defvar gnus-newsgroup-dormant nil
1276 "Sorted list of dormant articles in the current newsgroup.")
1278 (defvar gnus-newsgroup-unseen nil
1279 "List of unseen articles in the current newsgroup.")
1281 (defvar gnus-newsgroup-seen nil
1282 "Range of seen articles in the current newsgroup.")
1284 (defvar gnus-newsgroup-articles nil
1285 "List of articles in the current newsgroup.")
1287 (defvar gnus-newsgroup-scored nil
1288 "List of scored articles in the current newsgroup.")
1290 (defvar gnus-newsgroup-incorporated nil
1291 "List of incorporated articles in the current newsgroup.")
1293 (defvar gnus-newsgroup-headers nil
1294 "List of article headers in the current newsgroup.")
1296 (defvar gnus-newsgroup-threads nil)
1298 (defvar gnus-newsgroup-prepared nil
1299 "Whether the current group has been prepared properly.")
1301 (defvar gnus-newsgroup-ancient nil
1302 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1304 (defvar gnus-newsgroup-sparse nil)
1306 (defvar gnus-current-article nil)
1307 (defvar gnus-article-current nil)
1308 (defvar gnus-current-headers nil)
1309 (defvar gnus-have-all-headers nil)
1310 (defvar gnus-last-article nil)
1311 (defvar gnus-newsgroup-history nil)
1312 (defvar gnus-newsgroup-charset nil)
1313 (defvar gnus-newsgroup-ephemeral-charset nil)
1314 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1316 (defvar gnus-article-before-search nil)
1318 (defconst gnus-summary-local-variables
1319 '(gnus-newsgroup-name
1320 gnus-newsgroup-begin gnus-newsgroup-end
1321 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1322 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1323 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1324 gnus-newsgroup-unselected gnus-newsgroup-marked
1325 gnus-newsgroup-spam-marked
1326 gnus-newsgroup-reads gnus-newsgroup-saved
1327 gnus-newsgroup-replied gnus-newsgroup-forwarded
1328 gnus-newsgroup-recent
1329 gnus-newsgroup-expirable
1330 gnus-newsgroup-processable gnus-newsgroup-killed
1331 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1332 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1333 gnus-newsgroup-seen gnus-newsgroup-articles
1334 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1335 gnus-newsgroup-headers gnus-newsgroup-threads
1336 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1337 gnus-current-article gnus-current-headers gnus-have-all-headers
1338 gnus-last-article gnus-article-internal-prepare-hook
1339 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1340 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1341 gnus-thread-expunge-below
1342 gnus-score-alist gnus-current-score-file
1343 (gnus-summary-expunge-below . global)
1344 (gnus-summary-mark-below . global)
1345 (gnus-orphan-score . global)
1346 gnus-newsgroup-active gnus-scores-exclude-files
1347 gnus-newsgroup-history gnus-newsgroup-ancient
1348 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1349 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1350 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1351 (gnus-newsgroup-expunged-tally . 0)
1352 gnus-cache-removable-articles gnus-newsgroup-cached
1353 gnus-newsgroup-data gnus-newsgroup-data-reverse
1354 gnus-newsgroup-limit gnus-newsgroup-limits
1355 gnus-newsgroup-charset gnus-newsgroup-display
1356 gnus-newsgroup-incorporated)
1357 "Variables that are buffer-local to the summary buffers.")
1359 (defvar gnus-newsgroup-variables nil
1360 "A list of variables that have separate values in different newsgroups.
1361 A list of newsgroup (summary buffer) local variables, or cons of
1362 variables and their default values (when the default values are not
1363 nil), that should be made global while the summary buffer is active.
1364 These variables can be used to set variables in the group parameters
1365 while still allowing them to affect operations done in other
1366 buffers. For example:
1368 \(setq gnus-newsgroup-variables
1369 '(message-use-followup-to
1370 (gnus-visible-headers .
1371 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1374 ;; Byte-compiler warning.
1375 (eval-when-compile (defvar gnus-article-mode-map))
1377 ;; Subject simplification.
1379 (defun gnus-simplify-whitespace (str)
1380 "Remove excessive whitespace from STR."
1383 (while (string-match "[ \t][ \t]+" mystr)
1384 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1386 (substring mystr (match-end 0)))))
1388 (when (string-match "^[ \t]+" mystr)
1389 (setq mystr (substring mystr (match-end 0))))
1391 (when (string-match "[ \t]+$" mystr)
1392 (setq mystr (substring mystr 0 (match-beginning 0))))
1395 (defun gnus-simplify-all-whitespace (str)
1396 "Remove all whitespace from STR."
1398 (while (string-match "[ \t\n]+" mystr)
1399 (setq mystr (replace-match "" nil nil mystr)))
1402 (defsubst gnus-simplify-subject-re (subject)
1403 "Remove \"Re:\" from subject lines."
1404 (if (string-match message-subject-re-regexp subject)
1405 (substring subject (match-end 0))
1408 (defun gnus-simplify-subject (subject &optional re-only)
1409 "Remove `Re:' and words in parentheses.
1410 If RE-ONLY is non-nil, strip leading `Re:'s only."
1411 (let ((case-fold-search t)) ;Ignore case.
1412 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1413 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1414 (setq subject (substring subject (match-end 0))))
1415 ;; Remove uninteresting prefixes.
1416 (when (and (not re-only)
1417 gnus-simplify-ignored-prefixes
1418 (string-match gnus-simplify-ignored-prefixes subject))
1419 (setq subject (substring subject (match-end 0))))
1420 ;; Remove words in parentheses from end.
1422 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1423 (setq subject (substring subject 0 (match-beginning 0)))))
1424 ;; Return subject string.
1427 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1429 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1430 (goto-char (point-min))
1431 (while (re-search-forward regexp nil t)
1432 (replace-match (or newtext ""))))
1434 (defun gnus-simplify-buffer-fuzzy ()
1435 "Simplify string in the buffer fuzzily.
1436 The string in the accessible portion of the current buffer is simplified.
1437 It is assumed to be a single-line subject.
1438 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1439 matter is removed. Additional things can be deleted by setting
1440 `gnus-simplify-subject-fuzzy-regexp'."
1441 (let ((case-fold-search t)
1443 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1445 (while (not (eq modified-tick (buffer-modified-tick)))
1446 (setq modified-tick (buffer-modified-tick))
1448 ((listp gnus-simplify-subject-fuzzy-regexp)
1449 (mapcar 'gnus-simplify-buffer-fuzzy-step
1450 gnus-simplify-subject-fuzzy-regexp))
1451 (gnus-simplify-subject-fuzzy-regexp
1452 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1453 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1454 (gnus-simplify-buffer-fuzzy-step
1455 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1456 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1458 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1459 (gnus-simplify-buffer-fuzzy-step " +" " ")
1460 (gnus-simplify-buffer-fuzzy-step " $")
1461 (gnus-simplify-buffer-fuzzy-step "^ +")))
1463 (defun gnus-simplify-subject-fuzzy (subject)
1464 "Simplify a subject string fuzzily.
1465 See `gnus-simplify-buffer-fuzzy' for details."
1467 (gnus-set-work-buffer)
1468 (let ((case-fold-search t))
1469 ;; Remove uninteresting prefixes.
1470 (when (and gnus-simplify-ignored-prefixes
1471 (string-match gnus-simplify-ignored-prefixes subject))
1472 (setq subject (substring subject (match-end 0))))
1474 (inline (gnus-simplify-buffer-fuzzy))
1477 (defsubst gnus-simplify-subject-fully (subject)
1478 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1480 (gnus-simplify-subject-functions
1481 (gnus-map-function gnus-simplify-subject-functions subject))
1482 ((null gnus-summary-gather-subject-limit)
1483 (gnus-simplify-subject-re subject))
1484 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1485 (gnus-simplify-subject-fuzzy subject))
1486 ((numberp gnus-summary-gather-subject-limit)
1487 (gnus-limit-string (gnus-simplify-subject-re subject)
1488 gnus-summary-gather-subject-limit))
1492 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1493 "Check whether two subjects are equal.
1494 If optional argument simple-first is t, first argument is already
1497 ((null simple-first)
1498 (equal (gnus-simplify-subject-fully s1)
1499 (gnus-simplify-subject-fully s2)))
1502 (gnus-simplify-subject-fully s2)))))
1504 (defun gnus-summary-bubble-group ()
1505 "Increase the score of the current group.
1506 This is a handy function to add to `gnus-summary-exit-hook' to
1507 increase the score of each group you read."
1508 (gnus-group-add-score gnus-newsgroup-name))
1512 ;;; Gnus summary mode
1515 (put 'gnus-summary-mode 'mode-class 'special)
1517 (defvar gnus-article-commands-menu)
1520 ;; Non-orthogonal keys
1522 (gnus-define-keys gnus-summary-mode-map
1523 " " gnus-summary-next-page
1524 "\177" gnus-summary-prev-page
1525 [delete] gnus-summary-prev-page
1526 [backspace] gnus-summary-prev-page
1527 "\r" gnus-summary-scroll-up
1528 "\M-\r" gnus-summary-scroll-down
1529 "n" gnus-summary-next-unread-article
1530 "p" gnus-summary-prev-unread-article
1531 "N" gnus-summary-next-article
1532 "P" gnus-summary-prev-article
1533 "\M-\C-n" gnus-summary-next-same-subject
1534 "\M-\C-p" gnus-summary-prev-same-subject
1535 "\M-n" gnus-summary-next-unread-subject
1536 "\M-p" gnus-summary-prev-unread-subject
1537 "." gnus-summary-first-unread-article
1538 "," gnus-summary-best-unread-article
1539 "\M-s" gnus-summary-search-article-forward
1540 "\M-r" gnus-summary-search-article-backward
1541 "<" gnus-summary-beginning-of-article
1542 ">" gnus-summary-end-of-article
1543 "j" gnus-summary-goto-article
1544 "^" gnus-summary-refer-parent-article
1545 "\M-^" gnus-summary-refer-article
1546 "u" gnus-summary-tick-article-forward
1547 "!" gnus-summary-tick-article-forward
1548 "U" gnus-summary-tick-article-backward
1549 "d" gnus-summary-mark-as-read-forward
1550 "D" gnus-summary-mark-as-read-backward
1551 "E" gnus-summary-mark-as-expirable
1552 "\M-u" gnus-summary-clear-mark-forward
1553 "\M-U" gnus-summary-clear-mark-backward
1554 "k" gnus-summary-kill-same-subject-and-select
1555 "\C-k" gnus-summary-kill-same-subject
1556 "\M-\C-k" gnus-summary-kill-thread
1557 "\M-\C-l" gnus-summary-lower-thread
1558 "e" gnus-summary-edit-article
1559 "#" gnus-summary-mark-as-processable
1560 "\M-#" gnus-summary-unmark-as-processable
1561 "\M-\C-t" gnus-summary-toggle-threads
1562 "\M-\C-s" gnus-summary-show-thread
1563 "\M-\C-h" gnus-summary-hide-thread
1564 "\M-\C-f" gnus-summary-next-thread
1565 "\M-\C-b" gnus-summary-prev-thread
1566 [(meta down)] gnus-summary-next-thread
1567 [(meta up)] gnus-summary-prev-thread
1568 "\M-\C-u" gnus-summary-up-thread
1569 "\M-\C-d" gnus-summary-down-thread
1570 "&" gnus-summary-execute-command
1571 "c" gnus-summary-catchup-and-exit
1572 "\C-w" gnus-summary-mark-region-as-read
1573 "\C-t" gnus-summary-toggle-truncation
1574 "?" gnus-summary-mark-as-dormant
1575 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1576 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1577 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1578 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1579 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1580 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1581 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1582 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1583 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1584 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1585 "=" gnus-summary-expand-window
1586 "\C-x\C-s" gnus-summary-reselect-current-group
1587 "\M-g" gnus-summary-rescan-group
1588 "w" gnus-summary-stop-page-breaking
1589 "\C-c\C-r" gnus-summary-caesar-message
1590 "\M-t" gnus-summary-toggle-mime
1591 "f" gnus-summary-followup
1592 "F" gnus-summary-followup-with-original
1593 "C" gnus-summary-cancel-article
1594 "r" gnus-summary-reply
1595 "R" gnus-summary-reply-with-original
1596 "\C-c\C-f" gnus-summary-mail-forward
1597 "o" gnus-summary-save-article
1598 "\C-o" gnus-summary-save-article-mail
1599 "|" gnus-summary-pipe-output
1600 "\M-k" gnus-summary-edit-local-kill
1601 "\M-K" gnus-summary-edit-global-kill
1603 "\C-c\C-d" gnus-summary-describe-group
1604 "q" gnus-summary-exit
1605 "Q" gnus-summary-exit-no-update
1606 "\C-c\C-i" gnus-info-find-node
1607 gnus-mouse-2 gnus-mouse-pick-article
1608 "m" gnus-summary-mail-other-window
1609 "a" gnus-summary-post-news
1610 "i" gnus-summary-news-other-window
1611 "x" gnus-summary-limit-to-unread
1612 "s" gnus-summary-isearch-article
1613 "t" gnus-summary-toggle-header
1614 "g" gnus-summary-show-article
1615 "l" gnus-summary-goto-last-article
1616 "v" gnus-summary-preview-mime-message
1617 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1618 "\C-d" gnus-summary-enter-digest-group
1619 "\M-\C-d" gnus-summary-read-document
1620 "\M-\C-e" gnus-summary-edit-parameters
1621 "\M-\C-a" gnus-summary-customize-parameters
1623 "\C-c\C-n" gnus-namazu-search
1624 "*" gnus-cache-enter-article
1625 "\M-*" gnus-cache-remove-article
1626 "\M-&" gnus-summary-universal-argument
1627 "\C-l" gnus-recenter
1628 "I" gnus-summary-increase-score
1629 "L" gnus-summary-lower-score
1630 "\M-i" gnus-symbolic-argument
1631 "h" gnus-summary-select-article-buffer
1633 "V" gnus-summary-score-map
1634 "X" gnus-uu-extract-map
1635 "S" gnus-summary-send-map)
1637 ;; Sort of orthogonal keymap
1638 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1639 "t" gnus-summary-tick-article-forward
1640 "!" gnus-summary-tick-article-forward
1641 "d" gnus-summary-mark-as-read-forward
1642 "r" gnus-summary-mark-as-read-forward
1643 "c" gnus-summary-clear-mark-forward
1644 " " gnus-summary-clear-mark-forward
1645 "e" gnus-summary-mark-as-expirable
1646 "x" gnus-summary-mark-as-expirable
1647 "?" gnus-summary-mark-as-dormant
1648 "b" gnus-summary-set-bookmark
1649 "B" gnus-summary-remove-bookmark
1650 "#" gnus-summary-mark-as-processable
1651 "\M-#" gnus-summary-unmark-as-processable
1652 "S" gnus-summary-limit-include-expunged
1653 "C" gnus-summary-catchup
1654 "H" gnus-summary-catchup-to-here
1655 "h" gnus-summary-catchup-from-here
1656 "\C-c" gnus-summary-catchup-all
1657 "k" gnus-summary-kill-same-subject-and-select
1658 "K" gnus-summary-kill-same-subject
1659 "P" gnus-uu-mark-map)
1661 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1662 "c" gnus-summary-clear-above
1663 "u" gnus-summary-tick-above
1664 "m" gnus-summary-mark-above
1665 "k" gnus-summary-kill-below)
1667 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1668 "/" gnus-summary-limit-to-subject
1669 "n" gnus-summary-limit-to-articles
1670 "w" gnus-summary-pop-limit
1671 "s" gnus-summary-limit-to-subject
1672 "a" gnus-summary-limit-to-author
1673 "u" gnus-summary-limit-to-unread
1674 "m" gnus-summary-limit-to-marks
1675 "M" gnus-summary-limit-exclude-marks
1676 "v" gnus-summary-limit-to-score
1677 "*" gnus-summary-limit-include-cached
1678 "D" gnus-summary-limit-include-dormant
1679 "T" gnus-summary-limit-include-thread
1680 "d" gnus-summary-limit-exclude-dormant
1681 "t" gnus-summary-limit-to-age
1682 "." gnus-summary-limit-to-unseen
1683 "x" gnus-summary-limit-to-extra
1684 "p" gnus-summary-limit-to-display-predicate
1685 "E" gnus-summary-limit-include-expunged
1686 "c" gnus-summary-limit-exclude-childless-dormant
1687 "C" gnus-summary-limit-mark-excluded-as-read
1688 "o" gnus-summary-insert-old-articles
1689 "N" gnus-summary-insert-new-articles)
1691 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1692 "n" gnus-summary-next-unread-article
1693 "p" gnus-summary-prev-unread-article
1694 "N" gnus-summary-next-article
1695 "P" gnus-summary-prev-article
1696 "\C-n" gnus-summary-next-same-subject
1697 "\C-p" gnus-summary-prev-same-subject
1698 "\M-n" gnus-summary-next-unread-subject
1699 "\M-p" gnus-summary-prev-unread-subject
1700 "f" gnus-summary-first-unread-article
1701 "b" gnus-summary-best-unread-article
1702 "j" gnus-summary-goto-article
1703 "g" gnus-summary-goto-subject
1704 "l" gnus-summary-goto-last-article
1705 "o" gnus-summary-pop-article)
1707 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1708 "k" gnus-summary-kill-thread
1709 "l" gnus-summary-lower-thread
1710 "i" gnus-summary-raise-thread
1711 "T" gnus-summary-toggle-threads
1712 "t" gnus-summary-rethread-current
1713 "^" gnus-summary-reparent-thread
1714 "s" gnus-summary-show-thread
1715 "S" gnus-summary-show-all-threads
1716 "h" gnus-summary-hide-thread
1717 "H" gnus-summary-hide-all-threads
1718 "n" gnus-summary-next-thread
1719 "p" gnus-summary-prev-thread
1720 "u" gnus-summary-up-thread
1721 "o" gnus-summary-top-thread
1722 "d" gnus-summary-down-thread
1723 "#" gnus-uu-mark-thread
1724 "\M-#" gnus-uu-unmark-thread)
1726 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1727 "g" gnus-summary-prepare
1728 "c" gnus-summary-insert-cached-articles)
1730 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1731 "c" gnus-summary-catchup-and-exit
1732 "C" gnus-summary-catchup-all-and-exit
1733 "E" gnus-summary-exit-no-update
1734 "J" gnus-summary-jump-to-other-group
1735 "Q" gnus-summary-exit
1736 "Z" gnus-summary-exit
1737 "n" gnus-summary-catchup-and-goto-next-group
1738 "R" gnus-summary-reselect-current-group
1739 "G" gnus-summary-rescan-group
1740 "N" gnus-summary-next-group
1741 "s" gnus-summary-save-newsrc
1742 "P" gnus-summary-prev-group)
1744 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1745 " " gnus-summary-next-page
1746 "n" gnus-summary-next-page
1747 "\177" gnus-summary-prev-page
1748 [delete] gnus-summary-prev-page
1749 "p" gnus-summary-prev-page
1750 "\r" gnus-summary-scroll-up
1751 "\M-\r" gnus-summary-scroll-down
1752 "<" gnus-summary-beginning-of-article
1753 ">" gnus-summary-end-of-article
1754 "b" gnus-summary-beginning-of-article
1755 "e" gnus-summary-end-of-article
1756 "^" gnus-summary-refer-parent-article
1757 "r" gnus-summary-refer-parent-article
1758 "D" gnus-summary-enter-digest-group
1759 "R" gnus-summary-refer-references
1760 "T" gnus-summary-refer-thread
1761 "g" gnus-summary-show-article
1762 "s" gnus-summary-isearch-article
1763 "P" gnus-summary-print-article
1764 "M" gnus-mailing-list-insinuate
1765 "t" gnus-article-babel)
1767 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1768 "b" gnus-article-add-buttons
1769 "B" gnus-article-add-buttons-to-head
1770 "o" gnus-article-treat-overstrike
1771 "e" gnus-article-emphasize
1772 "w" gnus-article-fill-cited-article
1773 "Q" gnus-article-fill-long-lines
1774 "C" gnus-article-capitalize-sentences
1775 "c" gnus-article-remove-cr
1776 "Z" gnus-article-decode-HZ
1777 "h" gnus-article-wash-html
1778 "u" gnus-article-unsplit-urls
1779 "f" gnus-article-display-x-face
1780 "l" gnus-summary-stop-page-breaking
1781 "r" gnus-summary-caesar-message
1782 "m" gnus-summary-morse-message
1783 "t" gnus-summary-toggle-header
1784 "g" gnus-treat-smiley
1785 "v" gnus-summary-verbose-headers
1786 "m" gnus-summary-toggle-mime
1787 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1788 "p" gnus-article-verify-x-pgp-sig
1789 "d" gnus-article-treat-dumbquotes
1790 "k" gnus-article-outlook-deuglify-article)
1792 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1793 "a" gnus-article-hide
1794 "h" gnus-article-hide-headers
1795 "b" gnus-article-hide-boring-headers
1796 "s" gnus-article-hide-signature
1797 "c" gnus-article-hide-citation
1798 "C" gnus-article-hide-citation-in-followups
1799 "l" gnus-article-hide-list-identifiers
1800 "p" gnus-article-hide-pgp
1801 "B" gnus-article-strip-banner
1802 "P" gnus-article-hide-pem
1803 "\C-c" gnus-article-hide-citation-maybe)
1805 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1806 "a" gnus-article-highlight
1807 "h" gnus-article-highlight-headers
1808 "c" gnus-article-highlight-citation
1809 "s" gnus-article-highlight-signature)
1811 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1812 "f" gnus-article-treat-fold-headers
1813 "u" gnus-article-treat-unfold-headers
1814 "n" gnus-article-treat-fold-newsgroups)
1816 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1817 "x" gnus-article-display-x-face
1818 "s" gnus-treat-smiley
1819 "D" gnus-article-remove-images
1820 "f" gnus-treat-from-picon
1821 "m" gnus-treat-mail-picon
1822 "n" gnus-treat-newsgroups-picon)
1824 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1825 "z" gnus-article-date-ut
1826 "u" gnus-article-date-ut
1827 "l" gnus-article-date-local
1828 "p" gnus-article-date-english
1829 "e" gnus-article-date-lapsed
1830 "o" gnus-article-date-original
1831 "i" gnus-article-date-iso8601
1832 "s" gnus-article-date-user)
1834 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1835 "t" gnus-article-remove-trailing-blank-lines
1836 "l" gnus-article-strip-leading-blank-lines
1837 "m" gnus-article-strip-multiple-blank-lines
1838 "a" gnus-article-strip-blank-lines
1839 "A" gnus-article-strip-all-blank-lines
1840 "s" gnus-article-strip-leading-space
1841 "e" gnus-article-strip-trailing-space
1842 "w" gnus-article-remove-leading-whitespace)
1844 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1846 "f" gnus-summary-fetch-faq
1847 "d" gnus-summary-describe-group
1848 "h" gnus-summary-describe-briefly
1849 "i" gnus-info-find-node
1850 "c" gnus-group-fetch-charter
1851 "C" gnus-group-fetch-control)
1853 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1854 "e" gnus-summary-expire-articles
1855 "\M-\C-e" gnus-summary-expire-articles-now
1856 "\177" gnus-summary-delete-article
1857 [delete] gnus-summary-delete-article
1858 [backspace] gnus-summary-delete-article
1859 "m" gnus-summary-move-article
1860 "r" gnus-summary-respool-article
1861 "w" gnus-summary-edit-article
1862 "c" gnus-summary-copy-article
1863 "B" gnus-summary-crosspost-article
1864 "q" gnus-summary-respool-query
1865 "t" gnus-summary-respool-trace
1866 "i" gnus-summary-import-article
1867 "I" gnus-summary-create-article
1868 "p" gnus-summary-article-posted-p)
1870 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1871 "o" gnus-summary-save-article
1872 "m" gnus-summary-save-article-mail
1873 "F" gnus-summary-write-article-file
1874 "r" gnus-summary-save-article-rmail
1875 "f" gnus-summary-save-article-file
1876 "b" gnus-summary-save-article-body-file
1877 "h" gnus-summary-save-article-folder
1878 "v" gnus-summary-save-article-vm
1879 "p" gnus-summary-pipe-output
1880 "P" gnus-summary-muttprint
1881 "s" gnus-soup-add-article)
1883 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1884 "b" gnus-summary-display-buttonized
1885 "m" gnus-summary-repair-multipart
1886 "v" gnus-article-view-part
1887 "o" gnus-article-save-part
1888 "c" gnus-article-copy-part
1889 "C" gnus-article-view-part-as-charset
1890 "e" gnus-article-view-part-externally
1891 "E" gnus-article-encrypt-body
1892 "i" gnus-article-inline-part
1893 "|" gnus-article-pipe-part)
1895 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1896 "p" gnus-summary-mark-as-processable
1897 "u" gnus-summary-unmark-as-processable
1898 "U" gnus-summary-unmark-all-processable
1899 "v" gnus-uu-mark-over
1900 "s" gnus-uu-mark-series
1901 "r" gnus-uu-mark-region
1902 "g" gnus-uu-unmark-region
1903 "R" gnus-uu-mark-by-regexp
1904 "G" gnus-uu-unmark-by-regexp
1905 "t" gnus-uu-mark-thread
1906 "T" gnus-uu-unmark-thread
1907 "a" gnus-uu-mark-all
1908 "b" gnus-uu-mark-buffer
1909 "S" gnus-uu-mark-sparse
1910 "k" gnus-summary-kill-process-mark
1911 "y" gnus-summary-yank-process-mark
1912 "w" gnus-summary-save-process-mark
1913 "i" gnus-uu-invert-processable)
1915 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1916 ;;"x" gnus-uu-extract-any
1917 "m" gnus-summary-save-parts
1918 "u" gnus-uu-decode-uu
1919 "U" gnus-uu-decode-uu-and-save
1920 "s" gnus-uu-decode-unshar
1921 "S" gnus-uu-decode-unshar-and-save
1922 "o" gnus-uu-decode-save
1923 "O" gnus-uu-decode-save
1924 "b" gnus-uu-decode-binhex
1925 "B" gnus-uu-decode-binhex
1926 "p" gnus-uu-decode-postscript
1927 "P" gnus-uu-decode-postscript-and-save)
1930 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1931 "u" gnus-uu-decode-uu-view
1932 "U" gnus-uu-decode-uu-and-save-view
1933 "s" gnus-uu-decode-unshar-view
1934 "S" gnus-uu-decode-unshar-and-save-view
1935 "o" gnus-uu-decode-save-view
1936 "O" gnus-uu-decode-save-view
1937 "b" gnus-uu-decode-binhex-view
1938 "B" gnus-uu-decode-binhex-view
1939 "p" gnus-uu-decode-postscript-view
1940 "P" gnus-uu-decode-postscript-and-save-view))
1942 (defvar gnus-article-post-menu nil)
1944 (defconst gnus-summary-menu-maxlen 20)
1946 (defun gnus-summary-menu-split (menu)
1947 ;; If we have lots of elements, divide them into groups of 20
1948 ;; and make a pane (or submenu) for each one.
1949 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1950 (let ((menu menu) sublists next
1953 ;; Pull off the next gnus-summary-menu-maxlen elements
1954 ;; and make them the next element of sublist.
1955 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1957 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1959 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1960 (aref (car (last menu)) 0)) menu)
1964 (nreverse sublists))
1965 ;; Few elements--put them all in one pane.
1968 (defun gnus-summary-make-menu-bar ()
1969 (gnus-turn-off-edit-menu 'summary)
1971 (unless (boundp 'gnus-summary-misc-menu)
1974 gnus-summary-kill-menu gnus-summary-mode-map ""
1979 ["Customize" gnus-score-customize t])
1980 (gnus-make-score-map 'increase)
1981 (gnus-make-score-map 'lower)
1983 ["Kill below" gnus-summary-kill-below t]
1984 ["Mark above" gnus-summary-mark-above t]
1985 ["Tick above" gnus-summary-tick-above t]
1986 ["Clear above" gnus-summary-clear-above t])
1987 ["Current score" gnus-summary-current-score t]
1988 ["Set score" gnus-summary-set-score t]
1989 ["Switch current score file..." gnus-score-change-score-file t]
1990 ["Set mark below..." gnus-score-set-mark-below t]
1991 ["Set expunge below..." gnus-score-set-expunge-below t]
1992 ["Edit current score file" gnus-score-edit-current-scores t]
1993 ["Edit score file" gnus-score-edit-file t]
1994 ["Trace score" gnus-score-find-trace t]
1995 ["Find words" gnus-score-find-favourite-words t]
1996 ["Rescore buffer" gnus-summary-rescore t]
1997 ["Increase score..." gnus-summary-increase-score t]
1998 ["Lower score..." gnus-summary-lower-score t]))))
2000 ;; Define both the Article menu in the summary buffer and the
2001 ;; equivalent Commands menu in the article buffer here for
2005 ["All" gnus-article-hide t]
2006 ["Headers" gnus-article-hide-headers t]
2007 ["Signature" gnus-article-hide-signature t]
2008 ["Citation" gnus-article-hide-citation t]
2009 ["List identifiers" gnus-article-hide-list-identifiers t]
2010 ["PGP" gnus-article-hide-pgp t]
2011 ["Banner" gnus-article-strip-banner t]
2012 ["Boring headers" gnus-article-hide-boring-headers t])
2014 ["All" gnus-article-highlight t]
2015 ["Headers" gnus-article-highlight-headers t]
2016 ["Signature" gnus-article-highlight-signature t]
2017 ["Citation" gnus-article-highlight-citation t])
2019 ["Local" gnus-article-date-local t]
2020 ["ISO8601" gnus-article-date-iso8601 t]
2021 ["UT" gnus-article-date-ut t]
2022 ["Original" gnus-article-date-original t]
2023 ["Lapsed" gnus-article-date-lapsed t]
2024 ["User-defined" gnus-article-date-user t])
2026 ["Remove images" gnus-article-remove-images t]
2027 ["Toggle smiley" gnus-treat-smiley t]
2028 ["Show X-Face" gnus-article-display-x-face t]
2029 ["Show picons in From" gnus-treat-from-picon t]
2030 ["Show picons in mail headers" gnus-treat-mail-picon t]
2031 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2032 ("View as different encoding"
2033 ,@(gnus-summary-menu-split
2036 ;; Since easymenu under FSF Emacs doesn't allow lambda
2037 ;; forms for menu commands, we should provide intern'ed
2038 ;; function symbols.
2039 (let ((command (intern (format "\
2040 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2044 (let ((gnus-summary-show-article-charset-alist
2046 (gnus-summary-show-article 1))))
2047 `[,(symbol-name cs) ,command t]))
2048 (sort (if (fboundp 'coding-system-list)
2049 (coding-system-list)
2050 ;;(mapcar 'car mm-mime-mule-charset-alist)
2055 ["Leading" gnus-article-strip-leading-blank-lines t]
2056 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2057 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2058 ["All of the above" gnus-article-strip-blank-lines t]
2059 ["All" gnus-article-strip-all-blank-lines t]
2060 ["Leading space" gnus-article-strip-leading-space t]
2061 ["Trailing space" gnus-article-strip-trailing-space t]
2062 ["Leading space in headers"
2063 gnus-article-remove-leading-whitespace t])
2064 ["Overstrike" gnus-article-treat-overstrike t]
2065 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2066 ["Emphasis" gnus-article-emphasize t]
2067 ["Word wrap" gnus-article-fill-cited-article t]
2068 ["Fill long lines" gnus-article-fill-long-lines t]
2069 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2070 ["CR" gnus-article-remove-cr t]
2071 ["Rot 13" gnus-summary-caesar-message
2072 ,@(if (featurep 'xemacs) '(t)
2073 '(:help "\"Caesar rotate\" article by 13"))]
2074 ["Morse decode" gnus-summary-morse-message t]
2075 ["Unix pipe..." gnus-summary-pipe-message t]
2076 ["Add buttons" gnus-article-add-buttons t]
2077 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2078 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2079 ["Toggle MIME" gnus-summary-toggle-mime t]
2080 ["Verbose header" gnus-summary-verbose-headers t]
2081 ["Toggle header" gnus-summary-toggle-header t]
2082 ["Unfold headers" gnus-article-treat-unfold-headers t]
2083 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2084 ["Html" gnus-article-wash-html t]
2085 ["URLs" gnus-article-unsplit-urls t]
2086 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2087 ["HZ" gnus-article-decode-HZ t]
2088 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2091 ["Save in default format" gnus-summary-save-article
2092 ,@(if (featurep 'xemacs) '(t)
2093 '(:help "Save article using default method"))]
2094 ["Save in file" gnus-summary-save-article-file
2095 ,@(if (featurep 'xemacs) '(t)
2096 '(:help "Save article in file"))]
2097 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2098 ["Save in MH folder" gnus-summary-save-article-folder t]
2099 ["Save in VM folder" gnus-summary-save-article-vm t]
2100 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2101 ["Save body in file" gnus-summary-save-article-body-file t]
2102 ["Pipe through a filter" gnus-summary-pipe-output t]
2103 ["Add to SOUP packet" gnus-soup-add-article t]
2104 ["Print with Muttprint" gnus-summary-muttprint t]
2105 ["Print" gnus-summary-print-article t])
2107 ["Respool article..." gnus-summary-respool-article t]
2108 ["Move article..." gnus-summary-move-article
2109 (gnus-check-backend-function
2110 'request-move-article gnus-newsgroup-name)]
2111 ["Copy article..." gnus-summary-copy-article t]
2112 ["Crosspost article..." gnus-summary-crosspost-article
2113 (gnus-check-backend-function
2114 'request-replace-article gnus-newsgroup-name)]
2115 ["Import file..." gnus-summary-import-article t]
2116 ["Create article..." gnus-summary-create-article t]
2117 ["Check if posted" gnus-summary-article-posted-p t]
2118 ["Edit article" gnus-summary-edit-article
2119 (not (gnus-group-read-only-p))]
2120 ["Delete article" gnus-summary-delete-article
2121 (gnus-check-backend-function
2122 'request-expire-articles gnus-newsgroup-name)]
2123 ["Query respool" gnus-summary-respool-query t]
2124 ["Trace respool" gnus-summary-respool-trace t]
2125 ["Delete expirable articles" gnus-summary-expire-articles-now
2126 (gnus-check-backend-function
2127 'request-expire-articles gnus-newsgroup-name)])
2129 ["Uudecode" gnus-uu-decode-uu
2130 ,@(if (featurep 'xemacs) '(t)
2131 '(:help "Decode uuencoded article(s)"))]
2132 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2133 ["Unshar" gnus-uu-decode-unshar t]
2134 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2135 ["Save" gnus-uu-decode-save t]
2136 ["Binhex" gnus-uu-decode-binhex t]
2137 ["Postscript" gnus-uu-decode-postscript t])
2139 ["Enter article" gnus-cache-enter-article t]
2140 ["Remove article" gnus-cache-remove-article t])
2141 ["Translate" gnus-article-babel t]
2142 ["Select article buffer" gnus-summary-select-article-buffer t]
2143 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2144 ["Isearch article..." gnus-summary-isearch-article t]
2145 ["Beginning of the article" gnus-summary-beginning-of-article t]
2146 ["End of the article" gnus-summary-end-of-article t]
2147 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2148 ["Fetch referenced articles" gnus-summary-refer-references t]
2149 ["Fetch current thread" gnus-summary-refer-thread t]
2150 ["Fetch article with id..." gnus-summary-refer-article t]
2151 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2152 ["Redisplay" gnus-summary-show-article t]
2153 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2155 gnus-summary-article-menu gnus-summary-mode-map ""
2156 (cons "Article" innards))
2158 (if (not (keymapp gnus-summary-article-menu))
2160 gnus-article-commands-menu gnus-article-mode-map ""
2161 (cons "Commands" innards))
2162 ;; in Emacs, don't share menu.
2163 (setq gnus-article-commands-menu
2164 (copy-keymap gnus-summary-article-menu))
2165 (define-key gnus-article-mode-map [menu-bar commands]
2166 (cons "Commands" gnus-article-commands-menu))))
2169 gnus-summary-thread-menu gnus-summary-mode-map ""
2171 ["Toggle threading" gnus-summary-toggle-threads t]
2172 ["Hide threads" gnus-summary-hide-all-threads t]
2173 ["Show threads" gnus-summary-show-all-threads t]
2174 ["Hide thread" gnus-summary-hide-thread t]
2175 ["Show thread" gnus-summary-show-thread t]
2176 ["Go to next thread" gnus-summary-next-thread t]
2177 ["Go to previous thread" gnus-summary-prev-thread t]
2178 ["Go down thread" gnus-summary-down-thread t]
2179 ["Go up thread" gnus-summary-up-thread t]
2180 ["Top of thread" gnus-summary-top-thread t]
2181 ["Mark thread as read" gnus-summary-kill-thread t]
2182 ["Lower thread score" gnus-summary-lower-thread t]
2183 ["Raise thread score" gnus-summary-raise-thread t]
2184 ["Rethread current" gnus-summary-rethread-current t]))
2187 gnus-summary-post-menu gnus-summary-mode-map ""
2189 ["Send a message (mail or news)" gnus-summary-post-news
2190 ,@(if (featurep 'xemacs) '(t)
2191 '(:help "Post an article"))]
2192 ["Followup" gnus-summary-followup
2193 ,@(if (featurep 'xemacs) '(t)
2194 '(:help "Post followup to this article"))]
2195 ["Followup and yank" gnus-summary-followup-with-original
2196 ,@(if (featurep 'xemacs) '(t)
2197 '(:help "Post followup to this article, quoting its contents"))]
2198 ["Supersede article" gnus-summary-supersede-article t]
2199 ["Cancel article" gnus-summary-cancel-article
2200 ,@(if (featurep 'xemacs) '(t)
2201 '(:help "Cancel an article you posted"))]
2202 ["Reply" gnus-summary-reply t]
2203 ["Reply and yank" gnus-summary-reply-with-original t]
2204 ["Wide reply" gnus-summary-wide-reply t]
2205 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2206 ,@(if (featurep 'xemacs) '(t)
2207 '(:help "Mail a reply, quoting this article"))]
2208 ["Very wide reply" gnus-summary-very-wide-reply t]
2209 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2210 ,@(if (featurep 'xemacs) '(t)
2211 '(:help "Mail a very wide reply, quoting this article"))]
2212 ["Mail forward" gnus-summary-mail-forward t]
2213 ["Post forward" gnus-summary-post-forward t]
2214 ["Digest and mail" gnus-summary-digest-mail-forward t]
2215 ["Digest and post" gnus-summary-digest-post-forward t]
2216 ["Resend message" gnus-summary-resend-message t]
2217 ["Resend message edit" gnus-summary-resend-message-edit t]
2218 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2219 ["Send a mail" gnus-summary-mail-other-window t]
2220 ["Create a local message" gnus-summary-news-other-window t]
2221 ["Uuencode and post" gnus-uu-post-news
2222 ,@(if (featurep 'xemacs) '(t)
2223 '(:help "Post a uuencoded article"))]
2224 ["Followup via news" gnus-summary-followup-to-mail t]
2225 ["Followup via news and yank"
2226 gnus-summary-followup-to-mail-with-original t]
2228 ;;["Send" gnus-summary-send-draft t]
2229 ;;["Send bounced" gnus-resend-bounced-mail t])
2233 ((not (keymapp gnus-summary-post-menu))
2234 (setq gnus-article-post-menu gnus-summary-post-menu))
2235 ((not gnus-article-post-menu)
2236 ;; Don't share post menu.
2237 (setq gnus-article-post-menu
2238 (copy-keymap gnus-summary-post-menu))))
2239 (define-key gnus-article-mode-map [menu-bar post]
2240 (cons "Post" gnus-article-post-menu))
2243 gnus-summary-misc-menu gnus-summary-mode-map ""
2246 ["Mark as read" gnus-summary-mark-as-read-forward t]
2247 ["Mark same subject and select"
2248 gnus-summary-kill-same-subject-and-select t]
2249 ["Mark same subject" gnus-summary-kill-same-subject t]
2250 ["Catchup" gnus-summary-catchup
2251 ,@(if (featurep 'xemacs) '(t)
2252 '(:help "Mark unread articles in this group as read"))]
2253 ["Catchup all" gnus-summary-catchup-all t]
2254 ["Catchup to here" gnus-summary-catchup-to-here t]
2255 ["Catchup from here" gnus-summary-catchup-from-here t]
2256 ["Catchup region" gnus-summary-mark-region-as-read t]
2257 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2259 ["Tick" gnus-summary-tick-article-forward t]
2260 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2261 ["Remove marks" gnus-summary-clear-mark-forward t]
2262 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2263 ["Set bookmark" gnus-summary-set-bookmark t]
2264 ["Remove bookmark" gnus-summary-remove-bookmark t])
2266 ["Marks..." gnus-summary-limit-to-marks t]
2267 ["Subject..." gnus-summary-limit-to-subject t]
2268 ["Author..." gnus-summary-limit-to-author t]
2269 ["Age..." gnus-summary-limit-to-age t]
2270 ["Extra..." gnus-summary-limit-to-extra t]
2271 ["Score..." gnus-summary-limit-to-score t]
2272 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2273 ["Unread" gnus-summary-limit-to-unread t]
2274 ["Unseen" gnus-summary-limit-to-unseen t]
2275 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2276 ["Articles" gnus-summary-limit-to-articles t]
2277 ["Pop limit" gnus-summary-pop-limit t]
2278 ["Show dormant" gnus-summary-limit-include-dormant t]
2279 ["Hide childless dormant"
2280 gnus-summary-limit-exclude-childless-dormant t]
2281 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2282 ["Hide marked" gnus-summary-limit-exclude-marks t]
2283 ["Show expunged" gnus-summary-limit-include-expunged t])
2285 ["Set mark" gnus-summary-mark-as-processable t]
2286 ["Remove mark" gnus-summary-unmark-as-processable t]
2287 ["Remove all marks" gnus-summary-unmark-all-processable t]
2288 ["Mark above" gnus-uu-mark-over t]
2289 ["Mark series" gnus-uu-mark-series t]
2290 ["Mark region" gnus-uu-mark-region t]
2291 ["Unmark region" gnus-uu-unmark-region t]
2292 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2293 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2294 ["Mark all" gnus-uu-mark-all t]
2295 ["Mark buffer" gnus-uu-mark-buffer t]
2296 ["Mark sparse" gnus-uu-mark-sparse t]
2297 ["Mark thread" gnus-uu-mark-thread t]
2298 ["Unmark thread" gnus-uu-unmark-thread t]
2299 ("Process Mark Sets"
2300 ["Kill" gnus-summary-kill-process-mark t]
2301 ["Yank" gnus-summary-yank-process-mark
2302 gnus-newsgroup-process-stack]
2303 ["Save" gnus-summary-save-process-mark t]))
2305 ["Page forward" gnus-summary-next-page
2306 ,@(if (featurep 'xemacs) '(t)
2307 '(:help "Show next page of article"))]
2308 ["Page backward" gnus-summary-prev-page
2309 ,@(if (featurep 'xemacs) '(t)
2310 '(:help "Show previous page of article"))]
2311 ["Line forward" gnus-summary-scroll-up t])
2313 ["Next unread article" gnus-summary-next-unread-article t]
2314 ["Previous unread article" gnus-summary-prev-unread-article t]
2315 ["Next article" gnus-summary-next-article t]
2316 ["Previous article" gnus-summary-prev-article t]
2317 ["Next unread subject" gnus-summary-next-unread-subject t]
2318 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2319 ["Next article same subject" gnus-summary-next-same-subject t]
2320 ["Previous article same subject" gnus-summary-prev-same-subject t]
2321 ["First unread article" gnus-summary-first-unread-article t]
2322 ["Best unread article" gnus-summary-best-unread-article t]
2323 ["Go to subject number..." gnus-summary-goto-subject t]
2324 ["Go to article number..." gnus-summary-goto-article t]
2325 ["Go to the last article" gnus-summary-goto-last-article t]
2326 ["Pop article off history" gnus-summary-pop-article t])
2328 ["Sort by number" gnus-summary-sort-by-number t]
2329 ["Sort by author" gnus-summary-sort-by-author t]
2330 ["Sort by subject" gnus-summary-sort-by-subject t]
2331 ["Sort by date" gnus-summary-sort-by-date t]
2332 ["Sort by score" gnus-summary-sort-by-score t]
2333 ["Sort by lines" gnus-summary-sort-by-lines t]
2334 ["Sort by characters" gnus-summary-sort-by-chars t]
2335 ["Randomize" gnus-summary-sort-by-random t]
2336 ["Original sort" gnus-summary-sort-by-original t])
2338 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2339 ["Describe group" gnus-summary-describe-group t]
2340 ["Fetch charter" gnus-group-fetch-charter
2341 ,@(if (featurep 'xemacs) nil
2342 '(:help "Display the charter of the current group"))]
2343 ["Fetch control message" gnus-group-fetch-control
2344 ,@(if (featurep 'xemacs) nil
2345 '(:help "Display the archived control message for the current group"))]
2346 ["Read manual" gnus-info-find-node t])
2348 ["Pick and read" gnus-pick-mode t]
2349 ["Binary" gnus-binary-mode t])
2351 ["Regenerate" gnus-summary-prepare t]
2352 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2353 ["Toggle threading" gnus-summary-toggle-threads t])
2354 ["See old articles" gnus-summary-insert-old-articles t]
2355 ["See new articles" gnus-summary-insert-new-articles t]
2356 ["Filter articles..." gnus-summary-execute-command t]
2357 ["Run command on subjects..." gnus-summary-universal-argument t]
2358 ["Search articles forward..." gnus-summary-search-article-forward t]
2359 ["Search articles backward..." gnus-summary-search-article-backward t]
2360 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2361 ["Expand window" gnus-summary-expand-window t]
2362 ["Expire expirable articles" gnus-summary-expire-articles
2363 (gnus-check-backend-function
2364 'request-expire-articles gnus-newsgroup-name)]
2365 ["Edit local kill file" gnus-summary-edit-local-kill t]
2366 ["Edit main kill file" gnus-summary-edit-global-kill t]
2367 ["Edit group parameters" gnus-summary-edit-parameters t]
2368 ["Customize group parameters" gnus-summary-customize-parameters t]
2369 ["Send a bug report" gnus-bug t]
2371 ["Catchup and exit" gnus-summary-catchup-and-exit
2372 ,@(if (featurep 'xemacs) '(t)
2373 '(:help "Mark unread articles in this group as read, then exit"))]
2374 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2375 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2376 ["Exit group" gnus-summary-exit
2377 ,@(if (featurep 'xemacs) '(t)
2378 '(:help "Exit current group, return to group selection mode"))]
2379 ["Exit group without updating" gnus-summary-exit-no-update t]
2380 ["Exit and goto next group" gnus-summary-next-group t]
2381 ["Exit and goto prev group" gnus-summary-prev-group t]
2382 ["Reselect group" gnus-summary-reselect-current-group t]
2383 ["Rescan group" gnus-summary-rescan-group t]
2384 ["Update dribble" gnus-summary-save-newsrc t])))
2386 (gnus-run-hooks 'gnus-summary-menu-hook)))
2388 (defvar gnus-summary-tool-bar-map nil)
2390 ;; Emacs 21 tool bar. Should be no-op otherwise.
2391 (defun gnus-summary-make-tool-bar ()
2392 (if (and (fboundp 'tool-bar-add-item-from-menu)
2393 (default-value 'tool-bar-mode)
2394 (not gnus-summary-tool-bar-map))
2395 (setq gnus-summary-tool-bar-map
2396 (let ((tool-bar-map (make-sparse-keymap))
2397 (load-path (mm-image-load-path)))
2398 (tool-bar-add-item-from-menu
2399 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2400 (tool-bar-add-item-from-menu
2401 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2402 (tool-bar-add-item-from-menu
2403 'gnus-summary-post-news "post" gnus-summary-mode-map)
2404 (tool-bar-add-item-from-menu
2405 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2406 (tool-bar-add-item-from-menu
2407 'gnus-summary-followup "followup" gnus-summary-mode-map)
2408 (tool-bar-add-item-from-menu
2409 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2410 (tool-bar-add-item-from-menu
2411 'gnus-summary-reply "reply" gnus-summary-mode-map)
2412 (tool-bar-add-item-from-menu
2413 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2414 (tool-bar-add-item-from-menu
2415 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2416 (tool-bar-add-item-from-menu
2417 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2418 (tool-bar-add-item-from-menu
2419 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2420 (tool-bar-add-item-from-menu
2421 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2422 (tool-bar-add-item-from-menu
2423 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2424 (tool-bar-add-item-from-menu
2425 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2426 (tool-bar-add-item-from-menu
2427 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2429 (if gnus-summary-tool-bar-map
2430 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2432 (defun gnus-score-set-default (var value)
2433 "A version of set that updates the GNU Emacs menu-bar."
2435 ;; It is the message that forces the active status to be updated.
2438 (defun gnus-make-score-map (type)
2439 "Make a summary score map of type TYPE."
2442 (let ((headers '(("author" "from" string)
2443 ("subject" "subject" string)
2444 ("article body" "body" string)
2445 ("article head" "head" string)
2446 ("xref" "xref" string)
2447 ("extra header" "extra" string)
2448 ("lines" "lines" number)
2449 ("followups to author" "followup" string)))
2450 (types '((number ("less than" <)
2453 (string ("substring" s)
2457 (perms '(("temporary" (current-time-string))
2465 (if (eq type 'lower)
2470 (setq header (car headers))
2476 (let ((ts (cdr (assoc (nth 2 header) types)))
2492 'gnus-summary-score-entry
2494 (if (or (string= (nth 1 header)
2496 (string= (nth 1 header)
2499 (list 'gnus-summary-header
2501 (list 'quote (nth 1 (car ts)))
2502 (list 'gnus-score-delta-default
2509 (list (nreverse outp))))
2512 (list (nreverse outt))))
2514 (setq headers (cdr headers)))
2515 (list (nreverse outh))))))))
2519 (defun gnus-summary-mode (&optional group)
2520 "Major mode for reading articles.
2522 All normal editing commands are switched off.
2523 \\<gnus-summary-mode-map>
2524 Each line in this buffer represents one article. To read an
2525 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2526 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2529 You can also post articles and send mail from this buffer. To
2530 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2531 of an article, type `\\[gnus-summary-reply]'.
2533 There are approx. one gazillion commands you can execute in this
2534 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2536 The following commands are available:
2538 \\{gnus-summary-mode-map}"
2540 (kill-all-local-variables)
2541 (when (gnus-visual-p 'summary-menu 'menu)
2542 (gnus-summary-make-menu-bar)
2543 (gnus-summary-make-tool-bar))
2544 (gnus-summary-make-local-variables)
2545 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2546 (gnus-summary-make-local-variables))
2547 (gnus-make-thread-indent-array)
2548 (gnus-simplify-mode-line)
2549 (setq major-mode 'gnus-summary-mode)
2550 (setq mode-name "Summary")
2551 (make-local-variable 'minor-mode-alist)
2552 (use-local-map gnus-summary-mode-map)
2553 (buffer-disable-undo)
2554 (setq buffer-read-only t) ;Disable modification
2555 (setq truncate-lines t)
2556 (setq selective-display t)
2557 (setq selective-display-ellipses t) ;Display `...'
2558 (gnus-summary-set-display-table)
2559 (gnus-set-default-directory)
2560 (setq gnus-newsgroup-name group)
2561 (unless (gnus-news-group-p group)
2562 (setq gnus-newsgroup-incorporated
2563 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2564 (make-local-variable 'gnus-summary-line-format)
2565 (make-local-variable 'gnus-summary-line-format-spec)
2566 (make-local-variable 'gnus-summary-dummy-line-format)
2567 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2568 (make-local-variable 'gnus-summary-mark-positions)
2569 (make-local-hook 'pre-command-hook)
2570 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2571 (gnus-run-hooks 'gnus-summary-mode-hook)
2572 (turn-on-gnus-mailing-list-mode)
2573 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2574 (gnus-update-summary-mark-positions))
2576 (defun gnus-summary-make-local-variables ()
2577 "Make all the local summary buffer variables."
2579 (dolist (local gnus-summary-local-variables)
2582 (if (eq (cdr local) 'global)
2583 ;; Copy the global value of the variable.
2584 (setq global (symbol-value (car local)))
2585 ;; Use the value from the list.
2586 (setq global (eval (cdr local))))
2587 (set (make-local-variable (car local)) global))
2588 ;; Simple nil-valued local variable.
2589 (set (make-local-variable local) nil)))))
2591 (defun gnus-summary-clear-local-variables ()
2592 (let ((locals gnus-summary-local-variables))
2594 (if (consp (car locals))
2595 (and (vectorp (caar locals))
2596 (set (caar locals) nil))
2597 (and (vectorp (car locals))
2598 (set (car locals) nil)))
2599 (setq locals (cdr locals)))))
2601 ;; Summary data functions.
2603 (defmacro gnus-data-number (data)
2606 (defmacro gnus-data-set-number (data number)
2607 `(setcar ,data ,number))
2609 (defmacro gnus-data-mark (data)
2612 (defmacro gnus-data-set-mark (data mark)
2613 `(setcar (nthcdr 1 ,data) ,mark))
2615 (defmacro gnus-data-pos (data)
2618 (defmacro gnus-data-set-pos (data pos)
2619 `(setcar (nthcdr 2 ,data) ,pos))
2621 (defmacro gnus-data-header (data)
2624 (defmacro gnus-data-set-header (data header)
2625 `(setcar (nthcdr 3 ,data) ,header))
2627 (defmacro gnus-data-level (data)
2630 (defmacro gnus-data-unread-p (data)
2631 `(= (nth 1 ,data) gnus-unread-mark))
2633 (defmacro gnus-data-read-p (data)
2634 `(/= (nth 1 ,data) gnus-unread-mark))
2636 (defmacro gnus-data-pseudo-p (data)
2637 `(consp (nth 3 ,data)))
2639 (defmacro gnus-data-find (number)
2640 `(assq ,number gnus-newsgroup-data))
2642 (defmacro gnus-data-find-list (number &optional data)
2643 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2644 (memq (assq ,number bdata)
2647 (defmacro gnus-data-make (number mark pos header level)
2648 `(list ,number ,mark ,pos ,header ,level))
2650 (defun gnus-data-enter (after-article number mark pos header level offset)
2651 (let ((data (gnus-data-find-list after-article)))
2653 (error "No such article: %d" after-article))
2654 (setcdr data (cons (gnus-data-make number mark pos header level)
2656 (setq gnus-newsgroup-data-reverse nil)
2657 (gnus-data-update-list (cddr data) offset)))
2659 (defun gnus-data-enter-list (after-article list &optional offset)
2661 (let ((data (and after-article (gnus-data-find-list after-article)))
2665 (let ((odata gnus-newsgroup-data))
2666 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2668 (gnus-data-update-list odata offset)))
2669 ;; Find the last element in the list to be spliced into the main
2672 (setq list (cdr list)))
2675 (setcdr list gnus-newsgroup-data)
2676 (setq gnus-newsgroup-data ilist)
2678 (gnus-data-update-list (cdr list) offset)))
2679 (setcdr list (cdr data))
2682 (gnus-data-update-list (cdr list) offset))))
2683 (setq gnus-newsgroup-data-reverse nil))))
2685 (defun gnus-data-remove (article &optional offset)
2686 (let ((data gnus-newsgroup-data))
2687 (if (= (gnus-data-number (car data)) article)
2689 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2690 gnus-newsgroup-data-reverse nil)
2692 (gnus-data-update-list gnus-newsgroup-data offset)))
2694 (when (= (gnus-data-number (cadr data)) article)
2695 (setcdr data (cddr data))
2697 (gnus-data-update-list (cdr data) offset))
2699 gnus-newsgroup-data-reverse nil))
2700 (setq data (cdr data))))))
2702 (defmacro gnus-data-list (backward)
2704 (or gnus-newsgroup-data-reverse
2705 (setq gnus-newsgroup-data-reverse
2706 (reverse gnus-newsgroup-data)))
2707 gnus-newsgroup-data))
2709 (defun gnus-data-update-list (data offset)
2710 "Add OFFSET to the POS of all data entries in DATA."
2711 (setq gnus-newsgroup-data-reverse nil)
2713 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2714 (setq data (cdr data))))
2716 (defun gnus-summary-article-pseudo-p (article)
2717 "Say whether this article is a pseudo article or not."
2718 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2720 (defmacro gnus-summary-article-sparse-p (article)
2721 "Say whether this article is a sparse article or not."
2722 `(memq ,article gnus-newsgroup-sparse))
2724 (defmacro gnus-summary-article-ancient-p (article)
2725 "Say whether this article is a sparse article or not."
2726 `(memq ,article gnus-newsgroup-ancient))
2728 (defun gnus-article-parent-p (number)
2729 "Say whether this article is a parent or not."
2730 (let ((data (gnus-data-find-list number)))
2731 (and (cdr data) ; There has to be an article after...
2732 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2733 (gnus-data-level (nth 1 data))))))
2735 (defun gnus-article-children (number)
2736 "Return a list of all children to NUMBER."
2737 (let* ((data (gnus-data-find-list number))
2738 (level (gnus-data-level (car data)))
2740 (setq data (cdr data))
2742 (= (gnus-data-level (car data)) (1+ level)))
2743 (push (gnus-data-number (car data)) children)
2744 (setq data (cdr data)))
2747 (defmacro gnus-summary-skip-intangible ()
2748 "If the current article is intangible, then jump to a different article."
2749 '(let ((to (get-text-property (point) 'gnus-intangible)))
2750 (and to (gnus-summary-goto-subject to))))
2752 (defmacro gnus-summary-article-intangible-p ()
2753 "Say whether this article is intangible or not."
2754 '(get-text-property (point) 'gnus-intangible))
2756 (defun gnus-article-read-p (article)
2757 "Say whether ARTICLE is read or not."
2758 (not (or (memq article gnus-newsgroup-marked)
2759 (memq article gnus-newsgroup-spam-marked)
2760 (memq article gnus-newsgroup-unreads)
2761 (memq article gnus-newsgroup-unselected)
2762 (memq article gnus-newsgroup-dormant))))
2764 ;; Some summary mode macros.
2766 (defmacro gnus-summary-article-number ()
2767 "The article number of the article on the current line.
2768 If there isn't an article number here, then we return the current
2771 (gnus-summary-skip-intangible)
2772 (or (get-text-property (point) 'gnus-number)
2773 (gnus-summary-last-subject))))
2775 (defmacro gnus-summary-article-header (&optional number)
2776 "Return the header of article NUMBER."
2777 `(gnus-data-header (gnus-data-find
2778 ,(or number '(gnus-summary-article-number)))))
2780 (defmacro gnus-summary-thread-level (&optional number)
2781 "Return the level of thread that starts with article NUMBER."
2782 `(if (and (eq gnus-summary-make-false-root 'dummy)
2783 (get-text-property (point) 'gnus-intangible))
2785 (gnus-data-level (gnus-data-find
2786 ,(or number '(gnus-summary-article-number))))))
2788 (defmacro gnus-summary-article-mark (&optional number)
2789 "Return the mark of article NUMBER."
2790 `(gnus-data-mark (gnus-data-find
2791 ,(or number '(gnus-summary-article-number)))))
2793 (defmacro gnus-summary-article-pos (&optional number)
2794 "Return the position of the line of article NUMBER."
2795 `(gnus-data-pos (gnus-data-find
2796 ,(or number '(gnus-summary-article-number)))))
2798 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2799 (defmacro gnus-summary-article-subject (&optional number)
2800 "Return current subject string or nil if nothing."
2803 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2804 '(gnus-data-header (assq (gnus-summary-article-number)
2805 gnus-newsgroup-data)))))
2808 (mail-header-subject headers))))
2810 (defmacro gnus-summary-article-score (&optional number)
2811 "Return current article score."
2812 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2813 gnus-newsgroup-scored))
2814 gnus-summary-default-score 0))
2816 (defun gnus-summary-article-children (&optional number)
2817 "Return a list of article numbers that are children of article NUMBER."
2818 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2819 (level (gnus-data-level (car data)))
2821 (while (and (setq data (cdr data))
2822 (> (setq l (gnus-data-level (car data))) level))
2823 (and (= (1+ level) l)
2824 (push (gnus-data-number (car data))
2826 (nreverse children)))
2828 (defun gnus-summary-article-parent (&optional number)
2829 "Return the article number of the parent of article NUMBER."
2830 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2831 (gnus-data-list t)))
2832 (level (gnus-data-level (car data))))
2834 () ; This is a root.
2835 ;; We search until we find an article with a level less than
2836 ;; this one. That function has to be the parent.
2837 (while (and (setq data (cdr data))
2838 (not (< (gnus-data-level (car data)) level))))
2839 (and data (gnus-data-number (car data))))))
2841 (defun gnus-unread-mark-p (mark)
2842 "Say whether MARK is the unread mark."
2843 (= mark gnus-unread-mark))
2845 (defun gnus-read-mark-p (mark)
2846 "Say whether MARK is one of the marks that mark as read.
2847 This is all marks except unread, ticked, dormant, and expirable."
2848 (not (or (= mark gnus-unread-mark)
2849 (= mark gnus-ticked-mark)
2850 (= mark gnus-dormant-mark)
2851 (= mark gnus-expirable-mark))))
2853 (defmacro gnus-article-mark (number)
2854 "Return the MARK of article NUMBER.
2855 This macro should only be used when computing the mark the \"first\"
2856 time; i.e., when generating the summary lines. After that,
2857 `gnus-summary-article-mark' should be used to examine the
2860 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2861 ;;;; ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2862 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2863 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2864 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2865 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2866 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2867 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2868 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2869 gnus-ancient-mark))))
2871 ;; Saving hidden threads.
2873 (defmacro gnus-save-hidden-threads (&rest forms)
2874 "Save hidden threads, eval FORMS, and restore the hidden threads."
2875 (let ((config (make-symbol "config")))
2876 `(let ((,config (gnus-hidden-threads-configuration)))
2880 (gnus-restore-hidden-threads-configuration ,config)))))
2881 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2882 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2884 (defun gnus-data-compute-positions ()
2885 "Compute the positions of all articles."
2886 (setq gnus-newsgroup-data-reverse nil)
2887 (let ((data gnus-newsgroup-data))
2889 (gnus-save-hidden-threads
2890 (gnus-summary-show-all-threads)
2891 (goto-char (point-min))
2893 (while (get-text-property (point) 'gnus-intangible)
2895 (gnus-data-set-pos (car data) (+ (point) 3))
2896 (setq data (cdr data))
2897 (forward-line 1))))))
2899 (defun gnus-hidden-threads-configuration ()
2900 "Return the current hidden threads configuration."
2903 (goto-char (point-min))
2904 (while (search-forward "\r" nil t)
2905 (push (1- (point)) config))
2908 (defun gnus-restore-hidden-threads-configuration (config)
2909 "Restore hidden threads configuration from CONFIG."
2911 (let (point buffer-read-only)
2912 (while (setq point (pop config))
2913 (when (and (< point (point-max))
2915 (eq (char-after) ?\n))
2916 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2918 ;; Various summary mode internalish functions.
2920 (defun gnus-mouse-pick-article (e)
2923 (gnus-summary-next-page nil t))
2925 (defun gnus-summary-set-display-table ()
2926 "Change the display table.
2927 Odd characters have a tendency to mess
2928 up nicely formatted displays - we make all possible glyphs
2929 display only a single character."
2931 ;; We start from the standard display table, if any.
2932 (let ((table (or (copy-sequence standard-display-table)
2933 (make-display-table)))
2935 ;; Nix out all the control chars...
2936 (while (>= (setq i (1- i)) 0)
2937 (aset table i [??]))
2938 ;; ... but not newline and cr, of course. (cr is necessary for the
2939 ;; selective display).
2940 (aset table ?\n nil)
2941 (aset table ?\r nil)
2942 ;; We keep TAB as well.
2943 (aset table ?\t nil)
2944 ;; We nix out any glyphs over 126 that are not set already.
2946 (while (>= (setq i (1- i)) 127)
2947 ;; Only modify if the entry is nil.
2948 (unless (aref table i)
2949 (aset table i [??]))))
2950 (setq buffer-display-table table)))
2952 (defun gnus-summary-set-article-display-arrow (pos)
2953 "Update the overlay arrow to point to line at position POS."
2954 (when (and gnus-summary-display-arrow
2955 (boundp 'overlay-arrow-position)
2956 (boundp 'overlay-arrow-string))
2960 (unless overlay-arrow-position
2961 (setq overlay-arrow-position (make-marker)))
2962 (setq overlay-arrow-string "=>"
2963 overlay-arrow-position (set-marker overlay-arrow-position
2965 (current-buffer))))))
2967 (defun gnus-summary-buffer-name (group)
2968 "Return the summary buffer name of GROUP."
2969 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2971 (defun gnus-summary-setup-buffer (group)
2972 "Initialize summary buffer."
2973 (let ((buffer (gnus-summary-buffer-name group))
2974 (dead-name (concat "*Dead Summary "
2975 (gnus-group-decoded-name group) "*")))
2976 ;; If a dead summary buffer exists, we kill it.
2977 (when (gnus-buffer-live-p dead-name)
2978 (gnus-kill-buffer dead-name))
2979 (if (get-buffer buffer)
2982 (setq gnus-summary-buffer (current-buffer))
2983 (not gnus-newsgroup-prepared))
2984 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2985 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2986 (gnus-summary-mode group)
2988 (gnus-carpal-setup-buffer 'summary))
2989 (unless gnus-single-article-buffer
2990 (make-local-variable 'gnus-article-buffer)
2991 (make-local-variable 'gnus-article-current)
2992 (make-local-variable 'gnus-original-article-buffer))
2993 (setq gnus-newsgroup-name group)
2994 ;; Set any local variables in the group parameters.
2995 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2998 (defun gnus-set-global-variables ()
2999 "Set the global equivalents of the buffer-local variables.
3000 They are set to the latest values they had. These reflect the summary
3001 buffer that was in action when the last article was fetched."
3002 (when (eq major-mode 'gnus-summary-mode)
3003 (setq gnus-summary-buffer (current-buffer))
3004 (let ((name gnus-newsgroup-name)
3005 (marked gnus-newsgroup-marked)
3006 (spam gnus-newsgroup-spam-marked)
3007 (unread gnus-newsgroup-unreads)
3008 (headers gnus-current-headers)
3009 (data gnus-newsgroup-data)
3010 (summary gnus-summary-buffer)
3011 (article-buffer gnus-article-buffer)
3012 (original gnus-original-article-buffer)
3013 (gac gnus-article-current)
3014 (reffed gnus-reffed-article-number)
3015 (score-file gnus-current-score-file)
3016 (default-charset gnus-newsgroup-charset)
3018 (let ((locals gnus-newsgroup-variables))
3020 (if (consp (car locals))
3021 (push (eval (caar locals)) vlist)
3022 (push (eval (car locals)) vlist))
3023 (setq locals (cdr locals)))
3024 (setq vlist (nreverse vlist)))
3026 (set-buffer gnus-group-buffer)
3027 (setq gnus-newsgroup-name name
3028 gnus-newsgroup-marked marked
3029 gnus-newsgroup-spam-marked spam
3030 gnus-newsgroup-unreads unread
3031 gnus-current-headers headers
3032 gnus-newsgroup-data data
3033 gnus-article-current gac
3034 gnus-summary-buffer summary
3035 gnus-article-buffer article-buffer
3036 gnus-original-article-buffer original
3037 gnus-reffed-article-number reffed
3038 gnus-current-score-file score-file
3039 gnus-newsgroup-charset default-charset)
3040 (let ((locals gnus-newsgroup-variables))
3042 (if (consp (car locals))
3043 (set (caar locals) (pop vlist))
3044 (set (car locals) (pop vlist)))
3045 (setq locals (cdr locals))))
3046 ;; The article buffer also has local variables.
3047 (when (gnus-buffer-live-p gnus-article-buffer)
3048 (set-buffer gnus-article-buffer)
3049 (setq gnus-summary-buffer summary))))))
3051 (defun gnus-summary-article-unread-p (article)
3052 "Say whether ARTICLE is unread or not."
3053 (memq article gnus-newsgroup-unreads))
3055 (defun gnus-summary-first-article-p (&optional article)
3056 "Return whether ARTICLE is the first article in the buffer."
3057 (if (not (setq article (or article (gnus-summary-article-number))))
3059 (eq article (caar gnus-newsgroup-data))))
3061 (defun gnus-summary-last-article-p (&optional article)
3062 "Return whether ARTICLE is the last article in the buffer."
3063 (if (not (setq article (or article (gnus-summary-article-number))))
3064 ;; All non-existent numbers are the last article. :-)
3066 (not (cdr (gnus-data-find-list article)))))
3068 (defun gnus-make-thread-indent-array ()
3070 (unless (and gnus-thread-indent-array
3071 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3072 (setq gnus-thread-indent-array (make-vector 201 "")
3073 gnus-thread-indent-array-level gnus-thread-indent-level)
3075 (aset gnus-thread-indent-array n
3076 (make-string (* n gnus-thread-indent-level) ? ))
3079 (defun gnus-update-summary-mark-positions ()
3080 "Compute where the summary marks are to go."
3082 (when (gnus-buffer-exists-p gnus-summary-buffer)
3083 (set-buffer gnus-summary-buffer))
3084 (let ((gnus-replied-mark 129)
3085 (gnus-score-below-mark 130)
3086 (gnus-score-over-mark 130)
3087 (gnus-download-mark 131)
3088 (spec gnus-summary-line-format-spec)
3091 (gnus-set-work-buffer)
3092 (let ((gnus-summary-line-format-spec spec)
3093 (gnus-newsgroup-downloadable '((0 . t))))
3094 (gnus-summary-insert-line
3095 (make-full-mail-header 0 "" "nobody"
3096 "05 Apr 2001 23:33:09 +0400"
3098 0 nil 128 t nil "" nil 1)
3099 (goto-char (point-min))
3100 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3101 (- (point) (point-min) 1)))))
3102 (goto-char (point-min))
3103 (push (cons 'replied (and (search-forward "\201" nil t)
3104 (- (point) (point-min) 1)))
3106 (goto-char (point-min))
3107 (push (cons 'score (and (search-forward "\202" nil t)
3108 (- (point) (point-min) 1)))
3110 (goto-char (point-min))
3111 (push (cons 'download
3112 (and (search-forward "\203" nil t)
3113 (- (point) (point-min) 1)))
3115 (setq gnus-summary-mark-positions pos))))
3117 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3118 "Insert a dummy root in the summary buffer."
3120 (gnus-add-text-properties
3121 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3122 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3124 (defun gnus-summary-extract-address-component (from)
3125 (or (car (funcall gnus-extract-address-components from))
3128 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3129 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3130 default-mime-charset)))
3131 ;; Is it really necessary to do this next part for each summary line?
3132 ;; Luckily, doesn't seem to slow things down much.
3134 (and gnus-ignored-from-addresses
3135 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3136 (let ((extra-headers (mail-header-extra header))
3140 ((setq to (cdr (assq 'To extra-headers)))
3143 (gnus-summary-extract-address-component
3144 (funcall gnus-decode-encoded-word-function to)))))
3145 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3146 (concat "=> " newsgroups)))))
3147 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3149 (defun gnus-summary-insert-line (gnus-tmp-header
3150 gnus-tmp-level gnus-tmp-current
3151 gnus-tmp-unread gnus-tmp-replied
3152 gnus-tmp-expirable gnus-tmp-subject-or-nil
3153 &optional gnus-tmp-dummy gnus-tmp-score
3155 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3156 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3157 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3158 (gnus-tmp-score-char
3159 (if (or (null gnus-summary-default-score)
3160 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3161 gnus-summary-zcore-fuzz))
3163 (if (< gnus-tmp-score gnus-summary-default-score)
3164 gnus-score-below-mark gnus-score-over-mark)))
3165 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3167 (cond (gnus-tmp-process gnus-process-mark)
3168 ((memq gnus-tmp-current gnus-newsgroup-cached)
3170 (gnus-tmp-replied gnus-replied-mark)
3171 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3172 gnus-forwarded-mark)
3173 ((memq gnus-tmp-current gnus-newsgroup-saved)
3175 ((memq gnus-tmp-number gnus-newsgroup-recent)
3177 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3180 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3183 ((string-match "<[^>]+> *$" gnus-tmp-from)
3184 (let ((beg (match-beginning 0)))
3185 (or (and (string-match "^\".+\"" gnus-tmp-from)
3186 (substring gnus-tmp-from 1 (1- (match-end 0))))
3187 (substring gnus-tmp-from 0 beg))))
3188 ((string-match "(.+)" gnus-tmp-from)
3189 (substring gnus-tmp-from
3190 (1+ (match-beginning 0)) (1- (match-end 0))))
3192 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3193 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3194 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3195 (buffer-read-only nil))
3196 (when (string= gnus-tmp-name "")
3197 (setq gnus-tmp-name gnus-tmp-from))
3198 (unless (numberp gnus-tmp-lines)
3199 (setq gnus-tmp-lines -1))
3200 (if (= gnus-tmp-lines -1)
3201 (setq gnus-tmp-lines "?")
3202 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3203 (gnus-put-text-property-excluding-characters-with-faces
3205 (progn (eval gnus-summary-line-format-spec) (point))
3206 'gnus-number gnus-tmp-number)
3207 (when (gnus-visual-p 'summary-highlight 'highlight)
3209 (gnus-run-hooks 'gnus-summary-update-hook)
3212 (defun gnus-summary-update-line (&optional dont-update)
3213 "Update summary line after change."
3214 (when (and gnus-summary-default-score
3215 (not gnus-summary-inhibit-highlight))
3216 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3217 (article (gnus-summary-article-number))
3218 (score (gnus-summary-article-score article)))
3220 (if (and gnus-summary-mark-below
3221 (< (gnus-summary-article-score)
3222 gnus-summary-mark-below))
3223 ;; This article has a low score, so we mark it as read.
3224 (when (memq article gnus-newsgroup-unreads)
3225 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3226 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3227 ;; This article was previously marked as read on account
3228 ;; of a low score, but now it has risen, so we mark it as
3230 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3231 (gnus-summary-update-mark
3232 (if (or (null gnus-summary-default-score)
3233 (<= (abs (- score gnus-summary-default-score))
3234 gnus-summary-zcore-fuzz))
3236 (if (< score gnus-summary-default-score)
3237 gnus-score-below-mark gnus-score-over-mark))
3239 ;; Do visual highlighting.
3240 (when (gnus-visual-p 'summary-highlight 'highlight)
3241 (gnus-run-hooks 'gnus-summary-update-hook)))))
3243 (defvar gnus-tmp-new-adopts nil)
3245 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3246 "Return the number of articles in THREAD.
3247 This may be 0 in some cases -- if none of the articles in
3248 the thread are to be displayed."
3250 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3252 ((not (listp thread))
3254 ((and (consp thread) (cdr thread))
3257 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3260 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3263 (when (and level (zerop level) gnus-tmp-new-adopts)
3266 'gnus-summary-number-of-articles-in-thread
3267 gnus-tmp-new-adopts))))
3269 (if (> number 1) gnus-not-empty-thread-mark
3270 gnus-empty-thread-mark)
3273 (defsubst gnus-summary-line-message-size (head)
3274 "Return pretty-printed version of message size.
3275 This function is intended to be used in
3276 `gnus-summary-line-format-alist', which see."
3277 (let ((c (or (mail-header-chars head) -1)))
3278 (cond ((< c 0) "n/a") ; chars not available
3279 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3280 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3281 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3282 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3285 (defun gnus-summary-set-local-parameters (group)
3286 "Go through the local params of GROUP and set all variable specs in that list."
3287 (let ((params (gnus-group-find-parameter group))
3288 (vars '(quit-config)) ; Ignore quit-config.
3291 (setq elem (car params)
3292 params (cdr params))
3293 (and (consp elem) ; Has to be a cons.
3294 (consp (cdr elem)) ; The cdr has to be a list.
3295 (symbolp (car elem)) ; Has to be a symbol in there.
3296 (not (memq (car elem) vars))
3297 (ignore-errors ; So we set it.
3298 (push (car elem) vars)
3299 (make-local-variable (car elem))
3300 (set (car elem) (eval (nth 1 elem))))))))
3302 (defun gnus-summary-read-group (group &optional show-all no-article
3303 kill-buffer no-display backward
3305 "Start reading news in newsgroup GROUP.
3306 If SHOW-ALL is non-nil, already read articles are also listed.
3307 If NO-ARTICLE is non-nil, no article is selected initially.
3308 If NO-DISPLAY, don't generate a summary buffer."
3312 (let ((gnus-auto-select-next nil))
3313 (or (gnus-summary-read-group-1
3314 group show-all no-article
3315 kill-buffer no-display
3318 select-articles nil)))))
3319 (eq gnus-auto-select-next 'quietly))
3320 (set-buffer gnus-group-buffer)
3321 ;; The entry function called above goes to the next
3322 ;; group automatically, so we go two groups back
3323 ;; if we are searching for the previous group.
3325 (gnus-group-prev-unread-group 2))
3326 (if (not (equal group (gnus-group-group-name)))
3327 (setq group (gnus-group-group-name))
3331 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3332 "Directly jump to the other GROUP from summary buffer.
3333 If SHOW-ALL is non-nil, already read articles are also listed."
3335 (if (eq gnus-summary-buffer (current-buffer))
3336 (list (completing-read
3337 "Group: " gnus-active-hashtb nil t
3338 (when (and gnus-newsgroup-name
3339 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3340 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3341 'gnus-group-history)
3343 (error "%s must be invoked from a gnus summary buffer." this-command)))
3344 (unless (or (zerop (length group))
3345 (and gnus-newsgroup-name
3346 (string-equal gnus-newsgroup-name group)))
3348 (gnus-summary-read-group group show-all
3349 gnus-dont-select-after-jump-to-other-group)))
3351 (defun gnus-summary-read-group-1 (group show-all no-article
3352 kill-buffer no-display
3353 &optional select-articles)
3354 ;; Killed foreign groups can't be entered.
3355 ;; (when (and (not (gnus-group-native-p group))
3356 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3357 ;; (error "Dead non-native groups can't be entered"))
3358 (gnus-message 5 "Retrieving newsgroup: %s..."
3359 (gnus-group-decoded-name group))
3360 (let* ((new-group (gnus-summary-setup-buffer group))
3361 (quit-config (gnus-group-quit-config group))
3362 (did-select (and new-group (gnus-select-newsgroup
3363 group show-all select-articles))))
3365 ;; This summary buffer exists already, so we just select it.
3367 (gnus-set-global-variables)
3369 (gnus-kill-or-deaden-summary kill-buffer))
3370 (gnus-configure-windows 'summary 'force)
3371 (gnus-set-mode-line 'summary)
3372 (gnus-summary-position-point)
3375 ;; We couldn't select this group.
3377 (when (and (eq major-mode 'gnus-summary-mode)
3378 (not (equal (current-buffer) kill-buffer)))
3379 (kill-buffer (current-buffer))
3380 (if (not quit-config)
3382 ;; Update the info -- marks might need to be removed,
3384 (gnus-summary-update-info)
3385 (set-buffer gnus-group-buffer)
3386 (gnus-group-jump-to-group group)
3387 (gnus-group-next-unread-group 1))
3388 (gnus-handle-ephemeral-exit quit-config)))
3389 (let ((grpinfo (gnus-get-info group)))
3390 (if (null (gnus-info-read grpinfo))
3391 (gnus-message 3 "Group %s contains no messages"
3392 (gnus-group-decoded-name group))
3393 (gnus-message 3 "Can't select group")))
3395 ;; The user did a `C-g' while prompting for number of articles,
3396 ;; so we exit this group.
3397 ((eq did-select 'quit)
3398 (and (eq major-mode 'gnus-summary-mode)
3399 (not (equal (current-buffer) kill-buffer))
3400 (kill-buffer (current-buffer)))
3402 (gnus-kill-or-deaden-summary kill-buffer))
3403 (if (not quit-config)
3405 (set-buffer gnus-group-buffer)
3406 (gnus-group-jump-to-group group)
3407 (gnus-group-next-unread-group 1)
3408 (gnus-configure-windows 'group 'force))
3409 (gnus-handle-ephemeral-exit quit-config))
3410 ;; Finally signal the quit.
3412 ;; The group was successfully selected.
3414 (gnus-set-global-variables)
3415 ;; Save the active value in effect when the group was entered.
3416 (setq gnus-newsgroup-active
3418 (gnus-active gnus-newsgroup-name)))
3419 ;; You can change the summary buffer in some way with this hook.
3420 (gnus-run-hooks 'gnus-select-group-hook)
3421 (gnus-update-format-specifications
3422 nil 'summary 'summary-mode 'summary-dummy)
3423 (gnus-update-summary-mark-positions)
3424 ;; Do score processing.
3425 (when gnus-use-scoring
3426 (gnus-possibly-score-headers))
3427 ;; Check whether to fill in the gaps in the threads.
3428 (when gnus-build-sparse-threads
3429 (gnus-build-sparse-threads))
3430 ;; Find the initial limit.
3431 (if gnus-show-threads
3433 (let ((gnus-newsgroup-dormant nil))
3434 (gnus-summary-initial-limit show-all))
3435 (gnus-summary-initial-limit show-all))
3436 ;; When unthreaded, all articles are always shown.
3437 (setq gnus-newsgroup-limit
3439 (lambda (header) (mail-header-number header))
3440 gnus-newsgroup-headers)))
3441 ;; Generate the summary buffer.
3443 (gnus-summary-prepare))
3444 (when gnus-use-trees
3445 (gnus-tree-open group)
3446 (setq gnus-summary-highlight-line-function
3447 'gnus-tree-highlight-article))
3448 ;; If the summary buffer is empty, but there are some low-scored
3449 ;; articles or some excluded dormants, we include these in the
3451 (when (and (zerop (buffer-size))
3453 (cond (gnus-newsgroup-dormant
3454 (gnus-summary-limit-include-dormant))
3455 ((and gnus-newsgroup-scored show-all)
3456 (gnus-summary-limit-include-expunged t))))
3457 ;; Function `gnus-apply-kill-file' must be called in this hook.
3458 (gnus-run-hooks 'gnus-apply-kill-hook)
3459 (if (and (zerop (buffer-size))
3462 ;; This newsgroup is empty.
3463 (gnus-summary-catchup-and-exit nil t)
3464 (gnus-message 6 "No unread news")
3466 (gnus-kill-or-deaden-summary kill-buffer))
3467 ;; Return nil from this function.
3469 ;; Hide conversation thread subtrees. We cannot do this in
3470 ;; gnus-summary-prepare-hook since kill processing may not
3471 ;; work with hidden articles.
3472 (gnus-summary-maybe-hide-threads)
3474 (gnus-kill-or-deaden-summary kill-buffer))
3475 (gnus-summary-auto-select-subject)
3476 ;; Show first unread article if requested.
3477 (if (and (not no-article)
3479 gnus-newsgroup-unreads
3480 gnus-auto-select-first)
3482 (gnus-configure-windows 'summary)
3483 (let ((art (gnus-summary-article-number)))
3484 (unless (or (memq art gnus-newsgroup-undownloaded)
3485 (memq art gnus-newsgroup-downloadable))
3486 (gnus-summary-goto-article art))))
3487 ;; Don't select any articles.
3488 (gnus-summary-position-point)
3489 (gnus-configure-windows 'summary 'force)
3490 (gnus-set-mode-line 'summary))
3491 (when (get-buffer-window gnus-group-buffer t)
3492 ;; Gotta use windows, because recenter does weird stuff if
3493 ;; the current buffer ain't the displayed window.
3494 (let ((owin (selected-window)))
3495 (select-window (get-buffer-window gnus-group-buffer t))
3496 (when (gnus-group-goto-group group)
3498 (select-window owin)))
3499 ;; Mark this buffer as "prepared".
3500 (setq gnus-newsgroup-prepared t)
3501 (gnus-run-hooks 'gnus-summary-prepared-hook)
3504 (defun gnus-summary-auto-select-subject ()
3505 "Select the subject line on initial group entry."
3506 (goto-char (point-min))
3508 ((eq gnus-auto-select-subject 'best)
3509 (gnus-summary-best-unread-subject))
3510 ((eq gnus-auto-select-subject 'unread)
3511 (gnus-summary-first-unread-subject))
3512 ((eq gnus-auto-select-subject 'unseen)
3513 (gnus-summary-first-unseen-subject))
3514 ((eq gnus-auto-select-subject 'unseen-or-unread)
3515 (gnus-summary-first-unseen-or-unread-subject))
3516 ((eq gnus-auto-select-subject 'first)
3519 ((gnus-functionp gnus-auto-select-subject)
3520 (funcall gnus-auto-select-subject))))
3522 (defun gnus-summary-prepare ()
3523 "Generate the summary buffer."
3525 (let ((buffer-read-only nil))
3527 (setq gnus-newsgroup-data nil
3528 gnus-newsgroup-data-reverse nil)
3529 (gnus-run-hooks 'gnus-summary-generate-hook)
3530 ;; Generate the buffer, either with threads or without.
3531 (when gnus-newsgroup-headers
3532 (gnus-summary-prepare-threads
3533 (if gnus-show-threads
3534 (gnus-sort-gathered-threads
3535 (funcall gnus-summary-thread-gathering-function
3537 (gnus-cut-threads (gnus-make-threads)))))
3538 ;; Unthreaded display.
3539 (gnus-sort-articles gnus-newsgroup-headers))))
3540 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3541 ;; Call hooks for modifying summary buffer.
3542 (goto-char (point-min))
3543 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3545 (defsubst gnus-general-simplify-subject (subject)
3546 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3549 ;; Truncate the subject.
3550 (gnus-simplify-subject-functions
3551 (gnus-map-function gnus-simplify-subject-functions subject))
3552 ((numberp gnus-summary-gather-subject-limit)
3553 (setq subject (gnus-simplify-subject-re subject))
3554 (if (> (length subject) gnus-summary-gather-subject-limit)
3555 (substring subject 0 gnus-summary-gather-subject-limit)
3557 ;; Fuzzily simplify it.
3558 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3559 (gnus-simplify-subject-fuzzy subject))
3560 ;; Just remove the leading "Re:".
3562 (gnus-simplify-subject-re subject))))
3564 (if (and gnus-summary-gather-exclude-subject
3565 (string-match gnus-summary-gather-exclude-subject subject))
3566 nil ; This article shouldn't be gathered
3569 (defun gnus-summary-simplify-subject-query ()
3570 "Query where the respool algorithm would put this article."
3572 (gnus-summary-select-article)
3574 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3576 (defun gnus-gather-threads-by-subject (threads)
3577 "Gather threads by looking at Subject headers."
3578 (if (not gnus-summary-make-false-root)
3580 (let ((hashtb (gnus-make-hashtable 1024))
3583 subject hthread whole-subject)
3585 (setq subject (gnus-general-simplify-subject
3586 (setq whole-subject (mail-header-subject
3589 (if (setq hthread (gnus-gethash subject hashtb))
3591 ;; We enter a dummy root into the thread, if we
3592 ;; haven't done that already.
3593 (unless (stringp (caar hthread))
3594 (setcar hthread (list whole-subject (car hthread))))
3595 ;; We add this new gathered thread to this gathered
3597 (setcdr (car hthread)
3598 (nconc (cdar hthread) (list (car threads))))
3599 ;; Remove it from the list of threads.
3600 (setcdr prev (cdr threads))
3601 (setq threads prev))
3602 ;; Enter this thread into the hash table.
3603 (gnus-sethash subject threads hashtb)))
3605 (setq threads (cdr threads)))
3608 (defun gnus-gather-threads-by-references (threads)
3609 "Gather threads by looking at References headers."
3610 (let ((idhashtb (gnus-make-hashtable 1024))
3611 (thhashtb (gnus-make-hashtable 1024))
3614 ids references id gthread gid entered ref)
3616 (when (setq references (mail-header-references (caar threads)))
3617 (setq id (mail-header-id (caar threads))
3618 ids (inline (gnus-split-references references))
3620 (while (setq ref (pop ids))
3621 (setq ids (delete ref ids))
3622 (if (not (setq gid (gnus-gethash ref idhashtb)))
3624 (gnus-sethash ref id idhashtb)
3625 (gnus-sethash id threads thhashtb))
3626 (setq gthread (gnus-gethash gid thhashtb))
3628 ;; We enter a dummy root into the thread, if we
3629 ;; haven't done that already.
3630 (unless (stringp (caar gthread))
3631 (setcar gthread (list (mail-header-subject (caar gthread))
3633 ;; We add this new gathered thread to this gathered
3635 (setcdr (car gthread)
3636 (nconc (cdar gthread) (list (car threads)))))
3637 ;; Add it into the thread hash table.
3638 (gnus-sethash id gthread thhashtb)
3640 ;; Remove it from the list of threads.
3641 (setcdr prev (cdr threads))
3642 (setq threads prev))))
3644 (setq threads (cdr threads)))
3647 (defun gnus-sort-gathered-threads (threads)
3648 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3649 (let ((result threads))
3651 (when (stringp (caar threads))
3652 (setcdr (car threads)
3653 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3654 (setq threads (cdr threads)))
3657 (defun gnus-thread-loop-p (root thread)
3658 "Say whether ROOT is in THREAD."
3659 (let ((stack (list thread))
3662 (while (setq thread (pop stack))
3663 (setq th (cdr thread))
3665 (not (eq (caar th) root)))
3668 ;; We have found a loop.
3670 (setcdr thread (delq (car th) (cdr thread)))
3671 (if (boundp (setq ref-dep (intern "none"
3672 gnus-newsgroup-dependencies)))
3673 (setcdr (symbol-value ref-dep)
3674 (nconc (cdr (symbol-value ref-dep))
3676 (set ref-dep (list nil (car th))))
3679 ;; Push all the subthreads onto the stack.
3680 (push (cdr thread) stack)))
3683 (defun gnus-make-threads ()
3684 "Go through the dependency hashtb and find the roots. Return all threads."
3686 (while (catch 'infloop
3689 ;; Deal with self-referencing References loops.
3690 (when (and (car (symbol-value refs))
3697 (car (symbol-value refs)) thread))
3698 (cdr (symbol-value refs)))))))
3701 (unless (car (symbol-value refs))
3702 ;; These threads do not refer back to any other articles,
3703 ;; so they're roots.
3704 (setq threads (append (cdr (symbol-value refs)) threads))))
3705 gnus-newsgroup-dependencies)))
3708 ;; Build the thread tree.
3709 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3710 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3712 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3713 if it was already present.
3715 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3716 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3717 Message-IDs will be renamed to a unique Message-ID before being
3720 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3721 (let* ((id (mail-header-id header))
3722 (id-dep (and id (intern id dependencies)))
3723 parent-id ref ref-dep ref-header replaced)
3724 ;; Enter this `header' in the `dependencies' table.
3728 ;; The first two cases do the normal part: enter a new `header'
3729 ;; in the `dependencies' table.
3730 ((not (boundp id-dep))
3731 (set id-dep (list header)))
3732 ((null (car (symbol-value id-dep)))
3733 (setcar (symbol-value id-dep) header))
3735 ;; From here the `header' was already present in the
3736 ;; `dependencies' table.
3738 ;; Overrides an existing entry;
3739 ;; just set the header part of the entry.
3740 (setcar (symbol-value id-dep) header)
3743 ;; Renames the existing `header' to a unique Message-ID.
3744 ((not gnus-summary-ignore-duplicates)
3745 ;; An article with this Message-ID has already been seen.
3746 ;; We rename the Message-ID.
3747 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3749 (mail-header-set-id header id))
3751 ;; The last case ignores an existing entry, except it adds any
3752 ;; additional Xrefs (in case the two articles came from different
3754 ;; Also sets `header' to `nil' meaning that the `dependencies'
3755 ;; table was *not* modified.
3757 (mail-header-set-xref
3758 (car (symbol-value id-dep))
3759 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3761 (or (mail-header-xref header) "")))
3764 (when (and header (not replaced))
3765 ;; First check that we are not creating a References loop.
3766 (setq parent-id (gnus-parent-id (mail-header-references header)))
3767 (setq ref parent-id)
3769 (setq ref-dep (intern-soft ref dependencies))
3771 (setq ref-header (car (symbol-value ref-dep))))
3772 (if (string= id ref)
3773 ;; Yuk! This is a reference loop. Make the article be a
3776 (mail-header-set-references (car (symbol-value id-dep)) "none")
3778 (setq parent-id nil))
3779 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3780 (setq ref-dep (intern (or parent-id "none") dependencies))
3781 (if (boundp ref-dep)
3782 (setcdr (symbol-value ref-dep)
3783 (nconc (cdr (symbol-value ref-dep))
3784 (list (symbol-value id-dep))))
3785 (set ref-dep (list nil (symbol-value id-dep)))))
3788 (defun gnus-extract-message-id-from-in-reply-to (string)
3789 (if (string-match "<[^>]+>" string)
3790 (substring string (match-beginning 0) (match-end 0))
3793 (defun gnus-build-sparse-threads ()
3794 (let ((headers gnus-newsgroup-headers)
3795 (mail-parse-charset gnus-newsgroup-charset)
3796 (gnus-summary-ignore-duplicates t)
3797 header references generation relations
3798 subject child end new-child date)
3799 ;; First we create an alist of generations/relations, where
3800 ;; generations is how much we trust the relation, and the relation
3802 (gnus-message 7 "Making sparse threads...")
3804 (nnheader-set-temp-buffer " *gnus sparse threads*")
3805 (while (setq header (pop headers))
3806 (when (and (setq references (mail-header-references header))
3807 (not (string= references "")))
3809 (setq child (mail-header-id header)
3810 subject (mail-header-subject header)
3811 date (mail-header-date header)
3813 (while (search-backward ">" nil t)
3814 (setq end (1+ (point)))
3815 (when (search-backward "<" nil t)
3816 (setq new-child (buffer-substring (point) end))
3817 (push (list (incf generation)
3818 child (setq child new-child)
3822 (push (list (1+ generation) child nil subject) relations))
3824 (kill-buffer (current-buffer)))
3825 ;; Sort over trustworthiness.
3828 (when (gnus-dependencies-add-header
3829 (make-full-mail-header-from-decoded-header
3830 gnus-reffed-article-number
3831 (nth 3 relation) "" (or (nth 4 relation) "")
3833 (or (nth 2 relation) "") 0 0 "")
3834 gnus-newsgroup-dependencies nil)
3835 (push gnus-reffed-article-number gnus-newsgroup-limit)
3836 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3837 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3838 gnus-newsgroup-reads)
3839 (decf gnus-reffed-article-number)))
3840 (sort relations 'car-less-than-car))
3841 (gnus-message 7 "Making sparse threads...done")))
3843 (defun gnus-build-old-threads ()
3844 ;; Look at all the articles that refer back to old articles, and
3845 ;; fetch the headers for the articles that aren't there. This will
3846 ;; build complete threads - if the roots haven't been expired by the
3848 (let ((mail-parse-charset gnus-newsgroup-charset)
3852 (when (not (car (symbol-value refs)))
3853 (setq heads (cdr (symbol-value refs)))
3855 (if (memq (mail-header-number (caar heads))
3856 gnus-newsgroup-dormant)
3857 (setq heads (cdr heads))
3858 (setq id (symbol-name refs))
3859 (while (and (setq id (gnus-build-get-header id))
3860 (not (car (gnus-id-to-thread id)))))
3861 (setq heads nil)))))
3862 gnus-newsgroup-dependencies)))
3864 ;; This function has to be called with point after the article number
3865 ;; on the beginning of the line.
3866 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3867 (let ((eol (gnus-point-at-eol))
3868 (buffer (current-buffer))
3869 header references in-reply-to)
3871 ;; overview: [num subject from date id refs chars lines misc]
3874 (narrow-to-region (point) eol)
3879 (make-full-mail-header
3881 (nnheader-nov-field) ; subject
3882 (nnheader-nov-field) ; from
3883 (nnheader-nov-field) ; date
3884 (nnheader-nov-read-message-id) ; id
3885 (nnheader-nov-field) ; refs
3886 (nnheader-nov-read-integer) ; chars
3887 (nnheader-nov-read-integer) ; lines
3889 (if (looking-at "Xref: ")
3890 (goto-char (match-end 0)))
3891 (nnheader-nov-field)) ; Xref
3892 (nnheader-nov-parse-extra)))) ; extra
3896 (when (and (string= references "")
3897 (setq in-reply-to (mail-header-extra header))
3898 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3899 (mail-header-set-references
3900 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3902 (when gnus-alter-header-function
3903 (funcall gnus-alter-header-function header))
3904 (gnus-dependencies-add-header header dependencies force-new)))
3906 (defun gnus-build-get-header (id)
3907 "Look through the buffer of NOV lines and find the header to ID.
3908 Enter this line into the dependencies hash table, and return
3909 the id of the parent article (if any)."
3910 (let ((deps gnus-newsgroup-dependencies)
3914 (set-buffer nntp-server-buffer)
3915 (let ((case-fold-search nil))
3916 (goto-char (point-min))
3917 (while (and (not found)
3918 (search-forward id nil t))
3920 (setq found (looking-at
3921 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3922 (regexp-quote id))))
3923 (or found (beginning-of-line 2)))
3927 (setq header (gnus-nov-parse-line
3928 (read (current-buffer)) deps))
3929 (gnus-parent-id (mail-header-references header))))))
3931 (let ((number (mail-header-number header)))
3932 (push number gnus-newsgroup-limit)
3933 (push header gnus-newsgroup-headers)
3934 (if (memq number gnus-newsgroup-unselected)
3936 (setq gnus-newsgroup-unreads
3937 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3939 (setq gnus-newsgroup-unselected
3940 (delq number gnus-newsgroup-unselected)))
3941 (push number gnus-newsgroup-ancient)))))))
3943 (defun gnus-build-all-threads ()
3944 "Read all the headers."
3945 (let ((gnus-summary-ignore-duplicates t)
3946 (mail-parse-charset gnus-newsgroup-charset)
3947 (dependencies gnus-newsgroup-dependencies)
3950 (set-buffer nntp-server-buffer)
3951 (let ((case-fold-search nil))
3952 (goto-char (point-min))
3955 (setq article (read (current-buffer))
3956 header (gnus-nov-parse-line article dependencies)))
3959 (set-buffer gnus-summary-buffer)
3960 (push header gnus-newsgroup-headers)
3961 (if (memq (setq article (mail-header-number header))
3962 gnus-newsgroup-unselected)
3964 (setq gnus-newsgroup-unreads
3965 (gnus-add-to-sorted-list
3966 gnus-newsgroup-unreads article))
3967 (setq gnus-newsgroup-unselected
3968 (delq article gnus-newsgroup-unselected)))
3969 (push article gnus-newsgroup-ancient)))
3970 (forward-line 1)))))))
3972 (defun gnus-summary-update-article-line (article header)
3973 "Update the line for ARTICLE using HEADERS."
3974 (let* ((id (mail-header-id header))
3975 (thread (gnus-id-to-thread id)))
3977 (error "Article in no thread"))
3978 ;; Update the thread.
3979 (setcar thread header)
3980 (gnus-summary-goto-subject article)
3981 (let* ((datal (gnus-data-find-list article))
3983 (length (when (cdr datal)
3984 (- (gnus-data-pos data)
3985 (gnus-data-pos (cadr datal)))))
3986 (buffer-read-only nil)
3987 (level (gnus-summary-thread-level)))
3989 (gnus-summary-insert-line
3990 header level nil (gnus-article-mark article)
3991 (memq article gnus-newsgroup-replied)
3992 (memq article gnus-newsgroup-expirable)
3993 ;; Only insert the Subject string when it's different
3994 ;; from the previous Subject string.
3999 (mail-header-subject
4002 (gnus-data-find-list
4004 (gnus-data-list t)))))
4005 ;; Error on the side of excessive subjects.
4007 (mail-header-subject header)))
4009 (mail-header-subject header))
4010 nil (cdr (assq article gnus-newsgroup-scored))
4011 (memq article gnus-newsgroup-processable))
4013 (gnus-data-update-list
4014 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4016 (defun gnus-summary-update-article (article &optional iheader)
4017 "Update ARTICLE in the summary buffer."
4018 (set-buffer gnus-summary-buffer)
4019 (let* ((header (gnus-summary-article-header article))
4020 (id (mail-header-id header))
4021 (data (gnus-data-find article))
4022 (thread (gnus-id-to-thread id))
4023 (references (mail-header-references header))
4027 (when (and references
4028 (not (equal "" references)))
4031 (buffer-read-only nil)
4037 (delq thread parent)))
4038 (if (gnus-summary-insert-subject id header)
4039 ;; Set the (possibly) new article number in the data structure.
4040 (gnus-data-set-number data (gnus-id-to-article id))
4044 (defun gnus-rebuild-thread (id &optional line)
4045 "Rebuild the thread containing ID.
4046 If LINE, insert the rebuilt thread starting on line LINE."
4047 (let ((buffer-read-only nil)
4048 old-pos current thread data)
4049 (if (not gnus-show-threads)
4050 (setq thread (list (car (gnus-id-to-thread id))))
4051 ;; Get the thread this article is part of.
4052 (setq thread (gnus-remove-thread id)))
4053 (setq old-pos (gnus-point-at-bol))
4054 (setq current (save-excursion
4055 (and (re-search-backward "[\r\n]" nil t)
4056 (gnus-summary-article-number))))
4057 ;; If this is a gathered thread, we have to go some re-gathering.
4058 (when (stringp (car thread))
4059 (let ((subject (car thread))
4061 (setq thread (cdr thread))
4063 (unless (memq (setq thr (gnus-id-to-thread
4065 (mail-header-id (caar thread)))))
4068 (setq thread (cdr thread)))
4069 ;; We now have all (unique) roots.
4070 (if (= (length roots) 1)
4071 ;; All the loose roots are now one solid root.
4072 (setq thread (car roots))
4073 (setq thread (cons subject (gnus-sort-threads roots))))))
4075 ;; We then insert this thread into the summary buffer.
4077 (goto-char (point-min))
4078 (forward-line (1- line)))
4079 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4080 (if gnus-show-threads
4081 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4082 (gnus-summary-prepare-unthreaded thread))
4083 (setq data (nreverse gnus-newsgroup-data))
4084 (setq threads gnus-newsgroup-threads))
4085 ;; We splice the new data into the data structure.
4086 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4087 ;;!!! then we want to insert at the beginning of the buffer.
4088 ;;!!! That happens to be true with Gnus now, but that may
4089 ;;!!! change in the future. Perhaps.
4090 (gnus-data-enter-list
4091 (if line nil current) data (- (point) old-pos))
4092 (setq gnus-newsgroup-threads
4093 (nconc threads gnus-newsgroup-threads))
4094 (gnus-data-compute-positions))))
4096 (defun gnus-number-to-header (number)
4097 "Return the header for article NUMBER."
4098 (let ((headers gnus-newsgroup-headers))
4100 (not (= number (mail-header-number (car headers)))))
4105 (defun gnus-parent-headers (in-headers &optional generation)
4106 "Return the headers of the GENERATIONeth parent of HEADERS."
4108 (setq generation 1))
4110 (headers in-headers)
4113 (not (zerop generation))
4114 (setq references (mail-header-references headers)))
4115 (setq headers (if (and references
4116 (setq parent (gnus-parent-id references)))
4117 (car (gnus-id-to-thread parent))
4120 (and (not (eq headers in-headers))
4123 (defun gnus-id-to-thread (id)
4124 "Return the (sub-)thread where ID appears."
4125 (gnus-gethash id gnus-newsgroup-dependencies))
4127 (defun gnus-id-to-article (id)
4128 "Return the article number of ID."
4129 (let ((thread (gnus-id-to-thread id)))
4132 (mail-header-number (car thread)))))
4134 (defun gnus-id-to-header (id)
4135 "Return the article headers of ID."
4136 (car (gnus-id-to-thread id)))
4138 (defun gnus-article-displayed-root-p (article)
4139 "Say whether ARTICLE is a root(ish) article."
4140 (let ((level (gnus-summary-thread-level article))
4141 (refs (mail-header-references (gnus-summary-article-header article)))
4147 ((null (gnus-parent-id refs)) t)
4149 (null (setq particle (gnus-id-to-article
4150 (gnus-parent-id refs))))
4151 (null (gnus-summary-thread-level particle)))))))
4153 (defun gnus-root-id (id)
4154 "Return the id of the root of the thread where ID appears."
4156 (while (and id (setq prev (car (gnus-id-to-thread id))))
4158 id (gnus-parent-id (mail-header-references prev))))
4161 (defun gnus-articles-in-thread (thread)
4162 "Return the list of articles in THREAD."
4163 (cons (mail-header-number (car thread))
4164 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4166 (defun gnus-remove-thread (id &optional dont-remove)
4167 "Remove the thread that has ID in it."
4168 (let (headers thread last-id)
4169 ;; First go up in this thread until we find the root.
4170 (setq last-id (gnus-root-id id)
4171 headers (message-flatten-list (gnus-id-to-thread last-id)))
4172 ;; We have now found the real root of this thread. It might have
4173 ;; been gathered into some loose thread, so we have to search
4174 ;; through the threads to find the thread we wanted.
4175 (let ((threads gnus-newsgroup-threads)
4178 (setq sub (car threads))
4179 (if (stringp (car sub))
4180 ;; This is a gathered thread, so we look at the roots
4181 ;; below it to find whether this article is in this
4184 (setq sub (cdr sub))
4186 (when (member (caar sub) headers)
4187 (setq thread (car threads)
4190 (setq sub (cdr sub))))
4191 ;; It's an ordinary thread, so we check it.
4192 (when (eq (car sub) (car headers))
4195 (setq threads (cdr threads)))
4196 ;; If this article is in no thread, then it's a root.
4199 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4200 (setq thread (gnus-id-to-thread last-id)))
4203 thread ; We return this thread.
4205 (if (stringp (car thread))
4207 ;; If we use dummy roots, then we have to remove the
4208 ;; dummy root as well.
4209 (when (eq gnus-summary-make-false-root 'dummy)
4210 ;; We go to the dummy root by going to
4211 ;; the first sub-"thread", and then one line up.
4212 (gnus-summary-goto-article
4213 (mail-header-number (caadr thread)))
4216 (gnus-data-compute-positions))
4217 (setq thread (cdr thread))
4219 (gnus-remove-thread-1 (car thread))
4220 (setq thread (cdr thread))))
4221 (gnus-remove-thread-1 thread))))))))
4223 (defun gnus-remove-thread-1 (thread)
4224 "Remove the thread THREAD recursively."
4225 (let ((number (mail-header-number (pop thread)))
4227 (setq thread (reverse thread))
4229 (gnus-remove-thread-1 (pop thread)))
4230 (when (setq d (gnus-data-find number))
4231 (goto-char (gnus-data-pos d))
4232 (gnus-summary-show-thread)
4235 (- (gnus-point-at-bol)
4237 (1+ (gnus-point-at-eol))
4238 (gnus-delete-line)))))))
4240 (defun gnus-sort-threads-1 (threads func)
4241 (sort (mapcar (lambda (thread)
4244 (gnus-sort-threads-1 (cdr thread) func))))
4247 (defun gnus-sort-threads (threads)
4249 (if (not gnus-thread-sort-functions)
4251 (gnus-message 8 "Sorting threads...")
4253 (gnus-sort-threads-1
4255 (gnus-make-sort-function gnus-thread-sort-functions))
4256 (gnus-message 8 "Sorting threads...done"))))
4258 (defun gnus-sort-articles (articles)
4260 (when gnus-article-sort-functions
4261 (gnus-message 7 "Sorting articles...")
4263 (setq gnus-newsgroup-headers
4264 (sort articles (gnus-make-sort-function
4265 gnus-article-sort-functions)))
4266 (gnus-message 7 "Sorting articles...done"))))
4268 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4269 (defmacro gnus-thread-header (thread)
4270 "Return header of first article in THREAD.
4271 Note that THREAD must never, ever be anything else than a variable -
4272 using some other form will lead to serious barfage."
4273 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4274 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4275 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4278 (defsubst gnus-article-sort-by-number (h1 h2)
4279 "Sort articles by article number."
4280 (< (mail-header-number h1)
4281 (mail-header-number h2)))
4283 (defun gnus-thread-sort-by-number (h1 h2)
4284 "Sort threads by root article number."
4285 (gnus-article-sort-by-number
4286 (gnus-thread-header h1) (gnus-thread-header h2)))
4288 (defsubst gnus-article-sort-by-random (h1 h2)
4289 "Sort articles by article number."
4292 (defun gnus-thread-sort-by-random (h1 h2)
4293 "Sort threads by root article number."
4294 (gnus-article-sort-by-random
4295 (gnus-thread-header h1) (gnus-thread-header h2)))
4297 (defsubst gnus-article-sort-by-lines (h1 h2)
4298 "Sort articles by article Lines header."
4299 (< (mail-header-lines h1)
4300 (mail-header-lines h2)))
4302 (defun gnus-thread-sort-by-lines (h1 h2)
4303 "Sort threads by root article Lines header."
4304 (gnus-article-sort-by-lines
4305 (gnus-thread-header h1) (gnus-thread-header h2)))
4307 (defsubst gnus-article-sort-by-chars (h1 h2)
4308 "Sort articles by octet length."
4309 (< (mail-header-chars h1)
4310 (mail-header-chars h2)))
4312 (defun gnus-thread-sort-by-chars (h1 h2)
4313 "Sort threads by root article octet length."
4314 (gnus-article-sort-by-chars
4315 (gnus-thread-header h1) (gnus-thread-header h2)))
4317 (defsubst gnus-article-sort-by-author (h1 h2)
4318 "Sort articles by root author."
4320 (let ((addr (car (mime-entity-read-field h1 'From))))
4321 (or (std11-full-name-string addr)
4322 (std11-address-string addr)
4324 (let ((addr (car (mime-entity-read-field h2 'From))))
4325 (or (std11-full-name-string addr)
4326 (std11-address-string addr)
4330 (defun gnus-thread-sort-by-author (h1 h2)
4331 "Sort threads by root author."
4332 (gnus-article-sort-by-author
4333 (gnus-thread-header h1) (gnus-thread-header h2)))
4335 (defsubst gnus-article-sort-by-subject (h1 h2)
4336 "Sort articles by root subject."
4338 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4339 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4341 (defun gnus-thread-sort-by-subject (h1 h2)
4342 "Sort threads by root subject."
4343 (gnus-article-sort-by-subject
4344 (gnus-thread-header h1) (gnus-thread-header h2)))
4346 (defsubst gnus-article-sort-by-date (h1 h2)
4347 "Sort articles by root article date."
4349 (gnus-date-get-time (mail-header-date h1))
4350 (gnus-date-get-time (mail-header-date h2))))
4352 (defun gnus-thread-sort-by-date (h1 h2)
4353 "Sort threads by root article date."
4354 (gnus-article-sort-by-date
4355 (gnus-thread-header h1) (gnus-thread-header h2)))
4357 (defsubst gnus-article-sort-by-score (h1 h2)
4358 "Sort articles by root article score.
4359 Unscored articles will be counted as having a score of zero."
4360 (> (or (cdr (assq (mail-header-number h1)
4361 gnus-newsgroup-scored))
4362 gnus-summary-default-score 0)
4363 (or (cdr (assq (mail-header-number h2)
4364 gnus-newsgroup-scored))
4365 gnus-summary-default-score 0)))
4367 (defun gnus-thread-sort-by-score (h1 h2)
4368 "Sort threads by root article score."
4369 (gnus-article-sort-by-score
4370 (gnus-thread-header h1) (gnus-thread-header h2)))
4372 (defun gnus-thread-sort-by-total-score (h1 h2)
4373 "Sort threads by the sum of all scores in the thread.
4374 Unscored articles will be counted as having a score of zero."
4375 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4377 (defun gnus-thread-total-score (thread)
4378 ;; This function find the total score of THREAD.
4383 (if (stringp (car thread))
4384 (apply gnus-thread-score-function 0
4385 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4386 (gnus-thread-total-score-1 thread)))
4388 (gnus-thread-total-score-1 (list thread)))))
4390 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4391 "Sort threads such that the thread with the most recently arrived article comes first."
4392 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4394 (defun gnus-thread-highest-number (thread)
4395 "Return the highest article number in THREAD."
4396 (apply 'max (mapcar (lambda (header)
4397 (mail-header-number header))
4398 (message-flatten-list thread))))
4400 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4401 "Sort threads such that the thread with the most recently dated article comes first."
4402 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4404 (defun gnus-thread-latest-date (thread)
4405 "Return the highest article date in THREAD."
4406 (let ((previous-time 0))
4411 (mail-header-parse-date
4413 (mail-header-date header)
4414 (error previous-time))))))
4416 (message-flatten-list thread)
4418 (< (mail-header-number h1)
4419 (mail-header-number h2))))))))
4421 (defun gnus-thread-total-score-1 (root)
4422 ;; This function find the total score of the thread below ROOT.
4423 (setq root (car root))
4424 (apply gnus-thread-score-function
4426 (mapcar 'gnus-thread-total-score
4427 (cdr (gnus-id-to-thread (mail-header-id root))))
4428 (when (> (mail-header-number root) 0)
4429 (list (or (cdr (assq (mail-header-number root)
4430 gnus-newsgroup-scored))
4431 gnus-summary-default-score 0))))
4432 (list gnus-summary-default-score)
4435 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4436 (defvar gnus-tmp-prev-subject nil)
4437 (defvar gnus-tmp-false-parent nil)
4438 (defvar gnus-tmp-root-expunged nil)
4439 (defvar gnus-tmp-dummy-line nil)
4441 (eval-when-compile (defvar gnus-tmp-header))
4442 (defun gnus-extra-header (type &optional header)
4443 "Return the extra header of TYPE."
4444 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4447 (defvar gnus-tmp-thread-tree-header-string "")
4449 (defcustom gnus-sum-thread-tree-root "> "
4450 "With %B spec, used for the root of a thread.
4451 If nil, use subject instead."
4453 :group 'gnus-thread)
4454 (defcustom gnus-sum-thread-tree-single-indent ""
4455 "With %B spec, used for a thread with just one message.
4456 If nil, use subject instead."
4458 :group 'gnus-thread)
4459 (defcustom gnus-sum-thread-tree-vertical "| "
4460 "With %B spec, used for drawing a vertical line."
4462 :group 'gnus-thread)
4463 (defcustom gnus-sum-thread-tree-indent " "
4464 "With %B spec, used for indenting."
4466 :group 'gnus-thread)
4467 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4468 "With %B spec, used for a leaf with brothers."
4470 :group 'gnus-thread)
4471 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4472 "With %B spec, used for a leaf without brothers."
4474 :group 'gnus-thread)
4476 (defun gnus-summary-prepare-threads (threads)
4477 "Prepare summary buffer from THREADS and indentation LEVEL.
4478 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4479 or a straight list of headers."
4480 (gnus-message 7 "Generating summary...")
4482 (setq gnus-newsgroup-threads threads)
4485 (let ((gnus-tmp-level 0)
4486 (default-score (or gnus-summary-default-score 0))
4487 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4488 thread number subject stack state gnus-tmp-gathered beg-match
4489 new-roots gnus-tmp-new-adopts thread-end simp-subject
4490 gnus-tmp-header gnus-tmp-unread
4491 gnus-tmp-replied gnus-tmp-subject-or-nil
4492 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4493 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4494 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4497 (setq gnus-tmp-prev-subject nil)
4499 (if (vectorp (car threads))
4500 ;; If this is a straight (sic) list of headers, then a
4501 ;; threaded summary display isn't required, so we just create
4502 ;; an unthreaded one.
4503 (gnus-summary-prepare-unthreaded threads)
4505 ;; Do the threaded display.
4507 (while (or threads stack gnus-tmp-new-adopts new-roots)
4509 (if (and (= gnus-tmp-level 0)
4512 (not gnus-tmp-false-parent)
4513 (or gnus-tmp-new-adopts new-roots))
4514 (if gnus-tmp-new-adopts
4515 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4516 thread (list (car gnus-tmp-new-adopts))
4517 gnus-tmp-header (caar thread)
4518 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4520 (setq thread (list (car new-roots))
4521 gnus-tmp-header (caar thread)
4522 new-roots (cdr new-roots))))
4525 ;; If there are some threads, we do them before the
4526 ;; threads on the stack.
4527 (setq thread threads
4528 gnus-tmp-header (caar thread))
4529 ;; There were no current threads, so we pop something off
4531 (setq state (car stack)
4532 gnus-tmp-level (car state)
4533 tree-stack (cadr state)
4534 thread (caddr state)
4536 gnus-tmp-header (caar thread))))
4538 (setq gnus-tmp-false-parent nil)
4539 (setq gnus-tmp-root-expunged nil)
4540 (setq thread-end nil)
4542 (if (stringp gnus-tmp-header)
4543 ;; The header is a dummy root.
4545 ((eq gnus-summary-make-false-root 'adopt)
4546 ;; We let the first article adopt the rest.
4547 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4549 (setq gnus-tmp-gathered
4551 (lambda (h) (mail-header-number (car h)))
4554 (setq thread (cons (list (caar thread)
4557 (setq gnus-tmp-level -1
4558 gnus-tmp-false-parent t))
4559 ((eq gnus-summary-make-false-root 'empty)
4560 ;; We print adopted articles with empty subject fields.
4561 (setq gnus-tmp-gathered
4563 (lambda (h) (mail-header-number (car h)))
4566 (setq gnus-tmp-level -1))
4567 ((eq gnus-summary-make-false-root 'dummy)
4568 ;; We remember that we probably want to output a dummy
4570 (setq gnus-tmp-dummy-line gnus-tmp-header)
4571 (setq gnus-tmp-prev-subject gnus-tmp-header))
4573 ;; We do not make a root for the gathered
4574 ;; sub-threads at all.
4575 (setq gnus-tmp-level -1)))
4577 (setq number (mail-header-number gnus-tmp-header)
4578 subject (mail-header-subject gnus-tmp-header)
4579 simp-subject (gnus-simplify-subject-fully subject))
4582 ;; If the thread has changed subject, we might want to make
4583 ;; this subthread into a root.
4584 ((and (null gnus-thread-ignore-subject)
4585 (not (zerop gnus-tmp-level))
4586 gnus-tmp-prev-subject
4587 (not (string= gnus-tmp-prev-subject simp-subject)))
4588 (setq new-roots (nconc new-roots (list (car thread)))
4590 gnus-tmp-header nil))
4591 ;; If the article lies outside the current limit,
4592 ;; then we do not display it.
4593 ((not (memq number gnus-newsgroup-limit))
4594 (setq gnus-tmp-gathered
4596 (lambda (h) (mail-header-number (car h)))
4599 (setq gnus-tmp-new-adopts (if (cdar thread)
4600 (append gnus-tmp-new-adopts
4602 gnus-tmp-new-adopts)
4604 gnus-tmp-header nil)
4605 (when (zerop gnus-tmp-level)
4606 (setq gnus-tmp-root-expunged t)))
4607 ;; Perhaps this article is to be marked as read?
4608 ((and gnus-summary-mark-below
4609 (< (or (cdr (assq number gnus-newsgroup-scored))
4611 gnus-summary-mark-below)
4612 ;; Don't touch sparse articles.
4613 (not (gnus-summary-article-sparse-p number))
4614 (not (gnus-summary-article-ancient-p number)))
4615 (setq gnus-newsgroup-unreads
4616 (delq number gnus-newsgroup-unreads))
4617 (if gnus-newsgroup-auto-expire
4618 (setq gnus-newsgroup-expirable
4619 (gnus-add-to-sorted-list
4620 gnus-newsgroup-expirable number))
4621 (push (cons number gnus-low-score-mark)
4622 gnus-newsgroup-reads))))
4624 (when gnus-tmp-header
4625 ;; We may have an old dummy line to output before this
4627 (when (and gnus-tmp-dummy-line
4630 (mail-header-subject gnus-tmp-header)))
4631 (gnus-summary-insert-dummy-line
4632 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4633 (setq gnus-tmp-dummy-line nil))
4635 ;; Compute the mark.
4636 (setq gnus-tmp-unread (gnus-article-mark number))
4638 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4639 gnus-tmp-header gnus-tmp-level)
4640 gnus-newsgroup-data)
4642 ;; Actually insert the line.
4644 gnus-tmp-subject-or-nil
4646 ((and gnus-thread-ignore-subject
4647 gnus-tmp-prev-subject
4648 (not (string= gnus-tmp-prev-subject simp-subject)))
4650 ((zerop gnus-tmp-level)
4651 (if (and (eq gnus-summary-make-false-root 'empty)
4652 (memq number gnus-tmp-gathered)
4653 gnus-tmp-prev-subject
4654 (string= gnus-tmp-prev-subject simp-subject))
4655 gnus-summary-same-subject
4657 (t gnus-summary-same-subject)))
4658 (if (and (eq gnus-summary-make-false-root 'adopt)
4659 (= gnus-tmp-level 1)
4660 (memq number gnus-tmp-gathered))
4661 (setq gnus-tmp-opening-bracket ?\<
4662 gnus-tmp-closing-bracket ?\>)
4663 (setq gnus-tmp-opening-bracket ?\[
4664 gnus-tmp-closing-bracket ?\]))
4666 gnus-tmp-indentation
4667 (aref gnus-thread-indent-array gnus-tmp-level)
4668 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4669 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4670 gnus-summary-default-score 0)
4672 (if (or (null gnus-summary-default-score)
4673 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4674 gnus-summary-zcore-fuzz))
4676 (if (< gnus-tmp-score gnus-summary-default-score)
4677 gnus-score-below-mark gnus-score-over-mark))
4679 (cond ((memq number gnus-newsgroup-processable)
4681 ((memq number gnus-newsgroup-cached)
4683 ((memq number gnus-newsgroup-replied)
4685 ((memq number gnus-newsgroup-forwarded)
4686 gnus-forwarded-mark)
4687 ((memq number gnus-newsgroup-saved)
4689 ((memq number gnus-newsgroup-recent)
4691 ((memq number gnus-newsgroup-unseen)
4694 gnus-tmp-from (mail-header-from gnus-tmp-header)
4697 ((string-match "<[^>]+> *$" gnus-tmp-from)
4698 (setq beg-match (match-beginning 0))
4699 (or (and (string-match "^\".+\"" gnus-tmp-from)
4700 (substring gnus-tmp-from 1 (1- (match-end 0))))
4701 (substring gnus-tmp-from 0 beg-match)))
4702 ((string-match "(.+)" gnus-tmp-from)
4703 (substring gnus-tmp-from
4704 (1+ (match-beginning 0)) (1- (match-end 0))))
4706 gnus-tmp-thread-tree-header-string
4708 ((not gnus-show-threads) "")
4709 ((zerop gnus-tmp-level)
4711 (or gnus-sum-thread-tree-root subject)
4712 (or gnus-sum-thread-tree-single-indent subject)))
4714 (concat (apply 'concat
4715 (mapcar (lambda (item)
4717 gnus-sum-thread-tree-vertical
4718 gnus-sum-thread-tree-indent))
4719 (cdr (reverse tree-stack))))
4721 gnus-sum-thread-tree-leaf-with-other
4722 gnus-sum-thread-tree-single-leaf)))))
4723 (when (string= gnus-tmp-name "")
4724 (setq gnus-tmp-name gnus-tmp-from))
4725 (unless (numberp gnus-tmp-lines)
4726 (setq gnus-tmp-lines -1))
4727 (if (= gnus-tmp-lines -1)
4728 (setq gnus-tmp-lines "?")
4729 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4730 (gnus-put-text-property
4732 (progn (eval gnus-summary-line-format-spec) (point))
4733 'gnus-number number)
4736 (gnus-run-hooks 'gnus-summary-update-hook)
4739 (setq gnus-tmp-prev-subject simp-subject)))
4741 (when (nth 1 thread)
4742 (push (list (max 0 gnus-tmp-level)
4743 (copy-list tree-stack)
4746 (push (if (nth 1 thread) 1 0) tree-stack)
4747 (incf gnus-tmp-level)
4748 (setq threads (if thread-end nil (cdar thread)))
4750 (setq gnus-tmp-level 0)))))
4751 (gnus-message 7 "Generating summary...done"))
4753 (defun gnus-summary-prepare-unthreaded (headers)
4754 "Generate an unthreaded summary buffer based on HEADERS."
4755 (let (header number mark)
4760 ;; We may have to root out some bad articles...
4761 (when (memq (setq number (mail-header-number
4762 (setq header (pop headers))))
4763 gnus-newsgroup-limit)
4764 ;; Mark article as read when it has a low score.
4765 (when (and gnus-summary-mark-below
4766 (< (or (cdr (assq number gnus-newsgroup-scored))
4767 gnus-summary-default-score 0)
4768 gnus-summary-mark-below)
4769 (not (gnus-summary-article-ancient-p number)))
4770 (setq gnus-newsgroup-unreads
4771 (delq number gnus-newsgroup-unreads))
4772 (if gnus-newsgroup-auto-expire
4773 (push number gnus-newsgroup-expirable)
4774 (push (cons number gnus-low-score-mark)
4775 gnus-newsgroup-reads)))
4777 (setq mark (gnus-article-mark number))
4778 (push (gnus-data-make number mark (1+ (point)) header 0)
4779 gnus-newsgroup-data)
4780 (gnus-summary-insert-line
4782 mark (memq number gnus-newsgroup-replied)
4783 (memq number gnus-newsgroup-expirable)
4784 (mail-header-subject header) nil
4785 (cdr (assq number gnus-newsgroup-scored))
4786 (memq number gnus-newsgroup-processable))))))
4788 (defun gnus-summary-remove-list-identifiers ()
4789 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4790 (let ((regexp (if (consp gnus-list-identifiers)
4791 (mapconcat 'identity gnus-list-identifiers " *\\|")
4792 gnus-list-identifiers))
4795 (dolist (header gnus-newsgroup-headers)
4796 (setq subject (mail-header-subject header)
4798 (while (string-match
4799 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4802 (concat (substring subject 0 (match-beginning 2))
4803 (substring subject (match-end 0)))
4807 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4809 (concat (substring subject 0 (match-beginning 1))
4810 (substring subject (match-end 1)))))
4812 (mail-header-set-subject header subject))))))
4814 (defun gnus-fetch-headers (articles)
4815 "Fetch headers of ARTICLES."
4816 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4817 (gnus-message 5 "Fetching headers for %s..." name)
4820 (setq gnus-headers-retrieved-by
4821 (gnus-retrieve-headers
4822 articles gnus-newsgroup-name
4823 ;; We might want to fetch old headers, but
4824 ;; not if there is only 1 article.
4826 (not (eq gnus-fetch-old-headers 'some))
4827 (not (numberp gnus-fetch-old-headers)))
4828 (> (length articles) 1))
4829 gnus-fetch-old-headers))))
4830 (gnus-get-newsgroup-headers-xover
4831 articles nil nil gnus-newsgroup-name t)
4832 (gnus-get-newsgroup-headers))
4833 (gnus-message 5 "Fetching headers for %s...done" name))))
4835 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4836 "Select newsgroup GROUP.
4837 If READ-ALL is non-nil, all articles in the group are selected.
4838 If SELECT-ARTICLES, only select those articles from GROUP."
4839 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4840 ;;!!! Dirty hack; should be removed.
4841 (gnus-summary-ignore-duplicates
4842 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4844 gnus-summary-ignore-duplicates))
4845 (info (nth 2 entry))
4846 articles fetched-articles cached)
4848 (unless (gnus-check-server
4849 (set (make-local-variable 'gnus-current-select-method)
4850 (gnus-find-method-for-group group)))
4851 (error "Couldn't open server"))
4853 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4854 (gnus-activate-group group) ; Or we can activate it...
4855 (progn ; Or we bug out.
4856 (when (equal major-mode 'gnus-summary-mode)
4857 (kill-buffer (current-buffer)))
4858 (error "Couldn't activate group %s: %s"
4859 group (gnus-status-message group))))
4861 (unless (gnus-request-group group t)
4862 (when (equal major-mode 'gnus-summary-mode)
4863 (kill-buffer (current-buffer)))
4864 (error "Couldn't request group %s: %s"
4865 group (gnus-status-message group)))
4867 (setq gnus-newsgroup-name group
4868 gnus-newsgroup-unselected nil
4869 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4871 (let ((display (gnus-group-find-parameter group 'display)))
4872 (setq gnus-newsgroup-display
4874 ((not (zerop (or (car-safe read-all) 0)))
4875 ;; The user entered the group with C-u SPC/RET, let's show
4881 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4883 ;; The following is probably the "correct" solution, but
4884 ;; it makes Gnus fetch all headers and then limit the
4885 ;; articles (which is slow), so instead we hack the
4886 ;; select-articles parameter instead. -- Simon Josefsson
4889 ;; (gnus-byte-compile
4890 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4892 (setq select-articles
4893 (gnus-uncompress-range
4894 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4898 (cdr (gnus-active group)))))
4903 (gnus-summary-setup-default-charset)
4905 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4906 (when (gnus-virtual-group-p group)
4907 (setq cached gnus-newsgroup-cached))
4909 (setq gnus-newsgroup-unreads
4910 (gnus-sorted-ndifference
4911 (gnus-sorted-ndifference gnus-newsgroup-unreads
4912 gnus-newsgroup-marked)
4913 gnus-newsgroup-dormant))
4915 (setq gnus-newsgroup-processable nil)
4917 (gnus-update-read-articles group gnus-newsgroup-unreads)
4919 ;; Adjust and set lists of article marks.
4921 (gnus-adjust-marked-articles info))
4922 (if (setq articles select-articles)
4923 (setq gnus-newsgroup-unselected
4924 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4925 (setq articles (gnus-articles-to-read group read-all)))
4929 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4931 ((eq articles 0) nil)
4933 ;; Init the dependencies hash table.
4934 (setq gnus-newsgroup-dependencies
4935 (gnus-make-hashtable (length articles)))
4936 (gnus-set-global-variables)
4937 ;; Retrieve the headers and read them in.
4939 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4941 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4943 (setq gnus-newsgroup-cached cached))
4945 ;; Suppress duplicates?
4946 (when gnus-suppress-duplicates
4947 (gnus-dup-suppress-articles))
4949 ;; Set the initial limit.
4950 (setq gnus-newsgroup-limit (copy-sequence articles))
4951 ;; Remove canceled articles from the list of unread articles.
4952 (setq fetched-articles
4953 (mapcar (lambda (headers) (mail-header-number headers))
4954 gnus-newsgroup-headers))
4955 (setq gnus-newsgroup-articles fetched-articles)
4956 (setq gnus-newsgroup-unreads
4957 (gnus-sorted-nintersection
4958 gnus-newsgroup-unreads fetched-articles))
4959 (gnus-compute-unseen-list)
4961 ;; Removed marked articles that do not exist.
4962 (gnus-update-missing-marks
4963 (gnus-sorted-difference articles fetched-articles))
4964 ;; We might want to build some more threads first.
4965 (when (and gnus-fetch-old-headers
4966 (eq gnus-headers-retrieved-by 'nov))
4967 (if (eq gnus-fetch-old-headers 'invisible)
4968 (gnus-build-all-threads)
4969 (gnus-build-old-threads)))
4970 ;; Let the Gnus agent mark articles as read.
4972 (gnus-agent-get-undownloaded-list))
4973 ;; Remove list identifiers from subject
4974 (when gnus-list-identifiers
4975 (gnus-summary-remove-list-identifiers))
4976 ;; Check whether auto-expire is to be done in this group.
4977 (setq gnus-newsgroup-auto-expire
4978 (gnus-group-auto-expirable-p group))
4979 ;; Set up the article buffer now, if necessary.
4980 (unless gnus-single-article-buffer
4981 (gnus-article-setup-buffer))
4982 ;; First and last article in this newsgroup.
4983 (when gnus-newsgroup-headers
4984 (setq gnus-newsgroup-begin
4985 (mail-header-number (car gnus-newsgroup-headers))
4988 (gnus-last-element gnus-newsgroup-headers))))
4989 ;; GROUP is successfully selected.
4990 (or gnus-newsgroup-headers t)))))
4992 (defun gnus-compute-unseen-list ()
4993 ;; The `seen' marks are treated specially.
4994 (if (not gnus-newsgroup-seen)
4995 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4996 (setq gnus-newsgroup-unseen
4997 (gnus-inverse-list-range-intersection
4998 gnus-newsgroup-articles gnus-newsgroup-seen))))
5000 (defun gnus-summary-display-make-predicate (display)
5001 (require 'gnus-agent)
5002 (when (= (length display) 1)
5003 (setq display (car display)))
5004 (unless gnus-summary-display-cache
5005 (dolist (elem (append '((unread . unread)
5008 gnus-article-mark-lists))
5009 (push (cons (cdr elem)
5011 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5012 gnus-summary-display-cache)))
5013 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5014 (gnus-category-predicate-cache gnus-summary-display-cache))
5015 (gnus-get-predicate display)))
5017 ;; Uses the dynamically bound `number' variable.
5019 (defun gnus-article-marked-p (type &optional article)
5020 (let ((article (or article number)))
5023 (memq article gnus-newsgroup-marked))
5025 (memq article gnus-newsgroup-spam-marked))
5027 (memq article gnus-newsgroup-unsendable))
5028 ((eq type 'undownload)
5029 (memq article gnus-newsgroup-undownloaded))
5030 ((eq type 'download)
5031 (memq article gnus-newsgroup-downloadable))
5033 (memq article gnus-newsgroup-unreads))
5035 (memq article gnus-newsgroup-reads))
5037 (memq article gnus-newsgroup-dormant) )
5039 (memq article gnus-newsgroup-expirable))
5041 (memq article gnus-newsgroup-replied))
5043 (memq article gnus-newsgroup-killed))
5044 ((eq type 'bookmark)
5045 (assq article gnus-newsgroup-bookmarks))
5047 (assq article gnus-newsgroup-scored))
5049 (memq article gnus-newsgroup-saved))
5051 (memq article gnus-newsgroup-cached))
5053 (memq article gnus-newsgroup-forwarded))
5055 (not (memq article gnus-newsgroup-unseen)))
5057 (memq article gnus-newsgroup-recent))
5060 (defun gnus-articles-to-read (group &optional read-all)
5061 "Find out what articles the user wants to read."
5063 ;; Select all articles if `read-all' is non-nil, or if there
5064 ;; are no unread articles.
5066 (and (zerop (length gnus-newsgroup-marked))
5067 (zerop (length gnus-newsgroup-unreads)))
5068 ;; Fetch all if the predicate is non-nil.
5069 gnus-newsgroup-display)
5070 ;; We want to select the headers for all the articles in
5071 ;; the group, so we select either all the active
5072 ;; articles in the group, or (if that's nil), the
5073 ;; articles in the cache.
5075 (gnus-uncompress-range (gnus-active group))
5076 (gnus-cache-articles-in-group group))
5077 ;; Select only the "normal" subset of articles.
5079 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5080 gnus-newsgroup-unreads)))
5081 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5082 (scored (length scored-list))
5083 (number (length articles))
5084 (marked (+ (length gnus-newsgroup-marked)
5085 (length gnus-newsgroup-dormant)))
5090 ((numberp gnus-newsgroup-display)
5091 gnus-newsgroup-display)
5095 ((and (or (<= scored marked) (= scored number))
5096 (numberp gnus-large-newsgroup)
5097 (> number gnus-large-newsgroup))
5098 (let* ((cursor-in-echo-area nil)
5099 (initial (gnus-parameter-large-newsgroup-initial
5100 gnus-newsgroup-name))
5104 "How many articles from %s (%s %d): "
5106 (gnus-group-decoded-name gnus-newsgroup-name)
5108 (if initial "max" "default")
5111 (cons (number-to-string initial)
5113 (if (string-match "^[ \t]*$" input) number input)))
5114 ((and (> scored marked) (< scored number)
5115 (> (- scored number) 20))
5118 (format "%s %s (%d scored, %d total): "
5119 "How many articles from"
5120 (gnus-group-decoded-name group)
5122 (if (string-match "^[ \t]*$" input)
5126 (message "Quit getting the articles to read")
5128 (setq select (if (stringp select) (string-to-number select) select))
5129 (if (or (null select) (zerop select))
5131 (if (and (not (zerop scored)) (<= (abs select) scored))
5133 (setq articles (sort scored-list '<))
5134 (setq number (length articles)))
5135 (setq articles (copy-sequence articles)))
5137 (when (< (abs select) number)
5139 ;; Select the N oldest articles.
5140 (setcdr (nthcdr (1- (abs select)) articles) nil)
5141 ;; Select the N most recent articles.
5142 (setq articles (nthcdr (- number select) articles))))
5143 (setq gnus-newsgroup-unselected
5144 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5145 (when gnus-alter-articles-to-read-function
5146 (setq gnus-newsgroup-unreads
5148 (funcall gnus-alter-articles-to-read-function
5149 gnus-newsgroup-name gnus-newsgroup-unreads)
5153 (defun gnus-killed-articles (killed articles)
5156 (when (inline (gnus-member-of-range (car articles) killed))
5157 (push (car articles) out))
5158 (setq articles (cdr articles)))
5161 (defun gnus-uncompress-marks (marks)
5162 "Uncompress the mark ranges in MARKS."
5163 (let ((uncompressed '(score bookmark))
5166 (if (memq (caar marks) uncompressed)
5167 (push (car marks) out)
5168 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5169 (setq marks (cdr marks)))
5172 (defun gnus-article-mark-to-type (mark)
5173 "Return the type of MARK."
5174 (or (cadr (assq mark gnus-article-special-mark-lists))
5177 (defun gnus-article-unpropagatable-p (mark)
5178 "Return whether MARK should be propagated to backend."
5179 (memq mark gnus-article-unpropagated-mark-lists))
5181 (defun gnus-adjust-marked-articles (info)
5182 "Set all article lists and remove all marks that are no longer valid."
5183 (let* ((marked-lists (gnus-info-marks info))
5184 (active (gnus-active (gnus-info-group info)))
5187 (types gnus-article-mark-lists)
5188 marks var articles article mark mark-type)
5190 (dolist (marks marked-lists)
5191 (setq mark (car marks)
5192 mark-type (gnus-article-mark-to-type mark)
5193 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5195 ;; We set the variable according to the type of the marks list,
5196 ;; and then adjust the marks to a subset of the active articles.
5198 ;; Adjust "simple" lists.
5199 ((eq mark-type 'list)
5200 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5201 (when (memq mark '(tick dormant expire reply save))
5203 (when (or (< (setq article (pop articles)) min) (> article max))
5204 (set var (delq article (symbol-value var)))))))
5206 ((eq mark-type 'tuple)
5207 (set var (setq articles (cdr marks)))
5208 (when (not (listp (cdr (symbol-value var))))
5209 (set var (list (symbol-value var))))
5210 (when (not (listp (cdr articles)))
5211 (setq articles (list articles)))
5213 (when (or (not (consp (setq article (pop articles))))
5214 (< (car article) min)
5215 (> (car article) max))
5216 (set var (delq article (symbol-value var))))))
5217 ;; Adjust ranges (sloppily).
5218 ((eq mark-type 'range)
5221 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5222 ;; It should be (seen (NUM1 . NUM2)).
5223 (when (numberp (cddr marks))
5224 (setcdr marks (list (cdr marks))))
5225 (setq articles (cdr marks))
5226 (while (and articles
5227 (or (and (consp (car articles))
5228 (> min (cdar articles)))
5229 (and (numberp (car articles))
5230 (> min (car articles)))))
5232 (set var articles))))))))
5234 (defun gnus-update-missing-marks (missing)
5235 "Go through the list of MISSING articles and remove them from the mark lists."
5238 ;; Go through all types.
5239 (dolist (elem gnus-article-mark-lists)
5240 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5241 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5242 (when (symbol-value var)
5243 ;; This list has articles. So we delete all missing
5244 ;; articles from it.
5247 (set var (delq (pop m) (symbol-value var))))))))))
5249 (defun gnus-update-marks ()
5250 "Enter the various lists of marked articles into the newsgroup info list."
5251 (let ((types gnus-article-mark-lists)
5252 (info (gnus-get-info gnus-newsgroup-name))
5253 type list newmarked symbol delta-marks)
5255 ;; Add all marks lists to the list of marks lists.
5256 (while (setq type (pop types))
5257 (setq list (symbol-value
5259 (intern (format "gnus-newsgroup-%s" (car type))))))
5262 ;; Get rid of the entries of the articles that have the
5264 (when (and (eq (cdr type) 'score)
5268 (prev (cons nil list))
5271 (if (or (not (consp (car arts)))
5272 (= (cdar arts) gnus-summary-default-score))
5273 (setcdr prev (cdr arts))
5275 (setq arts (cdr arts)))
5276 (setq list (cdr all)))))
5278 (when (eq (cdr type) 'seen)
5279 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5281 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5282 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5284 (when (and (gnus-check-backend-function
5285 'request-set-mark gnus-newsgroup-name)
5286 (not (gnus-article-unpropagatable-p (cdr type))))
5287 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5288 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5289 (add (gnus-remove-from-range
5290 (gnus-copy-sequence list) old)))
5292 (push (list add 'add (list (cdr type))) delta-marks))
5294 (push (list del 'del (list (cdr type))) delta-marks))))
5297 (push (cons (cdr type) list) newmarked)))
5300 (unless (gnus-check-group gnus-newsgroup-name)
5301 (error "Can't open server for %s" gnus-newsgroup-name))
5302 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5304 ;; Enter these new marks into the info of the group.
5306 (setcar (nthcdr 3 info) newmarked)
5307 ;; Add the marks lists to the end of the info.
5309 (setcdr (nthcdr 2 info) (list newmarked))))
5311 ;; Cut off the end of the info if there's nothing else there.
5315 (when (nthcdr (decf i) info)
5316 (setcdr (nthcdr i info) nil)))))))
5318 (defun gnus-set-mode-line (where)
5319 "Set the mode line of the article or summary buffers.
5320 If WHERE is `summary', the summary mode line format will be used."
5321 ;; Is this mode line one we keep updated?
5322 (when (and (memq where gnus-updated-mode-lines)
5324 (intern (format "gnus-%s-mode-line-format-spec" where))))
5327 ;; We evaluate this in the summary buffer since these
5328 ;; variables are buffer-local to that buffer.
5329 (set-buffer gnus-summary-buffer)
5330 ;; We bind all these variables that are used in the `eval' form
5332 (let* ((mformat (symbol-value
5334 (format "gnus-%s-mode-line-format-spec" where))))
5335 (gnus-tmp-group-name (gnus-group-decoded-name
5336 gnus-newsgroup-name))
5337 (gnus-tmp-article-number (or gnus-current-article 0))
5338 (gnus-tmp-unread gnus-newsgroup-unreads)
5339 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5340 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5341 (gnus-tmp-unread-and-unselected
5342 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5343 (zerop gnus-tmp-unselected))
5345 ((zerop gnus-tmp-unselected)
5346 (format "{%d more}" gnus-tmp-unread-and-unticked))
5347 (t (format "{%d(+%d) more}"
5348 gnus-tmp-unread-and-unticked
5349 gnus-tmp-unselected))))
5351 (if (and gnus-current-headers
5352 (vectorp gnus-current-headers))
5353 (gnus-mode-string-quote
5354 (mail-header-subject gnus-current-headers))
5356 bufname-length max-len
5357 gnus-tmp-header);; passed as argument to any user-format-funcs
5358 (setq mode-string (eval mformat))
5359 (setq bufname-length (if (string-match "%b" mode-string)
5362 (if (eq where 'summary)
5364 (get-buffer gnus-article-buffer))))
5367 (setq max-len (max 4 (if gnus-mode-non-string-length
5369 gnus-mode-non-string-length
5371 (length mode-string))))
5372 ;; We might have to chop a bit of the string off...
5373 (when (> (length mode-string) max-len)
5375 (concat (gnus-truncate-string mode-string (- max-len 3))
5377 ;; Pad the mode string a bit.
5378 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5379 ;; Update the mode line.
5380 (setq mode-line-buffer-identification
5381 (gnus-mode-line-buffer-identification (list mode-string)))
5382 (set-buffer-modified-p t))))
5384 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5385 "Go through the HEADERS list and add all Xrefs to a hash table.
5386 The resulting hash table is returned, or nil if no Xrefs were found."
5387 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5388 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5389 (xref-hashtb (gnus-make-hashtable))
5390 start group entry number xrefs header)
5392 (setq header (pop headers))
5393 (when (and (setq xrefs (mail-header-xref header))
5394 (not (memq (setq number (mail-header-number header))
5397 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5398 (setq start (match-end 0))
5399 (setq group (if prefix
5400 (concat prefix (substring xrefs (match-beginning 1)
5402 (substring xrefs (match-beginning 1) (match-end 1))))
5404 (string-to-int (substring xrefs (match-beginning 2)
5406 (if (setq entry (gnus-gethash group xref-hashtb))
5407 (setcdr entry (cons number (cdr entry)))
5408 (gnus-sethash group (cons number nil) xref-hashtb)))))
5409 (and start xref-hashtb)))
5411 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5412 "Look through all the headers and mark the Xrefs as read."
5413 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5414 name entry info xref-hashtb idlist method nth4)
5416 (set-buffer gnus-group-buffer)
5417 (when (setq xref-hashtb
5418 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5421 (unless (string= from-newsgroup (setq name (symbol-name group)))
5422 (setq idlist (symbol-value group))
5423 ;; Dead groups are not updated.
5425 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5427 (when (stringp (setq nth4 (gnus-info-method info)))
5428 (setq nth4 (gnus-server-to-method nth4))))
5429 ;; Only do the xrefs if the group has the same
5430 ;; select method as the group we have just read.
5431 (or (gnus-methods-equal-p
5432 nth4 (gnus-find-method-for-group from-newsgroup))
5434 (equal nth4 (setq method (gnus-find-method-for-group
5436 (and (equal (car nth4) (car method))
5437 (equal (nth 1 nth4) (nth 1 method))))
5438 gnus-use-cross-reference
5439 (or (not (eq gnus-use-cross-reference t))
5441 ;; Only do cross-references on subscribed
5442 ;; groups, if that is what is wanted.
5443 (<= (gnus-info-level info) gnus-level-subscribed))
5444 (gnus-group-make-articles-read name idlist))))
5447 (defun gnus-compute-read-articles (group articles)
5448 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5449 (info (nth 2 entry))
5450 (active (gnus-active group))
5453 ;; First peel off all invalid article numbers.
5455 (let ((ids articles)
5457 (while (setq id (pop ids))
5458 (when (and first (> id (cdr active)))
5459 ;; We'll end up in this situation in one particular
5460 ;; obscure situation. If you re-scan a group and get
5461 ;; a new article that is cross-posted to a different
5462 ;; group that has not been re-scanned, you might get
5463 ;; crossposted article that has a higher number than
5464 ;; Gnus believes possible. So we re-activate this
5465 ;; group as well. This might mean doing the
5466 ;; crossposting thingy will *increase* the number
5467 ;; of articles in some groups. Tsk, tsk.
5468 (setq active (or (gnus-activate-group group) active)))
5469 (when (or (> id (cdr active))
5470 (< id (car active)))
5471 (setq articles (delq id articles))))))
5472 ;; If the read list is nil, we init it.
5474 (null (gnus-info-read info))
5476 (setq ninfo (cons 1 (1- (car active))))
5477 (setq ninfo (gnus-info-read info)))
5478 ;; Then we add the read articles to the range.
5480 ninfo (setq articles (sort articles '<))))))
5482 (defun gnus-group-make-articles-read (group articles)
5483 "Update the info of GROUP to say that ARTICLES are read."
5485 (entry (gnus-gethash group gnus-newsrc-hashtb))
5486 (info (nth 2 entry))
5487 (active (gnus-active group))
5490 (setq range (gnus-compute-read-articles group articles))
5492 (set-buffer gnus-group-buffer)
5495 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5496 (gnus-info-set-read ',info ',(gnus-info-read info))
5497 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5498 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5499 (gnus-group-update-group ,group t))))
5500 ;; Add the read articles to the range.
5501 (gnus-info-set-read info range)
5502 (gnus-request-set-mark group (list (list range 'add '(read))))
5503 ;; Then we have to re-compute how many unread
5504 ;; articles there are in this group.
5508 (setq num (- (1+ (cdr active)) (car active))))
5509 ((not (listp (cdr range)))
5510 (setq num (- (cdr active) (- (1+ (cdr range))
5514 (if (numberp (car range))
5516 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5517 (setq range (cdr range)))
5518 (setq num (- (cdr active) num))))
5519 ;; Update the number of unread articles.
5521 ;; Update the group buffer.
5522 (gnus-group-update-group group t)))))
5524 (defvar gnus-newsgroup-none-id 0)
5526 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5527 (let ((cur nntp-server-buffer)
5530 (save-excursion (set-buffer gnus-summary-buffer)
5531 gnus-newsgroup-dependencies)))
5533 (mail-parse-charset gnus-newsgroup-charset)
5534 (mail-parse-ignored-charsets
5535 (save-excursion (condition-case nil
5536 (set-buffer gnus-summary-buffer)
5538 gnus-newsgroup-ignored-charsets)))
5540 (set-buffer nntp-server-buffer)
5541 ;; Translate all TAB characters into SPACE characters.
5542 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5543 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5544 (gnus-run-hooks 'gnus-parse-headers-hook)
5545 (let ((case-fold-search t)
5546 in-reply-to header p lines chars ctype)
5547 (goto-char (point-min))
5548 ;; Search to the beginning of the next header. Error messages
5549 ;; do not begin with 2 or 3.
5550 (while (re-search-forward "^[23][0-9]+ " nil t)
5553 ;; This implementation of this function, with nine
5554 ;; search-forwards instead of the one re-search-forward and
5555 ;; a case (which basically was the old function) is actually
5556 ;; about twice as fast, even though it looks messier. You
5557 ;; can't have everything, I guess. Speed and elegance
5558 ;; doesn't always go hand in hand.
5561 (make-full-mail-header
5567 (narrow-to-region (point)
5568 (or (and (search-forward "\n.\n" nil t)
5574 (if (search-forward "\nsubject:" nil t)
5575 (nnheader-header-value)
5580 (if (search-forward "\nfrom:" nil t)
5581 (nnheader-header-value)
5586 (if (search-forward "\ndate:" nil t)
5587 (nnheader-header-value) ""))
5591 (setq id (if (re-search-forward
5592 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5593 ;; We do it this way to make sure the Message-ID
5594 ;; is (somewhat) syntactically valid.
5595 (buffer-substring (match-beginning 1)
5597 ;; If there was no message-id, we just fake one
5598 ;; to make subsequent routines simpler.
5599 (nnheader-generate-fake-message-id))))
5603 (if (search-forward "\nreferences:" nil t)
5607 (nnheader-header-value)
5612 (search-backward ">" end t)
5615 (search-backward "<" end t)
5617 ;; Get the references from the in-reply-to header if there
5618 ;; were no references and the in-reply-to header looks
5620 (if (and (search-forward "\nin-reply-to:" nil t)
5621 (setq in-reply-to (nnheader-header-value))
5622 (string-match "<[^>]+>" in-reply-to))
5624 (setq ref (substring in-reply-to (match-beginning 0)
5626 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5627 (setq ref2 (substring in-reply-to (match-beginning 0)
5629 (when (> (length ref2) (length ref))
5636 (if (search-forward "\nchars: " nil t)
5637 (if (numberp (setq chars (ignore-errors (read cur))))
5643 (if (search-forward "\nlines: " nil t)
5644 (if (numberp (setq lines (ignore-errors (read cur))))
5650 (and (search-forward "\nxref:" nil t)
5651 (nnheader-header-value)))
5653 (when gnus-extra-headers
5654 (let ((extra gnus-extra-headers)
5658 (when (search-forward
5659 (concat "\n" (symbol-name (car extra)) ":") nil t)
5660 (push (cons (car extra) (nnheader-header-value)) out))
5664 (if (and (search-forward "\ncontent-type: " nil t)
5665 (setq ctype (nnheader-header-value)))
5666 (mime-entity-set-content-type-internal
5667 header (mime-parse-Content-Type ctype)))
5668 (when (equal id ref)
5671 (when gnus-alter-header-function
5672 (funcall gnus-alter-header-function header)
5673 (setq id (mail-header-id header)
5674 ref (gnus-parent-id (mail-header-references header))))
5677 (gnus-dependencies-add-header
5678 header dependencies force-new))
5679 (push header headers))
5680 (goto-char (point-max))
5682 (nreverse headers)))))
5684 ;; Goes through the xover lines and returns a list of vectors
5685 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5686 force-new dependencies
5687 group also-fetch-heads)
5688 "Parse the news overview data in the server buffer.
5689 Return a list of headers that match SEQUENCE (see
5690 `nntp-retrieve-headers')."
5691 ;; Get the Xref when the users reads the articles since most/some
5692 ;; NNTP servers do not include Xrefs when using XOVER.
5693 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5694 (let ((mail-parse-charset gnus-newsgroup-charset)
5695 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5696 (cur nntp-server-buffer)
5697 (dependencies (or dependencies gnus-newsgroup-dependencies))
5699 ((eq gnus-read-all-available-headers t)
5701 ((stringp gnus-read-all-available-headers)
5702 (string-match gnus-read-all-available-headers group))
5705 number headers header)
5707 (set-buffer nntp-server-buffer)
5708 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5709 ;; Allow the user to mangle the headers before parsing them.
5710 (gnus-run-hooks 'gnus-parse-headers-hook)
5711 (goto-char (point-min))
5712 (gnus-parse-without-error
5713 (while (and (or sequence allp)
5715 (setq number (read cur))
5717 (while (and sequence
5718 (< (car sequence) number))
5719 (setq sequence (cdr sequence))))
5722 (eq number (car sequence))))
5724 (setq sequence (cdr sequence))
5725 (setq header (inline
5726 (gnus-nov-parse-line
5727 number dependencies force-new)))))
5728 (push header headers))
5730 ;; A common bug in inn is that if you have posted an article and
5731 ;; then retrieves the active file, it will answer correctly --
5732 ;; the new article is included. However, a NOV entry for the
5733 ;; article may not have been generated yet, so this may fail.
5734 ;; We work around this problem by retrieving the last few
5735 ;; headers using HEAD.
5736 (if (or (not also-fetch-heads)
5738 ;; We (probably) got all the headers.
5740 (let ((gnus-nov-is-evil t))
5743 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5744 (gnus-get-newsgroup-headers))))))))
5746 (defun gnus-article-get-xrefs ()
5747 "Fill in the Xref value in `gnus-current-headers', if necessary.
5748 This is meant to be called in `gnus-article-internal-prepare-hook'."
5749 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5750 gnus-current-headers)))
5751 (or (not gnus-use-cross-reference)
5753 (and (mail-header-xref headers)
5754 (not (string= (mail-header-xref headers) "")))
5755 (let ((case-fold-search t)
5758 (nnheader-narrow-to-headers)
5759 (goto-char (point-min))
5760 (when (or (and (not (eobp))
5761 (eq (downcase (char-after)) ?x)
5762 (looking-at "Xref:"))
5763 (search-forward "\nXref:" nil t))
5764 (goto-char (1+ (match-end 0)))
5765 (setq xref (buffer-substring (point)
5766 (progn (end-of-line) (point))))
5767 (mail-header-set-xref headers xref)))))))
5769 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5770 "Find article ID and insert the summary line for that article.
5771 OLD-HEADER can either be a header or a line number to insert
5772 the subject line on."
5773 (let* ((line (and (numberp old-header) old-header))
5774 (old-header (and (vectorp old-header) old-header))
5775 (header (cond ((and old-header use-old-header)
5778 (gnus-number-to-header id))
5779 (gnus-number-to-header id))
5781 (gnus-read-header id))))
5782 (number (and (numberp id) id))
5785 ;; Rebuild the thread that this article is part of and go to the
5786 ;; article we have fetched.
5787 (when (and (not gnus-show-threads)
5790 (setq d (gnus-data-find (mail-header-number old-header))))
5791 (goto-char (gnus-data-pos d))
5794 (- (gnus-point-at-bol)
5796 (1+ (gnus-point-at-eol))
5797 (gnus-delete-line))))))
5799 (mail-header-set-number header (mail-header-number old-header)))
5800 (setq gnus-newsgroup-sparse
5801 (delq (setq number (mail-header-number header))
5802 gnus-newsgroup-sparse))
5803 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5804 (push number gnus-newsgroup-limit)
5805 (gnus-rebuild-thread (mail-header-id header) line)
5806 (gnus-summary-goto-subject number nil t))
5807 (when (and (numberp number)
5809 ;; We have to update the boundaries even if we can't fetch the
5810 ;; article if ID is a number -- so that the next `P' or `N'
5811 ;; command will fetch the previous (or next) article even
5812 ;; if the one we tried to fetch this time has been canceled.
5813 (when (> number gnus-newsgroup-end)
5814 (setq gnus-newsgroup-end number))
5815 (when (< number gnus-newsgroup-begin)
5816 (setq gnus-newsgroup-begin number))
5817 (setq gnus-newsgroup-unselected
5818 (delq number gnus-newsgroup-unselected)))
5819 ;; Report back a success?
5820 (and header (mail-header-number header))))
5822 ;;; Process/prefix in the summary buffer
5824 (defun gnus-summary-work-articles (n)
5825 "Return a list of articles to be worked upon.
5826 The prefix argument, the list of process marked articles, and the
5827 current article will be taken into consideration."
5829 (set-buffer gnus-summary-buffer)
5832 ;; A numerical prefix has been given.
5833 (setq n (prefix-numeric-value n))
5834 (let ((backward (< n 0))
5835 (n (abs (prefix-numeric-value n)))
5840 (push (setq article (gnus-summary-article-number))
5843 (gnus-summary-find-prev nil article)
5844 (gnus-summary-find-next nil article)))
5846 (nreverse articles)))
5847 ((and (gnus-region-active-p) (mark))
5848 (message "region active")
5849 ;; Work on the region between point and mark.
5850 (let ((max (max (point) (mark)))
5853 (goto-char (min (point) (mark)))
5856 (push (setq article (gnus-summary-article-number)) articles)
5857 (gnus-summary-find-next nil article)
5859 (nreverse articles))))
5860 (gnus-newsgroup-processable
5861 ;; There are process-marked articles present.
5862 ;; Save current state.
5863 (gnus-summary-save-process-mark)
5865 (reverse gnus-newsgroup-processable))
5867 ;; Just return the current article.
5868 (list (gnus-summary-article-number))))))
5870 (defmacro gnus-summary-iterate (arg &rest forms)
5871 "Iterate over the process/prefixed articles and do FORMS.
5872 ARG is the interactive prefix given to the command. FORMS will be
5873 executed with point over the summary line of the articles."
5874 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5875 `(let ((,articles (gnus-summary-work-articles ,arg)))
5877 (gnus-summary-goto-subject (car ,articles))
5881 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5882 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5884 (defun gnus-summary-save-process-mark ()
5885 "Push the current set of process marked articles on the stack."
5887 (push (copy-sequence gnus-newsgroup-processable)
5888 gnus-newsgroup-process-stack))
5890 (defun gnus-summary-kill-process-mark ()
5891 "Push the current set of process marked articles on the stack and unmark."
5893 (gnus-summary-save-process-mark)
5894 (gnus-summary-unmark-all-processable))
5896 (defun gnus-summary-yank-process-mark ()
5897 "Pop the last process mark state off the stack and restore it."
5899 (unless gnus-newsgroup-process-stack
5900 (error "Empty mark stack"))
5901 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5903 (defun gnus-summary-process-mark-set (set)
5904 "Make SET into the current process marked articles."
5905 (gnus-summary-unmark-all-processable)
5907 (gnus-summary-set-process-mark (pop set))))
5909 ;;; Searching and stuff
5911 (defun gnus-summary-search-group (&optional backward use-level)
5912 "Search for next unread newsgroup.
5913 If optional argument BACKWARD is non-nil, search backward instead."
5915 (set-buffer gnus-group-buffer)
5916 (when (gnus-group-search-forward
5917 backward nil (if use-level (gnus-group-group-level) nil))
5918 (gnus-group-group-name))))
5920 (defun gnus-summary-best-group (&optional exclude-group)
5921 "Find the name of the best unread group.
5922 If EXCLUDE-GROUP, do not go to this group."
5924 (set-buffer gnus-group-buffer)
5926 (gnus-group-best-unread-group exclude-group))))
5928 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5929 (if backward (gnus-summary-find-prev)
5930 (let* ((dummy (gnus-summary-article-intangible-p))
5931 (article (or article (gnus-summary-article-number)))
5932 (arts (gnus-data-find-list article))
5934 (when (and (not dummy)
5935 (or (not gnus-summary-check-current)
5937 (not (gnus-data-unread-p (car arts)))))
5938 (setq arts (cdr arts)))
5943 (when (or (and undownloaded
5944 (eq gnus-undownloaded-mark
5945 (gnus-data-mark (car arts))))
5946 (gnus-data-unread-p (car arts)))
5947 (setq result (car arts)
5949 (setq arts (cdr arts)))
5952 (goto-char (gnus-data-pos result))
5953 (gnus-data-number result)))))
5955 (defun gnus-summary-find-prev (&optional unread article)
5956 (let* ((eobp (eobp))
5957 (article (or article (gnus-summary-article-number)))
5958 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5960 (when (and (not eobp)
5961 (or (not gnus-summary-check-current)
5963 (not (gnus-data-unread-p (car arts)))))
5964 (setq arts (cdr arts)))
5969 (when (gnus-data-unread-p (car arts))
5970 (setq result (car arts)
5972 (setq arts (cdr arts)))
5975 (goto-char (gnus-data-pos result))
5976 (gnus-data-number result))))
5978 (defun gnus-summary-find-subject (subject &optional unread backward article)
5979 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5980 (article (or article (gnus-summary-article-number)))
5981 (articles (gnus-data-list backward))
5982 (arts (gnus-data-find-list article articles))
5984 (when (or (not gnus-summary-check-current)
5986 (not (gnus-data-unread-p (car arts))))
5987 (setq arts (cdr arts)))
5989 (and (or (not unread)
5990 (gnus-data-unread-p (car arts)))
5991 (vectorp (gnus-data-header (car arts)))
5993 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5994 (setq result (car arts)
5996 (setq arts (cdr arts)))
5998 (goto-char (gnus-data-pos result))
5999 (gnus-data-number result))))
6001 (defun gnus-summary-search-forward (&optional unread subject backward)
6002 "Search forward for an article.
6003 If UNREAD, look for unread articles. If SUBJECT, look for
6004 articles with that subject. If BACKWARD, search backward instead."
6005 (cond (subject (gnus-summary-find-subject subject unread backward))
6006 (backward (gnus-summary-find-prev unread))
6007 (t (gnus-summary-find-next unread))))
6009 (defun gnus-recenter (&optional n)
6010 "Center point in window and redisplay frame.
6011 Also do horizontal recentering."
6013 (when (and gnus-auto-center-summary
6014 (not (eq gnus-auto-center-summary 'vertical)))
6015 (gnus-horizontal-recenter))
6018 (defun gnus-summary-recenter ()
6019 "Center point in the summary window.
6020 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6021 displayed, no centering will be performed."
6022 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6023 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6025 (let* ((top (cond ((< (window-height) 4) 0)
6026 ((< (window-height) 7) 1)
6027 (t (if (numberp gnus-auto-center-summary)
6028 gnus-auto-center-summary
6030 (height (1- (window-height)))
6031 (bottom (save-excursion (goto-char (point-max))
6032 (forward-line (- height))
6034 (window (get-buffer-window (current-buffer))))
6035 ;; The user has to want it.
6036 (when gnus-auto-center-summary
6037 (when (get-buffer-window gnus-article-buffer)
6038 ;; Only do recentering when the article buffer is displayed,
6039 ;; Set the window start to either `bottom', which is the biggest
6040 ;; possible valid number, or the second line from the top,
6041 ;; whichever is the least.
6042 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6043 (if (> bottom top-pos)
6044 ;; Keep the second line from the top visible
6045 (set-window-start window top-pos t)
6046 ;; Try to keep the bottom line visible; if it's partially
6047 ;; obscured, either scroll one more line to make it fully
6048 ;; visible, or revert to using TOP-POS.
6050 (goto-char (point-max))
6052 (let ((last-line-start (point)))
6054 (set-window-start window (point) t)
6055 (when (not (pos-visible-in-window-p last-line-start window))
6057 (set-window-start window (min (point) top-pos) t)))))))
6058 ;; Do horizontal recentering while we're at it.
6059 (when (and (get-buffer-window (current-buffer) t)
6060 (not (eq gnus-auto-center-summary 'vertical)))
6061 (let ((selected (selected-window)))
6062 (select-window (get-buffer-window (current-buffer) t))
6063 (gnus-summary-position-point)
6064 (gnus-horizontal-recenter)
6065 (select-window selected))))))
6067 (defun gnus-summary-jump-to-group (newsgroup)
6068 "Move point to NEWSGROUP in group mode buffer."
6069 ;; Keep update point of group mode buffer if visible.
6070 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6071 (save-window-excursion
6072 ;; Take care of tree window mode.
6073 (when (get-buffer-window gnus-group-buffer)
6074 (pop-to-buffer gnus-group-buffer))
6075 (gnus-group-jump-to-group newsgroup))
6077 ;; Take care of tree window mode.
6078 (if (get-buffer-window gnus-group-buffer)
6079 (pop-to-buffer gnus-group-buffer)
6080 (set-buffer gnus-group-buffer))
6081 (gnus-group-jump-to-group newsgroup))))
6083 ;; This function returns a list of article numbers based on the
6084 ;; difference between the ranges of read articles in this group and
6085 ;; the range of active articles.
6086 (defun gnus-list-of-unread-articles (group)
6087 (let* ((read (gnus-info-read (gnus-get-info group)))
6088 (active (or (gnus-active group) (gnus-activate-group group)))
6091 ;; If none are read, then all are unread.
6093 (setq first (car active))
6094 ;; If the range of read articles is a single range, then the
6095 ;; first unread article is the article after the last read
6096 ;; article. Sounds logical, doesn't it?
6097 (if (and (not (listp (cdr read)))
6098 (or (< (car read) (car active))
6099 (progn (setq read (list read))
6101 (setq first (max (car active) (1+ (cdr read))))
6102 ;; `read' is a list of ranges.
6103 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6106 (setq first (car active)))
6109 (while (< first nlast)
6111 (setq first (1+ first))))
6112 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6113 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6114 (setq read (cdr read)))))
6115 ;; And add the last unread articles.
6116 (while (<= first last)
6118 (setq first (1+ first)))
6119 ;; Return the list of unread articles.
6120 (delq 0 (nreverse unread))))
6122 (defun gnus-list-of-read-articles (group)
6123 "Return a list of unread, unticked and non-dormant articles."
6124 (let* ((info (gnus-get-info group))
6125 (marked (gnus-info-marks info))
6126 (active (gnus-active group)))
6128 (gnus-list-range-difference
6129 (gnus-list-range-difference
6130 (gnus-sorted-complement
6131 (gnus-uncompress-range active)
6132 (gnus-list-of-unread-articles group))
6133 (cdr (assq 'dormant marked)))
6134 (cdr (assq 'tick marked))))))
6136 ;; Various summary commands
6138 (defun gnus-summary-select-article-buffer ()
6139 "Reconfigure windows to show article buffer."
6141 (if (not (gnus-buffer-live-p gnus-article-buffer))
6142 (error "There is no article buffer for this summary buffer")
6143 (gnus-configure-windows 'article)
6144 (select-window (get-buffer-window gnus-article-buffer))))
6146 (defun gnus-summary-universal-argument (arg)
6147 "Perform any operation on all articles that are process/prefixed."
6149 (let ((articles (gnus-summary-work-articles arg))
6156 (substitute-command-keys
6157 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6159 (gnus-error 1 "Undefined key")
6162 (gnus-summary-goto-subject (setq article (pop articles)))
6163 (let (gnus-newsgroup-processable)
6164 (command-execute func))
6165 (gnus-summary-remove-process-mark article)))))
6166 (gnus-summary-position-point))
6168 (defun gnus-summary-toggle-truncation (&optional arg)
6169 "Toggle truncation of summary lines.
6170 With arg, turn line truncation on if arg is positive."
6172 (setq truncate-lines
6173 (if (null arg) (not truncate-lines)
6174 (> (prefix-numeric-value arg) 0)))
6177 (defun gnus-summary-find-uncancelled ()
6178 "Return the number of an uncancelled article.
6179 The current article is considered, then following articles, then previous
6180 articles. If all articles are cancelled then return a dummy 0."
6182 (dolist (rev '(nil t))
6183 (unless found ; don't demand the reverse list if we don't need it
6184 (let ((data (gnus-data-find-list
6185 (gnus-summary-article-number) (gnus-data-list rev))))
6186 (while (and data (not found))
6187 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6188 (setq found (gnus-data-number (car data))))
6189 (setq data (cdr data))))))
6192 (defun gnus-summary-reselect-current-group (&optional all rescan)
6193 "Exit and then reselect the current newsgroup.
6194 The prefix argument ALL means to select all articles."
6196 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6197 (error "Ephemeral groups can't be reselected"))
6198 (let ((current-subject (gnus-summary-find-uncancelled))
6199 (group gnus-newsgroup-name))
6200 (setq gnus-newsgroup-begin nil)
6202 ;; We have to adjust the point of group mode buffer because
6203 ;; point was moved to the next unread newsgroup by exiting.
6204 (gnus-summary-jump-to-group group)
6207 (save-window-excursion
6208 ;; Don't show group contents.
6209 (set-window-start (selected-window) (point-max))
6210 (gnus-group-get-new-news-this-group 1))))
6211 (gnus-group-read-group all t)
6212 (gnus-summary-goto-subject current-subject nil t)))
6214 (defun gnus-summary-rescan-group (&optional all)
6215 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6217 (gnus-summary-reselect-current-group all t))
6219 (defun gnus-summary-update-info (&optional non-destructive)
6221 (let ((group gnus-newsgroup-name))
6223 (when gnus-newsgroup-kill-headers
6224 (setq gnus-newsgroup-killed
6225 (gnus-compress-sequence
6227 (gnus-list-range-intersection
6228 gnus-newsgroup-unselected gnus-newsgroup-killed)
6229 gnus-newsgroup-unreads)
6231 (unless (listp (cdr gnus-newsgroup-killed))
6232 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6233 (let ((headers gnus-newsgroup-headers))
6234 ;; Set the new ranges of read articles.
6236 (set-buffer gnus-group-buffer)
6237 (gnus-undo-force-boundary))
6238 (gnus-update-read-articles
6239 group (gnus-sorted-union
6240 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6241 ;; Set the current article marks.
6242 (let ((gnus-newsgroup-scored
6243 (if (and (not gnus-save-score)
6244 (not non-destructive))
6246 gnus-newsgroup-scored)))
6248 (gnus-update-marks)))
6249 ;; Do the cross-ref thing.
6250 (when gnus-use-cross-reference
6251 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6252 ;; Do not switch windows but change the buffer to work.
6253 (set-buffer gnus-group-buffer)
6254 (unless (gnus-ephemeral-group-p group)
6255 (gnus-group-update-group group)))))))
6257 (defun gnus-summary-save-newsrc (&optional force)
6258 "Save the current number of read/marked articles in the dribble buffer.
6259 The dribble buffer will then be saved.
6260 If FORCE (the prefix), also save the .newsrc file(s)."
6262 (gnus-summary-update-info t)
6264 (gnus-save-newsrc-file)
6265 (gnus-dribble-save)))
6267 (defun gnus-summary-exit (&optional temporary)
6268 "Exit reading current newsgroup, and then return to group selection mode.
6269 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6271 (gnus-set-global-variables)
6272 (gnus-kill-save-kill-buffer)
6273 (gnus-async-halt-prefetch)
6274 (let* ((group gnus-newsgroup-name)
6275 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6278 (buf (current-buffer)))
6280 ;; Do adaptive scoring, and possibly save score files.
6281 (when gnus-newsgroup-adaptive
6282 (gnus-score-adaptive))
6283 (when gnus-use-scoring
6285 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6286 ;; If we have several article buffers, we kill them at exit.
6287 (unless gnus-single-article-buffer
6288 (gnus-kill-buffer gnus-original-article-buffer)
6289 (setq gnus-article-current nil))
6290 (when gnus-use-cache
6291 (gnus-cache-possibly-remove-articles)
6292 (gnus-cache-save-buffers))
6293 (gnus-async-prefetch-remove-group group)
6294 (when gnus-suppress-duplicates
6295 (gnus-dup-enter-articles))
6296 (when gnus-use-trees
6297 (gnus-tree-close group))
6298 (when gnus-use-cache
6299 (gnus-cache-write-active))
6300 ;; Remove entries for this group.
6301 (nnmail-purge-split-history (gnus-group-real-name group))
6302 ;; Make all changes in this group permanent.
6304 (gnus-run-hooks 'gnus-exit-group-hook)
6305 (gnus-summary-update-info))
6306 (gnus-close-group group)
6307 ;; Make sure where we were, and go to next newsgroup.
6308 (set-buffer gnus-group-buffer)
6310 (gnus-group-jump-to-group group))
6311 (gnus-run-hooks 'gnus-summary-exit-hook)
6312 (unless (or quit-config
6313 ;; If this group has disappeared from the summary
6314 ;; buffer, don't skip forwards.
6315 (not (string= group (gnus-group-group-name))))
6316 (gnus-group-next-unread-group 1))
6317 (setq group-point (point))
6320 ;; If we have several article buffers, we kill them at exit.
6321 (unless gnus-single-article-buffer
6322 (gnus-kill-buffer gnus-article-buffer)
6323 (gnus-kill-buffer gnus-original-article-buffer)
6324 (setq gnus-article-current nil))
6326 (if (not gnus-kill-summary-on-exit)
6328 (gnus-deaden-summary)
6330 ;; We set all buffer-local variables to nil. It is unclear why
6331 ;; this is needed, but if we don't, buffer-local variables are
6332 ;; not garbage-collected, it seems. This would the lead to en
6333 ;; ever-growing Emacs.
6334 (gnus-summary-clear-local-variables)
6335 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6336 (gnus-summary-clear-local-variables))
6337 (when (get-buffer gnus-article-buffer)
6338 (bury-buffer gnus-article-buffer))
6339 ;; We clear the global counterparts of the buffer-local
6340 ;; variables as well, just to be on the safe side.
6341 (set-buffer gnus-group-buffer)
6342 (gnus-summary-clear-local-variables)
6343 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6344 (gnus-summary-clear-local-variables)))
6345 (setq gnus-current-select-method gnus-select-method)
6346 (pop-to-buffer gnus-group-buffer)
6347 (if (not quit-config)
6349 (goto-char group-point)
6350 (gnus-configure-windows 'group 'force)
6351 (unless (pos-visible-in-window-p)
6352 (forward-line (/ (static-if (featurep 'xemacs)
6353 (window-displayed-height)
6354 (1- (window-height)))
6356 (set-window-start (selected-window) (point))
6357 (goto-char group-point)))
6358 (gnus-handle-ephemeral-exit quit-config))
6359 ;; Return to group mode buffer.
6360 (when (eq mode 'gnus-summary-mode)
6361 (gnus-kill-buffer buf))
6362 ;; Clear the current group name.
6364 (setq gnus-newsgroup-name nil)))))
6366 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6367 (defun gnus-summary-exit-no-update (&optional no-questions)
6368 "Quit reading current newsgroup without updating read article info."
6370 (let* ((group gnus-newsgroup-name)
6371 (quit-config (gnus-group-quit-config group)))
6372 (when (or no-questions
6374 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6375 (gnus-async-halt-prefetch)
6377 (delq 'gnus-summary-expire-articles
6378 (copy-sequence gnus-summary-prepare-exit-hook)))
6379 ;; If we have several article buffers, we kill them at exit.
6380 (unless gnus-single-article-buffer
6381 (gnus-kill-buffer gnus-article-buffer)
6382 (gnus-kill-buffer gnus-original-article-buffer)
6383 (setq gnus-article-current nil))
6384 (if (not gnus-kill-summary-on-exit)
6385 (gnus-deaden-summary)
6386 (gnus-close-group group)
6387 (gnus-summary-clear-local-variables)
6388 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6389 (gnus-summary-clear-local-variables))
6390 (set-buffer gnus-group-buffer)
6391 (gnus-summary-clear-local-variables)
6392 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6393 (gnus-summary-clear-local-variables))
6394 (when (get-buffer gnus-summary-buffer)
6395 (kill-buffer gnus-summary-buffer)))
6396 (unless gnus-single-article-buffer
6397 (setq gnus-article-current nil))
6398 (when gnus-use-trees
6399 (gnus-tree-close group))
6400 (gnus-async-prefetch-remove-group group)
6401 (when (get-buffer gnus-article-buffer)
6402 (bury-buffer gnus-article-buffer))
6403 ;; Return to the group buffer.
6404 (gnus-configure-windows 'group 'force)
6405 ;; Clear the current group name.
6406 (setq gnus-newsgroup-name nil)
6407 (when (equal (gnus-group-group-name) group)
6408 (gnus-group-next-unread-group 1))
6410 (gnus-handle-ephemeral-exit quit-config)))))
6412 (defun gnus-handle-ephemeral-exit (quit-config)
6413 "Handle movement when leaving an ephemeral group.
6414 The state which existed when entering the ephemeral is reset."
6415 (if (not (buffer-name (car quit-config)))
6416 (gnus-configure-windows 'group 'force)
6417 (set-buffer (car quit-config))
6418 (cond ((eq major-mode 'gnus-summary-mode)
6419 (gnus-set-global-variables))
6420 ((eq major-mode 'gnus-article-mode)
6422 ;; The `gnus-summary-buffer' variable may point
6423 ;; to the old summary buffer when using a single
6425 (unless (gnus-buffer-live-p gnus-summary-buffer)
6426 (set-buffer gnus-group-buffer))
6427 (set-buffer gnus-summary-buffer)
6428 (gnus-set-global-variables))))
6429 (if (or (eq (cdr quit-config) 'article)
6430 (eq (cdr quit-config) 'pick))
6432 ;; The current article may be from the ephemeral group
6433 ;; thus it is best that we reload this article
6434 (gnus-summary-show-article)
6435 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6436 (gnus-configure-windows 'pick 'force)
6437 (gnus-configure-windows (cdr quit-config) 'force)))
6438 (gnus-configure-windows (cdr quit-config) 'force))
6439 (when (eq major-mode 'gnus-summary-mode)
6440 (gnus-summary-next-subject 1 nil t)
6441 (gnus-summary-recenter)
6442 (gnus-summary-position-point))))
6444 (defun gnus-summary-preview-mime-message ()
6445 "MIME decode and play this message."
6447 (let ((gnus-break-pages nil)
6449 (gnus-summary-select-article gnus-show-all-headers t))
6450 (let ((w (get-buffer-window gnus-article-buffer)))
6452 (select-window (get-buffer-window gnus-article-buffer)))))
6456 (defvar gnus-dead-summary-mode-map nil)
6458 (unless gnus-dead-summary-mode-map
6459 (setq gnus-dead-summary-mode-map (make-keymap))
6460 (suppress-keymap gnus-dead-summary-mode-map)
6461 (substitute-key-definition
6462 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6463 (dolist (key '("\C-d" "\r" "\177" [delete]))
6464 (define-key gnus-dead-summary-mode-map
6465 key 'gnus-summary-wake-up-the-dead))
6466 (dolist (key '("q" "Q"))
6467 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6469 (defvar gnus-dead-summary-mode nil
6470 "Minor mode for Gnus summary buffers.")
6472 (defun gnus-dead-summary-mode (&optional arg)
6473 "Minor mode for Gnus summary buffers."
6475 (when (eq major-mode 'gnus-summary-mode)
6476 (make-local-variable 'gnus-dead-summary-mode)
6477 (setq gnus-dead-summary-mode
6478 (if (null arg) (not gnus-dead-summary-mode)
6479 (> (prefix-numeric-value arg) 0)))
6480 (when gnus-dead-summary-mode
6481 (gnus-add-minor-mode
6482 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6484 (defun gnus-deaden-summary ()
6485 "Make the current summary buffer into a dead summary buffer."
6486 ;; Kill any previous dead summary buffer.
6487 (when (and gnus-dead-summary
6488 (buffer-name gnus-dead-summary))
6490 (set-buffer gnus-dead-summary)
6491 (when gnus-dead-summary-mode
6492 (kill-buffer (current-buffer)))))
6493 ;; Make this the current dead summary.
6494 (setq gnus-dead-summary (current-buffer))
6495 (gnus-dead-summary-mode 1)
6496 (let ((name (buffer-name)))
6497 (when (string-match "Summary" name)
6499 (concat (substring name 0 (match-beginning 0)) "Dead "
6500 (substring name (match-beginning 0)))
6504 (defun gnus-kill-or-deaden-summary (buffer)
6505 "Kill or deaden the summary BUFFER."
6507 (when (and (buffer-name buffer)
6508 (not gnus-single-article-buffer))
6511 (gnus-kill-buffer gnus-article-buffer)
6512 (gnus-kill-buffer gnus-original-article-buffer)))
6515 (gnus-kill-summary-on-exit
6516 (when (and gnus-use-trees
6517 (gnus-buffer-exists-p buffer))
6520 (gnus-tree-close gnus-newsgroup-name)))
6521 (gnus-kill-buffer buffer))
6522 ;; Deaden the buffer.
6523 ((gnus-buffer-exists-p buffer)
6526 (gnus-deaden-summary))))))
6528 (defun gnus-summary-wake-up-the-dead (&rest args)
6529 "Wake up the dead summary buffer."
6531 (gnus-dead-summary-mode -1)
6532 (let ((name (buffer-name)))
6533 (when (string-match "Dead " name)
6535 (concat (substring name 0 (match-beginning 0))
6536 (substring name (match-end 0)))
6538 (gnus-message 3 "This dead summary is now alive again"))
6540 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6541 (defun gnus-summary-fetch-faq (&optional faq-dir)
6542 "Fetch the FAQ for the current group.
6543 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6547 (when current-prefix-arg
6549 "FAQ dir: " (and (listp gnus-group-faq-directory)
6550 (mapcar (lambda (file) (list file))
6551 gnus-group-faq-directory))))))
6552 (let (gnus-faq-buffer)
6553 (when (setq gnus-faq-buffer
6554 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6555 (gnus-configure-windows 'summary-faq))))
6557 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6558 (defun gnus-summary-describe-group (&optional force)
6559 "Describe the current newsgroup."
6561 (gnus-group-describe-group force gnus-newsgroup-name))
6563 (defun gnus-summary-describe-briefly ()
6564 "Describe summary mode commands briefly."
6566 (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")))
6568 ;; Walking around group mode buffer from summary mode.
6570 (defun gnus-summary-next-group (&optional no-article target-group backward)
6571 "Exit current newsgroup and then select next unread newsgroup.
6572 If prefix argument NO-ARTICLE is non-nil, no article is selected
6573 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6574 previous group instead."
6576 ;; Stop pre-fetching.
6577 (gnus-async-halt-prefetch)
6578 (let ((current-group gnus-newsgroup-name)
6579 (current-buffer (current-buffer))
6581 (gnus-summary-exit t)
6582 (while (not entered)
6583 ;; Then we find what group we are supposed to enter.
6584 (set-buffer gnus-group-buffer)
6585 (gnus-group-jump-to-group current-group)
6588 (if (eq gnus-keep-same-level 'best)
6589 (gnus-summary-best-group gnus-newsgroup-name)
6590 (gnus-summary-search-group backward gnus-keep-same-level))))
6591 (if (not target-group)
6592 ;; There are no further groups, so we return to the group
6595 (gnus-message 5 "Returning to the group buffer")
6597 (when (gnus-buffer-live-p current-buffer)
6598 (set-buffer current-buffer)
6599 (gnus-summary-exit))
6600 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6601 ;; We try to enter the target group.
6602 (gnus-group-jump-to-group target-group)
6603 (let ((unreads (gnus-group-group-unread)))
6604 (if (and (or (eq t unreads)
6605 (and unreads (not (zerop unreads))))
6607 ;; Now we semi-exit this group to update Xrefs
6608 ;; and all variables. We can't do a real exit,
6609 ;; because the window conf must remain the same
6610 ;; in case the user is prompted for info, and we
6611 ;; don't want the window conf to change before
6613 (when (gnus-buffer-live-p current-buffer)
6614 (set-buffer current-buffer)
6615 (gnus-summary-exit t))
6616 (gnus-summary-read-group
6617 target-group nil no-article
6618 (and (buffer-name current-buffer) current-buffer)
6621 (setq current-group target-group
6622 target-group nil)))))))
6624 (defun gnus-summary-prev-group (&optional no-article)
6625 "Exit current newsgroup and then select previous unread newsgroup.
6626 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6628 (gnus-summary-next-group no-article nil t))
6630 ;; Walking around summary lines.
6632 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6633 "Go to the first unread subject.
6634 If UNREAD is non-nil, go to the first unread article.
6635 Returns the article selected or nil if there are no unread articles."
6640 ((null gnus-newsgroup-data)
6641 (gnus-message 3 "No articles in the group")
6643 ;; Pick the first article.
6645 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6646 (gnus-data-number (car gnus-newsgroup-data)))
6647 ;; No unread articles.
6648 ((null gnus-newsgroup-unreads)
6649 (gnus-message 3 "No more unread articles")
6651 ;; Find the first unread article.
6653 (let ((data gnus-newsgroup-data))
6655 (and (not (and undownloaded
6656 (eq gnus-undownloaded-mark
6657 (gnus-data-mark (car data)))))
6660 (gnus-data-number (car data))
6661 gnus-newsgroup-unseen))
6662 (not (gnus-data-unread-p (car data))))
6663 (not (gnus-data-unread-p (car data))))))
6664 (setq data (cdr data)))
6666 (goto-char (gnus-data-pos (car data)))
6667 (gnus-data-number (car data))))))
6668 (gnus-summary-position-point)))
6670 (defun gnus-summary-next-subject (n &optional unread dont-display)
6671 "Go to next N'th summary line.
6672 If N is negative, go to the previous N'th subject line.
6673 If UNREAD is non-nil, only unread articles are selected.
6674 The difference between N and the actual number of steps taken is
6677 (let ((backward (< n 0))
6681 (gnus-summary-find-prev unread)
6682 (gnus-summary-find-next unread)))
6683 (unless (zerop (setq n (1- n)))
6684 (gnus-summary-show-thread)))
6686 (gnus-message 7 "No more%s articles"
6687 (if unread " unread" "")))
6688 (unless dont-display
6689 (gnus-summary-recenter)
6690 (gnus-summary-position-point))
6693 (defun gnus-summary-next-unread-subject (n)
6694 "Go to next N'th unread summary line."
6696 (gnus-summary-next-subject n t))
6698 (defun gnus-summary-prev-subject (n &optional unread)
6699 "Go to previous N'th summary line.
6700 If optional argument UNREAD is non-nil, only unread article is selected."
6702 (gnus-summary-next-subject (- n) unread))
6704 (defun gnus-summary-prev-unread-subject (n)
6705 "Go to previous N'th unread summary line."
6707 (gnus-summary-next-subject (- n) t))
6709 (defun gnus-summary-goto-subject (article &optional force silent)
6710 "Go the subject line of ARTICLE.
6711 If FORCE, also allow jumping to articles not currently shown."
6712 (interactive "nArticle number: ")
6713 (unless (numberp article)
6714 (error "Article %s is not a number" article))
6716 (data (gnus-data-find article)))
6717 ;; We read in the article if we have to.
6720 (gnus-summary-insert-subject
6722 (if (or (numberp force) (vectorp force)) force)
6724 (setq data (gnus-data-find article)))
6729 (gnus-message 3 "Can't find article %d" article))
6731 (let ((pt (gnus-data-pos data)))
6733 (gnus-summary-set-article-display-arrow pt))
6734 (gnus-summary-position-point)
6737 ;; Walking around summary lines with displaying articles.
6739 (defun gnus-summary-expand-window (&optional arg)
6740 "Make the summary buffer take up the entire Emacs frame.
6741 Given a prefix, will force an `article' buffer configuration."
6744 (gnus-configure-windows 'article 'force)
6745 (gnus-configure-windows 'summary 'force)))
6747 (defun gnus-summary-display-article (article &optional all-header)
6748 "Display ARTICLE in article buffer."
6749 (when (gnus-buffer-live-p gnus-article-buffer)
6750 (with-current-buffer gnus-article-buffer
6751 (set-buffer-multibyte t)))
6752 (gnus-set-global-variables)
6753 (when (gnus-buffer-live-p gnus-article-buffer)
6754 (with-current-buffer gnus-article-buffer
6755 (setq gnus-article-charset gnus-newsgroup-charset)
6756 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6757 (set-buffer-multibyte t)))
6761 (if gnus-summary-display-article-function
6762 (funcall gnus-summary-display-article-function article all-header)
6763 (gnus-article-prepare article all-header))
6764 (with-current-buffer gnus-article-buffer
6765 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6767 (gnus-run-hooks 'gnus-select-article-hook)
6768 (when (and gnus-current-article
6769 (not (zerop gnus-current-article)))
6770 (gnus-summary-goto-subject gnus-current-article))
6771 (gnus-summary-recenter)
6772 (when (and gnus-use-trees gnus-show-threads)
6773 (gnus-possibly-generate-tree article)
6774 (gnus-highlight-selected-tree article))
6775 ;; Successfully display article.
6776 (gnus-article-set-window-start
6777 (cdr (assq article gnus-newsgroup-bookmarks))))))
6779 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6780 "Select the current article.
6781 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6782 non-nil, the article will be re-fetched even if it already present in
6783 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6785 ;; Make sure we are in the summary buffer to work around bbdb bug.
6786 (unless (eq major-mode 'gnus-summary-mode)
6787 (set-buffer gnus-summary-buffer))
6788 (let ((article (or article (gnus-summary-article-number)))
6789 (all-headers (not (not all-headers))) ;Must be T or NIL.
6790 gnus-summary-display-article-function)
6792 (gnus-summary-article-pseudo-p article)
6793 (error "This is a pseudo-article"))
6795 (set-buffer gnus-summary-buffer)
6796 (if (or (and gnus-single-article-buffer
6797 (or (null gnus-current-article)
6798 (null gnus-article-current)
6799 (null (get-buffer gnus-article-buffer))
6800 (not (eq article (cdr gnus-article-current)))
6801 (not (equal (car gnus-article-current)
6802 gnus-newsgroup-name))))
6803 (and (not gnus-single-article-buffer)
6804 (or (null gnus-current-article)
6805 (not (eq gnus-current-article article))))
6807 ;; The requested article is different from the current article.
6809 (gnus-summary-display-article article all-headers)
6810 (gnus-article-set-window-start
6811 (cdr (assq article gnus-newsgroup-bookmarks)))
6815 (defun gnus-summary-force-verify-and-decrypt ()
6817 (let ((mm-verify-option 'known)
6818 (mm-decrypt-option 'known)
6819 (gnus-buttonized-mime-types (append (list "multipart/signed"
6820 "multipart/encrypted")
6821 gnus-buttonized-mime-types)))
6822 (gnus-summary-select-article nil 'force)))
6824 (defun gnus-summary-set-current-mark (&optional current-mark)
6825 "Obsolete function."
6828 (defun gnus-summary-next-article (&optional unread subject backward push)
6829 "Select the next article.
6830 If UNREAD, only unread articles are selected.
6831 If SUBJECT, only articles with SUBJECT are selected.
6832 If BACKWARD, the previous article is selected instead of the next."
6835 ;; Is there such an article?
6836 ((and (gnus-summary-search-forward unread subject backward)
6837 (or (gnus-summary-display-article (gnus-summary-article-number))
6838 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6839 (gnus-summary-position-point))
6840 ;; If not, we try the first unread, if that is wanted.
6842 gnus-auto-select-same
6843 (gnus-summary-first-unread-article))
6844 (gnus-summary-position-point)
6845 (gnus-message 6 "Wrapped"))
6846 ;; Try to get next/previous article not displayed in this group.
6847 ((and gnus-auto-extend-newsgroup
6848 (not unread) (not subject))
6849 (gnus-summary-goto-article
6850 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6851 nil (count-lines (point-min) (point))))
6852 ;; Go to next/previous group.
6854 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6855 (gnus-summary-jump-to-group gnus-newsgroup-name))
6856 (let ((cmd last-command-char)
6859 (set-buffer gnus-group-buffer)
6862 (if (eq gnus-keep-same-level 'best)
6863 (gnus-summary-best-group gnus-newsgroup-name)
6864 (gnus-summary-search-group backward gnus-keep-same-level))))
6865 ;; For some reason, the group window gets selected. We change
6867 (select-window (get-buffer-window (current-buffer)))
6868 ;; Select next unread newsgroup automagically.
6870 ((or (not gnus-auto-select-next)
6872 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6873 ((or (eq gnus-auto-select-next 'quietly)
6874 (and (eq gnus-auto-select-next 'slightly-quietly)
6876 (and (eq gnus-auto-select-next 'almost-quietly)
6877 (gnus-summary-last-article-p)))
6879 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6881 (gnus-message 7 "No more%s articles (%s)..."
6882 (if unread " unread" "")
6883 (if group (concat "selecting " group)
6885 (gnus-summary-next-group nil group backward)))
6887 (when (gnus-key-press-event-p last-input-event)
6888 (gnus-summary-walk-group-buffer
6889 gnus-newsgroup-name cmd unread backward point))))))))
6891 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6892 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6893 (?\C-p (gnus-group-prev-unread-group 1))))
6894 (cursor-in-echo-area t)
6895 keve key group ended)
6897 (set-buffer gnus-group-buffer)
6900 (if (eq gnus-keep-same-level 'best)
6901 (gnus-summary-best-group gnus-newsgroup-name)
6902 (gnus-summary-search-group backward gnus-keep-same-level))))
6905 5 "No more%s articles%s" (if unread " unread" "")
6907 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6908 (format " (Type %s for %s [%s])"
6909 (single-key-description cmd) group
6910 (car (gnus-gethash group gnus-newsrc-hashtb)))
6911 (format " (Type %s to exit %s)"
6912 (single-key-description cmd)
6913 gnus-newsgroup-name)))
6914 ;; Confirm auto selection.
6915 (setq key (car (setq keve (gnus-read-event-char))))
6918 ((assq key keystrokes)
6919 (let ((obuf (current-buffer)))
6920 (switch-to-buffer gnus-group-buffer)
6922 (gnus-group-jump-to-group group))
6923 (eval (cadr (assq key keystrokes)))
6924 (setq group (gnus-group-group-name))
6925 (switch-to-buffer obuf))
6929 (gnus-ephemeral-group-p gnus-newsgroup-name))
6931 (gnus-summary-next-group nil group backward)))
6933 (push (cdr keve) unread-command-events))))))
6935 (defun gnus-summary-next-unread-article ()
6936 "Select unread article after current one."
6938 (gnus-summary-next-article
6939 (or (not (eq gnus-summary-goto-unread 'never))
6940 (gnus-summary-last-article-p (gnus-summary-article-number)))
6941 (and gnus-auto-select-same
6942 (gnus-summary-article-subject))))
6944 (defun gnus-summary-prev-article (&optional unread subject)
6945 "Select the article after the current one.
6946 If UNREAD is non-nil, only unread articles are selected."
6948 (gnus-summary-next-article unread subject t))
6950 (defun gnus-summary-prev-unread-article ()
6951 "Select unread article before current one."
6953 (gnus-summary-prev-article
6954 (or (not (eq gnus-summary-goto-unread 'never))
6955 (gnus-summary-first-article-p (gnus-summary-article-number)))
6956 (and gnus-auto-select-same
6957 (gnus-summary-article-subject))))
6959 (defun gnus-summary-next-page (&optional lines circular)
6960 "Show next page of the selected article.
6961 If at the end of the current article, select the next article.
6962 LINES says how many lines should be scrolled up.
6964 If CIRCULAR is non-nil, go to the start of the article instead of
6965 selecting the next article when reaching the end of the current
6968 (setq gnus-summary-buffer (current-buffer))
6969 (gnus-set-global-variables)
6970 (let ((article (gnus-summary-article-number))
6971 (article-window (get-buffer-window gnus-article-buffer t))
6973 ;; If the buffer is empty, we have no article.
6975 (error "No article to select"))
6976 (gnus-configure-windows 'article)
6977 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6978 (if (and (eq gnus-summary-goto-unread 'never)
6979 (not (gnus-summary-last-article-p article)))
6980 (gnus-summary-next-article)
6981 (gnus-summary-next-unread-article))
6982 (if (or (null gnus-current-article)
6983 (null gnus-article-current)
6984 (/= article (cdr gnus-article-current))
6985 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6986 ;; Selected subject is different from current article's.
6987 (gnus-summary-display-article article)
6988 (when article-window
6989 (gnus-eval-in-buffer-window gnus-article-buffer
6990 (setq endp (gnus-article-next-page lines)))
6993 (gnus-summary-beginning-of-article))
6995 (gnus-message 3 "End of message"))
6997 (if (and (eq gnus-summary-goto-unread 'never)
6998 (not (gnus-summary-last-article-p article)))
6999 (gnus-summary-next-article)
7000 (gnus-summary-next-unread-article))))))))
7001 (gnus-summary-recenter)
7002 (gnus-summary-position-point)))
7004 (defun gnus-summary-prev-page (&optional lines move)
7005 "Show previous page of selected article.
7006 Argument LINES specifies lines to be scrolled down.
7007 If MOVE, move to the previous unread article if point is at
7008 the beginning of the buffer."
7010 (let ((article (gnus-summary-article-number))
7011 (article-window (get-buffer-window gnus-article-buffer t))
7013 (gnus-configure-windows 'article)
7014 (if (or (null gnus-current-article)
7015 (null gnus-article-current)
7016 (/= article (cdr gnus-article-current))
7017 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7018 ;; Selected subject is different from current article's.
7019 (gnus-summary-display-article article)
7020 (gnus-summary-recenter)
7021 (when article-window
7022 (gnus-eval-in-buffer-window gnus-article-buffer
7023 (setq endp (gnus-article-prev-page lines)))
7024 (when (and move endp)
7026 (gnus-message 3 "Beginning of message"))
7028 (if (and (eq gnus-summary-goto-unread 'never)
7029 (not (gnus-summary-first-article-p article)))
7030 (gnus-summary-prev-article)
7031 (gnus-summary-prev-unread-article))))))))
7032 (gnus-summary-position-point))
7034 (defun gnus-summary-prev-page-or-article (&optional lines)
7035 "Show previous page of selected article.
7036 Argument LINES specifies lines to be scrolled down.
7037 If at the beginning of the article, go to the next article."
7039 (gnus-summary-prev-page lines t))
7041 (defun gnus-summary-scroll-up (lines)
7042 "Scroll up (or down) one line current article.
7043 Argument LINES specifies lines to be scrolled up (or down if negative)."
7045 (gnus-configure-windows 'article)
7046 (gnus-summary-show-thread)
7047 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7048 (gnus-eval-in-buffer-window gnus-article-buffer
7050 (when (gnus-article-next-page lines)
7051 (gnus-message 3 "End of message")))
7053 (gnus-article-prev-page (- lines))))))
7054 (gnus-summary-recenter)
7055 (gnus-summary-position-point))
7057 (defun gnus-summary-scroll-down (lines)
7058 "Scroll down (or up) one line current article.
7059 Argument LINES specifies lines to be scrolled down (or up if negative)."
7061 (gnus-summary-scroll-up (- lines)))
7063 (defun gnus-summary-next-same-subject ()
7064 "Select next article which has the same subject as current one."
7066 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7068 (defun gnus-summary-prev-same-subject ()
7069 "Select previous article which has the same subject as current one."
7071 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7073 (defun gnus-summary-next-unread-same-subject ()
7074 "Select next unread article which has the same subject as current one."
7076 (gnus-summary-next-article t (gnus-summary-article-subject)))
7078 (defun gnus-summary-prev-unread-same-subject ()
7079 "Select previous unread article which has the same subject as current one."
7081 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7083 (defun gnus-summary-first-unread-article ()
7084 "Select the first unread article.
7085 Return nil if there are no unread articles."
7088 (when (gnus-summary-first-subject t)
7089 (gnus-summary-show-thread)
7090 (gnus-summary-first-subject t)
7091 (gnus-summary-display-article (gnus-summary-article-number)))
7092 (gnus-summary-position-point)))
7094 (defun gnus-summary-first-unread-subject ()
7095 "Place the point on the subject line of the first unread article.
7096 Return nil if there are no unread articles."
7099 (when (gnus-summary-first-subject t)
7100 (gnus-summary-show-thread)
7101 (gnus-summary-first-subject t))
7102 (gnus-summary-position-point)))
7104 (defun gnus-summary-first-unseen-subject ()
7105 "Place the point on the subject line of the first unseen article.
7106 Return nil if there are no unseen articles."
7109 (when (gnus-summary-first-subject t t t)
7110 (gnus-summary-show-thread)
7111 (gnus-summary-first-subject t t t))
7112 (gnus-summary-position-point)))
7114 (defun gnus-summary-first-unseen-or-unread-subject ()
7115 "Place the point on the subject line of the first unseen article.
7116 Return nil if there are no unseen articles."
7119 (unless (when (gnus-summary-first-subject t t t)
7120 (gnus-summary-show-thread)
7121 (gnus-summary-first-subject t t t))
7122 (when (gnus-summary-first-subject t)
7123 (gnus-summary-show-thread)
7124 (gnus-summary-first-subject t)))
7125 (gnus-summary-position-point)))
7127 (defun gnus-summary-first-article ()
7128 "Select the first article.
7129 Return nil if there are no articles."
7132 (when (gnus-summary-first-subject)
7133 (gnus-summary-show-thread)
7134 (gnus-summary-first-subject)
7135 (gnus-summary-display-article (gnus-summary-article-number)))
7136 (gnus-summary-position-point)))
7138 (defun gnus-summary-best-unread-article (&optional arg)
7139 "Select the unread article with the highest score.
7140 If given a prefix argument, select the next unread article that has a
7141 score higher than the default score."
7143 (let ((article (if arg
7144 (gnus-summary-better-unread-subject)
7145 (gnus-summary-best-unread-subject))))
7147 (gnus-summary-goto-article article)
7148 (error "No unread articles"))))
7150 (defun gnus-summary-best-unread-subject ()
7151 "Select the unread subject with the highest score."
7153 (let ((best -1000000)
7154 (data gnus-newsgroup-data)
7157 (and (gnus-data-unread-p (car data))
7159 (gnus-summary-article-score (gnus-data-number (car data))))
7162 article (gnus-data-number (car data))))
7163 (setq data (cdr data)))
7165 (gnus-summary-goto-subject article))
7166 (gnus-summary-position-point)
7169 (defun gnus-summary-better-unread-subject ()
7170 "Select the first unread subject that has a score over the default score."
7172 (let ((data gnus-newsgroup-data)
7174 (while (and (setq article (gnus-data-number (car data)))
7175 (or (gnus-data-read-p (car data))
7176 (not (> (gnus-summary-article-score article)
7177 gnus-summary-default-score))))
7178 (setq data (cdr data)))
7180 (gnus-summary-goto-subject article))
7181 (gnus-summary-position-point)
7184 (defun gnus-summary-last-subject ()
7185 "Go to the last displayed subject line in the group."
7186 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7188 (gnus-summary-goto-subject article))))
7190 (defun gnus-summary-goto-article (article &optional all-headers force)
7191 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7192 If ALL-HEADERS is non-nil, no header lines are hidden.
7193 If FORCE, go to the article even if it isn't displayed. If FORCE
7194 is a number, it is the line the article is to be displayed on."
7198 "Article number or Message-ID: "
7199 (mapcar (lambda (number) (list (int-to-string number)))
7200 gnus-newsgroup-limit))
7204 (if (and (stringp article)
7205 (string-match "@" article))
7206 (gnus-summary-refer-article article)
7207 (when (stringp article)
7208 (setq article (string-to-number article)))
7209 (if (gnus-summary-goto-subject article force)
7210 (gnus-summary-display-article article all-headers)
7211 (gnus-message 4 "Couldn't go to article %s" article) nil))
7212 (gnus-summary-position-point)))
7214 (defun gnus-summary-goto-last-article ()
7215 "Go to the previously read article."
7218 (when gnus-last-article
7219 (gnus-summary-goto-article gnus-last-article nil t))
7220 (gnus-summary-position-point)))
7222 (defun gnus-summary-pop-article (number)
7223 "Pop one article off the history and go to the previous.
7224 NUMBER articles will be popped off."
7227 (setq gnus-newsgroup-history
7228 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7230 (gnus-summary-goto-article (car to) nil t)
7231 (error "Article history empty")))
7232 (gnus-summary-position-point))
7234 ;; Summary commands and functions for limiting the summary buffer.
7236 (defun gnus-summary-limit-to-articles (n)
7237 "Limit the summary buffer to the next N articles.
7238 If not given a prefix, use the process marked articles instead."
7241 (let ((articles (gnus-summary-work-articles n)))
7242 (setq gnus-newsgroup-processable nil)
7243 (gnus-summary-limit articles))
7244 (gnus-summary-position-point)))
7246 (defun gnus-summary-pop-limit (&optional total)
7247 "Restore the previous limit.
7248 If given a prefix, remove all limits."
7251 (setq gnus-newsgroup-limits
7252 (list (mapcar (lambda (h) (mail-header-number h))
7253 gnus-newsgroup-headers))))
7254 (unless gnus-newsgroup-limits
7255 (error "No limit to pop"))
7257 (gnus-summary-limit nil 'pop)
7258 (gnus-summary-position-point)))
7260 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7261 "Limit the summary buffer to articles that have subjects that match a regexp.
7262 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7264 (list (read-string (if current-prefix-arg
7265 "Exclude subject (regexp): "
7266 "Limit to subject (regexp): "))
7267 nil current-prefix-arg))
7269 (setq header "subject"))
7270 (when (not (equal "" subject))
7272 (let ((articles (gnus-summary-find-matching
7273 (or header "subject") subject 'all nil nil
7276 (error "Found no matches for \"%s\"" subject))
7277 (gnus-summary-limit articles))
7278 (gnus-summary-position-point))))
7280 (defun gnus-summary-limit-to-author (from &optional not-matching)
7281 "Limit the summary buffer to articles that have authors that match a regexp.
7282 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7284 (list (read-string (if current-prefix-arg
7285 "Exclude author (regexp): "
7286 "Limit to author (regexp): "))
7287 current-prefix-arg))
7288 (gnus-summary-limit-to-subject from "from" not-matching))
7290 (defun gnus-summary-limit-to-age (age &optional younger-p)
7291 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7292 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7293 articles that are younger than AGE days."
7295 (let ((younger current-prefix-arg)
7298 (while (not days-got)
7299 (setq days (if younger
7300 (read-string "Limit to articles within (in days): ")
7301 (read-string "Limit to articles older than (in days): ")))
7302 (when (> (length days) 0)
7303 (setq days (read days)))
7309 (setq younger (not younger))
7310 (setq days (* days -1)))))
7311 (message "Please enter a number.")
7313 (list days younger)))
7315 (let ((data gnus-newsgroup-data)
7316 (cutoff (days-to-time age))
7317 articles d date is-younger)
7318 (while (setq d (pop data))
7319 (when (and (vectorp (gnus-data-header d))
7320 (setq date (mail-header-date (gnus-data-header d))))
7321 (setq is-younger (time-less-p
7322 (time-since (condition-case ()
7329 (push (gnus-data-number d) articles))))
7330 (gnus-summary-limit (nreverse articles)))
7331 (gnus-summary-position-point)))
7333 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7334 "Limit the summary buffer to articles that match an 'extra' header."
7338 (gnus-completing-read-with-default
7339 (symbol-name (car gnus-extra-headers))
7340 (if current-prefix-arg
7341 "Exclude extra header:"
7342 "Limit extra header:")
7344 (cons (symbol-name x) x))
7349 (read-string (format "%s header %s (regexp): "
7350 (if current-prefix-arg "Exclude" "Limit to")
7352 current-prefix-arg)))
7353 (when (not (equal "" regexp))
7355 (let ((articles (gnus-summary-find-matching
7356 (cons 'extra header) regexp 'all nil nil
7359 (error "Found no matches for \"%s\"" regexp))
7360 (gnus-summary-limit articles))
7361 (gnus-summary-position-point))))
7363 (defun gnus-summary-limit-to-display-predicate ()
7364 "Limit the summary buffer to the predicated in the `display' group parameter."
7366 (unless gnus-newsgroup-display
7367 (error "There is no `display' group parameter"))
7369 (dolist (number gnus-newsgroup-articles)
7370 (when (funcall gnus-newsgroup-display)
7371 (push number articles)))
7372 (gnus-summary-limit articles))
7373 (gnus-summary-position-point))
7375 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7377 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7379 (defun gnus-summary-limit-to-unread (&optional all)
7380 "Limit the summary buffer to articles that are not marked as read.
7381 If ALL is non-nil, limit strictly to unread articles."
7384 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7385 (gnus-summary-limit-to-marks
7386 ;; Concat all the marks that say that an article is read and have
7388 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7389 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7390 gnus-low-score-mark gnus-expirable-mark
7391 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7392 gnus-duplicate-mark gnus-souped-mark)
7395 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7396 (make-obsolete 'gnus-summary-delete-marked-with
7397 'gnus-summary-limit-exclude-marks)
7399 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7400 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7401 If REVERSE, limit the summary buffer to articles that are marked
7402 with MARKS. MARKS can either be a string of marks or a list of marks.
7403 Returns how many articles were removed."
7404 (interactive "sMarks: ")
7405 (gnus-summary-limit-to-marks marks t))
7407 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7408 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7409 If REVERSE (the prefix), limit the summary buffer to articles that are
7410 not marked with MARKS. MARKS can either be a string of marks or a
7412 Returns how many articles were removed."
7413 (interactive "sMarks: \nP")
7415 (let ((data gnus-newsgroup-data)
7416 (marks (if (listp marks) marks
7417 (append marks nil))) ; Transform to list.
7420 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7421 (memq (gnus-data-mark (car data)) marks))
7422 (push (gnus-data-number (car data)) articles))
7423 (setq data (cdr data)))
7424 (gnus-summary-limit articles))
7425 (gnus-summary-position-point)))
7427 (defun gnus-summary-limit-to-score (score)
7428 "Limit to articles with score at or above SCORE."
7429 (interactive "NLimit to articles with score of at least: ")
7430 (let ((data gnus-newsgroup-data)
7433 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7435 (push (gnus-data-number (car data)) articles))
7436 (setq data (cdr data)))
7438 (gnus-summary-limit articles)
7439 (gnus-summary-position-point))))
7441 (defun gnus-summary-limit-to-unseen ()
7442 "Limit to unseen articles."
7445 (gnus-summary-limit gnus-newsgroup-unseen)
7446 (gnus-summary-position-point)))
7448 (defun gnus-summary-limit-include-thread (id)
7449 "Display all the hidden articles that is in the thread with ID in it.
7450 When called interactively, ID is the Message-ID of the current
7452 (interactive (list (mail-header-id (gnus-summary-article-header))))
7453 (let ((articles (gnus-articles-in-thread
7454 (gnus-id-to-thread (gnus-root-id id)))))
7456 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7457 (gnus-summary-limit-include-matching-articles
7459 (regexp-quote (gnus-simplify-subject-re
7460 (mail-header-subject (gnus-id-to-header id)))))
7461 (gnus-summary-position-point))))
7463 (defun gnus-summary-limit-include-matching-articles (header regexp)
7464 "Display all the hidden articles that have HEADERs that match REGEXP."
7465 (interactive (list (read-string "Match on header: ")
7466 (read-string "Regexp: ")))
7467 (let ((articles (gnus-find-matching-articles header regexp)))
7469 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7470 (gnus-summary-position-point))))
7472 (defun gnus-summary-limit-include-dormant ()
7473 "Display all the hidden articles that are marked as dormant.
7474 Note that this command only works on a subset of the articles currently
7475 fetched for this group."
7477 (unless gnus-newsgroup-dormant
7478 (error "There are no dormant articles in this group"))
7480 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7481 (gnus-summary-position-point)))
7483 (defun gnus-summary-limit-exclude-dormant ()
7484 "Hide all dormant articles."
7487 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7488 (gnus-summary-position-point)))
7490 (defun gnus-summary-limit-exclude-childless-dormant ()
7491 "Hide all dormant articles that have no children."
7493 (let ((data (gnus-data-list t))
7494 articles d children)
7495 ;; Find all articles that are either not dormant or have
7497 (while (setq d (pop data))
7498 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7500 (gnus-article-children (gnus-data-number d)))
7503 (when (memq (car children) articles)
7508 (push (gnus-data-number d) articles)))
7511 (gnus-summary-limit articles)
7512 (gnus-summary-position-point))))
7514 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7515 "Mark all unread excluded articles as read.
7516 If ALL, mark even excluded ticked and dormants as read."
7518 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7519 (let ((articles (gnus-sorted-ndifference
7521 (mapcar (lambda (h) (mail-header-number h))
7522 gnus-newsgroup-headers)
7524 gnus-newsgroup-limit))
7526 (setq gnus-newsgroup-unreads
7527 (gnus-sorted-intersection gnus-newsgroup-unreads
7528 gnus-newsgroup-limit))
7530 (setq gnus-newsgroup-dormant nil
7531 gnus-newsgroup-marked nil
7532 gnus-newsgroup-reads
7534 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7535 gnus-newsgroup-reads))
7536 (while (setq article (pop articles))
7537 (unless (or (memq article gnus-newsgroup-dormant)
7538 (memq article gnus-newsgroup-marked))
7539 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7541 (defun gnus-summary-limit (articles &optional pop)
7543 ;; We pop the previous limit off the stack and use that.
7544 (setq articles (car gnus-newsgroup-limits)
7545 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7546 ;; We use the new limit, so we push the old limit on the stack.
7547 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7549 (setq gnus-newsgroup-limit articles)
7550 (let ((total (length gnus-newsgroup-data))
7551 (data (gnus-data-find-list (gnus-summary-article-number)))
7552 (gnus-summary-mark-below nil) ; Inhibit this.
7554 ;; This will do all the work of generating the new summary buffer
7555 ;; according to the new limit.
7556 (gnus-summary-prepare)
7557 ;; Hide any threads, possibly.
7558 (gnus-summary-maybe-hide-threads)
7559 ;; Try to return to the article you were at, or one in the
7562 ;; We try to find some article after the current one.
7564 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7567 (setq data (cdr data))))
7569 ;; If there is no data, that means that we were after the last
7570 ;; article. The same goes when we can't find any articles
7571 ;; after the current one.
7572 (goto-char (point-max))
7573 (gnus-summary-find-prev))
7574 (gnus-set-mode-line 'summary)
7575 ;; We return how many articles were removed from the summary
7576 ;; buffer as a result of the new limit.
7577 (- total (length gnus-newsgroup-data))))
7579 (defsubst gnus-invisible-cut-children (threads)
7582 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7587 (defsubst gnus-cut-thread (thread)
7588 "Go forwards in the thread until we find an article that we want to display."
7589 (when (or (eq gnus-fetch-old-headers 'some)
7590 (eq gnus-fetch-old-headers 'invisible)
7591 (numberp gnus-fetch-old-headers)
7592 (eq gnus-build-sparse-threads 'some)
7593 (eq gnus-build-sparse-threads 'more))
7594 ;; Deal with old-fetched headers and sparse threads.
7598 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7599 (gnus-summary-article-ancient-p
7600 (mail-header-number (car thread))))
7601 (if (or (<= (length (cdr thread)) 1)
7602 (eq gnus-fetch-old-headers 'invisible))
7603 (setq gnus-newsgroup-limit
7604 (delq (mail-header-number (car thread))
7605 gnus-newsgroup-limit)
7606 thread (cadr thread))
7607 (when (gnus-invisible-cut-children (cdr thread))
7608 (let ((th (cdr thread)))
7610 (if (memq (mail-header-number (caar th))
7611 gnus-newsgroup-limit)
7612 (setq thread (car th)
7614 (setq th (cdr th))))))))))
7617 (defun gnus-cut-threads (threads)
7618 "Cut off all uninteresting articles from the beginning of threads."
7619 (when (or (eq gnus-fetch-old-headers 'some)
7620 (eq gnus-fetch-old-headers 'invisible)
7621 (numberp gnus-fetch-old-headers)
7622 (eq gnus-build-sparse-threads 'some)
7623 (eq gnus-build-sparse-threads 'more))
7626 (setcar th (gnus-cut-thread (car th)))
7627 (setq th (cdr th)))))
7628 ;; Remove nixed out threads.
7631 (defun gnus-summary-initial-limit (&optional show-if-empty)
7632 "Figure out what the initial limit is supposed to be on group entry.
7633 This entails weeding out unwanted dormants, low-scored articles,
7634 fetch-old-headers verbiage, and so on."
7635 ;; Most groups have nothing to remove.
7636 (if (or gnus-inhibit-limiting
7637 (and (null gnus-newsgroup-dormant)
7638 (eq gnus-newsgroup-display 'gnus-not-ignore)
7639 (not (eq gnus-fetch-old-headers 'some))
7640 (not (numberp gnus-fetch-old-headers))
7641 (not (eq gnus-fetch-old-headers 'invisible))
7642 (null gnus-summary-expunge-below)
7643 (not (eq gnus-build-sparse-threads 'some))
7644 (not (eq gnus-build-sparse-threads 'more))
7645 (null gnus-thread-expunge-below)
7646 (not gnus-use-nocem)))
7648 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7649 (setq gnus-newsgroup-limit nil)
7652 (unless (car (symbol-value node))
7653 ;; These threads have no parents -- they are roots.
7654 (let ((nodes (cdr (symbol-value node)))
7657 (if (and gnus-thread-expunge-below
7658 (< (gnus-thread-total-score (car nodes))
7659 gnus-thread-expunge-below))
7660 (gnus-expunge-thread (pop nodes))
7661 (setq thread (pop nodes))
7662 (gnus-summary-limit-children thread))))))
7663 gnus-newsgroup-dependencies)
7664 ;; If this limitation resulted in an empty group, we might
7665 ;; pop the previous limit and use it instead.
7666 (when (and (not gnus-newsgroup-limit)
7668 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7669 gnus-newsgroup-limit))
7671 (defun gnus-summary-limit-children (thread)
7672 "Return 1 if this subthread is visible and 0 if it is not."
7673 ;; First we get the number of visible children to this thread. This
7674 ;; is done by recursing down the thread using this function, so this
7675 ;; will really go down to a leaf article first, before slowly
7676 ;; working its way up towards the root.
7680 (apply '+ (mapcar 'gnus-summary-limit-children
7683 (number (mail-header-number (car thread)))
7686 (not (memq number gnus-newsgroup-marked))
7688 ;; If this article is dormant and has absolutely no visible
7689 ;; children, then this article isn't visible.
7690 (and (memq number gnus-newsgroup-dormant)
7692 ;; If this is "fetch-old-headered" and there is no
7693 ;; visible children, then we don't want this article.
7694 (and (or (eq gnus-fetch-old-headers 'some)
7695 (numberp gnus-fetch-old-headers))
7696 (gnus-summary-article-ancient-p number)
7698 ;; If this is "fetch-old-headered" and `invisible', then
7699 ;; we don't want this article.
7700 (and (eq gnus-fetch-old-headers 'invisible)
7701 (gnus-summary-article-ancient-p number))
7702 ;; If this is a sparsely inserted article with no children,
7703 ;; we don't want it.
7704 (and (eq gnus-build-sparse-threads 'some)
7705 (gnus-summary-article-sparse-p number)
7707 ;; If we use expunging, and this article is really
7708 ;; low-scored, then we don't want this article.
7709 (when (and gnus-summary-expunge-below
7711 (or (cdr (assq number gnus-newsgroup-scored))
7712 gnus-summary-default-score))
7713 gnus-summary-expunge-below))
7714 ;; We increase the expunge-tally here, but that has
7715 ;; nothing to do with the limits, really.
7716 (incf gnus-newsgroup-expunged-tally)
7717 ;; We also mark as read here, if that's wanted.
7718 (when (and gnus-summary-mark-below
7719 (< score gnus-summary-mark-below))
7720 (setq gnus-newsgroup-unreads
7721 (delq number gnus-newsgroup-unreads))
7722 (if gnus-newsgroup-auto-expire
7723 (push number gnus-newsgroup-expirable)
7724 (push (cons number gnus-low-score-mark)
7725 gnus-newsgroup-reads)))
7727 ;; Do the `display' group parameter.
7728 (and gnus-newsgroup-display
7729 (not (funcall gnus-newsgroup-display)))
7730 ;; Check NoCeM things.
7731 (if (and gnus-use-nocem
7732 (gnus-nocem-unwanted-article-p
7733 (mail-header-id (car thread))))
7735 (setq gnus-newsgroup-unreads
7736 (delq number gnus-newsgroup-unreads))
7738 ;; Nope, invisible article.
7740 ;; Ok, this article is to be visible, so we add it to the limit
7742 (push number gnus-newsgroup-limit)
7745 (defun gnus-expunge-thread (thread)
7746 "Mark all articles in THREAD as read."
7747 (let* ((number (mail-header-number (car thread))))
7748 (incf gnus-newsgroup-expunged-tally)
7749 ;; We also mark as read here, if that's wanted.
7750 (setq gnus-newsgroup-unreads
7751 (delq number gnus-newsgroup-unreads))
7752 (if gnus-newsgroup-auto-expire
7753 (push number gnus-newsgroup-expirable)
7754 (push (cons number gnus-low-score-mark)
7755 gnus-newsgroup-reads)))
7756 ;; Go recursively through all subthreads.
7757 (mapcar 'gnus-expunge-thread (cdr thread)))
7759 ;; Summary article oriented commands
7761 (defun gnus-summary-refer-parent-article (n)
7762 "Refer parent article N times.
7763 If N is negative, go to ancestor -N instead.
7764 The difference between N and the number of articles fetched is returned."
7768 (when (not (natnump n))
7773 (setq header (gnus-summary-article-header))
7774 (if (and (eq (mail-header-number header)
7775 (cdr gnus-article-current))
7776 (equal gnus-newsgroup-name
7777 (car gnus-article-current)))
7778 ;; If we try to find the parent of the currently
7779 ;; displayed article, then we take a look at the actual
7780 ;; References header, since this is slightly more
7781 ;; reliable than the References field we got from the
7784 (set-buffer gnus-original-article-buffer)
7785 (nnheader-narrow-to-headers)
7786 (unless (setq ref (message-fetch-field "references"))
7787 (setq ref (message-fetch-field "in-reply-to")))
7790 ;; It's not the current article, so we take a bet on
7791 ;; the value we got from the server.
7792 (mail-header-references header)))
7794 (not (equal ref "")))
7795 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7796 (gnus-message 1 "Couldn't find parent"))
7797 (gnus-message 1 "No references in article %d"
7798 (gnus-summary-article-number))
7801 (gnus-summary-position-point)
7804 (defun gnus-summary-refer-references ()
7805 "Fetch all articles mentioned in the References header.
7806 Return the number of articles fetched."
7808 (let ((ref (mail-header-references (gnus-summary-article-header)))
7809 (current (gnus-summary-article-number))
7813 (error "No References in the current article")
7814 ;; For each Message-ID in the References header...
7815 (while (string-match "<[^>]*>" ref)
7817 ;; ... fetch that article.
7818 (gnus-summary-refer-article
7819 (prog1 (match-string 0 ref)
7820 (setq ref (substring ref (match-end 0))))))
7821 (gnus-summary-goto-subject current)
7822 (gnus-summary-position-point)
7825 (defun gnus-summary-refer-thread (&optional limit)
7826 "Fetch all articles in the current thread.
7827 If LIMIT (the numerical prefix), fetch that many old headers instead
7828 of what's specified by the `gnus-refer-thread-limit' variable."
7830 (let ((id (mail-header-id (gnus-summary-article-header)))
7831 (limit (if limit (prefix-numeric-value limit)
7832 gnus-refer-thread-limit)))
7833 ;; We want to fetch LIMIT *old* headers, but we also have to
7834 ;; re-fetch all the headers in the current buffer, because many of
7835 ;; them may be undisplayed. So we adjust LIMIT.
7836 (when (numberp limit)
7837 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7838 (unless (eq gnus-fetch-old-headers 'invisible)
7839 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7840 ;; Retrieve the headers and read them in.
7841 (if (eq (gnus-retrieve-headers
7842 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7844 (gnus-build-all-threads)
7845 (error "Can't fetch thread from backends that don't support NOV"))
7846 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7847 (gnus-summary-limit-include-thread id)))
7849 (defun gnus-summary-refer-article (message-id)
7850 "Fetch an article specified by MESSAGE-ID."
7851 (interactive "sMessage-ID: ")
7852 (when (and (stringp message-id)
7853 (not (zerop (length message-id))))
7854 ;; Construct the correct Message-ID if necessary.
7855 ;; Suggested by tale@pawl.rpi.edu.
7856 (unless (string-match "^<" message-id)
7857 (setq message-id (concat "<" message-id)))
7858 (unless (string-match ">$" message-id)
7859 (setq message-id (concat message-id ">")))
7860 (let* ((header (gnus-id-to-header message-id))
7862 (gnus-summary-article-sparse-p
7863 (mail-header-number header))
7864 (memq (mail-header-number header)
7865 gnus-newsgroup-limit)))
7868 ;; If the article is present in the buffer we just go to it.
7870 (or (not (gnus-summary-article-sparse-p
7871 (mail-header-number header)))
7874 (gnus-summary-goto-article
7875 (mail-header-number header) nil t)
7877 (gnus-summary-update-article (mail-header-number header)))))
7879 ;; We fetch the article.
7881 (dolist (gnus-override-method (gnus-refer-article-methods))
7882 (gnus-check-server gnus-override-method)
7883 ;; Fetch the header, and display the article.
7884 (when (setq number (gnus-summary-insert-subject message-id))
7885 (gnus-summary-select-article nil nil nil number)
7887 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7889 (defun gnus-refer-article-methods ()
7890 "Return a list of referable methods."
7892 ;; No method, so we default to current and native.
7893 ((null gnus-refer-article-method)
7894 (list gnus-current-select-method gnus-select-method))
7896 ((eq 'current gnus-refer-article-method)
7897 (list gnus-current-select-method))
7898 ;; List of select methods.
7899 ((not (and (symbolp (car gnus-refer-article-method))
7900 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7902 (dolist (method gnus-refer-article-method)
7903 (push (if (eq 'current method)
7904 gnus-current-select-method
7908 ;; One single select method.
7910 (list gnus-refer-article-method))))
7912 (defun gnus-summary-edit-parameters ()
7913 "Edit the group parameters of the current group."
7915 (gnus-group-edit-group gnus-newsgroup-name 'params))
7917 (defun gnus-summary-customize-parameters ()
7918 "Customize the group parameters of the current group."
7920 (gnus-group-customize gnus-newsgroup-name))
7922 (defun gnus-summary-enter-digest-group (&optional force)
7923 "Enter an nndoc group based on the current article.
7924 If FORCE, force a digest interpretation. If not, try
7925 to guess what the document format is."
7927 (let ((conf gnus-current-window-configuration))
7929 (gnus-summary-select-article))
7930 (setq gnus-current-window-configuration conf)
7931 (let* ((name (format "%s-%d"
7932 (gnus-group-prefixed-name
7933 gnus-newsgroup-name (list 'nndoc ""))
7935 (set-buffer gnus-summary-buffer)
7936 gnus-current-article)))
7937 (ogroup gnus-newsgroup-name)
7938 (params (append (gnus-info-params (gnus-get-info ogroup))
7939 (list (cons 'to-group ogroup))
7940 (list (cons 'save-article-group ogroup))))
7941 (case-fold-search t)
7942 (buf (current-buffer))
7945 (set-buffer gnus-original-article-buffer)
7946 ;; Have the digest group inherit the main mail address of
7947 ;; the parent article.
7948 (when (setq to-address (or (gnus-fetch-field "reply-to")
7949 (gnus-fetch-field "from")))
7950 (setq params (append
7951 (list (cons 'to-address
7952 (funcall gnus-decode-encoded-word-function
7954 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7955 (insert-buffer-substring gnus-original-article-buffer)
7956 ;; Remove lines that may lead nndoc to misinterpret the
7959 (goto-char (point-min))
7960 (or (search-forward "\n\n" nil t) (point)))
7961 (goto-char (point-min))
7962 (delete-matching-lines "^Path:\\|^From ")
7965 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7966 (gnus-newsgroup-ephemeral-ignored-charsets
7967 gnus-newsgroup-ignored-charsets))
7968 (gnus-group-read-ephemeral-group
7969 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7971 ,(if force 'mbox 'guess)))
7973 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7975 ;; Make all postings to this group go to the parent group.
7976 (nconc (gnus-info-params (gnus-get-info name))
7978 ;; Couldn't select this doc group.
7979 (switch-to-buffer buf)
7980 (gnus-set-global-variables)
7981 (gnus-configure-windows 'summary)
7982 (gnus-message 3 "Article couldn't be entered?"))
7983 (kill-buffer dig)))))
7985 (defun gnus-summary-read-document (n)
7986 "Open a new group based on the current article(s).
7987 This will allow you to read digests and other similar
7988 documents as newsgroups.
7989 Obeys the standard process/prefix convention."
7991 (let* ((articles (gnus-summary-work-articles n))
7992 (ogroup gnus-newsgroup-name)
7993 (params (append (gnus-info-params (gnus-get-info ogroup))
7994 (list (cons 'to-group ogroup))))
7995 article group egroup groups vgroup)
7996 (while (setq article (pop articles))
7997 (setq group (format "%s-%d" gnus-newsgroup-name article))
7998 (gnus-summary-remove-process-mark article)
7999 (when (gnus-summary-display-article article)
8002 (insert-buffer-substring gnus-original-article-buffer)
8003 ;; Remove some headers that may lead nndoc to make
8005 (message-narrow-to-head)
8006 (goto-char (point-min))
8007 (delete-matching-lines "^\\(Path\\):\\|^From ")
8010 (gnus-group-read-ephemeral-group
8011 group `(nndoc ,group (nndoc-address ,(current-buffer))
8012 (nndoc-article-type guess))
8015 ;; Make all postings to this group go to the parent group.
8016 (nconc (gnus-info-params (gnus-get-info egroup))
8018 (push egroup groups))
8019 ;; Couldn't select this doc group.
8020 (gnus-error 3 "Article couldn't be entered"))))))
8021 ;; Now we have selected all the documents.
8024 (error "None of the articles could be interpreted as documents"))
8025 ((gnus-group-read-ephemeral-group
8026 (setq vgroup (format
8027 "nnvirtual:%s-%s" gnus-newsgroup-name
8028 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8029 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8031 (cons (current-buffer) 'summary)))
8033 (error "Couldn't select virtual nndoc group")))))
8035 (defun gnus-summary-isearch-article (&optional regexp-p)
8036 "Do incremental search forward on the current article.
8037 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8039 (let* ((gnus-inhibit-treatment t)
8040 (old (gnus-summary-select-article)))
8041 (gnus-configure-windows 'article)
8042 (gnus-eval-in-buffer-window gnus-article-buffer
8046 (gnus-article-show-all-headers))
8047 (goto-char (point-min))
8048 (isearch-forward regexp-p)))))
8050 (defun gnus-summary-search-article-forward (regexp &optional backward)
8051 "Search for an article containing REGEXP forward.
8052 If BACKWARD, search backward instead."
8055 (format "Search article %s (regexp%s): "
8056 (if current-prefix-arg "backward" "forward")
8057 (if gnus-last-search-regexp
8058 (concat ", default " gnus-last-search-regexp)
8060 current-prefix-arg))
8061 (if (string-equal regexp "")
8062 (setq regexp (or gnus-last-search-regexp ""))
8063 (setq gnus-last-search-regexp regexp)
8064 (setq gnus-article-before-search gnus-current-article))
8065 ;; Intentionally set gnus-last-article.
8066 (setq gnus-last-article gnus-article-before-search)
8067 (let ((gnus-last-article gnus-last-article))
8068 (if (gnus-summary-search-article regexp backward)
8069 (gnus-summary-show-thread)
8070 (error "Search failed: \"%s\"" regexp))))
8072 (defun gnus-summary-search-article-backward (regexp)
8073 "Search for an article containing REGEXP backward."
8076 (format "Search article backward (regexp%s): "
8077 (if gnus-last-search-regexp
8078 (concat ", default " gnus-last-search-regexp)
8080 (gnus-summary-search-article-forward regexp 'backward))
8083 (defmacro gnus-summary-search-article-position-point (regexp backward)
8084 "Dehighlight the last matched text and goto the beginning position."
8085 (` (if (and gnus-summary-search-article-matched-data
8086 (let ((text (caddr gnus-summary-search-article-matched-data))
8087 (inhibit-read-only t)
8090 (goto-char (car gnus-summary-search-article-matched-data))
8091 (cadr gnus-summary-search-article-matched-data))
8093 (string-match (, regexp) text)))
8094 (if (, backward) (beginning-of-line) (end-of-line))
8095 (goto-char (if (, backward) (point-max) (point-min))))))
8097 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8098 "Place point where X-Face image is displayed."
8099 (if (featurep 'xemacs)
8100 (` (let ((end (if (search-forward "\n\n" nil t)
8101 (goto-char (1- (point)))
8104 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8105 (unless (and (re-search-forward "^From:" end t)
8106 (setq extent (extent-at (point)))
8107 (extent-begin-glyph extent))
8108 (goto-char (, opoint)))))
8109 (` (let ((end (if (search-forward "\n\n" nil t)
8110 (goto-char (1- (point)))
8112 (start (or (search-backward "\n\n" nil t) (point-min))))
8114 (or (text-property-any start end 'x-face-image t);; x-face-e21
8115 (text-property-any start end 'x-face-mule-bitmap-image t)
8118 (defmacro gnus-summary-search-article-highlight-matched-text
8119 (backward treated x-face)
8120 "Highlight matched text in the function `gnus-summary-search-article'."
8121 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8122 (end (set-marker (make-marker) (match-end 0)))
8123 (inhibit-read-only t)
8127 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8129 (lambda (item) (setq items (delq item items)))
8130 '(gnus-treat-buttonize
8131 gnus-treat-fill-article
8132 gnus-treat-fill-long-lines
8133 gnus-treat-emphasize
8134 gnus-treat-highlight-headers
8135 gnus-treat-highlight-citation
8136 gnus-treat-highlight-signature
8137 gnus-treat-overstrike
8138 gnus-treat-display-xface
8139 gnus-treat-buttonize-head
8140 gnus-treat-decode-article-as-default-mime-charset))
8141 (static-if (featurep 'xemacs)
8143 (cons '(x-face-mule-delete-x-face-field
8146 (gnus-treat-display-xface
8147 (when (, x-face) gnus-treat-display-xface)))
8148 (gnus-article-prepare-mime-display)))
8149 (goto-char (if (, backward) start end))
8151 (gnus-summary-search-article-highlight-goto-x-face (point)))
8152 (setq gnus-summary-search-article-matched-data
8153 (list start end (buffer-substring start end)))
8154 (unless (eq start end);; matched text has been deleted. :-<
8155 (put-text-property start end 'face
8156 (or (find-face 'isearch)
8157 'secondary-selection))))))
8160 (defun gnus-summary-search-article (regexp &optional backward)
8161 "Search for an article containing REGEXP.
8162 Optional argument BACKWARD means do search for backward.
8163 `gnus-select-article-hook' is not called during the search."
8164 ;; We have to require this here to make sure that the following
8165 ;; dynamic binding isn't shadowed by autoloading.
8166 (require 'gnus-async)
8168 (let ((gnus-select-article-hook nil) ;Disable hook.
8169 (gnus-article-prepare-hook nil)
8170 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8171 (gnus-use-article-prefetch nil)
8172 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8173 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8174 (sum (current-buffer))
8177 (gnus-save-hidden-threads
8178 (static-if (featurep 'xemacs)
8179 (let ((gnus-inhibit-treatment t))
8180 (setq treated (eq 'old (gnus-summary-select-article)))
8182 (not (and (gnus-buffer-live-p gnus-article-buffer)
8183 (window-live-p (get-buffer-window
8184 gnus-article-buffer t)))))
8185 (gnus-summary-select-article nil t)
8186 (setq treated nil)))
8187 (let ((gnus-inhibit-treatment t)
8188 (x-face-mule-delete-x-face-field 'never))
8189 (setq treated (eq 'old (gnus-summary-select-article)))
8192 (and (gnus-buffer-live-p gnus-article-buffer)
8193 (window-live-p (get-buffer-window
8194 gnus-article-buffer t))
8195 (or (not (string-match "^\\^X-Face:" regexp))
8196 (with-current-buffer gnus-article-buffer
8197 gnus-summary-search-article-matched-data)))))
8198 (gnus-summary-select-article nil t)
8199 (setq treated nil))))
8200 (set-buffer gnus-article-buffer)
8204 (gnus-article-show-all-headers)
8205 (gnus-summary-search-article-position-point regexp backward))
8206 (goto-char (if backward (point-max) (point-min))))
8208 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8210 (re-search-backward regexp nil t)
8211 (re-search-forward regexp nil t))
8212 ;; We found the regexp.
8214 (gnus-summary-search-article-highlight-matched-text
8215 backward treated (string-match "^\\^X-Face:" regexp))
8218 (/ (- 2 (window-height
8219 (get-buffer-window gnus-article-buffer t)))
8222 (get-buffer-window (current-buffer))
8225 (setq point (point)))
8226 ;; We didn't find it, so we go to the next article.
8229 (while (eq found 'not)
8230 (if (not (if backward (gnus-summary-find-prev)
8231 (gnus-summary-find-next)))
8232 ;; No more articles.
8234 ;; Select the next article and adjust point.
8235 (unless (gnus-summary-article-sparse-p
8236 (gnus-summary-article-number))
8238 (let ((gnus-inhibit-treatment t))
8239 (gnus-summary-select-article))
8241 (set-buffer gnus-article-buffer)
8243 (goto-char (if backward (point-max) (point-min))))))))
8244 (gnus-message 7 ""))
8245 ;; Return whether we found the regexp.
8246 (when (eq found 'found)
8248 (gnus-summary-show-thread)
8249 (gnus-summary-goto-subject gnus-current-article)
8250 (gnus-summary-position-point)
8253 (defun gnus-find-matching-articles (header regexp)
8254 "Return a list of all articles that match REGEXP on HEADER.
8255 This search includes all articles in the current group that Gnus has
8256 fetched headers for, whether they are displayed or not."
8257 (let ((articles nil)
8258 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8259 (case-fold-search t))
8260 (dolist (header gnus-newsgroup-headers)
8261 (when (string-match regexp (funcall func header))
8262 (push (mail-header-number header) articles)))
8263 (nreverse articles)))
8265 (defun gnus-summary-find-matching (header regexp &optional backward unread
8266 not-case-fold not-matching)
8267 "Return a list of all articles that match REGEXP on HEADER.
8268 The search stars on the current article and goes forwards unless
8269 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8270 If UNREAD is non-nil, only unread articles will
8271 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8272 in the comparisons. If NOT-MATCHING, return a list of all articles that
8273 not match REGEXP on HEADER."
8274 (let ((case-fold-search (not not-case-fold))
8277 (if (eq (car header) 'extra)
8280 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8282 (error "%s is an invalid header" header))
8283 (unless (fboundp (intern (concat "mail-header-" header)))
8284 (error "%s is not a valid header" header))
8285 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8286 (dolist (d (if (eq backward 'all)
8288 (gnus-data-find-list
8289 (gnus-summary-article-number)
8290 (gnus-data-list backward))))
8291 (when (and (or (not unread) ; We want all articles...
8292 (gnus-data-unread-p d)) ; Or just unreads.
8293 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8297 (funcall func (gnus-data-header d))))
8298 (string-match regexp
8299 (funcall func (gnus-data-header d)))))
8300 (push (gnus-data-number d) articles))) ; Success!
8301 (nreverse articles)))
8303 (defun gnus-summary-execute-command (header regexp command &optional backward)
8304 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8305 If HEADER is an empty string (or nil), the match is done on the entire
8306 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8308 (list (let ((completion-ignore-case t))
8311 (mapcar (lambda (header) (list (format "%s" header)))
8313 '("Number" "Subject" "From" "Lines" "Date"
8314 "Message-ID" "Xref" "References" "Body")
8315 gnus-extra-headers))
8316 nil 'require-match))
8317 (read-string "Regexp: ")
8318 (read-key-sequence "Command: ")
8319 current-prefix-arg))
8320 (when (equal header "Body")
8322 ;; Hidden thread subtrees must be searched as well.
8323 (gnus-summary-show-all-threads)
8324 ;; We don't want to change current point nor window configuration.
8326 (save-window-excursion
8328 gnus-treat-strip-trailing-blank-lines
8329 gnus-treat-strip-leading-blank-lines
8330 gnus-treat-strip-multiple-blank-lines
8331 gnus-treat-hide-boring-headers
8332 gnus-treat-fold-newsgroups
8333 gnus-article-prepare-hook)
8334 (gnus-message 6 "Executing %s..." (key-description command))
8335 ;; We'd like to execute COMMAND interactively so as to give arguments.
8336 (gnus-execute header regexp
8337 `(call-interactively ',(key-binding command))
8339 (gnus-message 6 "Executing %s...done" (key-description command))))))
8341 (defun gnus-summary-beginning-of-article ()
8342 "Scroll the article back to the beginning."
8344 (gnus-summary-select-article)
8345 (gnus-configure-windows 'article)
8346 (gnus-eval-in-buffer-window gnus-article-buffer
8348 (goto-char (point-min))
8349 (when gnus-page-broken
8350 (gnus-narrow-to-page))))
8352 (defun gnus-summary-end-of-article ()
8353 "Scroll to the end of the article."
8355 (gnus-summary-select-article)
8356 (gnus-configure-windows 'article)
8357 (gnus-eval-in-buffer-window gnus-article-buffer
8359 (goto-char (point-max))
8361 (when gnus-page-broken
8362 (gnus-narrow-to-page))))
8364 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8365 "Truncate to LEN and quote all \"(\"'s in STRING."
8366 (gnus-replace-in-string (if (and len (> (length string) len))
8367 (substring string 0 len)
8371 (defun gnus-summary-print-article (&optional filename n)
8372 "Generate and print a PostScript image of the N next (mail) articles.
8374 If N is negative, print the N previous articles. If N is nil and articles
8375 have been marked with the process mark, print these instead.
8377 If the optional first argument FILENAME is nil, send the image to the
8378 printer. If FILENAME is a string, save the PostScript image in a file with
8379 that name. If FILENAME is a number, prompt the user for the name of the file
8381 (interactive (list (ps-print-preprint current-prefix-arg)))
8382 (dolist (article (gnus-summary-work-articles n))
8383 (gnus-summary-select-article nil nil 'pseudo article)
8384 (gnus-eval-in-buffer-window gnus-article-buffer
8385 (gnus-print-buffer))
8386 (gnus-summary-remove-process-mark article))
8387 (ps-despool filename))
8389 (defun gnus-print-buffer ()
8390 (let ((buffer (generate-new-buffer " *print*")))
8393 (copy-to-buffer buffer (point-min) (point-max))
8395 (gnus-article-delete-invisible-text)
8396 (gnus-remove-text-with-property 'gnus-decoration)
8397 (when (gnus-visual-p 'article-highlight 'highlight)
8398 ;; Copy-to-buffer doesn't copy overlay. So redo
8400 (let ((gnus-article-buffer buffer))
8401 (gnus-article-highlight-citation t)
8402 (gnus-article-highlight-signature)))
8403 (let ((ps-left-header
8406 (gnus-summary-print-truncate-and-quote
8407 (mail-header-subject gnus-current-headers)
8410 (gnus-summary-print-truncate-and-quote
8411 (mail-header-from gnus-current-headers)
8415 "/pagenumberstring load"
8417 (mail-header-date gnus-current-headers) ")"))))
8418 (gnus-run-hooks 'gnus-ps-print-hook)
8421 (ps-spool-buffer-with-faces)
8422 (ps-spool-buffer)))))
8423 (kill-buffer buffer))))
8425 (defun gnus-summary-show-article (&optional arg)
8426 "Force redisplaying of the current article.
8427 If ARG (the prefix) is a number, show the article with the charset
8428 defined in `gnus-summary-show-article-charset-alist', or the charset
8430 If ARG (the prefix) is non-nil and not a number, show the raw article
8431 without any article massaging functions being run. Normally, the key strokes
8436 (gnus-summary-show-article t)
8437 (let* ((gnus-newsgroup-charset
8438 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8439 (mm-read-coding-system
8440 "View as charset: " ;; actually it is coding system.
8442 (set-buffer gnus-article-buffer)
8443 (mm-detect-coding-region (point) (point-max))))))
8444 (default-mime-charset gnus-newsgroup-charset)
8445 (gnus-newsgroup-ignored-charsets 'gnus-all))
8446 (gnus-summary-select-article nil 'force)
8447 (let ((deps gnus-newsgroup-dependencies)
8450 (set-buffer gnus-original-article-buffer)
8452 (message-narrow-to-head)
8453 (setq head (buffer-string))
8454 (goto-char (point-min))
8455 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8456 (goto-char (point-max))
8458 (setq lines (1- (count-lines (point) (point-max))))))
8460 (insert (format "211 %d Article retrieved.\n"
8461 (cdr gnus-article-current)))
8463 (if lines (insert (format "Lines: %d\n" lines)))
8465 (let ((nntp-server-buffer (current-buffer)))
8466 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8467 (gnus-data-set-header
8468 (gnus-data-find (cdr gnus-article-current))
8470 (gnus-summary-update-article-line
8471 (cdr gnus-article-current) header)
8472 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8473 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8475 ;; Select the article the normal way.
8476 (gnus-summary-select-article nil 'force))
8478 ;; We have to require this here to make sure that the following
8479 ;; dynamic binding isn't shadowed by autoloading.
8480 (require 'gnus-async)
8482 ;; Bind the article treatment functions to nil.
8483 (let ((gnus-have-all-headers t)
8484 gnus-article-prepare-hook
8485 gnus-article-decode-hook
8488 (gnus-inhibit-treatment t))
8489 (gnus-summary-select-article nil 'force))))
8490 (gnus-summary-goto-subject gnus-current-article)
8491 (gnus-summary-position-point))
8493 (defun gnus-summary-show-raw-article ()
8494 "Show the raw article without any article massaging functions being run."
8496 (gnus-summary-show-article t))
8498 (defun gnus-summary-verbose-headers (&optional arg)
8499 "Toggle permanent full header display.
8500 If ARG is a positive number, turn header display on.
8501 If ARG is a negative number, turn header display off."
8503 (setq gnus-show-all-headers
8504 (cond ((or (not (numberp arg))
8506 (not gnus-show-all-headers))
8509 (gnus-summary-show-article))
8511 (defun gnus-summary-toggle-header (&optional arg)
8512 "Show the headers if they are hidden, or hide them if they are shown.
8513 If ARG is a positive number, show the entire header.
8514 If ARG is a negative number, hide the unwanted header lines."
8516 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8517 (get-buffer-window gnus-article-buffer t))))
8518 (with-current-buffer gnus-article-buffer
8520 (article-narrow-to-head)
8521 (let* ((buffer-read-only nil)
8522 (inhibit-point-motion-hooks t)
8523 (hidden (if (numberp arg)
8525 (gnus-article-hidden-text-p 'headers)))
8527 (delete-region (point-min) (point-max))
8528 (with-current-buffer gnus-original-article-buffer
8529 (goto-char (setq s (point-min)))
8530 (setq e (if (search-forward "\n\n" nil t)
8533 (insert-buffer-substring gnus-original-article-buffer s e)
8534 (article-decode-encoded-words)
8536 (let ((gnus-treat-hide-headers nil)
8537 (gnus-treat-hide-boring-headers nil))
8538 (gnus-delete-wash-type 'headers)
8539 (gnus-treat-article 'head))
8540 (gnus-treat-article 'head))
8543 (set-window-start window (goto-char (point-min))))
8544 (setq gnus-page-broken
8545 (when gnus-break-pages
8546 (gnus-narrow-to-page)
8548 (gnus-set-mode-line 'article)))))
8550 (defun gnus-summary-show-all-headers ()
8551 "Make all header lines visible."
8553 (gnus-summary-toggle-header 1))
8555 (defun gnus-summary-toggle-mime (&optional arg)
8556 "Toggle MIME processing.
8557 If ARG is a positive number, turn MIME processing on."
8559 (setq gnus-show-mime
8561 (not gnus-show-mime)
8562 (> (prefix-numeric-value arg) 0)))
8563 (gnus-summary-select-article t 'force))
8565 (defun gnus-summary-caesar-message (&optional arg)
8566 "Caesar rotate the current article by 13.
8567 The numerical prefix specifies how many places to rotate each letter
8570 (gnus-summary-select-article)
8571 (let ((mail-header-separator ""))
8572 (gnus-eval-in-buffer-window gnus-article-buffer
8575 (let ((start (window-start))
8577 (message-caesar-buffer-body arg)
8578 (set-window-start (get-buffer-window (current-buffer)) start))))))
8580 (autoload 'unmorse-region "morse"
8581 "Convert morse coded text in region to ordinary ASCII text."
8584 (defun gnus-summary-morse-message (&optional arg)
8585 "Morse decode the current article."
8587 (gnus-summary-select-article)
8588 (let ((mail-header-separator ""))
8589 (gnus-eval-in-buffer-window gnus-article-buffer
8593 (let ((pos (window-start))
8595 (goto-char (point-min))
8596 (when (message-goto-body)
8597 (gnus-narrow-to-body))
8598 (goto-char (point-min))
8599 (while (re-search-forward "·" (point-max) t)
8600 (replace-match "."))
8601 (unmorse-region (point-min) (point-max))
8603 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8605 (defun gnus-summary-stop-page-breaking ()
8606 "Stop page breaking in the current article."
8608 (gnus-summary-select-article)
8609 (gnus-eval-in-buffer-window gnus-article-buffer
8611 (when (gnus-visual-p 'page-marker)
8612 (let ((buffer-read-only nil))
8613 (gnus-remove-text-with-property 'gnus-prev)
8614 (gnus-remove-text-with-property 'gnus-next))
8615 (setq gnus-page-broken nil))))
8617 (defun gnus-summary-move-article (&optional n to-newsgroup
8618 select-method action)
8619 "Move the current article to a different newsgroup.
8620 If N is a positive number, move the N next articles.
8621 If N is a negative number, move the N previous articles.
8622 If N is nil and any articles have been marked with the process mark,
8623 move those articles instead.
8624 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8625 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8626 re-spool using this method.
8628 When called interactively with TO-NEWSGROUP being nil, the value of
8629 the variable `gnus-move-split-methods' is used for finding a default
8630 for the target newsgroup.
8632 For this function to work, both the current newsgroup and the
8633 newsgroup that you want to move to have to support the `request-move'
8634 and `request-accept' functions.
8636 ACTION can be either `move' (the default), `crosspost' or `copy'."
8639 (setq action 'move))
8640 ;; Check whether the source group supports the required functions.
8641 (cond ((and (eq action 'move)
8642 (not (gnus-check-backend-function
8643 'request-move-article gnus-newsgroup-name)))
8644 (error "The current group does not support article moving"))
8645 ((and (eq action 'crosspost)
8646 (not (gnus-check-backend-function
8647 'request-replace-article gnus-newsgroup-name)))
8648 (error "The current group does not support article editing")))
8649 (let ((articles (gnus-summary-work-articles n))
8650 (prefix (if (gnus-check-backend-function
8651 'request-move-article gnus-newsgroup-name)
8652 (gnus-group-real-prefix gnus-newsgroup-name)
8654 (names '((move "Move" "Moving")
8655 (copy "Copy" "Copying")
8656 (crosspost "Crosspost" "Crossposting")))
8657 (copy-buf (save-excursion
8658 (nnheader-set-temp-buffer " *copy article*")))
8659 (default-marks gnus-article-mark-lists)
8660 (no-expire-marks (delete '(expirable . expire)
8661 (copy-sequence gnus-article-mark-lists)))
8662 art-group to-method new-xref article to-groups)
8663 (unless (assq action names)
8664 (error "Unknown action %s" action))
8665 ;; Read the newsgroup name.
8666 (when (and (not to-newsgroup)
8667 (not select-method))
8668 (if (and gnus-move-split-methods
8670 (and (memq gnus-current-article articles)
8671 (gnus-buffer-live-p gnus-original-article-buffer))))
8672 ;; When `gnus-move-split-methods' is non-nil, we have to
8673 ;; select an article to give `gnus-read-move-group-name' an
8674 ;; opportunity to suggest an appropriate default. However,
8675 ;; we needn't render or mark the article.
8676 (let ((gnus-display-mime-function nil)
8677 (gnus-article-prepare-hook nil)
8678 (gnus-mark-article-hook nil))
8679 (gnus-summary-select-article nil nil nil (car articles))))
8681 (gnus-read-move-group-name
8682 (cadr (assq action names))
8683 (symbol-value (intern (format "gnus-current-%s-group" action)))
8685 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8686 (setq to-method (or select-method
8687 (gnus-server-to-method
8688 (gnus-group-method to-newsgroup))))
8689 ;; Check the method we are to move this article to...
8690 (unless (gnus-check-backend-function
8691 'request-accept-article (car to-method))
8692 (error "%s does not support article copying" (car to-method)))
8693 (unless (gnus-check-server to-method)
8694 (error "Can't open server %s" (car to-method)))
8695 (gnus-message 6 "%s to %s: %s..."
8696 (caddr (assq action names))
8697 (or (car select-method) to-newsgroup) articles)
8699 (setq article (pop articles))
8703 ;; Move the article.
8705 ;; Remove this article from future suppression.
8706 (gnus-dup-unsuppress-article article)
8707 (gnus-request-move-article
8708 article ; Article to move
8709 gnus-newsgroup-name ; From newsgroup
8710 (nth 1 (gnus-find-method-for-group
8711 gnus-newsgroup-name)) ; Server
8712 (list 'gnus-request-accept-article
8713 to-newsgroup (list 'quote select-method)
8714 (not articles) t) ; Accept form
8715 (not articles))) ; Only save nov last time
8716 ;; Copy the article.
8719 (set-buffer copy-buf)
8720 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8721 (gnus-request-accept-article
8722 to-newsgroup select-method (not articles) t))))
8723 ;; Crosspost the article.
8724 ((eq action 'crosspost)
8725 (let ((xref (message-tokenize-header
8726 (mail-header-xref (gnus-summary-article-header article))
8728 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8729 ":" (number-to-string article)))
8731 (setq xref (list (system-name))))
8734 (mapconcat 'identity
8735 (delete "Xref:" (delete new-xref xref))
8739 (set-buffer copy-buf)
8740 ;; First put the article in the destination group.
8741 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8742 (when (consp (setq art-group
8743 (gnus-request-accept-article
8744 to-newsgroup select-method (not articles))))
8745 (setq new-xref (concat new-xref " " (car art-group)
8747 (number-to-string (cdr art-group))))
8748 ;; Now we have the new Xrefs header, so we insert
8749 ;; it and replace the new article.
8750 (nnheader-replace-header "Xref" new-xref)
8751 (gnus-request-replace-article
8752 (cdr art-group) to-newsgroup (current-buffer))
8756 (gnus-message 1 "Couldn't %s article %s: %s"
8757 (cadr (assq action names)) article
8758 (nnheader-get-report (car to-method))))
8759 ((eq art-group 'junk)
8760 (when (eq action 'move)
8761 (gnus-summary-mark-article article gnus-canceled-mark)
8762 (gnus-message 4 "Deleted article %s" article)))
8764 (let* ((pto-group (gnus-group-prefixed-name
8765 (car art-group) to-method))
8767 (gnus-gethash pto-group gnus-newsrc-hashtb))
8768 (info (nth 2 entry))
8769 (to-group (gnus-info-group info))
8771 ;; Update the group that has been moved to.
8773 (memq action '(move copy)))
8774 (unless (member to-group to-groups)
8775 (push to-group to-groups))
8777 (unless (memq article gnus-newsgroup-unreads)
8778 (push 'read to-marks)
8780 info (gnus-add-to-range (gnus-info-read info)
8781 (list (cdr art-group)))))
8783 ;; See whether the article is to be put in the cache.
8784 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8787 (to-article (cdr art-group)))
8789 ;; Enter the article into the cache in the new group,
8790 ;; if that is required.
8791 (when gnus-use-cache
8792 (gnus-cache-possibly-enter-article
8794 (let ((header (copy-sequence
8795 (gnus-summary-article-header article))))
8796 (mail-header-set-number header to-article)
8798 (memq article gnus-newsgroup-marked)
8799 (memq article gnus-newsgroup-dormant)
8800 (memq article gnus-newsgroup-unreads)))
8802 (when gnus-preserve-marks
8803 ;; Copy any marks over to the new group.
8804 (when (and (equal to-group gnus-newsgroup-name)
8805 (not (memq article gnus-newsgroup-unreads)))
8806 ;; Mark this article as read in this group.
8807 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8808 (setcdr (gnus-active to-group) to-article)
8809 (setcdr gnus-newsgroup-active to-article))
8812 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8813 (when (memq article (symbol-value
8814 (intern (format "gnus-newsgroup-%s"
8816 (push (cdar marks) to-marks)
8817 ;; If the other group is the same as this group,
8818 ;; then we have to add the mark to the list.
8819 (when (equal to-group gnus-newsgroup-name)
8820 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8823 (intern (format "gnus-newsgroup-%s"
8825 ;; Copy the marks to other group.
8826 (gnus-add-marked-articles
8827 to-group (cdar marks) (list to-article) info)))
8828 (setq marks (cdr marks)))
8830 (gnus-request-set-mark to-group (list (list (list to-article)
8835 (concat "(gnus-group-set-info '"
8836 (gnus-prin1-to-string (gnus-get-info to-group))
8839 ;; Update the Xref header in this article to point to
8840 ;; the new crossposted article we have just created.
8841 (when (eq action 'crosspost)
8843 (set-buffer copy-buf)
8844 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8845 (nnheader-replace-header "Xref" new-xref)
8846 (gnus-request-replace-article
8847 article gnus-newsgroup-name (current-buffer)))))
8849 ;;;!!!Why is this necessary?
8850 (set-buffer gnus-summary-buffer)
8852 (gnus-summary-goto-subject article)
8853 (when (eq action 'move)
8854 (gnus-summary-mark-article article gnus-canceled-mark))))
8855 (gnus-summary-remove-process-mark article))
8856 ;; Re-activate all groups that have been moved to.
8858 (set-buffer gnus-group-buffer)
8859 (let ((gnus-group-marked to-groups))
8860 (gnus-group-get-new-news-this-group nil t)))
8862 (gnus-kill-buffer copy-buf)
8863 (gnus-summary-position-point)
8864 (gnus-set-mode-line 'summary)))
8866 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8867 "Move the current article to a different newsgroup.
8868 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8869 When called interactively, if TO-NEWSGROUP is nil, use the value of
8870 the variable `gnus-move-split-methods' for finding a default target
8872 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8873 re-spool using this method."
8875 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8877 (defun gnus-summary-crosspost-article (&optional n)
8878 "Crosspost the current article to some other group."
8880 (gnus-summary-move-article n nil nil 'crosspost))
8882 (defcustom gnus-summary-respool-default-method nil
8883 "Default method type for respooling an article.
8884 If nil, use to the current newsgroup method."
8886 :group 'gnus-summary-mail)
8888 (defun gnus-summary-respool-article (&optional n method)
8889 "Respool the current article.
8890 The article will be squeezed through the mail spooling process again,
8891 which means that it will be put in some mail newsgroup or other
8892 depending on `nnmail-split-methods'.
8893 If N is a positive number, respool the N next articles.
8894 If N is a negative number, respool the N previous articles.
8895 If N is nil and any articles have been marked with the process mark,
8896 respool those articles instead.
8898 Respooling can be done both from mail groups and \"real\" newsgroups.
8899 In the former case, the articles in question will be moved from the
8900 current group into whatever groups they are destined to. In the
8901 latter case, they will be copied into the relevant groups."
8903 (list current-prefix-arg
8904 (let* ((methods (gnus-methods-using 'respool))
8906 (symbol-name (or gnus-summary-respool-default-method
8907 (car (gnus-find-method-for-group
8908 gnus-newsgroup-name)))))
8910 (gnus-completing-read-with-default
8911 methname "What backend do you want to use when respooling?"
8912 methods nil t nil 'gnus-mail-method-history))
8915 ((zerop (length (setq ms (gnus-servers-using-backend
8917 (list (intern method) ""))
8921 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8922 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8925 (error "No method given for respooling"))
8926 (if (assoc (symbol-name
8927 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8928 (gnus-methods-using 'respool))
8929 (gnus-summary-move-article n nil method)
8930 (gnus-summary-copy-article n nil method)))
8932 (defun gnus-summary-import-article (file &optional edit)
8933 "Import an arbitrary file into a mail newsgroup."
8934 (interactive "fImport file: \nP")
8935 (let ((group gnus-newsgroup-name)
8936 (now (current-time))
8937 atts lines group-art)
8938 (unless (gnus-check-backend-function 'request-accept-article group)
8939 (error "%s does not support article importing" group))
8940 (or (file-readable-p file)
8941 (not (file-regular-p file))
8942 (error "Can't read %s" file))
8944 (set-buffer (gnus-get-buffer-create " *import file*"))
8946 (nnheader-insert-file-contents file)
8947 (goto-char (point-min))
8948 (if (nnheader-article-p)
8950 (goto-char (point-min))
8951 (search-forward "\n\n" nil t)
8952 (narrow-to-region (point-min) (1- (point)))
8953 (goto-char (point-min))
8954 (unless (re-search-forward "^date:" nil t)
8955 (goto-char (point-max))
8956 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8957 ;; This doesn't look like an article, so we fudge some headers.
8958 (setq atts (file-attributes file)
8959 lines (count-lines (point-min) (point-max)))
8960 (insert "From: " (read-string "From: ") "\n"
8961 "Subject: " (read-string "Subject: ") "\n"
8962 "Date: " (message-make-date (nth 5 atts)) "\n"
8963 "Message-ID: " (message-make-message-id) "\n"
8964 "Lines: " (int-to-string lines) "\n"
8965 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8966 (setq group-art (gnus-request-accept-article group nil t))
8967 (kill-buffer (current-buffer)))
8968 (setq gnus-newsgroup-active (gnus-activate-group group))
8970 (gnus-summary-goto-article (cdr group-art) nil t)
8972 (gnus-summary-edit-article))))
8974 (defun gnus-summary-create-article ()
8975 "Create an article in a mail newsgroup."
8977 (let ((group gnus-newsgroup-name)
8978 (now (current-time))
8980 (unless (gnus-check-backend-function 'request-accept-article group)
8981 (error "%s does not support article importing" group))
8983 (set-buffer (gnus-get-buffer-create " *import file*"))
8985 (goto-char (point-min))
8986 ;; This doesn't look like an article, so we fudge some headers.
8987 (insert "From: " (read-string "From: ") "\n"
8988 "Subject: " (read-string "Subject: ") "\n"
8989 "Date: " (message-make-date now) "\n"
8990 "Message-ID: " (message-make-message-id) "\n")
8991 (setq group-art (gnus-request-accept-article group nil t))
8992 (kill-buffer (current-buffer)))
8993 (setq gnus-newsgroup-active (gnus-activate-group group))
8995 (gnus-summary-goto-article (cdr group-art) nil t)
8996 (gnus-summary-edit-article)))
8998 (defun gnus-summary-article-posted-p ()
8999 "Say whether the current (mail) article is available from news as well.
9000 This will be the case if the article has both been mailed and posted."
9002 (let ((id (mail-header-references (gnus-summary-article-header)))
9003 (gnus-override-method (car (gnus-refer-article-methods))))
9004 (if (gnus-request-head id "")
9005 (gnus-message 2 "The current message was found on %s"
9006 gnus-override-method)
9007 (gnus-message 2 "The current message couldn't be found on %s"
9008 gnus-override-method)
9011 (defun gnus-summary-expire-articles (&optional now)
9012 "Expire all articles that are marked as expirable in the current group."
9014 (when (gnus-check-backend-function
9015 'request-expire-articles gnus-newsgroup-name)
9016 ;; This backend supports expiry.
9017 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9018 (expirable (if total
9020 ;; We need to update the info for
9021 ;; this group for `gnus-list-of-read-articles'
9022 ;; to give us the right answer.
9023 (gnus-run-hooks 'gnus-exit-group-hook)
9024 (gnus-summary-update-info)
9025 (gnus-list-of-read-articles gnus-newsgroup-name))
9026 (setq gnus-newsgroup-expirable
9027 (sort gnus-newsgroup-expirable '<))))
9028 (expiry-wait (if now 'immediate
9029 (gnus-group-find-parameter
9030 gnus-newsgroup-name 'expiry-wait)))
9031 (nnmail-expiry-target
9032 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9033 nnmail-expiry-target))
9036 ;; There are expirable articles in this group, so we run them
9037 ;; through the expiry process.
9038 (gnus-message 6 "Expiring articles...")
9039 (unless (gnus-check-group gnus-newsgroup-name)
9040 (error "Can't open server for %s" gnus-newsgroup-name))
9041 ;; The list of articles that weren't expired is returned.
9044 (let ((nnmail-expiry-wait-function nil)
9045 (nnmail-expiry-wait expiry-wait))
9046 (setq es (gnus-request-expire-articles
9047 expirable gnus-newsgroup-name)))
9048 (setq es (gnus-request-expire-articles
9049 expirable gnus-newsgroup-name)))
9051 (setq gnus-newsgroup-expirable es))
9052 ;; We go through the old list of expirable, and mark all
9053 ;; really expired articles as nonexistent.
9054 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9055 (let ((gnus-use-cache nil))
9056 (dolist (article expirable)
9057 (when (and (not (memq article es))
9058 (gnus-data-find article))
9059 (gnus-summary-mark-article article gnus-canceled-mark))))))
9060 (gnus-message 6 "Expiring articles...done")))))
9062 (defun gnus-summary-expire-articles-now ()
9063 "Expunge all expirable articles in the current group.
9064 This means that *all* articles that are marked as expirable will be
9065 deleted forever, right now."
9067 (or gnus-expert-user
9069 "Are you really, really, really sure you want to delete all these messages? ")
9071 (gnus-summary-expire-articles t))
9073 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9074 (defun gnus-summary-delete-article (&optional n)
9075 "Delete the N next (mail) articles.
9076 This command actually deletes articles. This is not a marking
9077 command. The article will disappear forever from your life, never to
9079 If N is negative, delete backwards.
9080 If N is nil and articles have been marked with the process mark,
9081 delete these instead."
9083 (unless (gnus-check-backend-function 'request-expire-articles
9084 gnus-newsgroup-name)
9085 (error "The current newsgroup does not support article deletion"))
9086 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9087 (error "Couldn't open server"))
9088 ;; Compute the list of articles to delete.
9089 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9090 (nnmail-expiry-target 'delete)
9092 (if (and gnus-novice-user
9093 (not (gnus-yes-or-no-p
9094 (format "Do you really want to delete %s forever? "
9095 (if (> (length articles) 1)
9096 (format "these %s articles" (length articles))
9099 ;; Delete the articles.
9100 (setq not-deleted (gnus-request-expire-articles
9101 articles gnus-newsgroup-name 'force))
9103 (gnus-summary-remove-process-mark (car articles))
9104 ;; The backend might not have been able to delete the article
9106 (unless (memq (car articles) not-deleted)
9107 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9108 (setq articles (cdr articles)))
9110 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9111 (gnus-summary-position-point)
9112 (gnus-set-mode-line 'summary)
9115 (defun gnus-summary-edit-article (&optional force)
9116 "Edit the current article.
9117 This will have permanent effect only in mail groups.
9118 If FORCE is non-nil, allow editing of articles even in read-only
9122 (set-buffer gnus-summary-buffer)
9123 (let ((mail-parse-charset gnus-newsgroup-charset)
9124 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9125 (gnus-set-global-variables)
9126 (when (and (not force)
9127 (gnus-group-read-only-p))
9128 (error "The current newsgroup does not support article editing"))
9129 (gnus-summary-show-article t)
9130 (gnus-article-edit-article
9132 `(lambda (no-highlight)
9133 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9134 (message-options message-options)
9135 (message-options-set-recipient)
9136 (mail-parse-ignored-charsets
9137 ',gnus-newsgroup-ignored-charsets))
9138 (gnus-summary-edit-article-done
9139 ,(or (mail-header-references gnus-current-headers) "")
9140 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9142 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9144 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9146 "Make edits to the current article permanent."
9149 ;; The buffer restriction contains the entire article if it exists.
9150 (when (article-goto-body)
9151 (let ((lines (count-lines (point) (point-max)))
9152 (length (- (point-max) (point)))
9153 (case-fold-search t)
9154 (body (copy-marker (point))))
9155 (goto-char (point-min))
9156 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9157 (delete-region (match-beginning 1) (match-end 1))
9158 (insert (number-to-string length)))
9159 (goto-char (point-min))
9160 (when (re-search-forward
9161 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9162 (delete-region (match-beginning 1) (match-end 1))
9163 (insert (number-to-string length)))
9164 (goto-char (point-min))
9165 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9166 (delete-region (match-beginning 1) (match-end 1))
9167 (insert (number-to-string lines))))))
9168 ;; Replace the article.
9169 (let ((buf (current-buffer)))
9171 (insert-buffer-substring buf)
9173 (if (and (not read-only)
9174 (not (gnus-request-replace-article
9175 (cdr gnus-article-current) (car gnus-article-current)
9176 (current-buffer) t)))
9177 (error "Couldn't replace article")
9178 ;; Update the summary buffer.
9180 (equal (message-tokenize-header references " ")
9181 (message-tokenize-header
9182 (or (message-fetch-field "references") "") " ")))
9183 ;; We only have to update this line.
9186 (message-narrow-to-head)
9187 (let ((head (buffer-string))
9190 (insert (format "211 %d Article retrieved.\n"
9191 (cdr gnus-article-current)))
9194 (let ((nntp-server-buffer (current-buffer)))
9195 (setq header (car (gnus-get-newsgroup-headers
9198 (set-buffer gnus-summary-buffer)
9199 (gnus-data-set-header
9200 (gnus-data-find (cdr gnus-article-current))
9202 (gnus-summary-update-article-line
9203 (cdr gnus-article-current) header)
9204 (if (gnus-summary-goto-subject
9205 (cdr gnus-article-current) nil t)
9206 (gnus-summary-update-secondary-mark
9207 (cdr gnus-article-current))))))))
9209 (set-buffer (or buffer gnus-summary-buffer))
9210 (gnus-summary-update-article (cdr gnus-article-current))
9211 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9212 (gnus-summary-update-secondary-mark
9213 (cdr gnus-article-current))))
9214 ;; Prettify the article buffer again.
9215 (unless no-highlight
9217 (set-buffer gnus-article-buffer)
9218 ;;;!!! Fix this -- article should be rehighlighted.
9219 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9220 (set-buffer gnus-original-article-buffer)
9221 (gnus-request-article
9222 (cdr gnus-article-current)
9223 (car gnus-article-current) (current-buffer))))
9224 ;; Prettify the summary buffer line.
9225 (when (gnus-visual-p 'summary-highlight 'highlight)
9226 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9228 (defun gnus-summary-edit-wash (key)
9229 "Perform editing command KEY in the article buffer."
9233 (message "%s" (concat (this-command-keys) "- "))
9236 (gnus-summary-edit-article)
9237 (execute-kbd-macro (concat (this-command-keys) key))
9238 (gnus-article-edit-done))
9242 (defun gnus-summary-respool-query (&optional silent trace)
9243 "Query where the respool algorithm would put this article."
9245 (let (gnus-mark-article-hook)
9246 (gnus-summary-select-article)
9248 (set-buffer gnus-original-article-buffer)
9250 (message-narrow-to-head)
9251 (let ((groups (nnmail-article-group 'identity trace)))
9254 (message "This message would go to %s"
9255 (mapconcat 'car groups ", "))
9256 (message "This message would go to no groups"))
9259 (defun gnus-summary-respool-trace ()
9260 "Trace where the respool algorithm would put this article.
9261 Display a buffer showing all fancy splitting patterns which matched."
9263 (gnus-summary-respool-query nil t))
9265 ;; Summary marking commands.
9267 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9268 "Mark articles which has the same subject as read, and then select the next.
9269 If UNMARK is positive, remove any kind of mark.
9270 If UNMARK is negative, tick articles."
9273 (setq unmark (prefix-numeric-value unmark)))
9275 (gnus-summary-mark-same-subject
9276 (gnus-summary-article-subject) unmark)))
9277 ;; Select next unread article. If auto-select-same mode, should
9278 ;; select the first unread article.
9279 (gnus-summary-next-article t (and gnus-auto-select-same
9280 (gnus-summary-article-subject)))
9281 (gnus-message 7 "%d article%s marked as %s"
9282 count (if (= count 1) " is" "s are")
9283 (if unmark "unread" "read"))))
9285 (defun gnus-summary-kill-same-subject (&optional unmark)
9286 "Mark articles which has the same subject as read.
9287 If UNMARK is positive, remove any kind of mark.
9288 If UNMARK is negative, tick articles."
9291 (setq unmark (prefix-numeric-value unmark)))
9293 (gnus-summary-mark-same-subject
9294 (gnus-summary-article-subject) unmark)))
9295 ;; If marked as read, go to next unread subject.
9297 ;; Go to next unread subject.
9298 (gnus-summary-next-subject 1 t))
9299 (gnus-message 7 "%d articles are marked as %s"
9300 count (if unmark "unread" "read"))))
9302 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9303 "Mark articles with same SUBJECT as read, and return marked number.
9304 If optional argument UNMARK is positive, remove any kinds of marks.
9305 If optional argument UNMARK is negative, mark articles as unread instead."
9309 ((null unmark) ; Mark as read.
9312 (gnus-summary-mark-article-as-read gnus-killed-mark)
9313 (gnus-summary-show-thread) t)
9314 (gnus-summary-find-subject subject))
9315 (setq count (1+ count))))
9316 ((> unmark 0) ; Tick.
9319 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9320 (gnus-summary-show-thread) t)
9321 (gnus-summary-find-subject subject))
9322 (setq count (1+ count))))
9323 (t ; Mark as unread.
9326 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9327 (gnus-summary-show-thread) t)
9328 (gnus-summary-find-subject subject))
9329 (setq count (1+ count)))))
9330 (gnus-set-mode-line 'summary)
9331 ;; Return the number of marked articles.
9334 (defun gnus-summary-mark-as-processable (n &optional unmark)
9335 "Set the process mark on the next N articles.
9336 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9337 the process mark instead. The difference between N and the actual
9338 number of articles marked is returned."
9340 (if (and (null n) (gnus-region-active-p))
9341 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9342 (setq n (prefix-numeric-value n))
9343 (let ((backward (< n 0))
9348 (gnus-summary-remove-process-mark
9349 (gnus-summary-article-number))
9350 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9351 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9354 (gnus-message 7 "No more articles"))
9355 (gnus-summary-recenter)
9356 (gnus-summary-position-point)
9359 (defun gnus-summary-unmark-as-processable (n)
9360 "Remove the process mark from the next N articles.
9361 If N is negative, unmark backward instead. The difference between N and
9362 the actual number of articles unmarked is returned."
9364 (gnus-summary-mark-as-processable n t))
9366 (defun gnus-summary-unmark-all-processable ()
9367 "Remove the process mark from all articles."
9370 (while gnus-newsgroup-processable
9371 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9372 (gnus-summary-position-point))
9374 (defun gnus-summary-add-mark (article type)
9375 "Mark ARTICLE with a mark of TYPE."
9376 (let ((vtype (car (assq type gnus-article-mark-lists)))
9379 (error "No such mark type: %s" type)
9380 (setq var (intern (format "gnus-newsgroup-%s" type)))
9381 (set var (cons article (symbol-value var)))
9382 (if (memq type '(processable cached replied forwarded recent saved))
9383 (gnus-summary-update-secondary-mark article)
9384 ;;; !!! This is bogus. We should find out what primary
9385 ;;; !!! mark we want to set.
9386 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9388 (defun gnus-summary-mark-as-expirable (n)
9389 "Mark N articles forward as expirable.
9390 If N is negative, mark backward instead. The difference between N and
9391 the actual number of articles marked is returned."
9393 (gnus-summary-mark-forward n gnus-expirable-mark))
9395 (defun gnus-summary-mark-as-spam (n)
9396 "Mark N articles forward as spam.
9397 If N is negative, mark backward instead. The difference between N and
9398 the actual number of articles marked is returned."
9400 (gnus-summary-mark-forward n gnus-spam-mark))
9402 (defun gnus-summary-mark-article-as-replied (article)
9403 "Mark ARTICLE as replied to and update the summary line.
9404 ARTICLE can also be a list of articles."
9405 (interactive (list (gnus-summary-article-number)))
9406 (let ((articles (if (listp article) article (list article))))
9407 (dolist (article articles)
9408 (push article gnus-newsgroup-replied)
9409 (let ((buffer-read-only nil))
9410 (when (gnus-summary-goto-subject article nil t)
9411 (gnus-summary-update-secondary-mark article))))))
9413 (defun gnus-summary-mark-article-as-forwarded (article)
9414 "Mark ARTICLE as forwarded and update the summary line.
9415 ARTICLE can also be a list of articles."
9416 (let ((articles (if (listp article) article (list article))))
9417 (dolist (article articles)
9418 (push article gnus-newsgroup-forwarded)
9419 (let ((buffer-read-only nil))
9420 (when (gnus-summary-goto-subject article nil t)
9421 (gnus-summary-update-secondary-mark article))))))
9423 (defun gnus-summary-set-bookmark (article)
9424 "Set a bookmark in current article."
9425 (interactive (list (gnus-summary-article-number)))
9426 (when (or (not (get-buffer gnus-article-buffer))
9427 (not gnus-current-article)
9428 (not gnus-article-current)
9429 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9430 (error "No current article selected"))
9431 ;; Remove old bookmark, if one exists.
9432 (let ((old (assq article gnus-newsgroup-bookmarks)))
9434 (setq gnus-newsgroup-bookmarks
9435 (delq old gnus-newsgroup-bookmarks))))
9436 ;; Set the new bookmark, which is on the form
9437 ;; (article-number . line-number-in-body).
9441 (set-buffer gnus-article-buffer)
9445 (goto-char (point-min))
9446 (search-forward "\n\n" nil t)
9449 gnus-newsgroup-bookmarks)
9450 (gnus-message 6 "A bookmark has been added to the current article."))
9452 (defun gnus-summary-remove-bookmark (article)
9453 "Remove the bookmark from the current article."
9454 (interactive (list (gnus-summary-article-number)))
9455 ;; Remove old bookmark, if one exists.
9456 (let ((old (assq article gnus-newsgroup-bookmarks)))
9459 (setq gnus-newsgroup-bookmarks
9460 (delq old gnus-newsgroup-bookmarks))
9461 (gnus-message 6 "Removed bookmark."))
9462 (gnus-message 6 "No bookmark in current article."))))
9464 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9465 (defun gnus-summary-mark-as-dormant (n)
9466 "Mark N articles forward as dormant.
9467 If N is negative, mark backward instead. The difference between N and
9468 the actual number of articles marked is returned."
9470 (gnus-summary-mark-forward n gnus-dormant-mark))
9472 (defun gnus-summary-set-process-mark (article)
9473 "Set the process mark on ARTICLE and update the summary line."
9474 (setq gnus-newsgroup-processable
9476 (delq article gnus-newsgroup-processable)))
9477 (when (gnus-summary-goto-subject article)
9478 (gnus-summary-show-thread)
9479 (gnus-summary-goto-subject article)
9480 (gnus-summary-update-secondary-mark article)))
9482 (defun gnus-summary-remove-process-mark (article)
9483 "Remove the process mark from ARTICLE and update the summary line."
9484 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9485 (when (gnus-summary-goto-subject article)
9486 (gnus-summary-show-thread)
9487 (gnus-summary-goto-subject article)
9488 (gnus-summary-update-secondary-mark article)))
9490 (defun gnus-summary-set-saved-mark (article)
9491 "Set the process mark on ARTICLE and update the summary line."
9492 (push article gnus-newsgroup-saved)
9493 (when (gnus-summary-goto-subject article)
9494 (gnus-summary-update-secondary-mark article)))
9496 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9497 "Mark N articles as read forwards.
9498 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9499 The difference between N and the actual number of articles marked is
9501 If NO-EXPIRE, auto-expiry will be inhibited."
9503 (gnus-summary-show-thread)
9504 (let ((backward (< n 0))
9505 (gnus-summary-goto-unread
9506 (and gnus-summary-goto-unread
9507 (not (eq gnus-summary-goto-unread 'never))
9508 (not (memq mark (list gnus-unread-mark
9509 gnus-ticked-mark gnus-dormant-mark)))))
9511 (mark (or mark gnus-del-mark)))
9513 (gnus-summary-mark-article nil mark no-expire)
9514 (zerop (gnus-summary-next-subject
9516 (and gnus-summary-goto-unread
9517 (not (eq gnus-summary-goto-unread 'never)))
9521 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9522 (gnus-summary-recenter)
9523 (gnus-summary-position-point)
9524 (gnus-set-mode-line 'summary)
9527 (defun gnus-summary-mark-article-as-read (mark)
9528 "Mark the current article quickly as read with MARK."
9529 (let ((article (gnus-summary-article-number)))
9530 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9531 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9532 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9533 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9534 (push (cons article mark) gnus-newsgroup-reads)
9535 ;; Possibly remove from cache, if that is used.
9536 (when gnus-use-cache
9537 (gnus-cache-enter-remove-article article))
9538 ;; Allow the backend to change the mark.
9539 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9540 ;; Check for auto-expiry.
9541 (when (and gnus-newsgroup-auto-expire
9542 (memq mark gnus-auto-expirable-marks))
9543 (setq mark gnus-expirable-mark)
9544 ;; Let the backend know about the mark change.
9545 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9546 (push article gnus-newsgroup-expirable))
9547 ;; Set the mark in the buffer.
9548 (gnus-summary-update-mark mark 'unread)
9551 (defun gnus-summary-mark-article-as-unread (mark)
9552 "Mark the current article quickly as unread with MARK."
9553 (let* ((article (gnus-summary-article-number))
9554 (old-mark (gnus-summary-article-mark article)))
9555 ;; Allow the backend to change the mark.
9556 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9557 (if (eq mark old-mark)
9561 (gnus-error 1 "Can't mark negative article numbers")
9563 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9564 (setq gnus-newsgroup-spam-marked
9565 (delq article gnus-newsgroup-spam-marked))
9566 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9567 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9568 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9569 (cond ((= mark gnus-ticked-mark)
9570 (setq gnus-newsgroup-marked
9571 (gnus-add-to-sorted-list gnus-newsgroup-marked
9573 ((= mark gnus-spam-mark)
9574 (setq gnus-newsgroup-spam-marked
9575 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9577 ((= mark gnus-dormant-mark)
9578 (setq gnus-newsgroup-dormant
9579 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9582 (setq gnus-newsgroup-unreads
9583 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9585 (gnus-pull article gnus-newsgroup-reads)
9587 ;; See whether the article is to be put in the cache.
9589 (vectorp (gnus-summary-article-header article))
9591 (gnus-cache-possibly-enter-article
9592 gnus-newsgroup-name article
9593 (gnus-summary-article-header article)
9594 (= mark gnus-ticked-mark)
9595 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9598 (gnus-summary-update-mark mark 'unread)
9601 (defun gnus-summary-mark-article (&optional article mark no-expire)
9602 "Mark ARTICLE with MARK. MARK can be any character.
9603 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9604 `??' (dormant) and `?E' (expirable).
9605 If MARK is nil, then the default character `?r' is used.
9606 If ARTICLE is nil, then the article on the current line will be
9608 If NO-EXPIRE, auto-expiry will be inhibited."
9609 ;; The mark might be a string.
9610 (when (stringp mark)
9611 (setq mark (aref mark 0)))
9612 ;; If no mark is given, then we check auto-expiring.
9614 (setq mark gnus-del-mark))
9615 (when (and (not no-expire)
9616 gnus-newsgroup-auto-expire
9617 (memq mark gnus-auto-expirable-marks))
9618 (setq mark gnus-expirable-mark))
9619 (let ((article (or article (gnus-summary-article-number)))
9620 (old-mark (gnus-summary-article-mark article)))
9621 ;; Allow the backend to change the mark.
9622 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9623 (if (eq mark old-mark)
9626 (error "No article on current line"))
9627 (if (not (if (or (= mark gnus-unread-mark)
9628 (= mark gnus-ticked-mark)
9629 (= mark gnus-spam-mark)
9630 (= mark gnus-dormant-mark))
9631 (gnus-mark-article-as-unread article mark)
9632 (gnus-mark-article-as-read article mark)))
9634 ;; See whether the article is to be put in the cache.
9636 (not (= mark gnus-canceled-mark))
9637 (vectorp (gnus-summary-article-header article))
9639 (gnus-cache-possibly-enter-article
9640 gnus-newsgroup-name article
9641 (gnus-summary-article-header article)
9642 (= mark gnus-ticked-mark)
9643 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9645 (when (gnus-summary-goto-subject article nil t)
9646 (let ((buffer-read-only nil))
9647 (gnus-summary-show-thread)
9649 (gnus-summary-update-mark mark 'unread)
9652 (defun gnus-summary-update-secondary-mark (article)
9653 "Update the secondary (read, process, cache) mark."
9654 (gnus-summary-update-mark
9655 (cond ((memq article gnus-newsgroup-processable)
9657 ((memq article gnus-newsgroup-cached)
9659 ((memq article gnus-newsgroup-replied)
9661 ((memq article gnus-newsgroup-forwarded)
9662 gnus-forwarded-mark)
9663 ((memq article gnus-newsgroup-saved)
9665 ((memq article gnus-newsgroup-recent)
9667 ((memq article gnus-newsgroup-unseen)
9671 (when (gnus-visual-p 'summary-highlight 'highlight)
9672 (gnus-run-hooks 'gnus-summary-update-hook))
9675 (defun gnus-summary-update-mark (mark type)
9676 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9677 (buffer-read-only nil))
9678 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9680 (when (looking-at "\r")
9682 (when (<= (+ forward (point)) (point-max))
9683 ;; Go to the right position on the line.
9684 (goto-char (+ forward (point)))
9685 ;; Replace the old mark with the new mark.
9686 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9687 ;; Optionally update the marks by some user rule.
9688 (when (eq type 'unread)
9690 (gnus-data-find (gnus-summary-article-number)) mark)
9691 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9693 (defun gnus-mark-article-as-read (article &optional mark)
9694 "Enter ARTICLE in the pertinent lists and remove it from others."
9695 ;; Make the article expirable.
9696 (let ((mark (or mark gnus-del-mark)))
9697 (setq gnus-newsgroup-expirable
9698 (if (= mark gnus-expirable-mark)
9699 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9700 (delq article gnus-newsgroup-expirable)))
9701 ;; Remove from unread and marked lists.
9702 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9703 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9704 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9705 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9706 (push (cons article mark) gnus-newsgroup-reads)
9707 ;; Possibly remove from cache, if that is used.
9708 (when gnus-use-cache
9709 (gnus-cache-enter-remove-article article))
9712 (defun gnus-mark-article-as-unread (article &optional mark)
9713 "Enter ARTICLE in the pertinent lists and remove it from others."
9714 (let ((mark (or mark gnus-ticked-mark)))
9717 (gnus-error 1 "Can't mark negative article numbers")
9719 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9720 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9721 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9722 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9723 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9725 ;; Unsuppress duplicates?
9726 (when gnus-suppress-duplicates
9727 (gnus-dup-unsuppress-article article))
9729 (cond ((= mark gnus-ticked-mark)
9730 (setq gnus-newsgroup-marked
9731 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9732 ((= mark gnus-spam-mark)
9733 (setq gnus-newsgroup-spam-marked
9734 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9736 ((= mark gnus-dormant-mark)
9737 (setq gnus-newsgroup-dormant
9738 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9740 (setq gnus-newsgroup-unreads
9741 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9742 (gnus-pull article gnus-newsgroup-reads)
9745 (defalias 'gnus-summary-mark-as-unread-forward
9746 'gnus-summary-tick-article-forward)
9747 (make-obsolete 'gnus-summary-mark-as-unread-forward
9748 'gnus-summary-tick-article-forward)
9749 (defun gnus-summary-tick-article-forward (n)
9750 "Tick N articles forwards.
9751 If N is negative, tick backwards instead.
9752 The difference between N and the number of articles ticked is returned."
9754 (gnus-summary-mark-forward n gnus-ticked-mark))
9756 (defalias 'gnus-summary-mark-as-unread-backward
9757 'gnus-summary-tick-article-backward)
9758 (make-obsolete 'gnus-summary-mark-as-unread-backward
9759 'gnus-summary-tick-article-backward)
9760 (defun gnus-summary-tick-article-backward (n)
9761 "Tick N articles backwards.
9762 The difference between N and the number of articles ticked is returned."
9764 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9766 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9767 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9768 (defun gnus-summary-tick-article (&optional article clear-mark)
9769 "Mark current article as unread.
9770 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9771 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9773 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9776 (defun gnus-summary-mark-as-read-forward (n)
9777 "Mark N articles as read forwards.
9778 If N is negative, mark backwards instead.
9779 The difference between N and the actual number of articles marked is
9782 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9784 (defun gnus-summary-mark-as-read-backward (n)
9785 "Mark the N articles as read backwards.
9786 The difference between N and the actual number of articles marked is
9789 (gnus-summary-mark-forward
9790 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9792 (defun gnus-summary-mark-as-read (&optional article mark)
9793 "Mark current article as read.
9794 ARTICLE specifies the article to be marked as read.
9795 MARK specifies a string to be inserted at the beginning of the line."
9796 (gnus-summary-mark-article article mark))
9798 (defun gnus-summary-clear-mark-forward (n)
9799 "Clear marks from N articles forward.
9800 If N is negative, clear backward instead.
9801 The difference between N and the number of marks cleared is returned."
9803 (gnus-summary-mark-forward n gnus-unread-mark))
9805 (defun gnus-summary-clear-mark-backward (n)
9806 "Clear marks from N articles backward.
9807 The difference between N and the number of marks cleared is returned."
9809 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9811 (defun gnus-summary-mark-unread-as-read ()
9812 "Intended to be used by `gnus-summary-mark-article-hook'."
9813 (when (memq gnus-current-article gnus-newsgroup-unreads)
9814 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9816 (defun gnus-summary-mark-read-and-unread-as-read ()
9817 "Intended to be used by `gnus-summary-mark-article-hook'."
9818 (let ((mark (gnus-summary-article-mark)))
9819 (when (or (gnus-unread-mark-p mark)
9820 (gnus-read-mark-p mark))
9821 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9823 (defun gnus-summary-mark-unread-as-ticked ()
9824 "Intended to be used by `gnus-summary-mark-article-hook'."
9825 (when (memq gnus-current-article gnus-newsgroup-unreads)
9826 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9828 (defun gnus-summary-mark-region-as-read (point mark all)
9829 "Mark all unread articles between point and mark as read.
9830 If given a prefix, mark all articles between point and mark as read,
9831 even ticked and dormant ones."
9832 (interactive "r\nP")
9841 (memq (setq article (gnus-summary-article-number))
9842 gnus-newsgroup-unreads))
9843 (gnus-summary-mark-article article gnus-del-mark))
9845 (gnus-summary-find-next))))))
9847 (defun gnus-summary-mark-below (score mark)
9848 "Mark articles with score less than SCORE with MARK."
9849 (interactive "P\ncMark: ")
9850 (setq score (if score
9851 (prefix-numeric-value score)
9852 (or gnus-summary-default-score 0)))
9854 (set-buffer gnus-summary-buffer)
9855 (goto-char (point-min))
9858 (and (< (gnus-summary-article-score) score)
9859 (gnus-summary-mark-article nil mark))
9860 (gnus-summary-find-next)))))
9862 (defun gnus-summary-kill-below (&optional score)
9863 "Mark articles with score below SCORE as read."
9865 (gnus-summary-mark-below score gnus-killed-mark))
9867 (defun gnus-summary-clear-above (&optional score)
9868 "Clear all marks from articles with score above SCORE."
9870 (gnus-summary-mark-above score gnus-unread-mark))
9872 (defun gnus-summary-tick-above (&optional score)
9873 "Tick all articles with score above SCORE."
9875 (gnus-summary-mark-above score gnus-ticked-mark))
9877 (defun gnus-summary-mark-above (score mark)
9878 "Mark articles with score over SCORE with MARK."
9879 (interactive "P\ncMark: ")
9880 (setq score (if score
9881 (prefix-numeric-value score)
9882 (or gnus-summary-default-score 0)))
9884 (set-buffer gnus-summary-buffer)
9885 (goto-char (point-min))
9887 (when (> (gnus-summary-article-score) score)
9888 (gnus-summary-mark-article nil mark))
9890 (gnus-summary-find-next)))))
9892 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9893 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9894 (defun gnus-summary-limit-include-expunged (&optional no-error)
9895 "Display all the hidden articles that were expunged for low scores."
9897 (let ((buffer-read-only nil))
9898 (let ((scored gnus-newsgroup-scored)
9901 (unless (gnus-summary-article-header (caar scored))
9902 (and (setq h (gnus-number-to-header (caar scored)))
9903 (< (cdar scored) gnus-summary-expunge-below)
9905 (setq scored (cdr scored)))
9907 (when (not no-error)
9908 (error "No expunged articles hidden"))
9909 (goto-char (point-min))
9910 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9911 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9912 (mapcar (lambda (x) (push (mail-header-number x)
9913 gnus-newsgroup-limit))
9915 (gnus-summary-prepare-unthreaded (nreverse headers))
9916 (goto-char (point-min))
9917 (gnus-summary-position-point)
9920 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9921 "Mark all unread articles in this newsgroup as read.
9922 If prefix argument ALL is non-nil, ticked and dormant articles will
9923 also be marked as read.
9924 If QUIETLY is non-nil, no questions will be asked.
9925 If TO-HERE is non-nil, it should be a point in the buffer. All
9926 articles before (after, if REVERSE is set) this point will be marked as read.
9927 Note that this function will only catch up the unread article
9928 in the current summary buffer limitation.
9929 The number of articles marked as read is returned."
9934 (not gnus-interactive-catchup) ;Without confirmation?
9938 "Mark absolutely all articles as read? "
9939 "Mark all unread articles as read? ")))
9941 (not gnus-newsgroup-adaptive)
9942 (not gnus-newsgroup-auto-expire)
9943 (not gnus-suppress-duplicates)
9944 (or (not gnus-use-cache)
9945 (eq gnus-use-cache 'passive)))
9948 (setq gnus-newsgroup-marked nil
9949 gnus-newsgroup-spam-marked nil
9950 gnus-newsgroup-dormant nil))
9951 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9952 ;; We actually mark all articles as canceled, which we
9953 ;; have to do when using auto-expiry or adaptive scoring.
9954 (gnus-summary-show-all-threads)
9955 (if (and to-here reverse)
9959 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9960 (gnus-summary-find-next (not all) nil nil t))))
9961 (when (gnus-summary-first-subject (not all) t)
9963 (if to-here (< (point) to-here) t)
9964 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9965 (gnus-summary-find-next (not all) nil nil t)))))
9966 (gnus-set-mode-line 'summary))
9968 (gnus-summary-position-point)))
9970 (defun gnus-summary-catchup-to-here (&optional all)
9971 "Mark all unticked articles before the current one as read.
9972 If ALL is non-nil, also mark ticked and dormant articles as read."
9975 (gnus-save-hidden-threads
9976 (let ((beg (point)))
9977 ;; We check that there are unread articles.
9978 (when (or all (gnus-summary-find-prev))
9979 (gnus-summary-catchup all t beg)))))
9980 (gnus-summary-position-point))
9982 (defun gnus-summary-catchup-from-here (&optional all)
9983 "Mark all unticked articles after the current one as read.
9984 If ALL is non-nil, also mark ticked and dormant articles as read."
9987 (gnus-save-hidden-threads
9988 (let ((beg (point)))
9989 ;; We check that there are unread articles.
9990 (when (or all (gnus-summary-find-next))
9991 (gnus-summary-catchup all t beg nil t)))))
9992 (gnus-summary-position-point))
9994 (defun gnus-summary-catchup-all (&optional quietly)
9995 "Mark all articles in this newsgroup as read.
9996 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
9997 instead, which marks only unread articles as read."
9999 (gnus-summary-catchup t quietly))
10001 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10002 "Mark all unread articles in this group as read, then exit.
10003 If prefix argument ALL is non-nil, all articles are marked as read.
10004 If QUIETLY is non-nil, no questions will be asked."
10006 (when (gnus-summary-catchup all quietly nil 'fast)
10007 ;; Select next newsgroup or exit.
10008 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10009 (eq gnus-auto-select-next 'quietly))
10010 (gnus-summary-next-group nil)
10011 (gnus-summary-exit))))
10013 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10014 "Mark all articles in this newsgroup as read, and then exit.
10015 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10016 instead, which marks only unread articles as read."
10018 (gnus-summary-catchup-and-exit t quietly))
10020 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10021 "Mark all articles in this group as read and select the next group.
10022 If given a prefix, mark all articles, unread as well as ticked, as
10026 (gnus-summary-catchup all))
10027 (gnus-summary-next-group))
10033 (defmacro gnus-with-article (article &rest forms)
10034 "Select ARTICLE and perform FORMS in the original article buffer.
10035 Then replace the article with the result."
10037 ;; We don't want the article to be marked as read.
10038 (let (gnus-mark-article-hook)
10039 (gnus-summary-select-article t t nil ,article))
10040 (set-buffer gnus-original-article-buffer)
10042 (if (not (gnus-check-backend-function
10043 'request-replace-article (car gnus-article-current)))
10044 (gnus-message 5 "Read-only group; not replacing")
10045 (unless (gnus-request-replace-article
10046 ,article (car gnus-article-current)
10047 (current-buffer) t)
10048 (error "Couldn't replace article")))
10049 ;; The cache and backlog have to be flushed somewhat.
10050 (when gnus-keep-backlog
10051 (gnus-backlog-remove-article
10052 (car gnus-article-current) (cdr gnus-article-current)))
10053 (when gnus-use-cache
10054 (gnus-cache-update-article
10055 (car gnus-article-current) (cdr gnus-article-current)))))
10057 (put 'gnus-with-article 'lisp-indent-function 1)
10058 (put 'gnus-with-article 'edebug-form-spec '(form body))
10060 ;; Thread-based commands.
10062 (defun gnus-summary-articles-in-thread (&optional article)
10063 "Return a list of all articles in the current thread.
10064 If ARTICLE is non-nil, return all articles in the thread that starts
10065 with that article."
10066 (let* ((article (or article (gnus-summary-article-number)))
10067 (data (gnus-data-find-list article))
10068 (top-level (gnus-data-level (car data)))
10070 (cond ((null gnus-thread-operation-ignore-subject)
10071 (gnus-simplify-subject-re
10072 (mail-header-subject (gnus-data-header (car data)))))
10073 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10074 (gnus-simplify-subject-fuzzy
10075 (mail-header-subject (gnus-data-header (car data)))))
10077 (end-point (save-excursion
10078 (if (gnus-summary-go-to-next-thread)
10079 (point) (point-max))))
10082 (< (gnus-data-pos (car data)) end-point))
10083 (when (or (not top-subject)
10084 (string= top-subject
10085 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10086 (gnus-simplify-subject-fuzzy
10087 (mail-header-subject
10088 (gnus-data-header (car data))))
10089 (gnus-simplify-subject-re
10090 (mail-header-subject
10091 (gnus-data-header (car data)))))))
10092 (push (gnus-data-number (car data)) articles))
10093 (unless (and (setq data (cdr data))
10094 (> (gnus-data-level (car data)) top-level))
10096 ;; Return the list of articles.
10097 (nreverse articles)))
10099 (defun gnus-summary-rethread-current ()
10100 "Rethread the thread the current article is part of."
10102 (let* ((gnus-show-threads t)
10103 (article (gnus-summary-article-number))
10104 (id (mail-header-id (gnus-summary-article-header)))
10105 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10107 (error "No article on the current line"))
10108 (gnus-rebuild-thread id)
10109 (gnus-summary-goto-subject article)))
10111 (defun gnus-summary-reparent-thread ()
10112 "Make the current article child of the marked (or previous) article.
10114 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10115 is non-nil or the Subject: of both articles are the same."
10117 (unless (not (gnus-group-read-only-p))
10118 (error "The current newsgroup does not support article editing"))
10119 (unless (<= (length gnus-newsgroup-processable) 1)
10120 (error "No more than one article may be marked"))
10121 (save-window-excursion
10122 (let ((gnus-article-buffer " *reparent*")
10123 (current-article (gnus-summary-article-number))
10124 ;; First grab the marked article, otherwise one line up.
10125 (parent-article (if (not (null gnus-newsgroup-processable))
10126 (car gnus-newsgroup-processable)
10128 (if (eq (forward-line -1) 0)
10129 (gnus-summary-article-number)
10130 (error "Beginning of summary buffer"))))))
10131 (unless (not (eq current-article parent-article))
10132 (error "An article may not be self-referential"))
10133 (let ((message-id (mail-header-id
10134 (gnus-summary-article-header parent-article))))
10135 (unless (and message-id (not (equal message-id "")))
10136 (error "No message-id in desired parent"))
10137 (gnus-with-article current-article
10139 (goto-char (point-min))
10140 (message-narrow-to-head)
10141 (if (re-search-forward "^References: " nil t)
10143 (re-search-forward "^[^ \t]" nil t)
10146 (insert " " message-id))
10147 (insert "References: " message-id "\n"))))
10148 (set-buffer gnus-summary-buffer)
10149 (gnus-summary-unmark-all-processable)
10150 (gnus-summary-update-article current-article)
10151 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10152 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10153 (gnus-summary-rethread-current)
10154 (gnus-message 3 "Article %d is now the child of article %d"
10155 current-article parent-article)))))
10157 (defun gnus-summary-toggle-threads (&optional arg)
10158 "Toggle showing conversation threads.
10159 If ARG is positive number, turn showing conversation threads on."
10161 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10162 (setq gnus-show-threads
10163 (if (null arg) (not gnus-show-threads)
10164 (> (prefix-numeric-value arg) 0)))
10165 (gnus-summary-prepare)
10166 (gnus-summary-goto-subject current)
10167 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10168 (gnus-summary-position-point)))
10170 (defun gnus-summary-show-all-threads ()
10171 "Show all threads."
10174 (let ((buffer-read-only nil))
10175 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10176 (gnus-summary-position-point))
10178 (defun gnus-summary-show-thread ()
10179 "Show thread subtrees.
10180 Returns nil if no thread was there to be shown."
10182 (let ((buffer-read-only nil)
10184 ;; first goto end then to beg, to have point at beg after let
10185 (end (progn (end-of-line) (point)))
10186 (beg (progn (beginning-of-line) (point))))
10188 ;; Any hidden lines here?
10189 (search-forward "\r" end t)
10190 (subst-char-in-region beg end ?\^M ?\n t)
10192 (gnus-summary-position-point))))
10194 (defun gnus-summary-maybe-hide-threads ()
10195 "If requested, hide the threads that should be hidden."
10196 (when (and gnus-show-threads
10197 gnus-thread-hide-subtree)
10198 (gnus-summary-hide-all-threads
10199 (if (or (consp gnus-thread-hide-subtree)
10200 (gnus-functionp gnus-thread-hide-subtree))
10201 (gnus-make-predicate gnus-thread-hide-subtree)
10204 ;;; Hiding predicates.
10206 (defun gnus-article-unread-p (header)
10207 (memq (mail-header-number header) gnus-newsgroup-unreads))
10209 (defun gnus-article-unseen-p (header)
10210 (memq (mail-header-number header) gnus-newsgroup-unseen))
10212 (defun gnus-map-articles (predicate articles)
10213 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10214 (apply 'gnus-or (mapcar predicate
10215 (mapcar 'gnus-summary-article-header articles))))
10217 (defun gnus-summary-hide-all-threads (&optional predicate)
10218 "Hide all thread subtrees.
10219 If PREDICATE is supplied, threads that satisfy this predicate
10220 will not be hidden."
10223 (goto-char (point-min))
10226 (when (or (not predicate)
10228 predicate (gnus-summary-article-children)))
10229 (gnus-summary-hide-thread))
10230 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10231 (gnus-summary-position-point))
10233 (defun gnus-summary-hide-thread ()
10234 "Hide thread subtrees.
10235 If PREDICATE is supplied, threads that satisfy this predicate
10236 will not be hidden.
10237 Returns nil if no threads were there to be hidden."
10239 (let ((buffer-read-only nil)
10241 (article (gnus-summary-article-number)))
10243 ;; Go forward until either the buffer ends or the subthread
10245 (when (and (not (eobp))
10246 (or (zerop (gnus-summary-next-thread 1 t))
10247 (goto-char (point-max))))
10249 (if (and (> (point) start)
10250 (search-backward "\n" start t))
10252 (subst-char-in-region start (point) ?\n ?\^M)
10253 (gnus-summary-goto-subject article))
10257 (defun gnus-summary-go-to-next-thread (&optional previous)
10258 "Go to the same level (or less) next thread.
10259 If PREVIOUS is non-nil, go to previous thread instead.
10260 Return the article number moved to, or nil if moving was impossible."
10261 (let ((level (gnus-summary-thread-level))
10262 (way (if previous -1 1))
10265 (while (and (not (eobp))
10266 (< level (gnus-summary-thread-level)))
10267 (forward-line way))
10274 (gnus-summary-article-number)
10275 (goto-char beg)))))
10277 (defun gnus-summary-next-thread (n &optional silent)
10278 "Go to the same level next N'th thread.
10279 If N is negative, search backward instead.
10280 Returns the difference between N and the number of skips actually
10283 If SILENT, don't output messages."
10285 (let ((backward (< n 0))
10287 (while (and (> n 0)
10288 (gnus-summary-go-to-next-thread backward))
10291 (gnus-summary-position-point))
10292 (when (and (not silent) (/= 0 n))
10293 (gnus-message 7 "No more threads"))
10296 (defun gnus-summary-prev-thread (n)
10297 "Go to the same level previous N'th thread.
10298 Returns the difference between N and the number of skips actually
10301 (gnus-summary-next-thread (- n)))
10303 (defun gnus-summary-go-down-thread ()
10304 "Go down one level in the current thread."
10305 (let ((children (gnus-summary-article-children)))
10307 (gnus-summary-goto-subject (car children)))))
10309 (defun gnus-summary-go-up-thread ()
10310 "Go up one level in the current thread."
10311 (let ((parent (gnus-summary-article-parent)))
10313 (gnus-summary-goto-subject parent))))
10315 (defun gnus-summary-down-thread (n)
10316 "Go down thread N steps.
10317 If N is negative, go up instead.
10318 Returns the difference between N and how many steps down that were
10323 (while (and (> n 0)
10324 (if up (gnus-summary-go-up-thread)
10325 (gnus-summary-go-down-thread)))
10327 (gnus-summary-position-point)
10329 (gnus-message 7 "Can't go further"))
10332 (defun gnus-summary-up-thread (n)
10333 "Go up thread N steps.
10334 If N is negative, go down instead.
10335 Returns the difference between N and how many steps down that were
10338 (gnus-summary-down-thread (- n)))
10340 (defun gnus-summary-top-thread ()
10341 "Go to the top of the thread."
10343 (while (gnus-summary-go-up-thread))
10344 (gnus-summary-article-number))
10346 (defun gnus-summary-kill-thread (&optional unmark)
10347 "Mark articles under current thread as read.
10348 If the prefix argument is positive, remove any kinds of marks.
10349 If the prefix argument is negative, tick articles instead."
10352 (setq unmark (prefix-numeric-value unmark)))
10353 (let ((articles (gnus-summary-articles-in-thread)))
10355 ;; Expand the thread.
10356 (gnus-summary-show-thread)
10357 ;; Mark all the articles.
10359 (gnus-summary-goto-subject (car articles))
10360 (cond ((null unmark)
10361 (gnus-summary-mark-article-as-read gnus-killed-mark))
10363 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10365 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10366 (setq articles (cdr articles))))
10367 ;; Hide killed subtrees.
10369 gnus-thread-hide-killed
10370 (gnus-summary-hide-thread))
10371 ;; If marked as read, go to next unread subject.
10372 (when (null unmark)
10373 ;; Go to next unread subject.
10374 (gnus-summary-next-subject 1 t)))
10375 (gnus-set-mode-line 'summary))
10377 ;; Summary sorting commands
10379 (defun gnus-summary-sort-by-number (&optional reverse)
10380 "Sort the summary buffer by article number.
10381 Argument REVERSE means reverse order."
10383 (gnus-summary-sort 'number reverse))
10385 (defun gnus-summary-sort-by-random (&optional reverse)
10386 "Randomize the order in the summary buffer.
10387 Argument REVERSE means to randomize in reverse order."
10389 (gnus-summary-sort 'random reverse))
10391 (defun gnus-summary-sort-by-author (&optional reverse)
10392 "Sort the summary buffer by author name alphabetically.
10393 If `case-fold-search' is non-nil, case of letters is ignored.
10394 Argument REVERSE means reverse order."
10396 (gnus-summary-sort 'author reverse))
10398 (defun gnus-summary-sort-by-subject (&optional reverse)
10399 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10400 If `case-fold-search' is non-nil, case of letters is ignored.
10401 Argument REVERSE means reverse order."
10403 (gnus-summary-sort 'subject reverse))
10405 (defun gnus-summary-sort-by-date (&optional reverse)
10406 "Sort the summary buffer by date.
10407 Argument REVERSE means reverse order."
10409 (gnus-summary-sort 'date reverse))
10411 (defun gnus-summary-sort-by-score (&optional reverse)
10412 "Sort the summary buffer by score.
10413 Argument REVERSE means reverse order."
10415 (gnus-summary-sort 'score reverse))
10417 (defun gnus-summary-sort-by-lines (&optional reverse)
10418 "Sort the summary buffer by the number of lines.
10419 Argument REVERSE means reverse order."
10421 (gnus-summary-sort 'lines reverse))
10423 (defun gnus-summary-sort-by-chars (&optional reverse)
10424 "Sort the summary buffer by article length.
10425 Argument REVERSE means reverse order."
10427 (gnus-summary-sort 'chars reverse))
10429 (defun gnus-summary-sort-by-original (&optional reverse)
10430 "Sort the summary buffer using the default sorting method.
10431 Argument REVERSE means reverse order."
10433 (let* ((buffer-read-only)
10434 (gnus-summary-prepare-hook nil))
10435 ;; We do the sorting by regenerating the threads.
10436 (gnus-summary-prepare)
10437 ;; Hide subthreads if needed.
10438 (gnus-summary-maybe-hide-threads)))
10440 (defun gnus-summary-sort (predicate reverse)
10441 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10442 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10443 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10444 (gnus-thread-sort-functions
10449 (gnus-sort-gathered-threads-function
10450 gnus-thread-sort-functions)
10451 (gnus-article-sort-functions
10455 (,article t2 t1))))
10457 (gnus-summary-prepare-hook nil))
10458 ;; We do the sorting by regenerating the threads.
10459 (gnus-summary-prepare)
10460 ;; Hide subthreads if needed.
10461 (gnus-summary-maybe-hide-threads)))
10463 ;; Summary saving commands.
10465 (defun gnus-summary-save-article (&optional n not-saved)
10466 "Save the current article using the default saver function.
10467 If N is a positive number, save the N next articles.
10468 If N is a negative number, save the N previous articles.
10469 If N is nil and any articles have been marked with the process mark,
10470 save those articles instead.
10471 The variable `gnus-default-article-saver' specifies the saver function."
10473 (let* ((articles (gnus-summary-work-articles n))
10474 (save-buffer (save-excursion
10475 (nnheader-set-temp-buffer " *Gnus Save*")))
10476 (num (length articles))
10478 (dolist (article articles)
10479 (setq header (gnus-summary-article-header article))
10480 (if (not (vectorp header))
10481 ;; This is a pseudo-article.
10482 (if (assq 'name header)
10483 (gnus-copy-file (cdr (assq 'name header)))
10484 (gnus-message 1 "Article %d is unsaveable" article))
10485 ;; This is a real article.
10486 (save-window-excursion
10487 (let ((gnus-display-mime-function nil)
10488 (gnus-article-prepare-hook nil))
10489 (gnus-summary-select-article t nil nil article)))
10491 (set-buffer save-buffer)
10493 (insert-buffer-substring gnus-original-article-buffer))
10494 (setq file (gnus-article-save save-buffer file num))
10495 (gnus-summary-remove-process-mark article)
10497 (gnus-summary-set-saved-mark article))))
10498 (gnus-kill-buffer save-buffer)
10499 (gnus-summary-position-point)
10500 (gnus-set-mode-line 'summary)
10503 (defun gnus-summary-pipe-output (&optional arg)
10504 "Pipe the current article to a subprocess.
10505 If N is a positive number, pipe the N next articles.
10506 If N is a negative number, pipe the N previous articles.
10507 If N is nil and any articles have been marked with the process mark,
10508 pipe those articles instead."
10510 (require 'gnus-art)
10511 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10512 (gnus-summary-save-article arg t))
10513 (let ((buffer (get-buffer "*Shell Command Output*")))
10515 (with-current-buffer buffer (> (point-max) (point-min))))
10516 (gnus-configure-windows 'pipe))))
10518 (defun gnus-summary-save-article-mail (&optional arg)
10519 "Append the current article to an mail file.
10520 If N is a positive number, save the N next articles.
10521 If N is a negative number, save the N previous articles.
10522 If N is nil and any articles have been marked with the process mark,
10523 save those articles instead."
10525 (require 'gnus-art)
10526 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10527 (gnus-summary-save-article arg)))
10529 (defun gnus-summary-save-article-rmail (&optional arg)
10530 "Append the current article to an rmail file.
10531 If N is a positive number, save the N next articles.
10532 If N is a negative number, save the N previous articles.
10533 If N is nil and any articles have been marked with the process mark,
10534 save those articles instead."
10536 (require 'gnus-art)
10537 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10538 (gnus-summary-save-article arg)))
10540 (defun gnus-summary-save-article-file (&optional arg)
10541 "Append the current article to a file.
10542 If N is a positive number, save the N next articles.
10543 If N is a negative number, save the N previous articles.
10544 If N is nil and any articles have been marked with the process mark,
10545 save those articles instead."
10547 (require 'gnus-art)
10548 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10549 (gnus-summary-save-article arg)))
10551 (defun gnus-summary-write-article-file (&optional arg)
10552 "Write the current article to a file, deleting the previous file.
10553 If N is a positive number, save the N next articles.
10554 If N is a negative number, save the N previous articles.
10555 If N is nil and any articles have been marked with the process mark,
10556 save those articles instead."
10558 (require 'gnus-art)
10559 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10560 (gnus-summary-save-article arg)))
10562 (defun gnus-summary-save-article-body-file (&optional arg)
10563 "Append the current article body to a file.
10564 If N is a positive number, save the N next articles.
10565 If N is a negative number, save the N previous articles.
10566 If N is nil and any articles have been marked with the process mark,
10567 save those articles instead."
10569 (require 'gnus-art)
10570 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10571 (gnus-summary-save-article arg)))
10573 (defun gnus-summary-muttprint (&optional arg)
10574 "Print the current article using Muttprint.
10575 If N is a positive number, save the N next articles.
10576 If N is a negative number, save the N previous articles.
10577 If N is nil and any articles have been marked with the process mark,
10578 save those articles instead."
10580 (require 'gnus-art)
10581 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10582 (gnus-summary-save-article arg t)))
10584 (defun gnus-summary-pipe-message (program)
10585 "Pipe the current article through PROGRAM."
10586 (interactive "sProgram: ")
10587 (gnus-summary-select-article)
10588 (let ((mail-header-separator ""))
10589 (gnus-eval-in-buffer-window gnus-article-buffer
10592 (let ((start (window-start))
10594 (message-pipe-buffer-body program)
10595 (set-window-start (get-buffer-window (current-buffer)) start))))))
10597 (defun gnus-get-split-value (methods)
10598 "Return a value based on the split METHODS."
10599 (let (split-name method result match)
10602 (set-buffer gnus-original-article-buffer)
10604 (nnheader-narrow-to-headers)
10605 (while (and methods (not split-name))
10606 (goto-char (point-min))
10607 (setq method (pop methods))
10608 (setq match (car method))
10611 ;; Regular expression.
10613 (re-search-forward match nil t)))
10614 ((gnus-functionp match)
10618 (setq result (funcall match gnus-newsgroup-name))))
10623 (setq result (eval match)))))
10624 (setq split-name (cdr method))
10625 (cond ((stringp result)
10626 (push (expand-file-name
10627 result gnus-article-save-directory)
10630 (setq split-name (append result split-name)))))))))
10631 (nreverse split-name)))
10633 (defun gnus-valid-move-group-p (group)
10634 (and (boundp group)
10635 (symbol-name group)
10636 (symbol-value group)
10637 (gnus-get-function (gnus-find-method-for-group
10638 (symbol-name group)) 'request-accept-article t)))
10640 (defun gnus-read-move-group-name (prompt default articles prefix)
10641 "Read a group name."
10642 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10643 (minibuffer-confirm-incomplete nil) ; XEmacs
10645 (format "%s %s to:"
10647 (if (> (length articles) 1)
10648 (format "these %d articles" (length articles))
10653 (gnus-completing-read-with-default
10656 'gnus-valid-move-group-p
10658 'gnus-group-history))
10659 ((= 1 (length split-name))
10660 (gnus-completing-read-with-default
10661 (car split-name) prom
10663 'gnus-valid-move-group-p
10665 'gnus-group-history))
10667 (gnus-completing-read-with-default
10669 (mapcar (lambda (el) (list el))
10670 (nreverse split-name))
10672 'gnus-group-history))))
10673 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10675 (if (or (string= to-newsgroup "")
10676 (string= to-newsgroup prefix))
10677 (setq to-newsgroup default))
10678 (unless to-newsgroup
10679 (error "No group name entered"))
10680 (or (gnus-active to-newsgroup)
10681 (gnus-activate-group to-newsgroup nil nil to-method)
10682 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10684 (or (and (gnus-request-create-group to-newsgroup to-method)
10685 (gnus-activate-group
10686 to-newsgroup nil nil to-method)
10687 (gnus-subscribe-group to-newsgroup))
10688 (error "Couldn't create group %s" to-newsgroup)))
10689 (error "No such group: %s" to-newsgroup)))
10692 (defun gnus-summary-save-parts (type dir n &optional reverse)
10693 "Save parts matching TYPE to DIR.
10694 If REVERSE, save parts that do not match TYPE."
10696 (list (read-string "Save parts of type: "
10697 (or (car gnus-summary-save-parts-type-history)
10698 gnus-summary-save-parts-default-mime)
10699 'gnus-summary-save-parts-type-history)
10700 (setq gnus-summary-save-parts-last-directory
10701 (read-file-name "Save to directory: "
10702 gnus-summary-save-parts-last-directory
10704 current-prefix-arg))
10705 (gnus-summary-iterate n
10706 (let ((gnus-display-mime-function nil)
10707 (gnus-inhibit-treatment t))
10708 (gnus-summary-select-article))
10710 (set-buffer gnus-article-buffer)
10711 (let ((handles (or gnus-article-mime-handles
10712 (mm-dissect-buffer nil gnus-article-loose-mime)
10715 (gnus-summary-save-parts-1 type dir handles reverse)
10716 (unless gnus-article-mime-handles ;; Don't destroy this case.
10717 (mm-destroy-parts handles)))))))
10719 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10720 (if (stringp (car handle))
10721 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10724 (not (string-match type (mm-handle-media-type handle)))
10725 (string-match type (mm-handle-media-type handle)))
10726 (let ((file (expand-file-name
10727 (file-name-nondirectory
10729 (mail-content-type-get
10730 (mm-handle-disposition handle) 'filename)
10731 (concat gnus-newsgroup-name
10732 "." (number-to-string
10733 (cdr gnus-article-current)))))
10735 (unless (file-exists-p file)
10736 (mm-save-part-to-file handle file))))))
10738 ;; Summary extract commands
10740 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10741 (let ((buffer-read-only nil)
10742 (article (gnus-summary-article-number))
10744 (unless (gnus-summary-goto-subject article)
10745 (error "No such article: %d" article))
10746 (gnus-summary-position-point)
10747 ;; If all commands are to be bunched up on one line, we collect
10749 (unless gnus-view-pseudos-separately
10750 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10753 (setq action (cdr (assq 'action (car ps))))
10754 (setq files (list (cdr (assq 'name (car ps)))))
10755 (while (and ps (cdr ps)
10756 (string= (or action "1")
10757 (or (cdr (assq 'action (cadr ps))) "2")))
10758 (push (cdr (assq 'name (cadr ps))) files)
10759 (setcdr ps (cddr ps)))
10761 (when (not (string-match "%s" action))
10764 (when (assq 'execute (car ps))
10765 (setcdr (assq 'execute (car ps))
10766 (funcall (if (string-match "%s" action)
10773 (gnus-quote-arg-for-sh-or-csh f)))
10775 (setq ps (cdr ps)))))
10776 (if (and gnus-view-pseudos (not not-view))
10778 (when (assq 'execute (car pslist))
10779 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10780 (eq gnus-view-pseudos 'not-confirm)))
10781 (setq pslist (cdr pslist)))
10784 (setq after-article (or (cdr (assq 'article (car pslist)))
10785 (gnus-summary-article-number)))
10786 (gnus-summary-goto-subject after-article)
10789 (insert " " (file-name-nondirectory
10790 (cdr (assq 'name (car pslist))))
10791 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10793 (forward-line -1) ; back to `b'
10794 (gnus-add-text-properties
10795 b (1- e) (list 'gnus-number gnus-reffed-article-number
10796 gnus-mouse-face-prop gnus-mouse-face))
10798 after-article gnus-reffed-article-number
10799 gnus-unread-mark b (car pslist) 0 (- e b))
10800 (setq gnus-newsgroup-unreads
10801 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10802 gnus-reffed-article-number))
10803 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10804 (setq pslist (cdr pslist)))))))
10806 (defun gnus-pseudos< (p1 p2)
10807 (let ((c1 (cdr (assq 'action p1)))
10808 (c2 (cdr (assq 'action p2))))
10809 (and c1 c2 (string< c1 c2))))
10811 (defun gnus-request-pseudo-article (props)
10812 (cond ((assq 'execute props)
10813 (gnus-execute-command (cdr (assq 'execute props)))))
10814 (let ((gnus-current-article (gnus-summary-article-number)))
10815 (gnus-run-hooks 'gnus-mark-article-hook)))
10817 (defun gnus-execute-command (command &optional automatic)
10819 (gnus-article-setup-buffer)
10820 (set-buffer gnus-article-buffer)
10821 (setq buffer-read-only nil)
10822 (let ((command (if automatic command
10823 (read-string "Command: " (cons command 0)))))
10825 (insert "$ " command "\n\n")
10826 (if gnus-view-pseudo-asynchronously
10827 (start-process "gnus-execute" (current-buffer) shell-file-name
10828 shell-command-switch command)
10829 (call-process shell-file-name nil t nil
10830 shell-command-switch command)))))
10832 ;; Summary kill commands.
10834 (defun gnus-summary-edit-global-kill (article)
10835 "Edit the \"global\" kill file."
10836 (interactive (list (gnus-summary-article-number)))
10837 (gnus-group-edit-global-kill article))
10839 (defun gnus-summary-edit-local-kill ()
10840 "Edit a local kill file applied to the current newsgroup."
10842 (setq gnus-current-headers (gnus-summary-article-header))
10843 (gnus-group-edit-local-kill
10844 (gnus-summary-article-number) gnus-newsgroup-name))
10846 ;;; Header reading.
10848 (defun gnus-read-header (id &optional header)
10849 "Read the headers of article ID and enter them into the Gnus system."
10850 (let ((group gnus-newsgroup-name)
10851 (gnus-override-method
10853 gnus-override-method
10854 (and (gnus-news-group-p gnus-newsgroup-name)
10855 (car (gnus-refer-article-methods)))))
10857 ;; First we check to see whether the header in question is already
10860 ;; This is a Message-ID.
10861 (setq header (or header (gnus-id-to-header id)))
10862 ;; This is an article number.
10863 (setq header (or header (gnus-summary-article-header id))))
10865 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10866 ;; We have found the header.
10868 ;; If this is a sparse article, we have to nix out its
10869 ;; previous entry in the thread hashtb.
10871 (gnus-summary-article-sparse-p (mail-header-number header)))
10872 (let* ((parent (gnus-parent-id (mail-header-references header)))
10873 (thread (and parent (gnus-id-to-thread parent))))
10875 (delq (assq header thread) thread))))
10876 ;; We have to really fetch the header to this article.
10878 (set-buffer nntp-server-buffer)
10879 (when (setq where (gnus-request-head id group))
10880 (nnheader-fold-continuation-lines)
10881 (goto-char (point-max))
10883 (goto-char (point-min))
10887 ((cdr where) (cdr where))
10888 (header (mail-header-number header))
10889 (t gnus-reffed-article-number))
10891 (insert " Article retrieved.\n"))
10892 (if (or (not where)
10893 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10894 () ; Malformed head.
10895 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10896 (when (and (stringp id)
10897 (not (string= (gnus-group-real-name group)
10899 ;; If we fetched by Message-ID and the article came
10900 ;; from a different group, we fudge some bogus article
10901 ;; numbers for this article.
10902 (mail-header-set-number header gnus-reffed-article-number))
10904 (set-buffer gnus-summary-buffer)
10905 (decf gnus-reffed-article-number)
10906 (gnus-remove-header (mail-header-number header))
10907 (push header gnus-newsgroup-headers)
10908 (setq gnus-current-headers header)
10909 (push (mail-header-number header) gnus-newsgroup-limit)))
10912 (defun gnus-remove-header (number)
10913 "Remove header NUMBER from `gnus-newsgroup-headers'."
10914 (if (and gnus-newsgroup-headers
10915 (= number (mail-header-number (car gnus-newsgroup-headers))))
10916 (pop gnus-newsgroup-headers)
10917 (let ((headers gnus-newsgroup-headers))
10918 (while (and (cdr headers)
10919 (not (= number (mail-header-number (cadr headers)))))
10921 (when (cdr headers)
10922 (setcdr headers (cddr headers))))))
10925 ;;; summary highlights
10928 (defun gnus-highlight-selected-summary ()
10929 "Highlight selected article in summary buffer."
10930 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10931 (when gnus-summary-selected-face
10933 (let* ((beg (progn (beginning-of-line) (point)))
10934 (end (progn (end-of-line) (point)))
10935 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10936 (from (if (get-text-property beg gnus-mouse-face-prop)
10938 (or (next-single-property-change
10939 beg gnus-mouse-face-prop nil end)
10944 (or (next-single-property-change
10945 from gnus-mouse-face-prop nil end)
10947 ;; If no mouse-face prop on line we will have to = from = end,
10948 ;; so we highlight the entire line instead.
10949 (when (= (+ to 2) from)
10952 (if gnus-newsgroup-selected-overlay
10953 ;; Move old overlay.
10955 gnus-newsgroup-selected-overlay from to (current-buffer))
10956 ;; Create new overlay.
10958 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10959 'face gnus-summary-selected-face))))))
10961 (defvar gnus-summary-highlight-line-cached nil)
10962 (defvar gnus-summary-highlight-line-trigger nil)
10963 (defun gnus-summary-highlight-line-0 ()
10964 (if (and (eq gnus-summary-highlight-line-trigger
10965 gnus-summary-highlight)
10966 gnus-summary-highlight-line-cached)
10967 gnus-summary-highlight-line-cached
10968 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
10969 gnus-summary-highlight-line-cached
10970 (let* ((cond (list 'cond))
10972 (list gnus-summary-highlight))
10974 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
10977 (gnus-byte-compile (list 'lambda nil cond))))))
10979 (defvar gnus-summary-highlight-line-downloaded-alist nil)
10980 (defvar gnus-summary-highlight-line-downloaded-cached nil)
10982 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10983 (defun gnus-summary-highlight-line ()
10984 "Highlight current line according to `gnus-summary-highlight'."
10986 ((list gnus-summary-highlight)
10987 (beg (gnus-point-at-bol))
10988 (article (gnus-summary-article-number))
10989 (score (or (cdr (assq (or article gnus-current-article)
10990 gnus-newsgroup-scored))
10991 gnus-summary-default-score 0))
10992 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10993 (inhibit-read-only t)
10994 (default gnus-summary-default-score)
10995 (default-high gnus-summary-default-high-score)
10996 (default-low gnus-summary-default-low-score)
10999 (boundp 'gnus-agent-article-alist)
11000 gnus-agent-article-alist
11001 (gnus-agent-group-covered-p gnus-newsgroup-name)
11002 ;; Optimized for when gnus-summary-highlight-line is
11003 ;; called multiple times for articles in ascending
11004 ;; order (i.e. initial generation of summary buffer).
11007 (eq gnus-summary-highlight-line-downloaded-alist
11008 gnus-agent-article-alist)
11009 (<= (caar gnus-summary-highlight-line-downloaded-cached)
11011 (setq gnus-summary-highlight-line-downloaded-alist
11012 gnus-agent-article-alist)
11013 (setq gnus-summary-highlight-line-downloaded-cached
11014 gnus-agent-article-alist))
11016 (while (and (< (caar gnus-summary-highlight-line-downloaded-cached)
11018 (setq n (cdr gnus-summary-highlight-line-downloaded-cached)))
11019 (setq gnus-summary-highlight-line-downloaded-cached n)))
11020 (and (eq (caar gnus-summary-highlight-line-downloaded-cached)
11022 (cdar gnus-summary-highlight-line-downloaded-cached))))))
11023 (let ((face (funcall (gnus-summary-highlight-line-0))))
11024 (unless (eq face (get-text-property beg 'face))
11025 (gnus-put-text-property-excluding-characters-with-faces
11026 beg (gnus-point-at-eol) 'face
11027 (setq face (if (boundp face) (symbol-value face) face)))
11028 (when gnus-summary-highlight-line-function
11029 (funcall gnus-summary-highlight-line-function article face))))))
11031 (defun gnus-update-read-articles (group unread &optional compute)
11032 "Update the list of read articles in GROUP.
11033 UNREAD is a sorted list."
11034 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11035 (entry (gnus-gethash group gnus-newsrc-hashtb))
11036 (info (nth 2 entry))
11039 (if (or (not info) (not active))
11040 ;; There is no info on this group if it was, in fact,
11041 ;; killed. Gnus stores no information on killed groups, so
11042 ;; there's nothing to be done.
11043 ;; One could store the information somewhere temporarily,
11044 ;; perhaps... Hmmm...
11046 ;; Remove any negative articles numbers.
11047 (while (and unread (< (car unread) 0))
11048 (setq unread (cdr unread)))
11049 ;; Remove any expired article numbers
11050 (while (and unread (< (car unread) (car active)))
11051 (setq unread (cdr unread)))
11052 ;; Compute the ranges of read articles by looking at the list of
11053 ;; unread articles.
11055 (when (/= (car unread) prev)
11056 (push (if (= prev (1- (car unread))) prev
11057 (cons prev (1- (car unread))))
11059 (setq prev (1+ (car unread)))
11060 (setq unread (cdr unread)))
11061 (when (<= prev (cdr active))
11062 (push (cons prev (cdr active)) read))
11063 (setq read (if (> (length read) 1) (nreverse read) read))
11068 ;; Propagate the read marks to the backend.
11069 (when (gnus-check-backend-function 'request-set-mark group)
11070 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11071 (add (gnus-remove-from-range read (gnus-info-read info))))
11073 (unless (gnus-check-group group)
11074 (error "Can't open server for %s" group))
11075 (gnus-request-set-mark
11076 group (delq nil (list (if add (list add 'add '(read)))
11077 (if del (list del 'del '(read))))))
11079 `(gnus-request-set-mark
11082 (if del (list del 'add '(read)))
11083 (if add (list add 'del '(read))))))))))
11084 (set-buffer gnus-group-buffer)
11085 (gnus-undo-register
11087 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11088 (gnus-info-set-read ',info ',(gnus-info-read info))
11089 (gnus-get-unread-articles-in-group ',info
11090 (gnus-active ,group))
11091 (gnus-group-update-group ,group t)
11093 ;; Enter this list into the group info.
11094 (gnus-info-set-read info read)
11095 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11096 (gnus-get-unread-articles-in-group info (gnus-active group))
11099 (defun gnus-offer-save-summaries ()
11100 "Offer to save all active summary buffers."
11102 ;; Go through all buffers and find all summaries.
11103 (dolist (buffer (buffer-list))
11104 (when (and (setq buffer (buffer-name buffer))
11105 (string-match "Summary" buffer)
11107 (set-buffer buffer)
11108 ;; We check that this is, indeed, a summary buffer.
11109 (and (eq major-mode 'gnus-summary-mode)
11110 ;; Also make sure this isn't bogus.
11111 gnus-newsgroup-prepared
11112 ;; Also make sure that this isn't a
11113 ;; dead summary buffer.
11114 (not gnus-dead-summary-mode))))
11115 (push buffer buffers)))
11116 ;; Go through all these summary buffers and offer to save them.
11120 "Update summary buffer %s? "
11122 (switch-to-buffer buf)
11123 (gnus-summary-exit))
11127 ;;; @ for mime-partial
11130 (defun gnus-request-partial-message ()
11132 (let ((number (gnus-summary-article-number))
11133 (group gnus-newsgroup-name)
11134 (mother gnus-article-buffer))
11135 (set-buffer (get-buffer-create " *Partial Article*"))
11137 (setq mime-preview-buffer mother)
11138 (gnus-request-article-this-buffer number group)
11139 (mime-parse-buffer)
11142 (autoload 'mime-combine-message/partial-pieces-automatically
11144 "Internal method to combine message/partial messages automatically.")
11146 (mime-add-condition
11147 'action '((type . message)(subtype . partial)
11148 (major-mode . gnus-original-article-mode)
11149 (method . mime-combine-message/partial-pieces-automatically)
11150 (summary-buffer-exp . gnus-summary-buffer)
11151 (request-partial-message-method . gnus-request-partial-message)
11155 ;;; @ for message/rfc822
11158 (defun gnus-mime-extract-message/rfc822 (entity situation)
11159 "Burst a forwarded article."
11161 (set-buffer gnus-summary-buffer)
11162 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11163 gnus-newsgroup-name 'gnus-group-history))
11164 (gnus-group-marked (list group))
11167 (mime-insert-entity-content entity)
11168 (setq article (gnus-request-accept-article group)))
11169 (when (and (consp article)
11170 (numberp (setq article (cdr article))))
11171 (setq info (gnus-get-info group))
11172 (gnus-info-set-read info
11173 (gnus-remove-from-range (gnus-info-read info)
11175 (when (string-equal group gnus-newsgroup-name)
11177 (let (gnus-show-threads)
11178 (gnus-summary-goto-subject article t))
11179 (gnus-summary-clear-mark-forward 1))
11180 (set-buffer gnus-group-buffer)
11181 (gnus-group-get-new-news-this-group nil t)))))
11183 (mime-add-condition
11184 'action '((type . message)(subtype . rfc822)
11185 (major-mode . gnus-original-article-mode)
11186 (method . gnus-mime-extract-message/rfc822)
11190 (mime-add-condition
11191 'action '((type . message)(subtype . news)
11192 (major-mode . gnus-original-article-mode)
11193 (method . gnus-mime-extract-message/rfc822)
11197 (defun gnus-mime-extract-multipart (entity situation)
11198 (let ((children (mime-entity-children entity))
11199 mime-acting-situation-to-override
11202 (mime-play-entity (car children)
11203 (cons (assq 'mode situation)
11204 mime-acting-situation-to-override))
11205 (setq children (cdr children)))
11206 (if (setq f (cdr (assq 'after-method
11207 mime-acting-situation-to-override)))
11211 (mime-add-condition
11212 'action '((type . multipart)
11213 (method . gnus-mime-extract-multipart)
11222 (defun gnus-summary-inherit-default-charset ()
11223 "Import `default-mime-charset' from summary buffer.
11224 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11226 (if (buffer-live-p gnus-summary-buffer)
11227 (let (d-m-c d-m-c-u)
11228 (with-current-buffer gnus-summary-buffer
11229 (setq d-m-c (if (local-variable-p 'default-mime-charset
11230 gnus-summary-buffer)
11231 default-mime-charset
11234 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11235 gnus-summary-buffer)
11236 (symbol-value 'default-mime-charset-unlimited)
11239 (kill-local-variable 'default-mime-charset)
11240 (set (make-local-variable 'default-mime-charset) d-m-c))
11242 (kill-local-variable 'default-mime-charset-unlimited)
11243 (set (make-local-variable 'default-mime-charset-unlimited)
11246 (defun gnus-summary-setup-default-charset ()
11247 "Setup newsgroup default charset."
11248 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11250 (setq gnus-newsgroup-charset nil)
11251 (set (make-local-variable 'default-mime-charset) nil)
11252 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11253 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11254 (let ((ignored-charsets
11255 (or gnus-newsgroup-ephemeral-ignored-charsets
11257 (and gnus-newsgroup-name
11258 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11259 gnus-newsgroup-ignored-charsets)))
11261 (setq gnus-newsgroup-charset
11262 (or gnus-newsgroup-ephemeral-charset
11263 (when (and gnus-newsgroup-name
11264 (setq charset (gnus-parameter-charset
11265 gnus-newsgroup-name)))
11266 (make-local-variable 'default-mime-charset)
11267 (setq default-mime-charset charset))
11268 gnus-default-charset))
11269 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11270 ignored-charsets))))
11276 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11277 "Display the current article buffer fully MIME-buttonized.
11278 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11279 treated as multipart/mixed."
11281 (require 'gnus-art)
11282 (let ((gnus-unbuttonized-mime-types nil)
11283 (gnus-mime-display-multipart-as-mixed show-all-parts))
11284 (gnus-summary-show-article)))
11286 (defun gnus-summary-repair-multipart (article)
11287 "Add a Content-Type header to a multipart article without one."
11288 (interactive (list (gnus-summary-article-number)))
11289 (gnus-with-article article
11290 (message-narrow-to-head)
11291 (message-remove-header "Mime-Version")
11292 (goto-char (point-max))
11293 (insert "Mime-Version: 1.0\n")
11295 (when (search-forward "\n--" nil t)
11296 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11297 (message-narrow-to-head)
11298 (message-remove-header "Content-Type")
11299 (goto-char (point-max))
11300 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11303 (let (gnus-mark-article-hook)
11304 (gnus-summary-select-article t t nil article)))
11306 (defun gnus-summary-toggle-display-buttonized ()
11307 "Toggle the buttonizing of the article buffer."
11309 (require 'gnus-art)
11310 (if (setq gnus-inhibit-mime-unbuttonizing
11311 (not gnus-inhibit-mime-unbuttonizing))
11312 (let ((gnus-unbuttonized-mime-types nil))
11313 (gnus-summary-show-article))
11314 (gnus-summary-show-article)))
11317 ;;; Intelli-mouse commmands
11320 (defun gnus-wheel-summary-scroll (event)
11322 (let ((amount (if (memq 'shift (event-modifiers event))
11323 (car gnus-wheel-scroll-amount)
11324 (cdr gnus-wheel-scroll-amount)))
11325 (direction (- (* (static-if (featurep 'xemacs)
11326 (event-button event)
11327 (cond ((eq 'mouse-4 (event-basic-type event))
11329 ((eq 'mouse-5 (event-basic-type event))
11333 (gnus-summary-scroll-up (* amount direction))
11334 (when (gnus-eval-in-buffer-window gnus-article-buffer
11337 (and (if (< 0 direction)
11338 (gnus-article-next-page 0)
11339 (gnus-article-prev-page 0)
11341 (if (setq edge (get-text-property
11342 (point-min) 'gnus-wheel-edge))
11343 (setq edge (* edge direction))
11346 (let ((buffer-read-only nil)
11347 (inhibit-read-only t))
11348 (put-text-property (point-min) (point-max)
11349 'gnus-wheel-edge direction)
11351 (or (> edge gnus-wheel-edge-resistance)
11352 (let ((buffer-read-only nil)
11353 (inhibit-read-only t))
11354 (put-text-property (point-min) (point-max)
11356 (* (1+ edge) direction))
11358 (eq last-command 'gnus-wheel-summary-scroll))))
11359 (gnus-summary-next-article nil nil (minusp direction)))))
11361 (defun gnus-wheel-install ()
11362 "Enable mouse wheel support on summary window."
11363 (when gnus-use-wheel
11365 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11367 (define-key gnus-summary-mode-map key
11368 'gnus-wheel-summary-scroll)))))
11370 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11373 ;;; Traditional PGP commmands
11376 (defun gnus-summary-decrypt-article (&optional force)
11377 "Decrypt the current article in traditional PGP way.
11378 This will have permanent effect only in mail groups.
11379 If FORCE is non-nil, allow editing of articles even in read-only
11382 (gnus-summary-select-article t)
11383 (gnus-eval-in-buffer-window gnus-article-buffer
11387 (goto-char (point-min))
11388 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11389 (error "Not a traditional PGP message!"))
11390 (let ((armor-start (match-beginning 0)))
11391 (if (and (pgg-decrypt-region armor-start (point-max))
11392 (or force (not (gnus-group-read-only-p))))
11393 (let ((inhibit-read-only t)
11395 (delete-region armor-start
11397 (re-search-forward "^-+END PGP" nil t)
11398 (beginning-of-line 2)
11400 (insert-buffer-substring pgg-output-buffer))))))))
11402 (defun gnus-summary-verify-article ()
11403 "Verify the current article in traditional PGP way."
11406 (set-buffer gnus-original-article-buffer)
11407 (goto-char (point-min))
11408 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11409 (error "Not a traditional PGP message!"))
11410 (re-search-forward "^-+END PGP" nil t)
11411 (beginning-of-line 2)
11412 (call-interactively (function pgg-verify-region))))
11415 ;;; Generic summary marking commands
11418 (defvar gnus-summary-marking-alist
11419 '((read gnus-del-mark "d")
11420 (unread gnus-unread-mark "u")
11421 (ticked gnus-ticked-mark "!")
11422 (dormant gnus-dormant-mark "?")
11423 (expirable gnus-expirable-mark "e"))
11424 "An alist of names/marks/keystrokes.")
11426 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11427 (defvar gnus-summary-mark-map)
11429 (defun gnus-summary-make-all-marking-commands ()
11430 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11431 (dolist (elem gnus-summary-marking-alist)
11432 (apply 'gnus-summary-make-marking-command elem)))
11434 (defun gnus-summary-make-marking-command (name mark keystroke)
11435 (let ((map (make-sparse-keymap)))
11436 (define-key gnus-summary-generic-mark-map keystroke map)
11437 (dolist (lway `((next "next" next nil "n")
11438 (next-unread "next unread" next t "N")
11439 (prev "previous" prev nil "p")
11440 (prev-unread "previous unread" prev t "P")
11441 (nomove "" nil nil ,keystroke)))
11442 (let ((func (gnus-summary-make-marking-command-1
11443 mark (car lway) lway name)))
11444 (setq func (eval func))
11445 (define-key map (nth 4 lway) func)))))
11447 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11449 (format "gnus-summary-put-mark-as-%s%s"
11450 name (if (eq way 'nomove)
11452 (concat "-" (symbol-name way)))))
11455 "Mark the current article as %s%s.
11456 If N, the prefix, then repeat N times.
11457 If N is negative, move in reverse order.
11458 The difference between N and the actual number of articles marked is
11460 name (car (cdr lway)))
11462 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11464 (defun gnus-summary-generic-mark (n mark move unread)
11465 "Mark N articles with MARK."
11466 (unless (eq major-mode 'gnus-summary-mode)
11467 (error "This command can only be used in the summary buffer"))
11468 (gnus-summary-show-thread)
11471 ((eq move 'next) 1)
11472 ((eq move 'prev) -1)
11474 (if (zerop nummove)
11478 nummove (* -1 nummove))))
11479 (while (and (> n 0)
11480 (gnus-summary-mark-article nil mark)
11481 (zerop (gnus-summary-next-subject nummove unread t)))
11484 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11485 (gnus-summary-recenter)
11486 (gnus-summary-position-point)
11487 (gnus-set-mode-line 'summary)
11490 (defun gnus-summary-insert-articles (articles)
11491 (when (setq articles
11492 (gnus-sorted-difference articles
11493 (mapcar (lambda (h)
11494 (mail-header-number h))
11495 gnus-newsgroup-headers)))
11496 (setq gnus-newsgroup-headers
11498 gnus-newsgroup-headers
11499 (gnus-fetch-headers articles)
11500 'gnus-article-sort-by-number))
11501 ;; Suppress duplicates?
11502 (when gnus-suppress-duplicates
11503 (gnus-dup-suppress-articles))
11505 ;; We might want to build some more threads first.
11506 (when (and gnus-fetch-old-headers
11507 (eq gnus-headers-retrieved-by 'nov))
11508 (if (eq gnus-fetch-old-headers 'invisible)
11509 (gnus-build-all-threads)
11510 (gnus-build-old-threads)))
11511 ;; Let the Gnus agent mark articles as read.
11513 (gnus-agent-get-undownloaded-list))
11514 ;; Remove list identifiers from subject
11515 (when gnus-list-identifiers
11516 (gnus-summary-remove-list-identifiers))
11517 ;; First and last article in this newsgroup.
11518 (when gnus-newsgroup-headers
11519 (setq gnus-newsgroup-begin
11520 (mail-header-number (car gnus-newsgroup-headers))
11522 (mail-header-number
11523 (gnus-last-element gnus-newsgroup-headers))))
11524 (when gnus-use-scoring
11525 (gnus-possibly-score-headers))))
11527 (defun gnus-summary-insert-old-articles (&optional all)
11528 "Insert all old articles in this group.
11529 If ALL is non-nil, already read articles become readable.
11530 If ALL is a number, fetch this number of articles."
11533 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11536 ;; Some nntp servers lie about their active range. When this happens, the active
11537 ;; range can be in the millions.
11538 ;; Use a compressed range to avoid creating a huge list.
11539 (gnus-range-difference (list gnus-newsgroup-active) old))
11540 (setq len (gnus-range-length older))
11545 (let ((older-range (nreverse older)))
11549 (let* ((r (pop older-range))
11550 (min (if (numberp r) r (car r)))
11551 (max (if (numberp r) r (cdr r))))
11552 (while (and (<= min max)
11557 (setq older (gnus-uncompress-range older))))
11559 (setq older (gnus-uncompress-range older)))
11561 (when (and (numberp gnus-large-newsgroup)
11562 (> len gnus-large-newsgroup))
11563 (let* ((cursor-in-echo-area nil)
11564 (initial (gnus-parameter-large-newsgroup-initial
11565 gnus-newsgroup-name))
11569 "How many articles from %s (%s %d): "
11571 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11572 (if initial "max" "default")
11575 (cons (number-to-string initial)
11577 (unless (string-match "^[ \t]*$" input)
11578 (setq all (string-to-number input))
11580 (let ((older-range (nreverse older)))
11584 (let* ((r (pop older-range))
11585 (min (if (numberp r) r (car r)))
11586 (max (if (numberp r) r (cdr r))))
11587 (while (and (<= min max)
11591 max (1- max))))))))))
11592 (setq older (gnus-uncompress-range older))))
11594 (message "No old news.")
11595 (gnus-summary-insert-articles older)
11596 (gnus-summary-limit (gnus-sorted-nunion old older))))
11597 (gnus-summary-position-point)))
11599 (defun gnus-summary-insert-new-articles ()
11600 "Insert all new articles in this group."
11603 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11604 (old-active gnus-newsgroup-active)
11605 (nnmail-fetched-sources (list t))
11607 (setq gnus-newsgroup-active
11608 (gnus-activate-group gnus-newsgroup-name 'scan))
11609 (setq i (cdr gnus-newsgroup-active))
11610 (while (> i (cdr old-active))
11614 (message "No gnus is bad news.")
11615 (gnus-summary-insert-articles new)
11616 (setq gnus-newsgroup-unreads
11617 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11618 (gnus-summary-limit (gnus-sorted-nunion old new))))
11619 (gnus-summary-position-point)))
11621 (gnus-summary-make-all-marking-commands)
11623 (gnus-ems-redefine)
11625 (provide 'gnus-sum)
11627 (run-hooks 'gnus-sum-load-hook)
11629 ;;; gnus-sum.el ends here