1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'gnus-clfns))
49 (autoload 'pgg-decrypt-region "pgg" nil t)
50 (autoload 'pgg-verify-region "pgg" nil t))
52 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
53 (autoload 'gnus-cache-write-active "gnus-cache")
54 (autoload 'gnus-mailing-list-insinuate "gnus-ml" nil t)
55 (autoload 'turn-on-gnus-mailing-list-mode "gnus-ml" nil t)
56 (autoload 'mm-uu-dissect "mm-uu")
57 (autoload 'gnus-article-outlook-deuglify-article "deuglify"
58 "Deuglify broken Outlook (Express) articles and redisplay."
61 (defcustom gnus-kill-summary-on-exit t
62 "*If non-nil, kill the summary buffer when you exit from it.
63 If nil, the summary will become a \"*Dead Summary*\" buffer, and
64 it will be killed sometime later."
65 :group 'gnus-summary-exit
68 (defcustom gnus-fetch-old-headers nil
69 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
70 If an unread article in the group refers to an older, already read (or
71 just marked as read) article, the old article will not normally be
72 displayed in the Summary buffer. If this variable is non-nil, Gnus
73 will attempt to grab the headers to the old articles, and thereby
74 build complete threads. If it has the value `some', only enough
75 headers to connect otherwise loose threads will be displayed. This
76 variable can also be a number. In that case, no more than that number
77 of old headers will be fetched. If it has the value `invisible', all
78 old headers will be fetched, but none will be displayed.
80 The server has to support NOV for any of this to work."
82 :type '(choice (const :tag "off" nil)
85 (sexp :menu-tag "other" t)))
87 (defcustom gnus-refer-thread-limit 200
88 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
89 If t, fetch all the available old headers."
92 (sexp :menu-tag "other" t)))
94 (defcustom gnus-summary-make-false-root 'adopt
95 "*nil means that Gnus won't gather loose threads.
96 If the root of a thread has expired or been read in a previous
97 session, the information necessary to build a complete thread has been
98 lost. Instead of having many small sub-threads from this original thread
99 scattered all over the summary buffer, Gnus can gather them.
101 If non-nil, Gnus will try to gather all loose sub-threads from an
102 original thread into one large thread.
104 If this variable is non-nil, it should be one of `none', `adopt',
107 If this variable is `none', Gnus will not make a false root, but just
108 present the sub-threads after another.
109 If this variable is `dummy', Gnus will create a dummy root that will
110 have all the sub-threads as children.
111 If this variable is `adopt', Gnus will make one of the \"children\"
112 the parent and mark all the step-children as such.
113 If this variable is `empty', the \"children\" are printed with empty
114 subject fields. (Or rather, they will be printed with a string
115 given by the `gnus-summary-same-subject' variable.)"
117 :type '(choice (const :tag "off" nil)
123 (defcustom gnus-summary-make-false-root-always t
124 "Always make a false dummy root."
128 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
129 "*A regexp to match subjects to be excluded from loose thread gathering.
130 As loose thread gathering is done on subjects only, that means that
131 there can be many false gatherings performed. By rooting out certain
132 common subjects, gathering might become saner."
136 (defcustom gnus-summary-gather-subject-limit nil
137 "*Maximum length of subject comparisons when gathering loose threads.
138 Use nil to compare full subjects. Setting this variable to a low
139 number will help gather threads that have been corrupted by
140 newsreaders chopping off subject lines, but it might also mean that
141 unrelated articles that have subject that happen to begin with the
142 same few characters will be incorrectly gathered.
144 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
147 :type '(choice (const :tag "off" nil)
149 (sexp :menu-tag "on" t)))
151 (defcustom gnus-simplify-subject-functions nil
152 "List of functions taking a string argument that simplify subjects.
153 The functions are applied recursively.
155 Useful functions to put in this list include:
156 `gnus-simplify-subject-re', `gnus-simplify-subject-fuzzy',
157 `gnus-simplify-whitespace', and `gnus-simplify-all-whitespace'."
159 :type '(repeat function))
161 (defcustom gnus-simplify-ignored-prefixes nil
162 "*Remove matches for this regexp from subject lines when simplifying fuzzily."
164 :type '(choice (const :tag "off" nil)
167 (defcustom gnus-build-sparse-threads nil
168 "*If non-nil, fill in the gaps in threads.
169 If `some', only fill in the gaps that are needed to tie loose threads
170 together. If `more', fill in all leaf nodes that Gnus can find. If
171 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
173 :type '(choice (const :tag "off" nil)
176 (sexp :menu-tag "all" t)))
178 (defcustom gnus-summary-thread-gathering-function
179 'gnus-gather-threads-by-subject
180 "*Function used for gathering loose threads.
181 There are two pre-defined functions: `gnus-gather-threads-by-subject',
182 which only takes Subjects into consideration; and
183 `gnus-gather-threads-by-references', which compared the References
184 headers of the articles to find matches."
186 :type '(radio (function-item gnus-gather-threads-by-subject)
187 (function-item gnus-gather-threads-by-references)
188 (function :tag "other")))
190 (defcustom gnus-summary-same-subject ""
191 "*String indicating that the current article has the same subject as the previous.
192 This variable will only be used if the value of
193 `gnus-summary-make-false-root' is `empty'."
194 :group 'gnus-summary-format
197 (defcustom gnus-summary-goto-unread t
198 "*If t, many commands will go to the next unread article.
199 This applies to marking commands as well as other commands that
200 \"naturally\" select the next article, like, for instance, `SPC' at
201 the end of an article.
203 If nil, the marking commands do NOT go to the next unread article
204 \(they go to the next article instead). If `never', commands that
205 usually go to the next unread article, will go to the next article,
206 whether it is read or not."
207 :group 'gnus-summary-marks
208 :link '(custom-manual "(gnus)Setting Marks")
209 :type '(choice (const :tag "off" nil)
211 (sexp :menu-tag "on" t)))
213 (defcustom gnus-summary-default-score 0
214 "*Default article score level.
215 All scores generated by the score files will be added to this score.
216 If this variable is nil, scoring will be disabled."
217 :group 'gnus-score-default
218 :type '(choice (const :tag "disable")
221 (defcustom gnus-summary-default-high-score 0
222 "*Default threshold for a high scored article.
223 An article will be highlighted as high scored if its score is greater
225 :group 'gnus-score-default
228 (defcustom gnus-summary-default-low-score 0
229 "*Default threshold for a low scored article.
230 An article will be highlighted as low scored if its score is smaller
232 :group 'gnus-score-default
235 (defcustom gnus-summary-zcore-fuzz 0
236 "*Fuzziness factor for the zcore in the summary buffer.
237 Articles with scores closer than this to `gnus-summary-default-score'
239 :group 'gnus-summary-format
242 (defcustom gnus-simplify-subject-fuzzy-regexp nil
243 "*Strings to be removed when doing fuzzy matches.
244 This can either be a regular expression or list of regular expressions
245 that will be removed from subject strings if fuzzy subject
246 simplification is selected."
248 :type '(repeat regexp))
250 (defcustom gnus-show-threads t
251 "*If non-nil, display threads in summary mode."
255 (defcustom gnus-thread-hide-subtree nil
256 "*If non-nil, hide all threads initially.
257 This can be a predicate specifier which says which threads to hide.
258 If threads are hidden, you have to run the command
259 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
260 to expose hidden threads."
264 (defcustom gnus-thread-hide-killed t
265 "*If non-nil, hide killed threads automatically."
269 (defcustom gnus-thread-ignore-subject t
270 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
271 If nil, articles that have different subjects from their parents will
272 start separate threads."
276 (defcustom gnus-thread-operation-ignore-subject t
277 "*If non-nil, subjects will be ignored when doing thread commands.
278 This affects commands like `gnus-summary-kill-thread' and
279 `gnus-summary-lower-thread'.
281 If this variable is nil, articles in the same thread with different
282 subjects will not be included in the operation in question. If this
283 variable is `fuzzy', only articles that have subjects that are fuzzily
284 equal will be included."
286 :type '(choice (const :tag "off" nil)
290 (defcustom gnus-thread-indent-level 4
291 "*Number that says how much each sub-thread should be indented."
295 (defcustom gnus-auto-extend-newsgroup t
296 "*If non-nil, extend newsgroup forward and backward when requested."
297 :group 'gnus-summary-choose
300 (defcustom gnus-auto-select-first t
301 "*If non-nil, select the article under point.
302 Which article this is is controlled by the `gnus-auto-select-subject'
305 If you want to prevent automatic selection of articles in some
306 newsgroups, set the variable to nil in `gnus-select-group-hook'."
307 :group 'gnus-group-select
308 :type '(choice (const :tag "none" nil)
309 (sexp :menu-tag "first" t)))
311 (defcustom gnus-auto-select-subject 'unread
312 "*Says what subject to place under point when entering a group.
314 This variable can either be the symbols `first' (place point on the
315 first subject), `unread' (place point on the subject line of the first
316 unread article), `best' (place point on the subject line of the
317 higest-scored article), `unseen' (place point on the subject line of
318 the first unseen article), 'unseen-or-unread' (place point on the subject
319 line of the first unseen article or, if all article have been seen, on the
320 subject line of the first unread article), or a function to be called to
321 place point on some subject line."
322 :group 'gnus-group-select
323 :type '(choice (const best)
327 (const unseen-or-unread)))
329 (defcustom gnus-dont-select-after-jump-to-other-group nil
330 "If non-nil, don't select the first unread article after entering the
331 other group by the command `gnus-summary-jump-to-other-group'. If nil,
332 it is depend on the value of `gnus-auto-select-first' whether to select
334 :group 'gnus-group-select
337 (defcustom gnus-auto-select-next t
338 "*If non-nil, offer to go to the next group from the end of the previous.
339 If the value is t and the next newsgroup is empty, Gnus will exit
340 summary mode and go back to group mode. If the value is neither nil
341 nor t, Gnus will select the following unread newsgroup. In
342 particular, if the value is the symbol `quietly', the next unread
343 newsgroup will be selected without any confirmation, and if it is
344 `almost-quietly', the next group will be selected without any
345 confirmation if you are located on the last article in the group.
346 Finally, if this variable is `slightly-quietly', the `Z n' command
347 will go to the next group without confirmation."
348 :group 'gnus-summary-maneuvering
349 :type '(choice (const :tag "off" nil)
351 (const almost-quietly)
352 (const slightly-quietly)
353 (sexp :menu-tag "on" t)))
355 (defcustom gnus-auto-select-same nil
356 "*If non-nil, select the next article with the same subject.
357 If there are no more articles with the same subject, go to
358 the first unread article."
359 :group 'gnus-summary-maneuvering
362 (defcustom gnus-summary-check-current nil
363 "*If non-nil, consider the current article when moving.
364 The \"unread\" movement commands will stay on the same line if the
365 current article is unread."
366 :group 'gnus-summary-maneuvering
369 (defcustom gnus-auto-center-summary t
370 "*If non-nil, always center the current summary buffer.
371 In particular, if `vertical' do only vertical recentering. If non-nil
372 and non-`vertical', do both horizontal and vertical recentering."
373 :group 'gnus-summary-maneuvering
374 :type '(choice (const :tag "none" nil)
376 (integer :tag "height")
377 (sexp :menu-tag "both" t)))
379 (defcustom gnus-show-all-headers nil
380 "*If non-nil, don't hide any headers."
381 :group 'gnus-article-hiding
382 :group 'gnus-article-headers
385 (defcustom gnus-summary-ignore-duplicates nil
386 "*If non-nil, ignore articles with identical Message-ID headers."
390 (defcustom gnus-single-article-buffer t
391 "*If non-nil, display all articles in the same buffer.
392 If nil, each group will get its own article buffer."
393 :group 'gnus-article-various
396 (defcustom gnus-break-pages t
397 "*If non-nil, do page breaking on articles.
398 The page delimiter is specified by the `gnus-page-delimiter'
400 :group 'gnus-article-various
403 (defcustom gnus-show-mime t
404 "*If non-nil, do mime processing of articles.
405 The articles will simply be fed to the function given by
406 `gnus-article-display-method-for-mime'."
407 :group 'gnus-article-mime
410 (defcustom gnus-move-split-methods nil
411 "*Variable used to suggest where articles are to be moved to.
412 It uses the same syntax as the `gnus-split-methods' variable.
413 However, whereas `gnus-split-methods' specifies file names as targets,
414 this variable specifies group names."
415 :group 'gnus-summary-mail
416 :type '(repeat (choice (list :value (fun) function)
417 (cons :value ("" "") regexp (repeat string))
420 (defcustom gnus-unread-mark ?\ ;;;Whitespace
421 "*Mark used for unread articles."
422 :group 'gnus-summary-marks
425 (defcustom gnus-ticked-mark ?!
426 "*Mark used for ticked articles."
427 :group 'gnus-summary-marks
430 (defcustom gnus-dormant-mark ??
431 "*Mark used for dormant articles."
432 :group 'gnus-summary-marks
435 (defcustom gnus-del-mark ?r
436 "*Mark used for del'd articles."
437 :group 'gnus-summary-marks
440 (defcustom gnus-read-mark ?R
441 "*Mark used for read articles."
442 :group 'gnus-summary-marks
445 (defcustom gnus-expirable-mark ?E
446 "*Mark used for expirable articles."
447 :group 'gnus-summary-marks
450 (defcustom gnus-killed-mark ?K
451 "*Mark used for killed articles."
452 :group 'gnus-summary-marks
455 (defcustom gnus-spam-mark ?H
456 "*Mark used for spam articles."
457 :group 'gnus-summary-marks
460 (defcustom gnus-souped-mark ?F
461 "*Mark used for souped articles."
462 :group 'gnus-summary-marks
465 (defcustom gnus-kill-file-mark ?X
466 "*Mark used for articles killed by kill files."
467 :group 'gnus-summary-marks
470 (defcustom gnus-low-score-mark ?Y
471 "*Mark used for articles with a low score."
472 :group 'gnus-summary-marks
475 (defcustom gnus-catchup-mark ?C
476 "*Mark used for articles that are caught up."
477 :group 'gnus-summary-marks
480 (defcustom gnus-replied-mark ?A
481 "*Mark used for articles that have been replied to."
482 :group 'gnus-summary-marks
485 (defcustom gnus-forwarded-mark ?F
486 "*Mark used for articles that have been forwarded."
487 :group 'gnus-summary-marks
490 (defcustom gnus-recent-mark ?N
491 "*Mark used for articles that are recent."
492 :group 'gnus-summary-marks
495 (defcustom gnus-cached-mark ?*
496 "*Mark used for articles that are in the cache."
497 :group 'gnus-summary-marks
500 (defcustom gnus-saved-mark ?S
501 "*Mark used for articles that have been saved."
502 :group 'gnus-summary-marks
505 (defcustom gnus-unseen-mark ?.
506 "*Mark used for articles that haven't been seen."
507 :group 'gnus-summary-marks
510 (defcustom gnus-no-mark ?\ ;;;Whitespace
511 "*Mark used for articles that have no other secondary mark."
512 :group 'gnus-summary-marks
515 (defcustom gnus-ancient-mark ?O
516 "*Mark used for ancient articles."
517 :group 'gnus-summary-marks
520 (defcustom gnus-sparse-mark ?Q
521 "*Mark used for sparsely reffed articles."
522 :group 'gnus-summary-marks
525 (defcustom gnus-canceled-mark ?G
526 "*Mark used for canceled articles."
527 :group 'gnus-summary-marks
530 (defcustom gnus-duplicate-mark ?M
531 "*Mark used for duplicate articles."
532 :group 'gnus-summary-marks
535 (defcustom gnus-undownloaded-mark ?-
536 "*Mark used for articles that weren't downloaded."
537 :group 'gnus-summary-marks
540 (defcustom gnus-downloaded-mark ?+
541 "*Mark used for articles that were downloaded."
542 :group 'gnus-summary-marks
545 (defcustom gnus-downloadable-mark ?%
546 "*Mark used for articles that are to be downloaded."
547 :group 'gnus-summary-marks
550 (defcustom gnus-unsendable-mark ?=
551 "*Mark used for articles that won't be sent."
552 :group 'gnus-summary-marks
555 (defcustom gnus-score-over-mark ?+
556 "*Score mark used for articles with high scores."
557 :group 'gnus-summary-marks
560 (defcustom gnus-score-below-mark ?-
561 "*Score mark used for articles with low scores."
562 :group 'gnus-summary-marks
565 (defcustom gnus-empty-thread-mark ?\ ;;;Whitespace
566 "*There is no thread under the article."
567 :group 'gnus-summary-marks
570 (defcustom gnus-not-empty-thread-mark ?=
571 "*There is a thread under the article."
572 :group 'gnus-summary-marks
575 (defcustom gnus-view-pseudo-asynchronously nil
576 "*If non-nil, Gnus will view pseudo-articles asynchronously."
577 :group 'gnus-extract-view
580 (defcustom gnus-auto-expirable-marks
581 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
582 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
583 gnus-souped-mark gnus-duplicate-mark)
584 "*The list of marks converted into expiration if a group is auto-expirable."
587 :type '(repeat character))
589 (defcustom gnus-inhibit-user-auto-expire t
590 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
595 (defcustom gnus-view-pseudos nil
596 "*If `automatic', pseudo-articles will be viewed automatically.
597 If `not-confirm', pseudos will be viewed automatically, and the user
598 will not be asked to confirm the command."
599 :group 'gnus-extract-view
600 :type '(choice (const :tag "off" nil)
602 (const not-confirm)))
604 (defcustom gnus-view-pseudos-separately t
605 "*If non-nil, one pseudo-article will be created for each file to be viewed.
606 If nil, all files that use the same viewing command will be given as a
607 list of parameters to that command."
608 :group 'gnus-extract-view
611 (defcustom gnus-insert-pseudo-articles t
612 "*If non-nil, insert pseudo-articles when decoding articles."
613 :group 'gnus-extract-view
616 (defcustom gnus-summary-dummy-line-format
618 "*The format specification for the dummy roots in the summary buffer.
619 It works along the same lines as a normal formatting string,
620 with some simple extensions.
624 General format specifiers can also be used.
625 See `(gnus)Formatting Variables'."
626 :link '(custom-manual "(gnus)Formatting Variables")
627 :group 'gnus-threading
630 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
631 "*The format specification for the summary mode line.
632 It works along the same lines as a normal formatting string,
633 with some simple extensions:
636 %p Unprefixed group name
637 %A Current article number
638 %z Current article score
640 %U Number of unread articles in the group
641 %e Number of unselected articles in the group
642 %Z A string with unread/unselected article counts
643 %g Shortish group name
644 %S Subject of the current article
646 %s Current score file name
647 %d Number of dormant articles
648 %r Number of articles that have been marked as read in this session
649 %E Number of articles expunged by the score files"
650 :group 'gnus-summary-format
653 (defcustom gnus-list-identifiers nil
654 "Regexp that matches list identifiers to be removed from subject.
655 This can also be a list of regexps."
657 :group 'gnus-summary-format
658 :group 'gnus-article-hiding
659 :type '(choice (const :tag "none" nil)
661 (repeat :value (".*") regexp)))
663 (defcustom gnus-summary-mark-below 0
664 "*Mark all articles with a score below this variable as read.
665 This variable is local to each summary buffer and usually set by the
667 :group 'gnus-score-default
670 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
671 "*List of functions used for sorting articles in the summary buffer.
673 Each function takes two articles and returns non-nil if the first
674 article should be sorted before the other. If you use more than one
675 function, the primary sort function should be the last. You should
676 probably always include `gnus-article-sort-by-number' in the list of
677 sorting functions -- preferably first. Also note that sorting by date
678 is often much slower than sorting by number, and the sorting order is
679 very similar. (Sorting by date means sorting by the time the message
680 was sent, sorting by number means sorting by arrival time.)
682 Ready-made functions include `gnus-article-sort-by-number',
683 `gnus-article-sort-by-author', `gnus-article-sort-by-subject',
684 `gnus-article-sort-by-date', `gnus-article-sort-by-random'
685 and `gnus-article-sort-by-score'.
687 When threading is turned on, the variable `gnus-thread-sort-functions'
688 controls how articles are sorted."
689 :group 'gnus-summary-sort
690 :type '(repeat (choice (function-item gnus-article-sort-by-number)
691 (function-item gnus-article-sort-by-author)
692 (function-item gnus-article-sort-by-subject)
693 (function-item gnus-article-sort-by-date)
694 (function-item gnus-article-sort-by-score)
695 (function-item gnus-article-sort-by-random)
696 (function :tag "other"))))
698 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
699 "*List of functions used for sorting threads in the summary buffer.
700 By default, threads are sorted by article number.
702 Each function takes two threads and returns non-nil if the first
703 thread should be sorted before the other. If you use more than one
704 function, the primary sort function should be the last. You should
705 probably always include `gnus-thread-sort-by-number' in the list of
706 sorting functions -- preferably first. Also note that sorting by date
707 is often much slower than sorting by number, and the sorting order is
708 very similar. (Sorting by date means sorting by the time the message
709 was sent, sorting by number means sorting by arrival time.)
711 Ready-made functions include `gnus-thread-sort-by-number',
712 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
713 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score',
714 `gnus-thread-sort-by-most-recent-number',
715 `gnus-thread-sort-by-most-recent-date',
716 `gnus-thread-sort-by-random', and
717 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function').
719 When threading is turned off, the variable
720 `gnus-article-sort-functions' controls how articles are sorted."
721 :group 'gnus-summary-sort
722 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
723 (function-item gnus-thread-sort-by-author)
724 (function-item gnus-thread-sort-by-subject)
725 (function-item gnus-thread-sort-by-date)
726 (function-item gnus-thread-sort-by-score)
727 (function-item gnus-thread-sort-by-total-score)
728 (function-item gnus-thread-sort-by-random)
729 (function :tag "other"))))
731 (defcustom gnus-thread-score-function '+
732 "*Function used for calculating the total score of a thread.
734 The function is called with the scores of the article and each
735 subthread and should then return the score of the thread.
737 Some functions you can use are `+', `max', or `min'."
738 :group 'gnus-summary-sort
741 (defcustom gnus-summary-expunge-below nil
742 "All articles that have a score less than this variable will be expunged.
743 This variable is local to the summary buffers."
744 :group 'gnus-score-default
745 :type '(choice (const :tag "off" nil)
748 (defcustom gnus-thread-expunge-below nil
749 "All threads that have a total score less than this variable will be expunged.
750 See `gnus-thread-score-function' for en explanation of what a
753 This variable is local to the summary buffers."
754 :group 'gnus-threading
755 :group 'gnus-score-default
756 :type '(choice (const :tag "off" nil)
759 (defcustom gnus-summary-mode-hook nil
760 "*A hook for Gnus summary mode.
761 This hook is run before any variables are set in the summary buffer."
762 :options '(turn-on-gnus-mailing-list-mode gnus-pick-mode)
763 :group 'gnus-summary-various
766 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
767 (when (featurep 'xemacs)
768 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-summary-menu-add)
769 (add-hook 'gnus-summary-mode-hook 'gnus-xmas-setup-summary-toolbar)
770 (add-hook 'gnus-summary-mode-hook
771 'gnus-xmas-switch-horizontal-scrollbar-off))
773 (defcustom gnus-summary-menu-hook nil
774 "*Hook run after the creation of the summary mode menu."
775 :group 'gnus-summary-visual
778 (defcustom gnus-summary-exit-hook nil
779 "*A hook called on exit from the summary buffer.
780 It will be called with point in the group buffer."
781 :group 'gnus-summary-exit
784 (defcustom gnus-summary-prepare-hook nil
785 "*A hook called after the summary buffer has been generated.
786 If you want to modify the summary buffer, you can use this hook."
787 :group 'gnus-summary-various
790 (defcustom gnus-summary-prepared-hook nil
791 "*A hook called as the last thing after the summary buffer has been generated."
792 :group 'gnus-summary-various
795 (defcustom gnus-summary-generate-hook nil
796 "*A hook run just before generating the summary buffer.
797 This hook is commonly used to customize threading variables and the
799 :group 'gnus-summary-various
802 (defcustom gnus-select-group-hook nil
803 "*A hook called when a newsgroup is selected.
805 If you'd like to simplify subjects like the
806 `gnus-summary-next-same-subject' command does, you can use the
809 (add-hook gnus-select-group-hook
811 (mapcar (lambda (header)
812 (mail-header-set-subject
814 (gnus-simplify-subject
815 (mail-header-subject header) 're-only)))
816 gnus-newsgroup-headers)))"
817 :group 'gnus-group-select
820 (defcustom gnus-select-article-hook nil
821 "*A hook called when an article is selected."
822 :group 'gnus-summary-choose
825 (defcustom gnus-visual-mark-article-hook
826 (list 'gnus-highlight-selected-summary)
827 "*Hook run after selecting an article in the summary buffer.
828 It is meant to be used for highlighting the article in some way. It
829 is not run if `gnus-visual' is nil."
830 :group 'gnus-summary-visual
833 (defcustom gnus-parse-headers-hook '(gnus-summary-inherit-default-charset)
834 "*A hook called before parsing the headers."
838 (defcustom gnus-exit-group-hook nil
839 "*A hook called when exiting summary mode.
840 This hook is not called from the non-updating exit commands like `Q'."
844 (defcustom gnus-summary-update-hook
845 (list 'gnus-summary-highlight-line)
846 "*A hook called when a summary line is changed.
847 The hook will not be called if `gnus-visual' is nil.
849 The default function `gnus-summary-highlight-line' will
850 highlight the line according to the `gnus-summary-highlight'
852 :group 'gnus-summary-visual
855 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
856 "*A hook called when an article is selected for the first time.
857 The hook is intended to mark an article as read (or unread)
858 automatically when it is selected."
859 :group 'gnus-summary-choose
862 (defcustom gnus-group-no-more-groups-hook nil
863 "*A hook run when returning to group mode having no more (unread) groups."
864 :group 'gnus-group-select
867 (defcustom gnus-ps-print-hook nil
868 "*A hook run before ps-printing something from Gnus."
872 (defcustom gnus-summary-display-arrow
873 (and (fboundp 'display-graphic-p)
875 "*If non-nil, display an arrow highlighting the current article."
880 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
881 "Face used for highlighting the current article in the summary buffer."
882 :group 'gnus-summary-visual
885 (defvar gnus-tmp-downloaded nil)
887 (defcustom gnus-summary-highlight
888 '(((eq mark gnus-canceled-mark)
889 . gnus-summary-cancelled-face)
890 ((and uncached (> score default-high))
891 . gnus-summary-high-uncached-face)
892 ((and uncached (< score default-low))
893 . gnus-summary-low-uncached-face)
895 . gnus-summary-normal-uncached-face)
896 ((and (> score default-high)
897 (or (eq mark gnus-dormant-mark)
898 (eq mark gnus-ticked-mark)))
899 . gnus-summary-high-ticked-face)
900 ((and (< score default-low)
901 (or (eq mark gnus-dormant-mark)
902 (eq mark gnus-ticked-mark)))
903 . gnus-summary-low-ticked-face)
904 ((or (eq mark gnus-dormant-mark)
905 (eq mark gnus-ticked-mark))
906 . gnus-summary-normal-ticked-face)
907 ((and (> score default-high) (eq mark gnus-ancient-mark))
908 . gnus-summary-high-ancient-face)
909 ((and (< score default-low) (eq mark gnus-ancient-mark))
910 . gnus-summary-low-ancient-face)
911 ((eq mark gnus-ancient-mark)
912 . gnus-summary-normal-ancient-face)
913 ((and (> score default-high) (eq mark gnus-unread-mark))
914 . gnus-summary-high-unread-face)
915 ((and (< score default-low) (eq mark gnus-unread-mark))
916 . gnus-summary-low-unread-face)
917 ((eq mark gnus-unread-mark)
918 . gnus-summary-normal-unread-face)
919 ((> score default-high)
920 . gnus-summary-high-read-face)
921 ((< score default-low)
922 . gnus-summary-low-read-face)
924 . gnus-summary-normal-read-face))
925 "*Controls the highlighting of summary buffer lines.
927 A list of (FORM . FACE) pairs. When deciding how a a particular
928 summary line should be displayed, each form is evaluated. The content
929 of the face field after the first true form is used. You can change
930 how those summary lines are displayed, by editing the face field.
932 You can use the following variables in the FORM field.
934 score: The article's score
935 default: The default article score.
936 default-high: The default score for high scored articles.
937 default-low: The default score for low scored articles.
938 below: The score below which articles are automatically marked as read.
939 mark: The articles mark."
940 :group 'gnus-summary-visual
941 :type '(repeat (cons (sexp :tag "Form" nil)
944 (defcustom gnus-alter-header-function nil
945 "Function called to allow alteration of article header structures.
946 The function is called with one parameter, the article header vector,
947 which it may alter in any way.")
949 (defvar gnus-decode-encoded-word-function
950 (mime-find-field-decoder 'From 'nov)
951 "Variable that says which function should be used to decode a string with encoded words.")
953 (defcustom gnus-extra-headers '(To Newsgroups)
954 "*Extra headers to parse."
957 :type '(repeat symbol))
959 (defcustom gnus-ignored-from-addresses
960 (and user-mail-address (regexp-quote user-mail-address))
961 "*Regexp of From headers that may be suppressed in favor of To headers."
966 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit x-unknown)
967 "List of charsets that should be ignored.
968 When these charsets are used in the \"charset\" parameter, the
969 default charset will be used instead."
971 :type '(repeat symbol)
972 :group 'gnus-charset)
974 (gnus-define-group-parameter
978 "Return the ignored charsets of GROUP."
979 :variable gnus-group-ignored-charsets-alist
981 '(("alt\\.chinese\\.text" iso-8859-1))
983 "Alist of regexps (to match group names) and charsets that should be ignored.
984 When these charsets are used in the \"charset\" parameter, the
985 default charset will be used instead."
986 :variable-group gnus-charset
987 :variable-type '(repeat (cons (regexp :tag "Group")
989 :parameter-type '(choice :tag "Ignored charsets"
992 :parameter-document "\
993 List of charsets that should be ignored.
995 When these charsets are used in the \"charset\" parameter, the
996 default charset will be used instead.")
998 (defcustom gnus-group-highlight-words-alist nil
999 "Alist of group regexps and highlight regexps.
1000 This variable uses the same syntax as `gnus-emphasis-alist'."
1002 :type '(repeat (cons (regexp :tag "Group")
1003 (repeat (list (regexp :tag "Highlight regexp")
1004 (number :tag "Group for entire word" 0)
1005 (number :tag "Group for displayed part" 0)
1007 gnus-emphasis-highlight-words)))))
1008 :group 'gnus-summary-visual)
1010 (defcustom gnus-use-wheel nil
1011 "Use Intelli-mouse on summary movement"
1013 :group 'gnus-summary-maneuvering)
1015 (defcustom gnus-wheel-scroll-amount '(5 . 1)
1016 "Amount to scroll messages by spinning the mouse wheel.
1017 This is actually a cons cell, where the first item is the amount to scroll
1018 on a normal wheel event, and the second is the amount to scroll when the
1019 wheel is moved with the shift key depressed."
1020 :type '(cons (integer :tag "Shift") integer)
1021 :group 'gnus-summary-maneuvering)
1023 (defcustom gnus-wheel-edge-resistance 2
1024 "How hard it should be to change the current article
1025 by moving the mouse over the edge of the article window."
1027 :group 'gnus-summary-maneuvering)
1029 (defcustom gnus-summary-show-article-charset-alist
1031 "Alist of number and charset.
1032 The article will be shown with the charset corresponding to the
1034 For example: ((1 . cn-gb-2312) (2 . big5))."
1036 :type '(repeat (cons (number :tag "Argument" 1)
1037 (symbol :tag "Charset")))
1038 :group 'gnus-charset)
1040 (defcustom gnus-preserve-marks t
1041 "Whether marks are preserved when moving, copying and respooling messages."
1044 :group 'gnus-summary-marks)
1046 (defcustom gnus-alter-articles-to-read-function nil
1047 "Function to be called to alter the list of articles to be selected."
1048 :type '(choice (const nil) function)
1049 :group 'gnus-summary)
1051 (defcustom gnus-orphan-score nil
1052 "*All orphans get this score added. Set in the score file."
1053 :group 'gnus-score-default
1054 :type '(choice (const nil)
1057 (defcustom gnus-summary-save-parts-default-mime "image/.*"
1058 "*A regexp to match MIME parts when saving multiple parts of a message
1059 with gnus-summary-save-parts (X m). This regexp will be used by default
1060 when prompting the user for which type of files to save."
1061 :group 'gnus-summary
1064 (defcustom gnus-read-all-available-headers nil
1065 "Whether Gnus should parse all headers made available to it.
1066 This is mostly relevant for slow backends where the user may
1067 wish to widen the summary buffer to include all headers
1068 that were fetched. Say, for nnultimate groups."
1069 :group 'gnus-summary
1070 :type '(choice boolean regexp))
1072 (defcustom gnus-summary-muttprint-program "muttprint"
1073 "Command (and optional arguments) used to run Muttprint."
1075 :group 'gnus-summary
1078 (defcustom gnus-article-loose-mime nil
1079 "If non-nil, don't require MIME-Version header.
1080 Some brain-damaged MUA/MTA, e.g. Lotus Domino 5.0.6 clients, does not
1081 supply the MIME-Version header or deliberately strip it From the mail.
1082 Set it to non-nil, Gnus will treat some articles as MIME even if
1083 the MIME-Version header is missed."
1086 :group 'gnus-article)
1088 ;;; Internal variables
1090 (defvar gnus-summary-display-cache nil)
1091 (defvar gnus-article-mime-handles nil)
1092 (defvar gnus-article-decoded-p nil)
1093 (defvar gnus-article-charset nil)
1094 (defvar gnus-article-ignored-charsets nil)
1095 (defvar gnus-scores-exclude-files nil)
1096 (defvar gnus-page-broken nil)
1098 (defvar gnus-original-article nil)
1099 (defvar gnus-article-internal-prepare-hook nil)
1100 (defvar gnus-newsgroup-process-stack nil)
1102 (defvar gnus-thread-indent-array nil)
1103 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
1104 (defvar gnus-sort-gathered-threads-function 'gnus-thread-sort-by-number
1105 "Function called to sort the articles within a thread after it has been gathered together.")
1107 (defvar gnus-summary-save-parts-type-history nil)
1108 (defvar gnus-summary-save-parts-last-directory nil)
1110 ;; Avoid highlighting in kill files.
1111 (defvar gnus-summary-inhibit-highlight nil)
1112 (defvar gnus-newsgroup-selected-overlay nil)
1113 (defvar gnus-inhibit-limiting nil)
1114 (defvar gnus-newsgroup-adaptive-score-file nil)
1115 (defvar gnus-current-score-file nil)
1116 (defvar gnus-current-move-group nil)
1117 (defvar gnus-current-copy-group nil)
1118 (defvar gnus-current-crosspost-group nil)
1119 (defvar gnus-newsgroup-display nil)
1121 (defvar gnus-newsgroup-dependencies nil)
1122 (defvar gnus-newsgroup-adaptive nil)
1123 (defvar gnus-summary-display-article-function nil)
1124 (defvar gnus-summary-highlight-line-function nil
1125 "Function called after highlighting a summary line.")
1127 (defvar gnus-summary-line-format-alist
1128 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
1129 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
1130 (?s gnus-tmp-subject-or-nil ?s)
1131 (?n gnus-tmp-name ?s)
1132 (?A (std11-address-string
1133 (car (mime-entity-read-field gnus-tmp-header 'From))) ?s)
1134 (?a (or (std11-full-name-string
1135 (car (mime-entity-read-field gnus-tmp-header 'From)))
1137 (?F gnus-tmp-from ?s)
1138 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
1139 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
1140 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
1141 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
1142 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
1143 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
1144 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
1145 (?k (gnus-summary-line-message-size gnus-tmp-header) ?s)
1146 (?L gnus-tmp-lines ?s)
1147 (?O gnus-tmp-downloaded ?c)
1148 (?I gnus-tmp-indentation ?s)
1149 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
1150 (?R gnus-tmp-replied ?c)
1151 (?\[ gnus-tmp-opening-bracket ?c)
1152 (?\] gnus-tmp-closing-bracket ?c)
1153 (?\> (make-string gnus-tmp-level ? ) ?s)
1154 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
1155 (?i gnus-tmp-score ?d)
1156 (?z gnus-tmp-score-char ?c)
1157 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
1158 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
1159 (?U gnus-tmp-unread ?c)
1160 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header gnus-tmp-from)
1162 (?t (gnus-summary-number-of-articles-in-thread
1163 (and (boundp 'thread) (car thread)) gnus-tmp-level)
1165 (?e (gnus-summary-number-of-articles-in-thread
1166 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
1168 (?u gnus-tmp-user-defined ?s)
1169 (?P (gnus-pick-line-number) ?d)
1170 (?B gnus-tmp-thread-tree-header-string ?s)
1171 (user-date (gnus-user-date
1172 ,(macroexpand '(mail-header-date gnus-tmp-header))) ?s))
1173 "An alist of format specifications that can appear in summary lines.
1174 These are paired with what variables they correspond with, along with
1175 the type of the variable (string, integer, character, etc).")
1177 (defvar gnus-summary-dummy-line-format-alist
1178 `((?S gnus-tmp-subject ?s)
1179 (?N gnus-tmp-number ?d)
1180 (?u gnus-tmp-user-defined ?s)))
1182 (defvar gnus-summary-mode-line-format-alist
1183 `((?G gnus-tmp-group-name ?s)
1184 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
1185 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
1186 (?A gnus-tmp-article-number ?d)
1187 (?Z gnus-tmp-unread-and-unselected ?s)
1188 (?V gnus-version ?s)
1189 (?U gnus-tmp-unread-and-unticked ?d)
1190 (?S gnus-tmp-subject ?s)
1191 (?e gnus-tmp-unselected ?d)
1192 (?u gnus-tmp-user-defined ?s)
1193 (?d (length gnus-newsgroup-dormant) ?d)
1194 (?t (length gnus-newsgroup-marked) ?d)
1195 (?h (length gnus-newsgroup-spam-marked) ?d)
1196 (?r (length gnus-newsgroup-reads) ?d)
1197 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
1198 (?E gnus-newsgroup-expunged-tally ?d)
1199 (?s (gnus-current-score-file-nondirectory) ?s)))
1201 (defvar gnus-last-search-regexp nil
1202 "Default regexp for article search command.")
1204 (defvar gnus-summary-search-article-matched-data nil
1205 "Last matched data of article search command. It is the local variable
1206 in `gnus-article-buffer' which consists of the list of start position,
1207 end position and text.")
1209 (defvar gnus-last-shell-command nil
1210 "Default shell command on article.")
1212 (defvar gnus-newsgroup-agentized nil
1213 "Locally bound in each summary buffer to indicate whether the server has been agentized.")
1214 (defvar gnus-newsgroup-begin nil)
1215 (defvar gnus-newsgroup-end nil)
1216 (defvar gnus-newsgroup-last-rmail nil)
1217 (defvar gnus-newsgroup-last-mail nil)
1218 (defvar gnus-newsgroup-last-folder nil)
1219 (defvar gnus-newsgroup-last-file nil)
1220 (defvar gnus-newsgroup-auto-expire nil)
1221 (defvar gnus-newsgroup-active nil)
1223 (defvar gnus-newsgroup-data nil)
1224 (defvar gnus-newsgroup-data-reverse nil)
1225 (defvar gnus-newsgroup-limit nil)
1226 (defvar gnus-newsgroup-limits nil)
1228 (defvar gnus-newsgroup-unreads nil
1229 "Sorted list of unread articles in the current newsgroup.")
1231 (defvar gnus-newsgroup-unselected nil
1232 "Sorted list of unselected unread articles in the current newsgroup.")
1234 (defvar gnus-newsgroup-reads nil
1235 "Alist of read articles and article marks in the current newsgroup.")
1237 (defvar gnus-newsgroup-expunged-tally nil)
1239 (defvar gnus-newsgroup-marked nil
1240 "Sorted list of ticked articles in the current newsgroup (a subset of unread art).")
1242 (defvar gnus-newsgroup-spam-marked nil
1243 "List of ranges of articles that have been marked as spam.")
1245 (defvar gnus-newsgroup-killed nil
1246 "List of ranges of articles that have been through the scoring process.")
1248 (defvar gnus-newsgroup-cached nil
1249 "Sorted list of articles that come from the article cache.")
1251 (defvar gnus-newsgroup-saved nil
1252 "List of articles that have been saved.")
1254 (defvar gnus-newsgroup-kill-headers nil)
1256 (defvar gnus-newsgroup-replied nil
1257 "List of articles that have been replied to in the current newsgroup.")
1259 (defvar gnus-newsgroup-forwarded nil
1260 "List of articles that have been forwarded in the current newsgroup.")
1262 (defvar gnus-newsgroup-recent nil
1263 "List of articles that have are recent in the current newsgroup.")
1265 (defvar gnus-newsgroup-expirable nil
1266 "Sorted list of articles in the current newsgroup that can be expired.")
1268 (defvar gnus-newsgroup-processable nil
1269 "List of articles in the current newsgroup that can be processed.")
1271 (defvar gnus-newsgroup-downloadable nil
1272 "Sorted list of articles in the current newsgroup that can be processed.")
1274 (defvar gnus-newsgroup-undownloaded nil
1275 "List of articles in the current newsgroup that haven't been downloaded..")
1277 (defvar gnus-newsgroup-unsendable nil
1278 "List of articles in the current newsgroup that won't be sent.")
1280 (defvar gnus-newsgroup-bookmarks nil
1281 "List of articles in the current newsgroup that have bookmarks.")
1283 (defvar gnus-newsgroup-dormant nil
1284 "Sorted list of dormant articles in the current newsgroup.")
1286 (defvar gnus-newsgroup-unseen nil
1287 "List of unseen articles in the current newsgroup.")
1289 (defvar gnus-newsgroup-seen nil
1290 "Range of seen articles in the current newsgroup.")
1292 (defvar gnus-newsgroup-articles nil
1293 "List of articles in the current newsgroup.")
1295 (defvar gnus-newsgroup-scored nil
1296 "List of scored articles in the current newsgroup.")
1298 (defvar gnus-newsgroup-incorporated nil
1299 "List of incorporated articles in the current newsgroup.")
1301 (defvar gnus-newsgroup-headers nil
1302 "List of article headers in the current newsgroup.")
1304 (defvar gnus-newsgroup-threads nil)
1306 (defvar gnus-newsgroup-prepared nil
1307 "Whether the current group has been prepared properly.")
1309 (defvar gnus-newsgroup-ancient nil
1310 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1312 (defvar gnus-newsgroup-sparse nil)
1314 (defvar gnus-current-article nil)
1315 (defvar gnus-article-current nil)
1316 (defvar gnus-current-headers nil)
1317 (defvar gnus-have-all-headers nil)
1318 (defvar gnus-last-article nil)
1319 (defvar gnus-newsgroup-history nil)
1320 (defvar gnus-newsgroup-charset nil)
1321 (defvar gnus-newsgroup-ephemeral-charset nil)
1322 (defvar gnus-newsgroup-ephemeral-ignored-charsets nil)
1324 (defvar gnus-article-before-search nil)
1326 (defconst gnus-summary-local-variables
1327 '(gnus-newsgroup-name
1328 gnus-newsgroup-begin gnus-newsgroup-end
1329 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1330 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1331 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1332 gnus-newsgroup-unselected gnus-newsgroup-marked
1333 gnus-newsgroup-spam-marked
1334 gnus-newsgroup-reads gnus-newsgroup-saved
1335 gnus-newsgroup-replied gnus-newsgroup-forwarded
1336 gnus-newsgroup-recent
1337 gnus-newsgroup-expirable
1338 gnus-newsgroup-processable gnus-newsgroup-killed
1339 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1340 gnus-newsgroup-unsendable gnus-newsgroup-unseen
1341 gnus-newsgroup-seen gnus-newsgroup-articles
1342 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1343 gnus-newsgroup-headers gnus-newsgroup-threads
1344 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1345 gnus-current-article gnus-current-headers gnus-have-all-headers
1346 gnus-last-article gnus-article-internal-prepare-hook
1347 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1348 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1349 gnus-thread-expunge-below
1350 gnus-score-alist gnus-current-score-file
1351 (gnus-summary-expunge-below . global)
1352 (gnus-summary-mark-below . global)
1353 (gnus-orphan-score . global)
1354 gnus-newsgroup-active gnus-scores-exclude-files
1355 gnus-newsgroup-history gnus-newsgroup-ancient
1356 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1357 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1358 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1359 (gnus-newsgroup-expunged-tally . 0)
1360 gnus-cache-removable-articles gnus-newsgroup-cached
1361 gnus-newsgroup-data gnus-newsgroup-data-reverse
1362 gnus-newsgroup-limit gnus-newsgroup-limits
1363 gnus-newsgroup-charset gnus-newsgroup-display
1364 gnus-newsgroup-incorporated)
1365 "Variables that are buffer-local to the summary buffers.")
1367 (defvar gnus-newsgroup-variables nil
1368 "A list of variables that have separate values in different newsgroups.
1369 A list of newsgroup (summary buffer) local variables, or cons of
1370 variables and their default values (when the default values are not
1371 nil), that should be made global while the summary buffer is active.
1372 These variables can be used to set variables in the group parameters
1373 while still allowing them to affect operations done in other
1374 buffers. For example:
1376 \(setq gnus-newsgroup-variables
1377 '(message-use-followup-to
1378 (gnus-visible-headers .
1379 \"^From:\\\\|^Newsgroups:\\\\|^Subject:\\\\|^Date:\\\\|^To:\")))
1382 ;; Byte-compiler warning.
1383 (eval-when-compile (defvar gnus-article-mode-map))
1385 ;; Subject simplification.
1387 (defun gnus-simplify-whitespace (str)
1388 "Remove excessive whitespace from STR."
1391 (while (string-match "[ \t][ \t]+" mystr)
1392 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1394 (substring mystr (match-end 0)))))
1396 (when (string-match "^[ \t]+" mystr)
1397 (setq mystr (substring mystr (match-end 0))))
1399 (when (string-match "[ \t]+$" mystr)
1400 (setq mystr (substring mystr 0 (match-beginning 0))))
1403 (defun gnus-simplify-all-whitespace (str)
1404 "Remove all whitespace from STR."
1406 (while (string-match "[ \t\n]+" mystr)
1407 (setq mystr (replace-match "" nil nil mystr)))
1410 (defsubst gnus-simplify-subject-re (subject)
1411 "Remove \"Re:\" from subject lines."
1412 (if (string-match message-subject-re-regexp subject)
1413 (substring subject (match-end 0))
1416 (defun gnus-simplify-subject (subject &optional re-only)
1417 "Remove `Re:' and words in parentheses.
1418 If RE-ONLY is non-nil, strip leading `Re:'s only."
1419 (let ((case-fold-search t)) ;Ignore case.
1420 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1421 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1422 (setq subject (substring subject (match-end 0))))
1423 ;; Remove uninteresting prefixes.
1424 (when (and (not re-only)
1425 gnus-simplify-ignored-prefixes
1426 (string-match gnus-simplify-ignored-prefixes subject))
1427 (setq subject (substring subject (match-end 0))))
1428 ;; Remove words in parentheses from end.
1430 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1431 (setq subject (substring subject 0 (match-beginning 0)))))
1432 ;; Return subject string.
1435 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1437 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1438 (goto-char (point-min))
1439 (while (re-search-forward regexp nil t)
1440 (replace-match (or newtext ""))))
1442 (defun gnus-simplify-buffer-fuzzy ()
1443 "Simplify string in the buffer fuzzily.
1444 The string in the accessible portion of the current buffer is simplified.
1445 It is assumed to be a single-line subject.
1446 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1447 matter is removed. Additional things can be deleted by setting
1448 `gnus-simplify-subject-fuzzy-regexp'."
1449 (let ((case-fold-search t)
1451 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1453 (while (not (eq modified-tick (buffer-modified-tick)))
1454 (setq modified-tick (buffer-modified-tick))
1456 ((listp gnus-simplify-subject-fuzzy-regexp)
1457 (mapcar 'gnus-simplify-buffer-fuzzy-step
1458 gnus-simplify-subject-fuzzy-regexp))
1459 (gnus-simplify-subject-fuzzy-regexp
1460 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1461 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1462 (gnus-simplify-buffer-fuzzy-step
1463 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1464 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1466 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1467 (gnus-simplify-buffer-fuzzy-step " +" " ")
1468 (gnus-simplify-buffer-fuzzy-step " $")
1469 (gnus-simplify-buffer-fuzzy-step "^ +")))
1471 (defun gnus-simplify-subject-fuzzy (subject)
1472 "Simplify a subject string fuzzily.
1473 See `gnus-simplify-buffer-fuzzy' for details."
1475 (gnus-set-work-buffer)
1476 (let ((case-fold-search t))
1477 ;; Remove uninteresting prefixes.
1478 (when (and gnus-simplify-ignored-prefixes
1479 (string-match gnus-simplify-ignored-prefixes subject))
1480 (setq subject (substring subject (match-end 0))))
1482 (inline (gnus-simplify-buffer-fuzzy))
1485 (defsubst gnus-simplify-subject-fully (subject)
1486 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1488 (gnus-simplify-subject-functions
1489 (gnus-map-function gnus-simplify-subject-functions subject))
1490 ((null gnus-summary-gather-subject-limit)
1491 (gnus-simplify-subject-re subject))
1492 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1493 (gnus-simplify-subject-fuzzy subject))
1494 ((numberp gnus-summary-gather-subject-limit)
1495 (gnus-limit-string (gnus-simplify-subject-re subject)
1496 gnus-summary-gather-subject-limit))
1500 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1501 "Check whether two subjects are equal.
1502 If optional argument simple-first is t, first argument is already
1505 ((null simple-first)
1506 (equal (gnus-simplify-subject-fully s1)
1507 (gnus-simplify-subject-fully s2)))
1510 (gnus-simplify-subject-fully s2)))))
1512 (defun gnus-summary-bubble-group ()
1513 "Increase the score of the current group.
1514 This is a handy function to add to `gnus-summary-exit-hook' to
1515 increase the score of each group you read."
1516 (gnus-group-add-score gnus-newsgroup-name))
1520 ;;; Gnus summary mode
1523 (put 'gnus-summary-mode 'mode-class 'special)
1525 (defvar gnus-article-commands-menu)
1528 ;; Non-orthogonal keys
1530 (gnus-define-keys gnus-summary-mode-map
1531 " " gnus-summary-next-page
1532 "\177" gnus-summary-prev-page
1533 [delete] gnus-summary-prev-page
1534 [backspace] gnus-summary-prev-page
1535 "\r" gnus-summary-scroll-up
1536 "\M-\r" gnus-summary-scroll-down
1537 "n" gnus-summary-next-unread-article
1538 "p" gnus-summary-prev-unread-article
1539 "N" gnus-summary-next-article
1540 "P" gnus-summary-prev-article
1541 "\M-\C-n" gnus-summary-next-same-subject
1542 "\M-\C-p" gnus-summary-prev-same-subject
1543 "\M-n" gnus-summary-next-unread-subject
1544 "\M-p" gnus-summary-prev-unread-subject
1545 "." gnus-summary-first-unread-article
1546 "," gnus-summary-best-unread-article
1547 "\M-s" gnus-summary-search-article-forward
1548 "\M-r" gnus-summary-search-article-backward
1549 "<" gnus-summary-beginning-of-article
1550 ">" gnus-summary-end-of-article
1551 "j" gnus-summary-goto-article
1552 "^" gnus-summary-refer-parent-article
1553 "\M-^" gnus-summary-refer-article
1554 "u" gnus-summary-tick-article-forward
1555 "!" gnus-summary-tick-article-forward
1556 "U" gnus-summary-tick-article-backward
1557 "d" gnus-summary-mark-as-read-forward
1558 "D" gnus-summary-mark-as-read-backward
1559 "E" gnus-summary-mark-as-expirable
1560 "\M-u" gnus-summary-clear-mark-forward
1561 "\M-U" gnus-summary-clear-mark-backward
1562 "k" gnus-summary-kill-same-subject-and-select
1563 "\C-k" gnus-summary-kill-same-subject
1564 "\M-\C-k" gnus-summary-kill-thread
1565 "\M-\C-l" gnus-summary-lower-thread
1566 "e" gnus-summary-edit-article
1567 "#" gnus-summary-mark-as-processable
1568 "\M-#" gnus-summary-unmark-as-processable
1569 "\M-\C-t" gnus-summary-toggle-threads
1570 "\M-\C-s" gnus-summary-show-thread
1571 "\M-\C-h" gnus-summary-hide-thread
1572 "\M-\C-f" gnus-summary-next-thread
1573 "\M-\C-b" gnus-summary-prev-thread
1574 [(meta down)] gnus-summary-next-thread
1575 [(meta up)] gnus-summary-prev-thread
1576 "\M-\C-u" gnus-summary-up-thread
1577 "\M-\C-d" gnus-summary-down-thread
1578 "&" gnus-summary-execute-command
1579 "c" gnus-summary-catchup-and-exit
1580 "\C-w" gnus-summary-mark-region-as-read
1581 "\C-t" gnus-summary-toggle-truncation
1582 "?" gnus-summary-mark-as-dormant
1583 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1584 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1585 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1586 "\C-c\C-s\C-c" gnus-summary-sort-by-chars
1587 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1588 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1589 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1590 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1591 "\C-c\C-s\C-o" gnus-summary-sort-by-original
1592 "\C-c\C-s\C-r" gnus-summary-sort-by-random
1593 "=" gnus-summary-expand-window
1594 "\C-x\C-s" gnus-summary-reselect-current-group
1595 "\M-g" gnus-summary-rescan-group
1596 "w" gnus-summary-stop-page-breaking
1597 "\C-c\C-r" gnus-summary-caesar-message
1598 "\M-t" gnus-summary-toggle-mime
1599 "f" gnus-summary-followup
1600 "F" gnus-summary-followup-with-original
1601 "C" gnus-summary-cancel-article
1602 "r" gnus-summary-reply
1603 "R" gnus-summary-reply-with-original
1604 "\C-c\C-f" gnus-summary-mail-forward
1605 "o" gnus-summary-save-article
1606 "\C-o" gnus-summary-save-article-mail
1607 "|" gnus-summary-pipe-output
1608 "\M-k" gnus-summary-edit-local-kill
1609 "\M-K" gnus-summary-edit-global-kill
1611 "\C-c\C-d" gnus-summary-describe-group
1612 "q" gnus-summary-exit
1613 "Q" gnus-summary-exit-no-update
1614 "\C-c\C-i" gnus-info-find-node
1615 gnus-mouse-2 gnus-mouse-pick-article
1616 "m" gnus-summary-mail-other-window
1617 "a" gnus-summary-post-news
1618 "i" gnus-summary-news-other-window
1619 "x" gnus-summary-limit-to-unread
1620 "s" gnus-summary-isearch-article
1621 "t" gnus-summary-toggle-header
1622 "g" gnus-summary-show-article
1623 "l" gnus-summary-goto-last-article
1624 "v" gnus-summary-preview-mime-message
1625 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1626 "\C-d" gnus-summary-enter-digest-group
1627 "\M-\C-d" gnus-summary-read-document
1628 "\M-\C-e" gnus-summary-edit-parameters
1629 "\M-\C-a" gnus-summary-customize-parameters
1631 "\C-c\C-n" gnus-namazu-search
1632 "*" gnus-cache-enter-article
1633 "\M-*" gnus-cache-remove-article
1634 "\M-&" gnus-summary-universal-argument
1635 "\C-l" gnus-recenter
1636 "I" gnus-summary-increase-score
1637 "L" gnus-summary-lower-score
1638 "\M-i" gnus-symbolic-argument
1639 "h" gnus-summary-select-article-buffer
1641 "V" gnus-summary-score-map
1642 "X" gnus-uu-extract-map
1643 "S" gnus-summary-send-map)
1645 ;; Sort of orthogonal keymap
1646 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1647 "t" gnus-summary-tick-article-forward
1648 "!" gnus-summary-tick-article-forward
1649 "d" gnus-summary-mark-as-read-forward
1650 "r" gnus-summary-mark-as-read-forward
1651 "c" gnus-summary-clear-mark-forward
1652 " " gnus-summary-clear-mark-forward
1653 "e" gnus-summary-mark-as-expirable
1654 "x" gnus-summary-mark-as-expirable
1655 "?" gnus-summary-mark-as-dormant
1656 "b" gnus-summary-set-bookmark
1657 "B" gnus-summary-remove-bookmark
1658 "#" gnus-summary-mark-as-processable
1659 "\M-#" gnus-summary-unmark-as-processable
1660 "S" gnus-summary-limit-include-expunged
1661 "C" gnus-summary-catchup
1662 "H" gnus-summary-catchup-to-here
1663 "h" gnus-summary-catchup-from-here
1664 "\C-c" gnus-summary-catchup-all
1665 "k" gnus-summary-kill-same-subject-and-select
1666 "K" gnus-summary-kill-same-subject
1667 "P" gnus-uu-mark-map)
1669 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1670 "c" gnus-summary-clear-above
1671 "u" gnus-summary-tick-above
1672 "m" gnus-summary-mark-above
1673 "k" gnus-summary-kill-below)
1675 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1676 "/" gnus-summary-limit-to-subject
1677 "n" gnus-summary-limit-to-articles
1678 "w" gnus-summary-pop-limit
1679 "s" gnus-summary-limit-to-subject
1680 "a" gnus-summary-limit-to-author
1681 "u" gnus-summary-limit-to-unread
1682 "m" gnus-summary-limit-to-marks
1683 "M" gnus-summary-limit-exclude-marks
1684 "v" gnus-summary-limit-to-score
1685 "*" gnus-summary-limit-include-cached
1686 "D" gnus-summary-limit-include-dormant
1687 "T" gnus-summary-limit-include-thread
1688 "d" gnus-summary-limit-exclude-dormant
1689 "t" gnus-summary-limit-to-age
1690 "." gnus-summary-limit-to-unseen
1691 "x" gnus-summary-limit-to-extra
1692 "p" gnus-summary-limit-to-display-predicate
1693 "E" gnus-summary-limit-include-expunged
1694 "c" gnus-summary-limit-exclude-childless-dormant
1695 "C" gnus-summary-limit-mark-excluded-as-read
1696 "o" gnus-summary-insert-old-articles
1697 "N" gnus-summary-insert-new-articles)
1699 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1700 "n" gnus-summary-next-unread-article
1701 "p" gnus-summary-prev-unread-article
1702 "N" gnus-summary-next-article
1703 "P" gnus-summary-prev-article
1704 "\C-n" gnus-summary-next-same-subject
1705 "\C-p" gnus-summary-prev-same-subject
1706 "\M-n" gnus-summary-next-unread-subject
1707 "\M-p" gnus-summary-prev-unread-subject
1708 "f" gnus-summary-first-unread-article
1709 "b" gnus-summary-best-unread-article
1710 "j" gnus-summary-goto-article
1711 "g" gnus-summary-goto-subject
1712 "l" gnus-summary-goto-last-article
1713 "o" gnus-summary-pop-article)
1715 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1716 "k" gnus-summary-kill-thread
1717 "l" gnus-summary-lower-thread
1718 "i" gnus-summary-raise-thread
1719 "T" gnus-summary-toggle-threads
1720 "t" gnus-summary-rethread-current
1721 "^" gnus-summary-reparent-thread
1722 "s" gnus-summary-show-thread
1723 "S" gnus-summary-show-all-threads
1724 "h" gnus-summary-hide-thread
1725 "H" gnus-summary-hide-all-threads
1726 "n" gnus-summary-next-thread
1727 "p" gnus-summary-prev-thread
1728 "u" gnus-summary-up-thread
1729 "o" gnus-summary-top-thread
1730 "d" gnus-summary-down-thread
1731 "#" gnus-uu-mark-thread
1732 "\M-#" gnus-uu-unmark-thread)
1734 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1735 "g" gnus-summary-prepare
1736 "c" gnus-summary-insert-cached-articles)
1738 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1739 "c" gnus-summary-catchup-and-exit
1740 "C" gnus-summary-catchup-all-and-exit
1741 "E" gnus-summary-exit-no-update
1742 "J" gnus-summary-jump-to-other-group
1743 "Q" gnus-summary-exit
1744 "Z" gnus-summary-exit
1745 "n" gnus-summary-catchup-and-goto-next-group
1746 "R" gnus-summary-reselect-current-group
1747 "G" gnus-summary-rescan-group
1748 "N" gnus-summary-next-group
1749 "s" gnus-summary-save-newsrc
1750 "P" gnus-summary-prev-group)
1752 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1753 " " gnus-summary-next-page
1754 "n" gnus-summary-next-page
1755 "\177" gnus-summary-prev-page
1756 [delete] gnus-summary-prev-page
1757 "p" gnus-summary-prev-page
1758 "\r" gnus-summary-scroll-up
1759 "\M-\r" gnus-summary-scroll-down
1760 "<" gnus-summary-beginning-of-article
1761 ">" gnus-summary-end-of-article
1762 "b" gnus-summary-beginning-of-article
1763 "e" gnus-summary-end-of-article
1764 "^" gnus-summary-refer-parent-article
1765 "r" gnus-summary-refer-parent-article
1766 "D" gnus-summary-enter-digest-group
1767 "R" gnus-summary-refer-references
1768 "T" gnus-summary-refer-thread
1769 "g" gnus-summary-show-article
1770 "s" gnus-summary-isearch-article
1771 "P" gnus-summary-print-article
1772 "M" gnus-mailing-list-insinuate
1773 "t" gnus-article-babel)
1775 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1776 "b" gnus-article-add-buttons
1777 "B" gnus-article-add-buttons-to-head
1778 "o" gnus-article-treat-overstrike
1779 "e" gnus-article-emphasize
1780 "w" gnus-article-fill-cited-article
1781 "Q" gnus-article-fill-long-lines
1782 "C" gnus-article-capitalize-sentences
1783 "c" gnus-article-remove-cr
1784 "Z" gnus-article-decode-HZ
1785 "h" gnus-article-wash-html
1786 "u" gnus-article-unsplit-urls
1787 "f" gnus-article-display-x-face
1788 "l" gnus-summary-stop-page-breaking
1789 "r" gnus-summary-caesar-message
1790 "m" gnus-summary-morse-message
1791 "t" gnus-summary-toggle-header
1792 "g" gnus-treat-smiley
1793 "v" gnus-summary-verbose-headers
1794 "m" gnus-summary-toggle-mime
1795 "a" gnus-article-strip-headers-in-body ;; mnemonic: wash archive
1796 "p" gnus-article-verify-x-pgp-sig
1797 "d" gnus-article-treat-dumbquotes
1798 "k" gnus-article-outlook-deuglify-article)
1800 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1801 "a" gnus-article-hide
1802 "h" gnus-article-hide-headers
1803 "b" gnus-article-hide-boring-headers
1804 "s" gnus-article-hide-signature
1805 "c" gnus-article-hide-citation
1806 "C" gnus-article-hide-citation-in-followups
1807 "l" gnus-article-hide-list-identifiers
1808 "p" gnus-article-hide-pgp
1809 "B" gnus-article-strip-banner
1810 "P" gnus-article-hide-pem
1811 "\C-c" gnus-article-hide-citation-maybe)
1813 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1814 "a" gnus-article-highlight
1815 "h" gnus-article-highlight-headers
1816 "c" gnus-article-highlight-citation
1817 "s" gnus-article-highlight-signature)
1819 (gnus-define-keys (gnus-summary-wash-header-map "G" gnus-summary-wash-map)
1820 "f" gnus-article-treat-fold-headers
1821 "u" gnus-article-treat-unfold-headers
1822 "n" gnus-article-treat-fold-newsgroups)
1824 (gnus-define-keys (gnus-summary-wash-display-map "D" gnus-summary-wash-map)
1825 "x" gnus-article-display-x-face
1826 "s" gnus-treat-smiley
1827 "D" gnus-article-remove-images
1828 "f" gnus-treat-from-picon
1829 "m" gnus-treat-mail-picon
1830 "n" gnus-treat-newsgroups-picon)
1832 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1833 "z" gnus-article-date-ut
1834 "u" gnus-article-date-ut
1835 "l" gnus-article-date-local
1836 "p" gnus-article-date-english
1837 "e" gnus-article-date-lapsed
1838 "o" gnus-article-date-original
1839 "i" gnus-article-date-iso8601
1840 "s" gnus-article-date-user)
1842 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1843 "t" gnus-article-remove-trailing-blank-lines
1844 "l" gnus-article-strip-leading-blank-lines
1845 "m" gnus-article-strip-multiple-blank-lines
1846 "a" gnus-article-strip-blank-lines
1847 "A" gnus-article-strip-all-blank-lines
1848 "s" gnus-article-strip-leading-space
1849 "e" gnus-article-strip-trailing-space
1850 "w" gnus-article-remove-leading-whitespace)
1852 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1854 "f" gnus-summary-fetch-faq
1855 "d" gnus-summary-describe-group
1856 "h" gnus-summary-describe-briefly
1857 "i" gnus-info-find-node
1858 "c" gnus-group-fetch-charter
1859 "C" gnus-group-fetch-control)
1861 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1862 "e" gnus-summary-expire-articles
1863 "\M-\C-e" gnus-summary-expire-articles-now
1864 "\177" gnus-summary-delete-article
1865 [delete] gnus-summary-delete-article
1866 [backspace] gnus-summary-delete-article
1867 "m" gnus-summary-move-article
1868 "r" gnus-summary-respool-article
1869 "w" gnus-summary-edit-article
1870 "c" gnus-summary-copy-article
1871 "B" gnus-summary-crosspost-article
1872 "q" gnus-summary-respool-query
1873 "t" gnus-summary-respool-trace
1874 "i" gnus-summary-import-article
1875 "I" gnus-summary-create-article
1876 "p" gnus-summary-article-posted-p)
1878 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1879 "o" gnus-summary-save-article
1880 "m" gnus-summary-save-article-mail
1881 "F" gnus-summary-write-article-file
1882 "r" gnus-summary-save-article-rmail
1883 "f" gnus-summary-save-article-file
1884 "b" gnus-summary-save-article-body-file
1885 "h" gnus-summary-save-article-folder
1886 "v" gnus-summary-save-article-vm
1887 "p" gnus-summary-pipe-output
1888 "P" gnus-summary-muttprint
1889 "s" gnus-soup-add-article)
1891 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1892 "b" gnus-summary-display-buttonized
1893 "m" gnus-summary-repair-multipart
1894 "v" gnus-article-view-part
1895 "o" gnus-article-save-part
1896 "c" gnus-article-copy-part
1897 "C" gnus-article-view-part-as-charset
1898 "e" gnus-article-view-part-externally
1899 "E" gnus-article-encrypt-body
1900 "i" gnus-article-inline-part
1901 "|" gnus-article-pipe-part)
1903 (gnus-define-keys (gnus-uu-mark-map "P" gnus-summary-mark-map)
1904 "p" gnus-summary-mark-as-processable
1905 "u" gnus-summary-unmark-as-processable
1906 "U" gnus-summary-unmark-all-processable
1907 "v" gnus-uu-mark-over
1908 "s" gnus-uu-mark-series
1909 "r" gnus-uu-mark-region
1910 "g" gnus-uu-unmark-region
1911 "R" gnus-uu-mark-by-regexp
1912 "G" gnus-uu-unmark-by-regexp
1913 "t" gnus-uu-mark-thread
1914 "T" gnus-uu-unmark-thread
1915 "a" gnus-uu-mark-all
1916 "b" gnus-uu-mark-buffer
1917 "S" gnus-uu-mark-sparse
1918 "k" gnus-summary-kill-process-mark
1919 "y" gnus-summary-yank-process-mark
1920 "w" gnus-summary-save-process-mark
1921 "i" gnus-uu-invert-processable)
1923 (gnus-define-keys (gnus-uu-extract-map "X" gnus-summary-mode-map)
1924 ;;"x" gnus-uu-extract-any
1925 "m" gnus-summary-save-parts
1926 "u" gnus-uu-decode-uu
1927 "U" gnus-uu-decode-uu-and-save
1928 "s" gnus-uu-decode-unshar
1929 "S" gnus-uu-decode-unshar-and-save
1930 "o" gnus-uu-decode-save
1931 "O" gnus-uu-decode-save
1932 "b" gnus-uu-decode-binhex
1933 "B" gnus-uu-decode-binhex
1934 "p" gnus-uu-decode-postscript
1935 "P" gnus-uu-decode-postscript-and-save)
1938 (gnus-uu-extract-view-map "v" gnus-uu-extract-map)
1939 "u" gnus-uu-decode-uu-view
1940 "U" gnus-uu-decode-uu-and-save-view
1941 "s" gnus-uu-decode-unshar-view
1942 "S" gnus-uu-decode-unshar-and-save-view
1943 "o" gnus-uu-decode-save-view
1944 "O" gnus-uu-decode-save-view
1945 "b" gnus-uu-decode-binhex-view
1946 "B" gnus-uu-decode-binhex-view
1947 "p" gnus-uu-decode-postscript-view
1948 "P" gnus-uu-decode-postscript-and-save-view))
1950 (defvar gnus-article-post-menu nil)
1952 (defconst gnus-summary-menu-maxlen 20)
1954 (defun gnus-summary-menu-split (menu)
1955 ;; If we have lots of elements, divide them into groups of 20
1956 ;; and make a pane (or submenu) for each one.
1957 (if (> (length menu) (/ (* gnus-summary-menu-maxlen 3) 2))
1958 (let ((menu menu) sublists next
1961 ;; Pull off the next gnus-summary-menu-maxlen elements
1962 ;; and make them the next element of sublist.
1963 (setq next (nthcdr gnus-summary-menu-maxlen menu))
1965 (setcdr (nthcdr (1- gnus-summary-menu-maxlen) menu)
1967 (setq sublists (cons (cons (format "%s ... %s" (aref (car menu) 0)
1968 (aref (car (last menu)) 0)) menu)
1972 (nreverse sublists))
1973 ;; Few elements--put them all in one pane.
1976 (defun gnus-summary-make-menu-bar ()
1977 (gnus-turn-off-edit-menu 'summary)
1979 (unless (boundp 'gnus-summary-misc-menu)
1982 gnus-summary-kill-menu gnus-summary-mode-map ""
1987 ["Customize" gnus-score-customize t])
1988 (gnus-make-score-map 'increase)
1989 (gnus-make-score-map 'lower)
1991 ["Kill below" gnus-summary-kill-below t]
1992 ["Mark above" gnus-summary-mark-above t]
1993 ["Tick above" gnus-summary-tick-above t]
1994 ["Clear above" gnus-summary-clear-above t])
1995 ["Current score" gnus-summary-current-score t]
1996 ["Set score" gnus-summary-set-score t]
1997 ["Switch current score file..." gnus-score-change-score-file t]
1998 ["Set mark below..." gnus-score-set-mark-below t]
1999 ["Set expunge below..." gnus-score-set-expunge-below t]
2000 ["Edit current score file" gnus-score-edit-current-scores t]
2001 ["Edit score file" gnus-score-edit-file t]
2002 ["Trace score" gnus-score-find-trace t]
2003 ["Find words" gnus-score-find-favourite-words t]
2004 ["Rescore buffer" gnus-summary-rescore t]
2005 ["Increase score..." gnus-summary-increase-score t]
2006 ["Lower score..." gnus-summary-lower-score t]))))
2008 ;; Define both the Article menu in the summary buffer and the
2009 ;; equivalent Commands menu in the article buffer here for
2013 ["All" gnus-article-hide t]
2014 ["Headers" gnus-article-hide-headers t]
2015 ["Signature" gnus-article-hide-signature t]
2016 ["Citation" gnus-article-hide-citation t]
2017 ["List identifiers" gnus-article-hide-list-identifiers t]
2018 ["PGP" gnus-article-hide-pgp t]
2019 ["Banner" gnus-article-strip-banner t]
2020 ["Boring headers" gnus-article-hide-boring-headers t])
2022 ["All" gnus-article-highlight t]
2023 ["Headers" gnus-article-highlight-headers t]
2024 ["Signature" gnus-article-highlight-signature t]
2025 ["Citation" gnus-article-highlight-citation t])
2027 ["Local" gnus-article-date-local t]
2028 ["ISO8601" gnus-article-date-iso8601 t]
2029 ["UT" gnus-article-date-ut t]
2030 ["Original" gnus-article-date-original t]
2031 ["Lapsed" gnus-article-date-lapsed t]
2032 ["User-defined" gnus-article-date-user t])
2034 ["Remove images" gnus-article-remove-images t]
2035 ["Toggle smiley" gnus-treat-smiley t]
2036 ["Show X-Face" gnus-article-display-x-face t]
2037 ["Show picons in From" gnus-treat-from-picon t]
2038 ["Show picons in mail headers" gnus-treat-mail-picon t]
2039 ["Show picons in news headers" gnus-treat-newsgroups-picon t]
2040 ("View as different encoding"
2041 ,@(gnus-summary-menu-split
2044 ;; Since easymenu under FSF Emacs doesn't allow lambda
2045 ;; forms for menu commands, we should provide intern'ed
2046 ;; function symbols.
2047 (let ((command (intern (format "\
2048 gnus-summary-show-article-from-menu-as-charset-%s" cs))))
2052 (let ((gnus-summary-show-article-charset-alist
2054 (gnus-summary-show-article 1))))
2055 `[,(symbol-name cs) ,command t]))
2056 (sort (if (fboundp 'coding-system-list)
2057 (coding-system-list)
2058 ;;(mapcar 'car mm-mime-mule-charset-alist)
2063 ["Leading" gnus-article-strip-leading-blank-lines t]
2064 ["Multiple" gnus-article-strip-multiple-blank-lines t]
2065 ["Trailing" gnus-article-remove-trailing-blank-lines t]
2066 ["All of the above" gnus-article-strip-blank-lines t]
2067 ["All" gnus-article-strip-all-blank-lines t]
2068 ["Leading space" gnus-article-strip-leading-space t]
2069 ["Trailing space" gnus-article-strip-trailing-space t]
2070 ["Leading space in headers"
2071 gnus-article-remove-leading-whitespace t])
2072 ["Overstrike" gnus-article-treat-overstrike t]
2073 ["Dumb quotes" gnus-article-treat-dumbquotes t]
2074 ["Emphasis" gnus-article-emphasize t]
2075 ["Word wrap" gnus-article-fill-cited-article t]
2076 ["Fill long lines" gnus-article-fill-long-lines t]
2077 ["Capitalize sentences" gnus-article-capitalize-sentences t]
2078 ["CR" gnus-article-remove-cr t]
2079 ["Rot 13" gnus-summary-caesar-message
2080 ,@(if (featurep 'xemacs) '(t)
2081 '(:help "\"Caesar rotate\" article by 13"))]
2082 ["Morse decode" gnus-summary-morse-message t]
2083 ["Unix pipe..." gnus-summary-pipe-message t]
2084 ["Add buttons" gnus-article-add-buttons t]
2085 ["Add buttons to head" gnus-article-add-buttons-to-head t]
2086 ["Stop page breaking" gnus-summary-stop-page-breaking t]
2087 ["Toggle MIME" gnus-summary-toggle-mime t]
2088 ["Verbose header" gnus-summary-verbose-headers t]
2089 ["Toggle header" gnus-summary-toggle-header t]
2090 ["Unfold headers" gnus-article-treat-unfold-headers t]
2091 ["Fold newsgroups" gnus-article-treat-fold-newsgroups t]
2092 ["Html" gnus-article-wash-html t]
2093 ["URLs" gnus-article-unsplit-urls t]
2094 ["Verify X-PGP-Sig" gnus-article-verify-x-pgp-sig t]
2095 ["HZ" gnus-article-decode-HZ t]
2096 ["OutlooK deuglify" gnus-article-outlook-deuglify-article t]
2099 ["Save in default format" gnus-summary-save-article
2100 ,@(if (featurep 'xemacs) '(t)
2101 '(:help "Save article using default method"))]
2102 ["Save in file" gnus-summary-save-article-file
2103 ,@(if (featurep 'xemacs) '(t)
2104 '(:help "Save article in file"))]
2105 ["Save in Unix mail format" gnus-summary-save-article-mail t]
2106 ["Save in MH folder" gnus-summary-save-article-folder t]
2107 ["Save in VM folder" gnus-summary-save-article-vm t]
2108 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
2109 ["Save body in file" gnus-summary-save-article-body-file t]
2110 ["Pipe through a filter" gnus-summary-pipe-output t]
2111 ["Add to SOUP packet" gnus-soup-add-article t]
2112 ["Print with Muttprint" gnus-summary-muttprint t]
2113 ["Print" gnus-summary-print-article t])
2115 ["Respool article..." gnus-summary-respool-article t]
2116 ["Move article..." gnus-summary-move-article
2117 (gnus-check-backend-function
2118 'request-move-article gnus-newsgroup-name)]
2119 ["Copy article..." gnus-summary-copy-article t]
2120 ["Crosspost article..." gnus-summary-crosspost-article
2121 (gnus-check-backend-function
2122 'request-replace-article gnus-newsgroup-name)]
2123 ["Import file..." gnus-summary-import-article t]
2124 ["Create article..." gnus-summary-create-article t]
2125 ["Check if posted" gnus-summary-article-posted-p t]
2126 ["Edit article" gnus-summary-edit-article
2127 (not (gnus-group-read-only-p))]
2128 ["Delete article" gnus-summary-delete-article
2129 (gnus-check-backend-function
2130 'request-expire-articles gnus-newsgroup-name)]
2131 ["Query respool" gnus-summary-respool-query t]
2132 ["Trace respool" gnus-summary-respool-trace t]
2133 ["Delete expirable articles" gnus-summary-expire-articles-now
2134 (gnus-check-backend-function
2135 'request-expire-articles gnus-newsgroup-name)])
2137 ["Uudecode" gnus-uu-decode-uu
2138 ,@(if (featurep 'xemacs) '(t)
2139 '(:help "Decode uuencoded article(s)"))]
2140 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
2141 ["Unshar" gnus-uu-decode-unshar t]
2142 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
2143 ["Save" gnus-uu-decode-save t]
2144 ["Binhex" gnus-uu-decode-binhex t]
2145 ["Postscript" gnus-uu-decode-postscript t])
2147 ["Enter article" gnus-cache-enter-article t]
2148 ["Remove article" gnus-cache-remove-article t])
2149 ["Translate" gnus-article-babel t]
2150 ["Select article buffer" gnus-summary-select-article-buffer t]
2151 ["Enter digest buffer" gnus-summary-enter-digest-group t]
2152 ["Isearch article..." gnus-summary-isearch-article t]
2153 ["Beginning of the article" gnus-summary-beginning-of-article t]
2154 ["End of the article" gnus-summary-end-of-article t]
2155 ["Fetch parent of article" gnus-summary-refer-parent-article t]
2156 ["Fetch referenced articles" gnus-summary-refer-references t]
2157 ["Fetch current thread" gnus-summary-refer-thread t]
2158 ["Fetch article with id..." gnus-summary-refer-article t]
2159 ["Setup Mailing List Params" gnus-mailing-list-insinuate t]
2160 ["Redisplay" gnus-summary-show-article t]
2161 ["Raw article" gnus-summary-show-raw-article :keys "C-u g"])))
2163 gnus-summary-article-menu gnus-summary-mode-map ""
2164 (cons "Article" innards))
2166 (if (not (keymapp gnus-summary-article-menu))
2168 gnus-article-commands-menu gnus-article-mode-map ""
2169 (cons "Commands" innards))
2170 ;; in Emacs, don't share menu.
2171 (setq gnus-article-commands-menu
2172 (copy-keymap gnus-summary-article-menu))
2173 (define-key gnus-article-mode-map [menu-bar commands]
2174 (cons "Commands" gnus-article-commands-menu))))
2177 gnus-summary-thread-menu gnus-summary-mode-map ""
2179 ["Toggle threading" gnus-summary-toggle-threads t]
2180 ["Hide threads" gnus-summary-hide-all-threads t]
2181 ["Show threads" gnus-summary-show-all-threads t]
2182 ["Hide thread" gnus-summary-hide-thread t]
2183 ["Show thread" gnus-summary-show-thread t]
2184 ["Go to next thread" gnus-summary-next-thread t]
2185 ["Go to previous thread" gnus-summary-prev-thread t]
2186 ["Go down thread" gnus-summary-down-thread t]
2187 ["Go up thread" gnus-summary-up-thread t]
2188 ["Top of thread" gnus-summary-top-thread t]
2189 ["Mark thread as read" gnus-summary-kill-thread t]
2190 ["Lower thread score" gnus-summary-lower-thread t]
2191 ["Raise thread score" gnus-summary-raise-thread t]
2192 ["Rethread current" gnus-summary-rethread-current t]))
2195 gnus-summary-post-menu gnus-summary-mode-map ""
2197 ["Send a message (mail or news)" gnus-summary-post-news
2198 ,@(if (featurep 'xemacs) '(t)
2199 '(:help "Post an article"))]
2200 ["Followup" gnus-summary-followup
2201 ,@(if (featurep 'xemacs) '(t)
2202 '(:help "Post followup to this article"))]
2203 ["Followup and yank" gnus-summary-followup-with-original
2204 ,@(if (featurep 'xemacs) '(t)
2205 '(:help "Post followup to this article, quoting its contents"))]
2206 ["Supersede article" gnus-summary-supersede-article t]
2207 ["Cancel article" gnus-summary-cancel-article
2208 ,@(if (featurep 'xemacs) '(t)
2209 '(:help "Cancel an article you posted"))]
2210 ["Reply" gnus-summary-reply t]
2211 ["Reply and yank" gnus-summary-reply-with-original t]
2212 ["Wide reply" gnus-summary-wide-reply t]
2213 ["Wide reply and yank" gnus-summary-wide-reply-with-original
2214 ,@(if (featurep 'xemacs) '(t)
2215 '(:help "Mail a reply, quoting this article"))]
2216 ["Very wide reply" gnus-summary-very-wide-reply t]
2217 ["Very wide reply and yank" gnus-summary-very-wide-reply-with-original
2218 ,@(if (featurep 'xemacs) '(t)
2219 '(:help "Mail a very wide reply, quoting this article"))]
2220 ["Mail forward" gnus-summary-mail-forward t]
2221 ["Post forward" gnus-summary-post-forward t]
2222 ["Digest and mail" gnus-summary-digest-mail-forward t]
2223 ["Digest and post" gnus-summary-digest-post-forward t]
2224 ["Resend message" gnus-summary-resend-message t]
2225 ["Resend message edit" gnus-summary-resend-message-edit t]
2226 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
2227 ["Send a mail" gnus-summary-mail-other-window t]
2228 ["Create a local message" gnus-summary-news-other-window t]
2229 ["Uuencode and post" gnus-uu-post-news
2230 ,@(if (featurep 'xemacs) '(t)
2231 '(:help "Post a uuencoded article"))]
2232 ["Followup via news" gnus-summary-followup-to-mail t]
2233 ["Followup via news and yank"
2234 gnus-summary-followup-to-mail-with-original t]
2236 ;;["Send" gnus-summary-send-draft t]
2237 ;;["Send bounced" gnus-resend-bounced-mail t])
2241 ((not (keymapp gnus-summary-post-menu))
2242 (setq gnus-article-post-menu gnus-summary-post-menu))
2243 ((not gnus-article-post-menu)
2244 ;; Don't share post menu.
2245 (setq gnus-article-post-menu
2246 (copy-keymap gnus-summary-post-menu))))
2247 (define-key gnus-article-mode-map [menu-bar post]
2248 (cons "Post" gnus-article-post-menu))
2251 gnus-summary-misc-menu gnus-summary-mode-map ""
2254 ["Mark as read" gnus-summary-mark-as-read-forward t]
2255 ["Mark same subject and select"
2256 gnus-summary-kill-same-subject-and-select t]
2257 ["Mark same subject" gnus-summary-kill-same-subject t]
2258 ["Catchup" gnus-summary-catchup
2259 ,@(if (featurep 'xemacs) '(t)
2260 '(:help "Mark unread articles in this group as read"))]
2261 ["Catchup all" gnus-summary-catchup-all t]
2262 ["Catchup to here" gnus-summary-catchup-to-here t]
2263 ["Catchup from here" gnus-summary-catchup-from-here t]
2264 ["Catchup region" gnus-summary-mark-region-as-read t]
2265 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
2267 ["Tick" gnus-summary-tick-article-forward t]
2268 ["Mark as dormant" gnus-summary-mark-as-dormant t]
2269 ["Remove marks" gnus-summary-clear-mark-forward t]
2270 ["Set expirable mark" gnus-summary-mark-as-expirable t]
2271 ["Set bookmark" gnus-summary-set-bookmark t]
2272 ["Remove bookmark" gnus-summary-remove-bookmark t])
2274 ["Marks..." gnus-summary-limit-to-marks t]
2275 ["Subject..." gnus-summary-limit-to-subject t]
2276 ["Author..." gnus-summary-limit-to-author t]
2277 ["Age..." gnus-summary-limit-to-age t]
2278 ["Extra..." gnus-summary-limit-to-extra t]
2279 ["Score..." gnus-summary-limit-to-score t]
2280 ["Display Predicate" gnus-summary-limit-to-display-predicate t]
2281 ["Unread" gnus-summary-limit-to-unread t]
2282 ["Unseen" gnus-summary-limit-to-unseen t]
2283 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
2284 ["Articles" gnus-summary-limit-to-articles t]
2285 ["Pop limit" gnus-summary-pop-limit t]
2286 ["Show dormant" gnus-summary-limit-include-dormant t]
2287 ["Hide childless dormant"
2288 gnus-summary-limit-exclude-childless-dormant t]
2289 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
2290 ["Hide marked" gnus-summary-limit-exclude-marks t]
2291 ["Show expunged" gnus-summary-limit-include-expunged t])
2293 ["Set mark" gnus-summary-mark-as-processable t]
2294 ["Remove mark" gnus-summary-unmark-as-processable t]
2295 ["Remove all marks" gnus-summary-unmark-all-processable t]
2296 ["Mark above" gnus-uu-mark-over t]
2297 ["Mark series" gnus-uu-mark-series t]
2298 ["Mark region" gnus-uu-mark-region t]
2299 ["Unmark region" gnus-uu-unmark-region t]
2300 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
2301 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
2302 ["Mark all" gnus-uu-mark-all t]
2303 ["Mark buffer" gnus-uu-mark-buffer t]
2304 ["Mark sparse" gnus-uu-mark-sparse t]
2305 ["Mark thread" gnus-uu-mark-thread t]
2306 ["Unmark thread" gnus-uu-unmark-thread t]
2307 ("Process Mark Sets"
2308 ["Kill" gnus-summary-kill-process-mark t]
2309 ["Yank" gnus-summary-yank-process-mark
2310 gnus-newsgroup-process-stack]
2311 ["Save" gnus-summary-save-process-mark t]))
2313 ["Page forward" gnus-summary-next-page
2314 ,@(if (featurep 'xemacs) '(t)
2315 '(:help "Show next page of article"))]
2316 ["Page backward" gnus-summary-prev-page
2317 ,@(if (featurep 'xemacs) '(t)
2318 '(:help "Show previous page of article"))]
2319 ["Line forward" gnus-summary-scroll-up t])
2321 ["Next unread article" gnus-summary-next-unread-article t]
2322 ["Previous unread article" gnus-summary-prev-unread-article t]
2323 ["Next article" gnus-summary-next-article t]
2324 ["Previous article" gnus-summary-prev-article t]
2325 ["Next unread subject" gnus-summary-next-unread-subject t]
2326 ["Previous unread subject" gnus-summary-prev-unread-subject t]
2327 ["Next article same subject" gnus-summary-next-same-subject t]
2328 ["Previous article same subject" gnus-summary-prev-same-subject t]
2329 ["First unread article" gnus-summary-first-unread-article t]
2330 ["Best unread article" gnus-summary-best-unread-article t]
2331 ["Go to subject number..." gnus-summary-goto-subject t]
2332 ["Go to article number..." gnus-summary-goto-article t]
2333 ["Go to the last article" gnus-summary-goto-last-article t]
2334 ["Pop article off history" gnus-summary-pop-article t])
2336 ["Sort by number" gnus-summary-sort-by-number t]
2337 ["Sort by author" gnus-summary-sort-by-author t]
2338 ["Sort by subject" gnus-summary-sort-by-subject t]
2339 ["Sort by date" gnus-summary-sort-by-date t]
2340 ["Sort by score" gnus-summary-sort-by-score t]
2341 ["Sort by lines" gnus-summary-sort-by-lines t]
2342 ["Sort by characters" gnus-summary-sort-by-chars t]
2343 ["Randomize" gnus-summary-sort-by-random t]
2344 ["Original sort" gnus-summary-sort-by-original t])
2346 ["Fetch group FAQ" gnus-summary-fetch-faq t]
2347 ["Describe group" gnus-summary-describe-group t]
2348 ["Fetch charter" gnus-group-fetch-charter
2349 ,@(if (featurep 'xemacs) nil
2350 '(:help "Display the charter of the current group"))]
2351 ["Fetch control message" gnus-group-fetch-control
2352 ,@(if (featurep 'xemacs) nil
2353 '(:help "Display the archived control message for the current group"))]
2354 ["Read manual" gnus-info-find-node t])
2356 ["Pick and read" gnus-pick-mode t]
2357 ["Binary" gnus-binary-mode t])
2359 ["Regenerate" gnus-summary-prepare t]
2360 ["Insert cached articles" gnus-summary-insert-cached-articles t]
2361 ["Toggle threading" gnus-summary-toggle-threads t])
2362 ["See old articles" gnus-summary-insert-old-articles t]
2363 ["See new articles" gnus-summary-insert-new-articles t]
2364 ["Filter articles..." gnus-summary-execute-command t]
2365 ["Run command on subjects..." gnus-summary-universal-argument t]
2366 ["Search articles forward..." gnus-summary-search-article-forward t]
2367 ["Search articles backward..." gnus-summary-search-article-backward t]
2368 ["Toggle line truncation" gnus-summary-toggle-truncation t]
2369 ["Expand window" gnus-summary-expand-window t]
2370 ["Expire expirable articles" gnus-summary-expire-articles
2371 (gnus-check-backend-function
2372 'request-expire-articles gnus-newsgroup-name)]
2373 ["Edit local kill file" gnus-summary-edit-local-kill t]
2374 ["Edit main kill file" gnus-summary-edit-global-kill t]
2375 ["Edit group parameters" gnus-summary-edit-parameters t]
2376 ["Customize group parameters" gnus-summary-customize-parameters t]
2377 ["Send a bug report" gnus-bug t]
2379 ["Catchup and exit" gnus-summary-catchup-and-exit
2380 ,@(if (featurep 'xemacs) '(t)
2381 '(:help "Mark unread articles in this group as read, then exit"))]
2382 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
2383 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
2384 ["Exit group" gnus-summary-exit
2385 ,@(if (featurep 'xemacs) '(t)
2386 '(:help "Exit current group, return to group selection mode"))]
2387 ["Exit group without updating" gnus-summary-exit-no-update t]
2388 ["Exit and goto next group" gnus-summary-next-group t]
2389 ["Exit and goto prev group" gnus-summary-prev-group t]
2390 ["Reselect group" gnus-summary-reselect-current-group t]
2391 ["Rescan group" gnus-summary-rescan-group t]
2392 ["Update dribble" gnus-summary-save-newsrc t])))
2394 (gnus-run-hooks 'gnus-summary-menu-hook)))
2396 (defvar gnus-summary-tool-bar-map nil)
2398 ;; Emacs 21 tool bar. Should be no-op otherwise.
2399 (defun gnus-summary-make-tool-bar ()
2400 (if (and (fboundp 'tool-bar-add-item-from-menu)
2401 (default-value 'tool-bar-mode)
2402 (not gnus-summary-tool-bar-map))
2403 (setq gnus-summary-tool-bar-map
2404 (let ((tool-bar-map (make-sparse-keymap))
2405 (load-path (mm-image-load-path)))
2406 (tool-bar-add-item-from-menu
2407 'gnus-summary-prev-unread "prev-ur" gnus-summary-mode-map)
2408 (tool-bar-add-item-from-menu
2409 'gnus-summary-next-unread "next-ur" gnus-summary-mode-map)
2410 (tool-bar-add-item-from-menu
2411 'gnus-summary-post-news "post" gnus-summary-mode-map)
2412 (tool-bar-add-item-from-menu
2413 'gnus-summary-followup-with-original "fuwo" gnus-summary-mode-map)
2414 (tool-bar-add-item-from-menu
2415 'gnus-summary-followup "followup" gnus-summary-mode-map)
2416 (tool-bar-add-item-from-menu
2417 'gnus-summary-reply-with-original "reply-wo" gnus-summary-mode-map)
2418 (tool-bar-add-item-from-menu
2419 'gnus-summary-reply "reply" gnus-summary-mode-map)
2420 (tool-bar-add-item-from-menu
2421 'gnus-summary-caesar-message "rot13" gnus-summary-mode-map)
2422 (tool-bar-add-item-from-menu
2423 'gnus-uu-decode-uu "uu-decode" gnus-summary-mode-map)
2424 (tool-bar-add-item-from-menu
2425 'gnus-summary-save-article-file "save-aif" gnus-summary-mode-map)
2426 (tool-bar-add-item-from-menu
2427 'gnus-summary-save-article "save-art" gnus-summary-mode-map)
2428 (tool-bar-add-item-from-menu
2429 'gnus-uu-post-news "uu-post" gnus-summary-mode-map)
2430 (tool-bar-add-item-from-menu
2431 'gnus-summary-catchup "catchup" gnus-summary-mode-map)
2432 (tool-bar-add-item-from-menu
2433 'gnus-summary-catchup-and-exit "cu-exit" gnus-summary-mode-map)
2434 (tool-bar-add-item-from-menu
2435 'gnus-summary-exit "exit-summ" gnus-summary-mode-map)
2437 (if gnus-summary-tool-bar-map
2438 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
2440 (defun gnus-score-set-default (var value)
2441 "A version of set that updates the GNU Emacs menu-bar."
2443 ;; It is the message that forces the active status to be updated.
2446 (defun gnus-make-score-map (type)
2447 "Make a summary score map of type TYPE."
2450 (let ((headers '(("author" "from" string)
2451 ("subject" "subject" string)
2452 ("article body" "body" string)
2453 ("article head" "head" string)
2454 ("xref" "xref" string)
2455 ("extra header" "extra" string)
2456 ("lines" "lines" number)
2457 ("followups to author" "followup" string)))
2458 (types '((number ("less than" <)
2461 (string ("substring" s)
2465 (perms '(("temporary" (current-time-string))
2473 (if (eq type 'lower)
2478 (setq header (car headers))
2484 (let ((ts (cdr (assoc (nth 2 header) types)))
2500 'gnus-summary-score-entry
2502 (if (or (string= (nth 1 header)
2504 (string= (nth 1 header)
2507 (list 'gnus-summary-header
2509 (list 'quote (nth 1 (car ts)))
2510 (list 'gnus-score-delta-default
2517 (list (nreverse outp))))
2520 (list (nreverse outt))))
2522 (setq headers (cdr headers)))
2523 (list (nreverse outh))))))))
2527 (defun gnus-summary-mode (&optional group)
2528 "Major mode for reading articles.
2530 All normal editing commands are switched off.
2531 \\<gnus-summary-mode-map>
2532 Each line in this buffer represents one article. To read an
2533 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
2534 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
2537 You can also post articles and send mail from this buffer. To
2538 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
2539 of an article, type `\\[gnus-summary-reply]'.
2541 There are approx. one gazillion commands you can execute in this
2542 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
2544 The following commands are available:
2546 \\{gnus-summary-mode-map}"
2548 (kill-all-local-variables)
2549 (when (gnus-visual-p 'summary-menu 'menu)
2550 (gnus-summary-make-menu-bar)
2551 (gnus-summary-make-tool-bar))
2552 (gnus-summary-make-local-variables)
2553 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
2554 (gnus-summary-make-local-variables))
2555 (gnus-make-thread-indent-array)
2556 (gnus-simplify-mode-line)
2557 (setq major-mode 'gnus-summary-mode)
2558 (setq mode-name "Summary")
2559 (make-local-variable 'minor-mode-alist)
2560 (use-local-map gnus-summary-mode-map)
2561 (buffer-disable-undo)
2562 (setq buffer-read-only t) ;Disable modification
2563 (setq truncate-lines t)
2564 (setq selective-display t)
2565 (setq selective-display-ellipses t) ;Display `...'
2566 (gnus-summary-set-display-table)
2567 (gnus-set-default-directory)
2568 (setq gnus-newsgroup-name group)
2569 (unless (gnus-news-group-p group)
2570 (setq gnus-newsgroup-incorporated
2571 (nnmail-new-mail-numbers (gnus-group-real-name group))))
2572 (make-local-variable 'gnus-summary-line-format)
2573 (make-local-variable 'gnus-summary-line-format-spec)
2574 (make-local-variable 'gnus-summary-dummy-line-format)
2575 (make-local-variable 'gnus-summary-dummy-line-format-spec)
2576 (make-local-variable 'gnus-summary-mark-positions)
2577 (make-local-hook 'pre-command-hook)
2578 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
2579 (gnus-run-hooks 'gnus-summary-mode-hook)
2580 (turn-on-gnus-mailing-list-mode)
2581 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
2582 (gnus-update-summary-mark-positions))
2584 (defun gnus-summary-make-local-variables ()
2585 "Make all the local summary buffer variables."
2587 (dolist (local gnus-summary-local-variables)
2590 (if (eq (cdr local) 'global)
2591 ;; Copy the global value of the variable.
2592 (setq global (symbol-value (car local)))
2593 ;; Use the value from the list.
2594 (setq global (eval (cdr local))))
2595 (set (make-local-variable (car local)) global))
2596 ;; Simple nil-valued local variable.
2597 (set (make-local-variable local) nil)))))
2599 (defun gnus-summary-clear-local-variables ()
2600 (let ((locals gnus-summary-local-variables))
2602 (if (consp (car locals))
2603 (and (vectorp (caar locals))
2604 (set (caar locals) nil))
2605 (and (vectorp (car locals))
2606 (set (car locals) nil)))
2607 (setq locals (cdr locals)))))
2609 ;; Summary data functions.
2611 (defmacro gnus-data-number (data)
2614 (defmacro gnus-data-set-number (data number)
2615 `(setcar ,data ,number))
2617 (defmacro gnus-data-mark (data)
2620 (defmacro gnus-data-set-mark (data mark)
2621 `(setcar (nthcdr 1 ,data) ,mark))
2623 (defmacro gnus-data-pos (data)
2626 (defmacro gnus-data-set-pos (data pos)
2627 `(setcar (nthcdr 2 ,data) ,pos))
2629 (defmacro gnus-data-header (data)
2632 (defmacro gnus-data-set-header (data header)
2633 `(setcar (nthcdr 3 ,data) ,header))
2635 (defmacro gnus-data-level (data)
2638 (defmacro gnus-data-unread-p (data)
2639 `(= (nth 1 ,data) gnus-unread-mark))
2641 (defmacro gnus-data-read-p (data)
2642 `(/= (nth 1 ,data) gnus-unread-mark))
2644 (defmacro gnus-data-pseudo-p (data)
2645 `(consp (nth 3 ,data)))
2647 (defmacro gnus-data-find (number)
2648 `(assq ,number gnus-newsgroup-data))
2650 (defmacro gnus-data-find-list (number &optional data)
2651 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2652 (memq (assq ,number bdata)
2655 (defmacro gnus-data-make (number mark pos header level)
2656 `(list ,number ,mark ,pos ,header ,level))
2658 (defun gnus-data-enter (after-article number mark pos header level offset)
2659 (let ((data (gnus-data-find-list after-article)))
2661 (error "No such article: %d" after-article))
2662 (setcdr data (cons (gnus-data-make number mark pos header level)
2664 (setq gnus-newsgroup-data-reverse nil)
2665 (gnus-data-update-list (cddr data) offset)))
2667 (defun gnus-data-enter-list (after-article list &optional offset)
2669 (let ((data (and after-article (gnus-data-find-list after-article)))
2673 (let ((odata gnus-newsgroup-data))
2674 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2676 (gnus-data-update-list odata offset)))
2677 ;; Find the last element in the list to be spliced into the main
2680 (setq list (cdr list)))
2683 (setcdr list gnus-newsgroup-data)
2684 (setq gnus-newsgroup-data ilist)
2686 (gnus-data-update-list (cdr list) offset)))
2687 (setcdr list (cdr data))
2690 (gnus-data-update-list (cdr list) offset))))
2691 (setq gnus-newsgroup-data-reverse nil))))
2693 (defun gnus-data-remove (article &optional offset)
2694 (let ((data gnus-newsgroup-data))
2695 (if (= (gnus-data-number (car data)) article)
2697 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2698 gnus-newsgroup-data-reverse nil)
2700 (gnus-data-update-list gnus-newsgroup-data offset)))
2702 (when (= (gnus-data-number (cadr data)) article)
2703 (setcdr data (cddr data))
2705 (gnus-data-update-list (cdr data) offset))
2707 gnus-newsgroup-data-reverse nil))
2708 (setq data (cdr data))))))
2710 (defmacro gnus-data-list (backward)
2712 (or gnus-newsgroup-data-reverse
2713 (setq gnus-newsgroup-data-reverse
2714 (reverse gnus-newsgroup-data)))
2715 gnus-newsgroup-data))
2717 (defun gnus-data-update-list (data offset)
2718 "Add OFFSET to the POS of all data entries in DATA."
2719 (setq gnus-newsgroup-data-reverse nil)
2721 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2722 (setq data (cdr data))))
2724 (defun gnus-summary-article-pseudo-p (article)
2725 "Say whether this article is a pseudo article or not."
2726 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2728 (defmacro gnus-summary-article-sparse-p (article)
2729 "Say whether this article is a sparse article or not."
2730 `(memq ,article gnus-newsgroup-sparse))
2732 (defmacro gnus-summary-article-ancient-p (article)
2733 "Say whether this article is a sparse article or not."
2734 `(memq ,article gnus-newsgroup-ancient))
2736 (defun gnus-article-parent-p (number)
2737 "Say whether this article is a parent or not."
2738 (let ((data (gnus-data-find-list number)))
2739 (and (cdr data) ; There has to be an article after...
2740 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2741 (gnus-data-level (nth 1 data))))))
2743 (defun gnus-article-children (number)
2744 "Return a list of all children to NUMBER."
2745 (let* ((data (gnus-data-find-list number))
2746 (level (gnus-data-level (car data)))
2748 (setq data (cdr data))
2750 (= (gnus-data-level (car data)) (1+ level)))
2751 (push (gnus-data-number (car data)) children)
2752 (setq data (cdr data)))
2755 (defmacro gnus-summary-skip-intangible ()
2756 "If the current article is intangible, then jump to a different article."
2757 '(let ((to (get-text-property (point) 'gnus-intangible)))
2758 (and to (gnus-summary-goto-subject to))))
2760 (defmacro gnus-summary-article-intangible-p ()
2761 "Say whether this article is intangible or not."
2762 '(get-text-property (point) 'gnus-intangible))
2764 (defun gnus-article-read-p (article)
2765 "Say whether ARTICLE is read or not."
2766 (not (or (memq article gnus-newsgroup-marked)
2767 (memq article gnus-newsgroup-spam-marked)
2768 (memq article gnus-newsgroup-unreads)
2769 (memq article gnus-newsgroup-unselected)
2770 (memq article gnus-newsgroup-dormant))))
2772 ;; Some summary mode macros.
2774 (defmacro gnus-summary-article-number ()
2775 "The article number of the article on the current line.
2776 If there isn't an article number here, then we return the current
2779 (gnus-summary-skip-intangible)
2780 (or (get-text-property (point) 'gnus-number)
2781 (gnus-summary-last-subject))))
2783 (defmacro gnus-summary-article-header (&optional number)
2784 "Return the header of article NUMBER."
2785 `(gnus-data-header (gnus-data-find
2786 ,(or number '(gnus-summary-article-number)))))
2788 (defmacro gnus-summary-thread-level (&optional number)
2789 "Return the level of thread that starts with article NUMBER."
2790 `(if (and (eq gnus-summary-make-false-root 'dummy)
2791 (get-text-property (point) 'gnus-intangible))
2793 (gnus-data-level (gnus-data-find
2794 ,(or number '(gnus-summary-article-number))))))
2796 (defmacro gnus-summary-article-mark (&optional number)
2797 "Return the mark of article NUMBER."
2798 `(gnus-data-mark (gnus-data-find
2799 ,(or number '(gnus-summary-article-number)))))
2801 (defmacro gnus-summary-article-pos (&optional number)
2802 "Return the position of the line of article NUMBER."
2803 `(gnus-data-pos (gnus-data-find
2804 ,(or number '(gnus-summary-article-number)))))
2806 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2807 (defmacro gnus-summary-article-subject (&optional number)
2808 "Return current subject string or nil if nothing."
2811 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2812 '(gnus-data-header (assq (gnus-summary-article-number)
2813 gnus-newsgroup-data)))))
2816 (mail-header-subject headers))))
2818 (defmacro gnus-summary-article-score (&optional number)
2819 "Return current article score."
2820 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2821 gnus-newsgroup-scored))
2822 gnus-summary-default-score 0))
2824 (defun gnus-summary-article-children (&optional number)
2825 "Return a list of article numbers that are children of article NUMBER."
2826 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2827 (level (gnus-data-level (car data)))
2829 (while (and (setq data (cdr data))
2830 (> (setq l (gnus-data-level (car data))) level))
2831 (and (= (1+ level) l)
2832 (push (gnus-data-number (car data))
2834 (nreverse children)))
2836 (defun gnus-summary-article-parent (&optional number)
2837 "Return the article number of the parent of article NUMBER."
2838 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2839 (gnus-data-list t)))
2840 (level (gnus-data-level (car data))))
2842 () ; This is a root.
2843 ;; We search until we find an article with a level less than
2844 ;; this one. That function has to be the parent.
2845 (while (and (setq data (cdr data))
2846 (not (< (gnus-data-level (car data)) level))))
2847 (and data (gnus-data-number (car data))))))
2849 (defun gnus-unread-mark-p (mark)
2850 "Say whether MARK is the unread mark."
2851 (= mark gnus-unread-mark))
2853 (defun gnus-read-mark-p (mark)
2854 "Say whether MARK is one of the marks that mark as read.
2855 This is all marks except unread, ticked, dormant, and expirable."
2856 (not (or (= mark gnus-unread-mark)
2857 (= mark gnus-ticked-mark)
2858 (= mark gnus-dormant-mark)
2859 (= mark gnus-expirable-mark))))
2861 (defmacro gnus-article-mark (number)
2862 "Return the MARK of article NUMBER.
2863 This macro should only be used when computing the mark the \"first\"
2864 time; i.e., when generating the summary lines. After that,
2865 `gnus-summary-article-mark' should be used to examine the
2868 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2869 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2870 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2871 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2872 ((memq ,number gnus-newsgroup-spam-marked) gnus-spam-mark)
2873 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2874 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2875 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2876 gnus-ancient-mark))))
2878 ;; Saving hidden threads.
2880 (defmacro gnus-save-hidden-threads (&rest forms)
2881 "Save hidden threads, eval FORMS, and restore the hidden threads."
2882 (let ((config (make-symbol "config")))
2883 `(let ((,config (gnus-hidden-threads-configuration)))
2887 (gnus-restore-hidden-threads-configuration ,config)))))
2888 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2889 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2891 (defun gnus-data-compute-positions ()
2892 "Compute the positions of all articles."
2893 (setq gnus-newsgroup-data-reverse nil)
2894 (let ((data gnus-newsgroup-data))
2896 (gnus-save-hidden-threads
2897 (gnus-summary-show-all-threads)
2898 (goto-char (point-min))
2900 (while (get-text-property (point) 'gnus-intangible)
2902 (gnus-data-set-pos (car data) (+ (point) 3))
2903 (setq data (cdr data))
2904 (forward-line 1))))))
2906 (defun gnus-hidden-threads-configuration ()
2907 "Return the current hidden threads configuration."
2910 (goto-char (point-min))
2911 (while (search-forward "\r" nil t)
2912 (push (1- (point)) config))
2915 (defun gnus-restore-hidden-threads-configuration (config)
2916 "Restore hidden threads configuration from CONFIG."
2918 (let (point buffer-read-only)
2919 (while (setq point (pop config))
2920 (when (and (< point (point-max))
2922 (eq (char-after) ?\n))
2923 (subst-char-in-region point (1+ point) ?\n ?\r))))))
2925 ;; Various summary mode internalish functions.
2927 (defun gnus-mouse-pick-article (e)
2930 (gnus-summary-next-page nil t))
2932 (defun gnus-summary-set-display-table ()
2933 "Change the display table.
2934 Odd characters have a tendency to mess
2935 up nicely formatted displays - we make all possible glyphs
2936 display only a single character."
2938 ;; We start from the standard display table, if any.
2939 (let ((table (or (copy-sequence standard-display-table)
2940 (make-display-table)))
2942 ;; Nix out all the control chars...
2943 (while (>= (setq i (1- i)) 0)
2944 (aset table i [??]))
2945 ;; ... but not newline and cr, of course. (cr is necessary for the
2946 ;; selective display).
2947 (aset table ?\n nil)
2948 (aset table ?\r nil)
2949 ;; We keep TAB as well.
2950 (aset table ?\t nil)
2951 ;; We nix out any glyphs over 126 that are not set already.
2953 (while (>= (setq i (1- i)) 127)
2954 ;; Only modify if the entry is nil.
2955 (unless (aref table i)
2956 (aset table i [??]))))
2957 (setq buffer-display-table table)))
2959 (defun gnus-summary-set-article-display-arrow (pos)
2960 "Update the overlay arrow to point to line at position POS."
2961 (when (and gnus-summary-display-arrow
2962 (boundp 'overlay-arrow-position)
2963 (boundp 'overlay-arrow-string))
2967 (unless overlay-arrow-position
2968 (setq overlay-arrow-position (make-marker)))
2969 (setq overlay-arrow-string "=>"
2970 overlay-arrow-position (set-marker overlay-arrow-position
2972 (current-buffer))))))
2974 (defun gnus-summary-buffer-name (group)
2975 "Return the summary buffer name of GROUP."
2976 (concat "*Summary " (gnus-group-decoded-name group) "*"))
2978 (defun gnus-summary-setup-buffer (group)
2979 "Initialize summary buffer."
2980 (let ((buffer (gnus-summary-buffer-name group))
2981 (dead-name (concat "*Dead Summary "
2982 (gnus-group-decoded-name group) "*")))
2983 ;; If a dead summary buffer exists, we kill it.
2984 (when (gnus-buffer-live-p dead-name)
2985 (gnus-kill-buffer dead-name))
2986 (if (get-buffer buffer)
2989 (setq gnus-summary-buffer (current-buffer))
2990 (not gnus-newsgroup-prepared))
2991 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2992 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2993 (gnus-summary-mode group)
2995 (gnus-carpal-setup-buffer 'summary))
2996 (unless gnus-single-article-buffer
2997 (make-local-variable 'gnus-article-buffer)
2998 (make-local-variable 'gnus-article-current)
2999 (make-local-variable 'gnus-original-article-buffer))
3000 (setq gnus-newsgroup-name group)
3001 ;; Set any local variables in the group parameters.
3002 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3005 (defun gnus-set-global-variables ()
3006 "Set the global equivalents of the buffer-local variables.
3007 They are set to the latest values they had. These reflect the summary
3008 buffer that was in action when the last article was fetched."
3009 (when (eq major-mode 'gnus-summary-mode)
3010 (setq gnus-summary-buffer (current-buffer))
3011 (let ((name gnus-newsgroup-name)
3012 (marked gnus-newsgroup-marked)
3013 (spam gnus-newsgroup-spam-marked)
3014 (unread gnus-newsgroup-unreads)
3015 (headers gnus-current-headers)
3016 (data gnus-newsgroup-data)
3017 (summary gnus-summary-buffer)
3018 (article-buffer gnus-article-buffer)
3019 (original gnus-original-article-buffer)
3020 (gac gnus-article-current)
3021 (reffed gnus-reffed-article-number)
3022 (score-file gnus-current-score-file)
3023 (default-charset gnus-newsgroup-charset)
3025 (let ((locals gnus-newsgroup-variables))
3027 (if (consp (car locals))
3028 (push (eval (caar locals)) vlist)
3029 (push (eval (car locals)) vlist))
3030 (setq locals (cdr locals)))
3031 (setq vlist (nreverse vlist)))
3033 (set-buffer gnus-group-buffer)
3034 (setq gnus-newsgroup-name name
3035 gnus-newsgroup-marked marked
3036 gnus-newsgroup-spam-marked spam
3037 gnus-newsgroup-unreads unread
3038 gnus-current-headers headers
3039 gnus-newsgroup-data data
3040 gnus-article-current gac
3041 gnus-summary-buffer summary
3042 gnus-article-buffer article-buffer
3043 gnus-original-article-buffer original
3044 gnus-reffed-article-number reffed
3045 gnus-current-score-file score-file
3046 gnus-newsgroup-charset default-charset)
3047 (let ((locals gnus-newsgroup-variables))
3049 (if (consp (car locals))
3050 (set (caar locals) (pop vlist))
3051 (set (car locals) (pop vlist)))
3052 (setq locals (cdr locals))))
3053 ;; The article buffer also has local variables.
3054 (when (gnus-buffer-live-p gnus-article-buffer)
3055 (set-buffer gnus-article-buffer)
3056 (setq gnus-summary-buffer summary))))))
3058 (defun gnus-summary-article-unread-p (article)
3059 "Say whether ARTICLE is unread or not."
3060 (memq article gnus-newsgroup-unreads))
3062 (defun gnus-summary-first-article-p (&optional article)
3063 "Return whether ARTICLE is the first article in the buffer."
3064 (if (not (setq article (or article (gnus-summary-article-number))))
3066 (eq article (caar gnus-newsgroup-data))))
3068 (defun gnus-summary-last-article-p (&optional article)
3069 "Return whether ARTICLE is the last article in the buffer."
3070 (if (not (setq article (or article (gnus-summary-article-number))))
3071 ;; All non-existent numbers are the last article. :-)
3073 (not (cdr (gnus-data-find-list article)))))
3075 (defun gnus-make-thread-indent-array ()
3077 (unless (and gnus-thread-indent-array
3078 (= gnus-thread-indent-level gnus-thread-indent-array-level))
3079 (setq gnus-thread-indent-array (make-vector 201 "")
3080 gnus-thread-indent-array-level gnus-thread-indent-level)
3082 (aset gnus-thread-indent-array n
3083 (make-string (* n gnus-thread-indent-level) ? ))
3086 (defun gnus-update-summary-mark-positions ()
3087 "Compute where the summary marks are to go."
3089 (when (gnus-buffer-exists-p gnus-summary-buffer)
3090 (set-buffer gnus-summary-buffer))
3091 (let ((gnus-replied-mark 129)
3092 (gnus-score-below-mark 130)
3093 (gnus-score-over-mark 130)
3094 (gnus-downloaded-mark 131)
3095 (spec gnus-summary-line-format-spec)
3098 (gnus-set-work-buffer)
3099 (let ((gnus-summary-line-format-spec spec)
3100 (gnus-newsgroup-downloadable '(0)))
3101 (gnus-summary-insert-line
3102 (make-full-mail-header 0 "" "nobody"
3103 "05 Apr 2001 23:33:09 +0400"
3105 0 nil nil 128 t nil "" nil 1)
3106 (goto-char (point-min))
3107 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
3108 (- (point) (point-min) 1)))))
3109 (goto-char (point-min))
3110 (push (cons 'replied (and (search-forward "\201" nil t)
3111 (- (point) (point-min) 1)))
3113 (goto-char (point-min))
3114 (push (cons 'score (and (search-forward "\202" nil t)
3115 (- (point) (point-min) 1)))
3117 (goto-char (point-min))
3118 (push (cons 'download
3119 (and (search-forward "\203" nil t)
3120 (- (point) (point-min) 1)))
3122 (setq gnus-summary-mark-positions pos))))
3124 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
3125 "Insert a dummy root in the summary buffer."
3127 (gnus-add-text-properties
3128 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
3129 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
3131 (defun gnus-summary-extract-address-component (from)
3132 (or (car (funcall gnus-extract-address-components from))
3135 (defun gnus-summary-from-or-to-or-newsgroups (header gnus-tmp-from)
3136 (let ((default-mime-charset (with-current-buffer gnus-summary-buffer
3137 default-mime-charset)))
3138 ;; Is it really necessary to do this next part for each summary line?
3139 ;; Luckily, doesn't seem to slow things down much.
3141 (and gnus-ignored-from-addresses
3142 (string-match gnus-ignored-from-addresses gnus-tmp-from)
3143 (let ((extra-headers (mail-header-extra header))
3147 ((setq to (cdr (assq 'To extra-headers)))
3150 (gnus-summary-extract-address-component
3151 (funcall gnus-decode-encoded-word-function to)))))
3152 ((setq newsgroups (cdr (assq 'Newsgroups extra-headers)))
3153 (concat "=> " newsgroups)))))
3154 (inline (gnus-summary-extract-address-component gnus-tmp-from)))))
3156 (defun gnus-summary-insert-line (gnus-tmp-header
3157 gnus-tmp-level gnus-tmp-current
3158 undownloaded gnus-tmp-unread gnus-tmp-replied
3159 gnus-tmp-expirable gnus-tmp-subject-or-nil
3160 &optional gnus-tmp-dummy gnus-tmp-score
3162 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
3163 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
3164 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
3165 (gnus-tmp-score-char
3166 (if (or (null gnus-summary-default-score)
3167 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3168 gnus-summary-zcore-fuzz))
3170 (if (< gnus-tmp-score gnus-summary-default-score)
3171 gnus-score-below-mark gnus-score-over-mark)))
3172 (gnus-tmp-number (mail-header-number gnus-tmp-header))
3174 (cond (gnus-tmp-process gnus-process-mark)
3175 ((memq gnus-tmp-current gnus-newsgroup-cached)
3177 (gnus-tmp-replied gnus-replied-mark)
3178 ((memq gnus-tmp-current gnus-newsgroup-forwarded)
3179 gnus-forwarded-mark)
3180 ((memq gnus-tmp-current gnus-newsgroup-saved)
3182 ((memq gnus-tmp-number gnus-newsgroup-recent)
3184 ((memq gnus-tmp-number gnus-newsgroup-unseen)
3187 (gnus-tmp-downloaded
3189 gnus-undownloaded-mark)
3190 (gnus-newsgroup-agentized
3191 gnus-downloaded-mark)
3194 (gnus-tmp-from (mail-header-from gnus-tmp-header))
3197 ((string-match "<[^>]+> *$" gnus-tmp-from)
3198 (let ((beg (match-beginning 0)))
3199 (or (and (string-match "^\".+\"" gnus-tmp-from)
3200 (substring gnus-tmp-from 1 (1- (match-end 0))))
3201 (substring gnus-tmp-from 0 beg))))
3202 ((string-match "(.+)" gnus-tmp-from)
3203 (substring gnus-tmp-from
3204 (1+ (match-beginning 0)) (1- (match-end 0))))
3206 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
3207 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
3208 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
3209 (buffer-read-only nil))
3210 (when (string= gnus-tmp-name "")
3211 (setq gnus-tmp-name gnus-tmp-from))
3212 (unless (numberp gnus-tmp-lines)
3213 (setq gnus-tmp-lines -1))
3214 (if (= gnus-tmp-lines -1)
3215 (setq gnus-tmp-lines "?")
3216 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
3217 (gnus-put-text-property-excluding-characters-with-faces
3219 (progn (eval gnus-summary-line-format-spec) (point))
3220 'gnus-number gnus-tmp-number)
3221 (when (gnus-visual-p 'summary-highlight 'highlight)
3223 (gnus-run-hooks 'gnus-summary-update-hook)
3226 (defun gnus-summary-update-line (&optional dont-update)
3227 "Update summary line after change."
3228 (when (and gnus-summary-default-score
3229 (not gnus-summary-inhibit-highlight))
3230 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
3231 (article (gnus-summary-article-number))
3232 (score (gnus-summary-article-score article)))
3234 (if (and gnus-summary-mark-below
3235 (< (gnus-summary-article-score)
3236 gnus-summary-mark-below))
3237 ;; This article has a low score, so we mark it as read.
3238 (when (memq article gnus-newsgroup-unreads)
3239 (gnus-summary-mark-article-as-read gnus-low-score-mark))
3240 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
3241 ;; This article was previously marked as read on account
3242 ;; of a low score, but now it has risen, so we mark it as
3244 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
3245 (gnus-summary-update-mark
3246 (if (or (null gnus-summary-default-score)
3247 (<= (abs (- score gnus-summary-default-score))
3248 gnus-summary-zcore-fuzz))
3250 (if (< score gnus-summary-default-score)
3251 gnus-score-below-mark gnus-score-over-mark))
3253 ;; Do visual highlighting.
3254 (when (gnus-visual-p 'summary-highlight 'highlight)
3255 (gnus-run-hooks 'gnus-summary-update-hook)))))
3257 (defvar gnus-tmp-new-adopts nil)
3259 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
3260 "Return the number of articles in THREAD.
3261 This may be 0 in some cases -- if none of the articles in
3262 the thread are to be displayed."
3264 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
3266 ((not (listp thread))
3268 ((and (consp thread) (cdr thread))
3271 'gnus-summary-number-of-articles-in-thread (cdr thread))))
3274 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
3277 (when (and level (zerop level) gnus-tmp-new-adopts)
3280 'gnus-summary-number-of-articles-in-thread
3281 gnus-tmp-new-adopts))))
3283 (if (> number 1) gnus-not-empty-thread-mark
3284 gnus-empty-thread-mark)
3287 (defsubst gnus-summary-line-message-size (head)
3288 "Return pretty-printed version of message size.
3289 This function is intended to be used in
3290 `gnus-summary-line-format-alist', which see."
3291 (let ((c (or (mail-header-chars head) -1)))
3292 (cond ((< c 0) "n/a") ; chars not available
3293 ((< c (* 1000 10)) (format "%1.1fk" (/ c 1024.0)))
3294 ((< c (* 1000 100)) (format "%dk" (/ c 1024.0)))
3295 ((< c (* 1000 10000)) (format "%1.1fM" (/ c (* 1024.0 1024))))
3296 (t (format "%dM" (/ c (* 1024.0 1024)))))))
3299 (defun gnus-summary-set-local-parameters (group)
3300 "Go through the local params of GROUP and set all variable specs in that list."
3301 (let ((params (gnus-group-find-parameter group))
3302 (vars '(quit-config)) ; Ignore quit-config.
3305 (setq elem (car params)
3306 params (cdr params))
3307 (and (consp elem) ; Has to be a cons.
3308 (consp (cdr elem)) ; The cdr has to be a list.
3309 (symbolp (car elem)) ; Has to be a symbol in there.
3310 (not (memq (car elem) vars))
3311 (ignore-errors ; So we set it.
3312 (push (car elem) vars)
3313 (make-local-variable (car elem))
3314 (set (car elem) (eval (nth 1 elem))))))))
3316 (defun gnus-summary-read-group (group &optional show-all no-article
3317 kill-buffer no-display backward
3319 "Start reading news in newsgroup GROUP.
3320 If SHOW-ALL is non-nil, already read articles are also listed.
3321 If NO-ARTICLE is non-nil, no article is selected initially.
3322 If NO-DISPLAY, don't generate a summary buffer."
3326 (let ((gnus-auto-select-next nil))
3327 (or (gnus-summary-read-group-1
3328 group show-all no-article
3329 kill-buffer no-display
3332 select-articles nil)))))
3333 (eq gnus-auto-select-next 'quietly))
3334 (set-buffer gnus-group-buffer)
3335 ;; The entry function called above goes to the next
3336 ;; group automatically, so we go two groups back
3337 ;; if we are searching for the previous group.
3339 (gnus-group-prev-unread-group 2))
3340 (if (not (equal group (gnus-group-group-name)))
3341 (setq group (gnus-group-group-name))
3345 (defun gnus-summary-jump-to-other-group (group &optional show-all)
3346 "Directly jump to the other GROUP from summary buffer.
3347 If SHOW-ALL is non-nil, already read articles are also listed."
3349 (if (eq gnus-summary-buffer (current-buffer))
3350 (list (completing-read
3351 "Group: " gnus-active-hashtb nil t
3352 (when (and gnus-newsgroup-name
3353 (string-match "[.:][^.:]+$" gnus-newsgroup-name))
3354 (substring gnus-newsgroup-name 0 (1+ (match-beginning 0))))
3355 'gnus-group-history)
3357 (error "%s must be invoked from a gnus summary buffer." this-command)))
3358 (unless (or (zerop (length group))
3359 (and gnus-newsgroup-name
3360 (string-equal gnus-newsgroup-name group)))
3362 (gnus-summary-read-group group show-all
3363 gnus-dont-select-after-jump-to-other-group)))
3365 (defun gnus-summary-read-group-1 (group show-all no-article
3366 kill-buffer no-display
3367 &optional select-articles)
3368 ;; Killed foreign groups can't be entered.
3369 ;; (when (and (not (gnus-group-native-p group))
3370 ;; (not (gnus-gethash group gnus-newsrc-hashtb)))
3371 ;; (error "Dead non-native groups can't be entered"))
3372 (gnus-message 5 "Retrieving newsgroup: %s..."
3373 (gnus-group-decoded-name group))
3374 (let* ((new-group (gnus-summary-setup-buffer group))
3375 (quit-config (gnus-group-quit-config group))
3376 (did-select (and new-group (gnus-select-newsgroup
3377 group show-all select-articles))))
3379 ;; This summary buffer exists already, so we just select it.
3381 (gnus-set-global-variables)
3383 (gnus-kill-or-deaden-summary kill-buffer))
3384 (gnus-configure-windows 'summary 'force)
3385 (gnus-set-mode-line 'summary)
3386 (gnus-summary-position-point)
3389 ;; We couldn't select this group.
3391 (when (and (eq major-mode 'gnus-summary-mode)
3392 (not (equal (current-buffer) kill-buffer)))
3393 (kill-buffer (current-buffer))
3394 (if (not quit-config)
3396 ;; Update the info -- marks might need to be removed,
3398 (gnus-summary-update-info)
3399 (set-buffer gnus-group-buffer)
3400 (gnus-group-jump-to-group group)
3401 (gnus-group-next-unread-group 1))
3402 (gnus-handle-ephemeral-exit quit-config)))
3403 (let ((grpinfo (gnus-get-info group)))
3404 (if (null (gnus-info-read grpinfo))
3405 (gnus-message 3 "Group %s contains no messages"
3406 (gnus-group-decoded-name group))
3407 (gnus-message 3 "Can't select group")))
3409 ;; The user did a `C-g' while prompting for number of articles,
3410 ;; so we exit this group.
3411 ((eq did-select 'quit)
3412 (and (eq major-mode 'gnus-summary-mode)
3413 (not (equal (current-buffer) kill-buffer))
3414 (kill-buffer (current-buffer)))
3416 (gnus-kill-or-deaden-summary kill-buffer))
3417 (if (not quit-config)
3419 (set-buffer gnus-group-buffer)
3420 (gnus-group-jump-to-group group)
3421 (gnus-group-next-unread-group 1)
3422 (gnus-configure-windows 'group 'force))
3423 (gnus-handle-ephemeral-exit quit-config))
3424 ;; Finally signal the quit.
3426 ;; The group was successfully selected.
3428 (gnus-set-global-variables)
3429 ;; Save the active value in effect when the group was entered.
3430 (setq gnus-newsgroup-active
3432 (gnus-active gnus-newsgroup-name)))
3433 ;; You can change the summary buffer in some way with this hook.
3434 (gnus-run-hooks 'gnus-select-group-hook)
3435 (gnus-update-format-specifications
3436 nil 'summary 'summary-mode 'summary-dummy)
3437 (gnus-update-summary-mark-positions)
3438 ;; Do score processing.
3439 (when gnus-use-scoring
3440 (gnus-possibly-score-headers))
3441 ;; Check whether to fill in the gaps in the threads.
3442 (when gnus-build-sparse-threads
3443 (gnus-build-sparse-threads))
3444 ;; Find the initial limit.
3445 (if gnus-show-threads
3447 (let ((gnus-newsgroup-dormant nil))
3448 (gnus-summary-initial-limit show-all))
3449 (gnus-summary-initial-limit show-all))
3450 ;; When unthreaded, all articles are always shown.
3451 (setq gnus-newsgroup-limit
3453 (lambda (header) (mail-header-number header))
3454 gnus-newsgroup-headers)))
3455 ;; Generate the summary buffer.
3457 (gnus-summary-prepare))
3458 (when gnus-use-trees
3459 (gnus-tree-open group)
3460 (setq gnus-summary-highlight-line-function
3461 'gnus-tree-highlight-article))
3462 ;; If the summary buffer is empty, but there are some low-scored
3463 ;; articles or some excluded dormants, we include these in the
3465 (when (and (zerop (buffer-size))
3467 (cond (gnus-newsgroup-dormant
3468 (gnus-summary-limit-include-dormant))
3469 ((and gnus-newsgroup-scored show-all)
3470 (gnus-summary-limit-include-expunged t))))
3471 ;; Function `gnus-apply-kill-file' must be called in this hook.
3472 (gnus-run-hooks 'gnus-apply-kill-hook)
3473 (if (and (zerop (buffer-size))
3476 ;; This newsgroup is empty.
3477 (gnus-summary-catchup-and-exit nil t)
3478 (gnus-message 6 "No unread news")
3480 (gnus-kill-or-deaden-summary kill-buffer))
3481 ;; Return nil from this function.
3483 ;; Hide conversation thread subtrees. We cannot do this in
3484 ;; gnus-summary-prepare-hook since kill processing may not
3485 ;; work with hidden articles.
3486 (gnus-summary-maybe-hide-threads)
3488 (gnus-kill-or-deaden-summary kill-buffer))
3489 (gnus-summary-auto-select-subject)
3490 ;; Show first unread article if requested.
3491 (if (and (not no-article)
3493 gnus-newsgroup-unreads
3494 gnus-auto-select-first)
3496 (gnus-configure-windows 'summary)
3497 (let ((art (gnus-summary-article-number)))
3498 (unless (or (memq art gnus-newsgroup-undownloaded)
3499 (memq art gnus-newsgroup-downloadable))
3500 (gnus-summary-goto-article art))))
3501 ;; Don't select any articles.
3502 (gnus-summary-position-point)
3503 (gnus-configure-windows 'summary 'force)
3504 (gnus-set-mode-line 'summary))
3505 (when (get-buffer-window gnus-group-buffer t)
3506 ;; Gotta use windows, because recenter does weird stuff if
3507 ;; the current buffer ain't the displayed window.
3508 (let ((owin (selected-window)))
3509 (select-window (get-buffer-window gnus-group-buffer t))
3510 (when (gnus-group-goto-group group)
3512 (select-window owin)))
3513 ;; Mark this buffer as "prepared".
3514 (setq gnus-newsgroup-prepared t)
3515 (gnus-run-hooks 'gnus-summary-prepared-hook)
3518 (defun gnus-summary-auto-select-subject ()
3519 "Select the subject line on initial group entry."
3520 (goto-char (point-min))
3522 ((eq gnus-auto-select-subject 'best)
3523 (gnus-summary-best-unread-subject))
3524 ((eq gnus-auto-select-subject 'unread)
3525 (gnus-summary-first-unread-subject))
3526 ((eq gnus-auto-select-subject 'unseen)
3527 (gnus-summary-first-unseen-subject))
3528 ((eq gnus-auto-select-subject 'unseen-or-unread)
3529 (gnus-summary-first-unseen-or-unread-subject))
3530 ((eq gnus-auto-select-subject 'first)
3533 ((gnus-functionp gnus-auto-select-subject)
3534 (funcall gnus-auto-select-subject))))
3536 (defun gnus-summary-prepare ()
3537 "Generate the summary buffer."
3539 (let ((buffer-read-only nil))
3541 (setq gnus-newsgroup-data nil
3542 gnus-newsgroup-data-reverse nil)
3543 (gnus-run-hooks 'gnus-summary-generate-hook)
3544 ;; Generate the buffer, either with threads or without.
3545 (when gnus-newsgroup-headers
3546 (gnus-summary-prepare-threads
3547 (if gnus-show-threads
3548 (gnus-sort-gathered-threads
3549 (funcall gnus-summary-thread-gathering-function
3551 (gnus-cut-threads (gnus-make-threads)))))
3552 ;; Unthreaded display.
3553 (gnus-sort-articles gnus-newsgroup-headers))))
3554 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
3555 ;; Call hooks for modifying summary buffer.
3556 (goto-char (point-min))
3557 (gnus-run-hooks 'gnus-summary-prepare-hook)))
3559 (defsubst gnus-general-simplify-subject (subject)
3560 "Simply subject by the same rules as gnus-gather-threads-by-subject."
3563 ;; Truncate the subject.
3564 (gnus-simplify-subject-functions
3565 (gnus-map-function gnus-simplify-subject-functions subject))
3566 ((numberp gnus-summary-gather-subject-limit)
3567 (setq subject (gnus-simplify-subject-re subject))
3568 (if (> (length subject) gnus-summary-gather-subject-limit)
3569 (substring subject 0 gnus-summary-gather-subject-limit)
3571 ;; Fuzzily simplify it.
3572 ((eq 'fuzzy gnus-summary-gather-subject-limit)
3573 (gnus-simplify-subject-fuzzy subject))
3574 ;; Just remove the leading "Re:".
3576 (gnus-simplify-subject-re subject))))
3578 (if (and gnus-summary-gather-exclude-subject
3579 (string-match gnus-summary-gather-exclude-subject subject))
3580 nil ; This article shouldn't be gathered
3583 (defun gnus-summary-simplify-subject-query ()
3584 "Query where the respool algorithm would put this article."
3586 (gnus-summary-select-article)
3588 (gnus-general-simplify-subject (gnus-summary-article-subject))))
3590 (defun gnus-gather-threads-by-subject (threads)
3591 "Gather threads by looking at Subject headers."
3592 (if (not gnus-summary-make-false-root)
3594 (let ((hashtb (gnus-make-hashtable 1024))
3597 subject hthread whole-subject)
3599 (setq subject (gnus-general-simplify-subject
3600 (setq whole-subject (mail-header-subject
3603 (if (setq hthread (gnus-gethash subject hashtb))
3605 ;; We enter a dummy root into the thread, if we
3606 ;; haven't done that already.
3607 (unless (stringp (caar hthread))
3608 (setcar hthread (list whole-subject (car hthread))))
3609 ;; We add this new gathered thread to this gathered
3611 (setcdr (car hthread)
3612 (nconc (cdar hthread) (list (car threads))))
3613 ;; Remove it from the list of threads.
3614 (setcdr prev (cdr threads))
3615 (setq threads prev))
3616 ;; Enter this thread into the hash table.
3617 (gnus-sethash subject
3618 (if gnus-summary-make-false-root-always
3620 ;; If you want a dummy root above all
3622 (setcar threads (list whole-subject
3628 (setq threads (cdr threads)))
3631 (defun gnus-gather-threads-by-references (threads)
3632 "Gather threads by looking at References headers."
3633 (let ((idhashtb (gnus-make-hashtable 1024))
3634 (thhashtb (gnus-make-hashtable 1024))
3637 ids references id gthread gid entered ref)
3639 (when (setq references (mail-header-references (caar threads)))
3640 (setq id (mail-header-id (caar threads))
3641 ids (inline (gnus-split-references references))
3643 (while (setq ref (pop ids))
3644 (setq ids (delete ref ids))
3645 (if (not (setq gid (gnus-gethash ref idhashtb)))
3647 (gnus-sethash ref id idhashtb)
3648 (gnus-sethash id threads thhashtb))
3649 (setq gthread (gnus-gethash gid thhashtb))
3651 ;; We enter a dummy root into the thread, if we
3652 ;; haven't done that already.
3653 (unless (stringp (caar gthread))
3654 (setcar gthread (list (mail-header-subject (caar gthread))
3656 ;; We add this new gathered thread to this gathered
3658 (setcdr (car gthread)
3659 (nconc (cdar gthread) (list (car threads)))))
3660 ;; Add it into the thread hash table.
3661 (gnus-sethash id gthread thhashtb)
3663 ;; Remove it from the list of threads.
3664 (setcdr prev (cdr threads))
3665 (setq threads prev))))
3667 (setq threads (cdr threads)))
3670 (defun gnus-sort-gathered-threads (threads)
3671 "Sort subtreads inside each gathered thread by `gnus-sort-gathered-threads-function'."
3672 (let ((result threads))
3674 (when (stringp (caar threads))
3675 (setcdr (car threads)
3676 (sort (cdar threads) gnus-sort-gathered-threads-function)))
3677 (setq threads (cdr threads)))
3680 (defun gnus-thread-loop-p (root thread)
3681 "Say whether ROOT is in THREAD."
3682 (let ((stack (list thread))
3685 (while (setq thread (pop stack))
3686 (setq th (cdr thread))
3688 (not (eq (caar th) root)))
3691 ;; We have found a loop.
3693 (setcdr thread (delq (car th) (cdr thread)))
3694 (if (boundp (setq ref-dep (intern "none"
3695 gnus-newsgroup-dependencies)))
3696 (setcdr (symbol-value ref-dep)
3697 (nconc (cdr (symbol-value ref-dep))
3699 (set ref-dep (list nil (car th))))
3702 ;; Push all the subthreads onto the stack.
3703 (push (cdr thread) stack)))
3706 (defun gnus-make-threads ()
3707 "Go through the dependency hashtb and find the roots. Return all threads."
3709 (while (catch 'infloop
3712 ;; Deal with self-referencing References loops.
3713 (when (and (car (symbol-value refs))
3720 (car (symbol-value refs)) thread))
3721 (cdr (symbol-value refs)))))))
3724 (unless (car (symbol-value refs))
3725 ;; These threads do not refer back to any other articles,
3726 ;; so they're roots.
3727 (setq threads (append (cdr (symbol-value refs)) threads))))
3728 gnus-newsgroup-dependencies)))
3731 ;; Build the thread tree.
3732 (defsubst gnus-dependencies-add-header (header dependencies force-new)
3733 "Enter HEADER into the DEPENDENCIES table if it is not already there.
3735 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
3736 if it was already present.
3738 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3739 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3740 Message-IDs will be renamed to a unique Message-ID before being
3743 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3744 (let* ((id (mail-header-id header))
3745 (id-dep (and id (intern id dependencies)))
3746 parent-id ref ref-dep ref-header replaced)
3747 ;; Enter this `header' in the `dependencies' table.
3751 ;; The first two cases do the normal part: enter a new `header'
3752 ;; in the `dependencies' table.
3753 ((not (boundp id-dep))
3754 (set id-dep (list header)))
3755 ((null (car (symbol-value id-dep)))
3756 (setcar (symbol-value id-dep) header))
3758 ;; From here the `header' was already present in the
3759 ;; `dependencies' table.
3761 ;; Overrides an existing entry;
3762 ;; just set the header part of the entry.
3763 (setcar (symbol-value id-dep) header)
3766 ;; Renames the existing `header' to a unique Message-ID.
3767 ((not gnus-summary-ignore-duplicates)
3768 ;; An article with this Message-ID has already been seen.
3769 ;; We rename the Message-ID.
3770 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3772 (mail-header-set-id header id))
3774 ;; The last case ignores an existing entry, except it adds any
3775 ;; additional Xrefs (in case the two articles came from different
3777 ;; Also sets `header' to `nil' meaning that the `dependencies'
3778 ;; table was *not* modified.
3780 (mail-header-set-xref
3781 (car (symbol-value id-dep))
3782 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3784 (or (mail-header-xref header) "")))
3787 (when (and header (not replaced))
3788 ;; First check that we are not creating a References loop.
3789 (setq parent-id (gnus-parent-id (mail-header-references header)))
3790 (setq ref parent-id)
3792 (setq ref-dep (intern-soft ref dependencies))
3794 (setq ref-header (car (symbol-value ref-dep))))
3795 (if (string= id ref)
3796 ;; Yuk! This is a reference loop. Make the article be a
3799 (mail-header-set-references (car (symbol-value id-dep)) "none")
3801 (setq parent-id nil))
3802 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3803 (setq ref-dep (intern (or parent-id "none") dependencies))
3804 (if (boundp ref-dep)
3805 (setcdr (symbol-value ref-dep)
3806 (nconc (cdr (symbol-value ref-dep))
3807 (list (symbol-value id-dep))))
3808 (set ref-dep (list nil (symbol-value id-dep)))))
3811 (defun gnus-extract-message-id-from-in-reply-to (string)
3812 (if (string-match "<[^>]+>" string)
3813 (substring string (match-beginning 0) (match-end 0))
3816 (defun gnus-build-sparse-threads ()
3817 (let ((headers gnus-newsgroup-headers)
3818 (mail-parse-charset gnus-newsgroup-charset)
3819 (gnus-summary-ignore-duplicates t)
3820 header references generation relations
3821 subject child end new-child date)
3822 ;; First we create an alist of generations/relations, where
3823 ;; generations is how much we trust the relation, and the relation
3825 (gnus-message 7 "Making sparse threads...")
3827 (nnheader-set-temp-buffer " *gnus sparse threads*")
3828 (while (setq header (pop headers))
3829 (when (and (setq references (mail-header-references header))
3830 (not (string= references "")))
3832 (setq child (mail-header-id header)
3833 subject (mail-header-subject header)
3834 date (mail-header-date header)
3836 (while (search-backward ">" nil t)
3837 (setq end (1+ (point)))
3838 (when (search-backward "<" nil t)
3839 (setq new-child (buffer-substring (point) end))
3840 (push (list (incf generation)
3841 child (setq child new-child)
3845 (push (list (1+ generation) child nil subject) relations))
3847 (kill-buffer (current-buffer)))
3848 ;; Sort over trustworthiness.
3851 (when (gnus-dependencies-add-header
3852 (make-full-mail-header-from-decoded-header
3853 gnus-reffed-article-number
3854 (nth 3 relation) "" (or (nth 4 relation) "")
3856 (or (nth 2 relation) "") 0 0 "")
3857 gnus-newsgroup-dependencies nil)
3858 (push gnus-reffed-article-number gnus-newsgroup-limit)
3859 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3860 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3861 gnus-newsgroup-reads)
3862 (decf gnus-reffed-article-number)))
3863 (sort relations 'car-less-than-car))
3864 (gnus-message 7 "Making sparse threads...done")))
3866 (defun gnus-build-old-threads ()
3867 ;; Look at all the articles that refer back to old articles, and
3868 ;; fetch the headers for the articles that aren't there. This will
3869 ;; build complete threads - if the roots haven't been expired by the
3871 (let ((mail-parse-charset gnus-newsgroup-charset)
3875 (when (not (car (symbol-value refs)))
3876 (setq heads (cdr (symbol-value refs)))
3878 (if (memq (mail-header-number (caar heads))
3879 gnus-newsgroup-dormant)
3880 (setq heads (cdr heads))
3881 (setq id (symbol-name refs))
3882 (while (and (setq id (gnus-build-get-header id))
3883 (not (car (gnus-id-to-thread id)))))
3884 (setq heads nil)))))
3885 gnus-newsgroup-dependencies)))
3887 ;; This function has to be called with point after the article number
3888 ;; on the beginning of the line.
3889 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3890 (let ((eol (gnus-point-at-eol))
3891 (buffer (current-buffer))
3892 header references in-reply-to)
3894 ;; overview: [num subject from date id refs chars lines misc]
3897 (narrow-to-region (point) eol)
3902 (make-full-mail-header
3904 (nnheader-nov-field) ; subject
3905 (nnheader-nov-field) ; from
3906 (nnheader-nov-field) ; date
3907 (nnheader-nov-read-message-id) ; id
3908 (nnheader-nov-field) ; refs
3909 (nnheader-nov-read-integer) ; chars
3910 (nnheader-nov-read-integer) ; lines
3912 (if (looking-at "Xref: ")
3913 (goto-char (match-end 0)))
3914 (nnheader-nov-field)) ; Xref
3915 (nnheader-nov-parse-extra)))) ; extra
3919 (when (and (string= references "")
3920 (setq in-reply-to (mail-header-extra header))
3921 (setq in-reply-to (cdr (assq 'In-Reply-To in-reply-to))))
3922 (mail-header-set-references
3923 header (gnus-extract-message-id-from-in-reply-to in-reply-to)))
3925 (when gnus-alter-header-function
3926 (funcall gnus-alter-header-function header))
3927 (gnus-dependencies-add-header header dependencies force-new)))
3929 (defun gnus-build-get-header (id)
3930 "Look through the buffer of NOV lines and find the header to ID.
3931 Enter this line into the dependencies hash table, and return
3932 the id of the parent article (if any)."
3933 (let ((deps gnus-newsgroup-dependencies)
3937 (set-buffer nntp-server-buffer)
3938 (let ((case-fold-search nil))
3939 (goto-char (point-min))
3940 (while (and (not found)
3941 (search-forward id nil t))
3943 (setq found (looking-at
3944 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3945 (regexp-quote id))))
3946 (or found (beginning-of-line 2)))
3950 (setq header (gnus-nov-parse-line
3951 (read (current-buffer)) deps))
3952 (gnus-parent-id (mail-header-references header))))))
3954 (let ((number (mail-header-number header)))
3955 (push number gnus-newsgroup-limit)
3956 (push header gnus-newsgroup-headers)
3957 (if (memq number gnus-newsgroup-unselected)
3959 (setq gnus-newsgroup-unreads
3960 (gnus-add-to-sorted-list gnus-newsgroup-unreads
3962 (setq gnus-newsgroup-unselected
3963 (delq number gnus-newsgroup-unselected)))
3964 (push number gnus-newsgroup-ancient)))))))
3966 (defun gnus-build-all-threads ()
3967 "Read all the headers."
3968 (let ((gnus-summary-ignore-duplicates t)
3969 (mail-parse-charset gnus-newsgroup-charset)
3970 (dependencies gnus-newsgroup-dependencies)
3973 (set-buffer nntp-server-buffer)
3974 (let ((case-fold-search nil))
3975 (goto-char (point-min))
3978 (setq article (read (current-buffer))
3979 header (gnus-nov-parse-line article dependencies)))
3982 (set-buffer gnus-summary-buffer)
3983 (push header gnus-newsgroup-headers)
3984 (if (memq (setq article (mail-header-number header))
3985 gnus-newsgroup-unselected)
3987 (setq gnus-newsgroup-unreads
3988 (gnus-add-to-sorted-list
3989 gnus-newsgroup-unreads article))
3990 (setq gnus-newsgroup-unselected
3991 (delq article gnus-newsgroup-unselected)))
3992 (push article gnus-newsgroup-ancient)))
3993 (forward-line 1)))))))
3995 (defun gnus-summary-update-article-line (article header)
3996 "Update the line for ARTICLE using HEADERS."
3997 (let* ((id (mail-header-id header))
3998 (thread (gnus-id-to-thread id)))
4000 (error "Article in no thread"))
4001 ;; Update the thread.
4002 (setcar thread header)
4003 (gnus-summary-goto-subject article)
4004 (let* ((datal (gnus-data-find-list article))
4006 (length (when (cdr datal)
4007 (- (gnus-data-pos data)
4008 (gnus-data-pos (cadr datal)))))
4009 (buffer-read-only nil)
4010 (level (gnus-summary-thread-level)))
4012 (gnus-summary-insert-line
4014 (memq article gnus-newsgroup-undownloaded)
4015 (gnus-article-mark article)
4016 (memq article gnus-newsgroup-replied)
4017 (memq article gnus-newsgroup-expirable)
4018 ;; Only insert the Subject string when it's different
4019 ;; from the previous Subject string.
4024 (mail-header-subject
4027 (gnus-data-find-list
4029 (gnus-data-list t)))))
4030 ;; Error on the side of excessive subjects.
4032 (mail-header-subject header)))
4034 (mail-header-subject header))
4035 nil (cdr (assq article gnus-newsgroup-scored))
4036 (memq article gnus-newsgroup-processable))
4038 (gnus-data-update-list
4039 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
4041 (defun gnus-summary-update-article (article &optional iheader)
4042 "Update ARTICLE in the summary buffer."
4043 (set-buffer gnus-summary-buffer)
4044 (let* ((header (gnus-summary-article-header article))
4045 (id (mail-header-id header))
4046 (data (gnus-data-find article))
4047 (thread (gnus-id-to-thread id))
4048 (references (mail-header-references header))
4052 (when (and references
4053 (not (equal "" references)))
4056 (buffer-read-only nil)
4062 (delq thread parent)))
4063 (if (gnus-summary-insert-subject id header)
4064 ;; Set the (possibly) new article number in the data structure.
4065 (gnus-data-set-number data (gnus-id-to-article id))
4069 (defun gnus-rebuild-thread (id &optional line)
4070 "Rebuild the thread containing ID.
4071 If LINE, insert the rebuilt thread starting on line LINE."
4072 (let ((buffer-read-only nil)
4073 old-pos current thread data)
4074 (if (not gnus-show-threads)
4075 (setq thread (list (car (gnus-id-to-thread id))))
4076 ;; Get the thread this article is part of.
4077 (setq thread (gnus-remove-thread id)))
4078 (setq old-pos (gnus-point-at-bol))
4079 (setq current (save-excursion
4080 (and (re-search-backward "[\r\n]" nil t)
4081 (gnus-summary-article-number))))
4082 ;; If this is a gathered thread, we have to go some re-gathering.
4083 (when (stringp (car thread))
4084 (let ((subject (car thread))
4086 (setq thread (cdr thread))
4088 (unless (memq (setq thr (gnus-id-to-thread
4090 (mail-header-id (caar thread)))))
4093 (setq thread (cdr thread)))
4094 ;; We now have all (unique) roots.
4095 (if (= (length roots) 1)
4096 ;; All the loose roots are now one solid root.
4097 (setq thread (car roots))
4098 (setq thread (cons subject (gnus-sort-threads roots))))))
4100 ;; We then insert this thread into the summary buffer.
4102 (goto-char (point-min))
4103 (forward-line (1- line)))
4104 (let (gnus-newsgroup-data gnus-newsgroup-threads)
4105 (if gnus-show-threads
4106 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
4107 (gnus-summary-prepare-unthreaded thread))
4108 (setq data (nreverse gnus-newsgroup-data))
4109 (setq threads gnus-newsgroup-threads))
4110 ;; We splice the new data into the data structure.
4111 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
4112 ;;!!! then we want to insert at the beginning of the buffer.
4113 ;;!!! That happens to be true with Gnus now, but that may
4114 ;;!!! change in the future. Perhaps.
4115 (gnus-data-enter-list
4116 (if line nil current) data (- (point) old-pos))
4117 (setq gnus-newsgroup-threads
4118 (nconc threads gnus-newsgroup-threads))
4119 (gnus-data-compute-positions))))
4121 (defun gnus-number-to-header (number)
4122 "Return the header for article NUMBER."
4123 (let ((headers gnus-newsgroup-headers))
4125 (not (= number (mail-header-number (car headers)))))
4130 (defun gnus-parent-headers (in-headers &optional generation)
4131 "Return the headers of the GENERATIONeth parent of HEADERS."
4133 (setq generation 1))
4135 (headers in-headers)
4138 (not (zerop generation))
4139 (setq references (mail-header-references headers)))
4140 (setq headers (if (and references
4141 (setq parent (gnus-parent-id references)))
4142 (car (gnus-id-to-thread parent))
4145 (and (not (eq headers in-headers))
4148 (defun gnus-id-to-thread (id)
4149 "Return the (sub-)thread where ID appears."
4150 (gnus-gethash id gnus-newsgroup-dependencies))
4152 (defun gnus-id-to-article (id)
4153 "Return the article number of ID."
4154 (let ((thread (gnus-id-to-thread id)))
4157 (mail-header-number (car thread)))))
4159 (defun gnus-id-to-header (id)
4160 "Return the article headers of ID."
4161 (car (gnus-id-to-thread id)))
4163 (defun gnus-article-displayed-root-p (article)
4164 "Say whether ARTICLE is a root(ish) article."
4165 (let ((level (gnus-summary-thread-level article))
4166 (refs (mail-header-references (gnus-summary-article-header article)))
4172 ((null (gnus-parent-id refs)) t)
4174 (null (setq particle (gnus-id-to-article
4175 (gnus-parent-id refs))))
4176 (null (gnus-summary-thread-level particle)))))))
4178 (defun gnus-root-id (id)
4179 "Return the id of the root of the thread where ID appears."
4181 (while (and id (setq prev (car (gnus-id-to-thread id))))
4183 id (gnus-parent-id (mail-header-references prev))))
4186 (defun gnus-articles-in-thread (thread)
4187 "Return the list of articles in THREAD."
4188 (cons (mail-header-number (car thread))
4189 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
4191 (defun gnus-remove-thread (id &optional dont-remove)
4192 "Remove the thread that has ID in it."
4193 (let (headers thread last-id)
4194 ;; First go up in this thread until we find the root.
4195 (setq last-id (gnus-root-id id)
4196 headers (message-flatten-list (gnus-id-to-thread last-id)))
4197 ;; We have now found the real root of this thread. It might have
4198 ;; been gathered into some loose thread, so we have to search
4199 ;; through the threads to find the thread we wanted.
4200 (let ((threads gnus-newsgroup-threads)
4203 (setq sub (car threads))
4204 (if (stringp (car sub))
4205 ;; This is a gathered thread, so we look at the roots
4206 ;; below it to find whether this article is in this
4209 (setq sub (cdr sub))
4211 (when (member (caar sub) headers)
4212 (setq thread (car threads)
4215 (setq sub (cdr sub))))
4216 ;; It's an ordinary thread, so we check it.
4217 (when (eq (car sub) (car headers))
4220 (setq threads (cdr threads)))
4221 ;; If this article is in no thread, then it's a root.
4224 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
4225 (setq thread (gnus-id-to-thread last-id)))
4228 thread ; We return this thread.
4230 (if (stringp (car thread))
4232 ;; If we use dummy roots, then we have to remove the
4233 ;; dummy root as well.
4234 (when (eq gnus-summary-make-false-root 'dummy)
4235 ;; We go to the dummy root by going to
4236 ;; the first sub-"thread", and then one line up.
4237 (gnus-summary-goto-article
4238 (mail-header-number (caadr thread)))
4241 (gnus-data-compute-positions))
4242 (setq thread (cdr thread))
4244 (gnus-remove-thread-1 (car thread))
4245 (setq thread (cdr thread))))
4246 (gnus-remove-thread-1 thread))))))))
4248 (defun gnus-remove-thread-1 (thread)
4249 "Remove the thread THREAD recursively."
4250 (let ((number (mail-header-number (pop thread)))
4252 (setq thread (reverse thread))
4254 (gnus-remove-thread-1 (pop thread)))
4255 (when (setq d (gnus-data-find number))
4256 (goto-char (gnus-data-pos d))
4257 (gnus-summary-show-thread)
4260 (- (gnus-point-at-bol)
4262 (1+ (gnus-point-at-eol))
4263 (gnus-delete-line)))))))
4265 (defun gnus-sort-threads-1 (threads func)
4266 (sort (mapcar (lambda (thread)
4269 (gnus-sort-threads-1 (cdr thread) func))))
4272 (defun gnus-sort-threads (threads)
4274 (if (not gnus-thread-sort-functions)
4276 (gnus-message 8 "Sorting threads...")
4277 (let ((max-lisp-eval-depth 5000))
4278 (prog1 (gnus-sort-threads-1
4280 (gnus-make-sort-function gnus-thread-sort-functions))
4281 (gnus-message 8 "Sorting threads...done")))))
4283 (defun gnus-sort-articles (articles)
4285 (when gnus-article-sort-functions
4286 (gnus-message 7 "Sorting articles...")
4288 (setq gnus-newsgroup-headers
4289 (sort articles (gnus-make-sort-function
4290 gnus-article-sort-functions)))
4291 (gnus-message 7 "Sorting articles...done"))))
4293 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
4294 (defmacro gnus-thread-header (thread)
4295 "Return header of first article in THREAD.
4296 Note that THREAD must never, ever be anything else than a variable -
4297 using some other form will lead to serious barfage."
4298 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
4299 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
4300 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207"
4303 (defsubst gnus-article-sort-by-number (h1 h2)
4304 "Sort articles by article number."
4305 (< (mail-header-number h1)
4306 (mail-header-number h2)))
4308 (defun gnus-thread-sort-by-number (h1 h2)
4309 "Sort threads by root article number."
4310 (gnus-article-sort-by-number
4311 (gnus-thread-header h1) (gnus-thread-header h2)))
4313 (defsubst gnus-article-sort-by-random (h1 h2)
4314 "Sort articles by article number."
4317 (defun gnus-thread-sort-by-random (h1 h2)
4318 "Sort threads by root article number."
4319 (gnus-article-sort-by-random
4320 (gnus-thread-header h1) (gnus-thread-header h2)))
4322 (defsubst gnus-article-sort-by-lines (h1 h2)
4323 "Sort articles by article Lines header."
4324 (< (mail-header-lines h1)
4325 (mail-header-lines h2)))
4327 (defun gnus-thread-sort-by-lines (h1 h2)
4328 "Sort threads by root article Lines header."
4329 (gnus-article-sort-by-lines
4330 (gnus-thread-header h1) (gnus-thread-header h2)))
4332 (defsubst gnus-article-sort-by-chars (h1 h2)
4333 "Sort articles by octet length."
4334 (< (mail-header-chars h1)
4335 (mail-header-chars h2)))
4337 (defun gnus-thread-sort-by-chars (h1 h2)
4338 "Sort threads by root article octet length."
4339 (gnus-article-sort-by-chars
4340 (gnus-thread-header h1) (gnus-thread-header h2)))
4342 (defsubst gnus-article-sort-by-author (h1 h2)
4343 "Sort articles by root author."
4345 (let ((addr (car (mime-entity-read-field h1 'From))))
4346 (or (std11-full-name-string addr)
4347 (std11-address-string addr)
4349 (let ((addr (car (mime-entity-read-field h2 'From))))
4350 (or (std11-full-name-string addr)
4351 (std11-address-string addr)
4355 (defun gnus-thread-sort-by-author (h1 h2)
4356 "Sort threads by root author."
4357 (gnus-article-sort-by-author
4358 (gnus-thread-header h1) (gnus-thread-header h2)))
4360 (defsubst gnus-article-sort-by-subject (h1 h2)
4361 "Sort articles by root subject."
4363 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
4364 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
4366 (defun gnus-thread-sort-by-subject (h1 h2)
4367 "Sort threads by root subject."
4368 (gnus-article-sort-by-subject
4369 (gnus-thread-header h1) (gnus-thread-header h2)))
4371 (defsubst gnus-article-sort-by-date (h1 h2)
4372 "Sort articles by root article date."
4374 (gnus-date-get-time (mail-header-date h1))
4375 (gnus-date-get-time (mail-header-date h2))))
4377 (defun gnus-thread-sort-by-date (h1 h2)
4378 "Sort threads by root article date."
4379 (gnus-article-sort-by-date
4380 (gnus-thread-header h1) (gnus-thread-header h2)))
4382 (defsubst gnus-article-sort-by-score (h1 h2)
4383 "Sort articles by root article score.
4384 Unscored articles will be counted as having a score of zero."
4385 (> (or (cdr (assq (mail-header-number h1)
4386 gnus-newsgroup-scored))
4387 gnus-summary-default-score 0)
4388 (or (cdr (assq (mail-header-number h2)
4389 gnus-newsgroup-scored))
4390 gnus-summary-default-score 0)))
4392 (defun gnus-thread-sort-by-score (h1 h2)
4393 "Sort threads by root article score."
4394 (gnus-article-sort-by-score
4395 (gnus-thread-header h1) (gnus-thread-header h2)))
4397 (defun gnus-thread-sort-by-total-score (h1 h2)
4398 "Sort threads by the sum of all scores in the thread.
4399 Unscored articles will be counted as having a score of zero."
4400 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
4402 (defun gnus-thread-total-score (thread)
4403 ;; This function find the total score of THREAD.
4408 (if (stringp (car thread))
4409 (apply gnus-thread-score-function 0
4410 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
4411 (gnus-thread-total-score-1 thread)))
4413 (gnus-thread-total-score-1 (list thread)))))
4415 (defun gnus-thread-sort-by-most-recent-number (h1 h2)
4416 "Sort threads such that the thread with the most recently arrived article comes first."
4417 (> (gnus-thread-highest-number h1) (gnus-thread-highest-number h2)))
4419 (defun gnus-thread-highest-number (thread)
4420 "Return the highest article number in THREAD."
4421 (apply 'max (mapcar (lambda (header)
4422 (mail-header-number header))
4423 (message-flatten-list thread))))
4425 (defun gnus-thread-sort-by-most-recent-date (h1 h2)
4426 "Sort threads such that the thread with the most recently dated article comes first."
4427 (> (gnus-thread-latest-date h1) (gnus-thread-latest-date h2)))
4429 (defun gnus-thread-latest-date (thread)
4430 "Return the highest article date in THREAD."
4431 (let ((previous-time 0))
4436 (mail-header-parse-date
4438 (mail-header-date header)
4439 (error previous-time))))))
4441 (message-flatten-list thread)
4443 (< (mail-header-number h1)
4444 (mail-header-number h2))))))))
4446 (defun gnus-thread-total-score-1 (root)
4447 ;; This function find the total score of the thread below ROOT.
4448 (setq root (car root))
4449 (apply gnus-thread-score-function
4451 (mapcar 'gnus-thread-total-score
4452 (cdr (gnus-id-to-thread (mail-header-id root))))
4453 (when (> (mail-header-number root) 0)
4454 (list (or (cdr (assq (mail-header-number root)
4455 gnus-newsgroup-scored))
4456 gnus-summary-default-score 0))))
4457 (list gnus-summary-default-score)
4460 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
4461 (defvar gnus-tmp-prev-subject nil)
4462 (defvar gnus-tmp-false-parent nil)
4463 (defvar gnus-tmp-root-expunged nil)
4464 (defvar gnus-tmp-dummy-line nil)
4466 (eval-when-compile (defvar gnus-tmp-header))
4467 (defun gnus-extra-header (type &optional header)
4468 "Return the extra header of TYPE."
4469 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
4472 (defvar gnus-tmp-thread-tree-header-string "")
4474 (defcustom gnus-sum-thread-tree-root "> "
4475 "With %B spec, used for the root of a thread.
4476 If nil, use subject instead."
4478 :group 'gnus-thread)
4479 (defcustom gnus-sum-thread-tree-single-indent ""
4480 "With %B spec, used for a thread with just one message.
4481 If nil, use subject instead."
4483 :group 'gnus-thread)
4484 (defcustom gnus-sum-thread-tree-vertical "| "
4485 "With %B spec, used for drawing a vertical line."
4487 :group 'gnus-thread)
4488 (defcustom gnus-sum-thread-tree-indent " "
4489 "With %B spec, used for indenting."
4491 :group 'gnus-thread)
4492 (defcustom gnus-sum-thread-tree-leaf-with-other "+-> "
4493 "With %B spec, used for a leaf with brothers."
4495 :group 'gnus-thread)
4496 (defcustom gnus-sum-thread-tree-single-leaf "\\-> "
4497 "With %B spec, used for a leaf without brothers."
4499 :group 'gnus-thread)
4501 (defun gnus-summary-prepare-threads (threads)
4502 "Prepare summary buffer from THREADS and indentation LEVEL.
4503 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
4504 or a straight list of headers."
4505 (gnus-message 7 "Generating summary...")
4507 (setq gnus-newsgroup-threads threads)
4510 (let ((gnus-tmp-level 0)
4511 (default-score (or gnus-summary-default-score 0))
4512 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
4513 thread number subject stack state gnus-tmp-gathered beg-match
4514 new-roots gnus-tmp-new-adopts thread-end simp-subject
4515 gnus-tmp-header gnus-tmp-unread gnus-tmp-downloaded
4516 gnus-tmp-replied gnus-tmp-subject-or-nil
4517 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
4518 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
4519 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket
4522 (setq gnus-tmp-prev-subject nil)
4524 (if (vectorp (car threads))
4525 ;; If this is a straight (sic) list of headers, then a
4526 ;; threaded summary display isn't required, so we just create
4527 ;; an unthreaded one.
4528 (gnus-summary-prepare-unthreaded threads)
4530 ;; Do the threaded display.
4532 (while (or threads stack gnus-tmp-new-adopts new-roots)
4534 (if (and (= gnus-tmp-level 0)
4537 (not gnus-tmp-false-parent)
4538 (or gnus-tmp-new-adopts new-roots))
4539 (if gnus-tmp-new-adopts
4540 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
4541 thread (list (car gnus-tmp-new-adopts))
4542 gnus-tmp-header (caar thread)
4543 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
4545 (setq thread (list (car new-roots))
4546 gnus-tmp-header (caar thread)
4547 new-roots (cdr new-roots))))
4550 ;; If there are some threads, we do them before the
4551 ;; threads on the stack.
4552 (setq thread threads
4553 gnus-tmp-header (caar thread))
4554 ;; There were no current threads, so we pop something off
4556 (setq state (car stack)
4557 gnus-tmp-level (car state)
4558 tree-stack (cadr state)
4559 thread (caddr state)
4561 gnus-tmp-header (caar thread))))
4563 (setq gnus-tmp-false-parent nil)
4564 (setq gnus-tmp-root-expunged nil)
4565 (setq thread-end nil)
4567 (if (stringp gnus-tmp-header)
4568 ;; The header is a dummy root.
4570 ((eq gnus-summary-make-false-root 'adopt)
4571 ;; We let the first article adopt the rest.
4572 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
4574 (setq gnus-tmp-gathered
4576 (lambda (h) (mail-header-number (car h)))
4579 (setq thread (cons (list (caar thread)
4582 (setq gnus-tmp-level -1
4583 gnus-tmp-false-parent t))
4584 ((eq gnus-summary-make-false-root 'empty)
4585 ;; We print adopted articles with empty subject fields.
4586 (setq gnus-tmp-gathered
4588 (lambda (h) (mail-header-number (car h)))
4591 (setq gnus-tmp-level -1))
4592 ((eq gnus-summary-make-false-root 'dummy)
4593 ;; We remember that we probably want to output a dummy
4595 (setq gnus-tmp-dummy-line gnus-tmp-header)
4596 (setq gnus-tmp-prev-subject gnus-tmp-header))
4598 ;; We do not make a root for the gathered
4599 ;; sub-threads at all.
4600 (setq gnus-tmp-level -1)))
4602 (setq number (mail-header-number gnus-tmp-header)
4603 subject (mail-header-subject gnus-tmp-header)
4604 simp-subject (gnus-simplify-subject-fully subject))
4607 ;; If the thread has changed subject, we might want to make
4608 ;; this subthread into a root.
4609 ((and (null gnus-thread-ignore-subject)
4610 (not (zerop gnus-tmp-level))
4611 gnus-tmp-prev-subject
4612 (not (string= gnus-tmp-prev-subject simp-subject)))
4613 (setq new-roots (nconc new-roots (list (car thread)))
4615 gnus-tmp-header nil))
4616 ;; If the article lies outside the current limit,
4617 ;; then we do not display it.
4618 ((not (memq number gnus-newsgroup-limit))
4619 (setq gnus-tmp-gathered
4621 (lambda (h) (mail-header-number (car h)))
4624 (setq gnus-tmp-new-adopts (if (cdar thread)
4625 (append gnus-tmp-new-adopts
4627 gnus-tmp-new-adopts)
4629 gnus-tmp-header nil)
4630 (when (zerop gnus-tmp-level)
4631 (setq gnus-tmp-root-expunged t)))
4632 ;; Perhaps this article is to be marked as read?
4633 ((and gnus-summary-mark-below
4634 (< (or (cdr (assq number gnus-newsgroup-scored))
4636 gnus-summary-mark-below)
4637 ;; Don't touch sparse articles.
4638 (not (gnus-summary-article-sparse-p number))
4639 (not (gnus-summary-article-ancient-p number)))
4640 (setq gnus-newsgroup-unreads
4641 (delq number gnus-newsgroup-unreads))
4642 (if gnus-newsgroup-auto-expire
4643 (setq gnus-newsgroup-expirable
4644 (gnus-add-to-sorted-list
4645 gnus-newsgroup-expirable number))
4646 (push (cons number gnus-low-score-mark)
4647 gnus-newsgroup-reads))))
4649 (when gnus-tmp-header
4650 ;; We may have an old dummy line to output before this
4652 (when (and gnus-tmp-dummy-line
4655 (mail-header-subject gnus-tmp-header)))
4656 (gnus-summary-insert-dummy-line
4657 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
4658 (setq gnus-tmp-dummy-line nil))
4660 ;; Compute the mark.
4661 (setq gnus-tmp-unread (gnus-article-mark number))
4663 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
4664 gnus-tmp-header gnus-tmp-level)
4665 gnus-newsgroup-data)
4667 ;; Actually insert the line.
4669 gnus-tmp-subject-or-nil
4671 ((and gnus-thread-ignore-subject
4672 gnus-tmp-prev-subject
4673 (not (string= gnus-tmp-prev-subject simp-subject)))
4675 ((zerop gnus-tmp-level)
4676 (if (and (eq gnus-summary-make-false-root 'empty)
4677 (memq number gnus-tmp-gathered)
4678 gnus-tmp-prev-subject
4679 (string= gnus-tmp-prev-subject simp-subject))
4680 gnus-summary-same-subject
4682 (t gnus-summary-same-subject)))
4683 (if (and (eq gnus-summary-make-false-root 'adopt)
4684 (= gnus-tmp-level 1)
4685 (memq number gnus-tmp-gathered))
4686 (setq gnus-tmp-opening-bracket ?\<
4687 gnus-tmp-closing-bracket ?\>)
4688 (setq gnus-tmp-opening-bracket ?\[
4689 gnus-tmp-closing-bracket ?\]))
4691 gnus-tmp-indentation
4692 (aref gnus-thread-indent-array gnus-tmp-level)
4693 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
4694 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
4695 gnus-summary-default-score 0)
4697 (if (or (null gnus-summary-default-score)
4698 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
4699 gnus-summary-zcore-fuzz))
4701 (if (< gnus-tmp-score gnus-summary-default-score)
4702 gnus-score-below-mark gnus-score-over-mark))
4704 (cond ((memq number gnus-newsgroup-processable)
4706 ((memq number gnus-newsgroup-cached)
4708 ((memq number gnus-newsgroup-replied)
4710 ((memq number gnus-newsgroup-forwarded)
4711 gnus-forwarded-mark)
4712 ((memq number gnus-newsgroup-saved)
4714 ((memq number gnus-newsgroup-recent)
4716 ((memq number gnus-newsgroup-unseen)
4720 (cond ((memq number gnus-newsgroup-undownloaded)
4721 gnus-undownloaded-mark)
4722 (gnus-newsgroup-agentized
4723 gnus-downloaded-mark)
4726 gnus-tmp-from (mail-header-from gnus-tmp-header)
4729 ((string-match "<[^>]+> *$" gnus-tmp-from)
4730 (setq beg-match (match-beginning 0))
4731 (or (and (string-match "^\".+\"" gnus-tmp-from)
4732 (substring gnus-tmp-from 1 (1- (match-end 0))))
4733 (substring gnus-tmp-from 0 beg-match)))
4734 ((string-match "(.+)" gnus-tmp-from)
4735 (substring gnus-tmp-from
4736 (1+ (match-beginning 0)) (1- (match-end 0))))
4738 gnus-tmp-thread-tree-header-string
4740 ((not gnus-show-threads) "")
4741 ((zerop gnus-tmp-level)
4743 (or gnus-sum-thread-tree-root subject)
4744 (or gnus-sum-thread-tree-single-indent subject)))
4746 (concat (apply 'concat
4747 (mapcar (lambda (item)
4749 gnus-sum-thread-tree-vertical
4750 gnus-sum-thread-tree-indent))
4751 (cdr (reverse tree-stack))))
4753 gnus-sum-thread-tree-leaf-with-other
4754 gnus-sum-thread-tree-single-leaf)))))
4755 (when (string= gnus-tmp-name "")
4756 (setq gnus-tmp-name gnus-tmp-from))
4757 (unless (numberp gnus-tmp-lines)
4758 (setq gnus-tmp-lines -1))
4759 (if (= gnus-tmp-lines -1)
4760 (setq gnus-tmp-lines "?")
4761 (setq gnus-tmp-lines (number-to-string gnus-tmp-lines)))
4762 (gnus-put-text-property
4764 (progn (eval gnus-summary-line-format-spec) (point))
4765 'gnus-number number)
4768 (gnus-run-hooks 'gnus-summary-update-hook)
4771 (setq gnus-tmp-prev-subject simp-subject)))
4773 (when (nth 1 thread)
4774 (push (list (max 0 gnus-tmp-level)
4775 (copy-list tree-stack)
4778 (push (if (nth 1 thread) 1 0) tree-stack)
4779 (incf gnus-tmp-level)
4780 (setq threads (if thread-end nil (cdar thread)))
4782 (setq gnus-tmp-level 0)))))
4783 (gnus-message 7 "Generating summary...done"))
4785 (defun gnus-summary-prepare-unthreaded (headers)
4786 "Generate an unthreaded summary buffer based on HEADERS."
4787 (let (header number mark)
4792 ;; We may have to root out some bad articles...
4793 (when (memq (setq number (mail-header-number
4794 (setq header (pop headers))))
4795 gnus-newsgroup-limit)
4796 ;; Mark article as read when it has a low score.
4797 (when (and gnus-summary-mark-below
4798 (< (or (cdr (assq number gnus-newsgroup-scored))
4799 gnus-summary-default-score 0)
4800 gnus-summary-mark-below)
4801 (not (gnus-summary-article-ancient-p number)))
4802 (setq gnus-newsgroup-unreads
4803 (delq number gnus-newsgroup-unreads))
4804 (if gnus-newsgroup-auto-expire
4805 (push number gnus-newsgroup-expirable)
4806 (push (cons number gnus-low-score-mark)
4807 gnus-newsgroup-reads)))
4809 (setq mark (gnus-article-mark number))
4810 (push (gnus-data-make number mark (1+ (point)) header 0)
4811 gnus-newsgroup-data)
4812 (gnus-summary-insert-line
4814 (memq number gnus-newsgroup-undownloaded)
4815 mark (memq number gnus-newsgroup-replied)
4816 (memq number gnus-newsgroup-expirable)
4817 (mail-header-subject header) nil
4818 (cdr (assq number gnus-newsgroup-scored))
4819 (memq number gnus-newsgroup-processable))))))
4821 (defun gnus-summary-remove-list-identifiers ()
4822 "Remove list identifiers in `gnus-list-identifiers' from articles in the current group."
4823 (let ((regexp (if (consp gnus-list-identifiers)
4824 (mapconcat 'identity gnus-list-identifiers " *\\|")
4825 gnus-list-identifiers))
4828 (dolist (header gnus-newsgroup-headers)
4829 (setq subject (mail-header-subject header)
4831 (while (string-match
4832 (concat "^\\(R[Ee]: +\\)*\\(" regexp " *\\)")
4835 (concat (substring subject 0 (match-beginning 2))
4836 (substring subject (match-end 0)))
4840 "^\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" subject))
4842 (concat (substring subject 0 (match-beginning 1))
4843 (substring subject (match-end 1)))))
4845 (mail-header-set-subject header subject))))))
4847 (defun gnus-fetch-headers (articles)
4848 "Fetch headers of ARTICLES."
4849 (let ((name (gnus-group-decoded-name gnus-newsgroup-name)))
4850 (gnus-message 5 "Fetching headers for %s..." name)
4853 (setq gnus-headers-retrieved-by
4854 (gnus-retrieve-headers
4855 articles gnus-newsgroup-name
4856 ;; We might want to fetch old headers, but
4857 ;; not if there is only 1 article.
4859 (not (eq gnus-fetch-old-headers 'some))
4860 (not (numberp gnus-fetch-old-headers)))
4861 (> (length articles) 1))
4862 gnus-fetch-old-headers))))
4863 (gnus-get-newsgroup-headers-xover
4864 articles nil nil gnus-newsgroup-name t)
4865 (gnus-get-newsgroup-headers))
4866 (gnus-message 5 "Fetching headers for %s...done" name))))
4868 (defun gnus-select-newsgroup (group &optional read-all select-articles)
4869 "Select newsgroup GROUP.
4870 If READ-ALL is non-nil, all articles in the group are selected.
4871 If SELECT-ARTICLES, only select those articles from GROUP."
4872 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4873 ;;!!! Dirty hack; should be removed.
4874 (gnus-summary-ignore-duplicates
4875 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
4877 gnus-summary-ignore-duplicates))
4878 (info (nth 2 entry))
4879 articles fetched-articles cached)
4881 (unless (gnus-check-server
4882 (set (make-local-variable 'gnus-current-select-method)
4883 (gnus-find-method-for-group group)))
4884 (error "Couldn't open server"))
4886 (or (and entry (not (eq (car entry) t))) ; Either it's active...
4887 (gnus-activate-group group) ; Or we can activate it...
4888 (progn ; Or we bug out.
4889 (when (equal major-mode 'gnus-summary-mode)
4890 (kill-buffer (current-buffer)))
4891 (error "Couldn't activate group %s: %s"
4892 group (gnus-status-message group))))
4894 (unless (gnus-request-group group t)
4895 (when (equal major-mode 'gnus-summary-mode)
4896 (kill-buffer (current-buffer)))
4897 (error "Couldn't request group %s: %s"
4898 group (gnus-status-message group)))
4900 (setq gnus-newsgroup-name group
4901 gnus-newsgroup-unselected nil
4902 gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
4904 (let ((display (gnus-group-find-parameter group 'display)))
4905 (setq gnus-newsgroup-display
4907 ((not (zerop (or (car-safe read-all) 0)))
4908 ;; The user entered the group with C-u SPC/RET, let's show
4914 (gnus-summary-display-make-predicate (mapcar 'identity display)))
4916 ;; The following is probably the "correct" solution, but
4917 ;; it makes Gnus fetch all headers and then limit the
4918 ;; articles (which is slow), so instead we hack the
4919 ;; select-articles parameter instead. -- Simon Josefsson
4922 ;; (gnus-byte-compile
4923 ;; `(lambda () (> number ,(- (cdr (gnus-active group))
4925 (setq select-articles
4926 (gnus-uncompress-range
4927 (cons (let ((tmp (- (cdr (gnus-active group)) display)))
4931 (cdr (gnus-active group)))))
4936 (gnus-summary-setup-default-charset)
4938 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4939 (when (gnus-virtual-group-p group)
4940 (setq cached gnus-newsgroup-cached))
4942 (setq gnus-newsgroup-unreads
4943 (gnus-sorted-ndifference
4944 (gnus-sorted-ndifference gnus-newsgroup-unreads
4945 gnus-newsgroup-marked)
4946 gnus-newsgroup-dormant))
4948 (setq gnus-newsgroup-processable nil)
4950 (gnus-update-read-articles group gnus-newsgroup-unreads)
4952 ;; Adjust and set lists of article marks.
4954 (gnus-adjust-marked-articles info))
4955 (if (setq articles select-articles)
4956 (setq gnus-newsgroup-unselected
4957 (gnus-sorted-difference gnus-newsgroup-unreads articles))
4958 (setq articles (gnus-articles-to-read group read-all)))
4962 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
4964 ((eq articles 0) nil)
4966 ;; Init the dependencies hash table.
4967 (setq gnus-newsgroup-dependencies
4968 (gnus-make-hashtable (length articles)))
4969 (gnus-set-global-variables)
4970 ;; Retrieve the headers and read them in.
4972 (setq gnus-newsgroup-headers (gnus-fetch-headers articles))
4974 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4976 (setq gnus-newsgroup-cached cached))
4978 ;; Suppress duplicates?
4979 (when gnus-suppress-duplicates
4980 (gnus-dup-suppress-articles))
4982 ;; Set the initial limit.
4983 (setq gnus-newsgroup-limit (copy-sequence articles))
4984 ;; Remove canceled articles from the list of unread articles.
4985 (setq fetched-articles
4986 (mapcar (lambda (headers) (mail-header-number headers))
4987 gnus-newsgroup-headers))
4988 (setq gnus-newsgroup-articles fetched-articles)
4989 (setq gnus-newsgroup-unreads
4990 (gnus-sorted-nintersection
4991 gnus-newsgroup-unreads fetched-articles))
4992 (gnus-compute-unseen-list)
4994 ;; Removed marked articles that do not exist.
4995 (gnus-update-missing-marks
4996 (gnus-sorted-difference articles fetched-articles))
4997 ;; We might want to build some more threads first.
4998 (when (and gnus-fetch-old-headers
4999 (eq gnus-headers-retrieved-by 'nov))
5000 (if (eq gnus-fetch-old-headers 'invisible)
5001 (gnus-build-all-threads)
5002 (gnus-build-old-threads)))
5003 ;; Let the Gnus agent mark articles as read.
5005 (gnus-agent-get-undownloaded-list))
5006 ;; Remove list identifiers from subject
5007 (when gnus-list-identifiers
5008 (gnus-summary-remove-list-identifiers))
5009 ;; Check whether auto-expire is to be done in this group.
5010 (setq gnus-newsgroup-auto-expire
5011 (gnus-group-auto-expirable-p group))
5012 ;; Set up the article buffer now, if necessary.
5013 (unless gnus-single-article-buffer
5014 (gnus-article-setup-buffer))
5015 ;; First and last article in this newsgroup.
5016 (when gnus-newsgroup-headers
5017 (setq gnus-newsgroup-begin
5018 (mail-header-number (car gnus-newsgroup-headers))
5021 (gnus-last-element gnus-newsgroup-headers))))
5022 ;; GROUP is successfully selected.
5023 (or gnus-newsgroup-headers t)))))
5025 (defun gnus-compute-unseen-list ()
5026 ;; The `seen' marks are treated specially.
5027 (if (not gnus-newsgroup-seen)
5028 (setq gnus-newsgroup-unseen gnus-newsgroup-articles)
5029 (setq gnus-newsgroup-unseen
5030 (gnus-inverse-list-range-intersection
5031 gnus-newsgroup-articles gnus-newsgroup-seen))))
5033 (defun gnus-summary-display-make-predicate (display)
5034 (require 'gnus-agent)
5035 (when (= (length display) 1)
5036 (setq display (car display)))
5037 (unless gnus-summary-display-cache
5038 (dolist (elem (append '((unread . unread)
5041 gnus-article-mark-lists))
5042 (push (cons (cdr elem)
5044 `(lambda () (gnus-article-marked-p ',(cdr elem)))))
5045 gnus-summary-display-cache)))
5046 (let ((gnus-category-predicate-alist gnus-summary-display-cache)
5047 (gnus-category-predicate-cache gnus-summary-display-cache))
5048 (gnus-get-predicate display)))
5050 ;; Uses the dynamically bound `number' variable.
5053 (defun gnus-article-marked-p (type &optional article)
5054 (let ((article (or article number)))
5057 (memq article gnus-newsgroup-marked))
5059 (memq article gnus-newsgroup-spam-marked))
5061 (memq article gnus-newsgroup-unsendable))
5062 ((eq type 'undownload)
5063 (memq article gnus-newsgroup-undownloaded))
5064 ((eq type 'download)
5065 (memq article gnus-newsgroup-downloadable))
5067 (memq article gnus-newsgroup-unreads))
5069 (memq article gnus-newsgroup-reads))
5071 (memq article gnus-newsgroup-dormant) )
5073 (memq article gnus-newsgroup-expirable))
5075 (memq article gnus-newsgroup-replied))
5077 (memq article gnus-newsgroup-killed))
5078 ((eq type 'bookmark)
5079 (assq article gnus-newsgroup-bookmarks))
5081 (assq article gnus-newsgroup-scored))
5083 (memq article gnus-newsgroup-saved))
5085 (memq article gnus-newsgroup-cached))
5087 (memq article gnus-newsgroup-forwarded))
5089 (not (memq article gnus-newsgroup-unseen)))
5091 (memq article gnus-newsgroup-recent))
5094 (defun gnus-articles-to-read (group &optional read-all)
5095 "Find out what articles the user wants to read."
5097 ;; Select all articles if `read-all' is non-nil, or if there
5098 ;; are no unread articles.
5100 (and (zerop (length gnus-newsgroup-marked))
5101 (zerop (length gnus-newsgroup-unreads)))
5102 ;; Fetch all if the predicate is non-nil.
5103 gnus-newsgroup-display)
5104 ;; We want to select the headers for all the articles in
5105 ;; the group, so we select either all the active
5106 ;; articles in the group, or (if that's nil), the
5107 ;; articles in the cache.
5109 (gnus-uncompress-range (gnus-active group))
5110 (gnus-cache-articles-in-group group))
5111 ;; Select only the "normal" subset of articles.
5113 (gnus-sorted-union gnus-newsgroup-dormant gnus-newsgroup-marked)
5114 gnus-newsgroup-unreads)))
5115 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
5116 (scored (length scored-list))
5117 (number (length articles))
5118 (marked (+ (length gnus-newsgroup-marked)
5119 (length gnus-newsgroup-dormant)))
5124 ((numberp gnus-newsgroup-display)
5125 gnus-newsgroup-display)
5129 ((and (or (<= scored marked) (= scored number))
5130 (numberp gnus-large-newsgroup)
5131 (> number gnus-large-newsgroup))
5132 (let* ((cursor-in-echo-area nil)
5133 (initial (gnus-parameter-large-newsgroup-initial
5134 gnus-newsgroup-name))
5138 "How many articles from %s (%s %d): "
5140 (gnus-group-decoded-name gnus-newsgroup-name)
5142 (if initial "max" "default")
5145 (cons (number-to-string initial)
5147 (if (string-match "^[ \t]*$" input) number input)))
5148 ((and (> scored marked) (< scored number)
5149 (> (- scored number) 20))
5152 (format "%s %s (%d scored, %d total): "
5153 "How many articles from"
5154 (gnus-group-decoded-name group)
5156 (if (string-match "^[ \t]*$" input)
5160 (message "Quit getting the articles to read")
5162 (setq select (if (stringp select) (string-to-number select) select))
5163 (if (or (null select) (zerop select))
5165 (if (and (not (zerop scored)) (<= (abs select) scored))
5167 (setq articles (sort scored-list '<))
5168 (setq number (length articles)))
5169 (setq articles (copy-sequence articles)))
5171 (when (< (abs select) number)
5173 ;; Select the N oldest articles.
5174 (setcdr (nthcdr (1- (abs select)) articles) nil)
5175 ;; Select the N most recent articles.
5176 (setq articles (nthcdr (- number select) articles))))
5177 (setq gnus-newsgroup-unselected
5178 (gnus-sorted-difference gnus-newsgroup-unreads articles))
5179 (when gnus-alter-articles-to-read-function
5180 (setq gnus-newsgroup-unreads
5182 (funcall gnus-alter-articles-to-read-function
5183 gnus-newsgroup-name gnus-newsgroup-unreads)
5187 (defun gnus-killed-articles (killed articles)
5190 (when (inline (gnus-member-of-range (car articles) killed))
5191 (push (car articles) out))
5192 (setq articles (cdr articles)))
5195 (defun gnus-uncompress-marks (marks)
5196 "Uncompress the mark ranges in MARKS."
5197 (let ((uncompressed '(score bookmark))
5200 (if (memq (caar marks) uncompressed)
5201 (push (car marks) out)
5202 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
5203 (setq marks (cdr marks)))
5206 (defun gnus-article-mark-to-type (mark)
5207 "Return the type of MARK."
5208 (or (cadr (assq mark gnus-article-special-mark-lists))
5211 (defun gnus-article-unpropagatable-p (mark)
5212 "Return whether MARK should be propagated to backend."
5213 (memq mark gnus-article-unpropagated-mark-lists))
5215 (defun gnus-adjust-marked-articles (info)
5216 "Set all article lists and remove all marks that are no longer valid."
5217 (let* ((marked-lists (gnus-info-marks info))
5218 (active (gnus-active (gnus-info-group info)))
5221 (types gnus-article-mark-lists)
5222 marks var articles article mark mark-type)
5224 (dolist (marks marked-lists)
5225 (setq mark (car marks)
5226 mark-type (gnus-article-mark-to-type mark)
5227 var (intern (format "gnus-newsgroup-%s" (car (rassq mark types)))))
5229 ;; We set the variable according to the type of the marks list,
5230 ;; and then adjust the marks to a subset of the active articles.
5232 ;; Adjust "simple" lists.
5233 ((eq mark-type 'list)
5234 (set var (setq articles (gnus-uncompress-range (cdr marks))))
5235 (when (memq mark '(tick dormant expire reply save))
5237 (when (or (< (setq article (pop articles)) min) (> article max))
5238 (set var (delq article (symbol-value var)))))))
5240 ((eq mark-type 'tuple)
5241 (set var (setq articles (cdr marks)))
5242 (when (not (listp (cdr (symbol-value var))))
5243 (set var (list (symbol-value var))))
5244 (when (not (listp (cdr articles)))
5245 (setq articles (list articles)))
5247 (when (or (not (consp (setq article (pop articles))))
5248 (< (car article) min)
5249 (> (car article) max))
5250 (set var (delq article (symbol-value var))))))
5251 ;; Adjust ranges (sloppily).
5252 ((eq mark-type 'range)
5255 ;; Fix the record for `seen' if it looks like (seen NUM1 . NUM2).
5256 ;; It should be (seen (NUM1 . NUM2)).
5257 (when (numberp (cddr marks))
5258 (setcdr marks (list (cdr marks))))
5259 (setq articles (cdr marks))
5260 (while (and articles
5261 (or (and (consp (car articles))
5262 (> min (cdar articles)))
5263 (and (numberp (car articles))
5264 (> min (car articles)))))
5266 (set var articles))))))))
5268 (defun gnus-update-missing-marks (missing)
5269 "Go through the list of MISSING articles and remove them from the mark lists."
5272 ;; Go through all types.
5273 (dolist (elem gnus-article-mark-lists)
5274 (when (eq (gnus-article-mark-to-type (cdr elem)) 'list)
5275 (setq var (intern (format "gnus-newsgroup-%s" (car elem))))
5276 (when (symbol-value var)
5277 ;; This list has articles. So we delete all missing
5278 ;; articles from it.
5281 (set var (delq (pop m) (symbol-value var))))))))))
5283 (defun gnus-update-marks ()
5284 "Enter the various lists of marked articles into the newsgroup info list."
5285 (let ((types gnus-article-mark-lists)
5286 (info (gnus-get-info gnus-newsgroup-name))
5287 type list newmarked symbol delta-marks)
5289 ;; Add all marks lists to the list of marks lists.
5290 (while (setq type (pop types))
5291 (setq list (symbol-value
5293 (intern (format "gnus-newsgroup-%s" (car type))))))
5296 ;; Get rid of the entries of the articles that have the
5298 (when (and (eq (cdr type) 'score)
5302 (prev (cons nil list))
5305 (if (or (not (consp (car arts)))
5306 (= (cdar arts) gnus-summary-default-score))
5307 (setcdr prev (cdr arts))
5309 (setq arts (cdr arts)))
5310 (setq list (cdr all)))))
5312 (when (eq (cdr type) 'seen)
5313 (setq list (gnus-range-add list gnus-newsgroup-unseen)))
5315 (when (eq (gnus-article-mark-to-type (cdr type)) 'list)
5316 (setq list (gnus-compress-sequence (set symbol (sort list '<)) t)))
5318 (when (and (gnus-check-backend-function
5319 'request-set-mark gnus-newsgroup-name)
5320 (not (gnus-article-unpropagatable-p (cdr type))))
5321 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
5322 (del (gnus-remove-from-range (gnus-copy-sequence old) list))
5323 (add (gnus-remove-from-range
5324 (gnus-copy-sequence list) old)))
5326 (push (list add 'add (list (cdr type))) delta-marks))
5328 (push (list del 'del (list (cdr type))) delta-marks))))
5331 (push (cons (cdr type) list) newmarked)))
5334 (unless (gnus-check-group gnus-newsgroup-name)
5335 (error "Can't open server for %s" gnus-newsgroup-name))
5336 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
5338 ;; Enter these new marks into the info of the group.
5340 (setcar (nthcdr 3 info) newmarked)
5341 ;; Add the marks lists to the end of the info.
5343 (setcdr (nthcdr 2 info) (list newmarked))))
5345 ;; Cut off the end of the info if there's nothing else there.
5349 (when (nthcdr (decf i) info)
5350 (setcdr (nthcdr i info) nil)))))))
5352 (defun gnus-set-mode-line (where)
5353 "Set the mode line of the article or summary buffers.
5354 If WHERE is `summary', the summary mode line format will be used."
5355 ;; Is this mode line one we keep updated?
5356 (when (and (memq where gnus-updated-mode-lines)
5358 (intern (format "gnus-%s-mode-line-format-spec" where))))
5361 ;; We evaluate this in the summary buffer since these
5362 ;; variables are buffer-local to that buffer.
5363 (set-buffer gnus-summary-buffer)
5364 ;; We bind all these variables that are used in the `eval' form
5366 (let* ((mformat (symbol-value
5368 (format "gnus-%s-mode-line-format-spec" where))))
5369 (gnus-tmp-group-name (gnus-group-decoded-name
5370 gnus-newsgroup-name))
5371 (gnus-tmp-article-number (or gnus-current-article 0))
5372 (gnus-tmp-unread gnus-newsgroup-unreads)
5373 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
5374 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
5375 (gnus-tmp-unread-and-unselected
5376 (cond ((and (zerop gnus-tmp-unread-and-unticked)
5377 (zerop gnus-tmp-unselected))
5379 ((zerop gnus-tmp-unselected)
5380 (format "{%d more}" gnus-tmp-unread-and-unticked))
5381 (t (format "{%d(+%d) more}"
5382 gnus-tmp-unread-and-unticked
5383 gnus-tmp-unselected))))
5385 (if (and gnus-current-headers
5386 (vectorp gnus-current-headers))
5387 (gnus-mode-string-quote
5388 (mail-header-subject gnus-current-headers))
5390 bufname-length max-len
5391 gnus-tmp-header);; passed as argument to any user-format-funcs
5392 (setq mode-string (eval mformat))
5393 (setq bufname-length (if (string-match "%b" mode-string)
5396 (if (eq where 'summary)
5398 (get-buffer gnus-article-buffer))))
5401 (setq max-len (max 4 (if gnus-mode-non-string-length
5403 gnus-mode-non-string-length
5405 (length mode-string))))
5406 ;; We might have to chop a bit of the string off...
5407 (when (> (length mode-string) max-len)
5409 (concat (gnus-truncate-string mode-string (- max-len 3))
5411 ;; Pad the mode string a bit.
5412 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
5413 ;; Update the mode line.
5414 (setq mode-line-buffer-identification
5415 (gnus-mode-line-buffer-identification (list mode-string)))
5416 (set-buffer-modified-p t))))
5418 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
5419 "Go through the HEADERS list and add all Xrefs to a hash table.
5420 The resulting hash table is returned, or nil if no Xrefs were found."
5421 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
5422 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
5423 (xref-hashtb (gnus-make-hashtable))
5424 start group entry number xrefs header)
5426 (setq header (pop headers))
5427 (when (and (setq xrefs (mail-header-xref header))
5428 (not (memq (setq number (mail-header-number header))
5431 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
5432 (setq start (match-end 0))
5433 (setq group (if prefix
5434 (concat prefix (substring xrefs (match-beginning 1)
5436 (substring xrefs (match-beginning 1) (match-end 1))))
5438 (string-to-int (substring xrefs (match-beginning 2)
5440 (if (setq entry (gnus-gethash group xref-hashtb))
5441 (setcdr entry (cons number (cdr entry)))
5442 (gnus-sethash group (cons number nil) xref-hashtb)))))
5443 (and start xref-hashtb)))
5445 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
5446 "Look through all the headers and mark the Xrefs as read."
5447 (let ((virtual (gnus-virtual-group-p from-newsgroup))
5448 name entry info xref-hashtb idlist method nth4)
5450 (set-buffer gnus-group-buffer)
5451 (when (setq xref-hashtb
5452 (gnus-create-xref-hashtb from-newsgroup headers unreads))
5455 (unless (string= from-newsgroup (setq name (symbol-name group)))
5456 (setq idlist (symbol-value group))
5457 ;; Dead groups are not updated.
5459 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
5461 (when (stringp (setq nth4 (gnus-info-method info)))
5462 (setq nth4 (gnus-server-to-method nth4))))
5463 ;; Only do the xrefs if the group has the same
5464 ;; select method as the group we have just read.
5465 (or (gnus-methods-equal-p
5466 nth4 (gnus-find-method-for-group from-newsgroup))
5468 (equal nth4 (setq method (gnus-find-method-for-group
5470 (and (equal (car nth4) (car method))
5471 (equal (nth 1 nth4) (nth 1 method))))
5472 gnus-use-cross-reference
5473 (or (not (eq gnus-use-cross-reference t))
5475 ;; Only do cross-references on subscribed
5476 ;; groups, if that is what is wanted.
5477 (<= (gnus-info-level info) gnus-level-subscribed))
5478 (gnus-group-make-articles-read name idlist))))
5481 (defun gnus-compute-read-articles (group articles)
5482 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
5483 (info (nth 2 entry))
5484 (active (gnus-active group))
5487 ;; First peel off all invalid article numbers.
5489 (let ((ids articles)
5491 (while (setq id (pop ids))
5492 (when (and first (> id (cdr active)))
5493 ;; We'll end up in this situation in one particular
5494 ;; obscure situation. If you re-scan a group and get
5495 ;; a new article that is cross-posted to a different
5496 ;; group that has not been re-scanned, you might get
5497 ;; crossposted article that has a higher number than
5498 ;; Gnus believes possible. So we re-activate this
5499 ;; group as well. This might mean doing the
5500 ;; crossposting thingy will *increase* the number
5501 ;; of articles in some groups. Tsk, tsk.
5502 (setq active (or (gnus-activate-group group) active)))
5503 (when (or (> id (cdr active))
5504 (< id (car active)))
5505 (setq articles (delq id articles))))))
5506 ;; If the read list is nil, we init it.
5508 (null (gnus-info-read info))
5510 (setq ninfo (cons 1 (1- (car active))))
5511 (setq ninfo (gnus-info-read info)))
5512 ;; Then we add the read articles to the range.
5514 ninfo (setq articles (sort articles '<))))))
5516 (defun gnus-group-make-articles-read (group articles)
5517 "Update the info of GROUP to say that ARTICLES are read."
5519 (entry (gnus-gethash group gnus-newsrc-hashtb))
5520 (info (nth 2 entry))
5521 (active (gnus-active group))
5524 (setq range (gnus-compute-read-articles group articles))
5526 (set-buffer gnus-group-buffer)
5529 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
5530 (gnus-info-set-read ',info ',(gnus-info-read info))
5531 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
5532 (gnus-request-set-mark ,group (list (list ',range 'del '(read))))
5533 (gnus-group-update-group ,group t))))
5534 ;; Add the read articles to the range.
5535 (gnus-info-set-read info range)
5536 (gnus-request-set-mark group (list (list range 'add '(read))))
5537 ;; Then we have to re-compute how many unread
5538 ;; articles there are in this group.
5542 (setq num (- (1+ (cdr active)) (car active))))
5543 ((not (listp (cdr range)))
5544 (setq num (- (cdr active) (- (1+ (cdr range))
5548 (if (numberp (car range))
5550 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
5551 (setq range (cdr range)))
5552 (setq num (- (cdr active) num))))
5553 ;; Update the number of unread articles.
5555 ;; Update the group buffer.
5556 (gnus-group-update-group group t)))))
5558 (defvar gnus-newsgroup-none-id 0)
5560 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
5561 (let ((cur nntp-server-buffer)
5564 (save-excursion (set-buffer gnus-summary-buffer)
5565 gnus-newsgroup-dependencies)))
5567 (mail-parse-charset gnus-newsgroup-charset)
5568 (mail-parse-ignored-charsets
5569 (save-excursion (condition-case nil
5570 (set-buffer gnus-summary-buffer)
5572 gnus-newsgroup-ignored-charsets)))
5574 (set-buffer nntp-server-buffer)
5575 ;; Translate all TAB characters into SPACE characters.
5576 (subst-char-in-region (point-min) (point-max) ?\t ? t)
5577 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5578 (gnus-run-hooks 'gnus-parse-headers-hook)
5579 (let ((case-fold-search t)
5580 in-reply-to header p lines chars ctype)
5581 (goto-char (point-min))
5582 ;; Search to the beginning of the next header. Error messages
5583 ;; do not begin with 2 or 3.
5584 (while (re-search-forward "^[23][0-9]+ " nil t)
5587 ;; This implementation of this function, with nine
5588 ;; search-forwards instead of the one re-search-forward and
5589 ;; a case (which basically was the old function) is actually
5590 ;; about twice as fast, even though it looks messier. You
5591 ;; can't have everything, I guess. Speed and elegance
5592 ;; doesn't always go hand in hand.
5595 (make-full-mail-header
5601 (narrow-to-region (point)
5602 (or (and (search-forward "\n.\n" nil t)
5608 (if (search-forward "\nsubject:" nil t)
5609 (nnheader-header-value)
5614 (if (search-forward "\nfrom:" nil t)
5615 (nnheader-header-value)
5620 (if (search-forward "\ndate:" nil t)
5621 (nnheader-header-value) ""))
5625 (setq id (if (re-search-forward
5626 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
5627 ;; We do it this way to make sure the Message-ID
5628 ;; is (somewhat) syntactically valid.
5629 (buffer-substring (match-beginning 1)
5631 ;; If there was no message-id, we just fake one
5632 ;; to make subsequent routines simpler.
5633 (nnheader-generate-fake-message-id))))
5637 (if (search-forward "\nreferences:" nil t)
5641 (nnheader-header-value)
5646 (search-backward ">" end t)
5649 (search-backward "<" end t)
5651 ;; Get the references from the in-reply-to header if there
5652 ;; were no references and the in-reply-to header looks
5654 (if (and (search-forward "\nin-reply-to:" nil t)
5655 (setq in-reply-to (nnheader-header-value))
5656 (string-match "<[^>]+>" in-reply-to))
5658 (setq ref (substring in-reply-to (match-beginning 0)
5660 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
5661 (setq ref2 (substring in-reply-to (match-beginning 0)
5663 (when (> (length ref2) (length ref))
5670 (if (search-forward "\nchars: " nil t)
5671 (if (numberp (setq chars (ignore-errors (read cur))))
5677 (if (search-forward "\nlines: " nil t)
5678 (if (numberp (setq lines (ignore-errors (read cur))))
5684 (and (search-forward "\nxref:" nil t)
5685 (nnheader-header-value)))
5687 (when gnus-extra-headers
5688 (let ((extra gnus-extra-headers)
5692 (when (search-forward
5693 (concat "\n" (symbol-name (car extra)) ":") nil t)
5694 (push (cons (car extra) (nnheader-header-value)) out))
5698 (if (and (search-forward "\ncontent-type: " nil t)
5699 (setq ctype (nnheader-header-value)))
5700 (mime-entity-set-content-type-internal
5701 header (mime-parse-Content-Type ctype)))
5702 (when (equal id ref)
5705 (when gnus-alter-header-function
5706 (funcall gnus-alter-header-function header)
5707 (setq id (mail-header-id header)
5708 ref (gnus-parent-id (mail-header-references header))))
5711 (gnus-dependencies-add-header
5712 header dependencies force-new))
5713 (push header headers))
5714 (goto-char (point-max))
5716 (nreverse headers)))))
5718 ;; Goes through the xover lines and returns a list of vectors
5719 (defun gnus-get-newsgroup-headers-xover (sequence &optional
5720 force-new dependencies
5721 group also-fetch-heads)
5722 "Parse the news overview data in the server buffer.
5723 Return a list of headers that match SEQUENCE (see
5724 `nntp-retrieve-headers')."
5725 ;; Get the Xref when the users reads the articles since most/some
5726 ;; NNTP servers do not include Xrefs when using XOVER.
5727 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
5728 (let ((mail-parse-charset gnus-newsgroup-charset)
5729 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5730 (cur nntp-server-buffer)
5731 (dependencies (or dependencies gnus-newsgroup-dependencies))
5733 ((eq gnus-read-all-available-headers t)
5735 ((stringp gnus-read-all-available-headers)
5736 (string-match gnus-read-all-available-headers group))
5739 number headers header)
5741 (set-buffer nntp-server-buffer)
5742 (subst-char-in-region (point-min) (point-max) ?\r ? t)
5743 ;; Allow the user to mangle the headers before parsing them.
5744 (gnus-run-hooks 'gnus-parse-headers-hook)
5745 (goto-char (point-min))
5746 (gnus-parse-without-error
5747 (while (and (or sequence allp)
5749 (setq number (read cur))
5751 (while (and sequence
5752 (< (car sequence) number))
5753 (setq sequence (cdr sequence))))
5756 (eq number (car sequence))))
5758 (setq sequence (cdr sequence))
5759 (setq header (inline
5760 (gnus-nov-parse-line
5761 number dependencies force-new)))))
5762 (push header headers))
5764 ;; A common bug in inn is that if you have posted an article and
5765 ;; then retrieves the active file, it will answer correctly --
5766 ;; the new article is included. However, a NOV entry for the
5767 ;; article may not have been generated yet, so this may fail.
5768 ;; We work around this problem by retrieving the last few
5769 ;; headers using HEAD.
5770 (if (or (not also-fetch-heads)
5772 ;; We (probably) got all the headers.
5774 (let ((gnus-nov-is-evil t))
5777 (when (eq (gnus-retrieve-headers sequence group) 'headers)
5778 (gnus-get-newsgroup-headers))))))))
5780 (defun gnus-article-get-xrefs ()
5781 "Fill in the Xref value in `gnus-current-headers', if necessary.
5782 This is meant to be called in `gnus-article-internal-prepare-hook'."
5783 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
5784 gnus-current-headers)))
5785 (or (not gnus-use-cross-reference)
5787 (and (mail-header-xref headers)
5788 (not (string= (mail-header-xref headers) "")))
5789 (let ((case-fold-search t)
5792 (nnheader-narrow-to-headers)
5793 (goto-char (point-min))
5794 (when (or (and (not (eobp))
5795 (eq (downcase (char-after)) ?x)
5796 (looking-at "Xref:"))
5797 (search-forward "\nXref:" nil t))
5798 (goto-char (1+ (match-end 0)))
5799 (setq xref (buffer-substring (point)
5800 (progn (end-of-line) (point))))
5801 (mail-header-set-xref headers xref)))))))
5803 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
5804 "Find article ID and insert the summary line for that article.
5805 OLD-HEADER can either be a header or a line number to insert
5806 the subject line on."
5807 (let* ((line (and (numberp old-header) old-header))
5808 (old-header (and (vectorp old-header) old-header))
5809 (header (cond ((and old-header use-old-header)
5812 (gnus-number-to-header id))
5813 (gnus-number-to-header id))
5815 (gnus-read-header id))))
5816 (number (and (numberp id) id))
5819 ;; Rebuild the thread that this article is part of and go to the
5820 ;; article we have fetched.
5821 (when (and (not gnus-show-threads)
5824 (setq d (gnus-data-find (mail-header-number old-header))))
5825 (goto-char (gnus-data-pos d))
5828 (- (gnus-point-at-bol)
5830 (1+ (gnus-point-at-eol))
5831 (gnus-delete-line))))))
5833 (mail-header-set-number header (mail-header-number old-header)))
5834 (setq gnus-newsgroup-sparse
5835 (delq (setq number (mail-header-number header))
5836 gnus-newsgroup-sparse))
5837 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
5838 (push number gnus-newsgroup-limit)
5839 (gnus-rebuild-thread (mail-header-id header) line)
5840 (gnus-summary-goto-subject number nil t))
5841 (when (and (numberp number)
5843 ;; We have to update the boundaries even if we can't fetch the
5844 ;; article if ID is a number -- so that the next `P' or `N'
5845 ;; command will fetch the previous (or next) article even
5846 ;; if the one we tried to fetch this time has been canceled.
5847 (when (> number gnus-newsgroup-end)
5848 (setq gnus-newsgroup-end number))
5849 (when (< number gnus-newsgroup-begin)
5850 (setq gnus-newsgroup-begin number))
5851 (setq gnus-newsgroup-unselected
5852 (delq number gnus-newsgroup-unselected)))
5853 ;; Report back a success?
5854 (and header (mail-header-number header))))
5856 ;;; Process/prefix in the summary buffer
5858 (defun gnus-summary-work-articles (n)
5859 "Return a list of articles to be worked upon.
5860 The prefix argument, the list of process marked articles, and the
5861 current article will be taken into consideration."
5863 (set-buffer gnus-summary-buffer)
5866 ;; A numerical prefix has been given.
5867 (setq n (prefix-numeric-value n))
5868 (let ((backward (< n 0))
5869 (n (abs (prefix-numeric-value n)))
5874 (push (setq article (gnus-summary-article-number))
5877 (gnus-summary-find-prev nil article)
5878 (gnus-summary-find-next nil article)))
5880 (nreverse articles)))
5881 ((and (gnus-region-active-p) (mark))
5882 (message "region active")
5883 ;; Work on the region between point and mark.
5884 (let ((max (max (point) (mark)))
5887 (goto-char (min (point) (mark)))
5890 (push (setq article (gnus-summary-article-number)) articles)
5891 (gnus-summary-find-next nil article)
5893 (nreverse articles))))
5894 (gnus-newsgroup-processable
5895 ;; There are process-marked articles present.
5896 ;; Save current state.
5897 (gnus-summary-save-process-mark)
5899 (reverse gnus-newsgroup-processable))
5901 ;; Just return the current article.
5902 (list (gnus-summary-article-number))))))
5904 (defmacro gnus-summary-iterate (arg &rest forms)
5905 "Iterate over the process/prefixed articles and do FORMS.
5906 ARG is the interactive prefix given to the command. FORMS will be
5907 executed with point over the summary line of the articles."
5908 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
5909 `(let ((,articles (gnus-summary-work-articles ,arg)))
5911 (gnus-summary-goto-subject (car ,articles))
5915 (put 'gnus-summary-iterate 'lisp-indent-function 1)
5916 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
5918 (defun gnus-summary-save-process-mark ()
5919 "Push the current set of process marked articles on the stack."
5921 (push (copy-sequence gnus-newsgroup-processable)
5922 gnus-newsgroup-process-stack))
5924 (defun gnus-summary-kill-process-mark ()
5925 "Push the current set of process marked articles on the stack and unmark."
5927 (gnus-summary-save-process-mark)
5928 (gnus-summary-unmark-all-processable))
5930 (defun gnus-summary-yank-process-mark ()
5931 "Pop the last process mark state off the stack and restore it."
5933 (unless gnus-newsgroup-process-stack
5934 (error "Empty mark stack"))
5935 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
5937 (defun gnus-summary-process-mark-set (set)
5938 "Make SET into the current process marked articles."
5939 (gnus-summary-unmark-all-processable)
5941 (gnus-summary-set-process-mark (pop set))))
5943 ;;; Searching and stuff
5945 (defun gnus-summary-search-group (&optional backward use-level)
5946 "Search for next unread newsgroup.
5947 If optional argument BACKWARD is non-nil, search backward instead."
5949 (set-buffer gnus-group-buffer)
5950 (when (gnus-group-search-forward
5951 backward nil (if use-level (gnus-group-group-level) nil))
5952 (gnus-group-group-name))))
5954 (defun gnus-summary-best-group (&optional exclude-group)
5955 "Find the name of the best unread group.
5956 If EXCLUDE-GROUP, do not go to this group."
5958 (set-buffer gnus-group-buffer)
5960 (gnus-group-best-unread-group exclude-group))))
5962 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
5963 (if backward (gnus-summary-find-prev)
5964 (let* ((dummy (gnus-summary-article-intangible-p))
5965 (article (or article (gnus-summary-article-number)))
5966 (arts (gnus-data-find-list article))
5968 (when (and (not dummy)
5969 (or (not gnus-summary-check-current)
5971 (not (gnus-data-unread-p (car arts)))))
5972 (setq arts (cdr arts)))
5977 (when (or (and undownloaded
5978 (memq (car arts) gnus-newsgroup-undownloaded))
5979 (gnus-data-unread-p (car arts)))
5980 (setq result (car arts)
5982 (setq arts (cdr arts)))
5985 (goto-char (gnus-data-pos result))
5986 (gnus-data-number result)))))
5988 (defun gnus-summary-find-prev (&optional unread article)
5989 (let* ((eobp (eobp))
5990 (article (or article (gnus-summary-article-number)))
5991 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
5993 (when (and (not eobp)
5994 (or (not gnus-summary-check-current)
5996 (not (gnus-data-unread-p (car arts)))))
5997 (setq arts (cdr arts)))
6002 (when (gnus-data-unread-p (car arts))
6003 (setq result (car arts)
6005 (setq arts (cdr arts)))
6008 (goto-char (gnus-data-pos result))
6009 (gnus-data-number result))))
6011 (defun gnus-summary-find-subject (subject &optional unread backward article)
6012 (let* ((simp-subject (gnus-simplify-subject-fully subject))
6013 (article (or article (gnus-summary-article-number)))
6014 (articles (gnus-data-list backward))
6015 (arts (gnus-data-find-list article articles))
6017 (when (or (not gnus-summary-check-current)
6019 (not (gnus-data-unread-p (car arts))))
6020 (setq arts (cdr arts)))
6022 (and (or (not unread)
6023 (gnus-data-unread-p (car arts)))
6024 (vectorp (gnus-data-header (car arts)))
6026 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
6027 (setq result (car arts)
6029 (setq arts (cdr arts)))
6031 (goto-char (gnus-data-pos result))
6032 (gnus-data-number result))))
6034 (defun gnus-summary-search-forward (&optional unread subject backward)
6035 "Search forward for an article.
6036 If UNREAD, look for unread articles. If SUBJECT, look for
6037 articles with that subject. If BACKWARD, search backward instead."
6038 (cond (subject (gnus-summary-find-subject subject unread backward))
6039 (backward (gnus-summary-find-prev unread))
6040 (t (gnus-summary-find-next unread))))
6042 (defun gnus-recenter (&optional n)
6043 "Center point in window and redisplay frame.
6044 Also do horizontal recentering."
6046 (when (and gnus-auto-center-summary
6047 (not (eq gnus-auto-center-summary 'vertical)))
6048 (gnus-horizontal-recenter))
6051 (defun gnus-summary-recenter ()
6052 "Center point in the summary window.
6053 If `gnus-auto-center-summary' is nil, or the article buffer isn't
6054 displayed, no centering will be performed."
6055 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
6056 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
6058 (let* ((top (cond ((< (window-height) 4) 0)
6059 ((< (window-height) 7) 1)
6060 (t (if (numberp gnus-auto-center-summary)
6061 gnus-auto-center-summary
6063 (height (1- (window-height)))
6064 (bottom (save-excursion (goto-char (point-max))
6065 (forward-line (- height))
6067 (window (get-buffer-window (current-buffer))))
6068 ;; The user has to want it.
6069 (when gnus-auto-center-summary
6070 (when (get-buffer-window gnus-article-buffer)
6071 ;; Only do recentering when the article buffer is displayed,
6072 ;; Set the window start to either `bottom', which is the biggest
6073 ;; possible valid number, or the second line from the top,
6074 ;; whichever is the least.
6075 (let ((top-pos (save-excursion (forward-line (- top)) (point))))
6076 (if (> bottom top-pos)
6077 ;; Keep the second line from the top visible
6078 (set-window-start window top-pos t)
6079 ;; Try to keep the bottom line visible; if it's partially
6080 ;; obscured, either scroll one more line to make it fully
6081 ;; visible, or revert to using TOP-POS.
6083 (goto-char (point-max))
6085 (let ((last-line-start (point)))
6087 (set-window-start window (point) t)
6088 (when (not (pos-visible-in-window-p last-line-start window))
6090 (set-window-start window (min (point) top-pos) t)))))))
6091 ;; Do horizontal recentering while we're at it.
6092 (when (and (get-buffer-window (current-buffer) t)
6093 (not (eq gnus-auto-center-summary 'vertical)))
6094 (let ((selected (selected-window)))
6095 (select-window (get-buffer-window (current-buffer) t))
6096 (gnus-summary-position-point)
6097 (gnus-horizontal-recenter)
6098 (select-window selected))))))
6100 (defun gnus-summary-jump-to-group (newsgroup)
6101 "Move point to NEWSGROUP in group mode buffer."
6102 ;; Keep update point of group mode buffer if visible.
6103 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
6104 (save-window-excursion
6105 ;; Take care of tree window mode.
6106 (when (get-buffer-window gnus-group-buffer)
6107 (pop-to-buffer gnus-group-buffer))
6108 (gnus-group-jump-to-group newsgroup))
6110 ;; Take care of tree window mode.
6111 (if (get-buffer-window gnus-group-buffer)
6112 (pop-to-buffer gnus-group-buffer)
6113 (set-buffer gnus-group-buffer))
6114 (gnus-group-jump-to-group newsgroup))))
6116 ;; This function returns a list of article numbers based on the
6117 ;; difference between the ranges of read articles in this group and
6118 ;; the range of active articles.
6119 (defun gnus-list-of-unread-articles (group)
6120 (let* ((read (gnus-info-read (gnus-get-info group)))
6121 (active (or (gnus-active group) (gnus-activate-group group)))
6124 ;; If none are read, then all are unread.
6126 (setq first (car active))
6127 ;; If the range of read articles is a single range, then the
6128 ;; first unread article is the article after the last read
6129 ;; article. Sounds logical, doesn't it?
6130 (if (and (not (listp (cdr read)))
6131 (or (< (car read) (car active))
6132 (progn (setq read (list read))
6134 (setq first (max (car active) (1+ (cdr read))))
6135 ;; `read' is a list of ranges.
6136 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
6139 (setq first (car active)))
6142 (while (< first nlast)
6144 (setq first (1+ first))))
6145 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
6146 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
6147 (setq read (cdr read)))))
6148 ;; And add the last unread articles.
6149 (while (<= first last)
6151 (setq first (1+ first)))
6152 ;; Return the list of unread articles.
6153 (delq 0 (nreverse unread))))
6155 (defun gnus-list-of-read-articles (group)
6156 "Return a list of unread, unticked and non-dormant articles."
6157 (let* ((info (gnus-get-info group))
6158 (marked (gnus-info-marks info))
6159 (active (gnus-active group)))
6161 (gnus-list-range-difference
6162 (gnus-list-range-difference
6163 (gnus-sorted-complement
6164 (gnus-uncompress-range active)
6165 (gnus-list-of-unread-articles group))
6166 (cdr (assq 'dormant marked)))
6167 (cdr (assq 'tick marked))))))
6169 ;; Various summary commands
6171 (defun gnus-summary-select-article-buffer ()
6172 "Reconfigure windows to show article buffer."
6174 (if (not (gnus-buffer-live-p gnus-article-buffer))
6175 (error "There is no article buffer for this summary buffer")
6176 (gnus-configure-windows 'article)
6177 (select-window (get-buffer-window gnus-article-buffer))))
6179 (defun gnus-summary-universal-argument (arg)
6180 "Perform any operation on all articles that are process/prefixed."
6182 (let ((articles (gnus-summary-work-articles arg))
6189 (substitute-command-keys
6190 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"))))
6192 (gnus-error 1 "Undefined key")
6195 (gnus-summary-goto-subject (setq article (pop articles)))
6196 (let (gnus-newsgroup-processable)
6197 (command-execute func))
6198 (gnus-summary-remove-process-mark article)))))
6199 (gnus-summary-position-point))
6201 (defun gnus-summary-toggle-truncation (&optional arg)
6202 "Toggle truncation of summary lines.
6203 With arg, turn line truncation on if arg is positive."
6205 (setq truncate-lines
6206 (if (null arg) (not truncate-lines)
6207 (> (prefix-numeric-value arg) 0)))
6210 (defun gnus-summary-find-uncancelled ()
6211 "Return the number of an uncancelled article.
6212 The current article is considered, then following articles, then previous
6213 articles. If all articles are cancelled then return a dummy 0."
6215 (dolist (rev '(nil t))
6216 (unless found ; don't demand the reverse list if we don't need it
6217 (let ((data (gnus-data-find-list
6218 (gnus-summary-article-number) (gnus-data-list rev))))
6219 (while (and data (not found))
6220 (if (not (eq gnus-canceled-mark (gnus-data-mark (car data))))
6221 (setq found (gnus-data-number (car data))))
6222 (setq data (cdr data))))))
6225 (defun gnus-summary-reselect-current-group (&optional all rescan)
6226 "Exit and then reselect the current newsgroup.
6227 The prefix argument ALL means to select all articles."
6229 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
6230 (error "Ephemeral groups can't be reselected"))
6231 (let ((current-subject (gnus-summary-find-uncancelled))
6232 (group gnus-newsgroup-name))
6233 (setq gnus-newsgroup-begin nil)
6235 ;; We have to adjust the point of group mode buffer because
6236 ;; point was moved to the next unread newsgroup by exiting.
6237 (gnus-summary-jump-to-group group)
6240 (save-window-excursion
6241 ;; Don't show group contents.
6242 (set-window-start (selected-window) (point-max))
6243 (gnus-group-get-new-news-this-group 1))))
6244 (gnus-group-read-group all t)
6245 (gnus-summary-goto-subject current-subject nil t)))
6247 (defun gnus-summary-rescan-group (&optional all)
6248 "Exit the newsgroup, ask for new articles, and select the newsgroup."
6250 (gnus-summary-reselect-current-group all t))
6252 (defun gnus-summary-update-info (&optional non-destructive)
6254 (let ((group gnus-newsgroup-name))
6256 (when gnus-newsgroup-kill-headers
6257 (setq gnus-newsgroup-killed
6258 (gnus-compress-sequence
6260 (gnus-list-range-intersection
6261 gnus-newsgroup-unselected gnus-newsgroup-killed)
6262 gnus-newsgroup-unreads)
6264 (unless (listp (cdr gnus-newsgroup-killed))
6265 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
6266 (let ((headers gnus-newsgroup-headers))
6267 ;; Set the new ranges of read articles.
6269 (set-buffer gnus-group-buffer)
6270 (gnus-undo-force-boundary))
6271 (gnus-update-read-articles
6272 group (gnus-sorted-union
6273 gnus-newsgroup-unreads gnus-newsgroup-unselected))
6274 ;; Set the current article marks.
6275 (let ((gnus-newsgroup-scored
6276 (if (and (not gnus-save-score)
6277 (not non-destructive))
6279 gnus-newsgroup-scored)))
6281 (gnus-update-marks)))
6282 ;; Do the cross-ref thing.
6283 (when gnus-use-cross-reference
6284 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
6285 ;; Do not switch windows but change the buffer to work.
6286 (set-buffer gnus-group-buffer)
6287 (unless (gnus-ephemeral-group-p group)
6288 (gnus-group-update-group group)))))))
6290 (defun gnus-summary-save-newsrc (&optional force)
6291 "Save the current number of read/marked articles in the dribble buffer.
6292 The dribble buffer will then be saved.
6293 If FORCE (the prefix), also save the .newsrc file(s)."
6295 (gnus-summary-update-info t)
6297 (gnus-save-newsrc-file)
6298 (gnus-dribble-save)))
6300 (defun gnus-summary-exit (&optional temporary)
6301 "Exit reading current newsgroup, and then return to group selection mode.
6302 `gnus-exit-group-hook' is called with no arguments if that value is non-nil."
6304 (gnus-set-global-variables)
6305 (gnus-kill-save-kill-buffer)
6306 (gnus-async-halt-prefetch)
6307 (let* ((group gnus-newsgroup-name)
6308 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
6311 (buf (current-buffer)))
6313 ;; Do adaptive scoring, and possibly save score files.
6314 (when gnus-newsgroup-adaptive
6315 (gnus-score-adaptive))
6316 (when gnus-use-scoring
6318 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
6319 ;; If we have several article buffers, we kill them at exit.
6320 (unless gnus-single-article-buffer
6321 (gnus-kill-buffer gnus-original-article-buffer)
6322 (setq gnus-article-current nil))
6323 (when gnus-use-cache
6324 (gnus-cache-possibly-remove-articles)
6325 (gnus-cache-save-buffers))
6326 (gnus-async-prefetch-remove-group group)
6327 (when gnus-suppress-duplicates
6328 (gnus-dup-enter-articles))
6329 (when gnus-use-trees
6330 (gnus-tree-close group))
6331 (when gnus-use-cache
6332 (gnus-cache-write-active))
6333 ;; Remove entries for this group.
6334 (nnmail-purge-split-history (gnus-group-real-name group))
6335 ;; Make all changes in this group permanent.
6337 (gnus-run-hooks 'gnus-exit-group-hook)
6338 (gnus-summary-update-info))
6339 (gnus-close-group group)
6340 ;; Make sure where we were, and go to next newsgroup.
6341 (set-buffer gnus-group-buffer)
6343 (gnus-group-jump-to-group group))
6344 (gnus-run-hooks 'gnus-summary-exit-hook)
6345 (unless (or quit-config
6346 ;; If this group has disappeared from the summary
6347 ;; buffer, don't skip forwards.
6348 (not (string= group (gnus-group-group-name))))
6349 (gnus-group-next-unread-group 1))
6350 (setq group-point (point))
6353 ;; If we have several article buffers, we kill them at exit.
6354 (unless gnus-single-article-buffer
6355 (gnus-kill-buffer gnus-article-buffer)
6356 (gnus-kill-buffer gnus-original-article-buffer)
6357 (setq gnus-article-current nil))
6359 (if (not gnus-kill-summary-on-exit)
6361 (gnus-deaden-summary)
6363 ;; We set all buffer-local variables to nil. It is unclear why
6364 ;; this is needed, but if we don't, buffer-local variables are
6365 ;; not garbage-collected, it seems. This would the lead to en
6366 ;; ever-growing Emacs.
6367 (gnus-summary-clear-local-variables)
6368 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6369 (gnus-summary-clear-local-variables))
6370 (when (get-buffer gnus-article-buffer)
6371 (bury-buffer gnus-article-buffer))
6372 ;; We clear the global counterparts of the buffer-local
6373 ;; variables as well, just to be on the safe side.
6374 (set-buffer gnus-group-buffer)
6375 (gnus-summary-clear-local-variables)
6376 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6377 (gnus-summary-clear-local-variables)))
6378 (setq gnus-current-select-method gnus-select-method)
6379 (pop-to-buffer gnus-group-buffer)
6380 (if (not quit-config)
6382 (goto-char group-point)
6383 (gnus-configure-windows 'group 'force)
6384 (unless (pos-visible-in-window-p)
6385 (forward-line (/ (static-if (featurep 'xemacs)
6386 (window-displayed-height)
6387 (1- (window-height)))
6389 (set-window-start (selected-window) (point))
6390 (goto-char group-point)))
6391 (gnus-handle-ephemeral-exit quit-config))
6392 ;; Return to group mode buffer.
6393 (when (eq mode 'gnus-summary-mode)
6394 (gnus-kill-buffer buf))
6395 ;; Clear the current group name.
6397 (setq gnus-newsgroup-name nil)))))
6399 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
6400 (defun gnus-summary-exit-no-update (&optional no-questions)
6401 "Quit reading current newsgroup without updating read article info."
6403 (let* ((group gnus-newsgroup-name)
6404 (quit-config (gnus-group-quit-config group)))
6405 (when (or no-questions
6407 (gnus-y-or-n-p "Discard changes to this group and exit? "))
6408 (gnus-async-halt-prefetch)
6410 (delq 'gnus-summary-expire-articles
6411 (copy-sequence gnus-summary-prepare-exit-hook)))
6412 ;; If we have several article buffers, we kill them at exit.
6413 (unless gnus-single-article-buffer
6414 (gnus-kill-buffer gnus-article-buffer)
6415 (gnus-kill-buffer gnus-original-article-buffer)
6416 (setq gnus-article-current nil))
6417 (if (not gnus-kill-summary-on-exit)
6418 (gnus-deaden-summary)
6419 (gnus-close-group group)
6420 (gnus-summary-clear-local-variables)
6421 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6422 (gnus-summary-clear-local-variables))
6423 (set-buffer gnus-group-buffer)
6424 (gnus-summary-clear-local-variables)
6425 (let ((gnus-summary-local-variables gnus-newsgroup-variables))
6426 (gnus-summary-clear-local-variables))
6427 (when (get-buffer gnus-summary-buffer)
6428 (kill-buffer gnus-summary-buffer)))
6429 (unless gnus-single-article-buffer
6430 (setq gnus-article-current nil))
6431 (when gnus-use-trees
6432 (gnus-tree-close group))
6433 (gnus-async-prefetch-remove-group group)
6434 (when (get-buffer gnus-article-buffer)
6435 (bury-buffer gnus-article-buffer))
6436 ;; Return to the group buffer.
6437 (gnus-configure-windows 'group 'force)
6438 ;; Clear the current group name.
6439 (setq gnus-newsgroup-name nil)
6440 (when (equal (gnus-group-group-name) group)
6441 (gnus-group-next-unread-group 1))
6443 (gnus-handle-ephemeral-exit quit-config)))))
6445 (defun gnus-handle-ephemeral-exit (quit-config)
6446 "Handle movement when leaving an ephemeral group.
6447 The state which existed when entering the ephemeral is reset."
6448 (if (not (buffer-name (car quit-config)))
6449 (gnus-configure-windows 'group 'force)
6450 (set-buffer (car quit-config))
6451 (cond ((eq major-mode 'gnus-summary-mode)
6452 (gnus-set-global-variables))
6453 ((eq major-mode 'gnus-article-mode)
6455 ;; The `gnus-summary-buffer' variable may point
6456 ;; to the old summary buffer when using a single
6458 (unless (gnus-buffer-live-p gnus-summary-buffer)
6459 (set-buffer gnus-group-buffer))
6460 (set-buffer gnus-summary-buffer)
6461 (gnus-set-global-variables))))
6462 (if (or (eq (cdr quit-config) 'article)
6463 (eq (cdr quit-config) 'pick))
6465 ;; The current article may be from the ephemeral group
6466 ;; thus it is best that we reload this article
6467 (gnus-summary-show-article)
6468 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
6469 (gnus-configure-windows 'pick 'force)
6470 (gnus-configure-windows (cdr quit-config) 'force)))
6471 (gnus-configure-windows (cdr quit-config) 'force))
6472 (when (eq major-mode 'gnus-summary-mode)
6473 (gnus-summary-next-subject 1 nil t)
6474 (gnus-summary-recenter)
6475 (gnus-summary-position-point))))
6477 (defun gnus-summary-preview-mime-message ()
6478 "MIME decode and play this message."
6480 (let ((gnus-break-pages nil)
6482 (gnus-summary-select-article gnus-show-all-headers t))
6483 (let ((w (get-buffer-window gnus-article-buffer)))
6485 (select-window (get-buffer-window gnus-article-buffer)))))
6489 (defvar gnus-dead-summary-mode-map nil)
6491 (unless gnus-dead-summary-mode-map
6492 (setq gnus-dead-summary-mode-map (make-keymap))
6493 (suppress-keymap gnus-dead-summary-mode-map)
6494 (substitute-key-definition
6495 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
6496 (dolist (key '("\C-d" "\r" "\177" [delete]))
6497 (define-key gnus-dead-summary-mode-map
6498 key 'gnus-summary-wake-up-the-dead))
6499 (dolist (key '("q" "Q"))
6500 (define-key gnus-dead-summary-mode-map key 'bury-buffer)))
6502 (defvar gnus-dead-summary-mode nil
6503 "Minor mode for Gnus summary buffers.")
6505 (defun gnus-dead-summary-mode (&optional arg)
6506 "Minor mode for Gnus summary buffers."
6508 (when (eq major-mode 'gnus-summary-mode)
6509 (make-local-variable 'gnus-dead-summary-mode)
6510 (setq gnus-dead-summary-mode
6511 (if (null arg) (not gnus-dead-summary-mode)
6512 (> (prefix-numeric-value arg) 0)))
6513 (when gnus-dead-summary-mode
6514 (gnus-add-minor-mode
6515 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
6517 (defun gnus-deaden-summary ()
6518 "Make the current summary buffer into a dead summary buffer."
6519 ;; Kill any previous dead summary buffer.
6520 (when (and gnus-dead-summary
6521 (buffer-name gnus-dead-summary))
6523 (set-buffer gnus-dead-summary)
6524 (when gnus-dead-summary-mode
6525 (kill-buffer (current-buffer)))))
6526 ;; Make this the current dead summary.
6527 (setq gnus-dead-summary (current-buffer))
6528 (gnus-dead-summary-mode 1)
6529 (let ((name (buffer-name)))
6530 (when (string-match "Summary" name)
6532 (concat (substring name 0 (match-beginning 0)) "Dead "
6533 (substring name (match-beginning 0)))
6537 (defun gnus-kill-or-deaden-summary (buffer)
6538 "Kill or deaden the summary BUFFER."
6540 (when (and (buffer-name buffer)
6541 (not gnus-single-article-buffer))
6544 (gnus-kill-buffer gnus-article-buffer)
6545 (gnus-kill-buffer gnus-original-article-buffer)))
6548 (gnus-kill-summary-on-exit
6549 (when (and gnus-use-trees
6550 (gnus-buffer-exists-p buffer))
6553 (gnus-tree-close gnus-newsgroup-name)))
6554 (gnus-kill-buffer buffer))
6555 ;; Deaden the buffer.
6556 ((gnus-buffer-exists-p buffer)
6559 (gnus-deaden-summary))))))
6561 (defun gnus-summary-wake-up-the-dead (&rest args)
6562 "Wake up the dead summary buffer."
6564 (gnus-dead-summary-mode -1)
6565 (let ((name (buffer-name)))
6566 (when (string-match "Dead " name)
6568 (concat (substring name 0 (match-beginning 0))
6569 (substring name (match-end 0)))
6571 (gnus-message 3 "This dead summary is now alive again"))
6573 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
6574 (defun gnus-summary-fetch-faq (&optional faq-dir)
6575 "Fetch the FAQ for the current group.
6576 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
6580 (when current-prefix-arg
6582 "FAQ dir: " (and (listp gnus-group-faq-directory)
6583 (mapcar (lambda (file) (list file))
6584 gnus-group-faq-directory))))))
6585 (let (gnus-faq-buffer)
6586 (when (setq gnus-faq-buffer
6587 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
6588 (gnus-configure-windows 'summary-faq))))
6590 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
6591 (defun gnus-summary-describe-group (&optional force)
6592 "Describe the current newsgroup."
6594 (gnus-group-describe-group force gnus-newsgroup-name))
6596 (defun gnus-summary-describe-briefly ()
6597 "Describe summary mode commands briefly."
6599 (gnus-message 6 (substitute-command-keys "\\<gnus-summary-mode-map>\\[gnus-summary-next-page]:Select \\[gnus-summary-next-unread-article]:Forward \\[gnus-summary-prev-unread-article]:Backward \\[gnus-summary-exit]:Exit \\[gnus-info-find-node]:Run Info \\[gnus-summary-describe-briefly]:This help")))
6601 ;; Walking around group mode buffer from summary mode.
6603 (defun gnus-summary-next-group (&optional no-article target-group backward)
6604 "Exit current newsgroup and then select next unread newsgroup.
6605 If prefix argument NO-ARTICLE is non-nil, no article is selected
6606 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
6607 previous group instead."
6609 ;; Stop pre-fetching.
6610 (gnus-async-halt-prefetch)
6611 (let ((current-group gnus-newsgroup-name)
6612 (current-buffer (current-buffer))
6614 (gnus-summary-exit t)
6615 (while (not entered)
6616 ;; Then we find what group we are supposed to enter.
6617 (set-buffer gnus-group-buffer)
6618 (gnus-group-jump-to-group current-group)
6621 (if (eq gnus-keep-same-level 'best)
6622 (gnus-summary-best-group gnus-newsgroup-name)
6623 (gnus-summary-search-group backward gnus-keep-same-level))))
6624 (if (not target-group)
6625 ;; There are no further groups, so we return to the group
6628 (gnus-message 5 "Returning to the group buffer")
6630 (when (gnus-buffer-live-p current-buffer)
6631 (set-buffer current-buffer)
6632 (gnus-summary-exit))
6633 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
6634 ;; We try to enter the target group.
6635 (gnus-group-jump-to-group target-group)
6636 (let ((unreads (gnus-group-group-unread)))
6637 (if (and (or (eq t unreads)
6638 (and unreads (not (zerop unreads))))
6640 ;; Now we semi-exit this group to update Xrefs
6641 ;; and all variables. We can't do a real exit,
6642 ;; because the window conf must remain the same
6643 ;; in case the user is prompted for info, and we
6644 ;; don't want the window conf to change before
6646 (when (gnus-buffer-live-p current-buffer)
6647 (set-buffer current-buffer)
6648 (gnus-summary-exit t))
6649 (gnus-summary-read-group
6650 target-group nil no-article
6651 (and (buffer-name current-buffer) current-buffer)
6654 (setq current-group target-group
6655 target-group nil)))))))
6657 (defun gnus-summary-prev-group (&optional no-article)
6658 "Exit current newsgroup and then select previous unread newsgroup.
6659 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
6661 (gnus-summary-next-group no-article nil t))
6663 ;; Walking around summary lines.
6665 (defun gnus-summary-first-subject (&optional unread undownloaded unseen)
6666 "Go to the first unread subject.
6667 If UNREAD is non-nil, go to the first unread article.
6668 Returns the article selected or nil if there are no unread articles."
6673 ((null gnus-newsgroup-data)
6674 (gnus-message 3 "No articles in the group")
6676 ;; Pick the first article.
6678 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
6679 (gnus-data-number (car gnus-newsgroup-data)))
6680 ;; No unread articles.
6681 ((null gnus-newsgroup-unreads)
6682 (gnus-message 3 "No more unread articles")
6684 ;; Find the first unread article.
6686 (let ((data gnus-newsgroup-data))
6688 (and (not (and undownloaded
6689 (memq (car data) gnus-newsgroup-undownloaded)))
6692 (gnus-data-number (car data))
6693 gnus-newsgroup-unseen))
6694 (not (gnus-data-unread-p (car data))))
6695 (not (gnus-data-unread-p (car data))))))
6696 (setq data (cdr data)))
6698 (goto-char (gnus-data-pos (car data)))
6699 (gnus-data-number (car data))))))
6700 (gnus-summary-position-point)))
6702 (defun gnus-summary-next-subject (n &optional unread dont-display)
6703 "Go to next N'th summary line.
6704 If N is negative, go to the previous N'th subject line.
6705 If UNREAD is non-nil, only unread articles are selected.
6706 The difference between N and the actual number of steps taken is
6709 (let ((backward (< n 0))
6713 (gnus-summary-find-prev unread)
6714 (gnus-summary-find-next unread)))
6715 (unless (zerop (setq n (1- n)))
6716 (gnus-summary-show-thread)))
6718 (gnus-message 7 "No more%s articles"
6719 (if unread " unread" "")))
6720 (unless dont-display
6721 (gnus-summary-recenter)
6722 (gnus-summary-position-point))
6725 (defun gnus-summary-next-unread-subject (n)
6726 "Go to next N'th unread summary line."
6728 (gnus-summary-next-subject n t))
6730 (defun gnus-summary-prev-subject (n &optional unread)
6731 "Go to previous N'th summary line.
6732 If optional argument UNREAD is non-nil, only unread article is selected."
6734 (gnus-summary-next-subject (- n) unread))
6736 (defun gnus-summary-prev-unread-subject (n)
6737 "Go to previous N'th unread summary line."
6739 (gnus-summary-next-subject (- n) t))
6741 (defun gnus-summary-goto-subject (article &optional force silent)
6742 "Go the subject line of ARTICLE.
6743 If FORCE, also allow jumping to articles not currently shown."
6744 (interactive "nArticle number: ")
6745 (unless (numberp article)
6746 (error "Article %s is not a number" article))
6748 (data (gnus-data-find article)))
6749 ;; We read in the article if we have to.
6752 (gnus-summary-insert-subject
6754 (if (or (numberp force) (vectorp force)) force)
6756 (setq data (gnus-data-find article)))
6761 (gnus-message 3 "Can't find article %d" article))
6763 (let ((pt (gnus-data-pos data)))
6765 (gnus-summary-set-article-display-arrow pt))
6766 (gnus-summary-position-point)
6769 ;; Walking around summary lines with displaying articles.
6771 (defun gnus-summary-expand-window (&optional arg)
6772 "Make the summary buffer take up the entire Emacs frame.
6773 Given a prefix, will force an `article' buffer configuration."
6776 (gnus-configure-windows 'article 'force)
6777 (gnus-configure-windows 'summary 'force)))
6779 (defun gnus-summary-display-article (article &optional all-header)
6780 "Display ARTICLE in article buffer."
6781 (when (gnus-buffer-live-p gnus-article-buffer)
6782 (with-current-buffer gnus-article-buffer
6783 (set-buffer-multibyte t)))
6784 (gnus-set-global-variables)
6785 (when (gnus-buffer-live-p gnus-article-buffer)
6786 (with-current-buffer gnus-article-buffer
6787 (setq gnus-article-charset gnus-newsgroup-charset)
6788 (setq gnus-article-ignored-charsets gnus-newsgroup-ignored-charsets)
6789 (set-buffer-multibyte t)))
6793 (if gnus-summary-display-article-function
6794 (funcall gnus-summary-display-article-function article all-header)
6795 (gnus-article-prepare article all-header))
6796 (with-current-buffer gnus-article-buffer
6797 (set (make-local-variable 'gnus-summary-search-article-matched-data)
6799 (gnus-run-hooks 'gnus-select-article-hook)
6800 (when (and gnus-current-article
6801 (not (zerop gnus-current-article)))
6802 (gnus-summary-goto-subject gnus-current-article))
6803 (gnus-summary-recenter)
6804 (when (and gnus-use-trees gnus-show-threads)
6805 (gnus-possibly-generate-tree article)
6806 (gnus-highlight-selected-tree article))
6807 ;; Successfully display article.
6808 (gnus-article-set-window-start
6809 (cdr (assq article gnus-newsgroup-bookmarks))))))
6811 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
6812 "Select the current article.
6813 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
6814 non-nil, the article will be re-fetched even if it already present in
6815 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
6817 ;; Make sure we are in the summary buffer to work around bbdb bug.
6818 (unless (eq major-mode 'gnus-summary-mode)
6819 (set-buffer gnus-summary-buffer))
6820 (let ((article (or article (gnus-summary-article-number)))
6821 (all-headers (not (not all-headers))) ;Must be T or NIL.
6822 gnus-summary-display-article-function)
6824 (gnus-summary-article-pseudo-p article)
6825 (error "This is a pseudo-article"))
6827 (set-buffer gnus-summary-buffer)
6828 (if (or (and gnus-single-article-buffer
6829 (or (null gnus-current-article)
6830 (null gnus-article-current)
6831 (null (get-buffer gnus-article-buffer))
6832 (not (eq article (cdr gnus-article-current)))
6833 (not (equal (car gnus-article-current)
6834 gnus-newsgroup-name))))
6835 (and (not gnus-single-article-buffer)
6836 (or (null gnus-current-article)
6837 (not (eq gnus-current-article article))))
6839 ;; The requested article is different from the current article.
6841 (gnus-summary-display-article article all-headers)
6842 (gnus-article-set-window-start
6843 (cdr (assq article gnus-newsgroup-bookmarks)))
6847 (defun gnus-summary-force-verify-and-decrypt ()
6849 (let ((mm-verify-option 'known)
6850 (mm-decrypt-option 'known)
6851 (gnus-buttonized-mime-types (append (list "multipart/signed"
6852 "multipart/encrypted")
6853 gnus-buttonized-mime-types)))
6854 (gnus-summary-select-article nil 'force)))
6856 (defun gnus-summary-set-current-mark (&optional current-mark)
6857 "Obsolete function."
6860 (defun gnus-summary-next-article (&optional unread subject backward push)
6861 "Select the next article.
6862 If UNREAD, only unread articles are selected.
6863 If SUBJECT, only articles with SUBJECT are selected.
6864 If BACKWARD, the previous article is selected instead of the next."
6867 ;; Is there such an article?
6868 ((and (gnus-summary-search-forward unread subject backward)
6869 (or (gnus-summary-display-article (gnus-summary-article-number))
6870 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
6871 (gnus-summary-position-point))
6872 ;; If not, we try the first unread, if that is wanted.
6874 gnus-auto-select-same
6875 (gnus-summary-first-unread-article))
6876 (gnus-summary-position-point)
6877 (gnus-message 6 "Wrapped"))
6878 ;; Try to get next/previous article not displayed in this group.
6879 ((and gnus-auto-extend-newsgroup
6880 (not unread) (not subject))
6881 (gnus-summary-goto-article
6882 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
6883 nil (count-lines (point-min) (point))))
6884 ;; Go to next/previous group.
6886 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
6887 (gnus-summary-jump-to-group gnus-newsgroup-name))
6888 (let ((cmd last-command-char)
6891 (set-buffer gnus-group-buffer)
6894 (if (eq gnus-keep-same-level 'best)
6895 (gnus-summary-best-group gnus-newsgroup-name)
6896 (gnus-summary-search-group backward gnus-keep-same-level))))
6897 ;; For some reason, the group window gets selected. We change
6899 (select-window (get-buffer-window (current-buffer)))
6900 ;; Select next unread newsgroup automagically.
6902 ((or (not gnus-auto-select-next)
6904 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
6905 ((or (eq gnus-auto-select-next 'quietly)
6906 (and (eq gnus-auto-select-next 'slightly-quietly)
6908 (and (eq gnus-auto-select-next 'almost-quietly)
6909 (gnus-summary-last-article-p)))
6911 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
6913 (gnus-message 7 "No more%s articles (%s)..."
6914 (if unread " unread" "")
6915 (if group (concat "selecting " group)
6917 (gnus-summary-next-group nil group backward)))
6919 (when (gnus-key-press-event-p last-input-event)
6920 (gnus-summary-walk-group-buffer
6921 gnus-newsgroup-name cmd unread backward point))))))))
6923 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
6924 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
6925 (?\C-p (gnus-group-prev-unread-group 1))))
6926 (cursor-in-echo-area t)
6927 keve key group ended)
6929 (set-buffer gnus-group-buffer)
6932 (if (eq gnus-keep-same-level 'best)
6933 (gnus-summary-best-group gnus-newsgroup-name)
6934 (gnus-summary-search-group backward gnus-keep-same-level))))
6937 5 "No more%s articles%s" (if unread " unread" "")
6939 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
6940 (format " (Type %s for %s [%s])"
6941 (single-key-description cmd) group
6942 (car (gnus-gethash group gnus-newsrc-hashtb)))
6943 (format " (Type %s to exit %s)"
6944 (single-key-description cmd)
6945 gnus-newsgroup-name)))
6946 ;; Confirm auto selection.
6947 (setq key (car (setq keve (gnus-read-event-char))))
6950 ((assq key keystrokes)
6951 (let ((obuf (current-buffer)))
6952 (switch-to-buffer gnus-group-buffer)
6954 (gnus-group-jump-to-group group))
6955 (eval (cadr (assq key keystrokes)))
6956 (setq group (gnus-group-group-name))
6957 (switch-to-buffer obuf))
6961 (gnus-ephemeral-group-p gnus-newsgroup-name))
6963 (gnus-summary-next-group nil group backward)))
6965 (push (cdr keve) unread-command-events))))))
6967 (defun gnus-summary-next-unread-article ()
6968 "Select unread article after current one."
6970 (gnus-summary-next-article
6971 (or (not (eq gnus-summary-goto-unread 'never))
6972 (gnus-summary-last-article-p (gnus-summary-article-number)))
6973 (and gnus-auto-select-same
6974 (gnus-summary-article-subject))))
6976 (defun gnus-summary-prev-article (&optional unread subject)
6977 "Select the article after the current one.
6978 If UNREAD is non-nil, only unread articles are selected."
6980 (gnus-summary-next-article unread subject t))
6982 (defun gnus-summary-prev-unread-article ()
6983 "Select unread article before current one."
6985 (gnus-summary-prev-article
6986 (or (not (eq gnus-summary-goto-unread 'never))
6987 (gnus-summary-first-article-p (gnus-summary-article-number)))
6988 (and gnus-auto-select-same
6989 (gnus-summary-article-subject))))
6991 (defun gnus-summary-next-page (&optional lines circular)
6992 "Show next page of the selected article.
6993 If at the end of the current article, select the next article.
6994 LINES says how many lines should be scrolled up.
6996 If CIRCULAR is non-nil, go to the start of the article instead of
6997 selecting the next article when reaching the end of the current
7000 (setq gnus-summary-buffer (current-buffer))
7001 (gnus-set-global-variables)
7002 (let ((article (gnus-summary-article-number))
7003 (article-window (get-buffer-window gnus-article-buffer t))
7005 ;; If the buffer is empty, we have no article.
7007 (error "No article to select"))
7008 (gnus-configure-windows 'article)
7009 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
7010 (if (and (eq gnus-summary-goto-unread 'never)
7011 (not (gnus-summary-last-article-p article)))
7012 (gnus-summary-next-article)
7013 (gnus-summary-next-unread-article))
7014 (if (or (null gnus-current-article)
7015 (null gnus-article-current)
7016 (/= article (cdr gnus-article-current))
7017 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7018 ;; Selected subject is different from current article's.
7019 (gnus-summary-display-article article)
7020 (when article-window
7021 (gnus-eval-in-buffer-window gnus-article-buffer
7022 (setq endp (gnus-article-next-page lines)))
7025 (gnus-summary-beginning-of-article))
7027 (gnus-message 3 "End of message"))
7029 (if (and (eq gnus-summary-goto-unread 'never)
7030 (not (gnus-summary-last-article-p article)))
7031 (gnus-summary-next-article)
7032 (gnus-summary-next-unread-article))))))))
7033 (gnus-summary-recenter)
7034 (gnus-summary-position-point)))
7036 (defun gnus-summary-prev-page (&optional lines move)
7037 "Show previous page of selected article.
7038 Argument LINES specifies lines to be scrolled down.
7039 If MOVE, move to the previous unread article if point is at
7040 the beginning of the buffer."
7042 (let ((article (gnus-summary-article-number))
7043 (article-window (get-buffer-window gnus-article-buffer t))
7045 (gnus-configure-windows 'article)
7046 (if (or (null gnus-current-article)
7047 (null gnus-article-current)
7048 (/= article (cdr gnus-article-current))
7049 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
7050 ;; Selected subject is different from current article's.
7051 (gnus-summary-display-article article)
7052 (gnus-summary-recenter)
7053 (when article-window
7054 (gnus-eval-in-buffer-window gnus-article-buffer
7055 (setq endp (gnus-article-prev-page lines)))
7056 (when (and move endp)
7058 (gnus-message 3 "Beginning of message"))
7060 (if (and (eq gnus-summary-goto-unread 'never)
7061 (not (gnus-summary-first-article-p article)))
7062 (gnus-summary-prev-article)
7063 (gnus-summary-prev-unread-article))))))))
7064 (gnus-summary-position-point))
7066 (defun gnus-summary-prev-page-or-article (&optional lines)
7067 "Show previous page of selected article.
7068 Argument LINES specifies lines to be scrolled down.
7069 If at the beginning of the article, go to the next article."
7071 (gnus-summary-prev-page lines t))
7073 (defun gnus-summary-scroll-up (lines)
7074 "Scroll up (or down) one line current article.
7075 Argument LINES specifies lines to be scrolled up (or down if negative)."
7077 (gnus-configure-windows 'article)
7078 (gnus-summary-show-thread)
7079 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
7080 (gnus-eval-in-buffer-window gnus-article-buffer
7082 (when (gnus-article-next-page lines)
7083 (gnus-message 3 "End of message")))
7085 (gnus-article-prev-page (- lines))))))
7086 (gnus-summary-recenter)
7087 (gnus-summary-position-point))
7089 (defun gnus-summary-scroll-down (lines)
7090 "Scroll down (or up) one line current article.
7091 Argument LINES specifies lines to be scrolled down (or up if negative)."
7093 (gnus-summary-scroll-up (- lines)))
7095 (defun gnus-summary-next-same-subject ()
7096 "Select next article which has the same subject as current one."
7098 (gnus-summary-next-article nil (gnus-summary-article-subject)))
7100 (defun gnus-summary-prev-same-subject ()
7101 "Select previous article which has the same subject as current one."
7103 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
7105 (defun gnus-summary-next-unread-same-subject ()
7106 "Select next unread article which has the same subject as current one."
7108 (gnus-summary-next-article t (gnus-summary-article-subject)))
7110 (defun gnus-summary-prev-unread-same-subject ()
7111 "Select previous unread article which has the same subject as current one."
7113 (gnus-summary-prev-article t (gnus-summary-article-subject)))
7115 (defun gnus-summary-first-unread-article ()
7116 "Select the first unread article.
7117 Return nil if there are no unread articles."
7120 (when (gnus-summary-first-subject t)
7121 (gnus-summary-show-thread)
7122 (gnus-summary-first-subject t)
7123 (gnus-summary-display-article (gnus-summary-article-number)))
7124 (gnus-summary-position-point)))
7126 (defun gnus-summary-first-unread-subject ()
7127 "Place the point on the subject line of the first unread article.
7128 Return nil if there are no unread articles."
7131 (when (gnus-summary-first-subject t)
7132 (gnus-summary-show-thread)
7133 (gnus-summary-first-subject t))
7134 (gnus-summary-position-point)))
7136 (defun gnus-summary-first-unseen-subject ()
7137 "Place the point on the subject line of the first unseen article.
7138 Return nil if there are no unseen articles."
7141 (when (gnus-summary-first-subject t t t)
7142 (gnus-summary-show-thread)
7143 (gnus-summary-first-subject t t t))
7144 (gnus-summary-position-point)))
7146 (defun gnus-summary-first-unseen-or-unread-subject ()
7147 "Place the point on the subject line of the first unseen article.
7148 Return nil if there are no unseen articles."
7151 (unless (when (gnus-summary-first-subject t t t)
7152 (gnus-summary-show-thread)
7153 (gnus-summary-first-subject t t t))
7154 (when (gnus-summary-first-subject t)
7155 (gnus-summary-show-thread)
7156 (gnus-summary-first-subject t)))
7157 (gnus-summary-position-point)))
7159 (defun gnus-summary-first-article ()
7160 "Select the first article.
7161 Return nil if there are no articles."
7164 (when (gnus-summary-first-subject)
7165 (gnus-summary-show-thread)
7166 (gnus-summary-first-subject)
7167 (gnus-summary-display-article (gnus-summary-article-number)))
7168 (gnus-summary-position-point)))
7170 (defun gnus-summary-best-unread-article (&optional arg)
7171 "Select the unread article with the highest score.
7172 If given a prefix argument, select the next unread article that has a
7173 score higher than the default score."
7175 (let ((article (if arg
7176 (gnus-summary-better-unread-subject)
7177 (gnus-summary-best-unread-subject))))
7179 (gnus-summary-goto-article article)
7180 (error "No unread articles"))))
7182 (defun gnus-summary-best-unread-subject ()
7183 "Select the unread subject with the highest score."
7185 (let ((best -1000000)
7186 (data gnus-newsgroup-data)
7189 (and (gnus-data-unread-p (car data))
7191 (gnus-summary-article-score (gnus-data-number (car data))))
7194 article (gnus-data-number (car data))))
7195 (setq data (cdr data)))
7197 (gnus-summary-goto-subject article))
7198 (gnus-summary-position-point)
7201 (defun gnus-summary-better-unread-subject ()
7202 "Select the first unread subject that has a score over the default score."
7204 (let ((data gnus-newsgroup-data)
7206 (while (and (setq article (gnus-data-number (car data)))
7207 (or (gnus-data-read-p (car data))
7208 (not (> (gnus-summary-article-score article)
7209 gnus-summary-default-score))))
7210 (setq data (cdr data)))
7212 (gnus-summary-goto-subject article))
7213 (gnus-summary-position-point)
7216 (defun gnus-summary-last-subject ()
7217 "Go to the last displayed subject line in the group."
7218 (let ((article (gnus-data-number (car (gnus-data-list t)))))
7220 (gnus-summary-goto-subject article))))
7222 (defun gnus-summary-goto-article (article &optional all-headers force)
7223 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
7224 If ALL-HEADERS is non-nil, no header lines are hidden.
7225 If FORCE, go to the article even if it isn't displayed. If FORCE
7226 is a number, it is the line the article is to be displayed on."
7230 "Article number or Message-ID: "
7231 (mapcar (lambda (number) (list (int-to-string number)))
7232 gnus-newsgroup-limit))
7236 (if (and (stringp article)
7237 (string-match "@" article))
7238 (gnus-summary-refer-article article)
7239 (when (stringp article)
7240 (setq article (string-to-number article)))
7241 (if (gnus-summary-goto-subject article force)
7242 (gnus-summary-display-article article all-headers)
7243 (gnus-message 4 "Couldn't go to article %s" article) nil))
7244 (gnus-summary-position-point)))
7246 (defun gnus-summary-goto-last-article ()
7247 "Go to the previously read article."
7250 (when gnus-last-article
7251 (gnus-summary-goto-article gnus-last-article nil t))
7252 (gnus-summary-position-point)))
7254 (defun gnus-summary-pop-article (number)
7255 "Pop one article off the history and go to the previous.
7256 NUMBER articles will be popped off."
7259 (setq gnus-newsgroup-history
7260 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
7262 (gnus-summary-goto-article (car to) nil t)
7263 (error "Article history empty")))
7264 (gnus-summary-position-point))
7266 ;; Summary commands and functions for limiting the summary buffer.
7268 (defun gnus-summary-limit-to-articles (n)
7269 "Limit the summary buffer to the next N articles.
7270 If not given a prefix, use the process marked articles instead."
7273 (let ((articles (gnus-summary-work-articles n)))
7274 (setq gnus-newsgroup-processable nil)
7275 (gnus-summary-limit articles))
7276 (gnus-summary-position-point)))
7278 (defun gnus-summary-pop-limit (&optional total)
7279 "Restore the previous limit.
7280 If given a prefix, remove all limits."
7283 (setq gnus-newsgroup-limits
7284 (list (mapcar (lambda (h) (mail-header-number h))
7285 gnus-newsgroup-headers))))
7286 (unless gnus-newsgroup-limits
7287 (error "No limit to pop"))
7289 (gnus-summary-limit nil 'pop)
7290 (gnus-summary-position-point)))
7292 (defun gnus-summary-limit-to-subject (subject &optional header not-matching)
7293 "Limit the summary buffer to articles that have subjects that match a regexp.
7294 If NOT-MATCHING, excluding articles that have subjects that match a regexp."
7296 (list (read-string (if current-prefix-arg
7297 "Exclude subject (regexp): "
7298 "Limit to subject (regexp): "))
7299 nil current-prefix-arg))
7301 (setq header "subject"))
7302 (when (not (equal "" subject))
7304 (let ((articles (gnus-summary-find-matching
7305 (or header "subject") subject 'all nil nil
7308 (error "Found no matches for \"%s\"" subject))
7309 (gnus-summary-limit articles))
7310 (gnus-summary-position-point))))
7312 (defun gnus-summary-limit-to-author (from &optional not-matching)
7313 "Limit the summary buffer to articles that have authors that match a regexp.
7314 If NOT-MATCHING, excluding articles that have authors that match a regexp."
7316 (list (read-string (if current-prefix-arg
7317 "Exclude author (regexp): "
7318 "Limit to author (regexp): "))
7319 current-prefix-arg))
7320 (gnus-summary-limit-to-subject from "from" not-matching))
7322 (defun gnus-summary-limit-to-age (age &optional younger-p)
7323 "Limit the summary buffer to articles that are older than (or equal) AGE days.
7324 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
7325 articles that are younger than AGE days."
7327 (let ((younger current-prefix-arg)
7330 (while (not days-got)
7331 (setq days (if younger
7332 (read-string "Limit to articles within (in days): ")
7333 (read-string "Limit to articles older than (in days): ")))
7334 (when (> (length days) 0)
7335 (setq days (read days)))
7341 (setq younger (not younger))
7342 (setq days (* days -1)))))
7343 (message "Please enter a number.")
7345 (list days younger)))
7347 (let ((data gnus-newsgroup-data)
7348 (cutoff (days-to-time age))
7349 articles d date is-younger)
7350 (while (setq d (pop data))
7351 (when (and (vectorp (gnus-data-header d))
7352 (setq date (mail-header-date (gnus-data-header d))))
7353 (setq is-younger (time-less-p
7354 (time-since (condition-case ()
7361 (push (gnus-data-number d) articles))))
7362 (gnus-summary-limit (nreverse articles)))
7363 (gnus-summary-position-point)))
7365 (defun gnus-summary-limit-to-extra (header regexp &optional not-matching)
7366 "Limit the summary buffer to articles that match an 'extra' header."
7370 (gnus-completing-read-with-default
7371 (symbol-name (car gnus-extra-headers))
7372 (if current-prefix-arg
7373 "Exclude extra header:"
7374 "Limit extra header:")
7376 (cons (symbol-name x) x))
7381 (read-string (format "%s header %s (regexp): "
7382 (if current-prefix-arg "Exclude" "Limit to")
7384 current-prefix-arg)))
7385 (when (not (equal "" regexp))
7387 (let ((articles (gnus-summary-find-matching
7388 (cons 'extra header) regexp 'all nil nil
7391 (error "Found no matches for \"%s\"" regexp))
7392 (gnus-summary-limit articles))
7393 (gnus-summary-position-point))))
7395 (defun gnus-summary-limit-to-display-predicate ()
7396 "Limit the summary buffer to the predicated in the `display' group parameter."
7398 (unless gnus-newsgroup-display
7399 (error "There is no `display' group parameter"))
7401 (dolist (number gnus-newsgroup-articles)
7402 (when (funcall gnus-newsgroup-display)
7403 (push number articles)))
7404 (gnus-summary-limit articles))
7405 (gnus-summary-position-point))
7407 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7409 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
7411 (defun gnus-summary-limit-to-unread (&optional all)
7412 "Limit the summary buffer to articles that are not marked as read.
7413 If ALL is non-nil, limit strictly to unread articles."
7416 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
7417 (gnus-summary-limit-to-marks
7418 ;; Concat all the marks that say that an article is read and have
7420 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
7421 gnus-killed-mark gnus-spam-mark gnus-kill-file-mark
7422 gnus-low-score-mark gnus-expirable-mark
7423 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
7424 gnus-duplicate-mark gnus-souped-mark)
7427 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
7428 (make-obsolete 'gnus-summary-delete-marked-with
7429 'gnus-summary-limit-exclude-marks)
7431 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
7432 "Exclude articles that are marked with MARKS (e.g. \"DK\").
7433 If REVERSE, limit the summary buffer to articles that are marked
7434 with MARKS. MARKS can either be a string of marks or a list of marks.
7435 Returns how many articles were removed."
7436 (interactive "sMarks: ")
7437 (gnus-summary-limit-to-marks marks t))
7439 (defun gnus-summary-limit-to-marks (marks &optional reverse)
7440 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
7441 If REVERSE (the prefix), limit the summary buffer to articles that are
7442 not marked with MARKS. MARKS can either be a string of marks or a
7444 Returns how many articles were removed."
7445 (interactive "sMarks: \nP")
7447 (let ((data gnus-newsgroup-data)
7448 (marks (if (listp marks) marks
7449 (append marks nil))) ; Transform to list.
7452 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
7453 (memq (gnus-data-mark (car data)) marks))
7454 (push (gnus-data-number (car data)) articles))
7455 (setq data (cdr data)))
7456 (gnus-summary-limit articles))
7457 (gnus-summary-position-point)))
7459 (defun gnus-summary-limit-to-score (score)
7460 "Limit to articles with score at or above SCORE."
7461 (interactive "NLimit to articles with score of at least: ")
7462 (let ((data gnus-newsgroup-data)
7465 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
7467 (push (gnus-data-number (car data)) articles))
7468 (setq data (cdr data)))
7470 (gnus-summary-limit articles)
7471 (gnus-summary-position-point))))
7473 (defun gnus-summary-limit-to-unseen ()
7474 "Limit to unseen articles."
7477 (gnus-summary-limit gnus-newsgroup-unseen)
7478 (gnus-summary-position-point)))
7480 (defun gnus-summary-limit-include-thread (id)
7481 "Display all the hidden articles that is in the thread with ID in it.
7482 When called interactively, ID is the Message-ID of the current
7484 (interactive (list (mail-header-id (gnus-summary-article-header))))
7485 (let ((articles (gnus-articles-in-thread
7486 (gnus-id-to-thread (gnus-root-id id)))))
7488 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7489 (gnus-summary-limit-include-matching-articles
7491 (regexp-quote (gnus-simplify-subject-re
7492 (mail-header-subject (gnus-id-to-header id)))))
7493 (gnus-summary-position-point))))
7495 (defun gnus-summary-limit-include-matching-articles (header regexp)
7496 "Display all the hidden articles that have HEADERs that match REGEXP."
7497 (interactive (list (read-string "Match on header: ")
7498 (read-string "Regexp: ")))
7499 (let ((articles (gnus-find-matching-articles header regexp)))
7501 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
7502 (gnus-summary-position-point))))
7504 (defun gnus-summary-limit-include-dormant ()
7505 "Display all the hidden articles that are marked as dormant.
7506 Note that this command only works on a subset of the articles currently
7507 fetched for this group."
7509 (unless gnus-newsgroup-dormant
7510 (error "There are no dormant articles in this group"))
7512 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
7513 (gnus-summary-position-point)))
7515 (defun gnus-summary-limit-exclude-dormant ()
7516 "Hide all dormant articles."
7519 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
7520 (gnus-summary-position-point)))
7522 (defun gnus-summary-limit-exclude-childless-dormant ()
7523 "Hide all dormant articles that have no children."
7525 (let ((data (gnus-data-list t))
7526 articles d children)
7527 ;; Find all articles that are either not dormant or have
7529 (while (setq d (pop data))
7530 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
7532 (gnus-article-children (gnus-data-number d)))
7535 (when (memq (car children) articles)
7540 (push (gnus-data-number d) articles)))
7543 (gnus-summary-limit articles)
7544 (gnus-summary-position-point))))
7546 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
7547 "Mark all unread excluded articles as read.
7548 If ALL, mark even excluded ticked and dormants as read."
7550 (setq gnus-newsgroup-limit (sort gnus-newsgroup-limit '<))
7551 (let ((articles (gnus-sorted-ndifference
7553 (mapcar (lambda (h) (mail-header-number h))
7554 gnus-newsgroup-headers)
7556 gnus-newsgroup-limit))
7558 (setq gnus-newsgroup-unreads
7559 (gnus-sorted-intersection gnus-newsgroup-unreads
7560 gnus-newsgroup-limit))
7562 (setq gnus-newsgroup-dormant nil
7563 gnus-newsgroup-marked nil
7564 gnus-newsgroup-reads
7566 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
7567 gnus-newsgroup-reads))
7568 (while (setq article (pop articles))
7569 (unless (or (memq article gnus-newsgroup-dormant)
7570 (memq article gnus-newsgroup-marked))
7571 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
7573 (defun gnus-summary-limit (articles &optional pop)
7575 ;; We pop the previous limit off the stack and use that.
7576 (setq articles (car gnus-newsgroup-limits)
7577 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
7578 ;; We use the new limit, so we push the old limit on the stack.
7579 (push gnus-newsgroup-limit gnus-newsgroup-limits))
7581 (setq gnus-newsgroup-limit articles)
7582 (let ((total (length gnus-newsgroup-data))
7583 (data (gnus-data-find-list (gnus-summary-article-number)))
7584 (gnus-summary-mark-below nil) ; Inhibit this.
7586 ;; This will do all the work of generating the new summary buffer
7587 ;; according to the new limit.
7588 (gnus-summary-prepare)
7589 ;; Hide any threads, possibly.
7590 (gnus-summary-maybe-hide-threads)
7591 ;; Try to return to the article you were at, or one in the
7594 ;; We try to find some article after the current one.
7596 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
7599 (setq data (cdr data))))
7601 ;; If there is no data, that means that we were after the last
7602 ;; article. The same goes when we can't find any articles
7603 ;; after the current one.
7604 (goto-char (point-max))
7605 (gnus-summary-find-prev))
7606 (gnus-set-mode-line 'summary)
7607 ;; We return how many articles were removed from the summary
7608 ;; buffer as a result of the new limit.
7609 (- total (length gnus-newsgroup-data))))
7611 (defsubst gnus-invisible-cut-children (threads)
7614 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
7619 (defsubst gnus-cut-thread (thread)
7620 "Go forwards in the thread until we find an article that we want to display."
7621 (when (or (eq gnus-fetch-old-headers 'some)
7622 (eq gnus-fetch-old-headers 'invisible)
7623 (numberp gnus-fetch-old-headers)
7624 (eq gnus-build-sparse-threads 'some)
7625 (eq gnus-build-sparse-threads 'more))
7626 ;; Deal with old-fetched headers and sparse threads.
7630 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
7631 (gnus-summary-article-ancient-p
7632 (mail-header-number (car thread))))
7633 (if (or (<= (length (cdr thread)) 1)
7634 (eq gnus-fetch-old-headers 'invisible))
7635 (setq gnus-newsgroup-limit
7636 (delq (mail-header-number (car thread))
7637 gnus-newsgroup-limit)
7638 thread (cadr thread))
7639 (when (gnus-invisible-cut-children (cdr thread))
7640 (let ((th (cdr thread)))
7642 (if (memq (mail-header-number (caar th))
7643 gnus-newsgroup-limit)
7644 (setq thread (car th)
7646 (setq th (cdr th))))))))))
7649 (defun gnus-cut-threads (threads)
7650 "Cut off all uninteresting articles from the beginning of threads."
7651 (when (or (eq gnus-fetch-old-headers 'some)
7652 (eq gnus-fetch-old-headers 'invisible)
7653 (numberp gnus-fetch-old-headers)
7654 (eq gnus-build-sparse-threads 'some)
7655 (eq gnus-build-sparse-threads 'more))
7658 (setcar th (gnus-cut-thread (car th)))
7659 (setq th (cdr th)))))
7660 ;; Remove nixed out threads.
7663 (defun gnus-summary-initial-limit (&optional show-if-empty)
7664 "Figure out what the initial limit is supposed to be on group entry.
7665 This entails weeding out unwanted dormants, low-scored articles,
7666 fetch-old-headers verbiage, and so on."
7667 ;; Most groups have nothing to remove.
7668 (if (or gnus-inhibit-limiting
7669 (and (null gnus-newsgroup-dormant)
7670 (eq gnus-newsgroup-display 'gnus-not-ignore)
7671 (not (eq gnus-fetch-old-headers 'some))
7672 (not (numberp gnus-fetch-old-headers))
7673 (not (eq gnus-fetch-old-headers 'invisible))
7674 (null gnus-summary-expunge-below)
7675 (not (eq gnus-build-sparse-threads 'some))
7676 (not (eq gnus-build-sparse-threads 'more))
7677 (null gnus-thread-expunge-below)
7678 (not gnus-use-nocem)))
7680 (push gnus-newsgroup-limit gnus-newsgroup-limits)
7681 (setq gnus-newsgroup-limit nil)
7684 (unless (car (symbol-value node))
7685 ;; These threads have no parents -- they are roots.
7686 (let ((nodes (cdr (symbol-value node)))
7689 (if (and gnus-thread-expunge-below
7690 (< (gnus-thread-total-score (car nodes))
7691 gnus-thread-expunge-below))
7692 (gnus-expunge-thread (pop nodes))
7693 (setq thread (pop nodes))
7694 (gnus-summary-limit-children thread))))))
7695 gnus-newsgroup-dependencies)
7696 ;; If this limitation resulted in an empty group, we might
7697 ;; pop the previous limit and use it instead.
7698 (when (and (not gnus-newsgroup-limit)
7700 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
7701 gnus-newsgroup-limit))
7703 (defun gnus-summary-limit-children (thread)
7704 "Return 1 if this subthread is visible and 0 if it is not."
7705 ;; First we get the number of visible children to this thread. This
7706 ;; is done by recursing down the thread using this function, so this
7707 ;; will really go down to a leaf article first, before slowly
7708 ;; working its way up towards the root.
7710 (let* ((max-lisp-eval-depth 5000)
7713 (apply '+ (mapcar 'gnus-summary-limit-children
7716 (number (mail-header-number (car thread)))
7719 (not (memq number gnus-newsgroup-marked))
7721 ;; If this article is dormant and has absolutely no visible
7722 ;; children, then this article isn't visible.
7723 (and (memq number gnus-newsgroup-dormant)
7725 ;; If this is "fetch-old-headered" and there is no
7726 ;; visible children, then we don't want this article.
7727 (and (or (eq gnus-fetch-old-headers 'some)
7728 (numberp gnus-fetch-old-headers))
7729 (gnus-summary-article-ancient-p number)
7731 ;; If this is "fetch-old-headered" and `invisible', then
7732 ;; we don't want this article.
7733 (and (eq gnus-fetch-old-headers 'invisible)
7734 (gnus-summary-article-ancient-p number))
7735 ;; If this is a sparsely inserted article with no children,
7736 ;; we don't want it.
7737 (and (eq gnus-build-sparse-threads 'some)
7738 (gnus-summary-article-sparse-p number)
7740 ;; If we use expunging, and this article is really
7741 ;; low-scored, then we don't want this article.
7742 (when (and gnus-summary-expunge-below
7744 (or (cdr (assq number gnus-newsgroup-scored))
7745 gnus-summary-default-score))
7746 gnus-summary-expunge-below))
7747 ;; We increase the expunge-tally here, but that has
7748 ;; nothing to do with the limits, really.
7749 (incf gnus-newsgroup-expunged-tally)
7750 ;; We also mark as read here, if that's wanted.
7751 (when (and gnus-summary-mark-below
7752 (< score gnus-summary-mark-below))
7753 (setq gnus-newsgroup-unreads
7754 (delq number gnus-newsgroup-unreads))
7755 (if gnus-newsgroup-auto-expire
7756 (push number gnus-newsgroup-expirable)
7757 (push (cons number gnus-low-score-mark)
7758 gnus-newsgroup-reads)))
7760 ;; Do the `display' group parameter.
7761 (and gnus-newsgroup-display
7762 (not (funcall gnus-newsgroup-display)))
7763 ;; Check NoCeM things.
7764 (if (and gnus-use-nocem
7765 (gnus-nocem-unwanted-article-p
7766 (mail-header-id (car thread))))
7768 (setq gnus-newsgroup-unreads
7769 (delq number gnus-newsgroup-unreads))
7771 ;; Nope, invisible article.
7773 ;; Ok, this article is to be visible, so we add it to the limit
7775 (push number gnus-newsgroup-limit)
7778 (defun gnus-expunge-thread (thread)
7779 "Mark all articles in THREAD as read."
7780 (let* ((number (mail-header-number (car thread))))
7781 (incf gnus-newsgroup-expunged-tally)
7782 ;; We also mark as read here, if that's wanted.
7783 (setq gnus-newsgroup-unreads
7784 (delq number gnus-newsgroup-unreads))
7785 (if gnus-newsgroup-auto-expire
7786 (push number gnus-newsgroup-expirable)
7787 (push (cons number gnus-low-score-mark)
7788 gnus-newsgroup-reads)))
7789 ;; Go recursively through all subthreads.
7790 (mapcar 'gnus-expunge-thread (cdr thread)))
7792 ;; Summary article oriented commands
7794 (defun gnus-summary-refer-parent-article (n)
7795 "Refer parent article N times.
7796 If N is negative, go to ancestor -N instead.
7797 The difference between N and the number of articles fetched is returned."
7801 (when (not (natnump n))
7806 (setq header (gnus-summary-article-header))
7807 (if (and (eq (mail-header-number header)
7808 (cdr gnus-article-current))
7809 (equal gnus-newsgroup-name
7810 (car gnus-article-current)))
7811 ;; If we try to find the parent of the currently
7812 ;; displayed article, then we take a look at the actual
7813 ;; References header, since this is slightly more
7814 ;; reliable than the References field we got from the
7817 (set-buffer gnus-original-article-buffer)
7818 (nnheader-narrow-to-headers)
7819 (unless (setq ref (message-fetch-field "references"))
7820 (setq ref (message-fetch-field "in-reply-to")))
7823 ;; It's not the current article, so we take a bet on
7824 ;; the value we got from the server.
7825 (mail-header-references header)))
7827 (not (equal ref "")))
7828 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
7829 (gnus-message 1 "Couldn't find parent"))
7830 (gnus-message 1 "No references in article %d"
7831 (gnus-summary-article-number))
7834 (gnus-summary-position-point)
7837 (defun gnus-summary-refer-references ()
7838 "Fetch all articles mentioned in the References header.
7839 Return the number of articles fetched."
7841 (let ((ref (mail-header-references (gnus-summary-article-header)))
7842 (current (gnus-summary-article-number))
7846 (error "No References in the current article")
7847 ;; For each Message-ID in the References header...
7848 (while (string-match "<[^>]*>" ref)
7850 ;; ... fetch that article.
7851 (gnus-summary-refer-article
7852 (prog1 (match-string 0 ref)
7853 (setq ref (substring ref (match-end 0))))))
7854 (gnus-summary-goto-subject current)
7855 (gnus-summary-position-point)
7858 (defun gnus-summary-refer-thread (&optional limit)
7859 "Fetch all articles in the current thread.
7860 If LIMIT (the numerical prefix), fetch that many old headers instead
7861 of what's specified by the `gnus-refer-thread-limit' variable."
7863 (let ((id (mail-header-id (gnus-summary-article-header)))
7864 (limit (if limit (prefix-numeric-value limit)
7865 gnus-refer-thread-limit)))
7866 ;; We want to fetch LIMIT *old* headers, but we also have to
7867 ;; re-fetch all the headers in the current buffer, because many of
7868 ;; them may be undisplayed. So we adjust LIMIT.
7869 (when (numberp limit)
7870 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
7871 (unless (eq gnus-fetch-old-headers 'invisible)
7872 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
7873 ;; Retrieve the headers and read them in.
7874 (if (eq (gnus-retrieve-headers
7875 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
7877 (gnus-build-all-threads)
7878 (error "Can't fetch thread from backends that don't support NOV"))
7879 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
7880 (gnus-summary-limit-include-thread id)))
7882 (defun gnus-summary-refer-article (message-id)
7883 "Fetch an article specified by MESSAGE-ID."
7884 (interactive "sMessage-ID: ")
7885 (when (and (stringp message-id)
7886 (not (zerop (length message-id))))
7887 ;; Construct the correct Message-ID if necessary.
7888 ;; Suggested by tale@pawl.rpi.edu.
7889 (unless (string-match "^<" message-id)
7890 (setq message-id (concat "<" message-id)))
7891 (unless (string-match ">$" message-id)
7892 (setq message-id (concat message-id ">")))
7893 (let* ((header (gnus-id-to-header message-id))
7895 (gnus-summary-article-sparse-p
7896 (mail-header-number header))
7897 (memq (mail-header-number header)
7898 gnus-newsgroup-limit)))
7901 ;; If the article is present in the buffer we just go to it.
7903 (or (not (gnus-summary-article-sparse-p
7904 (mail-header-number header)))
7907 (gnus-summary-goto-article
7908 (mail-header-number header) nil t)
7910 (gnus-summary-update-article (mail-header-number header)))))
7912 ;; We fetch the article.
7914 (dolist (gnus-override-method (gnus-refer-article-methods))
7915 (gnus-check-server gnus-override-method)
7916 ;; Fetch the header, and display the article.
7917 (when (setq number (gnus-summary-insert-subject message-id))
7918 (gnus-summary-select-article nil nil nil number)
7920 (gnus-message 3 "Couldn't fetch article %s" message-id)))))))
7922 (defun gnus-refer-article-methods ()
7923 "Return a list of referable methods."
7925 ;; No method, so we default to current and native.
7926 ((null gnus-refer-article-method)
7927 (list gnus-current-select-method gnus-select-method))
7929 ((eq 'current gnus-refer-article-method)
7930 (list gnus-current-select-method))
7931 ;; List of select methods.
7932 ((not (and (symbolp (car gnus-refer-article-method))
7933 (assq (car gnus-refer-article-method) nnoo-definition-alist)))
7935 (dolist (method gnus-refer-article-method)
7936 (push (if (eq 'current method)
7937 gnus-current-select-method
7941 ;; One single select method.
7943 (list gnus-refer-article-method))))
7945 (defun gnus-summary-edit-parameters ()
7946 "Edit the group parameters of the current group."
7948 (gnus-group-edit-group gnus-newsgroup-name 'params))
7950 (defun gnus-summary-customize-parameters ()
7951 "Customize the group parameters of the current group."
7953 (gnus-group-customize gnus-newsgroup-name))
7955 (defun gnus-summary-enter-digest-group (&optional force)
7956 "Enter an nndoc group based on the current article.
7957 If FORCE, force a digest interpretation. If not, try
7958 to guess what the document format is."
7960 (let ((conf gnus-current-window-configuration))
7962 (gnus-summary-select-article))
7963 (setq gnus-current-window-configuration conf)
7964 (let* ((name (format "%s-%d"
7965 (gnus-group-prefixed-name
7966 gnus-newsgroup-name (list 'nndoc ""))
7968 (set-buffer gnus-summary-buffer)
7969 gnus-current-article)))
7970 (ogroup gnus-newsgroup-name)
7971 (params (append (gnus-info-params (gnus-get-info ogroup))
7972 (list (cons 'to-group ogroup))
7973 (list (cons 'save-article-group ogroup))))
7974 (case-fold-search t)
7975 (buf (current-buffer))
7978 (set-buffer gnus-original-article-buffer)
7979 ;; Have the digest group inherit the main mail address of
7980 ;; the parent article.
7981 (when (setq to-address (or (gnus-fetch-field "reply-to")
7982 (gnus-fetch-field "from")))
7983 (setq params (append
7984 (list (cons 'to-address
7985 (funcall gnus-decode-encoded-word-function
7987 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
7988 (insert-buffer-substring gnus-original-article-buffer)
7989 ;; Remove lines that may lead nndoc to misinterpret the
7992 (goto-char (point-min))
7993 (or (search-forward "\n\n" nil t) (point)))
7994 (goto-char (point-min))
7995 (delete-matching-lines "^Path:\\|^From ")
7998 (if (let ((gnus-newsgroup-ephemeral-charset gnus-newsgroup-charset)
7999 (gnus-newsgroup-ephemeral-ignored-charsets
8000 gnus-newsgroup-ignored-charsets))
8001 (gnus-group-read-ephemeral-group
8002 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
8004 ,(if force 'mbox 'guess)))
8006 `((adapt-file . ,(gnus-score-file-name gnus-newsgroup-name
8008 ;; Make all postings to this group go to the parent group.
8009 (nconc (gnus-info-params (gnus-get-info name))
8011 ;; Couldn't select this doc group.
8012 (switch-to-buffer buf)
8013 (gnus-set-global-variables)
8014 (gnus-configure-windows 'summary)
8015 (gnus-message 3 "Article couldn't be entered?"))
8016 (kill-buffer dig)))))
8018 (defun gnus-summary-read-document (n)
8019 "Open a new group based on the current article(s).
8020 This will allow you to read digests and other similar
8021 documents as newsgroups.
8022 Obeys the standard process/prefix convention."
8024 (let* ((articles (gnus-summary-work-articles n))
8025 (ogroup gnus-newsgroup-name)
8026 (params (append (gnus-info-params (gnus-get-info ogroup))
8027 (list (cons 'to-group ogroup))))
8028 article group egroup groups vgroup)
8029 (while (setq article (pop articles))
8030 (setq group (format "%s-%d" gnus-newsgroup-name article))
8031 (gnus-summary-remove-process-mark article)
8032 (when (gnus-summary-display-article article)
8035 (insert-buffer-substring gnus-original-article-buffer)
8036 ;; Remove some headers that may lead nndoc to make
8038 (message-narrow-to-head)
8039 (goto-char (point-min))
8040 (delete-matching-lines "^\\(Path\\):\\|^From ")
8043 (gnus-group-read-ephemeral-group
8044 group `(nndoc ,group (nndoc-address ,(current-buffer))
8045 (nndoc-article-type guess))
8048 ;; Make all postings to this group go to the parent group.
8049 (nconc (gnus-info-params (gnus-get-info egroup))
8051 (push egroup groups))
8052 ;; Couldn't select this doc group.
8053 (gnus-error 3 "Article couldn't be entered"))))))
8054 ;; Now we have selected all the documents.
8057 (error "None of the articles could be interpreted as documents"))
8058 ((gnus-group-read-ephemeral-group
8059 (setq vgroup (format
8060 "nnvirtual:%s-%s" gnus-newsgroup-name
8061 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
8062 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
8064 (cons (current-buffer) 'summary)))
8066 (error "Couldn't select virtual nndoc group")))))
8068 (defun gnus-summary-isearch-article (&optional regexp-p)
8069 "Do incremental search forward on the current article.
8070 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
8072 (let* ((gnus-inhibit-treatment t)
8073 (old (gnus-summary-select-article)))
8074 (gnus-configure-windows 'article)
8075 (gnus-eval-in-buffer-window gnus-article-buffer
8079 (gnus-article-show-all-headers))
8080 (goto-char (point-min))
8081 (isearch-forward regexp-p)))))
8083 (defun gnus-summary-search-article-forward (regexp &optional backward)
8084 "Search for an article containing REGEXP forward.
8085 If BACKWARD, search backward instead."
8088 (format "Search article %s (regexp%s): "
8089 (if current-prefix-arg "backward" "forward")
8090 (if gnus-last-search-regexp
8091 (concat ", default " gnus-last-search-regexp)
8093 current-prefix-arg))
8094 (if (string-equal regexp "")
8095 (setq regexp (or gnus-last-search-regexp ""))
8096 (setq gnus-last-search-regexp regexp)
8097 (setq gnus-article-before-search gnus-current-article))
8098 ;; Intentionally set gnus-last-article.
8099 (setq gnus-last-article gnus-article-before-search)
8100 (let ((gnus-last-article gnus-last-article))
8101 (if (gnus-summary-search-article regexp backward)
8102 (gnus-summary-show-thread)
8103 (error "Search failed: \"%s\"" regexp))))
8105 (defun gnus-summary-search-article-backward (regexp)
8106 "Search for an article containing REGEXP backward."
8109 (format "Search article backward (regexp%s): "
8110 (if gnus-last-search-regexp
8111 (concat ", default " gnus-last-search-regexp)
8113 (gnus-summary-search-article-forward regexp 'backward))
8116 (defmacro gnus-summary-search-article-position-point (regexp backward)
8117 "Dehighlight the last matched text and goto the beginning position."
8118 (` (if (and gnus-summary-search-article-matched-data
8119 (let ((text (caddr gnus-summary-search-article-matched-data))
8120 (inhibit-read-only t)
8123 (goto-char (car gnus-summary-search-article-matched-data))
8124 (cadr gnus-summary-search-article-matched-data))
8126 (string-match (, regexp) text)))
8127 (if (, backward) (beginning-of-line) (end-of-line))
8128 (goto-char (if (, backward) (point-max) (point-min))))))
8130 (defmacro gnus-summary-search-article-highlight-goto-x-face (opoint)
8131 "Place point where X-Face image is displayed."
8132 (if (featurep 'xemacs)
8133 (` (let ((end (if (search-forward "\n\n" nil t)
8134 (goto-char (1- (point)))
8137 (or (search-backward "\n\n" nil t) (goto-char (point-min)))
8138 (unless (and (re-search-forward "^From:" end t)
8139 (setq extent (extent-at (point)))
8140 (extent-begin-glyph extent))
8141 (goto-char (, opoint)))))
8142 (` (let ((end (if (search-forward "\n\n" nil t)
8143 (goto-char (1- (point)))
8145 (start (or (search-backward "\n\n" nil t) (point-min))))
8147 (or (text-property-any start end 'x-face-image t);; x-face-e21
8148 (text-property-any start end 'x-face-mule-bitmap-image t)
8151 (defmacro gnus-summary-search-article-highlight-matched-text
8152 (backward treated x-face)
8153 "Highlight matched text in the function `gnus-summary-search-article'."
8154 (` (let ((start (set-marker (make-marker) (match-beginning 0)))
8155 (end (set-marker (make-marker) (match-end 0)))
8156 (inhibit-read-only t)
8160 (let ((items (mapcar 'car gnus-treatment-function-alist)))
8162 (lambda (item) (setq items (delq item items)))
8163 '(gnus-treat-buttonize
8164 gnus-treat-fill-article
8165 gnus-treat-fill-long-lines
8166 gnus-treat-emphasize
8167 gnus-treat-highlight-headers
8168 gnus-treat-highlight-citation
8169 gnus-treat-highlight-signature
8170 gnus-treat-overstrike
8171 gnus-treat-display-xface
8172 gnus-treat-buttonize-head
8173 gnus-treat-decode-article-as-default-mime-charset))
8174 (static-if (featurep 'xemacs)
8176 (cons '(x-face-mule-delete-x-face-field
8179 (gnus-treat-display-xface
8180 (when (, x-face) gnus-treat-display-xface)))
8181 (gnus-article-prepare-mime-display)))
8182 (goto-char (if (, backward) start end))
8184 (gnus-summary-search-article-highlight-goto-x-face (point)))
8185 (setq gnus-summary-search-article-matched-data
8186 (list start end (buffer-substring start end)))
8187 (unless (eq start end);; matched text has been deleted. :-<
8188 (put-text-property start end 'face
8189 (or (find-face 'isearch)
8190 'secondary-selection))))))
8193 (defun gnus-summary-search-article (regexp &optional backward)
8194 "Search for an article containing REGEXP.
8195 Optional argument BACKWARD means do search for backward.
8196 `gnus-select-article-hook' is not called during the search."
8197 ;; We have to require this here to make sure that the following
8198 ;; dynamic binding isn't shadowed by autoloading.
8199 (require 'gnus-async)
8201 (let ((gnus-select-article-hook nil) ;Disable hook.
8202 (gnus-article-prepare-hook nil)
8203 (gnus-mark-article-hook nil) ;Inhibit marking as read.
8204 (gnus-use-article-prefetch nil)
8205 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
8206 (gnus-use-trees nil) ;Inhibit updating tree buffer.
8207 (sum (current-buffer))
8210 (gnus-save-hidden-threads
8211 (static-if (featurep 'xemacs)
8212 (let ((gnus-inhibit-treatment t))
8213 (setq treated (eq 'old (gnus-summary-select-article)))
8215 (not (and (gnus-buffer-live-p gnus-article-buffer)
8216 (window-live-p (get-buffer-window
8217 gnus-article-buffer t)))))
8218 (gnus-summary-select-article nil t)
8219 (setq treated nil)))
8220 (let ((gnus-inhibit-treatment t)
8221 (x-face-mule-delete-x-face-field 'never))
8222 (setq treated (eq 'old (gnus-summary-select-article)))
8225 (and (gnus-buffer-live-p gnus-article-buffer)
8226 (window-live-p (get-buffer-window
8227 gnus-article-buffer t))
8228 (or (not (string-match "^\\^X-Face:" regexp))
8229 (with-current-buffer gnus-article-buffer
8230 gnus-summary-search-article-matched-data)))))
8231 (gnus-summary-select-article nil t)
8232 (setq treated nil))))
8233 (set-buffer gnus-article-buffer)
8237 (gnus-article-show-all-headers)
8238 (gnus-summary-search-article-position-point regexp backward))
8239 (goto-char (if backward (point-max) (point-min))))
8241 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
8243 (re-search-backward regexp nil t)
8244 (re-search-forward regexp nil t))
8245 ;; We found the regexp.
8247 (gnus-summary-search-article-highlight-matched-text
8248 backward treated (string-match "^\\^X-Face:" regexp))
8251 (/ (- 2 (window-height
8252 (get-buffer-window gnus-article-buffer t)))
8255 (get-buffer-window (current-buffer))
8258 (setq point (point)))
8259 ;; We didn't find it, so we go to the next article.
8262 (while (eq found 'not)
8263 (if (not (if backward (gnus-summary-find-prev)
8264 (gnus-summary-find-next)))
8265 ;; No more articles.
8267 ;; Select the next article and adjust point.
8268 (unless (gnus-summary-article-sparse-p
8269 (gnus-summary-article-number))
8271 (let ((gnus-inhibit-treatment t))
8272 (gnus-summary-select-article))
8274 (set-buffer gnus-article-buffer)
8276 (goto-char (if backward (point-max) (point-min))))))))
8277 (gnus-message 7 ""))
8278 ;; Return whether we found the regexp.
8279 (when (eq found 'found)
8281 (gnus-summary-show-thread)
8282 (gnus-summary-goto-subject gnus-current-article)
8283 (gnus-summary-position-point)
8286 (defun gnus-find-matching-articles (header regexp)
8287 "Return a list of all articles that match REGEXP on HEADER.
8288 This search includes all articles in the current group that Gnus has
8289 fetched headers for, whether they are displayed or not."
8290 (let ((articles nil)
8291 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
8292 (case-fold-search t))
8293 (dolist (header gnus-newsgroup-headers)
8294 (when (string-match regexp (funcall func header))
8295 (push (mail-header-number header) articles)))
8296 (nreverse articles)))
8298 (defun gnus-summary-find-matching (header regexp &optional backward unread
8299 not-case-fold not-matching)
8300 "Return a list of all articles that match REGEXP on HEADER.
8301 The search stars on the current article and goes forwards unless
8302 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
8303 If UNREAD is non-nil, only unread articles will
8304 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
8305 in the comparisons. If NOT-MATCHING, return a list of all articles that
8306 not match REGEXP on HEADER."
8307 (let ((case-fold-search (not not-case-fold))
8310 (if (eq (car header) 'extra)
8313 (or (cdr (assq ',(cdr header) (mail-header-extra h)))
8315 (error "%s is an invalid header" header))
8316 (unless (fboundp (intern (concat "mail-header-" header)))
8317 (error "%s is not a valid header" header))
8318 (setq func `(lambda (h) (,(intern (concat "mail-header-" header)) h))))
8319 (dolist (d (if (eq backward 'all)
8321 (gnus-data-find-list
8322 (gnus-summary-article-number)
8323 (gnus-data-list backward))))
8324 (when (and (or (not unread) ; We want all articles...
8325 (gnus-data-unread-p d)) ; Or just unreads.
8326 (vectorp (gnus-data-header d)) ; It's not a pseudo.
8330 (funcall func (gnus-data-header d))))
8331 (string-match regexp
8332 (funcall func (gnus-data-header d)))))
8333 (push (gnus-data-number d) articles))) ; Success!
8334 (nreverse articles)))
8336 (defun gnus-summary-execute-command (header regexp command &optional backward)
8337 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
8338 If HEADER is an empty string (or nil), the match is done on the entire
8339 article. If BACKWARD (the prefix) is non-nil, search backward instead."
8341 (list (let ((completion-ignore-case t))
8344 (mapcar (lambda (header) (list (format "%s" header)))
8346 '("Number" "Subject" "From" "Lines" "Date"
8347 "Message-ID" "Xref" "References" "Body")
8348 gnus-extra-headers))
8349 nil 'require-match))
8350 (read-string "Regexp: ")
8351 (read-key-sequence "Command: ")
8352 current-prefix-arg))
8353 (when (equal header "Body")
8355 ;; Hidden thread subtrees must be searched as well.
8356 (gnus-summary-show-all-threads)
8357 ;; We don't want to change current point nor window configuration.
8359 (save-window-excursion
8361 gnus-treat-strip-trailing-blank-lines
8362 gnus-treat-strip-leading-blank-lines
8363 gnus-treat-strip-multiple-blank-lines
8364 gnus-treat-hide-boring-headers
8365 gnus-treat-fold-newsgroups
8366 gnus-article-prepare-hook)
8367 (gnus-message 6 "Executing %s..." (key-description command))
8368 ;; We'd like to execute COMMAND interactively so as to give arguments.
8369 (gnus-execute header regexp
8370 `(call-interactively ',(key-binding command))
8372 (gnus-message 6 "Executing %s...done" (key-description command))))))
8374 (defun gnus-summary-beginning-of-article ()
8375 "Scroll the article back to the beginning."
8377 (gnus-summary-select-article)
8378 (gnus-configure-windows 'article)
8379 (gnus-eval-in-buffer-window gnus-article-buffer
8381 (goto-char (point-min))
8382 (when gnus-page-broken
8383 (gnus-narrow-to-page))))
8385 (defun gnus-summary-end-of-article ()
8386 "Scroll to the end of the article."
8388 (gnus-summary-select-article)
8389 (gnus-configure-windows 'article)
8390 (gnus-eval-in-buffer-window gnus-article-buffer
8392 (goto-char (point-max))
8394 (when gnus-page-broken
8395 (gnus-narrow-to-page))))
8397 (defun gnus-summary-print-truncate-and-quote (string &optional len)
8398 "Truncate to LEN and quote all \"(\"'s in STRING."
8399 (gnus-replace-in-string (if (and len (> (length string) len))
8400 (substring string 0 len)
8404 (defun gnus-summary-print-article (&optional filename n)
8405 "Generate and print a PostScript image of the N next (mail) articles.
8407 If N is negative, print the N previous articles. If N is nil and articles
8408 have been marked with the process mark, print these instead.
8410 If the optional first argument FILENAME is nil, send the image to the
8411 printer. If FILENAME is a string, save the PostScript image in a file with
8412 that name. If FILENAME is a number, prompt the user for the name of the file
8414 (interactive (list (ps-print-preprint current-prefix-arg)))
8415 (dolist (article (gnus-summary-work-articles n))
8416 (gnus-summary-select-article nil nil 'pseudo article)
8417 (gnus-eval-in-buffer-window gnus-article-buffer
8418 (gnus-print-buffer))
8419 (gnus-summary-remove-process-mark article))
8420 (ps-despool filename))
8422 (defun gnus-print-buffer ()
8423 (let ((buffer (generate-new-buffer " *print*")))
8426 (copy-to-buffer buffer (point-min) (point-max))
8428 (gnus-article-delete-invisible-text)
8429 (gnus-remove-text-with-property 'gnus-decoration)
8430 (when (gnus-visual-p 'article-highlight 'highlight)
8431 ;; Copy-to-buffer doesn't copy overlay. So redo
8433 (let ((gnus-article-buffer buffer))
8434 (gnus-article-highlight-citation t)
8435 (gnus-article-highlight-signature)))
8436 (let ((ps-left-header
8439 (gnus-summary-print-truncate-and-quote
8440 (mail-header-subject gnus-current-headers)
8443 (gnus-summary-print-truncate-and-quote
8444 (mail-header-from gnus-current-headers)
8448 "/pagenumberstring load"
8450 (mail-header-date gnus-current-headers) ")"))))
8451 (gnus-run-hooks 'gnus-ps-print-hook)
8454 (ps-spool-buffer-with-faces)
8455 (ps-spool-buffer)))))
8456 (kill-buffer buffer))))
8458 (defun gnus-summary-show-article (&optional arg)
8459 "Force redisplaying of the current article.
8460 If ARG (the prefix) is a number, show the article with the charset
8461 defined in `gnus-summary-show-article-charset-alist', or the charset
8463 If ARG (the prefix) is non-nil and not a number, show the raw article
8464 without any article massaging functions being run. Normally, the key strokes
8469 (gnus-summary-show-article t)
8470 (let* ((gnus-newsgroup-charset
8471 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
8472 (mm-read-coding-system
8473 "View as charset: " ;; actually it is coding system.
8475 (set-buffer gnus-article-buffer)
8476 (mm-detect-coding-region (point) (point-max))))))
8477 (default-mime-charset gnus-newsgroup-charset)
8478 (gnus-newsgroup-ignored-charsets 'gnus-all))
8479 (gnus-summary-select-article nil 'force)
8480 (let ((deps gnus-newsgroup-dependencies)
8483 (set-buffer gnus-original-article-buffer)
8485 (message-narrow-to-head)
8486 (setq head (buffer-string))
8487 (goto-char (point-min))
8488 (unless (re-search-forward "^lines:[ \t]\\([0-9]+\\)" nil t)
8489 (goto-char (point-max))
8491 (setq lines (1- (count-lines (point) (point-max))))))
8493 (insert (format "211 %d Article retrieved.\n"
8494 (cdr gnus-article-current)))
8496 (if lines (insert (format "Lines: %d\n" lines)))
8498 (let ((nntp-server-buffer (current-buffer)))
8499 (setq header (car (gnus-get-newsgroup-headers deps t))))))
8500 (gnus-data-set-header
8501 (gnus-data-find (cdr gnus-article-current))
8503 (gnus-summary-update-article-line
8504 (cdr gnus-article-current) header)
8505 (when (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
8506 (gnus-summary-update-secondary-mark (cdr gnus-article-current))))))
8508 ;; Select the article the normal way.
8509 (gnus-summary-select-article nil 'force))
8511 ;; We have to require this here to make sure that the following
8512 ;; dynamic binding isn't shadowed by autoloading.
8513 (require 'gnus-async)
8515 ;; Bind the article treatment functions to nil.
8516 (let ((gnus-have-all-headers t)
8517 gnus-article-prepare-hook
8518 gnus-article-decode-hook
8521 (gnus-inhibit-treatment t))
8522 (gnus-summary-select-article nil 'force))))
8523 (gnus-summary-goto-subject gnus-current-article)
8524 (gnus-summary-position-point))
8526 (defun gnus-summary-show-raw-article ()
8527 "Show the raw article without any article massaging functions being run."
8529 (gnus-summary-show-article t))
8531 (defun gnus-summary-verbose-headers (&optional arg)
8532 "Toggle permanent full header display.
8533 If ARG is a positive number, turn header display on.
8534 If ARG is a negative number, turn header display off."
8536 (setq gnus-show-all-headers
8537 (cond ((or (not (numberp arg))
8539 (not gnus-show-all-headers))
8542 (gnus-summary-show-article))
8544 (defun gnus-summary-toggle-header (&optional arg)
8545 "Show the headers if they are hidden, or hide them if they are shown.
8546 If ARG is a positive number, show the entire header.
8547 If ARG is a negative number, hide the unwanted header lines."
8549 (let ((window (and (gnus-buffer-live-p gnus-article-buffer)
8550 (get-buffer-window gnus-article-buffer t))))
8551 (with-current-buffer gnus-article-buffer
8553 (article-narrow-to-head)
8554 (let* ((buffer-read-only nil)
8555 (inhibit-point-motion-hooks t)
8556 (hidden (if (numberp arg)
8558 (gnus-article-hidden-text-p 'headers)))
8560 (delete-region (point-min) (point-max))
8561 (with-current-buffer gnus-original-article-buffer
8562 (goto-char (setq s (point-min)))
8563 (setq e (if (search-forward "\n\n" nil t)
8566 (insert-buffer-substring gnus-original-article-buffer s e)
8567 (article-decode-encoded-words)
8569 (let ((gnus-treat-hide-headers nil)
8570 (gnus-treat-hide-boring-headers nil))
8571 (gnus-delete-wash-type 'headers)
8572 (gnus-treat-article 'head))
8573 (gnus-treat-article 'head))
8576 (set-window-start window (goto-char (point-min))))
8577 (setq gnus-page-broken
8578 (when gnus-break-pages
8579 (gnus-narrow-to-page)
8581 (gnus-set-mode-line 'article)))))
8583 (defun gnus-summary-show-all-headers ()
8584 "Make all header lines visible."
8586 (gnus-summary-toggle-header 1))
8588 (defun gnus-summary-toggle-mime (&optional arg)
8589 "Toggle MIME processing.
8590 If ARG is a positive number, turn MIME processing on."
8592 (setq gnus-show-mime
8594 (not gnus-show-mime)
8595 (> (prefix-numeric-value arg) 0)))
8596 (gnus-summary-select-article t 'force))
8598 (defun gnus-summary-caesar-message (&optional arg)
8599 "Caesar rotate the current article by 13.
8600 The numerical prefix specifies how many places to rotate each letter
8603 (gnus-summary-select-article)
8604 (let ((mail-header-separator ""))
8605 (gnus-eval-in-buffer-window gnus-article-buffer
8608 (let ((start (window-start))
8610 (message-caesar-buffer-body arg)
8611 (set-window-start (get-buffer-window (current-buffer)) start))))))
8613 (autoload 'unmorse-region "morse"
8614 "Convert morse coded text in region to ordinary ASCII text."
8617 (defun gnus-summary-morse-message (&optional arg)
8618 "Morse decode the current article."
8620 (gnus-summary-select-article)
8621 (let ((mail-header-separator ""))
8622 (gnus-eval-in-buffer-window gnus-article-buffer
8626 (let ((pos (window-start))
8628 (goto-char (point-min))
8629 (when (message-goto-body)
8630 (gnus-narrow-to-body))
8631 (goto-char (point-min))
8632 (while (re-search-forward "·" (point-max) t)
8633 (replace-match "."))
8634 (unmorse-region (point-min) (point-max))
8636 (set-window-start (get-buffer-window (current-buffer)) pos)))))))
8638 (defun gnus-summary-stop-page-breaking ()
8639 "Stop page breaking in the current article."
8641 (gnus-summary-select-article)
8642 (gnus-eval-in-buffer-window gnus-article-buffer
8644 (when (gnus-visual-p 'page-marker)
8645 (let ((buffer-read-only nil))
8646 (gnus-remove-text-with-property 'gnus-prev)
8647 (gnus-remove-text-with-property 'gnus-next))
8648 (setq gnus-page-broken nil))))
8650 (defun gnus-summary-move-article (&optional n to-newsgroup
8651 select-method action)
8652 "Move the current article to a different newsgroup.
8653 If N is a positive number, move the N next articles.
8654 If N is a negative number, move the N previous articles.
8655 If N is nil and any articles have been marked with the process mark,
8656 move those articles instead.
8657 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8658 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8659 re-spool using this method.
8661 When called interactively with TO-NEWSGROUP being nil, the value of
8662 the variable `gnus-move-split-methods' is used for finding a default
8663 for the target newsgroup.
8665 For this function to work, both the current newsgroup and the
8666 newsgroup that you want to move to have to support the `request-move'
8667 and `request-accept' functions.
8669 ACTION can be either `move' (the default), `crosspost' or `copy'."
8672 (setq action 'move))
8673 ;; Check whether the source group supports the required functions.
8674 (cond ((and (eq action 'move)
8675 (not (gnus-check-backend-function
8676 'request-move-article gnus-newsgroup-name)))
8677 (error "The current group does not support article moving"))
8678 ((and (eq action 'crosspost)
8679 (not (gnus-check-backend-function
8680 'request-replace-article gnus-newsgroup-name)))
8681 (error "The current group does not support article editing")))
8682 (let ((articles (gnus-summary-work-articles n))
8683 (prefix (if (gnus-check-backend-function
8684 'request-move-article gnus-newsgroup-name)
8685 (gnus-group-real-prefix gnus-newsgroup-name)
8687 (names '((move "Move" "Moving")
8688 (copy "Copy" "Copying")
8689 (crosspost "Crosspost" "Crossposting")))
8690 (copy-buf (save-excursion
8691 (nnheader-set-temp-buffer " *copy article*")))
8692 (default-marks gnus-article-mark-lists)
8693 (no-expire-marks (delete '(expirable . expire)
8694 (copy-sequence gnus-article-mark-lists)))
8695 art-group to-method new-xref article to-groups)
8696 (unless (assq action names)
8697 (error "Unknown action %s" action))
8698 ;; Read the newsgroup name.
8699 (when (and (not to-newsgroup)
8700 (not select-method))
8701 (if (and gnus-move-split-methods
8703 (and (memq gnus-current-article articles)
8704 (gnus-buffer-live-p gnus-original-article-buffer))))
8705 ;; When `gnus-move-split-methods' is non-nil, we have to
8706 ;; select an article to give `gnus-read-move-group-name' an
8707 ;; opportunity to suggest an appropriate default. However,
8708 ;; we needn't render or mark the article.
8709 (let ((gnus-display-mime-function nil)
8710 (gnus-article-prepare-hook nil)
8711 (gnus-mark-article-hook nil))
8712 (gnus-summary-select-article nil nil nil (car articles))))
8714 (gnus-read-move-group-name
8715 (cadr (assq action names))
8716 (symbol-value (intern (format "gnus-current-%s-group" action)))
8718 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
8719 (setq to-method (or select-method
8720 (gnus-server-to-method
8721 (gnus-group-method to-newsgroup))))
8722 ;; Check the method we are to move this article to...
8723 (unless (gnus-check-backend-function
8724 'request-accept-article (car to-method))
8725 (error "%s does not support article copying" (car to-method)))
8726 (unless (gnus-check-server to-method)
8727 (error "Can't open server %s" (car to-method)))
8728 (gnus-message 6 "%s to %s: %s..."
8729 (caddr (assq action names))
8730 (or (car select-method) to-newsgroup) articles)
8732 (setq article (pop articles))
8736 ;; Move the article.
8738 ;; Remove this article from future suppression.
8739 (gnus-dup-unsuppress-article article)
8740 (gnus-request-move-article
8741 article ; Article to move
8742 gnus-newsgroup-name ; From newsgroup
8743 (nth 1 (gnus-find-method-for-group
8744 gnus-newsgroup-name)) ; Server
8745 (list 'gnus-request-accept-article
8746 to-newsgroup (list 'quote select-method)
8747 (not articles) t) ; Accept form
8748 (not articles))) ; Only save nov last time
8749 ;; Copy the article.
8752 (set-buffer copy-buf)
8753 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
8754 (gnus-request-accept-article
8755 to-newsgroup select-method (not articles) t))))
8756 ;; Crosspost the article.
8757 ((eq action 'crosspost)
8758 (let ((xref (message-tokenize-header
8759 (mail-header-xref (gnus-summary-article-header article))
8761 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
8762 ":" (number-to-string article)))
8764 (setq xref (list (system-name))))
8767 (mapconcat 'identity
8768 (delete "Xref:" (delete new-xref xref))
8772 (set-buffer copy-buf)
8773 ;; First put the article in the destination group.
8774 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8775 (when (consp (setq art-group
8776 (gnus-request-accept-article
8777 to-newsgroup select-method (not articles))))
8778 (setq new-xref (concat new-xref " " (car art-group)
8780 (number-to-string (cdr art-group))))
8781 ;; Now we have the new Xrefs header, so we insert
8782 ;; it and replace the new article.
8783 (nnheader-replace-header "Xref" new-xref)
8784 (gnus-request-replace-article
8785 (cdr art-group) to-newsgroup (current-buffer))
8789 (gnus-message 1 "Couldn't %s article %s: %s"
8790 (cadr (assq action names)) article
8791 (nnheader-get-report (car to-method))))
8792 ((eq art-group 'junk)
8793 (when (eq action 'move)
8794 (gnus-summary-mark-article article gnus-canceled-mark)
8795 (gnus-message 4 "Deleted article %s" article)))
8797 (let* ((pto-group (gnus-group-prefixed-name
8798 (car art-group) to-method))
8800 (gnus-gethash pto-group gnus-newsrc-hashtb))
8801 (info (nth 2 entry))
8802 (to-group (gnus-info-group info))
8804 ;; Update the group that has been moved to.
8806 (memq action '(move copy)))
8807 (unless (member to-group to-groups)
8808 (push to-group to-groups))
8810 (unless (memq article gnus-newsgroup-unreads)
8811 (push 'read to-marks)
8813 info (gnus-add-to-range (gnus-info-read info)
8814 (list (cdr art-group)))))
8816 ;; See whether the article is to be put in the cache.
8817 (let ((marks (if (gnus-group-auto-expirable-p to-group)
8820 (to-article (cdr art-group)))
8822 ;; Enter the article into the cache in the new group,
8823 ;; if that is required.
8824 (when gnus-use-cache
8825 (gnus-cache-possibly-enter-article
8827 (let ((header (copy-sequence
8828 (gnus-summary-article-header article))))
8829 (mail-header-set-number header to-article)
8831 (memq article gnus-newsgroup-marked)
8832 (memq article gnus-newsgroup-dormant)
8833 (memq article gnus-newsgroup-unreads)))
8835 (when gnus-preserve-marks
8836 ;; Copy any marks over to the new group.
8837 (when (and (equal to-group gnus-newsgroup-name)
8838 (not (memq article gnus-newsgroup-unreads)))
8839 ;; Mark this article as read in this group.
8840 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
8841 (setcdr (gnus-active to-group) to-article)
8842 (setcdr gnus-newsgroup-active to-article))
8845 (when (eq (gnus-article-mark-to-type (cdar marks)) 'list)
8846 (when (memq article (symbol-value
8847 (intern (format "gnus-newsgroup-%s"
8849 (push (cdar marks) to-marks)
8850 ;; If the other group is the same as this group,
8851 ;; then we have to add the mark to the list.
8852 (when (equal to-group gnus-newsgroup-name)
8853 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
8856 (intern (format "gnus-newsgroup-%s"
8858 ;; Copy the marks to other group.
8859 (gnus-add-marked-articles
8860 to-group (cdar marks) (list to-article) info)))
8861 (setq marks (cdr marks)))
8863 (gnus-request-set-mark
8864 to-group (list (list (list to-article) 'add to-marks))))
8867 (concat "(gnus-group-set-info '"
8868 (gnus-prin1-to-string (gnus-get-info to-group))
8871 ;; Update the Xref header in this article to point to
8872 ;; the new crossposted article we have just created.
8873 (when (eq action 'crosspost)
8875 (set-buffer copy-buf)
8876 (gnus-request-article-this-buffer article gnus-newsgroup-name)
8877 (nnheader-replace-header "Xref" new-xref)
8878 (gnus-request-replace-article
8879 article gnus-newsgroup-name (current-buffer)))))
8881 ;;;!!!Why is this necessary?
8882 (set-buffer gnus-summary-buffer)
8884 (gnus-summary-goto-subject article)
8885 (when (eq action 'move)
8886 (gnus-summary-mark-article article gnus-canceled-mark))))
8887 (gnus-summary-remove-process-mark article))
8888 ;; Re-activate all groups that have been moved to.
8890 (set-buffer gnus-group-buffer)
8891 (let ((gnus-group-marked to-groups))
8892 (gnus-group-get-new-news-this-group nil t)))
8894 (gnus-kill-buffer copy-buf)
8895 (gnus-summary-position-point)
8896 (gnus-set-mode-line 'summary)))
8898 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
8899 "Move the current article to a different newsgroup.
8900 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
8901 When called interactively, if TO-NEWSGROUP is nil, use the value of
8902 the variable `gnus-move-split-methods' for finding a default target
8904 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
8905 re-spool using this method."
8907 (gnus-summary-move-article n to-newsgroup select-method 'copy))
8909 (defun gnus-summary-crosspost-article (&optional n)
8910 "Crosspost the current article to some other group."
8912 (gnus-summary-move-article n nil nil 'crosspost))
8914 (defcustom gnus-summary-respool-default-method nil
8915 "Default method type for respooling an article.
8916 If nil, use to the current newsgroup method."
8918 :group 'gnus-summary-mail)
8920 (defun gnus-summary-respool-article (&optional n method)
8921 "Respool the current article.
8922 The article will be squeezed through the mail spooling process again,
8923 which means that it will be put in some mail newsgroup or other
8924 depending on `nnmail-split-methods'.
8925 If N is a positive number, respool the N next articles.
8926 If N is a negative number, respool the N previous articles.
8927 If N is nil and any articles have been marked with the process mark,
8928 respool those articles instead.
8930 Respooling can be done both from mail groups and \"real\" newsgroups.
8931 In the former case, the articles in question will be moved from the
8932 current group into whatever groups they are destined to. In the
8933 latter case, they will be copied into the relevant groups."
8935 (list current-prefix-arg
8936 (let* ((methods (gnus-methods-using 'respool))
8938 (symbol-name (or gnus-summary-respool-default-method
8939 (car (gnus-find-method-for-group
8940 gnus-newsgroup-name)))))
8942 (gnus-completing-read-with-default
8943 methname "What backend do you want to use when respooling?"
8944 methods nil t nil 'gnus-mail-method-history))
8947 ((zerop (length (setq ms (gnus-servers-using-backend
8949 (list (intern method) ""))
8953 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
8954 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
8957 (error "No method given for respooling"))
8958 (if (assoc (symbol-name
8959 (car (gnus-find-method-for-group gnus-newsgroup-name)))
8960 (gnus-methods-using 'respool))
8961 (gnus-summary-move-article n nil method)
8962 (gnus-summary-copy-article n nil method)))
8964 (defun gnus-summary-import-article (file &optional edit)
8965 "Import an arbitrary file into a mail newsgroup."
8966 (interactive "fImport file: \nP")
8967 (let ((group gnus-newsgroup-name)
8968 (now (current-time))
8969 atts lines group-art)
8970 (unless (gnus-check-backend-function 'request-accept-article group)
8971 (error "%s does not support article importing" group))
8972 (or (file-readable-p file)
8973 (not (file-regular-p file))
8974 (error "Can't read %s" file))
8976 (set-buffer (gnus-get-buffer-create " *import file*"))
8978 (nnheader-insert-file-contents file)
8979 (goto-char (point-min))
8980 (if (nnheader-article-p)
8982 (goto-char (point-min))
8983 (search-forward "\n\n" nil t)
8984 (narrow-to-region (point-min) (1- (point)))
8985 (goto-char (point-min))
8986 (unless (re-search-forward "^date:" nil t)
8987 (goto-char (point-max))
8988 (insert "Date: " (message-make-date (nth 5 atts)) "\n")))
8989 ;; This doesn't look like an article, so we fudge some headers.
8990 (setq atts (file-attributes file)
8991 lines (count-lines (point-min) (point-max)))
8992 (insert "From: " (read-string "From: ") "\n"
8993 "Subject: " (read-string "Subject: ") "\n"
8994 "Date: " (message-make-date (nth 5 atts)) "\n"
8995 "Message-ID: " (message-make-message-id) "\n"
8996 "Lines: " (int-to-string lines) "\n"
8997 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
8998 (setq group-art (gnus-request-accept-article group nil t))
8999 (kill-buffer (current-buffer)))
9000 (setq gnus-newsgroup-active (gnus-activate-group group))
9002 (gnus-summary-goto-article (cdr group-art) nil t)
9004 (gnus-summary-edit-article))))
9006 (defun gnus-summary-create-article ()
9007 "Create an article in a mail newsgroup."
9009 (let ((group gnus-newsgroup-name)
9010 (now (current-time))
9012 (unless (gnus-check-backend-function 'request-accept-article group)
9013 (error "%s does not support article importing" group))
9015 (set-buffer (gnus-get-buffer-create " *import file*"))
9017 (goto-char (point-min))
9018 ;; This doesn't look like an article, so we fudge some headers.
9019 (insert "From: " (read-string "From: ") "\n"
9020 "Subject: " (read-string "Subject: ") "\n"
9021 "Date: " (message-make-date now) "\n"
9022 "Message-ID: " (message-make-message-id) "\n")
9023 (setq group-art (gnus-request-accept-article group nil t))
9024 (kill-buffer (current-buffer)))
9025 (setq gnus-newsgroup-active (gnus-activate-group group))
9027 (gnus-summary-goto-article (cdr group-art) nil t)
9028 (gnus-summary-edit-article)))
9030 (defun gnus-summary-article-posted-p ()
9031 "Say whether the current (mail) article is available from news as well.
9032 This will be the case if the article has both been mailed and posted."
9034 (let ((id (mail-header-references (gnus-summary-article-header)))
9035 (gnus-override-method (car (gnus-refer-article-methods))))
9036 (if (gnus-request-head id "")
9037 (gnus-message 2 "The current message was found on %s"
9038 gnus-override-method)
9039 (gnus-message 2 "The current message couldn't be found on %s"
9040 gnus-override-method)
9043 (defun gnus-summary-expire-articles (&optional now)
9044 "Expire all articles that are marked as expirable in the current group."
9046 (when (gnus-check-backend-function
9047 'request-expire-articles gnus-newsgroup-name)
9048 ;; This backend supports expiry.
9049 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
9050 (expirable (if total
9052 ;; We need to update the info for
9053 ;; this group for `gnus-list-of-read-articles'
9054 ;; to give us the right answer.
9055 (gnus-run-hooks 'gnus-exit-group-hook)
9056 (gnus-summary-update-info)
9057 (gnus-list-of-read-articles gnus-newsgroup-name))
9058 (setq gnus-newsgroup-expirable
9059 (sort gnus-newsgroup-expirable '<))))
9060 (expiry-wait (if now 'immediate
9061 (gnus-group-find-parameter
9062 gnus-newsgroup-name 'expiry-wait)))
9063 (nnmail-expiry-target
9064 (or (gnus-group-find-parameter gnus-newsgroup-name 'expiry-target)
9065 nnmail-expiry-target))
9068 ;; There are expirable articles in this group, so we run them
9069 ;; through the expiry process.
9070 (gnus-message 6 "Expiring articles...")
9071 (unless (gnus-check-group gnus-newsgroup-name)
9072 (error "Can't open server for %s" gnus-newsgroup-name))
9073 ;; The list of articles that weren't expired is returned.
9076 (let ((nnmail-expiry-wait-function nil)
9077 (nnmail-expiry-wait expiry-wait))
9078 (setq es (gnus-request-expire-articles
9079 expirable gnus-newsgroup-name)))
9080 (setq es (gnus-request-expire-articles
9081 expirable gnus-newsgroup-name)))
9083 (setq gnus-newsgroup-expirable es))
9084 ;; We go through the old list of expirable, and mark all
9085 ;; really expired articles as nonexistent.
9086 (unless (eq es expirable) ;If nothing was expired, we don't mark.
9087 (let ((gnus-use-cache nil))
9088 (dolist (article expirable)
9089 (when (and (not (memq article es))
9090 (gnus-data-find article))
9091 (gnus-summary-mark-article article gnus-canceled-mark))))))
9092 (gnus-message 6 "Expiring articles...done")))))
9094 (defun gnus-summary-expire-articles-now ()
9095 "Expunge all expirable articles in the current group.
9096 This means that *all* articles that are marked as expirable will be
9097 deleted forever, right now."
9099 (or gnus-expert-user
9101 "Are you really, really, really sure you want to delete all these messages? ")
9103 (gnus-summary-expire-articles t))
9105 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
9106 (defun gnus-summary-delete-article (&optional n)
9107 "Delete the N next (mail) articles.
9108 This command actually deletes articles. This is not a marking
9109 command. The article will disappear forever from your life, never to
9111 If N is negative, delete backwards.
9112 If N is nil and articles have been marked with the process mark,
9113 delete these instead."
9115 (unless (gnus-check-backend-function 'request-expire-articles
9116 gnus-newsgroup-name)
9117 (error "The current newsgroup does not support article deletion"))
9118 (unless (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
9119 (error "Couldn't open server"))
9120 ;; Compute the list of articles to delete.
9121 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
9122 (nnmail-expiry-target 'delete)
9124 (if (and gnus-novice-user
9125 (not (gnus-yes-or-no-p
9126 (format "Do you really want to delete %s forever? "
9127 (if (> (length articles) 1)
9128 (format "these %s articles" (length articles))
9131 ;; Delete the articles.
9132 (setq not-deleted (gnus-request-expire-articles
9133 articles gnus-newsgroup-name 'force))
9135 (gnus-summary-remove-process-mark (car articles))
9136 ;; The backend might not have been able to delete the article
9138 (unless (memq (car articles) not-deleted)
9139 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
9140 (setq articles (cdr articles)))
9142 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
9143 (gnus-summary-position-point)
9144 (gnus-set-mode-line 'summary)
9147 (defun gnus-summary-edit-article (&optional force)
9148 "Edit the current article.
9149 This will have permanent effect only in mail groups.
9150 If FORCE is non-nil, allow editing of articles even in read-only
9154 (set-buffer gnus-summary-buffer)
9155 (let ((mail-parse-charset gnus-newsgroup-charset)
9156 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets))
9157 (gnus-set-global-variables)
9158 (when (and (not force)
9159 (gnus-group-read-only-p))
9160 (error "The current newsgroup does not support article editing"))
9161 (gnus-summary-show-article t)
9162 (gnus-article-edit-article
9164 `(lambda (no-highlight)
9165 (let ((mail-parse-charset ',gnus-newsgroup-charset)
9166 (message-options message-options)
9167 (message-options-set-recipient)
9168 (mail-parse-ignored-charsets
9169 ',gnus-newsgroup-ignored-charsets))
9170 (gnus-summary-edit-article-done
9171 ,(or (mail-header-references gnus-current-headers) "")
9172 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
9174 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
9176 (defun gnus-summary-edit-article-done (&optional references read-only buffer
9178 "Make edits to the current article permanent."
9181 ;; The buffer restriction contains the entire article if it exists.
9182 (when (article-goto-body)
9183 (let ((lines (count-lines (point) (point-max)))
9184 (length (- (point-max) (point)))
9185 (case-fold-search t)
9186 (body (copy-marker (point))))
9187 (goto-char (point-min))
9188 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
9189 (delete-region (match-beginning 1) (match-end 1))
9190 (insert (number-to-string length)))
9191 (goto-char (point-min))
9192 (when (re-search-forward
9193 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
9194 (delete-region (match-beginning 1) (match-end 1))
9195 (insert (number-to-string length)))
9196 (goto-char (point-min))
9197 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
9198 (delete-region (match-beginning 1) (match-end 1))
9199 (insert (number-to-string lines))))))
9200 ;; Replace the article.
9201 (let ((buf (current-buffer)))
9203 (insert-buffer-substring buf)
9205 (if (and (not read-only)
9206 (not (gnus-request-replace-article
9207 (cdr gnus-article-current) (car gnus-article-current)
9208 (current-buffer) t)))
9209 (error "Couldn't replace article")
9210 ;; Update the summary buffer.
9212 (equal (message-tokenize-header references " ")
9213 (message-tokenize-header
9214 (or (message-fetch-field "references") "") " ")))
9215 ;; We only have to update this line.
9218 (message-narrow-to-head)
9219 (let ((head (buffer-string))
9222 (insert (format "211 %d Article retrieved.\n"
9223 (cdr gnus-article-current)))
9226 (let ((nntp-server-buffer (current-buffer)))
9227 (setq header (car (gnus-get-newsgroup-headers
9230 (set-buffer gnus-summary-buffer)
9231 (gnus-data-set-header
9232 (gnus-data-find (cdr gnus-article-current))
9234 (gnus-summary-update-article-line
9235 (cdr gnus-article-current) header)
9236 (if (gnus-summary-goto-subject
9237 (cdr gnus-article-current) nil t)
9238 (gnus-summary-update-secondary-mark
9239 (cdr gnus-article-current))))))))
9241 (set-buffer (or buffer gnus-summary-buffer))
9242 (gnus-summary-update-article (cdr gnus-article-current))
9243 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
9244 (gnus-summary-update-secondary-mark
9245 (cdr gnus-article-current))))
9246 ;; Prettify the article buffer again.
9247 (unless no-highlight
9249 (set-buffer gnus-article-buffer)
9250 ;;;!!! Fix this -- article should be rehighlighted.
9251 ;;;(gnus-run-hooks 'gnus-article-display-hook)
9252 (set-buffer gnus-original-article-buffer)
9253 (gnus-request-article
9254 (cdr gnus-article-current)
9255 (car gnus-article-current) (current-buffer))))
9256 ;; Prettify the summary buffer line.
9257 (when (gnus-visual-p 'summary-highlight 'highlight)
9258 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
9260 (defun gnus-summary-edit-wash (key)
9261 "Perform editing command KEY in the article buffer."
9265 (message "%s" (concat (this-command-keys) "- "))
9268 (gnus-summary-edit-article)
9269 (execute-kbd-macro (concat (this-command-keys) key))
9270 (gnus-article-edit-done))
9274 (defun gnus-summary-respool-query (&optional silent trace)
9275 "Query where the respool algorithm would put this article."
9277 (let (gnus-mark-article-hook)
9278 (gnus-summary-select-article)
9280 (set-buffer gnus-original-article-buffer)
9282 (message-narrow-to-head)
9283 (let ((groups (nnmail-article-group 'identity trace)))
9286 (message "This message would go to %s"
9287 (mapconcat 'car groups ", "))
9288 (message "This message would go to no groups"))
9291 (defun gnus-summary-respool-trace ()
9292 "Trace where the respool algorithm would put this article.
9293 Display a buffer showing all fancy splitting patterns which matched."
9295 (gnus-summary-respool-query nil t))
9297 ;; Summary marking commands.
9299 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
9300 "Mark articles which has the same subject as read, and then select the next.
9301 If UNMARK is positive, remove any kind of mark.
9302 If UNMARK is negative, tick articles."
9305 (setq unmark (prefix-numeric-value unmark)))
9307 (gnus-summary-mark-same-subject
9308 (gnus-summary-article-subject) unmark)))
9309 ;; Select next unread article. If auto-select-same mode, should
9310 ;; select the first unread article.
9311 (gnus-summary-next-article t (and gnus-auto-select-same
9312 (gnus-summary-article-subject)))
9313 (gnus-message 7 "%d article%s marked as %s"
9314 count (if (= count 1) " is" "s are")
9315 (if unmark "unread" "read"))))
9317 (defun gnus-summary-kill-same-subject (&optional unmark)
9318 "Mark articles which has the same subject as read.
9319 If UNMARK is positive, remove any kind of mark.
9320 If UNMARK is negative, tick articles."
9323 (setq unmark (prefix-numeric-value unmark)))
9325 (gnus-summary-mark-same-subject
9326 (gnus-summary-article-subject) unmark)))
9327 ;; If marked as read, go to next unread subject.
9329 ;; Go to next unread subject.
9330 (gnus-summary-next-subject 1 t))
9331 (gnus-message 7 "%d articles are marked as %s"
9332 count (if unmark "unread" "read"))))
9334 (defun gnus-summary-mark-same-subject (subject &optional unmark)
9335 "Mark articles with same SUBJECT as read, and return marked number.
9336 If optional argument UNMARK is positive, remove any kinds of marks.
9337 If optional argument UNMARK is negative, mark articles as unread instead."
9341 ((null unmark) ; Mark as read.
9344 (gnus-summary-mark-article-as-read gnus-killed-mark)
9345 (gnus-summary-show-thread) t)
9346 (gnus-summary-find-subject subject))
9347 (setq count (1+ count))))
9348 ((> unmark 0) ; Tick.
9351 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
9352 (gnus-summary-show-thread) t)
9353 (gnus-summary-find-subject subject))
9354 (setq count (1+ count))))
9355 (t ; Mark as unread.
9358 (gnus-summary-mark-article-as-unread gnus-unread-mark)
9359 (gnus-summary-show-thread) t)
9360 (gnus-summary-find-subject subject))
9361 (setq count (1+ count)))))
9362 (gnus-set-mode-line 'summary)
9363 ;; Return the number of marked articles.
9366 (defun gnus-summary-mark-as-processable (n &optional unmark)
9367 "Set the process mark on the next N articles.
9368 If N is negative, mark backward instead. If UNMARK is non-nil, remove
9369 the process mark instead. The difference between N and the actual
9370 number of articles marked is returned."
9372 (if (and (null n) (gnus-region-active-p))
9373 (gnus-uu-mark-region (region-beginning) (region-end) unmark)
9374 (setq n (prefix-numeric-value n))
9375 (let ((backward (< n 0))
9380 (gnus-summary-remove-process-mark
9381 (gnus-summary-article-number))
9382 (gnus-summary-set-process-mark (gnus-summary-article-number)))
9383 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
9386 (gnus-message 7 "No more articles"))
9387 (gnus-summary-recenter)
9388 (gnus-summary-position-point)
9391 (defun gnus-summary-unmark-as-processable (n)
9392 "Remove the process mark from the next N articles.
9393 If N is negative, unmark backward instead. The difference between N and
9394 the actual number of articles unmarked is returned."
9396 (gnus-summary-mark-as-processable n t))
9398 (defun gnus-summary-unmark-all-processable ()
9399 "Remove the process mark from all articles."
9402 (while gnus-newsgroup-processable
9403 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
9404 (gnus-summary-position-point))
9406 (defun gnus-summary-add-mark (article type)
9407 "Mark ARTICLE with a mark of TYPE."
9408 (let ((vtype (car (assq type gnus-article-mark-lists)))
9411 (error "No such mark type: %s" type)
9412 (setq var (intern (format "gnus-newsgroup-%s" type)))
9413 (set var (cons article (symbol-value var)))
9414 (if (memq type '(processable cached replied forwarded recent saved))
9415 (gnus-summary-update-secondary-mark article)
9416 ;;; !!! This is bogus. We should find out what primary
9417 ;;; !!! mark we want to set.
9418 (gnus-summary-update-mark gnus-del-mark 'unread)))))
9420 (defun gnus-summary-mark-as-expirable (n)
9421 "Mark N articles forward as expirable.
9422 If N is negative, mark backward instead. The difference between N and
9423 the actual number of articles marked is returned."
9425 (gnus-summary-mark-forward n gnus-expirable-mark))
9427 (defun gnus-summary-mark-as-spam (n)
9428 "Mark N articles forward as spam.
9429 If N is negative, mark backward instead. The difference between N and
9430 the actual number of articles marked is returned."
9432 (gnus-summary-mark-forward n gnus-spam-mark))
9434 (defun gnus-summary-mark-article-as-replied (article)
9435 "Mark ARTICLE as replied to and update the summary line.
9436 ARTICLE can also be a list of articles."
9437 (interactive (list (gnus-summary-article-number)))
9438 (let ((articles (if (listp article) article (list article))))
9439 (dolist (article articles)
9440 (push article gnus-newsgroup-replied)
9441 (let ((buffer-read-only nil))
9442 (when (gnus-summary-goto-subject article nil t)
9443 (gnus-summary-update-secondary-mark article))))))
9445 (defun gnus-summary-mark-article-as-forwarded (article)
9446 "Mark ARTICLE as forwarded and update the summary line.
9447 ARTICLE can also be a list of articles."
9448 (let ((articles (if (listp article) article (list article))))
9449 (dolist (article articles)
9450 (push article gnus-newsgroup-forwarded)
9451 (let ((buffer-read-only nil))
9452 (when (gnus-summary-goto-subject article nil t)
9453 (gnus-summary-update-secondary-mark article))))))
9455 (defun gnus-summary-set-bookmark (article)
9456 "Set a bookmark in current article."
9457 (interactive (list (gnus-summary-article-number)))
9458 (when (or (not (get-buffer gnus-article-buffer))
9459 (not gnus-current-article)
9460 (not gnus-article-current)
9461 (not (equal gnus-newsgroup-name (car gnus-article-current))))
9462 (error "No current article selected"))
9463 ;; Remove old bookmark, if one exists.
9464 (let ((old (assq article gnus-newsgroup-bookmarks)))
9466 (setq gnus-newsgroup-bookmarks
9467 (delq old gnus-newsgroup-bookmarks))))
9468 ;; Set the new bookmark, which is on the form
9469 ;; (article-number . line-number-in-body).
9473 (set-buffer gnus-article-buffer)
9477 (goto-char (point-min))
9478 (search-forward "\n\n" nil t)
9481 gnus-newsgroup-bookmarks)
9482 (gnus-message 6 "A bookmark has been added to the current article."))
9484 (defun gnus-summary-remove-bookmark (article)
9485 "Remove the bookmark from the current article."
9486 (interactive (list (gnus-summary-article-number)))
9487 ;; Remove old bookmark, if one exists.
9488 (let ((old (assq article gnus-newsgroup-bookmarks)))
9491 (setq gnus-newsgroup-bookmarks
9492 (delq old gnus-newsgroup-bookmarks))
9493 (gnus-message 6 "Removed bookmark."))
9494 (gnus-message 6 "No bookmark in current article."))))
9496 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9497 (defun gnus-summary-mark-as-dormant (n)
9498 "Mark N articles forward as dormant.
9499 If N is negative, mark backward instead. The difference between N and
9500 the actual number of articles marked is returned."
9502 (gnus-summary-mark-forward n gnus-dormant-mark))
9504 (defun gnus-summary-set-process-mark (article)
9505 "Set the process mark on ARTICLE and update the summary line."
9506 (setq gnus-newsgroup-processable
9508 (delq article gnus-newsgroup-processable)))
9509 (when (gnus-summary-goto-subject article)
9510 (gnus-summary-show-thread)
9511 (gnus-summary-goto-subject article)
9512 (gnus-summary-update-secondary-mark article)))
9514 (defun gnus-summary-remove-process-mark (article)
9515 "Remove the process mark from ARTICLE and update the summary line."
9516 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
9517 (when (gnus-summary-goto-subject article)
9518 (gnus-summary-show-thread)
9519 (gnus-summary-goto-subject article)
9520 (gnus-summary-update-secondary-mark article)))
9522 (defun gnus-summary-set-saved-mark (article)
9523 "Set the process mark on ARTICLE and update the summary line."
9524 (push article gnus-newsgroup-saved)
9525 (when (gnus-summary-goto-subject article)
9526 (gnus-summary-update-secondary-mark article)))
9528 (defun gnus-summary-mark-forward (n &optional mark no-expire)
9529 "Mark N articles as read forwards.
9530 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
9531 The difference between N and the actual number of articles marked is
9533 If NO-EXPIRE, auto-expiry will be inhibited."
9535 (gnus-summary-show-thread)
9536 (let ((backward (< n 0))
9537 (gnus-summary-goto-unread
9538 (and gnus-summary-goto-unread
9539 (not (eq gnus-summary-goto-unread 'never))
9540 (not (memq mark (list gnus-unread-mark
9541 gnus-ticked-mark gnus-dormant-mark)))))
9543 (mark (or mark gnus-del-mark)))
9545 (gnus-summary-mark-article nil mark no-expire)
9546 (zerop (gnus-summary-next-subject
9548 (and gnus-summary-goto-unread
9549 (not (eq gnus-summary-goto-unread 'never)))
9553 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
9554 (gnus-summary-recenter)
9555 (gnus-summary-position-point)
9556 (gnus-set-mode-line 'summary)
9559 (defun gnus-summary-mark-article-as-read (mark)
9560 "Mark the current article quickly as read with MARK."
9561 (let ((article (gnus-summary-article-number)))
9562 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9563 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9564 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9565 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9566 (push (cons article mark) gnus-newsgroup-reads)
9567 ;; Possibly remove from cache, if that is used.
9568 (when gnus-use-cache
9569 (gnus-cache-enter-remove-article article))
9570 ;; Allow the backend to change the mark.
9571 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9572 ;; Check for auto-expiry.
9573 (when (and gnus-newsgroup-auto-expire
9574 (memq mark gnus-auto-expirable-marks))
9575 (setq mark gnus-expirable-mark)
9576 ;; Let the backend know about the mark change.
9577 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9578 (push article gnus-newsgroup-expirable))
9579 ;; Set the mark in the buffer.
9580 (gnus-summary-update-mark mark 'unread)
9583 (defun gnus-summary-mark-article-as-unread (mark)
9584 "Mark the current article quickly as unread with MARK."
9585 (let* ((article (gnus-summary-article-number))
9586 (old-mark (gnus-summary-article-mark article)))
9587 ;; Allow the backend to change the mark.
9588 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9589 (if (eq mark old-mark)
9593 (gnus-error 1 "Can't mark negative article numbers")
9595 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9596 (setq gnus-newsgroup-spam-marked
9597 (delq article gnus-newsgroup-spam-marked))
9598 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9599 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
9600 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
9601 (cond ((= mark gnus-ticked-mark)
9602 (setq gnus-newsgroup-marked
9603 (gnus-add-to-sorted-list gnus-newsgroup-marked
9605 ((= mark gnus-spam-mark)
9606 (setq gnus-newsgroup-spam-marked
9607 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9609 ((= mark gnus-dormant-mark)
9610 (setq gnus-newsgroup-dormant
9611 (gnus-add-to-sorted-list gnus-newsgroup-dormant
9614 (setq gnus-newsgroup-unreads
9615 (gnus-add-to-sorted-list gnus-newsgroup-unreads
9617 (gnus-pull article gnus-newsgroup-reads)
9619 ;; See whether the article is to be put in the cache.
9621 (vectorp (gnus-summary-article-header article))
9623 (gnus-cache-possibly-enter-article
9624 gnus-newsgroup-name article
9625 (gnus-summary-article-header article)
9626 (= mark gnus-ticked-mark)
9627 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9630 (gnus-summary-update-mark mark 'unread)
9633 (defun gnus-summary-mark-article (&optional article mark no-expire)
9634 "Mark ARTICLE with MARK. MARK can be any character.
9635 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
9636 `??' (dormant) and `?E' (expirable).
9637 If MARK is nil, then the default character `?r' is used.
9638 If ARTICLE is nil, then the article on the current line will be
9640 If NO-EXPIRE, auto-expiry will be inhibited."
9641 ;; The mark might be a string.
9642 (when (stringp mark)
9643 (setq mark (aref mark 0)))
9644 ;; If no mark is given, then we check auto-expiring.
9646 (setq mark gnus-del-mark))
9647 (when (and (not no-expire)
9648 gnus-newsgroup-auto-expire
9649 (memq mark gnus-auto-expirable-marks))
9650 (setq mark gnus-expirable-mark))
9651 (let ((article (or article (gnus-summary-article-number)))
9652 (old-mark (gnus-summary-article-mark article)))
9653 ;; Allow the backend to change the mark.
9654 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
9655 (if (eq mark old-mark)
9658 (error "No article on current line"))
9659 (if (not (if (or (= mark gnus-unread-mark)
9660 (= mark gnus-ticked-mark)
9661 (= mark gnus-spam-mark)
9662 (= mark gnus-dormant-mark))
9663 (gnus-mark-article-as-unread article mark)
9664 (gnus-mark-article-as-read article mark)))
9666 ;; See whether the article is to be put in the cache.
9668 (not (= mark gnus-canceled-mark))
9669 (vectorp (gnus-summary-article-header article))
9671 (gnus-cache-possibly-enter-article
9672 gnus-newsgroup-name article
9673 (gnus-summary-article-header article)
9674 (= mark gnus-ticked-mark)
9675 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
9677 (when (gnus-summary-goto-subject article nil t)
9678 (let ((buffer-read-only nil))
9679 (gnus-summary-show-thread)
9681 (gnus-summary-update-mark mark 'unread)
9684 (defun gnus-summary-update-secondary-mark (article)
9685 "Update the secondary (read, process, cache) mark."
9686 (gnus-summary-update-mark
9687 (cond ((memq article gnus-newsgroup-processable)
9689 ((memq article gnus-newsgroup-cached)
9691 ((memq article gnus-newsgroup-replied)
9693 ((memq article gnus-newsgroup-forwarded)
9694 gnus-forwarded-mark)
9695 ((memq article gnus-newsgroup-saved)
9697 ((memq article gnus-newsgroup-recent)
9699 ((memq article gnus-newsgroup-unseen)
9703 (when (gnus-visual-p 'summary-highlight 'highlight)
9704 (gnus-run-hooks 'gnus-summary-update-hook))
9707 (defun gnus-summary-update-download-mark (article)
9708 "Update the secondary (read, process, cache) mark."
9709 (gnus-summary-update-mark
9710 (cond ((memq article gnus-newsgroup-undownloaded)
9711 gnus-undownloaded-mark)
9712 (gnus-newsgroup-agentized
9713 gnus-downloaded-mark)
9717 (gnus-summary-update-line t)
9720 (defun gnus-summary-update-mark (mark type)
9721 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
9722 (buffer-read-only nil))
9723 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
9725 (when (looking-at "\r")
9727 (when (<= (+ forward (point)) (point-max))
9728 ;; Go to the right position on the line.
9729 (goto-char (+ forward (point)))
9730 ;; Replace the old mark with the new mark.
9731 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
9732 ;; Optionally update the marks by some user rule.
9733 (when (eq type 'unread)
9735 (gnus-data-find (gnus-summary-article-number)) mark)
9736 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
9738 (defun gnus-mark-article-as-read (article &optional mark)
9739 "Enter ARTICLE in the pertinent lists and remove it from others."
9740 ;; Make the article expirable.
9741 (let ((mark (or mark gnus-del-mark)))
9742 (setq gnus-newsgroup-expirable
9743 (if (= mark gnus-expirable-mark)
9744 (gnus-add-to-sorted-list gnus-newsgroup-expirable article)
9745 (delq article gnus-newsgroup-expirable)))
9746 ;; Remove from unread and marked lists.
9747 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9748 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
9749 (setq gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked))
9750 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
9751 (push (cons article mark) gnus-newsgroup-reads)
9752 ;; Possibly remove from cache, if that is used.
9753 (when gnus-use-cache
9754 (gnus-cache-enter-remove-article article))
9757 (defun gnus-mark-article-as-unread (article &optional mark)
9758 "Enter ARTICLE in the pertinent lists and remove it from others."
9759 (let ((mark (or mark gnus-ticked-mark)))
9762 (gnus-error 1 "Can't mark negative article numbers")
9764 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
9765 gnus-newsgroup-spam-marked (delq article gnus-newsgroup-spam-marked)
9766 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
9767 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
9768 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
9770 ;; Unsuppress duplicates?
9771 (when gnus-suppress-duplicates
9772 (gnus-dup-unsuppress-article article))
9774 (cond ((= mark gnus-ticked-mark)
9775 (setq gnus-newsgroup-marked
9776 (gnus-add-to-sorted-list gnus-newsgroup-marked article)))
9777 ((= mark gnus-spam-mark)
9778 (setq gnus-newsgroup-spam-marked
9779 (gnus-add-to-sorted-list gnus-newsgroup-spam-marked
9781 ((= mark gnus-dormant-mark)
9782 (setq gnus-newsgroup-dormant
9783 (gnus-add-to-sorted-list gnus-newsgroup-dormant article)))
9785 (setq gnus-newsgroup-unreads
9786 (gnus-add-to-sorted-list gnus-newsgroup-unreads article))))
9787 (gnus-pull article gnus-newsgroup-reads)
9790 (defalias 'gnus-summary-mark-as-unread-forward
9791 'gnus-summary-tick-article-forward)
9792 (make-obsolete 'gnus-summary-mark-as-unread-forward
9793 'gnus-summary-tick-article-forward)
9794 (defun gnus-summary-tick-article-forward (n)
9795 "Tick N articles forwards.
9796 If N is negative, tick backwards instead.
9797 The difference between N and the number of articles ticked is returned."
9799 (gnus-summary-mark-forward n gnus-ticked-mark))
9801 (defalias 'gnus-summary-mark-as-unread-backward
9802 'gnus-summary-tick-article-backward)
9803 (make-obsolete 'gnus-summary-mark-as-unread-backward
9804 'gnus-summary-tick-article-backward)
9805 (defun gnus-summary-tick-article-backward (n)
9806 "Tick N articles backwards.
9807 The difference between N and the number of articles ticked is returned."
9809 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
9811 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9812 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
9813 (defun gnus-summary-tick-article (&optional article clear-mark)
9814 "Mark current article as unread.
9815 Optional 1st argument ARTICLE specifies article number to be marked as unread.
9816 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
9818 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
9821 (defun gnus-summary-mark-as-read-forward (n)
9822 "Mark N articles as read forwards.
9823 If N is negative, mark backwards instead.
9824 The difference between N and the actual number of articles marked is
9827 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
9829 (defun gnus-summary-mark-as-read-backward (n)
9830 "Mark the N articles as read backwards.
9831 The difference between N and the actual number of articles marked is
9834 (gnus-summary-mark-forward
9835 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
9837 (defun gnus-summary-mark-as-read (&optional article mark)
9838 "Mark current article as read.
9839 ARTICLE specifies the article to be marked as read.
9840 MARK specifies a string to be inserted at the beginning of the line."
9841 (gnus-summary-mark-article article mark))
9843 (defun gnus-summary-clear-mark-forward (n)
9844 "Clear marks from N articles forward.
9845 If N is negative, clear backward instead.
9846 The difference between N and the number of marks cleared is returned."
9848 (gnus-summary-mark-forward n gnus-unread-mark))
9850 (defun gnus-summary-clear-mark-backward (n)
9851 "Clear marks from N articles backward.
9852 The difference between N and the number of marks cleared is returned."
9854 (gnus-summary-mark-forward (- n) gnus-unread-mark))
9856 (defun gnus-summary-mark-unread-as-read ()
9857 "Intended to be used by `gnus-summary-mark-article-hook'."
9858 (when (memq gnus-current-article gnus-newsgroup-unreads)
9859 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
9861 (defun gnus-summary-mark-read-and-unread-as-read ()
9862 "Intended to be used by `gnus-summary-mark-article-hook'."
9863 (let ((mark (gnus-summary-article-mark)))
9864 (when (or (gnus-unread-mark-p mark)
9865 (gnus-read-mark-p mark))
9866 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
9868 (defun gnus-summary-mark-unread-as-ticked ()
9869 "Intended to be used by `gnus-summary-mark-article-hook'."
9870 (when (memq gnus-current-article gnus-newsgroup-unreads)
9871 (gnus-summary-mark-article gnus-current-article gnus-ticked-mark)))
9873 (defun gnus-summary-mark-region-as-read (point mark all)
9874 "Mark all unread articles between point and mark as read.
9875 If given a prefix, mark all articles between point and mark as read,
9876 even ticked and dormant ones."
9877 (interactive "r\nP")
9886 (memq (setq article (gnus-summary-article-number))
9887 gnus-newsgroup-unreads))
9888 (gnus-summary-mark-article article gnus-del-mark))
9890 (gnus-summary-find-next))))))
9892 (defun gnus-summary-mark-below (score mark)
9893 "Mark articles with score less than SCORE with MARK."
9894 (interactive "P\ncMark: ")
9895 (setq score (if score
9896 (prefix-numeric-value score)
9897 (or gnus-summary-default-score 0)))
9899 (set-buffer gnus-summary-buffer)
9900 (goto-char (point-min))
9903 (and (< (gnus-summary-article-score) score)
9904 (gnus-summary-mark-article nil mark))
9905 (gnus-summary-find-next)))))
9907 (defun gnus-summary-kill-below (&optional score)
9908 "Mark articles with score below SCORE as read."
9910 (gnus-summary-mark-below score gnus-killed-mark))
9912 (defun gnus-summary-clear-above (&optional score)
9913 "Clear all marks from articles with score above SCORE."
9915 (gnus-summary-mark-above score gnus-unread-mark))
9917 (defun gnus-summary-tick-above (&optional score)
9918 "Tick all articles with score above SCORE."
9920 (gnus-summary-mark-above score gnus-ticked-mark))
9922 (defun gnus-summary-mark-above (score mark)
9923 "Mark articles with score over SCORE with MARK."
9924 (interactive "P\ncMark: ")
9925 (setq score (if score
9926 (prefix-numeric-value score)
9927 (or gnus-summary-default-score 0)))
9929 (set-buffer gnus-summary-buffer)
9930 (goto-char (point-min))
9932 (when (> (gnus-summary-article-score) score)
9933 (gnus-summary-mark-article nil mark))
9935 (gnus-summary-find-next)))))
9937 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
9938 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
9939 (defun gnus-summary-limit-include-expunged (&optional no-error)
9940 "Display all the hidden articles that were expunged for low scores."
9942 (let ((buffer-read-only nil))
9943 (let ((scored gnus-newsgroup-scored)
9946 (unless (gnus-summary-article-header (caar scored))
9947 (and (setq h (gnus-number-to-header (caar scored)))
9948 (< (cdar scored) gnus-summary-expunge-below)
9950 (setq scored (cdr scored)))
9952 (when (not no-error)
9953 (error "No expunged articles hidden"))
9954 (goto-char (point-min))
9955 (push gnus-newsgroup-limit gnus-newsgroup-limits)
9956 (setq gnus-newsgroup-limit (copy-sequence gnus-newsgroup-limit))
9957 (mapcar (lambda (x) (push (mail-header-number x)
9958 gnus-newsgroup-limit))
9960 (gnus-summary-prepare-unthreaded (nreverse headers))
9961 (goto-char (point-min))
9962 (gnus-summary-position-point)
9965 (defun gnus-summary-catchup (&optional all quietly to-here not-mark reverse)
9966 "Mark all unread articles in this newsgroup as read.
9967 If prefix argument ALL is non-nil, ticked and dormant articles will
9968 also be marked as read.
9969 If QUIETLY is non-nil, no questions will be asked.
9970 If TO-HERE is non-nil, it should be a point in the buffer. All
9971 articles before (after, if REVERSE is set) this point will be marked as read.
9972 Note that this function will only catch up the unread article
9973 in the current summary buffer limitation.
9974 The number of articles marked as read is returned."
9979 (not gnus-interactive-catchup) ;Without confirmation?
9983 "Mark absolutely all articles as read? "
9984 "Mark all unread articles as read? ")))
9986 (not gnus-newsgroup-adaptive)
9987 (not gnus-newsgroup-auto-expire)
9988 (not gnus-suppress-duplicates)
9989 (or (not gnus-use-cache)
9990 (eq gnus-use-cache 'passive)))
9993 (setq gnus-newsgroup-marked nil
9994 gnus-newsgroup-spam-marked nil
9995 gnus-newsgroup-dormant nil))
9996 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
9997 ;; We actually mark all articles as canceled, which we
9998 ;; have to do when using auto-expiry or adaptive scoring.
9999 (gnus-summary-show-all-threads)
10000 (if (and to-here reverse)
10002 (goto-char to-here)
10004 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10005 (gnus-summary-find-next (not all) nil nil t))))
10006 (when (gnus-summary-first-subject (not all) t)
10008 (if to-here (< (point) to-here) t)
10009 (gnus-summary-mark-article-as-read gnus-catchup-mark)
10010 (gnus-summary-find-next (not all) nil nil t)))))
10011 (gnus-set-mode-line 'summary))
10013 (gnus-summary-position-point)))
10015 (defun gnus-summary-catchup-to-here (&optional all)
10016 "Mark all unticked articles before the current one as read.
10017 If ALL is non-nil, also mark ticked and dormant articles as read."
10020 (gnus-save-hidden-threads
10021 (let ((beg (point)))
10022 ;; We check that there are unread articles.
10023 (when (or all (gnus-summary-find-prev))
10024 (gnus-summary-catchup all t beg)))))
10025 (gnus-summary-position-point))
10027 (defun gnus-summary-catchup-from-here (&optional all)
10028 "Mark all unticked articles after the current one as read.
10029 If ALL is non-nil, also mark ticked and dormant articles as read."
10032 (gnus-save-hidden-threads
10033 (let ((beg (point)))
10034 ;; We check that there are unread articles.
10035 (when (or all (gnus-summary-find-next))
10036 (gnus-summary-catchup all t beg nil t)))))
10037 (gnus-summary-position-point))
10039 (defun gnus-summary-catchup-all (&optional quietly)
10040 "Mark all articles in this newsgroup as read.
10041 This command is dangerous. Normally, you want \\[gnus-summary-catchup]
10042 instead, which marks only unread articles as read."
10044 (gnus-summary-catchup t quietly))
10046 (defun gnus-summary-catchup-and-exit (&optional all quietly)
10047 "Mark all unread articles in this group as read, then exit.
10048 If prefix argument ALL is non-nil, all articles are marked as read.
10049 If QUIETLY is non-nil, no questions will be asked."
10051 (when (gnus-summary-catchup all quietly nil 'fast)
10052 ;; Select next newsgroup or exit.
10053 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
10054 (eq gnus-auto-select-next 'quietly))
10055 (gnus-summary-next-group nil)
10056 (gnus-summary-exit))))
10058 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
10059 "Mark all articles in this newsgroup as read, and then exit.
10060 This command is dangerous. Normally, you want \\[gnus-summary-catchup-and-exit]
10061 instead, which marks only unread articles as read."
10063 (gnus-summary-catchup-and-exit t quietly))
10065 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
10066 "Mark all articles in this group as read and select the next group.
10067 If given a prefix, mark all articles, unread as well as ticked, as
10071 (gnus-summary-catchup all))
10072 (gnus-summary-next-group))
10078 (defmacro gnus-with-article (article &rest forms)
10079 "Select ARTICLE and perform FORMS in the original article buffer.
10080 Then replace the article with the result."
10082 ;; We don't want the article to be marked as read.
10083 (let (gnus-mark-article-hook)
10084 (gnus-summary-select-article t t nil ,article))
10085 (set-buffer gnus-original-article-buffer)
10087 (if (not (gnus-check-backend-function
10088 'request-replace-article (car gnus-article-current)))
10089 (gnus-message 5 "Read-only group; not replacing")
10090 (unless (gnus-request-replace-article
10091 ,article (car gnus-article-current)
10092 (current-buffer) t)
10093 (error "Couldn't replace article")))
10094 ;; The cache and backlog have to be flushed somewhat.
10095 (when gnus-keep-backlog
10096 (gnus-backlog-remove-article
10097 (car gnus-article-current) (cdr gnus-article-current)))
10098 (when gnus-use-cache
10099 (gnus-cache-update-article
10100 (car gnus-article-current) (cdr gnus-article-current)))))
10102 (put 'gnus-with-article 'lisp-indent-function 1)
10103 (put 'gnus-with-article 'edebug-form-spec '(form body))
10105 ;; Thread-based commands.
10107 (defun gnus-summary-articles-in-thread (&optional article)
10108 "Return a list of all articles in the current thread.
10109 If ARTICLE is non-nil, return all articles in the thread that starts
10110 with that article."
10111 (let* ((article (or article (gnus-summary-article-number)))
10112 (data (gnus-data-find-list article))
10113 (top-level (gnus-data-level (car data)))
10115 (cond ((null gnus-thread-operation-ignore-subject)
10116 (gnus-simplify-subject-re
10117 (mail-header-subject (gnus-data-header (car data)))))
10118 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
10119 (gnus-simplify-subject-fuzzy
10120 (mail-header-subject (gnus-data-header (car data)))))
10122 (end-point (save-excursion
10123 (if (gnus-summary-go-to-next-thread)
10124 (point) (point-max))))
10127 (< (gnus-data-pos (car data)) end-point))
10128 (when (or (not top-subject)
10129 (string= top-subject
10130 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
10131 (gnus-simplify-subject-fuzzy
10132 (mail-header-subject
10133 (gnus-data-header (car data))))
10134 (gnus-simplify-subject-re
10135 (mail-header-subject
10136 (gnus-data-header (car data)))))))
10137 (push (gnus-data-number (car data)) articles))
10138 (unless (and (setq data (cdr data))
10139 (> (gnus-data-level (car data)) top-level))
10141 ;; Return the list of articles.
10142 (nreverse articles)))
10144 (defun gnus-summary-rethread-current ()
10145 "Rethread the thread the current article is part of."
10147 (let* ((gnus-show-threads t)
10148 (article (gnus-summary-article-number))
10149 (id (mail-header-id (gnus-summary-article-header)))
10150 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
10152 (error "No article on the current line"))
10153 (gnus-rebuild-thread id)
10154 (gnus-summary-goto-subject article)))
10156 (defun gnus-summary-reparent-thread ()
10157 "Make the current article child of the marked (or previous) article.
10159 Note that the re-threading will only work if `gnus-thread-ignore-subject'
10160 is non-nil or the Subject: of both articles are the same."
10162 (unless (not (gnus-group-read-only-p))
10163 (error "The current newsgroup does not support article editing"))
10164 (unless (<= (length gnus-newsgroup-processable) 1)
10165 (error "No more than one article may be marked"))
10166 (save-window-excursion
10167 (let ((gnus-article-buffer " *reparent*")
10168 (current-article (gnus-summary-article-number))
10169 ;; First grab the marked article, otherwise one line up.
10170 (parent-article (if (not (null gnus-newsgroup-processable))
10171 (car gnus-newsgroup-processable)
10173 (if (eq (forward-line -1) 0)
10174 (gnus-summary-article-number)
10175 (error "Beginning of summary buffer"))))))
10176 (unless (not (eq current-article parent-article))
10177 (error "An article may not be self-referential"))
10178 (let ((message-id (mail-header-id
10179 (gnus-summary-article-header parent-article))))
10180 (unless (and message-id (not (equal message-id "")))
10181 (error "No message-id in desired parent"))
10182 (gnus-with-article current-article
10184 (goto-char (point-min))
10185 (message-narrow-to-head)
10186 (if (re-search-forward "^References: " nil t)
10188 (re-search-forward "^[^ \t]" nil t)
10191 (insert " " message-id))
10192 (insert "References: " message-id "\n"))))
10193 (set-buffer gnus-summary-buffer)
10194 (gnus-summary-unmark-all-processable)
10195 (gnus-summary-update-article current-article)
10196 (if (gnus-summary-goto-subject (cdr gnus-article-current) nil t)
10197 (gnus-summary-update-secondary-mark (cdr gnus-article-current)))
10198 (gnus-summary-rethread-current)
10199 (gnus-message 3 "Article %d is now the child of article %d"
10200 current-article parent-article)))))
10202 (defun gnus-summary-toggle-threads (&optional arg)
10203 "Toggle showing conversation threads.
10204 If ARG is positive number, turn showing conversation threads on."
10206 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
10207 (setq gnus-show-threads
10208 (if (null arg) (not gnus-show-threads)
10209 (> (prefix-numeric-value arg) 0)))
10210 (gnus-summary-prepare)
10211 (gnus-summary-goto-subject current)
10212 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
10213 (gnus-summary-position-point)))
10215 (defun gnus-summary-show-all-threads ()
10216 "Show all threads."
10219 (let ((buffer-read-only nil))
10220 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
10221 (gnus-summary-position-point))
10223 (defun gnus-summary-show-thread ()
10224 "Show thread subtrees.
10225 Returns nil if no thread was there to be shown."
10227 (let ((buffer-read-only nil)
10229 ;; first goto end then to beg, to have point at beg after let
10230 (end (progn (end-of-line) (point)))
10231 (beg (progn (beginning-of-line) (point))))
10233 ;; Any hidden lines here?
10234 (search-forward "\r" end t)
10235 (subst-char-in-region beg end ?\^M ?\n t)
10237 (gnus-summary-position-point))))
10239 (defun gnus-summary-maybe-hide-threads ()
10240 "If requested, hide the threads that should be hidden."
10241 (when (and gnus-show-threads
10242 gnus-thread-hide-subtree)
10243 (gnus-summary-hide-all-threads
10244 (if (or (consp gnus-thread-hide-subtree)
10245 (gnus-functionp gnus-thread-hide-subtree))
10246 (gnus-make-predicate gnus-thread-hide-subtree)
10249 ;;; Hiding predicates.
10251 (defun gnus-article-unread-p (header)
10252 (memq (mail-header-number header) gnus-newsgroup-unreads))
10254 (defun gnus-article-unseen-p (header)
10255 (memq (mail-header-number header) gnus-newsgroup-unseen))
10257 (defun gnus-map-articles (predicate articles)
10258 "Map PREDICATE over ARTICLES and return non-nil if any predicate is non-nil."
10259 (apply 'gnus-or (mapcar predicate
10260 (mapcar 'gnus-summary-article-header articles))))
10262 (defun gnus-summary-hide-all-threads (&optional predicate)
10263 "Hide all thread subtrees.
10264 If PREDICATE is supplied, threads that satisfy this predicate
10265 will not be hidden."
10268 (goto-char (point-min))
10271 (when (or (not predicate)
10273 predicate (gnus-summary-article-children)))
10274 (gnus-summary-hide-thread))
10275 (setq end (not (zerop (gnus-summary-next-thread 1 t)))))))
10276 (gnus-summary-position-point))
10278 (defun gnus-summary-hide-thread ()
10279 "Hide thread subtrees.
10280 If PREDICATE is supplied, threads that satisfy this predicate
10281 will not be hidden.
10282 Returns nil if no threads were there to be hidden."
10284 (let ((buffer-read-only nil)
10286 (article (gnus-summary-article-number)))
10288 ;; Go forward until either the buffer ends or the subthread
10290 (when (and (not (eobp))
10291 (or (zerop (gnus-summary-next-thread 1 t))
10292 (goto-char (point-max))))
10294 (if (and (> (point) start)
10295 (search-backward "\n" start t))
10297 (subst-char-in-region start (point) ?\n ?\^M)
10298 (gnus-summary-goto-subject article))
10302 (defun gnus-summary-go-to-next-thread (&optional previous)
10303 "Go to the same level (or less) next thread.
10304 If PREVIOUS is non-nil, go to previous thread instead.
10305 Return the article number moved to, or nil if moving was impossible."
10306 (let ((level (gnus-summary-thread-level))
10307 (way (if previous -1 1))
10310 (while (and (not (eobp))
10311 (< level (gnus-summary-thread-level)))
10312 (forward-line way))
10319 (gnus-summary-article-number)
10320 (goto-char beg)))))
10322 (defun gnus-summary-next-thread (n &optional silent)
10323 "Go to the same level next N'th thread.
10324 If N is negative, search backward instead.
10325 Returns the difference between N and the number of skips actually
10328 If SILENT, don't output messages."
10330 (let ((backward (< n 0))
10332 (while (and (> n 0)
10333 (gnus-summary-go-to-next-thread backward))
10336 (gnus-summary-position-point))
10337 (when (and (not silent) (/= 0 n))
10338 (gnus-message 7 "No more threads"))
10341 (defun gnus-summary-prev-thread (n)
10342 "Go to the same level previous N'th thread.
10343 Returns the difference between N and the number of skips actually
10346 (gnus-summary-next-thread (- n)))
10348 (defun gnus-summary-go-down-thread ()
10349 "Go down one level in the current thread."
10350 (let ((children (gnus-summary-article-children)))
10352 (gnus-summary-goto-subject (car children)))))
10354 (defun gnus-summary-go-up-thread ()
10355 "Go up one level in the current thread."
10356 (let ((parent (gnus-summary-article-parent)))
10358 (gnus-summary-goto-subject parent))))
10360 (defun gnus-summary-down-thread (n)
10361 "Go down thread N steps.
10362 If N is negative, go up instead.
10363 Returns the difference between N and how many steps down that were
10368 (while (and (> n 0)
10369 (if up (gnus-summary-go-up-thread)
10370 (gnus-summary-go-down-thread)))
10372 (gnus-summary-position-point)
10374 (gnus-message 7 "Can't go further"))
10377 (defun gnus-summary-up-thread (n)
10378 "Go up thread N steps.
10379 If N is negative, go down instead.
10380 Returns the difference between N and how many steps down that were
10383 (gnus-summary-down-thread (- n)))
10385 (defun gnus-summary-top-thread ()
10386 "Go to the top of the thread."
10388 (while (gnus-summary-go-up-thread))
10389 (gnus-summary-article-number))
10391 (defun gnus-summary-kill-thread (&optional unmark)
10392 "Mark articles under current thread as read.
10393 If the prefix argument is positive, remove any kinds of marks.
10394 If the prefix argument is negative, tick articles instead."
10397 (setq unmark (prefix-numeric-value unmark)))
10398 (let ((articles (gnus-summary-articles-in-thread)))
10400 ;; Expand the thread.
10401 (gnus-summary-show-thread)
10402 ;; Mark all the articles.
10404 (gnus-summary-goto-subject (car articles))
10405 (cond ((null unmark)
10406 (gnus-summary-mark-article-as-read gnus-killed-mark))
10408 (gnus-summary-mark-article-as-unread gnus-unread-mark))
10410 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
10411 (setq articles (cdr articles))))
10412 ;; Hide killed subtrees.
10414 gnus-thread-hide-killed
10415 (gnus-summary-hide-thread))
10416 ;; If marked as read, go to next unread subject.
10417 (when (null unmark)
10418 ;; Go to next unread subject.
10419 (gnus-summary-next-subject 1 t)))
10420 (gnus-set-mode-line 'summary))
10422 ;; Summary sorting commands
10424 (defun gnus-summary-sort-by-number (&optional reverse)
10425 "Sort the summary buffer by article number.
10426 Argument REVERSE means reverse order."
10428 (gnus-summary-sort 'number reverse))
10430 (defun gnus-summary-sort-by-random (&optional reverse)
10431 "Randomize the order in the summary buffer.
10432 Argument REVERSE means to randomize in reverse order."
10434 (gnus-summary-sort 'random reverse))
10436 (defun gnus-summary-sort-by-author (&optional reverse)
10437 "Sort the summary buffer by author name alphabetically.
10438 If `case-fold-search' is non-nil, case of letters is ignored.
10439 Argument REVERSE means reverse order."
10441 (gnus-summary-sort 'author reverse))
10443 (defun gnus-summary-sort-by-subject (&optional reverse)
10444 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
10445 If `case-fold-search' is non-nil, case of letters is ignored.
10446 Argument REVERSE means reverse order."
10448 (gnus-summary-sort 'subject reverse))
10450 (defun gnus-summary-sort-by-date (&optional reverse)
10451 "Sort the summary buffer by date.
10452 Argument REVERSE means reverse order."
10454 (gnus-summary-sort 'date reverse))
10456 (defun gnus-summary-sort-by-score (&optional reverse)
10457 "Sort the summary buffer by score.
10458 Argument REVERSE means reverse order."
10460 (gnus-summary-sort 'score reverse))
10462 (defun gnus-summary-sort-by-lines (&optional reverse)
10463 "Sort the summary buffer by the number of lines.
10464 Argument REVERSE means reverse order."
10466 (gnus-summary-sort 'lines reverse))
10468 (defun gnus-summary-sort-by-chars (&optional reverse)
10469 "Sort the summary buffer by article length.
10470 Argument REVERSE means reverse order."
10472 (gnus-summary-sort 'chars reverse))
10474 (defun gnus-summary-sort-by-original (&optional reverse)
10475 "Sort the summary buffer using the default sorting method.
10476 Argument REVERSE means reverse order."
10478 (let* ((buffer-read-only)
10479 (gnus-summary-prepare-hook nil))
10480 ;; We do the sorting by regenerating the threads.
10481 (gnus-summary-prepare)
10482 ;; Hide subthreads if needed.
10483 (gnus-summary-maybe-hide-threads)))
10485 (defun gnus-summary-sort (predicate reverse)
10486 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
10487 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
10488 (article (intern (format "gnus-article-sort-by-%s" predicate)))
10489 (gnus-thread-sort-functions
10494 (gnus-sort-gathered-threads-function
10495 gnus-thread-sort-functions)
10496 (gnus-article-sort-functions
10500 (,article t2 t1))))
10502 (gnus-summary-prepare-hook nil))
10503 ;; We do the sorting by regenerating the threads.
10504 (gnus-summary-prepare)
10505 ;; Hide subthreads if needed.
10506 (gnus-summary-maybe-hide-threads)))
10508 ;; Summary saving commands.
10510 (defun gnus-summary-save-article (&optional n not-saved)
10511 "Save the current article using the default saver function.
10512 If N is a positive number, save the N next articles.
10513 If N is a negative number, save the N previous articles.
10514 If N is nil and any articles have been marked with the process mark,
10515 save those articles instead.
10516 The variable `gnus-default-article-saver' specifies the saver function."
10518 (let* ((articles (gnus-summary-work-articles n))
10519 (save-buffer (save-excursion
10520 (nnheader-set-temp-buffer " *Gnus Save*")))
10521 (num (length articles))
10523 (dolist (article articles)
10524 (setq header (gnus-summary-article-header article))
10525 (if (not (vectorp header))
10526 ;; This is a pseudo-article.
10527 (if (assq 'name header)
10528 (gnus-copy-file (cdr (assq 'name header)))
10529 (gnus-message 1 "Article %d is unsaveable" article))
10530 ;; This is a real article.
10531 (save-window-excursion
10532 (let ((gnus-display-mime-function nil)
10533 (gnus-article-prepare-hook nil))
10534 (gnus-summary-select-article t nil nil article)))
10536 (set-buffer save-buffer)
10538 (insert-buffer-substring gnus-original-article-buffer))
10539 (setq file (gnus-article-save save-buffer file num))
10540 (gnus-summary-remove-process-mark article)
10542 (gnus-summary-set-saved-mark article))))
10543 (gnus-kill-buffer save-buffer)
10544 (gnus-summary-position-point)
10545 (gnus-set-mode-line 'summary)
10548 (defun gnus-summary-pipe-output (&optional arg)
10549 "Pipe the current article to a subprocess.
10550 If N is a positive number, pipe the N next articles.
10551 If N is a negative number, pipe the N previous articles.
10552 If N is nil and any articles have been marked with the process mark,
10553 pipe those articles instead."
10555 (require 'gnus-art)
10556 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
10557 (gnus-summary-save-article arg t))
10558 (let ((buffer (get-buffer "*Shell Command Output*")))
10560 (with-current-buffer buffer (> (point-max) (point-min))))
10561 (gnus-configure-windows 'pipe))))
10563 (defun gnus-summary-save-article-mail (&optional arg)
10564 "Append the current article to an mail file.
10565 If N is a positive number, save the N next articles.
10566 If N is a negative number, save the N previous articles.
10567 If N is nil and any articles have been marked with the process mark,
10568 save those articles instead."
10570 (require 'gnus-art)
10571 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
10572 (gnus-summary-save-article arg)))
10574 (defun gnus-summary-save-article-rmail (&optional arg)
10575 "Append the current article to an rmail file.
10576 If N is a positive number, save the N next articles.
10577 If N is a negative number, save the N previous articles.
10578 If N is nil and any articles have been marked with the process mark,
10579 save those articles instead."
10581 (require 'gnus-art)
10582 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
10583 (gnus-summary-save-article arg)))
10585 (defun gnus-summary-save-article-file (&optional arg)
10586 "Append the current article to a file.
10587 If N is a positive number, save the N next articles.
10588 If N is a negative number, save the N previous articles.
10589 If N is nil and any articles have been marked with the process mark,
10590 save those articles instead."
10592 (require 'gnus-art)
10593 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
10594 (gnus-summary-save-article arg)))
10596 (defun gnus-summary-write-article-file (&optional arg)
10597 "Write the current article to a file, deleting the previous file.
10598 If N is a positive number, save the N next articles.
10599 If N is a negative number, save the N previous articles.
10600 If N is nil and any articles have been marked with the process mark,
10601 save those articles instead."
10603 (require 'gnus-art)
10604 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
10605 (gnus-summary-save-article arg)))
10607 (defun gnus-summary-save-article-body-file (&optional arg)
10608 "Append the current article body to a file.
10609 If N is a positive number, save the N next articles.
10610 If N is a negative number, save the N previous articles.
10611 If N is nil and any articles have been marked with the process mark,
10612 save those articles instead."
10614 (require 'gnus-art)
10615 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
10616 (gnus-summary-save-article arg)))
10618 (defun gnus-summary-muttprint (&optional arg)
10619 "Print the current article using Muttprint.
10620 If N is a positive number, save the N next articles.
10621 If N is a negative number, save the N previous articles.
10622 If N is nil and any articles have been marked with the process mark,
10623 save those articles instead."
10625 (require 'gnus-art)
10626 (let ((gnus-default-article-saver 'gnus-summary-pipe-to-muttprint))
10627 (gnus-summary-save-article arg t)))
10629 (defun gnus-summary-pipe-message (program)
10630 "Pipe the current article through PROGRAM."
10631 (interactive "sProgram: ")
10632 (gnus-summary-select-article)
10633 (let ((mail-header-separator ""))
10634 (gnus-eval-in-buffer-window gnus-article-buffer
10637 (let ((start (window-start))
10639 (message-pipe-buffer-body program)
10640 (set-window-start (get-buffer-window (current-buffer)) start))))))
10642 (defun gnus-get-split-value (methods)
10643 "Return a value based on the split METHODS."
10644 (let (split-name method result match)
10647 (set-buffer gnus-original-article-buffer)
10649 (nnheader-narrow-to-headers)
10650 (while (and methods (not split-name))
10651 (goto-char (point-min))
10652 (setq method (pop methods))
10653 (setq match (car method))
10656 ;; Regular expression.
10658 (re-search-forward match nil t)))
10659 ((gnus-functionp match)
10663 (setq result (funcall match gnus-newsgroup-name))))
10668 (setq result (eval match)))))
10669 (setq split-name (cdr method))
10670 (cond ((stringp result)
10671 (push (expand-file-name
10672 result gnus-article-save-directory)
10675 (setq split-name (append result split-name)))))))))
10676 (nreverse split-name)))
10678 (defun gnus-valid-move-group-p (group)
10679 (and (boundp group)
10680 (symbol-name group)
10681 (symbol-value group)
10682 (gnus-get-function (gnus-find-method-for-group
10683 (symbol-name group)) 'request-accept-article t)))
10685 (defun gnus-read-move-group-name (prompt default articles prefix)
10686 "Read a group name."
10687 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
10688 (minibuffer-confirm-incomplete nil) ; XEmacs
10690 (format "%s %s to:"
10692 (if (> (length articles) 1)
10693 (format "these %d articles" (length articles))
10698 (gnus-completing-read-with-default
10701 'gnus-valid-move-group-p
10703 'gnus-group-history))
10704 ((= 1 (length split-name))
10705 (gnus-completing-read-with-default
10706 (car split-name) prom
10708 'gnus-valid-move-group-p
10710 'gnus-group-history))
10712 (gnus-completing-read-with-default
10714 (mapcar (lambda (el) (list el))
10715 (nreverse split-name))
10717 'gnus-group-history))))
10718 (to-method (gnus-server-to-method (gnus-group-method to-newsgroup))))
10720 (if (or (string= to-newsgroup "")
10721 (string= to-newsgroup prefix))
10722 (setq to-newsgroup default))
10723 (unless to-newsgroup
10724 (error "No group name entered"))
10725 (or (gnus-active to-newsgroup)
10726 (gnus-activate-group to-newsgroup nil nil to-method)
10727 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
10729 (or (and (gnus-request-create-group to-newsgroup to-method)
10730 (gnus-activate-group
10731 to-newsgroup nil nil to-method)
10732 (gnus-subscribe-group to-newsgroup))
10733 (error "Couldn't create group %s" to-newsgroup)))
10734 (error "No such group: %s" to-newsgroup)))
10737 (defun gnus-summary-save-parts (type dir n &optional reverse)
10738 "Save parts matching TYPE to DIR.
10739 If REVERSE, save parts that do not match TYPE."
10741 (list (read-string "Save parts of type: "
10742 (or (car gnus-summary-save-parts-type-history)
10743 gnus-summary-save-parts-default-mime)
10744 'gnus-summary-save-parts-type-history)
10745 (setq gnus-summary-save-parts-last-directory
10746 (read-file-name "Save to directory: "
10747 gnus-summary-save-parts-last-directory
10749 current-prefix-arg))
10750 (gnus-summary-iterate n
10751 (let ((gnus-display-mime-function nil)
10752 (gnus-inhibit-treatment t))
10753 (gnus-summary-select-article))
10755 (set-buffer gnus-article-buffer)
10756 (let ((handles (or gnus-article-mime-handles
10757 (mm-dissect-buffer nil gnus-article-loose-mime)
10760 (gnus-summary-save-parts-1 type dir handles reverse)
10761 (unless gnus-article-mime-handles ;; Don't destroy this case.
10762 (mm-destroy-parts handles)))))))
10764 (defun gnus-summary-save-parts-1 (type dir handle reverse)
10765 (if (stringp (car handle))
10766 (mapcar (lambda (h) (gnus-summary-save-parts-1 type dir h reverse))
10769 (not (string-match type (mm-handle-media-type handle)))
10770 (string-match type (mm-handle-media-type handle)))
10771 (let ((file (expand-file-name
10772 (file-name-nondirectory
10774 (mail-content-type-get
10775 (mm-handle-disposition handle) 'filename)
10776 (concat gnus-newsgroup-name
10777 "." (number-to-string
10778 (cdr gnus-article-current)))))
10780 (unless (file-exists-p file)
10781 (mm-save-part-to-file handle file))))))
10783 ;; Summary extract commands
10785 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
10786 (let ((buffer-read-only nil)
10787 (article (gnus-summary-article-number))
10789 (unless (gnus-summary-goto-subject article)
10790 (error "No such article: %d" article))
10791 (gnus-summary-position-point)
10792 ;; If all commands are to be bunched up on one line, we collect
10794 (unless gnus-view-pseudos-separately
10795 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
10798 (setq action (cdr (assq 'action (car ps))))
10799 (setq files (list (cdr (assq 'name (car ps)))))
10800 (while (and ps (cdr ps)
10801 (string= (or action "1")
10802 (or (cdr (assq 'action (cadr ps))) "2")))
10803 (push (cdr (assq 'name (cadr ps))) files)
10804 (setcdr ps (cddr ps)))
10806 (when (not (string-match "%s" action))
10809 (when (assq 'execute (car ps))
10810 (setcdr (assq 'execute (car ps))
10811 (funcall (if (string-match "%s" action)
10818 (gnus-quote-arg-for-sh-or-csh f)))
10820 (setq ps (cdr ps)))))
10821 (if (and gnus-view-pseudos (not not-view))
10823 (when (assq 'execute (car pslist))
10824 (gnus-execute-command (cdr (assq 'execute (car pslist)))
10825 (eq gnus-view-pseudos 'not-confirm)))
10826 (setq pslist (cdr pslist)))
10829 (setq after-article (or (cdr (assq 'article (car pslist)))
10830 (gnus-summary-article-number)))
10831 (gnus-summary-goto-subject after-article)
10834 (insert " " (file-name-nondirectory
10835 (cdr (assq 'name (car pslist))))
10836 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
10838 (forward-line -1) ; back to `b'
10839 (gnus-add-text-properties
10840 b (1- e) (list 'gnus-number gnus-reffed-article-number
10841 gnus-mouse-face-prop gnus-mouse-face))
10843 after-article gnus-reffed-article-number
10844 gnus-unread-mark b (car pslist) 0 (- e b))
10845 (setq gnus-newsgroup-unreads
10846 (gnus-add-to-sorted-list gnus-newsgroup-unreads
10847 gnus-reffed-article-number))
10848 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
10849 (setq pslist (cdr pslist)))))))
10851 (defun gnus-pseudos< (p1 p2)
10852 (let ((c1 (cdr (assq 'action p1)))
10853 (c2 (cdr (assq 'action p2))))
10854 (and c1 c2 (string< c1 c2))))
10856 (defun gnus-request-pseudo-article (props)
10857 (cond ((assq 'execute props)
10858 (gnus-execute-command (cdr (assq 'execute props)))))
10859 (let ((gnus-current-article (gnus-summary-article-number)))
10860 (gnus-run-hooks 'gnus-mark-article-hook)))
10862 (defun gnus-execute-command (command &optional automatic)
10864 (gnus-article-setup-buffer)
10865 (set-buffer gnus-article-buffer)
10866 (setq buffer-read-only nil)
10867 (let ((command (if automatic command
10868 (read-string "Command: " (cons command 0)))))
10870 (insert "$ " command "\n\n")
10871 (if gnus-view-pseudo-asynchronously
10872 (start-process "gnus-execute" (current-buffer) shell-file-name
10873 shell-command-switch command)
10874 (call-process shell-file-name nil t nil
10875 shell-command-switch command)))))
10877 ;; Summary kill commands.
10879 (defun gnus-summary-edit-global-kill (article)
10880 "Edit the \"global\" kill file."
10881 (interactive (list (gnus-summary-article-number)))
10882 (gnus-group-edit-global-kill article))
10884 (defun gnus-summary-edit-local-kill ()
10885 "Edit a local kill file applied to the current newsgroup."
10887 (setq gnus-current-headers (gnus-summary-article-header))
10888 (gnus-group-edit-local-kill
10889 (gnus-summary-article-number) gnus-newsgroup-name))
10891 ;;; Header reading.
10893 (defun gnus-read-header (id &optional header)
10894 "Read the headers of article ID and enter them into the Gnus system."
10895 (let ((group gnus-newsgroup-name)
10896 (gnus-override-method
10898 gnus-override-method
10899 (and (gnus-news-group-p gnus-newsgroup-name)
10900 (car (gnus-refer-article-methods)))))
10902 ;; First we check to see whether the header in question is already
10905 ;; This is a Message-ID.
10906 (setq header (or header (gnus-id-to-header id)))
10907 ;; This is an article number.
10908 (setq header (or header (gnus-summary-article-header id))))
10910 (not (gnus-summary-article-sparse-p (mail-header-number header))))
10911 ;; We have found the header.
10913 ;; If this is a sparse article, we have to nix out its
10914 ;; previous entry in the thread hashtb.
10916 (gnus-summary-article-sparse-p (mail-header-number header)))
10917 (let* ((parent (gnus-parent-id (mail-header-references header)))
10918 (thread (and parent (gnus-id-to-thread parent))))
10920 (delq (assq header thread) thread))))
10921 ;; We have to really fetch the header to this article.
10923 (set-buffer nntp-server-buffer)
10924 (when (setq where (gnus-request-head id group))
10925 (nnheader-fold-continuation-lines)
10926 (goto-char (point-max))
10928 (goto-char (point-min))
10932 ((cdr where) (cdr where))
10933 (header (mail-header-number header))
10934 (t gnus-reffed-article-number))
10936 (insert " Article retrieved.\n"))
10937 (if (or (not where)
10938 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
10939 () ; Malformed head.
10940 (unless (gnus-summary-article-sparse-p (mail-header-number header))
10941 (when (and (stringp id)
10942 (not (string= (gnus-group-real-name group)
10944 ;; If we fetched by Message-ID and the article came
10945 ;; from a different group, we fudge some bogus article
10946 ;; numbers for this article.
10947 (mail-header-set-number header gnus-reffed-article-number))
10949 (set-buffer gnus-summary-buffer)
10950 (decf gnus-reffed-article-number)
10951 (gnus-remove-header (mail-header-number header))
10952 (push header gnus-newsgroup-headers)
10953 (setq gnus-current-headers header)
10954 (push (mail-header-number header) gnus-newsgroup-limit)))
10957 (defun gnus-remove-header (number)
10958 "Remove header NUMBER from `gnus-newsgroup-headers'."
10959 (if (and gnus-newsgroup-headers
10960 (= number (mail-header-number (car gnus-newsgroup-headers))))
10961 (pop gnus-newsgroup-headers)
10962 (let ((headers gnus-newsgroup-headers))
10963 (while (and (cdr headers)
10964 (not (= number (mail-header-number (cadr headers)))))
10966 (when (cdr headers)
10967 (setcdr headers (cddr headers))))))
10970 ;;; summary highlights
10973 (defun gnus-highlight-selected-summary ()
10974 "Highlight selected article in summary buffer."
10975 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
10976 (when gnus-summary-selected-face
10978 (let* ((beg (progn (beginning-of-line) (point)))
10979 (end (progn (end-of-line) (point)))
10980 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
10981 (from (if (get-text-property beg gnus-mouse-face-prop)
10983 (or (next-single-property-change
10984 beg gnus-mouse-face-prop nil end)
10989 (or (next-single-property-change
10990 from gnus-mouse-face-prop nil end)
10992 ;; If no mouse-face prop on line we will have to = from = end,
10993 ;; so we highlight the entire line instead.
10994 (when (= (+ to 2) from)
10997 (if gnus-newsgroup-selected-overlay
10998 ;; Move old overlay.
11000 gnus-newsgroup-selected-overlay from to (current-buffer))
11001 ;; Create new overlay.
11003 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
11004 'face gnus-summary-selected-face))))))
11006 (defvar gnus-summary-highlight-line-cached nil)
11007 (defvar gnus-summary-highlight-line-trigger nil)
11009 (defun gnus-summary-highlight-line-0 ()
11010 (if (and (eq gnus-summary-highlight-line-trigger
11011 gnus-summary-highlight)
11012 gnus-summary-highlight-line-cached)
11013 gnus-summary-highlight-line-cached
11014 (setq gnus-summary-highlight-line-trigger gnus-summary-highlight
11015 gnus-summary-highlight-line-cached
11016 (let* ((cond (list 'cond))
11018 (list gnus-summary-highlight))
11020 (setcdr c (cons (list (caar list) (list 'quote (cdar list))) nil))
11023 (gnus-byte-compile (list 'lambda nil cond))))))
11025 (defun gnus-summary-highlight-line ()
11026 "Highlight current line according to `gnus-summary-highlight'."
11027 (let* ((beg (gnus-point-at-bol))
11028 (article (or (gnus-summary-article-number) gnus-current-article))
11029 (score (or (cdr (assq article
11030 gnus-newsgroup-scored))
11031 gnus-summary-default-score 0))
11032 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
11033 (inhibit-read-only t)
11034 (default gnus-summary-default-score)
11035 (default-high gnus-summary-default-high-score)
11036 (default-low gnus-summary-default-low-score)
11037 (uncached (memq article gnus-newsgroup-undownloaded))
11038 (downloaded (not uncached)))
11039 (let ((face (funcall (gnus-summary-highlight-line-0))))
11040 (unless (eq face (get-text-property beg 'face))
11041 (gnus-put-text-property-excluding-characters-with-faces
11042 beg (gnus-point-at-eol) 'face
11043 (setq face (if (boundp face) (symbol-value face) face)))
11044 (when gnus-summary-highlight-line-function
11045 (funcall gnus-summary-highlight-line-function article face))))))
11047 (defun gnus-update-read-articles (group unread &optional compute)
11048 "Update the list of read articles in GROUP.
11049 UNREAD is a sorted list."
11050 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
11051 (entry (gnus-gethash group gnus-newsrc-hashtb))
11052 (info (nth 2 entry))
11055 (if (or (not info) (not active))
11056 ;; There is no info on this group if it was, in fact,
11057 ;; killed. Gnus stores no information on killed groups, so
11058 ;; there's nothing to be done.
11059 ;; One could store the information somewhere temporarily,
11060 ;; perhaps... Hmmm...
11062 ;; Remove any negative articles numbers.
11063 (while (and unread (< (car unread) 0))
11064 (setq unread (cdr unread)))
11065 ;; Remove any expired article numbers
11066 (while (and unread (< (car unread) (car active)))
11067 (setq unread (cdr unread)))
11068 ;; Compute the ranges of read articles by looking at the list of
11069 ;; unread articles.
11071 (when (/= (car unread) prev)
11072 (push (if (= prev (1- (car unread))) prev
11073 (cons prev (1- (car unread))))
11075 (setq prev (1+ (car unread)))
11076 (setq unread (cdr unread)))
11077 (when (<= prev (cdr active))
11078 (push (cons prev (cdr active)) read))
11079 (setq read (if (> (length read) 1) (nreverse read) read))
11084 ;; Propagate the read marks to the backend.
11085 (when (gnus-check-backend-function 'request-set-mark group)
11086 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
11087 (add (gnus-remove-from-range read (gnus-info-read info))))
11089 (unless (gnus-check-group group)
11090 (error "Can't open server for %s" group))
11091 (gnus-request-set-mark
11092 group (delq nil (list (if add (list add 'add '(read)))
11093 (if del (list del 'del '(read))))))
11095 `(gnus-request-set-mark
11098 (if del (list del 'add '(read)))
11099 (if add (list add 'del '(read))))))))))
11100 (set-buffer gnus-group-buffer)
11101 (gnus-undo-register
11103 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
11104 (gnus-info-set-read ',info ',(gnus-info-read info))
11105 (gnus-get-unread-articles-in-group ',info
11106 (gnus-active ,group))
11107 (gnus-group-update-group ,group t)
11109 ;; Enter this list into the group info.
11110 (gnus-info-set-read info read)
11111 ;; Set the number of unread articles in gnus-newsrc-hashtb.
11112 (gnus-get-unread-articles-in-group info (gnus-active group))
11115 (defun gnus-offer-save-summaries ()
11116 "Offer to save all active summary buffers."
11118 ;; Go through all buffers and find all summaries.
11119 (dolist (buffer (buffer-list))
11120 (when (and (setq buffer (buffer-name buffer))
11121 (string-match "Summary" buffer)
11123 (set-buffer buffer)
11124 ;; We check that this is, indeed, a summary buffer.
11125 (and (eq major-mode 'gnus-summary-mode)
11126 ;; Also make sure this isn't bogus.
11127 gnus-newsgroup-prepared
11128 ;; Also make sure that this isn't a
11129 ;; dead summary buffer.
11130 (not gnus-dead-summary-mode))))
11131 (push buffer buffers)))
11132 ;; Go through all these summary buffers and offer to save them.
11136 "Update summary buffer %s? "
11138 (switch-to-buffer buf)
11139 (gnus-summary-exit))
11143 ;;; @ for mime-partial
11146 (defun gnus-request-partial-message ()
11148 (let ((number (gnus-summary-article-number))
11149 (group gnus-newsgroup-name)
11150 (mother gnus-article-buffer))
11151 (set-buffer (get-buffer-create " *Partial Article*"))
11153 (setq mime-preview-buffer mother)
11154 (gnus-request-article-this-buffer number group)
11155 (mime-parse-buffer)
11158 (autoload 'mime-combine-message/partial-pieces-automatically
11160 "Internal method to combine message/partial messages automatically.")
11162 (mime-add-condition
11163 'action '((type . message)(subtype . partial)
11164 (major-mode . gnus-original-article-mode)
11165 (method . mime-combine-message/partial-pieces-automatically)
11166 (summary-buffer-exp . gnus-summary-buffer)
11167 (request-partial-message-method . gnus-request-partial-message)
11171 ;;; @ for message/rfc822
11174 (defun gnus-mime-extract-message/rfc822 (entity situation)
11175 "Burst a forwarded article."
11177 (set-buffer gnus-summary-buffer)
11178 (let* ((group (completing-read "Group: " gnus-active-hashtb nil t
11179 gnus-newsgroup-name 'gnus-group-history))
11180 (gnus-group-marked (list group))
11183 (mime-insert-entity-content entity)
11184 (setq article (gnus-request-accept-article group)))
11185 (when (and (consp article)
11186 (numberp (setq article (cdr article))))
11187 (setq info (gnus-get-info group))
11188 (gnus-info-set-read info
11189 (gnus-remove-from-range (gnus-info-read info)
11191 (when (string-equal group gnus-newsgroup-name)
11193 (let (gnus-show-threads)
11194 (gnus-summary-goto-subject article t))
11195 (gnus-summary-clear-mark-forward 1))
11196 (set-buffer gnus-group-buffer)
11197 (gnus-group-get-new-news-this-group nil t)))))
11199 (mime-add-condition
11200 'action '((type . message)(subtype . rfc822)
11201 (major-mode . gnus-original-article-mode)
11202 (method . gnus-mime-extract-message/rfc822)
11206 (mime-add-condition
11207 'action '((type . message)(subtype . news)
11208 (major-mode . gnus-original-article-mode)
11209 (method . gnus-mime-extract-message/rfc822)
11213 (defun gnus-mime-extract-multipart (entity situation)
11214 (let ((children (mime-entity-children entity))
11215 mime-acting-situation-to-override
11218 (mime-play-entity (car children)
11219 (cons (assq 'mode situation)
11220 mime-acting-situation-to-override))
11221 (setq children (cdr children)))
11222 (if (setq f (cdr (assq 'after-method
11223 mime-acting-situation-to-override)))
11227 (mime-add-condition
11228 'action '((type . multipart)
11229 (method . gnus-mime-extract-multipart)
11238 (defun gnus-summary-inherit-default-charset ()
11239 "Import `default-mime-charset' from summary buffer.
11240 Also take care of `default-mime-charset-unlimited' if the LIMIT version
11242 (if (buffer-live-p gnus-summary-buffer)
11243 (let (d-m-c d-m-c-u)
11244 (with-current-buffer gnus-summary-buffer
11245 (setq d-m-c (if (local-variable-p 'default-mime-charset
11246 gnus-summary-buffer)
11247 default-mime-charset
11250 d-m-c-u (if (local-variable-p 'default-mime-charset-unlimited
11251 gnus-summary-buffer)
11252 (symbol-value 'default-mime-charset-unlimited)
11255 (kill-local-variable 'default-mime-charset)
11256 (set (make-local-variable 'default-mime-charset) d-m-c))
11258 (kill-local-variable 'default-mime-charset-unlimited)
11259 (set (make-local-variable 'default-mime-charset-unlimited)
11262 (defun gnus-summary-setup-default-charset ()
11263 "Setup newsgroup default charset."
11264 (if (member gnus-newsgroup-name '("nndraft:delayed" "nndraft:drafts"))
11266 (setq gnus-newsgroup-charset nil)
11267 (set (make-local-variable 'default-mime-charset) nil)
11268 (when (boundp 'default-mime-charset-unlimited);; LIMIT
11269 (set (make-local-variable 'default-mime-charset-unlimited) nil)))
11270 (let ((ignored-charsets
11271 (or gnus-newsgroup-ephemeral-ignored-charsets
11273 (and gnus-newsgroup-name
11274 (gnus-parameter-ignored-charsets gnus-newsgroup-name))
11275 gnus-newsgroup-ignored-charsets)))
11277 (setq gnus-newsgroup-charset
11278 (or gnus-newsgroup-ephemeral-charset
11279 (when (and gnus-newsgroup-name
11280 (setq charset (gnus-parameter-charset
11281 gnus-newsgroup-name)))
11282 (make-local-variable 'default-mime-charset)
11283 (setq default-mime-charset charset))
11284 gnus-default-charset))
11285 (set (make-local-variable 'gnus-newsgroup-ignored-charsets)
11286 ignored-charsets))))
11292 (defun gnus-summary-display-buttonized (&optional show-all-parts)
11293 "Display the current article buffer fully MIME-buttonized.
11294 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
11295 treated as multipart/mixed."
11297 (require 'gnus-art)
11298 (let ((gnus-unbuttonized-mime-types nil)
11299 (gnus-mime-display-multipart-as-mixed show-all-parts))
11300 (gnus-summary-show-article)))
11302 (defun gnus-summary-repair-multipart (article)
11303 "Add a Content-Type header to a multipart article without one."
11304 (interactive (list (gnus-summary-article-number)))
11305 (gnus-with-article article
11306 (message-narrow-to-head)
11307 (message-remove-header "Mime-Version")
11308 (goto-char (point-max))
11309 (insert "Mime-Version: 1.0\n")
11311 (when (search-forward "\n--" nil t)
11312 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
11313 (message-narrow-to-head)
11314 (message-remove-header "Content-Type")
11315 (goto-char (point-max))
11316 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
11319 (let (gnus-mark-article-hook)
11320 (gnus-summary-select-article t t nil article)))
11322 (defun gnus-summary-toggle-display-buttonized ()
11323 "Toggle the buttonizing of the article buffer."
11325 (require 'gnus-art)
11326 (if (setq gnus-inhibit-mime-unbuttonizing
11327 (not gnus-inhibit-mime-unbuttonizing))
11328 (let ((gnus-unbuttonized-mime-types nil))
11329 (gnus-summary-show-article))
11330 (gnus-summary-show-article)))
11333 ;;; Intelli-mouse commmands
11336 (defun gnus-wheel-summary-scroll (event)
11338 (let ((amount (if (memq 'shift (event-modifiers event))
11339 (car gnus-wheel-scroll-amount)
11340 (cdr gnus-wheel-scroll-amount)))
11341 (direction (- (* (static-if (featurep 'xemacs)
11342 (event-button event)
11343 (cond ((eq 'mouse-4 (event-basic-type event))
11345 ((eq 'mouse-5 (event-basic-type event))
11349 (gnus-summary-scroll-up (* amount direction))
11350 (when (gnus-eval-in-buffer-window gnus-article-buffer
11353 (and (if (< 0 direction)
11354 (gnus-article-next-page 0)
11355 (gnus-article-prev-page 0)
11357 (if (setq edge (get-text-property
11358 (point-min) 'gnus-wheel-edge))
11359 (setq edge (* edge direction))
11362 (let ((buffer-read-only nil)
11363 (inhibit-read-only t))
11364 (put-text-property (point-min) (point-max)
11365 'gnus-wheel-edge direction)
11367 (or (> edge gnus-wheel-edge-resistance)
11368 (let ((buffer-read-only nil)
11369 (inhibit-read-only t))
11370 (put-text-property (point-min) (point-max)
11372 (* (1+ edge) direction))
11374 (eq last-command 'gnus-wheel-summary-scroll))))
11375 (gnus-summary-next-article nil nil (minusp direction)))))
11377 (defun gnus-wheel-install ()
11378 "Enable mouse wheel support on summary window."
11379 (when gnus-use-wheel
11381 '([(mouse-4)] [(shift mouse-4)] [(mouse-5)] [(shift mouse-5)])))
11383 (define-key gnus-summary-mode-map key
11384 'gnus-wheel-summary-scroll)))))
11386 (add-hook 'gnus-summary-mode-hook 'gnus-wheel-install)
11389 ;;; Traditional PGP commmands
11392 (defun gnus-summary-decrypt-article (&optional force)
11393 "Decrypt the current article in traditional PGP way.
11394 This will have permanent effect only in mail groups.
11395 If FORCE is non-nil, allow editing of articles even in read-only
11398 (gnus-summary-select-article t)
11399 (gnus-eval-in-buffer-window gnus-article-buffer
11403 (goto-char (point-min))
11404 (unless (re-search-forward (car pgg-armor-header-lines) nil t)
11405 (error "Not a traditional PGP message!"))
11406 (let ((armor-start (match-beginning 0)))
11407 (if (and (pgg-decrypt-region armor-start (point-max))
11408 (or force (not (gnus-group-read-only-p))))
11409 (let ((inhibit-read-only t)
11411 (delete-region armor-start
11413 (re-search-forward "^-+END PGP" nil t)
11414 (beginning-of-line 2)
11416 (insert-buffer-substring pgg-output-buffer))))))))
11418 (defun gnus-summary-verify-article ()
11419 "Verify the current article in traditional PGP way."
11422 (set-buffer gnus-original-article-buffer)
11423 (goto-char (point-min))
11424 (unless (re-search-forward "^-+BEGIN PGP SIGNED MESSAGE" nil t)
11425 (error "Not a traditional PGP message!"))
11426 (re-search-forward "^-+END PGP" nil t)
11427 (beginning-of-line 2)
11428 (call-interactively (function pgg-verify-region))))
11431 ;;; Generic summary marking commands
11434 (defvar gnus-summary-marking-alist
11435 '((read gnus-del-mark "d")
11436 (unread gnus-unread-mark "u")
11437 (ticked gnus-ticked-mark "!")
11438 (dormant gnus-dormant-mark "?")
11439 (expirable gnus-expirable-mark "e"))
11440 "An alist of names/marks/keystrokes.")
11442 (defvar gnus-summary-generic-mark-map (make-sparse-keymap))
11443 (defvar gnus-summary-mark-map)
11445 (defun gnus-summary-make-all-marking-commands ()
11446 (define-key gnus-summary-mark-map "M" gnus-summary-generic-mark-map)
11447 (dolist (elem gnus-summary-marking-alist)
11448 (apply 'gnus-summary-make-marking-command elem)))
11450 (defun gnus-summary-make-marking-command (name mark keystroke)
11451 (let ((map (make-sparse-keymap)))
11452 (define-key gnus-summary-generic-mark-map keystroke map)
11453 (dolist (lway `((next "next" next nil "n")
11454 (next-unread "next unread" next t "N")
11455 (prev "previous" prev nil "p")
11456 (prev-unread "previous unread" prev t "P")
11457 (nomove "" nil nil ,keystroke)))
11458 (let ((func (gnus-summary-make-marking-command-1
11459 mark (car lway) lway name)))
11460 (setq func (eval func))
11461 (define-key map (nth 4 lway) func)))))
11463 (defun gnus-summary-make-marking-command-1 (mark way lway name)
11465 (format "gnus-summary-put-mark-as-%s%s"
11466 name (if (eq way 'nomove)
11468 (concat "-" (symbol-name way)))))
11471 "Mark the current article as %s%s.
11472 If N, the prefix, then repeat N times.
11473 If N is negative, move in reverse order.
11474 The difference between N and the actual number of articles marked is
11476 name (car (cdr lway)))
11478 (gnus-summary-generic-mark n ,mark ',(nth 2 lway) ,(nth 3 lway))))
11480 (defun gnus-summary-generic-mark (n mark move unread)
11481 "Mark N articles with MARK."
11482 (unless (eq major-mode 'gnus-summary-mode)
11483 (error "This command can only be used in the summary buffer"))
11484 (gnus-summary-show-thread)
11487 ((eq move 'next) 1)
11488 ((eq move 'prev) -1)
11490 (if (zerop nummove)
11494 nummove (* -1 nummove))))
11495 (while (and (> n 0)
11496 (gnus-summary-mark-article nil mark)
11497 (zerop (gnus-summary-next-subject nummove unread t)))
11500 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
11501 (gnus-summary-recenter)
11502 (gnus-summary-position-point)
11503 (gnus-set-mode-line 'summary)
11506 (defun gnus-summary-insert-articles (articles)
11507 (when (setq articles
11508 (gnus-sorted-difference articles
11509 (mapcar (lambda (h)
11510 (mail-header-number h))
11511 gnus-newsgroup-headers)))
11512 (setq gnus-newsgroup-headers
11514 gnus-newsgroup-headers
11515 (gnus-fetch-headers articles)
11516 'gnus-article-sort-by-number))
11517 ;; Suppress duplicates?
11518 (when gnus-suppress-duplicates
11519 (gnus-dup-suppress-articles))
11521 ;; We might want to build some more threads first.
11522 (when (and gnus-fetch-old-headers
11523 (eq gnus-headers-retrieved-by 'nov))
11524 (if (eq gnus-fetch-old-headers 'invisible)
11525 (gnus-build-all-threads)
11526 (gnus-build-old-threads)))
11527 ;; Let the Gnus agent mark articles as read.
11529 (gnus-agent-get-undownloaded-list))
11530 ;; Remove list identifiers from subject
11531 (when gnus-list-identifiers
11532 (gnus-summary-remove-list-identifiers))
11533 ;; First and last article in this newsgroup.
11534 (when gnus-newsgroup-headers
11535 (setq gnus-newsgroup-begin
11536 (mail-header-number (car gnus-newsgroup-headers))
11538 (mail-header-number
11539 (gnus-last-element gnus-newsgroup-headers))))
11540 (when gnus-use-scoring
11541 (gnus-possibly-score-headers))))
11543 (defun gnus-summary-insert-old-articles (&optional all)
11544 "Insert all old articles in this group.
11545 If ALL is non-nil, already read articles become readable.
11546 If ALL is a number, fetch this number of articles."
11549 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11552 ;; Some nntp servers lie about their active range. When
11553 ;; this happens, the active range can be in the millions.
11554 ;; Use a compressed range to avoid creating a huge list.
11555 (gnus-range-difference (list gnus-newsgroup-active) old))
11556 (setq len (gnus-range-length older))
11561 (let ((older-range (nreverse older)))
11565 (let* ((r (pop older-range))
11566 (min (if (numberp r) r (car r)))
11567 (max (if (numberp r) r (cdr r))))
11568 (while (and (<= min max)
11573 (setq older (gnus-uncompress-range older))))
11575 (setq older (gnus-uncompress-range older)))
11577 (when (and (numberp gnus-large-newsgroup)
11578 (> len gnus-large-newsgroup))
11579 (let* ((cursor-in-echo-area nil)
11580 (initial (gnus-parameter-large-newsgroup-initial
11581 gnus-newsgroup-name))
11585 "How many articles from %s (%s %d): "
11587 (gnus-group-decoded-name gnus-newsgroup-name) 35)
11588 (if initial "max" "default")
11591 (cons (number-to-string initial)
11593 (unless (string-match "^[ \t]*$" input)
11594 (setq all (string-to-number input))
11596 (let ((older-range (nreverse older)))
11600 (let* ((r (pop older-range))
11601 (min (if (numberp r) r (car r)))
11602 (max (if (numberp r) r (cdr r))))
11603 (while (and (<= min max)
11607 max (1- max))))))))))
11608 (setq older (gnus-uncompress-range older))))
11610 (message "No old news.")
11611 (gnus-summary-insert-articles older)
11612 (gnus-summary-limit (gnus-sorted-nunion old older))))
11613 (gnus-summary-position-point)))
11615 (defun gnus-summary-insert-new-articles ()
11616 "Insert all new articles in this group."
11619 (let ((old (sort (mapcar 'car gnus-newsgroup-data) '<))
11620 (old-active gnus-newsgroup-active)
11621 (nnmail-fetched-sources (list t))
11623 (setq gnus-newsgroup-active
11624 (gnus-activate-group gnus-newsgroup-name 'scan))
11625 (setq i (cdr gnus-newsgroup-active))
11626 (while (> i (cdr old-active))
11630 (message "No gnus is bad news.")
11631 (gnus-summary-insert-articles new)
11632 (setq gnus-newsgroup-unreads
11633 (gnus-sorted-nunion gnus-newsgroup-unreads new))
11634 (gnus-summary-limit (gnus-sorted-nunion old new))))
11635 (gnus-summary-position-point)))
11637 (gnus-summary-make-all-marking-commands)
11639 (gnus-ems-redefine)
11641 (provide 'gnus-sum)
11643 (run-hooks 'gnus-sum-load-hook)
11645 ;;; gnus-sum.el ends here