1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
124 "*A regexp to match subjects to be excluded from loose thread gathering.
125 As loose thread gathering is done on subjects only, that means that
126 there can be many false gatherings performed. By rooting out certain
127 common subjects, gathering might become saner."
131 (defcustom gnus-summary-gather-subject-limit nil
132 "*Maximum length of subject comparisons when gathering loose threads.
133 Use nil to compare full subjects. Setting this variable to a low
134 number will help gather threads that have been corrupted by
135 newsreaders chopping off subject lines, but it might also mean that
136 unrelated articles that have subject that happen to begin with the
137 same few characters will be incorrectly gathered.
139 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
142 :type '(choice (const :tag "off" nil)
144 (sexp :menu-tag "on" t)))
146 (defcustom gnus-simplify-subject-functions nil
147 "List of functions taking a string argument that simplify subjects.
148 The functions are applied recursively.
150 Useful functions to put in this list include:
151 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
152 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
154 :type '(repeat function))
156 (defcustom gnus-simplify-ignored-prefixes nil
157 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
159 :type '(choice (const :tag "off" nil)
162 (defcustom gnus-build-sparse-threads nil
163 "*If non-nil, fill in the gaps in threads.
164 If `some', only fill in the gaps that are needed to tie loose threads
165 together. If `more', fill in all leaf nodes that Gnus can find. If
166 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
168 :type '(choice (const :tag "off" nil)
171 (sexp :menu-tag "all" t)))
173 (defcustom gnus-summary-thread-gathering-function
174 'gnus-gather-threads-by-subject
175 "*Function used for gathering loose threads.
176 There are two pre-defined functions: `gnus-gather-threads-by-subject',
177 which only takes Subjects into consideration; and
178 `gnus-gather-threads-by-references', which compared the References
179 headers of the articles to find matches."
181 :type '(radio (function-item gnus-gather-threads-by-subject)
182 (function-item gnus-gather-threads-by-references)
183 (function :tag "other")))
185 (defcustom gnus-summary-same-subject ""
186 "*String indicating that the current article has the same subject as the previous.
187 This variable will only be used if the value of
188 `gnus-summary-make-false-root' is `empty'."
189 :group 'gnus-summary-format
192 (defcustom gnus-summary-goto-unread t
193 "*If t, many commands will go to the next unread article.
194 This applies to marking commands as well as other commands that
195 \"naturally\" select the next article, like, for instance, `SPC' at
196 the end of an article.
198 If nil, the marking commands do NOT go to the next unread article
199 (they go to the next article instead). If `never', commands that
200 usually go to the next unread article, will go to the next article,
201 whether it is read or not."
202 :group 'gnus-summary-marks
203 :link '(custom-manual "(gnus)Setting Marks")
204 :type '(choice (const :tag "off" nil)
206 (sexp :menu-tag "on" t)))
208 (defcustom gnus-summary-default-score 0
209 "*Default article score level.
210 All scores generated by the score files will be added to this score.
211 If this variable is nil, scoring will be disabled."
212 :group 'gnus-score-default
213 :type '(choice (const :tag "disable")
216 (defcustom gnus-summary-default-high-score 0
217 "*Default threshold for a high scored article.
218 An article will be highlighted as high scored if its score is greater
220 :group 'gnus-score-default
223 (defcustom gnus-summary-default-low-score 0
224 "*Default threshold for a low scored article.
225 An article will be highlighted as low scored if its score is smaller
227 :group 'gnus-score-default
230 (defcustom gnus-summary-zcore-fuzz 0
231 "*Fuzziness factor for the zcore in the summary buffer.
232 Articles with scores closer than this to `gnus-summary-default-score'
234 :group 'gnus-summary-format
237 (defcustom gnus-simplify-subject-fuzzy-regexp nil
238 "*Strings to be removed when doing fuzzy matches.
239 This can either be a regular expression or list of regular expressions
240 that will be removed from subject strings if fuzzy subject
241 simplification is selected."
243 :type '(repeat regexp))
245 (defcustom gnus-show-threads t
246 "*If non-nil, display threads in summary mode."
250 (defcustom gnus-thread-hide-subtree nil
251 "*If non-nil, hide all threads initially.
252 This can be a predicate specifier which says which threads to hide.
253 If threads are hidden, you have to run the command
254 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
255 to expose hidden threads."
259 (defcustom gnus-thread-hide-killed t
260 "*If non-nil, hide killed threads automatically."
264 (defcustom gnus-thread-ignore-subject t
265 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
266 If nil, articles that have different subjects from their parents will
267 start separate threads."
271 (defcustom gnus-thread-operation-ignore-subject t
272 "*If non-nil, subjects will be ignored when doing thread commands.
273 This affects commands like `gnus-summary-kill-thread' and
274 `gnus-summary-lower-thread'.
276 If this variable is nil, articles in the same thread with different
277 subjects will not be included in the operation in question. If this
278 variable is `fuzzy', only articles that have subjects that are fuzzily
279 equal will be included."
281 :type '(choice (const :tag "off" nil)
285 (defcustom gnus-thread-indent-level 4
286 "*Number that says how much each sub-thread should be indented."
290 (defcustom gnus-auto-extend-newsgroup t
291 "*If non-nil, extend newsgroup forward and backward when requested."
292 :group 'gnus-summary-choose
295 (defcustom gnus-auto-select-first t
296 "*If non-nil, select the article under point.
297 Which article this is is controlled by the `gnus-auto-select-subject'
300 If you want to prevent automatic selection of articles in some
301 newsgroups, set the variable to nil in `gnus-select-group-hook'."
302 :group 'gnus-group-select
303 :type '(choice (const :tag "none" nil)
304 (sexp :menu-tag "first" t)))
306 (defcustom gnus-auto-select-subject 'unread
307 "*Says what subject to place under point when entering a group.
309 This variable can either be the symbols `first' (place point on the
310 first subject), `unread' (place point on the subject line of the first
311 unread article), `best' (place point on the subject line of the
312 higest-scored article), `unseen' (place point on the subject line of
313 the first unseen article), 'unseen-or-unread' (place point on the subject
314 line of the first unseen article or, if all article have been seen, on the
315 subject line of the first unread article), or a function to be called to
316 place point on some subject line."
317 :group 'gnus-group-select
318 :type '(choice (const best)
322 (const unseen-or-unread)))
324 (defcustom gnus-dont-select-after-jump-to-other-group nil
325 "If non-nil, don't select the first unread article after entering the
326 other group by the command `gnus-summary-jump-to-other-group'. If nil,
327 it is depend on the value of `gnus-auto-select-first' whether to select
329 :group 'gnus-group-select
332 (defcustom gnus-auto-select-next t
333 "*If non-nil, offer to go to the next group from the end of the previous.
334 If the value is t and the next newsgroup is empty, Gnus will exit
335 summary mode and go back to group mode. If the value is neither nil
336 nor t, Gnus will select the following unread newsgroup. In
337 particular, if the value is the symbol `quietly', the next unread
338 newsgroup will be selected without any confirmation, and if it is
339 `almost-quietly', the next group will be selected without any
340 confirmation if you are located on the last article in the group.
341 Finally, if this variable is `slightly-quietly', the `Z n' command
342 will go to the next group without confirmation."
343 :group 'gnus-summary-maneuvering
344 :type '(choice (const :tag "off" nil)
346 (const almost-quietly)
347 (const slightly-quietly)
348 (sexp :menu-tag "on" t)))
350 (defcustom gnus-auto-select-same nil
351 "*If non-nil, select the next article with the same subject.
352 If there are no more articles with the same subject, go to
353 the first unread article."
354 :group 'gnus-summary-maneuvering
357 (defcustom gnus-summary-check-current nil
358 "*If non-nil, consider the current article when moving.
359 The \"unread\" movement commands will stay on the same line if the
360 current article is unread."
361 :group 'gnus-summary-maneuvering
364 (defcustom gnus-auto-center-summary t
365 "*If non-nil, always center the current summary buffer.
366 In particular, if `vertical' do only vertical recentering. If non-nil
367 and non-`vertical', do both horizontal and vertical recentering."
368 :group 'gnus-summary-maneuvering
369 :type '(choice (const :tag "none" nil)
371 (integer :tag "height")
372 (sexp :menu-tag "both" t)))
374 (defcustom gnus-show-all-headers nil
375 "*If non-nil, don't hide any headers."
376 :group 'gnus-article-hiding
377 :group 'gnus-article-headers
380 (defcustom gnus-summary-ignore-duplicates nil
381 "*If non-nil, ignore articles with identical Message-ID headers."
385 (defcustom gnus-single-article-buffer t
386 "*If non-nil, display all articles in the same buffer.
387 If nil, each group will get its own article buffer."
388 :group 'gnus-article-various
391 (defcustom gnus-break-pages t
392 "*If non-nil, do page breaking on articles.
393 The page delimiter is specified by the `gnus-page-delimiter'
395 :group 'gnus-article-various
398 (defcustom gnus-show-mime t
399 "*If non-nil, do mime processing of articles.
400 The articles will simply be fed to the function given by
401 `gnus-article-display-method-for-mime'."
402 :group 'gnus-article-mime
405 (defcustom gnus-move-split-methods nil
406 "*Variable used to suggest where articles are to be moved to.
407 It uses the same syntax as the `gnus-split-methods' variable.
408 However, whereas `gnus-split-methods' specifies file names as targets,
409 this variable specifies group names."
410 :group 'gnus-summary-mail
411 :type '(repeat (choice (list :value (fun) function)
412 (cons :value ("" "") regexp (repeat string))
415 (defcustom gnus-unread-mark ?\ ;;;Whitespace
416 "*Mark used for unread articles."
417 :group 'gnus-summary-marks
420 (defcustom gnus-ticked-mark ?!
421 "*Mark used for ticked articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-dormant-mark ??
426 "*Mark used for dormant articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-del-mark ?r
431 "*Mark used for del'd articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-read-mark ?R
436 "*Mark used for read articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-expirable-mark ?E
441 "*Mark used for expirable articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-killed-mark ?K
446 "*Mark used for killed articles."
447 :group 'gnus-summary-marks
450 (defcustom gnus-spam-mark ?H
451 "*Mark used for spam articles."
452 :group 'gnus-summary-marks
455 (defcustom gnus-souped-mark ?F
456 "*Mark used for souped articles."
457 :group 'gnus-summary-marks
460 (defcustom gnus-kill-file-mark ?X
461 "*Mark used for articles killed by kill files."
462 :group 'gnus-summary-marks
465 (defcustom gnus-low-score-mark ?Y
466 "*Mark used for articles with a low score."
467 :group 'gnus-summary-marks
470 (defcustom gnus-catchup-mark ?C
471 "*Mark used for articles that are caught up."
472 :group 'gnus-summary-marks
475 (defcustom gnus-replied-mark ?A
476 "*Mark used for articles that have been replied to."
477 :group 'gnus-summary-marks
480 (defcustom gnus-forwarded-mark ?F
481 "*Mark used for articles that have been forwarded."
482 :group 'gnus-summary-marks
485 (defcustom gnus-recent-mark ?N
486 "*Mark used for articles that are recent."
487 :group 'gnus-summary-marks
490 (defcustom gnus-cached-mark ?*
491 "*Mark used for articles that are in the cache."
492 :group 'gnus-summary-marks
495 (defcustom gnus-saved-mark ?S
496 "*Mark used for articles that have been saved."
497 :group 'gnus-summary-marks
500 (defcustom gnus-unseen-mark ?.
501 "*Mark used for articles that haven't been seen."
502 :group 'gnus-summary-marks
505 (defcustom gnus-no-mark ?\ ;;;Whitespace
506 "*Mark used for articles that have no other secondary mark."
507 :group 'gnus-summary-marks
510 (defcustom gnus-ancient-mark ?O
511 "*Mark used for ancient articles."
512 :group 'gnus-summary-marks
515 (defcustom gnus-sparse-mark ?Q
516 "*Mark used for sparsely reffed articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-canceled-mark ?G
521 "*Mark used for canceled articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-duplicate-mark ?M
526 "*Mark used for duplicate articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-undownloaded-mark ?@
531 "*Mark used for articles that weren't downloaded."
532 :group 'gnus-summary-marks
535 (defcustom gnus-downloadable-mark ?%
536 "*Mark used for articles that are to be downloaded."
537 :group 'gnus-summary-marks
540 (defcustom gnus-unsendable-mark ?=
541 "*Mark used for articles that won't be sent."
542 :group 'gnus-summary-marks
545 (defcustom gnus-score-over-mark ?+
546 "*Score mark used for articles with high scores."
547 :group 'gnus-summary-marks
550 (defcustom gnus-score-below-mark ?-
551 "*Score mark used for articles with low scores."
552 :group 'gnus-summary-marks
555 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
556 "*There is no thread under the article."
557 :group 'gnus-summary-marks
560 (defcustom gnus-not-empty-thread-mark ?=
561 "*There is a thread under the article."
562 :group 'gnus-summary-marks
565 (defcustom gnus-view-pseudo-asynchronously nil
566 "*If non-nil, Gnus will view pseudo-articles asynchronously."
567 :group 'gnus-extract-view
570 (defcustom gnus-auto-expirable-marks
571 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
572 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
573 gnus-souped-mark gnus-duplicate-mark)
574 "*The list of marks converted into expiration if a group is auto-expirable."
577 :type '(repeat character))
579 (defcustom gnus-inhibit-user-auto-expire t
580 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
585 (defcustom gnus-view-pseudos nil
586 "*If `automatic', pseudo-articles will be viewed automatically.
587 If `not-confirm', pseudos will be viewed automatically, and the user
588 will not be asked to confirm the command."
589 :group 'gnus-extract-view
590 :type '(choice (const :tag "off" nil)
592 (const not-confirm)))
594 (defcustom gnus-view-pseudos-separately t
595 "*If non-nil, one pseudo-article will be created for each file to be viewed.
596 If nil, all files that use the same viewing command will be given as a
597 list of parameters to that command."
598 :group 'gnus-extract-view
601 (defcustom gnus-insert-pseudo-articles t
602 "*If non-nil, insert pseudo-articles when decoding articles."
603 :group 'gnus-extract-view
606 (defcustom gnus-summary-dummy-line-format
608 "*The format specification for the dummy roots in the summary buffer.
609 It works along the same lines as a normal formatting string,
610 with some simple extensions.
614 General format specifiers can also be used.
615 See `(gnus)Formatting Variables'."
616 :link '(custom-manual "(gnus)Formatting Variables")
617 :group 'gnus-threading
620 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
621 "*The format specification for the summary mode line.
622 It works along the same lines as a normal formatting string,
623 with some simple extensions:
626 %p Unprefixed group name
627 %A Current article number
628 %z Current article score
630 %U Number of unread articles in the group
631 %e Number of unselected articles in the group
632 %Z A string with unread/unselected article counts
633 %g Shortish group name
634 %S Subject of the current article
636 %s Current score file name
637 %d Number of dormant articles
638 %r Number of articles that have been marked as read in this session
639 %E Number of articles expunged by the score files"
640 :group 'gnus-summary-format
643 (defcustom gnus-list-identifiers nil
644 "Regexp that matches list identifiers to be removed from subject.
645 This can also be a list of regexps."
647 :group 'gnus-summary-format
648 :group 'gnus-article-hiding
649 :type '(choice (const :tag "none" nil)
651 (repeat :value (".*") regexp)))
653 (defcustom gnus-summary-mark-below 0
654 "*Mark all articles with a score below this variable as read.
655 This variable is local to each summary buffer and usually set by the
657 :group 'gnus-score-default
660 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
661 "*List of functions used for sorting articles in the summary buffer.
663 Each function takes two articles and returns non-nil if the first
664 article should be sorted before the other. If you use more than one
665 function, the primary sort function should be the last. You should
666 probably always include `gnus-article-sort-by-number' in the list of
667 sorting functions -- preferably first. Also note that sorting by date
668 is often much slower than sorting by number, and the sorting order is
669 very similar. (Sorting by date means sorting by the time the message
670 was sent, sorting by number means sorting by arrival time.)
672 Ready-made functions include `gnus-article-sort-by-number',
673 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
674 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
675 and `gnus-article-sort-by-score'.
677 When threading is turned on, the variable `gnus-thread-sort-functions'
678 controls how articles are sorted."
679 :group 'gnus-summary-sort
680 :type '(repeat (choice (function-item gnus-article-sort-by-number)
681 (function-item gnus-article-sort-by-author)
682 (function-item gnus-article-sort-by-subject)
683 (function-item gnus-article-sort-by-date)
684 (function-item gnus-article-sort-by-score)
685 (function-item gnus-article-sort-by-random)
686 (function :tag "other"))))
688 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
689 "*List of functions used for sorting threads in the summary buffer.
690 By default, threads are sorted by article number.
692 Each function takes two threads and returns non-nil if the first
693 thread should be sorted before the other. If you use more than one
694 function, the primary sort function should be the last. You should
695 probably always include `gnus-thread-sort-by-number' in the list of
696 sorting functions -- preferably first. Also note that sorting by date
697 is often much slower than sorting by number, and the sorting order is
698 very similar. (Sorting by date means sorting by the time the message
699 was sent, sorting by number means sorting by arrival time.)
701 Ready-made functions include `gnus-thread-sort-by-number',
702 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
703 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
704 `gnus-thread-sort-by-most-recent-number',
705 `gnus-thread-sort-by-most-recent-date',
706 `gnus-thread-sort-by-random', and
707 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
709 When threading is turned off, the variable
710 `gnus-article-sort-functions' controls how articles are sorted."
711 :group 'gnus-summary-sort
712 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
713 (function-item gnus-thread-sort-by-author)
714 (function-item gnus-thread-sort-by-subject)
715 (function-item gnus-thread-sort-by-date)
716 (function-item gnus-thread-sort-by-score)
717 (function-item gnus-thread-sort-by-total-score)
718 (function-item gnus-thread-sort-by-random)
719 (function :tag "other"))))
721 (defcustom gnus-thread-score-function '+
722 "*Function used for calculating the total score of a thread.
724 The function is called with the scores of the article and each
725 subthread and should then return the score of the thread.
727 Some functions you can use are `+', `max', or `min'."
728 :group 'gnus-summary-sort
731 (defcustom gnus-summary-expunge-below nil
732 "All articles that have a score less than this variable will be expunged.
733 This variable is local to the summary buffers."
734 :group 'gnus-score-default
735 :type '(choice (const :tag "off" nil)
738 (defcustom gnus-thread-expunge-below nil
739 "All threads that have a total score less than this variable will be expunged.
740 See `gnus-thread-score-function' for en explanation of what a
743 This variable is local to the summary buffers."
744 :group 'gnus-threading
745 :group 'gnus-score-default
746 :type '(choice (const :tag "off" nil)
749 (defcustom gnus-summary-mode-hook nil
750 "*A hook for Gnus summary mode.
751 This hook is run before any variables are set in the summary buffer."
752 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
753 :group 'gnus-summary-various
756 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
757 (when (featurep 'xemacs)
758 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
759 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
760 (add-hook 'gnus-summary-mode-hook
761 'gnus-xmas-switch-horizontal-scrollbar-off))
763 (defcustom gnus-summary-menu-hook nil
764 "*Hook run after the creation of the summary mode menu."
765 :group 'gnus-summary-visual
768 (defcustom gnus-summary-exit-hook nil
769 "*A hook called on exit from the summary buffer.
770 It will be called with point in the group buffer."
771 :group 'gnus-summary-exit
774 (defcustom gnus-summary-prepare-hook nil
775 "*A hook called after the summary buffer has been generated.
776 If you want to modify the summary buffer, you can use this hook."
777 :group 'gnus-summary-various
780 (defcustom gnus-summary-prepared-hook nil
781 "*A hook called as the last thing after the summary buffer has been generated."
782 :group 'gnus-summary-various
785 (defcustom gnus-summary-generate-hook nil
786 "*A hook run just before generating the summary buffer.
787 This hook is commonly used to customize threading variables and the
789 :group 'gnus-summary-various
792 (defcustom gnus-select-group-hook nil
793 "*A hook called when a newsgroup is selected.
795 If you'd like to simplify subjects like the
796 `gnus-summary-next-same-subject' command does, you can use the
799 (add-hook gnus-select-group-hook
801 (mapcar (lambda (header)
802 (mail-header-set-subject
804 (gnus-simplify-subject
805 (mail-header-subject header) 're-only)))
806 gnus-newsgroup-headers)))"
807 :group 'gnus-group-select
810 (defcustom gnus-select-article-hook nil
811 "*A hook called when an article is selected."
812 :group 'gnus-summary-choose
815 (defcustom gnus-visual-mark-article-hook
816 (list 'gnus-highlight-selected-summary)
817 "*Hook run after selecting an article in the summary buffer.
818 It is meant to be used for highlighting the article in some way. It
819 is not run if `gnus-visual' is nil."
820 :group 'gnus-summary-visual
823 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
824 "*A hook called before parsing the headers."
828 (defcustom gnus-exit-group-hook nil
829 "*A hook called when exiting summary mode.
830 This hook is not called from the non-updating exit commands like `Q'."
834 (defcustom gnus-summary-update-hook
835 (list 'gnus-summary-highlight-line)
836 "*A hook called when a summary line is changed.
837 The hook will not be called if `gnus-visual' is nil.
839 The default function `gnus-summary-highlight-line' will
840 highlight the line according to the `gnus-summary-highlight'
842 :group 'gnus-summary-visual
845 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
846 "*A hook called when an article is selected for the first time.
847 The hook is intended to mark an article as read (or unread)
848 automatically when it is selected."
849 :group 'gnus-summary-choose
852 (defcustom gnus-group-no-more-groups-hook nil
853 "*A hook run when returning to group mode having no more (unread) groups."
854 :group 'gnus-group-select
857 (defcustom gnus-ps-print-hook nil
858 "*A hook run before ps-printing something from Gnus."
862 (defcustom gnus-summary-display-arrow
863 (and (fboundp 'display-graphic-p)
865 "*If non-nil, display an arrow highlighting the current article."
870 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
871 "Face used for highlighting the current article in the summary buffer."
872 :group 'gnus-summary-visual
875 (defcustom gnus-summary-highlight
876 '(((eq mark gnus-canceled-mark)
877 . gnus-summary-cancelled-face)
878 ((and (> score default-high)
879 (or (eq mark gnus-dormant-mark)
880 (eq mark gnus-ticked-mark)))
881 . gnus-summary-high-ticked-face)
882 ((and (< score default-low)
883 (or (eq mark gnus-dormant-mark)
884 (eq mark gnus-ticked-mark)))
885 . gnus-summary-low-ticked-face)
886 ((or (eq mark gnus-dormant-mark)
887 (eq mark gnus-ticked-mark))
888 . gnus-summary-normal-ticked-face)
889 ((and (> score default-high) (eq mark gnus-ancient-mark))
890 . gnus-summary-high-ancient-face)
891 ((and (< score default-low) (eq mark gnus-ancient-mark))
892 . gnus-summary-low-ancient-face)
893 ((eq mark gnus-ancient-mark)
894 . gnus-summary-normal-ancient-face)
895 ((and (> score default-high) (eq mark gnus-unread-mark))
896 . gnus-summary-high-unread-face)
897 ((and (< score default-low) (eq mark gnus-unread-mark))
898 . gnus-summary-low-unread-face)
899 ((eq mark gnus-unread-mark)
900 . gnus-summary-normal-unread-face)
901 ((and (> score default-high) (memq mark (list gnus-downloadable-mark
902 gnus-undownloaded-mark)))
903 . gnus-summary-high-unread-face)
904 ((and (< score default-low) (memq mark (list gnus-downloadable-mark
905 gnus-undownloaded-mark)))
906 . gnus-summary-low-unread-face)
907 ((and (memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
908 (memq article gnus-newsgroup-unreads))
909 . gnus-summary-normal-unread-face)
910 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
911 . gnus-summary-normal-read-face)
912 ((> score default-high)
913 . gnus-summary-high-read-face)
914 ((< score default-low)
915 . gnus-summary-low-read-face)
917 . gnus-summary-normal-read-face))
918 "*Controls the highlighting of summary buffer lines.
920 A list of (FORM . FACE) pairs. When deciding how a a particular
921 summary line should be displayed, each form is evaluated. The content
922 of the face field after the first true form is used. You can change
923 how those summary lines are displayed, by editing the face field.
925 You can use the following variables in the FORM field.
927 score: The article's score
928 default: The default article score.
929 default-high: The default score for high scored articles.
930 default-low: The default score for low scored articles.
931 below: The score below which articles are automatically marked as read.
932 mark: The articles mark."
933 :group 'gnus-summary-visual
934 :type '(repeat (cons (sexp :tag "Form" nil)
937 (defcustom gnus-alter-header-function nil
938 "Function called to allow alteration of article header structures.
939 The function is called with one parameter, the article header vector,
940 which it may alter in any way.")
942 (defvar gnus-decode-encoded-word-function
943 (mime-find-field-decoder 'From 'nov)
944 "Variable that says which function should be used to decode a string with encoded words.")
946 (defcustom gnus-extra-headers '(To Newsgroups)
947 "*Extra headers to parse."
950 :type '(repeat symbol))
952 (defcustom gnus-ignored-from-addresses
953 (and user-mail-address (regexp-quote user-mail-address))
954 "*Regexp of From headers that may be suppressed in favor of To headers."
959 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
960 "List of charsets that should be ignored.
961 When these charsets are used in the \"charset\" parameter, the
962 default charset will be used instead."
964 :type '(repeat symbol)
965 :group 'gnus-charset)
967 (gnus-define-group-parameter
971 "Return the ignored charsets of GROUP."
972 :variable gnus-group-ignored-charsets-alist
974 '(("alt\\.chinese\\.text" iso-8859-1))
976 "Alist of regexps (to match group names) and charsets that should be ignored.
977 When these charsets are used in the \"charset\" parameter, the
978 default charset will be used instead."
979 :variable-group gnus-charset
980 :variable-type '(repeat (cons (regexp :tag "Group")
982 :parameter-type '(choice :tag "Ignored charsets"
985 :parameter-document "\
986 List of charsets that should be ignored.
988 When these charsets are used in the \"charset\" parameter, the
989 default charset will be used instead.")
991 (defcustom gnus-group-highlight-words-alist nil
992 "Alist of group regexps and highlight regexps.
993 This variable uses the same syntax as `gnus-emphasis-alist'."
995 :type '(repeat (cons (regexp :tag "Group")
996 (repeat (list (regexp :tag "Highlight regexp")
997 (number :tag "Group for entire word" 0)
998 (number :tag "Group for displayed part" 0)
1000 gnus-emphasis-highlight-words)))))
1001 :group 'gnus-summary-visual)
1003 (defcustom gnus-use-wheel nil
1004 "Use Intelli-mouse on summary movement"
1006 :group 'gnus-summary-maneuvering)
1008 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1009 "Amount to scroll messages by spinning the mouse wheel.
1010 This is actually a cons cell, where the first item is the amount to scroll
1011 on a normal wheel event, and the second is the amount to scroll when the
1012 wheel is moved with the shift key depressed."
1013 :type '(cons (integer :tag "Shift") integer)
1014 :group 'gnus-summary-maneuvering)
1016 (defcustom gnus-wheel-edge-resistance 2
1017 "How hard it should be to change the current article
1018 by moving the mouse over the edge of the article window."
1020 :group 'gnus-summary-maneuvering)
1022 (defcustom gnus-summary-show-article-charset-alist
1024 "Alist of number and charset.
1025 The article will be shown with the charset corresponding to the
1027 For example: ((1 . cn-gb-2312) (2 . big5))."
1029 :type '(repeat (cons (number :tag "Argument" 1)
1030 (symbol :tag "Charset")))
1031 :group 'gnus-charset)
1033 (defcustom gnus-preserve-marks t
1034 "Whether marks are preserved when moving, copying and respooling messages."
1037 :group 'gnus-summary-marks)
1039 (defcustom gnus-alter-articles-to-read-function nil
1040 "Function to be called to alter the list of articles to be selected."
1041 :type '(choice (const nil) function)
1042 :group 'gnus-summary)
1044 (defcustom gnus-orphan-score nil
1045 "*All orphans get this score added. Set in the score file."
1046 :group 'gnus-score-default
1047 :type '(choice (const nil)
1050 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1051 "*A regexp to match MIME parts when saving multiple parts of a message
1052 with gnus-summary-save-parts (X m). This regexp will be used by default
1053 when prompting the user for which type of files to save."
1054 :group 'gnus-summary
1057 (defcustom gnus-read-all-available-headers nil
1058 "Whether Gnus should parse all headers made available to it.
1059 This is mostly relevant for slow backends where the user may
1060 wish to widen the summary buffer to include all headers
1061 that were fetched. Say, for nnultimate groups."
1062 :group 'gnus-summary
1063 :type '(choice boolean regexp))
1065 (defcustom gnus-summary-muttprint-program "muttprint"
1066 "Command (and optional arguments) used to run Muttprint."
1068 :group 'gnus-summary
1071 (defcustom gnus-article-loose-mime nil
1072 "If non-nil, don't require MIME-Version header.
1073 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1074 supply the MIME-Version header or deliberately strip it From the mail.
1075 Set it to non-nil, Gnus will treat some articles as MIME even if
1076 the MIME-Version header is missed."
1079 :group 'gnus-article)
1081 ;;; Internal variables
1083 (defvar gnus-summary-display-cache nil)
1084 (defvar gnus-article-mime-handles nil)
1085 (defvar gnus-article-decoded-p nil)
1086 (defvar gnus-article-charset nil)
1087 (defvar gnus-article-ignored-charsets nil)
1088 (defvar gnus-scores-exclude-files nil)
1089 (defvar gnus-page-broken nil)
1090 (defvar gnus-inhibit-mime-unbuttonizing nil)
1092 (defvar gnus-original-article nil)
1093 (defvar gnus-article-internal-prepare-hook nil)
1094 (defvar gnus-newsgroup-process-stack nil)
1096 (defvar gnus-thread-indent-array nil)
1097 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1098 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1099 "Function called to sort the articles within a thread after it has been gathered together.")
1101 (defvar gnus-summary-save-parts-type-history nil)
1102 (defvar gnus-summary-save-parts-last-directory nil)
1104 ;; Avoid highlighting in kill files.
1105 (defvar gnus-summary-inhibit-highlight nil)
1106 (defvar gnus-newsgroup-selected-overlay nil)
1107 (defvar gnus-inhibit-limiting nil)
1108 (defvar gnus-newsgroup-adaptive-score-file nil)
1109 (defvar gnus-current-score-file nil)
1110 (defvar gnus-current-move-group nil)
1111 (defvar gnus-current-copy-group nil)
1112 (defvar gnus-current-crosspost-group nil)
1113 (defvar gnus-newsgroup-display nil)
1115 (defvar gnus-newsgroup-dependencies nil)
1116 (defvar gnus-newsgroup-adaptive nil)
1117 (defvar gnus-summary-display-article-function nil)
1118 (defvar gnus-summary-highlight-line-function nil
1119 "Function called after highlighting a summary line.")
1121 (defvar gnus-summary-line-format-alist
1122 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1123 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1124 (?s gnus-tmp-subject-or-nil ?s)
1125 (?n gnus-tmp-name ?s)
1126 (?A (std11-address-string
1127 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1128 (?a (or (std11-full-name-string
1129 (car (mime-entity-read-field gnus-tmp-header 'From)))
1131 (?F gnus-tmp-from ?s)
1132 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1133 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1134 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1135 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1136 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1137 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1138 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1139 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1140 (?L gnus-tmp-lines ?s)
1141 (?I gnus-tmp-indentation ?s)
1142 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1143 (?R gnus-tmp-replied ?c)
1144 (?\[ gnus-tmp-opening-bracket ?c)
1145 (?\] gnus-tmp-closing-bracket ?c)
1146 (?\> (make-string gnus-tmp-level ? ) ?s)
1147 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1148 (?i gnus-tmp-score ?d)
1149 (?z gnus-tmp-score-char ?c)
1150 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1151 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1152 (?U gnus-tmp-unread ?c)
1153 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1155 (?t (gnus-summary-number-of-articles-in-thread
1156 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1158 (?e (gnus-summary-number-of-articles-in-thread
1159 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1161 (?u gnus-tmp-user-defined ?s)
1162 (?P (gnus-pick-line-number) ?d)
1163 (?B gnus-tmp-thread-tree-header-string ?s)
1164 (user-date (gnus-user-date
1165 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1166 "An alist of format specifications that can appear in summary lines.
1167 These are paired with what variables they correspond with, along with
1168 the type of the variable (string, integer, character, etc).")
1170 (defvar gnus-summary-dummy-line-format-alist
1171 `((?S gnus-tmp-subject ?s)
1172 (?N gnus-tmp-number ?d)
1173 (?u gnus-tmp-user-defined ?s)))
1175 (defvar gnus-summary-mode-line-format-alist
1176 `((?G gnus-tmp-group-name ?s)
1177 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1178 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1179 (?A gnus-tmp-article-number ?d)
1180 (?Z gnus-tmp-unread-and-unselected ?s)
1181 (?V gnus-version ?s)
1182 (?U gnus-tmp-unread-and-unticked ?d)
1183 (?S gnus-tmp-subject ?s)
1184 (?e gnus-tmp-unselected ?d)
1185 (?u gnus-tmp-user-defined ?s)
1186 (?d (length gnus-newsgroup-dormant) ?d)
1187 (?t (length gnus-newsgroup-marked) ?d)
1188 (?h (length gnus-newsgroup-spam-marked) ?d)
1189 (?r (length gnus-newsgroup-reads) ?d)
1190 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1191 (?E gnus-newsgroup-expunged-tally ?d)
1192 (?s (gnus-current-score-file-nondirectory) ?s)))
1194 (defvar gnus-last-search-regexp nil
1195 "Default regexp for article search command.")
1197 (defvar gnus-summary-search-article-matched-data nil
1198 "Last matched data of article search command. It is the local variable
1199 in `gnus-article-buffer' which consists of the list of start position,
1200 end position and text.")
1202 (defvar gnus-last-shell-command nil
1203 "Default shell command on article.")
1205 (defvar gnus-newsgroup-begin nil)
1206 (defvar gnus-newsgroup-end nil)
1207 (defvar gnus-newsgroup-last-rmail nil)
1208 (defvar gnus-newsgroup-last-mail nil)
1209 (defvar gnus-newsgroup-last-folder nil)
1210 (defvar gnus-newsgroup-last-file nil)
1211 (defvar gnus-newsgroup-auto-expire nil)
1212 (defvar gnus-newsgroup-active nil)
1214 (defvar gnus-newsgroup-data nil)
1215 (defvar gnus-newsgroup-data-reverse nil)
1216 (defvar gnus-newsgroup-limit nil)
1217 (defvar gnus-newsgroup-limits nil)
1219 (defvar gnus-newsgroup-unreads nil
1220 "Sorted list of unread articles in the current newsgroup.")
1222 (defvar gnus-newsgroup-unselected nil
1223 "Sorted list of unselected unread articles in the current newsgroup.")
1225 (defvar gnus-newsgroup-reads nil
1226 "Alist of read articles and article marks in the current newsgroup.")
1228 (defvar gnus-newsgroup-expunged-tally nil)
1230 (defvar gnus-newsgroup-marked nil
1231 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1233 (defvar gnus-newsgroup-spam-marked nil
1234 "List of ranges of articles that have been marked as spam.")
1236 (defvar gnus-newsgroup-killed nil
1237 "List of ranges of articles that have been through the scoring process.")
1239 (defvar gnus-newsgroup-cached nil
1240 "Sorted list of articles that come from the article cache.")
1242 (defvar gnus-newsgroup-saved nil
1243 "List of articles that have been saved.")
1245 (defvar gnus-newsgroup-kill-headers nil)
1247 (defvar gnus-newsgroup-replied nil
1248 "List of articles that have been replied to in the current newsgroup.")
1250 (defvar gnus-newsgroup-forwarded nil
1251 "List of articles that have been forwarded in the current newsgroup.")
1253 (defvar gnus-newsgroup-recent nil
1254 "List of articles that have are recent in the current newsgroup.")
1256 (defvar gnus-newsgroup-expirable nil
1257 "Sorted list of articles in the current newsgroup that can be expired.")
1259 (defvar gnus-newsgroup-processable nil
1260 "List of articles in the current newsgroup that can be processed.")
1262 (defvar gnus-newsgroup-downloadable nil
1263 "Sorted list of articles in the current newsgroup that can be processed.")
1265 (defvar gnus-newsgroup-undownloaded nil
1266 "List of articles in the current newsgroup that haven't been downloaded..")
1268 (defvar gnus-newsgroup-unsendable nil
1269 "List of articles in the current newsgroup that won't be sent.")
1271 (defvar gnus-newsgroup-bookmarks nil
1272 "List of articles in the current newsgroup that have bookmarks.")
1274 (defvar gnus-newsgroup-dormant nil
1275 "Sorted list of dormant articles in the current newsgroup.")
1277 (defvar gnus-newsgroup-unseen nil
1278 "List of unseen articles in the current newsgroup.")
1280 (defvar gnus-newsgroup-seen nil
1281 "Range of seen articles in the current newsgroup.")
1283 (defvar gnus-newsgroup-articles nil
1284 "List of articles in the current newsgroup.")
1286 (defvar gnus-newsgroup-scored nil
1287 "List of scored articles in the current newsgroup.")
1289 (defvar gnus-newsgroup-incorporated nil
1290 "List of incorporated articles in the current newsgroup.")
1292 (defvar gnus-newsgroup-headers nil
1293 "List of article headers in the current newsgroup.")
1295 (defvar gnus-newsgroup-threads nil)
1297 (defvar gnus-newsgroup-prepared nil
1298 "Whether the current group has been prepared properly.")
1300 (defvar gnus-newsgroup-ancient nil
1301 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1303 (defvar gnus-newsgroup-sparse nil)
1305 (defvar gnus-current-article nil)
1306 (defvar gnus-article-current nil)
1307 (defvar gnus-current-headers nil)
1308 (defvar gnus-have-all-headers nil)
1309 (defvar gnus-last-article nil)
1310 (defvar gnus-newsgroup-history nil)
1311 (defvar gnus-newsgroup-charset nil)
1312 (defvar gnus-newsgroup-ephemeral-charset nil)
1313 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1315 (defvar gnus-article-before-search nil)
1317 (defconst gnus-summary-local-variables
1318 '(gnus-newsgroup-name
1319 gnus-newsgroup-begin gnus-newsgroup-end
1320 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1321 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1322 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1323 gnus-newsgroup-unselected gnus-newsgroup-marked
1324 gnus-newsgroup-spam-marked
1325 gnus-newsgroup-reads gnus-newsgroup-saved
1326 gnus-newsgroup-replied gnus-newsgroup-forwarded
1327 gnus-newsgroup-recent
1328 gnus-newsgroup-expirable
1329 gnus-newsgroup-processable gnus-newsgroup-killed
1330 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1331 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1332 gnus-newsgroup-seen gnus-newsgroup-articles
1333 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1334 gnus-newsgroup-headers gnus-newsgroup-threads
1335 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1336 gnus-current-article gnus-current-headers gnus-have-all-headers
1337 gnus-last-article gnus-article-internal-prepare-hook
1338 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1339 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1340 gnus-thread-expunge-below
1341 gnus-score-alist gnus-current-score-file
1342 (gnus-summary-expunge-below . global)
1343 (gnus-summary-mark-below . global)
1344 (gnus-orphan-score . global)
1345 gnus-newsgroup-active gnus-scores-exclude-files
1346 gnus-newsgroup-history gnus-newsgroup-ancient
1347 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1348 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1349 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1350 (gnus-newsgroup-expunged-tally . 0)
1351 gnus-cache-removable-articles gnus-newsgroup-cached
1352 gnus-newsgroup-data gnus-newsgroup-data-reverse
1353 gnus-newsgroup-limit gnus-newsgroup-limits
1354 gnus-newsgroup-charset gnus-newsgroup-display
1355 gnus-newsgroup-incorporated)
1356 "Variables that are buffer-local to the summary buffers.")
1358 (defvar gnus-newsgroup-variables nil
1359 "A list of variables that have separate values in different newsgroups.
1360 A list of newsgroup (summary buffer) local variables, or cons of
1361 variables and their default values (when the default values are not
1362 nil), that should be made global while the summary buffer is active.
1363 These variables can be used to set variables in the group parameters
1364 while still allowing them to affect operations done in other
1365 buffers. For example:
1367 \(setq gnus-newsgroup-variables
1368 '(message-use-followup-to
1369 (gnus-visible-headers .
1370 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1373 ;; Byte-compiler warning.
1374 (eval-when-compile (defvar gnus-article-mode-map))
1376 ;; Subject simplification.
1378 (defun gnus-simplify-whitespace (str)
1379 "Remove excessive whitespace from STR."
1382 (while (string-match "[ \t][ \t]+" mystr)
1383 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1385 (substring mystr (match-end 0)))))
1387 (when (string-match "^[ \t]+" mystr)
1388 (setq mystr (substring mystr (match-end 0))))
1390 (when (string-match "[ \t]+$" mystr)
1391 (setq mystr (substring mystr 0 (match-beginning 0))))
1394 (defun gnus-simplify-all-whitespace (str)
1395 "Remove all whitespace from STR."
1397 (while (string-match "[ \t\n]+" mystr)
1398 (setq mystr (replace-match "" nil nil mystr)))
1401 (defsubst gnus-simplify-subject-re (subject)
1402 "Remove \"Re:\" from subject lines."
1403 (if (string-match message-subject-re-regexp subject)
1404 (substring subject (match-end 0))
1407 (defun gnus-simplify-subject (subject &optional re-only)
1408 "Remove `Re:' and words in parentheses.
1409 If RE-ONLY is non-nil, strip leading `Re:'s only."
1410 (let ((case-fold-search t)) ;Ignore case.
1411 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1412 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1413 (setq subject (substring subject (match-end 0))))
1414 ;; Remove uninteresting prefixes.
1415 (when (and (not re-only)
1416 gnus-simplify-ignored-prefixes
1417 (string-match gnus-simplify-ignored-prefixes subject))
1418 (setq subject (substring subject (match-end 0))))
1419 ;; Remove words in parentheses from end.
1421 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1422 (setq subject (substring subject 0 (match-beginning 0)))))
1423 ;; Return subject string.
1426 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1428 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1429 (goto-char (point-min))
1430 (while (re-search-forward regexp nil t)
1431 (replace-match (or newtext ""))))
1433 (defun gnus-simplify-buffer-fuzzy ()
1434 "Simplify string in the buffer fuzzily.
1435 The string in the accessible portion of the current buffer is simplified.
1436 It is assumed to be a single-line subject.
1437 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1438 matter is removed. Additional things can be deleted by setting
1439 `gnus-simplify-subject-fuzzy-regexp'."
1440 (let ((case-fold-search t)
1442 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1444 (while (not (eq modified-tick (buffer-modified-tick)))
1445 (setq modified-tick (buffer-modified-tick))
1447 ((listp gnus-simplify-subject-fuzzy-regexp)
1448 (mapcar 'gnus-simplify-buffer-fuzzy-step
1449 gnus-simplify-subject-fuzzy-regexp))
1450 (gnus-simplify-subject-fuzzy-regexp
1451 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1452 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1453 (gnus-simplify-buffer-fuzzy-step
1454 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1455 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1457 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1458 (gnus-simplify-buffer-fuzzy-step " +" " ")
1459 (gnus-simplify-buffer-fuzzy-step " $")
1460 (gnus-simplify-buffer-fuzzy-step "^ +")))
1462 (defun gnus-simplify-subject-fuzzy (subject)
1463 "Simplify a subject string fuzzily.
1464 See `gnus-simplify-buffer-fuzzy' for details."
1466 (gnus-set-work-buffer)
1467 (let ((case-fold-search t))
1468 ;; Remove uninteresting prefixes.
1469 (when (and gnus-simplify-ignored-prefixes
1470 (string-match gnus-simplify-ignored-prefixes subject))
1471 (setq subject (substring subject (match-end 0))))
1473 (inline (gnus-simplify-buffer-fuzzy))
1476 (defsubst gnus-simplify-subject-fully (subject)
1477 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1479 (gnus-simplify-subject-functions
1480 (gnus-map-function gnus-simplify-subject-functions subject))
1481 ((null gnus-summary-gather-subject-limit)
1482 (gnus-simplify-subject-re subject))
1483 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1484 (gnus-simplify-subject-fuzzy subject))
1485 ((numberp gnus-summary-gather-subject-limit)
1486 (gnus-limit-string (gnus-simplify-subject-re subject)
1487 gnus-summary-gather-subject-limit))
1491 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1492 "Check whether two subjects are equal.
1493 If optional argument simple-first is t, first argument is already
1496 ((null simple-first)
1497 (equal (gnus-simplify-subject-fully s1)
1498 (gnus-simplify-subject-fully s2)))
1501 (gnus-simplify-subject-fully s2)))))
1503 (defun gnus-summary-bubble-group ()
1504 "Increase the score of the current group.
1505 This is a handy function to add to `gnus-summary-exit-hook' to
1506 increase the score of each group you read."
1507 (gnus-group-add-score gnus-newsgroup-name))
1511 ;;; Gnus summary mode
1514 (put 'gnus-summary-mode 'mode-class 'special)
1516 (defvar gnus-article-commands-menu)
1519 ;; Non-orthogonal keys
1521 (gnus-define-keys gnus-summary-mode-map
1522 " " gnus-summary-next-page
1523 "\177" gnus-summary-prev-page
1524 [delete] gnus-summary-prev-page
1525 [backspace] gnus-summary-prev-page
1526 "\r" gnus-summary-scroll-up
1527 "\M-\r" gnus-summary-scroll-down
1528 "n" gnus-summary-next-unread-article
1529 "p" gnus-summary-prev-unread-article
1530 "N" gnus-summary-next-article
1531 "P" gnus-summary-prev-article
1532 "\M-\C-n" gnus-summary-next-same-subject
1533 "\M-\C-p" gnus-summary-prev-same-subject
1534 "\M-n" gnus-summary-next-unread-subject
1535 "\M-p" gnus-summary-prev-unread-subject
1536 "." gnus-summary-first-unread-article
1537 "," gnus-summary-best-unread-article
1538 "\M-s" gnus-summary-search-article-forward
1539 "\M-r" gnus-summary-search-article-backward
1540 "<" gnus-summary-beginning-of-article
1541 ">" gnus-summary-end-of-article
1542 "j" gnus-summary-goto-article
1543 "^" gnus-summary-refer-parent-article
1544 "\M-^" gnus-summary-refer-article
1545 "u" gnus-summary-tick-article-forward
1546 "!" gnus-summary-tick-article-forward
1547 "U" gnus-summary-tick-article-backward
1548 "d" gnus-summary-mark-as-read-forward
1549 "D" gnus-summary-mark-as-read-backward
1550 "E" gnus-summary-mark-as-expirable
1551 "\M-u" gnus-summary-clear-mark-forward
1552 "\M-U" gnus-summary-clear-mark-backward
1553 "k" gnus-summary-kill-same-subject-and-select
1554 "\C-k" gnus-summary-kill-same-subject
1555 "\M-\C-k" gnus-summary-kill-thread
1556 "\M-\C-l" gnus-summary-lower-thread
1557 "e" gnus-summary-edit-article
1558 "#" gnus-summary-mark-as-processable
1559 "\M-#" gnus-summary-unmark-as-processable
1560 "\M-\C-t" gnus-summary-toggle-threads
1561 "\M-\C-s" gnus-summary-show-thread
1562 "\M-\C-h" gnus-summary-hide-thread
1563 "\M-\C-f" gnus-summary-next-thread
1564 "\M-\C-b" gnus-summary-prev-thread
1565 [(meta down)] gnus-summary-next-thread
1566 [(meta up)] gnus-summary-prev-thread
1567 "\M-\C-u" gnus-summary-up-thread
1568 "\M-\C-d" gnus-summary-down-thread
1569 "&" gnus-summary-execute-command
1570 "c" gnus-summary-catchup-and-exit
1571 "\C-w" gnus-summary-mark-region-as-read
1572 "\C-t" gnus-summary-toggle-truncation
1573 "?" gnus-summary-mark-as-dormant
1574 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1575 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1576 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1577 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1578 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1579 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1580 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1581 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1582 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1583 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1584 "=" gnus-summary-expand-window
1585 "\C-x\C-s" gnus-summary-reselect-current-group
1586 "\M-g" gnus-summary-rescan-group
1587 "w" gnus-summary-stop-page-breaking
1588 "\C-c\C-r" gnus-summary-caesar-message
1589 "\M-t" gnus-summary-toggle-mime
1590 "f" gnus-summary-followup
1591 "F" gnus-summary-followup-with-original
1592 "C" gnus-summary-cancel-article
1593 "r" gnus-summary-reply
1594 "R" gnus-summary-reply-with-original
1595 "\C-c\C-f" gnus-summary-mail-forward
1596 "o" gnus-summary-save-article
1597 "\C-o" gnus-summary-save-article-mail
1598 "|" gnus-summary-pipe-output
1599 "\M-k" gnus-summary-edit-local-kill
1600 "\M-K" gnus-summary-edit-global-kill
1602 "\C-c\C-d" gnus-summary-describe-group
1603 "q" gnus-summary-exit
1604 "Q" gnus-summary-exit-no-update
1605 "\C-c\C-i" gnus-info-find-node
1606 gnus-mouse-2 gnus-mouse-pick-article
1607 "m" gnus-summary-mail-other-window
1608 "a" gnus-summary-post-news
1609 "i" gnus-summary-news-other-window
1610 "x" gnus-summary-limit-to-unread
1611 "s" gnus-summary-isearch-article
1612 "t" gnus-summary-toggle-header
1613 "g" gnus-summary-show-article
1614 "l" gnus-summary-goto-last-article
1615 "v" gnus-summary-preview-mime-message
1616 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1617 "\C-d" gnus-summary-enter-digest-group
1618 "\M-\C-d" gnus-summary-read-document
1619 "\M-\C-e" gnus-summary-edit-parameters
1620 "\M-\C-a" gnus-summary-customize-parameters
1622 "\C-c\C-n" gnus-namazu-search
1623 "*" gnus-cache-enter-article
1624 "\M-*" gnus-cache-remove-article
1625 "\M-&" gnus-summary-universal-argument
1626 "\C-l" gnus-recenter
1627 "I" gnus-summary-increase-score
1628 "L" gnus-summary-lower-score
1629 "\M-i" gnus-symbolic-argument
1630 "h" gnus-summary-select-article-buffer
1632 "V" gnus-summary-score-map
1633 "X" gnus-uu-extract-map
1634 "S" gnus-summary-send-map)
1636 ;; Sort of orthogonal keymap
1637 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1638 "t" gnus-summary-tick-article-forward
1639 "!" gnus-summary-tick-article-forward
1640 "d" gnus-summary-mark-as-read-forward
1641 "r" gnus-summary-mark-as-read-forward
1642 "c" gnus-summary-clear-mark-forward
1643 " " gnus-summary-clear-mark-forward
1644 "e" gnus-summary-mark-as-expirable
1645 "x" gnus-summary-mark-as-expirable
1646 "?" gnus-summary-mark-as-dormant
1647 "b" gnus-summary-set-bookmark
1648 "B" gnus-summary-remove-bookmark
1649 "#" gnus-summary-mark-as-processable
1650 "\M-#" gnus-summary-unmark-as-processable
1651 "S" gnus-summary-limit-include-expunged
1652 "C" gnus-summary-catchup
1653 "H" gnus-summary-catchup-to-here
1654 "h" gnus-summary-catchup-from-here
1655 "\C-c" gnus-summary-catchup-all
1656 "k" gnus-summary-kill-same-subject-and-select
1657 "K" gnus-summary-kill-same-subject
1658 "P" gnus-uu-mark-map)
1660 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1661 "c" gnus-summary-clear-above
1662 "u" gnus-summary-tick-above
1663 "m" gnus-summary-mark-above
1664 "k" gnus-summary-kill-below)
1666 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1667 "/" gnus-summary-limit-to-subject
1668 "n" gnus-summary-limit-to-articles
1669 "w" gnus-summary-pop-limit
1670 "s" gnus-summary-limit-to-subject
1671 "a" gnus-summary-limit-to-author
1672 "u" gnus-summary-limit-to-unread
1673 "m" gnus-summary-limit-to-marks
1674 "M" gnus-summary-limit-exclude-marks
1675 "v" gnus-summary-limit-to-score
1676 "*" gnus-summary-limit-include-cached
1677 "D" gnus-summary-limit-include-dormant
1678 "T" gnus-summary-limit-include-thread
1679 "d" gnus-summary-limit-exclude-dormant
1680 "t" gnus-summary-limit-to-age
1681 "." gnus-summary-limit-to-unseen
1682 "x" gnus-summary-limit-to-extra
1683 "p" gnus-summary-limit-to-display-predicate
1684 "E" gnus-summary-limit-include-expunged
1685 "c" gnus-summary-limit-exclude-childless-dormant
1686 "C" gnus-summary-limit-mark-excluded-as-read
1687 "o" gnus-summary-insert-old-articles
1688 "N" gnus-summary-insert-new-articles)
1690 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1691 "n" gnus-summary-next-unread-article
1692 "p" gnus-summary-prev-unread-article
1693 "N" gnus-summary-next-article
1694 "P" gnus-summary-prev-article
1695 "\C-n" gnus-summary-next-same-subject
1696 "\C-p" gnus-summary-prev-same-subject
1697 "\M-n" gnus-summary-next-unread-subject
1698 "\M-p" gnus-summary-prev-unread-subject
1699 "f" gnus-summary-first-unread-article
1700 "b" gnus-summary-best-unread-article
1701 "j" gnus-summary-goto-article
1702 "g" gnus-summary-goto-subject
1703 "l" gnus-summary-goto-last-article
1704 "o" gnus-summary-pop-article)
1706 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1707 "k" gnus-summary-kill-thread
1708 "l" gnus-summary-lower-thread
1709 "i" gnus-summary-raise-thread
1710 "T" gnus-summary-toggle-threads
1711 "t" gnus-summary-rethread-current
1712 "^" gnus-summary-reparent-thread
1713 "s" gnus-summary-show-thread
1714 "S" gnus-summary-show-all-threads
1715 "h" gnus-summary-hide-thread
1716 "H" gnus-summary-hide-all-threads
1717 "n" gnus-summary-next-thread
1718 "p" gnus-summary-prev-thread
1719 "u" gnus-summary-up-thread
1720 "o" gnus-summary-top-thread
1721 "d" gnus-summary-down-thread
1722 "#" gnus-uu-mark-thread
1723 "\M-#" gnus-uu-unmark-thread)
1725 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1726 "g" gnus-summary-prepare
1727 "c" gnus-summary-insert-cached-articles)
1729 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1730 "c" gnus-summary-catchup-and-exit
1731 "C" gnus-summary-catchup-all-and-exit
1732 "E" gnus-summary-exit-no-update
1733 "J" gnus-summary-jump-to-other-group
1734 "Q" gnus-summary-exit
1735 "Z" gnus-summary-exit
1736 "n" gnus-summary-catchup-and-goto-next-group
1737 "R" gnus-summary-reselect-current-group
1738 "G" gnus-summary-rescan-group
1739 "N" gnus-summary-next-group
1740 "s" gnus-summary-save-newsrc
1741 "P" gnus-summary-prev-group)
1743 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1744 " " gnus-summary-next-page
1745 "n" gnus-summary-next-page
1746 "\177" gnus-summary-prev-page
1747 [delete] gnus-summary-prev-page
1748 "p" gnus-summary-prev-page
1749 "\r" gnus-summary-scroll-up
1750 "\M-\r" gnus-summary-scroll-down
1751 "<" gnus-summary-beginning-of-article
1752 ">" gnus-summary-end-of-article
1753 "b" gnus-summary-beginning-of-article
1754 "e" gnus-summary-end-of-article
1755 "^" gnus-summary-refer-parent-article
1756 "r" gnus-summary-refer-parent-article
1757 "D" gnus-summary-enter-digest-group
1758 "R" gnus-summary-refer-references
1759 "T" gnus-summary-refer-thread
1760 "g" gnus-summary-show-article
1761 "s" gnus-summary-isearch-article
1762 "P" gnus-summary-print-article
1763 "M" gnus-mailing-list-insinuate
1764 "t" gnus-article-babel)
1766 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1767 "b" gnus-article-add-buttons
1768 "B" gnus-article-add-buttons-to-head
1769 "o" gnus-article-treat-overstrike
1770 "e" gnus-article-emphasize
1771 "w" gnus-article-fill-cited-article
1772 "Q" gnus-article-fill-long-lines
1773 "C" gnus-article-capitalize-sentences
1774 "c" gnus-article-remove-cr
1775 "Z" gnus-article-decode-HZ
1776 "h" gnus-article-wash-html
1777 "u" gnus-article-unsplit-urls
1778 "f" gnus-article-display-x-face
1779 "l" gnus-summary-stop-page-breaking
1780 "r" gnus-summary-caesar-message
1781 "t" gnus-summary-toggle-header
1782 "g" gnus-treat-smiley
1783 "v" gnus-summary-verbose-headers
1784 "m" gnus-summary-toggle-mime
1785 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1786 "p" gnus-article-verify-x-pgp-sig
1787 "d" gnus-article-treat-dumbquotes
1788 "k" gnus-article-outlook-deuglify-article)
1790 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1791 "a" gnus-article-hide
1792 "h" gnus-article-hide-headers
1793 "b" gnus-article-hide-boring-headers
1794 "s" gnus-article-hide-signature
1795 "c" gnus-article-hide-citation
1796 "C" gnus-article-hide-citation-in-followups
1797 "l" gnus-article-hide-list-identifiers
1798 "p" gnus-article-hide-pgp
1799 "B" gnus-article-strip-banner
1800 "P" gnus-article-hide-pem
1801 "\C-c" gnus-article-hide-citation-maybe)
1803 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1804 "a" gnus-article-highlight
1805 "h" gnus-article-highlight-headers
1806 "c" gnus-article-highlight-citation
1807 "s" gnus-article-highlight-signature)
1809 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1810 "f" gnus-article-treat-fold-headers
1811 "u" gnus-article-treat-unfold-headers
1812 "n" gnus-article-treat-fold-newsgroups)
1814 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1815 "x" gnus-article-display-x-face
1816 "s" gnus-treat-smiley
1817 "D" gnus-article-remove-images
1818 "f" gnus-treat-from-picon
1819 "m" gnus-treat-mail-picon
1820 "n" gnus-treat-newsgroups-picon)
1822 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1823 "z" gnus-article-date-ut
1824 "u" gnus-article-date-ut
1825 "l" gnus-article-date-local
1826 "p" gnus-article-date-english
1827 "e" gnus-article-date-lapsed
1828 "o" gnus-article-date-original
1829 "i" gnus-article-date-iso8601
1830 "s" gnus-article-date-user)
1832 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1833 "t" gnus-article-remove-trailing-blank-lines
1834 "l" gnus-article-strip-leading-blank-lines
1835 "m" gnus-article-strip-multiple-blank-lines
1836 "a" gnus-article-strip-blank-lines
1837 "A" gnus-article-strip-all-blank-lines
1838 "s" gnus-article-strip-leading-space
1839 "e" gnus-article-strip-trailing-space
1840 "w" gnus-article-remove-leading-whitespace)
1842 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1844 "f" gnus-summary-fetch-faq
1845 "d" gnus-summary-describe-group
1846 "h" gnus-summary-describe-briefly
1847 "i" gnus-info-find-node)
1849 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1850 "e" gnus-summary-expire-articles
1851 "\M-\C-e" gnus-summary-expire-articles-now
1852 "\177" gnus-summary-delete-article
1853 [delete] gnus-summary-delete-article
1854 [backspace] gnus-summary-delete-article
1855 "m" gnus-summary-move-article
1856 "r" gnus-summary-respool-article
1857 "w" gnus-summary-edit-article
1858 "c" gnus-summary-copy-article
1859 "B" gnus-summary-crosspost-article
1860 "q" gnus-summary-respool-query
1861 "t" gnus-summary-respool-trace
1862 "i" gnus-summary-import-article
1863 "I" gnus-summary-create-article
1864 "p" gnus-summary-article-posted-p)
1866 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1867 "o" gnus-summary-save-article
1868 "m" gnus-summary-save-article-mail
1869 "F" gnus-summary-write-article-file
1870 "r" gnus-summary-save-article-rmail
1871 "f" gnus-summary-save-article-file
1872 "b" gnus-summary-save-article-body-file
1873 "h" gnus-summary-save-article-folder
1874 "v" gnus-summary-save-article-vm
1875 "p" gnus-summary-pipe-output
1876 "P" gnus-summary-muttprint
1877 "s" gnus-soup-add-article)
1879 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1880 "b" gnus-summary-display-buttonized
1881 "m" gnus-summary-repair-multipart
1882 "v" gnus-article-view-part
1883 "o" gnus-article-save-part
1884 "c" gnus-article-copy-part
1885 "C" gnus-article-view-part-as-charset
1886 "e" gnus-article-view-part-externally
1887 "E" gnus-article-encrypt-body
1888 "i" gnus-article-inline-part
1889 "|" gnus-article-pipe-part)
1891 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1892 "p" gnus-summary-mark-as-processable
1893 "u" gnus-summary-unmark-as-processable
1894 "U" gnus-summary-unmark-all-processable
1895 "v" gnus-uu-mark-over
1896 "s" gnus-uu-mark-series
1897 "r" gnus-uu-mark-region
1898 "g" gnus-uu-unmark-region
1899 "R" gnus-uu-mark-by-regexp
1900 "G" gnus-uu-unmark-by-regexp
1901 "t" gnus-uu-mark-thread
1902 "T" gnus-uu-unmark-thread
1903 "a" gnus-uu-mark-all
1904 "b" gnus-uu-mark-buffer
1905 "S" gnus-uu-mark-sparse
1906 "k" gnus-summary-kill-process-mark
1907 "y" gnus-summary-yank-process-mark
1908 "w" gnus-summary-save-process-mark
1909 "i" gnus-uu-invert-processable)
1911 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1912 ;;"x" gnus-uu-extract-any
1913 "m" gnus-summary-save-parts
1914 "u" gnus-uu-decode-uu
1915 "U" gnus-uu-decode-uu-and-save
1916 "s" gnus-uu-decode-unshar
1917 "S" gnus-uu-decode-unshar-and-save
1918 "o" gnus-uu-decode-save
1919 "O" gnus-uu-decode-save
1920 "b" gnus-uu-decode-binhex
1921 "B" gnus-uu-decode-binhex
1922 "p" gnus-uu-decode-postscript
1923 "P" gnus-uu-decode-postscript-and-save)
1926 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1927 "u" gnus-uu-decode-uu-view
1928 "U" gnus-uu-decode-uu-and-save-view
1929 "s" gnus-uu-decode-unshar-view
1930 "S" gnus-uu-decode-unshar-and-save-view
1931 "o" gnus-uu-decode-save-view
1932 "O" gnus-uu-decode-save-view
1933 "b" gnus-uu-decode-binhex-view
1934 "B" gnus-uu-decode-binhex-view
1935 "p" gnus-uu-decode-postscript-view
1936 "P" gnus-uu-decode-postscript-and-save-view))
1938 (defvar gnus-article-post-menu nil)
1940 (defconst gnus-summary-menu-maxlen 20)
1942 (defun gnus-summary-menu-split (menu)
1943 ;; If we have lots of elements, divide them into groups of 20
1944 ;; and make a pane (or submenu) for each one.
1945 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1946 (let ((menu menu) sublists next
1949 ;; Pull off the next gnus-summary-menu-maxlen elements
1950 ;; and make them the next element of sublist.
1951 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1953 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1955 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1956 (aref (car (last menu)) 0)) menu)
1960 (nreverse sublists))
1961 ;; Few elements--put them all in one pane.
1964 (defun gnus-summary-make-menu-bar ()
1965 (gnus-turn-off-edit-menu 'summary)
1967 (unless (boundp 'gnus-summary-misc-menu)
1970 gnus-summary-kill-menu gnus-summary-mode-map ""
1975 ["Customize" gnus-score-customize t])
1976 (gnus-make-score-map 'increase)
1977 (gnus-make-score-map 'lower)
1979 ["Kill below" gnus-summary-kill-below t]
1980 ["Mark above" gnus-summary-mark-above t]
1981 ["Tick above" gnus-summary-tick-above t]
1982 ["Clear above" gnus-summary-clear-above t])
1983 ["Current score" gnus-summary-current-score t]
1984 ["Set score" gnus-summary-set-score t]
1985 ["Switch current score file..." gnus-score-change-score-file t]
1986 ["Set mark below..." gnus-score-set-mark-below t]
1987 ["Set expunge below..." gnus-score-set-expunge-below t]
1988 ["Edit current score file" gnus-score-edit-current-scores t]
1989 ["Edit score file" gnus-score-edit-file t]
1990 ["Trace score" gnus-score-find-trace t]
1991 ["Find words" gnus-score-find-favourite-words t]
1992 ["Rescore buffer" gnus-summary-rescore t]
1993 ["Increase score..." gnus-summary-increase-score t]
1994 ["Lower score..." gnus-summary-lower-score t]))))
1996 ;; Define both the Article menu in the summary buffer and the
1997 ;; equivalent Commands menu in the article buffer here for
2001 ["All" gnus-article-hide t]
2002 ["Headers" gnus-article-hide-headers t]
2003 ["Signature" gnus-article-hide-signature t]
2004 ["Citation" gnus-article-hide-citation t]
2005 ["List identifiers" gnus-article-hide-list-identifiers t]
2006 ["PGP" gnus-article-hide-pgp t]
2007 ["Banner" gnus-article-strip-banner t]
2008 ["Boring headers" gnus-article-hide-boring-headers t])
2010 ["All" gnus-article-highlight t]
2011 ["Headers" gnus-article-highlight-headers t]
2012 ["Signature" gnus-article-highlight-signature t]
2013 ["Citation" gnus-article-highlight-citation t])
2015 ["Local" gnus-article-date-local t]
2016 ["ISO8601" gnus-article-date-iso8601 t]
2017 ["UT" gnus-article-date-ut t]
2018 ["Original" gnus-article-date-original t]
2019 ["Lapsed" gnus-article-date-lapsed t]
2020 ["User-defined" gnus-article-date-user t])
2022 ["Remove images" gnus-article-remove-images t]
2023 ["Toggle smiley" gnus-treat-smiley t]
2024 ["Show X-Face" gnus-article-display-x-face t]
2025 ["Show picons in From" gnus-treat-from-picon t]
2026 ["Show picons in mail headers" gnus-treat-mail-picon t]
2027 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2028 ("View as different encoding"
2029 ,@(gnus-summary-menu-split
2032 ;; Since easymenu under FSF Emacs doesn't allow lambda
2033 ;; forms for menu commands, we should provide intern'ed
2034 ;; function symbols.
2035 (let ((command (intern (format "\
2036 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2040 (let ((gnus-summary-show-article-charset-alist
2042 (gnus-summary-show-article 1))))
2043 `[,(symbol-name cs) ,command t]))
2044 (sort (if (fboundp 'coding-system-list)
2045 (coding-system-list)
2046 ;;(mapcar 'car mm-mime-mule-charset-alist)
2051 ["Leading" gnus-article-strip-leading-blank-lines t]
2052 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2053 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2054 ["All of the above" gnus-article-strip-blank-lines t]
2055 ["All" gnus-article-strip-all-blank-lines t]
2056 ["Leading space" gnus-article-strip-leading-space t]
2057 ["Trailing space" gnus-article-strip-trailing-space t]
2058 ["Leading space in headers"
2059 gnus-article-remove-leading-whitespace t])
2060 ["Overstrike" gnus-article-treat-overstrike t]
2061 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2062 ["Emphasis" gnus-article-emphasize t]
2063 ["Word wrap" gnus-article-fill-cited-article t]
2064 ["Fill long lines" gnus-article-fill-long-lines t]
2065 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2066 ["CR" gnus-article-remove-cr t]
2067 ["Rot 13" gnus-summary-caesar-message
2068 ,@(if (featurep 'xemacs) '(t)
2069 '(:help "\"Caesar rotate\" article by 13"))]
2070 ["Unix pipe..." gnus-summary-pipe-message t]
2071 ["Add buttons" gnus-article-add-buttons t]
2072 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2073 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2074 ["Toggle MIME" gnus-summary-toggle-mime t]
2075 ["Verbose header" gnus-summary-verbose-headers t]
2076 ["Toggle header" gnus-summary-toggle-header t]
2077 ["Unfold headers" gnus-article-treat-unfold-headers t]
2078 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2079 ["Html" gnus-article-wash-html t]
2080 ["URLs" gnus-article-unsplit-urls t]
2081 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2082 ["HZ" gnus-article-decode-HZ t]
2083 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2086 ["Save in default format" gnus-summary-save-article
2087 ,@(if (featurep 'xemacs) '(t)
2088 '(:help "Save article using default method"))]
2089 ["Save in file" gnus-summary-save-article-file
2090 ,@(if (featurep 'xemacs) '(t)
2091 '(:help "Save article in file"))]
2092 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2093 ["Save in MH folder" gnus-summary-save-article-folder t]
2094 ["Save in VM folder" gnus-summary-save-article-vm t]
2095 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2096 ["Save body in file" gnus-summary-save-article-body-file t]
2097 ["Pipe through a filter" gnus-summary-pipe-output t]
2098 ["Add to SOUP packet" gnus-soup-add-article t]
2099 ["Print with Muttprint" gnus-summary-muttprint t]
2100 ["Print" gnus-summary-print-article t])
2102 ["Respool article..." gnus-summary-respool-article t]
2103 ["Move article..." gnus-summary-move-article
2104 (gnus-check-backend-function
2105 'request-move-article gnus-newsgroup-name)]
2106 ["Copy article..." gnus-summary-copy-article t]
2107 ["Crosspost article..." gnus-summary-crosspost-article
2108 (gnus-check-backend-function
2109 'request-replace-article gnus-newsgroup-name)]
2110 ["Import file..." gnus-summary-import-article t]
2111 ["Create article..." gnus-summary-create-article t]
2112 ["Check if posted" gnus-summary-article-posted-p t]
2113 ["Edit article" gnus-summary-edit-article
2114 (not (gnus-group-read-only-p))]
2115 ["Delete article" gnus-summary-delete-article
2116 (gnus-check-backend-function
2117 'request-expire-articles gnus-newsgroup-name)]
2118 ["Query respool" gnus-summary-respool-query t]
2119 ["Trace respool" gnus-summary-respool-trace t]
2120 ["Delete expirable articles" gnus-summary-expire-articles-now
2121 (gnus-check-backend-function
2122 'request-expire-articles gnus-newsgroup-name)])
2124 ["Uudecode" gnus-uu-decode-uu
2125 ,@(if (featurep 'xemacs) '(t)
2126 '(:help "Decode uuencoded article(s)"))]
2127 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2128 ["Unshar" gnus-uu-decode-unshar t]
2129 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2130 ["Save" gnus-uu-decode-save t]
2131 ["Binhex" gnus-uu-decode-binhex t]
2132 ["Postscript" gnus-uu-decode-postscript t])
2134 ["Enter article" gnus-cache-enter-article t]
2135 ["Remove article" gnus-cache-remove-article t])
2136 ["Translate" gnus-article-babel t]
2137 ["Select article buffer" gnus-summary-select-article-buffer t]
2138 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2139 ["Isearch article..." gnus-summary-isearch-article t]
2140 ["Beginning of the article" gnus-summary-beginning-of-article t]
2141 ["End of the article" gnus-summary-end-of-article t]
2142 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2143 ["Fetch referenced articles" gnus-summary-refer-references t]
2144 ["Fetch current thread" gnus-summary-refer-thread t]
2145 ["Fetch article with id..." gnus-summary-refer-article t]
2146 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2147 ["Redisplay" gnus-summary-show-article t]
2148 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2150 gnus-summary-article-menu gnus-summary-mode-map ""
2151 (cons "Article" innards))
2153 (if (not (keymapp gnus-summary-article-menu))
2155 gnus-article-commands-menu gnus-article-mode-map ""
2156 (cons "Commands" innards))
2157 ;; in Emacs, don't share menu.
2158 (setq gnus-article-commands-menu
2159 (copy-keymap gnus-summary-article-menu))
2160 (define-key gnus-article-mode-map [menu-bar commands]
2161 (cons "Commands" gnus-article-commands-menu))))
2164 gnus-summary-thread-menu gnus-summary-mode-map ""
2166 ["Toggle threading" gnus-summary-toggle-threads t]
2167 ["Hide threads" gnus-summary-hide-all-threads t]
2168 ["Show threads" gnus-summary-show-all-threads t]
2169 ["Hide thread" gnus-summary-hide-thread t]
2170 ["Show thread" gnus-summary-show-thread t]
2171 ["Go to next thread" gnus-summary-next-thread t]
2172 ["Go to previous thread" gnus-summary-prev-thread t]
2173 ["Go down thread" gnus-summary-down-thread t]
2174 ["Go up thread" gnus-summary-up-thread t]
2175 ["Top of thread" gnus-summary-top-thread t]
2176 ["Mark thread as read" gnus-summary-kill-thread t]
2177 ["Lower thread score" gnus-summary-lower-thread t]
2178 ["Raise thread score" gnus-summary-raise-thread t]
2179 ["Rethread current" gnus-summary-rethread-current t]))
2182 gnus-summary-post-menu gnus-summary-mode-map ""
2184 ["Send a message (mail or news)" gnus-summary-post-news
2185 ,@(if (featurep 'xemacs) '(t)
2186 '(:help "Post an article"))]
2187 ["Followup" gnus-summary-followup
2188 ,@(if (featurep 'xemacs) '(t)
2189 '(:help "Post followup to this article"))]
2190 ["Followup and yank" gnus-summary-followup-with-original
2191 ,@(if (featurep 'xemacs) '(t)
2192 '(:help "Post followup to this article, quoting its contents"))]
2193 ["Supersede article" gnus-summary-supersede-article t]
2194 ["Cancel article" gnus-summary-cancel-article
2195 ,@(if (featurep 'xemacs) '(t)
2196 '(:help "Cancel an article you posted"))]
2197 ["Reply" gnus-summary-reply t]
2198 ["Reply and yank" gnus-summary-reply-with-original t]
2199 ["Wide reply" gnus-summary-wide-reply t]
2200 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Mail a reply, quoting this article"))]
2203 ["Very wide reply" gnus-summary-very-wide-reply t]
2204 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2205 ,@(if (featurep 'xemacs) '(t)
2206 '(:help "Mail a very wide reply, quoting this article"))]
2207 ["Mail forward" gnus-summary-mail-forward t]
2208 ["Post forward" gnus-summary-post-forward t]
2209 ["Digest and mail" gnus-summary-digest-mail-forward t]
2210 ["Digest and post" gnus-summary-digest-post-forward t]
2211 ["Resend message" gnus-summary-resend-message t]
2212 ["Resend message edit" gnus-summary-resend-message-edit t]
2213 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2214 ["Send a mail" gnus-summary-mail-other-window t]
2215 ["Create a local message" gnus-summary-news-other-window t]
2216 ["Uuencode and post" gnus-uu-post-news
2217 ,@(if (featurep 'xemacs) '(t)
2218 '(:help "Post a uuencoded article"))]
2219 ["Followup via news" gnus-summary-followup-to-mail t]
2220 ["Followup via news and yank"
2221 gnus-summary-followup-to-mail-with-original t]
2223 ;;["Send" gnus-summary-send-draft t]
2224 ;;["Send bounced" gnus-resend-bounced-mail t])
2228 ((not (keymapp gnus-summary-post-menu))
2229 (setq gnus-article-post-menu gnus-summary-post-menu))
2230 ((not gnus-article-post-menu)
2231 ;; Don't share post menu.
2232 (setq gnus-article-post-menu
2233 (copy-keymap gnus-summary-post-menu))))
2234 (define-key gnus-article-mode-map [menu-bar post]
2235 (cons "Post" gnus-article-post-menu))
2238 gnus-summary-misc-menu gnus-summary-mode-map ""
2241 ["Mark as read" gnus-summary-mark-as-read-forward t]
2242 ["Mark same subject and select"
2243 gnus-summary-kill-same-subject-and-select t]
2244 ["Mark same subject" gnus-summary-kill-same-subject t]
2245 ["Catchup" gnus-summary-catchup
2246 ,@(if (featurep 'xemacs) '(t)
2247 '(:help "Mark unread articles in this group as read"))]
2248 ["Catchup all" gnus-summary-catchup-all t]
2249 ["Catchup to here" gnus-summary-catchup-to-here t]
2250 ["Catchup from here" gnus-summary-catchup-from-here t]
2251 ["Catchup region" gnus-summary-mark-region-as-read t]
2252 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2254 ["Tick" gnus-summary-tick-article-forward t]
2255 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2256 ["Remove marks" gnus-summary-clear-mark-forward t]
2257 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2258 ["Set bookmark" gnus-summary-set-bookmark t]
2259 ["Remove bookmark" gnus-summary-remove-bookmark t])
2261 ["Marks..." gnus-summary-limit-to-marks t]
2262 ["Subject..." gnus-summary-limit-to-subject t]
2263 ["Author..." gnus-summary-limit-to-author t]
2264 ["Age..." gnus-summary-limit-to-age t]
2265 ["Extra..." gnus-summary-limit-to-extra t]
2266 ["Score..." gnus-summary-limit-to-score t]
2267 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2268 ["Unread" gnus-summary-limit-to-unread t]
2269 ["Unseen" gnus-summary-limit-to-unseen t]
2270 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2271 ["Articles" gnus-summary-limit-to-articles t]
2272 ["Pop limit" gnus-summary-pop-limit t]
2273 ["Show dormant" gnus-summary-limit-include-dormant t]
2274 ["Hide childless dormant"
2275 gnus-summary-limit-exclude-childless-dormant t]
2276 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2277 ["Hide marked" gnus-summary-limit-exclude-marks t]
2278 ["Show expunged" gnus-summary-limit-include-expunged t])
2280 ["Set mark" gnus-summary-mark-as-processable t]
2281 ["Remove mark" gnus-summary-unmark-as-processable t]
2282 ["Remove all marks" gnus-summary-unmark-all-processable t]
2283 ["Mark above" gnus-uu-mark-over t]
2284 ["Mark series" gnus-uu-mark-series t]
2285 ["Mark region" gnus-uu-mark-region t]
2286 ["Unmark region" gnus-uu-unmark-region t]
2287 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2288 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2289 ["Mark all" gnus-uu-mark-all t]
2290 ["Mark buffer" gnus-uu-mark-buffer t]
2291 ["Mark sparse" gnus-uu-mark-sparse t]
2292 ["Mark thread" gnus-uu-mark-thread t]
2293 ["Unmark thread" gnus-uu-unmark-thread t]
2294 ("Process Mark Sets"
2295 ["Kill" gnus-summary-kill-process-mark t]
2296 ["Yank" gnus-summary-yank-process-mark
2297 gnus-newsgroup-process-stack]
2298 ["Save" gnus-summary-save-process-mark t]))
2300 ["Page forward" gnus-summary-next-page
2301 ,@(if (featurep 'xemacs) '(t)
2302 '(:help "Show next page of article"))]
2303 ["Page backward" gnus-summary-prev-page
2304 ,@(if (featurep 'xemacs) '(t)
2305 '(:help "Show previous page of article"))]
2306 ["Line forward" gnus-summary-scroll-up t])
2308 ["Next unread article" gnus-summary-next-unread-article t]
2309 ["Previous unread article" gnus-summary-prev-unread-article t]
2310 ["Next article" gnus-summary-next-article t]
2311 ["Previous article" gnus-summary-prev-article t]
2312 ["Next unread subject" gnus-summary-next-unread-subject t]
2313 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2314 ["Next article same subject" gnus-summary-next-same-subject t]
2315 ["Previous article same subject" gnus-summary-prev-same-subject t]
2316 ["First unread article" gnus-summary-first-unread-article t]
2317 ["Best unread article" gnus-summary-best-unread-article t]
2318 ["Go to subject number..." gnus-summary-goto-subject t]
2319 ["Go to article number..." gnus-summary-goto-article t]
2320 ["Go to the last article" gnus-summary-goto-last-article t]
2321 ["Pop article off history" gnus-summary-pop-article t])
2323 ["Sort by number" gnus-summary-sort-by-number t]
2324 ["Sort by author" gnus-summary-sort-by-author t]
2325 ["Sort by subject" gnus-summary-sort-by-subject t]
2326 ["Sort by date" gnus-summary-sort-by-date t]
2327 ["Sort by score" gnus-summary-sort-by-score t]
2328 ["Sort by lines" gnus-summary-sort-by-lines t]
2329 ["Sort by characters" gnus-summary-sort-by-chars t]
2330 ["Randomize" gnus-summary-sort-by-random t]
2331 ["Original sort" gnus-summary-sort-by-original t])
2333 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2334 ["Describe group" gnus-summary-describe-group t]
2335 ["Read manual" gnus-info-find-node t])
2337 ["Pick and read" gnus-pick-mode t]
2338 ["Binary" gnus-binary-mode t])
2340 ["Regenerate" gnus-summary-prepare t]
2341 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2342 ["Toggle threading" gnus-summary-toggle-threads t])
2343 ["See old articles" gnus-summary-insert-old-articles t]
2344 ["See new articles" gnus-summary-insert-new-articles t]
2345 ["Filter articles..." gnus-summary-execute-command t]
2346 ["Run command on subjects..." gnus-summary-universal-argument t]
2347 ["Search articles forward..." gnus-summary-search-article-forward t]
2348 ["Search articles backward..." gnus-summary-search-article-backward t]
2349 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2350 ["Expand window" gnus-summary-expand-window t]
2351 ["Expire expirable articles" gnus-summary-expire-articles
2352 (gnus-check-backend-function
2353 'request-expire-articles gnus-newsgroup-name)]
2354 ["Edit local kill file" gnus-summary-edit-local-kill t]
2355 ["Edit main kill file" gnus-summary-edit-global-kill t]
2356 ["Edit group parameters" gnus-summary-edit-parameters t]
2357 ["Customize group parameters" gnus-summary-customize-parameters t]
2358 ["Send a bug report" gnus-bug t]
2360 ["Catchup and exit" gnus-summary-catchup-and-exit
2361 ,@(if (featurep 'xemacs) '(t)
2362 '(:help "Mark unread articles in this group as read, then exit"))]
2363 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2364 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2365 ["Exit group" gnus-summary-exit
2366 ,@(if (featurep 'xemacs) '(t)
2367 '(:help "Exit current group, return to group selection mode"))]
2368 ["Exit group without updating" gnus-summary-exit-no-update t]
2369 ["Exit and goto next group" gnus-summary-next-group t]
2370 ["Exit and goto prev group" gnus-summary-prev-group t]
2371 ["Reselect group" gnus-summary-reselect-current-group t]
2372 ["Rescan group" gnus-summary-rescan-group t]
2373 ["Update dribble" gnus-summary-save-newsrc t])))
2375 (gnus-run-hooks 'gnus-summary-menu-hook)))
2377 (defvar gnus-summary-tool-bar-map nil)
2379 ;; Emacs 21 tool bar. Should be no-op otherwise.
2380 (defun gnus-summary-make-tool-bar ()
2381 (if (and (fboundp 'tool-bar-add-item-from-menu)
2382 (default-value 'tool-bar-mode)
2383 (not gnus-summary-tool-bar-map))
2384 (setq gnus-summary-tool-bar-map
2385 (let ((tool-bar-map (make-sparse-keymap))
2386 (load-path (mm-image-load-path)))
2387 (tool-bar-add-item-from-menu
2388 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2389 (tool-bar-add-item-from-menu
2390 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2391 (tool-bar-add-item-from-menu
2392 'gnus-summary-post-news "post" gnus-summary-mode-map)
2393 (tool-bar-add-item-from-menu
2394 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2395 (tool-bar-add-item-from-menu
2396 'gnus-summary-followup "followup" gnus-summary-mode-map)
2397 (tool-bar-add-item-from-menu
2398 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2399 (tool-bar-add-item-from-menu
2400 'gnus-summary-reply "reply" gnus-summary-mode-map)
2401 (tool-bar-add-item-from-menu
2402 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2403 (tool-bar-add-item-from-menu
2404 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2405 (tool-bar-add-item-from-menu
2406 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2407 (tool-bar-add-item-from-menu
2408 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2409 (tool-bar-add-item-from-menu
2410 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2411 (tool-bar-add-item-from-menu
2412 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2413 (tool-bar-add-item-from-menu
2414 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2415 (tool-bar-add-item-from-menu
2416 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2418 (if gnus-summary-tool-bar-map
2419 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2421 (defun gnus-score-set-default (var value)
2422 "A version of set that updates the GNU Emacs menu-bar."
2424 ;; It is the message that forces the active status to be updated.
2427 (defun gnus-make-score-map (type)
2428 "Make a summary score map of type TYPE."
2431 (let ((headers '(("author" "from" string)
2432 ("subject" "subject" string)
2433 ("article body" "body" string)
2434 ("article head" "head" string)
2435 ("xref" "xref" string)
2436 ("extra header" "extra" string)
2437 ("lines" "lines" number)
2438 ("followups to author" "followup" string)))
2439 (types '((number ("less than" <)
2442 (string ("substring" s)
2446 (perms '(("temporary" (current-time-string))
2454 (if (eq type 'lower)
2459 (setq header (car headers))
2465 (let ((ts (cdr (assoc (nth 2 header) types)))
2481 'gnus-summary-score-entry
2483 (if (or (string= (nth 1 header)
2485 (string= (nth 1 header)
2488 (list 'gnus-summary-header
2490 (list 'quote (nth 1 (car ts)))
2491 (list 'gnus-score-delta-default
2498 (list (nreverse outp))))
2501 (list (nreverse outt))))
2503 (setq headers (cdr headers)))
2504 (list (nreverse outh))))))))
2508 (defun gnus-summary-mode (&optional group)
2509 "Major mode for reading articles.
2511 All normal editing commands are switched off.
2512 \\<gnus-summary-mode-map>
2513 Each line in this buffer represents one article. To read an
2514 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2515 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2518 You can also post articles and send mail from this buffer. To
2519 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2520 of an article, type `\\[gnus-summary-reply]'.
2522 There are approx. one gazillion commands you can execute in this
2523 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2525 The following commands are available:
2527 \\{gnus-summary-mode-map}"
2529 (kill-all-local-variables)
2530 (when (gnus-visual-p 'summary-menu 'menu)
2531 (gnus-summary-make-menu-bar)
2532 (gnus-summary-make-tool-bar))
2533 (gnus-summary-make-local-variables)
2534 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2535 (gnus-summary-make-local-variables))
2536 (gnus-make-thread-indent-array)
2537 (gnus-simplify-mode-line)
2538 (setq major-mode 'gnus-summary-mode)
2539 (setq mode-name "Summary")
2540 (make-local-variable 'minor-mode-alist)
2541 (use-local-map gnus-summary-mode-map)
2542 (buffer-disable-undo)
2543 (setq buffer-read-only t) ;Disable modification
2544 (setq truncate-lines t)
2545 (setq selective-display t)
2546 (setq selective-display-ellipses t) ;Display `...'
2547 (gnus-summary-set-display-table)
2548 (gnus-set-default-directory)
2549 (setq gnus-newsgroup-name group)
2550 (unless (gnus-news-group-p group)
2551 (setq gnus-newsgroup-incorporated
2552 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2553 (make-local-variable 'gnus-summary-line-format)
2554 (make-local-variable 'gnus-summary-line-format-spec)
2555 (make-local-variable 'gnus-summary-dummy-line-format)
2556 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2557 (make-local-variable 'gnus-summary-mark-positions)
2558 (make-local-hook 'pre-command-hook)
2559 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2560 (gnus-run-hooks 'gnus-summary-mode-hook)
2561 (turn-on-gnus-mailing-list-mode)
2562 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2563 (gnus-update-summary-mark-positions))
2565 (defun gnus-summary-make-local-variables ()
2566 "Make all the local summary buffer variables."
2568 (dolist (local gnus-summary-local-variables)
2571 (if (eq (cdr local) 'global)
2572 ;; Copy the global value of the variable.
2573 (setq global (symbol-value (car local)))
2574 ;; Use the value from the list.
2575 (setq global (eval (cdr local))))
2576 (set (make-local-variable (car local)) global))
2577 ;; Simple nil-valued local variable.
2578 (set (make-local-variable local) nil)))))
2580 (defun gnus-summary-clear-local-variables ()
2581 (let ((locals gnus-summary-local-variables))
2583 (if (consp (car locals))
2584 (and (vectorp (caar locals))
2585 (set (caar locals) nil))
2586 (and (vectorp (car locals))
2587 (set (car locals) nil)))
2588 (setq locals (cdr locals)))))
2590 ;; Summary data functions.
2592 (defmacro gnus-data-number (data)
2595 (defmacro gnus-data-set-number (data number)
2596 `(setcar ,data ,number))
2598 (defmacro gnus-data-mark (data)
2601 (defmacro gnus-data-set-mark (data mark)
2602 `(setcar (nthcdr 1 ,data) ,mark))
2604 (defmacro gnus-data-pos (data)
2607 (defmacro gnus-data-set-pos (data pos)
2608 `(setcar (nthcdr 2 ,data) ,pos))
2610 (defmacro gnus-data-header (data)
2613 (defmacro gnus-data-set-header (data header)
2614 `(setcar (nthcdr 3 ,data) ,header))
2616 (defmacro gnus-data-level (data)
2619 (defmacro gnus-data-unread-p (data)
2620 `(= (nth 1 ,data) gnus-unread-mark))
2622 (defmacro gnus-data-read-p (data)
2623 `(/= (nth 1 ,data) gnus-unread-mark))
2625 (defmacro gnus-data-pseudo-p (data)
2626 `(consp (nth 3 ,data)))
2628 (defmacro gnus-data-find (number)
2629 `(assq ,number gnus-newsgroup-data))
2631 (defmacro gnus-data-find-list (number &optional data)
2632 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2633 (memq (assq ,number bdata)
2636 (defmacro gnus-data-make (number mark pos header level)
2637 `(list ,number ,mark ,pos ,header ,level))
2639 (defun gnus-data-enter (after-article number mark pos header level offset)
2640 (let ((data (gnus-data-find-list after-article)))
2642 (error "No such article: %d" after-article))
2643 (setcdr data (cons (gnus-data-make number mark pos header level)
2645 (setq gnus-newsgroup-data-reverse nil)
2646 (gnus-data-update-list (cddr data) offset)))
2648 (defun gnus-data-enter-list (after-article list &optional offset)
2650 (let ((data (and after-article (gnus-data-find-list after-article)))
2654 (let ((odata gnus-newsgroup-data))
2655 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2657 (gnus-data-update-list odata offset)))
2658 ;; Find the last element in the list to be spliced into the main
2661 (setq list (cdr list)))
2664 (setcdr list gnus-newsgroup-data)
2665 (setq gnus-newsgroup-data ilist)
2667 (gnus-data-update-list (cdr list) offset)))
2668 (setcdr list (cdr data))
2671 (gnus-data-update-list (cdr list) offset))))
2672 (setq gnus-newsgroup-data-reverse nil))))
2674 (defun gnus-data-remove (article &optional offset)
2675 (let ((data gnus-newsgroup-data))
2676 (if (= (gnus-data-number (car data)) article)
2678 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2679 gnus-newsgroup-data-reverse nil)
2681 (gnus-data-update-list gnus-newsgroup-data offset)))
2683 (when (= (gnus-data-number (cadr data)) article)
2684 (setcdr data (cddr data))
2686 (gnus-data-update-list (cdr data) offset))
2688 gnus-newsgroup-data-reverse nil))
2689 (setq data (cdr data))))))
2691 (defmacro gnus-data-list (backward)
2693 (or gnus-newsgroup-data-reverse
2694 (setq gnus-newsgroup-data-reverse
2695 (reverse gnus-newsgroup-data)))
2696 gnus-newsgroup-data))
2698 (defun gnus-data-update-list (data offset)
2699 "Add OFFSET to the POS of all data entries in DATA."
2700 (setq gnus-newsgroup-data-reverse nil)
2702 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2703 (setq data (cdr data))))
2705 (defun gnus-summary-article-pseudo-p (article)
2706 "Say whether this article is a pseudo article or not."
2707 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2709 (defmacro gnus-summary-article-sparse-p (article)
2710 "Say whether this article is a sparse article or not."
2711 `(memq ,article gnus-newsgroup-sparse))
2713 (defmacro gnus-summary-article-ancient-p (article)
2714 "Say whether this article is a sparse article or not."
2715 `(memq ,article gnus-newsgroup-ancient))
2717 (defun gnus-article-parent-p (number)
2718 "Say whether this article is a parent or not."
2719 (let ((data (gnus-data-find-list number)))
2720 (and (cdr data) ; There has to be an article after...
2721 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2722 (gnus-data-level (nth 1 data))))))
2724 (defun gnus-article-children (number)
2725 "Return a list of all children to NUMBER."
2726 (let* ((data (gnus-data-find-list number))
2727 (level (gnus-data-level (car data)))
2729 (setq data (cdr data))
2731 (= (gnus-data-level (car data)) (1+ level)))
2732 (push (gnus-data-number (car data)) children)
2733 (setq data (cdr data)))
2736 (defmacro gnus-summary-skip-intangible ()
2737 "If the current article is intangible, then jump to a different article."
2738 '(let ((to (get-text-property (point) 'gnus-intangible)))
2739 (and to (gnus-summary-goto-subject to))))
2741 (defmacro gnus-summary-article-intangible-p ()
2742 "Say whether this article is intangible or not."
2743 '(get-text-property (point) 'gnus-intangible))
2745 (defun gnus-article-read-p (article)
2746 "Say whether ARTICLE is read or not."
2747 (not (or (memq article gnus-newsgroup-marked)
2748 (memq article gnus-newsgroup-spam-marked)
2749 (memq article gnus-newsgroup-unreads)
2750 (memq article gnus-newsgroup-unselected)
2751 (memq article gnus-newsgroup-dormant))))
2753 ;; Some summary mode macros.
2755 (defmacro gnus-summary-article-number ()
2756 "The article number of the article on the current line.
2757 If there isn's an article number here, then we return the current
2760 (gnus-summary-skip-intangible)
2761 (or (get-text-property (point) 'gnus-number)
2762 (gnus-summary-last-subject))))
2764 (defmacro gnus-summary-article-header (&optional number)
2765 "Return the header of article NUMBER."
2766 `(gnus-data-header (gnus-data-find
2767 ,(or number '(gnus-summary-article-number)))))
2769 (defmacro gnus-summary-thread-level (&optional number)
2770 "Return the level of thread that starts with article NUMBER."
2771 `(if (and (eq gnus-summary-make-false-root 'dummy)
2772 (get-text-property (point) 'gnus-intangible))
2774 (gnus-data-level (gnus-data-find
2775 ,(or number '(gnus-summary-article-number))))))
2777 (defmacro gnus-summary-article-mark (&optional number)
2778 "Return the mark of article NUMBER."
2779 `(gnus-data-mark (gnus-data-find
2780 ,(or number '(gnus-summary-article-number)))))
2782 (defmacro gnus-summary-article-pos (&optional number)
2783 "Return the position of the line of article NUMBER."
2784 `(gnus-data-pos (gnus-data-find
2785 ,(or number '(gnus-summary-article-number)))))
2787 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2788 (defmacro gnus-summary-article-subject (&optional number)
2789 "Return current subject string or nil if nothing."
2792 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2793 '(gnus-data-header (assq (gnus-summary-article-number)
2794 gnus-newsgroup-data)))))
2797 (mail-header-subject headers))))
2799 (defmacro gnus-summary-article-score (&optional number)
2800 "Return current article score."
2801 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2802 gnus-newsgroup-scored))
2803 gnus-summary-default-score 0))
2805 (defun gnus-summary-article-children (&optional number)
2806 "Return a list of article numbers that are children of article NUMBER."
2807 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2808 (level (gnus-data-level (car data)))
2810 (while (and (setq data (cdr data))
2811 (> (setq l (gnus-data-level (car data))) level))
2812 (and (= (1+ level) l)
2813 (push (gnus-data-number (car data))
2815 (nreverse children)))
2817 (defun gnus-summary-article-parent (&optional number)
2818 "Return the article number of the parent of article NUMBER."
2819 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2820 (gnus-data-list t)))
2821 (level (gnus-data-level (car data))))
2823 () ; This is a root.
2824 ;; We search until we find an article with a level less than
2825 ;; this one. That function has to be the parent.
2826 (while (and (setq data (cdr data))
2827 (not (< (gnus-data-level (car data)) level))))
2828 (and data (gnus-data-number (car data))))))
2830 (defun gnus-unread-mark-p (mark)
2831 "Say whether MARK is the unread mark."
2832 (= mark gnus-unread-mark))
2834 (defun gnus-read-mark-p (mark)
2835 "Say whether MARK is one of the marks that mark as read.
2836 This is all marks except unread, ticked, dormant, and expirable."
2837 (not (or (= mark gnus-unread-mark)
2838 (= mark gnus-ticked-mark)
2839 (= mark gnus-dormant-mark)
2840 (= mark gnus-expirable-mark))))
2842 (defmacro gnus-article-mark (number)
2843 "Return the MARK of article NUMBER.
2844 This macro should only be used when computing the mark the \"first\"
2845 time; i.e., when generating the summary lines. After that,
2846 `gnus-summary-article-mark' should be used to examine the
2849 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2850 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2851 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2852 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2853 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2854 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2855 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2856 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2857 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2858 gnus-ancient-mark))))
2860 ;; Saving hidden threads.
2862 (defmacro gnus-save-hidden-threads (&rest forms)
2863 "Save hidden threads, eval FORMS, and restore the hidden threads."
2864 (let ((config (make-symbol "config")))
2865 `(let ((,config (gnus-hidden-threads-configuration)))
2869 (gnus-restore-hidden-threads-configuration ,config)))))
2870 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2871 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2873 (defun gnus-data-compute-positions ()
2874 "Compute the positions of all articles."
2875 (setq gnus-newsgroup-data-reverse nil)
2876 (let ((data gnus-newsgroup-data))
2878 (gnus-save-hidden-threads
2879 (gnus-summary-show-all-threads)
2880 (goto-char (point-min))
2882 (while (get-text-property (point) 'gnus-intangible)
2884 (gnus-data-set-pos (car data) (+ (point) 3))
2885 (setq data (cdr data))
2886 (forward-line 1))))))
2888 (defun gnus-hidden-threads-configuration ()
2889 "Return the current hidden threads configuration."
2892 (goto-char (point-min))
2893 (while (search-forward "\r" nil t)
2894 (push (1- (point)) config))
2897 (defun gnus-restore-hidden-threads-configuration (config)
2898 "Restore hidden threads configuration from CONFIG."
2900 (let (point buffer-read-only)
2901 (while (setq point (pop config))
2902 (when (and (< point (point-max))
2904 (eq (char-after) ?\n))
2905 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2907 ;; Various summary mode internalish functions.
2909 (defun gnus-mouse-pick-article (e)
2912 (gnus-summary-next-page nil t))
2914 (defun gnus-summary-set-display-table ()
2915 "Change the display table.
2916 Odd characters have a tendency to mess
2917 up nicely formatted displays - we make all possible glyphs
2918 display only a single character."
2920 ;; We start from the standard display table, if any.
2921 (let ((table (or (copy-sequence standard-display-table)
2922 (make-display-table)))
2924 ;; Nix out all the control chars...
2925 (while (>= (setq i (1- i)) 0)
2926 (aset table i [??]))
2927 ;; ... but not newline and cr, of course. (cr is necessary for the
2928 ;; selective display).
2929 (aset table ?\n nil)
2930 (aset table ?\r nil)
2931 ;; We keep TAB as well.
2932 (aset table ?\t nil)
2933 ;; We nix out any glyphs over 126 that are not set already.
2935 (while (>= (setq i (1- i)) 127)
2936 ;; Only modify if the entry is nil.
2937 (unless (aref table i)
2938 (aset table i [??]))))
2939 (setq buffer-display-table table)))
2941 (defun gnus-summary-set-article-display-arrow (pos)
2942 "Update the overlay arrow to point to line at position POS."
2943 (when (and gnus-summary-display-arrow
2944 (boundp 'overlay-arrow-position)
2945 (boundp 'overlay-arrow-string))
2949 (unless overlay-arrow-position
2950 (setq overlay-arrow-position (make-marker)))
2951 (setq overlay-arrow-string "=>"
2952 overlay-arrow-position (set-marker overlay-arrow-position
2954 (current-buffer))))))
2956 (defun gnus-summary-buffer-name (group)
2957 "Return the summary buffer name of GROUP."
2958 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2960 (defun gnus-summary-setup-buffer (group)
2961 "Initialize summary buffer."
2962 (let ((buffer (gnus-summary-buffer-name group))
2963 (dead-name (concat "*Dead Summary "
2964 (gnus-group-decoded-name group) "*")))
2965 ;; If a dead summary buffer exists, we kill it.
2966 (when (gnus-buffer-live-p dead-name)
2967 (gnus-kill-buffer dead-name))
2968 (if (get-buffer buffer)
2971 (setq gnus-summary-buffer (current-buffer))
2972 (not gnus-newsgroup-prepared))
2973 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2974 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2975 (gnus-summary-mode group)
2977 (gnus-carpal-setup-buffer 'summary))
2978 (unless gnus-single-article-buffer
2979 (make-local-variable 'gnus-article-buffer)
2980 (make-local-variable 'gnus-article-current)
2981 (make-local-variable 'gnus-original-article-buffer))
2982 (setq gnus-newsgroup-name group)
2983 ;; Set any local variables in the group parameters.
2984 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2987 (defun gnus-set-global-variables ()
2988 "Set the global equivalents of the buffer-local variables.
2989 They are set to the latest values they had. These reflect the summary
2990 buffer that was in action when the last article was fetched."
2991 (when (eq major-mode 'gnus-summary-mode)
2992 (setq gnus-summary-buffer (current-buffer))
2993 (let ((name gnus-newsgroup-name)
2994 (marked gnus-newsgroup-marked)
2995 (spam gnus-newsgroup-spam-marked)
2996 (unread gnus-newsgroup-unreads)
2997 (headers gnus-current-headers)
2998 (data gnus-newsgroup-data)
2999 (summary gnus-summary-buffer)
3000 (article-buffer gnus-article-buffer)
3001 (original gnus-original-article-buffer)
3002 (gac gnus-article-current)
3003 (reffed gnus-reffed-article-number)
3004 (score-file gnus-current-score-file)
3005 (default-charset gnus-newsgroup-charset)
3007 (let ((locals gnus-newsgroup-variables))
3009 (if (consp (car locals))
3010 (push (eval (caar locals)) vlist)
3011 (push (eval (car locals)) vlist))
3012 (setq locals (cdr locals)))
3013 (setq vlist (nreverse vlist)))
3015 (set-buffer gnus-group-buffer)
3016 (setq gnus-newsgroup-name name
3017 gnus-newsgroup-marked marked
3018 gnus-newsgroup-spam-marked spam
3019 gnus-newsgroup-unreads unread
3020 gnus-current-headers headers
3021 gnus-newsgroup-data data
3022 gnus-article-current gac
3023 gnus-summary-buffer summary
3024 gnus-article-buffer article-buffer
3025 gnus-original-article-buffer original
3026 gnus-reffed-article-number reffed
3027 gnus-current-score-file score-file
3028 gnus-newsgroup-charset default-charset)
3029 (let ((locals gnus-newsgroup-variables))
3031 (if (consp (car locals))
3032 (set (caar locals) (pop vlist))
3033 (set (car locals) (pop vlist)))
3034 (setq locals (cdr locals))))
3035 ;; The article buffer also has local variables.
3036 (when (gnus-buffer-live-p gnus-article-buffer)
3037 (set-buffer gnus-article-buffer)
3038 (setq gnus-summary-buffer summary))))))
3040 (defun gnus-summary-article-unread-p (article)
3041 "Say whether ARTICLE is unread or not."
3042 (memq article gnus-newsgroup-unreads))
3044 (defun gnus-summary-first-article-p (&optional article)
3045 "Return whether ARTICLE is the first article in the buffer."
3046 (if (not (setq article (or article (gnus-summary-article-number))))
3048 (eq article (caar gnus-newsgroup-data))))
3050 (defun gnus-summary-last-article-p (&optional article)
3051 "Return whether ARTICLE is the last article in the buffer."
3052 (if (not (setq article (or article (gnus-summary-article-number))))
3053 ;; All non-existent numbers are the last article. :-)
3055 (not (cdr (gnus-data-find-list article)))))
3057 (defun gnus-make-thread-indent-array ()
3059 (unless (and gnus-thread-indent-array
3060 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3061 (setq gnus-thread-indent-array (make-vector 201 "")
3062 gnus-thread-indent-array-level gnus-thread-indent-level)
3064 (aset gnus-thread-indent-array n
3065 (make-string (* n gnus-thread-indent-level) ? ))
3068 (defun gnus-update-summary-mark-positions ()
3069 "Compute where the summary marks are to go."
3071 (when (gnus-buffer-exists-p gnus-summary-buffer)
3072 (set-buffer gnus-summary-buffer))
3073 (let ((gnus-replied-mark 129)
3074 (gnus-score-below-mark 130)
3075 (gnus-score-over-mark 130)
3076 (gnus-download-mark 131)
3077 (spec gnus-summary-line-format-spec)
3080 (gnus-set-work-buffer)
3081 (let ((gnus-summary-line-format-spec spec)
3082 (gnus-newsgroup-downloadable '((0 . t))))
3083 (gnus-summary-insert-line
3084 (make-full-mail-header 0 "" "nobody"
3085 "05 Apr 2001 23:33:09 +0400"
3087 0 nil 128 t nil "" nil 1)
3088 (goto-char (point-min))
3089 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3090 (- (point) (point-min) 1)))))
3091 (goto-char (point-min))
3092 (push (cons 'replied (and (search-forward "\201" nil t)
3093 (- (point) (point-min) 1)))
3095 (goto-char (point-min))
3096 (push (cons 'score (and (search-forward "\202" nil t)
3097 (- (point) (point-min) 1)))
3099 (goto-char (point-min))
3100 (push (cons 'download
3101 (and (search-forward "\203" nil t)
3102 (- (point) (point-min) 1)))
3104 (setq gnus-summary-mark-positions pos))))
3106 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3107 "Insert a dummy root in the summary buffer."
3109 (gnus-add-text-properties
3110 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3111 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3113 (defun gnus-summary-extract-address-component (from)
3114 (or (car (funcall gnus-extract-address-components from))
3117 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3118 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3119 default-mime-charset)))
3120 ;; Is it really necessary to do this next part for each summary line?
3121 ;; Luckily, doesn't seem to slow things down much.
3123 (and gnus-ignored-from-addresses
3124 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3125 (let ((extra-headers (mail-header-extra header))
3129 ((setq to (cdr (assq 'To extra-headers)))
3132 (gnus-summary-extract-address-component
3133 (funcall gnus-decode-encoded-word-function to)))))
3134 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3135 (concat "=> " newsgroups)))))
3136 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3138 (defun gnus-summary-insert-line (gnus-tmp-header
3139 gnus-tmp-level gnus-tmp-current
3140 gnus-tmp-unread gnus-tmp-replied
3141 gnus-tmp-expirable gnus-tmp-subject-or-nil
3142 &optional gnus-tmp-dummy gnus-tmp-score
3144 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3145 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3146 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3147 (gnus-tmp-score-char
3148 (if (or (null gnus-summary-default-score)
3149 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3150 gnus-summary-zcore-fuzz))
3152 (if (< gnus-tmp-score gnus-summary-default-score)
3153 gnus-score-below-mark gnus-score-over-mark)))
3154 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3156 (cond (gnus-tmp-process gnus-process-mark)
3157 ((memq gnus-tmp-current gnus-newsgroup-cached)
3159 (gnus-tmp-replied gnus-replied-mark)
3160 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3161 gnus-forwarded-mark)
3162 ((memq gnus-tmp-current gnus-newsgroup-saved)
3164 ((memq gnus-tmp-number gnus-newsgroup-recent)
3166 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3169 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3172 ((string-match "<[^>]+> *$" gnus-tmp-from)
3173 (let ((beg (match-beginning 0)))
3174 (or (and (string-match "^\".+\"" gnus-tmp-from)
3175 (substring gnus-tmp-from 1 (1- (match-end 0))))
3176 (substring gnus-tmp-from 0 beg))))
3177 ((string-match "(.+)" gnus-tmp-from)
3178 (substring gnus-tmp-from
3179 (1+ (match-beginning 0)) (1- (match-end 0))))
3181 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3182 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3183 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3184 (buffer-read-only nil))
3185 (when (string= gnus-tmp-name "")
3186 (setq gnus-tmp-name gnus-tmp-from))
3187 (unless (numberp gnus-tmp-lines)
3188 (setq gnus-tmp-lines -1))
3189 (if (= gnus-tmp-lines -1)
3190 (setq gnus-tmp-lines "?")
3191 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3192 (gnus-put-text-property-excluding-characters-with-faces
3194 (progn (eval gnus-summary-line-format-spec) (point))
3195 'gnus-number gnus-tmp-number)
3196 (when (gnus-visual-p 'summary-highlight 'highlight)
3198 (gnus-run-hooks 'gnus-summary-update-hook)
3201 (defun gnus-summary-update-line (&optional dont-update)
3202 "Update summary line after change."
3203 (when (and gnus-summary-default-score
3204 (not gnus-summary-inhibit-highlight))
3205 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3206 (article (gnus-summary-article-number))
3207 (score (gnus-summary-article-score article)))
3209 (if (and gnus-summary-mark-below
3210 (< (gnus-summary-article-score)
3211 gnus-summary-mark-below))
3212 ;; This article has a low score, so we mark it as read.
3213 (when (memq article gnus-newsgroup-unreads)
3214 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3215 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3216 ;; This article was previously marked as read on account
3217 ;; of a low score, but now it has risen, so we mark it as
3219 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3220 (gnus-summary-update-mark
3221 (if (or (null gnus-summary-default-score)
3222 (<= (abs (- score gnus-summary-default-score))
3223 gnus-summary-zcore-fuzz))
3225 (if (< score gnus-summary-default-score)
3226 gnus-score-below-mark gnus-score-over-mark))
3228 ;; Do visual highlighting.
3229 (when (gnus-visual-p 'summary-highlight 'highlight)
3230 (gnus-run-hooks 'gnus-summary-update-hook)))))
3232 (defvar gnus-tmp-new-adopts nil)
3234 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3235 "Return the number of articles in THREAD.
3236 This may be 0 in some cases -- if none of the articles in
3237 the thread are to be displayed."
3239 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3241 ((not (listp thread))
3243 ((and (consp thread) (cdr thread))
3246 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3249 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3252 (when (and level (zerop level) gnus-tmp-new-adopts)
3255 'gnus-summary-number-of-articles-in-thread
3256 gnus-tmp-new-adopts))))
3258 (if (> number 1) gnus-not-empty-thread-mark
3259 gnus-empty-thread-mark)
3262 (defsubst gnus-summary-line-message-size (head)
3263 "Return pretty-printed version of message size.
3264 This function is intended to be used in
3265 `gnus-summary-line-format-alist', which see."
3266 (let ((c (or (mail-header-chars head) -1)))
3267 (cond ((< c 0) "n/a") ; chars not available
3268 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3269 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3270 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3271 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3274 (defun gnus-summary-set-local-parameters (group)
3275 "Go through the local params of GROUP and set all variable specs in that list."
3276 (let ((params (gnus-group-find-parameter group))
3277 (vars '(quit-config)) ; Ignore quit-config.
3280 (setq elem (car params)
3281 params (cdr params))
3282 (and (consp elem) ; Has to be a cons.
3283 (consp (cdr elem)) ; The cdr has to be a list.
3284 (symbolp (car elem)) ; Has to be a symbol in there.
3285 (not (memq (car elem) vars))
3286 (ignore-errors ; So we set it.
3287 (push (car elem) vars)
3288 (make-local-variable (car elem))
3289 (set (car elem) (eval (nth 1 elem))))))))
3291 (defun gnus-summary-read-group (group &optional show-all no-article
3292 kill-buffer no-display backward
3294 "Start reading news in newsgroup GROUP.
3295 If SHOW-ALL is non-nil, already read articles are also listed.
3296 If NO-ARTICLE is non-nil, no article is selected initially.
3297 If NO-DISPLAY, don't generate a summary buffer."
3301 (let ((gnus-auto-select-next nil))
3302 (or (gnus-summary-read-group-1
3303 group show-all no-article
3304 kill-buffer no-display
3307 select-articles nil)))))
3308 (eq gnus-auto-select-next 'quietly))
3309 (set-buffer gnus-group-buffer)
3310 ;; The entry function called above goes to the next
3311 ;; group automatically, so we go two groups back
3312 ;; if we are searching for the previous group.
3314 (gnus-group-prev-unread-group 2))
3315 (if (not (equal group (gnus-group-group-name)))
3316 (setq group (gnus-group-group-name))
3320 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3321 "Directly jump to the other GROUP from summary buffer.
3322 If SHOW-ALL is non-nil, already read articles are also listed."
3324 (if (eq gnus-summary-buffer (current-buffer))
3325 (list (completing-read
3326 "Group: " gnus-active-hashtb nil t
3327 (when (and gnus-newsgroup-name
3328 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3329 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3330 'gnus-group-history)
3332 (error "%s must be invoked from a gnus summary buffer." this-command)))
3333 (unless (or (zerop (length group))
3334 (and gnus-newsgroup-name
3335 (string-equal gnus-newsgroup-name group)))
3337 (gnus-summary-read-group group show-all
3338 gnus-dont-select-after-jump-to-other-group)))
3340 (defun gnus-summary-read-group-1 (group show-all no-article
3341 kill-buffer no-display
3342 &optional select-articles)
3343 ;; Killed foreign groups can't be entered.
3344 ;; (when (and (not (gnus-group-native-p group))
3345 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3346 ;; (error "Dead non-native groups can't be entered"))
3347 (gnus-message 5 "Retrieving newsgroup: %s..."
3348 (gnus-group-decoded-name group))
3349 (let* ((new-group (gnus-summary-setup-buffer group))
3350 (quit-config (gnus-group-quit-config group))
3351 (did-select (and new-group (gnus-select-newsgroup
3352 group show-all select-articles))))
3354 ;; This summary buffer exists already, so we just select it.
3356 (gnus-set-global-variables)
3358 (gnus-kill-or-deaden-summary kill-buffer))
3359 (gnus-configure-windows 'summary 'force)
3360 (gnus-set-mode-line 'summary)
3361 (gnus-summary-position-point)
3364 ;; We couldn't select this group.
3366 (when (and (eq major-mode 'gnus-summary-mode)
3367 (not (equal (current-buffer) kill-buffer)))
3368 (kill-buffer (current-buffer))
3369 (if (not quit-config)
3371 ;; Update the info -- marks might need to be removed,
3373 (gnus-summary-update-info)
3374 (set-buffer gnus-group-buffer)
3375 (gnus-group-jump-to-group group)
3376 (gnus-group-next-unread-group 1))
3377 (gnus-handle-ephemeral-exit quit-config)))
3378 (let ((grpinfo (gnus-get-info group)))
3379 (if (null (gnus-info-read grpinfo))
3380 (gnus-message 3 "Group %s contains no messages"
3381 (gnus-group-decoded-name group))
3382 (gnus-message 3 "Can't select group")))
3384 ;; The user did a `C-g' while prompting for number of articles,
3385 ;; so we exit this group.
3386 ((eq did-select 'quit)
3387 (and (eq major-mode 'gnus-summary-mode)
3388 (not (equal (current-buffer) kill-buffer))
3389 (kill-buffer (current-buffer)))
3391 (gnus-kill-or-deaden-summary kill-buffer))
3392 (if (not quit-config)
3394 (set-buffer gnus-group-buffer)
3395 (gnus-group-jump-to-group group)
3396 (gnus-group-next-unread-group 1)
3397 (gnus-configure-windows 'group 'force))
3398 (gnus-handle-ephemeral-exit quit-config))
3399 ;; Finally signal the quit.
3401 ;; The group was successfully selected.
3403 (gnus-set-global-variables)
3404 ;; Save the active value in effect when the group was entered.
3405 (setq gnus-newsgroup-active
3407 (gnus-active gnus-newsgroup-name)))
3408 ;; You can change the summary buffer in some way with this hook.
3409 (gnus-run-hooks 'gnus-select-group-hook)
3410 (gnus-update-format-specifications
3411 nil 'summary 'summary-mode 'summary-dummy)
3412 (gnus-update-summary-mark-positions)
3413 ;; Do score processing.
3414 (when gnus-use-scoring
3415 (gnus-possibly-score-headers))
3416 ;; Check whether to fill in the gaps in the threads.
3417 (when gnus-build-sparse-threads
3418 (gnus-build-sparse-threads))
3419 ;; Find the initial limit.
3420 (if gnus-show-threads
3422 (let ((gnus-newsgroup-dormant nil))
3423 (gnus-summary-initial-limit show-all))
3424 (gnus-summary-initial-limit show-all))
3425 ;; When untreaded, all articles are always shown.
3426 (setq gnus-newsgroup-limit
3428 (lambda (header) (mail-header-number header))
3429 gnus-newsgroup-headers)))
3430 ;; Generate the summary buffer.
3432 (gnus-summary-prepare))
3433 (when gnus-use-trees
3434 (gnus-tree-open group)
3435 (setq gnus-summary-highlight-line-function
3436 'gnus-tree-highlight-article))
3437 ;; If the summary buffer is empty, but there are some low-scored
3438 ;; articles or some excluded dormants, we include these in the
3440 (when (and (zerop (buffer-size))
3442 (cond (gnus-newsgroup-dormant
3443 (gnus-summary-limit-include-dormant))
3444 ((and gnus-newsgroup-scored show-all)
3445 (gnus-summary-limit-include-expunged t))))
3446 ;; Function `gnus-apply-kill-file' must be called in this hook.
3447 (gnus-run-hooks 'gnus-apply-kill-hook)
3448 (if (and (zerop (buffer-size))
3451 ;; This newsgroup is empty.
3452 (gnus-summary-catchup-and-exit nil t)
3453 (gnus-message 6 "No unread news")
3455 (gnus-kill-or-deaden-summary kill-buffer))
3456 ;; Return nil from this function.
3458 ;; Hide conversation thread subtrees. We cannot do this in
3459 ;; gnus-summary-prepare-hook since kill processing may not
3460 ;; work with hidden articles.
3461 (gnus-summary-maybe-hide-threads)
3463 (gnus-kill-or-deaden-summary kill-buffer))
3464 (gnus-summary-auto-select-subject)
3465 ;; Show first unread article if requested.
3466 (if (and (not no-article)
3468 gnus-newsgroup-unreads
3469 gnus-auto-select-first)
3471 (gnus-configure-windows 'summary)
3472 (let ((art (gnus-summary-article-number)))
3473 (unless (or (memq art gnus-newsgroup-undownloaded)
3474 (memq art gnus-newsgroup-downloadable))
3475 (gnus-summary-goto-article art))))
3476 ;; Don't select any articles.
3477 (gnus-summary-position-point)
3478 (gnus-configure-windows 'summary 'force)
3479 (gnus-set-mode-line 'summary))
3480 (when (get-buffer-window gnus-group-buffer t)
3481 ;; Gotta use windows, because recenter does weird stuff if
3482 ;; the current buffer ain't the displayed window.
3483 (let ((owin (selected-window)))
3484 (select-window (get-buffer-window gnus-group-buffer t))
3485 (when (gnus-group-goto-group group)
3487 (select-window owin)))
3488 ;; Mark this buffer as "prepared".
3489 (setq gnus-newsgroup-prepared t)
3490 (gnus-run-hooks 'gnus-summary-prepared-hook)
3493 (defun gnus-summary-auto-select-subject ()
3494 "Select the subject line on initial group entry."
3495 (goto-char (point-min))
3497 ((eq gnus-auto-select-subject 'best)
3498 (gnus-summary-best-unread-subject))
3499 ((eq gnus-auto-select-subject 'unread)
3500 (gnus-summary-first-unread-subject))
3501 ((eq gnus-auto-select-subject 'unseen)
3502 (gnus-summary-first-unseen-subject))
3503 ((eq gnus-auto-select-subject 'unseen-or-unread)
3504 (gnus-summary-first-unseen-or-unread-subject))
3505 ((eq gnus-auto-select-subject 'first)
3508 ((gnus-functionp gnus-auto-select-subject)
3509 (funcall gnus-auto-select-subject))))
3511 (defun gnus-summary-prepare ()
3512 "Generate the summary buffer."
3514 (let ((buffer-read-only nil))
3516 (setq gnus-newsgroup-data nil
3517 gnus-newsgroup-data-reverse nil)
3518 (gnus-run-hooks 'gnus-summary-generate-hook)
3519 ;; Generate the buffer, either with threads or without.
3520 (when gnus-newsgroup-headers
3521 (gnus-summary-prepare-threads
3522 (if gnus-show-threads
3523 (gnus-sort-gathered-threads
3524 (funcall gnus-summary-thread-gathering-function
3526 (gnus-cut-threads (gnus-make-threads)))))
3527 ;; Unthreaded display.
3528 (gnus-sort-articles gnus-newsgroup-headers))))
3529 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3530 ;; Call hooks for modifying summary buffer.
3531 (goto-char (point-min))
3532 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3534 (defsubst gnus-general-simplify-subject (subject)
3535 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3538 ;; Truncate the subject.
3539 (gnus-simplify-subject-functions
3540 (gnus-map-function gnus-simplify-subject-functions subject))
3541 ((numberp gnus-summary-gather-subject-limit)
3542 (setq subject (gnus-simplify-subject-re subject))
3543 (if (> (length subject) gnus-summary-gather-subject-limit)
3544 (substring subject 0 gnus-summary-gather-subject-limit)
3546 ;; Fuzzily simplify it.
3547 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3548 (gnus-simplify-subject-fuzzy subject))
3549 ;; Just remove the leading "Re:".
3551 (gnus-simplify-subject-re subject))))
3553 (if (and gnus-summary-gather-exclude-subject
3554 (string-match gnus-summary-gather-exclude-subject subject))
3555 nil ; This article shouldn't be gathered
3558 (defun gnus-summary-simplify-subject-query ()
3559 "Query where the respool algorithm would put this article."
3561 (gnus-summary-select-article)
3563 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3565 (defun gnus-gather-threads-by-subject (threads)
3566 "Gather threads by looking at Subject headers."
3567 (if (not gnus-summary-make-false-root)
3569 (let ((hashtb (gnus-make-hashtable 1024))
3572 subject hthread whole-subject)
3574 (setq subject (gnus-general-simplify-subject
3575 (setq whole-subject (mail-header-subject
3578 (if (setq hthread (gnus-gethash subject hashtb))
3580 ;; We enter a dummy root into the thread, if we
3581 ;; haven't done that already.
3582 (unless (stringp (caar hthread))
3583 (setcar hthread (list whole-subject (car hthread))))
3584 ;; We add this new gathered thread to this gathered
3586 (setcdr (car hthread)
3587 (nconc (cdar hthread) (list (car threads))))
3588 ;; Remove it from the list of threads.
3589 (setcdr prev (cdr threads))
3590 (setq threads prev))
3591 ;; Enter this thread into the hash table.
3592 (gnus-sethash subject threads hashtb)))
3594 (setq threads (cdr threads)))
3597 (defun gnus-gather-threads-by-references (threads)
3598 "Gather threads by looking at References headers."
3599 (let ((idhashtb (gnus-make-hashtable 1024))
3600 (thhashtb (gnus-make-hashtable 1024))
3603 ids references id gthread gid entered ref)
3605 (when (setq references (mail-header-references (caar threads)))
3606 (setq id (mail-header-id (caar threads))
3607 ids (inline (gnus-split-references references))
3609 (while (setq ref (pop ids))
3610 (setq ids (delete ref ids))
3611 (if (not (setq gid (gnus-gethash ref idhashtb)))
3613 (gnus-sethash ref id idhashtb)
3614 (gnus-sethash id threads thhashtb))
3615 (setq gthread (gnus-gethash gid thhashtb))
3617 ;; We enter a dummy root into the thread, if we
3618 ;; haven't done that already.
3619 (unless (stringp (caar gthread))
3620 (setcar gthread (list (mail-header-subject (caar gthread))
3622 ;; We add this new gathered thread to this gathered
3624 (setcdr (car gthread)
3625 (nconc (cdar gthread) (list (car threads)))))
3626 ;; Add it into the thread hash table.
3627 (gnus-sethash id gthread thhashtb)
3629 ;; Remove it from the list of threads.
3630 (setcdr prev (cdr threads))
3631 (setq threads prev))))
3633 (setq threads (cdr threads)))
3636 (defun gnus-sort-gathered-threads (threads)
3637 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3638 (let ((result threads))
3640 (when (stringp (caar threads))
3641 (setcdr (car threads)
3642 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3643 (setq threads (cdr threads)))
3646 (defun gnus-thread-loop-p (root thread)
3647 "Say whether ROOT is in THREAD."
3648 (let ((stack (list thread))
3651 (while (setq thread (pop stack))
3652 (setq th (cdr thread))
3654 (not (eq (caar th) root)))
3657 ;; We have found a loop.
3659 (setcdr thread (delq (car th) (cdr thread)))
3660 (if (boundp (setq ref-dep (intern "none"
3661 gnus-newsgroup-dependencies)))
3662 (setcdr (symbol-value ref-dep)
3663 (nconc (cdr (symbol-value ref-dep))
3665 (set ref-dep (list nil (car th))))
3668 ;; Push all the subthreads onto the stack.
3669 (push (cdr thread) stack)))
3672 (defun gnus-make-threads ()
3673 "Go through the dependency hashtb and find the roots. Return all threads."
3675 (while (catch 'infloop
3678 ;; Deal with self-referencing References loops.
3679 (when (and (car (symbol-value refs))
3686 (car (symbol-value refs)) thread))
3687 (cdr (symbol-value refs)))))))
3690 (unless (car (symbol-value refs))
3691 ;; These threads do not refer back to any other articles,
3692 ;; so they're roots.
3693 (setq threads (append (cdr (symbol-value refs)) threads))))
3694 gnus-newsgroup-dependencies)))
3697 ;; Build the thread tree.
3698 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3699 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3701 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3702 if it was already present.
3704 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3705 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3706 Message-IDs will be renamed to a unique Message-ID before being
3709 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3710 (let* ((id (mail-header-id header))
3711 (id-dep (and id (intern id dependencies)))
3712 parent-id ref ref-dep ref-header replaced)
3713 ;; Enter this `header' in the `dependencies' table.
3717 ;; The first two cases do the normal part: enter a new `header'
3718 ;; in the `dependencies' table.
3719 ((not (boundp id-dep))
3720 (set id-dep (list header)))
3721 ((null (car (symbol-value id-dep)))
3722 (setcar (symbol-value id-dep) header))
3724 ;; From here the `header' was already present in the
3725 ;; `dependencies' table.
3727 ;; Overrides an existing entry;
3728 ;; just set the header part of the entry.
3729 (setcar (symbol-value id-dep) header)
3732 ;; Renames the existing `header' to a unique Message-ID.
3733 ((not gnus-summary-ignore-duplicates)
3734 ;; An article with this Message-ID has already been seen.
3735 ;; We rename the Message-ID.
3736 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3738 (mail-header-set-id header id))
3740 ;; The last case ignores an existing entry, except it adds any
3741 ;; additional Xrefs (in case the two articles came from different
3743 ;; Also sets `header' to `nil' meaning that the `dependencies'
3744 ;; table was *not* modified.
3746 (mail-header-set-xref
3747 (car (symbol-value id-dep))
3748 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3750 (or (mail-header-xref header) "")))
3753 (when (and header (not replaced))
3754 ;; First check that we are not creating a References loop.
3755 (setq parent-id (gnus-parent-id (mail-header-references header)))
3756 (setq ref parent-id)
3758 (setq ref-dep (intern-soft ref dependencies))
3760 (setq ref-header (car (symbol-value ref-dep))))
3761 (if (string= id ref)
3762 ;; Yuk! This is a reference loop. Make the article be a
3765 (mail-header-set-references (car (symbol-value id-dep)) "none")
3767 (setq parent-id nil))
3768 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3769 (setq ref-dep (intern (or parent-id "none") dependencies))
3770 (if (boundp ref-dep)
3771 (setcdr (symbol-value ref-dep)
3772 (nconc (cdr (symbol-value ref-dep))
3773 (list (symbol-value id-dep))))
3774 (set ref-dep (list nil (symbol-value id-dep)))))
3777 (defun gnus-extract-message-id-from-in-reply-to (string)
3778 (if (string-match "<[^>]+>" string)
3779 (substring string (match-beginning 0) (match-end 0))
3782 (defun gnus-build-sparse-threads ()
3783 (let ((headers gnus-newsgroup-headers)
3784 (mail-parse-charset gnus-newsgroup-charset)
3785 (gnus-summary-ignore-duplicates t)
3786 header references generation relations
3787 subject child end new-child date)
3788 ;; First we create an alist of generations/relations, where
3789 ;; generations is how much we trust the relation, and the relation
3791 (gnus-message 7 "Making sparse threads...")
3793 (nnheader-set-temp-buffer " *gnus sparse threads*")
3794 (while (setq header (pop headers))
3795 (when (and (setq references (mail-header-references header))
3796 (not (string= references "")))
3798 (setq child (mail-header-id header)
3799 subject (mail-header-subject header)
3800 date (mail-header-date header)
3802 (while (search-backward ">" nil t)
3803 (setq end (1+ (point)))
3804 (when (search-backward "<" nil t)
3805 (setq new-child (buffer-substring (point) end))
3806 (push (list (incf generation)
3807 child (setq child new-child)
3811 (push (list (1+ generation) child nil subject) relations))
3813 (kill-buffer (current-buffer)))
3814 ;; Sort over trustworthiness.
3817 (when (gnus-dependencies-add-header
3818 (make-full-mail-header-from-decoded-header
3819 gnus-reffed-article-number
3820 (nth 3 relation) "" (or (nth 4 relation) "")
3822 (or (nth 2 relation) "") 0 0 "")
3823 gnus-newsgroup-dependencies nil)
3824 (push gnus-reffed-article-number gnus-newsgroup-limit)
3825 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3826 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3827 gnus-newsgroup-reads)
3828 (decf gnus-reffed-article-number)))
3829 (sort relations 'car-less-than-car))
3830 (gnus-message 7 "Making sparse threads...done")))
3832 (defun gnus-build-old-threads ()
3833 ;; Look at all the articles that refer back to old articles, and
3834 ;; fetch the headers for the articles that aren't there. This will
3835 ;; build complete threads - if the roots haven't been expired by the
3837 (let ((mail-parse-charset gnus-newsgroup-charset)
3841 (when (not (car (symbol-value refs)))
3842 (setq heads (cdr (symbol-value refs)))
3844 (if (memq (mail-header-number (caar heads))
3845 gnus-newsgroup-dormant)
3846 (setq heads (cdr heads))
3847 (setq id (symbol-name refs))
3848 (while (and (setq id (gnus-build-get-header id))
3849 (not (car (gnus-id-to-thread id)))))
3850 (setq heads nil)))))
3851 gnus-newsgroup-dependencies)))
3853 ;; This function has to be called with point after the article number
3854 ;; on the beginning of the line.
3855 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3856 (let ((eol (gnus-point-at-eol))
3857 (buffer (current-buffer))
3858 header references in-reply-to)
3860 ;; overview: [num subject from date id refs chars lines misc]
3863 (narrow-to-region (point) eol)
3868 (make-full-mail-header
3870 (nnheader-nov-field) ; subject
3871 (nnheader-nov-field) ; from
3872 (nnheader-nov-field) ; date
3873 (nnheader-nov-read-message-id) ; id
3874 (nnheader-nov-field) ; refs
3875 (nnheader-nov-read-integer) ; chars
3876 (nnheader-nov-read-integer) ; lines
3878 (if (looking-at "Xref: ")
3879 (goto-char (match-end 0)))
3880 (nnheader-nov-field)) ; Xref
3881 (nnheader-nov-parse-extra)))) ; extra
3885 (when (and (string= references "")
3886 (setq in-reply-to (mail-header-extra header))
3887 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3888 (mail-header-set-references
3889 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3891 (when gnus-alter-header-function
3892 (funcall gnus-alter-header-function header))
3893 (gnus-dependencies-add-header header dependencies force-new)))
3895 (defun gnus-build-get-header (id)
3896 "Look through the buffer of NOV lines and find the header to ID.
3897 Enter this line into the dependencies hash table, and return
3898 the id of the parent article (if any)."
3899 (let ((deps gnus-newsgroup-dependencies)
3903 (set-buffer nntp-server-buffer)
3904 (let ((case-fold-search nil))
3905 (goto-char (point-min))
3906 (while (and (not found)
3907 (search-forward id nil t))
3909 (setq found (looking-at
3910 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3911 (regexp-quote id))))
3912 (or found (beginning-of-line 2)))
3916 (setq header (gnus-nov-parse-line
3917 (read (current-buffer)) deps))
3918 (gnus-parent-id (mail-header-references header))))))
3920 (let ((number (mail-header-number header)))
3921 (push number gnus-newsgroup-limit)
3922 (push header gnus-newsgroup-headers)
3923 (if (memq number gnus-newsgroup-unselected)
3925 (setq gnus-newsgroup-unreads
3926 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3928 (setq gnus-newsgroup-unselected
3929 (delq number gnus-newsgroup-unselected)))
3930 (push number gnus-newsgroup-ancient)))))))
3932 (defun gnus-build-all-threads ()
3933 "Read all the headers."
3934 (let ((gnus-summary-ignore-duplicates t)
3935 (mail-parse-charset gnus-newsgroup-charset)
3936 (dependencies gnus-newsgroup-dependencies)
3939 (set-buffer nntp-server-buffer)
3940 (let ((case-fold-search nil))
3941 (goto-char (point-min))
3944 (setq article (read (current-buffer))
3945 header (gnus-nov-parse-line article dependencies)))
3948 (set-buffer gnus-summary-buffer)
3949 (push header gnus-newsgroup-headers)
3950 (if (memq (setq article (mail-header-number header))
3951 gnus-newsgroup-unselected)
3953 (setq gnus-newsgroup-unreads
3954 (gnus-add-to-sorted-list
3955 gnus-newsgroup-unreads article))
3956 (setq gnus-newsgroup-unselected
3957 (delq article gnus-newsgroup-unselected)))
3958 (push article gnus-newsgroup-ancient)))
3959 (forward-line 1)))))))
3961 (defun gnus-summary-update-article-line (article header)
3962 "Update the line for ARTICLE using HEADERS."
3963 (let* ((id (mail-header-id header))
3964 (thread (gnus-id-to-thread id)))
3966 (error "Article in no thread"))
3967 ;; Update the thread.
3968 (setcar thread header)
3969 (gnus-summary-goto-subject article)
3970 (let* ((datal (gnus-data-find-list article))
3972 (length (when (cdr datal)
3973 (- (gnus-data-pos data)
3974 (gnus-data-pos (cadr datal)))))
3975 (buffer-read-only nil)
3976 (level (gnus-summary-thread-level)))
3978 (gnus-summary-insert-line
3979 header level nil (gnus-article-mark article)
3980 (memq article gnus-newsgroup-replied)
3981 (memq article gnus-newsgroup-expirable)
3982 ;; Only insert the Subject string when it's different
3983 ;; from the previous Subject string.
3988 (mail-header-subject
3991 (gnus-data-find-list
3993 (gnus-data-list t)))))
3994 ;; Error on the side of excessive subjects.
3996 (mail-header-subject header)))
3998 (mail-header-subject header))
3999 nil (cdr (assq article gnus-newsgroup-scored))
4000 (memq article gnus-newsgroup-processable))
4002 (gnus-data-update-list
4003 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4005 (defun gnus-summary-update-article (article &optional iheader)
4006 "Update ARTICLE in the summary buffer."
4007 (set-buffer gnus-summary-buffer)
4008 (let* ((header (gnus-summary-article-header article))
4009 (id (mail-header-id header))
4010 (data (gnus-data-find article))
4011 (thread (gnus-id-to-thread id))
4012 (references (mail-header-references header))
4016 (when (and references
4017 (not (equal "" references)))
4020 (buffer-read-only nil)
4026 (delq thread parent)))
4027 (if (gnus-summary-insert-subject id header)
4028 ;; Set the (possibly) new article number in the data structure.
4029 (gnus-data-set-number data (gnus-id-to-article id))
4033 (defun gnus-rebuild-thread (id &optional line)
4034 "Rebuild the thread containing ID.
4035 If LINE, insert the rebuilt thread starting on line LINE."
4036 (let ((buffer-read-only nil)
4037 old-pos current thread data)
4038 (if (not gnus-show-threads)
4039 (setq thread (list (car (gnus-id-to-thread id))))
4040 ;; Get the thread this article is part of.
4041 (setq thread (gnus-remove-thread id)))
4042 (setq old-pos (gnus-point-at-bol))
4043 (setq current (save-excursion
4044 (and (re-search-backward "[\r\n]" nil t)
4045 (gnus-summary-article-number))))
4046 ;; If this is a gathered thread, we have to go some re-gathering.
4047 (when (stringp (car thread))
4048 (let ((subject (car thread))
4050 (setq thread (cdr thread))
4052 (unless (memq (setq thr (gnus-id-to-thread
4054 (mail-header-id (caar thread)))))
4057 (setq thread (cdr thread)))
4058 ;; We now have all (unique) roots.
4059 (if (= (length roots) 1)
4060 ;; All the loose roots are now one solid root.
4061 (setq thread (car roots))
4062 (setq thread (cons subject (gnus-sort-threads roots))))))
4064 ;; We then insert this thread into the summary buffer.
4066 (goto-char (point-min))
4067 (forward-line (1- line)))
4068 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4069 (if gnus-show-threads
4070 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4071 (gnus-summary-prepare-unthreaded thread))
4072 (setq data (nreverse gnus-newsgroup-data))
4073 (setq threads gnus-newsgroup-threads))
4074 ;; We splice the new data into the data structure.
4075 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4076 ;;!!! then we want to insert at the beginning of the buffer.
4077 ;;!!! That happens to be true with Gnus now, but that may
4078 ;;!!! change in the future. Perhaps.
4079 (gnus-data-enter-list
4080 (if line nil current) data (- (point) old-pos))
4081 (setq gnus-newsgroup-threads
4082 (nconc threads gnus-newsgroup-threads))
4083 (gnus-data-compute-positions))))
4085 (defun gnus-number-to-header (number)
4086 "Return the header for article NUMBER."
4087 (let ((headers gnus-newsgroup-headers))
4089 (not (= number (mail-header-number (car headers)))))
4094 (defun gnus-parent-headers (in-headers &optional generation)
4095 "Return the headers of the GENERATIONeth parent of HEADERS."
4097 (setq generation 1))
4099 (headers in-headers)
4102 (not (zerop generation))
4103 (setq references (mail-header-references headers)))
4104 (setq headers (if (and references
4105 (setq parent (gnus-parent-id references)))
4106 (car (gnus-id-to-thread parent))
4109 (and (not (eq headers in-headers))
4112 (defun gnus-id-to-thread (id)
4113 "Return the (sub-)thread where ID appears."
4114 (gnus-gethash id gnus-newsgroup-dependencies))
4116 (defun gnus-id-to-article (id)
4117 "Return the article number of ID."
4118 (let ((thread (gnus-id-to-thread id)))
4121 (mail-header-number (car thread)))))
4123 (defun gnus-id-to-header (id)
4124 "Return the article headers of ID."
4125 (car (gnus-id-to-thread id)))
4127 (defun gnus-article-displayed-root-p (article)
4128 "Say whether ARTICLE is a root(ish) article."
4129 (let ((level (gnus-summary-thread-level article))
4130 (refs (mail-header-references (gnus-summary-article-header article)))
4136 ((null (gnus-parent-id refs)) t)
4138 (null (setq particle (gnus-id-to-article
4139 (gnus-parent-id refs))))
4140 (null (gnus-summary-thread-level particle)))))))
4142 (defun gnus-root-id (id)
4143 "Return the id of the root of the thread where ID appears."
4145 (while (and id (setq prev (car (gnus-id-to-thread id))))
4147 id (gnus-parent-id (mail-header-references prev))))
4150 (defun gnus-articles-in-thread (thread)
4151 "Return the list of articles in THREAD."
4152 (cons (mail-header-number (car thread))
4153 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4155 (defun gnus-remove-thread (id &optional dont-remove)
4156 "Remove the thread that has ID in it."
4157 (let (headers thread last-id)
4158 ;; First go up in this thread until we find the root.
4159 (setq last-id (gnus-root-id id)
4160 headers (message-flatten-list (gnus-id-to-thread last-id)))
4161 ;; We have now found the real root of this thread. It might have
4162 ;; been gathered into some loose thread, so we have to search
4163 ;; through the threads to find the thread we wanted.
4164 (let ((threads gnus-newsgroup-threads)
4167 (setq sub (car threads))
4168 (if (stringp (car sub))
4169 ;; This is a gathered thread, so we look at the roots
4170 ;; below it to find whether this article is in this
4173 (setq sub (cdr sub))
4175 (when (member (caar sub) headers)
4176 (setq thread (car threads)
4179 (setq sub (cdr sub))))
4180 ;; It's an ordinary thread, so we check it.
4181 (when (eq (car sub) (car headers))
4184 (setq threads (cdr threads)))
4185 ;; If this article is in no thread, then it's a root.
4188 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4189 (setq thread (gnus-id-to-thread last-id)))
4192 thread ; We return this thread.
4194 (if (stringp (car thread))
4196 ;; If we use dummy roots, then we have to remove the
4197 ;; dummy root as well.
4198 (when (eq gnus-summary-make-false-root 'dummy)
4199 ;; We go to the dummy root by going to
4200 ;; the first sub-"thread", and then one line up.
4201 (gnus-summary-goto-article
4202 (mail-header-number (caadr thread)))
4205 (gnus-data-compute-positions))
4206 (setq thread (cdr thread))
4208 (gnus-remove-thread-1 (car thread))
4209 (setq thread (cdr thread))))
4210 (gnus-remove-thread-1 thread))))))))
4212 (defun gnus-remove-thread-1 (thread)
4213 "Remove the thread THREAD recursively."
4214 (let ((number (mail-header-number (pop thread)))
4216 (setq thread (reverse thread))
4218 (gnus-remove-thread-1 (pop thread)))
4219 (when (setq d (gnus-data-find number))
4220 (goto-char (gnus-data-pos d))
4221 (gnus-summary-show-thread)
4224 (- (gnus-point-at-bol)
4226 (1+ (gnus-point-at-eol))
4227 (gnus-delete-line)))))))
4229 (defun gnus-sort-threads-1 (threads func)
4230 (sort (mapcar (lambda (thread)
4233 (gnus-sort-threads-1 (cdr thread) func))))
4236 (defun gnus-sort-threads (threads)
4238 (if (not gnus-thread-sort-functions)
4240 (gnus-message 8 "Sorting threads...")
4242 (gnus-sort-threads-1
4244 (gnus-make-sort-function gnus-thread-sort-functions))
4245 (gnus-message 8 "Sorting threads...done"))))
4247 (defun gnus-sort-articles (articles)
4249 (when gnus-article-sort-functions
4250 (gnus-message 7 "Sorting articles...")
4252 (setq gnus-newsgroup-headers
4253 (sort articles (gnus-make-sort-function
4254 gnus-article-sort-functions)))
4255 (gnus-message 7 "Sorting articles...done"))))
4257 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4258 (defmacro gnus-thread-header (thread)
4259 "Return header of first article in THREAD.
4260 Note that THREAD must never, ever be anything else than a variable -
4261 using some other form will lead to serious barfage."
4262 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4263 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4264 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4267 (defsubst gnus-article-sort-by-number (h1 h2)
4268 "Sort articles by article number."
4269 (< (mail-header-number h1)
4270 (mail-header-number h2)))
4272 (defun gnus-thread-sort-by-number (h1 h2)
4273 "Sort threads by root article number."
4274 (gnus-article-sort-by-number
4275 (gnus-thread-header h1) (gnus-thread-header h2)))
4277 (defsubst gnus-article-sort-by-random (h1 h2)
4278 "Sort articles by article number."
4281 (defun gnus-thread-sort-by-random (h1 h2)
4282 "Sort threads by root article number."
4283 (gnus-article-sort-by-random
4284 (gnus-thread-header h1) (gnus-thread-header h2)))
4286 (defsubst gnus-article-sort-by-lines (h1 h2)
4287 "Sort articles by article Lines header."
4288 (< (mail-header-lines h1)
4289 (mail-header-lines h2)))
4291 (defun gnus-thread-sort-by-lines (h1 h2)
4292 "Sort threads by root article Lines header."
4293 (gnus-article-sort-by-lines
4294 (gnus-thread-header h1) (gnus-thread-header h2)))
4296 (defsubst gnus-article-sort-by-chars (h1 h2)
4297 "Sort articles by octet length."
4298 (< (mail-header-chars h1)
4299 (mail-header-chars h2)))
4301 (defun gnus-thread-sort-by-chars (h1 h2)
4302 "Sort threads by root article octet length."
4303 (gnus-article-sort-by-chars
4304 (gnus-thread-header h1) (gnus-thread-header h2)))
4306 (defsubst gnus-article-sort-by-author (h1 h2)
4307 "Sort articles by root author."
4309 (let ((addr (car (mime-entity-read-field h1 'From))))
4310 (or (std11-full-name-string addr)
4311 (std11-address-string addr)
4313 (let ((addr (car (mime-entity-read-field h2 'From))))
4314 (or (std11-full-name-string addr)
4315 (std11-address-string addr)
4319 (defun gnus-thread-sort-by-author (h1 h2)
4320 "Sort threads by root author."
4321 (gnus-article-sort-by-author
4322 (gnus-thread-header h1) (gnus-thread-header h2)))
4324 (defsubst gnus-article-sort-by-subject (h1 h2)
4325 "Sort articles by root subject."
4327 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4328 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4330 (defun gnus-thread-sort-by-subject (h1 h2)
4331 "Sort threads by root subject."
4332 (gnus-article-sort-by-subject
4333 (gnus-thread-header h1) (gnus-thread-header h2)))
4335 (defsubst gnus-article-sort-by-date (h1 h2)
4336 "Sort articles by root article date."
4338 (gnus-date-get-time (mail-header-date h1))
4339 (gnus-date-get-time (mail-header-date h2))))
4341 (defun gnus-thread-sort-by-date (h1 h2)
4342 "Sort threads by root article date."
4343 (gnus-article-sort-by-date
4344 (gnus-thread-header h1) (gnus-thread-header h2)))
4346 (defsubst gnus-article-sort-by-score (h1 h2)
4347 "Sort articles by root article score.
4348 Unscored articles will be counted as having a score of zero."
4349 (> (or (cdr (assq (mail-header-number h1)
4350 gnus-newsgroup-scored))
4351 gnus-summary-default-score 0)
4352 (or (cdr (assq (mail-header-number h2)
4353 gnus-newsgroup-scored))
4354 gnus-summary-default-score 0)))
4356 (defun gnus-thread-sort-by-score (h1 h2)
4357 "Sort threads by root article score."
4358 (gnus-article-sort-by-score
4359 (gnus-thread-header h1) (gnus-thread-header h2)))
4361 (defun gnus-thread-sort-by-total-score (h1 h2)
4362 "Sort threads by the sum of all scores in the thread.
4363 Unscored articles will be counted as having a score of zero."
4364 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4366 (defun gnus-thread-total-score (thread)
4367 ;; This function find the total score of THREAD.
4372 (if (stringp (car thread))
4373 (apply gnus-thread-score-function 0
4374 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4375 (gnus-thread-total-score-1 thread)))
4377 (gnus-thread-total-score-1 (list thread)))))
4379 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4380 "Sort threads such that the thread with the most recently arrived article comes first."
4381 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4383 (defun gnus-thread-highest-number (thread)
4384 "Return the highest article number in THREAD."
4385 (apply 'max (mapcar (lambda (header)
4386 (mail-header-number header))
4387 (message-flatten-list thread))))
4389 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4390 "Sort threads such that the thread with the most recently dated article comes first."
4391 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4393 (defun gnus-thread-latest-date (thread)
4394 "Return the highest article date in THREAD."
4395 (let ((previous-time 0))
4400 (mail-header-parse-date
4402 (mail-header-date header)
4403 (error previous-time))))))
4405 (message-flatten-list thread)
4407 (< (mail-header-number h1)
4408 (mail-header-number h2))))))))
4410 (defun gnus-thread-total-score-1 (root)
4411 ;; This function find the total score of the thread below ROOT.
4412 (setq root (car root))
4413 (apply gnus-thread-score-function
4415 (mapcar 'gnus-thread-total-score
4416 (cdr (gnus-id-to-thread (mail-header-id root))))
4417 (when (> (mail-header-number root) 0)
4418 (list (or (cdr (assq (mail-header-number root)
4419 gnus-newsgroup-scored))
4420 gnus-summary-default-score 0))))
4421 (list gnus-summary-default-score)
4424 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4425 (defvar gnus-tmp-prev-subject nil)
4426 (defvar gnus-tmp-false-parent nil)
4427 (defvar gnus-tmp-root-expunged nil)
4428 (defvar gnus-tmp-dummy-line nil)
4430 (eval-when-compile (defvar gnus-tmp-header))
4431 (defun gnus-extra-header (type &optional header)
4432 "Return the extra header of TYPE."
4433 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4436 (defvar gnus-tmp-thread-tree-header-string "")
4438 (defcustom gnus-sum-thread-tree-root "> "
4439 "With %B spec, used for the root of a thread.
4440 If nil, use subject instead."
4442 :group 'gnus-thread)
4443 (defcustom gnus-sum-thread-tree-single-indent ""
4444 "With %B spec, used for a thread with just one message.
4445 If nil, use subject instead."
4447 :group 'gnus-thread)
4448 (defcustom gnus-sum-thread-tree-vertical "| "
4449 "With %B spec, used for drawing a vertical line."
4451 :group 'gnus-thread)
4452 (defcustom gnus-sum-thread-tree-indent " "
4453 "With %B spec, used for indenting."
4455 :group 'gnus-thread)
4456 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4457 "With %B spec, used for a leaf with brothers."
4459 :group 'gnus-thread)
4460 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4461 "With %B spec, used for a leaf without brothers."
4463 :group 'gnus-thread)
4465 (defun gnus-summary-prepare-threads (threads)
4466 "Prepare summary buffer from THREADS and indentation LEVEL.
4467 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4468 or a straight list of headers."
4469 (gnus-message 7 "Generating summary...")
4471 (setq gnus-newsgroup-threads threads)
4474 (let ((gnus-tmp-level 0)
4475 (default-score (or gnus-summary-default-score 0))
4476 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4477 thread number subject stack state gnus-tmp-gathered beg-match
4478 new-roots gnus-tmp-new-adopts thread-end simp-subject
4479 gnus-tmp-header gnus-tmp-unread
4480 gnus-tmp-replied gnus-tmp-subject-or-nil
4481 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4482 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4483 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4486 (setq gnus-tmp-prev-subject nil)
4488 (if (vectorp (car threads))
4489 ;; If this is a straight (sic) list of headers, then a
4490 ;; threaded summary display isn't required, so we just create
4491 ;; an unthreaded one.
4492 (gnus-summary-prepare-unthreaded threads)
4494 ;; Do the threaded display.
4496 (while (or threads stack gnus-tmp-new-adopts new-roots)
4498 (if (and (= gnus-tmp-level 0)
4501 (not gnus-tmp-false-parent)
4502 (or gnus-tmp-new-adopts new-roots))
4503 (if gnus-tmp-new-adopts
4504 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4505 thread (list (car gnus-tmp-new-adopts))
4506 gnus-tmp-header (caar thread)
4507 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4509 (setq thread (list (car new-roots))
4510 gnus-tmp-header (caar thread)
4511 new-roots (cdr new-roots))))
4514 ;; If there are some threads, we do them before the
4515 ;; threads on the stack.
4516 (setq thread threads
4517 gnus-tmp-header (caar thread))
4518 ;; There were no current threads, so we pop something off
4520 (setq state (car stack)
4521 gnus-tmp-level (car state)
4522 tree-stack (cadr state)
4523 thread (caddr state)
4525 gnus-tmp-header (caar thread))))
4527 (setq gnus-tmp-false-parent nil)
4528 (setq gnus-tmp-root-expunged nil)
4529 (setq thread-end nil)
4531 (if (stringp gnus-tmp-header)
4532 ;; The header is a dummy root.
4534 ((eq gnus-summary-make-false-root 'adopt)
4535 ;; We let the first article adopt the rest.
4536 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4538 (setq gnus-tmp-gathered
4540 (lambda (h) (mail-header-number (car h)))
4543 (setq thread (cons (list (caar thread)
4546 (setq gnus-tmp-level -1
4547 gnus-tmp-false-parent t))
4548 ((eq gnus-summary-make-false-root 'empty)
4549 ;; We print adopted articles with empty subject fields.
4550 (setq gnus-tmp-gathered
4552 (lambda (h) (mail-header-number (car h)))
4555 (setq gnus-tmp-level -1))
4556 ((eq gnus-summary-make-false-root 'dummy)
4557 ;; We remember that we probably want to output a dummy
4559 (setq gnus-tmp-dummy-line gnus-tmp-header)
4560 (setq gnus-tmp-prev-subject gnus-tmp-header))
4562 ;; We do not make a root for the gathered
4563 ;; sub-threads at all.
4564 (setq gnus-tmp-level -1)))
4566 (setq number (mail-header-number gnus-tmp-header)
4567 subject (mail-header-subject gnus-tmp-header)
4568 simp-subject (gnus-simplify-subject-fully subject))
4571 ;; If the thread has changed subject, we might want to make
4572 ;; this subthread into a root.
4573 ((and (null gnus-thread-ignore-subject)
4574 (not (zerop gnus-tmp-level))
4575 gnus-tmp-prev-subject
4576 (not (string= gnus-tmp-prev-subject simp-subject)))
4577 (setq new-roots (nconc new-roots (list (car thread)))
4579 gnus-tmp-header nil))
4580 ;; If the article lies outside the current limit,
4581 ;; then we do not display it.
4582 ((not (memq number gnus-newsgroup-limit))
4583 (setq gnus-tmp-gathered
4585 (lambda (h) (mail-header-number (car h)))
4588 (setq gnus-tmp-new-adopts (if (cdar thread)
4589 (append gnus-tmp-new-adopts
4591 gnus-tmp-new-adopts)
4593 gnus-tmp-header nil)
4594 (when (zerop gnus-tmp-level)
4595 (setq gnus-tmp-root-expunged t)))
4596 ;; Perhaps this article is to be marked as read?
4597 ((and gnus-summary-mark-below
4598 (< (or (cdr (assq number gnus-newsgroup-scored))
4600 gnus-summary-mark-below)
4601 ;; Don't touch sparse articles.
4602 (not (gnus-summary-article-sparse-p number))
4603 (not (gnus-summary-article-ancient-p number)))
4604 (setq gnus-newsgroup-unreads
4605 (delq number gnus-newsgroup-unreads))
4606 (if gnus-newsgroup-auto-expire
4607 (setq gnus-newsgroup-expirable
4608 (gnus-add-to-sorted-list
4609 gnus-newsgroup-expirable number))
4610 (push (cons number gnus-low-score-mark)
4611 gnus-newsgroup-reads))))
4613 (when gnus-tmp-header
4614 ;; We may have an old dummy line to output before this
4616 (when (and gnus-tmp-dummy-line
4619 (mail-header-subject gnus-tmp-header)))
4620 (gnus-summary-insert-dummy-line
4621 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4622 (setq gnus-tmp-dummy-line nil))
4624 ;; Compute the mark.
4625 (setq gnus-tmp-unread (gnus-article-mark number))
4627 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4628 gnus-tmp-header gnus-tmp-level)
4629 gnus-newsgroup-data)
4631 ;; Actually insert the line.
4633 gnus-tmp-subject-or-nil
4635 ((and gnus-thread-ignore-subject
4636 gnus-tmp-prev-subject
4637 (not (string= gnus-tmp-prev-subject simp-subject)))
4639 ((zerop gnus-tmp-level)
4640 (if (and (eq gnus-summary-make-false-root 'empty)
4641 (memq number gnus-tmp-gathered)
4642 gnus-tmp-prev-subject
4643 (string= gnus-tmp-prev-subject simp-subject))
4644 gnus-summary-same-subject
4646 (t gnus-summary-same-subject)))
4647 (if (and (eq gnus-summary-make-false-root 'adopt)
4648 (= gnus-tmp-level 1)
4649 (memq number gnus-tmp-gathered))
4650 (setq gnus-tmp-opening-bracket ?\<
4651 gnus-tmp-closing-bracket ?\>)
4652 (setq gnus-tmp-opening-bracket ?\[
4653 gnus-tmp-closing-bracket ?\]))
4655 gnus-tmp-indentation
4656 (aref gnus-thread-indent-array gnus-tmp-level)
4657 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4658 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4659 gnus-summary-default-score 0)
4661 (if (or (null gnus-summary-default-score)
4662 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4663 gnus-summary-zcore-fuzz))
4665 (if (< gnus-tmp-score gnus-summary-default-score)
4666 gnus-score-below-mark gnus-score-over-mark))
4668 (cond ((memq number gnus-newsgroup-processable)
4670 ((memq number gnus-newsgroup-cached)
4672 ((memq number gnus-newsgroup-replied)
4674 ((memq number gnus-newsgroup-forwarded)
4675 gnus-forwarded-mark)
4676 ((memq number gnus-newsgroup-saved)
4678 ((memq number gnus-newsgroup-recent)
4680 ((memq number gnus-newsgroup-unseen)
4683 gnus-tmp-from (mail-header-from gnus-tmp-header)
4686 ((string-match "<[^>]+> *$" gnus-tmp-from)
4687 (setq beg-match (match-beginning 0))
4688 (or (and (string-match "^\".+\"" gnus-tmp-from)
4689 (substring gnus-tmp-from 1 (1- (match-end 0))))
4690 (substring gnus-tmp-from 0 beg-match)))
4691 ((string-match "(.+)" gnus-tmp-from)
4692 (substring gnus-tmp-from
4693 (1+ (match-beginning 0)) (1- (match-end 0))))
4695 gnus-tmp-thread-tree-header-string
4697 ((not gnus-show-threads) "")
4698 ((zerop gnus-tmp-level)
4700 (or gnus-sum-thread-tree-root subject)
4701 (or gnus-sum-thread-tree-single-indent subject)))
4703 (concat (apply 'concat
4704 (mapcar (lambda (item)
4706 gnus-sum-thread-tree-vertical
4707 gnus-sum-thread-tree-indent))
4708 (cdr (reverse tree-stack))))
4710 gnus-sum-thread-tree-leaf-with-other
4711 gnus-sum-thread-tree-single-leaf)))))
4712 (when (string= gnus-tmp-name "")
4713 (setq gnus-tmp-name gnus-tmp-from))
4714 (unless (numberp gnus-tmp-lines)
4715 (setq gnus-tmp-lines -1))
4716 (if (= gnus-tmp-lines -1)
4717 (setq gnus-tmp-lines "?")
4718 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4719 (gnus-put-text-property
4721 (progn (eval gnus-summary-line-format-spec) (point))
4722 'gnus-number number)
4725 (gnus-run-hooks 'gnus-summary-update-hook)
4728 (setq gnus-tmp-prev-subject simp-subject)))
4730 (when (nth 1 thread)
4731 (push (list (max 0 gnus-tmp-level)
4732 (copy-list tree-stack)
4735 (push (if (nth 1 thread) 1 0) tree-stack)
4736 (incf gnus-tmp-level)
4737 (setq threads (if thread-end nil (cdar thread)))
4739 (setq gnus-tmp-level 0)))))
4740 (gnus-message 7 "Generating summary...done"))
4742 (defun gnus-summary-prepare-unthreaded (headers)
4743 "Generate an unthreaded summary buffer based on HEADERS."
4744 (let (header number mark)
4749 ;; We may have to root out some bad articles...
4750 (when (memq (setq number (mail-header-number
4751 (setq header (pop headers))))
4752 gnus-newsgroup-limit)
4753 ;; Mark article as read when it has a low score.
4754 (when (and gnus-summary-mark-below
4755 (< (or (cdr (assq number gnus-newsgroup-scored))
4756 gnus-summary-default-score 0)
4757 gnus-summary-mark-below)
4758 (not (gnus-summary-article-ancient-p number)))
4759 (setq gnus-newsgroup-unreads
4760 (delq number gnus-newsgroup-unreads))
4761 (if gnus-newsgroup-auto-expire
4762 (push number gnus-newsgroup-expirable)
4763 (push (cons number gnus-low-score-mark)
4764 gnus-newsgroup-reads)))
4766 (setq mark (gnus-article-mark number))
4767 (push (gnus-data-make number mark (1+ (point)) header 0)
4768 gnus-newsgroup-data)
4769 (gnus-summary-insert-line
4771 mark (memq number gnus-newsgroup-replied)
4772 (memq number gnus-newsgroup-expirable)
4773 (mail-header-subject header) nil
4774 (cdr (assq number gnus-newsgroup-scored))
4775 (memq number gnus-newsgroup-processable))))))
4777 (defun gnus-summary-remove-list-identifiers ()
4778 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4779 (let ((regexp (if (consp gnus-list-identifiers)
4780 (mapconcat 'identity gnus-list-identifiers " *\\|")
4781 gnus-list-identifiers))
4784 (dolist (header gnus-newsgroup-headers)
4785 (setq subject (mail-header-subject header)
4787 (while (string-match
4788 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4791 (concat (substring subject 0 (match-beginning 2))
4792 (substring subject (match-end 0)))
4796 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4798 (concat (substring subject 0 (match-beginning 1))
4799 (substring subject (match-end 1)))))
4801 (mail-header-set-subject header subject))))))
4803 (defun gnus-fetch-headers (articles)
4804 "Fetch headers of ARTICLES."
4805 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4806 (gnus-message 5 "Fetching headers for %s..." name)
4809 (setq gnus-headers-retrieved-by
4810 (gnus-retrieve-headers
4811 articles gnus-newsgroup-name
4812 ;; We might want to fetch old headers, but
4813 ;; not if there is only 1 article.
4815 (not (eq gnus-fetch-old-headers 'some))
4816 (not (numberp gnus-fetch-old-headers)))
4817 (> (length articles) 1))
4818 gnus-fetch-old-headers))))
4819 (gnus-get-newsgroup-headers-xover
4820 articles nil nil gnus-newsgroup-name t)
4821 (gnus-get-newsgroup-headers))
4822 (gnus-message 5 "Fetching headers for %s...done" name))))
4824 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4825 "Select newsgroup GROUP.
4826 If READ-ALL is non-nil, all articles in the group are selected.
4827 If SELECT-ARTICLES, only select those articles from GROUP."
4828 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4829 ;;!!! Dirty hack; should be removed.
4830 (gnus-summary-ignore-duplicates
4831 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4833 gnus-summary-ignore-duplicates))
4834 (info (nth 2 entry))
4835 articles fetched-articles cached)
4837 (unless (gnus-check-server
4838 (set (make-local-variable 'gnus-current-select-method)
4839 (gnus-find-method-for-group group)))
4840 (error "Couldn't open server"))
4842 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4843 (gnus-activate-group group) ; Or we can activate it...
4844 (progn ; Or we bug out.
4845 (when (equal major-mode 'gnus-summary-mode)
4846 (kill-buffer (current-buffer)))
4847 (error "Couldn't activate group %s: %s"
4848 group (gnus-status-message group))))
4850 (unless (gnus-request-group group t)
4851 (when (equal major-mode 'gnus-summary-mode)
4852 (kill-buffer (current-buffer)))
4853 (error "Couldn't request group %s: %s"
4854 group (gnus-status-message group)))
4856 (setq gnus-newsgroup-name group
4857 gnus-newsgroup-unselected nil
4858 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4860 (let ((display (gnus-group-find-parameter group 'display)))
4861 (setq gnus-newsgroup-display
4863 ((not (zerop (or (car-safe read-all) 0)))
4864 ;; The user entered the group with C-u SPC/RET, let's show
4870 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4872 ;; The following is probably the "correct" solution, but
4873 ;; it makes Gnus fetch all headers and then limit the
4874 ;; articles (which is slow), so instead we hack the
4875 ;; select-articles parameter instead. -- Simon Josefsson
4878 ;; (gnus-byte-compile
4879 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4881 (setq select-articles
4882 (gnus-uncompress-range
4883 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4887 (cdr (gnus-active group)))))
4892 (gnus-summary-setup-default-charset)
4894 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4895 (when (gnus-virtual-group-p group)
4896 (setq cached gnus-newsgroup-cached))
4898 (setq gnus-newsgroup-unreads
4899 (gnus-sorted-ndifference
4900 (gnus-sorted-ndifference gnus-newsgroup-unreads
4901 gnus-newsgroup-marked)
4902 gnus-newsgroup-dormant))
4904 (setq gnus-newsgroup-processable nil)
4906 (gnus-update-read-articles group gnus-newsgroup-unreads)
4908 ;; Adjust and set lists of article marks.
4910 (gnus-adjust-marked-articles info))
4912 (if (setq articles select-articles)
4913 (setq gnus-newsgroup-unselected
4914 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4915 (setq articles (gnus-articles-to-read group read-all)))
4919 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4921 ((eq articles 0) nil)
4923 ;; Init the dependencies hash table.
4924 (setq gnus-newsgroup-dependencies
4925 (gnus-make-hashtable (length articles)))
4926 (gnus-set-global-variables)
4927 ;; Retrieve the headers and read them in.
4928 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4930 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4932 (setq gnus-newsgroup-cached cached))
4934 ;; Suppress duplicates?
4935 (when gnus-suppress-duplicates
4936 (gnus-dup-suppress-articles))
4938 ;; Set the initial limit.
4939 (setq gnus-newsgroup-limit (copy-sequence articles))
4940 ;; Remove canceled articles from the list of unread articles.
4941 (setq fetched-articles
4942 (mapcar (lambda (headers) (mail-header-number headers))
4943 gnus-newsgroup-headers))
4944 (setq gnus-newsgroup-articles fetched-articles)
4945 (setq gnus-newsgroup-unreads
4946 (gnus-sorted-nintersection
4947 gnus-newsgroup-unreads fetched-articles))
4948 (gnus-compute-unseen-list)
4950 ;; Removed marked articles that do not exist.
4951 (gnus-update-missing-marks
4952 (gnus-sorted-difference articles fetched-articles))
4953 ;; We might want to build some more threads first.
4954 (when (and gnus-fetch-old-headers
4955 (eq gnus-headers-retrieved-by 'nov))
4956 (if (eq gnus-fetch-old-headers 'invisible)
4957 (gnus-build-all-threads)
4958 (gnus-build-old-threads)))
4959 ;; Let the Gnus agent mark articles as read.
4961 (gnus-agent-get-undownloaded-list))
4962 ;; Remove list identifiers from subject
4963 (when gnus-list-identifiers
4964 (gnus-summary-remove-list-identifiers))
4965 ;; Check whether auto-expire is to be done in this group.
4966 (setq gnus-newsgroup-auto-expire
4967 (gnus-group-auto-expirable-p group))
4968 ;; Set up the article buffer now, if necessary.
4969 (unless gnus-single-article-buffer
4970 (gnus-article-setup-buffer))
4971 ;; First and last article in this newsgroup.
4972 (when gnus-newsgroup-headers
4973 (setq gnus-newsgroup-begin
4974 (mail-header-number (car gnus-newsgroup-headers))
4977 (gnus-last-element gnus-newsgroup-headers))))
4978 ;; GROUP is successfully selected.
4979 (or gnus-newsgroup-headers t)))))
4981 (defun gnus-compute-unseen-list ()
4982 ;; The `seen' marks are treated specially.
4983 (if (not gnus-newsgroup-seen)
4984 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
4985 (setq gnus-newsgroup-unseen
4986 (gnus-inverse-list-range-intersection
4987 gnus-newsgroup-articles gnus-newsgroup-seen))))
4989 (defun gnus-summary-display-make-predicate (display)
4990 (require 'gnus-agent)
4991 (when (= (length display) 1)
4992 (setq display (car display)))
4993 (unless gnus-summary-display-cache
4994 (dolist (elem (append '((unread . unread)
4997 gnus-article-mark-lists))
4998 (push (cons (cdr elem)
5000 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5001 gnus-summary-display-cache)))
5002 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5003 (gnus-category-predicate-cache gnus-summary-display-cache))
5004 (gnus-get-predicate display)))
5006 ;; Uses the dynamically bound `number' variable.
5008 (defun gnus-article-marked-p (type &optional article)
5009 (let ((article (or article number)))
5012 (memq article gnus-newsgroup-marked))
5014 (memq article gnus-newsgroup-spam-marked))
5016 (memq article gnus-newsgroup-unsendable))
5017 ((eq type 'undownload)
5018 (memq article gnus-newsgroup-undownloaded))
5019 ((eq type 'download)
5020 (memq article gnus-newsgroup-downloadable))
5022 (memq article gnus-newsgroup-unreads))
5024 (memq article gnus-newsgroup-reads))
5026 (memq article gnus-newsgroup-dormant) )
5028 (memq article gnus-newsgroup-expirable))
5030 (memq article gnus-newsgroup-replied))
5032 (memq article gnus-newsgroup-killed))
5033 ((eq type 'bookmark)
5034 (assq article gnus-newsgroup-bookmarks))
5036 (assq article gnus-newsgroup-scored))
5038 (memq article gnus-newsgroup-saved))
5040 (memq article gnus-newsgroup-cached))
5042 (memq article gnus-newsgroup-forwarded))
5044 (not (memq article gnus-newsgroup-unseen)))
5046 (memq article gnus-newsgroup-recent))
5049 (defun gnus-articles-to-read (group &optional read-all)
5050 "Find out what articles the user wants to read."
5052 ;; Select all articles if `read-all' is non-nil, or if there
5053 ;; are no unread articles.
5055 (and (zerop (length gnus-newsgroup-marked))
5056 (zerop (length gnus-newsgroup-unreads)))
5057 ;; Fetch all if the predicate is non-nil.
5058 gnus-newsgroup-display)
5059 ;; We want to select the headers for all the articles in
5060 ;; the group, so we select either all the active
5061 ;; articles in the group, or (if that's nil), the
5062 ;; articles in the cache.
5064 (gnus-uncompress-range (gnus-active group))
5065 (gnus-cache-articles-in-group group))
5066 ;; Select only the "normal" subset of articles.
5068 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5069 gnus-newsgroup-unreads)))
5070 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5071 (scored (length scored-list))
5072 (number (length articles))
5073 (marked (+ (length gnus-newsgroup-marked)
5074 (length gnus-newsgroup-dormant)))
5079 ((numberp gnus-newsgroup-display)
5080 gnus-newsgroup-display)
5084 ((and (or (<= scored marked) (= scored number))
5085 (numberp gnus-large-newsgroup)
5086 (> number gnus-large-newsgroup))
5087 (let* ((cursor-in-echo-area nil)
5088 (initial (gnus-parameter-large-newsgroup-initial
5089 gnus-newsgroup-name))
5093 "How many articles from %s (%s %d): "
5095 (gnus-group-decoded-name gnus-newsgroup-name)
5097 (if initial "max" "default")
5100 (cons (number-to-string initial)
5102 (if (string-match "^[ \t]*$" input) number input)))
5103 ((and (> scored marked) (< scored number)
5104 (> (- scored number) 20))
5107 (format "%s %s (%d scored, %d total): "
5108 "How many articles from"
5109 (gnus-group-decoded-name group)
5111 (if (string-match "^[ \t]*$" input)
5115 (message "Quit getting the articles to read")
5117 (setq select (if (stringp select) (string-to-number select) select))
5118 (if (or (null select) (zerop select))
5120 (if (and (not (zerop scored)) (<= (abs select) scored))
5122 (setq articles (sort scored-list '<))
5123 (setq number (length articles)))
5124 (setq articles (copy-sequence articles)))
5126 (when (< (abs select) number)
5128 ;; Select the N oldest articles.
5129 (setcdr (nthcdr (1- (abs select)) articles) nil)
5130 ;; Select the N most recent articles.
5131 (setq articles (nthcdr (- number select) articles))))
5132 (setq gnus-newsgroup-unselected
5133 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5134 (when gnus-alter-articles-to-read-function
5135 (setq gnus-newsgroup-unreads
5137 (funcall gnus-alter-articles-to-read-function
5138 gnus-newsgroup-name gnus-newsgroup-unreads)
5142 (defun gnus-killed-articles (killed articles)
5145 (when (inline (gnus-member-of-range (car articles) killed))
5146 (push (car articles) out))
5147 (setq articles (cdr articles)))
5150 (defun gnus-uncompress-marks (marks)
5151 "Uncompress the mark ranges in MARKS."
5152 (let ((uncompressed '(score bookmark))
5155 (if (memq (caar marks) uncompressed)
5156 (push (car marks) out)
5157 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5158 (setq marks (cdr marks)))
5161 (defun gnus-article-mark-to-type (mark)
5162 "Return the type of MARK."
5163 (or (cadr (assq mark gnus-article-special-mark-lists))
5166 (defun gnus-article-unpropagatable-p (mark)
5167 "Return whether MARK should be propagated to backend."
5168 (memq mark gnus-article-unpropagated-mark-lists))
5170 (defun gnus-adjust-marked-articles (info)
5171 "Set all article lists and remove all marks that are no longer valid."
5172 (let* ((marked-lists (gnus-info-marks info))
5173 (active (gnus-active (gnus-info-group info)))
5176 (types gnus-article-mark-lists)
5177 marks var articles article mark mark-type)
5179 (dolist (marks marked-lists)
5180 (setq mark (car marks)
5181 mark-type (gnus-article-mark-to-type mark)
5182 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5184 ;; We set the variable according to the type of the marks list,
5185 ;; and then adjust the marks to a subset of the active articles.
5187 ;; Adjust "simple" lists.
5188 ((eq mark-type 'list)
5189 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5190 (when (memq mark '(tick dormant expire reply save))
5192 (when (or (< (setq article (pop articles)) min) (> article max))
5193 (set var (delq article (symbol-value var)))))))
5195 ((eq mark-type 'tuple)
5196 (set var (setq articles (cdr marks)))
5197 (when (not (listp (cdr (symbol-value var))))
5198 (set var (list (symbol-value var))))
5199 (when (not (listp (cdr articles)))
5200 (setq articles (list articles)))
5202 (when (or (not (consp (setq article (pop articles))))
5203 (< (car article) min)
5204 (> (car article) max))
5205 (set var (delq article (symbol-value var))))))
5206 ;; Adjust ranges (sloppily).
5207 ((eq mark-type 'range)
5210 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5211 ;; It should be (seen (NUM1 . NUM2)).
5212 (when (numberp (cddr marks))
5213 (setcdr marks (list (cdr marks))))
5214 (setq articles (cdr marks))
5215 (while (and articles
5216 (or (and (consp (car articles))
5217 (> min (cdar articles)))
5218 (and (numberp (car articles))
5219 (> min (car articles)))))
5221 (set var articles))))))))
5223 (defun gnus-update-missing-marks (missing)
5224 "Go through the list of MISSING articles and remove them from the mark lists."
5227 ;; Go through all types.
5228 (dolist (elem gnus-article-mark-lists)
5229 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5230 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5231 (when (symbol-value var)
5232 ;; This list has articles. So we delete all missing
5233 ;; articles from it.
5236 (set var (delq (pop m) (symbol-value var))))))))))
5238 (defun gnus-update-marks ()
5239 "Enter the various lists of marked articles into the newsgroup info list."
5240 (let ((types gnus-article-mark-lists)
5241 (info (gnus-get-info gnus-newsgroup-name))
5242 type list newmarked symbol delta-marks)
5244 ;; Add all marks lists to the list of marks lists.
5245 (while (setq type (pop types))
5246 (setq list (symbol-value
5248 (intern (format "gnus-newsgroup-%s" (car type))))))
5251 ;; Get rid of the entries of the articles that have the
5253 (when (and (eq (cdr type) 'score)
5257 (prev (cons nil list))
5260 (if (or (not (consp (car arts)))
5261 (= (cdar arts) gnus-summary-default-score))
5262 (setcdr prev (cdr arts))
5264 (setq arts (cdr arts)))
5265 (setq list (cdr all)))))
5267 (when (eq (cdr type) 'seen)
5268 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5270 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5271 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5273 (when (and (gnus-check-backend-function
5274 'request-set-mark gnus-newsgroup-name)
5275 (not (gnus-article-unpropagatable-p (cdr type))))
5276 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5277 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5278 (add (gnus-remove-from-range
5279 (gnus-copy-sequence list) old)))
5281 (push (list add 'add (list (cdr type))) delta-marks))
5283 (push (list del 'del (list (cdr type))) delta-marks))))
5286 (push (cons (cdr type) list) newmarked)))
5289 (unless (gnus-check-group gnus-newsgroup-name)
5290 (error "Can't open server for %s" gnus-newsgroup-name))
5291 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5293 ;; Enter these new marks into the info of the group.
5295 (setcar (nthcdr 3 info) newmarked)
5296 ;; Add the marks lists to the end of the info.
5298 (setcdr (nthcdr 2 info) (list newmarked))))
5300 ;; Cut off the end of the info if there's nothing else there.
5304 (when (nthcdr (decf i) info)
5305 (setcdr (nthcdr i info) nil)))))))
5307 (defun gnus-set-mode-line (where)
5308 "Set the mode line of the article or summary buffers.
5309 If WHERE is `summary', the summary mode line format will be used."
5310 ;; Is this mode line one we keep updated?
5311 (when (and (memq where gnus-updated-mode-lines)
5313 (intern (format "gnus-%s-mode-line-format-spec" where))))
5316 ;; We evaluate this in the summary buffer since these
5317 ;; variables are buffer-local to that buffer.
5318 (set-buffer gnus-summary-buffer)
5319 ;; We bind all these variables that are used in the `eval' form
5321 (let* ((mformat (symbol-value
5323 (format "gnus-%s-mode-line-format-spec" where))))
5324 (gnus-tmp-group-name (gnus-group-decoded-name
5325 gnus-newsgroup-name))
5326 (gnus-tmp-article-number (or gnus-current-article 0))
5327 (gnus-tmp-unread gnus-newsgroup-unreads)
5328 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5329 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5330 (gnus-tmp-unread-and-unselected
5331 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5332 (zerop gnus-tmp-unselected))
5334 ((zerop gnus-tmp-unselected)
5335 (format "{%d more}" gnus-tmp-unread-and-unticked))
5336 (t (format "{%d(+%d) more}"
5337 gnus-tmp-unread-and-unticked
5338 gnus-tmp-unselected))))
5340 (if (and gnus-current-headers
5341 (vectorp gnus-current-headers))
5342 (gnus-mode-string-quote
5343 (mail-header-subject gnus-current-headers))
5345 bufname-length max-len
5346 gnus-tmp-header);; passed as argument to any user-format-funcs
5347 (setq mode-string (eval mformat))
5348 (setq bufname-length (if (string-match "%b" mode-string)
5351 (if (eq where 'summary)
5353 (get-buffer gnus-article-buffer))))
5356 (setq max-len (max 4 (if gnus-mode-non-string-length
5358 gnus-mode-non-string-length
5360 (length mode-string))))
5361 ;; We might have to chop a bit of the string off...
5362 (when (> (length mode-string) max-len)
5364 (concat (gnus-truncate-string mode-string (- max-len 3))
5366 ;; Pad the mode string a bit.
5367 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5368 ;; Update the mode line.
5369 (setq mode-line-buffer-identification
5370 (gnus-mode-line-buffer-identification (list mode-string)))
5371 (set-buffer-modified-p t))))
5373 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5374 "Go through the HEADERS list and add all Xrefs to a hash table.
5375 The resulting hash table is returned, or nil if no Xrefs were found."
5376 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5377 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5378 (xref-hashtb (gnus-make-hashtable))
5379 start group entry number xrefs header)
5381 (setq header (pop headers))
5382 (when (and (setq xrefs (mail-header-xref header))
5383 (not (memq (setq number (mail-header-number header))
5386 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5387 (setq start (match-end 0))
5388 (setq group (if prefix
5389 (concat prefix (substring xrefs (match-beginning 1)
5391 (substring xrefs (match-beginning 1) (match-end 1))))
5393 (string-to-int (substring xrefs (match-beginning 2)
5395 (if (setq entry (gnus-gethash group xref-hashtb))
5396 (setcdr entry (cons number (cdr entry)))
5397 (gnus-sethash group (cons number nil) xref-hashtb)))))
5398 (and start xref-hashtb)))
5400 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5401 "Look through all the headers and mark the Xrefs as read."
5402 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5403 name entry info xref-hashtb idlist method nth4)
5405 (set-buffer gnus-group-buffer)
5406 (when (setq xref-hashtb
5407 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5410 (unless (string= from-newsgroup (setq name (symbol-name group)))
5411 (setq idlist (symbol-value group))
5412 ;; Dead groups are not updated.
5414 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5416 (when (stringp (setq nth4 (gnus-info-method info)))
5417 (setq nth4 (gnus-server-to-method nth4))))
5418 ;; Only do the xrefs if the group has the same
5419 ;; select method as the group we have just read.
5420 (or (gnus-methods-equal-p
5421 nth4 (gnus-find-method-for-group from-newsgroup))
5423 (equal nth4 (setq method (gnus-find-method-for-group
5425 (and (equal (car nth4) (car method))
5426 (equal (nth 1 nth4) (nth 1 method))))
5427 gnus-use-cross-reference
5428 (or (not (eq gnus-use-cross-reference t))
5430 ;; Only do cross-references on subscribed
5431 ;; groups, if that is what is wanted.
5432 (<= (gnus-info-level info) gnus-level-subscribed))
5433 (gnus-group-make-articles-read name idlist))))
5436 (defun gnus-compute-read-articles (group articles)
5437 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5438 (info (nth 2 entry))
5439 (active (gnus-active group))
5442 ;; First peel off all invalid article numbers.
5444 (let ((ids articles)
5446 (while (setq id (pop ids))
5447 (when (and first (> id (cdr active)))
5448 ;; We'll end up in this situation in one particular
5449 ;; obscure situation. If you re-scan a group and get
5450 ;; a new article that is cross-posted to a different
5451 ;; group that has not been re-scanned, you might get
5452 ;; crossposted article that has a higher number than
5453 ;; Gnus believes possible. So we re-activate this
5454 ;; group as well. This might mean doing the
5455 ;; crossposting thingy will *increase* the number
5456 ;; of articles in some groups. Tsk, tsk.
5457 (setq active (or (gnus-activate-group group) active)))
5458 (when (or (> id (cdr active))
5459 (< id (car active)))
5460 (setq articles (delq id articles))))))
5461 ;; If the read list is nil, we init it.
5463 (null (gnus-info-read info))
5465 (setq ninfo (cons 1 (1- (car active))))
5466 (setq ninfo (gnus-info-read info)))
5467 ;; Then we add the read articles to the range.
5469 ninfo (setq articles (sort articles '<))))))
5471 (defun gnus-group-make-articles-read (group articles)
5472 "Update the info of GROUP to say that ARTICLES are read."
5474 (entry (gnus-gethash group gnus-newsrc-hashtb))
5475 (info (nth 2 entry))
5476 (active (gnus-active group))
5479 (setq range (gnus-compute-read-articles group articles))
5481 (set-buffer gnus-group-buffer)
5484 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5485 (gnus-info-set-read ',info ',(gnus-info-read info))
5486 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5487 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5488 (gnus-group-update-group ,group t))))
5489 ;; Add the read articles to the range.
5490 (gnus-info-set-read info range)
5491 (gnus-request-set-mark group (list (list range 'add '(read))))
5492 ;; Then we have to re-compute how many unread
5493 ;; articles there are in this group.
5497 (setq num (- (1+ (cdr active)) (car active))))
5498 ((not (listp (cdr range)))
5499 (setq num (- (cdr active) (- (1+ (cdr range))
5503 (if (numberp (car range))
5505 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5506 (setq range (cdr range)))
5507 (setq num (- (cdr active) num))))
5508 ;; Update the number of unread articles.
5510 ;; Update the group buffer.
5511 (gnus-group-update-group group t)))))
5513 (defvar gnus-newsgroup-none-id 0)
5515 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5516 (let ((cur nntp-server-buffer)
5519 (save-excursion (set-buffer gnus-summary-buffer)
5520 gnus-newsgroup-dependencies)))
5522 (mail-parse-charset gnus-newsgroup-charset)
5523 (mail-parse-ignored-charsets
5524 (save-excursion (condition-case nil
5525 (set-buffer gnus-summary-buffer)
5527 gnus-newsgroup-ignored-charsets)))
5529 (set-buffer nntp-server-buffer)
5530 ;; Translate all TAB characters into SPACE characters.
5531 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5532 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5533 (gnus-run-hooks 'gnus-parse-headers-hook)
5534 (let ((case-fold-search t)
5535 in-reply-to header p lines chars ctype)
5536 (goto-char (point-min))
5537 ;; Search to the beginning of the next header. Error messages
5538 ;; do not begin with 2 or 3.
5539 (while (re-search-forward "^[23][0-9]+ " nil t)
5542 ;; This implementation of this function, with nine
5543 ;; search-forwards instead of the one re-search-forward and
5544 ;; a case (which basically was the old function) is actually
5545 ;; about twice as fast, even though it looks messier. You
5546 ;; can't have everything, I guess. Speed and elegance
5547 ;; doesn't always go hand in hand.
5550 (make-full-mail-header
5556 (narrow-to-region (point)
5557 (or (and (search-forward "\n.\n" nil t)
5563 (if (search-forward "\nsubject:" nil t)
5564 (nnheader-header-value)
5569 (if (search-forward "\nfrom:" nil t)
5570 (nnheader-header-value)
5575 (if (search-forward "\ndate:" nil t)
5576 (nnheader-header-value) ""))
5580 (setq id (if (re-search-forward
5581 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5582 ;; We do it this way to make sure the Message-ID
5583 ;; is (somewhat) syntactically valid.
5584 (buffer-substring (match-beginning 1)
5586 ;; If there was no message-id, we just fake one
5587 ;; to make subsequent routines simpler.
5588 (nnheader-generate-fake-message-id))))
5592 (if (search-forward "\nreferences:" nil t)
5596 (nnheader-header-value)
5601 (search-backward ">" end t)
5604 (search-backward "<" end t)
5606 ;; Get the references from the in-reply-to header if there
5607 ;; were no references and the in-reply-to header looks
5609 (if (and (search-forward "\nin-reply-to:" nil t)
5610 (setq in-reply-to (nnheader-header-value))
5611 (string-match "<[^>]+>" in-reply-to))
5613 (setq ref (substring in-reply-to (match-beginning 0)
5615 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5616 (setq ref2 (substring in-reply-to (match-beginning 0)
5618 (when (> (length ref2) (length ref))
5625 (if (search-forward "\nchars: " nil t)
5626 (if (numberp (setq chars (ignore-errors (read cur))))
5632 (if (search-forward "\nlines: " nil t)
5633 (if (numberp (setq lines (ignore-errors (read cur))))
5639 (and (search-forward "\nxref:" nil t)
5640 (nnheader-header-value)))
5642 (when gnus-extra-headers
5643 (let ((extra gnus-extra-headers)
5647 (when (search-forward
5648 (concat "\n" (symbol-name (car extra)) ":") nil t)
5649 (push (cons (car extra) (nnheader-header-value)) out))
5653 (if (and (search-forward "\ncontent-type: " nil t)
5654 (setq ctype (nnheader-header-value)))
5655 (mime-entity-set-content-type-internal
5656 header (mime-parse-Content-Type ctype)))
5657 (when (equal id ref)
5660 (when gnus-alter-header-function
5661 (funcall gnus-alter-header-function header)
5662 (setq id (mail-header-id header)
5663 ref (gnus-parent-id (mail-header-references header))))
5666 (gnus-dependencies-add-header
5667 header dependencies force-new))
5668 (push header headers))
5669 (goto-char (point-max))
5671 (nreverse headers)))))
5673 ;; Goes through the xover lines and returns a list of vectors
5674 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5675 force-new dependencies
5676 group also-fetch-heads)
5677 "Parse the news overview data in the server buffer.
5678 Return a list of headers that match SEQUENCE (see
5679 `nntp-retrieve-headers')."
5680 ;; Get the Xref when the users reads the articles since most/some
5681 ;; NNTP servers do not include Xrefs when using XOVER.
5682 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5683 (let ((mail-parse-charset gnus-newsgroup-charset)
5684 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5685 (cur nntp-server-buffer)
5686 (dependencies (or dependencies gnus-newsgroup-dependencies))
5688 ((eq gnus-read-all-available-headers t)
5690 ((stringp gnus-read-all-available-headers)
5691 (string-match gnus-read-all-available-headers group))
5694 number headers header)
5696 (set-buffer nntp-server-buffer)
5697 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5698 ;; Allow the user to mangle the headers before parsing them.
5699 (gnus-run-hooks 'gnus-parse-headers-hook)
5700 (goto-char (point-min))
5701 (gnus-parse-without-error
5702 (while (and (or sequence allp)
5704 (setq number (read cur))
5706 (while (and sequence
5707 (< (car sequence) number))
5708 (setq sequence (cdr sequence))))
5711 (eq number (car sequence))))
5713 (setq sequence (cdr sequence))
5714 (setq header (inline
5715 (gnus-nov-parse-line
5716 number dependencies force-new)))))
5717 (push header headers))
5719 ;; A common bug in inn is that if you have posted an article and
5720 ;; then retrieves the active file, it will answer correctly --
5721 ;; the new article is included. However, a NOV entry for the
5722 ;; article may not have been generated yet, so this may fail.
5723 ;; We work around this problem by retrieving the last few
5724 ;; headers using HEAD.
5725 (if (or (not also-fetch-heads)
5727 ;; We (probably) got all the headers.
5729 (let ((gnus-nov-is-evil t))
5732 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5733 (gnus-get-newsgroup-headers))))))))
5735 (defun gnus-article-get-xrefs ()
5736 "Fill in the Xref value in `gnus-current-headers', if necessary.
5737 This is meant to be called in `gnus-article-internal-prepare-hook'."
5738 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5739 gnus-current-headers)))
5740 (or (not gnus-use-cross-reference)
5742 (and (mail-header-xref headers)
5743 (not (string= (mail-header-xref headers) "")))
5744 (let ((case-fold-search t)
5747 (nnheader-narrow-to-headers)
5748 (goto-char (point-min))
5749 (when (or (and (not (eobp))
5750 (eq (downcase (char-after)) ?x)
5751 (looking-at "Xref:"))
5752 (search-forward "\nXref:" nil t))
5753 (goto-char (1+ (match-end 0)))
5754 (setq xref (buffer-substring (point)
5755 (progn (end-of-line) (point))))
5756 (mail-header-set-xref headers xref)))))))
5758 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5759 "Find article ID and insert the summary line for that article.
5760 OLD-HEADER can either be a header or a line number to insert
5761 the subject line on."
5762 (let* ((line (and (numberp old-header) old-header))
5763 (old-header (and (vectorp old-header) old-header))
5764 (header (cond ((and old-header use-old-header)
5767 (gnus-number-to-header id))
5768 (gnus-number-to-header id))
5770 (gnus-read-header id))))
5771 (number (and (numberp id) id))
5774 ;; Rebuild the thread that this article is part of and go to the
5775 ;; article we have fetched.
5776 (when (and (not gnus-show-threads)
5779 (setq d (gnus-data-find (mail-header-number old-header))))
5780 (goto-char (gnus-data-pos d))
5783 (- (gnus-point-at-bol)
5785 (1+ (gnus-point-at-eol))
5786 (gnus-delete-line))))))
5788 (mail-header-set-number header (mail-header-number old-header)))
5789 (setq gnus-newsgroup-sparse
5790 (delq (setq number (mail-header-number header))
5791 gnus-newsgroup-sparse))
5792 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5793 (push number gnus-newsgroup-limit)
5794 (gnus-rebuild-thread (mail-header-id header) line)
5795 (gnus-summary-goto-subject number nil t))
5796 (when (and (numberp number)
5798 ;; We have to update the boundaries even if we can't fetch the
5799 ;; article if ID is a number -- so that the next `P' or `N'
5800 ;; command will fetch the previous (or next) article even
5801 ;; if the one we tried to fetch this time has been canceled.
5802 (when (> number gnus-newsgroup-end)
5803 (setq gnus-newsgroup-end number))
5804 (when (< number gnus-newsgroup-begin)
5805 (setq gnus-newsgroup-begin number))
5806 (setq gnus-newsgroup-unselected
5807 (delq number gnus-newsgroup-unselected)))
5808 ;; Report back a success?
5809 (and header (mail-header-number header))))
5811 ;;; Process/prefix in the summary buffer
5813 (defun gnus-summary-work-articles (n)
5814 "Return a list of articles to be worked upon.
5815 The prefix argument, the list of process marked articles, and the
5816 current article will be taken into consideration."
5818 (set-buffer gnus-summary-buffer)
5821 ;; A numerical prefix has been given.
5822 (setq n (prefix-numeric-value n))
5823 (let ((backward (< n 0))
5824 (n (abs (prefix-numeric-value n)))
5829 (push (setq article (gnus-summary-article-number))
5832 (gnus-summary-find-prev nil article)
5833 (gnus-summary-find-next nil article)))
5835 (nreverse articles)))
5836 ((and (gnus-region-active-p) (mark))
5837 (message "region active")
5838 ;; Work on the region between point and mark.
5839 (let ((max (max (point) (mark)))
5842 (goto-char (min (point) (mark)))
5845 (push (setq article (gnus-summary-article-number)) articles)
5846 (gnus-summary-find-next nil article)
5848 (nreverse articles))))
5849 (gnus-newsgroup-processable
5850 ;; There are process-marked articles present.
5851 ;; Save current state.
5852 (gnus-summary-save-process-mark)
5854 (reverse gnus-newsgroup-processable))
5856 ;; Just return the current article.
5857 (list (gnus-summary-article-number))))))
5859 (defmacro gnus-summary-iterate (arg &rest forms)
5860 "Iterate over the process/prefixed articles and do FORMS.
5861 ARG is the interactive prefix given to the command. FORMS will be
5862 executed with point over the summary line of the articles."
5863 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5864 `(let ((,articles (gnus-summary-work-articles ,arg)))
5866 (gnus-summary-goto-subject (car ,articles))
5870 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5871 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5873 (defun gnus-summary-save-process-mark ()
5874 "Push the current set of process marked articles on the stack."
5876 (push (copy-sequence gnus-newsgroup-processable)
5877 gnus-newsgroup-process-stack))
5879 (defun gnus-summary-kill-process-mark ()
5880 "Push the current set of process marked articles on the stack and unmark."
5882 (gnus-summary-save-process-mark)
5883 (gnus-summary-unmark-all-processable))
5885 (defun gnus-summary-yank-process-mark ()
5886 "Pop the last process mark state off the stack and restore it."
5888 (unless gnus-newsgroup-process-stack
5889 (error "Empty mark stack"))
5890 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5892 (defun gnus-summary-process-mark-set (set)
5893 "Make SET into the current process marked articles."
5894 (gnus-summary-unmark-all-processable)
5896 (gnus-summary-set-process-mark (pop set))))
5898 ;;; Searching and stuff
5900 (defun gnus-summary-search-group (&optional backward use-level)
5901 "Search for next unread newsgroup.
5902 If optional argument BACKWARD is non-nil, search backward instead."
5904 (set-buffer gnus-group-buffer)
5905 (when (gnus-group-search-forward
5906 backward nil (if use-level (gnus-group-group-level) nil))
5907 (gnus-group-group-name))))
5909 (defun gnus-summary-best-group (&optional exclude-group)
5910 "Find the name of the best unread group.
5911 If EXCLUDE-GROUP, do not go to this group."
5913 (set-buffer gnus-group-buffer)
5915 (gnus-group-best-unread-group exclude-group))))
5917 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5918 (if backward (gnus-summary-find-prev)
5919 (let* ((dummy (gnus-summary-article-intangible-p))
5920 (article (or article (gnus-summary-article-number)))
5921 (arts (gnus-data-find-list article))
5923 (when (and (not dummy)
5924 (or (not gnus-summary-check-current)
5926 (not (gnus-data-unread-p (car arts)))))
5927 (setq arts (cdr arts)))
5932 (when (or (and undownloaded
5933 (eq gnus-undownloaded-mark
5934 (gnus-data-mark (car arts))))
5935 (gnus-data-unread-p (car arts)))
5936 (setq result (car arts)
5938 (setq arts (cdr arts)))
5941 (goto-char (gnus-data-pos result))
5942 (gnus-data-number result)))))
5944 (defun gnus-summary-find-prev (&optional unread article)
5945 (let* ((eobp (eobp))
5946 (article (or article (gnus-summary-article-number)))
5947 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5949 (when (and (not eobp)
5950 (or (not gnus-summary-check-current)
5952 (not (gnus-data-unread-p (car arts)))))
5953 (setq arts (cdr arts)))
5958 (when (gnus-data-unread-p (car arts))
5959 (setq result (car arts)
5961 (setq arts (cdr arts)))
5964 (goto-char (gnus-data-pos result))
5965 (gnus-data-number result))))
5967 (defun gnus-summary-find-subject (subject &optional unread backward article)
5968 (let* ((simp-subject (gnus-simplify-subject-fully subject))
5969 (article (or article (gnus-summary-article-number)))
5970 (articles (gnus-data-list backward))
5971 (arts (gnus-data-find-list article articles))
5973 (when (or (not gnus-summary-check-current)
5975 (not (gnus-data-unread-p (car arts))))
5976 (setq arts (cdr arts)))
5978 (and (or (not unread)
5979 (gnus-data-unread-p (car arts)))
5980 (vectorp (gnus-data-header (car arts)))
5982 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
5983 (setq result (car arts)
5985 (setq arts (cdr arts)))
5987 (goto-char (gnus-data-pos result))
5988 (gnus-data-number result))))
5990 (defun gnus-summary-search-forward (&optional unread subject backward)
5991 "Search forward for an article.
5992 If UNREAD, look for unread articles. If SUBJECT, look for
5993 articles with that subject. If BACKWARD, search backward instead."
5994 (cond (subject (gnus-summary-find-subject subject unread backward))
5995 (backward (gnus-summary-find-prev unread))
5996 (t (gnus-summary-find-next unread))))
5998 (defun gnus-recenter (&optional n)
5999 "Center point in window and redisplay frame.
6000 Also do horizontal recentering."
6002 (when (and gnus-auto-center-summary
6003 (not (eq gnus-auto-center-summary 'vertical)))
6004 (gnus-horizontal-recenter))
6007 (defun gnus-summary-recenter ()
6008 "Center point in the summary window.
6009 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6010 displayed, no centering will be performed."
6011 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6012 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6014 (let* ((top (cond ((< (window-height) 4) 0)
6015 ((< (window-height) 7) 1)
6016 (t (if (numberp gnus-auto-center-summary)
6017 gnus-auto-center-summary
6019 (height (1- (window-height)))
6020 (bottom (save-excursion (goto-char (point-max))
6021 (forward-line (- height))
6023 (window (get-buffer-window (current-buffer))))
6024 ;; The user has to want it.
6025 (when gnus-auto-center-summary
6026 (when (get-buffer-window gnus-article-buffer)
6027 ;; Only do recentering when the article buffer is displayed,
6028 ;; Set the window start to either `bottom', which is the biggest
6029 ;; possible valid number, or the second line from the top,
6030 ;; whichever is the least.
6031 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6032 (if (> bottom top-pos)
6033 ;; Keep the second line from the top visible
6034 (set-window-start window top-pos t)
6035 ;; Try to keep the bottom line visible; if it's partially
6036 ;; obscured, either scroll one more line to make it fully
6037 ;; visible, or revert to using TOP-POS.
6039 (goto-char (point-max))
6041 (let ((last-line-start (point)))
6043 (set-window-start window (point) t)
6044 (when (not (pos-visible-in-window-p last-line-start window))
6046 (set-window-start window (min (point) top-pos) t)))))))
6047 ;; Do horizontal recentering while we're at it.
6048 (when (and (get-buffer-window (current-buffer) t)
6049 (not (eq gnus-auto-center-summary 'vertical)))
6050 (let ((selected (selected-window)))
6051 (select-window (get-buffer-window (current-buffer) t))
6052 (gnus-summary-position-point)
6053 (gnus-horizontal-recenter)
6054 (select-window selected))))))
6056 (defun gnus-summary-jump-to-group (newsgroup)
6057 "Move point to NEWSGROUP in group mode buffer."
6058 ;; Keep update point of group mode buffer if visible.
6059 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6060 (save-window-excursion
6061 ;; Take care of tree window mode.
6062 (when (get-buffer-window gnus-group-buffer)
6063 (pop-to-buffer gnus-group-buffer))
6064 (gnus-group-jump-to-group newsgroup))
6066 ;; Take care of tree window mode.
6067 (if (get-buffer-window gnus-group-buffer)
6068 (pop-to-buffer gnus-group-buffer)
6069 (set-buffer gnus-group-buffer))
6070 (gnus-group-jump-to-group newsgroup))))
6072 ;; This function returns a list of article numbers based on the
6073 ;; difference between the ranges of read articles in this group and
6074 ;; the range of active articles.
6075 (defun gnus-list-of-unread-articles (group)
6076 (let* ((read (gnus-info-read (gnus-get-info group)))
6077 (active (or (gnus-active group) (gnus-activate-group group)))
6080 ;; If none are read, then all are unread.
6082 (setq first (car active))
6083 ;; If the range of read articles is a single range, then the
6084 ;; first unread article is the article after the last read
6085 ;; article. Sounds logical, doesn't it?
6086 (if (and (not (listp (cdr read)))
6087 (or (< (car read) (car active))
6088 (progn (setq read (list read))
6090 (setq first (max (car active) (1+ (cdr read))))
6091 ;; `read' is a list of ranges.
6092 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6095 (setq first (car active)))
6098 (while (< first nlast)
6100 (setq first (1+ first))))
6101 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6102 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6103 (setq read (cdr read)))))
6104 ;; And add the last unread articles.
6105 (while (<= first last)
6107 (setq first (1+ first)))
6108 ;; Return the list of unread articles.
6109 (delq 0 (nreverse unread))))
6111 (defun gnus-list-of-read-articles (group)
6112 "Return a list of unread, unticked and non-dormant articles."
6113 (let* ((info (gnus-get-info group))
6114 (marked (gnus-info-marks info))
6115 (active (gnus-active group)))
6117 (gnus-list-range-difference
6118 (gnus-list-range-difference
6119 (gnus-sorted-complement
6120 (gnus-uncompress-range active)
6121 (gnus-list-of-unread-articles group))
6122 (cdr (assq 'dormant marked)))
6123 (cdr (assq 'tick marked))))))
6125 ;; Various summary commands
6127 (defun gnus-summary-select-article-buffer ()
6128 "Reconfigure windows to show article buffer."
6130 (if (not (gnus-buffer-live-p gnus-article-buffer))
6131 (error "There is no article buffer for this summary buffer")
6132 (gnus-configure-windows 'article)
6133 (select-window (get-buffer-window gnus-article-buffer))))
6135 (defun gnus-summary-universal-argument (arg)
6136 "Perform any operation on all articles that are process/prefixed."
6138 (let ((articles (gnus-summary-work-articles arg))
6145 (substitute-command-keys
6146 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6148 (gnus-error 1 "Undefined key")
6151 (gnus-summary-goto-subject (setq article (pop articles)))
6152 (let (gnus-newsgroup-processable)
6153 (command-execute func))
6154 (gnus-summary-remove-process-mark article)))))
6155 (gnus-summary-position-point))
6157 (defun gnus-summary-toggle-truncation (&optional arg)
6158 "Toggle truncation of summary lines.
6159 With arg, turn line truncation on iff arg is positive."
6161 (setq truncate-lines
6162 (if (null arg) (not truncate-lines)
6163 (> (prefix-numeric-value arg) 0)))
6166 (defun gnus-summary-reselect-current-group (&optional all rescan)
6167 "Exit and then reselect the current newsgroup.
6168 The prefix argument ALL means to select all articles."
6170 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6171 (error "Ephemeral groups can't be reselected"))
6172 (let ((current-subject (gnus-summary-article-number))
6173 (group gnus-newsgroup-name))
6174 (setq gnus-newsgroup-begin nil)
6176 ;; We have to adjust the point of group mode buffer because
6177 ;; point was moved to the next unread newsgroup by exiting.
6178 (gnus-summary-jump-to-group group)
6181 (save-window-excursion
6182 ;; Don't show group contents.
6183 (set-window-start (selected-window) (point-max))
6184 (gnus-group-get-new-news-this-group 1))))
6185 (gnus-group-read-group all t)
6186 (gnus-summary-goto-subject current-subject nil t)))
6188 (defun gnus-summary-rescan-group (&optional all)
6189 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6191 (gnus-summary-reselect-current-group all t))
6193 (defun gnus-summary-update-info (&optional non-destructive)
6195 (let ((group gnus-newsgroup-name))
6197 (when gnus-newsgroup-kill-headers
6198 (setq gnus-newsgroup-killed
6199 (gnus-compress-sequence
6201 (gnus-list-range-intersection
6202 gnus-newsgroup-unselected gnus-newsgroup-killed)
6203 gnus-newsgroup-unreads)
6205 (unless (listp (cdr gnus-newsgroup-killed))
6206 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6207 (let ((headers gnus-newsgroup-headers))
6208 ;; Set the new ranges of read articles.
6210 (set-buffer gnus-group-buffer)
6211 (gnus-undo-force-boundary))
6212 (gnus-update-read-articles
6213 group (gnus-sorted-union
6214 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6215 ;; Set the current article marks.
6216 (let ((gnus-newsgroup-scored
6217 (if (and (not gnus-save-score)
6218 (not non-destructive))
6220 gnus-newsgroup-scored)))
6222 (gnus-update-marks)))
6223 ;; Do the cross-ref thing.
6224 (when gnus-use-cross-reference
6225 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6226 ;; Do not switch windows but change the buffer to work.
6227 (set-buffer gnus-group-buffer)
6228 (unless (gnus-ephemeral-group-p group)
6229 (gnus-group-update-group group)))))))
6231 (defun gnus-summary-save-newsrc (&optional force)
6232 "Save the current number of read/marked articles in the dribble buffer.
6233 The dribble buffer will then be saved.
6234 If FORCE (the prefix), also save the .newsrc file(s)."
6236 (gnus-summary-update-info t)
6238 (gnus-save-newsrc-file)
6239 (gnus-dribble-save)))
6241 (defun gnus-summary-exit (&optional temporary)
6242 "Exit reading current newsgroup, and then return to group selection mode.
6243 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6245 (gnus-set-global-variables)
6246 (gnus-kill-save-kill-buffer)
6247 (gnus-async-halt-prefetch)
6248 (let* ((group gnus-newsgroup-name)
6249 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6252 (buf (current-buffer)))
6254 ;; Do adaptive scoring, and possibly save score files.
6255 (when gnus-newsgroup-adaptive
6256 (gnus-score-adaptive))
6257 (when gnus-use-scoring
6259 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6260 ;; If we have several article buffers, we kill them at exit.
6261 (unless gnus-single-article-buffer
6262 (gnus-kill-buffer gnus-original-article-buffer)
6263 (setq gnus-article-current nil))
6264 (when gnus-use-cache
6265 (gnus-cache-possibly-remove-articles)
6266 (gnus-cache-save-buffers))
6267 (gnus-async-prefetch-remove-group group)
6268 (when gnus-suppress-duplicates
6269 (gnus-dup-enter-articles))
6270 (when gnus-use-trees
6271 (gnus-tree-close group))
6272 (when gnus-use-cache
6273 (gnus-cache-write-active))
6274 ;; Remove entries for this group.
6275 (nnmail-purge-split-history (gnus-group-real-name group))
6276 ;; Make all changes in this group permanent.
6278 (gnus-run-hooks 'gnus-exit-group-hook)
6279 (gnus-summary-update-info))
6280 (gnus-close-group group)
6281 ;; Make sure where we were, and go to next newsgroup.
6282 (set-buffer gnus-group-buffer)
6284 (gnus-group-jump-to-group group))
6285 (gnus-run-hooks 'gnus-summary-exit-hook)
6286 (unless (or quit-config
6287 ;; If this group has disappeared from the summary
6288 ;; buffer, don't skip forwards.
6289 (not (string= group (gnus-group-group-name))))
6290 (gnus-group-next-unread-group 1))
6291 (setq group-point (point))
6294 ;; If we have several article buffers, we kill them at exit.
6295 (unless gnus-single-article-buffer
6296 (gnus-kill-buffer gnus-article-buffer)
6297 (gnus-kill-buffer gnus-original-article-buffer)
6298 (setq gnus-article-current nil))
6300 (if (not gnus-kill-summary-on-exit)
6302 (gnus-deaden-summary)
6304 ;; We set all buffer-local variables to nil. It is unclear why
6305 ;; this is needed, but if we don't, buffer-local variables are
6306 ;; not garbage-collected, it seems. This would the lead to en
6307 ;; ever-growing Emacs.
6308 (gnus-summary-clear-local-variables)
6309 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6310 (gnus-summary-clear-local-variables))
6311 (when (get-buffer gnus-article-buffer)
6312 (bury-buffer gnus-article-buffer))
6313 ;; We clear the global counterparts of the buffer-local
6314 ;; variables as well, just to be on the safe side.
6315 (set-buffer gnus-group-buffer)
6316 (gnus-summary-clear-local-variables)
6317 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6318 (gnus-summary-clear-local-variables)))
6319 (setq gnus-current-select-method gnus-select-method)
6320 (pop-to-buffer gnus-group-buffer)
6321 (if (not quit-config)
6323 (goto-char group-point)
6324 (gnus-configure-windows 'group 'force)
6325 (unless (pos-visible-in-window-p)
6326 (forward-line (/ (static-if (featurep 'xemacs)
6327 (window-displayed-height)
6328 (1- (window-height)))
6330 (set-window-start (selected-window) (point))
6331 (goto-char group-point)))
6332 (gnus-handle-ephemeral-exit quit-config))
6333 ;; Return to group mode buffer.
6334 (when (eq mode 'gnus-summary-mode)
6335 (gnus-kill-buffer buf))
6336 ;; Clear the current group name.
6338 (setq gnus-newsgroup-name nil)))))
6340 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6341 (defun gnus-summary-exit-no-update (&optional no-questions)
6342 "Quit reading current newsgroup without updating read article info."
6344 (let* ((group gnus-newsgroup-name)
6345 (quit-config (gnus-group-quit-config group)))
6346 (when (or no-questions
6348 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6349 (gnus-async-halt-prefetch)
6351 (delq 'gnus-summary-expire-articles
6352 (copy-sequence gnus-summary-prepare-exit-hook)))
6353 ;; If we have several article buffers, we kill them at exit.
6354 (unless gnus-single-article-buffer
6355 (gnus-kill-buffer gnus-article-buffer)
6356 (gnus-kill-buffer gnus-original-article-buffer)
6357 (setq gnus-article-current nil))
6358 (if (not gnus-kill-summary-on-exit)
6359 (gnus-deaden-summary)
6360 (gnus-close-group group)
6361 (gnus-summary-clear-local-variables)
6362 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6363 (gnus-summary-clear-local-variables))
6364 (set-buffer gnus-group-buffer)
6365 (gnus-summary-clear-local-variables)
6366 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6367 (gnus-summary-clear-local-variables))
6368 (when (get-buffer gnus-summary-buffer)
6369 (kill-buffer gnus-summary-buffer)))
6370 (unless gnus-single-article-buffer
6371 (setq gnus-article-current nil))
6372 (when gnus-use-trees
6373 (gnus-tree-close group))
6374 (gnus-async-prefetch-remove-group group)
6375 (when (get-buffer gnus-article-buffer)
6376 (bury-buffer gnus-article-buffer))
6377 ;; Return to the group buffer.
6378 (gnus-configure-windows 'group 'force)
6379 ;; Clear the current group name.
6380 (setq gnus-newsgroup-name nil)
6381 (when (equal (gnus-group-group-name) group)
6382 (gnus-group-next-unread-group 1))
6384 (gnus-handle-ephemeral-exit quit-config)))))
6386 (defun gnus-handle-ephemeral-exit (quit-config)
6387 "Handle movement when leaving an ephemeral group.
6388 The state which existed when entering the ephemeral is reset."
6389 (if (not (buffer-name (car quit-config)))
6390 (gnus-configure-windows 'group 'force)
6391 (set-buffer (car quit-config))
6392 (cond ((eq major-mode 'gnus-summary-mode)
6393 (gnus-set-global-variables))
6394 ((eq major-mode 'gnus-article-mode)
6396 ;; The `gnus-summary-buffer' variable may point
6397 ;; to the old summary buffer when using a single
6399 (unless (gnus-buffer-live-p gnus-summary-buffer)
6400 (set-buffer gnus-group-buffer))
6401 (set-buffer gnus-summary-buffer)
6402 (gnus-set-global-variables))))
6403 (if (or (eq (cdr quit-config) 'article)
6404 (eq (cdr quit-config) 'pick))
6406 ;; The current article may be from the ephemeral group
6407 ;; thus it is best that we reload this article
6408 (gnus-summary-show-article)
6409 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6410 (gnus-configure-windows 'pick 'force)
6411 (gnus-configure-windows (cdr quit-config) 'force)))
6412 (gnus-configure-windows (cdr quit-config) 'force))
6413 (when (eq major-mode 'gnus-summary-mode)
6414 (gnus-summary-next-subject 1 nil t)
6415 (gnus-summary-recenter)
6416 (gnus-summary-position-point))))
6418 (defun gnus-summary-preview-mime-message ()
6419 "MIME decode and play this message."
6421 (let ((gnus-break-pages nil)
6423 (gnus-summary-select-article gnus-show-all-headers t))
6424 (let ((w (get-buffer-window gnus-article-buffer)))
6426 (select-window (get-buffer-window gnus-article-buffer)))))
6430 (defvar gnus-dead-summary-mode-map nil)
6432 (unless gnus-dead-summary-mode-map
6433 (setq gnus-dead-summary-mode-map (make-keymap))
6434 (suppress-keymap gnus-dead-summary-mode-map)
6435 (substitute-key-definition
6436 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6437 (dolist (key '("\C-d" "\r" "\177" [delete]))
6438 (define-key gnus-dead-summary-mode-map
6439 key 'gnus-summary-wake-up-the-dead))
6440 (dolist (key '("q" "Q"))
6441 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6443 (defvar gnus-dead-summary-mode nil
6444 "Minor mode for Gnus summary buffers.")
6446 (defun gnus-dead-summary-mode (&optional arg)
6447 "Minor mode for Gnus summary buffers."
6449 (when (eq major-mode 'gnus-summary-mode)
6450 (make-local-variable 'gnus-dead-summary-mode)
6451 (setq gnus-dead-summary-mode
6452 (if (null arg) (not gnus-dead-summary-mode)
6453 (> (prefix-numeric-value arg) 0)))
6454 (when gnus-dead-summary-mode
6455 (gnus-add-minor-mode
6456 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6458 (defun gnus-deaden-summary ()
6459 "Make the current summary buffer into a dead summary buffer."
6460 ;; Kill any previous dead summary buffer.
6461 (when (and gnus-dead-summary
6462 (buffer-name gnus-dead-summary))
6464 (set-buffer gnus-dead-summary)
6465 (when gnus-dead-summary-mode
6466 (kill-buffer (current-buffer)))))
6467 ;; Make this the current dead summary.
6468 (setq gnus-dead-summary (current-buffer))
6469 (gnus-dead-summary-mode 1)
6470 (let ((name (buffer-name)))
6471 (when (string-match "Summary" name)
6473 (concat (substring name 0 (match-beginning 0)) "Dead "
6474 (substring name (match-beginning 0)))
6478 (defun gnus-kill-or-deaden-summary (buffer)
6479 "Kill or deaden the summary BUFFER."
6481 (when (and (buffer-name buffer)
6482 (not gnus-single-article-buffer))
6485 (gnus-kill-buffer gnus-article-buffer)
6486 (gnus-kill-buffer gnus-original-article-buffer)))
6489 (gnus-kill-summary-on-exit
6490 (when (and gnus-use-trees
6491 (gnus-buffer-exists-p buffer))
6494 (gnus-tree-close gnus-newsgroup-name)))
6495 (gnus-kill-buffer buffer))
6496 ;; Deaden the buffer.
6497 ((gnus-buffer-exists-p buffer)
6500 (gnus-deaden-summary))))))
6502 (defun gnus-summary-wake-up-the-dead (&rest args)
6503 "Wake up the dead summary buffer."
6505 (gnus-dead-summary-mode -1)
6506 (let ((name (buffer-name)))
6507 (when (string-match "Dead " name)
6509 (concat (substring name 0 (match-beginning 0))
6510 (substring name (match-end 0)))
6512 (gnus-message 3 "This dead summary is now alive again"))
6514 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6515 (defun gnus-summary-fetch-faq (&optional faq-dir)
6516 "Fetch the FAQ for the current group.
6517 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6521 (when current-prefix-arg
6523 "Faq dir: " (and (listp gnus-group-faq-directory)
6524 (mapcar (lambda (file) (list file))
6525 gnus-group-faq-directory))))))
6526 (let (gnus-faq-buffer)
6527 (when (setq gnus-faq-buffer
6528 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6529 (gnus-configure-windows 'summary-faq))))
6531 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6532 (defun gnus-summary-describe-group (&optional force)
6533 "Describe the current newsgroup."
6535 (gnus-group-describe-group force gnus-newsgroup-name))
6537 (defun gnus-summary-describe-briefly ()
6538 "Describe summary mode commands briefly."
6540 (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")))
6542 ;; Walking around group mode buffer from summary mode.
6544 (defun gnus-summary-next-group (&optional no-article target-group backward)
6545 "Exit current newsgroup and then select next unread newsgroup.
6546 If prefix argument NO-ARTICLE is non-nil, no article is selected
6547 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6548 previous group instead."
6550 ;; Stop pre-fetching.
6551 (gnus-async-halt-prefetch)
6552 (let ((current-group gnus-newsgroup-name)
6553 (current-buffer (current-buffer))
6555 (gnus-summary-exit t)
6556 (while (not entered)
6557 ;; Then we find what group we are supposed to enter.
6558 (set-buffer gnus-group-buffer)
6559 (gnus-group-jump-to-group current-group)
6562 (if (eq gnus-keep-same-level 'best)
6563 (gnus-summary-best-group gnus-newsgroup-name)
6564 (gnus-summary-search-group backward gnus-keep-same-level))))
6565 (if (not target-group)
6566 ;; There are no further groups, so we return to the group
6569 (gnus-message 5 "Returning to the group buffer")
6571 (when (gnus-buffer-live-p current-buffer)
6572 (set-buffer current-buffer)
6573 (gnus-summary-exit))
6574 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6575 ;; We try to enter the target group.
6576 (gnus-group-jump-to-group target-group)
6577 (let ((unreads (gnus-group-group-unread)))
6578 (if (and (or (eq t unreads)
6579 (and unreads (not (zerop unreads))))
6581 ;; Now we semi-exit this group to update Xrefs
6582 ;; and all variables. We can't do a real exit,
6583 ;; because the window conf must remain the same
6584 ;; in case the user is prompted for info, and we
6585 ;; don't want the window conf to change before
6587 (when (gnus-buffer-live-p current-buffer)
6588 (set-buffer current-buffer)
6589 (gnus-summary-exit t))
6590 (gnus-summary-read-group
6591 target-group nil no-article
6592 (and (buffer-name current-buffer) current-buffer)
6595 (setq current-group target-group
6596 target-group nil)))))))
6598 (defun gnus-summary-prev-group (&optional no-article)
6599 "Exit current newsgroup and then select previous unread newsgroup.
6600 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6602 (gnus-summary-next-group no-article nil t))
6604 ;; Walking around summary lines.
6606 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6607 "Go to the first unread subject.
6608 If UNREAD is non-nil, go to the first unread article.
6609 Returns the article selected or nil if there are no unread articles."
6614 ((null gnus-newsgroup-data)
6615 (gnus-message 3 "No articles in the group")
6617 ;; Pick the first article.
6619 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6620 (gnus-data-number (car gnus-newsgroup-data)))
6621 ;; No unread articles.
6622 ((null gnus-newsgroup-unreads)
6623 (gnus-message 3 "No more unread articles")
6625 ;; Find the first unread article.
6627 (let ((data gnus-newsgroup-data))
6629 (and (not (and undownloaded
6630 (eq gnus-undownloaded-mark
6631 (gnus-data-mark (car data)))))
6634 (gnus-data-number (car data))
6635 gnus-newsgroup-unseen))
6636 (not (gnus-data-unread-p (car data))))
6637 (not (gnus-data-unread-p (car data))))))
6638 (setq data (cdr data)))
6640 (goto-char (gnus-data-pos (car data)))
6641 (gnus-data-number (car data))))))
6642 (gnus-summary-position-point)))
6644 (defun gnus-summary-next-subject (n &optional unread dont-display)
6645 "Go to next N'th summary line.
6646 If N is negative, go to the previous N'th subject line.
6647 If UNREAD is non-nil, only unread articles are selected.
6648 The difference between N and the actual number of steps taken is
6651 (let ((backward (< n 0))
6655 (gnus-summary-find-prev unread)
6656 (gnus-summary-find-next unread)))
6657 (unless (zerop (setq n (1- n)))
6658 (gnus-summary-show-thread)))
6660 (gnus-message 7 "No more%s articles"
6661 (if unread " unread" "")))
6662 (unless dont-display
6663 (gnus-summary-recenter)
6664 (gnus-summary-position-point))
6667 (defun gnus-summary-next-unread-subject (n)
6668 "Go to next N'th unread summary line."
6670 (gnus-summary-next-subject n t))
6672 (defun gnus-summary-prev-subject (n &optional unread)
6673 "Go to previous N'th summary line.
6674 If optional argument UNREAD is non-nil, only unread article is selected."
6676 (gnus-summary-next-subject (- n) unread))
6678 (defun gnus-summary-prev-unread-subject (n)
6679 "Go to previous N'th unread summary line."
6681 (gnus-summary-next-subject (- n) t))
6683 (defun gnus-summary-goto-subject (article &optional force silent)
6684 "Go the subject line of ARTICLE.
6685 If FORCE, also allow jumping to articles not currently shown."
6686 (interactive "nArticle number: ")
6687 (unless (numberp article)
6688 (error "Article %s is not a number" article))
6690 (data (gnus-data-find article)))
6691 ;; We read in the article if we have to.
6694 (gnus-summary-insert-subject
6696 (if (or (numberp force) (vectorp force)) force)
6698 (setq data (gnus-data-find article)))
6703 (gnus-message 3 "Can't find article %d" article))
6705 (let ((pt (gnus-data-pos data)))
6707 (gnus-summary-set-article-display-arrow pt))
6708 (gnus-summary-position-point)
6711 ;; Walking around summary lines with displaying articles.
6713 (defun gnus-summary-expand-window (&optional arg)
6714 "Make the summary buffer take up the entire Emacs frame.
6715 Given a prefix, will force an `article' buffer configuration."
6718 (gnus-configure-windows 'article 'force)
6719 (gnus-configure-windows 'summary 'force)))
6721 (defun gnus-summary-display-article (article &optional all-header)
6722 "Display ARTICLE in article buffer."
6723 (when (gnus-buffer-live-p gnus-article-buffer)
6724 (with-current-buffer gnus-article-buffer
6725 (set-buffer-multibyte t)))
6726 (gnus-set-global-variables)
6727 (when (gnus-buffer-live-p gnus-article-buffer)
6728 (with-current-buffer gnus-article-buffer
6729 (setq gnus-article-charset gnus-newsgroup-charset)
6730 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6731 (set-buffer-multibyte t)))
6735 (if gnus-summary-display-article-function
6736 (funcall gnus-summary-display-article-function article all-header)
6737 (gnus-article-prepare article all-header))
6738 (with-current-buffer gnus-article-buffer
6739 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6741 (gnus-run-hooks 'gnus-select-article-hook)
6742 (when (and gnus-current-article
6743 (not (zerop gnus-current-article)))
6744 (gnus-summary-goto-subject gnus-current-article))
6745 (gnus-summary-recenter)
6746 (when (and gnus-use-trees gnus-show-threads)
6747 (gnus-possibly-generate-tree article)
6748 (gnus-highlight-selected-tree article))
6749 ;; Successfully display article.
6750 (gnus-article-set-window-start
6751 (cdr (assq article gnus-newsgroup-bookmarks))))))
6753 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6754 "Select the current article.
6755 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6756 non-nil, the article will be re-fetched even if it already present in
6757 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6759 ;; Make sure we are in the summary buffer to work around bbdb bug.
6760 (unless (eq major-mode 'gnus-summary-mode)
6761 (set-buffer gnus-summary-buffer))
6762 (let ((article (or article (gnus-summary-article-number)))
6763 (all-headers (not (not all-headers))) ;Must be T or NIL.
6764 gnus-summary-display-article-function)
6766 (gnus-summary-article-pseudo-p article)
6767 (error "This is a pseudo-article"))
6769 (set-buffer gnus-summary-buffer)
6770 (if (or (and gnus-single-article-buffer
6771 (or (null gnus-current-article)
6772 (null gnus-article-current)
6773 (null (get-buffer gnus-article-buffer))
6774 (not (eq article (cdr gnus-article-current)))
6775 (not (equal (car gnus-article-current)
6776 gnus-newsgroup-name))))
6777 (and (not gnus-single-article-buffer)
6778 (or (null gnus-current-article)
6779 (not (eq gnus-current-article article))))
6781 ;; The requested article is different from the current article.
6783 (gnus-summary-display-article article all-headers)
6784 (gnus-article-set-window-start
6785 (cdr (assq article gnus-newsgroup-bookmarks)))
6789 (defun gnus-summary-force-verify-and-decrypt ()
6791 (let ((mm-verify-option 'known)
6792 (mm-decrypt-option 'known)
6793 (gnus-buttonized-mime-types (append (list "multipart/signed"
6794 "multipart/encrypted")
6795 gnus-buttonized-mime-types)))
6796 (gnus-summary-select-article nil 'force)))
6798 (defun gnus-summary-set-current-mark (&optional current-mark)
6799 "Obsolete function."
6802 (defun gnus-summary-next-article (&optional unread subject backward push)
6803 "Select the next article.
6804 If UNREAD, only unread articles are selected.
6805 If SUBJECT, only articles with SUBJECT are selected.
6806 If BACKWARD, the previous article is selected instead of the next."
6809 ;; Is there such an article?
6810 ((and (gnus-summary-search-forward unread subject backward)
6811 (or (gnus-summary-display-article (gnus-summary-article-number))
6812 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6813 (gnus-summary-position-point))
6814 ;; If not, we try the first unread, if that is wanted.
6816 gnus-auto-select-same
6817 (gnus-summary-first-unread-article))
6818 (gnus-summary-position-point)
6819 (gnus-message 6 "Wrapped"))
6820 ;; Try to get next/previous article not displayed in this group.
6821 ((and gnus-auto-extend-newsgroup
6822 (not unread) (not subject))
6823 (gnus-summary-goto-article
6824 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6825 nil (count-lines (point-min) (point))))
6826 ;; Go to next/previous group.
6828 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6829 (gnus-summary-jump-to-group gnus-newsgroup-name))
6830 (let ((cmd last-command-char)
6833 (set-buffer gnus-group-buffer)
6836 (if (eq gnus-keep-same-level 'best)
6837 (gnus-summary-best-group gnus-newsgroup-name)
6838 (gnus-summary-search-group backward gnus-keep-same-level))))
6839 ;; For some reason, the group window gets selected. We change
6841 (select-window (get-buffer-window (current-buffer)))
6842 ;; Select next unread newsgroup automagically.
6844 ((or (not gnus-auto-select-next)
6846 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6847 ((or (eq gnus-auto-select-next 'quietly)
6848 (and (eq gnus-auto-select-next 'slightly-quietly)
6850 (and (eq gnus-auto-select-next 'almost-quietly)
6851 (gnus-summary-last-article-p)))
6853 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6855 (gnus-message 7 "No more%s articles (%s)..."
6856 (if unread " unread" "")
6857 (if group (concat "selecting " group)
6859 (gnus-summary-next-group nil group backward)))
6861 (when (gnus-key-press-event-p last-input-event)
6862 (gnus-summary-walk-group-buffer
6863 gnus-newsgroup-name cmd unread backward point))))))))
6865 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6866 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6867 (?\C-p (gnus-group-prev-unread-group 1))))
6868 (cursor-in-echo-area t)
6869 keve key group ended)
6871 (set-buffer gnus-group-buffer)
6874 (if (eq gnus-keep-same-level 'best)
6875 (gnus-summary-best-group gnus-newsgroup-name)
6876 (gnus-summary-search-group backward gnus-keep-same-level))))
6879 5 "No more%s articles%s" (if unread " unread" "")
6881 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6882 (format " (Type %s for %s [%s])"
6883 (single-key-description cmd) group
6884 (car (gnus-gethash group gnus-newsrc-hashtb)))
6885 (format " (Type %s to exit %s)"
6886 (single-key-description cmd)
6887 gnus-newsgroup-name)))
6888 ;; Confirm auto selection.
6889 (setq key (car (setq keve (gnus-read-event-char))))
6892 ((assq key keystrokes)
6893 (let ((obuf (current-buffer)))
6894 (switch-to-buffer gnus-group-buffer)
6896 (gnus-group-jump-to-group group))
6897 (eval (cadr (assq key keystrokes)))
6898 (setq group (gnus-group-group-name))
6899 (switch-to-buffer obuf))
6903 (gnus-ephemeral-group-p gnus-newsgroup-name))
6905 (gnus-summary-next-group nil group backward)))
6907 (push (cdr keve) unread-command-events))))))
6909 (defun gnus-summary-next-unread-article ()
6910 "Select unread article after current one."
6912 (gnus-summary-next-article
6913 (or (not (eq gnus-summary-goto-unread 'never))
6914 (gnus-summary-last-article-p (gnus-summary-article-number)))
6915 (and gnus-auto-select-same
6916 (gnus-summary-article-subject))))
6918 (defun gnus-summary-prev-article (&optional unread subject)
6919 "Select the article after the current one.
6920 If UNREAD is non-nil, only unread articles are selected."
6922 (gnus-summary-next-article unread subject t))
6924 (defun gnus-summary-prev-unread-article ()
6925 "Select unread article before current one."
6927 (gnus-summary-prev-article
6928 (or (not (eq gnus-summary-goto-unread 'never))
6929 (gnus-summary-first-article-p (gnus-summary-article-number)))
6930 (and gnus-auto-select-same
6931 (gnus-summary-article-subject))))
6933 (defun gnus-summary-next-page (&optional lines circular)
6934 "Show next page of the selected article.
6935 If at the end of the current article, select the next article.
6936 LINES says how many lines should be scrolled up.
6938 If CIRCULAR is non-nil, go to the start of the article instead of
6939 selecting the next article when reaching the end of the current
6942 (setq gnus-summary-buffer (current-buffer))
6943 (gnus-set-global-variables)
6944 (let ((article (gnus-summary-article-number))
6945 (article-window (get-buffer-window gnus-article-buffer t))
6947 ;; If the buffer is empty, we have no article.
6949 (error "No article to select"))
6950 (gnus-configure-windows 'article)
6951 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
6952 (if (and (eq gnus-summary-goto-unread 'never)
6953 (not (gnus-summary-last-article-p article)))
6954 (gnus-summary-next-article)
6955 (gnus-summary-next-unread-article))
6956 (if (or (null gnus-current-article)
6957 (null gnus-article-current)
6958 (/= article (cdr gnus-article-current))
6959 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6960 ;; Selected subject is different from current article's.
6961 (gnus-summary-display-article article)
6962 (when article-window
6963 (gnus-eval-in-buffer-window gnus-article-buffer
6964 (setq endp (gnus-article-next-page lines)))
6967 (gnus-summary-beginning-of-article))
6969 (gnus-message 3 "End of message"))
6971 (if (and (eq gnus-summary-goto-unread 'never)
6972 (not (gnus-summary-last-article-p article)))
6973 (gnus-summary-next-article)
6974 (gnus-summary-next-unread-article))))))))
6975 (gnus-summary-recenter)
6976 (gnus-summary-position-point)))
6978 (defun gnus-summary-prev-page (&optional lines move)
6979 "Show previous page of selected article.
6980 Argument LINES specifies lines to be scrolled down.
6981 If MOVE, move to the previous unread article if point is at
6982 the beginning of the buffer."
6984 (let ((article (gnus-summary-article-number))
6985 (article-window (get-buffer-window gnus-article-buffer t))
6987 (gnus-configure-windows 'article)
6988 (if (or (null gnus-current-article)
6989 (null gnus-article-current)
6990 (/= article (cdr gnus-article-current))
6991 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
6992 ;; Selected subject is different from current article's.
6993 (gnus-summary-display-article article)
6994 (gnus-summary-recenter)
6995 (when article-window
6996 (gnus-eval-in-buffer-window gnus-article-buffer
6997 (setq endp (gnus-article-prev-page lines)))
6998 (when (and move endp)
7000 (gnus-message 3 "Beginning of message"))
7002 (if (and (eq gnus-summary-goto-unread 'never)
7003 (not (gnus-summary-first-article-p article)))
7004 (gnus-summary-prev-article)
7005 (gnus-summary-prev-unread-article))))))))
7006 (gnus-summary-position-point))
7008 (defun gnus-summary-prev-page-or-article (&optional lines)
7009 "Show previous page of selected article.
7010 Argument LINES specifies lines to be scrolled down.
7011 If at the beginning of the article, go to the next article."
7013 (gnus-summary-prev-page lines t))
7015 (defun gnus-summary-scroll-up (lines)
7016 "Scroll up (or down) one line current article.
7017 Argument LINES specifies lines to be scrolled up (or down if negative)."
7019 (gnus-configure-windows 'article)
7020 (gnus-summary-show-thread)
7021 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7022 (gnus-eval-in-buffer-window gnus-article-buffer
7024 (when (gnus-article-next-page lines)
7025 (gnus-message 3 "End of message")))
7027 (gnus-article-prev-page (- lines))))))
7028 (gnus-summary-recenter)
7029 (gnus-summary-position-point))
7031 (defun gnus-summary-scroll-down (lines)
7032 "Scroll down (or up) one line current article.
7033 Argument LINES specifies lines to be scrolled down (or up if negative)."
7035 (gnus-summary-scroll-up (- lines)))
7037 (defun gnus-summary-next-same-subject ()
7038 "Select next article which has the same subject as current one."
7040 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7042 (defun gnus-summary-prev-same-subject ()
7043 "Select previous article which has the same subject as current one."
7045 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7047 (defun gnus-summary-next-unread-same-subject ()
7048 "Select next unread article which has the same subject as current one."
7050 (gnus-summary-next-article t (gnus-summary-article-subject)))
7052 (defun gnus-summary-prev-unread-same-subject ()
7053 "Select previous unread article which has the same subject as current one."
7055 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7057 (defun gnus-summary-first-unread-article ()
7058 "Select the first unread article.
7059 Return nil if there are no unread articles."
7062 (when (gnus-summary-first-subject t)
7063 (gnus-summary-show-thread)
7064 (gnus-summary-first-subject t)
7065 (gnus-summary-display-article (gnus-summary-article-number)))
7066 (gnus-summary-position-point)))
7068 (defun gnus-summary-first-unread-subject ()
7069 "Place the point on the subject line of the first unread article.
7070 Return nil if there are no unread articles."
7073 (when (gnus-summary-first-subject t)
7074 (gnus-summary-show-thread)
7075 (gnus-summary-first-subject t))
7076 (gnus-summary-position-point)))
7078 (defun gnus-summary-first-unseen-subject ()
7079 "Place the point on the subject line of the first unseen article.
7080 Return nil if there are no unseen articles."
7083 (when (gnus-summary-first-subject t t t)
7084 (gnus-summary-show-thread)
7085 (gnus-summary-first-subject t t t))
7086 (gnus-summary-position-point)))
7088 (defun gnus-summary-first-unseen-or-unread-subject ()
7089 "Place the point on the subject line of the first unseen article.
7090 Return nil if there are no unseen articles."
7093 (unless (when (gnus-summary-first-subject t t t)
7094 (gnus-summary-show-thread)
7095 (gnus-summary-first-subject t t t))
7096 (when (gnus-summary-first-subject t)
7097 (gnus-summary-show-thread)
7098 (gnus-summary-first-subject t)))
7099 (gnus-summary-position-point)))
7101 (defun gnus-summary-first-article ()
7102 "Select the first article.
7103 Return nil if there are no articles."
7106 (when (gnus-summary-first-subject)
7107 (gnus-summary-show-thread)
7108 (gnus-summary-first-subject)
7109 (gnus-summary-display-article (gnus-summary-article-number)))
7110 (gnus-summary-position-point)))
7112 (defun gnus-summary-best-unread-article (&optional arg)
7113 "Select the unread article with the highest score.
7114 If given a prefix argument, select the next unread article that has a
7115 score higher than the default score."
7117 (let ((article (if arg
7118 (gnus-summary-better-unread-subject)
7119 (gnus-summary-best-unread-subject))))
7121 (gnus-summary-goto-article article)
7122 (error "No unread articles"))))
7124 (defun gnus-summary-best-unread-subject ()
7125 "Select the unread subject with the highest score."
7127 (let ((best -1000000)
7128 (data gnus-newsgroup-data)
7131 (and (gnus-data-unread-p (car data))
7133 (gnus-summary-article-score (gnus-data-number (car data))))
7136 article (gnus-data-number (car data))))
7137 (setq data (cdr data)))
7139 (gnus-summary-goto-subject article))
7140 (gnus-summary-position-point)
7143 (defun gnus-summary-better-unread-subject ()
7144 "Select the first unread subject that has a score over the default score."
7146 (let ((data gnus-newsgroup-data)
7148 (while (and (setq article (gnus-data-number (car data)))
7149 (or (gnus-data-read-p (car data))
7150 (not (> (gnus-summary-article-score article)
7151 gnus-summary-default-score))))
7152 (setq data (cdr data)))
7154 (gnus-summary-goto-subject article))
7155 (gnus-summary-position-point)
7158 (defun gnus-summary-last-subject ()
7159 "Go to the last displayed subject line in the group."
7160 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7162 (gnus-summary-goto-subject article))))
7164 (defun gnus-summary-goto-article (article &optional all-headers force)
7165 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7166 If ALL-HEADERS is non-nil, no header lines are hidden.
7167 If FORCE, go to the article even if it isn't displayed. If FORCE
7168 is a number, it is the line the article is to be displayed on."
7172 "Article number or Message-ID: "
7173 (mapcar (lambda (number) (list (int-to-string number)))
7174 gnus-newsgroup-limit))
7178 (if (and (stringp article)
7179 (string-match "@" article))
7180 (gnus-summary-refer-article article)
7181 (when (stringp article)
7182 (setq article (string-to-number article)))
7183 (if (gnus-summary-goto-subject article force)
7184 (gnus-summary-display-article article all-headers)
7185 (gnus-message 4 "Couldn't go to article %s" article) nil))
7186 (gnus-summary-position-point)))
7188 (defun gnus-summary-goto-last-article ()
7189 "Go to the previously read article."
7192 (when gnus-last-article
7193 (gnus-summary-goto-article gnus-last-article nil t))
7194 (gnus-summary-position-point)))
7196 (defun gnus-summary-pop-article (number)
7197 "Pop one article off the history and go to the previous.
7198 NUMBER articles will be popped off."
7201 (setq gnus-newsgroup-history
7202 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7204 (gnus-summary-goto-article (car to) nil t)
7205 (error "Article history empty")))
7206 (gnus-summary-position-point))
7208 ;; Summary commands and functions for limiting the summary buffer.
7210 (defun gnus-summary-limit-to-articles (n)
7211 "Limit the summary buffer to the next N articles.
7212 If not given a prefix, use the process marked articles instead."
7215 (let ((articles (gnus-summary-work-articles n)))
7216 (setq gnus-newsgroup-processable nil)
7217 (gnus-summary-limit articles))
7218 (gnus-summary-position-point)))
7220 (defun gnus-summary-pop-limit (&optional total)
7221 "Restore the previous limit.
7222 If given a prefix, remove all limits."
7225 (setq gnus-newsgroup-limits
7226 (list (mapcar (lambda (h) (mail-header-number h))
7227 gnus-newsgroup-headers))))
7228 (unless gnus-newsgroup-limits
7229 (error "No limit to pop"))
7231 (gnus-summary-limit nil 'pop)
7232 (gnus-summary-position-point)))
7234 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7235 "Limit the summary buffer to articles that have subjects that match a regexp.
7236 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7238 (list (read-string (if current-prefix-arg
7239 "Exclude subject (regexp): "
7240 "Limit to subject (regexp): "))
7241 nil current-prefix-arg))
7243 (setq header "subject"))
7244 (when (not (equal "" subject))
7246 (let ((articles (gnus-summary-find-matching
7247 (or header "subject") subject 'all nil nil
7250 (error "Found no matches for \"%s\"" subject))
7251 (gnus-summary-limit articles))
7252 (gnus-summary-position-point))))
7254 (defun gnus-summary-limit-to-author (from &optional not-matching)
7255 "Limit the summary buffer to articles that have authors that match a regexp.
7256 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7258 (list (read-string (if current-prefix-arg
7259 "Exclude author (regexp): "
7260 "Limit to author (regexp): "))
7261 current-prefix-arg))
7262 (gnus-summary-limit-to-subject from "from" not-matching))
7264 (defun gnus-summary-limit-to-age (age &optional younger-p)
7265 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7266 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7267 articles that are younger than AGE days."
7269 (let ((younger current-prefix-arg)
7272 (while (not days-got)
7273 (setq days (if younger
7274 (read-string "Limit to articles within (in days): ")
7275 (read-string "Limit to articles older than (in days): ")))
7276 (when (> (length days) 0)
7277 (setq days (read days)))
7283 (setq younger (not younger))
7284 (setq days (* days -1)))))
7285 (message "Please enter a number.")
7287 (list days younger)))
7289 (let ((data gnus-newsgroup-data)
7290 (cutoff (days-to-time age))
7291 articles d date is-younger)
7292 (while (setq d (pop data))
7293 (when (and (vectorp (gnus-data-header d))
7294 (setq date (mail-header-date (gnus-data-header d))))
7295 (setq is-younger (time-less-p
7296 (time-since (condition-case ()
7303 (push (gnus-data-number d) articles))))
7304 (gnus-summary-limit (nreverse articles)))
7305 (gnus-summary-position-point)))
7307 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7308 "Limit the summary buffer to articles that match an 'extra' header."
7312 (gnus-completing-read-with-default
7313 (symbol-name (car gnus-extra-headers))
7314 (if current-prefix-arg
7315 "Exclude extra header:"
7316 "Limit extra header:")
7318 (cons (symbol-name x) x))
7323 (read-string (format "%s header %s (regexp): "
7324 (if current-prefix-arg "Exclude" "Limit to")
7326 current-prefix-arg)))
7327 (when (not (equal "" regexp))
7329 (let ((articles (gnus-summary-find-matching
7330 (cons 'extra header) regexp 'all nil nil
7333 (error "Found no matches for \"%s\"" regexp))
7334 (gnus-summary-limit articles))
7335 (gnus-summary-position-point))))
7337 (defun gnus-summary-limit-to-display-predicate ()
7338 "Limit the summary buffer to the predicated in the `display' group parameter."
7340 (unless gnus-newsgroup-display
7341 (error "There is no `display' group parameter"))
7343 (dolist (number gnus-newsgroup-articles)
7344 (when (funcall gnus-newsgroup-display)
7345 (push number articles)))
7346 (gnus-summary-limit articles))
7347 (gnus-summary-position-point))
7349 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7351 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7353 (defun gnus-summary-limit-to-unread (&optional all)
7354 "Limit the summary buffer to articles that are not marked as read.
7355 If ALL is non-nil, limit strictly to unread articles."
7358 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7359 (gnus-summary-limit-to-marks
7360 ;; Concat all the marks that say that an article is read and have
7362 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7363 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7364 gnus-low-score-mark gnus-expirable-mark
7365 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7366 gnus-duplicate-mark gnus-souped-mark)
7369 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7370 (make-obsolete 'gnus-summary-delete-marked-with
7371 'gnus-summary-limit-exclude-marks)
7373 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7374 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7375 If REVERSE, limit the summary buffer to articles that are marked
7376 with MARKS. MARKS can either be a string of marks or a list of marks.
7377 Returns how many articles were removed."
7378 (interactive "sMarks: ")
7379 (gnus-summary-limit-to-marks marks t))
7381 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7382 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7383 If REVERSE (the prefix), limit the summary buffer to articles that are
7384 not marked with MARKS. MARKS can either be a string of marks or a
7386 Returns how many articles were removed."
7387 (interactive "sMarks: \nP")
7389 (let ((data gnus-newsgroup-data)
7390 (marks (if (listp marks) marks
7391 (append marks nil))) ; Transform to list.
7394 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7395 (memq (gnus-data-mark (car data)) marks))
7396 (push (gnus-data-number (car data)) articles))
7397 (setq data (cdr data)))
7398 (gnus-summary-limit articles))
7399 (gnus-summary-position-point)))
7401 (defun gnus-summary-limit-to-score (score)
7402 "Limit to articles with score at or above SCORE."
7403 (interactive "NLimit to articles with score of at least: ")
7404 (let ((data gnus-newsgroup-data)
7407 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7409 (push (gnus-data-number (car data)) articles))
7410 (setq data (cdr data)))
7412 (gnus-summary-limit articles)
7413 (gnus-summary-position-point))))
7415 (defun gnus-summary-limit-to-unseen ()
7416 "Limit to unseen articles."
7419 (gnus-summary-limit gnus-newsgroup-unseen)
7420 (gnus-summary-position-point)))
7422 (defun gnus-summary-limit-include-thread (id)
7423 "Display all the hidden articles that is in the thread with ID in it.
7424 When called interactively, ID is the Message-ID of the current
7426 (interactive (list (mail-header-id (gnus-summary-article-header))))
7427 (let ((articles (gnus-articles-in-thread
7428 (gnus-id-to-thread (gnus-root-id id)))))
7430 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7431 (gnus-summary-limit-include-matching-articles
7433 (regexp-quote (gnus-simplify-subject-re
7434 (mail-header-subject (gnus-id-to-header id)))))
7435 (gnus-summary-position-point))))
7437 (defun gnus-summary-limit-include-matching-articles (header regexp)
7438 "Display all the hidden articles that have HEADERs that match REGEXP."
7439 (interactive (list (read-string "Match on header: ")
7440 (read-string "Regexp: ")))
7441 (let ((articles (gnus-find-matching-articles header regexp)))
7443 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7444 (gnus-summary-position-point))))
7446 (defun gnus-summary-limit-include-dormant ()
7447 "Display all the hidden articles that are marked as dormant.
7448 Note that this command only works on a subset of the articles currently
7449 fetched for this group."
7451 (unless gnus-newsgroup-dormant
7452 (error "There are no dormant articles in this group"))
7454 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7455 (gnus-summary-position-point)))
7457 (defun gnus-summary-limit-exclude-dormant ()
7458 "Hide all dormant articles."
7461 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7462 (gnus-summary-position-point)))
7464 (defun gnus-summary-limit-exclude-childless-dormant ()
7465 "Hide all dormant articles that have no children."
7467 (let ((data (gnus-data-list t))
7468 articles d children)
7469 ;; Find all articles that are either not dormant or have
7471 (while (setq d (pop data))
7472 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7474 (gnus-article-children (gnus-data-number d)))
7477 (when (memq (car children) articles)
7482 (push (gnus-data-number d) articles)))
7485 (gnus-summary-limit articles)
7486 (gnus-summary-position-point))))
7488 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7489 "Mark all unread excluded articles as read.
7490 If ALL, mark even excluded ticked and dormants as read."
7492 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7493 (let ((articles (gnus-sorted-ndifference
7495 (mapcar (lambda (h) (mail-header-number h))
7496 gnus-newsgroup-headers)
7498 gnus-newsgroup-limit))
7500 (setq gnus-newsgroup-unreads
7501 (gnus-sorted-intersection gnus-newsgroup-unreads
7502 gnus-newsgroup-limit))
7504 (setq gnus-newsgroup-dormant nil
7505 gnus-newsgroup-marked nil
7506 gnus-newsgroup-reads
7508 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7509 gnus-newsgroup-reads))
7510 (while (setq article (pop articles))
7511 (unless (or (memq article gnus-newsgroup-dormant)
7512 (memq article gnus-newsgroup-marked))
7513 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7515 (defun gnus-summary-limit (articles &optional pop)
7517 ;; We pop the previous limit off the stack and use that.
7518 (setq articles (car gnus-newsgroup-limits)
7519 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7520 ;; We use the new limit, so we push the old limit on the stack.
7521 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7523 (setq gnus-newsgroup-limit articles)
7524 (let ((total (length gnus-newsgroup-data))
7525 (data (gnus-data-find-list (gnus-summary-article-number)))
7526 (gnus-summary-mark-below nil) ; Inhibit this.
7528 ;; This will do all the work of generating the new summary buffer
7529 ;; according to the new limit.
7530 (gnus-summary-prepare)
7531 ;; Hide any threads, possibly.
7532 (gnus-summary-maybe-hide-threads)
7533 ;; Try to return to the article you were at, or one in the
7536 ;; We try to find some article after the current one.
7538 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7541 (setq data (cdr data))))
7543 ;; If there is no data, that means that we were after the last
7544 ;; article. The same goes when we can't find any articles
7545 ;; after the current one.
7546 (goto-char (point-max))
7547 (gnus-summary-find-prev))
7548 (gnus-set-mode-line 'summary)
7549 ;; We return how many articles were removed from the summary
7550 ;; buffer as a result of the new limit.
7551 (- total (length gnus-newsgroup-data))))
7553 (defsubst gnus-invisible-cut-children (threads)
7556 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7561 (defsubst gnus-cut-thread (thread)
7562 "Go forwards in the thread until we find an article that we want to display."
7563 (when (or (eq gnus-fetch-old-headers 'some)
7564 (eq gnus-fetch-old-headers 'invisible)
7565 (numberp gnus-fetch-old-headers)
7566 (eq gnus-build-sparse-threads 'some)
7567 (eq gnus-build-sparse-threads 'more))
7568 ;; Deal with old-fetched headers and sparse threads.
7572 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7573 (gnus-summary-article-ancient-p
7574 (mail-header-number (car thread))))
7575 (if (or (<= (length (cdr thread)) 1)
7576 (eq gnus-fetch-old-headers 'invisible))
7577 (setq gnus-newsgroup-limit
7578 (delq (mail-header-number (car thread))
7579 gnus-newsgroup-limit)
7580 thread (cadr thread))
7581 (when (gnus-invisible-cut-children (cdr thread))
7582 (let ((th (cdr thread)))
7584 (if (memq (mail-header-number (caar th))
7585 gnus-newsgroup-limit)
7586 (setq thread (car th)
7588 (setq th (cdr th))))))))))
7591 (defun gnus-cut-threads (threads)
7592 "Cut off all uninteresting articles from the beginning of threads."
7593 (when (or (eq gnus-fetch-old-headers 'some)
7594 (eq gnus-fetch-old-headers 'invisible)
7595 (numberp gnus-fetch-old-headers)
7596 (eq gnus-build-sparse-threads 'some)
7597 (eq gnus-build-sparse-threads 'more))
7600 (setcar th (gnus-cut-thread (car th)))
7601 (setq th (cdr th)))))
7602 ;; Remove nixed out threads.
7605 (defun gnus-summary-initial-limit (&optional show-if-empty)
7606 "Figure out what the initial limit is supposed to be on group entry.
7607 This entails weeding out unwanted dormants, low-scored articles,
7608 fetch-old-headers verbiage, and so on."
7609 ;; Most groups have nothing to remove.
7610 (if (or gnus-inhibit-limiting
7611 (and (null gnus-newsgroup-dormant)
7612 (eq gnus-newsgroup-display 'gnus-not-ignore)
7613 (not (eq gnus-fetch-old-headers 'some))
7614 (not (numberp gnus-fetch-old-headers))
7615 (not (eq gnus-fetch-old-headers 'invisible))
7616 (null gnus-summary-expunge-below)
7617 (not (eq gnus-build-sparse-threads 'some))
7618 (not (eq gnus-build-sparse-threads 'more))
7619 (null gnus-thread-expunge-below)
7620 (not gnus-use-nocem)))
7622 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7623 (setq gnus-newsgroup-limit nil)
7626 (unless (car (symbol-value node))
7627 ;; These threads have no parents -- they are roots.
7628 (let ((nodes (cdr (symbol-value node)))
7631 (if (and gnus-thread-expunge-below
7632 (< (gnus-thread-total-score (car nodes))
7633 gnus-thread-expunge-below))
7634 (gnus-expunge-thread (pop nodes))
7635 (setq thread (pop nodes))
7636 (gnus-summary-limit-children thread))))))
7637 gnus-newsgroup-dependencies)
7638 ;; If this limitation resulted in an empty group, we might
7639 ;; pop the previous limit and use it instead.
7640 (when (and (not gnus-newsgroup-limit)
7642 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7643 gnus-newsgroup-limit))
7645 (defun gnus-summary-limit-children (thread)
7646 "Return 1 if this subthread is visible and 0 if it is not."
7647 ;; First we get the number of visible children to this thread. This
7648 ;; is done by recursing down the thread using this function, so this
7649 ;; will really go down to a leaf article first, before slowly
7650 ;; working its way up towards the root.
7654 (apply '+ (mapcar 'gnus-summary-limit-children
7657 (number (mail-header-number (car thread)))
7660 (not (memq number gnus-newsgroup-marked))
7662 ;; If this article is dormant and has absolutely no visible
7663 ;; children, then this article isn't visible.
7664 (and (memq number gnus-newsgroup-dormant)
7666 ;; If this is "fetch-old-headered" and there is no
7667 ;; visible children, then we don't want this article.
7668 (and (or (eq gnus-fetch-old-headers 'some)
7669 (numberp gnus-fetch-old-headers))
7670 (gnus-summary-article-ancient-p number)
7672 ;; If this is "fetch-old-headered" and `invisible', then
7673 ;; we don't want this article.
7674 (and (eq gnus-fetch-old-headers 'invisible)
7675 (gnus-summary-article-ancient-p number))
7676 ;; If this is a sparsely inserted article with no children,
7677 ;; we don't want it.
7678 (and (eq gnus-build-sparse-threads 'some)
7679 (gnus-summary-article-sparse-p number)
7681 ;; If we use expunging, and this article is really
7682 ;; low-scored, then we don't want this article.
7683 (when (and gnus-summary-expunge-below
7685 (or (cdr (assq number gnus-newsgroup-scored))
7686 gnus-summary-default-score))
7687 gnus-summary-expunge-below))
7688 ;; We increase the expunge-tally here, but that has
7689 ;; nothing to do with the limits, really.
7690 (incf gnus-newsgroup-expunged-tally)
7691 ;; We also mark as read here, if that's wanted.
7692 (when (and gnus-summary-mark-below
7693 (< score gnus-summary-mark-below))
7694 (setq gnus-newsgroup-unreads
7695 (delq number gnus-newsgroup-unreads))
7696 (if gnus-newsgroup-auto-expire
7697 (push number gnus-newsgroup-expirable)
7698 (push (cons number gnus-low-score-mark)
7699 gnus-newsgroup-reads)))
7701 ;; Do the `display' group parameter.
7702 (and gnus-newsgroup-display
7703 (not (funcall gnus-newsgroup-display)))
7704 ;; Check NoCeM things.
7705 (if (and gnus-use-nocem
7706 (gnus-nocem-unwanted-article-p
7707 (mail-header-id (car thread))))
7709 (setq gnus-newsgroup-unreads
7710 (delq number gnus-newsgroup-unreads))
7712 ;; Nope, invisible article.
7714 ;; Ok, this article is to be visible, so we add it to the limit
7716 (push number gnus-newsgroup-limit)
7719 (defun gnus-expunge-thread (thread)
7720 "Mark all articles in THREAD as read."
7721 (let* ((number (mail-header-number (car thread))))
7722 (incf gnus-newsgroup-expunged-tally)
7723 ;; We also mark as read here, if that's wanted.
7724 (setq gnus-newsgroup-unreads
7725 (delq number gnus-newsgroup-unreads))
7726 (if gnus-newsgroup-auto-expire
7727 (push number gnus-newsgroup-expirable)
7728 (push (cons number gnus-low-score-mark)
7729 gnus-newsgroup-reads)))
7730 ;; Go recursively through all subthreads.
7731 (mapcar 'gnus-expunge-thread (cdr thread)))
7733 ;; Summary article oriented commands
7735 (defun gnus-summary-refer-parent-article (n)
7736 "Refer parent article N times.
7737 If N is negative, go to ancestor -N instead.
7738 The difference between N and the number of articles fetched is returned."
7742 (when (not (natnump n))
7747 (setq header (gnus-summary-article-header))
7748 (if (and (eq (mail-header-number header)
7749 (cdr gnus-article-current))
7750 (equal gnus-newsgroup-name
7751 (car gnus-article-current)))
7752 ;; If we try to find the parent of the currently
7753 ;; displayed article, then we take a look at the actual
7754 ;; References header, since this is slightly more
7755 ;; reliable than the References field we got from the
7758 (set-buffer gnus-original-article-buffer)
7759 (nnheader-narrow-to-headers)
7760 (unless (setq ref (message-fetch-field "references"))
7761 (setq ref (message-fetch-field "in-reply-to")))
7764 ;; It's not the current article, so we take a bet on
7765 ;; the value we got from the server.
7766 (mail-header-references header)))
7768 (not (equal ref "")))
7769 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7770 (gnus-message 1 "Couldn't find parent"))
7771 (gnus-message 1 "No references in article %d"
7772 (gnus-summary-article-number))
7775 (gnus-summary-position-point)
7778 (defun gnus-summary-refer-references ()
7779 "Fetch all articles mentioned in the References header.
7780 Return the number of articles fetched."
7782 (let ((ref (mail-header-references (gnus-summary-article-header)))
7783 (current (gnus-summary-article-number))
7787 (error "No References in the current article")
7788 ;; For each Message-ID in the References header...
7789 (while (string-match "<[^>]*>" ref)
7791 ;; ... fetch that article.
7792 (gnus-summary-refer-article
7793 (prog1 (match-string 0 ref)
7794 (setq ref (substring ref (match-end 0))))))
7795 (gnus-summary-goto-subject current)
7796 (gnus-summary-position-point)
7799 (defun gnus-summary-refer-thread (&optional limit)
7800 "Fetch all articles in the current thread.
7801 If LIMIT (the numerical prefix), fetch that many old headers instead
7802 of what's specified by the `gnus-refer-thread-limit' variable."
7804 (let ((id (mail-header-id (gnus-summary-article-header)))
7805 (limit (if limit (prefix-numeric-value limit)
7806 gnus-refer-thread-limit)))
7807 ;; We want to fetch LIMIT *old* headers, but we also have to
7808 ;; re-fetch all the headers in the current buffer, because many of
7809 ;; them may be undisplayed. So we adjust LIMIT.
7810 (when (numberp limit)
7811 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7812 (unless (eq gnus-fetch-old-headers 'invisible)
7813 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7814 ;; Retrieve the headers and read them in.
7815 (if (eq (gnus-retrieve-headers
7816 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7818 (gnus-build-all-threads)
7819 (error "Can't fetch thread from backends that don't support NOV"))
7820 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7821 (gnus-summary-limit-include-thread id)))
7823 (defun gnus-summary-refer-article (message-id)
7824 "Fetch an article specified by MESSAGE-ID."
7825 (interactive "sMessage-ID: ")
7826 (when (and (stringp message-id)
7827 (not (zerop (length message-id))))
7828 ;; Construct the correct Message-ID if necessary.
7829 ;; Suggested by tale@pawl.rpi.edu.
7830 (unless (string-match "^<" message-id)
7831 (setq message-id (concat "<" message-id)))
7832 (unless (string-match ">$" message-id)
7833 (setq message-id (concat message-id ">")))
7834 (let* ((header (gnus-id-to-header message-id))
7836 (gnus-summary-article-sparse-p
7837 (mail-header-number header))
7838 (memq (mail-header-number header)
7839 gnus-newsgroup-limit)))
7842 ;; If the article is present in the buffer we just go to it.
7844 (or (not (gnus-summary-article-sparse-p
7845 (mail-header-number header)))
7848 (gnus-summary-goto-article
7849 (mail-header-number header) nil t)
7851 (gnus-summary-update-article (mail-header-number header)))))
7853 ;; We fetch the article.
7855 (dolist (gnus-override-method (gnus-refer-article-methods))
7856 (gnus-check-server gnus-override-method)
7857 ;; Fetch the header, and display the article.
7858 (when (setq number (gnus-summary-insert-subject message-id))
7859 (gnus-summary-select-article nil nil nil number)
7861 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7863 (defun gnus-refer-article-methods ()
7864 "Return a list of referrable methods."
7866 ;; No method, so we default to current and native.
7867 ((null gnus-refer-article-method)
7868 (list gnus-current-select-method gnus-select-method))
7870 ((eq 'current gnus-refer-article-method)
7871 (list gnus-current-select-method))
7872 ;; List of select methods.
7873 ((not (and (symbolp (car gnus-refer-article-method))
7874 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7876 (dolist (method gnus-refer-article-method)
7877 (push (if (eq 'current method)
7878 gnus-current-select-method
7882 ;; One single select method.
7884 (list gnus-refer-article-method))))
7886 (defun gnus-summary-edit-parameters ()
7887 "Edit the group parameters of the current group."
7889 (gnus-group-edit-group gnus-newsgroup-name 'params))
7891 (defun gnus-summary-customize-parameters ()
7892 "Customize the group parameters of the current group."
7894 (gnus-group-customize gnus-newsgroup-name))
7896 (defun gnus-summary-enter-digest-group (&optional force)
7897 "Enter an nndoc group based on the current article.
7898 If FORCE, force a digest interpretation. If not, try
7899 to guess what the document format is."
7901 (let ((conf gnus-current-window-configuration))
7903 (gnus-summary-select-article))
7904 (setq gnus-current-window-configuration conf)
7905 (let* ((name (format "%s-%d"
7906 (gnus-group-prefixed-name
7907 gnus-newsgroup-name (list 'nndoc ""))
7909 (set-buffer gnus-summary-buffer)
7910 gnus-current-article)))
7911 (ogroup gnus-newsgroup-name)
7912 (params (append (gnus-info-params (gnus-get-info ogroup))
7913 (list (cons 'to-group ogroup))
7914 (list (cons 'save-article-group ogroup))))
7915 (case-fold-search t)
7916 (buf (current-buffer))
7919 (set-buffer gnus-original-article-buffer)
7920 ;; Have the digest group inherit the main mail address of
7921 ;; the parent article.
7922 (when (setq to-address (or (gnus-fetch-field "reply-to")
7923 (gnus-fetch-field "from")))
7924 (setq params (append
7925 (list (cons 'to-address
7926 (funcall gnus-decode-encoded-word-function
7928 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7929 (insert-buffer-substring gnus-original-article-buffer)
7930 ;; Remove lines that may lead nndoc to misinterpret the
7933 (goto-char (point-min))
7934 (or (search-forward "\n\n" nil t) (point)))
7935 (goto-char (point-min))
7936 (delete-matching-lines "^Path:\\|^From ")
7939 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7940 (gnus-newsgroup-ephemeral-ignored-charsets
7941 gnus-newsgroup-ignored-charsets))
7942 (gnus-group-read-ephemeral-group
7943 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
7945 ,(if force 'mbox 'guess)))
7947 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
7949 ;; Make all postings to this group go to the parent group.
7950 (nconc (gnus-info-params (gnus-get-info name))
7952 ;; Couldn't select this doc group.
7953 (switch-to-buffer buf)
7954 (gnus-set-global-variables)
7955 (gnus-configure-windows 'summary)
7956 (gnus-message 3 "Article couldn't be entered?"))
7957 (kill-buffer dig)))))
7959 (defun gnus-summary-read-document (n)
7960 "Open a new group based on the current article(s).
7961 This will allow you to read digests and other similar
7962 documents as newsgroups.
7963 Obeys the standard process/prefix convention."
7965 (let* ((articles (gnus-summary-work-articles n))
7966 (ogroup gnus-newsgroup-name)
7967 (params (append (gnus-info-params (gnus-get-info ogroup))
7968 (list (cons 'to-group ogroup))))
7969 article group egroup groups vgroup)
7970 (while (setq article (pop articles))
7971 (setq group (format "%s-%d" gnus-newsgroup-name article))
7972 (gnus-summary-remove-process-mark article)
7973 (when (gnus-summary-display-article article)
7976 (insert-buffer-substring gnus-original-article-buffer)
7977 ;; Remove some headers that may lead nndoc to make
7979 (message-narrow-to-head)
7980 (goto-char (point-min))
7981 (delete-matching-lines "^\\(Path\\):\\|^From ")
7984 (gnus-group-read-ephemeral-group
7985 group `(nndoc ,group (nndoc-address ,(current-buffer))
7986 (nndoc-article-type guess))
7989 ;; Make all postings to this group go to the parent group.
7990 (nconc (gnus-info-params (gnus-get-info egroup))
7992 (push egroup groups))
7993 ;; Couldn't select this doc group.
7994 (gnus-error 3 "Article couldn't be entered"))))))
7995 ;; Now we have selected all the documents.
7998 (error "None of the articles could be interpreted as documents"))
7999 ((gnus-group-read-ephemeral-group
8000 (setq vgroup (format
8001 "nnvirtual:%s-%s" gnus-newsgroup-name
8002 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8003 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8005 (cons (current-buffer) 'summary)))
8007 (error "Couldn't select virtual nndoc group")))))
8009 (defun gnus-summary-isearch-article (&optional regexp-p)
8010 "Do incremental search forward on the current article.
8011 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8013 (let* ((gnus-inhibit-treatment t)
8014 (old (gnus-summary-select-article)))
8015 (gnus-configure-windows 'article)
8016 (gnus-eval-in-buffer-window gnus-article-buffer
8020 (gnus-article-show-all-headers))
8021 (goto-char (point-min))
8022 (isearch-forward regexp-p)))))
8024 (defun gnus-summary-search-article-forward (regexp &optional backward)
8025 "Search for an article containing REGEXP forward.
8026 If BACKWARD, search backward instead."
8029 (format "Search article %s (regexp%s): "
8030 (if current-prefix-arg "backward" "forward")
8031 (if gnus-last-search-regexp
8032 (concat ", default " gnus-last-search-regexp)
8034 current-prefix-arg))
8035 (if (string-equal regexp "")
8036 (setq regexp (or gnus-last-search-regexp ""))
8037 (setq gnus-last-search-regexp regexp)
8038 (setq gnus-article-before-search gnus-current-article))
8039 ;; Intentionally set gnus-last-article.
8040 (setq gnus-last-article gnus-article-before-search)
8041 (let ((gnus-last-article gnus-last-article))
8042 (if (gnus-summary-search-article regexp backward)
8043 (gnus-summary-show-thread)
8044 (error "Search failed: \"%s\"" regexp))))
8046 (defun gnus-summary-search-article-backward (regexp)
8047 "Search for an article containing REGEXP backward."
8050 (format "Search article backward (regexp%s): "
8051 (if gnus-last-search-regexp
8052 (concat ", default " gnus-last-search-regexp)
8054 (gnus-summary-search-article-forward regexp 'backward))
8057 (defmacro gnus-summary-search-article-position-point (regexp backward)
8058 "Dehighlight the last matched text and goto the beginning position."
8059 (` (if (and gnus-summary-search-article-matched-data
8060 (let ((text (caddr gnus-summary-search-article-matched-data))
8061 (inhibit-read-only t)
8064 (goto-char (car gnus-summary-search-article-matched-data))
8065 (cadr gnus-summary-search-article-matched-data))
8067 (string-match (, regexp) text)))
8068 (if (, backward) (beginning-of-line) (end-of-line))
8069 (goto-char (if (, backward) (point-max) (point-min))))))
8071 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8072 "Place point where X-Face image is displayed."
8073 (if (featurep 'xemacs)
8074 (` (let ((end (if (search-forward "\n\n" nil t)
8075 (goto-char (1- (point)))
8078 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8079 (unless (and (re-search-forward "^From:" end t)
8080 (setq extent (extent-at (point)))
8081 (extent-begin-glyph extent))
8082 (goto-char (, opoint)))))
8083 (` (let ((end (if (search-forward "\n\n" nil t)
8084 (goto-char (1- (point)))
8086 (start (or (search-backward "\n\n" nil t) (point-min))))
8088 (or (text-property-any start end 'x-face-image t);; x-face-e21
8089 (text-property-any start end 'x-face-mule-bitmap-image t)
8092 (defmacro gnus-summary-search-article-highlight-matched-text
8093 (backward treated x-face)
8094 "Highlight matched text in the function `gnus-summary-search-article'."
8095 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8096 (end (set-marker (make-marker) (match-end 0)))
8097 (inhibit-read-only t)
8101 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8103 (lambda (item) (setq items (delq item items)))
8104 '(gnus-treat-buttonize
8105 gnus-treat-fill-article
8106 gnus-treat-fill-long-lines
8107 gnus-treat-emphasize
8108 gnus-treat-highlight-headers
8109 gnus-treat-highlight-citation
8110 gnus-treat-highlight-signature
8111 gnus-treat-overstrike
8112 gnus-treat-display-xface
8113 gnus-treat-buttonize-head
8114 gnus-treat-decode-article-as-default-mime-charset))
8115 (static-if (featurep 'xemacs)
8117 (cons '(x-face-mule-delete-x-face-field
8120 (gnus-treat-display-xface
8121 (when (, x-face) gnus-treat-display-xface)))
8122 (gnus-article-prepare-mime-display)))
8123 (goto-char (if (, backward) start end))
8125 (gnus-summary-search-article-highlight-goto-x-face (point)))
8126 (setq gnus-summary-search-article-matched-data
8127 (list start end (buffer-substring start end)))
8128 (unless (eq start end);; matched text has been deleted. :-<
8129 (put-text-property start end 'face
8130 (or (find-face 'isearch)
8131 'secondary-selection))))))
8134 (defun gnus-summary-search-article (regexp &optional backward)
8135 "Search for an article containing REGEXP.
8136 Optional argument BACKWARD means do search for backward.
8137 `gnus-select-article-hook' is not called during the search."
8138 ;; We have to require this here to make sure that the following
8139 ;; dynamic binding isn't shadowed by autoloading.
8140 (require 'gnus-async)
8142 (let ((gnus-select-article-hook nil) ;Disable hook.
8143 (gnus-article-prepare-hook nil)
8144 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8145 (gnus-use-article-prefetch nil)
8146 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8147 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8148 (sum (current-buffer))
8151 (gnus-save-hidden-threads
8152 (static-if (featurep 'xemacs)
8153 (let ((gnus-inhibit-treatment t))
8154 (setq treated (eq 'old (gnus-summary-select-article)))
8156 (not (and (gnus-buffer-live-p gnus-article-buffer)
8157 (window-live-p (get-buffer-window
8158 gnus-article-buffer t)))))
8159 (gnus-summary-select-article nil t)
8160 (setq treated nil)))
8161 (let ((gnus-inhibit-treatment t)
8162 (x-face-mule-delete-x-face-field 'never))
8163 (setq treated (eq 'old (gnus-summary-select-article)))
8166 (and (gnus-buffer-live-p gnus-article-buffer)
8167 (window-live-p (get-buffer-window
8168 gnus-article-buffer t))
8169 (or (not (string-match "^\\^X-Face:" regexp))
8170 (with-current-buffer gnus-article-buffer
8171 gnus-summary-search-article-matched-data)))))
8172 (gnus-summary-select-article nil t)
8173 (setq treated nil))))
8174 (set-buffer gnus-article-buffer)
8178 (gnus-article-show-all-headers)
8179 (gnus-summary-search-article-position-point regexp backward))
8180 (goto-char (if backward (point-max) (point-min))))
8182 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8184 (re-search-backward regexp nil t)
8185 (re-search-forward regexp nil t))
8186 ;; We found the regexp.
8188 (gnus-summary-search-article-highlight-matched-text
8189 backward treated (string-match "^\\^X-Face:" regexp))
8192 (/ (- 2 (window-height
8193 (get-buffer-window gnus-article-buffer t)))
8196 (get-buffer-window (current-buffer))
8199 (setq point (point)))
8200 ;; We didn't find it, so we go to the next article.
8203 (while (eq found 'not)
8204 (if (not (if backward (gnus-summary-find-prev)
8205 (gnus-summary-find-next)))
8206 ;; No more articles.
8208 ;; Select the next article and adjust point.
8209 (unless (gnus-summary-article-sparse-p
8210 (gnus-summary-article-number))
8212 (let ((gnus-inhibit-treatment t))
8213 (gnus-summary-select-article))
8215 (set-buffer gnus-article-buffer)
8217 (goto-char (if backward (point-max) (point-min))))))))
8218 (gnus-message 7 ""))
8219 ;; Return whether we found the regexp.
8220 (when (eq found 'found)
8222 (gnus-summary-show-thread)
8223 (gnus-summary-goto-subject gnus-current-article)
8224 (gnus-summary-position-point)
8227 (defun gnus-find-matching-articles (header regexp)
8228 "Return a list of all articles that match REGEXP on HEADER.
8229 This search includes all articles in the current group that Gnus has
8230 fetched headers for, whether they are displayed or not."
8231 (let ((articles nil)
8232 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8233 (case-fold-search t))
8234 (dolist (header gnus-newsgroup-headers)
8235 (when (string-match regexp (funcall func header))
8236 (push (mail-header-number header) articles)))
8237 (nreverse articles)))
8239 (defun gnus-summary-find-matching (header regexp &optional backward unread
8240 not-case-fold not-matching)
8241 "Return a list of all articles that match REGEXP on HEADER.
8242 The search stars on the current article and goes forwards unless
8243 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8244 If UNREAD is non-nil, only unread articles will
8245 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8246 in the comparisons. If NOT-MATCHING, return a list of all articles that
8247 not match REGEXP on HEADER."
8248 (let ((case-fold-search (not not-case-fold))
8251 (if (eq (car header) 'extra)
8254 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8256 (error "%s is an invalid header" header))
8257 (unless (fboundp (intern (concat "mail-header-" header)))
8258 (error "%s is not a valid header" header))
8259 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8260 (dolist (d (if (eq backward 'all)
8262 (gnus-data-find-list
8263 (gnus-summary-article-number)
8264 (gnus-data-list backward))))
8265 (when (and (or (not unread) ; We want all articles...
8266 (gnus-data-unread-p d)) ; Or just unreads.
8267 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8271 (funcall func (gnus-data-header d))))
8272 (string-match regexp
8273 (funcall func (gnus-data-header d)))))
8274 (push (gnus-data-number d) articles))) ; Success!
8275 (nreverse articles)))
8277 (defun gnus-summary-execute-command (header regexp command &optional backward)
8278 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8279 If HEADER is an empty string (or nil), the match is done on the entire
8280 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8282 (list (let ((completion-ignore-case t))
8285 (mapcar (lambda (header) (list (format "%s" header)))
8287 '("Number" "Subject" "From" "Lines" "Date"
8288 "Message-ID" "Xref" "References" "Body")
8289 gnus-extra-headers))
8290 nil 'require-match))
8291 (read-string "Regexp: ")
8292 (read-key-sequence "Command: ")
8293 current-prefix-arg))
8294 (when (equal header "Body")
8296 ;; Hidden thread subtrees must be searched as well.
8297 (gnus-summary-show-all-threads)
8298 ;; We don't want to change current point nor window configuration.
8300 (save-window-excursion
8301 (gnus-message 6 "Executing %s..." (key-description command))
8302 ;; We'd like to execute COMMAND interactively so as to give arguments.
8303 (gnus-execute header regexp
8304 `(call-interactively ',(key-binding command))
8306 (gnus-message 6 "Executing %s...done" (key-description command)))))
8308 (defun gnus-summary-beginning-of-article ()
8309 "Scroll the article back to the beginning."
8311 (gnus-summary-select-article)
8312 (gnus-configure-windows 'article)
8313 (gnus-eval-in-buffer-window gnus-article-buffer
8315 (goto-char (point-min))
8316 (when gnus-page-broken
8317 (gnus-narrow-to-page))))
8319 (defun gnus-summary-end-of-article ()
8320 "Scroll to the end of the article."
8322 (gnus-summary-select-article)
8323 (gnus-configure-windows 'article)
8324 (gnus-eval-in-buffer-window gnus-article-buffer
8326 (goto-char (point-max))
8328 (when gnus-page-broken
8329 (gnus-narrow-to-page))))
8331 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8332 "Truncate to LEN and quote all \"(\"'s in STRING."
8333 (gnus-replace-in-string (if (and len (> (length string) len))
8334 (substring string 0 len)
8338 (defun gnus-summary-print-article (&optional filename n)
8339 "Generate and print a PostScript image of the N next (mail) articles.
8341 If N is negative, print the N previous articles. If N is nil and articles
8342 have been marked with the process mark, print these instead.
8344 If the optional first argument FILENAME is nil, send the image to the
8345 printer. If FILENAME is a string, save the PostScript image in a file with
8346 that name. If FILENAME is a number, prompt the user for the name of the file
8348 (interactive (list (ps-print-preprint current-prefix-arg)))
8349 (dolist (article (gnus-summary-work-articles n))
8350 (gnus-summary-select-article nil nil 'pseudo article)
8351 (gnus-eval-in-buffer-window gnus-article-buffer
8352 (gnus-print-buffer))
8353 (gnus-summary-remove-process-mark article))
8354 (ps-despool filename))
8356 (defun gnus-print-buffer ()
8357 (let ((buffer (generate-new-buffer " *print*")))
8360 (copy-to-buffer buffer (point-min) (point-max))
8362 (gnus-article-delete-invisible-text)
8363 (gnus-remove-text-with-property 'gnus-decoration)
8364 (when (gnus-visual-p 'article-highlight 'highlight)
8365 ;; Copy-to-buffer doesn't copy overlay. So redo
8367 (let ((gnus-article-buffer buffer))
8368 (gnus-article-highlight-citation t)
8369 (gnus-article-highlight-signature)))
8370 (let ((ps-left-header
8373 (gnus-summary-print-truncate-and-quote
8374 (mail-header-subject gnus-current-headers)
8377 (gnus-summary-print-truncate-and-quote
8378 (mail-header-from gnus-current-headers)
8382 "/pagenumberstring load"
8384 (mail-header-date gnus-current-headers) ")"))))
8385 (gnus-run-hooks 'gnus-ps-print-hook)
8388 (ps-spool-buffer-with-faces)
8389 (ps-spool-buffer)))))
8390 (kill-buffer buffer))))
8392 (defun gnus-summary-show-article (&optional arg)
8393 "Force redisplaying of the current article.
8394 If ARG (the prefix) is a number, show the article with the charset
8395 defined in `gnus-summary-show-article-charset-alist', or the charset
8397 If ARG (the prefix) is non-nil and not a number, show the raw article
8398 without any article massaging functions being run. Normally, the key strokes
8403 (gnus-summary-show-article t)
8404 (let* ((gnus-newsgroup-charset
8405 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8406 (mm-read-coding-system
8407 "View as charset: " ;; actually it is coding system.
8409 (set-buffer gnus-article-buffer)
8410 (mm-detect-coding-region (point) (point-max))))))
8411 (default-mime-charset gnus-newsgroup-charset)
8412 (gnus-newsgroup-ignored-charsets 'gnus-all))
8413 (gnus-summary-select-article nil 'force)
8414 (let ((deps gnus-newsgroup-dependencies)
8417 (set-buffer gnus-original-article-buffer)
8419 (message-narrow-to-head)
8420 (setq head (buffer-string))
8421 (goto-char (point-min))
8422 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8423 (goto-char (point-max))
8425 (setq lines (1- (count-lines (point) (point-max))))))
8427 (insert (format "211 %d Article retrieved.\n"
8428 (cdr gnus-article-current)))
8430 (if lines (insert (format "Lines: %d\n" lines)))
8432 (let ((nntp-server-buffer (current-buffer)))
8433 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8434 (gnus-data-set-header
8435 (gnus-data-find (cdr gnus-article-current))
8437 (gnus-summary-update-article-line
8438 (cdr gnus-article-current) header)
8439 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8440 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8442 ;; Select the article the normal way.
8443 (gnus-summary-select-article nil 'force))
8445 ;; We have to require this here to make sure that the following
8446 ;; dynamic binding isn't shadowed by autoloading.
8447 (require 'gnus-async)
8449 ;; Bind the article treatment functions to nil.
8450 (let ((gnus-have-all-headers t)
8451 gnus-article-prepare-hook
8452 gnus-article-decode-hook
8455 (gnus-inhibit-treatment t))
8456 (gnus-summary-select-article nil 'force))))
8457 (gnus-summary-goto-subject gnus-current-article)
8458 (gnus-summary-position-point))
8460 (defun gnus-summary-show-raw-article ()
8461 "Show the raw article without any article massaging functions being run."
8463 (gnus-summary-show-article t))
8465 (defun gnus-summary-verbose-headers (&optional arg)
8466 "Toggle permanent full header display.
8467 If ARG is a positive number, turn header display on.
8468 If ARG is a negative number, turn header display off."
8470 (setq gnus-show-all-headers
8471 (cond ((or (not (numberp arg))
8473 (not gnus-show-all-headers))
8476 (gnus-summary-show-article))
8478 (defun gnus-summary-toggle-header (&optional arg)
8479 "Show the headers if they are hidden, or hide them if they are shown.
8480 If ARG is a positive number, show the entire header.
8481 If ARG is a negative number, hide the unwanted header lines."
8483 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8484 (get-buffer-window gnus-article-buffer t))))
8485 (with-current-buffer gnus-article-buffer
8487 (article-narrow-to-head)
8488 (let* ((buffer-read-only nil)
8489 (inhibit-point-motion-hooks t)
8490 (hidden (if (numberp arg)
8492 (gnus-article-hidden-text-p 'headers)))
8494 (delete-region (point-min) (point-max))
8495 (with-current-buffer gnus-original-article-buffer
8496 (goto-char (setq s (point-min)))
8497 (setq e (if (search-forward "\n\n" nil t)
8500 (insert-buffer-substring gnus-original-article-buffer s e)
8501 (article-decode-encoded-words)
8503 (let ((gnus-treat-hide-headers nil)
8504 (gnus-treat-hide-boring-headers nil))
8505 (gnus-delete-wash-type 'headers)
8506 (gnus-treat-article 'head))
8507 (gnus-treat-article 'head))
8510 (set-window-start window (goto-char (point-min))))
8511 (setq gnus-page-broken
8512 (when gnus-break-pages
8513 (gnus-narrow-to-page)
8515 (gnus-set-mode-line 'article)))))
8517 (defun gnus-summary-show-all-headers ()
8518 "Make all header lines visible."
8520 (gnus-summary-toggle-header 1))
8522 (defun gnus-summary-toggle-mime (&optional arg)
8523 "Toggle MIME processing.
8524 If ARG is a positive number, turn MIME processing on."
8526 (setq gnus-show-mime
8528 (not gnus-show-mime)
8529 (> (prefix-numeric-value arg) 0)))
8530 (gnus-summary-select-article t 'force))
8532 (defun gnus-summary-caesar-message (&optional arg)
8533 "Caesar rotate the current article by 13.
8534 The numerical prefix specifies how many places to rotate each letter
8537 (gnus-summary-select-article)
8538 (let ((mail-header-separator ""))
8539 (gnus-eval-in-buffer-window gnus-article-buffer
8542 (let ((start (window-start))
8544 (message-caesar-buffer-body arg)
8545 (set-window-start (get-buffer-window (current-buffer)) start))))))
8547 (defun gnus-summary-stop-page-breaking ()
8548 "Stop page breaking in the current article."
8550 (gnus-summary-select-article)
8551 (gnus-eval-in-buffer-window gnus-article-buffer
8553 (when (gnus-visual-p 'page-marker)
8554 (let ((buffer-read-only nil))
8555 (gnus-remove-text-with-property 'gnus-prev)
8556 (gnus-remove-text-with-property 'gnus-next))
8557 (setq gnus-page-broken nil))))
8559 (defun gnus-summary-move-article (&optional n to-newsgroup
8560 select-method action)
8561 "Move the current article to a different newsgroup.
8562 If N is a positive number, move the N next articles.
8563 If N is a negative number, move the N previous articles.
8564 If N is nil and any articles have been marked with the process mark,
8565 move those articles instead.
8566 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8567 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8568 re-spool using this method.
8570 When called interactively with TO-NEWSGROUP being nil, the value of
8571 the variable `gnus-move-split-methods' is used for finding a default
8572 for the target newsgroup.
8574 For this function to work, both the current newsgroup and the
8575 newsgroup that you want to move to have to support the `request-move'
8576 and `request-accept' functions.
8578 ACTION can be either `move' (the default), `crosspost' or `copy'."
8581 (setq action 'move))
8582 ;; Check whether the source group supports the required functions.
8583 (cond ((and (eq action 'move)
8584 (not (gnus-check-backend-function
8585 'request-move-article gnus-newsgroup-name)))
8586 (error "The current group does not support article moving"))
8587 ((and (eq action 'crosspost)
8588 (not (gnus-check-backend-function
8589 'request-replace-article gnus-newsgroup-name)))
8590 (error "The current group does not support article editing")))
8591 (let ((articles (gnus-summary-work-articles n))
8592 (prefix (if (gnus-check-backend-function
8593 'request-move-article gnus-newsgroup-name)
8594 (gnus-group-real-prefix gnus-newsgroup-name)
8596 (names '((move "Move" "Moving")
8597 (copy "Copy" "Copying")
8598 (crosspost "Crosspost" "Crossposting")))
8599 (copy-buf (save-excursion
8600 (nnheader-set-temp-buffer " *copy article*")))
8601 (default-marks gnus-article-mark-lists)
8602 (no-expire-marks (delete '(expirable . expire)
8603 (copy-sequence gnus-article-mark-lists)))
8604 art-group to-method new-xref article to-groups)
8605 (unless (assq action names)
8606 (error "Unknown action %s" action))
8607 ;; Read the newsgroup name.
8608 (when (and (not to-newsgroup)
8609 (not select-method))
8610 (if (and gnus-move-split-methods
8612 (and (memq gnus-current-article articles)
8613 (gnus-buffer-live-p gnus-original-article-buffer))))
8614 ;; When `gnus-move-split-methods' is non-nil, we have to
8615 ;; select an article to give `gnus-read-move-group-name' an
8616 ;; opportunity to suggest an appropriate default. However,
8617 ;; we needn't render or mark the article.
8618 (let ((gnus-display-mime-function nil)
8619 (gnus-article-prepare-hook nil)
8620 (gnus-mark-article-hook nil))
8621 (gnus-summary-select-article nil nil nil (car articles))))
8623 (gnus-read-move-group-name
8624 (cadr (assq action names))
8625 (symbol-value (intern (format "gnus-current-%s-group" action)))
8627 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8628 (setq to-method (or select-method
8629 (gnus-server-to-method
8630 (gnus-group-method to-newsgroup))))
8631 ;; Check the method we are to move this article to...
8632 (unless (gnus-check-backend-function
8633 'request-accept-article (car to-method))
8634 (error "%s does not support article copying" (car to-method)))
8635 (unless (gnus-check-server to-method)
8636 (error "Can't open server %s" (car to-method)))
8637 (gnus-message 6 "%s to %s: %s..."
8638 (caddr (assq action names))
8639 (or (car select-method) to-newsgroup) articles)
8641 (setq article (pop articles))
8645 ;; Move the article.
8647 ;; Remove this article from future suppression.
8648 (gnus-dup-unsuppress-article article)
8649 (gnus-request-move-article
8650 article ; Article to move
8651 gnus-newsgroup-name ; From newsgroup
8652 (nth 1 (gnus-find-method-for-group
8653 gnus-newsgroup-name)) ; Server
8654 (list 'gnus-request-accept-article
8655 to-newsgroup (list 'quote select-method)
8656 (not articles) t) ; Accept form
8657 (not articles))) ; Only save nov last time
8658 ;; Copy the article.
8661 (set-buffer copy-buf)
8662 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8663 (gnus-request-accept-article
8664 to-newsgroup select-method (not articles) t))))
8665 ;; Crosspost the article.
8666 ((eq action 'crosspost)
8667 (let ((xref (message-tokenize-header
8668 (mail-header-xref (gnus-summary-article-header article))
8670 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8671 ":" (number-to-string article)))
8673 (setq xref (list (system-name))))
8676 (mapconcat 'identity
8677 (delete "Xref:" (delete new-xref xref))
8681 (set-buffer copy-buf)
8682 ;; First put the article in the destination group.
8683 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8684 (when (consp (setq art-group
8685 (gnus-request-accept-article
8686 to-newsgroup select-method (not articles))))
8687 (setq new-xref (concat new-xref " " (car art-group)
8689 (number-to-string (cdr art-group))))
8690 ;; Now we have the new Xrefs header, so we insert
8691 ;; it and replace the new article.
8692 (nnheader-replace-header "Xref" new-xref)
8693 (gnus-request-replace-article
8694 (cdr art-group) to-newsgroup (current-buffer))
8698 (gnus-message 1 "Couldn't %s article %s: %s"
8699 (cadr (assq action names)) article
8700 (nnheader-get-report (car to-method))))
8701 ((eq art-group 'junk)
8702 (when (eq action 'move)
8703 (gnus-summary-mark-article article gnus-canceled-mark)
8704 (gnus-message 4 "Deleted article %s" article)))
8706 (let* ((pto-group (gnus-group-prefixed-name
8707 (car art-group) to-method))
8709 (gnus-gethash pto-group gnus-newsrc-hashtb))
8710 (info (nth 2 entry))
8711 (to-group (gnus-info-group info))
8713 ;; Update the group that has been moved to.
8715 (memq action '(move copy)))
8716 (unless (member to-group to-groups)
8717 (push to-group to-groups))
8719 (unless (memq article gnus-newsgroup-unreads)
8720 (push 'read to-marks)
8722 info (gnus-add-to-range (gnus-info-read info)
8723 (list (cdr art-group)))))
8725 ;; See whether the article is to be put in the cache.
8726 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8729 (to-article (cdr art-group)))
8731 ;; Enter the article into the cache in the new group,
8732 ;; if that is required.
8733 (when gnus-use-cache
8734 (gnus-cache-possibly-enter-article
8736 (let ((header (copy-sequence
8737 (gnus-summary-article-header article))))
8738 (mail-header-set-number header to-article)
8740 (memq article gnus-newsgroup-marked)
8741 (memq article gnus-newsgroup-dormant)
8742 (memq article gnus-newsgroup-unreads)))
8744 (when gnus-preserve-marks
8745 ;; Copy any marks over to the new group.
8746 (when (and (equal to-group gnus-newsgroup-name)
8747 (not (memq article gnus-newsgroup-unreads)))
8748 ;; Mark this article as read in this group.
8749 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8750 (setcdr (gnus-active to-group) to-article)
8751 (setcdr gnus-newsgroup-active to-article))
8754 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8755 (when (memq article (symbol-value
8756 (intern (format "gnus-newsgroup-%s"
8758 (push (cdar marks) to-marks)
8759 ;; If the other group is the same as this group,
8760 ;; then we have to add the mark to the list.
8761 (when (equal to-group gnus-newsgroup-name)
8762 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8765 (intern (format "gnus-newsgroup-%s"
8767 ;; Copy the marks to other group.
8768 (gnus-add-marked-articles
8769 to-group (cdar marks) (list to-article) info)))
8770 (setq marks (cdr marks)))
8772 (gnus-request-set-mark to-group (list (list (list to-article)
8777 (concat "(gnus-group-set-info '"
8778 (gnus-prin1-to-string (gnus-get-info to-group))
8781 ;; Update the Xref header in this article to point to
8782 ;; the new crossposted article we have just created.
8783 (when (eq action 'crosspost)
8785 (set-buffer copy-buf)
8786 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8787 (nnheader-replace-header "Xref" new-xref)
8788 (gnus-request-replace-article
8789 article gnus-newsgroup-name (current-buffer)))))
8791 ;;;!!!Why is this necessary?
8792 (set-buffer gnus-summary-buffer)
8794 (gnus-summary-goto-subject article)
8795 (when (eq action 'move)
8796 (gnus-summary-mark-article article gnus-canceled-mark))))
8797 (gnus-summary-remove-process-mark article))
8798 ;; Re-activate all groups that have been moved to.
8800 (set-buffer gnus-group-buffer)
8801 (let ((gnus-group-marked to-groups))
8802 (gnus-group-get-new-news-this-group nil t)))
8804 (gnus-kill-buffer copy-buf)
8805 (gnus-summary-position-point)
8806 (gnus-set-mode-line 'summary)))
8808 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8809 "Move the current article to a different newsgroup.
8810 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8811 When called interactively, if TO-NEWSGROUP is nil, use the value of
8812 the variable `gnus-move-split-methods' for finding a default target
8814 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8815 re-spool using this method."
8817 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8819 (defun gnus-summary-crosspost-article (&optional n)
8820 "Crosspost the current article to some other group."
8822 (gnus-summary-move-article n nil nil 'crosspost))
8824 (defcustom gnus-summary-respool-default-method nil
8825 "Default method type for respooling an article.
8826 If nil, use to the current newsgroup method."
8828 :group 'gnus-summary-mail)
8830 (defun gnus-summary-respool-article (&optional n method)
8831 "Respool the current article.
8832 The article will be squeezed through the mail spooling process again,
8833 which means that it will be put in some mail newsgroup or other
8834 depending on `nnmail-split-methods'.
8835 If N is a positive number, respool the N next articles.
8836 If N is a negative number, respool the N previous articles.
8837 If N is nil and any articles have been marked with the process mark,
8838 respool those articles instead.
8840 Respooling can be done both from mail groups and \"real\" newsgroups.
8841 In the former case, the articles in question will be moved from the
8842 current group into whatever groups they are destined to. In the
8843 latter case, they will be copied into the relevant groups."
8845 (list current-prefix-arg
8846 (let* ((methods (gnus-methods-using 'respool))
8848 (symbol-name (or gnus-summary-respool-default-method
8849 (car (gnus-find-method-for-group
8850 gnus-newsgroup-name)))))
8852 (gnus-completing-read-with-default
8853 methname "What backend do you want to use when respooling?"
8854 methods nil t nil 'gnus-mail-method-history))
8857 ((zerop (length (setq ms (gnus-servers-using-backend
8859 (list (intern method) ""))
8863 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8864 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8867 (error "No method given for respooling"))
8868 (if (assoc (symbol-name
8869 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8870 (gnus-methods-using 'respool))
8871 (gnus-summary-move-article n nil method)
8872 (gnus-summary-copy-article n nil method)))
8874 (defun gnus-summary-import-article (file &optional edit)
8875 "Import an arbitrary file into a mail newsgroup."
8876 (interactive "fImport file: \nP")
8877 (let ((group gnus-newsgroup-name)
8878 (now (current-time))
8879 atts lines group-art)
8880 (unless (gnus-check-backend-function 'request-accept-article group)
8881 (error "%s does not support article importing" group))
8882 (or (file-readable-p file)
8883 (not (file-regular-p file))
8884 (error "Can't read %s" file))
8886 (set-buffer (gnus-get-buffer-create " *import file*"))
8888 (nnheader-insert-file-contents file)
8889 (goto-char (point-min))
8890 (if (nnheader-article-p)
8892 (goto-char (point-min))
8893 (search-forward "\n\n" nil t)
8894 (narrow-to-region (point-min) (1- (point)))
8895 (goto-char (point-min))
8896 (unless (re-search-forward "^date:" nil t)
8897 (goto-char (point-max))
8898 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8899 ;; This doesn't look like an article, so we fudge some headers.
8900 (setq atts (file-attributes file)
8901 lines (count-lines (point-min) (point-max)))
8902 (insert "From: " (read-string "From: ") "\n"
8903 "Subject: " (read-string "Subject: ") "\n"
8904 "Date: " (message-make-date (nth 5 atts)) "\n"
8905 "Message-ID: " (message-make-message-id) "\n"
8906 "Lines: " (int-to-string lines) "\n"
8907 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8908 (setq group-art (gnus-request-accept-article group nil t))
8909 (kill-buffer (current-buffer)))
8910 (setq gnus-newsgroup-active (gnus-activate-group group))
8912 (gnus-summary-goto-article (cdr group-art) nil t)
8914 (gnus-summary-edit-article))))
8916 (defun gnus-summary-create-article ()
8917 "Create an article in a mail newsgroup."
8919 (let ((group gnus-newsgroup-name)
8920 (now (current-time))
8922 (unless (gnus-check-backend-function 'request-accept-article group)
8923 (error "%s does not support article importing" group))
8925 (set-buffer (gnus-get-buffer-create " *import file*"))
8927 (goto-char (point-min))
8928 ;; This doesn't look like an article, so we fudge some headers.
8929 (insert "From: " (read-string "From: ") "\n"
8930 "Subject: " (read-string "Subject: ") "\n"
8931 "Date: " (message-make-date now) "\n"
8932 "Message-ID: " (message-make-message-id) "\n")
8933 (setq group-art (gnus-request-accept-article group nil t))
8934 (kill-buffer (current-buffer)))
8935 (setq gnus-newsgroup-active (gnus-activate-group group))
8937 (gnus-summary-goto-article (cdr group-art) nil t)
8938 (gnus-summary-edit-article)))
8940 (defun gnus-summary-article-posted-p ()
8941 "Say whether the current (mail) article is available from news as well.
8942 This will be the case if the article has both been mailed and posted."
8944 (let ((id (mail-header-references (gnus-summary-article-header)))
8945 (gnus-override-method (car (gnus-refer-article-methods))))
8946 (if (gnus-request-head id "")
8947 (gnus-message 2 "The current message was found on %s"
8948 gnus-override-method)
8949 (gnus-message 2 "The current message couldn't be found on %s"
8950 gnus-override-method)
8953 (defun gnus-summary-expire-articles (&optional now)
8954 "Expire all articles that are marked as expirable in the current group."
8956 (when (gnus-check-backend-function
8957 'request-expire-articles gnus-newsgroup-name)
8958 ;; This backend supports expiry.
8959 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
8960 (expirable (if total
8962 ;; We need to update the info for
8963 ;; this group for `gnus-list-of-read-articles'
8964 ;; to give us the right answer.
8965 (gnus-run-hooks 'gnus-exit-group-hook)
8966 (gnus-summary-update-info)
8967 (gnus-list-of-read-articles gnus-newsgroup-name))
8968 (setq gnus-newsgroup-expirable
8969 (sort gnus-newsgroup-expirable '<))))
8970 (expiry-wait (if now 'immediate
8971 (gnus-group-find-parameter
8972 gnus-newsgroup-name 'expiry-wait)))
8973 (nnmail-expiry-target
8974 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
8975 nnmail-expiry-target))
8978 ;; There are expirable articles in this group, so we run them
8979 ;; through the expiry process.
8980 (gnus-message 6 "Expiring articles...")
8981 (unless (gnus-check-group gnus-newsgroup-name)
8982 (error "Can't open server for %s" gnus-newsgroup-name))
8983 ;; The list of articles that weren't expired is returned.
8986 (let ((nnmail-expiry-wait-function nil)
8987 (nnmail-expiry-wait expiry-wait))
8988 (setq es (gnus-request-expire-articles
8989 expirable gnus-newsgroup-name)))
8990 (setq es (gnus-request-expire-articles
8991 expirable gnus-newsgroup-name)))
8993 (setq gnus-newsgroup-expirable es))
8994 ;; We go through the old list of expirable, and mark all
8995 ;; really expired articles as nonexistent.
8996 (unless (eq es expirable) ;If nothing was expired, we don't mark.
8997 (let ((gnus-use-cache nil))
8998 (dolist (article expirable)
8999 (when (and (not (memq article es))
9000 (gnus-data-find article))
9001 (gnus-summary-mark-article article gnus-canceled-mark))))))
9002 (gnus-message 6 "Expiring articles...done")))))
9004 (defun gnus-summary-expire-articles-now ()
9005 "Expunge all expirable articles in the current group.
9006 This means that *all* articles that are marked as expirable will be
9007 deleted forever, right now."
9009 (or gnus-expert-user
9011 "Are you really, really, really sure you want to delete all these messages? ")
9013 (gnus-summary-expire-articles t))
9015 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9016 (defun gnus-summary-delete-article (&optional n)
9017 "Delete the N next (mail) articles.
9018 This command actually deletes articles. This is not a marking
9019 command. The article will disappear forever from your life, never to
9021 If N is negative, delete backwards.
9022 If N is nil and articles have been marked with the process mark,
9023 delete these instead."
9025 (unless (gnus-check-backend-function 'request-expire-articles
9026 gnus-newsgroup-name)
9027 (error "The current newsgroup does not support article deletion"))
9028 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9029 (error "Couldn't open server"))
9030 ;; Compute the list of articles to delete.
9031 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9032 (nnmail-expiry-target 'delete)
9034 (if (and gnus-novice-user
9035 (not (gnus-yes-or-no-p
9036 (format "Do you really want to delete %s forever? "
9037 (if (> (length articles) 1)
9038 (format "these %s articles" (length articles))
9041 ;; Delete the articles.
9042 (setq not-deleted (gnus-request-expire-articles
9043 articles gnus-newsgroup-name 'force))
9045 (gnus-summary-remove-process-mark (car articles))
9046 ;; The backend might not have been able to delete the article
9048 (unless (memq (car articles) not-deleted)
9049 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9050 (setq articles (cdr articles)))
9052 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9053 (gnus-summary-position-point)
9054 (gnus-set-mode-line 'summary)
9057 (defun gnus-summary-edit-article (&optional force)
9058 "Edit the current article.
9059 This will have permanent effect only in mail groups.
9060 If FORCE is non-nil, allow editing of articles even in read-only
9064 (set-buffer gnus-summary-buffer)
9065 (let ((mail-parse-charset gnus-newsgroup-charset)
9066 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9067 (gnus-set-global-variables)
9068 (when (and (not force)
9069 (gnus-group-read-only-p))
9070 (error "The current newsgroup does not support article editing"))
9071 (gnus-summary-show-article t)
9072 (gnus-article-edit-article
9074 `(lambda (no-highlight)
9075 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9076 (message-options message-options)
9077 (message-options-set-recipient)
9078 (mail-parse-ignored-charsets
9079 ',gnus-newsgroup-ignored-charsets))
9080 (gnus-summary-edit-article-done
9081 ,(or (mail-header-references gnus-current-headers) "")
9082 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9084 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9086 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9088 "Make edits to the current article permanent."
9091 ;; The buffer restriction contains the entire article if it exists.
9092 (when (article-goto-body)
9093 (let ((lines (count-lines (point) (point-max)))
9094 (length (- (point-max) (point)))
9095 (case-fold-search t)
9096 (body (copy-marker (point))))
9097 (goto-char (point-min))
9098 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9099 (delete-region (match-beginning 1) (match-end 1))
9100 (insert (number-to-string length)))
9101 (goto-char (point-min))
9102 (when (re-search-forward
9103 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9104 (delete-region (match-beginning 1) (match-end 1))
9105 (insert (number-to-string length)))
9106 (goto-char (point-min))
9107 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9108 (delete-region (match-beginning 1) (match-end 1))
9109 (insert (number-to-string lines))))))
9110 ;; Replace the article.
9111 (let ((buf (current-buffer)))
9113 (insert-buffer-substring buf)
9115 (if (and (not read-only)
9116 (not (gnus-request-replace-article
9117 (cdr gnus-article-current) (car gnus-article-current)
9118 (current-buffer) t)))
9119 (error "Couldn't replace article")
9120 ;; Update the summary buffer.
9122 (equal (message-tokenize-header references " ")
9123 (message-tokenize-header
9124 (or (message-fetch-field "references") "") " ")))
9125 ;; We only have to update this line.
9128 (message-narrow-to-head)
9129 (let ((head (buffer-string))
9132 (insert (format "211 %d Article retrieved.\n"
9133 (cdr gnus-article-current)))
9136 (let ((nntp-server-buffer (current-buffer)))
9137 (setq header (car (gnus-get-newsgroup-headers
9140 (set-buffer gnus-summary-buffer)
9141 (gnus-data-set-header
9142 (gnus-data-find (cdr gnus-article-current))
9144 (gnus-summary-update-article-line
9145 (cdr gnus-article-current) header)
9146 (if (gnus-summary-goto-subject
9147 (cdr gnus-article-current) nil t)
9148 (gnus-summary-update-secondary-mark
9149 (cdr gnus-article-current))))))))
9151 (set-buffer (or buffer gnus-summary-buffer))
9152 (gnus-summary-update-article (cdr gnus-article-current))
9153 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9154 (gnus-summary-update-secondary-mark
9155 (cdr gnus-article-current))))
9156 ;; Prettify the article buffer again.
9157 (unless no-highlight
9159 (set-buffer gnus-article-buffer)
9160 ;;;!!! Fix this -- article should be rehighlighted.
9161 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9162 (set-buffer gnus-original-article-buffer)
9163 (gnus-request-article
9164 (cdr gnus-article-current)
9165 (car gnus-article-current) (current-buffer))))
9166 ;; Prettify the summary buffer line.
9167 (when (gnus-visual-p 'summary-highlight 'highlight)
9168 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9170 (defun gnus-summary-edit-wash (key)
9171 "Perform editing command KEY in the article buffer."
9175 (message "%s" (concat (this-command-keys) "- "))
9178 (gnus-summary-edit-article)
9179 (execute-kbd-macro (concat (this-command-keys) key))
9180 (gnus-article-edit-done))
9184 (defun gnus-summary-respool-query (&optional silent trace)
9185 "Query where the respool algorithm would put this article."
9187 (let (gnus-mark-article-hook)
9188 (gnus-summary-select-article)
9190 (set-buffer gnus-original-article-buffer)
9192 (message-narrow-to-head)
9193 (let ((groups (nnmail-article-group 'identity trace)))
9196 (message "This message would go to %s"
9197 (mapconcat 'car groups ", "))
9198 (message "This message would go to no groups"))
9201 (defun gnus-summary-respool-trace ()
9202 "Trace where the respool algorithm would put this article.
9203 Display a buffer showing all fancy splitting patterns which matched."
9205 (gnus-summary-respool-query nil t))
9207 ;; Summary marking commands.
9209 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9210 "Mark articles which has the same subject as read, and then select the next.
9211 If UNMARK is positive, remove any kind of mark.
9212 If UNMARK is negative, tick articles."
9215 (setq unmark (prefix-numeric-value unmark)))
9217 (gnus-summary-mark-same-subject
9218 (gnus-summary-article-subject) unmark)))
9219 ;; Select next unread article. If auto-select-same mode, should
9220 ;; select the first unread article.
9221 (gnus-summary-next-article t (and gnus-auto-select-same
9222 (gnus-summary-article-subject)))
9223 (gnus-message 7 "%d article%s marked as %s"
9224 count (if (= count 1) " is" "s are")
9225 (if unmark "unread" "read"))))
9227 (defun gnus-summary-kill-same-subject (&optional unmark)
9228 "Mark articles which has the same subject as read.
9229 If UNMARK is positive, remove any kind of mark.
9230 If UNMARK is negative, tick articles."
9233 (setq unmark (prefix-numeric-value unmark)))
9235 (gnus-summary-mark-same-subject
9236 (gnus-summary-article-subject) unmark)))
9237 ;; If marked as read, go to next unread subject.
9239 ;; Go to next unread subject.
9240 (gnus-summary-next-subject 1 t))
9241 (gnus-message 7 "%d articles are marked as %s"
9242 count (if unmark "unread" "read"))))
9244 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9245 "Mark articles with same SUBJECT as read, and return marked number.
9246 If optional argument UNMARK is positive, remove any kinds of marks.
9247 If optional argument UNMARK is negative, mark articles as unread instead."
9251 ((null unmark) ; Mark as read.
9254 (gnus-summary-mark-article-as-read gnus-killed-mark)
9255 (gnus-summary-show-thread) t)
9256 (gnus-summary-find-subject subject))
9257 (setq count (1+ count))))
9258 ((> unmark 0) ; Tick.
9261 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9262 (gnus-summary-show-thread) t)
9263 (gnus-summary-find-subject subject))
9264 (setq count (1+ count))))
9265 (t ; Mark as unread.
9268 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9269 (gnus-summary-show-thread) t)
9270 (gnus-summary-find-subject subject))
9271 (setq count (1+ count)))))
9272 (gnus-set-mode-line 'summary)
9273 ;; Return the number of marked articles.
9276 (defun gnus-summary-mark-as-processable (n &optional unmark)
9277 "Set the process mark on the next N articles.
9278 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9279 the process mark instead. The difference between N and the actual
9280 number of articles marked is returned."
9282 (if (and (null n) (gnus-region-active-p))
9283 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9284 (setq n (prefix-numeric-value n))
9285 (let ((backward (< n 0))
9290 (gnus-summary-remove-process-mark
9291 (gnus-summary-article-number))
9292 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9293 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9296 (gnus-message 7 "No more articles"))
9297 (gnus-summary-recenter)
9298 (gnus-summary-position-point)
9301 (defun gnus-summary-unmark-as-processable (n)
9302 "Remove the process mark from the next N articles.
9303 If N is negative, unmark backward instead. The difference between N and
9304 the actual number of articles unmarked is returned."
9306 (gnus-summary-mark-as-processable n t))
9308 (defun gnus-summary-unmark-all-processable ()
9309 "Remove the process mark from all articles."
9312 (while gnus-newsgroup-processable
9313 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9314 (gnus-summary-position-point))
9316 (defun gnus-summary-add-mark (article type)
9317 "Mark ARTICLE with a mark of TYPE."
9318 (let ((vtype (car (assq type gnus-article-mark-lists)))
9321 (error "No such mark type: %s" type)
9322 (setq var (intern (format "gnus-newsgroup-%s" type)))
9323 (set var (cons article (symbol-value var)))
9324 (if (memq type '(processable cached replied forwarded recent saved))
9325 (gnus-summary-update-secondary-mark article)
9326 ;;; !!! This is bogus. We should find out what primary
9327 ;;; !!! mark we want to set.
9328 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9330 (defun gnus-summary-mark-as-expirable (n)
9331 "Mark N articles forward as expirable.
9332 If N is negative, mark backward instead. The difference between N and
9333 the actual number of articles marked is returned."
9335 (gnus-summary-mark-forward n gnus-expirable-mark))
9337 (defun gnus-summary-mark-as-spam (n)
9338 "Mark N articles forward as spam.
9339 If N is negative, mark backward instead. The difference between N and
9340 the actual number of articles marked is returned."
9342 (gnus-summary-mark-forward n gnus-spam-mark))
9344 (defun gnus-summary-mark-article-as-replied (article)
9345 "Mark ARTICLE as replied to and update the summary line.
9346 ARTICLE can also be a list of articles."
9347 (interactive (list (gnus-summary-article-number)))
9348 (let ((articles (if (listp article) article (list article))))
9349 (dolist (article articles)
9350 (push article gnus-newsgroup-replied)
9351 (let ((buffer-read-only nil))
9352 (when (gnus-summary-goto-subject article nil t)
9353 (gnus-summary-update-secondary-mark article))))))
9355 (defun gnus-summary-mark-article-as-forwarded (article)
9356 "Mark ARTICLE as forwarded and update the summary line.
9357 ARTICLE can also be a list of articles."
9358 (let ((articles (if (listp article) article (list article))))
9359 (dolist (article articles)
9360 (push article gnus-newsgroup-forwarded)
9361 (let ((buffer-read-only nil))
9362 (when (gnus-summary-goto-subject article nil t)
9363 (gnus-summary-update-secondary-mark article))))))
9365 (defun gnus-summary-set-bookmark (article)
9366 "Set a bookmark in current article."
9367 (interactive (list (gnus-summary-article-number)))
9368 (when (or (not (get-buffer gnus-article-buffer))
9369 (not gnus-current-article)
9370 (not gnus-article-current)
9371 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9372 (error "No current article selected"))
9373 ;; Remove old bookmark, if one exists.
9374 (let ((old (assq article gnus-newsgroup-bookmarks)))
9376 (setq gnus-newsgroup-bookmarks
9377 (delq old gnus-newsgroup-bookmarks))))
9378 ;; Set the new bookmark, which is on the form
9379 ;; (article-number . line-number-in-body).
9383 (set-buffer gnus-article-buffer)
9387 (goto-char (point-min))
9388 (search-forward "\n\n" nil t)
9391 gnus-newsgroup-bookmarks)
9392 (gnus-message 6 "A bookmark has been added to the current article."))
9394 (defun gnus-summary-remove-bookmark (article)
9395 "Remove the bookmark from the current article."
9396 (interactive (list (gnus-summary-article-number)))
9397 ;; Remove old bookmark, if one exists.
9398 (let ((old (assq article gnus-newsgroup-bookmarks)))
9401 (setq gnus-newsgroup-bookmarks
9402 (delq old gnus-newsgroup-bookmarks))
9403 (gnus-message 6 "Removed bookmark."))
9404 (gnus-message 6 "No bookmark in current article."))))
9406 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9407 (defun gnus-summary-mark-as-dormant (n)
9408 "Mark N articles forward as dormant.
9409 If N is negative, mark backward instead. The difference between N and
9410 the actual number of articles marked is returned."
9412 (gnus-summary-mark-forward n gnus-dormant-mark))
9414 (defun gnus-summary-set-process-mark (article)
9415 "Set the process mark on ARTICLE and update the summary line."
9416 (setq gnus-newsgroup-processable
9418 (delq article gnus-newsgroup-processable)))
9419 (when (gnus-summary-goto-subject article)
9420 (gnus-summary-show-thread)
9421 (gnus-summary-goto-subject article)
9422 (gnus-summary-update-secondary-mark article)))
9424 (defun gnus-summary-remove-process-mark (article)
9425 "Remove the process mark from ARTICLE and update the summary line."
9426 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9427 (when (gnus-summary-goto-subject article)
9428 (gnus-summary-show-thread)
9429 (gnus-summary-goto-subject article)
9430 (gnus-summary-update-secondary-mark article)))
9432 (defun gnus-summary-set-saved-mark (article)
9433 "Set the process mark on ARTICLE and update the summary line."
9434 (push article gnus-newsgroup-saved)
9435 (when (gnus-summary-goto-subject article)
9436 (gnus-summary-update-secondary-mark article)))
9438 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9439 "Mark N articles as read forwards.
9440 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9441 The difference between N and the actual number of articles marked is
9443 Iff NO-EXPIRE, auto-expiry will be inhibited."
9445 (gnus-summary-show-thread)
9446 (let ((backward (< n 0))
9447 (gnus-summary-goto-unread
9448 (and gnus-summary-goto-unread
9449 (not (eq gnus-summary-goto-unread 'never))
9450 (not (memq mark (list gnus-unread-mark
9451 gnus-ticked-mark gnus-dormant-mark)))))
9453 (mark (or mark gnus-del-mark)))
9455 (gnus-summary-mark-article nil mark no-expire)
9456 (zerop (gnus-summary-next-subject
9458 (and gnus-summary-goto-unread
9459 (not (eq gnus-summary-goto-unread 'never)))
9463 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9464 (gnus-summary-recenter)
9465 (gnus-summary-position-point)
9466 (gnus-set-mode-line 'summary)
9469 (defun gnus-summary-mark-article-as-read (mark)
9470 "Mark the current article quickly as read with MARK."
9471 (let ((article (gnus-summary-article-number)))
9472 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9473 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9474 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9475 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9476 (push (cons article mark) gnus-newsgroup-reads)
9477 ;; Possibly remove from cache, if that is used.
9478 (when gnus-use-cache
9479 (gnus-cache-enter-remove-article article))
9480 ;; Allow the backend to change the mark.
9481 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9482 ;; Check for auto-expiry.
9483 (when (and gnus-newsgroup-auto-expire
9484 (memq mark gnus-auto-expirable-marks))
9485 (setq mark gnus-expirable-mark)
9486 ;; Let the backend know about the mark change.
9487 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9488 (push article gnus-newsgroup-expirable))
9489 ;; Set the mark in the buffer.
9490 (gnus-summary-update-mark mark 'unread)
9493 (defun gnus-summary-mark-article-as-unread (mark)
9494 "Mark the current article quickly as unread with MARK."
9495 (let* ((article (gnus-summary-article-number))
9496 (old-mark (gnus-summary-article-mark article)))
9497 ;; Allow the backend to change the mark.
9498 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9499 (if (eq mark old-mark)
9503 (gnus-error 1 "Can't mark negative article numbers")
9505 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9506 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9507 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9508 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9509 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9510 (cond ((= mark gnus-ticked-mark)
9511 (setq gnus-newsgroup-marked
9512 (gnus-add-to-sorted-list gnus-newsgroup-marked
9514 ((= mark gnus-spam-mark)
9515 (setq gnus-newsgroup-spam-marked
9516 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9518 ((= mark gnus-dormant-mark)
9519 (setq gnus-newsgroup-dormant
9520 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9523 (setq gnus-newsgroup-unreads
9524 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9526 (gnus-pull article gnus-newsgroup-reads)
9528 ;; See whether the article is to be put in the cache.
9530 (vectorp (gnus-summary-article-header article))
9532 (gnus-cache-possibly-enter-article
9533 gnus-newsgroup-name article
9534 (gnus-summary-article-header article)
9535 (= mark gnus-ticked-mark)
9536 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9539 (gnus-summary-update-mark mark 'unread)
9542 (defun gnus-summary-mark-article (&optional article mark no-expire)
9543 "Mark ARTICLE with MARK. MARK can be any character.
9544 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9545 `??' (dormant) and `?E' (expirable).
9546 If MARK is nil, then the default character `?r' is used.
9547 If ARTICLE is nil, then the article on the current line will be
9549 Iff NO-EXPIRE, auto-expiry will be inhibited."
9550 ;; The mark might be a string.
9551 (when (stringp mark)
9552 (setq mark (aref mark 0)))
9553 ;; If no mark is given, then we check auto-expiring.
9555 (setq mark gnus-del-mark))
9556 (when (and (not no-expire)
9557 gnus-newsgroup-auto-expire
9558 (memq mark gnus-auto-expirable-marks))
9559 (setq mark gnus-expirable-mark))
9560 (let ((article (or article (gnus-summary-article-number)))
9561 (old-mark (gnus-summary-article-mark article)))
9562 ;; Allow the backend to change the mark.
9563 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9564 (if (eq mark old-mark)
9567 (error "No article on current line"))
9568 (if (not (if (or (= mark gnus-unread-mark)
9569 (= mark gnus-ticked-mark)
9570 (= mark gnus-spam-mark)
9571 (= mark gnus-dormant-mark))
9572 (gnus-mark-article-as-unread article mark)
9573 (gnus-mark-article-as-read article mark)))
9575 ;; See whether the article is to be put in the cache.
9577 (not (= mark gnus-canceled-mark))
9578 (vectorp (gnus-summary-article-header article))
9580 (gnus-cache-possibly-enter-article
9581 gnus-newsgroup-name article
9582 (gnus-summary-article-header article)
9583 (= mark gnus-ticked-mark)
9584 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9586 (when (gnus-summary-goto-subject article nil t)
9587 (let ((buffer-read-only nil))
9588 (gnus-summary-show-thread)
9590 (gnus-summary-update-mark mark 'unread)
9593 (defun gnus-summary-update-secondary-mark (article)
9594 "Update the secondary (read, process, cache) mark."
9595 (gnus-summary-update-mark
9596 (cond ((memq article gnus-newsgroup-processable)
9598 ((memq article gnus-newsgroup-cached)
9600 ((memq article gnus-newsgroup-replied)
9602 ((memq article gnus-newsgroup-forwarded)
9603 gnus-forwarded-mark)
9604 ((memq article gnus-newsgroup-saved)
9606 ((memq article gnus-newsgroup-recent)
9608 ((memq article gnus-newsgroup-unseen)
9612 (when (gnus-visual-p 'summary-highlight 'highlight)
9613 (gnus-run-hooks 'gnus-summary-update-hook))
9616 (defun gnus-summary-update-mark (mark type)
9617 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9618 (buffer-read-only nil))
9619 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9621 (when (looking-at "\r")
9623 (when (<= (+ forward (point)) (point-max))
9624 ;; Go to the right position on the line.
9625 (goto-char (+ forward (point)))
9626 ;; Replace the old mark with the new mark.
9627 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9628 ;; Optionally update the marks by some user rule.
9629 (when (eq type 'unread)
9631 (gnus-data-find (gnus-summary-article-number)) mark)
9632 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9634 (defun gnus-mark-article-as-read (article &optional mark)
9635 "Enter ARTICLE in the pertinent lists and remove it from others."
9636 ;; Make the article expirable.
9637 (let ((mark (or mark gnus-del-mark)))
9638 (setq gnus-newsgroup-expirable
9639 (if (= mark gnus-expirable-mark)
9640 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9641 (delq article gnus-newsgroup-expirable)))
9642 ;; Remove from unread and marked lists.
9643 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9644 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9645 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9646 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9647 (push (cons article mark) gnus-newsgroup-reads)
9648 ;; Possibly remove from cache, if that is used.
9649 (when gnus-use-cache
9650 (gnus-cache-enter-remove-article article))
9653 (defun gnus-mark-article-as-unread (article &optional mark)
9654 "Enter ARTICLE in the pertinent lists and remove it from others."
9655 (let ((mark (or mark gnus-ticked-mark)))
9658 (gnus-error 1 "Can't mark negative article numbers")
9660 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9661 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9662 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9663 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9664 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9666 ;; Unsuppress duplicates?
9667 (when gnus-suppress-duplicates
9668 (gnus-dup-unsuppress-article article))
9670 (cond ((= mark gnus-ticked-mark)
9671 (setq gnus-newsgroup-marked
9672 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9673 ((= mark gnus-spam-mark)
9674 (setq gnus-newsgroup-spam-marked
9675 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked article)))
9676 ((= mark gnus-dormant-mark)
9677 (setq gnus-newsgroup-dormant
9678 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9680 (setq gnus-newsgroup-unreads
9681 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9682 (gnus-pull article gnus-newsgroup-reads)
9685 (defalias 'gnus-summary-mark-as-unread-forward
9686 'gnus-summary-tick-article-forward)
9687 (make-obsolete 'gnus-summary-mark-as-unread-forward
9688 'gnus-summary-tick-article-forward)
9689 (defun gnus-summary-tick-article-forward (n)
9690 "Tick N articles forwards.
9691 If N is negative, tick backwards instead.
9692 The difference between N and the number of articles ticked is returned."
9694 (gnus-summary-mark-forward n gnus-ticked-mark))
9696 (defalias 'gnus-summary-mark-as-unread-backward
9697 'gnus-summary-tick-article-backward)
9698 (make-obsolete 'gnus-summary-mark-as-unread-backward
9699 'gnus-summary-tick-article-backward)
9700 (defun gnus-summary-tick-article-backward (n)
9701 "Tick N articles backwards.
9702 The difference between N and the number of articles ticked is returned."
9704 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9706 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9707 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9708 (defun gnus-summary-tick-article (&optional article clear-mark)
9709 "Mark current article as unread.
9710 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9711 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9713 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9716 (defun gnus-summary-mark-as-read-forward (n)
9717 "Mark N articles as read forwards.
9718 If N is negative, mark backwards instead.
9719 The difference between N and the actual number of articles marked is
9722 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9724 (defun gnus-summary-mark-as-read-backward (n)
9725 "Mark the N articles as read backwards.
9726 The difference between N and the actual number of articles marked is
9729 (gnus-summary-mark-forward
9730 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9732 (defun gnus-summary-mark-as-read (&optional article mark)
9733 "Mark current article as read.
9734 ARTICLE specifies the article to be marked as read.
9735 MARK specifies a string to be inserted at the beginning of the line."
9736 (gnus-summary-mark-article article mark))
9738 (defun gnus-summary-clear-mark-forward (n)
9739 "Clear marks from N articles forward.
9740 If N is negative, clear backward instead.
9741 The difference between N and the number of marks cleared is returned."
9743 (gnus-summary-mark-forward n gnus-unread-mark))
9745 (defun gnus-summary-clear-mark-backward (n)
9746 "Clear marks from N articles backward.
9747 The difference between N and the number of marks cleared is returned."
9749 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9751 (defun gnus-summary-mark-unread-as-read ()
9752 "Intended to be used by `gnus-summary-mark-article-hook'."
9753 (when (memq gnus-current-article gnus-newsgroup-unreads)
9754 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9756 (defun gnus-summary-mark-read-and-unread-as-read ()
9757 "Intended to be used by `gnus-summary-mark-article-hook'."
9758 (let ((mark (gnus-summary-article-mark)))
9759 (when (or (gnus-unread-mark-p mark)
9760 (gnus-read-mark-p mark))
9761 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9763 (defun gnus-summary-mark-unread-as-ticked ()
9764 "Intended to be used by `gnus-summary-mark-article-hook'."
9765 (when (memq gnus-current-article gnus-newsgroup-unreads)
9766 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9768 (defun gnus-summary-mark-region-as-read (point mark all)
9769 "Mark all unread articles between point and mark as read.
9770 If given a prefix, mark all articles between point and mark as read,
9771 even ticked and dormant ones."
9772 (interactive "r\nP")
9781 (memq (setq article (gnus-summary-article-number))
9782 gnus-newsgroup-unreads))
9783 (gnus-summary-mark-article article gnus-del-mark))
9785 (gnus-summary-find-next))))))
9787 (defun gnus-summary-mark-below (score mark)
9788 "Mark articles with score less than SCORE with MARK."
9789 (interactive "P\ncMark: ")
9790 (setq score (if score
9791 (prefix-numeric-value score)
9792 (or gnus-summary-default-score 0)))
9794 (set-buffer gnus-summary-buffer)
9795 (goto-char (point-min))
9798 (and (< (gnus-summary-article-score) score)
9799 (gnus-summary-mark-article nil mark))
9800 (gnus-summary-find-next)))))
9802 (defun gnus-summary-kill-below (&optional score)
9803 "Mark articles with score below SCORE as read."
9805 (gnus-summary-mark-below score gnus-killed-mark))
9807 (defun gnus-summary-clear-above (&optional score)
9808 "Clear all marks from articles with score above SCORE."
9810 (gnus-summary-mark-above score gnus-unread-mark))
9812 (defun gnus-summary-tick-above (&optional score)
9813 "Tick all articles with score above SCORE."
9815 (gnus-summary-mark-above score gnus-ticked-mark))
9817 (defun gnus-summary-mark-above (score mark)
9818 "Mark articles with score over SCORE with MARK."
9819 (interactive "P\ncMark: ")
9820 (setq score (if score
9821 (prefix-numeric-value score)
9822 (or gnus-summary-default-score 0)))
9824 (set-buffer gnus-summary-buffer)
9825 (goto-char (point-min))
9827 (when (> (gnus-summary-article-score) score)
9828 (gnus-summary-mark-article nil mark))
9830 (gnus-summary-find-next)))))
9832 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9833 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9834 (defun gnus-summary-limit-include-expunged (&optional no-error)
9835 "Display all the hidden articles that were expunged for low scores."
9837 (let ((buffer-read-only nil))
9838 (let ((scored gnus-newsgroup-scored)
9841 (unless (gnus-summary-article-header (caar scored))
9842 (and (setq h (gnus-number-to-header (caar scored)))
9843 (< (cdar scored) gnus-summary-expunge-below)
9845 (setq scored (cdr scored)))
9847 (when (not no-error)
9848 (error "No expunged articles hidden"))
9849 (goto-char (point-min))
9850 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9851 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9852 (mapcar (lambda (x) (push (mail-header-number x)
9853 gnus-newsgroup-limit))
9855 (gnus-summary-prepare-unthreaded (nreverse headers))
9856 (goto-char (point-min))
9857 (gnus-summary-position-point)
9860 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9861 "Mark all unread articles in this newsgroup as read.
9862 If prefix argument ALL is non-nil, ticked and dormant articles will
9863 also be marked as read.
9864 If QUIETLY is non-nil, no questions will be asked.
9865 If TO-HERE is non-nil, it should be a point in the buffer. All
9866 articles before (after, if REVERSE is set) this point will be marked as read.
9867 Note that this function will only catch up the unread article
9868 in the current summary buffer limitation.
9869 The number of articles marked as read is returned."
9874 (not gnus-interactive-catchup) ;Without confirmation?
9878 "Mark absolutely all articles as read? "
9879 "Mark all unread articles as read? ")))
9881 (not gnus-newsgroup-adaptive)
9882 (not gnus-newsgroup-auto-expire)
9883 (not gnus-suppress-duplicates)
9884 (or (not gnus-use-cache)
9885 (eq gnus-use-cache 'passive)))
9888 (setq gnus-newsgroup-marked nil
9889 gnus-newsgroup-spam-marked nil
9890 gnus-newsgroup-dormant nil))
9891 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9892 ;; We actually mark all articles as canceled, which we
9893 ;; have to do when using auto-expiry or adaptive scoring.
9894 (gnus-summary-show-all-threads)
9895 (if (and to-here reverse)
9899 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9900 (gnus-summary-find-next (not all) nil nil t))))
9901 (when (gnus-summary-first-subject (not all) t)
9903 (if to-here (< (point) to-here) t)
9904 (gnus-summary-mark-article-as-read gnus-catchup-mark)
9905 (gnus-summary-find-next (not all) nil nil t)))))
9906 (gnus-set-mode-line 'summary))
9908 (gnus-summary-position-point)))
9910 (defun gnus-summary-catchup-to-here (&optional all)
9911 "Mark all unticked articles before the current one as read.
9912 If ALL is non-nil, also mark ticked and dormant articles as read."
9915 (gnus-save-hidden-threads
9916 (let ((beg (point)))
9917 ;; We check that there are unread articles.
9918 (when (or all (gnus-summary-find-prev))
9919 (gnus-summary-catchup all t beg)))))
9920 (gnus-summary-position-point))
9922 (defun gnus-summary-catchup-from-here (&optional all)
9923 "Mark all unticked articles after the current one as read.
9924 If ALL is non-nil, also mark ticked and dormant articles as read."
9927 (gnus-save-hidden-threads
9928 (let ((beg (point)))
9929 ;; We check that there are unread articles.
9930 (when (or all (gnus-summary-find-next))
9931 (gnus-summary-catchup all t beg nil t)))))
9932 (gnus-summary-position-point))
9934 (defun gnus-summary-catchup-all (&optional quietly)
9935 "Mark all articles in this newsgroup as read."
9937 (gnus-summary-catchup t quietly))
9939 (defun gnus-summary-catchup-and-exit (&optional all quietly)
9940 "Mark all unread articles in this group as read, then exit.
9941 If prefix argument ALL is non-nil, all articles are marked as read.
9942 If QUIETLY is non-nil, no questions will be asked."
9944 (when (gnus-summary-catchup all quietly nil 'fast)
9945 ;; Select next newsgroup or exit.
9946 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
9947 (eq gnus-auto-select-next 'quietly))
9948 (gnus-summary-next-group nil)
9949 (gnus-summary-exit))))
9951 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
9952 "Mark all articles in this newsgroup as read, and then exit."
9954 (gnus-summary-catchup-and-exit t quietly))
9956 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
9957 "Mark all articles in this group as read and select the next group.
9958 If given a prefix, mark all articles, unread as well as ticked, as
9962 (gnus-summary-catchup all))
9963 (gnus-summary-next-group))
9969 (defmacro gnus-with-article (article &rest forms)
9970 "Select ARTICLE and perform FORMS in the original article buffer.
9971 Then replace the article with the result."
9973 ;; We don't want the article to be marked as read.
9974 (let (gnus-mark-article-hook)
9975 (gnus-summary-select-article t t nil ,article))
9976 (set-buffer gnus-original-article-buffer)
9978 (if (not (gnus-check-backend-function
9979 'request-replace-article (car gnus-article-current)))
9980 (gnus-message 5 "Read-only group; not replacing")
9981 (unless (gnus-request-replace-article
9982 ,article (car gnus-article-current)
9984 (error "Couldn't replace article")))
9985 ;; The cache and backlog have to be flushed somewhat.
9986 (when gnus-keep-backlog
9987 (gnus-backlog-remove-article
9988 (car gnus-article-current) (cdr gnus-article-current)))
9989 (when gnus-use-cache
9990 (gnus-cache-update-article
9991 (car gnus-article-current) (cdr gnus-article-current)))))
9993 (put 'gnus-with-article 'lisp-indent-function 1)
9994 (put 'gnus-with-article 'edebug-form-spec '(form body))
9996 ;; Thread-based commands.
9998 (defun gnus-summary-articles-in-thread (&optional article)
9999 "Return a list of all articles in the current thread.
10000 If ARTICLE is non-nil, return all articles in the thread that starts
10001 with that article."
10002 (let* ((article (or article (gnus-summary-article-number)))
10003 (data (gnus-data-find-list article))
10004 (top-level (gnus-data-level (car data)))
10006 (cond ((null gnus-thread-operation-ignore-subject)
10007 (gnus-simplify-subject-re
10008 (mail-header-subject (gnus-data-header (car data)))))
10009 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10010 (gnus-simplify-subject-fuzzy
10011 (mail-header-subject (gnus-data-header (car data)))))
10013 (end-point (save-excursion
10014 (if (gnus-summary-go-to-next-thread)
10015 (point) (point-max))))
10018 (< (gnus-data-pos (car data)) end-point))
10019 (when (or (not top-subject)
10020 (string= top-subject
10021 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10022 (gnus-simplify-subject-fuzzy
10023 (mail-header-subject
10024 (gnus-data-header (car data))))
10025 (gnus-simplify-subject-re
10026 (mail-header-subject
10027 (gnus-data-header (car data)))))))
10028 (push (gnus-data-number (car data)) articles))
10029 (unless (and (setq data (cdr data))
10030 (> (gnus-data-level (car data)) top-level))
10032 ;; Return the list of articles.
10033 (nreverse articles)))
10035 (defun gnus-summary-rethread-current ()
10036 "Rethread the thread the current article is part of."
10038 (let* ((gnus-show-threads t)
10039 (article (gnus-summary-article-number))
10040 (id (mail-header-id (gnus-summary-article-header)))
10041 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10043 (error "No article on the current line"))
10044 (gnus-rebuild-thread id)
10045 (gnus-summary-goto-subject article)))
10047 (defun gnus-summary-reparent-thread ()
10048 "Make the current article child of the marked (or previous) article.
10050 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10051 is non-nil or the Subject: of both articles are the same."
10053 (unless (not (gnus-group-read-only-p))
10054 (error "The current newsgroup does not support article editing"))
10055 (unless (<= (length gnus-newsgroup-processable) 1)
10056 (error "No more than one article may be marked"))
10057 (save-window-excursion
10058 (let ((gnus-article-buffer " *reparent*")
10059 (current-article (gnus-summary-article-number))
10060 ;; First grab the marked article, otherwise one line up.
10061 (parent-article (if (not (null gnus-newsgroup-processable))
10062 (car gnus-newsgroup-processable)
10064 (if (eq (forward-line -1) 0)
10065 (gnus-summary-article-number)
10066 (error "Beginning of summary buffer"))))))
10067 (unless (not (eq current-article parent-article))
10068 (error "An article may not be self-referential"))
10069 (let ((message-id (mail-header-id
10070 (gnus-summary-article-header parent-article))))
10071 (unless (and message-id (not (equal message-id "")))
10072 (error "No message-id in desired parent"))
10073 (gnus-with-article current-article
10075 (goto-char (point-min))
10076 (message-narrow-to-head)
10077 (if (re-search-forward "^References: " nil t)
10079 (re-search-forward "^[^ \t]" nil t)
10082 (insert " " message-id))
10083 (insert "References: " message-id "\n"))))
10084 (set-buffer gnus-summary-buffer)
10085 (gnus-summary-unmark-all-processable)
10086 (gnus-summary-update-article current-article)
10087 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10088 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10089 (gnus-summary-rethread-current)
10090 (gnus-message 3 "Article %d is now the child of article %d"
10091 current-article parent-article)))))
10093 (defun gnus-summary-toggle-threads (&optional arg)
10094 "Toggle showing conversation threads.
10095 If ARG is positive number, turn showing conversation threads on."
10097 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10098 (setq gnus-show-threads
10099 (if (null arg) (not gnus-show-threads)
10100 (> (prefix-numeric-value arg) 0)))
10101 (gnus-summary-prepare)
10102 (gnus-summary-goto-subject current)
10103 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10104 (gnus-summary-position-point)))
10106 (defun gnus-summary-show-all-threads ()
10107 "Show all threads."
10110 (let ((buffer-read-only nil))
10111 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10112 (gnus-summary-position-point))
10114 (defun gnus-summary-show-thread ()
10115 "Show thread subtrees.
10116 Returns nil if no thread was there to be shown."
10118 (let ((buffer-read-only nil)
10120 ;; first goto end then to beg, to have point at beg after let
10121 (end (progn (end-of-line) (point)))
10122 (beg (progn (beginning-of-line) (point))))
10124 ;; Any hidden lines here?
10125 (search-forward "\r" end t)
10126 (subst-char-in-region beg end ?\^M ?\n t)
10128 (gnus-summary-position-point))))
10130 (defun gnus-summary-maybe-hide-threads ()
10131 "If requested, hide the threads that should be hidden."
10132 (when (and gnus-show-threads
10133 gnus-thread-hide-subtree)
10134 (gnus-summary-hide-all-threads
10135 (if (or (consp gnus-thread-hide-subtree)
10136 (gnus-functionp gnus-thread-hide-subtree))
10137 (gnus-make-predicate gnus-thread-hide-subtree)
10140 ;;; Hiding predicates.
10142 (defun gnus-article-unread-p (header)
10143 (memq (mail-header-number header) gnus-newsgroup-unreads))
10145 (defun gnus-article-unseen-p (header)
10146 (memq (mail-header-number header) gnus-newsgroup-unseen))
10148 (defun gnus-map-articles (predicate articles)
10149 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10150 (apply 'gnus-or (mapcar predicate
10151 (mapcar 'gnus-summary-article-header articles))))
10153 (defun gnus-summary-hide-all-threads (&optional predicate)
10154 "Hide all thread subtrees.
10155 If PREDICATE is supplied, threads that satisfy this predicate
10156 will not be hidden."
10159 (goto-char (point-min))
10162 (when (or (not predicate)
10164 predicate (gnus-summary-article-children)))
10165 (gnus-summary-hide-thread))
10166 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10167 (gnus-summary-position-point))
10169 (defun gnus-summary-hide-thread ()
10170 "Hide thread subtrees.
10171 If PREDICATE is supplied, threads that satisfy this predicate
10172 will not be hidden.
10173 Returns nil if no threads were there to be hidden."
10175 (let ((buffer-read-only nil)
10177 (article (gnus-summary-article-number)))
10179 ;; Go forward until either the buffer ends or the subthread
10181 (when (and (not (eobp))
10182 (or (zerop (gnus-summary-next-thread 1 t))
10183 (goto-char (point-max))))
10185 (if (and (> (point) start)
10186 (search-backward "\n" start t))
10188 (subst-char-in-region start (point) ?\n ?\^M)
10189 (gnus-summary-goto-subject article))
10193 (defun gnus-summary-go-to-next-thread (&optional previous)
10194 "Go to the same level (or less) next thread.
10195 If PREVIOUS is non-nil, go to previous thread instead.
10196 Return the article number moved to, or nil if moving was impossible."
10197 (let ((level (gnus-summary-thread-level))
10198 (way (if previous -1 1))
10201 (while (and (not (eobp))
10202 (< level (gnus-summary-thread-level)))
10203 (forward-line way))
10210 (gnus-summary-article-number)
10211 (goto-char beg)))))
10213 (defun gnus-summary-next-thread (n &optional silent)
10214 "Go to the same level next N'th thread.
10215 If N is negative, search backward instead.
10216 Returns the difference between N and the number of skips actually
10219 If SILENT, don't output messages."
10221 (let ((backward (< n 0))
10223 (while (and (> n 0)
10224 (gnus-summary-go-to-next-thread backward))
10227 (gnus-summary-position-point))
10228 (when (and (not silent) (/= 0 n))
10229 (gnus-message 7 "No more threads"))
10232 (defun gnus-summary-prev-thread (n)
10233 "Go to the same level previous N'th thread.
10234 Returns the difference between N and the number of skips actually
10237 (gnus-summary-next-thread (- n)))
10239 (defun gnus-summary-go-down-thread ()
10240 "Go down one level in the current thread."
10241 (let ((children (gnus-summary-article-children)))
10243 (gnus-summary-goto-subject (car children)))))
10245 (defun gnus-summary-go-up-thread ()
10246 "Go up one level in the current thread."
10247 (let ((parent (gnus-summary-article-parent)))
10249 (gnus-summary-goto-subject parent))))
10251 (defun gnus-summary-down-thread (n)
10252 "Go down thread N steps.
10253 If N is negative, go up instead.
10254 Returns the difference between N and how many steps down that were
10259 (while (and (> n 0)
10260 (if up (gnus-summary-go-up-thread)
10261 (gnus-summary-go-down-thread)))
10263 (gnus-summary-position-point)
10265 (gnus-message 7 "Can't go further"))
10268 (defun gnus-summary-up-thread (n)
10269 "Go up thread N steps.
10270 If N is negative, go down instead.
10271 Returns the difference between N and how many steps down that were
10274 (gnus-summary-down-thread (- n)))
10276 (defun gnus-summary-top-thread ()
10277 "Go to the top of the thread."
10279 (while (gnus-summary-go-up-thread))
10280 (gnus-summary-article-number))
10282 (defun gnus-summary-kill-thread (&optional unmark)
10283 "Mark articles under current thread as read.
10284 If the prefix argument is positive, remove any kinds of marks.
10285 If the prefix argument is negative, tick articles instead."
10288 (setq unmark (prefix-numeric-value unmark)))
10289 (let ((articles (gnus-summary-articles-in-thread)))
10291 ;; Expand the thread.
10292 (gnus-summary-show-thread)
10293 ;; Mark all the articles.
10295 (gnus-summary-goto-subject (car articles))
10296 (cond ((null unmark)
10297 (gnus-summary-mark-article-as-read gnus-killed-mark))
10299 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10301 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10302 (setq articles (cdr articles))))
10303 ;; Hide killed subtrees.
10305 gnus-thread-hide-killed
10306 (gnus-summary-hide-thread))
10307 ;; If marked as read, go to next unread subject.
10308 (when (null unmark)
10309 ;; Go to next unread subject.
10310 (gnus-summary-next-subject 1 t)))
10311 (gnus-set-mode-line 'summary))
10313 ;; Summary sorting commands
10315 (defun gnus-summary-sort-by-number (&optional reverse)
10316 "Sort the summary buffer by article number.
10317 Argument REVERSE means reverse order."
10319 (gnus-summary-sort 'number reverse))
10321 (defun gnus-summary-sort-by-random (&optional reverse)
10322 "Randomize the order in the summary buffer.
10323 Argument REVERSE means to randomize in reverse order."
10325 (gnus-summary-sort 'random reverse))
10327 (defun gnus-summary-sort-by-author (&optional reverse)
10328 "Sort the summary buffer by author name alphabetically.
10329 If `case-fold-search' is non-nil, case of letters is ignored.
10330 Argument REVERSE means reverse order."
10332 (gnus-summary-sort 'author reverse))
10334 (defun gnus-summary-sort-by-subject (&optional reverse)
10335 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10336 If `case-fold-search' is non-nil, case of letters is ignored.
10337 Argument REVERSE means reverse order."
10339 (gnus-summary-sort 'subject reverse))
10341 (defun gnus-summary-sort-by-date (&optional reverse)
10342 "Sort the summary buffer by date.
10343 Argument REVERSE means reverse order."
10345 (gnus-summary-sort 'date reverse))
10347 (defun gnus-summary-sort-by-score (&optional reverse)
10348 "Sort the summary buffer by score.
10349 Argument REVERSE means reverse order."
10351 (gnus-summary-sort 'score reverse))
10353 (defun gnus-summary-sort-by-lines (&optional reverse)
10354 "Sort the summary buffer by the number of lines.
10355 Argument REVERSE means reverse order."
10357 (gnus-summary-sort 'lines reverse))
10359 (defun gnus-summary-sort-by-chars (&optional reverse)
10360 "Sort the summary buffer by article length.
10361 Argument REVERSE means reverse order."
10363 (gnus-summary-sort 'chars reverse))
10365 (defun gnus-summary-sort-by-original (&optional reverse)
10366 "Sort the summary buffer using the default sorting method.
10367 Argument REVERSE means reverse order."
10369 (let* ((buffer-read-only)
10370 (gnus-summary-prepare-hook nil))
10371 ;; We do the sorting by regenerating the threads.
10372 (gnus-summary-prepare)
10373 ;; Hide subthreads if needed.
10374 (gnus-summary-maybe-hide-threads)))
10376 (defun gnus-summary-sort (predicate reverse)
10377 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10378 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10379 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10380 (gnus-thread-sort-functions
10385 (gnus-sort-gathered-threads-function
10386 gnus-thread-sort-functions)
10387 (gnus-article-sort-functions
10391 (,article t2 t1))))
10393 (gnus-summary-prepare-hook nil))
10394 ;; We do the sorting by regenerating the threads.
10395 (gnus-summary-prepare)
10396 ;; Hide subthreads if needed.
10397 (gnus-summary-maybe-hide-threads)))
10399 ;; Summary saving commands.
10401 (defun gnus-summary-save-article (&optional n not-saved)
10402 "Save the current article using the default saver function.
10403 If N is a positive number, save the N next articles.
10404 If N is a negative number, save the N previous articles.
10405 If N is nil and any articles have been marked with the process mark,
10406 save those articles instead.
10407 The variable `gnus-default-article-saver' specifies the saver function."
10409 (let* ((articles (gnus-summary-work-articles n))
10410 (save-buffer (save-excursion
10411 (nnheader-set-temp-buffer " *Gnus Save*")))
10412 (num (length articles))
10414 (dolist (article articles)
10415 (setq header (gnus-summary-article-header article))
10416 (if (not (vectorp header))
10417 ;; This is a pseudo-article.
10418 (if (assq 'name header)
10419 (gnus-copy-file (cdr (assq 'name header)))
10420 (gnus-message 1 "Article %d is unsaveable" article))
10421 ;; This is a real article.
10422 (save-window-excursion
10423 (let ((gnus-display-mime-function nil)
10424 (gnus-article-prepare-hook nil))
10425 (gnus-summary-select-article t nil nil article)))
10427 (set-buffer save-buffer)
10429 (insert-buffer-substring gnus-original-article-buffer))
10430 (setq file (gnus-article-save save-buffer file num))
10431 (gnus-summary-remove-process-mark article)
10433 (gnus-summary-set-saved-mark article))))
10434 (gnus-kill-buffer save-buffer)
10435 (gnus-summary-position-point)
10436 (gnus-set-mode-line 'summary)
10439 (defun gnus-summary-pipe-output (&optional arg)
10440 "Pipe the current article to a subprocess.
10441 If N is a positive number, pipe the N next articles.
10442 If N is a negative number, pipe the N previous articles.
10443 If N is nil and any articles have been marked with the process mark,
10444 pipe those articles instead."
10446 (require 'gnus-art)
10447 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10448 (gnus-summary-save-article arg t))
10449 (let ((buffer (get-buffer "*Shell Command Output*")))
10451 (with-current-buffer buffer (> (point-max) (point-min))))
10452 (gnus-configure-windows 'pipe))))
10454 (defun gnus-summary-save-article-mail (&optional arg)
10455 "Append the current article to an mail file.
10456 If N is a positive number, save the N next articles.
10457 If N is a negative number, save the N previous articles.
10458 If N is nil and any articles have been marked with the process mark,
10459 save those articles instead."
10461 (require 'gnus-art)
10462 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10463 (gnus-summary-save-article arg)))
10465 (defun gnus-summary-save-article-rmail (&optional arg)
10466 "Append the current article to an rmail file.
10467 If N is a positive number, save the N next articles.
10468 If N is a negative number, save the N previous articles.
10469 If N is nil and any articles have been marked with the process mark,
10470 save those articles instead."
10472 (require 'gnus-art)
10473 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10474 (gnus-summary-save-article arg)))
10476 (defun gnus-summary-save-article-file (&optional arg)
10477 "Append the current article to a file.
10478 If N is a positive number, save the N next articles.
10479 If N is a negative number, save the N previous articles.
10480 If N is nil and any articles have been marked with the process mark,
10481 save those articles instead."
10483 (require 'gnus-art)
10484 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10485 (gnus-summary-save-article arg)))
10487 (defun gnus-summary-write-article-file (&optional arg)
10488 "Write the current article to a file, deleting the previous file.
10489 If N is a positive number, save the N next articles.
10490 If N is a negative number, save the N previous articles.
10491 If N is nil and any articles have been marked with the process mark,
10492 save those articles instead."
10494 (require 'gnus-art)
10495 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10496 (gnus-summary-save-article arg)))
10498 (defun gnus-summary-save-article-body-file (&optional arg)
10499 "Append the current article body to a 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-body-in-file))
10507 (gnus-summary-save-article arg)))
10509 (defun gnus-summary-muttprint (&optional arg)
10510 "Print the current article using Muttprint.
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-pipe-to-muttprint))
10518 (gnus-summary-save-article arg t)))
10520 (defun gnus-summary-pipe-message (program)
10521 "Pipe the current article through PROGRAM."
10522 (interactive "sProgram: ")
10523 (gnus-summary-select-article)
10524 (let ((mail-header-separator ""))
10525 (gnus-eval-in-buffer-window gnus-article-buffer
10528 (let ((start (window-start))
10530 (message-pipe-buffer-body program)
10531 (set-window-start (get-buffer-window (current-buffer)) start))))))
10533 (defun gnus-get-split-value (methods)
10534 "Return a value based on the split METHODS."
10535 (let (split-name method result match)
10538 (set-buffer gnus-original-article-buffer)
10540 (nnheader-narrow-to-headers)
10541 (while (and methods (not split-name))
10542 (goto-char (point-min))
10543 (setq method (pop methods))
10544 (setq match (car method))
10547 ;; Regular expression.
10549 (re-search-forward match nil t)))
10550 ((gnus-functionp match)
10554 (setq result (funcall match gnus-newsgroup-name))))
10559 (setq result (eval match)))))
10560 (setq split-name (cdr method))
10561 (cond ((stringp result)
10562 (push (expand-file-name
10563 result gnus-article-save-directory)
10566 (setq split-name (append result split-name)))))))))
10567 (nreverse split-name)))
10569 (defun gnus-valid-move-group-p (group)
10570 (and (boundp group)
10571 (symbol-name group)
10572 (symbol-value group)
10573 (gnus-get-function (gnus-find-method-for-group
10574 (symbol-name group)) 'request-accept-article t)))
10576 (defun gnus-read-move-group-name (prompt default articles prefix)
10577 "Read a group name."
10578 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10579 (minibuffer-confirm-incomplete nil) ; XEmacs
10581 (format "%s %s to:"
10583 (if (> (length articles) 1)
10584 (format "these %d articles" (length articles))
10589 (gnus-completing-read-with-default
10592 'gnus-valid-move-group-p
10594 'gnus-group-history))
10595 ((= 1 (length split-name))
10596 (gnus-completing-read-with-default
10597 (car split-name) prom
10599 'gnus-valid-move-group-p
10601 'gnus-group-history))
10603 (gnus-completing-read-with-default
10605 (mapcar (lambda (el) (list el))
10606 (nreverse split-name))
10608 'gnus-group-history))))
10609 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10611 (if (or (string= to-newsgroup "")
10612 (string= to-newsgroup prefix))
10613 (setq to-newsgroup default))
10614 (unless to-newsgroup
10615 (error "No group name entered"))
10616 (or (gnus-active to-newsgroup)
10617 (gnus-activate-group to-newsgroup nil nil to-method)
10618 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10620 (or (and (gnus-request-create-group to-newsgroup to-method)
10621 (gnus-activate-group
10622 to-newsgroup nil nil to-method)
10623 (gnus-subscribe-group to-newsgroup))
10624 (error "Couldn't create group %s" to-newsgroup)))
10625 (error "No such group: %s" to-newsgroup)))
10628 (defun gnus-summary-save-parts (type dir n &optional reverse)
10629 "Save parts matching TYPE to DIR.
10630 If REVERSE, save parts that do not match TYPE."
10632 (list (read-string "Save parts of type: "
10633 (or (car gnus-summary-save-parts-type-history)
10634 gnus-summary-save-parts-default-mime)
10635 'gnus-summary-save-parts-type-history)
10636 (setq gnus-summary-save-parts-last-directory
10637 (read-file-name "Save to directory: "
10638 gnus-summary-save-parts-last-directory
10640 current-prefix-arg))
10641 (gnus-summary-iterate n
10642 (let ((gnus-display-mime-function nil)
10643 (gnus-inhibit-treatment t))
10644 (gnus-summary-select-article))
10646 (set-buffer gnus-article-buffer)
10647 (let ((handles (or gnus-article-mime-handles
10648 (mm-dissect-buffer nil gnus-article-loose-mime)
10651 (gnus-summary-save-parts-1 type dir handles reverse)
10652 (unless gnus-article-mime-handles ;; Don't destroy this case.
10653 (mm-destroy-parts handles)))))))
10655 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10656 (if (stringp (car handle))
10657 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10660 (not (string-match type (mm-handle-media-type handle)))
10661 (string-match type (mm-handle-media-type handle)))
10662 (let ((file (expand-file-name
10663 (file-name-nondirectory
10665 (mail-content-type-get
10666 (mm-handle-disposition handle) 'filename)
10667 (concat gnus-newsgroup-name
10668 "." (number-to-string
10669 (cdr gnus-article-current)))))
10671 (unless (file-exists-p file)
10672 (mm-save-part-to-file handle file))))))
10674 ;; Summary extract commands
10676 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10677 (let ((buffer-read-only nil)
10678 (article (gnus-summary-article-number))
10680 (unless (gnus-summary-goto-subject article)
10681 (error "No such article: %d" article))
10682 (gnus-summary-position-point)
10683 ;; If all commands are to be bunched up on one line, we collect
10685 (unless gnus-view-pseudos-separately
10686 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10689 (setq action (cdr (assq 'action (car ps))))
10690 (setq files (list (cdr (assq 'name (car ps)))))
10691 (while (and ps (cdr ps)
10692 (string= (or action "1")
10693 (or (cdr (assq 'action (cadr ps))) "2")))
10694 (push (cdr (assq 'name (cadr ps))) files)
10695 (setcdr ps (cddr ps)))
10697 (when (not (string-match "%s" action))
10700 (when (assq 'execute (car ps))
10701 (setcdr (assq 'execute (car ps))
10702 (funcall (if (string-match "%s" action)
10709 (gnus-quote-arg-for-sh-or-csh f)))
10711 (setq ps (cdr ps)))))
10712 (if (and gnus-view-pseudos (not not-view))
10714 (when (assq 'execute (car pslist))
10715 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10716 (eq gnus-view-pseudos 'not-confirm)))
10717 (setq pslist (cdr pslist)))
10720 (setq after-article (or (cdr (assq 'article (car pslist)))
10721 (gnus-summary-article-number)))
10722 (gnus-summary-goto-subject after-article)
10725 (insert " " (file-name-nondirectory
10726 (cdr (assq 'name (car pslist))))
10727 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10729 (forward-line -1) ; back to `b'
10730 (gnus-add-text-properties
10731 b (1- e) (list 'gnus-number gnus-reffed-article-number
10732 gnus-mouse-face-prop gnus-mouse-face))
10734 after-article gnus-reffed-article-number
10735 gnus-unread-mark b (car pslist) 0 (- e b))
10736 (setq gnus-newsgroup-unreads
10737 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10738 gnus-reffed-article-number))
10739 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10740 (setq pslist (cdr pslist)))))))
10742 (defun gnus-pseudos< (p1 p2)
10743 (let ((c1 (cdr (assq 'action p1)))
10744 (c2 (cdr (assq 'action p2))))
10745 (and c1 c2 (string< c1 c2))))
10747 (defun gnus-request-pseudo-article (props)
10748 (cond ((assq 'execute props)
10749 (gnus-execute-command (cdr (assq 'execute props)))))
10750 (let ((gnus-current-article (gnus-summary-article-number)))
10751 (gnus-run-hooks 'gnus-mark-article-hook)))
10753 (defun gnus-execute-command (command &optional automatic)
10755 (gnus-article-setup-buffer)
10756 (set-buffer gnus-article-buffer)
10757 (setq buffer-read-only nil)
10758 (let ((command (if automatic command
10759 (read-string "Command: " (cons command 0)))))
10761 (insert "$ " command "\n\n")
10762 (if gnus-view-pseudo-asynchronously
10763 (start-process "gnus-execute" (current-buffer) shell-file-name
10764 shell-command-switch command)
10765 (call-process shell-file-name nil t nil
10766 shell-command-switch command)))))
10768 ;; Summary kill commands.
10770 (defun gnus-summary-edit-global-kill (article)
10771 "Edit the \"global\" kill file."
10772 (interactive (list (gnus-summary-article-number)))
10773 (gnus-group-edit-global-kill article))
10775 (defun gnus-summary-edit-local-kill ()
10776 "Edit a local kill file applied to the current newsgroup."
10778 (setq gnus-current-headers (gnus-summary-article-header))
10779 (gnus-group-edit-local-kill
10780 (gnus-summary-article-number) gnus-newsgroup-name))
10782 ;;; Header reading.
10784 (defun gnus-read-header (id &optional header)
10785 "Read the headers of article ID and enter them into the Gnus system."
10786 (let ((group gnus-newsgroup-name)
10787 (gnus-override-method
10789 gnus-override-method
10790 (and (gnus-news-group-p gnus-newsgroup-name)
10791 (car (gnus-refer-article-methods)))))
10793 ;; First we check to see whether the header in question is already
10796 ;; This is a Message-ID.
10797 (setq header (or header (gnus-id-to-header id)))
10798 ;; This is an article number.
10799 (setq header (or header (gnus-summary-article-header id))))
10801 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10802 ;; We have found the header.
10804 ;; If this is a sparse article, we have to nix out its
10805 ;; previous entry in the thread hashtb.
10807 (gnus-summary-article-sparse-p (mail-header-number header)))
10808 (let* ((parent (gnus-parent-id (mail-header-references header)))
10809 (thread (and parent (gnus-id-to-thread parent))))
10811 (delq (assq header thread) thread))))
10812 ;; We have to really fetch the header to this article.
10814 (set-buffer nntp-server-buffer)
10815 (when (setq where (gnus-request-head id group))
10816 (nnheader-fold-continuation-lines)
10817 (goto-char (point-max))
10819 (goto-char (point-min))
10823 ((cdr where) (cdr where))
10824 (header (mail-header-number header))
10825 (t gnus-reffed-article-number))
10827 (insert " Article retrieved.\n"))
10828 (if (or (not where)
10829 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10830 () ; Malformed head.
10831 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10832 (when (and (stringp id)
10833 (not (string= (gnus-group-real-name group)
10835 ;; If we fetched by Message-ID and the article came
10836 ;; from a different group, we fudge some bogus article
10837 ;; numbers for this article.
10838 (mail-header-set-number header gnus-reffed-article-number))
10840 (set-buffer gnus-summary-buffer)
10841 (decf gnus-reffed-article-number)
10842 (gnus-remove-header (mail-header-number header))
10843 (push header gnus-newsgroup-headers)
10844 (setq gnus-current-headers header)
10845 (push (mail-header-number header) gnus-newsgroup-limit)))
10848 (defun gnus-remove-header (number)
10849 "Remove header NUMBER from `gnus-newsgroup-headers'."
10850 (if (and gnus-newsgroup-headers
10851 (= number (mail-header-number (car gnus-newsgroup-headers))))
10852 (pop gnus-newsgroup-headers)
10853 (let ((headers gnus-newsgroup-headers))
10854 (while (and (cdr headers)
10855 (not (= number (mail-header-number (cadr headers)))))
10857 (when (cdr headers)
10858 (setcdr headers (cddr headers))))))
10861 ;;; summary highlights
10864 (defun gnus-highlight-selected-summary ()
10865 "Highlight selected article in summary buffer."
10866 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10867 (when gnus-summary-selected-face
10869 (let* ((beg (progn (beginning-of-line) (point)))
10870 (end (progn (end-of-line) (point)))
10871 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10872 (from (if (get-text-property beg gnus-mouse-face-prop)
10874 (or (next-single-property-change
10875 beg gnus-mouse-face-prop nil end)
10880 (or (next-single-property-change
10881 from gnus-mouse-face-prop nil end)
10883 ;; If no mouse-face prop on line we will have to = from = end,
10884 ;; so we highlight the entire line instead.
10885 (when (= (+ to 2) from)
10888 (if gnus-newsgroup-selected-overlay
10889 ;; Move old overlay.
10891 gnus-newsgroup-selected-overlay from to (current-buffer))
10892 ;; Create new overlay.
10894 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
10895 'face gnus-summary-selected-face))))))
10897 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
10898 (defun gnus-summary-highlight-line ()
10899 "Highlight current line according to `gnus-summary-highlight'."
10900 (let* ((list gnus-summary-highlight)
10901 (beg (gnus-point-at-bol))
10902 (article (gnus-summary-article-number))
10903 (score (or (cdr (assq (or article gnus-current-article)
10904 gnus-newsgroup-scored))
10905 gnus-summary-default-score 0))
10906 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
10907 (inhibit-read-only t)
10908 (default gnus-summary-default-score)
10909 (default-high gnus-summary-default-high-score)
10910 (default-low gnus-summary-default-low-score))
10911 ;; Eval the cars of the lists until we find a match.
10913 (not (eval (caar list))))
10914 (setq list (cdr list)))
10915 (let ((face (cdar list)))
10916 (unless (eq face (get-text-property beg 'face))
10917 (gnus-put-text-property-excluding-characters-with-faces
10918 beg (gnus-point-at-eol) 'face
10919 (setq face (if (boundp face) (symbol-value face) face)))
10920 (when gnus-summary-highlight-line-function
10921 (funcall gnus-summary-highlight-line-function article face))))))
10923 (defun gnus-update-read-articles (group unread &optional compute)
10924 "Update the list of read articles in GROUP.
10925 UNREAD is a sorted list."
10926 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
10927 (entry (gnus-gethash group gnus-newsrc-hashtb))
10928 (info (nth 2 entry))
10931 (if (or (not info) (not active))
10932 ;; There is no info on this group if it was, in fact,
10933 ;; killed. Gnus stores no information on killed groups, so
10934 ;; there's nothing to be done.
10935 ;; One could store the information somewhere temporarily,
10936 ;; perhaps... Hmmm...
10938 ;; Remove any negative articles numbers.
10939 (while (and unread (< (car unread) 0))
10940 (setq unread (cdr unread)))
10941 ;; Remove any expired article numbers
10942 (while (and unread (< (car unread) (car active)))
10943 (setq unread (cdr unread)))
10944 ;; Compute the ranges of read articles by looking at the list of
10945 ;; unread articles.
10947 (when (/= (car unread) prev)
10948 (push (if (= prev (1- (car unread))) prev
10949 (cons prev (1- (car unread))))
10951 (setq prev (1+ (car unread)))
10952 (setq unread (cdr unread)))
10953 (when (<= prev (cdr active))
10954 (push (cons prev (cdr active)) read))
10955 (setq read (if (> (length read) 1) (nreverse read) read))
10960 ;; Propagate the read marks to the backend.
10961 (when (gnus-check-backend-function 'request-set-mark group)
10962 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
10963 (add (gnus-remove-from-range read (gnus-info-read info))))
10965 (unless (gnus-check-group group)
10966 (error "Can't open server for %s" group))
10967 (gnus-request-set-mark
10968 group (delq nil (list (if add (list add 'add '(read)))
10969 (if del (list del 'del '(read))))))
10971 `(gnus-request-set-mark
10974 (if del (list del 'add '(read)))
10975 (if add (list add 'del '(read))))))))))
10976 (set-buffer gnus-group-buffer)
10977 (gnus-undo-register
10979 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
10980 (gnus-info-set-read ',info ',(gnus-info-read info))
10981 (gnus-get-unread-articles-in-group ',info
10982 (gnus-active ,group))
10983 (gnus-group-update-group ,group t)
10985 ;; Enter this list into the group info.
10986 (gnus-info-set-read info read)
10987 ;; Set the number of unread articles in gnus-newsrc-hashtb.
10988 (gnus-get-unread-articles-in-group info (gnus-active group))
10991 (defun gnus-offer-save-summaries ()
10992 "Offer to save all active summary buffers."
10994 ;; Go through all buffers and find all summaries.
10995 (dolist (buffer (buffer-list))
10996 (when (and (setq buffer (buffer-name buffer))
10997 (string-match "Summary" buffer)
10999 (set-buffer buffer)
11000 ;; We check that this is, indeed, a summary buffer.
11001 (and (eq major-mode 'gnus-summary-mode)
11002 ;; Also make sure this isn't bogus.
11003 gnus-newsgroup-prepared
11004 ;; Also make sure that this isn't a
11005 ;; dead summary buffer.
11006 (not gnus-dead-summary-mode))))
11007 (push buffer buffers)))
11008 ;; Go through all these summary buffers and offer to save them.
11012 "Update summary buffer %s? "
11014 (switch-to-buffer buf)
11015 (gnus-summary-exit))
11019 ;;; @ for mime-partial
11022 (defun gnus-request-partial-message ()
11024 (let ((number (gnus-summary-article-number))
11025 (group gnus-newsgroup-name)
11026 (mother gnus-article-buffer))
11027 (set-buffer (get-buffer-create " *Partial Article*"))
11029 (setq mime-preview-buffer mother)
11030 (gnus-request-article-this-buffer number group)
11031 (mime-parse-buffer)
11034 (autoload 'mime-combine-message/partial-pieces-automatically
11036 "Internal method to combine message/partial messages automatically.")
11038 (mime-add-condition
11039 'action '((type . message)(subtype . partial)
11040 (major-mode . gnus-original-article-mode)
11041 (method . mime-combine-message/partial-pieces-automatically)
11042 (summary-buffer-exp . gnus-summary-buffer)
11043 (request-partial-message-method . gnus-request-partial-message)
11047 ;;; @ for message/rfc822
11050 (defun gnus-mime-extract-message/rfc822 (entity situation)
11051 "Burst a forwarded article."
11053 (set-buffer gnus-summary-buffer)
11054 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11055 gnus-newsgroup-name 'gnus-group-history))
11056 (gnus-group-marked (list group))
11059 (mime-insert-entity-content entity)
11060 (setq article (gnus-request-accept-article group)))
11061 (when (and (consp article)
11062 (numberp (setq article (cdr article))))
11063 (setq info (gnus-get-info group))
11064 (gnus-info-set-read info
11065 (gnus-remove-from-range (gnus-info-read info)
11067 (when (string-equal group gnus-newsgroup-name)
11069 (let (gnus-show-threads)
11070 (gnus-summary-goto-subject article t))
11071 (gnus-summary-clear-mark-forward 1))
11072 (set-buffer gnus-group-buffer)
11073 (gnus-group-get-new-news-this-group nil t)))))
11075 (mime-add-condition
11076 'action '((type . message)(subtype . rfc822)
11077 (major-mode . gnus-original-article-mode)
11078 (method . gnus-mime-extract-message/rfc822)
11082 (mime-add-condition
11083 'action '((type . message)(subtype . news)
11084 (major-mode . gnus-original-article-mode)
11085 (method . gnus-mime-extract-message/rfc822)
11089 (defun gnus-mime-extract-multipart (entity situation)
11090 (let ((children (mime-entity-children entity))
11091 mime-acting-situation-to-override
11094 (mime-play-entity (car children)
11095 (cons (assq 'mode situation)
11096 mime-acting-situation-to-override))
11097 (setq children (cdr children)))
11098 (if (setq f (cdr (assq 'after-method
11099 mime-acting-situation-to-override)))
11103 (mime-add-condition
11104 'action '((type . multipart)
11105 (method . gnus-mime-extract-multipart)
11114 (defun gnus-summary-inherit-default-charset ()
11115 "Import `default-mime-charset' from summary buffer."
11116 (if (buffer-live-p gnus-summary-buffer)
11117 (if (local-variable-p 'default-mime-charset gnus-summary-buffer)
11119 (make-local-variable 'default-mime-charset)
11120 (setq default-mime-charset
11121 (with-current-buffer gnus-summary-buffer
11122 default-mime-charset)))
11123 (kill-local-variable 'default-mime-charset))))
11125 (defun gnus-summary-setup-default-charset ()
11126 "Setup newsgroup default charset."
11127 (if (equal gnus-newsgroup-name "nndraft:drafts")
11129 (setq gnus-newsgroup-charset nil)
11130 (make-local-variable 'default-mime-charset)
11131 (setq default-mime-charset nil))
11132 (let ((ignored-charsets
11133 (or gnus-newsgroup-ephemeral-ignored-charsets
11135 (and gnus-newsgroup-name
11136 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11137 gnus-newsgroup-ignored-charsets)))
11139 (setq gnus-newsgroup-charset
11140 (or gnus-newsgroup-ephemeral-charset
11141 (when (and gnus-newsgroup-name
11142 (setq charset (gnus-parameter-charset
11143 gnus-newsgroup-name)))
11144 (make-local-variable 'default-mime-charset)
11145 (setq default-mime-charset charset))
11146 gnus-default-charset))
11147 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11148 ignored-charsets))))
11154 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11155 "Display the current article buffer fully MIME-buttonized.
11156 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11157 treated as multipart/mixed."
11159 (require 'gnus-art)
11160 (let ((gnus-unbuttonized-mime-types nil)
11161 (gnus-mime-display-multipart-as-mixed show-all-parts))
11162 (gnus-summary-show-article)))
11164 (defun gnus-summary-repair-multipart (article)
11165 "Add a Content-Type header to a multipart article without one."
11166 (interactive (list (gnus-summary-article-number)))
11167 (gnus-with-article article
11168 (message-narrow-to-head)
11169 (message-remove-header "Mime-Version")
11170 (goto-char (point-max))
11171 (insert "Mime-Version: 1.0\n")
11173 (when (search-forward "\n--" nil t)
11174 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11175 (message-narrow-to-head)
11176 (message-remove-header "Content-Type")
11177 (goto-char (point-max))
11178 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11181 (let (gnus-mark-article-hook)
11182 (gnus-summary-select-article t t nil article)))
11184 (defun gnus-summary-toggle-display-buttonized ()
11185 "Toggle the buttonizing of the article buffer."
11187 (require 'gnus-art)
11188 (if (setq gnus-inhibit-mime-unbuttonizing
11189 (not gnus-inhibit-mime-unbuttonizing))
11190 (let ((gnus-unbuttonized-mime-types nil))
11191 (gnus-summary-show-article))
11192 (gnus-summary-show-article)))
11195 ;;; Intelli-mouse commmands
11198 (defun gnus-wheel-summary-scroll (event)
11200 (let ((amount (if (memq 'shift (event-modifiers event))
11201 (car gnus-wheel-scroll-amount)
11202 (cdr gnus-wheel-scroll-amount)))
11203 (direction (- (* (static-if (featurep 'xemacs)
11204 (event-button event)
11205 (cond ((eq 'mouse-4 (event-basic-type event))
11207 ((eq 'mouse-5 (event-basic-type event))
11211 (gnus-summary-scroll-up (* amount direction))
11212 (when (gnus-eval-in-buffer-window gnus-article-buffer
11215 (and (if (< 0 direction)
11216 (gnus-article-next-page 0)
11217 (gnus-article-prev-page 0)
11219 (if (setq edge (get-text-property
11220 (point-min) 'gnus-wheel-edge))
11221 (setq edge (* edge direction))
11224 (let ((buffer-read-only nil)
11225 (inhibit-read-only t))
11226 (put-text-property (point-min) (point-max)
11227 'gnus-wheel-edge direction)
11229 (or (> edge gnus-wheel-edge-resistance)
11230 (let ((buffer-read-only nil)
11231 (inhibit-read-only t))
11232 (put-text-property (point-min) (point-max)
11234 (* (1+ edge) direction))
11236 (eq last-command 'gnus-wheel-summary-scroll))))
11237 (gnus-summary-next-article nil nil (minusp direction)))))
11239 (defun gnus-wheel-install ()
11240 "Enable mouse wheel support on summary window."
11241 (when gnus-use-wheel
11243 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11245 (define-key gnus-summary-mode-map key
11246 'gnus-wheel-summary-scroll)))))
11248 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11251 ;;; Traditional PGP commmands
11254 (defun gnus-summary-decrypt-article (&optional force)
11255 "Decrypt the current article in traditional PGP way.
11256 This will have permanent effect only in mail groups.
11257 If FORCE is non-nil, allow editing of articles even in read-only
11260 (gnus-summary-select-article t)
11261 (gnus-eval-in-buffer-window gnus-article-buffer
11265 (goto-char (point-min))
11266 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11267 (error "Not a traditional PGP message!"))
11268 (let ((armor-start (match-beginning 0)))
11269 (if (and (pgg-decrypt-region armor-start (point-max))
11270 (or force (not (gnus-group-read-only-p))))
11271 (let ((inhibit-read-only t)
11273 (delete-region armor-start
11275 (re-search-forward "^-+END PGP" nil t)
11276 (beginning-of-line 2)
11278 (insert-buffer-substring pgg-output-buffer))))))))
11280 (defun gnus-summary-verify-article ()
11281 "Verify the current article in traditional PGP way."
11284 (set-buffer gnus-original-article-buffer)
11285 (goto-char (point-min))
11286 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11287 (error "Not a traditional PGP message!"))
11288 (re-search-forward "^-+END PGP" nil t)
11289 (beginning-of-line 2)
11290 (call-interactively (function pgg-verify-region))))
11293 ;;; Generic summary marking commands
11296 (defvar gnus-summary-marking-alist
11297 '((read gnus-del-mark "d")
11298 (unread gnus-unread-mark "u")
11299 (ticked gnus-ticked-mark "!")
11300 (dormant gnus-dormant-mark "?")
11301 (expirable gnus-expirable-mark "e"))
11302 "An alist of names/marks/keystrokes.")
11304 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11305 (defvar gnus-summary-mark-map)
11307 (defun gnus-summary-make-all-marking-commands ()
11308 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11309 (dolist (elem gnus-summary-marking-alist)
11310 (apply 'gnus-summary-make-marking-command elem)))
11312 (defun gnus-summary-make-marking-command (name mark keystroke)
11313 (let ((map (make-sparse-keymap)))
11314 (define-key gnus-summary-generic-mark-map keystroke map)
11315 (dolist (lway `((next "next" next nil "n")
11316 (next-unread "next unread" next t "N")
11317 (prev "previous" prev nil "p")
11318 (prev-unread "previous unread" prev t "P")
11319 (nomove "" nil nil ,keystroke)))
11320 (let ((func (gnus-summary-make-marking-command-1
11321 mark (car lway) lway name)))
11322 (setq func (eval func))
11323 (define-key map (nth 4 lway) func)))))
11325 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11327 (format "gnus-summary-put-mark-as-%s%s"
11328 name (if (eq way 'nomove)
11330 (concat "-" (symbol-name way)))))
11333 "Mark the current article as %s%s.
11334 If N, the prefix, then repeat N times.
11335 If N is negative, move in reverse order.
11336 The difference between N and the actual number of articles marked is
11338 name (car (cdr lway)))
11340 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11342 (defun gnus-summary-generic-mark (n mark move unread)
11343 "Mark N articles with MARK."
11344 (unless (eq major-mode 'gnus-summary-mode)
11345 (error "This command can only be used in the summary buffer"))
11346 (gnus-summary-show-thread)
11349 ((eq move 'next) 1)
11350 ((eq move 'prev) -1)
11352 (if (zerop nummove)
11356 nummove (* -1 nummove))))
11357 (while (and (> n 0)
11358 (gnus-summary-mark-article nil mark)
11359 (zerop (gnus-summary-next-subject nummove unread t)))
11362 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11363 (gnus-summary-recenter)
11364 (gnus-summary-position-point)
11365 (gnus-set-mode-line 'summary)
11368 (defun gnus-summary-insert-articles (articles)
11369 (when (setq articles
11370 (gnus-sorted-difference articles
11371 (mapcar (lambda (h)
11372 (mail-header-number h))
11373 gnus-newsgroup-headers)))
11374 (setq gnus-newsgroup-headers
11376 gnus-newsgroup-headers
11377 (gnus-fetch-headers articles)
11378 'gnus-article-sort-by-number))
11379 ;; Suppress duplicates?
11380 (when gnus-suppress-duplicates
11381 (gnus-dup-suppress-articles))
11383 ;; We might want to build some more threads first.
11384 (when (and gnus-fetch-old-headers
11385 (eq gnus-headers-retrieved-by 'nov))
11386 (if (eq gnus-fetch-old-headers 'invisible)
11387 (gnus-build-all-threads)
11388 (gnus-build-old-threads)))
11389 ;; Let the Gnus agent mark articles as read.
11391 (gnus-agent-get-undownloaded-list))
11392 ;; Remove list identifiers from subject
11393 (when gnus-list-identifiers
11394 (gnus-summary-remove-list-identifiers))
11395 ;; First and last article in this newsgroup.
11396 (when gnus-newsgroup-headers
11397 (setq gnus-newsgroup-begin
11398 (mail-header-number (car gnus-newsgroup-headers))
11400 (mail-header-number
11401 (gnus-last-element gnus-newsgroup-headers))))
11402 (when gnus-use-scoring
11403 (gnus-possibly-score-headers))))
11405 (defun gnus-summary-insert-old-articles (&optional all)
11406 "Insert all old articles in this group.
11407 If ALL is non-nil, already read articles become readable.
11408 If ALL is a number, fetch this number of articles."
11411 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11414 (gnus-sorted-difference
11415 (gnus-uncompress-range (list gnus-newsgroup-active))
11417 (setq len (length older))
11422 (setq older (last older all))))
11425 (if (and (numberp gnus-large-newsgroup)
11426 (> len gnus-large-newsgroup))
11427 (let* ((cursor-in-echo-area nil)
11428 (initial (gnus-parameter-large-newsgroup-initial
11429 gnus-newsgroup-name))
11433 "How many articles from %s (%s %d): "
11435 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11436 (if initial "max" "default")
11439 (cons (number-to-string initial)
11441 (unless (string-match "^[ \t]*$" input)
11442 (setq all (string-to-number input))
11444 (setq older (last older all))))))))
11446 (message "No old news.")
11447 (gnus-summary-insert-articles older)
11448 (gnus-summary-limit (gnus-sorted-nunion old older))))
11449 (gnus-summary-position-point)))
11451 (defun gnus-summary-insert-new-articles ()
11452 "Insert all new articles in this group."
11455 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11456 (old-active gnus-newsgroup-active)
11457 (nnmail-fetched-sources (list t))
11459 (setq gnus-newsgroup-active
11460 (gnus-activate-group gnus-newsgroup-name 'scan))
11461 (setq i (cdr gnus-newsgroup-active))
11462 (while (> i (cdr old-active))
11466 (message "No gnus is bad news.")
11467 (gnus-summary-insert-articles new)
11468 (setq gnus-newsgroup-unreads
11469 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11470 (gnus-summary-limit (gnus-sorted-nunion old new))))
11471 (gnus-summary-position-point)))
11473 (gnus-summary-make-all-marking-commands)
11475 (gnus-ems-redefine)
11477 (provide 'gnus-sum)
11479 (run-hooks 'gnus-sum-load-hook)
11481 ;;; gnus-sum.el ends here