1 ;;; gnus-sum.el --- summary mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
43 ;; Avoid byte-compile warnings.
44 (defvar gnus-article-decoded-p)
45 (defvar gnus-decode-encoded-word-function)
48 (autoload 'gnus-summary-limit-include-cached "gnus-cache" nil t)
49 (autoload 'gnus-set-summary-default-charset "gnus-i18n" nil t)
51 (defcustom gnus-kill-summary-on-exit t
52 "*If non-nil, kill the summary buffer when you exit from it.
53 If nil, the summary will become a \"*Dead Summary*\" buffer, and
54 it will be killed sometime later."
55 :group 'gnus-summary-exit
58 (defcustom gnus-fetch-old-headers nil
59 "*Non-nil means that Gnus will try to build threads by grabbing old headers.
60 If an unread article in the group refers to an older, already read (or
61 just marked as read) article, the old article will not normally be
62 displayed in the Summary buffer. If this variable is non-nil, Gnus
63 will attempt to grab the headers to the old articles, and thereby
64 build complete threads. If it has the value `some', only enough
65 headers to connect otherwise loose threads will be displayed. This
66 variable can also be a number. In that case, no more than that number
67 of old headers will be fetched. If it has the value `invisible', all
68 old headers will be fetched, but none will be displayed.
70 The server has to support NOV for any of this to work."
72 :type '(choice (const :tag "off" nil)
75 (sexp :menu-tag "other" t)))
77 (defcustom gnus-refer-thread-limit 200
78 "*The number of old headers to fetch when doing \\<gnus-summary-mode-map>\\[gnus-summary-refer-thread].
79 If t, fetch all the available old headers."
82 (sexp :menu-tag "other" t)))
84 (defcustom gnus-summary-make-false-root 'adopt
85 "*nil means that Gnus won't gather loose threads.
86 If the root of a thread has expired or been read in a previous
87 session, the information necessary to build a complete thread has been
88 lost. Instead of having many small sub-threads from this original thread
89 scattered all over the summary buffer, Gnus can gather them.
91 If non-nil, Gnus will try to gather all loose sub-threads from an
92 original thread into one large thread.
94 If this variable is non-nil, it should be one of `none', `adopt',
97 If this variable is `none', Gnus will not make a false root, but just
98 present the sub-threads after another.
99 If this variable is `dummy', Gnus will create a dummy root that will
100 have all the sub-threads as children.
101 If this variable is `adopt', Gnus will make one of the \"children\"
102 the parent and mark all the step-children as such.
103 If this variable is `empty', the \"children\" are printed with empty
104 subject fields. (Or rather, they will be printed with a string
105 given by the `gnus-summary-same-subject' variable.)"
107 :type '(choice (const :tag "off" nil)
113 (defcustom gnus-summary-gather-exclude-subject "^ *$\\|^(none)$"
114 "*A regexp to match subjects to be excluded from loose thread gathering.
115 As loose thread gathering is done on subjects only, that means that
116 there can be many false gatherings performed. By rooting out certain
117 common subjects, gathering might become saner."
121 (defcustom gnus-summary-gather-subject-limit nil
122 "*Maximum length of subject comparisons when gathering loose threads.
123 Use nil to compare full subjects. Setting this variable to a low
124 number will help gather threads that have been corrupted by
125 newsreaders chopping off subject lines, but it might also mean that
126 unrelated articles that have subject that happen to begin with the
127 same few characters will be incorrectly gathered.
129 If this variable is `fuzzy', Gnus will use a fuzzy algorithm when
132 :type '(choice (const :tag "off" nil)
134 (sexp :menu-tag "on" t)))
136 (defcustom gnus-simplify-subject-functions nil
137 "List of functions taking a string argument that simplify subjects.
138 The functions are applied recursively.
140 Useful functions to put in this list include: `gnus-simplify-subject-re',
141 `gnus-simplify-subject-fuzzy' and `gnus-simplify-whitespace'."
143 :type '(repeat function))
145 (defcustom gnus-simplify-ignored-prefixes nil
146 "*Regexp, matches for which are removed from subject lines when simplifying fuzzily."
148 :type '(choice (const :tag "off" nil)
151 (defcustom gnus-build-sparse-threads nil
152 "*If non-nil, fill in the gaps in threads.
153 If `some', only fill in the gaps that are needed to tie loose threads
154 together. If `more', fill in all leaf nodes that Gnus can find. If
155 non-nil and non-`some', fill in all gaps that Gnus manages to guess."
157 :type '(choice (const :tag "off" nil)
160 (sexp :menu-tag "all" t)))
162 (defcustom gnus-summary-thread-gathering-function
163 'gnus-gather-threads-by-subject
164 "*Function used for gathering loose threads.
165 There are two pre-defined functions: `gnus-gather-threads-by-subject',
166 which only takes Subjects into consideration; and
167 `gnus-gather-threads-by-references', which compared the References
168 headers of the articles to find matches."
170 :type '(radio (function-item gnus-gather-threads-by-subject)
171 (function-item gnus-gather-threads-by-references)
172 (function :tag "other")))
174 (defcustom gnus-summary-same-subject ""
175 "*String indicating that the current article has the same subject as the previous.
176 This variable will only be used if the value of
177 `gnus-summary-make-false-root' is `empty'."
178 :group 'gnus-summary-format
181 (defcustom gnus-summary-goto-unread t
182 "*If t, marking commands will go to the next unread article.
183 If `never', commands that usually go to the next unread article, will
184 go to the next article, whether it is read or not.
185 If nil, only the marking commands will go to the next (un)read article."
186 :group 'gnus-summary-marks
187 :link '(custom-manual "(gnus)Setting Marks")
188 :type '(choice (const :tag "off" nil)
190 (sexp :menu-tag "on" t)))
192 (defcustom gnus-summary-default-score 0
193 "*Default article score level.
194 All scores generated by the score files will be added to this score.
195 If this variable is nil, scoring will be disabled."
196 :group 'gnus-score-default
197 :type '(choice (const :tag "disable")
200 (defcustom gnus-summary-zcore-fuzz 0
201 "*Fuzziness factor for the zcore in the summary buffer.
202 Articles with scores closer than this to `gnus-summary-default-score'
204 :group 'gnus-summary-format
207 (defcustom gnus-simplify-subject-fuzzy-regexp nil
208 "*Strings to be removed when doing fuzzy matches.
209 This can either be a regular expression or list of regular expressions
210 that will be removed from subject strings if fuzzy subject
211 simplification is selected."
213 :type '(repeat regexp))
215 (defcustom gnus-show-threads t
216 "*If non-nil, display threads in summary mode."
220 (defcustom gnus-thread-hide-subtree nil
221 "*If non-nil, hide all threads initially.
222 If threads are hidden, you have to run the command
223 `gnus-summary-show-thread' by hand or use `gnus-select-article-hook'
224 to expose hidden threads."
228 (defcustom gnus-thread-hide-killed t
229 "*If non-nil, hide killed threads automatically."
233 (defcustom gnus-thread-ignore-subject t
234 "*If non-nil, which is the default, ignore subjects and do all threading based on the Reference header.
235 If nil, articles that have different subjects from their parents will
236 start separate threads."
240 (defcustom gnus-thread-operation-ignore-subject t
241 "*If non-nil, subjects will be ignored when doing thread commands.
242 This affects commands like `gnus-summary-kill-thread' and
243 `gnus-summary-lower-thread'.
245 If this variable is nil, articles in the same thread with different
246 subjects will not be included in the operation in question. If this
247 variable is `fuzzy', only articles that have subjects that are fuzzily
248 equal will be included."
250 :type '(choice (const :tag "off" nil)
254 (defcustom gnus-thread-indent-level 4
255 "*Number that says how much each sub-thread should be indented."
259 (defcustom gnus-auto-extend-newsgroup t
260 "*If non-nil, extend newsgroup forward and backward when requested."
261 :group 'gnus-summary-choose
264 (defcustom gnus-auto-select-first t
265 "*If nil, don't select the first unread article when entering a group.
266 If this variable is `best', select the highest-scored unread article
267 in the group. If t, select the first unread article.
269 This variable can also be a function to place point on a likely
270 subject line. Useful values include `gnus-summary-first-unread-subject',
271 `gnus-summary-first-unread-article' and
272 `gnus-summary-best-unread-article'.
274 If you want to prevent automatic selection of the first unread article
275 in some newsgroups, set the variable to nil in
276 `gnus-select-group-hook'."
277 :group 'gnus-group-select
278 :type '(choice (const :tag "none" nil)
280 (sexp :menu-tag "first" t)
281 (function-item gnus-summary-first-unread-subject)
282 (function-item gnus-summary-first-unread-article)
283 (function-item gnus-summary-best-unread-article)))
285 (defcustom gnus-auto-select-next t
286 "*If non-nil, offer to go to the next group from the end of the previous.
287 If the value is t and the next newsgroup is empty, Gnus will exit
288 summary mode and go back to group mode. If the value is neither nil
289 nor t, Gnus will select the following unread newsgroup. In
290 particular, if the value is the symbol `quietly', the next unread
291 newsgroup will be selected without any confirmation, and if it is
292 `almost-quietly', the next group will be selected without any
293 confirmation if you are located on the last article in the group.
294 Finally, if this variable is `slightly-quietly', the `Z n' command
295 will go to the next group without confirmation."
296 :group 'gnus-summary-maneuvering
297 :type '(choice (const :tag "off" nil)
299 (const almost-quietly)
300 (const slightly-quietly)
301 (sexp :menu-tag "on" t)))
303 (defcustom gnus-auto-select-same nil
304 "*If non-nil, select the next article with the same subject.
305 If there are no more articles with the same subject, go to
306 the first unread article."
307 :group 'gnus-summary-maneuvering
310 (defcustom gnus-summary-check-current nil
311 "*If non-nil, consider the current article when moving.
312 The \"unread\" movement commands will stay on the same line if the
313 current article is unread."
314 :group 'gnus-summary-maneuvering
317 (defcustom gnus-auto-center-summary t
318 "*If non-nil, always center the current summary buffer.
319 In particular, if `vertical' do only vertical recentering. If non-nil
320 and non-`vertical', do both horizontal and vertical recentering."
321 :group 'gnus-summary-maneuvering
322 :type '(choice (const :tag "none" nil)
324 (integer :tag "height")
325 (sexp :menu-tag "both" t)))
327 (defcustom gnus-show-all-headers nil
328 "*If non-nil, don't hide any headers."
329 :group 'gnus-article-hiding
330 :group 'gnus-article-headers
333 (defcustom gnus-summary-ignore-duplicates nil
334 "*If non-nil, ignore articles with identical Message-ID headers."
338 (defcustom gnus-single-article-buffer t
339 "*If non-nil, display all articles in the same buffer.
340 If nil, each group will get its own article buffer."
341 :group 'gnus-article-various
344 (defcustom gnus-break-pages t
345 "*If non-nil, do page breaking on articles.
346 The page delimiter is specified by the `gnus-page-delimiter'
348 :group 'gnus-article-various
351 (defcustom gnus-show-mime t
352 "*If non-nil, do mime processing of articles.
353 The articles will simply be fed to the function given by
354 `gnus-article-display-method-for-mime'."
355 :group 'gnus-article-mime
358 (defcustom gnus-move-split-methods nil
359 "*Variable used to suggest where articles are to be moved to.
360 It uses the same syntax as the `gnus-split-methods' variable."
361 :group 'gnus-summary-mail
362 :type '(repeat (choice (list :value (fun) function)
363 (cons :value ("" "") regexp (repeat string))
366 (defcustom gnus-unread-mark ? ;Whitespace
367 "*Mark used for unread articles."
368 :group 'gnus-summary-marks
371 (defcustom gnus-ticked-mark ?!
372 "*Mark used for ticked articles."
373 :group 'gnus-summary-marks
376 (defcustom gnus-dormant-mark ??
377 "*Mark used for dormant articles."
378 :group 'gnus-summary-marks
381 (defcustom gnus-del-mark ?r
382 "*Mark used for del'd articles."
383 :group 'gnus-summary-marks
386 (defcustom gnus-read-mark ?R
387 "*Mark used for read articles."
388 :group 'gnus-summary-marks
391 (defcustom gnus-expirable-mark ?E
392 "*Mark used for expirable articles."
393 :group 'gnus-summary-marks
396 (defcustom gnus-killed-mark ?K
397 "*Mark used for killed articles."
398 :group 'gnus-summary-marks
401 (defcustom gnus-souped-mark ?F
402 "*Mark used for killed articles."
403 :group 'gnus-summary-marks
406 (defcustom gnus-kill-file-mark ?X
407 "*Mark used for articles killed by kill files."
408 :group 'gnus-summary-marks
411 (defcustom gnus-low-score-mark ?Y
412 "*Mark used for articles with a low score."
413 :group 'gnus-summary-marks
416 (defcustom gnus-catchup-mark ?C
417 "*Mark used for articles that are caught up."
418 :group 'gnus-summary-marks
421 (defcustom gnus-replied-mark ?A
422 "*Mark used for articles that have been replied to."
423 :group 'gnus-summary-marks
426 (defcustom gnus-cached-mark ?*
427 "*Mark used for articles that are in the cache."
428 :group 'gnus-summary-marks
431 (defcustom gnus-saved-mark ?S
432 "*Mark used for articles that have been saved to."
433 :group 'gnus-summary-marks
436 (defcustom gnus-ancient-mark ?O
437 "*Mark used for ancient articles."
438 :group 'gnus-summary-marks
441 (defcustom gnus-sparse-mark ?Q
442 "*Mark used for sparsely reffed articles."
443 :group 'gnus-summary-marks
446 (defcustom gnus-canceled-mark ?G
447 "*Mark used for canceled articles."
448 :group 'gnus-summary-marks
451 (defcustom gnus-duplicate-mark ?M
452 "*Mark used for duplicate articles."
453 :group 'gnus-summary-marks
456 (defcustom gnus-undownloaded-mark ?@
457 "*Mark used for articles that weren't downloaded."
458 :group 'gnus-summary-marks
461 (defcustom gnus-downloadable-mark ?%
462 "*Mark used for articles that are to be downloaded."
463 :group 'gnus-summary-marks
466 (defcustom gnus-unsendable-mark ?=
467 "*Mark used for articles that won't be sent."
468 :group 'gnus-summary-marks
471 (defcustom gnus-score-over-mark ?+
472 "*Score mark used for articles with high scores."
473 :group 'gnus-summary-marks
476 (defcustom gnus-score-below-mark ?-
477 "*Score mark used for articles with low scores."
478 :group 'gnus-summary-marks
481 (defcustom gnus-empty-thread-mark ? ;Whitespace
482 "*There is no thread under the article."
483 :group 'gnus-summary-marks
486 (defcustom gnus-not-empty-thread-mark ?=
487 "*There is a thread under the article."
488 :group 'gnus-summary-marks
491 (defcustom gnus-view-pseudo-asynchronously nil
492 "*If non-nil, Gnus will view pseudo-articles asynchronously."
493 :group 'gnus-extract-view
496 (defcustom gnus-auto-expirable-marks
497 (list gnus-killed-mark gnus-del-mark gnus-catchup-mark
498 gnus-low-score-mark gnus-ancient-mark gnus-read-mark
499 gnus-souped-mark gnus-duplicate-mark)
500 "*The list of marks converted into expiration if a group is auto-expirable."
502 :type '(repeat character))
504 (defcustom gnus-inhibit-user-auto-expire t
505 "*If non-nil, user marking commands will not mark an article as expirable, even if the group has auto-expire turned on."
509 (defcustom gnus-view-pseudos nil
510 "*If `automatic', pseudo-articles will be viewed automatically.
511 If `not-confirm', pseudos will be viewed automatically, and the user
512 will not be asked to confirm the command."
513 :group 'gnus-extract-view
514 :type '(choice (const :tag "off" nil)
516 (const not-confirm)))
518 (defcustom gnus-view-pseudos-separately t
519 "*If non-nil, one pseudo-article will be created for each file to be viewed.
520 If nil, all files that use the same viewing command will be given as a
521 list of parameters to that command."
522 :group 'gnus-extract-view
525 (defcustom gnus-insert-pseudo-articles t
526 "*If non-nil, insert pseudo-articles when decoding articles."
527 :group 'gnus-extract-view
530 (defcustom gnus-summary-dummy-line-format
532 "*The format specification for the dummy roots in the summary buffer.
533 It works along the same lines as a normal formatting string,
534 with some simple extensions.
537 :group 'gnus-threading
540 (defcustom gnus-summary-mode-line-format "Gnus: %g [%A] %Z"
541 "*The format specification for the summary mode line.
542 It works along the same lines as a normal formatting string,
543 with some simple extensions:
546 %p Unprefixed group name
547 %A Current article number
548 %z Current article score
550 %U Number of unread articles in the group
551 %e Number of unselected articles in the group
552 %Z A string with unread/unselected article counts
553 %g Shortish group name
554 %S Subject of the current article
556 %s Current score file name
557 %d Number of dormant articles
558 %r Number of articles that have been marked as read in this session
559 %E Number of articles expunged by the score files"
560 :group 'gnus-summary-format
563 (defcustom gnus-summary-mark-below 0
564 "*Mark all articles with a score below this variable as read.
565 This variable is local to each summary buffer and usually set by the
567 :group 'gnus-score-default
570 (defcustom gnus-article-sort-functions '(gnus-article-sort-by-number)
571 "*List of functions used for sorting articles in the summary buffer.
572 This variable is only used when not using a threaded display."
573 :group 'gnus-summary-sort
574 :type '(repeat (choice (function-item gnus-article-sort-by-number)
575 (function-item gnus-article-sort-by-author)
576 (function-item gnus-article-sort-by-subject)
577 (function-item gnus-article-sort-by-date)
578 (function-item gnus-article-sort-by-score)
579 (function :tag "other"))))
581 (defcustom gnus-thread-sort-functions '(gnus-thread-sort-by-number)
582 "*List of functions used for sorting threads in the summary buffer.
583 By default, threads are sorted by article number.
585 Each function takes two threads and return non-nil if the first thread
586 should be sorted before the other. If you use more than one function,
587 the primary sort function should be the last. You should probably
588 always include `gnus-thread-sort-by-number' in the list of sorting
589 functions -- preferably first.
591 Ready-made functions include `gnus-thread-sort-by-number',
592 `gnus-thread-sort-by-author', `gnus-thread-sort-by-subject',
593 `gnus-thread-sort-by-date', `gnus-thread-sort-by-score' and
594 `gnus-thread-sort-by-total-score' (see `gnus-thread-score-function')."
595 :group 'gnus-summary-sort
596 :type '(repeat (choice (function-item gnus-thread-sort-by-number)
597 (function-item gnus-thread-sort-by-author)
598 (function-item gnus-thread-sort-by-subject)
599 (function-item gnus-thread-sort-by-date)
600 (function-item gnus-thread-sort-by-score)
601 (function-item gnus-thread-sort-by-total-score)
602 (function :tag "other"))))
604 (defcustom gnus-thread-score-function '+
605 "*Function used for calculating the total score of a thread.
607 The function is called with the scores of the article and each
608 subthread and should then return the score of the thread.
610 Some functions you can use are `+', `max', or `min'."
611 :group 'gnus-summary-sort
614 (defcustom gnus-summary-expunge-below nil
615 "All articles that have a score less than this variable will be expunged.
616 This variable is local to the summary buffers."
617 :group 'gnus-score-default
618 :type '(choice (const :tag "off" nil)
621 (defcustom gnus-thread-expunge-below nil
622 "All threads that have a total score less than this variable will be expunged.
623 See `gnus-thread-score-function' for en explanation of what a
626 This variable is local to the summary buffers."
627 :group 'gnus-threading
628 :group 'gnus-score-default
629 :type '(choice (const :tag "off" nil)
632 (defcustom gnus-summary-mode-hook nil
633 "*A hook for Gnus summary mode.
634 This hook is run before any variables are set in the summary buffer."
635 :group 'gnus-summary-various
638 (defcustom gnus-summary-menu-hook nil
639 "*Hook run after the creation of the summary mode menu."
640 :group 'gnus-summary-visual
643 (defcustom gnus-summary-exit-hook nil
644 "*A hook called on exit from the summary buffer.
645 It will be called with point in the group buffer."
646 :group 'gnus-summary-exit
649 (defcustom gnus-summary-prepare-hook nil
650 "*A hook called after the summary buffer has been generated.
651 If you want to modify the summary buffer, you can use this hook."
652 :group 'gnus-summary-various
655 (defcustom gnus-summary-prepared-hook nil
656 "*A hook called as the last thing after the summary buffer has been generated."
657 :group 'gnus-summary-various
660 (defcustom gnus-summary-generate-hook nil
661 "*A hook run just before generating the summary buffer.
662 This hook is commonly used to customize threading variables and the
664 :group 'gnus-summary-various
667 (defcustom gnus-select-group-hook nil
668 "*A hook called when a newsgroup is selected.
670 If you'd like to simplify subjects like the
671 `gnus-summary-next-same-subject' command does, you can use the
674 (setq gnus-select-group-hook
677 (mapcar (lambda (header)
678 (mail-header-set-subject
680 (gnus-simplify-subject
681 (mail-header-subject header) 're-only)))
682 gnus-newsgroup-headers))))"
683 :group 'gnus-group-select
686 (defcustom gnus-select-article-hook nil
687 "*A hook called when an article is selected."
688 :group 'gnus-summary-choose
691 (defcustom gnus-visual-mark-article-hook
692 (list 'gnus-highlight-selected-summary)
693 "*Hook run after selecting an article in the summary buffer.
694 It is meant to be used for highlighting the article in some way. It
695 is not run if `gnus-visual' is nil."
696 :group 'gnus-summary-visual
699 (defcustom gnus-parse-headers-hook '(gnus-set-summary-default-charset)
700 "*A hook called before parsing the headers."
704 (defcustom gnus-exit-group-hook nil
705 "*A hook called when exiting (not quitting) summary mode."
709 (defcustom gnus-summary-update-hook
710 (list 'gnus-summary-highlight-line)
711 "*A hook called when a summary line is changed.
712 The hook will not be called if `gnus-visual' is nil.
714 The default function `gnus-summary-highlight-line' will
715 highlight the line according to the `gnus-summary-highlight'
717 :group 'gnus-summary-visual
720 (defcustom gnus-mark-article-hook '(gnus-summary-mark-read-and-unread-as-read)
721 "*A hook called when an article is selected for the first time.
722 The hook is intended to mark an article as read (or unread)
723 automatically when it is selected."
724 :group 'gnus-summary-choose
727 (defcustom gnus-group-no-more-groups-hook nil
728 "*A hook run when returning to group mode having no more (unread) groups."
729 :group 'gnus-group-select
732 (defcustom gnus-ps-print-hook nil
733 "*A hook run before ps-printing something from Gnus."
737 (defcustom gnus-summary-selected-face 'gnus-summary-selected-face
738 "Face used for highlighting the current article in the summary buffer."
739 :group 'gnus-summary-visual
742 (defcustom gnus-summary-highlight
743 '(((= mark gnus-canceled-mark)
744 . gnus-summary-cancelled-face)
745 ((and (> score default)
746 (or (= mark gnus-dormant-mark)
747 (= mark gnus-ticked-mark)))
748 . gnus-summary-high-ticked-face)
749 ((and (< score default)
750 (or (= mark gnus-dormant-mark)
751 (= mark gnus-ticked-mark)))
752 . gnus-summary-low-ticked-face)
753 ((or (= mark gnus-dormant-mark)
754 (= mark gnus-ticked-mark))
755 . gnus-summary-normal-ticked-face)
756 ((and (> score default) (= mark gnus-ancient-mark))
757 . gnus-summary-high-ancient-face)
758 ((and (< score default) (= mark gnus-ancient-mark))
759 . gnus-summary-low-ancient-face)
760 ((= mark gnus-ancient-mark)
761 . gnus-summary-normal-ancient-face)
762 ((and (> score default) (= mark gnus-unread-mark))
763 . gnus-summary-high-unread-face)
764 ((and (< score default) (= mark gnus-unread-mark))
765 . gnus-summary-low-unread-face)
766 ((= mark gnus-unread-mark)
767 . gnus-summary-normal-unread-face)
768 ((and (> score default) (memq mark (list gnus-downloadable-mark
769 gnus-undownloaded-mark)))
770 . gnus-summary-high-unread-face)
771 ((and (< score default) (memq mark (list gnus-downloadable-mark
772 gnus-undownloaded-mark)))
773 . gnus-summary-low-unread-face)
774 ((memq mark (list gnus-downloadable-mark gnus-undownloaded-mark))
775 . gnus-summary-normal-unread-face)
777 . gnus-summary-high-read-face)
779 . gnus-summary-low-read-face)
781 . gnus-summary-normal-read-face))
782 "*Controls the highlighting of summary buffer lines.
784 A list of (FORM . FACE) pairs. When deciding how a a particular
785 summary line should be displayed, each form is evaluated. The content
786 of the face field after the first true form is used. You can change
787 how those summary lines are displayed, by editing the face field.
789 You can use the following variables in the FORM field.
791 score: The articles score
792 default: The default article score.
793 below: The score below which articles are automatically marked as read.
794 mark: The articles mark."
795 :group 'gnus-summary-visual
796 :type '(repeat (cons (sexp :tag "Form" nil)
799 (defcustom gnus-alter-header-function nil
800 "Function called to allow alteration of article header structures.
801 The function is called with one parameter, the article header vector,
802 which it may alter in any way.")
804 (defcustom gnus-extra-headers nil
805 "*Extra headers to parse."
807 :type '(repeat symbol))
809 (defcustom gnus-ignored-from-addresses
810 (and user-mail-address (regexp-quote user-mail-address))
811 "*Regexp of From headers that may be suppressed in favor of To headers."
815 (defcustom gnus-group-charset-alist
816 '(("^hk\\>\\|^tw\\>\\|\\<big5\\>" cn-big5)
817 ("^cn\\>\\|\\<chinese\\>" cn-gb-2312)
818 ("^fj\\>\\|^japan\\>" iso-2022-jp-2)
819 ("^relcom\\>" koi8-r)
820 ("^\\(cz\\|hun\\|pl\\|sk\\)\\>" iso-8859-2)
821 ("^israel\\>" iso-8859-1)
822 ("^\\(comp\\|rec\\|alt\\|sci\\|soc\\|news\\|gnu\\|bofh\\)\\>" iso-8859-1)
824 "Alist of regexps (to match group names) and default charsets to be used when reading."
825 :type '(repeat (list (regexp :tag "Group")
826 (symbol :tag "Charset")))
827 :group 'gnus-charset)
829 (defcustom gnus-newsgroup-ignored-charsets '(unknown-8bit)
830 "List of charsets that should be ignored.
831 When these charsets are used in the \"charset\" parameter, the
832 default charset will be used instead."
833 :type '(repeat symbol)
834 :group 'gnus-charset)
836 ;;; Internal variables
838 (defvar gnus-scores-exclude-files nil)
839 (defvar gnus-page-broken nil)
840 (defvar gnus-inhibit-mime-unbuttonizing nil)
842 (defvar gnus-original-article nil)
843 (defvar gnus-article-internal-prepare-hook nil)
844 (defvar gnus-newsgroup-process-stack nil)
846 (defvar gnus-thread-indent-array nil)
847 (defvar gnus-thread-indent-array-level gnus-thread-indent-level)
849 ;; Avoid highlighting in kill files.
850 (defvar gnus-summary-inhibit-highlight nil)
851 (defvar gnus-newsgroup-selected-overlay nil)
852 (defvar gnus-inhibit-limiting nil)
853 (defvar gnus-newsgroup-adaptive-score-file nil)
854 (defvar gnus-current-score-file nil)
855 (defvar gnus-current-move-group nil)
856 (defvar gnus-current-copy-group nil)
857 (defvar gnus-current-crosspost-group nil)
859 (defvar gnus-newsgroup-dependencies nil)
860 (defvar gnus-newsgroup-adaptive nil)
861 (defvar gnus-summary-display-article-function nil)
862 (defvar gnus-summary-highlight-line-function nil
863 "Function called after highlighting a summary line.")
865 (defvar gnus-summary-line-format-alist
866 `((?N ,(macroexpand '(mail-header-number gnus-tmp-header)) ?d)
867 (?S ,(macroexpand '(mail-header-subject gnus-tmp-header)) ?s)
868 (?s gnus-tmp-subject-or-nil ?s)
869 (?n gnus-tmp-name ?s)
870 (?A (std11-address-string
871 (car (mime-read-field 'From gnus-tmp-header))) ?s)
872 (?a (or (std11-full-name-string
873 (car (mime-read-field 'From gnus-tmp-header)))
875 (?F gnus-tmp-from ?s)
876 (?x ,(macroexpand '(mail-header-xref gnus-tmp-header)) ?s)
877 (?D ,(macroexpand '(mail-header-date gnus-tmp-header)) ?s)
878 (?d (gnus-dd-mmm (mail-header-date gnus-tmp-header)) ?s)
879 (?o (gnus-date-iso8601 (mail-header-date gnus-tmp-header)) ?s)
880 (?M ,(macroexpand '(mail-header-id gnus-tmp-header)) ?s)
881 (?r ,(macroexpand '(mail-header-references gnus-tmp-header)) ?s)
882 (?c (or (mail-header-chars gnus-tmp-header) 0) ?d)
883 (?L gnus-tmp-lines ?d)
884 (?I gnus-tmp-indentation ?s)
885 (?T (if (= gnus-tmp-level 0) "" (make-string (frame-width) ? )) ?s)
886 (?R gnus-tmp-replied ?c)
887 (?\[ gnus-tmp-opening-bracket ?c)
888 (?\] gnus-tmp-closing-bracket ?c)
889 (?\> (make-string gnus-tmp-level ? ) ?s)
890 (?\< (make-string (max 0 (- 20 gnus-tmp-level)) ? ) ?s)
891 (?i gnus-tmp-score ?d)
892 (?z gnus-tmp-score-char ?c)
893 (?l (bbb-grouplens-score gnus-tmp-header) ?s)
894 (?V (gnus-thread-total-score (and (boundp 'thread) (car thread))) ?d)
895 (?U gnus-tmp-unread ?c)
896 (?f (gnus-summary-from-or-to-or-newsgroups gnus-tmp-header) ?s)
897 (?t (gnus-summary-number-of-articles-in-thread
898 (and (boundp 'thread) (car thread)) gnus-tmp-level)
900 (?e (gnus-summary-number-of-articles-in-thread
901 (and (boundp 'thread) (car thread)) gnus-tmp-level t)
903 (?u gnus-tmp-user-defined ?s)
904 (?P (gnus-pick-line-number) ?d))
905 "An alist of format specifications that can appear in summary lines,
906 and what variables they correspond with, along with the type of the
907 variable (string, integer, character, etc).")
909 (defvar gnus-summary-dummy-line-format-alist
910 `((?S gnus-tmp-subject ?s)
911 (?N gnus-tmp-number ?d)
912 (?u gnus-tmp-user-defined ?s)))
914 (defvar gnus-summary-mode-line-format-alist
915 `((?G gnus-tmp-group-name ?s)
916 (?g (gnus-short-group-name gnus-tmp-group-name) ?s)
917 (?p (gnus-group-real-name gnus-tmp-group-name) ?s)
918 (?A gnus-tmp-article-number ?d)
919 (?Z gnus-tmp-unread-and-unselected ?s)
921 (?U gnus-tmp-unread-and-unticked ?d)
922 (?S gnus-tmp-subject ?s)
923 (?e gnus-tmp-unselected ?d)
924 (?u gnus-tmp-user-defined ?s)
925 (?d (length gnus-newsgroup-dormant) ?d)
926 (?t (length gnus-newsgroup-marked) ?d)
927 (?r (length gnus-newsgroup-reads) ?d)
928 (?z (gnus-summary-article-score gnus-tmp-article-number) ?d)
929 (?E gnus-newsgroup-expunged-tally ?d)
930 (?s (gnus-current-score-file-nondirectory) ?s)))
932 (defvar gnus-last-search-regexp nil
933 "Default regexp for article search command.")
935 (defvar gnus-last-shell-command nil
936 "Default shell command on article.")
938 (defvar gnus-newsgroup-begin nil)
939 (defvar gnus-newsgroup-end nil)
940 (defvar gnus-newsgroup-last-rmail nil)
941 (defvar gnus-newsgroup-last-mail nil)
942 (defvar gnus-newsgroup-last-folder nil)
943 (defvar gnus-newsgroup-last-file nil)
944 (defvar gnus-newsgroup-auto-expire nil)
945 (defvar gnus-newsgroup-active nil)
947 (defvar gnus-newsgroup-data nil)
948 (defvar gnus-newsgroup-data-reverse nil)
949 (defvar gnus-newsgroup-limit nil)
950 (defvar gnus-newsgroup-limits nil)
952 (defvar gnus-newsgroup-unreads nil
953 "List of unread articles in the current newsgroup.")
955 (defvar gnus-newsgroup-unselected nil
956 "List of unselected unread articles in the current newsgroup.")
958 (defvar gnus-newsgroup-reads nil
959 "Alist of read articles and article marks in the current newsgroup.")
961 (defvar gnus-newsgroup-expunged-tally nil)
963 (defvar gnus-newsgroup-marked nil
964 "List of ticked articles in the current newsgroup (a subset of unread art).")
966 (defvar gnus-newsgroup-killed nil
967 "List of ranges of articles that have been through the scoring process.")
969 (defvar gnus-newsgroup-cached nil
970 "List of articles that come from the article cache.")
972 (defvar gnus-newsgroup-saved nil
973 "List of articles that have been saved.")
975 (defvar gnus-newsgroup-kill-headers nil)
977 (defvar gnus-newsgroup-replied nil
978 "List of articles that have been replied to in the current newsgroup.")
980 (defvar gnus-newsgroup-expirable nil
981 "List of articles in the current newsgroup that can be expired.")
983 (defvar gnus-newsgroup-processable nil
984 "List of articles in the current newsgroup that can be processed.")
986 (defvar gnus-newsgroup-downloadable nil
987 "List of articles in the current newsgroup that can be processed.")
989 (defvar gnus-newsgroup-undownloaded nil
990 "List of articles in the current newsgroup that haven't been downloaded..")
992 (defvar gnus-newsgroup-unsendable nil
993 "List of articles in the current newsgroup that won't be sent.")
995 (defvar gnus-newsgroup-bookmarks nil
996 "List of articles in the current newsgroup that have bookmarks.")
998 (defvar gnus-newsgroup-dormant nil
999 "List of dormant articles in the current newsgroup.")
1001 (defvar gnus-newsgroup-scored nil
1002 "List of scored articles in the current newsgroup.")
1004 (defvar gnus-newsgroup-headers nil
1005 "List of article headers in the current newsgroup.")
1007 (defvar gnus-newsgroup-threads nil)
1009 (defvar gnus-newsgroup-prepared nil
1010 "Whether the current group has been prepared properly.")
1012 (defvar gnus-newsgroup-ancient nil
1013 "List of `gnus-fetch-old-headers' articles in the current newsgroup.")
1015 (defvar gnus-newsgroup-sparse nil)
1017 (defvar gnus-current-article nil)
1018 (defvar gnus-article-current nil)
1019 (defvar gnus-current-headers nil)
1020 (defvar gnus-have-all-headers nil)
1021 (defvar gnus-last-article nil)
1022 (defvar gnus-newsgroup-history nil)
1023 (defvar gnus-newsgroup-charset nil)
1025 (defconst gnus-summary-local-variables
1026 '(gnus-newsgroup-name
1027 gnus-newsgroup-begin gnus-newsgroup-end
1028 gnus-newsgroup-last-rmail gnus-newsgroup-last-mail
1029 gnus-newsgroup-last-folder gnus-newsgroup-last-file
1030 gnus-newsgroup-auto-expire gnus-newsgroup-unreads
1031 gnus-newsgroup-unselected gnus-newsgroup-marked
1032 gnus-newsgroup-reads gnus-newsgroup-saved
1033 gnus-newsgroup-replied gnus-newsgroup-expirable
1034 gnus-newsgroup-processable gnus-newsgroup-killed
1035 gnus-newsgroup-downloadable gnus-newsgroup-undownloaded
1036 gnus-newsgroup-unsendable
1037 gnus-newsgroup-bookmarks gnus-newsgroup-dormant
1038 gnus-newsgroup-headers gnus-newsgroup-threads
1039 gnus-newsgroup-prepared gnus-summary-highlight-line-function
1040 gnus-current-article gnus-current-headers gnus-have-all-headers
1041 gnus-last-article gnus-article-internal-prepare-hook
1042 gnus-newsgroup-dependencies gnus-newsgroup-selected-overlay
1043 gnus-newsgroup-scored gnus-newsgroup-kill-headers
1044 gnus-thread-expunge-below
1045 gnus-score-alist gnus-current-score-file gnus-summary-expunge-below
1046 (gnus-summary-mark-below . global)
1047 gnus-newsgroup-active gnus-scores-exclude-files
1048 gnus-newsgroup-history gnus-newsgroup-ancient
1049 gnus-newsgroup-sparse gnus-newsgroup-process-stack
1050 (gnus-newsgroup-adaptive . gnus-use-adaptive-scoring)
1051 gnus-newsgroup-adaptive-score-file (gnus-reffed-article-number . -1)
1052 (gnus-newsgroup-expunged-tally . 0)
1053 gnus-cache-removable-articles gnus-newsgroup-cached
1054 gnus-newsgroup-data gnus-newsgroup-data-reverse
1055 gnus-newsgroup-limit gnus-newsgroup-limits
1056 gnus-newsgroup-charset)
1057 "Variables that are buffer-local to the summary buffers.")
1059 ;; Byte-compiler warning.
1060 (defvar gnus-article-mode-map)
1062 ;; Subject simplification.
1064 (defun gnus-simplify-whitespace (str)
1065 "Remove excessive whitespace."
1068 (while (string-match "[ \t][ \t]+" mystr)
1069 (setq mystr (concat (substring mystr 0 (match-beginning 0))
1071 (substring mystr (match-end 0)))))
1073 (when (string-match "^[ \t]+" mystr)
1074 (setq mystr (substring mystr (match-end 0))))
1076 (when (string-match "[ \t]+$" mystr)
1077 (setq mystr (substring mystr 0 (match-beginning 0))))
1080 (defsubst gnus-simplify-subject-re (subject)
1081 "Remove \"Re:\" from subject lines."
1082 (if (string-match "^[Rr][Ee]: *" subject)
1083 (substring subject (match-end 0))
1086 (defun gnus-simplify-subject (subject &optional re-only)
1087 "Remove `Re:' and words in parentheses.
1088 If RE-ONLY is non-nil, strip leading `Re:'s only."
1089 (let ((case-fold-search t)) ;Ignore case.
1090 ;; Remove `Re:', `Re^N:', `Re(n)', and `Re[n]:'.
1091 (when (string-match "\\`\\(re\\([[(^][0-9]+[])]?\\)?:[ \t]*\\)+" subject)
1092 (setq subject (substring subject (match-end 0))))
1093 ;; Remove uninteresting prefixes.
1094 (when (and (not re-only)
1095 gnus-simplify-ignored-prefixes
1096 (string-match gnus-simplify-ignored-prefixes subject))
1097 (setq subject (substring subject (match-end 0))))
1098 ;; Remove words in parentheses from end.
1100 (while (string-match "[ \t\n]*([^()]*)[ \t\n]*\\'" subject)
1101 (setq subject (substring subject 0 (match-beginning 0)))))
1102 ;; Return subject string.
1105 ;; Remove any leading "re:"s, any trailing paren phrases, and simplify
1107 (defsubst gnus-simplify-buffer-fuzzy-step (regexp &optional newtext)
1108 (goto-char (point-min))
1109 (while (re-search-forward regexp nil t)
1110 (replace-match (or newtext ""))))
1112 (defun gnus-simplify-buffer-fuzzy ()
1113 "Simplify string in the buffer fuzzily.
1114 The string in the accessible portion of the current buffer is simplified.
1115 It is assumed to be a single-line subject.
1116 Whitespace is generally cleaned up, and miscellaneous leading/trailing
1117 matter is removed. Additional things can be deleted by setting
1118 gnus-simplify-subject-fuzzy-regexp."
1119 (let ((case-fold-search t)
1121 (gnus-simplify-buffer-fuzzy-step "\t" " ")
1123 (while (not (eq modified-tick (buffer-modified-tick)))
1124 (setq modified-tick (buffer-modified-tick))
1126 ((listp gnus-simplify-subject-fuzzy-regexp)
1127 (mapcar 'gnus-simplify-buffer-fuzzy-step
1128 gnus-simplify-subject-fuzzy-regexp))
1129 (gnus-simplify-subject-fuzzy-regexp
1130 (gnus-simplify-buffer-fuzzy-step gnus-simplify-subject-fuzzy-regexp)))
1131 (gnus-simplify-buffer-fuzzy-step "^ *\\[[-+?*!][-+?*!]\\] *")
1132 (gnus-simplify-buffer-fuzzy-step
1133 "^ *\\(re\\|fw\\|fwd\\)[[{(^0-9]*[])}]?[:;] *")
1134 (gnus-simplify-buffer-fuzzy-step "^[[].*:\\( .*\\)[]]$" "\\1"))
1136 (gnus-simplify-buffer-fuzzy-step " *[[{(][^()\n]*[]})] *$")
1137 (gnus-simplify-buffer-fuzzy-step " +" " ")
1138 (gnus-simplify-buffer-fuzzy-step " $")
1139 (gnus-simplify-buffer-fuzzy-step "^ +")))
1141 (defun gnus-simplify-subject-fuzzy (subject)
1142 "Simplify a subject string fuzzily.
1143 See `gnus-simplify-buffer-fuzzy' for details."
1145 (gnus-set-work-buffer)
1146 (let ((case-fold-search t))
1147 ;; Remove uninteresting prefixes.
1148 (when (and gnus-simplify-ignored-prefixes
1149 (string-match gnus-simplify-ignored-prefixes subject))
1150 (setq subject (substring subject (match-end 0))))
1152 (inline (gnus-simplify-buffer-fuzzy))
1155 (defsubst gnus-simplify-subject-fully (subject)
1156 "Simplify a subject string according to gnus-summary-gather-subject-limit."
1158 (gnus-simplify-subject-functions
1159 (gnus-map-function gnus-simplify-subject-functions subject))
1160 ((null gnus-summary-gather-subject-limit)
1161 (gnus-simplify-subject-re subject))
1162 ((eq gnus-summary-gather-subject-limit 'fuzzy)
1163 (gnus-simplify-subject-fuzzy subject))
1164 ((numberp gnus-summary-gather-subject-limit)
1165 (gnus-limit-string (gnus-simplify-subject-re subject)
1166 gnus-summary-gather-subject-limit))
1170 (defsubst gnus-subject-equal (s1 s2 &optional simple-first)
1171 "Check whether two subjects are equal.
1172 If optional argument simple-first is t, first argument is already
1175 ((null simple-first)
1176 (equal (gnus-simplify-subject-fully s1)
1177 (gnus-simplify-subject-fully s2)))
1180 (gnus-simplify-subject-fully s2)))))
1182 (defun gnus-summary-bubble-group ()
1183 "Increase the score of the current group.
1184 This is a handy function to add to `gnus-summary-exit-hook' to
1185 increase the score of each group you read."
1186 (gnus-group-add-score gnus-newsgroup-name))
1190 ;;; Gnus summary mode
1193 (put 'gnus-summary-mode 'mode-class 'special)
1196 ;; Non-orthogonal keys
1198 (gnus-define-keys gnus-summary-mode-map
1199 " " gnus-summary-next-page
1200 "\177" gnus-summary-prev-page
1201 [delete] gnus-summary-prev-page
1202 [backspace] gnus-summary-prev-page
1203 "\r" gnus-summary-scroll-up
1204 "\M-\r" gnus-summary-scroll-down
1205 "n" gnus-summary-next-unread-article
1206 "p" gnus-summary-prev-unread-article
1207 "N" gnus-summary-next-article
1208 "P" gnus-summary-prev-article
1209 "\M-\C-n" gnus-summary-next-same-subject
1210 "\M-\C-p" gnus-summary-prev-same-subject
1211 "\M-n" gnus-summary-next-unread-subject
1212 "\M-p" gnus-summary-prev-unread-subject
1213 "." gnus-summary-first-unread-article
1214 "," gnus-summary-best-unread-article
1215 "\M-s" gnus-summary-search-article-forward
1216 "\M-r" gnus-summary-search-article-backward
1217 "<" gnus-summary-beginning-of-article
1218 ">" gnus-summary-end-of-article
1219 "j" gnus-summary-goto-article
1220 "^" gnus-summary-refer-parent-article
1221 "\M-^" gnus-summary-refer-article
1222 "u" gnus-summary-tick-article-forward
1223 "!" gnus-summary-tick-article-forward
1224 "U" gnus-summary-tick-article-backward
1225 "d" gnus-summary-mark-as-read-forward
1226 "D" gnus-summary-mark-as-read-backward
1227 "E" gnus-summary-mark-as-expirable
1228 "\M-u" gnus-summary-clear-mark-forward
1229 "\M-U" gnus-summary-clear-mark-backward
1230 "k" gnus-summary-kill-same-subject-and-select
1231 "\C-k" gnus-summary-kill-same-subject
1232 "\M-\C-k" gnus-summary-kill-thread
1233 "\M-\C-l" gnus-summary-lower-thread
1234 "e" gnus-summary-edit-article
1235 "#" gnus-summary-mark-as-processable
1236 "\M-#" gnus-summary-unmark-as-processable
1237 "\M-\C-t" gnus-summary-toggle-threads
1238 "\M-\C-s" gnus-summary-show-thread
1239 "\M-\C-h" gnus-summary-hide-thread
1240 "\M-\C-f" gnus-summary-next-thread
1241 "\M-\C-b" gnus-summary-prev-thread
1242 "\M-\C-u" gnus-summary-up-thread
1243 "\M-\C-d" gnus-summary-down-thread
1244 "&" gnus-summary-execute-command
1245 "c" gnus-summary-catchup-and-exit
1246 "\C-w" gnus-summary-mark-region-as-read
1247 "\C-t" gnus-summary-toggle-truncation
1248 "?" gnus-summary-mark-as-dormant
1249 "\C-c\M-\C-s" gnus-summary-limit-include-expunged
1250 "\C-c\C-s\C-n" gnus-summary-sort-by-number
1251 "\C-c\C-s\C-l" gnus-summary-sort-by-lines
1252 "\C-c\C-s\C-a" gnus-summary-sort-by-author
1253 "\C-c\C-s\C-s" gnus-summary-sort-by-subject
1254 "\C-c\C-s\C-d" gnus-summary-sort-by-date
1255 "\C-c\C-s\C-i" gnus-summary-sort-by-score
1256 "=" gnus-summary-expand-window
1257 "\C-x\C-s" gnus-summary-reselect-current-group
1258 "\M-g" gnus-summary-rescan-group
1259 "w" gnus-summary-stop-page-breaking
1260 "\C-c\C-r" gnus-summary-caesar-message
1261 "\M-t" gnus-summary-toggle-mime
1262 "f" gnus-summary-followup
1263 "F" gnus-summary-followup-with-original
1264 "C" gnus-summary-cancel-article
1265 "r" gnus-summary-reply
1266 "R" gnus-summary-reply-with-original
1267 "\C-c\C-f" gnus-summary-mail-forward
1268 "o" gnus-summary-save-article
1269 "\C-o" gnus-summary-save-article-mail
1270 "|" gnus-summary-pipe-output
1271 "\M-k" gnus-summary-edit-local-kill
1272 "\M-K" gnus-summary-edit-global-kill
1274 "\C-c\C-d" gnus-summary-describe-group
1275 "q" gnus-summary-exit
1276 "Q" gnus-summary-exit-no-update
1277 "\C-c\C-i" gnus-info-find-node
1278 gnus-mouse-2 gnus-mouse-pick-article
1279 "m" gnus-summary-mail-other-window
1280 "a" gnus-summary-post-news
1281 "x" gnus-summary-limit-to-unread
1282 "s" gnus-summary-isearch-article
1283 "t" gnus-article-hide-headers
1284 "g" gnus-summary-show-article
1285 "l" gnus-summary-goto-last-article
1286 "v" gnus-summary-preview-mime-message
1287 "\C-c\C-v\C-v" gnus-uu-decode-uu-view
1288 "\C-d" gnus-summary-enter-digest-group
1289 "\M-\C-d" gnus-summary-read-document
1290 "\M-\C-e" gnus-summary-edit-parameters
1291 "\M-\C-g" gnus-summary-customize-parameters
1293 "*" gnus-cache-enter-article
1294 "\M-*" gnus-cache-remove-article
1295 "\M-&" gnus-summary-universal-argument
1296 "\C-l" gnus-recenter
1297 "I" gnus-summary-increase-score
1298 "L" gnus-summary-lower-score
1299 "\M-i" gnus-symbolic-argument
1300 "h" gnus-summary-select-article-buffer
1302 "V" gnus-summary-score-map
1303 "X" gnus-uu-extract-map
1304 "S" gnus-summary-send-map)
1306 ;; Sort of orthogonal keymap
1307 (gnus-define-keys (gnus-summary-mark-map "M" gnus-summary-mode-map)
1308 "t" gnus-summary-tick-article-forward
1309 "!" gnus-summary-tick-article-forward
1310 "d" gnus-summary-mark-as-read-forward
1311 "r" gnus-summary-mark-as-read-forward
1312 "c" gnus-summary-clear-mark-forward
1313 " " gnus-summary-clear-mark-forward
1314 "e" gnus-summary-mark-as-expirable
1315 "x" gnus-summary-mark-as-expirable
1316 "?" gnus-summary-mark-as-dormant
1317 "b" gnus-summary-set-bookmark
1318 "B" gnus-summary-remove-bookmark
1319 "#" gnus-summary-mark-as-processable
1320 "\M-#" gnus-summary-unmark-as-processable
1321 "S" gnus-summary-limit-include-expunged
1322 "C" gnus-summary-catchup
1323 "H" gnus-summary-catchup-to-here
1324 "\C-c" gnus-summary-catchup-all
1325 "k" gnus-summary-kill-same-subject-and-select
1326 "K" gnus-summary-kill-same-subject
1327 "P" gnus-uu-mark-map)
1329 (gnus-define-keys (gnus-summary-mscore-map "V" gnus-summary-mark-map)
1330 "c" gnus-summary-clear-above
1331 "u" gnus-summary-tick-above
1332 "m" gnus-summary-mark-above
1333 "k" gnus-summary-kill-below)
1335 (gnus-define-keys (gnus-summary-limit-map "/" gnus-summary-mode-map)
1336 "/" gnus-summary-limit-to-subject
1337 "n" gnus-summary-limit-to-articles
1338 "w" gnus-summary-pop-limit
1339 "s" gnus-summary-limit-to-subject
1340 "a" gnus-summary-limit-to-author
1341 "u" gnus-summary-limit-to-unread
1342 "m" gnus-summary-limit-to-marks
1343 "M" gnus-summary-limit-exclude-marks
1344 "v" gnus-summary-limit-to-score
1345 "*" gnus-summary-limit-include-cached
1346 "D" gnus-summary-limit-include-dormant
1347 "T" gnus-summary-limit-include-thread
1348 "d" gnus-summary-limit-exclude-dormant
1349 "t" gnus-summary-limit-to-age
1350 "E" gnus-summary-limit-include-expunged
1351 "c" gnus-summary-limit-exclude-childless-dormant
1352 "C" gnus-summary-limit-mark-excluded-as-read)
1354 (gnus-define-keys (gnus-summary-goto-map "G" gnus-summary-mode-map)
1355 "n" gnus-summary-next-unread-article
1356 "p" gnus-summary-prev-unread-article
1357 "N" gnus-summary-next-article
1358 "P" gnus-summary-prev-article
1359 "\C-n" gnus-summary-next-same-subject
1360 "\C-p" gnus-summary-prev-same-subject
1361 "\M-n" gnus-summary-next-unread-subject
1362 "\M-p" gnus-summary-prev-unread-subject
1363 "f" gnus-summary-first-unread-article
1364 "b" gnus-summary-best-unread-article
1365 "j" gnus-summary-goto-article
1366 "g" gnus-summary-goto-subject
1367 "l" gnus-summary-goto-last-article
1368 "o" gnus-summary-pop-article)
1370 (gnus-define-keys (gnus-summary-thread-map "T" gnus-summary-mode-map)
1371 "k" gnus-summary-kill-thread
1372 "l" gnus-summary-lower-thread
1373 "i" gnus-summary-raise-thread
1374 "T" gnus-summary-toggle-threads
1375 "t" gnus-summary-rethread-current
1376 "^" gnus-summary-reparent-thread
1377 "s" gnus-summary-show-thread
1378 "S" gnus-summary-show-all-threads
1379 "h" gnus-summary-hide-thread
1380 "H" gnus-summary-hide-all-threads
1381 "n" gnus-summary-next-thread
1382 "p" gnus-summary-prev-thread
1383 "u" gnus-summary-up-thread
1384 "o" gnus-summary-top-thread
1385 "d" gnus-summary-down-thread
1386 "#" gnus-uu-mark-thread
1387 "\M-#" gnus-uu-unmark-thread)
1389 (gnus-define-keys (gnus-summary-buffer-map "Y" gnus-summary-mode-map)
1390 "g" gnus-summary-prepare
1391 "c" gnus-summary-insert-cached-articles)
1393 (gnus-define-keys (gnus-summary-exit-map "Z" gnus-summary-mode-map)
1394 "c" gnus-summary-catchup-and-exit
1395 "C" gnus-summary-catchup-all-and-exit
1396 "E" gnus-summary-exit-no-update
1397 "Q" gnus-summary-exit
1398 "Z" gnus-summary-exit
1399 "n" gnus-summary-catchup-and-goto-next-group
1400 "R" gnus-summary-reselect-current-group
1401 "G" gnus-summary-rescan-group
1402 "N" gnus-summary-next-group
1403 "s" gnus-summary-save-newsrc
1404 "P" gnus-summary-prev-group)
1406 (gnus-define-keys (gnus-summary-article-map "A" gnus-summary-mode-map)
1407 " " gnus-summary-next-page
1408 "n" gnus-summary-next-page
1409 "\177" gnus-summary-prev-page
1410 [delete] gnus-summary-prev-page
1411 "p" gnus-summary-prev-page
1412 "\r" gnus-summary-scroll-up
1413 "\M-\r" gnus-summary-scroll-down
1414 "<" gnus-summary-beginning-of-article
1415 ">" gnus-summary-end-of-article
1416 "b" gnus-summary-beginning-of-article
1417 "e" gnus-summary-end-of-article
1418 "^" gnus-summary-refer-parent-article
1419 "r" gnus-summary-refer-parent-article
1420 "R" gnus-summary-refer-references
1421 "T" gnus-summary-refer-thread
1422 "g" gnus-summary-show-article
1423 "s" gnus-summary-isearch-article
1424 "P" gnus-summary-print-article)
1426 (gnus-define-keys (gnus-summary-wash-map "W" gnus-summary-mode-map)
1427 "b" gnus-article-add-buttons
1428 "B" gnus-article-add-buttons-to-head
1429 "o" gnus-article-treat-overstrike
1430 "e" gnus-article-emphasize
1431 "w" gnus-article-fill-cited-article
1432 "Q" gnus-article-fill-long-lines
1433 "C" gnus-article-capitalize-sentences
1434 "c" gnus-article-remove-cr
1435 "f" gnus-article-display-x-face
1436 "l" gnus-summary-stop-page-breaking
1437 "r" gnus-summary-caesar-message
1438 "t" gnus-article-hide-headers
1439 "v" gnus-summary-verbose-headers
1440 "m" gnus-summary-toggle-mime
1441 "h" gnus-article-treat-html
1442 "d" gnus-article-treat-dumbquotes)
1444 (gnus-define-keys (gnus-summary-wash-hide-map "W" gnus-summary-wash-map)
1445 "a" gnus-article-hide
1446 "h" gnus-article-hide-headers
1447 "b" gnus-article-hide-boring-headers
1448 "s" gnus-article-hide-signature
1449 "c" gnus-article-hide-citation
1450 "C" gnus-article-hide-citation-in-followups
1451 "p" gnus-article-hide-pgp
1452 "B" gnus-article-strip-banner
1453 "P" gnus-article-hide-pem
1454 "\C-c" gnus-article-hide-citation-maybe)
1456 (gnus-define-keys (gnus-summary-wash-highlight-map "H" gnus-summary-wash-map)
1457 "a" gnus-article-highlight
1458 "h" gnus-article-highlight-headers
1459 "c" gnus-article-highlight-citation
1460 "s" gnus-article-highlight-signature)
1462 (gnus-define-keys (gnus-summary-wash-time-map "T" gnus-summary-wash-map)
1463 "z" gnus-article-date-ut
1464 "u" gnus-article-date-ut
1465 "l" gnus-article-date-local
1466 "e" gnus-article-date-lapsed
1467 "o" gnus-article-date-original
1468 "i" gnus-article-date-iso8601
1469 "s" gnus-article-date-user)
1471 (gnus-define-keys (gnus-summary-wash-empty-map "E" gnus-summary-wash-map)
1472 "t" gnus-article-remove-trailing-blank-lines
1473 "l" gnus-article-strip-leading-blank-lines
1474 "m" gnus-article-strip-multiple-blank-lines
1475 "a" gnus-article-strip-blank-lines
1476 "A" gnus-article-strip-all-blank-lines
1477 "s" gnus-article-strip-leading-space
1478 "e" gnus-article-strip-trailing-space)
1480 (gnus-define-keys (gnus-summary-help-map "H" gnus-summary-mode-map)
1482 "f" gnus-summary-fetch-faq
1483 "d" gnus-summary-describe-group
1484 "h" gnus-summary-describe-briefly
1485 "i" gnus-info-find-node)
1487 (gnus-define-keys (gnus-summary-backend-map "B" gnus-summary-mode-map)
1488 "e" gnus-summary-expire-articles
1489 "\M-\C-e" gnus-summary-expire-articles-now
1490 "\177" gnus-summary-delete-article
1491 [delete] gnus-summary-delete-article
1492 "m" gnus-summary-move-article
1493 "r" gnus-summary-respool-article
1494 "w" gnus-summary-edit-article
1495 "c" gnus-summary-copy-article
1496 "B" gnus-summary-crosspost-article
1497 "q" gnus-summary-respool-query
1498 "t" gnus-summary-respool-trace
1499 "i" gnus-summary-import-article
1500 "p" gnus-summary-article-posted-p)
1502 (gnus-define-keys (gnus-summary-save-map "O" gnus-summary-mode-map)
1503 "o" gnus-summary-save-article
1504 "m" gnus-summary-save-article-mail
1505 "F" gnus-summary-write-article-file
1506 "r" gnus-summary-save-article-rmail
1507 "f" gnus-summary-save-article-file
1508 "b" gnus-summary-save-article-body-file
1509 "h" gnus-summary-save-article-folder
1510 "v" gnus-summary-save-article-vm
1511 "p" gnus-summary-pipe-output
1512 "s" gnus-soup-add-article)
1514 (gnus-define-keys (gnus-summary-mime-map "K" gnus-summary-mode-map)
1515 "b" gnus-summary-display-buttonized
1516 "m" gnus-summary-repair-multipart
1517 "v" gnus-article-view-part
1518 "o" gnus-article-save-part
1519 "c" gnus-article-copy-part
1520 "e" gnus-article-externalize-part
1521 "i" gnus-article-inline-part
1522 "|" gnus-article-pipe-part)
1525 (defun gnus-summary-make-menu-bar ()
1526 (gnus-turn-off-edit-menu 'summary)
1528 (unless (boundp 'gnus-summary-misc-menu)
1531 gnus-summary-kill-menu gnus-summary-mode-map ""
1536 ["Enter score..." gnus-summary-score-entry t]
1537 ["Customize" gnus-score-customize t])
1538 (gnus-make-score-map 'increase)
1539 (gnus-make-score-map 'lower)
1541 ["Kill below" gnus-summary-kill-below t]
1542 ["Mark above" gnus-summary-mark-above t]
1543 ["Tick above" gnus-summary-tick-above t]
1544 ["Clear above" gnus-summary-clear-above t])
1545 ["Current score" gnus-summary-current-score t]
1546 ["Set score" gnus-summary-set-score t]
1547 ["Switch current score file..." gnus-score-change-score-file t]
1548 ["Set mark below..." gnus-score-set-mark-below t]
1549 ["Set expunge below..." gnus-score-set-expunge-below t]
1550 ["Edit current score file" gnus-score-edit-current-scores t]
1551 ["Edit score file" gnus-score-edit-file t]
1552 ["Trace score" gnus-score-find-trace t]
1553 ["Find words" gnus-score-find-favourite-words t]
1554 ["Rescore buffer" gnus-summary-rescore t]
1555 ["Increase score..." gnus-summary-increase-score t]
1556 ["Lower score..." gnus-summary-lower-score t]))))
1558 ;; Define both the Article menu in the summary buffer and the equivalent
1559 ;; Commands menu in the article buffer here for consistency.
1562 ["All" gnus-article-hide t]
1563 ["Headers" gnus-article-hide-headers t]
1564 ["Signature" gnus-article-hide-signature t]
1565 ["Citation" gnus-article-hide-citation t]
1566 ["PGP" gnus-article-hide-pgp t]
1567 ["Banner" gnus-article-strip-banner t]
1568 ["Boring headers" gnus-article-hide-boring-headers t])
1570 ["All" gnus-article-highlight t]
1571 ["Headers" gnus-article-highlight-headers t]
1572 ["Signature" gnus-article-highlight-signature t]
1573 ["Citation" gnus-article-highlight-citation t])
1575 ["Local" gnus-article-date-local t]
1576 ["ISO8601" gnus-article-date-iso8601 t]
1577 ["UT" gnus-article-date-ut t]
1578 ["Original" gnus-article-date-original t]
1579 ["Lapsed" gnus-article-date-lapsed t]
1580 ["User-defined" gnus-article-date-user t])
1583 ["Leading" gnus-article-strip-leading-blank-lines t]
1584 ["Multiple" gnus-article-strip-multiple-blank-lines t]
1585 ["Trailing" gnus-article-remove-trailing-blank-lines t]
1586 ["All of the above" gnus-article-strip-blank-lines t]
1587 ["All" gnus-article-strip-all-blank-lines t]
1588 ["Leading space" gnus-article-strip-leading-space t]
1589 ["Trailing space" gnus-article-strip-trailing-space t])
1590 ["Overstrike" gnus-article-treat-overstrike t]
1591 ["Dumb quotes" gnus-article-treat-dumbquotes t]
1592 ["Emphasis" gnus-article-emphasize t]
1593 ["Word wrap" gnus-article-fill-cited-article t]
1594 ["Fill long lines" gnus-article-fill-long-lines t]
1595 ["Capitalize sentences" gnus-article-capitalize-sentences t]
1596 ["CR" gnus-article-remove-cr t]
1597 ["Show X-Face" gnus-article-display-x-face t]
1598 ["UnHTMLize" gnus-article-treat-html t]
1599 ["Rot 13" gnus-summary-caesar-message t]
1600 ["Unix pipe" gnus-summary-pipe-message t]
1601 ["Add buttons" gnus-article-add-buttons t]
1602 ["Add buttons to head" gnus-article-add-buttons-to-head t]
1603 ["Stop page breaking" gnus-summary-stop-page-breaking t]
1604 ["Toggle MIME" gnus-summary-toggle-mime t]
1605 ["Verbose header" gnus-summary-verbose-headers t]
1606 ["Toggle header" gnus-summary-toggle-header t])
1608 ["Save in default format" gnus-summary-save-article t]
1609 ["Save in file" gnus-summary-save-article-file t]
1610 ["Save in Unix mail format" gnus-summary-save-article-mail t]
1611 ["Save in MH folder" gnus-summary-save-article-folder t]
1612 ["Save in VM folder" gnus-summary-save-article-vm t]
1613 ["Save in RMAIL mbox" gnus-summary-save-article-rmail t]
1614 ["Save body in file" gnus-summary-save-article-body-file t]
1615 ["Pipe through a filter" gnus-summary-pipe-output t]
1616 ["Add to SOUP packet" gnus-soup-add-article t]
1617 ["Print" gnus-summary-print-article t])
1619 ["Respool article..." gnus-summary-respool-article t]
1620 ["Move article..." gnus-summary-move-article
1621 (gnus-check-backend-function
1622 'request-move-article gnus-newsgroup-name)]
1623 ["Copy article..." gnus-summary-copy-article t]
1624 ["Crosspost article..." gnus-summary-crosspost-article
1625 (gnus-check-backend-function
1626 'request-replace-article gnus-newsgroup-name)]
1627 ["Import file..." gnus-summary-import-article t]
1628 ["Check if posted" gnus-summary-article-posted-p t]
1629 ["Edit article" gnus-summary-edit-article
1630 (not (gnus-group-read-only-p))]
1631 ["Delete article" gnus-summary-delete-article
1632 (gnus-check-backend-function
1633 'request-expire-articles gnus-newsgroup-name)]
1634 ["Query respool" gnus-summary-respool-query t]
1635 ["Trace respool" gnus-summary-respool-trace t]
1636 ["Delete expirable articles" gnus-summary-expire-articles-now
1637 (gnus-check-backend-function
1638 'request-expire-articles gnus-newsgroup-name)])
1640 ["Uudecode" gnus-uu-decode-uu t]
1641 ["Uudecode and save" gnus-uu-decode-uu-and-save t]
1642 ["Unshar" gnus-uu-decode-unshar t]
1643 ["Unshar and save" gnus-uu-decode-unshar-and-save t]
1644 ["Save" gnus-uu-decode-save t]
1645 ["Binhex" gnus-uu-decode-binhex t]
1646 ["Postscript" gnus-uu-decode-postscript t])
1648 ["Enter article" gnus-cache-enter-article t]
1649 ["Remove article" gnus-cache-remove-article t])
1650 ["Select article buffer" gnus-summary-select-article-buffer t]
1651 ["Enter digest buffer" gnus-summary-enter-digest-group t]
1652 ["Isearch article..." gnus-summary-isearch-article t]
1653 ["Beginning of the article" gnus-summary-beginning-of-article t]
1654 ["End of the article" gnus-summary-end-of-article t]
1655 ["Fetch parent of article" gnus-summary-refer-parent-article t]
1656 ["Fetch referenced articles" gnus-summary-refer-references t]
1657 ["Fetch current thread" gnus-summary-refer-thread t]
1658 ["Fetch article with id..." gnus-summary-refer-article t]
1659 ["Redisplay" gnus-summary-show-article t])))
1661 gnus-summary-article-menu gnus-summary-mode-map ""
1662 (cons "Article" innards))
1665 gnus-article-commands-menu gnus-article-mode-map ""
1666 (cons "Commands" innards)))
1669 gnus-summary-thread-menu gnus-summary-mode-map ""
1671 ["Toggle threading" gnus-summary-toggle-threads t]
1672 ["Hide threads" gnus-summary-hide-all-threads t]
1673 ["Show threads" gnus-summary-show-all-threads t]
1674 ["Hide thread" gnus-summary-hide-thread t]
1675 ["Show thread" gnus-summary-show-thread t]
1676 ["Go to next thread" gnus-summary-next-thread t]
1677 ["Go to previous thread" gnus-summary-prev-thread t]
1678 ["Go down thread" gnus-summary-down-thread t]
1679 ["Go up thread" gnus-summary-up-thread t]
1680 ["Top of thread" gnus-summary-top-thread t]
1681 ["Mark thread as read" gnus-summary-kill-thread t]
1682 ["Lower thread score" gnus-summary-lower-thread t]
1683 ["Raise thread score" gnus-summary-raise-thread t]
1684 ["Rethread current" gnus-summary-rethread-current t]
1688 gnus-summary-post-menu gnus-summary-mode-map ""
1690 ["Post an article" gnus-summary-post-news t]
1691 ["Followup" gnus-summary-followup t]
1692 ["Followup and yank" gnus-summary-followup-with-original t]
1693 ["Supersede article" gnus-summary-supersede-article t]
1694 ["Cancel article" gnus-summary-cancel-article t]
1695 ["Reply" gnus-summary-reply t]
1696 ["Reply and yank" gnus-summary-reply-with-original t]
1697 ["Wide reply" gnus-summary-wide-reply t]
1698 ["Wide reply and yank" gnus-summary-wide-reply-with-original t]
1699 ["Mail forward" gnus-summary-mail-forward t]
1700 ["Post forward" gnus-summary-post-forward t]
1701 ["Digest and mail" gnus-summary-mail-digest t]
1702 ["Digest and post" gnus-summary-post-digest t]
1703 ["Resend message" gnus-summary-resend-message t]
1704 ["Send bounced mail" gnus-summary-resend-bounced-mail t]
1705 ["Send a mail" gnus-summary-mail-other-window t]
1706 ["Uuencode and post" gnus-uu-post-news t]
1707 ["Followup via news" gnus-summary-followup-to-mail t]
1708 ["Followup via news and yank"
1709 gnus-summary-followup-to-mail-with-original t]
1711 ;;["Send" gnus-summary-send-draft t]
1712 ;;["Send bounced" gnus-resend-bounced-mail t])
1716 gnus-summary-misc-menu gnus-summary-mode-map ""
1719 ["Mark as read" gnus-summary-mark-as-read-forward t]
1720 ["Mark same subject and select"
1721 gnus-summary-kill-same-subject-and-select t]
1722 ["Mark same subject" gnus-summary-kill-same-subject t]
1723 ["Catchup" gnus-summary-catchup t]
1724 ["Catchup all" gnus-summary-catchup-all t]
1725 ["Catchup to here" gnus-summary-catchup-to-here t]
1726 ["Catchup region" gnus-summary-mark-region-as-read t]
1727 ["Mark excluded" gnus-summary-limit-mark-excluded-as-read t])
1729 ["Tick" gnus-summary-tick-article-forward t]
1730 ["Mark as dormant" gnus-summary-mark-as-dormant t]
1731 ["Remove marks" gnus-summary-clear-mark-forward t]
1732 ["Set expirable mark" gnus-summary-mark-as-expirable t]
1733 ["Set bookmark" gnus-summary-set-bookmark t]
1734 ["Remove bookmark" gnus-summary-remove-bookmark t])
1736 ["Marks..." gnus-summary-limit-to-marks t]
1737 ["Subject..." gnus-summary-limit-to-subject t]
1738 ["Author..." gnus-summary-limit-to-author t]
1739 ["Age..." gnus-summary-limit-to-age t]
1740 ["Score" gnus-summary-limit-to-score t]
1741 ["Unread" gnus-summary-limit-to-unread t]
1742 ["Non-dormant" gnus-summary-limit-exclude-dormant t]
1743 ["Articles" gnus-summary-limit-to-articles t]
1744 ["Pop limit" gnus-summary-pop-limit t]
1745 ["Show dormant" gnus-summary-limit-include-dormant t]
1746 ["Hide childless dormant"
1747 gnus-summary-limit-exclude-childless-dormant t]
1748 ;;["Hide thread" gnus-summary-limit-exclude-thread t]
1749 ["Hide marked" gnus-summary-limit-exclude-marks t]
1750 ["Show expunged" gnus-summary-show-all-expunged t])
1752 ["Set mark" gnus-summary-mark-as-processable t]
1753 ["Remove mark" gnus-summary-unmark-as-processable t]
1754 ["Remove all marks" gnus-summary-unmark-all-processable t]
1755 ["Mark above" gnus-uu-mark-over t]
1756 ["Mark series" gnus-uu-mark-series t]
1757 ["Mark region" gnus-uu-mark-region t]
1758 ["Unmark region" gnus-uu-unmark-region t]
1759 ["Mark by regexp..." gnus-uu-mark-by-regexp t]
1760 ["Unmark by regexp..." gnus-uu-unmark-by-regexp t]
1761 ["Mark all" gnus-uu-mark-all t]
1762 ["Mark buffer" gnus-uu-mark-buffer t]
1763 ["Mark sparse" gnus-uu-mark-sparse t]
1764 ["Mark thread" gnus-uu-mark-thread t]
1765 ["Unmark thread" gnus-uu-unmark-thread t]
1766 ("Process Mark Sets"
1767 ["Kill" gnus-summary-kill-process-mark t]
1768 ["Yank" gnus-summary-yank-process-mark
1769 gnus-newsgroup-process-stack]
1770 ["Save" gnus-summary-save-process-mark t]))
1772 ["Page forward" gnus-summary-next-page t]
1773 ["Page backward" gnus-summary-prev-page t]
1774 ["Line forward" gnus-summary-scroll-up t])
1776 ["Next unread article" gnus-summary-next-unread-article t]
1777 ["Previous unread article" gnus-summary-prev-unread-article t]
1778 ["Next article" gnus-summary-next-article t]
1779 ["Previous article" gnus-summary-prev-article t]
1780 ["Next unread subject" gnus-summary-next-unread-subject t]
1781 ["Previous unread subject" gnus-summary-prev-unread-subject t]
1782 ["Next article same subject" gnus-summary-next-same-subject t]
1783 ["Previous article same subject" gnus-summary-prev-same-subject t]
1784 ["First unread article" gnus-summary-first-unread-article t]
1785 ["Best unread article" gnus-summary-best-unread-article t]
1786 ["Go to subject number..." gnus-summary-goto-subject t]
1787 ["Go to article number..." gnus-summary-goto-article t]
1788 ["Go to the last article" gnus-summary-goto-last-article t]
1789 ["Pop article off history" gnus-summary-pop-article t])
1791 ["Sort by number" gnus-summary-sort-by-number t]
1792 ["Sort by author" gnus-summary-sort-by-author t]
1793 ["Sort by subject" gnus-summary-sort-by-subject t]
1794 ["Sort by date" gnus-summary-sort-by-date t]
1795 ["Sort by score" gnus-summary-sort-by-score t]
1796 ["Sort by lines" gnus-summary-sort-by-lines t])
1798 ["Fetch group FAQ" gnus-summary-fetch-faq t]
1799 ["Describe group" gnus-summary-describe-group t]
1800 ["Read manual" gnus-info-find-node t])
1802 ["Pick and read" gnus-pick-mode t]
1803 ["Binary" gnus-binary-mode t])
1805 ["Regenerate" gnus-summary-prepare t]
1806 ["Insert cached articles" gnus-summary-insert-cached-articles t]
1807 ["Toggle threading" gnus-summary-toggle-threads t])
1808 ["Filter articles..." gnus-summary-execute-command t]
1809 ["Run command on subjects..." gnus-summary-universal-argument t]
1810 ["Search articles forward..." gnus-summary-search-article-forward t]
1811 ["Search articles backward..." gnus-summary-search-article-backward t]
1812 ["Toggle line truncation" gnus-summary-toggle-truncation t]
1813 ["Expand window" gnus-summary-expand-window t]
1814 ["Expire expirable articles" gnus-summary-expire-articles
1815 (gnus-check-backend-function
1816 'request-expire-articles gnus-newsgroup-name)]
1817 ["Edit local kill file" gnus-summary-edit-local-kill t]
1818 ["Edit main kill file" gnus-summary-edit-global-kill t]
1819 ["Edit group parameters" gnus-summary-edit-parameters t]
1820 ["Customize group parameters" gnus-summary-customize-parameters t]
1821 ["Send a bug report" gnus-bug t]
1823 ["Catchup and exit" gnus-summary-catchup-and-exit t]
1824 ["Catchup all and exit" gnus-summary-catchup-all-and-exit t]
1825 ["Catchup and goto next" gnus-summary-catchup-and-goto-next-group t]
1826 ["Exit group" gnus-summary-exit t]
1827 ["Exit group without updating" gnus-summary-exit-no-update t]
1828 ["Exit and goto next group" gnus-summary-next-group t]
1829 ["Exit and goto prev group" gnus-summary-prev-group t]
1830 ["Reselect group" gnus-summary-reselect-current-group t]
1831 ["Rescan group" gnus-summary-rescan-group t]
1832 ["Update dribble" gnus-summary-save-newsrc t])))
1834 (gnus-run-hooks 'gnus-summary-menu-hook)))
1836 (defun gnus-score-set-default (var value)
1837 "A version of set that updates the GNU Emacs menu-bar."
1839 ;; It is the message that forces the active status to be updated.
1842 (defun gnus-make-score-map (type)
1843 "Make a summary score map of type TYPE."
1846 (let ((headers '(("author" "from" string)
1847 ("subject" "subject" string)
1848 ("article body" "body" string)
1849 ("article head" "head" string)
1850 ("xref" "xref" string)
1851 ("extra header" "extra" string)
1852 ("lines" "lines" number)
1853 ("followups to author" "followup" string)))
1854 (types '((number ("less than" <)
1857 (string ("substring" s)
1861 (perms '(("temporary" (current-time-string))
1869 (if (eq type 'lower)
1874 (setq header (car headers))
1880 (let ((ts (cdr (assoc (nth 2 header) types)))
1896 'gnus-summary-score-entry
1898 (if (or (string= (nth 1 header)
1900 (string= (nth 1 header)
1903 (list 'gnus-summary-header
1905 (list 'quote (nth 1 (car ts)))
1906 (list 'gnus-score-default nil)
1912 (list (nreverse outp))))
1915 (list (nreverse outt))))
1917 (setq headers (cdr headers)))
1918 (list (nreverse outh))))))))
1922 (defun gnus-summary-mode (&optional group)
1923 "Major mode for reading articles.
1925 All normal editing commands are switched off.
1926 \\<gnus-summary-mode-map>
1927 Each line in this buffer represents one article. To read an
1928 article, you can, for instance, type `\\[gnus-summary-next-page]'. To move forwards
1929 and backwards while displaying articles, type `\\[gnus-summary-next-unread-article]' and `\\[gnus-summary-prev-unread-article]',
1932 You can also post articles and send mail from this buffer. To
1933 follow up an article, type `\\[gnus-summary-followup]'. To mail a reply to the author
1934 of an article, type `\\[gnus-summary-reply]'.
1936 There are approx. one gazillion commands you can execute in this
1937 buffer; read the info pages for more information (`\\[gnus-info-find-node]').
1939 The following commands are available:
1941 \\{gnus-summary-mode-map}"
1943 (when (gnus-visual-p 'summary-menu 'menu)
1944 (gnus-summary-make-menu-bar))
1945 (kill-all-local-variables)
1946 (gnus-summary-make-local-variables)
1947 (gnus-make-thread-indent-array)
1948 (gnus-simplify-mode-line)
1949 (setq major-mode 'gnus-summary-mode)
1950 (setq mode-name "Summary")
1951 (make-local-variable 'minor-mode-alist)
1952 (use-local-map gnus-summary-mode-map)
1953 (buffer-disable-undo)
1954 (setq buffer-read-only t) ;Disable modification
1955 (setq truncate-lines t)
1956 (setq selective-display t)
1957 (setq selective-display-ellipses t) ;Display `...'
1958 (gnus-summary-set-display-table)
1959 (gnus-set-default-directory)
1960 (setq gnus-newsgroup-name group)
1961 (make-local-variable 'gnus-summary-line-format)
1962 (make-local-variable 'gnus-summary-line-format-spec)
1963 (make-local-variable 'gnus-summary-dummy-line-format)
1964 (make-local-variable 'gnus-summary-dummy-line-format-spec)
1965 (make-local-variable 'gnus-summary-mark-positions)
1966 (make-local-hook 'pre-command-hook)
1967 (add-hook 'pre-command-hook 'gnus-set-global-variables nil t)
1968 (gnus-run-hooks 'gnus-summary-mode-hook)
1969 (gnus-update-format-specifications nil 'summary 'summary-mode 'summary-dummy)
1970 (gnus-update-summary-mark-positions))
1972 (defun gnus-summary-make-local-variables ()
1973 "Make all the local summary buffer variables."
1975 (dolist (local gnus-summary-local-variables)
1978 (if (eq (cdr local) 'global)
1979 ;; Copy the global value of the variable.
1980 (setq global (symbol-value (car local)))
1981 ;; Use the value from the list.
1982 (setq global (eval (cdr local))))
1983 (set (make-local-variable (car local)) global))
1984 ;; Simple nil-valued local variable.
1985 (set (make-local-variable local) nil)))))
1987 (defun gnus-summary-clear-local-variables ()
1988 (let ((locals gnus-summary-local-variables))
1990 (if (consp (car locals))
1991 (and (vectorp (caar locals))
1992 (set (caar locals) nil))
1993 (and (vectorp (car locals))
1994 (set (car locals) nil)))
1995 (setq locals (cdr locals)))))
1997 ;; Summary data functions.
1999 (defmacro gnus-data-number (data)
2002 (defmacro gnus-data-set-number (data number)
2003 `(setcar ,data ,number))
2005 (defmacro gnus-data-mark (data)
2008 (defmacro gnus-data-set-mark (data mark)
2009 `(setcar (nthcdr 1 ,data) ,mark))
2011 (defmacro gnus-data-pos (data)
2014 (defmacro gnus-data-set-pos (data pos)
2015 `(setcar (nthcdr 2 ,data) ,pos))
2017 (defmacro gnus-data-header (data)
2020 (defmacro gnus-data-set-header (data header)
2021 `(setf (nth 3 ,data) ,header))
2023 (defmacro gnus-data-level (data)
2026 (defmacro gnus-data-unread-p (data)
2027 `(= (nth 1 ,data) gnus-unread-mark))
2029 (defmacro gnus-data-read-p (data)
2030 `(/= (nth 1 ,data) gnus-unread-mark))
2032 (defmacro gnus-data-pseudo-p (data)
2033 `(consp (nth 3 ,data)))
2035 (defmacro gnus-data-find (number)
2036 `(assq ,number gnus-newsgroup-data))
2038 (defmacro gnus-data-find-list (number &optional data)
2039 `(let ((bdata ,(or data 'gnus-newsgroup-data)))
2040 (memq (assq ,number bdata)
2043 (defmacro gnus-data-make (number mark pos header level)
2044 `(list ,number ,mark ,pos ,header ,level))
2046 (defun gnus-data-enter (after-article number mark pos header level offset)
2047 (let ((data (gnus-data-find-list after-article)))
2049 (error "No such article: %d" after-article))
2050 (setcdr data (cons (gnus-data-make number mark pos header level)
2052 (setq gnus-newsgroup-data-reverse nil)
2053 (gnus-data-update-list (cddr data) offset)))
2055 (defun gnus-data-enter-list (after-article list &optional offset)
2057 (let ((data (and after-article (gnus-data-find-list after-article)))
2061 (let ((odata gnus-newsgroup-data))
2062 (setq gnus-newsgroup-data (nconc list gnus-newsgroup-data))
2064 (gnus-data-update-list odata offset)))
2065 ;; Find the last element in the list to be spliced into the main
2068 (setq list (cdr list)))
2071 (setcdr list gnus-newsgroup-data)
2072 (setq gnus-newsgroup-data ilist)
2074 (gnus-data-update-list (cdr list) offset)))
2075 (setcdr list (cdr data))
2078 (gnus-data-update-list (cdr list) offset))))
2079 (setq gnus-newsgroup-data-reverse nil))))
2081 (defun gnus-data-remove (article &optional offset)
2082 (let ((data gnus-newsgroup-data))
2083 (if (= (gnus-data-number (car data)) article)
2085 (setq gnus-newsgroup-data (cdr gnus-newsgroup-data)
2086 gnus-newsgroup-data-reverse nil)
2088 (gnus-data-update-list gnus-newsgroup-data offset)))
2090 (when (= (gnus-data-number (cadr data)) article)
2091 (setcdr data (cddr data))
2093 (gnus-data-update-list (cdr data) offset))
2095 gnus-newsgroup-data-reverse nil))
2096 (setq data (cdr data))))))
2098 (defmacro gnus-data-list (backward)
2100 (or gnus-newsgroup-data-reverse
2101 (setq gnus-newsgroup-data-reverse
2102 (reverse gnus-newsgroup-data)))
2103 gnus-newsgroup-data))
2105 (defun gnus-data-update-list (data offset)
2106 "Add OFFSET to the POS of all data entries in DATA."
2107 (setq gnus-newsgroup-data-reverse nil)
2109 (setcar (nthcdr 2 (car data)) (+ offset (nth 2 (car data))))
2110 (setq data (cdr data))))
2112 (defun gnus-summary-article-pseudo-p (article)
2113 "Say whether this article is a pseudo article or not."
2114 (not (vectorp (gnus-data-header (gnus-data-find article)))))
2116 (defmacro gnus-summary-article-sparse-p (article)
2117 "Say whether this article is a sparse article or not."
2118 `(memq ,article gnus-newsgroup-sparse))
2120 (defmacro gnus-summary-article-ancient-p (article)
2121 "Say whether this article is a sparse article or not."
2122 `(memq ,article gnus-newsgroup-ancient))
2124 (defun gnus-article-parent-p (number)
2125 "Say whether this article is a parent or not."
2126 (let ((data (gnus-data-find-list number)))
2127 (and (cdr data) ; There has to be an article after...
2128 (< (gnus-data-level (car data)) ; And it has to have a higher level.
2129 (gnus-data-level (nth 1 data))))))
2131 (defun gnus-article-children (number)
2132 "Return a list of all children to NUMBER."
2133 (let* ((data (gnus-data-find-list number))
2134 (level (gnus-data-level (car data)))
2136 (setq data (cdr data))
2138 (= (gnus-data-level (car data)) (1+ level)))
2139 (push (gnus-data-number (car data)) children)
2140 (setq data (cdr data)))
2143 (defmacro gnus-summary-skip-intangible ()
2144 "If the current article is intangible, then jump to a different article."
2145 '(let ((to (get-text-property (point) 'gnus-intangible)))
2146 (and to (gnus-summary-goto-subject to))))
2148 (defmacro gnus-summary-article-intangible-p ()
2149 "Say whether this article is intangible or not."
2150 '(get-text-property (point) 'gnus-intangible))
2152 (defun gnus-article-read-p (article)
2153 "Say whether ARTICLE is read or not."
2154 (not (or (memq article gnus-newsgroup-marked)
2155 (memq article gnus-newsgroup-unreads)
2156 (memq article gnus-newsgroup-unselected)
2157 (memq article gnus-newsgroup-dormant))))
2159 ;; Some summary mode macros.
2161 (defmacro gnus-summary-article-number ()
2162 "The article number of the article on the current line.
2163 If there isn's an article number here, then we return the current
2166 (gnus-summary-skip-intangible)
2167 (or (get-text-property (point) 'gnus-number)
2168 (gnus-summary-last-subject))))
2170 (defmacro gnus-summary-article-header (&optional number)
2171 "Return the header of article NUMBER."
2172 `(gnus-data-header (gnus-data-find
2173 ,(or number '(gnus-summary-article-number)))))
2175 (defmacro gnus-summary-thread-level (&optional number)
2176 "Return the level of thread that starts with article NUMBER."
2177 `(if (and (eq gnus-summary-make-false-root 'dummy)
2178 (get-text-property (point) 'gnus-intangible))
2180 (gnus-data-level (gnus-data-find
2181 ,(or number '(gnus-summary-article-number))))))
2183 (defmacro gnus-summary-article-mark (&optional number)
2184 "Return the mark of article NUMBER."
2185 `(gnus-data-mark (gnus-data-find
2186 ,(or number '(gnus-summary-article-number)))))
2188 (defmacro gnus-summary-article-pos (&optional number)
2189 "Return the position of the line of article NUMBER."
2190 `(gnus-data-pos (gnus-data-find
2191 ,(or number '(gnus-summary-article-number)))))
2193 (defalias 'gnus-summary-subject-string 'gnus-summary-article-subject)
2194 (defmacro gnus-summary-article-subject (&optional number)
2195 "Return current subject string or nil if nothing."
2198 `(gnus-data-header (assq ,number gnus-newsgroup-data))
2199 '(gnus-data-header (assq (gnus-summary-article-number)
2200 gnus-newsgroup-data)))))
2203 (mail-header-subject headers))))
2205 (defmacro gnus-summary-article-score (&optional number)
2206 "Return current article score."
2207 `(or (cdr (assq ,(or number '(gnus-summary-article-number))
2208 gnus-newsgroup-scored))
2209 gnus-summary-default-score 0))
2211 (defun gnus-summary-article-children (&optional number)
2212 "Return a list of article numbers that are children of article NUMBER."
2213 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))))
2214 (level (gnus-data-level (car data)))
2216 (while (and (setq data (cdr data))
2217 (> (setq l (gnus-data-level (car data))) level))
2218 (and (= (1+ level) l)
2219 (push (gnus-data-number (car data))
2221 (nreverse children)))
2223 (defun gnus-summary-article-parent (&optional number)
2224 "Return the article number of the parent of article NUMBER."
2225 (let* ((data (gnus-data-find-list (or number (gnus-summary-article-number))
2226 (gnus-data-list t)))
2227 (level (gnus-data-level (car data))))
2229 () ; This is a root.
2230 ;; We search until we find an article with a level less than
2231 ;; this one. That function has to be the parent.
2232 (while (and (setq data (cdr data))
2233 (not (< (gnus-data-level (car data)) level))))
2234 (and data (gnus-data-number (car data))))))
2236 (defun gnus-unread-mark-p (mark)
2237 "Say whether MARK is the unread mark."
2238 (= mark gnus-unread-mark))
2240 (defun gnus-read-mark-p (mark)
2241 "Say whether MARK is one of the marks that mark as read.
2242 This is all marks except unread, ticked, dormant, and expirable."
2243 (not (or (= mark gnus-unread-mark)
2244 (= mark gnus-ticked-mark)
2245 (= mark gnus-dormant-mark)
2246 (= mark gnus-expirable-mark))))
2248 (defmacro gnus-article-mark (number)
2249 "Return the MARK of article NUMBER.
2250 This macro should only be used when computing the mark the \"first\"
2251 time; i.e., when generating the summary lines. After that,
2252 `gnus-summary-article-mark' should be used to examine the
2255 ((memq ,number gnus-newsgroup-unsendable) gnus-unsendable-mark)
2256 ((memq ,number gnus-newsgroup-undownloaded) gnus-undownloaded-mark)
2257 ((memq ,number gnus-newsgroup-downloadable) gnus-downloadable-mark)
2258 ((memq ,number gnus-newsgroup-unreads) gnus-unread-mark)
2259 ((memq ,number gnus-newsgroup-marked) gnus-ticked-mark)
2260 ((memq ,number gnus-newsgroup-dormant) gnus-dormant-mark)
2261 ((memq ,number gnus-newsgroup-expirable) gnus-expirable-mark)
2262 (t (or (cdr (assq ,number gnus-newsgroup-reads))
2263 gnus-ancient-mark))))
2265 ;; Saving hidden threads.
2267 (put 'gnus-save-hidden-threads 'lisp-indent-function 0)
2268 (put 'gnus-save-hidden-threads 'edebug-form-spec '(body))
2270 (defmacro gnus-save-hidden-threads (&rest forms)
2271 "Save hidden threads, eval FORMS, and restore the hidden threads."
2272 (let ((config (make-symbol "config")))
2273 `(let ((,config (gnus-hidden-threads-configuration)))
2277 (gnus-restore-hidden-threads-configuration ,config)))))
2279 (defun gnus-data-compute-positions ()
2280 "Compute the positions of all articles."
2281 (setq gnus-newsgroup-data-reverse nil)
2282 (let ((data gnus-newsgroup-data))
2284 (gnus-save-hidden-threads
2285 (gnus-summary-show-all-threads)
2286 (goto-char (point-min))
2288 (while (get-text-property (point) 'gnus-intangible)
2290 (gnus-data-set-pos (car data) (+ (point) 3))
2291 (setq data (cdr data))
2292 (forward-line 1))))))
2294 (defun gnus-hidden-threads-configuration ()
2295 "Return the current hidden threads configuration."
2298 (goto-char (point-min))
2299 (while (search-forward "\r" nil t)
2300 (push (1- (point)) config))
2303 (defun gnus-restore-hidden-threads-configuration (config)
2304 "Restore hidden threads configuration from CONFIG."
2305 (let (point buffer-read-only)
2306 (while (setq point (pop config))
2307 (when (and (< point (point-max))
2309 (eq (char-after) ?\n))
2310 (subst-char-in-region point (1+ point) ?\n ?\r)))))
2312 ;; Various summary mode internalish functions.
2314 (defun gnus-mouse-pick-article (e)
2317 (gnus-summary-next-page nil t))
2319 (defun gnus-summary-set-display-table ()
2320 ;; Change the display table. Odd characters have a tendency to mess
2321 ;; up nicely formatted displays - we make all possible glyphs
2322 ;; display only a single character.
2324 ;; We start from the standard display table, if any.
2325 (let ((table (or (copy-sequence standard-display-table)
2326 (make-display-table)))
2328 ;; Nix out all the control chars...
2329 (while (>= (setq i (1- i)) 0)
2330 (aset table i [??]))
2331 ;; ... but not newline and cr, of course. (cr is necessary for the
2332 ;; selective display).
2333 (aset table ?\n nil)
2334 (aset table ?\r nil)
2335 ;; We keep TAB as well.
2336 (aset table ?\t nil)
2337 ;; We nix out any glyphs over 126 that are not set already.
2339 (while (>= (setq i (1- i)) 127)
2340 ;; Only modify if the entry is nil.
2341 (unless (aref table i)
2342 (aset table i [??]))))
2343 (setq buffer-display-table table)))
2345 (defun gnus-summary-setup-buffer (group)
2346 "Initialize summary buffer."
2347 (let ((buffer (concat "*Summary " group "*")))
2348 (if (get-buffer buffer)
2351 (setq gnus-summary-buffer (current-buffer))
2352 (not gnus-newsgroup-prepared))
2353 ;; Fix by Sudish Joseph <joseph@cis.ohio-state.edu>
2354 (setq gnus-summary-buffer (set-buffer (gnus-get-buffer-create buffer)))
2355 (gnus-summary-mode group)
2357 (gnus-carpal-setup-buffer 'summary))
2358 (unless gnus-single-article-buffer
2359 (make-local-variable 'gnus-article-buffer)
2360 (make-local-variable 'gnus-article-current)
2361 (make-local-variable 'gnus-original-article-buffer))
2362 (setq gnus-newsgroup-name group)
2365 (defun gnus-set-global-variables ()
2366 ;; Set the global equivalents of the summary buffer-local variables
2367 ;; to the latest values they had. These reflect the summary buffer
2368 ;; that was in action when the last article was fetched.
2369 (when (eq major-mode 'gnus-summary-mode)
2370 (setq gnus-summary-buffer (current-buffer))
2371 (let ((name gnus-newsgroup-name)
2372 (marked gnus-newsgroup-marked)
2373 (unread gnus-newsgroup-unreads)
2374 (headers gnus-current-headers)
2375 (data gnus-newsgroup-data)
2376 (summary gnus-summary-buffer)
2377 (article-buffer gnus-article-buffer)
2378 (original gnus-original-article-buffer)
2379 (gac gnus-article-current)
2380 (reffed gnus-reffed-article-number)
2381 (score-file gnus-current-score-file)
2382 (default-charset gnus-newsgroup-charset))
2384 (set-buffer gnus-group-buffer)
2385 (setq gnus-newsgroup-name name
2386 gnus-newsgroup-marked marked
2387 gnus-newsgroup-unreads unread
2388 gnus-current-headers headers
2389 gnus-newsgroup-data data
2390 gnus-article-current gac
2391 gnus-summary-buffer summary
2392 gnus-article-buffer article-buffer
2393 gnus-original-article-buffer original
2394 gnus-reffed-article-number reffed
2395 gnus-current-score-file score-file
2396 gnus-newsgroup-charset default-charset)
2397 ;; The article buffer also has local variables.
2398 (when (gnus-buffer-live-p gnus-article-buffer)
2399 (set-buffer gnus-article-buffer)
2400 (setq gnus-summary-buffer summary))))))
2402 (defun gnus-summary-article-unread-p (article)
2403 "Say whether ARTICLE is unread or not."
2404 (memq article gnus-newsgroup-unreads))
2406 (defun gnus-summary-first-article-p (&optional article)
2407 "Return whether ARTICLE is the first article in the buffer."
2408 (if (not (setq article (or article (gnus-summary-article-number))))
2410 (eq article (caar gnus-newsgroup-data))))
2412 (defun gnus-summary-last-article-p (&optional article)
2413 "Return whether ARTICLE is the last article in the buffer."
2414 (if (not (setq article (or article (gnus-summary-article-number))))
2415 ;; All non-existent numbers are the last article. :-)
2417 (not (cdr (gnus-data-find-list article)))))
2419 (defun gnus-make-thread-indent-array ()
2421 (unless (and gnus-thread-indent-array
2422 (= gnus-thread-indent-level gnus-thread-indent-array-level))
2423 (setq gnus-thread-indent-array (make-vector 201 "")
2424 gnus-thread-indent-array-level gnus-thread-indent-level)
2426 (aset gnus-thread-indent-array n
2427 (make-string (* n gnus-thread-indent-level) ? ))
2430 (defun gnus-update-summary-mark-positions ()
2431 "Compute where the summary marks are to go."
2433 (when (gnus-buffer-exists-p gnus-summary-buffer)
2434 (set-buffer gnus-summary-buffer))
2435 (let ((gnus-replied-mark 129)
2436 (gnus-score-below-mark 130)
2437 (gnus-score-over-mark 130)
2438 (gnus-download-mark 131)
2439 (spec gnus-summary-line-format-spec)
2442 (gnus-set-work-buffer)
2443 (let ((gnus-summary-line-format-spec spec)
2444 (gnus-newsgroup-downloadable '((0 . t))))
2445 (gnus-summary-insert-line
2446 (make-full-mail-header 0 "" "" "" "" "" 0 0 "" nil)
2447 0 nil 128 t nil "" nil 1)
2448 (goto-char (point-min))
2449 (setq pos (list (cons 'unread (and (search-forward "\200" nil t)
2451 (goto-char (point-min))
2452 (push (cons 'replied (and (search-forward "\201" nil t)
2455 (goto-char (point-min))
2456 (push (cons 'score (and (search-forward "\202" nil t) (- (point) 2)))
2458 (goto-char (point-min))
2459 (push (cons 'download
2460 (and (search-forward "\203" nil t) (- (point) 2)))
2462 (setq gnus-summary-mark-positions pos))))
2464 (defun gnus-summary-insert-dummy-line (gnus-tmp-subject gnus-tmp-number)
2465 "Insert a dummy root in the summary buffer."
2467 (gnus-add-text-properties
2468 (point) (progn (eval gnus-summary-dummy-line-format-spec) (point))
2469 (list 'gnus-number gnus-tmp-number 'gnus-intangible gnus-tmp-number)))
2471 (defun gnus-summary-from-or-to-or-newsgroups (header)
2472 (let ((to (cdr (assq 'To (mail-header-extra header))))
2473 (newsgroups (cdr (assq 'Newsgroups (mail-header-extra header))))
2474 (mail-parse-charset gnus-newsgroup-charset))
2477 gnus-ignored-from-addresses
2478 (string-match gnus-ignored-from-addresses
2479 (mail-header-from header)))
2481 (or (car (funcall gnus-extract-address-components
2483 gnus-decode-encoded-word-function to)))
2484 (funcall gnus-decode-encoded-word-function to))))
2486 gnus-ignored-from-addresses
2487 (string-match gnus-ignored-from-addresses
2488 (mail-header-from header)))
2489 (concat "=> " newsgroups))
2491 (or (car (funcall gnus-extract-address-components
2492 (mail-header-from header)))
2493 (mail-header-from header))))))
2495 (defun gnus-summary-insert-line (gnus-tmp-header
2496 gnus-tmp-level gnus-tmp-current
2497 gnus-tmp-unread gnus-tmp-replied
2498 gnus-tmp-expirable gnus-tmp-subject-or-nil
2499 &optional gnus-tmp-dummy gnus-tmp-score
2501 (let* ((gnus-tmp-indentation (aref gnus-thread-indent-array gnus-tmp-level))
2502 (gnus-tmp-lines (mail-header-lines gnus-tmp-header))
2503 (gnus-tmp-score (or gnus-tmp-score gnus-summary-default-score 0))
2504 (gnus-tmp-score-char
2505 (if (or (null gnus-summary-default-score)
2506 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
2507 gnus-summary-zcore-fuzz))
2509 (if (< gnus-tmp-score gnus-summary-default-score)
2510 gnus-score-below-mark gnus-score-over-mark)))
2512 (cond (gnus-tmp-process gnus-process-mark)
2513 ((memq gnus-tmp-current gnus-newsgroup-cached)
2515 (gnus-tmp-replied gnus-replied-mark)
2516 ((memq gnus-tmp-current gnus-newsgroup-saved)
2518 (t gnus-unread-mark)))
2519 (gnus-tmp-from (mail-header-from gnus-tmp-header))
2522 ((string-match "<[^>]+> *$" gnus-tmp-from)
2523 (let ((beg (match-beginning 0)))
2524 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
2525 (substring gnus-tmp-from (1+ (match-beginning 0))
2526 (1- (match-end 0))))
2527 (substring gnus-tmp-from 0 beg))))
2528 ((string-match "(.+)" gnus-tmp-from)
2529 (substring gnus-tmp-from
2530 (1+ (match-beginning 0)) (1- (match-end 0))))
2532 (gnus-tmp-subject (mail-header-subject gnus-tmp-header))
2533 (gnus-tmp-number (mail-header-number gnus-tmp-header))
2534 (gnus-tmp-opening-bracket (if gnus-tmp-dummy ?\< ?\[))
2535 (gnus-tmp-closing-bracket (if gnus-tmp-dummy ?\> ?\]))
2536 (buffer-read-only nil))
2537 (when (string= gnus-tmp-name "")
2538 (setq gnus-tmp-name gnus-tmp-from))
2539 (unless (numberp gnus-tmp-lines)
2540 (setq gnus-tmp-lines 0))
2541 (gnus-put-text-property-excluding-characters-with-faces
2543 (progn (eval gnus-summary-line-format-spec) (point))
2544 'gnus-number gnus-tmp-number)
2545 (when (gnus-visual-p 'summary-highlight 'highlight)
2547 (gnus-run-hooks 'gnus-summary-update-hook)
2550 (defun gnus-summary-update-line (&optional dont-update)
2551 ;; Update summary line after change.
2552 (when (and gnus-summary-default-score
2553 (not gnus-summary-inhibit-highlight))
2554 (let* ((gnus-summary-inhibit-highlight t) ; Prevent recursion.
2555 (article (gnus-summary-article-number))
2556 (score (gnus-summary-article-score article)))
2558 (if (and gnus-summary-mark-below
2559 (< (gnus-summary-article-score)
2560 gnus-summary-mark-below))
2561 ;; This article has a low score, so we mark it as read.
2562 (when (memq article gnus-newsgroup-unreads)
2563 (gnus-summary-mark-article-as-read gnus-low-score-mark))
2564 (when (eq (gnus-summary-article-mark) gnus-low-score-mark)
2565 ;; This article was previously marked as read on account
2566 ;; of a low score, but now it has risen, so we mark it as
2568 (gnus-summary-mark-article-as-unread gnus-unread-mark)))
2569 (gnus-summary-update-mark
2570 (if (or (null gnus-summary-default-score)
2571 (<= (abs (- score gnus-summary-default-score))
2572 gnus-summary-zcore-fuzz))
2574 (if (< score gnus-summary-default-score)
2575 gnus-score-below-mark gnus-score-over-mark))
2577 ;; Do visual highlighting.
2578 (when (gnus-visual-p 'summary-highlight 'highlight)
2579 (gnus-run-hooks 'gnus-summary-update-hook)))))
2581 (defvar gnus-tmp-new-adopts nil)
2583 (defun gnus-summary-number-of-articles-in-thread (thread &optional level char)
2584 "Return the number of articles in THREAD.
2585 This may be 0 in some cases -- if none of the articles in
2586 the thread are to be displayed."
2588 ;; Fix by Luc Van Eycken <Luc.VanEycken@esat.kuleuven.ac.be>.
2590 ((not (listp thread))
2592 ((and (consp thread) (cdr thread))
2595 'gnus-summary-number-of-articles-in-thread (cdr thread))))
2598 ((memq (mail-header-number (car thread)) gnus-newsgroup-limit)
2601 (when (and level (zerop level) gnus-tmp-new-adopts)
2604 'gnus-summary-number-of-articles-in-thread
2605 gnus-tmp-new-adopts))))
2607 (if (> number 1) gnus-not-empty-thread-mark
2608 gnus-empty-thread-mark)
2611 (defun gnus-summary-set-local-parameters (group)
2612 "Go through the local params of GROUP and set all variable specs in that list."
2613 (let ((params (gnus-group-find-parameter group))
2616 (setq elem (car params)
2617 params (cdr params))
2618 (and (consp elem) ; Has to be a cons.
2619 (consp (cdr elem)) ; The cdr has to be a list.
2620 (symbolp (car elem)) ; Has to be a symbol in there.
2621 (not (memq (car elem) '(quit-config))) ; Ignore quit-config.
2622 (ignore-errors ; So we set it.
2623 (make-local-variable (car elem))
2624 (set (car elem) (eval (nth 1 elem))))))))
2626 (defun gnus-summary-read-group (group &optional show-all no-article
2627 kill-buffer no-display backward
2629 "Start reading news in newsgroup GROUP.
2630 If SHOW-ALL is non-nil, already read articles are also listed.
2631 If NO-ARTICLE is non-nil, no article is selected initially.
2632 If NO-DISPLAY, don't generate a summary buffer."
2636 (let ((gnus-auto-select-next nil))
2637 (or (gnus-summary-read-group-1
2638 group show-all no-article
2639 kill-buffer no-display
2642 select-articles nil)))))
2643 (eq gnus-auto-select-next 'quietly))
2644 (set-buffer gnus-group-buffer)
2645 ;; The entry function called above goes to the next
2646 ;; group automatically, so we go two groups back
2647 ;; if we are searching for the previous group.
2649 (gnus-group-prev-unread-group 2))
2650 (if (not (equal group (gnus-group-group-name)))
2651 (setq group (gnus-group-group-name))
2655 (defun gnus-summary-read-group-1 (group show-all no-article
2656 kill-buffer no-display
2657 &optional select-articles)
2658 ;; Killed foreign groups can't be entered.
2659 (when (and (not (gnus-group-native-p group))
2660 (not (gnus-gethash group gnus-newsrc-hashtb)))
2661 (error "Dead non-native groups can't be entered"))
2662 (gnus-message 5 "Retrieving newsgroup: %s..." group)
2663 (let* ((new-group (gnus-summary-setup-buffer group))
2664 (quit-config (gnus-group-quit-config group))
2665 (did-select (and new-group (gnus-select-newsgroup
2666 group show-all select-articles))))
2668 ;; This summary buffer exists already, so we just select it.
2670 (gnus-set-global-variables)
2672 (gnus-kill-or-deaden-summary kill-buffer))
2673 (gnus-configure-windows 'summary 'force)
2674 (gnus-set-mode-line 'summary)
2675 (gnus-summary-position-point)
2678 ;; We couldn't select this group.
2680 (when (and (eq major-mode 'gnus-summary-mode)
2681 (not (equal (current-buffer) kill-buffer)))
2682 (kill-buffer (current-buffer))
2683 (if (not quit-config)
2685 ;; Update the info -- marks might need to be removed,
2687 (gnus-summary-update-info)
2688 (set-buffer gnus-group-buffer)
2689 (gnus-group-jump-to-group group)
2690 (gnus-group-next-unread-group 1))
2691 (gnus-handle-ephemeral-exit quit-config)))
2692 (gnus-message 3 "Can't select group")
2694 ;; The user did a `C-g' while prompting for number of articles,
2695 ;; so we exit this group.
2696 ((eq did-select 'quit)
2697 (and (eq major-mode 'gnus-summary-mode)
2698 (not (equal (current-buffer) kill-buffer))
2699 (kill-buffer (current-buffer)))
2701 (gnus-kill-or-deaden-summary kill-buffer))
2702 (if (not quit-config)
2704 (set-buffer gnus-group-buffer)
2705 (gnus-group-jump-to-group group)
2706 (gnus-group-next-unread-group 1)
2707 (gnus-configure-windows 'group 'force))
2708 (gnus-handle-ephemeral-exit quit-config))
2709 ;; Finally signal the quit.
2711 ;; The group was successfully selected.
2713 (gnus-set-global-variables)
2714 ;; Save the active value in effect when the group was entered.
2715 (setq gnus-newsgroup-active
2717 (gnus-active gnus-newsgroup-name)))
2718 ;; You can change the summary buffer in some way with this hook.
2719 (gnus-run-hooks 'gnus-select-group-hook)
2720 ;; Set any local variables in the group parameters.
2721 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2722 (gnus-update-format-specifications
2723 nil 'summary 'summary-mode 'summary-dummy)
2724 ;; Do score processing.
2725 (when gnus-use-scoring
2726 (gnus-possibly-score-headers))
2727 ;; Check whether to fill in the gaps in the threads.
2728 (when gnus-build-sparse-threads
2729 (gnus-build-sparse-threads))
2730 ;; Find the initial limit.
2731 (if gnus-show-threads
2733 (let ((gnus-newsgroup-dormant nil))
2734 (gnus-summary-initial-limit show-all))
2735 (gnus-summary-initial-limit show-all))
2736 (setq gnus-newsgroup-limit
2738 (lambda (header) (mail-header-number header))
2739 gnus-newsgroup-headers)))
2740 ;; Generate the summary buffer.
2742 (gnus-summary-prepare))
2743 (when gnus-use-trees
2744 (gnus-tree-open group)
2745 (setq gnus-summary-highlight-line-function
2746 'gnus-tree-highlight-article))
2747 ;; If the summary buffer is empty, but there are some low-scored
2748 ;; articles or some excluded dormants, we include these in the
2750 (when (and (zerop (buffer-size))
2752 (cond (gnus-newsgroup-dormant
2753 (gnus-summary-limit-include-dormant))
2754 ((and gnus-newsgroup-scored show-all)
2755 (gnus-summary-limit-include-expunged t))))
2756 ;; Function `gnus-apply-kill-file' must be called in this hook.
2757 (gnus-run-hooks 'gnus-apply-kill-hook)
2758 (if (and (zerop (buffer-size))
2761 ;; This newsgroup is empty.
2762 (gnus-summary-catchup-and-exit nil t)
2763 (gnus-message 6 "No unread news")
2765 (gnus-kill-or-deaden-summary kill-buffer))
2766 ;; Return nil from this function.
2768 ;; Hide conversation thread subtrees. We cannot do this in
2769 ;; gnus-summary-prepare-hook since kill processing may not
2770 ;; work with hidden articles.
2771 (and gnus-show-threads
2772 gnus-thread-hide-subtree
2773 (gnus-summary-hide-all-threads))
2775 (gnus-kill-or-deaden-summary kill-buffer))
2776 ;; Show first unread article if requested.
2777 (if (and (not no-article)
2779 gnus-newsgroup-unreads
2780 gnus-auto-select-first)
2782 (gnus-configure-windows 'summary)
2784 ((eq gnus-auto-select-first 'best)
2785 (gnus-summary-best-unread-article))
2786 ((eq gnus-auto-select-first t)
2787 (gnus-summary-first-unread-article))
2788 ((gnus-functionp gnus-auto-select-first)
2789 (funcall gnus-auto-select-first))))
2790 ;; Don't select any articles, just move point to the first
2791 ;; article in the group.
2792 (goto-char (point-min))
2793 (gnus-summary-position-point)
2794 (gnus-configure-windows 'summary 'force)
2795 (gnus-set-mode-line 'summary))
2796 (when (get-buffer-window gnus-group-buffer t)
2797 ;; Gotta use windows, because recenter does weird stuff if
2798 ;; the current buffer ain't the displayed window.
2799 (let ((owin (selected-window)))
2800 (select-window (get-buffer-window gnus-group-buffer t))
2801 (when (gnus-group-goto-group group)
2803 (select-window owin)))
2804 ;; Mark this buffer as "prepared".
2805 (setq gnus-newsgroup-prepared t)
2806 (gnus-run-hooks 'gnus-summary-prepared-hook)
2809 (defun gnus-summary-prepare ()
2810 "Generate the summary buffer."
2812 (let ((buffer-read-only nil))
2814 (setq gnus-newsgroup-data nil
2815 gnus-newsgroup-data-reverse nil)
2816 (gnus-run-hooks 'gnus-summary-generate-hook)
2817 ;; Generate the buffer, either with threads or without.
2818 (when gnus-newsgroup-headers
2819 (gnus-summary-prepare-threads
2820 (if gnus-show-threads
2821 (gnus-sort-gathered-threads
2822 (funcall gnus-summary-thread-gathering-function
2824 (gnus-cut-threads (gnus-make-threads)))))
2825 ;; Unthreaded display.
2826 (gnus-sort-articles gnus-newsgroup-headers))))
2827 (setq gnus-newsgroup-data (nreverse gnus-newsgroup-data))
2828 ;; Call hooks for modifying summary buffer.
2829 (goto-char (point-min))
2830 (gnus-run-hooks 'gnus-summary-prepare-hook)))
2832 (defsubst gnus-general-simplify-subject (subject)
2833 "Simply subject by the same rules as gnus-gather-threads-by-subject."
2836 ;; Truncate the subject.
2837 (gnus-simplify-subject-functions
2838 (gnus-map-function gnus-simplify-subject-functions subject))
2839 ((numberp gnus-summary-gather-subject-limit)
2840 (setq subject (gnus-simplify-subject-re subject))
2841 (if (> (length subject) gnus-summary-gather-subject-limit)
2842 (substring subject 0 gnus-summary-gather-subject-limit)
2844 ;; Fuzzily simplify it.
2845 ((eq 'fuzzy gnus-summary-gather-subject-limit)
2846 (gnus-simplify-subject-fuzzy subject))
2847 ;; Just remove the leading "Re:".
2849 (gnus-simplify-subject-re subject))))
2851 (if (and gnus-summary-gather-exclude-subject
2852 (string-match gnus-summary-gather-exclude-subject subject))
2853 nil ; This article shouldn't be gathered
2856 (defun gnus-summary-simplify-subject-query ()
2857 "Query where the respool algorithm would put this article."
2859 (gnus-summary-select-article)
2860 (message (gnus-general-simplify-subject (gnus-summary-article-subject))))
2862 (defun gnus-gather-threads-by-subject (threads)
2863 "Gather threads by looking at Subject headers."
2864 (if (not gnus-summary-make-false-root)
2866 (let ((hashtb (gnus-make-hashtable 1024))
2869 subject hthread whole-subject)
2871 (setq subject (gnus-general-simplify-subject
2872 (setq whole-subject (mail-header-subject
2875 (if (setq hthread (gnus-gethash subject hashtb))
2877 ;; We enter a dummy root into the thread, if we
2878 ;; haven't done that already.
2879 (unless (stringp (caar hthread))
2880 (setcar hthread (list whole-subject (car hthread))))
2881 ;; We add this new gathered thread to this gathered
2883 (setcdr (car hthread)
2884 (nconc (cdar hthread) (list (car threads))))
2885 ;; Remove it from the list of threads.
2886 (setcdr prev (cdr threads))
2887 (setq threads prev))
2888 ;; Enter this thread into the hash table.
2889 (gnus-sethash subject threads hashtb)))
2891 (setq threads (cdr threads)))
2894 (defun gnus-gather-threads-by-references (threads)
2895 "Gather threads by looking at References headers."
2896 (let ((idhashtb (gnus-make-hashtable 1024))
2897 (thhashtb (gnus-make-hashtable 1024))
2900 ids references id gthread gid entered ref)
2902 (when (setq references (mail-header-references (caar threads)))
2903 (setq id (mail-header-id (caar threads))
2904 ids (gnus-split-references references)
2906 (while (setq ref (pop ids))
2907 (setq ids (delete ref ids))
2908 (if (not (setq gid (gnus-gethash ref idhashtb)))
2910 (gnus-sethash ref id idhashtb)
2911 (gnus-sethash id threads thhashtb))
2912 (setq gthread (gnus-gethash gid thhashtb))
2914 ;; We enter a dummy root into the thread, if we
2915 ;; haven't done that already.
2916 (unless (stringp (caar gthread))
2917 (setcar gthread (list (mail-header-subject (caar gthread))
2919 ;; We add this new gathered thread to this gathered
2921 (setcdr (car gthread)
2922 (nconc (cdar gthread) (list (car threads)))))
2923 ;; Add it into the thread hash table.
2924 (gnus-sethash id gthread thhashtb)
2926 ;; Remove it from the list of threads.
2927 (setcdr prev (cdr threads))
2928 (setq threads prev))))
2930 (setq threads (cdr threads)))
2933 (defun gnus-sort-gathered-threads (threads)
2934 "Sort subtreads inside each gathered thread by article number."
2935 (let ((result threads))
2937 (when (stringp (caar threads))
2938 (setcdr (car threads)
2939 (sort (cdar threads) 'gnus-thread-sort-by-number)))
2940 (setq threads (cdr threads)))
2943 (defun gnus-thread-loop-p (root thread)
2944 "Say whether ROOT is in THREAD."
2945 (let ((stack (list thread))
2948 (while (setq thread (pop stack))
2949 (setq th (cdr thread))
2951 (not (eq (caar th) root)))
2954 ;; We have found a loop.
2956 (setcdr thread (delq (car th) (cdr thread)))
2957 (if (boundp (setq ref-dep (intern "none"
2958 gnus-newsgroup-dependencies)))
2959 (setcdr (symbol-value ref-dep)
2960 (nconc (cdr (symbol-value ref-dep))
2962 (set ref-dep (list nil (car th))))
2965 ;; Push all the subthreads onto the stack.
2966 (push (cdr thread) stack)))
2969 (defun gnus-make-threads ()
2970 "Go through the dependency hashtb and find the roots. Return all threads."
2972 (while (catch 'infloop
2975 ;; Deal with self-referencing References loops.
2976 (when (and (car (symbol-value refs))
2983 (car (symbol-value refs)) thread))
2984 (cdr (symbol-value refs)))))))
2987 (unless (car (symbol-value refs))
2988 ;; These threads do not refer back to any other articles,
2989 ;; so they're roots.
2990 (setq threads (append (cdr (symbol-value refs)) threads))))
2991 gnus-newsgroup-dependencies)))
2994 ;; Build the thread tree.
2995 (defsubst gnus-dependencies-add-header (header dependencies force-new)
2996 "Enter HEADER into the DEPENDENCIES table if it is not already there.
2998 If FORCE-NEW is not nil, enter HEADER into the DEPENDENCIES table even
2999 if it was already present.
3001 If `gnus-summary-ignore-duplicates' is nil then duplicate Message-IDs
3002 will not be entered in the DEPENDENCIES table. Otherwise duplicate
3003 Message-IDs will be renamed be renamed to a unique Message-ID before
3006 Returns HEADER if it was entered in the DEPENDENCIES. Returns nil otherwise."
3007 (let* ((id (mail-header-id header))
3008 (id-dep (and id (intern id dependencies)))
3009 ref ref-dep ref-header)
3010 ;; Enter this `header' in the `dependencies' table.
3014 ;; The first two cases do the normal part: enter a new `header'
3015 ;; in the `dependencies' table.
3016 ((not (boundp id-dep))
3017 (set id-dep (list header)))
3018 ((null (car (symbol-value id-dep)))
3019 (setcar (symbol-value id-dep) header))
3021 ;; From here the `header' was already present in the
3022 ;; `dependencies' table.
3024 ;; Overrides an existing entry;
3025 ;; just set the header part of the entry.
3026 (setcar (symbol-value id-dep) header))
3028 ;; Renames the existing `header' to a unique Message-ID.
3029 ((not gnus-summary-ignore-duplicates)
3030 ;; An article with this Message-ID has already been seen.
3031 ;; We rename the Message-ID.
3032 (set (setq id-dep (intern (setq id (nnmail-message-id)) dependencies))
3034 (mail-header-set-id header id))
3036 ;; The last case ignores an existing entry, except it adds any
3037 ;; additional Xrefs (in case the two articles came from different
3039 ;; Also sets `header' to `nil' meaning that the `dependencies'
3040 ;; table was *not* modified.
3042 (mail-header-set-xref
3043 (car (symbol-value id-dep))
3044 (concat (or (mail-header-xref (car (symbol-value id-dep)))
3046 (or (mail-header-xref header) "")))
3050 ;; First check if that we are not creating a References loop.
3051 (setq ref (gnus-parent-id (mail-header-references header)))
3053 (setq ref-dep (intern-soft ref dependencies))
3055 (setq ref-header (car (symbol-value ref-dep))))
3056 (if (string= id ref)
3057 ;; Yuk! This is a reference loop. Make the article be a
3060 (mail-header-set-references (car (symbol-value id-dep)) "none")
3062 (setq ref (gnus-parent-id (mail-header-references ref-header)))))
3063 (setq ref (gnus-parent-id (mail-header-references header)))
3064 (setq ref-dep (intern (or ref "none") dependencies))
3065 (if (boundp ref-dep)
3066 (setcdr (symbol-value ref-dep)
3067 (nconc (cdr (symbol-value ref-dep))
3068 (list (symbol-value id-dep))))
3069 (set ref-dep (list nil (symbol-value id-dep)))))
3072 (defun gnus-build-sparse-threads ()
3073 (let ((headers gnus-newsgroup-headers)
3074 (gnus-summary-ignore-duplicates t)
3075 header references generation relations
3076 subject child end new-child date)
3077 ;; First we create an alist of generations/relations, where
3078 ;; generations is how much we trust the relation, and the relation
3080 (gnus-message 7 "Making sparse threads...")
3082 (nnheader-set-temp-buffer " *gnus sparse threads*")
3083 (while (setq header (pop headers))
3084 (when (and (setq references (mail-header-references header))
3085 (not (string= references "")))
3087 (setq child (mail-header-id header)
3088 subject (mail-header-subject header)
3089 date (mail-header-date header)
3091 (while (search-backward ">" nil t)
3092 (setq end (1+ (point)))
3093 (when (search-backward "<" nil t)
3094 (setq new-child (buffer-substring (point) end))
3095 (push (list (incf generation)
3096 child (setq child new-child)
3100 (push (list (1+ generation) child nil subject) relations))
3102 (kill-buffer (current-buffer)))
3103 ;; Sort over trustworthiness.
3106 (when (gnus-dependencies-add-header
3107 (make-full-mail-header
3108 gnus-reffed-article-number
3109 (nth 3 relation) "" (or (nth 4 relation) "")
3111 (or (nth 2 relation) "") 0 0 "")
3112 gnus-newsgroup-dependencies nil)
3113 (push gnus-reffed-article-number gnus-newsgroup-limit)
3114 (push gnus-reffed-article-number gnus-newsgroup-sparse)
3115 (push (cons gnus-reffed-article-number gnus-sparse-mark)
3116 gnus-newsgroup-reads)
3117 (decf gnus-reffed-article-number)))
3118 (sort relations 'car-less-than-car))
3119 (gnus-message 7 "Making sparse threads...done")))
3121 (defun gnus-build-old-threads ()
3122 ;; Look at all the articles that refer back to old articles, and
3123 ;; fetch the headers for the articles that aren't there. This will
3124 ;; build complete threads - if the roots haven't been expired by the
3129 (when (not (car (symbol-value refs)))
3130 (setq heads (cdr (symbol-value refs)))
3132 (if (memq (mail-header-number (caar heads))
3133 gnus-newsgroup-dormant)
3134 (setq heads (cdr heads))
3135 (setq id (symbol-name refs))
3136 (while (and (setq id (gnus-build-get-header id))
3137 (not (car (gnus-id-to-thread id)))))
3138 (setq heads nil)))))
3139 gnus-newsgroup-dependencies)))
3141 ;; This function has to be called with point after the article number
3142 ;; on the beginning of the line.
3143 (defsubst gnus-nov-parse-line (number dependencies &optional force-new)
3144 (let ((eol (gnus-point-at-eol))
3145 (buffer (current-buffer))
3148 ;; overview: [num subject from date id refs chars lines misc]
3153 (make-full-mail-header
3155 (nnheader-nov-field) ; subject
3156 (nnheader-nov-field) ; from
3157 (nnheader-nov-field) ; date
3158 (nnheader-nov-read-message-id) ; id
3159 (nnheader-nov-field) ; refs
3160 (nnheader-nov-read-integer) ; chars
3161 (nnheader-nov-read-integer) ; lines
3163 (nnheader-nov-field)) ; misc
3164 (nnheader-nov-parse-extra))) ; extra
3166 (when gnus-alter-header-function
3167 (funcall gnus-alter-header-function header))
3168 (gnus-dependencies-add-header header dependencies force-new)))
3170 (defun gnus-build-get-header (id)
3171 ;; Look through the buffer of NOV lines and find the header to
3172 ;; ID. Enter this line into the dependencies hash table, and return
3173 ;; the id of the parent article (if any).
3174 (let ((deps gnus-newsgroup-dependencies)
3178 (set-buffer nntp-server-buffer)
3179 (let ((case-fold-search nil))
3180 (goto-char (point-min))
3181 (while (and (not found)
3182 (search-forward id nil t))
3184 (setq found (looking-at
3185 (format "^[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t%s"
3186 (regexp-quote id))))
3187 (or found (beginning-of-line 2)))
3191 (setq header (gnus-nov-parse-line
3192 (read (current-buffer)) deps))
3193 (gnus-parent-id (mail-header-references header))))))
3195 (let ((number (mail-header-number header)))
3196 (push number gnus-newsgroup-limit)
3197 (push header gnus-newsgroup-headers)
3198 (if (memq number gnus-newsgroup-unselected)
3200 (push number gnus-newsgroup-unreads)
3201 (setq gnus-newsgroup-unselected
3202 (delq number gnus-newsgroup-unselected)))
3203 (push number gnus-newsgroup-ancient)))))))
3205 (defun gnus-build-all-threads ()
3206 "Read all the headers."
3207 (let ((gnus-summary-ignore-duplicates t)
3208 (dependencies gnus-newsgroup-dependencies)
3211 (set-buffer nntp-server-buffer)
3212 (let ((case-fold-search nil))
3213 (goto-char (point-min))
3216 (setq article (read (current-buffer))
3217 header (gnus-nov-parse-line
3218 article dependencies)))
3221 (set-buffer gnus-summary-buffer)
3222 (push header gnus-newsgroup-headers)
3223 (if (memq (setq article (mail-header-number header))
3224 gnus-newsgroup-unselected)
3226 (push article gnus-newsgroup-unreads)
3227 (setq gnus-newsgroup-unselected
3228 (delq article gnus-newsgroup-unselected)))
3229 (push article gnus-newsgroup-ancient)))
3230 (forward-line 1)))))))
3232 (defun gnus-summary-update-article-line (article header)
3233 "Update the line for ARTICLE using HEADERS."
3234 (let* ((id (mail-header-id header))
3235 (thread (gnus-id-to-thread id)))
3237 (error "Article in no thread"))
3238 ;; Update the thread.
3239 (setcar thread header)
3240 (gnus-summary-goto-subject article)
3241 (let* ((datal (gnus-data-find-list article))
3243 (length (when (cdr datal)
3244 (- (gnus-data-pos data)
3245 (gnus-data-pos (cadr datal)))))
3246 (buffer-read-only nil)
3247 (level (gnus-summary-thread-level)))
3249 (gnus-summary-insert-line
3250 header level nil (gnus-article-mark article)
3251 (memq article gnus-newsgroup-replied)
3252 (memq article gnus-newsgroup-expirable)
3253 ;; Only insert the Subject string when it's different
3254 ;; from the previous Subject string.
3255 (if (gnus-subject-equal
3257 (mail-header-subject
3260 (gnus-data-find-list
3262 (gnus-data-list t)))))
3263 ;; Error on the side of excessive subjects.
3265 (mail-header-subject header))
3267 (mail-header-subject header))
3268 nil (cdr (assq article gnus-newsgroup-scored))
3269 (memq article gnus-newsgroup-processable))
3271 (gnus-data-update-list
3272 (cdr datal) (- length (- (gnus-data-pos data) (point))))))))
3274 (defun gnus-summary-update-article (article &optional iheader)
3275 "Update ARTICLE in the summary buffer."
3276 (set-buffer gnus-summary-buffer)
3277 (let* ((header (gnus-summary-article-header article))
3278 (id (mail-header-id header))
3279 (data (gnus-data-find article))
3280 (thread (gnus-id-to-thread id))
3281 (references (mail-header-references header))
3285 (when (and references
3286 (not (equal "" references)))
3289 (buffer-read-only nil)
3295 (delq thread parent)))
3296 (if (gnus-summary-insert-subject id header)
3297 ;; Set the (possibly) new article number in the data structure.
3298 (gnus-data-set-number data (gnus-id-to-article id))
3302 (defun gnus-rebuild-thread (id &optional line)
3303 "Rebuild the thread containing ID.
3304 If LINE, insert the rebuilt thread starting on line LINE."
3305 (let ((buffer-read-only nil)
3306 old-pos current thread data)
3307 (if (not gnus-show-threads)
3308 (setq thread (list (car (gnus-id-to-thread id))))
3309 ;; Get the thread this article is part of.
3310 (setq thread (gnus-remove-thread id)))
3311 (setq old-pos (gnus-point-at-bol))
3312 (setq current (save-excursion
3313 (and (zerop (forward-line -1))
3314 (gnus-summary-article-number))))
3315 ;; If this is a gathered thread, we have to go some re-gathering.
3316 (when (stringp (car thread))
3317 (let ((subject (car thread))
3319 (setq thread (cdr thread))
3321 (unless (memq (setq thr (gnus-id-to-thread
3323 (mail-header-id (caar thread)))))
3326 (setq thread (cdr thread)))
3327 ;; We now have all (unique) roots.
3328 (if (= (length roots) 1)
3329 ;; All the loose roots are now one solid root.
3330 (setq thread (car roots))
3331 (setq thread (cons subject (gnus-sort-threads roots))))))
3333 ;; We then insert this thread into the summary buffer.
3335 (goto-char (point-min))
3336 (forward-line (1- line)))
3337 (let (gnus-newsgroup-data gnus-newsgroup-threads)
3338 (if gnus-show-threads
3339 (gnus-summary-prepare-threads (gnus-cut-threads (list thread)))
3340 (gnus-summary-prepare-unthreaded thread))
3341 (setq data (nreverse gnus-newsgroup-data))
3342 (setq threads gnus-newsgroup-threads))
3343 ;; We splice the new data into the data structure.
3344 ;;!!! This is kinda bogus. We assume that in LINE is non-nil,
3345 ;;!!! then we want to insert at the beginning of the buffer.
3346 ;;!!! That happens to be true with Gnus now, but that may
3347 ;;!!! change in the future. Perhaps.
3348 (gnus-data-enter-list
3349 (if line nil current) data (- (point) old-pos))
3350 (setq gnus-newsgroup-threads
3351 (nconc threads gnus-newsgroup-threads))
3352 (gnus-data-compute-positions))))
3354 (defun gnus-number-to-header (number)
3355 "Return the header for article NUMBER."
3356 (let ((headers gnus-newsgroup-headers))
3358 (not (= number (mail-header-number (car headers)))))
3363 (defun gnus-parent-headers (in-headers &optional generation)
3364 "Return the headers of the GENERATIONeth parent of HEADERS."
3366 (setq generation 1))
3368 (headers in-headers)
3371 (not (zerop generation))
3372 (setq references (mail-header-references headers)))
3373 (setq headers (if (and references
3374 (setq parent (gnus-parent-id references)))
3375 (car (gnus-id-to-thread parent))
3378 (and (not (eq headers in-headers))
3381 (defun gnus-id-to-thread (id)
3382 "Return the (sub-)thread where ID appears."
3383 (gnus-gethash id gnus-newsgroup-dependencies))
3385 (defun gnus-id-to-article (id)
3386 "Return the article number of ID."
3387 (let ((thread (gnus-id-to-thread id)))
3390 (mail-header-number (car thread)))))
3392 (defun gnus-id-to-header (id)
3393 "Return the article headers of ID."
3394 (car (gnus-id-to-thread id)))
3396 (defun gnus-article-displayed-root-p (article)
3397 "Say whether ARTICLE is a root(ish) article."
3398 (let ((level (gnus-summary-thread-level article))
3399 (refs (mail-header-references (gnus-summary-article-header article)))
3405 ((null (gnus-parent-id refs)) t)
3407 (null (setq particle (gnus-id-to-article
3408 (gnus-parent-id refs))))
3409 (null (gnus-summary-thread-level particle)))))))
3411 (defun gnus-root-id (id)
3412 "Return the id of the root of the thread where ID appears."
3414 (while (and id (setq prev (car (gnus-id-to-thread id))))
3416 id (gnus-parent-id (mail-header-references prev))))
3419 (defun gnus-articles-in-thread (thread)
3420 "Return the list of articles in THREAD."
3421 (cons (mail-header-number (car thread))
3422 (apply 'nconc (mapcar 'gnus-articles-in-thread (cdr thread)))))
3424 (defun gnus-remove-thread (id &optional dont-remove)
3425 "Remove the thread that has ID in it."
3426 (let (headers thread last-id)
3427 ;; First go up in this thread until we find the root.
3428 (setq last-id (gnus-root-id id)
3429 headers (message-flatten-list (gnus-id-to-thread last-id)))
3430 ;; We have now found the real root of this thread. It might have
3431 ;; been gathered into some loose thread, so we have to search
3432 ;; through the threads to find the thread we wanted.
3433 (let ((threads gnus-newsgroup-threads)
3436 (setq sub (car threads))
3437 (if (stringp (car sub))
3438 ;; This is a gathered thread, so we look at the roots
3439 ;; below it to find whether this article is in this
3442 (setq sub (cdr sub))
3444 (when (member (caar sub) headers)
3445 (setq thread (car threads)
3448 (setq sub (cdr sub))))
3449 ;; It's an ordinary thread, so we check it.
3450 (when (eq (car sub) (car headers))
3453 (setq threads (cdr threads)))
3454 ;; If this article is in no thread, then it's a root.
3457 (setq gnus-newsgroup-threads (delq thread gnus-newsgroup-threads)))
3458 (setq thread (gnus-id-to-thread last-id)))
3461 thread ; We return this thread.
3463 (if (stringp (car thread))
3465 ;; If we use dummy roots, then we have to remove the
3466 ;; dummy root as well.
3467 (when (eq gnus-summary-make-false-root 'dummy)
3468 ;; We go to the dummy root by going to
3469 ;; the first sub-"thread", and then one line up.
3470 (gnus-summary-goto-article
3471 (mail-header-number (caadr thread)))
3474 (gnus-data-compute-positions))
3475 (setq thread (cdr thread))
3477 (gnus-remove-thread-1 (car thread))
3478 (setq thread (cdr thread))))
3479 (gnus-summary-show-all-threads)
3480 (gnus-remove-thread-1 thread))))))))
3482 (defun gnus-remove-thread-1 (thread)
3483 "Remove the thread THREAD recursively."
3484 (let ((number (mail-header-number (pop thread)))
3486 (setq thread (reverse thread))
3488 (gnus-remove-thread-1 (pop thread)))
3489 (when (setq d (gnus-data-find number))
3490 (goto-char (gnus-data-pos d))
3493 (- (gnus-point-at-bol)
3495 (1+ (gnus-point-at-eol))
3496 (gnus-delete-line)))))))
3498 (defun gnus-sort-threads (threads)
3500 (if (not gnus-thread-sort-functions)
3502 (gnus-message 8 "Sorting threads...")
3504 (sort threads (gnus-make-sort-function gnus-thread-sort-functions))
3505 (gnus-message 8 "Sorting threads...done"))))
3507 (defun gnus-sort-articles (articles)
3509 (when gnus-article-sort-functions
3510 (gnus-message 7 "Sorting articles...")
3512 (setq gnus-newsgroup-headers
3513 (sort articles (gnus-make-sort-function
3514 gnus-article-sort-functions)))
3515 (gnus-message 7 "Sorting articles...done"))))
3517 ;; Written by Hallvard B Furuseth <h.b.furuseth@usit.uio.no>.
3518 (defmacro gnus-thread-header (thread)
3519 ;; Return header of first article in THREAD.
3520 ;; Note that THREAD must never, ever be anything else than a variable -
3521 ;; using some other form will lead to serious barfage.
3522 (or (symbolp thread) (signal 'wrong-type-argument '(symbolp thread)))
3523 ;; (8% speedup to gnus-summary-prepare, just for fun :-)
3524 (list 'byte-code "\10\211:\203\17\0\211@;\203\16\0A@@\207" ;
3527 (defsubst gnus-article-sort-by-number (h1 h2)
3528 "Sort articles by article number."
3529 (< (mail-header-number h1)
3530 (mail-header-number h2)))
3532 (defun gnus-thread-sort-by-number (h1 h2)
3533 "Sort threads by root article number."
3534 (gnus-article-sort-by-number
3535 (gnus-thread-header h1) (gnus-thread-header h2)))
3537 (defsubst gnus-article-sort-by-lines (h1 h2)
3538 "Sort articles by article Lines header."
3539 (< (mail-header-lines h1)
3540 (mail-header-lines h2)))
3542 (defun gnus-thread-sort-by-lines (h1 h2)
3543 "Sort threads by root article Lines header."
3544 (gnus-article-sort-by-lines
3545 (gnus-thread-header h1) (gnus-thread-header h2)))
3547 (defsubst gnus-article-sort-by-author (h1 h2)
3548 "Sort articles by root author."
3550 (let ((addr (mime-read-field 'From h1)))
3551 (or (std11-full-name-string addr)
3552 (std11-address-string addr)
3554 (let ((addr (mime-read-field 'From h2)))
3555 (or (std11-full-name-string addr)
3556 (std11-address-string addr)
3560 (defun gnus-thread-sort-by-author (h1 h2)
3561 "Sort threads by root author."
3562 (gnus-article-sort-by-author
3563 (gnus-thread-header h1) (gnus-thread-header h2)))
3565 (defsubst gnus-article-sort-by-subject (h1 h2)
3566 "Sort articles by root subject."
3568 (downcase (gnus-simplify-subject-re (mail-header-subject h1)))
3569 (downcase (gnus-simplify-subject-re (mail-header-subject h2)))))
3571 (defun gnus-thread-sort-by-subject (h1 h2)
3572 "Sort threads by root subject."
3573 (gnus-article-sort-by-subject
3574 (gnus-thread-header h1) (gnus-thread-header h2)))
3576 (defsubst gnus-article-sort-by-date (h1 h2)
3577 "Sort articles by root article date."
3579 (gnus-date-get-time (mail-header-date h1))
3580 (gnus-date-get-time (mail-header-date h2))))
3582 (defun gnus-thread-sort-by-date (h1 h2)
3583 "Sort threads by root article date."
3584 (gnus-article-sort-by-date
3585 (gnus-thread-header h1) (gnus-thread-header h2)))
3587 (defsubst gnus-article-sort-by-score (h1 h2)
3588 "Sort articles by root article score.
3589 Unscored articles will be counted as having a score of zero."
3590 (> (or (cdr (assq (mail-header-number h1)
3591 gnus-newsgroup-scored))
3592 gnus-summary-default-score 0)
3593 (or (cdr (assq (mail-header-number h2)
3594 gnus-newsgroup-scored))
3595 gnus-summary-default-score 0)))
3597 (defun gnus-thread-sort-by-score (h1 h2)
3598 "Sort threads by root article score."
3599 (gnus-article-sort-by-score
3600 (gnus-thread-header h1) (gnus-thread-header h2)))
3602 (defun gnus-thread-sort-by-total-score (h1 h2)
3603 "Sort threads by the sum of all scores in the thread.
3604 Unscored articles will be counted as having a score of zero."
3605 (> (gnus-thread-total-score h1) (gnus-thread-total-score h2)))
3607 (defun gnus-thread-total-score (thread)
3608 ;; This function find the total score of THREAD.
3609 (cond ((null thread)
3612 (if (stringp (car thread))
3613 (apply gnus-thread-score-function 0
3614 (mapcar 'gnus-thread-total-score-1 (cdr thread)))
3615 (gnus-thread-total-score-1 thread)))
3617 (gnus-thread-total-score-1 (list thread)))))
3619 (defun gnus-thread-total-score-1 (root)
3620 ;; This function find the total score of the thread below ROOT.
3621 (setq root (car root))
3622 (apply gnus-thread-score-function
3624 (mapcar 'gnus-thread-total-score
3625 (cdr (gnus-id-to-thread (mail-header-id root))))
3626 (when (> (mail-header-number root) 0)
3627 (list (or (cdr (assq (mail-header-number root)
3628 gnus-newsgroup-scored))
3629 gnus-summary-default-score 0))))
3630 (list gnus-summary-default-score)
3633 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
3634 (defvar gnus-tmp-prev-subject nil)
3635 (defvar gnus-tmp-false-parent nil)
3636 (defvar gnus-tmp-root-expunged nil)
3637 (defvar gnus-tmp-dummy-line nil)
3639 (defvar gnus-tmp-header)
3640 (defun gnus-extra-header (type &optional header)
3641 "Return the extra header of TYPE."
3642 (or (cdr (assq type (mail-header-extra (or header gnus-tmp-header))))
3645 (defun gnus-summary-prepare-threads (threads)
3646 "Prepare summary buffer from THREADS and indentation LEVEL.
3647 THREADS is either a list of `(PARENT [(CHILD1 [(GRANDCHILD ...]...) ...])'
3648 or a straight list of headers."
3649 (gnus-message 7 "Generating summary...")
3651 (setq gnus-newsgroup-threads threads)
3654 (let ((gnus-tmp-level 0)
3655 (default-score (or gnus-summary-default-score 0))
3656 (gnus-visual-p (gnus-visual-p 'summary-highlight 'highlight))
3657 thread number subject stack state gnus-tmp-gathered beg-match
3658 new-roots gnus-tmp-new-adopts thread-end
3659 gnus-tmp-header gnus-tmp-unread
3660 gnus-tmp-replied gnus-tmp-subject-or-nil
3661 gnus-tmp-dummy gnus-tmp-indentation gnus-tmp-lines gnus-tmp-score
3662 gnus-tmp-score-char gnus-tmp-from gnus-tmp-name
3663 gnus-tmp-number gnus-tmp-opening-bracket gnus-tmp-closing-bracket)
3665 (setq gnus-tmp-prev-subject nil)
3667 (if (vectorp (car threads))
3668 ;; If this is a straight (sic) list of headers, then a
3669 ;; threaded summary display isn't required, so we just create
3670 ;; an unthreaded one.
3671 (gnus-summary-prepare-unthreaded threads)
3673 ;; Do the threaded display.
3675 (while (or threads stack gnus-tmp-new-adopts new-roots)
3677 (if (and (= gnus-tmp-level 0)
3680 (not gnus-tmp-false-parent)
3681 (or gnus-tmp-new-adopts new-roots))
3682 (if gnus-tmp-new-adopts
3683 (setq gnus-tmp-level (if gnus-tmp-root-expunged 0 1)
3684 thread (list (car gnus-tmp-new-adopts))
3685 gnus-tmp-header (caar thread)
3686 gnus-tmp-new-adopts (cdr gnus-tmp-new-adopts))
3688 (setq thread (list (car new-roots))
3689 gnus-tmp-header (caar thread)
3690 new-roots (cdr new-roots))))
3693 ;; If there are some threads, we do them before the
3694 ;; threads on the stack.
3695 (setq thread threads
3696 gnus-tmp-header (caar thread))
3697 ;; There were no current threads, so we pop something off
3699 (setq state (car stack)
3700 gnus-tmp-level (car state)
3703 gnus-tmp-header (caar thread))))
3705 (setq gnus-tmp-false-parent nil)
3706 (setq gnus-tmp-root-expunged nil)
3707 (setq thread-end nil)
3709 (if (stringp gnus-tmp-header)
3710 ;; The header is a dummy root.
3712 ((eq gnus-summary-make-false-root 'adopt)
3713 ;; We let the first article adopt the rest.
3714 (setq gnus-tmp-new-adopts (nconc gnus-tmp-new-adopts
3716 (setq gnus-tmp-gathered
3718 (lambda (h) (mail-header-number (car h)))
3721 (setq thread (cons (list (caar thread)
3724 (setq gnus-tmp-level -1
3725 gnus-tmp-false-parent t))
3726 ((eq gnus-summary-make-false-root 'empty)
3727 ;; We print adopted articles with empty subject fields.
3728 (setq gnus-tmp-gathered
3730 (lambda (h) (mail-header-number (car h)))
3733 (setq gnus-tmp-level -1))
3734 ((eq gnus-summary-make-false-root 'dummy)
3735 ;; We remember that we probably want to output a dummy
3737 (setq gnus-tmp-dummy-line gnus-tmp-header)
3738 (setq gnus-tmp-prev-subject gnus-tmp-header))
3740 ;; We do not make a root for the gathered
3741 ;; sub-threads at all.
3742 (setq gnus-tmp-level -1)))
3744 (setq number (mail-header-number gnus-tmp-header)
3745 subject (mail-header-subject gnus-tmp-header))
3748 ;; If the thread has changed subject, we might want to make
3749 ;; this subthread into a root.
3750 ((and (null gnus-thread-ignore-subject)
3751 (not (zerop gnus-tmp-level))
3752 gnus-tmp-prev-subject
3754 (gnus-subject-equal gnus-tmp-prev-subject subject))))
3755 (setq new-roots (nconc new-roots (list (car thread)))
3757 gnus-tmp-header nil))
3758 ;; If the article lies outside the current limit,
3759 ;; then we do not display it.
3760 ((not (memq number gnus-newsgroup-limit))
3761 (setq gnus-tmp-gathered
3763 (lambda (h) (mail-header-number (car h)))
3766 (setq gnus-tmp-new-adopts (if (cdar thread)
3767 (append gnus-tmp-new-adopts
3769 gnus-tmp-new-adopts)
3771 gnus-tmp-header nil)
3772 (when (zerop gnus-tmp-level)
3773 (setq gnus-tmp-root-expunged t)))
3774 ;; Perhaps this article is to be marked as read?
3775 ((and gnus-summary-mark-below
3776 (< (or (cdr (assq number gnus-newsgroup-scored))
3778 gnus-summary-mark-below)
3779 ;; Don't touch sparse articles.
3780 (not (gnus-summary-article-sparse-p number))
3781 (not (gnus-summary-article-ancient-p number)))
3782 (setq gnus-newsgroup-unreads
3783 (delq number gnus-newsgroup-unreads))
3784 (if gnus-newsgroup-auto-expire
3785 (push number gnus-newsgroup-expirable)
3786 (push (cons number gnus-low-score-mark)
3787 gnus-newsgroup-reads))))
3789 (when gnus-tmp-header
3790 ;; We may have an old dummy line to output before this
3792 (when (and gnus-tmp-dummy-line
3795 (mail-header-subject gnus-tmp-header)))
3796 (gnus-summary-insert-dummy-line
3797 gnus-tmp-dummy-line (mail-header-number gnus-tmp-header))
3798 (setq gnus-tmp-dummy-line nil))
3800 ;; Compute the mark.
3801 (setq gnus-tmp-unread (gnus-article-mark number))
3803 (push (gnus-data-make number gnus-tmp-unread (1+ (point))
3804 gnus-tmp-header gnus-tmp-level)
3805 gnus-newsgroup-data)
3807 ;; Actually insert the line.
3809 gnus-tmp-subject-or-nil
3811 ((and gnus-thread-ignore-subject
3812 gnus-tmp-prev-subject
3813 (not (inline (gnus-subject-equal
3814 gnus-tmp-prev-subject subject))))
3816 ((zerop gnus-tmp-level)
3817 (if (and (eq gnus-summary-make-false-root 'empty)
3818 (memq number gnus-tmp-gathered)
3819 gnus-tmp-prev-subject
3820 (inline (gnus-subject-equal
3821 gnus-tmp-prev-subject subject)))
3822 gnus-summary-same-subject
3824 (t gnus-summary-same-subject)))
3825 (if (and (eq gnus-summary-make-false-root 'adopt)
3826 (= gnus-tmp-level 1)
3827 (memq number gnus-tmp-gathered))
3828 (setq gnus-tmp-opening-bracket ?\<
3829 gnus-tmp-closing-bracket ?\>)
3830 (setq gnus-tmp-opening-bracket ?\[
3831 gnus-tmp-closing-bracket ?\]))
3833 gnus-tmp-indentation
3834 (aref gnus-thread-indent-array gnus-tmp-level)
3835 gnus-tmp-lines (mail-header-lines gnus-tmp-header)
3836 gnus-tmp-score (or (cdr (assq number gnus-newsgroup-scored))
3837 gnus-summary-default-score 0)
3839 (if (or (null gnus-summary-default-score)
3840 (<= (abs (- gnus-tmp-score gnus-summary-default-score))
3841 gnus-summary-zcore-fuzz))
3843 (if (< gnus-tmp-score gnus-summary-default-score)
3844 gnus-score-below-mark gnus-score-over-mark))
3846 (cond ((memq number gnus-newsgroup-processable)
3848 ((memq number gnus-newsgroup-cached)
3850 ((memq number gnus-newsgroup-replied)
3852 ((memq number gnus-newsgroup-saved)
3854 (t gnus-unread-mark))
3855 gnus-tmp-from (mail-header-from gnus-tmp-header)
3858 ((string-match "<[^>]+> *$" gnus-tmp-from)
3859 (setq beg-match (match-beginning 0))
3860 (or (and (string-match "^\"[^\"]*\"" gnus-tmp-from)
3861 (substring gnus-tmp-from (1+ (match-beginning 0))
3862 (1- (match-end 0))))
3863 (substring gnus-tmp-from 0 beg-match)))
3864 ((string-match "(.+)" gnus-tmp-from)
3865 (substring gnus-tmp-from
3866 (1+ (match-beginning 0)) (1- (match-end 0))))
3868 (when (string= gnus-tmp-name "")
3869 (setq gnus-tmp-name gnus-tmp-from))
3870 (unless (numberp gnus-tmp-lines)
3871 (setq gnus-tmp-lines 0))
3872 (gnus-put-text-property
3874 (progn (eval gnus-summary-line-format-spec) (point))
3875 'gnus-number number)
3878 (gnus-run-hooks 'gnus-summary-update-hook)
3881 (setq gnus-tmp-prev-subject subject)))
3883 (when (nth 1 thread)
3884 (push (cons (max 0 gnus-tmp-level) (nthcdr 1 thread)) stack))
3885 (incf gnus-tmp-level)
3886 (setq threads (if thread-end nil (cdar thread)))
3888 (setq gnus-tmp-level 0)))))
3889 (gnus-message 7 "Generating summary...done"))
3891 (defun gnus-summary-prepare-unthreaded (headers)
3892 "Generate an unthreaded summary buffer based on HEADERS."
3893 (let (header number mark)
3898 ;; We may have to root out some bad articles...
3899 (when (memq (setq number (mail-header-number
3900 (setq header (pop headers))))
3901 gnus-newsgroup-limit)
3902 ;; Mark article as read when it has a low score.
3903 (when (and gnus-summary-mark-below
3904 (< (or (cdr (assq number gnus-newsgroup-scored))
3905 gnus-summary-default-score 0)
3906 gnus-summary-mark-below)
3907 (not (gnus-summary-article-ancient-p number)))
3908 (setq gnus-newsgroup-unreads
3909 (delq number gnus-newsgroup-unreads))
3910 (if gnus-newsgroup-auto-expire
3911 (push number gnus-newsgroup-expirable)
3912 (push (cons number gnus-low-score-mark)
3913 gnus-newsgroup-reads)))
3915 (setq mark (gnus-article-mark number))
3916 (push (gnus-data-make number mark (1+ (point)) header 0)
3917 gnus-newsgroup-data)
3918 (gnus-summary-insert-line
3920 mark (memq number gnus-newsgroup-replied)
3921 (memq number gnus-newsgroup-expirable)
3922 (mail-header-subject header) nil
3923 (cdr (assq number gnus-newsgroup-scored))
3924 (memq number gnus-newsgroup-processable))))))
3926 (defun gnus-select-newsgroup (group &optional read-all select-articles)
3927 "Select newsgroup GROUP.
3928 If READ-ALL is non-nil, all articles in the group are selected.
3929 If SELECT-ARTICLES, only select those articles from GROUP."
3930 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
3931 ;;!!! Dirty hack; should be removed.
3932 (gnus-summary-ignore-duplicates
3933 (if (eq (car (gnus-find-method-for-group group)) 'nnvirtual)
3935 gnus-summary-ignore-duplicates))
3936 (info (nth 2 entry))
3937 articles fetched-articles cached)
3939 (unless (gnus-check-server
3940 (setq gnus-current-select-method
3941 (gnus-find-method-for-group group)))
3942 (error "Couldn't open server"))
3944 (or (and entry (not (eq (car entry) t))) ; Either it's active...
3945 (gnus-activate-group group) ; Or we can activate it...
3946 (progn ; Or we bug out.
3947 (when (equal major-mode 'gnus-summary-mode)
3948 (kill-buffer (current-buffer)))
3949 (error "Couldn't request group %s: %s"
3950 group (gnus-status-message group))))
3952 (unless (gnus-request-group group t)
3953 (when (equal major-mode 'gnus-summary-mode)
3954 (kill-buffer (current-buffer)))
3955 (error "Couldn't request group %s: %s"
3956 group (gnus-status-message group)))
3958 (setq gnus-newsgroup-name group)
3959 (setq gnus-newsgroup-unselected nil)
3960 (setq gnus-newsgroup-unreads (gnus-list-of-unread-articles group))
3961 (gnus-summary-setup-default-charset)
3963 ;; Adjust and set lists of article marks.
3965 (gnus-adjust-marked-articles info))
3967 ;; Kludge to avoid having cached articles nixed out in virtual groups.
3968 (when (gnus-virtual-group-p group)
3969 (setq cached gnus-newsgroup-cached))
3971 (setq gnus-newsgroup-unreads
3972 (gnus-set-difference
3973 (gnus-set-difference gnus-newsgroup-unreads gnus-newsgroup-marked)
3974 gnus-newsgroup-dormant))
3976 (setq gnus-newsgroup-processable nil)
3978 (gnus-update-read-articles group gnus-newsgroup-unreads)
3980 (if (setq articles select-articles)
3981 (setq gnus-newsgroup-unselected
3982 (gnus-sorted-intersection
3983 gnus-newsgroup-unreads
3984 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
3985 (setq articles (gnus-articles-to-read group read-all)))
3989 ;;(gnus-message 3 "Couldn't select newsgroup -- no articles to display")
3991 ((eq articles 0) nil)
3993 ;; Init the dependencies hash table.
3994 (setq gnus-newsgroup-dependencies
3995 (gnus-make-hashtable (length articles)))
3996 (gnus-set-global-variables)
3997 ;; Retrieve the headers and read them in.
3998 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
3999 (setq gnus-newsgroup-headers
4000 (gnus-retrieve-parsed-headers
4001 articles gnus-newsgroup-name
4002 ;; We might want to fetch old headers, but
4003 ;; not if there is only 1 article.
4004 (and (or (and (not (eq gnus-fetch-old-headers 'some))
4005 (not (numberp gnus-fetch-old-headers)))
4006 (> (length articles) 1))
4007 gnus-fetch-old-headers)))
4008 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name)
4010 ;; Kludge to avoid having cached articles nixed out in virtual groups.
4012 (setq gnus-newsgroup-cached cached))
4014 ;; Suppress duplicates?
4015 (when gnus-suppress-duplicates
4016 (gnus-dup-suppress-articles))
4018 ;; Set the initial limit.
4019 (setq gnus-newsgroup-limit (copy-sequence articles))
4020 ;; Remove canceled articles from the list of unread articles.
4021 (setq gnus-newsgroup-unreads
4022 (gnus-set-sorted-intersection
4023 gnus-newsgroup-unreads
4024 (setq fetched-articles
4025 (mapcar (lambda (headers) (mail-header-number headers))
4026 gnus-newsgroup-headers))))
4027 ;; Removed marked articles that do not exist.
4028 (gnus-update-missing-marks
4029 (gnus-sorted-complement fetched-articles articles))
4030 ;; We might want to build some more threads first.
4031 (when (and gnus-fetch-old-headers
4032 (eq gnus-headers-retrieved-by 'nov))
4033 (if (eq gnus-fetch-old-headers 'invisible)
4034 (gnus-build-all-threads)
4035 (gnus-build-old-threads)))
4036 ;; Let the Gnus agent mark articles as read.
4038 (gnus-agent-get-undownloaded-list))
4039 ;; Check whether auto-expire is to be done in this group.
4040 (setq gnus-newsgroup-auto-expire
4041 (gnus-group-auto-expirable-p group))
4042 ;; Set up the article buffer now, if necessary.
4043 (unless gnus-single-article-buffer
4044 (gnus-article-setup-buffer))
4045 ;; First and last article in this newsgroup.
4046 (when gnus-newsgroup-headers
4047 (setq gnus-newsgroup-begin
4048 (mail-header-number (car gnus-newsgroup-headers))
4051 (gnus-last-element gnus-newsgroup-headers))))
4052 ;; GROUP is successfully selected.
4053 (or gnus-newsgroup-headers t)))))
4055 (defun gnus-articles-to-read (group &optional read-all)
4056 ;; Find out what articles the user wants to read.
4058 ;; Select all articles if `read-all' is non-nil, or if there
4059 ;; are no unread articles.
4061 (and (zerop (length gnus-newsgroup-marked))
4062 (zerop (length gnus-newsgroup-unreads)))
4063 (eq (gnus-group-find-parameter group 'display)
4065 (gnus-uncompress-range (gnus-active group))
4066 (sort (append gnus-newsgroup-dormant gnus-newsgroup-marked
4067 (copy-sequence gnus-newsgroup-unreads))
4069 (scored-list (gnus-killed-articles gnus-newsgroup-killed articles))
4070 (scored (length scored-list))
4071 (number (length articles))
4072 (marked (+ (length gnus-newsgroup-marked)
4073 (length gnus-newsgroup-dormant)))
4081 ((and (or (<= scored marked) (= scored number))
4082 (natnump gnus-large-newsgroup)
4083 (> number gnus-large-newsgroup))
4084 (let* ((minibuffer-setup-hook (append
4085 minibuffer-setup-hook
4086 '(beginning-of-line)))
4089 "How many articles from %s (max %d): "
4090 (gnus-limit-string gnus-newsgroup-name 35)
4092 (number-to-string gnus-large-newsgroup))))
4093 (if (string-match "^[ \t]*$" input)
4096 ((and (> scored marked) (< scored number)
4097 (> (- scored number) 20))
4100 (format "%s %s (%d scored, %d total): "
4101 "How many articles from"
4102 group scored number))))
4103 (if (string-match "^[ \t]*$" input)
4107 (setq select (if (stringp select) (string-to-number select) select))
4108 (if (or (null select) (zerop select))
4110 (if (and (not (zerop scored)) (<= (abs select) scored))
4112 (setq articles (sort scored-list '<))
4113 (setq number (length articles)))
4114 (setq articles (copy-sequence articles)))
4116 (when (< (abs select) number)
4118 ;; Select the N oldest articles.
4119 (setcdr (nthcdr (1- (abs select)) articles) nil)
4120 ;; Select the N most recent articles.
4121 (setq articles (nthcdr (- number select) articles))))
4122 (setq gnus-newsgroup-unselected
4123 (gnus-sorted-intersection
4124 gnus-newsgroup-unreads
4125 (gnus-sorted-complement gnus-newsgroup-unreads articles)))
4128 (defun gnus-killed-articles (killed articles)
4131 (when (inline (gnus-member-of-range (car articles) killed))
4132 (push (car articles) out))
4133 (setq articles (cdr articles)))
4136 (defun gnus-uncompress-marks (marks)
4137 "Uncompress the mark ranges in MARKS."
4138 (let ((uncompressed '(score bookmark))
4141 (if (memq (caar marks) uncompressed)
4142 (push (car marks) out)
4143 (push (cons (caar marks) (gnus-uncompress-range (cdar marks))) out))
4144 (setq marks (cdr marks)))
4147 (defun gnus-adjust-marked-articles (info)
4148 "Set all article lists and remove all marks that are no longer valid."
4149 (let* ((marked-lists (gnus-info-marks info))
4150 (active (gnus-active (gnus-info-group info)))
4153 (types gnus-article-mark-lists)
4154 (uncompressed '(score bookmark killed))
4155 marks var articles article mark)
4158 (setq marks (pop marked-lists))
4159 (set (setq var (intern (format "gnus-newsgroup-%s"
4160 (car (rassq (setq mark (car marks))
4162 (if (memq (car marks) uncompressed) (cdr marks)
4163 (gnus-uncompress-range (cdr marks))))
4165 (setq articles (symbol-value var))
4167 ;; All articles have to be subsets of the active articles.
4169 ;; Adjust "simple" lists.
4170 ((memq mark '(tick dormant expire reply save))
4172 (when (or (< (setq article (pop articles)) min) (> article max))
4173 (set var (delq article (symbol-value var))))))
4175 ((memq mark uncompressed)
4176 (when (not (listp (cdr (symbol-value var))))
4177 (set var (list (symbol-value var))))
4178 (when (not (listp (cdr articles)))
4179 (setq articles (list articles)))
4181 (when (or (not (consp (setq article (pop articles))))
4182 (< (car article) min)
4183 (> (car article) max))
4184 (set var (delq article (symbol-value var))))))))))
4186 (defun gnus-update-missing-marks (missing)
4187 "Go through the list of MISSING articles and remove them from the mark lists."
4189 (let ((types gnus-article-mark-lists)
4191 ;; Go through all types.
4193 (setq var (intern (format "gnus-newsgroup-%s" (car (pop types)))))
4194 (when (symbol-value var)
4195 ;; This list has articles. So we delete all missing articles
4199 (set var (delq (pop m) (symbol-value var)))))))))
4201 (defun gnus-update-marks ()
4202 "Enter the various lists of marked articles into the newsgroup info list."
4203 (let ((types gnus-article-mark-lists)
4204 (info (gnus-get-info gnus-newsgroup-name))
4205 (uncompressed '(score bookmark killed))
4206 type list newmarked symbol delta-marks)
4208 ;; Add all marks lists that are non-nil to the list of marks lists.
4209 (while (setq type (pop types))
4210 (when (setq list (symbol-value
4212 (intern (format "gnus-newsgroup-%s"
4215 ;; Get rid of the entries of the articles that have the
4217 (when (and (eq (cdr type) 'score)
4221 (prev (cons nil list))
4224 (if (or (not (consp (car arts)))
4225 (= (cdar arts) gnus-summary-default-score))
4226 (setcdr prev (cdr arts))
4228 (setq arts (cdr arts)))
4229 (setq list (cdr all))))
4231 (when (gnus-check-backend-function 'request-set-mark
4232 gnus-newsgroup-name)
4233 ;; score & bookmark are not proper flags (they are cons cells)
4234 ;; cache is a internal gnus flag
4235 (unless (memq (cdr type) '(cache score bookmark))
4236 (let* ((old (cdr (assq (cdr type) (gnus-info-marks info))))
4237 (del (gnus-remove-from-range old list))
4238 (add (gnus-remove-from-range list old)))
4240 (push (list add 'add (list (cdr type))) delta-marks))
4242 (push (list del 'del (list (cdr type))) delta-marks)))))
4244 (push (cons (cdr type)
4245 (if (memq (cdr type) uncompressed) list
4246 (gnus-compress-sequence
4247 (set symbol (sort list '<)) t)))
4251 (gnus-request-set-mark gnus-newsgroup-name delta-marks))
4253 ;; Enter these new marks into the info of the group.
4255 (setcar (nthcdr 3 info) newmarked)
4256 ;; Add the marks lists to the end of the info.
4258 (setcdr (nthcdr 2 info) (list newmarked))))
4260 ;; Cut off the end of the info if there's nothing else there.
4264 (when (nthcdr (decf i) info)
4265 (setcdr (nthcdr i info) nil)))))))
4267 (defun gnus-set-mode-line (where)
4268 "This function sets the mode line of the article or summary buffers.
4269 If WHERE is `summary', the summary mode line format will be used."
4270 ;; Is this mode line one we keep updated?
4271 (when (and (memq where gnus-updated-mode-lines)
4273 (intern (format "gnus-%s-mode-line-format-spec" where))))
4276 ;; We evaluate this in the summary buffer since these
4277 ;; variables are buffer-local to that buffer.
4278 (set-buffer gnus-summary-buffer)
4279 ;; We bind all these variables that are used in the `eval' form
4281 (let* ((mformat (symbol-value
4283 (format "gnus-%s-mode-line-format-spec" where))))
4284 (gnus-tmp-group-name gnus-newsgroup-name)
4285 (gnus-tmp-article-number (or gnus-current-article 0))
4286 (gnus-tmp-unread gnus-newsgroup-unreads)
4287 (gnus-tmp-unread-and-unticked (length gnus-newsgroup-unreads))
4288 (gnus-tmp-unselected (length gnus-newsgroup-unselected))
4289 (gnus-tmp-unread-and-unselected
4290 (cond ((and (zerop gnus-tmp-unread-and-unticked)
4291 (zerop gnus-tmp-unselected))
4293 ((zerop gnus-tmp-unselected)
4294 (format "{%d more}" gnus-tmp-unread-and-unticked))
4295 (t (format "{%d(+%d) more}"
4296 gnus-tmp-unread-and-unticked
4297 gnus-tmp-unselected))))
4299 (if (and gnus-current-headers
4300 (vectorp gnus-current-headers))
4301 (gnus-mode-string-quote
4302 (mail-header-subject gnus-current-headers))
4304 bufname-length max-len
4305 gnus-tmp-header);; passed as argument to any user-format-funcs
4306 (setq mode-string (eval mformat))
4307 (setq bufname-length (if (string-match "%b" mode-string)
4310 (if (eq where 'summary)
4312 (get-buffer gnus-article-buffer))))
4315 (setq max-len (max 4 (if gnus-mode-non-string-length
4317 gnus-mode-non-string-length
4319 (length mode-string))))
4320 ;; We might have to chop a bit of the string off...
4321 (when (> (length mode-string) max-len)
4323 (concat (gnus-truncate-string mode-string (- max-len 3))
4325 ;; Pad the mode string a bit.
4326 (setq mode-string (format (format "%%-%ds" max-len) mode-string))))
4327 ;; Update the mode line.
4328 (setq mode-line-buffer-identification
4329 (gnus-mode-line-buffer-identification (list mode-string)))
4330 (set-buffer-modified-p t))))
4332 (defun gnus-create-xref-hashtb (from-newsgroup headers unreads)
4333 "Go through the HEADERS list and add all Xrefs to a hash table.
4334 The resulting hash table is returned, or nil if no Xrefs were found."
4335 (let* ((virtual (gnus-virtual-group-p from-newsgroup))
4336 (prefix (if virtual "" (gnus-group-real-prefix from-newsgroup)))
4337 (xref-hashtb (gnus-make-hashtable))
4338 start group entry number xrefs header)
4340 (setq header (pop headers))
4341 (when (and (setq xrefs (mail-header-xref header))
4342 (not (memq (setq number (mail-header-number header))
4345 (while (string-match "\\([^ ]+\\)[:/]\\([0-9]+\\)" xrefs start)
4346 (setq start (match-end 0))
4347 (setq group (if prefix
4348 (concat prefix (substring xrefs (match-beginning 1)
4350 (substring xrefs (match-beginning 1) (match-end 1))))
4352 (string-to-int (substring xrefs (match-beginning 2)
4354 (if (setq entry (gnus-gethash group xref-hashtb))
4355 (setcdr entry (cons number (cdr entry)))
4356 (gnus-sethash group (cons number nil) xref-hashtb)))))
4357 (and start xref-hashtb)))
4359 (defun gnus-mark-xrefs-as-read (from-newsgroup headers unreads)
4360 "Look through all the headers and mark the Xrefs as read."
4361 (let ((virtual (gnus-virtual-group-p from-newsgroup))
4362 name entry info xref-hashtb idlist method nth4)
4364 (set-buffer gnus-group-buffer)
4365 (when (setq xref-hashtb
4366 (gnus-create-xref-hashtb from-newsgroup headers unreads))
4369 (unless (string= from-newsgroup (setq name (symbol-name group)))
4370 (setq idlist (symbol-value group))
4371 ;; Dead groups are not updated.
4373 (setq entry (gnus-gethash name gnus-newsrc-hashtb)
4375 (when (stringp (setq nth4 (gnus-info-method info)))
4376 (setq nth4 (gnus-server-to-method nth4))))
4377 ;; Only do the xrefs if the group has the same
4378 ;; select method as the group we have just read.
4379 (or (gnus-methods-equal-p
4380 nth4 (gnus-find-method-for-group from-newsgroup))
4382 (equal nth4 (setq method (gnus-find-method-for-group
4384 (and (equal (car nth4) (car method))
4385 (equal (nth 1 nth4) (nth 1 method))))
4386 gnus-use-cross-reference
4387 (or (not (eq gnus-use-cross-reference t))
4389 ;; Only do cross-references on subscribed
4390 ;; groups, if that is what is wanted.
4391 (<= (gnus-info-level info) gnus-level-subscribed))
4392 (gnus-group-make-articles-read name idlist))))
4395 (defun gnus-compute-read-articles (group articles)
4396 (let* ((entry (gnus-gethash group gnus-newsrc-hashtb))
4397 (info (nth 2 entry))
4398 (active (gnus-active group))
4401 ;; First peel off all invalid article numbers.
4403 (let ((ids articles)
4405 (while (setq id (pop ids))
4406 (when (and first (> id (cdr active)))
4407 ;; We'll end up in this situation in one particular
4408 ;; obscure situation. If you re-scan a group and get
4409 ;; a new article that is cross-posted to a different
4410 ;; group that has not been re-scanned, you might get
4411 ;; crossposted article that has a higher number than
4412 ;; Gnus believes possible. So we re-activate this
4413 ;; group as well. This might mean doing the
4414 ;; crossposting thingy will *increase* the number
4415 ;; of articles in some groups. Tsk, tsk.
4416 (setq active (or (gnus-activate-group group) active)))
4417 (when (or (> id (cdr active))
4418 (< id (car active)))
4419 (setq articles (delq id articles))))))
4420 ;; If the read list is nil, we init it.
4422 (null (gnus-info-read info))
4424 (setq ninfo (cons 1 (1- (car active))))
4425 (setq ninfo (gnus-info-read info)))
4426 ;; Then we add the read articles to the range.
4428 ninfo (setq articles (sort articles '<))))))
4430 (defun gnus-group-make-articles-read (group articles)
4431 "Update the info of GROUP to say that ARTICLES are read."
4433 (entry (gnus-gethash group gnus-newsrc-hashtb))
4434 (info (nth 2 entry))
4435 (active (gnus-active group))
4438 (setq range (gnus-compute-read-articles group articles))
4440 (set-buffer gnus-group-buffer)
4443 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
4444 (gnus-info-set-read ',info ',(gnus-info-read info))
4445 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
4446 (gnus-group-update-group ,group t))))
4447 ;; Add the read articles to the range.
4448 (gnus-info-set-read info range)
4449 ;; Then we have to re-compute how many unread
4450 ;; articles there are in this group.
4454 (setq num (- (1+ (cdr active)) (car active))))
4455 ((not (listp (cdr range)))
4456 (setq num (- (cdr active) (- (1+ (cdr range))
4460 (if (numberp (car range))
4462 (setq num (+ num (- (1+ (cdar range)) (caar range)))))
4463 (setq range (cdr range)))
4464 (setq num (- (cdr active) num))))
4465 ;; Update the number of unread articles.
4467 ;; Update the group buffer.
4468 (gnus-group-update-group group t)))))
4470 (defun gnus-methods-equal-p (m1 m2)
4471 (let ((m1 (or m1 gnus-select-method))
4472 (m2 (or m2 gnus-select-method)))
4474 (and (eq (car m1) (car m2))
4475 (or (not (memq 'address (assoc (symbol-name (car m1))
4476 gnus-valid-select-methods)))
4477 (equal (nth 1 m1) (nth 1 m2)))))))
4479 (defvar gnus-newsgroup-none-id 0)
4481 (defun gnus-get-newsgroup-headers (&optional dependencies force-new)
4482 (let ((cur nntp-server-buffer)
4485 (save-excursion (set-buffer gnus-summary-buffer)
4486 gnus-newsgroup-dependencies)))
4488 (mail-parse-charset gnus-newsgroup-charset))
4490 (set-buffer nntp-server-buffer)
4491 ;; Translate all TAB characters into SPACE characters.
4492 (subst-char-in-region (point-min) (point-max) ?\t ? t)
4493 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4494 (gnus-run-hooks 'gnus-parse-headers-hook)
4495 (let ((case-fold-search t)
4496 in-reply-to header p lines chars ctype)
4497 (goto-char (point-min))
4498 ;; Search to the beginning of the next header. Error messages
4499 ;; do not begin with 2 or 3.
4500 (while (re-search-forward "^[23][0-9]+ " nil t)
4503 ;; This implementation of this function, with nine
4504 ;; search-forwards instead of the one re-search-forward and
4505 ;; a case (which basically was the old function) is actually
4506 ;; about twice as fast, even though it looks messier. You
4507 ;; can't have everything, I guess. Speed and elegance
4508 ;; doesn't always go hand in hand.
4511 (make-full-mail-header
4517 (narrow-to-region (point)
4518 (or (and (search-forward "\n.\n" nil t)
4524 (if (search-forward "\nsubject: " nil t)
4525 (buffer-substring (match-end 0) (std11-field-end))
4530 (if (search-forward "\nfrom: " nil t)
4531 (buffer-substring (match-end 0) (std11-field-end))
4536 (if (search-forward "\ndate: " nil t)
4537 (buffer-substring (match-end 0) (std11-field-end))
4542 (setq id (if (re-search-forward
4543 "^message-id: *\\(<[^\n\t> ]+>\\)" nil t)
4544 ;; We do it this way to make sure the Message-ID
4545 ;; is (somewhat) syntactically valid.
4546 (buffer-substring (match-beginning 1)
4548 ;; If there was no message-id, we just fake one
4549 ;; to make subsequent routines simpler.
4550 (nnheader-generate-fake-message-id))))
4554 (if (search-forward "\nreferences: " nil t)
4558 (buffer-substring (match-end 0) (std11-field-end))
4563 (search-backward ">" end t)
4566 (search-backward "<" end t)
4568 ;; Get the references from the in-reply-to header if there
4569 ;; were no references and the in-reply-to header looks
4571 (if (and (search-forward "\nin-reply-to: " nil t)
4573 (buffer-substring (match-end 0)
4575 (string-match "<[^>]+>" in-reply-to))
4577 (setq ref (substring in-reply-to (match-beginning 0)
4579 (while (string-match "<[^>]+>" in-reply-to (match-end 0))
4580 (setq ref2 (substring in-reply-to (match-beginning 0)
4582 (when (> (length ref2) (length ref))
4589 (if (search-forward "\nchars: " nil t)
4590 (if (numberp (setq chars (ignore-errors (read cur))))
4596 (if (search-forward "\nlines: " nil t)
4597 (if (numberp (setq lines (ignore-errors (read cur))))
4603 (and (search-forward "\nxref: " nil t)
4604 (buffer-substring (match-end 0) (std11-field-end))))
4606 (when gnus-extra-headers
4607 (let ((extra gnus-extra-headers)
4611 (when (search-forward
4612 (concat "\n" (symbol-name (car extra)) ": ") nil t)
4613 (push (cons (car extra)
4614 (buffer-substring (match-end 0)
4620 (if (and (search-forward "\ncontent-type: " nil t)
4622 (buffer-substring (match-end 0) (std11-field-end))))
4623 (mime-entity-set-content-type-internal
4624 header (mime-parse-Content-Type ctype)))
4625 (when (equal id ref)
4628 (when gnus-alter-header-function
4629 (funcall gnus-alter-header-function header)
4630 (setq id (mail-header-id header)
4631 ref (gnus-parent-id (mail-header-references header))))
4634 (gnus-dependencies-add-header
4635 header dependencies force-new))
4636 (push header headers))
4637 (goto-char (point-max))
4639 (nreverse headers)))))
4641 ;; Goes through the xover lines and returns a list of vectors
4642 (defun gnus-get-newsgroup-headers-xover (sequence &optional
4643 force-new dependencies
4644 group also-fetch-heads)
4645 "Parse the news overview data in the server buffer, and return a
4646 list of headers that match SEQUENCE (see `nntp-retrieve-headers')."
4647 ;; Get the Xref when the users reads the articles since most/some
4648 ;; NNTP servers do not include Xrefs when using XOVER.
4649 (setq gnus-article-internal-prepare-hook '(gnus-article-get-xrefs))
4650 (let ((mail-parse-charset gnus-newsgroup-charset)
4651 (cur nntp-server-buffer)
4652 (dependencies (or dependencies gnus-newsgroup-dependencies))
4653 number headers header)
4655 (set-buffer nntp-server-buffer)
4656 (subst-char-in-region (point-min) (point-max) ?\r ? t)
4657 ;; Allow the user to mangle the headers before parsing them.
4658 (gnus-run-hooks 'gnus-parse-headers-hook)
4659 (goto-char (point-min))
4662 (while (and sequence (not (eobp)))
4663 (setq number (read cur))
4664 (while (and sequence
4665 (< (car sequence) number))
4666 (setq sequence (cdr sequence)))
4668 (eq number (car sequence))
4670 (setq sequence (cdr sequence))
4671 (setq header (inline
4672 (gnus-nov-parse-line
4673 number dependencies force-new))))
4674 (push header headers))
4677 (gnus-error 4 "Strange nov line (%d)"
4678 (count-lines (point-min) (point)))))
4680 ;; A common bug in inn is that if you have posted an article and
4681 ;; then retrieves the active file, it will answer correctly --
4682 ;; the new article is included. However, a NOV entry for the
4683 ;; article may not have been generated yet, so this may fail.
4684 ;; We work around this problem by retrieving the last few
4685 ;; headers using HEAD.
4686 (if (or (not also-fetch-heads)
4688 ;; We (probably) got all the headers.
4690 (let ((gnus-nov-is-evil t))
4693 (gnus-retrieve-parsed-headers sequence group)
4696 (defun gnus-article-get-xrefs ()
4697 "Fill in the Xref value in `gnus-current-headers', if necessary.
4698 This is meant to be called in `gnus-article-internal-prepare-hook'."
4699 (let ((headers (save-excursion (set-buffer gnus-summary-buffer)
4700 gnus-current-headers)))
4701 (or (not gnus-use-cross-reference)
4703 (and (mail-header-xref headers)
4704 (not (string= (mail-header-xref headers) "")))
4705 (let ((case-fold-search t)
4708 (nnheader-narrow-to-headers)
4709 (goto-char (point-min))
4710 (when (or (and (eq (downcase (char-after)) ?x)
4711 (looking-at "Xref:"))
4712 (search-forward "\nXref:" nil t))
4713 (goto-char (1+ (match-end 0)))
4714 (setq xref (buffer-substring (point)
4715 (progn (end-of-line) (point))))
4716 (mail-header-set-xref headers xref)))))))
4718 (defun gnus-summary-insert-subject (id &optional old-header use-old-header)
4719 "Find article ID and insert the summary line for that article.
4720 OLD-HEADER can either be a header or a line number to insert
4721 the subject line on."
4722 (let* ((line (and (numberp old-header) old-header))
4723 (old-header (and (vectorp old-header) old-header))
4724 (header (cond ((and old-header use-old-header)
4727 (gnus-number-to-header id))
4728 (gnus-number-to-header id))
4730 (gnus-read-header id))))
4731 (number (and (numberp id) id))
4734 ;; Rebuild the thread that this article is part of and go to the
4735 ;; article we have fetched.
4736 (when (and (not gnus-show-threads)
4739 (setq d (gnus-data-find (mail-header-number old-header))))
4740 (goto-char (gnus-data-pos d))
4743 (- (gnus-point-at-bol)
4745 (1+ (gnus-point-at-eol))
4746 (gnus-delete-line))))))
4748 (mail-header-set-number header (mail-header-number old-header)))
4749 (setq gnus-newsgroup-sparse
4750 (delq (setq number (mail-header-number header))
4751 gnus-newsgroup-sparse))
4752 (setq gnus-newsgroup-ancient (delq number gnus-newsgroup-ancient))
4753 (push number gnus-newsgroup-limit)
4754 (gnus-rebuild-thread (mail-header-id header) line)
4755 (gnus-summary-goto-subject number nil t))
4756 (when (and (numberp number)
4758 ;; We have to update the boundaries even if we can't fetch the
4759 ;; article if ID is a number -- so that the next `P' or `N'
4760 ;; command will fetch the previous (or next) article even
4761 ;; if the one we tried to fetch this time has been canceled.
4762 (when (> number gnus-newsgroup-end)
4763 (setq gnus-newsgroup-end number))
4764 (when (< number gnus-newsgroup-begin)
4765 (setq gnus-newsgroup-begin number))
4766 (setq gnus-newsgroup-unselected
4767 (delq number gnus-newsgroup-unselected)))
4768 ;; Report back a success?
4769 (and header (mail-header-number header))))
4771 ;;; Process/prefix in the summary buffer
4773 (defun gnus-summary-work-articles (n)
4774 "Return a list of articles to be worked upon.
4775 The prefix argument, the list of process marked articles, and the
4776 current article will be taken into consideration."
4778 (set-buffer gnus-summary-buffer)
4781 ;; A numerical prefix has been given.
4782 (setq n (prefix-numeric-value n))
4783 (let ((backward (< n 0))
4784 (n (abs (prefix-numeric-value n)))
4789 (push (setq article (gnus-summary-article-number))
4792 (gnus-summary-find-prev nil article)
4793 (gnus-summary-find-next nil article)))
4795 (nreverse articles)))
4796 ((and (gnus-region-active-p) (mark))
4797 (message "region active")
4798 ;; Work on the region between point and mark.
4799 (let ((max (max (point) (mark)))
4802 (goto-char (min (point) (mark)))
4805 (push (setq article (gnus-summary-article-number)) articles)
4806 (gnus-summary-find-next nil article)
4808 (nreverse articles))))
4809 (gnus-newsgroup-processable
4810 ;; There are process-marked articles present.
4811 ;; Save current state.
4812 (gnus-summary-save-process-mark)
4814 (reverse gnus-newsgroup-processable))
4816 ;; Just return the current article.
4817 (list (gnus-summary-article-number))))))
4819 (defmacro gnus-summary-iterate (arg &rest forms)
4820 "Iterate over the process/prefixed articles and do FORMS.
4821 ARG is the interactive prefix given to the command. FORMS will be
4822 executed with point over the summary line of the articles."
4823 (let ((articles (make-symbol "gnus-summary-iterate-articles")))
4824 `(let ((,articles (gnus-summary-work-articles ,arg)))
4826 (gnus-summary-goto-subject (car ,articles))
4829 (put 'gnus-summary-iterate 'lisp-indent-function 1)
4830 (put 'gnus-summary-iterate 'edebug-form-spec '(form body))
4832 (defun gnus-summary-save-process-mark ()
4833 "Push the current set of process marked articles on the stack."
4835 (push (copy-sequence gnus-newsgroup-processable)
4836 gnus-newsgroup-process-stack))
4838 (defun gnus-summary-kill-process-mark ()
4839 "Push the current set of process marked articles on the stack and unmark."
4841 (gnus-summary-save-process-mark)
4842 (gnus-summary-unmark-all-processable))
4844 (defun gnus-summary-yank-process-mark ()
4845 "Pop the last process mark state off the stack and restore it."
4847 (unless gnus-newsgroup-process-stack
4848 (error "Empty mark stack"))
4849 (gnus-summary-process-mark-set (pop gnus-newsgroup-process-stack)))
4851 (defun gnus-summary-process-mark-set (set)
4852 "Make SET into the current process marked articles."
4853 (gnus-summary-unmark-all-processable)
4855 (gnus-summary-set-process-mark (pop set))))
4857 ;;; Searching and stuff
4859 (defun gnus-summary-search-group (&optional backward use-level)
4860 "Search for next unread newsgroup.
4861 If optional argument BACKWARD is non-nil, search backward instead."
4863 (set-buffer gnus-group-buffer)
4864 (when (gnus-group-search-forward
4865 backward nil (if use-level (gnus-group-group-level) nil))
4866 (gnus-group-group-name))))
4868 (defun gnus-summary-best-group (&optional exclude-group)
4869 "Find the name of the best unread group.
4870 If EXCLUDE-GROUP, do not go to this group."
4872 (set-buffer gnus-group-buffer)
4874 (gnus-group-best-unread-group exclude-group))))
4876 (defun gnus-summary-find-next (&optional unread article backward undownloaded)
4877 (if backward (gnus-summary-find-prev)
4878 (let* ((dummy (gnus-summary-article-intangible-p))
4879 (article (or article (gnus-summary-article-number)))
4880 (arts (gnus-data-find-list article))
4882 (when (and (not dummy)
4883 (or (not gnus-summary-check-current)
4885 (not (gnus-data-unread-p (car arts)))))
4886 (setq arts (cdr arts)))
4891 (when (or (and undownloaded
4892 (eq gnus-undownloaded-mark
4893 (gnus-data-mark (car arts))))
4894 (gnus-data-unread-p (car arts)))
4895 (setq result (car arts)
4897 (setq arts (cdr arts)))
4900 (goto-char (gnus-data-pos result))
4901 (gnus-data-number result)))))
4903 (defun gnus-summary-find-prev (&optional unread article)
4904 (let* ((eobp (eobp))
4905 (article (or article (gnus-summary-article-number)))
4906 (arts (gnus-data-find-list article (gnus-data-list 'rev)))
4908 (when (and (not eobp)
4909 (or (not gnus-summary-check-current)
4911 (not (gnus-data-unread-p (car arts)))))
4912 (setq arts (cdr arts)))
4917 (when (gnus-data-unread-p (car arts))
4918 (setq result (car arts)
4920 (setq arts (cdr arts)))
4923 (goto-char (gnus-data-pos result))
4924 (gnus-data-number result))))
4926 (defun gnus-summary-find-subject (subject &optional unread backward article)
4927 (let* ((simp-subject (gnus-simplify-subject-fully subject))
4928 (article (or article (gnus-summary-article-number)))
4929 (articles (gnus-data-list backward))
4930 (arts (gnus-data-find-list article articles))
4932 (when (or (not gnus-summary-check-current)
4934 (not (gnus-data-unread-p (car arts))))
4935 (setq arts (cdr arts)))
4937 (and (or (not unread)
4938 (gnus-data-unread-p (car arts)))
4939 (vectorp (gnus-data-header (car arts)))
4941 simp-subject (mail-header-subject (gnus-data-header (car arts))) t)
4942 (setq result (car arts)
4944 (setq arts (cdr arts)))
4946 (goto-char (gnus-data-pos result))
4947 (gnus-data-number result))))
4949 (defun gnus-summary-search-forward (&optional unread subject backward)
4950 "Search forward for an article.
4951 If UNREAD, look for unread articles. If SUBJECT, look for
4952 articles with that subject. If BACKWARD, search backward instead."
4953 (cond (subject (gnus-summary-find-subject subject unread backward))
4954 (backward (gnus-summary-find-prev unread))
4955 (t (gnus-summary-find-next unread))))
4957 (defun gnus-recenter (&optional n)
4958 "Center point in window and redisplay frame.
4959 Also do horizontal recentering."
4961 (when (and gnus-auto-center-summary
4962 (not (eq gnus-auto-center-summary 'vertical)))
4963 (gnus-horizontal-recenter))
4966 (defun gnus-summary-recenter ()
4967 "Center point in the summary window.
4968 If `gnus-auto-center-summary' is nil, or the article buffer isn't
4969 displayed, no centering will be performed."
4970 ;; Suggested by earle@mahendo.JPL.NASA.GOV (Greg Earle).
4971 ;; Recenter only when requested. Suggested by popovich@park.cs.columbia.edu.
4972 (let* ((top (cond ((< (window-height) 4) 0)
4973 ((< (window-height) 7) 1)
4974 (t (if (numberp gnus-auto-center-summary)
4975 gnus-auto-center-summary
4977 (height (1- (window-height)))
4978 (bottom (save-excursion (goto-char (point-max))
4979 (forward-line (- height))
4981 (window (get-buffer-window (current-buffer))))
4982 ;; The user has to want it.
4983 (when gnus-auto-center-summary
4984 (when (get-buffer-window gnus-article-buffer)
4985 ;; Only do recentering when the article buffer is displayed,
4986 ;; Set the window start to either `bottom', which is the biggest
4987 ;; possible valid number, or the second line from the top,
4988 ;; whichever is the least.
4990 window (min bottom (save-excursion
4991 (forward-line (- top)) (point)))))
4992 ;; Do horizontal recentering while we're at it.
4993 (when (and (get-buffer-window (current-buffer) t)
4994 (not (eq gnus-auto-center-summary 'vertical)))
4995 (let ((selected (selected-window)))
4996 (select-window (get-buffer-window (current-buffer) t))
4997 (gnus-summary-position-point)
4998 (gnus-horizontal-recenter)
4999 (select-window selected))))))
5001 (defun gnus-summary-jump-to-group (newsgroup)
5002 "Move point to NEWSGROUP in group mode buffer."
5003 ;; Keep update point of group mode buffer if visible.
5004 (if (eq (current-buffer) (get-buffer gnus-group-buffer))
5005 (save-window-excursion
5006 ;; Take care of tree window mode.
5007 (when (get-buffer-window gnus-group-buffer)
5008 (pop-to-buffer gnus-group-buffer))
5009 (gnus-group-jump-to-group newsgroup))
5011 ;; Take care of tree window mode.
5012 (if (get-buffer-window gnus-group-buffer)
5013 (pop-to-buffer gnus-group-buffer)
5014 (set-buffer gnus-group-buffer))
5015 (gnus-group-jump-to-group newsgroup))))
5017 ;; This function returns a list of article numbers based on the
5018 ;; difference between the ranges of read articles in this group and
5019 ;; the range of active articles.
5020 (defun gnus-list-of-unread-articles (group)
5021 (let* ((read (gnus-info-read (gnus-get-info group)))
5022 (active (or (gnus-active group) (gnus-activate-group group)))
5025 ;; If none are read, then all are unread.
5027 (setq first (car active))
5028 ;; If the range of read articles is a single range, then the
5029 ;; first unread article is the article after the last read
5030 ;; article. Sounds logical, doesn't it?
5031 (if (not (listp (cdr read)))
5032 (setq first (max (car active) (1+ (cdr read))))
5033 ;; `read' is a list of ranges.
5034 (when (/= (setq nlast (or (and (numberp (car read)) (car read))
5037 (setq first (car active)))
5040 (while (< first nlast)
5042 (setq first (1+ first))))
5043 (setq first (1+ (if (atom (car read)) (car read) (cdar read))))
5044 (setq nlast (if (atom (cadr read)) (cadr read) (caadr read)))
5045 (setq read (cdr read)))))
5046 ;; And add the last unread articles.
5047 (while (<= first last)
5049 (setq first (1+ first)))
5050 ;; Return the list of unread articles.
5051 (delq 0 (nreverse unread))))
5053 (defun gnus-list-of-read-articles (group)
5054 "Return a list of unread, unticked and non-dormant articles."
5055 (let* ((info (gnus-get-info group))
5056 (marked (gnus-info-marks info))
5057 (active (gnus-active group)))
5059 (gnus-set-difference
5060 (gnus-sorted-complement
5061 (gnus-uncompress-range active)
5062 (gnus-list-of-unread-articles group))
5064 (gnus-uncompress-range (cdr (assq 'dormant marked)))
5065 (gnus-uncompress-range (cdr (assq 'tick marked))))))))
5067 ;; Various summary commands
5069 (defun gnus-summary-select-article-buffer ()
5070 "Reconfigure windows to show article buffer."
5072 (if (not (gnus-buffer-live-p gnus-article-buffer))
5073 (error "There is no article buffer for this summary buffer")
5074 (gnus-configure-windows 'article)
5075 (select-window (get-buffer-window gnus-article-buffer))))
5077 (defun gnus-summary-universal-argument (arg)
5078 "Perform any operation on all articles that are process/prefixed."
5080 (let ((articles (gnus-summary-work-articles arg))
5087 (substitute-command-keys
5088 "\\<gnus-summary-mode-map>\\[gnus-summary-universal-argument]"
5091 (gnus-error 1 "Undefined key")
5094 (gnus-summary-goto-subject (setq article (pop articles)))
5095 (let (gnus-newsgroup-processable)
5096 (command-execute func))
5097 (gnus-summary-remove-process-mark article)))))
5098 (gnus-summary-position-point))
5100 (defun gnus-summary-toggle-truncation (&optional arg)
5101 "Toggle truncation of summary lines.
5102 With arg, turn line truncation on iff arg is positive."
5104 (setq truncate-lines
5105 (if (null arg) (not truncate-lines)
5106 (> (prefix-numeric-value arg) 0)))
5109 (defun gnus-summary-reselect-current-group (&optional all rescan)
5110 "Exit and then reselect the current newsgroup.
5111 The prefix argument ALL means to select all articles."
5113 (when (gnus-ephemeral-group-p gnus-newsgroup-name)
5114 (error "Ephemeral groups can't be reselected"))
5115 (let ((current-subject (gnus-summary-article-number))
5116 (group gnus-newsgroup-name))
5117 (setq gnus-newsgroup-begin nil)
5119 ;; We have to adjust the point of group mode buffer because
5120 ;; point was moved to the next unread newsgroup by exiting.
5121 (gnus-summary-jump-to-group group)
5124 (gnus-group-get-new-news-this-group 1)))
5125 (gnus-group-read-group all t)
5126 (gnus-summary-goto-subject current-subject nil t)))
5128 (defun gnus-summary-rescan-group (&optional all)
5129 "Exit the newsgroup, ask for new articles, and select the newsgroup."
5131 (gnus-summary-reselect-current-group all t))
5133 (defun gnus-summary-update-info (&optional non-destructive)
5135 (let ((group gnus-newsgroup-name))
5137 (when gnus-newsgroup-kill-headers
5138 (setq gnus-newsgroup-killed
5139 (gnus-compress-sequence
5141 (gnus-set-sorted-intersection
5142 (gnus-uncompress-range gnus-newsgroup-killed)
5143 (setq gnus-newsgroup-unselected
5144 (sort gnus-newsgroup-unselected '<)))
5145 (setq gnus-newsgroup-unreads
5146 (sort gnus-newsgroup-unreads '<)))
5148 (unless (listp (cdr gnus-newsgroup-killed))
5149 (setq gnus-newsgroup-killed (list gnus-newsgroup-killed)))
5150 (let ((headers gnus-newsgroup-headers))
5151 ;; Set the new ranges of read articles.
5153 (set-buffer gnus-group-buffer)
5154 (gnus-undo-force-boundary))
5155 (gnus-update-read-articles
5156 group (append gnus-newsgroup-unreads gnus-newsgroup-unselected))
5157 ;; Set the current article marks.
5158 (let ((gnus-newsgroup-scored
5159 (if (and (not gnus-save-score)
5160 (not non-destructive))
5162 gnus-newsgroup-scored)))
5164 (gnus-update-marks)))
5165 ;; Do the cross-ref thing.
5166 (when gnus-use-cross-reference
5167 (gnus-mark-xrefs-as-read group headers gnus-newsgroup-unreads))
5168 ;; Do not switch windows but change the buffer to work.
5169 (set-buffer gnus-group-buffer)
5170 (unless (gnus-ephemeral-group-p group)
5171 (gnus-group-update-group group)))))))
5173 (defun gnus-summary-save-newsrc (&optional force)
5174 "Save the current number of read/marked articles in the dribble buffer.
5175 The dribble buffer will then be saved.
5176 If FORCE (the prefix), also save the .newsrc file(s)."
5178 (gnus-summary-update-info t)
5180 (gnus-save-newsrc-file)
5181 (gnus-dribble-save)))
5183 (defun gnus-summary-exit (&optional temporary)
5184 "Exit reading current newsgroup, and then return to group selection mode.
5185 gnus-exit-group-hook is called with no arguments if that value is non-nil."
5187 (gnus-set-global-variables)
5188 (gnus-kill-save-kill-buffer)
5189 (gnus-async-halt-prefetch)
5190 (let* ((group gnus-newsgroup-name)
5191 (quit-config (gnus-group-quit-config gnus-newsgroup-name))
5194 (buf (current-buffer)))
5196 ;; Do adaptive scoring, and possibly save score files.
5197 (when gnus-newsgroup-adaptive
5198 (gnus-score-adaptive))
5199 (when gnus-use-scoring
5201 (gnus-run-hooks 'gnus-summary-prepare-exit-hook)
5202 ;; If we have several article buffers, we kill them at exit.
5203 (unless gnus-single-article-buffer
5204 (gnus-kill-buffer gnus-original-article-buffer)
5205 (setq gnus-article-current nil))
5206 (when gnus-use-cache
5207 (gnus-cache-possibly-remove-articles)
5208 (gnus-cache-save-buffers))
5209 (gnus-async-prefetch-remove-group group)
5210 (when gnus-suppress-duplicates
5211 (gnus-dup-enter-articles))
5212 (when gnus-use-trees
5213 (gnus-tree-close group))
5214 ;; Remove entries for this group.
5215 (nnmail-purge-split-history (gnus-group-real-name group))
5216 ;; Make all changes in this group permanent.
5218 (gnus-run-hooks 'gnus-exit-group-hook)
5219 (gnus-summary-update-info))
5220 (gnus-close-group group)
5221 ;; Make sure where we were, and go to next newsgroup.
5222 (set-buffer gnus-group-buffer)
5224 (gnus-group-jump-to-group group))
5225 (gnus-run-hooks 'gnus-summary-exit-hook)
5226 (unless (or quit-config
5227 ;; If this group has disappeared from the summary
5228 ;; buffer, don't skip forwards.
5229 (not (string= group (gnus-group-group-name))))
5230 (gnus-group-next-unread-group 1))
5231 (setq group-point (point))
5234 ;; If we have several article buffers, we kill them at exit.
5235 (unless gnus-single-article-buffer
5236 (gnus-kill-buffer gnus-article-buffer)
5237 (gnus-kill-buffer gnus-original-article-buffer)
5238 (setq gnus-article-current nil))
5240 (if (not gnus-kill-summary-on-exit)
5241 (gnus-deaden-summary)
5242 ;; We set all buffer-local variables to nil. It is unclear why
5243 ;; this is needed, but if we don't, buffer-local variables are
5244 ;; not garbage-collected, it seems. This would the lead to en
5245 ;; ever-growing Emacs.
5246 (gnus-summary-clear-local-variables)
5247 (when (get-buffer gnus-article-buffer)
5248 (bury-buffer gnus-article-buffer))
5249 ;; We clear the global counterparts of the buffer-local
5250 ;; variables as well, just to be on the safe side.
5251 (set-buffer gnus-group-buffer)
5252 (gnus-summary-clear-local-variables)
5253 ;; Return to group mode buffer.
5254 (when (eq mode 'gnus-summary-mode)
5255 (gnus-kill-buffer buf)))
5256 (setq gnus-current-select-method gnus-select-method)
5257 (pop-to-buffer gnus-group-buffer)
5258 (if (not quit-config)
5260 (goto-char group-point)
5261 (gnus-configure-windows 'group 'force))
5262 (gnus-handle-ephemeral-exit quit-config))
5263 ;; Clear the current group name.
5265 (setq gnus-newsgroup-name nil)))))
5267 (defalias 'gnus-summary-quit 'gnus-summary-exit-no-update)
5268 (defun gnus-summary-exit-no-update (&optional no-questions)
5269 "Quit reading current newsgroup without updating read article info."
5271 (let* ((group gnus-newsgroup-name)
5272 (quit-config (gnus-group-quit-config group)))
5273 (when (or no-questions
5275 (gnus-y-or-n-p "Discard changes to this group and exit? "))
5276 (gnus-async-halt-prefetch)
5278 (delq 'gnus-summary-expire-articles
5279 (copy-list gnus-summary-prepare-exit-hook)))
5280 ;; If we have several article buffers, we kill them at exit.
5281 (unless gnus-single-article-buffer
5282 (gnus-kill-buffer gnus-article-buffer)
5283 (gnus-kill-buffer gnus-original-article-buffer)
5284 (setq gnus-article-current nil))
5285 (if (not gnus-kill-summary-on-exit)
5286 (gnus-deaden-summary)
5287 (gnus-close-group group)
5288 (gnus-summary-clear-local-variables)
5289 (set-buffer gnus-group-buffer)
5290 (gnus-summary-clear-local-variables)
5291 (when (get-buffer gnus-summary-buffer)
5292 (kill-buffer gnus-summary-buffer)))
5293 (unless gnus-single-article-buffer
5294 (setq gnus-article-current nil))
5295 (when gnus-use-trees
5296 (gnus-tree-close group))
5297 (gnus-async-prefetch-remove-group group)
5298 (when (get-buffer gnus-article-buffer)
5299 (bury-buffer gnus-article-buffer))
5300 ;; Return to the group buffer.
5301 (gnus-configure-windows 'group 'force)
5302 ;; Clear the current group name.
5303 (setq gnus-newsgroup-name nil)
5304 (when (equal (gnus-group-group-name) group)
5305 (gnus-group-next-unread-group 1))
5307 (gnus-handle-ephemeral-exit quit-config)))))
5309 (defun gnus-handle-ephemeral-exit (quit-config)
5310 "Handle movement when leaving an ephemeral group.
5311 The state which existed when entering the ephemeral is reset."
5312 (if (not (buffer-name (car quit-config)))
5313 (gnus-configure-windows 'group 'force)
5314 (set-buffer (car quit-config))
5315 (cond ((eq major-mode 'gnus-summary-mode)
5316 (gnus-set-global-variables))
5317 ((eq major-mode 'gnus-article-mode)
5319 ;; The `gnus-summary-buffer' variable may point
5320 ;; to the old summary buffer when using a single
5322 (unless (gnus-buffer-live-p gnus-summary-buffer)
5323 (set-buffer gnus-group-buffer))
5324 (set-buffer gnus-summary-buffer)
5325 (gnus-set-global-variables))))
5326 (if (or (eq (cdr quit-config) 'article)
5327 (eq (cdr quit-config) 'pick))
5329 ;; The current article may be from the ephemeral group
5330 ;; thus it is best that we reload this article
5331 (gnus-summary-show-article)
5332 (if (and (boundp 'gnus-pick-mode) (symbol-value 'gnus-pick-mode))
5333 (gnus-configure-windows 'pick 'force)
5334 (gnus-configure-windows (cdr quit-config) 'force)))
5335 (gnus-configure-windows (cdr quit-config) 'force))
5336 (when (eq major-mode 'gnus-summary-mode)
5337 (gnus-summary-next-subject 1 nil t)
5338 (gnus-summary-recenter)
5339 (gnus-summary-position-point))))
5341 (defun gnus-summary-preview-mime-message ()
5342 "MIME decode and play this message."
5344 (let ((gnus-break-pages nil)
5346 (gnus-summary-select-article gnus-show-all-headers t))
5347 (select-window (get-buffer-window gnus-article-buffer)))
5351 (defvar gnus-dead-summary-mode-map nil)
5353 (unless gnus-dead-summary-mode-map
5354 (setq gnus-dead-summary-mode-map (make-keymap))
5355 (suppress-keymap gnus-dead-summary-mode-map)
5356 (substitute-key-definition
5357 'undefined 'gnus-summary-wake-up-the-dead gnus-dead-summary-mode-map)
5358 (let ((keys '("\C-d" "\r" "\177" [delete])))
5360 (define-key gnus-dead-summary-mode-map
5361 (pop keys) 'gnus-summary-wake-up-the-dead))))
5363 (defvar gnus-dead-summary-mode nil
5364 "Minor mode for Gnus summary buffers.")
5366 (defun gnus-dead-summary-mode (&optional arg)
5367 "Minor mode for Gnus summary buffers."
5369 (when (eq major-mode 'gnus-summary-mode)
5370 (make-local-variable 'gnus-dead-summary-mode)
5371 (setq gnus-dead-summary-mode
5372 (if (null arg) (not gnus-dead-summary-mode)
5373 (> (prefix-numeric-value arg) 0)))
5374 (when gnus-dead-summary-mode
5375 (gnus-add-minor-mode
5376 'gnus-dead-summary-mode " Dead" gnus-dead-summary-mode-map))))
5378 (defun gnus-deaden-summary ()
5379 "Make the current summary buffer into a dead summary buffer."
5380 ;; Kill any previous dead summary buffer.
5381 (when (and gnus-dead-summary
5382 (buffer-name gnus-dead-summary))
5384 (set-buffer gnus-dead-summary)
5385 (when gnus-dead-summary-mode
5386 (kill-buffer (current-buffer)))))
5387 ;; Make this the current dead summary.
5388 (setq gnus-dead-summary (current-buffer))
5389 (gnus-dead-summary-mode 1)
5390 (let ((name (buffer-name)))
5391 (when (string-match "Summary" name)
5393 (concat (substring name 0 (match-beginning 0)) "Dead "
5394 (substring name (match-beginning 0)))
5397 (defun gnus-kill-or-deaden-summary (buffer)
5398 "Kill or deaden the summary BUFFER."
5400 (when (and (buffer-name buffer)
5401 (not gnus-single-article-buffer))
5404 (gnus-kill-buffer gnus-article-buffer)
5405 (gnus-kill-buffer gnus-original-article-buffer)))
5406 (cond (gnus-kill-summary-on-exit
5407 (when (and gnus-use-trees
5408 (gnus-buffer-exists-p buffer))
5411 (gnus-tree-close gnus-newsgroup-name)))
5412 (gnus-kill-buffer buffer))
5413 ((gnus-buffer-exists-p buffer)
5416 (gnus-deaden-summary))))))
5418 (defun gnus-summary-wake-up-the-dead (&rest args)
5419 "Wake up the dead summary buffer."
5421 (gnus-dead-summary-mode -1)
5422 (let ((name (buffer-name)))
5423 (when (string-match "Dead " name)
5425 (concat (substring name 0 (match-beginning 0))
5426 (substring name (match-end 0)))
5428 (gnus-message 3 "This dead summary is now alive again"))
5430 ;; Suggested by Andrew Eskilsson <pi92ae@pt.hk-r.se>.
5431 (defun gnus-summary-fetch-faq (&optional faq-dir)
5432 "Fetch the FAQ for the current group.
5433 If FAQ-DIR (the prefix), prompt for a directory to search for the faq
5437 (when current-prefix-arg
5439 "Faq dir: " (and (listp gnus-group-faq-directory)
5440 (mapcar (lambda (file) (list file))
5441 gnus-group-faq-directory))))))
5442 (let (gnus-faq-buffer)
5443 (when (setq gnus-faq-buffer
5444 (gnus-group-fetch-faq gnus-newsgroup-name faq-dir))
5445 (gnus-configure-windows 'summary-faq))))
5447 ;; Suggested by Per Abrahamsen <amanda@iesd.auc.dk>.
5448 (defun gnus-summary-describe-group (&optional force)
5449 "Describe the current newsgroup."
5451 (gnus-group-describe-group force gnus-newsgroup-name))
5453 (defun gnus-summary-describe-briefly ()
5454 "Describe summary mode commands briefly."
5456 (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")))
5458 ;; Walking around group mode buffer from summary mode.
5460 (defun gnus-summary-next-group (&optional no-article target-group backward)
5461 "Exit current newsgroup and then select next unread newsgroup.
5462 If prefix argument NO-ARTICLE is non-nil, no article is selected
5463 initially. If NEXT-GROUP, go to this group. If BACKWARD, go to
5464 previous group instead."
5466 ;; Stop pre-fetching.
5467 (gnus-async-halt-prefetch)
5468 (let ((current-group gnus-newsgroup-name)
5469 (current-buffer (current-buffer))
5471 ;; First we semi-exit this group to update Xrefs and all variables.
5472 ;; We can't do a real exit, because the window conf must remain
5473 ;; the same in case the user is prompted for info, and we don't
5474 ;; want the window conf to change before that...
5475 (gnus-summary-exit t)
5476 (while (not entered)
5477 ;; Then we find what group we are supposed to enter.
5478 (set-buffer gnus-group-buffer)
5479 (gnus-group-jump-to-group current-group)
5482 (if (eq gnus-keep-same-level 'best)
5483 (gnus-summary-best-group gnus-newsgroup-name)
5484 (gnus-summary-search-group backward gnus-keep-same-level))))
5485 (if (not target-group)
5486 ;; There are no further groups, so we return to the group
5489 (gnus-message 5 "Returning to the group buffer")
5491 (when (gnus-buffer-live-p current-buffer)
5492 (set-buffer current-buffer)
5493 (gnus-summary-exit))
5494 (gnus-run-hooks 'gnus-group-no-more-groups-hook))
5495 ;; We try to enter the target group.
5496 (gnus-group-jump-to-group target-group)
5497 (let ((unreads (gnus-group-group-unread)))
5498 (if (and (or (eq t unreads)
5499 (and unreads (not (zerop unreads))))
5500 (gnus-summary-read-group
5501 target-group nil no-article
5502 (and (buffer-name current-buffer) current-buffer)
5505 (setq current-group target-group
5506 target-group nil)))))))
5508 (defun gnus-summary-prev-group (&optional no-article)
5509 "Exit current newsgroup and then select previous unread newsgroup.
5510 If prefix argument NO-ARTICLE is non-nil, no article is selected initially."
5512 (gnus-summary-next-group no-article nil t))
5514 ;; Walking around summary lines.
5516 (defun gnus-summary-first-subject (&optional unread undownloaded)
5517 "Go to the first unread subject.
5518 If UNREAD is non-nil, go to the first unread article.
5519 Returns the article selected or nil if there are no unread articles."
5524 ((null gnus-newsgroup-data)
5525 (gnus-message 3 "No articles in the group")
5527 ;; Pick the first article.
5529 (goto-char (gnus-data-pos (car gnus-newsgroup-data)))
5530 (gnus-data-number (car gnus-newsgroup-data)))
5531 ;; No unread articles.
5532 ((null gnus-newsgroup-unreads)
5533 (gnus-message 3 "No more unread articles")
5535 ;; Find the first unread article.
5537 (let ((data gnus-newsgroup-data))
5539 (and (not (and undownloaded
5540 (eq gnus-undownloaded-mark
5541 (gnus-data-mark (car data)))))
5542 (not (gnus-data-unread-p (car data)))))
5543 (setq data (cdr data)))
5545 (goto-char (gnus-data-pos (car data)))
5546 (gnus-data-number (car data))))))
5547 (gnus-summary-position-point)))
5549 (defun gnus-summary-next-subject (n &optional unread dont-display)
5550 "Go to next N'th summary line.
5551 If N is negative, go to the previous N'th subject line.
5552 If UNREAD is non-nil, only unread articles are selected.
5553 The difference between N and the actual number of steps taken is
5556 (let ((backward (< n 0))
5560 (gnus-summary-find-prev unread)
5561 (gnus-summary-find-next unread)))
5562 (gnus-summary-show-thread)
5565 (gnus-message 7 "No more%s articles"
5566 (if unread " unread" "")))
5567 (unless dont-display
5568 (gnus-summary-recenter)
5569 (gnus-summary-position-point))
5572 (defun gnus-summary-next-unread-subject (n)
5573 "Go to next N'th unread summary line."
5575 (gnus-summary-next-subject n t))
5577 (defun gnus-summary-prev-subject (n &optional unread)
5578 "Go to previous N'th summary line.
5579 If optional argument UNREAD is non-nil, only unread article is selected."
5581 (gnus-summary-next-subject (- n) unread))
5583 (defun gnus-summary-prev-unread-subject (n)
5584 "Go to previous N'th unread summary line."
5586 (gnus-summary-next-subject (- n) t))
5588 (defun gnus-summary-goto-subject (article &optional force silent)
5589 "Go the subject line of ARTICLE.
5590 If FORCE, also allow jumping to articles not currently shown."
5591 (interactive "nArticle number: ")
5593 (data (gnus-data-find article)))
5594 ;; We read in the article if we have to.
5597 (gnus-summary-insert-subject
5599 (if (or (numberp force) (vectorp force)) force)
5601 (setq data (gnus-data-find article)))
5606 (gnus-message 3 "Can't find article %d" article))
5608 (goto-char (gnus-data-pos data))
5609 (gnus-summary-position-point)
5612 ;; Walking around summary lines with displaying articles.
5614 (defun gnus-summary-expand-window (&optional arg)
5615 "Make the summary buffer take up the entire Emacs frame.
5616 Given a prefix, will force an `article' buffer configuration."
5619 (gnus-configure-windows 'article 'force)
5620 (gnus-configure-windows 'summary 'force)))
5622 (defun gnus-summary-display-article (article &optional all-header)
5623 "Display ARTICLE in article buffer."
5624 (gnus-set-global-variables)
5628 (if gnus-summary-display-article-function
5629 (funcall gnus-summary-display-article-function article all-header)
5630 (gnus-article-prepare article all-header))
5631 (gnus-run-hooks 'gnus-select-article-hook)
5632 (when (and gnus-current-article
5633 (not (zerop gnus-current-article)))
5634 (gnus-summary-goto-subject gnus-current-article))
5635 (gnus-summary-recenter)
5636 (when (and gnus-use-trees gnus-show-threads)
5637 (gnus-possibly-generate-tree article)
5638 (gnus-highlight-selected-tree article))
5639 ;; Successfully display article.
5640 (gnus-article-set-window-start
5641 (cdr (assq article gnus-newsgroup-bookmarks))))))
5643 (defun gnus-summary-select-article (&optional all-headers force pseudo article)
5644 "Select the current article.
5645 If ALL-HEADERS is non-nil, show all header fields. If FORCE is
5646 non-nil, the article will be re-fetched even if it already present in
5647 the article buffer. If PSEUDO is non-nil, pseudo-articles will also
5649 ;; Make sure we are in the summary buffer to work around bbdb bug.
5650 (unless (eq major-mode 'gnus-summary-mode)
5651 (set-buffer gnus-summary-buffer))
5652 (let ((article (or article (gnus-summary-article-number)))
5653 (all-headers (not (not all-headers))) ;Must be T or NIL.
5654 gnus-summary-display-article-function
5657 (gnus-summary-article-pseudo-p article)
5658 (error "This is a pseudo-article"))
5661 (set-buffer gnus-summary-buffer)
5662 (if (or (and gnus-single-article-buffer
5663 (or (null gnus-current-article)
5664 (null gnus-article-current)
5665 (null (get-buffer gnus-article-buffer))
5666 (not (eq article (cdr gnus-article-current)))
5667 (not (equal (car gnus-article-current)
5668 gnus-newsgroup-name))))
5669 (and (not gnus-single-article-buffer)
5670 (or (null gnus-current-article)
5671 (not (eq gnus-current-article article))))
5673 ;; The requested article is different from the current article.
5675 (gnus-summary-display-article article all-headers)
5677 (when (or all-headers gnus-show-all-headers)
5678 (gnus-article-show-all-headers)))
5679 (when (or all-headers gnus-show-all-headers)
5680 (gnus-article-show-all-headers))
5683 (gnus-article-set-window-start
5684 (cdr (assq article gnus-newsgroup-bookmarks)))))))
5686 (defun gnus-summary-set-current-mark (&optional current-mark)
5687 "Obsolete function."
5690 (defun gnus-summary-next-article (&optional unread subject backward push)
5691 "Select the next article.
5692 If UNREAD, only unread articles are selected.
5693 If SUBJECT, only articles with SUBJECT are selected.
5694 If BACKWARD, the previous article is selected instead of the next."
5697 ;; Is there such an article?
5698 ((and (gnus-summary-search-forward unread subject backward)
5699 (or (gnus-summary-display-article (gnus-summary-article-number))
5700 (eq (gnus-summary-article-mark) gnus-canceled-mark)))
5701 (gnus-summary-position-point))
5702 ;; If not, we try the first unread, if that is wanted.
5704 gnus-auto-select-same
5705 (gnus-summary-first-unread-article))
5706 (gnus-summary-position-point)
5707 (gnus-message 6 "Wrapped"))
5708 ;; Try to get next/previous article not displayed in this group.
5709 ((and gnus-auto-extend-newsgroup
5710 (not unread) (not subject))
5711 (gnus-summary-goto-article
5712 (if backward (1- gnus-newsgroup-begin) (1+ gnus-newsgroup-end))
5713 nil (count-lines (point-min) (point))))
5714 ;; Go to next/previous group.
5716 (unless (gnus-ephemeral-group-p gnus-newsgroup-name)
5717 (gnus-summary-jump-to-group gnus-newsgroup-name))
5718 (let ((cmd last-command-char)
5721 (set-buffer gnus-group-buffer)
5724 (if (eq gnus-keep-same-level 'best)
5725 (gnus-summary-best-group gnus-newsgroup-name)
5726 (gnus-summary-search-group backward gnus-keep-same-level))))
5727 ;; For some reason, the group window gets selected. We change
5729 (select-window (get-buffer-window (current-buffer)))
5730 ;; Select next unread newsgroup automagically.
5732 ((or (not gnus-auto-select-next)
5734 (gnus-message 7 "No more%s articles" (if unread " unread" "")))
5735 ((or (eq gnus-auto-select-next 'quietly)
5736 (and (eq gnus-auto-select-next 'slightly-quietly)
5738 (and (eq gnus-auto-select-next 'almost-quietly)
5739 (gnus-summary-last-article-p)))
5741 (if (gnus-ephemeral-group-p gnus-newsgroup-name)
5743 (gnus-message 7 "No more%s articles (%s)..."
5744 (if unread " unread" "")
5745 (if group (concat "selecting " group)
5747 (gnus-summary-next-group nil group backward)))
5749 (when (gnus-key-press-event-p last-input-event)
5750 (gnus-summary-walk-group-buffer
5751 gnus-newsgroup-name cmd unread backward point))))))))
5753 (defun gnus-summary-walk-group-buffer (from-group cmd unread backward start)
5754 (let ((keystrokes '((?\C-n (gnus-group-next-unread-group 1))
5755 (?\C-p (gnus-group-prev-unread-group 1))))
5756 (cursor-in-echo-area t)
5757 keve key group ended)
5759 (set-buffer gnus-group-buffer)
5762 (if (eq gnus-keep-same-level 'best)
5763 (gnus-summary-best-group gnus-newsgroup-name)
5764 (gnus-summary-search-group backward gnus-keep-same-level))))
5767 5 "No more%s articles%s" (if unread " unread" "")
5769 (not (gnus-ephemeral-group-p gnus-newsgroup-name)))
5770 (format " (Type %s for %s [%s])"
5771 (single-key-description cmd) group
5772 (car (gnus-gethash group gnus-newsrc-hashtb)))
5773 (format " (Type %s to exit %s)"
5774 (single-key-description cmd)
5775 gnus-newsgroup-name)))
5776 ;; Confirm auto selection.
5777 (setq key (car (setq keve (gnus-read-event-char))))
5780 ((assq key keystrokes)
5781 (let ((obuf (current-buffer)))
5782 (switch-to-buffer gnus-group-buffer)
5784 (gnus-group-jump-to-group group))
5785 (eval (cadr (assq key keystrokes)))
5786 (setq group (gnus-group-group-name))
5787 (switch-to-buffer obuf))
5791 (gnus-ephemeral-group-p gnus-newsgroup-name))
5793 (gnus-summary-next-group nil group backward)))
5795 (push (cdr keve) unread-command-events))))))
5797 (defun gnus-summary-next-unread-article ()
5798 "Select unread article after current one."
5800 (gnus-summary-next-article
5801 (or (not (eq gnus-summary-goto-unread 'never))
5802 (gnus-summary-last-article-p (gnus-summary-article-number)))
5803 (and gnus-auto-select-same
5804 (gnus-summary-article-subject))))
5806 (defun gnus-summary-prev-article (&optional unread subject)
5807 "Select the article after the current one.
5808 If UNREAD is non-nil, only unread articles are selected."
5810 (gnus-summary-next-article unread subject t))
5812 (defun gnus-summary-prev-unread-article ()
5813 "Select unread article before current one."
5815 (gnus-summary-prev-article
5816 (or (not (eq gnus-summary-goto-unread 'never))
5817 (gnus-summary-first-article-p (gnus-summary-article-number)))
5818 (and gnus-auto-select-same
5819 (gnus-summary-article-subject))))
5821 (defun gnus-summary-next-page (&optional lines circular)
5822 "Show next page of the selected article.
5823 If at the end of the current article, select the next article.
5824 LINES says how many lines should be scrolled up.
5826 If CIRCULAR is non-nil, go to the start of the article instead of
5827 selecting the next article when reaching the end of the current
5830 (setq gnus-summary-buffer (current-buffer))
5831 (gnus-set-global-variables)
5832 (let ((article (gnus-summary-article-number))
5833 (article-window (get-buffer-window gnus-article-buffer t))
5835 ;; If the buffer is empty, we have no article.
5837 (error "No article to select"))
5838 (gnus-configure-windows 'article)
5839 (if (eq (cdr (assq article gnus-newsgroup-reads)) gnus-canceled-mark)
5840 (if (and (eq gnus-summary-goto-unread 'never)
5841 (not (gnus-summary-last-article-p article)))
5842 (gnus-summary-next-article)
5843 (gnus-summary-next-unread-article))
5844 (if (or (null gnus-current-article)
5845 (null gnus-article-current)
5846 (/= article (cdr gnus-article-current))
5847 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5848 ;; Selected subject is different from current article's.
5849 (gnus-summary-display-article article)
5850 (when article-window
5851 (gnus-eval-in-buffer-window gnus-article-buffer
5852 (setq endp (gnus-article-next-page lines)))
5855 (gnus-summary-beginning-of-article))
5857 (gnus-message 3 "End of message"))
5859 (if (and (eq gnus-summary-goto-unread 'never)
5860 (not (gnus-summary-last-article-p article)))
5861 (gnus-summary-next-article)
5862 (gnus-summary-next-unread-article))))))))
5863 (gnus-summary-recenter)
5864 (gnus-summary-position-point)))
5866 (defun gnus-summary-prev-page (&optional lines move)
5867 "Show previous page of selected article.
5868 Argument LINES specifies lines to be scrolled down.
5869 If MOVE, move to the previous unread article if point is at
5870 the beginning of the buffer."
5872 (let ((article (gnus-summary-article-number))
5873 (article-window (get-buffer-window gnus-article-buffer t))
5875 (gnus-configure-windows 'article)
5876 (if (or (null gnus-current-article)
5877 (null gnus-article-current)
5878 (/= article (cdr gnus-article-current))
5879 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
5880 ;; Selected subject is different from current article's.
5881 (gnus-summary-display-article article)
5882 (gnus-summary-recenter)
5883 (when article-window
5884 (gnus-eval-in-buffer-window gnus-article-buffer
5885 (setq endp (gnus-article-prev-page lines)))
5886 (when (and move endp)
5888 (gnus-message 3 "Beginning of message"))
5890 (if (and (eq gnus-summary-goto-unread 'never)
5891 (not (gnus-summary-first-article-p article)))
5892 (gnus-summary-prev-article)
5893 (gnus-summary-prev-unread-article))))))))
5894 (gnus-summary-position-point))
5896 (defun gnus-summary-prev-page-or-article (&optional lines)
5897 "Show previous page of selected article.
5898 Argument LINES specifies lines to be scrolled down.
5899 If at the beginning of the article, go to the next article."
5901 (gnus-summary-prev-page lines t))
5903 (defun gnus-summary-scroll-up (lines)
5904 "Scroll up (or down) one line current article.
5905 Argument LINES specifies lines to be scrolled up (or down if negative)."
5907 (gnus-configure-windows 'article)
5908 (gnus-summary-show-thread)
5909 (when (eq (gnus-summary-select-article nil nil 'pseudo) 'old)
5910 (gnus-eval-in-buffer-window gnus-article-buffer
5912 (when (gnus-article-next-page lines)
5913 (gnus-message 3 "End of message")))
5915 (gnus-article-prev-page (- lines))))))
5916 (gnus-summary-recenter)
5917 (gnus-summary-position-point))
5919 (defun gnus-summary-scroll-down (lines)
5920 "Scroll down (or up) one line current article.
5921 Argument LINES specifies lines to be scrolled down (or up if negative)."
5923 (gnus-summary-scroll-up (- lines)))
5925 (defun gnus-summary-next-same-subject ()
5926 "Select next article which has the same subject as current one."
5928 (gnus-summary-next-article nil (gnus-summary-article-subject)))
5930 (defun gnus-summary-prev-same-subject ()
5931 "Select previous article which has the same subject as current one."
5933 (gnus-summary-prev-article nil (gnus-summary-article-subject)))
5935 (defun gnus-summary-next-unread-same-subject ()
5936 "Select next unread article which has the same subject as current one."
5938 (gnus-summary-next-article t (gnus-summary-article-subject)))
5940 (defun gnus-summary-prev-unread-same-subject ()
5941 "Select previous unread article which has the same subject as current one."
5943 (gnus-summary-prev-article t (gnus-summary-article-subject)))
5945 (defun gnus-summary-first-unread-article ()
5946 "Select the first unread article.
5947 Return nil if there are no unread articles."
5950 (when (gnus-summary-first-subject t)
5951 (gnus-summary-show-thread)
5952 (gnus-summary-first-subject t)
5953 (gnus-summary-display-article (gnus-summary-article-number)))
5954 (gnus-summary-position-point)))
5956 (defun gnus-summary-first-unread-subject ()
5957 "Place the point on the subject line of the first unread article.
5958 Return nil if there are no unread articles."
5961 (when (gnus-summary-first-subject t)
5962 (gnus-summary-show-thread)
5963 (gnus-summary-first-subject t))
5964 (gnus-summary-position-point)))
5966 (defun gnus-summary-first-article ()
5967 "Select the first article.
5968 Return nil if there are no articles."
5971 (when (gnus-summary-first-subject)
5972 (gnus-summary-show-thread)
5973 (gnus-summary-first-subject)
5974 (gnus-summary-display-article (gnus-summary-article-number)))
5975 (gnus-summary-position-point)))
5977 (defun gnus-summary-best-unread-article ()
5978 "Select the unread article with the highest score."
5980 (let ((best -1000000)
5981 (data gnus-newsgroup-data)
5984 (and (gnus-data-unread-p (car data))
5986 (gnus-summary-article-score (gnus-data-number (car data))))
5989 article (gnus-data-number (car data))))
5990 (setq data (cdr data)))
5993 (gnus-summary-goto-article article)
5994 (error "No unread articles"))
5995 (gnus-summary-position-point))))
5997 (defun gnus-summary-last-subject ()
5998 "Go to the last displayed subject line in the group."
5999 (let ((article (gnus-data-number (car (gnus-data-list t)))))
6001 (gnus-summary-goto-subject article))))
6003 (defun gnus-summary-goto-article (article &optional all-headers force)
6004 "Fetch ARTICLE (article number or Message-ID) and display it if it exists.
6005 If ALL-HEADERS is non-nil, no header lines are hidden.
6006 If FORCE, go to the article even if it isn't displayed. If FORCE
6007 is a number, it is the line the article is to be displayed on."
6011 "Article number or Message-ID: "
6012 (mapcar (lambda (number) (list (int-to-string number)))
6013 gnus-newsgroup-limit))
6017 (if (and (stringp article)
6018 (string-match "@" article))
6019 (gnus-summary-refer-article article)
6020 (when (stringp article)
6021 (setq article (string-to-number article)))
6022 (if (gnus-summary-goto-subject article force)
6023 (gnus-summary-display-article article all-headers)
6024 (gnus-message 4 "Couldn't go to article %s" article) nil))
6025 (gnus-summary-position-point)))
6027 (defun gnus-summary-goto-last-article ()
6028 "Go to the previously read article."
6031 (when gnus-last-article
6032 (gnus-summary-goto-article gnus-last-article nil t))
6033 (gnus-summary-position-point)))
6035 (defun gnus-summary-pop-article (number)
6036 "Pop one article off the history and go to the previous.
6037 NUMBER articles will be popped off."
6040 (setq gnus-newsgroup-history
6041 (cdr (setq to (nthcdr number gnus-newsgroup-history))))
6043 (gnus-summary-goto-article (car to) nil t)
6044 (error "Article history empty")))
6045 (gnus-summary-position-point))
6047 ;; Summary commands and functions for limiting the summary buffer.
6049 (defun gnus-summary-limit-to-articles (n)
6050 "Limit the summary buffer to the next N articles.
6051 If not given a prefix, use the process marked articles instead."
6054 (let ((articles (gnus-summary-work-articles n)))
6055 (setq gnus-newsgroup-processable nil)
6056 (gnus-summary-limit articles))
6057 (gnus-summary-position-point)))
6059 (defun gnus-summary-pop-limit (&optional total)
6060 "Restore the previous limit.
6061 If given a prefix, remove all limits."
6064 (setq gnus-newsgroup-limits
6065 (list (mapcar (lambda (h) (mail-header-number h))
6066 gnus-newsgroup-headers))))
6067 (unless gnus-newsgroup-limits
6068 (error "No limit to pop"))
6070 (gnus-summary-limit nil 'pop)
6071 (gnus-summary-position-point)))
6073 (defun gnus-summary-limit-to-subject (subject &optional header)
6074 "Limit the summary buffer to articles that have subjects that match a regexp."
6075 (interactive "sLimit to subject (regexp): ")
6077 (setq header "subject"))
6078 (when (not (equal "" subject))
6080 (let ((articles (gnus-summary-find-matching
6081 (or header "subject") subject 'all)))
6083 (error "Found no matches for \"%s\"" subject))
6084 (gnus-summary-limit articles))
6085 (gnus-summary-position-point))))
6087 (defun gnus-summary-limit-to-author (from)
6088 "Limit the summary buffer to articles that have authors that match a regexp."
6089 (interactive "sLimit to author (regexp): ")
6090 (gnus-summary-limit-to-subject from "from"))
6092 (defun gnus-summary-limit-to-age (age &optional younger-p)
6093 "Limit the summary buffer to articles that are older than (or equal) AGE days.
6094 If YOUNGER-P (the prefix) is non-nil, limit the summary buffer to
6095 articles that are younger than AGE days."
6096 (interactive "nTime in days: \nP")
6098 (let ((data gnus-newsgroup-data)
6099 (cutoff (days-to-time age))
6100 articles d date is-younger)
6101 (while (setq d (pop data))
6102 (when (and (vectorp (gnus-data-header d))
6103 (setq date (mail-header-date (gnus-data-header d))))
6104 (setq is-younger (time-less-p
6105 (time-since (date-to-time date))
6110 (push (gnus-data-number d) articles))))
6111 (gnus-summary-limit (nreverse articles)))
6112 (gnus-summary-position-point)))
6114 (defalias 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6116 'gnus-summary-delete-marked-as-read 'gnus-summary-limit-to-unread)
6118 (defun gnus-summary-limit-to-unread (&optional all)
6119 "Limit the summary buffer to articles that are not marked as read.
6120 If ALL is non-nil, limit strictly to unread articles."
6123 (gnus-summary-limit-to-marks (char-to-string gnus-unread-mark))
6124 (gnus-summary-limit-to-marks
6125 ;; Concat all the marks that say that an article is read and have
6127 (list gnus-del-mark gnus-read-mark gnus-ancient-mark
6128 gnus-killed-mark gnus-kill-file-mark
6129 gnus-low-score-mark gnus-expirable-mark
6130 gnus-canceled-mark gnus-catchup-mark gnus-sparse-mark
6131 gnus-duplicate-mark gnus-souped-mark)
6134 (defalias 'gnus-summary-delete-marked-with 'gnus-summary-limit-exclude-marks)
6135 (make-obsolete 'gnus-summary-delete-marked-with
6136 'gnus-summary-limit-exlude-marks)
6138 (defun gnus-summary-limit-exclude-marks (marks &optional reverse)
6139 "Exclude articles that are marked with MARKS (e.g. \"DK\").
6140 If REVERSE, limit the summary buffer to articles that are marked
6141 with MARKS. MARKS can either be a string of marks or a list of marks.
6142 Returns how many articles were removed."
6143 (interactive "sMarks: ")
6144 (gnus-summary-limit-to-marks marks t))
6146 (defun gnus-summary-limit-to-marks (marks &optional reverse)
6147 "Limit the summary buffer to articles that are marked with MARKS (e.g. \"DK\").
6148 If REVERSE (the prefix), limit the summary buffer to articles that are
6149 not marked with MARKS. MARKS can either be a string of marks or a
6151 Returns how many articles were removed."
6152 (interactive "sMarks: \nP")
6154 (let ((data gnus-newsgroup-data)
6155 (marks (if (listp marks) marks
6156 (append marks nil))) ; Transform to list.
6159 (when (if reverse (not (memq (gnus-data-mark (car data)) marks))
6160 (memq (gnus-data-mark (car data)) marks))
6161 (push (gnus-data-number (car data)) articles))
6162 (setq data (cdr data)))
6163 (gnus-summary-limit articles))
6164 (gnus-summary-position-point)))
6166 (defun gnus-summary-limit-to-score (&optional score)
6167 "Limit to articles with score at or above SCORE."
6169 (setq score (if score
6170 (prefix-numeric-value score)
6171 (or gnus-summary-default-score 0)))
6172 (let ((data gnus-newsgroup-data)
6175 (when (>= (gnus-summary-article-score (gnus-data-number (car data)))
6177 (push (gnus-data-number (car data)) articles))
6178 (setq data (cdr data)))
6180 (gnus-summary-limit articles)
6181 (gnus-summary-position-point))))
6183 (defun gnus-summary-limit-include-thread (id)
6184 "Display all the hidden articles that in the current thread."
6185 (interactive (list (mail-header-id (gnus-summary-article-header))))
6186 (let ((articles (gnus-articles-in-thread
6187 (gnus-id-to-thread (gnus-root-id id)))))
6189 (gnus-summary-limit (nconc articles gnus-newsgroup-limit))
6190 (gnus-summary-position-point))))
6192 (defun gnus-summary-limit-include-dormant ()
6193 "Display all the hidden articles that are marked as dormant.
6194 Note that this command only works on a subset of the articles currently
6195 fetched for this group."
6197 (unless gnus-newsgroup-dormant
6198 (error "There are no dormant articles in this group"))
6200 (gnus-summary-limit (append gnus-newsgroup-dormant gnus-newsgroup-limit))
6201 (gnus-summary-position-point)))
6203 (defun gnus-summary-limit-exclude-dormant ()
6204 "Hide all dormant articles."
6207 (gnus-summary-limit-to-marks (list gnus-dormant-mark) 'reverse)
6208 (gnus-summary-position-point)))
6210 (defun gnus-summary-limit-exclude-childless-dormant ()
6211 "Hide all dormant articles that have no children."
6213 (let ((data (gnus-data-list t))
6214 articles d children)
6215 ;; Find all articles that are either not dormant or have
6217 (while (setq d (pop data))
6218 (when (or (not (= (gnus-data-mark d) gnus-dormant-mark))
6220 (gnus-article-children (gnus-data-number d)))
6223 (when (memq (car children) articles)
6228 (push (gnus-data-number d) articles)))
6231 (gnus-summary-limit articles)
6232 (gnus-summary-position-point))))
6234 (defun gnus-summary-limit-mark-excluded-as-read (&optional all)
6235 "Mark all unread excluded articles as read.
6236 If ALL, mark even excluded ticked and dormants as read."
6238 (let ((articles (gnus-sorted-complement
6240 (mapcar (lambda (h) (mail-header-number h))
6241 gnus-newsgroup-headers)
6243 (sort gnus-newsgroup-limit '<)))
6245 (setq gnus-newsgroup-unreads
6246 (gnus-intersection gnus-newsgroup-unreads gnus-newsgroup-limit))
6248 (setq gnus-newsgroup-dormant nil
6249 gnus-newsgroup-marked nil
6250 gnus-newsgroup-reads
6252 (mapcar (lambda (n) (cons n gnus-catchup-mark)) articles)
6253 gnus-newsgroup-reads))
6254 (while (setq article (pop articles))
6255 (unless (or (memq article gnus-newsgroup-dormant)
6256 (memq article gnus-newsgroup-marked))
6257 (push (cons article gnus-catchup-mark) gnus-newsgroup-reads))))))
6259 (defun gnus-summary-limit (articles &optional pop)
6261 ;; We pop the previous limit off the stack and use that.
6262 (setq articles (car gnus-newsgroup-limits)
6263 gnus-newsgroup-limits (cdr gnus-newsgroup-limits))
6264 ;; We use the new limit, so we push the old limit on the stack.
6265 (push gnus-newsgroup-limit gnus-newsgroup-limits))
6267 (setq gnus-newsgroup-limit articles)
6268 (let ((total (length gnus-newsgroup-data))
6269 (data (gnus-data-find-list (gnus-summary-article-number)))
6270 (gnus-summary-mark-below nil) ; Inhibit this.
6272 ;; This will do all the work of generating the new summary buffer
6273 ;; according to the new limit.
6274 (gnus-summary-prepare)
6275 ;; Hide any threads, possibly.
6276 (and gnus-show-threads
6277 gnus-thread-hide-subtree
6278 (gnus-summary-hide-all-threads))
6279 ;; Try to return to the article you were at, or one in the
6282 ;; We try to find some article after the current one.
6284 (when (gnus-summary-goto-subject (gnus-data-number (car data)) nil t)
6287 (setq data (cdr data))))
6289 ;; If there is no data, that means that we were after the last
6290 ;; article. The same goes when we can't find any articles
6291 ;; after the current one.
6292 (goto-char (point-max))
6293 (gnus-summary-find-prev))
6294 (gnus-set-mode-line 'summary)
6295 ;; We return how many articles were removed from the summary
6296 ;; buffer as a result of the new limit.
6297 (- total (length gnus-newsgroup-data))))
6299 (defsubst gnus-invisible-cut-children (threads)
6302 (when (memq (mail-header-number (caar threads)) gnus-newsgroup-limit)
6307 (defsubst gnus-cut-thread (thread)
6308 "Go forwards in the thread until we find an article that we want to display."
6309 (when (or (eq gnus-fetch-old-headers 'some)
6310 (eq gnus-fetch-old-headers 'invisible)
6311 (eq gnus-build-sparse-threads 'some)
6312 (eq gnus-build-sparse-threads 'more))
6313 ;; Deal with old-fetched headers and sparse threads.
6317 (gnus-summary-article-sparse-p (mail-header-number (car thread)))
6318 (gnus-summary-article-ancient-p
6319 (mail-header-number (car thread))))
6320 (if (or (<= (length (cdr thread)) 1)
6321 (eq gnus-fetch-old-headers 'invisible))
6322 (setq gnus-newsgroup-limit
6323 (delq (mail-header-number (car thread))
6324 gnus-newsgroup-limit)
6325 thread (cadr thread))
6326 (when (gnus-invisible-cut-children (cdr thread))
6327 (let ((th (cdr thread)))
6329 (if (memq (mail-header-number (caar th))
6330 gnus-newsgroup-limit)
6331 (setq thread (car th)
6333 (setq th (cdr th))))))))))
6336 (defun gnus-cut-threads (threads)
6337 "Cut off all uninteresting articles from the beginning of threads."
6338 (when (or (eq gnus-fetch-old-headers 'some)
6339 (eq gnus-fetch-old-headers 'invisible)
6340 (eq gnus-build-sparse-threads 'some)
6341 (eq gnus-build-sparse-threads 'more))
6344 (setcar th (gnus-cut-thread (car th)))
6345 (setq th (cdr th)))))
6346 ;; Remove nixed out threads.
6349 (defun gnus-summary-initial-limit (&optional show-if-empty)
6350 "Figure out what the initial limit is supposed to be on group entry.
6351 This entails weeding out unwanted dormants, low-scored articles,
6352 fetch-old-headers verbiage, and so on."
6353 ;; Most groups have nothing to remove.
6354 (if (or gnus-inhibit-limiting
6355 (and (null gnus-newsgroup-dormant)
6356 (not (eq gnus-fetch-old-headers 'some))
6357 (not (eq gnus-fetch-old-headers 'invisible))
6358 (null gnus-summary-expunge-below)
6359 (not (eq gnus-build-sparse-threads 'some))
6360 (not (eq gnus-build-sparse-threads 'more))
6361 (null gnus-thread-expunge-below)
6362 (not gnus-use-nocem)))
6364 (push gnus-newsgroup-limit gnus-newsgroup-limits)
6365 (setq gnus-newsgroup-limit nil)
6368 (unless (car (symbol-value node))
6369 ;; These threads have no parents -- they are roots.
6370 (let ((nodes (cdr (symbol-value node)))
6373 (if (and gnus-thread-expunge-below
6374 (< (gnus-thread-total-score (car nodes))
6375 gnus-thread-expunge-below))
6376 (gnus-expunge-thread (pop nodes))
6377 (setq thread (pop nodes))
6378 (gnus-summary-limit-children thread))))))
6379 gnus-newsgroup-dependencies)
6380 ;; If this limitation resulted in an empty group, we might
6381 ;; pop the previous limit and use it instead.
6382 (when (and (not gnus-newsgroup-limit)
6384 (setq gnus-newsgroup-limit (pop gnus-newsgroup-limits)))
6385 gnus-newsgroup-limit))
6387 (defun gnus-summary-limit-children (thread)
6388 "Return 1 if this subthread is visible and 0 if it is not."
6389 ;; First we get the number of visible children to this thread. This
6390 ;; is done by recursing down the thread using this function, so this
6391 ;; will really go down to a leaf article first, before slowly
6392 ;; working its way up towards the root.
6396 (apply '+ (mapcar 'gnus-summary-limit-children
6399 (number (mail-header-number (car thread)))
6402 (not (memq number gnus-newsgroup-marked))
6404 ;; If this article is dormant and has absolutely no visible
6405 ;; children, then this article isn't visible.
6406 (and (memq number gnus-newsgroup-dormant)
6408 ;; If this is "fetch-old-headered" and there is no
6409 ;; visible children, then we don't want this article.
6410 (and (eq gnus-fetch-old-headers 'some)
6411 (gnus-summary-article-ancient-p number)
6413 ;; If this is "fetch-old-headered" and `invisible', then
6414 ;; we don't want this article.
6415 (and (eq gnus-fetch-old-headers 'invisible)
6416 (gnus-summary-article-ancient-p number))
6417 ;; If this is a sparsely inserted article with no children,
6418 ;; we don't want it.
6419 (and (eq gnus-build-sparse-threads 'some)
6420 (gnus-summary-article-sparse-p number)
6422 ;; If we use expunging, and this article is really
6423 ;; low-scored, then we don't want this article.
6424 (when (and gnus-summary-expunge-below
6426 (or (cdr (assq number gnus-newsgroup-scored))
6427 gnus-summary-default-score))
6428 gnus-summary-expunge-below))
6429 ;; We increase the expunge-tally here, but that has
6430 ;; nothing to do with the limits, really.
6431 (incf gnus-newsgroup-expunged-tally)
6432 ;; We also mark as read here, if that's wanted.
6433 (when (and gnus-summary-mark-below
6434 (< score gnus-summary-mark-below))
6435 (setq gnus-newsgroup-unreads
6436 (delq number gnus-newsgroup-unreads))
6437 (if gnus-newsgroup-auto-expire
6438 (push number gnus-newsgroup-expirable)
6439 (push (cons number gnus-low-score-mark)
6440 gnus-newsgroup-reads)))
6442 ;; Check NoCeM things.
6443 (if (and gnus-use-nocem
6444 (gnus-nocem-unwanted-article-p
6445 (mail-header-id (car thread))))
6447 (setq gnus-newsgroup-unreads
6448 (delq number gnus-newsgroup-unreads))
6450 ;; Nope, invisible article.
6452 ;; Ok, this article is to be visible, so we add it to the limit
6454 (push number gnus-newsgroup-limit)
6457 (defun gnus-expunge-thread (thread)
6458 "Mark all articles in THREAD as read."
6459 (let* ((number (mail-header-number (car thread))))
6460 (incf gnus-newsgroup-expunged-tally)
6461 ;; We also mark as read here, if that's wanted.
6462 (setq gnus-newsgroup-unreads
6463 (delq number gnus-newsgroup-unreads))
6464 (if gnus-newsgroup-auto-expire
6465 (push number gnus-newsgroup-expirable)
6466 (push (cons number gnus-low-score-mark)
6467 gnus-newsgroup-reads)))
6468 ;; Go recursively through all subthreads.
6469 (mapcar 'gnus-expunge-thread (cdr thread)))
6471 ;; Summary article oriented commands
6473 (defun gnus-summary-refer-parent-article (n)
6474 "Refer parent article N times.
6475 If N is negative, go to ancestor -N instead.
6476 The difference between N and the number of articles fetched is returned."
6480 (when (not (natnump n))
6485 (setq header (gnus-summary-article-header))
6486 (if (and (eq (mail-header-number header)
6487 (cdr gnus-article-current))
6488 (equal gnus-newsgroup-name
6489 (car gnus-article-current)))
6490 ;; If we try to find the parent of the currently
6491 ;; displayed article, then we take a look at the actual
6492 ;; References header, since this is slightly more
6493 ;; reliable than the References field we got from the
6496 (set-buffer gnus-original-article-buffer)
6497 (nnheader-narrow-to-headers)
6498 (unless (setq ref (message-fetch-field "references"))
6499 (setq ref (message-fetch-field "in-reply-to")))
6502 ;; It's not the current article, so we take a bet on
6503 ;; the value we got from the server.
6504 (mail-header-references header)))
6506 (not (equal ref "")))
6507 (unless (gnus-summary-refer-article (gnus-parent-id ref skip))
6508 (gnus-message 1 "Couldn't find parent"))
6509 (gnus-message 1 "No references in article %d"
6510 (gnus-summary-article-number))
6513 (gnus-summary-position-point)
6516 (defun gnus-summary-refer-references ()
6517 "Fetch all articles mentioned in the References header.
6518 Return the number of articles fetched."
6520 (let ((ref (mail-header-references (gnus-summary-article-header)))
6521 (current (gnus-summary-article-number))
6525 (error "No References in the current article")
6526 ;; For each Message-ID in the References header...
6527 (while (string-match "<[^>]*>" ref)
6529 ;; ... fetch that article.
6530 (gnus-summary-refer-article
6531 (prog1 (match-string 0 ref)
6532 (setq ref (substring ref (match-end 0))))))
6533 (gnus-summary-goto-subject current)
6534 (gnus-summary-position-point)
6537 (defun gnus-summary-refer-thread (&optional limit)
6538 "Fetch all articles in the current thread.
6539 If LIMIT (the numerical prefix), fetch that many old headers instead
6540 of what's specified by the `gnus-refer-thread-limit' variable."
6542 (let ((id (mail-header-id (gnus-summary-article-header)))
6543 (limit (if limit (prefix-numeric-value limit)
6544 gnus-refer-thread-limit)))
6545 ;; We want to fetch LIMIT *old* headers, but we also have to
6546 ;; re-fetch all the headers in the current buffer, because many of
6547 ;; them may be undisplayed. So we adjust LIMIT.
6548 (when (numberp limit)
6549 (incf limit (- gnus-newsgroup-end gnus-newsgroup-begin)))
6550 (unless (eq gnus-fetch-old-headers 'invisible)
6551 (gnus-message 5 "Fetching headers for %s..." gnus-newsgroup-name)
6552 ;; Retrieve the headers and read them in.
6553 (if (eq (gnus-retrieve-headers
6554 (list gnus-newsgroup-end) gnus-newsgroup-name limit)
6556 (gnus-build-all-threads)
6557 (error "Can't fetch thread from backends that don't support NOV"))
6558 (gnus-message 5 "Fetching headers for %s...done" gnus-newsgroup-name))
6559 (gnus-summary-limit-include-thread id)))
6561 (defun gnus-summary-refer-article (message-id &optional arg)
6562 "Fetch an article specified by MESSAGE-ID.
6563 If ARG (the prefix), fetch the article using `gnus-refer-article-method'
6564 or `gnus-select-method', no matter what backend the article comes from."
6565 (interactive "sMessage-ID: \nP")
6566 (when (and (stringp message-id)
6567 (not (zerop (length message-id))))
6568 ;; Construct the correct Message-ID if necessary.
6569 ;; Suggested by tale@pawl.rpi.edu.
6570 (unless (string-match "^<" message-id)
6571 (setq message-id (concat "<" message-id)))
6572 (unless (string-match ">$" message-id)
6573 (setq message-id (concat message-id ">")))
6574 (let* ((header (gnus-id-to-header message-id))
6576 (gnus-summary-article-sparse-p
6577 (mail-header-number header))
6578 (memq (mail-header-number header)
6579 gnus-newsgroup-limit))))
6581 ;; If the article is present in the buffer we just go to it.
6583 (or (not (gnus-summary-article-sparse-p
6584 (mail-header-number header)))
6587 (gnus-summary-goto-article
6588 (mail-header-number header) nil t)
6590 (gnus-summary-update-article (mail-header-number header)))))
6592 ;; We fetch the article
6593 (let ((gnus-override-method
6594 (cond ((gnus-news-group-p gnus-newsgroup-name)
6595 gnus-refer-article-method)
6597 (or gnus-refer-article-method gnus-select-method))
6600 ;; Start the special refer-article method, if necessary.
6601 (when (and gnus-refer-article-method
6602 (gnus-news-group-p gnus-newsgroup-name))
6603 (gnus-check-server gnus-refer-article-method))
6604 ;; Fetch the header, and display the article.
6605 (if (setq number (gnus-summary-insert-subject message-id))
6606 (gnus-summary-select-article nil nil nil number)
6607 (gnus-message 3 "Couldn't fetch article %s" message-id))))))))
6609 (defun gnus-summary-edit-parameters ()
6610 "Edit the group parameters of the current group."
6612 (gnus-group-edit-group gnus-newsgroup-name 'params))
6614 (defun gnus-summary-customize-parameters ()
6615 "Customize the group parameters of the current group."
6617 (gnus-group-customize gnus-newsgroup-name))
6619 (defun gnus-summary-enter-digest-group (&optional force)
6620 "Enter an nndoc group based on the current article.
6621 If FORCE, force a digest interpretation. If not, try
6622 to guess what the document format is."
6624 (let ((conf gnus-current-window-configuration))
6626 (gnus-summary-select-article))
6627 (setq gnus-current-window-configuration conf)
6628 (let* ((name (format "%s-%d"
6629 (gnus-group-prefixed-name
6630 gnus-newsgroup-name (list 'nndoc ""))
6632 (set-buffer gnus-summary-buffer)
6633 gnus-current-article)))
6634 (ogroup gnus-newsgroup-name)
6635 (params (append (gnus-info-params (gnus-get-info ogroup))
6636 (list (cons 'to-group ogroup))
6637 (list (cons 'save-article-group ogroup))))
6638 (case-fold-search t)
6639 (buf (current-buffer))
6642 (setq dig (nnheader-set-temp-buffer " *gnus digest buffer*"))
6643 (insert-buffer-substring gnus-original-article-buffer)
6644 ;; Remove lines that may lead nndoc to misinterpret the
6647 (goto-char (point-min))
6648 (or (search-forward "\n\n" nil t) (point)))
6649 (goto-char (point-min))
6650 (delete-matching-lines "^\\(Path\\):\\|^From ")
6653 (if (gnus-group-read-ephemeral-group
6654 name `(nndoc ,name (nndoc-address ,(get-buffer dig))
6656 ,(if force 'digest 'guess))) t)
6657 ;; Make all postings to this group go to the parent group.
6658 (nconc (gnus-info-params (gnus-get-info name))
6660 ;; Couldn't select this doc group.
6661 (switch-to-buffer buf)
6662 (gnus-set-global-variables)
6663 (gnus-configure-windows 'summary)
6664 (gnus-message 3 "Article couldn't be entered?"))
6665 (kill-buffer dig)))))
6667 (defun gnus-summary-read-document (n)
6668 "Open a new group based on the current article(s).
6669 This will allow you to read digests and other similar
6670 documents as newsgroups.
6671 Obeys the standard process/prefix convention."
6673 (let* ((articles (gnus-summary-work-articles n))
6674 (ogroup gnus-newsgroup-name)
6675 (params (append (gnus-info-params (gnus-get-info ogroup))
6676 (list (cons 'to-group ogroup))))
6677 article group egroup groups vgroup)
6678 (while (setq article (pop articles))
6679 (setq group (format "%s-%d" gnus-newsgroup-name article))
6680 (gnus-summary-remove-process-mark article)
6681 (when (gnus-summary-display-article article)
6684 (insert-buffer-substring gnus-original-article-buffer)
6685 ;; Remove some headers that may lead nndoc to make
6687 (message-narrow-to-head)
6688 (goto-char (point-min))
6689 (delete-matching-lines "^\\(Path\\):\\|^From ")
6692 (gnus-group-read-ephemeral-group
6693 group `(nndoc ,group (nndoc-address ,(current-buffer))
6694 (nndoc-article-type guess))
6697 ;; Make all postings to this group go to the parent group.
6698 (nconc (gnus-info-params (gnus-get-info egroup))
6700 (push egroup groups))
6701 ;; Couldn't select this doc group.
6702 (gnus-error 3 "Article couldn't be entered"))))))
6703 ;; Now we have selected all the documents.
6706 (error "None of the articles could be interpreted as documents"))
6707 ((gnus-group-read-ephemeral-group
6708 (setq vgroup (format
6709 "nnvirtual:%s-%s" gnus-newsgroup-name
6710 (format-time-string "%Y%m%dT%H%M%S" (current-time))))
6711 `(nnvirtual ,vgroup (nnvirtual-component-groups ,groups))
6713 (cons (current-buffer) 'summary)))
6715 (error "Couldn't select virtual nndoc group")))))
6717 (defun gnus-summary-isearch-article (&optional regexp-p)
6718 "Do incremental search forward on the current article.
6719 If REGEXP-P (the prefix) is non-nil, do regexp isearch."
6721 (gnus-summary-select-article)
6722 (gnus-configure-windows 'article)
6723 (gnus-eval-in-buffer-window gnus-article-buffer
6726 (isearch-forward regexp-p))))
6728 (defun gnus-summary-search-article-forward (regexp &optional backward)
6729 "Search for an article containing REGEXP forward.
6730 If BACKWARD, search backward instead."
6733 (format "Search article %s (regexp%s): "
6734 (if current-prefix-arg "backward" "forward")
6735 (if gnus-last-search-regexp
6736 (concat ", default " gnus-last-search-regexp)
6738 current-prefix-arg))
6739 (if (string-equal regexp "")
6740 (setq regexp (or gnus-last-search-regexp ""))
6741 (setq gnus-last-search-regexp regexp))
6742 (if (gnus-summary-search-article regexp backward)
6743 (gnus-summary-show-thread)
6744 (error "Search failed: \"%s\"" regexp)))
6746 (defun gnus-summary-search-article-backward (regexp)
6747 "Search for an article containing REGEXP backward."
6750 (format "Search article backward (regexp%s): "
6751 (if gnus-last-search-regexp
6752 (concat ", default " gnus-last-search-regexp)
6754 (gnus-summary-search-article-forward regexp 'backward))
6756 (defun gnus-summary-search-article (regexp &optional backward)
6757 "Search for an article containing REGEXP.
6758 Optional argument BACKWARD means do search for backward.
6759 `gnus-select-article-hook' is not called during the search."
6760 ;; We have to require this here to make sure that the following
6761 ;; dynamic binding isn't shadowed by autoloading.
6762 (require 'gnus-async)
6764 (let ((gnus-select-article-hook nil) ;Disable hook.
6765 (gnus-article-display-hook nil)
6766 (gnus-mark-article-hook nil) ;Inhibit marking as read.
6767 (gnus-use-article-prefetch nil)
6768 (gnus-xmas-force-redisplay nil) ;Inhibit XEmacs redisplay.
6769 (gnus-use-trees nil) ;Inhibit updating tree buffer.
6770 (sum (current-buffer))
6773 (gnus-save-hidden-threads
6774 (gnus-summary-select-article)
6775 (set-buffer gnus-article-buffer)
6779 (gnus-message 7 "Searching article: %d..." (cdr gnus-article-current))
6781 (re-search-backward regexp nil t)
6782 (re-search-forward regexp nil t))
6783 ;; We found the regexp.
6788 (get-buffer-window (current-buffer))
6792 (setq point (point)))
6793 ;; We didn't find it, so we go to the next article.
6796 (while (eq found 'not)
6797 (if (not (if backward (gnus-summary-find-prev)
6798 (gnus-summary-find-next)))
6799 ;; No more articles.
6801 ;; Select the next article and adjust point.
6802 (unless (gnus-summary-article-sparse-p
6803 (gnus-summary-article-number))
6805 (gnus-summary-select-article)
6806 (set-buffer gnus-article-buffer)
6808 (goto-char (if backward (point-max) (point-min))))))))
6809 (gnus-message 7 ""))
6810 ;; Return whether we found the regexp.
6811 (when (eq found 'found)
6813 (gnus-summary-show-thread)
6814 (gnus-summary-goto-subject gnus-current-article)
6815 (gnus-summary-position-point)
6818 (defun gnus-summary-find-matching (header regexp &optional backward unread
6820 "Return a list of all articles that match REGEXP on HEADER.
6821 The search stars on the current article and goes forwards unless
6822 BACKWARD is non-nil. If BACKWARD is `all', do all articles.
6823 If UNREAD is non-nil, only unread articles will
6824 be taken into consideration. If NOT-CASE-FOLD, case won't be folded
6825 in the comparisons."
6826 (let ((data (if (eq backward 'all) gnus-newsgroup-data
6827 (gnus-data-find-list
6828 (gnus-summary-article-number) (gnus-data-list backward))))
6829 (func `(lambda (h) (,(intern (concat "mail-header-" header)) h)))
6830 (case-fold-search (not not-case-fold))
6832 (unless (fboundp (intern (concat "mail-header-" header)))
6833 (error "%s is not a valid header" header))
6836 (and (or (not unread) ; We want all articles...
6837 (gnus-data-unread-p d)) ; Or just unreads.
6838 (vectorp (gnus-data-header d)) ; It's not a pseudo.
6839 (string-match regexp (funcall func (gnus-data-header d))) ; Match.
6840 (push (gnus-data-number d) articles)) ; Success!
6841 (setq data (cdr data)))
6842 (nreverse articles)))
6844 (defun gnus-summary-execute-command (header regexp command &optional backward)
6845 "Search forward for an article whose HEADER matches REGEXP and execute COMMAND.
6846 If HEADER is an empty string (or nil), the match is done on the entire
6847 article. If BACKWARD (the prefix) is non-nil, search backward instead."
6849 (list (let ((completion-ignore-case t))
6852 (mapcar (lambda (string) (list string))
6853 '("Number" "Subject" "From" "Lines" "Date"
6854 "Message-ID" "Xref" "References" "Body"))
6855 nil 'require-match))
6856 (read-string "Regexp: ")
6857 (read-key-sequence "Command: ")
6858 current-prefix-arg))
6859 (when (equal header "Body")
6861 ;; Hidden thread subtrees must be searched as well.
6862 (gnus-summary-show-all-threads)
6863 ;; We don't want to change current point nor window configuration.
6865 (save-window-excursion
6866 (gnus-message 6 "Executing %s..." (key-description command))
6867 ;; We'd like to execute COMMAND interactively so as to give arguments.
6868 (gnus-execute header regexp
6869 `(call-interactively ',(key-binding command))
6871 (gnus-message 6 "Executing %s...done" (key-description command)))))
6873 (defun gnus-summary-beginning-of-article ()
6874 "Scroll the article back to the beginning."
6876 (gnus-summary-select-article)
6877 (gnus-configure-windows 'article)
6878 (gnus-eval-in-buffer-window gnus-article-buffer
6880 (goto-char (point-min))
6881 (when gnus-page-broken
6882 (gnus-narrow-to-page))))
6884 (defun gnus-summary-end-of-article ()
6885 "Scroll to the end of the article."
6887 (gnus-summary-select-article)
6888 (gnus-configure-windows 'article)
6889 (gnus-eval-in-buffer-window gnus-article-buffer
6891 (goto-char (point-max))
6893 (when gnus-page-broken
6894 (gnus-narrow-to-page))))
6896 (defun gnus-summary-print-article (&optional filename n)
6897 "Generate and print a PostScript image of the N next (mail) articles.
6899 If N is negative, print the N previous articles. If N is nil and articles
6900 have been marked with the process mark, print these instead.
6902 If the optional first argument FILENAME is nil, send the image to the
6903 printer. If FILENAME is a string, save the PostScript image in a file with
6904 that name. If FILENAME is a number, prompt the user for the name of the file
6906 (interactive (list (ps-print-preprint current-prefix-arg)
6907 current-prefix-arg))
6908 (dolist (article (gnus-summary-work-articles n))
6909 (gnus-summary-select-article nil nil 'pseudo article)
6910 (gnus-eval-in-buffer-window gnus-article-buffer
6911 (let ((buffer (generate-new-buffer " *print*")))
6914 (copy-to-buffer buffer (point-min) (point-max))
6916 (gnus-article-delete-invisible-text)
6917 (let ((ps-left-header
6920 (mail-header-subject gnus-current-headers) ")")
6922 (mail-header-from gnus-current-headers) ")")))
6925 "/pagenumberstring load"
6927 (mail-header-date gnus-current-headers) ")"))))
6928 (gnus-run-hooks 'gnus-ps-print-hook)
6930 (ps-print-buffer-with-faces filename))))
6931 (kill-buffer buffer))))))
6933 (defun gnus-summary-show-article (&optional arg)
6934 "Force re-fetching of the current article.
6935 If ARG (the prefix) is non-nil, show the raw article without any
6936 article massaging functions being run."
6939 ;; Select the article the normal way.
6940 (gnus-summary-select-article nil 'force)
6941 ;; We have to require this here to make sure that the following
6942 ;; dynamic binding isn't shadowed by autoloading.
6943 (require 'gnus-async)
6945 ;; Bind the article treatment functions to nil.
6946 (let ((gnus-have-all-headers t)
6947 gnus-article-display-hook
6948 gnus-article-prepare-hook
6949 gnus-article-decode-hook
6953 (gnus-summary-select-article nil 'force)))
6954 (gnus-summary-goto-subject gnus-current-article)
6955 (gnus-summary-position-point))
6957 (defun gnus-summary-verbose-headers (&optional arg)
6958 "Toggle permanent full header display.
6959 If ARG is a positive number, turn header display on.
6960 If ARG is a negative number, turn header display off."
6962 (setq gnus-show-all-headers
6963 (cond ((or (not (numberp arg))
6965 (not gnus-show-all-headers))
6968 (gnus-summary-show-article))
6970 (defun gnus-summary-toggle-header (&optional arg)
6971 "Show the headers if they are hidden, or hide them if they are shown.
6972 If ARG is a positive number, show the entire header.
6973 If ARG is a negative number, hide the unwanted header lines."
6976 (set-buffer gnus-article-buffer)
6977 (let* ((buffer-read-only nil)
6978 (inhibit-point-motion-hooks t)
6979 (hidden (gnus-article-hidden-text-p 'headers))
6981 (goto-char (point-min))
6982 (when (search-forward "\n\n" nil t)
6983 (delete-region (point-min) (1- (point))))
6984 (goto-char (point-min))
6986 (set-buffer gnus-original-article-buffer)
6987 (goto-char (point-min))
6988 (setq e (1- (or (search-forward "\n\n" nil t) (point-max)))))
6989 (insert-buffer-substring gnus-original-article-buffer 1 e)
6990 (let ((article-inhibit-hiding t))
6991 (gnus-run-hooks 'gnus-article-display-hook))
6993 (and (numberp arg) (< arg 0)))
6994 (let ((gnus-treat-hide-headers nil)
6995 (gnus-treat-hide-boring-headers nil))
6996 (gnus-treat-article 'head))
6997 (gnus-treat-article 'head)))))
6999 (defun gnus-summary-show-all-headers ()
7000 "Make all header lines visible."
7002 (gnus-article-show-all-headers))
7004 (defun gnus-summary-toggle-mime (&optional arg)
7005 "Toggle MIME processing.
7006 If ARG is a positive number, turn MIME processing on."
7008 (setq gnus-show-mime
7010 (not gnus-show-mime)
7011 (> (prefix-numeric-value arg) 0)))
7012 (gnus-summary-select-article t 'force))
7014 (defun gnus-summary-caesar-message (&optional arg)
7015 "Caesar rotate the current article by 13.
7016 The numerical prefix specifies how many places to rotate each letter
7019 (gnus-summary-select-article)
7020 (let ((mail-header-separator ""))
7021 (gnus-eval-in-buffer-window gnus-article-buffer
7024 (let ((start (window-start))
7026 (message-caesar-buffer-body arg)
7027 (set-window-start (get-buffer-window (current-buffer)) start))))))
7029 (defun gnus-summary-stop-page-breaking ()
7030 "Stop page breaking in the current article."
7032 (gnus-summary-select-article)
7033 (gnus-eval-in-buffer-window gnus-article-buffer
7035 (when (gnus-visual-p 'page-marker)
7036 (let ((buffer-read-only nil))
7037 (gnus-remove-text-with-property 'gnus-prev)
7038 (gnus-remove-text-with-property 'gnus-next))
7039 (setq gnus-page-broken nil))))
7041 (defun gnus-summary-move-article (&optional n to-newsgroup
7042 select-method action)
7043 "Move the current article to a different newsgroup.
7044 If N is a positive number, move the N next articles.
7045 If N is a negative number, move the N previous articles.
7046 If N is nil and any articles have been marked with the process mark,
7047 move those articles instead.
7048 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7049 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7050 re-spool using this method.
7052 For this function to work, both the current newsgroup and the
7053 newsgroup that you want to move to have to support the `request-move'
7054 and `request-accept' functions."
7057 (setq action 'move))
7058 ;; Disable marking as read.
7059 (let (gnus-mark-article-hook)
7060 (save-window-excursion
7061 (gnus-summary-select-article)))
7062 ;; Check whether the source group supports the required functions.
7063 (cond ((and (eq action 'move)
7064 (not (gnus-check-backend-function
7065 'request-move-article gnus-newsgroup-name)))
7066 (error "The current group does not support article moving"))
7067 ((and (eq action 'crosspost)
7068 (not (gnus-check-backend-function
7069 'request-replace-article gnus-newsgroup-name)))
7070 (error "The current group does not support article editing")))
7071 (let ((articles (gnus-summary-work-articles n))
7072 (prefix (gnus-group-real-prefix gnus-newsgroup-name))
7073 (names '((move "Move" "Moving")
7074 (copy "Copy" "Copying")
7075 (crosspost "Crosspost" "Crossposting")))
7076 (copy-buf (save-excursion
7077 (nnheader-set-temp-buffer " *copy article*")))
7078 art-group to-method new-xref article to-groups)
7079 (unless (assq action names)
7080 (error "Unknown action %s" action))
7081 ;; Read the newsgroup name.
7082 (when (and (not to-newsgroup)
7083 (not select-method))
7085 (gnus-read-move-group-name
7086 (cadr (assq action names))
7087 (symbol-value (intern (format "gnus-current-%s-group" action)))
7089 (set (intern (format "gnus-current-%s-group" action)) to-newsgroup))
7090 (setq to-method (or select-method
7091 (gnus-group-name-to-method to-newsgroup)))
7092 ;; Check the method we are to move this article to...
7093 (unless (gnus-check-backend-function
7094 'request-accept-article (car to-method))
7095 (error "%s does not support article copying" (car to-method)))
7096 (unless (gnus-check-server to-method)
7097 (error "Can't open server %s" (car to-method)))
7098 (gnus-message 6 "%s to %s: %s..."
7099 (caddr (assq action names))
7100 (or (car select-method) to-newsgroup) articles)
7102 (setq article (pop articles))
7106 ;; Move the article.
7108 ;; Remove this article from future suppression.
7109 (gnus-dup-unsuppress-article article)
7110 (gnus-request-move-article
7111 article ; Article to move
7112 gnus-newsgroup-name ; From newsgroup
7113 (nth 1 (gnus-find-method-for-group
7114 gnus-newsgroup-name)) ; Server
7115 (list 'gnus-request-accept-article
7116 to-newsgroup (list 'quote select-method)
7117 (not articles) t) ; Accept form
7118 (not articles))) ; Only save nov last time
7119 ;; Copy the article.
7122 (set-buffer copy-buf)
7123 (when (gnus-request-article-this-buffer article gnus-newsgroup-name)
7124 (gnus-request-accept-article
7125 to-newsgroup select-method (not articles) t))))
7126 ;; Crosspost the article.
7127 ((eq action 'crosspost)
7128 (let ((xref (message-tokenize-header
7129 (mail-header-xref (gnus-summary-article-header article))
7131 (setq new-xref (concat (gnus-group-real-name gnus-newsgroup-name)
7134 (setq xref (list (system-name))))
7137 (mapconcat 'identity
7138 (delete "Xref:" (delete new-xref xref))
7142 (set-buffer copy-buf)
7143 ;; First put the article in the destination group.
7144 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7145 (when (consp (setq art-group
7146 (gnus-request-accept-article
7147 to-newsgroup select-method (not articles))))
7148 (setq new-xref (concat new-xref " " (car art-group)
7149 ":" (cdr art-group)))
7150 ;; Now we have the new Xrefs header, so we insert
7151 ;; it and replace the new article.
7152 (nnheader-replace-header "Xref" new-xref)
7153 (gnus-request-replace-article
7154 (cdr art-group) to-newsgroup (current-buffer))
7158 (gnus-message 1 "Couldn't %s article %s"
7159 (cadr (assq action names)) article))
7160 ((and (eq art-group 'junk)
7162 (gnus-summary-mark-article article gnus-canceled-mark)
7163 (gnus-message 4 "Deleted article %s" article))
7165 (let* ((pto-group (gnus-group-prefixed-name
7166 (car art-group) to-method))
7168 (gnus-gethash pto-group gnus-newsrc-hashtb))
7169 (info (nth 2 entry))
7170 (to-group (gnus-info-group info)))
7171 ;; Update the group that has been moved to.
7173 (memq action '(move copy)))
7174 (unless (member to-group to-groups)
7175 (push to-group to-groups))
7177 (unless (memq article gnus-newsgroup-unreads)
7179 info (gnus-add-to-range (gnus-info-read info)
7180 (list (cdr art-group)))))
7182 ;; Copy any marks over to the new group.
7183 (let ((marks gnus-article-mark-lists)
7184 (to-article (cdr art-group)))
7185 (unless (gnus-group-auto-expirable-p to-group)
7186 (setq marks (delete '(expirable . expire) marks)))
7188 ;; See whether the article is to be put in the cache.
7189 (when gnus-use-cache
7190 (gnus-cache-possibly-enter-article
7192 (let ((header (copy-sequence
7193 (gnus-summary-article-header article))))
7194 (mail-header-set-number header to-article)
7196 (memq article gnus-newsgroup-marked)
7197 (memq article gnus-newsgroup-dormant)
7198 (memq article gnus-newsgroup-unreads)))
7200 (when (and (equal to-group gnus-newsgroup-name)
7201 (not (memq article gnus-newsgroup-unreads)))
7202 ;; Mark this article as read in this group.
7203 (push (cons to-article gnus-read-mark) gnus-newsgroup-reads)
7204 (setcdr (gnus-active to-group) to-article)
7205 (setcdr gnus-newsgroup-active to-article))
7208 (when (memq article (symbol-value
7209 (intern (format "gnus-newsgroup-%s"
7211 ;; If the other group is the same as this group,
7212 ;; then we have to add the mark to the list.
7213 (when (equal to-group gnus-newsgroup-name)
7214 (set (intern (format "gnus-newsgroup-%s" (caar marks)))
7217 (intern (format "gnus-newsgroup-%s"
7219 ;; Copy the marks to other group.
7220 (gnus-add-marked-articles
7221 to-group (cdar marks) (list to-article) info))
7222 (setq marks (cdr marks)))
7225 (concat "(gnus-group-set-info '"
7226 (gnus-prin1-to-string (gnus-get-info to-group))
7229 ;; Update the Xref header in this article to point to
7230 ;; the new crossposted article we have just created.
7231 (when (eq action 'crosspost)
7233 (set-buffer copy-buf)
7234 (gnus-request-article-this-buffer article gnus-newsgroup-name)
7235 (nnheader-replace-header "Xref" new-xref)
7236 (gnus-request-replace-article
7237 article gnus-newsgroup-name (current-buffer)))))
7239 ;;;!!!Why is this necessary?
7240 (set-buffer gnus-summary-buffer)
7242 (gnus-summary-goto-subject article)
7243 (when (eq action 'move)
7244 (gnus-summary-mark-article article gnus-canceled-mark))))
7245 (gnus-summary-remove-process-mark article))
7246 ;; Re-activate all groups that have been moved to.
7249 (set-buffer gnus-group-buffer)
7250 (when (gnus-group-goto-group (car to-groups) t)
7251 (gnus-group-get-new-news-this-group 1 t))
7254 (gnus-kill-buffer copy-buf)
7255 (gnus-summary-position-point)
7256 (gnus-set-mode-line 'summary)))
7258 (defun gnus-summary-copy-article (&optional n to-newsgroup select-method)
7259 "Move the current article to a different newsgroup.
7260 If TO-NEWSGROUP is string, do not prompt for a newsgroup to move to.
7261 If SELECT-METHOD is non-nil, do not move to a specific newsgroup, but
7262 re-spool using this method."
7264 (gnus-summary-move-article n to-newsgroup select-method 'copy))
7266 (defun gnus-summary-crosspost-article (&optional n)
7267 "Crosspost the current article to some other group."
7269 (gnus-summary-move-article n nil nil 'crosspost))
7271 (defcustom gnus-summary-respool-default-method nil
7272 "Default method for respooling an article.
7273 If nil, use to the current newsgroup method."
7274 :type '(choice (gnus-select-method :value (nnml ""))
7276 :group 'gnus-summary-mail)
7278 (defun gnus-summary-respool-article (&optional n method)
7279 "Respool the current article.
7280 The article will be squeezed through the mail spooling process again,
7281 which means that it will be put in some mail newsgroup or other
7282 depending on `nnmail-split-methods'.
7283 If N is a positive number, respool the N next articles.
7284 If N is a negative number, respool the N previous articles.
7285 If N is nil and any articles have been marked with the process mark,
7286 respool those articles instead.
7288 Respooling can be done both from mail groups and \"real\" newsgroups.
7289 In the former case, the articles in question will be moved from the
7290 current group into whatever groups they are destined to. In the
7291 latter case, they will be copied into the relevant groups."
7293 (list current-prefix-arg
7294 (let* ((methods (gnus-methods-using 'respool))
7296 (symbol-name (or gnus-summary-respool-default-method
7297 (car (gnus-find-method-for-group
7298 gnus-newsgroup-name)))))
7300 (gnus-completing-read
7301 methname "What backend do you want to use when respooling?"
7302 methods nil t nil 'gnus-mail-method-history))
7305 ((zerop (length (setq ms (gnus-servers-using-backend
7307 (list (intern method) ""))
7311 (let ((ms-alist (mapcar (lambda (m) (cons (cadr m) m)) ms)))
7312 (cdr (assoc (completing-read "Server name: " ms-alist nil t)
7315 (error "No method given for respooling"))
7316 (if (assoc (symbol-name
7317 (car (gnus-find-method-for-group gnus-newsgroup-name)))
7318 (gnus-methods-using 'respool))
7319 (gnus-summary-move-article n nil method)
7320 (gnus-summary-copy-article n nil method)))
7322 (defun gnus-summary-import-article (file)
7323 "Import an arbitrary file into a mail newsgroup."
7324 (interactive "fImport file: ")
7325 (let ((group gnus-newsgroup-name)
7326 (now (current-time))
7328 (unless (gnus-check-backend-function 'request-accept-article group)
7329 (error "%s does not support article importing" group))
7330 (or (file-readable-p file)
7331 (not (file-regular-p file))
7332 (error "Can't read %s" file))
7334 (set-buffer (gnus-get-buffer-create " *import file*"))
7336 (nnheader-insert-file-contents file)
7337 (goto-char (point-min))
7338 (unless (nnheader-article-p)
7339 ;; This doesn't look like an article, so we fudge some headers.
7340 (setq atts (file-attributes file)
7341 lines (count-lines (point-min) (point-max)))
7342 (insert "From: " (read-string "From: ") "\n"
7343 "Subject: " (read-string "Subject: ") "\n"
7344 "Date: " (message-make-date (nth 5 atts))
7346 "Message-ID: " (message-make-message-id) "\n"
7347 "Lines: " (int-to-string lines) "\n"
7348 "Chars: " (int-to-string (nth 7 atts)) "\n\n"))
7349 (gnus-request-accept-article group nil t)
7350 (kill-buffer (current-buffer)))))
7352 (defun gnus-summary-article-posted-p ()
7353 "Say whether the current (mail) article is available from `gnus-select-method' as well.
7354 This will be the case if the article has both been mailed and posted."
7356 (let ((id (mail-header-references (gnus-summary-article-header)))
7357 (gnus-override-method
7358 (or gnus-refer-article-method gnus-select-method)))
7359 (if (gnus-request-head id "")
7360 (gnus-message 2 "The current message was found on %s"
7361 gnus-override-method)
7362 (gnus-message 2 "The current message couldn't be found on %s"
7363 gnus-override-method)
7366 (defun gnus-summary-expire-articles (&optional now)
7367 "Expire all articles that are marked as expirable in the current group."
7369 (when (gnus-check-backend-function
7370 'request-expire-articles gnus-newsgroup-name)
7371 ;; This backend supports expiry.
7372 (let* ((total (gnus-group-total-expirable-p gnus-newsgroup-name))
7373 (expirable (if total
7375 ;; We need to update the info for
7376 ;; this group for `gnus-list-of-read-articles'
7377 ;; to give us the right answer.
7378 (gnus-run-hooks 'gnus-exit-group-hook)
7379 (gnus-summary-update-info)
7380 (gnus-list-of-read-articles gnus-newsgroup-name))
7381 (setq gnus-newsgroup-expirable
7382 (sort gnus-newsgroup-expirable '<))))
7383 (expiry-wait (if now 'immediate
7384 (gnus-group-find-parameter
7385 gnus-newsgroup-name 'expiry-wait)))
7388 ;; There are expirable articles in this group, so we run them
7389 ;; through the expiry process.
7390 (gnus-message 6 "Expiring articles...")
7391 ;; The list of articles that weren't expired is returned.
7394 (let ((nnmail-expiry-wait-function nil)
7395 (nnmail-expiry-wait expiry-wait))
7396 (setq es (gnus-request-expire-articles
7397 expirable gnus-newsgroup-name)))
7398 (setq es (gnus-request-expire-articles
7399 expirable gnus-newsgroup-name))))
7401 (setq gnus-newsgroup-expirable es))
7402 ;; We go through the old list of expirable, and mark all
7403 ;; really expired articles as nonexistent.
7404 (unless (eq es expirable) ;If nothing was expired, we don't mark.
7405 (let ((gnus-use-cache nil))
7407 (unless (memq (car expirable) es)
7408 (when (gnus-data-find (car expirable))
7409 (gnus-summary-mark-article
7410 (car expirable) gnus-canceled-mark)))
7411 (setq expirable (cdr expirable)))))
7412 (gnus-message 6 "Expiring articles...done")))))
7414 (defun gnus-summary-expire-articles-now ()
7415 "Expunge all expirable articles in the current group.
7416 This means that *all* articles that are marked as expirable will be
7417 deleted forever, right now."
7419 (or gnus-expert-user
7421 "Are you really, really, really sure you want to delete all these messages? ")
7423 (gnus-summary-expire-articles t))
7425 ;; Suggested by Jack Vinson <vinson@unagi.cis.upenn.edu>.
7426 (defun gnus-summary-delete-article (&optional n)
7427 "Delete the N next (mail) articles.
7428 This command actually deletes articles. This is not a marking
7429 command. The article will disappear forever from your life, never to
7431 If N is negative, delete backwards.
7432 If N is nil and articles have been marked with the process mark,
7433 delete these instead."
7435 (unless (gnus-check-backend-function 'request-expire-articles
7436 gnus-newsgroup-name)
7437 (error "The current newsgroup does not support article deletion"))
7438 ;; Compute the list of articles to delete.
7439 (let ((articles (sort (copy-sequence (gnus-summary-work-articles n)) '<))
7441 (if (and gnus-novice-user
7442 (not (gnus-yes-or-no-p
7443 (format "Do you really want to delete %s forever? "
7444 (if (> (length articles) 1)
7445 (format "these %s articles" (length articles))
7448 ;; Delete the articles.
7449 (setq not-deleted (gnus-request-expire-articles
7450 articles gnus-newsgroup-name 'force))
7452 (gnus-summary-remove-process-mark (car articles))
7453 ;; The backend might not have been able to delete the article
7455 (unless (memq (car articles) not-deleted)
7456 (gnus-summary-mark-article (car articles) gnus-canceled-mark))
7457 (setq articles (cdr articles)))
7459 (gnus-message 4 "Couldn't delete articles %s" not-deleted)))
7460 (gnus-summary-position-point)
7461 (gnus-set-mode-line 'summary)
7464 (defun gnus-summary-edit-article (&optional force)
7465 "Edit the current article.
7466 This will have permanent effect only in mail groups.
7467 If FORCE is non-nil, allow editing of articles even in read-only
7470 (let ((mail-parse-charset gnus-newsgroup-charset))
7472 (set-buffer gnus-summary-buffer)
7473 (gnus-set-global-variables)
7474 (when (and (not force)
7475 (gnus-group-read-only-p))
7476 (error "The current newsgroup does not support article editing"))
7477 (gnus-summary-show-article t)
7478 (gnus-article-edit-article
7480 `(lambda (no-highlight)
7481 (let ((mail-parse-charset ',gnus-newsgroup-charset))
7483 (gnus-summary-edit-article-done
7484 ,(or (mail-header-references gnus-current-headers) "")
7485 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))))))
7487 (defalias 'gnus-summary-edit-article-postpone 'gnus-article-edit-exit)
7489 (defun gnus-summary-edit-article-done (&optional references read-only buffer
7491 "Make edits to the current article permanent."
7493 ;; Replace the article.
7494 (let ((buf (current-buffer)))
7496 (insert-buffer-substring buf)
7497 (if (and (not read-only)
7498 (not (gnus-request-replace-article
7499 (cdr gnus-article-current) (car gnus-article-current)
7500 (current-buffer) t)))
7501 (error "Couldn't replace article")
7502 ;; Update the summary buffer.
7504 (equal (message-tokenize-header references " ")
7505 (message-tokenize-header
7506 (or (message-fetch-field "references") "") " ")))
7507 ;; We only have to update this line.
7510 (message-narrow-to-head)
7511 (let ((head (buffer-string))
7514 (insert (format "211 %d Article retrieved.\n"
7515 (cdr gnus-article-current)))
7518 (let ((nntp-server-buffer (current-buffer)))
7519 (setq header (car (gnus-get-newsgroup-headers
7521 (set-buffer gnus-summary-buffer)
7522 gnus-newsgroup-dependencies)
7525 (set-buffer gnus-summary-buffer)
7526 (gnus-data-set-header
7527 (gnus-data-find (cdr gnus-article-current))
7529 (gnus-summary-update-article-line
7530 (cdr gnus-article-current) header))))))
7532 (set-buffer (or buffer gnus-summary-buffer))
7533 (gnus-summary-update-article (cdr gnus-article-current)))
7534 ;; Prettify the article buffer again.
7535 (unless no-highlight
7537 (set-buffer gnus-article-buffer)
7538 ;;;!!! Fix this -- article should be rehighlighted.
7539 ;;;(gnus-run-hooks 'gnus-article-display-hook)
7540 (set-buffer gnus-original-article-buffer)
7541 (gnus-request-article
7542 (cdr gnus-article-current)
7543 (car gnus-article-current) (current-buffer))))
7544 ;; Prettify the summary buffer line.
7545 (when (gnus-visual-p 'summary-highlight 'highlight)
7546 (gnus-run-hooks 'gnus-visual-mark-article-hook))))))
7548 (defun gnus-summary-edit-wash (key)
7549 "Perform editing command KEY in the article buffer."
7553 (message "%s" (concat (this-command-keys) "- "))
7556 (gnus-summary-edit-article)
7557 (execute-kbd-macro (concat (this-command-keys) key))
7558 (gnus-article-edit-done))
7562 (defun gnus-summary-respool-query (&optional silent trace)
7563 "Query where the respool algorithm would put this article."
7565 (let (gnus-mark-article-hook)
7566 (gnus-summary-select-article)
7568 (set-buffer gnus-original-article-buffer)
7570 (message-narrow-to-head)
7571 (let ((groups (nnmail-article-group 'identity trace)))
7574 (message "This message would go to %s"
7575 (mapconcat 'car groups ", "))
7576 (message "This message would go to no groups"))
7579 (defun gnus-summary-respool-trace ()
7580 "Trace where the respool algorithm would put this article.
7581 Display a buffer showing all fancy splitting patterns which matched."
7583 (gnus-summary-respool-query nil t))
7585 ;; Summary marking commands.
7587 (defun gnus-summary-kill-same-subject-and-select (&optional unmark)
7588 "Mark articles which has the same subject as read, and then select the next.
7589 If UNMARK is positive, remove any kind of mark.
7590 If UNMARK is negative, tick articles."
7593 (setq unmark (prefix-numeric-value unmark)))
7595 (gnus-summary-mark-same-subject
7596 (gnus-summary-article-subject) unmark)))
7597 ;; Select next unread article. If auto-select-same mode, should
7598 ;; select the first unread article.
7599 (gnus-summary-next-article t (and gnus-auto-select-same
7600 (gnus-summary-article-subject)))
7601 (gnus-message 7 "%d article%s marked as %s"
7602 count (if (= count 1) " is" "s are")
7603 (if unmark "unread" "read"))))
7605 (defun gnus-summary-kill-same-subject (&optional unmark)
7606 "Mark articles which has the same subject as read.
7607 If UNMARK is positive, remove any kind of mark.
7608 If UNMARK is negative, tick articles."
7611 (setq unmark (prefix-numeric-value unmark)))
7613 (gnus-summary-mark-same-subject
7614 (gnus-summary-article-subject) unmark)))
7615 ;; If marked as read, go to next unread subject.
7617 ;; Go to next unread subject.
7618 (gnus-summary-next-subject 1 t))
7619 (gnus-message 7 "%d articles are marked as %s"
7620 count (if unmark "unread" "read"))))
7622 (defun gnus-summary-mark-same-subject (subject &optional unmark)
7623 "Mark articles with same SUBJECT as read, and return marked number.
7624 If optional argument UNMARK is positive, remove any kinds of marks.
7625 If optional argument UNMARK is negative, mark articles as unread instead."
7629 ((null unmark) ; Mark as read.
7632 (gnus-summary-mark-article-as-read gnus-killed-mark)
7633 (gnus-summary-show-thread) t)
7634 (gnus-summary-find-subject subject))
7635 (setq count (1+ count))))
7636 ((> unmark 0) ; Tick.
7639 (gnus-summary-mark-article-as-unread gnus-ticked-mark)
7640 (gnus-summary-show-thread) t)
7641 (gnus-summary-find-subject subject))
7642 (setq count (1+ count))))
7643 (t ; Mark as unread.
7646 (gnus-summary-mark-article-as-unread gnus-unread-mark)
7647 (gnus-summary-show-thread) t)
7648 (gnus-summary-find-subject subject))
7649 (setq count (1+ count)))))
7650 (gnus-set-mode-line 'summary)
7651 ;; Return the number of marked articles.
7654 (defun gnus-summary-mark-as-processable (n &optional unmark)
7655 "Set the process mark on the next N articles.
7656 If N is negative, mark backward instead. If UNMARK is non-nil, remove
7657 the process mark instead. The difference between N and the actual
7658 number of articles marked is returned."
7660 (let ((backward (< n 0))
7665 (gnus-summary-remove-process-mark
7666 (gnus-summary-article-number))
7667 (gnus-summary-set-process-mark (gnus-summary-article-number)))
7668 (zerop (gnus-summary-next-subject (if backward -1 1) nil t)))
7671 (gnus-message 7 "No more articles"))
7672 (gnus-summary-recenter)
7673 (gnus-summary-position-point)
7676 (defun gnus-summary-unmark-as-processable (n)
7677 "Remove the process mark from the next N articles.
7678 If N is negative, unmark backward instead. The difference between N and
7679 the actual number of articles unmarked is returned."
7681 (gnus-summary-mark-as-processable n t))
7683 (defun gnus-summary-unmark-all-processable ()
7684 "Remove the process mark from all articles."
7687 (while gnus-newsgroup-processable
7688 (gnus-summary-remove-process-mark (car gnus-newsgroup-processable))))
7689 (gnus-summary-position-point))
7691 (defun gnus-summary-mark-as-expirable (n)
7692 "Mark N articles forward as expirable.
7693 If N is negative, mark backward instead. The difference between N and
7694 the actual number of articles marked is returned."
7696 (gnus-summary-mark-forward n gnus-expirable-mark))
7698 (defun gnus-summary-mark-article-as-replied (article)
7699 "Mark ARTICLE replied and update the summary line."
7700 (push article gnus-newsgroup-replied)
7701 (let ((buffer-read-only nil))
7702 (when (gnus-summary-goto-subject article nil t)
7703 (gnus-summary-update-secondary-mark article))))
7705 (defun gnus-summary-set-bookmark (article)
7706 "Set a bookmark in current article."
7707 (interactive (list (gnus-summary-article-number)))
7708 (when (or (not (get-buffer gnus-article-buffer))
7709 (not gnus-current-article)
7710 (not gnus-article-current)
7711 (not (equal gnus-newsgroup-name (car gnus-article-current))))
7712 (error "No current article selected"))
7713 ;; Remove old bookmark, if one exists.
7714 (let ((old (assq article gnus-newsgroup-bookmarks)))
7716 (setq gnus-newsgroup-bookmarks
7717 (delq old gnus-newsgroup-bookmarks))))
7718 ;; Set the new bookmark, which is on the form
7719 ;; (article-number . line-number-in-body).
7723 (set-buffer gnus-article-buffer)
7727 (goto-char (point-min))
7728 (search-forward "\n\n" nil t)
7731 gnus-newsgroup-bookmarks)
7732 (gnus-message 6 "A bookmark has been added to the current article."))
7734 (defun gnus-summary-remove-bookmark (article)
7735 "Remove the bookmark from the current article."
7736 (interactive (list (gnus-summary-article-number)))
7737 ;; Remove old bookmark, if one exists.
7738 (let ((old (assq article gnus-newsgroup-bookmarks)))
7741 (setq gnus-newsgroup-bookmarks
7742 (delq old gnus-newsgroup-bookmarks))
7743 (gnus-message 6 "Removed bookmark."))
7744 (gnus-message 6 "No bookmark in current article."))))
7746 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
7747 (defun gnus-summary-mark-as-dormant (n)
7748 "Mark N articles forward as dormant.
7749 If N is negative, mark backward instead. The difference between N and
7750 the actual number of articles marked is returned."
7752 (gnus-summary-mark-forward n gnus-dormant-mark))
7754 (defun gnus-summary-set-process-mark (article)
7755 "Set the process mark on ARTICLE and update the summary line."
7756 (setq gnus-newsgroup-processable
7758 (delq article gnus-newsgroup-processable)))
7759 (when (gnus-summary-goto-subject article)
7760 (gnus-summary-show-thread)
7761 (gnus-summary-goto-subject article)
7762 (gnus-summary-update-secondary-mark article)))
7764 (defun gnus-summary-remove-process-mark (article)
7765 "Remove the process mark from ARTICLE and update the summary line."
7766 (setq gnus-newsgroup-processable (delq article gnus-newsgroup-processable))
7767 (when (gnus-summary-goto-subject article)
7768 (gnus-summary-show-thread)
7769 (gnus-summary-goto-subject article)
7770 (gnus-summary-update-secondary-mark article)))
7772 (defun gnus-summary-set-saved-mark (article)
7773 "Set the process mark on ARTICLE and update the summary line."
7774 (push article gnus-newsgroup-saved)
7775 (when (gnus-summary-goto-subject article)
7776 (gnus-summary-update-secondary-mark article)))
7778 (defun gnus-summary-mark-forward (n &optional mark no-expire)
7779 "Mark N articles as read forwards.
7780 If N is negative, mark backwards instead. Mark with MARK, ?r by default.
7781 The difference between N and the actual number of articles marked is
7784 (gnus-summary-show-thread)
7785 (let ((backward (< n 0))
7786 (gnus-summary-goto-unread
7787 (and gnus-summary-goto-unread
7788 (not (eq gnus-summary-goto-unread 'never))
7789 (not (memq mark (list gnus-unread-mark
7790 gnus-ticked-mark gnus-dormant-mark)))))
7792 (mark (or mark gnus-del-mark)))
7794 (gnus-summary-mark-article nil mark no-expire)
7795 (zerop (gnus-summary-next-subject
7797 (and gnus-summary-goto-unread
7798 (not (eq gnus-summary-goto-unread 'never)))
7802 (gnus-message 7 "No more %sarticles" (if mark "" "unread ")))
7803 (gnus-summary-recenter)
7804 (gnus-summary-position-point)
7805 (gnus-set-mode-line 'summary)
7808 (defun gnus-summary-mark-article-as-read (mark)
7809 "Mark the current article quickly as read with MARK."
7810 (let ((article (gnus-summary-article-number)))
7811 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7812 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7813 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7814 (push (cons article mark) gnus-newsgroup-reads)
7815 ;; Possibly remove from cache, if that is used.
7816 (when gnus-use-cache
7817 (gnus-cache-enter-remove-article article))
7818 ;; Allow the backend to change the mark.
7819 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7820 ;; Check for auto-expiry.
7821 (when (and gnus-newsgroup-auto-expire
7822 (memq mark gnus-auto-expirable-marks))
7823 (setq mark gnus-expirable-mark)
7824 ;; Let the backend know about the mark change.
7825 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7826 (push article gnus-newsgroup-expirable))
7827 ;; Set the mark in the buffer.
7828 (gnus-summary-update-mark mark 'unread)
7831 (defun gnus-summary-mark-article-as-unread (mark)
7832 "Mark the current article quickly as unread with MARK."
7833 (let* ((article (gnus-summary-article-number))
7834 (old-mark (gnus-summary-article-mark article)))
7835 ;; Allow the backend to change the mark.
7836 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7837 (if (eq mark old-mark)
7841 (gnus-error 1 "Can't mark negative article numbers")
7843 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7844 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7845 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable))
7846 (setq gnus-newsgroup-reads (delq article gnus-newsgroup-reads))
7847 (cond ((= mark gnus-ticked-mark)
7848 (push article gnus-newsgroup-marked))
7849 ((= mark gnus-dormant-mark)
7850 (push article gnus-newsgroup-dormant))
7852 (push article gnus-newsgroup-unreads)))
7853 (gnus-pull article gnus-newsgroup-reads)
7855 ;; See whether the article is to be put in the cache.
7857 (vectorp (gnus-summary-article-header article))
7859 (gnus-cache-possibly-enter-article
7860 gnus-newsgroup-name article
7861 (gnus-summary-article-header article)
7862 (= mark gnus-ticked-mark)
7863 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7866 (gnus-summary-update-mark mark 'unread)
7869 (defun gnus-summary-mark-article (&optional article mark no-expire)
7870 "Mark ARTICLE with MARK. MARK can be any character.
7871 Four MARK strings are reserved: `? ' (unread), `?!' (ticked),
7872 `??' (dormant) and `?E' (expirable).
7873 If MARK is nil, then the default character `?r' is used.
7874 If ARTICLE is nil, then the article on the current line will be
7876 ;; The mark might be a string.
7877 (when (stringp mark)
7878 (setq mark (aref mark 0)))
7879 ;; If no mark is given, then we check auto-expiring.
7881 (setq mark gnus-del-mark))
7882 (when (and (not no-expire)
7883 gnus-newsgroup-auto-expire
7884 (memq mark gnus-auto-expirable-marks))
7885 (setq mark gnus-expirable-mark))
7886 (let ((article (or article (gnus-summary-article-number)))
7887 (old-mark (gnus-summary-article-mark article)))
7888 ;; Allow the backend to change the mark.
7889 (setq mark (gnus-request-update-mark gnus-newsgroup-name article mark))
7890 (if (eq mark old-mark)
7893 (error "No article on current line"))
7894 (if (not (if (or (= mark gnus-unread-mark)
7895 (= mark gnus-ticked-mark)
7896 (= mark gnus-dormant-mark))
7897 (gnus-mark-article-as-unread article mark)
7898 (gnus-mark-article-as-read article mark)))
7900 ;; See whether the article is to be put in the cache.
7902 (not (= mark gnus-canceled-mark))
7903 (vectorp (gnus-summary-article-header article))
7905 (gnus-cache-possibly-enter-article
7906 gnus-newsgroup-name article
7907 (gnus-summary-article-header article)
7908 (= mark gnus-ticked-mark)
7909 (= mark gnus-dormant-mark) (= mark gnus-unread-mark))))
7911 (when (gnus-summary-goto-subject article nil t)
7912 (let ((buffer-read-only nil))
7913 (gnus-summary-show-thread)
7915 (gnus-summary-update-mark mark 'unread)
7918 (defun gnus-summary-update-secondary-mark (article)
7919 "Update the secondary (read, process, cache) mark."
7920 (gnus-summary-update-mark
7921 (cond ((memq article gnus-newsgroup-processable)
7923 ((memq article gnus-newsgroup-cached)
7925 ((memq article gnus-newsgroup-replied)
7927 ((memq article gnus-newsgroup-saved)
7929 (t gnus-unread-mark))
7931 (when (gnus-visual-p 'summary-highlight 'highlight)
7932 (gnus-run-hooks 'gnus-summary-update-hook))
7935 (defun gnus-summary-update-mark (mark type)
7936 (let ((forward (cdr (assq type gnus-summary-mark-positions)))
7937 (buffer-read-only nil))
7938 (re-search-backward "[\n\r]" (gnus-point-at-bol) 'move-to-limit)
7940 (when (looking-at "\r")
7942 (when (<= (+ forward (point)) (point-max))
7943 ;; Go to the right position on the line.
7944 (goto-char (+ forward (point)))
7945 ;; Replace the old mark with the new mark.
7946 (subst-char-in-region (point) (1+ (point)) (char-after) mark)
7947 ;; Optionally update the marks by some user rule.
7948 (when (eq type 'unread)
7950 (gnus-data-find (gnus-summary-article-number)) mark)
7951 (gnus-summary-update-line (eq mark gnus-unread-mark)))))))
7953 (defun gnus-mark-article-as-read (article &optional mark)
7954 "Enter ARTICLE in the pertinent lists and remove it from others."
7955 ;; Make the article expirable.
7956 (let ((mark (or mark gnus-del-mark)))
7957 (if (= mark gnus-expirable-mark)
7958 (push article gnus-newsgroup-expirable)
7959 (setq gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)))
7960 ;; Remove from unread and marked lists.
7961 (setq gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7962 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked))
7963 (setq gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant))
7964 (push (cons article mark) gnus-newsgroup-reads)
7965 ;; Possibly remove from cache, if that is used.
7966 (when gnus-use-cache
7967 (gnus-cache-enter-remove-article article))
7970 (defun gnus-mark-article-as-unread (article &optional mark)
7971 "Enter ARTICLE in the pertinent lists and remove it from others."
7972 (let ((mark (or mark gnus-ticked-mark)))
7975 (gnus-error 1 "Can't mark negative article numbers")
7977 (setq gnus-newsgroup-marked (delq article gnus-newsgroup-marked)
7978 gnus-newsgroup-dormant (delq article gnus-newsgroup-dormant)
7979 gnus-newsgroup-expirable (delq article gnus-newsgroup-expirable)
7980 gnus-newsgroup-unreads (delq article gnus-newsgroup-unreads))
7982 ;; Unsuppress duplicates?
7983 (when gnus-suppress-duplicates
7984 (gnus-dup-unsuppress-article article))
7986 (cond ((= mark gnus-ticked-mark)
7987 (push article gnus-newsgroup-marked))
7988 ((= mark gnus-dormant-mark)
7989 (push article gnus-newsgroup-dormant))
7991 (push article gnus-newsgroup-unreads)))
7992 (gnus-pull article gnus-newsgroup-reads)
7995 (defalias 'gnus-summary-mark-as-unread-forward
7996 'gnus-summary-tick-article-forward)
7997 (make-obsolete 'gnus-summary-mark-as-unread-forward
7998 'gnus-summary-tick-article-forward)
7999 (defun gnus-summary-tick-article-forward (n)
8000 "Tick N articles forwards.
8001 If N is negative, tick backwards instead.
8002 The difference between N and the number of articles ticked is returned."
8004 (gnus-summary-mark-forward n gnus-ticked-mark))
8006 (defalias 'gnus-summary-mark-as-unread-backward
8007 'gnus-summary-tick-article-backward)
8008 (make-obsolete 'gnus-summary-mark-as-unread-backward
8009 'gnus-summary-tick-article-backward)
8010 (defun gnus-summary-tick-article-backward (n)
8011 "Tick N articles backwards.
8012 The difference between N and the number of articles ticked is returned."
8014 (gnus-summary-mark-forward (- n) gnus-ticked-mark))
8016 (defalias 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8017 (make-obsolete 'gnus-summary-mark-as-unread 'gnus-summary-tick-article)
8018 (defun gnus-summary-tick-article (&optional article clear-mark)
8019 "Mark current article as unread.
8020 Optional 1st argument ARTICLE specifies article number to be marked as unread.
8021 Optional 2nd argument CLEAR-MARK remove any kinds of mark."
8023 (gnus-summary-mark-article article (if clear-mark gnus-unread-mark
8026 (defun gnus-summary-mark-as-read-forward (n)
8027 "Mark N articles as read forwards.
8028 If N is negative, mark backwards instead.
8029 The difference between N and the actual number of articles marked is
8032 (gnus-summary-mark-forward n gnus-del-mark gnus-inhibit-user-auto-expire))
8034 (defun gnus-summary-mark-as-read-backward (n)
8035 "Mark the N articles as read backwards.
8036 The difference between N and the actual number of articles marked is
8039 (gnus-summary-mark-forward
8040 (- n) gnus-del-mark gnus-inhibit-user-auto-expire))
8042 (defun gnus-summary-mark-as-read (&optional article mark)
8043 "Mark current article as read.
8044 ARTICLE specifies the article to be marked as read.
8045 MARK specifies a string to be inserted at the beginning of the line."
8046 (gnus-summary-mark-article article mark))
8048 (defun gnus-summary-clear-mark-forward (n)
8049 "Clear marks from N articles forward.
8050 If N is negative, clear backward instead.
8051 The difference between N and the number of marks cleared is returned."
8053 (gnus-summary-mark-forward n gnus-unread-mark))
8055 (defun gnus-summary-clear-mark-backward (n)
8056 "Clear marks from N articles backward.
8057 The difference between N and the number of marks cleared is returned."
8059 (gnus-summary-mark-forward (- n) gnus-unread-mark))
8061 (defun gnus-summary-mark-unread-as-read ()
8062 "Intended to be used by `gnus-summary-mark-article-hook'."
8063 (when (memq gnus-current-article gnus-newsgroup-unreads)
8064 (gnus-summary-mark-article gnus-current-article gnus-read-mark)))
8066 (defun gnus-summary-mark-read-and-unread-as-read ()
8067 "Intended to be used by `gnus-summary-mark-article-hook'."
8068 (let ((mark (gnus-summary-article-mark)))
8069 (when (or (gnus-unread-mark-p mark)
8070 (gnus-read-mark-p mark))
8071 (gnus-summary-mark-article gnus-current-article gnus-read-mark))))
8073 (defun gnus-summary-mark-region-as-read (point mark all)
8074 "Mark all unread articles between point and mark as read.
8075 If given a prefix, mark all articles between point and mark as read,
8076 even ticked and dormant ones."
8077 (interactive "r\nP")
8086 (memq (setq article (gnus-summary-article-number))
8087 gnus-newsgroup-unreads))
8088 (gnus-summary-mark-article article gnus-del-mark))
8090 (gnus-summary-find-next))))))
8092 (defun gnus-summary-mark-below (score mark)
8093 "Mark articles with score less than SCORE with MARK."
8094 (interactive "P\ncMark: ")
8095 (setq score (if score
8096 (prefix-numeric-value score)
8097 (or gnus-summary-default-score 0)))
8099 (set-buffer gnus-summary-buffer)
8100 (goto-char (point-min))
8103 (and (< (gnus-summary-article-score) score)
8104 (gnus-summary-mark-article nil mark))
8105 (gnus-summary-find-next)))))
8107 (defun gnus-summary-kill-below (&optional score)
8108 "Mark articles with score below SCORE as read."
8110 (gnus-summary-mark-below score gnus-killed-mark))
8112 (defun gnus-summary-clear-above (&optional score)
8113 "Clear all marks from articles with score above SCORE."
8115 (gnus-summary-mark-above score gnus-unread-mark))
8117 (defun gnus-summary-tick-above (&optional score)
8118 "Tick all articles with score above SCORE."
8120 (gnus-summary-mark-above score gnus-ticked-mark))
8122 (defun gnus-summary-mark-above (score mark)
8123 "Mark articles with score over SCORE with MARK."
8124 (interactive "P\ncMark: ")
8125 (setq score (if score
8126 (prefix-numeric-value score)
8127 (or gnus-summary-default-score 0)))
8129 (set-buffer gnus-summary-buffer)
8130 (goto-char (point-min))
8132 (when (> (gnus-summary-article-score) score)
8133 (gnus-summary-mark-article nil mark))
8135 (gnus-summary-find-next)))))
8137 ;; Suggested by Daniel Quinlan <quinlan@best.com>.
8138 (defalias 'gnus-summary-show-all-expunged 'gnus-summary-limit-include-expunged)
8139 (defun gnus-summary-limit-include-expunged (&optional no-error)
8140 "Display all the hidden articles that were expunged for low scores."
8142 (let ((buffer-read-only nil))
8143 (let ((scored gnus-newsgroup-scored)
8146 (unless (gnus-summary-goto-subject (caar scored))
8147 (and (setq h (gnus-summary-article-header (caar scored)))
8148 (< (cdar scored) gnus-summary-expunge-below)
8150 (setq scored (cdr scored)))
8152 (when (not no-error)
8153 (error "No expunged articles hidden"))
8154 (goto-char (point-min))
8155 (gnus-summary-prepare-unthreaded (nreverse headers))
8156 (goto-char (point-min))
8157 (gnus-summary-position-point)
8160 (defun gnus-summary-catchup (&optional all quietly to-here not-mark)
8161 "Mark all unread articles in this newsgroup as read.
8162 If prefix argument ALL is non-nil, ticked and dormant articles will
8163 also be marked as read.
8164 If QUIETLY is non-nil, no questions will be asked.
8165 If TO-HERE is non-nil, it should be a point in the buffer. All
8166 articles before this point will be marked as read.
8167 Note that this function will only catch up the unread article
8168 in the current summary buffer limitation.
8169 The number of articles marked as read is returned."
8174 (not gnus-interactive-catchup) ;Without confirmation?
8178 "Mark absolutely all articles as read? "
8179 "Mark all unread articles as read? ")))
8181 (not gnus-newsgroup-adaptive)
8182 (not gnus-newsgroup-auto-expire)
8183 (not gnus-suppress-duplicates)
8184 (or (not gnus-use-cache)
8185 (eq gnus-use-cache 'passive)))
8188 (setq gnus-newsgroup-marked nil
8189 gnus-newsgroup-dormant nil))
8190 (setq gnus-newsgroup-unreads gnus-newsgroup-downloadable))
8191 ;; We actually mark all articles as canceled, which we
8192 ;; have to do when using auto-expiry or adaptive scoring.
8193 (gnus-summary-show-all-threads)
8194 (when (gnus-summary-first-subject (not all) t)
8196 (if to-here (< (point) to-here) t)
8197 (gnus-summary-mark-article-as-read gnus-catchup-mark)
8198 (gnus-summary-find-next (not all) nil nil t))))
8199 (gnus-set-mode-line 'summary))
8201 (gnus-summary-position-point)))
8203 (defun gnus-summary-catchup-to-here (&optional all)
8204 "Mark all unticked articles before the current one as read.
8205 If ALL is non-nil, also mark ticked and dormant articles as read."
8208 (gnus-save-hidden-threads
8209 (let ((beg (point)))
8210 ;; We check that there are unread articles.
8211 (when (or all (gnus-summary-find-prev))
8212 (gnus-summary-catchup all t beg)))))
8213 (gnus-summary-position-point))
8215 (defun gnus-summary-catchup-all (&optional quietly)
8216 "Mark all articles in this newsgroup as read."
8218 (gnus-summary-catchup t quietly))
8220 (defun gnus-summary-catchup-and-exit (&optional all quietly)
8221 "Mark all articles not marked as unread in this newsgroup as read, then exit.
8222 If prefix argument ALL is non-nil, all articles are marked as read."
8224 (when (gnus-summary-catchup all quietly nil 'fast)
8225 ;; Select next newsgroup or exit.
8226 (if (and (not (gnus-group-quit-config gnus-newsgroup-name))
8227 (eq gnus-auto-select-next 'quietly))
8228 (gnus-summary-next-group nil)
8229 (gnus-summary-exit))))
8231 (defun gnus-summary-catchup-all-and-exit (&optional quietly)
8232 "Mark all articles in this newsgroup as read, and then exit."
8234 (gnus-summary-catchup-and-exit t quietly))
8236 ;; Suggested by "Arne Eofsson" <arne@hodgkin.mbi.ucla.edu>.
8237 (defun gnus-summary-catchup-and-goto-next-group (&optional all)
8238 "Mark all articles in this group as read and select the next group.
8239 If given a prefix, mark all articles, unread as well as ticked, as
8243 (gnus-summary-catchup all))
8244 (gnus-summary-next-article t nil nil t))
8246 ;; Thread-based commands.
8248 (defun gnus-summary-articles-in-thread (&optional article)
8249 "Return a list of all articles in the current thread.
8250 If ARTICLE is non-nil, return all articles in the thread that starts
8252 (let* ((article (or article (gnus-summary-article-number)))
8253 (data (gnus-data-find-list article))
8254 (top-level (gnus-data-level (car data)))
8256 (cond ((null gnus-thread-operation-ignore-subject)
8257 (gnus-simplify-subject-re
8258 (mail-header-subject (gnus-data-header (car data)))))
8259 ((eq gnus-thread-operation-ignore-subject 'fuzzy)
8260 (gnus-simplify-subject-fuzzy
8261 (mail-header-subject (gnus-data-header (car data)))))
8263 (end-point (save-excursion
8264 (if (gnus-summary-go-to-next-thread)
8265 (point) (point-max))))
8268 (< (gnus-data-pos (car data)) end-point))
8269 (when (or (not top-subject)
8270 (string= top-subject
8271 (if (eq gnus-thread-operation-ignore-subject 'fuzzy)
8272 (gnus-simplify-subject-fuzzy
8273 (mail-header-subject
8274 (gnus-data-header (car data))))
8275 (gnus-simplify-subject-re
8276 (mail-header-subject
8277 (gnus-data-header (car data)))))))
8278 (push (gnus-data-number (car data)) articles))
8279 (unless (and (setq data (cdr data))
8280 (> (gnus-data-level (car data)) top-level))
8282 ;; Return the list of articles.
8283 (nreverse articles)))
8285 (defun gnus-summary-rethread-current ()
8286 "Rethread the thread the current article is part of."
8288 (let* ((gnus-show-threads t)
8289 (article (gnus-summary-article-number))
8290 (id (mail-header-id (gnus-summary-article-header)))
8291 (gnus-newsgroup-threads (list (gnus-id-to-thread (gnus-root-id id)))))
8293 (error "No article on the current line"))
8294 (gnus-rebuild-thread id)
8295 (gnus-summary-goto-subject article)))
8297 (defun gnus-summary-reparent-thread ()
8298 "Make the current article child of the marked (or previous) article.
8300 Note that the re-threading will only work if `gnus-thread-ignore-subject'
8301 is non-nil or the Subject: of both articles are the same."
8303 (unless (not (gnus-group-read-only-p))
8304 (error "The current newsgroup does not support article editing"))
8305 (unless (<= (length gnus-newsgroup-processable) 1)
8306 (error "No more than one article may be marked"))
8307 (save-window-excursion
8308 (let ((gnus-article-buffer " *reparent*")
8309 (current-article (gnus-summary-article-number))
8310 ;; First grab the marked article, otherwise one line up.
8311 (parent-article (if (not (null gnus-newsgroup-processable))
8312 (car gnus-newsgroup-processable)
8314 (if (eq (forward-line -1) 0)
8315 (gnus-summary-article-number)
8316 (error "Beginning of summary buffer"))))))
8317 (unless (not (eq current-article parent-article))
8318 (error "An article may not be self-referential"))
8319 (let ((message-id (mail-header-id
8320 (gnus-summary-article-header parent-article))))
8321 (unless (and message-id (not (equal message-id "")))
8322 (error "No message-id in desired parent"))
8323 (gnus-with-article current-article
8324 (goto-char (point-min))
8325 (if (re-search-forward "^References: " nil t)
8327 (re-search-forward "^[^ \t]" nil t)
8330 (insert " " message-id))
8331 (insert "References: " message-id "\n")))
8332 (set-buffer gnus-summary-buffer)
8333 (gnus-summary-unmark-all-processable)
8334 (gnus-summary-update-article current-article)
8335 (gnus-summary-rethread-current)
8336 (gnus-message 3 "Article %d is now the child of article %d"
8337 current-article parent-article)))))
8339 (defun gnus-summary-toggle-threads (&optional arg)
8340 "Toggle showing conversation threads.
8341 If ARG is positive number, turn showing conversation threads on."
8343 (let ((current (or (gnus-summary-article-number) gnus-newsgroup-end)))
8344 (setq gnus-show-threads
8345 (if (null arg) (not gnus-show-threads)
8346 (> (prefix-numeric-value arg) 0)))
8347 (gnus-summary-prepare)
8348 (gnus-summary-goto-subject current)
8349 (gnus-message 6 "Threading is now %s" (if gnus-show-threads "on" "off"))
8350 (gnus-summary-position-point)))
8352 (defun gnus-summary-show-all-threads ()
8356 (let ((buffer-read-only nil))
8357 (subst-char-in-region (point-min) (point-max) ?\^M ?\n t)))
8358 (gnus-summary-position-point))
8360 (defun gnus-summary-show-thread ()
8361 "Show thread subtrees.
8362 Returns nil if no thread was there to be shown."
8364 (let ((buffer-read-only nil)
8366 ;; first goto end then to beg, to have point at beg after let
8367 (end (progn (end-of-line) (point)))
8368 (beg (progn (beginning-of-line) (point))))
8370 ;; Any hidden lines here?
8371 (search-forward "\r" end t)
8372 (subst-char-in-region beg end ?\^M ?\n t)
8374 (gnus-summary-position-point))))
8376 (defun gnus-summary-hide-all-threads ()
8377 "Hide all thread subtrees."
8380 (goto-char (point-min))
8381 (gnus-summary-hide-thread)
8382 (while (zerop (gnus-summary-next-thread 1 t))
8383 (gnus-summary-hide-thread)))
8384 (gnus-summary-position-point))
8386 (defun gnus-summary-hide-thread ()
8387 "Hide thread subtrees.
8388 Returns nil if no threads were there to be hidden."
8390 (let ((buffer-read-only nil)
8392 (article (gnus-summary-article-number)))
8394 ;; Go forward until either the buffer ends or the subthread
8396 (when (and (not (eobp))
8397 (or (zerop (gnus-summary-next-thread 1 t))
8398 (goto-char (point-max))))
8400 (if (and (> (point) start)
8401 (search-backward "\n" start t))
8403 (subst-char-in-region start (point) ?\n ?\^M)
8404 (gnus-summary-goto-subject article))
8407 ;;(gnus-summary-position-point)
8410 (defun gnus-summary-go-to-next-thread (&optional previous)
8411 "Go to the same level (or less) next thread.
8412 If PREVIOUS is non-nil, go to previous thread instead.
8413 Return the article number moved to, or nil if moving was impossible."
8414 (let ((level (gnus-summary-thread-level))
8415 (way (if previous -1 1))
8418 (while (and (not (eobp))
8419 (< level (gnus-summary-thread-level)))
8427 (gnus-summary-article-number)
8430 (defun gnus-summary-next-thread (n &optional silent)
8431 "Go to the same level next N'th thread.
8432 If N is negative, search backward instead.
8433 Returns the difference between N and the number of skips actually
8436 If SILENT, don't output messages."
8438 (let ((backward (< n 0))
8441 (gnus-summary-go-to-next-thread backward))
8444 (gnus-summary-position-point))
8445 (when (and (not silent) (/= 0 n))
8446 (gnus-message 7 "No more threads"))
8449 (defun gnus-summary-prev-thread (n)
8450 "Go to the same level previous N'th thread.
8451 Returns the difference between N and the number of skips actually
8454 (gnus-summary-next-thread (- n)))
8456 (defun gnus-summary-go-down-thread ()
8457 "Go down one level in the current thread."
8458 (let ((children (gnus-summary-article-children)))
8460 (gnus-summary-goto-subject (car children)))))
8462 (defun gnus-summary-go-up-thread ()
8463 "Go up one level in the current thread."
8464 (let ((parent (gnus-summary-article-parent)))
8466 (gnus-summary-goto-subject parent))))
8468 (defun gnus-summary-down-thread (n)
8469 "Go down thread N steps.
8470 If N is negative, go up instead.
8471 Returns the difference between N and how many steps down that were
8477 (if up (gnus-summary-go-up-thread)
8478 (gnus-summary-go-down-thread)))
8480 (gnus-summary-position-point)
8482 (gnus-message 7 "Can't go further"))
8485 (defun gnus-summary-up-thread (n)
8486 "Go up thread N steps.
8487 If N is negative, go up instead.
8488 Returns the difference between N and how many steps down that were
8491 (gnus-summary-down-thread (- n)))
8493 (defun gnus-summary-top-thread ()
8494 "Go to the top of the thread."
8496 (while (gnus-summary-go-up-thread))
8497 (gnus-summary-article-number))
8499 (defun gnus-summary-kill-thread (&optional unmark)
8500 "Mark articles under current thread as read.
8501 If the prefix argument is positive, remove any kinds of marks.
8502 If the prefix argument is negative, tick articles instead."
8505 (setq unmark (prefix-numeric-value unmark)))
8506 (let ((articles (gnus-summary-articles-in-thread)))
8508 ;; Expand the thread.
8509 (gnus-summary-show-thread)
8510 ;; Mark all the articles.
8512 (gnus-summary-goto-subject (car articles))
8513 (cond ((null unmark)
8514 (gnus-summary-mark-article-as-read gnus-killed-mark))
8516 (gnus-summary-mark-article-as-unread gnus-unread-mark))
8518 (gnus-summary-mark-article-as-unread gnus-ticked-mark)))
8519 (setq articles (cdr articles))))
8520 ;; Hide killed subtrees.
8522 gnus-thread-hide-killed
8523 (gnus-summary-hide-thread))
8524 ;; If marked as read, go to next unread subject.
8526 ;; Go to next unread subject.
8527 (gnus-summary-next-subject 1 t)))
8528 (gnus-set-mode-line 'summary))
8530 ;; Summary sorting commands
8532 (defun gnus-summary-sort-by-number (&optional reverse)
8533 "Sort the summary buffer by article number.
8534 Argument REVERSE means reverse order."
8536 (gnus-summary-sort 'number reverse))
8538 (defun gnus-summary-sort-by-author (&optional reverse)
8539 "Sort the summary buffer by author name alphabetically.
8540 If case-fold-search is non-nil, case of letters is ignored.
8541 Argument REVERSE means reverse order."
8543 (gnus-summary-sort 'author reverse))
8545 (defun gnus-summary-sort-by-subject (&optional reverse)
8546 "Sort the summary buffer by subject alphabetically. `Re:'s are ignored.
8547 If case-fold-search is non-nil, case of letters is ignored.
8548 Argument REVERSE means reverse order."
8550 (gnus-summary-sort 'subject reverse))
8552 (defun gnus-summary-sort-by-date (&optional reverse)
8553 "Sort the summary buffer by date.
8554 Argument REVERSE means reverse order."
8556 (gnus-summary-sort 'date reverse))
8558 (defun gnus-summary-sort-by-score (&optional reverse)
8559 "Sort the summary buffer by score.
8560 Argument REVERSE means reverse order."
8562 (gnus-summary-sort 'score reverse))
8564 (defun gnus-summary-sort-by-lines (&optional reverse)
8565 "Sort the summary buffer by article length.
8566 Argument REVERSE means reverse order."
8568 (gnus-summary-sort 'lines reverse))
8570 (defun gnus-summary-sort (predicate reverse)
8571 "Sort summary buffer by PREDICATE. REVERSE means reverse order."
8572 (let* ((thread (intern (format "gnus-thread-sort-by-%s" predicate)))
8573 (article (intern (format "gnus-article-sort-by-%s" predicate)))
8574 (gnus-thread-sort-functions
8579 (gnus-article-sort-functions
8585 (gnus-summary-prepare-hook nil))
8586 ;; We do the sorting by regenerating the threads.
8587 (gnus-summary-prepare)
8588 ;; Hide subthreads if needed.
8589 (when (and gnus-show-threads gnus-thread-hide-subtree)
8590 (gnus-summary-hide-all-threads))))
8592 ;; Summary saving commands.
8594 (defun gnus-summary-save-article (&optional n not-saved)
8595 "Save the current article using the default saver function.
8596 If N is a positive number, save the N next articles.
8597 If N is a negative number, save the N previous articles.
8598 If N is nil and any articles have been marked with the process mark,
8599 save those articles instead.
8600 The variable `gnus-default-article-saver' specifies the saver function."
8602 (let* ((articles (gnus-summary-work-articles n))
8603 (save-buffer (save-excursion
8604 (nnheader-set-temp-buffer " *Gnus Save*")))
8605 (num (length articles))
8607 (dolist (article articles)
8608 (setq header (gnus-summary-article-header article))
8609 (if (not (vectorp header))
8610 ;; This is a pseudo-article.
8611 (if (assq 'name header)
8612 (gnus-copy-file (cdr (assq 'name header)))
8613 (gnus-message 1 "Article %d is unsaveable" article))
8614 ;; This is a real article.
8615 (save-window-excursion
8616 (gnus-summary-select-article t nil nil article))
8618 (set-buffer save-buffer)
8620 (insert-buffer-substring gnus-original-article-buffer))
8621 (setq file (gnus-article-save save-buffer file num))
8622 (gnus-summary-remove-process-mark article)
8624 (gnus-summary-set-saved-mark article))))
8625 (gnus-kill-buffer save-buffer)
8626 (gnus-summary-position-point)
8627 (gnus-set-mode-line 'summary)
8630 (defun gnus-summary-pipe-output (&optional arg)
8631 "Pipe the current article to a subprocess.
8632 If N is a positive number, pipe the N next articles.
8633 If N is a negative number, pipe the N previous articles.
8634 If N is nil and any articles have been marked with the process mark,
8635 pipe those articles instead."
8637 (let ((gnus-default-article-saver 'gnus-summary-save-in-pipe))
8638 (gnus-summary-save-article arg t))
8639 (gnus-configure-windows 'pipe))
8641 (defun gnus-summary-save-article-mail (&optional arg)
8642 "Append the current article to an mail file.
8643 If N is a positive number, save the N next articles.
8644 If N is a negative number, save the N previous articles.
8645 If N is nil and any articles have been marked with the process mark,
8646 save those articles instead."
8648 (let ((gnus-default-article-saver 'gnus-summary-save-in-mail))
8649 (gnus-summary-save-article arg)))
8651 (defun gnus-summary-save-article-rmail (&optional arg)
8652 "Append the current article to an rmail file.
8653 If N is a positive number, save the N next articles.
8654 If N is a negative number, save the N previous articles.
8655 If N is nil and any articles have been marked with the process mark,
8656 save those articles instead."
8658 (let ((gnus-default-article-saver 'gnus-summary-save-in-rmail))
8659 (gnus-summary-save-article arg)))
8661 (defun gnus-summary-save-article-file (&optional arg)
8662 "Append the current article to a file.
8663 If N is a positive number, save the N next articles.
8664 If N is a negative number, save the N previous articles.
8665 If N is nil and any articles have been marked with the process mark,
8666 save those articles instead."
8668 (let ((gnus-default-article-saver 'gnus-summary-save-in-file))
8669 (gnus-summary-save-article arg)))
8671 (defun gnus-summary-write-article-file (&optional arg)
8672 "Write the current article to a file, deleting the previous file.
8673 If N is a positive number, save the N next articles.
8674 If N is a negative number, save the N previous articles.
8675 If N is nil and any articles have been marked with the process mark,
8676 save those articles instead."
8678 (let ((gnus-default-article-saver 'gnus-summary-write-to-file))
8679 (gnus-summary-save-article arg)))
8681 (defun gnus-summary-save-article-body-file (&optional arg)
8682 "Append the current article body to a file.
8683 If N is a positive number, save the N next articles.
8684 If N is a negative number, save the N previous articles.
8685 If N is nil and any articles have been marked with the process mark,
8686 save those articles instead."
8688 (let ((gnus-default-article-saver 'gnus-summary-save-body-in-file))
8689 (gnus-summary-save-article arg)))
8691 (defun gnus-summary-pipe-message (program)
8692 "Pipe the current article through PROGRAM."
8693 (interactive "sProgram: ")
8694 (gnus-summary-select-article)
8695 (let ((mail-header-separator ""))
8696 (gnus-eval-in-buffer-window gnus-article-buffer
8699 (let ((start (window-start))
8701 (message-pipe-buffer-body program)
8702 (set-window-start (get-buffer-window (current-buffer)) start))))))
8704 (defun gnus-get-split-value (methods)
8705 "Return a value based on the split METHODS."
8706 (let (split-name method result match)
8709 (set-buffer gnus-original-article-buffer)
8711 (nnheader-narrow-to-headers)
8713 (goto-char (point-min))
8714 (setq method (pop methods))
8715 (setq match (car method))
8718 ;; Regular expression.
8720 (re-search-forward match nil t)))
8721 ((gnus-functionp match)
8725 (setq result (funcall match gnus-newsgroup-name))))
8730 (setq result (eval match)))))
8731 (setq split-name (append (cdr method) split-name))
8732 (cond ((stringp result)
8733 (push (expand-file-name
8734 result gnus-article-save-directory)
8737 (setq split-name (append result split-name)))))))))
8740 (defun gnus-valid-move-group-p (group)
8743 (symbol-value group)
8746 (car (gnus-find-method-for-group
8747 (symbol-name group))))
8748 gnus-valid-select-methods))))
8750 (defun gnus-read-move-group-name (prompt default articles prefix)
8751 "Read a group name."
8752 (let* ((split-name (gnus-get-split-value gnus-move-split-methods))
8753 (minibuffer-confirm-incomplete nil) ; XEmacs
8757 (if (> (length articles) 1)
8758 (format "these %d articles" (length articles))
8763 (gnus-completing-read default prom
8765 'gnus-valid-move-group-p
8767 'gnus-group-history))
8768 ((= 1 (length split-name))
8769 (gnus-completing-read (car split-name) prom
8771 'gnus-valid-move-group-p
8773 'gnus-group-history))
8775 (gnus-completing-read nil prom
8776 (mapcar (lambda (el) (list el))
8777 (nreverse split-name))
8779 'gnus-group-history)))))
8781 (if (or (string= to-newsgroup "")
8782 (string= to-newsgroup prefix))
8783 (setq to-newsgroup default))
8784 (unless to-newsgroup
8785 (error "No group name entered"))
8786 (or (gnus-active to-newsgroup)
8787 (gnus-activate-group to-newsgroup)
8788 (if (gnus-y-or-n-p (format "No such group: %s. Create it? "
8790 (or (and (gnus-request-create-group
8791 to-newsgroup (gnus-group-name-to-method to-newsgroup))
8792 (gnus-activate-group to-newsgroup nil nil
8793 (gnus-group-name-to-method
8795 (error "Couldn't create group %s" to-newsgroup)))
8796 (error "No such group: %s" to-newsgroup)))
8799 ;; Summary extract commands
8801 (defun gnus-summary-insert-pseudos (pslist &optional not-view)
8802 (let ((buffer-read-only nil)
8803 (article (gnus-summary-article-number))
8805 (unless (gnus-summary-goto-subject article)
8806 (error "No such article: %d" article))
8807 (gnus-summary-position-point)
8808 ;; If all commands are to be bunched up on one line, we collect
8810 (unless gnus-view-pseudos-separately
8811 (let ((ps (setq pslist (sort pslist 'gnus-pseudos<)))
8814 (setq action (cdr (assq 'action (car ps))))
8815 (setq files (list (cdr (assq 'name (car ps)))))
8816 (while (and ps (cdr ps)
8817 (string= (or action "1")
8818 (or (cdr (assq 'action (cadr ps))) "2")))
8819 (push (cdr (assq 'name (cadr ps))) files)
8820 (setcdr ps (cddr ps)))
8822 (when (not (string-match "%s" action))
8825 (when (assq 'execute (car ps))
8826 (setcdr (assq 'execute (car ps))
8827 (funcall (if (string-match "%s" action)
8834 (gnus-quote-arg-for-sh-or-csh f)))
8836 (setq ps (cdr ps)))))
8837 (if (and gnus-view-pseudos (not not-view))
8839 (when (assq 'execute (car pslist))
8840 (gnus-execute-command (cdr (assq 'execute (car pslist)))
8841 (eq gnus-view-pseudos 'not-confirm)))
8842 (setq pslist (cdr pslist)))
8845 (setq after-article (or (cdr (assq 'article (car pslist)))
8846 (gnus-summary-article-number)))
8847 (gnus-summary-goto-subject after-article)
8850 (insert " " (file-name-nondirectory
8851 (cdr (assq 'name (car pslist))))
8852 ": " (or (cdr (assq 'execute (car pslist))) "") "\n")
8854 (forward-line -1) ; back to `b'
8855 (gnus-add-text-properties
8856 b (1- e) (list 'gnus-number gnus-reffed-article-number
8857 gnus-mouse-face-prop gnus-mouse-face))
8859 after-article gnus-reffed-article-number
8860 gnus-unread-mark b (car pslist) 0 (- e b))
8861 (push gnus-reffed-article-number gnus-newsgroup-unreads)
8862 (setq gnus-reffed-article-number (1- gnus-reffed-article-number))
8863 (setq pslist (cdr pslist)))))))
8865 (defun gnus-pseudos< (p1 p2)
8866 (let ((c1 (cdr (assq 'action p1)))
8867 (c2 (cdr (assq 'action p2))))
8868 (and c1 c2 (string< c1 c2))))
8870 (defun gnus-request-pseudo-article (props)
8871 (cond ((assq 'execute props)
8872 (gnus-execute-command (cdr (assq 'execute props)))))
8873 (let ((gnus-current-article (gnus-summary-article-number)))
8874 (gnus-run-hooks 'gnus-mark-article-hook)))
8876 (defun gnus-execute-command (command &optional automatic)
8878 (gnus-article-setup-buffer)
8879 (set-buffer gnus-article-buffer)
8880 (setq buffer-read-only nil)
8881 (let ((command (if automatic command
8882 (read-string "Command: " (cons command 0)))))
8884 (insert "$ " command "\n\n")
8885 (if gnus-view-pseudo-asynchronously
8886 (start-process "gnus-execute" (current-buffer) shell-file-name
8887 shell-command-switch command)
8888 (call-process shell-file-name nil t nil
8889 shell-command-switch command)))))
8891 ;; Summary kill commands.
8893 (defun gnus-summary-edit-global-kill (article)
8894 "Edit the \"global\" kill file."
8895 (interactive (list (gnus-summary-article-number)))
8896 (gnus-group-edit-global-kill article))
8898 (defun gnus-summary-edit-local-kill ()
8899 "Edit a local kill file applied to the current newsgroup."
8901 (setq gnus-current-headers (gnus-summary-article-header))
8902 (gnus-group-edit-local-kill
8903 (gnus-summary-article-number) gnus-newsgroup-name))
8907 (defun gnus-read-header (id &optional header)
8908 "Read the headers of article ID and enter them into the Gnus system."
8909 (let ((group gnus-newsgroup-name)
8910 (gnus-override-method
8911 (and (gnus-news-group-p gnus-newsgroup-name)
8912 gnus-refer-article-method))
8914 ;; First we check to see whether the header in question is already
8917 ;; This is a Message-ID.
8918 (setq header (or header (gnus-id-to-header id)))
8919 ;; This is an article number.
8920 (setq header (or header (gnus-summary-article-header id))))
8922 (not (gnus-summary-article-sparse-p (mail-header-number header))))
8923 ;; We have found the header.
8925 ;; If this is a sparse article, we have to nix out its
8926 ;; previous entry in the thread hashtb.
8928 (gnus-summary-article-sparse-p (mail-header-number header)))
8929 (let* ((parent (gnus-parent-id (mail-header-references header)))
8930 (thread (and parent (gnus-id-to-thread parent))))
8932 (delq (assq header thread) thread))))
8933 ;; We have to really fetch the header to this article.
8935 (set-buffer nntp-server-buffer)
8936 (when (setq where (gnus-request-head id group))
8937 (nnheader-fold-continuation-lines)
8938 (goto-char (point-max))
8940 (goto-char (point-min))
8944 ((cdr where) (cdr where))
8945 (header (mail-header-number header))
8946 (t gnus-reffed-article-number))
8948 (insert " Article retrieved.\n"))
8950 (not (setq header (car (gnus-get-newsgroup-headers nil t)))))
8951 () ; Malformed head.
8952 (unless (gnus-summary-article-sparse-p (mail-header-number header))
8953 (when (and (stringp id)
8954 (not (string= (gnus-group-real-name group)
8956 ;; If we fetched by Message-ID and the article came
8957 ;; from a different group, we fudge some bogus article
8958 ;; numbers for this article.
8959 (mail-header-set-number header gnus-reffed-article-number))
8961 (set-buffer gnus-summary-buffer)
8962 (decf gnus-reffed-article-number)
8963 (gnus-remove-header (mail-header-number header))
8964 (push header gnus-newsgroup-headers)
8965 (setq gnus-current-headers header)
8966 (push (mail-header-number header) gnus-newsgroup-limit)))
8969 (defun gnus-remove-header (number)
8970 "Remove header NUMBER from `gnus-newsgroup-headers'."
8971 (if (and gnus-newsgroup-headers
8972 (= number (mail-header-number (car gnus-newsgroup-headers))))
8973 (pop gnus-newsgroup-headers)
8974 (let ((headers gnus-newsgroup-headers))
8975 (while (and (cdr headers)
8976 (not (= number (mail-header-number (cadr headers)))))
8979 (setcdr headers (cddr headers))))))
8982 ;;; summary highlights
8985 (defun gnus-highlight-selected-summary ()
8986 ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
8987 ;; Highlight selected article in summary buffer
8988 (when gnus-summary-selected-face
8990 (let* ((beg (progn (beginning-of-line) (point)))
8991 (end (progn (end-of-line) (point)))
8992 ;; Fix by Mike Dugan <dugan@bucrf16.bu.edu>.
8993 (from (if (get-text-property beg gnus-mouse-face-prop)
8995 (or (next-single-property-change
8996 beg gnus-mouse-face-prop nil end)
9001 (or (next-single-property-change
9002 from gnus-mouse-face-prop nil end)
9004 ;; If no mouse-face prop on line we will have to = from = end,
9005 ;; so we highlight the entire line instead.
9006 (when (= (+ to 2) from)
9009 (if gnus-newsgroup-selected-overlay
9010 ;; Move old overlay.
9012 gnus-newsgroup-selected-overlay from to (current-buffer))
9013 ;; Create new overlay.
9015 (setq gnus-newsgroup-selected-overlay (gnus-make-overlay from to))
9016 'face gnus-summary-selected-face))))))
9018 ;; New implementation by Christian Limpach <Christian.Limpach@nice.ch>.
9019 (defun gnus-summary-highlight-line ()
9020 "Highlight current line according to `gnus-summary-highlight'."
9021 (let* ((list gnus-summary-highlight)
9023 (end (progn (end-of-line) (point)))
9024 ;; now find out where the line starts and leave point there.
9025 (beg (progn (beginning-of-line) (point)))
9026 (article (gnus-summary-article-number))
9027 (score (or (cdr (assq (or article gnus-current-article)
9028 gnus-newsgroup-scored))
9029 gnus-summary-default-score 0))
9030 (mark (or (gnus-summary-article-mark) gnus-unread-mark))
9031 (inhibit-read-only t))
9032 ;; Eval the cars of the lists until we find a match.
9033 (let ((default gnus-summary-default-score))
9035 (not (eval (caar list))))
9036 (setq list (cdr list))))
9037 (let ((face (cdar list)))
9038 (unless (eq face (get-text-property beg 'face))
9039 (gnus-put-text-property-excluding-characters-with-faces
9041 (setq face (if (boundp face) (symbol-value face) face)))
9042 (when gnus-summary-highlight-line-function
9043 (funcall gnus-summary-highlight-line-function article face))))
9046 (defun gnus-update-read-articles (group unread &optional compute)
9047 "Update the list of read articles in GROUP."
9048 (let* ((active (or gnus-newsgroup-active (gnus-active group)))
9049 (entry (gnus-gethash group gnus-newsrc-hashtb))
9050 (info (nth 2 entry))
9052 (unread (sort (copy-sequence unread) '<))
9054 (if (or (not info) (not active))
9055 ;; There is no info on this group if it was, in fact,
9056 ;; killed. Gnus stores no information on killed groups, so
9057 ;; there's nothing to be done.
9058 ;; One could store the information somewhere temporarily,
9059 ;; perhaps... Hmmm...
9061 ;; Remove any negative articles numbers.
9062 (while (and unread (< (car unread) 0))
9063 (setq unread (cdr unread)))
9064 ;; Remove any expired article numbers
9065 (while (and unread (< (car unread) (car active)))
9066 (setq unread (cdr unread)))
9067 ;; Compute the ranges of read articles by looking at the list of
9070 (when (/= (car unread) prev)
9071 (push (if (= prev (1- (car unread))) prev
9072 (cons prev (1- (car unread))))
9074 (setq prev (1+ (car unread)))
9075 (setq unread (cdr unread)))
9076 (when (<= prev (cdr active))
9077 (push (cons prev (cdr active)) read))
9078 (setq read (if (> (length read) 1) (nreverse read) read))
9082 (set-buffer gnus-group-buffer)
9085 (gnus-info-set-marks ',info ',(gnus-info-marks info) t)
9086 (gnus-info-set-read ',info ',(gnus-info-read info))
9087 (gnus-get-unread-articles-in-group ',info (gnus-active ,group))
9088 (gnus-group-update-group ,group t))))
9089 ;; Propagate the read marks to the backend.
9090 (if (gnus-check-backend-function 'request-set-mark group)
9091 (let ((del (gnus-remove-from-range (gnus-info-read info) read))
9092 (add (gnus-remove-from-range read (gnus-info-read info))))
9094 (gnus-request-set-mark
9095 group (delq nil (list (if add (list add 'add '(read)))
9096 (if del (list del 'del '(read)))))))))
9097 ;; Enter this list into the group info.
9098 (gnus-info-set-read info read)
9099 ;; Set the number of unread articles in gnus-newsrc-hashtb.
9100 (gnus-get-unread-articles-in-group info (gnus-active group))
9103 (defun gnus-offer-save-summaries ()
9104 "Offer to save all active summary buffers."
9106 (let ((buflist (buffer-list))
9108 ;; Go through all buffers and find all summaries.
9110 (and (setq bufname (buffer-name (car buflist)))
9111 (string-match "Summary" bufname)
9113 (set-buffer bufname)
9114 ;; We check that this is, indeed, a summary buffer.
9115 (and (eq major-mode 'gnus-summary-mode)
9116 ;; Also make sure this isn't bogus.
9117 gnus-newsgroup-prepared
9118 ;; Also make sure that this isn't a dead summary buffer.
9119 (not gnus-dead-summary-mode)))
9120 (push bufname buffers))
9121 (setq buflist (cdr buflist)))
9122 ;; Go through all these summary buffers and offer to save them.
9125 "Update summary buffer %s? "
9127 (switch-to-buffer buf)
9128 (gnus-summary-exit))
9132 ;;; @ for mime-partial
9135 (defun gnus-request-partial-message ()
9137 (let ((number (gnus-summary-article-number))
9138 (group gnus-newsgroup-name)
9139 (mother gnus-article-buffer))
9140 (set-buffer (get-buffer-create " *Partial Article*"))
9142 (setq mime-preview-buffer mother)
9143 (gnus-request-article-this-buffer number group)
9147 (autoload 'mime-combine-message/partial-pieces-automatically
9149 "Internal method to combine message/partial messages automatically.")
9152 'action '((type . message)(subtype . partial)
9153 (major-mode . gnus-original-article-mode)
9154 (method . mime-combine-message/partial-pieces-automatically)
9155 (summary-buffer-exp . gnus-summary-buffer)
9156 (request-partial-message-method . gnus-request-partial-message)
9160 ;;; @ for message/rfc822
9163 (defun gnus-mime-extract-message/rfc822 (entity situation)
9164 (let (group article num cwin swin cur)
9165 (with-current-buffer (mime-entity-buffer entity)
9167 (narrow-to-region (mime-entity-body-start entity)
9168 (mime-entity-body-end entity))
9169 (setq group (or (cdr (assq 'group situation))
9170 (completing-read "Group: "
9173 (gnus-read-active-file-p)
9174 gnus-newsgroup-name))
9175 article (gnus-request-accept-article group)
9178 (when (and (consp article)
9179 (numberp (setq article (cdr article))))
9180 (setq num (1+ (or (cdr (assq 'number situation)) 0))
9181 cwin (get-buffer-window (current-buffer) t)
9183 (save-window-excursion
9184 (if (setq swin (get-buffer-window gnus-summary-buffer t))
9185 (select-window swin)
9186 (set-buffer gnus-summary-buffer)
9188 (setq cur gnus-current-article)
9190 (let (gnus-show-threads)
9191 (gnus-summary-goto-subject article t)
9193 (gnus-summary-clear-mark-forward 1)
9194 (gnus-summary-goto-subject cur)
9196 (when (and cwin (window-frame cwin))
9197 (select-frame (window-frame cwin))
9199 (when (boundp 'mime-acting-situation-to-override)
9200 (set-alist 'mime-acting-situation-to-override
9203 (set-alist 'mime-acting-situation-to-override
9206 (save-current-buffer
9207 (set-buffer gnus-group-buffer)
9208 (gnus-activate-group ,group)
9210 (gnus-summary-goto-article ,cur
9211 gnus-show-all-headers)
9213 (set-alist 'mime-acting-situation-to-override
9219 'action '((type . message)(subtype . rfc822)
9220 (major-mode . gnus-original-article-mode)
9221 (method . gnus-mime-extract-message/rfc822)
9226 'action '((type . message)(subtype . news)
9227 (major-mode . gnus-original-article-mode)
9228 (method . gnus-mime-extract-message/rfc822)
9232 (defun gnus-mime-extract-multipart (entity situation)
9233 (let ((children (mime-entity-children entity))
9234 mime-acting-situation-to-override
9237 (mime-play-entity (car children)
9238 (cons (assq 'mode situation)
9239 mime-acting-situation-to-override))
9240 (setq children (cdr children)))
9241 (if (setq f (cdr (assq 'after-method
9242 mime-acting-situation-to-override)))
9247 'action '((type . multipart)
9248 (method . gnus-mime-extract-multipart)
9257 (defun gnus-summary-setup-default-charset ()
9258 "Setup newsgroup default charset."
9259 (let ((name (and gnus-newsgroup-name
9260 (gnus-group-real-name gnus-newsgroup-name))))
9261 (setq gnus-newsgroup-charset
9262 (or (and gnus-newsgroup-name
9263 (or (gnus-group-find-parameter gnus-newsgroup-name
9265 (let ((alist gnus-group-charset-alist)
9267 (while (setq elem (pop alist))
9269 (string-match (car elem) name))
9271 charset (cadr elem))))
9273 gnus-default-charset))))
9279 (defun gnus-summary-display-buttonized (&optional show-all-parts)
9280 "Display the current article buffer fully MIME-buttonized.
9281 If SHOW-ALL-PARTS (the prefix) is non-nil, all multipart/* parts are
9282 treated as multipart/mixed."
9285 (let ((gnus-unbuttonized-mime-types nil)
9286 (gnus-mime-display-multipart-as-mixed show-all-parts))
9287 (gnus-summary-show-article)))
9289 (defun gnus-summary-repair-multipart (article)
9290 "Add a Content-Type header to a multipart article without one."
9291 (interactive (list (gnus-summary-article-number)))
9292 (gnus-with-article article
9293 (message-narrow-to-head)
9294 (goto-char (point-max))
9296 (when (search-forward "\n--" nil t)
9297 (let ((separator (buffer-substring (point) (gnus-point-at-eol))))
9298 (message-narrow-to-head)
9299 (message-remove-header "Mime-Version")
9300 (message-remove-header "Content-Type")
9301 (goto-char (point-max))
9302 (insert (format "Content-Type: multipart/mixed; boundary=\"%s\"\n"
9304 (insert "Mime-Version: 1.0\n")
9306 (let (gnus-mark-article-hook)
9307 (gnus-summary-select-article t t nil article)))
9309 (defun gnus-summary-toggle-display-buttonized ()
9310 "Toggle the buttonizing of the article buffer."
9313 (if (setq gnus-inhibit-mime-unbuttonizing
9314 (not gnus-inhibit-mime-unbuttonizing))
9315 (let ((gnus-unbuttonized-mime-types nil))
9316 (gnus-summary-show-article))
9317 (gnus-summary-show-article)))
9323 (run-hooks 'gnus-sum-load-hook)
9325 ;;; gnus-sum.el ends here