1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include:
151 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
152 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 \(they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-default-high-score 0
217 "*Default threshold for a high scored article.
218 An article will be highlighted as high scored if its score is greater
220 :group 'gnus-score-default
223 (defcustom gnus-summary-default-low-score 0
224 "*Default threshold for a low scored article.
225 An article will be highlighted as low scored if its score is smaller
227 :group 'gnus-score-default
230 (defcustom gnus-summary-zcore-fuzz 0
231 "*Fuzziness factor for the zcore in the summary buffer.
232 Articles with scores closer than this to `gnus-summary-default-score'
234 :group 'gnus-summary-format
237 (defcustom gnus-simplify-subject-fuzzy-regexp nil
238 "*Strings to be removed when doing fuzzy matches.
239 This can either be a regular expression or list of regular expressions
240 that will be removed from subject strings if fuzzy subject
241 simplification is selected."
243 :type '(repeat regexp))
245 (defcustom gnus-show-threads t
246 "*If non-nil, display threads in summary mode."
250 (defcustom gnus-thread-hide-subtree nil
251 "*If non-nil, hide all threads initially.
252 This can be a predicate specifier which says which threads to hide.
253 If threads are hidden, you have to run the command
254 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
255 to expose hidden threads."
259 (defcustom gnus-thread-hide-killed t
260 "*If non-nil, hide killed threads automatically."
264 (defcustom gnus-thread-ignore-subject t
265 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
266 If nil, articles that have different subjects from their parents will
267 start separate threads."
271 (defcustom gnus-thread-operation-ignore-subject t
272 "*If non-nil, subjects will be ignored when doing thread commands.
273 This affects commands like `gnus-summary-kill-thread' and
274 `gnus-summary-lower-thread'.
276 If this variable is nil, articles in the same thread with different
277 subjects will not be included in the operation in question. If this
278 variable is `fuzzy', only articles that have subjects that are fuzzily
279 equal will be included."
281 :type '(choice (const :tag "off" nil)
285 (defcustom gnus-thread-indent-level 4
286 "*Number that says how much each sub-thread should be indented."
290 (defcustom gnus-auto-extend-newsgroup t
291 "*If non-nil, extend newsgroup forward and backward when requested."
292 :group 'gnus-summary-choose
295 (defcustom gnus-auto-select-first t
296 "*If non-nil, select the article under point.
297 Which article this is is controlled by the `gnus-auto-select-subject'
300 If you want to prevent automatic selection of articles in some
301 newsgroups, set the variable to nil in `gnus-select-group-hook'."
302 :group 'gnus-group-select
303 :type '(choice (const :tag "none" nil)
304 (sexp :menu-tag "first" t)))
306 (defcustom gnus-auto-select-subject 'unread
307 "*Says what subject to place under point when entering a group.
309 This variable can either be the symbols `first' (place point on the
310 first subject), `unread' (place point on the subject line of the first
311 unread article), `best' (place point on the subject line of the
312 higest-scored article), `unseen' (place point on the subject line of
313 the first unseen article), 'unseen-or-unread' (place point on the subject
314 line of the first unseen article or, if all article have been seen, on the
315 subject line of the first unread article), or a function to be called to
316 place point on some subject line."
317 :group 'gnus-group-select
318 :type '(choice (const best)
322 (const unseen-or-unread)))
324 (defcustom gnus-dont-select-after-jump-to-other-group nil
325 "If non-nil, don't select the first unread article after entering the
326 other group by the command `gnus-summary-jump-to-other-group'. If nil,
327 it is depend on the value of `gnus-auto-select-first' whether to select
329 :group 'gnus-group-select
332 (defcustom gnus-auto-select-next t
333 "*If non-nil, offer to go to the next group from the end of the previous.
334 If the value is t and the next newsgroup is empty, Gnus will exit
335 summary mode and go back to group mode. If the value is neither nil
336 nor t, Gnus will select the following unread newsgroup. In
337 particular, if the value is the symbol `quietly', the next unread
338 newsgroup will be selected without any confirmation, and if it is
339 `almost-quietly', the next group will be selected without any
340 confirmation if you are located on the last article in the group.
341 Finally, if this variable is `slightly-quietly', the `Z n' command
342 will go to the next group without confirmation."
343 :group 'gnus-summary-maneuvering
344 :type '(choice (const :tag "off" nil)
346 (const almost-quietly)
347 (const slightly-quietly)
348 (sexp :menu-tag "on" t)))
350 (defcustom gnus-auto-select-same nil
351 "*If non-nil, select the next article with the same subject.
352 If there are no more articles with the same subject, go to
353 the first unread article."
354 :group 'gnus-summary-maneuvering
357 (defcustom gnus-summary-check-current nil
358 "*If non-nil, consider the current article when moving.
359 The \"unread\" movement commands will stay on the same line if the
360 current article is unread."
361 :group 'gnus-summary-maneuvering
364 (defcustom gnus-auto-center-summary t
365 "*If non-nil, always center the current summary buffer.
366 In particular, if `vertical' do only vertical recentering. If non-nil
367 and non-`vertical', do both horizontal and vertical recentering."
368 :group 'gnus-summary-maneuvering
369 :type '(choice (const :tag "none" nil)
371 (integer :tag "height")
372 (sexp :menu-tag "both" t)))
374 (defcustom gnus-show-all-headers nil
375 "*If non-nil, don't hide any headers."
376 :group 'gnus-article-hiding
377 :group 'gnus-article-headers
380 (defcustom gnus-summary-ignore-duplicates nil
381 "*If non-nil, ignore articles with identical Message-ID headers."
385 (defcustom gnus-single-article-buffer t
386 "*If non-nil, display all articles in the same buffer.
387 If nil, each group will get its own article buffer."
388 :group 'gnus-article-various
391 (defcustom gnus-break-pages t
392 "*If non-nil, do page breaking on articles.
393 The page delimiter is specified by the `gnus-page-delimiter'
395 :group 'gnus-article-various
398 (defcustom gnus-show-mime t
399 "*If non-nil, do mime processing of articles.
400 The articles will simply be fed to the function given by
401 `gnus-article-display-method-for-mime'."
402 :group 'gnus-article-mime
405 (defcustom gnus-move-split-methods nil
406 "*Variable used to suggest where articles are to be moved to.
407 It uses the same syntax as the `gnus-split-methods' variable.
408 However, whereas `gnus-split-methods' specifies file names as targets,
409 this variable specifies group names."
410 :group 'gnus-summary-mail
411 :type '(repeat (choice (list :value (fun) function)
412 (cons :value ("" "") regexp (repeat string))
415 (defcustom gnus-unread-mark ?\ ;;;Whitespace
416 "*Mark used for unread articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-ticked-mark ?!
421 "*Mark used for ticked articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-dormant-mark ??
426 "*Mark used for dormant articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-del-mark ?r
431 "*Mark used for del'd articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-read-mark ?R
436 "*Mark used for read articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-expirable-mark ?E
441 "*Mark used for expirable articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-killed-mark ?K
446 "*Mark used for killed articles."
447 :group 'gnus-summary-marks
450 (defcustom gnus-spam-mark ?H
451 "*Mark used for spam articles."
452 :group 'gnus-summary-marks
455 (defcustom gnus-souped-mark ?F
456 "*Mark used for souped articles."
457 :group 'gnus-summary-marks
460 (defcustom gnus-kill-file-mark ?X
461 "*Mark used for articles killed by kill files."
462 :group 'gnus-summary-marks
465 (defcustom gnus-low-score-mark ?Y
466 "*Mark used for articles with a low score."
467 :group 'gnus-summary-marks
470 (defcustom gnus-catchup-mark ?C
471 "*Mark used for articles that are caught up."
472 :group 'gnus-summary-marks
475 (defcustom gnus-replied-mark ?A
476 "*Mark used for articles that have been replied to."
477 :group 'gnus-summary-marks
480 (defcustom gnus-forwarded-mark ?F
481 "*Mark used for articles that have been forwarded."
482 :group 'gnus-summary-marks
485 (defcustom gnus-recent-mark ?N
486 "*Mark used for articles that are recent."
487 :group 'gnus-summary-marks
490 (defcustom gnus-cached-mark ?*
491 "*Mark used for articles that are in the cache."
492 :group 'gnus-summary-marks
495 (defcustom gnus-saved-mark ?S
496 "*Mark used for articles that have been saved."
497 :group 'gnus-summary-marks
500 (defcustom gnus-unseen-mark ?.
501 "*Mark used for articles that haven't been seen."
502 :group 'gnus-summary-marks
505 (defcustom gnus-no-mark ?\ ;;;Whitespace
506 "*Mark used for articles that have no other secondary mark."
507 :group 'gnus-summary-marks
510 (defcustom gnus-ancient-mark ?O
511 "*Mark used for ancient articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-sparse-mark ?Q
516 "*Mark used for sparsely reffed articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-canceled-mark ?G
521 "*Mark used for canceled articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-duplicate-mark ?M
526 "*Mark used for duplicate articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-undownloaded-mark ?@
531 "*Mark used for articles that weren't downloaded."
532 :group 'gnus-summary-marks
535 (defcustom gnus-downloadable-mark ?%
536 "*Mark used for articles that are to be downloaded."
537 :group 'gnus-summary-marks
540 (defcustom gnus-unsendable-mark ?=
541 "*Mark used for articles that won't be sent."
542 :group 'gnus-summary-marks
545 (defcustom gnus-score-over-mark ?+
546 "*Score mark used for articles with high scores."
547 :group 'gnus-summary-marks
550 (defcustom gnus-score-below-mark ?-
551 "*Score mark used for articles with low scores."
552 :group 'gnus-summary-marks
555 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
556 "*There is no thread under the article."
557 :group 'gnus-summary-marks
560 (defcustom gnus-not-empty-thread-mark ?=
561 "*There is a thread under the article."
562 :group 'gnus-summary-marks
565 (defcustom gnus-view-pseudo-asynchronously nil
566 "*If non-nil, Gnus will view pseudo-articles asynchronously."
567 :group 'gnus-extract-view
570 (defcustom gnus-auto-expirable-marks
571 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
572 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
573 gnus-souped-mark gnus-duplicate-mark)
574 "*The list of marks converted into expiration if a group is auto-expirable."
577 :type '(repeat character))
579 (defcustom gnus-inhibit-user-auto-expire t
580 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
585 (defcustom gnus-view-pseudos nil
586 "*If `automatic', pseudo-articles will be viewed automatically.
587 If `not-confirm', pseudos will be viewed automatically, and the user
588 will not be asked to confirm the command."
589 :group 'gnus-extract-view
590 :type '(choice (const :tag "off" nil)
592 (const not-confirm)))
594 (defcustom gnus-view-pseudos-separately t
595 "*If non-nil, one pseudo-article will be created for each file to be viewed.
596 If nil, all files that use the same viewing command will be given as a
597 list of parameters to that command."
598 :group 'gnus-extract-view
601 (defcustom gnus-insert-pseudo-articles t
602 "*If non-nil, insert pseudo-articles when decoding articles."
603 :group 'gnus-extract-view
606 (defcustom gnus-summary-dummy-line-format
608 "*The format specification for the dummy roots in the summary buffer.
609 It works along the same lines as a normal formatting string,
610 with some simple extensions.
614 General format specifiers can also be used.
615 See `(gnus)Formatting Variables'."
616 :link '(custom-manual "(gnus)Formatting Variables")
617 :group 'gnus-threading
620 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
621 "*The format specification for the summary mode line.
622 It works along the same lines as a normal formatting string,
623 with some simple extensions:
626 %p Unprefixed group name
627 %A Current article number
628 %z Current article score
630 %U Number of unread articles in the group
631 %e Number of unselected articles in the group
632 %Z A string with unread/unselected article counts
633 %g Shortish group name
634 %S Subject of the current article
636 %s Current score file name
637 %d Number of dormant articles
638 %r Number of articles that have been marked as read in this session
639 %E Number of articles expunged by the score files"
640 :group 'gnus-summary-format
643 (defcustom gnus-list-identifiers nil
644 "Regexp that matches list identifiers to be removed from subject.
645 This can also be a list of regexps."
647 :group 'gnus-summary-format
648 :group 'gnus-article-hiding
649 :type '(choice (const :tag "none" nil)
651 (repeat :value (".*") regexp)))
653 (defcustom gnus-summary-mark-below 0
654 "*Mark all articles with a score below this variable as read.
655 This variable is local to each summary buffer and usually set by the
657 :group 'gnus-score-default
660 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
661 "*List of functions used for sorting articles in the summary buffer.
663 Each function takes two articles and returns non-nil if the first
664 article should be sorted before the other. If you use more than one
665 function, the primary sort function should be the last. You should
666 probably always include `gnus-article-sort-by-number' in the list of
667 sorting functions -- preferably first. Also note that sorting by date
668 is often much slower than sorting by number, and the sorting order is
669 very similar. (Sorting by date means sorting by the time the message
670 was sent, sorting by number means sorting by arrival time.)
672 Ready-made functions include `gnus-article-sort-by-number',
673 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
674 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
675 and `gnus-article-sort-by-score'.
677 When threading is turned on, the variable `gnus-thread-sort-functions'
678 controls how articles are sorted."
679 :group 'gnus-summary-sort
680 :type '(repeat (choice (function-item gnus-article-sort-by-number)
681 (function-item gnus-article-sort-by-author)
682 (function-item gnus-article-sort-by-subject)
683 (function-item gnus-article-sort-by-date)
684 (function-item gnus-article-sort-by-score)
685 (function-item gnus-article-sort-by-random)
686 (function :tag "other"))))
688 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
689 "*List of functions used for sorting threads in the summary buffer.
690 By default, threads are sorted by article number.
692 Each function takes two threads and returns non-nil if the first
693 thread should be sorted before the other. If you use more than one
694 function, the primary sort function should be the last. You should
695 probably always include `gnus-thread-sort-by-number' in the list of
696 sorting functions -- preferably first. Also note that sorting by date
697 is often much slower than sorting by number, and the sorting order is
698 very similar. (Sorting by date means sorting by the time the message
699 was sent, sorting by number means sorting by arrival time.)
701 Ready-made functions include `gnus-thread-sort-by-number',
702 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
703 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
704 `gnus-thread-sort-by-most-recent-number',
705 `gnus-thread-sort-by-most-recent-date',
706 `gnus-thread-sort-by-random', and
707 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
709 When threading is turned off, the variable
710 `gnus-article-sort-functions' controls how articles are sorted."
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
713 (function-item gnus-thread-sort-by-author)
714 (function-item gnus-thread-sort-by-subject)
715 (function-item gnus-thread-sort-by-date)
716 (function-item gnus-thread-sort-by-score)
717 (function-item gnus-thread-sort-by-total-score)
718 (function-item gnus-thread-sort-by-random)
719 (function :tag "other"))))
721 (defcustom gnus-thread-score-function '+
722 "*Function used for calculating the total score of a thread.
724 The function is called with the scores of the article and each
725 subthread and should then return the score of the thread.
727 Some functions you can use are `+', `max', or `min'."
728 :group 'gnus-summary-sort
731 (defcustom gnus-summary-expunge-below nil
732 "All articles that have a score less than this variable will be expunged.
733 This variable is local to the summary buffers."
734 :group 'gnus-score-default
735 :type '(choice (const :tag "off" nil)
738 (defcustom gnus-thread-expunge-below nil
739 "All threads that have a total score less than this variable will be expunged.
740 See `gnus-thread-score-function' for en explanation of what a
743 This variable is local to the summary buffers."
744 :group 'gnus-threading
745 :group 'gnus-score-default
746 :type '(choice (const :tag "off" nil)
749 (defcustom gnus-summary-mode-hook nil
750 "*A hook for Gnus summary mode.
751 This hook is run before any variables are set in the summary buffer."
752 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
753 :group 'gnus-summary-various
756 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
757 (when (featurep 'xemacs)
758 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
759 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
760 (add-hook 'gnus-summary-mode-hook
761 'gnus-xmas-switch-horizontal-scrollbar-off))
763 (defcustom gnus-summary-menu-hook nil
764 "*Hook run after the creation of the summary mode menu."
765 :group 'gnus-summary-visual
768 (defcustom gnus-summary-exit-hook nil
769 "*A hook called on exit from the summary buffer.
770 It will be called with point in the group buffer."
771 :group 'gnus-summary-exit
774 (defcustom gnus-summary-prepare-hook nil
775 "*A hook called after the summary buffer has been generated.
776 If you want to modify the summary buffer, you can use this hook."
777 :group 'gnus-summary-various
780 (defcustom gnus-summary-prepared-hook nil
781 "*A hook called as the last thing after the summary buffer has been generated."
782 :group 'gnus-summary-various
785 (defcustom gnus-summary-generate-hook nil
786 "*A hook run just before generating the summary buffer.
787 This hook is commonly used to customize threading variables and the
789 :group 'gnus-summary-various
792 (defcustom gnus-select-group-hook nil
793 "*A hook called when a newsgroup is selected.
795 If you'd like to simplify subjects like the
796 `gnus-summary-next-same-subject' command does, you can use the
799 (add-hook gnus-select-group-hook
801 (mapcar (lambda (header)
802 (mail-header-set-subject
804 (gnus-simplify-subject
805 (mail-header-subject header) 're-only)))
806 gnus-newsgroup-headers)))"
807 :group 'gnus-group-select
810 (defcustom gnus-select-article-hook nil
811 "*A hook called when an article is selected."
812 :group 'gnus-summary-choose
815 (defcustom gnus-visual-mark-article-hook
816 (list 'gnus-highlight-selected-summary)
817 "*Hook run after selecting an article in the summary buffer.
818 It is meant to be used for highlighting the article in some way. It
819 is not run if `gnus-visual' is nil."
820 :group 'gnus-summary-visual
823 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
824 "*A hook called before parsing the headers."
828 (defcustom gnus-exit-group-hook nil
829 "*A hook called when exiting summary mode.
830 This hook is not called from the non-updating exit commands like `Q'."
834 (defcustom gnus-summary-update-hook
835 (list 'gnus-summary-highlight-line)
836 "*A hook called when a summary line is changed.
837 The hook will not be called if `gnus-visual' is nil.
839 The default function `gnus-summary-highlight-line' will
840 highlight the line according to the `gnus-summary-highlight'
842 :group 'gnus-summary-visual
845 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
846 "*A hook called when an article is selected for the first time.
847 The hook is intended to mark an article as read (or unread)
848 automatically when it is selected."
849 :group 'gnus-summary-choose
852 (defcustom gnus-group-no-more-groups-hook nil
853 "*A hook run when returning to group mode having no more (unread) groups."
854 :group 'gnus-group-select
857 (defcustom gnus-ps-print-hook nil
858 "*A hook run before ps-printing something from Gnus."
862 (defcustom gnus-summary-display-arrow
863 (and (fboundp 'display-graphic-p)
865 "*If non-nil, display an arrow highlighting the current article."
870 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
871 "Face used for highlighting the current article in the summary buffer."
872 :group 'gnus-summary-visual
875 (defcustom gnus-summary-highlight
876 '(((eq mark gnus-canceled-mark)
877 . gnus-summary-cancelled-face)
878 ((and (> score default-high)
879 (or (eq mark gnus-dormant-mark)
880 (eq mark gnus-ticked-mark)))
881 . gnus-summary-high-ticked-face)
882 ((and (< score default-low)
883 (or (eq mark gnus-dormant-mark)
884 (eq mark gnus-ticked-mark)))
885 . gnus-summary-low-ticked-face)
886 ((or (eq mark gnus-dormant-mark)
887 (eq mark gnus-ticked-mark))
888 . gnus-summary-normal-ticked-face)
889 ((and (> score default-high) (eq mark gnus-ancient-mark))
890 . gnus-summary-high-ancient-face)
891 ((and (< score default-low) (eq mark gnus-ancient-mark))
892 . gnus-summary-low-ancient-face)
893 ((eq mark gnus-ancient-mark)
894 . gnus-summary-normal-ancient-face)
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)
1092 (defvar gnus-inhibit-mime-unbuttonizing nil)
1094 (defvar gnus-original-article nil)
1095 (defvar gnus-article-internal-prepare-hook nil)
1096 (defvar gnus-newsgroup-process-stack nil)
1098 (defvar gnus-thread-indent-array nil)
1099 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1100 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1101 "Function called to sort the articles within a thread after it has been gathered together.")
1103 (defvar gnus-summary-save-parts-type-history nil)
1104 (defvar gnus-summary-save-parts-last-directory nil)
1106 ;; Avoid highlighting in kill files.
1107 (defvar gnus-summary-inhibit-highlight nil)
1108 (defvar gnus-newsgroup-selected-overlay nil)
1109 (defvar gnus-inhibit-limiting nil)
1110 (defvar gnus-newsgroup-adaptive-score-file nil)
1111 (defvar gnus-current-score-file nil)
1112 (defvar gnus-current-move-group nil)
1113 (defvar gnus-current-copy-group nil)
1114 (defvar gnus-current-crosspost-group nil)
1115 (defvar gnus-newsgroup-display nil)
1117 (defvar gnus-newsgroup-dependencies nil)
1118 (defvar gnus-newsgroup-adaptive nil)
1119 (defvar gnus-summary-display-article-function nil)
1120 (defvar gnus-summary-highlight-line-function nil
1121 "Function called after highlighting a summary line.")
1123 (defvar gnus-summary-line-format-alist
1124 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1125 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1126 (?s gnus-tmp-subject-or-nil ?s)
1127 (?n gnus-tmp-name ?s)
1128 (?A (std11-address-string
1129 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1130 (?a (or (std11-full-name-string
1131 (car (mime-entity-read-field gnus-tmp-header 'From)))
1133 (?F gnus-tmp-from ?s)
1134 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1135 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1136 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1137 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1138 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1139 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1140 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1141 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1142 (?L gnus-tmp-lines ?s)
1143 (?I gnus-tmp-indentation ?s)
1144 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1145 (?R gnus-tmp-replied ?c)
1146 (?\[ gnus-tmp-opening-bracket ?c)
1147 (?\] gnus-tmp-closing-bracket ?c)
1148 (?\> (make-string gnus-tmp-level ? ) ?s)
1149 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1150 (?i gnus-tmp-score ?d)
1151 (?z gnus-tmp-score-char ?c)
1152 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1153 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1154 (?U gnus-tmp-unread ?c)
1155 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1157 (?t (gnus-summary-number-of-articles-in-thread
1158 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1160 (?e (gnus-summary-number-of-articles-in-thread
1161 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1163 (?u gnus-tmp-user-defined ?s)
1164 (?P (gnus-pick-line-number) ?d)
1165 (?B gnus-tmp-thread-tree-header-string ?s)
1166 (user-date (gnus-user-date
1167 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1168 "An alist of format specifications that can appear in summary lines.
1169 These are paired with what variables they correspond with, along with
1170 the type of the variable (string, integer, character, etc).")
1172 (defvar gnus-summary-dummy-line-format-alist
1173 `((?S gnus-tmp-subject ?s)
1174 (?N gnus-tmp-number ?d)
1175 (?u gnus-tmp-user-defined ?s)))
1177 (defvar gnus-summary-mode-line-format-alist
1178 `((?G gnus-tmp-group-name ?s)
1179 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1180 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1181 (?A gnus-tmp-article-number ?d)
1182 (?Z gnus-tmp-unread-and-unselected ?s)
1183 (?V gnus-version ?s)
1184 (?U gnus-tmp-unread-and-unticked ?d)
1185 (?S gnus-tmp-subject ?s)
1186 (?e gnus-tmp-unselected ?d)
1187 (?u gnus-tmp-user-defined ?s)
1188 (?d (length gnus-newsgroup-dormant) ?d)
1189 (?t (length gnus-newsgroup-marked) ?d)
1190 (?h (length gnus-newsgroup-spam-marked) ?d)
1191 (?r (length gnus-newsgroup-reads) ?d)
1192 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1193 (?E gnus-newsgroup-expunged-tally ?d)
1194 (?s (gnus-current-score-file-nondirectory) ?s)))
1196 (defvar gnus-last-search-regexp nil
1197 "Default regexp for article search command.")
1199 (defvar gnus-summary-search-article-matched-data nil
1200 "Last matched data of article search command. It is the local variable
1201 in `gnus-article-buffer' which consists of the list of start position,
1202 end position and text.")
1204 (defvar gnus-last-shell-command nil
1205 "Default shell command on article.")
1207 (defvar gnus-newsgroup-begin nil)
1208 (defvar gnus-newsgroup-end nil)
1209 (defvar gnus-newsgroup-last-rmail nil)
1210 (defvar gnus-newsgroup-last-mail nil)
1211 (defvar gnus-newsgroup-last-folder nil)
1212 (defvar gnus-newsgroup-last-file nil)
1213 (defvar gnus-newsgroup-auto-expire nil)
1214 (defvar gnus-newsgroup-active nil)
1216 (defvar gnus-newsgroup-data nil)
1217 (defvar gnus-newsgroup-data-reverse nil)
1218 (defvar gnus-newsgroup-limit nil)
1219 (defvar gnus-newsgroup-limits nil)
1221 (defvar gnus-newsgroup-unreads nil
1222 "Sorted list of unread articles in the current newsgroup.")
1224 (defvar gnus-newsgroup-unselected nil
1225 "Sorted list of unselected unread articles in the current newsgroup.")
1227 (defvar gnus-newsgroup-reads nil
1228 "Alist of read articles and article marks in the current newsgroup.")
1230 (defvar gnus-newsgroup-expunged-tally nil)
1232 (defvar gnus-newsgroup-marked nil
1233 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1235 (defvar gnus-newsgroup-spam-marked nil
1236 "List of ranges of articles that have been marked as spam.")
1238 (defvar gnus-newsgroup-killed nil
1239 "List of ranges of articles that have been through the scoring process.")
1241 (defvar gnus-newsgroup-cached nil
1242 "Sorted list of articles that come from the article cache.")
1244 (defvar gnus-newsgroup-saved nil
1245 "List of articles that have been saved.")
1247 (defvar gnus-newsgroup-kill-headers nil)
1249 (defvar gnus-newsgroup-replied nil
1250 "List of articles that have been replied to in the current newsgroup.")
1252 (defvar gnus-newsgroup-forwarded nil
1253 "List of articles that have been forwarded in the current newsgroup.")
1255 (defvar gnus-newsgroup-recent nil
1256 "List of articles that have are recent in the current newsgroup.")
1258 (defvar gnus-newsgroup-expirable nil
1259 "Sorted list of articles in the current newsgroup that can be expired.")
1261 (defvar gnus-newsgroup-processable nil
1262 "List of articles in the current newsgroup that can be processed.")
1264 (defvar gnus-newsgroup-downloadable nil
1265 "Sorted list of articles in the current newsgroup that can be processed.")
1267 (defvar gnus-newsgroup-undownloaded nil
1268 "List of articles in the current newsgroup that haven't been downloaded..")
1270 (defvar gnus-newsgroup-unsendable nil
1271 "List of articles in the current newsgroup that won't be sent.")
1273 (defvar gnus-newsgroup-bookmarks nil
1274 "List of articles in the current newsgroup that have bookmarks.")
1276 (defvar gnus-newsgroup-dormant nil
1277 "Sorted list of dormant articles in the current newsgroup.")
1279 (defvar gnus-newsgroup-unseen nil
1280 "List of unseen articles in the current newsgroup.")
1282 (defvar gnus-newsgroup-seen nil
1283 "Range of seen articles in the current newsgroup.")
1285 (defvar gnus-newsgroup-articles nil
1286 "List of articles in the current newsgroup.")
1288 (defvar gnus-newsgroup-scored nil
1289 "List of scored articles in the current newsgroup.")
1291 (defvar gnus-newsgroup-incorporated nil
1292 "List of incorporated articles in the current newsgroup.")
1294 (defvar gnus-newsgroup-headers nil
1295 "List of article headers in the current newsgroup.")
1297 (defvar gnus-newsgroup-threads nil)
1299 (defvar gnus-newsgroup-prepared nil
1300 "Whether the current group has been prepared properly.")
1302 (defvar gnus-newsgroup-ancient nil
1303 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1305 (defvar gnus-newsgroup-sparse nil)
1307 (defvar gnus-current-article nil)
1308 (defvar gnus-article-current nil)
1309 (defvar gnus-current-headers nil)
1310 (defvar gnus-have-all-headers nil)
1311 (defvar gnus-last-article nil)
1312 (defvar gnus-newsgroup-history nil)
1313 (defvar gnus-newsgroup-charset nil)
1314 (defvar gnus-newsgroup-ephemeral-charset nil)
1315 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1317 (defvar gnus-article-before-search nil)
1319 (defconst gnus-summary-local-variables
1320 '(gnus-newsgroup-name
1321 gnus-newsgroup-begin gnus-newsgroup-end
1322 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1323 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1324 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1325 gnus-newsgroup-unselected gnus-newsgroup-marked
1326 gnus-newsgroup-spam-marked
1327 gnus-newsgroup-reads gnus-newsgroup-saved
1328 gnus-newsgroup-replied gnus-newsgroup-forwarded
1329 gnus-newsgroup-recent
1330 gnus-newsgroup-expirable
1331 gnus-newsgroup-processable gnus-newsgroup-killed
1332 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1333 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1334 gnus-newsgroup-seen gnus-newsgroup-articles
1335 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1336 gnus-newsgroup-headers gnus-newsgroup-threads
1337 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1338 gnus-current-article gnus-current-headers gnus-have-all-headers
1339 gnus-last-article gnus-article-internal-prepare-hook
1340 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1341 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1342 gnus-thread-expunge-below
1343 gnus-score-alist gnus-current-score-file
1344 (gnus-summary-expunge-below . global)
1345 (gnus-summary-mark-below . global)
1346 (gnus-orphan-score . global)
1347 gnus-newsgroup-active gnus-scores-exclude-files
1348 gnus-newsgroup-history gnus-newsgroup-ancient
1349 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1350 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1351 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1352 (gnus-newsgroup-expunged-tally . 0)
1353 gnus-cache-removable-articles gnus-newsgroup-cached
1354 gnus-newsgroup-data gnus-newsgroup-data-reverse
1355 gnus-newsgroup-limit gnus-newsgroup-limits
1356 gnus-newsgroup-charset gnus-newsgroup-display
1357 gnus-newsgroup-incorporated)
1358 "Variables that are buffer-local to the summary buffers.")
1360 (defvar gnus-newsgroup-variables nil
1361 "A list of variables that have separate values in different newsgroups.
1362 A list of newsgroup (summary buffer) local variables, or cons of
1363 variables and their default values (when the default values are not
1364 nil), that should be made global while the summary buffer is active.
1365 These variables can be used to set variables in the group parameters
1366 while still allowing them to affect operations done in other
1367 buffers. For example:
1369 \(setq gnus-newsgroup-variables
1370 '(message-use-followup-to
1371 (gnus-visible-headers .
1372 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1375 ;; Byte-compiler warning.
1376 (eval-when-compile (defvar gnus-article-mode-map))
1378 ;; Subject simplification.
1380 (defun gnus-simplify-whitespace (str)
1381 "Remove excessive whitespace from STR."
1384 (while (string-match "[ \t][ \t]+" mystr)
1385 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1387 (substring mystr (match-end 0)))))
1389 (when (string-match "^[ \t]+" mystr)
1390 (setq mystr (substring mystr (match-end 0))))
1392 (when (string-match "[ \t]+$" mystr)
1393 (setq mystr (substring mystr 0 (match-beginning 0))))
1396 (defun gnus-simplify-all-whitespace (str)
1397 "Remove all whitespace from STR."
1399 (while (string-match "[ \t\n]+" mystr)
1400 (setq mystr (replace-match "" nil nil mystr)))
1403 (defsubst gnus-simplify-subject-re (subject)
1404 "Remove \"Re:\" from subject lines."
1405 (if (string-match message-subject-re-regexp subject)
1406 (substring subject (match-end 0))
1409 (defun gnus-simplify-subject (subject &optional re-only)
1410 "Remove `Re:' and words in parentheses.
1411 If RE-ONLY is non-nil, strip leading `Re:'s only."
1412 (let ((case-fold-search t)) ;Ignore case.
1413 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1414 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1415 (setq subject (substring subject (match-end 0))))
1416 ;; Remove uninteresting prefixes.
1417 (when (and (not re-only)
1418 gnus-simplify-ignored-prefixes
1419 (string-match gnus-simplify-ignored-prefixes subject))
1420 (setq subject (substring subject (match-end 0))))
1421 ;; Remove words in parentheses from end.
1423 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1424 (setq subject (substring subject 0 (match-beginning 0)))))
1425 ;; Return subject string.
1428 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1430 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1431 (goto-char (point-min))
1432 (while (re-search-forward regexp nil t)
1433 (replace-match (or newtext ""))))
1435 (defun gnus-simplify-buffer-fuzzy ()
1436 "Simplify string in the buffer fuzzily.
1437 The string in the accessible portion of the current buffer is simplified.
1438 It is assumed to be a single-line subject.
1439 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1440 matter is removed. Additional things can be deleted by setting
1441 `gnus-simplify-subject-fuzzy-regexp'."
1442 (let ((case-fold-search t)
1444 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1446 (while (not (eq modified-tick (buffer-modified-tick)))
1447 (setq modified-tick (buffer-modified-tick))
1449 ((listp gnus-simplify-subject-fuzzy-regexp)
1450 (mapcar 'gnus-simplify-buffer-fuzzy-step
1451 gnus-simplify-subject-fuzzy-regexp))
1452 (gnus-simplify-subject-fuzzy-regexp
1453 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1454 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1455 (gnus-simplify-buffer-fuzzy-step
1456 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1457 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1459 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1460 (gnus-simplify-buffer-fuzzy-step " +" " ")
1461 (gnus-simplify-buffer-fuzzy-step " $")
1462 (gnus-simplify-buffer-fuzzy-step "^ +")))
1464 (defun gnus-simplify-subject-fuzzy (subject)
1465 "Simplify a subject string fuzzily.
1466 See `gnus-simplify-buffer-fuzzy' for details."
1468 (gnus-set-work-buffer)
1469 (let ((case-fold-search t))
1470 ;; Remove uninteresting prefixes.
1471 (when (and gnus-simplify-ignored-prefixes
1472 (string-match gnus-simplify-ignored-prefixes subject))
1473 (setq subject (substring subject (match-end 0))))
1475 (inline (gnus-simplify-buffer-fuzzy))
1478 (defsubst gnus-simplify-subject-fully (subject)
1479 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1481 (gnus-simplify-subject-functions
1482 (gnus-map-function gnus-simplify-subject-functions subject))
1483 ((null gnus-summary-gather-subject-limit)
1484 (gnus-simplify-subject-re subject))
1485 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1486 (gnus-simplify-subject-fuzzy subject))
1487 ((numberp gnus-summary-gather-subject-limit)
1488 (gnus-limit-string (gnus-simplify-subject-re subject)
1489 gnus-summary-gather-subject-limit))
1493 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1494 "Check whether two subjects are equal.
1495 If optional argument simple-first is t, first argument is already
1498 ((null simple-first)
1499 (equal (gnus-simplify-subject-fully s1)
1500 (gnus-simplify-subject-fully s2)))
1503 (gnus-simplify-subject-fully s2)))))
1505 (defun gnus-summary-bubble-group ()
1506 "Increase the score of the current group.
1507 This is a handy function to add to `gnus-summary-exit-hook' to
1508 increase the score of each group you read."
1509 (gnus-group-add-score gnus-newsgroup-name))
1513 ;;; Gnus summary mode
1516 (put 'gnus-summary-mode 'mode-class 'special)
1518 (defvar gnus-article-commands-menu)
1521 ;; Non-orthogonal keys
1523 (gnus-define-keys gnus-summary-mode-map
1524 " " gnus-summary-next-page
1525 "\177" gnus-summary-prev-page
1526 [delete] gnus-summary-prev-page
1527 [backspace] gnus-summary-prev-page
1528 "\r" gnus-summary-scroll-up
1529 "\M-\r" gnus-summary-scroll-down
1530 "n" gnus-summary-next-unread-article
1531 "p" gnus-summary-prev-unread-article
1532 "N" gnus-summary-next-article
1533 "P" gnus-summary-prev-article
1534 "\M-\C-n" gnus-summary-next-same-subject
1535 "\M-\C-p" gnus-summary-prev-same-subject
1536 "\M-n" gnus-summary-next-unread-subject
1537 "\M-p" gnus-summary-prev-unread-subject
1538 "." gnus-summary-first-unread-article
1539 "," gnus-summary-best-unread-article
1540 "\M-s" gnus-summary-search-article-forward
1541 "\M-r" gnus-summary-search-article-backward
1542 "<" gnus-summary-beginning-of-article
1543 ">" gnus-summary-end-of-article
1544 "j" gnus-summary-goto-article
1545 "^" gnus-summary-refer-parent-article
1546 "\M-^" gnus-summary-refer-article
1547 "u" gnus-summary-tick-article-forward
1548 "!" gnus-summary-tick-article-forward
1549 "U" gnus-summary-tick-article-backward
1550 "d" gnus-summary-mark-as-read-forward
1551 "D" gnus-summary-mark-as-read-backward
1552 "E" gnus-summary-mark-as-expirable
1553 "\M-u" gnus-summary-clear-mark-forward
1554 "\M-U" gnus-summary-clear-mark-backward
1555 "k" gnus-summary-kill-same-subject-and-select
1556 "\C-k" gnus-summary-kill-same-subject
1557 "\M-\C-k" gnus-summary-kill-thread
1558 "\M-\C-l" gnus-summary-lower-thread
1559 "e" gnus-summary-edit-article
1560 "#" gnus-summary-mark-as-processable
1561 "\M-#" gnus-summary-unmark-as-processable
1562 "\M-\C-t" gnus-summary-toggle-threads
1563 "\M-\C-s" gnus-summary-show-thread
1564 "\M-\C-h" gnus-summary-hide-thread
1565 "\M-\C-f" gnus-summary-next-thread
1566 "\M-\C-b" gnus-summary-prev-thread
1567 [(meta down)] gnus-summary-next-thread
1568 [(meta up)] gnus-summary-prev-thread
1569 "\M-\C-u" gnus-summary-up-thread
1570 "\M-\C-d" gnus-summary-down-thread
1571 "&" gnus-summary-execute-command
1572 "c" gnus-summary-catchup-and-exit
1573 "\C-w" gnus-summary-mark-region-as-read
1574 "\C-t" gnus-summary-toggle-truncation
1575 "?" gnus-summary-mark-as-dormant
1576 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1577 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1578 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1579 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1580 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1581 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1582 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1583 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1584 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1585 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1586 "=" gnus-summary-expand-window
1587 "\C-x\C-s" gnus-summary-reselect-current-group
1588 "\M-g" gnus-summary-rescan-group
1589 "w" gnus-summary-stop-page-breaking
1590 "\C-c\C-r" gnus-summary-caesar-message
1591 "\M-t" gnus-summary-toggle-mime
1592 "f" gnus-summary-followup
1593 "F" gnus-summary-followup-with-original
1594 "C" gnus-summary-cancel-article
1595 "r" gnus-summary-reply
1596 "R" gnus-summary-reply-with-original
1597 "\C-c\C-f" gnus-summary-mail-forward
1598 "o" gnus-summary-save-article
1599 "\C-o" gnus-summary-save-article-mail
1600 "|" gnus-summary-pipe-output
1601 "\M-k" gnus-summary-edit-local-kill
1602 "\M-K" gnus-summary-edit-global-kill
1604 "\C-c\C-d" gnus-summary-describe-group
1605 "q" gnus-summary-exit
1606 "Q" gnus-summary-exit-no-update
1607 "\C-c\C-i" gnus-info-find-node
1608 gnus-mouse-2 gnus-mouse-pick-article
1609 "m" gnus-summary-mail-other-window
1610 "a" gnus-summary-post-news
1611 "i" gnus-summary-news-other-window
1612 "x" gnus-summary-limit-to-unread
1613 "s" gnus-summary-isearch-article
1614 "t" gnus-summary-toggle-header
1615 "g" gnus-summary-show-article
1616 "l" gnus-summary-goto-last-article
1617 "v" gnus-summary-preview-mime-message
1618 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1619 "\C-d" gnus-summary-enter-digest-group
1620 "\M-\C-d" gnus-summary-read-document
1621 "\M-\C-e" gnus-summary-edit-parameters
1622 "\M-\C-a" gnus-summary-customize-parameters
1624 "\C-c\C-n" gnus-namazu-search
1625 "*" gnus-cache-enter-article
1626 "\M-*" gnus-cache-remove-article
1627 "\M-&" gnus-summary-universal-argument
1628 "\C-l" gnus-recenter
1629 "I" gnus-summary-increase-score
1630 "L" gnus-summary-lower-score
1631 "\M-i" gnus-symbolic-argument
1632 "h" gnus-summary-select-article-buffer
1634 "V" gnus-summary-score-map
1635 "X" gnus-uu-extract-map
1636 "S" gnus-summary-send-map)
1638 ;; Sort of orthogonal keymap
1639 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1640 "t" gnus-summary-tick-article-forward
1641 "!" gnus-summary-tick-article-forward
1642 "d" gnus-summary-mark-as-read-forward
1643 "r" gnus-summary-mark-as-read-forward
1644 "c" gnus-summary-clear-mark-forward
1645 " " gnus-summary-clear-mark-forward
1646 "e" gnus-summary-mark-as-expirable
1647 "x" gnus-summary-mark-as-expirable
1648 "?" gnus-summary-mark-as-dormant
1649 "b" gnus-summary-set-bookmark
1650 "B" gnus-summary-remove-bookmark
1651 "#" gnus-summary-mark-as-processable
1652 "\M-#" gnus-summary-unmark-as-processable
1653 "S" gnus-summary-limit-include-expunged
1654 "C" gnus-summary-catchup
1655 "H" gnus-summary-catchup-to-here
1656 "h" gnus-summary-catchup-from-here
1657 "\C-c" gnus-summary-catchup-all
1658 "k" gnus-summary-kill-same-subject-and-select
1659 "K" gnus-summary-kill-same-subject
1660 "P" gnus-uu-mark-map)
1662 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1663 "c" gnus-summary-clear-above
1664 "u" gnus-summary-tick-above
1665 "m" gnus-summary-mark-above
1666 "k" gnus-summary-kill-below)
1668 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1669 "/" gnus-summary-limit-to-subject
1670 "n" gnus-summary-limit-to-articles
1671 "w" gnus-summary-pop-limit
1672 "s" gnus-summary-limit-to-subject
1673 "a" gnus-summary-limit-to-author
1674 "u" gnus-summary-limit-to-unread
1675 "m" gnus-summary-limit-to-marks
1676 "M" gnus-summary-limit-exclude-marks
1677 "v" gnus-summary-limit-to-score
1678 "*" gnus-summary-limit-include-cached
1679 "D" gnus-summary-limit-include-dormant
1680 "T" gnus-summary-limit-include-thread
1681 "d" gnus-summary-limit-exclude-dormant
1682 "t" gnus-summary-limit-to-age
1683 "." gnus-summary-limit-to-unseen
1684 "x" gnus-summary-limit-to-extra
1685 "p" gnus-summary-limit-to-display-predicate
1686 "E" gnus-summary-limit-include-expunged
1687 "c" gnus-summary-limit-exclude-childless-dormant
1688 "C" gnus-summary-limit-mark-excluded-as-read
1689 "o" gnus-summary-insert-old-articles
1690 "N" gnus-summary-insert-new-articles)
1692 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1693 "n" gnus-summary-next-unread-article
1694 "p" gnus-summary-prev-unread-article
1695 "N" gnus-summary-next-article
1696 "P" gnus-summary-prev-article
1697 "\C-n" gnus-summary-next-same-subject
1698 "\C-p" gnus-summary-prev-same-subject
1699 "\M-n" gnus-summary-next-unread-subject
1700 "\M-p" gnus-summary-prev-unread-subject
1701 "f" gnus-summary-first-unread-article
1702 "b" gnus-summary-best-unread-article
1703 "j" gnus-summary-goto-article
1704 "g" gnus-summary-goto-subject
1705 "l" gnus-summary-goto-last-article
1706 "o" gnus-summary-pop-article)
1708 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1709 "k" gnus-summary-kill-thread
1710 "l" gnus-summary-lower-thread
1711 "i" gnus-summary-raise-thread
1712 "T" gnus-summary-toggle-threads
1713 "t" gnus-summary-rethread-current
1714 "^" gnus-summary-reparent-thread
1715 "s" gnus-summary-show-thread
1716 "S" gnus-summary-show-all-threads
1717 "h" gnus-summary-hide-thread
1718 "H" gnus-summary-hide-all-threads
1719 "n" gnus-summary-next-thread
1720 "p" gnus-summary-prev-thread
1721 "u" gnus-summary-up-thread
1722 "o" gnus-summary-top-thread
1723 "d" gnus-summary-down-thread
1724 "#" gnus-uu-mark-thread
1725 "\M-#" gnus-uu-unmark-thread)
1727 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1728 "g" gnus-summary-prepare
1729 "c" gnus-summary-insert-cached-articles)
1731 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1732 "c" gnus-summary-catchup-and-exit
1733 "C" gnus-summary-catchup-all-and-exit
1734 "E" gnus-summary-exit-no-update
1735 "J" gnus-summary-jump-to-other-group
1736 "Q" gnus-summary-exit
1737 "Z" gnus-summary-exit
1738 "n" gnus-summary-catchup-and-goto-next-group
1739 "R" gnus-summary-reselect-current-group
1740 "G" gnus-summary-rescan-group
1741 "N" gnus-summary-next-group
1742 "s" gnus-summary-save-newsrc
1743 "P" gnus-summary-prev-group)
1745 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1746 " " gnus-summary-next-page
1747 "n" gnus-summary-next-page
1748 "\177" gnus-summary-prev-page
1749 [delete] gnus-summary-prev-page
1750 "p" gnus-summary-prev-page
1751 "\r" gnus-summary-scroll-up
1752 "\M-\r" gnus-summary-scroll-down
1753 "<" gnus-summary-beginning-of-article
1754 ">" gnus-summary-end-of-article
1755 "b" gnus-summary-beginning-of-article
1756 "e" gnus-summary-end-of-article
1757 "^" gnus-summary-refer-parent-article
1758 "r" gnus-summary-refer-parent-article
1759 "D" gnus-summary-enter-digest-group
1760 "R" gnus-summary-refer-references
1761 "T" gnus-summary-refer-thread
1762 "g" gnus-summary-show-article
1763 "s" gnus-summary-isearch-article
1764 "P" gnus-summary-print-article
1765 "M" gnus-mailing-list-insinuate
1766 "t" gnus-article-babel)
1768 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1769 "b" gnus-article-add-buttons
1770 "B" gnus-article-add-buttons-to-head
1771 "o" gnus-article-treat-overstrike
1772 "e" gnus-article-emphasize
1773 "w" gnus-article-fill-cited-article
1774 "Q" gnus-article-fill-long-lines
1775 "C" gnus-article-capitalize-sentences
1776 "c" gnus-article-remove-cr
1777 "Z" gnus-article-decode-HZ
1778 "h" gnus-article-wash-html
1779 "u" gnus-article-unsplit-urls
1780 "f" gnus-article-display-x-face
1781 "l" gnus-summary-stop-page-breaking
1782 "r" gnus-summary-caesar-message
1783 "m" gnus-summary-morse-message
1784 "t" gnus-summary-toggle-header
1785 "g" gnus-treat-smiley
1786 "v" gnus-summary-verbose-headers
1787 "m" gnus-summary-toggle-mime
1788 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1789 "p" gnus-article-verify-x-pgp-sig
1790 "d" gnus-article-treat-dumbquotes
1791 "k" gnus-article-outlook-deuglify-article)
1793 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1794 "a" gnus-article-hide
1795 "h" gnus-article-hide-headers
1796 "b" gnus-article-hide-boring-headers
1797 "s" gnus-article-hide-signature
1798 "c" gnus-article-hide-citation
1799 "C" gnus-article-hide-citation-in-followups
1800 "l" gnus-article-hide-list-identifiers
1801 "p" gnus-article-hide-pgp
1802 "B" gnus-article-strip-banner
1803 "P" gnus-article-hide-pem
1804 "\C-c" gnus-article-hide-citation-maybe)
1806 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1807 "a" gnus-article-highlight
1808 "h" gnus-article-highlight-headers
1809 "c" gnus-article-highlight-citation
1810 "s" gnus-article-highlight-signature)
1812 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1813 "f" gnus-article-treat-fold-headers
1814 "u" gnus-article-treat-unfold-headers
1815 "n" gnus-article-treat-fold-newsgroups)
1817 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1818 "x" gnus-article-display-x-face
1819 "s" gnus-treat-smiley
1820 "D" gnus-article-remove-images
1821 "f" gnus-treat-from-picon
1822 "m" gnus-treat-mail-picon
1823 "n" gnus-treat-newsgroups-picon)
1825 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1826 "z" gnus-article-date-ut
1827 "u" gnus-article-date-ut
1828 "l" gnus-article-date-local
1829 "p" gnus-article-date-english
1830 "e" gnus-article-date-lapsed
1831 "o" gnus-article-date-original
1832 "i" gnus-article-date-iso8601
1833 "s" gnus-article-date-user)
1835 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1836 "t" gnus-article-remove-trailing-blank-lines
1837 "l" gnus-article-strip-leading-blank-lines
1838 "m" gnus-article-strip-multiple-blank-lines
1839 "a" gnus-article-strip-blank-lines
1840 "A" gnus-article-strip-all-blank-lines
1841 "s" gnus-article-strip-leading-space
1842 "e" gnus-article-strip-trailing-space
1843 "w" gnus-article-remove-leading-whitespace)
1845 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1847 "f" gnus-summary-fetch-faq
1848 "d" gnus-summary-describe-group
1849 "h" gnus-summary-describe-briefly
1850 "i" gnus-info-find-node
1851 "c" gnus-group-fetch-charter
1852 "C" gnus-group-fetch-control)
1854 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1855 "e" gnus-summary-expire-articles
1856 "\M-\C-e" gnus-summary-expire-articles-now
1857 "\177" gnus-summary-delete-article
1858 [delete] gnus-summary-delete-article
1859 [backspace] gnus-summary-delete-article
1860 "m" gnus-summary-move-article
1861 "r" gnus-summary-respool-article
1862 "w" gnus-summary-edit-article
1863 "c" gnus-summary-copy-article
1864 "B" gnus-summary-crosspost-article
1865 "q" gnus-summary-respool-query
1866 "t" gnus-summary-respool-trace
1867 "i" gnus-summary-import-article
1868 "I" gnus-summary-create-article
1869 "p" gnus-summary-article-posted-p)
1871 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1872 "o" gnus-summary-save-article
1873 "m" gnus-summary-save-article-mail
1874 "F" gnus-summary-write-article-file
1875 "r" gnus-summary-save-article-rmail
1876 "f" gnus-summary-save-article-file
1877 "b" gnus-summary-save-article-body-file
1878 "h" gnus-summary-save-article-folder
1879 "v" gnus-summary-save-article-vm
1880 "p" gnus-summary-pipe-output
1881 "P" gnus-summary-muttprint
1882 "s" gnus-soup-add-article)
1884 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1885 "b" gnus-summary-display-buttonized
1886 "m" gnus-summary-repair-multipart
1887 "v" gnus-article-view-part
1888 "o" gnus-article-save-part
1889 "c" gnus-article-copy-part
1890 "C" gnus-article-view-part-as-charset
1891 "e" gnus-article-view-part-externally
1892 "E" gnus-article-encrypt-body
1893 "i" gnus-article-inline-part
1894 "|" gnus-article-pipe-part)
1896 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1897 "p" gnus-summary-mark-as-processable
1898 "u" gnus-summary-unmark-as-processable
1899 "U" gnus-summary-unmark-all-processable
1900 "v" gnus-uu-mark-over
1901 "s" gnus-uu-mark-series
1902 "r" gnus-uu-mark-region
1903 "g" gnus-uu-unmark-region
1904 "R" gnus-uu-mark-by-regexp
1905 "G" gnus-uu-unmark-by-regexp
1906 "t" gnus-uu-mark-thread
1907 "T" gnus-uu-unmark-thread
1908 "a" gnus-uu-mark-all
1909 "b" gnus-uu-mark-buffer
1910 "S" gnus-uu-mark-sparse
1911 "k" gnus-summary-kill-process-mark
1912 "y" gnus-summary-yank-process-mark
1913 "w" gnus-summary-save-process-mark
1914 "i" gnus-uu-invert-processable)
1916 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1917 ;;"x" gnus-uu-extract-any
1918 "m" gnus-summary-save-parts
1919 "u" gnus-uu-decode-uu
1920 "U" gnus-uu-decode-uu-and-save
1921 "s" gnus-uu-decode-unshar
1922 "S" gnus-uu-decode-unshar-and-save
1923 "o" gnus-uu-decode-save
1924 "O" gnus-uu-decode-save
1925 "b" gnus-uu-decode-binhex
1926 "B" gnus-uu-decode-binhex
1927 "p" gnus-uu-decode-postscript
1928 "P" gnus-uu-decode-postscript-and-save)
1931 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1932 "u" gnus-uu-decode-uu-view
1933 "U" gnus-uu-decode-uu-and-save-view
1934 "s" gnus-uu-decode-unshar-view
1935 "S" gnus-uu-decode-unshar-and-save-view
1936 "o" gnus-uu-decode-save-view
1937 "O" gnus-uu-decode-save-view
1938 "b" gnus-uu-decode-binhex-view
1939 "B" gnus-uu-decode-binhex-view
1940 "p" gnus-uu-decode-postscript-view
1941 "P" gnus-uu-decode-postscript-and-save-view))
1943 (defvar gnus-article-post-menu nil)
1945 (defconst gnus-summary-menu-maxlen 20)
1947 (defun gnus-summary-menu-split (menu)
1948 ;; If we have lots of elements, divide them into groups of 20
1949 ;; and make a pane (or submenu) for each one.
1950 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1951 (let ((menu menu) sublists next
1954 ;; Pull off the next gnus-summary-menu-maxlen elements
1955 ;; and make them the next element of sublist.
1956 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1958 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1960 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1961 (aref (car (last menu)) 0)) menu)
1965 (nreverse sublists))
1966 ;; Few elements--put them all in one pane.
1969 (defun gnus-summary-make-menu-bar ()
1970 (gnus-turn-off-edit-menu 'summary)
1972 (unless (boundp 'gnus-summary-misc-menu)
1975 gnus-summary-kill-menu gnus-summary-mode-map ""
1980 ["Customize" gnus-score-customize t])
1981 (gnus-make-score-map 'increase)
1982 (gnus-make-score-map 'lower)
1984 ["Kill below" gnus-summary-kill-below t]
1985 ["Mark above" gnus-summary-mark-above t]
1986 ["Tick above" gnus-summary-tick-above t]
1987 ["Clear above" gnus-summary-clear-above t])
1988 ["Current score" gnus-summary-current-score t]
1989 ["Set score" gnus-summary-set-score t]
1990 ["Switch current score file..." gnus-score-change-score-file t]
1991 ["Set mark below..." gnus-score-set-mark-below t]
1992 ["Set expunge below..." gnus-score-set-expunge-below t]
1993 ["Edit current score file" gnus-score-edit-current-scores t]
1994 ["Edit score file" gnus-score-edit-file t]
1995 ["Trace score" gnus-score-find-trace t]
1996 ["Find words" gnus-score-find-favourite-words t]
1997 ["Rescore buffer" gnus-summary-rescore t]
1998 ["Increase score..." gnus-summary-increase-score t]
1999 ["Lower score..." gnus-summary-lower-score t]))))
2001 ;; Define both the Article menu in the summary buffer and the
2002 ;; equivalent Commands menu in the article buffer here for
2006 ["All" gnus-article-hide t]
2007 ["Headers" gnus-article-hide-headers t]
2008 ["Signature" gnus-article-hide-signature t]
2009 ["Citation" gnus-article-hide-citation t]
2010 ["List identifiers" gnus-article-hide-list-identifiers t]
2011 ["PGP" gnus-article-hide-pgp t]
2012 ["Banner" gnus-article-strip-banner t]
2013 ["Boring headers" gnus-article-hide-boring-headers t])
2015 ["All" gnus-article-highlight t]
2016 ["Headers" gnus-article-highlight-headers t]
2017 ["Signature" gnus-article-highlight-signature t]
2018 ["Citation" gnus-article-highlight-citation t])
2020 ["Local" gnus-article-date-local t]
2021 ["ISO8601" gnus-article-date-iso8601 t]
2022 ["UT" gnus-article-date-ut t]
2023 ["Original" gnus-article-date-original t]
2024 ["Lapsed" gnus-article-date-lapsed t]
2025 ["User-defined" gnus-article-date-user t])
2027 ["Remove images" gnus-article-remove-images t]
2028 ["Toggle smiley" gnus-treat-smiley t]
2029 ["Show X-Face" gnus-article-display-x-face t]
2030 ["Show picons in From" gnus-treat-from-picon t]
2031 ["Show picons in mail headers" gnus-treat-mail-picon t]
2032 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2033 ("View as different encoding"
2034 ,@(gnus-summary-menu-split
2037 ;; Since easymenu under FSF Emacs doesn't allow lambda
2038 ;; forms for menu commands, we should provide intern'ed
2039 ;; function symbols.
2040 (let ((command (intern (format "\
2041 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2045 (let ((gnus-summary-show-article-charset-alist
2047 (gnus-summary-show-article 1))))
2048 `[,(symbol-name cs) ,command t]))
2049 (sort (if (fboundp 'coding-system-list)
2050 (coding-system-list)
2051 ;;(mapcar 'car mm-mime-mule-charset-alist)
2056 ["Leading" gnus-article-strip-leading-blank-lines t]
2057 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2058 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2059 ["All of the above" gnus-article-strip-blank-lines t]
2060 ["All" gnus-article-strip-all-blank-lines t]
2061 ["Leading space" gnus-article-strip-leading-space t]
2062 ["Trailing space" gnus-article-strip-trailing-space t]
2063 ["Leading space in headers"
2064 gnus-article-remove-leading-whitespace t])
2065 ["Overstrike" gnus-article-treat-overstrike t]
2066 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2067 ["Emphasis" gnus-article-emphasize t]
2068 ["Word wrap" gnus-article-fill-cited-article t]
2069 ["Fill long lines" gnus-article-fill-long-lines t]
2070 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2071 ["CR" gnus-article-remove-cr t]
2072 ["Rot 13" gnus-summary-caesar-message
2073 ,@(if (featurep 'xemacs) '(t)
2074 '(:help "\"Caesar rotate\" article by 13"))]
2075 ["Morse decode" gnus-summary-morse-message t]
2076 ["Unix pipe..." gnus-summary-pipe-message t]
2077 ["Add buttons" gnus-article-add-buttons t]
2078 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2079 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2080 ["Toggle MIME" gnus-summary-toggle-mime t]
2081 ["Verbose header" gnus-summary-verbose-headers t]
2082 ["Toggle header" gnus-summary-toggle-header t]
2083 ["Unfold headers" gnus-article-treat-unfold-headers t]
2084 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2085 ["Html" gnus-article-wash-html t]
2086 ["URLs" gnus-article-unsplit-urls t]
2087 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2088 ["HZ" gnus-article-decode-HZ t]
2089 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2092 ["Save in default format" gnus-summary-save-article
2093 ,@(if (featurep 'xemacs) '(t)
2094 '(:help "Save article using default method"))]
2095 ["Save in file" gnus-summary-save-article-file
2096 ,@(if (featurep 'xemacs) '(t)
2097 '(:help "Save article in file"))]
2098 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2099 ["Save in MH folder" gnus-summary-save-article-folder t]
2100 ["Save in VM folder" gnus-summary-save-article-vm t]
2101 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2102 ["Save body in file" gnus-summary-save-article-body-file t]
2103 ["Pipe through a filter" gnus-summary-pipe-output t]
2104 ["Add to SOUP packet" gnus-soup-add-article t]
2105 ["Print with Muttprint" gnus-summary-muttprint t]
2106 ["Print" gnus-summary-print-article t])
2108 ["Respool article..." gnus-summary-respool-article t]
2109 ["Move article..." gnus-summary-move-article
2110 (gnus-check-backend-function
2111 'request-move-article gnus-newsgroup-name)]
2112 ["Copy article..." gnus-summary-copy-article t]
2113 ["Crosspost article..." gnus-summary-crosspost-article
2114 (gnus-check-backend-function
2115 'request-replace-article gnus-newsgroup-name)]
2116 ["Import file..." gnus-summary-import-article t]
2117 ["Create article..." gnus-summary-create-article t]
2118 ["Check if posted" gnus-summary-article-posted-p t]
2119 ["Edit article" gnus-summary-edit-article
2120 (not (gnus-group-read-only-p))]
2121 ["Delete article" gnus-summary-delete-article
2122 (gnus-check-backend-function
2123 'request-expire-articles gnus-newsgroup-name)]
2124 ["Query respool" gnus-summary-respool-query t]
2125 ["Trace respool" gnus-summary-respool-trace t]
2126 ["Delete expirable articles" gnus-summary-expire-articles-now
2127 (gnus-check-backend-function
2128 'request-expire-articles gnus-newsgroup-name)])
2130 ["Uudecode" gnus-uu-decode-uu
2131 ,@(if (featurep 'xemacs) '(t)
2132 '(:help "Decode uuencoded article(s)"))]
2133 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2134 ["Unshar" gnus-uu-decode-unshar t]
2135 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2136 ["Save" gnus-uu-decode-save t]
2137 ["Binhex" gnus-uu-decode-binhex t]
2138 ["Postscript" gnus-uu-decode-postscript t])
2140 ["Enter article" gnus-cache-enter-article t]
2141 ["Remove article" gnus-cache-remove-article t])
2142 ["Translate" gnus-article-babel t]
2143 ["Select article buffer" gnus-summary-select-article-buffer t]
2144 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2145 ["Isearch article..." gnus-summary-isearch-article t]
2146 ["Beginning of the article" gnus-summary-beginning-of-article t]
2147 ["End of the article" gnus-summary-end-of-article t]
2148 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2149 ["Fetch referenced articles" gnus-summary-refer-references t]
2150 ["Fetch current thread" gnus-summary-refer-thread t]
2151 ["Fetch article with id..." gnus-summary-refer-article t]
2152 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2153 ["Redisplay" gnus-summary-show-article t]
2154 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2156 gnus-summary-article-menu gnus-summary-mode-map ""
2157 (cons "Article" innards))
2159 (if (not (keymapp gnus-summary-article-menu))
2161 gnus-article-commands-menu gnus-article-mode-map ""
2162 (cons "Commands" innards))
2163 ;; in Emacs, don't share menu.
2164 (setq gnus-article-commands-menu
2165 (copy-keymap gnus-summary-article-menu))
2166 (define-key gnus-article-mode-map [menu-bar commands]
2167 (cons "Commands" gnus-article-commands-menu))))
2170 gnus-summary-thread-menu gnus-summary-mode-map ""
2172 ["Toggle threading" gnus-summary-toggle-threads t]
2173 ["Hide threads" gnus-summary-hide-all-threads t]
2174 ["Show threads" gnus-summary-show-all-threads t]
2175 ["Hide thread" gnus-summary-hide-thread t]
2176 ["Show thread" gnus-summary-show-thread t]
2177 ["Go to next thread" gnus-summary-next-thread t]
2178 ["Go to previous thread" gnus-summary-prev-thread t]
2179 ["Go down thread" gnus-summary-down-thread t]
2180 ["Go up thread" gnus-summary-up-thread t]
2181 ["Top of thread" gnus-summary-top-thread t]
2182 ["Mark thread as read" gnus-summary-kill-thread t]
2183 ["Lower thread score" gnus-summary-lower-thread t]
2184 ["Raise thread score" gnus-summary-raise-thread t]
2185 ["Rethread current" gnus-summary-rethread-current t]))
2188 gnus-summary-post-menu gnus-summary-mode-map ""
2190 ["Send a message (mail or news)" gnus-summary-post-news
2191 ,@(if (featurep 'xemacs) '(t)
2192 '(:help "Post an article"))]
2193 ["Followup" gnus-summary-followup
2194 ,@(if (featurep 'xemacs) '(t)
2195 '(:help "Post followup to this article"))]
2196 ["Followup and yank" gnus-summary-followup-with-original
2197 ,@(if (featurep 'xemacs) '(t)
2198 '(:help "Post followup to this article, quoting its contents"))]
2199 ["Supersede article" gnus-summary-supersede-article t]
2200 ["Cancel article" gnus-summary-cancel-article
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Cancel an article you posted"))]
2203 ["Reply" gnus-summary-reply t]
2204 ["Reply and yank" gnus-summary-reply-with-original t]
2205 ["Wide reply" gnus-summary-wide-reply t]
2206 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2207 ,@(if (featurep 'xemacs) '(t)
2208 '(:help "Mail a reply, quoting this article"))]
2209 ["Very wide reply" gnus-summary-very-wide-reply t]
2210 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2211 ,@(if (featurep 'xemacs) '(t)
2212 '(:help "Mail a very wide reply, quoting this article"))]
2213 ["Mail forward" gnus-summary-mail-forward t]
2214 ["Post forward" gnus-summary-post-forward t]
2215 ["Digest and mail" gnus-summary-digest-mail-forward t]
2216 ["Digest and post" gnus-summary-digest-post-forward t]
2217 ["Resend message" gnus-summary-resend-message t]
2218 ["Resend message edit" gnus-summary-resend-message-edit t]
2219 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2220 ["Send a mail" gnus-summary-mail-other-window t]
2221 ["Create a local message" gnus-summary-news-other-window t]
2222 ["Uuencode and post" gnus-uu-post-news
2223 ,@(if (featurep 'xemacs) '(t)
2224 '(:help "Post a uuencoded article"))]
2225 ["Followup via news" gnus-summary-followup-to-mail t]
2226 ["Followup via news and yank"
2227 gnus-summary-followup-to-mail-with-original t]
2229 ;;["Send" gnus-summary-send-draft t]
2230 ;;["Send bounced" gnus-resend-bounced-mail t])
2234 ((not (keymapp gnus-summary-post-menu))
2235 (setq gnus-article-post-menu gnus-summary-post-menu))
2236 ((not gnus-article-post-menu)
2237 ;; Don't share post menu.
2238 (setq gnus-article-post-menu
2239 (copy-keymap gnus-summary-post-menu))))
2240 (define-key gnus-article-mode-map [menu-bar post]
2241 (cons "Post" gnus-article-post-menu))
2244 gnus-summary-misc-menu gnus-summary-mode-map ""
2247 ["Mark as read" gnus-summary-mark-as-read-forward t]
2248 ["Mark same subject and select"
2249 gnus-summary-kill-same-subject-and-select t]
2250 ["Mark same subject" gnus-summary-kill-same-subject t]
2251 ["Catchup" gnus-summary-catchup
2252 ,@(if (featurep 'xemacs) '(t)
2253 '(:help "Mark unread articles in this group as read"))]
2254 ["Catchup all" gnus-summary-catchup-all t]
2255 ["Catchup to here" gnus-summary-catchup-to-here t]
2256 ["Catchup from here" gnus-summary-catchup-from-here t]
2257 ["Catchup region" gnus-summary-mark-region-as-read t]
2258 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2260 ["Tick" gnus-summary-tick-article-forward t]
2261 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2262 ["Remove marks" gnus-summary-clear-mark-forward t]
2263 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2264 ["Set bookmark" gnus-summary-set-bookmark t]
2265 ["Remove bookmark" gnus-summary-remove-bookmark t])
2267 ["Marks..." gnus-summary-limit-to-marks t]
2268 ["Subject..." gnus-summary-limit-to-subject t]
2269 ["Author..." gnus-summary-limit-to-author t]
2270 ["Age..." gnus-summary-limit-to-age t]
2271 ["Extra..." gnus-summary-limit-to-extra t]
2272 ["Score..." gnus-summary-limit-to-score t]
2273 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2274 ["Unread" gnus-summary-limit-to-unread t]
2275 ["Unseen" gnus-summary-limit-to-unseen t]
2276 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2277 ["Articles" gnus-summary-limit-to-articles t]
2278 ["Pop limit" gnus-summary-pop-limit t]
2279 ["Show dormant" gnus-summary-limit-include-dormant t]
2280 ["Hide childless dormant"
2281 gnus-summary-limit-exclude-childless-dormant t]
2282 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2283 ["Hide marked" gnus-summary-limit-exclude-marks t]
2284 ["Show expunged" gnus-summary-limit-include-expunged t])
2286 ["Set mark" gnus-summary-mark-as-processable t]
2287 ["Remove mark" gnus-summary-unmark-as-processable t]
2288 ["Remove all marks" gnus-summary-unmark-all-processable t]
2289 ["Mark above" gnus-uu-mark-over t]
2290 ["Mark series" gnus-uu-mark-series t]
2291 ["Mark region" gnus-uu-mark-region t]
2292 ["Unmark region" gnus-uu-unmark-region t]
2293 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2294 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2295 ["Mark all" gnus-uu-mark-all t]
2296 ["Mark buffer" gnus-uu-mark-buffer t]
2297 ["Mark sparse" gnus-uu-mark-sparse t]
2298 ["Mark thread" gnus-uu-mark-thread t]
2299 ["Unmark thread" gnus-uu-unmark-thread t]
2300 ("Process Mark Sets"
2301 ["Kill" gnus-summary-kill-process-mark t]
2302 ["Yank" gnus-summary-yank-process-mark
2303 gnus-newsgroup-process-stack]
2304 ["Save" gnus-summary-save-process-mark t]))
2306 ["Page forward" gnus-summary-next-page
2307 ,@(if (featurep 'xemacs) '(t)
2308 '(:help "Show next page of article"))]
2309 ["Page backward" gnus-summary-prev-page
2310 ,@(if (featurep 'xemacs) '(t)
2311 '(:help "Show previous page of article"))]
2312 ["Line forward" gnus-summary-scroll-up t])
2314 ["Next unread article" gnus-summary-next-unread-article t]
2315 ["Previous unread article" gnus-summary-prev-unread-article t]
2316 ["Next article" gnus-summary-next-article t]
2317 ["Previous article" gnus-summary-prev-article t]
2318 ["Next unread subject" gnus-summary-next-unread-subject t]
2319 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2320 ["Next article same subject" gnus-summary-next-same-subject t]
2321 ["Previous article same subject" gnus-summary-prev-same-subject t]
2322 ["First unread article" gnus-summary-first-unread-article t]
2323 ["Best unread article" gnus-summary-best-unread-article t]
2324 ["Go to subject number..." gnus-summary-goto-subject t]
2325 ["Go to article number..." gnus-summary-goto-article t]
2326 ["Go to the last article" gnus-summary-goto-last-article t]
2327 ["Pop article off history" gnus-summary-pop-article t])
2329 ["Sort by number" gnus-summary-sort-by-number t]
2330 ["Sort by author" gnus-summary-sort-by-author t]
2331 ["Sort by subject" gnus-summary-sort-by-subject t]
2332 ["Sort by date" gnus-summary-sort-by-date t]
2333 ["Sort by score" gnus-summary-sort-by-score t]
2334 ["Sort by lines" gnus-summary-sort-by-lines t]
2335 ["Sort by characters" gnus-summary-sort-by-chars t]
2336 ["Randomize" gnus-summary-sort-by-random t]
2337 ["Original sort" gnus-summary-sort-by-original t])
2339 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2340 ["Describe group" gnus-summary-describe-group t]
2341 ["Fetch charter" gnus-group-fetch-charter
2342 ,@(if (featurep 'xemacs) nil
2343 '(:help "Display the charter of the current group"))]
2344 ["Fetch control message" gnus-group-fetch-control
2345 ,@(if (featurep 'xemacs) nil
2346 '(:help "Display the archived control message for the current group"))]
2347 ["Read manual" gnus-info-find-node t])
2349 ["Pick and read" gnus-pick-mode t]
2350 ["Binary" gnus-binary-mode t])
2352 ["Regenerate" gnus-summary-prepare t]
2353 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2354 ["Toggle threading" gnus-summary-toggle-threads t])
2355 ["See old articles" gnus-summary-insert-old-articles t]
2356 ["See new articles" gnus-summary-insert-new-articles t]
2357 ["Filter articles..." gnus-summary-execute-command t]
2358 ["Run command on subjects..." gnus-summary-universal-argument t]
2359 ["Search articles forward..." gnus-summary-search-article-forward t]
2360 ["Search articles backward..." gnus-summary-search-article-backward t]
2361 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2362 ["Expand window" gnus-summary-expand-window t]
2363 ["Expire expirable articles" gnus-summary-expire-articles
2364 (gnus-check-backend-function
2365 'request-expire-articles gnus-newsgroup-name)]
2366 ["Edit local kill file" gnus-summary-edit-local-kill t]
2367 ["Edit main kill file" gnus-summary-edit-global-kill t]
2368 ["Edit group parameters" gnus-summary-edit-parameters t]
2369 ["Customize group parameters" gnus-summary-customize-parameters t]
2370 ["Send a bug report" gnus-bug t]
2372 ["Catchup and exit" gnus-summary-catchup-and-exit
2373 ,@(if (featurep 'xemacs) '(t)
2374 '(:help "Mark unread articles in this group as read, then exit"))]
2375 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2376 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2377 ["Exit group" gnus-summary-exit
2378 ,@(if (featurep 'xemacs) '(t)
2379 '(:help "Exit current group, return to group selection mode"))]
2380 ["Exit group without updating" gnus-summary-exit-no-update t]
2381 ["Exit and goto next group" gnus-summary-next-group t]
2382 ["Exit and goto prev group" gnus-summary-prev-group t]
2383 ["Reselect group" gnus-summary-reselect-current-group t]
2384 ["Rescan group" gnus-summary-rescan-group t]
2385 ["Update dribble" gnus-summary-save-newsrc t])))
2387 (gnus-run-hooks 'gnus-summary-menu-hook)))
2389 (defvar gnus-summary-tool-bar-map nil)
2391 ;; Emacs 21 tool bar. Should be no-op otherwise.
2392 (defun gnus-summary-make-tool-bar ()
2393 (if (and (fboundp 'tool-bar-add-item-from-menu)
2394 (default-value 'tool-bar-mode)
2395 (not gnus-summary-tool-bar-map))
2396 (setq gnus-summary-tool-bar-map
2397 (let ((tool-bar-map (make-sparse-keymap))
2398 (load-path (mm-image-load-path)))
2399 (tool-bar-add-item-from-menu
2400 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2401 (tool-bar-add-item-from-menu
2402 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2403 (tool-bar-add-item-from-menu
2404 'gnus-summary-post-news "post" gnus-summary-mode-map)
2405 (tool-bar-add-item-from-menu
2406 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2407 (tool-bar-add-item-from-menu
2408 'gnus-summary-followup "followup" gnus-summary-mode-map)
2409 (tool-bar-add-item-from-menu
2410 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2411 (tool-bar-add-item-from-menu
2412 'gnus-summary-reply "reply" gnus-summary-mode-map)
2413 (tool-bar-add-item-from-menu
2414 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2415 (tool-bar-add-item-from-menu
2416 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2417 (tool-bar-add-item-from-menu
2418 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2419 (tool-bar-add-item-from-menu
2420 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2421 (tool-bar-add-item-from-menu
2422 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2423 (tool-bar-add-item-from-menu
2424 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2425 (tool-bar-add-item-from-menu
2426 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2427 (tool-bar-add-item-from-menu
2428 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2430 (if gnus-summary-tool-bar-map
2431 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2433 (defun gnus-score-set-default (var value)
2434 "A version of set that updates the GNU Emacs menu-bar."
2436 ;; It is the message that forces the active status to be updated.
2439 (defun gnus-make-score-map (type)
2440 "Make a summary score map of type TYPE."
2443 (let ((headers '(("author" "from" string)
2444 ("subject" "subject" string)
2445 ("article body" "body" string)
2446 ("article head" "head" string)
2447 ("xref" "xref" string)
2448 ("extra header" "extra" string)
2449 ("lines" "lines" number)
2450 ("followups to author" "followup" string)))
2451 (types '((number ("less than" <)
2454 (string ("substring" s)
2458 (perms '(("temporary" (current-time-string))
2466 (if (eq type 'lower)
2471 (setq header (car headers))
2477 (let ((ts (cdr (assoc (nth 2 header) types)))
2493 'gnus-summary-score-entry
2495 (if (or (string= (nth 1 header)
2497 (string= (nth 1 header)
2500 (list 'gnus-summary-header
2502 (list 'quote (nth 1 (car ts)))
2503 (list 'gnus-score-delta-default
2510 (list (nreverse outp))))
2513 (list (nreverse outt))))
2515 (setq headers (cdr headers)))
2516 (list (nreverse outh))))))))
2520 (defun gnus-summary-mode (&optional group)
2521 "Major mode for reading articles.
2523 All normal editing commands are switched off.
2524 \\<gnus-summary-mode-map>
2525 Each line in this buffer represents one article. To read an
2526 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2527 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2530 You can also post articles and send mail from this buffer. To
2531 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2532 of an article, type `\\[gnus-summary-reply]'.
2534 There are approx. one gazillion commands you can execute in this
2535 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2537 The following commands are available:
2539 \\{gnus-summary-mode-map}"
2541 (kill-all-local-variables)
2542 (when (gnus-visual-p 'summary-menu 'menu)
2543 (gnus-summary-make-menu-bar)
2544 (gnus-summary-make-tool-bar))
2545 (gnus-summary-make-local-variables)
2546 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2547 (gnus-summary-make-local-variables))
2548 (gnus-make-thread-indent-array)
2549 (gnus-simplify-mode-line)
2550 (setq major-mode 'gnus-summary-mode)
2551 (setq mode-name "Summary")
2552 (make-local-variable 'minor-mode-alist)
2553 (use-local-map gnus-summary-mode-map)
2554 (buffer-disable-undo)
2555 (setq buffer-read-only t) ;Disable modification
2556 (setq truncate-lines t)
2557 (setq selective-display t)
2558 (setq selective-display-ellipses t) ;Display `...'
2559 (gnus-summary-set-display-table)
2560 (gnus-set-default-directory)
2561 (setq gnus-newsgroup-name group)
2562 (unless (gnus-news-group-p group)
2563 (setq gnus-newsgroup-incorporated
2564 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2565 (make-local-variable 'gnus-summary-line-format)
2566 (make-local-variable 'gnus-summary-line-format-spec)
2567 (make-local-variable 'gnus-summary-dummy-line-format)
2568 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2569 (make-local-variable 'gnus-summary-mark-positions)
2570 (make-local-hook 'pre-command-hook)
2571 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2572 (gnus-run-hooks 'gnus-summary-mode-hook)
2573 (turn-on-gnus-mailing-list-mode)
2574 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2575 (gnus-update-summary-mark-positions))
2577 (defun gnus-summary-make-local-variables ()
2578 "Make all the local summary buffer variables."
2580 (dolist (local gnus-summary-local-variables)
2583 (if (eq (cdr local) 'global)
2584 ;; Copy the global value of the variable.
2585 (setq global (symbol-value (car local)))
2586 ;; Use the value from the list.
2587 (setq global (eval (cdr local))))
2588 (set (make-local-variable (car local)) global))
2589 ;; Simple nil-valued local variable.
2590 (set (make-local-variable local) nil)))))
2592 (defun gnus-summary-clear-local-variables ()
2593 (let ((locals gnus-summary-local-variables))
2595 (if (consp (car locals))
2596 (and (vectorp (caar locals))
2597 (set (caar locals) nil))
2598 (and (vectorp (car locals))
2599 (set (car locals) nil)))
2600 (setq locals (cdr locals)))))
2602 ;; Summary data functions.
2604 (defmacro gnus-data-number (data)
2607 (defmacro gnus-data-set-number (data number)
2608 `(setcar ,data ,number))
2610 (defmacro gnus-data-mark (data)
2613 (defmacro gnus-data-set-mark (data mark)
2614 `(setcar (nthcdr 1 ,data) ,mark))
2616 (defmacro gnus-data-pos (data)
2619 (defmacro gnus-data-set-pos (data pos)
2620 `(setcar (nthcdr 2 ,data) ,pos))
2622 (defmacro gnus-data-header (data)
2625 (defmacro gnus-data-set-header (data header)
2626 `(setcar (nthcdr 3 ,data) ,header))
2628 (defmacro gnus-data-level (data)
2631 (defmacro gnus-data-unread-p (data)
2632 `(= (nth 1 ,data) gnus-unread-mark))
2634 (defmacro gnus-data-read-p (data)
2635 `(/= (nth 1 ,data) gnus-unread-mark))
2637 (defmacro gnus-data-pseudo-p (data)
2638 `(consp (nth 3 ,data)))
2640 (defmacro gnus-data-find (number)
2641 `(assq ,number gnus-newsgroup-data))
2643 (defmacro gnus-data-find-list (number &optional data)
2644 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2645 (memq (assq ,number bdata)
2648 (defmacro gnus-data-make (number mark pos header level)
2649 `(list ,number ,mark ,pos ,header ,level))
2651 (defun gnus-data-enter (after-article number mark pos header level offset)
2652 (let ((data (gnus-data-find-list after-article)))
2654 (error "No such article: %d" after-article))
2655 (setcdr data (cons (gnus-data-make number mark pos header level)
2657 (setq gnus-newsgroup-data-reverse nil)
2658 (gnus-data-update-list (cddr data) offset)))
2660 (defun gnus-data-enter-list (after-article list &optional offset)
2662 (let ((data (and after-article (gnus-data-find-list after-article)))
2666 (let ((odata gnus-newsgroup-data))
2667 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2669 (gnus-data-update-list odata offset)))
2670 ;; Find the last element in the list to be spliced into the main
2673 (setq list (cdr list)))
2676 (setcdr list gnus-newsgroup-data)
2677 (setq gnus-newsgroup-data ilist)
2679 (gnus-data-update-list (cdr list) offset)))
2680 (setcdr list (cdr data))
2683 (gnus-data-update-list (cdr list) offset))))
2684 (setq gnus-newsgroup-data-reverse nil))))
2686 (defun gnus-data-remove (article &optional offset)
2687 (let ((data gnus-newsgroup-data))
2688 (if (= (gnus-data-number (car data)) article)
2690 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2691 gnus-newsgroup-data-reverse nil)
2693 (gnus-data-update-list gnus-newsgroup-data offset)))
2695 (when (= (gnus-data-number (cadr data)) article)
2696 (setcdr data (cddr data))
2698 (gnus-data-update-list (cdr data) offset))
2700 gnus-newsgroup-data-reverse nil))
2701 (setq data (cdr data))))))
2703 (defmacro gnus-data-list (backward)
2705 (or gnus-newsgroup-data-reverse
2706 (setq gnus-newsgroup-data-reverse
2707 (reverse gnus-newsgroup-data)))
2708 gnus-newsgroup-data))
2710 (defun gnus-data-update-list (data offset)
2711 "Add OFFSET to the POS of all data entries in DATA."
2712 (setq gnus-newsgroup-data-reverse nil)
2714 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2715 (setq data (cdr data))))
2717 (defun gnus-summary-article-pseudo-p (article)
2718 "Say whether this article is a pseudo article or not."
2719 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2721 (defmacro gnus-summary-article-sparse-p (article)
2722 "Say whether this article is a sparse article or not."
2723 `(memq ,article gnus-newsgroup-sparse))
2725 (defmacro gnus-summary-article-ancient-p (article)
2726 "Say whether this article is a sparse article or not."
2727 `(memq ,article gnus-newsgroup-ancient))
2729 (defun gnus-article-parent-p (number)
2730 "Say whether this article is a parent or not."
2731 (let ((data (gnus-data-find-list number)))
2732 (and (cdr data) ; There has to be an article after...
2733 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2734 (gnus-data-level (nth 1 data))))))
2736 (defun gnus-article-children (number)
2737 "Return a list of all children to NUMBER."
2738 (let* ((data (gnus-data-find-list number))
2739 (level (gnus-data-level (car data)))
2741 (setq data (cdr data))
2743 (= (gnus-data-level (car data)) (1+ level)))
2744 (push (gnus-data-number (car data)) children)
2745 (setq data (cdr data)))
2748 (defmacro gnus-summary-skip-intangible ()
2749 "If the current article is intangible, then jump to a different article."
2750 '(let ((to (get-text-property (point) 'gnus-intangible)))
2751 (and to (gnus-summary-goto-subject to))))
2753 (defmacro gnus-summary-article-intangible-p ()
2754 "Say whether this article is intangible or not."
2755 '(get-text-property (point) 'gnus-intangible))
2757 (defun gnus-article-read-p (article)
2758 "Say whether ARTICLE is read or not."
2759 (not (or (memq article gnus-newsgroup-marked)
2760 (memq article gnus-newsgroup-spam-marked)
2761 (memq article gnus-newsgroup-unreads)
2762 (memq article gnus-newsgroup-unselected)
2763 (memq article gnus-newsgroup-dormant))))
2765 ;; Some summary mode macros.
2767 (defmacro gnus-summary-article-number ()
2768 "The article number of the article on the current line.
2769 If there isn's an article number here, then we return the current
2772 (gnus-summary-skip-intangible)
2773 (or (get-text-property (point) 'gnus-number)
2774 (gnus-summary-last-subject))))
2776 (defmacro gnus-summary-article-header (&optional number)
2777 "Return the header of article NUMBER."
2778 `(gnus-data-header (gnus-data-find
2779 ,(or number '(gnus-summary-article-number)))))
2781 (defmacro gnus-summary-thread-level (&optional number)
2782 "Return the level of thread that starts with article NUMBER."
2783 `(if (and (eq gnus-summary-make-false-root 'dummy)
2784 (get-text-property (point) 'gnus-intangible))
2786 (gnus-data-level (gnus-data-find
2787 ,(or number '(gnus-summary-article-number))))))
2789 (defmacro gnus-summary-article-mark (&optional number)
2790 "Return the mark of article NUMBER."
2791 `(gnus-data-mark (gnus-data-find
2792 ,(or number '(gnus-summary-article-number)))))
2794 (defmacro gnus-summary-article-pos (&optional number)
2795 "Return the position of the line of article NUMBER."
2796 `(gnus-data-pos (gnus-data-find
2797 ,(or number '(gnus-summary-article-number)))))
2799 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2800 (defmacro gnus-summary-article-subject (&optional number)
2801 "Return current subject string or nil if nothing."
2804 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2805 '(gnus-data-header (assq (gnus-summary-article-number)
2806 gnus-newsgroup-data)))))
2809 (mail-header-subject headers))))
2811 (defmacro gnus-summary-article-score (&optional number)
2812 "Return current article score."
2813 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2814 gnus-newsgroup-scored))
2815 gnus-summary-default-score 0))
2817 (defun gnus-summary-article-children (&optional number)
2818 "Return a list of article numbers that are children of article NUMBER."
2819 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2820 (level (gnus-data-level (car data)))
2822 (while (and (setq data (cdr data))
2823 (> (setq l (gnus-data-level (car data))) level))
2824 (and (= (1+ level) l)
2825 (push (gnus-data-number (car data))
2827 (nreverse children)))
2829 (defun gnus-summary-article-parent (&optional number)
2830 "Return the article number of the parent of article NUMBER."
2831 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2832 (gnus-data-list t)))
2833 (level (gnus-data-level (car data))))
2835 () ; This is a root.
2836 ;; We search until we find an article with a level less than
2837 ;; this one. That function has to be the parent.
2838 (while (and (setq data (cdr data))
2839 (not (< (gnus-data-level (car data)) level))))
2840 (and data (gnus-data-number (car data))))))
2842 (defun gnus-unread-mark-p (mark)
2843 "Say whether MARK is the unread mark."
2844 (= mark gnus-unread-mark))
2846 (defun gnus-read-mark-p (mark)
2847 "Say whether MARK is one of the marks that mark as read.
2848 This is all marks except unread, ticked, dormant, and expirable."
2849 (not (or (= mark gnus-unread-mark)
2850 (= mark gnus-ticked-mark)
2851 (= mark gnus-dormant-mark)
2852 (= mark gnus-expirable-mark))))
2854 (defmacro gnus-article-mark (number)
2855 "Return the MARK of article NUMBER.
2856 This macro should only be used when computing the mark the \"first\"
2857 time; i.e., when generating the summary lines. After that,
2858 `gnus-summary-article-mark' should be used to examine the
2861 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2862 ;;;; ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2863 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2864 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2865 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2866 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2867 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2868 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2869 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2870 gnus-ancient-mark))))
2872 ;; Saving hidden threads.
2874 (defmacro gnus-save-hidden-threads (&rest forms)
2875 "Save hidden threads, eval FORMS, and restore the hidden threads."
2876 (let ((config (make-symbol "config")))
2877 `(let ((,config (gnus-hidden-threads-configuration)))
2881 (gnus-restore-hidden-threads-configuration ,config)))))
2882 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2883 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2885 (defun gnus-data-compute-positions ()
2886 "Compute the positions of all articles."
2887 (setq gnus-newsgroup-data-reverse nil)
2888 (let ((data gnus-newsgroup-data))
2890 (gnus-save-hidden-threads
2891 (gnus-summary-show-all-threads)
2892 (goto-char (point-min))
2894 (while (get-text-property (point) 'gnus-intangible)
2896 (gnus-data-set-pos (car data) (+ (point) 3))
2897 (setq data (cdr data))
2898 (forward-line 1))))))
2900 (defun gnus-hidden-threads-configuration ()
2901 "Return the current hidden threads configuration."
2904 (goto-char (point-min))
2905 (while (search-forward "\r" nil t)
2906 (push (1- (point)) config))
2909 (defun gnus-restore-hidden-threads-configuration (config)
2910 "Restore hidden threads configuration from CONFIG."
2912 (let (point buffer-read-only)
2913 (while (setq point (pop config))
2914 (when (and (< point (point-max))
2916 (eq (char-after) ?\n))
2917 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2919 ;; Various summary mode internalish functions.
2921 (defun gnus-mouse-pick-article (e)
2924 (gnus-summary-next-page nil t))
2926 (defun gnus-summary-set-display-table ()
2927 "Change the display table.
2928 Odd characters have a tendency to mess
2929 up nicely formatted displays - we make all possible glyphs
2930 display only a single character."
2932 ;; We start from the standard display table, if any.
2933 (let ((table (or (copy-sequence standard-display-table)
2934 (make-display-table)))
2936 ;; Nix out all the control chars...
2937 (while (>= (setq i (1- i)) 0)
2938 (aset table i [??]))
2939 ;; ... but not newline and cr, of course. (cr is necessary for the
2940 ;; selective display).
2941 (aset table ?\n nil)
2942 (aset table ?\r nil)
2943 ;; We keep TAB as well.
2944 (aset table ?\t nil)
2945 ;; We nix out any glyphs over 126 that are not set already.
2947 (while (>= (setq i (1- i)) 127)
2948 ;; Only modify if the entry is nil.
2949 (unless (aref table i)
2950 (aset table i [??]))))
2951 (setq buffer-display-table table)))
2953 (defun gnus-summary-set-article-display-arrow (pos)
2954 "Update the overlay arrow to point to line at position POS."
2955 (when (and gnus-summary-display-arrow
2956 (boundp 'overlay-arrow-position)
2957 (boundp 'overlay-arrow-string))
2961 (unless overlay-arrow-position
2962 (setq overlay-arrow-position (make-marker)))
2963 (setq overlay-arrow-string "=>"
2964 overlay-arrow-position (set-marker overlay-arrow-position
2966 (current-buffer))))))
2968 (defun gnus-summary-buffer-name (group)
2969 "Return the summary buffer name of GROUP."
2970 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2972 (defun gnus-summary-setup-buffer (group)
2973 "Initialize summary buffer."
2974 (let ((buffer (gnus-summary-buffer-name group))
2975 (dead-name (concat "*Dead Summary "
2976 (gnus-group-decoded-name group) "*")))
2977 ;; If a dead summary buffer exists, we kill it.
2978 (when (gnus-buffer-live-p dead-name)
2979 (gnus-kill-buffer dead-name))
2980 (if (get-buffer buffer)
2983 (setq gnus-summary-buffer (current-buffer))
2984 (not gnus-newsgroup-prepared))
2985 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2986 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2987 (gnus-summary-mode group)
2989 (gnus-carpal-setup-buffer 'summary))
2990 (unless gnus-single-article-buffer
2991 (make-local-variable 'gnus-article-buffer)
2992 (make-local-variable 'gnus-article-current)
2993 (make-local-variable 'gnus-original-article-buffer))
2994 (setq gnus-newsgroup-name group)
2995 ;; Set any local variables in the group parameters.
2996 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2999 (defun gnus-set-global-variables ()
3000 "Set the global equivalents of the buffer-local variables.
3001 They are set to the latest values they had. These reflect the summary
3002 buffer that was in action when the last article was fetched."
3003 (when (eq major-mode 'gnus-summary-mode)
3004 (setq gnus-summary-buffer (current-buffer))
3005 (let ((name gnus-newsgroup-name)
3006 (marked gnus-newsgroup-marked)
3007 (spam gnus-newsgroup-spam-marked)
3008 (unread gnus-newsgroup-unreads)
3009 (headers gnus-current-headers)
3010 (data gnus-newsgroup-data)
3011 (summary gnus-summary-buffer)
3012 (article-buffer gnus-article-buffer)
3013 (original gnus-original-article-buffer)
3014 (gac gnus-article-current)
3015 (reffed gnus-reffed-article-number)
3016 (score-file gnus-current-score-file)
3017 (default-charset gnus-newsgroup-charset)
3019 (let ((locals gnus-newsgroup-variables))
3021 (if (consp (car locals))
3022 (push (eval (caar locals)) vlist)
3023 (push (eval (car locals)) vlist))
3024 (setq locals (cdr locals)))
3025 (setq vlist (nreverse vlist)))
3027 (set-buffer gnus-group-buffer)
3028 (setq gnus-newsgroup-name name
3029 gnus-newsgroup-marked marked
3030 gnus-newsgroup-spam-marked spam
3031 gnus-newsgroup-unreads unread
3032 gnus-current-headers headers
3033 gnus-newsgroup-data data
3034 gnus-article-current gac
3035 gnus-summary-buffer summary
3036 gnus-article-buffer article-buffer
3037 gnus-original-article-buffer original
3038 gnus-reffed-article-number reffed
3039 gnus-current-score-file score-file
3040 gnus-newsgroup-charset default-charset)
3041 (let ((locals gnus-newsgroup-variables))
3043 (if (consp (car locals))
3044 (set (caar locals) (pop vlist))
3045 (set (car locals) (pop vlist)))
3046 (setq locals (cdr locals))))
3047 ;; The article buffer also has local variables.
3048 (when (gnus-buffer-live-p gnus-article-buffer)
3049 (set-buffer gnus-article-buffer)
3050 (setq gnus-summary-buffer summary))))))
3052 (defun gnus-summary-article-unread-p (article)
3053 "Say whether ARTICLE is unread or not."
3054 (memq article gnus-newsgroup-unreads))
3056 (defun gnus-summary-first-article-p (&optional article)
3057 "Return whether ARTICLE is the first article in the buffer."
3058 (if (not (setq article (or article (gnus-summary-article-number))))
3060 (eq article (caar gnus-newsgroup-data))))
3062 (defun gnus-summary-last-article-p (&optional article)
3063 "Return whether ARTICLE is the last article in the buffer."
3064 (if (not (setq article (or article (gnus-summary-article-number))))
3065 ;; All non-existent numbers are the last article. :-)
3067 (not (cdr (gnus-data-find-list article)))))
3069 (defun gnus-make-thread-indent-array ()
3071 (unless (and gnus-thread-indent-array
3072 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3073 (setq gnus-thread-indent-array (make-vector 201 "")
3074 gnus-thread-indent-array-level gnus-thread-indent-level)
3076 (aset gnus-thread-indent-array n
3077 (make-string (* n gnus-thread-indent-level) ? ))
3080 (defun gnus-update-summary-mark-positions ()
3081 "Compute where the summary marks are to go."
3083 (when (gnus-buffer-exists-p gnus-summary-buffer)
3084 (set-buffer gnus-summary-buffer))
3085 (let ((gnus-replied-mark 129)
3086 (gnus-score-below-mark 130)
3087 (gnus-score-over-mark 130)
3088 (gnus-download-mark 131)
3089 (spec gnus-summary-line-format-spec)
3092 (gnus-set-work-buffer)
3093 (let ((gnus-summary-line-format-spec spec)
3094 (gnus-newsgroup-downloadable '((0 . t))))
3095 (gnus-summary-insert-line
3096 (make-full-mail-header 0 "" "nobody"
3097 "05 Apr 2001 23:33:09 +0400"
3099 0 nil 128 t nil "" nil 1)
3100 (goto-char (point-min))
3101 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3102 (- (point) (point-min) 1)))))
3103 (goto-char (point-min))
3104 (push (cons 'replied (and (search-forward "\201" nil t)
3105 (- (point) (point-min) 1)))
3107 (goto-char (point-min))
3108 (push (cons 'score (and (search-forward "\202" nil t)
3109 (- (point) (point-min) 1)))
3111 (goto-char (point-min))
3112 (push (cons 'download
3113 (and (search-forward "\203" nil t)
3114 (- (point) (point-min) 1)))
3116 (setq gnus-summary-mark-positions pos))))
3118 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3119 "Insert a dummy root in the summary buffer."
3121 (gnus-add-text-properties
3122 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3123 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3125 (defun gnus-summary-extract-address-component (from)
3126 (or (car (funcall gnus-extract-address-components from))
3129 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3130 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3131 default-mime-charset)))
3132 ;; Is it really necessary to do this next part for each summary line?
3133 ;; Luckily, doesn't seem to slow things down much.
3135 (and gnus-ignored-from-addresses
3136 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3137 (let ((extra-headers (mail-header-extra header))
3141 ((setq to (cdr (assq 'To extra-headers)))
3144 (gnus-summary-extract-address-component
3145 (funcall gnus-decode-encoded-word-function to)))))
3146 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3147 (concat "=> " newsgroups)))))
3148 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3150 (defun gnus-summary-insert-line (gnus-tmp-header
3151 gnus-tmp-level gnus-tmp-current
3152 gnus-tmp-unread gnus-tmp-replied
3153 gnus-tmp-expirable gnus-tmp-subject-or-nil
3154 &optional gnus-tmp-dummy gnus-tmp-score
3156 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3157 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3158 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3159 (gnus-tmp-score-char
3160 (if (or (null gnus-summary-default-score)
3161 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3162 gnus-summary-zcore-fuzz))
3164 (if (< gnus-tmp-score gnus-summary-default-score)
3165 gnus-score-below-mark gnus-score-over-mark)))
3166 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3168 (cond (gnus-tmp-process gnus-process-mark)
3169 ((memq gnus-tmp-current gnus-newsgroup-cached)
3171 (gnus-tmp-replied gnus-replied-mark)
3172 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3173 gnus-forwarded-mark)
3174 ((memq gnus-tmp-current gnus-newsgroup-saved)
3176 ((memq gnus-tmp-number gnus-newsgroup-recent)
3178 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3181 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3184 ((string-match "<[^>]+> *$" gnus-tmp-from)
3185 (let ((beg (match-beginning 0)))
3186 (or (and (string-match "^\".+\"" gnus-tmp-from)
3187 (substring gnus-tmp-from 1 (1- (match-end 0))))
3188 (substring gnus-tmp-from 0 beg))))
3189 ((string-match "(.+)" gnus-tmp-from)
3190 (substring gnus-tmp-from
3191 (1+ (match-beginning 0)) (1- (match-end 0))))
3193 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3194 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3195 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3196 (buffer-read-only nil))
3197 (when (string= gnus-tmp-name "")
3198 (setq gnus-tmp-name gnus-tmp-from))
3199 (unless (numberp gnus-tmp-lines)
3200 (setq gnus-tmp-lines -1))
3201 (if (= gnus-tmp-lines -1)
3202 (setq gnus-tmp-lines "?")
3203 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3204 (gnus-put-text-property-excluding-characters-with-faces
3206 (progn (eval gnus-summary-line-format-spec) (point))
3207 'gnus-number gnus-tmp-number)
3208 (when (gnus-visual-p 'summary-highlight 'highlight)
3210 (gnus-run-hooks 'gnus-summary-update-hook)
3213 (defun gnus-summary-update-line (&optional dont-update)
3214 "Update summary line after change."
3215 (when (and gnus-summary-default-score
3216 (not gnus-summary-inhibit-highlight))
3217 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3218 (article (gnus-summary-article-number))
3219 (score (gnus-summary-article-score article)))
3221 (if (and gnus-summary-mark-below
3222 (< (gnus-summary-article-score)
3223 gnus-summary-mark-below))
3224 ;; This article has a low score, so we mark it as read.
3225 (when (memq article gnus-newsgroup-unreads)
3226 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3227 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3228 ;; This article was previously marked as read on account
3229 ;; of a low score, but now it has risen, so we mark it as
3231 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3232 (gnus-summary-update-mark
3233 (if (or (null gnus-summary-default-score)
3234 (<= (abs (- score gnus-summary-default-score))
3235 gnus-summary-zcore-fuzz))
3237 (if (< score gnus-summary-default-score)
3238 gnus-score-below-mark gnus-score-over-mark))
3240 ;; Do visual highlighting.
3241 (when (gnus-visual-p 'summary-highlight 'highlight)
3242 (gnus-run-hooks 'gnus-summary-update-hook)))))
3244 (defvar gnus-tmp-new-adopts nil)
3246 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3247 "Return the number of articles in THREAD.
3248 This may be 0 in some cases -- if none of the articles in
3249 the thread are to be displayed."
3251 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3253 ((not (listp thread))
3255 ((and (consp thread) (cdr thread))
3258 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3261 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3264 (when (and level (zerop level) gnus-tmp-new-adopts)
3267 'gnus-summary-number-of-articles-in-thread
3268 gnus-tmp-new-adopts))))
3270 (if (> number 1) gnus-not-empty-thread-mark
3271 gnus-empty-thread-mark)
3274 (defsubst gnus-summary-line-message-size (head)
3275 "Return pretty-printed version of message size.
3276 This function is intended to be used in
3277 `gnus-summary-line-format-alist', which see."
3278 (let ((c (or (mail-header-chars head) -1)))
3279 (cond ((< c 0) "n/a") ; chars not available
3280 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3281 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3282 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3283 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3286 (defun gnus-summary-set-local-parameters (group)
3287 "Go through the local params of GROUP and set all variable specs in that list."
3288 (let ((params (gnus-group-find-parameter group))
3289 (vars '(quit-config)) ; Ignore quit-config.
3292 (setq elem (car params)
3293 params (cdr params))
3294 (and (consp elem) ; Has to be a cons.
3295 (consp (cdr elem)) ; The cdr has to be a list.
3296 (symbolp (car elem)) ; Has to be a symbol in there.
3297 (not (memq (car elem) vars))
3298 (ignore-errors ; So we set it.
3299 (push (car elem) vars)
3300 (make-local-variable (car elem))
3301 (set (car elem) (eval (nth 1 elem))))))))
3303 (defun gnus-summary-read-group (group &optional show-all no-article
3304 kill-buffer no-display backward
3306 "Start reading news in newsgroup GROUP.
3307 If SHOW-ALL is non-nil, already read articles are also listed.
3308 If NO-ARTICLE is non-nil, no article is selected initially.
3309 If NO-DISPLAY, don't generate a summary buffer."
3313 (let ((gnus-auto-select-next nil))
3314 (or (gnus-summary-read-group-1
3315 group show-all no-article
3316 kill-buffer no-display
3319 select-articles nil)))))
3320 (eq gnus-auto-select-next 'quietly))
3321 (set-buffer gnus-group-buffer)
3322 ;; The entry function called above goes to the next
3323 ;; group automatically, so we go two groups back
3324 ;; if we are searching for the previous group.
3326 (gnus-group-prev-unread-group 2))
3327 (if (not (equal group (gnus-group-group-name)))
3328 (setq group (gnus-group-group-name))
3332 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3333 "Directly jump to the other GROUP from summary buffer.
3334 If SHOW-ALL is non-nil, already read articles are also listed."
3336 (if (eq gnus-summary-buffer (current-buffer))
3337 (list (completing-read
3338 "Group: " gnus-active-hashtb nil t
3339 (when (and gnus-newsgroup-name
3340 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3341 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3342 'gnus-group-history)
3344 (error "%s must be invoked from a gnus summary buffer." this-command)))
3345 (unless (or (zerop (length group))
3346 (and gnus-newsgroup-name
3347 (string-equal gnus-newsgroup-name group)))
3349 (gnus-summary-read-group group show-all
3350 gnus-dont-select-after-jump-to-other-group)))
3352 (defun gnus-summary-read-group-1 (group show-all no-article
3353 kill-buffer no-display
3354 &optional select-articles)
3355 ;; Killed foreign groups can't be entered.
3356 ;; (when (and (not (gnus-group-native-p group))
3357 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3358 ;; (error "Dead non-native groups can't be entered"))
3359 (gnus-message 5 "Retrieving newsgroup: %s..."
3360 (gnus-group-decoded-name group))
3361 (let* ((new-group (gnus-summary-setup-buffer group))
3362 (quit-config (gnus-group-quit-config group))
3363 (did-select (and new-group (gnus-select-newsgroup
3364 group show-all select-articles))))
3366 ;; This summary buffer exists already, so we just select it.
3368 (gnus-set-global-variables)
3370 (gnus-kill-or-deaden-summary kill-buffer))
3371 (gnus-configure-windows 'summary 'force)
3372 (gnus-set-mode-line 'summary)
3373 (gnus-summary-position-point)
3376 ;; We couldn't select this group.
3378 (when (and (eq major-mode 'gnus-summary-mode)
3379 (not (equal (current-buffer) kill-buffer)))
3380 (kill-buffer (current-buffer))
3381 (if (not quit-config)
3383 ;; Update the info -- marks might need to be removed,
3385 (gnus-summary-update-info)
3386 (set-buffer gnus-group-buffer)
3387 (gnus-group-jump-to-group group)
3388 (gnus-group-next-unread-group 1))
3389 (gnus-handle-ephemeral-exit quit-config)))
3390 (let ((grpinfo (gnus-get-info group)))
3391 (if (null (gnus-info-read grpinfo))
3392 (gnus-message 3 "Group %s contains no messages"
3393 (gnus-group-decoded-name group))
3394 (gnus-message 3 "Can't select group")))
3396 ;; The user did a `C-g' while prompting for number of articles,
3397 ;; so we exit this group.
3398 ((eq did-select 'quit)
3399 (and (eq major-mode 'gnus-summary-mode)
3400 (not (equal (current-buffer) kill-buffer))
3401 (kill-buffer (current-buffer)))
3403 (gnus-kill-or-deaden-summary kill-buffer))
3404 (if (not quit-config)
3406 (set-buffer gnus-group-buffer)
3407 (gnus-group-jump-to-group group)
3408 (gnus-group-next-unread-group 1)
3409 (gnus-configure-windows 'group 'force))
3410 (gnus-handle-ephemeral-exit quit-config))
3411 ;; Finally signal the quit.
3413 ;; The group was successfully selected.
3415 (gnus-set-global-variables)
3416 ;; Save the active value in effect when the group was entered.
3417 (setq gnus-newsgroup-active
3419 (gnus-active gnus-newsgroup-name)))
3420 ;; You can change the summary buffer in some way with this hook.
3421 (gnus-run-hooks 'gnus-select-group-hook)
3422 (gnus-update-format-specifications
3423 nil 'summary 'summary-mode 'summary-dummy)
3424 (gnus-update-summary-mark-positions)
3425 ;; Do score processing.
3426 (when gnus-use-scoring
3427 (gnus-possibly-score-headers))
3428 ;; Check whether to fill in the gaps in the threads.
3429 (when gnus-build-sparse-threads
3430 (gnus-build-sparse-threads))
3431 ;; Find the initial limit.
3432 (if gnus-show-threads
3434 (let ((gnus-newsgroup-dormant nil))
3435 (gnus-summary-initial-limit show-all))
3436 (gnus-summary-initial-limit show-all))
3437 ;; When untreaded, all articles are always shown.
3438 (setq gnus-newsgroup-limit
3440 (lambda (header) (mail-header-number header))
3441 gnus-newsgroup-headers)))
3442 ;; Generate the summary buffer.
3444 (gnus-summary-prepare))
3445 (when gnus-use-trees
3446 (gnus-tree-open group)
3447 (setq gnus-summary-highlight-line-function
3448 'gnus-tree-highlight-article))
3449 ;; If the summary buffer is empty, but there are some low-scored
3450 ;; articles or some excluded dormants, we include these in the
3452 (when (and (zerop (buffer-size))
3454 (cond (gnus-newsgroup-dormant
3455 (gnus-summary-limit-include-dormant))
3456 ((and gnus-newsgroup-scored show-all)
3457 (gnus-summary-limit-include-expunged t))))
3458 ;; Function `gnus-apply-kill-file' must be called in this hook.
3459 (gnus-run-hooks 'gnus-apply-kill-hook)
3460 (if (and (zerop (buffer-size))
3463 ;; This newsgroup is empty.
3464 (gnus-summary-catchup-and-exit nil t)
3465 (gnus-message 6 "No unread news")
3467 (gnus-kill-or-deaden-summary kill-buffer))
3468 ;; Return nil from this function.
3470 ;; Hide conversation thread subtrees. We cannot do this in
3471 ;; gnus-summary-prepare-hook since kill processing may not
3472 ;; work with hidden articles.
3473 (gnus-summary-maybe-hide-threads)
3475 (gnus-kill-or-deaden-summary kill-buffer))
3476 (gnus-summary-auto-select-subject)
3477 ;; Show first unread article if requested.
3478 (if (and (not no-article)
3480 gnus-newsgroup-unreads
3481 gnus-auto-select-first)
3483 (gnus-configure-windows 'summary)
3484 (let ((art (gnus-summary-article-number)))
3485 (unless (or (memq art gnus-newsgroup-undownloaded)
3486 (memq art gnus-newsgroup-downloadable))
3487 (gnus-summary-goto-article art))))
3488 ;; Don't select any articles.
3489 (gnus-summary-position-point)
3490 (gnus-configure-windows 'summary 'force)
3491 (gnus-set-mode-line 'summary))
3492 (when (get-buffer-window gnus-group-buffer t)
3493 ;; Gotta use windows, because recenter does weird stuff if
3494 ;; the current buffer ain't the displayed window.
3495 (let ((owin (selected-window)))
3496 (select-window (get-buffer-window gnus-group-buffer t))
3497 (when (gnus-group-goto-group group)
3499 (select-window owin)))
3500 ;; Mark this buffer as "prepared".
3501 (setq gnus-newsgroup-prepared t)
3502 (gnus-run-hooks 'gnus-summary-prepared-hook)
3505 (defun gnus-summary-auto-select-subject ()
3506 "Select the subject line on initial group entry."
3507 (goto-char (point-min))
3509 ((eq gnus-auto-select-subject 'best)
3510 (gnus-summary-best-unread-subject))
3511 ((eq gnus-auto-select-subject 'unread)
3512 (gnus-summary-first-unread-subject))
3513 ((eq gnus-auto-select-subject 'unseen)
3514 (gnus-summary-first-unseen-subject))
3515 ((eq gnus-auto-select-subject 'unseen-or-unread)
3516 (gnus-summary-first-unseen-or-unread-subject))
3517 ((eq gnus-auto-select-subject 'first)
3520 ((gnus-functionp gnus-auto-select-subject)
3521 (funcall gnus-auto-select-subject))))
3523 (defun gnus-summary-prepare ()
3524 "Generate the summary buffer."
3526 (let ((buffer-read-only nil))
3528 (setq gnus-newsgroup-data nil
3529 gnus-newsgroup-data-reverse nil)
3530 (gnus-run-hooks 'gnus-summary-generate-hook)
3531 ;; Generate the buffer, either with threads or without.
3532 (when gnus-newsgroup-headers
3533 (gnus-summary-prepare-threads
3534 (if gnus-show-threads
3535 (gnus-sort-gathered-threads
3536 (funcall gnus-summary-thread-gathering-function
3538 (gnus-cut-threads (gnus-make-threads)))))
3539 ;; Unthreaded display.
3540 (gnus-sort-articles gnus-newsgroup-headers))))
3541 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3542 ;; Call hooks for modifying summary buffer.
3543 (goto-char (point-min))
3544 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3546 (defsubst gnus-general-simplify-subject (subject)
3547 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3550 ;; Truncate the subject.
3551 (gnus-simplify-subject-functions
3552 (gnus-map-function gnus-simplify-subject-functions subject))
3553 ((numberp gnus-summary-gather-subject-limit)
3554 (setq subject (gnus-simplify-subject-re subject))
3555 (if (> (length subject) gnus-summary-gather-subject-limit)
3556 (substring subject 0 gnus-summary-gather-subject-limit)
3558 ;; Fuzzily simplify it.
3559 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3560 (gnus-simplify-subject-fuzzy subject))
3561 ;; Just remove the leading "Re:".
3563 (gnus-simplify-subject-re subject))))
3565 (if (and gnus-summary-gather-exclude-subject
3566 (string-match gnus-summary-gather-exclude-subject subject))
3567 nil ; This article shouldn't be gathered
3570 (defun gnus-summary-simplify-subject-query ()
3571 "Query where the respool algorithm would put this article."
3573 (gnus-summary-select-article)
3575 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3577 (defun gnus-gather-threads-by-subject (threads)
3578 "Gather threads by looking at Subject headers."
3579 (if (not gnus-summary-make-false-root)
3581 (let ((hashtb (gnus-make-hashtable 1024))
3584 subject hthread whole-subject)
3586 (setq subject (gnus-general-simplify-subject
3587 (setq whole-subject (mail-header-subject
3590 (if (setq hthread (gnus-gethash subject hashtb))
3592 ;; We enter a dummy root into the thread, if we
3593 ;; haven't done that already.
3594 (unless (stringp (caar hthread))
3595 (setcar hthread (list whole-subject (car hthread))))
3596 ;; We add this new gathered thread to this gathered
3598 (setcdr (car hthread)
3599 (nconc (cdar hthread) (list (car threads))))
3600 ;; Remove it from the list of threads.
3601 (setcdr prev (cdr threads))
3602 (setq threads prev))
3603 ;; Enter this thread into the hash table.
3604 (gnus-sethash subject threads hashtb)))
3606 (setq threads (cdr threads)))
3609 (defun gnus-gather-threads-by-references (threads)
3610 "Gather threads by looking at References headers."
3611 (let ((idhashtb (gnus-make-hashtable 1024))
3612 (thhashtb (gnus-make-hashtable 1024))
3615 ids references id gthread gid entered ref)
3617 (when (setq references (mail-header-references (caar threads)))
3618 (setq id (mail-header-id (caar threads))
3619 ids (inline (gnus-split-references references))
3621 (while (setq ref (pop ids))
3622 (setq ids (delete ref ids))
3623 (if (not (setq gid (gnus-gethash ref idhashtb)))
3625 (gnus-sethash ref id idhashtb)
3626 (gnus-sethash id threads thhashtb))
3627 (setq gthread (gnus-gethash gid thhashtb))
3629 ;; We enter a dummy root into the thread, if we
3630 ;; haven't done that already.
3631 (unless (stringp (caar gthread))
3632 (setcar gthread (list (mail-header-subject (caar gthread))
3634 ;; We add this new gathered thread to this gathered
3636 (setcdr (car gthread)
3637 (nconc (cdar gthread) (list (car threads)))))
3638 ;; Add it into the thread hash table.
3639 (gnus-sethash id gthread thhashtb)
3641 ;; Remove it from the list of threads.
3642 (setcdr prev (cdr threads))
3643 (setq threads prev))))
3645 (setq threads (cdr threads)))
3648 (defun gnus-sort-gathered-threads (threads)
3649 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3650 (let ((result threads))
3652 (when (stringp (caar threads))
3653 (setcdr (car threads)
3654 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3655 (setq threads (cdr threads)))
3658 (defun gnus-thread-loop-p (root thread)
3659 "Say whether ROOT is in THREAD."
3660 (let ((stack (list thread))
3663 (while (setq thread (pop stack))
3664 (setq th (cdr thread))
3666 (not (eq (caar th) root)))
3669 ;; We have found a loop.
3671 (setcdr thread (delq (car th) (cdr thread)))
3672 (if (boundp (setq ref-dep (intern "none"
3673 gnus-newsgroup-dependencies)))
3674 (setcdr (symbol-value ref-dep)
3675 (nconc (cdr (symbol-value ref-dep))
3677 (set ref-dep (list nil (car th))))
3680 ;; Push all the subthreads onto the stack.
3681 (push (cdr thread) stack)))
3684 (defun gnus-make-threads ()
3685 "Go through the dependency hashtb and find the roots. Return all threads."
3687 (while (catch 'infloop
3690 ;; Deal with self-referencing References loops.
3691 (when (and (car (symbol-value refs))
3698 (car (symbol-value refs)) thread))
3699 (cdr (symbol-value refs)))))))
3702 (unless (car (symbol-value refs))
3703 ;; These threads do not refer back to any other articles,
3704 ;; so they're roots.
3705 (setq threads (append (cdr (symbol-value refs)) threads))))
3706 gnus-newsgroup-dependencies)))
3709 ;; Build the thread tree.
3710 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3711 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3713 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3714 if it was already present.
3716 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3717 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3718 Message-IDs will be renamed to a unique Message-ID before being
3721 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3722 (let* ((id (mail-header-id header))
3723 (id-dep (and id (intern id dependencies)))
3724 parent-id ref ref-dep ref-header replaced)
3725 ;; Enter this `header' in the `dependencies' table.
3729 ;; The first two cases do the normal part: enter a new `header'
3730 ;; in the `dependencies' table.
3731 ((not (boundp id-dep))
3732 (set id-dep (list header)))
3733 ((null (car (symbol-value id-dep)))
3734 (setcar (symbol-value id-dep) header))
3736 ;; From here the `header' was already present in the
3737 ;; `dependencies' table.
3739 ;; Overrides an existing entry;
3740 ;; just set the header part of the entry.
3741 (setcar (symbol-value id-dep) header)
3744 ;; Renames the existing `header' to a unique Message-ID.
3745 ((not gnus-summary-ignore-duplicates)
3746 ;; An article with this Message-ID has already been seen.
3747 ;; We rename the Message-ID.
3748 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3750 (mail-header-set-id header id))
3752 ;; The last case ignores an existing entry, except it adds any
3753 ;; additional Xrefs (in case the two articles came from different
3755 ;; Also sets `header' to `nil' meaning that the `dependencies'
3756 ;; table was *not* modified.
3758 (mail-header-set-xref
3759 (car (symbol-value id-dep))
3760 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3762 (or (mail-header-xref header) "")))
3765 (when (and header (not replaced))
3766 ;; First check that we are not creating a References loop.
3767 (setq parent-id (gnus-parent-id (mail-header-references header)))
3768 (setq ref parent-id)
3770 (setq ref-dep (intern-soft ref dependencies))
3772 (setq ref-header (car (symbol-value ref-dep))))
3773 (if (string= id ref)
3774 ;; Yuk! This is a reference loop. Make the article be a
3777 (mail-header-set-references (car (symbol-value id-dep)) "none")
3779 (setq parent-id nil))
3780 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3781 (setq ref-dep (intern (or parent-id "none") dependencies))
3782 (if (boundp ref-dep)
3783 (setcdr (symbol-value ref-dep)
3784 (nconc (cdr (symbol-value ref-dep))
3785 (list (symbol-value id-dep))))
3786 (set ref-dep (list nil (symbol-value id-dep)))))
3789 (defun gnus-extract-message-id-from-in-reply-to (string)
3790 (if (string-match "<[^>]+>" string)
3791 (substring string (match-beginning 0) (match-end 0))
3794 (defun gnus-build-sparse-threads ()
3795 (let ((headers gnus-newsgroup-headers)
3796 (mail-parse-charset gnus-newsgroup-charset)
3797 (gnus-summary-ignore-duplicates t)
3798 header references generation relations
3799 subject child end new-child date)
3800 ;; First we create an alist of generations/relations, where
3801 ;; generations is how much we trust the relation, and the relation
3803 (gnus-message 7 "Making sparse threads...")
3805 (nnheader-set-temp-buffer " *gnus sparse threads*")
3806 (while (setq header (pop headers))
3807 (when (and (setq references (mail-header-references header))
3808 (not (string= references "")))
3810 (setq child (mail-header-id header)
3811 subject (mail-header-subject header)
3812 date (mail-header-date header)
3814 (while (search-backward ">" nil t)
3815 (setq end (1+ (point)))
3816 (when (search-backward "<" nil t)
3817 (setq new-child (buffer-substring (point) end))
3818 (push (list (incf generation)
3819 child (setq child new-child)
3823 (push (list (1+ generation) child nil subject) relations))
3825 (kill-buffer (current-buffer)))
3826 ;; Sort over trustworthiness.
3829 (when (gnus-dependencies-add-header
3830 (make-full-mail-header-from-decoded-header
3831 gnus-reffed-article-number
3832 (nth 3 relation) "" (or (nth 4 relation) "")
3834 (or (nth 2 relation) "") 0 0 "")
3835 gnus-newsgroup-dependencies nil)
3836 (push gnus-reffed-article-number gnus-newsgroup-limit)
3837 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3838 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3839 gnus-newsgroup-reads)
3840 (decf gnus-reffed-article-number)))
3841 (sort relations 'car-less-than-car))
3842 (gnus-message 7 "Making sparse threads...done")))
3844 (defun gnus-build-old-threads ()
3845 ;; Look at all the articles that refer back to old articles, and
3846 ;; fetch the headers for the articles that aren't there. This will
3847 ;; build complete threads - if the roots haven't been expired by the
3849 (let ((mail-parse-charset gnus-newsgroup-charset)
3853 (when (not (car (symbol-value refs)))
3854 (setq heads (cdr (symbol-value refs)))
3856 (if (memq (mail-header-number (caar heads))
3857 gnus-newsgroup-dormant)
3858 (setq heads (cdr heads))
3859 (setq id (symbol-name refs))
3860 (while (and (setq id (gnus-build-get-header id))
3861 (not (car (gnus-id-to-thread id)))))
3862 (setq heads nil)))))
3863 gnus-newsgroup-dependencies)))
3865 ;; This function has to be called with point after the article number
3866 ;; on the beginning of the line.
3867 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3868 (let ((eol (gnus-point-at-eol))
3869 (buffer (current-buffer))
3870 header references in-reply-to)
3872 ;; overview: [num subject from date id refs chars lines misc]
3875 (narrow-to-region (point) eol)
3880 (make-full-mail-header
3882 (nnheader-nov-field) ; subject
3883 (nnheader-nov-field) ; from
3884 (nnheader-nov-field) ; date
3885 (nnheader-nov-read-message-id) ; id
3886 (nnheader-nov-field) ; refs
3887 (nnheader-nov-read-integer) ; chars
3888 (nnheader-nov-read-integer) ; lines
3890 (if (looking-at "Xref: ")
3891 (goto-char (match-end 0)))
3892 (nnheader-nov-field)) ; Xref
3893 (nnheader-nov-parse-extra)))) ; extra
3897 (when (and (string= references "")
3898 (setq in-reply-to (mail-header-extra header))
3899 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3900 (mail-header-set-references
3901 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3903 (when gnus-alter-header-function
3904 (funcall gnus-alter-header-function header))
3905 (gnus-dependencies-add-header header dependencies force-new)))
3907 (defun gnus-build-get-header (id)
3908 "Look through the buffer of NOV lines and find the header to ID.
3909 Enter this line into the dependencies hash table, and return
3910 the id of the parent article (if any)."
3911 (let ((deps gnus-newsgroup-dependencies)
3915 (set-buffer nntp-server-buffer)
3916 (let ((case-fold-search nil))
3917 (goto-char (point-min))
3918 (while (and (not found)
3919 (search-forward id nil t))
3921 (setq found (looking-at
3922 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3923 (regexp-quote id))))
3924 (or found (beginning-of-line 2)))
3928 (setq header (gnus-nov-parse-line
3929 (read (current-buffer)) deps))
3930 (gnus-parent-id (mail-header-references header))))))
3932 (let ((number (mail-header-number header)))
3933 (push number gnus-newsgroup-limit)
3934 (push header gnus-newsgroup-headers)
3935 (if (memq number gnus-newsgroup-unselected)
3937 (setq gnus-newsgroup-unreads
3938 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3940 (setq gnus-newsgroup-unselected
3941 (delq number gnus-newsgroup-unselected)))
3942 (push number gnus-newsgroup-ancient)))))))
3944 (defun gnus-build-all-threads ()
3945 "Read all the headers."
3946 (let ((gnus-summary-ignore-duplicates t)
3947 (mail-parse-charset gnus-newsgroup-charset)
3948 (dependencies gnus-newsgroup-dependencies)
3951 (set-buffer nntp-server-buffer)
3952 (let ((case-fold-search nil))
3953 (goto-char (point-min))
3956 (setq article (read (current-buffer))
3957 header (gnus-nov-parse-line article dependencies)))
3960 (set-buffer gnus-summary-buffer)
3961 (push header gnus-newsgroup-headers)
3962 (if (memq (setq article (mail-header-number header))
3963 gnus-newsgroup-unselected)
3965 (setq gnus-newsgroup-unreads
3966 (gnus-add-to-sorted-list
3967 gnus-newsgroup-unreads article))
3968 (setq gnus-newsgroup-unselected
3969 (delq article gnus-newsgroup-unselected)))
3970 (push article gnus-newsgroup-ancient)))
3971 (forward-line 1)))))))
3973 (defun gnus-summary-update-article-line (article header)
3974 "Update the line for ARTICLE using HEADERS."
3975 (let* ((id (mail-header-id header))
3976 (thread (gnus-id-to-thread id)))
3978 (error "Article in no thread"))
3979 ;; Update the thread.
3980 (setcar thread header)
3981 (gnus-summary-goto-subject article)
3982 (let* ((datal (gnus-data-find-list article))
3984 (length (when (cdr datal)
3985 (- (gnus-data-pos data)
3986 (gnus-data-pos (cadr datal)))))
3987 (buffer-read-only nil)
3988 (level (gnus-summary-thread-level)))
3990 (gnus-summary-insert-line
3991 header level nil (gnus-article-mark article)
3992 (memq article gnus-newsgroup-replied)
3993 (memq article gnus-newsgroup-expirable)
3994 ;; Only insert the Subject string when it's different
3995 ;; from the previous Subject string.
4000 (mail-header-subject
4003 (gnus-data-find-list
4005 (gnus-data-list t)))))
4006 ;; Error on the side of excessive subjects.
4008 (mail-header-subject header)))
4010 (mail-header-subject header))
4011 nil (cdr (assq article gnus-newsgroup-scored))
4012 (memq article gnus-newsgroup-processable))
4014 (gnus-data-update-list
4015 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4017 (defun gnus-summary-update-article (article &optional iheader)
4018 "Update ARTICLE in the summary buffer."
4019 (set-buffer gnus-summary-buffer)
4020 (let* ((header (gnus-summary-article-header article))
4021 (id (mail-header-id header))
4022 (data (gnus-data-find article))
4023 (thread (gnus-id-to-thread id))
4024 (references (mail-header-references header))
4028 (when (and references
4029 (not (equal "" references)))
4032 (buffer-read-only nil)
4038 (delq thread parent)))
4039 (if (gnus-summary-insert-subject id header)
4040 ;; Set the (possibly) new article number in the data structure.
4041 (gnus-data-set-number data (gnus-id-to-article id))
4045 (defun gnus-rebuild-thread (id &optional line)
4046 "Rebuild the thread containing ID.
4047 If LINE, insert the rebuilt thread starting on line LINE."
4048 (let ((buffer-read-only nil)
4049 old-pos current thread data)
4050 (if (not gnus-show-threads)
4051 (setq thread (list (car (gnus-id-to-thread id))))
4052 ;; Get the thread this article is part of.
4053 (setq thread (gnus-remove-thread id)))
4054 (setq old-pos (gnus-point-at-bol))
4055 (setq current (save-excursion
4056 (and (re-search-backward "[\r\n]" nil t)
4057 (gnus-summary-article-number))))
4058 ;; If this is a gathered thread, we have to go some re-gathering.
4059 (when (stringp (car thread))
4060 (let ((subject (car thread))
4062 (setq thread (cdr thread))
4064 (unless (memq (setq thr (gnus-id-to-thread
4066 (mail-header-id (caar thread)))))
4069 (setq thread (cdr thread)))
4070 ;; We now have all (unique) roots.
4071 (if (= (length roots) 1)
4072 ;; All the loose roots are now one solid root.
4073 (setq thread (car roots))
4074 (setq thread (cons subject (gnus-sort-threads roots))))))
4076 ;; We then insert this thread into the summary buffer.
4078 (goto-char (point-min))
4079 (forward-line (1- line)))
4080 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4081 (if gnus-show-threads
4082 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4083 (gnus-summary-prepare-unthreaded thread))
4084 (setq data (nreverse gnus-newsgroup-data))
4085 (setq threads gnus-newsgroup-threads))
4086 ;; We splice the new data into the data structure.
4087 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4088 ;;!!! then we want to insert at the beginning of the buffer.
4089 ;;!!! That happens to be true with Gnus now, but that may
4090 ;;!!! change in the future. Perhaps.
4091 (gnus-data-enter-list
4092 (if line nil current) data (- (point) old-pos))
4093 (setq gnus-newsgroup-threads
4094 (nconc threads gnus-newsgroup-threads))
4095 (gnus-data-compute-positions))))
4097 (defun gnus-number-to-header (number)
4098 "Return the header for article NUMBER."
4099 (let ((headers gnus-newsgroup-headers))
4101 (not (= number (mail-header-number (car headers)))))
4106 (defun gnus-parent-headers (in-headers &optional generation)
4107 "Return the headers of the GENERATIONeth parent of HEADERS."
4109 (setq generation 1))
4111 (headers in-headers)
4114 (not (zerop generation))
4115 (setq references (mail-header-references headers)))
4116 (setq headers (if (and references
4117 (setq parent (gnus-parent-id references)))
4118 (car (gnus-id-to-thread parent))
4121 (and (not (eq headers in-headers))
4124 (defun gnus-id-to-thread (id)
4125 "Return the (sub-)thread where ID appears."
4126 (gnus-gethash id gnus-newsgroup-dependencies))
4128 (defun gnus-id-to-article (id)
4129 "Return the article number of ID."
4130 (let ((thread (gnus-id-to-thread id)))
4133 (mail-header-number (car thread)))))
4135 (defun gnus-id-to-header (id)
4136 "Return the article headers of ID."
4137 (car (gnus-id-to-thread id)))
4139 (defun gnus-article-displayed-root-p (article)
4140 "Say whether ARTICLE is a root(ish) article."
4141 (let ((level (gnus-summary-thread-level article))
4142 (refs (mail-header-references (gnus-summary-article-header article)))
4148 ((null (gnus-parent-id refs)) t)
4150 (null (setq particle (gnus-id-to-article
4151 (gnus-parent-id refs))))
4152 (null (gnus-summary-thread-level particle)))))))
4154 (defun gnus-root-id (id)
4155 "Return the id of the root of the thread where ID appears."
4157 (while (and id (setq prev (car (gnus-id-to-thread id))))
4159 id (gnus-parent-id (mail-header-references prev))))
4162 (defun gnus-articles-in-thread (thread)
4163 "Return the list of articles in THREAD."
4164 (cons (mail-header-number (car thread))
4165 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4167 (defun gnus-remove-thread (id &optional dont-remove)
4168 "Remove the thread that has ID in it."
4169 (let (headers thread last-id)
4170 ;; First go up in this thread until we find the root.
4171 (setq last-id (gnus-root-id id)
4172 headers (message-flatten-list (gnus-id-to-thread last-id)))
4173 ;; We have now found the real root of this thread. It might have
4174 ;; been gathered into some loose thread, so we have to search
4175 ;; through the threads to find the thread we wanted.
4176 (let ((threads gnus-newsgroup-threads)
4179 (setq sub (car threads))
4180 (if (stringp (car sub))
4181 ;; This is a gathered thread, so we look at the roots
4182 ;; below it to find whether this article is in this
4185 (setq sub (cdr sub))
4187 (when (member (caar sub) headers)
4188 (setq thread (car threads)
4191 (setq sub (cdr sub))))
4192 ;; It's an ordinary thread, so we check it.
4193 (when (eq (car sub) (car headers))
4196 (setq threads (cdr threads)))
4197 ;; If this article is in no thread, then it's a root.
4200 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4201 (setq thread (gnus-id-to-thread last-id)))
4204 thread ; We return this thread.
4206 (if (stringp (car thread))
4208 ;; If we use dummy roots, then we have to remove the
4209 ;; dummy root as well.
4210 (when (eq gnus-summary-make-false-root 'dummy)
4211 ;; We go to the dummy root by going to
4212 ;; the first sub-"thread", and then one line up.
4213 (gnus-summary-goto-article
4214 (mail-header-number (caadr thread)))
4217 (gnus-data-compute-positions))
4218 (setq thread (cdr thread))
4220 (gnus-remove-thread-1 (car thread))
4221 (setq thread (cdr thread))))
4222 (gnus-remove-thread-1 thread))))))))
4224 (defun gnus-remove-thread-1 (thread)
4225 "Remove the thread THREAD recursively."
4226 (let ((number (mail-header-number (pop thread)))
4228 (setq thread (reverse thread))
4230 (gnus-remove-thread-1 (pop thread)))
4231 (when (setq d (gnus-data-find number))
4232 (goto-char (gnus-data-pos d))
4233 (gnus-summary-show-thread)
4236 (- (gnus-point-at-bol)
4238 (1+ (gnus-point-at-eol))
4239 (gnus-delete-line)))))))
4241 (defun gnus-sort-threads-1 (threads func)
4242 (sort (mapcar (lambda (thread)
4245 (gnus-sort-threads-1 (cdr thread) func))))
4248 (defun gnus-sort-threads (threads)
4250 (if (not gnus-thread-sort-functions)
4252 (gnus-message 8 "Sorting threads...")
4254 (gnus-sort-threads-1
4256 (gnus-make-sort-function gnus-thread-sort-functions))
4257 (gnus-message 8 "Sorting threads...done"))))
4259 (defun gnus-sort-articles (articles)
4261 (when gnus-article-sort-functions
4262 (gnus-message 7 "Sorting articles...")
4264 (setq gnus-newsgroup-headers
4265 (sort articles (gnus-make-sort-function
4266 gnus-article-sort-functions)))
4267 (gnus-message 7 "Sorting articles...done"))))
4269 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4270 (defmacro gnus-thread-header (thread)
4271 "Return header of first article in THREAD.
4272 Note that THREAD must never, ever be anything else than a variable -
4273 using some other form will lead to serious barfage."
4274 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4275 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4276 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4279 (defsubst gnus-article-sort-by-number (h1 h2)
4280 "Sort articles by article number."
4281 (< (mail-header-number h1)
4282 (mail-header-number h2)))
4284 (defun gnus-thread-sort-by-number (h1 h2)
4285 "Sort threads by root article number."
4286 (gnus-article-sort-by-number
4287 (gnus-thread-header h1) (gnus-thread-header h2)))
4289 (defsubst gnus-article-sort-by-random (h1 h2)
4290 "Sort articles by article number."
4293 (defun gnus-thread-sort-by-random (h1 h2)
4294 "Sort threads by root article number."
4295 (gnus-article-sort-by-random
4296 (gnus-thread-header h1) (gnus-thread-header h2)))
4298 (defsubst gnus-article-sort-by-lines (h1 h2)
4299 "Sort articles by article Lines header."
4300 (< (mail-header-lines h1)
4301 (mail-header-lines h2)))
4303 (defun gnus-thread-sort-by-lines (h1 h2)
4304 "Sort threads by root article Lines header."
4305 (gnus-article-sort-by-lines
4306 (gnus-thread-header h1) (gnus-thread-header h2)))
4308 (defsubst gnus-article-sort-by-chars (h1 h2)
4309 "Sort articles by octet length."
4310 (< (mail-header-chars h1)
4311 (mail-header-chars h2)))
4313 (defun gnus-thread-sort-by-chars (h1 h2)
4314 "Sort threads by root article octet length."
4315 (gnus-article-sort-by-chars
4316 (gnus-thread-header h1) (gnus-thread-header h2)))
4318 (defsubst gnus-article-sort-by-author (h1 h2)
4319 "Sort articles by root author."
4321 (let ((addr (car (mime-entity-read-field h1 'From))))
4322 (or (std11-full-name-string addr)
4323 (std11-address-string addr)
4325 (let ((addr (car (mime-entity-read-field h2 'From))))
4326 (or (std11-full-name-string addr)
4327 (std11-address-string addr)
4331 (defun gnus-thread-sort-by-author (h1 h2)
4332 "Sort threads by root author."
4333 (gnus-article-sort-by-author
4334 (gnus-thread-header h1) (gnus-thread-header h2)))
4336 (defsubst gnus-article-sort-by-subject (h1 h2)
4337 "Sort articles by root subject."
4339 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4340 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4342 (defun gnus-thread-sort-by-subject (h1 h2)
4343 "Sort threads by root subject."
4344 (gnus-article-sort-by-subject
4345 (gnus-thread-header h1) (gnus-thread-header h2)))
4347 (defsubst gnus-article-sort-by-date (h1 h2)
4348 "Sort articles by root article date."
4350 (gnus-date-get-time (mail-header-date h1))
4351 (gnus-date-get-time (mail-header-date h2))))
4353 (defun gnus-thread-sort-by-date (h1 h2)
4354 "Sort threads by root article date."
4355 (gnus-article-sort-by-date
4356 (gnus-thread-header h1) (gnus-thread-header h2)))
4358 (defsubst gnus-article-sort-by-score (h1 h2)
4359 "Sort articles by root article score.
4360 Unscored articles will be counted as having a score of zero."
4361 (> (or (cdr (assq (mail-header-number h1)
4362 gnus-newsgroup-scored))
4363 gnus-summary-default-score 0)
4364 (or (cdr (assq (mail-header-number h2)
4365 gnus-newsgroup-scored))
4366 gnus-summary-default-score 0)))
4368 (defun gnus-thread-sort-by-score (h1 h2)
4369 "Sort threads by root article score."
4370 (gnus-article-sort-by-score
4371 (gnus-thread-header h1) (gnus-thread-header h2)))
4373 (defun gnus-thread-sort-by-total-score (h1 h2)
4374 "Sort threads by the sum of all scores in the thread.
4375 Unscored articles will be counted as having a score of zero."
4376 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4378 (defun gnus-thread-total-score (thread)
4379 ;; This function find the total score of THREAD.
4384 (if (stringp (car thread))
4385 (apply gnus-thread-score-function 0
4386 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4387 (gnus-thread-total-score-1 thread)))
4389 (gnus-thread-total-score-1 (list thread)))))
4391 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4392 "Sort threads such that the thread with the most recently arrived article comes first."
4393 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4395 (defun gnus-thread-highest-number (thread)
4396 "Return the highest article number in THREAD."
4397 (apply 'max (mapcar (lambda (header)
4398 (mail-header-number header))
4399 (message-flatten-list thread))))
4401 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4402 "Sort threads such that the thread with the most recently dated article comes first."
4403 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4405 (defun gnus-thread-latest-date (thread)
4406 "Return the highest article date in THREAD."
4407 (let ((previous-time 0))
4412 (mail-header-parse-date
4414 (mail-header-date header)
4415 (error previous-time))))))
4417 (message-flatten-list thread)
4419 (< (mail-header-number h1)
4420 (mail-header-number h2))))))))
4422 (defun gnus-thread-total-score-1 (root)
4423 ;; This function find the total score of the thread below ROOT.
4424 (setq root (car root))
4425 (apply gnus-thread-score-function
4427 (mapcar 'gnus-thread-total-score
4428 (cdr (gnus-id-to-thread (mail-header-id root))))
4429 (when (> (mail-header-number root) 0)
4430 (list (or (cdr (assq (mail-header-number root)
4431 gnus-newsgroup-scored))
4432 gnus-summary-default-score 0))))
4433 (list gnus-summary-default-score)
4436 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4437 (defvar gnus-tmp-prev-subject nil)
4438 (defvar gnus-tmp-false-parent nil)
4439 (defvar gnus-tmp-root-expunged nil)
4440 (defvar gnus-tmp-dummy-line nil)
4442 (eval-when-compile (defvar gnus-tmp-header))
4443 (defun gnus-extra-header (type &optional header)
4444 "Return the extra header of TYPE."
4445 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4448 (defvar gnus-tmp-thread-tree-header-string "")
4450 (defcustom gnus-sum-thread-tree-root "> "
4451 "With %B spec, used for the root of a thread.
4452 If nil, use subject instead."
4454 :group 'gnus-thread)
4455 (defcustom gnus-sum-thread-tree-single-indent ""
4456 "With %B spec, used for a thread with just one message.
4457 If nil, use subject instead."
4459 :group 'gnus-thread)
4460 (defcustom gnus-sum-thread-tree-vertical "| "
4461 "With %B spec, used for drawing a vertical line."
4463 :group 'gnus-thread)
4464 (defcustom gnus-sum-thread-tree-indent " "
4465 "With %B spec, used for indenting."
4467 :group 'gnus-thread)
4468 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4469 "With %B spec, used for a leaf with brothers."
4471 :group 'gnus-thread)
4472 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4473 "With %B spec, used for a leaf without brothers."
4475 :group 'gnus-thread)
4477 (defun gnus-summary-prepare-threads (threads)
4478 "Prepare summary buffer from THREADS and indentation LEVEL.
4479 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4480 or a straight list of headers."
4481 (gnus-message 7 "Generating summary...")
4483 (setq gnus-newsgroup-threads threads)
4486 (let ((gnus-tmp-level 0)
4487 (default-score (or gnus-summary-default-score 0))
4488 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4489 thread number subject stack state gnus-tmp-gathered beg-match
4490 new-roots gnus-tmp-new-adopts thread-end simp-subject
4491 gnus-tmp-header gnus-tmp-unread
4492 gnus-tmp-replied gnus-tmp-subject-or-nil
4493 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4494 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4495 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4498 (setq gnus-tmp-prev-subject nil)
4500 (if (vectorp (car threads))
4501 ;; If this is a straight (sic) list of headers, then a
4502 ;; threaded summary display isn't required, so we just create
4503 ;; an unthreaded one.
4504 (gnus-summary-prepare-unthreaded threads)
4506 ;; Do the threaded display.
4508 (while (or threads stack gnus-tmp-new-adopts new-roots)
4510 (if (and (= gnus-tmp-level 0)
4513 (not gnus-tmp-false-parent)
4514 (or gnus-tmp-new-adopts new-roots))
4515 (if gnus-tmp-new-adopts
4516 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4517 thread (list (car gnus-tmp-new-adopts))
4518 gnus-tmp-header (caar thread)
4519 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4521 (setq thread (list (car new-roots))
4522 gnus-tmp-header (caar thread)
4523 new-roots (cdr new-roots))))
4526 ;; If there are some threads, we do them before the
4527 ;; threads on the stack.
4528 (setq thread threads
4529 gnus-tmp-header (caar thread))
4530 ;; There were no current threads, so we pop something off
4532 (setq state (car stack)
4533 gnus-tmp-level (car state)
4534 tree-stack (cadr state)
4535 thread (caddr state)
4537 gnus-tmp-header (caar thread))))
4539 (setq gnus-tmp-false-parent nil)
4540 (setq gnus-tmp-root-expunged nil)
4541 (setq thread-end nil)
4543 (if (stringp gnus-tmp-header)
4544 ;; The header is a dummy root.
4546 ((eq gnus-summary-make-false-root 'adopt)
4547 ;; We let the first article adopt the rest.
4548 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4550 (setq gnus-tmp-gathered
4552 (lambda (h) (mail-header-number (car h)))
4555 (setq thread (cons (list (caar thread)
4558 (setq gnus-tmp-level -1
4559 gnus-tmp-false-parent t))
4560 ((eq gnus-summary-make-false-root 'empty)
4561 ;; We print adopted articles with empty subject fields.
4562 (setq gnus-tmp-gathered
4564 (lambda (h) (mail-header-number (car h)))
4567 (setq gnus-tmp-level -1))
4568 ((eq gnus-summary-make-false-root 'dummy)
4569 ;; We remember that we probably want to output a dummy
4571 (setq gnus-tmp-dummy-line gnus-tmp-header)
4572 (setq gnus-tmp-prev-subject gnus-tmp-header))
4574 ;; We do not make a root for the gathered
4575 ;; sub-threads at all.
4576 (setq gnus-tmp-level -1)))
4578 (setq number (mail-header-number gnus-tmp-header)
4579 subject (mail-header-subject gnus-tmp-header)
4580 simp-subject (gnus-simplify-subject-fully subject))
4583 ;; If the thread has changed subject, we might want to make
4584 ;; this subthread into a root.
4585 ((and (null gnus-thread-ignore-subject)
4586 (not (zerop gnus-tmp-level))
4587 gnus-tmp-prev-subject
4588 (not (string= gnus-tmp-prev-subject simp-subject)))
4589 (setq new-roots (nconc new-roots (list (car thread)))
4591 gnus-tmp-header nil))
4592 ;; If the article lies outside the current limit,
4593 ;; then we do not display it.
4594 ((not (memq number gnus-newsgroup-limit))
4595 (setq gnus-tmp-gathered
4597 (lambda (h) (mail-header-number (car h)))
4600 (setq gnus-tmp-new-adopts (if (cdar thread)
4601 (append gnus-tmp-new-adopts
4603 gnus-tmp-new-adopts)
4605 gnus-tmp-header nil)
4606 (when (zerop gnus-tmp-level)
4607 (setq gnus-tmp-root-expunged t)))
4608 ;; Perhaps this article is to be marked as read?
4609 ((and gnus-summary-mark-below
4610 (< (or (cdr (assq number gnus-newsgroup-scored))
4612 gnus-summary-mark-below)
4613 ;; Don't touch sparse articles.
4614 (not (gnus-summary-article-sparse-p number))
4615 (not (gnus-summary-article-ancient-p number)))
4616 (setq gnus-newsgroup-unreads
4617 (delq number gnus-newsgroup-unreads))
4618 (if gnus-newsgroup-auto-expire
4619 (setq gnus-newsgroup-expirable
4620 (gnus-add-to-sorted-list
4621 gnus-newsgroup-expirable number))
4622 (push (cons number gnus-low-score-mark)
4623 gnus-newsgroup-reads))))
4625 (when gnus-tmp-header
4626 ;; We may have an old dummy line to output before this
4628 (when (and gnus-tmp-dummy-line
4631 (mail-header-subject gnus-tmp-header)))
4632 (gnus-summary-insert-dummy-line
4633 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4634 (setq gnus-tmp-dummy-line nil))
4636 ;; Compute the mark.
4637 (setq gnus-tmp-unread (gnus-article-mark number))
4639 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4640 gnus-tmp-header gnus-tmp-level)
4641 gnus-newsgroup-data)
4643 ;; Actually insert the line.
4645 gnus-tmp-subject-or-nil
4647 ((and gnus-thread-ignore-subject
4648 gnus-tmp-prev-subject
4649 (not (string= gnus-tmp-prev-subject simp-subject)))
4651 ((zerop gnus-tmp-level)
4652 (if (and (eq gnus-summary-make-false-root 'empty)
4653 (memq number gnus-tmp-gathered)
4654 gnus-tmp-prev-subject
4655 (string= gnus-tmp-prev-subject simp-subject))
4656 gnus-summary-same-subject
4658 (t gnus-summary-same-subject)))
4659 (if (and (eq gnus-summary-make-false-root 'adopt)
4660 (= gnus-tmp-level 1)
4661 (memq number gnus-tmp-gathered))
4662 (setq gnus-tmp-opening-bracket ?\<
4663 gnus-tmp-closing-bracket ?\>)
4664 (setq gnus-tmp-opening-bracket ?\[
4665 gnus-tmp-closing-bracket ?\]))
4667 gnus-tmp-indentation
4668 (aref gnus-thread-indent-array gnus-tmp-level)
4669 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4670 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4671 gnus-summary-default-score 0)
4673 (if (or (null gnus-summary-default-score)
4674 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4675 gnus-summary-zcore-fuzz))
4677 (if (< gnus-tmp-score gnus-summary-default-score)
4678 gnus-score-below-mark gnus-score-over-mark))
4680 (cond ((memq number gnus-newsgroup-processable)
4682 ((memq number gnus-newsgroup-cached)
4684 ((memq number gnus-newsgroup-replied)
4686 ((memq number gnus-newsgroup-forwarded)
4687 gnus-forwarded-mark)
4688 ((memq number gnus-newsgroup-saved)
4690 ((memq number gnus-newsgroup-recent)
4692 ((memq number gnus-newsgroup-unseen)
4695 gnus-tmp-from (mail-header-from gnus-tmp-header)
4698 ((string-match "<[^>]+> *$" gnus-tmp-from)
4699 (setq beg-match (match-beginning 0))
4700 (or (and (string-match "^\".+\"" gnus-tmp-from)
4701 (substring gnus-tmp-from 1 (1- (match-end 0))))
4702 (substring gnus-tmp-from 0 beg-match)))
4703 ((string-match "(.+)" gnus-tmp-from)
4704 (substring gnus-tmp-from
4705 (1+ (match-beginning 0)) (1- (match-end 0))))
4707 gnus-tmp-thread-tree-header-string
4709 ((not gnus-show-threads) "")
4710 ((zerop gnus-tmp-level)
4712 (or gnus-sum-thread-tree-root subject)
4713 (or gnus-sum-thread-tree-single-indent subject)))
4715 (concat (apply 'concat
4716 (mapcar (lambda (item)
4718 gnus-sum-thread-tree-vertical
4719 gnus-sum-thread-tree-indent))
4720 (cdr (reverse tree-stack))))
4722 gnus-sum-thread-tree-leaf-with-other
4723 gnus-sum-thread-tree-single-leaf)))))
4724 (when (string= gnus-tmp-name "")
4725 (setq gnus-tmp-name gnus-tmp-from))
4726 (unless (numberp gnus-tmp-lines)
4727 (setq gnus-tmp-lines -1))
4728 (if (= gnus-tmp-lines -1)
4729 (setq gnus-tmp-lines "?")
4730 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4731 (gnus-put-text-property
4733 (progn (eval gnus-summary-line-format-spec) (point))
4734 'gnus-number number)
4737 (gnus-run-hooks 'gnus-summary-update-hook)
4740 (setq gnus-tmp-prev-subject simp-subject)))
4742 (when (nth 1 thread)
4743 (push (list (max 0 gnus-tmp-level)
4744 (copy-list tree-stack)
4747 (push (if (nth 1 thread) 1 0) tree-stack)
4748 (incf gnus-tmp-level)
4749 (setq threads (if thread-end nil (cdar thread)))
4751 (setq gnus-tmp-level 0)))))
4752 (gnus-message 7 "Generating summary...done"))
4754 (defun gnus-summary-prepare-unthreaded (headers)
4755 "Generate an unthreaded summary buffer based on HEADERS."
4756 (let (header number mark)
4761 ;; We may have to root out some bad articles...
4762 (when (memq (setq number (mail-header-number
4763 (setq header (pop headers))))
4764 gnus-newsgroup-limit)
4765 ;; Mark article as read when it has a low score.
4766 (when (and gnus-summary-mark-below
4767 (< (or (cdr (assq number gnus-newsgroup-scored))
4768 gnus-summary-default-score 0)
4769 gnus-summary-mark-below)
4770 (not (gnus-summary-article-ancient-p number)))
4771 (setq gnus-newsgroup-unreads
4772 (delq number gnus-newsgroup-unreads))
4773 (if gnus-newsgroup-auto-expire
4774 (push number gnus-newsgroup-expirable)
4775 (push (cons number gnus-low-score-mark)
4776 gnus-newsgroup-reads)))
4778 (setq mark (gnus-article-mark number))
4779 (push (gnus-data-make number mark (1+ (point)) header 0)
4780 gnus-newsgroup-data)
4781 (gnus-summary-insert-line
4783 mark (memq number gnus-newsgroup-replied)
4784 (memq number gnus-newsgroup-expirable)
4785 (mail-header-subject header) nil
4786 (cdr (assq number gnus-newsgroup-scored))
4787 (memq number gnus-newsgroup-processable))))))
4789 (defun gnus-summary-remove-list-identifiers ()
4790 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4791 (let ((regexp (if (consp gnus-list-identifiers)
4792 (mapconcat 'identity gnus-list-identifiers " *\\|")
4793 gnus-list-identifiers))
4796 (dolist (header gnus-newsgroup-headers)
4797 (setq subject (mail-header-subject header)
4799 (while (string-match
4800 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4803 (concat (substring subject 0 (match-beginning 2))
4804 (substring subject (match-end 0)))
4808 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4810 (concat (substring subject 0 (match-beginning 1))
4811 (substring subject (match-end 1)))))
4813 (mail-header-set-subject header subject))))))
4815 (defun gnus-fetch-headers (articles)
4816 "Fetch headers of ARTICLES."
4817 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4818 (gnus-message 5 "Fetching headers for %s..." name)
4821 (setq gnus-headers-retrieved-by
4822 (gnus-retrieve-headers
4823 articles gnus-newsgroup-name
4824 ;; We might want to fetch old headers, but
4825 ;; not if there is only 1 article.
4827 (not (eq gnus-fetch-old-headers 'some))
4828 (not (numberp gnus-fetch-old-headers)))
4829 (> (length articles) 1))
4830 gnus-fetch-old-headers))))
4831 (gnus-get-newsgroup-headers-xover
4832 articles nil nil gnus-newsgroup-name t)
4833 (gnus-get-newsgroup-headers))
4834 (gnus-message 5 "Fetching headers for %s...done" name))))
4836 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4837 "Select newsgroup GROUP.
4838 If READ-ALL is non-nil, all articles in the group are selected.
4839 If SELECT-ARTICLES, only select those articles from GROUP."
4840 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4841 ;;!!! Dirty hack; should be removed.
4842 (gnus-summary-ignore-duplicates
4843 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4845 gnus-summary-ignore-duplicates))
4846 (info (nth 2 entry))
4847 articles fetched-articles cached)
4849 (unless (gnus-check-server
4850 (set (make-local-variable 'gnus-current-select-method)
4851 (gnus-find-method-for-group group)))
4852 (error "Couldn't open server"))
4854 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4855 (gnus-activate-group group) ; Or we can activate it...
4856 (progn ; Or we bug out.
4857 (when (equal major-mode 'gnus-summary-mode)
4858 (kill-buffer (current-buffer)))
4859 (error "Couldn't activate group %s: %s"
4860 group (gnus-status-message group))))
4862 (unless (gnus-request-group group t)
4863 (when (equal major-mode 'gnus-summary-mode)
4864 (kill-buffer (current-buffer)))
4865 (error "Couldn't request group %s: %s"
4866 group (gnus-status-message group)))
4868 (setq gnus-newsgroup-name group
4869 gnus-newsgroup-unselected nil
4870 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4872 (let ((display (gnus-group-find-parameter group 'display)))
4873 (setq gnus-newsgroup-display
4875 ((not (zerop (or (car-safe read-all) 0)))
4876 ;; The user entered the group with C-u SPC/RET, let's show
4882 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4884 ;; The following is probably the "correct" solution, but
4885 ;; it makes Gnus fetch all headers and then limit the
4886 ;; articles (which is slow), so instead we hack the
4887 ;; select-articles parameter instead. -- Simon Josefsson
4890 ;; (gnus-byte-compile
4891 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4893 (setq select-articles
4894 (gnus-uncompress-range
4895 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4899 (cdr (gnus-active group)))))
4904 (gnus-summary-setup-default-charset)
4906 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4907 (when (gnus-virtual-group-p group)
4908 (setq cached gnus-newsgroup-cached))
4910 (setq gnus-newsgroup-unreads
4911 (gnus-sorted-ndifference
4912 (gnus-sorted-ndifference gnus-newsgroup-unreads
4913 gnus-newsgroup-marked)
4914 gnus-newsgroup-dormant))
4916 (setq gnus-newsgroup-processable nil)
4918 (gnus-update-read-articles group gnus-newsgroup-unreads)
4920 ;; Adjust and set lists of article marks.
4922 (gnus-adjust-marked-articles info))
4923 (if (setq articles select-articles)
4924 (setq gnus-newsgroup-unselected
4925 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4926 (setq articles (gnus-articles-to-read group read-all)))
4930 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4932 ((eq articles 0) nil)
4934 ;; Init the dependencies hash table.
4935 (setq gnus-newsgroup-dependencies
4936 (gnus-make-hashtable (length articles)))
4937 (gnus-set-global-variables)
4938 ;; Retrieve the headers and read them in.
4940 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4942 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4944 (setq gnus-newsgroup-cached cached))
4946 ;; Suppress duplicates?
4947 (when gnus-suppress-duplicates
4948 (gnus-dup-suppress-articles))
4950 ;; Set the initial limit.
4951 (setq gnus-newsgroup-limit (copy-sequence articles))
4952 ;; Remove canceled articles from the list of unread articles.
4953 (setq fetched-articles
4954 (mapcar (lambda (headers) (mail-header-number headers))
4955 gnus-newsgroup-headers))
4956 (setq gnus-newsgroup-articles fetched-articles)
4957 (setq gnus-newsgroup-unreads
4958 (gnus-sorted-nintersection
4959 gnus-newsgroup-unreads fetched-articles))
4960 (gnus-compute-unseen-list)
4962 ;; Removed marked articles that do not exist.
4963 (gnus-update-missing-marks
4964 (gnus-sorted-difference articles fetched-articles))
4965 ;; We might want to build some more threads first.
4966 (when (and gnus-fetch-old-headers
4967 (eq gnus-headers-retrieved-by 'nov))
4968 (if (eq gnus-fetch-old-headers 'invisible)
4969 (gnus-build-all-threads)
4970 (gnus-build-old-threads)))
4971 ;; Let the Gnus agent mark articles as read.
4973 (gnus-agent-get-undownloaded-list))
4974 ;; Remove list identifiers from subject
4975 (when gnus-list-identifiers
4976 (gnus-summary-remove-list-identifiers))
4977 ;; Check whether auto-expire is to be done in this group.
4978 (setq gnus-newsgroup-auto-expire
4979 (gnus-group-auto-expirable-p group))
4980 ;; Set up the article buffer now, if necessary.
4981 (unless gnus-single-article-buffer
4982 (gnus-article-setup-buffer))
4983 ;; First and last article in this newsgroup.
4984 (when gnus-newsgroup-headers
4985 (setq gnus-newsgroup-begin
4986 (mail-header-number (car gnus-newsgroup-headers))
4989 (gnus-last-element gnus-newsgroup-headers))))
4990 ;; GROUP is successfully selected.
4991 (or gnus-newsgroup-headers t)))))
4993 (defun gnus-compute-unseen-list ()
4994 ;; The `seen' marks are treated specially.
4995 (if (not gnus-newsgroup-seen)
4996 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4997 (setq gnus-newsgroup-unseen
4998 (gnus-inverse-list-range-intersection
4999 gnus-newsgroup-articles gnus-newsgroup-seen))))
5001 (defun gnus-summary-display-make-predicate (display)
5002 (require 'gnus-agent)
5003 (when (= (length display) 1)
5004 (setq display (car display)))
5005 (unless gnus-summary-display-cache
5006 (dolist (elem (append '((unread . unread)
5009 gnus-article-mark-lists))
5010 (push (cons (cdr elem)
5012 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5013 gnus-summary-display-cache)))
5014 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5015 (gnus-category-predicate-cache gnus-summary-display-cache))
5016 (gnus-get-predicate display)))
5018 ;; Uses the dynamically bound `number' variable.
5020 (defun gnus-article-marked-p (type &optional article)
5021 (let ((article (or article number)))
5024 (memq article gnus-newsgroup-marked))
5026 (memq article gnus-newsgroup-spam-marked))
5028 (memq article gnus-newsgroup-unsendable))
5029 ((eq type 'undownload)
5030 (memq article gnus-newsgroup-undownloaded))
5031 ((eq type 'download)
5032 (memq article gnus-newsgroup-downloadable))
5034 (memq article gnus-newsgroup-unreads))
5036 (memq article gnus-newsgroup-reads))
5038 (memq article gnus-newsgroup-dormant) )
5040 (memq article gnus-newsgroup-expirable))
5042 (memq article gnus-newsgroup-replied))
5044 (memq article gnus-newsgroup-killed))
5045 ((eq type 'bookmark)
5046 (assq article gnus-newsgroup-bookmarks))
5048 (assq article gnus-newsgroup-scored))
5050 (memq article gnus-newsgroup-saved))
5052 (memq article gnus-newsgroup-cached))
5054 (memq article gnus-newsgroup-forwarded))
5056 (not (memq article gnus-newsgroup-unseen)))
5058 (memq article gnus-newsgroup-recent))
5061 (defun gnus-articles-to-read (group &optional read-all)
5062 "Find out what articles the user wants to read."
5064 ;; Select all articles if `read-all' is non-nil, or if there
5065 ;; are no unread articles.
5067 (and (zerop (length gnus-newsgroup-marked))
5068 (zerop (length gnus-newsgroup-unreads)))
5069 ;; Fetch all if the predicate is non-nil.
5070 gnus-newsgroup-display)
5071 ;; We want to select the headers for all the articles in
5072 ;; the group, so we select either all the active
5073 ;; articles in the group, or (if that's nil), the
5074 ;; articles in the cache.
5076 (gnus-uncompress-range (gnus-active group))
5077 (gnus-cache-articles-in-group group))
5078 ;; Select only the "normal" subset of articles.
5080 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5081 gnus-newsgroup-unreads)))
5082 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5083 (scored (length scored-list))
5084 (number (length articles))
5085 (marked (+ (length gnus-newsgroup-marked)
5086 (length gnus-newsgroup-dormant)))
5091 ((numberp gnus-newsgroup-display)
5092 gnus-newsgroup-display)
5096 ((and (or (<= scored marked) (= scored number))
5097 (numberp gnus-large-newsgroup)
5098 (> number gnus-large-newsgroup))
5099 (let* ((cursor-in-echo-area nil)
5100 (initial (gnus-parameter-large-newsgroup-initial
5101 gnus-newsgroup-name))
5105 "How many articles from %s (%s %d): "
5107 (gnus-group-decoded-name gnus-newsgroup-name)
5109 (if initial "max" "default")
5112 (cons (number-to-string initial)
5114 (if (string-match "^[ \t]*$" input) number input)))
5115 ((and (> scored marked) (< scored number)
5116 (> (- scored number) 20))
5119 (format "%s %s (%d scored, %d total): "
5120 "How many articles from"
5121 (gnus-group-decoded-name group)
5123 (if (string-match "^[ \t]*$" input)
5127 (message "Quit getting the articles to read")
5129 (setq select (if (stringp select) (string-to-number select) select))
5130 (if (or (null select) (zerop select))
5132 (if (and (not (zerop scored)) (<= (abs select) scored))
5134 (setq articles (sort scored-list '<))
5135 (setq number (length articles)))
5136 (setq articles (copy-sequence articles)))
5138 (when (< (abs select) number)
5140 ;; Select the N oldest articles.
5141 (setcdr (nthcdr (1- (abs select)) articles) nil)
5142 ;; Select the N most recent articles.
5143 (setq articles (nthcdr (- number select) articles))))
5144 (setq gnus-newsgroup-unselected
5145 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5146 (when gnus-alter-articles-to-read-function
5147 (setq gnus-newsgroup-unreads
5149 (funcall gnus-alter-articles-to-read-function
5150 gnus-newsgroup-name gnus-newsgroup-unreads)
5154 (defun gnus-killed-articles (killed articles)
5157 (when (inline (gnus-member-of-range (car articles) killed))
5158 (push (car articles) out))
5159 (setq articles (cdr articles)))
5162 (defun gnus-uncompress-marks (marks)
5163 "Uncompress the mark ranges in MARKS."
5164 (let ((uncompressed '(score bookmark))
5167 (if (memq (caar marks) uncompressed)
5168 (push (car marks) out)
5169 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5170 (setq marks (cdr marks)))
5173 (defun gnus-article-mark-to-type (mark)
5174 "Return the type of MARK."
5175 (or (cadr (assq mark gnus-article-special-mark-lists))
5178 (defun gnus-article-unpropagatable-p (mark)
5179 "Return whether MARK should be propagated to backend."
5180 (memq mark gnus-article-unpropagated-mark-lists))
5182 (defun gnus-adjust-marked-articles (info)
5183 "Set all article lists and remove all marks that are no longer valid."
5184 (let* ((marked-lists (gnus-info-marks info))
5185 (active (gnus-active (gnus-info-group info)))
5188 (types gnus-article-mark-lists)
5189 marks var articles article mark mark-type)
5191 (dolist (marks marked-lists)
5192 (setq mark (car marks)
5193 mark-type (gnus-article-mark-to-type mark)
5194 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5196 ;; We set the variable according to the type of the marks list,
5197 ;; and then adjust the marks to a subset of the active articles.
5199 ;; Adjust "simple" lists.
5200 ((eq mark-type 'list)
5201 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5202 (when (memq mark '(tick dormant expire reply save))
5204 (when (or (< (setq article (pop articles)) min) (> article max))
5205 (set var (delq article (symbol-value var)))))))
5207 ((eq mark-type 'tuple)
5208 (set var (setq articles (cdr marks)))
5209 (when (not (listp (cdr (symbol-value var))))
5210 (set var (list (symbol-value var))))
5211 (when (not (listp (cdr articles)))
5212 (setq articles (list articles)))
5214 (when (or (not (consp (setq article (pop articles))))
5215 (< (car article) min)
5216 (> (car article) max))
5217 (set var (delq article (symbol-value var))))))
5218 ;; Adjust ranges (sloppily).
5219 ((eq mark-type 'range)
5222 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5223 ;; It should be (seen (NUM1 . NUM2)).
5224 (when (numberp (cddr marks))
5225 (setcdr marks (list (cdr marks))))
5226 (setq articles (cdr marks))
5227 (while (and articles
5228 (or (and (consp (car articles))
5229 (> min (cdar articles)))
5230 (and (numberp (car articles))
5231 (> min (car articles)))))
5233 (set var articles))))))))
5235 (defun gnus-update-missing-marks (missing)
5236 "Go through the list of MISSING articles and remove them from the mark lists."
5239 ;; Go through all types.
5240 (dolist (elem gnus-article-mark-lists)
5241 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5242 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5243 (when (symbol-value var)
5244 ;; This list has articles. So we delete all missing
5245 ;; articles from it.
5248 (set var (delq (pop m) (symbol-value var))))))))))
5250 (defun gnus-update-marks ()
5251 "Enter the various lists of marked articles into the newsgroup info list."
5252 (let ((types gnus-article-mark-lists)
5253 (info (gnus-get-info gnus-newsgroup-name))
5254 type list newmarked symbol delta-marks)
5256 ;; Add all marks lists to the list of marks lists.
5257 (while (setq type (pop types))
5258 (setq list (symbol-value
5260 (intern (format "gnus-newsgroup-%s" (car type))))))
5263 ;; Get rid of the entries of the articles that have the
5265 (when (and (eq (cdr type) 'score)
5269 (prev (cons nil list))
5272 (if (or (not (consp (car arts)))
5273 (= (cdar arts) gnus-summary-default-score))
5274 (setcdr prev (cdr arts))
5276 (setq arts (cdr arts)))
5277 (setq list (cdr all)))))
5279 (when (eq (cdr type) 'seen)
5280 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5282 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5283 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5285 (when (and (gnus-check-backend-function
5286 'request-set-mark gnus-newsgroup-name)
5287 (not (gnus-article-unpropagatable-p (cdr type))))
5288 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5289 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5290 (add (gnus-remove-from-range
5291 (gnus-copy-sequence list) old)))
5293 (push (list add 'add (list (cdr type))) delta-marks))
5295 (push (list del 'del (list (cdr type))) delta-marks))))
5298 (push (cons (cdr type) list) newmarked)))
5301 (unless (gnus-check-group gnus-newsgroup-name)
5302 (error "Can't open server for %s" gnus-newsgroup-name))
5303 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5305 ;; Enter these new marks into the info of the group.
5307 (setcar (nthcdr 3 info) newmarked)
5308 ;; Add the marks lists to the end of the info.
5310 (setcdr (nthcdr 2 info) (list newmarked))))
5312 ;; Cut off the end of the info if there's nothing else there.
5316 (when (nthcdr (decf i) info)
5317 (setcdr (nthcdr i info) nil)))))))
5319 (defun gnus-set-mode-line (where)
5320 "Set the mode line of the article or summary buffers.
5321 If WHERE is `summary', the summary mode line format will be used."
5322 ;; Is this mode line one we keep updated?
5323 (when (and (memq where gnus-updated-mode-lines)
5325 (intern (format "gnus-%s-mode-line-format-spec" where))))
5328 ;; We evaluate this in the summary buffer since these
5329 ;; variables are buffer-local to that buffer.
5330 (set-buffer gnus-summary-buffer)
5331 ;; We bind all these variables that are used in the `eval' form
5333 (let* ((mformat (symbol-value
5335 (format "gnus-%s-mode-line-format-spec" where))))
5336 (gnus-tmp-group-name (gnus-group-decoded-name
5337 gnus-newsgroup-name))
5338 (gnus-tmp-article-number (or gnus-current-article 0))
5339 (gnus-tmp-unread gnus-newsgroup-unreads)
5340 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5341 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5342 (gnus-tmp-unread-and-unselected
5343 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5344 (zerop gnus-tmp-unselected))
5346 ((zerop gnus-tmp-unselected)
5347 (format "{%d more}" gnus-tmp-unread-and-unticked))
5348 (t (format "{%d(+%d) more}"
5349 gnus-tmp-unread-and-unticked
5350 gnus-tmp-unselected))))
5352 (if (and gnus-current-headers
5353 (vectorp gnus-current-headers))
5354 (gnus-mode-string-quote
5355 (mail-header-subject gnus-current-headers))
5357 bufname-length max-len
5358 gnus-tmp-header);; passed as argument to any user-format-funcs
5359 (setq mode-string (eval mformat))
5360 (setq bufname-length (if (string-match "%b" mode-string)
5363 (if (eq where 'summary)
5365 (get-buffer gnus-article-buffer))))
5368 (setq max-len (max 4 (if gnus-mode-non-string-length
5370 gnus-mode-non-string-length
5372 (length mode-string))))
5373 ;; We might have to chop a bit of the string off...
5374 (when (> (length mode-string) max-len)
5376 (concat (gnus-truncate-string mode-string (- max-len 3))
5378 ;; Pad the mode string a bit.
5379 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5380 ;; Update the mode line.
5381 (setq mode-line-buffer-identification
5382 (gnus-mode-line-buffer-identification (list mode-string)))
5383 (set-buffer-modified-p t))))
5385 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5386 "Go through the HEADERS list and add all Xrefs to a hash table.
5387 The resulting hash table is returned, or nil if no Xrefs were found."
5388 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5389 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5390 (xref-hashtb (gnus-make-hashtable))
5391 start group entry number xrefs header)
5393 (setq header (pop headers))
5394 (when (and (setq xrefs (mail-header-xref header))
5395 (not (memq (setq number (mail-header-number header))
5398 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5399 (setq start (match-end 0))
5400 (setq group (if prefix
5401 (concat prefix (substring xrefs (match-beginning 1)
5403 (substring xrefs (match-beginning 1) (match-end 1))))
5405 (string-to-int (substring xrefs (match-beginning 2)
5407 (if (setq entry (gnus-gethash group xref-hashtb))
5408 (setcdr entry (cons number (cdr entry)))
5409 (gnus-sethash group (cons number nil) xref-hashtb)))))
5410 (and start xref-hashtb)))
5412 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5413 "Look through all the headers and mark the Xrefs as read."
5414 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5415 name entry info xref-hashtb idlist method nth4)
5417 (set-buffer gnus-group-buffer)
5418 (when (setq xref-hashtb
5419 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5422 (unless (string= from-newsgroup (setq name (symbol-name group)))
5423 (setq idlist (symbol-value group))
5424 ;; Dead groups are not updated.
5426 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5428 (when (stringp (setq nth4 (gnus-info-method info)))
5429 (setq nth4 (gnus-server-to-method nth4))))
5430 ;; Only do the xrefs if the group has the same
5431 ;; select method as the group we have just read.
5432 (or (gnus-methods-equal-p
5433 nth4 (gnus-find-method-for-group from-newsgroup))
5435 (equal nth4 (setq method (gnus-find-method-for-group
5437 (and (equal (car nth4) (car method))
5438 (equal (nth 1 nth4) (nth 1 method))))
5439 gnus-use-cross-reference
5440 (or (not (eq gnus-use-cross-reference t))
5442 ;; Only do cross-references on subscribed
5443 ;; groups, if that is what is wanted.
5444 (<= (gnus-info-level info) gnus-level-subscribed))
5445 (gnus-group-make-articles-read name idlist))))
5448 (defun gnus-compute-read-articles (group articles)
5449 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5450 (info (nth 2 entry))
5451 (active (gnus-active group))
5454 ;; First peel off all invalid article numbers.
5456 (let ((ids articles)
5458 (while (setq id (pop ids))
5459 (when (and first (> id (cdr active)))
5460 ;; We'll end up in this situation in one particular
5461 ;; obscure situation. If you re-scan a group and get
5462 ;; a new article that is cross-posted to a different
5463 ;; group that has not been re-scanned, you might get
5464 ;; crossposted article that has a higher number than
5465 ;; Gnus believes possible. So we re-activate this
5466 ;; group as well. This might mean doing the
5467 ;; crossposting thingy will *increase* the number
5468 ;; of articles in some groups. Tsk, tsk.
5469 (setq active (or (gnus-activate-group group) active)))
5470 (when (or (> id (cdr active))
5471 (< id (car active)))
5472 (setq articles (delq id articles))))))
5473 ;; If the read list is nil, we init it.
5475 (null (gnus-info-read info))
5477 (setq ninfo (cons 1 (1- (car active))))
5478 (setq ninfo (gnus-info-read info)))
5479 ;; Then we add the read articles to the range.
5481 ninfo (setq articles (sort articles '<))))))
5483 (defun gnus-group-make-articles-read (group articles)
5484 "Update the info of GROUP to say that ARTICLES are read."
5486 (entry (gnus-gethash group gnus-newsrc-hashtb))
5487 (info (nth 2 entry))
5488 (active (gnus-active group))
5491 (setq range (gnus-compute-read-articles group articles))
5493 (set-buffer gnus-group-buffer)
5496 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5497 (gnus-info-set-read ',info ',(gnus-info-read info))
5498 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5499 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5500 (gnus-group-update-group ,group t))))
5501 ;; Add the read articles to the range.
5502 (gnus-info-set-read info range)
5503 (gnus-request-set-mark group (list (list range 'add '(read))))
5504 ;; Then we have to re-compute how many unread
5505 ;; articles there are in this group.
5509 (setq num (- (1+ (cdr active)) (car active))))
5510 ((not (listp (cdr range)))
5511 (setq num (- (cdr active) (- (1+ (cdr range))
5515 (if (numberp (car range))
5517 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5518 (setq range (cdr range)))
5519 (setq num (- (cdr active) num))))
5520 ;; Update the number of unread articles.
5522 ;; Update the group buffer.
5523 (gnus-group-update-group group t)))))
5525 (defvar gnus-newsgroup-none-id 0)
5527 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5528 (let ((cur nntp-server-buffer)
5531 (save-excursion (set-buffer gnus-summary-buffer)
5532 gnus-newsgroup-dependencies)))
5534 (mail-parse-charset gnus-newsgroup-charset)
5535 (mail-parse-ignored-charsets
5536 (save-excursion (condition-case nil
5537 (set-buffer gnus-summary-buffer)
5539 gnus-newsgroup-ignored-charsets)))
5541 (set-buffer nntp-server-buffer)
5542 ;; Translate all TAB characters into SPACE characters.
5543 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5544 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5545 (gnus-run-hooks 'gnus-parse-headers-hook)
5546 (let ((case-fold-search t)
5547 in-reply-to header p lines chars ctype)
5548 (goto-char (point-min))
5549 ;; Search to the beginning of the next header. Error messages
5550 ;; do not begin with 2 or 3.
5551 (while (re-search-forward "^[23][0-9]+ " nil t)
5554 ;; This implementation of this function, with nine
5555 ;; search-forwards instead of the one re-search-forward and
5556 ;; a case (which basically was the old function) is actually
5557 ;; about twice as fast, even though it looks messier. You
5558 ;; can't have everything, I guess. Speed and elegance
5559 ;; doesn't always go hand in hand.
5562 (make-full-mail-header
5568 (narrow-to-region (point)
5569 (or (and (search-forward "\n.\n" nil t)
5575 (if (search-forward "\nsubject:" nil t)
5576 (nnheader-header-value)
5581 (if (search-forward "\nfrom:" nil t)
5582 (nnheader-header-value)
5587 (if (search-forward "\ndate:" nil t)
5588 (nnheader-header-value) ""))
5592 (setq id (if (re-search-forward
5593 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5594 ;; We do it this way to make sure the Message-ID
5595 ;; is (somewhat) syntactically valid.
5596 (buffer-substring (match-beginning 1)
5598 ;; If there was no message-id, we just fake one
5599 ;; to make subsequent routines simpler.
5600 (nnheader-generate-fake-message-id))))
5604 (if (search-forward "\nreferences:" nil t)
5608 (nnheader-header-value)
5613 (search-backward ">" end t)
5616 (search-backward "<" end t)
5618 ;; Get the references from the in-reply-to header if there
5619 ;; were no references and the in-reply-to header looks
5621 (if (and (search-forward "\nin-reply-to:" nil t)
5622 (setq in-reply-to (nnheader-header-value))
5623 (string-match "<[^>]+>" in-reply-to))
5625 (setq ref (substring in-reply-to (match-beginning 0)
5627 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5628 (setq ref2 (substring in-reply-to (match-beginning 0)
5630 (when (> (length ref2) (length ref))
5637 (if (search-forward "\nchars: " nil t)
5638 (if (numberp (setq chars (ignore-errors (read cur))))
5644 (if (search-forward "\nlines: " nil t)
5645 (if (numberp (setq lines (ignore-errors (read cur))))
5651 (and (search-forward "\nxref:" nil t)
5652 (nnheader-header-value)))
5654 (when gnus-extra-headers
5655 (let ((extra gnus-extra-headers)
5659 (when (search-forward
5660 (concat "\n" (symbol-name (car extra)) ":") nil t)
5661 (push (cons (car extra) (nnheader-header-value)) out))
5665 (if (and (search-forward "\ncontent-type: " nil t)
5666 (setq ctype (nnheader-header-value)))
5667 (mime-entity-set-content-type-internal
5668 header (mime-parse-Content-Type ctype)))
5669 (when (equal id ref)
5672 (when gnus-alter-header-function
5673 (funcall gnus-alter-header-function header)
5674 (setq id (mail-header-id header)
5675 ref (gnus-parent-id (mail-header-references header))))
5678 (gnus-dependencies-add-header
5679 header dependencies force-new))
5680 (push header headers))
5681 (goto-char (point-max))
5683 (nreverse headers)))))
5685 ;; Goes through the xover lines and returns a list of vectors
5686 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5687 force-new dependencies
5688 group also-fetch-heads)
5689 "Parse the news overview data in the server buffer.
5690 Return a list of headers that match SEQUENCE (see
5691 `nntp-retrieve-headers')."
5692 ;; Get the Xref when the users reads the articles since most/some
5693 ;; NNTP servers do not include Xrefs when using XOVER.
5694 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5695 (let ((mail-parse-charset gnus-newsgroup-charset)
5696 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5697 (cur nntp-server-buffer)
5698 (dependencies (or dependencies gnus-newsgroup-dependencies))
5700 ((eq gnus-read-all-available-headers t)
5702 ((stringp gnus-read-all-available-headers)
5703 (string-match gnus-read-all-available-headers group))
5706 number headers header)
5708 (set-buffer nntp-server-buffer)
5709 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5710 ;; Allow the user to mangle the headers before parsing them.
5711 (gnus-run-hooks 'gnus-parse-headers-hook)
5712 (goto-char (point-min))
5713 (gnus-parse-without-error
5714 (while (and (or sequence allp)
5716 (setq number (read cur))
5718 (while (and sequence
5719 (< (car sequence) number))
5720 (setq sequence (cdr sequence))))
5723 (eq number (car sequence))))
5725 (setq sequence (cdr sequence))
5726 (setq header (inline
5727 (gnus-nov-parse-line
5728 number dependencies force-new)))))
5729 (push header headers))
5731 ;; A common bug in inn is that if you have posted an article and
5732 ;; then retrieves the active file, it will answer correctly --
5733 ;; the new article is included. However, a NOV entry for the
5734 ;; article may not have been generated yet, so this may fail.
5735 ;; We work around this problem by retrieving the last few
5736 ;; headers using HEAD.
5737 (if (or (not also-fetch-heads)
5739 ;; We (probably) got all the headers.
5741 (let ((gnus-nov-is-evil t))
5744 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5745 (gnus-get-newsgroup-headers))))))))
5747 (defun gnus-article-get-xrefs ()
5748 "Fill in the Xref value in `gnus-current-headers', if necessary.
5749 This is meant to be called in `gnus-article-internal-prepare-hook'."
5750 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5751 gnus-current-headers)))
5752 (or (not gnus-use-cross-reference)
5754 (and (mail-header-xref headers)
5755 (not (string= (mail-header-xref headers) "")))
5756 (let ((case-fold-search t)
5759 (nnheader-narrow-to-headers)
5760 (goto-char (point-min))
5761 (when (or (and (not (eobp))
5762 (eq (downcase (char-after)) ?x)
5763 (looking-at "Xref:"))
5764 (search-forward "\nXref:" nil t))
5765 (goto-char (1+ (match-end 0)))
5766 (setq xref (buffer-substring (point)
5767 (progn (end-of-line) (point))))
5768 (mail-header-set-xref headers xref)))))))
5770 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5771 "Find article ID and insert the summary line for that article.
5772 OLD-HEADER can either be a header or a line number to insert
5773 the subject line on."
5774 (let* ((line (and (numberp old-header) old-header))
5775 (old-header (and (vectorp old-header) old-header))
5776 (header (cond ((and old-header use-old-header)
5779 (gnus-number-to-header id))
5780 (gnus-number-to-header id))
5782 (gnus-read-header id))))
5783 (number (and (numberp id) id))
5786 ;; Rebuild the thread that this article is part of and go to the
5787 ;; article we have fetched.
5788 (when (and (not gnus-show-threads)
5791 (setq d (gnus-data-find (mail-header-number old-header))))
5792 (goto-char (gnus-data-pos d))
5795 (- (gnus-point-at-bol)
5797 (1+ (gnus-point-at-eol))
5798 (gnus-delete-line))))))
5800 (mail-header-set-number header (mail-header-number old-header)))
5801 (setq gnus-newsgroup-sparse
5802 (delq (setq number (mail-header-number header))
5803 gnus-newsgroup-sparse))
5804 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5805 (push number gnus-newsgroup-limit)
5806 (gnus-rebuild-thread (mail-header-id header) line)
5807 (gnus-summary-goto-subject number nil t))
5808 (when (and (numberp number)
5810 ;; We have to update the boundaries even if we can't fetch the
5811 ;; article if ID is a number -- so that the next `P' or `N'
5812 ;; command will fetch the previous (or next) article even
5813 ;; if the one we tried to fetch this time has been canceled.
5814 (when (> number gnus-newsgroup-end)
5815 (setq gnus-newsgroup-end number))
5816 (when (< number gnus-newsgroup-begin)
5817 (setq gnus-newsgroup-begin number))
5818 (setq gnus-newsgroup-unselected
5819 (delq number gnus-newsgroup-unselected)))
5820 ;; Report back a success?
5821 (and header (mail-header-number header))))
5823 ;;; Process/prefix in the summary buffer
5825 (defun gnus-summary-work-articles (n)
5826 "Return a list of articles to be worked upon.
5827 The prefix argument, the list of process marked articles, and the
5828 current article will be taken into consideration."
5830 (set-buffer gnus-summary-buffer)
5833 ;; A numerical prefix has been given.
5834 (setq n (prefix-numeric-value n))
5835 (let ((backward (< n 0))
5836 (n (abs (prefix-numeric-value n)))
5841 (push (setq article (gnus-summary-article-number))
5844 (gnus-summary-find-prev nil article)
5845 (gnus-summary-find-next nil article)))
5847 (nreverse articles)))
5848 ((and (gnus-region-active-p) (mark))
5849 (message "region active")
5850 ;; Work on the region between point and mark.
5851 (let ((max (max (point) (mark)))
5854 (goto-char (min (point) (mark)))
5857 (push (setq article (gnus-summary-article-number)) articles)
5858 (gnus-summary-find-next nil article)
5860 (nreverse articles))))
5861 (gnus-newsgroup-processable
5862 ;; There are process-marked articles present.
5863 ;; Save current state.
5864 (gnus-summary-save-process-mark)
5866 (reverse gnus-newsgroup-processable))
5868 ;; Just return the current article.
5869 (list (gnus-summary-article-number))))))
5871 (defmacro gnus-summary-iterate (arg &rest forms)
5872 "Iterate over the process/prefixed articles and do FORMS.
5873 ARG is the interactive prefix given to the command. FORMS will be
5874 executed with point over the summary line of the articles."
5875 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5876 `(let ((,articles (gnus-summary-work-articles ,arg)))
5878 (gnus-summary-goto-subject (car ,articles))
5882 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5883 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5885 (defun gnus-summary-save-process-mark ()
5886 "Push the current set of process marked articles on the stack."
5888 (push (copy-sequence gnus-newsgroup-processable)
5889 gnus-newsgroup-process-stack))
5891 (defun gnus-summary-kill-process-mark ()
5892 "Push the current set of process marked articles on the stack and unmark."
5894 (gnus-summary-save-process-mark)
5895 (gnus-summary-unmark-all-processable))
5897 (defun gnus-summary-yank-process-mark ()
5898 "Pop the last process mark state off the stack and restore it."
5900 (unless gnus-newsgroup-process-stack
5901 (error "Empty mark stack"))
5902 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5904 (defun gnus-summary-process-mark-set (set)
5905 "Make SET into the current process marked articles."
5906 (gnus-summary-unmark-all-processable)
5908 (gnus-summary-set-process-mark (pop set))))
5910 ;;; Searching and stuff
5912 (defun gnus-summary-search-group (&optional backward use-level)
5913 "Search for next unread newsgroup.
5914 If optional argument BACKWARD is non-nil, search backward instead."
5916 (set-buffer gnus-group-buffer)
5917 (when (gnus-group-search-forward
5918 backward nil (if use-level (gnus-group-group-level) nil))
5919 (gnus-group-group-name))))
5921 (defun gnus-summary-best-group (&optional exclude-group)
5922 "Find the name of the best unread group.
5923 If EXCLUDE-GROUP, do not go to this group."
5925 (set-buffer gnus-group-buffer)
5927 (gnus-group-best-unread-group exclude-group))))
5929 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5930 (if backward (gnus-summary-find-prev)
5931 (let* ((dummy (gnus-summary-article-intangible-p))
5932 (article (or article (gnus-summary-article-number)))
5933 (arts (gnus-data-find-list article))
5935 (when (and (not dummy)
5936 (or (not gnus-summary-check-current)
5938 (not (gnus-data-unread-p (car arts)))))
5939 (setq arts (cdr arts)))
5944 (when (or (and undownloaded
5945 (eq gnus-undownloaded-mark
5946 (gnus-data-mark (car arts))))
5947 (gnus-data-unread-p (car arts)))
5948 (setq result (car arts)
5950 (setq arts (cdr arts)))
5953 (goto-char (gnus-data-pos result))
5954 (gnus-data-number result)))))
5956 (defun gnus-summary-find-prev (&optional unread article)
5957 (let* ((eobp (eobp))
5958 (article (or article (gnus-summary-article-number)))
5959 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5961 (when (and (not eobp)
5962 (or (not gnus-summary-check-current)
5964 (not (gnus-data-unread-p (car arts)))))
5965 (setq arts (cdr arts)))
5970 (when (gnus-data-unread-p (car arts))
5971 (setq result (car arts)
5973 (setq arts (cdr arts)))
5976 (goto-char (gnus-data-pos result))
5977 (gnus-data-number result))))
5979 (defun gnus-summary-find-subject (subject &optional unread backward article)
5980 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5981 (article (or article (gnus-summary-article-number)))
5982 (articles (gnus-data-list backward))
5983 (arts (gnus-data-find-list article articles))
5985 (when (or (not gnus-summary-check-current)
5987 (not (gnus-data-unread-p (car arts))))
5988 (setq arts (cdr arts)))
5990 (and (or (not unread)
5991 (gnus-data-unread-p (car arts)))
5992 (vectorp (gnus-data-header (car arts)))
5994 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5995 (setq result (car arts)
5997 (setq arts (cdr arts)))
5999 (goto-char (gnus-data-pos result))
6000 (gnus-data-number result))))
6002 (defun gnus-summary-search-forward (&optional unread subject backward)
6003 "Search forward for an article.
6004 If UNREAD, look for unread articles. If SUBJECT, look for
6005 articles with that subject. If BACKWARD, search backward instead."
6006 (cond (subject (gnus-summary-find-subject subject unread backward))
6007 (backward (gnus-summary-find-prev unread))
6008 (t (gnus-summary-find-next unread))))
6010 (defun gnus-recenter (&optional n)
6011 "Center point in window and redisplay frame.
6012 Also do horizontal recentering."
6014 (when (and gnus-auto-center-summary
6015 (not (eq gnus-auto-center-summary 'vertical)))
6016 (gnus-horizontal-recenter))
6019 (defun gnus-summary-recenter ()
6020 "Center point in the summary window.
6021 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6022 displayed, no centering will be performed."
6023 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6024 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6026 (let* ((top (cond ((< (window-height) 4) 0)
6027 ((< (window-height) 7) 1)
6028 (t (if (numberp gnus-auto-center-summary)
6029 gnus-auto-center-summary
6031 (height (1- (window-height)))
6032 (bottom (save-excursion (goto-char (point-max))
6033 (forward-line (- height))
6035 (window (get-buffer-window (current-buffer))))
6036 ;; The user has to want it.
6037 (when gnus-auto-center-summary
6038 (when (get-buffer-window gnus-article-buffer)
6039 ;; Only do recentering when the article buffer is displayed,
6040 ;; Set the window start to either `bottom', which is the biggest
6041 ;; possible valid number, or the second line from the top,
6042 ;; whichever is the least.
6043 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6044 (if (> bottom top-pos)
6045 ;; Keep the second line from the top visible
6046 (set-window-start window top-pos t)
6047 ;; Try to keep the bottom line visible; if it's partially
6048 ;; obscured, either scroll one more line to make it fully
6049 ;; visible, or revert to using TOP-POS.
6051 (goto-char (point-max))
6053 (let ((last-line-start (point)))
6055 (set-window-start window (point) t)
6056 (when (not (pos-visible-in-window-p last-line-start window))
6058 (set-window-start window (min (point) top-pos) t)))))))
6059 ;; Do horizontal recentering while we're at it.
6060 (when (and (get-buffer-window (current-buffer) t)
6061 (not (eq gnus-auto-center-summary 'vertical)))
6062 (let ((selected (selected-window)))
6063 (select-window (get-buffer-window (current-buffer) t))
6064 (gnus-summary-position-point)
6065 (gnus-horizontal-recenter)
6066 (select-window selected))))))
6068 (defun gnus-summary-jump-to-group (newsgroup)
6069 "Move point to NEWSGROUP in group mode buffer."
6070 ;; Keep update point of group mode buffer if visible.
6071 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6072 (save-window-excursion
6073 ;; Take care of tree window mode.
6074 (when (get-buffer-window gnus-group-buffer)
6075 (pop-to-buffer gnus-group-buffer))
6076 (gnus-group-jump-to-group newsgroup))
6078 ;; Take care of tree window mode.
6079 (if (get-buffer-window gnus-group-buffer)
6080 (pop-to-buffer gnus-group-buffer)
6081 (set-buffer gnus-group-buffer))
6082 (gnus-group-jump-to-group newsgroup))))
6084 ;; This function returns a list of article numbers based on the
6085 ;; difference between the ranges of read articles in this group and
6086 ;; the range of active articles.
6087 (defun gnus-list-of-unread-articles (group)
6088 (let* ((read (gnus-info-read (gnus-get-info group)))
6089 (active (or (gnus-active group) (gnus-activate-group group)))
6092 ;; If none are read, then all are unread.
6094 (setq first (car active))
6095 ;; If the range of read articles is a single range, then the
6096 ;; first unread article is the article after the last read
6097 ;; article. Sounds logical, doesn't it?
6098 (if (and (not (listp (cdr read)))
6099 (or (< (car read) (car active))
6100 (progn (setq read (list read))
6102 (setq first (max (car active) (1+ (cdr read))))
6103 ;; `read' is a list of ranges.
6104 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6107 (setq first (car active)))
6110 (while (< first nlast)
6112 (setq first (1+ first))))
6113 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6114 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6115 (setq read (cdr read)))))
6116 ;; And add the last unread articles.
6117 (while (<= first last)
6119 (setq first (1+ first)))
6120 ;; Return the list of unread articles.
6121 (delq 0 (nreverse unread))))
6123 (defun gnus-list-of-read-articles (group)
6124 "Return a list of unread, unticked and non-dormant articles."
6125 (let* ((info (gnus-get-info group))
6126 (marked (gnus-info-marks info))
6127 (active (gnus-active group)))
6129 (gnus-list-range-difference
6130 (gnus-list-range-difference
6131 (gnus-sorted-complement
6132 (gnus-uncompress-range active)
6133 (gnus-list-of-unread-articles group))
6134 (cdr (assq 'dormant marked)))
6135 (cdr (assq 'tick marked))))))
6137 ;; Various summary commands
6139 (defun gnus-summary-select-article-buffer ()
6140 "Reconfigure windows to show article buffer."
6142 (if (not (gnus-buffer-live-p gnus-article-buffer))
6143 (error "There is no article buffer for this summary buffer")
6144 (gnus-configure-windows 'article)
6145 (select-window (get-buffer-window gnus-article-buffer))))
6147 (defun gnus-summary-universal-argument (arg)
6148 "Perform any operation on all articles that are process/prefixed."
6150 (let ((articles (gnus-summary-work-articles arg))
6157 (substitute-command-keys
6158 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6160 (gnus-error 1 "Undefined key")
6163 (gnus-summary-goto-subject (setq article (pop articles)))
6164 (let (gnus-newsgroup-processable)
6165 (command-execute func))
6166 (gnus-summary-remove-process-mark article)))))
6167 (gnus-summary-position-point))
6169 (defun gnus-summary-toggle-truncation (&optional arg)
6170 "Toggle truncation of summary lines.
6171 With arg, turn line truncation on iff arg is positive."
6173 (setq truncate-lines
6174 (if (null arg) (not truncate-lines)
6175 (> (prefix-numeric-value arg) 0)))
6178 (defun gnus-summary-reselect-current-group (&optional all rescan)
6179 "Exit and then reselect the current newsgroup.
6180 The prefix argument ALL means to select all articles."
6182 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6183 (error "Ephemeral groups can't be reselected"))
6184 (let ((current-subject (gnus-summary-article-number))
6185 (group gnus-newsgroup-name))
6186 (setq gnus-newsgroup-begin nil)
6188 ;; We have to adjust the point of group mode buffer because
6189 ;; point was moved to the next unread newsgroup by exiting.
6190 (gnus-summary-jump-to-group group)
6193 (save-window-excursion
6194 ;; Don't show group contents.
6195 (set-window-start (selected-window) (point-max))
6196 (gnus-group-get-new-news-this-group 1))))
6197 (gnus-group-read-group all t)
6198 (gnus-summary-goto-subject current-subject nil t)))
6200 (defun gnus-summary-rescan-group (&optional all)
6201 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6203 (gnus-summary-reselect-current-group all t))
6205 (defun gnus-summary-update-info (&optional non-destructive)
6207 (let ((group gnus-newsgroup-name))
6209 (when gnus-newsgroup-kill-headers
6210 (setq gnus-newsgroup-killed
6211 (gnus-compress-sequence
6213 (gnus-list-range-intersection
6214 gnus-newsgroup-unselected gnus-newsgroup-killed)
6215 gnus-newsgroup-unreads)
6217 (unless (listp (cdr gnus-newsgroup-killed))
6218 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6219 (let ((headers gnus-newsgroup-headers))
6220 ;; Set the new ranges of read articles.
6222 (set-buffer gnus-group-buffer)
6223 (gnus-undo-force-boundary))
6224 (gnus-update-read-articles
6225 group (gnus-sorted-union
6226 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6227 ;; Set the current article marks.
6228 (let ((gnus-newsgroup-scored
6229 (if (and (not gnus-save-score)
6230 (not non-destructive))
6232 gnus-newsgroup-scored)))
6234 (gnus-update-marks)))
6235 ;; Do the cross-ref thing.
6236 (when gnus-use-cross-reference
6237 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6238 ;; Do not switch windows but change the buffer to work.
6239 (set-buffer gnus-group-buffer)
6240 (unless (gnus-ephemeral-group-p group)
6241 (gnus-group-update-group group)))))))
6243 (defun gnus-summary-save-newsrc (&optional force)
6244 "Save the current number of read/marked articles in the dribble buffer.
6245 The dribble buffer will then be saved.
6246 If FORCE (the prefix), also save the .newsrc file(s)."
6248 (gnus-summary-update-info t)
6250 (gnus-save-newsrc-file)
6251 (gnus-dribble-save)))
6253 (defun gnus-summary-exit (&optional temporary)
6254 "Exit reading current newsgroup, and then return to group selection mode.
6255 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6257 (gnus-set-global-variables)
6258 (gnus-kill-save-kill-buffer)
6259 (gnus-async-halt-prefetch)
6260 (let* ((group gnus-newsgroup-name)
6261 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6264 (buf (current-buffer)))
6266 ;; Do adaptive scoring, and possibly save score files.
6267 (when gnus-newsgroup-adaptive
6268 (gnus-score-adaptive))
6269 (when gnus-use-scoring
6271 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6272 ;; If we have several article buffers, we kill them at exit.
6273 (unless gnus-single-article-buffer
6274 (gnus-kill-buffer gnus-original-article-buffer)
6275 (setq gnus-article-current nil))
6276 (when gnus-use-cache
6277 (gnus-cache-possibly-remove-articles)
6278 (gnus-cache-save-buffers))
6279 (gnus-async-prefetch-remove-group group)
6280 (when gnus-suppress-duplicates
6281 (gnus-dup-enter-articles))
6282 (when gnus-use-trees
6283 (gnus-tree-close group))
6284 (when gnus-use-cache
6285 (gnus-cache-write-active))
6286 ;; Remove entries for this group.
6287 (nnmail-purge-split-history (gnus-group-real-name group))
6288 ;; Make all changes in this group permanent.
6290 (gnus-run-hooks 'gnus-exit-group-hook)
6291 (gnus-summary-update-info))
6292 (gnus-close-group group)
6293 ;; Make sure where we were, and go to next newsgroup.
6294 (set-buffer gnus-group-buffer)
6296 (gnus-group-jump-to-group group))
6297 (gnus-run-hooks 'gnus-summary-exit-hook)
6298 (unless (or quit-config
6299 ;; If this group has disappeared from the summary
6300 ;; buffer, don't skip forwards.
6301 (not (string= group (gnus-group-group-name))))
6302 (gnus-group-next-unread-group 1))
6303 (setq group-point (point))
6306 ;; If we have several article buffers, we kill them at exit.
6307 (unless gnus-single-article-buffer
6308 (gnus-kill-buffer gnus-article-buffer)
6309 (gnus-kill-buffer gnus-original-article-buffer)
6310 (setq gnus-article-current nil))
6312 (if (not gnus-kill-summary-on-exit)
6314 (gnus-deaden-summary)
6316 ;; We set all buffer-local variables to nil. It is unclear why
6317 ;; this is needed, but if we don't, buffer-local variables are
6318 ;; not garbage-collected, it seems. This would the lead to en
6319 ;; ever-growing Emacs.
6320 (gnus-summary-clear-local-variables)
6321 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6322 (gnus-summary-clear-local-variables))
6323 (when (get-buffer gnus-article-buffer)
6324 (bury-buffer gnus-article-buffer))
6325 ;; We clear the global counterparts of the buffer-local
6326 ;; variables as well, just to be on the safe side.
6327 (set-buffer gnus-group-buffer)
6328 (gnus-summary-clear-local-variables)
6329 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6330 (gnus-summary-clear-local-variables)))
6331 (setq gnus-current-select-method gnus-select-method)
6332 (pop-to-buffer gnus-group-buffer)
6333 (if (not quit-config)
6335 (goto-char group-point)
6336 (gnus-configure-windows 'group 'force)
6337 (unless (pos-visible-in-window-p)
6338 (forward-line (/ (static-if (featurep 'xemacs)
6339 (window-displayed-height)
6340 (1- (window-height)))
6342 (set-window-start (selected-window) (point))
6343 (goto-char group-point)))
6344 (gnus-handle-ephemeral-exit quit-config))
6345 ;; Return to group mode buffer.
6346 (when (eq mode 'gnus-summary-mode)
6347 (gnus-kill-buffer buf))
6348 ;; Clear the current group name.
6350 (setq gnus-newsgroup-name nil)))))
6352 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6353 (defun gnus-summary-exit-no-update (&optional no-questions)
6354 "Quit reading current newsgroup without updating read article info."
6356 (let* ((group gnus-newsgroup-name)
6357 (quit-config (gnus-group-quit-config group)))
6358 (when (or no-questions
6360 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6361 (gnus-async-halt-prefetch)
6363 (delq 'gnus-summary-expire-articles
6364 (copy-sequence gnus-summary-prepare-exit-hook)))
6365 ;; If we have several article buffers, we kill them at exit.
6366 (unless gnus-single-article-buffer
6367 (gnus-kill-buffer gnus-article-buffer)
6368 (gnus-kill-buffer gnus-original-article-buffer)
6369 (setq gnus-article-current nil))
6370 (if (not gnus-kill-summary-on-exit)
6371 (gnus-deaden-summary)
6372 (gnus-close-group group)
6373 (gnus-summary-clear-local-variables)
6374 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6375 (gnus-summary-clear-local-variables))
6376 (set-buffer gnus-group-buffer)
6377 (gnus-summary-clear-local-variables)
6378 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6379 (gnus-summary-clear-local-variables))
6380 (when (get-buffer gnus-summary-buffer)
6381 (kill-buffer gnus-summary-buffer)))
6382 (unless gnus-single-article-buffer
6383 (setq gnus-article-current nil))
6384 (when gnus-use-trees
6385 (gnus-tree-close group))
6386 (gnus-async-prefetch-remove-group group)
6387 (when (get-buffer gnus-article-buffer)
6388 (bury-buffer gnus-article-buffer))
6389 ;; Return to the group buffer.
6390 (gnus-configure-windows 'group 'force)
6391 ;; Clear the current group name.
6392 (setq gnus-newsgroup-name nil)
6393 (when (equal (gnus-group-group-name) group)
6394 (gnus-group-next-unread-group 1))
6396 (gnus-handle-ephemeral-exit quit-config)))))
6398 (defun gnus-handle-ephemeral-exit (quit-config)
6399 "Handle movement when leaving an ephemeral group.
6400 The state which existed when entering the ephemeral is reset."
6401 (if (not (buffer-name (car quit-config)))
6402 (gnus-configure-windows 'group 'force)
6403 (set-buffer (car quit-config))
6404 (cond ((eq major-mode 'gnus-summary-mode)
6405 (gnus-set-global-variables))
6406 ((eq major-mode 'gnus-article-mode)
6408 ;; The `gnus-summary-buffer' variable may point
6409 ;; to the old summary buffer when using a single
6411 (unless (gnus-buffer-live-p gnus-summary-buffer)
6412 (set-buffer gnus-group-buffer))
6413 (set-buffer gnus-summary-buffer)
6414 (gnus-set-global-variables))))
6415 (if (or (eq (cdr quit-config) 'article)
6416 (eq (cdr quit-config) 'pick))
6418 ;; The current article may be from the ephemeral group
6419 ;; thus it is best that we reload this article
6420 (gnus-summary-show-article)
6421 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6422 (gnus-configure-windows 'pick 'force)
6423 (gnus-configure-windows (cdr quit-config) 'force)))
6424 (gnus-configure-windows (cdr quit-config) 'force))
6425 (when (eq major-mode 'gnus-summary-mode)
6426 (gnus-summary-next-subject 1 nil t)
6427 (gnus-summary-recenter)
6428 (gnus-summary-position-point))))
6430 (defun gnus-summary-preview-mime-message ()
6431 "MIME decode and play this message."
6433 (let ((gnus-break-pages nil)
6435 (gnus-summary-select-article gnus-show-all-headers t))
6436 (let ((w (get-buffer-window gnus-article-buffer)))
6438 (select-window (get-buffer-window gnus-article-buffer)))))
6442 (defvar gnus-dead-summary-mode-map nil)
6444 (unless gnus-dead-summary-mode-map
6445 (setq gnus-dead-summary-mode-map (make-keymap))
6446 (suppress-keymap gnus-dead-summary-mode-map)
6447 (substitute-key-definition
6448 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6449 (dolist (key '("\C-d" "\r" "\177" [delete]))
6450 (define-key gnus-dead-summary-mode-map
6451 key 'gnus-summary-wake-up-the-dead))
6452 (dolist (key '("q" "Q"))
6453 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6455 (defvar gnus-dead-summary-mode nil
6456 "Minor mode for Gnus summary buffers.")
6458 (defun gnus-dead-summary-mode (&optional arg)
6459 "Minor mode for Gnus summary buffers."
6461 (when (eq major-mode 'gnus-summary-mode)
6462 (make-local-variable 'gnus-dead-summary-mode)
6463 (setq gnus-dead-summary-mode
6464 (if (null arg) (not gnus-dead-summary-mode)
6465 (> (prefix-numeric-value arg) 0)))
6466 (when gnus-dead-summary-mode
6467 (gnus-add-minor-mode
6468 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6470 (defun gnus-deaden-summary ()
6471 "Make the current summary buffer into a dead summary buffer."
6472 ;; Kill any previous dead summary buffer.
6473 (when (and gnus-dead-summary
6474 (buffer-name gnus-dead-summary))
6476 (set-buffer gnus-dead-summary)
6477 (when gnus-dead-summary-mode
6478 (kill-buffer (current-buffer)))))
6479 ;; Make this the current dead summary.
6480 (setq gnus-dead-summary (current-buffer))
6481 (gnus-dead-summary-mode 1)
6482 (let ((name (buffer-name)))
6483 (when (string-match "Summary" name)
6485 (concat (substring name 0 (match-beginning 0)) "Dead "
6486 (substring name (match-beginning 0)))
6490 (defun gnus-kill-or-deaden-summary (buffer)
6491 "Kill or deaden the summary BUFFER."
6493 (when (and (buffer-name buffer)
6494 (not gnus-single-article-buffer))
6497 (gnus-kill-buffer gnus-article-buffer)
6498 (gnus-kill-buffer gnus-original-article-buffer)))
6501 (gnus-kill-summary-on-exit
6502 (when (and gnus-use-trees
6503 (gnus-buffer-exists-p buffer))
6506 (gnus-tree-close gnus-newsgroup-name)))
6507 (gnus-kill-buffer buffer))
6508 ;; Deaden the buffer.
6509 ((gnus-buffer-exists-p buffer)
6512 (gnus-deaden-summary))))))
6514 (defun gnus-summary-wake-up-the-dead (&rest args)
6515 "Wake up the dead summary buffer."
6517 (gnus-dead-summary-mode -1)
6518 (let ((name (buffer-name)))
6519 (when (string-match "Dead " name)
6521 (concat (substring name 0 (match-beginning 0))
6522 (substring name (match-end 0)))
6524 (gnus-message 3 "This dead summary is now alive again"))
6526 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6527 (defun gnus-summary-fetch-faq (&optional faq-dir)
6528 "Fetch the FAQ for the current group.
6529 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6533 (when current-prefix-arg
6535 "Faq dir: " (and (listp gnus-group-faq-directory)
6536 (mapcar (lambda (file) (list file))
6537 gnus-group-faq-directory))))))
6538 (let (gnus-faq-buffer)
6539 (when (setq gnus-faq-buffer
6540 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6541 (gnus-configure-windows 'summary-faq))))
6543 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6544 (defun gnus-summary-describe-group (&optional force)
6545 "Describe the current newsgroup."
6547 (gnus-group-describe-group force gnus-newsgroup-name))
6549 (defun gnus-summary-describe-briefly ()
6550 "Describe summary mode commands briefly."
6552 (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")))
6554 ;; Walking around group mode buffer from summary mode.
6556 (defun gnus-summary-next-group (&optional no-article target-group backward)
6557 "Exit current newsgroup and then select next unread newsgroup.
6558 If prefix argument NO-ARTICLE is non-nil, no article is selected
6559 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6560 previous group instead."
6562 ;; Stop pre-fetching.
6563 (gnus-async-halt-prefetch)
6564 (let ((current-group gnus-newsgroup-name)
6565 (current-buffer (current-buffer))
6567 (gnus-summary-exit t)
6568 (while (not entered)
6569 ;; Then we find what group we are supposed to enter.
6570 (set-buffer gnus-group-buffer)
6571 (gnus-group-jump-to-group current-group)
6574 (if (eq gnus-keep-same-level 'best)
6575 (gnus-summary-best-group gnus-newsgroup-name)
6576 (gnus-summary-search-group backward gnus-keep-same-level))))
6577 (if (not target-group)
6578 ;; There are no further groups, so we return to the group
6581 (gnus-message 5 "Returning to the group buffer")
6583 (when (gnus-buffer-live-p current-buffer)
6584 (set-buffer current-buffer)
6585 (gnus-summary-exit))
6586 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6587 ;; We try to enter the target group.
6588 (gnus-group-jump-to-group target-group)
6589 (let ((unreads (gnus-group-group-unread)))
6590 (if (and (or (eq t unreads)
6591 (and unreads (not (zerop unreads))))
6593 ;; Now we semi-exit this group to update Xrefs
6594 ;; and all variables. We can't do a real exit,
6595 ;; because the window conf must remain the same
6596 ;; in case the user is prompted for info, and we
6597 ;; don't want the window conf to change before
6599 (when (gnus-buffer-live-p current-buffer)
6600 (set-buffer current-buffer)
6601 (gnus-summary-exit t))
6602 (gnus-summary-read-group
6603 target-group nil no-article
6604 (and (buffer-name current-buffer) current-buffer)
6607 (setq current-group target-group
6608 target-group nil)))))))
6610 (defun gnus-summary-prev-group (&optional no-article)
6611 "Exit current newsgroup and then select previous unread newsgroup.
6612 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6614 (gnus-summary-next-group no-article nil t))
6616 ;; Walking around summary lines.
6618 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6619 "Go to the first unread subject.
6620 If UNREAD is non-nil, go to the first unread article.
6621 Returns the article selected or nil if there are no unread articles."
6626 ((null gnus-newsgroup-data)
6627 (gnus-message 3 "No articles in the group")
6629 ;; Pick the first article.
6631 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6632 (gnus-data-number (car gnus-newsgroup-data)))
6633 ;; No unread articles.
6634 ((null gnus-newsgroup-unreads)
6635 (gnus-message 3 "No more unread articles")
6637 ;; Find the first unread article.
6639 (let ((data gnus-newsgroup-data))
6641 (and (not (and undownloaded
6642 (eq gnus-undownloaded-mark
6643 (gnus-data-mark (car data)))))
6646 (gnus-data-number (car data))
6647 gnus-newsgroup-unseen))
6648 (not (gnus-data-unread-p (car data))))
6649 (not (gnus-data-unread-p (car data))))))
6650 (setq data (cdr data)))
6652 (goto-char (gnus-data-pos (car data)))
6653 (gnus-data-number (car data))))))
6654 (gnus-summary-position-point)))
6656 (defun gnus-summary-next-subject (n &optional unread dont-display)
6657 "Go to next N'th summary line.
6658 If N is negative, go to the previous N'th subject line.
6659 If UNREAD is non-nil, only unread articles are selected.
6660 The difference between N and the actual number of steps taken is
6663 (let ((backward (< n 0))
6667 (gnus-summary-find-prev unread)
6668 (gnus-summary-find-next unread)))
6669 (unless (zerop (setq n (1- n)))
6670 (gnus-summary-show-thread)))
6672 (gnus-message 7 "No more%s articles"
6673 (if unread " unread" "")))
6674 (unless dont-display
6675 (gnus-summary-recenter)
6676 (gnus-summary-position-point))
6679 (defun gnus-summary-next-unread-subject (n)
6680 "Go to next N'th unread summary line."
6682 (gnus-summary-next-subject n t))
6684 (defun gnus-summary-prev-subject (n &optional unread)
6685 "Go to previous N'th summary line.
6686 If optional argument UNREAD is non-nil, only unread article is selected."
6688 (gnus-summary-next-subject (- n) unread))
6690 (defun gnus-summary-prev-unread-subject (n)
6691 "Go to previous N'th unread summary line."
6693 (gnus-summary-next-subject (- n) t))
6695 (defun gnus-summary-goto-subject (article &optional force silent)
6696 "Go the subject line of ARTICLE.
6697 If FORCE, also allow jumping to articles not currently shown."
6698 (interactive "nArticle number: ")
6699 (unless (numberp article)
6700 (error "Article %s is not a number" article))
6702 (data (gnus-data-find article)))
6703 ;; We read in the article if we have to.
6706 (gnus-summary-insert-subject
6708 (if (or (numberp force) (vectorp force)) force)
6710 (setq data (gnus-data-find article)))
6715 (gnus-message 3 "Can't find article %d" article))
6717 (let ((pt (gnus-data-pos data)))
6719 (gnus-summary-set-article-display-arrow pt))
6720 (gnus-summary-position-point)
6723 ;; Walking around summary lines with displaying articles.
6725 (defun gnus-summary-expand-window (&optional arg)
6726 "Make the summary buffer take up the entire Emacs frame.
6727 Given a prefix, will force an `article' buffer configuration."
6730 (gnus-configure-windows 'article 'force)
6731 (gnus-configure-windows 'summary 'force)))
6733 (defun gnus-summary-display-article (article &optional all-header)
6734 "Display ARTICLE in article buffer."
6735 (when (gnus-buffer-live-p gnus-article-buffer)
6736 (with-current-buffer gnus-article-buffer
6737 (set-buffer-multibyte t)))
6738 (gnus-set-global-variables)
6739 (when (gnus-buffer-live-p gnus-article-buffer)
6740 (with-current-buffer gnus-article-buffer
6741 (setq gnus-article-charset gnus-newsgroup-charset)
6742 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6743 (set-buffer-multibyte t)))
6747 (if gnus-summary-display-article-function
6748 (funcall gnus-summary-display-article-function article all-header)
6749 (gnus-article-prepare article all-header))
6750 (with-current-buffer gnus-article-buffer
6751 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6753 (gnus-run-hooks 'gnus-select-article-hook)
6754 (when (and gnus-current-article
6755 (not (zerop gnus-current-article)))
6756 (gnus-summary-goto-subject gnus-current-article))
6757 (gnus-summary-recenter)
6758 (when (and gnus-use-trees gnus-show-threads)
6759 (gnus-possibly-generate-tree article)
6760 (gnus-highlight-selected-tree article))
6761 ;; Successfully display article.
6762 (gnus-article-set-window-start
6763 (cdr (assq article gnus-newsgroup-bookmarks))))))
6765 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6766 "Select the current article.
6767 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6768 non-nil, the article will be re-fetched even if it already present in
6769 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6771 ;; Make sure we are in the summary buffer to work around bbdb bug.
6772 (unless (eq major-mode 'gnus-summary-mode)
6773 (set-buffer gnus-summary-buffer))
6774 (let ((article (or article (gnus-summary-article-number)))
6775 (all-headers (not (not all-headers))) ;Must be T or NIL.
6776 gnus-summary-display-article-function)
6778 (gnus-summary-article-pseudo-p article)
6779 (error "This is a pseudo-article"))
6781 (set-buffer gnus-summary-buffer)
6782 (if (or (and gnus-single-article-buffer
6783 (or (null gnus-current-article)
6784 (null gnus-article-current)
6785 (null (get-buffer gnus-article-buffer))
6786 (not (eq article (cdr gnus-article-current)))
6787 (not (equal (car gnus-article-current)
6788 gnus-newsgroup-name))))
6789 (and (not gnus-single-article-buffer)
6790 (or (null gnus-current-article)
6791 (not (eq gnus-current-article article))))
6793 ;; The requested article is different from the current article.
6795 (gnus-summary-display-article article all-headers)
6796 (gnus-article-set-window-start
6797 (cdr (assq article gnus-newsgroup-bookmarks)))
6801 (defun gnus-summary-force-verify-and-decrypt ()
6803 (let ((mm-verify-option 'known)
6804 (mm-decrypt-option 'known)
6805 (gnus-buttonized-mime-types (append (list "multipart/signed"
6806 "multipart/encrypted")
6807 gnus-buttonized-mime-types)))
6808 (gnus-summary-select-article nil 'force)))
6810 (defun gnus-summary-set-current-mark (&optional current-mark)
6811 "Obsolete function."
6814 (defun gnus-summary-next-article (&optional unread subject backward push)
6815 "Select the next article.
6816 If UNREAD, only unread articles are selected.
6817 If SUBJECT, only articles with SUBJECT are selected.
6818 If BACKWARD, the previous article is selected instead of the next."
6821 ;; Is there such an article?
6822 ((and (gnus-summary-search-forward unread subject backward)
6823 (or (gnus-summary-display-article (gnus-summary-article-number))
6824 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6825 (gnus-summary-position-point))
6826 ;; If not, we try the first unread, if that is wanted.
6828 gnus-auto-select-same
6829 (gnus-summary-first-unread-article))
6830 (gnus-summary-position-point)
6831 (gnus-message 6 "Wrapped"))
6832 ;; Try to get next/previous article not displayed in this group.
6833 ((and gnus-auto-extend-newsgroup
6834 (not unread) (not subject))
6835 (gnus-summary-goto-article
6836 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6837 nil (count-lines (point-min) (point))))
6838 ;; Go to next/previous group.
6840 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6841 (gnus-summary-jump-to-group gnus-newsgroup-name))
6842 (let ((cmd last-command-char)
6845 (set-buffer gnus-group-buffer)
6848 (if (eq gnus-keep-same-level 'best)
6849 (gnus-summary-best-group gnus-newsgroup-name)
6850 (gnus-summary-search-group backward gnus-keep-same-level))))
6851 ;; For some reason, the group window gets selected. We change
6853 (select-window (get-buffer-window (current-buffer)))
6854 ;; Select next unread newsgroup automagically.
6856 ((or (not gnus-auto-select-next)
6858 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6859 ((or (eq gnus-auto-select-next 'quietly)
6860 (and (eq gnus-auto-select-next 'slightly-quietly)
6862 (and (eq gnus-auto-select-next 'almost-quietly)
6863 (gnus-summary-last-article-p)))
6865 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6867 (gnus-message 7 "No more%s articles (%s)..."
6868 (if unread " unread" "")
6869 (if group (concat "selecting " group)
6871 (gnus-summary-next-group nil group backward)))
6873 (when (gnus-key-press-event-p last-input-event)
6874 (gnus-summary-walk-group-buffer
6875 gnus-newsgroup-name cmd unread backward point))))))))
6877 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6878 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6879 (?\C-p (gnus-group-prev-unread-group 1))))
6880 (cursor-in-echo-area t)
6881 keve key group ended)
6883 (set-buffer gnus-group-buffer)
6886 (if (eq gnus-keep-same-level 'best)
6887 (gnus-summary-best-group gnus-newsgroup-name)
6888 (gnus-summary-search-group backward gnus-keep-same-level))))
6891 5 "No more%s articles%s" (if unread " unread" "")
6893 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6894 (format " (Type %s for %s [%s])"
6895 (single-key-description cmd) group
6896 (car (gnus-gethash group gnus-newsrc-hashtb)))
6897 (format " (Type %s to exit %s)"
6898 (single-key-description cmd)
6899 gnus-newsgroup-name)))
6900 ;; Confirm auto selection.
6901 (setq key (car (setq keve (gnus-read-event-char))))
6904 ((assq key keystrokes)
6905 (let ((obuf (current-buffer)))
6906 (switch-to-buffer gnus-group-buffer)
6908 (gnus-group-jump-to-group group))
6909 (eval (cadr (assq key keystrokes)))
6910 (setq group (gnus-group-group-name))
6911 (switch-to-buffer obuf))
6915 (gnus-ephemeral-group-p gnus-newsgroup-name))
6917 (gnus-summary-next-group nil group backward)))
6919 (push (cdr keve) unread-command-events))))))
6921 (defun gnus-summary-next-unread-article ()
6922 "Select unread article after current one."
6924 (gnus-summary-next-article
6925 (or (not (eq gnus-summary-goto-unread 'never))
6926 (gnus-summary-last-article-p (gnus-summary-article-number)))
6927 (and gnus-auto-select-same
6928 (gnus-summary-article-subject))))
6930 (defun gnus-summary-prev-article (&optional unread subject)
6931 "Select the article after the current one.
6932 If UNREAD is non-nil, only unread articles are selected."
6934 (gnus-summary-next-article unread subject t))
6936 (defun gnus-summary-prev-unread-article ()
6937 "Select unread article before current one."
6939 (gnus-summary-prev-article
6940 (or (not (eq gnus-summary-goto-unread 'never))
6941 (gnus-summary-first-article-p (gnus-summary-article-number)))
6942 (and gnus-auto-select-same
6943 (gnus-summary-article-subject))))
6945 (defun gnus-summary-next-page (&optional lines circular)
6946 "Show next page of the selected article.
6947 If at the end of the current article, select the next article.
6948 LINES says how many lines should be scrolled up.
6950 If CIRCULAR is non-nil, go to the start of the article instead of
6951 selecting the next article when reaching the end of the current
6954 (setq gnus-summary-buffer (current-buffer))
6955 (gnus-set-global-variables)
6956 (let ((article (gnus-summary-article-number))
6957 (article-window (get-buffer-window gnus-article-buffer t))
6959 ;; If the buffer is empty, we have no article.
6961 (error "No article to select"))
6962 (gnus-configure-windows 'article)
6963 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6964 (if (and (eq gnus-summary-goto-unread 'never)
6965 (not (gnus-summary-last-article-p article)))
6966 (gnus-summary-next-article)
6967 (gnus-summary-next-unread-article))
6968 (if (or (null gnus-current-article)
6969 (null gnus-article-current)
6970 (/= article (cdr gnus-article-current))
6971 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6972 ;; Selected subject is different from current article's.
6973 (gnus-summary-display-article article)
6974 (when article-window
6975 (gnus-eval-in-buffer-window gnus-article-buffer
6976 (setq endp (gnus-article-next-page lines)))
6979 (gnus-summary-beginning-of-article))
6981 (gnus-message 3 "End of message"))
6983 (if (and (eq gnus-summary-goto-unread 'never)
6984 (not (gnus-summary-last-article-p article)))
6985 (gnus-summary-next-article)
6986 (gnus-summary-next-unread-article))))))))
6987 (gnus-summary-recenter)
6988 (gnus-summary-position-point)))
6990 (defun gnus-summary-prev-page (&optional lines move)
6991 "Show previous page of selected article.
6992 Argument LINES specifies lines to be scrolled down.
6993 If MOVE, move to the previous unread article if point is at
6994 the beginning of the buffer."
6996 (let ((article (gnus-summary-article-number))
6997 (article-window (get-buffer-window gnus-article-buffer t))
6999 (gnus-configure-windows 'article)
7000 (if (or (null gnus-current-article)
7001 (null gnus-article-current)
7002 (/= article (cdr gnus-article-current))
7003 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7004 ;; Selected subject is different from current article's.
7005 (gnus-summary-display-article article)
7006 (gnus-summary-recenter)
7007 (when article-window
7008 (gnus-eval-in-buffer-window gnus-article-buffer
7009 (setq endp (gnus-article-prev-page lines)))
7010 (when (and move endp)
7012 (gnus-message 3 "Beginning of message"))
7014 (if (and (eq gnus-summary-goto-unread 'never)
7015 (not (gnus-summary-first-article-p article)))
7016 (gnus-summary-prev-article)
7017 (gnus-summary-prev-unread-article))))))))
7018 (gnus-summary-position-point))
7020 (defun gnus-summary-prev-page-or-article (&optional lines)
7021 "Show previous page of selected article.
7022 Argument LINES specifies lines to be scrolled down.
7023 If at the beginning of the article, go to the next article."
7025 (gnus-summary-prev-page lines t))
7027 (defun gnus-summary-scroll-up (lines)
7028 "Scroll up (or down) one line current article.
7029 Argument LINES specifies lines to be scrolled up (or down if negative)."
7031 (gnus-configure-windows 'article)
7032 (gnus-summary-show-thread)
7033 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7034 (gnus-eval-in-buffer-window gnus-article-buffer
7036 (when (gnus-article-next-page lines)
7037 (gnus-message 3 "End of message")))
7039 (gnus-article-prev-page (- lines))))))
7040 (gnus-summary-recenter)
7041 (gnus-summary-position-point))
7043 (defun gnus-summary-scroll-down (lines)
7044 "Scroll down (or up) one line current article.
7045 Argument LINES specifies lines to be scrolled down (or up if negative)."
7047 (gnus-summary-scroll-up (- lines)))
7049 (defun gnus-summary-next-same-subject ()
7050 "Select next article which has the same subject as current one."
7052 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7054 (defun gnus-summary-prev-same-subject ()
7055 "Select previous article which has the same subject as current one."
7057 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7059 (defun gnus-summary-next-unread-same-subject ()
7060 "Select next unread article which has the same subject as current one."
7062 (gnus-summary-next-article t (gnus-summary-article-subject)))
7064 (defun gnus-summary-prev-unread-same-subject ()
7065 "Select previous unread article which has the same subject as current one."
7067 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7069 (defun gnus-summary-first-unread-article ()
7070 "Select the first unread article.
7071 Return nil if there are no unread articles."
7074 (when (gnus-summary-first-subject t)
7075 (gnus-summary-show-thread)
7076 (gnus-summary-first-subject t)
7077 (gnus-summary-display-article (gnus-summary-article-number)))
7078 (gnus-summary-position-point)))
7080 (defun gnus-summary-first-unread-subject ()
7081 "Place the point on the subject line of the first unread article.
7082 Return nil if there are no unread articles."
7085 (when (gnus-summary-first-subject t)
7086 (gnus-summary-show-thread)
7087 (gnus-summary-first-subject t))
7088 (gnus-summary-position-point)))
7090 (defun gnus-summary-first-unseen-subject ()
7091 "Place the point on the subject line of the first unseen article.
7092 Return nil if there are no unseen articles."
7095 (when (gnus-summary-first-subject t t t)
7096 (gnus-summary-show-thread)
7097 (gnus-summary-first-subject t t t))
7098 (gnus-summary-position-point)))
7100 (defun gnus-summary-first-unseen-or-unread-subject ()
7101 "Place the point on the subject line of the first unseen article.
7102 Return nil if there are no unseen articles."
7105 (unless (when (gnus-summary-first-subject t t t)
7106 (gnus-summary-show-thread)
7107 (gnus-summary-first-subject t t t))
7108 (when (gnus-summary-first-subject t)
7109 (gnus-summary-show-thread)
7110 (gnus-summary-first-subject t)))
7111 (gnus-summary-position-point)))
7113 (defun gnus-summary-first-article ()
7114 "Select the first article.
7115 Return nil if there are no articles."
7118 (when (gnus-summary-first-subject)
7119 (gnus-summary-show-thread)
7120 (gnus-summary-first-subject)
7121 (gnus-summary-display-article (gnus-summary-article-number)))
7122 (gnus-summary-position-point)))
7124 (defun gnus-summary-best-unread-article (&optional arg)
7125 "Select the unread article with the highest score.
7126 If given a prefix argument, select the next unread article that has a
7127 score higher than the default score."
7129 (let ((article (if arg
7130 (gnus-summary-better-unread-subject)
7131 (gnus-summary-best-unread-subject))))
7133 (gnus-summary-goto-article article)
7134 (error "No unread articles"))))
7136 (defun gnus-summary-best-unread-subject ()
7137 "Select the unread subject with the highest score."
7139 (let ((best -1000000)
7140 (data gnus-newsgroup-data)
7143 (and (gnus-data-unread-p (car data))
7145 (gnus-summary-article-score (gnus-data-number (car data))))
7148 article (gnus-data-number (car data))))
7149 (setq data (cdr data)))
7151 (gnus-summary-goto-subject article))
7152 (gnus-summary-position-point)
7155 (defun gnus-summary-better-unread-subject ()
7156 "Select the first unread subject that has a score over the default score."
7158 (let ((data gnus-newsgroup-data)
7160 (while (and (setq article (gnus-data-number (car data)))
7161 (or (gnus-data-read-p (car data))
7162 (not (> (gnus-summary-article-score article)
7163 gnus-summary-default-score))))
7164 (setq data (cdr data)))
7166 (gnus-summary-goto-subject article))
7167 (gnus-summary-position-point)
7170 (defun gnus-summary-last-subject ()
7171 "Go to the last displayed subject line in the group."
7172 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7174 (gnus-summary-goto-subject article))))
7176 (defun gnus-summary-goto-article (article &optional all-headers force)
7177 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7178 If ALL-HEADERS is non-nil, no header lines are hidden.
7179 If FORCE, go to the article even if it isn't displayed. If FORCE
7180 is a number, it is the line the article is to be displayed on."
7184 "Article number or Message-ID: "
7185 (mapcar (lambda (number) (list (int-to-string number)))
7186 gnus-newsgroup-limit))
7190 (if (and (stringp article)
7191 (string-match "@" article))
7192 (gnus-summary-refer-article article)
7193 (when (stringp article)
7194 (setq article (string-to-number article)))
7195 (if (gnus-summary-goto-subject article force)
7196 (gnus-summary-display-article article all-headers)
7197 (gnus-message 4 "Couldn't go to article %s" article) nil))
7198 (gnus-summary-position-point)))
7200 (defun gnus-summary-goto-last-article ()
7201 "Go to the previously read article."
7204 (when gnus-last-article
7205 (gnus-summary-goto-article gnus-last-article nil t))
7206 (gnus-summary-position-point)))
7208 (defun gnus-summary-pop-article (number)
7209 "Pop one article off the history and go to the previous.
7210 NUMBER articles will be popped off."
7213 (setq gnus-newsgroup-history
7214 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7216 (gnus-summary-goto-article (car to) nil t)
7217 (error "Article history empty")))
7218 (gnus-summary-position-point))
7220 ;; Summary commands and functions for limiting the summary buffer.
7222 (defun gnus-summary-limit-to-articles (n)
7223 "Limit the summary buffer to the next N articles.
7224 If not given a prefix, use the process marked articles instead."
7227 (let ((articles (gnus-summary-work-articles n)))
7228 (setq gnus-newsgroup-processable nil)
7229 (gnus-summary-limit articles))
7230 (gnus-summary-position-point)))
7232 (defun gnus-summary-pop-limit (&optional total)
7233 "Restore the previous limit.
7234 If given a prefix, remove all limits."
7237 (setq gnus-newsgroup-limits
7238 (list (mapcar (lambda (h) (mail-header-number h))
7239 gnus-newsgroup-headers))))
7240 (unless gnus-newsgroup-limits
7241 (error "No limit to pop"))
7243 (gnus-summary-limit nil 'pop)
7244 (gnus-summary-position-point)))
7246 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7247 "Limit the summary buffer to articles that have subjects that match a regexp.
7248 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7250 (list (read-string (if current-prefix-arg
7251 "Exclude subject (regexp): "
7252 "Limit to subject (regexp): "))
7253 nil current-prefix-arg))
7255 (setq header "subject"))
7256 (when (not (equal "" subject))
7258 (let ((articles (gnus-summary-find-matching
7259 (or header "subject") subject 'all nil nil
7262 (error "Found no matches for \"%s\"" subject))
7263 (gnus-summary-limit articles))
7264 (gnus-summary-position-point))))
7266 (defun gnus-summary-limit-to-author (from &optional not-matching)
7267 "Limit the summary buffer to articles that have authors that match a regexp.
7268 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7270 (list (read-string (if current-prefix-arg
7271 "Exclude author (regexp): "
7272 "Limit to author (regexp): "))
7273 current-prefix-arg))
7274 (gnus-summary-limit-to-subject from "from" not-matching))
7276 (defun gnus-summary-limit-to-age (age &optional younger-p)
7277 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7278 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7279 articles that are younger than AGE days."
7281 (let ((younger current-prefix-arg)
7284 (while (not days-got)
7285 (setq days (if younger
7286 (read-string "Limit to articles within (in days): ")
7287 (read-string "Limit to articles older than (in days): ")))
7288 (when (> (length days) 0)
7289 (setq days (read days)))
7295 (setq younger (not younger))
7296 (setq days (* days -1)))))
7297 (message "Please enter a number.")
7299 (list days younger)))
7301 (let ((data gnus-newsgroup-data)
7302 (cutoff (days-to-time age))
7303 articles d date is-younger)
7304 (while (setq d (pop data))
7305 (when (and (vectorp (gnus-data-header d))
7306 (setq date (mail-header-date (gnus-data-header d))))
7307 (setq is-younger (time-less-p
7308 (time-since (condition-case ()
7315 (push (gnus-data-number d) articles))))
7316 (gnus-summary-limit (nreverse articles)))
7317 (gnus-summary-position-point)))
7319 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7320 "Limit the summary buffer to articles that match an 'extra' header."
7324 (gnus-completing-read-with-default
7325 (symbol-name (car gnus-extra-headers))
7326 (if current-prefix-arg
7327 "Exclude extra header:"
7328 "Limit extra header:")
7330 (cons (symbol-name x) x))
7335 (read-string (format "%s header %s (regexp): "
7336 (if current-prefix-arg "Exclude" "Limit to")
7338 current-prefix-arg)))
7339 (when (not (equal "" regexp))
7341 (let ((articles (gnus-summary-find-matching
7342 (cons 'extra header) regexp 'all nil nil
7345 (error "Found no matches for \"%s\"" regexp))
7346 (gnus-summary-limit articles))
7347 (gnus-summary-position-point))))
7349 (defun gnus-summary-limit-to-display-predicate ()
7350 "Limit the summary buffer to the predicated in the `display' group parameter."
7352 (unless gnus-newsgroup-display
7353 (error "There is no `display' group parameter"))
7355 (dolist (number gnus-newsgroup-articles)
7356 (when (funcall gnus-newsgroup-display)
7357 (push number articles)))
7358 (gnus-summary-limit articles))
7359 (gnus-summary-position-point))
7361 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7363 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7365 (defun gnus-summary-limit-to-unread (&optional all)
7366 "Limit the summary buffer to articles that are not marked as read.
7367 If ALL is non-nil, limit strictly to unread articles."
7370 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7371 (gnus-summary-limit-to-marks
7372 ;; Concat all the marks that say that an article is read and have
7374 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7375 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7376 gnus-low-score-mark gnus-expirable-mark
7377 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7378 gnus-duplicate-mark gnus-souped-mark)
7381 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7382 (make-obsolete 'gnus-summary-delete-marked-with
7383 'gnus-summary-limit-exclude-marks)
7385 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7386 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7387 If REVERSE, limit the summary buffer to articles that are marked
7388 with MARKS. MARKS can either be a string of marks or a list of marks.
7389 Returns how many articles were removed."
7390 (interactive "sMarks: ")
7391 (gnus-summary-limit-to-marks marks t))
7393 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7394 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7395 If REVERSE (the prefix), limit the summary buffer to articles that are
7396 not marked with MARKS. MARKS can either be a string of marks or a
7398 Returns how many articles were removed."
7399 (interactive "sMarks: \nP")
7401 (let ((data gnus-newsgroup-data)
7402 (marks (if (listp marks) marks
7403 (append marks nil))) ; Transform to list.
7406 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7407 (memq (gnus-data-mark (car data)) marks))
7408 (push (gnus-data-number (car data)) articles))
7409 (setq data (cdr data)))
7410 (gnus-summary-limit articles))
7411 (gnus-summary-position-point)))
7413 (defun gnus-summary-limit-to-score (score)
7414 "Limit to articles with score at or above SCORE."
7415 (interactive "NLimit to articles with score of at least: ")
7416 (let ((data gnus-newsgroup-data)
7419 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7421 (push (gnus-data-number (car data)) articles))
7422 (setq data (cdr data)))
7424 (gnus-summary-limit articles)
7425 (gnus-summary-position-point))))
7427 (defun gnus-summary-limit-to-unseen ()
7428 "Limit to unseen articles."
7431 (gnus-summary-limit gnus-newsgroup-unseen)
7432 (gnus-summary-position-point)))
7434 (defun gnus-summary-limit-include-thread (id)
7435 "Display all the hidden articles that is in the thread with ID in it.
7436 When called interactively, ID is the Message-ID of the current
7438 (interactive (list (mail-header-id (gnus-summary-article-header))))
7439 (let ((articles (gnus-articles-in-thread
7440 (gnus-id-to-thread (gnus-root-id id)))))
7442 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7443 (gnus-summary-limit-include-matching-articles
7445 (regexp-quote (gnus-simplify-subject-re
7446 (mail-header-subject (gnus-id-to-header id)))))
7447 (gnus-summary-position-point))))
7449 (defun gnus-summary-limit-include-matching-articles (header regexp)
7450 "Display all the hidden articles that have HEADERs that match REGEXP."
7451 (interactive (list (read-string "Match on header: ")
7452 (read-string "Regexp: ")))
7453 (let ((articles (gnus-find-matching-articles header regexp)))
7455 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7456 (gnus-summary-position-point))))
7458 (defun gnus-summary-limit-include-dormant ()
7459 "Display all the hidden articles that are marked as dormant.
7460 Note that this command only works on a subset of the articles currently
7461 fetched for this group."
7463 (unless gnus-newsgroup-dormant
7464 (error "There are no dormant articles in this group"))
7466 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7467 (gnus-summary-position-point)))
7469 (defun gnus-summary-limit-exclude-dormant ()
7470 "Hide all dormant articles."
7473 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7474 (gnus-summary-position-point)))
7476 (defun gnus-summary-limit-exclude-childless-dormant ()
7477 "Hide all dormant articles that have no children."
7479 (let ((data (gnus-data-list t))
7480 articles d children)
7481 ;; Find all articles that are either not dormant or have
7483 (while (setq d (pop data))
7484 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7486 (gnus-article-children (gnus-data-number d)))
7489 (when (memq (car children) articles)
7494 (push (gnus-data-number d) articles)))
7497 (gnus-summary-limit articles)
7498 (gnus-summary-position-point))))
7500 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7501 "Mark all unread excluded articles as read.
7502 If ALL, mark even excluded ticked and dormants as read."
7504 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7505 (let ((articles (gnus-sorted-ndifference
7507 (mapcar (lambda (h) (mail-header-number h))
7508 gnus-newsgroup-headers)
7510 gnus-newsgroup-limit))
7512 (setq gnus-newsgroup-unreads
7513 (gnus-sorted-intersection gnus-newsgroup-unreads
7514 gnus-newsgroup-limit))
7516 (setq gnus-newsgroup-dormant nil
7517 gnus-newsgroup-marked nil
7518 gnus-newsgroup-reads
7520 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7521 gnus-newsgroup-reads))
7522 (while (setq article (pop articles))
7523 (unless (or (memq article gnus-newsgroup-dormant)
7524 (memq article gnus-newsgroup-marked))
7525 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7527 (defun gnus-summary-limit (articles &optional pop)
7529 ;; We pop the previous limit off the stack and use that.
7530 (setq articles (car gnus-newsgroup-limits)
7531 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7532 ;; We use the new limit, so we push the old limit on the stack.
7533 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7535 (setq gnus-newsgroup-limit articles)
7536 (let ((total (length gnus-newsgroup-data))
7537 (data (gnus-data-find-list (gnus-summary-article-number)))
7538 (gnus-summary-mark-below nil) ; Inhibit this.
7540 ;; This will do all the work of generating the new summary buffer
7541 ;; according to the new limit.
7542 (gnus-summary-prepare)
7543 ;; Hide any threads, possibly.
7544 (gnus-summary-maybe-hide-threads)
7545 ;; Try to return to the article you were at, or one in the
7548 ;; We try to find some article after the current one.
7550 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7553 (setq data (cdr data))))
7555 ;; If there is no data, that means that we were after the last
7556 ;; article. The same goes when we can't find any articles
7557 ;; after the current one.
7558 (goto-char (point-max))
7559 (gnus-summary-find-prev))
7560 (gnus-set-mode-line 'summary)
7561 ;; We return how many articles were removed from the summary
7562 ;; buffer as a result of the new limit.
7563 (- total (length gnus-newsgroup-data))))
7565 (defsubst gnus-invisible-cut-children (threads)
7568 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7573 (defsubst gnus-cut-thread (thread)
7574 "Go forwards in the thread until we find an article that we want to display."
7575 (when (or (eq gnus-fetch-old-headers 'some)
7576 (eq gnus-fetch-old-headers 'invisible)
7577 (numberp gnus-fetch-old-headers)
7578 (eq gnus-build-sparse-threads 'some)
7579 (eq gnus-build-sparse-threads 'more))
7580 ;; Deal with old-fetched headers and sparse threads.
7584 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7585 (gnus-summary-article-ancient-p
7586 (mail-header-number (car thread))))
7587 (if (or (<= (length (cdr thread)) 1)
7588 (eq gnus-fetch-old-headers 'invisible))
7589 (setq gnus-newsgroup-limit
7590 (delq (mail-header-number (car thread))
7591 gnus-newsgroup-limit)
7592 thread (cadr thread))
7593 (when (gnus-invisible-cut-children (cdr thread))
7594 (let ((th (cdr thread)))
7596 (if (memq (mail-header-number (caar th))
7597 gnus-newsgroup-limit)
7598 (setq thread (car th)
7600 (setq th (cdr th))))))))))
7603 (defun gnus-cut-threads (threads)
7604 "Cut off all uninteresting articles from the beginning of threads."
7605 (when (or (eq gnus-fetch-old-headers 'some)
7606 (eq gnus-fetch-old-headers 'invisible)
7607 (numberp gnus-fetch-old-headers)
7608 (eq gnus-build-sparse-threads 'some)
7609 (eq gnus-build-sparse-threads 'more))
7612 (setcar th (gnus-cut-thread (car th)))
7613 (setq th (cdr th)))))
7614 ;; Remove nixed out threads.
7617 (defun gnus-summary-initial-limit (&optional show-if-empty)
7618 "Figure out what the initial limit is supposed to be on group entry.
7619 This entails weeding out unwanted dormants, low-scored articles,
7620 fetch-old-headers verbiage, and so on."
7621 ;; Most groups have nothing to remove.
7622 (if (or gnus-inhibit-limiting
7623 (and (null gnus-newsgroup-dormant)
7624 (eq gnus-newsgroup-display 'gnus-not-ignore)
7625 (not (eq gnus-fetch-old-headers 'some))
7626 (not (numberp gnus-fetch-old-headers))
7627 (not (eq gnus-fetch-old-headers 'invisible))
7628 (null gnus-summary-expunge-below)
7629 (not (eq gnus-build-sparse-threads 'some))
7630 (not (eq gnus-build-sparse-threads 'more))
7631 (null gnus-thread-expunge-below)
7632 (not gnus-use-nocem)))
7634 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7635 (setq gnus-newsgroup-limit nil)
7638 (unless (car (symbol-value node))
7639 ;; These threads have no parents -- they are roots.
7640 (let ((nodes (cdr (symbol-value node)))
7643 (if (and gnus-thread-expunge-below
7644 (< (gnus-thread-total-score (car nodes))
7645 gnus-thread-expunge-below))
7646 (gnus-expunge-thread (pop nodes))
7647 (setq thread (pop nodes))
7648 (gnus-summary-limit-children thread))))))
7649 gnus-newsgroup-dependencies)
7650 ;; If this limitation resulted in an empty group, we might
7651 ;; pop the previous limit and use it instead.
7652 (when (and (not gnus-newsgroup-limit)
7654 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7655 gnus-newsgroup-limit))
7657 (defun gnus-summary-limit-children (thread)
7658 "Return 1 if this subthread is visible and 0 if it is not."
7659 ;; First we get the number of visible children to this thread. This
7660 ;; is done by recursing down the thread using this function, so this
7661 ;; will really go down to a leaf article first, before slowly
7662 ;; working its way up towards the root.
7666 (apply '+ (mapcar 'gnus-summary-limit-children
7669 (number (mail-header-number (car thread)))
7672 (not (memq number gnus-newsgroup-marked))
7674 ;; If this article is dormant and has absolutely no visible
7675 ;; children, then this article isn't visible.
7676 (and (memq number gnus-newsgroup-dormant)
7678 ;; If this is "fetch-old-headered" and there is no
7679 ;; visible children, then we don't want this article.
7680 (and (or (eq gnus-fetch-old-headers 'some)
7681 (numberp gnus-fetch-old-headers))
7682 (gnus-summary-article-ancient-p number)
7684 ;; If this is "fetch-old-headered" and `invisible', then
7685 ;; we don't want this article.
7686 (and (eq gnus-fetch-old-headers 'invisible)
7687 (gnus-summary-article-ancient-p number))
7688 ;; If this is a sparsely inserted article with no children,
7689 ;; we don't want it.
7690 (and (eq gnus-build-sparse-threads 'some)
7691 (gnus-summary-article-sparse-p number)
7693 ;; If we use expunging, and this article is really
7694 ;; low-scored, then we don't want this article.
7695 (when (and gnus-summary-expunge-below
7697 (or (cdr (assq number gnus-newsgroup-scored))
7698 gnus-summary-default-score))
7699 gnus-summary-expunge-below))
7700 ;; We increase the expunge-tally here, but that has
7701 ;; nothing to do with the limits, really.
7702 (incf gnus-newsgroup-expunged-tally)
7703 ;; We also mark as read here, if that's wanted.
7704 (when (and gnus-summary-mark-below
7705 (< score gnus-summary-mark-below))
7706 (setq gnus-newsgroup-unreads
7707 (delq number gnus-newsgroup-unreads))
7708 (if gnus-newsgroup-auto-expire
7709 (push number gnus-newsgroup-expirable)
7710 (push (cons number gnus-low-score-mark)
7711 gnus-newsgroup-reads)))
7713 ;; Do the `display' group parameter.
7714 (and gnus-newsgroup-display
7715 (not (funcall gnus-newsgroup-display)))
7716 ;; Check NoCeM things.
7717 (if (and gnus-use-nocem
7718 (gnus-nocem-unwanted-article-p
7719 (mail-header-id (car thread))))
7721 (setq gnus-newsgroup-unreads
7722 (delq number gnus-newsgroup-unreads))
7724 ;; Nope, invisible article.
7726 ;; Ok, this article is to be visible, so we add it to the limit
7728 (push number gnus-newsgroup-limit)
7731 (defun gnus-expunge-thread (thread)
7732 "Mark all articles in THREAD as read."
7733 (let* ((number (mail-header-number (car thread))))
7734 (incf gnus-newsgroup-expunged-tally)
7735 ;; We also mark as read here, if that's wanted.
7736 (setq gnus-newsgroup-unreads
7737 (delq number gnus-newsgroup-unreads))
7738 (if gnus-newsgroup-auto-expire
7739 (push number gnus-newsgroup-expirable)
7740 (push (cons number gnus-low-score-mark)
7741 gnus-newsgroup-reads)))
7742 ;; Go recursively through all subthreads.
7743 (mapcar 'gnus-expunge-thread (cdr thread)))
7745 ;; Summary article oriented commands
7747 (defun gnus-summary-refer-parent-article (n)
7748 "Refer parent article N times.
7749 If N is negative, go to ancestor -N instead.
7750 The difference between N and the number of articles fetched is returned."
7754 (when (not (natnump n))
7759 (setq header (gnus-summary-article-header))
7760 (if (and (eq (mail-header-number header)
7761 (cdr gnus-article-current))
7762 (equal gnus-newsgroup-name
7763 (car gnus-article-current)))
7764 ;; If we try to find the parent of the currently
7765 ;; displayed article, then we take a look at the actual
7766 ;; References header, since this is slightly more
7767 ;; reliable than the References field we got from the
7770 (set-buffer gnus-original-article-buffer)
7771 (nnheader-narrow-to-headers)
7772 (unless (setq ref (message-fetch-field "references"))
7773 (setq ref (message-fetch-field "in-reply-to")))
7776 ;; It's not the current article, so we take a bet on
7777 ;; the value we got from the server.
7778 (mail-header-references header)))
7780 (not (equal ref "")))
7781 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7782 (gnus-message 1 "Couldn't find parent"))
7783 (gnus-message 1 "No references in article %d"
7784 (gnus-summary-article-number))
7787 (gnus-summary-position-point)
7790 (defun gnus-summary-refer-references ()
7791 "Fetch all articles mentioned in the References header.
7792 Return the number of articles fetched."
7794 (let ((ref (mail-header-references (gnus-summary-article-header)))
7795 (current (gnus-summary-article-number))
7799 (error "No References in the current article")
7800 ;; For each Message-ID in the References header...
7801 (while (string-match "<[^>]*>" ref)
7803 ;; ... fetch that article.
7804 (gnus-summary-refer-article
7805 (prog1 (match-string 0 ref)
7806 (setq ref (substring ref (match-end 0))))))
7807 (gnus-summary-goto-subject current)
7808 (gnus-summary-position-point)
7811 (defun gnus-summary-refer-thread (&optional limit)
7812 "Fetch all articles in the current thread.
7813 If LIMIT (the numerical prefix), fetch that many old headers instead
7814 of what's specified by the `gnus-refer-thread-limit' variable."
7816 (let ((id (mail-header-id (gnus-summary-article-header)))
7817 (limit (if limit (prefix-numeric-value limit)
7818 gnus-refer-thread-limit)))
7819 ;; We want to fetch LIMIT *old* headers, but we also have to
7820 ;; re-fetch all the headers in the current buffer, because many of
7821 ;; them may be undisplayed. So we adjust LIMIT.
7822 (when (numberp limit)
7823 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7824 (unless (eq gnus-fetch-old-headers 'invisible)
7825 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7826 ;; Retrieve the headers and read them in.
7827 (if (eq (gnus-retrieve-headers
7828 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7830 (gnus-build-all-threads)
7831 (error "Can't fetch thread from backends that don't support NOV"))
7832 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7833 (gnus-summary-limit-include-thread id)))
7835 (defun gnus-summary-refer-article (message-id)
7836 "Fetch an article specified by MESSAGE-ID."
7837 (interactive "sMessage-ID: ")
7838 (when (and (stringp message-id)
7839 (not (zerop (length message-id))))
7840 ;; Construct the correct Message-ID if necessary.
7841 ;; Suggested by tale@pawl.rpi.edu.
7842 (unless (string-match "^<" message-id)
7843 (setq message-id (concat "<" message-id)))
7844 (unless (string-match ">$" message-id)
7845 (setq message-id (concat message-id ">")))
7846 (let* ((header (gnus-id-to-header message-id))
7848 (gnus-summary-article-sparse-p
7849 (mail-header-number header))
7850 (memq (mail-header-number header)
7851 gnus-newsgroup-limit)))
7854 ;; If the article is present in the buffer we just go to it.
7856 (or (not (gnus-summary-article-sparse-p
7857 (mail-header-number header)))
7860 (gnus-summary-goto-article
7861 (mail-header-number header) nil t)
7863 (gnus-summary-update-article (mail-header-number header)))))
7865 ;; We fetch the article.
7867 (dolist (gnus-override-method (gnus-refer-article-methods))
7868 (gnus-check-server gnus-override-method)
7869 ;; Fetch the header, and display the article.
7870 (when (setq number (gnus-summary-insert-subject message-id))
7871 (gnus-summary-select-article nil nil nil number)
7873 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7875 (defun gnus-refer-article-methods ()
7876 "Return a list of referrable methods."
7878 ;; No method, so we default to current and native.
7879 ((null gnus-refer-article-method)
7880 (list gnus-current-select-method gnus-select-method))
7882 ((eq 'current gnus-refer-article-method)
7883 (list gnus-current-select-method))
7884 ;; List of select methods.
7885 ((not (and (symbolp (car gnus-refer-article-method))
7886 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7888 (dolist (method gnus-refer-article-method)
7889 (push (if (eq 'current method)
7890 gnus-current-select-method
7894 ;; One single select method.
7896 (list gnus-refer-article-method))))
7898 (defun gnus-summary-edit-parameters ()
7899 "Edit the group parameters of the current group."
7901 (gnus-group-edit-group gnus-newsgroup-name 'params))
7903 (defun gnus-summary-customize-parameters ()
7904 "Customize the group parameters of the current group."
7906 (gnus-group-customize gnus-newsgroup-name))
7908 (defun gnus-summary-enter-digest-group (&optional force)
7909 "Enter an nndoc group based on the current article.
7910 If FORCE, force a digest interpretation. If not, try
7911 to guess what the document format is."
7913 (let ((conf gnus-current-window-configuration))
7915 (gnus-summary-select-article))
7916 (setq gnus-current-window-configuration conf)
7917 (let* ((name (format "%s-%d"
7918 (gnus-group-prefixed-name
7919 gnus-newsgroup-name (list 'nndoc ""))
7921 (set-buffer gnus-summary-buffer)
7922 gnus-current-article)))
7923 (ogroup gnus-newsgroup-name)
7924 (params (append (gnus-info-params (gnus-get-info ogroup))
7925 (list (cons 'to-group ogroup))
7926 (list (cons 'save-article-group ogroup))))
7927 (case-fold-search t)
7928 (buf (current-buffer))
7931 (set-buffer gnus-original-article-buffer)
7932 ;; Have the digest group inherit the main mail address of
7933 ;; the parent article.
7934 (when (setq to-address (or (gnus-fetch-field "reply-to")
7935 (gnus-fetch-field "from")))
7936 (setq params (append
7937 (list (cons 'to-address
7938 (funcall gnus-decode-encoded-word-function
7940 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7941 (insert-buffer-substring gnus-original-article-buffer)
7942 ;; Remove lines that may lead nndoc to misinterpret the
7945 (goto-char (point-min))
7946 (or (search-forward "\n\n" nil t) (point)))
7947 (goto-char (point-min))
7948 (delete-matching-lines "^Path:\\|^From ")
7951 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7952 (gnus-newsgroup-ephemeral-ignored-charsets
7953 gnus-newsgroup-ignored-charsets))
7954 (gnus-group-read-ephemeral-group
7955 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7957 ,(if force 'mbox 'guess)))
7959 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7961 ;; Make all postings to this group go to the parent group.
7962 (nconc (gnus-info-params (gnus-get-info name))
7964 ;; Couldn't select this doc group.
7965 (switch-to-buffer buf)
7966 (gnus-set-global-variables)
7967 (gnus-configure-windows 'summary)
7968 (gnus-message 3 "Article couldn't be entered?"))
7969 (kill-buffer dig)))))
7971 (defun gnus-summary-read-document (n)
7972 "Open a new group based on the current article(s).
7973 This will allow you to read digests and other similar
7974 documents as newsgroups.
7975 Obeys the standard process/prefix convention."
7977 (let* ((articles (gnus-summary-work-articles n))
7978 (ogroup gnus-newsgroup-name)
7979 (params (append (gnus-info-params (gnus-get-info ogroup))
7980 (list (cons 'to-group ogroup))))
7981 article group egroup groups vgroup)
7982 (while (setq article (pop articles))
7983 (setq group (format "%s-%d" gnus-newsgroup-name article))
7984 (gnus-summary-remove-process-mark article)
7985 (when (gnus-summary-display-article article)
7988 (insert-buffer-substring gnus-original-article-buffer)
7989 ;; Remove some headers that may lead nndoc to make
7991 (message-narrow-to-head)
7992 (goto-char (point-min))
7993 (delete-matching-lines "^\\(Path\\):\\|^From ")
7996 (gnus-group-read-ephemeral-group
7997 group `(nndoc ,group (nndoc-address ,(current-buffer))
7998 (nndoc-article-type guess))
8001 ;; Make all postings to this group go to the parent group.
8002 (nconc (gnus-info-params (gnus-get-info egroup))
8004 (push egroup groups))
8005 ;; Couldn't select this doc group.
8006 (gnus-error 3 "Article couldn't be entered"))))))
8007 ;; Now we have selected all the documents.
8010 (error "None of the articles could be interpreted as documents"))
8011 ((gnus-group-read-ephemeral-group
8012 (setq vgroup (format
8013 "nnvirtual:%s-%s" gnus-newsgroup-name
8014 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8015 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8017 (cons (current-buffer) 'summary)))
8019 (error "Couldn't select virtual nndoc group")))))
8021 (defun gnus-summary-isearch-article (&optional regexp-p)
8022 "Do incremental search forward on the current article.
8023 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8025 (let* ((gnus-inhibit-treatment t)
8026 (old (gnus-summary-select-article)))
8027 (gnus-configure-windows 'article)
8028 (gnus-eval-in-buffer-window gnus-article-buffer
8032 (gnus-article-show-all-headers))
8033 (goto-char (point-min))
8034 (isearch-forward regexp-p)))))
8036 (defun gnus-summary-search-article-forward (regexp &optional backward)
8037 "Search for an article containing REGEXP forward.
8038 If BACKWARD, search backward instead."
8041 (format "Search article %s (regexp%s): "
8042 (if current-prefix-arg "backward" "forward")
8043 (if gnus-last-search-regexp
8044 (concat ", default " gnus-last-search-regexp)
8046 current-prefix-arg))
8047 (if (string-equal regexp "")
8048 (setq regexp (or gnus-last-search-regexp ""))
8049 (setq gnus-last-search-regexp regexp)
8050 (setq gnus-article-before-search gnus-current-article))
8051 ;; Intentionally set gnus-last-article.
8052 (setq gnus-last-article gnus-article-before-search)
8053 (let ((gnus-last-article gnus-last-article))
8054 (if (gnus-summary-search-article regexp backward)
8055 (gnus-summary-show-thread)
8056 (error "Search failed: \"%s\"" regexp))))
8058 (defun gnus-summary-search-article-backward (regexp)
8059 "Search for an article containing REGEXP backward."
8062 (format "Search article backward (regexp%s): "
8063 (if gnus-last-search-regexp
8064 (concat ", default " gnus-last-search-regexp)
8066 (gnus-summary-search-article-forward regexp 'backward))
8069 (defmacro gnus-summary-search-article-position-point (regexp backward)
8070 "Dehighlight the last matched text and goto the beginning position."
8071 (` (if (and gnus-summary-search-article-matched-data
8072 (let ((text (caddr gnus-summary-search-article-matched-data))
8073 (inhibit-read-only t)
8076 (goto-char (car gnus-summary-search-article-matched-data))
8077 (cadr gnus-summary-search-article-matched-data))
8079 (string-match (, regexp) text)))
8080 (if (, backward) (beginning-of-line) (end-of-line))
8081 (goto-char (if (, backward) (point-max) (point-min))))))
8083 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8084 "Place point where X-Face image is displayed."
8085 (if (featurep 'xemacs)
8086 (` (let ((end (if (search-forward "\n\n" nil t)
8087 (goto-char (1- (point)))
8090 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8091 (unless (and (re-search-forward "^From:" end t)
8092 (setq extent (extent-at (point)))
8093 (extent-begin-glyph extent))
8094 (goto-char (, opoint)))))
8095 (` (let ((end (if (search-forward "\n\n" nil t)
8096 (goto-char (1- (point)))
8098 (start (or (search-backward "\n\n" nil t) (point-min))))
8100 (or (text-property-any start end 'x-face-image t);; x-face-e21
8101 (text-property-any start end 'x-face-mule-bitmap-image t)
8104 (defmacro gnus-summary-search-article-highlight-matched-text
8105 (backward treated x-face)
8106 "Highlight matched text in the function `gnus-summary-search-article'."
8107 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8108 (end (set-marker (make-marker) (match-end 0)))
8109 (inhibit-read-only t)
8113 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8115 (lambda (item) (setq items (delq item items)))
8116 '(gnus-treat-buttonize
8117 gnus-treat-fill-article
8118 gnus-treat-fill-long-lines
8119 gnus-treat-emphasize
8120 gnus-treat-highlight-headers
8121 gnus-treat-highlight-citation
8122 gnus-treat-highlight-signature
8123 gnus-treat-overstrike
8124 gnus-treat-display-xface
8125 gnus-treat-buttonize-head
8126 gnus-treat-decode-article-as-default-mime-charset))
8127 (static-if (featurep 'xemacs)
8129 (cons '(x-face-mule-delete-x-face-field
8132 (gnus-treat-display-xface
8133 (when (, x-face) gnus-treat-display-xface)))
8134 (gnus-article-prepare-mime-display)))
8135 (goto-char (if (, backward) start end))
8137 (gnus-summary-search-article-highlight-goto-x-face (point)))
8138 (setq gnus-summary-search-article-matched-data
8139 (list start end (buffer-substring start end)))
8140 (unless (eq start end);; matched text has been deleted. :-<
8141 (put-text-property start end 'face
8142 (or (find-face 'isearch)
8143 'secondary-selection))))))
8146 (defun gnus-summary-search-article (regexp &optional backward)
8147 "Search for an article containing REGEXP.
8148 Optional argument BACKWARD means do search for backward.
8149 `gnus-select-article-hook' is not called during the search."
8150 ;; We have to require this here to make sure that the following
8151 ;; dynamic binding isn't shadowed by autoloading.
8152 (require 'gnus-async)
8154 (let ((gnus-select-article-hook nil) ;Disable hook.
8155 (gnus-article-prepare-hook nil)
8156 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8157 (gnus-use-article-prefetch nil)
8158 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8159 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8160 (sum (current-buffer))
8163 (gnus-save-hidden-threads
8164 (static-if (featurep 'xemacs)
8165 (let ((gnus-inhibit-treatment t))
8166 (setq treated (eq 'old (gnus-summary-select-article)))
8168 (not (and (gnus-buffer-live-p gnus-article-buffer)
8169 (window-live-p (get-buffer-window
8170 gnus-article-buffer t)))))
8171 (gnus-summary-select-article nil t)
8172 (setq treated nil)))
8173 (let ((gnus-inhibit-treatment t)
8174 (x-face-mule-delete-x-face-field 'never))
8175 (setq treated (eq 'old (gnus-summary-select-article)))
8178 (and (gnus-buffer-live-p gnus-article-buffer)
8179 (window-live-p (get-buffer-window
8180 gnus-article-buffer t))
8181 (or (not (string-match "^\\^X-Face:" regexp))
8182 (with-current-buffer gnus-article-buffer
8183 gnus-summary-search-article-matched-data)))))
8184 (gnus-summary-select-article nil t)
8185 (setq treated nil))))
8186 (set-buffer gnus-article-buffer)
8190 (gnus-article-show-all-headers)
8191 (gnus-summary-search-article-position-point regexp backward))
8192 (goto-char (if backward (point-max) (point-min))))
8194 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8196 (re-search-backward regexp nil t)
8197 (re-search-forward regexp nil t))
8198 ;; We found the regexp.
8200 (gnus-summary-search-article-highlight-matched-text
8201 backward treated (string-match "^\\^X-Face:" regexp))
8204 (/ (- 2 (window-height
8205 (get-buffer-window gnus-article-buffer t)))
8208 (get-buffer-window (current-buffer))
8211 (setq point (point)))
8212 ;; We didn't find it, so we go to the next article.
8215 (while (eq found 'not)
8216 (if (not (if backward (gnus-summary-find-prev)
8217 (gnus-summary-find-next)))
8218 ;; No more articles.
8220 ;; Select the next article and adjust point.
8221 (unless (gnus-summary-article-sparse-p
8222 (gnus-summary-article-number))
8224 (let ((gnus-inhibit-treatment t))
8225 (gnus-summary-select-article))
8227 (set-buffer gnus-article-buffer)
8229 (goto-char (if backward (point-max) (point-min))))))))
8230 (gnus-message 7 ""))
8231 ;; Return whether we found the regexp.
8232 (when (eq found 'found)
8234 (gnus-summary-show-thread)
8235 (gnus-summary-goto-subject gnus-current-article)
8236 (gnus-summary-position-point)
8239 (defun gnus-find-matching-articles (header regexp)
8240 "Return a list of all articles that match REGEXP on HEADER.
8241 This search includes all articles in the current group that Gnus has
8242 fetched headers for, whether they are displayed or not."
8243 (let ((articles nil)
8244 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8245 (case-fold-search t))
8246 (dolist (header gnus-newsgroup-headers)
8247 (when (string-match regexp (funcall func header))
8248 (push (mail-header-number header) articles)))
8249 (nreverse articles)))
8251 (defun gnus-summary-find-matching (header regexp &optional backward unread
8252 not-case-fold not-matching)
8253 "Return a list of all articles that match REGEXP on HEADER.
8254 The search stars on the current article and goes forwards unless
8255 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8256 If UNREAD is non-nil, only unread articles will
8257 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8258 in the comparisons. If NOT-MATCHING, return a list of all articles that
8259 not match REGEXP on HEADER."
8260 (let ((case-fold-search (not not-case-fold))
8263 (if (eq (car header) 'extra)
8266 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8268 (error "%s is an invalid header" header))
8269 (unless (fboundp (intern (concat "mail-header-" header)))
8270 (error "%s is not a valid header" header))
8271 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8272 (dolist (d (if (eq backward 'all)
8274 (gnus-data-find-list
8275 (gnus-summary-article-number)
8276 (gnus-data-list backward))))
8277 (when (and (or (not unread) ; We want all articles...
8278 (gnus-data-unread-p d)) ; Or just unreads.
8279 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8283 (funcall func (gnus-data-header d))))
8284 (string-match regexp
8285 (funcall func (gnus-data-header d)))))
8286 (push (gnus-data-number d) articles))) ; Success!
8287 (nreverse articles)))
8289 (defun gnus-summary-execute-command (header regexp command &optional backward)
8290 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8291 If HEADER is an empty string (or nil), the match is done on the entire
8292 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8294 (list (let ((completion-ignore-case t))
8297 (mapcar (lambda (header) (list (format "%s" header)))
8299 '("Number" "Subject" "From" "Lines" "Date"
8300 "Message-ID" "Xref" "References" "Body")
8301 gnus-extra-headers))
8302 nil 'require-match))
8303 (read-string "Regexp: ")
8304 (read-key-sequence "Command: ")
8305 current-prefix-arg))
8306 (when (equal header "Body")
8308 ;; Hidden thread subtrees must be searched as well.
8309 (gnus-summary-show-all-threads)
8310 ;; We don't want to change current point nor window configuration.
8312 (save-window-excursion
8314 gnus-treat-strip-trailing-blank-lines
8315 gnus-treat-strip-leading-blank-lines
8316 gnus-treat-strip-multiple-blank-lines
8317 gnus-treat-hide-boring-headers
8318 gnus-treat-fold-newsgroups
8319 gnus-article-prepare-hook)
8320 (gnus-message 6 "Executing %s..." (key-description command))
8321 ;; We'd like to execute COMMAND interactively so as to give arguments.
8322 (gnus-execute header regexp
8323 `(call-interactively ',(key-binding command))
8325 (gnus-message 6 "Executing %s...done" (key-description command))))))
8327 (defun gnus-summary-beginning-of-article ()
8328 "Scroll the article back to the beginning."
8330 (gnus-summary-select-article)
8331 (gnus-configure-windows 'article)
8332 (gnus-eval-in-buffer-window gnus-article-buffer
8334 (goto-char (point-min))
8335 (when gnus-page-broken
8336 (gnus-narrow-to-page))))
8338 (defun gnus-summary-end-of-article ()
8339 "Scroll to the end of the article."
8341 (gnus-summary-select-article)
8342 (gnus-configure-windows 'article)
8343 (gnus-eval-in-buffer-window gnus-article-buffer
8345 (goto-char (point-max))
8347 (when gnus-page-broken
8348 (gnus-narrow-to-page))))
8350 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8351 "Truncate to LEN and quote all \"(\"'s in STRING."
8352 (gnus-replace-in-string (if (and len (> (length string) len))
8353 (substring string 0 len)
8357 (defun gnus-summary-print-article (&optional filename n)
8358 "Generate and print a PostScript image of the N next (mail) articles.
8360 If N is negative, print the N previous articles. If N is nil and articles
8361 have been marked with the process mark, print these instead.
8363 If the optional first argument FILENAME is nil, send the image to the
8364 printer. If FILENAME is a string, save the PostScript image in a file with
8365 that name. If FILENAME is a number, prompt the user for the name of the file
8367 (interactive (list (ps-print-preprint current-prefix-arg)))
8368 (dolist (article (gnus-summary-work-articles n))
8369 (gnus-summary-select-article nil nil 'pseudo article)
8370 (gnus-eval-in-buffer-window gnus-article-buffer
8371 (gnus-print-buffer))
8372 (gnus-summary-remove-process-mark article))
8373 (ps-despool filename))
8375 (defun gnus-print-buffer ()
8376 (let ((buffer (generate-new-buffer " *print*")))
8379 (copy-to-buffer buffer (point-min) (point-max))
8381 (gnus-article-delete-invisible-text)
8382 (gnus-remove-text-with-property 'gnus-decoration)
8383 (when (gnus-visual-p 'article-highlight 'highlight)
8384 ;; Copy-to-buffer doesn't copy overlay. So redo
8386 (let ((gnus-article-buffer buffer))
8387 (gnus-article-highlight-citation t)
8388 (gnus-article-highlight-signature)))
8389 (let ((ps-left-header
8392 (gnus-summary-print-truncate-and-quote
8393 (mail-header-subject gnus-current-headers)
8396 (gnus-summary-print-truncate-and-quote
8397 (mail-header-from gnus-current-headers)
8401 "/pagenumberstring load"
8403 (mail-header-date gnus-current-headers) ")"))))
8404 (gnus-run-hooks 'gnus-ps-print-hook)
8407 (ps-spool-buffer-with-faces)
8408 (ps-spool-buffer)))))
8409 (kill-buffer buffer))))
8411 (defun gnus-summary-show-article (&optional arg)
8412 "Force redisplaying of the current article.
8413 If ARG (the prefix) is a number, show the article with the charset
8414 defined in `gnus-summary-show-article-charset-alist', or the charset
8416 If ARG (the prefix) is non-nil and not a number, show the raw article
8417 without any article massaging functions being run. Normally, the key strokes
8422 (gnus-summary-show-article t)
8423 (let* ((gnus-newsgroup-charset
8424 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8425 (mm-read-coding-system
8426 "View as charset: " ;; actually it is coding system.
8428 (set-buffer gnus-article-buffer)
8429 (mm-detect-coding-region (point) (point-max))))))
8430 (default-mime-charset gnus-newsgroup-charset)
8431 (gnus-newsgroup-ignored-charsets 'gnus-all))
8432 (gnus-summary-select-article nil 'force)
8433 (let ((deps gnus-newsgroup-dependencies)
8436 (set-buffer gnus-original-article-buffer)
8438 (message-narrow-to-head)
8439 (setq head (buffer-string))
8440 (goto-char (point-min))
8441 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8442 (goto-char (point-max))
8444 (setq lines (1- (count-lines (point) (point-max))))))
8446 (insert (format "211 %d Article retrieved.\n"
8447 (cdr gnus-article-current)))
8449 (if lines (insert (format "Lines: %d\n" lines)))
8451 (let ((nntp-server-buffer (current-buffer)))
8452 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8453 (gnus-data-set-header
8454 (gnus-data-find (cdr gnus-article-current))
8456 (gnus-summary-update-article-line
8457 (cdr gnus-article-current) header)
8458 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8459 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8461 ;; Select the article the normal way.
8462 (gnus-summary-select-article nil 'force))
8464 ;; We have to require this here to make sure that the following
8465 ;; dynamic binding isn't shadowed by autoloading.
8466 (require 'gnus-async)
8468 ;; Bind the article treatment functions to nil.
8469 (let ((gnus-have-all-headers t)
8470 gnus-article-prepare-hook
8471 gnus-article-decode-hook
8474 (gnus-inhibit-treatment t))
8475 (gnus-summary-select-article nil 'force))))
8476 (gnus-summary-goto-subject gnus-current-article)
8477 (gnus-summary-position-point))
8479 (defun gnus-summary-show-raw-article ()
8480 "Show the raw article without any article massaging functions being run."
8482 (gnus-summary-show-article t))
8484 (defun gnus-summary-verbose-headers (&optional arg)
8485 "Toggle permanent full header display.
8486 If ARG is a positive number, turn header display on.
8487 If ARG is a negative number, turn header display off."
8489 (setq gnus-show-all-headers
8490 (cond ((or (not (numberp arg))
8492 (not gnus-show-all-headers))
8495 (gnus-summary-show-article))
8497 (defun gnus-summary-toggle-header (&optional arg)
8498 "Show the headers if they are hidden, or hide them if they are shown.
8499 If ARG is a positive number, show the entire header.
8500 If ARG is a negative number, hide the unwanted header lines."
8502 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8503 (get-buffer-window gnus-article-buffer t))))
8504 (with-current-buffer gnus-article-buffer
8506 (article-narrow-to-head)
8507 (let* ((buffer-read-only nil)
8508 (inhibit-point-motion-hooks t)
8509 (hidden (if (numberp arg)
8511 (gnus-article-hidden-text-p 'headers)))
8513 (delete-region (point-min) (point-max))
8514 (with-current-buffer gnus-original-article-buffer
8515 (goto-char (setq s (point-min)))
8516 (setq e (if (search-forward "\n\n" nil t)
8519 (insert-buffer-substring gnus-original-article-buffer s e)
8520 (article-decode-encoded-words)
8522 (let ((gnus-treat-hide-headers nil)
8523 (gnus-treat-hide-boring-headers nil))
8524 (gnus-delete-wash-type 'headers)
8525 (gnus-treat-article 'head))
8526 (gnus-treat-article 'head))
8529 (set-window-start window (goto-char (point-min))))
8530 (setq gnus-page-broken
8531 (when gnus-break-pages
8532 (gnus-narrow-to-page)
8534 (gnus-set-mode-line 'article)))))
8536 (defun gnus-summary-show-all-headers ()
8537 "Make all header lines visible."
8539 (gnus-summary-toggle-header 1))
8541 (defun gnus-summary-toggle-mime (&optional arg)
8542 "Toggle MIME processing.
8543 If ARG is a positive number, turn MIME processing on."
8545 (setq gnus-show-mime
8547 (not gnus-show-mime)
8548 (> (prefix-numeric-value arg) 0)))
8549 (gnus-summary-select-article t 'force))
8551 (defun gnus-summary-caesar-message (&optional arg)
8552 "Caesar rotate the current article by 13.
8553 The numerical prefix specifies how many places to rotate each letter
8556 (gnus-summary-select-article)
8557 (let ((mail-header-separator ""))
8558 (gnus-eval-in-buffer-window gnus-article-buffer
8561 (let ((start (window-start))
8563 (message-caesar-buffer-body arg)
8564 (set-window-start (get-buffer-window (current-buffer)) start))))))
8566 (autoload 'unmorse-region "morse"
8567 "Convert morse coded text in region to ordinary ASCII text."
8570 (defun gnus-summary-morse-message (&optional arg)
8571 "Morse decode the current article."
8573 (gnus-summary-select-article)
8574 (let ((mail-header-separator ""))
8575 (gnus-eval-in-buffer-window gnus-article-buffer
8579 (let ((pos (window-start))
8581 (goto-char (point-min))
8582 (when (message-goto-body)
8583 (gnus-narrow-to-body))
8584 (goto-char (point-min))
8585 (while (re-search-forward "·" (point-max) t)
8586 (replace-match "."))
8587 (unmorse-region (point-min) (point-max))
8589 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8591 (defun gnus-summary-stop-page-breaking ()
8592 "Stop page breaking in the current article."
8594 (gnus-summary-select-article)
8595 (gnus-eval-in-buffer-window gnus-article-buffer
8597 (when (gnus-visual-p 'page-marker)
8598 (let ((buffer-read-only nil))
8599 (gnus-remove-text-with-property 'gnus-prev)
8600 (gnus-remove-text-with-property 'gnus-next))
8601 (setq gnus-page-broken nil))))
8603 (defun gnus-summary-move-article (&optional n to-newsgroup
8604 select-method action)
8605 "Move the current article to a different newsgroup.
8606 If N is a positive number, move the N next articles.
8607 If N is a negative number, move the N previous articles.
8608 If N is nil and any articles have been marked with the process mark,
8609 move those articles instead.
8610 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8611 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8612 re-spool using this method.
8614 When called interactively with TO-NEWSGROUP being nil, the value of
8615 the variable `gnus-move-split-methods' is used for finding a default
8616 for the target newsgroup.
8618 For this function to work, both the current newsgroup and the
8619 newsgroup that you want to move to have to support the `request-move'
8620 and `request-accept' functions.
8622 ACTION can be either `move' (the default), `crosspost' or `copy'."
8625 (setq action 'move))
8626 ;; Check whether the source group supports the required functions.
8627 (cond ((and (eq action 'move)
8628 (not (gnus-check-backend-function
8629 'request-move-article gnus-newsgroup-name)))
8630 (error "The current group does not support article moving"))
8631 ((and (eq action 'crosspost)
8632 (not (gnus-check-backend-function
8633 'request-replace-article gnus-newsgroup-name)))
8634 (error "The current group does not support article editing")))
8635 (let ((articles (gnus-summary-work-articles n))
8636 (prefix (if (gnus-check-backend-function
8637 'request-move-article gnus-newsgroup-name)
8638 (gnus-group-real-prefix gnus-newsgroup-name)
8640 (names '((move "Move" "Moving")
8641 (copy "Copy" "Copying")
8642 (crosspost "Crosspost" "Crossposting")))
8643 (copy-buf (save-excursion
8644 (nnheader-set-temp-buffer " *copy article*")))
8645 (default-marks gnus-article-mark-lists)
8646 (no-expire-marks (delete '(expirable . expire)
8647 (copy-sequence gnus-article-mark-lists)))
8648 art-group to-method new-xref article to-groups)
8649 (unless (assq action names)
8650 (error "Unknown action %s" action))
8651 ;; Read the newsgroup name.
8652 (when (and (not to-newsgroup)
8653 (not select-method))
8654 (if (and gnus-move-split-methods
8656 (and (memq gnus-current-article articles)
8657 (gnus-buffer-live-p gnus-original-article-buffer))))
8658 ;; When `gnus-move-split-methods' is non-nil, we have to
8659 ;; select an article to give `gnus-read-move-group-name' an
8660 ;; opportunity to suggest an appropriate default. However,
8661 ;; we needn't render or mark the article.
8662 (let ((gnus-display-mime-function nil)
8663 (gnus-article-prepare-hook nil)
8664 (gnus-mark-article-hook nil))
8665 (gnus-summary-select-article nil nil nil (car articles))))
8667 (gnus-read-move-group-name
8668 (cadr (assq action names))
8669 (symbol-value (intern (format "gnus-current-%s-group" action)))
8671 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8672 (setq to-method (or select-method
8673 (gnus-server-to-method
8674 (gnus-group-method to-newsgroup))))
8675 ;; Check the method we are to move this article to...
8676 (unless (gnus-check-backend-function
8677 'request-accept-article (car to-method))
8678 (error "%s does not support article copying" (car to-method)))
8679 (unless (gnus-check-server to-method)
8680 (error "Can't open server %s" (car to-method)))
8681 (gnus-message 6 "%s to %s: %s..."
8682 (caddr (assq action names))
8683 (or (car select-method) to-newsgroup) articles)
8685 (setq article (pop articles))
8689 ;; Move the article.
8691 ;; Remove this article from future suppression.
8692 (gnus-dup-unsuppress-article article)
8693 (gnus-request-move-article
8694 article ; Article to move
8695 gnus-newsgroup-name ; From newsgroup
8696 (nth 1 (gnus-find-method-for-group
8697 gnus-newsgroup-name)) ; Server
8698 (list 'gnus-request-accept-article
8699 to-newsgroup (list 'quote select-method)
8700 (not articles) t) ; Accept form
8701 (not articles))) ; Only save nov last time
8702 ;; Copy the article.
8705 (set-buffer copy-buf)
8706 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8707 (gnus-request-accept-article
8708 to-newsgroup select-method (not articles) t))))
8709 ;; Crosspost the article.
8710 ((eq action 'crosspost)
8711 (let ((xref (message-tokenize-header
8712 (mail-header-xref (gnus-summary-article-header article))
8714 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8715 ":" (number-to-string article)))
8717 (setq xref (list (system-name))))
8720 (mapconcat 'identity
8721 (delete "Xref:" (delete new-xref xref))
8725 (set-buffer copy-buf)
8726 ;; First put the article in the destination group.
8727 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8728 (when (consp (setq art-group
8729 (gnus-request-accept-article
8730 to-newsgroup select-method (not articles))))
8731 (setq new-xref (concat new-xref " " (car art-group)
8733 (number-to-string (cdr art-group))))
8734 ;; Now we have the new Xrefs header, so we insert
8735 ;; it and replace the new article.
8736 (nnheader-replace-header "Xref" new-xref)
8737 (gnus-request-replace-article
8738 (cdr art-group) to-newsgroup (current-buffer))
8742 (gnus-message 1 "Couldn't %s article %s: %s"
8743 (cadr (assq action names)) article
8744 (nnheader-get-report (car to-method))))
8745 ((eq art-group 'junk)
8746 (when (eq action 'move)
8747 (gnus-summary-mark-article article gnus-canceled-mark)
8748 (gnus-message 4 "Deleted article %s" article)))
8750 (let* ((pto-group (gnus-group-prefixed-name
8751 (car art-group) to-method))
8753 (gnus-gethash pto-group gnus-newsrc-hashtb))
8754 (info (nth 2 entry))
8755 (to-group (gnus-info-group info))
8757 ;; Update the group that has been moved to.
8759 (memq action '(move copy)))
8760 (unless (member to-group to-groups)
8761 (push to-group to-groups))
8763 (unless (memq article gnus-newsgroup-unreads)
8764 (push 'read to-marks)
8766 info (gnus-add-to-range (gnus-info-read info)
8767 (list (cdr art-group)))))
8769 ;; See whether the article is to be put in the cache.
8770 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8773 (to-article (cdr art-group)))
8775 ;; Enter the article into the cache in the new group,
8776 ;; if that is required.
8777 (when gnus-use-cache
8778 (gnus-cache-possibly-enter-article
8780 (let ((header (copy-sequence
8781 (gnus-summary-article-header article))))
8782 (mail-header-set-number header to-article)
8784 (memq article gnus-newsgroup-marked)
8785 (memq article gnus-newsgroup-dormant)
8786 (memq article gnus-newsgroup-unreads)))
8788 (when gnus-preserve-marks
8789 ;; Copy any marks over to the new group.
8790 (when (and (equal to-group gnus-newsgroup-name)
8791 (not (memq article gnus-newsgroup-unreads)))
8792 ;; Mark this article as read in this group.
8793 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8794 (setcdr (gnus-active to-group) to-article)
8795 (setcdr gnus-newsgroup-active to-article))
8798 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8799 (when (memq article (symbol-value
8800 (intern (format "gnus-newsgroup-%s"
8802 (push (cdar marks) to-marks)
8803 ;; If the other group is the same as this group,
8804 ;; then we have to add the mark to the list.
8805 (when (equal to-group gnus-newsgroup-name)
8806 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8809 (intern (format "gnus-newsgroup-%s"
8811 ;; Copy the marks to other group.
8812 (gnus-add-marked-articles
8813 to-group (cdar marks) (list to-article) info)))
8814 (setq marks (cdr marks)))
8816 (gnus-request-set-mark to-group (list (list (list to-article)
8821 (concat "(gnus-group-set-info '"
8822 (gnus-prin1-to-string (gnus-get-info to-group))
8825 ;; Update the Xref header in this article to point to
8826 ;; the new crossposted article we have just created.
8827 (when (eq action 'crosspost)
8829 (set-buffer copy-buf)
8830 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8831 (nnheader-replace-header "Xref" new-xref)
8832 (gnus-request-replace-article
8833 article gnus-newsgroup-name (current-buffer)))))
8835 ;;;!!!Why is this necessary?
8836 (set-buffer gnus-summary-buffer)
8838 (gnus-summary-goto-subject article)
8839 (when (eq action 'move)
8840 (gnus-summary-mark-article article gnus-canceled-mark))))
8841 (gnus-summary-remove-process-mark article))
8842 ;; Re-activate all groups that have been moved to.
8844 (set-buffer gnus-group-buffer)
8845 (let ((gnus-group-marked to-groups))
8846 (gnus-group-get-new-news-this-group nil t)))
8848 (gnus-kill-buffer copy-buf)
8849 (gnus-summary-position-point)
8850 (gnus-set-mode-line 'summary)))
8852 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8853 "Move the current article to a different newsgroup.
8854 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8855 When called interactively, if TO-NEWSGROUP is nil, use the value of
8856 the variable `gnus-move-split-methods' for finding a default target
8858 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8859 re-spool using this method."
8861 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8863 (defun gnus-summary-crosspost-article (&optional n)
8864 "Crosspost the current article to some other group."
8866 (gnus-summary-move-article n nil nil 'crosspost))
8868 (defcustom gnus-summary-respool-default-method nil
8869 "Default method type for respooling an article.
8870 If nil, use to the current newsgroup method."
8872 :group 'gnus-summary-mail)
8874 (defun gnus-summary-respool-article (&optional n method)
8875 "Respool the current article.
8876 The article will be squeezed through the mail spooling process again,
8877 which means that it will be put in some mail newsgroup or other
8878 depending on `nnmail-split-methods'.
8879 If N is a positive number, respool the N next articles.
8880 If N is a negative number, respool the N previous articles.
8881 If N is nil and any articles have been marked with the process mark,
8882 respool those articles instead.
8884 Respooling can be done both from mail groups and \"real\" newsgroups.
8885 In the former case, the articles in question will be moved from the
8886 current group into whatever groups they are destined to. In the
8887 latter case, they will be copied into the relevant groups."
8889 (list current-prefix-arg
8890 (let* ((methods (gnus-methods-using 'respool))
8892 (symbol-name (or gnus-summary-respool-default-method
8893 (car (gnus-find-method-for-group
8894 gnus-newsgroup-name)))))
8896 (gnus-completing-read-with-default
8897 methname "What backend do you want to use when respooling?"
8898 methods nil t nil 'gnus-mail-method-history))
8901 ((zerop (length (setq ms (gnus-servers-using-backend
8903 (list (intern method) ""))
8907 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8908 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8911 (error "No method given for respooling"))
8912 (if (assoc (symbol-name
8913 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8914 (gnus-methods-using 'respool))
8915 (gnus-summary-move-article n nil method)
8916 (gnus-summary-copy-article n nil method)))
8918 (defun gnus-summary-import-article (file &optional edit)
8919 "Import an arbitrary file into a mail newsgroup."
8920 (interactive "fImport file: \nP")
8921 (let ((group gnus-newsgroup-name)
8922 (now (current-time))
8923 atts lines group-art)
8924 (unless (gnus-check-backend-function 'request-accept-article group)
8925 (error "%s does not support article importing" group))
8926 (or (file-readable-p file)
8927 (not (file-regular-p file))
8928 (error "Can't read %s" file))
8930 (set-buffer (gnus-get-buffer-create " *import file*"))
8932 (nnheader-insert-file-contents file)
8933 (goto-char (point-min))
8934 (if (nnheader-article-p)
8936 (goto-char (point-min))
8937 (search-forward "\n\n" nil t)
8938 (narrow-to-region (point-min) (1- (point)))
8939 (goto-char (point-min))
8940 (unless (re-search-forward "^date:" nil t)
8941 (goto-char (point-max))
8942 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8943 ;; This doesn't look like an article, so we fudge some headers.
8944 (setq atts (file-attributes file)
8945 lines (count-lines (point-min) (point-max)))
8946 (insert "From: " (read-string "From: ") "\n"
8947 "Subject: " (read-string "Subject: ") "\n"
8948 "Date: " (message-make-date (nth 5 atts)) "\n"
8949 "Message-ID: " (message-make-message-id) "\n"
8950 "Lines: " (int-to-string lines) "\n"
8951 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8952 (setq group-art (gnus-request-accept-article group nil t))
8953 (kill-buffer (current-buffer)))
8954 (setq gnus-newsgroup-active (gnus-activate-group group))
8956 (gnus-summary-goto-article (cdr group-art) nil t)
8958 (gnus-summary-edit-article))))
8960 (defun gnus-summary-create-article ()
8961 "Create an article in a mail newsgroup."
8963 (let ((group gnus-newsgroup-name)
8964 (now (current-time))
8966 (unless (gnus-check-backend-function 'request-accept-article group)
8967 (error "%s does not support article importing" group))
8969 (set-buffer (gnus-get-buffer-create " *import file*"))
8971 (goto-char (point-min))
8972 ;; This doesn't look like an article, so we fudge some headers.
8973 (insert "From: " (read-string "From: ") "\n"
8974 "Subject: " (read-string "Subject: ") "\n"
8975 "Date: " (message-make-date now) "\n"
8976 "Message-ID: " (message-make-message-id) "\n")
8977 (setq group-art (gnus-request-accept-article group nil t))
8978 (kill-buffer (current-buffer)))
8979 (setq gnus-newsgroup-active (gnus-activate-group group))
8981 (gnus-summary-goto-article (cdr group-art) nil t)
8982 (gnus-summary-edit-article)))
8984 (defun gnus-summary-article-posted-p ()
8985 "Say whether the current (mail) article is available from news as well.
8986 This will be the case if the article has both been mailed and posted."
8988 (let ((id (mail-header-references (gnus-summary-article-header)))
8989 (gnus-override-method (car (gnus-refer-article-methods))))
8990 (if (gnus-request-head id "")
8991 (gnus-message 2 "The current message was found on %s"
8992 gnus-override-method)
8993 (gnus-message 2 "The current message couldn't be found on %s"
8994 gnus-override-method)
8997 (defun gnus-summary-expire-articles (&optional now)
8998 "Expire all articles that are marked as expirable in the current group."
9000 (when (gnus-check-backend-function
9001 'request-expire-articles gnus-newsgroup-name)
9002 ;; This backend supports expiry.
9003 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9004 (expirable (if total
9006 ;; We need to update the info for
9007 ;; this group for `gnus-list-of-read-articles'
9008 ;; to give us the right answer.
9009 (gnus-run-hooks 'gnus-exit-group-hook)
9010 (gnus-summary-update-info)
9011 (gnus-list-of-read-articles gnus-newsgroup-name))
9012 (setq gnus-newsgroup-expirable
9013 (sort gnus-newsgroup-expirable '<))))
9014 (expiry-wait (if now 'immediate
9015 (gnus-group-find-parameter
9016 gnus-newsgroup-name 'expiry-wait)))
9017 (nnmail-expiry-target
9018 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9019 nnmail-expiry-target))
9022 ;; There are expirable articles in this group, so we run them
9023 ;; through the expiry process.
9024 (gnus-message 6 "Expiring articles...")
9025 (unless (gnus-check-group gnus-newsgroup-name)
9026 (error "Can't open server for %s" gnus-newsgroup-name))
9027 ;; The list of articles that weren't expired is returned.
9030 (let ((nnmail-expiry-wait-function nil)
9031 (nnmail-expiry-wait expiry-wait))
9032 (setq es (gnus-request-expire-articles
9033 expirable gnus-newsgroup-name)))
9034 (setq es (gnus-request-expire-articles
9035 expirable gnus-newsgroup-name)))
9037 (setq gnus-newsgroup-expirable es))
9038 ;; We go through the old list of expirable, and mark all
9039 ;; really expired articles as nonexistent.
9040 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9041 (let ((gnus-use-cache nil))
9042 (dolist (article expirable)
9043 (when (and (not (memq article es))
9044 (gnus-data-find article))
9045 (gnus-summary-mark-article article gnus-canceled-mark))))))
9046 (gnus-message 6 "Expiring articles...done")))))
9048 (defun gnus-summary-expire-articles-now ()
9049 "Expunge all expirable articles in the current group.
9050 This means that *all* articles that are marked as expirable will be
9051 deleted forever, right now."
9053 (or gnus-expert-user
9055 "Are you really, really, really sure you want to delete all these messages? ")
9057 (gnus-summary-expire-articles t))
9059 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9060 (defun gnus-summary-delete-article (&optional n)
9061 "Delete the N next (mail) articles.
9062 This command actually deletes articles. This is not a marking
9063 command. The article will disappear forever from your life, never to
9065 If N is negative, delete backwards.
9066 If N is nil and articles have been marked with the process mark,
9067 delete these instead."
9069 (unless (gnus-check-backend-function 'request-expire-articles
9070 gnus-newsgroup-name)
9071 (error "The current newsgroup does not support article deletion"))
9072 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9073 (error "Couldn't open server"))
9074 ;; Compute the list of articles to delete.
9075 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9076 (nnmail-expiry-target 'delete)
9078 (if (and gnus-novice-user
9079 (not (gnus-yes-or-no-p
9080 (format "Do you really want to delete %s forever? "
9081 (if (> (length articles) 1)
9082 (format "these %s articles" (length articles))
9085 ;; Delete the articles.
9086 (setq not-deleted (gnus-request-expire-articles
9087 articles gnus-newsgroup-name 'force))
9089 (gnus-summary-remove-process-mark (car articles))
9090 ;; The backend might not have been able to delete the article
9092 (unless (memq (car articles) not-deleted)
9093 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9094 (setq articles (cdr articles)))
9096 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9097 (gnus-summary-position-point)
9098 (gnus-set-mode-line 'summary)
9101 (defun gnus-summary-edit-article (&optional force)
9102 "Edit the current article.
9103 This will have permanent effect only in mail groups.
9104 If FORCE is non-nil, allow editing of articles even in read-only
9108 (set-buffer gnus-summary-buffer)
9109 (let ((mail-parse-charset gnus-newsgroup-charset)
9110 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9111 (gnus-set-global-variables)
9112 (when (and (not force)
9113 (gnus-group-read-only-p))
9114 (error "The current newsgroup does not support article editing"))
9115 (gnus-summary-show-article t)
9116 (gnus-article-edit-article
9118 `(lambda (no-highlight)
9119 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9120 (message-options message-options)
9121 (message-options-set-recipient)
9122 (mail-parse-ignored-charsets
9123 ',gnus-newsgroup-ignored-charsets))
9124 (gnus-summary-edit-article-done
9125 ,(or (mail-header-references gnus-current-headers) "")
9126 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9128 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9130 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9132 "Make edits to the current article permanent."
9135 ;; The buffer restriction contains the entire article if it exists.
9136 (when (article-goto-body)
9137 (let ((lines (count-lines (point) (point-max)))
9138 (length (- (point-max) (point)))
9139 (case-fold-search t)
9140 (body (copy-marker (point))))
9141 (goto-char (point-min))
9142 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9143 (delete-region (match-beginning 1) (match-end 1))
9144 (insert (number-to-string length)))
9145 (goto-char (point-min))
9146 (when (re-search-forward
9147 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9148 (delete-region (match-beginning 1) (match-end 1))
9149 (insert (number-to-string length)))
9150 (goto-char (point-min))
9151 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9152 (delete-region (match-beginning 1) (match-end 1))
9153 (insert (number-to-string lines))))))
9154 ;; Replace the article.
9155 (let ((buf (current-buffer)))
9157 (insert-buffer-substring buf)
9159 (if (and (not read-only)
9160 (not (gnus-request-replace-article
9161 (cdr gnus-article-current) (car gnus-article-current)
9162 (current-buffer) t)))
9163 (error "Couldn't replace article")
9164 ;; Update the summary buffer.
9166 (equal (message-tokenize-header references " ")
9167 (message-tokenize-header
9168 (or (message-fetch-field "references") "") " ")))
9169 ;; We only have to update this line.
9172 (message-narrow-to-head)
9173 (let ((head (buffer-string))
9176 (insert (format "211 %d Article retrieved.\n"
9177 (cdr gnus-article-current)))
9180 (let ((nntp-server-buffer (current-buffer)))
9181 (setq header (car (gnus-get-newsgroup-headers
9184 (set-buffer gnus-summary-buffer)
9185 (gnus-data-set-header
9186 (gnus-data-find (cdr gnus-article-current))
9188 (gnus-summary-update-article-line
9189 (cdr gnus-article-current) header)
9190 (if (gnus-summary-goto-subject
9191 (cdr gnus-article-current) nil t)
9192 (gnus-summary-update-secondary-mark
9193 (cdr gnus-article-current))))))))
9195 (set-buffer (or buffer gnus-summary-buffer))
9196 (gnus-summary-update-article (cdr gnus-article-current))
9197 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9198 (gnus-summary-update-secondary-mark
9199 (cdr gnus-article-current))))
9200 ;; Prettify the article buffer again.
9201 (unless no-highlight
9203 (set-buffer gnus-article-buffer)
9204 ;;;!!! Fix this -- article should be rehighlighted.
9205 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9206 (set-buffer gnus-original-article-buffer)
9207 (gnus-request-article
9208 (cdr gnus-article-current)
9209 (car gnus-article-current) (current-buffer))))
9210 ;; Prettify the summary buffer line.
9211 (when (gnus-visual-p 'summary-highlight 'highlight)
9212 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9214 (defun gnus-summary-edit-wash (key)
9215 "Perform editing command KEY in the article buffer."
9219 (message "%s" (concat (this-command-keys) "- "))
9222 (gnus-summary-edit-article)
9223 (execute-kbd-macro (concat (this-command-keys) key))
9224 (gnus-article-edit-done))
9228 (defun gnus-summary-respool-query (&optional silent trace)
9229 "Query where the respool algorithm would put this article."
9231 (let (gnus-mark-article-hook)
9232 (gnus-summary-select-article)
9234 (set-buffer gnus-original-article-buffer)
9236 (message-narrow-to-head)
9237 (let ((groups (nnmail-article-group 'identity trace)))
9240 (message "This message would go to %s"
9241 (mapconcat 'car groups ", "))
9242 (message "This message would go to no groups"))
9245 (defun gnus-summary-respool-trace ()
9246 "Trace where the respool algorithm would put this article.
9247 Display a buffer showing all fancy splitting patterns which matched."
9249 (gnus-summary-respool-query nil t))
9251 ;; Summary marking commands.
9253 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9254 "Mark articles which has the same subject as read, and then select the next.
9255 If UNMARK is positive, remove any kind of mark.
9256 If UNMARK is negative, tick articles."
9259 (setq unmark (prefix-numeric-value unmark)))
9261 (gnus-summary-mark-same-subject
9262 (gnus-summary-article-subject) unmark)))
9263 ;; Select next unread article. If auto-select-same mode, should
9264 ;; select the first unread article.
9265 (gnus-summary-next-article t (and gnus-auto-select-same
9266 (gnus-summary-article-subject)))
9267 (gnus-message 7 "%d article%s marked as %s"
9268 count (if (= count 1) " is" "s are")
9269 (if unmark "unread" "read"))))
9271 (defun gnus-summary-kill-same-subject (&optional unmark)
9272 "Mark articles which has the same subject as read.
9273 If UNMARK is positive, remove any kind of mark.
9274 If UNMARK is negative, tick articles."
9277 (setq unmark (prefix-numeric-value unmark)))
9279 (gnus-summary-mark-same-subject
9280 (gnus-summary-article-subject) unmark)))
9281 ;; If marked as read, go to next unread subject.
9283 ;; Go to next unread subject.
9284 (gnus-summary-next-subject 1 t))
9285 (gnus-message 7 "%d articles are marked as %s"
9286 count (if unmark "unread" "read"))))
9288 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9289 "Mark articles with same SUBJECT as read, and return marked number.
9290 If optional argument UNMARK is positive, remove any kinds of marks.
9291 If optional argument UNMARK is negative, mark articles as unread instead."
9295 ((null unmark) ; Mark as read.
9298 (gnus-summary-mark-article-as-read gnus-killed-mark)
9299 (gnus-summary-show-thread) t)
9300 (gnus-summary-find-subject subject))
9301 (setq count (1+ count))))
9302 ((> unmark 0) ; Tick.
9305 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9306 (gnus-summary-show-thread) t)
9307 (gnus-summary-find-subject subject))
9308 (setq count (1+ count))))
9309 (t ; Mark as unread.
9312 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9313 (gnus-summary-show-thread) t)
9314 (gnus-summary-find-subject subject))
9315 (setq count (1+ count)))))
9316 (gnus-set-mode-line 'summary)
9317 ;; Return the number of marked articles.
9320 (defun gnus-summary-mark-as-processable (n &optional unmark)
9321 "Set the process mark on the next N articles.
9322 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9323 the process mark instead. The difference between N and the actual
9324 number of articles marked is returned."
9326 (if (and (null n) (gnus-region-active-p))
9327 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9328 (setq n (prefix-numeric-value n))
9329 (let ((backward (< n 0))
9334 (gnus-summary-remove-process-mark
9335 (gnus-summary-article-number))
9336 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9337 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9340 (gnus-message 7 "No more articles"))
9341 (gnus-summary-recenter)
9342 (gnus-summary-position-point)
9345 (defun gnus-summary-unmark-as-processable (n)
9346 "Remove the process mark from the next N articles.
9347 If N is negative, unmark backward instead. The difference between N and
9348 the actual number of articles unmarked is returned."
9350 (gnus-summary-mark-as-processable n t))
9352 (defun gnus-summary-unmark-all-processable ()
9353 "Remove the process mark from all articles."
9356 (while gnus-newsgroup-processable
9357 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9358 (gnus-summary-position-point))
9360 (defun gnus-summary-add-mark (article type)
9361 "Mark ARTICLE with a mark of TYPE."
9362 (let ((vtype (car (assq type gnus-article-mark-lists)))
9365 (error "No such mark type: %s" type)
9366 (setq var (intern (format "gnus-newsgroup-%s" type)))
9367 (set var (cons article (symbol-value var)))
9368 (if (memq type '(processable cached replied forwarded recent saved))
9369 (gnus-summary-update-secondary-mark article)
9370 ;;; !!! This is bogus. We should find out what primary
9371 ;;; !!! mark we want to set.
9372 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9374 (defun gnus-summary-mark-as-expirable (n)
9375 "Mark N articles forward as expirable.
9376 If N is negative, mark backward instead. The difference between N and
9377 the actual number of articles marked is returned."
9379 (gnus-summary-mark-forward n gnus-expirable-mark))
9381 (defun gnus-summary-mark-as-spam (n)
9382 "Mark N articles forward as spam.
9383 If N is negative, mark backward instead. The difference between N and
9384 the actual number of articles marked is returned."
9386 (gnus-summary-mark-forward n gnus-spam-mark))
9388 (defun gnus-summary-mark-article-as-replied (article)
9389 "Mark ARTICLE as replied to and update the summary line.
9390 ARTICLE can also be a list of articles."
9391 (interactive (list (gnus-summary-article-number)))
9392 (let ((articles (if (listp article) article (list article))))
9393 (dolist (article articles)
9394 (push article gnus-newsgroup-replied)
9395 (let ((buffer-read-only nil))
9396 (when (gnus-summary-goto-subject article nil t)
9397 (gnus-summary-update-secondary-mark article))))))
9399 (defun gnus-summary-mark-article-as-forwarded (article)
9400 "Mark ARTICLE as forwarded and update the summary line.
9401 ARTICLE can also be a list of articles."
9402 (let ((articles (if (listp article) article (list article))))
9403 (dolist (article articles)
9404 (push article gnus-newsgroup-forwarded)
9405 (let ((buffer-read-only nil))
9406 (when (gnus-summary-goto-subject article nil t)
9407 (gnus-summary-update-secondary-mark article))))))
9409 (defun gnus-summary-set-bookmark (article)
9410 "Set a bookmark in current article."
9411 (interactive (list (gnus-summary-article-number)))
9412 (when (or (not (get-buffer gnus-article-buffer))
9413 (not gnus-current-article)
9414 (not gnus-article-current)
9415 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9416 (error "No current article selected"))
9417 ;; Remove old bookmark, if one exists.
9418 (let ((old (assq article gnus-newsgroup-bookmarks)))
9420 (setq gnus-newsgroup-bookmarks
9421 (delq old gnus-newsgroup-bookmarks))))
9422 ;; Set the new bookmark, which is on the form
9423 ;; (article-number . line-number-in-body).
9427 (set-buffer gnus-article-buffer)
9431 (goto-char (point-min))
9432 (search-forward "\n\n" nil t)
9435 gnus-newsgroup-bookmarks)
9436 (gnus-message 6 "A bookmark has been added to the current article."))
9438 (defun gnus-summary-remove-bookmark (article)
9439 "Remove the bookmark from the current article."
9440 (interactive (list (gnus-summary-article-number)))
9441 ;; Remove old bookmark, if one exists.
9442 (let ((old (assq article gnus-newsgroup-bookmarks)))
9445 (setq gnus-newsgroup-bookmarks
9446 (delq old gnus-newsgroup-bookmarks))
9447 (gnus-message 6 "Removed bookmark."))
9448 (gnus-message 6 "No bookmark in current article."))))
9450 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9451 (defun gnus-summary-mark-as-dormant (n)
9452 "Mark N articles forward as dormant.
9453 If N is negative, mark backward instead. The difference between N and
9454 the actual number of articles marked is returned."
9456 (gnus-summary-mark-forward n gnus-dormant-mark))
9458 (defun gnus-summary-set-process-mark (article)
9459 "Set the process mark on ARTICLE and update the summary line."
9460 (setq gnus-newsgroup-processable
9462 (delq article gnus-newsgroup-processable)))
9463 (when (gnus-summary-goto-subject article)
9464 (gnus-summary-show-thread)
9465 (gnus-summary-goto-subject article)
9466 (gnus-summary-update-secondary-mark article)))
9468 (defun gnus-summary-remove-process-mark (article)
9469 "Remove the process mark from ARTICLE and update the summary line."
9470 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9471 (when (gnus-summary-goto-subject article)
9472 (gnus-summary-show-thread)
9473 (gnus-summary-goto-subject article)
9474 (gnus-summary-update-secondary-mark article)))
9476 (defun gnus-summary-set-saved-mark (article)
9477 "Set the process mark on ARTICLE and update the summary line."
9478 (push article gnus-newsgroup-saved)
9479 (when (gnus-summary-goto-subject article)
9480 (gnus-summary-update-secondary-mark article)))
9482 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9483 "Mark N articles as read forwards.
9484 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9485 The difference between N and the actual number of articles marked is
9487 Iff NO-EXPIRE, auto-expiry will be inhibited."
9489 (gnus-summary-show-thread)
9490 (let ((backward (< n 0))
9491 (gnus-summary-goto-unread
9492 (and gnus-summary-goto-unread
9493 (not (eq gnus-summary-goto-unread 'never))
9494 (not (memq mark (list gnus-unread-mark
9495 gnus-ticked-mark gnus-dormant-mark)))))
9497 (mark (or mark gnus-del-mark)))
9499 (gnus-summary-mark-article nil mark no-expire)
9500 (zerop (gnus-summary-next-subject
9502 (and gnus-summary-goto-unread
9503 (not (eq gnus-summary-goto-unread 'never)))
9507 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9508 (gnus-summary-recenter)
9509 (gnus-summary-position-point)
9510 (gnus-set-mode-line 'summary)
9513 (defun gnus-summary-mark-article-as-read (mark)
9514 "Mark the current article quickly as read with MARK."
9515 (let ((article (gnus-summary-article-number)))
9516 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9517 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9518 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9519 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9520 (push (cons article mark) gnus-newsgroup-reads)
9521 ;; Possibly remove from cache, if that is used.
9522 (when gnus-use-cache
9523 (gnus-cache-enter-remove-article article))
9524 ;; Allow the backend to change the mark.
9525 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9526 ;; Check for auto-expiry.
9527 (when (and gnus-newsgroup-auto-expire
9528 (memq mark gnus-auto-expirable-marks))
9529 (setq mark gnus-expirable-mark)
9530 ;; Let the backend know about the mark change.
9531 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9532 (push article gnus-newsgroup-expirable))
9533 ;; Set the mark in the buffer.
9534 (gnus-summary-update-mark mark 'unread)
9537 (defun gnus-summary-mark-article-as-unread (mark)
9538 "Mark the current article quickly as unread with MARK."
9539 (let* ((article (gnus-summary-article-number))
9540 (old-mark (gnus-summary-article-mark article)))
9541 ;; Allow the backend to change the mark.
9542 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9543 (if (eq mark old-mark)
9547 (gnus-error 1 "Can't mark negative article numbers")
9549 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9550 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9551 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9552 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9553 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9554 (cond ((= mark gnus-ticked-mark)
9555 (setq gnus-newsgroup-marked
9556 (gnus-add-to-sorted-list gnus-newsgroup-marked
9558 ((= mark gnus-spam-mark)
9559 (setq gnus-newsgroup-spam-marked
9560 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9562 ((= mark gnus-dormant-mark)
9563 (setq gnus-newsgroup-dormant
9564 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9567 (setq gnus-newsgroup-unreads
9568 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9570 (gnus-pull article gnus-newsgroup-reads)
9572 ;; See whether the article is to be put in the cache.
9574 (vectorp (gnus-summary-article-header article))
9576 (gnus-cache-possibly-enter-article
9577 gnus-newsgroup-name article
9578 (gnus-summary-article-header article)
9579 (= mark gnus-ticked-mark)
9580 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9583 (gnus-summary-update-mark mark 'unread)
9586 (defun gnus-summary-mark-article (&optional article mark no-expire)
9587 "Mark ARTICLE with MARK. MARK can be any character.
9588 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9589 `??' (dormant) and `?E' (expirable).
9590 If MARK is nil, then the default character `?r' is used.
9591 If ARTICLE is nil, then the article on the current line will be
9593 Iff NO-EXPIRE, auto-expiry will be inhibited."
9594 ;; The mark might be a string.
9595 (when (stringp mark)
9596 (setq mark (aref mark 0)))
9597 ;; If no mark is given, then we check auto-expiring.
9599 (setq mark gnus-del-mark))
9600 (when (and (not no-expire)
9601 gnus-newsgroup-auto-expire
9602 (memq mark gnus-auto-expirable-marks))
9603 (setq mark gnus-expirable-mark))
9604 (let ((article (or article (gnus-summary-article-number)))
9605 (old-mark (gnus-summary-article-mark article)))
9606 ;; Allow the backend to change the mark.
9607 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9608 (if (eq mark old-mark)
9611 (error "No article on current line"))
9612 (if (not (if (or (= mark gnus-unread-mark)
9613 (= mark gnus-ticked-mark)
9614 (= mark gnus-spam-mark)
9615 (= mark gnus-dormant-mark))
9616 (gnus-mark-article-as-unread article mark)
9617 (gnus-mark-article-as-read article mark)))
9619 ;; See whether the article is to be put in the cache.
9621 (not (= mark gnus-canceled-mark))
9622 (vectorp (gnus-summary-article-header article))
9624 (gnus-cache-possibly-enter-article
9625 gnus-newsgroup-name article
9626 (gnus-summary-article-header article)
9627 (= mark gnus-ticked-mark)
9628 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9630 (when (gnus-summary-goto-subject article nil t)
9631 (let ((buffer-read-only nil))
9632 (gnus-summary-show-thread)
9634 (gnus-summary-update-mark mark 'unread)
9637 (defun gnus-summary-update-secondary-mark (article)
9638 "Update the secondary (read, process, cache) mark."
9639 (gnus-summary-update-mark
9640 (cond ((memq article gnus-newsgroup-processable)
9642 ((memq article gnus-newsgroup-cached)
9644 ((memq article gnus-newsgroup-replied)
9646 ((memq article gnus-newsgroup-forwarded)
9647 gnus-forwarded-mark)
9648 ((memq article gnus-newsgroup-saved)
9650 ((memq article gnus-newsgroup-recent)
9652 ((memq article gnus-newsgroup-unseen)
9656 (when (gnus-visual-p 'summary-highlight 'highlight)
9657 (gnus-run-hooks 'gnus-summary-update-hook))
9660 (defun gnus-summary-update-mark (mark type)
9661 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9662 (buffer-read-only nil))
9663 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9665 (when (looking-at "\r")
9667 (when (<= (+ forward (point)) (point-max))
9668 ;; Go to the right position on the line.
9669 (goto-char (+ forward (point)))
9670 ;; Replace the old mark with the new mark.
9671 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9672 ;; Optionally update the marks by some user rule.
9673 (when (eq type 'unread)
9675 (gnus-data-find (gnus-summary-article-number)) mark)
9676 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9678 (defun gnus-mark-article-as-read (article &optional mark)
9679 "Enter ARTICLE in the pertinent lists and remove it from others."
9680 ;; Make the article expirable.
9681 (let ((mark (or mark gnus-del-mark)))
9682 (setq gnus-newsgroup-expirable
9683 (if (= mark gnus-expirable-mark)
9684 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9685 (delq article gnus-newsgroup-expirable)))
9686 ;; Remove from unread and marked lists.
9687 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9688 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9689 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9690 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9691 (push (cons article mark) gnus-newsgroup-reads)
9692 ;; Possibly remove from cache, if that is used.
9693 (when gnus-use-cache
9694 (gnus-cache-enter-remove-article article))
9697 (defun gnus-mark-article-as-unread (article &optional mark)
9698 "Enter ARTICLE in the pertinent lists and remove it from others."
9699 (let ((mark (or mark gnus-ticked-mark)))
9702 (gnus-error 1 "Can't mark negative article numbers")
9704 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9705 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9706 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9707 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9708 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9710 ;; Unsuppress duplicates?
9711 (when gnus-suppress-duplicates
9712 (gnus-dup-unsuppress-article article))
9714 (cond ((= mark gnus-ticked-mark)
9715 (setq gnus-newsgroup-marked
9716 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9717 ((= mark gnus-spam-mark)
9718 (setq gnus-newsgroup-spam-marked
9719 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked article)))
9720 ((= mark gnus-dormant-mark)
9721 (setq gnus-newsgroup-dormant
9722 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9724 (setq gnus-newsgroup-unreads
9725 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9726 (gnus-pull article gnus-newsgroup-reads)
9729 (defalias 'gnus-summary-mark-as-unread-forward
9730 'gnus-summary-tick-article-forward)
9731 (make-obsolete 'gnus-summary-mark-as-unread-forward
9732 'gnus-summary-tick-article-forward)
9733 (defun gnus-summary-tick-article-forward (n)
9734 "Tick N articles forwards.
9735 If N is negative, tick backwards instead.
9736 The difference between N and the number of articles ticked is returned."
9738 (gnus-summary-mark-forward n gnus-ticked-mark))
9740 (defalias 'gnus-summary-mark-as-unread-backward
9741 'gnus-summary-tick-article-backward)
9742 (make-obsolete 'gnus-summary-mark-as-unread-backward
9743 'gnus-summary-tick-article-backward)
9744 (defun gnus-summary-tick-article-backward (n)
9745 "Tick N articles backwards.
9746 The difference between N and the number of articles ticked is returned."
9748 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9750 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9751 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9752 (defun gnus-summary-tick-article (&optional article clear-mark)
9753 "Mark current article as unread.
9754 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9755 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9757 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9760 (defun gnus-summary-mark-as-read-forward (n)
9761 "Mark N articles as read forwards.
9762 If N is negative, mark backwards instead.
9763 The difference between N and the actual number of articles marked is
9766 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9768 (defun gnus-summary-mark-as-read-backward (n)
9769 "Mark the N articles as read backwards.
9770 The difference between N and the actual number of articles marked is
9773 (gnus-summary-mark-forward
9774 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9776 (defun gnus-summary-mark-as-read (&optional article mark)
9777 "Mark current article as read.
9778 ARTICLE specifies the article to be marked as read.
9779 MARK specifies a string to be inserted at the beginning of the line."
9780 (gnus-summary-mark-article article mark))
9782 (defun gnus-summary-clear-mark-forward (n)
9783 "Clear marks from N articles forward.
9784 If N is negative, clear backward instead.
9785 The difference between N and the number of marks cleared is returned."
9787 (gnus-summary-mark-forward n gnus-unread-mark))
9789 (defun gnus-summary-clear-mark-backward (n)
9790 "Clear marks from N articles backward.
9791 The difference between N and the number of marks cleared is returned."
9793 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9795 (defun gnus-summary-mark-unread-as-read ()
9796 "Intended to be used by `gnus-summary-mark-article-hook'."
9797 (when (memq gnus-current-article gnus-newsgroup-unreads)
9798 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9800 (defun gnus-summary-mark-read-and-unread-as-read ()
9801 "Intended to be used by `gnus-summary-mark-article-hook'."
9802 (let ((mark (gnus-summary-article-mark)))
9803 (when (or (gnus-unread-mark-p mark)
9804 (gnus-read-mark-p mark))
9805 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9807 (defun gnus-summary-mark-unread-as-ticked ()
9808 "Intended to be used by `gnus-summary-mark-article-hook'."
9809 (when (memq gnus-current-article gnus-newsgroup-unreads)
9810 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9812 (defun gnus-summary-mark-region-as-read (point mark all)
9813 "Mark all unread articles between point and mark as read.
9814 If given a prefix, mark all articles between point and mark as read,
9815 even ticked and dormant ones."
9816 (interactive "r\nP")
9825 (memq (setq article (gnus-summary-article-number))
9826 gnus-newsgroup-unreads))
9827 (gnus-summary-mark-article article gnus-del-mark))
9829 (gnus-summary-find-next))))))
9831 (defun gnus-summary-mark-below (score mark)
9832 "Mark articles with score less than SCORE with MARK."
9833 (interactive "P\ncMark: ")
9834 (setq score (if score
9835 (prefix-numeric-value score)
9836 (or gnus-summary-default-score 0)))
9838 (set-buffer gnus-summary-buffer)
9839 (goto-char (point-min))
9842 (and (< (gnus-summary-article-score) score)
9843 (gnus-summary-mark-article nil mark))
9844 (gnus-summary-find-next)))))
9846 (defun gnus-summary-kill-below (&optional score)
9847 "Mark articles with score below SCORE as read."
9849 (gnus-summary-mark-below score gnus-killed-mark))
9851 (defun gnus-summary-clear-above (&optional score)
9852 "Clear all marks from articles with score above SCORE."
9854 (gnus-summary-mark-above score gnus-unread-mark))
9856 (defun gnus-summary-tick-above (&optional score)
9857 "Tick all articles with score above SCORE."
9859 (gnus-summary-mark-above score gnus-ticked-mark))
9861 (defun gnus-summary-mark-above (score mark)
9862 "Mark articles with score over SCORE with MARK."
9863 (interactive "P\ncMark: ")
9864 (setq score (if score
9865 (prefix-numeric-value score)
9866 (or gnus-summary-default-score 0)))
9868 (set-buffer gnus-summary-buffer)
9869 (goto-char (point-min))
9871 (when (> (gnus-summary-article-score) score)
9872 (gnus-summary-mark-article nil mark))
9874 (gnus-summary-find-next)))))
9876 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9877 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9878 (defun gnus-summary-limit-include-expunged (&optional no-error)
9879 "Display all the hidden articles that were expunged for low scores."
9881 (let ((buffer-read-only nil))
9882 (let ((scored gnus-newsgroup-scored)
9885 (unless (gnus-summary-article-header (caar scored))
9886 (and (setq h (gnus-number-to-header (caar scored)))
9887 (< (cdar scored) gnus-summary-expunge-below)
9889 (setq scored (cdr scored)))
9891 (when (not no-error)
9892 (error "No expunged articles hidden"))
9893 (goto-char (point-min))
9894 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9895 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9896 (mapcar (lambda (x) (push (mail-header-number x)
9897 gnus-newsgroup-limit))
9899 (gnus-summary-prepare-unthreaded (nreverse headers))
9900 (goto-char (point-min))
9901 (gnus-summary-position-point)
9904 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9905 "Mark all unread articles in this newsgroup as read.
9906 If prefix argument ALL is non-nil, ticked and dormant articles will
9907 also be marked as read.
9908 If QUIETLY is non-nil, no questions will be asked.
9909 If TO-HERE is non-nil, it should be a point in the buffer. All
9910 articles before (after, if REVERSE is set) this point will be marked as read.
9911 Note that this function will only catch up the unread article
9912 in the current summary buffer limitation.
9913 The number of articles marked as read is returned."
9918 (not gnus-interactive-catchup) ;Without confirmation?
9922 "Mark absolutely all articles as read? "
9923 "Mark all unread articles as read? ")))
9925 (not gnus-newsgroup-adaptive)
9926 (not gnus-newsgroup-auto-expire)
9927 (not gnus-suppress-duplicates)
9928 (or (not gnus-use-cache)
9929 (eq gnus-use-cache 'passive)))
9932 (setq gnus-newsgroup-marked nil
9933 gnus-newsgroup-spam-marked nil
9934 gnus-newsgroup-dormant nil))
9935 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9936 ;; We actually mark all articles as canceled, which we
9937 ;; have to do when using auto-expiry or adaptive scoring.
9938 (gnus-summary-show-all-threads)
9939 (if (and to-here reverse)
9943 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9944 (gnus-summary-find-next (not all) nil nil t))))
9945 (when (gnus-summary-first-subject (not all) t)
9947 (if to-here (< (point) to-here) t)
9948 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9949 (gnus-summary-find-next (not all) nil nil t)))))
9950 (gnus-set-mode-line 'summary))
9952 (gnus-summary-position-point)))
9954 (defun gnus-summary-catchup-to-here (&optional all)
9955 "Mark all unticked articles before the current one as read.
9956 If ALL is non-nil, also mark ticked and dormant articles as read."
9959 (gnus-save-hidden-threads
9960 (let ((beg (point)))
9961 ;; We check that there are unread articles.
9962 (when (or all (gnus-summary-find-prev))
9963 (gnus-summary-catchup all t beg)))))
9964 (gnus-summary-position-point))
9966 (defun gnus-summary-catchup-from-here (&optional all)
9967 "Mark all unticked articles after the current one as read.
9968 If ALL is non-nil, also mark ticked and dormant articles as read."
9971 (gnus-save-hidden-threads
9972 (let ((beg (point)))
9973 ;; We check that there are unread articles.
9974 (when (or all (gnus-summary-find-next))
9975 (gnus-summary-catchup all t beg nil t)))))
9976 (gnus-summary-position-point))
9978 (defun gnus-summary-catchup-all (&optional quietly)
9979 "Mark all articles in this newsgroup as read."
9981 (gnus-summary-catchup t quietly))
9983 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9984 "Mark all unread articles in this group as read, then exit.
9985 If prefix argument ALL is non-nil, all articles are marked as read.
9986 If QUIETLY is non-nil, no questions will be asked."
9988 (when (gnus-summary-catchup all quietly nil 'fast)
9989 ;; Select next newsgroup or exit.
9990 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9991 (eq gnus-auto-select-next 'quietly))
9992 (gnus-summary-next-group nil)
9993 (gnus-summary-exit))))
9995 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9996 "Mark all articles in this newsgroup as read, and then exit."
9998 (gnus-summary-catchup-and-exit t quietly))
10000 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10001 "Mark all articles in this group as read and select the next group.
10002 If given a prefix, mark all articles, unread as well as ticked, as
10006 (gnus-summary-catchup all))
10007 (gnus-summary-next-group))
10013 (defmacro gnus-with-article (article &rest forms)
10014 "Select ARTICLE and perform FORMS in the original article buffer.
10015 Then replace the article with the result."
10017 ;; We don't want the article to be marked as read.
10018 (let (gnus-mark-article-hook)
10019 (gnus-summary-select-article t t nil ,article))
10020 (set-buffer gnus-original-article-buffer)
10022 (if (not (gnus-check-backend-function
10023 'request-replace-article (car gnus-article-current)))
10024 (gnus-message 5 "Read-only group; not replacing")
10025 (unless (gnus-request-replace-article
10026 ,article (car gnus-article-current)
10027 (current-buffer) t)
10028 (error "Couldn't replace article")))
10029 ;; The cache and backlog have to be flushed somewhat.
10030 (when gnus-keep-backlog
10031 (gnus-backlog-remove-article
10032 (car gnus-article-current) (cdr gnus-article-current)))
10033 (when gnus-use-cache
10034 (gnus-cache-update-article
10035 (car gnus-article-current) (cdr gnus-article-current)))))
10037 (put 'gnus-with-article 'lisp-indent-function 1)
10038 (put 'gnus-with-article 'edebug-form-spec '(form body))
10040 ;; Thread-based commands.
10042 (defun gnus-summary-articles-in-thread (&optional article)
10043 "Return a list of all articles in the current thread.
10044 If ARTICLE is non-nil, return all articles in the thread that starts
10045 with that article."
10046 (let* ((article (or article (gnus-summary-article-number)))
10047 (data (gnus-data-find-list article))
10048 (top-level (gnus-data-level (car data)))
10050 (cond ((null gnus-thread-operation-ignore-subject)
10051 (gnus-simplify-subject-re
10052 (mail-header-subject (gnus-data-header (car data)))))
10053 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10054 (gnus-simplify-subject-fuzzy
10055 (mail-header-subject (gnus-data-header (car data)))))
10057 (end-point (save-excursion
10058 (if (gnus-summary-go-to-next-thread)
10059 (point) (point-max))))
10062 (< (gnus-data-pos (car data)) end-point))
10063 (when (or (not top-subject)
10064 (string= top-subject
10065 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10066 (gnus-simplify-subject-fuzzy
10067 (mail-header-subject
10068 (gnus-data-header (car data))))
10069 (gnus-simplify-subject-re
10070 (mail-header-subject
10071 (gnus-data-header (car data)))))))
10072 (push (gnus-data-number (car data)) articles))
10073 (unless (and (setq data (cdr data))
10074 (> (gnus-data-level (car data)) top-level))
10076 ;; Return the list of articles.
10077 (nreverse articles)))
10079 (defun gnus-summary-rethread-current ()
10080 "Rethread the thread the current article is part of."
10082 (let* ((gnus-show-threads t)
10083 (article (gnus-summary-article-number))
10084 (id (mail-header-id (gnus-summary-article-header)))
10085 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10087 (error "No article on the current line"))
10088 (gnus-rebuild-thread id)
10089 (gnus-summary-goto-subject article)))
10091 (defun gnus-summary-reparent-thread ()
10092 "Make the current article child of the marked (or previous) article.
10094 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10095 is non-nil or the Subject: of both articles are the same."
10097 (unless (not (gnus-group-read-only-p))
10098 (error "The current newsgroup does not support article editing"))
10099 (unless (<= (length gnus-newsgroup-processable) 1)
10100 (error "No more than one article may be marked"))
10101 (save-window-excursion
10102 (let ((gnus-article-buffer " *reparent*")
10103 (current-article (gnus-summary-article-number))
10104 ;; First grab the marked article, otherwise one line up.
10105 (parent-article (if (not (null gnus-newsgroup-processable))
10106 (car gnus-newsgroup-processable)
10108 (if (eq (forward-line -1) 0)
10109 (gnus-summary-article-number)
10110 (error "Beginning of summary buffer"))))))
10111 (unless (not (eq current-article parent-article))
10112 (error "An article may not be self-referential"))
10113 (let ((message-id (mail-header-id
10114 (gnus-summary-article-header parent-article))))
10115 (unless (and message-id (not (equal message-id "")))
10116 (error "No message-id in desired parent"))
10117 (gnus-with-article current-article
10119 (goto-char (point-min))
10120 (message-narrow-to-head)
10121 (if (re-search-forward "^References: " nil t)
10123 (re-search-forward "^[^ \t]" nil t)
10126 (insert " " message-id))
10127 (insert "References: " message-id "\n"))))
10128 (set-buffer gnus-summary-buffer)
10129 (gnus-summary-unmark-all-processable)
10130 (gnus-summary-update-article current-article)
10131 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10132 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10133 (gnus-summary-rethread-current)
10134 (gnus-message 3 "Article %d is now the child of article %d"
10135 current-article parent-article)))))
10137 (defun gnus-summary-toggle-threads (&optional arg)
10138 "Toggle showing conversation threads.
10139 If ARG is positive number, turn showing conversation threads on."
10141 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10142 (setq gnus-show-threads
10143 (if (null arg) (not gnus-show-threads)
10144 (> (prefix-numeric-value arg) 0)))
10145 (gnus-summary-prepare)
10146 (gnus-summary-goto-subject current)
10147 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10148 (gnus-summary-position-point)))
10150 (defun gnus-summary-show-all-threads ()
10151 "Show all threads."
10154 (let ((buffer-read-only nil))
10155 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10156 (gnus-summary-position-point))
10158 (defun gnus-summary-show-thread ()
10159 "Show thread subtrees.
10160 Returns nil if no thread was there to be shown."
10162 (let ((buffer-read-only nil)
10164 ;; first goto end then to beg, to have point at beg after let
10165 (end (progn (end-of-line) (point)))
10166 (beg (progn (beginning-of-line) (point))))
10168 ;; Any hidden lines here?
10169 (search-forward "\r" end t)
10170 (subst-char-in-region beg end ?\^M ?\n t)
10172 (gnus-summary-position-point))))
10174 (defun gnus-summary-maybe-hide-threads ()
10175 "If requested, hide the threads that should be hidden."
10176 (when (and gnus-show-threads
10177 gnus-thread-hide-subtree)
10178 (gnus-summary-hide-all-threads
10179 (if (or (consp gnus-thread-hide-subtree)
10180 (gnus-functionp gnus-thread-hide-subtree))
10181 (gnus-make-predicate gnus-thread-hide-subtree)
10184 ;;; Hiding predicates.
10186 (defun gnus-article-unread-p (header)
10187 (memq (mail-header-number header) gnus-newsgroup-unreads))
10189 (defun gnus-article-unseen-p (header)
10190 (memq (mail-header-number header) gnus-newsgroup-unseen))
10192 (defun gnus-map-articles (predicate articles)
10193 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10194 (apply 'gnus-or (mapcar predicate
10195 (mapcar 'gnus-summary-article-header articles))))
10197 (defun gnus-summary-hide-all-threads (&optional predicate)
10198 "Hide all thread subtrees.
10199 If PREDICATE is supplied, threads that satisfy this predicate
10200 will not be hidden."
10203 (goto-char (point-min))
10206 (when (or (not predicate)
10208 predicate (gnus-summary-article-children)))
10209 (gnus-summary-hide-thread))
10210 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10211 (gnus-summary-position-point))
10213 (defun gnus-summary-hide-thread ()
10214 "Hide thread subtrees.
10215 If PREDICATE is supplied, threads that satisfy this predicate
10216 will not be hidden.
10217 Returns nil if no threads were there to be hidden."
10219 (let ((buffer-read-only nil)
10221 (article (gnus-summary-article-number)))
10223 ;; Go forward until either the buffer ends or the subthread
10225 (when (and (not (eobp))
10226 (or (zerop (gnus-summary-next-thread 1 t))
10227 (goto-char (point-max))))
10229 (if (and (> (point) start)
10230 (search-backward "\n" start t))
10232 (subst-char-in-region start (point) ?\n ?\^M)
10233 (gnus-summary-goto-subject article))
10237 (defun gnus-summary-go-to-next-thread (&optional previous)
10238 "Go to the same level (or less) next thread.
10239 If PREVIOUS is non-nil, go to previous thread instead.
10240 Return the article number moved to, or nil if moving was impossible."
10241 (let ((level (gnus-summary-thread-level))
10242 (way (if previous -1 1))
10245 (while (and (not (eobp))
10246 (< level (gnus-summary-thread-level)))
10247 (forward-line way))
10254 (gnus-summary-article-number)
10255 (goto-char beg)))))
10257 (defun gnus-summary-next-thread (n &optional silent)
10258 "Go to the same level next N'th thread.
10259 If N is negative, search backward instead.
10260 Returns the difference between N and the number of skips actually
10263 If SILENT, don't output messages."
10265 (let ((backward (< n 0))
10267 (while (and (> n 0)
10268 (gnus-summary-go-to-next-thread backward))
10271 (gnus-summary-position-point))
10272 (when (and (not silent) (/= 0 n))
10273 (gnus-message 7 "No more threads"))
10276 (defun gnus-summary-prev-thread (n)
10277 "Go to the same level previous N'th thread.
10278 Returns the difference between N and the number of skips actually
10281 (gnus-summary-next-thread (- n)))
10283 (defun gnus-summary-go-down-thread ()
10284 "Go down one level in the current thread."
10285 (let ((children (gnus-summary-article-children)))
10287 (gnus-summary-goto-subject (car children)))))
10289 (defun gnus-summary-go-up-thread ()
10290 "Go up one level in the current thread."
10291 (let ((parent (gnus-summary-article-parent)))
10293 (gnus-summary-goto-subject parent))))
10295 (defun gnus-summary-down-thread (n)
10296 "Go down thread N steps.
10297 If N is negative, go up instead.
10298 Returns the difference between N and how many steps down that were
10303 (while (and (> n 0)
10304 (if up (gnus-summary-go-up-thread)
10305 (gnus-summary-go-down-thread)))
10307 (gnus-summary-position-point)
10309 (gnus-message 7 "Can't go further"))
10312 (defun gnus-summary-up-thread (n)
10313 "Go up thread N steps.
10314 If N is negative, go down instead.
10315 Returns the difference between N and how many steps down that were
10318 (gnus-summary-down-thread (- n)))
10320 (defun gnus-summary-top-thread ()
10321 "Go to the top of the thread."
10323 (while (gnus-summary-go-up-thread))
10324 (gnus-summary-article-number))
10326 (defun gnus-summary-kill-thread (&optional unmark)
10327 "Mark articles under current thread as read.
10328 If the prefix argument is positive, remove any kinds of marks.
10329 If the prefix argument is negative, tick articles instead."
10332 (setq unmark (prefix-numeric-value unmark)))
10333 (let ((articles (gnus-summary-articles-in-thread)))
10335 ;; Expand the thread.
10336 (gnus-summary-show-thread)
10337 ;; Mark all the articles.
10339 (gnus-summary-goto-subject (car articles))
10340 (cond ((null unmark)
10341 (gnus-summary-mark-article-as-read gnus-killed-mark))
10343 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10345 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10346 (setq articles (cdr articles))))
10347 ;; Hide killed subtrees.
10349 gnus-thread-hide-killed
10350 (gnus-summary-hide-thread))
10351 ;; If marked as read, go to next unread subject.
10352 (when (null unmark)
10353 ;; Go to next unread subject.
10354 (gnus-summary-next-subject 1 t)))
10355 (gnus-set-mode-line 'summary))
10357 ;; Summary sorting commands
10359 (defun gnus-summary-sort-by-number (&optional reverse)
10360 "Sort the summary buffer by article number.
10361 Argument REVERSE means reverse order."
10363 (gnus-summary-sort 'number reverse))
10365 (defun gnus-summary-sort-by-random (&optional reverse)
10366 "Randomize the order in the summary buffer.
10367 Argument REVERSE means to randomize in reverse order."
10369 (gnus-summary-sort 'random reverse))
10371 (defun gnus-summary-sort-by-author (&optional reverse)
10372 "Sort the summary buffer by author name alphabetically.
10373 If `case-fold-search' is non-nil, case of letters is ignored.
10374 Argument REVERSE means reverse order."
10376 (gnus-summary-sort 'author reverse))
10378 (defun gnus-summary-sort-by-subject (&optional reverse)
10379 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10380 If `case-fold-search' is non-nil, case of letters is ignored.
10381 Argument REVERSE means reverse order."
10383 (gnus-summary-sort 'subject reverse))
10385 (defun gnus-summary-sort-by-date (&optional reverse)
10386 "Sort the summary buffer by date.
10387 Argument REVERSE means reverse order."
10389 (gnus-summary-sort 'date reverse))
10391 (defun gnus-summary-sort-by-score (&optional reverse)
10392 "Sort the summary buffer by score.
10393 Argument REVERSE means reverse order."
10395 (gnus-summary-sort 'score reverse))
10397 (defun gnus-summary-sort-by-lines (&optional reverse)
10398 "Sort the summary buffer by the number of lines.
10399 Argument REVERSE means reverse order."
10401 (gnus-summary-sort 'lines reverse))
10403 (defun gnus-summary-sort-by-chars (&optional reverse)
10404 "Sort the summary buffer by article length.
10405 Argument REVERSE means reverse order."
10407 (gnus-summary-sort 'chars reverse))
10409 (defun gnus-summary-sort-by-original (&optional reverse)
10410 "Sort the summary buffer using the default sorting method.
10411 Argument REVERSE means reverse order."
10413 (let* ((buffer-read-only)
10414 (gnus-summary-prepare-hook nil))
10415 ;; We do the sorting by regenerating the threads.
10416 (gnus-summary-prepare)
10417 ;; Hide subthreads if needed.
10418 (gnus-summary-maybe-hide-threads)))
10420 (defun gnus-summary-sort (predicate reverse)
10421 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10422 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10423 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10424 (gnus-thread-sort-functions
10429 (gnus-sort-gathered-threads-function
10430 gnus-thread-sort-functions)
10431 (gnus-article-sort-functions
10435 (,article t2 t1))))
10437 (gnus-summary-prepare-hook nil))
10438 ;; We do the sorting by regenerating the threads.
10439 (gnus-summary-prepare)
10440 ;; Hide subthreads if needed.
10441 (gnus-summary-maybe-hide-threads)))
10443 ;; Summary saving commands.
10445 (defun gnus-summary-save-article (&optional n not-saved)
10446 "Save the current article using the default saver function.
10447 If N is a positive number, save the N next articles.
10448 If N is a negative number, save the N previous articles.
10449 If N is nil and any articles have been marked with the process mark,
10450 save those articles instead.
10451 The variable `gnus-default-article-saver' specifies the saver function."
10453 (let* ((articles (gnus-summary-work-articles n))
10454 (save-buffer (save-excursion
10455 (nnheader-set-temp-buffer " *Gnus Save*")))
10456 (num (length articles))
10458 (dolist (article articles)
10459 (setq header (gnus-summary-article-header article))
10460 (if (not (vectorp header))
10461 ;; This is a pseudo-article.
10462 (if (assq 'name header)
10463 (gnus-copy-file (cdr (assq 'name header)))
10464 (gnus-message 1 "Article %d is unsaveable" article))
10465 ;; This is a real article.
10466 (save-window-excursion
10467 (let ((gnus-display-mime-function nil)
10468 (gnus-article-prepare-hook nil))
10469 (gnus-summary-select-article t nil nil article)))
10471 (set-buffer save-buffer)
10473 (insert-buffer-substring gnus-original-article-buffer))
10474 (setq file (gnus-article-save save-buffer file num))
10475 (gnus-summary-remove-process-mark article)
10477 (gnus-summary-set-saved-mark article))))
10478 (gnus-kill-buffer save-buffer)
10479 (gnus-summary-position-point)
10480 (gnus-set-mode-line 'summary)
10483 (defun gnus-summary-pipe-output (&optional arg)
10484 "Pipe the current article to a subprocess.
10485 If N is a positive number, pipe the N next articles.
10486 If N is a negative number, pipe the N previous articles.
10487 If N is nil and any articles have been marked with the process mark,
10488 pipe those articles instead."
10490 (require 'gnus-art)
10491 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10492 (gnus-summary-save-article arg t))
10493 (let ((buffer (get-buffer "*Shell Command Output*")))
10495 (with-current-buffer buffer (> (point-max) (point-min))))
10496 (gnus-configure-windows 'pipe))))
10498 (defun gnus-summary-save-article-mail (&optional arg)
10499 "Append the current article to an mail file.
10500 If N is a positive number, save the N next articles.
10501 If N is a negative number, save the N previous articles.
10502 If N is nil and any articles have been marked with the process mark,
10503 save those articles instead."
10505 (require 'gnus-art)
10506 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10507 (gnus-summary-save-article arg)))
10509 (defun gnus-summary-save-article-rmail (&optional arg)
10510 "Append the current article to an rmail file.
10511 If N is a positive number, save the N next articles.
10512 If N is a negative number, save the N previous articles.
10513 If N is nil and any articles have been marked with the process mark,
10514 save those articles instead."
10516 (require 'gnus-art)
10517 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10518 (gnus-summary-save-article arg)))
10520 (defun gnus-summary-save-article-file (&optional arg)
10521 "Append the current article to a file.
10522 If N is a positive number, save the N next articles.
10523 If N is a negative number, save the N previous articles.
10524 If N is nil and any articles have been marked with the process mark,
10525 save those articles instead."
10527 (require 'gnus-art)
10528 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10529 (gnus-summary-save-article arg)))
10531 (defun gnus-summary-write-article-file (&optional arg)
10532 "Write the current article to a file, deleting the previous file.
10533 If N is a positive number, save the N next articles.
10534 If N is a negative number, save the N previous articles.
10535 If N is nil and any articles have been marked with the process mark,
10536 save those articles instead."
10538 (require 'gnus-art)
10539 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10540 (gnus-summary-save-article arg)))
10542 (defun gnus-summary-save-article-body-file (&optional arg)
10543 "Append the current article body to a file.
10544 If N is a positive number, save the N next articles.
10545 If N is a negative number, save the N previous articles.
10546 If N is nil and any articles have been marked with the process mark,
10547 save those articles instead."
10549 (require 'gnus-art)
10550 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10551 (gnus-summary-save-article arg)))
10553 (defun gnus-summary-muttprint (&optional arg)
10554 "Print the current article using Muttprint.
10555 If N is a positive number, save the N next articles.
10556 If N is a negative number, save the N previous articles.
10557 If N is nil and any articles have been marked with the process mark,
10558 save those articles instead."
10560 (require 'gnus-art)
10561 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10562 (gnus-summary-save-article arg t)))
10564 (defun gnus-summary-pipe-message (program)
10565 "Pipe the current article through PROGRAM."
10566 (interactive "sProgram: ")
10567 (gnus-summary-select-article)
10568 (let ((mail-header-separator ""))
10569 (gnus-eval-in-buffer-window gnus-article-buffer
10572 (let ((start (window-start))
10574 (message-pipe-buffer-body program)
10575 (set-window-start (get-buffer-window (current-buffer)) start))))))
10577 (defun gnus-get-split-value (methods)
10578 "Return a value based on the split METHODS."
10579 (let (split-name method result match)
10582 (set-buffer gnus-original-article-buffer)
10584 (nnheader-narrow-to-headers)
10585 (while (and methods (not split-name))
10586 (goto-char (point-min))
10587 (setq method (pop methods))
10588 (setq match (car method))
10591 ;; Regular expression.
10593 (re-search-forward match nil t)))
10594 ((gnus-functionp match)
10598 (setq result (funcall match gnus-newsgroup-name))))
10603 (setq result (eval match)))))
10604 (setq split-name (cdr method))
10605 (cond ((stringp result)
10606 (push (expand-file-name
10607 result gnus-article-save-directory)
10610 (setq split-name (append result split-name)))))))))
10611 (nreverse split-name)))
10613 (defun gnus-valid-move-group-p (group)
10614 (and (boundp group)
10615 (symbol-name group)
10616 (symbol-value group)
10617 (gnus-get-function (gnus-find-method-for-group
10618 (symbol-name group)) 'request-accept-article t)))
10620 (defun gnus-read-move-group-name (prompt default articles prefix)
10621 "Read a group name."
10622 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10623 (minibuffer-confirm-incomplete nil) ; XEmacs
10625 (format "%s %s to:"
10627 (if (> (length articles) 1)
10628 (format "these %d articles" (length articles))
10633 (gnus-completing-read-with-default
10636 'gnus-valid-move-group-p
10638 'gnus-group-history))
10639 ((= 1 (length split-name))
10640 (gnus-completing-read-with-default
10641 (car split-name) prom
10643 'gnus-valid-move-group-p
10645 'gnus-group-history))
10647 (gnus-completing-read-with-default
10649 (mapcar (lambda (el) (list el))
10650 (nreverse split-name))
10652 'gnus-group-history))))
10653 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10655 (if (or (string= to-newsgroup "")
10656 (string= to-newsgroup prefix))
10657 (setq to-newsgroup default))
10658 (unless to-newsgroup
10659 (error "No group name entered"))
10660 (or (gnus-active to-newsgroup)
10661 (gnus-activate-group to-newsgroup nil nil to-method)
10662 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10664 (or (and (gnus-request-create-group to-newsgroup to-method)
10665 (gnus-activate-group
10666 to-newsgroup nil nil to-method)
10667 (gnus-subscribe-group to-newsgroup))
10668 (error "Couldn't create group %s" to-newsgroup)))
10669 (error "No such group: %s" to-newsgroup)))
10672 (defun gnus-summary-save-parts (type dir n &optional reverse)
10673 "Save parts matching TYPE to DIR.
10674 If REVERSE, save parts that do not match TYPE."
10676 (list (read-string "Save parts of type: "
10677 (or (car gnus-summary-save-parts-type-history)
10678 gnus-summary-save-parts-default-mime)
10679 'gnus-summary-save-parts-type-history)
10680 (setq gnus-summary-save-parts-last-directory
10681 (read-file-name "Save to directory: "
10682 gnus-summary-save-parts-last-directory
10684 current-prefix-arg))
10685 (gnus-summary-iterate n
10686 (let ((gnus-display-mime-function nil)
10687 (gnus-inhibit-treatment t))
10688 (gnus-summary-select-article))
10690 (set-buffer gnus-article-buffer)
10691 (let ((handles (or gnus-article-mime-handles
10692 (mm-dissect-buffer nil gnus-article-loose-mime)
10695 (gnus-summary-save-parts-1 type dir handles reverse)
10696 (unless gnus-article-mime-handles ;; Don't destroy this case.
10697 (mm-destroy-parts handles)))))))
10699 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10700 (if (stringp (car handle))
10701 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10704 (not (string-match type (mm-handle-media-type handle)))
10705 (string-match type (mm-handle-media-type handle)))
10706 (let ((file (expand-file-name
10707 (file-name-nondirectory
10709 (mail-content-type-get
10710 (mm-handle-disposition handle) 'filename)
10711 (concat gnus-newsgroup-name
10712 "." (number-to-string
10713 (cdr gnus-article-current)))))
10715 (unless (file-exists-p file)
10716 (mm-save-part-to-file handle file))))))
10718 ;; Summary extract commands
10720 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10721 (let ((buffer-read-only nil)
10722 (article (gnus-summary-article-number))
10724 (unless (gnus-summary-goto-subject article)
10725 (error "No such article: %d" article))
10726 (gnus-summary-position-point)
10727 ;; If all commands are to be bunched up on one line, we collect
10729 (unless gnus-view-pseudos-separately
10730 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10733 (setq action (cdr (assq 'action (car ps))))
10734 (setq files (list (cdr (assq 'name (car ps)))))
10735 (while (and ps (cdr ps)
10736 (string= (or action "1")
10737 (or (cdr (assq 'action (cadr ps))) "2")))
10738 (push (cdr (assq 'name (cadr ps))) files)
10739 (setcdr ps (cddr ps)))
10741 (when (not (string-match "%s" action))
10744 (when (assq 'execute (car ps))
10745 (setcdr (assq 'execute (car ps))
10746 (funcall (if (string-match "%s" action)
10753 (gnus-quote-arg-for-sh-or-csh f)))
10755 (setq ps (cdr ps)))))
10756 (if (and gnus-view-pseudos (not not-view))
10758 (when (assq 'execute (car pslist))
10759 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10760 (eq gnus-view-pseudos 'not-confirm)))
10761 (setq pslist (cdr pslist)))
10764 (setq after-article (or (cdr (assq 'article (car pslist)))
10765 (gnus-summary-article-number)))
10766 (gnus-summary-goto-subject after-article)
10769 (insert " " (file-name-nondirectory
10770 (cdr (assq 'name (car pslist))))
10771 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10773 (forward-line -1) ; back to `b'
10774 (gnus-add-text-properties
10775 b (1- e) (list 'gnus-number gnus-reffed-article-number
10776 gnus-mouse-face-prop gnus-mouse-face))
10778 after-article gnus-reffed-article-number
10779 gnus-unread-mark b (car pslist) 0 (- e b))
10780 (setq gnus-newsgroup-unreads
10781 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10782 gnus-reffed-article-number))
10783 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10784 (setq pslist (cdr pslist)))))))
10786 (defun gnus-pseudos< (p1 p2)
10787 (let ((c1 (cdr (assq 'action p1)))
10788 (c2 (cdr (assq 'action p2))))
10789 (and c1 c2 (string< c1 c2))))
10791 (defun gnus-request-pseudo-article (props)
10792 (cond ((assq 'execute props)
10793 (gnus-execute-command (cdr (assq 'execute props)))))
10794 (let ((gnus-current-article (gnus-summary-article-number)))
10795 (gnus-run-hooks 'gnus-mark-article-hook)))
10797 (defun gnus-execute-command (command &optional automatic)
10799 (gnus-article-setup-buffer)
10800 (set-buffer gnus-article-buffer)
10801 (setq buffer-read-only nil)
10802 (let ((command (if automatic command
10803 (read-string "Command: " (cons command 0)))))
10805 (insert "$ " command "\n\n")
10806 (if gnus-view-pseudo-asynchronously
10807 (start-process "gnus-execute" (current-buffer) shell-file-name
10808 shell-command-switch command)
10809 (call-process shell-file-name nil t nil
10810 shell-command-switch command)))))
10812 ;; Summary kill commands.
10814 (defun gnus-summary-edit-global-kill (article)
10815 "Edit the \"global\" kill file."
10816 (interactive (list (gnus-summary-article-number)))
10817 (gnus-group-edit-global-kill article))
10819 (defun gnus-summary-edit-local-kill ()
10820 "Edit a local kill file applied to the current newsgroup."
10822 (setq gnus-current-headers (gnus-summary-article-header))
10823 (gnus-group-edit-local-kill
10824 (gnus-summary-article-number) gnus-newsgroup-name))
10826 ;;; Header reading.
10828 (defun gnus-read-header (id &optional header)
10829 "Read the headers of article ID and enter them into the Gnus system."
10830 (let ((group gnus-newsgroup-name)
10831 (gnus-override-method
10833 gnus-override-method
10834 (and (gnus-news-group-p gnus-newsgroup-name)
10835 (car (gnus-refer-article-methods)))))
10837 ;; First we check to see whether the header in question is already
10840 ;; This is a Message-ID.
10841 (setq header (or header (gnus-id-to-header id)))
10842 ;; This is an article number.
10843 (setq header (or header (gnus-summary-article-header id))))
10845 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10846 ;; We have found the header.
10848 ;; If this is a sparse article, we have to nix out its
10849 ;; previous entry in the thread hashtb.
10851 (gnus-summary-article-sparse-p (mail-header-number header)))
10852 (let* ((parent (gnus-parent-id (mail-header-references header)))
10853 (thread (and parent (gnus-id-to-thread parent))))
10855 (delq (assq header thread) thread))))
10856 ;; We have to really fetch the header to this article.
10858 (set-buffer nntp-server-buffer)
10859 (when (setq where (gnus-request-head id group))
10860 (nnheader-fold-continuation-lines)
10861 (goto-char (point-max))
10863 (goto-char (point-min))
10867 ((cdr where) (cdr where))
10868 (header (mail-header-number header))
10869 (t gnus-reffed-article-number))
10871 (insert " Article retrieved.\n"))
10872 (if (or (not where)
10873 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10874 () ; Malformed head.
10875 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10876 (when (and (stringp id)
10877 (not (string= (gnus-group-real-name group)
10879 ;; If we fetched by Message-ID and the article came
10880 ;; from a different group, we fudge some bogus article
10881 ;; numbers for this article.
10882 (mail-header-set-number header gnus-reffed-article-number))
10884 (set-buffer gnus-summary-buffer)
10885 (decf gnus-reffed-article-number)
10886 (gnus-remove-header (mail-header-number header))
10887 (push header gnus-newsgroup-headers)
10888 (setq gnus-current-headers header)
10889 (push (mail-header-number header) gnus-newsgroup-limit)))
10892 (defun gnus-remove-header (number)
10893 "Remove header NUMBER from `gnus-newsgroup-headers'."
10894 (if (and gnus-newsgroup-headers
10895 (= number (mail-header-number (car gnus-newsgroup-headers))))
10896 (pop gnus-newsgroup-headers)
10897 (let ((headers gnus-newsgroup-headers))
10898 (while (and (cdr headers)
10899 (not (= number (mail-header-number (cadr headers)))))
10901 (when (cdr headers)
10902 (setcdr headers (cddr headers))))))
10905 ;;; summary highlights
10908 (defun gnus-highlight-selected-summary ()
10909 "Highlight selected article in summary buffer."
10910 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10911 (when gnus-summary-selected-face
10913 (let* ((beg (progn (beginning-of-line) (point)))
10914 (end (progn (end-of-line) (point)))
10915 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10916 (from (if (get-text-property beg gnus-mouse-face-prop)
10918 (or (next-single-property-change
10919 beg gnus-mouse-face-prop nil end)
10924 (or (next-single-property-change
10925 from gnus-mouse-face-prop nil end)
10927 ;; If no mouse-face prop on line we will have to = from = end,
10928 ;; so we highlight the entire line instead.
10929 (when (= (+ to 2) from)
10932 (if gnus-newsgroup-selected-overlay
10933 ;; Move old overlay.
10935 gnus-newsgroup-selected-overlay from to (current-buffer))
10936 ;; Create new overlay.
10938 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10939 'face gnus-summary-selected-face))))))
10941 (defvar gnus-summary-highlight-line-cached nil)
10942 (defvar gnus-summary-highlight-line-trigger nil)
10943 (defun gnus-summary-highlight-line-0 ()
10944 (if (and (eq gnus-summary-highlight-line-trigger
10945 gnus-summary-highlight)
10946 gnus-summary-highlight-line-cached)
10947 gnus-summary-highlight-line-cached
10948 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
10949 gnus-summary-highlight-line-cached
10950 (let* ((cond (list 'cond))
10952 (list gnus-summary-highlight))
10954 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
10957 (gnus-byte-compile (list 'lambda nil cond))))))
10959 (defvar gnus-summary-highlight-line-downloaded-alist nil)
10960 (defvar gnus-summary-highlight-line-downloaded-cached nil)
10962 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10963 (defun gnus-summary-highlight-line ()
10964 "Highlight current line according to `gnus-summary-highlight'."
10965 (let* ((list gnus-summary-highlight)
10966 (beg (gnus-point-at-bol))
10967 (article (gnus-summary-article-number))
10968 (score (or (cdr (assq (or article gnus-current-article)
10969 gnus-newsgroup-scored))
10970 gnus-summary-default-score 0))
10971 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10972 (inhibit-read-only t)
10973 (default gnus-summary-default-score)
10974 (default-high gnus-summary-default-high-score)
10975 (default-low gnus-summary-default-low-score)
10976 (downloaded (and (boundp 'gnus-agent-article-alist)
10977 gnus-agent-article-alist
10978 ;; Optimized for when gnus-summary-highlight-line is called multiple times for articles in ascending order (i.e. initial generation of summary buffer).
10980 (if (and (eq gnus-summary-highlight-line-downloaded-alist gnus-agent-article-alist)
10981 (<= (caar gnus-summary-highlight-line-downloaded-cached) article))
10983 (setq gnus-summary-highlight-line-downloaded-alist gnus-agent-article-alist
10984 gnus-summary-highlight-line-downloaded-cached gnus-agent-article-alist))
10986 (while (and (< (caar gnus-summary-highlight-line-downloaded-cached) article)
10987 (setq n (cdr gnus-summary-highlight-line-downloaded-cached)))
10988 (setq gnus-summary-highlight-line-downloaded-cached n)))
10989 (and (eq (caar gnus-summary-highlight-line-downloaded-cached) article)
10990 (cdar gnus-summary-highlight-line-downloaded-cached))))))
10991 (let ((face (funcall (gnus-summary-highlight-line-0))))
10992 (unless (eq face (get-text-property beg 'face))
10993 (gnus-put-text-property-excluding-characters-with-faces
10994 beg (gnus-point-at-eol) 'face
10995 (setq face (if (boundp face) (symbol-value face) face)))
10996 (when gnus-summary-highlight-line-function
10997 (funcall gnus-summary-highlight-line-function article face))))))
10999 (defun gnus-update-read-articles (group unread &optional compute)
11000 "Update the list of read articles in GROUP.
11001 UNREAD is a sorted list."
11002 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11003 (entry (gnus-gethash group gnus-newsrc-hashtb))
11004 (info (nth 2 entry))
11007 (if (or (not info) (not active))
11008 ;; There is no info on this group if it was, in fact,
11009 ;; killed. Gnus stores no information on killed groups, so
11010 ;; there's nothing to be done.
11011 ;; One could store the information somewhere temporarily,
11012 ;; perhaps... Hmmm...
11014 ;; Remove any negative articles numbers.
11015 (while (and unread (< (car unread) 0))
11016 (setq unread (cdr unread)))
11017 ;; Remove any expired article numbers
11018 (while (and unread (< (car unread) (car active)))
11019 (setq unread (cdr unread)))
11020 ;; Compute the ranges of read articles by looking at the list of
11021 ;; unread articles.
11023 (when (/= (car unread) prev)
11024 (push (if (= prev (1- (car unread))) prev
11025 (cons prev (1- (car unread))))
11027 (setq prev (1+ (car unread)))
11028 (setq unread (cdr unread)))
11029 (when (<= prev (cdr active))
11030 (push (cons prev (cdr active)) read))
11031 (setq read (if (> (length read) 1) (nreverse read) read))
11036 ;; Propagate the read marks to the backend.
11037 (when (gnus-check-backend-function 'request-set-mark group)
11038 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11039 (add (gnus-remove-from-range read (gnus-info-read info))))
11041 (unless (gnus-check-group group)
11042 (error "Can't open server for %s" group))
11043 (gnus-request-set-mark
11044 group (delq nil (list (if add (list add 'add '(read)))
11045 (if del (list del 'del '(read))))))
11047 `(gnus-request-set-mark
11050 (if del (list del 'add '(read)))
11051 (if add (list add 'del '(read))))))))))
11052 (set-buffer gnus-group-buffer)
11053 (gnus-undo-register
11055 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11056 (gnus-info-set-read ',info ',(gnus-info-read info))
11057 (gnus-get-unread-articles-in-group ',info
11058 (gnus-active ,group))
11059 (gnus-group-update-group ,group t)
11061 ;; Enter this list into the group info.
11062 (gnus-info-set-read info read)
11063 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11064 (gnus-get-unread-articles-in-group info (gnus-active group))
11067 (defun gnus-offer-save-summaries ()
11068 "Offer to save all active summary buffers."
11070 ;; Go through all buffers and find all summaries.
11071 (dolist (buffer (buffer-list))
11072 (when (and (setq buffer (buffer-name buffer))
11073 (string-match "Summary" buffer)
11075 (set-buffer buffer)
11076 ;; We check that this is, indeed, a summary buffer.
11077 (and (eq major-mode 'gnus-summary-mode)
11078 ;; Also make sure this isn't bogus.
11079 gnus-newsgroup-prepared
11080 ;; Also make sure that this isn't a
11081 ;; dead summary buffer.
11082 (not gnus-dead-summary-mode))))
11083 (push buffer buffers)))
11084 ;; Go through all these summary buffers and offer to save them.
11088 "Update summary buffer %s? "
11090 (switch-to-buffer buf)
11091 (gnus-summary-exit))
11095 ;;; @ for mime-partial
11098 (defun gnus-request-partial-message ()
11100 (let ((number (gnus-summary-article-number))
11101 (group gnus-newsgroup-name)
11102 (mother gnus-article-buffer))
11103 (set-buffer (get-buffer-create " *Partial Article*"))
11105 (setq mime-preview-buffer mother)
11106 (gnus-request-article-this-buffer number group)
11107 (mime-parse-buffer)
11110 (autoload 'mime-combine-message/partial-pieces-automatically
11112 "Internal method to combine message/partial messages automatically.")
11114 (mime-add-condition
11115 'action '((type . message)(subtype . partial)
11116 (major-mode . gnus-original-article-mode)
11117 (method . mime-combine-message/partial-pieces-automatically)
11118 (summary-buffer-exp . gnus-summary-buffer)
11119 (request-partial-message-method . gnus-request-partial-message)
11123 ;;; @ for message/rfc822
11126 (defun gnus-mime-extract-message/rfc822 (entity situation)
11127 "Burst a forwarded article."
11129 (set-buffer gnus-summary-buffer)
11130 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11131 gnus-newsgroup-name 'gnus-group-history))
11132 (gnus-group-marked (list group))
11135 (mime-insert-entity-content entity)
11136 (setq article (gnus-request-accept-article group)))
11137 (when (and (consp article)
11138 (numberp (setq article (cdr article))))
11139 (setq info (gnus-get-info group))
11140 (gnus-info-set-read info
11141 (gnus-remove-from-range (gnus-info-read info)
11143 (when (string-equal group gnus-newsgroup-name)
11145 (let (gnus-show-threads)
11146 (gnus-summary-goto-subject article t))
11147 (gnus-summary-clear-mark-forward 1))
11148 (set-buffer gnus-group-buffer)
11149 (gnus-group-get-new-news-this-group nil t)))))
11151 (mime-add-condition
11152 'action '((type . message)(subtype . rfc822)
11153 (major-mode . gnus-original-article-mode)
11154 (method . gnus-mime-extract-message/rfc822)
11158 (mime-add-condition
11159 'action '((type . message)(subtype . news)
11160 (major-mode . gnus-original-article-mode)
11161 (method . gnus-mime-extract-message/rfc822)
11165 (defun gnus-mime-extract-multipart (entity situation)
11166 (let ((children (mime-entity-children entity))
11167 mime-acting-situation-to-override
11170 (mime-play-entity (car children)
11171 (cons (assq 'mode situation)
11172 mime-acting-situation-to-override))
11173 (setq children (cdr children)))
11174 (if (setq f (cdr (assq 'after-method
11175 mime-acting-situation-to-override)))
11179 (mime-add-condition
11180 'action '((type . multipart)
11181 (method . gnus-mime-extract-multipart)
11190 (defun gnus-summary-inherit-default-charset ()
11191 "Import `default-mime-charset' from summary buffer.
11192 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11194 (if (buffer-live-p gnus-summary-buffer)
11195 (let (d-m-c d-m-c-u)
11196 (with-current-buffer gnus-summary-buffer
11197 (setq d-m-c (if (local-variable-p 'default-mime-charset
11198 gnus-summary-buffer)
11199 default-mime-charset
11202 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11203 gnus-summary-buffer)
11204 (symbol-value 'default-mime-charset-unlimited)
11207 (kill-local-variable 'default-mime-charset)
11208 (set (make-local-variable 'default-mime-charset) d-m-c))
11210 (kill-local-variable 'default-mime-charset-unlimited)
11211 (set (make-local-variable 'default-mime-charset-unlimited)
11214 (defun gnus-summary-setup-default-charset ()
11215 "Setup newsgroup default charset."
11216 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11218 (setq gnus-newsgroup-charset nil)
11219 (set (make-local-variable 'default-mime-charset) nil)
11220 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11221 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11222 (let ((ignored-charsets
11223 (or gnus-newsgroup-ephemeral-ignored-charsets
11225 (and gnus-newsgroup-name
11226 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11227 gnus-newsgroup-ignored-charsets)))
11229 (setq gnus-newsgroup-charset
11230 (or gnus-newsgroup-ephemeral-charset
11231 (when (and gnus-newsgroup-name
11232 (setq charset (gnus-parameter-charset
11233 gnus-newsgroup-name)))
11234 (make-local-variable 'default-mime-charset)
11235 (setq default-mime-charset charset))
11236 gnus-default-charset))
11237 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11238 ignored-charsets))))
11244 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11245 "Display the current article buffer fully MIME-buttonized.
11246 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11247 treated as multipart/mixed."
11249 (require 'gnus-art)
11250 (let ((gnus-unbuttonized-mime-types nil)
11251 (gnus-mime-display-multipart-as-mixed show-all-parts))
11252 (gnus-summary-show-article)))
11254 (defun gnus-summary-repair-multipart (article)
11255 "Add a Content-Type header to a multipart article without one."
11256 (interactive (list (gnus-summary-article-number)))
11257 (gnus-with-article article
11258 (message-narrow-to-head)
11259 (message-remove-header "Mime-Version")
11260 (goto-char (point-max))
11261 (insert "Mime-Version: 1.0\n")
11263 (when (search-forward "\n--" nil t)
11264 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11265 (message-narrow-to-head)
11266 (message-remove-header "Content-Type")
11267 (goto-char (point-max))
11268 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11271 (let (gnus-mark-article-hook)
11272 (gnus-summary-select-article t t nil article)))
11274 (defun gnus-summary-toggle-display-buttonized ()
11275 "Toggle the buttonizing of the article buffer."
11277 (require 'gnus-art)
11278 (if (setq gnus-inhibit-mime-unbuttonizing
11279 (not gnus-inhibit-mime-unbuttonizing))
11280 (let ((gnus-unbuttonized-mime-types nil))
11281 (gnus-summary-show-article))
11282 (gnus-summary-show-article)))
11285 ;;; Intelli-mouse commmands
11288 (defun gnus-wheel-summary-scroll (event)
11290 (let ((amount (if (memq 'shift (event-modifiers event))
11291 (car gnus-wheel-scroll-amount)
11292 (cdr gnus-wheel-scroll-amount)))
11293 (direction (- (* (static-if (featurep 'xemacs)
11294 (event-button event)
11295 (cond ((eq 'mouse-4 (event-basic-type event))
11297 ((eq 'mouse-5 (event-basic-type event))
11301 (gnus-summary-scroll-up (* amount direction))
11302 (when (gnus-eval-in-buffer-window gnus-article-buffer
11305 (and (if (< 0 direction)
11306 (gnus-article-next-page 0)
11307 (gnus-article-prev-page 0)
11309 (if (setq edge (get-text-property
11310 (point-min) 'gnus-wheel-edge))
11311 (setq edge (* edge direction))
11314 (let ((buffer-read-only nil)
11315 (inhibit-read-only t))
11316 (put-text-property (point-min) (point-max)
11317 'gnus-wheel-edge direction)
11319 (or (> edge gnus-wheel-edge-resistance)
11320 (let ((buffer-read-only nil)
11321 (inhibit-read-only t))
11322 (put-text-property (point-min) (point-max)
11324 (* (1+ edge) direction))
11326 (eq last-command 'gnus-wheel-summary-scroll))))
11327 (gnus-summary-next-article nil nil (minusp direction)))))
11329 (defun gnus-wheel-install ()
11330 "Enable mouse wheel support on summary window."
11331 (when gnus-use-wheel
11333 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11335 (define-key gnus-summary-mode-map key
11336 'gnus-wheel-summary-scroll)))))
11338 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11341 ;;; Traditional PGP commmands
11344 (defun gnus-summary-decrypt-article (&optional force)
11345 "Decrypt the current article in traditional PGP way.
11346 This will have permanent effect only in mail groups.
11347 If FORCE is non-nil, allow editing of articles even in read-only
11350 (gnus-summary-select-article t)
11351 (gnus-eval-in-buffer-window gnus-article-buffer
11355 (goto-char (point-min))
11356 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11357 (error "Not a traditional PGP message!"))
11358 (let ((armor-start (match-beginning 0)))
11359 (if (and (pgg-decrypt-region armor-start (point-max))
11360 (or force (not (gnus-group-read-only-p))))
11361 (let ((inhibit-read-only t)
11363 (delete-region armor-start
11365 (re-search-forward "^-+END PGP" nil t)
11366 (beginning-of-line 2)
11368 (insert-buffer-substring pgg-output-buffer))))))))
11370 (defun gnus-summary-verify-article ()
11371 "Verify the current article in traditional PGP way."
11374 (set-buffer gnus-original-article-buffer)
11375 (goto-char (point-min))
11376 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11377 (error "Not a traditional PGP message!"))
11378 (re-search-forward "^-+END PGP" nil t)
11379 (beginning-of-line 2)
11380 (call-interactively (function pgg-verify-region))))
11383 ;;; Generic summary marking commands
11386 (defvar gnus-summary-marking-alist
11387 '((read gnus-del-mark "d")
11388 (unread gnus-unread-mark "u")
11389 (ticked gnus-ticked-mark "!")
11390 (dormant gnus-dormant-mark "?")
11391 (expirable gnus-expirable-mark "e"))
11392 "An alist of names/marks/keystrokes.")
11394 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11395 (defvar gnus-summary-mark-map)
11397 (defun gnus-summary-make-all-marking-commands ()
11398 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11399 (dolist (elem gnus-summary-marking-alist)
11400 (apply 'gnus-summary-make-marking-command elem)))
11402 (defun gnus-summary-make-marking-command (name mark keystroke)
11403 (let ((map (make-sparse-keymap)))
11404 (define-key gnus-summary-generic-mark-map keystroke map)
11405 (dolist (lway `((next "next" next nil "n")
11406 (next-unread "next unread" next t "N")
11407 (prev "previous" prev nil "p")
11408 (prev-unread "previous unread" prev t "P")
11409 (nomove "" nil nil ,keystroke)))
11410 (let ((func (gnus-summary-make-marking-command-1
11411 mark (car lway) lway name)))
11412 (setq func (eval func))
11413 (define-key map (nth 4 lway) func)))))
11415 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11417 (format "gnus-summary-put-mark-as-%s%s"
11418 name (if (eq way 'nomove)
11420 (concat "-" (symbol-name way)))))
11423 "Mark the current article as %s%s.
11424 If N, the prefix, then repeat N times.
11425 If N is negative, move in reverse order.
11426 The difference between N and the actual number of articles marked is
11428 name (car (cdr lway)))
11430 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11432 (defun gnus-summary-generic-mark (n mark move unread)
11433 "Mark N articles with MARK."
11434 (unless (eq major-mode 'gnus-summary-mode)
11435 (error "This command can only be used in the summary buffer"))
11436 (gnus-summary-show-thread)
11439 ((eq move 'next) 1)
11440 ((eq move 'prev) -1)
11442 (if (zerop nummove)
11446 nummove (* -1 nummove))))
11447 (while (and (> n 0)
11448 (gnus-summary-mark-article nil mark)
11449 (zerop (gnus-summary-next-subject nummove unread t)))
11452 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11453 (gnus-summary-recenter)
11454 (gnus-summary-position-point)
11455 (gnus-set-mode-line 'summary)
11458 (defun gnus-summary-insert-articles (articles)
11459 (when (setq articles
11460 (gnus-sorted-difference articles
11461 (mapcar (lambda (h)
11462 (mail-header-number h))
11463 gnus-newsgroup-headers)))
11464 (setq gnus-newsgroup-headers
11466 gnus-newsgroup-headers
11467 (gnus-fetch-headers articles)
11468 'gnus-article-sort-by-number))
11469 ;; Suppress duplicates?
11470 (when gnus-suppress-duplicates
11471 (gnus-dup-suppress-articles))
11473 ;; We might want to build some more threads first.
11474 (when (and gnus-fetch-old-headers
11475 (eq gnus-headers-retrieved-by 'nov))
11476 (if (eq gnus-fetch-old-headers 'invisible)
11477 (gnus-build-all-threads)
11478 (gnus-build-old-threads)))
11479 ;; Let the Gnus agent mark articles as read.
11481 (gnus-agent-get-undownloaded-list))
11482 ;; Remove list identifiers from subject
11483 (when gnus-list-identifiers
11484 (gnus-summary-remove-list-identifiers))
11485 ;; First and last article in this newsgroup.
11486 (when gnus-newsgroup-headers
11487 (setq gnus-newsgroup-begin
11488 (mail-header-number (car gnus-newsgroup-headers))
11490 (mail-header-number
11491 (gnus-last-element gnus-newsgroup-headers))))
11492 (when gnus-use-scoring
11493 (gnus-possibly-score-headers))))
11495 (defun gnus-summary-insert-old-articles (&optional all)
11496 "Insert all old articles in this group.
11497 If ALL is non-nil, already read articles become readable.
11498 If ALL is a number, fetch this number of articles."
11501 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11504 ;;; Some nntp servers lie about their active range. When this happens, the active range can be in the millions.
11505 ;;; (gnus-sorted-difference
11506 ;;; (gnus-uncompress-range (list gnus-newsgroup-active))
11508 (gnus-range-difference (list gnus-newsgroup-active) old))
11509 (setq len (gnus-range-length older))
11514 (let ((older-range (nreverse older)))
11518 (let* ((r (pop older-range))
11519 (min (if (numberp r) r (car r)))
11520 (max (if (numberp r) r (cdr r))))
11521 (while (and (<= min max)
11526 (setq older (gnus-uncompress-range older))))
11529 (if (and (numberp gnus-large-newsgroup)
11530 (> len gnus-large-newsgroup))
11531 (let* ((cursor-in-echo-area nil)
11532 (initial (gnus-parameter-large-newsgroup-initial
11533 gnus-newsgroup-name))
11537 "How many articles from %s (%s %d): "
11539 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11540 (if initial "max" "default")
11543 (cons (number-to-string initial)
11545 (unless (string-match "^[ \t]*$" input)
11546 (setq all (string-to-number input))
11548 (let ((older-range (nreverse older)))
11552 (let* ((r (pop older-range))
11553 (min (if (numberp r) r (car r)))
11554 (max (if (numberp r) r (cdr r))))
11555 (while (and (<= min max)
11560 (setq older (gnus-uncompress-range older))))))))
11562 (message "No old news.")
11563 (gnus-summary-insert-articles older)
11564 (gnus-summary-limit (gnus-sorted-nunion old older))))
11565 (gnus-summary-position-point)))
11567 (defun gnus-summary-insert-new-articles ()
11568 "Insert all new articles in this group."
11571 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11572 (old-active gnus-newsgroup-active)
11573 (nnmail-fetched-sources (list t))
11575 (setq gnus-newsgroup-active
11576 (gnus-activate-group gnus-newsgroup-name 'scan))
11577 (setq i (cdr gnus-newsgroup-active))
11578 (while (> i (cdr old-active))
11582 (message "No gnus is bad news.")
11583 (gnus-summary-insert-articles new)
11584 (setq gnus-newsgroup-unreads
11585 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11586 (gnus-summary-limit (gnus-sorted-nunion old new))))
11587 (gnus-summary-position-point)))
11589 (gnus-summary-make-all-marking-commands)
11591 (gnus-ems-redefine)
11593 (provide 'gnus-sum)
11595 (run-hooks 'gnus-sum-load-hook)
11597 ;;; gnus-sum.el ends here